linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maya Erez <merez@codeaurora.org>
To: Kalle Valo <kvalo@codeaurora.org>
Cc: Alexei Avshalom Lazar <ailizaro@codeaurora.org>,
	linux-wireless@vger.kernel.org, wil6210@qti.qualcomm.com,
	Maya Erez <merez@codeaurora.org>
Subject: [PATCH 3/8] wil6210: take mem_lock for writing in crash dump collection
Date: Wed, 18 Dec 2019 15:59:42 +0200	[thread overview]
Message-ID: <20191218135947.5903-4-merez@codeaurora.org> (raw)
In-Reply-To: <20191218135947.5903-1-merez@codeaurora.org>

From: Alexei Avshalom Lazar <ailizaro@codeaurora.org>

On some crash dump cases mem_lock is already taken, error
returns and crash dump copy fails.
In this case wait until mem_lock available instead of failing
the operation.
Also take the mem_lock for writing to prevent other threads from
altering the state of the device while collecting crash dump.

Signed-off-by: Alexei Avshalom Lazar <ailizaro@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
---
 .../net/wireless/ath/wil6210/wil_crash_dump.c   | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/wil_crash_dump.c b/drivers/net/wireless/ath/wil6210/wil_crash_dump.c
index 1332eb8c831f..89c12cb2aaab 100644
--- a/drivers/net/wireless/ath/wil6210/wil_crash_dump.c
+++ b/drivers/net/wireless/ath/wil6210/wil_crash_dump.c
@@ -46,7 +46,7 @@ static int wil_fw_get_crash_dump_bounds(struct wil6210_priv *wil,
 
 int wil_fw_copy_crash_dump(struct wil6210_priv *wil, void *dest, u32 size)
 {
-	int i, rc;
+	int i;
 	const struct fw_map *map;
 	void *data;
 	u32 host_min, dump_size, offset, len;
@@ -62,9 +62,15 @@ int wil_fw_copy_crash_dump(struct wil6210_priv *wil, void *dest, u32 size)
 		return -EINVAL;
 	}
 
-	rc = wil_mem_access_lock(wil);
-	if (rc)
-		return rc;
+	down_write(&wil->mem_lock);
+
+	if (test_bit(wil_status_suspending, wil->status) ||
+	    test_bit(wil_status_suspended, wil->status)) {
+		wil_err(wil,
+			"suspend/resume in progress. cannot copy crash dump\n");
+		up_write(&wil->mem_lock);
+		return -EBUSY;
+	}
 
 	/* copy to crash dump area */
 	for (i = 0; i < ARRAY_SIZE(fw_mapping); i++) {
@@ -84,7 +90,8 @@ int wil_fw_copy_crash_dump(struct wil6210_priv *wil, void *dest, u32 size)
 		wil_memcpy_fromio_32((void * __force)(dest + offset),
 				     (const void __iomem * __force)data, len);
 	}
-	wil_mem_access_unlock(wil);
+
+	up_write(&wil->mem_lock);
 
 	return 0;
 }
-- 
2.23.0


  parent reply	other threads:[~2019-12-18 14:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-18 13:59 [PATCH 0/8] wil6210 patches Maya Erez
2019-12-18 13:59 ` [PATCH 1/8] wil6210: dump Rx status message on errors Maya Erez
2019-12-18 14:07   ` Kalle Valo
2019-12-18 14:31     ` Kalle Valo
2019-12-18 15:00       ` merez
2019-12-19 16:17   ` Kalle Valo
2019-12-18 13:59 ` [PATCH 2/8] wil6210: minimize the time that mem_lock is held Maya Erez
2019-12-18 13:59 ` Maya Erez [this message]
2019-12-18 13:59 ` [PATCH 4/8] wil6210: add verification for cid upper bound Maya Erez
2019-12-18 13:59 ` [PATCH 5/8] wil6210: reduce ucode_debug memory region Maya Erez
2019-12-18 13:59 ` [PATCH 6/8] wil6210: fix MID valid bits in Rx status message Maya Erez
2019-12-18 13:59 ` [PATCH 7/8] wil6210: support set_multicast_to_unicast cfg80211 operation Maya Erez
2019-12-18 13:59 ` [PATCH 8/8] wil6210: add support for set_cqm_rssi_config Maya Erez

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=20191218135947.5903-4-merez@codeaurora.org \
    --to=merez@codeaurora.org \
    --cc=ailizaro@codeaurora.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=wil6210@qti.qualcomm.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 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).