Re: [PATCH 2/2] USB: musb: gadget: fix MUSB_TXMAXP and MUSB_RXMAXP configuration

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

 



Hi Bob,

2010/10/19 Liu, Bob <Bob.Liu@xxxxxxxxxx>:

> Hi, Ming
>
> Sorry for my mistake, in my test the failed case was case5 not case4.
> Case5 is BULK OUT transfer, so this patch changed txstate() only won't have effect,
> sorry for the noise.
>
> Now the problem is if "fixed MUSB_TXMAXP and MUSB_RXMAXP configuration",
> double buffer mode will be auto enabled on our platform which makes case5 fail sometimes.
>
> And the root cause is in function rxstate()
> ===
> if (csr & MUSB_RXCSR_RXPKTRDY) {
>        len = musb_readw(epio, MUSB_RXCOUNT);
> ==
> len will be read out with very strange value like 1022,514 which are not expected and
> make things mess, so case5 failed.

I guess it is caused by double buffer, since double buffer support depends
on rx_double_buffered flag now but the flag isn't set in blackfin musb.

Please try the patch below. If the patch still doesn't work, please enable musb
debug switch and post the debug info on list.

diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 2a82362..f86dce9 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -536,6 +536,25 @@ static inline void musb_configure_ep0(struct musb *musb)
 	musb->endpoints[0].is_shared_fifo = true;
 }

+static inline void musb_update_double_fifo(struct musb_ep *musb_ep,
+											int rx)
+{
+	struct musb_hw_ep   *hw_ep = musb_ep->hw_ep;
+
+	if (rx) {
+		if (hw_ep->max_packet_sz_rx >= (musb_ep->packet_sz * 2)) {
+			hw_ep->rx_double_buffered = 1;
+			hw_ep->max_packet_sz_rx >>= 1;
+		} else
+			hw_ep->rx_double_buffered = 0;
+	} else {
+		if (hw_ep->max_packet_sz_tx >= (musb_ep->packet_sz * 2)) {
+			hw_ep->tx_double_buffered = 1;
+			hw_ep->max_packet_sz_tx >>= 1;
+		} else
+			hw_ep->tx_double_buffered = 0;
+	}
+}
 #else

 static inline int musb_read_fifosize(struct musb *musb,
@@ -574,6 +593,11 @@ static inline void musb_configure_ep0(struct musb *musb)
 	musb->endpoints[0].max_packet_sz_rx = MUSB_EP0_FIFOSIZE;
 	musb->endpoints[0].is_shared_fifo = true;
 }
+static inline void musb_update_double_fifo(struct musb_ep *musb_ep,
+											int rx)
+{
+
+}
 #endif /* CONFIG_BLACKFIN */


diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 9cfd18b..bcecd13 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -920,6 +927,8 @@ static int musb_gadget_enable(struct usb_ep *ep,
 			goto fail;
 		}

+		musb_update_double_fifo(musb_ep, 0);
+
 		int_txe |= (1 << epnum);
 		musb_writew(mbase, MUSB_INTRTXE, int_txe);

@@ -956,6 +965,8 @@ static int musb_gadget_enable(struct usb_ep *ep,
 			goto fail;
 		}

+		musb_update_double_fifo(musb_ep, 1);
+
 		int_rxe |= (1 << epnum);
 		musb_writew(mbase, MUSB_INTRRXE, int_rxe);



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