From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5566606A322 for ; Fri, 4 Dec 2026 14:45:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=UR7XzdcE Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 99DD3112FD8; Fri, 4 Dec 2026 14:45:49 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by gabe.freedesktop.org (Postfix) with ESMTPS id DFE3A112FDD for ; Fri, 4 Dec 2026 14:45:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796395543; x=1827931543; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=YSd2nYEL8kFmNHGCn0PYjgQuKzv57vvqBRU9zlIvcMA=; b=UR7XzdcEpzMKpUZTFvTenb5qK6ps9gEHcbbI/ZJdolnPVrXGGlb7SNoZ u1PpdN3GaYWWVHgDOjwi4XS425BNP8XlYYIreax6zu4B9aGaK9QjAIR/r AG927uIAAiEPHXR51+0g7gMKTZ9NueM/IVCmH38RNZMaQ1+JQXc3zoaJO TaTnC223OTYwfWvn8g1kwuOlBW1jxdZhCM30Vyy0hvO639A1pCBFEdoh6 ebkBfHNbepxTG7HvnUbu7EaddEcM30zp13d9pybPz4i0Gp2zw8jHmSoCE iSvLCFOzVGEKNDatO1kjARu/cg9wNCe6Pbdr4bTUdkRkZ34l3Bte4SCv3 g==; X-CSE-ConnectionGUID: YwQX81rKRWiYBBh0HWeU5g== X-CSE-MsgGUID: umgtxsXZQSuBmtUZHPOcgg== X-IronPort-AV: E=McAfee;i="6800,10657,11986"; a="5235143" X-IronPort-AV: E=Sophos;i="6.29,78,1794902400"; d="scan'208";a="5235143" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 06:45:42 -0800 X-CSE-ConnectionGUID: +mUt8IzzQ6SYFh4cx6d/Sw== X-CSE-MsgGUID: j/OhKVkHT1OGOzp1zdajSw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,78,1794902400"; d="scan'208";a="14095435" Received: from orsmsx901.amr.corp.intel.com ([10.22.229.23]) by orviesa002.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2026 06:45:40 -0800 Received: from ORSMSX901.amr.corp.intel.com (10.22.229.23) by ORSMSX901.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Fri, 4 Dec 2026 06:45:39 -0800 Received: from ORSEDG902.ED.cps.intel.com (10.7.248.12) by ORSMSX901.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Fri, 4 Dec 2026 06:45:39 -0800 Received: from SN4PR2101CU001.outbound.protection.outlook.com (40.93.195.12) by edgegateway.intel.com (134.134.137.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Fri, 4 Dec 2026 06:45:39 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KAVMPrKMnb1iK1bAWxbIQtVuLJrZYR9bHIx7ufg6iqaAtMhhEEMc/6e8EHgbRGbpAZ6tUQTS+bJczJEpVCoxlIMvCOp/nVBCs3C2jr5d4PHmPAuRXwyW3ttFhWPan1nr9XKiseXg6GUV+1OthldmV/fZs2y2wL5+lyW3zANNUbgNKooNJWrHNFuzDimQhijNK1Qe3hzrcnURTLODP5gapprup4u2Oe/UKfVLekx8t+yR2ZlfIbHlVHGt2oj8chdUQOHoAf3vWgyuTH+WkQYC4CV/TnNH5xspxqdGjM/QowRtc1qk7ZsjOpOU4Re2tiReiCqkfXKWtwlmH33SeGPCBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YSd2nYEL8kFmNHGCn0PYjgQuKzv57vvqBRU9zlIvcMA=; b=KARgR7NU9f5vk0AvGsQq7gL/tgC0kiENAo/8gxQzoUiiq0s9nkr/QNkCJrB8jV5J9Uqn9fuYC+K+45I+4mYWUngiVJ+YohzGM41LwuX932UCgkWP8oz/bqsjkI6m1Y9CGLl/x58LsVNjqdST4oz5FG+2NjvqIsNxpijx99tlqZgjdN+n6QHJA8OyKtt1nNP2mI7k6mNzvLhIAEARzlG1BxW+aKHevxMDyHEAbvz3wsNGFonmtn/WQKzpBPcY3LvfwhrAtVqC4G7ndgHl218wwIOYSNpkEsX36d4+QeVSyrIlQwW+wC/7rfoeTjDTCLXUC06eIGHODE4drL+vx9Ez6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS7PR11MB5990.namprd11.prod.outlook.com (2603:10b6:8:71::5) by SJ0PR11MB4782.namprd11.prod.outlook.com (2603:10b6:a03:2df::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.13; Fri, 4 Dec 2026 14:45:36 +0000 Received: from DS7PR11MB5990.namprd11.prod.outlook.com ([fe80::133c:5eed:3aec:b899]) by DS7PR11MB5990.namprd11.prod.outlook.com ([fe80::133c:5eed:3aec:b899%3]) with mapi id 15.21.0688.011; Fri, 4 Dec 2026 14:45:36 +0000 Date: Fri, 4 Dec 2026 09:45:32 -0500 From: Rodrigo Vivi To: Stuart Summers CC: , , , , , , Subject: Re: [PATCH 2/2] drm/xe: Work around media 52-bit limitation on CRI Message-ID: References: <20261203232859.321380-4-stuart.summers@intel.com> <20261203232859.321380-6-stuart.summers@intel.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261203232859.321380-6-stuart.summers@intel.com> X-ClientProxiedBy: BY3PR05CA0040.namprd05.prod.outlook.com (2603:10b6:a03:39b::15) To DS7PR11MB5990.namprd11.prod.outlook.com (2603:10b6:8:71::5) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR11MB5990:EE_|SJ0PR11MB4782:EE_ X-MS-Office365-Filtering-Correlation-Id: 678473aa-cd3d-46b4-33c1-08df521541e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|1800799024|23010399003|376014|22082099003|18002099003|10067099003|56012099006|260925021311599003|260925021911599003|260925022911599003|261022113327099003|261102123227099003|261022075727099003|261022105027099003|261026140227099003|261028144727099003|261026121527099003|261021121427099003|261021123027099003|261009221227099003|261009223027099003|11063799006|4143699003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: WpYf7LciC+AO4/YjBlXuEtXQuwiaTgqZ5Ji2b1G5OY9s7LK3wS5cfKoG/oU6L29Mw8CZdk3rgKG63YbXjU76Kf3jYJ1LgIx3kWKWevVSSGVJgtg5ZVoADMRgbmWZ4JCMA+mpbBfTVa4A/3e7/vuXbc+vbwY8RcRStFhW+arxV94Dnysor6tWz8io06vjQQO4Ti1IUuceqhR+ZpcDpZ/sU8Ub7DgHUVzBaIUo6JMv5IhmYFkv03ixGjFhqE1FFJrGgrYLcCq9Vd3wPSACtqDh+iA0hv6EQJriJLzNUl5Z7iRLATd9zl/TXfjX6RT/2cbQNZ/kW8mISvTM02YEVpG/jMmzqpJo1+S/B7BGybIJH58LML3l9Poef49Uba90jhsQ+gyxFWmNKNXSpnnbWq89FhQUYF8Kr0PPx8q9V7sN3/0MWwtveEffc2R7iUNG1i7bHfeeWWzfcDwd++ragcJKor7k3KRwor2z3TPRmAaKWc3hRLu+rcz5eAT1an8MMxdHfwb8kaRKmSK/o/DM2muNXLHJ5ExesXZb9bGl+GEQ1DEOZbmfsG46a/9NH/Cbm30eX2/p9BLp1OIlvAr1G3b8Em+FHyKLaPneTCjJqt08pNA7w2AG2I7sFv48zTtj7R84+FUL4bmLAHtOmvmuiCzfXVQF8l3sVE6CpIg9UeFIrHg= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS7PR11MB5990.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(23010399003)(376014)(22082099003)(18002099003)(10067099003)(56012099006)(260925021311599003)(260925021911599003)(260925022911599003)(261022113327099003)(261102123227099003)(261022075727099003)(261022105027099003)(261026140227099003)(261028144727099003)(261026121527099003)(261021121427099003)(261021123027099003)(261009221227099003)(261009223027099003)(11063799006)(4143699003)(6133799003)(3023799007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?SbhNVl0DbE/h2sbyS7cApnTvKpaiO2UQUDXzm9EVSK2MAyva2/68/cQCRHZM?= =?us-ascii?Q?eSrh/SCbSXbwleynO5OBsA0dQMYOGPVP3yGx37n8MKS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qsxk0ph9E8RCiRfH3y7fx7DTB0cjTrK36V/w4nRezHGP9bFPqBnh1fN9KZVZtEmtgF2oWzsAfujj3OnwUDaxmoYcxJu0X+pm3i0YVaVRgO5VUpuXxoS165RacC9yUWiny+ldOWEZvwgUv8lDr+ECrASxmUL6CF+7AV0gYUgAJqQi7Ch755SGf9ktaL9J7YWB/wesBTITcJAl/E+lN2lIVoLyaTz/BOPzpgFRMkHikzYEhfhfVtz9trQ== X-MS-Exchange-CrossTenant-Network-Message-Id: 678473aa-cd3d-46b4-33c1-08df521541e2 X-MS-Exchange-CrossTenant-AuthSource: DS7PR11MB5990.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 14:45:36.5410 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RdhvCrtPHDk7iGS3iofT6Lq5kWTXshvjcJ9xoold27YwiNLu1BQyw6RhUYZWeQu9HEeSlJmZ9LIyBR6ixTQtzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4782 X-OriginatorOrg: intel.com X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-16.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Thu, Dec 03, 2026 at 11:29:00PM +0000, Stuart Summers wrote: > CRI media only supports 46-bit GPA. With the IOMMU handing out IOVAs > above 46 bits this shows up as ATS translation errors and a media > GuC load failure. > > The workaround for this is broken into a couple of parts: > 1) Media is now disabled by default on CRI. > 2) When media is enabled, implement certain workarounds to > ensure compute performance remains optimal and media accesses > do not result in the above mentioned translation errors. > > The first part of the workaround means for the customers who are > not interested in using media, they can retain the full 52-bit GPA > range for a broader PCIe installation without worrying about any > specific limitation to support the media workloads on this device. > > Additionally, to ensure power is not consumed by media in this > configuration, a new interfaces is added between the KMD and the GFSP > firmware to bring media down into a low power state. > > The second part of the workaround again is broken down into a few > parts: > 1) The whole device is restricted to 46-bit GPA. > 2) Disable address translation in the media block alone to allow > faster translation for compute workloads with PCIe level address > translation enabled while ensuring host accesses beyond 46-bits > (e.g. coming from another 52-bit supporting device) are still > limited to 46-bits for the CRI media. > > Media needs every device DMA address to stay within 46 bits. With the > IOMMU translating device DMA that is guaranteed by the IOVA allocator > honoring the clamped mask. Without it, DMA addresses are host physical > addresses, so media stays enabled only when the architectural host > physical address limit fits in 46 bits (e.g. x86-64 with 4-level > paging). Beyond that the host can hand out an address media cannot > reach, so disable media. > > In order to disable address translation for media, a certain register > programming which is not accessible from the host must be engaged. To > facilitate this, an additional new interface is added between the KMD > and the GFSP firmware to do this programming. > > Media disable persists until a secondary bus reset, so it is only sent > at probe. Address translation disable is lost on power loss, so it is > sent again on resume from D3cold and system suspend. > > HSDES: 14028632488 > > Signed-off-by: Stuart Summers > Assisted-by: LLM > --- > drivers/gpu/drm/xe/xe_device.c | 10 ++ > drivers/gpu/drm/xe/xe_device_wa_oob.rules | 1 + > drivers/gpu/drm/xe/xe_pci.c | 64 ++++++- > drivers/gpu/drm/xe/xe_pm.c | 7 +- > drivers/gpu/drm/xe/xe_sysctrl.c | 164 ++++++++++++++++++ > drivers/gpu/drm/xe/xe_sysctrl.h | 2 + > drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h | 34 ++++ > drivers/gpu/drm/xe/xe_sysctrl_types.h | 6 + > 8 files changed, 285 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c > index de89342f737e..1ef4908a7d69 100644 > --- a/drivers/gpu/drm/xe/xe_device.c > +++ b/drivers/gpu/drm/xe/xe_device.c > @@ -1017,6 +1017,12 @@ int xe_device_probe(struct xe_device *xe) > if (err) > return err; > > + /* > + * Let the System Controller know how media is configured as early as > + * the mailbox allows, before any media GT is brought up. > + */ > + xe_sysctrl_media_probe(xe); > + > err = xe_ras_init(xe); > if (err) > return err; > @@ -1560,6 +1566,10 @@ int xe_device_resume(struct xe_device *xe, bool flr) > > xe_sysctrl_pm_resume(xe); > > + err = xe_sysctrl_media_resume(xe); > + if (err) > + return err; > + > xe_irq_resume(xe); > > for_each_gt(gt, xe, id) { > diff --git a/drivers/gpu/drm/xe/xe_device_wa_oob.rules b/drivers/gpu/drm/xe/xe_device_wa_oob.rules > index 300207596893..14308f90938e 100644 > --- a/drivers/gpu/drm/xe/xe_device_wa_oob.rules > +++ b/drivers/gpu/drm/xe/xe_device_wa_oob.rules > @@ -8,3 +8,4 @@ > 14026779378 PLATFORM(CRESCENTISLAND) > 14028586678 PLATFORM(CRESCENTISLAND) > 14028434957 PLATFORM(CRESCENTISLAND) > +14028632488 PLATFORM(CRESCENTISLAND) > diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c > index 2771e1a60e47..d68f1050ee3d 100644 > --- a/drivers/gpu/drm/xe/xe_pci.c > +++ b/drivers/gpu/drm/xe/xe_pci.c > @@ -7,6 +7,9 @@ > > #include > #include > +#include > +#include > +#include > #include > #include > #include > @@ -791,6 +794,54 @@ static int xe_probe_info_early(struct xe_device *xe, > return 0; > } > > +/* > + * Number of address bits media is able to reach on CRI, where it has no > + * address translation of its own. > + */ > +#define XE_CRI_MEDIA_ADDR_BITS 46 > + > +static bool device_iommu_iova_backed(struct device *dev) > +{ > + struct iommu_domain *domain = iommu_get_domain_for_dev(dev); > + > + return domain && domain->type != IOMMU_DOMAIN_IDENTITY; > +} > + > +/* Highest architectural physical address the host can produce */ > +static u64 host_max_phys_addr(void) > +{ > +#ifdef MAX_PHYSMEM_BITS > + return DMA_BIT_MASK(MAX_PHYSMEM_BITS); > +#else > + return (phys_addr_t)-1; > +#endif > +} > + > +/* > + * Decide whether media can be used on CRI. Media there cannot translate > + * addresses, so it is only usable if device DMA is guaranteed to stay within > + * XE_CRI_MEDIA_ADDR_BITS. The IOMMU guarantees that by allocating IOVAs > + * below the device dma mask. Without it, DMA addresses are host physical > + * addresses, so media is only usable when the host cannot produce an address > + * wider than media can reach. > + */ > +static bool cri_media_addressable(struct xe_device *xe) > +{ > + u64 host_max_addr = host_max_phys_addr(); > + > + if (device_iommu_iova_backed(xe->drm.dev)) > + return true; > + > + if (host_max_addr <= DMA_BIT_MASK(XE_CRI_MEDIA_ADDR_BITS)) > + return true; > + > + drm_info(&xe->drm, > + "IOMMU is not translating device DMA and the host can produce %u bit physical addresses, media is limited to %u\n", > + fls64(host_max_addr), XE_CRI_MEDIA_ADDR_BITS); > + > + return false; > +} > + > /* > * Whether the user wants media at all. The default (-1) leaves the decision > * to the driver. > @@ -798,7 +849,7 @@ static int xe_probe_info_early(struct xe_device *xe, > static bool media_wanted(struct xe_device *xe) > { > if (xe_modparam.enable_media < 0) > - return true; > + return !XE_DEVICE_WA(xe, 14028632488); > > return xe_modparam.enable_media; > } > @@ -830,9 +881,18 @@ static int xe_info_init_early(struct xe_device *xe, > xe_wa_process_device_oob(xe); > > xe->info.media_allowed = media_wanted(xe) && > - xe_configfs_media_gt_allowed(to_pci_dev(xe->drm.dev)); > + xe_configfs_media_gt_allowed(to_pci_dev(xe->drm.dev)) && > + (!XE_DEVICE_WA(xe, 14028632488) || cri_media_addressable(xe)); > > xe->info.dma_mask_size = desc->dma_mask_size; > + /* > + * Some device media blocks cannot address beyond 46 bits. Clamp the > + * dma_mask_size to reflect this. > + */ > + if (XE_DEVICE_WA(xe, 14028632488) && xe_device_media_allowed(xe)) > + xe->info.dma_mask_size = min_t(u8, xe->info.dma_mask_size, > + XE_CRI_MEDIA_ADDR_BITS); > + > xe->info.va_bits = desc->va_bits; > xe->info.vm_max_level = desc->vm_max_level; > xe->info.vram_flags = desc->vram_flags; > diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c > index 51e020fbf9a6..1573fdd97b68 100644 > --- a/drivers/gpu/drm/xe/xe_pm.c > +++ b/drivers/gpu/drm/xe/xe_pm.c > @@ -665,9 +665,14 @@ int xe_pm_runtime_resume(struct xe_device *xe) > > xe_i2c_pm_resume(xe, xe->d3cold.allowed); > > - if (xe->d3cold.allowed) > + if (xe->d3cold.allowed) { > xe_sysctrl_pm_resume(xe); > > + err = xe_sysctrl_media_resume(xe); > + if (err) > + goto out; > + } > + > xe_display_pm_runtime_resume_early(xe); > > xe_irq_resume(xe); > diff --git a/drivers/gpu/drm/xe/xe_sysctrl.c b/drivers/gpu/drm/xe/xe_sysctrl.c > index d362e8156fca..2fc4e35f3e25 100644 > --- a/drivers/gpu/drm/xe/xe_sysctrl.c > +++ b/drivers/gpu/drm/xe/xe_sysctrl.c > @@ -5,9 +5,12 @@ > > #include > #include > +#include > > #include > > +#include > + > #include "regs/xe_irq_regs.h" > #include "regs/xe_sysctrl_regs.h" > #include "xe_device.h" > @@ -19,6 +22,7 @@ > #include "xe_sysctrl_mailbox.h" > #include "xe_sysctrl_mailbox_types.h" > #include "xe_sysctrl_types.h" > +#include "xe_wa.h" > > /** > * DOC: System Controller (sysctrl) > @@ -103,6 +107,7 @@ int xe_sysctrl_init(struct xe_device *xe) > > xe->soc_remapper.set_sysctrl_region(xe, SYSCTRL_MAILBOX_INDEX); > INIT_WORK(&sc->work, xe_sysctrl_work); > + sc->has_media_feature_disable = true; > > return devm_add_action_or_reset(xe->drm.dev, sysctrl_fini, xe); > } > @@ -249,3 +254,162 @@ int xe_sysctrl_sdk_api_version(struct xe_device *xe, u16 *version) > > return 0; > } > + > +static int sysctrl_media_defeature(struct xe_device *xe, u8 feature) > +{ > + struct xe_sysctrl_media_defeature_req req = { .feature = feature }; > + struct xe_sysctrl_media_defeature_resp resp = {}; > + struct xe_sysctrl_mailbox_command cmd = {}; > + size_t out_len = 0; > + int ret; > + > + xe_sysctrl_create_command(&cmd, XE_SYSCTRL_GROUP_RUNTIME, > + XE_SYSCTRL_CMD_MEDIA_DEFEATURE, > + &req, sizeof(req), &resp, sizeof(resp)); > + > + ret = xe_sysctrl_send_command(&xe->sc, &cmd, &out_len); > + if (ret) > + return ret; > + > + if (out_len != sizeof(resp)) { > + xe_err(xe, "sysctrl: unexpected media defeature response length %zu (expected %zu)\n", > + out_len, sizeof(resp)); > + return -EPROTO; > + } should we also check for resp.flags for a fw failure? or not needed in this case? > + > + return 0; > +} > + > +/* Check whether the ATS Enable bit is set in the PCI ATS Control register */ > +static bool sysctrl_ats_enabled(struct xe_device *xe) > +{ > + struct pci_dev *pdev = to_pci_dev(xe->drm.dev); > + int ats_cap; > + u16 ctrl; > + > + ats_cap = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ATS); > + if (!ats_cap) > + return false; > + > + if (pci_read_config_word(pdev, ats_cap + PCI_ATS_CTRL, &ctrl)) > + return false; > + > + return ctrl & PCI_ATS_CTRL_ENABLE; > +} > + > +/* Send the media defeature command, logging any failure */ > +static int sysctrl_media_defeature_send(struct xe_device *xe, u8 feature) > +{ > + int ret; > + > + ret = sysctrl_media_defeature(xe, feature); > + if (ret) > + xe_err(xe, "sysctrl: failed to defeature media (0x%02x): %pe\n", > + feature, ERR_PTR(ret)); > + else > + xe_dbg(xe, "sysctrl: media defeature 0x%02x done\n", feature); > + > + return ret; > +} > + > +/* Whether this platform needs the media defeature workaround at all */ > +static bool sysctrl_media_defeature_needed(struct xe_device *xe) > +{ > + return XE_DEVICE_WA(xe, 14028632488) && > + xe->info.has_soc_remapper_sysctrl && > + xe->info.has_sysctrl && > + xe->sc.has_media_feature_disable; > +} > + > +/** > + * xe_sysctrl_media_resume() - Restore media address translation defeature > + * @xe: xe device instance > + * > + * The media address translation defeature does not survive a power loss, so > + * it must be requested again on resume from D3cold or system suspend whenever > + * media is in use and ATS is enabled. The media defeature sent at probe when > + * media is not in use persists until a secondary bus reset, which cannot > + * happen while the driver is bound, so it is not resent here. Both go to the same fw, but the ATS one is resent after D3cold and the media one is not. Where does fw keep the media one, so it survives D3cold but not a bus reset? And since it persists, a reload with enable_media=1 won't get media back right?! > + * > + * Return: 0 on success, error code on failure > + */ > +int xe_sysctrl_media_resume(struct xe_device *xe) > +{ > + if (!sysctrl_media_defeature_needed(xe) || > + !xe_device_media_allowed(xe) || !sysctrl_ats_enabled(xe)) > + return 0; > + > + return sysctrl_media_defeature_send(xe, XE_SYSCTRL_MEDIA_DEFEATURE_ATS_DISABLE); > +} > + > +/* > + * Drop media from the device. Only safe during probe, before the media GT is > + * fully brought up. The dma_mask_size cap derived from the early media > + * decision is left in place, which is harmless since it is only more > + * restrictive than needed. > + */ > +static void sysctrl_media_drop(struct xe_device *xe) > +{ > + struct xe_tile *tile; > + u8 id; > + > + xe->info.media_allowed = false; > + > + for_each_tile(tile, xe, id) { > + if (!tile->media_gt) > + continue; > + > + tile->media_gt = NULL; > + xe->info.gt_count--; > + } > +} > + > +/** > + * xe_sysctrl_media_probe() - Configure media with the System Controller at probe > + * @xe: xe device instance > + * > + * The driver and the System Controller must agree on the media configuration > + * before media is used. When media is in use and ATS is enabled, address > + * translation for media is not supported and must be defeatured. When media > + * has been disabled, via either the enable_media modparam or the > + * gt_types_allowed configfs attribute, media itself is defeatured so it does > + * not consume power. > + * > + * Media cannot be used while the System Controller does not know how it is > + * configured, so if address translation cannot be defeatured, media is > + * defeatured and dropped instead and probe continues without it. If that > + * fails too, the System Controller is assumed not to support these requests > + * and none are sent again. > + * > + * This is restricted to platforms that need this workaround and must be called > + * before any media GT is brought up. > + */ > +void xe_sysctrl_media_probe(struct xe_device *xe) > +{ > + bool media_allowed = xe_device_media_allowed(xe); > + int ret; > + > + if (!sysctrl_media_defeature_needed(xe) || !xe->info.media_verx100) When media is not allowed, read_gmdid() doesn't read the hw and returns 0 for media, so media_verx100 is 0 here and the DISABLE is still never sent in the default CRI config. Perhaps: if (!sysctrl_media_defeature_needed(xe)) return; if (media_allowed && !xe->info.media_verx100) return; > + return; > + > + if (media_allowed) { > + if (!sysctrl_ats_enabled(xe)) > + return; > + > + if (!sysctrl_media_defeature_send(xe, XE_SYSCTRL_MEDIA_DEFEATURE_ATS_DISABLE)) { > + xe_dbg(xe, "sysctrl: media address translation defeatured\n"); > + return; > + } > + } > + > + ret = sysctrl_media_defeature_send(xe, XE_SYSCTRL_MEDIA_DEFEATURE_DISABLE); > + if (ret) > + xe->sc.has_media_feature_disable = false; > + else > + xe_dbg(xe, "sysctrl: media defeatured\n"); > + > + if (media_allowed) { > + sysctrl_media_drop(xe); > + xe_err(xe, "sysctrl: media configuration failed, continuing without media\n"); > + } > +} > diff --git a/drivers/gpu/drm/xe/xe_sysctrl.h b/drivers/gpu/drm/xe/xe_sysctrl.h > index c0b6d4330c88..f751986f7f84 100644 > --- a/drivers/gpu/drm/xe/xe_sysctrl.h > +++ b/drivers/gpu/drm/xe/xe_sysctrl.h > @@ -18,6 +18,8 @@ static inline struct xe_device *sc_to_xe(struct xe_sysctrl *sc) > > void xe_sysctrl_event(struct xe_sysctrl *sc); > int xe_sysctrl_init(struct xe_device *xe); > +void xe_sysctrl_media_probe(struct xe_device *xe); > +int xe_sysctrl_media_resume(struct xe_device *xe); > void xe_sysctrl_irq_handler(struct xe_device *xe, u32 master_ctl); > void xe_sysctrl_pm_resume(struct xe_device *xe); > bool xe_sysctrl_is_oobmsm_fw_ready(struct xe_device *xe); > diff --git a/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h b/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h > index 50b1d9abaf1f..85ad92ffb2b1 100644 > --- a/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h > +++ b/drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h > @@ -15,11 +15,13 @@ > * > * @XE_SYSCTRL_GROUP_GFSP: GFSP group > * @XE_SYSCTRL_GROUP_DIAG: Diag group > + * @XE_SYSCTRL_GROUP_RUNTIME: Runtime group > * @XE_SYSCTRL_GROUP_CORE: Core group > */ > enum xe_sysctrl_group { > XE_SYSCTRL_GROUP_GFSP = 0x01, > XE_SYSCTRL_GROUP_DIAG = 0x02, > + XE_SYSCTRL_GROUP_RUNTIME = 0x31, > XE_SYSCTRL_GROUP_CORE = 0xFF, > }; > > @@ -96,6 +98,38 @@ struct xe_sysctrl_diag_ras_err_inj_req { > u32 params; > } __packed; > > +/** > + * enum xe_sysctrl_runtime_cmd - Commands supported by Runtime group > + * > + * @XE_SYSCTRL_CMD_MEDIA_DEFEATURE: Disable feature in media > + */ > +enum xe_sysctrl_runtime_cmd { > + XE_SYSCTRL_CMD_MEDIA_DEFEATURE = 0x11, > +}; > + > +#define XE_SYSCTRL_MEDIA_DEFEATURE_DISABLE 0x01 > +#define XE_SYSCTRL_MEDIA_DEFEATURE_ATS_DISABLE 0x02 > + > +/** > + * struct xe_sysctrl_media_defeature_req - Media defeature request > + * > + * @feature: Media feature to defeature, one of > + * XE_SYSCTRL_MEDIA_DEFEATURE_DISABLE or > + * XE_SYSCTRL_MEDIA_DEFEATURE_ATS_DISABLE > + */ > +struct xe_sysctrl_media_defeature_req { > + u8 feature; > +} __packed; > + > +/** > + * struct xe_sysctrl_media_defeature_resp - Media defeature response > + * > + * @flags: Firmware status flags > + */ > +struct xe_sysctrl_media_defeature_resp { > + u32 flags; > +} __packed; > + > /** > * struct xe_sysctrl_app_status_req - Get application status request > * > diff --git a/drivers/gpu/drm/xe/xe_sysctrl_types.h b/drivers/gpu/drm/xe/xe_sysctrl_types.h > index 605bdc62e0bf..1b44308b18b7 100644 > --- a/drivers/gpu/drm/xe/xe_sysctrl_types.h > +++ b/drivers/gpu/drm/xe/xe_sysctrl_types.h > @@ -75,6 +75,12 @@ struct xe_sysctrl { > /** @event_lock: Mutex protecting pending events */ > struct mutex event_lock; > > + /** > + * @has_media_feature_disable: The System Controller accepts media > + * defeature requests. Cleared only if they all fail at probe. > + */ > + bool has_media_feature_disable; > + > /** @debugfs: Debugfs entries */ > struct { > /** @debugfs.root: Root debugfs directory */ > -- > 2.43.0 >