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 <[email protected]>

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/[email protected]/ # 
[1]
Link: 
https://lore.kernel.org/all/[email protected]/ # 
[2]
Link: https://lore.kernel.org/all/[email protected]/ # 
[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/[email protected]?part=3

Reply via email to