2022-08-19 22:36:05

by Saravana Kannan

[permalink] [raw]
Subject: [PATCH v2 0/4] Bring back driver_deferred_probe_check_state() for now

A bunch of issues have been reported in the original series[1] that removed
driver_deferred_probe_check_state(). While most of the issues have been
fixed in a new series that improved fw_devlink [2], there are still a few
unresolved issues I need to address.

So let's bring back driver_deferred_probe_check_state() until the other
issues are resolved.

Greg,

Can we get this into 6.0-rcX please?

-Saravana

[1] - https://lore.kernel.org/lkml/[email protected]/
[2] - https://lore.kernel.org/lkml/[email protected]/

v1 -> v2:
- Added a revert of the iommu change too.

Saravana Kannan (4):
Revert "driver core: Delete driver_deferred_probe_check_state()"
Revert "net: mdio: Delete usage of
driver_deferred_probe_check_state()"
Revert "PM: domains: Delete usage of
driver_deferred_probe_check_state()"
Revert "iommu/of: Delete usage of driver_deferred_probe_check_state()"

drivers/base/dd.c | 30 ++++++++++++++++++++++++++++++
drivers/base/power/domain.c | 2 +-
drivers/iommu/of_iommu.c | 2 +-
drivers/net/mdio/fwnode_mdio.c | 4 +++-
include/linux/device/driver.h | 1 +
5 files changed, 36 insertions(+), 3 deletions(-)

--
2.37.1.595.g718a3a8f04-goog


2022-08-19 22:40:33

by Saravana Kannan

[permalink] [raw]
Subject: [PATCH v2 2/4] Revert "net: mdio: Delete usage of driver_deferred_probe_check_state()"

This reverts commit f8217275b57aa48d98cc42051c2aac34152718d6.

There are a few more issues to fix that have been reported in the thread
for the original series [1]. We'll need to fix those before this will work.
So, revert it for now.

[1] - https://lore.kernel.org/lkml/CAMuHMdWo_wRwV-i_iyTxVnEsf3Th9GBAG+wxUQMQGnw1t2ijTg@mail.gmail.com/

Fixes: f8217275b57a ("net: mdio: Delete usage of driver_deferred_probe_check_state()")
Reviewed-by: Tony Lindgren <[email protected]>
Reported-by: Geert Uytterhoeven <[email protected]>
Signed-off-by: Saravana Kannan <[email protected]>
---
drivers/net/mdio/fwnode_mdio.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
index 3e79c2c51929..1c1584fca632 100644
--- a/drivers/net/mdio/fwnode_mdio.c
+++ b/drivers/net/mdio/fwnode_mdio.c
@@ -47,7 +47,9 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
* just fall back to poll mode
*/
if (rc == -EPROBE_DEFER)
- rc = -ENODEV;
+ rc = driver_deferred_probe_check_state(&phy->mdio.dev);
+ if (rc == -EPROBE_DEFER)
+ return rc;

if (rc > 0) {
phy->irq = rc;
--
2.37.1.595.g718a3a8f04-goog

2022-08-19 22:57:36

by Saravana Kannan

[permalink] [raw]
Subject: [PATCH v2 1/4] Revert "driver core: Delete driver_deferred_probe_check_state()"

This reverts commit 9cbffc7a59561be950ecc675d19a3d2b45202b2b.

There are a few more issues to fix that have been reported in the thread
for the original series [1]. We'll need to fix those before this will work.
So, revert it for now.

[1] - https://lore.kernel.org/lkml/[email protected]/

Fixes: 9cbffc7a5956 ("driver core: Delete driver_deferred_probe_check_state()")
Reviewed-by: Tony Lindgren <[email protected]>
Tested-by: Tony Lindgren <[email protected]>
Signed-off-by: Saravana Kannan <[email protected]>
---
drivers/base/dd.c | 30 ++++++++++++++++++++++++++++++
include/linux/device/driver.h | 1 +
2 files changed, 31 insertions(+)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 70f79fc71539..a8916d1bfdcb 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -274,12 +274,42 @@ static int __init deferred_probe_timeout_setup(char *str)
}
__setup("deferred_probe_timeout=", deferred_probe_timeout_setup);

