From: Alex Williamson <alex@shazbot.org>
To: Zhiping Zhang <zhipingz@meta.com>
Cc: <netdev@vger.kernel.org>, <kvm@vger.kernel.org>,
<linux-rdma@vger.kernel.org>, <linux-pci@vger.kernel.org>,
<dri-devel@lists.freedesktop.org>,
Bjorn Helgaas <bhelgaas@google.com>,
alex@shazbot.org
Subject: Re: [PATCH v7 2/5] PCI/TPH: Add requester/completer type helpers
Date: Fri, 12 Jun 2026 10:52:48 -0600 [thread overview]
Message-ID: <20260612105248.7d8431f2@shazbot.org> (raw)
In-Reply-To: <20260611161546.4075580-3-zhipingz@meta.com>
On Thu, 11 Jun 2026 09:11:17 -0700
Zhiping Zhang <zhipingz@meta.com> wrote:
> Add pcie_tph_enabled_req_type() so drivers can query the enabled TPH
> requester mode without reaching into pci_dev internals.
>
> Add pcie_tph_completer_type() so drivers that publish TPH metadata for
> a device acting as a completer can gate on the "TPH Completer
> Supported" field of Device Capabilities 2 (bits 13:12,
> PCI_EXP_DEVCAP2_TPH_COMP_MASK) rather than reusing requester-side
> state. Fold the reserved 0b10 encoding into NONE so callers only see
> the defined values.
>
> This keeps pci_dev::tph_req_type and the completer-capability decode
> inside the PCI/TPH code and provides !CONFIG_PCIE_TPH stubs for
> callers.
>
> Signed-off-by: Zhiping Zhang <zhipingz@meta.com>
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
This is carrying forward an ack for v6, where half the interface here
was dropped and changed shape. Thanks,
Alex
> ---
> drivers/pci/tph.c | 43 +++++++++++++++++++++++++++++++++++++++++
> include/linux/pci-tph.h | 8 ++++++++
> 2 files changed, 51 insertions(+)
>
> diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
> index 91145e8d9d95..4fe076bba953 100644
> --- a/drivers/pci/tph.c
> +++ b/drivers/pci/tph.c
> @@ -174,6 +174,49 @@ u32 pcie_tph_get_st_table_loc(struct pci_dev *pdev)
> }
> EXPORT_SYMBOL(pcie_tph_get_st_table_loc);
>
> +/**
> + * pcie_tph_enabled_req_type - Return the device's enabled TPH requester type
> + * @pdev: PCI device to query
> + *
> + * Return: PCI_TPH_REQ_DISABLE, PCI_TPH_REQ_TPH_ONLY or PCI_TPH_REQ_EXT_TPH.
> + */
> +u8 pcie_tph_enabled_req_type(struct pci_dev *pdev)
> +{
> + return pdev->tph_req_type;
> +}
> +EXPORT_SYMBOL(pcie_tph_enabled_req_type);
> +
> +/**
> + * pcie_tph_completer_type - Return the device's TPH Completer support
> + * @pdev: PCI device to query
> + *
> + * Reads the "TPH Completer Supported" field (bits 13:12) of Device
> + * Capabilities 2. The reserved 0b10 encoding is folded into
> + * "not supported" so callers only need to compare against the three
> + * defined values.
> + *
> + * Return: one of %PCI_EXP_DEVCAP2_TPH_COMP_NONE,
> + * %PCI_EXP_DEVCAP2_TPH_COMP_TPH_ONLY or
> + * %PCI_EXP_DEVCAP2_TPH_COMP_EXT_TPH.
> + */
> +u8 pcie_tph_completer_type(struct pci_dev *pdev)
> +{
> + u32 reg;
> +
> + if (pcie_capability_read_dword(pdev, PCI_EXP_DEVCAP2, ®))
> + return PCI_EXP_DEVCAP2_TPH_COMP_NONE;
> +
> + switch (FIELD_GET(PCI_EXP_DEVCAP2_TPH_COMP_MASK, reg)) {
> + case PCI_EXP_DEVCAP2_TPH_COMP_TPH_ONLY:
> + return PCI_EXP_DEVCAP2_TPH_COMP_TPH_ONLY;
> + case PCI_EXP_DEVCAP2_TPH_COMP_EXT_TPH:
> + return PCI_EXP_DEVCAP2_TPH_COMP_EXT_TPH;
> + default:
> + return PCI_EXP_DEVCAP2_TPH_COMP_NONE;
> + }
> +}
> +EXPORT_SYMBOL(pcie_tph_completer_type);
> +
> /*
> * Return the size of ST table. If ST table is not in TPH Requester Extended
> * Capability space, return 0. Otherwise return the ST Table Size + 1.
> diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h
> index be68cd17f2f8..7743af6fe432 100644
> --- a/include/linux/pci-tph.h
> +++ b/include/linux/pci-tph.h
> @@ -9,6 +9,8 @@
> #ifndef LINUX_PCI_TPH_H
> #define LINUX_PCI_TPH_H
>
> +#include <linux/pci_regs.h>
> +
> /*
> * According to the ECN for PCI Firmware Spec, Steering Tag can be different
> * depending on the memory type: Volatile Memory or Persistent Memory. When a
> @@ -30,6 +32,8 @@ void pcie_disable_tph(struct pci_dev *pdev);
> int pcie_enable_tph(struct pci_dev *pdev, int mode);
> u16 pcie_tph_get_st_table_size(struct pci_dev *pdev);
> u32 pcie_tph_get_st_table_loc(struct pci_dev *pdev);
> +u8 pcie_tph_enabled_req_type(struct pci_dev *pdev);
> +u8 pcie_tph_completer_type(struct pci_dev *pdev);
> #else
> static inline int pcie_tph_set_st_entry(struct pci_dev *pdev,
> unsigned int index, u16 tag)
> @@ -41,6 +45,10 @@ static inline int pcie_tph_get_cpu_st(struct pci_dev *dev,
> static inline void pcie_disable_tph(struct pci_dev *pdev) { }
> static inline int pcie_enable_tph(struct pci_dev *pdev, int mode)
> { return -EINVAL; }
> +static inline u8 pcie_tph_enabled_req_type(struct pci_dev *pdev)
> +{ return PCI_TPH_REQ_DISABLE; }
> +static inline u8 pcie_tph_completer_type(struct pci_dev *pdev)
> +{ return PCI_EXP_DEVCAP2_TPH_COMP_NONE; }
> #endif
>
> #endif /* LINUX_PCI_TPH_H */
next prev parent reply other threads:[~2026-06-12 16:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 16:11 [PATCH v7 0/5] vfio/dma-buf: add TPH support for peer-to-peer access Zhiping Zhang
2026-06-11 16:11 ` [PATCH v7 1/5] net/mlx5: free mlx5_st_idx_data on final dealloc Zhiping Zhang
2026-06-12 16:46 ` sashiko-bot
2026-06-11 16:11 ` [PATCH v7 2/5] PCI/TPH: Add requester/completer type helpers Zhiping Zhang
2026-06-12 16:46 ` sashiko-bot
2026-06-12 16:52 ` Alex Williamson [this message]
2026-06-11 16:11 ` [PATCH v7 3/5] dma-buf: add optional get_tph() callback Zhiping Zhang
2026-06-12 16:46 ` sashiko-bot
2026-06-11 16:11 ` [PATCH v7 4/5] vfio/pci: implement get_tph and DMA_BUF_TPH feature Zhiping Zhang
2026-06-12 16:46 ` sashiko-bot
2026-06-12 17:10 ` Alex Williamson
2026-06-11 16:11 ` [PATCH v7 5/5] RDMA/mlx5: get tph for p2p access when registering dma-buf mr Zhiping Zhang
2026-06-12 16:46 ` sashiko-bot
-- strict thread matches above, loose matches on Subject: below --
2026-06-10 19:31 [PATCH v7 0/5] vfio/dma-buf: add TPH support for peer-to-peer access Zhiping Zhang
2026-06-10 19:31 ` [PATCH v7 2/5] PCI/TPH: Add requester/completer type helpers Zhiping Zhang
2026-06-11 20:25 ` sashiko-bot
2026-06-11 23:06 ` Zhiping Zhang
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=20260612105248.7d8431f2@shazbot.org \
--to=alex@shazbot.org \
--cc=bhelgaas@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kvm@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--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.