Re: [PATCH] musb_host: Fix high bandwidth iso transfer issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 25, 2010 at 7:06 PM, Felipe Balbi <balbi@xxxxxx> wrote:
> On Thu, Nov 25, 2010 at 06:24:46PM +0800, Ming Lei wrote:
>>
>> 2010/11/25 Anand Gadiyar <gadiyar@xxxxxx>:
>>>
>>> Felipe Balbi wrote:
>>>>
>>>> Hi,
>>>>
>>>> On Thu, Nov 25, 2010 at 04:54:05PM +0800, Bob Liu wrote:
>>>> >>> The only work around is to config the receive FIFO into single
>>>
>>> buffer
>>>>
>>>> >>> mode.
>>>> >>
>>>> >> And how to do that ?
>>>> >>
>>>> >
>>>> >It's used to by "USB: musb: disable double buffering for older RTL
>>>> >versions"
>>>>
>>>>
>>>> http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git;a=commitdif
>>>
>>> f;h=9f445cb29918dc488b7a9a92ef018599cce33df7
>>>>
>>>> yeah, but that breaks other stuff high bandwidth eps, so we need a
>>>> better way to "disable double buffering".
>>>>
>>>
>>> Here's how I understand the problem.
>>>
>>> Blackfin has a statically configured fifo allocation - with no
>>> possibility to change it. The IP uses double buffering by default
>>> if a FIFO is allocated space enough to hold 2*maxp (which is the
>>> case for at least some of the endpoints).
>>>
>>> The only way to make the IP use single buffering is to tell the
>>> IP that the maxp is different.
>>>
>>> This is an anomaly only in the blackfin - I don't see any way to
>>> work around this (for lack of information), than what has been
>>> implemented in the patch that already got merged.
>>
>> Yes, I agree.
>>
>>>
>>> However, that code should be made to execute only on blackfin
>>> and not on other platforms - so that the others are not broken
>>> by that change.
>>
>> Even in blackfin platform, the code may break some function,
>> especially for full speed device, which was explained a lot in
>> the previous discussion:
>
> how about something like:
>
> From 0cbcba73308ca808d898c2b5d8220e3ff9f52e58 Mon Sep 17 00:00:00 2001
> From: Felipe Balbi <balbi@xxxxxx>
> Date: Thu, 18 Nov 2010 13:44:29 +0200
> Subject: [PATCH] usb: musb: disable double buffer when it's broken
> Organization: Texas Instruments\n
>
> We know that blackfin doesn't support double
> buffering feature as of today. So we add a
> flag set by musb_platform_init() to forcefully
> disable that feature.
>
> Such flag is created and marked as deprecated
> to force us to find a solution for the missing
> double buffering support on blackfin.
>
> NYET-Signed-off-by: Felipe Balbi <balbi@xxxxxx>
> ---
> Âdrivers/usb/musb/blackfin.c  Â|  Â1 +
> Âdrivers/usb/musb/musb_core.h  |  13 +++++++++++++
> Âdrivers/usb/musb/musb_gadget.c | Â 28 ++++++++++++++++++++++------
> Âdrivers/usb/musb/musb_host.c  |  17 +++++++++--------
> Â4 files changed, 45 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
> index fcb5206..dba1f63 100644
> --- a/drivers/usb/musb/blackfin.c
> +++ b/drivers/usb/musb/blackfin.c
> @@ -397,6 +397,7 @@ int __init musb_platform_init(struct musb *musb, void
> *board_data)
> Â Â Â Â Â Â Â Âmusb->xceiv->set_power = bfin_set_power;
> Â Â Â Âmusb->isr = blackfin_interrupt;
> + Â Â Â musb->double_buffer_not_ok = true;
> Â Â Â Âreturn 0;
> Â}
> diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
> index febaabc..05cf5ef 100644
> --- a/drivers/usb/musb/musb_core.h
> +++ b/drivers/usb/musb/musb_core.h
> @@ -443,6 +443,19 @@ struct musb {
>    Âunsigned        Âtest_mode:1;
>    Âunsigned        Âsoftconnect:1;
> Â+ Â Â Â/*
> + Â Â Â Â* FIXME: Remove this flag.
> + Â Â Â Â*
> + Â Â Â Â* This is only added to allow Blackfin to work
> + Â Â Â Â* with current driver. For some unknown reason
> + Â Â Â Â* Blackfin doesn't work with double buffering
> + Â Â Â Â* and that's enabled by default.
> + Â Â Â Â*
> + Â Â Â Â* We added this flag to forcefully disable double
> + Â Â Â Â* buffering until we get it working.
> + Â Â Â Â*/
> +    unsigned        Âdouble_buffer_not_ok:1 __deprecated;
> +
> Â Â Â Âu8 Â Â Â Â Â Â Â Â Â Â Âaddress;
> Â Â Â Âu8 Â Â Â Â Â Â Â Â Â Â Âtest_mode_nr;
> Â Â Â Âu16 Â Â Â Â Â Â Â Â Â Â ackpend; Â Â Â Â Â Â Â Â/* ep0 */
> diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
> index 36cfd06..d6bfad8 100644
> --- a/drivers/usb/musb/musb_gadget.c
> +++ b/drivers/usb/musb/musb_gadget.c
> @@ -925,10 +925,18 @@ static int musb_gadget_enable(struct usb_ep *ep,
> Â Â Â Â Â Â Â Â/* REVISIT if can_bulk_split(), use by updating "tmp";
> Â Â Â Â Â Â Â Â * likewise high bandwidth periodic tx
> Â Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â /* Set TXMAXP with the FIFO size of the endpoint
> - Â Â Â Â Â Â Â Â* to disable double buffering mode.
> +
> + Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â* At least blackfin doesn't like Double Buffering
> + Â Â Â Â Â Â Â Â* which is enabled by default. So check if we can
> + Â Â Â Â Â Â Â Â* support double buffering and set MaxPacket register
> + Â Â Â Â Â Â Â Â* accordingly.
> Â Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz |
> (musb_ep->hb_mult << 11));
> + Â Â Â Â Â Â Â if (musb->double_buffer_not_ok)
> + Â Â Â Â Â Â Â Â Â Â Â musb_writew(regs, MUSB_TXMAXP, 1024);

And  I think musb_writew(regs, MUSB_TXMAXP, hw_ep->max_packet_sz_tx); is better.

> + Â Â Â Â Â Â Â else
> + Â Â Â Â Â Â Â Â Â Â Â musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â | (musb_ep->hb_mult << 11));
> Â Â Â Â Â Â Â Âcsr = MUSB_TXCSR_MODE | MUSB_TXCSR_CLRDATATOG;
> Â Â Â Â Â Â Â Âif (musb_readw(regs, MUSB_TXCSR)
> @@ -961,10 +969,18 @@ static int musb_gadget_enable(struct usb_ep *ep,
> Â Â Â Â Â Â Â Â/* REVISIT if can_bulk_combine() use by updating "tmp"
> Â Â Â Â Â Â Â Â * likewise high bandwidth periodic rx
> Â Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â /* Set RXMAXP with the FIFO size of the endpoint
> - Â Â Â Â Â Â Â Â* to disable double buffering mode.
> +
> + Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â* At least blackfin doesn't like Double Buffering
> + Â Â Â Â Â Â Â Â* which is enabled by default. So check if we can
> + Â Â Â Â Â Â Â Â* support double buffering and MaxPacket register
> + Â Â Â Â Â Â Â Â* accordingly.
> Â Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â musb_writew(regs, MUSB_RXMAXP, musb_ep->packet_sz |
> (musb_ep->hb_mult << 11));
> + Â Â Â Â Â Â Â if (musb->double_buffer_not_ok)
> + Â Â Â Â Â Â Â Â Â Â Â musb_writew(regs, MUSB_TXMAXP, 1024);

So as here, musb_writew(regs, MUSB_RXMAXP, hw_ep->max_packet_sz_rx);
And here should write MUSB_RXMAXP instead of MUSB_TXMAXP.

> + Â Â Â Â Â Â Â else
> + Â Â Â Â Â Â Â Â Â Â Â musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â | (musb_ep->hb_mult << 11));
> Â Â Â Â Â Â Â Â/* force shared fifo to OUT-only mode */
> Â Â Â Â Â Â Â Âif (hw_ep->is_shared_fifo) {
> diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
> index 4d5bcb4..0484bad 100644
> --- a/drivers/usb/musb/musb_host.c
> +++ b/drivers/usb/musb/musb_host.c
> @@ -606,11 +606,12 @@ musb_rx_reinit(struct musb *musb, struct musb_qh *qh,
> struct musb_hw_ep *ep)
> Â Â Â Âmusb_writeb(ep->regs, MUSB_RXTYPE, qh->type_reg);
> Â Â Â Âmusb_writeb(ep->regs, MUSB_RXINTERVAL, qh->intv_reg);
> Â Â Â Â/* NOTE: bulk combining rewrites high bits of maxpacket */
> - Â Â Â /* Set RXMAXP with the FIFO size of the endpoint
> + Â Â Â /*
> + Â Â Â Â* Set RXMAXP with the FIFO size of the endpoint
> Â Â Â Â * to disable double buffer mode.
> Â Â Â Â */
> - Â Â Â if (musb->hwvers < MUSB_HWVERS_2000)
> - Â Â Â Â Â Â Â musb_writew(ep->regs, MUSB_RXMAXP, ep->max_packet_sz_rx);
> + Â Â Â if (musb->double_buffer_not_ok)
> + Â Â Â Â Â Â Â musb_writew(ep->regs, MUSB_RXMAXP, 1024);

musb_writew(ep->regs, MUSB_RXMAXP, ep->max_packet_sz_rx); is better;
And tx route should also be changed.

> Â Â Â Âelse
> Â Â Â Â Â Â Â Âmusb_writew(ep->regs, MUSB_RXMAXP,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âqh->maxpacket | ((qh->hb_mult - 1) << 11));
> @@ -784,14 +785,14 @@ static void musb_ep_program(struct musb *musb, u8
> epnum,
> Â Â Â Â Â Â Â Â/* protocol/endpoint/interval/NAKlimit */
> Â Â Â Â Â Â Â Âif (epnum) {
> Â Â Â Â Â Â Â Â Â Â Â Âmusb_writeb(epio, MUSB_TXTYPE, qh->type_reg);
> - Â Â Â Â Â Â Â Â Â Â Â if (can_bulk_split(musb, qh->type))
> + Â Â Â Â Â Â Â Â Â Â Â if (musb->double_buffer_not_ok)
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âmusb_writew(epio, MUSB_TXMAXP,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â packet_sz
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â | ((hw_ep->max_packet_sz_tx /
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â packet_sz) - 1) << 11);
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1024);
> Â Â Â Â Â Â Â Â Â Â Â Âelse
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âmusb_writew(epio, MUSB_TXMAXP,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â packet_sz);
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â qh->maxpacket |
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ((qh->hb_mult - 1) << 11));
> +
> Â Â Â Â Â Â Â Â Â Â Â Âmusb_writeb(epio, MUSB_TXINTERVAL, qh->intv_reg);
> Â Â Â Â Â Â Â Â} else {
> Â Â Â Â Â Â Â Â Â Â Â Âmusb_writeb(epio, MUSB_NAKLIMIT0, qh->intv_reg);
> --
> 1.7.3.2.245.g03276
>
>
> --
> balbi
>

-- 
Thanks,
--Bob
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux