On Tue, Sep 15, 2026 at 3:23 PM Bjorn Helgaas <[email protected]> wrote: > > > > On Fri, Jul 31, 2026 at 02:15:49PM -0700, Zhiping Zhang 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. It applies the same reserved- > > encoding fold as get_rp_completer_type(), inlined, so the reserved 0b10 > > value never reaches callers. > > > > 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 <[email protected]> > > Acked-by: Bjorn Helgaas <[email protected]> > > > --- > > drivers/pci/tph.c | 44 +++++++++++++++++++++++++++++++++++++++++ > > include/linux/pci-tph.h | 8 ++++++++ > > 2 files changed, 52 insertions(+) > > > > diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c > > index 5cbb381e2a02..d0202ff7a1b2 100644 > > --- a/drivers/pci/tph.c > > +++ b/drivers/pci/tph.c > > @@ -223,6 +223,50 @@ static u8 get_rp_completer_type(struct pci_dev *pdev) > > return PCI_EXP_DEVCAP2_TPH_COMP_NONE; > > } > > > > +/** > > + * 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 > > s/Reads/Read/ to match other doc ("Return ... type" above, "Write tag" below) > > > + * Capabilities 2. The reserved 0b10 encoding is folded into > > + * "not supported" so callers only need to compare against the three > > + * defined values. > > s/The reserved 0b10 encoding is folded/Fold reserved 0b10 encoding/ >
Thanks Bjorn for the ack. I'll incorporate both wording fixes in v14. The kernel-doc becomes: /** * pcie_tph_completer_type - Return the device's TPH Completer support * @pdev: PCI device to query * * Read the "TPH Completer Supported" field (bits 13:12) of Device * Capabilities 2. Fold reserved 0b10 encoding 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. */ Thanks, Zhiping
