From: Alex Williamson <alex@shazbot.org>
To: Chengwen Feng <fengchengwen@huawei.com>
Cc: <jgg@ziepe.ca>, <helgaas@kernel.org>,
<wathsala.vithanage@arm.com>, <wei.huang2@amd.com>,
<zhipingz@meta.com>, <wangzhou1@hisilicon.com>,
<wangyushan12@huawei.com>, <liuyonglong@huawei.com>,
<kvm@vger.kernel.org>, <linux-pci@vger.kernel.org>,
alex@shazbot.org
Subject: Re: [PATCH v19 17/18] vfio/pci: Reset hardware TPH state on device enable/disable
Date: Wed, 8 Jul 2026 17:29:44 -0600 [thread overview]
Message-ID: <20260708172944.685c3cea@shazbot.org> (raw)
In-Reply-To: <20260702124224.57168-18-fengchengwen@huawei.com>
On Thu, 2 Jul 2026 20:42:23 +0800
Chengwen Feng <fengchengwen@huawei.com> wrote:
> VFIO allows user space to enable and modify PCI TPH state, but device
> reset only clears hardware TPH registers, while the software TPH state
> maintained in pci/tph.c remains stale.
It's saved and restored, why is it "stale"? It seems more that the
interface simply doesn't meet our use case.
What about resets through vfio-pci interfaces, should TPH be
automatically disabled? Thanks,
Alex
> Fix the stale state leakage by explicitly disabling TPH in core enable
> and disable paths:
> - In vfio_pci_core_enable(), clear leftover TPH state from previous
> user sessions before device initialization.
> - In vfio_pci_core_disable(), revert any user-modified TPH state
> when releasing the device.
>
> This ensures consistent TPH hardware and software state for each
> user session and avoids residual state contamination.
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
> drivers/vfio/pci/vfio_pci_core.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> index 7251e251824a..5a14439d1ccb 100644
> --- a/drivers/vfio/pci/vfio_pci_core.c
> +++ b/drivers/vfio/pci/vfio_pci_core.c
> @@ -612,6 +612,8 @@ int vfio_pci_core_enable(struct vfio_pci_core_device *vdev)
>
> vdev->reset_works = !ret;
> vdev->tph_permit = false;
> + /* Reset TPH status on new user session */
> + pcie_disable_tph(vdev->pdev);
> pci_save_state(pdev);
> vdev->pci_saved_state = pci_store_saved_state(pdev);
> if (!vdev->pci_saved_state)
> @@ -759,6 +761,9 @@ void vfio_pci_core_disable(struct vfio_pci_core_device *vdev)
>
> vfio_pci_zdev_close_device(vdev);
>
> + /* Reset TPH status on exit user session */
> + pcie_disable_tph(vdev->pdev);
> +
> /*
> * If we have saved state, restore it. If we can reset the device,
> * even better. Resetting with current state seems better than
next prev parent reply other threads:[~2026-07-08 23:33 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 12:42 [PATCH v19 00/18] vfio/pci: Add PCIe TPH support Chengwen Feng
2026-07-02 12:42 ` [PATCH v19 01/18] PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction Chengwen Feng
2026-07-02 12:51 ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 02/18] PCI/TPH: Fix tph_enabled concurrent update race by bitfield packing Chengwen Feng
2026-07-02 12:51 ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 03/18] PCI/TPH: Cache TPH requester capability at probe time Chengwen Feng
2026-07-02 12:55 ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 04/18] PCI/TPH: Refactor pcie_enable_tph & add explicit requester variant Chengwen Feng
2026-07-02 12:50 ` sashiko-bot
2026-07-08 23:33 ` Alex Williamson
2026-07-09 9:22 ` fengchengwen
2026-07-13 0:21 ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 05/18] PCI/TPH: Refactor pcie_tph_get_cpu_st & add explicit variant Chengwen Feng
2026-07-02 12:56 ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 06/18] PCI/TPH: Expose the enabled TPH requester type Chengwen Feng
2026-07-02 12:49 ` sashiko-bot
2026-07-08 23:33 ` Alex Williamson
2026-07-09 9:30 ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 07/18] PCI/TPH: Add pcie_tph_supported() helper to check TPH capability attributes Chengwen Feng
2026-07-02 12:53 ` sashiko-bot
2026-07-03 0:39 ` fengchengwen
2026-07-08 23:32 ` Alex Williamson
2026-07-09 9:36 ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 08/18] PCI/TPH: Add pci_tph_dsm_supported() helper to detect device TPH ST _DSM Chengwen Feng
2026-07-02 12:55 ` sashiko-bot
2026-07-02 12:42 ` [PATCH v19 09/18] vfio/pci: Hide TPH capability when TPH is unsupported Chengwen Feng
2026-07-02 13:00 ` sashiko-bot
2026-07-03 0:36 ` fengchengwen
2026-07-08 23:32 ` Alex Williamson
2026-07-09 11:00 ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 10/18] vfio/pci: Introduce tph policy parameter for staged TPH feature enablement Chengwen Feng
2026-07-02 12:50 ` sashiko-bot
2026-07-08 23:31 ` Alex Williamson
2026-07-09 11:29 ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 11/18] vfio/pci: Virtualize PCIe TPH capability registers Chengwen Feng
2026-07-02 13:04 ` sashiko-bot
2026-07-03 0:51 ` fengchengwen
2026-07-08 23:31 ` Alex Williamson
2026-07-09 11:40 ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 12/18] vfio/pci: Add dmabuf TPH metadata storage and fd query helper Chengwen Feng
2026-07-02 12:56 ` sashiko-bot
2026-07-03 0:53 ` fengchengwen
2026-07-08 23:31 ` Alex Williamson
2026-07-09 11:49 ` fengchengwen
2026-07-09 18:50 ` Alex Williamson
2026-07-14 10:46 ` fengchengwen
2026-07-14 13:57 ` Alex Williamson
2026-07-15 1:37 ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 13/18] vfio/pci: Introduce VFIO_DEVICE_FEATURE_TPH family uapi for PCI TPH control Chengwen Feng
2026-07-02 13:01 ` sashiko-bot
2026-07-03 0:57 ` fengchengwen
2026-07-08 23:31 ` Alex Williamson
2026-07-09 11:56 ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 14/18] vfio/pci: Implement VFIO_DEVICE_FEATURE_TPH and valid TPH config write support Chengwen Feng
2026-07-02 13:04 ` sashiko-bot
2026-07-03 1:16 ` fengchengwen
2026-07-08 23:30 ` Alex Williamson
2026-07-09 12:16 ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 15/18] vfio/pci: Implement TPH_RESOLVE feature for DMABUF and CPU source resolving Chengwen Feng
2026-07-02 13:00 ` sashiko-bot
2026-07-03 1:26 ` fengchengwen
2026-07-08 23:31 ` Alex Williamson
2026-07-09 12:20 ` fengchengwen
2026-07-02 12:42 ` [PATCH v19 16/18] vfio/pci: Implement TPH_ST feature for batch ST table programming Chengwen Feng
2026-07-02 13:04 ` sashiko-bot
2026-07-03 1:42 ` fengchengwen
2026-07-08 23:29 ` Alex Williamson
2026-07-09 12:36 ` fengchengwen
2026-07-09 13:49 ` Alex Williamson
2026-07-02 12:42 ` [PATCH v19 17/18] vfio/pci: Reset hardware TPH state on device enable/disable Chengwen Feng
2026-07-02 13:00 ` sashiko-bot
2026-07-08 23:29 ` Alex Williamson [this message]
2026-07-09 12:39 ` fengchengwen
2026-07-15 3:09 ` fengchengwen
2026-07-15 4:23 ` Alex Williamson
2026-07-02 12:42 ` [PATCH v19 18/18] vfio/pci: Expose tph_policy via debugfs Chengwen Feng
2026-07-02 12:59 ` sashiko-bot
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=20260708172944.685c3cea@shazbot.org \
--to=alex@shazbot.org \
--cc=fengchengwen@huawei.com \
--cc=helgaas@kernel.org \
--cc=jgg@ziepe.ca \
--cc=kvm@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=liuyonglong@huawei.com \
--cc=wangyushan12@huawei.com \
--cc=wangzhou1@hisilicon.com \
--cc=wathsala.vithanage@arm.com \
--cc=wei.huang2@amd.com \
--cc=zhipingz@meta.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.