From: Vidya Sagar <vidyas@nvidia.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
Dan Williams <djbw@kernel.org>,
"Dave Jiang" <dave.jiang@intel.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Joerg Roedel <joerg.roedel@amd.com>,
Jason Gunthorpe <jgg@ziepe.ca>,
"Nicolin Chen" <nicolinc@nvidia.com>,
Kevin Tian <kevin.tian@intel.com>
Cc: <vsethi@nvidia.com>, <kthota@nvidia.com>,
<mmaddireddy@nvidia.com>, <kumarahul@nvidia.com>,
<sagar.tv@gmail.com>, <linux-pci@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, Vidya Sagar <vidyas@nvidia.com>
Subject: [PATCH V1 3/4] PCI/sysfs: Take the device lock when setting reset methods
Date: Thu, 19 Nov 2026 15:36:27 +0530 [thread overview]
Message-ID: <20261119100628.1948990-4-vidyas@nvidia.com> (raw)
In-Reply-To: <20261119100628.1948990-1-vidyas@nvidia.com>
reset_method_store() updates dev->reset_methods without holding any
lock. A reset can run at the same time: __pci_reset_function_locked()
walks the list one entry at a time while the write copies the new list
over it, so the reset may use a mix of the old and the new list.
Take the device lock in reset_method_store(), as
__pci_reset_function_locked() already requires. This also serializes
concurrent writes. The reset methods already run under this lock during
a reset, and probing a method does less than running it, so probing them
with the lock held is safe. A write now waits while a reset of the
device is in progress.
Signed-off-by: Vidya Sagar <vidyas@nvidia.com>
---
drivers/pci/pci-sysfs.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 6669e9ad5bd3..dff3c2d9408c 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1643,6 +1643,9 @@ static ssize_t reset_method_store(struct device *dev,
int m, n;
u8 reset_methods[PCI_NUM_RESET_METHODS] = {};
+ /* Serialize against resets and other updates of the list */
+ guard(device)(dev);
+
if (sysfs_streq(buf, "")) {
pdev->reset_methods[0] = 0;
pci_warn(pdev, "All device reset methods disabled by user");
--
2.43.0
next prev parent reply other threads:[~2026-11-19 10:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 10:06 [PATCH V1 0/4] PCI: Don't list reset methods that can't reset the device Vidya Sagar
2026-11-19 10:06 ` [PATCH V1 1/4] PCI/CXL: Don't offer 'cxl_bus' reset where a bus reset can't work Vidya Sagar
2026-11-19 10:06 ` [PATCH V1 2/4] PCI: Don't run IOMMU reset hooks when only probing reset methods Vidya Sagar
2026-11-19 10:06 ` Vidya Sagar [this message]
2026-11-19 10:06 ` [PATCH V1 4/4] PCI: Re-check function 0 reset methods after scanning its slot Vidya Sagar
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=20261119100628.1948990-4-vidyas@nvidia.com \
--to=vidyas@nvidia.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=bhelgaas@google.com \
--cc=dave.jiang@intel.com \
--cc=djbw@kernel.org \
--cc=jgg@ziepe.ca \
--cc=joerg.roedel@amd.com \
--cc=kevin.tian@intel.com \
--cc=kthota@nvidia.com \
--cc=kumarahul@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mmaddireddy@nvidia.com \
--cc=nicolinc@nvidia.com \
--cc=sagar.tv@gmail.com \
--cc=vsethi@nvidia.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
all inboxes | Powered by JetHome®