From patchwork Mon Jul 16 17:00:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10527261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C68C160348 for ; Mon, 16 Jul 2018 17:11:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5A6828D80 for ; Mon, 16 Jul 2018 17:11:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9E9128D82; Mon, 16 Jul 2018 17:11:10 +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 5977F28D83 for ; Mon, 16 Jul 2018 17:11:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4379C6B0273; Mon, 16 Jul 2018 13:11:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3E65B6B0274; Mon, 16 Jul 2018 13:11:09 -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 2D5226B0275; Mon, 16 Jul 2018 13:11:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id E49BB6B0273 for ; Mon, 16 Jul 2018 13:11:08 -0400 (EDT) Received: by mail-pf0-f200.google.com with SMTP id t26-v6so2008758pfh.0 for ; Mon, 16 Jul 2018 10:11:08 -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:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=X0nMdeTAxOLMB9YWU2TN+evclwF+cjiCHlvXwgRdB/o=; b=e9d6eJVrxnqGbAyeeCK9NRP0GLi/j8nGSWuc75Wa+ZjM/oLig/y83oz9+saqQcQIdv 6ABXwO//B9yOeycQeFf576Yy5fCLnjZFemY+w5Ir5iS5tyflMkLo2+KZnThl9GiEy5cJ Jgvy5evQbYUm/q/WCt2TCYgbuSHKmpDsgP6vnR5fWOoWXhDb87OpiDYCRJZwSYdAanki mi7sZRaGI0D48RxXBebaOiw6kyP5oJ8lzublFD9oISF/D3Ufn/ukE5OgQa2gAaBWMFCJ 7Bw2TpP0bqDH30locE7/pfIn1vOD++tS7/RmW5Gg0SWW+SgtOkD1oNblG/kYxFHLGPZ6 7aZw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AOUpUlF4YRziDsPILp+TVR3F1cDSgdyvzdEmrebZJcmhJyBgfdv1ZcYI ve3aZGjDgZCuF61F6fLr2AMKM0R7UMPU7witITlgGmlSMMkUDJ5ENuDu2p998YXYTYax+1bzQnM Wr4nmt/5nKoAbz6Gdf2kEErAxAHTLWp13/RGikDSqKgq/BcCga8uoYSlwW5BbSgEfjg== X-Received: by 2002:aa7:81d3:: with SMTP id c19-v6mr18950541pfn.224.1531761068630; Mon, 16 Jul 2018 10:11:08 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcUAQgHOn+dzaqUG73nUMwCcxUPuPepziqx5bPUYG2uqLx7PmaV6pPrkjCDyYpiqwYOuDB9 X-Received: by 2002:aa7:81d3:: with SMTP id c19-v6mr18950496pfn.224.1531761067921; Mon, 16 Jul 2018 10:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531761067; cv=none; d=google.com; s=arc-20160816; b=fH69ymVrd3CruMq+1StN5+LfaKUbOcHDT57IdtfySxkOv21k5OGiUVb/CQe4FsFA51 WhZqXddkQG3D172YCDRuExI8sDM8fpvtNlZO0K+dDAFKM/aVxmNqtwGnndePBPAsUwho 1gFUnNQQ209aAPxPKHs0uW9wzkKTDu8EJ4wksELE71jMsaJ90jkJLJ7mIE5PTtyE9jQP JIB05WC/ND/6S3WqowfoyQWa7qXjUxY825ypJid424itKjnGg1vol4V4fZDsuJcCUcI/ mbkjS9VukyK3wdv7sIicKNLjphuV+cm3/ltG3bSVpmOClnv0RYVMOmrjaQVlR2AxOkb3 atcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject :arc-authentication-results; bh=X0nMdeTAxOLMB9YWU2TN+evclwF+cjiCHlvXwgRdB/o=; b=BpeeaTscL3Y/6EFbdKIgTEtirhx/1G0g5YmhbEV6z/XhKknuR3WYpDbhEEOhx0YS3b iufdLRMAPSROxB9fag8PtkkoKEl84qYzWMFcM/D0xfUzioHCIcIn0a3TCV/TPN9sIE1V 18wX+HQn050RAbwtkYClewlCfMRdLEaakr6vzVKjnpg95YFB74xbuNEOopsiPiF0JOiQ A6/Yv5xCYY4cACiZJY1nDeOdjJ+M/LAinyoXhzwKrqRAB92qClSbdGkn3CU33ODQsF28 B53LpLbEIOKXbnXAdJ+CjKgpPQOpoZ9WoiEw/uzDku5PhIuROxnfma754kOJOjJ3dyjg PgDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga17.intel.com (mga17.intel.com. [192.55.52.151]) by mx.google.com with ESMTPS id q3-v6si30597304plb.238.2018.07.16.10.11.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 10:11:07 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.151 as permitted sender) client-ip=192.55.52.151; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2018 10:11:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,362,1526367600"; d="scan'208";a="216447242" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga004.jf.intel.com with ESMTP; 16 Jul 2018 10:10:55 -0700 Subject: [PATCH v2 07/14] libnvdimm, pmem: Allow a NULL-pfn to ->direct_access() From: Dan Williams To: akpm@linux-foundation.org Cc: Huaisheng Ye , Jan Kara , vishal.l.verma@intel.com, hch@lst.de, linux-mm@kvack.org, jack@suse.cz, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Date: Mon, 16 Jul 2018 10:00:58 -0700 Message-ID: <153176045824.12695.14255237229973044333.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153176041838.12695.3365448145295112857.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153176041838.12695.3365448145295112857.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 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 From: Huaisheng Ye pmem_direct_access() needs to check the validity of pointer pfn for NULL assignment. If pfn equals to NULL, it doesn't need to calculate the value. This is in support of asynchronous memmap init and avoid page lookups when possible. Signed-off-by: Huaisheng Ye Reviewed-by: Jan Kara Signed-off-by: Dan Williams --- drivers/nvdimm/pmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index e8ac6f244d2b..c430536320a5 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -228,7 +228,8 @@ __weak long __pmem_direct_access(struct pmem_device *pmem, pgoff_t pgoff, PFN_PHYS(nr_pages)))) return -EIO; *kaddr = pmem->virt_addr + offset; - *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); + if (pfn) + *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags); /* * If badblocks are present, limit known good range to the