Received: by 10.223.164.221 with SMTP id h29csp146019wrb; Tue, 31 Oct 2017 15:47:22 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TMas6kDDE6sS+05QbYZx7QULjiNyHoVwJ4vQcA6xYCvFMbo9yRYlDeUEt/EQ22xoeb7OVJ X-Received: by 10.101.80.3 with SMTP id f3mr3492425pgo.109.1509490042643; Tue, 31 Oct 2017 15:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509490042; cv=none; d=google.com; s=arc-20160816; b=MvqOtME2xXXUWfjLgJeKO+oRsuAbNJhgCSxmbuWgxa2myUH8IV34WF8wUVcEdgBNhs YpGiPE+RZlFZ4ftGeXqSh+6kgO92+8cHz/q7Tbp4gG+r8Mby0hGLPRCaZ1U0R+L7LQnO A3EgxcGydCqbPc3lxDfzd+YWzUjKcuPYBtMtWTdD5kH3KEkX/1d45yV0gDd6wBoqm1mV a9OIESrfAqTquPTY1R9e3v53h5Je8z8ABRAeR7t6vrSgyyELZmNdzUSdZ7KCjNfY4y8m 7u8uDifsgbEyGUDFzXNHpM3oo9N1oxqb09uHOAbjCYnXQhAfwex1NwwJn4AwlTBYg4Jm jgFA== 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=Pqd4Mx6LdwuEbJy63n80MIIFr88GZyzGAV/kR6eoXns=; b=NlYGIOiYggOazA+7TnZHe+7gFiHlhO9K5YtP79slcs/3VnpbEODjGnPydLdoO9c9fb n2Yz5y70pS3J/sOM5nU+nTweyeHPAoe5ebRDDgkZEHaCHljkt4yokMoPdzI9htyH3rhg sKGOfVlFqWqQDl1vuN90svfpGNew43bkgtvSXCIXAKX4ODuq44SzXQxe8Uz6GAidls64 06lHpMRf7CD/Xsv64LP3UE3bja9chIPAiAFkBDjwJlizTvb4IkfaOfzVcjUXvfLNPLZe PEs6Fyy1oQsOamO2CdLWq93oejCy+A1gQBD4LFj1bbtqmIDqQc4oam/3qeKkkCuqiN/x KS+g== 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 s14si2820699pfa.333.2017.10.31.15.47.08; Tue, 31 Oct 2017 15:47:22 -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 S1753815AbdJaWqL (ORCPT + 99 others); Tue, 31 Oct 2017 18:46:11 -0400 Received: from bastet.se.axis.com ([195.60.68.11]:52269 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753931AbdJaWj5 (ORCPT ); Tue, 31 Oct 2017 18:39:57 -0400 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 58BEC186F3; Tue, 31 Oct 2017 23:39: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 M01YB4acB2GK; Tue, 31 Oct 2017 23:39:53 +0100 (CET) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bastet.se.axis.com (Postfix) with ESMTPS id C58891842D; Tue, 31 Oct 2017 23:39:53 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B399C1A09A; Tue, 31 Oct 2017 23:39:53 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A83301A091; Tue, 31 Oct 2017 23:39:53 +0100 (CET) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder02.se.axis.com (Postfix) with ESMTP; Tue, 31 Oct 2017 23:39:53 +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 9BB9F2331; Tue, 31 Oct 2017 23:39:53 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 97B5040101; Tue, 31 Oct 2017 23:39:53 +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 v3 04/17] PCI: designware-ep: Pre-allocate memory for MSI in dw_pcie_ep_init Date: Tue, 31 Oct 2017 23:39:22 +0100 Message-Id: <20171031223936.27549-5-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171031223936.27549-1-niklas.cassel@axis.com> References: <20171031223936.27549-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 --- V3: * Use ep->page_size rather than PAGE_SIZE. 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..2684090b782b 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, + ep->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, + ep->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 1582808223266901455@xxx Tue Oct 31 20:59:10 +0000 2017 X-GM-THRID: 1582686746258533661 X-Gmail-Labels: Inbox,Category Forums