From: Bjorn Helgaas <helgaas@kernel.org>
To: qinyuntan <qinyuntan@linux.alibaba.com>
Cc: Christoph Hellwig <hch@lst.de>, Keith Busch <kbusch@kernel.org>,
Jens Axboe <axboe@kernel.dk>, Sagi Grimberg <sagi@grimberg.me>,
linux-nvme@lists.infradead.org,
Xunlei Pang <xlpang@linux.alibaba.com>,
Guixin Liu <kanie@linux.alibaba.com>,
oliver.yang@linux.alibaba.com,
Guanghui Feng <guanghuifeng@linux.alibaba.com>,
Bjorn Helgaas <bhelgaas@google.com>,
linux-pci@vger.kernel.org
Subject: Re: [PATCH V1] nvme-pci: disable SR-IOV VFs on driver unbind
Date: Fri, 6 Feb 2026 16:28:26 -0600 [thread overview]
Message-ID: <20260206222826.GA98751@bhelgaas> (raw)
In-Reply-To: <88437e1a-2df0-41e6-a58f-dcc68d4458bc@linux.alibaba.com>
On Fri, Jan 30, 2026 at 12:53:25PM +0800, qinyuntan wrote:
> Hi All,
>
> Thank you all for the insightful discussion!
>
> I agree with Leon's point that not all devices are created equal when it
> comes to SR-IOV handling during driver unbind.
>
> Looking at existing driver implementations, I found two different
> approaches:
>
> 1) mlx5 - unconditionally disables SR-IOV in remove:
>
> drivers/net/ethernet/mellanox/mlx5/core/main.c:
> static void remove_one(struct pci_dev *pdev)
> {
> ...
> mlx5_sriov_disable(pdev, false);
> ...
> }
>
> drivers/net/ethernet/mellanox/mlx5/core/sriov.c:
> void mlx5_sriov_disable(struct pci_dev *pdev, bool num_vf_change)
> {
> struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
> struct devlink *devlink = priv_to_devlink(dev);
> int num_vfs = pci_num_vf(dev->pdev);
>
> pci_disable_sriov(pdev); /* Always disable, no pci_vfs_assigned()
> check */
> devl_lock(devlink);
> mlx5_device_disable_sriov(dev, num_vfs, true, num_vf_change);
> devl_unlock(devlink);
> }
>
> 2) ixgbe - checks pci_vfs_assigned() and skips disable if VFs are in use:
>
> drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:
> static void ixgbe_remove(struct pci_dev *pdev)
> {
> ...
> #ifdef CONFIG_PCI_IOV
> ixgbe_disable_sriov(adapter);
> #endif
> ...
> }
>
> drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c:
> #ifdef CONFIG_PCI_IOV
> if (pci_vfs_assigned(adapter->pdev)) {
> e_dev_warn("Unloading driver while VFs are assigned - VFs will
> not be deallocated\n");
> return -EPERM;
> }
> pci_disable_sriov(adapter->pdev);
> #endif
>
> Regarding the warning level discussion: I would prefer keeping it as
> dev_warn() rather than downgrading to dev_info(). As Leon mentioned,
> some devices do require SR-IOV to be disabled when the PF is unbound,
> and for those cases, this warning is important for operators to notice
> and take action. A warning level helps ensure it doesn't get lost in
> normal system logs.
>
> Please let me know how you'd like to proceed.
"driver left SR-IOV enabled after remove\n" is KERN_WARNING today, and
I'm OK with leaving it that way.
prev parent reply other threads:[~2026-02-06 22:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 7:33 [PATCH V1] nvme-pci: disable SR-IOV VFs on driver unbind Qinyun Tan
2026-01-27 8:48 ` Christoph Hellwig
2026-01-27 14:31 ` Leon Romanovsky
2026-01-27 16:06 ` Keith Busch
2026-01-27 18:00 ` Leon Romanovsky
2026-01-27 23:09 ` Bjorn Helgaas
2026-01-27 23:43 ` Jakub Kicinski
2026-01-28 8:44 ` Leon Romanovsky
2026-01-30 4:53 ` qinyuntan
2026-02-06 22:28 ` Bjorn Helgaas [this message]
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=20260206222826.GA98751@bhelgaas \
--to=helgaas@kernel.org \
--cc=axboe@kernel.dk \
--cc=bhelgaas@google.com \
--cc=guanghuifeng@linux.alibaba.com \
--cc=hch@lst.de \
--cc=kanie@linux.alibaba.com \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=oliver.yang@linux.alibaba.com \
--cc=qinyuntan@linux.alibaba.com \
--cc=sagi@grimberg.me \
--cc=xlpang@linux.alibaba.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.