Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3488773imu; Sun, 11 Nov 2018 16:14:37 -0800 (PST) X-Google-Smtp-Source: AJdET5ePsNua1q3pS8shHMnGEUKd23rb9FBErexx77a3Ng6jkwvLRXHP+J97RMAt7Y5xMrEDVypM X-Received: by 2002:a17:902:8e81:: with SMTP id bg1-v6mr17798937plb.192.1541981677217; Sun, 11 Nov 2018 16:14:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981677; cv=none; d=google.com; s=arc-20160816; b=TJmD3uGBm9b2CvS21Y8a4eb0dNIZrX6iHmK7ihZEdDoBTyGIB7OD3rWPZ4kVjV9rTl VOWmm6khuNRUxX/5PC97TeH+eHFAXJqErWpvAsxM5x9KwpyMCLAqGYPvzEoFnKs7rDGl 5xQXjq8CFY2TMcJEvRottMBfHibACAYs5RjSFQTaoIAjHRN8ArxjUL/scTyC/Z7vafnv QeqMSeEgCqhNNDf4OhepTdEi5E4yg3AVvAXKuyiH1neWsB8h400UFN881EOljYi/5q9u 6gCIvNpeUqmLuiyDHZ4Y7IHK7wSgDBRPisQwUY9UgSZkJ2KEU0tqXKyhjCjgJGpMVXoL HBLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bs+rLUFrwJrclBII7wqBQ2NiRYd8hI+CUcJitnF0r1A=; b=MsdcqiD0+QFToR1Z6BKbCy90mdUqQw6JtGlXh9Rv8Ep7tIwSmpQ9gk89WkGPAiwwDM lcr4RGyl2+jRgqixOeguZeaYeW6scGrPQGdRh4jrN0iv+NjSMuIScSfQk0ah+dfWOm+I 8rQieqP0RY3Ls+/0c9GbJD3rnGqKO3sKRqT6+8/r2FUSg9FRixLAeWq+CeGKx8s8WMho tH7byMHVaIkh4WHYLiYNKFS/n6ryDBVbixYWfFfs//ZpQ4BaZyq4fXgHtL9J64GD069v 98l/whv9osQl/31oc2qWz21mjbYNjb5AZ3X7ic4gs/c0eBW+wuaKzpZdc22dA5j1xfCu 2qYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NTcaZNoL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 10-v6si13704525pgo.486.2018.11.11.16.14.22; Sun, 11 Nov 2018 16:14:37 -0800 (PST) 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=NTcaZNoL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730737AbeKLKEa (ORCPT + 99 others); Mon, 12 Nov 2018 05:04:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:60196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730397AbeKLIRO (ORCPT ); Mon, 12 Nov 2018 03:17:14 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 560AE215EA; Sun, 11 Nov 2018 22:27:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975238; bh=IlcIFchbqj0e5+EjQVQ68duHljTyg53ea/P0LbuuaJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NTcaZNoLIQkpwzdbcdUBW+d8TkbeSjn7KeKgYVd6TWevvDrMUKaBSTloN4SkwMwMy 3epG9Wc4mF31nw3sRp/2ebGPx32MKbD0k5OqV1issXV7KOKHGXkansW5VBuH3hAxwA xGp9Irk5cyCn7uFYdrHwE7ve2pVYzGnNlZQh3U6E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eyal Reizer , Tony Lindgren , Kalle Valo , Sasha Levin Subject: [PATCH 4.19 077/361] wlcore: Fix BUG with clear completion on timeout Date: Sun, 11 Nov 2018 14:17:04 -0800 Message-Id: <20181111221630.803995370@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/ti/wlcore/main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) --- 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 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 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 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 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 @@ err: 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; }