Browse Source

Merge pull request #121 from DeathWish5/dev

Bug fix: update VirtQueue.avail.used_event to support VIRTIO_F_EVENT_IDX
Yuekai Jia 1 year ago
parent
commit
61ece509c4
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/queue.rs

+ 8 - 1
src/queue.rs

@@ -530,6 +530,12 @@ impl<H: Hal, const SIZE: usize> VirtQueue<H, SIZE> {
         }
         self.last_used_idx = self.last_used_idx.wrapping_add(1);
 
+        if self.event_idx {
+            unsafe {
+                (*self.avail.as_ptr()).used_event = self.last_used_idx;
+            }
+        }
+
         Ok(len)
     }
 }
@@ -759,7 +765,8 @@ struct AvailRing<const SIZE: usize> {
     /// A driver MUST NOT decrement the idx.
     idx: u16,
     ring: [u16; SIZE],
-    used_event: u16, // unused
+    /// Only used if `VIRTIO_F_EVENT_IDX` is negotiated.
+    used_event: u16,
 }
 
 /// The used ring is where the device returns buffers once it is done with them: