musb: save OTG base physical address
Subsystems (2)
PATCH 1/5 musb: save OTG base physical address
OTG base physical address is required in calculating physical address of endpoint FIFO which is needed by system dma.
--- drivers/usb/musb/musb_core.c | 6 ++++-- drivers/usb/musb/musb_core.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/usb/musb/musb_core.c +4 -2
@@ -1867,7 +1867,8 @@ static void musb_free(struct musb *musb)* not yet corrected for platform-specific offsets */ static int __init -musb_init_controller (struct device *dev,int nIrq,void __iomem *ctrl) +musb_init_controller (struct device *dev,int nIrq,void __iomem *ctrl, +phys_addr_t ctrl_phys_addr) {int status;struct musb *musb;
@@ -1919,6 +1920,7 @@ bad_config: musb->board_set_power = plat->set_power; musb->set_clock = plat->set_clock; musb->min_power = plat->min_power; + musb->ctrl_phys_base = ctrl_phys_addr;/* Clock usage is chip-specific ... functional clock (DaVinci, * OMAP2430), or PHY ref (some TUSB6010 boards). All this core
@@ -2136,7 +2138,7 @@ static int __init musb_probe(struct platform_device *pdev)/* clobbered by use_dma=n */ orig_dma_mask = dev->dma_mask;#endif - status =musb_init_controller (dev, irq, base); + status =musb_init_controller (dev, irq, base, iomem->start);if (status <0 )iounmap (base);
drivers/usb/musb/musb_core.h +1 -0
@@ -367,6 +367,7 @@ struct musb {struct device *controller;void __iomem *ctrl_base; +phys_addr_t ctrl_phys_base;void __iomem *mregs;#ifdef CONFIG_USB_TUSB6010
Signature · 6 lines
1.6.2.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/5 musb: use system DMA to fix Inventra DMA issue on RTL-1.4
MUSB RTL version 1.4 has a hardware issue when TX and RX DMA channels are simultaneously enabled which results in DMA lockup.
Use system DMA for all RX channels as a workaround of this issue as this will have minimal throughput overhead based on the fact that Rx transfers are done in DMA mode-0 on OMAP34x/35x platforms.
Another approach to use PIO mode in opposite direction would increase the cpu loading and thus using system DMA is preferred workaround.
---
Original version of this patch can be found at,
http://marc.info/?l=linux-usb&m=121861118320955&w=2
drivers/usb/musb/Kconfig | 9 ++++ drivers/usb/musb/musbhsdma.c | 101 ++++++++++++++++++++++++++++++++++++++++++ drivers/usb/musb/musbhsdma.h | 10 ++++ 3 files changed, 120 insertions(+), 0 deletions(-)
drivers/usb/musb/Kconfig +9 -0
@@ -157,6 +157,15 @@ config USB_INVENTRA_DMA help Enable DMA transfers using Mentor's engine. +config MUSB_USE_SYSTEM_DMA_WORKAROUND + bool 'Use System DMA for Mentor DMA workaround' + depends on USB_MUSB_HDRC && USB_INVENTRA_DMA + default y + help + MUSB RTL version 1.4 (OMAP34x/35x) has a hardware issue when TX and RX + DMA channels are simultaneously enabled. To work around this issue, + you can choose to use System DMA for RX channels. + config USB_TI_CPPI_DMA bool depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY
drivers/usb/musb/musbhsdma.c +101 -0
155 lines not on this page · raw message
drivers/usb/musb/musbhsdma.h +10 -0
@@ -142,6 +142,15 @@ static inline void musb_write_hsdma_count(void __iomem *mbase,#define MUSB_HSDMA_CHANNELS 8 +#define MUSB_FIFO_ADDRESS (base, epnum) \ + ((unsigned long) (base + MUSB_FIFO_OFFSET(epnum))) + +#ifdef CONFIG_MUSB_USE_SYSTEM_DMA_WORKAROUND +#define use_sdma_workaround () 1 +#else +#define use_sdma_workaround () 0 +#endif +struct musb_dma_controller ;struct musb_dma_channel {
@@ -153,6 +162,7 @@ struct musb_dma_channel {u8 idx;u8 epnum;u8 transmit; +int sysdma_channel; };struct musb_dma_controller {
Signature · 1 line
1.6.2.4
A message that is not in the archive (sent off-list or not yet received): 1273664979-493-2-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org
PATCH 3/5 musb: add function to check if Inventra DMA used
Added is_inventra_dma_enabled() funtion which would be required for adding workaround for Inventra DMA issues. It can also be used at other places instead of #ifdefs.
--- drivers/usb/musb/musb_dma.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/usb/musb/musb_dma.h +6 -0
@@ -80,6 +80,12 @@ struct musb_hw_ep;#define tusb_dma_omap () 0#endif +#ifdef CONFIG_USB_INVENTRA_DMA +#define is_inventra_dma_enabled () 1 +#else +#define is_inventra_dma_enabled () 0 +#endif +/* Anomaly 05000456 - USB Receive Interrupt Is Not Generated in DMA Mode 1 * Only allow DMA mode 1 to be used when the USB will actually generate the * interrupts we expect.
Signature · 6 lines
1.6.2.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1273664979-493-3-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org
PATCH 4/5 musb: use system DMA for unaligned buffers on RTL >= 1.8
MUSB RTL version 1.8 onward (OMAP3630, AM/DM37x, OMAP4) DMA requires the buffers to be aligned on a four byte boundary. This affects USB CDC/RNDIS class application where buffers are always unaligned.
Use system DMA for unaligned buffers as a workaround of this issue.
Current patch supports device side CDC/RNDIS. Host side would require change in Tx programming path for mode-0 operation when transfer length is more than packet size.
Also fixed an issue in device Tx completion path where 'is_dma' is getting set unconditionally. This would fail the io if Tx transfer is done in mode-0. Fixed it by updating it based on 'request->actual' length.
--- drivers/usb/musb/Kconfig | 6 +++ drivers/usb/musb/musb_gadget.c | 21 +++++++++++- drivers/usb/musb/musbhsdma.c | 75 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 98 insertions(+), 4 deletions(-)
drivers/usb/musb/Kconfig +6 -0
@@ -166,6 +166,12 @@ config MUSB_USE_SYSTEM_DMA_WORKAROUND DMA channels are simultaneously enabled. To work around this issue, you can choose to use System DMA for RX channels. + Also on Mentor DMA in MUSB RTL version 1.8 (OMAP3630, AM/DM37x) + requires buffers to be aligned on a four byte boundary. This affects + USB CDC/RNDIS class application where buffers are always unaligned. + To work around this issue, you can choose to use System DMA for + unaligned buffers. + config USB_TI_CPPI_DMA bool depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY
drivers/usb/musb/musb_gadget.c +20 -1
@@ -317,6 +317,22 @@ static void txstate(struct musb *musb, struct musb_request *req)else musb_ep->dma->desired_mode =1 ; +/* +* Use system dma for unaligned buffers on RTL >= 1.8 +* for Inventra DMA. As system DMA can work only in +* mode-0 so update the desired_mode and request_size. +*/ +if (is_inventra_dma_enabled () && + ((request->dma + request->actual) &0x3 ) && + (musb->hwvers >=MUSB_HWVERS_1800 )) { + + request_size =min_t (size_t, + musb_ep->hw_ep->max_packet_sz_tx, + request->length - request->actual); + + musb_ep->dma->desired_mode =0 ; + } + use_dma = use_dma && c->channel_program( musb_ep->dma, musb_ep->packet_sz, musb_ep->dma->desired_mode,
@@ -463,7 +479,6 @@ void musb_g_tx(struct musb *musb, u8 epnum)u8 is_dma =0 ;if (dma && (csr &MUSB_TXCSR_DMAENAB )) { - is_dma =1 ; csr |=MUSB_TXCSR_P_WZC_BITS ; csr &= ~(MUSB_TXCSR_DMAENAB |MUSB_TXCSR_P_UNDERRUN |MUSB_TXCSR_TXPKTRDY );
@@ -471,6 +486,10 @@ void musb_g_tx(struct musb *musb, u8 epnum)/* Ensure writebuffer is empty. */ csr =musb_readw (epio,MUSB_TXCSR ); request->actual += musb_ep->dma->actual_len; + +if (request->actual == request->length) + is_dma =1 ; +DBG (4 ,"TXCSR%d %04x, DMA off, len %zu, req %p\n" , epnum, csr, musb_ep->dma->actual_len, request); }
drivers/usb/musb/musbhsdma.c +72 -3
121 lines not on this page · raw message
Signature · 6 lines
1.6.2.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1273664979-493-4-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org
PATCH 5/5 musb: dma: use optimal transfer element for sdma
Use optimal values of transfer element based on buffer address in system DMA programming. This would improve the performance.
--- drivers/usb/musb/musbhsdma.c | 39 +++++++++++++++++++++++++++++++++------ 1 files changed, 33 insertions(+), 6 deletions(-)
drivers/usb/musb/musbhsdma.c +33 -6
@@ -230,6 +230,8 @@ static void configure_channel(struct dma_channel *channel,u8 buffer_is_aligned = (dma_addr &0x3 ) ?0 :1 ;u8 use_sdma = (musb_channel->sysdma_channel ==-1 ) ?0 :1 ;u16 csr =0 ; +u16 frame = len; +int data_type =OMAP_DMA_DATA_TYPE_S8 ;DBG (4 ,"%p, pkt_sz %d, addr 0x%x, len %d, mode %d\n" , channel, packet_sz, dma_addr, len, mode);
@@ -238,13 +240,38 @@ static void configure_channel(struct dma_channel *channel, (musb->hwvers >= MUSB_HWVERS_1800)) use_sdma =0 ; +if (use_sdma) { +switch (dma_addr &0x3 ) { +case 0 : +if ((len %4 ) ==0 ) { + data_type =OMAP_DMA_DATA_TYPE_S32 ; + frame = len /4 ; +break ; + } +/* FALLTHROUGH */ +case 2 : +if ((len %2 ) ==0 ) { + data_type =OMAP_DMA_DATA_TYPE_S16 ; + frame = len /2 ; +break ; + } +/* FALLTHROUGH */ +case 1 : +case 3 : +default : + data_type =OMAP_DMA_DATA_TYPE_S8 ; + frame = len; +break ; + } + } +if (use_sdma && !musb_channel->transmit) {/* System DMA */ /* RX: set src = FIFO */ omap_set_dma_transfer_params (musb_channel->sysdma_channel, -OMAP_DMA_DATA_TYPE_S8 , - len ? len :1 ,1 ,/* One frame */ -OMAP_DMA_SYNC_ELEMENT , + data_type, + len ? frame :1 ,1 ,/* One frame */ +OMAP_DMA_SYNC_FRAME ,OMAP24XX_DMA_NO_DEVICE ,0 );/* Src Sync */
@@ -268,9 +295,9 @@ static void configure_channel(struct dma_channel *channel,/* System DMA */ /* TX: set dst = FIFO */ omap_set_dma_transfer_params (musb_channel->sysdma_channel, -OMAP_DMA_DATA_TYPE_S8 , - len ? len :1 ,1 ,/* One frame */ -OMAP_DMA_SYNC_ELEMENT , + data_type, + len ? frame :1 ,1 ,/* One frame */ +OMAP_DMA_SYNC_FRAME ,OMAP24XX_DMA_NO_DEVICE ,0 );/* Src Sync */
Signature · 6 lines
1.6.2.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTL >= 1.8
In reply to a message not in the archiveHello.
Quoted 16 lines · Ajay Kumar Gupta
MUSB RTL version 1.8 onward (OMAP3630, AM/DM37x, OMAP4) DMA requires the buffers to be aligned on a four byte boundary. This affects USB CDC/RNDIS class application where buffers are always unaligned.
Use system DMA for unaligned buffers as a workaround of this issue.
Current patch supports device side CDC/RNDIS. Host side would require change in Tx programming path for mode-0 operation when transfer length is more than packet size.
Also fixed an issue in device Tx completion path where '
is_dma' is getting set unconditionally. This would fail the io if Tx transfer is done in mode-0. Fixed it by updating it based on 'request->actual' length.Signed-off-by Ajay Kumar Gupta <[email protected]>
[...]
Quoted 122 lines
drivers/usb/musb/musbhsdma.c +69
-3@@ -54,12 +54,18 @@ static void musb_sysdma_completion(int lch, u16 ch_status, void *data) (struct musb_dma_channel *) data;struct musb_dma_controller *controller = musb_channel->controller;struct musb *musb = controller->private_data; +void __iomem *mbase = controller->base; + channel = &musb_channel->channel;DBG (2 ,"lch = 0x%d, ch_status = 0x%x\n" , lch, ch_status);spin_lock_irqsave (&musb->lock, flags); - addr = (u32 )omap_get_dma_dst_pos (musb_channel->sysdma_channel); +if (musb_channel->transmit) + addr = (u32 )omap_get_dma_src_pos (musb_channel->sysdma_channel); +else + addr = (u32 )omap_get_dma_dst_pos (musb_channel->sysdma_channel); +if (musb_channel->len ==0 ) channel->actual_len =0 ;else @@ -72,6 +78,26 @@ static void musb_sysdma_completion(int lch, u16 ch_status, void *data) "=> reconfig 0 " : " => complete"); channel->status =MUSB_DMA_STATUS_FREE ; + +/* completed */ +if ((musb_channel->transmit) && (channel->desired_mode ==0 ) + && (channel->actual_len == musb_channel->max_packet_sz)) { + +u8 epnum = musb_channel->epnum; +int offset =MUSB_EP_OFFSET (epnum, +MUSB_TXCSR ); +u16 txcsr; + +/* +* The programming guide says that we +* must clear DMAENAB before DMAMODE. +*/ +musb_ep_select (mbase, epnum); + txcsr =musb_readw (mbase, offset); + txcsr |=MUSB_TXCSR_TXPKTRDY ; +musb_writew (mbase, offset, txcsr); + } +musb_dma_completion (musb, musb_channel->epnum, musb_channel->transmit);spin_unlock_irqrestore (&musb->lock, flags);@@ -138,8 +164,15 @@ static struct dma_channel *dma_channel_allocate(struct dma_controller *c,* issue when TX and RX DMA channels are simultaneously * enabled. To work around this issue, use system DMA * for all RX channels. +* Also on MUSB RTL version 1.8 onward (OMAP3630, OMAP4 +* and AM/DM37x) DMA requires buffers to be aligned on +* a four byte boundary. This affects USB CDC/RNDIS +* class application where buffers are always unaligned. +* Using system DMA for unaligned buffers as a +* workaround for this issue. */ -if (((musb->hwvers ==MUSB_HWVERS_1400 ) && !transmit) +if ((((musb->hwvers ==MUSB_HWVERS_1400 ) && !transmit) + || (musb->hwvers >=MUSB_HWVERS_1800 )) &&use_sdma_workaround ()) {int ret; ret = omap_request_dma(OMAP24XX_DMA_NO_DEVICE,@@ -194,11 +227,18 @@ static void configure_channel(struct dma_channel *channel,struct musb *musb = controller->private_data;void __iomem *mbase = controller->base;u8 bchannel = musb_channel->idx; +u8 buffer_is_aligned = (dma_addr &0x3 ) ?0 :1 ; +u8 use_sdma = (musb_channel->sysdma_channel ==-1 ) ?0 :1 ;u16 csr =0 ;DBG (4 ,"%p, pkt_sz %d, addr 0x%x, len %d, mode %d\n" , channel, packet_sz, dma_addr, len, mode); -if (musb_channel->sysdma_channel !=-1 ) { + +if (buffer_is_aligned && (packet_sz >=512 ) && + (musb->hwvers >=MUSB_HWVERS_1800 )) + use_sdma =0 ; + +if (use_sdma && !musb_channel->transmit) {/* System DMA */ /* RX: set src = FIFO */ omap_set_dma_transfer_params(musb_channel->sysdma_channel,@@ -224,6 +264,32 @@ static void configure_channel(struct dma_channel *channel,omap_start_dma (musb_channel->sysdma_channel); + }else if (use_sdma && musb_channel->transmit) { +/* System DMA */ +/* TX: set dst = FIFO */ +omap_set_dma_transfer_params (musb_channel->sysdma_channel, +OMAP_DMA_DATA_TYPE_S8 , + len ? len :1 ,1 ,/* One frame */ +OMAP_DMA_SYNC_ELEMENT , +OMAP24XX_DMA_NO_DEVICE , +0 );/* Src Sync */ + +omap_set_dma_src_params (musb_channel->sysdma_channel,0 , +OMAP_DMA_AMODE_POST_INC , dma_addr, +0 ,0 ); + +omap_set_dma_dest_params (musb_channel->sysdma_channel,0 , +OMAP_DMA_AMODE_CONSTANT , +MUSB_FIFO_ADDRESS (musb->ctrl_phys_base, + musb_channel->epnum), +0 ,0 ); + +omap_set_dma_dest_data_pack (musb_channel->sysdma_channel,0 ); +omap_set_dma_dest_burst_mode (musb_channel->sysdma_channel, +OMAP_DMA_DATA_BURST_DIS ); + +omap_start_dma (musb_channel->sysdma_channel); + }else {/* Mentor DMA */ if (mode) {
drivers/usb/musb/musbhsdma.c static int dma_channel_abort(struct dma_channel *channel) · line 371
Quoted 7 lines
drivers/usb/musb/musbhsdma.c +3
-0@@ -299,6 +365,9 @@ static int dma_channel_abort(struct dma_channel *channel)if (channel->status ==MUSB_DMA_STATUS_BUSY ) {if (musb_channel->transmit) { +if (musb_channel->sysdma_channel !=-1 ) +omap_stop_dma (musb_channel->sysdma_channel); +
Have you thought about e.g. Blackfin? How this is going to compile
there, without omap_*() functions even existing? Or did you think that OMAP is the only user of this driver?
WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTL >= 1.8
Hi,
Quoted 10 lines
drivers/usb/musb/musbhsdma.c static int dma_channel_abort(struct dma_channel *channel) · line 370
Quoted 6 lines
drivers/usb/musb/musbhsdma.c +3
-0if (channel->status ==MUSB_DMA_STATUS_BUSY ) {if (musb_channel->transmit) { +if (musb_channel->sysdma_channel !=-1 ) +omap_stop_dma (musb_channel->sysdma_channel); +Have you thought about e.g. Blackfin? How this is going to compile
there, without omap_*() functions even existing? Or did you think that OMAP is the only user of this driver?
Thanks for pointing this. It would require adding wrapper functions for Blckfin's.
-Ajay
Quoted 2 lines
WBR, Sergei
Re: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTL >= 1.8
Hello.
Quoted 13 lines · Ajay Kumar
Hi,
Quoted 11 lines
drivers/usb/musb/musbhsdma.c static int dma_channel_abort(struct dma_channel *channel) · line 370
Quoted 7 lines
drivers/usb/musb/musbhsdma.c +3
-0if (channel->status ==MUSB_DMA_STATUS_BUSY ) {if (musb_channel->transmit) { +if (musb_channel->sysdma_channel !=-1 ) +omap_stop_dma (musb_channel->sysdma_channel); +Have you thought about e.g. Blackfin? How this is going to compile
there, without omap_*() functions even existing? Or did you think that OMAP is the only user of this driver?
Quoted 3 lines
Thanks for pointing this. It would require adding wrapper functions for Blckfin's.
Better wrap your stuff into #ifdef OMAP, I think...
Quoted 2 lines
-Ajay
WBR, Sergei
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTL >= 1.8
Quoted 1 line · Sergei Shtylyov
Better wrap your stuff into #ifdef OMAP, I think...
please don't, better to use the bounce buffer... It would work on blackfin, davinci and omap...
Signature · 5 lines
balbi -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTL >= 1.8
Hi,
Quoted 7 lines
-----Original Message-----
From: Felipe Balbi [mailto:me-uiRdBs8odbtmTBlB0Cgj/[email protected]]
Sent: Wednesday, May 12, 2010 11:26 PM
To: Sergei Shtylyov
Cc: Gupta, Ajay Kumar; [email protected]; linux- [email protected]
Subject: Re: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTL
Quoted 7 lines
Quoted 1 line
= 1.8
Quoted 1 line · Sergei Shtylyov
Better wrap your stuff into #ifdef OMAP, I think...
please don't, better to use the bounce buffer... It would work on blackfin, davinci and omap...
Just working is not enough. We need to think of performance and cpu loading as well.
-Ajay
Quoted 3 lines
--
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 19F8576C6E063C45BE387C64729E7394044E40516A-/tLxBxkBPtCIQmiDNMet8wC/[email protected]
Re: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTL >= 1.8
Quoted 10 lines · Ajay Kumar
Hi,
Quoted 9 lines
-----Original Message-----
From: Felipe Balbi [mailto:me-uiRdBs8odbtmTBlB0Cgj/[email protected]]
Sent: Wednesday, May 12, 2010 11:26 PM
To: Sergei Shtylyov
Cc: Gupta, Ajay Kumar; [email protected]; linux- [email protected]
Subject: Re: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTLQuoted 1 line
= 1.8
Quoted 8 lines
Quoted 5 lines · Sergei Shtylyov
Quoted 1 line
Better wrap your stuff into #ifdef OMAP, I think...
please don't, better to use the bounce buffer... It would work on blackfin, davinci and omap...
Just working is not enough. We need to think of performance and cpu loading as well.
allocating a bounce buffer doesn't take long and you can still use mentor DMA to transfer the data.
Signature · 5 lines
balbi -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTL >= 1.8
Hi,
Quoted 15 lines · Ajay Kumar
Quoted 8 lines
Hi,
Quoted 7 lines
-----Original Message-----
From: Felipe Balbi [mailto:[email protected]]
Sent: Wednesday, May 12, 2010 11:26 PM
To: Sergei Shtylyov
Cc: Gupta, Ajay Kumar; [email protected]; linux- [email protected]
Subject: Re: [PATCH 4/5] musb: use system DMA for unaligned buffers onRTL
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
= 1.8
Quoted 1 line · Sergei Shtylyov
Better wrap your stuff into #ifdef OMAP, I think...
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
please don't, better to use the bounce buffer... It would work on blackfin, davinci and omap...
Just working is not enough. We need to think of performance and cpu loading as well.
allocating a bounce buffer doesn't take long and you can still use mentor DMA to transfer the data.
But there is a memcpy involved right? It will use cpu and thus would be hitting on performance, cpu loading and power consumption. Instead why not use other available system resources (system dma)to do this job.
I understand, some platform may not support/have system dma then they can surely use bounce buffer or use PIO mode.
There was another workaround proposed earlier which was using 'memmove'
(similar to memcpy) that was badly affecting cpu loading. I was hardly getting 50Mbits/sec of throughput with 100% loading. Instead when I tried system DMA, numbers went up to 90Mbits/sec with a cpu loading of 50%.
I think we must use system DMA for this issue and also have bounce buffer Or PIO fallback mechanism in place for platforms not supporting system DMA.
Regards,
Ajay
Quoted 3 lines
--
balbi
Re: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTL >= 1.8
In reply to a message not in the archiveQuoted 15 lines · Ajay Kumar Gupta
MUSB RTL version 1.8 onward (OMAP3630, AM/DM37x, OMAP4) DMA requires the buffers to be aligned on a four byte boundary. This affects USB CDC/RNDIS class application where buffers are always unaligned.
Use system DMA for unaligned buffers as a workaround of this issue.
Current patch supports device side CDC/RNDIS. Host side would require change in Tx programming path for mode-0 operation when transfer length is more than packet size.
Also fixed an issue in device Tx completion path where '
is_dma' is getting set unconditionally. This would fail the io if Tx transfer is done in mode-0. Fixed it by updating it based on 'request->actual' length.Signed-off-by Ajay Kumar Gupta <[email protected]>
[..]
drivers/usb/musb/Kconfig config MUSB_USE_SYSTEM_DMA_WORKAROUND · line 173
Quoted 9 lines
drivers/usb/musb/Kconfig +5
-0@@ -166,6 +166,12 @@ config MUSB_USE_SYSTEM_DMA_WORKAROUND DMA channels are simultaneously enabled. To work around this issue, you can choose to use System DMA for RX channels. + Also on Mentor DMA in MUSB RTL version 1.8 (OMAP3630, AM/DM37x) + requires buffers to be aligned on a four byte boundary. This affects + USB CDC/RNDIS class application where buffers are always unaligned. + To work around this issue, you can choose to use System DMA for + unaligned buffers.
instead of this patch, it's a whole lot easier to simply use a bounce buffer:
if (unaligned) {
bounce = dma_alloc_coherent(......);
memcpy(request->buf, bounce, request->length);
}and use that buffer on channel_program();
Signature · 5 lines
balbi -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTL >= 1.8
Hi,
Quoted 36 lines · Ajay Kumar Gupta
Quoted 11 lines
MUSB RTL version 1.8 onward (OMAP3630, AM/DM37x, OMAP4) DMA requires the buffers to be aligned on a four byte boundary. This affects USB CDC/RNDIS class application where buffers are always unaligned.
Use system DMA for unaligned buffers as a workaround of this issue.
Current patch supports device side CDC/RNDIS. Host side would require change in Tx programming path for mode-0 operation when transfer length is more than packet size.
Also fixed an issue in device Tx completion path where '
is_dma' isgetting
Quoted 4 lines
set unconditionally. This would fail the io if Tx transfer is done in mode-0. Fixed it by updating it based on '
request->actual' length.Signed-off-by Ajay Kumar Gupta <[email protected]>[..]
Review config MUSB_USE_SYSTEM_DMA_WORKAROUND · line 166
Quoted 2 lines
(quoted diff) +0
-0@@ -166,6 +166,12 @@ config MUSB_USE_SYSTEM_DMA_WORKAROUND DMA channels are simultaneously enabled. To work around thisissue,
drivers/usb/musb/Kconfig config MUSB_USE_SYSTEM_DMA_WORKAROUND
Quoted 4 lines
drivers/usb/musb/Kconfig +2
-0you can choose to use System DMA for RX channels. + Also on Mentor DMA in MUSB RTL version 1.8 (OMAP3630, AM/DM37x) + requires buffers to be aligned on a four byte boundary. Thisaffects
Review config MUSB_USE_SYSTEM_DMA_WORKAROUND · line 171
Quoted 1 line
(quoted diff) +1
-0+ USB CDC/RNDIS class application where buffers are alwaysunaligned.
drivers/usb/musb/Kconfig config MUSB_USE_SYSTEM_DMA_WORKAROUND · line 173
Quoted 2 lines
drivers/usb/musb/Kconfig +2
-0+ To work around this issue, you can choose to use System DMA for + unaligned buffers.instead of this patch, it's a whole lot easier to simply use a bounce buffer:
Quoted 4 lines
if (unaligned) {
bounce = dma_alloc_coherent(......);
memcpy(request->buf, bounce, request->length);
}How about this 'memcpy', this would affect both cpu loading and performance. That's why using system dma would be a better approach.
-Ajay
Quoted 5 lines
and use that buffer on
channel_program();--
balbi
A message that is not in the archive (sent off-list or not yet received): 19F8576C6E063C45BE387C64729E7394044E405169-/tLxBxkBPtCIQmiDNMet8wC/[email protected]
Re: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTL >= 1.8
Quoted 3 lines · Ajay Kumar
How about this 'memcpy', this would affect both cpu loading and performance. That's why using system dma would be a better approach.
but that's not portable. Even if you come up with nice wrappers for system dma usage (which is already ugly, more exported functions) you might end up on a board where system dma has same alignment constraints as mentor dma. Either fall back to pio or use a bounce buffer. That'll work always.
Besides, the only offending gadget driver we have is g_ether and that's already 'fixed' by the alignment patch to g_ether. Any other gadget driver causing that, should be fixed too...
Signature · 7 lines
balbi DefectiveByDesign.org -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTL >= 1.8
Hi,
Quoted 14 lines
-----Original Message-----
From: Felipe Balbi [mailto:[email protected]]
Sent: Friday, May 14, 2010 4:37 PM
To: Gupta, Ajay Kumar
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH 4/5] musb: use system DMA for unaligned buffers on RTLQuoted 1 line
= 1.8
Quoted 3 lines · Ajay Kumar
How about this 'memcpy', this would affect both cpu loading and performance. That's why using system dma would be a better approach.
Quoted 5 lines
but that's not portable.
Even if you come up with nice wrappers for
system dma usage (which is already ugly, more exported functions) you might end up on a board where system dma has same alignment constraints as mentor dma.
It can't be an OMAP3 based board but yes, future platform could have such limitations but they should not restrict other platforms to use system dma which can handle unaligned buffers.
Quoted 2 lines
Either fall back to pio or use a bounce buffer. That'll work always.
Agreed but performance we should allow system dma approach also.
Quoted 3 lines
Besides, the only offending gadget driver we have is
g_etherand that's already 'fixed' by the alignment patch tog_ether.
No, it's not fixed. It had two issues,
1. Cache coherency as we observed iperf failing and after using
Cache_flush_all() things started working.
2. High cpu loading of 100% and bit rate of only 30Mbits/sec due
To memmove and cache_flush..
-Ajay
Quoted 7 lines
Any other gadget
driver causing that, should be fixed too...--
balbiDefectiveByDesign.org
Re: [PATCH 3/5] musb: add function to check if Inventra DMA used
In reply to Ajay Kumar GuptaQuoted 5 lines · Ajay Kumar Gupta
Added
is_inventra_dma_enabled()funtion which would be required for adding workaround for Inventra DMA issues. It can also be used at other places instead of #ifdefs.Signed-off-by Ajay Kumar Gupta <[email protected]>
[..]
drivers/usb/musb/musb_dma.h struct musb_hw_ep; · line 87
Quoted 5 lines
drivers/usb/musb/musb_dma.h +5
-0+#ifdef CONFIG_USB_INVENTRA_DMA +#define is_inventra_dma_enabled () 1 +#else +#define is_inventra_dma_enabled () 0 +#endif
actually I wanted to get rid of those...
Signature · 1 line
balbi
Re: [PATCH 2/5] musb: use system DMA to fix Inventra DMA issue on RTL-1.4
In reply to a message not in the archiveQuoted 2 lines · Ajay Kumar Gupta
MUSB RTL version 1.4 has a hardware issue when TX and RX DMA channels are simultaneously enabled which results in DMA lockup.
I've seen it on rtl1.8 also if I remember correctly.
Quoted 9 lines
Use system DMA for all RX channels as a workaround of this issue as this will have minimal throughput overhead based on the fact that Rx transfers are done in DMA mode-0 on OMAP34x/35x platforms.
Another approach to use PIO mode in opposite direction would increase the cpu loading and thus using system DMA is preferred workaround.
Signed-off-by Anand Gadiyar <[email protected]>Signed-off-by Ajay Kumar Gupta <[email protected]>
I think falling back to pio is better than this patch. It will most likely be only one transfer. Another approach is to allocate dma channels on a transfer basis. This is way too big of a problem.
Signature · 5 lines
balbi -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 2/5] musb: use system DMA to fix Inventra DMA issue on RTL-1.4
Quoted 6 lines · Felipe Balbi
Quoted 2 lines · Ajay Kumar Gupta
MUSB RTL version 1.4 has a hardware issue when TX and RX DMA channels are simultaneously enabled which results in DMA lockup.
I've seen it on rtl1.8 also if I remember correctly.
I'm fairly certain that this is not the case with RTL1.8, and if it is I'm very much interested in getting to the bottom of it. Do you have a test case that reproduces the lockup? Or a description of your use-case, or a register dump at failure, or any other clues?
Quoted 7 lines
Quoted 7 lines
Use system DMA for all RX channels as a workaround of this issue as this will have minimal throughput overhead based on the fact that Rx transfers are done in DMA mode-0 on OMAP34x/35x platforms.
Another approach to use PIO mode in opposite direction would increase the cpu loading and thus using system DMA is preferred workaround.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Anand Gadiyar <[email protected]>Signed-off-by Ajay Kumar Gupta <[email protected]>I think falling back to pio is better than this patch. It will most likely be only one transfer. Another approach is to allocate dma channels on a transfer basis. This is way too big of a problem.
Which one is better depends on how many endpoints are doing, transfers in parallel, I suppose.
I did post the a patch for the other approach (to fall back to PIO). I haven't received a response to that yet. I'm okay with either approach.
- Anand--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 5A47E75E594F054BAF48C5E4FC4B92AB03216237DA-/tLxBxkBPtCIQmiDNMet8wC/[email protected]
RE: [PATCH 2/5] musb: use system DMA to fix Inventra DMA issue on RTL-1.4
Hi,
Quoted 9 lines
Subject: RE: [PATCH 2/5] musb: use system DMA to fix Inventra DMA issue on RTL-1.4
Quoted 2 lines · Felipe Balbi
Quoted 1 line · Ajay Kumar Gupta
MUSB RTL version 1.4 has a hardware issue when TX and RX DMA channels
are
Quoted 2 lines
Quoted 1 line
simultaneously enabled which results in DMA lockup.
Quoted 9 lines
Quoted 2 lines
I've seen it on rtl1.8 also if I remember correctly.
I'm fairly certain that this is not the case with RTL1.8, and if it is I'm very
much interested in getting to the bottom of it. Do you have a test case that reproduces the lockup? Or a description of your use-case, or a register dump at failure, or any other clues?
Felipe,
I have also not seen lockup issue on rtl1.8. Can you provide more detail on your test case as Anand asked?
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Use system DMA for all RX channels as a workaround of this issue as
this
Quoted 1 line
Quoted 1 line
will have minimal throughput overhead based on the fact that Rx
transfers
Quoted 3 lines
Quoted 3 lines
are done in DMA mode-0 on OMAP34x/35x platforms.
Another approach to use PIO mode in opposite direction would increase
the
Quoted 6 lines
Quoted 4 lines
cpu loading and thus using system DMA is preferred workaround.
Signed-off-by Anand Gadiyar <[email protected]>Signed-off-by Ajay Kumar Gupta <[email protected]>I think falling back to pio is better than this patch.
At the cost of cpu, which certainly is not preferred.
Quoted 1 line
Quoted 1 line
It will most likely be only one transfer.
How about host mode with multiple devices connected and doing transfers? Falling back to PIO would kill the cpu.
Quoted 1 line
Quoted 1 line
Another approach is to allocate dma channels on a transfer basis.
Can you elaborate this?
Quoted 1 line
Quoted 1 line
This is way too big of a problem.
If we think of the scenarios in host mode then certainly using system DMA is best approach.
-Ajay
Quoted 8 lines
Which one is better depends on how many endpoints are doing, transfers in parallel, I suppose.
I did post the a patch for the other approach (to fall back to PIO). I haven't received a response to that yet. I'm okay with either approach.
- Anand
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH 2/5] musb: use system DMA to fix Inventra DMA issue on RTL-1.4
Hi,
Quoted 31 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Gupta, Ajay Kumar
Sent: Thursday, May 13, 2010 9:53 AM
To: Gadiyar, Anand; [email protected]
Cc: [email protected]; [email protected]
Subject: RE: [PATCH 2/5] musb: use system DMA to fix Inventra DMA issue on RTL-1.4Hi,
Quoted 1 line
Subject: RE: [PATCH 2/5] musb: use system DMA to fix Inventra
DMA issue
Quoted 2 lines
on
RTL-1.4Felipe,
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
Another approach to use PIO mode in opposite direction would increase
the
Quoted 6 lines
Quoted 4 lines
cpu loading and thus using system DMA is preferred workaround.
Signed-off-by Anand Gadiyar <[email protected]>Signed-off-by Ajay Kumar Gupta <[email protected]>I think falling back to pio is better than this patch.
At the cost of cpu, which certainly is not preferred.
Quoted 1 line
Quoted 1 line
It will most likely be only one transfer.
Quoted 7 lines
How about host mode with multiple devices connected and doing transfers?
Falling back to PIO would kill the cpu.Quoted 1 line
Quoted 1 line
Another approach is to allocate dma channels on a transfer basis.
Can you elaborate this?
It might be good idea to allocate the dma channels on tarnsfer basis as Felipe Suggested. The musb driver allocates dma channels for the first 8 enabled endpoints and higher endpoints works in PIO mode.
For system dma if there are more nummber of Rx endpoints enabled but not used for data Transfer you might end up having many sdma channles allocated biut not used which will Impact in the system of not utilizing the sdma channels effectively.
~Hema
Quoted 23 lines
Quoted 1 line
Quoted 1 line
This is way too big of a problem.
If we think of the scenarios in host mode then certainly using system DMA is best approach.
-Ajay
Quoted 1 line
Which one is better depends on how many endpoints are doing,
transfers
Quoted 4 lines
in parallel, I suppose.
I did post the a patch for the other approach (to fall back to PIO). I haven't received a response to that yet. I'm okay with
either approach.
Quoted 3 lines
- Anand
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
RE: [PATCH 2/5] musb: use system DMA to fix Inventra DMA issue on RTL-1.4
Hi,
Quoted 21 lines
Quoted 13 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
Another approach to use PIO mode in opposite direction would increase
the
Quoted 6 lines
Quoted 4 lines
cpu loading and thus using system DMA is preferred workaround.
Signed-off-by Anand Gadiyar <[email protected]>Signed-off-by Ajay Kumar Gupta <[email protected]>I think falling back to pio is better than this patch.
At the cost of cpu, which certainly is not preferred.
Quoted 1 line
Quoted 1 line
It will most likely be only one transfer.
Quoted 7 lines
How about host mode with multiple devices connected and doing transfers?
Falling back to PIO would kill the cpu.Quoted 1 line
Quoted 1 line
Another approach is to allocate dma channels on a transfer basis.
Can you elaborate this?
Quoted 9 lines
It might be good idea to allocate the dma channels on tarnsfer basis as Felipe
Suggested. The musb driver allocates dma channels for the first 8 enabled endpoints and higher endpoints works in PIO mode.
For system dma if there are more nummber of Rx endpoints enabled but not used for data
Transfer you might end up having many sdma channles allocated biut not used which will
Impact in the system of not utilizing the sdma channels effectively.
Felipe, Is this what you meant? If so then I have a patch (copied below) to fix this and I can post this one along with others.
-------------- cut here -----------------
Currently DMA channels are allocated and they remain allocated even if there is no active data transfer. Added channel_release() whenever there is no pending request.
--- drivers/usb/musb/musb_gadget.c | 27 +++++++++++++++++++++------ drivers/usb/musb/musb_host.c | 14 ++++++++++++-- 2 files changed, 33 insertions(+), 8 deletions(-)
drivers/usb/musb/musb_gadget.c +21 -6
@@ -297,9 +297,13 @@ static void txstate(struct musb *musb, struct musb_request *req) csr);#ifndef CONFIG_MUSB_PIO_ONLY -if (is_dma_capable () && musb_ep->dma) { + +if (is_dma_capable () && musb->dma_controller) {struct dma_controller *c = musb->dma_controller; +if (!musb_ep->dma) + musb_ep->dma = c->channel_alloc (c, musb_ep->hw_ep,1 ); + use_dma = (request->dma !=DMA_ADDR_INVALID );/* MUSB_TXCSR_P_ISO is still set correctly */
@@ -433,6 +437,7 @@ void musb_g_tx(struct musb *musb, u8 epnum)u8 __iomem *mbase = musb->mregs;struct musb_ep *musb_ep = &musb->endpoints[epnum].ep_in;void __iomem *epio = musb->endpoints[epnum].regs; +struct dma_controller *c = musb->dma_controller;struct dma_channel *dma;musb_ep_select (mbase, epnum);
@@ -535,6 +540,10 @@ void musb_g_tx(struct musb *musb, u8 epnum)if (!request) {DBG (4 ,"%s idle now\n" , musb_ep->end_point.name); +if (musb_ep->dma) { + c->channel_release (musb_ep->dma); + musb_ep->dma =NULL ; + }return ; } }
@@ -585,6 +594,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)struct usb_request *request = &req->request;struct musb_ep *musb_ep = &musb->endpoints[epnum].ep_out;void __iomem *epio = musb->endpoints[epnum].regs; +struct dma_controller *c = musb->dma_controller;unsigned fifo_count =0 ;u16 len = musb_ep->packet_sz;u16 csr =musb_readw (epio,MUSB_RXCSR );
@@ -601,8 +611,10 @@ static void rxstate(struct musb *musb, struct musb_request *req)return ; } +if (is_dma_capable () && musb->dma_controller && !musb_ep->dma) + musb_ep->dma = c->channel_alloc (c, musb_ep->hw_ep,0 ); +if ((is_cppi_enabled () ||is_cppi41_enabled ()) && musb_ep->dma) { -struct dma_controller *c = musb->dma_controller;struct dma_channel *channel = musb_ep->dma;/* NOTE: CPPI won't actually stop advancing the DMA
@@ -633,11 +645,9 @@ static void rxstate(struct musb *musb, struct musb_request *req)if (request->actual < request->length) {#ifdef CONFIG_USB_INVENTRA_DMA if (is_dma_capable () && musb_ep->dma) { -struct dma_controller *c;struct dma_channel *channel;int use_dma =0 ; - c = musb->dma_controller; channel = musb_ep->dma;/* We use DMA Req mode 0 in rx_csr, and DMA controller operates in
@@ -719,7 +729,6 @@ static void rxstate(struct musb *musb, struct musb_request *req)#ifdef CONFIG_USB_TUSB_OMAP_DMA if (tusb_dma_omap () && musb_ep->dma) { -struct dma_controller *c = musb->dma_controller;struct dma_channel *channel = musb_ep->dma;u32 dma_addr = request->dma + request->actual;int ret;
@@ -764,6 +773,7 @@ void musb_g_rx(struct musb *musb, u8 epnum)void __iomem *mbase = musb->mregs;struct musb_ep *musb_ep = &musb->endpoints[epnum].ep_out;void __iomem *epio = musb->endpoints[epnum].regs; +struct dma_controller *c = musb->dma_controller;struct dma_channel *dma;musb_ep_select (mbase, epnum);
@@ -838,8 +848,13 @@ void musb_g_rx(struct musb *musb, u8 epnum)musb_g_giveback (musb_ep, request,0 ); request =next_request (musb_ep); -if (!request) +if (!request) { +if (musb_ep->dma) { + c->channel_release (musb_ep->dma); + musb_ep->dma =NULL ; + }return ; + } }/* analyze request if the ep is hot */
drivers/usb/musb/musb_host.c +12 -2
@@ -460,11 +460,21 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb,*/ if (list_empty (&qh->hep->urb_list)) {struct list_head *head; +struct dma_controller *dma = musb->dma_controller; -if (is_in) +if (is_in) { ep->rx_reinit =1 ; -else +if (ep->rx_channel) { + dma->channel_release (ep->rx_channel); + ep->rx_channel =NULL ; + } + }else { ep->tx_reinit =1 ; +if (ep->tx_channel) { + dma->channel_release (ep->tx_channel); + ep->tx_channel =NULL ; + } + }/* Clobber old pointers to this qh */ musb_ep_set_qh (ep, is_in,NULL );
Signature · 5 lines
1.6.2.4 ----------------------------------------- -Ajay
Quoted 1 line
RE: [PATCH 2/5] musb: use system DMA to fix Inventra DMA issue on RTL-1.4
Hi,
Quoted 67 lines
-----Original Message-----
From: Gupta, Ajay Kumar
Sent: Thursday, May 13, 2010 3:41 PM
To: Kalliguddi, Hema; Gadiyar, Anand; [email protected]
Cc: [email protected]; [email protected]
Subject: RE: [PATCH 2/5] musb: use system DMA to fix Inventra DMA issue on RTL-1.4Hi,
Quoted 17 lines
Quoted 17 lines
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
Another approach to use PIO mode in opposite direction would increase
the
Quoted 6 lines
Quoted 4 lines
cpu loading and thus using system DMA is preferred workaround.
Signed-off-by Anand Gadiyar <[email protected]>Signed-off-by Ajay Kumar Gupta <[email protected]>I think falling back to pio is better than this patch.
At the cost of cpu, which certainly is not preferred.
Quoted 1 line
Quoted 1 line
It will most likely be only one transfer.
How about host mode with multiple devices connected and doing transfers?
Falling back to PIO would kill the cpu.Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Another approach is to allocate dma channels on a transfer basis.
Can you elaborate this?
It might be good idea to allocate the dma channels on
tarnsfer basis as
Quoted 2 lines
Felipe
Suggested. The musb driver allocates dma channels for thefirst 8 enabled
Quoted 2 lines
endpoints and higher endpoints works in PIO mode. For system dma if there are more nummber of Rx endpoints
enabled but not
Quoted 2 lines
used for data
Transfer you might end up having many sdma channlesallocated biut not
Quoted 2 lines
used which will
Impact in the system of not utilizing the sdma channels effectively.Felipe, Is this what you meant? If so then I have a patch (copied below)
to fix this and I can post this one along with others.-------------- cut here -----------------
Currently DMA channels are allocated and they remain allocated even if there is no active data transfer. Addedchannel_release()whenever there is no pending request.Signed-off-by Ajay Kumar Gupta <[email protected]>---
drivers/usb/musb/musb_gadget.c | 27 +++++++++++++++++++++------ drivers/usb/musb/musb_host.c | 14 ++++++++++++-- 2 files changed, 33 insertions(+), 8 deletions(-)drivers/usb/musb/musb_gadget.c +0
-0@@ -297,9 +297,13 @@ static void txstate(struct musb *musb, struct musb_request *req) csr);
drivers/usb/musb/musb_gadget.c static void txstate(struct musb *musb, · line 307
Quoted 10 lines
drivers/usb/musb/musb_gadget.c +4
-1#ifndef CONFIG_MUSB_PIO_ONLY -if (is_dma_capable () && musb_ep->dma) { + +if (is_dma_capable () && musb->dma_controller) {struct dma_controller *c = musb->dma_controller; +if (!musb_ep->dma) + musb_ep->dma = c->channel_alloc (c, musb_ep->hw_ep,1 );
If the channel_alloc returns failure then there should be a way to fallback to PIO mode. I am posting a patch for dynamic dma channel allocation for mentor dma for gadget driver.
~Hema
Quoted 137 lines
drivers/usb/musb/musb_gadget.c +1
-0+ use_dma = (request->dma !=DMA_ADDR_INVALID );/* MUSB_TXCSR_P_ISO is still set correctly */drivers/usb/musb/musb_gadget.c +1
-0@@ -433,6 +437,7 @@ void musb_g_tx(struct musb *musb, u8 epnum)u8 __iomem *mbase = musb->mregs;struct musb_ep *musb_ep = &musb->endpoints[epnum].ep_in;void __iomem *epio = musb->endpoints[epnum].regs; +struct dma_controller *c = musb->dma_controller;struct dma_channel *dma;musb_ep_select(mbase, epnum);drivers/usb/musb/musb_gadget.c +4
-0@@ -535,6 +540,10 @@ void musb_g_tx(struct musb *musb, u8 epnum)if (!request) {DBG (4 ,"%s idle now\n" , musb_ep->end_point.name); +if (musb_ep->dma) { + c->channel_release (musb_ep->dma); + musb_ep->dma =NULL ; + }return ; }}drivers/usb/musb/musb_gadget.c +1
-0@@ -585,6 +594,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)struct usb_request *request = &req->request;struct musb_ep *musb_ep = &musb->endpoints[epnum].ep_out;void __iomem *epio = musb->endpoints[epnum].regs; +struct dma_controller *c = musb->dma_controller;unsigned fifo_count =0 ;u16 len = musb_ep->packet_sz; u16 csr = musb_readw(epio, MUSB_RXCSR);drivers/usb/musb/musb_gadget.c +3
-1@@ -601,8 +611,10 @@ static void rxstate(struct musb *musb, struct musb_request *req) return; } +if (is_dma_capable () && musb->dma_controller && !musb_ep->dma) + musb_ep->dma = c->channel_alloc (c, musb_ep->hw_ep,0 ); +if ((is_cppi_enabled () ||is_cppi41_enabled ()) && musb_ep->dma) { -struct dma_controller *c = musb->dma_controller;struct dma_channel *channel = musb_ep->dma;/* NOTE: CPPI won't actually stop advancing the DMAdrivers/usb/musb/musb_gadget.c +0
-2@@ -633,11 +645,9 @@ static void rxstate(struct musb *musb, struct musb_request *req)if (request->actual < request->length) {#ifdef CONFIG_USB_INVENTRA_DMA if (is_dma_capable () && musb_ep->dma) { -struct dma_controller *c;struct dma_channel *channel;int use_dma =0 ; - c = musb->dma_controller; channel = musb_ep->dma;/* We use DMA Req mode 0 in rx_csr, and DMA controlleroperates in
drivers/usb/musb/musb_gadget.c +0
-1@@ -719,7 +729,6 @@ static void rxstate(struct musb *musb, struct musb_request *req)#ifdef CONFIG_USB_TUSB_OMAP_DMA if (tusb_dma_omap () && musb_ep->dma) { -struct dma_controller *c = musb->dma_controller; struct dma_channel *channel =musb_ep->dma; u32 dma_addr = request->dma + request->actual; int ret;drivers/usb/musb/musb_gadget.c +1
-0@@ -764,6 +773,7 @@ void musb_g_rx(struct musb *musb, u8 epnum)void __iomem *mbase = musb->mregs;struct musb_ep *musb_ep = &musb->endpoints[epnum].ep_out;void __iomem *epio = musb->endpoints[epnum].regs; +struct dma_controller *c = musb->dma_controller;struct dma_channel *dma;musb_ep_select(mbase, epnum);drivers/usb/musb/musb_gadget.c +6
-1@@ -838,8 +848,13 @@ void musb_g_rx(struct musb *musb, u8 epnum)musb_g_giveback (musb_ep, request,0 ); request =next_request (musb_ep); -if (!request) +if (!request) { +if (musb_ep->dma) { + c->channel_release (musb_ep->dma); + musb_ep->dma =NULL ; + }return ; + } }/* analyze request if the ep is hot */ drivers/usb/musb/musb_host.c +12
-2@@ -460,11 +460,21 @@ static void musb_advance_schedule(structmusb *musb, struct urb *urb, */ if (list_empty (&qh->hep->urb_list)) {struct list_head *head; +struct dma_controller *dma = musb->dma_controller; -if (is_in) +if (is_in) { ep->rx_reinit =1 ; -else +if (ep->rx_channel) { + dma->channel_release (ep->rx_channel); + ep->rx_channel =NULL ; + } + }else { ep->tx_reinit =1 ; +if (ep->tx_channel) { + dma->channel_release (ep->tx_channel); + ep->tx_channel =NULL ; + } + }/* Clobber old pointers to this qh */ musb_ep_set_qh(ep, is_in, NULL);Signature · 5 lines
1.6.2.4 ----------------------------------------- -AjayQuoted 1 line