Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp384503ybb; Wed, 1 Apr 2020 01:49:31 -0700 (PDT) X-Google-Smtp-Source: APiQypLQwVVM7pha1u2FDRiZUwyipUDCU5qYwbeqULgAE+CtpIYLVcsR5gB3jaIHfE8UeyKJbtyr X-Received: by 2002:aca:646:: with SMTP id 67mr1950608oig.4.1585730971268; Wed, 01 Apr 2020 01:49:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585730971; cv=none; d=google.com; s=arc-20160816; b=epKPxBXRZzqWrgYRL9AfRXMTG0NEF2um/5RHqh9EN8fFHYgmjbOalMZx97Kuwvp29X jzfXMULf3LIs/OoJ1lk6iiqX3kT7HRhU/GgKa9l9AKyFjQF6AeRfeSLzzXbz1iZ42cIo QBDFcUWRisv+wRC/NIk7uSpsSkzzYQgwlmhHGqJh7y6Z4f5xG9z9lObhb4A9yhRR4Mqt Wrq6MzjqBxgRxcfHtWz64vy0jkO+vZ/kfttCSXy00a/Jl42/o+ixHgqP48uLGr8N2r8R y8MupIRSQPOFUiT0W5FmA3eA2acV6B2s672C9xbbv/ylmapTLtQnBmjHdvlA1ITvV7CF oZkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=NFnQtMAv52vc67tP5TFOUo3bRsY9ihV28ROS9W2huxg=; b=CjKpSA6ZYzVmMjrwt5CGiEUZjumx4fSvvMsYZLBkEmu7kX+wAT26OIsz7Hyvz31HWY J1MfCEwBFOizWYcjAr1znQUTczAXKjjpe6lMVanj/2wJolP6dRQffTaIhPL6DxvX1VBc mdd5AubEYPELgTHR5r0owa9ltkcEMAHnBtslF2s0izh/kkbDou2VE513OXOZusCI4KLC HzWkqRNONCLL9A7hQ1PhdcH0cVLgFi5bgX+bODgp5f2kwugahCRAlK0lvqj4FlUbyMSM 8znEByLUXYKLXYjfKYel/VbBjG4lDJe7tp2GgOM9KjU2QSbPWP5Yz848uIdaRQVlAApU TxBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=UGfBm0OG; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g81si698931oia.8.2020.04.01.01.49.19; Wed, 01 Apr 2020 01:49:31 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=UGfBm0OG; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732004AbgDAIsr (ORCPT + 99 others); Wed, 1 Apr 2020 04:48:47 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:43734 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726536AbgDAIsr (ORCPT ); Wed, 1 Apr 2020 04:48:47 -0400 Received: by mail-ed1-f65.google.com with SMTP id bd14so28632880edb.10 for ; Wed, 01 Apr 2020 01:48:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NFnQtMAv52vc67tP5TFOUo3bRsY9ihV28ROS9W2huxg=; b=UGfBm0OG6dm/aY2vbCbLWqdatsFbxQNSssJ6VGYhMiDq/OZ3CcwFMRXjdJP0AXYK7D qh0ra8EMgQmGzX4Fxxcv2zpRpA6bvmpNcGy3vpPXv3wvgBL5g1kIy0ijObNxfTpeqLe8 zJQlvRgzdUnUwCw9a3vVQyhTkhOj1bGwFPHvgJUavxqHY6EN1biqXsQJEuRb2ZAx1+la bIBqqpPryQe7pXTndun8sNc9rg9fyRYz2RGUeOFAXiGwD9NEgCHUS1mhusff7WG/rzRe rFzKfqWGnLyr5HwxUXqFoo2mpn0Y5mBOQNJqTToIbYTuOKzCLXGk0bf6ytMk5SVA0IRX r6Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NFnQtMAv52vc67tP5TFOUo3bRsY9ihV28ROS9W2huxg=; b=cvBlApepoCjD/NNQHsdH/2+5FwWcqLzNRRS1N7Tvf4F4LRLoLZGwLbZvK9GruxxsYV 24NPwz9n9z9eUTQ+pCN1YkywZkB77e7K1ud7n1055iyOlDoPE+KKuEiPLvZpQC6r5DTG wZ+JWd/97dJ/32wk/Rrwb3VxfvL2Yb/judfGxnKQ8ysW4FneSIhIDBHjWTM3JfnmtDNk cMk8+bYY5N/tkNXm19uEYlfXFl3sGAjrA6Z6IlDgnsEEv7dEtbGQ7STDQvXU4OftO6e7 P2Sy3UyhZgO/ND33471Fve2RIfLHsjvTFM8HL9HacubkxtdzJ3Tbb7J7asmPrPaAutgh CdBQ== X-Gm-Message-State: ANhLgQ1UViaBQjx5fdVBNbwrTwyCySNgZgL1Q1LGad91dh2cBScuOclE V263V2VxgolMAmyYcbSMFa2RZP/pGzvhN4gqcRZX5Q== X-Received: by 2002:a50:d847:: with SMTP id v7mr19478119edj.154.1585730924056; Wed, 01 Apr 2020 01:48:44 -0700 (PDT) MIME-Version: 1.0 References: <20200327071202.2159885-1-alastair@d-silva.org> <20200327071202.2159885-4-alastair@d-silva.org> In-Reply-To: <20200327071202.2159885-4-alastair@d-silva.org> From: Dan Williams Date: Wed, 1 Apr 2020 01:48:32 -0700 Message-ID: Subject: Re: [PATCH v4 03/25] powerpc/powernv: Map & release OpenCAPI LPC memory To: "Alastair D'Silva" Cc: "Aneesh Kumar K . V" , "Oliver O'Halloran" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Frederic Barrat , Andrew Donnellan , Arnd Bergmann , Greg Kroah-Hartman , Vishal Verma , Dave Jiang , Ira Weiny , Andrew Morton , Mauro Carvalho Chehab , "David S. Miller" , Rob Herring , Anton Blanchard , Krzysztof Kozlowski , Mahesh Salgaonkar , Madhavan Srinivasan , =?UTF-8?Q?C=C3=A9dric_Le_Goater?= , Anju T Sudhakar , Hari Bathini , Thomas Gleixner , Greg Kurz , Nicholas Piggin , Masahiro Yamada , Alexey Kardashevskiy , Linux Kernel Mailing List , linuxppc-dev , linux-nvdimm , Linux MM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 29, 2020 at 10:23 PM Alastair D'Silva wrote: > > This patch adds OPAL calls to powernv so that the OpenCAPI > driver can map & release LPC (Lowest Point of Coherency) memory. > > Signed-off-by: Alastair D'Silva > Reviewed-by: Andrew Donnellan > --- > arch/powerpc/include/asm/pnv-ocxl.h | 2 ++ > arch/powerpc/platforms/powernv/ocxl.c | 43 +++++++++++++++++++++++++++ > 2 files changed, 45 insertions(+) > > diff --git a/arch/powerpc/include/asm/pnv-ocxl.h b/arch/powerpc/include/asm/pnv-ocxl.h > index 7de82647e761..560a19bb71b7 100644 > --- a/arch/powerpc/include/asm/pnv-ocxl.h > +++ b/arch/powerpc/include/asm/pnv-ocxl.h > @@ -32,5 +32,7 @@ extern int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle) > > extern int pnv_ocxl_alloc_xive_irq(u32 *irq, u64 *trigger_addr); > extern void pnv_ocxl_free_xive_irq(u32 irq); > +u64 pnv_ocxl_platform_lpc_setup(struct pci_dev *pdev, u64 size); > +void pnv_ocxl_platform_lpc_release(struct pci_dev *pdev); > > #endif /* _ASM_PNV_OCXL_H */ > diff --git a/arch/powerpc/platforms/powernv/ocxl.c b/arch/powerpc/platforms/powernv/ocxl.c > index 8c65aacda9c8..f13119a7c026 100644 > --- a/arch/powerpc/platforms/powernv/ocxl.c > +++ b/arch/powerpc/platforms/powernv/ocxl.c > @@ -475,6 +475,49 @@ void pnv_ocxl_spa_release(void *platform_data) > } > EXPORT_SYMBOL_GPL(pnv_ocxl_spa_release); > > +u64 pnv_ocxl_platform_lpc_setup(struct pci_dev *pdev, u64 size) > +{ > + struct pci_controller *hose = pci_bus_to_host(pdev->bus); > + struct pnv_phb *phb = hose->private_data; Is calling the local variable 'hose' instead of 'host' on purpose? > + u32 bdfn = pci_dev_id(pdev); > + __be64 base_addr_be64; > + u64 base_addr; > + int rc; > + > + rc = opal_npu_mem_alloc(phb->opal_id, bdfn, size, &base_addr_be64); > + if (rc) { > + dev_warn(&pdev->dev, > + "OPAL could not allocate LPC memory, rc=%d\n", rc); > + return 0; > + } > + > + base_addr = be64_to_cpu(base_addr_be64); > + > +#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE With the proposed cleanup in patch2 the ifdef can be elided here. > + rc = check_hotplug_memory_addressable(base_addr >> PAGE_SHIFT, > + size >> PAGE_SHIFT); > + if (rc) > + return 0; Is this an error worth logging if someone is wondering why their device is not showing up? > +#endif > + > + return base_addr; > +} > +EXPORT_SYMBOL_GPL(pnv_ocxl_platform_lpc_setup); > + > +void pnv_ocxl_platform_lpc_release(struct pci_dev *pdev) > +{ > + struct pci_controller *hose = pci_bus_to_host(pdev->bus); > + struct pnv_phb *phb = hose->private_data; > + u32 bdfn = pci_dev_id(pdev); > + int rc; > + > + rc = opal_npu_mem_release(phb->opal_id, bdfn); > + if (rc) > + dev_warn(&pdev->dev, > + "OPAL reported rc=%d when releasing LPC memory\n", rc); > +} > +EXPORT_SYMBOL_GPL(pnv_ocxl_platform_lpc_release); > + > int pnv_ocxl_spa_remove_pe_from_cache(void *platform_data, int pe_handle) > { > struct spa_data *data = (struct spa_data *) platform_data; > -- > 2.24.1 >