drm: verisilicon: support non-coherent DMA framebuffers
PATCH 1/1 drm: verisilicon: support non-coherent DMA framebuffers
Wire up the standard non-coherent path matching the ingenic DRM driver.
Tested on StarFive JH7110 (VisionFive 2 v1.3B).
--- drivers/gpu/drm/verisilicon/vs_drm.c | 31 +++++++++++++++++-- drivers/gpu/drm/verisilicon/vs_drm.h | 7 +++++ .../gpu/drm/verisilicon/vs_primary_plane.c | 11 ++++++- 3 files changed, 46 insertions(+), 3 deletions(-)
drivers/gpu/drm/verisilicon/vs_drm.c +29 -2
@@ -4,7 +4,7 @@*/ #include <linux/aperture.h> -#include <linux/dma-mapping.h> +#include <linux/of_address.h> #include <linux/platform_device.h> #include <linux/module.h> #include <linux/regmap.h>
@@ -49,6 +49,31 @@ static int vs_gem_dumb_create(struct drm_file *file_priv,DEFINE_DRM_GEM_FOPS (vs_drm_driver_fops); +static struct drm_gem_object *vs_gem_create_object (struct drm_device *drm, +size_t size) +{ +struct drm_gem_dma_object *obj; + + obj =kzalloc_obj (*obj); +if (!obj) +return ERR_PTR (-ENOMEM ); + + obj->map_noncoherent =to_vs_drm_dev (drm)->noncoherent; + +return &obj->base; +} + +static struct drm_framebuffer * +vs_gem_fb_create (struct drm_device *drm,struct drm_file *file, +const struct drm_format_info *info, +const struct drm_mode_fb_cmd2 *mode_cmd) +{ +if (to_vs_drm_dev (drm)->noncoherent) +return drm_gem_fb_create_with_dirty (drm, file, info, mode_cmd); + +return drm_gem_fb_create (drm, file, info, mode_cmd); +} +static const struct drm_driver vs_drm_driver = { .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_ATOMIC , .fops = &vs_drm_driver_fops,
@@ -58,12 +83,13 @@ static const struct drm_driver vs_drm_driver = { .minor = DRIVER_MINOR,/* GEM Operations */ + .gem_create_object = vs_gem_create_object,DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE (vs_gem_dumb_create), DRM_FBDEV_DMA_DRIVER_OPS, };static const struct drm_mode_config_funcs vs_mode_config_funcs = { - .fb_create = drm_gem_fb_create, + .fb_create = vs_gem_fb_create, .atomic_check = drm_atomic_helper_check, .atomic_commit = drm_atomic_helper_commit, };
@@ -98,6 +124,7 @@ int vs_drm_initialize(struct vs_dc *dc, struct platform_device *pdev) drm = &vdrm->base; vdrm->dc = dc; + vdrm->noncoherent = !of_dma_is_coherent (dev->of_node); dc->drm_dev = vdrm; ret =drmm_mode_config_init (drm);
drivers/gpu/drm/verisilicon/vs_drm.h +7 -0
@@ -18,8 +18,15 @@ struct vs_drm_dev {struct vs_dc *dc;struct vs_crtc *crtcs[VSDC_MAX_OUTPUTS ]; + +bool noncoherent; }; +static inline struct vs_drm_dev *to_vs_drm_dev (struct drm_device *drm) +{ + return container_of(drm, struct vs_drm_dev, base); +} +int vs_drm_initialize (struct vs_dc *dc,struct platform_device *pdev);void vs_drm_finalize (struct vs_dc *dc);void vs_drm_shutdown_handler (struct vs_dc *dc);
drivers/gpu/drm/verisilicon/vs_primary_plane.c +10 -1
@@ -8,6 +8,7 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_crtc.h> +#include <drm/drm_fb_dma_helper.h> #include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_atomic_helper.h>
@@ -16,8 +17,9 @@#include <drm/drm_print.h> #include "vs_crtc.h" -#include "vs_plane.h" #include "vs_dc.h" +#include "vs_drm.h" +#include "vs_plane.h" #include "vs_primary_plane_regs.h" static int vs_primary_plane_atomic_check(struct drm_plane *plane,
@@ -86,6 +88,8 @@ static void vs_primary_plane_atomic_disable(struct drm_plane *plane,static void vs_primary_plane_atomic_update (struct drm_plane *plane,struct drm_atomic_state *atomic_state) { +struct drm_plane_state *old_state =drm_atomic_get_old_plane_state (atomic_state, + plane);struct drm_plane_state *state =drm_atomic_get_new_plane_state (atomic_state, plane);struct drm_framebuffer *fb = state->fb;
@@ -101,6 +105,8 @@ static void vs_primary_plane_atomic_update(struct drm_plane *plane,return ; } +drm_fb_dma_sync_non_coherent (plane->dev, old_state, state); + vcrtc =drm_crtc_to_vs_crtc (crtc); output = vcrtc->id; dc = vcrtc->dc;
@@ -169,5 +175,8 @@ struct drm_plane *vs_primary_plane_init(struct drm_device *drm_dev, struct vs_dcdrm_plane_helper_add (plane, &vs_primary_plane_helper_funcs); +if (to_vs_drm_dev (drm_dev)->noncoherent) +drm_plane_enable_fb_damage_clips (plane); +return plane; }
Signature · 1 line
2.53.0
Icenowy Zheng
maintainerQuoted 4 lines · 在 2026-05-05二的 04:26 +0000,Dominique Belhachemi写道:
Wire up the standard non-coherent path matching the ingenic DRM driver.
Tested on StarFive JH7110 (VisionFive 2 v1.3B).
Interesting, I am curious about other patches added to test this.
And this patch looks quite generic, should this code be added to the corresponding helpers instead.
Thanks,
Icenowy
Quoted 165 lines
Signed-off-by Dominique Belhachemi <[email protected]>---
drivers/gpu/drm/verisilicon/vs_drm.c | 31
+++++++++++++++++--
drivers/gpu/drm/verisilicon/vs_drm.h | 7 +++++ .../gpu/drm/verisilicon/vs_primary_plane.c | 11 ++++++-3 files changed, 46 insertions(+), 3 deletions(-)drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -4,7 +4,7 @@*/
#include <linux/aperture.h>drivers/gpu/drm/verisilicon/vs_drm.c +1
-1-#include <linux/dma-mapping.h> +#include <linux/of_address.h> #include <
linux/platform_device.h>
#include <linux/module.h>
#include <linux/regmap.h>drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -49,6 +49,31 @@ static int vs_gem_dumb_create(struct drm_file *file_priv,
DEFINE_DRM_GEM_FOPS(vs_drm_driver_fops);
+static structdrm_gem_object*vs_gem_create_object(structdrm_device*drm,drivers/gpu/drm/verisilicon/vs_drm.c +20
-0+ size_t size) +{ +struct drm_gem_dma_object *obj; + + obj =kzalloc_obj (*obj); +if (!obj) +return ERR_PTR (-ENOMEM ); + + obj->map_noncoherent =to_vs_drm_dev (drm)->noncoherent; + +return &obj->base; +} + +static struct drm_framebuffer * +vs_gem_fb_create (struct drm_device *drm,struct drm_file *file, +const struct drm_format_info *info, +const struct drm_mode_fb_cmd2 *mode_cmd) +{ +if (to_vs_drm_dev (drm)->noncoherent) + return drm_gem_fb_create_with_dirty(drm, file, info,
mode_cmd);drivers/gpu/drm/verisilicon/vs_drm.c +4
-0+ +return drm_gem_fb_create (drm, file, info, mode_cmd); +} +static const struct
drm_drivervs_drm_driver= {
.driver_features =DRIVER_MODESET|DRIVER_GEM|DRIVER_ATOMIC,
.fops =&vs_drm_driver_fops,drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -58,12 +83,13 @@ static const struct drm_driver vs_drm_driver = { .minor = DRIVER_MINOR,
/* GEM Operations */drivers/gpu/drm/verisilicon/vs_drm.c +1
-0+ .gem_create_object = vs_gem_create_object,
DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(vs_gem_dumb_create),DRM_FBDEV_DMA_DRIVER_OPS,
};
static const structdrm_mode_config_funcsvs_mode_config_funcs= {drivers/gpu/drm/verisilicon/vs_drm.c +1
-1- .fb_create = drm_gem_fb_create, + .fb_create = vs_gem_fb_create,.atomic_check =
drm_atomic_helper_check,
.atomic_commit =drm_atomic_helper_commit,
};drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -98,6 +124,7 @@ int vs_drm_initialize(struct vs_dc *dc, struct platform_device *pdev)
drm =&vdrm->base;
vdrm->dc= dc;drivers/gpu/drm/verisilicon/vs_drm.c +1
-0+ vdrm->noncoherent = !of_dma_is_coherent (dev->of_node);
dc->drm_dev= vdrm;
ret =drmm_mode_config_init(drm);drivers/gpu/drm/verisilicon/vs_drm.h +0
-0@@ -18,8 +18,15 @@ struct vs_drm_dev {
structvs_dc*dc;
structvs_crtc*crtcs[VSDC_MAX_OUTPUTS];drivers/gpu/drm/verisilicon/vs_drm.h +2
-0+ +bool noncoherent;};
+static inline structvs_drm_dev*to_vs_drm_dev(structdrm_device*drm)drivers/gpu/drm/verisilicon/vs_drm.h +4
-0+{ + return container_of(drm, struct vs_drm_dev, base); +} +int
vs_drm_initialize(struct vs_dc *dc, struct platform_device *pdev);
voidvs_drm_finalize(struct vs_dc *dc);
voidvs_drm_shutdown_handler(struct vs_dc *dc);drivers/gpu/drm/verisilicon/vs_primary_plane.c +1
-0@@ -8,6 +8,7 @@ #include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_crtc.h> +#include <drm/drm_fb_dma_helper.h> #include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_atomic_helper.h>@@ -16,8 +17,9 @@ #include <drm/drm_print.h>
#include "vs_crtc.h"
-#include "vs_plane.h"
#include "vs_dc.h"drivers/gpu/drm/verisilicon/vs_primary_plane.c +2
-0+#include "vs_drm.h" +#include "vs_plane.h" #include "
vs_primary_plane_regs.h"
static int vs_primary_plane_atomic_check(structdrm_plane*plane,drivers/gpu/drm/verisilicon/vs_primary_plane.c +0
-0@@ -86,6 +88,8 @@ static void vs_primary_plane_atomic_disable(struct drm_plane *plane, static void vs_primary_plane_atomic_update(struct drm_plane *plane,struct
drm_atomic_state*atomic_state)
{drivers/gpu/drm/verisilicon/vs_primary_plane.c +1
-0+ struct drm_plane_state *old_state =drm_atomic_get_old_plane_state(atomic_state,
drivers/gpu/drm/verisilicon/vs_primary_plane.c +1
-0+plane);struct
drm_plane_state*state =
drm_atomic_get_new_plane_state(atomic_state,
plane);
structdrm_framebuffer*fb =state->fb;drivers/gpu/drm/verisilicon/vs_primary_plane.c +0
-0@@ -101,6 +105,8 @@ static void vs_primary_plane_atomic_update(struct drm_plane *plane, return; }drivers/gpu/drm/verisilicon/vs_primary_plane.c +2
-0+drm_fb_dma_sync_non_coherent (plane->dev, old_state, state); +vcrtc =
drm_crtc_to_vs_crtc(crtc);
output =vcrtc->id;
dc =vcrtc->dc;drivers/gpu/drm/verisilicon/vs_primary_plane.c +0
-0@@ -169,5 +175,8 @@ struct drm_plane *vs_primary_plane_init(struct
drm_device*drm_dev, structvs_dc
drm_plane_helper_add(plane, &vs_primary_plane_helper_funcs);drivers/gpu/drm/verisilicon/vs_primary_plane.c +3
-0+if (to_vs_drm_dev (drm_dev)->noncoherent) +drm_plane_enable_fb_damage_clips (plane); +return plane;
}
Quoted 11 lines · Icenowy Zheng
Quoted 4 lines · 在 2026-05-05二的 04:26 +0000,Dominique Belhachemi写道:
Wire up the standard non-coherent path matching the ingenic DRM driver.
Tested on StarFive JH7110 (VisionFive 2 v1.3B).
Interesting, I am curious about other patches added to test this.
And this patch looks quite generic, should this code be added to the corresponding helpers instead.
This is pretty generic already. The helper functions are used where they are needed.
ChenYu
Quoted 9 lines · Icenowy Zheng
Quoted 4 lines · 在 2026-05-05二的 04:26 +0000,Dominique Belhachemi写道:
Wire up the standard non-coherent path matching the ingenic DRM driver.
Tested on StarFive JH7110 (VisionFive 2 v1.3B).
Interesting, I am curious about other patches added to test this.
Hi,
I tested this on Debian unstable with a slightly patched 7.0.3 kernel [1]. The test branch contains your verisilicon series, Michal's JH7110 display series [2],
and a JH7110 ccache change [3], which was also required to communicate with the BXE-4-32 firmware [4].
This change here is only used to remove the ugly framebuffer stripes on the console and in the desktop environment.
[1] https://github.com/domibel/linux/tree/jh7110_dc8200_hdmi_v7.0.3
[2] https://lore.kernel.org/lkml/[email protected]/
[3] https://lore.kernel.org/lkml/[email protected]/
[4] https://github.com/domibel/linux/tree/powervr_on_jh7110_visionfive2_v7.0.3
Dominique
Icenowy Zheng
maintainerQuoted 13 lines · 在 2026-05-05二的 18:25 -0400,Dominique Belhachemi写道:
Quoted 9 lines · Icenowy Zheng
Quoted 4 lines · 在 2026-05-05二的 04:26 +0000,Dominique Belhachemi写道:
Wire up the standard non-coherent path matching the ingenic DRM driver.
Tested on StarFive JH7110 (VisionFive 2 v1.3B).
Interesting, I am curious about other patches added to test this.
Hi,
Quoted 7 lines
I tested this on Debian unstable with a slightly patched 7.0.3 kernel [1].
The test branch contains your verisilicon series, Michal's JH7110 display series [2],
and a JH7110 ccache change [3], which was also required to communicate
with the BXE-4-32 firmware [4].
BTW did you run any rendering? I think the way currently powervr open source driver works requires "coherent memory" (although it's usually implemented as uncached memory).
Quoted 3 lines
This change here is only used to remove the ugly framebuffer stripes on the console and in the desktop environment.
But I still think it'd be better to implement proper uncached memory support instead of flushing caches with dirty tracking.
Quoted 8 lines
[1] https://github.com/domibel/linux/tree/jh7110_dc8200_hdmi_v7.0.3
[2]
https://lore.kernel.org/lkml/[email protected]/
[3]
https://lore.kernel.org/lkml/[email protected]/
[4]
https://github.com/domibel/linux/tree/powervr_on_jh7110_visionfive2_v7.0.3
The POW_RASCALDUST thing looks quite interesting, maybe I should investigate it further.
Thanks,
Icenowy
Quoted 2 lines
Dominique
Quoted 23 lines · Icenowy Zheng
Quoted 13 lines · 在 2026-05-05二的 18:25 -0400,Dominique Belhachemi写道:
Quoted 9 lines · Icenowy Zheng
Quoted 4 lines · 在 2026-05-05二的 04:26 +0000,Dominique Belhachemi写道:
Wire up the standard non-coherent path matching the ingenic DRM driver.
Tested on StarFive JH7110 (VisionFive 2 v1.3B).
Interesting, I am curious about other patches added to test this.
Hi,
Quoted 7 lines
I tested this on Debian unstable with a slightly patched 7.0.3 kernel [1].
The test branch contains your verisilicon series, Michal's JH7110 display series [2],
and a JH7110 ccache change [3], which was also required to communicate
with the BXE-4-32 firmware [4].
Quoted 3 lines
BTW did you run any rendering? I think the way currently powervr open source driver works requires "coherent memory" (although it's usually implemented as uncached memory).
Yes, GPU dispatches run with [4].
Compute shaders run fine, but rendering crashes after a few frames.
Quoted 6 lines
Quoted 3 lines
This change here is only used to remove the ugly framebuffer stripes on the console and in the desktop environment.
But I still think it'd be better to implement proper uncached memory support instead of flushing caches with dirty tracking.
Maybe, this patch is just a working alternative.
Dominique
Quoted 18 lines
Quoted 8 lines
[1] https://github.com/domibel/linux/tree/jh7110_dc8200_hdmi_v7.0.3
[2]
https://lore.kernel.org/lkml/[email protected]/
[3]
https://lore.kernel.org/lkml/[email protected]/
[4]
https://github.com/domibel/linux/tree/powervr_on_jh7110_visionfive2_v7.0.3The
POW_RASCALDUSTthing looks quite interesting, maybe I should investigate it further.Thanks,
IcenowyQuoted 2 lines
Dominique
Icenowy Zheng
maintainerQuoted 42 lines · 在 2026-05-06三的 13:38 -0400,Dominique Belhachemi写道:
Quoted 26 lines · Icenowy Zheng
Quoted 15 lines · 在 2026-05-05二的 18:25 -0400,Dominique Belhachemi写道:
Quoted 11 lines · Icenowy Zheng
Quoted 5 lines · 在 2026-05-05二的 04:26 +0000,Dominique Belhachemi写道:
Wire up the standard non-coherent path matching the ingenic DRM
driver.Tested on StarFive JH7110 (VisionFive 2 v1.3B).
Interesting, I am curious about other patches added to test this.
Hi,
Quoted 8 lines
I tested this on Debian unstable with a slightly patched 7.0.3 kernel
[1].
The test branch contains your verisilicon series, Michal's JH7110 display series [2],
and a JH7110 ccache change [3], which was also required to communicate
with the BXE-4-32 firmware [4].Quoted 5 lines
BTW did you run any rendering? I think the way currently powervr open
source driver works requires "coherent memory" (although it's usually
implemented as uncached memory).Yes, GPU dispatches run with [4].
Compute shaders run fine, but rendering crashes after a few frames.Quoted 5 lines
Quoted 4 lines
This change here is only used to remove the ugly framebuffer stripes
on the console and in the desktop environment.
Quoted 5 lines
Quoted 3 lines
But I still think it'd be better to implement proper uncached memory
support instead of flushing caches with dirty tracking.Maybe, this patch is just a working alternative.
I wonder whether it's possible to detect the availability of uncached memory.
At least detecting using of_dma_is_coherent() isn't enough because it will only be true when the device is fully coherent with the CPU (snooping CPU cache).
Thanks,
Icenowy
Quoted 22 lines
Dominique
Quoted 19 lines
Quoted 9 lines
[1]
https://github.com/domibel/linux/tree/jh7110_dc8200_hdmi_v7.0.3
[2]
https://lore.kernel.org/lkml/[email protected]/
[3]
https://lore.kernel.org/lkml/[email protected]/
[4]
https://github.com/domibel/linux/tree/powervr_on_jh7110_visionfive2_v7.0.3The
POW_RASCALDUSTthing looks quite interesting, maybe I should investigate it further.Thanks,
IcenowyQuoted 2 lines
Dominique
Icenowy Zheng
maintainerQuoted 2 lines · 在 2026-05-05二的 04:26 +0000,Dominique Belhachemi写道:
Wire up the standard non-coherent path matching the ingenic DRM driver.
Ah I forgot that my test platform is also noncoherent -- it uses uncached memory map instead of cache maintenance.
Should some other facility to be wired in to check whether cache maintenance or uncached mapping is available and use that functionality?
Thanks,
Icenowy
Quoted 167 lines
Tested on StarFive JH7110 (VisionFive 2 v1.3B).
Signed-off-by Dominique Belhachemi <[email protected]>---
drivers/gpu/drm/verisilicon/vs_drm.c | 31
+++++++++++++++++--
drivers/gpu/drm/verisilicon/vs_drm.h | 7 +++++ .../gpu/drm/verisilicon/vs_primary_plane.c | 11 ++++++-3 files changed, 46 insertions(+), 3 deletions(-)drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -4,7 +4,7 @@*/
#include <linux/aperture.h>drivers/gpu/drm/verisilicon/vs_drm.c +1
-1-#include <linux/dma-mapping.h> +#include <linux/of_address.h> #include <
linux/platform_device.h>
#include <linux/module.h>
#include <linux/regmap.h>drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -49,6 +49,31 @@ static int vs_gem_dumb_create(struct drm_file *file_priv,
DEFINE_DRM_GEM_FOPS(vs_drm_driver_fops);
+static structdrm_gem_object*vs_gem_create_object(structdrm_device*drm,drivers/gpu/drm/verisilicon/vs_drm.c +20
-0+ size_t size) +{ +struct drm_gem_dma_object *obj; + + obj =kzalloc_obj (*obj); +if (!obj) +return ERR_PTR (-ENOMEM ); + + obj->map_noncoherent =to_vs_drm_dev (drm)->noncoherent; + +return &obj->base; +} + +static struct drm_framebuffer * +vs_gem_fb_create (struct drm_device *drm,struct drm_file *file, +const struct drm_format_info *info, +const struct drm_mode_fb_cmd2 *mode_cmd) +{ +if (to_vs_drm_dev (drm)->noncoherent) + return drm_gem_fb_create_with_dirty(drm, file, info,
mode_cmd);drivers/gpu/drm/verisilicon/vs_drm.c +4
-0+ +return drm_gem_fb_create (drm, file, info, mode_cmd); +} +static const struct
drm_drivervs_drm_driver= {
.driver_features =DRIVER_MODESET|DRIVER_GEM|DRIVER_ATOMIC,
.fops =&vs_drm_driver_fops,drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -58,12 +83,13 @@ static const struct drm_driver vs_drm_driver = { .minor = DRIVER_MINOR,
/* GEM Operations */drivers/gpu/drm/verisilicon/vs_drm.c +1
-0+ .gem_create_object = vs_gem_create_object,
DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(vs_gem_dumb_create),DRM_FBDEV_DMA_DRIVER_OPS,
};
static const structdrm_mode_config_funcsvs_mode_config_funcs= {drivers/gpu/drm/verisilicon/vs_drm.c +1
-1- .fb_create = drm_gem_fb_create, + .fb_create = vs_gem_fb_create,.atomic_check =
drm_atomic_helper_check,
.atomic_commit =drm_atomic_helper_commit,
};drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -98,6 +124,7 @@ int vs_drm_initialize(struct vs_dc *dc, struct platform_device *pdev)
drm =&vdrm->base;
vdrm->dc= dc;drivers/gpu/drm/verisilicon/vs_drm.c +1
-0+ vdrm->noncoherent = !of_dma_is_coherent (dev->of_node);
dc->drm_dev= vdrm;
ret =drmm_mode_config_init(drm);drivers/gpu/drm/verisilicon/vs_drm.h +0
-0@@ -18,8 +18,15 @@ struct vs_drm_dev {
structvs_dc*dc;
structvs_crtc*crtcs[VSDC_MAX_OUTPUTS];drivers/gpu/drm/verisilicon/vs_drm.h +2
-0+ +bool noncoherent;};
+static inline structvs_drm_dev*to_vs_drm_dev(structdrm_device*drm)drivers/gpu/drm/verisilicon/vs_drm.h +4
-0+{ + return container_of(drm, struct vs_drm_dev, base); +} +int
vs_drm_initialize(struct vs_dc *dc, struct platform_device *pdev);
voidvs_drm_finalize(struct vs_dc *dc);
voidvs_drm_shutdown_handler(struct vs_dc *dc);drivers/gpu/drm/verisilicon/vs_primary_plane.c +1
-0@@ -8,6 +8,7 @@ #include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_crtc.h> +#include <drm/drm_fb_dma_helper.h> #include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_atomic_helper.h>@@ -16,8 +17,9 @@ #include <drm/drm_print.h>
#include "vs_crtc.h"
-#include "vs_plane.h"
#include "vs_dc.h"drivers/gpu/drm/verisilicon/vs_primary_plane.c +2
-0+#include "vs_drm.h" +#include "vs_plane.h" #include "
vs_primary_plane_regs.h"
static int vs_primary_plane_atomic_check(structdrm_plane*plane,drivers/gpu/drm/verisilicon/vs_primary_plane.c +0
-0@@ -86,6 +88,8 @@ static void vs_primary_plane_atomic_disable(struct drm_plane *plane, static void vs_primary_plane_atomic_update(struct drm_plane *plane,struct
drm_atomic_state*atomic_state)
{drivers/gpu/drm/verisilicon/vs_primary_plane.c +1
-0+ struct drm_plane_state *old_state =drm_atomic_get_old_plane_state(atomic_state,
drivers/gpu/drm/verisilicon/vs_primary_plane.c +1
-0+plane);struct
drm_plane_state*state =
drm_atomic_get_new_plane_state(atomic_state,
plane);
structdrm_framebuffer*fb =state->fb;drivers/gpu/drm/verisilicon/vs_primary_plane.c +0
-0@@ -101,6 +105,8 @@ static void vs_primary_plane_atomic_update(struct drm_plane *plane, return; }drivers/gpu/drm/verisilicon/vs_primary_plane.c +2
-0+drm_fb_dma_sync_non_coherent (plane->dev, old_state, state); +vcrtc =
drm_crtc_to_vs_crtc(crtc);
output =vcrtc->id;
dc =vcrtc->dc;drivers/gpu/drm/verisilicon/vs_primary_plane.c +0
-0@@ -169,5 +175,8 @@ struct drm_plane *vs_primary_plane_init(struct
drm_device*drm_dev, structvs_dc
drm_plane_helper_add(plane, &vs_primary_plane_helper_funcs);drivers/gpu/drm/verisilicon/vs_primary_plane.c +3
-0+if (to_vs_drm_dev (drm_dev)->noncoherent) +drm_plane_enable_fb_damage_clips (plane); +return plane;
}
Icenowy Zheng
maintainerQuoted 10 lines · 在 2026-05-05二的 17:05 +0800,Icenowy Zheng写道:
Quoted 2 lines · 在 2026-05-05二的 04:26 +0000,Dominique Belhachemi写道:
Wire up the standard non-coherent path matching the ingenic DRM driver.
Ah I forgot that my test platform is also noncoherent -- it uses uncached memory map instead of cache maintenance.
Should some other facility to be wired in to check whether cache maintenance or uncached mapping is available and use that functionality?
Ah forgot to mention that drm/imagination driver requires uncached mapping too, and this seems to be difficult to lower (currently impossible because the userspace only does Vulkan coherent map now).
Thanks,
Icenowy
Quoted 181 lines
Thanks,
IcenowyQuoted 177 lines
Tested on StarFive JH7110 (VisionFive 2 v1.3B).
Signed-off-by Dominique Belhachemi <[email protected]>---
drivers/gpu/drm/verisilicon/vs_drm.c | 31
+++++++++++++++++--
drivers/gpu/drm/verisilicon/vs_drm.h | 7 +++++ .../gpu/drm/verisilicon/vs_primary_plane.c | 11 ++++++-3 files changed, 46 insertions(+), 3 deletions(-)drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -4,7 +4,7 @@*/
#include <linux/aperture.h>drivers/gpu/drm/verisilicon/vs_drm.c +1
-1-#include <linux/dma-mapping.h> +#include <linux/of_address.h> #include <
linux/platform_device.h>
#include <linux/module.h>
#include <linux/regmap.h>drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -49,6 +49,31 @@ static int vs_gem_dumb_create(struct drm_file *file_priv,
DEFINE_DRM_GEM_FOPS(vs_drm_driver_fops);
+static structdrm_gem_object*vs_gem_create_object(structdrm_device
*drm,drivers/gpu/drm/verisilicon/vs_drm.c +20
-0+ size_t size) +{ +struct drm_gem_dma_object *obj; + + obj =kzalloc_obj (*obj); +if (!obj) +return ERR_PTR (-ENOMEM ); + + obj->map_noncoherent =to_vs_drm_dev (drm)->noncoherent; + +return &obj->base; +} + +static struct drm_framebuffer * +vs_gem_fb_create (struct drm_device *drm,struct drm_file *file, +const struct drm_format_info *info, +const struct drm_mode_fb_cmd2 *mode_cmd) +{ +if (to_vs_drm_dev (drm)->noncoherent) + return drm_gem_fb_create_with_dirty(drm, file,info,
mode_cmd);drivers/gpu/drm/verisilicon/vs_drm.c +4
-0+ +return drm_gem_fb_create (drm, file, info, mode_cmd); +} +static const struct
drm_drivervs_drm_driver= {
.driver_features =DRIVER_MODESET|DRIVER_GEM|DRIVER_ATOMIC,
.fops =&vs_drm_driver_fops,drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -58,12 +83,13 @@ static const struct drm_driver vs_drm_driver = { .minor = DRIVER_MINOR,
/* GEM Operations */drivers/gpu/drm/verisilicon/vs_drm.c +1
-0+ .gem_create_object = vs_gem_create_object,
DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(vs_gem_dumb_create ),
DRM_FBDEV_DMA_DRIVER_OPS,
};
static const structdrm_mode_config_funcsvs_mode_config_funcs= {drivers/gpu/drm/verisilicon/vs_drm.c +1
-1- .fb_create = drm_gem_fb_create, + .fb_create = vs_gem_fb_create,.atomic_check =
drm_atomic_helper_check,
.atomic_commit =drm_atomic_helper_commit,
};drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -98,6 +124,7 @@ int vs_drm_initialize(struct vs_dc *dc, struct platform_device *pdev)
drm =&vdrm->base;
vdrm->dc= dc;drivers/gpu/drm/verisilicon/vs_drm.c +1
-0+ vdrm->noncoherent = !of_dma_is_coherent (dev->of_node);
dc->drm_dev= vdrm;
ret =drmm_mode_config_init(drm);drivers/gpu/drm/verisilicon/vs_drm.h +0
-0@@ -18,8 +18,15 @@ struct vs_drm_dev {
structvs_dc*dc;
structvs_crtc*crtcs[VSDC_MAX_OUTPUTS];drivers/gpu/drm/verisilicon/vs_drm.h +2
-0+ +bool noncoherent;};
+static inline structvs_drm_dev*to_vs_drm_dev(structdrm_device*drm)drivers/gpu/drm/verisilicon/vs_drm.h +4
-0+{ + return container_of(drm, struct vs_drm_dev, base); +} +int
vs_drm_initialize(struct vs_dc *dc, struct platform_device *pdev);
voidvs_drm_finalize(struct vs_dc *dc);
voidvs_drm_shutdown_handler(struct vs_dc *dc);drivers/gpu/drm/verisilicon/vs_primary_plane.c +1
-0@@ -8,6 +8,7 @@ #include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_crtc.h> +#include <drm/drm_fb_dma_helper.h> #include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_atomic_helper.h>@@ -16,8 +17,9 @@ #include <drm/drm_print.h>
#include "vs_crtc.h"
-#include "vs_plane.h"
#include "vs_dc.h"drivers/gpu/drm/verisilicon/vs_primary_plane.c +2
-0+#include "vs_drm.h" +#include "vs_plane.h" #include "
vs_primary_plane_regs.h"
static int vs_primary_plane_atomic_check(structdrm_plane*plane,drivers/gpu/drm/verisilicon/vs_primary_plane.c +0
-0@@ -86,6 +88,8 @@ static voidvs_primary_plane_atomic_disable(struct
drm_plane*plane,
static void vs_primary_plane_atomic_update(structdrm_plane*plane,
structdrm_atomic_state*atomic_state)
{drivers/gpu/drm/verisilicon/vs_primary_plane.c +1
-0+ struct drm_plane_state *old_state =drm_atomic_get_old_plane_state(atomic_state,
drivers/gpu/drm/verisilicon/vs_primary_plane.c +1
-0+plane);struct
drm_plane_state*state =
drm_atomic_get_new_plane_state(atomic_state,
plane);
structdrm_framebuffer*fb =state->fb;drivers/gpu/drm/verisilicon/vs_primary_plane.c +0
-0@@ -101,6 +105,8 @@ static voidvs_primary_plane_atomic_update(struct
drm_plane*plane,
return;
}drivers/gpu/drm/verisilicon/vs_primary_plane.c +1
-0+ drm_fb_dma_sync_non_coherent(plane->dev, old_state,state);
+
vcrtc =drm_crtc_to_vs_crtc(crtc);
output =vcrtc->id;
dc =vcrtc->dc;drivers/gpu/drm/verisilicon/vs_primary_plane.c +0
-0@@ -169,5 +175,8 @@ struct drm_plane *vs_primary_plane_init(struct
drm_device*drm_dev, structvs_dc
drm_plane_helper_add(plane,&vs_primary_plane_helper_funcs);drivers/gpu/drm/verisilicon/vs_primary_plane.c +3
-0+if (to_vs_drm_dev (drm_dev)->noncoherent) +drm_plane_enable_fb_damage_clips (plane); +return plane;
}
Icenowy Zheng
maintainerQuoted 43 lines · 在 2026-05-05二的 04:26 +0000,Dominique Belhachemi写道:
Wire up the standard non-coherent path matching the ingenic DRM driver.
Tested on StarFive JH7110 (VisionFive 2 v1.3B).
Signed-off-by Dominique Belhachemi <[email protected]>---
drivers/gpu/drm/verisilicon/vs_drm.c | 31
+++++++++++++++++--
drivers/gpu/drm/verisilicon/vs_drm.h | 7 +++++ .../gpu/drm/verisilicon/vs_primary_plane.c | 11 ++++++-3 files changed, 46 insertions(+), 3 deletions(-)drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -4,7 +4,7 @@*/
#include <linux/aperture.h>drivers/gpu/drm/verisilicon/vs_drm.c +1
-1-#include <linux/dma-mapping.h> +#include <linux/of_address.h> #include <
linux/platform_device.h>
#include <linux/module.h>
#include <linux/regmap.h>drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -49,6 +49,31 @@ static int vs_gem_dumb_create(struct drm_file *file_priv,
DEFINE_DRM_GEM_FOPS(vs_drm_driver_fops);
+static structdrm_gem_object*vs_gem_create_object(structdrm_device*drm,drivers/gpu/drm/verisilicon/vs_drm.c +9
-0+ size_t size) +{ +struct drm_gem_dma_object *obj; + + obj =kzalloc_obj (*obj); +if (!obj) +return ERR_PTR (-ENOMEM ); + + obj->map_noncoherent =to_vs_drm_dev (drm)->noncoherent;
drivers/gpu/drm/verisilicon/vs_drm.c static int vs_gem_dumb_create(struct drm_file *file_priv, · line 71
Quoted 10 lines
drivers/gpu/drm/verisilicon/vs_drm.c +10
-0+ +return &obj->base; +} + +static struct drm_framebuffer * +vs_gem_fb_create (struct drm_device *drm,struct drm_file *file, +const struct drm_format_info *info, +const struct drm_mode_fb_cmd2 *mode_cmd) +{ +if (to_vs_drm_dev (drm)->noncoherent)
(Added arch/riscv list/maintainers to To/Cc)
I am still thinking how to decide whether to use dirty-tracking-based cache coherent maintenance or writecombine/uncached mapping.
Maybe a helper should be added, but where? Should it be in arch/riscv (in this case architecture-specific code would be present in the verisilicon driver) or in drivers/gpu/drm?
Nevertheless I think using dev->noncoherent is improper here because in case of writecombine mapping it's also true.
Except for this I think I have no more opinion and okay with the implementation of this patch now.
Thanks,
Icenowy
Quoted 116 lines
drivers/gpu/drm/verisilicon/vs_drm.c +1
-0+ return drm_gem_fb_create_with_dirty(drm, file, info,
mode_cmd);drivers/gpu/drm/verisilicon/vs_drm.c +4
-0+ +return drm_gem_fb_create (drm, file, info, mode_cmd); +} +static const struct
drm_drivervs_drm_driver= {
.driver_features =DRIVER_MODESET|DRIVER_GEM|DRIVER_ATOMIC,
.fops =&vs_drm_driver_fops,drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -58,12 +83,13 @@ static const struct drm_driver vs_drm_driver = { .minor = DRIVER_MINOR,
/* GEM Operations */drivers/gpu/drm/verisilicon/vs_drm.c +1
-0+ .gem_create_object = vs_gem_create_object,
DRM_GEM_DMA_DRIVER_OPS_WITH_DUMB_CREATE(vs_gem_dumb_create),DRM_FBDEV_DMA_DRIVER_OPS,
};
static const structdrm_mode_config_funcsvs_mode_config_funcs= {drivers/gpu/drm/verisilicon/vs_drm.c +1
-1- .fb_create = drm_gem_fb_create, + .fb_create = vs_gem_fb_create,.atomic_check =
drm_atomic_helper_check,
.atomic_commit =drm_atomic_helper_commit,
};drivers/gpu/drm/verisilicon/vs_drm.c +0
-0@@ -98,6 +124,7 @@ int vs_drm_initialize(struct vs_dc *dc, struct platform_device *pdev)
drm =&vdrm->base;
vdrm->dc= dc;drivers/gpu/drm/verisilicon/vs_drm.c +1
-0+ vdrm->noncoherent = !of_dma_is_coherent (dev->of_node);
dc->drm_dev= vdrm;
ret =drmm_mode_config_init(drm);drivers/gpu/drm/verisilicon/vs_drm.h +0
-0@@ -18,8 +18,15 @@ struct vs_drm_dev {
structvs_dc*dc;
structvs_crtc*crtcs[VSDC_MAX_OUTPUTS];drivers/gpu/drm/verisilicon/vs_drm.h +2
-0+ +bool noncoherent;};
+static inline structvs_drm_dev*to_vs_drm_dev(structdrm_device*drm)drivers/gpu/drm/verisilicon/vs_drm.h +4
-0+{ + return container_of(drm, struct vs_drm_dev, base); +} +int
vs_drm_initialize(struct vs_dc *dc, struct platform_device *pdev);
voidvs_drm_finalize(struct vs_dc *dc);
voidvs_drm_shutdown_handler(struct vs_dc *dc);drivers/gpu/drm/verisilicon/vs_primary_plane.c +1
-0@@ -8,6 +8,7 @@ #include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> #include <drm/drm_crtc.h> +#include <drm/drm_fb_dma_helper.h> #include <drm/drm_fourcc.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_atomic_helper.h>@@ -16,8 +17,9 @@ #include <drm/drm_print.h>
#include "vs_crtc.h"
-#include "vs_plane.h"
#include "vs_dc.h"drivers/gpu/drm/verisilicon/vs_primary_plane.c +2
-0+#include "vs_drm.h" +#include "vs_plane.h" #include "
vs_primary_plane_regs.h"
static int vs_primary_plane_atomic_check(structdrm_plane*plane,drivers/gpu/drm/verisilicon/vs_primary_plane.c +0
-0@@ -86,6 +88,8 @@ static void vs_primary_plane_atomic_disable(struct drm_plane *plane, static void vs_primary_plane_atomic_update(struct drm_plane *plane,struct
drm_atomic_state*atomic_state)
{drivers/gpu/drm/verisilicon/vs_primary_plane.c +1
-0+ struct drm_plane_state *old_state =drm_atomic_get_old_plane_state(atomic_state,
drivers/gpu/drm/verisilicon/vs_primary_plane.c +1
-0+plane);struct
drm_plane_state*state =
drm_atomic_get_new_plane_state(atomic_state,
plane);
structdrm_framebuffer*fb =state->fb;drivers/gpu/drm/verisilicon/vs_primary_plane.c +0
-0@@ -101,6 +105,8 @@ static void vs_primary_plane_atomic_update(struct drm_plane *plane, return; }drivers/gpu/drm/verisilicon/vs_primary_plane.c +2
-0+drm_fb_dma_sync_non_coherent (plane->dev, old_state, state); +vcrtc =
drm_crtc_to_vs_crtc(crtc);
output =vcrtc->id;
dc =vcrtc->dc;drivers/gpu/drm/verisilicon/vs_primary_plane.c +0
-0@@ -169,5 +175,8 @@ struct drm_plane *vs_primary_plane_init(struct
drm_device*drm_dev, structvs_dc
drm_plane_helper_add(plane, &vs_primary_plane_helper_funcs);drivers/gpu/drm/verisilicon/vs_primary_plane.c +3
-0+if (to_vs_drm_dev (drm_dev)->noncoherent) +drm_plane_enable_fb_damage_clips (plane); +return plane;
}
Quoted 4 lines · Icenowy Zheng
I am still thinking how to decide whether to use dirty-tracking-based cache coherent maintenance or writecombine/uncached mapping.
Hi Icenowy,
I looked into this again and writecombine/uncached mapping is the way to go. I used Bo Gan's XPbmtUC series and Michal Wilczynski's jh7110 display series and finally got the integrated BXE-4-32 GPU to work.
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
https://github.com/domibel/visionfive2_gpu_bringup
Best
-Dominique
Icenowy Zheng
maintainerQuoted 11 lines · 在 2026-09-28一的 01:21 -0400,Dominique Belhachemi写道:
Quoted 5 lines · Icenowy Zheng
I am still thinking how to decide whether to use dirty-tracking- based
cache coherent maintenance or writecombine/uncached mapping.Hi Icenowy,
I looked into this again and writecombine/uncached mapping is the way to go.
I think drm/imagination really requires it (because the correspoding userspace driver advertises only one memory type with HOST_COHERENT_BIT set), however in the future it could also add cache maintenance support for performance reasons.
Quoted 2 lines
I used Bo Gan's XPbmtUC series and Michal Wilczynski's jh7110 display series and finally got the integrated BXE-4-32 GPU to work.
The XPbmtUC series is problematic -- it "supports EIC7700" "with a hypervisor", which means it cannot run on EIC7700 natively. This severely restricts its usage.
Samuel Holland from SiFive is working on patching the PTE on-the-fly, but that will change all code accessing PTE in the kernel and thus is a heavy work.
P.S. For the JH7110 rascal+dust power issue, I did a try-and-error hack at [1]. The basical register definition of this register (called RGX_CR_POWER_EVENT) is available in their KM volcanic part (but it seems to apply for rogue too), but the individual bits for domains are undocumented, and the highest 8-bit seems to be some kind of multi-core mask on Rogue.
Thanks,
Icenowy
[1]
https://github.com/Icenowy/linux/commit/09db317c9c229ef359e35463f8c08efd3e23c685
Quoted 38 lines · Icenowy Zheng
Quoted 11 lines · 在 2026-09-28一的 01:21 -0400,Dominique Belhachemi写道:
Quoted 5 lines · Icenowy Zheng
I am still thinking how to decide whether to use dirty-tracking- based
cache coherent maintenance or writecombine/uncached mapping.Hi Icenowy,
I looked into this again and writecombine/uncached mapping is the way to go.
I think drm/imagination really requires it (because the correspoding userspace driver advertises only one memory type with
HOST_COHERENT_BITset), however in the future it could also add cache maintenance support for performance reasons.Quoted 2 lines
I used Bo Gan's XPbmtUC series and Michal Wilczynski's jh7110 display series and finally got the integrated BXE-4-32 GPU to work.
The XPbmtUC series is problematic -- it "supports EIC7700" "with a hypervisor", which means it cannot run on EIC7700 natively. This severely restricts its usage.
Samuel Holland from SiFive is working on patching the PTE on-the-fly, but that will change all code accessing PTE in the kernel and thus is a heavy work.
P.S. For the JH7110 rascal+dust power issue, I did a try-and-error hack at [1]. The basical register definition of this register (calledRGX_CR_POWER_EVENT) is available in their KM volcanic part (but it seems to apply for rogue too), but the individual bits for domains are undocumented, and the highest 8-bit seems to be some kind of multi-core mask on Rogue.
Wow, thanks for sharing this. It works reliably and helped me get rid of the double-insmod for powervr.
I integrated it into my branch with updated #defines.
Best
-Dominique