From patchwork Tue Aug 21 02:44:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10570925 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 30E7B1803 for ; Tue, 21 Aug 2018 02:47:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19D142876D for ; Tue, 21 Aug 2018 02:47:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08D7E28774; Tue, 21 Aug 2018 02:47:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6ED72200E5 for ; Tue, 21 Aug 2018 02:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=TCinR806fUKGp4A7E4qeWj5WTPjU+0pE503RpvWtGD4=; b=q3+NwzBIRbTI4Y 5ZNGakQ+F71RsPYeK+B8BIB7SU+ipcwOIa8jdGZppzFN7zNJx6I9C0byh8i3Dn7cSEAnY0n9meNle fLZkNL61zyJzPOROPpC1OgAnyoBNcoKnw7915oDrvie/nnj9Gq63xviy6v3t9SfpQqU+wiP9jQ+aj 4Uhe/URaWfFpZS0V9nXhKEtkju5KIPFe7TyGAwx3Io5Qp3I9nAx8/eqKRJagvIAsHEbLeqggrcy0R 6RjR5ulGkI/CY8E1qEi+zxhTxBmq5pqwS1BluVVjohsQhAki+TPWNqncMaiw1vJQ686GaOw4oU+Or SPzP7rubPoCVowK8MdvA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1frwhy-000780-Kf; Tue, 21 Aug 2018 02:47:50 +0000 Received: from mail-eopbgr690081.outbound.protection.outlook.com ([40.107.69.81] helo=NAM04-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1frwhv-00072C-35 for linux-arm-kernel@lists.infradead.org; Tue, 21 Aug 2018 02:47:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector1-synaptics-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OmZ2GKLpLDuvcNh7uy5VeDL+9JUt2iz91G1SqMqUJic=; b=aoKWuSk7WKX9AFGfeiVzL0XrscHTY6hWqdQPwtzLNW0ztGA2DbL4rIbOOXGUx+5Wum5kXjH6Xxm8Wlwl4VrJaoc2xls9UJW2FIs0c2IiVZrRmqIdapd5Lrx7UsnvfHlK6JFOHYUwevNhXXxv0BbAbvLuK4NRABRxN7m9eJu6mr4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by BY2PR0301MB1576.namprd03.prod.outlook.com (2a01:111:e400:526e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.24; Tue, 21 Aug 2018 02:47:29 +0000 Date: Tue, 21 Aug 2018 10:44:33 +0800 From: Jisheng Zhang To: Jingoo Han , Joao Pinto , Lorenzo Pieralisi , Bjorn Helgaas Subject: [PATCH] PCI: dwc: fix scheduling while atomic issues Message-ID: <20180821104433.1c408d7e@xhacker.debian> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: TYAPR01CA0135.jpnprd01.prod.outlook.com (2603:1096:404:2d::27) To BY2PR0301MB1576.namprd03.prod.outlook.com (2a01:111:e400:526e::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2be818ff-57e9-4141-cfe6-08d607107146 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BY2PR0301MB1576; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1576; 3:4zbxfGhZ1Y9ob8c2JOiGgWer9NLPA6ZfJbsPAx/pzZYXhRZhCVvq3mEbb5kUjrfR5JbcJkGUzbkfNQyMC+kd05EOuoK82PWdwy14w99xqhK6dOgsPKvoTraZgS5fyg7oFZ2bCylr0i2ts1jDSAMpUicZF5usb3kE9xv45RwemzHNckJftwbzX6LxFfjyGh0miyDW56dx7wgCtrFnxH8jvExEx+V98nERVdTTGqf5pG4Yt/1aIYIEeVh/W63Kac7s; 25:ph6USRFkom3BeHsU931Dn4ePih9nahpN/gxe6ZpjP7nlS8hAIGotOYhDBg5SWaRgcvpHsUNzAwq47iOtLUTfzH2NnW90DaKsQRV/69QCi4/13dJTd9O8FwPYNub2BEQbBr6C+0yDYh92col5ncZMecRK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0bkMRlYVr6mbo1Z4RPOFFxTelSdTVpEaJHpLW3kp9vqstdj9vLYhB2N5fTu1iUFEFOtX1yM0qq0MBmUq7jW3FlTkxSui0DorqnZivLDPOBQbxam4aggkEP1Nrr1YdwB5KwsHbkekG6CMhVvXzzbUumGUCr53uYZzo+yD6pokIkiTRrrhvWixZtf+4plzJdOHnNz2mOjCb0AoiACMOwx945nRuNVKUG3WCAcTMA8nro5XdQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(149027)(150027)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699016); SRVR:BY2PR0301MB1576; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0301MB1576; X-Forefront-PRVS: 0771670921 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(366004)(396003)(136003)(346002)(189003)(199004)(4326008)(230700001)(2906002)(186003)(1076002)(6666003)(16526019)(486006)(26005)(305945005)(110136005)(7736002)(72206003)(106356001)(66066001)(23726003)(478600001)(39060400002)(47776003)(97736004)(105586002)(25786009)(6116002)(68736007)(3846002)(50226002)(8676002)(8936002)(316002)(52116002)(7696005)(33896004)(1857600001)(956004)(386003)(5660300001)(86362001)(50466002)(53936002)(81156014)(55016002)(476003)(9686003)(81166006)(6506007)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB1576; H:xhacker.debian; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB1576; 23:FjJ8zFn7mRYtrkh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0EdmHVZxYFI/A+aEgrLFXzUiQfpUmq+QC7/l60pU8sn8LF8KIrs8QjlfQWnCzbKFzqbSLhW7ylVnyHpGZ+PVmtsxkQXJJodCgaHL2tj6aod3BrckkJJ+4Y=; 7:qrHkKjlnkPPqa9LGaQ5j/IRJSlkBOA4oRbFZN3zj49t4Puc1xtAPvN3vNoxB1K/Iil424P8k5wxx83k26ChA/80CtVoOMdf6N+jsFgsV+1VtijZ6geasriziK4NcUTOwC1qGvP32BpD0UaFvtfc70e452Wo8b0Yc22fqsT6HCdAeNG/O3i0sbAU14NnHGJtjiYFX751Vyxe4gJUmVDgNmrDA+//yOf598YbK2znChHaUYoNXRJQ/avFJ51H+kRyL SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2018 02:47:29.7941 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2be818ff-57e9-4141-cfe6-08d607107146 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB1576 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180820_194747_202545_50000DD7 X-CRM114-Status: UNSURE ( 8.41 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When programming inbound/outbound atu, we call usleep_range() after each checking PCIE_ATU_ENABLE bit. Unfortunately, the atu programming can be called in atomic context: inbound atu programming could be called through pci_epc_write_header() =>dw_pcie_ep_write_header() =>dw_pcie_prog_inbound_atu() outbound atu programming could be called through pci_bus_read_config_dword() =>dw_pcie_rd_conf() =>dw_pcie_prog_outbound_atu() Fix this issue by calling udelay() instead. Signed-off-by: Jisheng Zhang --- drivers/pci/controller/dwc/pcie-designware.c | 8 ++++---- drivers/pci/controller/dwc/pcie-designware.h | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index 778c4f76a884..4c15929d9c79 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -135,7 +135,7 @@ static void dw_pcie_prog_outbound_atu_unroll(struct dw_pcie *pci, int index, if (val & PCIE_ATU_ENABLE) return; - usleep_range(LINK_WAIT_IATU_MIN, LINK_WAIT_IATU_MAX); + udelay(LINK_WAIT_IATU); } dev_err(pci->dev, "Outbound iATU is not being enabled\n"); } @@ -178,7 +178,7 @@ void dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index, int type, if (val & PCIE_ATU_ENABLE) return; - usleep_range(LINK_WAIT_IATU_MIN, LINK_WAIT_IATU_MAX); + udelay(LINK_WAIT_IATU); } dev_err(pci->dev, "Outbound iATU is not being enabled\n"); } @@ -236,7 +236,7 @@ static int dw_pcie_prog_inbound_atu_unroll(struct dw_pcie *pci, int index, if (val & PCIE_ATU_ENABLE) return 0; - usleep_range(LINK_WAIT_IATU_MIN, LINK_WAIT_IATU_MAX); + udelay(LINK_WAIT_IATU); } dev_err(pci->dev, "Inbound iATU is not being enabled\n"); @@ -282,7 +282,7 @@ int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, int index, int bar, if (val & PCIE_ATU_ENABLE) return 0; - usleep_range(LINK_WAIT_IATU_MIN, LINK_WAIT_IATU_MAX); + udelay(LINK_WAIT_IATU); } dev_err(pci->dev, "Inbound iATU is not being enabled\n"); diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 96126fd8403c..8bab329c5cd3 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -26,8 +26,7 @@ /* Parameters for the waiting for iATU enabled routine */ #define LINK_WAIT_MAX_IATU_RETRIES 5 -#define LINK_WAIT_IATU_MIN 9000 -#define LINK_WAIT_IATU_MAX 10000 +#define LINK_WAIT_IATU 9000 /* Synopsys-specific PCIe configuration registers */ #define PCIE_PORT_LINK_CONTROL 0x710