linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pandita, Vikram" <vikram.pandita@ti.com>
To: balbi@ti.com
Cc: linux-usb@vger.kernel.org, gadiyar@ti.com,
	linux-omap@vger.kernel.org, Moiz Sonasath <m-sonasath@ti.com>
Subject: Re: [PATCH v4] usb: musb: Enable DMA mode1 RX for USB-Mass-Storage
Date: Thu, 28 Jul 2011 21:50:17 -0700	[thread overview]
Message-ID: <CAFm5wm10MhJOLQ1WcWDSa3CpAQu7FnFcSQ8h4t9ZFJTrCj_V5Q@mail.gmail.com> (raw)
In-Reply-To: <20110729044508.GY9069@legolas.emea.dhcp.ti.com>

On Thu, Jul 28, 2011 at 9:45 PM, Felipe Balbi <balbi@ti.com> wrote:
> Hi,
>
> On Tue, Jul 19, 2011 at 10:11:58PM -0700, Vikram Pandita wrote:
>> From: Anand Gadiyar <gadiyar@ti.com>
>>
>> This patch enables the DMA mode1 RX support.
>> This feature is enabled based on the short_not_ok flag passed from
>> gadget drivers.
>>
>> This will result in a thruput performance gain of around
>> 40% for USB mass-storage/mtp use cases.
>>
>> Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
>> Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
>> Signed-off-by: Vikram Pandita <vikram.pandita@ti.com>
>> Tested-by: Vikram Pandita <vikram.pandita@ti.com>
>
> applied this one, but I changed commit log and code comment a little
> bit. Here's updated commit:
>
> commit e9c281b174f188adb7950ea8f6a55ca07be69914
> Author: Anand Gadiyar <gadiyar@ti.com>
> Date:   Tue Jul 19 22:11:58 2011 -0700
>
>    usb: musb: Enable DMA mode1 RX for transfers without short packets
>
>    This patch enables DMA mode1 for the RX patch when we know
>    there won't be any short packets. We check that by looking
>    into the short_no_ok flag, if it's true we enable mode1, otherwise
>    we use mode0 to transfer the data.
>
>    This will result in a throughput performance gain of around
>    40% for USB mass-storage/mtp use cases.
>
>    [ balbi@ti.com : updated commit log and code comments slightly ]

Ack

