Re: [PATCH v4 07/24] PCI/sysfs: Convert PCI resource files to static attributes

Krzysztof Wilczyński <[email protected]>
Newsgroups gmane.linux.ports.ppc.embedded,gmane.linux.kernel.pci,gmane.linux.ports.alpha
Message-ID <20260417114912.GD1625998@rocinante>
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;
[...]
> Did you accidently forget to address some of the comments as I thought you 
> were agreeing to changing this to resource_assigned() but I found no 
> resource_assigned() from entire series?

I have not.  Sorry for late reply here.

When testing resource_assigned() as replacement for pci_resource_len(),
none of the resource files would be made visible.

The resource_assigned() checks res->parent, but the static .is_bin_visible
callback runs at device_add() time, called from pci_device_add() during bus
enumeration, so before pci_assign_unassigned_bus_resources() runs and inserts
resources into the resource tree via pci_claim_resource(), etc.

The call sequence in pci_host_probe() is:

  pci_scan_root_bus_bridge()
    pci_scan_child_bus()
      pci_scan_slot()
        pci_scan_single_device()
          pci_scan_device()
            pci_setup_device()
              pci_read_bases()        <- res->start/end set from BARs
          pci_device_add()
            device_add()              <- is_bin_visible() runs here
                                         res->parent still NULL

  pci_assign_unassigned_root_bus_resources()
    pci_claim_resource()
      request_resource_conflict()
        __request_resource()          <- res->parent set here

At that point, the pci_resource_len() would return a non-zero value as
res->start and res->end would already be set, but the res->parent is
still NULL (not yet assigned to tree).

The old dynamic code ran from pci_sysfs_init() as a late_initcall (after
assignment), where resource_assigned() would have worked.

As such, we can't really use resource_assigned() together with static
sysfs attributes, at least not without solving the resources evaluation
order here.

Thank you!

	Krzysztof
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.