From: Abhijit Gangurde <abhijit.gangurde@amd.com>
To: <gregkh@linuxfoundation.org>, <masahiroy@kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: <puneet.gupta@amd.com>, <Nipun.Gupta@amd.com>,
<nikhil.agarwal@amd.com>, <michal.simek@amd.com>, <git@amd.com>,
Abhijit Gangurde <abhijit.gangurde@amd.com>
Subject: [PATCH v7 6/7] cdx: add sysfs for bus reset
Date: Tue, 17 Oct 2023 21:35:04 +0530 [thread overview]
Message-ID: <20231017160505.10640-7-abhijit.gangurde@amd.com> (raw)
In-Reply-To: <20231017160505.10640-1-abhijit.gangurde@amd.com>
Add sysfs interface reset to reset all the devices on the CDX bus.
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
---
Changes in v7:
- None
Changes in v6:
- Remove reset bus attribute
- Use reset attribute of cdx device for bus reset.
Changes in v5:
- None
Changes in v4:
- None
Changes in v3:
- None
Changes in v2:
- Improve documentation
- sysfs entry reset takes bus number as an argument
Documentation/ABI/testing/sysfs-bus-cdx | 8 ++++----
drivers/cdx/cdx.c | 26 +++++++++++++++++++++----
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-bus-cdx b/Documentation/ABI/testing/sysfs-bus-cdx
index c12bdaa4152a..c2c54abffed5 100644
--- a/Documentation/ABI/testing/sysfs-bus-cdx
+++ b/Documentation/ABI/testing/sysfs-bus-cdx
@@ -45,10 +45,10 @@ What: /sys/bus/cdx/devices/.../reset
Date: March 2023
Contact: nipun.gupta@amd.com
Description:
- Writing y/1/on to this file resets the CDX device.
- On resetting the device, the corresponding driver is notified
- twice, once before the device is being reset, and again after
- the reset has been complete.
+ Writing y/1/on to this file resets the CDX device or all devices
+ on the bus. On resetting the device, the corresponding driver is
+ notified twice, once before the device is being reset, and again
+ after the reset has been complete.
For example::
diff --git a/drivers/cdx/cdx.c b/drivers/cdx/cdx.c
index 8eb484c37e97..e22a7138292e 100644
--- a/drivers/cdx/cdx.c
+++ b/drivers/cdx/cdx.c
@@ -110,6 +110,20 @@ int cdx_dev_reset(struct device *dev)
}
EXPORT_SYMBOL_GPL(cdx_dev_reset);
+/**
+ * reset_cdx_device - Reset a CDX device
+ * @dev: CDX device
+ * @data: This is always passed as NULL, and is not used in this API,
+ * but is required here as the device_for_each_child() API expects
+ * the passed function to have this as an argument.
+ *
+ * Return: -errno on failure, 0 on success.
+ */
+static int reset_cdx_device(struct device *dev, void *data)
+{
+ return cdx_dev_reset(dev);
+}
+
/**
* cdx_unregister_device - Unregister a CDX device
* @dev: CDX device
@@ -343,6 +357,7 @@ static DEVICE_ATTR_WO(remove);
static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct cdx_device *cdx_dev = to_cdx_device(dev);
bool val;
int ret;
@@ -352,11 +367,13 @@ static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
if (!val)
return -EINVAL;
- ret = cdx_dev_reset(dev);
- if (ret)
- return ret;
+ if (cdx_dev->is_bus)
+ /* Reset all the devices attached to cdx bus */
+ ret = device_for_each_child(dev, NULL, reset_cdx_device);
+ else
+ ret = cdx_dev_reset(dev);
- return count;
+ return ret < 0 ? ret : count;
}
static DEVICE_ATTR_WO(reset);
@@ -461,6 +478,7 @@ static const struct attribute_group cdx_dev_group = {
static struct attribute *cdx_bus_dev_attrs[] = {
&dev_attr_enable.attr,
+ &dev_attr_reset.attr,
NULL,
};
--
2.34.1
next prev parent reply other threads:[~2023-10-17 16:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 16:04 [PATCH v7 0/7] cdx: provide sysfs interface for cdx device resources Abhijit Gangurde
2023-10-17 16:04 ` [PATCH v7 1/7] cdx: Remove cdx controller list from cdx bus system Abhijit Gangurde
2023-10-17 16:05 ` [PATCH v7 2/7] cdx: Introduce lock to protect controller ops Abhijit Gangurde
2023-10-17 16:05 ` [PATCH v7 3/7] cdx: Create symbol namespaces for cdx subsystem Abhijit Gangurde
2023-10-17 16:05 ` [PATCH v7 4/7] cdx: Register cdx bus as a device on " Abhijit Gangurde
2023-10-17 16:05 ` [PATCH v7 5/7] cdx: add support for bus enable and disable Abhijit Gangurde
2023-10-17 16:05 ` Abhijit Gangurde [this message]
2023-10-17 16:05 ` [PATCH v7 7/7] cdx: add sysfs for subsystem, class and revision Abhijit Gangurde
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=20231017160505.10640-7-abhijit.gangurde@amd.com \
--to=abhijit.gangurde@amd.com \
--cc=Nipun.Gupta@amd.com \
--cc=git@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=michal.simek@amd.com \
--cc=nikhil.agarwal@amd.com \
--cc=puneet.gupta@amd.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®