Skip to content

Commit e99785a

Browse files
committed
Merge tag 'libnvdimm-for-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull libnvdimm updates from Ira Weiny: "A kmap conversion and a bug fix this go around: - drivers/nvdimm: Use local kmaps - nvdimm: virtio_pmem: serialize flush requests" * tag 'libnvdimm-for-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: nvdimm: virtio_pmem: serialize flush requests drivers/nvdimm: Use local kmaps
2 parents 582a1ef + a9ba673 commit e99785a

5 files changed

Lines changed: 17 additions & 11 deletions

File tree

drivers/nvdimm/btt.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,10 +1104,10 @@ static int btt_data_read(struct arena_info *arena, struct page *page,
11041104
{
11051105
int ret;
11061106
u64 nsoff = to_namespace_offset(arena, lba);
1107-
void *mem = kmap_atomic(page);
1107+
void *mem = kmap_local_page(page);
11081108

11091109
ret = arena_read_bytes(arena, nsoff, mem + off, len, NVDIMM_IO_ATOMIC);
1110-
kunmap_atomic(mem);
1110+
kunmap_local(mem);
11111111

11121112
return ret;
11131113
}
@@ -1117,20 +1117,20 @@ static int btt_data_write(struct arena_info *arena, u32 lba,
11171117
{
11181118
int ret;
11191119
u64 nsoff = to_namespace_offset(arena, lba);
1120-
void *mem = kmap_atomic(page);
1120+
void *mem = kmap_local_page(page);
11211121

11221122
ret = arena_write_bytes(arena, nsoff, mem + off, len, NVDIMM_IO_ATOMIC);
1123-
kunmap_atomic(mem);
1123+
kunmap_local(mem);
11241124

11251125
return ret;
11261126
}
11271127

11281128
static void zero_fill_data(struct page *page, unsigned int off, u32 len)
11291129
{
1130-
void *mem = kmap_atomic(page);
1130+
void *mem = kmap_local_page(page);
11311131

11321132
memset(mem + off, 0, len);
1133-
kunmap_atomic(mem);
1133+
kunmap_local(mem);
11341134
}
11351135

11361136
#ifdef CONFIG_BLK_DEV_INTEGRITY

drivers/nvdimm/nd_virtio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ static int virtio_pmem_flush(struct nd_region *nd_region)
4444
unsigned long flags;
4545
int err, err1;
4646

47+
guard(mutex)(&vpmem->flush_lock);
48+
4749
/*
4850
* Don't bother to submit the request to the device if the device is
4951
* not activated.
@@ -53,7 +55,6 @@ static int virtio_pmem_flush(struct nd_region *nd_region)
5355
return -EIO;
5456
}
5557

56-
might_sleep();
5758
req_data = kmalloc(sizeof(*req_data), GFP_KERNEL);
5859
if (!req_data)
5960
return -ENOMEM;

drivers/nvdimm/pmem.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ static void write_pmem(void *pmem_addr, struct page *page,
128128
void *mem;
129129

130130
while (len) {
131-
mem = kmap_atomic(page);
131+
mem = kmap_local_page(page);
132132
chunk = min_t(unsigned int, len, PAGE_SIZE - off);
133133
memcpy_flushcache(pmem_addr, mem + off, chunk);
134-
kunmap_atomic(mem);
134+
kunmap_local(mem);
135135
len -= chunk;
136136
off = 0;
137137
page++;
@@ -147,10 +147,10 @@ static blk_status_t read_pmem(struct page *page, unsigned int off,
147147
void *mem;
148148

149149
while (len) {
150-
mem = kmap_atomic(page);
150+
mem = kmap_local_page(page);
151151
chunk = min_t(unsigned int, len, PAGE_SIZE - off);
152152
rem = copy_mc_to_kernel(mem + off, pmem_addr, chunk);
153-
kunmap_atomic(mem);
153+
kunmap_local(mem);
154154
if (rem)
155155
return BLK_STS_IOERR;
156156
len -= chunk;

drivers/nvdimm/virtio_pmem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ static int virtio_pmem_probe(struct virtio_device *vdev)
6464
goto out_err;
6565
}
6666

67+
mutex_init(&vpmem->flush_lock);
6768
vpmem->vdev = vdev;
6869
vdev->priv = vpmem;
6970
err = init_vq(vpmem);

drivers/nvdimm/virtio_pmem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/module.h>
1414
#include <uapi/linux/virtio_pmem.h>
1515
#include <linux/libnvdimm.h>
16+
#include <linux/mutex.h>
1617
#include <linux/spinlock.h>
1718

1819
struct virtio_pmem_request {
@@ -35,6 +36,9 @@ struct virtio_pmem {
3536
/* Virtio pmem request queue */
3637
struct virtqueue *req_vq;
3738

39+
/* Serialize flush requests to the device. */
40+
struct mutex flush_lock;
41+
3842
/* nvdimm bus registers virtio pmem device */
3943
struct nvdimm_bus *nvdimm_bus;
4044
struct nvdimm_bus_descriptor nd_desc;

0 commit comments

Comments
 (0)