Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1006176rwb; Thu, 18 Aug 2022 16:54:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR5fEKw91fH97kM6K9wTvdS3BbMaiFXaxwB171VT7erVkepfMrismOp2ok+KrEh+1smF/SkA X-Received: by 2002:a63:5c4a:0:b0:41d:bd7d:6084 with SMTP id n10-20020a635c4a000000b0041dbd7d6084mr4147104pgm.411.1660866887923; Thu, 18 Aug 2022 16:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660866887; cv=none; d=google.com; s=arc-20160816; b=W3IBtxAXCr2udo/b1jgD4zwA15m4kUuc1z8iJeP/9bTzmMCcfiTwJ3scmeLZWz5f/V g7BvkQvsPOyDQx5X2ORlr+USyTT5nNOYWVfIisgafH6f+V9ZsnOS18XXVGSVYTwwYx4n FzD2LeDHZ/X658XfzVNO2exf4WR4dcW2o98+soWtDNHv+btLCxJ8EhmRI1Xvr39RIPrr DvvAJzFXdsaumFPxJj3KXKmRH+KCJGMu7xcEerWw7znwG+gl2NGL3Vz/Bd+e0sqIbPal q3tS3671tRCFKUWUnp+avG9KFgVkaetkXlJWXVpSrtsr1KPLCwOFVT4aoaNIBdkEkKEo Jy0g== 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=KEf+9oe7rBGfKa0RbKd0ia0PNz6udrYgCbbGFQ8PjW0=; b=0n0qRi9BwbP848gXnRRK/wBHbI1ofE7jl2i9c20/b/g2+5UMChI+RFIBrHs8RK3FgT e+8lcV7x7minb03UAWgCYOxGOcTWMU9renbk9CpnZPr5A6aMFlJrM5IZJzv1e95WN1tr Jqx4ClRgikSXz9wAapW6Svu02KpzYzmNGki0QicxyTVmbm3nukY8a+gAGlxRkRVZk0iv tf2cNCbRJMWok5taeZoCgXhIebJwSrICrXzUPdMvWZPidjGOM/5TbLGzeogVLBX/7aQR G/+IU7j/E5LTmLg45TFpLbAmYf3jvblYk3/XTcizzs5Y+W6Mo04T3LS982US++eW8PXU 72bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PGZc0ZZu; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a170902f15500b0016c3f3acbaasi2145688plb.441.2022.08.18.16.54.37; Thu, 18 Aug 2022 16:54:47 -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=@kernel.org header.s=k20201202 header.b=PGZc0ZZu; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243925AbiHRXlM (ORCPT + 64 others); Thu, 18 Aug 2022 19:41:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240276AbiHRXlL (ORCPT ); Thu, 18 Aug 2022 19:41:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 708F3DDB54 for ; Thu, 18 Aug 2022 16:41:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0D6AF61762 for ; Thu, 18 Aug 2022 23:41:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71F5BC433D6 for ; Thu, 18 Aug 2022 23:41:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660866069; bh=4/ee5rBqbhthSFfgx0AiAmy1Qrru12HILchShtOcxxE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=PGZc0ZZuDKI2e7yhIoCCNA+EjMy5Gqjw76eWfTVFJRPd1z7vb3FGb8+CmM+qd2CYt xhFj2kCt4Naay/kzSAaqbA437zIo1JJh63HBq7I7+h2ETTG2bOshoiONlysoyIifvG J98+V9pSjXFJpYtFv79RC7bLRWXBkRyNC2m5TE5gCyE32NeXqa4L0UXDLOob1XA0xb lz6lI93M7V6kaOlSatrk1R1BVgg+GbkU/OlH6z+4rOLyN/2F6Vosl/xA4UAe+/mJ84 48Th56rPkuIGk9m/Kt2kMKFvtP0ALFx4ye5F3ZyCQOJcc30p2xr2xzgp8upUQvg+Jd wm9ca4YXwgUmw== Received: by mail-wr1-f53.google.com with SMTP id ba1so3369874wrb.5 for ; Thu, 18 Aug 2022 16:41:09 -0700 (PDT) X-Gm-Message-State: ACgBeo1uPXtNupENRI3zEJvyLVcgWXQCnSrr+/UxvgD7a+oCzSRECJli bFAgj1k63CEsRtXqwhYU/NNySs0jZeDSwAbly9Y= X-Received: by 2002:a05:6000:1547:b0:221:7a23:ab67 with SMTP id 7-20020a056000154700b002217a23ab67mr2756819wry.515.1660866067658; Thu, 18 Aug 2022 16:41:07 -0700 (PDT) MIME-Version: 1.0 References: <473fc7b169f288b7815a7736cf33ac0ec1599a09.1660606893.git.objelf@gmail.com> <5b24421363048bff1a9f03174cb0223b3e226bf9.camel@sipsolutions.net> In-Reply-To: From: Sean Wang Date: Thu, 18 Aug 2022 16:40:55 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/9] wifi: mac80211: allow enabling chanctx until hw registration To: Johannes Berg Cc: =?UTF-8?B?U2VhbiBXYW5nICjnjovlv5fkupgp?= , Felix Fietkau , lorenzo.bianconi@redhat.com, Soul.Huang@mediatek.com, YN.Chen@mediatek.com, Leon.Yen@mediatek.com, Eric-SY.Chang@mediatek.com, Deren Wu , km.lin@mediatek.com, jenhao.yang@mediatek.com, robin.chiu@mediatek.com, Eddie.Chen@mediatek.com, ch.yeh@mediatek.com, posh.sun@mediatek.com, ted.huang@mediatek.com, Stella.Chang@mediatek.com, Tom.Chou@mediatek.com, steve.lee@mediatek.com, jsiuda@google.com, frankgor@google.com, kuabhs@google.com, druth@google.com, abhishekpandit@google.com, shawnku@google.com, linux-wireless@vger.kernel.org, "moderated list:ARM/Mediatek SoC support" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Hi Johannes, On Thu, Aug 18, 2022 at 3:49 AM Johannes Berg wrote: > > Hi Sean, > > > It could be changed but it would break the consistency of the current > > mt76 driver. > > I'm not really convinced ... > > > mt76 driver does the things in the following order > > - ieee80211_alloc_hw (where an instance of "struct mt76_dev *" would be created) > > - register bus operation into mt76 core (depending on struct mt76_dev > > to provide an abstraction layer for mt76 core to access bus) > > - read chip identifier (depending on bus operation) > > - load the firmware capabilities (depending on chip identifier) > > - initialize the hardware > > .... > > -ieee80211_register_hw > > > > If firmware capability is needed to load before ieee80211_alloc_hw, we > > need to create kind of similar functions to read chip identifiers and > > load firmware. > > I know It may not a strong reason not to change, but if we can support > > read firmware capabilities after alloc_hw, it provides flexibility to > > the vendor driver > > and helps mt7921 look more consistent and save a few changes across > > different mt7921 bus drivers (mt7921 now supports SDIO, USB, PCIe type > > driver). > > But you're loading _firmware_, so to determine the capabilities all you > should need is the actual file, no? I mean, you don't even have to load > it into the device. Like iwlwifi, you could have an indication (or many > flags, or TLVs, or whatnot) in the file that says what it's capable of. > > > I kmemdup the const ops and ieee80211_alloc_hw with the duplicated ops > > the duplicated ops would be updated by the actual firmware > > capabilities before ieee80211_register_hw. > > Well ... yeah ok that works, but it's pretty wasteful, and also makes > this a nice security attack target - there's a reason ops structs are > supposed to be const, that's because they can then be really read-only > and you can't have function pointer changes. Some of the CFI stuff is > meant to help avoid that, but still ... > > So anyway. I'm not really sure I buy this - even you while doing this > already kind of introduced a bug because you didn't change this code: > > if (!use_chanctx || ops->remain_on_channel) > wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; > > I guess you didn't notice because you have remain_on_channel in the > first place, but that's not the only code there assuming that we have > the ops in place and they don't change. > > If we really, really need to allow changing the ops, then we should > probably make a much larger change to not even pass the ops until > register, though I'm not really sure it's worth it just to have mt7921 > avoid loading the firmware from disk before allocation? > > johannes Thanks for your input. I thought I'd try to write a patch to follow up on the idea you mentioned here. sean