From patchwork Mon Dec 22 19:07:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 5528791 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A894CBEEA8 for ; Mon, 22 Dec 2014 19:07:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC00C201BB for ; Mon, 22 Dec 2014 19:07:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D73F1200FF for ; Mon, 22 Dec 2014 19:07:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754825AbaLVTHH (ORCPT ); Mon, 22 Dec 2014 14:07:07 -0500 Received: from mga01.intel.com ([192.55.52.88]:12811 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754460AbaLVTHG (ORCPT ); Mon, 22 Dec 2014 14:07:06 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 22 Dec 2014 11:07:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,625,1413270000"; d="scan'208";a="658609823" Received: from dcgshare.lm.intel.com ([10.232.118.254]) by orsmga002.jf.intel.com with ESMTP; 22 Dec 2014 11:07:05 -0800 Received: by dcgshare.lm.intel.com (Postfix, from userid 1017) id 93BEDE00F2; Mon, 22 Dec 2014 12:07:05 -0700 (MST) From: Keith Busch To: Bjorn Helgaas , linux-pci@vger.kernel.org Cc: Keith Busch Subject: [PATCH] pci: Use hot-plug capable for testing presence on Date: Mon, 22 Dec 2014 12:07:03 -0700 Message-Id: <1419275223-14602-1-git-send-email-keith.busch@intel.com> X-Mailer: git-send-email 1.7.1 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The PCI-e Base specifically says Hot-Plug Surprise capability is for removal only, but pciehp checked this to determine if it should handle a slot event on device add. Lots of platform's pcie slots don't advertise support for surprise removal, but are perfectly capable of handling hot-add, so checking surprise removal is not appropriate. This patch checks the Hot-Plug Capable bit in the slot capabilities to determine if the detected presence on is a reliable event instead of Hot-Plug Surprise. Signed-off-by: Keith Busch --- drivers/pci/hotplug/pciehp.h | 1 + drivers/pci/hotplug/pciehp_ctrl.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index b115219..b91eefb 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -126,6 +126,7 @@ struct controller { #define ATTN_LED(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_AIP) #define PWR_LED(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_PIP) #define HP_SUPR_RM(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_HPS) +#define HP_CAP(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_HPC) #define EMI(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_EIP) #define NO_CMD_CMPL(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_NCCS) #define PSN(ctrl) (((ctrl)->slot_cap & PCI_EXP_SLTCAP_PSN) >> 19) diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index ff32e85..996c313 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -532,7 +532,7 @@ static void interrupt_event_handler(struct work_struct *work) pciehp_green_led_off(p_slot); break; case INT_PRESENCE_ON: - if (!HP_SUPR_RM(ctrl)) + if (!HP_CAP(ctrl)) break; ctrl_dbg(ctrl, "Surprise Insertion\n"); handle_surprise_event(p_slot);