Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset deb2e55 in mainline


Ignore:
Timestamp:
2017-12-28T21:54:38Z (4 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master
Children:
415c5116
Parents:
66c16b0
git-author:
Petr Manek <petr.manek@…> (2017-12-28 21:54:31)
git-committer:
Petr Manek <petr.manek@…> (2017-12-28 21:54:38)
Message:

usbhost: refactoring

Moved the "online" attribute from xhci_device_t to device_t. Changed
USB2 bus implementation to produce online devices (not to break
functionality on older buses).

Location:
uspace
Files:
8 edited

Legend:

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

    r66c16b0 rdeb2e55  
    217217        usb_log_debug2("Device " XHCI_DEV_FMT " going offline.", XHCI_DEV_ARGS(*xhci_dev));
    218218        fibril_mutex_lock(&dev->guard);
    219         xhci_dev->online = false;
     219        dev->online = false;
    220220        fibril_mutex_unlock(&dev->guard);
    221221
     
    304304        usb_log_debug2("Device " XHCI_DEV_FMT " going online.", XHCI_DEV_ARGS(*dev));
    305305        fibril_mutex_lock(&dev_base->guard);
    306         dev->online = true;
     306        dev_base->online = true;
    307307        fibril_mutex_unlock(&dev_base->guard);
    308308
     
    332332        usb_log_debug2("Device " XHCI_DEV_FMT " going offline.", XHCI_DEV_ARGS(*dev));
    333333        fibril_mutex_lock(&dev_base->guard);
    334         dev->online = false;
     334        dev_base->online = false;
    335335        fibril_mutex_unlock(&dev_base->guard);
    336336
  • uspace/drv/bus/usb/xhci/endpoint.c

    r66c16b0 rdeb2e55  
    463463
    464464        /* Offline devices don't create new endpoints other than EP0. */
    465         if (!dev->online && ep->base.endpoint > 0) {
     465        if (!dev->base.online && ep->base.endpoint > 0) {
    466466                return EAGAIN;
    467467        }
  • uspace/drv/bus/usb/xhci/endpoint.h

    r66c16b0 rdeb2e55  
    141141        /** Flag indicating whether the device is USB3 (it's USB2 otherwise). */
    142142        bool usb3;
    143 
    144         /** True if the device can add new endpoints and schedule transfers. */
    145         volatile bool online;
    146143} xhci_device_t;
    147144
  • uspace/drv/bus/usb/xhci/hc.c

    r66c16b0 rdeb2e55  
    706706        /* From now on, the device is officially online, yay! */
    707707        fibril_mutex_lock(&dev->base.guard);
    708         dev->online = true;
     708        dev->base.online = true;
    709709        fibril_mutex_unlock(&dev->base.guard);
    710710
  • uspace/drv/bus/usb/xhci/transfers.c

    r66c16b0 rdeb2e55  
    261261        size_t tdpc = len / 1024 + ((len % 1024) ? 1 : 0);
    262262        size_t tbc = tdpc / (ep->max_burst + 1);
    263         if(!tdpc % (ep->max_burst + 1)) --tbc;
     263        if (!tdpc % (ep->max_burst + 1)) --tbc;
    264264        size_t bsp = tdpc % (ep->max_burst + 1);
    265265        size_t tlbpc = (bsp ? bsp - 1 : ep->max_burst);
     
    520520        xhci_device_t *xhci_dev = xhci_ep_to_dev(xhci_ep);
    521521
    522         /* Offline devices don't schedule transfers other than on EP0. */
    523         if (!xhci_dev->online && ep->endpoint > 0) {
    524                 return EAGAIN;
    525         }
    526 
    527522        // FIXME: find a better way to check if the ring is not initialized
    528523        if (!xhci_ep->ring.segment_count) {
     
    533528
    534529        // Isochronous transfer needs to be handled differently
    535         if(batch->ep->transfer_type == USB_TRANSFER_ISOCHRONOUS) {
     530        if (batch->ep->transfer_type == USB_TRANSFER_ISOCHRONOUS) {
    536531                return schedule_isochronous(hc, transfer, xhci_ep, xhci_dev);
    537532        }
  • uspace/lib/usbhost/include/usb/host/bus.h

    r66c16b0 rdeb2e55  
    7979        /* Managing bus */
    8080        bus_t *bus;
     81
     82        /** True if the device can add new endpoints and schedule transfers. */
     83        volatile bool online;
    8184
    8285        /* This structure is meant to be extended by overriding. */
  • uspace/lib/usbhost/src/endpoint.c

    r66c16b0 rdeb2e55  
    214214        }
    215215
     216        /* Offline devices don't schedule transfers other than on EP0. */
     217        if (!ep->device->online && ep->endpoint > 0) {
     218                return EAGAIN;
     219        }
     220
    216221        const size_t bw = endpoint_count_bw(ep, size);
    217222        /* Check if we have enough bandwidth reserved */
  • uspace/lib/usbhost/src/usb2_bus.c

    r66c16b0 rdeb2e55  
    271271        }
    272272
     273        /* From now on, the device is officially online, yay! */
     274        fibril_mutex_lock(&dev->guard);
     275        dev->online = true;
     276        fibril_mutex_unlock(&dev->guard);
     277
    273278        return EOK;
    274279
Note: See TracChangeset for help on using the changeset viewer.