Re: [PATCH v2 4/6] usb: musb: fix bit masks for CSR in musb_h_tx_flush_fifo()

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

 



Hello.

On 05/23/2014 04:57 PM, Daniel Mack wrote:

The datasheet says that MUSB_TXCSR_FLUSHFIFO is only valid when
MUSB_CSR0_TXPKTRDY is set as well. Also, clear the MUSB_TXCSR_H_RXSTALL
which drivers are not supposed to write,

     I'd say "to set" ISO "to write" -- the bit still is clearable by the driver.

You're referring to the wording in the commit log? I can fix that, sure.

   Yes, of course.

according to the docs.

     Looks like the new code is contrariwise not clearing the stall.

I I'd say it's not supposed to. I just wanted the bit to be 0 when
writing back the CSR.

You failed to achieve that since you forgot ~; you're clearing all bits but this one.

IOW, it follows the advisory in the datasheet that
says: "You should clear this bit."

   It only makes sense to clear it in the interrupt handler I think.

With this patch applied, the warning in this function does no longer
kick in when an USB soundcard is unplugged while the stream is active.

Signed-off-by: Daniel Mack <zonque@xxxxxxxxx>
---
   drivers/usb/musb/musb_host.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index f98a7c0..9d3a5b2 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -120,7 +120,8 @@ static void musb_h_tx_flush_fifo(struct musb_hw_ep *ep)
   		if (csr != lastcsr)
   			dev_dbg(musb->controller, "Host TX FIFONOTEMPTY csr: %02x\n", csr);
   		lastcsr = csr;
-		csr |= MUSB_TXCSR_FLUSHFIFO;
+		csr &= MUSB_TXCSR_H_RXSTALL;
+		csr |= MUSB_TXCSR_FLUSHFIFO | MUSB_CSR0_TXPKTRDY;

Yes, the manual tells us to set TxPktRdy along with FlushFIFO. This has been a long standing bug, perhaps because the old versions of the MUSBHDRC manuals didn't mention that.

   		musb_writew(epio, MUSB_TXCSR, csr);
   		csr = musb_readw(epio, MUSB_TXCSR);

Another possible bug here is not flushing the second FIFO in the double-buffered mode...

   		if (WARN(retries-- < 1,

     I guess you meant this WARN()?

Jup. It's easy to reproduce btw, presumably with any off-the-shelf USB
audio card, connected to something like the BBB.

   BBB? My guess would be the bulk-only transport for the USB storage devices...

Thanks,
Daniel

WBR, Sergei

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