浏览代码

Notify device after adding buffers to available ring.

Andrew Walbran 2 年之前
父节点
当前提交
b559de30f3
共有 2 个文件被更改,包括 9 次插入0 次删除
  1. 3 0
      src/device/console.rs
  2. 6 0
      src/device/input.rs

+ 3 - 0
src/device/console.rs

@@ -119,6 +119,9 @@ impl<H: Hal, T: Transport> VirtIOConsole<'_, H, T> {
             // Safe because the buffer lasts at least as long as the queue, and there are no other
             // outstanding requests using the buffer.
             self.receive_token = Some(unsafe { self.receiveq.add(&[], &[self.queue_buf_rx]) }?);
+            if self.receiveq.should_notify() {
+                self.transport.notify(QUEUE_RECEIVEQ_PORT_0);
+            }
         }
         Ok(())
     }

+ 6 - 0
src/device/input.rs

@@ -45,6 +45,9 @@ impl<H: Hal, T: Transport> VirtIOInput<H, T> {
             let token = unsafe { event_queue.add(&[], &[event.as_bytes_mut()])? };
             assert_eq!(token, i as u16);
         }
+        if event_queue.should_notify() {
+            transport.notify(QUEUE_EVENT);
+        }
 
         transport.finish_init();
 
@@ -76,6 +79,9 @@ impl<H: Hal, T: Transport> VirtIOInput<H, T> {
                 // the list of free descriptors in the queue, so `add` reuses the descriptor which
                 // was just freed by `pop_used`.
                 assert_eq!(new_token, token);
+                if self.event_queue.should_notify() {
+                    self.transport.notify(QUEUE_EVENT);
+                }
                 return Some(*event);
             }
         }