musb patches for v5.7-rc1
Subsystems (4)
Bin Liu
maintainercover musb patches for v5.7-rc1
Hi Greg,
Here are the musb patches for v5.7-rc1. The set adds DMA support for JZ4740 and new device JZ4770, along with some trivial cleanup. It does include a fix for a NULL-pointer dereference bug when usbmon is enabled. The patch came in late in v5.6 rc cycles, so I am including the patch here but added Cc: stable@ tag. Please let me know if there is any change needed.
Thanks,
-Bin.
---
Colin Ian King (1):
usb: musb: remove redundant assignment to variable ret
Macpaul Lin (1):
usb: musb: tusb6010: fix a possible missing data type replacement
Mans Rullgard (1):
usb: musb: fix crash with highmen PIO and usbmon
Paul Cercueil (5):
dt-bindings: usb: Convert jz4740-musb doc to YAML
usb: musb: jz4740: Add support for DMA
usb: musb: jz4740: Register USB role switch
usb: musb: jz4740: Unconditionally depend on devicetree
usb: musb: jz4740: Add support for the JZ4770
.../bindings/usb/ingenic,jz4740-musb.txt | 32 ----- .../devicetree/bindings/usb/ingenic,musb.yaml | 76 ++++++++++++ drivers/usb/musb/Kconfig | 4 +- drivers/usb/musb/jz4740.c | 110 ++++++++++++++++-- drivers/usb/musb/mediatek.c | 2 +- drivers/usb/musb/musb_host.c | 17 +-- drivers/usb/musb/tusb6010.c | 2 +- 7 files changed, 185 insertions(+), 58 deletions(-) delete mode 100644 Documentation/devicetree/bindings/usb/ingenic,jz4740-musb.txt create mode 100644 Documentation/devicetree/bindings/usb/ingenic,musb.yaml
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 1/8 usb: musb: remove redundant assignment to variable ret
From: Colin Ian King <[email protected]>
Variable ret is being initialized with a value that is never read, it is assigned a new value later on. The assignment is redundant and can be removed.
Addresses-Coverity: ("Unused value")
--- drivers/usb/musb/mediatek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/musb/mediatek.c +1 -1
@@ -448,7 +448,7 @@ static int mtk_musb_probe(struct platform_device *pdev)struct platform_device_info pinfo;struct device *dev = &pdev->dev;struct device_node *np = dev->of_node; -int ret = -ENOMEM ; +int ret; glue =devm_kzalloc (dev,sizeof (*glue),GFP_KERNEL );if (!glue)
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 2/8 dt-bindings: usb: Convert jz4740-musb doc to YAML
In reply to Bin LiuFrom: Paul Cercueil <[email protected]>
Convert ingenic,jz4740-musb.txt to ingenic,musb.yaml, and add the new ingenic,jz4770-musb and ingenic,jz4725b-musb compatible strings in the process.
--- .../bindings/usb/ingenic,jz4740-musb.txt | 32 -------- .../devicetree/bindings/usb/ingenic,musb.yaml | 76 +++++++++++++++++++ 2 files changed, 76 insertions(+), 32 deletions(-) delete mode 100644 Documentation/devicetree/bindings/usb/ingenic,jz4740-musb.txt create mode 100644 Documentation/devicetree/bindings/usb/ingenic,musb.yaml
Documentation/devicetree/bindings/usb/ingenic,jz4740-musb.txt deleted +0 -32
@@ -1,32 +0,0 @@ -Ingenic JZ4740 MUSB driver - -Required properties: - -- compatible: Must be "ingenic,jz4740-musb" -- reg: Address range of the UDC register set -- interrupts: IRQ number related to the UDC hardware -- interrupt-names: must be "mc" -- clocks: phandle to the "udc" clock -- clock-names: must be "udc" -- phys: phandle to the USB PHY - -Example: - -usb_phy: usb-phy@0 { - compatible = "usb-nop-xceiv"; - #phy-cells = <0>; -}; - -udc: usb@13040000 { - compatible = "ingenic,jz4740-musb"; - reg = <0x13040000 0x10000>; - - interrupt-parent = <&intc>; - interrupts = <24>; - interrupt-names = "mc"; - - clocks = <&cgu JZ4740_CLK_UDC>; - clock-names = "udc"; - - phys = <&usb_phy>; -};
Documentation/devicetree/bindings/usb/ingenic,musb.yaml new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 3/8 usb: musb: jz4740: Add support for DMA
In reply to Bin LiuFrom: Paul Cercueil <[email protected]>
Add support for using the DMA channels built into the Inventra IP.
--- drivers/usb/musb/Kconfig | 2 +- drivers/usb/musb/jz4740.c | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-)
drivers/usb/musb/Kconfig +1 -1
@@ -144,7 +144,7 @@ config USB_UX500_DMA config USB_INVENTRA_DMA bool 'Inventra' - depends on USB_MUSB_OMAP2PLUS || USB_MUSB_MEDIATEK + depends on USB_MUSB_OMAP2PLUS || USB_MUSB_MEDIATEK || USB_MUSB_JZ4740 help Enable DMA transfers using Mentor's engine.
drivers/usb/musb/jz4740.c +14 -6
@@ -24,11 +24,14 @@ struct jz4740_glue {static irqreturn_t jz4740_musb_interrupt (int irq,void *__hci) {unsigned long flags; -irqreturn_t retval =IRQ_NONE ; +irqreturn_t retval =IRQ_NONE , retval_dma =IRQ_NONE ;struct musb *musb = __hci;spin_lock_irqsave (&musb->lock, flags); +if (IS_ENABLED (CONFIG_USB_INVENTRA_DMA ) && musb->dma_controller) + retval_dma =dma_controller_irq (irq, musb->dma_controller); + musb->int_usb =musb_readb (musb->mregs,MUSB_INTRUSB ); musb->int_tx =musb_readw (musb->mregs,MUSB_INTRTX ); musb->int_rx =musb_readw (musb->mregs,MUSB_INTRRX );
@@ -46,7 +49,10 @@ static irqreturn_t jz4740_musb_interrupt(int irq, void *__hci)spin_unlock_irqrestore (&musb->lock, flags); -return retval; +if (retval ==IRQ_HANDLED || retval_dma ==IRQ_HANDLED ) +return IRQ_HANDLED ; + +return IRQ_NONE ; }static struct musb_fifo_cfg jz4740_musb_fifo_cfg[] = {
@@ -93,14 +99,14 @@ static int jz4740_musb_init(struct musb *musb)return 0 ; } -/* -* DMA has not been confirmed to work with CONFIG_USB_INVENTRA_DMA, -* so let's not set up the dma function pointers yet. -*/ static const struct musb_platform_ops jz4740_musb_ops = { .quirks =MUSB_DMA_INVENTRA |MUSB_INDEXED_EP , .fifo_mode =2 , .init = jz4740_musb_init, +#ifdef CONFIG_USB_INVENTRA_DMA + .dma_init = musbhs_dma_controller_create_noirq, + .dma_exit = musbhs_dma_controller_destroy, +#endif };static const struct musb_hdrc_platform_data jz4740_musb_pdata = {
@@ -142,6 +148,8 @@ static int jz4740_probe(struct platform_device *pdev) } musb->dev.parent = dev; + musb->dev.dma_mask = &musb->dev.coherent_dma_mask; + musb->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); glue->pdev = musb; glue->clk = clk;
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 4/8 usb: musb: jz4740: Register USB role switch
In reply to Bin LiuFrom: Paul Cercueil <[email protected]>
Register a USB role switch, in order to get notified by the connector driver when the USB role changes. The notification is then transmitted to the PHY.
--- drivers/usb/musb/Kconfig | 1 + drivers/usb/musb/jz4740.c | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+)
drivers/usb/musb/Kconfig +1 -0
@@ -113,6 +113,7 @@ config USB_MUSB_JZ4740 depends on MIPS || COMPILE_TEST depends on USB_MUSB_GADGET depends on USB=n || USB_OTG_BLACKLIST_HUB + select USB_ROLE_SWITCH config USB_MUSB_MEDIATEK tristate "MediaTek platforms"
drivers/usb/musb/jz4740.c +48 -0
88 lines not on this page · raw message
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 5/8 usb: musb: jz4740: Unconditionally depend on devicetree
In reply to Bin LiuFrom: Paul Cercueil <[email protected]>
The jz4740-musb driver is unconditionally probed from devicetree, so we can add a hard dependency on devicetree. This makes the code a bit cleaner, and is more future-proof as the platform data is now retrieved using of_device_get_match_data().
--- drivers/usb/musb/Kconfig | 1 + drivers/usb/musb/jz4740.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-)
drivers/usb/musb/Kconfig +1 -0
@@ -110,6 +110,7 @@ config USB_MUSB_UX500 config USB_MUSB_JZ4740 tristate "JZ4740" + depends on OF depends on MIPS || COMPILE_TEST depends on USB_MUSB_GADGET depends on USB=n || USB_OTG_BLACKLIST_HUB
drivers/usb/musb/jz4740.c +9 -5
@@ -166,7 +166,7 @@ static const struct musb_hdrc_platform_data jz4740_musb_pdata = {static int jz4740_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -const struct musb_hdrc_platform_data *pdata = &jz4740_musb_pdata; +const struct musb_hdrc_platform_data *pdata;struct platform_device *musb;struct jz4740_glue *glue;struct clk *clk;
@@ -176,6 +176,12 @@ static int jz4740_probe(struct platform_device *pdev)if (!glue)return -ENOMEM ; + pdata =of_device_get_match_data (dev); +if (!pdata) { +dev_err (dev,"missing platform data" ); +return -EINVAL ; + } + musb =platform_device_alloc ("musb-hdrc" ,PLATFORM_DEVID_AUTO );if (!musb) {dev_err (dev,"failed to allocate musb device" );
@@ -242,20 +248,18 @@ static int jz4740_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_OF static const struct of_device_id jz4740_musb_of_match[] = { - { .compatible ="ingenic,jz4740-musb" }, + { .compatible ="ingenic,jz4740-musb" , .data = &jz4740_musb_pdata }, {/* sentinel */ }, };MODULE_DEVICE_TABLE (of, jz4740_musb_of_match); -#endif static struct platform_driver jz4740_driver = { .probe = jz4740_probe, .remove = jz4740_remove, .driver = { .name ="musb-jz4740" , - .of_match_table =of_match_ptr (jz4740_musb_of_match), + .of_match_table = jz4740_musb_of_match, }, };
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 6/8 usb: musb: jz4740: Add support for the JZ4770
In reply to Bin LiuFrom: Paul Cercueil <[email protected]>
Add support for probing the jz4740-musb driver on the JZ4770 SoC.
The USB IP in the JZ4770 works the same Inventra IP as for the JZ4740, but it features more endpoints, and officially supports OTG.
--- drivers/usb/musb/jz4740.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/usb/musb/jz4740.c +28 -0
@@ -163,6 +163,33 @@ static const struct musb_hdrc_platform_data jz4740_musb_pdata = { .platform_ops = &jz4740_musb_ops, }; +static struct musb_fifo_cfg jz4770_musb_fifo_cfg[] = { + { .hw_ep_num =1 , .style =FIFO_TX , .maxpacket =512 , }, + { .hw_ep_num =1 , .style =FIFO_RX , .maxpacket =512 , }, + { .hw_ep_num =2 , .style =FIFO_TX , .maxpacket =512 , }, + { .hw_ep_num =2 , .style =FIFO_RX , .maxpacket =512 , }, + { .hw_ep_num =3 , .style =FIFO_TX , .maxpacket =512 , }, + { .hw_ep_num =3 , .style =FIFO_RX , .maxpacket =512 , }, + { .hw_ep_num =4 , .style =FIFO_TX , .maxpacket =512 , }, + { .hw_ep_num =4 , .style =FIFO_RX , .maxpacket =512 , }, + { .hw_ep_num =5 , .style =FIFO_TX , .maxpacket =512 , }, + { .hw_ep_num =5 , .style =FIFO_RX , .maxpacket =512 , }, +}; + +static struct musb_hdrc_config jz4770_musb_config = { + .multipoint =1 , + .num_eps =11 , + .ram_bits =11 , + .fifo_cfg = jz4770_musb_fifo_cfg, + .fifo_cfg_size =ARRAY_SIZE (jz4770_musb_fifo_cfg), +}; + +static const struct musb_hdrc_platform_data jz4770_musb_pdata = { + .mode =MUSB_PERIPHERAL ,/* TODO: support OTG */ + .config = &jz4770_musb_config, + .platform_ops = &jz4740_musb_ops, +}; +static int jz4740_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -250,6 +277,7 @@ static int jz4740_remove(struct platform_device *pdev)static const struct of_device_id jz4740_musb_of_match[] = { { .compatible ="ingenic,jz4740-musb" , .data = &jz4740_musb_pdata }, + { .compatible ="ingenic,jz4770-musb" , .data = &jz4770_musb_pdata }, {/* sentinel */ }, };MODULE_DEVICE_TABLE (of, jz4740_musb_of_match);
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 7/8 usb: musb: fix crash with highmen PIO and usbmon
In reply to Bin LiuFrom: Mans Rullgard <[email protected]>
When handling a PIO bulk transfer with highmem buffer, a temporary mapping is assigned to urb->transfer_buffer. After the transfer is complete, an invalid address is left behind in this pointer. This is not ordinarily a problem since nothing touches that buffer before the urb is released. However, when usbmon is active, usbmon_urb_complete() calls (indirectly) mon_bin_get_data() which does access the transfer buffer if it is set. To prevent an invalid memory access here, reset urb->transfer_buffer to NULL when finished (musb_host_rx()), or do not set it at all (musb_host_tx()).
--- drivers/usb/musb/musb_host.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/usb/musb/musb_host.c +5 -12
@@ -1436,10 +1436,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)* We need to map sg if the transfer_buffer is * NULL. */ -if (!urb->transfer_buffer) - qh->use_sg = true; - -if (qh->use_sg) { +if (!urb->transfer_buffer) {/* sg_miter_start is already done in musb_ep_program */ if (!sg_miter_next (&qh->sg_miter)) {dev_err (musb->controller,"error: sg list empty\n" );
@@ -1447,9 +1444,8 @@ void musb_host_tx(struct musb *musb, u8 epnum) status = -EINVAL ; goto done; } - urb->transfer_buffer = qh->sg_miter.addr; length =min_t (u32, length, qh->sg_miter.length); -musb_write_fifo (hw_ep, length, urb->transfer_buffer); +musb_write_fifo (hw_ep, length, qh->sg_miter.addr); qh->sg_miter.consumed = length;sg_miter_stop (&qh->sg_miter); }else {
@@ -1458,11 +1454,6 @@ void musb_host_tx(struct musb *musb, u8 epnum) qh->segsize = length; -if (qh->use_sg) { -if (offset + length >= urb->transfer_buffer_length) - qh->use_sg = false; - } -musb_ep_select (mbase, epnum);musb_writew (epio,MUSB_TXCSR ,MUSB_TXCSR_H_WZC_BITS |MUSB_TXCSR_TXPKTRDY );
@@ -1977,8 +1968,10 @@ void musb_host_rx(struct musb *musb, u8 epnum) urb->actual_length += xfer_len; qh->offset += xfer_len;if (done) { -if (qh->use_sg) +if (qh->use_sg) { qh->use_sg = false; + urb->transfer_buffer =NULL ; + }if (urb->status == -EINPROGRESS ) urb->status = status;
Signature · 1 line
2.17.1
Bin Liu
maintainerPATCH 8/8 usb: musb: tusb6010: fix a possible missing data type replacement
In reply to Bin LiuFrom: Macpaul Lin <[email protected]>
Replace "unsigned" to "u32" for checkpatch fix to tusb_writeb().
--- drivers/usb/musb/tusb6010.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/musb/tusb6010.c +1 -1
@@ -156,7 +156,7 @@ static u8 tusb_readb(void __iomem *addr, u32 offset)return val; } -static void tusb_writeb (void __iomem *addr,unsigned offset,u8 data) +static void tusb_writeb (void __iomem *addr,u32 offset,u8 data) {u16 tmp;
Signature · 1 line
2.17.1