All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	andreas.noever@gmail.com, michael.jamet@intel.com,
	YehezkelShB@gmail.com, linux-usb@vger.kernel.org
Subject: [PATCH AUTOSEL 5.15 13/46] thunderbolt: Add back Intel Falcon Ridge end-to-end flow control workaround
Date: Sun,  9 Oct 2022 18:18:38 -0400	[thread overview]
Message-ID: <20221009221912.1217372-13-sashal@kernel.org> (raw)
In-Reply-To: <20221009221912.1217372-1-sashal@kernel.org>

From: Mika Westerberg <mika.westerberg@linux.intel.com>

[ Upstream commit 54669e2f17cb5a4c41ade89427f074dc22cecb17 ]

As we are now enabling full end-to-end flow control to the Thunderbolt
networking driver, in order for it to work properly on second generation
Thunderbolt hardware (Falcon Ridge), we need to add back the workaround
that was removed with commit 53f13319d131 ("thunderbolt: Get rid of E2E
workaround"). However, this time we only apply it for Falcon Ridge
controllers as a form of an additional quirk. For non-Falcon Ridge this
does nothing.

While there fix a typo 'reqister' -> 'register' in the comment.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/thunderbolt/nhi.c | 49 +++++++++++++++++++++++++++++++++------
 1 file changed, 42 insertions(+), 7 deletions(-)

diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index c73da0532be4..aa6cf7f2f438 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -25,7 +25,11 @@
 #define RING_TYPE(ring) ((ring)->is_tx ? "TX ring" : "RX ring")
 
 #define RING_FIRST_USABLE_HOPID	1
-
+/*
+ * Used with QUIRK_E2E to specify an unused HopID the Rx credits are
+ * transferred.
+ */
+#define RING_E2E_RESERVED_HOPID	RING_FIRST_USABLE_HOPID
 /*
  * Minimal number of vectors when we use MSI-X. Two for control channel
  * Rx/Tx and the rest four are for cross domain DMA paths.
@@ -35,7 +39,9 @@
 
 #define NHI_MAILBOX_TIMEOUT	500 /* ms */
 
+/* Host interface quirks */
 #define QUIRK_AUTO_CLEAR_INT	BIT(0)
+#define QUIRK_E2E		BIT(1)
 
 static int ring_interrupt_index(struct tb_ring *ring)
 {
@@ -455,8 +461,18 @@ static void ring_release_msix(struct tb_ring *ring)
 
 static int nhi_alloc_hop(struct tb_nhi *nhi, struct tb_ring *ring)
 {
+	unsigned int start_hop = RING_FIRST_USABLE_HOPID;
 	int ret = 0;
 
+	if (nhi->quirks & QUIRK_E2E) {
+		start_hop = RING_FIRST_USABLE_HOPID + 1;
+		if (ring->flags & RING_FLAG_E2E && !ring->is_tx) {
+			dev_dbg(&nhi->pdev->dev, "quirking E2E TX HopID %u -> %u\n",
+				ring->e2e_tx_hop, RING_E2E_RESERVED_HOPID);
+			ring->e2e_tx_hop = RING_E2E_RESERVED_HOPID;
+		}
+	}
+
 	spin_lock_irq(&nhi->lock);
 
 	if (ring->hop < 0) {
@@ -466,7 +482,7 @@ static int nhi_alloc_hop(struct tb_nhi *nhi, struct tb_ring *ring)
 		 * Automatically allocate HopID from the non-reserved
 		 * range 1 .. hop_count - 1.
 		 */
-		for (i = RING_FIRST_USABLE_HOPID; i < nhi->hop_count; i++) {
+		for (i = start_hop; i < nhi->hop_count; i++) {
 			if (ring->is_tx) {
 				if (!nhi->tx_rings[i]) {
 					ring->hop = i;
@@ -481,6 +497,11 @@ static int nhi_alloc_hop(struct tb_nhi *nhi, struct tb_ring *ring)
 		}
 	}
 
+	if (ring->hop > 0 && ring->hop < start_hop) {
+		dev_warn(&nhi->pdev->dev, "invalid hop: %d\n", ring->hop);
+		ret = -EINVAL;
+		goto err_unlock;
+	}
 	if (ring->hop < 0 || ring->hop >= nhi->hop_count) {
 		dev_warn(&nhi->pdev->dev, "invalid hop: %d\n", ring->hop);
 		ret = -EINVAL;
@@ -1094,12 +1115,26 @@ static void nhi_shutdown(struct tb_nhi *nhi)
 
 static void nhi_check_quirks(struct tb_nhi *nhi)
 {
-	/*
-	 * Intel hardware supports auto clear of the interrupt status
-	 * reqister right after interrupt is being issued.
-	 */
-	if (nhi->pdev->vendor == PCI_VENDOR_ID_INTEL)
+	if (nhi->pdev->vendor == PCI_VENDOR_ID_INTEL) {
+		/*
+		 * Intel hardware supports auto clear of the interrupt
+		 * status register right after interrupt is being
+		 * issued.
+		 */
 		nhi->quirks |= QUIRK_AUTO_CLEAR_INT;
+
+		switch (nhi->pdev->device) {
+		case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_NHI:
+		case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI:
+			/*
+			 * Falcon Ridge controller needs the end-to-end
+			 * flow control workaround to avoid losing Rx
+			 * packets when RING_FLAG_E2E is set.
+			 */
+			nhi->quirks |= QUIRK_E2E;
+			break;
+		}
+	}
 }
 
 static int nhi_init_msi(struct tb_nhi *nhi)
-- 
2.35.1


  parent reply	other threads:[~2022-10-09 22:35 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-09 22:18 [PATCH AUTOSEL 5.15 01/46] wifi: rtw88: phy: fix warning of possible buffer overflow Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 02/46] wifi: brcmfmac: fix invalid address access when enabling SCAN log level Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 03/46] bpftool: Clear errno after libcap's checks Sasha Levin
2022-10-09 22:18 ` [Intel-wired-lan] [PATCH AUTOSEL 5.15 04/46] ice: set tx_tstamps when creating new Tx rings via ethtool Sasha Levin
2022-10-09 22:18   ` Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 05/46] net: ethernet: ti: davinci_mdio: Add workaround for errata i2329 Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 06/46] openvswitch: Fix double reporting of drops in dropwatch Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 07/46] openvswitch: Fix overreporting " Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 08/46] tcp: annotate data-race around tcp_md5sig_pool_populated Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 09/46] micrel: ksz8851: fixes struct pointer issue Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 10/46] genetlink: hold read cb_lock during iteration of genl_fam_idr in genl_bind() Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 11/46] x86/mce: Retrieve poison range from hardware Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 12/46] wifi: ath9k: avoid uninit memory read in ath9k_htc_rx_msg() Sasha Levin
2022-10-09 22:18 ` Sasha Levin [this message]
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 14/46] xfrm: Update ipcomp_scratches with NULL when freed Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 15/46] net: broadcom: Fix return type for implementation of Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 16/46] net: xscale: Fix return type for implementation of ndo_start_xmit Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 17/46] net: lantiq_etop: " Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 18/46] net: ftmac100: fix endianness-related issues from 'sparse' Sasha Levin
2022-10-09 22:18 ` [Intel-wired-lan] [PATCH AUTOSEL 5.15 19/46] iavf: Fix race between iavf_close and iavf_reset_task Sasha Levin
2022-10-09 22:18   ` Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 20/46] wifi: brcmfmac: fix use-after-free bug in brcmf_netdev_start_xmit() Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 21/46] Bluetooth: btintel: Mark Intel controller to support LE_STATES quirk Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 22/46] regulator: core: Prevent integer underflow Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 23/46] wifi: mt76: mt7921: reset msta->airtime_ac while clearing up hw value Sasha Levin
2022-10-09 22:18   ` Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 24/46] Bluetooth: L2CAP: initialize delayed works at l2cap_chan_create() Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 25/46] net: davicom: Fix return type of dm9000_start_xmit Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 26/46] net: ethernet: ti: davinci_emac: Fix return type of emac_dev_xmit Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 27/46] net: ethernet: litex: Fix return type of liteeth_start_xmit Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 28/46] net: korina: Fix return type of korina_send_packet Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 29/46] net: wwan: iosm: Fix return type of ipc_wwan_link_transmit Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 30/46] net: sfp: re-implement soft state polling setup Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 31/46] net: sfp: move quirk handling into sfp.c Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 32/46] net: sfp: move Alcatel Lucent 3FE46541AA fixup Sasha Levin
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 33/46] net/sched: taprio: taprio_dump and taprio_change are protected by rtnl_mutex Sasha Levin
2022-10-10 13:33   ` Vladimir Oltean
2022-10-09 22:18 ` [PATCH AUTOSEL 5.15 34/46] Bluetooth: hci_sysfs: Fix attempting to call device_add multiple times Sasha Levin
2022-10-09 22:19 ` [PATCH AUTOSEL 5.15 35/46] wifi: ath10k: reset pointer after memory free to avoid potential use-after-free Sasha Levin
2022-10-09 22:19   ` Sasha Levin
2022-10-09 22:19 ` [PATCH AUTOSEL 5.15 36/46] can: bcm: check the result of can_send() in bcm_can_tx() Sasha Levin
2022-10-09 22:19 ` [PATCH AUTOSEL 5.15 37/46] wifi: rt2x00: don't run Rt5592 IQ calibration on MT7620 Sasha Levin
2022-10-09 22:19 ` [PATCH AUTOSEL 5.15 38/46] wifi: rt2x00: set correct TX_SW_CFG1 MAC register for MT7620 Sasha Levin
2022-10-09 22:19 ` [PATCH AUTOSEL 5.15 39/46] wifi: rt2x00: set VGC gain for both chains of MT7620 Sasha Levin
2022-10-09 22:19 ` [PATCH AUTOSEL 5.15 40/46] wifi: rt2x00: set SoC wmac clock register Sasha Levin
2022-10-09 22:19 ` [PATCH AUTOSEL 5.15 41/46] wifi: rt2x00: correctly set BBP register 86 for MT7620 Sasha Levin
2022-10-09 22:19 ` [PATCH AUTOSEL 5.15 42/46] hwmon: (sht4x) do not overflow clamping operation on 32-bit platforms Sasha Levin
2022-10-09 22:19 ` [PATCH AUTOSEL 5.15 43/46] net: If sock is dead don't access sock's sk_wq in sk_stream_wait_memory Sasha Levin
2022-10-09 22:19 ` [PATCH AUTOSEL 5.15 44/46] Bluetooth: L2CAP: Fix user-after-free Sasha Levin
2022-10-09 22:19 ` [PATCH AUTOSEL 5.15 45/46] libbpf: Fix overrun in netlink attribute iteration Sasha Levin
2022-10-09 22:19 ` [PATCH AUTOSEL 5.15 46/46] r8152: Rate limit overflow messages Sasha Levin

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=20221009221912.1217372-13-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=michael.jamet@intel.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=stable@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 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.