All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers
@ 2021-10-18 18:39 Sergey Shtylyov
  2021-10-18 18:39   ` Sergey Shtylyov
                   ` (24 more replies)
  0 siblings, 25 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Alan Stern, Mathias Nyman

Here are 22 patches against the 'usb-next' branch of Greg KH's 'usb.git' repo.
The affected drivers use platform_get_irq() which can return IRQ0 (considered
invalid, according to Linus) that means broken HCD when passed to usb_add_hcd()
called at the end of the probe methods. I think that the solution to this issue
is either explicitly deny or accept IRQ0 in usb_add_hcd()... /but/ here's this
patch set to get the things going...

Sergey Shtylyov (22):
  usb: host: ehci-exynos: deny IRQ0
  usb: host: ehci-mv: deny IRQ0
  usb: host: ehci-npcm7xx: deny IRQ0
  usb: host: ehci-omap: deny IRQ0
  usb: host: ehci-platform: deny IRQ0
  usb: host: ehci-spear: deny IRQ0
  usb: host: ehci-st: deny IRQ0
  usb: host: ohci-at91: deny IRQ0
  usb: host: ohci-da8xx: deny IRQ0
  usb: host: ohci-exynos: deny IRQ0
  usb: host: ohci-at91: deny IRQ0
  usb: host: ohci-omap: deny IRQ0
  usb: host: ohci-platform: deny IRQ0
  usb: host: ohci-pxa27x: deny IRQ0
  usb: host: ohci-sm501: deny IRQ0
  usb: host: ohci-spear: deny IRQ0
  usb: host: ohci-st: deny IRQ0
  usb: host: ohci-tmio: deny IRQ0
  usb: host: xhci-histb: deny IRQ0
  usb: host: xhci-mtk: deny IRQ0
  usb: host: xhci-plat: deny IRQ0
  usb: host: xhci-tegra: deny IRQ0

 drivers/usb/host/ehci-exynos.c   | 4 ++++
 drivers/usb/host/ehci-mv.c       | 4 ++++
 drivers/usb/host/ehci-npcm7xx.c  | 4 ++++
 drivers/usb/host/ehci-omap.c     | 2 ++
 drivers/usb/host/ehci-platform.c | 2 ++
 drivers/usb/host/ehci-spear.c    | 4 ++++
 drivers/usb/host/ehci-st.c       | 2 ++
 drivers/usb/host/ohci-at91.c     | 2 ++
 drivers/usb/host/ohci-da8xx.c    | 4 ++++
 drivers/usb/host/ohci-exynos.c   | 4 ++++
 drivers/usb/host/ohci-nxp.c      | 4 ++++
 drivers/usb/host/ohci-omap.c     | 4 ++++
 drivers/usb/host/ohci-platform.c | 2 ++
 drivers/usb/host/ohci-pxa27x.c   | 2 ++
 drivers/usb/host/ohci-sm501.c    | 4 ++++
 drivers/usb/host/ohci-spear.c    | 4 ++++
 drivers/usb/host/ohci-st.c       | 2 ++
 drivers/usb/host/ohci-tmio.c     | 2 ++
 drivers/usb/host/xhci-histb.c    | 2 ++
 drivers/usb/host/xhci-mtk.c      | 4 +++-
 drivers/usb/host/xhci-plat.c     | 2 ++
 drivers/usb/host/xhci-tegra.c    | 2 ++
 22 files changed, 65 insertions(+), 1 deletion(-)

-- 
2.26.3

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

* [PATCH 01/22] usb: host: ehci-exynos: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
@ 2021-10-18 18:39   ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 02/22] usb: host: ehci-mv: " Sergey Shtylyov
                     ` (23 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Krzysztof Kozlowski, linux-arm-kernel, linux-samsung-soc

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 44ed240d6273 ("usb: host: ehci-exynos: Fix error check in exynos_ehci_probe()")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ehci-exynos.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index 1a9b7572e17f..ff4e1261801a 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -207,6 +207,10 @@ static int exynos_ehci_probe(struct platform_device *pdev)
 		err = irq;
 		goto fail_io;
 	}
+	if (!irq) {
+		err = -EINVAL;
+		goto fail_io;
+	}
 
 	err = exynos_ehci_phy_enable(&pdev->dev);
 	if (err) {
-- 
2.26.3


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

* [PATCH 01/22] usb: host: ehci-exynos: deny IRQ0
@ 2021-10-18 18:39   ` Sergey Shtylyov
  0 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Krzysztof Kozlowski, linux-arm-kernel, linux-samsung-soc

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 44ed240d6273 ("usb: host: ehci-exynos: Fix error check in exynos_ehci_probe()")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ehci-exynos.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index 1a9b7572e17f..ff4e1261801a 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -207,6 +207,10 @@ static int exynos_ehci_probe(struct platform_device *pdev)
 		err = irq;
 		goto fail_io;
 	}
+	if (!irq) {
+		err = -EINVAL;
+		goto fail_io;
+	}
 
 	err = exynos_ehci_phy_enable(&pdev->dev);
 	if (err) {
-- 
2.26.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 02/22] usb: host: ehci-mv: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
  2021-10-18 18:39   ` Sergey Shtylyov
@ 2021-10-18 18:39 ` Sergey Shtylyov
  2021-10-18 18:39   ` Sergey Shtylyov
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: a7f40c233a6b ("USB: EHCI: ehci-mv: fix less than zero comparison of an unsigned int")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ehci-mv.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c
index 8fd27249ad25..f54ce1eeccf3 100644
--- a/drivers/usb/host/ehci-mv.c
+++ b/drivers/usb/host/ehci-mv.c
@@ -168,6 +168,10 @@ static int mv_ehci_probe(struct platform_device *pdev)
 	retval = platform_get_irq(pdev, 0);
 	if (retval < 0)
 		goto err_disable_clk;
+	if (!retval) {
+		retval = -EINVAL;
+		goto err_disable_clk;
+	}
 	hcd->irq = retval;
 
 	ehci = hcd_to_ehci(hcd);
-- 
2.26.3


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

* [PATCH 03/22] usb: host: ehci-npcm7xx: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
@ 2021-10-18 18:39   ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 02/22] usb: host: ehci-mv: " Sergey Shtylyov
                     ` (23 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Avi Fishman, Tomer Maimon, Tali Perry, Patrick Venture,
	Nancy Yuen, Benjamin Fair, openbmc

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: df44831ee2dd ("USB host: Add USB ehci support for nuvoton npcm7xx platform")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ehci-npcm7xx.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ehci-npcm7xx.c b/drivers/usb/host/ehci-npcm7xx.c
index 6b5a7a873e01..aff3d906ced5 100644
--- a/drivers/usb/host/ehci-npcm7xx.c
+++ b/drivers/usb/host/ehci-npcm7xx.c
@@ -114,6 +114,10 @@ static int npcm7xx_ehci_hcd_drv_probe(struct platform_device *pdev)
 		retval = irq;
 		goto fail;
 	}
