From: Alex Chiang <achiang@hp.com>
To: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
jbarnes@virtuousgeek.org, kristen.c.accardi@intel.com,
matthew@wil.cx
Subject: Re: [PATCH v3 02/14] PCI: prevent duplicate slot names
Date: Wed, 1 Oct 2008 22:48:26 -0600 [thread overview]
Message-ID: <20081002044825.GA18063@ldl.fc.hp.com> (raw)
In-Reply-To: <48E43657.4040006@jp.fujitsu.com>
Hi Kenji-san,
* Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>:
> Alex Chiang wrote:
>> * Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>:
>>> Kenji Kaneshige wrote:
>>>> Hi Alex-san,
>>>>
>>>> Here is one comment, though I have not finished reviewing/testing
>>>> your patches yet (sorry for the delay).
>>>>
>>>> Alex Chiang wrote:
>>>>
>>>> (snip.)
>>>>
>>>>> diff --git a/drivers/pci/hotplug/pci_hotplug_core.c
>>>>> b/drivers/pci/hotplug/pci_hotplug_core.c
>>>>> index 3e37d63..46802dc 100644
>>>>> --- a/drivers/pci/hotplug/pci_hotplug_core.c
>>>>> +++ b/drivers/pci/hotplug/pci_hotplug_core.c
>>>>> @@ -570,39 +570,32 @@ int pci_hp_register(struct hotplug_slot
>>>>> *slot, struct pci_bus *bus, int slot_nr,
>>>>> return -EINVAL;
>>>>> }
>>>>> - /* Check if we have already registered a slot with the same
>>>>> name. */
>>>>> - if (get_slot_from_name(name))
>>>>> - return -EEXIST;
>>>>> -
>>>>> /*
>>>>> - * No problems if we call this interface from both ACPI_PCI_SLOT
>>>>> - * driver and call it here again. If we've already created the
>>>>> - * pci_slot, the interface will simply bump the refcount.
>>>>> + * Look for existing slot. If we find it, and it was created by a
>>>>> + * slot detection driver (ie, doesn't have a ->hotplug()) then we
>>>>> + * allow the hotplug driver calling us to rename the slot if
>>>>> desired.
>>>>> + *
>>>>> + * Otherwise, create the slot and carry on with life.
>>>>> */
>>>>> - pci_slot = pci_create_slot(bus, slot_nr, name);
>>>>> - if (IS_ERR(pci_slot))
>>>>> - return PTR_ERR(pci_slot);
>>>>> -
>>>>> - if (pci_slot->hotplug) {
>>>>> - dbg("%s: already claimed\n", __func__);
>>>>> - pci_destroy_slot(pci_slot);
>>>>> - return -EBUSY;
>>>>> + pci_slot = pci_get_pci_slot(bus, slot_nr);
>>>> The pci_get_pci_slot() function refers pci_bus->slots list, so it
>>>> should be called with pci_bus_sem semaphore held as pci_create_slot()
>>>> does, or pci_bus_sem semaphore should be held by pci_get_pci_slot()
>>>> itself.
>>
>> Yes, I've changed pci_get_pci_slot() to acquire the pci_bus_sem
>> semaphore.
>>
>> Thank you for pointing this out.
>>
>> It will be fixed in v4 of this patch series, which I will send
>> out after I receive the rest of your review comments.
>>
>
> I noticed that changing pci_get_pci_slot() to acquire the pci_bus_sem
> might be not enough. If slot was created between pci_get_pci_slot() and
> pci_create_slot() by another thread in the following code, something
> wrong would happen I think.
>
> pci_slot = pci_get_pci_slot(bus, slot_nr);
> if (pci_slot) {
> if (pci_slot->hotplug) {
> result = -EBUSY;
> goto err;
> }
>
> if (strcmp(kobject_name(&pci_slot->kobj), name))
> if ((result = pci_rename_slot(pci_slot, name)))
> goto err;
> } else {
> pci_slot = pci_create_slot(bus, slot_nr, name);
> if ((result = IS_ERR(pci_slot)))
> goto out;
> }
I'm sorry, I don't think I see the problem you are pointing out.
If pci_get_pci_slot() finds a pci_slot, we do not modify
pci_bus->slots any further, so even if a new slot is created, it
shouldn't affect the pci_slot that we already found.
I must be missing something, but I don't know what. Would you
mind explaining what you had in mind with your comment?
> I've finished reviewing and testing your patches. The rest of your
> patch looks good to me. Of course, we must not forget the comment
> from Taku Izumi.
Yes, I've modified my patch series to take into account the bugs
that Taku-san found.
Thank you both for your reviews.
/ac
next prev parent reply other threads:[~2008-10-02 4:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-23 16:45 [PATCH v3 00/14] PCI: let the core manage slot names Alex Chiang
2008-09-23 16:45 ` [PATCH v3 01/14] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
2008-09-23 16:45 ` [PATCH v3 02/14] PCI: prevent duplicate slot names Alex Chiang
[not found] ` <48E09936.2030905@jp.fujitsu.com>
2008-09-30 2:06 ` Kenji Kaneshige
2008-10-02 1:05 ` Alex Chiang
2008-10-02 2:47 ` Kenji Kaneshige
2008-10-02 4:48 ` Alex Chiang [this message]
2008-10-03 1:33 ` Kenji Kaneshige
2008-09-23 16:45 ` [PATCH v3 03/14] PCI, PCI Hotplug: introduce slot_name helpers Alex Chiang
2008-09-23 16:45 ` [PATCH v3 04/14] PCI: acpiphp: remove 'name' parameter Alex Chiang
2008-09-23 16:45 ` [PATCH v3 05/14] PCI: cpci_hotplug: stop managing hotplug_slot->name Alex Chiang
2008-09-23 16:45 ` [PATCH v3 06/14] PCI: cpqphp: " Alex Chiang
2008-09-23 16:45 ` [PATCH v3 07/14] PCI: fakephp: remove 'name' parameter Alex Chiang
2008-09-23 16:45 ` [PATCH v3 08/14] PCI: ibmphp: stop managing hotplug_slot->name Alex Chiang
2008-09-23 16:45 ` [PATCH v3 09/14] PCI: pciehp: remove 'name' parameter Alex Chiang
2008-09-23 16:46 ` [PATCH v3 10/14] PCI: rpaphp: stop managing hotplug_slot->name Alex Chiang
2008-09-23 16:46 ` [PATCH v3 11/14] PCI: SGI Hotplug: stop managing bss_hotplug_slot->name Alex Chiang
2008-09-23 16:46 ` [PATCH v3 12/14] PCI: shcphp: remove 'name' parameter Alex Chiang
2008-09-23 16:46 ` [PATCH v3 13/14] PCI: Hotplug core: remove 'name' Alex Chiang
2008-09-23 16:46 ` [PATCH v3 14/14] PCI Hotplug: fakephp: add duplicate slot name debugging Alex Chiang
2008-09-24 8:47 ` [PATCH v3 00/14] PCI: let the core manage slot names Kenji Kaneshige
2008-09-26 8:06 ` Taku Izumi
2008-10-01 21:04 ` Alex Chiang
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=20081002044825.GA18063@ldl.fc.hp.com \
--to=achiang@hp.com \
--cc=jbarnes@virtuousgeek.org \
--cc=kaneshige.kenji@jp.fujitsu.com \
--cc=kristen.c.accardi@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=matthew@wil.cx \
/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