Updates for the 7.0 release

* nvdimm: virtio_pmem: serialize flush requests
 	* drivers/nvdimm: Use local kmaps
 -----BEGIN PGP SIGNATURE-----
 
 iIoEABYKADIWIQSgX9xt+GwmrJEQ+euebuN7TNx1MQUCaYzqOxQcaXJhLndlaW55
 QGludGVsLmNvbQAKCRCebuN7TNx1MWQwAQC+5Eo6DEFRltrAv2IiVl7Gab+eR++W
 J16PhyI7VHxPPwD/Ty0TZJf80tpDQp5EmokdqvBm5CjvEuw2LlQFvGE4qwc=
 =RUbc
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2026-02-12 14:47:35 -08:00
commit e99785a923
5 changed files with 17 additions and 11 deletions

View file

@ -1104,10 +1104,10 @@ static int btt_data_read(struct arena_info *arena, struct page *page,
{
int ret;
u64 nsoff = to_namespace_offset(arena, lba);
void *mem = kmap_atomic(page);
void *mem = kmap_local_page(page);
ret = arena_read_bytes(arena, nsoff, mem + off, len, NVDIMM_IO_ATOMIC);
kunmap_atomic(mem);
kunmap_local(mem);
return ret;
}
@ -1117,20 +1117,20 @@ static int btt_data_write(struct arena_info *arena, u32 lba,
{
int ret;
u64 nsoff = to_namespace_offset(arena, lba);
void *mem = kmap_atomic(page);
void *mem = kmap_local_page(page);
ret = arena_write_bytes(arena, nsoff, mem + off, len, NVDIMM_IO_ATOMIC);
kunmap_atomic(mem);
kunmap_local(mem);
return ret;
}
static void zero_fill_data(struct page *page, unsigned int off, u32 len)
{
void *mem = kmap_atomic(page);
void *mem = kmap_local_page(page);
memset(mem + off, 0, len);
kunmap_atomic(mem);
kunmap_local(mem);
}
#ifdef CONFIG_BLK_DEV_INTEGRITY

View file

@ -44,6 +44,8 @@ static int virtio_pmem_flush(struct nd_region *nd_region)
unsigned long flags;
int err, err1;
guard(mutex)(&vpmem->flush_lock);
/*
* Don't bother to submit the request to the device if the device is
* not activated.
@ -53,7 +55,6 @@ static int virtio_pmem_flush(struct nd_region *nd_region)
return -EIO;
}
might_sleep();
req_data = kmalloc(sizeof(*req_data), GFP_KERNEL);
if (!req_data)
return -ENOMEM;

View file

@ -128,10 +128,10 @@ static void write_pmem(void *pmem_addr, struct page *page,
void *mem;
while (len) {
mem = kmap_atomic(page);
mem = kmap_local_page(page);
chunk = min_t(unsigned int, len, PAGE_SIZE - off);
memcpy_flushcache(pmem_addr, mem + off, chunk);
kunmap_atomic(mem);
kunmap_local(mem);
len -= chunk;
off = 0;
page++;
@ -147,10 +147,10 @@ static blk_status_t read_pmem(struct page *page, unsigned int off,
void *mem;
while (len) {
mem = kmap_atomic(page);
mem = kmap_local_page(page);
chunk = min_t(unsigned int, len, PAGE_SIZE - off);
rem = copy_mc_to_kernel(mem + off, pmem_addr, chunk);
kunmap_atomic(mem);
kunmap_local(mem);
if (rem)
return BLK_STS_IOERR;
len -= chunk;

View file

@ -64,6 +64,7 @@ static int virtio_pmem_probe(struct virtio_device *vdev)
goto out_err;
}
mutex_init(&vpmem->flush_lock);
vpmem->vdev = vdev;
vdev->priv = vpmem;
err = init_vq(vpmem);

View file

@ -13,6 +13,7 @@
#include <linux/module.h>
#include <uapi/linux/virtio_pmem.h>
#include <linux/libnvdimm.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
struct virtio_pmem_request {
@ -35,6 +36,9 @@ struct virtio_pmem {
/* Virtio pmem request queue */
struct virtqueue *req_vq;
/* Serialize flush requests to the device. */
struct mutex flush_lock;
/* nvdimm bus registers virtio pmem device */
struct nvdimm_bus *nvdimm_bus;
struct nvdimm_bus_descriptor nd_desc;