All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] OF: mark released devices as no longer populated
@ 2016-08-09  9:33 ` Russell King
  0 siblings, 0 replies; 14+ messages in thread
From: Russell King @ 2016-08-09  9:33 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: Fabio Estevam, horia.geanta-3arQi8VN3Tc,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

When a Linux device is released and cleaned up, we left the OF device
node marked as populated.  This causes the Freescale CAAM driver
(drivers/crypto/caam) problems when the module is removed and re-
inserted:

JR0 Platform device creation error
JR0 Platform device creation error
caam 2100000.caam: no queues configured, terminating
caam: probe of 2100000.caam failed with error -12

The reason is that CAAM creates platform devices for each job ring:

        for_each_available_child_of_node(nprop, np)
                if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") ||
                    of_device_is_compatible(np, "fsl,sec4.0-job-ring")) {
                        ctrlpriv->jrpdev[ring] =
                                of_platform_device_create(np, NULL, dev);

which sets OF_POPULATED on the device node, but then it cleans these
up:

        /* Remove platform devices for JobRs */
        for (ring = 0; ring < ctrlpriv->total_jobrs; ring++) {
                if (ctrlpriv->jrpdev[ring])
                        of_device_unregister(ctrlpriv->jrpdev[ring]);
        }

which leaves OF_POPULATED set.

Arrange for platform devices with a device node to clear the
OF_POPULATED bit when they are released.

Signed-off-by: Russell King <rmk+kernel-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org>
---
Please check this carefully - it may have issues where an of_node
pointer is copied from one platform device to another, but IMHO
doing that is itself buggy behaviour.

Resending due to wrong list address, sorry.

 include/linux/of_device.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index cc7dd687a89d..7a8362d0c6d2 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -43,6 +43,7 @@ extern int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env
 
 static inline void of_device_node_put(struct device *dev)
 {
+	of_node_clear_flag(dev->of_node, OF_POPULATED);
 	of_node_put(dev->of_node);
 }
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2017-04-05 17:09 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-09  9:33 [PATCH] OF: mark released devices as no longer populated Russell King
2016-08-09  9:33 ` Russell King
     [not found] ` <E1bX3Pw-00088i-KU-eh5Bv4kxaXIk46pC+1QYvQNdhmdF6hFW@public.gmane.org>
2016-08-09 16:48   ` Rob Herring
2016-08-09 16:48     ` Rob Herring
     [not found]     ` <CAL_Jsq+pDeL1_=p06ynrV4CK+h8-Yx_KDbH-W=d-aSdARe3ZHw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-31 10:39       ` Russell King - ARM Linux
2017-03-31 10:39         ` Russell King - ARM Linux
2017-03-31 15:23         ` Horia Geantă
2017-03-31 15:23           ` Horia Geantă
     [not found]           ` <VI1PR0401MB2591E5FD962023914F042C9B98370-9IDQY6o3qQhGNIhRVge97I3W/0Ik+aLCnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-03-31 16:59             ` Rob Herring
2017-03-31 16:59               ` Rob Herring
2017-04-03 15:12               ` [PATCH] crypto: caam - fix JR platform device subsequent (re)creations Horia Geantă
2017-04-03 15:52                 ` Rob Herring
2017-04-05 14:08                 ` Herbert Xu
2017-04-05 17:09                   ` Horia Geantă

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.