Message ID | 52F1A26F.3020105@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | Bjorn Helgaas |
Headers | show |
SGVsbG8sDQoNCkkgZm91bmQgdGhhdCB3aGlsZSBmaXhpbmcgdGhlIGNvbmZsaWN0cyBkdXJpbmcg cmViYXNpbmcsIGFuICJ1bnVzZWQgdmFyaWFibGUgJ3JldCcgIiB3YXJuaW5nIGhhcyBjcmVwdCB1 cCBpbiB0aGlzIHBhcnRpY3VsYXIgcGF0Y2guDQoNCkFwb2xvZ2llcyBmb3IgdGhlIHNhbWUuIEkg d2lsbCB0YWtlIGNhcmUgb2YgdGhhdCwgaG93ZXZlciwgYW0gd2FpdGluZyBmb3IgYW55IGFkZGl0 aW9uYWwgY29tbWVudHMgYmVmb3JlIHJlc2VuZGluZy4NCg0KVGhhbmtzICYgQmVzdCBSZWdhcmRz LA0KDQpSYWphdA0KDQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogUmFq YXQgSmFpbiBbbWFpbHRvOnJhamF0eGphaW5AZ21haWwuY29tXQ0KPiBTZW50OiBUdWVzZGF5LCBG ZWJydWFyeSAwNCwgMjAxNCA2OjMxIFBNDQo+IFRvOiBCam9ybiBIZWxnYWFzOyBSYWZhZWwgSi4g V3lzb2NraTsgS2VuamkgS2FuZXNoaWdlOyBBbGV4IFdpbGxpYW1zb247DQo+IFlpamluZyBXYW5n OyBsaW51eC1wY2lAdmdlci5rZXJuZWwub3JnOyBsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3Jn Ow0KPiBZaW5naGFpIEx1DQo+IENjOiBHdWVudGVyIFJvZWNrOyBSYWphdCBKYWluOyBSYWphdCBK YWluDQo+IFN1YmplY3Q6IFtQQVRDSCB2NCA4LzhdIHBjaWVocDogSW50cm9kdWNlIGhvdHBsdWdf bG9jayB0byBzZXJpYWxpemUgSFANCj4gZXZlbnRzDQo+IA0KPiBUb2RheSBpdCBpcyB0aGVyZSBp cyBuby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DQo+ICAJCWJyZWFrOw0K PiBkaWZmIC0tZ2l0IGEvZHJpdmVycy9wY2kvaG90cGx1Zy9wY2llaHBfaHBjLmMNCj4gYi9kcml2 ZXJzL3BjaS9ob3RwbHVnL3BjaWVocF9ocGMuYw0KPiBpbmRleCA2NDMzZTczLi5kYTRiMDIwIDEw MDY0NA0KPiAtLS0gYS9kcml2ZXJzL3BjaS9ob3RwbHVnL3BjaWVocF9ocGMuYw0KPiArKysgYi9k cml2ZXJzL3BjaS9ob3RwbHVnL3BjaWVocF9ocGMuYw0KPiBAQCAtNjg2LDYgKzY4Niw3IEBAIHN0 YXRpYyBpbnQgcGNpZV9pbml0X3Nsb3Qoc3RydWN0IGNvbnRyb2xsZXIgKmN0cmwpDQo+IA0KPiAg CXNsb3QtPmN0cmwgPSBjdHJsOw0KPiAgCW11dGV4X2luaXQoJnNsb3QtPmxvY2spOw0KPiArCW11 dGV4X2luaXQoJnNsb3QtPmhvdHBsdWdfbG9jayk7DQo+ICAJSU5JVF9ERUxBWUVEX1dPUksoJnNs b3QtPndvcmssIHBjaWVocF9xdWV1ZV9wdXNoYnV0dG9uX3dvcmspOw0KPiAgCWN0cmwtPnNsb3Qg PSBzbG90Ow0KPiAgCXJldHVybiAwOw0KPiAtLQ0KPiAxLjcuOS41DQo+IA0KPiANCg0K -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index d8d0336..8a66866 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -76,6 +76,7 @@ struct slot { struct hotplug_slot *hotplug_slot; struct delayed_work work; /* work for button event */ struct mutex lock; + struct mutex hotplug_lock; struct workqueue_struct *wq; }; diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 53b58de..23b4bde 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c @@ -283,8 +283,11 @@ static int pciehp_probe(struct pcie_device *dev) slot = ctrl->slot; pciehp_get_adapter_status(slot, &occupied); pciehp_get_power_status(slot, &poweron); - if (occupied && pciehp_force) + if (occupied && pciehp_force) { + mutex_lock(&slot->hotplug_lock); pciehp_enable_slot(slot); + mutex_unlock(&slot->hotplug_lock); + } /* If empty slot's power status is on, turn power off */ if (!occupied && poweron && POWER_CTRL(ctrl)) pciehp_power_off_slot(slot); @@ -328,10 +331,12 @@ static int pciehp_resume (struct pcie_device *dev) /* Check if slot is occupied */ pciehp_get_adapter_status(slot, &status); + mutex_lock(&slot->hotplug_lock); if (status) pciehp_enable_slot(slot); else pciehp_disable_slot(slot); + mutex_unlock(&slot->hotplug_lock); return 0; } #endif /* PM */ diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 3e40ec0..1f2716c 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -293,6 +293,7 @@ static void pciehp_power_thread(struct work_struct *work) struct power_work_info *info = container_of(work, struct power_work_info, work); struct slot *p_slot = info->p_slot; + int ret; switch (info->req) { case DISABLE_REQ: @@ -300,7 +301,9 @@ static void pciehp_power_thread(struct work_struct *work) "Disabling domain:bus:device=%04x:%02x:00\n", pci_domain_nr(p_slot->ctrl->pcie->port->subordinate), p_slot->ctrl->pcie->port->subordinate->number); + mutex_lock(&p_slot->hotplug_lock); pciehp_disable_slot(p_slot); + mutex_unlock(&p_slot->hotplug_lock); mutex_lock(&p_slot->lock); p_slot->state = STATIC_STATE; mutex_unlock(&p_slot->lock); @@ -310,8 +313,10 @@ static void pciehp_power_thread(struct work_struct *work) "Enabling domain:bus:device=%04x:%02x:00\n", pci_domain_nr(p_slot->ctrl->pcie->port->subordinate), p_slot->ctrl->pcie->port->subordinate->number); + mutex_lock(&p_slot->hotplug_lock); if (pciehp_enable_slot(p_slot)) pciehp_green_led_off(p_slot); + mutex_unlock(&p_slot->hotplug_lock); mutex_lock(&p_slot->lock); p_slot->state = STATIC_STATE; mutex_unlock(&p_slot->lock); @@ -546,6 +551,9 @@ static void interrupt_event_handler(struct work_struct *work) kfree(info); } +/* + * Note: This function must be called with slot->hotplug_lock held + */ int pciehp_enable_slot(struct slot *p_slot) { u8 getstatus = 0; @@ -584,7 +592,9 @@ int pciehp_enable_slot(struct slot *p_slot) return rc; } - +/* + * Note: This function must be called with slot->hotplug_lock held + */ int pciehp_disable_slot(struct slot *p_slot) { u8 getstatus = 0; @@ -617,7 +627,9 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot) case STATIC_STATE: p_slot->state = POWERON_STATE; mutex_unlock(&p_slot->lock); + mutex_lock(&p_slot->hotplug_lock); retval = pciehp_enable_slot(p_slot); + mutex_unlock(&p_slot->hotplug_lock); mutex_lock(&p_slot->lock); p_slot->state = STATIC_STATE; break; diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 6433e73..da4b020 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -686,6 +686,7 @@ static int pcie_init_slot(struct controller *ctrl) slot->ctrl = ctrl; mutex_init(&slot->lock); + mutex_init(&slot->hotplug_lock); INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work); ctrl->slot = slot; return 0;