public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Rob Herring <robh@kernel.org>
Cc: Daire McNamara <Daire.McNamara@microchip.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	PCI <linux-pci@vger.kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	devicetree@vger.kernel.org, david.abdurachmanov@gmail.com
Subject: Re: [PATCH v15 2/2] PCI: microchip: Add host driver for Microchip PCIe controller
Date: Fri, 21 Aug 2020 14:03:28 -0500	[thread overview]
Message-ID: <20200821190328.GA1689493@bjorn-Precision-5520> (raw)
In-Reply-To: <CAL_JsqL1FiQ1CxTeOcEV8Y=p1yZKkXLq5Zz3qZ+xiJqkvH+RxA@mail.gmail.com>

On Fri, Aug 21, 2020 at 11:57:47AM -0600, Rob Herring wrote:
> On Thu, Aug 20, 2020 at 12:10 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
> >
> > On Wed, Aug 19, 2020 at 04:33:10PM +0000, Daire.McNamara@microchip.com wrote:
> >
> > > +static struct mc_port *port;
> >
> > This file scope item is not ideal.  It might work in your situation if
> > you can never have more than one device, but it's not a pattern we
> > want other people to copy.
> 
> Indeed.
> 
> > I think I sort of see how it works:
> >
> >   mc_pci_host_probe
> >     pci_host_common_probe
> >       ops = of_device_get_match_data()              # mc_ecam_ops
> >       gen_pci_init(..., ops)
> >         pci_ecam_create(..., ops)
> >           ops->init                                 # mc_ecam_ops.init
> >             mc_platform_init(pci_config_window *)
> >               port = devm_kzalloc(...)              # initialized
> >     mc_setup_windows
> >       bridge_base_addr = port->axi_base_addr + ...  # used
> >
> > And you're using the file scope "port" because mc_platform_init()
> > doesn't have a pointer to the platform_device.
> 
> This is a simple fix. Move platform_set_drvdata to just after
> devm_pci_alloc_host_bridge() in pci_host_common_probe(). (Don't fall
> into the 'platform problem'[1] and work-around the core code.)
> 
> Then pci_host_common_probe can be called directly and mc_setup_windows
> can be moved to mc_platform_init().
> 
> > But I think this
> > abuses the pci_ecam_ops design to do host bridge initialization that
> > it is not intended for.
> 
> What init should be done then? IMO, given this driver is using ECAM
> support already and it's all one time init that fits into init(), it
> seems like a fit to me.

Oh, OK.  If you can solve this as you outlined above, that's fine with
me.  It didn't look like a common pattern yet, but maybe it will be.

Thanks for chiming in.  I didn't have a good idea for how to fix the
file-scope variable problem.

Bjorn

      reply	other threads:[~2020-08-21 19:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-19 16:30 [PATCH v15 0/2] PCI: microchip: Add host driver for Microchip PCIe controller Daire.McNamara
2020-08-19 16:32 ` [PATCH v15 1/2] dt-bindings: PCI: microchip: Add Microchip PolarFire host binding Daire.McNamara
2020-08-25 22:05   ` Rob Herring
2020-08-19 16:33 ` [PATCH v15 2/2] PCI: microchip: Add host driver for Microchip PCIe controller Daire.McNamara
2020-08-20 18:10   ` Bjorn Helgaas
2020-08-21 17:57     ` Rob Herring
2020-08-21 19:03       ` Bjorn Helgaas [this message]

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=20200821190328.GA1689493@bjorn-Precision-5520 \
    --to=helgaas@kernel.org \
    --cc=Daire.McNamara@microchip.com \
    --cc=bhelgaas@google.com \
    --cc=david.abdurachmanov@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=robh@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