From: Zhenguo Yao <yaozhenguo1@gmail.com>
To: bhelgaas@google.com, alex.williamson@redhat.com
Cc: cohuck@redhat.com, jgg@ziepe.ca, mgurtovoy@nvidia.com,
yishaih@nvidia.com, kvm@vger.kernel.org,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
yaozhenguo@jd.com, Zhenguo Yao <yaozhenguo1@gmail.com>
Subject: [PATCH v1 1/2] PCI: Add ignore_reset sysfs interface to control whether to do device reset in PCI drivers
Date: Thu, 14 Oct 2021 17:57:47 +0800 [thread overview]
Message-ID: <20211014095748.84604-2-yaozhenguo1@gmail.com> (raw)
In-Reply-To: <20211014095748.84604-1-yaozhenguo1@gmail.com>
Some PCI devices can't do device reset in enable and disable operations.
So, and ignore_reset sysfs interface to ignore reset in those operations.
For example:
echo 1 > /sys/bus/pci/xxxx/ignore_reset
PCI drivers can ignore reset for this device based on ignore_reset.
Signed-off-by: Zhenguo Yao <yaozhenguo1@gmail.com>
---
drivers/pci/pci-sysfs.c | 25 +++++++++++++++++++++++++
include/linux/pci.h | 1 +
2 files changed, 26 insertions(+)
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 7fb5cd17cc98..c2fa2ed3ae55 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -255,6 +255,30 @@ static ssize_t ari_enabled_show(struct device *dev,
}
static DEVICE_ATTR_RO(ari_enabled);
+static ssize_t ignore_reset_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct pci_dev *pci_dev = to_pci_dev(dev);
+
+ return sprintf(buf, "%u\n", pci_dev->ignore_reset);
+}
+static ssize_t ignore_reset_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+ unsigned long val;
+
+ if (kstrtoul(buf, 0, &val) < 0)
+ return -EINVAL;
+
+ pdev->ignore_reset = !!val;
+
+ return count;
+}
+static DEVICE_ATTR_RW(ignore_reset);
+
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
@@ -618,6 +642,7 @@ static struct attribute *pci_dev_attrs[] = {
#endif
&dev_attr_driver_override.attr,
&dev_attr_ari_enabled.attr,
+ &dev_attr_ignore_reset.attr,
NULL,
};
diff --git a/include/linux/pci.h b/include/linux/pci.h
index cd8aa6fce204..ac026acd4572 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -508,6 +508,7 @@ struct pci_dev {
/* These methods index pci_reset_fn_methods[] */
u8 reset_methods[PCI_NUM_RESET_METHODS]; /* In priority order */
+ u8 ignore_reset; /* ignore reset control in driver */
};
static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
--
2.27.0
next prev parent reply other threads:[~2021-10-14 9:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-14 9:57 [PATCH v1 0/2] Add ablility of VFIO driver to ignore reset when device don't need it Zhenguo Yao
2021-10-14 9:57 ` Zhenguo Yao [this message]
2021-10-14 9:57 ` [PATCH v1 2/2] vfio-pci: Don't do device reset when ignore_reset is setting Zhenguo Yao
2021-10-14 12:48 ` [PATCH v1 0/2] Add ablility of VFIO driver to ignore reset when device don't need it Alex Williamson
2021-10-14 13:37 ` Zhenguo Yao
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=20211014095748.84604-2-yaozhenguo1@gmail.com \
--to=yaozhenguo1@gmail.com \
--cc=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=cohuck@redhat.com \
--cc=jgg@ziepe.ca \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mgurtovoy@nvidia.com \
--cc=yaozhenguo@jd.com \
--cc=yishaih@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®