linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: virtio: remove timeout
@ 2021-12-20 13:06 Vincent Whitchurch
  2021-12-20 14:54 ` Bartosz Golaszewski
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Vincent Whitchurch @ 2021-12-20 13:06 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult, Viresh Kumar, Linus Walleij,
	Bartosz Golaszewski
  Cc: kernel, mst, Vincent Whitchurch, Bartosz Golaszewski,
	Viresh Kumar, linux-gpio, virtualization, linux-kernel

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")
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
 drivers/gpio/gpio-virtio.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
index 84f96b78f32a..9f4941bc5760 100644
--- a/drivers/gpio/gpio-virtio.c
+++ b/drivers/gpio/gpio-virtio.c
@@ -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);
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] gpio: virtio: remove timeout
  2021-12-20 13:06 [PATCH] gpio: virtio: remove timeout Vincent Whitchurch
@ 2021-12-20 14:54 ` Bartosz Golaszewski
  2021-12-20 15:35   ` Michael S. Tsirkin
  2021-12-20 15:35 ` Michael S. Tsirkin
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Bartosz Golaszewski @ 2021-12-20 14:54 UTC (permalink / raw)
  To: Vincent Whitchurch
  Cc: Enrico Weigelt, metux IT consult, Viresh Kumar, Linus Walleij,
	kernel, Michael S . Tsirkin, Bartosz Golaszewski, Viresh Kumar,
	open list:GPIO SUBSYSTEM, virtualization,
	Linux Kernel Mailing List

On Mon, Dec 20, 2021 at 2:07 PM Vincent Whitchurch
<vincent.whitchurch@axis.com> wrote:
>
> 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")
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> ---
>  drivers/gpio/gpio-virtio.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
> index 84f96b78f32a..9f4941bc5760 100644
> --- a/drivers/gpio/gpio-virtio.c
> +++ b/drivers/gpio/gpio-virtio.c
> @@ -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);
> --
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gpio: virtio: remove timeout
  2021-12-20 14:54 ` Bartosz Golaszewski
@ 2021-12-20 15:35   ` Michael S. Tsirkin
  0 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2021-12-20 15:35 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Vincent Whitchurch, Enrico Weigelt, metux IT consult,
	Viresh Kumar, Linus Walleij, kernel, Bartosz Golaszewski,
	Viresh Kumar, open list:GPIO SUBSYSTEM, virtualization,
	Linux Kernel Mailing List

On Mon, Dec 20, 2021 at 03:54:56PM +0100, Bartosz Golaszewski wrote:
> On Mon, Dec 20, 2021 at 2:07 PM Vincent Whitchurch
> <vincent.whitchurch@axis.com> wrote:
> >
> > 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")
> > Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> > ---
> >  drivers/gpio/gpio-virtio.c | 6 +-----
> >  1 file changed, 1 insertion(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
> > index 84f96b78f32a..9f4941bc5760 100644
> > --- a/drivers/gpio/gpio-virtio.c
> > +++ b/drivers/gpio/gpio-virtio.c
> > @@ -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);
> > --
> > 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

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

-- 
MST


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gpio: virtio: remove timeout
  2021-12-20 13:06 [PATCH] gpio: virtio: remove timeout Vincent Whitchurch
  2021-12-20 14:54 ` Bartosz Golaszewski
@ 2021-12-20 15:35 ` Michael S. Tsirkin
  2021-12-21  4:26 ` Viresh Kumar
  2021-12-21 15:23 ` Bartosz Golaszewski
  3 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2021-12-20 15:35 UTC (permalink / raw)
  To: Vincent Whitchurch
  Cc: Enrico Weigelt, metux IT consult, Viresh Kumar, Linus Walleij,
	Bartosz Golaszewski, kernel, Bartosz Golaszewski, Viresh Kumar,
	linux-gpio, virtualization, linux-kernel

On Mon, Dec 20, 2021 at 02:06:56PM +0100, Vincent Whitchurch wrote:
> 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")
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  drivers/gpio/gpio-virtio.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
> index 84f96b78f32a..9f4941bc5760 100644
> --- a/drivers/gpio/gpio-virtio.c
> +++ b/drivers/gpio/gpio-virtio.c
> @@ -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);
> -- 
> 2.33.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gpio: virtio: remove timeout
  2021-12-20 13:06 [PATCH] gpio: virtio: remove timeout Vincent Whitchurch
  2021-12-20 14:54 ` Bartosz Golaszewski
  2021-12-20 15:35 ` Michael S. Tsirkin
@ 2021-12-21  4:26 ` Viresh Kumar
  2021-12-21 15:23 ` Bartosz Golaszewski
  3 siblings, 0 replies; 6+ messages in thread
From: Viresh Kumar @ 2021-12-21  4:26 UTC (permalink / raw)
  To: Vincent Whitchurch
  Cc: Enrico Weigelt, metux IT consult, Viresh Kumar, Linus Walleij,
	Bartosz Golaszewski, kernel, mst, Bartosz Golaszewski,
	linux-gpio, virtualization, linux-kernel

On 20-12-21, 14:06, Vincent Whitchurch wrote:
> 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")
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> ---
>  drivers/gpio/gpio-virtio.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
> index 84f96b78f32a..9f4941bc5760 100644
> --- a/drivers/gpio/gpio-virtio.c
> +++ b/drivers/gpio/gpio-virtio.c
> @@ -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);

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gpio: virtio: remove timeout
  2021-12-20 13:06 [PATCH] gpio: virtio: remove timeout Vincent Whitchurch
                   ` (2 preceding siblings ...)
  2021-12-21  4:26 ` Viresh Kumar
@ 2021-12-21 15:23 ` Bartosz Golaszewski
  3 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2021-12-21 15:23 UTC (permalink / raw)
  To: Vincent Whitchurch
  Cc: Enrico Weigelt, metux IT consult, Viresh Kumar, Linus Walleij,
	kernel, Michael S . Tsirkin, Bartosz Golaszewski, Viresh Kumar,
	open list:GPIO SUBSYSTEM, virtualization,
	Linux Kernel Mailing List

On Mon, Dec 20, 2021 at 2:07 PM Vincent Whitchurch
<vincent.whitchurch@axis.com> wrote:
>
> 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")
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> ---
>  drivers/gpio/gpio-virtio.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
> index 84f96b78f32a..9f4941bc5760 100644
> --- a/drivers/gpio/gpio-virtio.c
> +++ b/drivers/gpio/gpio-virtio.c
> @@ -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);
> --
> 2.33.1
>

Applied, thanks!

Bart

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-12-21 15:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20 13:06 [PATCH] gpio: virtio: remove timeout Vincent Whitchurch
2021-12-20 14:54 ` Bartosz Golaszewski
2021-12-20 15:35   ` Michael S. Tsirkin
2021-12-20 15:35 ` Michael S. Tsirkin
2021-12-21  4:26 ` Viresh Kumar
2021-12-21 15:23 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).