linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Bjorn Helgaas <helgaas@kernel.org>,
	Daire McNamara <Daire.McNamara@microchip.com>
Cc: 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 11:57:47 -0600	[thread overview]
Message-ID: <CAL_JsqL1FiQ1CxTeOcEV8Y=p1yZKkXLq5Zz3qZ+xiJqkvH+RxA@mail.gmail.com> (raw)
In-Reply-To: <20200820181018.GA1551400@bjorn-Precision-5520>

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:
>
> > + *   pcie-altera.c
> > + */
>
> Add a blank line here.
>
> > +#include <linux/irqchip/chained_irq.h>
> > +#include <linux/module.h>
>
> > +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.

> I'd suggest copying the host bridge init design from somewhere else.
> tango_pcie_probe() also calls pci_host_common_probe(), so maybe that's
> a good place.  But the fact that it's the *only* such caller makes me
> think it might not be the best thing to copy.
>
> Rob has been working in this area and probably has better insight.

It was my suggestion to move to the ECAM init. Prior versions had its own probe.

One question I've been wrestling with is if we can do all the firmware
setup for 'generic ECAM' on the same h/w we have drivers for, then
shouldn't we make the kernel driver create an ECAM setup? There's also
the question of why do root port config accesses go thru standard ECAM
config space in ECAM mode, but use different address space for
non-ECAM setup? DWC for example can probably do ECAM on more
platforms. There's some that can't which are generally ones w/o the
iATU or enough iATU entries or not enough memory space. The difference
from a config space standpoint is just DT configuration (in the case
of DWC with an iATU, the config space and memory space DT entries are
just iATU configuration not h/w constraints).

I think we have drivers too much in control of their initialization
ordering and things should be more the other way around with core code
calling h/w ops to do specific things. I don't have any grand plan
yet, but perhaps the generic/common host stuff evolves beyond just
ECAM and almost ECAM. The generic host would just have no h/w ops.

Rob

[1] https://lwn.net/Articles/443531/

  reply	other threads:[~2020-08-21 17:58 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 [this message]
2020-08-21 19:03       ` Bjorn Helgaas

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='CAL_JsqL1FiQ1CxTeOcEV8Y=p1yZKkXLq5Zz3qZ+xiJqkvH+RxA@mail.gmail.com' \
    --to=robh@kernel.org \
    --cc=Daire.McNamara@microchip.com \
    --cc=bhelgaas@google.com \
    --cc=david.abdurachmanov@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=helgaas@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.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;
as well as URLs for NNTP newsgroup(s).