All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Wenrui Li <wenrui.li@rock-chips.com>,
	Gabriele Paoloni <gabriele.paoloni@huawei.com>,
	linux-pci <linux-pci@vger.kernel.org>,
	Shawn Lin <shawn.lin@rock-chips.com>,
	Will Deacon <will.deacon@arm.com>,
	Michal Simek <michal.simek@xilinx.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Tanmay Inamdar <tinamdar@apm.com>,
	Matthew Minter <matt@masarand.com>, Rob Herring <robh@kernel.org>,
	Joao Pinto <Joao.Pinto@synopsys.com>,
	Pratyush Anand <pratyush.anand@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Murali Karicheri <m-karicheri2@ti.com>,
	Bharat Kumar Gogada <bharat.kumar.gogada@xilinx.com>,
	Simon Horman <horms@verge.net.au>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Mingkai Hu <mingkai.hu@freescale.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Jingoo Han <jingoohan1@gmail.com>,
	Stanimir Varbanov <svarbanov@mm-sol.com>,
	Minghuan Lian <minghuan.Lian@freescale.com>,
	Zhou Wang <wangzhou1@hisilicon.com>,
	Roy Zang <tie-fei.zang@freescale.com>
Subject: Re: [RFC/RFT PATCH 08/18] PCI: designware: Convert PCI scan API to pci_scan_root_bus_bridge()
Date: Fri, 2 Jun 2017 14:56:19 +0100	[thread overview]
Message-ID: <20170602135619.GA10491@red-moon> (raw)
In-Reply-To: <CAK8P3a0DRFxz_yjCeFZJ8Zukuy8gi9hPbWEfp29TaF2TMjrnTQ@mail.gmail.com>

On Fri, Jun 02, 2017 at 03:12:48PM +0200, Arnd Bergmann wrote:
> On Fri, Jun 2, 2017 at 1:49 PM, Lorenzo Pieralisi
> <lorenzo.pieralisi@arm.com> wrote:
> > On Fri, Apr 28, 2017 at 03:13:04PM +0200, Arnd Bergmann wrote:
> >> On Wed, Apr 26, 2017 at 1:17 PM, Lorenzo Pieralisi
> >> <lorenzo.pieralisi@arm.com> wrote:
> >> > The introduction of pci_scan_root_bus_bridge() provides a PCI core
> >> > API to scan a PCI root bus backed by an already initialized
> >> > struct pci_host_bridge object, which simplifies the bus scan
> >> > interface and makes the PCI scan root bus interface easier to
> >> > generalize as members are added to the struct pci_host_bridge().
> >> >
> >> > Convert PCI designware host code to pci_scan_root_bus_bridge() to
> >> > improve the PCI root bus scanning interface.
> >> >
> >> > Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> >> > Cc: Jingoo Han <jingoohan1@gmail.com>
> >> > Cc: Bjorn Helgaas <bhelgaas@google.com>
> >> > Cc: Joao Pinto <Joao.Pinto@synopsys.com>
> >> > ---
> >> >  drivers/pci/dwc/pcie-designware-host.c | 36 +++++++++++++++++++++-------------
> >> >  1 file changed, 22 insertions(+), 14 deletions(-)
> >> >
> >> > diff --git a/drivers/pci/dwc/pcie-designware-host.c b/drivers/pci/dwc/pcie-designware-host.c
> >> > index 5ba3349..e43c21a 100644
> >> > --- a/drivers/pci/dwc/pcie-designware-host.c
> >> > +++ b/drivers/pci/dwc/pcie-designware-host.c
> >> > @@ -294,16 +294,21 @@ int dw_pcie_host_init(struct pcie_port *pp)
> >> >                 dev_err(dev, "missing *config* reg space\n");
> >> >         }
> >> >
> >> > -       ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &res, &pp->io_base);
> >> > +       bridge = pci_alloc_host_bridge(0);
> >> > +       if (!bridge)
> >> > +               return  -ENOMEM;
> >> > +
> >>
> >> I think here we warn to have the pci_alloc_host_bridge() called in the
> >> individual
> >> drivers, to have them allocate the dw_pcie structure as part of the host
> >> bridge allocation, before calling hisi_add_pcie_port().
> >
> > I am almost done refactoring this series and this is the last review to
> > address. What you suggest above makes sense but:
> >
> > 1) it means patching ALL dw_pcie_host_init() callers and allocate the
> >    host bridge there, not sure it simplifies, certainly it complicates
> >    the error handling path (given that the host bridge memory is
> >    probably the only memory that is allocated with kzalloc instead of
> >    devm interface so it needs unwinding)
> >
> > 2) I noticed that allocating the host bridge in the caller complicates
> >    error handling, in particular code in the mainline (ie tegra and
> >    ftpci100) using pci_alloc_host_bridge() needs already patching since it
> >    may leak memory if PCI host bridge drivers probing fails.
> >
> > I can implement (1) and (2) but I wanted to ask first to understand if
> > that's the direction we want to take.
> 
> Good question. Maybe we should add a devm_pci_alloc_host_bridge()
> instead? Would that solve these problems without creating bigger ones?

