From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
linux-nvdimm@ml01.01.org
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>,
Dan Williams <dan.j.williams@intel.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>
Subject: [PATCH 4/6] pmem, nd_blk: update I/O paths to use PMEM API
Date: Thu, 28 May 2015 16:35:51 -0600 [thread overview]
Message-ID: <1432852553-24865-5-git-send-email-ross.zwisler@linux.intel.com> (raw)
In-Reply-To: <1432852553-24865-1-git-send-email-ross.zwisler@linux.intel.com>
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 <ross.zwisler@linux.intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm@lists.01.org
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
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 <linux/list.h>
#include <linux/acpi.h>
#include <linux/sort.h>
+#include <linux/pmem.h>
#include <linux/io.h>
#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 <asm/cacheflush.h>
#include <linux/blkdev.h>
#include <linux/hdreg.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
+#include <linux/pmem.h>
#include <linux/slab.h>
#include <linux/nd.h>
+#include <asm/cacheflush.h>
#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;
}
--
1.9.3
next prev parent reply other threads:[~2015-05-28 22:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-28 22:35 [PATCH 0/6] I/O path improvements for ND_BLK and PMEM Ross Zwisler
2015-05-28 22:35 ` [PATCH 1/6] pmem: add force casts to avoid __iomem annotation Ross Zwisler
2015-05-28 22:47 ` Dan Williams
2015-05-29 11:39 ` Ross Zwisler
2015-05-29 12:53 ` Dan Williams
2015-05-29 13:22 ` Dan Williams
2015-05-28 22:35 ` [PATCH 2/6] nfit: Fix up address spaces, sparse warnings Ross Zwisler
2015-05-28 22:40 ` Dan Williams
2015-05-28 22:35 ` [PATCH 3/6] x86, pmem: add PMEM API for persistent memory Ross Zwisler
2015-05-28 23:20 ` H. Peter Anvin
2015-05-29 0:02 ` Dan Williams
2015-05-29 4:19 ` H. Peter Anvin
2015-05-29 12:11 ` Ross Zwisler
2015-05-29 12:07 ` Ross Zwisler
2015-05-29 15:48 ` Dan Williams
2015-05-28 22:35 ` Ross Zwisler [this message]
2015-05-29 14:11 ` [PATCH 4/6] pmem, nd_blk: update I/O paths to use PMEM API Dan Williams
2015-05-28 22:35 ` [PATCH 5/6] nd_blk: add support for flush hints Ross Zwisler
2015-05-28 22:35 ` [PATCH 6/6] nd_blk: add support for NVDIMM flags Ross Zwisler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432852553-24865-5-git-send-email-ross.zwisler@linux.intel.com \
--to=ross.zwisler@linux.intel.com \
--cc=dan.j.williams@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@ml01.01.org \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®