Thread (19 messages) 19 messages, 5 authors, 2021-10-06

Re: [PATCH v2 2/2] mwifiex: Try waking the firmware until we get an interrupt

From: Jonas Dreßler <hidden>
Date: 2021-09-30 21:07:23
Also in: linux-pci, linux-wireless, lkml, stable

On 9/30/21 10:58 PM, Andy Shevchenko wrote:
On Thu, Sep 30, 2021 at 08:04:00PM +0200, Jonas Dreßler wrote:
quoted
On 9/22/21 1:19 PM, Andy Shevchenko wrote:
quoted
On Tue, Sep 14, 2021 at 01:48:13PM +0200, Jonas Dreßler wrote:
...
quoted
quoted
quoted
+	do {
+		if (mwifiex_write_reg(adapter, reg->fw_status, FIRMWARE_READY_PCIE)) {
+			mwifiex_dbg(adapter, ERROR,
+				    "Writing fw_status register failed\n");
+			return -EIO;
+		}
+
+		n_tries++;
+
+		if (n_tries <= N_WAKEUP_TRIES_SHORT_INTERVAL)
+			usleep_range(400, 700);
+		else
+			msleep(10);
+	} while (n_tries <= N_WAKEUP_TRIES_SHORT_INTERVAL + N_WAKEUP_TRIES_LONG_INTERVAL &&
+		 READ_ONCE(adapter->int_status) == 0);
Can't you use read_poll_timeout() twice instead of this custom approach?
I've tried this now, but read_poll_timeout() is not ideal for our use-case.
What we'd need would be read->sleep->poll->repeat instead of
read->poll->sleep->repeat. With read_poll_timeout() we always end up doing
one more (unnecessary) write.
First of all, there is a parameter to get sleep beforehand.
Sleeping beforehand will sleep before doing the first write, so that's 
just wasted time.
Second, what is the problem with having one write more or less?
Your current code doesn't guarantee this either. It only decreases
probability of such scenario. Am I wrong?
Indeed my approach just decreases the probability and we sometimes end 
up writing twice to wakeup the card, but it would kinda bug me if we'd 
always do one write too much.

Anyway, if you still prefer the read_poll_timeout() solution I'd be 
alright with that of course.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help