Re: [PATCH v4 net-next 2/8] virtio_pci_modern: allow configuring extended features
From: Paolo Abeni <pabeni@redhat.com>
Date: 2025-06-19 14:56:37
On 6/18/25 4:27 AM, Jason Wang wrote:
On Wed, Jun 18, 2025 at 12:12 AM Paolo Abeni [off-list ref] wrote:quoted
/* - * vp_modern_get_features - get features from device + * vp_modern_get_extended_features - get features from device * @mdev: the modern virtio-pci device + * @features: the features array to be filled * - * Returns the features read from the device + * Fill the specified features array with the features read from the device */ -u64 vp_modern_get_features(struct virtio_pci_modern_device *mdev) +void vp_modern_get_extended_features(struct virtio_pci_modern_device *mdev, + u64 *features) { struct virtio_pci_common_cfg __iomem *cfg = mdev->common; + int i; - u64 features; + virtio_features_zero(features); + for (i = 0; i < VIRTIO_FEATURES_WORDS; i++) { + u64 cur; - vp_iowrite32(0, &cfg->device_feature_select); - features = vp_ioread32(&cfg->device_feature); - vp_iowrite32(1, &cfg->device_feature_select); - features |= ((u64)vp_ioread32(&cfg->device_feature) << 32); - - return features; + vp_iowrite32(i, &cfg->device_feature_select); + cur = vp_ioread32(&cfg->device_feature); + features[i >> 1] |= cur << (32 * (i & 1));Nit: why not simply cast features to u32 * then everything is simplified.
I can be (and usually I am) low on coffee, but I think that will work only for BE architectures. /P