* [PATCH 1/2] iosys-map: Add getter functions for virtual addresses
@ 2026-07-24 9:38 oushixiong1025
2026-07-24 9:38 ` [PATCH 2/2] drm/udl: Use iosys_map getter for virtual address oushixiong1025
0 siblings, 1 reply; 3+ messages in thread
From: oushixiong1025 @ 2026-07-24 9:38 UTC (permalink / raw)
To: Thomas Zimmermann; +Cc: dri-devel, linux-kernel, Shixiong Ou
From: Shixiong Ou <oushixiong@kylinos.cn>
Add iosys_map_get_vaddr() and iosys_map_get_vaddr_iomem() as the
counterparts to iosys_map_set_vaddr() and iosys_map_set_vaddr_iomem().
This allows drivers to use the iosys_map abstraction layer properly
instead of directly accessing the structure members, improving code
maintainability and safety.
Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
---
include/linux/iosys-map.h | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
index 3e85afe794c0..658d5038498a 100644
--- a/include/linux/iosys-map.h
+++ b/include/linux/iosys-map.h
@@ -200,6 +200,42 @@ static inline void iosys_map_set_vaddr_iomem(struct iosys_map *map,
map->is_iomem = true;
}
+/**
+ * iosys_map_get_vaddr - Gets the virtual address of a system-memory mapping
+ * @map: The iosys_map structure
+ *
+ * Returns the system-memory address. The caller must ensure the mapping
+ * refers to system memory (not I/O memory).
+ *
+ * Returns:
+ * The system-memory address, or NULL if the mapping is not set or refers
+ * to I/O memory.
+ */
+static inline void *iosys_map_get_vaddr(const struct iosys_map *map)
+{
+ if (WARN_ON(map->is_iomem))
+ return NULL;
+ return map->vaddr;
+}
+
+/**
+ * iosys_map_get_vaddr_iomem - Gets the virtual address of an I/O-memory mapping
+ * @map: The iosys_map structure
+ *
+ * Returns the I/O-memory address. The caller must ensure the mapping
+ * refers to I/O memory (not system memory).
+ *
+ * Returns:
+ * The I/O-memory address, or NULL if the mapping is not set or refers
+ * to system memory.
+ */
+static inline void __iomem *iosys_map_get_vaddr_iomem(const struct iosys_map *map)
+{
+ if (WARN_ON(!map->is_iomem))
+ return NULL;
+ return map->vaddr_iomem;
+}
+
/**
* iosys_map_is_equal - Compares two iosys mapping structures for equality
* @lhs: The iosys_map structure
--
2.25.1
No virus found
Checked by Hillstone Network AntiVirus
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] drm/udl: Use iosys_map getter for virtual address
2026-07-24 9:38 [PATCH 1/2] iosys-map: Add getter functions for virtual addresses oushixiong1025
@ 2026-07-24 9:38 ` oushixiong1025
2026-07-24 11:29 ` Thomas Zimmermann
0 siblings, 1 reply; 3+ messages in thread
From: oushixiong1025 @ 2026-07-24 9:38 UTC (permalink / raw)
To: Thomas Zimmermann; +Cc: dri-devel, linux-kernel, Shixiong Ou
From: Shixiong Ou <oushixiong@kylinos.cn>
Replace direct access to map->vaddr with the new iosys_map_get_vaddr()
helper function. This properly uses the iosys_map abstraction layer
instead of directly accessing structure members.
Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
---
drivers/gpu/drm/udl/udl_modeset.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
index 289711035b67..06a3a4d149b9 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -207,12 +207,16 @@ static int udl_handle_damage(struct drm_framebuffer *fb,
{
struct drm_device *dev = fb->dev;
struct udl_device *udl = to_udl(dev);
- void *vaddr = map->vaddr; /* TODO: Use mapping abstraction properly */
+ void *vaddr;
int i, ret;
char *cmd;
struct urb *urb;
int log_bpp;
+ vaddr = iosys_map_get_vaddr(map);
+ if (!vaddr)
+ return -EFAULT;
+
ret = udl_log_cpp(fb->format->cpp[0]);
if (ret < 0)
return ret;
--
2.25.1
No virus found
Checked by Hillstone Network AntiVirus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] drm/udl: Use iosys_map getter for virtual address
2026-07-24 9:38 ` [PATCH 2/2] drm/udl: Use iosys_map getter for virtual address oushixiong1025
@ 2026-07-24 11:29 ` Thomas Zimmermann
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Zimmermann @ 2026-07-24 11:29 UTC (permalink / raw)
To: oushixiong1025; +Cc: dri-devel, linux-kernel, Shixiong Ou
Hi
Am 24.07.26 um 11:38 schrieb oushixiong1025@163.com:
> From: Shixiong Ou <oushixiong@kylinos.cn>
>
> Replace direct access to map->vaddr with the new iosys_map_get_vaddr()
> helper function. This properly uses the iosys_map abstraction layer
> instead of directly accessing structure members.
>
> Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
> ---
> drivers/gpu/drm/udl/udl_modeset.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
> index 289711035b67..06a3a4d149b9 100644
> --- a/drivers/gpu/drm/udl/udl_modeset.c
> +++ b/drivers/gpu/drm/udl/udl_modeset.c
> @@ -207,12 +207,16 @@ static int udl_handle_damage(struct drm_framebuffer *fb,
> {
> struct drm_device *dev = fb->dev;
> struct udl_device *udl = to_udl(dev);
> - void *vaddr = map->vaddr; /* TODO: Use mapping abstraction properly */
> + void *vaddr;
> int i, ret;
> char *cmd;
> struct urb *urb;
> int log_bpp;
>
> + vaddr = iosys_map_get_vaddr(map);
> + if (!vaddr)
> + return -EFAULT;
> +
This doesn't work in practice because we don't handle the vmap_iomem
correctly. You'll get NULL now, when before it was treated as a regular
address.
The current type aliasing works until we have proper import handling of
I/O-mem addresses.
Best regards
Thomas
> ret = udl_log_cpp(fb->format->cpp[0]);
> if (ret < 0)
> return ret;
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, (HRB 36809, AG Nürnberg)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-24 11:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-24 9:38 [PATCH 1/2] iosys-map: Add getter functions for virtual addresses oushixiong1025
2026-07-24 9:38 ` [PATCH 2/2] drm/udl: Use iosys_map getter for virtual address oushixiong1025
2026-07-24 11:29 ` Thomas Zimmermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®