>
>    Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
>    Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
>    Signed-off-by: Vikram Pandita <vikram.pandita@ti.com>
>    Tested-by: Vikram Pandita <vikram.pandita@ti.com>
>    Signed-off-by: Felipe Balbi <balbi@ti.com>
>
> diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
> index b67a062..d314f58 100644
> --- a/drivers/usb/musb/musb_gadget.c
> +++ b/drivers/usb/musb/musb_gadget.c
> @@ -634,6 +634,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
>        u16                     len;
>        u16                     csr = musb_readw(epio, MUSB_RXCSR);
>        struct musb_hw_ep       *hw_ep = &musb->endpoints[epnum];
> +       u8                      use_mode_1;
>
>        if (hw_ep->is_shared_fifo)
>                musb_ep = &hw_ep->ep_in;
> @@ -683,6 +684,18 @@ static void rxstate(struct musb *musb, struct musb_request *req)
>
>        if (csr & MUSB_RXCSR_RXPKTRDY) {
>                len = musb_readw(epio, MUSB_RXCOUNT);
> +
> +               /*
> +                * Enable Mode 1 on RX transfers only when short_not_ok flag
> +                * is set. Currently short_not_ok flag is set only from
> +                * file_storage and f_mass_storage drivers
> +                */
> +
> +               if (request->short_not_ok && len == musb_ep->packet_sz)
> +                       use_mode_1 = 1;
> +               else
> +                       use_mode_1 = 0;
> +
>                if (request->actual < request->length) {
>  #ifdef CONFIG_USB_INVENTRA_DMA
>                        if (is_buffer_mapped(req)) {
> @@ -714,37 +727,41 @@ static void rxstate(struct musb *musb, struct musb_request *req)
>         * then becomes usable as a runtime "use mode 1" hint...
>         */
>
> -                               csr |= MUSB_RXCSR_DMAENAB;
> -#ifdef USE_MODE1
> -                               csr |= MUSB_RXCSR_AUTOCLEAR;
> -                               /* csr |= MUSB_RXCSR_DMAMODE; */
> -
> -                               /* this special sequence (enabling and then
> -                                * disabling MUSB_RXCSR_DMAMODE) is required
> -                                * to get DMAReq to activate
> -                                */
> -                               musb_writew(epio, MUSB_RXCSR,
> -                                       csr | MUSB_RXCSR_DMAMODE);
> -#else
> -                               if (!musb_ep->hb_mult &&
> -                                       musb_ep->hw_ep->rx_double_buffered)
> +                               /* Experimental: Mode1 works with mass storage use cases */
> +                               if (use_mode_1) {
>                                        csr |= MUSB_RXCSR_AUTOCLEAR;
> -#endif
> -                               musb_writew(epio, MUSB_RXCSR, csr);
> +                                       musb_writew(epio, MUSB_RXCSR, csr);
> +                                       csr |= MUSB_RXCSR_DMAENAB;
> +                                       musb_writew(epio, MUSB_RXCSR, csr);
> +
> +                                       /*
> +                                        * this special sequence (enabling and then
> +                                        * disabling MUSB_RXCSR_DMAMODE) is required
> +                                        * to get DMAReq to activate
> +                                        */
> +                                       musb_writew(epio, MUSB_RXCSR,
> +                                               csr | MUSB_RXCSR_DMAMODE);
> +                                       musb_writew(epio, MUSB_RXCSR, csr);
> +
> +                               } else {
> +                                       if (!musb_ep->hb_mult &&
> +                                               musb_ep->hw_ep->rx_double_buffered)
> +                                               csr |= MUSB_RXCSR_AUTOCLEAR;
> +                                       csr |= MUSB_RXCSR_DMAENAB;
> +                                       musb_writew(epio, MUSB_RXCSR, csr);
> +                               }
>
>                                if (request->actual < request->length) {
>                                        int transfer_size = 0;
> -#ifdef USE_MODE1
> -                                       transfer_size = min(request->length - request->actual,
> -                                                       channel->max_len);
> -#else
> -                                       transfer_size = min(request->length - request->actual,
> -                                                       (unsigned)len);
> -#endif
> -                                       if (transfer_size <= musb_ep->packet_sz)
> -                                               musb_ep->dma->desired_mode = 0;
> -                                       else
> +                                       if (use_mode_1) {
> +                                               transfer_size = min(request->length - request->actual,
> +                                                               channel->max_len);
>                                                musb_ep->dma->desired_mode = 1;
> +                                       } else {
> +                                               transfer_size = min(request->length - request->actual,
> +                                                               (unsigned)len);
> +                                               musb_ep->dma->desired_mode = 0;
> +                                       }
>
>                                        use_dma = c->channel_program(
>                                                        channel,
>
> --
> balbi
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2011-07-29  4:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-20  5:11 [PATCH v4] usb: musb: Enable DMA mode1 RX for USB-Mass-Storage Vikram Pandita
2011-07-20  5:34 ` Jassi Brar
2011-07-20  5:45   ` Pandita, Vikram
2011-07-20  5:53     ` Jassi Brar
2011-07-20 16:48       ` Pandita, Vikram
2011-07-26 15:06         ` Felipe Balbi
     [not found]           ` <20110726150655.GK32582-UiBtZHVXSwEVvW8u9ZQWYwjfymiNCTlR@public.gmane.org>
2011-07-27  3:50             ` Jassi Brar
2011-07-27 11:30               ` Felipe Balbi
2011-07-29  4:45 ` Felipe Balbi
2011-07-29  4:50   ` Pandita, Vikram [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFm5wm10MhJOLQ1WcWDSa3CpAQu7FnFcSQ8h4t9ZFJTrCj_V5Q@mail.gmail.com \
    --to=vikram.pandita@ti.com \
    --cc=balbi@ti.com \
    --cc=gadiyar@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m-sonasath@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).