Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit b01793c

Browse files
Philip Chengregkh
authored andcommitted
virtio_pmem: Check device status before requesting flush
[ Upstream commit e25fbcd ] If a pmem device is in a bad status, the driver side could wait for host ack forever in virtio_pmem_flush(), causing the system to hang. So add a status check in the beginning of virtio_pmem_flush() to return early if the device is not activated. Signed-off-by: Philip Chen <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Pankaj Gupta <[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent 784744b commit b01793c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/nvdimm/nd_virtio.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ static int virtio_pmem_flush(struct nd_region *nd_region)
4444
unsigned long flags;
4545
int err, err1;
4646

47+
/*
48+
* Don't bother to submit the request to the device if the device is
49+
* not activated.
50+
*/
51+
if (vdev->config->get_status(vdev) & VIRTIO_CONFIG_S_NEEDS_RESET) {
52+
dev_info(&vdev->dev, "virtio pmem device needs a reset\n");
53+
return -EIO;
54+
}
55+
4756
might_sleep();
4857
req_data = kmalloc(sizeof(*req_data), GFP_KERNEL);
4958
if (!req_data)

0 commit comments

Comments
 (0)