From: Alexander Graf Date: Tue, 3 Jan 2023 21:50:03 +0000 (+0100) Subject: video: Always compile cache flushing code X-Git-Tag: v2025.07-rc2~45^2~1 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=369c6a6c35ea22e3ff60fac45664962d6350adcc;p=pandora-u-boot.git video: Always compile cache flushing code The dcache flushing code path was conditional on ARM && !DCACHE config options. However, dcaches exist on other platforms as well and may need clearing if their driver requires it. Simplify the compile logic and always enable the dcache flush logic in the video core. That way, drivers can always rely on it to call the arch specific callbacks. This will increase code size for non-ARM platforms with CONFIG_VIDEO=y slightly. Reported-by: Heinrich Schuchardt Signed-off-by: Alexander Graf Reviewed-by: Simon Glass Link: https://lore.kernel.org/u-boot/20230821135111.3558478-13-alpernebiyasak@gmail.com/ Added workaround for CONFIG_SYS_CACHELINE_SIZE for ibex-ast2700: Signed-off-by: Simon Glass --- diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 0d582e796cd..503cdb9f025 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -394,18 +394,25 @@ void video_damage(struct udevice *vid, int x, int y, int width, int height) } #endif -#if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) static void video_flush_dcache(struct udevice *vid, bool use_copy) { struct video_priv *priv = dev_get_uclass_priv(vid); ulong fb = use_copy ? (ulong)priv->copy_fb : (ulong)priv->fb; + uint cacheline_size = 32; + +#ifdef CONFIG_SYS_CACHELINE_SIZE + cacheline_size = CONFIG_SYS_CACHELINE_SIZE; +#endif + + if (CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) + return; if (!priv->flush_dcache) return; if (!IS_ENABLED(CONFIG_VIDEO_DAMAGE)) { flush_dcache_range(fb, ALIGN(fb + priv->fb_size, - CONFIG_SYS_CACHELINE_SIZE)); + cacheline_size)); return; } @@ -419,14 +426,13 @@ static void video_flush_dcache(struct udevice *vid, bool use_copy) ulong start = fb + (y * priv->line_length) + lstart; ulong end = start + lend - lstart; - start = ALIGN_DOWN(start, CONFIG_SYS_CACHELINE_SIZE); - end = ALIGN(end, CONFIG_SYS_CACHELINE_SIZE); + start = ALIGN_DOWN(start, cacheline_size); + end = ALIGN(end, cacheline_size); flush_dcache_range(start, end); } } } -#endif static void video_flush_copy(struct udevice *vid) { @@ -469,17 +475,12 @@ int video_sync(struct udevice *vid, bool force) get_timer(priv->last_sync) < CONFIG_VIDEO_SYNC_MS) return 0; - /* - * flush_dcache_range() is declared in common.h but it seems that some - * architectures do not actually implement it. Is there a way to find - * out whether it exists? For now, ARM is safe. - */ -#if defined(CONFIG_ARM) && !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) video_flush_dcache(vid, false); if (IS_ENABLED(CONFIG_VIDEO_COPY)) video_flush_dcache(vid, true); -#elif defined(CONFIG_VIDEO_SANDBOX_SDL) + +#if defined(CONFIG_VIDEO_SANDBOX_SDL) sandbox_sdl_sync(priv->fb); #endif priv->last_sync = get_timer(0);