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: 6502771 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 955EC9F444 for ; Thu, 28 May 2015 22:36:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 34C9E2076B for ; Thu, 28 May 2015 22:36:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 310A62076A for ; Thu, 28 May 2015 22:36:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754867AbbE1Wgc (ORCPT ); Thu, 28 May 2015 18:36:32 -0400 Received: from mga09.intel.com ([134.134.136.24]:20172 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755066AbbE1WgU (ORCPT ); Thu, 28 May 2015 18:36:20 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.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 Cc: Ross Zwisler , Dan Williams , "Rafael J. Wysocki" 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> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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; }