From patchwork Mon May 15 21:25:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 9727993 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AFDE06028A for ; Mon, 15 May 2017 21:26:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD1642843F for ; Mon, 15 May 2017 21:26:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1CD12882F; Mon, 15 May 2017 21:26:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4D63E289A8 for ; Mon, 15 May 2017 21:26:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ShJCZju0JMQ3Z5A03ugyTMbhnivk0yL+IDsANRIsGVc=; b=VyWO44RmRwPs5ItZFeo57VVSBt AMYl6/P0sF5nA8SAOcEfFnoJErHtY6O313C/7v8wah2zYcNWZ6jSGuGn7GtZaceSpcjQvKn76xggK +vCTtHt1dYvBAejHR8PLLZ11Sga/1JyigAQ0fr44SIZhANae85vK/ZhJUMdqkmRvFRavOHRwFctU6 vlhAqn1SMXLg3qC2ixSB6uUheWBjRowBmYO1HCG6OTRsvcQSgCDd+BgaihJ2QfkVzLZL7tKAZ9vMX M4MVJ3vKMTgzhhwPTB8ywcBRkdrm8Rji3TAF5pktIDeWrKRdT0W+TDa4JQzH9OZEAfgMYSf1pKUKF Rx8cRkWA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dANVL-0002oY-HU; Mon, 15 May 2017 21:26:11 +0000 Received: from mail2.candelatech.com ([208.74.158.173]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dANVE-0002jO-AK for ath10k@lists.infradead.org; Mon, 15 May 2017 21:26:07 +0000 Received: from ben-dt3.candelatech.com (firewall.candelatech.com [50.251.239.81]) by mail2.candelatech.com (Postfix) with ESMTP id 700A640A539; Mon, 15 May 2017 14:25:44 -0700 (PDT) From: greearb@candelatech.com To: ath10k@lists.infradead.org Subject: [PATCH 2/3] ath10k: Fix napi related crash when otp fails. Date: Mon, 15 May 2017 14:25:39 -0700 Message-Id: <1494883540-18558-2-git-send-email-greearb@candelatech.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1494883540-18558-1-git-send-email-greearb@candelatech.com> References: <1494883540-18558-1-git-send-email-greearb@candelatech.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170515_142604_422263_A91F9E92 X-CRM114-Status: UNSURE ( 9.79 ) X-CRM114-Notice: Please train this message. X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ben Greear MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Greear The failure case is something like this: otp fails (probably because BMI timeout was too short) so core_start fails so the entire firmware load fails..but since it was not ever started properly, then it is not stopped as far as PCI is concerned. So, napi is not released. A bit later, maybe, the driver succeeds in loading and then we have a BUG splat. ------------[ cut here ]------------ kernel BUG at /home/greearb/git/linux-4.9.dev.y/include/linux/netdevice.h:515! invalid opcode: 0000 [#1] PREEMPT SMP Modules linked in: nf_conntrack_netlink nf_conntrack nfnetlink nf_defrag_ipv4 bridge ath10k_pci ath10k_core 8021q garp mrp stp llc bnep bluetooth fuse macv] CPU: 1 PID: 3651 Comm: wpa_supplicant Not tainted 4.9.27+ #35 Hardware name: To be filled by O.E.M. To be filled by O.E.M./ChiefRiver, BIOS 4.6.5 06/07/2013 task: ffff8802111f0000 task.stack: ffffc90001fb4000 RIP: 0010:[] [] ath10k_pci_hif_power_up+0x173/0x180 [ath10k_pci] RSP: 0018:ffffc90001fb7c30 EFLAGS: 00010246 RAX: 0000000000000008 RBX: ffff880212bc2bc0 RCX: 0000000000082004 RDX: ffffc9000d282000 RSI: ffffc9000d282000 RDI: 000000000fd0a000 RBP: ffffc90001fb7c40 R08: 0000000000200000 R09: 0000000000000101 R10: 0000000000000d00 R11: 0000000000000003 R12: 0000000000082000 R13: ffff880212beaef8 R14: 0000000000000000 R15: ffff8802134c1118 FS: 00007f476575c800(0000) GS:ffff88021e240000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f3da950b490 CR3: 0000000212b5a000 CR4: 00000000001406e0 Stack: ffff880212bc2bc0 ffff880212bc0700 ffffc90001fb7c68 ffffffffa1429281 ffff8802134c0000 ffff880212bc0700 0000000000000000 ffffc90001fb7c90 ffffffffa07cb818 ffff8802134c0000 ffff880212bc0700 0000000000000000 Call Trace: [] ath10k_start+0x51/0x5c0 [ath10k_core] [] drv_start+0x38/0x140 [mac80211] [] ieee80211_do_open+0x2c5/0x990 [mac80211] [] ieee80211_open+0x50/0x60 [mac80211] [] __dev_open+0xaa/0x120 [] __dev_change_flags+0x98/0x160 [] dev_change_flags+0x24/0x60 [] devinet_ioctl+0x5ee/0x6c0 [] inet_ioctl+0x4b/0x70 [] sock_do_ioctl+0x20/0x50 [] sock_ioctl+0x1d6/0x2a0 [] do_vfs_ioctl+0x8b/0x5b0 [] ? __sys_recvmsg+0x3d/0x70 [] SyS_ioctl+0x74/0x80 [] entry_SYSCALL_64_fastpath+0x1e/0xad Code: ff ff ff 89 c2 48 89 df 48 c7 c6 10 d3 49 a1 e8 34 1d f9 ff 48 89 df e8 2c f9 ff ff 44 89 e0 c6 83 0e 74 02 00 01 5b 41 5c 5d c3 <0f> 0b 66 66 2e 0f RIP [] ath10k_pci_hif_power_up+0x173/0x180 [ath10k_pci] RSP ---[ end trace b6dede286ed70e39 ]--- The BUG in question is this: /** * napi_enable - enable NAPI scheduling * @n: NAPI context * * Resume NAPI from being scheduled on this context. * Must be paired with napi_disable. */ static inline void napi_enable(struct napi_struct *n) { BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state)); smp_mb__before_atomic(); clear_bit(NAPI_STATE_SCHED, &n->state); clear_bit(NAPI_STATE_NPSVC, &n->state); } Signed-off-by: Ben Greear --- drivers/net/wireless/ath/ath10k/core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index a715677..ad544b2 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -1806,7 +1806,7 @@ static int ath10k_core_pre_cal_config(struct ath10k *ar) ret = ath10k_download_and_run_otp(ar); if (ret) { - ath10k_err(ar, "failed to run otp: %d\n", ret); + ath10k_err(ar, "failed to run otp: %d (pre-cal-config)\n", ret); return ret; } @@ -1860,7 +1860,7 @@ static int ath10k_download_cal_data(struct ath10k *ar) ret = ath10k_download_and_run_otp(ar); if (ret) { - ath10k_err(ar, "failed to run otp: %d\n", ret); + ath10k_err(ar, "failed to run otp: %d (download-cal-data)\n", ret); return ret; } @@ -2783,7 +2783,11 @@ static void ath10k_core_register_work(struct work_struct *work) status = ath10k_core_probe_fw(ar); if (status) { - ath10k_err(ar, "could not probe fw (%d)\n", status); + ath10k_err(ar, "could not probe fw (%d), releasing napi\n", status); + /* Make sure that NAPI state is cleaned up, it can otherwise fail + * to be cleaned up in some error cases. + */ + napi_disable(&ar->napi); goto err; }