usb: musb-new: sunxi: Fix null pointer access
Subsystems (2)
PATCH 1/1 usb: musb-new: sunxi: Fix null pointer access
When the device is in peripheral mode there is no struct usb_bus_priv allocated pointer, as the uclass driver ("usb_dev_generic") doesn't call per_device_auto_alloc_size.
This results in writing to the internal SDRAM at
priv->desc_before_addr = true;
--- drivers/usb/musb-new/sunxi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/musb-new/sunxi.c +6 -2
@@ -435,11 +435,14 @@ static int musb_usb_probe(struct udevice *dev) {struct sunxi_glue *glue =dev_get_priv (dev);struct musb_host_data *host = &glue->mdata; -struct usb_bus_priv *priv =dev_get_uclass_priv (dev);struct musb_hdrc_platform_data pdata;void *base =dev_read_addr_ptr (dev);int ret; +#ifdef CONFIG_USB_MUSB_HOST +struct usb_bus_priv *priv =dev_get_uclass_priv (dev); +#endif +if (!base)return -EINVAL ;
@@ -459,7 +462,6 @@ static int musb_usb_probe(struct udevice *dev)return ret; } - priv->desc_before_addr = true;memset (&pdata,0 ,sizeof (pdata)); pdata.power =250 ;
@@ -467,6 +469,8 @@ static int musb_usb_probe(struct udevice *dev) pdata.config = glue->cfg->config;#ifdef CONFIG_USB_MUSB_HOST + priv->desc_before_addr = true; + pdata.mode =MUSB_HOST ; host->host =musb_init_controller (&pdata, &glue->dev, base);if (!host->host)
Signature · 1 line
2.17.1
PATCH 1/1 usb: musb-new: sunxi: Fix null pointer access
Quoted 1 line · Stefan Mavrodiev
When the device is in peripheral mode
Can you have two devices, one in peripheral mode and one in host mode, on the same system ?
Quoted 33 lines
there is no
structusb_bus_privallocated pointer, as the uclass driver ("usb_dev_generic") doesn't callper_device_auto_alloc_size.This results in writing to the internal SDRAM at
priv->desc_before_addr = true;Signed-off-by Stefan Mavrodiev <[email protected]>--- drivers/usb/musb-new/sunxi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/usb/musb-new/sunxi.c +4
-1@@ -435,11 +435,14 @@ static int musb_usb_probe(struct udevice *dev) {struct sunxi_glue *glue =dev_get_priv (dev);struct musb_host_data *host = &glue->mdata; -struct usb_bus_priv *priv =dev_get_uclass_priv (dev);struct musb_hdrc_platform_data pdata;void *base =dev_read_addr_ptr (dev);int ret; +#ifdef CONFIG_USB_MUSB_HOST +struct usb_bus_priv *priv =dev_get_uclass_priv (dev); +#endif +if (!base)return -EINVAL ;
drivers/usb/musb-new/sunxi.c static int musb_usb_probe(struct udevice *dev) · line 462
Quoted 4 lines
drivers/usb/musb-new/sunxi.c +0
-1@@ -459,7 +462,6 @@ static int musb_usb_probe(struct udevice *dev)return ret; } - priv->desc_before_addr = true;
See my question at the beginning, and if that can be the case, the fix is to check if priv is not null here, eg.
if (priv)
priv->...
Still, why is the priv data not allocated for device ?
Quoted 12 lines
drivers/usb/musb-new/sunxi.c +2
-0memset (&pdata,0 ,sizeof (pdata)); pdata.power =250 ;@@ -467,6 +469,8 @@ static int musb_usb_probe(struct udevice *dev) pdata.config = glue->cfg->config;#ifdef CONFIG_USB_MUSB_HOST + priv->desc_before_addr = true; + pdata.mode =MUSB_HOST ; host->host =musb_init_controller (&pdata, &glue->dev, base);if (!host->host)
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 usb: musb-new: sunxi: Fix null pointer access
Quoted 4 lines · Marek Vasut
Quoted 1 line · Stefan Mavrodiev
When the device is in peripheral mode
Can you have two devices, one in peripheral mode and one in host mode, on the same system ?
Not 100% sure, but I'm thinking there is only one OTG port for all sunxi boards. The operation is decided in the Kconfig.
Quoted 37 lines
Quoted 37 lines
there is no
structusb_bus_privallocated pointer, as the uclass driver ("usb_dev_generic") doesn't callper_device_auto_alloc_size.This results in writing to the internal SDRAM at
priv->desc_before_addr = true;Signed-off-by Stefan Mavrodiev <[email protected]>--- drivers/usb/musb-new/sunxi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/usb/musb-new/sunxi.c +4
-1@@ -435,11 +435,14 @@ static int musb_usb_probe(struct udevice *dev) {struct sunxi_glue *glue =dev_get_priv (dev);struct musb_host_data *host = &glue->mdata; -struct usb_bus_priv *priv =dev_get_uclass_priv (dev);struct musb_hdrc_platform_data pdata;void *base =dev_read_addr_ptr (dev);int ret; +#ifdef CONFIG_USB_MUSB_HOST +struct usb_bus_priv *priv =dev_get_uclass_priv (dev); +#endif +if (!base)return -EINVAL ;@@ -459,7 +462,6 @@ static int musb_usb_probe(struct udevice *dev)return ret; }
Quoted 7 lines
drivers/usb/musb-new/sunxi.c static int musb_usb_probe(struct udevice *dev) · line 462
Quoted 1 line
drivers/usb/musb-new/sunxi.c +0
-1- priv->desc_before_addr = true;See my question at the beginning, and if that can be the case, the fix is to check if priv is not null here, eg.
if (priv)
priv->...Still, why is the priv data not allocated for device ?
Depending on configuration, the device is registered ether as UCLASS_USB_DEV_GENERIC or UCLASS_USB. There is no
.per_device_auto_alloc_size = sizeof(struct usb_bus_priv),
for the second. (As seen in drivers/usb/host/usb-uclass.c)
Quoted 14 lines
Quoted 13 lines
drivers/usb/musb-new/sunxi.c +2
-0memset (&pdata,0 ,sizeof (pdata)); pdata.power =250 ;@@ -467,6 +469,8 @@ static int musb_usb_probe(struct udevice *dev) pdata.config = glue->cfg->config;#ifdef CONFIG_USB_MUSB_HOST + priv->desc_before_addr = true; + pdata.mode =MUSB_HOST ; host->host =musb_init_controller (&pdata, &glue->dev, base);if (!host->host)
PATCH 1/1 usb: musb-new: sunxi: Fix null pointer access
Quoted 9 lines · Stefan Mavrodiev
Quoted 4 lines · Marek Vasut
Quoted 1 line · Stefan Mavrodiev
When the device is in peripheral mode
Can you have two devices, one in peripheral mode and one in host mode, on the same system ?
Not 100% sure, but I'm thinking there is only one OTG port for all sunxi boards. The operation is decided in the
Kconfig.
I'm rather sure I saw sunxi boards with more than one USB port.
Quoted 39 lines
Quoted 39 lines
Quoted 28 lines
there is no
structusb_bus_privallocated pointer, as the uclass driver ("usb_dev_generic") doesn't callper_device_auto_alloc_size.This results in writing to the internal SDRAM at
priv->desc_before_addr = true;Signed-off-by Stefan Mavrodiev <[email protected]>---
drivers/usb/musb-new/sunxi.c| 8 ++++++--1 file changed, 6 insertions(+), 2 deletions(-)drivers/usb/musb-new/sunxi.c +0
-1@@ -435,11 +435,14 @@ static int musb_usb_probe(struct udevice *dev) { struct sunxi_glue *glue = dev_get_priv(dev); struct musb_host_data *host = &glue->mdata; - struct usb_bus_priv *priv = dev_get_uclass_priv(dev); struct musb_hdrc_platform_data pdata; void *base = dev_read_addr_ptr(dev); int ret;+#ifdef
CONFIG_USB_MUSB_HOST
+ structusb_bus_priv*priv =dev_get_uclass_priv(dev);drivers/usb/musb-new/sunxi.c +2
-0+#endif +Quoted 6 lines
if (!base)
return-EINVAL;
@@ -459,7 +462,6 @@ static intmusb_usb_probe(struct udevice *dev)return ret;
}
-priv->desc_before_addr= true;See my question at the beginning, and if that can be the case, the fix is to check if priv is not null here, eg.
if (priv)
priv->...
Quoted 8 lines
Quoted 1 line
Still, why is the priv data not allocated for device ?
Depending on configuration, the device is registered ether as
UCLASS_USB_DEV_GENERICorUCLASS_USB. There is no.per_device_auto_alloc_size =
sizeof(struct usb_bus_priv),for the second. (As seen in
drivers/usb/host/usb-uclass.c)
I see the code is rather horrible. I'd expect all that configuration to come from DT otg-mode property instead of being hard-wired into the code. Sigh.
Jagan, A-B ? I'd like to pick this .
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
memset(&pdata, 0, sizeof(pdata));
pdata.power = 250;drivers/usb/musb-new/sunxi.c +2
-0@@ -467,6 +469,8 @@ static int musb_usb_probe(struct udevice *dev) pdata.config = glue->cfg->config; #ifdef CONFIG_USB_MUSB_HOST + priv->desc_before_addr = true; + pdata.mode = MUSB_HOST; host->host = musb_init_controller(&pdata, &glue->dev, base); if (!host->host)
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 usb: musb-new: sunxi: Fix null pointer access
Quoted 62 lines · Marek Vasut
Quoted 7 lines · Stefan Mavrodiev
Quoted 4 lines · Marek Vasut
Quoted 1 line · Stefan Mavrodiev
When the device is in peripheral mode
Can you have two devices, one in peripheral mode and one in host mode, on the same system ?
Not 100% sure, but I'm thinking there is only one OTG port for all sunxi boards. The operation is decided in the
Kconfig.I'm rather sure I saw sunxi boards with more than one USB port.
Quoted 39 lines
Quoted 39 lines
Quoted 24 lines
there is no
structusb_bus_privallocated pointer, as the uclass driver ("usb_dev_generic") doesn't callper_device_auto_alloc_size.This results in writing to the internal SDRAM at
priv->desc_before_addr = true;Signed-off-by Stefan Mavrodiev <[email protected]>--- drivers/usb/musb-new/sunxi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/usb/musb-new/sunxi.c +0
-1@@ -435,11 +435,14 @@ static int musb_usb_probe(struct udevice *dev) { struct sunxi_glue *glue = dev_get_priv(dev); struct musb_host_data *host = &glue->mdata; - struct usb_bus_priv *priv = dev_get_uclass_priv(dev); struct musb_hdrc_platform_data pdata; void *base = dev_read_addr_ptr(dev); int ret;drivers/usb/musb-new/sunxi.c static int musb_usb_probe(struct udevice *dev)
Quoted 10 lines
drivers/usb/musb-new/sunxi.c +3
-0+#ifdef CONFIG_USB_MUSB_HOST + struct usb_bus_priv *priv = dev_get_uclass_priv(dev); +#endif + if (!base) return -EINVAL; @@ -459,7 +462,6 @@ static int musb_usb_probe(struct udevice *dev) return ret; } - priv->desc_before_addr = true;See my question at the beginning, and if that can be the case, the fix is to check if priv is not null here, eg.
if (priv)
priv->...Quoted 7 lines
Quoted 1 line
Still, why is the priv data not allocated for device ?
Depending on configuration, the device is registered ether as
UCLASS_USB_DEV_GENERICorUCLASS_USB. There is no.per_device_auto_alloc_size =
sizeof(struct usb_bus_priv),for the second. (As seen in
drivers/usb/host/usb-uclass.c)I see the code is rather horrible. I'd expect all that configuration to come from DT otg-mode property instead of being hard-wired into the code. Sigh.
Jagan, A-B ? I'd like to pick this .
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
drivers/usb/musb-new/sunxi.c static int musb_usb_probe(struct udevice *dev) · line 476
Quoted 11 lines
memset(&pdata, 0, sizeof(pdata));
pdata.power = 250;drivers/usb/musb-new/sunxi.c +2
-0@@ -467,6 +469,8 @@ static int musb_usb_probe(struct udevice *dev) pdata.config = glue->cfg->config; #ifdef CONFIG_USB_MUSB_HOST + priv->desc_before_addr = true; + pdata.mode = MUSB_HOST; host->host = musb_init_controller(&pdata, &glue->dev, base); if (!host->host)
Any further comments?
PATCH 1/1 usb: musb-new: sunxi: Fix null pointer access
Quoted 77 lines · Stefan Mavrodiev
Quoted 63 lines · Marek Vasut
Quoted 7 lines · Stefan Mavrodiev
Quoted 4 lines · Marek Vasut
Quoted 1 line · Stefan Mavrodiev
When the device is in peripheral mode
Can you have two devices, one in peripheral mode and one in host mode, on the same system ?
Not 100% sure, but I'm thinking there is only one OTG port for all sunxi boards. The operation is decided in the
Kconfig.I'm rather sure I saw sunxi boards with more than one USB port.
Quoted 40 lines
Quoted 40 lines
Quoted 29 lines
there is no
structusb_bus_privallocated pointer, as the uclass driver ("usb_dev_generic") doesn't callper_device_auto_alloc_size.This results in writing to the internal SDRAM at
priv->desc_before_addr = true;Signed-off-by Stefan Mavrodiev <[email protected]>---
drivers/usb/musb-new/sunxi.c| 8 ++++++--1 file changed, 6 insertions(+), 2 deletions(-)drivers/usb/musb-new/sunxi.c +0
-1@@ -435,11 +435,14 @@ static int musb_usb_probe(struct udevice *dev) { struct sunxi_glue *glue = dev_get_priv(dev); struct musb_host_data *host = &glue->mdata; - struct usb_bus_priv *priv = dev_get_uclass_priv(dev); struct musb_hdrc_platform_data pdata; void *base = dev_read_addr_ptr(dev); int ret;+#ifdef
CONFIG_USB_MUSB_HOST
+ structusb_bus_priv*priv =dev_get_uclass_priv(dev);drivers/usb/musb-new/sunxi.c +2
-0+#endif +Quoted 6 lines
if (!base)
return-EINVAL;
@@ -459,7 +462,6 @@ static intmusb_usb_probe(struct udevice *dev)return ret;
}
-priv->desc_before_addr= true;See my question at the beginning, and if that can be the case, the fix is to check if priv is not null here, eg.
if (priv)
priv->...Quoted 7 lines
Quoted 1 line
Still, why is the priv data not allocated for device ?
Depending on configuration, the device is registered ether as
UCLASS_USB_DEV_GENERICorUCLASS_USB. There is no.per_device_auto_alloc_size =
sizeof(struct usb_bus_priv),for the second. (As seen in
drivers/usb/host/usb-uclass.c)I see the code is rather horrible. I'd expect all that configuration to come from DT otg-mode property instead of being hard-wired into the code. Sigh.
Jagan, A-B ? I'd like to pick this .
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
drivers/usb/musb-new/sunxi.c static int musb_usb_probe(struct udevice *dev) · line 476
Quoted 11 lines
memset(&pdata, 0, sizeof(pdata));
pdata.power = 250;drivers/usb/musb-new/sunxi.c +2
-0@@ -467,6 +469,8 @@ static int musb_usb_probe(struct udevice *dev) pdata.config = glue->cfg->config; #ifdef CONFIG_USB_MUSB_HOST + priv->desc_before_addr = true; + pdata.mode = MUSB_HOST; host->host = musb_init_controller(&pdata, &glue->dev, base); if (!host->host)
Quoted 1 line
Any further comments?
As Jagan is inactive, applied.
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 usb: musb-new: sunxi: Fix null pointer access
Quoted 79 lines · Marek Vasut
Quoted 77 lines · Stefan Mavrodiev
Quoted 75 lines · Marek Vasut
Quoted 7 lines · Stefan Mavrodiev
Quoted 4 lines · Marek Vasut
Quoted 1 line · Stefan Mavrodiev
When the device is in peripheral mode
Can you have two devices, one in peripheral mode and one in host mode, on the same system ?
Not 100% sure, but I'm thinking there is only one OTG port for all sunxi boards. The operation is decided in the
Kconfig.I'm rather sure I saw sunxi boards with more than one USB port.
Quoted 40 lines
Quoted 40 lines
Quoted 25 lines
there is no
structusb_bus_privallocated pointer, as the uclass driver ("usb_dev_generic") doesn't callper_device_auto_alloc_size.This results in writing to the internal SDRAM at
priv->desc_before_addr = true;Signed-off-by Stefan Mavrodiev <[email protected]>--- drivers/usb/musb-new/sunxi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/usb/musb-new/sunxi.c +0
-1@@ -435,11 +435,14 @@ static int musb_usb_probe(struct udevice *dev) {struct sunxi_glue *glue =dev_get_priv (dev);struct musb_host_data *host = &glue->mdata; -struct usb_bus_priv *priv =dev_get_uclass_priv (dev);struct musb_hdrc_platform_data pdata;void *base =dev_read_addr_ptr (dev);int ret;drivers/usb/musb-new/sunxi.c static int musb_usb_probe(struct udevice *dev)
Quoted 10 lines
drivers/usb/musb-new/sunxi.c +3
-0+#ifdef CONFIG_USB_MUSB_HOST +struct usb_bus_priv *priv =dev_get_uclass_priv (dev); +#endif +if (!base)return -EINVAL ; @@ -459,7 +462,6 @@ static int musb_usb_probe(struct udevice *dev) return ret; } - priv->desc_before_addr = true;See my question at the beginning, and if that can be the case, the fix is to check if priv is not null here, eg.
if (priv)
priv->...Quoted 7 lines
Quoted 1 line
Still, why is the priv data not allocated for device ?
Depending on configuration, the device is registered ether as
UCLASS_USB_DEV_GENERICorUCLASS_USB. There is no.per_device_auto_alloc_size =
sizeof(struct usb_bus_priv),for the second. (As seen in
drivers/usb/host/usb-uclass.c)I see the code is rather horrible. I'd expect all that configuration to come from DT otg-mode property instead of being hard-wired into the code. Sigh.
Jagan, A-B ? I'd like to pick this .
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
memset(&pdata, 0, sizeof(pdata)); pdata.power = 250;drivers/usb/musb-new/sunxi.c +2
-0@@ -467,6 +469,8 @@ static int musb_usb_probe(struct udevice *dev) pdata.config = glue->cfg->config;#ifdef CONFIG_USB_MUSB_HOST + priv->desc_before_addr = true; + pdata.mode =MUSB_HOST ; host->host =musb_init_controller (&pdata, &glue->dev, base);if (!host->host)
Quoted 3 lines
Quoted 1 line
Any further comments?
As Jagan is inactive, applied.
Sorry, I was in travel in multiple locations couldn't find this patch. Thanks for applying on your side.
PATCH 1/1 usb: musb-new: sunxi: Fix null pointer access
In reply to Marek VasutQuoted 5 lines · Marek Vasut
Quoted 1 line · Stefan Mavrodiev
When the device is in peripheral mode
Can you have two devices, one in peripheral mode and one in host mode, on the same system ?
No, or at least, on all of the SoCs that Allwinner ever produced, there's only a single musb controller.
Maxime
Signature · 10 lines
Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 228 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181205/29062adb/attachment.sig>
PATCH 1/1 usb: musb-new: sunxi: Fix null pointer access
In reply to Marek VasutQuoted 4 lines · Marek Vasut
Quoted 1 line · Stefan Mavrodiev
When the device is in peripheral mode
Can you have two devices, one in peripheral mode and one in host mode, on the same system ?
It is possible with the musb-new. Using DM_USB and DM_USB_GADGET, I did it with on a beaglebone black.
JJ
Quoted 57 lines
Quoted 33 lines
there is no
structusb_bus_privallocated pointer, as the uclass driver ("usb_dev_generic") doesn't callper_device_auto_alloc_size.This results in writing to the internal SDRAM at
priv->desc_before_addr = true;Signed-off-by Stefan Mavrodiev <[email protected]>--- drivers/usb/musb-new/sunxi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/usb/musb-new/sunxi.c +4
-1@@ -435,11 +435,14 @@ static int musb_usb_probe(struct udevice *dev) {struct sunxi_glue *glue =dev_get_priv (dev);struct musb_host_data *host = &glue->mdata; -struct usb_bus_priv *priv =dev_get_uclass_priv (dev);struct musb_hdrc_platform_data pdata;void *base =dev_read_addr_ptr (dev);int ret; +#ifdef CONFIG_USB_MUSB_HOST +struct usb_bus_priv *priv =dev_get_uclass_priv (dev); +#endif +if (!base)return -EINVAL ;drivers/usb/musb-new/sunxi.c static int musb_usb_probe(struct udevice *dev) · line 462
Quoted 4 lines
drivers/usb/musb-new/sunxi.c +0
-1@@ -459,7 +462,6 @@ static int musb_usb_probe(struct udevice *dev)return ret; } - priv->desc_before_addr = true;See my question at the beginning, and if that can be the case, the fix is to check if priv is not null here, eg.
if (priv)
priv->...Still, why is the priv data not allocated for device ?
Quoted 12 lines
drivers/usb/musb-new/sunxi.c +2
-0memset (&pdata,0 ,sizeof (pdata)); pdata.power =250 ;@@ -467,6 +469,8 @@ static int musb_usb_probe(struct udevice *dev) pdata.config = glue->cfg->config;#ifdef CONFIG_USB_MUSB_HOST + priv->desc_before_addr = true; + pdata.mode =MUSB_HOST ; host->host =musb_init_controller (&pdata, &glue->dev, base);if (!host->host)
PATCH 1/1 usb: musb-new: sunxi: Fix null pointer access
Quoted 9 lines · Jean-Jacques Hiblot
Quoted 4 lines · Marek Vasut
Quoted 1 line · Stefan Mavrodiev
When the device is in peripheral mode
Can you have two devices, one in peripheral mode and one in host mode, on the same system ?
It is possible with the musb-new. Using
DM_USBandDM_USB_GADGET, I did it with on a beaglebone black.
Does this patch break it ? And if so, can you send a proper fix ?
Quoted 55 lines
JJ
Quoted 53 lines
Quoted 28 lines
there is no
structusb_bus_privallocated pointer, as the uclass driver ("usb_dev_generic") doesn't callper_device_auto_alloc_size.This results in writing to the internal SDRAM at
priv->desc_before_addr = true;Signed-off-by Stefan Mavrodiev <[email protected]>---
drivers/usb/musb-new/sunxi.c| 8 ++++++--1 file changed, 6 insertions(+), 2 deletions(-)drivers/usb/musb-new/sunxi.c +0
-1@@ -435,11 +435,14 @@ static int musb_usb_probe(struct udevice *dev) { struct sunxi_glue *glue = dev_get_priv(dev); struct musb_host_data *host = &glue->mdata; - struct usb_bus_priv *priv = dev_get_uclass_priv(dev); struct musb_hdrc_platform_data pdata; void *base = dev_read_addr_ptr(dev); int ret;+#ifdef
CONFIG_USB_MUSB_HOST
+ structusb_bus_priv*priv =dev_get_uclass_priv(dev);drivers/usb/musb-new/sunxi.c +2
-0+#endif +Quoted 6 lines
if (!base)
return-EINVAL;
@@ -459,7 +462,6 @@ static intmusb_usb_probe(struct udevice *dev)return ret;
}
-priv->desc_before_addr= true;See my question at the beginning, and if that can be the case, the fix is to check if priv is not null here, eg.
if (priv)
priv->...Still, why is the priv data not allocated for device ?
Quoted 11 lines
memset(&pdata, 0, sizeof(pdata));
pdata.power = 250;drivers/usb/musb-new/sunxi.c +2
-0@@ -467,6 +469,8 @@ static int musb_usb_probe(struct udevice *dev) pdata.config = glue->cfg->config; #ifdef CONFIG_USB_MUSB_HOST + priv->desc_before_addr = true; + pdata.mode = MUSB_HOST; host->host = musb_init_controller(&pdata, &glue->dev, base); if (!host->host)
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 usb: musb-new: sunxi: Fix null pointer access
Quoted 9 lines · Marek Vasut
Quoted 7 lines · Jean-Jacques Hiblot
Quoted 4 lines · Marek Vasut
Quoted 1 line · Stefan Mavrodiev
When the device is in peripheral mode
Can you have two devices, one in peripheral mode and one in host mode, on the same system ?
It is possible with the musb-new. Using
DM_USBandDM_USB_GADGET, I did it with on a beaglebone black.Does this patch break it ? And if so, can you send a proper fix ?
This file is not compiled when building for beaglebone, so it won't break anything.
BTW this driver could be adapted, with little work, to support a dynamic selection of the role based on "dr-mode" in the DT.
Not knowing the boards, I don't know if this work has any added value though.
JJ
Quoted 56 lines
Quoted 55 lines
JJ
Quoted 52 lines
Quoted 24 lines
there is no
structusb_bus_privallocated pointer, as the uclass driver ("usb_dev_generic") doesn't callper_device_auto_alloc_size.This results in writing to the internal SDRAM at
priv->desc_before_addr = true;Signed-off-by Stefan Mavrodiev <[email protected]>--- drivers/usb/musb-new/sunxi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/usb/musb-new/sunxi.c +0
-1@@ -435,11 +435,14 @@ static int musb_usb_probe(struct udevice *dev) { struct sunxi_glue *glue = dev_get_priv(dev); struct musb_host_data *host = &glue->mdata; - struct usb_bus_priv *priv = dev_get_uclass_priv(dev); struct musb_hdrc_platform_data pdata; void *base = dev_read_addr_ptr(dev); int ret;drivers/usb/musb-new/sunxi.c static int musb_usb_probe(struct udevice *dev)
Quoted 10 lines
drivers/usb/musb-new/sunxi.c +3
-0+#ifdef CONFIG_USB_MUSB_HOST + struct usb_bus_priv *priv = dev_get_uclass_priv(dev); +#endif + if (!base) return -EINVAL; @@ -459,7 +462,6 @@ static int musb_usb_probe(struct udevice *dev) return ret; } - priv->desc_before_addr = true;See my question at the beginning, and if that can be the case, the fix is to check if priv is not null here, eg.
if (priv)
priv->...Still, why is the priv data not allocated for device ?
Quoted 11 lines
memset(&pdata, 0, sizeof(pdata));
pdata.power = 250;drivers/usb/musb-new/sunxi.c +2
-0@@ -467,6 +469,8 @@ static int musb_usb_probe(struct udevice *dev) pdata.config = glue->cfg->config; #ifdef CONFIG_USB_MUSB_HOST + priv->desc_before_addr = true; + pdata.mode = MUSB_HOST; host->host = musb_init_controller(&pdata, &glue->dev, base); if (!host->host)
PATCH 1/1 usb: musb-new: sunxi: Fix null pointer access
Quoted 6 lines · Jean-Jacques Hiblot
Quoted 4 lines · Marek Vasut
Quoted 3 lines · Jean-Jacques Hiblot
Quoted 2 lines · Marek Vasut
Quoted 1 line · Stefan Mavrodiev
When the device is in peripheral mode
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Can you have two devices, one in peripheral mode and one in host mode, on the same system ?
It is possible with the musb-new. Using
DM_USBandDM_USB_GADGET, I did it with on a beaglebone black.Does this patch break it ? And if so, can you send a proper fix ?
This file is not compiled when building for beaglebone, so it won't break anything.
Ah, sunxi, right.
Quoted 5 lines
BTW this driver could be adapted, with little work, to support a dynamic selection of the role based on "dr-mode" in the DT.
Not knowing the boards, I don't know if this work has any added value though.
It would, as it would remove ifdeffery.
Signature · 2 lines
Best regards, Marek Vasut