devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Fix ehci-fsl autoload regression on fsl-mph-dr-of
@ 2023-02-07 11:05 Alexander Stein
  2023-02-07 11:05 ` [PATCH 1/3] of: device: Ignore modalias of reused nodes Alexander Stein
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Alexander Stein @ 2023-02-07 11:05 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, Greg Kroah-Hartman, Alan Stern,
	Darren Stevens
  Cc: Alexander Stein, devicetree, linux-usb

Hi,

I noticed on my ls1021a based platform (TQMLS102xA) that the platform device
created by fsl-mph-dr-of does not autoload fsl-ehci. Digging into it I noticed
that starting from commit bb160ee61c04f ("drivers/usb/host/ehci-fsl: Fix
interrupt setup in host mode.") this platform device has the wrong modalias:

$ cat /sys/bus/platform/devices/8600000.usb/fsl-ehci.0/modalias 
of:NusbT(null)Cfsl-usb2-dr-v2.5Cfsl-usb2-dr

This is the modalias of the parent device, thus module ehci_fsl is not loaded
automatically. Given the reason of removing the IRQ resource from DT in
commit a1a2b7125e107 ("of/platform: Drop static setup of IRQ resource from DT
core") the of_node has to be assigned to the subnode, but for modalias the
reused of_node has to be ignored.

Patch 2 is not strictly required to fix autoloading, but this is still a bug fix.

Best regards,
Alexander

Alexander Stein (3):
  of: device: Ignore modalias of reused nodes
  of: device: Do not ignore error code in of_device_uevent_modalias
  usb: host: fsl-mph-dr-of: reuse device_set_of_node_from_dev

 drivers/of/device.c              | 6 ++++--
 drivers/usb/host/fsl-mph-dr-of.c | 3 +--
 2 files changed, 5 insertions(+), 4 deletions(-)

-- 
2.34.1


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

* [PATCH 1/3] of: device: Ignore modalias of reused nodes
  2023-02-07 11:05 [PATCH 0/3] Fix ehci-fsl autoload regression on fsl-mph-dr-of Alexander Stein
@ 2023-02-07 11:05 ` Alexander Stein
  2023-02-07 11:05 ` [PATCH 2/3] of: device: Do not ignore error code in of_device_uevent_modalias Alexander Stein
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Alexander Stein @ 2023-02-07 11:05 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, Greg Kroah-Hartman, Alan Stern,
	Darren Stevens
  Cc: Alexander Stein, devicetree, linux-usb

If of_node is reused, do not use that node's modalias. This will hide
the name of the actual device. This is rather prominent in USB glue
drivers creating a platform device for the host controller.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/of/device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/of/device.c b/drivers/of/device.c
index dda51b7ce5970..5b929351b65bf 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -256,7 +256,7 @@ static ssize_t of_device_get_modalias(const struct device *dev, char *str, ssize
 	ssize_t csize;
 	ssize_t tsize;
 
-	if ((!dev) || (!dev->of_node))
+	if ((!dev) || (!dev->of_node) || dev->of_node_reused)
 		return -ENODEV;
 
 	/* Name & Type */
@@ -376,7 +376,7 @@ int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *
 {
 	int sl;
 
-	if ((!dev) || (!dev->of_node))
+	if ((!dev) || (!dev->of_node) || dev->of_node_reused)
 		return -ENODEV;
 
 	/* Devicetree modalias is tricky, we add it in 2 steps */
-- 
2.34.1


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

* [PATCH 2/3] of: device: Do not ignore error code in of_device_uevent_modalias
  2023-02-07 11:05 [PATCH 0/3] Fix ehci-fsl autoload regression on fsl-mph-dr-of Alexander Stein
  2023-02-07 11:05 ` [PATCH 1/3] of: device: Ignore modalias of reused nodes Alexander Stein