It would be yet another PCI core call (ie unfortunately we still need
pci_alloc_host_bridge() for bridges with no parent device eg bios32) but
I think that's the only option we have if we do not want to clutter the
host bridges error paths with host bridge free calls.

Implementing it should be relatively simple by reshuffling functions.

Thoughts ?

Lorenzo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC/RFT PATCH 08/18] PCI: designware: Convert PCI scan API to pci_scan_root_bus_bridge()
Date: Fri, 2 Jun 2017 14:56:19 +0100	[thread overview]
Message-ID: <20170602135619.GA10491@red-moon> (raw)
In-Reply-To: <CAK8P3a0DRFxz_yjCeFZJ8Zukuy8gi9hPbWEfp29TaF2TMjrnTQ@mail.gmail.com>

On Fri, Jun 02, 2017 at 03:12:48PM +0200, Arnd Bergmann wrote:
> On Fri, Jun 2, 2017 at 1:49 PM, Lorenzo Pieralisi
> <lorenzo.pieralisi@arm.com> wrote:
> > On Fri, Apr 28, 2017 at 03:13:04PM +0200, Arnd Bergmann wrote:
> >> On Wed, Apr 26, 2017 at 1:17 PM, Lorenzo Pieralisi
> >> <lorenzo.pieralisi@arm.com> wrote:
> >> > The introduction of pci_scan_root_bus_bridge() provides a PCI core
> >> > API to scan a PCI root bus backed by an already initialized
> >> > struct pci_host_bridge object, which simplifies the bus scan
> >> > interface and makes the PCI scan root bus interface easier to
> >> > generalize as members are added to the struct pci_host_bridge().
> >> >
> >> > Convert PCI designware host code to pci_scan_root_bus_bridge() to
> >> > improve the PCI root bus scanning interface.
> >> >
> >> > Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> >> > Cc: Jingoo Han <jingoohan1@gmail.com>
> >> > Cc: Bjorn Helgaas <bhelgaas@google.com>
> >> > Cc: Joao Pinto <Joao.Pinto@synopsys.com>
> >> > ---
> >> >  drivers/pci/dwc/pcie-designware-host.c | 36 +++++++++++++++++++++-------------
> >> >  1 file changed, 22 insertions(+), 14 deletions(-)
> >> >
> >> > diff --git a/drivers/pci/dwc/pcie-designware-host.c b/drivers/pci/dwc/pcie-designware-host.c
> >> > index 5ba3349..e43c21a 100644
> >> > --- a/drivers/pci/dwc/pcie-designware-host.c
> >> > +++ b/drivers/pci/dwc/pcie-designware-host.c
> >> > @@ -294,16 +294,21 @@ int dw_pcie_host_init(struct pcie_port *pp)
> >> >                 dev_err(dev, "missing *config* reg space\n");
> >> >         }
> >> >
> >> > -       ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &res, &pp->io_base);
> >> > +       bridge = pci_alloc_host_bridge(0);
> >> > +       if (!bridge)
> >> > +               return  -ENOMEM;
> >> > +
> >>
> >> I think here we warn to have the pci_alloc_host_bridge() called in the
> >> individual
> >> drivers, to have them allocate the dw_pcie structure as part of the host
> >> bridge allocation, before calling hisi_add_pcie_port().
> >
> > I am almost done refactoring this series and this is the last review to
> > address. What you suggest above makes sense but:
> >
> > 1) it means patching ALL dw_pcie_host_init() callers and allocate the
> >    host bridge there, not sure it simplifies, certainly it complicates
> >    the error handling path (given that the host bridge memory is
> >    probably the only memory that is allocated with kzalloc instead of
> >    devm interface so it needs unwinding)
> >
> > 2) I noticed that allocating the host bridge in the caller complicates
> >    error handling, in particular code in the mainline (ie tegra and
> >    ftpci100) using pci_alloc_host_bridge() needs already patching since it
> >    may leak memory if PCI host bridge drivers probing fails.
> >
> > I can implement (1) and (2) but I wanted to ask first to understand if
> > that's the direction we want to take.
> 
> Good question. Maybe we should add a devm_pci_alloc_host_bridge()
> instead? Would that solve these problems without creating bigger ones?

