linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gustavo Pimentel <Gustavo.Pimentel@synopsys.com>
To: helgaas@kernel.org
Cc: Gustavo Pimentel <Gustavo.Pimentel@synopsys.com>,
	Aditya Paluri <Venkata.AdityaPaluri@synopsys.com>,
	linux-pci@vger.kernel.org, Joao Pinto <Joao.Pinto@synopsys.com>
Subject: [PATCH] PCI/PTM: Fix PTM switch capability evaluation
Date: Thu, 21 May 2020 15:37:30 +0200	[thread overview]
Message-ID: <0b974380436d46ab3d8b7f4988f17e6f822079ac.1590068178.git.gustavo.pimentel@synopsys.com> (raw)

In order to enable PTM feature in a PCIe Endpoint, it is required to
enable this feature as well in all devices capable (if present) in the
datapath between the Root complex and the referred Endpoint e.g. PCIe
switches.

RC <--> Switch (USP) <-> Switch (DSP) <-> EP

According to PCIe specification Rev5 (6.22.3.2) and (7.9.16), in order
to enable this feature on a PTM capable switch, it's required to write a
enable bit in the switch upstream port (USP) control register, which after
that must respond to all PTM request messages received at any of its
downstream ports (DSP).

The previous implementation verifies if the PCIe switch has the PTM
feature enabled on both streams ports (USP and DSP). Since the DSP
doesn't support PTM capability, the previous implementation doesn't
allow the PTM feature to be enabled in the Endpoint, the current patch
fixes this.

Fixes: eec097d43100 ("PCI: Add pci_enable_ptm() for drivers to enable PTM on endpoints")
Signed-off-by: Aditya Paluri <venkata.adityapaluri@synopsys.com>
Signed-off-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: linux-pci@vger.kernel.org
Cc: Joao Pinto <jpinto@synopsys.com>
---
 drivers/pci/pcie/ptm.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c
index 9361f3a..cd85d44 100644
--- a/drivers/pci/pcie/ptm.c
+++ b/drivers/pci/pcie/ptm.c
@@ -111,6 +111,14 @@ int pci_enable_ptm(struct pci_dev *dev, u8 *granularity)
 	 */
 	if (pci_pcie_type(dev) == PCI_EXP_TYPE_ENDPOINT) {
 		ups = pci_upstream_bridge(dev);
+		/*
+		 * Per PCIe r5.0, sec 7.9.16, the PTM capability is not
+		 * permitted in Switch Downstream Ports
+		 */
+		if (ups && ups->hdr_type == PCI_HEADER_TYPE_BRIDGE &&
+		    pci_pcie_type(ups) == PCI_EXP_TYPE_DOWNSTREAM)
+			ups = pci_upstream_bridge(ups);
+
 		if (!ups || !ups->ptm_enabled)
 			return -EINVAL;
 
-- 
2.7.4


             reply	other threads:[~2020-05-21 13:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-21 13:37 Gustavo Pimentel [this message]
2020-05-21 20:50 ` [PATCH] PCI/PTM: Fix PTM switch capability evaluation Bjorn Helgaas
2020-05-22 14:46   ` Gustavo Pimentel
2020-05-27 21:40     ` Bjorn Helgaas

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=0b974380436d46ab3d8b7f4988f17e6f822079ac.1590068178.git.gustavo.pimentel@synopsys.com \
    --to=gustavo.pimentel@synopsys.com \
    --cc=Joao.Pinto@synopsys.com \
    --cc=Venkata.AdityaPaluri@synopsys.com \
    --cc=helgaas@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).