From patchwork Wed Aug 17 13:42:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Patel, Mayurkumar" X-Patchwork-Id: 9285985 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C9FFF60839 for ; Wed, 17 Aug 2016 13:42:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9F8D29A41 for ; Wed, 17 Aug 2016 13:42:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE12429A63; Wed, 17 Aug 2016 13:42:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2063829A41 for ; Wed, 17 Aug 2016 13:42:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751993AbcHQNmX convert rfc822-to-8bit (ORCPT ); Wed, 17 Aug 2016 09:42:23 -0400 Received: from mga09.intel.com ([134.134.136.24]:53993 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751495AbcHQNmW (ORCPT ); Wed, 17 Aug 2016 09:42:22 -0400 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 17 Aug 2016 06:42:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,529,1464678000"; d="scan'208";a="157151383" Received: from irsmsx108.ger.corp.intel.com ([163.33.3.3]) by fmsmga004.fm.intel.com with ESMTP; 17 Aug 2016 06:42:19 -0700 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.183]) by IRSMSX108.ger.corp.intel.com ([169.254.11.71]) with mapi id 14.03.0248.002; Wed, 17 Aug 2016 14:42:19 +0100 From: "Patel, Mayurkumar" 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" Subject: [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling Thread-Topic: [PATCH v1] PCI: pciehp: Fix presence detect change interrupt handling Thread-Index: AdH4jIpxLU9KSl+QQlOXmljdWkK/uA== Date: Wed, 17 Aug 2016 13:42:18 +0000 Message-ID: <92EBB4272BF81E4089A7126EC1E7B284665970B5@IRSMSX101.ger.corp.intel.com> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Rajat Jain --- Resending the patch addressing to PCI Maintainer Bjorn Helgaas. drivers/pci/hotplug/pciehp_ctrl.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) -- 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 -- 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_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: