Skip to contentSkip to conversation

Make deferring probe forever optional

PATCH Superseded Rob Herring 5 participants 12 messages Jun 28, 2018 – Jul 7, 2018

Subsystems (15)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Rob Herring

author maintainer
#0 lore raw

v3 cover Make deferring probe forever optional

This series came out of a discussion on the ARM boot-architecture list[1] about DT forwards and backwards compatibility issues. There are issues with newer DTs breaking on older, stable kernels. Some of these are difficult to solve, but cases of optional devices not having kernel support should be solvable.

I tested this on a RPi3 B with the pinctrl driver forced off. With this change, the MMC/SD and UART drivers can function without the pinctrl driver. I left the dts change out this time.

v2 of this series can be found here[2].

Rob

[1] https://lists.linaro.org/pipermail/boot-architecture/2018-April/000466.html
[2] https://lore.kernel.org/patchwork/project/lkml/list/?series=347413

Rob Herring (6):
driver core: allow stopping deferred probe after init
dt-bindings: pinctrl: add a 'pinctrl-use-default' property
pinctrl: Support stopping deferred probe after initcalls
iommu: Stop deferring probe at end of initcalls
iommu: Remove IOMMU_OF_DECLARE
PM / Domains: Stop deferring probe at the end of initcall

 .../admin-guide/kernel-parameters.txt         |  9 +++
 .../bindings/pinctrl/pinctrl-bindings.txt     |  6 ++
 drivers/base/dd.c                             | 57 +++++++++++++++++++
 drivers/base/power/domain.c                   |  2 +-
 drivers/iommu/arm-smmu-v3.c                   |  2 -
 drivers/iommu/arm-smmu.c                      |  7 ---
 drivers/iommu/exynos-iommu.c                  |  2 -
 drivers/iommu/ipmmu-vmsa.c                    |  3 -
 drivers/iommu/msm_iommu.c                     |  2 -
 drivers/iommu/of_iommu.c                      | 21 +------
 drivers/iommu/qcom_iommu.c                    |  2 -
 drivers/iommu/rockchip-iommu.c                |  2 -
 drivers/pinctrl/devicetree.c                  | 15 +++--
 include/asm-generic/vmlinux.lds.h             |  2 -
 include/linux/device.h                        |  2 +
 include/linux/of_iommu.h                      |  4 --
 16 files changed, 88 insertions(+), 50 deletions(-)

--
2.17.1

author maintainer
#1 lore raw

PATCH v3 1/6 driver core: allow stopping deferred probe after init

Deferred probe will currently wait forever on dependent devices to probe, but sometimes a driver will never exist. It's also not always critical for a driver to exist. Platforms can rely on default configuration from the bootloader or reset defaults for things such as pinctrl and power domains. This is often the case with initial platform support until various drivers get enabled. There's at least 2 scenarios where deferred probe can render a platform broken. Both involve using a DT which has more devices and dependencies than the kernel supports. The 1st case is a driver may be disabled in the kernel config. The 2nd case is the kernel version may simply not have the dependent driver. This can happen if using a newer DT (provided by firmware perhaps) with a stable kernel version. Deferred probe issues can be difficult to debug especially if the console has dependencies or userspace fails to boot to a shell.

There are also cases like IOMMUs where only built-in drivers are supported, so deferring probe after initcalls is not needed. The IOMMU subsystem implemented its own mechanism to handle this using OF_DECLARE linker sections.

This commit adds makes ending deferred probe conditional on initcalls being completed or a debug timeout. Subsystems or drivers may opt-in by calling driver_deferred_probe_check_init_done() instead of unconditionally returning -EPROBE_DEFER. They may use additional information from DT or kernel's config to decide whether to continue to defer probe or not.

The timeout mechanism is intended for debug purposes and WARNs loudly. The remaining deferred probe pending list will also be dumped after the timeout. Not that this timeout won't work for the console which needs to be enabled before userspace starts. However, if the console's dependencies are resolved, then the kernel log will be printed (as opposed to no output).

Cc Alexander Graf <[email protected]>

---
v3:
- Merged with timeout patch.
- Clarify that deferred_probe_timeout is a debug option.
- Drop the 'optional' param. The only user was pinctrl, so it has to handle that functionality.
- Rename function to driver_deferred_probe_check_state
- Added kerneldoc for driver_deferred_probe_check_state
- Print a 1 line warning if stopping deferred probe after initcalls and a WARN on timeout.

 .../admin-guide/kernel-parameters.txt         |  9 +++
 drivers/base/dd.c                             | 57 +++++++++++++++++++
 include/linux/device.h                        |  2 +
 3 files changed, 68 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +9 -0
index efc7aa7a0670..e83ef4648ea4 100644
@@ -804,6 +804,15 @@
 			Defaults to the default architecture's huge page size
 			if not specified.
 
+	deferred_probe_timeout=
+			[KNL] Debugging option to set a timeout in seconds for
+			deferred probe to give up waiting on dependencies to
+			probe. Only specific dependencies (subsystems or
+			drivers) that have opted in will be ignored. A timeout of 0
+			will timeout at the end of initcalls. This option will also
+			dump out devices still on the deferred probe list after
+			retrying.
+
 	dhash_entries=	[KNL]
 			Set number of hash buckets for dentry cache.
 
drivers/base/dd.c +57 -0

69 lines not on this page · raw message

include/linux/device.h +2 -0
index 055a69dbcd18..b6d8e0a09ad9 100644
@@ -339,6 +339,8 @@ struct device *driver_find_device(struct device_driver *drv,
 				  struct device *start, void *data,
 				  int (*match)(struct device *dev, void *data));
 
+int driver_deferred_probe_check_state(struct device *dev);
+
 /**
  * struct subsys_interface - interfaces to device functions
  * @name:       name of the device function

--
2.17.1

#2 lore raw

Re: [PATCH v3 1/6] driver core: allow stopping deferred probe after init

Quoted 26 lines · Rob Herring

Deferred probe will currently wait forever on dependent devices to probe, but sometimes a driver will never exist. It's also not always critical for a driver to exist. Platforms can rely on default configuration from the bootloader or reset defaults for things such as pinctrl and power domains. This is often the case with initial platform support until various drivers get enabled. There's at least 2 scenarios where deferred probe can render a platform broken. Both involve using a DT which has more devices and dependencies than the kernel supports. The 1st case is a driver may be disabled in the kernel config. The 2nd case is the kernel version may simply not have the dependent driver. This can happen if using a newer DT (provided by firmware perhaps) with a stable kernel version. Deferred probe issues can be difficult to debug especially if the console has dependencies or userspace fails to boot to a shell.

There are also cases like IOMMUs where only built-in drivers are supported, so deferring probe after initcalls is not needed. The IOMMU subsystem implemented its own mechanism to handle this using OF_DECLARE linker sections.

This commit adds makes ending deferred probe conditional on initcalls being completed or a debug timeout. Subsystems or drivers may opt-in by calling driver_deferred_probe_check_init_done() instead of unconditionally returning -EPROBE_DEFER. They may use additional information from DT or kernel's config to decide whether to continue to defer probe or not.

Quoted 7 lines

The timeout mechanism is intended for debug purposes and WARNs loudly.

The remaining deferred probe pending list will also be dumped after the timeout. Not that this timeout won't work for the console which needs to be enabled before userspace starts. However, if the console's dependencies are resolved, then the kernel log will be printed (as opposed to no output).

There is another patch flying around with debugfs node to dump a list of deferred probe queue.
I dunno if it makes sense to dump it here and there and if yes, some unification in output, perhaps?

Quoted 1 line

+ deferred_probe_timeout = simple_strtol(str, NULL, 0);

Hmm... I don't think 16-base or 8-base values are useful to support. One subtle difference that people usually consider timeout values as 10-base and if at some point someone makes it as 0100 (no matter why), it would be much less than expected.
08 wouldn't parsed at all.

Quoted 1 line

+ if (deferred_probe_timeout > 0) {

Would it be harmful / useful if we skip this check and run the work immediately?

Quoted 3 lines
drivers/base/dd.c +3 -0
+               schedule_delayed_work(&deferred_probe_timeout_work,
+                       deferred_probe_timeout * HZ);
+       }
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#3 lore raw

Re: [PATCH v3 1/6] driver core: allow stopping deferred probe after init

Quoted 36 lines · Andy Shevchenko
Quoted 26 lines · Rob Herring

Deferred probe will currently wait forever on dependent devices to probe, but sometimes a driver will never exist. It's also not always critical for a driver to exist. Platforms can rely on default configuration from the bootloader or reset defaults for things such as pinctrl and power domains. This is often the case with initial platform support until various drivers get enabled. There's at least 2 scenarios where deferred probe can render a platform broken. Both involve using a DT which has more devices and dependencies than the kernel supports. The 1st case is a driver may be disabled in the kernel config. The 2nd case is the kernel version may simply not have the dependent driver. This can happen if using a newer DT (provided by firmware perhaps) with a stable kernel version. Deferred probe issues can be difficult to debug especially if the console has dependencies or userspace fails to boot to a shell.

There are also cases like IOMMUs where only built-in drivers are supported, so deferring probe after initcalls is not needed. The IOMMU subsystem implemented its own mechanism to handle this using OF_DECLARE linker sections.

This commit adds makes ending deferred probe conditional on initcalls being completed or a debug timeout. Subsystems or drivers may opt-in by calling driver_deferred_probe_check_init_done() instead of unconditionally returning -EPROBE_DEFER. They may use additional information from DT or kernel's config to decide whether to continue to defer probe or not.

Quoted 7 lines

The timeout mechanism is intended for debug purposes and WARNs loudly.

The remaining deferred probe pending list will also be dumped after the timeout. Not that this timeout won't work for the console which needs to be enabled before userspace starts. However, if the console's dependencies are resolved, then the kernel log will be printed (as opposed to no output).

Quoted 4 lines

There is another patch flying around with debugfs node to dump a list of deferred probe queue.
I dunno if it makes sense to dump it here and there and if yes, some unification in output, perhaps?

Here makes sense because you may not be able to mount and read debugfs. That's the reason for the timeout too. Otherwise, debugfs could be used to trigger the same thing.

They are aligned at least in that both use dev_name(), but I don't think we can align completely as we need the context in the log where as reading a file you know the context already.

Quoted 7 lines
Quoted 1 line

+ deferred_probe_timeout = simple_strtol(str, NULL, 0);

Hmm... I don't think 16-base or 8-base values are useful to support. One subtle difference that people usually consider timeout values as 10-base and if at some point someone makes it as 0100 (no matter why), it would be much less than expected.
08 wouldn't parsed at all.

Agreed.

Quoted 3 lines
Quoted 1 line

+ if (deferred_probe_timeout > 0) {

Would it be harmful / useful if we skip this check and run the work immediately?

The default is -1 which is disabled. Scheduling work in that case would give us a very long timeout instead.

If the timeout is 0, then this never needs to run because driver_deferred_probe_check_state will immediately timeout. Running it would be harmless though as it would just do an extra run of deferred probe wq.

Rob

#4 lore raw

Re: [PATCH v3 1/6] driver core: allow stopping deferred probe after init

In reply to Rob Herring
Quoted 33 lines · Rob Herring

Deferred probe will currently wait forever on dependent devices to probe, but sometimes a driver will never exist. It's also not always critical for a driver to exist. Platforms can rely on default configuration from the bootloader or reset defaults for things such as pinctrl and power domains. This is often the case with initial platform support until various drivers get enabled. There's at least 2 scenarios where deferred probe can render a platform broken. Both involve using a DT which has more devices and dependencies than the kernel supports. The 1st case is a driver may be disabled in the kernel config. The 2nd case is the kernel version may simply not have the dependent driver. This can happen if using a newer DT (provided by firmware perhaps) with a stable kernel version. Deferred probe issues can be difficult to debug especially if the console has dependencies or userspace fails to boot to a shell.

There are also cases like IOMMUs where only built-in drivers are supported, so deferring probe after initcalls is not needed. The IOMMU subsystem implemented its own mechanism to handle this using OF_DECLARE linker sections.

This commit adds makes ending deferred probe conditional on initcalls being completed or a debug timeout. Subsystems or drivers may opt-in by calling driver_deferred_probe_check_init_done() instead of unconditionally returning -EPROBE_DEFER. They may use additional information from DT or kernel's config to decide whether to continue to defer probe or not.

The timeout mechanism is intended for debug purposes and WARNs loudly. The remaining deferred probe pending list will also be dumped after the timeout. Not that this timeout won't work for the console which needs to be enabled before userspace starts. However, if the console's dependencies are resolved, then the kernel log will be printed (as opposed to no output).

Quoted 2 lines
Cc Alexander Graf <[email protected]>

I wanted to apply this series, but this patch failed to apply to my driver-core tree :(

Can you rebase it and resend?

thanks,

greg k-h

author maintainer
#5 lore raw

PATCH v3 2/6 dt-bindings: pinctrl: add a 'pinctrl-use-default' property

In reply to Rob Herring

Pin setup may be optional in some cases such as the reset default works or the pin setup is done by the bootloader. In these cases, it is optional for the OS to support managing the pin controller and pin setup. In order to support this scenario, add a property 'pinctrl-use-default' to indicate that the pin configuration is optional.

---
 .../devicetree/bindings/pinctrl/pinctrl-bindings.txt        | 6 ++++++
 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt +6 -0
index ad9bbbba36e9..cef2b5855d60 100644
@@ -103,6 +103,12 @@ Optional properties:
 #pinctrl-cells:	Number of pin control cells in addition to the index within the
 		pin controller device instance
 
+pinctrl-use-default: Boolean. Indicates that the OS can use the boot default
+		pin configuration. This allows using an OS that does not have a
+		driver for the pin controller. This property can be set either
+		globally for the pin controller or in child nodes for individual
+		pin group control.
+
 Pin controller devices should contain the pin configuration nodes that client
 devices reference.
 
Signature · 1 line
2.17.1
author maintainer
#6 lore raw

PATCH v3 3/6 pinctrl: Support stopping deferred probe after initcalls

In reply to Rob Herring

Pinctrl drivers are a common dependency which can prevent a system booting even if the default or bootloader configured settings can work. If a pinctrl node in DT indicates that the default pin setup can be used with the 'pinctrl-use-default' property, then only defer probe until initcalls are done. If the deferred probe timeout is enabled or loadable modules are disabled, then we'll stop deferring probe regardless of the DT property. This gives platforms the option to work without their pinctrl driver being enabled.

Dropped the pinctrl specific deferring probe message as the driver core can print deferred probe related messages if needed.

---
v3:
- Drop pinctrl deferred probe msg in favor of driver core messages
- Move the handling of "pinctrl-use-default" option out of driver core
- Stop deferring probe if modules are not enabled.

Linus, I reworked this a bit, so didn't add your ack.

 drivers/pinctrl/devicetree.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/pinctrl/devicetree.c +11 -4
index c4aa411f5935..2969ff3162c3 100644
@@ -111,17 +111,24 @@ static int dt_to_map_one_config(struct pinctrl *p,
 	int ret;
 	struct pinctrl_map *map;
 	unsigned num_maps;
+	bool allow_default = false;
 
 	/* Find the pin controller containing np_config */
 	np_pctldev = of_node_get(np_config);
 	for (;;) {
+		if (!allow_default)
+			allow_default = of_property_read_bool(np_pctldev,
+							      "pinctrl-use-default");
+
 		np_pctldev = of_get_next_parent(np_pctldev);
 		if (!np_pctldev || of_node_is_root(np_pctldev)) {
-			dev_info(p->dev, "could not find pctldev for node %pOF, deferring probe\n",
-				np_config);
 			of_node_put(np_pctldev);
-			/* OK let's just assume this will appear later then */
-			return -EPROBE_DEFER;
+			ret = driver_deferred_probe_check_state(p->dev);
+			/* keep deferring if modules are enabled unless we've timed out */
+			if (IS_ENABLED(CONFIG_MODULES) && !allow_default && ret == -ENODEV)
+				ret = -EPROBE_DEFER;
+
+			return ret;
 		}
 		/* If we're creating a hog we can use the passed pctldev */
 		if (hog_pctldev && (np_pctldev == p->dev->of_node)) {

--
2.17.1

Reviewed-by on v3 3/6
#7 lore raw

Re: [PATCH v3 3/6] pinctrl: Support stopping deferred probe after initcalls

Quoted 12 lines · Rob Herring

Pinctrl drivers are a common dependency which can prevent a system booting even if the default or bootloader configured settings can work. If a pinctrl node in DT indicates that the default pin setup can be used with the 'pinctrl-use-default' property, then only defer probe until initcalls are done. If the deferred probe timeout is enabled or loadable modules are disabled, then we'll stop deferring probe regardless of the DT property. This gives platforms the option to work without their pinctrl driver being enabled.

Dropped the pinctrl specific deferring probe message as the driver core can print deferred probe related messages if needed.

Quoted 8 lines

---
v3:
- Drop pinctrl deferred probe msg in favor of driver core messages
- Move the handling of "pinctrl-use-default" option out of driver core
- Stop deferring probe if modules are not enabled.

Linus, I reworked this a bit, so didn't add your ack.

Looks even better now:

Yours,
Linus Walleij

author maintainer
#8 lore raw

PATCH v3 4/6 iommu: Stop deferring probe at end of initcalls

In reply to Rob Herring

The IOMMU subsystem has its own mechanism to not defer probe if driver support is missing. Now that the driver core supports stopping deferring probe if drivers aren't built-in (and probed), use the driver core support so the IOMMU specific support can be removed.

Cc iommu at lists.linux-foundation.org

---
v3:
- Update to new function name

 drivers/iommu/of_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/of_iommu.c +1 -1
index 5c36a8b7656a..78ddf47dd67a 100644
@@ -133,7 +133,7 @@ static int of_iommu_xlate(struct device *dev,
 	 * a proper probe-ordering dependency mechanism in future.
 	 */
 	if (!ops)
-		return -EPROBE_DEFER;
+		return driver_deferred_probe_check_state(dev);
 
 	return ops->of_xlate(dev, iommu_spec);
 }

--
2.17.1

author maintainer
#9 lore raw

PATCH v3 5/6 iommu: Remove IOMMU_OF_DECLARE

In reply to Rob Herring

Now that we use the driver core to stop deferred probe for missing drivers, IOMMU_OF_DECLARE can be removed.

This is slightly less optimal than having a list of built-in drivers in that we'll now defer probe twice before giving up. This shouldn't have a significant impact on boot times as past discussions about deferred probe have given no evidence of deferred probe having a substantial impact.

Cc Robin Murphy <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
Cc Rob Clark <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Frank Rowand <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc iommu at lists.linux-foundation.org
Cc linux-samsung-soc at vger.kernel.org
Cc linux-arm-msm at vger.kernel.org
Cc linux-rockchip at lists.infradead.org
Cc devicetree at vger.kernel.org

---
v3:
- Also remove linker sections from vmlinux.lds.h

 drivers/iommu/arm-smmu-v3.c       |  2 --
 drivers/iommu/arm-smmu.c          |  7 -------
 drivers/iommu/exynos-iommu.c      |  2 --
 drivers/iommu/ipmmu-vmsa.c        |  3 ---
 drivers/iommu/msm_iommu.c         |  2 --
 drivers/iommu/of_iommu.c          | 19 +------------------
 drivers/iommu/qcom_iommu.c        |  2 --
 drivers/iommu/rockchip-iommu.c    |  2 --
 include/asm-generic/vmlinux.lds.h |  2 --
 include/linux/of_iommu.h          |  4 ----
 10 files changed, 1 insertion(+), 44 deletions(-)
drivers/iommu/arm-smmu-v3.c +0 -2
index 1d647104bccc..22bdabd3d8e0 100644
@@ -2915,8 +2915,6 @@ static struct platform_driver arm_smmu_driver = {
 };
 module_platform_driver(arm_smmu_driver);
 
-IOMMU_OF_DECLARE(arm_smmuv3, "arm,smmu-v3");
-
 MODULE_DESCRIPTION("IOMMU API for ARM architected SMMUv3 implementations");
 MODULE_AUTHOR("Will Deacon <[email protected]>");
 MODULE_LICENSE("GPL v2");
drivers/iommu/arm-smmu.c +0 -7
index f7a96bcf94a6..c73cfce1ccc0 100644
@@ -2211,13 +2211,6 @@ static struct platform_driver arm_smmu_driver = {
 };
 module_platform_driver(arm_smmu_driver);
 
-IOMMU_OF_DECLARE(arm_smmuv1, "arm,smmu-v1");
-IOMMU_OF_DECLARE(arm_smmuv2, "arm,smmu-v2");
-IOMMU_OF_DECLARE(arm_mmu400, "arm,mmu-400");
-IOMMU_OF_DECLARE(arm_mmu401, "arm,mmu-401");
-IOMMU_OF_DECLARE(arm_mmu500, "arm,mmu-500");
-IOMMU_OF_DECLARE(cavium_smmuv2, "cavium,smmu-v2");
-
 MODULE_DESCRIPTION("IOMMU API for ARM architected SMMU implementations");
 MODULE_AUTHOR("Will Deacon <[email protected]>");
 MODULE_LICENSE("GPL v2");
drivers/iommu/exynos-iommu.c +0 -2
index 85879cfec52f..b128cb4372d3 100644
@@ -1390,5 +1390,3 @@ static int __init exynos_iommu_init(void)
 	return ret;
 }
 core_initcall(exynos_iommu_init);
-
-IOMMU_OF_DECLARE(exynos_iommu_of, "samsung,exynos-sysmmu");
drivers/iommu/ipmmu-vmsa.c +0 -3
index 40ae6e87cb88..f026aa16d5f1 100644
@@ -1108,9 +1108,6 @@ static void __exit ipmmu_exit(void)
 subsys_initcall(ipmmu_init);
 module_exit(ipmmu_exit);
 
-IOMMU_OF_DECLARE(ipmmu_vmsa_iommu_of, "renesas,ipmmu-vmsa");
-IOMMU_OF_DECLARE(ipmmu_r8a7795_iommu_of, "renesas,ipmmu-r8a7795");
-
 MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");
 MODULE_AUTHOR("Laurent Pinchart <[email protected]>");
 MODULE_LICENSE("GPL v2");
drivers/iommu/msm_iommu.c +0 -2
index 0d3350463a3f..27377742600d 100644
@@ -877,7 +877,5 @@ static void __exit msm_iommu_driver_exit(void)
 subsys_initcall(msm_iommu_driver_init);
 module_exit(msm_iommu_driver_exit);
 
-IOMMU_OF_DECLARE(msm_iommu_of, "qcom,apq8064-iommu");
-
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Stepan Moskovchenko <[email protected]>");
drivers/iommu/of_iommu.c +1 -18
index 78ddf47dd67a..f7787e757244 100644
@@ -27,9 +27,6 @@
 
 #define NO_IOMMU	1
 
-static const struct of_device_id __iommu_of_table_sentinel
-	__used __section(__iommu_of_table_end);
-
 /**
  * of_get_dma_window - Parse *dma-window property and returns 0 if found.
  *
@@ -98,19 +95,6 @@ int of_get_dma_window(struct device_node *dn, const char *prefix, int index,
 }
 EXPORT_SYMBOL_GPL(of_get_dma_window);
 
-static bool of_iommu_driver_present(struct device_node *np)
-{
-	/*
-	 * If the IOMMU still isn't ready by the time we reach init, assume
-	 * it never will be. We don't want to defer indefinitely, nor attempt
-	 * to dereference __iommu_of_table after it's been freed.
-	 */
-	if (system_state >= SYSTEM_RUNNING)
-		return false;
-
-	return of_match_node(&__iommu_of_table, np);
-}
-
 static int of_iommu_xlate(struct device *dev,
 			  struct of_phandle_args *iommu_spec)
 {
@@ -120,8 +104,7 @@ static int of_iommu_xlate(struct device *dev,
 
 	ops = iommu_ops_from_fwnode(fwnode);
 	if ((ops && !ops->of_xlate) ||
-	    !of_device_is_available(iommu_spec->np) ||
-	    (!ops && !of_iommu_driver_present(iommu_spec->np)))
+	    !of_device_is_available(iommu_spec->np))
 		return NO_IOMMU;
 
 	err = iommu_fwspec_init(dev, &iommu_spec->np->fwnode, ops);
drivers/iommu/qcom_iommu.c +0 -2
index fe88a4880d3a..b48aee82d14b 100644
@@ -945,7 +945,5 @@ static void __exit qcom_iommu_exit(void)
 module_init(qcom_iommu_init);
 module_exit(qcom_iommu_exit);
 
-IOMMU_OF_DECLARE(qcom_iommu_dev, "qcom,msm-iommu-v1");
-
 MODULE_DESCRIPTION("IOMMU API for QCOM IOMMU v1 implementations");
 MODULE_LICENSE("GPL v2");
drivers/iommu/rockchip-iommu.c +0 -2
index 054cd2c8e9c8..de8d3bf91b23 100644
@@ -1284,8 +1284,6 @@ static int __init rk_iommu_init(void)
 }
 subsys_initcall(rk_iommu_init);
 
