Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp812083imm; Thu, 13 Sep 2018 08:07:14 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdag0aRzpDxG3SHj/leKyflCWw9hCn7bpHWM60Au3GsHEX5zlWtE2aQh/kRPEU8uk5ZEdEw8 X-Received: by 2002:a62:3909:: with SMTP id g9-v6mr7906486pfa.176.1536851234475; Thu, 13 Sep 2018 08:07:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536851234; cv=none; d=google.com; s=arc-20160816; b=u1kPz4/PF8teUl1GVLBN3JTbc7B2sNOHuzrH+36ycO/rH+wQ6LvWqVnIrpSDalOnMl WjdKUcK/rlLzQdmCgjkpw9YAEQtPEe/EFFys83RDBTU99934xoG1VzN2B0lAOROso0jK VBzUNOWZPljckkyesFpKhwbYiIjx9yqqvN0J5WbnY46a5u0b+PKSNAu6Yl2B0tchzvwv lNfUYCqZ8hrJ4ILbXGIePvrMzcyT/gusOr9ejNuL8OZdQBqpgh/c1Nbb/oluAhJEQ8B2 5dtSyxulVa+lRRYNUu7TgZ4rwauHrTVvVUtTg099Ib6K2RgpQKv3W10adl+Jb8yTCbDV BQzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=QojwY2QMC3wyQoIrNvLk+q7IU11SkftoR9PxKrZOyCc=; b=mrvqBtTMuam7YYDOQbf7HEOZZX3frUE8/ZJpW5XYYpPPYujq2FpsQTKgCktbO6dtyE LdgX9Wg3dn1vtt1PmOa87mu1orlisLAsLJnPB40k/aB406HfnYXIUL8K5EC9ATDj0O/F 37eh4NJ/w/GtYECfasjFXuWFqp/p5dzSiziF5JuMKTNghlFYSbVM3XTGP9+BvcDKgbqw N88+NwCF25lADvijUQu0DBhYuceMpKEagwk763PqvxH0qvFBu57zQCyBFA+2lsjnSKzw Ci98Bgg0Vq44NXINczIeRKWAPgwVMdfOHLbBL3N4yTJx/Q17nE/J08JEjPiE61hh5Ta3 xW7Q== ARC-Authentication-Results: i=1; mx.google.com; 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 b7-v6si4474838pfj.245.2018.09.13.08.06.58; Thu, 13 Sep 2018 08:07:14 -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; 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 S1728368AbeIMUQA (ORCPT + 99 others); Thu, 13 Sep 2018 16:16:00 -0400 Received: from foss.arm.com ([217.140.101.70]:49852 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727760AbeIMUQA (ORCPT ); Thu, 13 Sep 2018 16:16:00 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BD95B7A9; Thu, 13 Sep 2018 08:06:05 -0700 (PDT) Received: from e107981-ln.cambridge.arm.com (e107981-ln.emea.arm.com [10.4.13.117]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 668143F557; Thu, 13 Sep 2018 08:06:04 -0700 (PDT) Date: Thu, 13 Sep 2018 16:05:54 +0100 From: Lorenzo Pieralisi To: Jisheng Zhang Cc: Jingoo Han , Joao Pinto , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3] PCI: dwc: fix scheduling while atomic issues Message-ID: <20180913150543.GA6199@e107981-ln.cambridge.arm.com> References: <20180829110408.556c3622@xhacker.debian> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180829110408.556c3622@xhacker.debian> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 29, 2018 at 11:04:08AM +0800, Jisheng Zhang wrote: > 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 > --- Applied to pci/controller-fixes aiming at one of the upcoming -rc*. Thanks, Lorenzo > 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 >