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 60DD4606A322 for ; Thu, 3 Dec 2026 21:37:58 +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=jjewsyx9 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 20B1610E3E3; Thu, 3 Dec 2026 21:37:53 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id B964510E3E3 for ; Thu, 3 Dec 2026 21:37:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796333867; x=1827869867; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=owmoCIcF30pm6uZur5auh/6mrDo2+uJ9nlnixtaN5Ho=; b=jjewsyx9aMkkPQS0Sxs5rvHhG+H7dFBDtt5+8aZK1DDnumJxv6nKT6Jd uvW3mm/RiqU+jVPoJeqawlBVqxJ4HYiye1IBgUPCOJX6lxCYuPnTWcC1k nINgnessCWrULOZBJeyZYPGD9HxqzDb8UCPTWoslXj81yGsXJmTOIG2g6 SECzC6HKpd4S2Iqd6AIkJzjK47QjoDg0lqoKkYiA7TuS9j06xMXTDq6Fk nJzNSIrdmDSUkq3MAWDZbOVG/XUsMRzKfIpBy20rXxC6MRh34opzvtKuV JVuzRh9M7eta8TcpGsG6NwxdErU1NyZD9AmAsAjYo+E9JyWvFTfsW2mLv g==; X-CSE-ConnectionGUID: LOwuX4oiSQ2M2/MGTe1DAw== X-CSE-MsgGUID: JZdTK9xWS7mMftE+m22SHg== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5306069" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5306069" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 13:37:46 -0800 X-CSE-ConnectionGUID: PtXEXkWMSoybPN+Bi/37hQ== X-CSE-MsgGUID: OuiiLZ9GTJGXvmqeCM/61Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="14198242" Received: from fmsmsx901.amr.corp.intel.com ([10.18.126.90]) by fmviesa007.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 13:37:45 -0800 Received: from FMSMSX903.amr.corp.intel.com (10.18.126.92) by fmsmsx901.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Thu, 3 Dec 2026 13:37:45 -0800 Received: from fmsedg902.ED.cps.intel.com (10.1.192.144) by FMSMSX903.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Thu, 3 Dec 2026 13:37:45 -0800 Received: from BL0PR03CU003.outbound.protection.outlook.com (52.101.53.66) by edgegateway.intel.com (192.55.55.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Thu, 3 Dec 2026 13:37:44 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Gc9/OJ/bk8Uh33JceTXAbuwZfceW2GG5O/dMTQJVRScjncPylQgmPhEzC6+/Y8/XPjj+6lfclX2+/HIou1EKZ/9MqnmRV4OB/kLlDzq9+EOpxGzR8KyI493hD7nmpZ5OLiN3WVPil8QxwQNX0vYdL3kGMxi4LOfrGIg5k/YlDTTa3PElF8UYtUCWnf5FFUGTBJO/LUVPSK7BZB/vnV/7cs4Y9lGPnvxqSjaKkYbLTyeH+7ND2WKXgfXhBTnd1lJaY1Ww5XQqqD6csLuAv8Fpk7OlBtwCmlabyrW2hn9Nkzschef+qkh77S0uvvnb2HB7t7TOLap7Bc/u+nn1YUM0bQ== 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=owmoCIcF30pm6uZur5auh/6mrDo2+uJ9nlnixtaN5Ho=; b=pUqQ4JWmYiA5MEXpfQuV6cT77k0pTWu5w8syPxviuft+KC2cNvupUGwjm9Wq6Cw9dRdCwDAJtXtsKyyTjsfaa2WuwLtDYvsJYhIfoVHwb30v2CldpcUIJCXqa88bHyXXJRDcvC9jV6p3tFC/U4MztN3i4aiuCg4TDzxJUiQbBRvY3siTQ7t7zqPNG89CVQMReN+XehWwBqm7g+1Adzbb7mp9dGdB3UzxRlsx6s3rexwmXR2TE9mzary8vF9p6eFvgaO+ucMmUWD4ZibjID5VqudRJ2uO7R8jaG30oMhmFThVXyfAWXRhLjBlWGb1r7JVzBs6tWAWz3xbNL1JD72iTw== 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 DM3PPF208195D8D.namprd11.prod.outlook.com (2603:10b6:f:fc00::f13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.12; Thu, 3 Dec 2026 21:37:40 +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.010; Thu, 3 Dec 2026 21:37:40 +0000 Date: Thu, 3 Dec 2026 16:37:35 -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: <20261203190926.249488-4-stuart.summers@intel.com> <20261203190926.249488-6-stuart.summers@intel.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261203190926.249488-6-stuart.summers@intel.com> X-ClientProxiedBy: PH7P220CA0128.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:327::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_|DM3PPF208195D8D:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e3a7b7c-b1d4-480d-25ef-08df5185a78d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|23010399003|366016|11063799006|5023799004|4143699003|6133799003|261009223027099003|261009221227099003|3023799007|10067099003|18002099003|22082099003|260925021311599003|260925022911599003|261102123227099003|260925021911599003|56012099006|261026121527099003|261022075727099003|261022113327099003|261026140227099003|261028144727099003|261021123027099003|261022105027099003|261021121427099003; X-Microsoft-Antispam-Message-Info: YJbv4C20JkiKR9OgBIYxfuwK1vb35mNJtTBF0vQQI57CcIXUT74og53uJOdbsfCf8LCqU3f+nX+NtcCWz2wsTq7UuuaZN1vWen0QN/cIAvc/Q6XP8Me+2bEBATz/CQvTXl2joF83M+Zf/10S/las925EVP9SGfERQN8nUX9O35PDEJrtEMALxH90gft1sC8813E5yoGjZzaJF/zWWS4HPdvR7DYKpnirB6byMAqbiTbuTe0EGPnTQClwyPircFwxIDoraAXIz0tw7SwWp4N3K/sl0/vm/lbhfDZpCMnWs/Zr0vgzpHKQNN/8FdQ/jn5HpNiMQErjNPlb7SbmByvZ0EVEyIEFPCygGoOfmd8QlPY2mbjtiaCxBQnGu3C8/oipwqxQHKBc4n29LVrROy3pe9m5pAQbqlZFAg0tpk+lWSD1sjx+FNeMZ2bN8sxZ3IZm/GqiDeEUgDycBJSb1Xa/hcGgK3QshP/Ua7NA2Vp+J4IEuhbcZHdecf99jSET2R43iePwE70ecWXWw+StdfbCiPqXfUK7ULOZxMDonKTuWKO5ydvi8p1kkCPuGZbWRAwHkfNoycNZs+U1c6SnwEwwtegf2KH2ffW4g/g3VSrbkH81BOg8MVXGLnu6dLmhHM80GYLD+TbvKYvjUMXlqCltiHrKK5tAh04bXxU+YqYvdts= 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)(376014)(1800799024)(23010399003)(366016)(11063799006)(5023799004)(4143699003)(6133799003)(261009223027099003)(261009221227099003)(3023799007)(10067099003)(18002099003)(22082099003)(260925021311599003)(260925022911599003)(261102123227099003)(260925021911599003)(56012099006)(261026121527099003)(261022075727099003)(261022113327099003)(261026140227099003)(261028144727099003)(261021123027099003)(261022105027099003)(261021121427099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?1aOSPWX945Zk1pJhLF0CkDnjlD8spudUVQO6k7CCelY804m4oYwWqva+jrOa?= =?us-ascii?Q?mhdlfywxvWnKQkNl7Y1QEehXCFE3QwlimfDQ6CQIvOWdju6YhjYAkWi5bkbi?= =?us-ascii?Q?uf3P+KcaWm3lpr6liszzXXp6JPBKcOCZmRMbijWD2AG+/C4THuslPx3II7yX?= =?us-ascii?Q?YVYR7m0VS7lbxbmI9HnfsuNUARr4lHBlPkkTCOlWzhIlbu8mkgUqfl5ZGcwH?= =?us-ascii?Q?QgrTNfpY0jY3WWWa7iczjMJ8NYxcvBYDfayfy/thot4jyyjYJw7NWH+aTNOj?= =?us-ascii?Q?7LM20Xjo0JBBt1bjA1f6XhMd2newmnnjSqMbRQ6CwAxGcuFRgB6XMsWHu2FJ?= =?us-ascii?Q?F1hp7FKmMSIfOvRTsFTc1HqFB513twQnoDAF6AtuYkyKBTx8uvuYDO/yJlFe?= =?us-ascii?Q?G1nsLH0KPcbEMSibn+XzQhaZCLTEydzk6eI9P+PqfvgOEgilUkpWGGXkP9hm?= =?us-ascii?Q?4xv/SJqeWM1ScyFbot7K+0Y6tR2Pn8Q5q/qj9+3MKGBQHO0UQ1ArvlxKqXnr?= =?us-ascii?Q?vcFYo/+o0F6vZOSO1elsFe1fFBs4D+ftuhK0JRZfCORi16PZtcfmAHNpBeO7?= =?us-ascii?Q?2dOmNaHlvjhR4U/KpXfcdir7X3cL05ZG9KTkICORNorqYPbntkfQf12ZNmO1?= =?us-ascii?Q?C09ZKfRpr7SL0OGQRSdpQPS+Gcy/LW/5kOzVrlAlATO8yri8hsEaA+v9rrV+?= =?us-ascii?Q?MyKpbuqhTF+9SobCTq4TdWA9LPPVCP4Pb1ZazLoLbBGDTXrxYSPU6qYBnDs9?= =?us-ascii?Q?1cGK9vnuPwwrrknCkESzvzHe9UUCqqrRjgf6N1MQe4f2bK7ezpkMN0EmoP6e?= =?us-ascii?Q?PDzowXwvMdgI97fp5dDxQsHBUaizSAhaS2Y1Nk+L9+y581vTf7PTrawXOR98?= =?us-ascii?Q?yM/pJBce7SMSStpe7t7sobC4zQIOofz9qgxHZZ86o9+FEGnte8qHeT5++qId?= =?us-ascii?Q?Bo8NiPEwGv4zU6+vzjR0Kv8MQffDL3o297lGCnH5yPn3RmtPcDlzG2DWS7Vl?= =?us-ascii?Q?swJlENvXR6udud11c9xewH97sL7/cA+dUoV/9E9+aCbNxvnePHII4XtnKqmj?= =?us-ascii?Q?5OLZtt79dtHYVCAEUtRF4yjLgJvSuUK+kLHN2UNZSc6AILfIx9vi14PCDnkW?= =?us-ascii?Q?TT61ZFZl/hNOgbI9a0kxdwhCJM7Y9AnUk77E3b0zVVFJYOUQOwTt4thwyngu?= =?us-ascii?Q?Cx6XRuSUr52sMxnVIY8XzAqRz1PigFAZgBo8JUYwDsLO6/oF9NZiigpNZXsN?= =?us-ascii?Q?5ZySupKmaDuOH/0fGAsariaJiC2fiis9WhNkjTv/1ZiwBOuY/NGzllfTJhLw?= =?us-ascii?Q?NGDeHp3O3LidSpmBzOeY5vO6B/5yu/snjrTKKfI788+DO82wGSdxeFPrneEd?= =?us-ascii?Q?MAUp84Udk80eisXGLYOGAIBJw1CgcsTwOj06LPv21qNcGZJ66eBaJWgmTudg?= =?us-ascii?Q?3H+m1hf3cFGL+bRWhdeO9lMRLmyiVkgtH8O4KDwVTgsVleW9xnHDxtbmuiaM?= =?us-ascii?Q?VqhoJVFjPbcUf9TCAKvUQ4y5SKQuQcOOzJP4X10J7xD+LOmjJKYJn19S0MYD?= =?us-ascii?Q?w/mzDQ8WQUquIT0Z3RG+sq9JGIzL5vg+3JDd0vW9gubOkjJvJC00o/etqC3a?= =?us-ascii?Q?nnKMhBzlZS9sm39Mm2fcU/4+/ep7O/BiUC285hhp8Lf+nUjhtPzTCRsEjqAj?= =?us-ascii?Q?HNiA7IRqHf233dXSLXHYE38Swounpf1v56w986IIlnjlxSLLdnslmqxrVqyH?= =?us-ascii?Q?86qiByK8kg=3D=3D?= X-Exchange-RoutingPolicyChecked: hy6w19vCbqMKugT+Af9oh2IQR8RGd+NvlG1cYnXZqqLnYnjCdgZ08TtNyEX1L3m/0ETuB+cRtUsTTVf6pc9bqOTeNlWOTiFuBW7D0c2cxrHX3VoOYaIfmeHYYzvJgwxFduC3CaGy1FP974ze2Cf29VKVgJKZ755M0X8IF3liQMECgFnuj754vz9+c75/8yVJ69q9WRRjQnZZziei4gD5awykZsWrr7SImRSYWAETpeJxFdAcAkArPF/ZNI3LUE5+J5wHa6OLEkxRzA+TW+oVToLtrttRHyyPri4fEwRS8GUhqm0i3xKW+cxoXIEt4c5krqBIzDqr/wRmnejMxC88eA== X-MS-Exchange-CrossTenant-Network-Message-Id: 4e3a7b7c-b1d4-480d-25ef-08df5185a78d X-MS-Exchange-CrossTenant-AuthSource: DS7PR11MB5990.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 21:37:39.9825 (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: JZzIZBoV1/9rzus8xSlf7UKV/L1SbfLIUbVIgk4s79YzmZcxCvrviTyxxSsL/xBweIgmbZdmTJPHeS+gpMYGDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PPF208195D8D 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=-15.8 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 07:09:27PM +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 host memory fits in 46 bits. > 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. > > HSDES: 14028632488 > > Signed-off-by: Stuart Summers > --- > 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 | 54 +++++- > drivers/gpu/drm/xe/xe_pm.c | 4 + > drivers/gpu/drm/xe/xe_sysctrl.c | 166 ++++++++++++++++++ > 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, 275 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c > index 1d9a2655a57b..a9a59d169e73 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_defeature(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 e1c31c96327d..090153996783 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,44 @@ 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; > +} > + > +/* > + * 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 = DIRECT_MAP_PHYSMEM_END; > + > + 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 +839,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 +871,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..04976dfd7ce2 100644 > --- a/drivers/gpu/drm/xe/xe_pm.c > +++ b/drivers/gpu/drm/xe/xe_pm.c > @@ -668,6 +668,10 @@ int xe_pm_runtime_resume(struct xe_device *xe) > if (xe->d3cold.allowed) > xe_sysctrl_pm_resume(xe); > > + err = xe_sysctrl_media_defeature(xe); > + if (err) > + goto out; do we really need this on every rpm resume? even on D3hot when we are sure we didn't lose power? Shouldn't we move this to d3cold allowed block? > + > 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..2095355ae674 100644 > --- a/drivers/gpu/drm/xe/xe_sysctrl.c > +++ b/drivers/gpu/drm/xe/xe_sysctrl.c > @@ -5,12 +5,16 @@ > > #include > #include > +#include > > #include > > +#include > + > #include "regs/xe_irq_regs.h" > #include "regs/xe_sysctrl_regs.h" > #include "xe_device.h" > +#include "xe_force_wake.h" > #include "xe_mmio.h" > #include "xe_pm.h" > #include "xe_printk.h" > @@ -19,6 +23,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 +108,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 +255,163 @@ 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; > + } > + > + 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 and report the outcome */ > +static int sysctrl_media_defeature_send(struct xe_device *xe, u8 feature) > +{ > + bool media_allowed = feature == XE_SYSCTRL_MEDIA_DEFEATURE_ATS_DISABLE; > + 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)); > + return ret; > + } > + > + xe_info(xe, "sysctrl: media %s, %s defeatured\n", > + media_allowed ? "enabled" : "disabled", > + media_allowed ? "address translation" : "media"); > + > + return 0; > +} > + > +/* 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_defeature() - Tell System Controller how media is configured > + * @xe: xe device instance > + * > + * The driver and the System Controller must agree on the media configuration > + * before media is used. When media is enabled, address translation for media > + * is not supported and must be defeatured. When media has been disabled by the > + * user, via either the enable_media modparam or the gt_types_allowed configfs > + * attribute, media itself is defeatured. > + * > + * This is restricted to platforms that need this workaround. > + * > + * Once a request has failed, the System Controller is assumed not to support > + * it and it is not sent again; this returns 0 from then on. > + * > + * Return: 0 on success, error code on failure > + */ > +int xe_sysctrl_media_defeature(struct xe_device *xe) > +{ > + bool media_allowed = xe_device_media_allowed(xe); > + u8 feature; > + int ret = 0; > + > + if (!sysctrl_media_defeature_needed(xe)) > + return 0; > + > + feature = media_allowed ? XE_SYSCTRL_MEDIA_DEFEATURE_ATS_DISABLE : > + XE_SYSCTRL_MEDIA_DEFEATURE_DISABLE; > + > + /* > + * If media is not present or if it is allowed but ATS is disabled, > + * nothing to do. > + */ > + if (xe_device_get_root_tile(xe)->media_gt) > + if (!media_allowed || (media_allowed && sysctrl_ats_enabled(xe))) > + ret = sysctrl_media_defeature_send(xe, feature); When media is forced off, alloc_media_gt() returns NULL, so media_gt is NULL here and the DISABLE is never sent. Perhaps: if (!media_allowed || (media_gt && sysctrl_ats_enabled(xe))) > + > + if (ret) > + xe->sc.has_media_feature_disable = false; > + > + return ret; > +} > + > +/* > + * Drop media from the device. Only safe during probe, before the media GT is > + * 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) > + tile->media_gt = NULL; > +} > + > +/** > + * xe_sysctrl_media_probe() - Configure media with the System Controller at probe > + * @xe: xe device instance > + * > + * Same as xe_sysctrl_media_defeature(), but media cannot be used while the > + * System Controller does not know how it is configured, so on failure media is > + * dropped and probe continues without it rather than failing driver load. > + * > + * Must be called from the same place xe_sysctrl_media_defeature() would be > + * called during probe. > + */ > +void xe_sysctrl_media_probe(struct xe_device *xe) > +{ > + if (!xe_sysctrl_media_defeature(xe)) > + return; > + > + /* > + * Media is going away, so ask the System Controller to defeature it > + * too. Nothing more can be done if even that fails, but the driver > + * does not touch media from here on either way. > + */ > + if (xe_device_media_allowed(xe)) > + sysctrl_media_defeature_send(xe, XE_SYSCTRL_MEDIA_DEFEATURE_DISABLE); > + > + sysctrl_media_drop(xe); > + > + xe_info(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..e1d4181942e0 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); > +int xe_sysctrl_media_defeature(struct xe_device *xe); > +void xe_sysctrl_media_probe(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..0cf265df1aa7 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. > + */ > + bool has_media_feature_disable; > + > /** @debugfs: Debugfs entries */ > struct { > /** @debugfs.root: Root debugfs directory */ > -- > 2.43.0 >