]> git.karo-electronics.de Git - karo-tx-linux.git/commit
virtio: expose added descriptors immediately.
authorRusty Russell <rusty@rustcorp.com.au>
Sun, 4 Dec 2011 23:33:30 +0000 (10:33 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Sun, 4 Dec 2011 23:33:30 +0000 (10:33 +1100)
commita9b029b8a831b793642d6486dabc734fa06c190d
treedd4443b8e764cd539d2c5c415ae484383816618c
parentb63f090a95b5430c158b2c002678ce56519d0ff2
virtio: expose added descriptors immediately.

A virtio driver does virtqueue_add_buf() multiple times before finally
calling virtqueue_kick(); previously we only exposed the added buffers
in the virtqueue_kick() call.  This means we don't need a memory
barrier in virtqueue_add_buf(), but it reduces concurrency as the
device (ie. host) can't see the buffers until the kick.

In the unusual (but now possible) case where a driver does add_buf()
and get_buf() without doing a kick, we do need to insert one before
our counter wraps.  Otherwise we could wrap num_added, and later on
not realize that we have passed the marker where we should have
kicked.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/virtio/virtio_ring.c