Merge tag 'powerpc-5.15-5' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[platform/kernel/linux-starfive.git] / drivers / virtio / virtio.c
index 0a5b540..236081a 100644 (file)
@@ -239,6 +239,17 @@ static int virtio_dev_probe(struct device *_d)
                driver_features_legacy = driver_features;
        }
 
+       /*
+        * Some devices detect legacy solely via F_VERSION_1. Write
+        * F_VERSION_1 to force LE config space accesses before FEATURES_OK for
+        * these when needed.
+        */
+       if (drv->validate && !virtio_legacy_is_little_endian()
+                         && device_features & BIT_ULL(VIRTIO_F_VERSION_1)) {
+               dev->features = BIT_ULL(VIRTIO_F_VERSION_1);
+               dev->config->finalize_features(dev);
+       }
+
        if (device_features & (1ULL << VIRTIO_F_VERSION_1))
                dev->features = driver_features & device_features;
        else