From patchwork Sat Nov 19 08:32:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj X-Patchwork-Id: 9437941 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 4B58560238 for ; Sat, 19 Nov 2016 08:33:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CB76298F3 for ; Sat, 19 Nov 2016 08:33:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30C942995B; Sat, 19 Nov 2016 08:33:37 +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 9BCE4298F3 for ; Sat, 19 Nov 2016 08:33:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752985AbcKSIdN (ORCPT ); Sat, 19 Nov 2016 03:33:13 -0500 Received: from mga06.intel.com ([134.134.136.31]:20360 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752072AbcKSIcx (ORCPT ); Sat, 19 Nov 2016 03:32:53 -0500 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 19 Nov 2016 00:32:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,662,1473145200"; d="scan'208";a="33236244" Received: from otc-nc-03.jf.intel.com ([10.54.39.141]) by fmsmga006.fm.intel.com with ESMTP; 19 Nov 2016 00:32:51 -0800 From: Ashok Raj To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Ashok Raj , Keith Busch , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 1/3] pciehp: Prioritize data-link event over presence detect Date: Sat, 19 Nov 2016 00:32:45 -0800 Message-Id: <1479544367-7195-2-git-send-email-ashok.raj@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479544367-7195-1-git-send-email-ashok.raj@intel.com> References: <1479544367-7195-1-git-send-email-ashok.raj@intel.com> 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 This patch places higher precedence on a Data Link Layer Status Change event over the Presence Detect Change event in the case the slot status contains both events in the same interrupt. When both events are observed, the pciehp driver is currently relying on the Slot Status Presence Detect State (PDS) agree with the Link Status Data Link Layer Active status. The Presence Detect State, however, may be set to 1 through out-of-band presence detect mechanism even though the link is down, which creates conflicting events. Since the Link Status accurately reflects the reachability of the down stream bus, the link change event should take precedence over a present detect event. This patch skips checking the PDC status we handled a link event in the same handler. Cc: linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Signed-off-by: Ashok Raj Reviewed-by: Keith Busch --- drivers/pci/hotplug/pciehp_hpc.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index b57fc6d..e1ebd67 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -620,8 +620,18 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) pciehp_queue_interrupt_event(slot, INT_BUTTON_PRESS); } - /* Check Presence Detect Changed */ - if (events & PCI_EXP_SLTSTA_PDC) { + /* + * Check Link Status Changed at higher precedence than Presence Detect + * Changed. The PDS value may be set to "card present" from out-of-band + * detection, which may be in conflict with a Link Down and cause the + * wrong event to queue. + */ + if (events & PCI_EXP_SLTSTA_DLLSC) { + ctrl_info(ctrl, "Slot(%s): Link %s\n", slot_name(slot), + link ? "Up" : "Down"); + pciehp_queue_interrupt_event(slot, link ? INT_LINK_UP : + INT_LINK_DOWN); + } else if (events & PCI_EXP_SLTSTA_PDC) { present = !!(status & PCI_EXP_SLTSTA_PDS); ctrl_info(ctrl, "Slot(%s): Card %spresent\n", slot_name(slot), present ? "" : "not "); @@ -636,13 +646,6 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) pciehp_queue_interrupt_event(slot, INT_POWER_FAULT); } - if (events & PCI_EXP_SLTSTA_DLLSC) { - ctrl_info(ctrl, "Slot(%s): Link %s\n", slot_name(slot), - link ? "Up" : "Down"); - pciehp_queue_interrupt_event(slot, link ? INT_LINK_UP : - INT_LINK_DOWN); - } - return IRQ_HANDLED; }