Skip to contentSkip to conversation

virtio: don't fail on !of_device_is_compatible

PATCH In review Michael S. Tsirkin 4 participants 6 messages Sep 13, 2021 – Sep 14, 2021 virtio core

lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

PATCH 1/1 virtio: don't fail on !of_device_is_compatible

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")
Cc Arnd Bergmann <[email protected]>
Cc Viresh Kumar <[email protected]>

---

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

 drivers/virtio/virtio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/virtio/virtio.c +6 -1
index c46cc1fbc7ae..19a70a2361b4 100644
@@ -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;
 	}
 
Signature · 1 line
MST
Reviewed-by on v1 1/1
#1 lore raw

Sorry about HTML (From phone)..

Quoted 38 lines · On Mon, 13 Sep 2021, 16:17 Michael S. Tsirkin, <[email protected]> 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")
Cc Arnd Bergmann <[email protected]>
Cc Viresh Kumar <[email protected]>

---

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

 drivers/virtio/virtio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/virtio/virtio.c +6 -1
index c46cc1fbc7ae..19a70a2361b4 100644
@@ -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;
Quoted 2 lines
        }
Quoted 1 line

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

author maintainer
#2 lore raw
In reply to Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin

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.

Quoted 6 lines
Fixes 694a1116b405 ("virtio: Bind virtio device to device-tree node")
Cc Arnd Bergmann <[email protected]>
Cc Viresh Kumar <[email protected]>

---

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

Quoted 26 lines

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

 drivers/virtio/virtio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/virtio/virtio.c +6 -1
index c46cc1fbc7ae..19a70a2361b4 100644
@@ -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;
 	}
 
Signature · 1 line
MST
Tested-by on v1 1/1
#4 lore raw
In reply to Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin

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.

Quoted 6 lines
Fixes 694a1116b405 ("virtio: Bind virtio device to device-tree node")
Cc Arnd Bergmann <[email protected]>
Cc Viresh Kumar <[email protected]>

---

This patch also fixes a similar problem seen with sparc64.

Guenter

Quoted 28 lines

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

 drivers/virtio/virtio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/virtio/virtio.c +6 -1
index c46cc1fbc7ae..19a70a2361b4 100644
@@ -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;
 	}
 
Signature · 1 line
MST

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#3 lore raw
In reply to Michael S. Tsirkin
Quoted 16 lines · Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin

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.

Quoted 6 lines
Fixes 694a1116b405 ("virtio: Bind virtio device to device-tree node")
Cc Arnd Bergmann <[email protected]>
Cc Viresh Kumar <[email protected]>

---

Quoted 3 lines

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

Quoted 28 lines
Quoted 27 lines

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

 drivers/virtio/virtio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/virtio/virtio.c +6 -1
index c46cc1fbc7ae..19a70a2361b4 100644
@@ -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;
 	}
 
Signature · 1 line
MST
Acked-by on v1 1/1
#5 lore raw
In reply to Michael S. Tsirkin
Quoted 28 lines · Michael S. Tsirkin

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")
Cc Arnd Bergmann <[email protected]>
Cc Viresh Kumar <[email protected]>

---

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

 drivers/virtio/virtio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/virtio/virtio.c +0 -0
index c46cc1fbc7ae..19a70a2361b4 100644
@@ -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));
 

drivers/virtio/virtio.c static int virtio_device_of_init(struct virtio_device *dev) · line 358

Quoted 10 lines
drivers/virtio/virtio.c +6 -1
+       /*
+        * 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;
        }
Quoted 4 lines
drivers/virtio/virtio.c +0 -1
--

MST