From: Liu Jiang <liuj97@gmail.com>
To: Gu Zheng <guz.fnst@cn.fujitsu.com>
Cc: Yinghai Lu <yinghai@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
"Rafael J . Wysocki" <rjw@sisk.pl>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Toshi Kani <toshi.kani@hp.com>,
Myron Stowe <myron.stowe@redhat.com>,
Yijing Wang <wangyijing@huawei.com>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
"David S. Miller" <davem@davemloft.net>,
David Airlie <airlied@linux.ie>,
Neela Syam Kolli <megaraidlinux@lsi.com>,
"James E.J. Bottomley" <JBottomley@parallels.com>,
Andrew Morton <akpm@linux-foundation.org>,
linuxppc-dev@lists.ozlabs.org,
"sparclinux@vger.kernel.org" <sparclinux@vger.kernel.org>,
Linux-Scsi <linux-scsi@vger.kernel.org>,
Jiang Liu <jiang.liu@huawei.com>
Subject: Re: [PATCH v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead
Date: Tue, 14 May 2013 22:59:02 +0800 [thread overview]
Message-ID: <51925136.5050302@gmail.com> (raw)
In-Reply-To: <5191F53E.4000305@cn.fujitsu.com>
On 05/14/2013 04:26 PM, Gu Zheng wrote:
> On 05/14/2013 01:23 AM, Yinghai Lu wrote:
>
>> On Mon, May 13, 2013 at 9:08 AM, Jiang Liu <liuj97@gmail.com> wrote:
>>> From: Gu Zheng <guz.fnst@cn.fujitsu.com>
>>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>>> index 4f0bc0a..bc075a3 100644
>>> --- a/drivers/pci/probe.c
>>> +++ b/drivers/pci/probe.c
>>> @@ -1131,6 +1131,7 @@ static void pci_release_dev(struct device *dev)
>>> struct pci_dev *pci_dev;
>>>
>>> pci_dev = to_pci_dev(dev);
>>> + pci_bus_put(pci_dev->bus);
>>> pci_release_capabilities(pci_dev);
>>> pci_release_of_node(pci_dev);
>>> kfree(pci_dev);
>>> @@ -1269,11 +1270,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
>>> if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
>>> return NULL;
>>>
>>> - dev = alloc_pci_dev();
>>> + dev = pci_alloc_dev(bus);
>>> if (!dev)
>>> return NULL;
>>>
>>> - dev->bus = bus;
>>> dev->devfn = devfn;
>>> dev->vendor = l & 0xffff;
>>> dev->device = (l >> 16) & 0xffff;
>> in pci_setup_device() fail path, it release the ref to that bus.
> Yes, you're right, we need to release the bus' ref if pci_setup_device() failed.
Hi Zheng,
I suggest to use pci_release_dev() instead because it also needs to
release OF related resources.
I will update it in next version.
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index bc075a3..2ac6338 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1281,7 +1281,7 @@ static struct pci_dev *pci_scan_device(struct
pci_bus *bus
pci_set_of_node(dev);
if (pci_setup_device(dev)) {
- kfree(dev);
+ pci_release_dev(&dev->dev);
return NULL;
}
> hanks for your correction.:)
>
> Best regards,
> Gu
>
>> Yinghai
>>
>
WARNING: multiple messages have this Message-ID (diff)
From: Liu Jiang <liuj97@gmail.com>
To: Gu Zheng <guz.fnst@cn.fujitsu.com>
Cc: Neela Syam Kolli <megaraidlinux@lsi.com>,
"sparclinux@vger.kernel.org" <sparclinux@vger.kernel.org>,
Toshi Kani <toshi.kani@hp.com>, Jiang Liu <jiang.liu@huawei.com>,
Linux-Scsi <linux-scsi@vger.kernel.org>,
David Airlie <airlied@linux.ie>,
Myron Stowe <myron.stowe@redhat.com>,
linuxppc-dev@lists.ozlabs.org,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"James E.J. Bottomley" <JBottomley@parallels.com>,
"Rafael J . Wysocki" <rjw@sisk.pl>,
Yijing Wang <wangyijing@huawei.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Paul Mackerras <paulus@samba.org>,
Andrew Morton <akpm@linux-foundation.org>,
Yinghai Lu <yinghai@kernel.org>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead
Date: Tue, 14 May 2013 22:59:02 +0800 [thread overview]
Message-ID: <51925136.5050302@gmail.com> (raw)
In-Reply-To: <5191F53E.4000305@cn.fujitsu.com>
On 05/14/2013 04:26 PM, Gu Zheng wrote:
> On 05/14/2013 01:23 AM, Yinghai Lu wrote:
>
>> On Mon, May 13, 2013 at 9:08 AM, Jiang Liu <liuj97@gmail.com> wrote:
>>> From: Gu Zheng <guz.fnst@cn.fujitsu.com>
>>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>>> index 4f0bc0a..bc075a3 100644
>>> --- a/drivers/pci/probe.c
>>> +++ b/drivers/pci/probe.c
>>> @@ -1131,6 +1131,7 @@ static void pci_release_dev(struct device *dev)
>>> struct pci_dev *pci_dev;
>>>
>>> pci_dev = to_pci_dev(dev);
>>> + pci_bus_put(pci_dev->bus);
>>> pci_release_capabilities(pci_dev);
>>> pci_release_of_node(pci_dev);
>>> kfree(pci_dev);
>>> @@ -1269,11 +1270,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
>>> if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
>>> return NULL;
>>>
>>> - dev = alloc_pci_dev();
>>> + dev = pci_alloc_dev(bus);
>>> if (!dev)
>>> return NULL;
>>>
>>> - dev->bus = bus;
>>> dev->devfn = devfn;
>>> dev->vendor = l & 0xffff;
>>> dev->device = (l >> 16) & 0xffff;
>> in pci_setup_device() fail path, it release the ref to that bus.
> Yes, you're right, we need to release the bus' ref if pci_setup_device() failed.
Hi Zheng,
I suggest to use pci_release_dev() instead because it also needs to
release OF related resources.
I will update it in next version.
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index bc075a3..2ac6338 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1281,7 +1281,7 @@ static struct pci_dev *pci_scan_device(struct
pci_bus *bus
pci_set_of_node(dev);
if (pci_setup_device(dev)) {
- kfree(dev);
+ pci_release_dev(&dev->dev);
return NULL;
}
> hanks for your correction.:)
>
> Best regards,
> Gu
>
>> Yinghai
>>
>
WARNING: multiple messages have this Message-ID (diff)
From: Liu Jiang <liuj97@gmail.com>
To: Gu Zheng <guz.fnst@cn.fujitsu.com>
Cc: Yinghai Lu <yinghai@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
"Rafael J . Wysocki" <rjw@sisk.pl>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Toshi Kani <toshi.kani@hp.com>,
Myron Stowe <myron.stowe@redhat.com>,
Yijing Wang <wangyijing@huawei.com>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
"David S. Miller" <davem@davemloft.net>,
David Airlie <airlied@linux.ie>,
Neela Syam Kolli <megaraidlinux@lsi.com>,
"James E.J. Bottomley" <JBottomley@parallels.com>,
Andrew Morton <akpm@linux-foundation.org>,
linuxppc-dev@lists.ozlabs.org,
"sparclinux@vger.kernel.org" <sparclinux@vger.kernel.org>,
Linux-Scsi <linux-scsi@vger.kernel.org>,
Jiang Liu <jiang.liu@huawei.com>
Subject: Re: [PATCH v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead
Date: Tue, 14 May 2013 14:59:02 +0000 [thread overview]
Message-ID: <51925136.5050302@gmail.com> (raw)
In-Reply-To: <5191F53E.4000305@cn.fujitsu.com>
On 05/14/2013 04:26 PM, Gu Zheng wrote:
> On 05/14/2013 01:23 AM, Yinghai Lu wrote:
>
>> On Mon, May 13, 2013 at 9:08 AM, Jiang Liu <liuj97@gmail.com> wrote:
>>> From: Gu Zheng <guz.fnst@cn.fujitsu.com>
>>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>>> index 4f0bc0a..bc075a3 100644
>>> --- a/drivers/pci/probe.c
>>> +++ b/drivers/pci/probe.c
>>> @@ -1131,6 +1131,7 @@ static void pci_release_dev(struct device *dev)
>>> struct pci_dev *pci_dev;
>>>
>>> pci_dev = to_pci_dev(dev);
>>> + pci_bus_put(pci_dev->bus);
>>> pci_release_capabilities(pci_dev);
>>> pci_release_of_node(pci_dev);
>>> kfree(pci_dev);
>>> @@ -1269,11 +1270,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
>>> if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
>>> return NULL;
>>>
>>> - dev = alloc_pci_dev();
>>> + dev = pci_alloc_dev(bus);
>>> if (!dev)
>>> return NULL;
>>>
>>> - dev->bus = bus;
>>> dev->devfn = devfn;
>>> dev->vendor = l & 0xffff;
>>> dev->device = (l >> 16) & 0xffff;
>> in pci_setup_device() fail path, it release the ref to that bus.
> Yes, you're right, we need to release the bus' ref if pci_setup_device() failed.
Hi Zheng,
I suggest to use pci_release_dev() instead because it also needs to
release OF related resources.
I will update it in next version.
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index bc075a3..2ac6338 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1281,7 +1281,7 @@ static struct pci_dev *pci_scan_device(struct
pci_bus *bus
pci_set_of_node(dev);
if (pci_setup_device(dev)) {
- kfree(dev);
+ pci_release_dev(&dev->dev);
return NULL;
}
> hanks for your correction.:)
>
> Best regards,
> Gu
>
>> Yinghai
>>
>
next prev parent reply other threads:[~2013-05-14 14:59 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-13 16:08 [PATCH v2, part 1 0/9] Prepare for introducing PCI bus lock interfaces Jiang Liu
2013-05-13 16:08 ` [PATCH v2, part 1 1/9] PCI: introduce pci_bus_{get|put}() to manage PCI bus reference count Jiang Liu
2013-05-13 16:08 ` [PATCH v2, part 1 2/9] PCI: Introduce pci_alloc_dev(struct pci_bus*) to replace alloc_pci_dev() Jiang Liu
2013-05-13 16:08 ` [PATCH v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead Jiang Liu
2013-05-13 16:08 ` Jiang Liu
2013-05-13 16:08 ` Jiang Liu
2013-05-13 17:23 ` Yinghai Lu
2013-05-13 17:23 ` Yinghai Lu
2013-05-13 17:23 ` Yinghai Lu
2013-05-14 8:26 ` Gu Zheng
2013-05-14 8:26 ` Gu Zheng
2013-05-14 8:26 ` Gu Zheng
2013-05-14 14:59 ` Liu Jiang [this message]
2013-05-14 14:59 ` Liu Jiang
2013-05-14 14:59 ` Liu Jiang
2013-05-14 15:10 ` Yinghai Lu
2013-05-14 15:10 ` Yinghai Lu
2013-05-14 15:10 ` Yinghai Lu
2013-05-14 16:57 ` Liu Jiang
2013-05-14 16:57 ` Liu Jiang
2013-05-14 16:57 ` Liu Jiang
2013-05-14 18:52 ` Yinghai Lu
2013-05-14 18:52 ` Yinghai Lu
2013-05-14 18:52 ` Yinghai Lu
2013-05-15 14:39 ` Liu Jiang
2013-05-15 14:39 ` Liu Jiang
2013-05-15 14:39 ` Liu Jiang
2013-05-15 14:43 ` Yinghai Lu
2013-05-15 14:43 ` Yinghai Lu
2013-05-15 14:43 ` Yinghai Lu
2013-05-15 14:46 ` Liu Jiang
2013-05-15 14:46 ` Liu Jiang
2013-05-15 14:46 ` Liu Jiang
2013-05-15 14:58 ` Yinghai Lu
2013-05-15 14:58 ` Yinghai Lu
2013-05-15 14:58 ` Yinghai Lu
2013-05-15 21:32 ` Benjamin Herrenschmidt
2013-05-15 21:32 ` Benjamin Herrenschmidt
2013-05-15 21:32 ` Benjamin Herrenschmidt
2013-05-15 21:52 ` Yinghai Lu
2013-05-15 21:52 ` Yinghai Lu
2013-05-15 21:52 ` Yinghai Lu
2013-05-15 21:29 ` Benjamin Herrenschmidt
2013-05-15 21:29 ` Benjamin Herrenschmidt
2013-05-15 21:29 ` Benjamin Herrenschmidt
2013-05-15 23:46 ` Liu Jiang
2013-05-15 23:46 ` Liu Jiang
2013-05-15 23:46 ` Liu Jiang
2013-05-13 16:08 ` [PATCH v2, part 1 4/9] PCI: mark pci_scan_bus_parented() as __deprecated Jiang Liu
2013-05-13 16:08 ` [PATCH v2, part 1 5/9] ACPI, PCI: remove unused global list acpi_pci_roots in pci_root.c Jiang Liu
2013-05-13 23:28 ` Rafael J. Wysocki
2013-05-14 12:41 ` Liu Jiang
2013-05-14 13:01 ` Rafael J. Wysocki
2013-05-13 16:08 ` [PATCH v2, part 1 6/9] ACPI, pci_root: use acpi_handle_print() and pr_xxx() to print messages Jiang Liu
2013-05-13 23:27 ` Rafael J. Wysocki
2013-05-14 12:46 ` Liu Jiang
2013-05-14 8:43 ` Gu Zheng
2013-05-13 16:08 ` [PATCH v2, part 1 7/9] PCI, IA64: minor code clean up Jiang Liu
2013-05-13 16:08 ` Jiang Liu
2013-05-13 16:08 ` [PATCH v2, part 1 8/9] PCI: make PCI host bridge/bus creating and destroying logic symmetric Jiang Liu
2013-05-20 6:35 ` Gu Zheng
2013-05-20 15:52 ` Liu Jiang
2013-05-13 16:08 ` [PATCH v2, part 1 9/9] PCI, unicore, m68k: remove redundant call of pci_bus_add_devices() 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=51925136.5050302@gmail.com \
--to=liuj97@gmail.com \
--cc=JBottomley@parallels.com \
--cc=airlied@linux.ie \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=bhelgaas@google.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=guz.fnst@cn.fujitsu.com \
--cc=jiang.liu@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=megaraidlinux@lsi.com \
--cc=myron.stowe@redhat.com \
--cc=paulus@samba.org \
--cc=rjw@sisk.pl \
--cc=sparclinux@vger.kernel.org \
--cc=toshi.kani@hp.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.