From nobody Thu Apr 9 11:40:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 424FDC636CC for ; Sun, 5 Feb 2023 18:11:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229585AbjBESLw (ORCPT ); Sun, 5 Feb 2023 13:11:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbjBESLr (ORCPT ); Sun, 5 Feb 2023 13:11:47 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F37A21717B for ; Sun, 5 Feb 2023 10:11:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675620706; x=1707156706; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yTjnbKpGMVcECZTzY6FB808WfcV0N8+6Eb4IlYgwXDU=; b=FQU1mMOVW/4Z3P8tSlmz6i456fYqItcRbIKdNXLFfRcDF3yoNyLbIjL2 EBeFAbVtU8O4Qhye0n42P0lTD/0QO/r2lv5PIFWPyLbYbijrFThZbubnk +8UCIsk3zpZ6Cc9utt4bf2aHfB3GFeG6MCt0DvFfNKRkCj7rSfQIai7TG tbwZiq2UQ1+QrcXJcBoyR7OJqsbWONlw3L2yYnv60MrH8Nu35yp+phGGb r3qC3CLCGzXYB9C1+On8zFm+xqkB7KJGTPdmtqGK69Uwa9Ce0SlKMBb+Y FQpjhZAaeA0HWFx+RDPQfHKPjmlmBSDQuAcBtLIdy3oynR7khNYUn8vF/ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10612"; a="326762225" X-IronPort-AV: E=Sophos;i="5.97,275,1669104000"; d="scan'208";a="326762225" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2023 10:11:46 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10612"; a="666286300" X-IronPort-AV: E=Sophos;i="5.97,275,1669104000"; d="scan'208";a="666286300" Received: from twinkler-lnx.jer.intel.com ([10.12.87.42]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2023 10:11:44 -0800 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , Vitaly Lubart , linux-kernel@vger.kernel.org, Tomas Winkler Subject: [char-misc-next v2 1/2] drm/i915/mtl: Define GSC Proxy component interface Date: Sun, 5 Feb 2023 20:11:31 +0200 Message-Id: <20230205181132.191064-2-tomas.winkler@intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230205181132.191064-1-tomas.winkler@intel.com> References: <20230205181132.191064-1-tomas.winkler@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Usyskin GSC Proxy component is used for communication between the Intel graphics driver and MEI driver. Signed-off-by: Alexander Usyskin Signed-off-by: Tomas Winkler --- V2: This patch was missing in the first series. MAINTAINERS | 1 + include/drm/i915_component.h | 3 +- include/drm/i915_gsc_proxy_mei_interface.h | 36 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 include/drm/i915_gsc_proxy_mei_interface.h diff --git a/MAINTAINERS b/MAINTAINERS index c81bbb771678..2c432b4d8506 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10570,6 +10570,7 @@ S: Supported F: Documentation/driver-api/mei/* F: drivers/misc/mei/ F: drivers/watchdog/mei_wdt.c +F: include/drm/i915_gsc_proxy_mei_interface.h F: include/linux/mei_aux.h F: include/linux/mei_cl_bus.h F: include/uapi/linux/mei.h diff --git a/include/drm/i915_component.h b/include/drm/i915_component.h index c1e2a43d2d1e..56a84ee1c64c 100644 --- a/include/drm/i915_component.h +++ b/include/drm/i915_component.h @@ -29,7 +29,8 @@ enum i915_component_type { I915_COMPONENT_AUDIO =3D 1, I915_COMPONENT_HDCP, - I915_COMPONENT_PXP + I915_COMPONENT_PXP, + I915_COMPONENT_GSC_PROXY, }; =20 /* MAX_PORT is the number of port diff --git a/include/drm/i915_gsc_proxy_mei_interface.h b/include/drm/i915_= gsc_proxy_mei_interface.h new file mode 100644 index 000000000000..e817bb316d5c --- /dev/null +++ b/include/drm/i915_gsc_proxy_mei_interface.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright (c) 2022-2023 Intel Corporation + */ + +#ifndef _I915_GSC_PROXY_MEI_INTERFACE_H_ +#define _I915_GSC_PROXY_MEI_INTERFACE_H_ + +#include +#include + +/** + * struct i915_gsc_proxy_component_ops - ops for GSC Proxy services. + * @owner: Module providing the ops + * @send: sends data through GSC proxy + * @recv: receives data through GSC proxy + */ +struct i915_gsc_proxy_component_ops { + struct module *owner; + + int (*send)(struct device *dev, const void *buf, size_t size); + int (*recv)(struct device *dev, void *buf, size_t size); +}; + +/** + * struct i915_gsc_proxy_component - Used for communication between i915 a= nd + * MEI drivers for GSC proxy services + * @mei_dev: device that provide the GSC proxy service. + * @ops: Ops implemented by GSC proxy driver, used by i915 driver. + */ +struct i915_gsc_proxy_component { + struct device *mei_dev; + const struct i915_gsc_proxy_component_ops *ops; +}; + +#endif /* _I915_GSC_PROXY_MEI_INTERFACE_H_ */ --=20 2.39.1 From nobody Thu Apr 9 11:40:42 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52A56C636D6 for ; Sun, 5 Feb 2023 18:11:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229599AbjBESLy (ORCPT ); Sun, 5 Feb 2023 13:11:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbjBESLu (ORCPT ); Sun, 5 Feb 2023 13:11:50 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6278618146 for ; Sun, 5 Feb 2023 10:11:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675620709; x=1707156709; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e5eXOdl27KCUi1a/V5eS0CiWUs6fBfGXPxKfqeyqe/E=; b=gBoFKXE5fLNnng0SrzUBAqpeCayxzF2YFqY9M6MHVQ5RhfbIH7kssUPZ V3rkdgrsmloNX249FmThkg4Hi14+e5Yk6FCJuKqFZkitLAPQBaawONdze ry4wsMuSD3URc9DiXMyKwWX+tN/EyI/uUOfxOsUyD1y734dw+2HZSqy/O UqhtuyTWvls7l1XLLyB6xUCscdRK+gOG8KLqh7exilYkpzu30yy54McQI BvTlPNERW3ay9vP8N1eTKtZLdJoRAKStXvRHSoFyRDZ5P+oBX+SB7YBZK iIIQ3wDiWcqsE34O7+TwigjxQ2YecJWvCt7ssSvet1jc3sLgNQBYECpOF g==; X-IronPort-AV: E=McAfee;i="6500,9779,10612"; a="326762227" X-IronPort-AV: E=Sophos;i="5.97,275,1669104000"; d="scan'208";a="326762227" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2023 10:11:48 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10612"; a="666286309" X-IronPort-AV: E=Sophos;i="5.97,275,1669104000"; d="scan'208";a="666286309" Received: from twinkler-lnx.jer.intel.com ([10.12.87.42]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2023 10:11:46 -0800 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , Vitaly Lubart , linux-kernel@vger.kernel.org, Tomas Winkler Subject: [char-misc-next v2 2/2] mei: gsc_proxy: add gsc proxy driver Date: Sun, 5 Feb 2023 20:11:32 +0200 Message-Id: <20230205181132.191064-3-tomas.winkler@intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230205181132.191064-1-tomas.winkler@intel.com> References: <20230205181132.191064-1-tomas.winkler@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Alexander Usyskin Add GSC proxy driver. It to allows messaging between GSC component on Intel on board graphics card and CSE device. Signed-off-by: Alexander Usyskin Signed-off-by: Tomas Winkler --- V2: refactor match function use device information instead of driver name to identify the aggregate device. drivers/misc/mei/Kconfig | 2 +- drivers/misc/mei/Makefile | 1 + drivers/misc/mei/gsc_proxy/Kconfig | 14 ++ drivers/misc/mei/gsc_proxy/Makefile | 7 + drivers/misc/mei/gsc_proxy/mei_gsc_proxy.c | 208 +++++++++++++++++++++ 5 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 drivers/misc/mei/gsc_proxy/Kconfig create mode 100644 drivers/misc/mei/gsc_proxy/Makefile create mode 100644 drivers/misc/mei/gsc_proxy/mei_gsc_proxy.c diff --git a/drivers/misc/mei/Kconfig b/drivers/misc/mei/Kconfig index d21486d69df2..37db142de413 100644 --- a/drivers/misc/mei/Kconfig +++ b/drivers/misc/mei/Kconfig @@ -62,4 +62,4 @@ config INTEL_MEI_GSC =20 source "drivers/misc/mei/hdcp/Kconfig" source "drivers/misc/mei/pxp/Kconfig" - +source "drivers/misc/mei/gsc_proxy/Kconfig" diff --git a/drivers/misc/mei/Makefile b/drivers/misc/mei/Makefile index fb740d754900..14aee253ae48 100644 --- a/drivers/misc/mei/Makefile +++ b/drivers/misc/mei/Makefile @@ -30,3 +30,4 @@ CFLAGS_mei-trace.o =3D -I$(src) =20 obj-$(CONFIG_INTEL_MEI_HDCP) +=3D hdcp/ obj-$(CONFIG_INTEL_MEI_PXP) +=3D pxp/ +obj-$(CONFIG_INTEL_MEI_GSC_PROXY) +=3D gsc_proxy/ diff --git a/drivers/misc/mei/gsc_proxy/Kconfig b/drivers/misc/mei/gsc_prox= y/Kconfig new file mode 100644 index 000000000000..fd45ce8c1df4 --- /dev/null +++ b/drivers/misc/mei/gsc_proxy/Kconfig @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2022-2023, Intel Corporation. All rights reserved. +# +config INTEL_MEI_GSC_PROXY + tristate "Intel GSC Proxy services of ME Interface" + select INTEL_MEI_ME + depends on DRM_I915 + help + MEI Support for GSC Proxy Services on Intel platforms. + + MEI GSC proxy enables messaging between GSC service on + Intel graphics on-board card and services on CSE (MEI) + firmware residing SoC or PCH. + diff --git a/drivers/misc/mei/gsc_proxy/Makefile b/drivers/misc/mei/gsc_pro= xy/Makefile new file mode 100644 index 000000000000..358847e9aaa9 --- /dev/null +++ b/drivers/misc/mei/gsc_proxy/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (c) 2022-2023, Intel Corporation. All rights reserved. +# +# Makefile - GSC Proxy client driver for Intel MEI Bus Driver. + +obj-$(CONFIG_INTEL_MEI_GSC_PROXY) +=3D mei_gsc_proxy.o diff --git a/drivers/misc/mei/gsc_proxy/mei_gsc_proxy.c b/drivers/misc/mei/= gsc_proxy/mei_gsc_proxy.c new file mode 100644 index 000000000000..953eda1a16fb --- /dev/null +++ b/drivers/misc/mei/gsc_proxy/mei_gsc_proxy.c @@ -0,0 +1,208 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022-2023 Intel Corporation + */ + +/** + * DOC: MEI_GSC_PROXY Client Driver + * + * The mei_gsc_proxy driver acts as a translation layer between + * proxy user (I915) and ME FW by proxying messages to ME FW + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * mei_gsc_proxy_send - Sends a proxy message to ME FW. + * @dev: device corresponding to the mei_cl_device + * @buf: a message buffer to send + * @size: size of the message + * Return: bytes sent on Success, <0 on Failure + */ +static int mei_gsc_proxy_send(struct device *dev, const void *buf, size_t = size) +{ + ssize_t ret; + + if (!dev || !buf) + return -EINVAL; + + ret =3D mei_cldev_send(to_mei_cl_device(dev), buf, size); + if (ret < 0) + dev_dbg(dev, "mei_cldev_send failed. %zd\n", ret); + + return ret; +} + +/** + * mei_gsc_proxy_recv - Receives a proxy message from ME FW. + * @dev: device corresponding to the mei_cl_device + * @buf: a message buffer to contain the received message + * @size: size of the buffer + * Return: bytes received on Success, <0 on Failure + */ +static int mei_gsc_proxy_recv(struct device *dev, void *buf, size_t size) +{ + ssize_t ret; + + if (!dev || !buf) + return -EINVAL; + + ret =3D mei_cldev_recv(to_mei_cl_device(dev), buf, size); + if (ret < 0) + dev_dbg(dev, "mei_cldev_recv failed. %zd\n", ret); + + return ret; +} + +static const struct i915_gsc_proxy_component_ops mei_gsc_proxy_ops =3D { + .owner =3D THIS_MODULE, + .send =3D mei_gsc_proxy_send, + .recv =3D mei_gsc_proxy_recv, +}; + +static int mei_component_master_bind(struct device *dev) +{ + struct mei_cl_device *cldev =3D to_mei_cl_device(dev); + struct i915_gsc_proxy_component *comp_master =3D mei_cldev_get_drvdata(cl= dev); + + comp_master->ops =3D &mei_gsc_proxy_ops; + comp_master->mei_dev =3D dev; + return component_bind_all(dev, comp_master); +} + +static void mei_component_master_unbind(struct device *dev) +{ + struct mei_cl_device *cldev =3D to_mei_cl_device(dev); + struct i915_gsc_proxy_component *comp_master =3D mei_cldev_get_drvdata(cl= dev); + + component_unbind_all(dev, comp_master); +} + +static const struct component_master_ops mei_component_master_ops =3D { + .bind =3D mei_component_master_bind, + .unbind =3D mei_component_master_unbind, +}; + +/** + * mei_gsc_proxy_component_match - compare function for matching mei. + * + * The function checks if the device is pci device and + * Intel VGA adapter, the subcomponent is SW Proxy + * and the parent of MEI PCI and the parent of VGA are the same PCH dev= ice. + * + * @dev: master device + * @subcomponent: subcomponent to match (I915_COMPONENT_SWPROXY) + * @data: compare data (mei pci parent) + * + * Return: + * * 1 - if components match + * * 0 - otherwise + */ +static int mei_gsc_proxy_component_match(struct device *dev, int subcompon= ent, + void *data) +{ + struct pci_dev *pdev; + + if (!dev_is_pci(dev)) + return 0; + + pdev =3D to_pci_dev(dev); + + if (pdev->class !=3D (PCI_CLASS_DISPLAY_VGA << 8) || + pdev->vendor !=3D PCI_VENDOR_ID_INTEL) + return 0; + + if (subcomponent !=3D I915_COMPONENT_GSC_PROXY) + return 0; + + return component_compare_dev(dev->parent, ((struct device *)data)->parent= ); +} + +static int mei_gsc_proxy_probe(struct mei_cl_device *cldev, + const struct mei_cl_device_id *id) +{ + struct i915_gsc_proxy_component *comp_master; + struct component_match *master_match =3D NULL; + int ret; + + ret =3D mei_cldev_enable(cldev); + if (ret < 0) { + dev_err(&cldev->dev, "mei_cldev_enable Failed. %d\n", ret); + goto enable_err_exit; + } + + comp_master =3D kzalloc(sizeof(*comp_master), GFP_KERNEL); + if (!comp_master) { + ret =3D -ENOMEM; + goto err_exit; + } + + component_match_add_typed(&cldev->dev, &master_match, + mei_gsc_proxy_component_match, cldev->dev.parent); + if (IS_ERR_OR_NULL(master_match)) { + ret =3D -ENOMEM; + goto err_exit; + } + + mei_cldev_set_drvdata(cldev, comp_master); + ret =3D component_master_add_with_match(&cldev->dev, + &mei_component_master_ops, + master_match); + if (ret < 0) { + dev_err(&cldev->dev, "Master comp add failed %d\n", ret); + goto err_exit; + } + + return 0; + +err_exit: + mei_cldev_set_drvdata(cldev, NULL); + kfree(comp_master); + mei_cldev_disable(cldev); +enable_err_exit: + return ret; +} + +static void mei_gsc_proxy_remove(struct mei_cl_device *cldev) +{ + struct i915_gsc_proxy_component *comp_master =3D mei_cldev_get_drvdata(cl= dev); + int ret; + + component_master_del(&cldev->dev, &mei_component_master_ops); + kfree(comp_master); + mei_cldev_set_drvdata(cldev, NULL); + + ret =3D mei_cldev_disable(cldev); + if (ret) + dev_warn(&cldev->dev, "mei_cldev_disable() failed %d\n", ret); +} + +#define MEI_UUID_GSC_PROXY UUID_LE(0xf73db04, 0x97ab, 0x4125, \ + 0xb8, 0x93, 0xe9, 0x4, 0xad, 0xd, 0x54, 0x64) + +static struct mei_cl_device_id mei_gsc_proxy_tbl[] =3D { + { .uuid =3D MEI_UUID_GSC_PROXY, .version =3D MEI_CL_VERSION_ANY }, + { } +}; +MODULE_DEVICE_TABLE(mei, mei_gsc_proxy_tbl); + +static struct mei_cl_driver mei_gsc_proxy_driver =3D { + .id_table =3D mei_gsc_proxy_tbl, + .name =3D KBUILD_MODNAME, + .probe =3D mei_gsc_proxy_probe, + .remove =3D mei_gsc_proxy_remove, +}; + +module_mei_cl_driver(mei_gsc_proxy_driver); + +MODULE_AUTHOR("Intel Corporation"); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("MEI GSC PROXY"); --=20 2.39.1