From patchwork Wed Feb 19 02:53:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 3677681 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 740EE9F35F for ; Wed, 19 Feb 2014 02:53:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CE0AB201DE for ; Wed, 19 Feb 2014 02:53:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8329201BA for ; Wed, 19 Feb 2014 02:53:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752172AbaBSCxX (ORCPT ); Tue, 18 Feb 2014 21:53:23 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:42126 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752006AbaBSCxW (ORCPT ); Tue, 18 Feb 2014 21:53:22 -0500 Received: by mail-pa0-f42.google.com with SMTP id kl14so17605060pab.15 for ; Tue, 18 Feb 2014 18:53:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=jCmm1QJkp1QgSttYilXTKDNY6OazJw4GKdaFGLKIYMg=; b=xnreJ2PcQ1xVRzbUnz7ZUE5LVuRECsJ+IXt6kLCegmAe/l43EmMZ3GT2YwbX1tUqgz uKmQ05YBNeTZkR6FaqxWYo53f9MbJw0IzKWBsbE14kfQJsMFGj4eU5+a7uMEB13Pk8JP OjC10lAbZd0WaxF40H0uanFpbI2l4TMJ7wL2mJUPg7naM7XBfeK00Lpk9TbM/6yugKxR SvpX/FsRG4u/3BgO7cSD26sDtTvi6sFypC/C4WVLdu1+Y6Ws2vrdN/bxekeW5waCB7ps HYvQ9FhSVfKwyycGYO8QMFiTdj8zgAF0pNYGhCKN/Zjsko/osgS/Lxz5anc2Uq3tu2pc qSjw== X-Received: by 10.68.163.197 with SMTP id yk5mr36996168pbb.57.1392778401885; Tue, 18 Feb 2014 18:53:21 -0800 (PST) Received: from [192.168.211.137] ([66.129.239.11]) by mx.google.com with ESMTPSA id xs1sm155186277pac.7.2014.02.18.18.53.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 18:53:21 -0800 (PST) Message-ID: <53041C9F.7050801@gmail.com> Date: Tue, 18 Feb 2014 18:53:19 -0800 From: Rajat Jain User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 MIME-Version: 1.0 To: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org CC: Rajat Jain , Guenter Roeck , Alex Williamson Subject: [PATCH] pciehp: Remove a non-existent card, regardless of "surprise" capability Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 In case a card is physically yanked out, it should immediately be removed, regardless of the "surprise" capability bit. Thus: * Always handle the physical removal - regardless of the "surprise" bit. * Don't use "surprise" capability when making decisions about enabling presence detect notifications. * Reword the comments to indicate the intent. Signed-off-by: Rajat Jain Signed-off-by: Rajat Jain Signed-off-by: Guenter Roeck --- drivers/pci/hotplug/pciehp_ctrl.c | 9 ++++++++- drivers/pci/hotplug/pciehp_hpc.c | 9 +++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index e027e36..c75e6a6 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -534,9 +534,16 @@ static void interrupt_event_handler(struct work_struct *work) pciehp_green_led_off(p_slot); break; case INT_PRESENCE_ON: - case INT_PRESENCE_OFF: if (!HP_SUPR_RM(ctrl)) break; + ctrl_dbg(ctrl, "Surprise Insertion\n"); + handle_surprise_event(p_slot); + break; + case INT_PRESENCE_OFF: + /* + * Regardless of surprise capability, we need to + * definitely remove a card that has been pulled out! + */ ctrl_dbg(ctrl, "Surprise Removal\n"); handle_surprise_event(p_slot); break; diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index da4b020..d7d058f 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -619,9 +619,10 @@ static void pcie_disable_notification(struct controller *ctrl) /* * pciehp has a 1:1 bus:slot relationship so we ultimately want a secondary - * bus reset of the bridge, but if the slot supports surprise removal (or - * link state change based hotplug), we need to disable presence detection - * (or link state notifications) around the bus reset and clear any spurious + * bus reset of the bridge, but at the same time we want to ensure that it is + * not seen as a hot-unplug, followed by the hot-plug of the device. Thus, + * disable link state notification and presence detection change notification + * momentarily, if we see that they could interfere. Also, clear any spurious * events after. */ int pciehp_reset_slot(struct slot *slot, int probe) @@ -633,7 +634,7 @@ int pciehp_reset_slot(struct slot *slot, int probe) if (probe) return 0; - if (HP_SUPR_RM(ctrl) && !ATTN_BUTTN(ctrl)) { + if (!ATTN_BUTTN(ctrl)) { ctrl_mask |= PCI_EXP_SLTCTL_PDCE; stat_mask |= PCI_EXP_SLTSTA_PDC; }