All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
To: linux-wireless@vger.kernel.org
Cc: brcm80211-dev-list@broadcom.com, brcm80211-dev-list@cypress.com,
	Arend van Spriel <arend.vanspriel@broadcom.com>,
	Franky Lin <franky.lin@broadcom.com>,
	Hante Meuleman <hante.meuleman@broadcom.com>,
	Wright Feng <wright.feng@cypress.com>,
	Kalle Valo <kvalo@codeaurora.org>,
	Amar Shankar <amsr@cypress.com>,
	Jia-Shyr Chuang <joseph.chuang@cypress.com>,
	Chi-Hsien Lin <chi-hsien.lin@cypress.com>
Subject: [PATCH V2 3/6] brcmfmac: reserve 2 credits for host tx control path
Date: Wed, 10 Jun 2020 10:21:03 -0500	[thread overview]
Message-ID: <20200610152106.175257-4-chi-hsien.lin@cypress.com> (raw)
In-Reply-To: <20200610152106.175257-1-chi-hsien.lin@cypress.com>

From: Amar Shankar <amsr@cypress.com>

It is observed that sometimes when sdiod is low in tx credits in low
rssi scenarios, the data path consumes all sdiod rx all credits and
there is no sdiod rx credit available for control path causing host
and card to go out of sync resulting in link loss between host and
card. So in order to prevent it some credits are reserved for control
path.

Note that TXCTL_CREDITS can't be larger than the firmware default
credit update threshold 2; otherwise there will be a deadlock for both
side waiting for each other.

Signed-off-by: Amar Shankar <amsr@cypress.com>
Signed-off-by: Jia-Shyr Chuang <joseph.chuang@cypress.com>
Signed-off-by: Chi-Hsien Lin <chi-hsien.lin@cypress.com>
---
 .../broadcom/brcm80211/brcmfmac/sdio.c        | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index ce6f15284277..4da40436b4ab 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -635,6 +635,8 @@ static const struct brcmf_firmware_mapping brcmf_sdio_fwnames[] = {
 	BRCMF_FW_ENTRY(CY_CC_43012_CHIP_ID, 0xFFFFFFFF, 43012)
 };
 
+#define TXCTL_CREDITS	2
+
 static void pkt_align(struct sk_buff *p, int len, int align)
 {
 	uint datalign;
@@ -648,8 +650,16 @@ static void pkt_align(struct sk_buff *p, int len, int align)
 /* To check if there's window offered */
 static bool data_ok(struct brcmf_sdio *bus)
 {
-	return (u8)(bus->tx_max - bus->tx_seq) != 0 &&
-	       ((u8)(bus->tx_max - bus->tx_seq) & 0x80) == 0;
+	/* Reserve TXCTL_CREDITS credits for txctl */
+	return (bus->tx_max - bus->tx_seq) > TXCTL_CREDITS &&
+	       ((bus->tx_max - bus->tx_seq) & 0x80) == 0;
+}
+
+/* To check if there's window offered */
+static bool txctl_ok(struct brcmf_sdio *bus)
+{
+	return (bus->tx_max - bus->tx_seq) != 0 &&
+	       ((bus->tx_max - bus->tx_seq) & 0x80) == 0;
 }
 
 static int
@@ -2655,7 +2665,7 @@ static void brcmf_sdio_dpc(struct brcmf_sdio *bus)
 	brcmf_sdio_clrintr(bus);
 
 	if (bus->ctrl_frame_stat && (bus->clkstate == CLK_AVAIL) &&
-	    data_ok(bus)) {
+	    txctl_ok(bus)) {
 		sdio_claim_host(bus->sdiodev->func1);
 		if (bus->ctrl_frame_stat) {
 			err = brcmf_sdio_tx_ctrlframe(bus,  bus->ctrl_frame_buf,
@@ -2663,6 +2673,9 @@ static void brcmf_sdio_dpc(struct brcmf_sdio *bus)
 			bus->ctrl_frame_err = err;
 			wmb();
 			bus->ctrl_frame_stat = false;
+			if (err)
+				brcmf_err("sdio ctrlframe tx failed err=%d\n",
+					  err);
 		}
 		sdio_release_host(bus->sdiodev->func1);
 		brcmf_sdio_wait_event_wakeup(bus);
-- 
2.25.0


  parent reply	other threads:[~2020-06-10 15:21 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-10 15:21 [PATCH V2 0/6] brcmfmac: flow control and p2p fix series Chi-Hsien Lin
2020-06-10 15:21 ` [PATCH V2 1/6] brcmfmac: allow credit borrowing for all access categories Chi-Hsien Lin
2020-07-14  9:47   ` Kalle Valo
2020-06-10 15:21 ` [PATCH V2 2/6] brcmfmac: increase message buffer size for control packets Chi-Hsien Lin
2020-06-10 15:21 ` Chi-Hsien Lin [this message]
2020-08-03 16:27   ` [PATCH V2 3/6] brcmfmac: reserve 2 credits for host tx control path Dmitry Osipenko
2020-08-04 11:08     ` Kalle Valo
2020-08-04 15:53       ` Dmitry Osipenko
2020-08-04 17:22         ` Kalle Valo
2020-08-05  8:24           ` Chi-Hsien Lin
2020-08-05 14:01             ` Dmitry Osipenko
2020-08-11  8:35               ` Wright Feng
2020-08-11 14:54                 ` Dmitry Osipenko
2020-08-12  4:03                   ` Wright Feng
2020-08-12 14:22                     ` Dmitry Osipenko
2020-08-13  3:03                       ` Wright Feng
2020-08-13 21:30                         ` Dmitry Osipenko
2020-06-10 15:21 ` [PATCH V2 4/6] brcmfmac: update tx status flags to sync with firmware Chi-Hsien Lin
2020-06-10 15:21 ` [PATCH V2 5/6] brcmfmac: fix throughput zero stalls on PM 1 mode due to credit map Chi-Hsien Lin
2020-06-10 15:21 ` [PATCH V2 6/6] brcmfmac: initialize the requested dwell time Chi-Hsien Lin
2020-06-22 15:04   ` Chi-Hsien Lin
2020-07-14  9:30   ` Kalle Valo

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=20200610152106.175257-4-chi-hsien.lin@cypress.com \
    --to=chi-hsien.lin@cypress.com \
    --cc=amsr@cypress.com \
    --cc=arend.vanspriel@broadcom.com \
    --cc=brcm80211-dev-list@broadcom.com \
    --cc=brcm80211-dev-list@cypress.com \
    --cc=franky.lin@broadcom.com \
    --cc=hante.meuleman@broadcom.com \
    --cc=joseph.chuang@cypress.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=wright.feng@cypress.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.