Re: [PATCH 06/20] PCI/sysfs: Convert PCI resource files to static attributes

Krzysztof Wilczyński
2026-04-10T11:13:45Z

Hello,

> > - /* Expose the PCI resources from this device as files */
> > - for (i = 0; i < PCI_STD_NUM_BARS; i++) {
> > + if (!pci_resource_len(pdev, bar))
> > + return 0;
>
> I know it's same as in the previous code but I dislike assuming len != 0
> implies resource has been assigned. While it currently holds, I'd want to
> change that eventually.
>
> The current behavior causes issue e.g. if IOV resource fails to assign, it
> is reset (making its len 0 among other thing) and since IOV resource are
> optional that is fine from kernel's perspective. But resetting the
> resource means we also lose access to that resource because its type gets
> cleared so from kernel perspective the VF BAR stops to exist. Losing it
> means the user cannot solve the issue by e.g. resizing some other BAR
> smaller to make space to allow the VF BARs to assign successfully.
>
> So I think this code would actually want to check resource_assigned()
> which implies also non-zero size.

Makes sense.

I will update the code to use resource_assigned(). Since we are working on
this code anyway, it would be only prudent to also do the right thing.

> AFAICT, this change looks fine (despite the diff being very messy).

Thank you!

Krzysztof