From patchwork Tue Jun 4 09:13:52 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: 10974455 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 4249D14B6 for ; Tue, 4 Jun 2019 09:14:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31C9D27F97 for ; Tue, 4 Jun 2019 09:14:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 258FC28689; Tue, 4 Jun 2019 09:14:20 +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 96DB027F97 for ; Tue, 4 Jun 2019 09:14:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 53CFB6B0271; Tue, 4 Jun 2019 05:14:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4ED926B0273; Tue, 4 Jun 2019 05:14: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 3B4716B0274; Tue, 4 Jun 2019 05:14:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f69.google.com (mail-yw1-f69.google.com [209.85.161.69]) by kanga.kvack.org (Postfix) with ESMTP id 162B76B0271 for ; Tue, 4 Jun 2019 05:14:18 -0400 (EDT) Received: by mail-yw1-f69.google.com with SMTP id d205so19117166ywe.8 for ; Tue, 04 Jun 2019 02:14: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:message-id:mime-version:content-transfer-encoding; bh=b2waML7tUSvmlU1YGL+N0av9auW8WPFKosUBIWaxKCo=; b=ObU4Hc+j9zoAj4TprUmEoZ286AqYAWW2wrOyyxyKYQ20fi+snkzWKfpRTZD7aGoiRf 4atvTqG0xZM8hHj5umlvvbK13V2+zgldGSyIUni9kCBhzDJT8XD7lB5h1k0MuJRqHrCv vv2NmQ0z0zfVKcTbhdZD0qonaXgtmY2SzvSQoSGu0fI75E4lMR7MnzPy8iWNHMnlZH8x fHONBriT12FU5zYJud6i7BSo3mgTCBlufiYTEjcw+Dj4MIz59wXXUuO2vbBu2Igs3IjC cdLTxM9KLL6nAbdux44WtkYOtBdH0uk66K7DVhzswtS0JMbCFvsRSo6dZ/bSp2ttG+5S Kzlw== 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: APjAAAUcd4iWDbOA8ArwtYs2Ye5fRxtLTVlmf9AwyAhXPomZEROcKhqI RGIYGWGN2Qr33HfOu374j+wfypQckJ9ghCzb46bybA22Eq1wjxoIXJ3rYEapYPfRqxTsh+dYK8o YTr78Sb/o3kU0Nwftew+wmETdwtxVvUefoRHGOulY5BgjPGWNLBV9Qpl479/O/6z3eA== X-Received: by 2002:a25:4ac9:: with SMTP id x192mr13562114yba.135.1559639657741; Tue, 04 Jun 2019 02:14:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwF/xwi6DLSaIK7k4ZU/FMrgS8b27pfVIqxQbDiFBl2AX48gMyWK58sq1wjF7hAUgJqrqGw X-Received: by 2002:a25:4ac9:: with SMTP id x192mr13562086yba.135.1559639656656; Tue, 04 Jun 2019 02:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559639656; cv=none; d=google.com; s=arc-20160816; b=hfJW2Dgz7I6k8GKiNL5nAqPtIsriSGTdvPdvkryTaF8BX8pJOHsA94icEYYs7u/HrM tb1ZdkRoHNJCYfAi1TF7AgD8b8wimmfPbKyxipTtsZ5sAgahwkdpMJKI31CTxpHslLee zbQkXuvfP656fYgsj9vyTfQJ8EBiQKQlZ75wwjHZHw/GkYz2HcCEkt3NooETrW87QAoT b022Iqsx6q0XYRErb9Wdc3gWmp6siHyamkQ54ZpO2F00y7kTONvapkYDiZmer5T4Rj74 MIAgn7PZIFXLnHtB9PG7ke3enJ5H1CSfPgsCSTQhv4A00DxZ6Nq0nJRLrrqS7Nw8s8mn drEQ== 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=b2waML7tUSvmlU1YGL+N0av9auW8WPFKosUBIWaxKCo=; b=Hk7BmTm8nmBMjg+lAxR0LKiM0gP+ghQvVk+nOTx/vf1yaMQxqIXevibIEXomAPyl4O VzSsE5AaiR8BWWHPmYVkzhvS05277FQ8kTf5oAlRK+trKD7UBAOKutx3os9tEzLwc2rL OWfSqj/MZPqd1FjhtmYUhThrCFVet02iS3WxHLriqsGs2V+c5rJY6dPThFRgAjKugWEM DzJYQwJvoAXNGC5Fs/MFxGvvXTl3bIj9J5HWuVoHO4302CpqTxsoW03sS1jCf/FUnX3E IpxfaCoHDuzBM97iGch897qchN6yaJUFylkUvd9NXuL/Url+djkrO/NiEbFBc5XVIVAO 88Fw== 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 186si5251441ybq.289.2019.06.04.02.14.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 02:14: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 (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5497XcC021735; Tue, 4 Jun 2019 05:14:14 -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 2swmk13qrd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Jun 2019 05:14:14 -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 x5438biT009398; Tue, 4 Jun 2019 03:19:16 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma01dal.us.ibm.com with ESMTP id 2suh097pgp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Jun 2019 03:19:16 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x549ECGC36372878 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Jun 2019 09:14:12 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7058EAC05F; Tue, 4 Jun 2019 09:14:12 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00CE0AC059; Tue, 4 Jun 2019 09:14:10 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.35.234]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 4 Jun 2019 09:14:10 +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: [PATCH v3 1/6] nvdimm: Consider probe return -EOPNOTSUPP as success Date: Tue, 4 Jun 2019 14:43:52 +0530 Message-Id: <20190604091357.32213-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-06-04_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 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-1906040061 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 With following patches we add EOPNOTSUPP as return from probe callback to indicate we were not able to initialize a namespace due to pfn superblock feature/version mismatch. We want to consider this a probe success so that we can create new namesapce seed and there by avoid marking the failed namespace as the seed namespace. Signed-off-by: Aneesh Kumar K.V --- drivers/nvdimm/bus.c | 4 ++-- drivers/nvdimm/nd-core.h | 3 ++- drivers/nvdimm/region_devs.c | 19 +++++++++++++++---- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c index 2eb6a6cfe9e4..792b3e90453b 100644 --- a/drivers/nvdimm/bus.c +++ b/drivers/nvdimm/bus.c @@ -100,8 +100,8 @@ static int nvdimm_bus_probe(struct device *dev) nvdimm_bus_probe_start(nvdimm_bus); rc = nd_drv->probe(dev); - if (rc == 0) - nd_region_probe_success(nvdimm_bus, dev); + if (rc == 0 || rc == -EOPNOTSUPP) + nd_region_probe_success(nvdimm_bus, dev, rc); else nd_region_disable(nvdimm_bus, dev); nvdimm_bus_probe_end(nvdimm_bus); diff --git a/drivers/nvdimm/nd-core.h b/drivers/nvdimm/nd-core.h index e5ffd5733540..9e67a79fb6d5 100644 --- a/drivers/nvdimm/nd-core.h +++ b/drivers/nvdimm/nd-core.h @@ -134,7 +134,8 @@ int __init nvdimm_bus_init(void); void nvdimm_bus_exit(void); void nvdimm_devs_exit(void); void nd_region_devs_exit(void); -void nd_region_probe_success(struct nvdimm_bus *nvdimm_bus, struct device *dev); +void nd_region_probe_success(struct nvdimm_bus *nvdimm_bus, + struct device *dev, int ret); struct nd_region; void nd_region_create_ns_seed(struct nd_region *nd_region); void nd_region_create_btt_seed(struct nd_region *nd_region); diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index b4ef7d9ff22e..fcf3d8828540 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -723,7 +723,7 @@ void nd_mapping_free_labels(struct nd_mapping *nd_mapping) * disable the region. */ static void nd_region_notify_driver_action(struct nvdimm_bus *nvdimm_bus, - struct device *dev, bool probe) + struct device *dev, bool probe, int ret) { struct nd_region *nd_region; @@ -753,6 +753,16 @@ static void nd_region_notify_driver_action(struct nvdimm_bus *nvdimm_bus, nd_region_create_ns_seed(nd_region); nvdimm_bus_unlock(dev); } + + if (dev->parent && is_nd_region(dev->parent) && + !probe && (ret == -EOPNOTSUPP)) { + nd_region = to_nd_region(dev->parent); + nvdimm_bus_lock(dev); + if (nd_region->ns_seed == dev) + nd_region_create_ns_seed(nd_region); + nvdimm_bus_unlock(dev); + } + if (is_nd_btt(dev) && probe) { struct nd_btt *nd_btt = to_nd_btt(dev); @@ -788,14 +798,15 @@ static void nd_region_notify_driver_action(struct nvdimm_bus *nvdimm_bus, } } -void nd_region_probe_success(struct nvdimm_bus *nvdimm_bus, struct device *dev) +void nd_region_probe_success(struct nvdimm_bus *nvdimm_bus, + struct device *dev, int ret) { - nd_region_notify_driver_action(nvdimm_bus, dev, true); + nd_region_notify_driver_action(nvdimm_bus, dev, true, ret); } void nd_region_disable(struct nvdimm_bus *nvdimm_bus, struct device *dev) { - nd_region_notify_driver_action(nvdimm_bus, dev, false); + nd_region_notify_driver_action(nvdimm_bus, dev, false, 0); } static ssize_t mappingN(struct device *dev, char *buf, int n) From patchwork Tue Jun 4 09:13:53 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: 10974465 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 EC9EB6C5 for ; Tue, 4 Jun 2019 09:14:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB3CF27F97 for ; Tue, 4 Jun 2019 09:14:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF70728725; Tue, 4 Jun 2019 09:14: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 407E827F97 for ; Tue, 4 Jun 2019 09:14:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 53DCA6B0274; Tue, 4 Jun 2019 05:14:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4ED616B0276; Tue, 4 Jun 2019 05:14:23 -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 38F066B0277; Tue, 4 Jun 2019 05:14:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id F0B636B0276 for ; Tue, 4 Jun 2019 05:14:22 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id 140so15672154pfa.23 for ; Tue, 04 Jun 2019 02:14:22 -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=kpoWseBFGA49tbcWqQaBX836YqFXpglIUaPpy4tHJyE=; b=LdgC0yA50HsHf1O5j9+27kF//2bPmJ3UZyi1/PelHY2Ya836lPDcuB7yO3FfEmq82Y pwJUgfpDAI0fJoECcSVm8lMoWLn5p49iRcw79ttZFeam8btjtJt+LKjLB7s24223YLVx vQh62OTgxHLKxPOjXspTa0Fou1JUhcEKifIXv/rYmcUKrkwoJLqvMGLn8zbMFZZNRH3h JYk3MHUXUzGQ51dCeCl62O9KfYV56iWoj/R5f9l/Zm3zA2TbTgPqEvpyPxLKjV0yvg53 a8eLGD/ckBKyEMPm0FGu2a5giQS88PAwIz6CPzFzN4I77IArYDcg3liKIBUIRkiJVD9X 6/rQ== 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: APjAAAWFskMZ9XzDyBCZDbZhueF65vAWcoUUh7RLYWJNclxDLHzXng7K oawlAimfTrEJWS1zVfX2E3+lKrbt82+x5Sr+h75/+A1L43VfUkwJMsL6dzCMO+jYKfpwv45es4k GodL4yWhy6D2sTkI+SYUH0jw3S8w73p+ZBxztgeb2sMN4Skz6aBLXGqK/F+59os11Yg== X-Received: by 2002:a17:902:860c:: with SMTP id f12mr35451975plo.127.1559639662472; Tue, 04 Jun 2019 02:14:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfREJZboJPr5xgriPKHFChu+jgMmQKl4wq1XjFaYIu3mCILYLbu/X8bBsPXsyWWUzzG0IQ X-Received: by 2002:a17:902:860c:: with SMTP id f12mr35451892plo.127.1559639660933; Tue, 04 Jun 2019 02:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559639660; cv=none; d=google.com; s=arc-20160816; b=EFfZMu4atNbg1lz1rDSUtWGe5kJlQq81SM1A67mOL2OEU+B43VYiSipMfguBlvbhBA 1cv/8IE3czIReZADF1ae7YyNu751BiXSu/7br3X4HL24W2O+uDNdgDjaav2U2DMtyrq0 zMnx+pYsMMqqXqJZ1tzmp/z3jVNlnqIpTkg98liktAPcY9bvOeIYfZu/S0kMYvS8goAm 2UNoi9h5VIv1qBigiLWfAbkYmc4I8hGUHDbRkrxrbaurDW4VEL1KH3PcCHAqBF1MUOHD q/smf1gM0HWDl/AYBEIZ1nZjm25ycnaeMZH3JpmOv9ARwFZoDvdS7Pd3SOw24x8p2Nd9 3TDA== 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=kpoWseBFGA49tbcWqQaBX836YqFXpglIUaPpy4tHJyE=; b=ENsmiuToh0C3I+kFDmwrW0VbLmTVfMx1iaLPpXSp+ndIJ6jhlQ5QjTaaY6iZDWCkXX aiQGBIIznyrM4fRB1WcFK8QENeda7qAM1HZ25FuuX5gDajd7Sbdl8JFu/j1y4oLrpNtz QE+4xfuAy+WcSG+gM7+7G89R0SMkAQ7z9nEgNU1DnHwY4CurIXuGZRJKcMjuQ4iGb1xk MjWAh4u9PlS//cqJ8ESmy50aacUnDNZHRxredpz8/iMonPN9ETOFFNjO39qbHdQ8mW9h vlR5bxpcu0Baf83qBq7WjlkoXWswI5krNCoqRUJpEpeRhN1rJIIUBQGGsQTF8I0W9keU XhNg== 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 f11si19924961plr.405.2019.06.04.02.14.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 02:14:20 -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 x5497dvp025070 for ; Tue, 4 Jun 2019 05:14:20 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2swkpaxdun-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 04 Jun 2019 05:14:20 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Jun 2019 10:14:19 +0100 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 4 Jun 2019 10:14:15 +0100 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x549EEnU15007958 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Jun 2019 09:14:14 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 528DCAC05F; Tue, 4 Jun 2019 09:14:14 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D6809AC060; Tue, 4 Jun 2019 09:14:12 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.35.234]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 4 Jun 2019 09:14:12 +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: [PATCH v3 2/6] mm/nvdimm: Add PFN_MIN_VERSION support Date: Tue, 4 Jun 2019 14:43:53 +0530 X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190604091357.32213-1-aneesh.kumar@linux.ibm.com> References: <20190604091357.32213-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19060409-0052-0000-0000-000003CB0714 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011212; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01213037; UDB=6.00637527; IPR=6.00994104; MB=3.00027178; MTD=3.00000008; XFM=3.00000015; UTC=2019-06-04 09:14:17 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19060409-0053-0000-0000-0000612A42D4 Message-Id: <20190604091357.32213-2-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-04_07:,, 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-1906040061 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 | 9 +++++++++ drivers/nvdimm/pmem.c | 26 ++++++++++++++++++++++---- 3 files changed, 39 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..00c57805cad3 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -439,6 +439,14 @@ 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 %d kernel" + " support version %d\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 +777,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 d9d845077b8b..eddc28e8c357 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -496,6 +496,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); @@ -511,12 +512,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 Tue Jun 4 09:13:54 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: 10974475 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 036D46C5 for ; Tue, 4 Jun 2019 09:15:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6FED271CB for ; Tue, 4 Jun 2019 09:15:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB0AE280FC; Tue, 4 Jun 2019 09:15:39 +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 561F9271CB for ; Tue, 4 Jun 2019 09:15:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7ACB76B0271; Tue, 4 Jun 2019 05:15:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7842B6B0273; Tue, 4 Jun 2019 05:15:38 -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 674366B0274; Tue, 4 Jun 2019 05:15:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 305EB6B0271 for ; Tue, 4 Jun 2019 05:15:38 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id u7so15689175pfh.17 for ; Tue, 04 Jun 2019 02:15:38 -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=yguVnoaVzkDkIEIYhWjcYSoglpBtVHAkjKX1ZneHBVg=; b=fysQx5WriUqsVG5sWokHFYE4/wQUSpxh5U2UDI/Adj7sZHc97rIywHUU8kO+TVSQ8U YwxVUXPzycdaRSYkeANqG1RGMlqlOH/vP4921aapyRTezl0euXxNk6SVp1BmPeLF8ue0 BDHWcAIuok9RVvs4pIIf5CKG6yKTFiDLnpFvxDGTjrc6CoTws+bnMu5Blj1gZ4o/fNiN jlwu6FPICQ3isQPlhSKstrehY1mpX46xretNRIXiNrTEog2O5e4Rx2VZAMpyYc0UHCjF gF2OkTB/la3E2Jh/CsOWLk3b/ZE3MpnT4tfK6zWPHNVHM2ZRN3fxw7B7gkwMEcxhoDba Kecg== 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: APjAAAUhYywGS5SsiUGAK3qT4Ld58EPcn41tNu0BaGoJaGzsZPK0D92y IPQtRtx7gnGlPU0cQTvc1KvuKHvQtsAvyAmwXI9rKZ55IS/u0XM5O2a2bvMH9nJZrq+q2N9ALBG jY2b1914m0jRZBP5ssCe7h6lrnq2uOnTlrZZP/K66Dg/oEnKGItoh9R0FdYghYeZxZQ== X-Received: by 2002:a17:902:8546:: with SMTP id d6mr27122151plo.207.1559639737626; Tue, 04 Jun 2019 02:15:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBSN034MPZ4IYakp7ZOsaGmjg/C80thyvFtkW+fjDmpAlOmXW+ck2bzZQpc2j8fBTPEln1 X-Received: by 2002:a17:902:8546:: with SMTP id d6mr27122099plo.207.1559639736688; Tue, 04 Jun 2019 02:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559639736; cv=none; d=google.com; s=arc-20160816; b=dDce5yvoEVsFWF2WP8UMbzM2u6BZ4v6TyrbsgYsCJgucAFJsukFv2WFz1xdayvsAni sZ5DPh+IlQoCBzHNyvDO224MtOK4YlbA9vQvdNKQZCt3omC0NYUQrOUMJdvWkxfVvOg8 7FNkV2gyay+6spMxxpSmywJOrim0PkAsazI76W1iQ/CWsBq775jmXlgQgLaYdHaEo2Qp /iix+J31l3ekyn9l9on1Y5hDyGAusrgF38nFLQbg6p+5rgf9of/lHm1Dc31lx8iLs6na rxz1FWvqpKIa2c9xelGTpHI8AI+/V5kr/xQEdPvAPsqaMViLpINjBMJw+JSaTEb7dUam FlKg== 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=yguVnoaVzkDkIEIYhWjcYSoglpBtVHAkjKX1ZneHBVg=; b=uS6cq1yj0XiYrt7LnWCpdv2mOpJRqe/A8I4Q2kzWFeURGi7Hx67ONreMI/6+xI5XHt nKN9ebGz3U5XXT7OHb+r78QoxBujWEug8qOGpM+QeXpCmK7It9CICSjJuzSJsMdvbxvQ OMlUQoY9wBQ7+Q9goexh6xPAhfTIzSeYx6YN2sO9IwiXveNxcoXUxUJFKBEhEHHAelUd GMzQw5//IPY+VkCGmy6StuTYnxIbZcWqa2kUe2jFGrneiNkB4DtjtW4kO7DIQmbtIh2M sZ6hAFIEocM8unjq78CF/RZDByvQNkQxjrj97Xo/EIX4zGzaNzeMgpJ6lgUexIywJLRG LKCQ== 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 b7si20391972pgk.553.2019.06.04.02.15.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 02:15:36 -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 x5497iD6101210 for ; Tue, 4 Jun 2019 05:15:36 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2swksswp13-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 04 Jun 2019 05:15:35 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Jun 2019 10:15:34 +0100 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 4 Jun 2019 10:15:31 +0100 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x549EG1W19136674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Jun 2019 09:14:16 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30FF8AC059; Tue, 4 Jun 2019 09:14:16 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B5B11AC06C; Tue, 4 Jun 2019 09:14:14 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.35.234]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 4 Jun 2019 09:14:14 +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: [PATCH v3 3/6] mm/nvdimm: Add page size and struct page size to pfn superblock Date: Tue, 4 Jun 2019 14:43:54 +0530 X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190604091357.32213-1-aneesh.kumar@linux.ibm.com> References: <20190604091357.32213-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19060409-0060-0000-0000-0000034BD878 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011212; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01213038; UDB=6.00637528; IPR=6.00994105; MB=3.00027178; MTD=3.00000008; XFM=3.00000015; UTC=2019-06-04 09:15:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19060409-0061-0000-0000-0000499E0CF1 Message-Id: <20190604091357.32213-3-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-04_07:,, 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-1906040061 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 | 27 ++++++++++++++++++++++++++- 2 files changed, 31 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 00c57805cad3..e01eee9efafe 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -467,6 +467,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: @@ -482,6 +491,20 @@ 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) { + dev_err(&nd_pfn->dev, + "init failed, page size mismatch %d\n", + le32_to_cpu(pfn_sb->page_size)); + return -EOPNOTSUPP; + } + + if (le16_to_cpu(pfn_sb->page_struct_size) != sizeof(struct page)) { + dev_err(&nd_pfn->dev, + "init failed, struct page size mismatch %d\n", + le16_to_cpu(pfn_sb->page_struct_size)); + return -EOPNOTSUPP; + } + if (!nd_pfn->uuid) { /* * When probing a namepace via nd_pfn_probe() the uuid @@ -776,11 +799,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 Tue Jun 4 09:13:55 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: 10974461 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 9776714B6 for ; Tue, 4 Jun 2019 09:14:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86C1227F97 for ; Tue, 4 Jun 2019 09:14:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AD8328689; Tue, 4 Jun 2019 09:14:24 +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 EAA2727F97 for ; Tue, 4 Jun 2019 09:14:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E3D736B0273; Tue, 4 Jun 2019 05:14:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DEEBC6B0274; Tue, 4 Jun 2019 05:14:22 -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 CB63D6B0276; Tue, 4 Jun 2019 05:14:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f69.google.com (mail-yw1-f69.google.com [209.85.161.69]) by kanga.kvack.org (Postfix) with ESMTP id A89516B0273 for ; Tue, 4 Jun 2019 05:14:22 -0400 (EDT) Received: by mail-yw1-f69.google.com with SMTP id o135so887847ywo.16 for ; Tue, 04 Jun 2019 02:14:22 -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=uHQOzTIkv8fvCjT6NRsoq9W8F2Km2qYgIp3prs4rNoM=; b=bMGubwQCahxBNDSD9+XhB3lqQCiHQVREIDFOLrfuJfVQzRFv0/A2zRdy2hlFVyajwm H1dvcqkr+463IWNOdQZiWlT3ZSclsLu0rehSbXbJuUNC+whMti9mQZl5+3xxuCijmOic 9qWRUKtGfgNgC/S8wIQPdMrCQb1i6OFuQdzbl4fD1EHWN/qINctE7o2m9EyC3p2c/CGF TACKbB+Bv1nSeb+RhjNjSq/kH/bCPZGjgPBkHn9/nhlYudA073Hdfgw9bdcQO0UXw/W+ m96ONF1IkQLOPSz77pmSY66ExKLSYCkuRuA0KL5nWDwsy0mbH5Kqmz+m1QxH6Bj9rnru k0lw== 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: APjAAAWSjxkJhiMZmQqOpkE1V3GDHB29IxczVXCUX4PatGR13WX1lcHq 4vcXTkO3/bFE6Y6QNGsUJb7HhEGTsKVuyc2mOZeFPpA/rzcAE5svPBzoRyQbS+vLpcvWWagLvkv WziSJWR4gCvZb2Ldpu0EzsEAjPo2dJgH8ZRDmEA9ti3nSrMD5cA3NUhBYJXQDLsOpZA== X-Received: by 2002:a81:480f:: with SMTP id v15mr3096002ywa.144.1559639662448; Tue, 04 Jun 2019 02:14:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqznxdRtsqPMJxeVL83ulFa9g0aNiZgC3gRmOCD1YFl4pt3aigaUA4Ucj3dYi7otf9LTSXmm X-Received: by 2002:a81:480f:: with SMTP id v15mr3095984ywa.144.1559639661797; Tue, 04 Jun 2019 02:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559639661; cv=none; d=google.com; s=arc-20160816; b=r9gZK7ZkNlckeTFWr/rflckZZwJw3WZu1XEgaNvlM8ulQQxvx9UFh82SLmZjN/rMBq Q0oLeMCH/lZPaZQt+wJQ3jAdhwbzisKZMkAupFutaVi1fI6DyxMr+E0kx6Vbv76108aI Lk0PVtO0M15J3RMKHrbaOAatcifHxoD9Klzd7Z0+eQrn5H4ODaXR6l4HaovhZ/+Y5a2l 0cjZSK7G6IE81XXfA2dBX5NU8x77Cgc/Tf8jucceaot4/Nsvkoghu/aZlSFNa2PsPMK+ L5dvtijXLdthiQJ8+c09mh1+6MtZheyqRXciYoYeNUFIXoh4BZZJTTBTFtWDrKIsv6cA sJuw== 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=uHQOzTIkv8fvCjT6NRsoq9W8F2Km2qYgIp3prs4rNoM=; b=AJnJA8G6pKOLo5EM5dDg7Wzp8ZIrdENlt0Kj+c9nyzHRzGxjbQ+iZGVcoSZ/KG6Dej 4917kUArktmElMeujOWNS5hqQLQ7qBf3goQyU4iN7b78sXWyVhPXEZ9Kgs/PLfWxMUx8 NWSySrZkzWheqMy26UoFFPoDd2ypXP//RHgF9QPmf/NltfECJxZeEPkk7KyCiLxbFtVB T/+QV6ek2XFrLvt6KjPBAAEJc5TO+TjHP+OaMkfbQc9UltZdedtVrffvv3k7PdFFzR6+ pG53R5ph0tG6h0lqXg8t4PWswQn2GTar2tvQRfNtPETvsrZFLHA3R2oFURfjqCFpNQKF U/bA== 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 e132si4869299ybe.235.2019.06.04.02.14.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 02:14:21 -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 (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5497bge073127 for ; Tue, 4 Jun 2019 05:14:21 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2swjwvqxnj-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 04 Jun 2019 05:14:21 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Jun 2019 10:14:20 +0100 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 4 Jun 2019 10:14:19 +0100 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x549EIIh37487078 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Jun 2019 09:14:18 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 102A4AC05B; Tue, 4 Jun 2019 09:14:18 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 944AFAC05F; Tue, 4 Jun 2019 09:14:16 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.35.234]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 4 Jun 2019 09:14:16 +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: [PATCH v3 4/6] mm/nvdimm: Use correct #defines instead of opencoding Date: Tue, 4 Jun 2019 14:43:55 +0530 X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190604091357.32213-1-aneesh.kumar@linux.ibm.com> References: <20190604091357.32213-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19060409-0040-0000-0000-000004F8624C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011212; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01213037; UDB=6.00637528; IPR=6.00994104; MB=3.00027178; MTD=3.00000008; XFM=3.00000015; UTC=2019-06-04 09:14:20 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19060409-0041-0000-0000-000009048050 Message-Id: <20190604091357.32213-4-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-04_07:,, 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-1906040061 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/namespace_devs.c | 6 +++--- drivers/nvdimm/pfn_devs.c | 6 +++--- drivers/nvdimm/region_devs.c | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c index edf278067e72..c5f28c48bde4 100644 --- a/drivers/nvdimm/label.c +++ b/drivers/nvdimm/label.c @@ -363,7 +363,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/namespace_devs.c b/drivers/nvdimm/namespace_devs.c index d0214644e334..c4c5a191b1d6 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -1014,10 +1014,10 @@ static ssize_t __size_store(struct device *dev, unsigned long long val) return -ENXIO; } - div_u64_rem(val, SZ_4K * nd_region->ndr_mappings, &remainder); + div_u64_rem(val, PAGE_SIZE * nd_region->ndr_mappings, &remainder); if (remainder) { - dev_dbg(dev, "%llu is not %dK aligned\n", val, - (SZ_4K * nd_region->ndr_mappings) / SZ_1K); + dev_dbg(dev, "%llu is not %ldK aligned\n", val, + (PAGE_SIZE * nd_region->ndr_mappings) / SZ_1K); return -EINVAL; } diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index e01eee9efafe..d137f52f46ee 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -778,8 +778,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 @@ -791,7 +791,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 fcf3d8828540..139d7b45b337 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -1005,10 +1005,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 %ld aligned\n", + caller, dev_name(&nvdimm->dev), i, PAGE_SIZE); return NULL; } From patchwork Tue Jun 4 09:13:56 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: 10974471 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 CB7916C5 for ; Tue, 4 Jun 2019 09:14:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAC1727F97 for ; Tue, 4 Jun 2019 09:14:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AECD228068; Tue, 4 Jun 2019 09:14:29 +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 E4E6628725 for ; Tue, 4 Jun 2019 09:14:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A6CA6B0276; Tue, 4 Jun 2019 05:14:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 20C976B0277; Tue, 4 Jun 2019 05:14:27 -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 0338E6B0278; Tue, 4 Jun 2019 05:14:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f69.google.com (mail-yw1-f69.google.com [209.85.161.69]) by kanga.kvack.org (Postfix) with ESMTP id D5CAE6B0276 for ; Tue, 4 Jun 2019 05:14:26 -0400 (EDT) Received: by mail-yw1-f69.google.com with SMTP id t141so19085162ywe.23 for ; Tue, 04 Jun 2019 02:14:26 -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=jU7nJGZqz3W+OPqACHi+vSvZlVzpNc8/McjlBMHYsnE=; b=lI7jWWMbKGOtV0IQVSWBVi252/Sijtg+tIHLgHi0EratrryqaTWzz30s60J1y3IZD2 acMhu4G/R/plLSDwi5tMn3r61hPB4iH2PByO4clwAFvpJO8/QA9JyPEZA05dXpDOeWXY EGk/555V87Cw89y/KaPG+xGmtIGg0MBrI7WuKWi9qH4u+MNSkzG6caXRNzNRZ22v5+h5 /nFzGkztbWoHKN9LKMUPBuiQG9Hf0FdFRfb6ffVmWxmYc99MTFGdbU0vWgXbZOCIG7b7 iq09o32evbnCtVhtXEVto9NH4yITKtU3Dh5tUytoFNEEqS9Qx3gA32dbc3ljH2tQs9iL dVYw== 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: APjAAAUXfJuQqKF8hlR0lWiLfDYGwQ6YkOFp/wgLrIu+MCY1ddHpQaui IVEfoPXqPlTzCrCWg1f+pxDAwbGoZNuS8lyjEU+3ZErqPoTyk1lBUkq0Hic6CmVQgGAe9BzX57r ejuRbZ/3J9GWslQBuAiKKJp2HP0/anfaa63Gay8taVhjNeLtNdqHPQBpB4U+Xs5sKng== X-Received: by 2002:a25:7712:: with SMTP id s18mr14242406ybc.263.1559639666562; Tue, 04 Jun 2019 02:14:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzaPo8kCnZxOPcr2GMgJgUPLiDEhFthaym2zpQ21SfDg0BbjneYWM01B043eosn17Z3x/q X-Received: by 2002:a25:7712:: with SMTP id s18mr14242372ybc.263.1559639665457; Tue, 04 Jun 2019 02:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559639665; cv=none; d=google.com; s=arc-20160816; b=unCjTB+WcqAPsp/hG3HAyqYxvWcCro6G1+PLottulVOKg1heNocxBghkhNL1XD3IG6 LXnjj6teVtJrPM4OAtvC1FZ67t5gMl8T0N1F+MMznfJ4EvgFu1sWz8d29HOcp5T3qi5t 8qidq40ceHUjkTPHQpsDmLAo/U3TjnRoM5orol7EhxVr4CEaDif9qcl/iUUjMHAL5VqD S+j6L8qm6J7O0p+c6mAFTepbCovHPxO2FpgYcJXwgMfhmGXj6kaTaYIfoUwig/Tp1G8Q rn1VW/ChJFsgf8chSvVyHPaL8A2KMPRzuJQ8/UOEl61VR5b3FQxv3stqgV528NnIUZxj tYgw== 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=jU7nJGZqz3W+OPqACHi+vSvZlVzpNc8/McjlBMHYsnE=; b=gJks0iZ6hOf1O8VY6TL26QPUD05djq917yeaEG+6L1Vm4XTDx4/E7CLS6qvXdHuv9l a1qMIqgsxkFbqGVc0E0ZytS4VNr3B5QSK9wrTC0bcGaRpFupng/u2EjBjZ+isRG36YG9 BRmwVYenI/3O6AGR8Qdy920gcylT/70HWHwOkBKw8zUszJBlAfDPMrSTJXT1gwkTYR9W ZCmjWXjkelHXchm0GuHIxhiAkKkW7AXQITEORdnIA2YtkP4RUgHytMmP90fe1DyD6wSP y/m07VjosXvztEqye+J3Y3AvuJfunVMoE79j3UO5MACAJQ+UC1bPG06Mozc5l2kl4Qoh MHWQ== 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 127si4835519ybu.373.2019.06.04.02.14.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 02:14:25 -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 (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5497Zka072920 for ; Tue, 4 Jun 2019 05:14:25 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2swjwvqxqg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 04 Jun 2019 05:14:24 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Jun 2019 10:14:24 +0100 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 4 Jun 2019 10:14:20 +0100 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x549EKjY34603294 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Jun 2019 09:14:20 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E614AAC05B; Tue, 4 Jun 2019 09:14:19 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7647CAC068; Tue, 4 Jun 2019 09:14:18 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.35.234]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 4 Jun 2019 09:14:18 +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: [PATCH v3 5/6] mm/nvdimm: Pick the right alignment default when creating dax devices Date: Tue, 4 Jun 2019 14:43:56 +0530 X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190604091357.32213-1-aneesh.kumar@linux.ibm.com> References: <20190604091357.32213-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19060409-0060-0000-0000-0000034BD866 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011212; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01213037; UDB=6.00637528; IPR=6.00994104; MB=3.00027178; MTD=3.00000008; XFM=3.00000015; UTC=2019-06-04 09:14:22 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19060409-0061-0000-0000-0000499E0C1C Message-Id: <20190604091357.32213-5-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-04_07:,, 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-1906040061 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 Allow arch to provide the supported alignments and use hugepage alignment only if we support hugepage. Right now we depend on compile time configs whereas this patch switch this to runtime discovery. Architectures like ppc64 can have THP enabled in code, but then can have hugepage size disabled by the hypervisor. This allows us to create dax devices with PAGE_SIZE alignment in this case. Existing dax namespace with alignment larger than PAGE_SIZE will fail to initialize in this specific case. We still allow fsdax namespace initialization. With respect to identifying whether to enable hugepage fault for a dax device, if THP is enabled during compile, we default to taking hugepage fault and in dax fault handler if we find the fault size > alignment we retry with PAGE_SIZE fault size. This also addresses the below failure scenario on ppc64 ndctl create-namespace --mode=devdax | grep align "align":16777216, "align":16777216 cat /sys/devices/ndbus0/region0/dax0.0/supported_alignments 65536 16777216 daxio.static-debug -z -o /dev/dax0.0 Bus error (core dumped) $ dmesg | tail lpar: Failed hash pte insert with error -4 hash-mmu: mm: Hashing failure ! EA=0x7fff17000000 access=0x8000000000000006 current=daxio hash-mmu: trap=0x300 vsid=0x22cb7a3 ssize=1 base psize=2 psize 10 pte=0xc000000501002b86 daxio[3860]: bus error (7) at 7fff17000000 nip 7fff973c007c lr 7fff973bff34 code 2 in libpmem.so.1.0.0[7fff973b0000+20000] daxio[3860]: code: 792945e4 7d494b78 e95f0098 7d494b78 f93f00a0 4800012c e93f0088 f93f0120 daxio[3860]: code: e93f00a0 f93f0128 e93f0120 e95f0128 e93f0088 39290008 f93f0110 The failure was due to guest kernel using wrong page size. The namespaces created with 16M alignment will appear as below on a config with 16M page size disabled. $ ndctl list -Ni [ { "dev":"namespace0.1", "mode":"fsdax", "map":"dev", "size":5351931904, "uuid":"fc6e9667-461a-4718-82b4-69b24570bddb", "align":16777216, "blockdev":"pmem0.1", "supported_alignments":[ 65536 ] }, { "dev":"namespace0.0", "mode":"fsdax", <==== devdax 16M alignment marked disabled. "map":"mem", "size":5368709120, "uuid":"a4bdf81a-f2ee-4bc6-91db-7b87eddd0484", "state":"disabled" } ] Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/include/asm/libnvdimm.h | 9 ++++++++ arch/powerpc/mm/Makefile | 1 + arch/powerpc/mm/nvdimm.c | 34 ++++++++++++++++++++++++++++ arch/x86/include/asm/libnvdimm.h | 19 ++++++++++++++++ drivers/nvdimm/nd.h | 6 ----- drivers/nvdimm/pfn_devs.c | 32 +++++++++++++++++++++++++- include/linux/huge_mm.h | 7 +++++- 7 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 arch/powerpc/include/asm/libnvdimm.h create mode 100644 arch/powerpc/mm/nvdimm.c create mode 100644 arch/x86/include/asm/libnvdimm.h diff --git a/arch/powerpc/include/asm/libnvdimm.h b/arch/powerpc/include/asm/libnvdimm.h new file mode 100644 index 000000000000..d35fd7f48603 --- /dev/null +++ b/arch/powerpc/include/asm/libnvdimm.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_POWERPC_LIBNVDIMM_H +#define _ASM_POWERPC_LIBNVDIMM_H + +#define nd_pfn_supported_alignments nd_pfn_supported_alignments +extern unsigned long *nd_pfn_supported_alignments(void); +extern unsigned long nd_pfn_default_alignment(void); + +#endif diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile index 0f499db315d6..42e4a399ba5d 100644 --- a/arch/powerpc/mm/Makefile +++ b/arch/powerpc/mm/Makefile @@ -20,3 +20,4 @@ obj-$(CONFIG_HIGHMEM) += highmem.o obj-$(CONFIG_PPC_COPRO_BASE) += copro_fault.o obj-$(CONFIG_PPC_PTDUMP) += ptdump/ obj-$(CONFIG_KASAN) += kasan/ +obj-$(CONFIG_NVDIMM_PFN) += nvdimm.o diff --git a/arch/powerpc/mm/nvdimm.c b/arch/powerpc/mm/nvdimm.c new file mode 100644 index 000000000000..a29a4510715e --- /dev/null +++ b/arch/powerpc/mm/nvdimm.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include + +#include +/* + * We support only pte and pmd mappings for now. + */ +const unsigned long *nd_pfn_supported_alignments(void) +{ + static unsigned long supported_alignments[3]; + + supported_alignments[0] = PAGE_SIZE; + + if (has_transparent_hugepage()) + supported_alignments[1] = HPAGE_PMD_SIZE; + else + supported_alignments[1] = 0; + + supported_alignments[2] = 0; + return supported_alignments; +} + +/* + * Use pmd mapping if supported as default alignment + */ +unsigned long nd_pfn_default_alignment(void) +{ + + if (has_transparent_hugepage()) + return HPAGE_PMD_SIZE; + return PAGE_SIZE; +} diff --git a/arch/x86/include/asm/libnvdimm.h b/arch/x86/include/asm/libnvdimm.h new file mode 100644 index 000000000000..3d5361db9164 --- /dev/null +++ b/arch/x86/include/asm/libnvdimm.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_LIBNVDIMM_H +#define _ASM_X86_LIBNVDIMM_H + +static inline unsigned long nd_pfn_default_alignment(void) +{ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + return HPAGE_PMD_SIZE; +#else + return PAGE_SIZE; +#endif +} + +static inline unsigned long nd_altmap_align_size(unsigned long nd_align) +{ + return PMD_SIZE; +} + +#endif diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h index 191d62af0e51..524be92c1cd0 100644 --- a/drivers/nvdimm/nd.h +++ b/drivers/nvdimm/nd.h @@ -296,12 +296,6 @@ static inline struct device *nd_btt_create(struct nd_region *nd_region) struct nd_pfn *to_nd_pfn(struct device *dev); #if IS_ENABLED(CONFIG_NVDIMM_PFN) -#ifdef CONFIG_TRANSPARENT_HUGEPAGE -#define PFN_DEFAULT_ALIGNMENT HPAGE_PMD_SIZE -#else -#define PFN_DEFAULT_ALIGNMENT PAGE_SIZE -#endif - int nd_pfn_probe(struct device *dev, struct nd_namespace_common *ndns); bool is_nd_pfn(struct device *dev); struct device *nd_pfn_create(struct nd_region *nd_region); diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index d137f52f46ee..9855357c9040 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "nd-core.h" #include "pfn.h" #include "nd.h" @@ -111,6 +112,8 @@ static ssize_t align_show(struct device *dev, return sprintf(buf, "%ld\n", nd_pfn->align); } +#ifndef nd_pfn_supported_alignments +#define nd_pfn_supported_alignments nd_pfn_supported_alignments static const unsigned long *nd_pfn_supported_alignments(void) { /* @@ -133,6 +136,7 @@ static const unsigned long *nd_pfn_supported_alignments(void) return data; } +#endif static ssize_t align_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) @@ -310,7 +314,7 @@ struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn, return NULL; nd_pfn->mode = PFN_MODE_NONE; - nd_pfn->align = PFN_DEFAULT_ALIGNMENT; + nd_pfn->align = nd_pfn_default_alignment(); dev = &nd_pfn->dev; device_initialize(&nd_pfn->dev); if (ndns && !__nd_attach_ndns(&nd_pfn->dev, ndns, &nd_pfn->ndns)) { @@ -420,6 +424,20 @@ static int nd_pfn_clear_memmap_errors(struct nd_pfn *nd_pfn) return 0; } +static bool nd_supported_alignment(unsigned long align) +{ + int i; + const unsigned long *supported = nd_pfn_supported_alignments(); + + if (align == 0) + return false; + + for (i = 0; supported[i]; i++) + if (align == supported[i]) + return true; + return false; +} + int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig) { u64 checksum, offset; @@ -505,6 +523,18 @@ int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig) return -EOPNOTSUPP; } + /* + * Check whether the we support the alignment. For Dax if the + * superblock alignment is not matching, we won't initialize + * the device. + */ + if (!nd_supported_alignment(align) && + !memcmp(pfn_sb->signature, DAX_SIG, PFN_SIG_LEN)) { + dev_err(&nd_pfn->dev, "init failed, alignment mismatch: " + "%lx:%lx\n", nd_pfn->align, align); + return -EOPNOTSUPP; + } + if (!nd_pfn->uuid) { /* * When probing a namepace via nd_pfn_probe() the uuid diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 7cd5c150c21d..64d16794bb27 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -108,7 +108,12 @@ static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma) if (transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_FLAG)) return true; - + /* + * For dax let's try to do hugepage fault always. If we don't support + * hugepages we will not have enabled namespaces with hugepage alignment. + * This also means we try to handle hugepage fault on device with + * smaller alignment. But for then we will return with VM_FAULT_FALLBACK + */ if (vma_is_dax(vma)) return true; From patchwork Tue Jun 4 09:13:57 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: 10974473 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 88F6914B6 for ; Tue, 4 Jun 2019 09:14:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7508D28068 for ; Tue, 4 Jun 2019 09:14:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 659F728726; Tue, 4 Jun 2019 09:14:32 +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 90F5D28068 for ; Tue, 4 Jun 2019 09:14:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6279D6B0277; Tue, 4 Jun 2019 05:14:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5D8B96B0278; Tue, 4 Jun 2019 05:14:29 -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 4A0236B0279; Tue, 4 Jun 2019 05:14:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by kanga.kvack.org (Postfix) with ESMTP id 2524C6B0277 for ; Tue, 4 Jun 2019 05:14:29 -0400 (EDT) Received: by mail-yb1-f200.google.com with SMTP id v5so635102ybq.17 for ; Tue, 04 Jun 2019 02:14:29 -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=DfCc8c1U4s8yOXO1igLbWqvoORiyMSAIleJlok7k80w=; b=cRRhTmZYM3IG9kT8N6NRIO84rQBMRRMSCHCWLrRKKVHTs7nov+P/U902/iSmauNMJk nk8n5lsW7vz/XSVdOYn0QjTn7ibwgERDdDkkIF6aLjDg8Go4kitzoZnqHZ/a/FSrxSXz 12RC3aVODKLPz4u9VL87ct5VmPvpYkiSY3OJsJViNOlcGtNGKHxjklfFPZauWnXGPriI 7f5SGyVYvfeFNORWc/lRYqlMNKVUNQwkGrXptJYY6XDzJIbtgmFiHzDEKQUYSA5S2syX pTMwZ+N9oOadOyUG0ej1hAX9ll1xdXeBxglyCbLZEQf/2sWKaRzYT/5NGkEOK9GTh/Av G2Yg== 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: APjAAAV4tJkc4o2zMZZN7tcVKTGP6MbNQ/I15c5LF36HN45mFbAIn36E sC/YOvihIqjsfawzg/Y3iHJ7zX/HyhZEJJaSnE82Oi3tXnEL01kxvgeUyLz1GUb+7kv4nITQu0V FIsgGQCFPTriBOZypjBQAs61zRzLnsXn4j4/Cz7VQP4tnJujhwtCRe7ybjmg0VTIEEA== X-Received: by 2002:a81:270c:: with SMTP id n12mr6437357ywn.134.1559639668648; Tue, 04 Jun 2019 02:14:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyM5H8Q6QrMUAdOH/qfu+w7tgozpyBc4fpDkkn0i7ZnPiOg+v2tt7TB2A8GdnhYypY7RFTK X-Received: by 2002:a81:270c:: with SMTP id n12mr6437338ywn.134.1559639668058; Tue, 04 Jun 2019 02:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559639668; cv=none; d=google.com; s=arc-20160816; b=eyz5cPCo/bE0aB2uEtV7S7utWcopReRqWyRk0lk8trAJLkmiX1x6hiZxWSURlIzoFt wFHczyoHSiamXwDWDajVKYH5Bvj7ndeINsJgfmaNTNAsL659qyu4zyeI0abiLkNKEq/u LoavLYvXIZ/8mCuZyNZwbkkEGp6/7aT2GCR5GGqH4Pit9s16hE7VeBJ0WL7ZNMAuB5c1 QGK+YKj/g8TPWT7C/4XmrExpjBgS2NEd3xfzmrnUIv9jKKa5I1NBg/CC23RHCEn6+z05 JIJjW4EuKiwRap6yjdTb2ZgWVBRpvQLVapQ5bqVjfBONU86N7ULMHclHNs5Q2XOnjsTq q4hw== 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=DfCc8c1U4s8yOXO1igLbWqvoORiyMSAIleJlok7k80w=; b=cnl7CQVLy/1KaXoZsmvgQP1+2NvSjE7i+l9FDWJ1H/9A6Cvi/2VU4I8HTz/rbsSBT0 H12Z7gdCuSAUdwIP8OuorbdJrIDyDd6txWXsVnN6ZFlWgEVglmC0spNpiLmeU5HdJFJ/ 9bv92F5+44bq8t0EwzjSTDXsFw911R7U8of6ehjJTboS7seRXZ+ogdg+PsV8cOiC95Kc EevqL525Bj/0hS1EbKatf5Qlvp+Wh1Ysfb1O6q3VGn1E2jsbfMoMzYxIHhAEUiiwRe54 c5v+1afA6Rxo4b6p7Zs+VfFY7KmO5AylTLmN/7wjOn9j9eCEBVQve6FTG1vdXKPEnuRc GVkA== 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 t193si317148ywe.54.2019.06.04.02.14.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 02:14:28 -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 (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5497bWQ072141 for ; Tue, 4 Jun 2019 05:14:27 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0b-001b2d01.pphosted.com with ESMTP id 2swjgp0w2a-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 04 Jun 2019 05:14:25 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Jun 2019 10:14:24 +0100 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 4 Jun 2019 10:14:22 +0100 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x549ELax33816652 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Jun 2019 09:14:22 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD6FEAC060; Tue, 4 Jun 2019 09:14:21 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 54B54AC05F; Tue, 4 Jun 2019 09:14:20 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.35.234]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 4 Jun 2019 09:14:20 +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: [PATCH v3 6/6] mm/nvdimm: Use correct alignment when looking at first pfn from a region Date: Tue, 4 Jun 2019 14:43:57 +0530 X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190604091357.32213-1-aneesh.kumar@linux.ibm.com> References: <20190604091357.32213-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19060409-0060-0000-0000-0000034BD868 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011212; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01213037; UDB=6.00637528; IPR=6.00994104; MB=3.00027178; MTD=3.00000008; XFM=3.00000015; UTC=2019-06-04 09:14:24 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19060409-0061-0000-0000-0000499E0C1E Message-Id: <20190604091357.32213-6-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-06-04_07:,, 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=728 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906040061 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 We already add the start_pad to the resource->start but fails to section align the start. This make sure with altmap we compute the right first pfn when start_pad is zero and we are doing an align down of start address. vmem_altmap_offset() adjust the section aligned base_pfn offset. So we need to make sure we account for the same when computing base_pfn. ie, for altmap_valid case, our pfn_first should be: pfn_first = altmap->base_pfn + vmem_altmap_offset(altmap); Signed-off-by: Aneesh Kumar K.V --- kernel/memremap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/memremap.c b/kernel/memremap.c index 1490e63f69a9..bf488b8658e7 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -60,9 +60,11 @@ static unsigned long pfn_first(struct dev_pagemap *pgmap) struct vmem_altmap *altmap = &pgmap->altmap; unsigned long pfn; - pfn = res->start >> PAGE_SHIFT; - if (pgmap->altmap_valid) - pfn += vmem_altmap_offset(altmap); + if (pgmap->altmap_valid) { + pfn = altmap->base_pfn + vmem_altmap_offset(altmap); + } else + pfn = PHYS_PFN(res->start); + return pfn; }