+/**
+ * driver_deferred_probe_check_state() - Check deferred probe state
+ * @dev: device to check
+ *
+ * Return:
+ * * -ENODEV if initcalls have completed and modules are disabled.
+ * * -ETIMEDOUT if the deferred probe timeout was set and has expired
+ * and modules are enabled.
+ * * -EPROBE_DEFER in other cases.
+ *
+ * Drivers or subsystems can opt-in to calling this function instead of directly
+ * returning -EPROBE_DEFER.
+ */
+int driver_deferred_probe_check_state(struct device *dev)
+{
+ if (!IS_ENABLED(CONFIG_MODULES) && initcalls_done) {
+ dev_warn(dev, "ignoring dependency for device, assuming no driver\n");
+ return -ENODEV;
+ }
+
+ if (!driver_deferred_probe_timeout && initcalls_done) {
+ dev_warn(dev, "deferred probe timeout, ignoring dependency\n");
+ return -ETIMEDOUT;
+ }
+
+ return -EPROBE_DEFER;
+}
+EXPORT_SYMBOL_GPL(driver_deferred_probe_check_state);
+
static void deferred_probe_timeout_work_func(struct work_struct *work)
{
struct device_private *p;

fw_devlink_drivers_done();

+ driver_deferred_probe_timeout = 0;
driver_deferred_probe_trigger();
flush_work(&deferred_probe_work);

diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h
index 7acaabde5396..2114d65b862f 100644
--- a/include/linux/device/driver.h
+++ b/include/linux/device/driver.h
@@ -242,6 +242,7 @@ driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev)

extern int driver_deferred_probe_timeout;
void driver_deferred_probe_add(struct device *dev);
+int driver_deferred_probe_check_state(struct device *dev);
void driver_init(void);

/**
--
2.37.1.595.g718a3a8f04-goog

2022-08-19 23:14:16

by Saravana Kannan

[permalink] [raw]
Subject: [PATCH v2 3/4] Revert "PM: domains: Delete usage of driver_deferred_probe_check_state()"

This reverts commit 5a46079a96451cfb15e4f5f01f73f7ba24ef851a.

Quite a few issues have been reported [1][2][3][4][5][6] on the original
commit. While about half of them have been fixed, I'll need to fix the rest
before driver_deferred_probe_check_state() can be deleted. So, revert the
deletion for now.

[1] - https://lore.kernel.org/all/DU0PR04MB941735271F45C716342D0410886B9@DU0PR04MB9417.eurprd04.prod.outlook.com/
[2] - https://lore.kernel.org/all/CM6REZS9Z8AC.2KCR9N3EFLNQR@otso/
[3] - https://lore.kernel.org/all/CAD=FV=XYVwaXZxqUKAuM5c7NiVjFz5C6m6gAHSJ7rBXBF94_Tg@mail.gmail.com/
[4] - https://lore.kernel.org/all/Yvpd2pwUJGp7R+YE@euler/
[5] - https://lore.kernel.org/lkml/[email protected]/
[6] - https://lore.kernel.org/all/CA+G9fYt_cc5SiNv1Vbse=HYY_+uc+9OYPZuJ-x59bROSaLN6fw@mail.gmail.com/

Fixes: 5a46079a9645 ("PM: domains: Delete usage of driver_deferred_probe_check_state()")
Reported-by: Peng Fan <[email protected]>
Reported-by: Luca Weiss <[email protected]>
Reported-by: Doug Anderson <[email protected]>
Reported-by: Colin Foster <[email protected]>
Reported-by: Tony Lindgren <[email protected]>
Reported-by: Alexander Stein <[email protected]>
Reported-by: Naresh Kamboju <[email protected]>
Reviewed-by: Tony Lindgren <[email protected]>
Tested-by: Tony Lindgren <[email protected]>
Signed-off-by: Saravana Kannan <[email protected]>
---
drivers/base/power/domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 5a2e0232862e..55a10e6d4e2a 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -2733,7 +2733,7 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
mutex_unlock(&gpd_list_lock);
dev_dbg(dev, "%s() failed to find PM domain: %ld\n",
__func__, PTR_ERR(pd));
- return -ENODEV;
+ return driver_deferred_probe_check_state(base_dev);
}

dev_dbg(dev, "adding to PM domain %s\n", pd->name);
--
2.37.1.595.g718a3a8f04-goog

2022-08-22 07:28:11

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH v2 0/4] Bring back driver_deferred_probe_check_state() for now

* Saravana Kannan <[email protected]> [220819 22:09]:
> A bunch of issues have been reported in the original series[1] that removed
> driver_deferred_probe_check_state(). While most of the issues have been
> fixed in a new series that improved fw_devlink [2], there are still a few
> unresolved issues I need to address.
>
> So let's bring back driver_deferred_probe_check_state() until the other
> issues are resolved.
>
> Greg,
>
> Can we get this into 6.0-rcX please?

Yes please.

I just tested these against v6.0-rc2 and it fixes the deferred probe boot
issues I've been seeing. The patches already have my Tested-by for the
relevant patches, so as far as I'm concerned these are good to go.

Thanks,

Tony

2022-08-22 11:59:15

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH v2 3/4] Revert "PM: domains: Delete usage of driver_deferred_probe_check_state()"

On Sat, 20 Aug 2022 at 00:16, Saravana Kannan <[email protected]> wrote:
>
> This reverts commit 5a46079a96451cfb15e4f5f01f73f7ba24ef851a.
>
> Quite a few issues have been reported [1][2][3][4][5][6] on the original
> commit. While about half of them have been fixed, I'll need to fix the rest
> before driver_deferred_probe_check_state() can be deleted. So, revert the
> deletion for now.
>
> [1] - https://lore.kernel.org/all/DU0PR04MB941735271F45C716342D0410886B9@DU0PR04MB9417.eurprd04.prod.outlook.com/
> [2] - https://lore.kernel.org/all/CM6REZS9Z8AC.2KCR9N3EFLNQR@otso/
> [3] - https://lore.kernel.org/all/CAD=FV=XYVwaXZxqUKAuM5c7NiVjFz5C6m6gAHSJ7rBXBF94_Tg@mail.gmail.com/
> [4] - https://lore.kernel.org/all/Yvpd2pwUJGp7R+YE@euler/
> [5] - https://lore.kernel.org/lkml/[email protected]/
> [6] - https://lore.kernel.org/all/CA+G9fYt_cc5SiNv1Vbse=HYY_+uc+9OYPZuJ-x59bROSaLN6fw@mail.gmail.com/
>
> Fixes: 5a46079a9645 ("PM: domains: Delete usage of driver_deferred_probe_check_state()")
> Reported-by: Peng Fan <[email protected]>
> Reported-by: Luca Weiss <[email protected]>
> Reported-by: Doug Anderson <[email protected]>
> Reported-by: Colin Foster <[email protected]>
> Reported-by: Tony Lindgren <[email protected]>
> Reported-by: Alexander Stein <[email protected]>
> Reported-by: Naresh Kamboju <[email protected]>
> Reviewed-by: Tony Lindgren <[email protected]>
> Tested-by: Tony Lindgren <[email protected]>
> Signed-off-by: Saravana Kannan <[email protected]>

Acked-by: Ulf Hansson <[email protected]>

Kind regards
Uffe

> ---
> drivers/base/power/domain.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 5a2e0232862e..55a10e6d4e2a 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -2733,7 +2733,7 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
> mutex_unlock(&gpd_list_lock);
> dev_dbg(dev, "%s() failed to find PM domain: %ld\n",
> __func__, PTR_ERR(pd));
> - return -ENODEV;
> + return driver_deferred_probe_check_state(base_dev);
> }
>
> dev_dbg(dev, "adding to PM domain %s\n", pd->name);
> --
> 2.37.1.595.g718a3a8f04-goog
>

2022-08-22 20:37:19

by Doug Anderson

[permalink] [raw]
Subject: Re: [PATCH v2 3/4] Revert "PM: domains: Delete usage of driver_deferred_probe_check_state()"

Hi,

On Fri, Aug 19, 2022 at 3:16 PM Saravana Kannan <[email protected]> wrote:
>
> This reverts commit 5a46079a96451cfb15e4f5f01f73f7ba24ef851a.
>
> Quite a few issues have been reported [1][2][3][4][5][6] on the original
> commit. While about half of them have been fixed, I'll need to fix the rest
> before driver_deferred_probe_check_state() can be deleted. So, revert the
> deletion for now.
>
> [1] - https://lore.kernel.org/all/DU0PR04MB941735271F45C716342D0410886B9@DU0PR04MB9417.eurprd04.prod.outlook.com/
> [2] - https://lore.kernel.org/all/CM6REZS9Z8AC.2KCR9N3EFLNQR@otso/
> [3] - https://lore.kernel.org/all/CAD=FV=XYVwaXZxqUKAuM5c7NiVjFz5C6m6gAHSJ7rBXBF94_Tg@mail.gmail.com/
> [4] - https://lore.kernel.org/all/Yvpd2pwUJGp7R+YE@euler/
> [5] - https://lore.kernel.org/lkml/[email protected]/
> [6] - https://lore.kernel.org/all/CA+G9fYt_cc5SiNv1Vbse=HYY_+uc+9OYPZuJ-x59bROSaLN6fw@mail.gmail.com/
>
> Fixes: 5a46079a9645 ("PM: domains: Delete usage of driver_deferred_probe_check_state()")
> Reported-by: Peng Fan <[email protected]>
> Reported-by: Luca Weiss <[email protected]>
> Reported-by: Doug Anderson <[email protected]>
> Reported-by: Colin Foster <[email protected]>
> Reported-by: Tony Lindgren <[email protected]>
> Reported-by: Alexander Stein <[email protected]>
> Reported-by: Naresh Kamboju <[email protected]>
> Reviewed-by: Tony Lindgren <[email protected]>
> Tested-by: Tony Lindgren <[email protected]>
> Signed-off-by: Saravana Kannan <[email protected]>
> ---
> drivers/base/power/domain.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

Tested-by: Douglas Anderson <[email protected]>

2022-08-22 21:13:43

by Doug Anderson

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] Revert "driver core: Delete driver_deferred_probe_check_state()"

Hi,

On Fri, Aug 19, 2022 at 3:16 PM Saravana Kannan <[email protected]> wrote:
>
> This reverts commit 9cbffc7a59561be950ecc675d19a3d2b45202b2b.
>
> There are a few more issues to fix that have been reported in the thread
> for the original series [1]. We'll need to fix those before this will work.
> So, revert it for now.
>
> [1] - https://lore.kernel.org/lkml/[email protected]/
>
> Fixes: 9cbffc7a5956 ("driver core: Delete driver_deferred_probe_check_state()")
> Reviewed-by: Tony Lindgren <[email protected]>
> Tested-by: Tony Lindgren <[email protected]>
> Signed-off-by: Saravana Kannan <[email protected]>
> ---
> drivers/base/dd.c | 30 ++++++++++++++++++++++++++++++
> include/linux/device/driver.h | 1 +
> 2 files changed, 31 insertions(+)

Tested-by: Douglas Anderson <[email protected]>

2022-08-23 07:55:31

by Alexander Stein

[permalink] [raw]
Subject: Re: [PATCH v2 0/4] Bring back driver_deferred_probe_check_state() for now

Hello Saravana,

Am Samstag, 20. August 2022, 00:16:10 CEST schrieb Saravana Kannan:
> A bunch of issues have been reported in the original series[1] that removed
> driver_deferred_probe_check_state(). While most of the issues have been
> fixed in a new series that improved fw_devlink [2], there are still a few
> unresolved issues I need to address.
>
> So let's bring back driver_deferred_probe_check_state() until the other
> issues are resolved.
>
> Greg,
>
> Can we get this into 6.0-rcX please?

On my TQMa8MQ + MBa8Mxon top of 072e51356cd5 ("Merge tag 'nfs-for-5.20-2' of
git://git.linux-nfs.org/projects/trondmy/linux-nfs"):
Tested-by: Alexander Stein <[email protected]>

> [1] -
> https://lore.kernel.org/lkml/[email protected]/
> [2] -
> https://lore.kernel.org/lkml/[email protected]/
>
> v1 -> v2:
> - Added a revert of the iommu change too.
>
> Saravana Kannan (4):
> Revert "driver core: Delete driver_deferred_probe_check_state()"
> Revert "net: mdio: Delete usage of
> driver_deferred_probe_check_state()"
> Revert "PM: domains: Delete usage of
> driver_deferred_probe_check_state()"
> Revert "iommu/of: Delete usage of driver_deferred_probe_check_state()"
>
> drivers/base/dd.c | 30 ++++++++++++++++++++++++++++++
> drivers/base/power/domain.c | 2 +-
> drivers/iommu/of_iommu.c | 2 +-
> drivers/net/mdio/fwnode_mdio.c | 4 +++-
> include/linux/device/driver.h | 1 +
> 5 files changed, 36 insertions(+), 3 deletions(-)




2022-08-23 11:11:53

by Peng Fan

[permalink] [raw]
Subject: RE: [PATCH v2 3/4] Revert "PM: domains: Delete usage of driver_deferred_probe_check_state()"

> Subject: [PATCH v2 3/4] Revert "PM: domains: Delete usage of
> driver_deferred_probe_check_state()"
>
> This reverts commit 5a46079a96451cfb15e4f5f01f73f7ba24ef851a.
>
> Quite a few issues have been reported [1][2][3][4][5][6] on the original
> commit. While about half of them have been fixed, I'll need to fix the rest
> before driver_deferred_probe_check_state() can be deleted. So, revert the
> deletion for now.
>
> [1] -
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
> kernel.org%2Fall%2FDU0PR04MB941735271F45C716342D0410886B9%40DU
> 0PR04MB9417.eurprd04.prod.outlook.com%2F&amp;data=05%7C01%7Cpe
> ng.fan%40nxp.com%7Ce5c97577ea9c4d34e28008da8230773f%7C686ea1d3
> bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637965441917494552%7CUnkno
> wn%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1
> haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=py122mCaQjLc7
> xFhApk61Zh9Hthol6tmprh5KDsOXqU%3D&amp;reserved=0
> [2] -
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
> kernel.org%2Fall%2FCM6REZS9Z8AC.2KCR9N3EFLNQR%40otso%2F&amp;dat
> a=05%7C01%7Cpeng.fan%40nxp.com%7Ce5c97577ea9c4d34e28008da8230
> 773f%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637965441917
> 494552%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV
> 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdat
> a=DYZ3eCmUPryFcqhgtexUZT1gYuL1utBgHrw%2BIH6apdk%3D&amp;reserv
> ed=0
> [3] -
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
> kernel.org%2Fall%2FCAD%3DFV%3DXYVwaXZxqUKAuM5c7NiVjFz5C6m6gAH
> SJ7rBXBF94_Tg%40mail.gmail.com%2F&amp;data=05%7C01%7Cpeng.fan%4
> 0nxp.com%7Ce5c97577ea9c4d34e28008da8230773f%7C686ea1d3bc2b4c6fa
> 92cd99c5c301635%7C0%7C0%7C637965441917494552%7CUnknown%7CTW
> FpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJX
> VCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=MesNMmK2dr%2BkEZQ9fE
> BzFWgZhx9PWRQSk3U7zqcRaZo%3D&amp;reserved=0
> [4] -
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
> kernel.org%2Fall%2FYvpd2pwUJGp7R%2BYE%40euler%2F&amp;data=05%7
> C01%7Cpeng.fan%40nxp.com%7Ce5c97577ea9c4d34e28008da8230773f%7C
> 686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637965441917494552%
> 7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLC
> JBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=31VDc
> KodaAH9dOYDnN%2BcJ1LhhAbyEQc8fYX743f8MY8%3D&amp;reserved=0
> [5] -
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
> kernel.org%2Flkml%2F20220601070707.3946847-2-
> saravanak%40google.com%2F&amp;data=05%7C01%7Cpeng.fan%40nxp.co
> m%7Ce5c97577ea9c4d34e28008da8230773f%7C686ea1d3bc2b4c6fa92cd99
> c5c301635%7C0%7C0%7C637965441917494552%7CUnknown%7CTWFpbGZs
> b3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6M
> n0%3D%7C3000%7C%7C%7C&amp;sdata=eE20zTJ7rKVTY1b0%2F4Pgp8sOx7
> zVTLnSIFsG%2FepL9Lo%3D&amp;reserved=0
> [6] -
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
> kernel.org%2Fall%2FCA%2BG9fYt_cc5SiNv1Vbse%3DHYY_%2Buc%2B9OYPZu
> J-
> x59bROSaLN6fw%40mail.gmail.com%2F&amp;data=05%7C01%7Cpeng.fan%
> 40nxp.com%7Ce5c97577ea9c4d34e28008da8230773f%7C686ea1d3bc2b4c6f
> a92cd99c5c301635%7C0%7C0%7C637965441917494552%7CUnknown%7CT
> WFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiL
> CJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=nYfyk%2FlEwmYsH%2F
> U028t8tnFjpnTZ7G8ffHgyLBZ4Czo%3D&amp;reserved=0
>
> Fixes: 5a46079a9645 ("PM: domains: Delete usage of
> driver_deferred_probe_check_state()")
> Reported-by: Peng Fan <[email protected]>
> Reported-by: Luca Weiss <[email protected]>
> Reported-by: Doug Anderson <[email protected]>
> Reported-by: Colin Foster <[email protected]>
> Reported-by: Tony Lindgren <[email protected]>
> Reported-by: Alexander Stein <[email protected]>
> Reported-by: Naresh Kamboju <[email protected]>
> Reviewed-by: Tony Lindgren <[email protected]>
> Tested-by: Tony Lindgren <[email protected]>
> Signed-off-by: Saravana Kannan <[email protected]>

Tested-by: Peng Fan <[email protected]>
> ---
> drivers/base/power/domain.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 5a2e0232862e..55a10e6d4e2a 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -2733,7 +2733,7 @@ static int __genpd_dev_pm_attach(struct device
> *dev, struct device *base_dev,
> mutex_unlock(&gpd_list_lock);
> dev_dbg(dev, "%s() failed to find PM domain: %ld\n",
> __func__, PTR_ERR(pd));
> - return -ENODEV;
> + return driver_deferred_probe_check_state(base_dev);
> }
>
> dev_dbg(dev, "adding to PM domain %s\n", pd->name);
> --
> 2.37.1.595.g718a3a8f04-goog

2022-08-23 11:25:16

by Peng Fan

[permalink] [raw]
Subject: RE: [PATCH v2 1/4] Revert "driver core: Delete driver_deferred_probe_check_state()"

> Subject: [PATCH v2 1/4] Revert "driver core: Delete
> driver_deferred_probe_check_state()"
>
> This reverts commit 9cbffc7a59561be950ecc675d19a3d2b45202b2b.
>
> There are a few more issues to fix that have been reported in the thread for
> the original series [1]. We'll need to fix those before this will work.
> So, revert it for now.
>
> [1] -
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
> kernel.org%2Flkml%2F20220601070707.3946847-1-
> saravanak%40google.com%2F&amp;data=05%7C01%7Cpeng.fan%40nxp.co
> m%7Ce9205a2ec9c049d2a68408da82307410%7C686ea1d3bc2b4c6fa92cd99
> c5c301635%7C0%7C0%7C637965441862478527%7CUnknown%7CTWFpbGZs
> b3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6M
> n0%3D%7C3000%7C%7C%7C&amp;sdata=tGjnNEQ6BwaNrxug9ceThYOlj0a3
> Gmds8qpwNcHf%2FH8%3D&amp;reserved=0
>
> Fixes: 9cbffc7a5956 ("driver core: Delete
> driver_deferred_probe_check_state()")
> Reviewed-by: Tony Lindgren <[email protected]>
> Tested-by: Tony Lindgren <[email protected]>
> Signed-off-by: Saravana Kannan <[email protected]>

Tested-by: Peng Fan <[email protected]>
> ---
> drivers/base/dd.c | 30 ++++++++++++++++++++++++++++++
> include/linux/device/driver.h | 1 +
> 2 files changed, 31 insertions(+)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c index
> 70f79fc71539..a8916d1bfdcb 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -274,12 +274,42 @@ static int __init
> deferred_probe_timeout_setup(char *str) }
> __setup("deferred_probe_timeout=", deferred_probe_timeout_setup);
>
> +/**
> + * driver_deferred_probe_check_state() - Check deferred probe state
> + * @dev: device to check
> + *
> + * Return:
> + * * -ENODEV if initcalls have completed and modules are disabled.
> + * * -ETIMEDOUT if the deferred probe timeout was set and has expired
> + * and modules are enabled.
> + * * -EPROBE_DEFER in other cases.
> + *
> + * Drivers or subsystems can opt-in to calling this function instead of
> +directly
> + * returning -EPROBE_DEFER.
> + */
> +int driver_deferred_probe_check_state(struct device *dev) {
> + if (!IS_ENABLED(CONFIG_MODULES) && initcalls_done) {
> + dev_warn(dev, "ignoring dependency for device, assuming
> no driver\n");
> + return -ENODEV;
> + }
> +
> + if (!driver_deferred_probe_timeout && initcalls_done) {
> + dev_warn(dev, "deferred probe timeout, ignoring
> dependency\n");
> + return -ETIMEDOUT;
> + }
> +
> + return -EPROBE_DEFER;
> +}
> +EXPORT_SYMBOL_GPL(driver_deferred_probe_check_state);
> +
> static void deferred_probe_timeout_work_func(struct work_struct *work)
> {
> struct device_private *p;
>
> fw_devlink_drivers_done();
>
> + driver_deferred_probe_timeout = 0;
> driver_deferred_probe_trigger();
> flush_work(&deferred_probe_work);
>
> diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h
> index 7acaabde5396..2114d65b862f 100644
> --- a/include/linux/device/driver.h
> +++ b/include/linux/device/driver.h
> @@ -242,6 +242,7 @@ driver_find_device_by_acpi_dev(struct
> device_driver *drv, const void *adev)
>
> extern int driver_deferred_probe_timeout; void
> driver_deferred_probe_add(struct device *dev);
> +int driver_deferred_probe_check_state(struct device *dev);
> void driver_init(void);
>
> /**
> --
> 2.37.1.595.g718a3a8f04-goog

2022-08-25 07:39:54

by Martin Kepplinger

[permalink] [raw]
Subject: Re: [PATCH v2 3/4] Revert "PM: domains: Delete usage of driver_deferred_probe_check_state()"

Am Freitag, dem 19.08.2022 um 15:16 -0700 schrieb Saravana Kannan:
> This reverts commit 5a46079a96451cfb15e4f5f01f73f7ba24ef851a.
>
> Quite a few issues have been reported [1][2][3][4][5][6] on the
> original
> commit. While about half of them have been fixed, I'll need to fix
> the rest
> before driver_deferred_probe_check_state() can be deleted. So, revert
> the
> deletion for now.
>
> [1] -
> https://lore.kernel.org/all/DU0PR04MB941735271F45C716342D0410886B9@DU0PR04MB9417.eurprd04.prod.outlook.com/
> [2] - https://lore.kernel.org/all/CM6REZS9Z8AC.2KCR9N3EFLNQR@otso/
> [3] -
> https://lore.kernel.org/all/CAD=FV=XYVwaXZxqUKAuM5c7NiVjFz5C6m6gAHSJ7rBXBF94_Tg@mail.gmail.com/
> [4] - https://lore.kernel.org/all/Yvpd2pwUJGp7R+YE@euler/
> [5] -
> https://lore.kernel.org/lkml/[email protected]/
> [6] -
> https://lore.kernel.org/all/CA+G9fYt_cc5SiNv1Vbse=HYY_+uc+9OYPZuJ-x59bROSaLN6fw@mail.gmail.com/
>
> Fixes: 5a46079a9645 ("PM: domains: Delete usage of
> driver_deferred_probe_check_state()")
> Reported-by: Peng Fan <[email protected]>
> Reported-by: Luca Weiss <[email protected]>
> Reported-by: Doug Anderson <[email protected]>
> Reported-by: Colin Foster <[email protected]>
> Reported-by: Tony Lindgren <[email protected]>
> Reported-by: Alexander Stein <[email protected]>
> Reported-by: Naresh Kamboju <[email protected]>
> Reviewed-by: Tony Lindgren <[email protected]>
> Tested-by: Tony Lindgren <[email protected]>
> Signed-off-by: Saravana Kannan <[email protected]>
> ---
>  drivers/base/power/domain.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/power/domain.c
> b/drivers/base/power/domain.c
> index 5a2e0232862e..55a10e6d4e2a 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -2733,7 +2733,7 @@ static int __genpd_dev_pm_attach(struct device
> *dev, struct device *base_dev,
>                 mutex_unlock(&gpd_list_lock);
>                 dev_dbg(dev, "%s() failed to find PM domain: %ld\n",
>                         __func__, PTR_ERR(pd));
> -               return -ENODEV;
> +               return driver_deferred_probe_check_state(base_dev);
>         }
>  
>         dev_dbg(dev, "adding to PM domain %s\n", pd->name);

Fixes imx8mq where ENODEV results in:
[ 1.048019] imx8m-blk-ctrl 38320000.blk-ctrl: error -ENODEV: failed
to attach power domain "bus"


Tested-by: Martin Kepplinger <[email protected]>

thanks for fixing this,

martin