From nobody Fri Dec 19 04:52:21 2025 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 3BBABCA0EC3 for ; Tue, 12 Sep 2023 13:13:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235431AbjILNNX (ORCPT ); Tue, 12 Sep 2023 09:13:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235295AbjILNNU (ORCPT ); Tue, 12 Sep 2023 09:13:20 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F02B10CA for ; Tue, 12 Sep 2023 06:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694524396; x=1726060396; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nJXlvOEO+czS205YyxCyTKdJGR4h9EWvKCOOlBcmerk=; b=J263f2A+SPUE4dY8t5lEVpj88lErK8RzfC9dLb2kuxYtsY304NJOytoM 0tVohKPxeWaL3jCdgxCfjtqOemaL9gGAzzsYREyb/IjVCvJtyg73YHMBU k/m+AwInKXbZs4GMl9zYkbzQtjxcA0nMHd9tsmAgj4dqzu+uU8AQrXWM7 HzjK1opEfizpbNCNDqcutQ94GulIUk16w4Cm6MvNEXsxCrxmHjYe1G4xL l6Z+jwv4hNyTIxGTHe3yjrCyv4g2DZirNnIQCECFluI0NggETZOD2pv43 6YW45XC0frs6NRPMRnT8ioQ/KK6GoEnqG1HB8H8Yxuk/u4ixnZc9e5Ro0 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="464740085" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="464740085" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 06:13:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="737116342" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="737116342" Received: from sannilnx-dsk.jer.intel.com ([10.12.231.107]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 06:13:13 -0700 From: Alexander Usyskin To: Greg Kroah-Hartman , Lucas De Marchi , Daniele Ceraolo Spurio , Rodrigo Vivi Cc: Tomas Winkler , Alexander Usyskin , Vitaly Lubart , intel-xe@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] drm/xe/gsc: add HECI2 register offsets Date: Tue, 12 Sep 2023 16:08:32 +0300 Message-Id: <20230912130835.2488728-2-alexander.usyskin@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912130835.2488728-1-alexander.usyskin@intel.com> References: <20230912130835.2488728-1-alexander.usyskin@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: Vitaly Lubart Add HECI2 register offsets for DG1 and DG2 to regs/xe_regs.h Signed-off-by: Vitaly Lubart Signed-off-by: Alexander Usyskin --- drivers/gpu/drm/xe/regs/xe_regs.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/xe/regs/xe_regs.h b/drivers/gpu/drm/xe/regs/xe= _regs.h index 77aa3dab321a..5d9380f307cc 100644 --- a/drivers/gpu/drm/xe/regs/xe_regs.h +++ b/drivers/gpu/drm/xe/regs/xe_regs.h @@ -33,6 +33,10 @@ #define XEHPC_BCS6_RING_BASE 0x3ea000 #define XEHPC_BCS7_RING_BASE 0x3ec000 #define XEHPC_BCS8_RING_BASE 0x3ee000 + +#define DG1_GSC_HECI2_BASE 0x00259000 +#define DG2_GSC_HECI2_BASE 0x00374000 + #define GSCCS_RING_BASE 0x11a000 #define GT_WAIT_SEMAPHORE_INTERRUPT REG_BIT(11) #define GT_CONTEXT_SWITCH_INTERRUPT REG_BIT(8) --=20 2.34.1 From nobody Fri Dec 19 04:52:21 2025 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 33211CA0ED4 for ; Tue, 12 Sep 2023 13:13:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235458AbjILNN0 (ORCPT ); Tue, 12 Sep 2023 09:13:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235423AbjILNNX (ORCPT ); Tue, 12 Sep 2023 09:13:23 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 507C810D1 for ; Tue, 12 Sep 2023 06:13:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694524399; x=1726060399; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CmVDPIi6iDITv7lp9F+ldlMc0s9EvQk1kBwLwS5H+Ao=; b=kD+1tf8S1gcCakuVastyxFv1XQO/G8ujNEKs8bx7LRueuoRf4YFskD27 DS9ap9zQqIroSMHjXFQD/8jEpa0MI64vp5ok+OPZvgDDhF7xMX9eBNeFe QGJFaOZ7v/fwVP2XQSG6H9yulTVnRzTi8lHieUhpNQN6p29hwkYmFAxTN h2NWJeI3rDoyb3Sz06jwPRy1TEz+T3y5z/e8S57HuG17ZdBYKlQCXW/NV PSCBwfHAFu9vicqgbpRHTjkh35pHZNI6AV6WQBhdqpWFR7PQGe/BBNkTu 03ObTgr1Sjaitncg7ERm0q4fbD/0Ink4rz5jjPvJShCzJ1h4eQpI3tMmL w==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="464740108" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="464740108" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 06:13:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="737116348" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="737116348" Received: from sannilnx-dsk.jer.intel.com ([10.12.231.107]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 06:13:16 -0700 From: Alexander Usyskin To: Greg Kroah-Hartman , Lucas De Marchi , Daniele Ceraolo Spurio , Rodrigo Vivi Cc: Tomas Winkler , Alexander Usyskin , Vitaly Lubart , intel-xe@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] drm/xe/gsc: add has_heci_gscfi indication to device Date: Tue, 12 Sep 2023 16:08:33 +0300 Message-Id: <20230912130835.2488728-3-alexander.usyskin@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912130835.2488728-1-alexander.usyskin@intel.com> References: <20230912130835.2488728-1-alexander.usyskin@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: Vitaly Lubart Mark support of MEI-GSC interaction per device. Add has_heci_gscfi indication to xe_device and xe_pci structures. Mark DG1 and DG2 devices as supported. Signed-off-by: Vitaly Lubart Signed-off-by: Alexander Usyskin --- drivers/gpu/drm/xe/xe_device_types.h | 3 +++ drivers/gpu/drm/xe/xe_pci.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_d= evice_types.h index e4391c94e576..bac3d893b128 100644 --- a/drivers/gpu/drm/xe/xe_device_types.h +++ b/drivers/gpu/drm/xe/xe_device_types.h @@ -34,6 +34,7 @@ struct xe_ggtt; #define GRAPHICS_VERx100(xe) ((xe)->info.graphics_verx100) #define MEDIA_VERx100(xe) ((xe)->info.media_verx100) #define IS_DGFX(xe) ((xe)->info.is_dgfx) +#define HAS_HECI_GSCFI(xe) ((xe)->info.has_heci_gscfi) =20 #define XE_VRAM_FLAGS_NEED64K BIT(0) =20 @@ -242,6 +243,8 @@ struct xe_device { u8 has_link_copy_engine:1; /** @enable_display: display enabled */ u8 enable_display:1; + /** @has_heci_gscfi: device has heci gscfi */ + u8 has_heci_gscfi:1; =20 #if IS_ENABLED(CONFIG_DRM_XE_DISPLAY) const struct intel_display_device_info *display; diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c index 60f3474844e2..dcbef397e03e 100644 --- a/drivers/gpu/drm/xe/xe_pci.c +++ b/drivers/gpu/drm/xe/xe_pci.c @@ -79,6 +79,7 @@ struct xe_device_desc { u8 require_force_probe:1; u8 is_dgfx:1; u8 has_display:1; + u8 has_heci_gscfi:1; =20 u8 has_llc:1; }; @@ -348,6 +349,7 @@ static const struct xe_device_desc dg1_desc =3D { PLATFORM(XE_DG1), .has_display =3D true, .require_force_probe =3D true, + .has_heci_gscfi =3D 1, }; =20 static const u16 dg2_g10_ids[] =3D { XE_DG2_G10_IDS(NOP), XE_ATS_M150_IDS(= NOP), 0 }; @@ -357,6 +359,7 @@ static const u16 dg2_g12_ids[] =3D { XE_DG2_G12_IDS(NOP= ), 0 }; #define DG2_FEATURES \ DGFX_FEATURES, \ PLATFORM(XE_DG2), \ + .has_heci_gscfi =3D 1, \ .subplatforms =3D (const struct xe_subplatform_desc[]) { \ { XE_SUBPLATFORM_DG2_G10, "G10", dg2_g10_ids }, \ { XE_SUBPLATFORM_DG2_G11, "G11", dg2_g11_ids }, \ @@ -686,6 +689,7 @@ static int xe_info_init(struct xe_device *xe, return -ENODEV; =20 xe->info.is_dgfx =3D desc->is_dgfx; + xe->info.has_heci_gscfi =3D desc->has_heci_gscfi; xe->info.graphics_name =3D graphics_desc->name; xe->info.media_name =3D media_desc ? media_desc->name : "none"; xe->info.has_llc =3D desc->has_llc; @@ -830,7 +834,7 @@ static int xe_pci_probe(struct pci_dev *pdev, const str= uct pci_device_id *ent) =20 xe_display_info_init(xe); =20 - drm_dbg(&xe->drm, "%s %s %04x:%04x dgfx:%d gfx:%s (%d.%02d) media:%s (%d.= %02d) display:%s dma_m_s:%d tc:%d", + drm_dbg(&xe->drm, "%s %s %04x:%04x dgfx:%d gfx:%s (%d.%02d) media:%s (%d.= %02d) display:%s dma_m_s:%d tc:%d gscfi:%d", desc->platform_name, subplatform_desc ? subplatform_desc->name : "", xe->info.devid, xe->info.revid, @@ -842,7 +846,8 @@ static int xe_pci_probe(struct pci_dev *pdev, const str= uct pci_device_id *ent) xe->info.media_verx100 / 100, xe->info.media_verx100 % 100, str_yes_no(xe->info.enable_display), - xe->info.dma_mask_size, xe->info.tile_count); + xe->info.dma_mask_size, xe->info.tile_count, + xe->info.has_heci_gscfi); =20 drm_dbg(&xe->drm, "Stepping =3D (G:%s, M:%s, D:%s, B:%s)\n", xe_step_name(xe->info.step.graphics), --=20 2.34.1 From nobody Fri Dec 19 04:52:21 2025 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 899B9CA0ECA for ; Tue, 12 Sep 2023 13:13:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235486AbjILNN2 (ORCPT ); Tue, 12 Sep 2023 09:13:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235447AbjILNNZ (ORCPT ); Tue, 12 Sep 2023 09:13:25 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3AA710D9 for ; Tue, 12 Sep 2023 06:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694524401; x=1726060401; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I849JyADgwOcl+HG+SklpbtTKTR89WyZMLdhnLssDt8=; b=mowDhGkm/pfKQgjzR7wT7CfwZi8vwjy+zAiL9d8/vy+fjQXi+jH05pK0 2tmxwMeMPKsVS3PZkFajaxmblLvnz0sB09gOGxfEIjTMKqqVh9hWFFPbb Tg1eOGtoAXrcJFQaSmmDIt8iHmqg7gsVszELpCshGgjENxXQ5jkuwf9pJ FBrQddTB37NfrNZck4+51FkjopAq4vHUyleP/b5ClUKX+I87Whmx9mMLm A3O56iwQasLhZpYDqpIjDdyjq+4pJTXBvb8wPRWbs5sUbAaf8PTIF/FH2 4app9RrzY30F9U7I0lE8yA6mbUignY00KFEb+zQPBFMhMAd+Vcl74Gdgr w==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="464740128" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="464740128" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 06:13:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="737116353" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="737116353" Received: from sannilnx-dsk.jer.intel.com ([10.12.231.107]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 06:13:18 -0700 From: Alexander Usyskin To: Greg Kroah-Hartman , Lucas De Marchi , Daniele Ceraolo Spurio , Rodrigo Vivi Cc: Tomas Winkler , Alexander Usyskin , Vitaly Lubart , intel-xe@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] drm/xe/gsc: add gsc device support Date: Tue, 12 Sep 2023 16:08:34 +0300 Message-Id: <20230912130835.2488728-4-alexander.usyskin@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912130835.2488728-1-alexander.usyskin@intel.com> References: <20230912130835.2488728-1-alexander.usyskin@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: Vitaly Lubart Create mei-gscfi auxiliary device and configure interrupts to be consumed by mei-gsc device driver. Signed-off-by: Vitaly Lubart Signed-off-by: Alexander Usyskin --- drivers/gpu/drm/xe/Kconfig | 1 + drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_gt.c | 4 + drivers/gpu/drm/xe/xe_gt_gsc.c | 218 +++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_gt_gsc.h | 36 +++++ drivers/gpu/drm/xe/xe_gt_types.h | 4 + drivers/gpu/drm/xe/xe_irq.c | 11 +- 7 files changed, 273 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_gt_gsc.c create mode 100644 drivers/gpu/drm/xe/xe_gt_gsc.h diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig index 0a4ea965645b..9d396ca7708a 100644 --- a/drivers/gpu/drm/xe/Kconfig +++ b/drivers/gpu/drm/xe/Kconfig @@ -36,6 +36,7 @@ config DRM_XE select DRM_SCHED select MMU_NOTIFIER select WANT_DEV_COREDUMP + select AUXILIARY_BUS help Experimental driver for Intel Xe series GPUs =20 diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile index 9a2245ffede2..9ba9389a2cfd 100644 --- a/drivers/gpu/drm/xe/Makefile +++ b/drivers/gpu/drm/xe/Makefile @@ -65,6 +65,7 @@ xe-y +=3D xe_bb.o \ xe_gt_sysfs.o \ xe_gt_tlb_invalidation.o \ xe_gt_topology.o \ + xe_gt_gsc.o \ xe_guc.o \ xe_guc_ads.o \ xe_guc_ct.o \ diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c index 4c7f66647a04..f373c139e1a1 100644 --- a/drivers/gpu/drm/xe/xe_gt.c +++ b/drivers/gpu/drm/xe/xe_gt.c @@ -76,6 +76,8 @@ static void gt_fini(struct drm_device *drm, void *arg) =20 destroy_workqueue(gt->ordered_wq); =20 + xe_gsc_fini(>->gsc); + for (i =3D 0; i < XE_ENGINE_CLASS_MAX; ++i) xe_hw_fence_irq_finish(>->fence_irq[i]); } @@ -460,6 +462,8 @@ int xe_gt_init(struct xe_gt *gt) if (err) return err; =20 + xe_gsc_init(>->gsc, gt_to_xe(gt)); + err =3D drmm_add_action_or_reset(>_to_xe(gt)->drm, gt_fini, gt); if (err) return err; diff --git a/drivers/gpu/drm/xe/xe_gt_gsc.c b/drivers/gpu/drm/xe/xe_gt_gsc.c new file mode 100644 index 000000000000..ed825c883da7 --- /dev/null +++ b/drivers/gpu/drm/xe/xe_gt_gsc.c @@ -0,0 +1,218 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright(c) 2023, Intel Corporation. All rights reserved. + */ + +#include +#include +#include +#include + +#include "regs/xe_regs.h" +#include "xe_drv.h" +#include "xe_gt_gsc.h" +#include "xe_gt_types.h" +#include "xe_device_types.h" +#include "xe_platform_types.h" + +#define GSC_BAR_LENGTH 0x00000FFC + +static void gsc_irq_mask(struct irq_data *d) +{ + /* generic irq handling */ +} + +static void gsc_irq_unmask(struct irq_data *d) +{ + /* generic irq handling */ +} + +static struct irq_chip gsc_irq_chip =3D { + .name =3D "gsc_irq_chip", + .irq_mask =3D gsc_irq_mask, + .irq_unmask =3D gsc_irq_unmask, +}; + +static inline struct xe_gt *gsc_to_gt(struct xe_gsc *gsc) +{ + return container_of(gsc, struct xe_gt, gsc); +} + +static int gsc_irq_init(int irq) +{ + irq_set_chip_and_handler_name(irq, &gsc_irq_chip, + handle_simple_irq, "gsc_irq_handler"); + + return irq_set_chip_data(irq, NULL); +} + +/** + * struct gsc_def - graphics security controller heci interface definistio= ns + * + * @name: name of the heci device + * @bar: address of the mmio bar + * @bar_size: size of the mmio bar + * @use_polling: indication of using polling mode for the device + * @slow_firmware: indication of whether the device is slow (needs longer = timeouts) + */ +struct gsc_def { + const char *name; + unsigned long bar; + size_t bar_size; + bool use_polling; + bool slow_firmware; +}; + +/* gsc resources and definitions */ +static const struct gsc_def gsc_def_dg1 =3D { + .name =3D "mei-gscfi", + .bar =3D DG1_GSC_HECI2_BASE, + .bar_size =3D GSC_BAR_LENGTH, +}; + +static const struct gsc_def gsc_def_dg2 =3D { + .name =3D "mei-gscfi", + .bar =3D DG2_GSC_HECI2_BASE, + .bar_size =3D GSC_BAR_LENGTH, +}; + +static void gsc_release_dev(struct device *dev) +{ + struct auxiliary_device *aux_dev =3D to_auxiliary_dev(dev); + struct mei_aux_device *adev =3D auxiliary_dev_to_mei_aux_dev(aux_dev); + + kfree(adev); +} + +void xe_gsc_fini(struct xe_gsc *gsc) +{ + struct xe_gt *gt =3D gsc_to_gt(gsc); + + if (!HAS_HECI_GSCFI(gt_to_xe(gt))) + return; + + if (gsc->adev) { + struct auxiliary_device *aux_dev =3D &gsc->adev->aux_dev; + + auxiliary_device_delete(aux_dev); + auxiliary_device_uninit(aux_dev); + gsc->adev =3D NULL; + } + + if (gsc->irq >=3D 0) + irq_free_desc(gsc->irq); + gsc->irq =3D -1; +} + +void xe_gsc_init(struct xe_gsc *gsc, struct xe_device *xe) +{ + struct pci_dev *pdev =3D to_pci_dev(xe->drm.dev); + struct mei_aux_device *adev; + struct auxiliary_device *aux_dev; + const struct gsc_def *def; + int ret; + + if (!HAS_HECI_GSCFI(xe)) + return; + + gsc->irq =3D -1; + + /* + * On the multi-tile setups the GSC is functional on the first tile only + */ + if (gsc_to_gt(gsc)->info.id !=3D 0) { + drm_dbg(&xe->drm, "Not initializing gsc for remote tiles\n"); + return; + } + + if (xe->info.platform =3D=3D XE_DG1) { + def =3D &gsc_def_dg1; + } else if (xe->info.platform =3D=3D XE_DG2) { + def =3D &gsc_def_dg2; + } else { + drm_warn_once(&xe->drm, "Unknown platform\n"); + return; + } + + if (!def->name) { + drm_warn_once(&xe->drm, "HECI is not implemented!\n"); + return; + } + + /* skip irq initialization */ + if (def->use_polling) + goto add_device; + + gsc->irq =3D irq_alloc_desc(0); + if (gsc->irq < 0) { + drm_err(&xe->drm, "gsc irq error %d\n", gsc->irq); + goto fail; + } + + ret =3D gsc_irq_init(gsc->irq); + if (ret < 0) { + drm_err(&xe->drm, "gsc irq init failed %d\n", ret); + goto fail; + } + +add_device: + adev =3D kzalloc(sizeof(*adev), GFP_KERNEL); + if (!adev) + goto fail; + adev->irq =3D gsc->irq; + adev->bar.parent =3D &pdev->resource[0]; + adev->bar.start =3D def->bar + pdev->resource[0].start; + adev->bar.end =3D adev->bar.start + def->bar_size - 1; + adev->bar.flags =3D IORESOURCE_MEM; + adev->bar.desc =3D IORES_DESC_NONE; + adev->slow_firmware =3D def->slow_firmware; + + aux_dev =3D &adev->aux_dev; + aux_dev->name =3D def->name; + aux_dev->id =3D (pci_domain_nr(pdev->bus) << 16) | + PCI_DEVID(pdev->bus->number, pdev->devfn); + aux_dev->dev.parent =3D &pdev->dev; + aux_dev->dev.release =3D gsc_release_dev; + + ret =3D auxiliary_device_init(aux_dev); + if (ret < 0) { + drm_err(&xe->drm, "gsc aux init failed %d\n", ret); + kfree(adev); + goto fail; + } + + gsc->adev =3D adev; /* needed by the notifier */ + ret =3D auxiliary_device_add(aux_dev); + if (ret < 0) { + drm_err(&xe->drm, "gsc aux add failed %d\n", ret); + gsc->adev =3D NULL; + + /* adev will be freed with the put_device() and .release sequence */ + auxiliary_device_uninit(aux_dev); + goto fail; + } + + return; +fail: + xe_gsc_fini(gsc); +} + +void xe_gsc_irq_handler(struct xe_gt *gt, u32 iir) +{ + int ret; + + if ((iir & GSC_IRQ_INTF(1)) =3D=3D 0) + return; + + if (!HAS_HECI_GSCFI(gt_to_xe(gt))) { + drm_warn_once(>_to_xe(gt)->drm, "GSC irq: not supported"); + return; + } + + if (gt->gsc.irq < 0) + return; + + ret =3D generic_handle_irq(gt->gsc.irq); + if (ret) + drm_err_ratelimited(>_to_xe(gt)->drm, "error handling GSC irq: %d\n", = ret); +} diff --git a/drivers/gpu/drm/xe/xe_gt_gsc.h b/drivers/gpu/drm/xe/xe_gt_gsc.h new file mode 100644 index 000000000000..91dba19e47c1 --- /dev/null +++ b/drivers/gpu/drm/xe/xe_gt_gsc.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Copyright(c) 2023, Intel Corporation. All rights reserved. + */ +#ifndef __XE_GSC_DEV_H__ +#define __XE_GSC_DEV_H__ + +#include + +struct xe_device; +struct xe_gt; +struct mei_aux_device; + +/* + * The HECI1 bit corresponds to bit15 and HECI2 to bit14. + * The reason for this is to allow growth for more interfaces in the futur= e. + */ +#define GSC_IRQ_INTF(_x) BIT(15 - (_x)) + +/** + * struct xe_gsc - graphics security controller for xe + * + * @adev : pointer to mei auxiliary device structure + * @irq : irq number + * + */ +struct xe_gsc { + struct mei_aux_device *adev; + int irq; +}; + +void xe_gsc_init(struct xe_gsc *gsc, struct xe_device *xe); +void xe_gsc_fini(struct xe_gsc *gsc); +void xe_gsc_irq_handler(struct xe_gt *gt, u32 iir); + +#endif /* __XE_GSC_DEV_H__ */ diff --git a/drivers/gpu/drm/xe/xe_gt_types.h b/drivers/gpu/drm/xe/xe_gt_ty= pes.h index f11da12d3146..1b8ab32b488d 100644 --- a/drivers/gpu/drm/xe/xe_gt_types.h +++ b/drivers/gpu/drm/xe/xe_gt_types.h @@ -13,6 +13,7 @@ #include "xe_reg_sr_types.h" #include "xe_sa_types.h" #include "xe_uc_types.h" +#include "xe_gt_gsc.h" =20 struct xe_exec_queue_ops; struct xe_migrate; @@ -267,6 +268,9 @@ struct xe_gt { /** @uc: micro controllers on the GT */ struct xe_uc uc; =20 + /** @gsc: graphics security controller */ + struct xe_gsc gsc; + /** @gtidle: idle properties of GT */ struct xe_gt_idle gtidle; =20 diff --git a/drivers/gpu/drm/xe/xe_irq.c b/drivers/gpu/drm/xe/xe_irq.c index 1dee3e832eb5..1ae4cc9f1522 100644 --- a/drivers/gpu/drm/xe/xe_irq.c +++ b/drivers/gpu/drm/xe/xe_irq.c @@ -128,6 +128,7 @@ void xe_irq_enable_hwe(struct xe_gt *gt) struct xe_device *xe =3D gt_to_xe(gt); u32 ccs_mask, bcs_mask; u32 irqs, dmask, smask; + u32 gsc_mask =3D GSC_IRQ_INTF(1); =20 if (xe_device_guc_submission_enabled(xe)) { irqs =3D GT_RENDER_USER_INTERRUPT | @@ -180,6 +181,9 @@ void xe_irq_enable_hwe(struct xe_gt *gt) if (xe_hw_engine_mask_per_class(gt, XE_ENGINE_CLASS_OTHER)) { xe_mmio_write32(gt, GUNIT_GSC_INTR_ENABLE, irqs); xe_mmio_write32(gt, GUNIT_GSC_INTR_MASK, ~irqs); + } else if (HAS_HECI_GSCFI(xe)) { + xe_mmio_write32(gt, GUNIT_GSC_INTR_ENABLE, gsc_mask); + xe_mmio_write32(gt, GUNIT_GSC_INTR_MASK, ~gsc_mask); } } } @@ -227,6 +231,8 @@ gt_other_irq_handler(struct xe_gt *gt, const u8 instanc= e, const u16 iir) return xe_guc_irq_handler(>->uc.guc, iir); if (instance =3D=3D OTHER_MEDIA_GUC_INSTANCE && xe_gt_is_media_type(gt)) return xe_guc_irq_handler(>->uc.guc, iir); + if (instance =3D=3D OTHER_GSC_INSTANCE) + return xe_gsc_irq_handler(gt, iir); =20 if (instance !=3D OTHER_GUC_INSTANCE && instance !=3D OTHER_MEDIA_GUC_INSTANCE) { @@ -470,8 +476,9 @@ static void gt_irq_reset(struct xe_tile *tile) if (ccs_mask & (BIT(2)|BIT(3))) xe_mmio_write32(mmio, CCS2_CCS3_INTR_MASK, ~0); =20 - if (tile->media_gt && - xe_hw_engine_mask_per_class(tile->media_gt, XE_ENGINE_CLASS_OTHER)) { + if ((tile->media_gt && + xe_hw_engine_mask_per_class(tile->media_gt, XE_ENGINE_CLASS_OTHER)) = || + HAS_HECI_GSCFI(tile_to_xe(tile))) { xe_mmio_write32(mmio, GUNIT_GSC_INTR_ENABLE, 0); xe_mmio_write32(mmio, GUNIT_GSC_INTR_MASK, ~0); } --=20 2.34.1 From nobody Fri Dec 19 04:52:21 2025 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 336AFCA0EC3 for ; Tue, 12 Sep 2023 13:13:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235489AbjILNNg (ORCPT ); Tue, 12 Sep 2023 09:13:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235391AbjILNNd (ORCPT ); Tue, 12 Sep 2023 09:13:33 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68F7C10DE for ; Tue, 12 Sep 2023 06:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694524404; x=1726060404; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1p71K//XQ9zZQYmDOllPeza8+3H0XOHh0PahGZw2m84=; b=BY3XwLjQs6DwX5TUiY03pymfAO6Si7ni2OnztySAP0I0GPiFwEEOllQq 769Xx8csTD4hBkNF3bpqg1d/pS4QgSs7nDz/Lymo6jOGkaCjvAkpe3M++ dI5zVqSAlPAp9IbvqkmMyo+CsjJMpn0b9lvX1eS2X5YhZIzAdBIROO77Y qHLu/c8/x1UnqNzmfFZPJ4s6XV48f+OqEhXZt7R7+sRJhgCh/XVRr0eDK u86di/6BLpkNolmH1Xc7UdiyUjeQZmS/wz10zBsa47E4Y/xXMvXRY/Jk8 cAhcJq9VkXmyeD1/JHjHK2TvPGxGoD4qzlx4jSbueJer64ojGItmZHNed w==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="464740149" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="464740149" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 06:13:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="737116359" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="737116359" Received: from sannilnx-dsk.jer.intel.com ([10.12.231.107]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 06:13:21 -0700 From: Alexander Usyskin To: Greg Kroah-Hartman , Lucas De Marchi , Daniele Ceraolo Spurio , Rodrigo Vivi Cc: Tomas Winkler , Alexander Usyskin , Vitaly Lubart , intel-xe@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] mei: gsc: add support for auxiliary device created by Xe driver Date: Tue, 12 Sep 2023 16:08:35 +0300 Message-Id: <20230912130835.2488728-5-alexander.usyskin@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912130835.2488728-1-alexander.usyskin@intel.com> References: <20230912130835.2488728-1-alexander.usyskin@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: Vitaly Lubart Add support for gsc mei auxiliary device created by Xe driver Signed-off-by: Vitaly Lubart Signed-off-by: Alexander Usyskin --- drivers/misc/mei/gsc-me.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/misc/mei/gsc-me.c b/drivers/misc/mei/gsc-me.c index e63cabd0818d..63525778a4e0 100644 --- a/drivers/misc/mei/gsc-me.c +++ b/drivers/misc/mei/gsc-me.c @@ -292,6 +292,10 @@ static const struct auxiliary_device_id mei_gsc_id_tab= le[] =3D { .name =3D "i915.mei-gscfi", .driver_data =3D MEI_ME_GSCFI_CFG, }, + { + .name =3D "xe.mei-gscfi", + .driver_data =3D MEI_ME_GSCFI_CFG, + }, { /* sentinel */ } @@ -312,4 +316,5 @@ module_auxiliary_driver(mei_gsc_driver); MODULE_AUTHOR("Intel Corporation"); MODULE_ALIAS("auxiliary:i915.mei-gsc"); MODULE_ALIAS("auxiliary:i915.mei-gscfi"); +MODULE_ALIAS("auxiliary:xe.mei-gscfi"); MODULE_LICENSE("GPL"); --=20 2.34.1