Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, Shuan He <heshuan@bytedance.com>,
	kwilczynski@kernel.org
Subject: Re: [PATCH] PCI: Remove redudant calls to pci_create_sysfs_dev_files() and pci_proc_attach_device()
Date: Wed, 23 Jul 2025 14:55:28 +0200	[thread overview]
Message-ID: <aIDbwNdWgtKcrfF_@wunner.de> (raw)
In-Reply-To: <20250723111124.13694-1-manivannan.sadhasivam@oss.qualcomm.com>

On Wed, Jul 23, 2025 at 04:41:24PM +0530, Manivannan Sadhasivam wrote:
> Both pci_create_sysfs_dev_files() and pci_proc_attach_device() are called
> from pci_bus_add_device(). Calling these APIs from other places is prone to
> a race condition as nothing prevents the callers from racing against
> each other.
> 
> Moreover, the proper place to create SYSFS and PROCFS entries is during
> the 'pci_dev' creation. So there is no real need to call these APIs
> elsewhere.

The raison d'être for the call to pci_create_sysfs_dev_files() in
pci_sysfs_init() is that PCI_ROM_RESOURCEs may appear after device
enumeration but before the late_initcall stage:

https://lore.kernel.org/r/20231019200110.GA1410324@bhelgaas/

Your patch will regress those platforms.

The proper solution is to make the resource files in sysfs static
and call sysfs_update_group() from pci_sysfs_init().

Krzysztof has an old branch where he started working on this:

https://github.com/kwilczynski/linux/commits/kwilczynski/sysfs-static-resource-attributes/

Thanks,

Lukas

  reply	other threads:[~2025-07-23 12:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-23 11:11 [PATCH] PCI: Remove redudant calls to pci_create_sysfs_dev_files() and pci_proc_attach_device() Manivannan Sadhasivam
2025-07-23 12:55 ` Lukas Wunner [this message]
2025-07-23 13:40   ` Manivannan Sadhasivam
     [not found]     ` <CAKmKDK=dOZp1a_syV1fjdo2gjEJX=C21A_mDsMqZVZrKLjf46A@mail.gmail.com>
2025-08-07 14:14       ` [External] " Krzysztof Wilczyński
     [not found]         ` <CAKmKDKmCfUgj+ZAjH-pKeaDu2xz6j1tbD7kHMUWbCRFxYAPenA@mail.gmail.com>
2025-08-07 15:14           ` Krzysztof Wilczyński

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=aIDbwNdWgtKcrfF_@wunner.de \
    --to=lukas@wunner.de \
    --cc=bhelgaas@google.com \
    --cc=heshuan@bytedance.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=manivannan.sadhasivam@oss.qualcomm.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