dax: Save the kva from memremap

Save the kva from memremap because we need it for iomap rw support.

Prior to famfs, there were no iomap users of /dev/dax - so the virtual
address from memremap was not needed.

Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: John Groves <john@groves.net>
Link: https://patch.msgid.link/0100019d311d1d08-dd372cb9-5934-43b8-bef8-089660d04a81-000000@email.amazonses.com
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
This commit is contained in:
John Groves 2026-03-27 21:04:44 +00:00 committed by Ira Weiny
parent d5406bd458
commit 759455848d
2 changed files with 4 additions and 1 deletions

View File

@ -69,6 +69,7 @@ struct dev_dax_range {
* data while the device is activated in the driver.
* @region: parent region
* @dax_dev: core dax functionality
* @virt_addr: kva from memremap; used by fsdev_dax
* @align: alignment of this instance
* @target_node: effective numa node if dev_dax memory range is onlined
* @dyn_id: is this a dynamic or statically created instance
@ -83,6 +84,7 @@ struct dev_dax_range {
struct dev_dax {
struct dax_region *region;
struct dax_device *dax_dev;
void *virt_addr;
unsigned int align;
int target_node;
bool dyn_id;

View File

@ -121,6 +121,7 @@ static int fsdev_dax_probe(struct dev_dax *dev_dax)
struct device *dev = &dev_dax->dev;
struct dev_pagemap *pgmap;
struct inode *inode;
u64 data_offset = 0;
struct cdev *cdev;
void *addr;
int rc, i;
@ -196,7 +197,6 @@ static int fsdev_dax_probe(struct dev_dax *dev_dax)
if (pgmap->range.start != dev_dax->ranges[0].range.start) {
u64 phys = dev_dax->ranges[0].range.start;
u64 pgmap_phys = dev_dax->pgmap[0].range.start;
u64 data_offset = 0;
if (!WARN_ON(pgmap_phys > phys))
data_offset = phys - pgmap_phys;
@ -204,6 +204,7 @@ static int fsdev_dax_probe(struct dev_dax *dev_dax)
pr_debug("%s: offset detected phys=%llx pgmap_phys=%llx offset=%llx\n",
__func__, phys, pgmap_phys, data_offset);
}
dev_dax->virt_addr = addr + data_offset;
inode = dax_inode(dax_dev);
cdev = inode->i_cdev;