Gerd Hoffmann
2019-Apr-09 11:59 UTC
[PATCH 4/4] drm: add convert_lines_toio() variant, fix cirrus builds on powerpc.
The __io_virt() macro is not available on all architectures, so cirrus can't simply pass a pointer to io memory down to the format conversion helpers. The format conversion helpers must use memcpy_toio() instead. Add a convert_lines_toio() variant which does just that. Switch the drm_fb_*_dstclip() functions used by cirrus to accept a __iomem pointer as destination and pass that down to convert_lines_toio(). Fix the calls in the cirrus driver to not use __io_virt() any more. Signed-off-by: Gerd Hoffmann <kraxel at redhat.com> --- include/drm/drm_format_helper.h | 9 ++-- drivers/gpu/drm/cirrus/cirrus.c | 6 +-- drivers/gpu/drm/drm_format_helper.c | 74 ++++++++++++++++++++++------- 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h index 6f84380757ee..3532b76c2340 100644 --- a/include/drm/drm_format_helper.h +++ b/include/drm/drm_format_helper.h @@ -15,17 +15,20 @@ struct drm_rect; void drm_fb_memcpy(void *dst, void *vaddr, struct drm_framebuffer *fb, struct drm_rect *clip); -void drm_fb_memcpy_dstclip(void *dst, void *vaddr, struct drm_framebuffer *fb, +void drm_fb_memcpy_dstclip(void __iomem *dst, void *vaddr, + struct drm_framebuffer *fb, struct drm_rect *clip); void drm_fb_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb, struct drm_rect *clip); void drm_fb_xrgb8888_to_rgb565(void *dst, void *vaddr, struct drm_framebuffer *fb, struct drm_rect *clip, bool swap); -void drm_fb_xrgb8888_to_rgb565_dstclip(void *dst, unsigned int dst_pitch, +void drm_fb_xrgb8888_to_rgb565_dstclip(void __iomem *dst, + unsigned int dst_pitch, void *vaddr, struct drm_framebuffer *fb, struct drm_rect *clip, bool swap); -void drm_fb_xrgb8888_to_rgb888_dstclip(void *dst, unsigned int dst_pitch, +void drm_fb_xrgb8888_to_rgb888_dstclip(void __iomem *dst, + unsigned int dst_pitch, void *vaddr, struct drm_framebuffer *fb, struct drm_rect *clip); void drm_fb_xrgb8888_to_gray8(u8 *dst, void *vaddr, struct drm_framebuffer *fb, diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c index 5095b8ce52c2..be4ea370ba31 100644 --- a/drivers/gpu/drm/cirrus/cirrus.c +++ b/drivers/gpu/drm/cirrus/cirrus.c @@ -307,16 +307,16 @@ static int cirrus_fb_blit_rect(struct drm_framebuffer *fb, return -ENOMEM; if (cirrus->cpp == fb->format->cpp[0]) - drm_fb_memcpy_dstclip(__io_virt(cirrus->vram), + drm_fb_memcpy_dstclip(cirrus->vram, vmap, fb, rect); else if (fb->format->cpp[0] == 4 && cirrus->cpp == 2) - drm_fb_xrgb8888_to_rgb565_dstclip(__io_virt(cirrus->vram), + drm_fb_xrgb8888_to_rgb565_dstclip(cirrus->vram, cirrus->pitch, vmap, fb, rect, false); else if (fb->format->cpp[0] == 4 && cirrus->cpp == 3) - drm_fb_xrgb8888_to_rgb888_dstclip(__io_virt(cirrus->vram), + drm_fb_xrgb8888_to_rgb888_dstclip(cirrus->vram, cirrus->pitch, vmap, fb, rect); diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c index 01d9ea134618..6a759cbaa263 100644 --- a/drivers/gpu/drm/drm_format_helper.c +++ b/drivers/gpu/drm/drm_format_helper.c @@ -11,6 +11,8 @@ #include <linux/module.h> #include <linux/slab.h> +#include <asm/io.h> + #include <drm/drm_format_helper.h> #include <drm/drm_framebuffer.h> #include <drm/drm_fourcc.h> @@ -125,6 +127,30 @@ static void convert_lines(void *dst, unsigned int dst_pitch, kfree(sbuf); } +static void convert_lines_toio(void __iomem *dst, unsigned int dst_pitch, + void *src, unsigned int src_pitch, + unsigned int pixels, + unsigned int lines, + struct drm_format_convert *conv) +{ + u32 dst_linelength = pixels * conv->dst_cpp; + u32 y; + void *dbuf; + + dbuf = kmalloc(dst_linelength, GFP_KERNEL); + if (!dbuf) + return; + + for (y = 0; y < lines; y++) { + conv->func(dbuf, src, pixels); + memcpy_toio(dst, dbuf, dst_linelength); + src += src_pitch; + dst += dst_pitch; + } + + kfree(dbuf); +} + static u32 clip_offset(struct drm_rect *clip, u32 pitch, u32 cpp) { return (clip->y1 * pitch) + (clip->x1 * cpp); @@ -143,6 +169,19 @@ static void drm_fb_memcpy_lines(void *dst, unsigned int dst_pitch, } } +static void drm_fb_memcpy_lines_toio(void __iomem *dst, unsigned int dst_pitch, + void *src, unsigned int src_pitch, + unsigned int linelength, unsigned int lines) +{ + int line; + + for (line = 0; line < lines; line++) { + memcpy_toio(dst, src, linelength); + src += src_pitch; + dst += dst_pitch; + } +} + /** * drm_fb_memcpy - Copy clip buffer * @dst: Destination buffer @@ -176,16 +215,17 @@ EXPORT_SYMBOL(drm_fb_memcpy); * This function applies clipping on dst, i.e. the destination is a * full framebuffer but only the clip rect content is copied over. */ -void drm_fb_memcpy_dstclip(void *dst, void *vaddr, struct drm_framebuffer *fb, +void drm_fb_memcpy_dstclip(void __iomem *dst, void *vaddr, + struct drm_framebuffer *fb, struct drm_rect *clip) { unsigned int cpp = drm_format_plane_cpp(fb->format->format, 0); unsigned int offset = (clip->y1 * fb->pitches[0]) + (clip->x1 * cpp); size_t len = (clip->x2 - clip->x1) * cpp; - drm_fb_memcpy_lines(dst + offset, fb->pitches[0], - vaddr + offset, fb->pitches[0], - len, clip->y2 - clip->y1); + drm_fb_memcpy_lines_toio(dst + offset, fb->pitches[0], + vaddr + offset, fb->pitches[0], + len, clip->y2 - clip->y1); } EXPORT_SYMBOL(drm_fb_memcpy_dstclip); @@ -245,7 +285,7 @@ EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565); /** * drm_fb_xrgb8888_to_rgb565_dstclip - Convert XRGB8888 to RGB565 clip buffer - * @dst: RGB565 destination buffer + * @dst: RGB565 destination buffer (__iomem) * @dst_pitch: destination buffer pitch * @vaddr: XRGB8888 source buffer * @fb: DRM framebuffer @@ -256,9 +296,10 @@ EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565); * support XRGB8888. * * This function applies clipping on dst, i.e. the destination is a - * full framebuffer but only the clip rect content is copied over. + * full framebuffer, in iomem, but only the clip rect content is copied over. */ -void drm_fb_xrgb8888_to_rgb565_dstclip(void *dst, unsigned int dst_pitch, +void drm_fb_xrgb8888_to_rgb565_dstclip(void __iomem *dst, + unsigned int dst_pitch, void *vaddr, struct drm_framebuffer *fb, struct drm_rect *clip, bool swap) { @@ -272,15 +313,15 @@ void drm_fb_xrgb8888_to_rgb565_dstclip(void *dst, unsigned int dst_pitch, size_t pixels = (clip->x2 - clip->x1); size_t lines = (clip->y2 - clip->y1); - convert_lines(dst + dst_offset, dst_pitch, - vaddr + src_offset, fb->pitches[0], - pixels, lines, conv); + convert_lines_toio(dst + dst_offset, dst_pitch, + vaddr + src_offset, fb->pitches[0], + pixels, lines, conv); } EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_dstclip); /** * drm_fb_xrgb8888_to_rgb888_dstclip - Convert XRGB8888 to RGB888 clip buffer - * @dst: RGB565 destination buffer + * @dst: RGB888 destination buffer (__iomem) * @dst_pitch: destination buffer pitch * @vaddr: XRGB8888 source buffer * @fb: DRM framebuffer @@ -291,9 +332,10 @@ EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_dstclip); * support XRGB8888. * * This function applies clipping on dst, i.e. the destination is a - * full framebuffer but only the clip rect content is copied over. + * full framebuffer, in iomem, but only the clip rect content is copied over. */ -void drm_fb_xrgb8888_to_rgb888_dstclip(void *dst, unsigned int dst_pitch, +void drm_fb_xrgb8888_to_rgb888_dstclip(void __iomem *dst, + unsigned int dst_pitch, void *vaddr, struct drm_framebuffer *fb, struct drm_rect *clip) { @@ -305,9 +347,9 @@ void drm_fb_xrgb8888_to_rgb888_dstclip(void *dst, unsigned int dst_pitch, size_t pixels = (clip->x2 - clip->x1); size_t lines = (clip->y2 - clip->y1); - convert_lines(dst + dst_offset, dst_pitch, - vaddr + src_offset, fb->pitches[0], - pixels, lines, conv); + convert_lines_toio(dst + dst_offset, dst_pitch, + vaddr + src_offset, fb->pitches[0], + pixels, lines, conv); } EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb888_dstclip); -- 2.18.1
Apparently Analagous Threads
- [PATCH v2 2/3] drm: switch drm_fb_xrgb8888_to_rgb565_dstclip to accept __iomem dst
- [PATCH v2 3/3] drm: switch drm_fb_xrgb8888_to_rgb888_dstclip to accept __iomem dst
- [PATCH v2 1/3] drm: switch drm_fb_memcpy_dstclip to accept __iomem dst
- [PATCH v3 5/5] drm/cirrus: rewrite and modernize driver.
- [PATCH 1/2] exa: Pre-G80 tiling support.