Received: by 10.223.164.221 with SMTP id h29csp2539622wrb; Mon, 30 Oct 2017 05:48:20 -0700 (PDT) X-Google-Smtp-Source: ABhQp+S0vwhG/Lg0sxbyXXx6BMgw0w2XbgphAeDzXB0AdcogVGQjjHgh1Qy5HHWaaxDenYXXe2e2 X-Received: by 10.98.57.220 with SMTP id u89mr8795524pfj.104.1509367700775; Mon, 30 Oct 2017 05:48:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509367700; cv=none; d=google.com; s=arc-20160816; b=hbRi7pUbSXpytbdXeQ6WSj0ZOoOHWWlz0NEWVV6azQtaHQzNtNzeHGbEkBRWE6ZX6Q b5sVe3Hv73+Uuh1dfBHm3yKB9RO+2MWpmaLNkwYensDHYVgmANBTZ8PsXfNtN3V23x3K Hs0MF76XNPOP1KgUIRXPRX2CeJZ216HFjXlFD0nhh2eMow4h0K9ZtiSHRahN1JkhTiMV gk/eNhoHnjkiO+BNRIN23yKzV2AcLqaWDmsMJlkjaHKhRP9a+RzKRc9Nd5q/p6yv+4bq TvAO01tBUCqtao3qXCrJW5SJTqVxpcDvShr0JRh7VqLaeK+NL3bdl39Z/Eahu9TH3oah ISBw== 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:arc-authentication-results; bh=6rX3SmYKaosgSCPRjuHBRclx3Ub+mEVAmcJUwEsPGU0=; b=ajAeokNXtnT5AuFcwQr1QmmpmEm7oqD3Ot9DQWnf+eh5Nio15nV2/Xn2WmcY9trHjD i8yh84ZeLml3Rr/k00BiTi9GJlTWufuOuCJGV6DiGnlkmiiqyDdgNn/fOyXLc0hKh8cd Omzx9xbZgBAs8Q/qdiXzni3c1PkQPqpAq76bAH7X6re0842mojZh4r+pEiXBCebF0pPy IgqLtVE9D1PHqW2BgXg5UlK9sH2LoClIaUucMAqmE96rb6r46P5CJid78ytUT0n68x+E sWUse+spxHOS+qcjgLu/r3GBD2YIcA81XSgnwGq3ibNaslWGMTD50cXWQWQKk3Azwr5I +7WA== 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 m6si10832801pff.595.2017.10.30.05.48.07; Mon, 30 Oct 2017 05:48:20 -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 S1751895AbdJ3Mmt (ORCPT + 99 others); Mon, 30 Oct 2017 08:42:49 -0400 Received: from bastet.se.axis.com ([195.60.68.11]:42958 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751772AbdJ3Mmq (ORCPT ); Mon, 30 Oct 2017 08:42:46 -0400 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 01AD3185AE; Mon, 30 Oct 2017 13:42:45 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id IjcFu9PLYmbs; Mon, 30 Oct 2017 13:42:44 +0100 (CET) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bastet.se.axis.com (Postfix) with ESMTPS id 62BD3185A4; Mon, 30 Oct 2017 13:42:44 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4667B1E066; Mon, 30 Oct 2017 13:42:44 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3A7A51E060; Mon, 30 Oct 2017 13:42:44 +0100 (CET) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder03.se.axis.com (Postfix) with ESMTP; Mon, 30 Oct 2017 13:42:44 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by seth.se.axis.com (Postfix) with ESMTP id 2D7A422B4; Mon, 30 Oct 2017 13:42:44 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 29BD840101; Mon, 30 Oct 2017 13:42:44 +0100 (CET) From: Niklas Cassel To: Jingoo Han , Joao Pinto , Bjorn Helgaas Cc: Niklas Cassel , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 04/17] PCI: designware-ep: Pre-allocate memory for MSI in dw_pcie_ep_init Date: Mon, 30 Oct 2017 13:42:07 +0100 Message-Id: <20171030124221.20690-5-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171030124221.20690-1-niklas.cassel@axis.com> References: <20171030124221.20690-1-niklas.cassel@axis.com> X-TM-AS-GCONF: 00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Certain SoCs need to map the MSI address in raise_irq. To map an address, you first need to call pci_epc_mem_alloc_addr, however, pci_epc_mem_alloc_addr calls ioremap (which can sleep). Since raise_irq is only called from atomic context, we can't call pci_epc_mem_alloc_addr from raise_irq, instead we pre-allocate a page in dw_pcie_ep_init, so this page can later be used to map/unmap the MSI address in raise_irq. Signed-off-by: Niklas Cassel --- V2: * No change. drivers/pci/dwc/pcie-designware-ep.c | 8 ++++++++ drivers/pci/dwc/pcie-designware.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/pci/dwc/pcie-designware-ep.c b/drivers/pci/dwc/pcie-designware-ep.c index 3fb34be99715..c291da2a10ba 100644 --- a/drivers/pci/dwc/pcie-designware-ep.c +++ b/drivers/pci/dwc/pcie-designware-ep.c @@ -286,6 +286,8 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep) { struct pci_epc *epc = ep->epc; + pci_epc_mem_free_addr(epc, ep->msi_mem_phys, ep->msi_mem, PAGE_SIZE); + pci_epc_mem_exit(epc); } @@ -341,6 +343,12 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) return ret; } + ep->msi_mem = pci_epc_mem_alloc_addr(epc, &ep->msi_mem_phys, PAGE_SIZE); + if (!ep->msi_mem) { + dev_err(dev, "Failed to reserve memory for MSI\n"); + return -ENOMEM; + } + ep->epc = epc; epc_set_drvdata(epc, ep); dw_pcie_setup(pci); diff --git a/drivers/pci/dwc/pcie-designware.h b/drivers/pci/dwc/pcie-designware.h index 9aaf0cd04dd6..5a1da459eda5 100644 --- a/drivers/pci/dwc/pcie-designware.h +++ b/drivers/pci/dwc/pcie-designware.h @@ -198,6 +198,8 @@ struct dw_pcie_ep { unsigned long ob_window_map; u32 num_ib_windows; u32 num_ob_windows; + void __iomem *msi_mem; + phys_addr_t msi_mem_phys; }; struct dw_pcie_ops { -- 2.14.2 From 1584224533391673986@xxx Thu Nov 16 12:10:48 +0000 2017 X-GM-THRID: 1584224533391673986 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread