Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp671665ybl; Wed, 8 Jan 2020 04:02:41 -0800 (PST) X-Google-Smtp-Source: APXvYqyC3sacYU6Sq7qWRijtRhw664jVgtNdV7NML0KNGkvhksao7zz3+IaH4A/jdIvQOZsxBjQA X-Received: by 2002:aca:4d58:: with SMTP id a85mr2587472oib.35.1578484961563; Wed, 08 Jan 2020 04:02:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578484961; cv=none; d=google.com; s=arc-20160816; b=ObD3O91g4hUPNT77uT6KVs9QYddYfoyj8djKXrCX+aq55yRMTw9oC/gJBN8h344+4i ehi7DrYJv0lqp9gaObEbczMquWgbLel4tmh+hkyw3IZYnkfvZ25eZBSfjd8+tNuz3jqZ x0nQMkW6FzxUARpMNrGoNKWZJwnhBzhqlqd29EnB+NHNJVRU+dlKdvltwGV0HKcCS5yy sYfdNKGJ63HJniYmGnD8JVI5iqb9GkQCJ1gmza/u6TVb18B1Hf5om8HWMIxktP1YeqSz O24UuFy0cTQTCeUrbTWd0bPyoz9DxooOEy+jRjrUfWYxqvdX4sIxeM6zcH6wWHmHZNH5 3KTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=A+4ekRz0HS4SHBbvZctSkuL3O7+gGpKDr+t7B4bqj6Y=; b=x9zwRVw/CpAWJ2Xgs6JWWWIrHGwJZYoS4WaT3uumqfuiE9jh8JQLpEP1OBz+zg35xw u0/XbD99RdOpmA9hY8TydHxz2Gc9Vai2/2pxIjHgneVRywoc8yAWE0M7RGQ4UGkJW4JZ TF34f4+bcZHCO01SnvJyL9jnZRLD7pOI/+i42eQcOoxSYM7KAY31G7aWiSzP1q63zHg4 12pyFgkcCL6W94AhVUFub5+uop7FOKNWiXIcl2xDF9a3J1VSMPZ1okrcCONUAmu6Dd0r B4uTBc0CvKmfIkJlF2Hukav0zZAzJbyyfYUFDoFS6f3GxKiztCKFkDYPe+Enn6mJ9o7H B8Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="r4VU/ksC"; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u130si1666502oif.94.2020.01.08.04.02.27; Wed, 08 Jan 2020 04:02:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="r4VU/ksC"; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726891AbgAHMCP (ORCPT + 99 others); Wed, 8 Jan 2020 07:02:15 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:45083 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726852AbgAHMCP (ORCPT ); Wed, 8 Jan 2020 07:02:15 -0500 Received: by mail-oi1-f194.google.com with SMTP id n16so2342423oie.12 for ; Wed, 08 Jan 2020 04:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=A+4ekRz0HS4SHBbvZctSkuL3O7+gGpKDr+t7B4bqj6Y=; b=r4VU/ksCnzNHMh0zR08v1hz8zZwHgRi0UJxiHPc0fKlFcrwRp4KWeCZLSXo6rASudc 9lH8W5HtDsIjSBEf+AaQtXEkTPDjflf4AO71AfCdKVr1MINNB/QMGeeIbQwjsD6b+LpJ XuemmdSawH1x2WN26ddDyOzBPdBZjphJgqDokv9CO5aoUPTm8cDpb5uW33s9yGA7iAXo Akkqi06MCQf64twoQjHIcR//X7uWgxFYaEBV38ngRDPHQO35idRX5oIyTS1qDetkzBAK QRxsJ4NZ5TDObHPg/PfPOC2tTqrg3P/FPj3Kc78DCpapu2JlpBne+TltGmCxoGzHX7Ye FHug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=A+4ekRz0HS4SHBbvZctSkuL3O7+gGpKDr+t7B4bqj6Y=; b=lvVrqljJTEdzxCZ/zbSsqfa3X49xB8CX2xfTwf5gTNqbClRNoPFha0WSf4z+kS78ax IsVbPWnKtRfVs9fZvGAPv0Qg8ekmMGjPSGOQPQ/Cwr54DTDHyqmlThMI5lnvCnmw4B5e ur86KtmQmtA852EZTGJdCcJnn4xbyiIqNr93OQhHed6M1sWDg6ecUIV97M7SKYk0liAZ bc09/Ze32ng2d0rizmNNEJyqTee1SYcUalr6FBhwUl4fsBw6+oJ+CWi9NYJ4didFVdBZ RqaQ+ZGdIq5asMOYQGs8ZnAoBA6xp9ptM2ffRpWdarPmZ50C5wzwZfMqlplY5Ph8GDCb JsVg== X-Gm-Message-State: APjAAAVRCmSLMUnYZVAfDjY+8deFRkVYY4kG5jsELtoxfS1m6yK9pG7e +AYb2AzD57JWU3si+g4yH8NXaIKM9tQNetnzc2o46R45tAHTiQ== X-Received: by 2002:a05:6808:3c2:: with SMTP id o2mr2729856oie.145.1578484933910; Wed, 08 Jan 2020 04:02:13 -0800 (PST) MIME-Version: 1.0 References: <20200108031957.22308-1-wgong@codeaurora.org> <20200108031957.22308-2-wgong@codeaurora.org> In-Reply-To: <20200108031957.22308-2-wgong@codeaurora.org> From: Justin Capella Date: Wed, 8 Jan 2020 04:02:02 -0800 Message-ID: Subject: Re: [PATCH v4 1/2] ath10k: add refcount for ath10k_core_restart To: Wen Gong Cc: ath10k , linux-wireless@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org I think this might break the "wedged" state. Would simply not taking action unless STATE ON avoid the problems with multiple calls to _restart? ie: diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 5ec16ce19b69..a6c11b2bc97c 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -2198,11 +2198,8 @@ static int ath10k_init_hw_params(struct ath10k *ar) return 0; } -static void ath10k_core_restart(struct work_struct *work) +static void inline _ath10k_core_restart(struct ath10k *ar) { - struct ath10k *ar = container_of(work, struct ath10k, restart_work); - int ret; - set_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags); /* Place a barrier to make sure the compiler doesn't reorder @@ -2232,14 +2229,28 @@ static void ath10k_core_restart(struct work_struct *work) */ cancel_work_sync(&ar->set_coverage_class_work); + ath10k_halt(ar); + ath10k_scan_finish(ar); + ieee80211_restart_hw(ar->hw); + + ret = ath10k_coredump_submit(ar); + if (ret) + ath10k_warn(ar, "failed to send firmware crash dump via devcoredump: %d", ret); + + complete(&ar->driver_recovery); +} + +static void ath10k_core_restart(struct work_struct *work) +{ + struct ath10k *ar = container_of(work, struct ath10k, restart_work); + int ret; + mutex_lock(&ar->conf_mutex); switch (ar->state) { case ATH10K_STATE_ON: ar->state = ATH10K_STATE_RESTARTING; - ath10k_halt(ar); - ath10k_scan_finish(ar); - ieee80211_restart_hw(ar->hw); + _ath10k_core_restart(ar); break; case ATH10K_STATE_OFF: /* this can happen if driver is being unloaded @@ -2262,13 +2273,6 @@ static void ath10k_core_restart(struct work_struct *work) } mutex_unlock(&ar->conf_mutex); - - ret = ath10k_coredump_submit(ar); - if (ret) - ath10k_warn(ar, "failed to send firmware crash dump via devcoredump: %d", - ret); - - complete(&ar->driver_recovery); } static void ath10k_core_set_coverage_class_work(struct work_struct *work) On Tue, Jan 7, 2020 at 7:20 PM Wen Gong wrote: > > When it has more than one restart_work queued meanwhile, the 2nd > restart_work is very esay to break the 1st restart work and lead > recovery fail. > > Add a ref count to allow only one restart work running untill > device successfully recovered. > > Tested with QCA6174 SDIO with firmware WLAN.RMH.4.4.1-00029. > > Signed-off-by: Wen Gong > --- > drivers/net/wireless/ath/ath10k/core.c | 13 +++++++++++++ > drivers/net/wireless/ath/ath10k/core.h | 2 ++ > drivers/net/wireless/ath/ath10k/mac.c | 1 + > 3 files changed, 16 insertions(+) > > diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c > index 91f131b87efc..0e31846e6c89 100644 > --- a/drivers/net/wireless/ath/ath10k/core.c > +++ b/drivers/net/wireless/ath/ath10k/core.c > @@ -2199,6 +2199,14 @@ static void ath10k_core_restart(struct work_struct *work) > { > struct ath10k *ar = container_of(work, struct ath10k, restart_work); > int ret; > + int restart_count; > + > + restart_count = atomic_add_return(1, &ar->restart_count); > + if (restart_count > 1) { > + ath10k_warn(ar, "can not restart, count: %d\n", restart_count); > + atomic_dec(&ar->restart_count); > + return; > + } > > set_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags); > > @@ -2231,6 +2239,11 @@ static void ath10k_core_restart(struct work_struct *work) > > mutex_lock(&ar->conf_mutex); > > + if (ar->state != ATH10K_STATE_ON) { > + ath10k_warn(ar, "state is not on: %d\n", ar->state); > + atomic_dec(&ar->restart_count); > + } > + > switch (ar->state) { > case ATH10K_STATE_ON: > ar->state = ATH10K_STATE_RESTARTING; > diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h > index e57b2e7235e3..810c99f2dc0e 100644 > --- a/drivers/net/wireless/ath/ath10k/core.h > +++ b/drivers/net/wireless/ath/ath10k/core.h > @@ -982,6 +982,8 @@ struct ath10k { > /* protected by conf_mutex */ > u8 ps_state_enable; > > + atomic_t restart_count; > + > bool nlo_enabled; > bool p2p; > > diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c > index 3856edba7915..bc1574145e66 100644 > --- a/drivers/net/wireless/ath/ath10k/mac.c > +++ b/drivers/net/wireless/ath/ath10k/mac.c > @@ -7208,6 +7208,7 @@ static void ath10k_reconfig_complete(struct ieee80211_hw *hw, > ath10k_info(ar, "device successfully recovered\n"); > ar->state = ATH10K_STATE_ON; > ieee80211_wake_queues(ar->hw); > + atomic_dec(&ar->restart_count); > } > > mutex_unlock(&ar->conf_mutex); > -- > 2.23.0