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

Changeset 33d19a7 in mainline


Ignore:
Timestamp:
2011-05-18T10:40:34Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
68b9f148
Parents:
c7b5826
Message:

Fix OHCI buffer access.

Consider more than one data transaction when computing transfered size.
Reduce max transfer size to 4KB to guarantee that max 2 pages will be used.

Location:
uspace/drv/ohci
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/batch.c

    rc7b5826 r33d19a7  
    151151
    152152        /* NOTE: OHCI is capable of handling buffer that crosses page boundaries
    153          * it is, however, not capable of handling buffer that accupies more
    154          * than two pages (the first page is computete using start pointer, the
    155          * other using end pointer)*/
     153         * it is, however, not capable of handling buffer that occupies more
     154         * than two pages (the first page is computed using start pointer, the
     155         * other using the end pointer) */
    156156        if (setup_size + buffer_size > 0) {
    157157                data->device_buffer = malloc32(setup_size + buffer_size);
     
    180180        ohci_transfer_batch_t *data = instance->private_data;
    181181        assert(data);
    182         size_t tds = data->td_count;
    183182        usb_log_debug("Batch(%p) checking %zu td(s) for completion.\n",
    184             instance, tds);
     183            instance, data->td_count);
    185184        usb_log_debug("ED: %x:%x:%x:%x.\n",
    186185            data->ed->status, data->ed->td_head, data->ed->td_tail,
     
    188187        size_t i = 0;
    189188        instance->transfered_size = instance->buffer_size;
    190         for (; i < tds; ++i) {
     189        for (; i < data->td_count; ++i) {
    191190                assert(data->tds[i] != NULL);
    192191                usb_log_debug("TD %zu: %x:%x:%x:%x.\n", i,
     
    213212        assert(hcd_ep);
    214213        hcd_ep->td = data->tds[i];
    215         if (i > 0)
    216                 instance->transfered_size -= td_remain_size(data->tds[i - 1]);
     214        assert(i > 0);
     215        for (--i;i < data->td_count; ++i)
     216                instance->transfered_size -= td_remain_size(data->tds[i]);
    217217
    218218        /* Clear possible ED HALT */
  • uspace/drv/ohci/hw_struct/transfer_descriptor.h

    rc7b5826 r33d19a7  
    4141#include "completion_codes.h"
    4242
    43 /* OHCI TDs can handle up to 8KB buffers */
    44 #define OHCI_TD_MAX_TRANSFER (8 * 1024)
     43/* OHCI TDs can handle up to 8KB buffers, however, it can use max 2 pages.
     44 * Using 4KB buffers guarantees the page count condition.
     45 * (OHCI assumes 4KB pages) */
     46#define OHCI_TD_MAX_TRANSFER (4 * 1024)
    4547
    4648typedef struct td {
Note: See TracChangeset for help on using the changeset viewer.