Received: by 10.223.164.221 with SMTP id h29csp139813wrb; Fri, 3 Nov 2017 06:53:02 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TBj3DzDVwVbnVKX4UXf8HSEk1RKkQAxmQy1c6PgJKiwLO8m2kIQZQ41GEjuhBTXP5INPmp X-Received: by 10.99.98.197 with SMTP id w188mr7189657pgb.41.1509717182192; Fri, 03 Nov 2017 06:53:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509717182; cv=none; d=google.com; s=arc-20160816; b=SSeX2yUY89kSfF/AHm6rX0KCjts1n5ak1UoRwcfHawHAsolnu3JeONqt5xhGnpaTYl YrVViiUuQq5Dtn/1GDPsuSHDPmr0OoCeu25cW33TsijZ/Sxpaz0I0hD3C4iJrsqeqowy Y76EN5m2bEwkfsOGbAspjqqKMa5gCMohK+O+Ht48YoDYkaZHRdlG5MfUp3LRn9IGbw+n 2nADKATgOr3UBVZiLLXpUdNEUyiBd1kOA9OdVjFWqaYRkyAFb0Ze2MJFq5+preGAmQuL hdtTEx2N/5wyZhM7w6YetINhVzZqXOATnl4R9TuKwqy8NT3h87DwnYR5m6qjen7VfwsE A32A== 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=M9TLjkQGHSTF+2ne/fKkG7ljZaln7mWhEqxwDpOj8J8=; b=M8TSyniKpV3WcaVCG3SC2vd7JXdW+59bXoiz9vVVpJDSa9UyHuQ3I1K3BZCU+UVkGK qVrJcOAGqzWzo9O5ZWyVzbMrNIDz37JZIi+addHhi0i2dmsosWeJMMktOpeWawbN7Cub W/WUINc4KVyHAFTkwhbVYvP9RpgDmFp+Yx+qo/RJRJXpSqijd0NRNP27Vb1jGcHi738f hhkGafMvWA+8dIl5reYZ+jp7MIPVRdMZ90dTj0ZlYZfI1AL7nG+x9MfVMA6NWQQC90TG GhZFABqBRHVxrCGfFz/aToeuJ63VlK+wUOFsNwE1xOePyraekfQ+imh2lC7GpcyB3H0U 15hw== 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 r6si4380116pls.575.2017.11.03.06.52.49; Fri, 03 Nov 2017 06:53:02 -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 S1756530AbdKCNvr (ORCPT + 95 others); Fri, 3 Nov 2017 09:51:47 -0400 Received: from bastet.se.axis.com ([195.60.68.11]:51534 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756356AbdKCNry (ORCPT ); Fri, 3 Nov 2017 09:47:54 -0400 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 7CF9718945; Fri, 3 Nov 2017 14:47:53 +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 rfg1nh772nIO; Fri, 3 Nov 2017 14:47:51 +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 0338618920; Fri, 3 Nov 2017 14:47:51 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E24841E07B; Fri, 3 Nov 2017 14:47:50 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D6F7A1E078; Fri, 3 Nov 2017 14:47:50 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder03.se.axis.com (Postfix) with ESMTP; Fri, 3 Nov 2017 14:47:50 +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 CAC9C2662; Fri, 3 Nov 2017 14:47:50 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id C700740101; Fri, 3 Nov 2017 14:47:50 +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 v4 04/17] PCI: designware-ep: Pre-allocate memory for MSI in dw_pcie_ep_init Date: Fri, 3 Nov 2017 14:47:08 +0100 Message-Id: <20171103134722.5532-5-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171103134722.5532-1-niklas.cassel@axis.com> References: <20171103134722.5532-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..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 1583053140331803167@xxx Fri Nov 03 13:52:01 +0000 2017 X-GM-THRID: 1583053140331803167 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread