virtio: Clear interrupt status register in virtio-blk
PATCH 1/1 virtio: Clear interrupt status register in virtio-blk
The VRING_AVAIL_F_NO_INTERRUPT flag is a hint that interrupts should be suppressed. It does not guarantee that interrupts will not be raised. Therefore, make sure to clear the interrupt after each virtio-blk read. This avoids a stuck interrupt interfering with the OS loaded later in the boot process.
--- src/virtio-blk.c | 6 ++++++ src/virtio-pci.h | 4 ++++ 2 files changed, 10 insertions(+), 0 deletions(-)
src/virtio-blk.c +6 -0
@@ -62,6 +62,12 @@ virtio_blk_read(struct disk_op_s *op)/* Reclaim virtqueue element */ vring_get_buf (vq,NULL ); + +/* Clear interrupt status register. Avoid leaving interrupts stuck if +* VRING_AVAIL_F_NO_INTERRUPT was ignored and interrupts were raised. +*/ +vp_get_isr (GET_GLOBAL (vdrive_g->ioaddr)); +return status ==VIRTIO_BLK_S_OK ?DISK_RET_SUCCESS :DISK_RET_EBADTRACK ; }
src/virtio-pci.h +4 -0
@@ -71,6 +71,10 @@ static inline void vp_set_status(unsigned int ioaddr, u8 status)outb (status, ioaddr +VIRTIO_PCI_STATUS ); } +static inline u8 vp_get_isr (unsigned int ioaddr) +{ +return inb (ioaddr +VIRTIO_PCI_ISR ); +}static inline void vp_reset (unsigned int ioaddr) {
Signature · 1 line
1.7.1
Quoted 7 lines · Stefan Hajnoczi
The
VRING_AVAIL_F_NO_INTERRUPTflag is a hint that interrupts should be suppressed. It does not guarantee that interrupts will not be raised. Therefore, make sure to clear the interrupt after each virtio-blk read. This avoids a stuck interrupt interfering with the OS loaded later in the boot process.Signed-off-by Stefan Hajnoczi <[email protected]>
Quoted 39 lines
--- src/virtio-blk.c | 6 ++++++ src/virtio-pci.h | 4 ++++ 2 files changed, 10 insertions(+), 0 deletions(-)src/virtio-blk.c +6
-0@@ -62,6 +62,12 @@ virtio_blk_read(struct disk_op_s *op)/* Reclaim virtqueue element */ vring_get_buf (vq,NULL ); + +/* Clear interrupt status register. Avoid leaving interrupts stuck if +* VRING_AVAIL_F_NO_INTERRUPT was ignored and interrupts were raised. +*/ +vp_get_isr (GET_GLOBAL (vdrive_g->ioaddr)); +return status ==VIRTIO_BLK_S_OK ?DISK_RET_SUCCESS :DISK_RET_EBADTRACK ; }src/virtio-pci.h +4
-0@@ -71,6 +71,10 @@ static inline void vp_set_status(unsigned int ioaddr, u8 status)outb (status, ioaddr +VIRTIO_PCI_STATUS ); } +static inline u8 vp_get_isr (unsigned int ioaddr) +{ +return inb (ioaddr +VIRTIO_PCI_ISR ); +}static inline void vp_reset (unsigned int ioaddr) {Signature · 1 line
1.7.1
--
Gleb.
Quoted 7 lines · Stefan Hajnoczi
The
VRING_AVAIL_F_NO_INTERRUPTflag is a hint that interrupts should be suppressed. It does not guarantee that interrupts will not be raised. Therefore, make sure to clear the interrupt after each virtio-blk read. This avoids a stuck interrupt interfering with the OS loaded later in the boot process.Signed-off-by Stefan Hajnoczi <[email protected]>
Thanks. Commit 4e0daae5.
-Kevin