-IOMMU_OF_DECLARE(rk_iommu_of, "rockchip,iommu");
-
 MODULE_DESCRIPTION("IOMMU API for Rockchip");
 MODULE_AUTHOR("Simon Xue <[email protected]> and Daniel Kurtz <[email protected]>");
 MODULE_ALIAS("platform:rockchip-iommu");
include/asm-generic/vmlinux.lds.h +0 -2
index e373e2e10f6a..f173b5f30dbe 100644
@@ -218,7 +218,6 @@
 #define TIMER_OF_TABLES()	OF_TABLE(CONFIG_TIMER_OF, timer)
 #define IRQCHIP_OF_MATCH_TABLE() OF_TABLE(CONFIG_IRQCHIP, irqchip)
 #define CLK_OF_TABLES()		OF_TABLE(CONFIG_COMMON_CLK, clk)
-#define IOMMU_OF_TABLES()	OF_TABLE(CONFIG_OF_IOMMU, iommu)
 #define RESERVEDMEM_OF_TABLES()	OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
 #define CPU_METHOD_OF_TABLES()	OF_TABLE(CONFIG_SMP, cpu_method)
 #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method)
@@ -601,7 +600,6 @@
 	CLK_OF_TABLES()							\
 	RESERVEDMEM_OF_TABLES()						\
 	TIMER_OF_TABLES()						\
-	IOMMU_OF_TABLES()						\
 	CPU_METHOD_OF_TABLES()						\
 	CPUIDLE_METHOD_OF_TABLES()					\
 	KERNEL_DTB()							\
include/linux/of_iommu.h +0 -4
index 4fa654e4b5a9..f3d40dd7bb66 100644
@@ -32,8 +32,4 @@ static inline const struct iommu_ops *of_iommu_configure(struct device *dev,
 
 #endif	/* CONFIG_OF_IOMMU */
 
-extern struct of_device_id __iommu_of_table;
-
-#define IOMMU_OF_DECLARE(name, compat)	OF_DECLARE_1(iommu, name, compat, NULL)
-
 #endif /* __OF_IOMMU_H */

--
2.17.1

author maintainer
#10 lore raw

PATCH v3 6/6 PM / Domains: Stop deferring probe at the end of initcall

In reply to Rob Herring

All PM domain drivers must be built-in (at least those using DT), so there is no point deferring probe after initcalls are done. Continuing to defer probe may prevent booting successfully even if managing PM domains is not required. This can happen if the user failed to enable the driver or if power-domains are added to a platform's DT, but there is not yet a driver (e.g. a new DTB with an old kernel).

Call the driver core function driver_deferred_probe_check_init_done() instead of just returning -EPROBE_DEFER to stop deferring probe when initcalls are done.

Cc "Rafael J. Wysocki" <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Ulf Hansson <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Len Brown <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc linux-pm at vger.kernel.org

---
v3:
- Update to new function name

 drivers/base/power/domain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/power/domain.c +1 -1
index 4925af5c4cf0..8c12213875c6 100644
@@ -2253,7 +2253,7 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
 		mutex_unlock(&gpd_list_lock);
 		dev_dbg(dev, "%s() failed to find PM domain: %ld\n",
 			__func__, PTR_ERR(pd));
-		return -EPROBE_DEFER;
+		return driver_deferred_probe_check_state(dev);
 	}
 
 	dev_dbg(dev, "adding to PM domain %s\n", pd->name);

