From patchwork Mon Sep 29 05:03:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhu X-Patchwork-Id: 4993701 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 BA231BEEA6 for ; Mon, 29 Sep 2014 05:33:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C8985201BC for ; Mon, 29 Sep 2014 05:33:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2FB0820256 for ; Mon, 29 Sep 2014 05:33:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751452AbaI2Fdm (ORCPT ); Mon, 29 Sep 2014 01:33:42 -0400 Received: from mail-bn1on0138.outbound.protection.outlook.com ([157.56.110.138]:48503 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751526AbaI2FdX (ORCPT ); Mon, 29 Sep 2014 01:33:23 -0400 Received: from DM2PR03CA0049.namprd03.prod.outlook.com (10.141.96.48) by BLUPR03MB344.namprd03.prod.outlook.com (10.141.48.24) with Microsoft SMTP Server (TLS) id 15.0.1044.7; Mon, 29 Sep 2014 05:33:20 +0000 Received: from BY2FFO11FD029.protection.gbl (2a01:111:f400:7c0c::118) by DM2PR03CA0049.outlook.office365.com (2a01:111:e400:2428::48) with Microsoft SMTP Server (TLS) id 15.0.1024.12 via Frontend Transport; Mon, 29 Sep 2014 05:33:19 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD029.mail.protection.outlook.com (10.1.14.212) with Microsoft SMTP Server (TLS) id 15.0.1029.15 via Frontend Transport; Mon, 29 Sep 2014 05:33:19 +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 s8T5XGtF021431; Sun, 28 Sep 2014 22:33:17 -0700 Received: by shlinux1.ap.freescale.net (Postfix, from userid 1003) id C05B11AE20B; Mon, 29 Sep 2014 13:03:21 +0800 (CST) From: Richard Zhu To: CC: , , , , , Richard Zhu Subject: [PATCH v3 9/9] PCI: imx6: Fix possible dead lock Date: Mon, 29 Sep 2014 13:03:17 +0800 Message-ID: <1411966997-27118-10-git-send-email-r65037@freescale.com> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1411966997-27118-1-git-send-email-r65037@freescale.com> References: <1411966997-27118-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)(46386002)(76482002)(26826002)(68736004)(99396003)(47776003)(90102001)(92566001)(87286001)(10300001)(20776003)(105586002)(6806004)(77096002)(95666004)(62966002)(89996001)(45336002)(52956003)(120916001)(84676001)(31966008)(50226001)(4396001)(103686003)(102836001)(85852003)(87936001)(16796002)(83072002)(101416001)(92726001)(97736003)(88136002)(42186005)(575784001)(93916002)(74662003)(50986999)(74502003)(77982003)(80022003)(81542003)(79102003)(76176999)(46102003)(33646002)(85306004)(21056001)(81342003)(106466001)(110136001)(44976005)(19580395003)(19580405001)(83322001)(50466002)(48376002)(64706001)(104166001)(107046002)(36756003)(77156001)(229853001)(2351001)(90966001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR03MB344; 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:BLUPR03MB344; X-Forefront-PRVS: 034902F5BC 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.7 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 be953aa..e60c195 100644 --- a/drivers/pci/host/pci-imx6.c +++ b/drivers/pci/host/pci-imx6.c @@ -521,7 +521,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 @@ -552,7 +552,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.