From patchwork Wed Aug 29 03:04:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10579493 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 B7347174C for ; Wed, 29 Aug 2018 03:07:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4BC229CE7 for ; Wed, 29 Aug 2018 03:07:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 972132A784; Wed, 29 Aug 2018 03:07:39 +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=ham 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 EF7DB29CE7 for ; Wed, 29 Aug 2018 03:07:38 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=b+I/TQF+b63ObRSHYc+u/gM4t2KzqEVLU17PC/IpOtw=; b=E5ryxbscD+aSVX Rai6uQ7DbBeJpYDQLuA+75gzkhmC0p7B+l9fLYEEo0fYdLlqJSe2yAl+01tAY97FGrogoAOQ8Q1Af ZhCb95aYzFuTNOYcJswmV7p7d8Z0/PYO9tVE38FGUccopq0hVuYwGpvR2/ytczGMaGB9rIwBu2/vU 7j04I5nQr/sPeL6Y7sjL+8sUf2vKAoTYYnH2Af7r/eetwC5HJ+MUI30MPpSwL4pgPgo9bOagCQofb +F4dBRprGLLip045PcNNfsKIonvthvVsl4Lu/6AaOlvLFKbXN4BEgkCyNOQcpYo+j+0AUtxj7epOb n/eVbGDErkkm2TVdNBGg==; 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 1fuqpQ-0003T7-Ni; Wed, 29 Aug 2018 03:07:32 +0000 Received: from mail-co1nam03on0066.outbound.protection.outlook.com ([104.47.40.66] helo=NAM03-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuqpM-0003HF-92 for linux-arm-kernel@lists.infradead.org; Wed, 29 Aug 2018 03:07:29 +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=jF/yHQ6vSFIy2qUV7hbMzs1AgKPNUd7hWSEl41vPOhY=; b=b3qyWAxtSnweUK89b0bsh/9yebn82eYTe3vX7cs67sKW3xG7Ak1/3fZmUkeyiqkqxTFbp9YjUCs2ArLtpPgIC2+msgOWr15pFJEeIldpz3TUE/9dZaPKO8juTIXL7kVq85KDYlUPfBFTwZRMuy/W6pZR+u4NTPKWa/ZdfNRvTBY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by CY1PR0301MB1579.namprd03.prod.outlook.com (2a01:111:e400:529c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.14; Wed, 29 Aug 2018 03:07:14 +0000 Date: Wed, 29 Aug 2018 11:04:08 +0800 From: Jisheng Zhang To: Jingoo Han , Joao Pinto , Bjorn Helgaas , Lorenzo Pieralisi , , , Subject: [PATCH v3] PCI: dwc: fix scheduling while atomic issues Message-ID: <20180829110408.556c3622@xhacker.debian> X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: KAWPR01CA0090.jpnprd01.prod.outlook.com (2603:1096:402:c::26) To CY1PR0301MB1579.namprd03.prod.outlook.com (2a01:111:e400:529c::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 80f58c90-e7a3-4fcd-fa2f-08d60d5c8658 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:CY1PR0301MB1579; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1579; 3:ZmdUgBFmUsuzpdlBPdCpYEppvtJSkyX7PtWClKTkvdKichTxavcaMFHnr0u2WVck7dJp6HymEEq7tvLg0BMcwqJ5etJgsQwAtAb77Rw+pPTrcKtZpC4rNt1TmP5Pubj2Aql6VmDd/T+4qSpWXUKUXOhrrU7NOWYfeq/Pb32eyNVRYU3LuX+dWErRUyNKVTplQ+kU9obQAA2lQ1OXDImD+77tpCUyZg+jBN7olMVAIzzy3dwvBusrkjxlkgPFZN5P; 25:N05uj38x8SCu9qTWZ86Aory8Hl3a0+W4NAdM4Rb/0pwZl9Mu9fa4GJwDqN2eYOqEQoRX/LP5n8wT6vVK3bYU9+gmHs6CGC89LpDhb0LwK2GYSUIHQHqrhX2YDRmyTGhi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5recIp8ihAQRq13woV2uQQmx0jvjfyP+iCu9XOkCvL7w2YcosEyGdV79VeFjJPHnFTFLYfzdOnFKvJzkKCgEgpYSR6y7KphceWsEOsDA0xV0C3QgZOI/P8/nSw4hUcvWcmaqEIfTfJ9QEfMyPUv2SOiTU+cXvl6sr8e7Uc7a+UAOzMeG1ULOwMYtiKuwy5bkCJgCEnaj/UN0H/VOrd4Syy1/saiadEZtpzTfO707KmZcRQC+ORPtpNFbaMfm2L4RwA== 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)(3231311)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016); SRVR:CY1PR0301MB1579; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1579; X-Forefront-PRVS: 077929D941 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39850400004)(366004)(396003)(136003)(346002)(189003)(199004)(81156014)(16526019)(316002)(23726003)(1076002)(50226002)(575784001)(105586002)(86362001)(106356001)(110136005)(39060400002)(55016002)(8936002)(72206003)(230700001)(9686003)(53936002)(81166006)(305945005)(7736002)(8676002)(6116002)(2906002)(3846002)(6666003)(478600001)(6506007)(476003)(486006)(956004)(33896004)(68736007)(97736004)(50466002)(7696005)(5660300001)(66066001)(186003)(2201001)(47776003)(386003)(25786009)(52116002)(26005)(2101003)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1579; 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; CY1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 5:NGsOWCzV6/8KeuBPOTc8A+5m0FX4lC3p8OgaxubuRN4KF7d6ZObDSplCYnD3CloRw2DuQZCud4b49eG1jb8+GB/sM3Ou6IBIS/vuCY70UUryPbhass3dJy+OzXdKyA8XnnT4ngMUks+XjVhkCRo3UeLKgJHB7UC6RHuoFFvwxB0=; 7:lau8Gu53b/a7gkcdlOM8P8ZyW3OD7AjfjmYu2iNFFXNCJvOK92fVpmASi7FKk5ugtx/c6zAFNS/0Tiew6s+CTq1DD21nelJyIt12jzsDy5b4essDeOMe/kuXfOk/nufXrKqUy8aDWzdgrg2Kd545gJ0CvVQSm8OH65CsDiHtMuxDk6RDn3xs6B1EVo1AYCWElLe427t1tqm1jgWdhvFBAa/bcSFKStFCy/obATlrPbayKgsT3VHE5DxWihQGRT47 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2018 03:07:14.3239 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80f58c90-e7a3-4fcd-fa2f-08d60d5c8658 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1579 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180828_200728_383163_A34E87DC X-CRM114-Status: UNSURE ( 7.55 ) 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: , 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 mdelay() instead. Fixes: f8aed6ec624f ("PCI: dwc: designware: Add EP mode support") Fixes: d8bbeb39fbf3 ("PCI: designware: Wait for iATU enable") Signed-off-by: Jisheng Zhang Acked-by: Gustavo Pimentel --- since v2: - Add Fixes tag - Add Gustavo's Ack since v1: - use mdelay() instead of udelay() to avoid __bad_udelay() 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..2153956a0b20 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); + mdelay(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); + mdelay(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); + mdelay(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); + mdelay(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..9f1a5e399b70 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 9 /* Synopsys-specific PCIe configuration registers */ #define PCIE_PORT_LINK_CONTROL 0x710