* [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling @ 2016-08-17 13:42 Patel, Mayurkumar 2016-08-17 17:12 ` Bjorn Helgaas 0 siblings, 1 reply; 13+ messages in thread From: Patel, Mayurkumar @ 2016-08-17 13:42 UTC (permalink / raw) To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, bhelgaas@google.com, Wysocki, Rafael J, mika.westerberg@linux.intel.com, Shevchenko, Andriy, Busch, Keith, Tarazona-Duarte, Luis Antonio, Patel, Mayurkumar Currently, if very fast hotplug removal and insertion event comes as following [ 608.823412] pciehp 0000:00:1c.1:pcie04: Card not present on Slot(1) [ 608.835249] pciehp 0000:00:1c.1:pcie04: Card present on Slot(1) In this case following scenario happens, While removal: pcie_isr() -> pciehp_queue_interrupt_event() -> triggers queue_work(). work invokes interrupt_event_handler() -> case INT_PRESENCE_OFF and calls handle_surprise_event(). handle_surprise_event() again calls pciehp_get_adapter_status() and reads slot status which might have been changed already due to PCI_EXP_SLTSTA_PDC event for hotplug insertion has happened. So it queues, ENABLE_REQ for both removal and insertion interrupt based on latest slot status. In this case, PCIe device can not be hot-add again because it was never removed due to which device can not get enabled. handle_surprise_event() can be removed and pciehp_queue_power_work() can be directly triggered based on INT_PRESENCE_ON and INT_PRESENCE_OFF from the switch case exist in interrupt_event_hanlder(). The patch ensures the pciehp_queue_power_work() processes presence detect change for removal and insertion correctly. Signed-off-by: Mayurkumar Patel <mayurkumar.patel@intel.com> --- Resending the patch addressing to PCI Maintainer Bjorn Helgaas. drivers/pci/hotplug/pciehp_ctrl.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 880978b..87c5bea 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -301,20 +301,6 @@ static void handle_button_press_event(struct slot *p_slot) /* * Note: This function must be called with slot->lock held */ -static void handle_surprise_event(struct slot *p_slot) -{ - u8 getstatus; - - pciehp_get_adapter_status(p_slot, &getstatus); - if (!getstatus) - pciehp_queue_power_work(p_slot, DISABLE_REQ); - else - pciehp_queue_power_work(p_slot, ENABLE_REQ); -} - -/* - * Note: This function must be called with slot->lock held - */ static void handle_link_event(struct slot *p_slot, u32 event) { struct controller *ctrl = p_slot->ctrl; @@ -377,14 +363,14 @@ static void interrupt_event_handler(struct work_struct *work) pciehp_green_led_off(p_slot); break; case INT_PRESENCE_ON: - handle_surprise_event(p_slot); + pciehp_queue_power_work(p_slot, ENABLE_REQ); break; case INT_PRESENCE_OFF: /* * Regardless of surprise capability, we need to * definitely remove a card that has been pulled out! */ - handle_surprise_event(p_slot); + pciehp_queue_power_work(p_slot, DISABLE_REQ); break; case INT_LINK_UP: case INT_LINK_DOWN: -- 1.7.9.5 Mayurkumar Patel Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928 Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling 2016-08-17 13:42 [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling Patel, Mayurkumar @ 2016-08-17 17:12 ` Bjorn Helgaas 2016-08-17 17:54 ` Rajat Jain 0 siblings, 1 reply; 13+ messages in thread From: Bjorn Helgaas @ 2016-08-17 17:12 UTC (permalink / raw) To: Patel, Mayurkumar Cc: bhelgaas@google.com, linux-pci@vger.kernel.org, Wysocki, Rafael J, mika.westerberg@linux.intel.com, Shevchenko, Andriy, Busch, Keith, Tarazona-Duarte, Luis Antonio Hi Mayurkumar, On Wed, Aug 17, 2016 at 01:42:18PM +0000, Patel, Mayurkumar wrote: > Currently, if very fast hotplug removal and insertion event comes > as following > > [ 608.823412] pciehp 0000:00:1c.1:pcie04: Card not present on Slot(1) > [ 608.835249] pciehp 0000:00:1c.1:pcie04: Card present on Slot(1) > > In this case following scenario happens, > > While removal: > pcie_isr() -> pciehp_queue_interrupt_event() -> triggers queue_work(). > work invokes interrupt_event_handler() -> case INT_PRESENCE_OFF > and calls handle_surprise_event(). > > handle_surprise_event() again calls pciehp_get_adapter_status() > and reads slot status which might have been changed > already due to PCI_EXP_SLTSTA_PDC event for hotplug insertion > has happened. So it queues, ENABLE_REQ for both removal > and insertion interrupt based on latest slot status. > > In this case, PCIe device can not be hot-add again because > it was never removed due to which device can not get enabled. > > handle_surprise_event() can be removed and pciehp_queue_power_work() > can be directly triggered based on INT_PRESENCE_ON and INT_PRESENCE_OFF > from the switch case exist in interrupt_event_hanlder(). > > The patch ensures the pciehp_queue_power_work() processes > presence detect change for removal and insertion correctly. > > Signed-off-by: Mayurkumar Patel <mayurkumar.patel@intel.com> > --- > Resending the patch addressing to PCI Maintainer Bjorn Helgaas. > > drivers/pci/hotplug/pciehp_ctrl.c | 18 ++---------------- > 1 file changed, 2 insertions(+), 16 deletions(-) > > diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c > index 880978b..87c5bea 100644 > --- a/drivers/pci/hotplug/pciehp_ctrl.c > +++ b/drivers/pci/hotplug/pciehp_ctrl.c > @@ -301,20 +301,6 @@ static void handle_button_press_event(struct slot *p_slot) > /* > * Note: This function must be called with slot->lock held > */ > -static void handle_surprise_event(struct slot *p_slot) > -{ > - u8 getstatus; > - > - pciehp_get_adapter_status(p_slot, &getstatus); > - if (!getstatus) > - pciehp_queue_power_work(p_slot, DISABLE_REQ); > - else > - pciehp_queue_power_work(p_slot, ENABLE_REQ); > -} > - > -/* > - * Note: This function must be called with slot->lock held > - */ > static void handle_link_event(struct slot *p_slot, u32 event) > { > struct controller *ctrl = p_slot->ctrl; > @@ -377,14 +363,14 @@ static void interrupt_event_handler(struct work_struct *work) > pciehp_green_led_off(p_slot); > break; > case INT_PRESENCE_ON: > - handle_surprise_event(p_slot); > + pciehp_queue_power_work(p_slot, ENABLE_REQ); > break; > case INT_PRESENCE_OFF: > /* > * Regardless of surprise capability, we need to > * definitely remove a card that has been pulled out! > */ > - handle_surprise_event(p_slot); > + pciehp_queue_power_work(p_slot, DISABLE_REQ); > break; > case INT_LINK_UP: > case INT_LINK_DOWN: Thanks a lot for this. I think other people have seen the same issue. Even with this fix, don't we have essentially the same problem one layer back? The first thing pcie_isr() does is read PCI_EXP_SLTSTA, then few lines down, we call pciehp_get_adapter_status(), which reads PCI_EXP_SLTSTA *again*. So I think the window is smaller but still there. I think what we really should do is read the status registers (PCI_EXP_SLTSTA and probably also PCI_EXP_LNKSTA) *once* in pcie_isr(), before we write PCI_EXP_SLTSTA to clear the RW1C bits there, and then queue up events based on those values, without re-reading the registers. What do you think? Bjorn ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling 2016-08-17 17:12 ` Bjorn Helgaas @ 2016-08-17 17:54 ` Rajat Jain 2016-08-17 18:14 ` Bjorn Helgaas 0 siblings, 1 reply; 13+ messages in thread From: Rajat Jain @ 2016-08-17 17:54 UTC (permalink / raw) To: Bjorn Helgaas Cc: Patel, Mayurkumar, bhelgaas@google.com, linux-pci@vger.kernel.org, Wysocki, Rafael J, mika.westerberg@linux.intel.com, Shevchenko, Andriy, Busch, Keith, Tarazona-Duarte, Luis Antonio, Rajat Jain On Wed, Aug 17, 2016 at 10:12 AM, Bjorn Helgaas <helgaas@kernel.org> wrote: > > Hi Mayurkumar, > > On Wed, Aug 17, 2016 at 01:42:18PM +0000, Patel, Mayurkumar wrote: > > Currently, if very fast hotplug removal and insertion event comes > > as following > > > > [ 608.823412] pciehp 0000:00:1c.1:pcie04: Card not present on Slot(1) > > [ 608.835249] pciehp 0000:00:1c.1:pcie04: Card present on Slot(1) > > > > In this case following scenario happens, > > > > While removal: > > pcie_isr() -> pciehp_queue_interrupt_event() -> triggers queue_work(). > > work invokes interrupt_event_handler() -> case INT_PRESENCE_OFF > > and calls handle_surprise_event(). > > > > handle_surprise_event() again calls pciehp_get_adapter_status() > > and reads slot status which might have been changed > > already due to PCI_EXP_SLTSTA_PDC event for hotplug insertion > > has happened. So it queues, ENABLE_REQ for both removal > > and insertion interrupt based on latest slot status. > > > > In this case, PCIe device can not be hot-add again because > > it was never removed due to which device can not get enabled. > > > > handle_surprise_event() can be removed and pciehp_queue_power_work() > > can be directly triggered based on INT_PRESENCE_ON and INT_PRESENCE_OFF > > from the switch case exist in interrupt_event_hanlder(). > > > > The patch ensures the pciehp_queue_power_work() processes > > presence detect change for removal and insertion correctly. > > > > Signed-off-by: Mayurkumar Patel <mayurkumar.patel@intel.com> Acked-by: Rajat Jain <rajatxjain@gmail.com> > > > --- > > Resending the patch addressing to PCI Maintainer Bjorn Helgaas. > > > > drivers/pci/hotplug/pciehp_ctrl.c | 18 ++---------------- > > 1 file changed, 2 insertions(+), 16 deletions(-) > > > > diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c > > index 880978b..87c5bea 100644 > > --- a/drivers/pci/hotplug/pciehp_ctrl.c > > +++ b/drivers/pci/hotplug/pciehp_ctrl.c > > @@ -301,20 +301,6 @@ static void handle_button_press_event(struct slot *p_slot) > > /* > > * Note: This function must be called with slot->lock held > > */ > > -static void handle_surprise_event(struct slot *p_slot) > > -{ > > - u8 getstatus; > > - > > - pciehp_get_adapter_status(p_slot, &getstatus); > > - if (!getstatus) > > - pciehp_queue_power_work(p_slot, DISABLE_REQ); > > - else > > - pciehp_queue_power_work(p_slot, ENABLE_REQ); > > -} > > - > > -/* > > - * Note: This function must be called with slot->lock held > > - */ > > static void handle_link_event(struct slot *p_slot, u32 event) > > { > > struct controller *ctrl = p_slot->ctrl; > > @@ -377,14 +363,14 @@ static void interrupt_event_handler(struct work_struct *work) > > pciehp_green_led_off(p_slot); > > break; > > case INT_PRESENCE_ON: > > - handle_surprise_event(p_slot); > > + pciehp_queue_power_work(p_slot, ENABLE_REQ); > > break; > > case INT_PRESENCE_OFF: > > /* > > * Regardless of surprise capability, we need to > > * definitely remove a card that has been pulled out! > > */ > > - handle_surprise_event(p_slot); > > + pciehp_queue_power_work(p_slot, DISABLE_REQ); > > break; > > case INT_LINK_UP: > > case INT_LINK_DOWN: > > Thanks a lot for this. I think other people have seen the same issue. > > Even with this fix, don't we have essentially the same problem one > layer back? The first thing pcie_isr() does is read PCI_EXP_SLTSTA, > then few lines down, we call pciehp_get_adapter_status(), which reads > PCI_EXP_SLTSTA *again*. So I think the window is smaller but still > there. > > I think what we really should do is read the status registers > (PCI_EXP_SLTSTA and probably also PCI_EXP_LNKSTA) *once* in > pcie_isr(), before we write PCI_EXP_SLTSTA to clear the RW1C bits > there, and then queue up events based on those values, without > re-reading the registers. > > What do you think? Yes, I agree. We need to do something about that *in addition * to the above patch to cover the whole story. However I think there still will be a room for some interrupt misses because we are collecting the interrupts in intr_loc, and theoretically we could be in a situation where in the pcie_isr, the do { ... } while(detected) loop gets a removal->insertion->removal all while in the same invocation of pcie_isr(). If this happens, the intr_loc will have recorded a single insertion and a single removal, and the final result will depend on the order in which we decide to process the events in intr_loc. Or, may be we can make the calls to pciehp_queue_interrupt_event() before clearing the RW1C in the slot status register (in the loop)? Thanks, rajat > > > Bjorn > -- > 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling 2016-08-17 17:54 ` Rajat Jain @ 2016-08-17 18:14 ` Bjorn Helgaas 2016-08-17 22:37 ` Patel, Mayurkumar 0 siblings, 1 reply; 13+ messages in thread From: Bjorn Helgaas @ 2016-08-17 18:14 UTC (permalink / raw) To: Rajat Jain Cc: Patel, Mayurkumar, bhelgaas@google.com, linux-pci@vger.kernel.org, Wysocki, Rafael J, mika.westerberg@linux.intel.com, Shevchenko, Andriy, Busch, Keith, Tarazona-Duarte, Luis Antonio, Rajat Jain Hi Rajat, thanks for chiming in! On Wed, Aug 17, 2016 at 10:54:12AM -0700, Rajat Jain wrote: > On Wed, Aug 17, 2016 at 10:12 AM, Bjorn Helgaas <helgaas@kernel.org> wrote: > > > > Hi Mayurkumar, > > > > On Wed, Aug 17, 2016 at 01:42:18PM +0000, Patel, Mayurkumar wrote: > > > Currently, if very fast hotplug removal and insertion event comes > > > as following > > > > > > [ 608.823412] pciehp 0000:00:1c.1:pcie04: Card not present on Slot(1) > > > [ 608.835249] pciehp 0000:00:1c.1:pcie04: Card present on Slot(1) > > > > > > In this case following scenario happens, > > > > > > While removal: > > > pcie_isr() -> pciehp_queue_interrupt_event() -> triggers queue_work(). > > > work invokes interrupt_event_handler() -> case INT_PRESENCE_OFF > > > and calls handle_surprise_event(). > > > > > > handle_surprise_event() again calls pciehp_get_adapter_status() > > > and reads slot status which might have been changed > > > already due to PCI_EXP_SLTSTA_PDC event for hotplug insertion > > > has happened. So it queues, ENABLE_REQ for both removal > > > and insertion interrupt based on latest slot status. > > > > > > In this case, PCIe device can not be hot-add again because > > > it was never removed due to which device can not get enabled. > > > > > > handle_surprise_event() can be removed and pciehp_queue_power_work() > > > can be directly triggered based on INT_PRESENCE_ON and INT_PRESENCE_OFF > > > from the switch case exist in interrupt_event_hanlder(). > > > > > > The patch ensures the pciehp_queue_power_work() processes > > > presence detect change for removal and insertion correctly. > > > > > > Signed-off-by: Mayurkumar Patel <mayurkumar.patel@intel.com> > > Acked-by: Rajat Jain <rajatxjain@gmail.com> > > > > > > --- > > > Resending the patch addressing to PCI Maintainer Bjorn Helgaas. > > > > > > drivers/pci/hotplug/pciehp_ctrl.c | 18 ++---------------- > > > 1 file changed, 2 insertions(+), 16 deletions(-) > > > > > > diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c > > > index 880978b..87c5bea 100644 > > > --- a/drivers/pci/hotplug/pciehp_ctrl.c > > > +++ b/drivers/pci/hotplug/pciehp_ctrl.c > > > @@ -301,20 +301,6 @@ static void handle_button_press_event(struct slot *p_slot) > > > /* > > > * Note: This function must be called with slot->lock held > > > */ > > > -static void handle_surprise_event(struct slot *p_slot) > > > -{ > > > - u8 getstatus; > > > - > > > - pciehp_get_adapter_status(p_slot, &getstatus); > > > - if (!getstatus) > > > - pciehp_queue_power_work(p_slot, DISABLE_REQ); > > > - else > > > - pciehp_queue_power_work(p_slot, ENABLE_REQ); > > > -} > > > - > > > -/* > > > - * Note: This function must be called with slot->lock held > > > - */ > > > static void handle_link_event(struct slot *p_slot, u32 event) > > > { > > > struct controller *ctrl = p_slot->ctrl; > > > @@ -377,14 +363,14 @@ static void interrupt_event_handler(struct work_struct *work) > > > pciehp_green_led_off(p_slot); > > > break; > > > case INT_PRESENCE_ON: > > > - handle_surprise_event(p_slot); > > > + pciehp_queue_power_work(p_slot, ENABLE_REQ); > > > break; > > > case INT_PRESENCE_OFF: > > > /* > > > * Regardless of surprise capability, we need to > > > * definitely remove a card that has been pulled out! > > > */ > > > - handle_surprise_event(p_slot); > > > + pciehp_queue_power_work(p_slot, DISABLE_REQ); > > > break; > > > case INT_LINK_UP: > > > case INT_LINK_DOWN: > > > > Thanks a lot for this. I think other people have seen the same issue. > > > > Even with this fix, don't we have essentially the same problem one > > layer back? The first thing pcie_isr() does is read PCI_EXP_SLTSTA, > > then few lines down, we call pciehp_get_adapter_status(), which reads > > PCI_EXP_SLTSTA *again*. So I think the window is smaller but still > > there. > > > > I think what we really should do is read the status registers > > (PCI_EXP_SLTSTA and probably also PCI_EXP_LNKSTA) *once* in > > pcie_isr(), before we write PCI_EXP_SLTSTA to clear the RW1C bits > > there, and then queue up events based on those values, without > > re-reading the registers. > > > > What do you think? > > > Yes, I agree. We need to do something about that *in addition * to the > above patch to cover the > whole story. However I think there still will be a room for some > interrupt misses because we are > collecting the interrupts in intr_loc, and theoretically we could be > in a situation where in the pcie_isr, the > > do { > ... > } while(detected) > > loop gets a removal->insertion->removal all while in the same > invocation of pcie_isr(). > If this happens, the intr_loc will have recorded a single insertion > and a single removal, and > the final result will depend on the order in which we decide to > process the events in intr_loc. I don't quite understand how that "do { .. } while (detected)" loop works or why it's done that way. Collecting interrupt status bits in an ISR is obviously a very common task; it seems like there should be a standard, idiomatic way of doing it, but I don't know it. > Or, may be we can make the calls to pciehp_queue_interrupt_event() > before clearing the > RW1C in the slot status register (in the loop)? Yeah, it seems like we should read PCI_EXP_SLTSTA once, queue up any events related to it, then clear the relevant SLTSTA bits. Bjorn ^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling 2016-08-17 18:14 ` Bjorn Helgaas @ 2016-08-17 22:37 ` Patel, Mayurkumar 2016-08-18 12:52 ` Bjorn Helgaas 2016-08-18 21:07 ` [PATCH v1 1/2] " Mayurkumar Patel 0 siblings, 2 replies; 13+ messages in thread From: Patel, Mayurkumar @ 2016-08-17 22:37 UTC (permalink / raw) To: Bjorn Helgaas, Rajat Jain Cc: bhelgaas@google.com, linux-pci@vger.kernel.org, Wysocki, Rafael J, mika.westerberg@linux.intel.com, Shevchenko, Andriy, Busch, Keith, Tarazona-Duarte, Luis Antonio, Rajat Jain Hi Bjorn and Rajat Thanks for replying. = > Hi Rajat, thanks for chiming in! > = > On Wed, Aug 17, 2016 at 10:54:12AM -0700, Rajat Jain wrote: > > On Wed, Aug 17, 2016 at 10:12 AM, Bjorn Helgaas <helgaas@kernel.org> wr= ote: > > > > > > Hi Mayurkumar, > > > > > > On Wed, Aug 17, 2016 at 01:42:18PM +0000, Patel, Mayurkumar wrote: > > > > Currently, if very fast hotplug removal and insertion event comes > > > > as following > > > > > > > > [ 608.823412] pciehp 0000:00:1c.1:pcie04: Card not present on Slot= (1) > > > > [ 608.835249] pciehp 0000:00:1c.1:pcie04: Card present on Slot(1) > > > > > > > > In this case following scenario happens, > > > > > > > > While removal: > > > > pcie_isr() -> pciehp_queue_interrupt_event() -> triggers queue_work= (). > > > > work invokes interrupt_event_handler() -> case INT_PRESENCE_OFF > > > > and calls handle_surprise_event(). > > > > > > > > handle_surprise_event() again calls pciehp_get_adapter_status() > > > > and reads slot status which might have been changed > > > > already due to PCI_EXP_SLTSTA_PDC event for hotplug insertion > > > > has happened. So it queues, ENABLE_REQ for both removal > > > > and insertion interrupt based on latest slot status. > > > > > > > > In this case, PCIe device can not be hot-add again because > > > > it was never removed due to which device can not get enabled. > > > > > > > > handle_surprise_event() can be removed and pciehp_queue_power_work() > > > > can be directly triggered based on INT_PRESENCE_ON and INT_PRESENCE= _OFF > > > > from the switch case exist in interrupt_event_hanlder(). > > > > > > > > The patch ensures the pciehp_queue_power_work() processes > > > > presence detect change for removal and insertion correctly. > > > > > > > > Signed-off-by: Mayurkumar Patel <mayurkumar.patel@intel.com> > > > > Acked-by: Rajat Jain <rajatxjain@gmail.com> > > > > > > > > > --- > > > > Resending the patch addressing to PCI Maintainer Bjorn Helgaas. > > > > > > > > drivers/pci/hotplug/pciehp_ctrl.c | 18 ++---------------- > > > > 1 file changed, 2 insertions(+), 16 deletions(-) > > > > > > > > diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplu= g/pciehp_ctrl.c > > > > index 880978b..87c5bea 100644 > > > > --- a/drivers/pci/hotplug/pciehp_ctrl.c > > > > +++ b/drivers/pci/hotplug/pciehp_ctrl.c > > > > @@ -301,20 +301,6 @@ static void handle_button_press_event(struct s= lot *p_slot) > > > > /* > > > > * Note: This function must be called with slot->lock held > > > > */ > > > > -static void handle_surprise_event(struct slot *p_slot) > > > > -{ > > > > - u8 getstatus; > > > > - > > > > - pciehp_get_adapter_status(p_slot, &getstatus); > > > > - if (!getstatus) > > > > - pciehp_queue_power_work(p_slot, DISABLE_REQ); > > > > - else > > > > - pciehp_queue_power_work(p_slot, ENABLE_REQ); > > > > -} > > > > - > > > > -/* > > > > - * Note: This function must be called with slot->lock held > > > > - */ > > > > static void handle_link_event(struct slot *p_slot, u32 event) > > > > { > > > > struct controller *ctrl =3D p_slot->ctrl; > > > > @@ -377,14 +363,14 @@ static void interrupt_event_handler(struct wo= rk_struct *work) > > > > pciehp_green_led_off(p_slot); > > > > break; > > > > case INT_PRESENCE_ON: > > > > - handle_surprise_event(p_slot); > > > > + pciehp_queue_power_work(p_slot, ENABLE_REQ); > > > > break; > > > > case INT_PRESENCE_OFF: > > > > /* > > > > * Regardless of surprise capability, we need to > > > > * definitely remove a card that has been pulled out! > > > > */ > > > > - handle_surprise_event(p_slot); > > > > + pciehp_queue_power_work(p_slot, DISABLE_REQ); > > > > break; > > > > case INT_LINK_UP: > > > > case INT_LINK_DOWN: > > > > > > Thanks a lot for this. I think other people have seen the same issue. > > > > > > Even with this fix, don't we have essentially the same problem one > > > layer back? The first thing pcie_isr() does is read PCI_EXP_SLTSTA, > > > then few lines down, we call pciehp_get_adapter_status(), which reads > > > PCI_EXP_SLTSTA *again*. So I think the window is smaller but still > > > there. > > > > > > I think what we really should do is read the status registers > > > (PCI_EXP_SLTSTA and probably also PCI_EXP_LNKSTA) *once* in > > > pcie_isr(), before we write PCI_EXP_SLTSTA to clear the RW1C bits > > > there, and then queue up events based on those values, without > > > re-reading the registers. > > > > > > What do you think? > > > > > > Yes, I agree. = Yes indeed that should be done too. > > We need to do something about that *in addition * to the > > above patch to cover the > > whole story. However I think there still will be a room for some > > interrupt misses because we are > > collecting the interrupts in intr_loc, and theoretically we could be > > in a situation where in the pcie_isr, the > > > > do { > > ... > > } while(detected) > > > > loop gets a removal->insertion->removal all while in the same > > invocation of pcie_isr(). > > If this happens, the intr_loc will have recorded a single insertion > > and a single removal, and > > the final result will depend on the order in which we decide to > > process the events in intr_loc. > = > I don't quite understand how that "do { .. } while (detected)" loop > works or why it's done that way. Collecting interrupt status bits in > an ISR is obviously a very common task; it seems like there should be > a standard, idiomatic way of doing it, but I don't know it. > = > > Or, may be we can make the calls to pciehp_queue_interrupt_event() > > before clearing the > > RW1C in the slot status register (in the loop)? > = > Yeah, it seems like we should read PCI_EXP_SLTSTA once, queue up any > events related to it, then clear the relevant SLTSTA bits. > = Do you mean to remove the do {...} while loop and just read PCI_EXP_SLTSTA once in ISR , queue the work and clear interrupts? > Bjorn Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling 2016-08-17 22:37 ` Patel, Mayurkumar @ 2016-08-18 12:52 ` Bjorn Helgaas 2016-08-18 20:59 ` Patel, Mayurkumar 2016-08-18 21:07 ` [PATCH v1 1/2] " Mayurkumar Patel 1 sibling, 1 reply; 13+ messages in thread From: Bjorn Helgaas @ 2016-08-18 12:52 UTC (permalink / raw) To: Patel, Mayurkumar Cc: Rajat Jain, bhelgaas@google.com, linux-pci@vger.kernel.org, Wysocki, Rafael J, mika.westerberg@linux.intel.com, Shevchenko, Andriy, Busch, Keith, Tarazona-Duarte, Luis Antonio, Rajat Jain On Wed, Aug 17, 2016 at 10:37:13PM +0000, Patel, Mayurkumar wrote: > > On Wed, Aug 17, 2016 at 10:54:12AM -0700, Rajat Jain wrote: > > > We need to do something about that *in addition * to the > > > above patch to cover the > > > whole story. However I think there still will be a room for some > > > interrupt misses because we are > > > collecting the interrupts in intr_loc, and theoretically we could be > > > in a situation where in the pcie_isr, the > > > > > > do { > > > ... > > > } while(detected) > > > > > > loop gets a removal->insertion->removal all while in the same > > > invocation of pcie_isr(). > > > If this happens, the intr_loc will have recorded a single insertion > > > and a single removal, and > > > the final result will depend on the order in which we decide to > > > process the events in intr_loc. > > > > I don't quite understand how that "do { .. } while (detected)" loop > > works or why it's done that way. Collecting interrupt status bits in > > an ISR is obviously a very common task; it seems like there should be > > a standard, idiomatic way of doing it, but I don't know it. > > > > > Or, may be we can make the calls to pciehp_queue_interrupt_event() > > > before clearing the > > > RW1C in the slot status register (in the loop)? > > > > Yeah, it seems like we should read PCI_EXP_SLTSTA once, queue up any > > events related to it, then clear the relevant SLTSTA bits. > > > > Do you mean to remove the do {...} while loop and just > read PCI_EXP_SLTSTA once in ISR , queue the work and clear interrupts? I don't know if removing the loop is the right thing or not. We need to understand why the loop is there in the first place and make sure removing it wouldn't break things. But I do think that in the resulting code, the connection between (1) the events we learn from the interrupt and (2) the queued work items needs to be crystal clear. Right now it's a bit muddy because of things like the case you fixed: a work item that goes back and looks at PCI_EXP_SLTSTA after it's been cleared and the hardware may have already set bits for new events. Bjorn ^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling 2016-08-18 12:52 ` Bjorn Helgaas @ 2016-08-18 20:59 ` Patel, Mayurkumar 2016-08-23 23:47 ` Rajat Jain 0 siblings, 1 reply; 13+ messages in thread From: Patel, Mayurkumar @ 2016-08-18 20:59 UTC (permalink / raw) To: Bjorn Helgaas Cc: Rajat Jain, bhelgaas@google.com, linux-pci@vger.kernel.org, Wysocki, Rafael J, mika.westerberg@linux.intel.com, Busch, Keith, Tarazona-Duarte, Luis Antonio, Rajat Jain, Andy Shevchenko = > On Wed, Aug 17, 2016 at 10:37:13PM +0000, Patel, Mayurkumar wrote: > > > On Wed, Aug 17, 2016 at 10:54:12AM -0700, Rajat Jain wrote: > = > > > > We need to do something about that *in addition * to the > > > > above patch to cover the > > > > whole story. However I think there still will be a room for some > > > > interrupt misses because we are > > > > collecting the interrupts in intr_loc, and theoretically we could be > > > > in a situation where in the pcie_isr, the > > > > > > > > do { > > > > ... > > > > } while(detected) > > > > > > > > loop gets a removal->insertion->removal all while in the same > > > > invocation of pcie_isr(). > > > > If this happens, the intr_loc will have recorded a single insertion > > > > and a single removal, and > > > > the final result will depend on the order in which we decide to > > > > process the events in intr_loc. > > > > > > I don't quite understand how that "do { .. } while (detected)" loop > > > works or why it's done that way. Collecting interrupt status bits in > > > an ISR is obviously a very common task; it seems like there should be > > > a standard, idiomatic way of doing it, but I don't know it. > > > > > > > Or, may be we can make the calls to pciehp_queue_interrupt_event() > > > > before clearing the > > > > RW1C in the slot status register (in the loop)? > > > > > > Yeah, it seems like we should read PCI_EXP_SLTSTA once, queue up any > > > events related to it, then clear the relevant SLTSTA bits. > > > > > > > Do you mean to remove the do {...} while loop and just > > read PCI_EXP_SLTSTA once in ISR , queue the work and clear interrupts? > = > I don't know if removing the loop is the right thing or not. We need > to understand why the loop is there in the first place and make sure > removing it wouldn't break things. > = The pcie base spec. 3.0 says from chapter 6.7.3.1. Slot Events: A Downstream Port with hot-plug capabilities monitors the slot it controls= for the slot events listed above. When one of these slot events is detected, the Port indicates that = the event has occurred by setting the status field associated with the event. At that point, the eve= nt is pending until software clears the status field. Once a slot event is pending on a particular slot, all subsequent events o= f that type are ignored on that slot until the event is cleared. The Port must continue to monitor th= e slot for all other slot event types and report them as they occur. So does it mean that the port would continue providing MSI if there has been any other events occurred apart from the event which is not cleared? If that is the case then it's not sure why the loop is still needed. Also with having a loop, pcie_isr() is reading the PCI_EXP_SLTSTA again and= taking action just based on latest event happens. That may mean removal->insertion happens fast enough = then removal could be overwritten by insertion and pciehp_get_adapter_status () will return insertion only and we may miss the removal event to be processe= d for the loop. If we don't clear the Slot event quick enough then according to spec. state= ment above that event could get ignored and SW may never get notified. > But I do think that in the resulting code, the connection between > = > (1) the events we learn from the interrupt and > (2) the queued work items > = > needs to be crystal clear. Right now it's a bit muddy because of > things like the case you fixed: a work item that goes back and looks > at PCI_EXP_SLTSTA after it's been cleared and the hardware may have > already set bits for new events. > = I have made a prototype patch in my follow up reply and tested ok on my exi= sting setup = on which I caught the previous issue although I cant say it will work on an= y HW. Clearing events after queuing events gave some problems and did not work pr= operly on my existing HW where I test very fast insertion and removal events, in which case only "removal" event comes and "insertion" does not occur even if HW g= ets powered. > Bjorn Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling 2016-08-18 20:59 ` Patel, Mayurkumar @ 2016-08-23 23:47 ` Rajat Jain 2016-08-24 9:00 ` Patel, Mayurkumar 2016-08-24 14:59 ` Keith Busch 0 siblings, 2 replies; 13+ messages in thread From: Rajat Jain @ 2016-08-23 23:47 UTC (permalink / raw) To: Patel, Mayurkumar Cc: Bjorn Helgaas, bhelgaas@google.com, linux-pci@vger.kernel.org, Wysocki, Rafael J, mika.westerberg@linux.intel.com, Busch, Keith, Tarazona-Duarte, Luis Antonio, Rajat Jain, Andy Shevchenko On Thu, Aug 18, 2016 at 1:59 PM, Patel, Mayurkumar <mayurkumar.patel@intel.com> wrote: > > > > > On Wed, Aug 17, 2016 at 10:37:13PM +0000, Patel, Mayurkumar wrote: > > > > On Wed, Aug 17, 2016 at 10:54:12AM -0700, Rajat Jain wrote: > > > > > > > We need to do something about that *in addition * to the > > > > > above patch to cover the > > > > > whole story. However I think there still will be a room for some > > > > > interrupt misses because we are > > > > > collecting the interrupts in intr_loc, and theoretically we could be > > > > > in a situation where in the pcie_isr, the > > > > > > > > > > do { > > > > > ... > > > > > } while(detected) > > > > > > > > > > loop gets a removal->insertion->removal all while in the same > > > > > invocation of pcie_isr(). > > > > > If this happens, the intr_loc will have recorded a single insertion > > > > > and a single removal, and > > > > > the final result will depend on the order in which we decide to > > > > > process the events in intr_loc. > > > > > > > > I don't quite understand how that "do { .. } while (detected)" loop > > > > works or why it's done that way. Collecting interrupt status bits in > > > > an ISR is obviously a very common task; it seems like there should be > > > > a standard, idiomatic way of doing it, but I don't know it. > > > > > > > > > Or, may be we can make the calls to pciehp_queue_interrupt_event() > > > > > before clearing the > > > > > RW1C in the slot status register (in the loop)? > > > > > > > > Yeah, it seems like we should read PCI_EXP_SLTSTA once, queue up any > > > > events related to it, then clear the relevant SLTSTA bits. > > > > > > > > > > Do you mean to remove the do {...} while loop and just > > > read PCI_EXP_SLTSTA once in ISR , queue the work and clear interrupts? > > > > I don't know if removing the loop is the right thing or not. We need > > to understand why the loop is there in the first place and make sure > > removing it wouldn't break things. > > > > > The pcie base spec. 3.0 says from chapter 6.7.3.1. Slot Events: > > A Downstream Port with hot-plug capabilities monitors the slot it controls for the slot events listed > above. When one of these slot events is detected, the Port indicates that the event has occurred by > setting the status field associated with the event. At that point, the event is pending until software > clears the status field. > Once a slot event is pending on a particular slot, all subsequent events of that type are ignored on > that slot until the event is cleared. The Port must continue to monitor the slot for all other slot > event types and report them as they occur. > > > So does it mean that the port would continue providing MSI if there has been > any other events occurred apart from the event which is not cleared? If that > is the case then it's not sure why the loop is still needed. I'd think that the loop is needed because we don't want to handle just one event on one interrupt. We want to handle as many events as we can (to keep the interrupt latency overhead low), that have happened during the ISR invocation. And hence the loop. > > Also with having a loop, pcie_isr() is reading the PCI_EXP_SLTSTA again and taking action just based on > latest event happens. That may mean removal->insertion happens fast enough then > removal could be overwritten by insertion and pciehp_get_adapter_status () > will return insertion only and we may miss the removal event to be processed for the loop. Current. This is the problem that Bjorn highlighted above. I think the current code works well when events of different kinds have happened (due to the loop). In case of similar kind of events (insertion / removal), I think there are 2 problems: (1) we use the transient values of slot status which may not be valid at that time. (2) because we ack the event before we queue it up, it leaves chance for error. I think we'd need more careful examination in order to fix these issues. > > If we don't clear the Slot event quick enough then according to spec. statement above > that event could get ignored and SW may never get notified. > > > > > But I do think that in the resulting code, the connection between > > > > (1) the events we learn from the interrupt and > > (2) the queued work items > > > > needs to be crystal clear. Right now it's a bit muddy because of > > things like the case you fixed: a work item that goes back and looks > > at PCI_EXP_SLTSTA after it's been cleared and the hardware may have > > already set bits for new events. > > > > I have made a prototype patch in my follow up reply and tested ok on my existing setup > on which I caught the previous issue although I cant say it will work on any HW. > Clearing events after queuing events gave some problems and did not work properly on my > existing HW where I test very fast insertion and removal events, in which > case only "removal" event comes and "insertion" does not occur even if HW gets powered. > > > Bjorn > Intel Deutschland GmbH > Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany > Tel: +49 89 99 8853-0, www.intel.de > Managing Directors: Christin Eisenschmid, Christian Lamprechter > Chairperson of the Supervisory Board: Nicole Lau > Registered Office: Munich > Commercial Register: Amtsgericht Muenchen HRB 186928 > ^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling 2016-08-23 23:47 ` Rajat Jain @ 2016-08-24 9:00 ` Patel, Mayurkumar 2016-09-01 10:44 ` Patel, Mayurkumar 2016-08-24 14:59 ` Keith Busch 1 sibling, 1 reply; 13+ messages in thread From: Patel, Mayurkumar @ 2016-08-24 9:00 UTC (permalink / raw) To: Rajat Jain Cc: Bjorn Helgaas, bhelgaas@google.com, linux-pci@vger.kernel.org, Wysocki, Rafael J, mika.westerberg@linux.intel.com, Busch, Keith, Tarazona-Duarte, Luis Antonio, Rajat Jain, Andy Shevchenko DQo+ID4NCj4gPiA+IE9uIFdlZCwgQXVnIDE3LCAyMDE2IGF0IDEwOjM3OjEzUE0gKzAwMDAsIFBh dGVsLCBNYXl1cmt1bWFyIHdyb3RlOg0KPiA+ID4gPiA+IE9uIFdlZCwgQXVnIDE3LCAyMDE2IGF0 IDEwOjU0OjEyQU0gLTA3MDAsIFJhamF0IEphaW4gd3JvdGU6DQo+ID4gPg0KPiA+ID4gPiA+ID4g V2UgbmVlZCB0byBk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CBDaHJpc3RpYW4gTGFtcHJlY2h0ZXIKQ2hh aXJwZXJzb24gb2YgdGhlIFN1cGVydmlzb3J5IEJvYXJkOiBOaWNvbGUgTGF1ClJlZ2lzdGVyZWQg T2ZmaWNlOiBNdW5pY2gKQ29tbWVyY2lhbCBSZWdpc3RlcjogQW10c2dlcmljaHQgTXVlbmNoZW4g SFJCIDE4NjkyOAo= ^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling 2016-08-24 9:00 ` Patel, Mayurkumar @ 2016-09-01 10:44 ` Patel, Mayurkumar 0 siblings, 0 replies; 13+ messages in thread From: Patel, Mayurkumar @ 2016-09-01 10:44 UTC (permalink / raw) To: Patel, Mayurkumar, Rajat Jain Cc: Bjorn Helgaas, bhelgaas@google.com, linux-pci@vger.kernel.org, Wysocki, Rafael J, mika.westerberg@linux.intel.com, Busch, Keith, Tarazona-Duarte, Luis Antonio, Rajat Jain, Andy Shevchenko DQogDQo+IA0KPiA+ID4NCj4gPiA+ID4gT24gV2VkLCBBdWcgMTcsIDIwMTYgYXQgMTA6Mzc6MTNQ TSArMDAwMCwgUGF0ZWwsIE1heXVya3VtYXIgd3JvdGU6DQo+ID4gPiA+ID4gPiBPbiBXZWQsIEF1 ZyAxNywgMjAxNiBhdCAxMDo1NDoxMkFNIC0wNzAwLCBSYWphdCBKYWluIHdyb3RlOg0KPiA+ID4g Pg0KPiA+ID4gPiA+ID4gPiBXZSBuZWVkIHRvIGRvIHNvbWV0aGluZyBhYm91dCB0aGF0ICppbiBh ZGRpdGlvbiAqIHRvIHRoZQ0KPiA+ID4gPiA+ID4gPiBhYm92ZSBwYXRjaCB0byBjb3ZlciB0aGUN Cj4gPiA+ID4gPiA+ID4gd2hvbGUgc3RvcnkuIEhvd2V2ZXIgSSB0aGluayB0aGVyZSBzdGlsbCB3 aWxsIGJlIGEgcm9vbSBmb3Igc29tZQ0KPiA+ID4gPiA+ID4gPiBpbnRlcnJ1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wgd29yayBvbiBhbnkgSFcuDQo+ID4gPiBDbGVhcmlu ZyBldmVudHMgYWZ0ZXIgcXVldWluZyBldmVudHMgZ2F2ZSBzb21lIHByb2JsZW1zIGFuZCBkaWQg bm90IHdvcmsgcHJvcGVybHkgb24gbXkNCj4gPiA+IGV4aXN0aW5nIEhXIHdoZXJlIEkgdGVzdCB2 ZXJ5IGZhc3QgaW5zZXJ0aW9uIGFuZCByZW1vdmFsIGV2ZW50cywgaW4gd2hpY2gNCj4gPiA+IGNh c2Ugb25seSAicmVtb3ZhbCIgZXZlbnQgY29tZXMgYW5kICJpbnNlcnRpb24iIGRvZXMgbm90IG9j Y3VyIGV2ZW4gaWYgSFcgZ2V0cyBwb3dlcmVkLg0KPiA+ID4NCj4gDQpJbnRlbCBEZXV0c2NobGFu ZCBHbWJIClJlZ2lzdGVyZWQgQWRkcmVzczogQW0gQ2FtcGVvbiAxMC0xMiwgODU1NzkgTmV1Ymli ZXJnLCBHZXJtYW55ClRlbDogKzQ5IDg5IDk5IDg4NTMtMCwgd3d3LmludGVsLmRlCk1hbmFnaW5n IERpcmVjdG9yczogQ2hyaXN0aW4gRWlzZW5zY2htaWQsIENocmlzdGlhbiBMYW1wcmVjaHRlcgpD aGFpcnBlcnNvbiBvZiB0aGUgU3VwZXJ2aXNvcnkgQm9hcmQ6IE5pY29sZSBMYXUKUmVnaXN0ZXJl ZCBPZmZpY2U6IE11bmljaApDb21tZXJjaWFsIFJlZ2lzdGVyOiBBbXRzZ2VyaWNodCBNdWVuY2hl biBIUkIgMTg2OTI4Cg== ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling 2016-08-23 23:47 ` Rajat Jain 2016-08-24 9:00 ` Patel, Mayurkumar @ 2016-08-24 14:59 ` Keith Busch 1 sibling, 0 replies; 13+ messages in thread From: Keith Busch @ 2016-08-24 14:59 UTC (permalink / raw) To: Rajat Jain Cc: Patel, Mayurkumar, Bjorn Helgaas, bhelgaas@google.com, linux-pci@vger.kernel.org, Wysocki, Rafael J, mika.westerberg@linux.intel.com, Tarazona-Duarte, Luis Antonio, Rajat Jain, Andy Shevchenko On Tue, Aug 23, 2016 at 04:47:44PM -0700, Rajat Jain wrote: > On Thu, Aug 18, 2016 at 1:59 PM, Patel, Mayurkumar > <mayurkumar.patel@intel.com> wrote: > > > > So does it mean that the port would continue providing MSI if there has been > > any other events occurred apart from the event which is not cleared? If that > > is the case then it's not sure why the loop is still needed. > > I'd think that the loop is needed because we don't want to handle just > one event on one interrupt. We want to handle as many events as we can > (to keep the interrupt latency overhead low), that have happened > during the ISR invocation. And hence the loop. The Slot Status doesn't have to provide a single event at a time. But even if it does, this isn't exactly a performance path that would be hurt by having one interrupt per event, right? ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v1 1/2] PCI: pciehp: Fix presence detect change interrupt handling 2016-08-17 22:37 ` Patel, Mayurkumar 2016-08-18 12:52 ` Bjorn Helgaas @ 2016-08-18 21:07 ` Mayurkumar Patel 2016-08-18 21:07 ` [PATCH v1 2/2] PCI: pciehp: Rework hotplug interrupt routine Mayurkumar Patel 1 sibling, 1 reply; 13+ messages in thread From: Mayurkumar Patel @ 2016-08-18 21:07 UTC (permalink / raw) To: helgaas, bhelgaas Cc: rajatja, linux-pci, andriy.shevchenko, mika.westerberg, rafael.j.wysocki, luis.antonio.tarazona-duarte, keith.busch, mayurkumar.patel Currently, if very fast hotplug removal and insertion event comes as following [ 608.823412] pciehp 0000:00:1c.1:pcie04: Card not present on Slot(1) [ 608.835249] pciehp 0000:00:1c.1:pcie04: Card present on Slot(1) In this case following scenario happens, While removal: pcie_isr() -> pciehp_queue_interrupt_event() -> triggers queue_work(). work invokes interrupt_event_handler() -> case INT_PRESENCE_OFF and calls handle_surprise_event(). handle_surprise_event() again calls pciehp_get_adapter_status() and reads slot status which might have been changed already due to PCI_EXP_SLTSTA_PDC event for hotplug insertion has happened. So it queues, ENABLE_REQ for both removal and insertion interrupt based on latest slot status. In this case, PCIe device can not be hot-add again because it was never removed due to which device can not get enabled. handle_surprise_event() can be removed and pciehp_queue_power_work() can be directly triggered based on INT_PRESENCE_ON and INT_PRESENCE_OFF from the switch case exist in interrupt_event_hanlder(). The patch ensures the pciehp_queue_power_work() processes presence detect change for removal and insertion correctly. Signed-off-by: Mayurkumar Patel <mayurkumar.patel@intel.com> Acked-by: Rajat Jain <rajatxjain@gmail.com> --- drivers/pci/hotplug/pciehp_ctrl.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 880978b..87c5bea 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -301,20 +301,6 @@ static void handle_button_press_event(struct slot *p_slot) /* * Note: This function must be called with slot->lock held */ -static void handle_surprise_event(struct slot *p_slot) -{ - u8 getstatus; - - pciehp_get_adapter_status(p_slot, &getstatus); - if (!getstatus) - pciehp_queue_power_work(p_slot, DISABLE_REQ); - else - pciehp_queue_power_work(p_slot, ENABLE_REQ); -} - -/* - * Note: This function must be called with slot->lock held - */ static void handle_link_event(struct slot *p_slot, u32 event) { struct controller *ctrl = p_slot->ctrl; @@ -377,14 +363,14 @@ static void interrupt_event_handler(struct work_struct *work) pciehp_green_led_off(p_slot); break; case INT_PRESENCE_ON: - handle_surprise_event(p_slot); + pciehp_queue_power_work(p_slot, ENABLE_REQ); break; case INT_PRESENCE_OFF: /* * Regardless of surprise capability, we need to * definitely remove a card that has been pulled out! */ - handle_surprise_event(p_slot); + pciehp_queue_power_work(p_slot, DISABLE_REQ); break; case INT_LINK_UP: case INT_LINK_DOWN: -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v1 2/2] PCI: pciehp: Rework hotplug interrupt routine 2016-08-18 21:07 ` [PATCH v1 1/2] " Mayurkumar Patel @ 2016-08-18 21:07 ` Mayurkumar Patel 0 siblings, 0 replies; 13+ messages in thread From: Mayurkumar Patel @ 2016-08-18 21:07 UTC (permalink / raw) To: helgaas, bhelgaas Cc: rajatja, linux-pci, andriy.shevchenko, mika.westerberg, rafael.j.wysocki, luis.antonio.tarazona-duarte, keith.busch, mayurkumar.patel First scenario, on any slot events, pcie_isr() does as following, pcie_isr() -> do {...} while(detected) loop in which it reads PCI_EXP_SLTSTA, stores it in the intr_loc, then clears respective interrupts by writing to PCI_EXP_SLTSTA. Again, due to loop, it reads PCI_EXP_SLTSTA, which might have been changed already for the same type of interrupts because in the previous iteration they already got cleared. In this case, it will execute pciehp_queue_interrupt_event() only once based on the last event happened. This can be problematic for PCI_EXP_SLTSTA_PDC and PCI_EXP_SLTSTA_DLLSC types of interrupts as if they miss to process previous events then PCIe device enumeration can get effected. Second scenario, pcie_isr() after clearing interrupts, it calls pciehp_get_adapter_status() before processing PCI_EXP_SLTSTA_PDS and pciehp_check_link_active() before processing PCI_EXP_SLTSTA_DLLSC and takes decisions based on that to do pciehp_queue_interrupt_event() which might also have already got changed due to the same fact that the respective interrupts got cleared earlier. The patch is just one proposal. It is just prototype and currently I don't know it would work any HW. It removes re-inspection to avoid first scenario happening and just reads the events once and clears them as soon as possible. To successfully execute right Slot events for PDC and DLLSC types which triggered pcie_isr() it reads the PCI_EXP_SLTSTA_PDS and PCI_EXP_LNKSTA_DLLLA earlier before clearing the respective interrupts and executes pciehp_queue_interrupt_event() based on the stored status of these two Slot events. Signed-off-by: Mayurkumar Patel <mayurkumar.patel@intel.com> --- drivers/pci/hotplug/pciehp_hpc.c | 45 ++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index 5c24e93..2d01b7d 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -542,36 +542,30 @@ static irqreturn_t pcie_isr(int irq, void *dev_id) struct pci_bus *subordinate = pdev->subordinate; struct pci_dev *dev; struct slot *slot = ctrl->slot; - u16 detected, intr_loc; + u16 slot_status, intr_loc = 0; u8 present; bool link; + pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status); + if (slot_status == (u16) ~0) { + ctrl_info(ctrl, "%s: no response from device\n", + __func__); + return IRQ_HANDLED; + } + intr_loc = (slot_status & (PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD | + PCI_EXP_SLTSTA_PDC | + PCI_EXP_SLTSTA_CC | PCI_EXP_SLTSTA_DLLSC)); + if (!intr_loc) + return IRQ_NONE; + /* - * In order to guarantee that all interrupt events are - * serviced, we need to re-inspect Slot Status register after - * clearing what is presumed to be the last pending interrupt. + * update link status before clearing interrupts to process + * it later */ - intr_loc = 0; - do { - pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &detected); - if (detected == (u16) ~0) { - ctrl_info(ctrl, "%s: no response from device\n", - __func__); - return IRQ_HANDLED; - } - - detected &= (PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD | - PCI_EXP_SLTSTA_PDC | - PCI_EXP_SLTSTA_CC | PCI_EXP_SLTSTA_DLLSC); - detected &= ~intr_loc; - intr_loc |= detected; - if (!intr_loc) - return IRQ_NONE; - if (detected) - pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, - intr_loc); - } while (detected); + if (intr_loc & PCI_EXP_SLTSTA_DLLSC) + link = pciehp_check_link_active(ctrl); + pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, intr_loc); ctrl_dbg(ctrl, "pending interrupts %#06x from Slot Status\n", intr_loc); /* Check Command Complete Interrupt Pending */ @@ -603,7 +597,7 @@ static irqreturn_t pcie_isr(int irq, void *dev_id) /* Check Presence Detect Changed */ if (intr_loc & PCI_EXP_SLTSTA_PDC) { - pciehp_get_adapter_status(slot, &present); + present = !!(slot_status & PCI_EXP_SLTSTA_PDS); ctrl_info(ctrl, "Card %spresent on Slot(%s)\n", present ? "" : "not ", slot_name(slot)); pciehp_queue_interrupt_event(slot, present ? INT_PRESENCE_ON : @@ -618,7 +612,6 @@ static irqreturn_t pcie_isr(int irq, void *dev_id) } if (intr_loc & PCI_EXP_SLTSTA_DLLSC) { - link = pciehp_check_link_active(ctrl); ctrl_info(ctrl, "slot(%s): Link %s event\n", slot_name(slot), link ? "Up" : "Down"); pciehp_queue_interrupt_event(slot, link ? INT_LINK_UP : -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2016-09-01 10:44 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-08-17 13:42 [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling Patel, Mayurkumar 2016-08-17 17:12 ` Bjorn Helgaas 2016-08-17 17:54 ` Rajat Jain 2016-08-17 18:14 ` Bjorn Helgaas 2016-08-17 22:37 ` Patel, Mayurkumar 2016-08-18 12:52 ` Bjorn Helgaas 2016-08-18 20:59 ` Patel, Mayurkumar 2016-08-23 23:47 ` Rajat Jain 2016-08-24 9:00 ` Patel, Mayurkumar 2016-09-01 10:44 ` Patel, Mayurkumar 2016-08-24 14:59 ` Keith Busch 2016-08-18 21:07 ` [PATCH v1 1/2] " Mayurkumar Patel 2016-08-18 21:07 ` [PATCH v1 2/2] PCI: pciehp: Rework hotplug interrupt routine Mayurkumar Patel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).