]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
vdpa/mlx5: update mlx_features with driver state check
authorCindy Lu <lulu@redhat.com>
Mon, 26 Jan 2026 09:45:36 +0000 (17:45 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 4 Feb 2026 19:13:43 +0000 (14:13 -0500)
Add logic in mlx5_vdpa_set_attr() to ensure the VIRTIO_NET_F_MAC
feature bit is properly set only when the device is not yet in
the DRIVER_OK (running) state.

This makes the MAC address visible in the output of:

 vdpa dev config show -jp

when the device is created without an initial MAC address.

Signed-off-by: Cindy Lu <lulu@redhat.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20260126094848.9601-2-lulu@redhat.com>

drivers/vdpa/mlx5/net/mlx5_vnet.c

index 44062e9d68f0061cf999767aaf53ae82f1d75c70..a02f34d8f0fe3b81620b3e26b98aef4ccf6beffb 100644 (file)
@@ -4046,7 +4046,7 @@ static int mlx5_vdpa_set_attr(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *
        struct mlx5_vdpa_dev *mvdev;
        struct mlx5_vdpa_net *ndev;
        struct mlx5_core_dev *mdev;
-       int err = -EOPNOTSUPP;
+       int err = 0;
 
        mvdev = to_mvdev(dev);
        ndev = to_mlx5_vdpa_ndev(mvdev);
@@ -4054,13 +4054,22 @@ static int mlx5_vdpa_set_attr(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *
        config = &ndev->config;
 
        down_write(&ndev->reslock);
-       if (add_config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)) {
+
+       if (add_config->mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MACADDR)) {
+               if (!(ndev->mvdev.status & VIRTIO_CONFIG_S_DRIVER_OK)) {
+                       ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_NET_F_MAC);
+               } else {
+                       mlx5_vdpa_warn(mvdev, "device running, skip updating MAC\n");
+                       err = -EBUSY;
+                       goto out;
+               }
                pfmdev = pci_get_drvdata(pci_physfn(mdev->pdev));
                err = mlx5_mpfs_add_mac(pfmdev, config->mac);
                if (!err)
                        ether_addr_copy(config->mac, add_config->net.mac);
        }
 
+out:
        up_write(&ndev->reslock);
        return err;
 }