From patchwork Thu May 13 06:12:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 12255189 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 51995C433ED for ; Thu, 13 May 2021 06:13:00 +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 D582B60241 for ; Thu, 13 May 2021 06:12:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D582B60241 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fossix.org 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 86527100EAB45; Wed, 12 May 2021 23:12:59 -0700 (PDT) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::432; helo=mail-pf1-x432.google.com; envelope-from=santosh@fossix.org; receiver= Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (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 1FBA2100F2255 for ; Wed, 12 May 2021 23:12:56 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d16so29007pfn.12 for ; Wed, 12 May 2021 23:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fossix-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ldw0NnK3agDWj5ekHEK7g3s2gQc83F6iEQZ6tWXyceE=; b=WrHDms0Ge1qmsG4tvkPF9OplzevscfoekilJH7S4sRJ1D0LHXO3lYPcBnL3MShyupm KO6cZFV5otrYIGLNBwyzVwowqCUMOOk32PDWRfKI74gA2om29seEyICSBNCxv7ZSpaww TAMVu48XzEu3G0Nh4k6BKWQE7cImCcqwGMFYnBtcimebJwnIa3AzqwlYzlhAztkd5xLQ l1kt3h2n5GPNRn5DuwpoHqAaKDorW7ripsAPdYno+RGWCp+A3tDn5gVXWSEEobq8d4l0 fq7DOQoUh4qyHnpRHLZC6dSedyB9KlK85MscJTHgs8d98VVxewhQ/UxP9M2LL3QnnHdA nAZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ldw0NnK3agDWj5ekHEK7g3s2gQc83F6iEQZ6tWXyceE=; b=O2naGG7ftomhiY39k7JUbvnOTqy843LlpbydmOXgcSoeg7EuhbioPJni1oShaHyzwy 9WT90lWVWDa2Q45FUNmn+IstRYbCFtjQ7QAvzTNe3nGl1+UgwP744+jbg2/EmpnegPtL 7SVDwYTRxqeAqh4KJfyFgNM0lmWwZp1MYOkiBJk9tAMKF9qH3jbwi2GRy4CNFaOuk0eg BoBp/of7q/NBvjkfxC0F2i4q/so4sTP9iSaXC1VONnpxpvjyzvJSKJKoF6mbN2ytTyEk fq6DkGc+lL6/QN1QSepFiCPqYcniLLNV1fP3+eiQB9WXAr2Jswv+JozEiBRVfg85FDZi S05A== X-Gm-Message-State: AOAM531Nfix9j+pdEzj0GtnxPMq9wFiukMaOwWwEytf87hxEJT7biS4d I+u9U7k8fUXCdEJtHZUynbcGKxkf+mIWDg== X-Google-Smtp-Source: ABdhPJyvcssk8zpTEplnbwns66QmjtQ/D4SCka+PiCMKW0jcBQUMQRWHUZCMQ+yikODrC42ID5FX/A== X-Received: by 2002:a65:6402:: with SMTP id a2mr4864749pgv.49.1620886376062; Wed, 12 May 2021 23:12:56 -0700 (PDT) Received: from desktop.fossix.local ([103.21.79.4]) by smtp.gmail.com with ESMTPSA id gf21sm1422351pjb.20.2021.05.12.23.12.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 23:12:55 -0700 (PDT) From: Santosh Sivaraj To: Linux NVDIMM Subject: [ndctl V5 1/4] libndctl: Unify adding dimms for papr and nfit families Date: Thu, 13 May 2021 11:42:15 +0530 Message-Id: <20210513061218.760322-1-santosh@fossix.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Message-ID-Hash: L3K6KSWO2SMAMQA45WZM5EHYE63TQUVG X-Message-ID-Hash: L3K6KSWO2SMAMQA45WZM5EHYE63TQUVG X-MailFrom: santosh@fossix.org 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: Shivaprasad G Bhat , Harish Sriram , "Aneesh Kumar K.V" 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: In preparation for enabling tests on non-nfit devices, unify both, already very similar, functions into one. This will help in adding all attributes needed for the unit tests. Since the function doesn't fail if some of the dimm attributes are missing, this will work fine on PAPR platforms though only part of the DIMM attributes are provided (This doesn't mean that all of the DIMM attributes can be missing). Signed-off-by: Santosh Sivaraj --- ndctl/lib/libndctl.c | 103 ++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 65 deletions(-) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 36fb6fe..26b9317 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -1646,41 +1646,9 @@ static int ndctl_bind(struct ndctl_ctx *ctx, struct kmod_module *module, static int ndctl_unbind(struct ndctl_ctx *ctx, const char *devpath); static struct kmod_module *to_module(struct ndctl_ctx *ctx, const char *alias); -static int add_papr_dimm(struct ndctl_dimm *dimm, const char *dimm_base) -{ - int rc = -ENODEV; - char buf[SYSFS_ATTR_SIZE]; - struct ndctl_ctx *ctx = dimm->bus->ctx; - char *path = calloc(1, strlen(dimm_base) + 100); - const char * const devname = ndctl_dimm_get_devname(dimm); - - dbg(ctx, "%s: Probing of_pmem dimm at %s\n", devname, dimm_base); - - if (!path) - return -ENOMEM; - - /* construct path to the papr compatible dimm flags file */ - sprintf(path, "%s/papr/flags", dimm_base); - - if (ndctl_bus_is_papr_scm(dimm->bus) && - sysfs_read_attr(ctx, path, buf) == 0) { - - dbg(ctx, "%s: Adding papr-scm dimm flags:\"%s\"\n", devname, buf); - dimm->cmd_family = NVDIMM_FAMILY_PAPR; - - /* Parse dimm flags */ - parse_papr_flags(dimm, buf); - - /* Allocate monitor mode fd */ - dimm->health_eventfd = open(path, O_RDONLY|O_CLOEXEC); - rc = 0; - } - - free(path); - return rc; -} - -static int add_nfit_dimm(struct ndctl_dimm *dimm, const char *dimm_base) +static int populate_dimm_attributes(struct ndctl_dimm *dimm, + const char *dimm_base, + const char *bus_prefix) { int i, rc = -1; char buf[SYSFS_ATTR_SIZE]; @@ -1694,7 +1662,7 @@ static int add_nfit_dimm(struct ndctl_dimm *dimm, const char *dimm_base) * 'unique_id' may not be available on older kernels, so don't * fail if the read fails. */ - sprintf(path, "%s/nfit/id", dimm_base); + sprintf(path, "%s/%s/id", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) == 0) { unsigned int b[9]; @@ -1709,68 +1677,74 @@ static int add_nfit_dimm(struct ndctl_dimm *dimm, const char *dimm_base) } } - sprintf(path, "%s/nfit/handle", dimm_base); + sprintf(path, "%s/%s/handle", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) < 0) goto err_read; dimm->handle = strtoul(buf, NULL, 0); - sprintf(path, "%s/nfit/phys_id", dimm_base); + sprintf(path, "%s/%s/phys_id", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) < 0) goto err_read; dimm->phys_id = strtoul(buf, NULL, 0); - sprintf(path, "%s/nfit/serial", dimm_base); + sprintf(path, "%s/%s/serial", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) == 0) dimm->serial = strtoul(buf, NULL, 0); - sprintf(path, "%s/nfit/vendor", dimm_base); + sprintf(path, "%s/%s/vendor", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) == 0) dimm->vendor_id = strtoul(buf, NULL, 0); - sprintf(path, "%s/nfit/device", dimm_base); + sprintf(path, "%s/%s/device", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) == 0) dimm->device_id = strtoul(buf, NULL, 0); - sprintf(path, "%s/nfit/rev_id", dimm_base); + sprintf(path, "%s/%s/rev_id", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) == 0) dimm->revision_id = strtoul(buf, NULL, 0); - sprintf(path, "%s/nfit/dirty_shutdown", dimm_base); + sprintf(path, "%s/%s/dirty_shutdown", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) == 0) dimm->dirty_shutdown = strtoll(buf, NULL, 0); - sprintf(path, "%s/nfit/subsystem_vendor", dimm_base); + sprintf(path, "%s/%s/subsystem_vendor", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) == 0) dimm->subsystem_vendor_id = strtoul(buf, NULL, 0); - sprintf(path, "%s/nfit/subsystem_device", dimm_base); + sprintf(path, "%s/%s/subsystem_device", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) == 0) dimm->subsystem_device_id = strtoul(buf, NULL, 0); - sprintf(path, "%s/nfit/subsystem_rev_id", dimm_base); + sprintf(path, "%s/%s/subsystem_rev_id", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) == 0) dimm->subsystem_revision_id = strtoul(buf, NULL, 0); - sprintf(path, "%s/nfit/family", dimm_base); + sprintf(path, "%s/%s/family", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) == 0) dimm->cmd_family = strtoul(buf, NULL, 0); - sprintf(path, "%s/nfit/dsm_mask", dimm_base); + sprintf(path, "%s/%s/dsm_mask", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) == 0) dimm->nfit_dsm_mask = strtoul(buf, NULL, 0); - sprintf(path, "%s/nfit/format", dimm_base); + sprintf(path, "%s/%s/format", dimm_base, bus_prefix); if (sysfs_read_attr(ctx, path, buf) == 0) dimm->format[0] = strtoul(buf, NULL, 0); for (i = 1; i < dimm->formats; i++) { - sprintf(path, "%s/nfit/format%d", dimm_base, i); + sprintf(path, "%s/%s/format%d", dimm_base, bus_prefix, i); if (sysfs_read_attr(ctx, path, buf) == 0) dimm->format[i] = strtoul(buf, NULL, 0); } - sprintf(path, "%s/nfit/flags", dimm_base); - if (sysfs_read_attr(ctx, path, buf) == 0) - parse_nfit_mem_flags(dimm, buf); + sprintf(path, "%s/%s/flags", dimm_base, bus_prefix); + if (sysfs_read_attr(ctx, path, buf) == 0) { + if (ndctl_bus_has_nfit(dimm->bus)) + parse_nfit_mem_flags(dimm, buf); + else if (ndctl_bus_is_papr_scm(dimm->bus)) { + dimm->cmd_family = NVDIMM_FAMILY_PAPR; + parse_papr_flags(dimm, buf); + } + } dimm->health_eventfd = open(path, O_RDONLY|O_CLOEXEC); rc = 0; @@ -1792,7 +1766,8 @@ static void *add_dimm(void *parent, int id, const char *dimm_base) if (!path) return NULL; - sprintf(path, "%s/nfit/formats", dimm_base); + sprintf(path, "%s/%s/formats", dimm_base, + ndctl_bus_has_nfit(bus) ? "nfit" : "papr"); if (sysfs_read_attr(ctx, path, buf) < 0) formats = 1; else @@ -1866,13 +1841,12 @@ static void *add_dimm(void *parent, int id, const char *dimm_base) else dimm->fwa_result = fwa_result_to_result(buf); + dimm->formats = formats; /* Check if the given dimm supports nfit */ if (ndctl_bus_has_nfit(bus)) { - dimm->formats = formats; - rc = add_nfit_dimm(dimm, dimm_base); - } else if (ndctl_bus_has_of_node(bus)) { - rc = add_papr_dimm(dimm, dimm_base); - } + rc = populate_dimm_attributes(dimm, dimm_base, "nfit"); + } else if (ndctl_bus_has_of_node(bus)) + rc = populate_dimm_attributes(dimm, dimm_base, "papr"); if (rc == -ENODEV) { /* Unprobed dimm with no family */ @@ -2531,13 +2505,12 @@ static void *add_region(void *parent, int id, const char *region_base) goto err_read; region->num_mappings = strtoul(buf, NULL, 0); - sprintf(path, "%s/nfit/range_index", region_base); - if (ndctl_bus_has_nfit(bus)) { - if (sysfs_read_attr(ctx, path, buf) < 0) - goto err_read; - region->range_index = strtoul(buf, NULL, 0); - } else + sprintf(path, "%s/%s/range_index", region_base, + ndctl_bus_has_nfit(bus) ? "nfit": "papr"); + if (sysfs_read_attr(ctx, path, buf) < 0) region->range_index = -1; + else + region->range_index = strtoul(buf, NULL, 0); sprintf(path, "%s/read_only", region_base); if (sysfs_read_attr(ctx, path, buf) < 0) From patchwork Thu May 13 06:12:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 12255191 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 4756AC433B4 for ; Thu, 13 May 2021 06:13:04 +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 D8709613C2 for ; Thu, 13 May 2021 06:13:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D8709613C2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fossix.org 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 A4F12100EAB4B; Wed, 12 May 2021 23:13:03 -0700 (PDT) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::535; helo=mail-pg1-x535.google.com; envelope-from=santosh@fossix.org; receiver= Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) (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 798B8100EAB48 for ; Wed, 12 May 2021 23:13:00 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id j12so14285455pgh.7 for ; Wed, 12 May 2021 23:13:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fossix-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=21lF0kFww8u+VQRqFv9/mONMyiJ9ESesCkeF8U+Ure4=; b=t4nBKJK29RuIQerNTRt5gqs5rZjBY7vcnB71ADMObfZE5aW2GlwsEgw+nWZOspC3EO qPf7Fq7H3WSQOynXzBiXzkiCJc9EDdkdLviMXuDM1EnDwZRr3ibwOGhD9YsdJaKmE4yZ aOIh4YljBWlEg9gguWXfudHZN44elTFYsqMEhLYudBsLauBt7xcuBbkBIbD67ROa2CwO F24vSererafiCs3k2l29IHC/r53/GYCRszqfuOrcpzAXh8hTtKkHc51fe7n8oMSEMI6G GBmaBe73EOG2OXtkIntghdi3ftj3XnE+RQE30c/N/HTWQ8GgYArubgzS1kYqQ7iO4TkC o9MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=21lF0kFww8u+VQRqFv9/mONMyiJ9ESesCkeF8U+Ure4=; b=NP1pOn9oYjba90j6HsqQWA0rvSC58Wr42C10zTMwfss20XgA2I/9L+U3Gsq0sUCLYu YR4dL8WTAjKJuNwRFLX++4qjkWsnS4VYTMXPPEVX1oR2kwWotSScHr3DfaUMZKdx9U9e x+IHNeEuOFkEyrkKDL3NF5hGcIDfl0dVa0Ttm6Q11Y5xCzfRTW/imFx/Z+Fb7xRkYjUJ +AaIMq7SIz/btCy3+f6FxhOzBhYSlS/XivDW4Dr7Mw43c8Nj+vKBB5CqI0t4Q1jH3kvT 7wS2mtwXMoORKSia2rTHaoHn6qmPoZ2Flsj3+zJIw7z7oN2jrMvBkqfOHv984Wgi5ADV GBfg== X-Gm-Message-State: AOAM530rKZCoOEp9FAXM9IdB61Hi6xSedERgloHWiFicBr7nrJ8iGjlu QwcjWLIWqNcJRcyOIdtYnRG8hC0AEUGSvg== X-Google-Smtp-Source: ABdhPJyfOHoM1522kSvcmoNFz3nqYfGvkqxE55hEpShqXsK2NKaw9Hqts95wqgzatxsbIG31uks7EQ== X-Received: by 2002:a17:90a:6285:: with SMTP id d5mr21127097pjj.3.1620886379896; Wed, 12 May 2021 23:12:59 -0700 (PDT) Received: from desktop.fossix.local ([103.21.79.4]) by smtp.gmail.com with ESMTPSA id gf21sm1422351pjb.20.2021.05.12.23.12.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 23:12:59 -0700 (PDT) From: Santosh Sivaraj To: Linux NVDIMM Subject: [ndctl V5 2/4] test: Don't skip tests if nfit modules are missing Date: Thu, 13 May 2021 11:42:16 +0530 Message-Id: <20210513061218.760322-2-santosh@fossix.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513061218.760322-1-santosh@fossix.org> References: <20210513061218.760322-1-santosh@fossix.org> MIME-Version: 1.0 Message-ID-Hash: MNGBWBCI2DPZZJOCMBEQLMPEK5JJVDCM X-Message-ID-Hash: MNGBWBCI2DPZZJOCMBEQLMPEK5JJVDCM X-MailFrom: santosh@fossix.org 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: Shivaprasad G Bhat , Harish Sriram , "Aneesh Kumar K.V" 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: For NFIT to be available ACPI is a must, so don't fail when nfit modules are missing on a platform that doesn't support ACPI. Signed-off-by: Santosh Sivaraj --- test.h | 2 +- test/ack-shutdown-count-set.c | 2 +- test/blk_namespaces.c | 2 +- test/core.c | 28 ++++++++++++++++++++++++++-- test/dpa-alloc.c | 2 +- test/dsm-fail.c | 2 +- test/libndctl.c | 2 +- test/multi-pmem.c | 2 +- test/parent-uuid.c | 2 +- test/pmem_namespaces.c | 2 +- 10 files changed, 35 insertions(+), 11 deletions(-) diff --git a/test.h b/test.h index cba8d41..7de13fe 100644 --- a/test.h +++ b/test.h @@ -20,7 +20,7 @@ void builtin_xaction_namespace_reset(void); struct kmod_ctx; struct kmod_module; -int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod, +int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod, struct ndctl_ctx *nd_ctx, int log_level, struct ndctl_test *test); diff --git a/test/ack-shutdown-count-set.c b/test/ack-shutdown-count-set.c index fb1d82b..c561ff3 100644 --- a/test/ack-shutdown-count-set.c +++ b/test/ack-shutdown-count-set.c @@ -99,7 +99,7 @@ static int test_ack_shutdown_count_set(int loglevel, struct ndctl_test *test, int result = EXIT_FAILURE, err; ndctl_set_log_priority(ctx, loglevel); - err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test); + err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test); if (err < 0) { result = 77; ndctl_test_skip(test); diff --git a/test/blk_namespaces.c b/test/blk_namespaces.c index d7f00cb..f076e85 100644 --- a/test/blk_namespaces.c +++ b/test/blk_namespaces.c @@ -228,7 +228,7 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test, if (!bus) { fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n"); - rc = nfit_test_init(&kmod_ctx, &mod, NULL, log_level, test); + rc = ndctl_test_init(&kmod_ctx, &mod, NULL, log_level, test); ndctl_invalidate(ctx); bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0"); if (rc < 0 || !bus) { diff --git a/test/core.c b/test/core.c index cc7d8d9..2b03aa9 100644 --- a/test/core.c +++ b/test/core.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #define KVER_STRLEN 20 @@ -106,11 +107,11 @@ int ndctl_test_get_skipped(struct ndctl_test *test) return test->skip; } -int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod, +int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod, struct ndctl_ctx *nd_ctx, int log_level, struct ndctl_test *test) { - int rc; + int rc, family = -1; unsigned int i; const char *name; struct ndctl_bus *bus; @@ -127,10 +128,28 @@ int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod, "nd_e820", "nd_pmem", }; + char *test_env; log_init(&log_ctx, "test/init", "NDCTL_TEST"); log_ctx.log_priority = log_level; + /* + * The following two checks determine the platform family. For + * Intel/platforms which support ACPI, check sysfs; for other platforms + * determine from the environment variable NVDIMM_TEST_FAMILY + */ + if (access("/sys/bus/acpi", F_OK) == 0) + family = NVDIMM_FAMILY_INTEL; + + test_env = getenv("NDCTL_TEST_FAMILY"); + if (test_env && strcmp(test_env, "PAPR") == 0) + family = NVDIMM_FAMILY_PAPR; + + if (family == -1) { + log_err(&log_ctx, "Cannot determine NVDIMM family\n"); + return -ENOTSUP; + } + *ctx = kmod_new(NULL, NULL); if (!*ctx) return -ENXIO; @@ -185,6 +204,11 @@ retry: path = kmod_module_get_path(*mod); if (!path) { + if (family != NVDIMM_FAMILY_INTEL && + (strcmp(name, "nfit") == 0 || + strcmp(name, "nd_e820") == 0)) + continue; + log_err(&log_ctx, "%s.ko: failed to get path\n", name); break; } diff --git a/test/dpa-alloc.c b/test/dpa-alloc.c index e922009..0b3bb7a 100644 --- a/test/dpa-alloc.c +++ b/test/dpa-alloc.c @@ -289,7 +289,7 @@ int test_dpa_alloc(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx) return 77; ndctl_set_log_priority(ctx, loglevel); - err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test); + err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test); if (err < 0) { ndctl_test_skip(test); fprintf(stderr, "nfit_test unavailable skipping tests\n"); diff --git a/test/dsm-fail.c b/test/dsm-fail.c index 9dfd8b0..0a6383d 100644 --- a/test/dsm-fail.c +++ b/test/dsm-fail.c @@ -346,7 +346,7 @@ int test_dsm_fail(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx) int result = EXIT_FAILURE, err; ndctl_set_log_priority(ctx, loglevel); - err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test); + err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test); if (err < 0) { result = 77; ndctl_test_skip(test); diff --git a/test/libndctl.c b/test/libndctl.c index 24d72b3..0e88fce 100644 --- a/test/libndctl.c +++ b/test/libndctl.c @@ -2692,7 +2692,7 @@ int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx) daxctl_set_log_priority(daxctl_ctx, loglevel); ndctl_set_private_data(ctx, test); - err = nfit_test_init(&kmod_ctx, &mod, ctx, loglevel, test); + err = ndctl_test_init(&kmod_ctx, &mod, ctx, loglevel, test); if (err < 0) { ndctl_test_skip(test); fprintf(stderr, "nfit_test unavailable skipping tests\n"); diff --git a/test/multi-pmem.c b/test/multi-pmem.c index 3d10952..3ea08cc 100644 --- a/test/multi-pmem.c +++ b/test/multi-pmem.c @@ -249,7 +249,7 @@ int test_multi_pmem(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx ndctl_set_log_priority(ctx, loglevel); - err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test); + err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test); if (err < 0) { result = 77; ndctl_test_skip(test); diff --git a/test/parent-uuid.c b/test/parent-uuid.c index 6424e9f..bded33a 100644 --- a/test/parent-uuid.c +++ b/test/parent-uuid.c @@ -218,7 +218,7 @@ int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ct return 77; ndctl_set_log_priority(ctx, loglevel); - err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test); + err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test); if (err < 0) { ndctl_test_skip(test); fprintf(stderr, "nfit_test unavailable skipping tests\n"); diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c index f0f2edd..a4db1ae 100644 --- a/test/pmem_namespaces.c +++ b/test/pmem_namespaces.c @@ -191,7 +191,7 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test, if (!bus) { fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n"); - rc = nfit_test_init(&kmod_ctx, &mod, NULL, log_level, test); + rc = ndctl_test_init(&kmod_ctx, &mod, NULL, log_level, test); ndctl_invalidate(ctx); bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0"); if (rc < 0 || !bus) { From patchwork Thu May 13 06:12:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 12255193 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=-12.8 required=3.0 tests=BAYES_50,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 3C6ABC433ED for ; Thu, 13 May 2021 06:13:10 +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 DF6BB613C2 for ; Thu, 13 May 2021 06:13:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF6BB613C2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fossix.org 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 BABD7100EAB4E; Wed, 12 May 2021 23:13:09 -0700 (PDT) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::530; helo=mail-pg1-x530.google.com; envelope-from=santosh@fossix.org; receiver= Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) (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 8FA67100EAB4C for ; Wed, 12 May 2021 23:13:07 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id l70so5654756pga.1 for ; Wed, 12 May 2021 23:13:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fossix-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nMATeAaC5U+4603Cs/hY3PWfCR31dXQRgSVD/soPB5c=; b=K/CkRdqcfQ3u8k+APAV7iAzHMovWeuqZqm1ngTAWCmsIAu7guFbfQqyAde5n5LH0xR lJdAWkpglF34r2xYjaj462+sckUOQcGYXCT7RRzDTiDiAPs96+KdEEl9KHQ/7sJSWRmx mGa/kbxBndkLnDWllq/ONnUtneO/wMHP7V5j1CEgN3wyimZOe2BLOg/CaGsg9rYJZrka 3yOqUEqbHRiyuioZE7+qh8l5zmT3JyHjYSlUW8fuZ4FUCBLo8Rk94YzUnwfz3m+fXGtp CVe6MIiDwJSlt0E82DUHGgkuWW/Mj3UjgtIUY9/4tvlTLdoca0BHKg2t5fncZFawZe55 7dmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nMATeAaC5U+4603Cs/hY3PWfCR31dXQRgSVD/soPB5c=; b=jSXN4tcMgddcmKCF0QFym80WD39gRcX76v8l7+J36gPzSYvAT3smpoOm8YtCeWt8bo RO/sRgwW2GyiNLb3Mn6UoKrF7jUgItiFeoeZAv6W7tHtOWFGsAROdIaqqjn9OUzErYx1 x/IWrlM2h1IAjaakJ+4y38f7cO6Ovx1+pSlVENKEeGKdH9kvuveEWjFZ881UNXqGESzJ NPspEZmR33HHCe4Y/um6HI5sXTiU3gZYzUXZOjuywlBmuN+PIDXadvbrMhXyhea95Ytq M+EYOWjUvi8CVaj0aqocOe5rU5BHBeAMDyWsJ7aiGj1XQRa4yLZDQRuwdz71WUg5krYL tNEg== X-Gm-Message-State: AOAM532N9gS94aAl838tkwCgvp+DkGQg8tWmdI98yOhZ/svsN+UTnAO4 d+90pvq62Ur3wSeLbWAp8v36jcL1zWIvRA== X-Google-Smtp-Source: ABdhPJwEi1nVGk+Gkzd317x1xA9uW7M4K/NohdKAzdcjKfmZR+ZX9eNM6bKbSlgjEPsYJAdryXIB3Q== X-Received: by 2002:a17:90a:fed:: with SMTP id 100mr44280018pjz.89.1620886387120; Wed, 12 May 2021 23:13:07 -0700 (PDT) Received: from desktop.fossix.local ([103.21.79.4]) by smtp.gmail.com with ESMTPSA id gf21sm1422351pjb.20.2021.05.12.23.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 23:13:06 -0700 (PDT) From: Santosh Sivaraj To: Linux NVDIMM Subject: [ndctl V5 3/4] papr: Add support to parse save_fail flag for dimm Date: Thu, 13 May 2021 11:42:17 +0530 Message-Id: <20210513061218.760322-3-santosh@fossix.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513061218.760322-1-santosh@fossix.org> References: <20210513061218.760322-1-santosh@fossix.org> MIME-Version: 1.0 Message-ID-Hash: Z5C2VTY76H46SNRSTBMSFXNRRPASKEJV X-Message-ID-Hash: Z5C2VTY76H46SNRSTBMSFXNRRPASKEJV X-MailFrom: santosh@fossix.org 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: Shivaprasad G Bhat , Harish Sriram , "Aneesh Kumar K.V" 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: This will help in getting the dimm fail tests to run on papr family too. Also add nvdimm_test compatibility string for recognizing the test module. Signed-off-by: Santosh Sivaraj --- ndctl/lib/libndctl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 26b9317..dd1a5fc 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -805,6 +805,8 @@ static void parse_papr_flags(struct ndctl_dimm *dimm, char *flags) dimm->flags.f_restore = 1; else if (strcmp(start, "smart_notify") == 0) dimm->flags.f_smart = 1; + else if (strcmp(start, "save_fail") == 0) + dimm->flags.f_save = 1; start = end + 1; } if (end != start) @@ -1035,7 +1037,8 @@ NDCTL_EXPORT int ndctl_bus_is_papr_scm(struct ndctl_bus *bus) if (sysfs_read_attr(bus->ctx, bus->bus_buf, buf) < 0) return 0; - return (strcmp(buf, "ibm,pmemory") == 0); + return (strcmp(buf, "ibm,pmemory") == 0 || + strcmp(buf, "nvdimm_test") == 0); } /** From patchwork Thu May 13 06:12:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 12255195 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 7701CC433ED for ; Thu, 13 May 2021 06:13:33 +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 2156B613C2 for ; Thu, 13 May 2021 06:13:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2156B613C2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=fossix.org 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 DB142100EAB4D; Wed, 12 May 2021 23:13:32 -0700 (PDT) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::630; helo=mail-pl1-x630.google.com; envelope-from=santosh@fossix.org; receiver= Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) (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 91977100F2257 for ; Wed, 12 May 2021 23:13:30 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id b3so13811367plg.11 for ; Wed, 12 May 2021 23:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fossix-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9GaySowKDRoeaBobshdWuwMR/EGY+Ux4n273LdfQ4dY=; b=pxpRP8TlU9fs707q5bL8nd630G8PriP2T97U5uyzQ8RiwRVebVN8qU4KPq/DSLiw0f sA8yyz7J1AaMI2MeWRO4GzqmBEk1exFihZF97Vf2o0CPBHjsUJReWuewp/WRxGsDDN38 vtmSh0AImEgMwYiDPlgbOk6mKdKiPETFP9btjhNG3knzW45prA20xaiM83i4t/opw/wi Eup4fASLDgcEOMi3sO2Ovl6h5lVX2OlDsgf9DJh9KBfLBlsP94Yfzgv5zZFsE6IDabTt IlMqz54OotPozxAur/vXBd86Dv4ecS3CldSYiIVEr+ng6UGx6OT5LYEqud0ZjrluXoDv 7T+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9GaySowKDRoeaBobshdWuwMR/EGY+Ux4n273LdfQ4dY=; b=ugxmZMNxyVzWJe0LGc7kjX2o1cqhvMhUCdCjk/GJrwVc+IorKTW5J9bSaMOD+N6hil fUG7NBMNF1EGilgom0DhGow3mweGil1YbyXh0UVfI7hSzvOhAIKaibBIn1ZXtg5bHQiK PlvDM7Di/P+Hr5n/84LY23EcsTb864oHtw0sy+yIDN/tA0HrsgB/jgrfAlrK4bCbkHvi 0xYA9pW2OAjb3vQpGkITgvRFopiayRFRjEe9tQqjiUDuLXP3/fQjJEyIe84o1iPD9ryA lpCjMv942VKCzTVglzAJ4cAsbhEih8EhSYhnkrSda6Ya6bSxb5fUnkoNcM1ogR4KSjI7 D6hA== X-Gm-Message-State: AOAM530BKOeGc/ZeFVQJZVrZSj16nzRzuNVYeOperCyIS8+WfDprN6XQ RNZGsTJqU1AFHeLL8LaPROw37bzLb6EEPQ== X-Google-Smtp-Source: ABdhPJyqA2afRvk9kEbXXLVfanx5++nl7BGfs7cLPCJY/JM/vjRzxd/Cz68+DfD50CoSSgSBHbk4xg== X-Received: by 2002:a17:902:b285:b029:ef:9419:b91c with SMTP id u5-20020a170902b285b02900ef9419b91cmr3405520plr.21.1620886409772; Wed, 12 May 2021 23:13:29 -0700 (PDT) Received: from desktop.fossix.local ([103.21.79.4]) by smtp.gmail.com with ESMTPSA id gf21sm1422351pjb.20.2021.05.12.23.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 23:13:29 -0700 (PDT) From: Santosh Sivaraj To: Linux NVDIMM Subject: [ndctl V5 4/4] Use page size as alignment value Date: Thu, 13 May 2021 11:42:18 +0530 Message-Id: <20210513061218.760322-4-santosh@fossix.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513061218.760322-1-santosh@fossix.org> References: <20210513061218.760322-1-santosh@fossix.org> MIME-Version: 1.0 Message-ID-Hash: KIFHFYTEIQNEQMVWCMXJZMJLJZU5BLS2 X-Message-ID-Hash: KIFHFYTEIQNEQMVWCMXJZMJLJZU5BLS2 X-MailFrom: santosh@fossix.org 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: Shivaprasad G Bhat , Harish Sriram , "Aneesh Kumar K.V" 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: The alignment sizes passed to ndctl in the tests are all hardcoded to 4k, the default page size on x86. Change those to the default page size on that architecture (sysconf/getconf). No functional changes otherwise. Signed-off-by: Santosh Sivaraj --- test/dpa-alloc.c | 15 ++++++++------- test/multi-dax.sh | 6 ++++-- test/sector-mode.sh | 4 +++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/test/dpa-alloc.c b/test/dpa-alloc.c index 0b3bb7a..59185cf 100644 --- a/test/dpa-alloc.c +++ b/test/dpa-alloc.c @@ -38,12 +38,13 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) struct ndctl_region *region, *blk_region = NULL; struct ndctl_namespace *ndns; struct ndctl_dimm *dimm; - unsigned long size; + unsigned long size, page_size; struct ndctl_bus *bus; char uuid_str[40]; int round; int rc; + page_size = sysconf(_SC_PAGESIZE); /* disable nfit_test.1, not used in this test */ bus = ndctl_bus_get_by_provider(ctx, NFIT_PROVIDER1); if (!bus) @@ -124,11 +125,11 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) return rc; } ndctl_namespace_disable_invalidate(ndns); - rc = ndctl_namespace_set_size(ndns, SZ_4K); + rc = ndctl_namespace_set_size(ndns, page_size); if (rc) { - fprintf(stderr, "failed to init %s to size: %d\n", + fprintf(stderr, "failed to init %s to size: %lu\n", ndctl_namespace_get_devname(ndns), - SZ_4K); + page_size); return rc; } namespaces[i].ndns = ndns; @@ -150,7 +151,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns; if (i % ARRAY_SIZE(namespaces) == 0) round++; - size = SZ_4K * round; + size = page_size * round; rc = ndctl_namespace_set_size(ndns, size); if (rc) { fprintf(stderr, "%s: set_size: %lx failed: %d\n", @@ -166,7 +167,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) i--; round++; ndns = namespaces[i % ARRAY_SIZE(namespaces)].ndns; - size = SZ_4K * round; + size = page_size * round; rc = ndctl_namespace_set_size(ndns, size); if (rc) { fprintf(stderr, "%s failed to update while labels full\n", @@ -175,7 +176,7 @@ static int do_test(struct ndctl_ctx *ctx, struct ndctl_test *test) } round--; - size = SZ_4K * round; + size = page_size * round; rc = ndctl_namespace_set_size(ndns, size); if (rc) { fprintf(stderr, "%s failed to reduce size while labels full\n", diff --git a/test/multi-dax.sh b/test/multi-dax.sh index e932569..9451ed0 100755 --- a/test/multi-dax.sh +++ b/test/multi-dax.sh @@ -12,6 +12,8 @@ check_min_kver "4.13" || do_skip "may lack multi-dax support" trap 'err $LINENO' ERR +ALIGN_SIZE=`getconf PAGESIZE` + # setup (reset nfit_test dimms) modprobe nfit_test $NDCTL disable-region -b $NFIT_TEST_BUS0 all @@ -22,9 +24,9 @@ rc=1 query=". | sort_by(.available_size) | reverse | .[0].dev" region=$($NDCTL list -b $NFIT_TEST_BUS0 -t pmem -Ri | jq -r "$query") -json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a 4096 -s 16M) +json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a $ALIGN_SIZE -s 16M) chardev1=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev") -json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a 4096 -s 16M) +json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -r $region -t pmem -m devdax -a $ALIGN_SIZE -s 16M) chardev2=$(echo $json | jq ". | select(.mode == \"devdax\") | .daxregion.devices[0].chardev") _cleanup diff --git a/test/sector-mode.sh b/test/sector-mode.sh index dd7013e..d03c0ca 100755 --- a/test/sector-mode.sh +++ b/test/sector-mode.sh @@ -9,6 +9,8 @@ rc=77 set -e trap 'err $LINENO' ERR +ALIGN_SIZE=`getconf PAGESIZE` + # setup (reset nfit_test dimms) modprobe nfit_test $NDCTL disable-region -b $NFIT_TEST_BUS0 all @@ -25,7 +27,7 @@ NAMESPACE=$($NDCTL list -b $NFIT_TEST_BUS1 -N | jq -r "$query") REGION=$($NDCTL list -R --namespace=$NAMESPACE | jq -r "(.[]) | .dev") echo 0 > /sys/bus/nd/devices/$REGION/read_only $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K -$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a 4K +$NDCTL create-namespace --no-autolabel -e $NAMESPACE -m dax -f -a $ALIGN_SIZE $NDCTL create-namespace --no-autolabel -e $NAMESPACE -m sector -f -l 4K _cleanup