linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv3] ARM: drivers/amba: release and cleanup the resource to allow for deferred probe
@ 2019-10-02 14:35 Dinh Nguyen
  2019-10-02 17:32 ` Russell King - ARM Linux admin
  0 siblings, 1 reply; 4+ messages in thread
From: Dinh Nguyen @ 2019-10-02 14:35 UTC (permalink / raw)
  To: linux
  Cc: thor.thayer, linus.walleij, linux-kernel, dinguyen, p.zabel,
	linux-arm-kernel

With commit "79bdcb202a35 ARM: 8906/1: drivers/amba: add reset control to
amba bus probe", the amba bus driver needs to be deferred probe because the
reset driver is probed later. However with a deferred probe, the call to
request_resource() in the driver returns -EBUSY. The reason is the driver
has not released the resource from the previous probe attempt.

This patch fixes how we handle the condition of EPROBE_DEFER that is returned
from getting the reset controls. For this condition, the patch will jump
to defer_probe, which will iounmap, dev_pm_domain_detach, and release the
resource.

Fixes: 79bdcb202a35 ("ARM: 8906/1: drivers/amba: add reset control to
amba bus probe")
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
---
v3: jump to defer_probe where the driver will unmap and pm_detach the
    driver resource for the next probe attempt
v2: release the resource when of_reset_control_array_get_optional_shared()
    returns EPROBE_DEFER
---
 drivers/amba/bus.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index f39f075abff9..4a021b1dab3d 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -409,9 +409,12 @@ static int amba_device_try_add(struct amba_device *dev, struct resource *parent)
 		 */
 		rstc = of_reset_control_array_get_optional_shared(dev->dev.of_node);
 		if (IS_ERR(rstc)) {
-			if (PTR_ERR(rstc) != -EPROBE_DEFER)
+			ret = PTR_ERR(rstc);
+			if (ret == -EPROBE_DEFER)
+				goto defer_probe;
+			else
 				dev_err(&dev->dev, "Can't get amba reset!\n");
-			return PTR_ERR(rstc);
+			return ret;
 		}
 		reset_control_deassert(rstc);
 		reset_control_put(rstc);
@@ -448,6 +451,7 @@ static int amba_device_try_add(struct amba_device *dev, struct resource *parent)
 			ret = -ENODEV;
 	}
 
+ defer_probe:
 	iounmap(tmp);
 	dev_pm_domain_detach(&dev->dev, true);
 
-- 
2.20.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-10-02 20:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-02 14:35 [PATCHv3] ARM: drivers/amba: release and cleanup the resource to allow for deferred probe Dinh Nguyen
2019-10-02 17:32 ` Russell King - ARM Linux admin
2019-10-02 20:45   ` Dinh Nguyen
2019-10-02 20:45   ` Dinh Nguyen

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).