All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 14/16] PCI: Add iterators for devices and resources in bus windows
Date: Sat, 05 Dec 2026 01:02:31 +0000	[thread overview]
Message-ID: <sashiko-outbox-250875@kernel.org> (raw)
In-Reply-To: <20261205003957.3304-15-ilpo.jarvinen@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] PCI: break inside pci_bus_for_each_window_resource() only exits
  inner loop
--

commit 73da7b0150edfd796b5aa15f8d77912a014f57a3
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

PCI: Add iterators for devices and resources in bus windows

This commit adds pci_bus_for_each_window_dev() and
pci_bus_for_each_window_resource() to iterate over devices on a bus (and
below its transparent bridges) and their resources that reside directly in
a given bus window.

> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 77efa4c5c960e..9d0cbe6c89917 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h

[ ... ]

> @@ -546,6 +547,27 @@ bool pci_bus_clip_resource(struct pci_dev *dev, int idx);
>  void pci_walk_bus_locked(struct pci_bus *top,
>  			 int (*cb)(struct pci_dev *, void *),
>  			 void *userdata);
> +struct pci_dev *pci_bus_next_window_dev(struct pci_bus *bus,
> +					struct pci_dev *dev);
> +
> +/*
> + * Iterate over the devices whose resources may reside directly in the
> + * windows of @bus: the devices on @bus and, recursively, the devices
> + * below its transparent bridges. A transparent bridge also forwards
> + * accesses outside of its own windows.
> + */
> +#define pci_bus_for_each_window_dev(bus, dev)				\
> +	for (dev = pci_bus_next_window_dev(bus, NULL); dev;		\
> +	     dev = pci_bus_next_window_dev(bus, dev))
> +
> +/*
> + * Iterate over the resources of the devices of
> + * pci_bus_for_each_window_dev() that reside directly in window @win.
> + */
> +#define pci_bus_for_each_window_resource(bus, win, dev, res)		\
> +	pci_bus_for_each_window_dev(bus, dev)				\
> +		pci_dev_for_each_resource(dev, res)			\
> +			for_each_if((res)->parent == (win))

[Severity: Low]
Will a break statement inside pci_bus_for_each_window_resource() only exit
the inner pci_dev_for_each_resource() loop?

Because this macro nests two separate for loops, break only stops scanning
the current device's resources while the outer
pci_bus_for_each_window_dev() loop silently continues to the remaining
devices, executing the loop body again and overwriting dev and res.

Backing the iterator with a single-loop helper that finds the next matching
resource, or documenting that break is unsupported, would avoid this trap.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205003957.3304-1-ilpo.jarvinen@linux.intel.com?part=14

  reply	other threads:[~2026-12-05  1:02 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  0:39 [PATCH v2 00/16] PCI: Resource release fixes and improvements Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 01/16] PCI: Release all resources before restoring them in BAR resize rollback Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 02/16] PCI: Set new BAR Size only after releasing the BARs for BAR resize Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 03/16] PCI: Abort BAR resize only if saving the resized BAR fails Ilpo Järvinen
2026-12-05  1:04   ` sashiko-bot
2026-12-05  1:25     ` Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 04/16] PCI: Consistently use Header Type to detect bridge headers Ilpo Järvinen
2026-12-05  1:04   ` sashiko-bot
2026-12-05  0:39 ` [PATCH v2 05/16] resource: Check that the resource is in the tree when releasing it Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 06/16] resource, kunit: Add test for releasing a resource not in the tree Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 07/16] resource: Add release_leaf_resource() Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 08/16] resource, kunit: Add test for release_leaf_resource() Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 09/16] PCI: Do not release resources with children in pci_release_resource() Ilpo Järvinen
2026-12-05  1:04   ` sashiko-bot
2026-12-05  1:29     ` Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 10/16] resource: Rename next_resource() and for_each_resource() Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 11/16] resource: Make resource_lock and resource tree traversal available Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 12/16] resource: Add release_resource_locked() Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 13/16] PCI: Split pci_resource_post_release() out of pci_release_resource() Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 14/16] PCI: Add iterators for devices and resources in bus windows Ilpo Järvinen
2026-12-05  1:02   ` sashiko-bot [this message]
2026-12-05  1:12     ` Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 15/16] PCI: Keep the range of fixed resources when releasing them Ilpo Järvinen
2026-12-05  0:39 ` [PATCH v2 16/16] PCI: Release only PCI resources when releasing a resource tree Ilpo Järvinen
2026-12-05  1:11   ` sashiko-bot
2026-12-05  1:57     ` Ilpo Järvinen
2026-12-05  0:50 ` ✗ CI.checkpatch: warning for PCI: Resource release fixes and improvements (rev2) Patchwork
2026-12-05  0:52 ` ✓ CI.KUnit: success " Patchwork
2026-12-05  1:27 ` ✓ Xe.CI.BAT: " Patchwork
2026-12-05  2:06 ` ✓ i915.CI.BAT: " Patchwork
2026-12-05 16:24 ` ✗ i915.CI.Full: failure " Patchwork

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-250875@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.