public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Jerome Pouiller <Jerome.Pouiller@silabs.com>
To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Kalle Valo" <kvalo@codeaurora.org>,
	"David S . Miller" <davem@davemloft.net>,
	"Jérôme Pouiller" <jerome.pouiller@silabs.com>
Subject: [PATCH v3 04/32] staging: wfx: wait for SCAN_CMPL after a SCAN_STOP
Date: Mon, 13 Sep 2021 15:01:35 +0200	[thread overview]
Message-ID: <20210913130203.1903622-5-Jerome.Pouiller@silabs.com> (raw)
In-Reply-To: <20210913130203.1903622-1-Jerome.Pouiller@silabs.com>

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

When the device has finished a scan request, it send a scan complete
("SCAN_COMPL") indication. It is also possible to abort a scan request
with a "SCAN_STOP" message. A SCAN_COMPL is also send in this case.

The driver limits the delay to make a scan request. A timeout happens
almost never but is theoretically possible. Currently, if it happens
the driver does not wait for the SCAN_COMPL. Then, when the driver
starts the next scan request, the device may return -EBUSY (scan
requests often occur back-to-back).

This patch give a chance to the device to send a SCAN_COMPL after a scan
timeout.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/scan.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/wfx/scan.c b/drivers/staging/wfx/scan.c
index fb47c7cddf2f..1e03b130049b 100644
--- a/drivers/staging/wfx/scan.c
+++ b/drivers/staging/wfx/scan.c
@@ -58,23 +58,31 @@ static int send_scan_req(struct wfx_vif *wvif,
 	reinit_completion(&wvif->scan_complete);
 	ret = hif_scan(wvif, req, start_idx, i - start_idx, &timeout);
 	if (ret) {
-		wfx_tx_unlock(wvif->wdev);
-		return -EIO;
+		ret = -EIO;
+		goto err_scan_start;
 	}
 	ret = wait_for_completion_timeout(&wvif->scan_complete, timeout);
-	if (req->channels[start_idx]->max_power != wvif->vif->bss_conf.txpower)
-		hif_set_output_power(wvif, wvif->vif->bss_conf.txpower);
-	wfx_tx_unlock(wvif->wdev);
 	if (!ret) {
 		dev_notice(wvif->wdev->dev, "scan timeout\n");
 		hif_stop_scan(wvif);
-		return -ETIMEDOUT;
+		ret = wait_for_completion_timeout(&wvif->scan_complete, 1 * HZ);
+		if (!ret)
+			dev_err(wvif->wdev->dev, "scan didn't stop\n");
+		ret = -ETIMEDOUT;
+		goto err_timeout;
 	}
 	if (wvif->scan_abort) {
 		dev_notice(wvif->wdev->dev, "scan abort\n");
-		return -ECONNABORTED;
+		ret = -ECONNABORTED;
+		goto err_timeout;
 	}
-	return i - start_idx;
+	ret = i - start_idx;
+err_timeout:
+	if (req->channels[start_idx]->max_power != wvif->vif->bss_conf.txpower)
+		hif_set_output_power(wvif, wvif->vif->bss_conf.txpower);
+err_scan_start:
+	wfx_tx_unlock(wvif->wdev);
+	return ret;
 }
 
 /*
-- 
2.33.0


  parent reply	other threads:[~2021-09-13 13:02 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13 13:01 [PATCH v3 00/32] staging/wfx: usual maintenance Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 01/32] staging: wfx: use abbreviated message for "incorrect sequence" Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 02/32] staging: wfx: do not send CAB while scanning Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 03/32] staging: wfx: ignore PS when STA/AP share same channel Jerome Pouiller
2021-09-13 13:01 ` Jerome Pouiller [this message]
2021-09-13 13:01 ` [PATCH v3 05/32] staging: wfx: avoid possible lock-up during scan Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 06/32] staging: wfx: drop unused argument from hif_scan() Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 07/32] staging: wfx: fix atomic accesses in wfx_tx_queue_empty() Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 08/32] staging: wfx: take advantage of wfx_tx_queue_empty() Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 09/32] staging: wfx: declare support for TDLS Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 10/32] staging: wfx: fix support for CSA Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 11/32] staging: wfx: relax the PDS existence constraint Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 12/32] staging: wfx: simplify API coherency check Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 13/32] staging: wfx: update with the firmware API 3.8 Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 14/32] staging: wfx: uniformize counter names Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 15/32] staging: wfx: fix misleading 'rate_id' usage Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 16/32] staging: wfx: declare variables at beginning of functions Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 17/32] staging: wfx: simplify hif_join() Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 18/32] staging: wfx: reorder function for slightly better eye candy Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 19/32] staging: wfx: fix error names Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 20/32] staging: wfx: apply naming rules in hif_tx_mib.c Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 21/32] staging: wfx: remove unused definition Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 22/32] staging: wfx: remove useless debug statement Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 23/32] staging: wfx: fix space after cast operator Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 24/32] staging: wfx: remove references to WFxxx in comments Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 25/32] staging: wfx: update files descriptions Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 26/32] staging: wfx: reformat comment Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 27/32] staging: wfx: avoid c99 comments Jerome Pouiller
2021-09-13 13:01 ` [PATCH v3 28/32] staging: wfx: fix comments styles Jerome Pouiller
2021-09-13 13:02 ` [PATCH v3 29/32] staging: wfx: remove useless comments after #endif Jerome Pouiller
2021-09-13 13:02 ` [PATCH v3 30/32] staging: wfx: explain the purpose of wfx_send_pds() Jerome Pouiller
2021-09-13 13:02 ` [PATCH v3 31/32] staging: wfx: indent functions arguments Jerome Pouiller
2021-09-13 13:02 ` [PATCH v3 32/32] staging: wfx: ensure IRQ is ready before enabling it Jerome Pouiller
2021-09-13 14:12 ` [PATCH v3 00/32] staging/wfx: usual maintenance Dan Carpenter

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=20210913130203.1903622-5-Jerome.Pouiller@silabs.com \
    --to=jerome.pouiller@silabs.com \
    --cc=davem@davemloft.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@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