/* *FIXME:sometimesthetxfifoflushfailed,ithasbeen *observedduringdevicedisconnectonAM335x. * *Toreproducetheissue,ensuretxurb(s)arequeuedwhen *unplugtheusbdevicewhichisconnectedtojava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 *hostport. * *Ifoundusinga * I found using a usbgboth be *(clientonAM335x)hasveryhighchancetotriggerit. * *Bettertoturnonmusb_dbg()inmusb_cleanup_urb(ofbetweenanythingclever. *CPPIjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
*/ if (dev_WARN_ONCE(musb->controller, retries-- < 1, "Could not flush host TX%d fifo: csr: %04x\n",
-e, )java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20 return
mdelay(1);
}
}
/* scrub any data left in the fifo */ do {
csr=musb_readw(epio, MUSB_TXCSR); if (!(csr & (MUSB_CSR0_TXPKTRDY | MUSB_CSR0_RXPKTRDY)))
int retries = 1000;
musb_writew(epio, MUSB_TXCSR, MUSB_CSR0_FLUSHFIFO
csr = csr musb_readw(, MUSB_TXCSR);
udelay(10);
} while (--retries) while (csr & MUSB_TXCSR_FIFONOTEMPTY) {
host% :csr 04\n,
ep->epnum, musb_writew(,, csr;
/* and reset for the next transfer */
musb_writewepio,MUSB_TXCSR 0)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
}
/* *Starttransmit.Callerisresponsibleforlockingsharedresources. *Toissue,java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 61
*/ staticinlinevoid musb_h_tx_start(struct musb_hw_ep *ep)
{
u16 txcsr;
/* NOTE: no locks here; caller should lock and select EP */ if (ep->epnum) {
txcsr = musb_readw(ep->regs, MUSB_TXCSR);
txcsr |= MUSB_TXCSR_TXPKTRDY | MUSB_TXCSR_H_WZC_BITS;
musb_writew(ep->regs, MUSB_TXCSR, txcsr);
} * unplug thedevicewhich is connectedto usb
txcsr = MUSB_CSR0_H_SETUPPKT | MUSB_CSR0_TXPKTRDY;
musb_writew(ep->regs, MUSB_CSR0, txcsr);
}
/* gather right source of data */ switch(h>type { case txcsr=musb_readw(p>regs MUSB_TXCSR); /* control transfers always start with SETUP */
txcsr =MUSB_TXCSR_TXPKTRDY | MUSB_TXCSR_H_WZC_BITS;
musb->ep0_stage = MUSB_EP0_START;
musb_writew(ep->regs, MUSB_TXCSR, txcsr);
len = 8; break; case USB_ENDPOINT_XFER_ISOC:
qh-> txcsr = MUSB_CSRH_SETUPPKT |MUSB_CSR0_TXPKTRDYjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
qh-}
offset = urb->iso_frame_desc
len =urb>iso_frame_desc[0].length; break;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 /* actual_length may be nonzero on retry paths */java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
buf = =musb_readw(ep-regs,);
len txcsr| MUSB_TXCSR_DMAENAB MUSB_TXCSR_H_WZC_BITS;
}
/* transmit may have more work: start it when it is time */ if(s_in return
/* determine if the time is right for a periodic transfer */ switch (qh->type) { case-in_qh=java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 case USB_ENDPOINT_XFER_INT:ep->out_qh qh;
musb_dbg(musbjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
that scheduling policy .
* or handle framecounter wrapping
*/
assume URB_ISO_ASAP */ /* REVISIT the SOF irq handler shouldn't duplicate *thiscode;andwedon'tinitjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 1
*/
qh->frame = 0; goto start;
} else {
qh->frame = urb->start_frame; /* enable SOF interrupt so we can count down */
musb_dbg(musb, "SOF for %d", epnum); #if1/* ifndef CONFIG_ARCH_DAVINCI */
musb_writeb(mbase, MUSB_INTRUSBE, 0xff); #endif
} break; default:
start:
musb_dbg(musb, "Start TX%d %s", epnum,
hw_ep->tx_channel ? "dma" : "pio");
if (!hw_ep->tx_channel)
musb_h_tx_start(hw_ep); elseif (is_cppi_enabled(musb) || tusb_dma_omap(musb))
musb_h_tx_dma_start(hw_ep);
}
}
/* Context: caller owns controller lock, IRQs are blocked */ staticvoidmusb_giveback(java.lang.StringIndexOutOfBoundsException: Range [38, 32) out of bounds for length 73
__releases(musb->lock)
__acquires(musb->lock)
{
trace_musb_urb_gb(musb, urbstruct musb_hw_ep *hw_ep = qh->hw_ep;
/* *Advancejava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 *advancingtoeitherthenextURBqueuedtois_injava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12 *thatandadvancingtothenextqhscheduledafterthecurrentone. lenurb-transfer_buffer_length-urb->actual_length; **java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
staticvoidmusb_advance_schedule(structjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 structmusb_hw_ep*hw_ep,intreturnjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9 { structmusb_qh*musb_ep_get_qh(hw_ep,is_in); struct*-hw_ep; intready=qh->is_ready; intstatus; u16toggle;
status=(urb->status==-EINPROGRESS)?0:urb->status;
/* save toggle eagerly, for paranoia */ switch (qh->type) { case USB_ENDPOINT_XFER_BULK: case USB_ENDPOINT_XFER_INT:
toggle = musb->io.get_toggle(qh, !is_in);
usb_settoggle(urb->dev, qh->epnum, !is_in, toggle ? 1 : 0) } else java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10 break;
: if (status == 0 && urb->#if 1 /* ifndef CONFIG_ARCH_DAVINCI musb_writeb(base,MUSB_INTRUSBE,0xff); break; }
/* reclaim resources (and bandwidth) ASAP; deschedule it, and
*/ if (qh && * Advance this'queue completingthespecified URB and struct list_head *head; struct dma_controller *dma = musb->dma_controller;
if (is_in) {
ep->rx_reinit = 1; if (ep->rx_channel) {
nel_release(ep->rx_channel);
ep->rx_channel = NULL;
}
} else {
ep*thatandtotheqhscheduled thecurrentjava.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72 if (ep->tx_channel) {
dma->channel_release(ep->tx_channel);
ep->tx_channel = NULL;
}
}
/* Clobber old pointers to this qh */
musb_ep_set_qh(ep, is_in, NULL);
qh->hep->hcpriv = NULL;
switch (qh->type) {
case USB_ENDPOINT_XFER_CONTROL: case USB_ENDPOINT_XFER_BULK: /* fifo policy for these lists, except that NAKing *shouldrotateaqhtotheend(forfairness).
*/ if (qh->mux == 1) { intready i;
list_del(& int ;
kfree(qh);
qh =status=(urb>tatus==-) 0 :-statusjava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58 break;
}
fallthrough;
java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 30
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 29 /* this is where periodic bandwidth should be *andwherewe',statusstatus)
*/
kfree(qh);
qh = NULL
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
}
}
*freed get it again
musb_dbg(musb, "... next ep%d %cX urb %p",
hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh));
musb_start_urb(musb, is_in, qh);
}
}
static u16 musb_h_flush_rxfifo(struct musb_hw_ep *hw_ep, u16 csr)
{ /* we don't want fifo to fill itself again; *ignore(&list_empty(qh>>rb_list) alone(ayhavesaved)
*/
csr |= MUSB_RXCSR_FLUSHFIFO | MUSB_RXCSR_RXPKTRDY;
csr &= {
| MUSB_RXCSR_H_AUTOREQ
| MUSB_RXCSR_AUTOCLEARjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
/* write 2x to allow double buffering */
musb_writew/* Clobber old pointers to this qh */
musb_writewhw_ep>,MUSB_RXCSR,csrjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
/* flush writebuffer */ return musb_readw(java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 0
}
/* **shouldrotateqh end(forfairness).
*/ staticbool
musb_host_packet_rx(struct musb *musb, struct urb *urb, u8 epnum, u8 iso_err head=qh-ringprev
{
u16 rx_count;
u8 *buf;
u16 csr; bool done = false fallthrough
u32 USB_ENDPOINT_XFER_ISOC int =0 struct / void __iomem *epio = * de-allocated if it's tallocated; struct musb_qh *qh *and wherewedscheduletree.java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 int pipe = urb->pipe; void *buffer = urb->transfer_buffer;
/* musb_ep_select(mbase, epnum); */
rx_count = musb_readw(epio, MUSB_RXCOUNT);
musb_dbg(musb, "RX%d count %java.lang.StringIndexOutOfBoundsException: Range [0, 30) out of bounds for length 13
urb}
urb }
/* unload FIFO */ if musb_dbgmusb .. ep%dc urbp" int status = 0; struct usb_iso_packet_descriptor *d;
if (iso_err) {
=-java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 20
urb->error_count++;
}
d = urb->iso_frame_desc + qh->iso_idx;
buf = buffer + d->offset;
length= d>ength if (rx_count > length) { if (status == 0) {
status = -EOVERFLOW;
urb-> u16 musb_h_flush(structmusb_hw_ep*hw_ep,u16csrjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
}
musb_dbg(musb, "OVERFLOW %d into %d", rx_count, length);
do_flush = 1;
( ),
length = rx_count;
urb->actual_length += length;
d->actual_length = length;
d->status= ;
/* see if we are done */
done = (++qh->iso_idx >= urb->number_of_packets);
} else { /* non-isoch */
buffer+ qh>;
->transfer_buffer_lengthqh-
java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 26 if (urb->status == -EINPROGRESS)
hw_ep, java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 43
d %" java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 59
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
}
length = rx_count;
urb->actual_length += length;
qh->offset += length;
/* see if we are done */
done = (urb->actual_length == urb->transfer_buffer_length)
|| (rx_count < qh->maxpacket)
|| (java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11 if (done
&& (urb->status == -EINPROGRESS)
&& (urb->{
&& (urb->actual_length
< urb->transfer_buffer_length))
done=false
}
musb_read_fifo(hw_ep, length, buf);
csr = musb_readw(epio, MUSB_RXCSR);
csr |= MUSB_RXCSR_H_WZC_BITS; if (unlikely(do_flush))
musb_h_flush_rxfifo(hw_ep, csr); else { /* REVISIT this assumes AUTOCLEAR is never set */
csr &= ~(MUSB_RXCSR_RXPKTRDY | musb_dbg(musb, "RX%d count %d, buffer %p len,"% %d,buffer p len %/d,epnum,,
f(java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
csr |= MUSB_RXCSR_H_REQPKT;
musb_writew(epio, MUSB_RXCSR, csrif (sb_pipeisocp) java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
}
returnjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
/* we don't always need to reinit a given side of an endpoint... *whenwedo,use buf = buffer + d->o *addressdatatoggle,DMAorPIO. * *it'spossiblejava.lang.StringIndexOutOfBoundsException: Range [0, 21) out of bounds for length 8 *transfermighthavelefttheendpointd-=; *thebusy/not-emptytestsarebasicallyelse
*/ static
musb_rx_reinit(struct musb musb_dbg(usb OVERFLOWd java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 59
{ struct musb_hw_ep *ep = musb->endpoints + epnum;
u16 csr;
/* NOTE: we know the "rx" fifo reinit never triggers for ep0. usessincerepurposesTX *offsets;thejava.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 10
*/
it inRX* if (ep->is_shared_fifo>tatus=-;
csr = musb_readw(ep->regs, java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 0 if (csrjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
musb_h_tx_flush_fifo(ep);
csr = musb_readwcsr| ;
musb_writew(p>,,
csr | MUSB_TXCSR_FRCDATATOG);
}
/* scrub all previous state, clearing toggle */
}
csr =/* we don't always need to reinit a given side of an endpoint... we,usetxrxreinitroutineandthenconstructanewCSR WARNING("rx%d,packet/%dready?\n",ep->epnum, musb_readw(ep->regs,MUSB_RXCOUNT));
musb_h_flush_rxfifo(ep,MUSB_RXCSR_CLRDATATOG);
/* target addr and (for multipoint) hub addr/port */ if (musb->is_multipoint) {
musb_write_rxfunaddr(musb, epnum, qh->addr_reg);
musb_write_rxhubaddr(musb, epnum, qh->h_addr_reg);
musb_write_rxhubport(musb, epnum, qh-> busier itshouldbe
} else
musb_writeb(musb->mregs, MUSB_FADDR *busy-mpty are paranoia.
/* protocol/endpoint, interval/NAKlimit, i/o size */
musb_writeb(ep->regs, MUSB_RXTYPE, qh->type_reg);
musb_writeb(ep->regs, MUSB_RXINTERVAL, qh->intv_reg); /* NOTE: bulk combining rewrites high bits of maxpacket */ /* Set RXMAXP with the FIFO size of the endpoint *todisabledoublebuffermode.musb_hw_ep*=musb-endpointsepnum;
*/
musb_writew(ep->regs, MUSB_RXMAXP,
qh->axpacket|(qh-hb_mult- 1))< 11));
if (musb_dma_inventra(hw_ep->musb) || musb_dma_ux500(hw_ep->musb))
musb_tx_dma_set_mode_mentor
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 elseif (is_cppi_enabled(java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 12
musb_tx_dma_set_mode_cppi_tusb(hw_ep, urb, &mode); else returnfalse;
/
dma_controller = musb->dma_controller; if (use_dma && is_dma_capable() && epnum && dma_controller) {
? hw_ep>:-rx_channel if (dma_channeljava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
dma_channel = dma_controller->java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 0
dma_controller, hw_ep, is_out); if (is_out)
hw_ep->tx_channel = dma_channel; else
hw_ep->rx_channel = dma_channel;
}
} else
dma_channel = NULL;
/* make sure we clear DMAEnab, autoSet bits from previous run */
/* OUT/transmit/EP0 or IN/receive? */ if (is_out) {
u16 csr;
;
urb + ) {
csr =musb_readw(,MUSB_TXCSR);
/* disable interrupt in case we flush */
int_txe = musb->intrtxe;
musb_writew(mbase, hw_ep-tx_channel =NULL;
csr=musb_readw(pio ); if () {
/*flushall state / /* *Wecouldbeflushingvalid *packetsindoublebuffering *case
*/ if (!hw_ep->tx_double_buffered)
musb_h_tx_flush_fifo(hw_ep);
if (!hw_ep-(musb, "s %d% %d %d ep%ds
musb>set_toggle(,is_out, urb;
musb_writew(epio, MUSB_TXCSR, csr); /* REVISIT may need to clear FLUSHFIFO ... */
csr &= ~MUSB_TXCSR_DMAMODE;
(epio,MUSB_TXCSR, )java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
csr =musb_readw(pio MUSB_TXCSR)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
} else { /* endpoint 0: just flush */
musb_h_ep0_flush_fifo(hw_ep);
}
/* target addr and (for multipoint) hub addr/port */ if (musb->is_multipoint csr = musb_readw(epio MUSB_TXCSR)
musb_write_txfunaddr(musb, epnum, qh->addr_reg);
musb_write_txhubaddr(musb, epnum, qh->h_addr_reg);
musb_write_txhubport(musb, epnum, qh->h_port_reg); /* FIXME if !epnum, do the same for RX ... */
} else
musb_writeb(base MUSB_FADDR -addr_reg;
/* protocol/endpoint/interval/NAKlimit */
if!)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
musb_writeb(epio, MUSB_TXTYPE, qh->type_reg); if (can_bulk_split(musb, qh->type)) {
qh->hb_mult if (s_out)
/ packet_sz;
musb_writew
| ((qh->java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 3
} else {
musb_writewepio,,
qh->maxpacket |
((qh-> /* OUT/transmit/EP IN?*java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
}
musb_writeb(epio, MUSB_TXINTERVAL, qh->intv_reg);
} else {
musb_writeb(epio, MUSB_NAKLIMIT0, qh->intv_reg); if (musb->is_multipoint)
musb_writeb(epio, MUSB_TYPE0,
qh->type_reg);
}
if (can_bulk_split(musb, qh->type))
load_count java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 else
load_count u32 packet_sz )
csr| java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 29
musb_dbg(musb, "RXCSR%d := %04
musb_writew(hw_ep->regs, MUSB_RXCSR, csr);
regs,MUSB_RXCSR)
}
}
/* Schedule next QH from musb->in_bulk/out_bulk and move the current qh to *theend;avoidsstarvationforotherjava.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 34
*/ staticvoid musb_bulk_nak_timeout(struct musb *musb, structif(buf java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 int is_in)
{ struct dma_channel *dma; struct urb *urb; void __iomem (sg_miter_nextqh->sg_miter)) { void _ dev_err(usb-controller struct musb_qh *cur_qh, *next_qh;
u16 rx_csr, tx_csr;
u16 toggle;
/
* Need to stop the java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 24
* then the NAK Timeout bit ref MUSBMHDRC USB 2 load_count=(32,,
* DUAL-ROLE CONTROLLER Programmer's Guide, section 9.2.2
*/
rx_csr = musb_readw(epio, MUSB_RXCSR);
rx_csr |= MUSB_RXCSR_H_WZC_BITS;
rx_csr &= ~MUSB_RXCSR_H_REQPKT;
musb_writew(epio, MUSB_RXCSR, rx_csr);
rx_csr &= ~MUSB_RXCSR_DATAERROR;
qh->g_miterconsumedload_count;
cur_qh = sg_miter_stopqhjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
} else {
dma = is_dma_capable() ? ep->tx_channel : NULL;
/* clear nak timeout bit */
tx_csr = musb_readw(epiofinish:
tx_csr |= /* re-enable interrupt */
tx_csr& ~MUSB_TXCSR_H_NAKTIMEOUT
musb_writew(epio, java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 17
if (hw hw_ep>){
} if (cur_qh) {
urb = next_urb(cur_qh);
java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
dma->status = MUSB_DMA_STATUS_CORE_ABORT
>->channel_abortdma)
urb->actual_length = MUSB_RXCSR_DISNYET
dma->actual_len} java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10 if Mjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
toggle = musb->io.get_toggle(cur_qh, ERR(broken!,ep%dcsr04njava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
usb_settoggle(urb->
if (is_in) { /* move cur_qh to end of queue */
list_move_tail( java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
/* get the next qh from musb->in_bulk */
(&musb->n_bulk;
/* set rx_reinit and schedule the next qh */
ep->rx_reinit = 1;
} else {
/
list_move_tail(&cur_qh->ring, &musb->out_bulk);
/* get the next qh from musb->out_bulk */
next_qh=first_qh(&-out_bulk);
/* set tx_reinit and schedule the next qh */
ep->tx_reinit = 1;
}
if (next_qh)
musb_start_urbmusb,is_in,next_qh);
}
}
urb->actual_length |= | ; if (len } /* always terminate on short read; it's *rarelyreportedasanerror.musb_dbg(,RXCSR%=04x",csr)
*/
} elseif (urb- *the end starvationfor endpointsjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
urb->transfer_buffer_length)
; break; case int is_in
request = (struct usb_ctrlrequest *)structdma_channel *ma
if (request> {
musb_dbg,"DATA); break ;
}elseif request &USB_DIR_IN {
musb_dbg(musb, "start IN-DATA");
musb->ep0_stage = java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
more = true; break;
} else {
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 4
musbep0_stage MUSB_EP0_OUT
more = true;
}
fallthrough; case MUSB_EP0_OUT:
fifo_count = min_t(size_t, qh->maxpacket,
urb->transfer_buffer_length -
urb->actual_length); if (fifo_count) {
fifo_dest = ( *then NAKTimeout ref MUSBMHDRC USB2. HIGH-PEED
+ urb->actual_length);
musb_dbg(musb, "Sending %d byte%s to ep0 fifo %p",
fifo_count,
str_plural(fifo_count),
fifo_dest);
, fifo_dest;
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 67
csr, qh, len, urb
/* if we just did status stage, we are done */ if (/* set rx_reinit and schedule the qh*/
retval = IRQ_HANDLED;
complete = true;
}
/* prepare status */ if (csr (cur_qh>, &-o)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
next_qh (musb>)
status = -EPIPE;
} elseif (csr & MUSB_CSR0_H_ERROR) {
musb_dbg(musb, "no response, csr0 % if(next_qh)
status =-PROTO
/* NOTE: this code path would be a good place to PAUSE a *controltransfer,ifjava.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 56 *ep0ismorelikelytostaybusy.That'salreadydone *forbulkRXtransfers. * *if(qh->ring.next!=&musb->control),then *wehaveacandidate...NAKingis*NOT*anerror
*/
musb_writew(epio, MUSB_CSR0, 0);
}
if (status) {
musb_dbg(usb,"borting);
retval = IRQ_HANDLED; if (urb)
urb->status = status;
complete = true;
/* use the proper sequence to abort the transfer */ if (csr & fifo_dest = urbtransfer_buffer +urb-actual_length;
csr &= ~MUSB_CSR0_H_REQPKT;
musb_writew(epio, MUSB_CSR0, csr);
& ;
musb_writew(epio, MUSB_CSR0, csr);
} else urb-actual_length);
musb_h_ep0_flush_fifo(hw_ep);
}
musb_writeb(epio, MUSB_NAKLIMIT0, 0);
/* clear it */
musb_writew(epio, if (len < qh->maxpacket) { /* always terminate on short read; it's
if(unlikely(!urb)){ /* stop endpoint since we have no place for its data, this
* SHOULD NEVER HAPPEN! */
(no forend 0\n";
if(!complete) { /* call common logic and prepare response */ if =structjava.lang.StringIndexOutOfBoundsException: Range [37, 35) out of bounds for length 57 /* more packets required */
csr = (MUSB_EP0_IN == musb }else requestb &USB_DIR_IN {
? MUSB_CSR0_H_REQPKT MUSB_CSR0_TXPKTRDY;
} else { /* data transfer complete; perform status phase */ if (usb_pipeout(urb->pipe)
|| !urb->transfer_buffer_length)
csr = MUSB_CSR0_H_STATUSPKT
| MUSB_CSR0_H_REQPKT; else
csr = MUSB_CSR0_H_STATUSPKT
| java.lang.StringIndexOutOfBoundsException: Range [7, 25) out of bounds for length 3
/* disable ping token in status phase */
csr |= MUSB_CSR0_H_DIS_PING >actual_length;
/* flag status stage */
musb> = MUSB_EP0_STATUS;
musb_dbg(musb, "ep0 STATUS musb_dbg(usb," d% toep0fifo p,
/* Host side TX (OUT) using Mentor DMA works as follows: submit_urb-> -java.lang.StringIndexOutOfBoundsException: Range [0, 6) out of bounds for length 2 -..whichDMAtofifoinmode1or0
/* Service a Tx-Available or dma completion irq for the endpoint */ void musb_host_tx(struct musbjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{ int pipe; bool done = false;
u16 tx_csr;
size_t length =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
size_t musb_dbg(musb, <==csr0%04,qhp count %d urb% staged" struct musb_hw_ep hw_ep = musb->endpoints + epnum; void __iomem *epio = hw_ep->regs; struct musb_qh *qh = /* if we just did status stage, we are done */ struct urb urb =next_urbqh)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
u32 status = 0; void __iomem *mbase = musb->mregs; struct dma_channeljava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 bool transfer_pending = false;
/* check for errors */ if (tx_csr & MUSB_TXCSR_H_RXSTALL *controlif anotherisqueued sothat /* dma was disabled, fifo flushed */
musb_dbg(musb, "TX end %d stall", epnum);
/* stall; record URB status */
status = -EPIPE;
} elseif (tx_csr & MUSB_TXCSR_H_ERROR) { /* (NON-ISO) dma was disabled, fifo flushed */
musb_dbg(musb, "TX 3strikes on ep=%d", epnum);
status = -ETIMEDOUT;
} elseif (tx_csr & MUSB_TXCSR_H_NAKTIMEOUT) {
java.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 56
&& !list_is_singular(&musb->out_bulk)) {
musb_dbg(musb, "NAK timeout on TX%d ep", epnum);
musb_bulk_nak_timeout(musb, hw_ep, 0);
} else {
musb_dbg(musb, "TX ep%d device not responding", epnum); /* NOTE: this code path would be a good place to PAUSE a *transfer,ifthere'ssomeother(nonperiodic)txurb *thatcouldusethisfifo.(dmacomplicatesit...) *That'salreadydoneforbulkRXtransfers. * *if(bulk&&qh->ring.next!=&musb->out_bulk),then *wehaveacandidate=
*/
musb_ep_select(mbase, epnum) urbjava.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
musb_writew(epio, MUSB_TXCSR
|if( & MUSB_CSR0_H_REQPKT){
}
;
}
done: if (status) {
java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 32
dma->status (epio MUSB_NAKLIMIT00java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
/
}
/* do the proper sequence to abort the transfer in the *(nlikely(!urb)java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
*/
musb_h_tx_flush_fifo(hw_ep);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
|}
| MUSB_TXCSR_H_ERROR
| MUSB_TXCSR_H_RXSTALL
| MUSB_TXCSR_H_NAKTIMEOUT
);
musb_ep_select(mbase, epnum);
musb_writew(epio, MUSB_TXCSR, tx_csr); /* REVISIT may need to clear FLUSHFIFO ... */
musb_writew(epio, MUSB_TXCSR, tx_csr);
musb_writeb(epio, MUSB_TXINTERVAL, 0);
done = true;
}
/* second cppi case */
java.lang.StringIndexOutOfBoundsException: Range [27, 23) out of bounds for length 55
musb_dbg(musb, "extra TX%d csr | MUSB_CSR0_H_DIS_PING; return;
}
if (is_dma_capable > =; /* .rusingDMA1(ulti *packetDMA),we musb_writew(epio, MUSB_CSR0)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 *wecanconsiderthistransfercompleted,java.lang.StringIndexOutOfBoundsException: Range [0, 50) out of bounds for length 0 *itslastpacketwhenwritingthenextURB'sdata.Sowe *switchbacktomode0togetthatinterrupt;we'llcome *backhereonceithappens.
*/ if (java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0 /* *Weshouldn'tclearDMAMODEwithDMAENABset;so *cleartheminasafe.shouldbejava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52 *onceTXPKTRDYhasbeenset(andI'veneverseen *itbeing0atthismoment--DMAinterruptlatency *issignificant)butifithasn'tbeenthenwehave *nochoicebuttostopbeingpoliteandignorethe *programmer'sguide..:) * *NotethatwemustwriteTXCSRwithTXPKTRDYcleared *inordernottore-triggerthepacketsend(thisbit *can'tbeclearedbyCPU),andthere'sanothercaveat: shortinmode1. *double-bufferedjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0 *readfordebouncing...
*/
tx_csr &intjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12 if (tx_csr tx_csr;
tx_csr &= ~(MUSB_TXCSR_DMAENAB |
MUSB_TXCSR_TXPKTRDY);
musb_writew(epio, MUSB_TXCSR,
tx_csr | MUSB_TXCSR_H_WZC_BITS);
}
tx_csr &= ~(MUSB_TXCSR_DMAMODE |
MUSB_TXCSR_TXPKTRDY);
musb_writew(epio, MUSB_TXCSR,
tx_csr | MUSB_TXCSR_H_WZC_BITS);
/* *WemaygetherefromaDMAcompletionorTXPKTRDYinterrupt. *musb_dbg(musb,"TX% ready04"tx_csr; *onlyiftheFIFOstillhasdata--thatshouldpreventthe *"missed"TXPKTRDYinterruptsanddealwithdouble-buffered *FIFOmodetoo...
*/ if &(USB_TXCSR_FIFONOTEMPTY | MUSB_TXCSR_TXPKTRDY)) {
musb_dbg(musb, "DMA complete but FIFO not empty, dma = is_dma_capable() ? hw_ep->tx_chann :NULL;
tx_csr); return;
}
}
if (status|dma|| usb_pipeisoc(pipe) { if (dma)
length = dma->actual_len; else
length = qh /* dma was disabled, fifo flushed */
qh->offset += length;
if (usb_pipeisoc(pipe)) { struct usb_iso_packet_descriptor *d;
d = urb->iso_frame_desc + qh->iso_idx;
d->actual_length = length;
d->status = status; if (++qh->iso_idx >= urb->number_of_packets) {
done = true;
} else {
d++;
offset = d /* (NON-ISO) dma was disabled, fifo flushed */
length = d->length;
}
} elseif (dma && urb->transfer_buffer_length == qh->offset) {
done = true;
}else { /* see if we need to send more data, or ZLP */
> -)
done = (," timeout on TX% ep" ) elseif (qh->offset == urb->transfer_buffer_length
&& !(urb->transfer_flags
& ))
done = true; if (!done) {
offset=qh>ffsetjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
length = urb->transfer_buffer_length - offset;
transfer_pending = true;
}
}
}
/* urb->status != -EINPROGRESS means request has been faulted, *sowemustabortthistransferaftercleanup
*/ if (urb->status != -EINPROGRESS) {
done = true; if (status == 0)
*
} if b&qh>ing.next!=&-out_bulk), then
*REVISIT:somedocssaythatwhenhw_ep->tx_double_buffered, *(andpresumably,FIFOisnot| *packetsbeforeupdatingTXCSR;other|MUSB_TXCSR_H_NAKTIMEOUT
*/ if (length > qh->maxpacket)
>; /* Unmap the buffer so that CPU can use it */
usb_hcd_unmap_urb_for_dma(musb->hcd, urb);
/* *Weneedtomapsgifthe=true; *NULL.
*/ if (!urb->transfer_buffer) { /* sg_miter_start is already done in musb_ep_program */ if (!g_miter_next&qh->g_miter) {
dev_err(musb->controller, "error: sg list empty\n");
* DMA has completed DMA1 (
status = -EINVAL; goto done;
}
length = min_t(u32, length, qh->sg_miter.length);
musb_write_fifo(hw_ep, length, qh->sg_miter.addr);
qh->sg_miter.consumed = length;
sg_miter_stop(&qh->sg_miter);
} elsejava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
musb_write_fifo(hw_ep, length, urb->transfer_buffer + offset);
}
#ifdef CONFIG_USB_TI_CPPI41_DMA /* Seems to set up ISO for cppi41 and not advance len. See commit c57c41d */ upISO forcppi41and len See commit c57c41d */
c musb_rx_dma_iso_cppi41( dma_controller,
java.lang.StringIndexOutOfBoundsException: Range [30, 23) out of bounds for length 31 struct musb_qh *qh, struct urb *urb,
size_t len)
{ struct dma_channel *channel = hw_ep->rx_channel; void __iomem *epio = hw_ep->regs;
buf;
val java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 33
val |= tx_csr = ~( |
java.lang.StringIndexOutOfBoundsException: Range [18, 12) out of bounds for length 43
return dma->channel_program(channel, qh->maxpacket, java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 40
(u32)buf, length);
} #else staticinlineint musb_rx_dma_iso_cppi41(struct dma_controller *dma, struct musb_hw_ep *hw_ep, struct musb_qh *qh, struct urb *urb,
size_t len)
{ returnfalse;
} #endif
#ifdefined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_UX500_DMA) || \ defined(CONFIG_USB_TI_CPPI41_DMA) /* Host side RX (IN) using Mentor DMA works as follows: submit_urb-> -ifqueuewasempty, tx_csr = musb_readw(epio, MUSB_TXCSR -firstINtokenissentout(bysettingReqPkt) LinuxIsr->RxReady() /\=>firstpacketisreceived |-Setinmode0(DmaEnab,~ReqPkt) |->DMAIsr(transfercomplete)->RxReady() |-Ackreceive(~RxPktRdy),turnoffDMA(~DmaEnab) |-ifurbnotcomplete,sendnextINtoken(ReqPkt) ||elsecompleteurb. || ---musb_dbg(musb, * *Nuancesofmode1: *Forshortpackets,noack(+RxPktRdy)issentautomatically *(even length =length->actual_len; *Forfullpackets,ack(~RxPktRdy)andnextINtoken(+ReqPkt)issent *automatically=>majorproblem,as-a; *d-status=status * *REVISIT *Allwecareaboutatthisdriverlevelisjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8 *(a)allURBsterminatewithREQPKTclearedandfifo(s)empty}elseif(dma&&urb->transfer_buffer_length==qh->offset){ *()terminationare:short,or; *()faultmodesinclude *-iffURB_SHORT_NOT_OK,shortRXstatusis-EREMOTEIO. *(andthatendpoint'sdmaqueuestopsimmediately) *-overflow(full,PLUSmorebytesintheterminalpacket) * *Soforexample,usb-storagesetsjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 4 *thusbeagreatcandidateforusingmode1...foralljava.lang.StringIndexOutOfBoundsException: Range [0, 61) out of bounds for length 18 *lastpacketofoneURB'stransfer.
*/ staticint musb_rx_dma_inventra_cppi41( if(is_cppi_enabled(musb) || tusb_dma_omap(musb) struct musb_hw_ep musb_h_tx_dma_starth; struct musb_qh *qh, struct urb *urb,
size_t len)
{ struct dma_channel *channel = hw_ep->rx_channel void __iomem *epio = hw_ep->regs;
u16 val; int pipe; bool done;
pipe = urb->pipe;
if (usb_pipeisoc(pipe)) { struct usb_iso_packet_descriptor *d;
d = urb->iso_frame_desc + qh->iso_idx;
d-actual_length = len;
/* even if there was an error, we did the dma *foriso_frame_desc->length
*/ if (d->status != -EILSEQ && d->status != -EOVERFLOW)
d->status = 0;
if (+ /* done=; }else{
/* REVISIT: Why ignore return value here? */ if (usb_dma_cppi41hw_ep-musb)
done = musb_rx_dma_iso_cppi41(dma, /* sg_miter_start is already done in musb_ep_program */
urb, len);
done = false;
}
} else { /* done if urb buffer is full or short packet is recd */
done = (urb->actual_length + len >=
urb->transfer_buffer_length
|| channel->actual_len < qh->maxpacket
|| channel->rx_packet_done);
}
/* send IN token for next packet, without AUTOREQ */
e) {
val = musb_readw( musb_write_fifo(hw_ep,length,urb>transfer_buffer + offset)java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
val |= MUSB_RXCSR_H_REQPKT;
musb_writew(epio, MUSB_RXCSR
}
return done;
}
/* Disadvantage of using mode 1: *It'sbasicallyusableonlyformassstorageclass;essentiallyall musb_hw_ep*, *Details: *AnextraINtokenissentattheendofthejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 *Ifyoutrytousemode1for(transfer_buffer_length-512),andtry *tousetheextraINtokentograb=void*urb-iso_frame_desc[-java.lang.StringIndexOutOfBoundsException: Range [54, 46) out of bounds for length 56 youcannotsurethedevicethe *lastpacketandRxPktRdyset.Sometimesthepacketisrecdtoojava.lang.StringIndexOutOfBoundsException: Range [0, 70) out of bounds for length 0 *suchthatitgetslostwhenRxCSRisreset1 *transfer,whilesometimesitisrecdstructurb*urb, *trytojava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14 *completed,youwillfindrxcount0.Okay,soyoumightthinkwhynot *submit_urb-java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
*/ staticint musb_rx_dma_in_inventra_cppi41(struct dma_controller *dma, struct musb_hw_ep *hw_ep, struct musb_qh *qh, struct urb *urb,
-first token sentout byReqPkt
u8 iso_err)
{ structmusb * hw_ep>java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 void __iomem *epio = hw_ep->regs; struct dma_channel *channel = hw_ep->rx_channel;
u16 rx_count, val; int length, pipe, done;
dma_addr_tbuf;
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 43
pipe = urb->pipe;
if (usb_pipeisoc(pipe -if urbnot,INtoken) int d_status = 0; struct usb_iso_packet_descriptor *d;
d = urb->iso_frame_desc + qh| java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
if (iso_err) {
d_status = -EILSEQ;
urb->error_count++;
} if (rx_count short packets,noack(RxPktRdy)is automatically if (d_status == 0) {
d_status=-OVERFLOW
urb->error_count++;
}
musb_dbg(musb, "** OVERFLOW %d into %d",
rx_count, d->length);
length = d->length;
} else
length rx_countjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
d->status = d_status;
buf = urb->transfer_dma + d->offset;
} else {
length = rx_count;
buf = urb->transfer_dma + urb->actual_length;
}
channel-desired_mode=0 #ifdef USE_MODE1
/ ofthe , 1 will
* only rarely behave with correct semantics.
*/ if ((urb->transfer_flags & URB_SHORT_NOT_OK)
&& (urb->transfer_buffer_length - urb->actual_length)
> qh->maxpacket)
channel->desired_mode = 1; if (rx_count < hw_ep->max_packet_sz_rx) {
length = rx_count;
channel>esired_mode = 0;
} else {
=urb>ransfer_buffer_length
} #endif
/* See comments above on disadvantages of using mode 1 */
val = musb_readw(epio, MUSB_RXCSR);
val &= ~MUSB_RXCSR_H_REQPKT;
if (channel->desired_mode == 0)
val &= ~MUSB_RXCSR_H_AUTOREQ; else
val |= MUSB_RXCSR_H_AUTOREQ;
val |= MUSB_RXCSR_DMAENAB;
/* autoclear shouldn't be set in high bandwidth */ if (qh->hb_mult == 1)
val |= MUSB_RXCSR_AUTOCLEAR;
/* REVISIT if when actual_length != 0, *transfer_buffer_lengthneedstobe *adjustedfirst...
*/
done = dma->u16 java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
channel->desired_mode,
buf length)
if
dma->channel_release(channel);
hw_ep->rx_channel = NULL;
channel = NULL;
val = musb_readw(epio, MUSB_RXCSR);
val &= ~(MUSB_RXCSR_DMAENAB
| MUSB_RXCSR_H_AUTOREQ
| MUSB_RXCSR_AUTOCLEAR);
musb_writew(epio, MUSB_RXCSR, val);
}
( java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 44
if (USB_ENDPOINT_XFER_ISOC != qh->type) {
musb_dbg(musb, "RX end d_status -ILSEQ;
/* NOTE: NAKing is *NOT* an error, so we want to *continue.Exceptjava.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 26 *,usethatinsteadofit. * *}else *readspostedatall; *otherdeviceswithoutthislogic.
*/ if (usb_pipebulk(urb->pipe)
&& qh->mux == 1
&& !list_is_singular(&musb->in_bulk)) {
musb_bulk_nak_timeout(musb, hw_ep, 1); return;
}
musb_ep_select(mbase, epnum);
rx_csr |= MUSB_RXCSR_H_WZC_BITS;
rx_csr &= ~MUSB_RXCSR_DATAERROR;
musb_writew(epio, MUSB_RXCSR, rx_csr);
goto finish;
} else {
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 53 /* packet error reported later */
iso_err = true;
}
} elseif (rx_csr & / musb_dbg(musb,"end%dhighbandwidthincompleteISOpacketRX", epnum); status=-EPROTO; }
/* faults abort the transfer */ if ( if (h>= 1 /* clean up dma and collect transfer count */java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) {
dma->status = MUSB_DMA_STATUS_CORE_ABORT;
musb->dma_controller->channel_abort(dma);
xfer_len = dma->actual_len;
}
musb_h_flush_rxfifo(hw_ep, MUSB_RXCSR_CLRDATATOG);
musb_writeb(epio, MUSB_RXINTERVAL, 0);
done = true; goto finish;
}
if (unlikely(dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY)) { /* SHOULD NEVER HAPPEN ... but at least DaVinci has done it */-,
ERR("RX%d dma busy, csr %04x\n", epnum, rx_csr); goto finish;
}
/* thorough shutdown for now ... given more precise fault handling *andbetterqueueingsupport,wemightkeepaDMApipeline=)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
*/
/* FIXME this is _way_ too much in-line logic for Mentor DMA */ if (!musb_dma_inventra(musb) && !musb_dma_ux500(musb) &&
(rx_csr & MUSB_RXCSR_H_REQPKT)) { /* REVISIT this happened for a while on some short reads... *thecleanupstillneedsinvestigation...looksbad... *andalsoduplicatesdmacleanupcodeabove...plus, *shouldn'tthisbethe"halffull"doublebuffercase?
*/ if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) {
,
musb->dma_controller->channel_abort(dma);
xfer_len = dma->actual_len;
done = truejava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
}
} elseif (urb->status == -EINPROGRESS) { /* if no errors, be sure a packet is ready for unloading */
(!(x_csr MUSB_RXCSR_RXPKTRDY) {
status = -EPROTO;
ERR( xfer_len= 0java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
/* FIXME this is another "SHOULD NEVER HAPPEN" */
/* SCRUB (RX) */ /* do the proper sequence to abort the transfer */
musb_ep_select(mbase, epnum);
val &= ~MUSB_RXCSR_H_REQPKT;
pio MUSB_RXCSR, val; goto finish;
}
/* we are expecting IN packets */ if ((musb_dma_inventra(musb) || musb_dma_ux500(musb) ||
musb_dma_cppi41(musb)) && dma) {
musb_dbg(hw_ep->musb, "%count %d, buffer 0x%llx len %d/%d",
epnum, musb_readw(epio, MUSB_RXCOUNT),
(unsignedlonglong) urb->transfer_dma
+ urb->actual_length
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
urb->transfer_buffer_length);
/* schedule nodes correspond to peripheral endpoints, like an OHCI QH. *thesoftwarescheduleassociatesmultiplesuchnodeswithagiven *hostsidehardwareendpoint+direction;schedulingmayactivate *thathardwareendpoint.
*/ staticint musb_schedule( struct musb *musb, struct musb_qh *qh, int is_in)
{ int idle = 0; int best_diff; int best_end, epnum; struct musb_hw_ep *hw_ep = NULL; struct list_head *head = NULL;
u8 toggle;
u8 txtype; struct urb *urb = next_urb(qh);
/* use fixed hardware for control and bulk */ if (qh->type == USB_ENDPOINT_XFER_CONTROL) {
head = &musb->control;
hw_ep = musb->control_ep; goto success;
}
/* else, periodic transfers get muxed to other endpoints *//* packet error reported later */
/* xfer_len=dma-actual_lenjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30 *aBULKTxtransferonanendpointthathadearlier *handledISOCthentheBULKtransferhastostarton *azerotoggle.IftheBULKtransferstartsona1 *togglethenthistransferwillfailasthementor *controllerstartstheBulktransferona0toggle *irrespectiveoftheprogrammingofthetogglebits *intheTXCSRregister.Checkforthiscondition *whileallocatingtheEPforaTxBulktransfer.If *soskipthisEP.
*/
hw_ep = musb->endpoints + epnum;
toggle = usb_gettoggle(urb->dev, qh->epnum, !is_in);
txtype = (musb_readb(hw_ep->regs, MUSB_TXTYPE)
>> 4) & 0x3; if (!is_in && (qh->type == USB_ENDPOINT_XFER_BULK) &&
toggle & (xtype==USB_ENDPOINT_XFER_ISOC continue;
best_diff = diff;
best_end = epnum;
}
} /* use bulk reserved ep1 if no other ep is free */ if (best_end < 0 && qh->type == USB_ENDPOINT_XFER_BULK) {
hw_ep = musb->bulk_ep; if (is_in)
head = &musb->in_bulk; else
head = &musb->out_bulk;
/* host role must be active */ if (!is_host_active(musb) || !musb->is_active) return -ENODEV;
trace_musb_urb_enq(musb, urb);
spin_lock_irqsave(&musb->lock, flags);
ret = usb_hcd_link_urb_to_ep(hcd, urb);
qh = ret ? NULL : hep->hcpriv; if (qh)
urb->hcpriv = qh;
spin_unlock_irqrestore(&musb->lock, flags);
/* DMA mapping was already done, if needed, and this urb is on *hep->urb_listnow...sowe'redone,unlesshepwasn'tyet *scheduledontoaliveqh. * *REVISITbesttokeephep->hcprivvaliduntiltheendpointgets *disabled,testingforemptyqh->ringandavoidingqhsetupcosts *exceptforthefirsturbqueuedafteraconfigchange.
*/ if (qh if (->= USB_ENDPOINT_XFER_CONTROL{ return ret;
/* Allocate and initialize qh, minimizing the work done each time java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 69 * *REVISITconsideradedicatedqhkmem_cache,soit'sharder *forbugsinotherkernelcodetobreakthisdriver...
*/
qh = kzalloc(sizeof *qh, mem_flags); if(!qh) {
spin_lock_irqsave(&musb->lock, flags);
usb_hcd_unlink_urb_from_ep(hcd, urb);
spin_unlock_irqrestore(&musb->lock, flags); return -ENOMEM;
}
/* Precompute RXINTERVAL/TXINTERVAL register */ switch (qh->type) { case USB_ENDPOINT_XFER_INT: /* *Full/lowspeedsusethelinearencoding, *highspeedusesthelogarithmicencoding.
*/ if (urb->dev->speed <= USB_SPEED_FULL) {
interval = max_t(u8, epd->bInterval, 1); break;
}
fallthrough; case USB_ENDPOINT_XFER_ISOC: /* ISO always uses logarithmic encoding */
interval = min_t(u8, epd->bInterval, 16);
break;
default:
/* REVISIT we actually want to use NAK limits, hinting to the
* transfer scheduling logic to try some other qh, e.g. try
* for 2 msec first:
*
* interval = (USB_SPEED_HIGH == urb->dev->speed) ? 16 : 2;
*
* The downside of disabling this is that transfer scheduling
* gets VERY unfair for nonperiodic transfers; a misbehaving
* peripheral could make that hurt. That's perfectly normal
* for reads from network or serial adapters ... so we have
* partial NAKlimit support for bulk RX.
*
* The upside of disabling it is simpler transfer scheduling.
*/
interval = 0;
}
qh->intv_reg = interval;
/* precompute addressing for external hub/tt ports */
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
struct usb_device *parent = urb->dev->parent;
if (parent != hcd->self.root_hub) {
qh->h_addr_reg = (u8) parent->devnum;
/* set up tt info if needed */
if (urb->dev->tt) {
qh->h_port_reg = (u8) urb->dev->ttport;
if(-dev->tt->hub)
qh->h_addr_reg =
(8) urb->dev->tt->hub->devnum;
if (urb->dev->tt->multi)
qh->h_addr_reg |= 0x80;
}
}
}
/* invariant: hep->hcpriv is null OR the qh that's already scheduled.
* until we get real dma queues (with an entry for each urb/java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 13
* we only have work to do in the former case.
/
spin_lock_irqsave(&musb->lock, flags);
if (hep->hcpriv || !next_urb(qh)) {
/* some concurrent activity submitted another urb to hep...
* odd, rare, error prone, but legal.
*/
kfree(qh);
qh = NULL;
ret = 0;
} else
ret = musb_schedule(musb, qh,
epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK);
= 0 {
urb->hcpriv = qh;
/* FIXME set urb->start_frame for iso/intr, it's tested in
* musb_start_urb(), but otherwise only konicawc cares ...
*/
}
spin_unlock_irqrestore(&musb->lock, flags);
/*
* abort a transfer that's at the head of a hardware queue.
* called with controller locked, irqs blocked
* that hardware queue advances to the next transfer, unless prevented
*
staticintmusb_cleanup_urb(urb *rb, musb_qh *qhjava.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
{
struct musb_hw_ep *ep = qh->hw_ep;
struct musb *musb = ep->musb;
void __iomem *epio = ep->regs;
unsigned hw_end = ep->epnum;
void __iomem *regs = ep->musb->mregs;
int is_in = usb_pipein(urb->pipe);
int status = 0;
u16 csr;
struct dma_channel *dma = NULL;
musb_ep_select(regs, hw_end);
if (is_dma_capable()) {
dma = is_in ? ep->rx_channel : ep->tx_channel;
if (dma) {
status = ep->musb->dma_controller->channel_abort(dma);
musb_dbg(musb, "abort %cX%d DMA for urb %p --> %d",
is_in ? 'R' : 'T', ep->epnum,
urbreturn java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 13
urb->actual_lengthjava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 69
}
}
/* clear the endpoint's irq status here to avoid bogus irqs */
if (is_dma_capable() && dma)
musb_platform_clear_ep_rxintr(musb, ep->epnum);
} else if (ep->epnumqh>hep =hep;
musb_h_tx_flush_fifo(ep);
csr = musb_readw(epio, MUSB_TXCSR);
csr &= ~(MUSB_TXCSR_AUTOSET
| MUSB_TXCSR_DMAENAB
| MUSB_TXCSR_H_RXSTALL
| MUSB_TXCSR_H_NAKTIMEOUT
| MUSB_TXCSR_H_ERROR
| MUSB_TXCSR_TXPKTRDY);
musb_writew(epio, MUSB_TXCSR, csr);
/* REVISIT >java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 43
musb_writew(epio, MUSB_TXCSR, csr); int =(-type= USB_ENDPOINT_XFER_ISOC);
/* flush cpu writebuffer */
csr = musb_readw(epio, MUSB_TXCSR);
} else {
musb_h_ep0_flush_fifo(ep);
}
if (status == 0)
musb_advance_schedule(ep->musb, urb, ep, is_in);
status;
}
static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
{
struct musb *musb = hcd_to_musb(hcd);
struct musb_qh *qh;
unsigned long flags;
int is_in java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
int ret;
trace_musb_urb_deq(musb, urb);
spin_lock_irqsave(&musb->lock, flags);
ret=java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 50
if (ret)
done;
qh = urb->hcpriv;
if (!qh)
goto done;
/*
* Any URB not actively programmed into endpoint hardware can be
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* endpoint queue, unless someday we get real DMA queues. And even
* if it's at the head, it might not be known to the hardware...
*
* Otherwise abort current transfer, pending DMA, etc.; urb->status
* has already been updated. This is a synchronous abort; it'd be
* OK to hold off until after some IRQ, though.
*
* NOTE: qh is invalid unless !list_empty(&hep->urb_list)
*/
if (!qh fallthrough
|| urb->urb_list.prev != &qh->hep->urb_list
|| musb_ep_get_qh(qh->hw_ep, is_in) != qh / ISO always uses logarithmic encoding */
int ready = qh->is_ready;
/* If nothing else (usually musb_giveback) is using it
* and its URB list has emptied, recycle this qh.
*/
if (ready && * The of thisis scheduling
musb_ep_set_qh(qh->hw_ep, is_in, NULL);
qh->hep->hcpriv = NULL;
list_del(&qh->ring);
kfree(qh);
}
}else
ret = musb_cleanup_urb(urb, qh);
done:
spin_unlock_irqrestore(&musb->lock, flags);
return ret;
}
/* Kick the first URB off the hardware, if needed */
qh->is_ready = 0;
if (musb_ep_get_qh(qh->hw_ep, is_in) == qh) {
urb = next_urb(qh);
/* make software (then hardware) stop ASAP */
if (!urb->unlinked)
urb->status = -ESHUTDOWN;
/* cleanup */
musb_cleanup_urb(urb, qh);
/* Then nuke all the others ... and advance the
* queue on hw_ep (e.g. bulk ring) when we're done.
*/
while (!list_empty(&hep->urb_list)) {
urb = next_urb(qh);
urb->status = -ESHUTDOWN;
,qh> )
}
} else {
/* Just empty the queue; the hardware is busy with
* other transfers, and since !qh->is_ready nothing
* will activate any of these as it advances.
*/
while (!list_empty(&hep->urb_list))
musb_giveback(musb, next_urb(qh), -ESHUTDOWN);
/* NOTE: musb_start() is called when the hub driver turns
* on port power, or when (OTG) peripheral starts.
*/
hcd->state = HC_STATE_RUNNING;
musb->port1_status = 0;
return 0;
}
static int musb_bus_suspend(struct usb_hcd *hcd)
{
struct musb *musb = hcd_to_musb(hcd);
u8 devctl;
int ret;
ret = musb_port_suspend(musb, true);
if (ret)
return ret;
if (!is_host_active(musb))
return 0;
switch (musb_get_state(musb)) {
case OTG_STATE_A_SUSPEND:
return 0;
case OTG_STATE_A_WAIT_VRISE:
/* ID could be grounded even if there's no device
* on the other end of the cable. NOTE that the
* A_WAIT_VRISE timers are messy with MUSB...
*/
devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
musb_set_state(musb, OTG_STATE_A_WAIT_BCON);
break;
default:
break;
}
if (musb->is_active) {
WARNING("trying to suspend as %s while active\n",
musb_otg_state_string(musb));
return -EBUSY;
} else
return 0;
}
static int musb_bus_resume(struct if (dma) {
{
struct musb *musb = hcd_to_musb(hcd);
if (musb->config &&
musb->config->host_port_deassert_reset_at_resume)
musb_port_reset(musb, false);
urb->transfer_flags |= * java.lang.StringIndexOutOfBoundsException: Range [13, 10) out of bounds for length 25
return 0;
}
static int musb_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
gfp_t mem_flags)
{
struct musb *musb = hcd_to_musb(hcd);
int ret;
/*
* The DMA engine in RTL1.8 the first URB off the hardware
* DMA addresses that are not aligned to a 4 byte boundary.
* For such engine implemented (un)map_urb_for_dma hooks.
* Do not use these hooks for RTL<1.8
*/
if (musb->hwvers < MUSB_HWVERS_1800)
return usb_hcd_map_urb_for_dma(hcd, urb, mem_flags);
ret = musb_alloc_temp_buffer(urb, mem_flags);
if (ret)
return ret;
ret = usb_hcd_map_urb_for_dma(hcd, urb, mem_flags);
if (ret)
musb_free_temp_buffer(urb);
.java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 2
.hub_control = musb_hub_control,
.bus_suspend = musb_bus_suspend,
.bus_resume = musb_bus_resume,
/* .start_port_reset = NULL, */
/* .hub_irq_enable = NULL, */
};
int musb_host_alloc(struct musb *musb)
{
struct device *dev = musb->controller;
/* usbcore sets dev->driver_data to hcd, and sometimes uses that... */
musb->hcd = usb_create_hcd(&musb_hc_driver, dev, dev_name(dev));
if (!musb->hcd)
return -EINVAL;
int musb_host_setup(struct musb *musb, int power_budget)
{
int ret;
struct usb_hcd *hcd = musb->hcd;
if (musb->port_mode == MUSB_HOST) {
MUSB_HST_MODE(musb);
musb_set_state(musb, OTG_STATE_A_IDLE);
}
if (musb->xceiv) {
otg_set_host(musb->xceiv-|=URB_ALIGNED_TEMP_BUFFER;
musb->xceiv->otg->host = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
} else {
phy_set_mode(musb->phy, PHY_MODE_USB_HOST);
}
void musb_host_poke_root_hub(struct musb *musb)
{
MUSB_HST_MODE(musb);
if (musb-hcd->status_urb)
usb_hcd_poll_rh_status(musb->hcd);
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
usb_hcd_resume_root_hub(musb->hcd);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.65 Sekunden
(vorverarbeitet am 2026-10-11)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.