From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011044.outbound.protection.outlook.com [40.93.194.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B29D0346E60 for ; Fri, 3 Jul 2026 06:45:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.194.44 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783061155; cv=fail; b=ojqMycpDVGLzTKp9JHZS04if4kXPgUBvU9BnEVYeoLDp5Jxgyi63wtNe9AVb/9AWOBzKYnnl32ScsrLc8l5cwdinqOZjpGr2jVlCCLCBj9Y9BBT76gRD+1h7sgC7zXRHiT90vhdmNq8RIBajFgH9EWpB1rg20Se0jpBCdUmYTLo= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783061155; c=relaxed/simple; bh=ovR8DilyOCs0LEtEJ+I8NW4PeasmpQa3Ij5FizVLNng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=lXOj+PH8ZBfuNyL0rav7l7/tZ9n16DWaB/YptrXjb2Jh1/+eZulX6VRfInsbyvAD6foQGD5qvyXGWGccguknSRZ4hMLqsXnh6fOMZWiWgRbzdiM6ZVCkfrZtzEGpzwFA9ZACZkRdIopXUPkgbho8rblPbqaoY7np/lUhszCkdW4= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=UKaU9S1m; arc=fail smtp.client-ip=40.93.194.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="UKaU9S1m" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=flumdvpCMAl9L2Za7+Nfo5R8Q4EXkH+EQUA7Vx0A6tuGlOodDydHWmgiRvOdgOCALu87Zd7FreQpHHa8kGxvBri3ZodeCxQc7gvSno9D5D2C5nxv/E6A16ffMMSd3NvBZTSKZRncjyViCuV1OESEUux6YS+6nVBdqtt3eixqS9CZ0kgUHjE4xl5BBZcahcy/JSsGUdjbNVynjokpDN3kQOP2JRFJ3Ni2kPdC1OmZbXxeG/qVY+IPRooKZe6ZCGB5RZZtn5qvnrjfEx1gS253DhtxAAoodAQ0UK7mymh+6gtY5xMCnh50P2Q2O4KebJrVNJVBA6mnBTMoLsHmFVO4Ew== 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=tVpiZ+V6EIihj4jtxmELm5Lbltx7Fbq6PAzUjqPRDuQ=; b=XqxXhwg6wQ/IJDm+TOeRposnYi75mi1CAf78vEMMmpJgHj1el8Y+AuDwEobLvXQf3e2y1xTWDoHcTlYjDjJGHWtNsg6URAWzj6rnHTa8RbOEgPECUAjPI4a0xlFXXYxu6fZ5b4Gb/pQ4MUI7U4LS2oxaod+nT41j5cEh6nONFDTo7s62VOLhDR4XvI5fjktL2XTCkHIFVhcxsNONxNCevr10/F4XiJHq2O06h4NuqWlRcM/Ohh3S/f0vMezNdYrU59tvZu5u1/+xeEfJUL0zGLjPmd51t3SsbXDfoQ+dICiPBvN+HWSCU/DhRYWYwbzPUrarNrKbKZps7LrijjQiFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tVpiZ+V6EIihj4jtxmELm5Lbltx7Fbq6PAzUjqPRDuQ=; b=UKaU9S1mZ/EhSqtKTZ3WwLuBU+d4kgs77phFjTif/QLGRVSCjf6fMr5wJMINAGhxkv4vy9OoEhAM+GHEzoYS3XWGcSP94rsbnrztZTT8ukdAW5ewLDDlHz7auHA+i5EDZbSPxMs7ojmYpbZtyFHNXo9iDP5oEzu5nbsqWrkvPRLccvDGMbBOtuEMPuwI1+kqxK20wS+LiC37AY2uLC6AzGYblxzVQ78umS3kO8jwTux32+B0Gt+y2nl/5yWcHAZqjDn5JvofPedHrOBO/9mpqaLEW6madd+P7SjeEIeymxZWm33JjfWpd+ovH1pvS0k8jKorty+jwWR5U4s93gtwPg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by SA1PR12MB5637.namprd12.prod.outlook.com (2603:10b6:806:228::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.181.8; Fri, 3 Jul 2026 06:45:48 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::5807:8e24:69b0:f6c0]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::5807:8e24:69b0:f6c0%4]) with mapi id 15.21.0181.008; Fri, 3 Jul 2026 06:45:48 +0000 From: Alistair Popple To: nova-gpu@lists.linux.dev Cc: Alistair Popple , Danilo Krummrich , Alice Ryhl , David Airlie , Alexandre Courbot , Benno Lossin , Gary Guo , Eliot Courtney , John Hubbard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org Subject: [RFC 2/3] drm: nova: Add GETPARAM parameter to read the GPU chipset Date: Fri, 3 Jul 2026 16:45:25 +1000 Message-ID: <20260703064526.3630668-3-apopple@nvidia.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260703064526.3630668-1-apopple@nvidia.com> References: <20260703064526.3630668-1-apopple@nvidia.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SY5P282CA0122.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:209::15) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: nova-gpu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|SA1PR12MB5637:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f3a1848-fcd2-4bb3-d3f2-08ded8ceb6fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|23010399003|366016|11062099010|18002099003|22082099003|7136999003|11063799006|56012099006; X-Microsoft-Antispam-Message-Info: xKvwbu7ZPlhjOzyMwkVCpWt+H1C5kCIHmRQD/cq4wmaqLl79s4Rqf6gnS2UwIQRQAOG0pUPsjBIlXfPZXZtiWVCbgYLPme5ZAhpwuZdpVLByWyE7ddn73qStT7wcv/zx6Qweuco8hCXthammpS0nGDTaa7H4j50I/pM0GdIdFvjapCmyBT4VgvBtoDozmgJ0JyigGj0AcrUhzpg2We4a2eFiwGBHeRqEjkMOQeNwTy49XJOGqakMgtFYO1BlToBvITUjG9DdiB3mdazYVRuVNuCsc/AXNqKhrD0cBohyuwoBfwdyfLVcktRnCiOLY0aCCJDAn5Vl20mpIdWv87cGskuSLdZAzikO+mXT71NO75ld9TBoGDN5kscgo2jpLJyJDivBUeDfpmk6wvNCZH/jNPhZjidm2/BfA5sr7nz7WPIzW85GESnUf8tkyNE19iXmbQOsQwkFYK6n4W4Kc9gyEnmfW54ugO2InBECwF+o1UgyM4bCt9R5+YBe97sAH1fjnwi+fkoCa1F88yPiKFp7qjRvWJZqMdqTyfmYHbj6Sqd1GJpU/hkTqw+c/yGvIVoEcsC/lV6CwJNLF6tEVkdC4xZdcKesc7VGGl3VoeBtO9oMgvVPR6DWvK5Njm+AOptBFvrZMxcjq6UqV6Z1x2xEtSvOqNNkADF87uq7HwNTVVE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(23010399003)(366016)(11062099010)(18002099003)(22082099003)(7136999003)(11063799006)(56012099006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?N3OwPxIfBy+oujes+wcep6joPR8t2Nf2/AQrMkHt+ROkBEf73vAZv4SD88xx?= =?us-ascii?Q?UjGVHtc3qAndhGsKjFMrbiST1XET353OvZmIp2FllZyieg8fhSZ7jAk4bYUI?= =?us-ascii?Q?KSBmdomSRj5IsOpibhfIwAI9MN7+T/x9M9Bdllo3uIombyNUzLED0XX4DXGq?= =?us-ascii?Q?x9NOz6JPO2r40OyQO/gVSi8rM2MCT7v2M+DpLmaGIEQkpsf03XCTKPWFQmiE?= =?us-ascii?Q?3YGDHNReN8Ky6rLjhge0tKkhOXZ2ZA1YYlMCnMIn7+E9rbyM9hv+tG7GQ7gK?= =?us-ascii?Q?E3ZsTCkZybnaZHzJsKrIDtskQd5NSQTNvl6lhYRLRVSChKXnBUxwOEjz9jf/?= =?us-ascii?Q?nx7fQwcSFrUUkvAPvtTV+JQevuE/fg4W9B5bonas+8fYsUVJGFK96bcg1T/L?= =?us-ascii?Q?I2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0fG6eX/P0KUDldn5DX1FjX?= =?us-ascii?Q?kX4jb+3iofb0c5kvQAUnyodmd/5g9WurU073lTZPS9nYR7X+6dtWf/GAzXwc?= =?us-ascii?Q?p2j89KIDfPgfjDtty5WwrQr8REkZukTMbueV9/65XrAKX5CfMiizUCmqA/54?= =?us-ascii?Q?4LJRgSSEFWG2XxHFW5qfHn78dlYNqiGDQHvAVte7l6oSuujBXfiwHKuSNRNw?= =?us-ascii?Q?qqJXP3lmmiG6Jw8OmZcDWBKO66J7Ehto8TcxvpXhfKiL8QGePg87d7QVLLg1?= =?us-ascii?Q?AwAbjbAqLhzjeMhq+U6pm/ygggz/F46zQfYYtO/CUgxZzwkaJPTFs4jLV3f0?= =?us-ascii?Q?PhoYO0cy5DaqGzDmSw4PLcge4rL6zhe85o//q8Yd2mN6Z3rxU3Qs9EYROkWR?= =?us-ascii?Q?952icE8RUZouT8dx7bEhRNVWn2C+OyziLyZ5/DVHjPwC2bsnXO633LHhPtqj?= =?us-ascii?Q?FeIs6fcraA=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f3a1848-fcd2-4bb3-d3f2-08ded8ceb6fa X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2026 06:45:48.0382 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6oQqqSEhVksHipTr2zbh0zUucZqd8bM3P1oVVRA+/s7YGdlAN3Ba0mgQFdqFGdtXxs1Ya8jeJcMXlkPL7XB/MQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5637 One of the first things a user needs to know about a GPU is its chipset, so add an ioctl to return that. Signed-off-by: Alistair Popple --- drivers/gpu/drm/nova/file.rs | 5 +++++ drivers/gpu/nova-core/auxdata.rs | 10 +++++++++- drivers/gpu/nova-core/driver.rs | 2 +- drivers/gpu/nova-core/gpu.rs | 10 +++++----- include/uapi/drm/nova_drm.h | 7 +++++++ 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/nova/file.rs b/drivers/gpu/drm/nova/file.rs index 298c02bacb4b..8147dfb366d8 100644 --- a/drivers/gpu/drm/nova/file.rs +++ b/drivers/gpu/drm/nova/file.rs @@ -16,6 +16,9 @@ uapi, }; +use kernel::types::ForLt; +use nova_core::auxdata::AuxData; + pub(crate) struct File; impl drm::file::DriverFile for File { @@ -36,9 +39,11 @@ pub(crate) fn get_param( ) -> Result { let adev: &auxiliary::Device = dev.as_ref(); let pdev: &pci::Device = adev.parent().try_into()?; + let data = adev.registration_data::)>()?; let value = match getparam.param as u32 { uapi::NOVA_GETPARAM_VRAM_BAR_SIZE => pdev.resource_len(1)?, + uapi::NOVA_GETPARAM_GPU_CHIPSET => data.chipset() as u64, _ => return Err(EINVAL), }; diff --git a/drivers/gpu/nova-core/auxdata.rs b/drivers/gpu/nova-core/auxdata.rs index 266b5ce4ee89..cd8a3511293b 100644 --- a/drivers/gpu/nova-core/auxdata.rs +++ b/drivers/gpu/nova-core/auxdata.rs @@ -3,10 +3,18 @@ //! Nova-core auxbus data. Contains all the methods used by the auxbus drivers //! to interact with nova-core. +use crate::gpu::Chipset; use crate::gpu::Gpu; /// Auxiliary bus registration data. Used by the auxbus drivers to call methods on /// the GPU. pub struct AuxData<'bound> { - pub(crate) _gpu: &'bound Gpu<'bound>, + pub(crate) gpu: &'bound Gpu<'bound>, +} + +impl AuxData<'_> { + /// Returns the chipset of this GPU. + pub fn chipset(&self) -> Chipset { + self.gpu.spec.chipset + } } diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs index ad232ca11833..193e87ac624e 100644 --- a/drivers/gpu/nova-core/driver.rs +++ b/drivers/gpu/nova-core/driver.rs @@ -112,7 +112,7 @@ fn probe<'bound>( // (`try_pin_init!()` initializes fields in declaration order), lives at // a pinned stable address, and is dropped after `_reg` (struct field // drop order). - _gpu: &*core::ptr::from_ref(&this.as_ref().gpu), + gpu: &*core::ptr::from_ref(&this.as_ref().gpu), }, )? }, diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs index 43c3f4f8df71..d4a71a1be6f1 100644 --- a/drivers/gpu/nova-core/gpu.rs +++ b/drivers/gpu/nova-core/gpu.rs @@ -38,7 +38,7 @@ macro_rules! define_chipset { { /// Enum representation of the GPU chipset. #[derive(fmt::Debug, Copy, Clone, PartialOrd, Ord, PartialEq, Eq)] - pub(crate) enum Chipset { + pub enum Chipset { $($variant = $value),*, } @@ -114,7 +114,7 @@ fn try_from(value: u32) -> Result { }); impl Chipset { - pub(crate) const fn arch(self) -> Architecture { + pub const fn arch(self) -> Architecture { match self { Self::TU102 | Self::TU104 | Self::TU106 | Self::TU117 | Self::TU116 => { Architecture::Turing @@ -172,7 +172,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { bounded_enum! { /// Enum representation of the GPU generation. #[derive(fmt::Debug, Copy, Clone)] - pub(crate) enum Architecture with TryFrom> { + pub enum Architecture with TryFrom> { Turing = 0x16, Ampere = 0x17, Hopper = 0x18, @@ -206,7 +206,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { /// Structure holding a basic description of the GPU: `Chipset` and `Revision`. #[derive(Clone, Copy)] pub(crate) struct Spec { - chipset: Chipset, + pub(crate) chipset: Chipset, revision: Revision, } @@ -286,7 +286,7 @@ struct GspResources<'gpu> { /// Structure holding the resources required to operate the GPU. #[pin_data] pub(crate) struct Gpu<'gpu> { - spec: Spec, + pub(crate) spec: Spec, /// Static GPU information as provided by the GSP. gsp_static_info: GetGspStaticInfoReply, /// GSP and its resources. diff --git a/include/uapi/drm/nova_drm.h b/include/uapi/drm/nova_drm.h index 3ca90ed9d2bb..63440f5dca9b 100644 --- a/include/uapi/drm/nova_drm.h +++ b/include/uapi/drm/nova_drm.h @@ -25,6 +25,13 @@ extern "C" { */ #define NOVA_GETPARAM_VRAM_BAR_SIZE 0x1 +/* + * NOVA_GETPARAM_GPU_CHIPSET + * + * Query the GPU chipset architecture/implementation. + */ +#define NOVA_GETPARAM_GPU_CHIPSET 0x2 + /** * struct drm_nova_getparam - query GPU and driver metadata */ -- 2.54.0