+	if (!irq) {
+		retval = -EINVAL;
+		goto fail;
+	}
 
 	/*
 	 * Right now device-tree probed devices don't get dma_mask set.
-- 
2.26.3


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

* [PATCH 03/22] usb: host: ehci-npcm7xx: deny IRQ0
@ 2021-10-18 18:39   ` Sergey Shtylyov
  0 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Benjamin Fair, Avi Fishman, Patrick Venture, openbmc, Tali Perry,
	Tomer Maimon

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: df44831ee2dd ("USB host: Add USB ehci support for nuvoton npcm7xx platform")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ehci-npcm7xx.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ehci-npcm7xx.c b/drivers/usb/host/ehci-npcm7xx.c
index 6b5a7a873e01..aff3d906ced5 100644
--- a/drivers/usb/host/ehci-npcm7xx.c
+++ b/drivers/usb/host/ehci-npcm7xx.c
@@ -114,6 +114,10 @@ static int npcm7xx_ehci_hcd_drv_probe(struct platform_device *pdev)
 		retval = irq;
 		goto fail;
 	}
+	if (!irq) {
+		retval = -EINVAL;
+		goto fail;
+	}
 
 	/*
 	 * Right now device-tree probed devices don't get dma_mask set.
-- 
2.26.3


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

* [PATCH 04/22] usb: host: ehci-omap: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (2 preceding siblings ...)
  2021-10-18 18:39   ` Sergey Shtylyov
@ 2021-10-18 18:39 ` Sergey Shtylyov
  2021-10-21  6:28     ` kernel test robot
  2021-10-18 18:39   ` Sergey Shtylyov
                   ` (20 subsequent siblings)
  24 siblings, 1 reply; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman; +Cc: linux-omap

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: b33f37064b74 ("USB: host: ehci: introduce omap ehci-hcd driver")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ehci-omap.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index 7f4a03e8647a..79cec242c025 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -117,6 +117,8 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
+	if (!irq)
+		return -ENIVAL;
 
 	res =  platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	regs = devm_ioremap_resource(dev, res);
-- 
2.26.3


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

* [PATCH 05/22] usb: host: ehci-platform: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
@ 2021-10-18 18:39   ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 02/22] usb: host: ehci-mv: " Sergey Shtylyov
                     ` (23 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman; +Cc: linux-arm-kernel

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 7a7a4a592f42 ("USB: EHCI: Add a generic platform device driver")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ehci-platform.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index c70f2d0b4aaf..1b20af65d799 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -265,6 +265,8 @@ static int ehci_platform_probe(struct platform_device *dev)
 	irq = platform_get_irq(dev, 0);
 	if (irq < 0)
 		return irq;
+	if (!irq)
+		return -EINVAL;
 
 	hcd = usb_create_hcd(&ehci_platform_hc_driver, &dev->dev,
 			     dev_name(&dev->dev));
-- 
2.26.3


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

* [PATCH 05/22] usb: host: ehci-platform: deny IRQ0
@ 2021-10-18 18:39   ` Sergey Shtylyov
  0 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman; +Cc: linux-arm-kernel

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 7a7a4a592f42 ("USB: EHCI: Add a generic platform device driver")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ehci-platform.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index c70f2d0b4aaf..1b20af65d799 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -265,6 +265,8 @@ static int ehci_platform_probe(struct platform_device *dev)
 	irq = platform_get_irq(dev, 0);
 	if (irq < 0)
 		return irq;
+	if (!irq)
+		return -EINVAL;
 
 	hcd = usb_create_hcd(&ehci_platform_hc_driver, &dev->dev,
 			     dev_name(&dev->dev));
-- 
2.26.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 06/22] usb: host: ehci-spear: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (4 preceding siblings ...)
  2021-10-18 18:39   ` Sergey Shtylyov
@ 2021-10-18 18:39 ` Sergey Shtylyov
  2021-10-18 18:39   ` Sergey Shtylyov
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: c8c38de9d800 ("USB host: Adding USB ehci & ohci support for spear platform")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ehci-spear.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c
index 3694e450a11a..f4a5896900dc 100644
--- a/drivers/usb/host/ehci-spear.c
+++ b/drivers/usb/host/ehci-spear.c
@@ -70,6 +70,10 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev)
 		retval = irq;
 		goto fail;
 	}
+	if (!irq) {
+		retval = -EINVAL;
+		goto fail;
+	}
 
 	/*
 	 * Right now device-tree probed devices don't get dma_mask set.
-- 
2.26.3


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

* [PATCH 07/22] usb: host: ehci-st: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
@ 2021-10-18 18:39   ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 02/22] usb: host: ehci-mv: " Sergey Shtylyov
                     ` (23 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Patrice Chotard, linux-arm-kernel

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: e47c5a0906f9 ("usb: host: ehci-st: Add EHCI support for ST STB devices")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ehci-st.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ehci-st.c b/drivers/usb/host/ehci-st.c
index f74433aac948..5f53c313f943 100644
--- a/drivers/usb/host/ehci-st.c
+++ b/drivers/usb/host/ehci-st.c
@@ -160,6 +160,8 @@ static int st_ehci_platform_probe(struct platform_device *dev)
 	irq = platform_get_irq(dev, 0);
 	if (irq < 0)
 		return irq;
+	if (!irq)
+		return -EINVAL;
 	res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	if (!res_mem) {
 		dev_err(&dev->dev, "no memory resource provided");
-- 
2.26.3


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

* [PATCH 07/22] usb: host: ehci-st: deny IRQ0
@ 2021-10-18 18:39   ` Sergey Shtylyov
  0 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Patrice Chotard, linux-arm-kernel

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: e47c5a0906f9 ("usb: host: ehci-st: Add EHCI support for ST STB devices")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ehci-st.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ehci-st.c b/drivers/usb/host/ehci-st.c
index f74433aac948..5f53c313f943 100644
--- a/drivers/usb/host/ehci-st.c
+++ b/drivers/usb/host/ehci-st.c
@@ -160,6 +160,8 @@ static int st_ehci_platform_probe(struct platform_device *dev)
 	irq = platform_get_irq(dev, 0);
 	if (irq < 0)
 		return irq;
+	if (!irq)
+		return -EINVAL;
 	res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	if (!res_mem) {
 		dev_err(&dev->dev, "no memory resource provided");
-- 
2.26.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 08/22] usb: host: ohci-at91: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
@ 2021-10-18 18:39   ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 02/22] usb: host: ehci-mv: " Sergey Shtylyov
                     ` (23 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Nicolas Ferre, Alexandre Belloni, Ludovic Desroches, linux-arm-kernel

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: fb5f1834c322 ("usb: ohci-at91: fix irq and iomem resource retrieval")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-at91.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index a24aea3d2759..6a7276a730d1 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -181,6 +181,8 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
 		dev_dbg(dev, "hcd probe: missing irq resource\n");
 		return irq;
 	}
+	if (!irq)
+		return -EINVAL;
 
 	hcd = usb_create_hcd(driver, dev, "at91");
 	if (!hcd)
-- 
2.26.3


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

* [PATCH 08/22] usb: host: ohci-at91: deny IRQ0
@ 2021-10-18 18:39   ` Sergey Shtylyov
  0 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Alexandre Belloni, Ludovic Desroches, linux-arm-kernel

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: fb5f1834c322 ("usb: ohci-at91: fix irq and iomem resource retrieval")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-at91.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index a24aea3d2759..6a7276a730d1 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -181,6 +181,8 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
 		dev_dbg(dev, "hcd probe: missing irq resource\n");
 		return irq;
 	}
+	if (!irq)
+		return -EINVAL;
 
 	hcd = usb_create_hcd(driver, dev, "at91");
 	if (!hcd)
-- 
2.26.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 09/22] usb: host: ohci-da8xx: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (7 preceding siblings ...)
  2021-10-18 18:39   ` Sergey Shtylyov
@ 2021-10-18 18:39 ` Sergey Shtylyov
  2021-10-18 18:39   ` Sergey Shtylyov
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: efe7daf2231a ("USB: OHCI: DA8xx/OMAP-L1x glue layer")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-da8xx.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 1371b0c249ec..6d08ab2bf163 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -449,6 +449,10 @@ static int ohci_da8xx_probe(struct platform_device *pdev)
 		error = -ENODEV;
 		goto err;
 	}
+	if (!hcd_irq) {
+		error = -EINVAL;
+		goto err;
+	}
 
 	error = usb_add_hcd(hcd, hcd_irq, 0);
 	if (error)
-- 
2.26.3


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

* [PATCH 10/22] usb: host: ohci-exynos: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
@ 2021-10-18 18:39   ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 02/22] usb: host: ehci-mv: " Sergey Shtylyov
                     ` (23 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Krzysztof Kozlowski, linux-arm-kernel, linux-samsung-soc

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 1d4169834628 ("usb: host: ohci-exynos: Fix error handling in exynos_ohci_probe()")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-exynos.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 5f5e8a64c8e2..f28f28e42f43 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -175,6 +175,10 @@ static int exynos_ohci_probe(struct platform_device *pdev)
 		err = irq;
 		goto fail_io;
 	}
+	if (!irq) {
+		err = -EINVAL;
+		goto fail_io;
+	}
 
 	platform_set_drvdata(pdev, hcd);
 
-- 
2.26.3


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

* [PATCH 10/22] usb: host: ohci-exynos: deny IRQ0
@ 2021-10-18 18:39   ` Sergey Shtylyov
  0 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Krzysztof Kozlowski, linux-arm-kernel, linux-samsung-soc

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 1d4169834628 ("usb: host: ohci-exynos: Fix error handling in exynos_ohci_probe()")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-exynos.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 5f5e8a64c8e2..f28f28e42f43 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -175,6 +175,10 @@ static int exynos_ohci_probe(struct platform_device *pdev)
 		err = irq;
 		goto fail_io;
 	}
+	if (!irq) {
+		err = -EINVAL;
+		goto fail_io;
+	}
 
 	platform_set_drvdata(pdev, hcd);
 
-- 
2.26.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 11/22] usb: host: ohci-at91: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
@ 2021-10-18 18:39   ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 02/22] usb: host: ehci-mv: " Sergey Shtylyov
                     ` (23 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Vladimir Zapolskiy, linux-arm-kernel

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 60bbfc84b6d9 ("USB OHCI controller support for PNX4008")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-nxp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
index 85878e8ad331..afb9c2fc85c3 100644
--- a/drivers/usb/host/ohci-nxp.c
+++ b/drivers/usb/host/ohci-nxp.c
@@ -215,6 +215,10 @@ static int ohci_hcd_nxp_probe(struct platform_device *pdev)
 		ret = -ENXIO;
 		goto fail_resource;
 	}
+	if (!irq) {
+		ret = -EINVAL;
+		goto fail_resource;
+	}
 
 	ohci_nxp_start_hc();
 	platform_set_drvdata(pdev, hcd);
-- 
2.26.3


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

* [PATCH 11/22] usb: host: ohci-at91: deny IRQ0
@ 2021-10-18 18:39   ` Sergey Shtylyov
  0 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Vladimir Zapolskiy, linux-arm-kernel

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 60bbfc84b6d9 ("USB OHCI controller support for PNX4008")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-nxp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
index 85878e8ad331..afb9c2fc85c3 100644
--- a/drivers/usb/host/ohci-nxp.c
+++ b/drivers/usb/host/ohci-nxp.c
@@ -215,6 +215,10 @@ static int ohci_hcd_nxp_probe(struct platform_device *pdev)
 		ret = -ENXIO;
 		goto fail_resource;
 	}
+	if (!irq) {
+		ret = -EINVAL;
+		goto fail_resource;
+	}
 
 	ohci_nxp_start_hc();
 	platform_set_drvdata(pdev, hcd);
-- 
2.26.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 12/22] usb: host: ohci-omap: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (10 preceding siblings ...)
  2021-10-18 18:39   ` Sergey Shtylyov
@ 2021-10-18 18:39 ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 13/22] usb: host: ohci-platform: " Sergey Shtylyov
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman; +Cc: linux-omap

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 489447380a29 ("[PATCH] handle errors returned by platform_get_irq*()")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-omap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index ded9738392e4..6d5f964d0995 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -309,6 +309,10 @@ static int ohci_hcd_omap_probe(struct platform_device *pdev)
 		retval = -ENXIO;
 		goto err3;
 	}
+	if (!irq) {
+		retval = -EINVAL;
+		goto err3;
+	}
 	retval = usb_add_hcd(hcd, irq, 0);
 	if (retval)
 		goto err3;
-- 
2.26.3


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

* [PATCH 13/22] usb: host: ohci-platform: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (11 preceding siblings ...)
  2021-10-18 18:39 ` [PATCH 12/22] usb: host: ohci-omap: " Sergey Shtylyov
@ 2021-10-18 18:39 ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 14/22] usb: host: ohci-pxa27x: " Sergey Shtylyov
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: fa3364b5a2d7 ("USB: OHCI: Add a generic platform device driver")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-platform.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index 4a8456f12a73..ec1d38d5d140 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -113,6 +113,8 @@ static int ohci_platform_probe(struct platform_device *dev)
 	irq = platform_get_irq(dev, 0);
 	if (irq < 0)
 		return irq;
+	if (!irq)
+		return -EINVAL;
 
 	hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev,
 			dev_name(&dev->dev));
-- 
2.26.3


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

* [PATCH 14/22] usb: host: ohci-pxa27x: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (12 preceding siblings ...)
  2021-10-18 18:39 ` [PATCH 13/22] usb: host: ohci-platform: " Sergey Shtylyov
@ 2021-10-18 18:39 ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 15/22] usb: host: ohci-sm501: " Sergey Shtylyov
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 84bab7393b0d ("[ARM] ohci-pxa27x: use platform_get_{irq,resource} for the resource")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-pxa27x.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 54aa5c77e549..336437277fd0 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -443,6 +443,8 @@ static int ohci_hcd_pxa27x_probe(struct platform_device *pdev)
 		pr_err("no resource of IORESOURCE_IRQ");
 		return irq;
 	}
+	if (!irq)
+		return -EINVAL;
 
 	usb_clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(usb_clk))
-- 
2.26.3


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

* [PATCH 15/22] usb: host: ohci-sm501: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (13 preceding siblings ...)
  2021-10-18 18:39 ` [PATCH 14/22] usb: host: ohci-pxa27x: " Sergey Shtylyov
@ 2021-10-18 18:39 ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 16/22] usb: host: ohci-spear: " Sergey Shtylyov
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: f54aab6ebcec ("usb: ohci-sm501 driver")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-sm501.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
index b91d50da6127..ffb7b6645d2c 100644
--- a/drivers/usb/host/ohci-sm501.c
+++ b/drivers/usb/host/ohci-sm501.c
@@ -96,6 +96,10 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev)
 	irq = retval = platform_get_irq(pdev, 0);
 	if (retval < 0)
 		goto err0;
+	if (!retval) {
+		retval = -EINVAL;
+		goto err0;
+	}
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 	if (mem == NULL) {
-- 
2.26.3


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

* [PATCH 16/22] usb: host: ohci-spear: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (14 preceding siblings ...)
  2021-10-18 18:39 ` [PATCH 15/22] usb: host: ohci-sm501: " Sergey Shtylyov
@ 2021-10-18 18:39 ` Sergey Shtylyov
  2021-10-18 18:39   ` Sergey Shtylyov
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: c8c38de9d800 ("USB host: Adding USB ehci & ohci support for spear platform")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-spear.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c
index b4cd9e6c72fd..6c5af2612c46 100644
--- a/drivers/usb/host/ohci-spear.c
+++ b/drivers/usb/host/ohci-spear.c
@@ -46,6 +46,10 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev)
 		retval = irq;
 		goto fail;
 	}
+	if (!irq) {
+		retval = -EINVAL;
+		goto fail;
+	}
 
 	/*
 	 * Right now device-tree probed devices don't get dma_mask set.
-- 
2.26.3


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

* [PATCH 17/22] usb: host: ohci-st: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
@ 2021-10-18 18:39   ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 02/22] usb: host: ehci-mv: " Sergey Shtylyov
                     ` (23 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Patrice Chotard, linux-arm-kernel

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: d115837259ad ("usb: host: ohci-st: Add OHCI driver support for ST STB devices")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-st.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ohci-st.c b/drivers/usb/host/ohci-st.c
index ac796ccd93ef..b9200071ce6c 100644
--- a/drivers/usb/host/ohci-st.c
+++ b/drivers/usb/host/ohci-st.c
@@ -140,6 +140,8 @@ static int st_ohci_platform_probe(struct platform_device *dev)
 	irq = platform_get_irq(dev, 0);
 	if (irq < 0)
 		return irq;
+	if (!irq)
+		return -EINVAL;
 
 	res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	if (!res_mem) {
-- 
2.26.3


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

* [PATCH 17/22] usb: host: ohci-st: deny IRQ0
@ 2021-10-18 18:39   ` Sergey Shtylyov
  0 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Patrice Chotard, linux-arm-kernel

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: d115837259ad ("usb: host: ohci-st: Add OHCI driver support for ST STB devices")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-st.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ohci-st.c b/drivers/usb/host/ohci-st.c
index ac796ccd93ef..b9200071ce6c 100644
--- a/drivers/usb/host/ohci-st.c
+++ b/drivers/usb/host/ohci-st.c
@@ -140,6 +140,8 @@ static int st_ohci_platform_probe(struct platform_device *dev)
 	irq = platform_get_irq(dev, 0);
 	if (irq < 0)
 		return irq;
+	if (!irq)
+		return -EINVAL;
 
 	res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	if (!res_mem) {
-- 
2.26.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 18/22] usb: host: ohci-tmio: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (16 preceding siblings ...)
  2021-10-18 18:39   ` Sergey Shtylyov
@ 2021-10-18 18:39 ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 19/22] usb: host: xhci-histb: " Sergey Shtylyov
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 78c73414f4f6 ("USB: ohci: add support for tmio-ohci cell")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/ohci-tmio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
index 08ec2ab0d95a..53932e8a968f 100644
--- a/drivers/usb/host/ohci-tmio.c
+++ b/drivers/usb/host/ohci-tmio.c
@@ -204,6 +204,8 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev)
 
 	if (irq < 0)
 		return irq;
+	if (!irq)
+		return -EINVAL;
 
 	hcd = usb_create_hcd(&ohci_tmio_hc_driver, &dev->dev, dev_name(&dev->dev));
 	if (!hcd) {
-- 
2.26.3


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

* [PATCH 19/22] usb: host: xhci-histb: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (17 preceding siblings ...)
  2021-10-18 18:39 ` [PATCH 18/22] usb: host: ohci-tmio: " Sergey Shtylyov
@ 2021-10-18 18:39 ` Sergey Shtylyov
  2021-10-18 18:39   ` Sergey Shtylyov
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Mathias Nyman, Greg Kroah-Hartman

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: c508f41da078 ("xhci: hisilicon: support HiSilicon STB xHCI host controller")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/xhci-histb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/xhci-histb.c b/drivers/usb/host/xhci-histb.c
index 08369857686e..581952dcefe8 100644
--- a/drivers/usb/host/xhci-histb.c
+++ b/drivers/usb/host/xhci-histb.c
@@ -218,6 +218,8 @@ static int xhci_histb_probe(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
+	if (!irq)
+		return -EINVAL;
 
 	histb->ctrl = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
 	if (IS_ERR(histb->ctrl))
-- 
2.26.3


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

* [PATCH 20/22] usb: host: xhci-mtk: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
  2021-10-18 18:39   ` Sergey Shtylyov
@ 2021-10-18 18:39   ` Sergey Shtylyov
  2021-10-18 18:39   ` Sergey Shtylyov
                     ` (22 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Mathias Nyman, Greg Kroah-Hartman
  Cc: Chunfeng Yun, Matthias Brugger, linux-arm-kernel, linux-mediatek

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host controller")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/xhci-mtk.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index c53f6f276d5c..d2dc8d9863ee 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -495,7 +495,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 		return ret;
 
 	irq = platform_get_irq_byname_optional(pdev, "host");
-	if (irq < 0) {
+	if (irq <= 0) {
 		if (irq == -EPROBE_DEFER)
 			return irq;
 
@@ -503,6 +503,8 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 		irq = platform_get_irq(pdev, 0);
 		if (irq < 0)
 			return irq;
+		if (!irq)
+			return -EINVAL;
 	}
 
 	wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
-- 
2.26.3

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

* [PATCH 20/22] usb: host: xhci-mtk: deny IRQ0
@ 2021-10-18 18:39   ` Sergey Shtylyov
  0 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Mathias Nyman, Greg Kroah-Hartman
  Cc: Chunfeng Yun, Matthias Brugger, linux-arm-kernel, linux-mediatek

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host controller")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/xhci-mtk.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index c53f6f276d5c..d2dc8d9863ee 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -495,7 +495,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 		return ret;
 
 	irq = platform_get_irq_byname_optional(pdev, "host");
-	if (irq < 0) {
+	if (irq <= 0) {
 		if (irq == -EPROBE_DEFER)
 			return irq;
 
@@ -503,6 +503,8 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 		irq = platform_get_irq(pdev, 0);
 		if (irq < 0)
 			return irq;
+		if (!irq)
+			return -EINVAL;
 	}
 
 	wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
-- 
2.26.3

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 20/22] usb: host: xhci-mtk: deny IRQ0
@ 2021-10-18 18:39   ` Sergey Shtylyov
  0 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Mathias Nyman, Greg Kroah-Hartman
  Cc: Chunfeng Yun, Matthias Brugger, linux-arm-kernel, linux-mediatek

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host controller")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/xhci-mtk.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index c53f6f276d5c..d2dc8d9863ee 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -495,7 +495,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 		return ret;
 
 	irq = platform_get_irq_byname_optional(pdev, "host");
-	if (irq < 0) {
+	if (irq <= 0) {
 		if (irq == -EPROBE_DEFER)
 			return irq;
 
@@ -503,6 +503,8 @@ static int xhci_mtk_probe(struct platform_device *pdev)
 		irq = platform_get_irq(pdev, 0);
 		if (irq < 0)
 			return irq;
+		if (!irq)
+			return -EINVAL;
 	}
 
 	wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
-- 
2.26.3

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 21/22] usb: host: xhci-plat: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (19 preceding siblings ...)
  2021-10-18 18:39   ` Sergey Shtylyov
@ 2021-10-18 18:39 ` Sergey Shtylyov
  2021-10-18 18:39 ` [PATCH 22/22] usb: host: xhci-tegra: " Sergey Shtylyov
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: 3429e91a661e ("usb: host: xhci: add platform driver support")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/xhci-plat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index c1edcc9b13ce..8f8ad82d90cd 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -205,6 +205,8 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
+	if (!irq)
+		return -EINVAL;
 
 	/*
 	 * sysdev must point to a device that is known to the system firmware
-- 
2.26.3


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

* [PATCH 22/22] usb: host: xhci-tegra: deny IRQ0
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (20 preceding siblings ...)
  2021-10-18 18:39 ` [PATCH 21/22] usb: host: xhci-plat: " Sergey Shtylyov
@ 2021-10-18 18:39 ` Sergey Shtylyov
  2021-10-21  9:09   ` Dmitry Osipenko
  2021-10-19  1:35 ` [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Alan Stern
                   ` (2 subsequent siblings)
  24 siblings, 1 reply; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-18 18:39 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Thierry Reding, Jonathan Hunter, linux-tegra

If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...

Fixes: e84fce0f8837 ("usb: xhci: Add NVIDIA Tegra XUSB controller driver")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/host/xhci-tegra.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index 1bf494b649bd..7151b1d4f876 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -1439,6 +1439,8 @@ static int tegra_xusb_probe(struct platform_device *pdev)
 	tegra->xhci_irq = platform_get_irq(pdev, 0);
 	if (tegra->xhci_irq < 0)
 		return tegra->xhci_irq;
+	if (!tegra->xhci_irq)
+		return -ENIVAL;
 
 	tegra->mbox_irq = platform_get_irq(pdev, 1);
 	if (tegra->mbox_irq < 0)
-- 
2.26.3


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

* Re: [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (21 preceding siblings ...)
  2021-10-18 18:39 ` [PATCH 22/22] usb: host: xhci-tegra: " Sergey Shtylyov
@ 2021-10-19  1:35 ` Alan Stern
  2021-10-19  5:41 ` Greg Kroah-Hartman
  2021-10-20 16:16 ` Greg Kroah-Hartman
  24 siblings, 0 replies; 57+ messages in thread
From: Alan Stern @ 2021-10-19  1:35 UTC (permalink / raw)
  To: Sergey Shtylyov; +Cc: linux-usb, Greg Kroah-Hartman, Mathias Nyman

On Mon, Oct 18, 2021 at 09:39:08PM +0300, Sergey Shtylyov wrote:
> Here are 22 patches against the 'usb-next' branch of Greg KH's 'usb.git' repo.
> The affected drivers use platform_get_irq() which can return IRQ0 (considered
> invalid, according to Linus) that means broken HCD when passed to usb_add_hcd()
> called at the end of the probe methods. I think that the solution to this issue
> is either explicitly deny or accept IRQ0 in usb_add_hcd()... /but/ here's this
> patch set to get the things going...
> 
> Sergey Shtylyov (22):

For patches 1 - 18 (EHCI and OHCI):

Acked-by: Alan Stern <stern@rowland.harvard.edu>

>   usb: host: ehci-exynos: deny IRQ0
>   usb: host: ehci-mv: deny IRQ0
>   usb: host: ehci-npcm7xx: deny IRQ0
>   usb: host: ehci-omap: deny IRQ0
>   usb: host: ehci-platform: deny IRQ0
>   usb: host: ehci-spear: deny IRQ0
>   usb: host: ehci-st: deny IRQ0
>   usb: host: ohci-at91: deny IRQ0
>   usb: host: ohci-da8xx: deny IRQ0
>   usb: host: ohci-exynos: deny IRQ0
>   usb: host: ohci-at91: deny IRQ0
>   usb: host: ohci-omap: deny IRQ0
>   usb: host: ohci-platform: deny IRQ0
>   usb: host: ohci-pxa27x: deny IRQ0
>   usb: host: ohci-sm501: deny IRQ0
>   usb: host: ohci-spear: deny IRQ0
>   usb: host: ohci-st: deny IRQ0
>   usb: host: ohci-tmio: deny IRQ0
>   usb: host: xhci-histb: deny IRQ0
>   usb: host: xhci-mtk: deny IRQ0
>   usb: host: xhci-plat: deny IRQ0
>   usb: host: xhci-tegra: deny IRQ0
> 
>  drivers/usb/host/ehci-exynos.c   | 4 ++++
>  drivers/usb/host/ehci-mv.c       | 4 ++++
>  drivers/usb/host/ehci-npcm7xx.c  | 4 ++++
>  drivers/usb/host/ehci-omap.c     | 2 ++
>  drivers/usb/host/ehci-platform.c | 2 ++
>  drivers/usb/host/ehci-spear.c    | 4 ++++
>  drivers/usb/host/ehci-st.c       | 2 ++
>  drivers/usb/host/ohci-at91.c     | 2 ++
>  drivers/usb/host/ohci-da8xx.c    | 4 ++++
>  drivers/usb/host/ohci-exynos.c   | 4 ++++
>  drivers/usb/host/ohci-nxp.c      | 4 ++++
>  drivers/usb/host/ohci-omap.c     | 4 ++++
>  drivers/usb/host/ohci-platform.c | 2 ++
>  drivers/usb/host/ohci-pxa27x.c   | 2 ++
>  drivers/usb/host/ohci-sm501.c    | 4 ++++
>  drivers/usb/host/ohci-spear.c    | 4 ++++
>  drivers/usb/host/ohci-st.c       | 2 ++
>  drivers/usb/host/ohci-tmio.c     | 2 ++
>  drivers/usb/host/xhci-histb.c    | 2 ++
>  drivers/usb/host/xhci-mtk.c      | 4 +++-
>  drivers/usb/host/xhci-plat.c     | 2 ++
>  drivers/usb/host/xhci-tegra.c    | 2 ++
>  22 files changed, 65 insertions(+), 1 deletion(-)
> 
> -- 
> 2.26.3

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

* Re: [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (22 preceding siblings ...)
  2021-10-19  1:35 ` [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Alan Stern
@ 2021-10-19  5:41 ` Greg Kroah-Hartman
  2021-10-19  7:31   ` Greg Kroah-Hartman
  2021-10-19 18:18   ` Sergey Shtylyov
  2021-10-20 16:16 ` Greg Kroah-Hartman
  24 siblings, 2 replies; 57+ messages in thread
From: Greg Kroah-Hartman @ 2021-10-19  5:41 UTC (permalink / raw)
  To: Sergey Shtylyov; +Cc: linux-usb, Alan Stern, Mathias Nyman

On Mon, Oct 18, 2021 at 09:39:08PM +0300, Sergey Shtylyov wrote:
> Here are 22 patches against the 'usb-next' branch of Greg KH's 'usb.git' repo.
> The affected drivers use platform_get_irq() which can return IRQ0 (considered
> invalid, according to Linus) that means broken HCD when passed to usb_add_hcd()
> called at the end of the probe methods. I think that the solution to this issue
> is either explicitly deny or accept IRQ0 in usb_add_hcd()... /but/ here's this
> patch set to get the things going...

Why not fix the root of the problem for your platform that is failing to
assign a valid irq for the device?

Are you going to make this change to all callers of this function in the
kernel tree?

thanks,

greg k-h

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

* Re: [PATCH 03/22] usb: host: ehci-npcm7xx: deny IRQ0
  2021-10-18 18:39   ` Sergey Shtylyov
@ 2021-10-19  7:11     ` Avi Fishman
  -1 siblings, 0 replies; 57+ messages in thread
From: Avi Fishman @ 2021-10-19  7:11 UTC (permalink / raw)
  To: Sergey Shtylyov
  Cc: linux-usb, Alan Stern, Greg Kroah-Hartman, Tomer Maimon,
	Tali Perry, Patrick Venture, Nancy Yuen, Benjamin Fair,
	OpenBMC Maillist

On Mon, Oct 18, 2021 at 9:39 PM Sergey Shtylyov <s.shtylyov@omp.ru> wrote:
>
> If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
> at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...
>
> Fixes: df44831ee2dd ("USB host: Add USB ehci support for nuvoton npcm7xx platform")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> ---
>  drivers/usb/host/ehci-npcm7xx.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/host/ehci-npcm7xx.c b/drivers/usb/host/ehci-npcm7xx.c
> index 6b5a7a873e01..aff3d906ced5 100644
> --- a/drivers/usb/host/ehci-npcm7xx.c
> +++ b/drivers/usb/host/ehci-npcm7xx.c
> @@ -114,6 +114,10 @@ static int npcm7xx_ehci_hcd_drv_probe(struct platform_device *pdev)
>                 retval = irq;
>                 goto fail;
>         }
> +       if (!irq) {
> +               retval = -EINVAL;
> +               goto fail;
> +       }
>
>         /*
>          * Right now device-tree probed devices don't get dma_mask set.
> --
> 2.26.3
>
Reviewed-by: Avi Fishman <avifishman70@gmail.com>

--
Regards,
Avi

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

* Re: [PATCH 03/22] usb: host: ehci-npcm7xx: deny IRQ0
@ 2021-10-19  7:11     ` Avi Fishman
  0 siblings, 0 replies; 57+ messages in thread
From: Avi Fishman @ 2021-10-19  7:11 UTC (permalink / raw)
  To: Sergey Shtylyov
  Cc: Tomer Maimon, Patrick Venture, OpenBMC Maillist, linux-usb,
	Tali Perry, Alan Stern, Greg Kroah-Hartman, Benjamin Fair

On Mon, Oct 18, 2021 at 9:39 PM Sergey Shtylyov <s.shtylyov@omp.ru> wrote:
>
> If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
> at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...
>
> Fixes: df44831ee2dd ("USB host: Add USB ehci support for nuvoton npcm7xx platform")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> ---
>  drivers/usb/host/ehci-npcm7xx.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/host/ehci-npcm7xx.c b/drivers/usb/host/ehci-npcm7xx.c
> index 6b5a7a873e01..aff3d906ced5 100644
> --- a/drivers/usb/host/ehci-npcm7xx.c
> +++ b/drivers/usb/host/ehci-npcm7xx.c
> @@ -114,6 +114,10 @@ static int npcm7xx_ehci_hcd_drv_probe(struct platform_device *pdev)
>                 retval = irq;
>                 goto fail;
>         }
> +       if (!irq) {
> +               retval = -EINVAL;
> +               goto fail;
> +       }
>
>         /*
>          * Right now device-tree probed devices don't get dma_mask set.
> --
> 2.26.3
>
Reviewed-by: Avi Fishman <avifishman70@gmail.com>

--
Regards,
Avi

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

* Re: [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers
  2021-10-19  5:41 ` Greg Kroah-Hartman
@ 2021-10-19  7:31   ` Greg Kroah-Hartman
  2021-10-19 18:28     ` Sergey Shtylyov
  2021-10-19 18:18   ` Sergey Shtylyov
  1 sibling, 1 reply; 57+ messages in thread
From: Greg Kroah-Hartman @ 2021-10-19  7:31 UTC (permalink / raw)
  To: Sergey Shtylyov; +Cc: linux-usb, Alan Stern, Mathias Nyman

On Tue, Oct 19, 2021 at 07:41:34AM +0200, Greg Kroah-Hartman wrote:
> On Mon, Oct 18, 2021 at 09:39:08PM +0300, Sergey Shtylyov wrote:
> > Here are 22 patches against the 'usb-next' branch of Greg KH's 'usb.git' repo.
> > The affected drivers use platform_get_irq() which can return IRQ0 (considered
> > invalid, according to Linus) that means broken HCD when passed to usb_add_hcd()
> > called at the end of the probe methods. I think that the solution to this issue
> > is either explicitly deny or accept IRQ0 in usb_add_hcd()... /but/ here's this
> > patch set to get the things going...
> 
> Why not fix the root of the problem for your platform that is failing to
> assign a valid irq for the device?
> 
> Are you going to make this change to all callers of this function in the
> kernel tree?

Also, you should have gotten a huge WARNING in your kernel log if this
happens to let you know that something bad is going on.  Is this patch
series going to really change any of that?

What is the root problem here that you are trying to paper over with
this patchset?

thanks,

greg k-h

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

* Re: [PATCH 11/22] usb: host: ohci-at91: deny IRQ0
  2021-10-18 18:39   ` Sergey Shtylyov
@ 2021-10-19 11:15     ` Alexander Dahl
  -1 siblings, 0 replies; 57+ messages in thread
From: Alexander Dahl @ 2021-10-19 11:15 UTC (permalink / raw)
  To: Sergey Shtylyov
  Cc: linux-usb, Alan Stern, Greg Kroah-Hartman, Vladimir Zapolskiy,
	linux-arm-kernel

Hello Sergey,

Am Mon, Oct 18, 2021 at 09:39:19PM +0300 schrieb Sergey Shtylyov:
> If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
> at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...
> 
> Fixes: 60bbfc84b6d9 ("USB OHCI controller support for PNX4008")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> ---
>  drivers/usb/host/ohci-nxp.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
> index 85878e8ad331..afb9c2fc85c3 100644
> --- a/drivers/usb/host/ohci-nxp.c
> +++ b/drivers/usb/host/ohci-nxp.c
> @@ -215,6 +215,10 @@ static int ohci_hcd_nxp_probe(struct platform_device *pdev)
>  		ret = -ENXIO;
>  		goto fail_resource;
>  	}
> +	if (!irq) {
> +		ret = -EINVAL;
> +		goto fail_resource;
> +	}
>  
>  	ohci_nxp_start_hc();
>  	platform_set_drvdata(pdev, hcd);

Subject refers to at91 while content is about nxp.

Greets
Alex

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

* Re: [PATCH 11/22] usb: host: ohci-at91: deny IRQ0
@ 2021-10-19 11:15     ` Alexander Dahl
  0 siblings, 0 replies; 57+ messages in thread
From: Alexander Dahl @ 2021-10-19 11:15 UTC (permalink / raw)
  To: Sergey Shtylyov
  Cc: linux-usb, Alan Stern, Greg Kroah-Hartman, Vladimir Zapolskiy,
	linux-arm-kernel

Hello Sergey,

Am Mon, Oct 18, 2021 at 09:39:19PM +0300 schrieb Sergey Shtylyov:
> If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
> at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...
> 
> Fixes: 60bbfc84b6d9 ("USB OHCI controller support for PNX4008")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> ---
>  drivers/usb/host/ohci-nxp.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
> index 85878e8ad331..afb9c2fc85c3 100644
> --- a/drivers/usb/host/ohci-nxp.c
> +++ b/drivers/usb/host/ohci-nxp.c
> @@ -215,6 +215,10 @@ static int ohci_hcd_nxp_probe(struct platform_device *pdev)
>  		ret = -ENXIO;
>  		goto fail_resource;
>  	}
> +	if (!irq) {
> +		ret = -EINVAL;
> +		goto fail_resource;
> +	}
>  
>  	ohci_nxp_start_hc();
>  	platform_set_drvdata(pdev, hcd);

Subject refers to at91 while content is about nxp.

Greets
Alex

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 11/22] usb: host: ohci-at91: deny IRQ0
  2021-10-19 11:15     ` Alexander Dahl
@ 2021-10-19 16:51       ` Sergey Shtylyov
  -1 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-19 16:51 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman, Vladimir Zapolskiy,
	linux-arm-kernel

On 10/19/21 2:15 PM, Alexander Dahl wrote:

>> If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
>> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
>> at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...
>>
>> Fixes: 60bbfc84b6d9 ("USB OHCI controller support for PNX4008")
>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>> ---
>>  drivers/usb/host/ohci-nxp.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
>> index 85878e8ad331..afb9c2fc85c3 100644
>> --- a/drivers/usb/host/ohci-nxp.c
>> +++ b/drivers/usb/host/ohci-nxp.c
>> @@ -215,6 +215,10 @@ static int ohci_hcd_nxp_probe(struct platform_device *pdev)
>>  		ret = -ENXIO;
>>  		goto fail_resource;
>>  	}
>> +	if (!irq) {
>> +		ret = -EINVAL;
>> +		goto fail_resource;
>> +	}
>>  
>>  	ohci_nxp_start_hc();
>>  	platform_set_drvdata(pdev, hcd);
> 
> Subject refers to at91 while content is about nxp.

   Oops, sorry! :-<
   That's what you get when you send 22 patches fixing the same issue... :-)

> Greets
> Alex

MBR, Sergey

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

* Re: [PATCH 11/22] usb: host: ohci-at91: deny IRQ0
@ 2021-10-19 16:51       ` Sergey Shtylyov
  0 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-19 16:51 UTC (permalink / raw)
  To: linux-usb, Alan Stern, Greg Kroah-Hartman, Vladimir Zapolskiy,
	linux-arm-kernel

On 10/19/21 2:15 PM, Alexander Dahl wrote:

>> If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
>> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
>> at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...
>>
>> Fixes: 60bbfc84b6d9 ("USB OHCI controller support for PNX4008")
>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>> ---
>>  drivers/usb/host/ohci-nxp.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
>> index 85878e8ad331..afb9c2fc85c3 100644
>> --- a/drivers/usb/host/ohci-nxp.c
>> +++ b/drivers/usb/host/ohci-nxp.c
>> @@ -215,6 +215,10 @@ static int ohci_hcd_nxp_probe(struct platform_device *pdev)
>>  		ret = -ENXIO;
>>  		goto fail_resource;
>>  	}
>> +	if (!irq) {
>> +		ret = -EINVAL;
>> +		goto fail_resource;
>> +	}
>>  
>>  	ohci_nxp_start_hc();
>>  	platform_set_drvdata(pdev, hcd);
> 
> Subject refers to at91 while content is about nxp.

   Oops, sorry! :-<
   That's what you get when you send 22 patches fixing the same issue... :-)

> Greets
> Alex

MBR, Sergey

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers
  2021-10-19  5:41 ` Greg Kroah-Hartman
  2021-10-19  7:31   ` Greg Kroah-Hartman
@ 2021-10-19 18:18   ` Sergey Shtylyov
  1 sibling, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-19 18:18 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Alan Stern, Mathias Nyman

Hello!

On 10/19/21 8:41 AM, Greg Kroah-Hartman wrote:

>> Here are 22 patches against the 'usb-next' branch of Greg KH's 'usb.git' repo.
>> The affected drivers use platform_get_irq() which can return IRQ0 (considered
>> invalid, according to Linus) that means broken HCD when passed to usb_add_hcd()
>> called at the end of the probe methods. I think that the solution to this issue
>> is either explicitly deny or accept IRQ0 in usb_add_hcd()... /but/ here's this
>> patch set to get the things going...
> 
> Why not fix the root of the problem for your platform that is failing to
> assign a valid irq for the device?

   I'm just auditing the existing code, not developing on a new platform.
   (I also don't share Linus' opinion on IRQ0, TBH.)

> Are you going to make this change to all callers of this function in the
> kernel tree?

   No, only to those drivers that reinterpret IRQ0 as something other, e.g. polling
(only libata so far). No change needed to the subsystem that call request_irq() and
its ilk w/o filtering out IRQ0.

> thanks,
> 
> greg k-h

MBR, Sergey

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

* Re: [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers
  2021-10-19  7:31   ` Greg Kroah-Hartman
@ 2021-10-19 18:28     ` Sergey Shtylyov
  2021-10-19 18:35       ` Alan Stern
  0 siblings, 1 reply; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-19 18:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Alan Stern, Mathias Nyman

On 10/19/21 10:31 AM, Greg Kroah-Hartman wrote:

[...]
>>> Here are 22 patches against the 'usb-next' branch of Greg KH's 'usb.git' repo.
>>> The affected drivers use platform_get_irq() which can return IRQ0 (considered
>>> invalid, according to Linus) that means broken HCD when passed to usb_add_hcd()
>>> called at the end of the probe methods. I think that the solution to this issue
>>> is either explicitly deny or accept IRQ0 in usb_add_hcd()... /but/ here's this
>>> patch set to get the things going...
>>
>> Why not fix the root of the problem for your platform that is failing to
>> assign a valid irq for the device?
>>
>> Are you going to make this change to all callers of this function in the
>> kernel tree?
> 
> Also, you should have gotten a huge WARNING in your kernel log if this
> happens to let you know that something bad is going on.

   That's the relatively recent addition, yet it doesn't override IRQ0 to s/th
like -EINVAL.

> Is this patch
> series going to really change any of that?

   How? It doesn't touch drivers/base/platform.c...

> 
> What is the root problem here that you are trying to paper over with
> this patchset?

   As I said, it would be preferrable to either deny IRQ0 in usb_add_hcd() or
just don't try to filter it out. The real problem is that usb_add_hcd() does
add a non-functioning HCD without the necessary IRQ handling (it only hooks
an IRQ when it's non-zero).

> thanks,
> 
> greg k-h

MBR, Sergey

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

* Re: [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers
  2021-10-19 18:28     ` Sergey Shtylyov
@ 2021-10-19 18:35       ` Alan Stern
  2021-10-19 18:46         ` Sergey Shtylyov
  0 siblings, 1 reply; 57+ messages in thread
From: Alan Stern @ 2021-10-19 18:35 UTC (permalink / raw)
  To: Sergey Shtylyov; +Cc: Greg Kroah-Hartman, linux-usb, Mathias Nyman

On Tue, Oct 19, 2021 at 09:28:08PM +0300, Sergey Shtylyov wrote:
> On 10/19/21 10:31 AM, Greg Kroah-Hartman wrote:
> 
> [...]
> >>> Here are 22 patches against the 'usb-next' branch of Greg KH's 'usb.git' repo.
> >>> The affected drivers use platform_get_irq() which can return IRQ0 (considered
> >>> invalid, according to Linus) that means broken HCD when passed to usb_add_hcd()
> >>> called at the end of the probe methods. I think that the solution to this issue
> >>> is either explicitly deny or accept IRQ0 in usb_add_hcd()... /but/ here's this
> >>> patch set to get the things going...
> >>
> >> Why not fix the root of the problem for your platform that is failing to
> >> assign a valid irq for the device?
> >>
> >> Are you going to make this change to all callers of this function in the
> >> kernel tree?
> > 
> > Also, you should have gotten a huge WARNING in your kernel log if this
> > happens to let you know that something bad is going on.
> 
>    That's the relatively recent addition, yet it doesn't override IRQ0 to s/th
> like -EINVAL.
> 
> > Is this patch
> > series going to really change any of that?
> 
>    How? It doesn't touch drivers/base/platform.c...
> 
> > 
> > What is the root problem here that you are trying to paper over with
> > this patchset?
> 
>    As I said, it would be preferrable to either deny IRQ0 in usb_add_hcd() or
> just don't try to filter it out. The real problem is that usb_add_hcd() does
> add a non-functioning HCD without the necessary IRQ handling (it only hooks
> an IRQ when it's non-zero).

This is because some HCDs don't use interrupts (e.g., dummy-hcd).

Alan Stern

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

* Re: [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers
  2021-10-19 18:35       ` Alan Stern
@ 2021-10-19 18:46         ` Sergey Shtylyov
  2021-10-20 16:06           ` Sergey Shtylyov
  0 siblings, 1 reply; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-19 18:46 UTC (permalink / raw)
  To: Alan Stern; +Cc: Greg Kroah-Hartman, linux-usb, Mathias Nyman

On 10/19/21 9:35 PM, Alan Stern wrote:
[...]
>>>>> Here are 22 patches against the 'usb-next' branch of Greg KH's 'usb.git' repo.
>>>>> The affected drivers use platform_get_irq() which can return IRQ0 (considered
>>>>> invalid, according to Linus) that means broken HCD when passed to usb_add_hcd()
>>>>> called at the end of the probe methods. I think that the solution to this issue
>>>>> is either explicitly deny or accept IRQ0 in usb_add_hcd()... /but/ here's this
>>>>> patch set to get the things going...
>>>>
>>>> Why not fix the root of the problem for your platform that is failing to
>>>> assign a valid irq for the device?
>>>>
>>>> Are you going to make this change to all callers of this function in the
>>>> kernel tree?
>>>
>>> Also, you should have gotten a huge WARNING in your kernel log if this
>>> happens to let you know that something bad is going on.
>>
>>    That's the relatively recent addition, yet it doesn't override IRQ0 to s/th
>> like -EINVAL.
>>
>>> Is this patch
>>> series going to really change any of that?
>>
>>    How? It doesn't touch drivers/base/platform.c...
>>
>>>
>>> What is the root problem here that you are trying to paper over with
>>> this patchset?
>>
>>    As I said, it would be preferrable to either deny IRQ0 in usb_add_hcd() or
>> just don't try to filter it out. The real problem is that usb_add_hcd() does
>> add a non-functioning HCD without the necessary IRQ handling (it only hooks
>> an IRQ when it's non-zero).
> 
> This is because some HCDs don't use interrupts (e.g., dummy-hcd).

   Ah, that was the missing piece of a puzzle, thanks!
   This series doesn't have an alternative then (other than ignoring :-))...

> Alan Stern

MBR, Sergey

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

* Re: [PATCH 20/22] usb: host: xhci-mtk: deny IRQ0
  2021-10-18 18:39   ` Sergey Shtylyov
  (?)
@ 2021-10-20  7:32     ` Chunfeng Yun
  -1 siblings, 0 replies; 57+ messages in thread
From: Chunfeng Yun @ 2021-10-20  7:32 UTC (permalink / raw)
  To: Sergey Shtylyov, linux-usb, Mathias Nyman, Greg Kroah-Hartman
  Cc: Matthias Brugger, linux-arm-kernel, linux-mediatek

On Mon, 2021-10-18 at 21:39 +0300, Sergey Shtylyov wrote:
> If platform_get_irq() returns IRQ0 (considered invalid according to
> Linus)
> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no
> IRQ
> at all. Deny IRQ0 right away, returning -EINVAL from the probe()
> method...
> 
> Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host
> controller")
Fixes the following patch:

04284eb74e0c usb: xhci-mtk: add support runtime PM

It introduced the 'host' irq

> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> ---
>  drivers/usb/host/xhci-mtk.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-
> mtk.c
> index c53f6f276d5c..d2dc8d9863ee 100644
> --- a/drivers/usb/host/xhci-mtk.c
> +++ b/drivers/usb/host/xhci-mtk.c
> @@ -495,7 +495,7 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  		return ret;
>  
>  	irq = platform_get_irq_byname_optional(pdev, "host");
> -	if (irq < 0) {
> +	if (irq <= 0) {
>  		if (irq == -EPROBE_DEFER)
>  			return irq;
>  
> @@ -503,6 +503,8 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  		irq = platform_get_irq(pdev, 0);
>  		if (irq < 0)
>  			return irq;
> +		if (!irq)
if (irq <= 0) ?

Thanks

> +			return -EINVAL;
>  	}
>  
>  	wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");

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

* Re: [PATCH 20/22] usb: host: xhci-mtk: deny IRQ0
@ 2021-10-20  7:32     ` Chunfeng Yun
  0 siblings, 0 replies; 57+ messages in thread
From: Chunfeng Yun @ 2021-10-20  7:32 UTC (permalink / raw)
  To: Sergey Shtylyov, linux-usb, Mathias Nyman, Greg Kroah-Hartman
  Cc: Matthias Brugger, linux-arm-kernel, linux-mediatek

On Mon, 2021-10-18 at 21:39 +0300, Sergey Shtylyov wrote:
> If platform_get_irq() returns IRQ0 (considered invalid according to
> Linus)
> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no
> IRQ
> at all. Deny IRQ0 right away, returning -EINVAL from the probe()
> method...
> 
> Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host
> controller")
Fixes the following patch:

04284eb74e0c usb: xhci-mtk: add support runtime PM

It introduced the 'host' irq

> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> ---
>  drivers/usb/host/xhci-mtk.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-
> mtk.c
> index c53f6f276d5c..d2dc8d9863ee 100644
> --- a/drivers/usb/host/xhci-mtk.c
> +++ b/drivers/usb/host/xhci-mtk.c
> @@ -495,7 +495,7 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  		return ret;
>  
>  	irq = platform_get_irq_byname_optional(pdev, "host");
> -	if (irq < 0) {
> +	if (irq <= 0) {
>  		if (irq == -EPROBE_DEFER)
>  			return irq;
>  
> @@ -503,6 +503,8 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  		irq = platform_get_irq(pdev, 0);
>  		if (irq < 0)
>  			return irq;
> +		if (!irq)
if (irq <= 0) ?

Thanks

> +			return -EINVAL;
>  	}
>  
>  	wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 20/22] usb: host: xhci-mtk: deny IRQ0
@ 2021-10-20  7:32     ` Chunfeng Yun
  0 siblings, 0 replies; 57+ messages in thread
From: Chunfeng Yun @ 2021-10-20  7:32 UTC (permalink / raw)
  To: Sergey Shtylyov, linux-usb, Mathias Nyman, Greg Kroah-Hartman
  Cc: Matthias Brugger, linux-arm-kernel, linux-mediatek

On Mon, 2021-10-18 at 21:39 +0300, Sergey Shtylyov wrote:
> If platform_get_irq() returns IRQ0 (considered invalid according to
> Linus)
> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no
> IRQ
> at all. Deny IRQ0 right away, returning -EINVAL from the probe()
> method...
> 
> Fixes: 0cbd4b34cda9 ("xhci: mediatek: support MTK xHCI host
> controller")
Fixes the following patch:

04284eb74e0c usb: xhci-mtk: add support runtime PM

It introduced the 'host' irq

> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> ---
>  drivers/usb/host/xhci-mtk.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-
> mtk.c
> index c53f6f276d5c..d2dc8d9863ee 100644
> --- a/drivers/usb/host/xhci-mtk.c
> +++ b/drivers/usb/host/xhci-mtk.c
> @@ -495,7 +495,7 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  		return ret;
>  
>  	irq = platform_get_irq_byname_optional(pdev, "host");
> -	if (irq < 0) {
> +	if (irq <= 0) {
>  		if (irq == -EPROBE_DEFER)
>  			return irq;
>  
> @@ -503,6 +503,8 @@ static int xhci_mtk_probe(struct platform_device
> *pdev)
>  		irq = platform_get_irq(pdev, 0);
>  		if (irq < 0)
>  			return irq;
> +		if (!irq)
if (irq <= 0) ?

Thanks

> +			return -EINVAL;
>  	}
>  
>  	wakeup_irq = platform_get_irq_byname_optional(pdev, "wakeup");
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers
  2021-10-19 18:46         ` Sergey Shtylyov
@ 2021-10-20 16:06           ` Sergey Shtylyov
  0 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-20 16:06 UTC (permalink / raw)
  To: Alan Stern; +Cc: Greg Kroah-Hartman, linux-usb, Mathias Nyman

On 10/19/21 9:46 PM, Sergey Shtylyov wrote:
[...]
>>>>>> Here are 22 patches against the 'usb-next' branch of Greg KH's 'usb.git' repo.
>>>>>> The affected drivers use platform_get_irq() which can return IRQ0 (considered
>>>>>> invalid, according to Linus) that means broken HCD when passed to usb_add_hcd()
>>>>>> called at the end of the probe methods. I think that the solution to this issue
>>>>>> is either explicitly deny or accept IRQ0 in usb_add_hcd()... /but/ here's this
>>>>>> patch set to get the things going...
>>>>>
>>>>> Why not fix the root of the problem for your platform that is failing to
>>>>> assign a valid irq for the device?
>>>>>
>>>>> Are you going to make this change to all callers of this function in the
>>>>> kernel tree?
>>>>
>>>> Also, you should have gotten a huge WARNING in your kernel log if this
>>>> happens to let you know that something bad is going on.
>>>
>>>    That's the relatively recent addition, yet it doesn't override IRQ0 to s/th
>>> like -EINVAL.
>>>
>>>> Is this patch
>>>> series going to really change any of that?
>>>
>>>    How? It doesn't touch drivers/base/platform.c...
>>>
>>>>
>>>> What is the root problem here that you are trying to paper over with
>>>> this patchset?
>>>
>>>    As I said, it would be preferrable to either deny IRQ0 in usb_add_hcd() or
>>> just don't try to filter it out. The real problem is that usb_add_hcd() does
>>> add a non-functioning HCD without the necessary IRQ handling (it only hooks
>>> an IRQ when it's non-zero).
>>
>> This is because some HCDs don't use interrupts (e.g., dummy-hcd).
> 
>    Ah, that was the missing piece of a puzzle, thanks!

   And some drivers prefer to manage the IRQs themselves too.

>    This series doesn't have an alternative then (other than ignoring :-))...

   Or overriding IRQ0 to an error code in platform_get_irq(), finally, of/c...

MBR, Sergey

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

* Re: [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers
  2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
                   ` (23 preceding siblings ...)
  2021-10-19  5:41 ` Greg Kroah-Hartman
@ 2021-10-20 16:16 ` Greg Kroah-Hartman
  2021-10-20 18:50   ` Sergey Shtylyov
  24 siblings, 1 reply; 57+ messages in thread
From: Greg Kroah-Hartman @ 2021-10-20 16:16 UTC (permalink / raw)
  To: Sergey Shtylyov; +Cc: linux-usb, Alan Stern, Mathias Nyman

On Mon, Oct 18, 2021 at 09:39:08PM +0300, Sergey Shtylyov wrote:
> Here are 22 patches against the 'usb-next' branch of Greg KH's 'usb.git' repo.
> The affected drivers use platform_get_irq() which can return IRQ0 (considered
> invalid, according to Linus) that means broken HCD when passed to usb_add_hcd()
> called at the end of the probe methods. I think that the solution to this issue
> is either explicitly deny or accept IRQ0 in usb_add_hcd()... /but/ here's this
> patch set to get the things going...
> 
> Sergey Shtylyov (22):
>   usb: host: ehci-exynos: deny IRQ0
>   usb: host: ehci-mv: deny IRQ0
>   usb: host: ehci-npcm7xx: deny IRQ0
>   usb: host: ehci-omap: deny IRQ0
>   usb: host: ehci-platform: deny IRQ0
>   usb: host: ehci-spear: deny IRQ0
>   usb: host: ehci-st: deny IRQ0
>   usb: host: ohci-at91: deny IRQ0
>   usb: host: ohci-da8xx: deny IRQ0
>   usb: host: ohci-exynos: deny IRQ0
>   usb: host: ohci-at91: deny IRQ0
>   usb: host: ohci-omap: deny IRQ0
>   usb: host: ohci-platform: deny IRQ0
>   usb: host: ohci-pxa27x: deny IRQ0
>   usb: host: ohci-sm501: deny IRQ0
>   usb: host: ohci-spear: deny IRQ0
>   usb: host: ohci-st: deny IRQ0
>   usb: host: ohci-tmio: deny IRQ0
>   usb: host: xhci-histb: deny IRQ0
>   usb: host: xhci-mtk: deny IRQ0
>   usb: host: xhci-plat: deny IRQ0
>   usb: host: xhci-tegra: deny IRQ0
> 
>  drivers/usb/host/ehci-exynos.c   | 4 ++++
>  drivers/usb/host/ehci-mv.c       | 4 ++++
>  drivers/usb/host/ehci-npcm7xx.c  | 4 ++++
>  drivers/usb/host/ehci-omap.c     | 2 ++
>  drivers/usb/host/ehci-platform.c | 2 ++
>  drivers/usb/host/ehci-spear.c    | 4 ++++
>  drivers/usb/host/ehci-st.c       | 2 ++
>  drivers/usb/host/ohci-at91.c     | 2 ++
>  drivers/usb/host/ohci-da8xx.c    | 4 ++++
>  drivers/usb/host/ohci-exynos.c   | 4 ++++
>  drivers/usb/host/ohci-nxp.c      | 4 ++++
>  drivers/usb/host/ohci-omap.c     | 4 ++++
>  drivers/usb/host/ohci-platform.c | 2 ++
>  drivers/usb/host/ohci-pxa27x.c   | 2 ++
>  drivers/usb/host/ohci-sm501.c    | 4 ++++
>  drivers/usb/host/ohci-spear.c    | 4 ++++
>  drivers/usb/host/ohci-st.c       | 2 ++
>  drivers/usb/host/ohci-tmio.c     | 2 ++
>  drivers/usb/host/xhci-histb.c    | 2 ++
>  drivers/usb/host/xhci-mtk.c      | 4 +++-
>  drivers/usb/host/xhci-plat.c     | 2 ++
>  drivers/usb/host/xhci-tegra.c    | 2 ++
>  22 files changed, 65 insertions(+), 1 deletion(-)

Can you update and send a v2 for this series, with Alan's acks added to
the proper commits and fix up the other things that people have found?

thanks,

greg k-h

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

* Re: [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers
  2021-10-20 16:16 ` Greg Kroah-Hartman
@ 2021-10-20 18:50   ` Sergey Shtylyov
  0 siblings, 0 replies; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-20 18:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Alan Stern, Mathias Nyman

On 10/20/21 7:16 PM, Greg Kroah-Hartman wrote:
[...]
>> Here are 22 patches against the 'usb-next' branch of Greg KH's 'usb.git' repo.
>> The affected drivers use platform_get_irq() which can return IRQ0 (considered
>> invalid, according to Linus) that means broken HCD when passed to usb_add_hcd()
>> called at the end of the probe methods. I think that the solution to this issue
>> is either explicitly deny or accept IRQ0 in usb_add_hcd()... /but/ here's this
>> patch set to get the things going...

[...]

> Can you update and send a v2 for this series, with Alan's acks added to
> the proper commits and fix up the other things that people have found?

   OK, I'll try. Posting the patches with git for the 1st time, so somewhat
afraid to ruin something (which I've already done). :-)

> thanks,
> 
> greg k-h

MBR, Sergey

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

* Re: [PATCH 04/22] usb: host: ehci-omap: deny IRQ0
  2021-10-18 18:39 ` [PATCH 04/22] usb: host: ehci-omap: " Sergey Shtylyov
@ 2021-10-21  6:28     ` kernel test robot
  0 siblings, 0 replies; 57+ messages in thread
From: kernel test robot @ 2021-10-21  6:28 UTC (permalink / raw)
  To: Sergey Shtylyov, linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: llvm, kbuild-all, linux-omap

[-- Attachment #1: Type: text/plain, Size: 6967 bytes --]

Hi Sergey,

I love your patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v5.15-rc6 next-20211020]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Sergey-Shtylyov/Explicitly-deny-IRQ0-in-the-USB-host-drivers/20211019-024031
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: arm-randconfig-c002-20211021 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 3cea2505fd8d99a9ba0cb625aecfe28a47c4e3f8)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/0day-ci/linux/commit/cafbcf482dba9f0918ee071d03683bc2e8681d73
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Sergey-Shtylyov/Explicitly-deny-IRQ0-in-the-USB-host-drivers/20211019-024031
        git checkout cafbcf482dba9f0918ee071d03683bc2e8681d73
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/usb/host/ehci-omap.c:121:11: error: use of undeclared identifier 'ENIVAL'
                   return -ENIVAL;
                           ^
   1 error generated.


vim +/ENIVAL +121 drivers/usb/host/ehci-omap.c

    77	
    78	/**
    79	 * ehci_hcd_omap_probe - initialize TI-based HCDs
    80	 * @pdev: Pointer to this platform device's information
    81	 *
    82	 * Allocates basic resources for this USB host controller, and
    83	 * then invokes the start() method for the HCD associated with it
    84	 * through the hotplug entry's driver_data.
    85	 */
    86	static int ehci_hcd_omap_probe(struct platform_device *pdev)
    87	{
    88		struct device *dev = &pdev->dev;
    89		struct usbhs_omap_platform_data *pdata = dev_get_platdata(dev);
    90		struct resource	*res;
    91		struct usb_hcd	*hcd;
    92		void __iomem *regs;
    93		int ret;
    94		int irq;
    95		int i;
    96		struct omap_hcd	*omap;
    97	
    98		if (usb_disabled())
    99			return -ENODEV;
   100	
   101		if (!dev->parent) {
   102			dev_err(dev, "Missing parent device\n");
   103			return -ENODEV;
   104		}
   105	
   106		/* For DT boot, get platform data from parent. i.e. usbhshost */
   107		if (dev->of_node) {
   108			pdata = dev_get_platdata(dev->parent);
   109			dev->platform_data = pdata;
   110		}
   111	
   112		if (!pdata) {
   113			dev_err(dev, "Missing platform data\n");
   114			return -ENODEV;
   115		}
   116	
   117		irq = platform_get_irq(pdev, 0);
   118		if (irq < 0)
   119			return irq;
   120		if (!irq)
 > 121			return -ENIVAL;
   122	
   123		res =  platform_get_resource(pdev, IORESOURCE_MEM, 0);
   124		regs = devm_ioremap_resource(dev, res);
   125		if (IS_ERR(regs))
   126			return PTR_ERR(regs);
   127	
   128		/*
   129		 * Right now device-tree probed devices don't get dma_mask set.
   130		 * Since shared usb code relies on it, set it here for now.
   131		 * Once we have dma capability bindings this can go away.
   132		 */
   133		ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
   134		if (ret)
   135			return ret;
   136	
   137		ret = -ENODEV;
   138		hcd = usb_create_hcd(&ehci_omap_hc_driver, dev,
   139				dev_name(dev));
   140		if (!hcd) {
   141			dev_err(dev, "Failed to create HCD\n");
   142			return -ENOMEM;
   143		}
   144	
   145		hcd->rsrc_start = res->start;
   146		hcd->rsrc_len = resource_size(res);
   147		hcd->regs = regs;
   148		hcd_to_ehci(hcd)->caps = regs;
   149	
   150		omap = (struct omap_hcd *)hcd_to_ehci(hcd)->priv;
   151		omap->nports = pdata->nports;
   152	
   153		platform_set_drvdata(pdev, hcd);
   154	
   155		/* get the PHY devices if needed */
   156		for (i = 0 ; i < omap->nports ; i++) {
   157			struct usb_phy *phy;
   158	
   159			/* get the PHY device */
   160			phy = devm_usb_get_phy_by_phandle(dev, "phys", i);
   161			if (IS_ERR(phy)) {
   162				ret = PTR_ERR(phy);
   163				if (ret == -ENODEV) { /* no PHY */
   164					phy = NULL;
   165					continue;
   166				}
   167	
   168				if (ret != -EPROBE_DEFER)
   169					dev_err(dev, "Can't get PHY for port %d: %d\n",
   170						i, ret);
   171				goto err_phy;
   172			}
   173	
   174			omap->phy[i] = phy;
   175	
   176			if (pdata->port_mode[i] == OMAP_EHCI_PORT_MODE_PHY) {
   177				usb_phy_init(omap->phy[i]);
   178				/* bring PHY out of suspend */
   179				usb_phy_set_suspend(omap->phy[i], 0);
   180			}
   181		}
   182	
   183		pm_runtime_enable(dev);
   184		pm_runtime_get_sync(dev);
   185	
   186		/*
   187		 * An undocumented "feature" in the OMAP3 EHCI controller,
   188		 * causes suspended ports to be taken out of suspend when
   189		 * the USBCMD.Run/Stop bit is cleared (for example when
   190		 * we do ehci_bus_suspend).
   191		 * This breaks suspend-resume if the root-hub is allowed
   192		 * to suspend. Writing 1 to this undocumented register bit
   193		 * disables this feature and restores normal behavior.
   194		 */
   195		ehci_write(regs, EHCI_INSNREG04,
   196					EHCI_INSNREG04_DISABLE_UNSUSPEND);
   197	
   198		ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
   199		if (ret) {
   200			dev_err(dev, "failed to add hcd with err %d\n", ret);
   201			goto err_pm_runtime;
   202		}
   203		device_wakeup_enable(hcd->self.controller);
   204	
   205		/*
   206		 * Bring PHYs out of reset for non PHY modes.
   207		 * Even though HSIC mode is a PHY-less mode, the reset
   208		 * line exists between the chips and can be modelled
   209		 * as a PHY device for reset control.
   210		 */
   211		for (i = 0; i < omap->nports; i++) {
   212			if (!omap->phy[i] ||
   213			     pdata->port_mode[i] == OMAP_EHCI_PORT_MODE_PHY)
   214				continue;
   215	
   216			usb_phy_init(omap->phy[i]);
   217			/* bring PHY out of suspend */
   218			usb_phy_set_suspend(omap->phy[i], 0);
   219		}
   220	
   221		return 0;
   222	
   223	err_pm_runtime:
   224		pm_runtime_put_sync(dev);
   225		pm_runtime_disable(dev);
   226	
   227	err_phy:
   228		for (i = 0; i < omap->nports; i++) {
   229			if (omap->phy[i])
   230				usb_phy_shutdown(omap->phy[i]);
   231		}
   232	
   233		usb_put_hcd(hcd);
   234	
   235		return ret;
   236	}
   237	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30132 bytes --]

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

