Skip to contentSkip to conversation

kernel/cobalt/rtdm: Further documentation for rtdm_mmap_kmem/vmem/iomem() and rtdm_mmap_to_user()

PATCH In review csmith 2 participants 2 messages Nov 13, 2021 – Nov 14, 2021

lore
Share & tools
lore

csmith

author
#0 lore raw

PATCH 1/1 kernel/cobalt/rtdm: Further documentation for rtdm_mmap_kmem/vmem/iomem() and rtdm_mmap_to_user()

kernel/cobalt/rtdm: Further documentation for rtdm_mmap_kmem/vmem/iomem()

---
 kernel/cobalt/rtdm/drvlib.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
kernel/cobalt/rtdm/drvlib.c +9 -5
index 7b7b0830c..56da04bf8 100644
@@ -1973,6 +1973,10 @@ int __rtdm_mmap_from_fdop(struct rtdm_fd *fd, size_t len, off_t offset,
  * vmalloc(). To map physical I/O memory to user-space use
  * rtdm_iomap_to_user() instead.
  *
+ * @note This service is provided only for use in .ioctl operation handlers. 
+ * Otherwise RTDM drivers implementing a .mmap operation should use 
+ * rtdm_mmap_kmem(), rtdm_mmap_vmem(), or rtdm_mmap_iomem().
+ * 
  * @note RTDM supports two models for unmapping the memory area:
  * - manual unmapping via rtdm_munmap(), which may be issued from a
  * driver in response to an IOCTL call, or by a call to the regular
@@ -2084,7 +2088,7 @@ EXPORT_SYMBOL_GPL(rtdm_iomap_to_user);
 /**
  * Map a kernel logical memory range to a virtual user area.
  *
- * This routine is commonly used from a ->mmap() handler of a RTDM
+ * This routine is commonly used from a .mmap operation handler of a RTDM
  * driver, for mapping a virtual memory area with a direct physical
  * mapping over the user address space referred to by @a vma.
  *
@@ -2107,10 +2111,10 @@ int rtdm_mmap_kmem(struct vm_area_struct *vma, void *va)
 EXPORT_SYMBOL_GPL(rtdm_mmap_kmem);
 
 /**
- * Map a virtual memory range to a virtual user area.
+ * Map a driver's kernel virtual memory range to a virtual user area.
  *
- * This routine is commonly used from a ->mmap() handler of a RTDM
- * driver, for mapping a purely virtual memory area over the user
+ * This routine is commonly used from a .mmap operation handler of a RTDM
+ * driver, for mapping a purely virtual kernel memory area over the user
  * address space referred to by @a vma.
  *
  * @param[in] vma The VMA descriptor to receive the mapping.
@@ -2138,7 +2142,7 @@ EXPORT_SYMBOL_GPL(rtdm_mmap_vmem);
 /**
  * Map an I/O memory range to a virtual user area.
  *
- * This routine is commonly used from a ->mmap() handler of a RTDM
+ * This routine is commonly used from a .mmap operation handler of a RTDM
  * driver, for mapping an I/O memory area over the user address space
  * referred to by @a vma.
  *
Signature · 1 line
2.17.2
#1 lore raw
Quoted 2 lines · csmith via Xenomai

kernel/cobalt/rtdm: Further documentation for rtdm_mmap_kmem/vmem/iomem()

For legal reasons (same as in
https://www.kernel.org/doc/html/latest/process/submitting-patches.html#developer-s-certificate-of-origin-1-1),
we need a real name here.

Quoted 9 lines
---
 kernel/cobalt/rtdm/drvlib.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
kernel/cobalt/rtdm/drvlib.c +0 -0
index 7b7b0830c..56da04bf8 100644

kernel/cobalt/rtdm/drvlib.c int __rtdm_mmap_from_fdop(struct rtdm_fd *fd, size_t len, off_t offset, · line 1979

Quoted 7 lines
kernel/cobalt/rtdm/drvlib.c +4 -0
@@ -1973,6 +1973,10 @@ int __rtdm_mmap_from_fdop(struct rtdm_fd *fd, size_t len, off_t offset,
  * vmalloc(). To map physical I/O memory to user-space use
  * rtdm_iomap_to_user() instead.
  *
+ * @note This service is provided only for use in .ioctl operation handlers. 
+ * Otherwise RTDM drivers implementing a .mmap operation should use 
+ * rtdm_mmap_kmem(), rtdm_mmap_vmem(), or rtdm_mmap_iomem().
+ * 

3 trailing whitespaces, says git.

Quoted 13 lines
kernel/cobalt/rtdm/drvlib.c +1 -1
  * @note RTDM supports two models for unmapping the memory area:
  * - manual unmapping via rtdm_munmap(), which may be issued from a
  * driver in response to an IOCTL call, or by a call to the regular
@@ -2084,7 +2088,7 @@ EXPORT_SYMBOL_GPL(rtdm_iomap_to_user);
 /**
  * Map a kernel logical memory range to a virtual user area.
  *
- * This routine is commonly used from a ->mmap() handler of a RTDM
+ * This routine is commonly used from a .mmap operation handler of a RTDM
  * driver, for mapping a virtual memory area with a direct physical
  * mapping over the user address space referred to by @a vma.
  *

kernel/cobalt/rtdm/drvlib.c int rtdm_mmap_kmem(struct vm_area_struct *vma, void *va) · line 2114

Quoted 5 lines
kernel/cobalt/rtdm/drvlib.c +1 -1
@@ -2107,10 +2111,10 @@ int rtdm_mmap_kmem(struct vm_area_struct *vma, void *va)
 EXPORT_SYMBOL_GPL(rtdm_mmap_kmem);
 
 /**
- * Map a virtual memory range to a virtual user area.
+ * Map a driver's kernel virtual memory range to a virtual user area.

Drop "driver's" - the driver has no private view on the kernel virtual memory.

kernel/cobalt/rtdm/drvlib.c int rtdm_mmap_kmem(struct vm_area_struct *vma, void *va) · line 2117

Quoted 5 lines
kernel/cobalt/rtdm/drvlib.c +2 -2
  *
- * This routine is commonly used from a ->mmap() handler of a RTDM
- * driver, for mapping a purely virtual memory area over the user
+ * This routine is commonly used from a .mmap operation handler of a RTDM
+ * driver, for mapping a purely virtual kernel memory area over the user

"kernel virtual"

kernel/cobalt/rtdm/drvlib.c EXPORT_SYMBOL_GPL(rtdm_mmap_vmem); · line 2148

Quoted 13 lines
kernel/cobalt/rtdm/drvlib.c +1 -1
  * address space referred to by @a vma.
  *
  * @param[in] vma The VMA descriptor to receive the mapping.
@@ -2138,7 +2142,7 @@ EXPORT_SYMBOL_GPL(rtdm_mmap_vmem);
 /**
  * Map an I/O memory range to a virtual user area.
  *
- * This routine is commonly used from a ->mmap() handler of a RTDM
+ * This routine is commonly used from a .mmap operation handler of a RTDM
  * driver, for mapping an I/O memory area over the user address space
  * referred to by @a vma.
  *

Looks good otherwise.

Thanks!
Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux