public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Abhijit Gangurde <abhijit.gangurde@amd.com>
Cc: linux-kernel@vger.kernel.org, Nipun.Gupta@amd.com,
	nikhil.agarwal@amd.com, puneet.gupta@amd.com, git@amd.com,
	michal.simek@amd.com,
	Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@amd.com>
Subject: Re: [PATCH 2/4] cdx: add sysfs for reset_all
Date: Tue, 11 Jul 2023 15:59:33 +0200	[thread overview]
Message-ID: <2023071111-unreached-probation-45c5@gregkh> (raw)
In-Reply-To: <20230711121027.936487-3-abhijit.gangurde@amd.com>

On Tue, Jul 11, 2023 at 05:40:25PM +0530, Abhijit Gangurde wrote:
> Add sysfs for reset_all entry which resets all the
> devices on the CDX bus.

On all CDX busses, right?  Why all?  Why not per-bus?


> 
> Co-developed-by: Puneet Gupta <puneet.gupta@amd.com>
> Signed-off-by: Puneet Gupta <puneet.gupta@amd.com>
> Co-developed-by: Nipun Gupta <nipun.gupta@amd.com>
> Signed-off-by: Nipun Gupta <nipun.gupta@amd.com>
> Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
> Reviewed-by: Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@amd.com>
> Tested-by: Nikhil Agarwal <nikhil.agarwal@amd.com>
> ---
>  Documentation/ABI/testing/sysfs-bus-cdx | 11 ++++++++++
>  drivers/cdx/cdx.c                       | 29 +++++++++++++++++++++++++
>  2 files changed, 40 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-bus-cdx b/Documentation/ABI/testing/sysfs-bus-cdx
> index 0afa85b3c63b..d9e00058471d 100644
> --- a/Documentation/ABI/testing/sysfs-bus-cdx
> +++ b/Documentation/ABI/testing/sysfs-bus-cdx
> @@ -22,6 +22,17 @@ Description:
>  
>  		  # echo 0 > /sys/bus/cdx/enable
>  
> +What:		/sys/bus/cdx/reset_all
> +Date:		July 2023
> +Contact:	puneet.gupta@amd.com
> +Description:
> +		Writing y/1/on to this file resets all the devices
> +		present on the CDX bus
> +
> +		For example::
> +
> +		  # echo 1 > /sys/bus/cdx/reset_all

What does resetting a device mean will happen?

> +
>  What:		/sys/bus/cdx/devices/.../vendor
>  Date:		March 2023
>  Contact:	nipun.gupta@amd.com
> diff --git a/drivers/cdx/cdx.c b/drivers/cdx/cdx.c
> index 48c493a43491..4d20047b55bb 100644
> --- a/drivers/cdx/cdx.c
> +++ b/drivers/cdx/cdx.c
> @@ -106,6 +106,11 @@ int cdx_dev_reset(struct device *dev)
>  }
>  EXPORT_SYMBOL_GPL(cdx_dev_reset);
>  
> +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
> @@ -433,9 +438,33 @@ static ssize_t rescan_store(const struct bus_type *bus,
>  }
>  static BUS_ATTR_WO(rescan);
>  
> +static ssize_t reset_all_store(const struct bus_type *bus,
> +			       const char *buf, size_t count)
> +{
> +	bool val;
> +	int ret;
> +
> +	if (kstrtobool(buf, &val) < 0)
> +		return -EINVAL;
> +
> +	if (!val)
> +		return -EINVAL;
> +
> +	/* Reset all the devices attached to cdx bus */
> +	ret = bus_for_each_dev(bus, NULL, NULL, reset_cdx_device);

No locking needed?


> +	if (ret) {
> +		pr_err("error in CDX bus reset\n");

What error?  For what device?  Put the error message in the reset
callback, not here, as you have no idea what device failed.

thanks,

greg k-h

  reply	other threads:[~2023-07-11 13:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11 12:10 [PATCH 0/4] cdx: provide sysfs interface for cdx device resources Abhijit Gangurde
2023-07-11 12:10 ` [PATCH 1/4] cdx: add support for bus enable and disable Abhijit Gangurde
2023-07-11 13:57   ` Greg KH
2023-07-12 13:21     ` Gangurde, Abhijit
2023-07-12 15:09       ` Greg KH
2023-07-11 12:10 ` [PATCH 2/4] cdx: add sysfs for reset_all Abhijit Gangurde
2023-07-11 13:59   ` Greg KH [this message]
2023-07-12 13:22     ` Gangurde, Abhijit
2023-07-11 12:10 ` [PATCH 3/4] cdx: create sysfs resource files Abhijit Gangurde
2023-07-11 14:00   ` Greg KH
2023-07-12 13:23     ` Gangurde, Abhijit
2023-07-12 15:11       ` Greg KH
2023-07-13  5:36         ` Gangurde, Abhijit
2023-07-13  5:57           ` Greg KH
2023-07-11 12:10 ` [PATCH 4/4] cdx: add sysfs for subsystem, class and revision Abhijit Gangurde
2023-07-11 14:02   ` Greg KH
2023-07-12 13:23     ` Gangurde, Abhijit

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=2023071111-unreached-probation-45c5@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=Nipun.Gupta@amd.com \
    --cc=abhijit.gangurde@amd.com \
    --cc=git@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=nikhil.agarwal@amd.com \
    --cc=pieter.jansen-van-vuuren@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