rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gary Guo <gary@garyguo.net>
To: Timur Tabi <ttabi@nvidia.com>
Cc: Danilo Krummrich <dakr@kernel.org>,
	Alexandre Courbot <acourbot@nvidia.com>,
	John Hubbard <jhubbard@nvidia.com>, <joelagnelf@nvidia.com>,
	<lyude@redhat.com>, <nouveau@lists.freedesktop.org>,
	<rust-for-linux@vger.kernel.org>
Subject: Re: [PATCH 2/7] gpu: nova-core: Replace module_pci_driver! with explicit module init
Date: Mon, 15 Dec 2025 11:36:30 +0000	[thread overview]
Message-ID: <20251215113630.5223e246.gary@garyguo.net> (raw)
In-Reply-To: <20251212204952.3690244-3-ttabi@nvidia.com>

On Fri, 12 Dec 2025 14:49:47 -0600
Timur Tabi <ttabi@nvidia.com> wrote:

> Replace the module_pci_driver! macro with an explicit module
> initialization using the standard module! macro and InPlaceModule
> trait implementation.  No functional change intended, with the
> exception that the driver now prints a message when loaded.
> 
> Also add a no-op module exit function as a template.
> 
> This change is necessary so that we can create a top-level "novacore"
> debugfs entry when the driver is loaded.
> 
> Signed-off-by: Timur Tabi <ttabi@nvidia.com>
> ---
>  drivers/gpu/nova-core/nova_core.rs | 29 ++++++++++++++++++++++++++---
>  1 file changed, 26 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/nova-core/nova_core.rs b/drivers/gpu/nova-core/nova_core.rs
> index b98a1c03f13d..7d7b75650b04 100644
> --- a/drivers/gpu/nova-core/nova_core.rs
> +++ b/drivers/gpu/nova-core/nova_core.rs
> @@ -2,6 +2,9 @@
>  
>  //! Nova Core GPU Driver
>  
> +use kernel::{error::Error, pci, prelude::*, InPlaceModule};
> +use pin_init::{PinInit, pinned_drop};
> +
>  #[macro_use]
>  mod bitfield;
>  
> @@ -21,13 +24,33 @@
>  
>  pub(crate) const MODULE_NAME: &kernel::str::CStr = <LocalModule as kernel::ModuleMetadata>::NAME;
>  
> -kernel::module_pci_driver! {
> -    type: driver::NovaCore,
> +#[pin_data(PinnedDrop)]
> +struct NovaCoreModule {
> +    #[pin]
> +    _driver: kernel::driver::Registration<pci::Adapter<driver::NovaCore>>,
> +}
> +
> +impl InPlaceModule for NovaCoreModule {
> +    fn init(module: &'static kernel::ThisModule) -> impl PinInit<Self, Error> {
> +        pr_info!("NovaCore GPU driver loaded\n");
> +        try_pin_init!(Self {
> +            _driver <- kernel::driver::Registration::new(MODULE_NAME, module),
> +        })
> +    }
> +}
> +
> +#[pinned_drop]
> +impl PinnedDrop for NovaCoreModule {
> +    fn drop(self: Pin<&mut Self>) {
> +    }
> +}

I don't see any subsequent patch that makes use of this added drop impl.
Why is it needed?

Best,
Gary

> +
> +module! {
> +    type: NovaCoreModule,
>      name: "NovaCore",
>      authors: ["Danilo Krummrich"],
>      description: "Nova Core GPU driver",
>      license: "GPL v2",
> -    firmware: [],
>  }
>  
>  kernel::module_firmware!(firmware::ModInfoBuilder);


  parent reply	other threads:[~2025-12-15 11:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-12 20:49 [PATCH 0/7] gpu: nova-core: expose the logging buffers via debugfs Timur Tabi
2025-12-12 20:49 ` [PATCH 1/7] rust: pci: add PCI device name method Timur Tabi
2025-12-15 11:35   ` Gary Guo
2025-12-15 16:49   ` lyude
2025-12-12 20:49 ` [PATCH 2/7] gpu: nova-core: Replace module_pci_driver! with explicit module init Timur Tabi
2025-12-13 23:46   ` Joel Fernandes
2025-12-15 11:36   ` Gary Guo [this message]
2025-12-12 20:49 ` [PATCH 3/7] gpu: nova-core: create debugfs root in PCI init closure Timur Tabi
2025-12-15 11:40   ` Gary Guo
2025-12-15 16:45     ` Timur Tabi
2025-12-16 10:04       ` John Hubbard
2025-12-16 20:28         ` Timur Tabi
2025-12-16 22:01           ` Joel Fernandes
2025-12-16 22:29             ` Timur Tabi
2025-12-16 23:17               ` Joel Fernandes
2025-12-16 23:29                 ` Timur Tabi
2025-12-12 20:49 ` [PATCH 4/7] gpu: nova-core: implement BinaryWriter for LogBuffer Timur Tabi
2025-12-12 20:49 ` [PATCH 5/7] gpu: nova-core: use pin projection in method boot() Timur Tabi
2025-12-12 20:49 ` [PATCH 6/7] gpu: nova-core: create loginit debugfs entry Timur Tabi
2025-12-15 16:45   ` Timur Tabi
2025-12-12 20:49 ` [PATCH 7/7] gpu: nova-core: create GSP-RM logging buffers debugfs entries Timur Tabi
2025-12-13 23:44   ` Joel Fernandes
2025-12-13 19:19 ` [PATCH 0/7] gpu: nova-core: expose the logging buffers via debugfs Joel Fernandes
2025-12-13 20:47   ` Timur Tabi
2025-12-13 21:49     ` Joel Fernandes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251215113630.5223e246.gary@garyguo.net \
    --to=gary@garyguo.net \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=jhubbard@nvidia.com \
    --cc=joelagnelf@nvidia.com \
    --cc=lyude@redhat.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=ttabi@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).