All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] usb: musb: Enable DMA mode1 RX for USB-Mass-Storage
@ 2011-07-20  5:11 Vikram Pandita
  2011-07-20  5:34 ` Jassi Brar
  2011-07-29  4:45 ` Felipe Balbi
  0 siblings, 2 replies; 10+ messages in thread
From: Vikram Pandita @ 2011-07-20  5:11 UTC (permalink / raw)
  To: balbi, linux-usb, gadiyar; +Cc: linux-omap, Moiz Sonasath, Vikram Pandita

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>
---
v1 - initial push
v2 - fixed whitespace issues as per Sergei Shtylyov<sshtylyov@mvista.com> comments
v3 - restor authorship to Anand Gadiyar <gadiyar@ti.com>
v4 - adding my signed-off as per Kevin Hilman <khilman@ti.com>

 drivers/usb/musb/musb_gadget.c |   68 ++++++++++++++++++++++++---------------
 1 files changed, 42 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 6aeb363..4a1432e 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 for RX transfers only for mass-storage
+		 * use-case, based on short_not_ok flag which 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,40 @@ 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,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v4] usb: musb: Enable DMA mode1 RX for USB-Mass-Storage
  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-29  4:45 ` Felipe Balbi
  1 sibling, 1 reply; 10+ messages in thread
From: Jassi Brar @ 2011-07-20  5:34 UTC (permalink / raw)
  To: Vikram Pandita; +Cc: balbi, linux-usb, gadiyar, linux-omap, Moiz Sonasath

On Wed, Jul 20, 2011 at 10:41 AM, Vikram Pandita <vikram.pandita@ti.com> 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>
> ---
> v1 - initial push
> v2 - fixed whitespace issues as per Sergei Shtylyov<sshtylyov@mvista.com> comments
> v3 - restor authorship to Anand Gadiyar <gadiyar@ti.com>
> v4 - adding my signed-off as per Kevin Hilman <khilman@ti.com>
>
>  drivers/usb/musb/musb_gadget.c |   68 ++++++++++++++++++++++++---------------
>  1 files changed, 42 insertions(+), 26 deletions(-)

> @@ -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 for RX transfers only for mass-storage
> +                * use-case, based on short_not_ok flag which 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;
> +
There is nothing UMS class specific in this patch...
(request->short_not_ok && len == musb_ep->packet_sz) may not be the
signature of, and only of, Mass Storage Functions. So maybe removing
the UMS mention from
comment and change-log is a good idea.
You might want to add is-ep-type-bulk-out check to the condition
though, so that it doesn't affect
cases that you didn't verify.
--
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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4] usb: musb: Enable DMA mode1 RX for USB-Mass-Storage
  2011-07-20  5:34 ` Jassi Brar
@ 2011-07-20  5:45   ` Pandita, Vikram
  2011-07-20  5:53     ` Jassi Brar
  0 siblings, 1 reply; 10+ messages in thread
From: Pandita, Vikram @ 2011-07-20  5:45 UTC (permalink / raw)
  To: Jassi Brar; +Cc: balbi, linux-usb, gadiyar, linux-omap, Moiz Sonasath

On Tue, Jul 19, 2011 at 10:34 PM, Jassi Brar <jassisinghbrar@gmail.com> wrote:
>
> On Wed, Jul 20, 2011 at 10:41 AM, Vikram Pandita <vikram.pandita@ti.com> 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>
> > ---
> > v1 - initial push
> > v2 - fixed whitespace issues as per Sergei Shtylyov<sshtylyov@mvista.com> comments
> > v3 - restor authorship to Anand Gadiyar <gadiyar@ti.com>
> > v4 - adding my signed-off as per Kevin Hilman <khilman@ti.com>
> >
> >  drivers/usb/musb/musb_gadget.c |   68 ++++++++++++++++++++++++---------------
> >  1 files changed, 42 insertions(+), 26 deletions(-)
>
> > @@ -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 for RX transfers only for mass-storage
> > +                * use-case, based on short_not_ok flag which 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;
> > +
> There is nothing UMS class specific in this patch...
> (request->short_not_ok && len == musb_ep->packet_sz) may not be the
> signature of, and only of, Mass Storage Functions. So maybe removing
> the UMS mention from
> comment and change-log is a good idea.

Have you grepped the code in drivers/usb/gadget/*.*
only UMS sets this flag today and hence the use of this flag.

As i understand, on UMS, CSW/data/CBW  - the data part size is a known
size and to be safe that mode=1 dma is not stuck up,
the mode is enabled only for the gadget driver that sets short_not_ok
flag - and that today happens to be only UMS.

> You might want to add is-ep-type-bulk-out check to the condition
> though, so that it doesn't affect
> cases that you didn't verify.

TX path (IN host), already uses the mode=1 DMA and hence the comment
is not valid.
This patch just also enables mode=1 on RX path.
--
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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4] usb: musb: Enable DMA mode1 RX for USB-Mass-Storage
  2011-07-20  5:45   ` Pandita, Vikram
@ 2011-07-20  5:53     ` Jassi Brar
  2011-07-20 16:48       ` Pandita, Vikram
  0 siblings, 1 reply; 10+ messages in thread
From: Jassi Brar @ 2011-07-20  5:53 UTC (permalink / raw)
  To: Pandita, Vikram; +Cc: balbi, linux-usb, gadiyar, linux-omap, Moiz Sonasath

On Wed, Jul 20, 2011 at 11:15 AM, Pandita, Vikram <vikram.pandita@ti.com> wrote:
> On Tue, Jul 19, 2011 at 10:34 PM, Jassi Brar <jassisinghbrar@gmail.com> wrote:
>>
>> On Wed, Jul 20, 2011 at 10:41 AM, Vikram Pandita <vikram.pandita@ti.com> 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>
>> > ---
>> > v1 - initial push
>> > v2 - fixed whitespace issues as per Sergei Shtylyov<sshtylyov@mvista.com> comments
>> > v3 - restor authorship to Anand Gadiyar <gadiyar@ti.com>
>> > v4 - adding my signed-off as per Kevin Hilman <khilman@ti.com>
>> >
>> >  drivers/usb/musb/musb_gadget.c |   68 ++++++++++++++++++++++++---------------
>> >  1 files changed, 42 insertions(+), 26 deletions(-)
>>
>> > @@ -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 for RX transfers only for mass-storage
>> > +                * use-case, based on short_not_ok flag which 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;
>> > +
>> There is nothing UMS class specific in this patch...
>> (request->short_not_ok && len == musb_ep->packet_sz) may not be the
>> signature of, and only of, Mass Storage Functions. So maybe removing
>> the UMS mention from
>> comment and change-log is a good idea.
>
> Have you grepped the code in drivers/usb/gadget/*.*
> only UMS sets this flag today and hence the use of this flag.
>
> As i understand, on UMS, CSW/data/CBW  - the data part size is a known
> size and to be safe that mode=1 dma is not stuck up,
> the mode is enabled only for the gadget driver that sets short_not_ok
> flag - and that today happens to be only UMS.

This *today happens to be only UMS* is my exact point here.
Can you guarantee no other function driver will ever expect only
full packet xfers and treat short as errors ?


>> You might want to add is-ep-type-bulk-out check to the condition
>> though, so that it doesn't affect
>> cases that you didn't verify.
>
> TX path (IN host), already uses the mode=1 DMA and hence the comment
> is not valid.
> This patch just also enables mode=1 on RX path.
Well, then no need for the ep-type check.
--
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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4] usb: musb: Enable DMA mode1 RX for USB-Mass-Storage
  2011-07-20  5:53     ` Jassi Brar
@ 2011-07-20 16:48       ` Pandita, Vikram
  2011-07-26 15:06         ` Felipe Balbi
  0 siblings, 1 reply; 10+ messages in thread
From: Pandita, Vikram @ 2011-07-20 16:48 UTC (permalink / raw)
  To: Jassi Brar, Anand Gadiyar, Balbi, Felipe
  Cc: linux-usb, linux-omap, Moiz Sonasath

On Tue, Jul 19, 2011 at 10:53 PM, Jassi Brar <jassisinghbrar@gmail.com> wrote:
>
> On Wed, Jul 20, 2011 at 11:15 AM, Pandita, Vikram <vikram.pandita@ti.com> wrote:
> > On Tue, Jul 19, 2011 at 10:34 PM, Jassi Brar <jassisinghbrar@gmail.com> wrote:
> >>
> >> On Wed, Jul 20, 2011 at 10:41 AM, Vikram Pandita <vikram.pandita@ti.com> 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>
> >> > ---
> >> > v1 - initial push
> >> > v2 - fixed whitespace issues as per Sergei Shtylyov<sshtylyov@mvista.com> comments
> >> > v3 - restor authorship to Anand Gadiyar <gadiyar@ti.com>
> >> > v4 - adding my signed-off as per Kevin Hilman <khilman@ti.com>
> >> >
> >> >  drivers/usb/musb/musb_gadget.c |   68 ++++++++++++++++++++++++---------------
> >> >  1 files changed, 42 insertions(+), 26 deletions(-)
> >>
> >> > @@ -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 for RX transfers only for mass-storage
> >> > +                * use-case, based on short_not_ok flag which 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;
> >> > +
> >> There is nothing UMS class specific in this patch...
> >> (request->short_not_ok && len == musb_ep->packet_sz) may not be the
> >> signature of, and only of, Mass Storage Functions. So maybe removing
> >> the UMS mention from
> >> comment and change-log is a good idea.
> >
> > Have you grepped the code in drivers/usb/gadget/*.*
> > only UMS sets this flag today and hence the use of this flag.
> >
> > As i understand, on UMS, CSW/data/CBW  - the data part size is a known
> > size and to be safe that mode=1 dma is not stuck up,
> > the mode is enabled only for the gadget driver that sets short_not_ok
> > flag - and that today happens to be only UMS.
>
> This *today happens to be only UMS* is my exact point here.
> Can you guarantee no other function driver will ever expect only
> full packet xfers and treat short as errors ?
>

We are trying to test if short_not_ok may not be needed at all. But
all gadgets need to be tested on MUSB for that.
We will need wider help from MUSB maintainer/author(anand g) to
determine if removing short_not_ok is fine on MUSB for _all_ gadgets.

To be safe we only enable for UMS use case today that is definitely
working fine.

Time for Maintainer/author to pitch in !!

>
> >> You might want to add is-ep-type-bulk-out check to the condition
> >> though, so that it doesn't affect
> >> cases that you didn't verify.
> >
> > TX path (IN host), already uses the mode=1 DMA and hence the comment
> > is not valid.
> > This patch just also enables mode=1 on RX path.
> Well, then no need for the ep-type check.

where did u see ep-type check? i can see only packet size check. Did i miss?
--
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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4] usb: musb: Enable DMA mode1 RX for USB-Mass-Storage
  2011-07-20 16:48       ` Pandita, Vikram
@ 2011-07-26 15:06         ` Felipe Balbi
       [not found]           ` <20110726150655.GK32582-UiBtZHVXSwEVvW8u9ZQWYwjfymiNCTlR@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Felipe Balbi @ 2011-07-26 15:06 UTC (permalink / raw)
  To: Pandita, Vikram
  Cc: Jassi Brar, Anand Gadiyar, Balbi, Felipe, linux-usb, linux-omap,
	Moiz Sonasath

[-- Attachment #1: Type: text/plain, Size: 1017 bytes --]

Hi,

On Wed, Jul 20, 2011 at 09:48:53AM -0700, Pandita, Vikram wrote:
> > This *today happens to be only UMS* is my exact point here.
> > Can you guarantee no other function driver will ever expect only
> > full packet xfers and treat short as errors ?
> >
> 
> We are trying to test if short_not_ok may not be needed at all. But
> all gadgets need to be tested on MUSB for that.
> We will need wider help from MUSB maintainer/author(anand g) to
> determine if removing short_not_ok is fine on MUSB for _all_ gadgets.
> 
> To be safe we only enable for UMS use case today that is definitely
> working fine.
> 
> Time for Maintainer/author to pitch in !!

I'm thinking on allowing this patch to go in if nobody has really strong
arguments against it. The real fix, though, would need a bigger re-write
of the endpoint IRQ handling and that would need more time to write and
stabilize. Together with the huge amount of HW issues MUSB has, it's
quite a task (been there, done that).

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4] usb: musb: Enable DMA mode1 RX for USB-Mass-Storage
       [not found]           ` <20110726150655.GK32582-UiBtZHVXSwEVvW8u9ZQWYwjfymiNCTlR@public.gmane.org>
@ 2011-07-27  3:50             ` Jassi Brar
  2011-07-27 11:30               ` Felipe Balbi
  0 siblings, 1 reply; 10+ messages in thread
From: Jassi Brar @ 2011-07-27  3:50 UTC (permalink / raw)
  To: balbi-l0cyMroinI0
  Cc: Pandita, Vikram, Anand Gadiyar, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA, Moiz Sonasath

On Tue, Jul 26, 2011 at 8:36 PM, Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org> wrote:
> Hi,
>
> On Wed, Jul 20, 2011 at 09:48:53AM -0700, Pandita, Vikram wrote:
>> > This *today happens to be only UMS* is my exact point here.
>> > Can you guarantee no other function driver will ever expect only
>> > full packet xfers and treat short as errors ?
>> >
>>
>> We are trying to test if short_not_ok may not be needed at all. But
>> all gadgets need to be tested on MUSB for that.
>> We will need wider help from MUSB maintainer/author(anand g) to
>> determine if removing short_not_ok is fine on MUSB for _all_ gadgets.
>>
>> To be safe we only enable for UMS use case today that is definitely
>> working fine.
>>
>> Time for Maintainer/author to pitch in !!
>
> I'm thinking on allowing this patch to go in if nobody has really strong
> arguments against it. The real fix, though, would need a bigger re-write
> of the endpoint IRQ handling and that would need more time to write and
> stabilize. Together with the huge amount of HW issues MUSB has, it's
> quite a task (been there, done that).

Please note that I never objected to the _code_.

I just think if the _comments_ could be made UMS agnostic... for ex if it works
for other protocols just fine(quite possible) in future the reader
might wonder what
is UMS specific about the code snippet.

Please feel free to go ahead and apply the patch.

thnx
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4] usb: musb: Enable DMA mode1 RX for USB-Mass-Storage
  2011-07-27  3:50             ` Jassi Brar
@ 2011-07-27 11:30               ` Felipe Balbi
  0 siblings, 0 replies; 10+ messages in thread
From: Felipe Balbi @ 2011-07-27 11:30 UTC (permalink / raw)
  To: Jassi Brar
  Cc: balbi, Pandita, Vikram, Anand Gadiyar, linux-usb, linux-omap,
	Moiz Sonasath

[-- Attachment #1: Type: text/plain, Size: 1653 bytes --]

Hi,

On Wed, Jul 27, 2011 at 09:20:02AM +0530, Jassi Brar wrote:
> On Tue, Jul 26, 2011 at 8:36 PM, Felipe Balbi <balbi@ti.com> wrote:
> > Hi,
> >
> > On Wed, Jul 20, 2011 at 09:48:53AM -0700, Pandita, Vikram wrote:
> >> > This *today happens to be only UMS* is my exact point here.
> >> > Can you guarantee no other function driver will ever expect only
> >> > full packet xfers and treat short as errors ?
> >> >
> >>
> >> We are trying to test if short_not_ok may not be needed at all. But
> >> all gadgets need to be tested on MUSB for that.
> >> We will need wider help from MUSB maintainer/author(anand g) to
> >> determine if removing short_not_ok is fine on MUSB for _all_ gadgets.
> >>
> >> To be safe we only enable for UMS use case today that is definitely
> >> working fine.
> >>
> >> Time for Maintainer/author to pitch in !!
> >
> > I'm thinking on allowing this patch to go in if nobody has really strong
> > arguments against it. The real fix, though, would need a bigger re-write
> > of the endpoint IRQ handling and that would need more time to write and
> > stabilize. Together with the huge amount of HW issues MUSB has, it's
> > quite a task (been there, done that).
> 
> Please note that I never objected to the _code_.
> 
> I just think if the _comments_ could be made UMS agnostic... for ex if it works
> for other protocols just fine(quite possible) in future the reader
> might wonder what
> is UMS specific about the code snippet.

for sure, makes sense to me. Vikram, do you want to update the comment
to remove UMS mentions ? Most likely UASP will have the same deal, btw.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4] usb: musb: Enable DMA mode1 RX for USB-Mass-Storage
  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-29  4:45 ` Felipe Balbi
  2011-07-29  4:50   ` Pandita, Vikram
  1 sibling, 1 reply; 10+ messages in thread
From: Felipe Balbi @ 2011-07-29  4:45 UTC (permalink / raw)
  To: Vikram Pandita; +Cc: balbi, linux-usb, gadiyar, linux-omap, Moiz Sonasath

[-- Attachment #1: Type: text/plain, Size: 4800 bytes --]

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 ]
    
    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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v4] usb: musb: Enable DMA mode1 RX for USB-Mass-Storage
  2011-07-29  4:45 ` Felipe Balbi
@ 2011-07-29  4:50   ` Pandita, Vikram
  0 siblings, 0 replies; 10+ messages in thread
From: Pandita, Vikram @ 2011-07-29  4:50 UTC (permalink / raw)
  To: balbi; +Cc: linux-usb, gadiyar, linux-omap, Moiz Sonasath

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-07-29  4:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.