dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Alexandre Courbot" <acourbot@nvidia.com>
Cc: <nouveau@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>,
	"Nouveau" <nouveau-bounces@lists.freedesktop.org>
Subject: Re: [PATCH] gpu: nova-core: take advantage of pci::Device::unbind()
Date: Mon, 01 Sep 2025 16:54:13 +0200	[thread overview]
Message-ID: <DCHJT462NSWC.RGNMTKZY295P@kernel.org> (raw)
In-Reply-To: <DCHHNSM1VS76.3ET66BZWUXCOM@nvidia.com>

On Mon Sep 1, 2025 at 3:13 PM CEST, Alexandre Courbot wrote:
> On Mon Sep 1, 2025 at 7:41 PM JST, Danilo Krummrich wrote:
>> On Sun Aug 31, 2025 at 3:50 PM CEST, Alexandre Courbot wrote:
>>>> +    pub(crate) fn unbind(&self, pdev: &pci::Device<device::Bound>) {
>>>> +        // Unregister the sysmem flush page before we release it.
>>>> +        kernel::warn_on!(self.bar.access(pdev.as_ref()).map_or(true, |bar| {
>>>> +            self.sysmem_flush.unregister(bar);
>>>> +
>>>> +            false
>>>> +        }));
>>>> +    }
>>>
>>> Maybe I'm overtly cautious, but this method can be called from a large
>>> part of the driver, leaving the Gpu device in a half-unbound state. The
>>> `PinnedDrop` approach had the benefit of not allowing this.
>>>
>>> One way to solve the problem would be to make this method `pub(in
>>> crate::driver)`, so other modules cannot call it.
>>
>> pub(in crate::driver) doesn't work, since hierarchically it's a sibling. :(
>
> Argh. TIL.
>
>>
>> However, I can add a doc-comment to make it a bit more obvious.
>
> Would it also help if we made `Gpu::unbind` take a
> `pci::Device<device::Core>`? That way, driver functions that only have a
> bound device could not invoke it.

This was my intention, but somehow I typed Bound.

> (also, should we make the argument a `device::Device` instead of a
> `pci::Device`?)

I think it makes sense to abstract the specific bus device, since long term we
also want to support tegra.

      reply	other threads:[~2025-09-01 14:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-30 13:32 [PATCH] gpu: nova-core: take advantage of pci::Device::unbind() Danilo Krummrich
2025-08-30 13:51 ` Danilo Krummrich
2025-08-31 13:50 ` Alexandre Courbot
2025-09-01 10:41   ` Danilo Krummrich
2025-09-01 13:13     ` Alexandre Courbot
2025-09-01 14:54       ` 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=DCHJT462NSWC.RGNMTKZY295P@kernel.org \
    --to=dakr@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=nouveau-bounces@lists.freedesktop.org \
    --cc=nouveau@lists.freedesktop.org \
    /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).