Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3728881imm; Mon, 8 Oct 2018 08:36:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV61vG5oZyt0Nvaa2WBx04XyLoWB0MzerN9v7tYoFSG21EldYgSLgNWmbPeu2PMcLO8v24tfO X-Received: by 2002:aa7:8305:: with SMTP id t5-v6mr25452193pfm.81.1539012989047; Mon, 08 Oct 2018 08:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539012989; cv=none; d=google.com; s=arc-20160816; b=GBqm/XfQ061t31wYMwE+i4pdkPJdInqCdwNISu3BtgQVnxrnrZT2UAJvNfZ/6A3okW QrYrZHHlYZU8ekg5EvqSGhIbVfsooxncu4mEu+1NWG3wZkqrRCBRGP2bj4EyC1HRT0l2 PxLs19sWacbL5fg+rEkAMz9Ah8B5lJ+taGvW/vUElQybLBZJojppCkB4pe9RTxPzwNQy K36htBqoNQfPuoFig/iJME3SZUMfG0m59tyuxM2zO2vElk33S/+pXmnrwiMXdIxXgpW9 s81w5iEn/O9XFnYcMF4ghqyki+DOw2NgLWN5P4jtHLLm13p3AhoMsNN5gRpvdzeF1CdG ibQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=7qeh1/97oJiHlbAGISlAA4gN3K4bBHchQDFUfhJqXLw=; b=tkJlwMIos5dLH3RIjNC8ftoEgi0fZZlh9DbY9kB6tprkqSaUHntEbyI5nbEOnQ77pa QsSDmHHvlMMh1uuZMNb4k/p4eCA1bdl4luB5sv/jncSjmezVmYw23sWAcqImDwBOLzjw AtckaQYZyooonOfZu2izAJDwUdyd42qqHC1QDWNbArtHWMBV738yuuDbU3SgQ9EoXReA l8uLguL/RhwXRl1hIZHqxpaMzN3j+flZd9HBCvFrMj06YZP7wngVxe6zf10lVygxsewp zwnN8ozL5PDl29FVDuusT7Gd2WAHuSjktI5fzzn1nrWA7gLW5qOLWzbfZsg23mXz2SD0 OWbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hcdCIzFs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o24-v6si14048925pgv.242.2018.10.08.08.36.14; Mon, 08 Oct 2018 08:36:29 -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=@kernel.org header.s=default header.b=hcdCIzFs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728126AbeJHWsK (ORCPT + 99 others); Mon, 8 Oct 2018 18:48:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:56698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726441AbeJHWiR (ORCPT ); Mon, 8 Oct 2018 18:38:17 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BDCBF2075E; Mon, 8 Oct 2018 15:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539012362; bh=Af4eNb0epPJ8qDTYgjFPsgb0MSgMaQDHVrpRQG/Fhyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hcdCIzFszoCJCO6DbUfYqmOYPlo7u/wer4J4Sm00oqZqnmeo+p1r2CaSN5VRMAZx0 SyjcMAnUZQN5WjiYmYGjZO8eGAzFMuVzkkpCNi4/7Am7ZNfuhEr4BJittznxAiswIZ LcddwxXDNafBiesQKyJh7KfvlVpMeGbgvwKuKVbo= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jisheng Zhang , Lorenzo Pieralisi , Bjorn Helgaas , Sasha Levin Subject: [PATCH AUTOSEL 4.18 37/58] PCI: dwc: Fix scheduling while atomic issues Date: Mon, 8 Oct 2018 11:25:02 -0400 Message-Id: <20181008152523.70705-37-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181008152523.70705-1-sashal@kernel.org> References: <20181008152523.70705-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jisheng Zhang [ Upstream commit 9024143e700f89d74b8cdaf316a3499d74fc56fe ] When programming the inbound/outbound ATUs, we call usleep_range() after each checking PCIE_ATU_ENABLE bit. Unfortunately, the ATU programming can be executed 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 [lorenzo.pieralisi@arm.com: commit log update] Signed-off-by: Lorenzo Pieralisi Signed-off-by: Bjorn Helgaas Acked-by: Gustavo Pimentel Signed-off-by: Sasha Levin --- 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 bee4e2535a61..b99d1d72dd12 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.17.1