From patchwork Sun Mar 28 02:09:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 12168743 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 0759EC433C1 for ; Sun, 28 Mar 2021 02:10:20 +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 7DC5761993 for ; Sun, 28 Mar 2021 02:10:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7DC5761993 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 49AC3100EC1CC; Sat, 27 Mar 2021 19:10:19 -0700 (PDT) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::532; helo=mail-pg1-x532.google.com; envelope-from=santosh@fossix.org; receiver= Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) (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 5076C100ED4A2 for ; Sat, 27 Mar 2021 19:10:14 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id 33so1276155pgy.4 for ; Sat, 27 Mar 2021 19:10:14 -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=Pfsh5cxjks6ox91fLrsV7zkYCSWZfEyj0oMrHnqmOLY=; b=Rh0scVk4Buw7VX98wNiewDHzic3rqhphZbC2FOEkuOEMTZo+bduSKpYA/Jrx8Hyi7T g7G6VPfvRtmZzS/zl3/xyjl4emCEGRTLodzTFYsYOdcfCHeJUKkNQbeAnt264CnXyf+h v8dQpmpGSIoq7TGWD8xwI2/Xw/k56TwB6iENNP8Xg0VjtT5OJGtFLSqODIqjTIvs7jQO H2UofEkdBgO51KtD/+mHjOJl3zMMA2ZnBn/a99snS00HOcHaZJ+P6vgTlmOOi/hsHLj7 hO0fWTyfigFT49+Z5zmiNykiMzMU67SNvYNWESLp2yE++0/ufzQI05KM4Ue9nMvnTGS1 AmdA== 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=Pfsh5cxjks6ox91fLrsV7zkYCSWZfEyj0oMrHnqmOLY=; b=oU4SZp9XfTmyitwRPryyISmJZ0mNzdW+mlyIZY8GdRh1J2amJef+Mb0skaHziDfyqS QmBe4UDr5dZRUQUR1XSY8WI1XxqI03pQXFgfBVfoCcK5jMMaBCXuwdKvWW7ve/fGdj5x qMAknV4u57fxOyE6AZKhYFLKEI1xaoNai+0PJB81jkbhZwVgzYjfh9UG/uquNReoVYKh GDArbiSOkH9KIKxS07plMeFOUfSSazwMAnHeXgXlWgaOaNGIdpGdpodjQLUWTQhp0G2J L1uyvDz6H9mzc8hP5F0+3zC4wD1kDgCnFM4lEJHsM+bR6KEEIvB+7rdKRpsGSQvTFTgN lqmA== X-Gm-Message-State: AOAM533PVhn6TDyRdHNNs4Eb5bywRpNZPg0SJsU72qZqtEyxmHZX2HZD jG9V66/DvOeatoExzxmUuhqc6n6zwD6cqQ== X-Google-Smtp-Source: ABdhPJzbHaM1e2X++iO9V7hXUNRty8V3HmMwpUJZUG47hWeLAXPbVfmVchsxfmBpuz39VRcCRZHqHw== X-Received: by 2002:a05:6a00:78c:b029:1f5:d587:1701 with SMTP id g12-20020a056a00078cb02901f5d5871701mr19539174pfu.59.1616897412408; Sat, 27 Mar 2021 19:10:12 -0700 (PDT) Received: from santosiv.in.ibm.com.com ([103.21.79.4]) by smtp.gmail.com with ESMTPSA id gb1sm11754148pjb.21.2021.03.27.19.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Mar 2021 19:10:11 -0700 (PDT) From: Santosh Sivaraj To: Linux NVDIMM , Vishal Verma , Vaibhav Jain , Shivaprasad G Bhat , Harish Sriram , Dan Williams Cc: Santosh Sivaraj Subject: [PATCH 1/4] libndctl: Unify adding dimms for papr and nfit families Date: Sun, 28 Mar 2021 07:39:58 +0530 Message-Id: <20210328021001.2340251-1-santosh@fossix.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Message-ID-Hash: QDI2I6WRUXUDCG5RLQD3YHRC2XE623UN X-Message-ID-Hash: QDI2I6WRUXUDCG5RLQD3YHRC2XE623UN 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 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 Sun Mar 28 02:09:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 12168745 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 367DAC433DB for ; Sun, 28 Mar 2021 02:10:21 +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 A234761993 for ; Sun, 28 Mar 2021 02:10:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A234761993 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 61A43100EBBC1; Sat, 27 Mar 2021 19:10:20 -0700 (PDT) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::633; helo=mail-pl1-x633.google.com; envelope-from=santosh@fossix.org; receiver= Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) (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 D6028100ED4A2 for ; Sat, 27 Mar 2021 19:10:15 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id e14so2738339plj.2 for ; Sat, 27 Mar 2021 19:10:15 -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=PJAxn1Id7XlM/niY9V/wDtMEtoV6+KwD0tDjHVdA2Gs=; b=0gXePmruviE7mA33HDVxw6fXVJpTbwbEJuAiDfCqAj9R+4fEkplVGUCNkJ+6KDImuM K8f8E3E9YCBpWVVjNUz504ceDl2wVBlki7YL6g/o3OP3oT1d/QY9QjtAS7pzZrnASOG7 BIVI/vjl6oomV6cILqqTEmGu28xUe8B0/nRSXLvO4WlODiGE8UoVVkNgFrLgf29SWXi5 Du06wAHLQGjEmU0pHUIPSFcp5h6wxkY7ZgTh+cvt2DjT4NA727QIZIixxkYwjalhMkpV V7eqmLIyxrax0gXyldJoq5QkcP6eWrLtUX4OLdNZbAcmBNTgOzkb2f/qU89td2TuSIvT 5+AQ== 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=PJAxn1Id7XlM/niY9V/wDtMEtoV6+KwD0tDjHVdA2Gs=; b=N/rF5SVz4nZzbOe3oirmhJnPME4D1Y0QCjTF/gc+WQM4uZy2TdlH53XV0OFiCgUnJa V6rYQEmqWa3O+zOdGX4V6C7K1AdTAkBwsH7hm0YP2AJq5MbFR7pmH73uEo2s72bIA28y JVSRK+tQ2MATPkWRBQ9N3prypiBG12mU8KzMkwAi3v536Ci9IUzxLIyxDJWD4YZw9J8+ zxxz46gUDcT4L4uuhTzX9ecxVr2WW8HglCZAxEkxOeLLruiuWS+tZMohHe5JEFELjOfk 8F9WONo3hXH2po5cCRK8BA5WZBQFpx8LAYRw63boMqdCpd8A1vJgqYt8mlA4a8EA5ehJ 9jQg== X-Gm-Message-State: AOAM531oZdTXg+sK0vqfgTroXT5XP+eXFTne92yOrkuyn8IbfgQnVdAQ Td1yJeIVo2y5l9zUxfblOA9OCa0QVexfHA== X-Google-Smtp-Source: ABdhPJwhbKZQQRvX2tTEQ8MjAP0/mgVbx+edaXC8FrhamUSYgijQbsMFzTX2k0V9akUsh1thsM2ryA== X-Received: by 2002:a17:90a:db51:: with SMTP id u17mr20271984pjx.194.1616897415024; Sat, 27 Mar 2021 19:10:15 -0700 (PDT) Received: from santosiv.in.ibm.com.com ([103.21.79.4]) by smtp.gmail.com with ESMTPSA id gb1sm11754148pjb.21.2021.03.27.19.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Mar 2021 19:10:14 -0700 (PDT) From: Santosh Sivaraj To: Linux NVDIMM , Vishal Verma , Vaibhav Jain , Shivaprasad G Bhat , Harish Sriram , Dan Williams Cc: Santosh Sivaraj Subject: [PATCH 2/4] test: Don't skip tests if nfit modules are missing Date: Sun, 28 Mar 2021 07:39:59 +0530 Message-Id: <20210328021001.2340251-2-santosh@fossix.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210328021001.2340251-1-santosh@fossix.org> References: <20210328021001.2340251-1-santosh@fossix.org> MIME-Version: 1.0 Message-ID-Hash: OO2FDE3KBL47BN4F4T3VOG2Y3VFKCJHX X-Message-ID-Hash: OO2FDE3KBL47BN4F4T3VOG2Y3VFKCJHX 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 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 | 30 ++++++++++++++++++++++++++++-- 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, 37 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..44cb277 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,30 @@ 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) { + if (errno == ENOENT) + 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 +206,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 Sun Mar 28 02:10:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 12168747 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 34F0DC433E1 for ; Sun, 28 Mar 2021 02:10:22 +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 8C0F261993 for ; Sun, 28 Mar 2021 02:10:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C0F261993 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 818B7100EBBD7; Sat, 27 Mar 2021 19:10:20 -0700 (PDT) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::42c; helo=mail-pf1-x42c.google.com; envelope-from=santosh@fossix.org; receiver= Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (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 65BAE100ED4A2 for ; Sat, 27 Mar 2021 19:10:18 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id q5so7496601pfh.10 for ; Sat, 27 Mar 2021 19:10:18 -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=EHy0HCSsdjzHPMQIH/8nG6HvMn0OJPybxvznNn6+fVo=; b=GBG5z94JZ0PmbCmlcq7e4AmOFSMtnp8kwcvH1xiLpsdAyRmw/G4bPyFjuPHZE5o0jr U3Mxbd3d+rhXdO6PC7cB5OL/Xpbtg9g0GUF7UQHxtXNYXUp6Zcoj5l1IhyNhY+Vh25Lg TZS5EJGeZUVA62tNwVHPSyefsHlGXLlCKWla/i2CQSiyinG5PIzuD4CMw/+tIXVxDWAL I1cm9ljk6dGHoW+4GRfZINqE1QWn+ywDmZfevQWPtxb6ae7npPt2iG5yC8ITZscUabyH Bc6aAQVkjc/asgLSbhbasKwPrT/B8bLbJetmJUeso4z44RI2hJuEQSHUm/3YGUJhsEAB beMA== 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=EHy0HCSsdjzHPMQIH/8nG6HvMn0OJPybxvznNn6+fVo=; b=f782Emc9+rkYvdI9ZqHF+hZkTHycLr0iVQlMkx2P1/fYtOn8RH1gzUrcaMS0z0xhFu Xs95+sCi2etrPY9B7dn1ftd3+2STvI0siPM4pzX8DUfoHib49yep8WtcyWuRU63YroyD yybCNv+6i07R2vHY2uYbH8D2qoPa00v/QGNxihZ0Pf4M/3Cz/cCH35RJ+cYhjHTkwCv0 8t5CdTxVZGdXaDTAScflYSN+9cJ3gXaJL1JPpaUZHpd7SjnxuF2JYNq/TMevCb+dkZtS A2zCP/hj1Y7mp5oP9r2M2w7a7nSXpMJQGSso1VMYYHUdAhtNhLjfaPU2PPw5isOwi6qE f33Q== X-Gm-Message-State: AOAM530sPNpadOnzSG83lTH0gXelLH3BuPvdXd2npN/Pm567+skpyCmv tj30pEJfzy/CpmG0b0x9opfvpRP0ShROfg== X-Google-Smtp-Source: ABdhPJxk64KiEAowC2cOIWzIi0p+NV9EksImIKze1/kYjPaCAWmh1WZEHWFaOOBviw45WnrYuyfo7A== X-Received: by 2002:a63:5c23:: with SMTP id q35mr18632767pgb.418.1616897417640; Sat, 27 Mar 2021 19:10:17 -0700 (PDT) Received: from santosiv.in.ibm.com.com ([103.21.79.4]) by smtp.gmail.com with ESMTPSA id gb1sm11754148pjb.21.2021.03.27.19.10.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Mar 2021 19:10:17 -0700 (PDT) From: Santosh Sivaraj To: Linux NVDIMM , Vishal Verma , Vaibhav Jain , Shivaprasad G Bhat , Harish Sriram , Dan Williams Cc: Santosh Sivaraj Subject: [PATCH 3/4] papr: Add support to parse save_fail flag for dimm Date: Sun, 28 Mar 2021 07:40:00 +0530 Message-Id: <20210328021001.2340251-3-santosh@fossix.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210328021001.2340251-1-santosh@fossix.org> References: <20210328021001.2340251-1-santosh@fossix.org> MIME-Version: 1.0 Message-ID-Hash: 7KOXOOCGKMDXJRHOFUJUKWDST2LCQEVT X-Message-ID-Hash: 7KOXOOCGKMDXJRHOFUJUKWDST2LCQEVT 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 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 Sun Mar 28 02:10:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Sivaraj X-Patchwork-Id: 12168749 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 47F97C433C1 for ; Sun, 28 Mar 2021 02:10:25 +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 DAEEA61993 for ; Sun, 28 Mar 2021 02:10:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DAEEA61993 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 AFCA7100EBB62; Sat, 27 Mar 2021 19:10:24 -0700 (PDT) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::1032; helo=mail-pj1-x1032.google.com; envelope-from=santosh@fossix.org; receiver= Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) (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 352D1100EBBC4 for ; Sat, 27 Mar 2021 19:10:21 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id nh23-20020a17090b3657b02900c0d5e235a8so4282050pjb.0 for ; Sat, 27 Mar 2021 19:10:21 -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=zSE0olNjoRqAUXPQrpmXcufxL8VpJmvBThhgw81t5vY=; b=b/MBwmK6WeJpirKN+paa68xVl9TNMyaXt9UAELpek5N1ujy+S+XPbuUAwmn9oaRjoV UcWdLD62fQilzefqAL9xangMKPPAEecESyTO1t2yZ8UhdWJ+kU91z84ZHRq1PbeJSFbU F/wkHKpF9Awp4LyzGEtoMIY0F5MQF1Bg6MJksuUv4PjFmt6mvY0S1+CM8hUOTSX99/+O 9l7EpeQVSyzcDfaowF/a4meQ0PH84zQI0aU2lSyx5q5cYn796ftZEENqG0JB6vKzx4Ya gPBOEuJJhQ1Cp4wu1PDgdYiRgRSD/c/E6UiMjnltqmyyeOa/VE3GHVSlcHYJhfVa6rYO fvKg== 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=zSE0olNjoRqAUXPQrpmXcufxL8VpJmvBThhgw81t5vY=; b=CpnNuGgSgKgBPL1eDJEK4VaWLh4Gv6Rrnj/O46bvCiq1hwdU0Qyw/TjV/Nu7HDGeBu WxlNkuDZw4Y65wniuxkkcXGf2qcNtKSsNmdHsIZbPirllsH4sTCGuJ9G9FAdz1OBA/Wi 9xIPdNax3gf6ZX0VZ2HviXfQzmN5rAF0UVE9sG7Oi71Nrj3XcAxABOziS+F1sRv1CaBZ r4E5wFXa5hCaBYwzs7tCGmE4ejOX6D4BKXzaOarKVDxaKnDSFz7PvJGoN09DwbXqZ4oT SZ+gLIuu/3t7Uo1JvixQ4V+VILjVVq1sBKl2jCJz9CEfFz1xygGPI0Zv5xg44TcS3AML esOA== X-Gm-Message-State: AOAM531su743zL9QyovZyIhz58laUVtTsGqWcUUdMmVhSf4xpIPUhKx6 YSEFyGX0CXtIYqwiul4B1LdJrGlawipZ7w== X-Google-Smtp-Source: ABdhPJyOzaCL1k1xd0qiJi4fauCx00GMFs4sLtRPxsiN+8p4Qo88OBpSKgaMV3Uqe8xESe45co/uKA== X-Received: by 2002:a17:90a:a103:: with SMTP id s3mr20650411pjp.158.1616897420297; Sat, 27 Mar 2021 19:10:20 -0700 (PDT) Received: from santosiv.in.ibm.com.com ([103.21.79.4]) by smtp.gmail.com with ESMTPSA id gb1sm11754148pjb.21.2021.03.27.19.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Mar 2021 19:10:20 -0700 (PDT) From: Santosh Sivaraj To: Linux NVDIMM , Vishal Verma , Vaibhav Jain , Shivaprasad G Bhat , Harish Sriram , Dan Williams Cc: Santosh Sivaraj Subject: [PATCH 4/4] Use page size as alignment value Date: Sun, 28 Mar 2021 07:40:01 +0530 Message-Id: <20210328021001.2340251-4-santosh@fossix.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210328021001.2340251-1-santosh@fossix.org> References: <20210328021001.2340251-1-santosh@fossix.org> MIME-Version: 1.0 Message-ID-Hash: 64R7M5JJ4URBXVLWQT7TFZBHWBKOBLBT X-Message-ID-Hash: 64R7M5JJ4URBXVLWQT7TFZBHWBKOBLBT 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 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