From: Alex Williamson <alex.williamson@nvidia.com>
To: Chengwen Feng <fengchengwen@huawei.com>
Cc: <jgg@ziepe.ca>, <wathsala.vithanage@arm.com>,
<helgaas@kernel.org>, <wangzhou1@hisilicon.com>,
<wangyushan12@huawei.com>, <liuyonglong@huawei.com>,
<kvm@vger.kernel.org>, <linux-pci@vger.kernel.org>
Subject: Re: [PATCH v5 1/6] PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction
Date: Mon, 4 May 2026 17:11:07 -0600 [thread overview]
Message-ID: <20260504171107.040d1190@nvidia.com> (raw)
In-Reply-To: <20260427085843.42460-2-fengchengwen@huawei.com>
On Mon, 27 Apr 2026 16:58:38 +0800
Chengwen Feng <fengchengwen@huawei.com> wrote:
> pcie_tph_get_st_table_loc() incorrectly uses FIELD_GET(), which shifts the
> field value to bit 0. But the function is designed to return raw
> PCI_TPH_LOC_* values as defined in the function comment.
>
> This causes incorrect ST table location detection. Fix it by using bitwise
> AND with PCI_TPH_CAP_LOC_MASK to return the unshifted field value matching
> the function specification.
>
> Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
> drivers/pci/tph.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
AFAICT, this is effectively a no-op within drivers/pci/tph.c. We remove
the FIELD_GET(), but we also remove the FIELD_PREP(), so the end result
is no change, other than to align with the function comment.
However, not mentioned in the commit log, mlx5_st_create() expects the
documented rather than implemented behavior here. That should be noted
here to justify the Fixes: tag.
Reviewed-by: Alex Williamson <alex.williamson@nvidia.com>
Nit below...
> diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
> index 91145e8d9d95..f17b74b5fb1e 100644
> --- a/drivers/pci/tph.c
> +++ b/drivers/pci/tph.c
> @@ -170,7 +170,7 @@ u32 pcie_tph_get_st_table_loc(struct pci_dev *pdev)
>
> pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®);
>
> - return FIELD_GET(PCI_TPH_CAP_LOC_MASK, reg);
> + return reg & PCI_TPH_CAP_LOC_MASK;
> }
> EXPORT_SYMBOL(pcie_tph_get_st_table_loc);
>
> @@ -183,11 +183,7 @@ u16 pcie_tph_get_st_table_size(struct pci_dev *pdev)
> u32 reg;
> u32 loc;
>
> - /* Check ST table location first */
This comment still seems valid. Thanks,
Alex
> loc = pcie_tph_get_st_table_loc(pdev);
> -
> - /* Convert loc to match with PCI_TPH_LOC_* defined in pci_regs.h */
> - loc = FIELD_PREP(PCI_TPH_CAP_LOC_MASK, loc);
> if (loc != PCI_TPH_LOC_CAP)
> return 0;
>
> @@ -316,8 +312,6 @@ int pcie_tph_set_st_entry(struct pci_dev *pdev, unsigned int index, u16 tag)
> set_ctrl_reg_req_en(pdev, PCI_TPH_REQ_DISABLE);
>
> loc = pcie_tph_get_st_table_loc(pdev);
> - /* Convert loc to match with PCI_TPH_LOC_* */
> - loc = FIELD_PREP(PCI_TPH_CAP_LOC_MASK, loc);
>
> switch (loc) {
> case PCI_TPH_LOC_MSIX:
next prev parent reply other threads:[~2026-05-04 23:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 8:58 [PATCH v5 0/6] vfio/pci: Add PCIe TPH support Chengwen Feng
2026-04-27 8:58 ` [PATCH v5 1/6] PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction Chengwen Feng
2026-04-27 22:25 ` Bjorn Helgaas
2026-05-04 23:11 ` Alex Williamson [this message]
2026-04-27 8:58 ` [PATCH v5 2/6] PCI/TPH: Export pcie_tph_get_st_modes() for external use Chengwen Feng
2026-04-27 8:58 ` [PATCH v5 3/6] vfio/pci: Add PCIe TPH interface with capability query Chengwen Feng
2026-04-27 8:58 ` [PATCH v5 4/6] vfio/pci: Add PCIe TPH enable/disable support Chengwen Feng
2026-04-27 8:58 ` [PATCH v5 5/6] vfio/pci: Add PCIe TPH GET_ST interface Chengwen Feng
2026-04-27 8:58 ` [PATCH v5 6/6] vfio/pci: Add PCIe TPH SET_ST interface Chengwen Feng
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=20260504171107.040d1190@nvidia.com \
--to=alex.williamson@nvidia.com \
--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 \
/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.