Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5281395rwd; Tue, 23 May 2023 22:29:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Wqparj3yP5us12XdgywA5qHNLub89OhOg1gGdXxYU2mOjXW969XY2m2a3+c1Tuu6ByQAG X-Received: by 2002:a17:90b:1941:b0:253:5728:f631 with SMTP id nk1-20020a17090b194100b002535728f631mr15693238pjb.15.1684906167389; Tue, 23 May 2023 22:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684906167; cv=none; d=google.com; s=arc-20160816; b=BFz36BwsIMMVlMGBoOtPaoU4kHpJ2sBPbmd5Lp31mBMB/gqVqQxluCf8HkO/VgcDfV YFkBfNiX4cYqcnwaCRfeSNxJRsP5jl0pZcxjKLVqyUvly+LbmZNl9KHDGZdCETLgKd60 HLAy5kwHmqHWBYIL+NvVQk/wALnWyA8rKKpMHFeHpQkMbd6hUWABD9zpyNMp8OXpJFyL h00lIUztzfbQ44UIVicKuZGMMjfjAoWLS+roYgWv5GRIHfngAZHW75ibbe2R+DGR4O4V /ULotev9EDbtKlXCXLFNJOLZ0bg5lGcQouWWhH2R9SNeI/HGDFRN6edWaea408w2nyOS m9JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ZgvfolGox3uzjBIvn/zvlH6IbQJKAlBVVhbBRQoBAFc=; b=wb+aBpefV+umfKqZOQVGyP0quVDdP7m6JWuLouNPPi2C6WjmsBqCPICuHnUXEbDCSz vK9Z9d+VY4BYnNCH/wb7HKtovrk/SwuP+wp+56EwgnexznJ7uvm+5PR2DUC7U7x41Wp0 z1EN9BGiq8iPVnzDZA6vSZ5pzaJKnJKyC3oGOVIKs2lNXkGqXMmvCbEwaYjWg76Nfxni j4l3PMT6onaOf8dVABpM9q21sfAJnMaggTTPo0R0okiQ2Y3jG6QwYFMTksmkeFwDe1lq QtXmt/8rkxxY87YQUo36tO6bM6nltW3IybytU8FDuBiqEJTz8Fwq4GgcFF7m0O68HqhD Mxow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=p8otjwLe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 q14-20020a63750e000000b0053eee173732si2618746pgc.161.2023.05.23.22.29.14; Tue, 23 May 2023 22:29:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@infradead.org header.s=bombadil.20210309 header.b=p8otjwLe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S239220AbjEXF0h (ORCPT + 99 others); Wed, 24 May 2023 01:26:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbjEXF0f (ORCPT ); Wed, 24 May 2023 01:26:35 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3277113E; Tue, 23 May 2023 22:26:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ZgvfolGox3uzjBIvn/zvlH6IbQJKAlBVVhbBRQoBAFc=; b=p8otjwLeYkd+K+o+o8Q27CmKGp z9rYA2K0u4yWt9KybnLrn+phprc+yCHtXydznHJpjtOZt16iv6H1WY2DA+mk9JR4PiSX4ME85chJ7 7vYJDTctL5volJOigSCeHUq+bKTuuWYYNAWlGzcLKy07dhU7JKPU73jd9clQS0IRSRB/oDRlIW+IB 3aP7jO48NmARb0ls0utJqr/nMIzLZr/pkd5J0wOBF4gW4Wv5I8L4PIVmDgZ6lsbc6UVbX7PE2vAxQ 6DvHP8Acwd5oARsqbdGRhQSqvDcvPwGne0PXxSh6AMHWLUwjlhcTAU/tOV4wXm6qzvWQvQfoOxQeB 9GH0Uj6w==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q1h12-00COyT-2I; Wed, 24 May 2023 05:26:28 +0000 Date: Tue, 23 May 2023 22:26:28 -0700 From: Luis Chamberlain To: Dave Airlie Cc: Lucas De Marchi , Dave Airlie , dri-devel@lists.freedesktop.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] modules/firmware: add a new option to denote a firmware group to choose one. Message-ID: References: <20230419043652.1773413-1-airlied@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Luis Chamberlain X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,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-kernel@vger.kernel.org On Wed, May 03, 2023 at 01:19:31PM +1000, Dave Airlie wrote: > > > > > > > >> > the GROUP until after the FIRMWARE, so this can't work, as it already > > >> > will have included all the ones below, hence why I bracketed top and > > >> > bottom with a group. > > >> > > >> well... that is something that can be adapted easily by using a 2 pass > > >> approach, filtering out the list based on the groups. > > >> > > >> I agree that yours is simpler though. If we can rely on the > > >> order produced by the compiler and we document the expectations of > > >> MODULE_FIRMWARE_GROUP_ONLY_ONE, then I believe we can stay with the > > >> simpler approach. > > >> > > >> Luis, any thoughts here? > > > > > >I see the Dracut code indicates that the order says now that you should > > >put the preferred firmware last, and that seems to match most coding > > >conventions, ie, new firmwares likely get added last, so it's a nice > > > > not all. i915 for example keeps it newest first so when attempting > > multiple firmware versions it starts from the preferred version. It > > will be harder to convert since it also uses a x-macro to make sure the > > MODULE_FIRMWARE() and the the platform mapping are actually using the same > > firmware. > > > > >coincidence. Will this always work? I don't know. But if you like to > > > > short answer: it depends if your compiler is gcc *and* -O2 is used > > Longer debug ahead. Simple test with the expansion of MODULE_FIRMWARE > > baked in: > > > > $ cat /tmp/a.c > > static const __attribute__((section("__modinfo_manual"), used, aligned(1))) char foo[] = "modinfo_manual_foo"; > > static const __attribute__((section("__modinfo_manual"), used, aligned(1))) char bar[] = "modinfo_manual_bar"; > > $ gcc -c -o /tmp/a.o /tmp/a.c > > $ objcopy -O binary --only-section=__modinfo_manual /tmp/a.o /tmp/modinfo_manual > > $ strings /tmp/modinfo_manual > > modinfo_manual_foo > > modinfo_manual_bar > > > > However that doesn't match when building modules. In kmod: > > > > diff --git a/testsuite/module-playground/mod-simple.c b/testsuite/module-playground/mod-simple.c > > index 503e4d8..6dd5771 100644 > > --- a/testsuite/module-playground/mod-simple.c > > +++ b/testsuite/module-playground/mod-simple.c > > @@ -30,3 +30,9 @@ module_exit(test_module_exit); > > > > MODULE_AUTHOR("Lucas De Marchi "); > > MODULE_LICENSE("GPL"); > > + > > + > > +static const char __UNIQUE_ID_firmware404[] __attribute__((__used__)) __attribute__((__section__("__modinfo_cpp"))) __attribute__((__aligned__(1))) = "modinfo_cpp_foo"; > > +static const char __UNIQUE_ID_firmware405[] __attribute__((__used__)) __attribute__((__section__("__modinfo_cpp"))) __attribute__((__aligned__(1))) = "modinfo_cpp_bar"; > > > > $ make .... > > $ objcopy -O binary --only-section=__modinfo_cpp testsuite/module-playground/mod-simple.ko /tmp/modinfo_cpp > > $ strings /tmp/modinfo_cpp > > modinfo_cpp_bar > > modinfo_cpp_foo > > > > It doesn't seem to be ./scripts/Makefile.modfinal neither as it's also > > inverted in testsuite/module-playground/mod-simple.o > > > > After checking the options passed to gcc, here is the "culprit": -O2 > > > > $ gcc -c -o /tmp/a.o /tmp/a.c && objcopy -O binary --only-section=__modinfo_manual /tmp/a.o /tmp/modinfo_manual && strings /tmp/modinfo_manual > > modinfo_manual_foo > > modinfo_manual_bar > > $ gcc -O2 -c -o /tmp/a.o /tmp/a.c && objcopy -O binary --only-section=__modinfo_manual /tmp/a.o /tmp/modinfo_manual && strings /tmp/modinfo_manual > > modinfo_manual_bar > > modinfo_manual_foo > > > > It seems anything but -O0 inverts the section. > > > > $ gcc --version > > gcc (GCC) 12.2.1 20230201 > > > > It doesn't match the behavior described in its man page though. Manually > > specifying all the options that -O1 turns on doesn't invert it. > > > > $ gcc -fauto-inc-dec -fbranch-count-reg -fcombine-stack-adjustments \ > > -fcompare-elim -fcprop-registers -fdce -fdefer-pop -fdelayed-branch > > -fdse -fforward-propagate -fguess-branch-probability -fif-conversion \ > > -fif-conversion2 -finline-functions-called-once -fipa-modref \ > > -fipa-profile -fipa-pure-const -fipa-reference -fipa-reference-addressable \ > > -fmerge-constants -fmove-loop-stores -fomit-frame-pointer -freorder-blocks \ > > -fshrink-wrap -fshrink-wrap-separate -fsplit-wide-types -fssa-backprop \ > > -fssa-phiopt -ftree-bit-ccp -ftree-ccp -ftree-ch -ftree-coalesce-vars \ > > -ftree-copy-prop -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-forwprop \ > > -ftree-fre -ftree-phiprop -ftree-pta -ftree-scev-cprop -ftree-sink -ftree-slsr \ > > -ftree-sra -ftree-ter -funit-at-a-time -c -o /tmp/a.o /tmp/a.c \ > > && objcopy -O binary --only-section=__modinfo_manual /tmp/a.o /tmp/modinfo_manual && strings /tmp/modinfo_manual > > cc1: warning: this target machine does not have delayed branches > > modinfo_manual_foo > > modinfo_manual_bar > > > > Thanks Lucas, > > -ftoplevel-reorder is the one that does it, now that does mean how > I've done it isn't going to be robust. > > I will reconsider but in order to keep backwards compat, it might be > easier to add firmware groups as an explicit list, but also spit out > the individual names, but not sure how clean this will end up on > dracut side. > > I'll take a look at the other options, but it does seem like reworking > dracut is going to be the harder end of this, esp if I still want to > keep compat with older ones. Hey Dave, just curious if there was going to be another follow up patch for this or if it was already posted. I don't see it clearly so just wanted to double check. Luis