@ 2023-02-07 11:05 ` Alexander Stein
  2023-02-07 11:05 ` [PATCH 3/3] usb: host: fsl-mph-dr-of: reuse device_set_of_node_from_dev Alexander Stein
  2023-02-08 23:44 ` [PATCH 0/3] Fix ehci-fsl autoload regression on fsl-mph-dr-of Rob Herring
  3 siblings, 0 replies; 5+ messages in thread
From: Alexander Stein @ 2023-02-07 11:05 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, Greg Kroah-Hartman, Alan Stern,
	Darren Stevens
  Cc: Alexander Stein, devicetree, linux-usb

of_device_get_modalias might return an error code, propagate that one.
Otherwise the negative, signed integer is propagated to unsigned integer
for the comparison resulting in a huge 'sl' size.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
There is no problem if of_device_uevent_modalias uses the same checks as
of_device_get_modalias, but this is error prone and cumbersome.

 drivers/of/device.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/of/device.c b/drivers/of/device.c
index 5b929351b65bf..955bfb3d1a834 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -385,6 +385,8 @@ int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *
 
 	sl = of_device_get_modalias(dev, &env->buf[env->buflen-1],
 				    sizeof(env->buf) - env->buflen);
+	if (sl < 0)
+		return sl;
 	if (sl >= (sizeof(env->buf) - env->buflen))
 		return -ENOMEM;
 	env->buflen += sl;
-- 
2.34.1


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

* [PATCH 3/3] usb: host: fsl-mph-dr-of: reuse device_set_of_node_from_dev
  2023-02-07 11:05 [PATCH 0/3] Fix ehci-fsl autoload regression on fsl-mph-dr-of Alexander Stein
  2023-02-07 11:05 ` [PATCH 1/3] of: device: Ignore modalias of reused nodes Alexander Stein
  2023-02-07 11:05 ` [PATCH 2/3] of: device: Do not ignore error code in of_device_uevent_modalias Alexander Stein
@ 2023-02-07 11:05 ` Alexander Stein
  2023-02-08 23:44 ` [PATCH 0/3] Fix ehci-fsl autoload regression on fsl-mph-dr-of Rob Herring
  3 siblings, 0 replies; 5+ messages in thread
From: Alexander Stein @ 2023-02-07 11:05 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, Greg Kroah-Hartman, Alan Stern,
	Darren Stevens
  Cc: Alexander Stein, devicetree, linux-usb

This sets both of_node fields and takes a of_node reference as well.

Fixes: bb160ee61c04 ("drivers/usb/host/ehci-fsl: Fix interrupt setup in host mode.")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/usb/host/fsl-mph-dr-of.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
index e5df175228928..46c6a152b8655 100644
--- a/drivers/usb/host/fsl-mph-dr-of.c
+++ b/drivers/usb/host/fsl-mph-dr-of.c
@@ -112,8 +112,7 @@ static struct platform_device *fsl_usb2_device_register(
 			goto error;
 	}
 
-	pdev->dev.of_node = ofdev->dev.of_node;
-	pdev->dev.of_node_reused = true;
+	device_set_of_node_from_dev(&pdev->dev, &ofdev->dev);
 
 	retval = platform_device_add(pdev);
 	if (retval)
-- 
2.34.1


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

* Re: [PATCH 0/3] Fix ehci-fsl autoload regression on fsl-mph-dr-of
  2023-02-07 11:05 [PATCH 0/3] Fix ehci-fsl autoload regression on fsl-mph-dr-of Alexander Stein
                   ` (2 preceding siblings ...)
  2023-02-07 11:05 ` [PATCH 3/3] usb: host: fsl-mph-dr-of: reuse device_set_of_node_from_dev Alexander Stein
@ 2023-02-08 23:44 ` Rob Herring
  3 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2023-02-08 23:44 UTC (permalink / raw)
  To: Alexander Stein
  Cc: Frank Rowand, Greg Kroah-Hartman, Alan Stern, Darren Stevens,
	devicetree, linux-usb

On Tue, Feb 07, 2023 at 12:05:28PM +0100, Alexander Stein wrote:
> Hi,
> 
> I noticed on my ls1021a based platform (TQMLS102xA) that the platform device
> created by fsl-mph-dr-of does not autoload fsl-ehci. Digging into it I noticed
> that starting from commit bb160ee61c04f ("drivers/usb/host/ehci-fsl: Fix
> interrupt setup in host mode.") this platform device has the wrong modalias:
> 
> $ cat /sys/bus/platform/devices/8600000.usb/fsl-ehci.0/modalias 
> of:NusbT(null)Cfsl-usb2-dr-v2.5Cfsl-usb2-dr
> 
> This is the modalias of the parent device, thus module ehci_fsl is not loaded
> automatically. Given the reason of removing the IRQ resource from DT in
> commit a1a2b7125e107 ("of/platform: Drop static setup of IRQ resource from DT
> core") the of_node has to be assigned to the subnode, but for modalias the
> reused of_node has to be ignored.
> 
> Patch 2 is not strictly required to fix autoloading, but this is still a bug fix.
> 
> Best regards,
> Alexander
> 
> Alexander Stein (3):
>   of: device: Ignore modalias of reused nodes
>   of: device: Do not ignore error code in of_device_uevent_modalias
>   usb: host: fsl-mph-dr-of: reuse device_set_of_node_from_dev

Assuming Greg will take these. For the series:

Reviewed-by: Rob Herring <robh@kernel.org>

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

end of thread, other threads:[~2023-02-08 23:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-07 11:05 [PATCH 0/3] Fix ehci-fsl autoload regression on fsl-mph-dr-of Alexander Stein
2023-02-07 11:05 ` [PATCH 1/3] of: device: Ignore modalias of reused nodes Alexander Stein
2023-02-07 11:05 ` [PATCH 2/3] of: device: Do not ignore error code in of_device_uevent_modalias Alexander Stein
2023-02-07 11:05 ` [PATCH 3/3] usb: host: fsl-mph-dr-of: reuse device_set_of_node_from_dev Alexander Stein
2023-02-08 23:44 ` [PATCH 0/3] Fix ehci-fsl autoload regression on fsl-mph-dr-of Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).