Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp177847imd; Wed, 31 Oct 2018 16:53:26 -0700 (PDT) X-Google-Smtp-Source: AJdET5eQYY6tnXy4hdZhaElH6OypPWlcMFO9gB/AWyRRLfbQxfpNqYsWNr8UPjsPk/32nA3kCiMQ X-Received: by 2002:a17:902:9004:: with SMTP id a4-v6mr5346531plp.334.1541030006051; Wed, 31 Oct 2018 16:53:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541030006; cv=none; d=google.com; s=arc-20160816; b=SsXbnPC80wgJGZq8qy8TI5vsKPYy2RtdMxdihiFMWE/IqTq7A2V6rwdBcioFxoWdHm J5pr344T/zt1N8R4g22YqsKqnIfiJ0aENa604wZcMOx+fIblSO4MwHZCR0aQORY7gdSD HTl2iBJ4IFBXvaDc8L0PazZY/+tj7HnLa7txZ9AltwOs5yhMx0j5Ru/0cu7WKHfrYufY AIiE/pBhteZp1YpmQvLzB14OUokMW8dCZgL4/b3ICN7qCxqoQWuTTCUDIkhW0fBIG74u DzmE0R/ONW0ffkfPmcnBM17tOf5hG6YQKJF82aFYjX0pzOuwmsOoO9q/1nD5F6JZsREG hgxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=peXCdAysJgnb2SZwtNM9vKVTTtuim41CKhl2LABhhDA=; b=wXE2x+CvJ8qzNoCI5gJoAF2DRViKOMa8TknDAy9mcg3wIWeC31xIX91u1zzikLPfd9 rjFsGzKbesZ9RKsW1Axqa2O7gXW6yflLJdPpvehswFvUXRvIAWgLxQFYxq3iUkEpEQbm OkIkNA27ouWwRWM4W12Q1jnosFeYjtO8MFJUuQ7P3ikT8GJzqk8YNz9Lhe6p7YMJF54i OYesKfIUId5uxveXRfwC3ryGcVlA+a6DGEZv+D2abNXFKM3EPLoSe4+qTJwWzv7IZivq /exCG+sXJIupb83V1OuDJss2kRFIltHBrfK9aLU/5NZ9Ub5XlwQ19tNx9u5+hmpPs4i5 2FKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zh2qj7wx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g38-v6si24681780pgl.248.2018.10.31.16.53.11; Wed, 31 Oct 2018 16:53:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=zh2qj7wx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727950AbeKAIGZ (ORCPT + 99 others); Thu, 1 Nov 2018 04:06:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:53232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727808AbeKAIGV (ORCPT ); Thu, 1 Nov 2018 04:06:21 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3F4802084A; Wed, 31 Oct 2018 23:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027170; bh=h8ZgqYChEDLjxdtBXxa9iMcaCugKcEZUbEqxY+Wl6z4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zh2qj7wx/wL9MpTL0qUkYn7uQsyrDBf5nDI7Wazscx5+vfGwqwUyAiwr1pJBKVGqY TeTtfmslqLIDZwHob5j5b014WiBdYm3EovA7jmA2QqVBngTQ4Uxodbp93QPBqkr9Dd lcghlGGuiKQdL/UQQJWRFPyDB4vsPPmCeR5HyzoI= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tony Lindgren , Eyal Reizer , Kalle Valo , Sasha Levin Subject: [PATCH AUTOSEL 4.19 031/146] wlcore: Fix BUG with clear completion on timeout Date: Wed, 31 Oct 2018 19:03:46 -0400 Message-Id: <20181031230541.28822-31-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tony Lindgren [ Upstream commit 4e651bad848955d88b29a568bfbfb4b831270e16 ] We do not currently clear wl->elp_compl on ELP timeout and we have bogus lingering pointer that wlcore_irq then will try to access after recovery is done: BUG: spinlock bad magic on CPU#1, irq/255-wl12xx/580 ... (spin_dump) from [] (do_raw_spin_lock+0xc8/0x124) (do_raw_spin_lock) from [] (_raw_spin_lock_irqsave+0x68/0x74) (_raw_spin_lock_irqsave) from [] (complete+0x24/0x58) (complete) from [] (wlcore_irq+0x48/0x17c [wlcore]) (wlcore_irq [wlcore]) from [] (irq_thread_fn+0x2c/0x64) (irq_thread_fn) from [] (irq_thread+0x148/0x290) (irq_thread) from [] (kthread+0x160/0x17c) (kthread) from [] (ret_from_fork+0x14/0x20) ... After that the system will hang. Let's fix this by adding a flag for recovery and moving the recovery work call to to the error handling section. And we want to set WL1271_FLAG_INTENDED_FW_RECOVERY and actually clear it too in wl1271_recovery_work() and just downgrade the error to a warning to prevent overly verbose output. Cc: Eyal Reizer Signed-off-by: Tony Lindgren Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin --- drivers/net/wireless/ti/wlcore/main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c index 89b0d0fade9f..19e3c5a0b715 100644 --- a/drivers/net/wireless/ti/wlcore/main.c +++ b/drivers/net/wireless/ti/wlcore/main.c @@ -957,6 +957,8 @@ static void wl1271_recovery_work(struct work_struct *work) BUG_ON(wl->conf.recovery.bug_on_recovery && !test_bit(WL1271_FLAG_INTENDED_FW_RECOVERY, &wl->flags)); + clear_bit(WL1271_FLAG_INTENDED_FW_RECOVERY, &wl->flags); + if (wl->conf.recovery.no_recovery) { wl1271_info("No recovery (chosen on module load). Fw will remain stuck."); goto out_unlock; @@ -6710,6 +6712,7 @@ static int __maybe_unused wlcore_runtime_resume(struct device *dev) int ret; unsigned long start_time = jiffies; bool pending = false; + bool recovery = false; /* Nothing to do if no ELP mode requested */ if (!test_bit(WL1271_FLAG_IN_ELP, &wl->flags)) @@ -6726,7 +6729,7 @@ static int __maybe_unused wlcore_runtime_resume(struct device *dev) ret = wlcore_raw_write32(wl, HW_ACCESS_ELP_CTRL_REG, ELPCTRL_WAKE_UP); if (ret < 0) { - wl12xx_queue_recovery_work(wl); + recovery = true; goto err; } @@ -6734,11 +6737,12 @@ static int __maybe_unused wlcore_runtime_resume(struct device *dev) ret = wait_for_completion_timeout(&compl, msecs_to_jiffies(WL1271_WAKEUP_TIMEOUT)); if (ret == 0) { - wl1271_error("ELP wakeup timeout!"); - wl12xx_queue_recovery_work(wl); + wl1271_warning("ELP wakeup timeout!"); /* Return no error for runtime PM for recovery */ - return 0; + ret = 0; + recovery = true; + goto err; } } @@ -6753,6 +6757,12 @@ static int __maybe_unused wlcore_runtime_resume(struct device *dev) spin_lock_irqsave(&wl->wl_lock, flags); wl->elp_compl = NULL; spin_unlock_irqrestore(&wl->wl_lock, flags); + + if (recovery) { + set_bit(WL1271_FLAG_INTENDED_FW_RECOVERY, &wl->flags); + wl12xx_queue_recovery_work(wl); + } + return ret; } -- 2.17.1