Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp193523imm; Tue, 28 Aug 2018 20:12:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZYjUYssonq3nLdoGBmRTyAhgg1ZC9JtIFNf8o8X6XQ7eWSGqYkZi3eKfbFcxeVFGnjnCzF X-Received: by 2002:a17:902:d917:: with SMTP id c23-v6mr4111681plz.65.1535512352040; Tue, 28 Aug 2018 20:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535512352; cv=none; d=google.com; s=arc-20160816; b=Iqy7/hzsrgY8Grt+gDdq3FW9bek6nUmTw9uf2aMtjbei1XUUNuAJT5xhAyQZwQKduP siL+oSAbgSApR80V0rPHRqCaXfQTfPLXW6I1DPSEQiz86kLVFeh5mdPgc6FL2Tln4vsd Jbb6PIw1oZUIcmxu+9IrdTltpfxLFxLyGe2Bl8X5yOoUnnQxa8sx/04IDYpoP5BxU3s+ HZ3iTPxWOE+BZTbz+EYyS4FlmsRTXSlbKh6QIgW2k5+vcUc7EBquKRNq1hqWYfD2k7up FHhVFudXSfhwn1B9CHwkKFBvT6Nt/0Uu7G7BGl6+1zD1m1zLB6AvWWH0UwhNo2XgNC12 u+MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:mime-version :message-id:subject:to:from:date:dkim-signature :arc-authentication-results; bh=jF/yHQ6vSFIy2qUV7hbMzs1AgKPNUd7hWSEl41vPOhY=; b=CBkmqxGvN5G9ZPm1C9SQI4epN1QSJK/rijVJfct51xITeBeldDUQmpCUDix+q4kivx ZPNRbdpXjSU1V5zYRLNMoN8k9xOFJ8wWmy0Td9yy0JV2pbpjRFSJJs0o0G6sRuR3B11S UtywfUlW4PfAiTIqe+wOPnEkqLb78+l55O6TD/qcmqXfFXGajyUX6+Ekpkps/YT4c2zp U9UsApzS5giJuSqABW44z11bpd+yjlKhS913J+VX3MozRradv6jGxfWMo2zRHyROn58R 4FUCyoZEY6/N869pw801qF/0bBPenjekvc8x40b2YwcxCRZqD0Er1/+XAWOxlWni+Tcu TPHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector1-synaptics-com header.b=b3qyWAxt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h8-v6si2717592pgd.449.2018.08.28.20.12.16; Tue, 28 Aug 2018 20:12:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector1-synaptics-com header.b=b3qyWAxt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727484AbeH2HFt (ORCPT + 99 others); Wed, 29 Aug 2018 03:05:49 -0400 Received: from mail-co1nam03on0055.outbound.protection.outlook.com ([104.47.40.55]:14435 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727166AbeH2HFt (ORCPT ); Wed, 29 Aug 2018 03:05:49 -0400 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 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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+pPTrcKtZpC4rNt1TmP5Pubj2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heu6eSEetq7Cr/epB3OYdgMFw/i2K5/8kkdyBbokX0tJCFhXWAW8vcwkOM2yH/hTJ1Ebx3uQRtl/aRSCwlvNJU5T0vyrLHHsnR7rwBUsegP5Ly8To2anP48v7xVaG2/0FF45BmA4/N5uCBXLZ/PicH8/1xd8K/HDBVfxQx3S4UBhwoUeaEyuoBs4DI7Mr5MMkKIKPYPMI5Yn1oYBxZUjhFjkyRDrnFWWYn33r1;4:8CgtAvGBJgoqMNmNoJIo5recIp8ihAQRq13woV2uQQmx0jvjfyP+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;CY1PR0301MB1579;23:x1uEyi224StWEr+KtU3DWqNDpZi2i8v1LJcCoU1?= =?us-ascii?Q?hqr+fjiapIRWnT4woWflKzX1zmOFopydurxGEQIEHdNam0J8vtpz44gVBjQ9?= =?us-ascii?Q?8aJZOlgNVQ+ktY4foTBnr5QQFsYunuUSdSZo0Ne2sKI0lZjUL4cMEW2N4nwv?= =?us-ascii?Q?Uzd7LzoEHiYYI7+9yl3KG2SwlpUstfv0f+wZDqlpNG2KZ3Sjc1FTfbDX0zj1?= =?us-ascii?Q?/JFs6wr8gt90VLRQuUe2o3ZMBWY0aKphHOcZ2viRYioe1ZmGuBIm0JNruMbe?= =?us-ascii?Q?x4zK0Yb6qDNK57FgdcJ6RLZ9wuhtEJf+XRkIdozAkh1CPei3hhejPhiWsWkQ?= =?us-ascii?Q?0YN1TmMnakoGkEEzGJ+SULagoZSuuWgJ1Z49AmEj9fs1LT+kpFWSJ643gr6T?= =?us-ascii?Q?aNfG+mxdypazO8oC1wBEvx7oVTOKs+veVPYPdYN1grxIEyQKBetbA816jbKx?= =?us-ascii?Q?yfvTqkbfdWrY9Vx/CP8FK4wxW9zpSwUxfklHWluF+vPjLyBx+JKGahTgjspa?= =?us-ascii?Q?LLngX/bOerfCQPYKrMj/6vN1TdwGTFxGmTNxz5tLfkL/Ca0RNsVKIKSOKSsW?= =?us-ascii?Q?26NbSmBPWIWFLPsEfyYGu4Y/bz2FteNUekujzwErWwDaa4WIdJFkg3Dx9Kbd?= =?us-ascii?Q?0yx6qscj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7C4c3xjD1tUEg/xSIzKdA0lWF1ahtqOqtwynqTfbv/O7WE= X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1579;6:MJiG930qka6Ad1KOaGpydK5o0cfNfnEze8I5bjNoIXcwv/1vEOsgxkU8kgrSKcrdWxdohYsxlioNGXD7OUJL11TYLYa+GWrq6ktFABV7Dyj3BPPZacPYmm7lXKiKImtT2o2eNceCqBliFIhyiUcmVPK5OOpK9CVeBlvtp/Nte5ZThvHGfIi07pzDgHO7hDW5thZuoZ1IC/5qPpKL1eb9YKSTRNd6XfDbNC/VR9HLjkBDenPT46YMQTxGdkyaaNIZrdEYm5pdFwUd+gyuGweEkxDhB+9nS2gNNWFkzuHwe4MavBrYxi0BE/qBpcC1eu0SNCqITkkE8kHexAbFr0TXga8pRXKZuTvizyVf0jRbBes3Zzj0noTennZs2cxl9X5mtZZdS/R1S+irvra6b7rZB9grXR5pODLkHfpljKbyqSC/tWf8sObxSmkQyD/+hYaY2A4fOtQ3j6AD+Mo/w+Tteg==;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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.18.0