Changeset 9afd2a8 in mainline for uspace/lib/virtio/virtio.c


Ignore:
Timestamp:
2018-06-22T20:27:31Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5609d3c
Parents:
b8ef198b
Message:

The idx of the avail ring must always grow

The index cannot wrap around the queue size or it would be 0 when all
buffers are made available in the queue. Instead, the standard mandates
idx always grows, naturally wrapping at 65536.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/virtio/virtio.c

    rb8ef198b r9afd2a8  
    6464
    6565        uint16_t idx = pio_read_le16(&q->avail->idx);
    66         pio_write_le16(&q->avail->ring[idx], descno);
     66        pio_write_le16(&q->avail->ring[idx % q->queue_size], descno);
    6767        write_barrier();
    68         pio_write_le16(&q->avail->idx, (idx + 1) % q->queue_size);
     68        pio_write_le16(&q->avail->idx, idx + 1);
    6969        write_barrier();
    7070        pio_write_le16(q->notify, num);
Note: See TracChangeset for help on using the changeset viewer.