From: Weili Qian <qianweili@huawei.com>
To: "Laguna, Lukasz" <lukasz.laguna@intel.com>,
<sashiko-reviews@lists.linux.dev>, <linux-pci@vger.kernel.org>,
<wangzhou1@hisilicon.com>, <liulongfang@huawei.com>
Cc: <michal.winiarski@intel.com>, <bhelgaas@google.com>,
<alex@shazbot.org>, <kevin.tian@intel.com>
Subject: Re: [PATCH v2 04/13] PCI/IOV: Allow VF drivers to handle resets
Date: Wed, 28 Oct 2026 16:52:05 +0800 [thread overview]
Message-ID: <3464fe3b-8a9a-cbe0-c96b-e4929ec46264@huawei.com> (raw)
In-Reply-To: <0576e676-b9b5-422b-8bbf-0643065c1bd5@intel.com>
Thanks for adding us.
We've reviewed the series and confirmed that it conflicts with QM's
existing PF↔VF reset coordination. QM currently handles PF FLR through
driver-specific mechanisms: the PF notifies all VFs before reset an each
VF stops itself and acknowledges back. The new
reset_prepare()/reset_done() calls on each VF before the PF's introduce
a second path that contends with QM's QM_RESETTING bit lock across
reset_prepare/reset_done, causing timeouts on both host-side VFs (QM
driver) and passthrough VFs (hisi-acc-vfio-pci driver).
We support the direction of this series and will adapt QM and
hisi-acc-vfio-pci to work with the PCI core's unified VF handling.
Additionally, we notice that passthrough VFs bound to generic vfio-pci
do not receive reset_prepare/reset_done notification. We're wondering
whether there's a way to uniformly cover both host-side and passthrough
VFs in the PCI core.
Thanks,
Weili
On 2026/10/28 0:51, Laguna, Lukasz wrote:
>
>
> Adding HiSilicon QM and hisi-acc-vfio-pci maintainers.
>
> Hi Zhou, Weili, Longfang,
>
> The series [1] adds generic handling of VFs across a PF reset in the
> PCI core. On PF reset, the core now saves / restores all subordinate
> VFs config state, and notify their drivers via .reset_prepare() /
> .reset_done(), as VF state is lost on PF reset anyway.
>
> Sashiko points out above [2], that this conflicts with the
> driver-specific VF handling in HiSilicon QM and hisi-acc-vfio-pci. It
> seems to be a valid point.
>
> Could you please take a look and share your thoughts?
>
> [1]
> https://lore.kernel.org/linux-pci/20261027160446.858300-1-lukasz.laguna@intel.com/
> [2] https://lore.kernel.org/linux-pci/sashiko-outbox-186926@kernel.org/
>
> Thanks,
> Lukasz
>
> On 10/27/2026 17:34, sashiko-bot@kernel.org wrote:
>> Thank you for your contribution! Sashiko AI review found 1 potential
>> issue(s) to consider:
>> - [High] PCI/IOV: calling VF reset_prepare() before PF breaks hisi_qm
>> PF FLR
>> --
>>
>> commit b82e20ef0c7a057bbb242268e11b3dd9218fd7d8
>> Author: Michał Winiarski <michal.winiarski@intel.com>
>>
>> PCI/IOV: Allow VF drivers to handle resets
>>
>> This commit updates PCI function, bus, and slot reset handling to lock
>> enabled VFs, notify VF drivers via .reset_prepare() and
>> .reset_done(), and
>> save and restore VF configuration state across PF resets.
>>
>>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>>> index d8e7c7d8e4021..d088302547c34 100644
>>> --- a/drivers/pci/pci.c
>>> +++ b/drivers/pci/pci.c
>> [ ... ]
>>
>>> @@ -5171,6 +5202,17 @@ static void pci_dev_save_and_disable(struct
>>> pci_dev *dev)
>>> return;
>>> pci_save_state(dev);
>>> +}
>>> +
>>> +static void pci_dev_save_and_disable(struct pci_dev *dev)
>>> +{
>>> + struct pci_dev *vf;
>>> +
>>> + for_each_pci_vf(dev, vf)
>>> + pci_dev_reset_prepare_and_save(vf);
>>> +
>>> + pci_dev_reset_prepare_and_save(dev);
>> [Severity: High]
>> Does calling .reset_prepare() on each VF before the PF here cause a
>> self-blocking timeout and reset failure on HiSilicon QM devices
>> (hisi_hpre, hisi_sec2, hisi_zip, and hisi_acc_vfio_pci) when
>> resetting a PF
>> with enabled VFs?
>>
>> In pci_dev_save_and_disable(), pci_dev_reset_prepare_and_save(vf)
>> runs for
>> every VF and then pci_dev_reset_prepare_and_save(dev) runs for the PF
>> in the
>> same thread before any .reset_done() callback is invoked in
>> pci_dev_restore().
>>
>> When VFs are bound to hisi_acc_vfio_pci (where hisi_acc_vdev->pf_qm
>> points
>> to the PF's struct hisi_qm), the first VF's .reset_prepare() sets the
>> reset
>> bit on the shared PF qm->misc_ctl and holds it until .reset_done():
>>
>> drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c:
>> hisi_acc_vf_pci_reset_prepare() {
>> struct hisi_acc_vf_core_device *hisi_acc_vdev =
>> hisi_acc_drvdata(pdev);
>> struct hisi_qm *qm = hisi_acc_vdev->pf_qm;
>> ...
>> while (test_and_set_bit(QM_RESETTING, &qm->misc_ctl)) {
>> msleep(1);
>> if (++delay > QM_RESET_WAIT_TIMEOUT) {
>> dev_err(dev, "reset prepare failed\n");
>> return;
>> }
>> }
>> }
>>
>> Similarly, when VFs are bound to hisi_hpre, hisi_sec2, or hisi_zip on
>> Kunpeng920, hisi_qm_reset_prepare() -> qm_reset_prepare_ready()
>> acquires the
>> same bit on pf_qm->misc_ctl via qm_wait_reset_finish(pf_qm) and only
>> clears
>> it in hisi_qm_reset_done() -> qm_reset_bit_clear():
>>
>> drivers/crypto/hisilicon/qm.c:
>> qm_reset_prepare_ready() {
>> struct pci_dev *pdev = qm->pdev;
>> struct hisi_qm *pf_qm = pci_get_drvdata(pci_physfn(pdev));
>>
>> if (qm->ver < QM_HW_V3)
>> return qm_wait_reset_finish(pf_qm);
>>
>> return qm_wait_reset_finish(qm);
>> }
>>
>> Because the first VF's .reset_done() has not run yet, every
>> subsequent VF's
>> .reset_prepare() and the PF's own hisi_qm_reset_prepare() will spin
>> waiting
>> for that bit on pf_qm->misc_ctl until the timeout expires, log an
>> error, and
>> return early without stopping the remaining VFs or the PF prior to the
>> hardware reset.
>>
>> On Kunpeng930 (where qm->ver >= QM_HW_V3) with host-bound VFs, each VF's
>> hisi_qm_reset_prepare() sets the bit on its own vf_qm->misc_ctl. When
>> the PF
>> subsequently runs hisi_qm_reset_prepare(), it notifies VFs via
>> mailbox and
>> waits for them:
>>
>> drivers/crypto/hisilicon/qm.c:
>> hisi_qm_reset_prepare()
>> -> qm_try_stop_vfs()
>> -> qm_ping_all_vfs()
>> -> qm_wait_vf_prepare_finish()
>>
>> Each VF's mailbox work handler (qm_pf_reset_vf_process() ->
>> qm_pf_reset_vf_prepare() -> qm_reset_prepare_ready(vf_qm)) then tries to
>> acquire the bit on vf_qm->misc_ctl that is already held by that VF's own
>> .reset_prepare(), timing out and causing the PF reset preparation to
>> fail as
>> well.
>>
>
> .
>
next prev parent reply other threads:[~2026-10-28 8:52 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 16:04 [PATCH v2 00/13] PCI/IOV: Improve reset handling with VFs enabled Lukasz Laguna
2026-10-27 16:04 ` [PATCH v2 01/13] PCI/IOV: Introduce pci_iov_get_virtfn() Lukasz Laguna
2026-10-27 16:20 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 02/13] PCI/IOV: Introduce VF iterators Lukasz Laguna
2026-10-27 16:21 ` sashiko-bot
2026-10-27 21:35 ` Bjorn Helgaas
2026-10-28 7:29 ` Laguna, Lukasz
2026-10-27 16:04 ` [PATCH v2 03/13] PCI/IOV: Introduce VF locking helpers Lukasz Laguna
2026-10-27 16:26 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 04/13] PCI/IOV: Allow VF drivers to handle resets Lukasz Laguna
2026-10-27 16:34 ` sashiko-bot
2026-10-27 16:51 ` Laguna, Lukasz
2026-10-28 8:52 ` Weili Qian [this message]
2026-10-28 14:05 ` Laguna, Lukasz
2026-10-27 20:00 ` Bjorn Helgaas
2026-10-28 6:39 ` Laguna, Lukasz
2026-10-27 16:04 ` [PATCH v2 05/13] ionic: Lock VFs around pci_reset_function_locked() Lukasz Laguna
2026-10-27 16:14 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 06/13] pds_core: " Lukasz Laguna
2026-10-27 16:12 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 07/13] i40e: Drop VF MSI state restore from PF reset_done Lukasz Laguna
2026-10-27 16:13 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 08/13] PCI/IOV: Allow bus reset_method for PF with VFs enabled Lukasz Laguna
2026-10-27 16:20 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 09/13] PCI/TSM: Use generic VF iterators Lukasz Laguna
2026-10-27 16:15 ` sashiko-bot
2026-10-27 20:08 ` Bjorn Helgaas
2026-10-28 7:25 ` Laguna, Lukasz
2026-10-27 16:04 ` [PATCH v2 10/13] ixgbe: Use generic VF iterator Lukasz Laguna
2026-10-27 16:17 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 11/13] ice: Use pci_iov_get_virtfn() Lukasz Laguna
2026-10-27 16:20 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 12/13] liquidio: " Lukasz Laguna
2026-10-27 16:19 ` sashiko-bot
2026-10-27 16:04 ` [PATCH v2 13/13] drm/xe/pf: " Lukasz Laguna
2026-10-27 16:21 ` sashiko-bot
2026-10-27 19:49 ` [PATCH v2 00/13] PCI/IOV: Improve reset handling with VFs enabled Bjorn Helgaas
2026-10-28 7:03 ` Laguna, Lukasz
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=3464fe3b-8a9a-cbe0-c96b-e4929ec46264@huawei.com \
--to=qianweili@huawei.com \
--cc=alex@shazbot.org \
--cc=bhelgaas@google.com \
--cc=kevin.tian@intel.com \
--cc=linux-pci@vger.kernel.org \
--cc=liulongfang@huawei.com \
--cc=lukasz.laguna@intel.com \
--cc=michal.winiarski@intel.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wangzhou1@hisilicon.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.