From: Greg KH <greg@kroah.com>
To: Prabhat Chand Pandey <prabhat.chand.pandey@intel.com>
Cc: linux-usb@vger.kernel.org, mathias.nyman@intel.com,
rajaram.regupathy@intel.com, abhilash.k.v@intel.com,
m.balaji@intel.com
Subject: Re: [PATCH 3/5] usb: xhci: dbc: Provide sysfs option to configure dbc descriptors
Date: Fri, 7 Jun 2019 16:10:29 +0200 [thread overview]
Message-ID: <20190607141029.GF14665@kroah.com> (raw)
In-Reply-To: <20190607063306.5612-4-prabhat.chand.pandey@intel.com>
On Fri, Jun 07, 2019 at 12:03:04PM +0530, Prabhat Chand Pandey wrote:
> From: "K V, Abhilash" <abhilash.k.v@intel.com>
>
> Show the active dbc function and dbc descriptors, allowing
> user space to dynamically modify the descriptors
>
> The DBC specific sysfs attributes are separated into two groups,
> in the first group there are dbc & dbc_function sysfs attributes and in
> second group all other DBC descriptor specific sysfs attributes.
>
> First group of attributes will be populated at the time of dbc_init and
> second group of attributes will only be populated when "dbc" attribute
> value is set to "enable".
>
> Whenever "dbc" attribute value will be "disable" then second group
> of attributes will be removed.
>
> Signed-off-by: Rajaram Regupathy <rajaram.regupathy@intel.com>
> Signed-off-by: Gururaj K <gururaj.k@intel.com>
> Signed-off-by: K V, Abhilash <abhilash.k.v@intel.com>
> Signed-off-by: Prabhat Chand Pandey <prabhat.chand.pandey@intel.com>
> Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com>
> ---
> .../testing/sysfs-bus-pci-drivers-xhci_hcd | 112 ++++++
> drivers/usb/host/xhci-dbgcap.c | 339 ++++++++++++++++++
> 2 files changed, 451 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd b/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd
> index 0088aba4caa8..b46b6afc6c4a 100644
> --- a/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd
> +++ b/Documentation/ABI/testing/sysfs-bus-pci-drivers-xhci_hcd
> @@ -23,3 +23,115 @@ Description:
> Reading this attribute gives the state of the DbC. It
> can be one of the following states: disabled, enabled,
> initialized, connected, configured and stalled.
> +
> +What: /sys/bus/pci/drivers/xhci_hcd/.../dbc_function
You are putting xhci-specific files in a pci device directory. why not
put it in your host controller device instead? That's the best place
for this, and what about xhci drivers that are NOT pci?
Don't abuse the pci device for things that are not pci.
> +static struct attribute *dbc_descriptor_attributes[] = {
> + &dev_attr_dbc_manufacturer.attr,
> + &dev_attr_dbc_product.attr,
> + &dev_attr_dbc_serial.attr,
> + &dev_attr_dbc_protocol.attr,
> + &dev_attr_dbc_vid.attr,
> + &dev_attr_dbc_pid.attr,
> + &dev_attr_dbc_device_rev.attr,
> + NULL
> +};
> +
> +static const struct attribute_group dbc_descriptor_attrib_grp = {
> + .attrs = dbc_descriptor_attributes,
> +};
ATTRIBUTE_GROUPS()?
> +
> static ssize_t dbc_store(struct device *dev,
> struct device_attribute *attr,
> const char *buf, size_t count)
> @@ -938,6 +1270,10 @@ static ssize_t dbc_store(struct device *dev,
> goto err;
> }
> xhci_dbc_start(xhci);
> + ret = sysfs_create_group(&dev->kobj,
> + &dbc_descriptor_attrib_grp);
If you EVER have to make a sysfs call within a driver, that is a HUGE
red flag that you are doing something wrong.
You are doing something wrong here, you just raced with userspace and
created a bunch of new files that userspace will not see.
Please do this correctly by setting the default device group for the
driver.
> + if (ret)
> + goto err;
> } else if (!strncmp(buf, "disable", 7) && dbc->state != DS_DISABLED) {
> if (!dbc_registered_func)
> return -EINVAL;
> @@ -945,6 +1281,7 @@ static ssize_t dbc_store(struct device *dev,
> if (dbc_registered_func->stop)
> dbc_registered_func->stop(dbc);
> module_put(dbc_registered_func->owner);
> + sysfs_remove_group(&dev->kobj, &dbc_descriptor_attrib_grp);
Same here.
And does this really remove the files for when the PCI device is removed
from the system? Or the driver from the device? It doesn't seem like
it, but I might be missing a codepath here...
thanks,
greg k-h
next prev parent reply other threads:[~2019-06-07 14:10 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-07 6:33 [PATCH 0/5] usb: xhci: dbc: make modular and add RAW interface Prabhat Chand Pandey
2019-06-07 6:33 ` [PATCH 1/5] usb: xhci: dbc: make DbC modular, introducing dbc_function structure Prabhat Chand Pandey
2019-06-07 14:02 ` Greg KH
2019-06-07 6:33 ` [PATCH 2/5] usb: xhci: dbc: DbC TTY driver to use new interface Prabhat Chand Pandey
2019-06-07 14:06 ` Greg KH
2019-06-07 6:33 ` [PATCH 3/5] usb: xhci: dbc: Provide sysfs option to configure dbc descriptors Prabhat Chand Pandey
2019-06-07 14:10 ` Greg KH [this message]
2019-06-07 6:33 ` [PATCH 4/5] usb: xhci: dbc: Add a dbc raw driver to provide a raw interface on DbC Prabhat Chand Pandey
2019-06-07 14:21 ` Greg KH
2019-06-10 13:53 ` Mathias Nyman
2019-06-10 14:16 ` Greg KH
2019-06-11 9:29 ` Regupathy, Rajaram
2019-06-11 9:52 ` Greg KH
2019-06-11 12:17 ` Regupathy, Rajaram
2019-06-11 12:34 ` Greg KH
2019-06-12 8:49 ` Regupathy, Rajaram
2019-06-12 10:54 ` Greg KH
2019-06-13 12:33 ` Felipe Balbi
2019-06-13 13:02 ` Greg KH
2019-06-07 6:33 ` [PATCH 5/5] usb: xhci: dbc: Document describe about dbc raw interface Prabhat Chand Pandey
2019-06-07 14:25 ` Greg KH
2019-06-07 13:59 ` [PATCH 0/5] usb: xhci: dbc: make modular and add RAW interface Greg KH
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=20190607141029.GF14665@kroah.com \
--to=greg@kroah.com \
--cc=abhilash.k.v@intel.com \
--cc=linux-usb@vger.kernel.org \
--cc=m.balaji@intel.com \
--cc=mathias.nyman@intel.com \
--cc=prabhat.chand.pandey@intel.com \
--cc=rajaram.regupathy@intel.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;
as well as URLs for NNTP newsgroup(s).