Skip to content

Commit

Permalink
add check for edpt_xfer() with halted, also reset data toggle when cl…
Browse files Browse the repository at this point in the history
…ear stall
  • Loading branch information
hathach committed Jul 27, 2023
1 parent 4deea87 commit 5a29db2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/portable/ehci/ehci.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,21 @@ bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t *
ehci_qtd_t* qtd;

if (epnum == 0) {
// Control endpoint never be stalled. Skip reset Data Toggle since it is fixed per stage
if (qhd->qtd_overlay.halted) {
qhd->qtd_overlay.halted = false;
}

qtd = qtd_control(dev_addr);
qtd_init(qtd, buffer, buflen);

// first data toggle is always 1 (data & setup stage)
qtd->data_toggle = 1;
qtd->pid = dir ? EHCI_PID_IN : EHCI_PID_OUT;
} else {
// skip if endpoint is halted
TU_VERIFY(!qhd->qtd_overlay.halted);

qtd = qtd_find_free();
TU_ASSERT(qtd);

Expand Down Expand Up @@ -506,8 +514,9 @@ bool hcd_edpt_clear_stall(uint8_t daddr, uint8_t ep_addr)
{
ehci_qhd_t *qhd = qhd_get_from_addr(daddr, ep_addr);
qhd->qtd_overlay.halted = 0;
qhd->qtd_overlay.data_toggle = 0;
hcd_dcache_clean_invalidate(qhd, sizeof(ehci_qhd_t));
// TODO reset data toggle ?

return true;
}

Expand Down Expand Up @@ -881,8 +890,10 @@ static void qhd_remove_qtd(ehci_qhd_t *qhd) {

qhd->attached_qtd = NULL;
qhd->attached_buffer = 0;
hcd_dcache_clean(qhd, sizeof(ehci_qhd_t));

qtd->used = 0; // free QTD
hcd_dcache_clean(qtd, sizeof(ehci_qtd_t));
}

//--------------------------------------------------------------------+
Expand Down

0 comments on commit 5a29db2

Please sign in to comment.