linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio: don't fail on !of_device_is_compatible
@ 2021-09-13 10:47 Michael S. Tsirkin
  2021-09-13 20:23 ` Michael S. Tsirkin
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2021-09-13 10:47 UTC (permalink / raw)
  To: Alexey Kardashevskiy
  Cc: Jason Wang, Michael S. Tsirkin, Rob Herring, Arnd Bergmann,
	Jean-Philippe Brucker, Viresh Kumar, Vincent Guittot, Bill Mills,
	Alex Bennée, Enrico Weigelt, metux IT consult, Jie Deng,
	devicetree, linux-kernel, virtualization, Arnd Bergmann

A recent change checking of_device_is_compatible on probe broke some
powerpc/pseries setups. Apparently there virtio devices do not have a
"compatible" property - they are matched by PCI vendor/device ids.

Let's just skip of_node setup but proceed with initialization like we
did previously.

Fixes: 694a1116b405 ("virtio: Bind virtio device to device-tree node")
Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

Arnd could you help review this pls? Viresh is on vacation.

 drivers/virtio/virtio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index c46cc1fbc7ae..19a70a2361b4 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -347,8 +347,13 @@ static int virtio_device_of_init(struct virtio_device *dev)
 	ret = snprintf(compat, sizeof(compat), "virtio,device%x", dev->id.device);
 	BUG_ON(ret >= sizeof(compat));
 
+	/*
+	 * On powerpc/pseries virtio devices are PCI devices so PCI
+	 * vendor/device ids play the role of the "compatible" property.
+	 * Simply don't init of_node in this case.
+	 */
 	if (!of_device_is_compatible(np, compat)) {
-		ret = -EINVAL;
+		ret = 0;
 		goto out;
 	}
 
-- 
MST


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

* Re: [PATCH] virtio: don't fail on !of_device_is_compatible
  2021-09-13 10:47 [PATCH] virtio: don't fail on !of_device_is_compatible Michael S. Tsirkin
@ 2021-09-13 20:23 ` Michael S. Tsirkin
  2021-09-13 20:54   ` Guenter Roeck
  2021-09-13 20:53 ` Guenter Roeck
  2021-09-14  2:50 ` Jason Wang
  2 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2021-09-13 20:23 UTC (permalink / raw)
  To: Alexey Kardashevskiy
  Cc: Jason Wang, Rob Herring, Arnd Bergmann, Jean-Philippe Brucker,
	Viresh Kumar, Vincent Guittot, Bill Mills, Alex Bennée,
	Enrico Weigelt, metux IT consult, Jie Deng, devicetree,
	linux-kernel, virtualization, Arnd Bergmann, Guenter Roeck

On Mon, Sep 13, 2021 at 06:47:52AM -0400, Michael S. Tsirkin wrote:
> A recent change checking of_device_is_compatible on probe broke some
> powerpc/pseries setups. Apparently there virtio devices do not have a
> "compatible" property - they are matched by PCI vendor/device ids.
> 
> Let's just skip of_node setup but proceed with initialization like we
> did previously.
> 
> Fixes: 694a1116b405 ("virtio: Bind virtio device to device-tree node")
> Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---


Guenter could you take a look at this patch pls? Does it help?



> Arnd could you help review this pls? Viresh is on vacation.
> 
>  drivers/virtio/virtio.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index c46cc1fbc7ae..19a70a2361b4 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -347,8 +347,13 @@ static int virtio_device_of_init(struct virtio_device *dev)
>  	ret = snprintf(compat, sizeof(compat), "virtio,device%x", dev->id.device);
>  	BUG_ON(ret >= sizeof(compat));
>  
> +	/*
> +	 * On powerpc/pseries virtio devices are PCI devices so PCI
> +	 * vendor/device ids play the role of the "compatible" property.
> +	 * Simply don't init of_node in this case.
> +	 */
>  	if (!of_device_is_compatible(np, compat)) {
> -		ret = -EINVAL;
> +		ret = 0;
>  		goto out;
>  	}
>  
> -- 
> MST


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

* Re: [PATCH] virtio: don't fail on !of_device_is_compatible
  2021-09-13 10:47 [PATCH] virtio: don't fail on !of_device_is_compatible Michael S. Tsirkin
  2021-09-13 20:23 ` Michael S. Tsirkin
@ 2021-09-13 20:53 ` Guenter Roeck
  2021-09-14  2:50 ` Jason Wang
  2 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2021-09-13 20:53 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Alexey Kardashevskiy, Jason Wang, Rob Herring, Arnd Bergmann,
	Jean-Philippe Brucker, Viresh Kumar, Vincent Guittot, Bill Mills,
	Alex Bennée, Enrico Weigelt, metux IT consult, Jie Deng,
	devicetree, linux-kernel, virtualization, Arnd Bergmann

On Mon, Sep 13, 2021 at 06:47:46AM -0400, Michael S. Tsirkin wrote:
> A recent change checking of_device_is_compatible on probe broke some
> powerpc/pseries setups. Apparently there virtio devices do not have a
> "compatible" property - they are matched by PCI vendor/device ids.
> 
> Let's just skip of_node setup but proceed with initialization like we
> did previously.
> 
> Fixes: 694a1116b405 ("virtio: Bind virtio device to device-tree node")
> Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---

This patch also fixes a similar problem seen with sparc64.

Tested-by: Guenter Roeck <linux@roeck-us.net>

Guenter

