diff mbox

[v2,05/10] usb: musb: tusb6010_omap: Do not reset the other direction's packet size

Message ID 20170510084231.19302-6-peter.ujfalusi@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Ujfalusi May 10, 2017, 8:42 a.m. UTC
We have one register for each EP to set the maximum packet size for both
TX and RX.
If for example an RX programming would happen before the previous TX
transfer finishes we would reset the TX packet side.

To fix this issue, only modify the TX or RX part of the register.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/usb/musb/tusb6010_omap.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Tony Lindgren May 10, 2017, 4:28 p.m. UTC | #1
* Peter Ujfalusi <peter.ujfalusi@ti.com> [170510 01:45]:
> We have one register for each EP to set the maximum packet size for both
> TX and RX.
> If for example an RX programming would happen before the previous TX
> transfer finishes we would reset the TX packet side.
> 
> To fix this issue, only modify the TX or RX part of the register.

Oh this is a nice one. I think we've always had this.

Bin, care to merge this one as a fix? This should have:

Fixes: 550a7375fe72 ("USB: Add MUSB and TUSB support")
Tested-by: Tony Lindgren <tony@atomide.com>
--
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
Bin Liu May 10, 2017, 5:07 p.m. UTC | #2
Hi,

On Wed, May 10, 2017 at 11:42:27AM +0300, Peter Ujfalusi wrote:
> We have one register for each EP to set the maximum packet size for both
> TX and RX.
> If for example an RX programming would happen before the previous TX
> transfer finishes we would reset the TX packet side.
> 
> To fix this issue, only modify the TX or RX part of the register.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
> ---
>  drivers/usb/musb/tusb6010_omap.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
> index db2e4c379ccf..4e1a6e4a61b8 100644
> --- a/drivers/usb/musb/tusb6010_omap.c
> +++ b/drivers/usb/musb/tusb6010_omap.c
> @@ -389,15 +389,19 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
>  
>  	if (chdat->tx) {
>  		/* Send transfer_packet_sz packets at a time */
> -		musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET,
> -			chdat->transfer_packet_sz);
> +		u32 psize = musb_readl(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET);

checkpatch.pl complains about declaration and assignment together.

> +		psize &= ~0x7ff;
> +		psize |= chdat->transfer_packet_sz;
> +		musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET, psize);
>  
>  		musb_writel(ep_conf, TUSB_EP_TX_OFFSET,
>  			TUSB_EP_CONFIG_XFR_SIZE(chdat->transfer_len));
>  	} else {
>  		/* Receive transfer_packet_sz packets at a time */
> -		musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET,
> -			chdat->transfer_packet_sz << 16);
> +		u32 psize = musb_readl(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET);

and at here too.

> +		psize &= ~(0x7ff << 16);
> +		psize |= (chdat->transfer_packet_sz << 16);
> +		musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET, psize);
>  
>  		musb_writel(ep_conf, TUSB_EP_RX_OFFSET,
>  			TUSB_EP_CONFIG_XFR_SIZE(chdat->transfer_len));

Regards,
-Bin.
--
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
Joe Perches May 10, 2017, 11:16 p.m. UTC | #3
On Wed, 2017-05-10 at 12:07 -0500, Bin Liu wrote:
> On Wed, May 10, 2017 at 11:42:27AM +0300, Peter Ujfalusi wrote:
> > We have one register for each EP to set the maximum packet size for both
> > TX and RX.
> > If for example an RX programming would happen before the previous TX
> > transfer finishes we would reset the TX packet side.
> > 
> > To fix this issue, only modify the TX or RX part of the register.
[]
> > diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
[]
> > @@ -389,15 +389,19 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
> >  
> >  	if (chdat->tx) {
> >  		/* Send transfer_packet_sz packets at a time */
> > -		musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET,
> > -			chdat->transfer_packet_sz);
> > +		u32 psize = musb_readl(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET);
> 
> checkpatch.pl complains about declaration and assignment together.

No it doesn't.

--
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
Peter Ujfalusi May 11, 2017, 6:19 a.m. UTC | #4
On 2017-05-11 02:16, Joe Perches wrote:
> On Wed, 2017-05-10 at 12:07 -0500, Bin Liu wrote:
>> On Wed, May 10, 2017 at 11:42:27AM +0300, Peter Ujfalusi wrote:
>>> We have one register for each EP to set the maximum packet size for both
>>> TX and RX.
>>> If for example an RX programming would happen before the previous TX
>>> transfer finishes we would reset the TX packet side.
>>>
>>> To fix this issue, only modify the TX or RX part of the register.
> []
>>> diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
> []
>>> @@ -389,15 +389,19 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
>>>   
>>>   	if (chdat->tx) {
>>>   		/* Send transfer_packet_sz packets at a time */
>>> -		musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET,
>>> -			chdat->transfer_packet_sz);
>>> +		u32 psize = musb_readl(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET);
>>
>> checkpatch.pl complains about declaration and assignment together.
> 
> No it doesn't.

It 'only' complains about:
WARNING: Missing a blank line after declarations

which is valid.

- Péter
--
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
Bin Liu May 11, 2017, 2:12 p.m. UTC | #5
On Thu, May 11, 2017 at 09:19:17AM +0300, Peter Ujfalusi wrote:
> 
> 
> On 2017-05-11 02:16, Joe Perches wrote:
> >On Wed, 2017-05-10 at 12:07 -0500, Bin Liu wrote:
> >>On Wed, May 10, 2017 at 11:42:27AM +0300, Peter Ujfalusi wrote:
> >>>We have one register for each EP to set the maximum packet size for both
> >>>TX and RX.
> >>>If for example an RX programming would happen before the previous TX
> >>>transfer finishes we would reset the TX packet side.
> >>>
> >>>To fix this issue, only modify the TX or RX part of the register.
> >[]
> >>>diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
> >[]
> >>>@@ -389,15 +389,19 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
> >>>  	if (chdat->tx) {
> >>>  		/* Send transfer_packet_sz packets at a time */
> >>>-		musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET,
> >>>-			chdat->transfer_packet_sz);
> >>>+		u32 psize = musb_readl(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET);
> >>
> >>checkpatch.pl complains about declaration and assignment together.
> >
> >No it doesn't.
> 
> It 'only' complains about:
> WARNING: Missing a blank line after declarations

It was it. My bad, I was multi-tasking and didn't read the log
carefully.

> 
> which is valid.

So will you update the patch to move the declaration to the beginning of
the function to avoid this WARNING. I would just fix it locally if you
prefer.

Regards,
-Bin.
--
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
Peter Ujfalusi May 12, 2017, 6:53 a.m. UTC | #6
Bin,

On 2017-05-11 17:12, Bin Liu wrote:
>> which is valid.
> 
> So will you update the patch to move the declaration to the beginning of
> the function to avoid this WARNING. I would just fix it locally if you
> prefer.

I was waiting for Vinod or someone from the DMAengine guys to say 
something for the first patch to send the v3, but I guess I can do it 
right away.

- Péter
--
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
Bin Liu May 12, 2017, 12:07 p.m. UTC | #7
On Fri, May 12, 2017 at 09:53:55AM +0300, Peter Ujfalusi wrote:
> Bin,
> 
> On 2017-05-11 17:12, Bin Liu wrote:
> >>which is valid.
> >
> >So will you update the patch to move the declaration to the beginning of
> >the function to avoid this WARNING. I would just fix it locally if you
> >prefer.
> 
> I was waiting for Vinod or someone from the DMAengine guys to say
> something for the first patch to send the v3, but I guess I can do
> it right away.

Yeah, this patch can go to the -rc in next week, but the rest will go to
-next, so you can send this patch seperately.

Regards,
-Bin.
--
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
diff mbox

Patch

diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index db2e4c379ccf..4e1a6e4a61b8 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -389,15 +389,19 @@  static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
 
 	if (chdat->tx) {
 		/* Send transfer_packet_sz packets at a time */
-		musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET,
-			chdat->transfer_packet_sz);
+		u32 psize = musb_readl(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET);
+		psize &= ~0x7ff;
+		psize |= chdat->transfer_packet_sz;
+		musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET, psize);
 
 		musb_writel(ep_conf, TUSB_EP_TX_OFFSET,
 			TUSB_EP_CONFIG_XFR_SIZE(chdat->transfer_len));
 	} else {
 		/* Receive transfer_packet_sz packets at a time */
-		musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET,
-			chdat->transfer_packet_sz << 16);
+		u32 psize = musb_readl(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET);
+		psize &= ~(0x7ff << 16);
+		psize |= (chdat->transfer_packet_sz << 16);
+		musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET, psize);
 
 		musb_writel(ep_conf, TUSB_EP_RX_OFFSET,
 			TUSB_EP_CONFIG_XFR_SIZE(chdat->transfer_len));