Skip to content

Commit e3fb550

Browse files
P33Mpopcornmix
authored andcommitted
fiq_fsm: fix bounce buffer utilisation for Isochronous OUT
Multi-packet isochronous OUT transactions were subject to a few bounday bugs. Fix them. Audio playback is now much more robust: however, an issue stands with devices that have adaptive sinks - ALSA plays samples too fast.
1 parent 1cb61d3 commit e3fb550

1 file changed

Lines changed: 9 additions & 20 deletions

File tree

‎drivers/usb/host/dwc_otg/dwc_otg_hcd.c‎

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,13 +1479,11 @@ int fiq_fsm_transaction_suitable(dwc_otg_qh_t *qh)
14791479
int fiq_fsm_setup_periodic_dma(dwc_otg_hcd_t *hcd, struct fiq_channel_state *st, dwc_otg_qh_t *qh)
14801480
{
14811481
int frame_length, i = 0;
1482-
uint32_t nrslots, last_size;
14831482
uint8_t *ptr = NULL;
14841483
dwc_hc_t *hc = qh->channel;
14851484
struct fiq_dma_blob *blob;
14861485
struct dwc_otg_hcd_iso_packet_desc *frame_desc;
14871486

1488-
14891487
for (i = 0; i < 6; i++) {
14901488
st->dma_info.slot_len[i] = 255;
14911489
}
@@ -1520,9 +1518,6 @@ int fiq_fsm_setup_periodic_dma(dwc_otg_hcd_t *hcd, struct fiq_channel_state *st,
15201518
blob = hcd->fiq_dmab;
15211519

15221520
ptr = qtd->urb->buf + frame_desc->offset;
1523-
nrslots = (frame_length + 187) / 188;
1524-
last_size = frame_length % 188;
1525-
//printk(KERN_INFO "len = %d nrslots = %d last_size=%d\n", frame_length, nrslots, last_size);
15261521
if (frame_length == 0) {
15271522
/*
15281523
* for isochronous transactions, we must still transmit a packet
@@ -1532,31 +1527,25 @@ int fiq_fsm_setup_periodic_dma(dwc_otg_hcd_t *hcd, struct fiq_channel_state *st,
15321527
st->nrpackets = 1;
15331528
} else {
15341529
do {
1535-
if (i < nrslots - 1) {
1530+
if (frame_length <= 188) {
1531+
dwc_memcpy(&blob->channel[hc->hc_num].index[i].buf[0], ptr, frame_length);
1532+
st->dma_info.slot_len[i] = frame_length;
1533+
ptr += frame_length;
1534+
} else {
15361535
dwc_memcpy(&blob->channel[hc->hc_num].index[i].buf[0], ptr, 188);
15371536
st->dma_info.slot_len[i] = 188;
15381537
ptr += 188;
1539-
} else {
1540-
dwc_memcpy(&blob->channel[hc->hc_num].index[i].buf[0], ptr, last_size);
1541-
st->dma_info.slot_len[i] = last_size;
1542-
ptr += last_size;
15431538
}
15441539
i++;
1545-
} while (i <= nrslots - 1);
1540+
frame_length -= 188;
1541+
} while (frame_length > 0);
15461542
st->nrpackets = i;
15471543
}
15481544
ptr = qtd->urb->buf + frame_desc->offset;
1549-
if(DWC_MEMCMP(&blob->channel[hc->hc_num].index[0].buf[0], ptr, frame_length))
1550-
BUG();
15511545
/* Point the HC at the DMA address of the bounce buffers */
15521546
blob = (struct fiq_dma_blob *) hcd->fiq_state->dma_base;
1553-
/* Bugette: for some reason, memcpy corrupts the data in the bounce buffers. May be a
1554-
* cache coherency issue */
1555-
//st->hcdma_copy.d32 = (uint32_t) &blob->channel[hc->hc_num].index[0].buf[0];
1556-
//ptr = qtd->urb->buf + frame_desc->offset;
1557-
st->hcdma_copy.d32 = (uint32_t) qtd->urb->dma + frame_desc->offset;
1558-
if (st->hcdma_copy.d32 & 0x3)
1559-
BUG();
1547+
st->hcdma_copy.d32 = (uint32_t) &blob->channel[hc->hc_num].index[0].buf[0];
1548+
15601549
/* fixup xfersize to the actual packet size */
15611550
st->hctsiz_copy.b.pid = 0;
15621551
st->hctsiz_copy.b.xfersize = st->dma_info.slot_len[0];

0 commit comments

Comments
 (0)