All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] pinctrl: implement pinctrl deferred probing
@ 2012-04-11  8:34 ` Linus Walleij
  0 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2012-04-11  8:34 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Stephen Warren, Shawn Guo, Thomas Abraham, Dong Aisheng,
	Rajendra Nayak, Haojian Zhuang, Linus Walleij, Mark Brown,
	Arnd Bergmann

From: Linus Walleij <linus.walleij@linaro.org>

If drivers try to obtain pinctrl handles for a pin controller that
has not yet registered to the subsystem, we need to be able to
back out and retry with deferred probing. So let's return
-EPROBE_DEFER whenever this location fails. Also downgrade the
errors to info, maybe we will even set them to debug once the
deferred probing is commonplace.

Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 Documentation/pinctrl.txt    |    5 +++++
 drivers/pinctrl/core.c       |    9 ++++++---
 drivers/pinctrl/devicetree.c |    6 +++---
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt
index eb46b1c..4431c3e7 100644
--- a/Documentation/pinctrl.txt
+++ b/Documentation/pinctrl.txt
@@ -1043,6 +1043,11 @@ quickly poking some registers.
 The pins are allocated for your device when you issue the pinctrl_get() call,
 after this you should be able to see this in the debugfs listing of all pins.
 
+NOTE: the pinctrl system will return -EPROBE_DEFER if it cannot find the
+requested pinctrl handles, for example if the pinctrl driver has not yet
+registered. Thus make sure that the error path in your driver gracefully
+cleans up and is ready to retry the probing later in the startup process.
+
 
 System pin control hogging
 ==========================
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 7ff8690..59027ab 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -518,11 +518,14 @@ static int add_setting(struct pinctrl *p, struct pinctrl_map const *map)
 
 	setting->pctldev = get_pinctrl_dev_from_devname(map->ctrl_dev_name);
 	if (setting->pctldev == NULL) {
-		dev_err(p->dev, "unknown pinctrl device %s in map entry",
+		dev_info(p->dev, "unknown pinctrl device %s in map entry, deferring probe",
 			map->ctrl_dev_name);
 		kfree(setting);
-		/* Eventually, this should trigger deferred probe */
-		return -ENODEV;
+		/*
+		 * OK let us guess that the driver is not there yet, and
+		 * let's defer obtaining this pinctrl handle to later...
+		 */
+		return -EPROBE_DEFER;
 	}
 
 	switch (map->type) {
diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
index 5ef2feb..fcb1de4 100644
--- a/drivers/pinctrl/devicetree.c
+++ b/drivers/pinctrl/devicetree.c
@@ -121,11 +121,11 @@ static int dt_to_map_one_config(struct pinctrl *p, const char *statename,
 	for (;;) {
 		np_pctldev = of_get_next_parent(np_pctldev);
 		if (!np_pctldev || of_node_is_root(np_pctldev)) {
-			dev_err(p->dev, "could not find pctldev for node %s\n",
+			dev_info(p->dev, "could not find pctldev for node %s, deferring probe\n",
 				np_config->full_name);
 			of_node_put(np_pctldev);
-			/* FIXME: This should trigger deferrered probe */
-			return -ENODEV;
+			/* OK let's just assume this will appear later then */
+			return -EPROBE_DEFER;
 		}
 		pctldev = find_pinctrl_by_of_node(np_pctldev);
 		if (pctldev)
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2] pinctrl: implement pinctrl deferred probing
@ 2012-04-11  8:34 ` Linus Walleij
  0 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2012-04-11  8:34 UTC (permalink / raw)
  To: linux-arm-kernel

From: Linus Walleij <linus.walleij@linaro.org>

If drivers try to obtain pinctrl handles for a pin controller that
has not yet registered to the subsystem, we need to be able to
back out and retry with deferred probing. So let's return
-EPROBE_DEFER whenever this location fails. Also downgrade the
errors to info, maybe we will even set them to debug once the
deferred probing is commonplace.

Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 Documentation/pinctrl.txt    |    5 +++++
 drivers/pinctrl/core.c       |    9 ++++++---
 drivers/pinctrl/devicetree.c |    6 +++---
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt
index eb46b1c..4431c3e7 100644
--- a/Documentation/pinctrl.txt
+++ b/Documentation/pinctrl.txt
@@ -1043,6 +1043,11 @@ quickly poking some registers.
 The pins are allocated for your device when you issue the pinctrl_get() call,
 after this you should be able to see this in the debugfs listing of all pins.
 
