[PATCH v2 3/3] virtio_pci: add module param for reset_timeout

Max Gurtovoy
2021-04-08T08:11:27Z

Enable the user to set the time for waiting for successful reset by the
virtio controller. Set the default to 180 seconds.

Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
---
drivers/virtio/virtio_pci_common.c | 5 +++++
drivers/virtio/virtio_pci_common.h | 2 ++
drivers/virtio/virtio_pci_modern.c | 3 ++-
3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index 222d630c41fc..3a4c57839ed8 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -24,6 +24,11 @@ MODULE_PARM_DESC(force_legacy,
"Force legacy mode for transitional virtio 1 devices");
#endif

+unsigned int reset_timeout = 180;
+module_param_named(reset_timeout, reset_timeout, uint, 0644);
+MODULE_PARM_DESC(reset_timeout,
+ "timeout in seconds for reset virtio device operation");
+
/* wait for pending irq handlers */
void vp_synchronize_vectors(struct virtio_device *vdev)
{
diff --git a/drivers/virtio/virtio_pci_common.h b/drivers/virtio/virtio_pci_common.h
index beec047a8f8d..4760cdf74961 100644
--- a/drivers/virtio/virtio_pci_common.h
+++ b/drivers/virtio/virtio_pci_common.h
@@ -29,6 +29,8 @@
#include <linux/highmem.h>
#include <linux/spinlock.h>

+extern unsigned int reset_timeout;
+
struct virtio_pci_vq_info {
/* the actual virtqueue */
struct virtqueue *vq;
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index dcee616e8d21..811fc1719d8c 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -162,7 +162,8 @@ static int vp_reset(struct virtio_device *vdev)
{
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
struct virtio_pci_modern_device *mdev = &vp_dev->mdev;
- unsigned long timeout = jiffies + msecs_to_jiffies(180000);
+ unsigned long timeout = jiffies +
+ msecs_to_jiffies(reset_timeout * 1000);

/* 0 status means a reset. */
vp_modern_set_status(mdev, 0);
--
2.25.4