Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1234892 > unrolled thread
| Started by | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| First post | 2015-09-29 11:20 +0200 |
| Last post | 2015-09-29 11:20 +0200 |
| Articles | 13 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH v7 0/20] On-demand device probing Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-29 11:20 +0200
[PATCH v7 20/20] of/platform: Defer probes of registered devices Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-29 11:20 +0200
[PATCH v7 13/20] usb: phy: Probe phy devices on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-29 11:20 +0200
[PATCH v7 09/20] drm/tegra: Probe dpaux devices on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-29 11:20 +0200
[PATCH v7 15/20] pinctrl: Probe pinctrl devices on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-29 11:20 +0200
[PATCH v7 06/20] pinctrl: Probe pinctrl devices on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-29 11:20 +0200
[PATCH v7 03/20] of/platform: Point to struct device from device node Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-29 11:20 +0200
[PATCH v7 10/20] i2c: core: Probe i2c adapters and devices on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-29 11:20 +0200
[PATCH v7 17/20] dma: of: Probe DMA controllers on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-29 11:20 +0200
[PATCH v7 11/20] pwm: Probe PWM chip devices on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-29 11:20 +0200
[PATCH v7 07/20] regulator: core: Probe regulators on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-29 11:20 +0200
[PATCH v7 12/20] backlight: Probe backlight devices on demand Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-29 11:20 +0200
[PATCH v7 04/20] of: add function to allow probing a device from a OF node Tomeu Vizoso <tomeu.vizoso@collabora.com> - 2015-09-29 11:20 +0200
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Date | 2015-09-29 11:20 +0200 |
| Subject | [PATCH v7 0/20] On-demand device probing |
| Message-ID | <qdZeN-2b3-5@gated-at.bofh.it> |
Hello, I have a problem with the panel on my Tegra Chromebook taking longer than expected to be ready during boot (Stéphane Marchesin reported what is basically the same issue in [0]), and have looked into ordered probing as a better way of solving this than moving nodes around in the DT or playing with initcall levels and linking order. While reading the thread [1] that Alexander Holler started with his series to make probing order deterministic, it occurred to me that it should be possible to achieve the same by probing devices as they are referenced by other devices. This basically reuses the information that is already implicit in the probe() implementations, saving us from refactoring existing drivers or adding information to DTBs. During review of v1 of this series Linus Walleij suggested that it should be the device driver core to make sure that dependencies are ready before probing a device. I gave this idea a try [2] but Mark Brown pointed out to the logic duplication between the resource acquisition and dependency discovery code paths (though I think it's fairly minor). To address that code duplication I experimented with Arnd's devm_probe [3] concept of having drivers declare their dependencies instead of acquiring them during probe, and while it worked [4], I don't think we end up winning anything when compared to just probing devices on-demand from resource getters. One remaining objection is to the "sprinkling" of calls to of_device_probe() in the resource getters of each subsystem, but I think it's the right thing to do given that the storage of resources is currently subsystem-specific. We could avoid the above by moving resource storage into the core, but I don't think there's a compelling case for that. I have tested this on boards with Tegra, iMX.6, Exynos, Rockchip and OMAP SoCs, and these patches were enough to eliminate all the deferred probes (except one in PandaBoard because omap_dma_system doesn't have a firmware node as of yet). Have submitted a branch [5][6][7] with these patches on top of friday's linux-next (20150925) to kernelci.org and I don't see any issues that could be caused by them. With this series I get the kernel to output to the panel in 0.5s, instead of 2.8s. Regards, Tomeu [0] http://lists.freedesktop.org/archives/dri-devel/2014-August/066527.html [1] https://lkml.org/lkml/2014/5/12/452 [2] https://lkml.org/lkml/2015/6/17/305 [3] http://article.gmane.org/gmane.linux.ports.arm.kernel/277689 [4] https://lkml.org/lkml/2015/7/21/441a [5] https://git.collabora.com/cgit/user/tomeu/linux.git/log/?h=on-demand-probes-v9 [6] http://kernelci.org/boot/all/job/collabora/kernel/v4.3-rc2-3497-g96d8df1bbcc1/ [7] http://kernelci.org/boot/all/job/next/kernel/next-20150925 Changes in v7: - Move IS_ENABLED(CONFIG_DELAY_DEVICE_PROBES) into if condition - Hide CONFIG_DELAY_DEVICE_PROBES behind EXPERT - Removed patch that moved deferred probe processing to device_initcall_sync, as it's not currently needed and can be applied later if we find any boards that fail to boot without this change. Changes in v6: - Drop bus_type.pre_probe and read the periphid in match() instead as suggested by Alan Stern. Changes in v5: - Set the pointer to struct device also for AMBA devices - Unset the pointer to struct device when the platform device is about to be unregistered - Increase the reference count of the device before returning from of_find_device_by_node() - Move the assignment to device_node->device for AMBA devices to another commit. - Hold a reference to the struct device while it's in use in of_device_probe(). Changes in v4: - Added bus.pre_probe callback so the probes of Primecell devices can be deferred if their device IDs cannot be yet read because of the clock driver not having probed when they are registered. Maybe this goes overboard and the matching information should be in the DT if there is one. - Rename of_platform_probe to of_device_probe - Use device_node.device instead of device_node.platform_dev - Add Kconfig DELAY_DEVICE_PROBES to allow disabling delayed probing in machines with initcalls that depend on devices probing at a given time. - Also defer probes of AMBA devices registered from the DT as they can also request resources. Changes in v3: - Set and use device_node.platform_dev instead of reversing the logic to find the platform device that encloses a device node. - Drop the fwnode API to probe firmware nodes and add OF-only API for now. I think this same scheme could be used for machines with ACPI, but I haven't been able to find one that had to defer its probes because of the device probe order. Tomeu Vizoso (20): driver core: handle -EPROBE_DEFER from bus_type.match() ARM: amba: Move reading of periphid to amba_match() of/platform: Point to struct device from device node of: add function to allow probing a device from a OF node gpio: Probe GPIO drivers on demand pinctrl: Probe pinctrl devices on demand regulator: core: Probe regulators on demand drm: Probe panels on demand drm/tegra: Probe dpaux devices on demand i2c: core: Probe i2c adapters and devices on demand pwm: Probe PWM chip devices on demand backlight: Probe backlight devices on demand usb: phy: Probe phy devices on demand clk: Probe clk providers on demand pinctrl: Probe pinctrl devices on demand phy: core: Probe phy providers on demand dma: of: Probe DMA controllers on demand power-supply: Probe power supplies on demand driver core: Allow deferring probes until late init of/platform: Defer probes of registered devices drivers/amba/bus.c | 88 +++++++++++++++++++------------------ drivers/base/Kconfig | 18 ++++++++ drivers/base/dd.c | 30 ++++++++++++- drivers/clk/clk.c | 3 ++ drivers/dma/of-dma.c | 3 ++ drivers/gpio/gpiolib-of.c | 5 +++ drivers/gpu/drm/drm_panel.c | 3 ++ drivers/gpu/drm/tegra/dpaux.c | 3 ++ drivers/i2c/i2c-core.c | 4 ++ drivers/of/device.c | 61 +++++++++++++++++++++++++ drivers/of/platform.c | 30 ++++++++----- drivers/phy/phy-core.c | 3 ++ drivers/pinctrl/devicetree.c | 3 ++ drivers/power/power_supply_core.c | 3 ++ drivers/pwm/core.c | 3 ++ drivers/regulator/core.c | 2 + drivers/usb/phy/phy.c | 3 ++ drivers/video/backlight/backlight.c | 3 ++ include/linux/device.h | 4 +- include/linux/of.h | 1 + include/linux/of_device.h | 3 ++ 21 files changed, 219 insertions(+), 57 deletions(-) -- 2.4.3 -- 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]
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Date | 2015-09-29 11:20 +0200 |
| Subject | [PATCH v7 20/20] of/platform: Defer probes of registered devices |
| Message-ID | <qdZeO-2b3-27@gated-at.bofh.it> |
| In reply to | #1234892 |
Instead of trying to match and probe platform and AMBA devices right
after each is registered, delay their probes until device_initcall_sync.
This means that devices will start probing once all built-in drivers
have registered, and after all platform and AMBA devices from the DT
have been registered already.
This allows us to prevent deferred probes by probing dependencies on
demand.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
Changes in v7:
- Removed patch that moved deferred probe processing to
device_initcall_sync, as it's not currently needed and can be applied
later if we find any boards that fail to boot without this change.
Changes in v4:
- Also defer probes of AMBA devices registered from the DT as they can
also request resources.
drivers/of/platform.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 408d89f1d124..7b33e0369374 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -164,7 +164,8 @@ static struct platform_device *of_platform_device_create_pdata(
struct device_node *np,
const char *bus_id,
void *platform_data,
- struct device *parent)
+ struct device *parent,
+ bool probe_late)
{
struct platform_device *dev;
@@ -178,6 +179,7 @@ static struct platform_device *of_platform_device_create_pdata(
dev->dev.bus = &platform_bus_type;
dev->dev.platform_data = platform_data;
+ dev->dev.probe_late = probe_late;
of_dma_configure(&dev->dev, dev->dev.of_node);
of_msi_configure(&dev->dev, dev->dev.of_node);
@@ -209,7 +211,8 @@ struct platform_device *of_platform_device_create(struct device_node *np,
const char *bus_id,
struct device *parent)
{
- return of_platform_device_create_pdata(np, bus_id, NULL, parent);
+ return of_platform_device_create_pdata(np, bus_id, NULL, parent,
+ false);
}
EXPORT_SYMBOL(of_platform_device_create);
@@ -240,6 +243,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
dev->dev.of_node = of_node_get(node);
dev->dev.parent = parent ? : &platform_bus;
dev->dev.platform_data = platform_data;
+ dev->dev.probe_late = true;
if (bus_id)
dev_set_name(&dev->dev, "%s", bus_id);
else
@@ -358,7 +362,8 @@ static int of_platform_bus_create(struct device_node *bus,
return 0;
}
- dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent);
+ dev = of_platform_device_create_pdata(bus, bus_id, platform_data,
+ parent, true);
if (!dev || !of_match_node(matches, bus))
return 0;
--
2.4.3
--
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] | [next] | [standalone]
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Date | 2015-09-29 11:20 +0200 |
| Subject | [PATCH v7 13/20] usb: phy: Probe phy devices on demand |
| Message-ID | <qdZeP-2b3-35@gated-at.bofh.it> |
| In reply to | #1234892 |
When looking up a phy through its OF node, probe it if it hasn't already. The goal is to reduce deferred probes to a minimum, as it makes it very cumbersome to find out why a device failed to probe, and can introduce very big delays in when a critical device is probed. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> --- drivers/usb/phy/phy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c index 98f75d2842b7..fb0b650bb494 100644 --- a/drivers/usb/phy/phy.c +++ b/drivers/usb/phy/phy.c @@ -15,6 +15,7 @@ #include <linux/module.h> #include <linux/slab.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/usb/phy.h> @@ -196,6 +197,8 @@ struct usb_phy *devm_usb_get_phy_by_node(struct device *dev, goto err0; } + of_device_probe(node); + spin_lock_irqsave(&phy_lock, flags); phy = __of_usb_find_phy(node); -- 2.4.3 -- 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] | [next] | [standalone]
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Date | 2015-09-29 11:20 +0200 |
| Subject | [PATCH v7 09/20] drm/tegra: Probe dpaux devices on demand |
| Message-ID | <qdZeP-2b3-39@gated-at.bofh.it> |
| In reply to | #1234892 |
When looking up a dpaux device through its OF node, probe it if it
hasn't already.
The goal is to reduce deferred probes to a minimum, as it makes it very
cumbersome to find out why a device failed to probe, and can introduce
very big delays in when a critical device is probed.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/gpu/drm/tegra/dpaux.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c
index 224a7dc8e4ed..96a2eec7e020 100644
--- a/drivers/gpu/drm/tegra/dpaux.c
+++ b/drivers/gpu/drm/tegra/dpaux.c
@@ -12,6 +12,7 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/of_gpio.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
#include <linux/regulator/consumer.h>
@@ -439,6 +440,8 @@ struct tegra_dpaux *tegra_dpaux_find_by_of_node(struct device_node *np)
{
struct tegra_dpaux *dpaux;
+ of_device_probe(np);
+
mutex_lock(&dpaux_lock);
list_for_each_entry(dpaux, &dpaux_list, list)
--
2.4.3
--
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] | [next] | [standalone]
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Date | 2015-09-29 11:20 +0200 |
| Subject | [PATCH v7 15/20] pinctrl: Probe pinctrl devices on demand |
| Message-ID | <qdZeO-2b3-31@gated-at.bofh.it> |
| In reply to | #1234892 |
When looking up a pin controller through its OF node, probe it if it
hasn't already.
The goal is to reduce deferred probes to a minimum, as it makes it very
cumbersome to find out why a device failed to probe, and can introduce
very big delays in when a critical device is probed.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/pinctrl/devicetree.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
index fe04e748dfe4..f5340b8e1dbe 100644
--- a/drivers/pinctrl/devicetree.c
+++ b/drivers/pinctrl/devicetree.c
@@ -18,6 +18,7 @@
#include <linux/device.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/slab.h>
@@ -110,6 +111,8 @@ static int dt_to_map_one_config(struct pinctrl *p, const char *statename,
struct pinctrl_map *map;
unsigned num_maps;
+ of_device_probe(np_config);
+
/* Find the pin controller containing np_config */
np_pctldev = of_node_get(np_config);
for (;;) {
--
2.4.3
--
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] | [next] | [standalone]
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Date | 2015-09-29 11:20 +0200 |
| Subject | [PATCH v7 06/20] pinctrl: Probe pinctrl devices on demand |
| Message-ID | <qdZeP-2b3-37@gated-at.bofh.it> |
| In reply to | #1234892 |
When looking up a pin controller through its OF node, probe it if it hasn't already. The goal is to reduce deferred probes to a minimum, as it makes it very cumbersome to find out why a device failed to probe, and can introduce very big delays in when a critical device is probed. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> --- drivers/gpio/gpiolib-of.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 9a439dab7a87..05da9a56608d 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -359,6 +359,8 @@ static int of_gpiochip_add_pin_range(struct gpio_chip *chip) if (ret) break; + of_device_probe(pinspec.np); + pctldev = of_pinctrl_get(pinspec.np); if (!pctldev) return -EPROBE_DEFER; -- 2.4.3 -- 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] | [next] | [standalone]
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Date | 2015-09-29 11:20 +0200 |
| Subject | [PATCH v7 03/20] of/platform: Point to struct device from device node |
| Message-ID | <qdZeP-2b3-41@gated-at.bofh.it> |
| In reply to | #1234892 |
When adding platform and AMBA devices, set the device node's device
member to point to it.
This speeds lookups considerably and is safe because we only create one
of these devices for any given device node.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
Changes in v5:
- Set the pointer to struct device also for AMBA devices
- Unset the pointer to struct device when the platform device is about
to be unregistered
- Increase the reference count of the device before returning from
of_find_device_by_node()
drivers/of/platform.c | 19 ++++++++++---------
include/linux/of.h | 1 +
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 1001efaedcb8..408d89f1d124 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -32,11 +32,6 @@ const struct of_device_id of_default_bus_match_table[] = {
{} /* Empty terminated list */
};
-static int of_dev_node_match(struct device *dev, void *data)
-{
- return dev->of_node == data;
-}
-
/**
* of_find_device_by_node - Find the platform_device associated with a node
* @np: Pointer to device tree node
@@ -45,10 +40,10 @@ static int of_dev_node_match(struct device *dev, void *data)
*/
struct platform_device *of_find_device_by_node(struct device_node *np)
{
- struct device *dev;
-
- dev = bus_find_device(&platform_bus_type, NULL, np, of_dev_node_match);
- return dev ? to_platform_device(dev) : NULL;
+ if (np->device && np->device->bus == &platform_bus_type &&
+ get_device(np->device))
+ return to_platform_device(np->device);
+ return NULL;
}
EXPORT_SYMBOL(of_find_device_by_node);
@@ -192,6 +187,8 @@ static struct platform_device *of_platform_device_create_pdata(
goto err_clear_flag;
}
+ np->device = &dev->dev;
+
return dev;
err_clear_flag:
@@ -272,6 +269,8 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
goto err_free;
}
+ node->device = &dev->dev;
+
return dev;
err_free:
@@ -476,6 +475,8 @@ static int of_platform_device_destroy(struct device *dev, void *data)
if (of_node_check_flag(dev->of_node, OF_POPULATED_BUS))
device_for_each_child(dev, NULL, of_platform_device_destroy);
+ dev->of_node->device = NULL;
+
if (dev->bus == &platform_bus_type)
platform_device_unregister(to_platform_device(dev));
#ifdef CONFIG_ARM_AMBA
diff --git a/include/linux/of.h b/include/linux/of.h
index 2194b8ca41f9..eb091be0f8ee 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -52,6 +52,7 @@ struct device_node {
phandle phandle;
const char *full_name;
struct fwnode_handle fwnode;
+ struct device *device;
struct property *properties;
struct property *deadprops; /* removed properties */
--
2.4.3
--
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] | [next] | [standalone]
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Date | 2015-09-29 11:20 +0200 |
| Subject | [PATCH v7 10/20] i2c: core: Probe i2c adapters and devices on demand |
| Message-ID | <qdZeQ-2b3-43@gated-at.bofh.it> |
| In reply to | #1234892 |
When looking up an i2c adapter or device through its OF node, probe it if it hasn't already. The goal is to reduce deferred probes to a minimum, as it makes it very cumbersome to find out why a device failed to probe, and can introduce very big delays in when a critical device is probed. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> --- drivers/i2c/i2c-core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 5f89f1e3c2f2..02da3acbbd35 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1413,6 +1413,8 @@ struct i2c_client *of_find_i2c_device_by_node(struct device_node *node) struct device *dev; struct i2c_client *client; + of_device_probe(node); + dev = bus_find_device(&i2c_bus_type, NULL, node, of_dev_node_match); if (!dev) return NULL; @@ -1431,6 +1433,8 @@ struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node) struct device *dev; struct i2c_adapter *adapter; + of_device_probe(node); + dev = bus_find_device(&i2c_bus_type, NULL, node, of_dev_node_match); if (!dev) return NULL; -- 2.4.3 -- 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] | [next] | [standalone]
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Date | 2015-09-29 11:20 +0200 |
| Subject | [PATCH v7 17/20] dma: of: Probe DMA controllers on demand |
| Message-ID | <qdZeQ-2b3-49@gated-at.bofh.it> |
| In reply to | #1234892 |
When looking up a DMA controller through its OF node, probe it if it hasn't already. The goal is to reduce deferred probes to a minimum, as it makes it very cumbersome to find out why a device failed to probe, and can introduce very big delays in when a critical device is probed. Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> --- drivers/dma/of-dma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c index 1e1f2986eba8..e899832f7df3 100644 --- a/drivers/dma/of-dma.c +++ b/drivers/dma/of-dma.c @@ -16,6 +16,7 @@ #include <linux/mutex.h> #include <linux/slab.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/of_dma.h> static LIST_HEAD(of_dma_list); @@ -263,6 +264,8 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np, if (of_dma_match_channel(np, name, i, &dma_spec)) continue; + of_device_probe(dma_spec.np); + mutex_lock(&of_dma_lock); ofdma = of_dma_find_controller(&dma_spec); -- 2.4.3 -- 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] | [next] | [standalone]
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Date | 2015-09-29 11:20 +0200 |
| Subject | [PATCH v7 11/20] pwm: Probe PWM chip devices on demand |
| Message-ID | <qdZeQ-2b3-47@gated-at.bofh.it> |
| In reply to | #1234892 |
When looking up a PWM chip through its OF node, probe it if it hasn't
already.
The goal is to reduce deferred probes to a minimum, as it makes it very
cumbersome to find out why a device failed to probe, and can introduce
very big delays in when a critical device is probed.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/pwm/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 3f9df3ea3350..794a923df0d8 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -29,6 +29,7 @@
#include <linux/device.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
+#include <linux/of_device.h>
#include <dt-bindings/pwm/pwm.h>
@@ -516,6 +517,8 @@ static struct pwm_chip *of_node_to_pwmchip(struct device_node *np)
{
struct pwm_chip *chip;
+ of_device_probe(np);
+
mutex_lock(&pwm_lock);
list_for_each_entry(chip, &pwm_chips, list)
--
2.4.3
--
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] | [next] | [standalone]
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Date | 2015-09-29 11:20 +0200 |
| Subject | [PATCH v7 07/20] regulator: core: Probe regulators on demand |
| Message-ID | <qdZeQ-2b3-53@gated-at.bofh.it> |
| In reply to | #1234892 |
When looking up a regulator through its OF node, probe it if it hasn't
already.
The goal is to reduce deferred probes to a minimum, as it makes it very
cumbersome to find out why a device failed to probe, and can introduce
very big delays in when a critical device is probed.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Acked-by: Mark Brown <broonie@kernel.org>
---
drivers/regulator/core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 7a85ac9e32c5..ee75199c2cfa 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -26,6 +26,7 @@
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/regmap.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/consumer.h>
@@ -1340,6 +1341,7 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
if (dev && dev->of_node) {
node = of_get_regulator(dev, supply);
if (node) {
+ of_device_probe(node);
list_for_each_entry(r, ®ulator_list, list)
if (r->dev.parent &&
node == r->dev.of_node)
--
2.4.3
--
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] | [next] | [standalone]
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Date | 2015-09-29 11:20 +0200 |
| Subject | [PATCH v7 12/20] backlight: Probe backlight devices on demand |
| Message-ID | <qdZeQ-2b3-51@gated-at.bofh.it> |
| In reply to | #1234892 |
When looking up a backlight device through its OF node, probe it if it
hasn't already.
The goal is to reduce deferred probes to a minimum, as it makes it very
cumbersome to find out why a device failed to probe, and can introduce
very big delays in when a critical device is probed.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
drivers/video/backlight/backlight.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index bddc8b17a4d8..9bcdc16eacdf 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -16,6 +16,7 @@
#include <linux/err.h>
#include <linux/fb.h>
#include <linux/slab.h>
+#include <linux/of_device.h>
#ifdef CONFIG_PMAC_BACKLIGHT
#include <asm/backlight.h>
@@ -559,6 +560,8 @@ struct backlight_device *of_find_backlight_by_node(struct device_node *node)
{
struct device *dev;
+ of_device_probe(node);
+
dev = class_find_device(backlight_class, NULL, node, of_parent_match);
return dev ? to_backlight_device(dev) : NULL;
--
2.4.3
--
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] | [next] | [standalone]
| From | Tomeu Vizoso <tomeu.vizoso@collabora.com> |
|---|---|
| Date | 2015-09-29 11:20 +0200 |
| Subject | [PATCH v7 04/20] of: add function to allow probing a device from a OF node |
| Message-ID | <qdZeQ-2b3-57@gated-at.bofh.it> |
| In reply to | #1234892 |
Walks the OF tree up and finds the closest ancestor that has a struct
device associated with it, probing it if isn't bound to a driver yet.
The above should ensure that the dependency represented by the passed OF
node is available, because probing a device should cause its descendants
to be probed as well (when they get registered).
Subsystems can use this when looking up resources for drivers, to reduce
the chances of deferred probes because of the probing order of devices.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---
Changes in v5:
- Move the assignment to device_node->device for AMBA devices to another
commit.
- Hold a reference to the struct device while it's in use in
of_device_probe().
Changes in v4:
- Rename of_platform_probe to of_device_probe
- Use device_node.device instead of device_node.platform_dev
Changes in v3:
- Set and use device_node.platform_dev instead of reversing the logic to
find the platform device that encloses a device node.
- Drop the fwnode API to probe firmware nodes and add OF-only API for
now. I think this same scheme could be used for machines with ACPI,
but I haven't been able to find one that had to defer its probes because
of the device probe order.
drivers/of/device.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++
include/linux/of_device.h | 3 +++
2 files changed, 64 insertions(+)
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 8b91ea241b10..836be71fc90e 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -286,3 +286,64 @@ int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
return 0;
}
+
+/**
+ * of_device_probe() - Probe device associated with OF node
+ * @np: node to probe
+ *
+ * Probe the device associated with the passed device node.
+ */
+void of_device_probe(struct device_node *np)
+{
+ struct device_node *target;
+ struct device *dev = NULL;
+
+ if (!of_root || !of_node_check_flag(of_root, OF_POPULATED_BUS))
+ return;
+
+ if (!np)
+ return;
+
+ of_node_get(np);
+
+ /* Find the closest ancestor that has a device associated */
+ for (target = np;
+ !of_node_is_root(target);
+ target = of_get_next_parent(target))
+ if (get_device(target->device)) {
+ dev = target->device;
+ break;
+ }
+
+ of_node_put(target);
+
+ if (!dev) {
+ pr_warn("Couldn't find a device for node '%s'\n",
+ of_node_full_name(np));
+ return;
+ }
+
+ /*
+ * Device is bound or is being probed right now. If we have bad luck
+ * and the dependency isn't ready when it's needed, deferred probe
+ * will save us.
+ */
+ if (dev->driver)
+ goto out;
+
+ /*
+ * Probing a device should cause its descendants to be probed as
+ * well, which includes the passed device node.
+ */
+ if (device_attach(dev) != 1)
+ /*
+ * This cannot be a warning for now because clock nodes have a
+ * compatible string but the clock framework doesn't follow
+ * the device/driver model yet.
+ */
+ dev_dbg(dev, "Probe failed for %s\n", of_node_full_name(np));
+
+out:
+ put_device(dev);
+}
+EXPORT_SYMBOL_GPL(of_device_probe);
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index cc7dd687a89d..da8d489e73ad 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -40,6 +40,7 @@ extern ssize_t of_device_get_modalias(struct device *dev,
extern void of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
extern int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env);
+extern void of_device_probe(struct device_node *np);
static inline void of_device_node_put(struct device *dev)
{
@@ -84,6 +85,8 @@ static inline int of_device_uevent_modalias(struct device *dev,
return -ENODEV;
}
+static inline void of_device_probe(struct device_node *np) { }
+
static inline void of_device_node_put(struct device *dev) { }
static inline const struct of_device_id *__of_match_device(
--
2.4.3
--
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