Changeset 81487c4a in mainline


Ignore:
Timestamp:
2017-10-23T09:33:25Z (7 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
31cca4f3
Parents:
82fe063
Message:

Changed PSA allocation to conform with specification.

Location:
uspace/drv/bus/usb/xhci
Files:
2 edited

Legend:

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

    r82fe063 r81487c4a  
    6464}
    6565
     66static bool endpoint_uses_streams(xhci_endpoint_t *xhci_ep)
     67{
     68        return xhci_ep->base.transfer_type == USB_TRANSFER_BULK
     69            && xhci_ep->max_streams;
     70}
     71
     72static size_t primary_stream_ctx_array_size(xhci_endpoint_t *xhci_ep)
     73{
     74        if (!endpoint_uses_streams(xhci_ep))
     75                return 0;
     76
     77        /* Section 6.2.3, Table 61 */
     78        return 1 << (xhci_ep->max_streams + 1);
     79}
     80
    6681int xhci_endpoint_alloc_transfer_ds(xhci_endpoint_t *xhci_ep)
    6782{
    6883        int err;
    6984
    70         if (xhci_ep->max_streams > 0) {
    71                 // Set up primary stream context array if needed.
    72                 xhci_ep->primary_stream_ctx_array = malloc32(xhci_ep->max_streams * sizeof(xhci_stream_ctx_t));
     85        if (endpoint_uses_streams(xhci_ep)) {
     86                /* Set up primary stream context array if needed. */
     87                const size_t size = primary_stream_ctx_array_size(xhci_ep);
     88
     89                xhci_ep->primary_stream_ctx_array = malloc32(size * sizeof(xhci_stream_ctx_t));
    7390                if (!xhci_ep->primary_stream_ctx_array) {
    7491                        return ENOMEM;
    7592                }
    76                 memset(xhci_ep->primary_stream_ctx_array, 0, xhci_ep->max_streams * sizeof(xhci_stream_ctx_t));
     93
     94                memset(xhci_ep->primary_stream_ctx_array, 0, size * sizeof(xhci_stream_ctx_t));
    7795        } else {
    7896                xhci_ep->primary_stream_ctx_array = NULL;
     
    89107        int err;
    90108
    91         if (xhci_ep->max_streams > 0) {
     109        if (endpoint_uses_streams(xhci_ep)) {
    92110                // TODO: What about secondaries?
    93111                free32(xhci_ep->primary_stream_ctx_array);
     
    169187        XHCI_EP_ERROR_COUNT_SET(*ctx, 3);
    170188
    171         if (ep->max_streams > 0) {
     189        if (endpoint_uses_streams(ep)) {
    172190                XHCI_EP_MAX_P_STREAMS_SET(*ctx, ep->max_streams);
    173191                XHCI_EP_TR_DPTR_SET(*ctx, addr_to_phys(ep->primary_stream_ctx_array));
  • uspace/drv/bus/usb/xhci/endpoint.h

    r82fe063 r81487c4a  
    7676        xhci_stream_ctx_t *primary_stream_ctx_array;
    7777
    78         /** Maximum number of primary streams (0-16), also a valid range of PSCA above */
     78        /** 2-log of maximum number of primary streams (0-16). Not to be used directly. */
    7979        uint8_t max_streams;
    8080
Note: See TracChangeset for help on using the changeset viewer.