From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: "platform-driver-x86@vger.kernel.org"
<platform-driver-x86@vger.kernel.org>,
"Hans de Goede" <hdegoede@redhat.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Lukas Wunner" <lukas@wunner.de>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>
Subject: Re: [PATCH RFC v2] platform/x86: p2sb: Allow p2sb_bar() calls during PCI device probe
Date: Fri, 15 Dec 2023 17:42:15 +0200 [thread overview]
Message-ID: <ZXxz16ecl4onz5w7@smile.fi.intel.com> (raw)
In-Reply-To: <kbaq6ejaujr565ubdxn6f4e2vxjppoabsbgmpp4zbtkpfpheyr@exlxebf2hy4j>
On Fri, Dec 15, 2023 at 07:33:37AM +0000, Shinichiro Kawasaki wrote:
> On Dec 14, 2023 / 18:38, Andy Shevchenko wrote:
> > On Tue, Dec 12, 2023 at 08:47:46PM +0900, Shin'ichiro Kawasaki wrote:
...
> > > +/* Cache BAR0 of P2SB device from function 0 ot 7 */
> > > +#define NR_P2SB_RES_CACHE 8
> >
> > This is fifth or so definition for the same, isn't it a good time to create
> > a treewide definition in pci.h?
> >
> > See also below.
> >
> > (In previous mail I even found all cases and listed, a bit lazy to repeat.)
>
> I'm not sure where are other definitions. I guess PCI_CONF1_FUNC_SHIFT in
> drivers/pci/pci.h is one of them.
Maybe, but I'm talking about treewide (drivers/, arch/, etc) duplications
IIRC it is 5+ of them.
> As you suggested in another mail, I'll add a
> TODO comment and note that the NR_P2SB_RES_CACHE should be refactored later.
Yeah, there are two ways, make this one dependent on the definition or
introduce a definition and update later on. In the latter case it means
a technical debt +.
In the lost email I suggested to list all existing cases somewhere in TODO,
so we won't grep again, but okay we can do that (although I forgot the
exact `git grep ...` command line I have used for that search).
...
> > > - /* if @bus is NULL, use bus 0 in domain 0 */
> > > - bus = bus ?: pci_find_bus(0, 0);
> > > + /* Assume P2SB is on the bus 0 in domain 0 */
> > > + bus = pci_find_bus(0, 0);
> >
> > The pci_find_bus() is called in two places now. Can we avoid doing
> > this duplication?
>
> I will add a global variable "static struct pci_bus *p2sb_bus". It will keep the
> first call return value and allow to skip the second call.
Hmm... Global variables are prone to subtle race conditions, OTOH the P2SB is
not supposed to be hotplugged or moved, so I think it will be fine.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-12-15 15:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 11:47 [PATCH RFC v2] platform/x86: p2sb: Allow p2sb_bar() calls during PCI device probe Shin'ichiro Kawasaki
2023-12-13 14:05 ` Andy Shevchenko
2023-12-14 0:55 ` Shinichiro Kawasaki
2023-12-14 14:13 ` Andy Shevchenko
2023-12-13 19:41 ` Bjorn Helgaas
2023-12-15 7:34 ` Shinichiro Kawasaki
2023-12-14 16:38 ` Andy Shevchenko
2023-12-15 7:33 ` Shinichiro Kawasaki
2023-12-15 15:42 ` Andy Shevchenko [this message]
2023-12-15 7:52 ` Lukas Wunner
2023-12-15 15:37 ` Andy Shevchenko
2023-12-15 15:45 ` Lukas Wunner
2023-12-15 16:13 ` Andy Shevchenko
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=ZXxz16ecl4onz5w7@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=platform-driver-x86@vger.kernel.org \
--cc=shinichiro.kawasaki@wdc.com \
/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