Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1193234 > unrolled thread

[PATCH v6 3/8] Driver core: wakeup the parent device before trying probe

Started byAndy Shevchenko <andriy.shevchenko@linux.intel.com>
First post2015-07-27 17:10 +0200
Last post2015-07-28 09:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v6 3/8] Driver core: wakeup the parent device before trying probe Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2015-07-27 17:10 +0200
    Re: [PATCH v6 3/8] Driver core: wakeup the parent device before  trying probe Lee Jones <lee.jones@linaro.org> - 2015-07-28 09:50 +0200

#1193234 — [PATCH v6 3/8] Driver core: wakeup the parent device before trying probe

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2015-07-27 17:10 +0200
Subject[PATCH v6 3/8] Driver core: wakeup the parent device before trying probe
Message-ID<pQScr-5tI-47@gated-at.bofh.it>
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

If the parent is still suspended when driver probe is
attempted, the result may be failure.

For example, if the parent is a PCI MFD device that has been
suspended when we try to probe our device, any register
reads will return 0xffffffff.

To fix the problem, making sure the parent is always awake
before attempting driver probe.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/dd.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index a638bbb..2d6df1d 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -399,6 +399,8 @@ EXPORT_SYMBOL_GPL(wait_for_device_probe);
  *
  * This function must be called with @dev lock held.  When called for a
  * USB interface, @dev->parent lock must be held as well.
+ *
+ * If the device has a parent, runtime-resume the parent before driver probing.
  */
 int driver_probe_device(struct device_driver *drv, struct device *dev)
 {
@@ -410,10 +412,16 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
 	pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
 		 drv->bus->name, __func__, dev_name(dev), drv->name);
 
+	if (dev->parent)
+		pm_runtime_get_sync(dev->parent);
+
 	pm_runtime_barrier(dev);
 	ret = really_probe(dev, drv);
 	pm_request_idle(dev);
 
+	if (dev->parent)
+		pm_runtime_put(dev->parent);
+
 	return ret;
 }
 
@@ -507,11 +515,17 @@ static void __device_attach_async_helper(void *_dev, async_cookie_t cookie)
 
 	device_lock(dev);
 
+	if (dev->parent)
+		pm_runtime_get_sync(dev->parent);
+
 	bus_for_each_drv(dev->bus, NULL, &data, __device_attach_driver);
 	dev_dbg(dev, "async probe completed\n");
 
 	pm_request_idle(dev);
 
+	if (dev->parent)
+		pm_runtime_put(dev->parent);
+
 	device_unlock(dev);
 
 	put_device(dev);
@@ -541,6 +555,9 @@ static int __device_attach(struct device *dev, bool allow_async)
 			.want_async = false,
 		};
 
+		if (dev->parent)
+			pm_runtime_get_sync(dev->parent);
+
 		ret = bus_for_each_drv(dev->bus, NULL, &data,
 					__device_attach_driver);
 		if (!ret && allow_async && data.have_async) {
@@ -557,6 +574,9 @@ static int __device_attach(struct device *dev, bool allow_async)
 		} else {
 			pm_request_idle(dev);
 		}
+
+		if (dev->parent)
+			pm_runtime_put(dev->parent);
 	}
 out_unlock:
 	device_unlock(dev);
-- 
2.4.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1193835 — Re: [PATCH v6 3/8] Driver core: wakeup the parent device before trying probe

FromLee Jones <lee.jones@linaro.org>
Date2015-07-28 09:50 +0200
SubjectRe: [PATCH v6 3/8] Driver core: wakeup the parent device before trying probe
Message-ID<pR7O9-2HP-19@gated-at.bofh.it>
In reply to#1193234
On Mon, 27 Jul 2015, Andy Shevchenko wrote:

> From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
> 
> If the parent is still suspended when driver probe is
> attempted, the result may be failure.
> 
> For example, if the parent is a PCI MFD device that has been
> suspended when we try to probe our device, any register
> reads will return 0xffffffff.
> 
> To fix the problem, making sure the parent is always awake
> before attempting driver probe.
> 
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/base/dd.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)

Applied, thanks.  Pull request to follow.

> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index a638bbb..2d6df1d 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -399,6 +399,8 @@ EXPORT_SYMBOL_GPL(wait_for_device_probe);
>   *
>   * This function must be called with @dev lock held.  When called for a
>   * USB interface, @dev->parent lock must be held as well.
> + *
> + * If the device has a parent, runtime-resume the parent before driver probing.
>   */
>  int driver_probe_device(struct device_driver *drv, struct device *dev)
>  {
> @@ -410,10 +412,16 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
>  	pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
>  		 drv->bus->name, __func__, dev_name(dev), drv->name);
>  
> +	if (dev->parent)
> +		pm_runtime_get_sync(dev->parent);
> +
>  	pm_runtime_barrier(dev);
>  	ret = really_probe(dev, drv);
>  	pm_request_idle(dev);
>  
> +	if (dev->parent)
> +		pm_runtime_put(dev->parent);
> +
>  	return ret;
>  }
>  
> @@ -507,11 +515,17 @@ static void __device_attach_async_helper(void *_dev, async_cookie_t cookie)
>  
>  	device_lock(dev);
>  
> +	if (dev->parent)
> +		pm_runtime_get_sync(dev->parent);
> +
>  	bus_for_each_drv(dev->bus, NULL, &data, __device_attach_driver);
>  	dev_dbg(dev, "async probe completed\n");
>  
>  	pm_request_idle(dev);
>  
> +	if (dev->parent)
> +		pm_runtime_put(dev->parent);
> +
>  	device_unlock(dev);
>  
>  	put_device(dev);
> @@ -541,6 +555,9 @@ static int __device_attach(struct device *dev, bool allow_async)
>  			.want_async = false,
>  		};
>  
> +		if (dev->parent)
> +			pm_runtime_get_sync(dev->parent);
> +
>  		ret = bus_for_each_drv(dev->bus, NULL, &data,
>  					__device_attach_driver);
>  		if (!ret && allow_async && data.have_async) {
> @@ -557,6 +574,9 @@ static int __device_attach(struct device *dev, bool allow_async)
>  		} else {
>  			pm_request_idle(dev);
>  		}
> +
> +		if (dev->parent)
> +			pm_runtime_put(dev->parent);
>  	}
>  out_unlock:
>  	device_unlock(dev);

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web