From patchwork Tue Sep 30 09:36:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhu X-Patchwork-Id: 5001691 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 75AB3BEEA6 for ; Tue, 30 Sep 2014 10:07:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 834C92018E for ; Tue, 30 Sep 2014 10:07:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94E72201C7 for ; Tue, 30 Sep 2014 10:07:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750981AbaI3KHI (ORCPT ); Tue, 30 Sep 2014 06:07:08 -0400 Received: from mail-bn1on0134.outbound.protection.outlook.com ([157.56.110.134]:50368 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751959AbaI3KHH (ORCPT ); Tue, 30 Sep 2014 06:07:07 -0400 Received: from BN3PR0301CA0046.namprd03.prod.outlook.com (25.160.152.142) by CY1PR0301MB0858.namprd03.prod.outlook.com (25.160.163.152) with Microsoft SMTP Server (TLS) id 15.0.1039.15; Tue, 30 Sep 2014 10:07:04 +0000 Received: from BN1BFFO11FD054.protection.gbl (2a01:111:f400:7c10::1:107) by BN3PR0301CA0046.outlook.office365.com (2a01:111:e400:401e::14) with Microsoft SMTP Server (TLS) id 15.0.1039.15 via Frontend Transport; Tue, 30 Sep 2014 10:07:03 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD054.mail.protection.outlook.com (10.58.145.9) with Microsoft SMTP Server (TLS) id 15.0.1029.15 via Frontend Transport; Tue, 30 Sep 2014 10:07:04 +0000 Received: from shlinux1.ap.freescale.net (shlinux1.ap.freescale.net [10.192.225.216]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s8UA709j011203; Tue, 30 Sep 2014 03:07:02 -0700 Received: by shlinux1.ap.freescale.net (Postfix, from userid 1003) id CDAE11AE206; Tue, 30 Sep 2014 17:36:44 +0800 (CST) From: Richard Zhu To: CC: , , , , , Richard Zhu Subject: [PATCH v4 03/10] PCI: imx6: Fix possible dead lock Date: Tue, 30 Sep 2014 17:36:37 +0800 Message-ID: <1412069804-17162-4-git-send-email-r65037@freescale.com> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1412069804-17162-1-git-send-email-r65037@freescale.com> References: <1412069804-17162-1-git-send-email-r65037@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(428002)(199003)(189002)(62966002)(89996001)(88136002)(4396001)(52956003)(10300001)(80022003)(92566001)(120916001)(92726001)(48376002)(64706001)(42186005)(87286001)(46102003)(85852003)(50466002)(76482002)(87936001)(99396003)(21056001)(19580405001)(102836001)(85306004)(95666004)(19580395003)(6806004)(44976005)(50986999)(36756003)(68736004)(101416001)(77156001)(2351001)(26826002)(31966008)(93916002)(46386002)(110136001)(50226001)(575784001)(45336002)(97736003)(106466001)(20776003)(104166001)(47776003)(103686003)(76176999)(107046002)(16796002)(84676001)(229853001)(33646002)(105586002)(77096002)(90966001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0301MB0858; H:tx30smr01.am.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; A:0; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB0858; X-Forefront-PRVS: 0350D7A55D Received-SPF: None (protection.outlook.com: shlinux1.ap.freescale.net does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is 192.88.168.50) smtp.mailfrom=r65037@shlinux1.ap.freescale.net; X-OriginatorOrg: freescale.com 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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 kernel report one possible dead lock during imx6sx pcie suspend resume stress tests, after enable Lock Debugging. platform: imx6sx sdb board + xhci(pcie2usb3.0 ep) reason: usleep_range used in imx6_pcie_link_up maybe scheduled out from dw_pcie_valid_config.isra... About details, please see the following logs. solution: replace the usleep_range(1000, 2000) by udelay(10) and enlarge the loop counter. logs: [ 50.643062] xhci_hcd 0000:01:00.0: Refused to change power state, currently in D3 [ 50.653390] [ 50.654898] ========================================================= [ 50.661343] [ INFO: possible irq lock inversion dependency detected ] [ 50.667792] 3.17.0-rc2-01341-gfc43ff7-dirty #101 Not tainted [ 50.673454] --------------------------------------------------------- [ 50.679898] kworker/u2:2/48 just changed the state of lock: [ 50.685477] (pci_lock){+.....}, at: [<802d650c>] pci_bus_read_config_dword+0x44/0x94 [ 50.693394] but this lock was taken by another, HARDIRQ-safe lock in the past: [ 50.700619] (&irq_desc_lock_class){-.-...} and interrupts could create inverse lock ordering between them. [ 50.710843] [ 50.710843] other info that might help us debug this: [ 50.717377] Possible interrupt unsafe locking scenario: [ 50.717377] [ 50.724169] CPU0 CPU1 [ 50.728702] ---- ---- [ 50.733234] lock(pci_lock); [ 50.736232] local_irq_disable(); [ 50.742154] lock(&irq_desc_lock_class); [ 50.748713] lock(pci_lock); [ 50.754229] [ 50.756852] lock(&irq_desc_lock_class); [ 50.761065] [ 50.761065] *** DEADLOCK *** ... [ 52.119515] [<806e8ad0>] (schedule_hrtimeout_range) from [<80077e90>] (usleep_range+0x50/0x58) [ 52.128141] [<80077e40>] (usleep_range) from [<802f3694>] (imx6_pcie_link_up+0x48/0x16c) [ 52.136242] [<802f364c>] (imx6_pcie_link_up) from [<802f1b74>] (dw_pcie_valid_config.isra.10+0x40/0x7c) [ 52.145637] r6:ae72606d r5:ae72606c r4:ae711228 [ 52.150311] [<802f1b34>] (dw_pcie_valid_config.isra.10) from [<802f1ca8>] (dw_pcie_rd_conf+0x4c/0x154) [ 52.159620] r7:00000000 r6:00000000 r5:ae711228 r4:ae726000 [ 52.165355] [<802f1c5c>] (dw_pcie_rd_conf) from [<802d6534>] (pci_bus_read_config_dword+0x6c/0x94) [ 52.174316] r9:adf4e910 r8:809bc51c r7:00000000 r6:60000153 r5:adc3fd5c r4:ae726000 [ 52.182152] [<802d64c8>] (pci_bus_read_config_dword) from [<802db588>] (pci_restore_config_dword+0x54/0xa4) [ 52.191894] r6:00000024 r5:0000000a r4:ae61e000 [ 52.196570] [<802db534>] (pci_restore_config_dword) from [<802dd150>] (pci_restore_state.part.37+0x7c/0x1f8) [ 52.206399] r8:802e086c r7:ae61dfe8 r6:519e2024 r5:ae61e000 r4:ae61dffc [ 52.213187] [<802dd0d4>] (pci_restore_state.part.37) from [<802dd2e8>] (pci_restore_state+0x1c/0x20) [ 52.222322] r7:adc3fea8 r6:809d90e0 r5:ae61e000 r4:ae61e068 [ 52.228056] [<802dd2cc>] (pci_restore_state) from [<802e0894>] (pci_pm_resume_noirq+0x28/0xa4) [ 52.236683] [<802e086c>] (pci_pm_resume_noirq) from [<8037ea1c>] (dpm_run_callback.isra.12+0x34/0x7c) Signed-off-by: Richard Zhu --- drivers/pci/host/pci-imx6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c index c74e87d..4334de6 100644 --- a/drivers/pci/host/pci-imx6.c +++ b/drivers/pci/host/pci-imx6.c @@ -519,7 +519,7 @@ static void imx6_pcie_reset_phy(struct pcie_port *pp) static int imx6_pcie_link_up(struct pcie_port *pp) { u32 rc, debug_r0, rx_valid; - int count = 5; + int count = 500; /* * Test if the PHY reports that the link is up and also that the LTSSM @@ -550,7 +550,7 @@ static int imx6_pcie_link_up(struct pcie_port *pp) * Wait a little bit, then re-check if the link finished * the training. */ - usleep_range(1000, 2000); + udelay(10); } /* * From L0, initiate MAC entry to gen2 if EP/RC supports gen2.