Received: by 10.223.164.202 with SMTP id h10csp2128686wrb; Thu, 16 Nov 2017 09:48:25 -0800 (PST) X-Google-Smtp-Source: AGs4zMYT7eHtiDhMWCFTH7tSH1cT6qXsP6phbSkACqz6TGqryhqVF4nos2V1X6QawQ0bveb3Bkdc X-Received: by 10.84.217.2 with SMTP id o2mr2020386pli.338.1510854505048; Thu, 16 Nov 2017 09:48:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510854505; cv=none; d=google.com; s=arc-20160816; b=ivXsj42Q3l0+T5i7swiN/ZnBOVEsGu4Ncu2+kuqUK74u9F8bKr3ngXllJUEte8bhLR q3sxAHzQzAteDd1jMEcNHhs8CsJZSzbpzwHeolhnt+QV1a4IzZSz8eRCQrun5IxMD6wY yTHCW5Jz4vVtLuO+EzWUsio7UpMcyZ21tSt5R3x0oXcX35s2ocgHzTT6CVUmeSMxQY95 iyxb2lRENEqns6qk6zU/N3RCbnQVkqeOIEdcm+C9RKwiiHi9IjPAPWB3roZEJqlo28ET slJ+iIn92Np3wk5iNtqbBML5UJxtsaheqBSnGbSYN9unHa8V6lMrOWf5Kujxi4VuUh1d +Q+g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Gi5ZXfHYknmfaY/tVWw8idOlgz8UwzBYNHih7YfRSMY=; b=oGC/a3FWQtD+o727fwo4MSbpCTDoXoyx16LzwdK2CAJqpqYPPMIe6euEvm2PwKpsRR YwMY7BdWCCtjfEK6w2ew1rGfsx+zwknAXkOfXFdm4fbk7mvuuc0GfzVI3ri+M0DAjbv6 A1Kj2Iw30ZW5KuIF86Q81WuEVw+13g59tEX2Qk6klcmLBP0RGj241EUSSK6WTBBFK4H3 LUyyvxhHRz8oawzfu3lCZ1d6JuLUqP/Bi7bTlqpn9mOpqbZlnEw0PPcJhlhK9oQbEQYe xjxLkZ61w5Ws+djDahp5N95rcH6Y9DgnSVs+FODNKOjnOLiO3mFDNgbapkrl8D0+vkZj z16A== 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 1si1219071plz.113.2017.11.16.09.48.12; Thu, 16 Nov 2017 09:48:25 -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 S936137AbdKPRRK (ORCPT + 92 others); Thu, 16 Nov 2017 12:17:10 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:53411 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935764AbdKPRQ4 (ORCPT ); Thu, 16 Nov 2017 12:16:56 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 101761813E; Thu, 16 Nov 2017 18:16:55 +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 5B4OoTw7zcS9; Thu, 16 Nov 2017 18:16:53 +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 B6259185AA; Thu, 16 Nov 2017 18:16:52 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3F56F1E080; Thu, 16 Nov 2017 18:16:52 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 32B811E07E; Thu, 16 Nov 2017 18:16:52 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder03.se.axis.com (Postfix) with ESMTP; Thu, 16 Nov 2017 18:16:52 +0100 (CET) Received: from XBOX02.axis.com (xbox02.axis.com [10.0.5.16]) by thoth.se.axis.com (Postfix) with ESMTP id 25D27F91; Thu, 16 Nov 2017 18:16:52 +0100 (CET) Received: from [10.88.4.10] (10.0.5.60) by XBOX02.axis.com (10.0.5.16) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Thu, 16 Nov 2017 18:16:51 +0100 Subject: Re: [PATCH v2 04/17] PCI: designware-ep: Pre-allocate memory for MSI in dw_pcie_ep_init To: Kishon Vijay Abraham I , Jingoo Han , Joao Pinto , Bjorn Helgaas CC: , References: <20171030124221.20690-1-niklas.cassel@axis.com> <20171030124221.20690-5-niklas.cassel@axis.com> <9d4c17b7-94ec-fd79-4bd8-8165019f04ce@ti.com> From: Niklas Cassel Message-ID: <123dbd8d-6943-f282-cad5-23841a925212@axis.com> Date: Thu, 16 Nov 2017 18:16:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <9d4c17b7-94ec-fd79-4bd8-8165019f04ce@ti.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.0.5.60] X-ClientProxiedBy: XBOX03.axis.com (10.0.5.17) To XBOX02.axis.com (10.0.5.16) X-TM-AS-GCONF: 00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/31/2017 07:01 AM, Kishon Vijay Abraham I wrote: > Hi Niklas, > > On Monday 30 October 2017 06:12 PM, Niklas Cassel wrote: >> 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); > > ep->page_size instead of PAGE_SIZE? > It was a really good call of Bjorn not to stress this series, since I apparently did not properly test this... I'm sorry, it will not happen again. ep->page_size is by default set to 0. __pci_epc_mem_init basically does this: if ep->page_size < PAGE_SIZE: epc->mem->page_size = PAGE_SIZE else epc->mem->page_size = ep->page_size So __pci_epc_mem_init is safe to call with ep->page_size 0, however, the same thing is not true for pci_epc_mem_alloc_addr. I will need to do a v5 of this patch series. Kishon, what do you think about doing this instead? +++ b/drivers/pci/dwc/pcie-designware-ep.c @@ -321,7 +321,7 @@ 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); + epc->mem->page_size); pci_epc_mem_exit(epc); } @@ -379,7 +379,7 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) } ep->msi_mem = pci_epc_mem_alloc_addr(epc, &ep->msi_mem_phys, - ep->page_size); + epc->mem->page_size); if (!ep->msi_mem) { dev_err(dev, "Failed to reserve memory for MSI\n"); return -ENOMEM; Regards, Niklas From 1582815031198406785@xxx Tue Oct 31 22:47:22 +0000 2017 X-GM-THRID: 1582686746258533661 X-Gmail-Labels: Inbox,Category Forums