Changeset a312d8f in mainline


Ignore:
Timestamp:
2017-10-30T22:18:28Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
17873ac7
Parents:
ef1a3a8
Message:

uhci: fixed buffer copying on IN transaction

Lost in some refactoring, masked by deadlock.

Location:
uspace
Files:
4 edited

Legend:

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

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

    ref1a3a8 ra312d8f  
    6464}
    6565
     66void 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
    6675/** Allocate memory and initialize internal data structure.
    6776 *
     
    131140        dest += setup_size;
    132141        /* Copy generic data unless they are provided by the device */
    133         if (usb_batch->ep->direction != USB_DIRECTION_IN) {
     142        if (usb_batch->dir != USB_DIRECTION_IN) {
    134143                memcpy(dest, usb_batch->buffer, usb_batch->buffer_size);
    135144        }
  • uspace/drv/bus/usb/uhci/uhci_batch.h

    ref1a3a8 ra312d8f  
    6767} uhci_transfer_batch_t;
    6868
    69 uhci_transfer_batch_t * uhci_transfer_batch_create(endpoint_t *ep);
    70 int uhci_transfer_batch_prepare(uhci_transfer_batch_t *uhci_batch);
    71 bool uhci_transfer_batch_check_completed(uhci_transfer_batch_t *uhci_batch);
    72 void uhci_transfer_batch_destroy(uhci_transfer_batch_t *uhci_batch);
     69uhci_transfer_batch_t * uhci_transfer_batch_create(endpoint_t *);
     70int uhci_transfer_batch_prepare(uhci_transfer_batch_t *);
     71bool uhci_transfer_batch_check_completed(uhci_transfer_batch_t *);
     72void uhci_transfer_batch_finish(uhci_transfer_batch_t *);
     73void uhci_transfer_batch_destroy(uhci_transfer_batch_t *);
    7374
    7475/** Get offset to setup buffer accessible to the HC hw.
  • uspace/lib/usbhost/src/bus.c

    ref1a3a8 ra312d8f  
    3636#include <usb/host/bus.h>
    3737#include <usb/host/endpoint.h>
     38#include <usb/debug.h>
    3839#include <ddf/driver.h>
    3940
     
    127128int bus_add_endpoint(bus_t *bus, device_t *device, const usb_endpoint_desc_t *desc, endpoint_t **out_ep)
    128129{
     130        assert(bus);
     131        assert(device);
     132
     133        fibril_mutex_lock(&bus->guard);
     134
     135        if (desc->max_packet_size == 0 || desc->packets == 0) {
     136                usb_log_warning("Invalid endpoint description (mps %zu, %u packets)", desc->max_packet_size, desc->packets);
     137                return EINVAL;
     138        }
     139
    129140        int err = ENOMEM;
    130 
    131         assert(bus);
    132         assert(device);
    133 
    134         fibril_mutex_lock(&bus->guard);
    135 
    136141        endpoint_t *ep = bus->ops.create_endpoint(bus);
    137142        if (!ep)
Note: See TracChangeset for help on using the changeset viewer.