From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6655FC43331 for ; Fri, 3 Apr 2020 03:52:45 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 731052077D for ; Fri, 3 Apr 2020 03:52:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (4096-bit key) header.d=d-silva.org header.i=@d-silva.org header.b="SmXkdqxM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 731052077D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=d-silva.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48tmGw5zLmzDrKj for ; Fri, 3 Apr 2020 14:52:40 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=d-silva.org (client-ip=66.55.73.32; helo=ushosting.nmnhosting.com; envelope-from=alastair@d-silva.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=d-silva.org Authentication-Results: lists.ozlabs.org; dkim=pass (4096-bit key; unprotected) header.d=d-silva.org header.i=@d-silva.org header.a=rsa-sha256 header.s=201810a header.b=SmXkdqxM; dkim-atps=neutral Received: from ushosting.nmnhosting.com (ushosting.nmnhosting.com [66.55.73.32]) by lists.ozlabs.org (Postfix) with ESMTP id 48tmDw4mh1zDrF1 for ; Fri, 3 Apr 2020 14:50:54 +1100 (AEDT) Received: from mail2.nmnhosting.com (unknown [202.169.106.97]) by ushosting.nmnhosting.com (Postfix) with ESMTPS id 20A782DC3D2F; Fri, 3 Apr 2020 14:50:51 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=d-silva.org; s=201810a; t=1585885852; bh=q0MWnVXh2aGk7v7ivIwQdA2GkasasysLWo22AkPKzug=; h=From:To:Cc:References:In-Reply-To:Subject:Date:From; b=SmXkdqxMWlBa5BfHDElmGi2xtWIwhlyZC+XnoaUyPT5aE6boLWD/AQN/Ujgix+fN4 lt4B5wlyflX5LxbuaPBd1/I+r9LZcxTBoOIJNrsPr7cwQ3rF8gAIphr9HUyU+/njBu hoDUPWUmDhnMr2IDYjVrcWf8DJx+zthb6UW/Ew6sB5BFaYRlbN8ZP22iJ5//EwDrEq dD4ehflXTk9vxREms73gx7K8mPfP1KwZYMl53l3NYL4Xwx/xE/mxenCpwKDjuyfzy5 PICZfF6bNcnScT6yJ1xqOYXDXaGhd9kSOB33hti6KhvnMClTAq2WANlpPBZVVSIvcL 8s0um1BD8fZCugtMXGq1JJtYm9lY4Vdx0/S22VpY28H9zFPcBf8ek6CH7t+BVz3vQX 1Kbfx9wB695SdNby60eBt8a4f23Yn9HWKUD+g3geM6UqmJSLXlha16GKuUlNpgR97c xNrt0sa9YC5YmQ+gienhkCLZV959msXZmwlkGv3KDF1SaRC8vCPEV4+E1xsA7FncHc xG5nT1bBI8S5029N239hJ5/GvRTWmSG6LD9okWBr23r7lr94UNfv5fYS6mHbrTb0J6 Q5sMgtZJxUzfbhwpv97hSzGRHHpOZU2lNlpmnojVWlsVdZ4cyc46gSWYOgf6FF5YiT KvA+UO/Nh6edhA/eclMg0h9A= Received: from Hawking (ntp.lan [10.0.1.1]) (authenticated bits=0) by mail2.nmnhosting.com (8.15.2/8.15.2) with ESMTPSA id 0333obha097274 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Apr 2020 14:50:39 +1100 (AEDT) (envelope-from alastair@d-silva.org) From: "Alastair D'Silva" To: "'Dan Williams'" References: <20200327071202.2159885-1-alastair@d-silva.org> <20200327071202.2159885-8-alastair@d-silva.org> In-Reply-To: Subject: RE: [PATCH v4 07/25] ocxl: Add functions to map/unmap LPC memory Date: Fri, 3 Apr 2020 14:50:36 +1100 Message-ID: <303a01d6096b$0ea3e120$2beba360$@d-silva.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Content-Language: en-au Thread-Index: AQJ5L4Hn/mp5p0p1jYAFWLJ+xmWSbgDVHtBXAp4PBwGnBNz6cA== X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (mail2.nmnhosting.com [10.0.1.20]); Fri, 03 Apr 2020 14:50:47 +1100 (AEDT) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 'Madhavan Srinivasan' , 'Alexey Kardashevskiy' , 'Masahiro Yamada' , 'Oliver O'Halloran' , 'Mauro Carvalho Chehab' , 'Ira Weiny' , 'Rob Herring' , 'Dave Jiang' , 'linux-nvdimm' , "'Aneesh Kumar K . V'" , 'Krzysztof Kozlowski' , 'Anju T Sudhakar' , 'Mahesh Salgaonkar' , 'Andrew Donnellan' , 'Arnd Bergmann' , 'Greg Kurz' , 'Nicholas Piggin' , =?utf-8?Q?'C=C3=A9dric_Le_Goater'?= , 'Thomas Gleixner' , 'Hari Bathini' , 'Linux MM' , 'Greg Kroah-Hartman' , 'Linux Kernel Mailing List' , 'Vishal Verma' , 'Frederic Barrat' , 'Paul Mackerras' , 'Andrew Morton' , 'linuxppc-dev' , "'David S. Miller'" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" > -----Original Message----- > From: Dan Williams > Sent: Wednesday, 1 April 2020 7:49 PM > 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 > ; 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 nvdimm@lists.01.org>; Linux MM > Subject: Re: [PATCH v4 07/25] ocxl: Add functions to map/unmap LPC > memory >=20 > On Sun, Mar 29, 2020 at 10:23 PM Alastair D'Silva = > wrote: > > > > Add functions to map/unmap LPC memory > > >=20 > "map memory" is an overloaded term. I'm guessing this patch has = nothing to > do with mapping memory in the MMU. Is it updating hardware resource > decoders to start claiming address space that was allocated = previously? >=20 It's similar to MMIO - these calls end up setting up a BAR which places = the LPC memory into a physical memory range addressable by the kernel. > > Signed-off-by: Alastair D'Silva > > Acked-by: Frederic Barrat > > --- > > drivers/misc/ocxl/core.c | 51 = +++++++++++++++++++++++++++++++ > > drivers/misc/ocxl/ocxl_internal.h | 3 ++ > > include/misc/ocxl.h | 21 +++++++++++++ > > 3 files changed, 75 insertions(+) > > > > diff --git a/drivers/misc/ocxl/core.c b/drivers/misc/ocxl/core.c = index > > 2531c6cf19a0..75ff14e3882a 100644 > > --- a/drivers/misc/ocxl/core.c > > +++ b/drivers/misc/ocxl/core.c > > @@ -210,6 +210,56 @@ static void unmap_mmio_areas(struct ocxl_afu > *afu) > > release_fn_bar(afu->fn, afu->config.global_mmio_bar); } > > > > +int ocxl_afu_map_lpc_mem(struct ocxl_afu *afu) { > > + struct pci_dev *dev =3D to_pci_dev(afu->fn->dev.parent); > > + > > + if ((afu->config.lpc_mem_size + afu- > >config.special_purpose_mem_size) =3D=3D 0) > > + return 0; > > + > > + afu->lpc_base_addr =3D ocxl_link_lpc_map(afu->fn->link, = dev); > > + if (afu->lpc_base_addr =3D=3D 0) > > + return -EINVAL; > > + > > + if (afu->config.lpc_mem_size > 0) { > > + afu->lpc_res.start =3D afu->lpc_base_addr + afu- > >config.lpc_mem_offset; > > + afu->lpc_res.end =3D afu->lpc_res.start + = afu->config.lpc_mem_size > - 1; > > + } > > + > > + if (afu->config.special_purpose_mem_size > 0) { > > + afu->special_purpose_res.start =3D = afu->lpc_base_addr + > > + = afu->config.special_purpose_mem_offset; > > + afu->special_purpose_res.end =3D = afu->special_purpose_res.start + > > + = afu->config.special_purpose_mem_size - 1; > > + } > > + > > + return 0; > > +} > > +EXPORT_SYMBOL_GPL(ocxl_afu_map_lpc_mem); > > + > > +struct resource *ocxl_afu_lpc_mem(struct ocxl_afu *afu) { > > + return &afu->lpc_res; > > +} > > +EXPORT_SYMBOL_GPL(ocxl_afu_lpc_mem); > > + > > +static void unmap_lpc_mem(struct ocxl_afu *afu) { > > + struct pci_dev *dev =3D to_pci_dev(afu->fn->dev.parent); > > + > > + if (afu->lpc_res.start || afu->special_purpose_res.start) { > > + void *link =3D afu->fn->link; > > + > > + // only release the link when the the last consumer = calls release > > + ocxl_link_lpc_release(link, dev); > > + > > + afu->lpc_res.start =3D 0; > > + afu->lpc_res.end =3D 0; > > + afu->special_purpose_res.start =3D 0; > > + afu->special_purpose_res.end =3D 0; > > + } > > +} > > + > > static int configure_afu(struct ocxl_afu *afu, u8 afu_idx, struct > > pci_dev *dev) { > > int rc; > > @@ -251,6 +301,7 @@ static int configure_afu(struct ocxl_afu *afu, = u8 > > afu_idx, struct pci_dev *dev) > > > > static void deconfigure_afu(struct ocxl_afu *afu) { > > + unmap_lpc_mem(afu); > > unmap_mmio_areas(afu); > > reclaim_afu_pasid(afu); > > reclaim_afu_actag(afu); > > diff --git a/drivers/misc/ocxl/ocxl_internal.h > > b/drivers/misc/ocxl/ocxl_internal.h > > index 2d7575225bd7..7b975a89db7b 100644 > > --- a/drivers/misc/ocxl/ocxl_internal.h > > +++ b/drivers/misc/ocxl/ocxl_internal.h > > @@ -52,6 +52,9 @@ struct ocxl_afu { > > void __iomem *global_mmio_ptr; > > u64 pp_mmio_start; > > void *private; > > + u64 lpc_base_addr; /* Covers both LPC & special purpose = memory */ > > + struct resource lpc_res; > > + struct resource special_purpose_res; > > }; > > > > enum ocxl_context_status { > > diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h index > > 357ef1aadbc0..d8b0b4d46bfb 100644 > > --- a/include/misc/ocxl.h > > +++ b/include/misc/ocxl.h > > @@ -203,6 +203,27 @@ int ocxl_irq_set_handler(struct ocxl_context > > *ctx, int irq_id, > > > > // AFU Metadata > > > > +/** > > + * ocxl_afu_map_lpc_mem() - Map the LPC system & special purpose > > +memory for an AFU > > + * Do not call this during device discovery, as there may me = multiple >=20 > s/me/be/ >=20 >=20 > > + * devices on a link, and the memory is mapped for the whole link, > > +not > > + * just one device. It should only be called after all devices have > > + * registered their memory on the link. > > + * > > + * @afu: The AFU that has the LPC memory to map > > + * > > + * Returns 0 on success, negative on failure */ int > > +ocxl_afu_map_lpc_mem(struct ocxl_afu *afu); > > + > > +/** > > + * ocxl_afu_lpc_mem() - Get the physical address range of LPC = memory > > +for an AFU > > + * @afu: The AFU associated with the LPC memory > > + * > > + * Returns a pointer to the resource struct for the physical = address > > +range */ struct resource *ocxl_afu_lpc_mem(struct ocxl_afu *afu); > > + > > /** > > * ocxl_afu_config() - Get a pointer to the config for an AFU > > * @afu: a pointer to the AFU to get the config for > > -- > > 2.24.1 > > --=20 Alastair D'Silva mob: 0423 762 819 skype: alastair_dsilva msn: alastair@d-silva.org blog: http://alastair.d-silva.org Twitter: @EvilDeece