All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Vlad Dumitrescu <vdumitrescu@nvidia.com>
Cc: linux-rdma@vger.kernel.org
Subject: [bug report] net/mlx5: Implement devlink total_vfs parameter
Date: Fri, 12 Sep 2025 15:47:54 +0300	[thread overview]
Message-ID: <aMQWenzpdjhAX4fm@stanley.mountain> (raw)

Hello Vlad Dumitrescu,

Commit a4c49611cf4f ("net/mlx5: Implement devlink total_vfs
parameter") from Sep 6, 2025 (linux-next), leads to the following
Smatch static checker warning:

	drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c:494 mlx5_devlink_total_vfs_set()
	warn: duplicate check 'per_pf_support' (previous on line 479)

drivers/net/ethernet/mellanox/mlx5/core/lib/nv_param.c
    455 static int mlx5_devlink_total_vfs_set(struct devlink *devlink, u32 id,
    456                                       struct devlink_param_gset_ctx *ctx,
    457                                       struct netlink_ext_ack *extack)
    458 {
    459         struct mlx5_core_dev *dev = devlink_priv(devlink);
    460         u32 mnvda[MLX5_ST_SZ_DW(mnvda_reg)];
    461         bool per_pf_support;
    462         void *data;
    463         int err;
    464 
    465         err = mlx5_nv_param_read_global_pci_cap(dev, mnvda, sizeof(mnvda));
    466         if (err) {
    467                 NL_SET_ERR_MSG_MOD(extack, "Failed to read global pci cap");
    468                 return err;
    469         }
    470 
    471         data = MLX5_ADDR_OF(mnvda_reg, mnvda, configuration_item_data);
    472         if (!MLX5_GET(nv_global_pci_cap, data, sriov_support)) {
    473                 NL_SET_ERR_MSG_MOD(extack, "Not configurable on this device");
    474                 return -EOPNOTSUPP;
    475         }
    476 
    477         per_pf_support = MLX5_GET(nv_global_pci_cap, data,
    478                                   per_pf_total_vf_supported);
    479         if (!per_pf_support) {
    480                 /* We don't allow global SRIOV setting on per PF devlink */
    481                 NL_SET_ERR_MSG_MOD(extack,
    482                                    "SRIOV is not per PF on this device");
    483                 return -EOPNOTSUPP;

!per_pf_support is not supported.

    484         }
    485 
    486         memset(mnvda, 0, sizeof(mnvda));
    487         err = mlx5_nv_param_read_global_pci_conf(dev, mnvda, sizeof(mnvda));
    488         if (err)
    489                 return err;
    490 
    491         MLX5_SET(nv_global_pci_conf, data, sriov_valid, 1);
    492         MLX5_SET(nv_global_pci_conf, data, per_pf_total_vf, per_pf_support);
    493 
--> 494         if (!per_pf_support) {
    495                 MLX5_SET(nv_global_pci_conf, data, total_vfs, ctx->val.vu32);
    496                 return mlx5_nv_param_write(dev, mnvda, sizeof(mnvda));

Dead code.

    497         }
    498 
    499         /* SRIOV is per PF */
    500         err = mlx5_nv_param_write(dev, mnvda, sizeof(mnvda));
    501         if (err)
    502                 return err;
    503 
    504         memset(mnvda, 0, sizeof(mnvda));
    505         err = mlx5_nv_param_read_per_host_pf_conf(dev, mnvda, sizeof(mnvda));
    506         if (err)
    507                 return err;
    508 
    509         data = MLX5_ADDR_OF(mnvda_reg, mnvda, configuration_item_data);
    510         MLX5_SET(nv_pf_pci_conf, data, total_vf, ctx->val.vu32);
    511         return mlx5_nv_param_write(dev, mnvda, sizeof(mnvda));
    512 }

regards,
dan carpenter

             reply	other threads:[~2025-09-12 12:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-12 12:47 Dan Carpenter [this message]
2025-09-14 17:04 ` [bug report] net/mlx5: Implement devlink total_vfs parameter Vlad Dumitrescu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aMQWenzpdjhAX4fm@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=vdumitrescu@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.