From: Arnd Bergmann <arnd@arndb.de>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-arm-kernel@lists.infradead.org,
Myron Stowe <myron.stowe@gmail.com>,
rjw@rjwysocki.net, lorenzo.pieralisi@arm.com,
linaro-acpi@lists.linaro.org,
linux-pci <linux-pci@vger.kernel.org>,
catalin.marinas@arm.com, x86 <x86@kernel.org>,
will.deacon@arm.com, LKML <linux-kernel@vger.kernel.org>,
Tomasz Nowicki <tomasz.nowicki@linaro.org>,
"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>,
hanjun.guo@linaro.org, "H. Peter Anvin" <hpa@zytor.com>,
wangyijing@huawei.com, Liviu.Dudau@arm.com,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 6/6] pci, acpi: Share ACPI PCI config space accessors.
Date: Mon, 24 Nov 2014 11:41:28 +0100 [thread overview]
Message-ID: <2178540.dTppAIY2rE@wuerfel> (raw)
In-Reply-To: <20141121180825.GD6578@google.com>
On Friday 21 November 2014 11:08:25 Bjorn Helgaas wrote:
> On Fri, Nov 21, 2014 at 01:24:52PM +0100, Arnd Bergmann wrote:
> > On Thursday 20 November 2014 21:00:17 Myron Stowe wrote:
> > > On Thu, Nov 20, 2014 at 3:26 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>
> > > > That's interesting. I would have said exactly the opposite -- I think the
> > > > extra Kconfiggery is harder to follow than weak/strong functions
> > > >
> > > > But consistency is better than my personal opinion. Is there a consensus
> > > > that we should use the Kconfig strategy instead of __weak?
> > >
> > > I too find weak/strong functions easier to follow than "Kconfiggery" (nice term
> > > invention there).
> >
> > I don't think there is a universal consensus, but the majority of
> > maintainers seems to avoid them for the same reasons that I think
> > __weak is problematic.
> >
> > We have some uses of __weak in the core kernel, but there is
> > basically none in drivers outside of PCI, and the most common
> > uses are all providing an empty __weak function that can be
> > overridden with a function that actually does something, unlike
> > the code above.
>
> One thing I like better about __weak (when used correctly) is that you have
> exactly one declaration, and the role of each definition (weak default
> implementation or strong override) is obvious from looking at it.
Right.
> In your #ifdef example, the extern declaration and the inline definition
> are never compiled together, so you have to repeat the signature and the
> compiler doesn't enforce that they match. So you end up with the extern
> and the inline in one file, a #define in an arch header file or Kconfig,
> and an arch definition in a third file.
>
> But it's certainly true that everybody knows how #ifdef works, and the fact
> that __weak on a declaration affects all in-scope definitions is definitely
> a land mine (multiple weak definitions with no strong one is a disaster).
>
> > My pragmatic approach so far has been to advocate __weak for
> > drivers/pci patches but discourage it elsewhere when I review
> > patches, in order to maintain consistency. I also think it
> > would be nice to change the way that PCI handles architecture
> > specific overrides in the process of unifying the host bridge
> > handling.
> >
> > I wouldn't use Kconfig symbols in most cases though. My preferred
> > choice would be to turn a lot of the __weak symbols into function
> > pointers within a per-hostbridge structure. As an example, we could
> > replace pcibios_add_device() with a pointer in pci_host_bridge->ops
> > that gets set by all the architectures and host drivers that currently
> > override it, and replace the one caller with
> >
> > if (pci_host_bridge->ops->add_device)
> > pci_host_bridge->ops->add_device(dev);
>
> I definitely agree with this part, but I think it's orthogonal to the
> __weak question. In this case, we'd like to support multiple host bridges,
> each with a different flavor of add_device(). We can't do that at all with
> either __weak or #ifdef.
What we currently have though is a a __weak definition of add_device,
which some architectures override, and some of them (ARM in particular)
by implementing their own abstraction. I suspect for the majority of
what we currently define as __weak functions, we could use a similar
approach and kill off the global symbols entirely.
Arnd
next prev parent reply other threads:[~2014-11-24 10:43 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-19 16:04 [PATCH 0/6] PCI: MMCONFIG clean up Tomasz Nowicki
2014-11-19 16:04 ` [PATCH 1/6] x86, acpi, pci: Reorder logic of pci_mmconfig_insert() function Tomasz Nowicki
2014-11-19 16:04 ` [PATCH 2/6] x86, acpi, pci: Move arch-agnostic MMCFG code out of arch/x86/ directory Tomasz Nowicki
2014-12-10 23:35 ` Bjorn Helgaas
2014-12-10 23:55 ` Bjorn Helgaas
2014-12-12 14:55 ` [Linaro-acpi] " Arnd Bergmann
2014-11-19 16:04 ` [PATCH 3/6] x86, acpi, pci: Move PCI config space accessors Tomasz Nowicki
2014-12-10 23:17 ` Bjorn Helgaas
2015-02-03 9:30 ` Tomasz Nowicki
2015-02-17 13:03 ` Tomasz Nowicki
2015-02-18 18:27 ` Bjorn Helgaas
2015-02-18 19:02 ` Rob Herring
2014-11-19 16:04 ` [PATCH 4/6] x86, acpi, pci: mmconfig_{32,64}.c code refactoring - remove code duplication Tomasz Nowicki
2014-11-19 16:04 ` [PATCH 5/6] x86, acpi, pci: mmconfig_64.c becomes default implementation for arch agnostic low-level direct PCI config space accessors via MMCONFIG Tomasz Nowicki
2014-11-19 16:04 ` [PATCH 6/6] pci, acpi: Share ACPI PCI config space accessors Tomasz Nowicki
2014-11-19 16:19 ` Arnd Bergmann
2014-11-19 16:24 ` Tomasz Nowicki
2014-11-20 22:26 ` Bjorn Helgaas
2014-11-21 4:00 ` Myron Stowe
2014-11-21 12:24 ` Arnd Bergmann
2014-11-21 18:08 ` Bjorn Helgaas
2014-11-24 10:41 ` Arnd Bergmann [this message]
2014-12-08 7:13 ` Tomasz Nowicki
2014-12-09 21:50 ` Bjorn Helgaas
2014-12-10 6:16 ` Tomasz Nowicki
2015-02-02 20:42 ` [PATCH 0/6] PCI: MMCONFIG clean up Bjorn Helgaas
2015-02-03 7:42 ` Tomasz Nowicki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2178540.dTppAIY2rE@wuerfel \
--to=arnd@arndb.de \
--cc=Liviu.Dudau@arm.com \
--cc=bhelgaas@google.com \
--cc=catalin.marinas@arm.com \
--cc=hanjun.guo@linaro.org \
--cc=hpa@zytor.com \
--cc=linaro-acpi@lists.linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mingo@redhat.com \
--cc=myron.stowe@gmail.com \
--cc=rjw@rjwysocki.net \
--cc=tglx@linutronix.de \
--cc=tomasz.nowicki@linaro.org \
--cc=wangyijing@huawei.com \
--cc=will.deacon@arm.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).