Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2224996imm; Thu, 18 Oct 2018 11:00:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV61sL5EOzr5+/xUpEYB0c0BzdjKK2EmVZYrDXRMofSgj4wPQCUDVm+aV71Ey9ACJtQJ/qD2h X-Received: by 2002:a62:460c:: with SMTP id t12-v6mr24563093pfa.206.1539885603130; Thu, 18 Oct 2018 11:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539885603; cv=none; d=google.com; s=arc-20160816; b=RfN4XJ71+lGPfaq6B8XYk5ohYgPON+hW5skV5N1S6biEBXibYjBQtgOusXprG8wib6 aCmjX05KiQ7N0dLOZXJ0r5z5EQq0/UYIyNYCGAjzpDPDU25aB8OusDzhq1nQ2VQVTQtn MJkqTWjzC1dm26XEJlZyWYPUfnPsC8j5A325WX5c7mUgS7Ibf0tRvw1atbOqsTnM0sHc OoB/Aeo6SrgGkYTZeuLDP5PXI1nha3dWP6XAx/9DHR6REaLtY2OzBflmhCBzebX01Gn5 JnUE5KrbJUZWgoA/jkZU3gV8mCkjEMkYyuKhtfozJ0AzfqBjll70rOjiep30DeCa6vg5 Aqmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oovfAGNaAWgqCj2aV4InnwTbM7TK8be7kQ+aVpVgu4Y=; b=KtZuswqshfT9NTAW5Qqy5qVTKOY99LzcC3qoooOdwkcm+2vq9qkn5sWDwZb7hcdcrx dgfoOyZfmiVUDJMAYo/233iTmsPuXAoRnUpN5Yr93WjbA/vwVvEKjw8XFaOfadAMpgoF sR1xpv49wQQVys7JVlM/E9aHsKq5HP638ckiNZorkYQSQKO+Ck75y7bqqngDEr2EzWFY DGL5xIf9uB3syhDFhUtHRXF5O1tQHmuDqbRoEUuoeTtPrGuqVIrTurybUXZzeFW6TIWX bP/cf1rPSX203NDpjBUzT5bwUhoZgQAFyVQ84rfmj4Jan2Nj/131eNkWrQmGTbE/NWqH froQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="qqPz/uaZ"; 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 q5-v6si20830916pgp.332.2018.10.18.10.59.47; Thu, 18 Oct 2018 11:00:03 -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="qqPz/uaZ"; 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 S1728893AbeJSB7o (ORCPT + 99 others); Thu, 18 Oct 2018 21:59:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:47394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728086AbeJSB7o (ORCPT ); Thu, 18 Oct 2018 21:59:44 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 68B9421473; Thu, 18 Oct 2018 17:57:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539885458; bh=OQJ8J3vVSK/s0fd1UP9WITZ3rFE16pcl54wcML7XJOs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qqPz/uaZzAB0DOuPwr7sXpkQSmTM6E+16UPqUr0I3jCb2mjaQvSjlhBkyUoN/NhTG O8Nn9GTfAowkv908u5NePLYbHTujzSaP3rJ4+9wFy4viPf6jmzjN7cTZpcruX0QzSI Gis/HwbQovYbFfY4xOjBYT2a1zKcDGHjYcCpYTs0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jisheng Zhang , Lorenzo Pieralisi , Bjorn Helgaas , Gustavo Pimentel , Sasha Levin Subject: [PATCH 4.18 30/53] PCI: dwc: Fix scheduling while atomic issues Date: Thu, 18 Oct 2018 19:54:23 +0200 Message-Id: <20181018175422.066166427@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018175416.561567978@linuxfoundation.org> References: <20181018175416.561567978@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/pci/controller/dwc/pcie-designware.c | 8 ++++---- drivers/pci/controller/dwc/pcie-designware.h | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) --- 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_un 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 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_unro 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_p 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"); --- 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