All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Greear <greearb@candelatech.com>
To: ath10k <ath10k@lists.infradead.org>
Subject: RFC: Possible napi deadlock work-around?
Date: Tue, 27 Feb 2018 17:09:26 -0800	[thread overview]
Message-ID: <33343f3f-0d5c-f17d-1606-281b94f3d333@candelatech.com> (raw)

Does this look like a good idea?


[greearb@ben-dt3 ath10k]$ git diff
diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index 72b4495..c7ba49f 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -1205,6 +1205,7 @@ struct ath10k {
         /* NAPI */
         struct net_device napi_dev;
         struct napi_struct napi;
+       bool napi_enabled;

         struct work_struct stop_scan_work;

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index 398e413..fad4fb9 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -1956,6 +1956,7 @@ static int ath10k_pci_hif_start(struct ath10k *ar)
         ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif start\n");

         napi_enable(&ar->napi);
+       ar->napi_enabled = true;

         ath10k_pci_irq_enable(ar);
         ath10k_pci_rx_post(ar);
@@ -2086,8 +2087,23 @@ static void ath10k_pci_hif_stop(struct ath10k *ar)
         ath10k_pci_irq_disable(ar);
         ath10k_pci_irq_sync(ar);
         ath10k_pci_flush(ar);
-       napi_synchronize(&ar->napi);
-       napi_disable(&ar->napi);
+
+       /* Calling napi_disable twice in a row (w/out starting it and/or without
+        * having NAPI active leads to deadlock because napi_disable sets
+        * NAPI_STATE_SCHED and NAPI_STATE_NPSVC when it returns, as far as I
+        * can tell.  So, guard this call to napi_disable.  I believe the
+        * failure case is something like this:
+        * rmmod ath10k_pci ath10k_core
+        *   Firmware crashes before hif_stop is called by the rmmod path
+        *   The crash handling logic calls hif_stop
+         *   Then rmmod gets around to calling hif_stop, but spins endlessly
+        *   in napi_synchronize.
+        */
+       if (ar->napi_enabled) {
+               napi_synchronize(&ar->napi);
+               napi_disable(&ar->napi);
+               ar->napi_enabled = false;
+       }

         spin_lock_irqsave(&ar_pci->ps_lock, flags);
         WARN_ON(ar_pci->ps_wake_refcount > 0);
[greearb@ben-dt3 ath10k]$

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

                 reply	other threads:[~2018-02-28  1:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=33343f3f-0d5c-f17d-1606-281b94f3d333@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=ath10k@lists.infradead.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.