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 2BEC0C43331 for ; Wed, 1 Apr 2020 19:35:41 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (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 E8FF120719 for ; Wed, 1 Apr 2020 19:35:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b="mjcsWDpY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8FF120719 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 49FFD10FC3C87; Wed, 1 Apr 2020 12:36:30 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:4864:20::541; helo=mail-ed1-x541.google.com; envelope-from=dan.j.williams@intel.com; receiver= Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3CF4410FC3C83 for ; Wed, 1 Apr 2020 12:36:27 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id bd14so1281631edb.10 for ; Wed, 01 Apr 2020 12:35:38 -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=Q3jSAO8i57DbvhBfb53ktHGZ2uMKAMcCW6E8VbEgc4s=; b=mjcsWDpYphXz5dA5YNqYJoMQpxtbcOHWMp/D9HjrzEb2TBLvYtHLQ9MiFW+MC+l57P McztFw8XSwIRuHgGHpF4R0SwzJjRZOnE0mnEcarYU9nFgLeBatSnCqiKCAhRbEt5OZ8i Ikd9F/1mTxVrHC966dn0DjsG2dA3wXrcjO6rHKNSUXQc+QEedR32ikkq/2y+h+2LN6Rp 1b/UVRVFzHbWQEEGLNg8s2v4TBr6j4ZtOv2qcrCl08DVT4Yv5pCFE0je/mn5MvrXJaCq NGs4XOjlcAYXJoRZu93V6/plTlNLjfDWwYkgkEj1O79FFtxtfIWXh79vagMVcIn26Hxa CVfA== 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=Q3jSAO8i57DbvhBfb53ktHGZ2uMKAMcCW6E8VbEgc4s=; b=LUYBC9AZjA87pY6a45/QXDkD+s4URCBD8ti1h9175z3l/EPVJOCNp0TkwI6w+sqDTl aR4k1KdXzY49gRMPZZdKai4BZkczbYwU6AK07jnXO6Guj1CUEHMzHYvW+4As6JOf/lH2 HxbLXKZ9AXcRMvXht7RbX5NwxjkOP+DX16FM6UCiklppmNzdHeh1QNjKA0ds/ql2g6uo Z2Ct5Bg6vpDifLboAwWq0Nlh2ZKaoI9rLHzQCnf0Up0NNc/tNNOJl/+R2aUne464ehCa Ehyzia15xD+n6uhv0VFbOxVIuVlzVAQWIucMyufPJZ+1leIWwd2yDZ+itcw3W8XEi7EU Szqw== X-Gm-Message-State: ANhLgQ2H3hTN1I3vhj8QMuzjKVhaWbczAbxF9u6JjTCwnOc7KjIN5gTl OGbQnVDal6YJ9IGGOnCchDR25FOMRFecSCi+ls3olA== X-Google-Smtp-Source: ADFU+vs7zqcb4vYtw0JFFUp+7vrhUNZOxwvyZ/ygpmPkcp52KXyXZx+7nxypoK8JQD5UfIspTkuezkIGVj6J1IyuTkU= X-Received: by 2002:a17:906:dbd4:: with SMTP id yc20mr21657879ejb.335.1585769735476; Wed, 01 Apr 2020 12:35:35 -0700 (PDT) MIME-Version: 1.0 References: <20200327071202.2159885-1-alastair@d-silva.org> <20200327071202.2159885-11-alastair@d-silva.org> In-Reply-To: From: Dan Williams Date: Wed, 1 Apr 2020 12:35:24 -0700 Message-ID: Subject: Re: [PATCH v4 10/25] nvdimm: Add driver for OpenCAPI Persistent Memory To: "Alastair D'Silva" Message-ID-Hash: XZGN3KP3LB42INLZRYPMVGHX2IP7FJVO X-Message-ID-Hash: XZGN3KP3LB42INLZRYPMVGHX2IP7FJVO X-MailFrom: dan.j.williams@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: "Aneesh Kumar K . V" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Frederic Barrat , Andrew Donnellan , Arnd Bergmann , Greg Kroah-Hartman , 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 X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Wed, Apr 1, 2020 at 1:49 AM Dan Williams wrote: > > On Sun, Mar 29, 2020 at 10:23 PM Alastair D'Silva wrote: > > > > This driver exposes LPC memory on OpenCAPI pmem cards > > as an NVDIMM, allowing the existing nvram infrastructure > > to be used. > > > > Namespace metadata is stored on the media itself, so > > scm_reserve_metadata() maps 1 section's worth of PMEM storage > > at the start to hold this. The rest of the PMEM range is registered > > with libnvdimm as an nvdimm. ndctl_config_read/write/size() provide > > callbacks to libnvdimm to access the metadata. > > > > Signed-off-by: Alastair D'Silva > > --- > > drivers/nvdimm/Kconfig | 2 + > > drivers/nvdimm/Makefile | 1 + > > drivers/nvdimm/ocxl/Kconfig | 15 ++ > > drivers/nvdimm/ocxl/Makefile | 7 + > > drivers/nvdimm/ocxl/main.c | 476 +++++++++++++++++++++++++++++++++ > > drivers/nvdimm/ocxl/ocxlpmem.h | 23 ++ > > 6 files changed, 524 insertions(+) > > create mode 100644 drivers/nvdimm/ocxl/Kconfig > > create mode 100644 drivers/nvdimm/ocxl/Makefile > > create mode 100644 drivers/nvdimm/ocxl/main.c > > create mode 100644 drivers/nvdimm/ocxl/ocxlpmem.h > > > > diff --git a/drivers/nvdimm/Kconfig b/drivers/nvdimm/Kconfig > > index b7d1eb38b27d..368328637182 100644 > > --- a/drivers/nvdimm/Kconfig > > +++ b/drivers/nvdimm/Kconfig > > @@ -131,4 +131,6 @@ config NVDIMM_TEST_BUILD > > core devm_memremap_pages() implementation and other > > infrastructure. > > > > +source "drivers/nvdimm/ocxl/Kconfig" > > + > > endif > > diff --git a/drivers/nvdimm/Makefile b/drivers/nvdimm/Makefile > > index 29203f3d3069..bc02be11c794 100644 > > --- a/drivers/nvdimm/Makefile > > +++ b/drivers/nvdimm/Makefile > > @@ -33,3 +33,4 @@ libnvdimm-$(CONFIG_NVDIMM_KEYS) += security.o > > TOOLS := ../../tools > > TEST_SRC := $(TOOLS)/testing/nvdimm/test > > obj-$(CONFIG_NVDIMM_TEST_BUILD) += $(TEST_SRC)/iomap.o > > +obj-$(CONFIG_LIBNVDIMM) += ocxl/ > > diff --git a/drivers/nvdimm/ocxl/Kconfig b/drivers/nvdimm/ocxl/Kconfig > > new file mode 100644 > > index 000000000000..c5d927520920 > > --- /dev/null > > +++ b/drivers/nvdimm/ocxl/Kconfig > > @@ -0,0 +1,15 @@ > > +# SPDX-License-Identifier: GPL-2.0-only > > +if LIBNVDIMM > > + > > +config OCXL_PMEM > > + tristate "OpenCAPI Persistent Memory" > > + depends on LIBNVDIMM && PPC_POWERNV && PCI && EEH && ZONE_DEVICE && OCXL > > Does OXCL_PMEM itself have any CONFIG_ZONE_DEVICE dependencies? That's > more a function of CONFIG_DEV_DAX and CONFIG_FS_DAX. Doesn't OCXL > already depend on CONFIG_PCI? > > > > + help > > + Exposes devices that implement the OpenCAPI Storage Class Memory > > + specification as persistent memory regions. You may also want > > + DEV_DAX, DEV_DAX_PMEM & FS_DAX if you plan on using DAX devices > > + stacked on top of this driver. > > + > > + Select N if unsure. > > + > > +endif > > diff --git a/drivers/nvdimm/ocxl/Makefile b/drivers/nvdimm/ocxl/Makefile > > new file mode 100644 > > index 000000000000..e0e8ade1987a > > --- /dev/null > > +++ b/drivers/nvdimm/ocxl/Makefile > > @@ -0,0 +1,7 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > + > > +ccflags-$(CONFIG_PPC_WERROR) += -Werror > > + > > +obj-$(CONFIG_OCXL_PMEM) += ocxlpmem.o > > + > > +ocxlpmem-y := main.o > > \ No newline at end of file > > diff --git a/drivers/nvdimm/ocxl/main.c b/drivers/nvdimm/ocxl/main.c > > new file mode 100644 > > index 000000000000..c0066fedf9cc > > --- /dev/null > > +++ b/drivers/nvdimm/ocxl/main.c > > @@ -0,0 +1,476 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +// Copyright 2020 IBM Corp. > > + > > +/* > > + * A driver for OpenCAPI devices that implement the Storage Class > > + * Memory specification. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include "ocxlpmem.h" > > + > > +static const struct pci_device_id pci_tbl[] = { > > + { PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x0625), }, > > + { } > > +}; > > + > > +MODULE_DEVICE_TABLE(pci, pci_tbl); > > + > > +#define NUM_MINORS 256 // Total to reserve > > + > > +static dev_t ocxlpmem_dev; > > +static struct class *ocxlpmem_class; > > +static struct mutex minors_idr_lock; > > +static struct idr minors_idr; > > + > > +/** > > + * ndctl_config_write() - Handle a ND_CMD_SET_CONFIG_DATA command from ndctl > > + * @ocxlpmem: the device metadata > > + * @command: the incoming data to write > > + * Return: 0 on success, negative on failure > > + */ > > +static int ndctl_config_write(struct ocxlpmem *ocxlpmem, > > + struct nd_cmd_set_config_hdr *command) > > +{ > > + if (command->in_offset + command->in_length > LABEL_AREA_SIZE) > > + return -EINVAL; > > + > > + memcpy_flushcache(ocxlpmem->metadata_addr + command->in_offset, > > + command->in_buf, command->in_length); > > + > > + return 0; > > +} > > + > > +/** > > + * ndctl_config_read() - Handle a ND_CMD_GET_CONFIG_DATA command from ndctl > > + * @ocxlpmem: the device metadata > > + * @command: the read request > > + * Return: 0 on success, negative on failure > > + */ > > +static int ndctl_config_read(struct ocxlpmem *ocxlpmem, > > + struct nd_cmd_get_config_data_hdr *command) > > +{ > > + if (command->in_offset + command->in_length > LABEL_AREA_SIZE) > > + return -EINVAL; > > + > > + memcpy_mcsafe(command->out_buf, > > + ocxlpmem->metadata_addr + command->in_offset, > > + command->in_length); > > + > > + return 0; > > +} > > + > > +/** > > + * ndctl_config_size() - Handle a ND_CMD_GET_CONFIG_SIZE command from ndctl > > + * @command: the read request > > + * Return: 0 on success, negative on failure > > + */ > > +static int ndctl_config_size(struct nd_cmd_get_config_size *command) > > +{ > > + command->status = 0; > > + command->config_size = LABEL_AREA_SIZE; > > + command->max_xfer = PAGE_SIZE; > > + > > + return 0; > > +} > > + > > +static int ndctl(struct nvdimm_bus_descriptor *nd_desc, > > + struct nvdimm *nvdimm, > > + unsigned int cmd, void *buf, unsigned int buf_len, int *cmd_rc) > > +{ > > + struct ocxlpmem *ocxlpmem = container_of(nd_desc, > > + struct ocxlpmem, bus_desc); > > + > > + switch (cmd) { > > + case ND_CMD_GET_CONFIG_SIZE: > > + *cmd_rc = ndctl_config_size(buf); > > + return 0; > > + > > + case ND_CMD_GET_CONFIG_DATA: > > + *cmd_rc = ndctl_config_read(ocxlpmem, buf); > > + return 0; > > + > > + case ND_CMD_SET_CONFIG_DATA: > > + *cmd_rc = ndctl_config_write(ocxlpmem, buf); > > + return 0; > > + > > + default: > > + return -ENOTTY; > > + } > > +} > > + > > +/** > > + * reserve_metadata() - Reserve space for nvdimm metadata > > + * @ocxlpmem: the device metadata > > + * @lpc_mem: The resource representing the LPC memory of the OpenCAPI device > > + */ > > +static int reserve_metadata(struct ocxlpmem *ocxlpmem, > > + struct resource *lpc_mem) > > +{ > > + ocxlpmem->metadata_addr = devm_memremap(&ocxlpmem->dev, lpc_mem->start, > > + LABEL_AREA_SIZE, MEMREMAP_WB); > > + if (IS_ERR(ocxlpmem->metadata_addr)) > > + return PTR_ERR(ocxlpmem->metadata_addr); > > + > > + return 0; > > +} > > + > > +/** > > + * register_lpc_mem() - Discover persistent memory on a device and register it with the NVDIMM subsystem > > + * @ocxlpmem: the device metadata > > + * Return: 0 on success > > + */ > > +static int register_lpc_mem(struct ocxlpmem *ocxlpmem) > > +{ > > + struct nd_region_desc region_desc; > > + struct nd_mapping_desc nd_mapping_desc; > > + struct resource *lpc_mem; > > + const struct ocxl_afu_config *config; > > + const struct ocxl_fn_config *fn_config; > > + int rc; > > + unsigned long nvdimm_cmd_mask = 0; > > + unsigned long nvdimm_flags = 0; > > + int target_node; > > + char serial[16 + 1]; > > + > > + // Set up the reserved metadata area > > + rc = ocxl_afu_map_lpc_mem(ocxlpmem->ocxl_afu); > > + if (rc < 0) > > + return rc; > > + > > + lpc_mem = ocxl_afu_lpc_mem(ocxlpmem->ocxl_afu); > > + if (!lpc_mem || !lpc_mem->start) > > + return -EINVAL; > > + > > + config = ocxl_afu_config(ocxlpmem->ocxl_afu); > > + fn_config = ocxl_function_config(ocxlpmem->ocxl_fn); > > + > > + rc = reserve_metadata(ocxlpmem, lpc_mem); > > + if (rc) > > + return rc; > > + > > + ocxlpmem->bus_desc.provider_name = "ocxlpmem"; > > + ocxlpmem->bus_desc.ndctl = ndctl; > > + ocxlpmem->bus_desc.module = THIS_MODULE; > > + > > + ocxlpmem->nvdimm_bus = nvdimm_bus_register(&ocxlpmem->dev, > > + &ocxlpmem->bus_desc); > > + if (!ocxlpmem->nvdimm_bus) > > + return -EINVAL; > > + > > + ocxlpmem->pmem_res.start = (u64)lpc_mem->start + LABEL_AREA_SIZE; > > + ocxlpmem->pmem_res.end = (u64)lpc_mem->start + config->lpc_mem_size - 1; > > + ocxlpmem->pmem_res.name = "OpenCAPI persistent memory"; > > + > > + set_bit(ND_CMD_GET_CONFIG_SIZE, &nvdimm_cmd_mask); > > + set_bit(ND_CMD_GET_CONFIG_DATA, &nvdimm_cmd_mask); > > + set_bit(ND_CMD_SET_CONFIG_DATA, &nvdimm_cmd_mask); > > + > > + set_bit(NDD_ALIASING, &nvdimm_flags); > > + > > + snprintf(serial, sizeof(serial), "%llx", fn_config->serial); > > + nd_mapping_desc.nvdimm = nvdimm_create(ocxlpmem->nvdimm_bus, ocxlpmem, > > + NULL, nvdimm_flags, > > + nvdimm_cmd_mask, 0, NULL); > > + if (!nd_mapping_desc.nvdimm) > > + return -ENOMEM; > > + > > + if (nvdimm_bus_check_dimm_count(ocxlpmem->nvdimm_bus, 1)) > > + return -EINVAL; > > + > > + nd_mapping_desc.start = ocxlpmem->pmem_res.start; > > + nd_mapping_desc.size = resource_size(&ocxlpmem->pmem_res); > > + nd_mapping_desc.position = 0; > > + > > + ocxlpmem->nd_set.cookie1 = fn_config->serial; > > + ocxlpmem->nd_set.cookie2 = fn_config->serial; > > + > > + target_node = of_node_to_nid(ocxlpmem->pdev->dev.of_node); > > + > > + memset(®ion_desc, 0, sizeof(region_desc)); > > + region_desc.res = &ocxlpmem->pmem_res; > > + region_desc.numa_node = NUMA_NO_NODE; > > + region_desc.target_node = target_node; > > + region_desc.num_mappings = 1; > > + region_desc.mapping = &nd_mapping_desc; > > + region_desc.nd_set = &ocxlpmem->nd_set; > > + > > + set_bit(ND_REGION_PAGEMAP, ®ion_desc.flags); > > + /* > > + * NB: libnvdimm copies the data from ndr_desc into it's own > > + * structures so passing a stack pointer is fine. > > + */ > > + ocxlpmem->nd_region = nvdimm_pmem_region_create(ocxlpmem->nvdimm_bus, > > + ®ion_desc); > > + if (!ocxlpmem->nd_region) > > + return -EINVAL; > > + > > + dev_info(&ocxlpmem->dev, > > + "Onlining %lluMB of persistent memory\n", > > + nd_mapping_desc.size / SZ_1M); > > + > > + return 0; > > +} > > + > > +/** > > + * allocate_minor() - Allocate a minor number to use for an OpenCAPI pmem device > > + * @ocxlpmem: the device metadata > > + * Return: the allocated minor number > > + */ > > +static int allocate_minor(struct ocxlpmem *ocxlpmem) > > +{ > > + int minor; > > + > > + mutex_lock(&minors_idr_lock); > > + minor = idr_alloc(&minors_idr, ocxlpmem, 0, NUM_MINORS, GFP_KERNEL); > > + mutex_unlock(&minors_idr_lock); > > + return minor; > > +} > > + > > +static void free_minor(struct ocxlpmem *ocxlpmem) > > +{ > > + mutex_lock(&minors_idr_lock); > > + idr_remove(&minors_idr, MINOR(ocxlpmem->dev.devt)); > > + mutex_unlock(&minors_idr_lock); > > +} > > + > > +/** > > + * free_ocxlpmem() - Free all members of an ocxlpmem struct > > + * @ocxlpmem: the device struct to clear > > + */ > > +static void free_ocxlpmem(struct ocxlpmem *ocxlpmem) > > +{ > > + int rc; > > + > > + free_minor(ocxlpmem); > > + > > + if (ocxlpmem->ocxl_context) { > > + rc = ocxl_context_detach(ocxlpmem->ocxl_context); > > + if (rc == -EBUSY) > > + dev_warn(&ocxlpmem->dev, "Timeout detaching ocxl context\n"); > > + else > > + ocxl_context_free(ocxlpmem->ocxl_context); > > + } > > + > > + if (ocxlpmem->ocxl_afu) > > + ocxl_afu_put(ocxlpmem->ocxl_afu); > > + > > + if (ocxlpmem->ocxl_fn) > > + ocxl_function_close(ocxlpmem->ocxl_fn); > > + > > + pci_dev_put(ocxlpmem->pdev); > > + > > + kfree(ocxlpmem); > > +} > > + > > +/** > > + * free_ocxlpmem_dev() - Free an OpenCAPI persistent memory device > > + * @dev: The device struct > > + */ > > +static void free_ocxlpmem_dev(struct device *dev) > > +{ > > + struct ocxlpmem *ocxlpmem = container_of(dev, struct ocxlpmem, dev); > > + > > + free_ocxlpmem(ocxlpmem); > > +} > > + > > +/** > > + * ocxlpmem_register() - Register an OpenCAPI pmem device with the kernel > > + * @ocxlpmem: the device metadata > > + * Return: 0 on success, negative on failure > > + */ > > +static int ocxlpmem_register(struct ocxlpmem *ocxlpmem) > > +{ > > + int rc; > > + int minor = allocate_minor(ocxlpmem); > > + > > + if (minor < 0) > > + return minor; > > + > > + ocxlpmem->dev.release = free_ocxlpmem_dev; > > + rc = dev_set_name(&ocxlpmem->dev, "ocxlpmem%d", minor); > > + if (rc < 0) > > + return rc; > > + > > + ocxlpmem->dev.devt = MKDEV(MAJOR(ocxlpmem_dev), minor); > > + ocxlpmem->dev.class = ocxlpmem_class; > > + ocxlpmem->dev.parent = &ocxlpmem->pdev->dev; > > + > > + return device_register(&ocxlpmem->dev); > > You lost me, why does this need it's own ioctl path and device node? > I'd expect you you'd tunnel the commands you need through the existing > infrastructure ideally with an eye for cross-arch compatibility. This > is a fundamental concern that probably has significant implications > for what follows. At a minimum this device registration should move to the end of the patchset once all the libnvdimm generic enabling is done. Even then I think the libnvdimm core has all the hooks you need to provide device specific enabling *through* the existing interfaces. Have a look at the how the ACPI NFIT bus driver provides "nfit/" scoped sysfs attributes and tunnels "struct nd_cmd_pkg" ioctl invocations to either the bus or "dimm" level device objects. The dimm security model is an example of an implementation that wraps a libnvdimm-generic sysfs front-end to an intel-specific-device backend. It would be unfortunate to need to invent another ABI. _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-leave@lists.01.org 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=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 665BAC2D0F3 for ; Wed, 1 Apr 2020 19:35:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2782D20719 for ; Wed, 1 Apr 2020 19:35:40 +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="mjcsWDpY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732834AbgDATfj (ORCPT ); Wed, 1 Apr 2020 15:35:39 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:40208 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732244AbgDATfi (ORCPT ); Wed, 1 Apr 2020 15:35:38 -0400 Received: by mail-ed1-f67.google.com with SMTP id w26so1306358edu.7 for ; Wed, 01 Apr 2020 12:35:36 -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=Q3jSAO8i57DbvhBfb53ktHGZ2uMKAMcCW6E8VbEgc4s=; b=mjcsWDpYphXz5dA5YNqYJoMQpxtbcOHWMp/D9HjrzEb2TBLvYtHLQ9MiFW+MC+l57P McztFw8XSwIRuHgGHpF4R0SwzJjRZOnE0mnEcarYU9nFgLeBatSnCqiKCAhRbEt5OZ8i Ikd9F/1mTxVrHC966dn0DjsG2dA3wXrcjO6rHKNSUXQc+QEedR32ikkq/2y+h+2LN6Rp 1b/UVRVFzHbWQEEGLNg8s2v4TBr6j4ZtOv2qcrCl08DVT4Yv5pCFE0je/mn5MvrXJaCq NGs4XOjlcAYXJoRZu93V6/plTlNLjfDWwYkgkEj1O79FFtxtfIWXh79vagMVcIn26Hxa CVfA== 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=Q3jSAO8i57DbvhBfb53ktHGZ2uMKAMcCW6E8VbEgc4s=; b=WdLUsy+HV7Np7cFlckOgn/VRJIUQS/dYEQnJujMJQO6xYEd3Rai9m7QYeJVGcq5fT9 6dnLfE6NL0RyweVuhOc6tVWjaN4UN/TUQk9Sv+cMqO1NFeGZCL/zrxF6gttReTk5iueS aQBru6eEFaj+mQ0h+z/G7+mBh5SQlHQIvAA2ruc0La0oK8mJk/ex/FxL9FM2YoWaUAkk Xp3VX+MkmVvy3McOo8jAG70dzHSSTRdoGuPLaDtytueZgFseGpmBy4Ci+yYxan2U5Aps U3v6XRGQ0Q8+lSqX1nNYlgM4KwQ0zOvVj14wJ24454Ji2dyJ6eU7l1Aqmv7QjngFNuO5 2x+w== X-Gm-Message-State: ANhLgQ0alChVnnak/QJv26XjU+4T9ZqB9Pso66Qlc0nxmoRkLneX/HoX bh3Prq2ISo+l/0uJiwD45kidIpMtrAhrYEWCWzLbnQ== X-Google-Smtp-Source: ADFU+vs7zqcb4vYtw0JFFUp+7vrhUNZOxwvyZ/ygpmPkcp52KXyXZx+7nxypoK8JQD5UfIspTkuezkIGVj6J1IyuTkU= X-Received: by 2002:a17:906:dbd4:: with SMTP id yc20mr21657879ejb.335.1585769735476; Wed, 01 Apr 2020 12:35:35 -0700 (PDT) MIME-Version: 1.0 References: <20200327071202.2159885-1-alastair@d-silva.org> <20200327071202.2159885-11-alastair@d-silva.org> In-Reply-To: From: Dan Williams Date: Wed, 1 Apr 2020 12:35:24 -0700 Message-ID: Subject: Re: [PATCH v4 10/25] nvdimm: Add driver for OpenCAPI Persistent 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 Wed, Apr 1, 2020 at 1:49 AM Dan Williams wrote: > > On Sun, Mar 29, 2020 at 10:23 PM Alastair D'Silva wrote: > > > > This driver exposes LPC memory on OpenCAPI pmem cards > > as an NVDIMM, allowing the existing nvram infrastructure > > to be used. > > > > Namespace metadata is stored on the media itself, so > > scm_reserve_metadata() maps 1 section's worth of PMEM storage > > at the start to hold this. The rest of the PMEM range is registered > > with libnvdimm as an nvdimm. ndctl_config_read/write/size() provide > > callbacks to libnvdimm to access the metadata. > > > > Signed-off-by: Alastair D'Silva > > --- > > drivers/nvdimm/Kconfig | 2 + > > drivers/nvdimm/Makefile | 1 + > > drivers/nvdimm/ocxl/Kconfig | 15 ++ > > drivers/nvdimm/ocxl/Makefile | 7 + > > drivers/nvdimm/ocxl/main.c | 476 +++++++++++++++++++++++++++++++++ > > drivers/nvdimm/ocxl/ocxlpmem.h | 23 ++ > > 6 files changed, 524 insertions(+) > > create mode 100644 drivers/nvdimm/ocxl/Kconfig > > create mode 100644 drivers/nvdimm/ocxl/Makefile > > create mode 100644 drivers/nvdimm/ocxl/main.c > > create mode 100644 drivers/nvdimm/ocxl/ocxlpmem.h > > > > diff --git a/drivers/nvdimm/Kconfig b/drivers/nvdimm/Kconfig > > index b7d1eb38b27d..368328637182 100644 > > --- a/drivers/nvdimm/Kconfig > > +++ b/drivers/nvdimm/Kconfig > > @@ -131,4 +131,6 @@ config NVDIMM_TEST_BUILD > > core devm_memremap_pages() implementation and other > > infrastructure. > > > > +source "drivers/nvdimm/ocxl/Kconfig" > > + > > endif > > diff --git a/drivers/nvdimm/Makefile b/drivers/nvdimm/Makefile > > index 29203f3d3069..bc02be11c794 100644 > > --- a/drivers/nvdimm/Makefile > > +++ b/drivers/nvdimm/Makefile > > @@ -33,3 +33,4 @@ libnvdimm-$(CONFIG_NVDIMM_KEYS) += security.o > > TOOLS := ../../tools > > TEST_SRC := $(TOOLS)/testing/nvdimm/test > > obj-$(CONFIG_NVDIMM_TEST_BUILD) += $(TEST_SRC)/iomap.o > > +obj-$(CONFIG_LIBNVDIMM) += ocxl/ > > diff --git a/drivers/nvdimm/ocxl/Kconfig b/drivers/nvdimm/ocxl/Kconfig > > new file mode 100644 > > index 000000000000..c5d927520920 > > --- /dev/null > > +++ b/drivers/nvdimm/ocxl/Kconfig > > @@ -0,0 +1,15 @@ > > +# SPDX-License-Identifier: GPL-2.0-only > > +if LIBNVDIMM > > + > > +config OCXL_PMEM > > + tristate "OpenCAPI Persistent Memory" > > + depends on LIBNVDIMM && PPC_POWERNV && PCI && EEH && ZONE_DEVICE && OCXL > > Does OXCL_PMEM itself have any CONFIG_ZONE_DEVICE dependencies? That's > more a function of CONFIG_DEV_DAX and CONFIG_FS_DAX. Doesn't OCXL > already depend on CONFIG_PCI? > > > > + help > > + Exposes devices that implement the OpenCAPI Storage Class Memory > > + specification as persistent memory regions. You may also want > > + DEV_DAX, DEV_DAX_PMEM & FS_DAX if you plan on using DAX devices > > + stacked on top of this driver. > > + > > + Select N if unsure. > > + > > +endif > > diff --git a/drivers/nvdimm/ocxl/Makefile b/drivers/nvdimm/ocxl/Makefile > > new file mode 100644 > > index 000000000000..e0e8ade1987a > > --- /dev/null > > +++ b/drivers/nvdimm/ocxl/Makefile > > @@ -0,0 +1,7 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > + > > +ccflags-$(CONFIG_PPC_WERROR) += -Werror > > + > > +obj-$(CONFIG_OCXL_PMEM) += ocxlpmem.o > > + > > +ocxlpmem-y := main.o > > \ No newline at end of file > > diff --git a/drivers/nvdimm/ocxl/main.c b/drivers/nvdimm/ocxl/main.c > > new file mode 100644 > > index 000000000000..c0066fedf9cc > > --- /dev/null > > +++ b/drivers/nvdimm/ocxl/main.c > > @@ -0,0 +1,476 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +// Copyright 2020 IBM Corp. > > + > > +/* > > + * A driver for OpenCAPI devices that implement the Storage Class > > + * Memory specification. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include "ocxlpmem.h" > > + > > +static const struct pci_device_id pci_tbl[] = { > > + { PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x0625), }, > > + { } > > +}; > > + > > +MODULE_DEVICE_TABLE(pci, pci_tbl); > > + > > +#define NUM_MINORS 256 // Total to reserve > > + > > +static dev_t ocxlpmem_dev; > > +static struct class *ocxlpmem_class; > > +static struct mutex minors_idr_lock; > > +static struct idr minors_idr; > > + > > +/** > > + * ndctl_config_write() - Handle a ND_CMD_SET_CONFIG_DATA command from ndctl > > + * @ocxlpmem: the device metadata > > + * @command: the incoming data to write > > + * Return: 0 on success, negative on failure > > + */ > > +static int ndctl_config_write(struct ocxlpmem *ocxlpmem, > > + struct nd_cmd_set_config_hdr *command) > > +{ > > + if (command->in_offset + command->in_length > LABEL_AREA_SIZE) > > + return -EINVAL; > > + > > + memcpy_flushcache(ocxlpmem->metadata_addr + command->in_offset, > > + command->in_buf, command->in_length); > > + > > + return 0; > > +} > > + > > +/** > > + * ndctl_config_read() - Handle a ND_CMD_GET_CONFIG_DATA command from ndctl > > + * @ocxlpmem: the device metadata > > + * @command: the read request > > + * Return: 0 on success, negative on failure > > + */ > > +static int ndctl_config_read(struct ocxlpmem *ocxlpmem, > > + struct nd_cmd_get_config_data_hdr *command) > > +{ > > + if (command->in_offset + command->in_length > LABEL_AREA_SIZE) > > + return -EINVAL; > > + > > + memcpy_mcsafe(command->out_buf, > > + ocxlpmem->metadata_addr + command->in_offset, > > + command->in_length); > > + > > + return 0; > > +} > > + > > +/** > > + * ndctl_config_size() - Handle a ND_CMD_GET_CONFIG_SIZE command from ndctl > > + * @command: the read request > > + * Return: 0 on success, negative on failure > > + */ > > +static int ndctl_config_size(struct nd_cmd_get_config_size *command) > > +{ > > + command->status = 0; > > + command->config_size = LABEL_AREA_SIZE; > > + command->max_xfer = PAGE_SIZE; > > + > > + return 0; > > +} > > + > > +static int ndctl(struct nvdimm_bus_descriptor *nd_desc, > > + struct nvdimm *nvdimm, > > + unsigned int cmd, void *buf, unsigned int buf_len, int *cmd_rc) > > +{ > > + struct ocxlpmem *ocxlpmem = container_of(nd_desc, > > + struct ocxlpmem, bus_desc); > > + > > + switch (cmd) { > > + case ND_CMD_GET_CONFIG_SIZE: > > + *cmd_rc = ndctl_config_size(buf); > > + return 0; > > + > > + case ND_CMD_GET_CONFIG_DATA: > > + *cmd_rc = ndctl_config_read(ocxlpmem, buf); > > + return 0; > > + > > + case ND_CMD_SET_CONFIG_DATA: > > + *cmd_rc = ndctl_config_write(ocxlpmem, buf); > > + return 0; > > + > > + default: > > + return -ENOTTY; > > + } > > +} > > + > > +/** > > + * reserve_metadata() - Reserve space for nvdimm metadata > > + * @ocxlpmem: the device metadata > > + * @lpc_mem: The resource representing the LPC memory of the OpenCAPI device > > + */ > > +static int reserve_metadata(struct ocxlpmem *ocxlpmem, > > + struct resource *lpc_mem) > > +{ > > + ocxlpmem->metadata_addr = devm_memremap(&ocxlpmem->dev, lpc_mem->start, > > + LABEL_AREA_SIZE, MEMREMAP_WB); > > + if (IS_ERR(ocxlpmem->metadata_addr)) > > + return PTR_ERR(ocxlpmem->metadata_addr); > > + > > + return 0; > > +} > > + > > +/** > > + * register_lpc_mem() - Discover persistent memory on a device and register it with the NVDIMM subsystem > > + * @ocxlpmem: the device metadata > > + * Return: 0 on success > > + */ > > +static int register_lpc_mem(struct ocxlpmem *ocxlpmem) > > +{ > > + struct nd_region_desc region_desc; > > + struct nd_mapping_desc nd_mapping_desc; > > + struct resource *lpc_mem; > > + const struct ocxl_afu_config *config; > > + const struct ocxl_fn_config *fn_config; > > + int rc; > > + unsigned long nvdimm_cmd_mask = 0; > > + unsigned long nvdimm_flags = 0; > > + int target_node; > > + char serial[16 + 1]; > > + > > + // Set up the reserved metadata area > > + rc = ocxl_afu_map_lpc_mem(ocxlpmem->ocxl_afu); > > + if (rc < 0) > > + return rc; > > + > > + lpc_mem = ocxl_afu_lpc_mem(ocxlpmem->ocxl_afu); > > + if (!lpc_mem || !lpc_mem->start) > > + return -EINVAL; > > + > > + config = ocxl_afu_config(ocxlpmem->ocxl_afu); > > + fn_config = ocxl_function_config(ocxlpmem->ocxl_fn); > > + > > + rc = reserve_metadata(ocxlpmem, lpc_mem); > > + if (rc) > > + return rc; > > + > > + ocxlpmem->bus_desc.provider_name = "ocxlpmem"; > > + ocxlpmem->bus_desc.ndctl = ndctl; > > + ocxlpmem->bus_desc.module = THIS_MODULE; > > + > > + ocxlpmem->nvdimm_bus = nvdimm_bus_register(&ocxlpmem->dev, > > + &ocxlpmem->bus_desc); > > + if (!ocxlpmem->nvdimm_bus) > > + return -EINVAL; > > + > > + ocxlpmem->pmem_res.start = (u64)lpc_mem->start + LABEL_AREA_SIZE; > > + ocxlpmem->pmem_res.end = (u64)lpc_mem->start + config->lpc_mem_size - 1; > > + ocxlpmem->pmem_res.name = "OpenCAPI persistent memory"; > > + > > + set_bit(ND_CMD_GET_CONFIG_SIZE, &nvdimm_cmd_mask); > > + set_bit(ND_CMD_GET_CONFIG_DATA, &nvdimm_cmd_mask); > > + set_bit(ND_CMD_SET_CONFIG_DATA, &nvdimm_cmd_mask); > > + > > + set_bit(NDD_ALIASING, &nvdimm_flags); > > + > > + snprintf(serial, sizeof(serial), "%llx", fn_config->serial); > > + nd_mapping_desc.nvdimm = nvdimm_create(ocxlpmem->nvdimm_bus, ocxlpmem, > > + NULL, nvdimm_flags, > > + nvdimm_cmd_mask, 0, NULL); > > + if (!nd_mapping_desc.nvdimm) > > + return -ENOMEM; > > + > > + if (nvdimm_bus_check_dimm_count(ocxlpmem->nvdimm_bus, 1)) > > + return -EINVAL; > > + > > + nd_mapping_desc.start = ocxlpmem->pmem_res.start; > > + nd_mapping_desc.size = resource_size(&ocxlpmem->pmem_res); > > + nd_mapping_desc.position = 0; > > + > > + ocxlpmem->nd_set.cookie1 = fn_config->serial; > > + ocxlpmem->nd_set.cookie2 = fn_config->serial; > > + > > + target_node = of_node_to_nid(ocxlpmem->pdev->dev.of_node); > > + > > + memset(®ion_desc, 0, sizeof(region_desc)); > > + region_desc.res = &ocxlpmem->pmem_res; > > + region_desc.numa_node = NUMA_NO_NODE; > > + region_desc.target_node = target_node; > > + region_desc.num_mappings = 1; > > + region_desc.mapping = &nd_mapping_desc; > > + region_desc.nd_set = &ocxlpmem->nd_set; > > + > > + set_bit(ND_REGION_PAGEMAP, ®ion_desc.flags); > > + /* > > + * NB: libnvdimm copies the data from ndr_desc into it's own > > + * structures so passing a stack pointer is fine. > > + */ > > + ocxlpmem->nd_region = nvdimm_pmem_region_create(ocxlpmem->nvdimm_bus, > > + ®ion_desc); > > + if (!ocxlpmem->nd_region) > > + return -EINVAL; > > + > > + dev_info(&ocxlpmem->dev, > > + "Onlining %lluMB of persistent memory\n", > > + nd_mapping_desc.size / SZ_1M); > > + > > + return 0; > > +} > > + > > +/** > > + * allocate_minor() - Allocate a minor number to use for an OpenCAPI pmem device > > + * @ocxlpmem: the device metadata > > + * Return: the allocated minor number > > + */ > > +static int allocate_minor(struct ocxlpmem *ocxlpmem) > > +{ > > + int minor; > > + > > + mutex_lock(&minors_idr_lock); > > + minor = idr_alloc(&minors_idr, ocxlpmem, 0, NUM_MINORS, GFP_KERNEL); > > + mutex_unlock(&minors_idr_lock); > > + return minor; > > +} > > + > > +static void free_minor(struct ocxlpmem *ocxlpmem) > > +{ > > + mutex_lock(&minors_idr_lock); > > + idr_remove(&minors_idr, MINOR(ocxlpmem->dev.devt)); > > + mutex_unlock(&minors_idr_lock); > > +} > > + > > +/** > > + * free_ocxlpmem() - Free all members of an ocxlpmem struct > > + * @ocxlpmem: the device struct to clear > > + */ > > +static void free_ocxlpmem(struct ocxlpmem *ocxlpmem) > > +{ > > + int rc; > > + > > + free_minor(ocxlpmem); > > + > > + if (ocxlpmem->ocxl_context) { > > + rc = ocxl_context_detach(ocxlpmem->ocxl_context); > > + if (rc == -EBUSY) > > + dev_warn(&ocxlpmem->dev, "Timeout detaching ocxl context\n"); > > + else > > + ocxl_context_free(ocxlpmem->ocxl_context); > > + } > > + > > + if (ocxlpmem->ocxl_afu) > > + ocxl_afu_put(ocxlpmem->ocxl_afu); > > + > > + if (ocxlpmem->ocxl_fn) > > + ocxl_function_close(ocxlpmem->ocxl_fn); > > + > > + pci_dev_put(ocxlpmem->pdev); > > + > > + kfree(ocxlpmem); > > +} > > + > > +/** > > + * free_ocxlpmem_dev() - Free an OpenCAPI persistent memory device > > + * @dev: The device struct > > + */ > > +static void free_ocxlpmem_dev(struct device *dev) > > +{ > > + struct ocxlpmem *ocxlpmem = container_of(dev, struct ocxlpmem, dev); > > + > > + free_ocxlpmem(ocxlpmem); > > +} > > + > > +/** > > + * ocxlpmem_register() - Register an OpenCAPI pmem device with the kernel > > + * @ocxlpmem: the device metadata > > + * Return: 0 on success, negative on failure > > + */ > > +static int ocxlpmem_register(struct ocxlpmem *ocxlpmem) > > +{ > > + int rc; > > + int minor = allocate_minor(ocxlpmem); > > + > > + if (minor < 0) > > + return minor; > > + > > + ocxlpmem->dev.release = free_ocxlpmem_dev; > > + rc = dev_set_name(&ocxlpmem->dev, "ocxlpmem%d", minor); > > + if (rc < 0) > > + return rc; > > + > > + ocxlpmem->dev.devt = MKDEV(MAJOR(ocxlpmem_dev), minor); > > + ocxlpmem->dev.class = ocxlpmem_class; > > + ocxlpmem->dev.parent = &ocxlpmem->pdev->dev; > > + > > + return device_register(&ocxlpmem->dev); > > You lost me, why does this need it's own ioctl path and device node? > I'd expect you you'd tunnel the commands you need through the existing > infrastructure ideally with an eye for cross-arch compatibility. This > is a fundamental concern that probably has significant implications > for what follows. At a minimum this device registration should move to the end of the patchset once all the libnvdimm generic enabling is done. Even then I think the libnvdimm core has all the hooks you need to provide device specific enabling *through* the existing interfaces. Have a look at the how the ACPI NFIT bus driver provides "nfit/" scoped sysfs attributes and tunnels "struct nd_cmd_pkg" ioctl invocations to either the bus or "dimm" level device objects. The dimm security model is an example of an implementation that wraps a libnvdimm-generic sysfs front-end to an intel-specific-device backend. It would be unfortunate to need to invent another ABI. 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 CCFC4C43331 for ; Wed, 1 Apr 2020 19:37:29 +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 0214D20719 for ; Wed, 1 Apr 2020 19:37:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b="mjcsWDpY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0214D20719 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com 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 48sxKx56N3zDrCv for ; Thu, 2 Apr 2020 06:37:25 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=intel.com (client-ip=2a00:1450:4864:20::543; helo=mail-ed1-x543.google.com; envelope-from=dan.j.williams@intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=mjcsWDpY; dkim-atps=neutral Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48sxJ33TPWzDqFM for ; Thu, 2 Apr 2020 06:35:42 +1100 (AEDT) Received: by mail-ed1-x543.google.com with SMTP id v1so1295050edq.8 for ; Wed, 01 Apr 2020 12:35:42 -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=Q3jSAO8i57DbvhBfb53ktHGZ2uMKAMcCW6E8VbEgc4s=; b=mjcsWDpYphXz5dA5YNqYJoMQpxtbcOHWMp/D9HjrzEb2TBLvYtHLQ9MiFW+MC+l57P McztFw8XSwIRuHgGHpF4R0SwzJjRZOnE0mnEcarYU9nFgLeBatSnCqiKCAhRbEt5OZ8i Ikd9F/1mTxVrHC966dn0DjsG2dA3wXrcjO6rHKNSUXQc+QEedR32ikkq/2y+h+2LN6Rp 1b/UVRVFzHbWQEEGLNg8s2v4TBr6j4ZtOv2qcrCl08DVT4Yv5pCFE0je/mn5MvrXJaCq NGs4XOjlcAYXJoRZu93V6/plTlNLjfDWwYkgkEj1O79FFtxtfIWXh79vagMVcIn26Hxa CVfA== 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=Q3jSAO8i57DbvhBfb53ktHGZ2uMKAMcCW6E8VbEgc4s=; b=knXDhF3b20vjI04a2YOEqcvTOqC4mG9SzkUULp3nMZ2MDtt5WX+472YjUuBOjmlICH 8SAdtJRWDxWQOHPSnZ2M/uENAu38lUEaJk6p8/JNT0oHXr0rc4sH23rcbYlAUTtFnPjf MaOTDF4ZqCsXjVy/KX8SOORjRfzF/oO4AXNUYe33rhWqeRqUTEVfuTFv6kQrNZ7hp99J 5XAzpqdE6dGG+/wn47xnaLgLvP5E2NyiKGVleThsQzhPxaHveB71GtUXJ4K4CBpeLccD 3UX9hRjQ0QM+sL6FIxyCoDKHQMfxla8Ej9ZdLHuqUG0JyFjsEMWLuSD/m+tXBxVF/XnL YDHw== X-Gm-Message-State: ANhLgQ3qK0qBLcLFE4Run2b5XOrR5SZnVDOfMSe4bZ3PJy7wra1oJsr1 m7TAUafwc06SU5RRJ06LkuGq03TsEp+xDpfD2TncNg== X-Google-Smtp-Source: ADFU+vs7zqcb4vYtw0JFFUp+7vrhUNZOxwvyZ/ygpmPkcp52KXyXZx+7nxypoK8JQD5UfIspTkuezkIGVj6J1IyuTkU= X-Received: by 2002:a17:906:dbd4:: with SMTP id yc20mr21657879ejb.335.1585769735476; Wed, 01 Apr 2020 12:35:35 -0700 (PDT) MIME-Version: 1.0 References: <20200327071202.2159885-1-alastair@d-silva.org> <20200327071202.2159885-11-alastair@d-silva.org> In-Reply-To: From: Dan Williams Date: Wed, 1 Apr 2020 12:35:24 -0700 Message-ID: Subject: Re: [PATCH v4 10/25] nvdimm: Add driver for OpenCAPI Persistent Memory To: "Alastair D'Silva" Content-Type: text/plain; charset="UTF-8" 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" On Wed, Apr 1, 2020 at 1:49 AM Dan Williams wrote: > > On Sun, Mar 29, 2020 at 10:23 PM Alastair D'Silva wrote: > > > > This driver exposes LPC memory on OpenCAPI pmem cards > > as an NVDIMM, allowing the existing nvram infrastructure > > to be used. > > > > Namespace metadata is stored on the media itself, so > > scm_reserve_metadata() maps 1 section's worth of PMEM storage > > at the start to hold this. The rest of the PMEM range is registered > > with libnvdimm as an nvdimm. ndctl_config_read/write/size() provide > > callbacks to libnvdimm to access the metadata. > > > > Signed-off-by: Alastair D'Silva > > --- > > drivers/nvdimm/Kconfig | 2 + > > drivers/nvdimm/Makefile | 1 + > > drivers/nvdimm/ocxl/Kconfig | 15 ++ > > drivers/nvdimm/ocxl/Makefile | 7 + > > drivers/nvdimm/ocxl/main.c | 476 +++++++++++++++++++++++++++++++++ > > drivers/nvdimm/ocxl/ocxlpmem.h | 23 ++ > > 6 files changed, 524 insertions(+) > > create mode 100644 drivers/nvdimm/ocxl/Kconfig > > create mode 100644 drivers/nvdimm/ocxl/Makefile > > create mode 100644 drivers/nvdimm/ocxl/main.c > > create mode 100644 drivers/nvdimm/ocxl/ocxlpmem.h > > > > diff --git a/drivers/nvdimm/Kconfig b/drivers/nvdimm/Kconfig > > index b7d1eb38b27d..368328637182 100644 > > --- a/drivers/nvdimm/Kconfig > > +++ b/drivers/nvdimm/Kconfig > > @@ -131,4 +131,6 @@ config NVDIMM_TEST_BUILD > > core devm_memremap_pages() implementation and other > > infrastructure. > > > > +source "drivers/nvdimm/ocxl/Kconfig" > > + > > endif > > diff --git a/drivers/nvdimm/Makefile b/drivers/nvdimm/Makefile > > index 29203f3d3069..bc02be11c794 100644 > > --- a/drivers/nvdimm/Makefile > > +++ b/drivers/nvdimm/Makefile > > @@ -33,3 +33,4 @@ libnvdimm-$(CONFIG_NVDIMM_KEYS) += security.o > > TOOLS := ../../tools > > TEST_SRC := $(TOOLS)/testing/nvdimm/test > > obj-$(CONFIG_NVDIMM_TEST_BUILD) += $(TEST_SRC)/iomap.o > > +obj-$(CONFIG_LIBNVDIMM) += ocxl/ > > diff --git a/drivers/nvdimm/ocxl/Kconfig b/drivers/nvdimm/ocxl/Kconfig > > new file mode 100644 > > index 000000000000..c5d927520920 > > --- /dev/null > > +++ b/drivers/nvdimm/ocxl/Kconfig > > @@ -0,0 +1,15 @@ > > +# SPDX-License-Identifier: GPL-2.0-only > > +if LIBNVDIMM > > + > > +config OCXL_PMEM > > + tristate "OpenCAPI Persistent Memory" > > + depends on LIBNVDIMM && PPC_POWERNV && PCI && EEH && ZONE_DEVICE && OCXL > > Does OXCL_PMEM itself have any CONFIG_ZONE_DEVICE dependencies? That's > more a function of CONFIG_DEV_DAX and CONFIG_FS_DAX. Doesn't OCXL > already depend on CONFIG_PCI? > > > > + help > > + Exposes devices that implement the OpenCAPI Storage Class Memory > > + specification as persistent memory regions. You may also want > > + DEV_DAX, DEV_DAX_PMEM & FS_DAX if you plan on using DAX devices > > + stacked on top of this driver. > > + > > + Select N if unsure. > > + > > +endif > > diff --git a/drivers/nvdimm/ocxl/Makefile b/drivers/nvdimm/ocxl/Makefile > > new file mode 100644 > > index 000000000000..e0e8ade1987a > > --- /dev/null > > +++ b/drivers/nvdimm/ocxl/Makefile > > @@ -0,0 +1,7 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > + > > +ccflags-$(CONFIG_PPC_WERROR) += -Werror > > + > > +obj-$(CONFIG_OCXL_PMEM) += ocxlpmem.o > > + > > +ocxlpmem-y := main.o > > \ No newline at end of file > > diff --git a/drivers/nvdimm/ocxl/main.c b/drivers/nvdimm/ocxl/main.c > > new file mode 100644 > > index 000000000000..c0066fedf9cc > > --- /dev/null > > +++ b/drivers/nvdimm/ocxl/main.c > > @@ -0,0 +1,476 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +// Copyright 2020 IBM Corp. > > + > > +/* > > + * A driver for OpenCAPI devices that implement the Storage Class > > + * Memory specification. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include "ocxlpmem.h" > > + > > +static const struct pci_device_id pci_tbl[] = { > > + { PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x0625), }, > > + { } > > +}; > > + > > +MODULE_DEVICE_TABLE(pci, pci_tbl); > > + > > +#define NUM_MINORS 256 // Total to reserve > > + > > +static dev_t ocxlpmem_dev; > > +static struct class *ocxlpmem_class; > > +static struct mutex minors_idr_lock; > > +static struct idr minors_idr; > > + > > +/** > > + * ndctl_config_write() - Handle a ND_CMD_SET_CONFIG_DATA command from ndctl > > + * @ocxlpmem: the device metadata > > + * @command: the incoming data to write > > + * Return: 0 on success, negative on failure > > + */ > > +static int ndctl_config_write(struct ocxlpmem *ocxlpmem, > > + struct nd_cmd_set_config_hdr *command) > > +{ > > + if (command->in_offset + command->in_length > LABEL_AREA_SIZE) > > + return -EINVAL; > > + > > + memcpy_flushcache(ocxlpmem->metadata_addr + command->in_offset, > > + command->in_buf, command->in_length); > > + > > + return 0; > > +} > > + > > +/** > > + * ndctl_config_read() - Handle a ND_CMD_GET_CONFIG_DATA command from ndctl > > + * @ocxlpmem: the device metadata > > + * @command: the read request > > + * Return: 0 on success, negative on failure > > + */ > > +static int ndctl_config_read(struct ocxlpmem *ocxlpmem, > > + struct nd_cmd_get_config_data_hdr *command) > > +{ > > + if (command->in_offset + command->in_length > LABEL_AREA_SIZE) > > + return -EINVAL; > > + > > + memcpy_mcsafe(command->out_buf, > > + ocxlpmem->metadata_addr + command->in_offset, > > + command->in_length); > > + > > + return 0; > > +} > > + > > +/** > > + * ndctl_config_size() - Handle a ND_CMD_GET_CONFIG_SIZE command from ndctl > > + * @command: the read request > > + * Return: 0 on success, negative on failure > > + */ > > +static int ndctl_config_size(struct nd_cmd_get_config_size *command) > > +{ > > + command->status = 0; > > + command->config_size = LABEL_AREA_SIZE; > > + command->max_xfer = PAGE_SIZE; > > + > > + return 0; > > +} > > + > > +static int ndctl(struct nvdimm_bus_descriptor *nd_desc, > > + struct nvdimm *nvdimm, > > + unsigned int cmd, void *buf, unsigned int buf_len, int *cmd_rc) > > +{ > > + struct ocxlpmem *ocxlpmem = container_of(nd_desc, > > + struct ocxlpmem, bus_desc); > > + > > + switch (cmd) { > > + case ND_CMD_GET_CONFIG_SIZE: > > + *cmd_rc = ndctl_config_size(buf); > > + return 0; > > + > > + case ND_CMD_GET_CONFIG_DATA: > > + *cmd_rc = ndctl_config_read(ocxlpmem, buf); > > + return 0; > > + > > + case ND_CMD_SET_CONFIG_DATA: > > + *cmd_rc = ndctl_config_write(ocxlpmem, buf); > > + return 0; > > + > > + default: > > + return -ENOTTY; > > + } > > +} > > + > > +/** > > + * reserve_metadata() - Reserve space for nvdimm metadata > > + * @ocxlpmem: the device metadata > > + * @lpc_mem: The resource representing the LPC memory of the OpenCAPI device > > + */ > > +static int reserve_metadata(struct ocxlpmem *ocxlpmem, > > + struct resource *lpc_mem) > > +{ > > + ocxlpmem->metadata_addr = devm_memremap(&ocxlpmem->dev, lpc_mem->start, > > + LABEL_AREA_SIZE, MEMREMAP_WB); > > + if (IS_ERR(ocxlpmem->metadata_addr)) > > + return PTR_ERR(ocxlpmem->metadata_addr); > > + > > + return 0; > > +} > > + > > +/** > > + * register_lpc_mem() - Discover persistent memory on a device and register it with the NVDIMM subsystem > > + * @ocxlpmem: the device metadata > > + * Return: 0 on success > > + */ > > +static int register_lpc_mem(struct ocxlpmem *ocxlpmem) > > +{ > > + struct nd_region_desc region_desc; > > + struct nd_mapping_desc nd_mapping_desc; > > + struct resource *lpc_mem; > > + const struct ocxl_afu_config *config; > > + const struct ocxl_fn_config *fn_config; > > + int rc; > > + unsigned long nvdimm_cmd_mask = 0; > > + unsigned long nvdimm_flags = 0; > > + int target_node; > > + char serial[16 + 1]; > > + > > + // Set up the reserved metadata area > > + rc = ocxl_afu_map_lpc_mem(ocxlpmem->ocxl_afu); > > + if (rc < 0) > > + return rc; > > + > > + lpc_mem = ocxl_afu_lpc_mem(ocxlpmem->ocxl_afu); > > + if (!lpc_mem || !lpc_mem->start) > > + return -EINVAL; > > + > > + config = ocxl_afu_config(ocxlpmem->ocxl_afu); > > + fn_config = ocxl_function_config(ocxlpmem->ocxl_fn); > > + > > + rc = reserve_metadata(ocxlpmem, lpc_mem); > > + if (rc) > > + return rc; > > + > > + ocxlpmem->bus_desc.provider_name = "ocxlpmem"; > > + ocxlpmem->bus_desc.ndctl = ndctl; > > + ocxlpmem->bus_desc.module = THIS_MODULE; > > + > > + ocxlpmem->nvdimm_bus = nvdimm_bus_register(&ocxlpmem->dev, > > + &ocxlpmem->bus_desc); > > + if (!ocxlpmem->nvdimm_bus) > > + return -EINVAL; > > + > > + ocxlpmem->pmem_res.start = (u64)lpc_mem->start + LABEL_AREA_SIZE; > > + ocxlpmem->pmem_res.end = (u64)lpc_mem->start + config->lpc_mem_size - 1; > > + ocxlpmem->pmem_res.name = "OpenCAPI persistent memory"; > > + > > + set_bit(ND_CMD_GET_CONFIG_SIZE, &nvdimm_cmd_mask); > > + set_bit(ND_CMD_GET_CONFIG_DATA, &nvdimm_cmd_mask); > > + set_bit(ND_CMD_SET_CONFIG_DATA, &nvdimm_cmd_mask); > > + > > + set_bit(NDD_ALIASING, &nvdimm_flags); > > + > > + snprintf(serial, sizeof(serial), "%llx", fn_config->serial); > > + nd_mapping_desc.nvdimm = nvdimm_create(ocxlpmem->nvdimm_bus, ocxlpmem, > > + NULL, nvdimm_flags, > > + nvdimm_cmd_mask, 0, NULL); > > + if (!nd_mapping_desc.nvdimm) > > + return -ENOMEM; > > + > > + if (nvdimm_bus_check_dimm_count(ocxlpmem->nvdimm_bus, 1)) > > + return -EINVAL; > > + > > + nd_mapping_desc.start = ocxlpmem->pmem_res.start; > > + nd_mapping_desc.size = resource_size(&ocxlpmem->pmem_res); > > + nd_mapping_desc.position = 0; > > + > > + ocxlpmem->nd_set.cookie1 = fn_config->serial; > > + ocxlpmem->nd_set.cookie2 = fn_config->serial; > > + > > + target_node = of_node_to_nid(ocxlpmem->pdev->dev.of_node); > > + > > + memset(®ion_desc, 0, sizeof(region_desc)); > > + region_desc.res = &ocxlpmem->pmem_res; > > + region_desc.numa_node = NUMA_NO_NODE; > > + region_desc.target_node = target_node; > > + region_desc.num_mappings = 1; > > + region_desc.mapping = &nd_mapping_desc; > > + region_desc.nd_set = &ocxlpmem->nd_set; > > + > > + set_bit(ND_REGION_PAGEMAP, ®ion_desc.flags); > > + /* > > + * NB: libnvdimm copies the data from ndr_desc into it's own > > + * structures so passing a stack pointer is fine. > > + */ > > + ocxlpmem->nd_region = nvdimm_pmem_region_create(ocxlpmem->nvdimm_bus, > > + ®ion_desc); > > + if (!ocxlpmem->nd_region) > > + return -EINVAL; > > + > > + dev_info(&ocxlpmem->dev, > > + "Onlining %lluMB of persistent memory\n", > > + nd_mapping_desc.size / SZ_1M); > > + > > + return 0; > > +} > > + > > +/** > > + * allocate_minor() - Allocate a minor number to use for an OpenCAPI pmem device > > + * @ocxlpmem: the device metadata > > + * Return: the allocated minor number > > + */ > > +static int allocate_minor(struct ocxlpmem *ocxlpmem) > > +{ > > + int minor; > > + > > + mutex_lock(&minors_idr_lock); > > + minor = idr_alloc(&minors_idr, ocxlpmem, 0, NUM_MINORS, GFP_KERNEL); > > + mutex_unlock(&minors_idr_lock); > > + return minor; > > +} > > + > > +static void free_minor(struct ocxlpmem *ocxlpmem) > > +{ > > + mutex_lock(&minors_idr_lock); > > + idr_remove(&minors_idr, MINOR(ocxlpmem->dev.devt)); > > + mutex_unlock(&minors_idr_lock); > > +} > > + > > +/** > > + * free_ocxlpmem() - Free all members of an ocxlpmem struct > > + * @ocxlpmem: the device struct to clear > > + */ > > +static void free_ocxlpmem(struct ocxlpmem *ocxlpmem) > > +{ > > + int rc; > > + > > + free_minor(ocxlpmem); > > + > > + if (ocxlpmem->ocxl_context) { > > + rc = ocxl_context_detach(ocxlpmem->ocxl_context); > > + if (rc == -EBUSY) > > + dev_warn(&ocxlpmem->dev, "Timeout detaching ocxl context\n"); > > + else > > + ocxl_context_free(ocxlpmem->ocxl_context); > > + } > > + > > + if (ocxlpmem->ocxl_afu) > > + ocxl_afu_put(ocxlpmem->ocxl_afu); > > + > > + if (ocxlpmem->ocxl_fn) > > + ocxl_function_close(ocxlpmem->ocxl_fn); > > + > > + pci_dev_put(ocxlpmem->pdev); > > + > > + kfree(ocxlpmem); > > +} > > + > > +/** > > + * free_ocxlpmem_dev() - Free an OpenCAPI persistent memory device > > + * @dev: The device struct > > + */ > > +static void free_ocxlpmem_dev(struct device *dev) > > +{ > > + struct ocxlpmem *ocxlpmem = container_of(dev, struct ocxlpmem, dev); > > + > > + free_ocxlpmem(ocxlpmem); > > +} > > + > > +/** > > + * ocxlpmem_register() - Register an OpenCAPI pmem device with the kernel > > + * @ocxlpmem: the device metadata > > + * Return: 0 on success, negative on failure > > + */ > > +static int ocxlpmem_register(struct ocxlpmem *ocxlpmem) > > +{ > > + int rc; > > + int minor = allocate_minor(ocxlpmem); > > + > > + if (minor < 0) > > + return minor; > > + > > + ocxlpmem->dev.release = free_ocxlpmem_dev; > > + rc = dev_set_name(&ocxlpmem->dev, "ocxlpmem%d", minor); > > + if (rc < 0) > > + return rc; > > + > > + ocxlpmem->dev.devt = MKDEV(MAJOR(ocxlpmem_dev), minor); > > + ocxlpmem->dev.class = ocxlpmem_class; > > + ocxlpmem->dev.parent = &ocxlpmem->pdev->dev; > > + > > + return device_register(&ocxlpmem->dev); > > You lost me, why does this need it's own ioctl path and device node? > I'd expect you you'd tunnel the commands you need through the existing > infrastructure ideally with an eye for cross-arch compatibility. This > is a fundamental concern that probably has significant implications > for what follows. At a minimum this device registration should move to the end of the patchset once all the libnvdimm generic enabling is done. Even then I think the libnvdimm core has all the hooks you need to provide device specific enabling *through* the existing interfaces. Have a look at the how the ACPI NFIT bus driver provides "nfit/" scoped sysfs attributes and tunnels "struct nd_cmd_pkg" ioctl invocations to either the bus or "dimm" level device objects. The dimm security model is an example of an implementation that wraps a libnvdimm-generic sysfs front-end to an intel-specific-device backend. It would be unfortunate to need to invent another ABI.