From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-a2-smtp.messagingengine.com (fout-a2-smtp.messagingengine.com [103.168.172.145]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B944D401495; Fri, 12 Jun 2026 16:52:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.145 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781283175; cv=none; b=ri1HKE05ZtEBIjvWewzpctBzfoFLXluBl6vxbYokvNtwZHawa7wUv2+Y+uzAAwDi8navPrHXy/PmDSg6iMcfMNoPIXJppDfx/UjG3Ct1Qvp7GB6CI7BwBMD3muU8bRZAeYMaHH4DPtkKcvHfEHLrvERP4oUTfhaKnxlO4j44clI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781283175; c=relaxed/simple; bh=24wQChAQOJp4jUd0/0DfoMQ1yU723OejhdZTkJTDDq8=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=o9lFVIEjgLwvhuQAYuZthLs2dEtx1PekSR146CHA97X7dcdaO/fXBmCQEO08FgOtA0lXGiq+UJc8rbQ/QWblCGSRUwr9aoGPVl7C+FTherVql1rsLY258bJsqq3ORqk3Sb0Zlx2pEq0fvFQ06Ag1DBlEXKw+xZyqaY/FCrV2qLU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shazbot.org; spf=pass smtp.mailfrom=shazbot.org; dkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org header.b=lFXpnGwc; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=XAPZINl4; arc=none smtp.client-ip=103.168.172.145 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shazbot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shazbot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=shazbot.org header.i=@shazbot.org header.b="lFXpnGwc"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="XAPZINl4" Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailfout.phl.internal (Postfix) with ESMTP id E25FBEC019E; Fri, 12 Jun 2026 12:52:51 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Fri, 12 Jun 2026 12:52:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shazbot.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1781283171; x=1781369571; bh=IMjdTnzoJaPEHm5nCFiglgf4MQ8JbUyD46xJ1bIgrWU=; b= lFXpnGwcIYKgvYDL/3TehmOZ1Kgfm1m9vLzM4mh/5yn9qC778edLi/zuF7hTlyjf 7qEddjjKjzQuqm4uSKFbE6qGiqy87DoZM+mEUczzThnuFEmt90jrmxS3aBeAnGCT XR6O4Ttz0NeqrMcB3aPpr/UlrBguVCNi+DHhbmDneCLjeS0+jFP86IFiYg90472U SImrX52qe13TDNV4Epnsmtwhk7mv1AfA7Umy7q8gdJrFtohQ0BOhAN8uS9LfCQ2d IMhJF8PgmNrTDeybihtO5vB9OaVtSmVL60l9g2vudNSJP5ZqHfsJ6JdGjswJ1v1L mE5nOq5ghRbU3QikXVqOdA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1781283171; x= 1781369571; bh=I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Xaw7fRDMW4JTQ3BhiKpuYO3fX2mmJtUA+mKUs1t7VxTVg X-ME-Proxy: Feedback-ID: i03f14258:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 12 Jun 2026 12:52:50 -0400 (EDT) Date: Fri, 12 Jun 2026 10:52:48 -0600 From: Alex Williamson To: Zhiping Zhang Cc: , , , , , Bjorn Helgaas , alex@shazbot.org Subject: Re: [PATCH v7 2/5] PCI/TPH: Add requester/completer type helpers Message-ID: <20260612105248.7d8431f2@shazbot.org> In-Reply-To: <20260611161546.4075580-3-zhipingz@meta.com> References: <20260611161546.4075580-1-zhipingz@meta.com> <20260611161546.4075580-3-zhipingz@meta.com> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 11 Jun 2026 09:11:17 -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. 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 > Acked-by: Bjorn Helgaas 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 > + > /* > * 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 */