Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp412679ybs; Sun, 24 May 2020 09:07:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq/j3kKIliroPyFkRDEWAc27x2rRKbR12b2uprR70rC9+rb9kuMHEQbaOXky00l79BGs0T X-Received: by 2002:a17:906:7750:: with SMTP id o16mr16325708ejn.12.1590336428664; Sun, 24 May 2020 09:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590336428; cv=none; d=google.com; s=arc-20160816; b=qRgKjB/UhEIxnoeC3Sm6DW80pR2u7I7fChiQ0GwG3AxXlrOd802QY2f8DziD70L4b/ LQNkT2dXnnm3wbr5FWMmVoIRH5X7Os7cTcFuJXRzbjrVsmDD33eqNwDnvedDb6DwWJcd mKTX71jBUSWL8hbPjR3LevFdj2ayQ7qVURm8FUk7TNAxBMaylZ5xaXzqmhCjpNQlKVlG 7bmPmmzkcjq3qaz3YczOYjGvDd7H7iTYmxiQtliuWr1X1HLfwNOWBqbsD0du9GfAyHlX EJCypASlbQhmSlX3SxWD/2UsRTUWfKH3I1PCuih5Z3bUmK80NhnyGDpyAlBRTyoNgJJM MI5Q== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject:dkim-signature; bh=UYQ0SFYgaF74nNPMyQhIjxs2f3iaDgh0yX57kp2iiKI=; b=kfjM/jWnFKclcTPX8ocpf15bpcJKCXWcSYNwAUoTU2XdbREGksLFZWR1IIgZE0k8PZ uKPFVJW22ftHQgvIao6j5gByCJlVddQPfKS1k7GKUmWATR+LN2aXcDWYM1Z5RMU6QQI6 KqU+/NozJMf2/9hTZqBVdG8AaMq1OAIhRHdxG1JpeXIxzBYVmanZKw46EbaD8XjpT1Va Ygi0UVRLkMhxuZWNbtYmlMwFEhjt6CakQW1Sn5/B5EH0UKP+VGy1YCw9TPJvQdBFPqQh CocBSFWMtVxO8pdeWpDo7q9xCy9+unO5XoXlznNJ7AUnLCaev/gVuYzpUmZVEM01Slaa 8cEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=iLIFI4ng; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm10si7366344edb.82.2020.05.24.09.06.31; Sun, 24 May 2020 09:07:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=iLIFI4ng; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727899AbgEXQGQ (ORCPT + 99 others); Sun, 24 May 2020 12:06:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727027AbgEXQGO (ORCPT ); Sun, 24 May 2020 12:06:14 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2339EC061A0E for ; Sun, 24 May 2020 09:06:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=UYQ0SFYgaF74nNPMyQhIjxs2f3iaDgh0yX57kp2iiKI=; b=iLIFI4ngBibzlVjc6ObmDZE8zj GzbBMjjaDacTm7qW8aCUN/nZTRdxpCJeCq7kAkYQDkYKdiVKV+FNKpXzX13TO1taOj+XMZFkcxRR0 lS4dhY3KE8sfufdKRSnaWi2ixes5/eDruAAW+IviQWgLaq+JG0kDg0/gtxx4CUUwFI9U=; Received: from p5b206c3b.dip0.t-ipconnect.de ([91.32.108.59] helo=nf.local) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1jct8c-0005r2-Fv; Sun, 24 May 2020 18:06:10 +0200 Subject: Re: [PATCH] mt76: only iterate over initialized rx queues To: Lorenzo Bianconi Cc: linux-wireless@vger.kernel.org, Sean Wang References: <20200524130746.98760-1-nbd@nbd.name> <20200524134500.GA33803@localhost.localdomain> From: Felix Fietkau Autocrypt: addr=nbd@nbd.name; prefer-encrypt=mutual; keydata= xsDiBEah5CcRBADIY7pu4LIv3jBlyQ/2u87iIZGe6f0f8pyB4UjzfJNXhJb8JylYYRzIOSxh ExKsdLCnJqsG1PY1mqTtoG8sONpwsHr2oJ4itjcGHfn5NJSUGTbtbbxLro13tHkGFCoCr4Z5 Pv+XRgiANSpYlIigiMbOkide6wbggQK32tC20QxUIwCg4k6dtV/4kwEeiOUfErq00TVqIiEE AKcUi4taOuh/PQWx/Ujjl/P1LfJXqLKRPa8PwD4j2yjoc9l+7LptSxJThL9KSu6gtXQjcoR2 vCK0OeYJhgO4kYMI78h1TSaxmtImEAnjFPYJYVsxrhay92jisYc7z5R/76AaELfF6RCjjGeP wdalulG+erWju710Bif7E1yjYVWeA/9Wd1lsOmx6uwwYgNqoFtcAunDaMKi9xVQW18FsUusM TdRvTZLBpoUAy+MajAL+R73TwLq3LnKpIcCwftyQXK5pEDKq57OhxJVv1Q8Xk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ozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200524134500.GA33803@localhost.localdomain> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 2020-05-24 15:45, Lorenzo Bianconi wrote: >> Fixes the following reported crash: >> >> [ 2.361127] BUG: spinlock bad magic on CPU#0, modprobe/456 >> [ 2.361583] lock: 0xffffa1287525b3b8, .magic: 00000000, .owner: /-1, .owner_cpu: 0 >> [ 2.362250] CPU: 0 PID: 456 Comm: modprobe Not tainted 4.14.177 #5 >> [ 2.362751] Hardware name: HP Meep/Meep, BIOS Google_Meep.11297.75.0 06/17/2019 >> [ 2.363343] Call Trace: >> [ 2.363552] dump_stack+0x97/0xdb >> [ 2.363826] ? spin_bug+0xa6/0xb3 >> [ 2.364096] do_raw_spin_lock+0x6a/0x9a >> [ 2.364417] mt76_dma_rx_fill+0x44/0x1de [mt76] >> [ 2.364787] ? mt76_dma_kick_queue+0x18/0x18 [mt76] >> [ 2.365184] mt76_dma_init+0x53/0x85 [mt76] >> [ 2.365532] mt7615_dma_init+0x3d7/0x546 [mt7615e] >> [ 2.365928] mt7615_register_device+0xe6/0x1a0 [mt7615e] >> [ 2.366364] mt7615_mmio_probe+0x14b/0x171 [mt7615e] >> [ 2.366771] mt7615_pci_probe+0x118/0x13b [mt7615e] >> [ 2.367169] pci_device_probe+0xaf/0x13d >> [ 2.367491] driver_probe_device+0x284/0x2ca >> [ 2.367840] __driver_attach+0x7a/0x9e >> [ 2.368146] ? driver_attach+0x1f/0x1f >> [ 2.368451] bus_for_each_dev+0xa0/0xdb >> [ 2.368765] bus_add_driver+0x132/0x204 >> [ 2.369078] driver_register+0x8e/0xcd >> [ 2.369384] do_one_initcall+0x160/0x257 >> [ 2.369706] ? 0xffffffffc0240000 >> [ 2.369980] do_init_module+0x60/0x1bb >> [ 2.370286] load_module+0x18c2/0x1a2b >> [ 2.370596] ? kernel_read_file+0x141/0x1b9 >> [ 2.370937] ? kernel_read_file_from_fd+0x46/0x71 >> [ 2.371320] SyS_finit_module+0xcc/0xf0 >> [ 2.371636] do_syscall_64+0x6b/0xf7 >> [ 2.371930] entry_SYSCALL_64_after_hwframe+0x3d/0xa2 >> [ 2.372344] RIP: 0033:0x7da218ae4199 >> [ 2.372637] RSP: 002b:00007fffd0608398 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 >> [ 2.373252] RAX: ffffffffffffffda RBX: 00005a705449df90 RCX: 00007da218ae4199 >> [ 2.373833] RDX: 0000000000000000 RSI: 00005a7052e73bd8 RDI: 0000000000000006 >> [ 2.374411] RBP: 00007fffd06083e0 R08: 0000000000000000 R09: 00005a705449d540 >> [ 2.374989] R10: 0000000000000006 R11: 0000000000000246 R12: 0000000000000000 >> [ 2.375569] R13: 00005a705449def0 R14: 00005a7052e73bd8 R15: 0000000000000000 >> >> Reported-by: Sean Wang >> Fixes: d3377b78cec6 ("mt76: add HE phy modes and hardware queue") >> Signed-off-by: Felix Fietkau > > Just a couple of nitpicks inline, for the rest: > > Acked-by: Lorenzo Bianconi > >> --- >> drivers/net/wireless/mediatek/mt76/debugfs.c | 2 +- >> drivers/net/wireless/mediatek/mt76/dma.c | 4 ++-- >> drivers/net/wireless/mediatek/mt76/mt76.h | 4 ++++ >> drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 3 ++- >> drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 3 ++- >> drivers/net/wireless/mediatek/mt76/mt7615/pci.c | 8 +++++--- >> drivers/net/wireless/mediatek/mt76/mt76x02_mmio.c | 3 ++- >> drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 3 ++- >> 8 files changed, 20 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h >> index afb1ccf61b74..78378dcf430a 100644 >> --- a/drivers/net/wireless/mediatek/mt76/mt76.h >> +++ b/drivers/net/wireless/mediatek/mt76/mt76.h >> @@ -671,6 +671,10 @@ static inline u16 mt76_rev(struct mt76_dev *dev) >> #define mt76_queue_tx_cleanup(dev, ...) (dev)->mt76.queue_ops->tx_cleanup(&((dev)->mt76), __VA_ARGS__) >> #define mt76_queue_kick(dev, ...) (dev)->mt76.queue_ops->kick(&((dev)->mt76), __VA_ARGS__) >> >> +#define mt76_for_each_q_rx(dev, i) \ >> + for (i = 0; i < ARRAY_SIZE((dev)->q_rx) && \ >> + (dev)->q_rx[i].desc; i++) >> + >> struct mt76_dev *mt76_alloc_device(struct device *pdev, unsigned int size, >> const struct ieee80211_ops *ops, >> const struct mt76_driver_ops *drv_ops); >> diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c >> index 0f205ffe4905..8060c1514396 100644 >> --- a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c >> +++ b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c >> @@ -1438,8 +1438,9 @@ static void mt7603_mac_watchdog_reset(struct mt7603_dev *dev) >> for (i = 0; i < __MT_TXQ_MAX; i++) >> mt76_queue_tx_cleanup(dev, i, true); >> >> - for (i = 0; i < ARRAY_SIZE(dev->mt76.q_rx); i++) >> + mt76_for_each_q_rx(&dev->mt76, i) { >> mt76_queue_rx_reset(dev, i); >> + } > > you can drop braces here I thought about it as well, but decided to keep them, because it's a custom iterator function and without the braces it might look to the untrained eye like a function call with missing ; and wrong indentation in the next line. I thought this might help a bit with code clarity. - Felix