dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Dave Airlie via B4 Relay" <devnull+airlied.redhat.com@kernel.org>
Cc: <airlied@redhat.com>, "Alice Ryhl" <aliceryhl@google.com>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"David Airlie" <airlied@gmail.com>,
	"Benno Lossin" <lossin@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	<nova-gpu@lists.linux.dev>, <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] gpu: nova-core: make bar1 optional
Date: Mon, 26 Oct 2026 13:11:47 +0100	[thread overview]
Message-ID: <DMERDJZTGIN2.3GG2GSRWTLE2X@kernel.org> (raw)
In-Reply-To: <20261026-nova-bar1-option-v1-1-8b43585881a3@redhat.com>

On Mon Oct 26, 2026 at 4:50 AM CET, Dave Airlie via B4 Relay wrote:
> @@ -135,7 +139,12 @@ fn probe<'bound>(
>                  // SAFETY: `bar` is initialized above, pinned, and outlives `gpu`.
>                  unsafe { &*core::ptr::from_ref(bar) },
>                  // SAFETY: `bar1` is initialized above, pinned, and outlives `gpu`.
> -                unsafe { &*core::ptr::from_ref(bar1) },
> +                unsafe {
> +                    match bar1 {
> +                        None => None,
> +                        Some(bar1) => Some(&*core::ptr::from_ref(bar1)),
> +                    }
> +                },

This can just be

	bar1.as_ref().map(|b| unsafe { &*core::ptr::from_ref(b) })

> +    /// BAR1 user interface for CPU access to GPU virtual memory, if the device has BAR1.
> +    bar_user: Option<Pin<KBox<BarUser<'gpu>>>>,

Can we please add a TODO to replace this, once we can get rid of the extra
allocation?

> +            bar_user: match bar1 {
> +                None => None,
> +                Some(bar1) => Some({
> +                    let pdb_addr = VramAddress::from_raw(gsp_static_info.bar1_pde_base);
> +                    let bar1_idx = crate::driver::bar1_resource_index(pdev)?;
> +                    let bar1_size = pdev.resource_len(bar1_idx)?;
> +
> +                    KBox::pin_init(
> +                        BarUser::new(
> +                            pdb_addr,
> +                            gsp_resources.spec.chipset,
> +                            bar1_size,
> +                            bar1,
> +                        ),
> +                        GFP_KERNEL,
> +                    )?
> +                }),

I think this could also use map().

      reply	other threads:[~2026-10-26 12:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26  3:50 [PATCH] gpu: nova-core: make bar1 optional Dave Airlie via B4 Relay
2026-10-26 12:11 ` Danilo Krummrich [this message]

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=DMERDJZTGIN2.3GG2GSRWTLE2X@kernel.org \
    --to=dakr@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=airlied@redhat.com \
    --cc=aliceryhl@google.com \
    --cc=devnull+airlied.redhat.com@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=lossin@kernel.org \
    --cc=nova-gpu@lists.linux.dev \
    /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