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.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 ECC0AC43331 for ; Wed, 1 Apr 2020 08:49:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A2B862077D for ; Wed, 1 Apr 2020 08:49:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b="hTimd5IY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2B862077D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 50C256B00AA; Wed, 1 Apr 2020 04:49:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4BCE96B00B2; Wed, 1 Apr 2020 04:49:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3AB6E6B00B3; Wed, 1 Apr 2020 04:49:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0048.hostedemail.com [216.40.44.48]) by kanga.kvack.org (Postfix) with ESMTP id 1F4C96B00AA for ; Wed, 1 Apr 2020 04:49:33 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id CD6AC180AD81A for ; Wed, 1 Apr 2020 08:49:32 +0000 (UTC) X-FDA: 76658662584.30.brick74_8d8033b5d990f X-HE-Tag: brick74_8d8033b5d990f X-Filterd-Recvd-Size: 9116 Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Wed, 1 Apr 2020 08:49:32 +0000 (UTC) Received: by mail-ed1-f65.google.com with SMTP id cf14so28673298edb.13 for ; Wed, 01 Apr 2020 01:49:32 -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=UN+wHZJTrcu6c2DZIJ8HGRDVBKCDEPMCRCE7ZQEQTH8=; b=hTimd5IY+hTrOkh1p7KqZ0axrIUJgA8aekcpldRM6K9XQupypeq6MkUu+ggRqryYZL x3rcZjrA+Y0jKfVyqzmVLjKEqr3O6iCBN8GDPJzQJi0cEQ/7ObMmXUtXR9XRnlRU8ZiF QkYVKtMu4mENT5W/pzpOUStrq0OytQ5oulJ0UhL1avGRyOevi9/UwPw4Ykxv3wnZ/OwP HyQu22Ie3HIn0/IIyicOfJJ+SkzyBj7Hq8Ljhf/QIcUeGPjXdPcMfFQIvRwGIm43aWdr ui6jSj1L0yFrnNz0X3pBByQOSEhf24bDK4BDfm5vSnLWL82Bjny7/+HfR7ecl+iDeNj+ l41w== 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=UN+wHZJTrcu6c2DZIJ8HGRDVBKCDEPMCRCE7ZQEQTH8=; b=D7s5jtrwJJIp/MdWj1Wj8L0IEvoHpQUD76+e+dGoT79bkrNdMxp2vGGGHpEvItODdR Aw/OWfiVOGdibSQrg6+vqEBylsEJ9VIgk4Oedu9vHCEtHBPS4wAZXmtNlf3kdpkpEO9Q +DUP8WBomc2xrwn42/LWuUn4FJWyjOPayrgovWDBWqhiI/NSmQ+RnpDutmjBS9g7Ht6G SL/gosqt/g+ZV82FKgOYdM0INqJKeyTlEcV/76CYTDL+zGBce/1MVOMOflHpHBzS3KvM BZ0goN2JGYlRO6wP0pXNNfWpCZ/jUqH4E8+89/hs5aTbbYrgbZ5AbbxE3kkxMwA+U8au bQnw== X-Gm-Message-State: ANhLgQ1rq/zvQEn+9wjaEPqir8IYKPMmad8z9fGiXzwHG/5lM4PvUXWX pLhqy/py4UsHPGqhKJCCKtigvD+v3TTtkVh/MxJC9g== X-Google-Smtp-Source: ADFU+vuTuxIfbgq1b9JfG+WohU6wvy4jaujfdFzqOb3NMAMPXWIOfeafCvEeGwbQtVd/xByPDwh7XT1QdUOquEPXjL8= X-Received: by 2002:a05:6402:3044:: with SMTP id bu4mr20560123edb.123.1585730971200; Wed, 01 Apr 2020 01:49:31 -0700 (PDT) MIME-Version: 1.0 References: <20200327071202.2159885-1-alastair@d-silva.org> <20200327071202.2159885-8-alastair@d-silva.org> In-Reply-To: <20200327071202.2159885-8-alastair@d-silva.org> From: Dan Williams Date: Wed, 1 Apr 2020 01:49:19 -0700 Message-ID: Subject: Re: [PATCH v4 07/25] ocxl: Add functions to map/unmap 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, Mar 29, 2020 at 10:23 PM Alastair D'Silva wrote: > > Add functions to map/unmap LPC memory > "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? > 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 = to_pci_dev(afu->fn->dev.parent); > + > + if ((afu->config.lpc_mem_size + afu->config.special_purpose_mem_size) == 0) > + return 0; > + > + afu->lpc_base_addr = ocxl_link_lpc_map(afu->fn->link, dev); > + if (afu->lpc_base_addr == 0) > + return -EINVAL; > + > + if (afu->config.lpc_mem_size > 0) { > + afu->lpc_res.start = afu->lpc_base_addr + afu->config.lpc_mem_offset; > + afu->lpc_res.end = afu->lpc_res.start + afu->config.lpc_mem_size - 1; > + } > + > + if (afu->config.special_purpose_mem_size > 0) { > + afu->special_purpose_res.start = afu->lpc_base_addr + > + afu->config.special_purpose_mem_offset; > + afu->special_purpose_res.end = 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 = to_pci_dev(afu->fn->dev.parent); > + > + if (afu->lpc_res.start || afu->special_purpose_res.start) { > + void *link = afu->fn->link; > + > + // only release the link when the the last consumer calls release > + ocxl_link_lpc_release(link, dev); > + > + afu->lpc_res.start = 0; > + afu->lpc_res.end = 0; > + afu->special_purpose_res.start = 0; > + afu->special_purpose_res.end = 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 s/me/be/ > + * 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 >