Received: by 10.223.164.202 with SMTP id h10csp3815598wrb; Mon, 20 Nov 2017 05:33:59 -0800 (PST) X-Google-Smtp-Source: AGs4zMa84vCzNwQ+lM/sP4Gv0hIdAKFRkz5k59RstsiJ29COATDxtxRtNx04lL4MXxWSSDqL2uQ/ X-Received: by 10.159.197.65 with SMTP id d1mr13930248plo.58.1511184839195; Mon, 20 Nov 2017 05:33:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511184839; cv=none; d=google.com; s=arc-20160816; b=MvwRCOtubx8ciC0cN4hHRTgjJugguoeoN4qltL+UVdJox2nfl+HBdJMsnq7EY0kps3 aIw9MgA9yPNY2WsrvFJ63J+zX2hC0DuaM2iCSTl+l88qTyUOLBfmV07zvYH+k0DtiWGo QSObNj/ZQhACW8I6g0QnufYZqnqblQVFOsV0Dw6pGHBRQcl709CR5e0OrbO15hjCQu4v k+DA8IzHfcdpTg9aaJ/W7thI28RrV72A6sqIEYlthjkxQvPUPjOYIytII9Qj5U1YDntv GagWKrlwGHEVE2wykDFeV9+lBUUBZMax73KtYrThdqBEGgIej/xdUEOH8AnQLFRwQQDB UJlA== 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=roNpOsQo80ison89ik9kFsQ8Zb82FFwZWYrnQXEcRRA=; b=I+Ul3SDbZLEzAU+0KDtuse2gzuRPl8vP7SSM3GZ8lDk2x9lM6PB/KKgldNvPsRD5OC k6krEM3qd0H9jwLhsUZs5iu+KBHKAL68NrP4fcgSxEjjWii2IwsvQ8a0ti1Kde7j/HRG r6OKBOxq4UyGPMLr/wIo0yhMkxo7QjGuc2U3ZKCGH5dRTDGjEkp5H8Lw1A5e5trZkwMy EDDG/DQW37OkzflBXTmZ2ZMBtHrvrPNJiO1OM5GOE2OEtL3gjDxwztsuhvCyWWEGjt2t hYPTV2sK7FUuWeMe4k99RuRPgNAP7xt1gOzVNTFlK1Gj2kTx39UO4KZIVsGSIWKfKlR9 YcQg== 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 a33si7732956pld.92.2017.11.20.05.33.48; Mon, 20 Nov 2017 05:33:59 -0800 (PST) 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 S1751311AbdKTNc7 (ORCPT + 66 others); Mon, 20 Nov 2017 08:32:59 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:39531 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751252AbdKTNc6 (ORCPT ); Mon, 20 Nov 2017 08:32:58 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id A2752183AC; Mon, 20 Nov 2017 14:32:56 +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 i2xfxxoweRek; Mon, 20 Nov 2017 14:32:55 +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 4ED8C180E6; Mon, 20 Nov 2017 14:32:55 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C80D1E07D; Mon, 20 Nov 2017 14:32:55 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 303ED1E07C; Mon, 20 Nov 2017 14:32:55 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder03.se.axis.com (Postfix) with ESMTP; Mon, 20 Nov 2017 14:32:55 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by thoth.se.axis.com (Postfix) with ESMTP id 233ED19AA; Mon, 20 Nov 2017 14:32:55 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 1F345400FE; Mon, 20 Nov 2017 14:32:55 +0100 (CET) From: Niklas Cassel To: Jingoo Han , Joao Pinto , Lorenzo Pieralisi , Bjorn Helgaas Cc: Niklas Cassel , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 04/18] PCI: designware-ep: Pre-allocate memory for MSI in dw_pcie_ep_init Date: Mon, 20 Nov 2017 14:32:07 +0100 Message-Id: <20171120133222.27771-5-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171120133222.27771-1-niklas.cassel@axis.com> References: <20171120133222.27771-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. Pre-allocate a page in dw_pcie_ep_init(), so that this page can later be used to map/unmap the MSI address in raise_irq. Signed-off-by: Niklas Cassel --- drivers/pci/dwc/pcie-designware-ep.c | 10 ++++++++++ drivers/pci/dwc/pcie-designware.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/drivers/pci/dwc/pcie-designware-ep.c b/drivers/pci/dwc/pcie-designware-ep.c index 3fb34be99715..8d8019cdff2a 100644 --- a/drivers/pci/dwc/pcie-designware-ep.c +++ b/drivers/pci/dwc/pcie-designware-ep.c @@ -286,6 +286,9 @@ 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, + epc->mem->page_size); + pci_epc_mem_exit(epc); } @@ -341,6 +344,13 @@ 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, + epc->mem->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 1584610782264526141@xxx Mon Nov 20 18:30:04 +0000 2017 X-GM-THRID: 1584610782264526141 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread