Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp433048ybl; Wed, 11 Dec 2019 21:58:16 -0800 (PST) X-Google-Smtp-Source: APXvYqw3HP2HboT230blbaeoCU5i0vKbUJ5qQMnHar+bPMbE+dOdZEUaWZnFugW7PD6CyQ//Hcvm X-Received: by 2002:a05:6830:2098:: with SMTP id y24mr6405289otq.312.1576130296364; Wed, 11 Dec 2019 21:58:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576130296; cv=none; d=google.com; s=arc-20160816; b=ugPSNNBicEPEIb67Y2nUt/CMABtrAv/uoJ1zU6nuPiy2ifoUZzmVlRkL6uHhCE+8f2 CWoAu+g1jZyUSBD/kInb1tsTa/atBodOQ4Q4Pdxa1s4QG1mOuyj+RVeoKnVp9cKvJtRR Y9J0e53TiZQhU6FMtHAF36gB9VcuoObMy+RCUWtPmCjczvLuYHUJPXLwZRhAWqeyVI5F wQLqFrwLGCzp8MCW93lDv98PQrUw/+F7bfYeYIYz5DSfOfJ3kdaMsAd/xrQHIB2oHZqR ATZFklzZeE+OxjvIrR6aHTsJOejSHyu8AGljUY1hTgP030LjTOBkzdJHsMp6a8yPKbv2 Ij1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=8QBINfV+5viQ33x4JNBf4ll2wZeQgtfbVXNY7lCFDkE=; b=NDXsvjEiY2Hh9TIheT/3eZdJGv3NqDWHDoSWYksuwifLg7QWQAesd50JXKHlnmIBf2 T3lvQQ5D3ALguWIN3JBBrl8voyPTvGpM1V8dxC9HLgJjls117XdRkdOaUVa6s6uJ1iok AJ8+FQ0UZpXXgUu/p2u6nci70RD8GJt+cd6iC4Vxv33T3dFFGqxg1Ozh9Re9Haf+q+fJ A7Gqqh4OKh9VnGcXyP7zlIX/EvnwK4GZUaXjYwOq2x1nYskPzJnxuJBMG8J2HWjvvSss Oa/nQ+E33Q/mWLo88JHJ6cSWROfvU5JpTt2mK35bH+v+ZztRzPrvuq/u89J83OXcH4rx jWXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o67si2591107oig.49.2019.12.11.21.58.03; Wed, 11 Dec 2019 21:58:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727968AbfLLF4s (ORCPT + 99 others); Thu, 12 Dec 2019 00:56:48 -0500 Received: from mga04.intel.com ([192.55.52.120]:16608 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726833AbfLLF4q (ORCPT ); Thu, 12 Dec 2019 00:56:46 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Dec 2019 21:56:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,304,1571727600"; d="scan'208";a="216003836" Received: from twinkler-lnx.jer.intel.com ([10.12.91.155]) by orsmga006.jf.intel.com with ESMTP; 11 Dec 2019 21:56:43 -0800 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , linux-kernel@vger.kernel.org, Tomas Winkler , stable@vger.kernel.org, Ramalingam C Subject: [char-misc-next] mei: hdcp: bind only with i915 on the same PCH Date: Thu, 12 Dec 2019 10:41:03 +0200 Message-Id: <20191212084103.2893-1-tomas.winkler@intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The mei device and i915 must reside on the same PCH in order for HDCP to work. Make the component matching function enforce this requirement. hdcp | i915 mei | | +----= PCH =----+ Cc: v5.0+ Cc: Ramalingam C Signed-off-by: Tomas Winkler Reviewed-by: Alexander Usyskin --- drivers/misc/mei/hdcp/mei_hdcp.c | 33 +++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/misc/mei/hdcp/mei_hdcp.c b/drivers/misc/mei/hdcp/mei_hdcp.c index 93027fd96c71..4c596c646ac0 100644 --- a/drivers/misc/mei/hdcp/mei_hdcp.c +++ b/drivers/misc/mei/hdcp/mei_hdcp.c @@ -757,11 +757,38 @@ static const struct component_master_ops mei_component_master_ops = { .unbind = mei_component_master_unbind, }; +/** + * mei_hdcp_component_match - compare function for matching mei hdcp. + * + * The function checks if the driver is i915, the subcomponent is HDCP + * and the grand parent of hdcp and the parent of i915 are the same + * PCH device. + * + * @dev: master device + * @subcomponent: subcomponent to match (I915_COMPONENT_HDCP) + * @data: compare data (mei hdcp device) + * + * Return: + * * 1 - if components match + * * 0 - otherwise + */ static int mei_hdcp_component_match(struct device *dev, int subcomponent, void *data) { - return !strcmp(dev->driver->name, "i915") && - subcomponent == I915_COMPONENT_HDCP; + struct device *base = data; + + if (strcmp(dev->driver->name, "i915") || + subcomponent != I915_COMPONENT_HDCP) + return 0; + + base = base->parent; + if (!base) + return 0; + + base = base->parent; + dev = dev->parent; + + return (base && dev && dev == base); } static int mei_hdcp_probe(struct mei_cl_device *cldev, @@ -785,7 +812,7 @@ static int mei_hdcp_probe(struct mei_cl_device *cldev, master_match = NULL; component_match_add_typed(&cldev->dev, &master_match, - mei_hdcp_component_match, comp_master); + mei_hdcp_component_match, &cldev->dev); if (IS_ERR_OR_NULL(master_match)) { ret = -ENOMEM; goto err_exit; -- 2.21.0