+NOTE: the pinctrl system will return -EPROBE_DEFER if it cannot find the
+requested pinctrl handles, for example if the pinctrl driver has not yet
+registered. Thus make sure that the error path in your driver gracefully
+cleans up and is ready to retry the probing later in the startup process.
+
 
 System pin control hogging
 ==========================
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 7ff8690..59027ab 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -518,11 +518,14 @@ static int add_setting(struct pinctrl *p, struct pinctrl_map const *map)
 
 	setting->pctldev = get_pinctrl_dev_from_devname(map->ctrl_dev_name);
 	if (setting->pctldev == NULL) {
-		dev_err(p->dev, "unknown pinctrl device %s in map entry",
+		dev_info(p->dev, "unknown pinctrl device %s in map entry, deferring probe",
 			map->ctrl_dev_name);
 		kfree(setting);
-		/* Eventually, this should trigger deferred probe */
-		return -ENODEV;
+		/*
+		 * OK let us guess that the driver is not there yet, and
+		 * let's defer obtaining this pinctrl handle to later...
+		 */
+		return -EPROBE_DEFER;
 	}
 
 	switch (map->type) {
diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
index 5ef2feb..fcb1de4 100644
--- a/drivers/pinctrl/devicetree.c
+++ b/drivers/pinctrl/devicetree.c
@@ -121,11 +121,11 @@ static int dt_to_map_one_config(struct pinctrl *p, const char *statename,
 	for (;;) {
 		np_pctldev = of_get_next_parent(np_pctldev);
 		if (!np_pctldev || of_node_is_root(np_pctldev)) {
-			dev_err(p->dev, "could not find pctldev for node %s\n",
+			dev_info(p->dev, "could not find pctldev for node %s, deferring probe\n",
 				np_config->full_name);
 			of_node_put(np_pctldev);
-			/* FIXME: This should trigger deferrered probe */
-			return -ENODEV;
+			/* OK let's just assume this will appear later then */
+			return -EPROBE_DEFER;
 		}
 		pctldev = find_pinctrl_by_of_node(np_pctldev);
 		if (pctldev)
-- 
1.7.9.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] pinctrl: implement pinctrl deferred probing
  2012-04-11  8:34 ` Linus Walleij
@ 2012-04-11 15:43   ` Stephen Warren
  -1 siblings, 0 replies; 8+ messages in thread
From: Stephen Warren @ 2012-04-11 15:43 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-kernel, linux-arm-kernel, Shawn Guo, Thomas Abraham,
	Dong Aisheng, Rajendra Nayak, Haojian Zhuang, Linus Walleij,
	Mark Brown, Arnd Bergmann

On 04/11/2012 02:34 AM, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> If drivers try to obtain pinctrl handles for a pin controller that
> has not yet registered to the subsystem, we need to be able to
> back out and retry with deferred probing. So let's return
> -EPROBE_DEFER whenever this location fails. Also downgrade the
> errors to info, maybe we will even set them to debug once the
> deferred probing is commonplace.

Acked-by: Stephen Warren <swarren@wwwdotorg.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] pinctrl: implement pinctrl deferred probing
@ 2012-04-11 15:43   ` Stephen Warren
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Warren @ 2012-04-11 15:43 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/11/2012 02:34 AM, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> If drivers try to obtain pinctrl handles for a pin controller that
> has not yet registered to the subsystem, we need to be able to
> back out and retry with deferred probing. So let's return
> -EPROBE_DEFER whenever this location fails. Also downgrade the
> errors to info, maybe we will even set them to debug once the
> deferred probing is commonplace.

Acked-by: Stephen Warren <swarren@wwwdotorg.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] pinctrl: implement pinctrl deferred probing
  2012-04-11  8:34 ` Linus Walleij
@ 2012-04-12 17:09   ` Mark Brown
  -1 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2012-04-12 17:09 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-kernel, linux-arm-kernel, Stephen Warren, Shawn Guo,
	Thomas Abraham, Dong Aisheng, Rajendra Nayak, Haojian Zhuang,
	Linus Walleij, Arnd Bergmann

[-- Attachment #1: Type: text/plain, Size: 709 bytes --]

On Wed, Apr 11, 2012 at 10:34:08AM +0200, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> If drivers try to obtain pinctrl handles for a pin controller that
> has not yet registered to the subsystem, we need to be able to
> back out and retry with deferred probing. So let's return
> -EPROBE_DEFER whenever this location fails. Also downgrade the
> errors to info, maybe we will even set them to debug once the
> deferred probing is commonplace.

Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Note that the probe deferral code already has info level logs every time
it does anything so you'll probably have a hint from that when it kicks
into action.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] pinctrl: implement pinctrl deferred probing
@ 2012-04-12 17:09   ` Mark Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2012-04-12 17:09 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Apr 11, 2012 at 10:34:08AM +0200, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> If drivers try to obtain pinctrl handles for a pin controller that
> has not yet registered to the subsystem, we need to be able to
> back out and retry with deferred probing. So let's return
> -EPROBE_DEFER whenever this location fails. Also downgrade the
> errors to info, maybe we will even set them to debug once the
> deferred probing is commonplace.

Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Note that the probe deferral code already has info level logs every time
it does anything so you'll probably have a hint from that when it kicks
into action.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120412/6687be35/attachment.sig>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] pinctrl: implement pinctrl deferred probing
  2012-04-12 17:09   ` Mark Brown
@ 2012-04-12 17:34     ` Linus Walleij
  -1 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2012-04-12 17:34 UTC (permalink / raw)
  To: Mark Brown
  Cc: Linus Walleij, linux-kernel, linux-arm-kernel, Stephen Warren,
	Shawn Guo, Thomas Abraham, Dong Aisheng, Rajendra Nayak,
	Haojian Zhuang, Arnd Bergmann

On Thu, Apr 12, 2012 at 7:09 PM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:

> Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Thanks!

> Note that the probe deferral code already has info level logs every time
> it does anything so you'll probably have a hint from that when it kicks
> into action.

Yeah, but these messages tell you what caused the deferral.
I'll take some patches the day someone thinks the kernel is
getting too talkative...

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] pinctrl: implement pinctrl deferred probing
@ 2012-04-12 17:34     ` Linus Walleij
  0 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2012-04-12 17:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 12, 2012 at 7:09 PM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:

> Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Thanks!

> Note that the probe deferral code already has info level logs every time
> it does anything so you'll probably have a hint from that when it kicks
> into action.

Yeah, but these messages tell you what caused the deferral.
I'll take some patches the day someone thinks the kernel is
getting too talkative...

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-04-12 17:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-11  8:34 [PATCH v2] pinctrl: implement pinctrl deferred probing Linus Walleij
2012-04-11  8:34 ` Linus Walleij
2012-04-11 15:43 ` Stephen Warren
2012-04-11 15:43   ` Stephen Warren
2012-04-12 17:09 ` Mark Brown
2012-04-12 17:09   ` Mark Brown
2012-04-12 17:34   ` Linus Walleij
2012-04-12 17:34     ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.