linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Chen <hzpeterchen@gmail.com>
To: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Peter Chen <peter.chen@freescale.com>,
	Rob Herring <robh@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	Sricharan R <sricharan@codeaurora.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>,
	linux-pm@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/7] USB: of: fix root-hub device-tree node handling
Date: Mon, 5 Jun 2017 12:51:04 +0800	[thread overview]
Message-ID: <20170605045103.GB20014@b29397-desktop> (raw)
In-Reply-To: <20170530162554.26159-6-johan@kernel.org>

On Tue, May 30, 2017 at 06:25:52PM +0200, Johan Hovold wrote:
> In an attempt to work around a pinmux over-allocation issue in driver
> core, commit dc5878abf49c ("usb: core: move root hub's device node
> assignment after it is added to bus") moved the device-tree node
> assignment until after the root hub had been registered.
> 
> This not only makes the device-tree node unavailable to the usb driver
> during probe, but also prevents the of_node from being linked to in
> sysfs and causes a race with user-space for the (recently added) devspec
> attribute.
> 
> Use the new device_set_of_node_from_dev() helper to reuse the node of
> the sysdev device, something which now prevents driver core from trying
> to reclaim any pinctrl pins during probe.
> 
> Fixes: dc5878abf49c ("usb: core: move root hub's device node assignment after it is added to bus")
> Fixes: 51fa91475e43 ("usb/core: Added devspec sysfs entry for devices behind the usb hub")
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/usb/core/hcd.c | 2 --
>  drivers/usb/core/usb.c | 4 ++--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 5dea98358c05..2cff59e9c268 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -1076,7 +1076,6 @@ static void usb_deregister_bus (struct usb_bus *bus)
>  static int register_root_hub(struct usb_hcd *hcd)
>  {
>  	struct device *parent_dev = hcd->self.controller;
> -	struct device *sysdev = hcd->self.sysdev;
>  	struct usb_device *usb_dev = hcd->self.root_hub;
>  	const int devnum = 1;
>  	int retval;
> @@ -1123,7 +1122,6 @@ static int register_root_hub(struct usb_hcd *hcd)
>  		/* Did the HC die before the root hub was registered? */
>  		if (HCD_DEAD(hcd))
>  			usb_hc_died (hcd);	/* This time clean up */
> -		usb_dev->dev.of_node = sysdev->of_node;
>  	}
>  	mutex_unlock(&usb_bus_idr_lock);
>  
> diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
> index 62e1906bb2f3..17681d5638ac 100644
> --- a/drivers/usb/core/usb.c
> +++ b/drivers/usb/core/usb.c
> @@ -416,8 +416,7 @@ static void usb_release_dev(struct device *dev)
>  
>  	usb_destroy_configuration(udev);
>  	usb_release_bos_descriptor(udev);
> -	if (udev->parent)
> -		of_node_put(dev->of_node);
> +	of_node_put(dev->of_node);
>  	usb_put_hcd(hcd);
>  	kfree(udev->product);
>  	kfree(udev->manufacturer);
> @@ -616,6 +615,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
>  		dev->route = 0;
>  
>  		dev->dev.parent = bus->controller;
> +		device_set_of_node_from_dev(&dev->dev, bus->sysdev);
>  		dev_set_name(&dev->dev, "usb%d", bus->busnum);
>  		root_hub = 1;
>  	} else {
> -- 
> 2.13.0

I am OK with it, but I suggest adding it for new rc1 since it is based
on the 1st patch which is a bug-fix. If this one is really needed for
stable tree in future, you can cherry-pick it.

-- 

Best Regards,
Peter Chen

  reply	other threads:[~2017-06-05  4:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-30 16:25 [PATCH 0/7] driver core/USB/thermal: fix device-tree node reuse Johan Hovold
2017-05-30 16:25 ` [PATCH 1/7] USB: core: fix device node leak Johan Hovold
2017-05-30 22:55   ` Tyrel Datwyler
     [not found]     ` <9aff0d42-ff3e-963a-7aaa-752c2f592d0d-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2017-05-31  8:25       ` Johan Hovold
     [not found]   ` <20170530162554.26159-2-johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-06-05  3:35     ` Peter Chen
2017-05-30 16:25 ` [PATCH 2/7] USB: of: document reference taken by child-lookup helper Johan Hovold
2017-05-30 22:40   ` Tyrel Datwyler
2017-06-06 15:38     ` Johan Hovold
2017-05-30 16:25 ` [PATCH 3/7] driver core: add helper to reuse a device-tree node Johan Hovold
2017-05-30 22:52   ` kbuild test robot
     [not found]     ` <201705310637.M1OKh99R%fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-05-31  8:38       ` Johan Hovold
2017-05-30 16:25 ` [PATCH 4/7] driver core: fix automatic pinctrl management Johan Hovold
     [not found]   ` <20170530162554.26159-5-johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-05-31  0:39     ` Linus Walleij
     [not found]       ` <CACRpkda2PFrua01uKy3b2Zvqi3SH1i0tsxOfWhNP8bB7RCo45g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-31  8:35         ` Johan Hovold
2017-05-30 16:25 ` [PATCH 5/7] USB: of: fix root-hub device-tree node handling Johan Hovold
2017-06-05  4:51   ` Peter Chen [this message]
2017-06-06 15:44     ` Johan Hovold
2017-05-30 16:25 ` [PATCH 6/7] thermal: max77620: fix device-node reference imbalance Johan Hovold
2017-05-30 22:59   ` Tyrel Datwyler
2017-05-31  8:28     ` Johan Hovold
2017-05-30 16:25 ` [PATCH 7/7] thermal: max77620: fix pinmux conflict on reprobe Johan Hovold
2017-05-30 18:57   ` Eduardo Valentin
2017-05-31  8:23     ` Johan Hovold

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=20170605045103.GB20014@b29397-desktop \
    --to=hzpeterchen@gmail.com \
    --cc=arnd@arndb.de \
    --cc=edubezval@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.chen@freescale.com \
    --cc=robh@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=sricharan@codeaurora.org \
    /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).