* [PATCH] drm/loongson: use drm_gem_ttm_dumb_map_offset()
@ 2026-03-08 10:15 Amin GATTOUT
2026-03-08 21:52 ` Claude review: " Claude Code Review Bot
2026-03-08 21:52 ` Claude Code Review Bot
0 siblings, 2 replies; 3+ messages in thread
From: Amin GATTOUT @ 2026-03-08 10:15 UTC (permalink / raw)
To: Sui Jingfeng, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter
Cc: dri-devel, linux-kernel, Amin GATTOUT
Replace the open-coded lsdc_dumb_map_offset() with the generic
drm_gem_ttm_dumb_map_offset() helper, which is functionally identical.
This removes unnecessary boilerplate and aligns with the DRM convention
for TTM-based drivers.
Signed-off-by: Amin GATTOUT <amin.gattout@gmail.com>
---
drivers/gpu/drm/loongson/lsdc_drv.c | 3 ++-
drivers/gpu/drm/loongson/lsdc_gem.c | 15 ---------------
drivers/gpu/drm/loongson/lsdc_gem.h | 4 ----
3 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/loongson/lsdc_drv.c b/drivers/gpu/drm/loongson/lsdc_drv.c
index abf5bf68eec2..1ece1ea42f78 100644
--- a/drivers/gpu/drm/loongson/lsdc_drv.c
+++ b/drivers/gpu/drm/loongson/lsdc_drv.c
@@ -13,6 +13,7 @@
#include <drm/drm_drv.h>
#include <drm/drm_fbdev_ttm.h>
#include <drm/drm_gem_framebuffer_helper.h>
+#include <drm/drm_gem_ttm_helper.h>
#include <drm/drm_ioctl.h>
#include <drm/drm_modeset_helper.h>
#include <drm/drm_print.h>
@@ -45,7 +46,7 @@ static const struct drm_driver lsdc_drm_driver = {
.debugfs_init = lsdc_debugfs_init,
.dumb_create = lsdc_dumb_create,
- .dumb_map_offset = lsdc_dumb_map_offset,
+ .dumb_map_offset = drm_gem_ttm_dumb_map_offset,
.gem_prime_import_sg_table = lsdc_prime_import_sg_table,
DRM_FBDEV_TTM_DRIVER_OPS,
};
diff --git a/drivers/gpu/drm/loongson/lsdc_gem.c b/drivers/gpu/drm/loongson/lsdc_gem.c
index 6372db2d3093..2fb03487c983 100644
--- a/drivers/gpu/drm/loongson/lsdc_gem.c
+++ b/drivers/gpu/drm/loongson/lsdc_gem.c
@@ -234,21 +234,6 @@ int lsdc_dumb_create(struct drm_file *file, struct drm_device *ddev,
return 0;
}
-int lsdc_dumb_map_offset(struct drm_file *filp, struct drm_device *ddev,
- u32 handle, uint64_t *offset)
-{
- struct drm_gem_object *gobj;
-
- gobj = drm_gem_object_lookup(filp, handle);
- if (!gobj)
- return -ENOENT;
-
- *offset = drm_vma_node_offset_addr(&gobj->vma_node);
-
- drm_gem_object_put(gobj);
-
- return 0;
-}
void lsdc_gem_init(struct drm_device *ddev)
{
diff --git a/drivers/gpu/drm/loongson/lsdc_gem.h b/drivers/gpu/drm/loongson/lsdc_gem.h
index 92cbb10e6e13..96729b3eebec 100644
--- a/drivers/gpu/drm/loongson/lsdc_gem.h
+++ b/drivers/gpu/drm/loongson/lsdc_gem.h
@@ -14,10 +14,6 @@ lsdc_prime_import_sg_table(struct drm_device *ddev,
struct dma_buf_attachment *attach,
struct sg_table *sg);
-int lsdc_dumb_map_offset(struct drm_file *file,
- struct drm_device *dev,
- u32 handle,
- uint64_t *offset);
int lsdc_dumb_create(struct drm_file *file,
struct drm_device *ddev,
---
base-commit: c23719abc3308df7ed3ad35650ad211fb2d2003d
change-id: 20260308-master-58f0cb492c5e
Best regards,
--
Amin GATTOUT <amin.gattout@gmail.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Claude review: drm/loongson: use drm_gem_ttm_dumb_map_offset()
2026-03-08 10:15 [PATCH] drm/loongson: use drm_gem_ttm_dumb_map_offset() Amin GATTOUT
@ 2026-03-08 21:52 ` Claude Code Review Bot
2026-03-08 21:52 ` Claude Code Review Bot
1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-03-08 21:52 UTC (permalink / raw)
To: dri-devel-reviews
Overall Series Review
Subject: drm/loongson: use drm_gem_ttm_dumb_map_offset()
Author: Amin GATTOUT <amin.gattout@gmail.com>
Patches: 1
Reviewed: 2026-03-09T07:52:56.083383
---
This is a clean, straightforward cleanup patch. It replaces the open-coded `lsdc_dumb_map_offset()` in the loongson DRM driver with the existing generic `drm_gem_ttm_dumb_map_offset()` helper from `drm_gem_ttm_helper.c`. The two implementations are **byte-for-byte identical** in logic (lookup GEM object by handle, get vma_node offset, put object, return). The patch correctly removes the now-unnecessary function definition and declaration, and adds the required header include.
**Verdict: Looks good.** No functional issues.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 3+ messages in thread
* Claude review: drm/loongson: use drm_gem_ttm_dumb_map_offset()
2026-03-08 10:15 [PATCH] drm/loongson: use drm_gem_ttm_dumb_map_offset() Amin GATTOUT
2026-03-08 21:52 ` Claude review: " Claude Code Review Bot
@ 2026-03-08 21:52 ` Claude Code Review Bot
1 sibling, 0 replies; 3+ messages in thread
From: Claude Code Review Bot @ 2026-03-08 21:52 UTC (permalink / raw)
To: dri-devel-reviews
Patch Review
**Correctness:** The removed `lsdc_dumb_map_offset()` at `lsdc_gem.c:147-161` is functionally identical to `drm_gem_ttm_dumb_map_offset()` at `drm_gem_ttm_helper.c:137-151` — same object lookup, same `drm_vma_node_offset_addr()` call, same `drm_gem_object_put()`, same return values. This is a safe substitution.
**Changes are complete:**
- `lsdc_drv.c`: Adds `#include <drm/drm_gem_ttm_helper.h>` and swaps `.dumb_map_offset` assignment — correct.
- `lsdc_gem.c`: Removes the function body — correct.
- `lsdc_gem.h`: Removes the declaration — correct.
- No remaining references to `lsdc_dumb_map_offset` exist in the tree after this patch.
**Minor nit:** The removal in `lsdc_gem.c` leaves a double blank line (the original blank before the function plus the blank after the closing brace). This is cosmetically harmless but could be cleaned up to a single blank line. Very minor — not worth blocking.
**Other drivers using the same pattern:** Multiple TTM-based drivers (xe, nouveau, vmwgfx, qxl, hibmc) already use `drm_gem_ttm_dumb_map_offset()`, so this aligns loongson with established convention.
Reviewed-by: looks appropriate here.
---
Generated by Claude Code Patch Reviewer
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-08 21:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-08 10:15 [PATCH] drm/loongson: use drm_gem_ttm_dumb_map_offset() Amin GATTOUT
2026-03-08 21:52 ` Claude review: " Claude Code Review Bot
2026-03-08 21:52 ` Claude Code Review Bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox