[PATCH V3 03/21] dax: Save the kva from memremap

John Groves posted 21 patches 1 month ago
[PATCH V3 03/21] dax: Save the kva from memremap
Posted by John Groves 1 month ago
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.

(also fill in missing kerneldoc comment fields for struct dev_dax)

Signed-off-by: John Groves <john@groves.net>
---
 drivers/dax/dax-private.h | 4 ++++
 drivers/dax/fsdev.c       | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/dax/dax-private.h b/drivers/dax/dax-private.h
index 0867115aeef2..1bb1631af485 100644
--- a/drivers/dax/dax-private.h
+++ b/drivers/dax/dax-private.h
@@ -69,18 +69,22 @@ 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
  * @id: ida allocated id when the dax_region is not static
  * @ida: mapping id allocator
  * @dev - device core
  * @pgmap - pgmap for memmap setup / lifetime (driver owned)
+ * @memmap_on_memory - allow kmem to put the memmap in the memory
  * @nr_range: size of @ranges
  * @ranges: range tuples of memory used
  */
 struct dev_dax {
 	struct dax_region *region;
 	struct dax_device *dax_dev;
+	void *virt_addr;
 	unsigned int align;
 	int target_node;
 	bool dyn_id;
diff --git a/drivers/dax/fsdev.c b/drivers/dax/fsdev.c
index 2a3249d1529c..c5c660b193e5 100644
--- a/drivers/dax/fsdev.c
+++ b/drivers/dax/fsdev.c
@@ -235,6 +235,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;
-- 
2.49.0
Re: [PATCH V3 03/21] dax: Save the kva from memremap
Posted by Jonathan Cameron 1 month ago
On Wed,  7 Jan 2026 09:33:12 -0600
John Groves <John@Groves.net> wrote:

> 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.
> 
> (also fill in missing kerneldoc comment fields for struct dev_dax)

Do that as a precursor that can be picked up ahead of the rest of the series.

> 
> Signed-off-by: John Groves <john@groves.net>
> ---
>  drivers/dax/dax-private.h | 4 ++++
>  drivers/dax/fsdev.c       | 1 +
>  2 files changed, 5 insertions(+)
> 
> diff --git a/drivers/dax/dax-private.h b/drivers/dax/dax-private.h
> index 0867115aeef2..1bb1631af485 100644
> --- a/drivers/dax/dax-private.h
> +++ b/drivers/dax/dax-private.h
> @@ -69,18 +69,22 @@ 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
>   * @id: ida allocated id when the dax_region is not static
>   * @ida: mapping id allocator
>   * @dev - device core
>   * @pgmap - pgmap for memmap setup / lifetime (driver owned)
> + * @memmap_on_memory - allow kmem to put the memmap in the memory
>   * @nr_range: size of @ranges
>   * @ranges: range tuples of memory used
>   */
>  struct dev_dax {
>  	struct dax_region *region;
>  	struct dax_device *dax_dev;
> +	void *virt_addr;
>  	unsigned int align;
>  	int target_node;
>  	bool dyn_id;
> diff --git a/drivers/dax/fsdev.c b/drivers/dax/fsdev.c
> index 2a3249d1529c..c5c660b193e5 100644
> --- a/drivers/dax/fsdev.c
> +++ b/drivers/dax/fsdev.c
> @@ -235,6 +235,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;
Re: [PATCH V3 03/21] dax: Save the kva from memremap
Posted by John Groves 1 month ago
On 26/01/08 11:32AM, Jonathan Cameron wrote:
> On Wed,  7 Jan 2026 09:33:12 -0600
> John Groves <John@Groves.net> wrote:
> 
> > 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.
> > 
> > (also fill in missing kerneldoc comment fields for struct dev_dax)
> 
> Do that as a precursor that can be picked up ahead of the rest of the series.

Makes sense. Actually, I'll just send it as a separate standalone patch...

Thanks,
John

[ ... ]