All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Jiang Liu <liuj97@gmail.com>, Jiang Liu <jiang.liu@huawei.com>,
	Yijing Wang <wangyijing@huawei.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>
Subject: Re: [PATCH 2/2] PCI: make PCI host bridge/bus creating and destroying logic symmetric
Date: Fri, 7 Jun 2013 19:51:33 -0600	[thread overview]
Message-ID: <20130608015133.GB5874@google.com> (raw)
In-Reply-To: <CAE9FiQUDnU_DaXDKKnRh=VYQ6Y+FeWHsKB7rnN2Gn3d0EoGLPg@mail.gmail.com>

On Thu, Jun 06, 2013 at 01:01:23PM -0700, Yinghai Lu wrote:
> On Thu, Jun 6, 2013 at 10:10 AM, Jiang Liu <liuj97@gmail.com> wrote:
> > This patch makes PCI host bridge/bus creating and destroying logic
> > symmetric by using device_initialize()/device_add()/device_del()/put_device()
> > pairs as discussed in thread at:
> > http://comments.gmane.org/gmane.linux.kernel.pci/22073
> >
> > It also fixes a bug in error recovery path in pci_create_root_bus()
> > which may kfree() an in-use host bridge object.
> >
> > Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> > Cc: Yinghai Lu <yinghai@kernel.org>
> > ---
> >  drivers/pci/probe.c  | 92 +++++++++++++++++++++++-----------------------------
> >  drivers/pci/remove.c |  3 +-
> >  2 files changed, 42 insertions(+), 53 deletions(-)
> >
> > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> > index 2f81a0a..9e9cdfe 100644
> > --- a/drivers/pci/probe.c
> > +++ b/drivers/pci/probe.c
> > ...
> > +static void pci_release_host_bridge_dev(struct device *dev)
> > +{
> > +       struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
> > +
> > +       if (bridge->release_fn)
> > +               bridge->release_fn(bridge);
> > +
> > +       pci_free_resource_list(&bridge->windows);
> > +
> > +       kfree(bridge);
> > +}
> > +
> 
> should split pci_release_host_bridge_dev renaming and moving to another patch.

I split the rename/move to another patch and added both to my
pci/jiang-bus-lock-v3 branch.

> > @@ -1726,30 +1722,21 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
> >                 goto err_out;
> >
> >         bridge->dev.parent = parent;
> > -       bridge->dev.release = pci_release_bus_bridge_dev;
> > -       dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
> >         error = pcibios_root_bridge_prepare(bridge);
> > -       if (error) {
> > -               kfree(bridge);
> > -               goto err_out;
> > -       }
> > +       if (error)
> > +               goto bridge_dev_reg_err;
> > +
> > +       error = device_add(&bridge->dev);
> > +       if (error)
> > +               goto bridge_dev_reg_err;
> >
> > -       error = device_register(&bridge->dev);
> > -       if (error) {
> > -               kfree(bridge);
> > -               goto err_out;
> > -       }

I think this function would be better if we created the host bridge
first, then the bus.  But your patch is an improvement, so we can look
at doing that later.

> looks like we don't need to split device_register to device_del and put_device.
> 
> we can make root bus removal to use device_unregister too, in the patches,

If we can use device_register()/device_unregister() directly instead of
splitting them into initialize/add/del/put, that would be awesome.

Anyway, http://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/jiang-bus-lock-v3
is the current state of what I've got.  If you want to iterate on this some
more and improve things, that's great.  But please start with what's on my
branch and post your updates as a complete v4 because I did tweak some
changelogs and code formatting, and I don't want to lose that work.

Bjorn

  reply	other threads:[~2013-06-08  1:51 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-25 13:48 [PATCH v3, part1 00/10] Prepare for introducing PCI bus lock interfaces Jiang Liu
2013-05-25 13:48 ` [PATCH v3, part1 01/10] PCI: introduce pci_bus_{get|put}() to manage PCI bus reference count Jiang Liu
2013-05-25 13:48 ` [PATCH v3, part1 02/10] PCI: Introduce pci_alloc_dev(struct pci_bus*) to replace alloc_pci_dev() Jiang Liu
2013-05-25 13:48 ` [PATCH v3, part1 03/10] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead Jiang Liu
2013-05-25 13:48   ` Jiang Liu
2013-05-25 13:48   ` Jiang Liu
2013-06-05 20:07   ` Bjorn Helgaas
2013-06-05 20:07     ` Bjorn Helgaas
2013-06-05 20:07     ` Bjorn Helgaas
2013-06-06 16:16     ` Jiang Liu
2013-06-06 16:16       ` Jiang Liu
2013-06-06 16:16       ` Jiang Liu
2013-05-25 13:48 ` [PATCH v3, part1 04/10] PCI: mark pci_scan_bus_parented() as __deprecated Jiang Liu
2013-05-31 20:12   ` Chris Metcalf
2013-06-05 20:04   ` Bjorn Helgaas
2013-06-06 16:32     ` Jiang Liu
2013-06-07 14:37       ` Konrad Rzeszutek Wilk
2013-06-07 15:11         ` Jiang Liu
2013-06-07 15:30         ` Jiang Liu
2013-06-07 20:37           ` Bjorn Helgaas
2013-05-25 13:48 ` [PATCH v3, part1 05/10] PCI, IA64: minor code clean up Jiang Liu
2013-05-25 13:48   ` Jiang Liu
2013-05-25 13:48 ` [PATCH v3, part1 06/10] PCI: make PCI host bridge/bus creating and destroying logic symmetric Jiang Liu
2013-06-05 20:14   ` Bjorn Helgaas
2013-06-06 17:10     ` [PATCH 1/2] PCI: fix a double free issue in pci_create_root_bus() error recovery path Jiang Liu
2013-06-08  1:42       ` Bjorn Helgaas
2013-06-06 17:10     ` [PATCH 2/2] PCI: make PCI host bridge/bus creating and destroying logic symmetric Jiang Liu
2013-06-06 20:01       ` Yinghai Lu
2013-06-08  1:51         ` Bjorn Helgaas [this message]
2013-06-08  7:01           ` Yinghai Lu
2013-06-14 23:53             ` Bjorn Helgaas
2013-06-15  1:46               ` Jiang Liu
2013-05-25 13:48 ` [PATCH v3, part1 07/10] PCI, unicore, m68k: remove redundant call of pci_bus_add_devices() Jiang Liu
2013-06-05 21:31   ` Bjorn Helgaas
2013-06-05 21:31     ` Bjorn Helgaas
2013-06-06  6:54     ` Greg Ungerer
2013-06-06  6:54       ` Greg Ungerer
2013-06-05 21:31   ` Bjorn Helgaas
2013-05-25 13:48 ` [PATCH v3, part1 08/10] PCI, IOV: don't touch bus->is_added flag Jiang Liu
2013-05-25 13:48 ` [PATCH v3, part1 09/10] PCI, IOV: simplify IOV implementation Jiang Liu
2013-05-28  2:00   ` Yinghai Lu
2013-05-28 14:48     ` Liu Jiang
2013-05-30  4:31   ` [PATCH] PCI, IOV: fix a resource leakage on error recovery path Jiang Liu
2013-05-30 18:24     ` Bjorn Helgaas
2013-05-25 13:48 ` [PATCH v3, part1 10/10] PCI, IOV: hide remove and rescan sysfs interfaces for SR-IOV virtual functions Jiang Liu

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=20130608015133.GB5874@google.com \
    --to=bhelgaas@google.com \
    --cc=jiang.liu@huawei.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=liuj97@gmail.com \
    --cc=wangyijing@huawei.com \
    --cc=yinghai@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 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.