Changeset 889146e in mainline for uspace/drv/bus/usb/xhci/hc.c


Ignore:
Timestamp:
2017-12-10T21:49:12Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
53db806
Parents:
6ef407b
git-author:
Ondřej Hlavatý <aearsis@…> (2017-12-10 21:43:47)
git-committer:
Ondřej Hlavatý <aearsis@…> (2017-12-10 21:49:12)
Message:

xhci: commands shall not just timeout

Previous behavior was breaking semantic: if a command was successful,
but just took too long to complete, we returned an error, and the caller
had no way to know if the command's effect has taken place.

This commit implements command aborting. The wait_for_command now cannot
just timeout - instead it aborts currently running (probably blocked)
command, and then gets back to waiting. So now, if command_sync returns
an error, it means the command was really unsuccessful.

If aborting the command takes too long, we should reset the whole HC.
This is not yet implemented.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/hc.c

    r6ef407b r889146e  
    4444#include "hw_struct/context.h"
    4545#include "endpoint.h"
    46 #include "commands.h"
    4746#include "transfers.h"
    4847#include "trb_ring.h"
     
    204203        hc->dcbaa = hc->dcbaa_dma.virt;
    205204
    206         if ((err = xhci_trb_ring_init(&hc->command_ring)))
     205        if ((err = xhci_event_ring_init(&hc->event_ring)))
    207206                goto err_dcbaa;
    208 
    209         if ((err = xhci_event_ring_init(&hc->event_ring)))
    210                 goto err_cmd_ring;
    211207
    212208        if ((err = xhci_scratchpad_alloc(hc)))
     
    233229err_event_ring:
    234230        xhci_event_ring_fini(&hc->event_ring);
    235 err_cmd_ring:
    236         xhci_trb_ring_fini(&hc->command_ring);
    237231err_dcbaa:
    238232        hc->dcbaa = NULL;
     
    399393                return err;
    400394
     395        // FIXME: Waiting forever.
    401396        while (XHCI_REG_RD(hc->op_regs, XHCI_OP_CNR))
    402397                async_usleep(1000);
     
    407402        XHCI_REG_WR(hc->op_regs, XHCI_OP_MAX_SLOTS_EN, 0);
    408403
    409         uint64_t crptr = xhci_trb_ring_get_dequeue_ptr(&hc->command_ring);
     404        uint64_t crptr = xhci_trb_ring_get_dequeue_ptr(&hc->cr.trb_ring);
    410405        XHCI_REG_WR(hc->op_regs, XHCI_OP_CRCR_LO, LOWER32(crptr) >> 6);
    411406        XHCI_REG_WR(hc->op_regs, XHCI_OP_CRCR_HI, UPPER32(crptr));
     
    578573{
    579574        xhci_bus_fini(&hc->bus);
    580         xhci_trb_ring_fini(&hc->command_ring);
    581575        xhci_event_ring_fini(&hc->event_ring);
    582576        hc_dcbaa_fini(hc);
Note: See TracChangeset for help on using the changeset viewer.