Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2229247/?format=api
{ "id": 2229247, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2229247/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pwm/patch/20260427221155.2144848-22-dakr@kernel.org/", "project": { "id": 38, "url": "http://patchwork.ozlabs.org/api/1.1/projects/38/?format=api", "name": "Linux PWM development", "link_name": "linux-pwm", "list_id": "linux-pwm.vger.kernel.org", "list_email": "linux-pwm@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260427221155.2144848-22-dakr@kernel.org>", "date": "2026-04-27T22:11:19", "name": "[REF,21/24] gpu: nova-core: use HRT lifetime for Bar", "commit_ref": null, "pull_url": null, "state": "handled-elsewhere", "archived": false, "hash": "22a862e06bafd582c1189d79532501812596dee2", "submitter": { "id": 89037, "url": "http://patchwork.ozlabs.org/api/1.1/people/89037/?format=api", "name": "Danilo Krummrich", "email": "dakr@kernel.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-pwm/patch/20260427221155.2144848-22-dakr@kernel.org/mbox/", "series": [ { "id": 501734, "url": "http://patchwork.ozlabs.org/api/1.1/series/501734/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pwm/list/?series=501734", "date": "2026-04-27T22:10:58", "name": "rust: device: Higher-Ranked Lifetime Types for device drivers", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/501734/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2229247/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2229247/checks/", "tags": {}, "headers": { "Return-Path": "\n <linux-pwm+bounces-8724-incoming=patchwork.ozlabs.org@vger.kernel.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "linux-pwm@vger.kernel.org" ], "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=W75RH2Y9;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pwm+bounces-8724-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)", "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"W75RH2Y9\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201" ], "Received": [ "from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4J0s34gfz1yHv\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 08:20:29 +1000 (AEST)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id DBACD3196472\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 22:15:19 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 20FDE3B0AC2;\n\tMon, 27 Apr 2026 22:14:21 +0000 (UTC)", "from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id EFDDE3AD528;\n\tMon, 27 Apr 2026 22:14:20 +0000 (UTC)", "by smtp.kernel.org (Postfix) with ESMTPSA id C523EC19425;\n\tMon, 27 Apr 2026 22:14:14 +0000 (UTC)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777328061; cv=none;\n b=IJKy0C9T/8i4UCmnXqSbI9bRY27h+WvjHLHgNbnfqDgnRION4TtvW4ztTGzMqKybWaNXnrFjyZ6vxvIs4W+L5FniK+Y23CvF7wrlOuiquB2kQUHXUrnDQPZz+KGiE5ZcPSTj8nixD+AR1g9R2kDQa/nXsF+K6J6O/yJezOg21Zw=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777328061; c=relaxed/simple;\n\tbh=+vCZJoneZObXHz+HrSLsZDDMk+BGXI4VJJ4WNODomsU=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=MOLQswjRkWU25KCwDxL1ie0+sm2zcfLl8KVLwV0mAuk7a8dR5LFePXjk4u7niBd/pPw/6RNp5edDnEDbyg+aBIXIv9VBd5fA6x1sobmLqvs4LJ9WmGYFJTfYAXGVoOFKagxTdMAUbq+8yXH0sn1+99FlLA5qudp6pM4J8/PDs10=", "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=W75RH2Y9; arc=none smtp.client-ip=10.30.226.201", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777328060;\n\tbh=+vCZJoneZObXHz+HrSLsZDDMk+BGXI4VJJ4WNODomsU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=W75RH2Y9F/+siwPQ1JHURZcogobZ9/VrlGLtxYgFA1gLCsqjOxrPQg1XKsISLV87C\n\t fQsa1U+tA3GM6aDw9oqcXpq5cLE+zLKREDMDG8R4OU9DliimeWPWQlG3kyJA7b5S7z\n\t ooGGLlzy1lXyPGwJ5q3stU6oLo6vInOjyWIa6D2C/FoLh6wMzJiRKEiVCBmR3IQgKe\n\t K7BFdXEiftt7WobIFyHxAHliiFeowDzCMDGRqPmLbKKR/m4a1yUzwHJVmPydCDKmIG\n\t yGznAjvJr6qehxk0Y5WUo7FrhKCcPUS5wIOfw08fSkAlbj9rXqvhoP1GC5FQqwFXIw\n\t pUy8/Ka1tYgpA==", "From": "Danilo Krummrich <dakr@kernel.org>", "To": "gregkh@linuxfoundation.org,\n\trafael@kernel.org,\n\tacourbot@nvidia.com,\n\taliceryhl@google.com,\n\tdavid.m.ertman@intel.com,\n\tira.weiny@intel.com,\n\tleon@kernel.org,\n\tviresh.kumar@linaro.org,\n\tm.wilczynski@samsung.com,\n\tukleinek@kernel.org,\n\tbhelgaas@google.com,\n\tkwilczynski@kernel.org,\n\tabdiel.janulgue@gmail.com,\n\trobin.murphy@arm.com,\n\tmarkus.probst@posteo.de,\n\tojeda@kernel.org,\n\tboqun@kernel.org,\n\tgary@garyguo.net,\n\tbjorn3_gh@protonmail.com,\n\tlossin@kernel.org,\n\ta.hindborg@kernel.org,\n\ttmgross@umich.edu", "Cc": "driver-core@lists.linux.dev,\n\tlinux-kernel@vger.kernel.org,\n\tnova-gpu@lists.linux.dev,\n\tdri-devel@lists.freedesktop.org,\n\tlinux-pm@vger.kernel.org,\n\tlinux-pwm@vger.kernel.org,\n\tlinux-pci@vger.kernel.org,\n\trust-for-linux@vger.kernel.org,\n\tDanilo Krummrich <dakr@kernel.org>", "Subject": "[PATCH REF 21/24] gpu: nova-core: use HRT lifetime for Bar", "Date": "Tue, 28 Apr 2026 00:11:19 +0200", "Message-ID": "<20260427221155.2144848-22-dakr@kernel.org>", "X-Mailer": "git-send-email 2.54.0", "In-Reply-To": "<20260427221155.2144848-1-dakr@kernel.org>", "References": "<20260427221155.2144848-1-dakr@kernel.org>", "Precedence": "bulk", "X-Mailing-List": "linux-pwm@vger.kernel.org", "List-Id": "<linux-pwm.vger.kernel.org>", "List-Subscribe": "<mailto:linux-pwm+subscribe@vger.kernel.org>", "List-Unsubscribe": "<mailto:linux-pwm+unsubscribe@vger.kernel.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit" }, "content": "Take advantage of the lifetime-parameterized pci::Bar<'a> to hold the\nBAR mapping directly in NovaCore<'a>, and pass a borrowed reference to\nGpu<'a>.\n\nThis eliminates the Arc<Devres<Bar0>> indirection, removes runtime\nrevocation checks for BAR access, and simplifies Gpu::unbind().\n\nSigned-off-by: Danilo Krummrich <dakr@kernel.org>\n---\n drivers/gpu/nova-core/driver.rs | 40 ++++++++++++++----------------\n drivers/gpu/nova-core/gpu.rs | 27 ++++++++------------\n drivers/gpu/nova-core/nova_core.rs | 2 +-\n 3 files changed, 30 insertions(+), 39 deletions(-)", "diff": "diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs\nindex 149a20748e86..ec9cecb30f63 100644\n--- a/drivers/gpu/nova-core/driver.rs\n+++ b/drivers/gpu/nova-core/driver.rs\n@@ -14,12 +14,9 @@\n },\n prelude::*,\n sizes::SZ_16M,\n- sync::{\n- atomic::{\n- Atomic,\n- Relaxed, //\n- },\n- Arc,\n+ sync::atomic::{\n+ Atomic,\n+ Relaxed, //\n },\n types::ForLt,\n };\n@@ -30,9 +27,10 @@\n static AUXILIARY_ID_COUNTER: Atomic<u32> = Atomic::new(0);\n \n #[pin_data]\n-pub(crate) struct NovaCore {\n+pub(crate) struct NovaCore<'a> {\n #[pin]\n- pub(crate) gpu: Gpu,\n+ pub(crate) gpu: Gpu<'a>,\n+ bar: pci::Bar<'a, BAR0_SIZE>,\n #[allow(clippy::type_complexity)]\n _reg: Devres<auxiliary::Registration<ForLt!(())>>,\n }\n@@ -47,12 +45,12 @@ pub(crate) struct NovaCore {\n // DMA addresses. These systems should be quite rare.\n const GPU_DMA_BITS: u32 = 47;\n \n-pub(crate) type Bar0 = pci::Bar<'static, BAR0_SIZE>;\n+pub(crate) type Bar0 = kernel::io::Mmio<BAR0_SIZE>;\n \n kernel::pci_device_table!(\n PCI_TABLE,\n MODULE_PCI_TABLE,\n- <NovaCore as pci::Driver<'_>>::IdInfo,\n+ <NovaCore<'_> as pci::Driver<'_>>::IdInfo,\n [\n // Modern NVIDIA GPUs will show up as either VGA or 3D controllers.\n (\n@@ -74,7 +72,7 @@ pub(crate) struct NovaCore {\n ]\n );\n \n-impl<'a> pci::Driver<'a> for NovaCore {\n+impl<'a> pci::Driver<'a> for NovaCore<'a> {\n type IdInfo = ();\n const ID_TABLE: pci::IdTable<Self::IdInfo> = &PCI_TABLE;\n \n@@ -93,14 +91,14 @@ fn probe(\n // other threads of execution.\n unsafe { pdev.dma_set_mask_and_coherent(DmaMask::new::<GPU_DMA_BITS>())? };\n \n- let bar = Arc::new(\n- pdev.iomap_region_sized::<BAR0_SIZE>(0, c\"nova-core/bar0\")?\n- .into_devres()?,\n- GFP_KERNEL,\n- )?;\n-\n- Ok(try_pin_init!(Self {\n- gpu <- Gpu::new(pdev, bar.clone(), bar.access(pdev.as_ref())?),\n+ Ok(try_pin_init!(NovaCore {\n+ bar: pdev.iomap_region_sized::<BAR0_SIZE>(0, c\"nova-core/bar0\")?,\n+ // TODO: Use `&bar` self-referential pin-init syntax once available.\n+ //\n+ // SAFETY: `bar` is initialized before this expression is evaluated\n+ // (`try_pin_init!()` initializes fields in declaration order), lives at a pinned\n+ // stable address, and is dropped after `gpu` (struct field drop order).\n+ gpu <- Gpu::new(pdev, unsafe { &*core::ptr::from_ref(bar) }),\n _reg: auxiliary::Registration::new(\n pdev.as_ref(),\n c\"nova-drm\",\n@@ -114,7 +112,7 @@ fn probe(\n })\n }\n \n- fn unbind(pdev: &pci::Device<Core>, this: Pin<&Self>) {\n- this.gpu.unbind(pdev.as_ref());\n+ fn unbind(_pdev: &'a pci::Device<Core>, this: Pin<&'a Self>) {\n+ this.gpu.unbind();\n }\n }\ndiff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs\nindex 0f6fe9a1b955..922197f2aeef 100644\n--- a/drivers/gpu/nova-core/gpu.rs\n+++ b/drivers/gpu/nova-core/gpu.rs\n@@ -2,13 +2,11 @@\n \n use kernel::{\n device,\n- devres::Devres,\n fmt,\n io::Io,\n num::Bounded,\n pci,\n- prelude::*,\n- sync::Arc, //\n+ prelude::*, //\n };\n \n use crate::{\n@@ -224,10 +222,10 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n \n /// Structure holding the resources required to operate the GPU.\n #[pin_data]\n-pub(crate) struct Gpu {\n+pub(crate) struct Gpu<'a> {\n spec: Spec,\n- /// MMIO mapping of PCI BAR 0\n- bar: Arc<Devres<Bar0>>,\n+ /// MMIO mapping of PCI BAR 0.\n+ bar: &'a Bar0,\n /// System memory page required for flushing all pending GPU-side memory writes done through\n /// PCIE into system memory, via sysmembar (A GPU-initiated HW memory-barrier operation).\n sysmem_flush: SysmemFlush,\n@@ -240,10 +238,9 @@ pub(crate) struct Gpu {\n gsp: Gsp,\n }\n \n-impl Gpu {\n- pub(crate) fn new<'a>(\n+impl<'a> Gpu<'a> {\n+ pub(crate) fn new(\n pdev: &'a pci::Device<device::Bound>,\n- devres_bar: Arc<Devres<Bar0>>,\n bar: &'a Bar0,\n ) -> impl PinInit<Self, Error> + 'a {\n try_pin_init!(Self {\n@@ -257,6 +254,8 @@ pub(crate) fn new<'a>(\n .inspect_err(|_| dev_err!(pdev, \"GFW boot did not complete\\n\"))?;\n },\n \n+ bar,\n+\n sysmem_flush: SysmemFlush::register(pdev.as_ref(), bar, spec.chipset)?,\n \n gsp_falcon: Falcon::new(\n@@ -270,19 +269,13 @@ pub(crate) fn new<'a>(\n gsp <- Gsp::new(pdev),\n \n _: { gsp.boot(pdev, bar, spec.chipset, gsp_falcon, sec2_falcon)? },\n-\n- bar: devres_bar,\n })\n }\n \n /// Called when the corresponding [`Device`](device::Device) is unbound.\n ///\n /// Note: This method must only be called from `Driver::unbind`.\n- pub(crate) fn unbind(&self, dev: &device::Device<device::Core>) {\n- kernel::warn_on!(self\n- .bar\n- .access(dev)\n- .inspect(|bar| self.sysmem_flush.unregister(bar))\n- .is_err());\n+ pub(crate) fn unbind(&self) {\n+ self.sysmem_flush.unregister(self.bar);\n }\n }\ndiff --git a/drivers/gpu/nova-core/nova_core.rs b/drivers/gpu/nova-core/nova_core.rs\nindex 49c093a0cb42..ed5eb39c8201 100644\n--- a/drivers/gpu/nova-core/nova_core.rs\n+++ b/drivers/gpu/nova-core/nova_core.rs\n@@ -49,7 +49,7 @@ struct NovaCoreModule {\n // then `_debugfs_guard` clears `DEBUGFS_ROOT`.\n #[allow(clippy::type_complexity)]\n #[pin]\n- _driver: Registration<pci::Adapter<ForLt!(driver::NovaCore)>>,\n+ _driver: Registration<pci::Adapter<ForLt!(driver::NovaCore<'_>)>>,\n _debugfs_guard: DebugfsRootGuard,\n }\n \n", "prefixes": [ "REF", "21/24" ] }