From patchwork Wed May 22 08:26:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 10955307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9911A13AD for ; Wed, 22 May 2019 08:28:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D05E28B4D for ; Wed, 22 May 2019 08:28:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81BCC28A48; Wed, 22 May 2019 08:28:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02CEE28B4D for ; Wed, 22 May 2019 08:28:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12B7B6B000A; Wed, 22 May 2019 04:28:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0DB736B000C; Wed, 22 May 2019 04:28:25 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F0D346B000D; Wed, 22 May 2019 04:28:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id BB4F76B000A for ; Wed, 22 May 2019 04:28:24 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id a90so947712plc.7 for ; Wed, 22 May 2019 01:28:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; bh=SwfZ5gHinL+ZGl3v5/D4Rf/RJsHj9sBvxpFwbDB8eOk=; b=Jkpt9Pc9gfQ6kzmJxqb2ReDN4ldPjyUaFIdgdeZPR5/Apg6KBMsbhmb85nuINu4KF7 gK6Fox7Ya4Ov4E7xMTKIoeCQZSuxEgjX72zsz9WoJOP2nkudaTpBoCXGDU90I6472VrD nclUjwxjwYkilOud8gut0fAlLDJmk/V0wbesRfD7jUuqb2DUmn+bcPwsE+Bwv0luv9+Y UkItSw6++0WLTj9BjXuQhXT+/B5zu8bh+4MUuBlm324j75EEh5yTkYik6IA74bAa36MC StEeUCODWFhQxdWuEo1y3ELskp6Z13GB2iQShK+WpCSoORJx6Mke6UbVgdukmGaRVvN1 JArg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: APjAAAV7sbPyxPrwxpWRBNQZ5KjQ8KbeQbK/ntM8mMiWu6Ns96NTCzQD uh3oY6ZTAiXqjrwBvoukMiMk/uohyFJkQMLbu4QvSnx0KI+YukRVc+ICHd7b4cPy6IUAvJ4Xh3S wYypp7uO9wqPDaTAulv7YtCDfAeih+vvzpWNbGL6zEBzZAIUDtMm6fjeUpkctVKU2lQ== X-Received: by 2002:a63:8dc9:: with SMTP id z192mr43222211pgd.6.1558513704404; Wed, 22 May 2019 01:28:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlM/nmfQou0zxFPdN3i0hapEmK8qBNS2v9FI+kSagYIXhI81cVO8C58ZkbAIcb33ZpMLPu X-Received: by 2002:a63:8dc9:: with SMTP id z192mr43222139pgd.6.1558513703652; Wed, 22 May 2019 01:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558513703; cv=none; d=google.com; s=arc-20160816; b=QhDrd/A+uxcPeCMHu8zDBCjokNMbLPS9Sh3YlDuk2yDPEU8ekaWb/UjgDi0ffGl1i8 WWkS+Cn/cNUVW9xyQiAnR4ovBko6mIrxbNw6LlCD3LK1hcG1ZPA6qS+72tUemfR3Eitu fIBdhIAcN/P3ZCJAAyOEKMr1Kyg0scmAZ+y1vuGfSqYkXMDUK0Wgx26sURn4l7YnLTk5 kDDAgF4Q9Mdsane9spttDyOZgB73D+ZwLxXhQlJlrj6Gmu6tSAD/oGAqKXVk5Yj69pYZ v2ltrhfEtVK3Y22v2XMS4YepVIem9vEXk+t9syQYtyTAYYT3i0l9bv/T+WnsQLDb/Q21 OMlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=SwfZ5gHinL+ZGl3v5/D4Rf/RJsHj9sBvxpFwbDB8eOk=; b=CV57piPAenZbfNrnlKyFzxVJY43pK4GBbvqfL1H/Z136wifstfU34Zi/mamarwiol8 EFcNPwZbkefBZ4475+f+fZdYbk8yJQ8d6r9xSl8ORLnAkjAc7Zj1iHlgl5EsR7ElUNF4 wVgRIa1rr9UZyZQoHxv7xENUoj49b5VQcQlwMUDJdiY976wSJ6AZHLyyUjJawGOkKoZ/ rNf2kxoAXHNGutzGXOVXjSYHPBBoOoex+8S7t6DomnSlBj7xpQgePX2TErMV5TNTfsFM v8u469/HJxtcjMgsHfdc43SdV6rfFxKVTB1ipaqA4AjqCl3ln63XPpZ0RGUsHZp9qaQn Lgdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id r185si24476581pgr.10.2019.05.22.01.28.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 01:28:23 -0700 (PDT) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4M8SF6E136849; Wed, 22 May 2019 04:28:22 -0400 Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 2smyuj7gaf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2019 04:28:21 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x4M4G3D1005567; Wed, 22 May 2019 04:19:20 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma01dal.us.ibm.com with ESMTP id 2smks6s7um-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 May 2019 04:19:20 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4M8R7ZL18874872 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 May 2019 08:27:07 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44734C6057; Wed, 22 May 2019 08:27:07 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9844DC6059; Wed, 22 May 2019 08:27:05 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.31.87]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 22 May 2019 08:27:05 +0000 (GMT) From: "Aneesh Kumar K.V" To: dan.j.williams@intel.com Cc: linux-nvdimm@lists.01.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [RFC PATCH V2 1/3] mm/nvdimm: Add PFN_MIN_VERSION support Date: Wed, 22 May 2019 13:56:59 +0530 Message-Id: <20190522082701.6817-1-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-05-22_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905220062 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This allows us to make changes in a backward incompatible way. I have kept the PFN_MIN_VERSION in this patch '0' because we are not introducing any incompatible changes in this patch. We also may want to backport this to older kernels. The error looks like dax0.1: init failed, superblock min version 1, kernel support version 0 and the namespace is marked disabled $ndctl list -Ni [ { "dev":"namespace0.0", "mode":"fsdax", "map":"mem", "size":10737418240, "uuid":"9605de6d-cefa-4a87-99cd-dec28b02cffe", "state":"disabled" } ] Signed-off-by: Aneesh Kumar K.V --- drivers/nvdimm/pfn.h | 9 ++++++++- drivers/nvdimm/pfn_devs.c | 8 ++++++++ drivers/nvdimm/pmem.c | 26 ++++++++++++++++++++++---- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/drivers/nvdimm/pfn.h b/drivers/nvdimm/pfn.h index dde9853453d3..5fd29242745a 100644 --- a/drivers/nvdimm/pfn.h +++ b/drivers/nvdimm/pfn.h @@ -20,6 +20,12 @@ #define PFN_SIG_LEN 16 #define PFN_SIG "NVDIMM_PFN_INFO\0" #define DAX_SIG "NVDIMM_DAX_INFO\0" +/* + * increment this when we are making changes such that older + * kernel should fail to initialize that namespace. + */ + +#define PFN_MIN_VERSION 0 struct nd_pfn_sb { u8 signature[PFN_SIG_LEN]; @@ -36,7 +42,8 @@ struct nd_pfn_sb { __le32 end_trunc; /* minor-version-2 record the base alignment of the mapping */ __le32 align; - u8 padding[4000]; + __le16 min_version; + u8 padding[3998]; __le64 checksum; }; diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 01f40672507f..a2268cf262f5 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -439,6 +439,13 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig) if (nvdimm_read_bytes(ndns, SZ_4K, pfn_sb, sizeof(*pfn_sb), 0)) return -ENXIO; + if (le16_to_cpu(pfn_sb->min_version) > PFN_MIN_VERSION) { + dev_err(&nd_pfn->dev, + "init failed, superblock min version %ld kernel support version %ld\n", + le16_to_cpu(pfn_sb->min_version), PFN_MIN_VERSION); + return -EOPNOTSUPP; + } + if (memcmp(pfn_sb->signature, sig, PFN_SIG_LEN) != 0) return -ENODEV; @@ -769,6 +776,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) memcpy(pfn_sb->parent_uuid, nd_dev_to_uuid(&ndns->dev), 16); pfn_sb->version_major = cpu_to_le16(1); pfn_sb->version_minor = cpu_to_le16(2); + pfn_sb->min_version = cpu_to_le16(PFN_MIN_VERSION); pfn_sb->start_pad = cpu_to_le32(start_pad); pfn_sb->end_trunc = cpu_to_le32(end_trunc); pfn_sb->align = cpu_to_le32(nd_pfn->align); diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 845c5b430cdd..406427c064d9 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -490,6 +490,7 @@ static int pmem_attach_disk(struct device *dev, static int nd_pmem_probe(struct device *dev) { + int ret; struct nd_namespace_common *ndns; ndns = nvdimm_namespace_common_probe(dev); @@ -505,12 +506,29 @@ static int nd_pmem_probe(struct device *dev) if (is_nd_pfn(dev)) return pmem_attach_disk(dev, ndns); - /* if we find a valid info-block we'll come back as that personality */ - if (nd_btt_probe(dev, ndns) == 0 || nd_pfn_probe(dev, ndns) == 0 - || nd_dax_probe(dev, ndns) == 0) + ret = nd_btt_probe(dev, ndns); + if (ret == 0) return -ENXIO; + else if (ret == -EOPNOTSUPP) + return ret; - /* ...otherwise we're just a raw pmem device */ + ret = nd_pfn_probe(dev, ndns); + if (ret == 0) + return -ENXIO; + else if (ret == -EOPNOTSUPP) + return ret; + + ret = nd_dax_probe(dev, ndns); + if (ret == 0) + return -ENXIO; + else if (ret == -EOPNOTSUPP) + return ret; + /* + * We have two failure conditions here, there is no + * info reserver block or we found a valid info reserve block + * but failed to initialize the pfn superblock. + * Don't create a raw pmem disk for the second case. + */ return pmem_attach_disk(dev, ndns); } From patchwork Wed May 22 08:27:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 10955301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3F4713AD for ; Wed, 22 May 2019 08:27:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B688428B2C for ; Wed, 22 May 2019 08:27:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA71F28A48; Wed, 22 May 2019 08:27:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2602728A51 for ; Wed, 22 May 2019 08:27:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 328B86B0008; Wed, 22 May 2019 04:27:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2D82A6B000A; Wed, 22 May 2019 04:27:54 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1793C6B000C; Wed, 22 May 2019 04:27:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id D3C056B0008 for ; Wed, 22 May 2019 04:27:53 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id a90so947038plc.7 for ; Wed, 22 May 2019 01:27:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:mime-version :content-transfer-encoding:message-id; bh=vI7PeKSqAKLLXfk0D6JsmO6VGJtlc2FvUpFvOX5yWxc=; b=ohEVFt0sMGCryPu3RhjIAe3hjAYhKEaUhP1nMUoU0X+ooischHZGqoKztC1unT6Tru zAYtPJX3Sn/4rDn3duYvHJr3RsMNOfhQ2CYV3prAWjTRP9a1G24RNpxqUb8bGvUWg9ez 4jhslTcannjlUmSY0NKKhlEjoUX7bpktOIDQYWKj/es85ZaU5HMax5nw3G3yUl6kbO4x puBnsLNOY8qKSSnRrOfxv7CcLVYTZGMv4TCdeADX2U3IYEUlxWtSS7Pdg+OPhvcB1adB efJ5g9IY/bin7hXCzt7o9+LVGegMRb+FqFihPz73M1Q54sCHfj1p7kO2B8sbg0Ys219A Mk2Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: APjAAAW8OeUZHseimJAvjVoRhHzJOTNhgM4FdNaqeFRSKN6YkYLZnVkO YCTDfwV+m5vHbcEkWB7uY3nBUeBOcxHsFUZRPAnM4+vKghjOy7wPDp8yhraSxExn/POQgJVpBg0 5S5RKydlrjCcc4Dsb0tUN3I9+0pM4Wp2kXi9WAJsvSmos4Tv5SPnFH0PKwk9eS/5K+A== X-Received: by 2002:a62:3605:: with SMTP id d5mr73580437pfa.28.1558513673509; Wed, 22 May 2019 01:27:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyF1bMRtPizuAYi5Cadu2BZ+Kk0DxyDR6q2Up0J8/E8Gs8ChA9XIB+gzMqUBbqKibS7nOXx X-Received: by 2002:a62:3605:: with SMTP id d5mr73580344pfa.28.1558513672750; Wed, 22 May 2019 01:27:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558513672; cv=none; d=google.com; s=arc-20160816; b=Cl4Oz4lHht3Vs5Qzf1lYJCmimcxH8byW8l8VEfx7VuUXm1MP9Nk9H7gms/Q6omGkqz IzK3lY+eu3tmAL2T5F6lEIdpdJhBbCVOqpuR+/B03nMKzr4Hu64wgUDAsFJkdEcE0R1s oJLQoetYIO0f4f21XNTKdv/QQ6ntI4ymuH7URMivtLFFr5wFtdPjeipTp0Wrkn+Rh+/w TQghtyde2vVQ6TaY5KWk/z0LvHNOXVbyvUS/9jPtGLQBbrhTedUCmehVSAuVHJl8mekU uXH03w8fWf7FrMI+F2QOxamoPaOFELaXbELdDdnQH4UKpjEfq0Eoxngt0imUV8yPHpb6 t4lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:content-transfer-encoding:mime-version:references :in-reply-to:date:subject:cc:to:from; bh=vI7PeKSqAKLLXfk0D6JsmO6VGJtlc2FvUpFvOX5yWxc=; b=eSD6L1EZrSft7k/3E8ctf6CZ742lAHOazDMHixNkAj3OqkqfCVfMoxBth+NDFaap4M J2mXd/33rB29gR8LMwIyCaU8MYqsoI7GMBDmEfVC2/rc1BHCvyvfHuCTxyRkr/aM8LBu eArdRZ3NsHjuxZuNrpOYf51yq2ekN9T9YLrW1avgoSNHPKReIurNcWwGEMiTdR8fTxS7 tEIrObXp12lIadegsbB+j8rQWw6otbVGHB96aygjKg17F5NlOmyVDbbdu5WfC3HXAI9a 8KU+M2pB/1dP7oab9OOfMfpkBYP5XcwhdLX52BAFLqic5ijjNIicsqoES5La9iLxBsiw QOkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id y10si10483541pfp.167.2019.05.22.01.27.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 01:27:52 -0700 (PDT) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4M8Ro4K102482 for ; Wed, 22 May 2019 04:27:52 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2sn205tjkn-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 May 2019 04:27:51 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 22 May 2019 09:27:13 +0100 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 22 May 2019 09:27:10 +0100 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4M8R9H212583204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 May 2019 08:27:09 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C6DAC6057; Wed, 22 May 2019 08:27:09 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C00EAC605B; Wed, 22 May 2019 08:27:07 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.31.87]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 22 May 2019 08:27:07 +0000 (GMT) From: "Aneesh Kumar K.V" To: dan.j.williams@intel.com Cc: linux-nvdimm@lists.01.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [RFC PATCH V2 2/3] mm/nvdimm: Add page size and struct page size to pfn superblock Date: Wed, 22 May 2019 13:57:00 +0530 X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190522082701.6817-1-aneesh.kumar@linux.ibm.com> References: <20190522082701.6817-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19052208-0012-0000-0000-00001739F84E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011141; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01206885; UDB=6.00633780; IPR=6.00987860; MB=3.00026999; MTD=3.00000008; XFM=3.00000015; UTC=2019-05-22 08:27:12 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19052208-0013-0000-0000-0000575C5264 Message-Id: <20190522082701.6817-2-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-05-22_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905220062 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This is needed so that we don't wrongly initialize a namespace which doesn't have enough space reserved for holding struct pages with the current kernel. We also increment PFN_MIN_VERSION to make sure that older kernel won't initialize namespace created with newer kernel. Signed-off-by: Aneesh Kumar K.V --- drivers/nvdimm/pfn.h | 7 +++++-- drivers/nvdimm/pfn_devs.c | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/nvdimm/pfn.h b/drivers/nvdimm/pfn.h index 5fd29242745a..ba11738ca8a2 100644 --- a/drivers/nvdimm/pfn.h +++ b/drivers/nvdimm/pfn.h @@ -25,7 +25,7 @@ * kernel should fail to initialize that namespace. */ -#define PFN_MIN_VERSION 0 +#define PFN_MIN_VERSION 1 struct nd_pfn_sb { u8 signature[PFN_SIG_LEN]; @@ -43,7 +43,10 @@ struct nd_pfn_sb { /* minor-version-2 record the base alignment of the mapping */ __le32 align; __le16 min_version; - u8 padding[3998]; + /* minor-version-3 record the page size and struct page size */ + __le16 page_struct_size; + __le32 page_size; + u8 padding[3992]; __le64 checksum; }; diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index a2268cf262f5..39fa8cf8ef58 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -466,6 +466,15 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig) if (__le16_to_cpu(pfn_sb->version_minor) < 2) pfn_sb->align = 0; + if (__le16_to_cpu(pfn_sb->version_minor) < 3) { + /* + * For a large part we use PAGE_SIZE. But we + * do have some accounting code using SZ_4K. + */ + pfn_sb->page_struct_size = cpu_to_le16(64); + pfn_sb->page_size = cpu_to_le32(SZ_4K); + } + switch (le32_to_cpu(pfn_sb->mode)) { case PFN_MODE_RAM: case PFN_MODE_PMEM: @@ -481,6 +490,12 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig) align = 1UL << ilog2(offset); mode = le32_to_cpu(pfn_sb->mode); + if (le32_to_cpu(pfn_sb->page_size) != PAGE_SIZE) + return -EOPNOTSUPP; + + if (le16_to_cpu(pfn_sb->page_struct_size) != sizeof(struct page)) + return -EOPNOTSUPP; + if (!nd_pfn->uuid) { /* * When probing a namepace via nd_pfn_probe() the uuid @@ -775,11 +790,13 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) memcpy(pfn_sb->uuid, nd_pfn->uuid, 16); memcpy(pfn_sb->parent_uuid, nd_dev_to_uuid(&ndns->dev), 16); pfn_sb->version_major = cpu_to_le16(1); - pfn_sb->version_minor = cpu_to_le16(2); + pfn_sb->version_minor = cpu_to_le16(3); pfn_sb->min_version = cpu_to_le16(PFN_MIN_VERSION); pfn_sb->start_pad = cpu_to_le32(start_pad); pfn_sb->end_trunc = cpu_to_le32(end_trunc); pfn_sb->align = cpu_to_le32(nd_pfn->align); + pfn_sb->page_struct_size = cpu_to_le16(sizeof(struct page)); + pfn_sb->page_size = cpu_to_le32(PAGE_SIZE); checksum = nd_sb_checksum((struct nd_gen_sb *) pfn_sb); pfn_sb->checksum = cpu_to_le64(checksum); From patchwork Wed May 22 08:27:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 10955297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE16C13AD for ; Wed, 22 May 2019 08:27:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E107228A2E for ; Wed, 22 May 2019 08:27:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D54AF28AAC; Wed, 22 May 2019 08:27:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5086728A32 for ; Wed, 22 May 2019 08:27:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 599B06B0007; Wed, 22 May 2019 04:27:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 54AB96B0008; Wed, 22 May 2019 04:27:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 439D66B000A; Wed, 22 May 2019 04:27:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by kanga.kvack.org (Postfix) with ESMTP id 242426B0007 for ; Wed, 22 May 2019 04:27:18 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id y3so1418531ybg.12 for ; Wed, 22 May 2019 01:27:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:mime-version :content-transfer-encoding:message-id; bh=X9uBNzC2btm2KmWV6r/+ddlF60lonpFz8lJksHabHHE=; b=d+thF0Orp0Xl6OCYeSwM3k24pUbM2xNIMbtJNQdb7VHvmUfVJvxi5F+f5b/CwT5hLp 8GjUCTMSyNO3Zrch6yHQK/fvTGH5899oojzuOyoHNxFr7UdL2APUwKy0sZeUh8nVbwwk iardgns2xV+ZDZRgj0CSjxRXfRvlil3oKmSNCokWiMwpYmRcW16kBEYyycZbHL5moqA2 aJgWxj+UDUAyrt51s8BCRp3KaNCSVZBHtnolf5OTrwWK09kMQ+Drp+UoduxYkp8EKNPw l8Pt77ofdaKfyyFbLSVwr+iR02qzwCnhcDrbftTLWBd0YpdM/CtAq+4HWB4NMg8H/uqy zrWQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: APjAAAV2Rvn/PCmaSr1HSvI2yp4lA5Xx3Ul3F4lL02Qj4TK/CP3fkJBm nq+9B5gbBOd4HJ8BYLrZVlpe4arZP3M3DmTntIxScZ4ZGe5wEoa7NrVdQhdi+ZKy4Xw8gW/OLUe aM2pJAF7FSKzPowhwxQOJrkcTGjUIywuIzv/H4Z54F6ABw2BjpLktKDosn6uY2HDHWQ== X-Received: by 2002:a5b:30a:: with SMTP id j10mr18490275ybp.466.1558513637834; Wed, 22 May 2019 01:27:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhGvf1rE7yjvEeOQELiWyhOW0/w64NBOnzSYwVEf/lGxZc0i/HGER0cDUwDdciqf0WEVGI X-Received: by 2002:a5b:30a:: with SMTP id j10mr18490258ybp.466.1558513636740; Wed, 22 May 2019 01:27:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558513636; cv=none; d=google.com; s=arc-20160816; b=DgvJMU7OcX9TgrmUUkTmfcAg/6ITwQVOjKti/CFCYoNblEWCWlEFYfzrkq7R+nUgNX Z6KBfODHnPERnpQP+wVvTor5o/y8LD5IAFuPHnez9efVBOX/tkNorjqTTfAu5ofbd17/ TVT0Me9rGDR9UN9IP8pgizHKsfWFw9aQmLV8D1dWNPLvw8EUkrASvSmg6yYkaVo0ennG /45KgwuHvtGiRCwqgkBdvrNLrjB6BlOWwyFOZsc1QIxui6pDL/ZsAaonOTYOTBUuZXC/ akSIRuthEW5JOK1mDQWxO5Ws0x8xlGEwJpjjHx+NHOZ7fZ0BjIjLMhhXWnX1xrNPtWow Fd1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:content-transfer-encoding:mime-version:references :in-reply-to:date:subject:cc:to:from; bh=X9uBNzC2btm2KmWV6r/+ddlF60lonpFz8lJksHabHHE=; b=QbpT7S/U//tHW728OVMVHlE0Kkf5zDf2dSguLHCPUGAUMOB/m5GzQo6TB8utb+Q7UA 3xGS8Ckmivr4daFSZTGpCILowJn5g5cTj0kQBXiyTInVxSqoq+TuiuzRYZ7wb+exyR1O lL5646orcWAnUI3rv0E0t33mTuO7I6scN5UA6edyWBUT6RZ2QqT0THdldnj9pbF2cGSa plx4LZu95Z3a7aw5kpuno24fPeFU4eN9QYWv5IbD9aEH4oNkzAE5TlcXHhA8/BGJWS87 2FkpLvXXymsuK/JgU062lMitUpP43jbH1WKlN3j86J9kExRESd3NIFt/9m3Cr68EReKX 1GZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id n14si6288115ybp.91.2019.05.22.01.27.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 01:27:16 -0700 (PDT) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) client-ip=148.163.158.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4M8RGn1134519 for ; Wed, 22 May 2019 04:27:16 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0b-001b2d01.pphosted.com with ESMTP id 2sn1tpttb1-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 May 2019 04:27:16 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 22 May 2019 09:27:15 +0100 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 22 May 2019 09:27:12 +0100 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4M8RBSF30409194 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 May 2019 08:27:11 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9DC79C605B; Wed, 22 May 2019 08:27:11 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F33B4C6055; Wed, 22 May 2019 08:27:09 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.31.87]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 22 May 2019 08:27:09 +0000 (GMT) From: "Aneesh Kumar K.V" To: dan.j.williams@intel.com Cc: linux-nvdimm@lists.01.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [RFC PATCH V2 3/3] mm/nvdimm: Use correct #defines instead of opencoding Date: Wed, 22 May 2019 13:57:01 +0530 X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190522082701.6817-1-aneesh.kumar@linux.ibm.com> References: <20190522082701.6817-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19052208-0036-0000-0000-00000AC1343D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011141; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01206886; UDB=6.00633780; IPR=6.00987861; MB=3.00026999; MTD=3.00000008; XFM=3.00000015; UTC=2019-05-22 08:27:13 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19052208-0037-0000-0000-00004BE5854A Message-Id: <20190522082701.6817-3-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-05-22_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905220062 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The nfpn related change is needed to fix the kernel message "number of pfns truncated from 2617344 to 163584" The change makes sure the nfpns stored in the superblock is right value. Signed-off-by: Aneesh Kumar K.V --- drivers/nvdimm/label.c | 2 +- drivers/nvdimm/pfn_devs.c | 6 +++--- drivers/nvdimm/region_devs.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c index f3d753d3169c..bc6de8fb0153 100644 --- a/drivers/nvdimm/label.c +++ b/drivers/nvdimm/label.c @@ -361,7 +361,7 @@ static bool slot_valid(struct nvdimm_drvdata *ndd, /* check that DPA allocations are page aligned */ if ((__le64_to_cpu(nd_label->dpa) - | __le64_to_cpu(nd_label->rawsize)) % SZ_4K) + | __le64_to_cpu(nd_label->rawsize)) % PAGE_SIZE) return false; /* check checksum */ diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 39fa8cf8ef58..9fc2e514e28a 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -769,8 +769,8 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) * when populating the vmemmap. This *should* be equal to * PMD_SIZE for most architectures. */ - offset = ALIGN(start + reserve + 64 * npfns, - max(nd_pfn->align, PMD_SIZE)) - start; + offset = ALIGN(start + reserve + sizeof(struct page) * npfns, + max(nd_pfn->align, PMD_SIZE)) - start; } else if (nd_pfn->mode == PFN_MODE_RAM) offset = ALIGN(start + reserve, nd_pfn->align) - start; else @@ -782,7 +782,7 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) return -ENXIO; } - npfns = (size - offset - start_pad - end_trunc) / SZ_4K; + npfns = (size - offset - start_pad - end_trunc) / PAGE_SIZE; pfn_sb->mode = cpu_to_le32(nd_pfn->mode); pfn_sb->dataoff = cpu_to_le64(offset); pfn_sb->npfns = cpu_to_le64(npfns); diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index b4ef7d9ff22e..2d8facea5a03 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -994,10 +994,10 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus, struct nd_mapping_desc *mapping = &ndr_desc->mapping[i]; struct nvdimm *nvdimm = mapping->nvdimm; - if ((mapping->start | mapping->size) % SZ_4K) { - dev_err(&nvdimm_bus->dev, "%s: %s mapping%d is not 4K aligned\n", - caller, dev_name(&nvdimm->dev), i); - + if ((mapping->start | mapping->size) % PAGE_SIZE) { + dev_err(&nvdimm_bus->dev, + "%s: %s mapping%d is not 4K aligned\n", + caller, dev_name(&nvdimm->dev), i); return NULL; }