--
2.17.1

#11 lore raw

Re: [PATCH v3 6/6] PM / Domains: Stop deferring probe at the end of initcall

Quoted 31 lines · CEST Rob Herring

All PM domain drivers must be built-in (at least those using DT), so there is no point deferring probe after initcalls are done. Continuing to defer probe may prevent booting successfully even if managing PM domains is not required. This can happen if the user failed to enable the driver or if power-domains are added to a platform's DT, but there is not yet a driver (e.g. a new DTB with an old kernel).

Call the driver core function driver_deferred_probe_check_init_done() instead of just returning -EPROBE_DEFER to stop deferring probe when initcalls are done.

Cc "Rafael J. Wysocki" <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Ulf Hansson <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Len Brown <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc linux-pm at vger.kernel.org

---
v3:
- Update to new function name

 drivers/base/power/domain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/power/domain.c +0 -0
index 4925af5c4cf0..8c12213875c6 100644

drivers/base/power/domain.c static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,

Quoted 9 lines
drivers/base/power/domain.c +1 -2
@@ -2253,7 +2253,7 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
 		mutex_unlock(&gpd_list_lock);
 		dev_dbg(dev, "%s() failed to find PM domain: %ld\n",
 			__func__, PTR_ERR(pd));
-		return -EPROBE_DEFER;
+		return driver_deferred_probe_check_state(dev);
 	}
 
 	dev_dbg(dev, "adding to PM domain %s\n", pd->name);
--

ACK