Changeset 17873ac7 in mainline for uspace/drv/bus/usb/uhci


Ignore:
Timestamp:
2017-10-31T19:06:57Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
479e32d
Parents:
a312d8f
Message:

usbhost endpoint: endpoint→active replaced by tracking active batch

The mechanism is optional, synchronization over endpoint is now not forced. It will be used by xhci to utilize streams.

Location:
uspace/drv/bus/usb/uhci
Files:
4 edited

Legend:

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

    ra312d8f r17873ac7  
    177177                        uhci_transfer_batch_t *batch =
    178178                            uhci_transfer_batch_from_link(current);
    179                         uhci_transfer_batch_finish(batch);
     179                        usb_transfer_batch_finish(&batch->base);
    180180                }
    181181        }
  • uspace/drv/bus/usb/uhci/transfer_list.c

    ra312d8f r17873ac7  
    115115        assert(instance);
    116116        assert(uhci_batch);
     117
     118        endpoint_t *ep = uhci_batch->base.ep;
     119
     120        /* First, wait until the endpoint is free to use */
     121        fibril_mutex_lock(&ep->guard);
     122        endpoint_activate_locked(ep, &uhci_batch->base);
     123        fibril_mutex_unlock(&ep->guard);
     124
    117125        usb_log_debug2("Batch %p adding to queue %s.\n",
    118126            uhci_batch, instance->name);
     
    189197                    uhci_transfer_batch_from_link(current);
    190198                transfer_list_remove_batch(instance, batch);
    191                 uhci_transfer_batch_abort(batch);
     199                endpoint_abort(batch->base.ep);
    192200        }
    193201        fibril_mutex_unlock(&instance->guard);
  • uspace/drv/bus/usb/uhci/uhci_batch.c

    ra312d8f r17873ac7  
    6464}
    6565
    66 void uhci_transfer_batch_finish(uhci_transfer_batch_t *batch)
    67 {
    68         if (batch->base.dir == USB_DIRECTION_IN) {
    69                 assert(batch->base.transfered_size <= batch->base.buffer_size);
    70                 memcpy(batch->base.buffer, uhci_transfer_batch_data_buffer(batch), batch->base.transfered_size);
    71         }
    72         usb_transfer_batch_finish(&batch->base);
    73 }
    74 
    7566/** Allocate memory and initialize internal data structure.
    7667 *
     
    113104        }
    114105
    115         const size_t setup_size = (uhci_batch->base.ep->transfer_type == USB_TRANSFER_CONTROL)
     106        const size_t setup_size = (usb_batch->ep->transfer_type == USB_TRANSFER_CONTROL)
    116107                ? USB_SETUP_PACKET_SIZE
    117108                : 0;
     
    165156{
    166157        assert(uhci_batch);
     158        usb_transfer_batch_t *batch = &uhci_batch->base;
    167159
    168160        usb_log_debug2("Batch %p " USB_TRANSFER_BATCH_FMT
    169161            " checking %zu transfer(s) for completion.\n",
    170             uhci_batch, USB_TRANSFER_BATCH_ARGS(uhci_batch->base),
     162            uhci_batch, USB_TRANSFER_BATCH_ARGS(*batch),
    171163            uhci_batch->td_count);
    172         uhci_batch->base.transfered_size = 0;
     164        batch->transfered_size = 0;
    173165
    174166        for (size_t i = 0;i < uhci_batch->td_count; ++i) {
     
    177169                }
    178170
    179                 uhci_batch->base.error = td_status(&uhci_batch->tds[i]);
    180                 if (uhci_batch->base.error != EOK) {
    181                         assert(uhci_batch->base.ep != NULL);
     171                batch->error = td_status(&uhci_batch->tds[i]);
     172                if (batch->error != EOK) {
     173                        assert(batch->ep != NULL);
    182174
    183175                        usb_log_debug("Batch %p found error TD(%zu->%p):%"
     
    186178                        td_print_status(&uhci_batch->tds[i]);
    187179
    188                         endpoint_toggle_set(uhci_batch->base.ep,
     180                        endpoint_toggle_set(batch->ep,
    189181                            td_toggle(&uhci_batch->tds[i]));
    190182                        if (i > 0)
     
    193185                }
    194186
    195                 uhci_batch->base.transfered_size
     187                batch->transfered_size
    196188                    += td_act_size(&uhci_batch->tds[i]);
    197189                if (td_is_short(&uhci_batch->tds[i]))
     
    199191        }
    200192substract_ret:
    201         if (uhci_batch->base.ep->transfer_type == USB_TRANSFER_CONTROL)
    202                 uhci_batch->base.transfered_size -= USB_SETUP_PACKET_SIZE;
     193        if (batch->ep->transfer_type == USB_TRANSFER_CONTROL)
     194                batch->transfered_size -= USB_SETUP_PACKET_SIZE;
     195
     196        fibril_mutex_lock(&batch->ep->guard);
     197        usb_transfer_batch_reset_toggle(batch);
     198        endpoint_deactivate_locked(batch->ep);
     199        fibril_mutex_unlock(&batch->ep->guard);
     200
     201        if (batch->dir == USB_DIRECTION_IN) {
     202                assert(batch->transfered_size <= batch->buffer_size);
     203                memcpy(batch->buffer,
     204                    uhci_transfer_batch_data_buffer(uhci_batch),
     205                    batch->transfered_size);
     206        }
     207
    203208        return true;
    204209}
  • uspace/drv/bus/usb/uhci/uhci_batch.h

    ra312d8f r17873ac7  
    9898}
    9999
    100 /** Aborts the batch.
    101  * Sets error to EINTR and size off transferd data to 0, before finishing the
    102  * batch.
    103  * @param uhci_batch Batch to abort.
    104  */
    105 static inline void uhci_transfer_batch_abort(uhci_transfer_batch_t *uhci_batch)
    106 {
    107         assert(uhci_batch);
    108         uhci_batch->base.error = EINTR;
    109         uhci_batch->base.transfered_size = 0;
    110         usb_transfer_batch_finish(&uhci_batch->base);
    111 }
    112 
    113100/** Linked list conversion wrapper.
    114101 * @param l Linked list link.
Note: See TracChangeset for help on using the changeset viewer.