Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2109356ybb; Sun, 29 Mar 2020 22:53:50 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs9G+ZlwkGwxFL2LOdJE8W7ukiM6Fwzgpmfe843v1RK+5HGadw6FdGu9SgJ16N2KwGTE3sZ X-Received: by 2002:aca:ea05:: with SMTP id i5mr6772283oih.162.1585547630031; Sun, 29 Mar 2020 22:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585547630; cv=none; d=google.com; s=arc-20160816; b=ogkV+T4MimJMfdyKrEaHsOgWPgUHMYTkSq42VbCVPEaOPOFRYWjgYE8+eIzgepJ5vB BrtZtqOflsZqBDylx6qW8osLXbbaM48a3K/1twwYDmmeupal36AXr/AZl57WE223g2O/ y+krnV7/aSrDQIxeuPWfkhQbR9Pnu9SyBawnUiYfTfgJimwnvd/OqTJ74iChyjmjxBw6 FG9o2p81qWY7rvGXpfzQ8YDexlOv0cxVuz88OObwqggSHFAmEhE1Lus1O+K6ANp5CZxM gusS8+/plHcOLmdnHjDvJ/EFfBxKjmQRHCdhwXaRo6hpu5fUTw+/iIBUZLwwU3PYYMMo ISug== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4mdJclo+1ql++wbStxBqZWbod2IW7cGy1g5ahXn7bO8=; b=rcu7mlgbdOMX2bUJTGo67vyVPn0uHZEDlS7ALyuL44ddYOMphHa20pFvuX0Qbt4xQn e6MZpCBY7XFid01TOQmwpTlh5iaoI+nmSuQyW8BmgiJiDMjFbYjF0CyyAfvfvawHa0Ut C8myeuSr1SsNybR6fRCeorDM+dw2VndmQlKlWVDG6cA+gAKgPzt35ndJ+8aCZQIEz/SK K/u/sev5v4PJ4Wg8dEF5AOdav0JDoFpLYaVpQk/UKA3PbGkwcMM6aiE1ZDLLjGJQEOyp ytL1EQooNBH4IGu/QtxYjXLLf9kuXseBepUvb83SKJbhOxGXH1eeSAmn0hhXzI8zZhRk nYXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@d-silva.org header.s=201810a header.b=QzIshqlF; 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 m2si5859434oof.17.2020.03.29.22.53.38; Sun, 29 Mar 2020 22:53:50 -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=@d-silva.org header.s=201810a header.b=QzIshqlF; 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 S1728773AbgC3FxF (ORCPT + 99 others); Mon, 30 Mar 2020 01:53:05 -0400 Received: from ushosting.nmnhosting.com ([66.55.73.32]:37400 "EHLO ushosting.nmnhosting.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728760AbgC3FxE (ORCPT ); Mon, 30 Mar 2020 01:53:04 -0400 Received: from mail2.nmnhosting.com (unknown [202.169.106.97]) by ushosting.nmnhosting.com (Postfix) with ESMTPS id 1A36B2DC685C; Mon, 30 Mar 2020 16:52:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=d-silva.org; s=201810a; t=1585547571; bh=7micxHdia2GvvQ4mY81c4jBHOqLOZ0TeAcVaPQleunM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QzIshqlFp53qA4DB8IAUutZabSbcugvEaXNKxzsAZpWDALJWJPENQ0mvFoELV93rV xBDyaQhfw6Fw/7rbXS8HW2uZrWtaFnR2MvhNnl6jlQdn02p7u/PmP6ztacNKbuPyu9 85tmlez/p2Zxt6TIwBFgAqzZRWTRiMnUh4iIZthtCkmm6j6qHrQe0olItNDpyXKcuu yrr563UM5DgGMo6LV7xzIIBif4ulFgC+/HkkjRqErrlhMI7zkwkMcxgPJBNiKUJris O3eIA6Pue08VWVHyK7Rqs/DxlrIVWcyA5LmzmtJO8eECSw88MVxEtfzv905BcPf3kH cMJ/o5fgzi/txiWRyh4RECCqzSOxZASTGF+B4aKQY9yDgE8tWr1RSDdkAgN9l5T7gK XufI3qOWi3HWntScxvoGIljl4WlGsy2jHNnAP16md7cjStgYPxE+MIOngRuFz9G+ot B0ZpigPUtr4kS4a5Zk/lekbvhIphRoTyFEEg27ngbAd4+R0Pdpi/03ray/974q6DRP oj9yVUBjNPWt7kNYNnilPCHMODV6tOeY6nPwnd/5fUVYpIYO/0G0qRYicw3MoB+cMo WNBBCFdNMn/eXciPsYoJgPiHCgAWonEXwlOPPECDtSKn/8ZevQqjdlygOvDl330WrX giiKa7eoY/kFQHdeCMxIcNVE= Received: from localhost.lan ([10.0.1.179]) by mail2.nmnhosting.com (8.15.2/8.15.2) with ESMTP id 02R7C4Ax045934; Fri, 27 Mar 2020 18:12:20 +1100 (AEDT) (envelope-from alastair@d-silva.org) From: "Alastair D'Silva" To: alastair@d-silva.org Cc: "Aneesh Kumar K . V" , "Oliver O'Halloran" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Frederic Barrat , Andrew Donnellan , Arnd Bergmann , Greg Kroah-Hartman , Dan Williams , 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=20Le=20Goater?= , Anju T Sudhakar , Hari Bathini , Thomas Gleixner , Greg Kurz , Nicholas Piggin , Masahiro Yamada , Alexey Kardashevskiy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-nvdimm@lists.01.org, linux-mm@kvack.org Subject: [PATCH v4 24/25] nvdimm/ocxl: Expose the serial number & firmware version in sysfs Date: Fri, 27 Mar 2020 18:12:01 +1100 Message-Id: <20200327071202.2159885-25-alastair@d-silva.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200327071202.2159885-1-alastair@d-silva.org> References: <20200327071202.2159885-1-alastair@d-silva.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mail2.nmnhosting.com [10.0.1.20]); Fri, 27 Mar 2020 18:12:20 +1100 (AEDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch exposes the serial number & firmware version in sysfs, which will be used by ndctl in userspace to help users identify the device. Signed-off-by: Alastair D'Silva --- drivers/nvdimm/ocxl/main.c | 42 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/nvdimm/ocxl/main.c b/drivers/nvdimm/ocxl/main.c index 92b4389e8cbb..1f422f0d51ef 100644 --- a/drivers/nvdimm/ocxl/main.c +++ b/drivers/nvdimm/ocxl/main.c @@ -235,6 +235,43 @@ static int reserve_metadata(struct ocxlpmem *ocxlpmem, return 0; } +static ssize_t serial_show(struct device *device, struct device_attribute *attr, + char *buf) +{ + struct nvdimm *nvdimm = to_nvdimm(device); + struct ocxlpmem *ocxlpmem = nvdimm_provider_data(nvdimm); + const struct ocxl_fn_config *fn_config = ocxl_function_config(ocxlpmem->ocxl_fn); + + return scnprintf(buf, PAGE_SIZE, "%llu\n", fn_config->serial); +} +static DEVICE_ATTR_RO(serial); + +static ssize_t fw_version_show(struct device *device, + struct device_attribute *attr, char *buf) +{ + struct nvdimm *nvdimm = to_nvdimm(device); + struct ocxlpmem *ocxlpmem = nvdimm_provider_data(nvdimm); + + return scnprintf(buf, PAGE_SIZE, "%s\n", ocxlpmem->fw_version); +} +static DEVICE_ATTR_RO(fw_version); + +static struct attribute *ocxl_pmem_attrs[] = { + &dev_attr_serial.attr, + &dev_attr_fw_version.attr, + NULL, +}; + +static const struct attribute_group ocxl_pmem_attribute_group = { + .name = "ocxlpmem", + .attrs = ocxl_pmem_attrs, +}; + +static const struct attribute_group *ocxl_pmem_dimm_attribute_groups[] = { + &ocxl_pmem_attribute_group, + NULL, +}; + /** * register_lpc_mem() - Discover persistent memory on a device and register it with the NVDIMM subsystem * @ocxlpmem: the device metadata @@ -291,8 +328,9 @@ static int register_lpc_mem(struct ocxlpmem *ocxlpmem) 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); + ocxl_pmem_dimm_attribute_groups, + nvdimm_flags, nvdimm_cmd_mask, 0, + NULL); if (!nd_mapping_desc.nvdimm) return -ENOMEM; -- 2.24.1