* Re: [PATCH 04/22] usb: host: ehci-omap: deny IRQ0
@ 2021-10-21  6:28     ` kernel test robot
  0 siblings, 0 replies; 57+ messages in thread
From: kernel test robot @ 2021-10-21  6:28 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 7174 bytes --]

Hi Sergey,

I love your patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on v5.15-rc6 next-20211020]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Sergey-Shtylyov/Explicitly-deny-IRQ0-in-the-USB-host-drivers/20211019-024031
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: arm-randconfig-c002-20211021 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 3cea2505fd8d99a9ba0cb625aecfe28a47c4e3f8)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/0day-ci/linux/commit/cafbcf482dba9f0918ee071d03683bc2e8681d73
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Sergey-Shtylyov/Explicitly-deny-IRQ0-in-the-USB-host-drivers/20211019-024031
        git checkout cafbcf482dba9f0918ee071d03683bc2e8681d73
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/usb/host/ehci-omap.c:121:11: error: use of undeclared identifier 'ENIVAL'
                   return -ENIVAL;
                           ^
   1 error generated.


vim +/ENIVAL +121 drivers/usb/host/ehci-omap.c

    77	
    78	/**
    79	 * ehci_hcd_omap_probe - initialize TI-based HCDs
    80	 * @pdev: Pointer to this platform device's information
    81	 *
    82	 * Allocates basic resources for this USB host controller, and
    83	 * then invokes the start() method for the HCD associated with it
    84	 * through the hotplug entry's driver_data.
    85	 */
    86	static int ehci_hcd_omap_probe(struct platform_device *pdev)
    87	{
    88		struct device *dev = &pdev->dev;
    89		struct usbhs_omap_platform_data *pdata = dev_get_platdata(dev);
    90		struct resource	*res;
    91		struct usb_hcd	*hcd;
    92		void __iomem *regs;
    93		int ret;
    94		int irq;
    95		int i;
    96		struct omap_hcd	*omap;
    97	
    98		if (usb_disabled())
    99			return -ENODEV;
   100	
   101		if (!dev->parent) {
   102			dev_err(dev, "Missing parent device\n");
   103			return -ENODEV;
   104		}
   105	
   106		/* For DT boot, get platform data from parent. i.e. usbhshost */
   107		if (dev->of_node) {
   108			pdata = dev_get_platdata(dev->parent);
   109			dev->platform_data = pdata;
   110		}
   111	
   112		if (!pdata) {
   113			dev_err(dev, "Missing platform data\n");
   114			return -ENODEV;
   115		}
   116	
   117		irq = platform_get_irq(pdev, 0);
   118		if (irq < 0)
   119			return irq;
   120		if (!irq)
 > 121			return -ENIVAL;
   122	
   123		res =  platform_get_resource(pdev, IORESOURCE_MEM, 0);
   124		regs = devm_ioremap_resource(dev, res);
   125		if (IS_ERR(regs))
   126			return PTR_ERR(regs);
   127	
   128		/*
   129		 * Right now device-tree probed devices don't get dma_mask set.
   130		 * Since shared usb code relies on it, set it here for now.
   131		 * Once we have dma capability bindings this can go away.
   132		 */
   133		ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
   134		if (ret)
   135			return ret;
   136	
   137		ret = -ENODEV;
   138		hcd = usb_create_hcd(&ehci_omap_hc_driver, dev,
   139				dev_name(dev));
   140		if (!hcd) {
   141			dev_err(dev, "Failed to create HCD\n");
   142			return -ENOMEM;
   143		}
   144	
   145		hcd->rsrc_start = res->start;
   146		hcd->rsrc_len = resource_size(res);
   147		hcd->regs = regs;
   148		hcd_to_ehci(hcd)->caps = regs;
   149	
   150		omap = (struct omap_hcd *)hcd_to_ehci(hcd)->priv;
   151		omap->nports = pdata->nports;
   152	
   153		platform_set_drvdata(pdev, hcd);
   154	
   155		/* get the PHY devices if needed */
   156		for (i = 0 ; i < omap->nports ; i++) {
   157			struct usb_phy *phy;
   158	
   159			/* get the PHY device */
   160			phy = devm_usb_get_phy_by_phandle(dev, "phys", i);
   161			if (IS_ERR(phy)) {
   162				ret = PTR_ERR(phy);
   163				if (ret == -ENODEV) { /* no PHY */
   164					phy = NULL;
   165					continue;
   166				}
   167	
   168				if (ret != -EPROBE_DEFER)
   169					dev_err(dev, "Can't get PHY for port %d: %d\n",
   170						i, ret);
   171				goto err_phy;
   172			}
   173	
   174			omap->phy[i] = phy;
   175	
   176			if (pdata->port_mode[i] == OMAP_EHCI_PORT_MODE_PHY) {
   177				usb_phy_init(omap->phy[i]);
   178				/* bring PHY out of suspend */
   179				usb_phy_set_suspend(omap->phy[i], 0);
   180			}
   181		}
   182	
   183		pm_runtime_enable(dev);
   184		pm_runtime_get_sync(dev);
   185	
   186		/*
   187		 * An undocumented "feature" in the OMAP3 EHCI controller,
   188		 * causes suspended ports to be taken out of suspend when
   189		 * the USBCMD.Run/Stop bit is cleared (for example when
   190		 * we do ehci_bus_suspend).
   191		 * This breaks suspend-resume if the root-hub is allowed
   192		 * to suspend. Writing 1 to this undocumented register bit
   193		 * disables this feature and restores normal behavior.
   194		 */
   195		ehci_write(regs, EHCI_INSNREG04,
   196					EHCI_INSNREG04_DISABLE_UNSUSPEND);
   197	
   198		ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
   199		if (ret) {
   200			dev_err(dev, "failed to add hcd with err %d\n", ret);
   201			goto err_pm_runtime;
   202		}
   203		device_wakeup_enable(hcd->self.controller);
   204	
   205		/*
   206		 * Bring PHYs out of reset for non PHY modes.
   207		 * Even though HSIC mode is a PHY-less mode, the reset
   208		 * line exists between the chips and can be modelled
   209		 * as a PHY device for reset control.
   210		 */
   211		for (i = 0; i < omap->nports; i++) {
   212			if (!omap->phy[i] ||
   213			     pdata->port_mode[i] == OMAP_EHCI_PORT_MODE_PHY)
   214				continue;
   215	
   216			usb_phy_init(omap->phy[i]);
   217			/* bring PHY out of suspend */
   218			usb_phy_set_suspend(omap->phy[i], 0);
   219		}
   220	
   221		return 0;
   222	
   223	err_pm_runtime:
   224		pm_runtime_put_sync(dev);
   225		pm_runtime_disable(dev);
   226	
   227	err_phy:
   228		for (i = 0; i < omap->nports; i++) {
   229			if (omap->phy[i])
   230				usb_phy_shutdown(omap->phy[i]);
   231		}
   232	
   233		usb_put_hcd(hcd);
   234	
   235		return ret;
   236	}
   237	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 30132 bytes --]

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

* Re: [PATCH 22/22] usb: host: xhci-tegra: deny IRQ0
  2021-10-18 18:39 ` [PATCH 22/22] usb: host: xhci-tegra: " Sergey Shtylyov
