Changeset 391d55b in mainline


Ignore:
Timestamp:
2011-04-06T18:27:49Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5876d36
Parents:
6ce42e85
Message:

Add interrupt bandwidth checks

Location:
uspace/drv/uhci-hcd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/hc.c

    r6ce42e85 r391d55b  
    6666static int hc_interrupt_emulator(void *arg);
    6767static int hc_debug_checker(void *arg);
    68 
     68#if 0
    6969static bool usb_is_allowed(
    7070    bool low_speed, usb_transfer_type_t transfer, size_t size);
     71#endif
    7172/*----------------------------------------------------------------------------*/
    7273/** Initialize UHCI hcd driver structure
     
    327328        assert(instance);
    328329        assert(batch);
    329         const int low_speed = (batch->speed == USB_SPEED_LOW);
    330         if (!usb_is_allowed(
    331             low_speed, batch->transfer_type, batch->max_packet_size)) {
    332                 usb_log_error("Invalid USB transfer specified %s %d %zu.\n",
    333                     usb_str_speed(batch->speed), batch->transfer_type,
    334                     batch->max_packet_size);
    335                 return ENOTSUP;
    336         }
    337         /* Check available bandwidth */
    338 /*
    339         if (batch->transfer_type == USB_TRANSFER_INTERRUPT ||
    340             batch->transfer_type == USB_TRANSFER_ISOCHRONOUS) {
    341                 const size_t bw = bandwidth_count_usb11(batch->speed,
    342                     batch->transfer_type, batch->buffer_size,
    343                     batch->max_packet_size);
    344 
    345                 int ret =
    346                     bandwidth_use(&instance->bandwidth, batch->target.address,
    347                     batch->target.endpoint, batch->direction, bw);
    348                 if (ret != EOK) {
    349                         usb_log_error("Failed(%d) to use reserved bw: %s.\n",
    350                             ret, str_error(ret));
    351                         return ret;
    352                 }
    353         }
    354 */
    355330
    356331        transfer_list_t *list =
     
    539514 * @return True if transaction is allowed by USB specs, false otherwise
    540515 */
     516#if 0
    541517bool usb_is_allowed(
    542518    bool low_speed, usb_transfer_type_t transfer, size_t size)
     
    556532        return false;
    557533}
     534#endif
    558535/**
    559536 * @}
  • uspace/drv/uhci-hcd/iface.c

    r6ce42e85 r391d55b  
    194194            target.address, target.endpoint, size, max_packet_size);
    195195
     196        size_t res_bw;
    196197        endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager,
    197             target.address, target.endpoint, USB_DIRECTION_OUT, NULL);
     198            target.address, target.endpoint, USB_DIRECTION_OUT, &res_bw);
    198199        if (ep == NULL) {
    199200                usb_log_error("Endpoint(%d:%d) not registered for INT OUT.\n",
    200201                        target.address, target.endpoint);
     202                return ENOENT;
     203        }
     204        const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type,
     205            size, ep->max_packet_size);
     206        if (res_bw < bw)
     207        {
     208                usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw "
     209                    "but only %zu is reserved.\n",
     210                    target.address, target.endpoint, bw, res_bw);
    201211                return ENOENT;
    202212        }
     
    241251            target.address, target.endpoint, size, max_packet_size);
    242252
     253        size_t res_bw;
    243254        endpoint_t *ep = usb_endpoint_manager_get_ep_data(&hc->ep_manager,
    244             target.address, target.endpoint, USB_DIRECTION_IN, NULL);
     255            target.address, target.endpoint, USB_DIRECTION_IN, &res_bw);
    245256        if (ep == NULL) {
    246257                usb_log_error("Endpoint(%d:%d) not registered for INT IN.\n",
    247                         target.address, target.endpoint);
     258                    target.address, target.endpoint);
    248259                return ENOENT;
    249260        }
     261        const size_t bw = bandwidth_count_usb11(ep->speed, ep->transfer_type,
     262            size, ep->max_packet_size);
     263        if (res_bw < bw)
     264        {
     265                usb_log_error("Endpoint(%d:%d) INT IN needs %zu bw "
     266                    "but only %zu bw is reserved.\n",
     267                    target.address, target.endpoint, bw, res_bw);
     268                return ENOENT;
     269        }
     270
    250271        assert(ep->speed ==
    251272            usb_device_keeper_get_speed(&hc->manager, target.address));
Note: See TracChangeset for help on using the changeset viewer.