Changeset 1d758fc in mainline for uspace/lib/usbdev/src/pipes.c


Ignore:
Timestamp:
2018-02-12T10:11:47Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5fe3f954
Parents:
2f762a7
git-author:
Ondřej Hlavatý <aearsis@…> (2018-02-05 03:28:50)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-02-12 10:11:47)
Message:

usb: rethinking DMA buffers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/pipes.c

    r2f762a7 r1d758fc  
    8383
    8484        /* Only control writes make sense without buffer */
    85         if ((t->dir != USB_DIRECTION_OUT || !t->is_control)
    86             && (t->req.base == NULL || t->req.size == 0))
     85        if ((t->dir != USB_DIRECTION_OUT || !t->is_control) && t->req.size == 0)
    8786                return EINVAL;
    8887
    8988        /* Nonzero size requires buffer */
    90         if (t->req.base == NULL && t->req.size != 0)
     89        if (!dma_buffer_is_set(&t->req.buffer) && t->req.size != 0)
    9190                return EINVAL;
    9291
     
    119118/**
    120119 * Setup the transfer request inside transfer according to dma buffer provided.
     120 *
     121 * TODO: The buffer could have been allocated as a more strict one. Currently,
     122 * we assume that the policy is just the requested one.
    121123 */
    122124static void setup_dma_buffer(transfer_t *t, void *base, void *ptr, size_t size)
    123125{
    124         t->req.base = base;
     126        t->req.buffer.virt = base;
     127        t->req.buffer.policy = t->pipe->desc.transfer_buffer_policy;
    125128        t->req.offset = ptr - base;
    126129        t->req.size = size;
    127         t->req.buffer_policy = t->pipe->desc.transfer_buffer_policy;
    128130}
    129131
     
    133135static errno_t transfer_wrap_dma(transfer_t *t, void *buf, size_t size)
    134136{
     137        if (size == 0) {
     138                setup_dma_buffer(t, NULL, NULL, 0);
     139                return transfer_common(t);
     140        }
     141
    135142        void *dma_buf = usb_pipe_alloc_buffer(t->pipe, size);
    136143        setup_dma_buffer(t, dma_buf, dma_buf, size);
     
    364371        .direction = USB_DIRECTION_BOTH,
    365372        .max_transfer_size = CTRL_PIPE_MIN_PACKET_SIZE,
     373        .transfer_buffer_policy = DMA_POLICY_STRICT,
    366374};
    367375
Note: See TracChangeset for help on using the changeset viewer.