Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio-pci library: introduce vp_modern_get_driver_features()

This patch introduce a helper to get driver/guest features from the
device.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20210602021536.39525-3-jasowang@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eli Cohen <elic@nvidia.com>

authored by

Jason Wang and committed by
Michael S. Tsirkin
0140b3d0 530a5678

+22
+21
drivers/virtio/virtio_pci_modern_dev.c
··· 384 384 EXPORT_SYMBOL_GPL(vp_modern_get_features); 385 385 386 386 /* 387 + * vp_modern_get_driver_features - get driver features from device 388 + * @mdev: the modern virtio-pci device 389 + * 390 + * Returns the driver features read from the device 391 + */ 392 + u64 vp_modern_get_driver_features(struct virtio_pci_modern_device *mdev) 393 + { 394 + struct virtio_pci_common_cfg __iomem *cfg = mdev->common; 395 + 396 + u64 features; 397 + 398 + vp_iowrite32(0, &cfg->guest_feature_select); 399 + features = vp_ioread32(&cfg->guest_feature); 400 + vp_iowrite32(1, &cfg->guest_feature_select); 401 + features |= ((u64)vp_ioread32(&cfg->guest_feature) << 32); 402 + 403 + return features; 404 + } 405 + EXPORT_SYMBOL_GPL(vp_modern_get_driver_features); 406 + 407 + /* 387 408 * vp_modern_set_features - set features to device 388 409 * @mdev: the modern virtio-pci device 389 410 * @features: the features set to device
+1
include/linux/virtio_pci_modern.h
··· 79 79 } 80 80 81 81 u64 vp_modern_get_features(struct virtio_pci_modern_device *mdev); 82 + u64 vp_modern_get_driver_features(struct virtio_pci_modern_device *mdev); 82 83 void vp_modern_set_features(struct virtio_pci_modern_device *mdev, 83 84 u64 features); 84 85 u32 vp_modern_generation(struct virtio_pci_modern_device *mdev);