Skip to content

Commit 9c0fc1d

Browse files
Davidlohr Buesoweiny2
authored andcommitted
drivers/nvdimm: Use local kmaps
Replace the now deprecated kmap_atomic() with kmap_local_page(). Optimizing nvdimm/pmem for highmem makes no sense as this is always 64bit, and the mapped regions for both btt and pmem do not require disabling preemption and pagefaults. Specifically, kmap does not care about the caller's atomic context (such as reads holding the btt arena spinlock) or NVDIMM_IO_ATOMIC semantics to avoid error handling when accessing the btt arena in general. Same for the memcpy cases. kmap local temporary mappings will hold valid across any context switches. Signed-off-by: Davidlohr Bueso <dave@stgolabs.net> Reviewed-by: Dave Jiang <dave.jiang@intel.com>> --- Link: https://patch.msgid.link/20251128212303.2170933-1-dave@stgolabs.net Signed-off-by: Ira Weiny <ira.weiny@intel.com>
1 parent 63804fe commit 9c0fc1d

2 files changed

Lines changed: 10 additions & 10 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/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;

0 commit comments

Comments
 (0)