It would be yet another PCI core call (ie unfortunately we still need
pci_alloc_host_bridge() for bridges with no parent device eg bios32) but
I think that's the only option we have if we do not want to clutter the
host bridges error paths with host bridge free calls.

Implementing it should be relatively simple by reshuffling functions.

Thoughts ?

Lorenzo

  reply	other threads:[~2017-06-02 13:56 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26 11:17 [RFC/RFT PATCH 00/18] PCI: ARM/ARM64: remove pci_fixup_irqs() usage Lorenzo Pieralisi
2017-04-26 11:17 ` Lorenzo Pieralisi
2017-04-26 11:17 ` [RFC/RFT PATCH 01/18] PCI: Initialize bridge release function at bridge allocation Lorenzo Pieralisi
2017-04-26 11:17   ` Lorenzo Pieralisi
2017-04-28 12:13   ` Arnd Bergmann
2017-04-28 12:13     ` Arnd Bergmann
2017-04-26 11:17 ` [RFC/RFT PATCH 02/18] PCI: Add pci_free_host_bridge interface Lorenzo Pieralisi
2017-04-26 11:17   ` Lorenzo Pieralisi
2017-04-28 12:14   ` Arnd Bergmann
2017-04-28 12:14     ` Arnd Bergmann
2017-04-26 11:17 ` [RFC/RFT PATCH 03/18] PCI: Introduce pci_scan_root_bus_bridge() Lorenzo Pieralisi
2017-04-26 11:17   ` Lorenzo Pieralisi
2017-04-28 12:28   ` Arnd Bergmann
2017-04-28 12:28     ` Arnd Bergmann
2017-05-02 17:15     ` Lorenzo Pieralisi
2017-05-02 17:15       ` Lorenzo Pieralisi
2017-05-02 19:36       ` Arnd Bergmann
2017-05-02 19:36         ` Arnd Bergmann
2017-05-25 20:56       ` Bjorn Helgaas
2017-05-25 20:56         ` Bjorn Helgaas
2017-05-26 13:07         ` Lorenzo Pieralisi
2017-05-26 13:07           ` Lorenzo Pieralisi
2017-05-26 17:29           ` Ray Jui
2017-05-26 17:29             ` Ray Jui
2017-05-31 10:20             ` Lorenzo Pieralisi
2017-05-31 10:20               ` Lorenzo Pieralisi
2017-05-30 11:16           ` Oza Oza
2017-05-30 11:16             ` Oza Oza
2017-05-31 11:13         ` Lorenzo Pieralisi
2017-05-31 11:13           ` Lorenzo Pieralisi
2017-04-26 11:17 ` [RFC/RFT PATCH 04/18] ARM: PCI: bios32: Convert PCI scan API to pci_scan_root_bus_bridge() Lorenzo Pieralisi
2017-04-26 11:17   ` Lorenzo Pieralisi
2017-04-28 12:41   ` Arnd Bergmann
2017-04-28 12:41     ` Arnd Bergmann
2017-04-26 11:17 ` [RFC/RFT PATCH 05/18] ARM: PCI: dove: " Lorenzo Pieralisi
2017-04-26 11:17   ` Lorenzo Pieralisi
2017-04-28 12:38   ` Arnd Bergmann
2017-04-28 12:38     ` Arnd Bergmann
2017-04-28 12:52     ` Arnd Bergmann
2017-04-28 12:52       ` Arnd Bergmann
2017-05-03 10:31     ` Lorenzo Pieralisi
2017-05-03 10:31       ` Lorenzo Pieralisi
2017-05-03 12:02       ` Arnd Bergmann
2017-05-03 12:02         ` Arnd Bergmann
2017-04-26 11:17 ` [RFC/RFT PATCH 06/18] ARM: PCI: iop13xx: " Lorenzo Pieralisi
2017-04-26 11:17   ` Lorenzo Pieralisi
2017-04-26 11:17 ` [RFC/RFT PATCH 07/18] ARM: PCI: orion5x: " Lorenzo Pieralisi
2017-04-26 11:17   ` Lorenzo Pieralisi
2017-04-26 15:12   ` Andrew Lunn
2017-04-26 15:12     ` Andrew Lunn
2017-04-26 16:13     ` Lorenzo Pieralisi
2017-04-26 16:13       ` Lorenzo Pieralisi
2017-04-26 18:53       ` Andrew Lunn
2017-04-26 18:53         ` Andrew Lunn
2017-04-27 10:40         ` Lorenzo Pieralisi
2017-04-27 10:40           ` Lorenzo Pieralisi
2017-04-26 11:17 ` [RFC/RFT PATCH 08/18] PCI: designware: " Lorenzo Pieralisi
2017-04-26 11:17   ` Lorenzo Pieralisi
2017-04-28 13:13   ` Arnd Bergmann
2017-04-28 13:13     ` Arnd Bergmann
2017-05-03 10:16     ` Lorenzo Pieralisi
2017-05-03 10:16       ` Lorenzo Pieralisi
2017-06-02 11:49     ` Lorenzo Pieralisi
2017-06-02 11:49       ` Lorenzo Pieralisi
2017-06-02 13:12       ` Arnd Bergmann
2017-06-02 13:12         ` Arnd Bergmann
2017-06-02 13:56         ` Lorenzo Pieralisi [this message]
2017-06-02 13:56           ` Lorenzo Pieralisi
2017-06-02 14:44           ` Arnd Bergmann
2017-06-02 14:44             ` Arnd Bergmann
2017-04-26 11:18 ` [RFC/RFT PATCH 09/18] PCI: aardvark: " Lorenzo Pieralisi
2017-04-26 11:18   ` Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 10/18] PCI: rcar: " Lorenzo Pieralisi
2017-04-26 11:18   ` Lorenzo Pieralisi
2017-04-28 12:53   ` Arnd Bergmann
2017-04-28 12:53     ` Arnd Bergmann
2017-04-26 11:18 ` [RFC/RFT PATCH 11/18] PCI: Remove pci_scan_root_bus_msi() Lorenzo Pieralisi
2017-04-26 11:18   ` Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 12/18] PCI: Build setup-irq.o on all arches Lorenzo Pieralisi
2017-04-26 11:18   ` Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 13/18] PCI: Add IRQ mapping function pointers to pci_host_bridge struct Lorenzo Pieralisi
2017-04-26 11:18   ` Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 14/18] PCI: Add pci_assign_irq() function and have pci_fixup_irqs() use it Lorenzo Pieralisi
2017-04-26 11:18   ` Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 15/18] OF/PCI: Update of_irq_parse_and_map_pci() comment Lorenzo Pieralisi
2017-04-26 11:18   ` Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 16/18] PCI: Add a call to pci_assign_irq() in pci_device_probe() Lorenzo Pieralisi
2017-04-26 11:18   ` Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 17/18] ARM: PCI: Remove pci_fixup_irqs() call for bios32 host controllers Lorenzo Pieralisi
2017-04-26 11:18   ` Lorenzo Pieralisi
2017-04-26 11:18 ` [RFC/RFT PATCH 18/18] ARM/ARM64: PCI: Drop pci_fixup_irqs() usage for DT based " Lorenzo Pieralisi
2017-04-26 11:18   ` Lorenzo Pieralisi
2017-04-28 13:05   ` Arnd Bergmann
2017-04-28 13:05     ` Arnd Bergmann
2017-05-03 10:51     ` Lorenzo Pieralisi
2017-05-03 10:51       ` Lorenzo Pieralisi
2017-04-27 20:06 ` [RFC/RFT PATCH 00/18] PCI: ARM/ARM64: remove pci_fixup_irqs() usage Thierry Reding
2017-04-27 20:06   ` Thierry Reding
2017-05-03 10:34   ` Lorenzo Pieralisi
2017-05-03 10:34     ` Lorenzo Pieralisi

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=20170602135619.GA10491@red-moon \
    --to=lorenzo.pieralisi@arm.com \
    --cc=Joao.Pinto@synopsys.com \
    --cc=arnd@arndb.de \
    --cc=bharat.kumar.gogada@xilinx.com \
    --cc=bhelgaas@google.com \
    --cc=gabriele.paoloni@huawei.com \
    --cc=horms@verge.net.au \
    --cc=jingoohan1@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=m-karicheri2@ti.com \
    --cc=matt@masarand.com \
    --cc=michal.simek@xilinx.com \
    --cc=minghuan.Lian@freescale.com \
    --cc=mingkai.hu@freescale.com \
    --cc=pratyush.anand@gmail.com \
    --cc=robh@kernel.org \
    --cc=shawn.lin@rock-chips.com \
    --cc=svarbanov@mm-sol.com \
    --cc=thierry.reding@gmail.com \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=tie-fei.zang@freescale.com \
    --cc=tinamdar@apm.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=wenrui.li@rock-chips.com \
    --cc=will.deacon@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.