Skip to contentSkip to conversation

gpio: virtio: remove timeout

PATCH Applied Vincent Whitchurch 4 participants 6 messages Dec 20, 2021 – Dec 21, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: virtio: remove timeout

The driver imposes an arbitrary one second timeout on virtio requests, but the specification doesn't prevent the virtio device from taking longer to process requests, so remove this timeout to support all systems and device implementations.

Fixes 3a29355a22c0275fe86 ("gpio: Add virtio-gpio driver")
---
 drivers/gpio/gpio-virtio.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpio/gpio-virtio.c +1 -5
index 84f96b78f32a..9f4941bc5760 100644
@@ -100,11 +100,7 @@ static int _virtio_gpio_req(struct virtio_gpio *vgpio, u16 type, u16 gpio,
 	virtqueue_kick(vgpio->request_vq);
 	mutex_unlock(&vgpio->lock);
 
-	if (!wait_for_completion_timeout(&line->completion, HZ)) {
-		dev_err(dev, "GPIO operation timed out\n");
-		ret = -ETIMEDOUT;
-		goto out;
-	}
+	wait_for_completion(&line->completion);
 
 	if (unlikely(res->status != VIRTIO_GPIO_STATUS_OK)) {
 		dev_err(dev, "GPIO request failed: %d\n", gpio);
Signature · 1 line
2.33.1
#1 lore raw
Quoted 30 lines · Vincent Whitchurch

The driver imposes an arbitrary one second timeout on virtio requests, but the specification doesn't prevent the virtio device from taking longer to process requests, so remove this timeout to support all systems and device implementations.

Fixes 3a29355a22c0275fe86 ("gpio: Add virtio-gpio driver")
---
 drivers/gpio/gpio-virtio.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpio/gpio-virtio.c +1 -6
index 84f96b78f32a..9f4941bc5760 100644
@@ -100,11 +100,7 @@ static int _virtio_gpio_req(struct virtio_gpio *vgpio, u16 type, u16 gpio,
        virtqueue_kick(vgpio->request_vq);
        mutex_unlock(&vgpio->lock);
 
-       if (!wait_for_completion_timeout(&line->completion, HZ)) {
-               dev_err(dev, "GPIO operation timed out\n");
-               ret = -ETIMEDOUT;
-               goto out;
-       }
+       wait_for_completion(&line->completion);
 
        if (unlikely(res->status != VIRTIO_GPIO_STATUS_OK)) {
                dev_err(dev, "GPIO request failed: %d\n", gpio);
--
Quoted 2 lines

2.33.1

My knowledge of virtio is limited, I hope this is not a stupid question.

Does this mean the operation can get stuck indefinitely?

Bart

#2 lore raw
Quoted 37 lines · Bartosz Golaszewski
Quoted 30 lines · Vincent Whitchurch

The driver imposes an arbitrary one second timeout on virtio requests, but the specification doesn't prevent the virtio device from taking longer to process requests, so remove this timeout to support all systems and device implementations.

Fixes 3a29355a22c0275fe86 ("gpio: Add virtio-gpio driver")
---
 drivers/gpio/gpio-virtio.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpio/gpio-virtio.c +1 -6
index 84f96b78f32a..9f4941bc5760 100644
@@ -100,11 +100,7 @@ static int _virtio_gpio_req(struct virtio_gpio *vgpio, u16 type, u16 gpio,
        virtqueue_kick(vgpio->request_vq);
        mutex_unlock(&vgpio->lock);
 
-       if (!wait_for_completion_timeout(&line->completion, HZ)) {
-               dev_err(dev, "GPIO operation timed out\n");
-               ret = -ETIMEDOUT;
-               goto out;
-       }
+       wait_for_completion(&line->completion);
 
        if (unlikely(res->status != VIRTIO_GPIO_STATUS_OK)) {
                dev_err(dev, "GPIO request failed: %d\n", gpio);
--
Quoted 2 lines

2.33.1

My knowledge of virtio is limited, I hope this is not a stupid question.

Quoted 3 lines

Does this mean the operation can get stuck indefinitely?

Bart

Only if the device is broken. which given it's part of the hypervisor, is par for the course.

Signature · 1 line
MST
maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Vincent Whitchurch
Quoted 7 lines · Vincent Whitchurch

The driver imposes an arbitrary one second timeout on virtio requests, but the specification doesn't prevent the virtio device from taking longer to process requests, so remove this timeout to support all systems and device implementations.

Fixes 3a29355a22c0275fe86 ("gpio: Add virtio-gpio driver")
Quoted 23 lines
---
 drivers/gpio/gpio-virtio.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpio/gpio-virtio.c +1 -5
index 84f96b78f32a..9f4941bc5760 100644
@@ -100,11 +100,7 @@ static int _virtio_gpio_req(struct virtio_gpio *vgpio, u16 type, u16 gpio,
 	virtqueue_kick(vgpio->request_vq);
 	mutex_unlock(&vgpio->lock);
 
-	if (!wait_for_completion_timeout(&line->completion, HZ)) {
-		dev_err(dev, "GPIO operation timed out\n");
-		ret = -ETIMEDOUT;
-		goto out;
-	}
+	wait_for_completion(&line->completion);
 
 	if (unlikely(res->status != VIRTIO_GPIO_STATUS_OK)) {
 		dev_err(dev, "GPIO request failed: %d\n", gpio);
Signature · 1 line
2.33.1
Acked-by on v1 1/1
#4 lore raw
In reply to Vincent Whitchurch
Quoted 18 lines · Vincent Whitchurch

The driver imposes an arbitrary one second timeout on virtio requests, but the specification doesn't prevent the virtio device from taking longer to process requests, so remove this timeout to support all systems and device implementations.

Fixes 3a29355a22c0275fe86 ("gpio: Add virtio-gpio driver")
---
 drivers/gpio/gpio-virtio.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpio/gpio-virtio.c +0 -0
index 84f96b78f32a..9f4941bc5760 100644
@@ -100,11 +100,7 @@ static int _virtio_gpio_req(struct virtio_gpio *vgpio, u16 type, u16 gpio,
 	virtqueue_kick(vgpio->request_vq);
 	mutex_unlock(&vgpio->lock);

drivers/gpio/gpio-virtio.c static int _virtio_gpio_req(struct virtio_gpio *vgpio, u16 type, u16 gpio, · line 106

Quoted 10 lines
drivers/gpio/gpio-virtio.c +1 -5
 
-	if (!wait_for_completion_timeout(&line->completion, HZ)) {
-		dev_err(dev, "GPIO operation timed out\n");
-		ret = -ETIMEDOUT;
-		goto out;
-	}
+	wait_for_completion(&line->completion);
 
 	if (unlikely(res->status != VIRTIO_GPIO_STATUS_OK)) {
 		dev_err(dev, "GPIO request failed: %d\n", gpio);
Signature · 1 line
viresh
#5 lore raw
In reply to Vincent Whitchurch
Quoted 30 lines · Vincent Whitchurch

The driver imposes an arbitrary one second timeout on virtio requests, but the specification doesn't prevent the virtio device from taking longer to process requests, so remove this timeout to support all systems and device implementations.

Fixes 3a29355a22c0275fe86 ("gpio: Add virtio-gpio driver")
---
 drivers/gpio/gpio-virtio.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpio/gpio-virtio.c +1 -6
index 84f96b78f32a..9f4941bc5760 100644
@@ -100,11 +100,7 @@ static int _virtio_gpio_req(struct virtio_gpio *vgpio, u16 type, u16 gpio,
        virtqueue_kick(vgpio->request_vq);
        mutex_unlock(&vgpio->lock);
 
-       if (!wait_for_completion_timeout(&line->completion, HZ)) {
-               dev_err(dev, "GPIO operation timed out\n");
-               ret = -ETIMEDOUT;
-               goto out;
-       }
+       wait_for_completion(&line->completion);
 
        if (unlikely(res->status != VIRTIO_GPIO_STATUS_OK)) {
                dev_err(dev, "GPIO request failed: %d\n", gpio);
--
Quoted 2 lines

2.33.1

Applied, thanks!

Bart