Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6673372rwl; Wed, 22 Mar 2023 13:57:10 -0700 (PDT) X-Google-Smtp-Source: AK7set8qyyquWXTShE1rTlzq4r+ve+XPbjRuSxYLbejdf/lEr8CIh5hRJ/xyMFDBj0AB8bqcCeRx X-Received: by 2002:a05:6402:785:b0:501:d43e:d1e5 with SMTP id d5-20020a056402078500b00501d43ed1e5mr7904008edy.2.1679518630378; Wed, 22 Mar 2023 13:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679518630; cv=none; d=google.com; s=arc-20160816; b=G2gpjTOaobGlMs1akevYPUWmu7R/VFvD6ap5muLEJ1DyNNEO4+1FxrPGeusUiTe0Ah Bvt52Ogtzjx0dAVVhsAnOBo7HtdxXO+hVZAGeLFay0SwH4NRp/j6hbxHxi5mxKXs+/aW ZqRseZ3E8YTakAasZ+yW3shkYNvAFCAYyDwKdImhFSs0wzTxRecmAjdcHAFxJV6FGwTw jpzvnmufYc2lt8mHB5y6g98FjvVWlP8Nz/OirdSGYGFc0cOHA7uxmi8g+xYaQ+XKEVX8 5Xa4CwUADaRyczf2kmIjcd/edl6nXF5je52IDHi0XXZF9cWG5FNCTzgAE17URLRhHPDf AlbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CWlpBm7vrzYxnF70yu+Dqd4NQ9SDIdN+19JogqnAdig=; b=iCiG2PR+NUgUXMJ6pX+zycYsfEnBZoivAgN0zNSPkQho6olf5kqOJ7vmV4sD+GpUHi nkQEQSqUNQEWJcTFlQ3E+UbcvCbG1BNrb2HfVeD45BUeq1Wukb9ty08p6qYD8KSngwXo 96h8SRsVsqKImmmYyPMuMBQlaMCAOE2o0dtdWEZQd+tWyEA3O6QqHkgrQLaSX7Yz0RIV pEbkEIqYkJOE0Hk3v23WF8WCTe+1g2hGlRMblvGRTEsmQkmu/IFolfsSICwagGTn4q6N NPDH8OdlkVs67wdmDlYRv5K6zZgl0VvgOV20M+pz2Jk3Ow5zMPpBN1JNNdk9pCZvTdcn ycEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="DO60S/FF"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020aa7d447000000b00501de556659si5622825edr.111.2023.03.22.13.56.54; Wed, 22 Mar 2023 13:57:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="DO60S/FF"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230323AbjCVUxU (ORCPT + 60 others); Wed, 22 Mar 2023 16:53:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231736AbjCVUxC (ORCPT ); Wed, 22 Mar 2023 16:53:02 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E8B435B4; Wed, 22 Mar 2023 13:52:39 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id c18so20401027ple.11; Wed, 22 Mar 2023 13:52:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679518358; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=CWlpBm7vrzYxnF70yu+Dqd4NQ9SDIdN+19JogqnAdig=; b=DO60S/FF7O+sG/Ce44mbbn0TqBH1Y/ojc2R0nKjGG0QyTLfUsQ9tuij8rLNUWYngs/ LWmcsTrgRIstcg9LEpEnevlD6PMPttTao2qNYZZS8lutOwMGbhCpqXm9iyksyPERWoqE 6cW+vsW4ObbBUkvwwxpy6Wr5qxznTs5zs6uA8WWi6NG5NZa0Bm4eHqXo0J6NtWM2LjpP 7//xubxam2Wox9wjZRUXNeZl5hLXPC3SbmB/kXVvYWV1ctUCCOkp1ZVkFW9390jIyTDc PgobKK4aQbmcsCscRuON8Ls6Zumng6GP/q1dDmRLnoQfFqLxtZeclv963qacw3hCAVUb adnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679518358; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CWlpBm7vrzYxnF70yu+Dqd4NQ9SDIdN+19JogqnAdig=; b=ZCWJkGbR2nS67j2RgUDzmyDGXjB7Che/A9+q5nokM72NEfdUTJ1b4a7sQW9vumyOWf Uf+lYE1BguFbLVwS7s5mjNMbevJ076/MSbL0mz3HIWqsJubrn77P3/VWxhi2qVHVYhGN 9ycyfGI8+uyHr27QfOMwAot40K6bPJxJ/9MJUQPtVB2xiJy0krRdkU7dmr/JhBvgHM75 0AcrJ+MI08EwAJq7WvYiGrFWGmP4H/mQeKPYlbt6P+4yHzr76+O79jvHQj06EvzRpX2n fjs/nZXMuajl/f+Tt/ZrJKPjcNcqe16YEi/cQaIVVgWpntYqdrxzpS18J0pyH/7ZGz+t NKSA== X-Gm-Message-State: AO0yUKV6gfycpNxrh/0i0kn3//bmSm59MjIrgIARQShl7abmvWBJunhA NvQQiAkSObx/FfG5YGkaTJChiqkjmFFGEYyr0+M= X-Received: by 2002:a17:903:2347:b0:1a0:5402:b17b with SMTP id c7-20020a170903234700b001a05402b17bmr1655554plh.0.1679518358570; Wed, 22 Mar 2023 13:52:38 -0700 (PDT) MIME-Version: 1.0 References: <55057734-9913-8288-ad88-85c189cbe045@lwfinger.net> In-Reply-To: <55057734-9913-8288-ad88-85c189cbe045@lwfinger.net> From: Jonas Gorski Date: Wed, 22 Mar 2023 21:52:27 +0100 Message-ID: Subject: Re: [BUG v6.2.7] Hitting BUG_ON() on rtw89 wireless driver startup To: Larry Finger Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Ping-Ke Shih Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Wed, 22 Mar 2023 at 18:03, Larry Finger wrote: > > On 3/22/23 10:54, Hyeonggon Yoo wrote: > > > > Hello folks, > > I've just encountered weird bug when booting Linux v6.2.7 > > > > config: attached > > dmesg: attached > > > > I'm not sure exactly how to trigger this issue yet because it's not > > stably reproducible. (just have encountered randomly when logging in) > > > > At quick look it seems to be related to rtw89 wireless driver or network subsystem. > > Your bug is weird indeed, and it does come from rtw89_8852be. My distro has not > yet released kernel 6.2.7, but I have not seen this problem with mainline > kernels throughout the 6.2 or 6.3 development series. Looking at the rtw89 driver's probe function, the bug is probably a simple race condition: int rtw89_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { ... ret = rtw89_core_register(rtwdev); <- calls ieee80211_register_hw(); ... rtw89_core_napi_init(rtwdev); ... } so it registers the wifi device first, making it visible to userspace, and then initializes napi. So there is a window where a fast userspace may already try to interact with the device before the driver got around to initializing the napi parts, and then it explodes. At least that is my theory for the issue. Switching the order of these two functions should avoid it in theory, as long as rtw89_core_napi_init() doesn't depend on anything rtw89_core_register() does. FWIW, registering the irq handler only after registering the device also seems suspect, and should probably also happen before that. Regards Jonas