@ 2021-10-21  9:09   ` Dmitry Osipenko
  2021-10-26 18:24     ` Sergey Shtylyov
  0 siblings, 1 reply; 57+ messages in thread
From: Dmitry Osipenko @ 2021-10-21  9:09 UTC (permalink / raw)
  To: Sergey Shtylyov, linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Thierry Reding, Jonathan Hunter, linux-tegra

18.10.2021 21:39, Sergey Shtylyov пишет:
> If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
> at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...
> 
> Fixes: e84fce0f8837 ("usb: xhci: Add NVIDIA Tegra XUSB controller driver")
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> ---
>  drivers/usb/host/xhci-tegra.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
> index 1bf494b649bd..7151b1d4f876 100644
> --- a/drivers/usb/host/xhci-tegra.c
> +++ b/drivers/usb/host/xhci-tegra.c
> @@ -1439,6 +1439,8 @@ static int tegra_xusb_probe(struct platform_device *pdev)
>  	tegra->xhci_irq = platform_get_irq(pdev, 0);
>  	if (tegra->xhci_irq < 0)
>  		return tegra->xhci_irq;
> +	if (!tegra->xhci_irq)
> +		return -ENIVAL;
>  
>  	tegra->mbox_irq = platform_get_irq(pdev, 1);
>  	if (tegra->mbox_irq < 0)
> 

