From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: kristen.c.accardi@intel.com
Cc: linux-pci@vger.kernel.org, linux-kernel <linux-kernel@vger.kernel.org>
Subject: pciehp resume handler - racy?
Date: Tue, 30 Jun 2009 17:00:23 +0100 [thread overview]
Message-ID: <4A4A3697.7020804@tuffmail.co.uk> (raw)
Hi,
I've been hacking on the PCI hotplug driver otherwise known as
eeepc-laptop. At one point I reliably triggered a race on resume. In
the hot-unplug case, it seemed that the resume handler would try to
remove the PCI device at the same time as an acpi notification (run in a
workqueue) tried to do the same thing. The result was an OOPS. My
conclusion is that the PCI hotplug core does not protect against
multiple simultaneous removals of the same device.
pciehp appears to have an analogous problem. Assuming pciehp_force is
set, the resume handler can hot-unplug the device. The interrupt
handler could try to hot-unplug the device at the same time. Should the
resume handler take the slot mutex to avoid this problem?
diff --faked-up a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -382,15 +382,18 @@ static int pciehp_resume (struct pcie_device *dev)
/* reinitialize the chipset's event detection logic */
pcie_enable_notification(ctrl);
t_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset);
+ mutex_lock(&t_slot->lock);
/* Check if slot is occupied */
t_slot->hpc_ops->get_adapter_status(t_slot, &status);
if (status)
pciehp_enable_slot(t_slot);
else
pciehp_disable_slot(t_slot);
+
+ mutex_unlock(&t_slot->lock);
}
return 0;
}
#endif /* PM */
Regards
Alan
next reply other threads:[~2009-06-30 16:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-30 16:00 Alan Jenkins [this message]
2009-07-01 4:34 ` pciehp resume handler - racy? Kenji Kaneshige
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=4A4A3697.7020804@tuffmail.co.uk \
--to=alan-jenkins@tuffmail.co.uk \
--cc=kristen.c.accardi@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox