From patchwork Thu May 28 22:35:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Zwisler X-Patchwork-Id: 6502701 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DED3BC0433 for ; Thu, 28 May 2015 22:36:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 024AF2076F for ; Thu, 28 May 2015 22:36:21 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF7FF2076E for ; Thu, 28 May 2015 22:36:19 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id AD572182882; Thu, 28 May 2015 15:36:19 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ml01.01.org (Postfix) with ESMTP id 26392182844 for ; Thu, 28 May 2015 15:36:18 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 28 May 2015 15:36:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,514,1427785200"; d="scan'208";a="578479035" Received: from rzwisler-mobl1.amr.corp.intel.com (HELO theros.lm.intel.com) ([10.232.112.154]) by orsmga003.jf.intel.com with ESMTP; 28 May 2015 15:36:10 -0700 From: Ross Zwisler To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-nvdimm@lists.01.org Subject: [PATCH 4/6] pmem, nd_blk: update I/O paths to use PMEM API Date: Thu, 28 May 2015 16:35:51 -0600 Message-Id: <1432852553-24865-5-git-send-email-ross.zwisler@linux.intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1432852553-24865-1-git-send-email-ross.zwisler@linux.intel.com> References: <1432852553-24865-1-git-send-email-ross.zwisler@linux.intel.com> Cc: "Rafael J. Wysocki" X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Update the PMEM and ND_BLK I/O paths to use the new PMEM API and to adhere to the read/write flows outlined in the "NVDIMM Block Window Driver Writer's Guide": http://pmem.io/documents/NVDIMM_Driver_Writers_Guide.pdf Signed-off-by: Ross Zwisler Cc: Dan Williams Cc: linux-nvdimm@lists.01.org Cc: "Rafael J. Wysocki" Cc: linux-acpi@vger.kernel.org --- drivers/acpi/nfit.c | 10 ++++++++-- drivers/block/nd/pmem.c | 15 +++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c index df14652ea13e..22df61968c1c 100644 --- a/drivers/acpi/nfit.c +++ b/drivers/acpi/nfit.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "nfit.h" @@ -926,7 +927,9 @@ static void write_blk_ctl(struct nfit_blk *nfit_blk, unsigned int bw, if (mmio->num_lines) offset = to_interleave_offset(offset, mmio); + /* mmio->base must be mapped uncacheable */ writeq(cmd, mmio->base + offset); + persistent_sync(); /* FIXME: conditionally perform read-back if mandated by firmware */ } @@ -940,7 +943,6 @@ static int acpi_nfit_blk_single_io(struct nfit_blk *nfit_blk, void *iobuf, int rc; base_offset = nfit_blk->bdw_offset + dpa % L1_CACHE_BYTES + bw * mmio->size; - /* TODO: non-temporal access, flush hints, cache management etc... */ write_blk_ctl(nfit_blk, bw, dpa, len, write); while (len) { unsigned int c; @@ -959,13 +961,17 @@ static int acpi_nfit_blk_single_io(struct nfit_blk *nfit_blk, void *iobuf, } if (write) - memcpy(mmio->aperture + offset, iobuf + copied, c); + persistent_copy(mmio->aperture + offset, iobuf + copied, c); else memcpy(iobuf + copied, mmio->aperture + offset, c); copied += c; len -= c; } + + if (write) + persistent_sync(); + rc = read_blk_stat(nfit_blk, bw) ? -EIO : 0; return rc; } diff --git a/drivers/block/nd/pmem.c b/drivers/block/nd/pmem.c index a8712e41e7f5..1a447c351aef 100644 --- a/drivers/block/nd/pmem.c +++ b/drivers/block/nd/pmem.c @@ -15,15 +15,16 @@ * more details. */ -#include #include #include #include #include #include #include +#include #include #include +#include #include "nd.h" struct pmem_device { @@ -51,7 +52,7 @@ static void pmem_do_bvec(struct pmem_device *pmem, struct page *page, flush_dcache_page(page); } else { flush_dcache_page(page); - memcpy(pmem->virt_addr + pmem_off, mem + off, len); + persistent_copy(pmem->virt_addr + pmem_off, mem + off, len); } kunmap_atomic(mem); @@ -82,6 +83,8 @@ static void pmem_make_request(struct request_queue *q, struct bio *bio) sector += bvec.bv_len >> 9; } + if (rw & WRITE) + persistent_sync(); out: bio_endio(bio, err); } @@ -92,6 +95,8 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector, struct pmem_device *pmem = bdev->bd_disk->private_data; pmem_do_bvec(pmem, page, PAGE_CACHE_SIZE, 0, rw, sector); + if (rw & WRITE) + persistent_sync(); page_endio(page, rw & WRITE, 0); return 0; @@ -111,8 +116,10 @@ static int pmem_rw_bytes(struct nd_io *ndio, void *buf, size_t offset, if (rw == READ) memcpy(buf, pmem->virt_addr + offset, n); - else - memcpy(pmem->virt_addr + offset, buf, n); + else { + persistent_copy(pmem->virt_addr + offset, buf, n); + persistent_sync(); + } return 0; }