From patchwork Wed Dec 18 06:50:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 3367931 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 9FF039F314 for ; Wed, 18 Dec 2013 06:50:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E6043203EC for ; Wed, 18 Dec 2013 06:50:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E126203E9 for ; Wed, 18 Dec 2013 06:50:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751316Ab3LRGuX (ORCPT ); Wed, 18 Dec 2013 01:50:23 -0500 Received: from mail-ig0-f169.google.com ([209.85.213.169]:63640 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751235Ab3LRGuW (ORCPT ); Wed, 18 Dec 2013 01:50:22 -0500 Received: by mail-ig0-f169.google.com with SMTP id hk11so8304038igb.0 for ; Tue, 17 Dec 2013 22:50:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=RRXc7R/Raf2zGan3ftWUY10dp7+qPndOCCz4uqKNAQ8=; b=cuDXY8zQae/tbAQlM1Tb1qKOfO2K40u/vLqYKYLSwhLlMAb2ugu9T4X+Y7DRIwwR6/ j961w0dQNaF6FmcB6cOLwRC5U+bI9OX588x3MlNt6RYr8FBzHB+0hPGt8YtMU76gW0mH tzEU5+vKMW1MES7HcmARbFO/zy1wrTw31NFoZuYL3tyy4+uFnL4mRvrEPaEF4WyR9aFn sZU/kG7qYWwjpZ09mF8GGCeYQvcILldO47OTtMkk2QdrpA6ctGQFjn7/m58zAPfSI30o 7CBWp7IgDBgFOjxmMT5aB+q/vvvnoXSqwHg8MvglRQwArIMsXPskgL7AHr+tIgHiiy1V /q1Q== MIME-Version: 1.0 X-Received: by 10.50.49.65 with SMTP id s1mr6631969ign.43.1387349421883; Tue, 17 Dec 2013 22:50:21 -0800 (PST) Received: by 10.64.235.70 with HTTP; Tue, 17 Dec 2013 22:50:21 -0800 (PST) In-Reply-To: <0c18891f0a754978a3015c9b3b50df93@DM2PR05MB671.namprd05.prod.outlook.com> References: <52B0AEAD.6050604@gmail.com> <20131218010207.GC15119@google.com> <41c1723da4454cdca6503418746a5ca7@DM2PR05MB671.namprd05.prod.outlook.com> <0c18891f0a754978a3015c9b3b50df93@DM2PR05MB671.namprd05.prod.outlook.com> Date: Tue, 17 Dec 2013 22:50:21 -0800 X-Google-Sender-Auth: APVhlxnHPcsyGuUwAyWhYz4szdM Message-ID: Subject: Re: [PATCH v3 4/8] pciehp: Don't disable the link permanently, during removal From: Yinghai Lu To: Rajat Jain Cc: Bjorn Helgaas , Rajat Jain , Kenji Kaneshige , Alex Williamson , Yijing Wang , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Guenter Roeck , Rajat Jain 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_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,T_TVD_MIME_EPI, 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 On Tue, Dec 17, 2013 at 10:17 PM, Rajat Jain wrote: > Well, in that case I doubt if the patch will solve the problem. I think > Most likely the "card present / not present" messages may be replaced > By "link-up / link-down" messages. But I'd appreciate your testing. I did have a debug patch at that time to report link status change. And it did report link up and link down. Thanks Yinghai Subject: [PATCH] PCI, pciehp: Report pcie link state change To see if there is some link state change. Signed-off-by: Yinghai Lu --- drivers/pci/hotplug/pciehp_hpc.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) Index: linux-2.6/drivers/pci/hotplug/pciehp_hpc.c =================================================================== --- linux-2.6.orig/drivers/pci/hotplug/pciehp_hpc.c +++ linux-2.6/drivers/pci/hotplug/pciehp_hpc.c @@ -603,6 +603,25 @@ int pciehp_power_off_slot(struct slot * return 0; } +static u8 pciehp_handle_linkstate_change(struct slot *slot) +{ + struct controller *ctrl = slot->ctrl; + u16 lnk_status; + int retval; + + /* LinkState Change */ + ctrl_dbg(ctrl, "LinkState change\n"); + + retval = pciehp_readw(ctrl, PCI_EXP_LNKSTA, &lnk_status); + if (retval) { + ctrl_err(ctrl, "Cannot read LNKSTATUS register\n"); + return 1; + } + ctrl_info(ctrl, "lnk_status = %x\n", lnk_status); + + return 1; +} + static irqreturn_t pcie_isr(int irq, void *dev_id) { struct controller *ctrl = (struct controller *)dev_id; @@ -624,7 +643,7 @@ static irqreturn_t pcie_isr(int irq, voi detected &= (PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD | PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_PDC | - PCI_EXP_SLTSTA_CC); + PCI_EXP_SLTSTA_CC | PCI_EXP_SLTSTA_DLLSC); detected &= ~intr_loc; intr_loc |= detected; if (!intr_loc) @@ -648,6 +667,10 @@ static irqreturn_t pcie_isr(int irq, voi if (!(intr_loc & ~PCI_EXP_SLTSTA_CC)) return IRQ_HANDLED; + /* Check Link State Changed */ + if (intr_loc & PCI_EXP_SLTSTA_DLLSC) + pciehp_handle_linkstate_change(slot); + /* Check MRL Sensor Changed */ if (intr_loc & PCI_EXP_SLTSTA_MRLSC) pciehp_handle_switch_change(slot); @@ -689,10 +712,12 @@ int pcie_enable_notification(struct cont cmd |= PCI_EXP_SLTCTL_MRLSCE; if (!pciehp_poll_mode) cmd |= PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE; + cmd |= PCI_EXP_SLTCTL_DLLSCE; mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE | PCI_EXP_SLTCTL_MRLSCE | PCI_EXP_SLTCTL_PFDE | - PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE); + PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE | + PCI_EXP_SLTCTL_DLLSCE); if (pcie_write_cmd(ctrl, cmd, mask)) { ctrl_err(ctrl, "Cannot enable software notification\n");