platform_get_irq() never returns zero in accordance to [1], but I see
that it can return it [2]. Should be better to fix [2] and return -EINVAL.

[1]
https://elixir.bootlin.com/linux/v5.15-rc6/source/drivers/base/platform.c#L254

[2]
https://elixir.bootlin.com/linux/v5.15-rc6/source/drivers/base/platform.c#L226

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

* Re: [PATCH 22/22] usb: host: xhci-tegra: deny IRQ0
  2021-10-21  9:09   ` Dmitry Osipenko
@ 2021-10-26 18:24     ` Sergey Shtylyov
  2021-10-27 11:13       ` Dmitry Osipenko
  0 siblings, 1 reply; 57+ messages in thread
From: Sergey Shtylyov @ 2021-10-26 18:24 UTC (permalink / raw)
  To: Dmitry Osipenko, linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Thierry Reding, Jonathan Hunter, linux-tegra

Hello!

On 10/21/21 12:09 PM, Dmitry Osipenko wrote:
[...]
>> If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
>> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
>> at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...
>>
>> Fixes: e84fce0f8837 ("usb: xhci: Add NVIDIA Tegra XUSB controller driver")
>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>> ---
>>  drivers/usb/host/xhci-tegra.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
>> index 1bf494b649bd..7151b1d4f876 100644
>> --- a/drivers/usb/host/xhci-tegra.c
>> +++ b/drivers/usb/host/xhci-tegra.c
>> @@ -1439,6 +1439,8 @@ static int tegra_xusb_probe(struct platform_device *pdev)
>>  	tegra->xhci_irq = platform_get_irq(pdev, 0);
>>  	if (tegra->xhci_irq < 0)
>>  		return tegra->xhci_irq;
>> +	if (!tegra->xhci_irq)
>> +		return -ENIVAL;
>>  
>>  	tegra->mbox_irq = platform_get_irq(pdev, 1);
>>  	if (tegra->mbox_irq < 0)
>>
> 
> platform_get_irq() never returns zero in accordance to [1], but I see
> that it can return it [2].

   Not only that, it also can be returned thru the normal path (from an IRQ descriptor).
I'm not sure whether 0 means an IRQ0 returned from acpi_dev_gpio_irq_get(), looks like yes...

> Should be better to fix [2] and return -EINVAL.

   No, we have WARN() before returning IRQ0 -- if we're going to finally declare IRQ0 invalid,
it should be done after this check.

> [1]
> https://elixir.bootlin.com/linux/v5.15-rc6/source/drivers/base/platform.c#L254
> 
> [2]
> https://elixir.bootlin.com/linux/v5.15-rc6/source/drivers/base/platform.c#L226

MBR, Sergey

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

* Re: [PATCH 22/22] usb: host: xhci-tegra: deny IRQ0
  2021-10-26 18:24     ` Sergey Shtylyov
@ 2021-10-27 11:13       ` Dmitry Osipenko
  0 siblings, 0 replies; 57+ messages in thread
From: Dmitry Osipenko @ 2021-10-27 11:13 UTC (permalink / raw)
  To: Sergey Shtylyov, linux-usb, Alan Stern, Greg Kroah-Hartman
  Cc: Thierry Reding, Jonathan Hunter, linux-tegra

26.10.2021 21:24, Sergey Shtylyov пишет:
> Hello!
> 
> On 10/21/21 12:09 PM, Dmitry Osipenko wrote:
> [...]
>>> If platform_get_irq() returns IRQ0 (considered invalid according to Linus)
>>> the driver blithely passes it to usb_add_hcd() that treats IRQ0 as no IRQ
>>> at all. Deny IRQ0 right away, returning -EINVAL from the probe() method...
>>>
>>> Fixes: e84fce0f8837 ("usb: xhci: Add NVIDIA Tegra XUSB controller driver")
>>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>>> ---
>>>  drivers/usb/host/xhci-tegra.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
>>> index 1bf494b649bd..7151b1d4f876 100644
>>> --- a/drivers/usb/host/xhci-tegra.c
>>> +++ b/drivers/usb/host/xhci-tegra.c
>>> @@ -1439,6 +1439,8 @@ static int tegra_xusb_probe(struct platform_device *pdev)
>>>  	tegra->xhci_irq = platform_get_irq(pdev, 0);
>>>  	if (tegra->xhci_irq < 0)
>>>  		return tegra->xhci_irq;
>>> +	if (!tegra->xhci_irq)
>>> +		return -ENIVAL;
>>>  
>>>  	tegra->mbox_irq = platform_get_irq(pdev, 1);
>>>  	if (tegra->mbox_irq < 0)
>>>
>>
>> platform_get_irq() never returns zero in accordance to [1], but I see
>> that it can return it [2].
> 
>    Not only that, it also can be returned thru the normal path (from an IRQ descriptor).
> I'm not sure whether 0 means an IRQ0 returned from acpi_dev_gpio_irq_get(), looks like yes...
> 
>> Should be better to fix [2] and return -EINVAL.
> 
>    No, we have WARN() before returning IRQ0 -- if we're going to finally declare IRQ0 invalid,
> it should be done after this check.

Warning is already explicitly saying that IRQ0 is invalid, hence IRQ0
*is* declared invalid. Either doc comment or function itself is wrong,
both are bad.

If function is wrong, then you're fixing symptom instead of fixing the
root of the problem.

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

end of thread, other threads:[~2021-10-27 11:13 UTC | newest]

Thread overview: 57+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18 18:39 [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 01/22] usb: host: ehci-exynos: deny IRQ0 Sergey Shtylyov
2021-10-18 18:39   ` Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 02/22] usb: host: ehci-mv: " Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 03/22] usb: host: ehci-npcm7xx: " Sergey Shtylyov
2021-10-18 18:39   ` Sergey Shtylyov
2021-10-19  7:11   ` Avi Fishman
2021-10-19  7:11     ` Avi Fishman
2021-10-18 18:39 ` [PATCH 04/22] usb: host: ehci-omap: " Sergey Shtylyov
2021-10-21  6:28   ` kernel test robot
2021-10-21  6:28     ` kernel test robot
2021-10-18 18:39 ` [PATCH 05/22] usb: host: ehci-platform: " Sergey Shtylyov
2021-10-18 18:39   ` Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 06/22] usb: host: ehci-spear: " Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 07/22] usb: host: ehci-st: " Sergey Shtylyov
2021-10-18 18:39   ` Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 08/22] usb: host: ohci-at91: " Sergey Shtylyov
2021-10-18 18:39   ` Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 09/22] usb: host: ohci-da8xx: " Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 10/22] usb: host: ohci-exynos: " Sergey Shtylyov
2021-10-18 18:39   ` Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 11/22] usb: host: ohci-at91: " Sergey Shtylyov
2021-10-18 18:39   ` Sergey Shtylyov
2021-10-19 11:15   ` Alexander Dahl
2021-10-19 11:15     ` Alexander Dahl
2021-10-19 16:51     ` Sergey Shtylyov
2021-10-19 16:51       ` Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 12/22] usb: host: ohci-omap: " Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 13/22] usb: host: ohci-platform: " Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 14/22] usb: host: ohci-pxa27x: " Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 15/22] usb: host: ohci-sm501: " Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 16/22] usb: host: ohci-spear: " Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 17/22] usb: host: ohci-st: " Sergey Shtylyov
2021-10-18 18:39   ` Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 18/22] usb: host: ohci-tmio: " Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 19/22] usb: host: xhci-histb: " Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 20/22] usb: host: xhci-mtk: " Sergey Shtylyov
2021-10-18 18:39   ` Sergey Shtylyov
2021-10-18 18:39   ` Sergey Shtylyov
2021-10-20  7:32   ` Chunfeng Yun
2021-10-20  7:32     ` Chunfeng Yun
2021-10-20  7:32     ` Chunfeng Yun
2021-10-18 18:39 ` [PATCH 21/22] usb: host: xhci-plat: " Sergey Shtylyov
2021-10-18 18:39 ` [PATCH 22/22] usb: host: xhci-tegra: " Sergey Shtylyov
2021-10-21  9:09   ` Dmitry Osipenko
2021-10-26 18:24     ` Sergey Shtylyov
2021-10-27 11:13       ` Dmitry Osipenko
2021-10-19  1:35 ` [PATCH 00/22] Explicitly deny IRQ0 in the USB host drivers Alan Stern
2021-10-19  5:41 ` Greg Kroah-Hartman
2021-10-19  7:31   ` Greg Kroah-Hartman
2021-10-19 18:28     ` Sergey Shtylyov
2021-10-19 18:35       ` Alan Stern
2021-10-19 18:46         ` Sergey Shtylyov
2021-10-20 16:06           ` Sergey Shtylyov
2021-10-19 18:18   ` Sergey Shtylyov
2021-10-20 16:16 ` Greg Kroah-Hartman
2021-10-20 18:50   ` Sergey Shtylyov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.