Changeset 0f803831 in mainline


Ignore:
Timestamp:
2018-01-17T10:52:53Z (6 years ago)
Author:
Salmelu <salmelu@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5dab9ef0
Parents:
740dafc
git-author:
Salmelu <salmelu@…> (2018-01-17 10:50:57)
git-committer:
Salmelu <salmelu@…> (2018-01-17 10:52:53)
Message:

xhci: more stream validity checks

Location:
uspace
Files:
2 edited

Legend:

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

    r740dafc r0f803831  
    193193 * @param[in] ctx Endpoint context to configure.
    194194 * @param[in] pstreams The value of MaxPStreams.
     195 * @param[in] lsa Specifies if the stream IDs point to primary stream array.
    195196 */
    196197static void setup_stream_context(xhci_endpoint_t *xhci_ep, xhci_ep_ctx_t *ctx, unsigned pstreams, unsigned lsa)
     
    203204        XHCI_EP_MAX_P_STREAMS_SET(*ctx, pstreams);
    204205        XHCI_EP_TR_DPTR_SET(*ctx, xhci_ep->primary_stream_ctx_dma.phys);
    205         // TODO: set HID?
    206206        XHCI_EP_LSA_SET(*ctx, lsa);
    207207}
     
    216216        }
    217217
    218         if (xhci_ep->max_streams == 1) {
     218        if (xhci_ep->max_streams <= 1) {
    219219                usb_log_error("Streams are not supported by endpoint " XHCI_EP_FMT, XHCI_EP_ARGS(*xhci_ep));
     220                return EINVAL;
     221        }
     222
     223        if (count < 2) {
     224                usb_log_error("The minumum amount of primary streams is 2.");
    220225                return EINVAL;
    221226        }
     
    295300        xhci_endpoint_t *xhci_ep, unsigned *sizes, unsigned count)
    296301{
     302        /* Check if HC supports secondary indexing */
     303        if (XHCI_REG_RD(hc->cap_regs, XHCI_CAP_NSS)) {
     304                usb_log_error("The host controller doesn't support secondary streams.");
     305                return ENOTSUP;
     306        }
     307
    297308        int err = verify_stream_conditions(hc, dev, xhci_ep, count);
    298309        if (err) {
     
    300311        }
    301312
    302         // TODO: determine if count * secondary streams <= max_streams
    303         if (count > xhci_ep->max_streams) {
     313        if (count > 256) {
     314                usb_log_error("The amount of primary streams cannot be higher than 256.");
     315                return EINVAL;
     316        }
     317
     318        /*
     319         * Find the largest requested secondary stream size,
     320         * that one is the maximum ID that device can receive.
     321         * We need to make sure the device can handle that ID.
     322         */
     323        unsigned max = 0;
     324        for (size_t index = 0; index < count; ++index) {
     325                if (sizes[count] > max) {
     326                        max = sizes[count];
     327                }
     328        }
     329
     330        if (max * count > xhci_ep->max_streams) {
    304331                usb_log_error("Endpoint " XHCI_EP_FMT " supports only %" PRIu32 " streams.",
    305332                        XHCI_EP_ARGS(*xhci_ep), xhci_ep->max_streams);
  • uspace/lib/drv/generic/remote_usbhc.c

    r740dafc r0f803831  
    558558                /* .address is initialized by write itself */
    559559                .endpoint = ep,
     560                /* streams are not given by the API call yet */
     561                .stream = 0,
    560562        }};
    561563
Note: See TracChangeset for help on using the changeset viewer.