NVIDIA GPU driver infrastructure
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Eliot Courtney" <ecourtney@nvidia.com>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Burak Emir" <burak.emir@gmail.com>,
	"Yury Norov" <yury.norov@gmail.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Timur Tabi" <ttabi@nvidia.com>, "Zhi Wang" <zhiw@nvidia.com>,
	nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v10 3/3] gpu: nova-core: add ChannelIdPool
Date: Mon, 19 Oct 2026 04:37:32 +0000	[thread overview]
Message-ID: <sashiko-outbox-176642@kernel.org> (raw)
In-Reply-To: <20261019-chid-v10-3-67de9180b4ed@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] gpu: nova-core: call to missing IdPool::reserve_ids() and release_ids()
--

commit 086e60d9f7e7ac9b6628a571ed585382eb5212a9
Author: Eliot Courtney <ecourtney@nvidia.com>

gpu: nova-core: add ChannelIdPool

This commit introduces ChannelIdPool on top of IdPool to automatically
track and release contiguous ranges of channel IDs for nova-core.

Link: https://lore.kernel.org/all/84bc8bd2-e292-4b84-9580-a1b5df4c5bdc@nvidia.com/ # [1]
Link: https://lore.kernel.org/all/20260710-chid-maple-v1-1-4ee869055268@nvidia.com/ # [2]
Link: https://lore.kernel.org/all/20260717053241.916441-1-ynorov@nvidia.com/ # [3]

> diff --git a/drivers/gpu/nova-core/gpu/channel.rs b/drivers/gpu/nova-core/gpu/channel.rs
> new file mode 100644
> index 0000000000000..485efaba059d9
> --- /dev/null
> +++ b/drivers/gpu/nova-core/gpu/channel.rs
> @@ -0,0 +1,198 @@
[ ... ]
> +impl ChannelIdPool {
> +    /// Creates a pool managing `num_chids` channel IDs.
> +    pub(crate) fn new(num_chids: NonZero<usize>) -> impl PinInit<Self, Error> {
> +        try_pin_init!(Self {
> +            inner <- new_mutex!(IdPool::with_capacity(num_chids.get(), GFP_KERNEL)?),
> +        })
> +    }
> +
> +    /// Reserves a contiguous area of `count` channel IDs starting at a multiple of `align`,
> +    /// returning a guard that releases the area on drop.
> +    pub(crate) fn reserve_ids(
> +        &self,
> +        count: NonZero<usize>,
> +        align: Alignment,
> +    ) -> Result<ChannelIdReservation<'_>> {
> +        let mut ids = self.inner.lock();
> +        let range = ids.reserve_ids(0, count, align).ok_or(ENOSPC)?;
> +        Ok(ChannelIdReservation { pool: self, range })
> +    }
> +}
> +
> +/// A reserved contiguous area of channel IDs.
> +///
> +/// Releases the whole area back to its [`ChannelIdPool`] when dropped. Releasing locks a
> +/// sleeping [`Mutex`], so the area must be dropped in a context that is allowed to sleep.
> +#[must_use = "the channel ID reservation is released immediately when unused"]
> +pub(crate) struct ChannelIdReservation<'a> {
> +    pool: &'a ChannelIdPool,
> +    range: Range<usize>,
> +}
> +
> +impl Drop for ChannelIdReservation<'_> {
> +    fn drop(&mut self) {
> +        self.pool.inner.lock().release_ids(&self.range);
> +    }
> +}

[Severity: Low]
Does this fail to build under CONFIG_NOVA_CORE due to a missing prerequisite
patch for IdPool?

In drivers/gpu/nova-core/gpu/channel.rs, ChannelIdPool::reserve_ids() calls
ids.reserve_ids(0, count, align), and <ChannelIdReservation as Drop>::drop()
calls release_ids(&self.range).

However, in rust/kernel/id_pool.rs, kernel::id_pool::IdPool only defines
single-ID operations:

    pub fn find_unused_id(&mut self, offset: usize) -> Option<usize> {
        self.map.next_zero_bit(offset).map(|id| {
            self.map.set_bit(id);
            id
        })
    }

    pub fn release_id(&mut self, id: usize) {
        self.map.clear_bit(id);
    }

Neither IdPool::reserve_ids() nor IdPool::release_ids() exists in the tree yet.

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261019-chid-v10-0-67de9180b4ed@nvidia.com?part=3

      reply	other threads:[~2026-10-19  4:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19  4:29 [PATCH v10 0/3] rust: Add support for reserving of ranges of IDs Eliot Courtney
2026-10-19  4:29 ` [PATCH v10 1/3] rust: use Alignment size constants Eliot Courtney
2026-10-19  4:41   ` sashiko-bot
2026-10-19  4:29 ` [PATCH v10 2/3] rust: id_pool: do not round capacity up to BitmapVec::MAX_INLINE_LEN Eliot Courtney
2026-10-19  4:37   ` sashiko-bot
2026-10-19  4:29 ` [PATCH v10 3/3] gpu: nova-core: add ChannelIdPool Eliot Courtney
2026-10-19  4:37   ` sashiko-bot [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=sashiko-outbox-176642@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=apopple@nvidia.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=burak.emir@gmail.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jhubbard@nvidia.com \
    --cc=lossin@kernel.org \
    --cc=nova-gpu@lists.linux.dev \
    --cc=ojeda@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=simona@ffwll.ch \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=ttabi@nvidia.com \
    --cc=work@onurozkan.dev \
    --cc=yury.norov@gmail.com \
    --cc=zhiw@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