Re: [PATCH] virtio: don't fail on !of_device_is_compatible

From
Guenter Roeck <linux@roeck-us.net>
Date
2021-09-13 20:53:53
Also in
lkml, virtualization
Reply to
Michael S. Tsirkin, 2021-09-13
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 <redacted>
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
quoted hunk ↗ jump to hunk
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
Thread (5 messages) 5 messages, 3 authors, last reply 2021-09-14
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help