> 
> Arnd could you help review this pls? Viresh is on vacation.
> 
>  drivers/virtio/virtio.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index c46cc1fbc7ae..19a70a2361b4 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -347,8 +347,13 @@ static int virtio_device_of_init(struct virtio_device *dev)
>  	ret = snprintf(compat, sizeof(compat), "virtio,device%x", dev->id.device);
>  	BUG_ON(ret >= sizeof(compat));
>  
> +	/*
> +	 * On powerpc/pseries virtio devices are PCI devices so PCI
> +	 * vendor/device ids play the role of the "compatible" property.
> +	 * Simply don't init of_node in this case.
> +	 */
>  	if (!of_device_is_compatible(np, compat)) {
> -		ret = -EINVAL;
> +		ret = 0;
>  		goto out;
>  	}
>  
> -- 
> MST
> 

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

* Re: [PATCH] virtio: don't fail on !of_device_is_compatible
  2021-09-13 20:23 ` Michael S. Tsirkin
@ 2021-09-13 20:54   ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2021-09-13 20:54 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Alexey Kardashevskiy, Jason Wang, Rob Herring, Arnd Bergmann,
	Jean-Philippe Brucker, Viresh Kumar, Vincent Guittot, Bill Mills,
	Alex Bennée, Enrico Weigelt, metux IT consult, Jie Deng,
	devicetree, linux-kernel, virtualization, Arnd Bergmann

On Mon, Sep 13, 2021 at 04:23:57PM -0400, Michael S. Tsirkin wrote:
> On Mon, Sep 13, 2021 at 06:47:52AM -0400, Michael S. Tsirkin wrote:
> > A recent change checking of_device_is_compatible on probe broke some
> > powerpc/pseries setups. Apparently there virtio devices do not have a
> > "compatible" property - they are matched by PCI vendor/device ids.
> > 
> > Let's just skip of_node setup but proceed with initialization like we
> > did previously.
> > 
> > Fixes: 694a1116b405 ("virtio: Bind virtio device to device-tree node")
> > Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> 
> 
> Guenter could you take a look at this patch pls? Does it help?
> 
> 
I confirmed that this patch fixes the problem. I replied in that thread.

Thanks,
Guenter

> 
> > Arnd could you help review this pls? Viresh is on vacation.
> > 
> >  drivers/virtio/virtio.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> > index c46cc1fbc7ae..19a70a2361b4 100644
> > --- a/drivers/virtio/virtio.c
> > +++ b/drivers/virtio/virtio.c
> > @@ -347,8 +347,13 @@ static int virtio_device_of_init(struct virtio_device *dev)
> >  	ret = snprintf(compat, sizeof(compat), "virtio,device%x", dev->id.device);
> >  	BUG_ON(ret >= sizeof(compat));
> >  
> > +	/*
> > +	 * On powerpc/pseries virtio devices are PCI devices so PCI
> > +	 * vendor/device ids play the role of the "compatible" property.
> > +	 * Simply don't init of_node in this case.
> > +	 */
> >  	if (!of_device_is_compatible(np, compat)) {
> > -		ret = -EINVAL;
> > +		ret = 0;
> >  		goto out;
> >  	}
> >  
> > -- 
> > MST
> 

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

* Re: [PATCH] virtio: don't fail on !of_device_is_compatible
  2021-09-13 10:47 [PATCH] virtio: don't fail on !of_device_is_compatible Michael S. Tsirkin
  2021-09-13 20:23 ` Michael S. Tsirkin
  2021-09-13 20:53 ` Guenter Roeck
@ 2021-09-14  2:50 ` Jason Wang
  2 siblings, 0 replies; 5+ messages in thread
From: Jason Wang @ 2021-09-14  2:50 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Alexey Kardashevskiy, Rob Herring, Arnd Bergmann,
	Jean-Philippe Brucker, Viresh Kumar, Vincent Guittot, Bill Mills,
	Alex Bennée, Enrico Weigelt, metux IT consult, Jie Deng,
	devicetree, linux-kernel, virtualization, Arnd Bergmann

On Mon, Sep 13, 2021 at 6:47 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> A recent change checking of_device_is_compatible on probe broke some
> powerpc/pseries setups. Apparently there virtio devices do not have a
> "compatible" property - they are matched by PCI vendor/device ids.
>
> Let's just skip of_node setup but proceed with initialization like we
> did previously.
>
> Fixes: 694a1116b405 ("virtio: Bind virtio device to device-tree node")
> Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Arnd could you help review this pls? Viresh is on vacation.
>
>  drivers/virtio/virtio.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index c46cc1fbc7ae..19a70a2361b4 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -347,8 +347,13 @@ static int virtio_device_of_init(struct virtio_device *dev)
>         ret = snprintf(compat, sizeof(compat), "virtio,device%x", dev->id.device);
>         BUG_ON(ret >= sizeof(compat));
>
> +       /*
> +        * On powerpc/pseries virtio devices are PCI devices so PCI
> +        * vendor/device ids play the role of the "compatible" property.
> +        * Simply don't init of_node in this case.
> +        */
>         if (!of_device_is_compatible(np, compat)) {
> -               ret = -EINVAL;
> +               ret = 0;
>                 goto out;
>         }

Acked-by: Jason Wang <jasowang@redhat.com>

>
> --
> MST
>


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

end of thread, other threads:[~2021-09-14  2:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 10:47 [PATCH] virtio: don't fail on !of_device_is_compatible Michael S. Tsirkin
2021-09-13 20:23 ` Michael S. Tsirkin
2021-09-13 20:54   ` Guenter Roeck
2021-09-13 20:53 ` Guenter Roeck
2021-09-14  2:50 ` Jason Wang

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).