* [PATCH v2 0/3] drm: fix cirrus build failure on powerpc
@ 2019-04-10 6:38 Gerd Hoffmann
2019-04-10 6:38 ` Gerd Hoffmann
` (5 more replies)
0 siblings, 6 replies; 19+ messages in thread
From: Gerd Hoffmann @ 2019-04-10 6:38 UTC (permalink / raw)
To: dri-devel; +Cc: Gerd Hoffmann
Turned out to be a bit more difficuilt than just adding the "asm/io.h"
header files. Not all architectures actually have a __io_virt() macro,
so cirrus can't depend on that. The drm format helpers have to call
memcpy_toio instead. So this little series add support for that.
v2: drop the drm_format_convert abstraction, its overkill (Noralf Trønnes)
Gerd Hoffmann (3):
drm: switch drm_fb_memcpy_dstclip to accept __iomem dst
drm: switch drm_fb_xrgb8888_to_rgb565_dstclip to accept __iomem dst
drm: switch drm_fb_xrgb8888_to_rgb888_dstclip to accept __iomem dst
include/drm/drm_format_helper.h | 7 +-
drivers/gpu/drm/cirrus/cirrus.c | 6 +-
drivers/gpu/drm/drm_format_helper.c | 215 ++++++++++++++--------------
3 files changed, 114 insertions(+), 114 deletions(-)
--
2.18.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v2 1/3] drm: switch drm_fb_memcpy_dstclip to accept __iomem dst
2019-04-10 6:38 [PATCH v2 0/3] drm: fix cirrus build failure on powerpc Gerd Hoffmann
@ 2019-04-10 6:38 ` Gerd Hoffmann
2019-04-10 6:38 ` Gerd Hoffmann
` (4 subsequent siblings)
5 siblings, 0 replies; 19+ messages in thread
From: Gerd Hoffmann @ 2019-04-10 6:38 UTC (permalink / raw)
To: dri-devel
Cc: Gerd Hoffmann, Dave Airlie, David Airlie, Daniel Vetter,
Maarten Lankhorst, Maxime Ripard, Sean Paul,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, open list
Not all archs have the __io_virt() macro, so cirrus can't simply convert
pointers that way. The drm format helpers have to use memcpy_toio()
instead.
This patch makes drm_fb_memcpy_dstclip() accept a __iomem dst pointer
and use memcpy_toio() instead of memcpy(). With that separating out the
memcpy loop into the drm_fb_memcpy_lines() helper isn't useful any more,
so move the code back into the calling functins.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/drm/drm_format_helper.h | 3 +-
drivers/gpu/drm/cirrus/cirrus.c | 2 +-
drivers/gpu/drm/drm_format_helper.c | 45 +++++++++++++++--------------
3 files changed, 27 insertions(+), 23 deletions(-)
diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
index 6f84380757ee..bc2e1004e166 100644
--- a/include/drm/drm_format_helper.h
+++ b/include/drm/drm_format_helper.h
@@ -15,7 +15,8 @@ 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);
diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index 5095b8ce52c2..0fc3aa31b5a4 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -307,7 +307,7 @@ 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)
diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
index 00d716f14173..dace05638bc3 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -10,23 +10,17 @@
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/io.h>
#include <drm/drm_format_helper.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_rect.h>
-static void drm_fb_memcpy_lines(void *dst, unsigned int dst_pitch,
- void *src, unsigned int src_pitch,
- unsigned int linelength, unsigned int lines)
+static unsigned int clip_offset(struct drm_rect *clip,
+ unsigned int pitch, unsigned int cpp)
{
- int line;
-
- for (line = 0; line < lines; line++) {
- memcpy(dst, src, linelength);
- src += src_pitch;
- dst += dst_pitch;
- }
+ return clip->y1 * pitch + clip->x1 * cpp;
}
/**
@@ -43,35 +37,44 @@ void drm_fb_memcpy(void *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;
+ unsigned int y, lines = clip->y2 - clip->y1;
- drm_fb_memcpy_lines(dst, len,
- vaddr + offset, fb->pitches[0],
- len, clip->y2 - clip->y1);
+ vaddr += clip_offset(clip, fb->pitches[0], cpp);
+ for (y = 0; y < lines; y++) {
+ memcpy(dst, vaddr, len);
+ vaddr += fb->pitches[0];
+ dst += len;
+ }
}
EXPORT_SYMBOL(drm_fb_memcpy);
/**
* drm_fb_memcpy_dstclip - Copy clip buffer
- * @dst: Destination buffer
+ * @dst: Destination buffer (iomem)
* @vaddr: Source buffer
* @fb: DRM framebuffer
* @clip: Clip rectangle area to copy
*
* This function applies clipping on dst, i.e. the destination is a
- * full framebuffer but only the clip rect content is copied over.
+ * full (iomem) 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);
+ unsigned int offset = clip_offset(clip, fb->pitches[0], cpp);
size_t len = (clip->x2 - clip->x1) * cpp;
+ unsigned int y, lines = clip->y2 - clip->y1;
- drm_fb_memcpy_lines(dst + offset, fb->pitches[0],
- vaddr + offset, fb->pitches[0],
- len, clip->y2 - clip->y1);
+ vaddr += offset;
+ dst += offset;
+ for (y = 0; y < lines; y++) {
+ memcpy_toio(dst, vaddr, len);
+ vaddr += fb->pitches[0];
+ dst += fb->pitches[0];
+ }
}
EXPORT_SYMBOL(drm_fb_memcpy_dstclip);
--
2.18.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 1/3] drm: switch drm_fb_memcpy_dstclip to accept __iomem dst
2019-04-10 6:38 [PATCH v2 0/3] drm: fix cirrus build failure on powerpc Gerd Hoffmann
2019-04-10 6:38 ` Gerd Hoffmann
@ 2019-04-10 6:38 ` Gerd Hoffmann
2019-04-10 6:38 ` Gerd Hoffmann
` (3 subsequent siblings)
5 siblings, 0 replies; 19+ messages in thread
From: Gerd Hoffmann @ 2019-04-10 6:38 UTC (permalink / raw)
To: dri-devel
Cc: David Airlie, Maarten Lankhorst, open list,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Maxime Ripard,
Daniel Vetter, Dave Airlie, Sean Paul
Not all archs have the __io_virt() macro, so cirrus can't simply convert
pointers that way. The drm format helpers have to use memcpy_toio()
instead.
This patch makes drm_fb_memcpy_dstclip() accept a __iomem dst pointer
and use memcpy_toio() instead of memcpy(). With that separating out the
memcpy loop into the drm_fb_memcpy_lines() helper isn't useful any more,
so move the code back into the calling functins.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/drm/drm_format_helper.h | 3 +-
drivers/gpu/drm/cirrus/cirrus.c | 2 +-
drivers/gpu/drm/drm_format_helper.c | 45 +++++++++++++++--------------
3 files changed, 27 insertions(+), 23 deletions(-)
diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
index 6f84380757ee..bc2e1004e166 100644
--- a/include/drm/drm_format_helper.h
+++ b/include/drm/drm_format_helper.h
@@ -15,7 +15,8 @@ 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);
diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index 5095b8ce52c2..0fc3aa31b5a4 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -307,7 +307,7 @@ 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)
diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
index 00d716f14173..dace05638bc3 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -10,23 +10,17 @@
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/io.h>
#include <drm/drm_format_helper.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_rect.h>
-static void drm_fb_memcpy_lines(void *dst, unsigned int dst_pitch,
- void *src, unsigned int src_pitch,
- unsigned int linelength, unsigned int lines)
+static unsigned int clip_offset(struct drm_rect *clip,
+ unsigned int pitch, unsigned int cpp)
{
- int line;
-
- for (line = 0; line < lines; line++) {
- memcpy(dst, src, linelength);
- src += src_pitch;
- dst += dst_pitch;
- }
+ return clip->y1 * pitch + clip->x1 * cpp;
}
/**
@@ -43,35 +37,44 @@ void drm_fb_memcpy(void *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;
+ unsigned int y, lines = clip->y2 - clip->y1;
- drm_fb_memcpy_lines(dst, len,
- vaddr + offset, fb->pitches[0],
- len, clip->y2 - clip->y1);
+ vaddr += clip_offset(clip, fb->pitches[0], cpp);
+ for (y = 0; y < lines; y++) {
+ memcpy(dst, vaddr, len);
+ vaddr += fb->pitches[0];
+ dst += len;
+ }
}
EXPORT_SYMBOL(drm_fb_memcpy);
/**
* drm_fb_memcpy_dstclip - Copy clip buffer
- * @dst: Destination buffer
+ * @dst: Destination buffer (iomem)
* @vaddr: Source buffer
* @fb: DRM framebuffer
* @clip: Clip rectangle area to copy
*
* This function applies clipping on dst, i.e. the destination is a
- * full framebuffer but only the clip rect content is copied over.
+ * full (iomem) 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);
+ unsigned int offset = clip_offset(clip, fb->pitches[0], cpp);
size_t len = (clip->x2 - clip->x1) * cpp;
+ unsigned int y, lines = clip->y2 - clip->y1;
- drm_fb_memcpy_lines(dst + offset, fb->pitches[0],
- vaddr + offset, fb->pitches[0],
- len, clip->y2 - clip->y1);
+ vaddr += offset;
+ dst += offset;
+ for (y = 0; y < lines; y++) {
+ memcpy_toio(dst, vaddr, len);
+ vaddr += fb->pitches[0];
+ dst += fb->pitches[0];
+ }
}
EXPORT_SYMBOL(drm_fb_memcpy_dstclip);
--
2.18.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 1/3] drm: switch drm_fb_memcpy_dstclip to accept __iomem dst
@ 2019-04-10 6:38 ` Gerd Hoffmann
0 siblings, 0 replies; 19+ messages in thread
From: Gerd Hoffmann @ 2019-04-10 6:38 UTC (permalink / raw)
To: dri-devel
Cc: Gerd Hoffmann, Dave Airlie, David Airlie, Daniel Vetter,
Maarten Lankhorst, Maxime Ripard, Sean Paul,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, open list
Not all archs have the __io_virt() macro, so cirrus can't simply convert
pointers that way. The drm format helpers have to use memcpy_toio()
instead.
This patch makes drm_fb_memcpy_dstclip() accept a __iomem dst pointer
and use memcpy_toio() instead of memcpy(). With that separating out the
memcpy loop into the drm_fb_memcpy_lines() helper isn't useful any more,
so move the code back into the calling functins.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/drm/drm_format_helper.h | 3 +-
drivers/gpu/drm/cirrus/cirrus.c | 2 +-
drivers/gpu/drm/drm_format_helper.c | 45 +++++++++++++++--------------
3 files changed, 27 insertions(+), 23 deletions(-)
diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
index 6f84380757ee..bc2e1004e166 100644
--- a/include/drm/drm_format_helper.h
+++ b/include/drm/drm_format_helper.h
@@ -15,7 +15,8 @@ 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);
diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index 5095b8ce52c2..0fc3aa31b5a4 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -307,7 +307,7 @@ 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)
diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
index 00d716f14173..dace05638bc3 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -10,23 +10,17 @@
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/io.h>
#include <drm/drm_format_helper.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_rect.h>
-static void drm_fb_memcpy_lines(void *dst, unsigned int dst_pitch,
- void *src, unsigned int src_pitch,
- unsigned int linelength, unsigned int lines)
+static unsigned int clip_offset(struct drm_rect *clip,
+ unsigned int pitch, unsigned int cpp)
{
- int line;
-
- for (line = 0; line < lines; line++) {
- memcpy(dst, src, linelength);
- src += src_pitch;
- dst += dst_pitch;
- }
+ return clip->y1 * pitch + clip->x1 * cpp;
}
/**
@@ -43,35 +37,44 @@ void drm_fb_memcpy(void *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;
+ unsigned int y, lines = clip->y2 - clip->y1;
- drm_fb_memcpy_lines(dst, len,
- vaddr + offset, fb->pitches[0],
- len, clip->y2 - clip->y1);
+ vaddr += clip_offset(clip, fb->pitches[0], cpp);
+ for (y = 0; y < lines; y++) {
+ memcpy(dst, vaddr, len);
+ vaddr += fb->pitches[0];
+ dst += len;
+ }
}
EXPORT_SYMBOL(drm_fb_memcpy);
/**
* drm_fb_memcpy_dstclip - Copy clip buffer
- * @dst: Destination buffer
+ * @dst: Destination buffer (iomem)
* @vaddr: Source buffer
* @fb: DRM framebuffer
* @clip: Clip rectangle area to copy
*
* This function applies clipping on dst, i.e. the destination is a
- * full framebuffer but only the clip rect content is copied over.
+ * full (iomem) 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);
+ unsigned int offset = clip_offset(clip, fb->pitches[0], cpp);
size_t len = (clip->x2 - clip->x1) * cpp;
+ unsigned int y, lines = clip->y2 - clip->y1;
- drm_fb_memcpy_lines(dst + offset, fb->pitches[0],
- vaddr + offset, fb->pitches[0],
- len, clip->y2 - clip->y1);
+ vaddr += offset;
+ dst += offset;
+ for (y = 0; y < lines; y++) {
+ memcpy_toio(dst, vaddr, len);
+ vaddr += fb->pitches[0];
+ dst += fb->pitches[0];
+ }
}
EXPORT_SYMBOL(drm_fb_memcpy_dstclip);
--
2.18.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 2/3] drm: switch drm_fb_xrgb8888_to_rgb565_dstclip to accept __iomem dst
2019-04-10 6:38 [PATCH v2 0/3] drm: fix cirrus build failure on powerpc Gerd Hoffmann
@ 2019-04-10 6:38 ` Gerd Hoffmann
2019-04-10 6:38 ` Gerd Hoffmann
` (4 subsequent siblings)
5 siblings, 0 replies; 19+ messages in thread
From: Gerd Hoffmann @ 2019-04-10 6:38 UTC (permalink / raw)
To: dri-devel
Cc: Gerd Hoffmann, Dave Airlie, David Airlie, Daniel Vetter,
Maarten Lankhorst, Maxime Ripard, Sean Paul,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, open list
Not all archs have the __io_virt() macro, so cirrus can't simply convert
pointers that way. The drm format helpers have to use memcpy_toio()
instead.
This patch makes drm_fb_xrgb8888_to_rgb565_dstclip() accept a __iomem
dst pointer and use memcpy_toio() instead of memcpy(). The helper
function (drm_fb_xrgb8888_to_rgb565_line) has been changed to process
a single scanline.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/drm/drm_format_helper.h | 2 +-
drivers/gpu/drm/cirrus/cirrus.c | 2 +-
drivers/gpu/drm/drm_format_helper.c | 113 ++++++++++++++--------------
3 files changed, 60 insertions(+), 57 deletions(-)
diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
index bc2e1004e166..d1b8a9ea01b4 100644
--- a/include/drm/drm_format_helper.h
+++ b/include/drm/drm_format_helper.h
@@ -23,7 +23,7 @@ void drm_fb_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
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,
diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index 0fc3aa31b5a4..ed2f2d8cfb6f 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -311,7 +311,7 @@ static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
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);
diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
index dace05638bc3..c9521af4e90b 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -113,42 +113,22 @@ void drm_fb_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
}
EXPORT_SYMBOL(drm_fb_swab16);
-static void drm_fb_xrgb8888_to_rgb565_lines(void *dst, unsigned int dst_pitch,
- void *src, unsigned int src_pitch,
- unsigned int src_linelength,
- unsigned int lines,
- bool swap)
+static void drm_fb_xrgb8888_to_rgb565_line(u16 *dbuf, u32 *sbuf,
+ unsigned int pixels,
+ bool swab)
{
- unsigned int linepixels = src_linelength / sizeof(u32);
- unsigned int x, y;
- u32 *sbuf;
- u16 *dbuf, val16;
+ unsigned int x;
+ u16 val16;
- /*
- * The cma memory is write-combined so reads are uncached.
- * Speed up by fetching one line at a time.
- */
- sbuf = kmalloc(src_linelength, GFP_KERNEL);
- if (!sbuf)
- return;
-
- for (y = 0; y < lines; y++) {
- memcpy(sbuf, src, src_linelength);
- dbuf = dst;
- for (x = 0; x < linepixels; x++) {
- val16 = ((sbuf[x] & 0x00F80000) >> 8) |
- ((sbuf[x] & 0x0000FC00) >> 5) |
- ((sbuf[x] & 0x000000F8) >> 3);
- if (swap)
- *dbuf++ = swab16(val16);
- else
- *dbuf++ = val16;
- }
- src += src_pitch;
- dst += dst_pitch;
+ for (x = 0; x < pixels; x++) {
+ val16 = ((sbuf[x] & 0x00F80000) >> 8) |
+ ((sbuf[x] & 0x0000FC00) >> 5) |
+ ((sbuf[x] & 0x000000F8) >> 3);
+ if (swab)
+ dbuf[x] = swab16(val16);
+ else
+ dbuf[x] = val16;
}
-
- kfree(sbuf);
}
/**
@@ -167,23 +147,37 @@ static void drm_fb_xrgb8888_to_rgb565_lines(void *dst, unsigned int dst_pitch,
*/
void drm_fb_xrgb8888_to_rgb565(void *dst, void *vaddr,
struct drm_framebuffer *fb,
- struct drm_rect *clip, bool swap)
+ struct drm_rect *clip, bool swab)
{
- unsigned int src_offset = (clip->y1 * fb->pitches[0])
- + (clip->x1 * sizeof(u32));
- size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
- size_t dst_len = (clip->x2 - clip->x1) * sizeof(u16);
+ size_t linepixels = clip->x2 - clip->x1;
+ size_t src_len = linepixels * sizeof(u32);
+ size_t dst_len = linepixels * sizeof(u16);
+ unsigned y, lines = clip->y2 - clip->y1;
+ void *sbuf;
- drm_fb_xrgb8888_to_rgb565_lines(dst, dst_len,
- vaddr + src_offset, fb->pitches[0],
- src_len, clip->y2 - clip->y1,
- swap);
+ /*
+ * The cma memory is write-combined so reads are uncached.
+ * Speed up by fetching one line at a time.
+ */
+ sbuf = kmalloc(src_len, GFP_KERNEL);
+ if (!sbuf)
+ return;
+
+ vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
+ for (y = 0; y < lines; y++) {
+ memcpy(sbuf, vaddr, src_len);
+ drm_fb_xrgb8888_to_rgb565_line(dst, sbuf, linepixels, swab);
+ vaddr += fb->pitches[0];
+ dst += dst_len;
+ }
+
+ kfree(sbuf);
}
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
@@ -194,22 +188,31 @@ 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 (iomem) framebuffer 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)
+ struct drm_rect *clip, bool swab)
{
- unsigned int src_offset = (clip->y1 * fb->pitches[0])
- + (clip->x1 * sizeof(u32));
- unsigned int dst_offset = (clip->y1 * dst_pitch)
- + (clip->x1 * sizeof(u16));
- size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
+ size_t linepixels = clip->x2 - clip->x1;
+ size_t dst_len = linepixels * sizeof(u16);
+ unsigned y, lines = clip->y2 - clip->y1;
+ void *dbuf;
- drm_fb_xrgb8888_to_rgb565_lines(dst + dst_offset, dst_pitch,
- vaddr + src_offset, fb->pitches[0],
- src_len, clip->y2 - clip->y1,
- swap);
+ dbuf = kmalloc(dst_len, GFP_KERNEL);
+ if (!dbuf)
+ return;
+
+ vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
+ dst += clip_offset(clip, dst_pitch, sizeof(u16));
+ for (y = 0; y < lines; y++) {
+ drm_fb_xrgb8888_to_rgb565_line(dbuf, vaddr, linepixels, swab);
+ memcpy_toio(dst, dbuf, dst_len);
+ vaddr += fb->pitches[0];
+ dst += dst_len;
+ }
+
+ kfree(dbuf);
}
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_dstclip);
--
2.18.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 2/3] drm: switch drm_fb_xrgb8888_to_rgb565_dstclip to accept __iomem dst
2019-04-10 6:38 [PATCH v2 0/3] drm: fix cirrus build failure on powerpc Gerd Hoffmann
` (2 preceding siblings ...)
2019-04-10 6:38 ` Gerd Hoffmann
@ 2019-04-10 6:38 ` Gerd Hoffmann
2019-04-10 6:38 ` Gerd Hoffmann
2019-04-10 6:38 ` Gerd Hoffmann
5 siblings, 0 replies; 19+ messages in thread
From: Gerd Hoffmann @ 2019-04-10 6:38 UTC (permalink / raw)
To: dri-devel
Cc: David Airlie, Maarten Lankhorst, open list,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Maxime Ripard,
Daniel Vetter, Dave Airlie, Sean Paul
Not all archs have the __io_virt() macro, so cirrus can't simply convert
pointers that way. The drm format helpers have to use memcpy_toio()
instead.
This patch makes drm_fb_xrgb8888_to_rgb565_dstclip() accept a __iomem
dst pointer and use memcpy_toio() instead of memcpy(). The helper
function (drm_fb_xrgb8888_to_rgb565_line) has been changed to process
a single scanline.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/drm/drm_format_helper.h | 2 +-
drivers/gpu/drm/cirrus/cirrus.c | 2 +-
drivers/gpu/drm/drm_format_helper.c | 113 ++++++++++++++--------------
3 files changed, 60 insertions(+), 57 deletions(-)
diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
index bc2e1004e166..d1b8a9ea01b4 100644
--- a/include/drm/drm_format_helper.h
+++ b/include/drm/drm_format_helper.h
@@ -23,7 +23,7 @@ void drm_fb_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
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,
diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index 0fc3aa31b5a4..ed2f2d8cfb6f 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -311,7 +311,7 @@ static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
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);
diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
index dace05638bc3..c9521af4e90b 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -113,42 +113,22 @@ void drm_fb_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
}
EXPORT_SYMBOL(drm_fb_swab16);
-static void drm_fb_xrgb8888_to_rgb565_lines(void *dst, unsigned int dst_pitch,
- void *src, unsigned int src_pitch,
- unsigned int src_linelength,
- unsigned int lines,
- bool swap)
+static void drm_fb_xrgb8888_to_rgb565_line(u16 *dbuf, u32 *sbuf,
+ unsigned int pixels,
+ bool swab)
{
- unsigned int linepixels = src_linelength / sizeof(u32);
- unsigned int x, y;
- u32 *sbuf;
- u16 *dbuf, val16;
+ unsigned int x;
+ u16 val16;
- /*
- * The cma memory is write-combined so reads are uncached.
- * Speed up by fetching one line at a time.
- */
- sbuf = kmalloc(src_linelength, GFP_KERNEL);
- if (!sbuf)
- return;
-
- for (y = 0; y < lines; y++) {
- memcpy(sbuf, src, src_linelength);
- dbuf = dst;
- for (x = 0; x < linepixels; x++) {
- val16 = ((sbuf[x] & 0x00F80000) >> 8) |
- ((sbuf[x] & 0x0000FC00) >> 5) |
- ((sbuf[x] & 0x000000F8) >> 3);
- if (swap)
- *dbuf++ = swab16(val16);
- else
- *dbuf++ = val16;
- }
- src += src_pitch;
- dst += dst_pitch;
+ for (x = 0; x < pixels; x++) {
+ val16 = ((sbuf[x] & 0x00F80000) >> 8) |
+ ((sbuf[x] & 0x0000FC00) >> 5) |
+ ((sbuf[x] & 0x000000F8) >> 3);
+ if (swab)
+ dbuf[x] = swab16(val16);
+ else
+ dbuf[x] = val16;
}
-
- kfree(sbuf);
}
/**
@@ -167,23 +147,37 @@ static void drm_fb_xrgb8888_to_rgb565_lines(void *dst, unsigned int dst_pitch,
*/
void drm_fb_xrgb8888_to_rgb565(void *dst, void *vaddr,
struct drm_framebuffer *fb,
- struct drm_rect *clip, bool swap)
+ struct drm_rect *clip, bool swab)
{
- unsigned int src_offset = (clip->y1 * fb->pitches[0])
- + (clip->x1 * sizeof(u32));
- size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
- size_t dst_len = (clip->x2 - clip->x1) * sizeof(u16);
+ size_t linepixels = clip->x2 - clip->x1;
+ size_t src_len = linepixels * sizeof(u32);
+ size_t dst_len = linepixels * sizeof(u16);
+ unsigned y, lines = clip->y2 - clip->y1;
+ void *sbuf;
- drm_fb_xrgb8888_to_rgb565_lines(dst, dst_len,
- vaddr + src_offset, fb->pitches[0],
- src_len, clip->y2 - clip->y1,
- swap);
+ /*
+ * The cma memory is write-combined so reads are uncached.
+ * Speed up by fetching one line at a time.
+ */
+ sbuf = kmalloc(src_len, GFP_KERNEL);
+ if (!sbuf)
+ return;
+
+ vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
+ for (y = 0; y < lines; y++) {
+ memcpy(sbuf, vaddr, src_len);
+ drm_fb_xrgb8888_to_rgb565_line(dst, sbuf, linepixels, swab);
+ vaddr += fb->pitches[0];
+ dst += dst_len;
+ }
+
+ kfree(sbuf);
}
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
@@ -194,22 +188,31 @@ 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 (iomem) framebuffer 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)
+ struct drm_rect *clip, bool swab)
{
- unsigned int src_offset = (clip->y1 * fb->pitches[0])
- + (clip->x1 * sizeof(u32));
- unsigned int dst_offset = (clip->y1 * dst_pitch)
- + (clip->x1 * sizeof(u16));
- size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
+ size_t linepixels = clip->x2 - clip->x1;
+ size_t dst_len = linepixels * sizeof(u16);
+ unsigned y, lines = clip->y2 - clip->y1;
+ void *dbuf;
- drm_fb_xrgb8888_to_rgb565_lines(dst + dst_offset, dst_pitch,
- vaddr + src_offset, fb->pitches[0],
- src_len, clip->y2 - clip->y1,
- swap);
+ dbuf = kmalloc(dst_len, GFP_KERNEL);
+ if (!dbuf)
+ return;
+
+ vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
+ dst += clip_offset(clip, dst_pitch, sizeof(u16));
+ for (y = 0; y < lines; y++) {
+ drm_fb_xrgb8888_to_rgb565_line(dbuf, vaddr, linepixels, swab);
+ memcpy_toio(dst, dbuf, dst_len);
+ vaddr += fb->pitches[0];
+ dst += dst_len;
+ }
+
+ kfree(dbuf);
}
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_dstclip);
--
2.18.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 2/3] drm: switch drm_fb_xrgb8888_to_rgb565_dstclip to accept __iomem dst
@ 2019-04-10 6:38 ` Gerd Hoffmann
0 siblings, 0 replies; 19+ messages in thread
From: Gerd Hoffmann @ 2019-04-10 6:38 UTC (permalink / raw)
To: dri-devel
Cc: Gerd Hoffmann, Dave Airlie, David Airlie, Daniel Vetter,
Maarten Lankhorst, Maxime Ripard, Sean Paul,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, open list
Not all archs have the __io_virt() macro, so cirrus can't simply convert
pointers that way. The drm format helpers have to use memcpy_toio()
instead.
This patch makes drm_fb_xrgb8888_to_rgb565_dstclip() accept a __iomem
dst pointer and use memcpy_toio() instead of memcpy(). The helper
function (drm_fb_xrgb8888_to_rgb565_line) has been changed to process
a single scanline.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/drm/drm_format_helper.h | 2 +-
drivers/gpu/drm/cirrus/cirrus.c | 2 +-
drivers/gpu/drm/drm_format_helper.c | 113 ++++++++++++++--------------
3 files changed, 60 insertions(+), 57 deletions(-)
diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
index bc2e1004e166..d1b8a9ea01b4 100644
--- a/include/drm/drm_format_helper.h
+++ b/include/drm/drm_format_helper.h
@@ -23,7 +23,7 @@ void drm_fb_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
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,
diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
index 0fc3aa31b5a4..ed2f2d8cfb6f 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -311,7 +311,7 @@ static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
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);
diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
index dace05638bc3..c9521af4e90b 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -113,42 +113,22 @@ void drm_fb_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
}
EXPORT_SYMBOL(drm_fb_swab16);
-static void drm_fb_xrgb8888_to_rgb565_lines(void *dst, unsigned int dst_pitch,
- void *src, unsigned int src_pitch,
- unsigned int src_linelength,
- unsigned int lines,
- bool swap)
+static void drm_fb_xrgb8888_to_rgb565_line(u16 *dbuf, u32 *sbuf,
+ unsigned int pixels,
+ bool swab)
{
- unsigned int linepixels = src_linelength / sizeof(u32);
- unsigned int x, y;
- u32 *sbuf;
- u16 *dbuf, val16;
+ unsigned int x;
+ u16 val16;
- /*
- * The cma memory is write-combined so reads are uncached.
- * Speed up by fetching one line at a time.
- */
- sbuf = kmalloc(src_linelength, GFP_KERNEL);
- if (!sbuf)
- return;
-
- for (y = 0; y < lines; y++) {
- memcpy(sbuf, src, src_linelength);
- dbuf = dst;
- for (x = 0; x < linepixels; x++) {
- val16 = ((sbuf[x] & 0x00F80000) >> 8) |
- ((sbuf[x] & 0x0000FC00) >> 5) |
- ((sbuf[x] & 0x000000F8) >> 3);
- if (swap)
- *dbuf++ = swab16(val16);
- else
- *dbuf++ = val16;
- }
- src += src_pitch;
- dst += dst_pitch;
+ for (x = 0; x < pixels; x++) {
+ val16 = ((sbuf[x] & 0x00F80000) >> 8) |
+ ((sbuf[x] & 0x0000FC00) >> 5) |
+ ((sbuf[x] & 0x000000F8) >> 3);
+ if (swab)
+ dbuf[x] = swab16(val16);
+ else
+ dbuf[x] = val16;
}
-
- kfree(sbuf);
}
/**
@@ -167,23 +147,37 @@ static void drm_fb_xrgb8888_to_rgb565_lines(void *dst, unsigned int dst_pitch,
*/
void drm_fb_xrgb8888_to_rgb565(void *dst, void *vaddr,
struct drm_framebuffer *fb,
- struct drm_rect *clip, bool swap)
+ struct drm_rect *clip, bool swab)
{
- unsigned int src_offset = (clip->y1 * fb->pitches[0])
- + (clip->x1 * sizeof(u32));
- size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
- size_t dst_len = (clip->x2 - clip->x1) * sizeof(u16);
+ size_t linepixels = clip->x2 - clip->x1;
+ size_t src_len = linepixels * sizeof(u32);
+ size_t dst_len = linepixels * sizeof(u16);
+ unsigned y, lines = clip->y2 - clip->y1;
+ void *sbuf;
- drm_fb_xrgb8888_to_rgb565_lines(dst, dst_len,
- vaddr + src_offset, fb->pitches[0],
- src_len, clip->y2 - clip->y1,
- swap);
+ /*
+ * The cma memory is write-combined so reads are uncached.
+ * Speed up by fetching one line at a time.
+ */
+ sbuf = kmalloc(src_len, GFP_KERNEL);
+ if (!sbuf)
+ return;
+
+ vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
+ for (y = 0; y < lines; y++) {
+ memcpy(sbuf, vaddr, src_len);
+ drm_fb_xrgb8888_to_rgb565_line(dst, sbuf, linepixels, swab);
+ vaddr += fb->pitches[0];
+ dst += dst_len;
+ }
+
+ kfree(sbuf);
}
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
@@ -194,22 +188,31 @@ 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 (iomem) framebuffer 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)
+ struct drm_rect *clip, bool swab)
{
- unsigned int src_offset = (clip->y1 * fb->pitches[0])
- + (clip->x1 * sizeof(u32));
- unsigned int dst_offset = (clip->y1 * dst_pitch)
- + (clip->x1 * sizeof(u16));
- size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
+ size_t linepixels = clip->x2 - clip->x1;
+ size_t dst_len = linepixels * sizeof(u16);
+ unsigned y, lines = clip->y2 - clip->y1;
+ void *dbuf;
- drm_fb_xrgb8888_to_rgb565_lines(dst + dst_offset, dst_pitch,
- vaddr + src_offset, fb->pitches[0],
- src_len, clip->y2 - clip->y1,
- swap);
+ dbuf = kmalloc(dst_len, GFP_KERNEL);
+ if (!dbuf)
+ return;
+
+ vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
+ dst += clip_offset(clip, dst_pitch, sizeof(u16));
+ for (y = 0; y < lines; y++) {
+ drm_fb_xrgb8888_to_rgb565_line(dbuf, vaddr, linepixels, swab);
+ memcpy_toio(dst, dbuf, dst_len);
+ vaddr += fb->pitches[0];
+ dst += dst_len;
+ }
+
+ kfree(dbuf);
}
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_dstclip);
--
2.18.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 3/3] drm: switch drm_fb_xrgb8888_to_rgb888_dstclip to accept __iomem dst
2019-04-10 6:38 [PATCH v2 0/3] drm: fix cirrus build failure on powerpc Gerd Hoffmann
@ 2019-04-10 6:38 ` Gerd Hoffmann
2019-04-10 6:38 ` Gerd Hoffmann
` (4 subsequent siblings)
5 siblings, 0 replies; 19+ messages in thread
From: Gerd Hoffmann @ 2019-04-10 6:38 UTC (permalink / raw)
To: dri-devel
Cc: Gerd Hoffmann, Dave Airlie, David Airlie, Daniel Vetter,
Maarten Lankhorst, Maxime Ripard, Sean Paul,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, open list
Not all archs have the __io_virt() macro, so cirrus can't simply convert
pointers that way. The drm format helpers have to use memcpy_toio()
instead.
This patch makes drm_fb_xrgb8888_to_rgb888_dstclip() accept a __iomem
dst pointer and use memcpy_toio() instead of memcpy(). The helper
function (drm_fb_xrgb8888_to_rgb888_line) has been changed to process a
single scanline.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/drm/drm_format_helper.h | 2 +-
drivers/gpu/drm/cirrus/cirrus.c | 2 +-
drivers/gpu/drm/drm_format_helper.c | 57 +++++++++++++----------------
3 files changed, 27 insertions(+), 34 deletions(-)
diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
index d1b8a9ea01b4..1594a1f967ad 100644
--- a/include/drm/drm_format_helper.h
+++ b/include/drm/drm_format_helper.h
@@ -26,7 +26,7 @@ void drm_fb_xrgb8888_to_rgb565(void *dst, void *vaddr,
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 ed2f2d8cfb6f..be4ea370ba31 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -316,7 +316,7 @@ static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
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 c9521af4e90b..dd9823e3a723 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -216,33 +216,16 @@ void drm_fb_xrgb8888_to_rgb565_dstclip(void __iomem *dst, unsigned int dst_pitch
}
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_dstclip);
-static void drm_fb_xrgb8888_to_rgb888_lines(void *dst, unsigned int dst_pitch,
- void *src, unsigned int src_pitch,
- unsigned int src_linelength,
- unsigned int lines)
+static void drm_fb_xrgb8888_to_rgb888_line(u8 *dbuf, u32 *sbuf,
+ unsigned int pixels)
{
- unsigned int linepixels = src_linelength / 3;
- unsigned int x, y;
- u32 *sbuf;
- u8 *dbuf;
+ unsigned int x;
- sbuf = kmalloc(src_linelength, GFP_KERNEL);
- if (!sbuf)
- return;
-
- for (y = 0; y < lines; y++) {
- memcpy(sbuf, src, src_linelength);
- dbuf = dst;
- for (x = 0; x < linepixels; x++) {
- *dbuf++ = (sbuf[x] & 0x000000FF) >> 0;
- *dbuf++ = (sbuf[x] & 0x0000FF00) >> 8;
- *dbuf++ = (sbuf[x] & 0x00FF0000) >> 16;
- }
- src += src_pitch;
- dst += dst_pitch;
+ for (x = 0; x < pixels; x++) {
+ *dbuf++ = (sbuf[x] & 0x000000FF) >> 0;
+ *dbuf++ = (sbuf[x] & 0x0000FF00) >> 8;
+ *dbuf++ = (sbuf[x] & 0x00FF0000) >> 16;
}
-
- kfree(sbuf);
}
/**
@@ -264,15 +247,25 @@ void drm_fb_xrgb8888_to_rgb888_dstclip(void *dst, unsigned int dst_pitch,
void *vaddr, struct drm_framebuffer *fb,
struct drm_rect *clip)
{
- unsigned int src_offset = (clip->y1 * fb->pitches[0])
- + (clip->x1 * sizeof(u32));
- unsigned int dst_offset = (clip->y1 * dst_pitch)
- + (clip->x1 * 3);
- size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
+ size_t linepixels = clip->x2 - clip->x1;
+ size_t dst_len = linepixels * 3;
+ unsigned y, lines = clip->y2 - clip->y1;
+ void *dbuf;
- drm_fb_xrgb8888_to_rgb888_lines(dst + dst_offset, dst_pitch,
- vaddr + src_offset, fb->pitches[0],
- src_len, clip->y2 - clip->y1);
+ dbuf = kmalloc(dst_len, GFP_KERNEL);
+ if (!dbuf)
+ return;
+
+ vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
+ dst += clip_offset(clip, dst_pitch, sizeof(u16));
+ for (y = 0; y < lines; y++) {
+ drm_fb_xrgb8888_to_rgb888_line(dbuf, vaddr, linepixels);
+ memcpy_toio(dst, dbuf, dst_len);
+ vaddr += fb->pitches[0];
+ dst += dst_len;
+ }
+
+ kfree(dbuf);
}
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb888_dstclip);
--
2.18.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 3/3] drm: switch drm_fb_xrgb8888_to_rgb888_dstclip to accept __iomem dst
2019-04-10 6:38 [PATCH v2 0/3] drm: fix cirrus build failure on powerpc Gerd Hoffmann
` (4 preceding siblings ...)
2019-04-10 6:38 ` Gerd Hoffmann
@ 2019-04-10 6:38 ` Gerd Hoffmann
5 siblings, 0 replies; 19+ messages in thread
From: Gerd Hoffmann @ 2019-04-10 6:38 UTC (permalink / raw)
To: dri-devel
Cc: David Airlie, Maarten Lankhorst, open list,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Maxime Ripard,
Daniel Vetter, Dave Airlie, Sean Paul
Not all archs have the __io_virt() macro, so cirrus can't simply convert
pointers that way. The drm format helpers have to use memcpy_toio()
instead.
This patch makes drm_fb_xrgb8888_to_rgb888_dstclip() accept a __iomem
dst pointer and use memcpy_toio() instead of memcpy(). The helper
function (drm_fb_xrgb8888_to_rgb888_line) has been changed to process a
single scanline.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/drm/drm_format_helper.h | 2 +-
drivers/gpu/drm/cirrus/cirrus.c | 2 +-
drivers/gpu/drm/drm_format_helper.c | 57 +++++++++++++----------------
3 files changed, 27 insertions(+), 34 deletions(-)
diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
index d1b8a9ea01b4..1594a1f967ad 100644
--- a/include/drm/drm_format_helper.h
+++ b/include/drm/drm_format_helper.h
@@ -26,7 +26,7 @@ void drm_fb_xrgb8888_to_rgb565(void *dst, void *vaddr,
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 ed2f2d8cfb6f..be4ea370ba31 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -316,7 +316,7 @@ static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
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 c9521af4e90b..dd9823e3a723 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -216,33 +216,16 @@ void drm_fb_xrgb8888_to_rgb565_dstclip(void __iomem *dst, unsigned int dst_pitch
}
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_dstclip);
-static void drm_fb_xrgb8888_to_rgb888_lines(void *dst, unsigned int dst_pitch,
- void *src, unsigned int src_pitch,
- unsigned int src_linelength,
- unsigned int lines)
+static void drm_fb_xrgb8888_to_rgb888_line(u8 *dbuf, u32 *sbuf,
+ unsigned int pixels)
{
- unsigned int linepixels = src_linelength / 3;
- unsigned int x, y;
- u32 *sbuf;
- u8 *dbuf;
+ unsigned int x;
- sbuf = kmalloc(src_linelength, GFP_KERNEL);
- if (!sbuf)
- return;
-
- for (y = 0; y < lines; y++) {
- memcpy(sbuf, src, src_linelength);
- dbuf = dst;
- for (x = 0; x < linepixels; x++) {
- *dbuf++ = (sbuf[x] & 0x000000FF) >> 0;
- *dbuf++ = (sbuf[x] & 0x0000FF00) >> 8;
- *dbuf++ = (sbuf[x] & 0x00FF0000) >> 16;
- }
- src += src_pitch;
- dst += dst_pitch;
+ for (x = 0; x < pixels; x++) {
+ *dbuf++ = (sbuf[x] & 0x000000FF) >> 0;
+ *dbuf++ = (sbuf[x] & 0x0000FF00) >> 8;
+ *dbuf++ = (sbuf[x] & 0x00FF0000) >> 16;
}
-
- kfree(sbuf);
}
/**
@@ -264,15 +247,25 @@ void drm_fb_xrgb8888_to_rgb888_dstclip(void *dst, unsigned int dst_pitch,
void *vaddr, struct drm_framebuffer *fb,
struct drm_rect *clip)
{
- unsigned int src_offset = (clip->y1 * fb->pitches[0])
- + (clip->x1 * sizeof(u32));
- unsigned int dst_offset = (clip->y1 * dst_pitch)
- + (clip->x1 * 3);
- size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
+ size_t linepixels = clip->x2 - clip->x1;
+ size_t dst_len = linepixels * 3;
+ unsigned y, lines = clip->y2 - clip->y1;
+ void *dbuf;
- drm_fb_xrgb8888_to_rgb888_lines(dst + dst_offset, dst_pitch,
- vaddr + src_offset, fb->pitches[0],
- src_len, clip->y2 - clip->y1);
+ dbuf = kmalloc(dst_len, GFP_KERNEL);
+ if (!dbuf)
+ return;
+
+ vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
+ dst += clip_offset(clip, dst_pitch, sizeof(u16));
+ for (y = 0; y < lines; y++) {
+ drm_fb_xrgb8888_to_rgb888_line(dbuf, vaddr, linepixels);
+ memcpy_toio(dst, dbuf, dst_len);
+ vaddr += fb->pitches[0];
+ dst += dst_len;
+ }
+
+ kfree(dbuf);
}
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb888_dstclip);
--
2.18.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v2 3/3] drm: switch drm_fb_xrgb8888_to_rgb888_dstclip to accept __iomem dst
@ 2019-04-10 6:38 ` Gerd Hoffmann
0 siblings, 0 replies; 19+ messages in thread
From: Gerd Hoffmann @ 2019-04-10 6:38 UTC (permalink / raw)
To: dri-devel
Cc: Gerd Hoffmann, Dave Airlie, David Airlie, Daniel Vetter,
Maarten Lankhorst, Maxime Ripard, Sean Paul,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, open list
Not all archs have the __io_virt() macro, so cirrus can't simply convert
pointers that way. The drm format helpers have to use memcpy_toio()
instead.
This patch makes drm_fb_xrgb8888_to_rgb888_dstclip() accept a __iomem
dst pointer and use memcpy_toio() instead of memcpy(). The helper
function (drm_fb_xrgb8888_to_rgb888_line) has been changed to process a
single scanline.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/drm/drm_format_helper.h | 2 +-
drivers/gpu/drm/cirrus/cirrus.c | 2 +-
drivers/gpu/drm/drm_format_helper.c | 57 +++++++++++++----------------
3 files changed, 27 insertions(+), 34 deletions(-)
diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
index d1b8a9ea01b4..1594a1f967ad 100644
--- a/include/drm/drm_format_helper.h
+++ b/include/drm/drm_format_helper.h
@@ -26,7 +26,7 @@ void drm_fb_xrgb8888_to_rgb565(void *dst, void *vaddr,
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 ed2f2d8cfb6f..be4ea370ba31 100644
--- a/drivers/gpu/drm/cirrus/cirrus.c
+++ b/drivers/gpu/drm/cirrus/cirrus.c
@@ -316,7 +316,7 @@ static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
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 c9521af4e90b..dd9823e3a723 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -216,33 +216,16 @@ void drm_fb_xrgb8888_to_rgb565_dstclip(void __iomem *dst, unsigned int dst_pitch
}
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_dstclip);
-static void drm_fb_xrgb8888_to_rgb888_lines(void *dst, unsigned int dst_pitch,
- void *src, unsigned int src_pitch,
- unsigned int src_linelength,
- unsigned int lines)
+static void drm_fb_xrgb8888_to_rgb888_line(u8 *dbuf, u32 *sbuf,
+ unsigned int pixels)
{
- unsigned int linepixels = src_linelength / 3;
- unsigned int x, y;
- u32 *sbuf;
- u8 *dbuf;
+ unsigned int x;
- sbuf = kmalloc(src_linelength, GFP_KERNEL);
- if (!sbuf)
- return;
-
- for (y = 0; y < lines; y++) {
- memcpy(sbuf, src, src_linelength);
- dbuf = dst;
- for (x = 0; x < linepixels; x++) {
- *dbuf++ = (sbuf[x] & 0x000000FF) >> 0;
- *dbuf++ = (sbuf[x] & 0x0000FF00) >> 8;
- *dbuf++ = (sbuf[x] & 0x00FF0000) >> 16;
- }
- src += src_pitch;
- dst += dst_pitch;
+ for (x = 0; x < pixels; x++) {
+ *dbuf++ = (sbuf[x] & 0x000000FF) >> 0;
+ *dbuf++ = (sbuf[x] & 0x0000FF00) >> 8;
+ *dbuf++ = (sbuf[x] & 0x00FF0000) >> 16;
}
-
- kfree(sbuf);
}
/**
@@ -264,15 +247,25 @@ void drm_fb_xrgb8888_to_rgb888_dstclip(void *dst, unsigned int dst_pitch,
void *vaddr, struct drm_framebuffer *fb,
struct drm_rect *clip)
{
- unsigned int src_offset = (clip->y1 * fb->pitches[0])
- + (clip->x1 * sizeof(u32));
- unsigned int dst_offset = (clip->y1 * dst_pitch)
- + (clip->x1 * 3);
- size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
+ size_t linepixels = clip->x2 - clip->x1;
+ size_t dst_len = linepixels * 3;
+ unsigned y, lines = clip->y2 - clip->y1;
+ void *dbuf;
- drm_fb_xrgb8888_to_rgb888_lines(dst + dst_offset, dst_pitch,
- vaddr + src_offset, fb->pitches[0],
- src_len, clip->y2 - clip->y1);
+ dbuf = kmalloc(dst_len, GFP_KERNEL);
+ if (!dbuf)
+ return;
+
+ vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
+ dst += clip_offset(clip, dst_pitch, sizeof(u16));
+ for (y = 0; y < lines; y++) {
+ drm_fb_xrgb8888_to_rgb888_line(dbuf, vaddr, linepixels);
+ memcpy_toio(dst, dbuf, dst_len);
+ vaddr += fb->pitches[0];
+ dst += dst_len;
+ }
+
+ kfree(dbuf);
}
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb888_dstclip);
--
2.18.1
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v2 1/3] drm: switch drm_fb_memcpy_dstclip to accept __iomem dst
2019-04-10 6:38 ` Gerd Hoffmann
@ 2019-04-10 9:42 ` Noralf Trønnes
-1 siblings, 0 replies; 19+ messages in thread
From: Noralf Trønnes @ 2019-04-10 9:42 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Maxime Ripard,
Dave Airlie, Sean Paul
Den 10.04.2019 08.38, skrev Gerd Hoffmann:
> Not all archs have the __io_virt() macro, so cirrus can't simply convert
> pointers that way. The drm format helpers have to use memcpy_toio()
> instead.
>
> This patch makes drm_fb_memcpy_dstclip() accept a __iomem dst pointer
> and use memcpy_toio() instead of memcpy(). With that separating out the
> memcpy loop into the drm_fb_memcpy_lines() helper isn't useful any more,
> so move the code back into the calling functins.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 1/3] drm: switch drm_fb_memcpy_dstclip to accept __iomem dst
2019-04-10 6:38 ` Gerd Hoffmann
(?)
@ 2019-04-10 9:42 ` Noralf Trønnes
-1 siblings, 0 replies; 19+ messages in thread
From: Noralf Trønnes @ 2019-04-10 9:42 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Maxime Ripard,
Dave Airlie, Sean Paul
Den 10.04.2019 08.38, skrev Gerd Hoffmann:
> Not all archs have the __io_virt() macro, so cirrus can't simply convert
> pointers that way. The drm format helpers have to use memcpy_toio()
> instead.
>
> This patch makes drm_fb_memcpy_dstclip() accept a __iomem dst pointer
> and use memcpy_toio() instead of memcpy(). With that separating out the
> memcpy loop into the drm_fb_memcpy_lines() helper isn't useful any more,
> so move the code back into the calling functins.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 1/3] drm: switch drm_fb_memcpy_dstclip to accept __iomem dst
@ 2019-04-10 9:42 ` Noralf Trønnes
0 siblings, 0 replies; 19+ messages in thread
From: Noralf Trønnes @ 2019-04-10 9:42 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Maxime Ripard,
Dave Airlie, Sean Paul
Den 10.04.2019 08.38, skrev Gerd Hoffmann:
> Not all archs have the __io_virt() macro, so cirrus can't simply convert
> pointers that way. The drm format helpers have to use memcpy_toio()
> instead.
>
> This patch makes drm_fb_memcpy_dstclip() accept a __iomem dst pointer
> and use memcpy_toio() instead of memcpy(). With that separating out the
> memcpy loop into the drm_fb_memcpy_lines() helper isn't useful any more,
> so move the code back into the calling functins.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 2/3] drm: switch drm_fb_xrgb8888_to_rgb565_dstclip to accept __iomem dst
2019-04-10 6:38 ` Gerd Hoffmann
@ 2019-04-10 9:44 ` Noralf Trønnes
-1 siblings, 0 replies; 19+ messages in thread
From: Noralf Trønnes @ 2019-04-10 9:44 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Maxime Ripard,
Dave Airlie, Sean Paul
Den 10.04.2019 08.38, skrev Gerd Hoffmann:
> Not all archs have the __io_virt() macro, so cirrus can't simply convert
> pointers that way. The drm format helpers have to use memcpy_toio()
> instead.
>
> This patch makes drm_fb_xrgb8888_to_rgb565_dstclip() accept a __iomem
> dst pointer and use memcpy_toio() instead of memcpy(). The helper
> function (drm_fb_xrgb8888_to_rgb565_line) has been changed to process
> a single scanline.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> include/drm/drm_format_helper.h | 2 +-
> drivers/gpu/drm/cirrus/cirrus.c | 2 +-
> drivers/gpu/drm/drm_format_helper.c | 113 ++++++++++++++--------------
> 3 files changed, 60 insertions(+), 57 deletions(-)
>
> diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
> index bc2e1004e166..d1b8a9ea01b4 100644
> --- a/include/drm/drm_format_helper.h
> +++ b/include/drm/drm_format_helper.h
> @@ -23,7 +23,7 @@ void drm_fb_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
> 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,
> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
> index 0fc3aa31b5a4..ed2f2d8cfb6f 100644
> --- a/drivers/gpu/drm/cirrus/cirrus.c
> +++ b/drivers/gpu/drm/cirrus/cirrus.c
> @@ -311,7 +311,7 @@ static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
> 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);
>
> diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
> index dace05638bc3..c9521af4e90b 100644
> --- a/drivers/gpu/drm/drm_format_helper.c
> +++ b/drivers/gpu/drm/drm_format_helper.c
> @@ -113,42 +113,22 @@ void drm_fb_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
> }
> EXPORT_SYMBOL(drm_fb_swab16);
>
> -static void drm_fb_xrgb8888_to_rgb565_lines(void *dst, unsigned int dst_pitch,
> - void *src, unsigned int src_pitch,
> - unsigned int src_linelength,
> - unsigned int lines,
> - bool swap)
> +static void drm_fb_xrgb8888_to_rgb565_line(u16 *dbuf, u32 *sbuf,
> + unsigned int pixels,
> + bool swab)
Both here and further down you change the argument name: swap -> swab.
If you want that, you need to fix the function declaration and the docs
as well.
With that sorted out:
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
> {
> - unsigned int linepixels = src_linelength / sizeof(u32);
> - unsigned int x, y;
> - u32 *sbuf;
> - u16 *dbuf, val16;
> + unsigned int x;
> + u16 val16;
>
> - /*
> - * The cma memory is write-combined so reads are uncached.
> - * Speed up by fetching one line at a time.
> - */
> - sbuf = kmalloc(src_linelength, GFP_KERNEL);
> - if (!sbuf)
> - return;
> -
> - for (y = 0; y < lines; y++) {
> - memcpy(sbuf, src, src_linelength);
> - dbuf = dst;
> - for (x = 0; x < linepixels; x++) {
> - val16 = ((sbuf[x] & 0x00F80000) >> 8) |
> - ((sbuf[x] & 0x0000FC00) >> 5) |
> - ((sbuf[x] & 0x000000F8) >> 3);
> - if (swap)
> - *dbuf++ = swab16(val16);
> - else
> - *dbuf++ = val16;
> - }
> - src += src_pitch;
> - dst += dst_pitch;
> + for (x = 0; x < pixels; x++) {
> + val16 = ((sbuf[x] & 0x00F80000) >> 8) |
> + ((sbuf[x] & 0x0000FC00) >> 5) |
> + ((sbuf[x] & 0x000000F8) >> 3);
> + if (swab)
> + dbuf[x] = swab16(val16);
> + else
> + dbuf[x] = val16;
> }
> -
> - kfree(sbuf);
> }
>
> /**
> @@ -167,23 +147,37 @@ static void drm_fb_xrgb8888_to_rgb565_lines(void *dst, unsigned int dst_pitch,
> */
> void drm_fb_xrgb8888_to_rgb565(void *dst, void *vaddr,
> struct drm_framebuffer *fb,
> - struct drm_rect *clip, bool swap)
> + struct drm_rect *clip, bool swab)
> {
> - unsigned int src_offset = (clip->y1 * fb->pitches[0])
> - + (clip->x1 * sizeof(u32));
> - size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
> - size_t dst_len = (clip->x2 - clip->x1) * sizeof(u16);
> + size_t linepixels = clip->x2 - clip->x1;
> + size_t src_len = linepixels * sizeof(u32);
> + size_t dst_len = linepixels * sizeof(u16);
> + unsigned y, lines = clip->y2 - clip->y1;
> + void *sbuf;
>
> - drm_fb_xrgb8888_to_rgb565_lines(dst, dst_len,
> - vaddr + src_offset, fb->pitches[0],
> - src_len, clip->y2 - clip->y1,
> - swap);
> + /*
> + * The cma memory is write-combined so reads are uncached.
> + * Speed up by fetching one line at a time.
> + */
> + sbuf = kmalloc(src_len, GFP_KERNEL);
> + if (!sbuf)
> + return;
> +
> + vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
> + for (y = 0; y < lines; y++) {
> + memcpy(sbuf, vaddr, src_len);
> + drm_fb_xrgb8888_to_rgb565_line(dst, sbuf, linepixels, swab);
> + vaddr += fb->pitches[0];
> + dst += dst_len;
> + }
> +
> + kfree(sbuf);
> }
> 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
> @@ -194,22 +188,31 @@ 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 (iomem) framebuffer 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)
> + struct drm_rect *clip, bool swab)
> {
> - unsigned int src_offset = (clip->y1 * fb->pitches[0])
> - + (clip->x1 * sizeof(u32));
> - unsigned int dst_offset = (clip->y1 * dst_pitch)
> - + (clip->x1 * sizeof(u16));
> - size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
> + size_t linepixels = clip->x2 - clip->x1;
> + size_t dst_len = linepixels * sizeof(u16);
> + unsigned y, lines = clip->y2 - clip->y1;
> + void *dbuf;
>
> - drm_fb_xrgb8888_to_rgb565_lines(dst + dst_offset, dst_pitch,
> - vaddr + src_offset, fb->pitches[0],
> - src_len, clip->y2 - clip->y1,
> - swap);
> + dbuf = kmalloc(dst_len, GFP_KERNEL);
> + if (!dbuf)
> + return;
> +
> + vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
> + dst += clip_offset(clip, dst_pitch, sizeof(u16));
> + for (y = 0; y < lines; y++) {
> + drm_fb_xrgb8888_to_rgb565_line(dbuf, vaddr, linepixels, swab);
> + memcpy_toio(dst, dbuf, dst_len);
> + vaddr += fb->pitches[0];
> + dst += dst_len;
> + }
> +
> + kfree(dbuf);
> }
> EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_dstclip);
>
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 2/3] drm: switch drm_fb_xrgb8888_to_rgb565_dstclip to accept __iomem dst
2019-04-10 6:38 ` Gerd Hoffmann
(?)
(?)
@ 2019-04-10 9:44 ` Noralf Trønnes
-1 siblings, 0 replies; 19+ messages in thread
From: Noralf Trønnes @ 2019-04-10 9:44 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Maxime Ripard,
Dave Airlie, Sean Paul
Den 10.04.2019 08.38, skrev Gerd Hoffmann:
> Not all archs have the __io_virt() macro, so cirrus can't simply convert
> pointers that way. The drm format helpers have to use memcpy_toio()
> instead.
>
> This patch makes drm_fb_xrgb8888_to_rgb565_dstclip() accept a __iomem
> dst pointer and use memcpy_toio() instead of memcpy(). The helper
> function (drm_fb_xrgb8888_to_rgb565_line) has been changed to process
> a single scanline.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> include/drm/drm_format_helper.h | 2 +-
> drivers/gpu/drm/cirrus/cirrus.c | 2 +-
> drivers/gpu/drm/drm_format_helper.c | 113 ++++++++++++++--------------
> 3 files changed, 60 insertions(+), 57 deletions(-)
>
> diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
> index bc2e1004e166..d1b8a9ea01b4 100644
> --- a/include/drm/drm_format_helper.h
> +++ b/include/drm/drm_format_helper.h
> @@ -23,7 +23,7 @@ void drm_fb_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
> 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,
> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
> index 0fc3aa31b5a4..ed2f2d8cfb6f 100644
> --- a/drivers/gpu/drm/cirrus/cirrus.c
> +++ b/drivers/gpu/drm/cirrus/cirrus.c
> @@ -311,7 +311,7 @@ static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
> 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);
>
> diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
> index dace05638bc3..c9521af4e90b 100644
> --- a/drivers/gpu/drm/drm_format_helper.c
> +++ b/drivers/gpu/drm/drm_format_helper.c
> @@ -113,42 +113,22 @@ void drm_fb_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
> }
> EXPORT_SYMBOL(drm_fb_swab16);
>
> -static void drm_fb_xrgb8888_to_rgb565_lines(void *dst, unsigned int dst_pitch,
> - void *src, unsigned int src_pitch,
> - unsigned int src_linelength,
> - unsigned int lines,
> - bool swap)
> +static void drm_fb_xrgb8888_to_rgb565_line(u16 *dbuf, u32 *sbuf,
> + unsigned int pixels,
> + bool swab)
Both here and further down you change the argument name: swap -> swab.
If you want that, you need to fix the function declaration and the docs
as well.
With that sorted out:
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
> {
> - unsigned int linepixels = src_linelength / sizeof(u32);
> - unsigned int x, y;
> - u32 *sbuf;
> - u16 *dbuf, val16;
> + unsigned int x;
> + u16 val16;
>
> - /*
> - * The cma memory is write-combined so reads are uncached.
> - * Speed up by fetching one line at a time.
> - */
> - sbuf = kmalloc(src_linelength, GFP_KERNEL);
> - if (!sbuf)
> - return;
> -
> - for (y = 0; y < lines; y++) {
> - memcpy(sbuf, src, src_linelength);
> - dbuf = dst;
> - for (x = 0; x < linepixels; x++) {
> - val16 = ((sbuf[x] & 0x00F80000) >> 8) |
> - ((sbuf[x] & 0x0000FC00) >> 5) |
> - ((sbuf[x] & 0x000000F8) >> 3);
> - if (swap)
> - *dbuf++ = swab16(val16);
> - else
> - *dbuf++ = val16;
> - }
> - src += src_pitch;
> - dst += dst_pitch;
> + for (x = 0; x < pixels; x++) {
> + val16 = ((sbuf[x] & 0x00F80000) >> 8) |
> + ((sbuf[x] & 0x0000FC00) >> 5) |
> + ((sbuf[x] & 0x000000F8) >> 3);
> + if (swab)
> + dbuf[x] = swab16(val16);
> + else
> + dbuf[x] = val16;
> }
> -
> - kfree(sbuf);
> }
>
> /**
> @@ -167,23 +147,37 @@ static void drm_fb_xrgb8888_to_rgb565_lines(void *dst, unsigned int dst_pitch,
> */
> void drm_fb_xrgb8888_to_rgb565(void *dst, void *vaddr,
> struct drm_framebuffer *fb,
> - struct drm_rect *clip, bool swap)
> + struct drm_rect *clip, bool swab)
> {
> - unsigned int src_offset = (clip->y1 * fb->pitches[0])
> - + (clip->x1 * sizeof(u32));
> - size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
> - size_t dst_len = (clip->x2 - clip->x1) * sizeof(u16);
> + size_t linepixels = clip->x2 - clip->x1;
> + size_t src_len = linepixels * sizeof(u32);
> + size_t dst_len = linepixels * sizeof(u16);
> + unsigned y, lines = clip->y2 - clip->y1;
> + void *sbuf;
>
> - drm_fb_xrgb8888_to_rgb565_lines(dst, dst_len,
> - vaddr + src_offset, fb->pitches[0],
> - src_len, clip->y2 - clip->y1,
> - swap);
> + /*
> + * The cma memory is write-combined so reads are uncached.
> + * Speed up by fetching one line at a time.
> + */
> + sbuf = kmalloc(src_len, GFP_KERNEL);
> + if (!sbuf)
> + return;
> +
> + vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
> + for (y = 0; y < lines; y++) {
> + memcpy(sbuf, vaddr, src_len);
> + drm_fb_xrgb8888_to_rgb565_line(dst, sbuf, linepixels, swab);
> + vaddr += fb->pitches[0];
> + dst += dst_len;
> + }
> +
> + kfree(sbuf);
> }
> 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
> @@ -194,22 +188,31 @@ 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 (iomem) framebuffer 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)
> + struct drm_rect *clip, bool swab)
> {
> - unsigned int src_offset = (clip->y1 * fb->pitches[0])
> - + (clip->x1 * sizeof(u32));
> - unsigned int dst_offset = (clip->y1 * dst_pitch)
> - + (clip->x1 * sizeof(u16));
> - size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
> + size_t linepixels = clip->x2 - clip->x1;
> + size_t dst_len = linepixels * sizeof(u16);
> + unsigned y, lines = clip->y2 - clip->y1;
> + void *dbuf;
>
> - drm_fb_xrgb8888_to_rgb565_lines(dst + dst_offset, dst_pitch,
> - vaddr + src_offset, fb->pitches[0],
> - src_len, clip->y2 - clip->y1,
> - swap);
> + dbuf = kmalloc(dst_len, GFP_KERNEL);
> + if (!dbuf)
> + return;
> +
> + vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
> + dst += clip_offset(clip, dst_pitch, sizeof(u16));
> + for (y = 0; y < lines; y++) {
> + drm_fb_xrgb8888_to_rgb565_line(dbuf, vaddr, linepixels, swab);
> + memcpy_toio(dst, dbuf, dst_len);
> + vaddr += fb->pitches[0];
> + dst += dst_len;
> + }
> +
> + kfree(dbuf);
> }
> EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_dstclip);
>
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 2/3] drm: switch drm_fb_xrgb8888_to_rgb565_dstclip to accept __iomem dst
@ 2019-04-10 9:44 ` Noralf Trønnes
0 siblings, 0 replies; 19+ messages in thread
From: Noralf Trønnes @ 2019-04-10 9:44 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Maxime Ripard,
Dave Airlie, Sean Paul
Den 10.04.2019 08.38, skrev Gerd Hoffmann:
> Not all archs have the __io_virt() macro, so cirrus can't simply convert
> pointers that way. The drm format helpers have to use memcpy_toio()
> instead.
>
> This patch makes drm_fb_xrgb8888_to_rgb565_dstclip() accept a __iomem
> dst pointer and use memcpy_toio() instead of memcpy(). The helper
> function (drm_fb_xrgb8888_to_rgb565_line) has been changed to process
> a single scanline.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> include/drm/drm_format_helper.h | 2 +-
> drivers/gpu/drm/cirrus/cirrus.c | 2 +-
> drivers/gpu/drm/drm_format_helper.c | 113 ++++++++++++++--------------
> 3 files changed, 60 insertions(+), 57 deletions(-)
>
> diff --git a/include/drm/drm_format_helper.h b/include/drm/drm_format_helper.h
> index bc2e1004e166..d1b8a9ea01b4 100644
> --- a/include/drm/drm_format_helper.h
> +++ b/include/drm/drm_format_helper.h
> @@ -23,7 +23,7 @@ void drm_fb_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
> 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,
> diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c
> index 0fc3aa31b5a4..ed2f2d8cfb6f 100644
> --- a/drivers/gpu/drm/cirrus/cirrus.c
> +++ b/drivers/gpu/drm/cirrus/cirrus.c
> @@ -311,7 +311,7 @@ static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
> 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);
>
> diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
> index dace05638bc3..c9521af4e90b 100644
> --- a/drivers/gpu/drm/drm_format_helper.c
> +++ b/drivers/gpu/drm/drm_format_helper.c
> @@ -113,42 +113,22 @@ void drm_fb_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
> }
> EXPORT_SYMBOL(drm_fb_swab16);
>
> -static void drm_fb_xrgb8888_to_rgb565_lines(void *dst, unsigned int dst_pitch,
> - void *src, unsigned int src_pitch,
> - unsigned int src_linelength,
> - unsigned int lines,
> - bool swap)
> +static void drm_fb_xrgb8888_to_rgb565_line(u16 *dbuf, u32 *sbuf,
> + unsigned int pixels,
> + bool swab)
Both here and further down you change the argument name: swap -> swab.
If you want that, you need to fix the function declaration and the docs
as well.
With that sorted out:
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
> {
> - unsigned int linepixels = src_linelength / sizeof(u32);
> - unsigned int x, y;
> - u32 *sbuf;
> - u16 *dbuf, val16;
> + unsigned int x;
> + u16 val16;
>
> - /*
> - * The cma memory is write-combined so reads are uncached.
> - * Speed up by fetching one line at a time.
> - */
> - sbuf = kmalloc(src_linelength, GFP_KERNEL);
> - if (!sbuf)
> - return;
> -
> - for (y = 0; y < lines; y++) {
> - memcpy(sbuf, src, src_linelength);
> - dbuf = dst;
> - for (x = 0; x < linepixels; x++) {
> - val16 = ((sbuf[x] & 0x00F80000) >> 8) |
> - ((sbuf[x] & 0x0000FC00) >> 5) |
> - ((sbuf[x] & 0x000000F8) >> 3);
> - if (swap)
> - *dbuf++ = swab16(val16);
> - else
> - *dbuf++ = val16;
> - }
> - src += src_pitch;
> - dst += dst_pitch;
> + for (x = 0; x < pixels; x++) {
> + val16 = ((sbuf[x] & 0x00F80000) >> 8) |
> + ((sbuf[x] & 0x0000FC00) >> 5) |
> + ((sbuf[x] & 0x000000F8) >> 3);
> + if (swab)
> + dbuf[x] = swab16(val16);
> + else
> + dbuf[x] = val16;
> }
> -
> - kfree(sbuf);
> }
>
> /**
> @@ -167,23 +147,37 @@ static void drm_fb_xrgb8888_to_rgb565_lines(void *dst, unsigned int dst_pitch,
> */
> void drm_fb_xrgb8888_to_rgb565(void *dst, void *vaddr,
> struct drm_framebuffer *fb,
> - struct drm_rect *clip, bool swap)
> + struct drm_rect *clip, bool swab)
> {
> - unsigned int src_offset = (clip->y1 * fb->pitches[0])
> - + (clip->x1 * sizeof(u32));
> - size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
> - size_t dst_len = (clip->x2 - clip->x1) * sizeof(u16);
> + size_t linepixels = clip->x2 - clip->x1;
> + size_t src_len = linepixels * sizeof(u32);
> + size_t dst_len = linepixels * sizeof(u16);
> + unsigned y, lines = clip->y2 - clip->y1;
> + void *sbuf;
>
> - drm_fb_xrgb8888_to_rgb565_lines(dst, dst_len,
> - vaddr + src_offset, fb->pitches[0],
> - src_len, clip->y2 - clip->y1,
> - swap);
> + /*
> + * The cma memory is write-combined so reads are uncached.
> + * Speed up by fetching one line at a time.
> + */
> + sbuf = kmalloc(src_len, GFP_KERNEL);
> + if (!sbuf)
> + return;
> +
> + vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
> + for (y = 0; y < lines; y++) {
> + memcpy(sbuf, vaddr, src_len);
> + drm_fb_xrgb8888_to_rgb565_line(dst, sbuf, linepixels, swab);
> + vaddr += fb->pitches[0];
> + dst += dst_len;
> + }
> +
> + kfree(sbuf);
> }
> 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
> @@ -194,22 +188,31 @@ 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 (iomem) framebuffer 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)
> + struct drm_rect *clip, bool swab)
> {
> - unsigned int src_offset = (clip->y1 * fb->pitches[0])
> - + (clip->x1 * sizeof(u32));
> - unsigned int dst_offset = (clip->y1 * dst_pitch)
> - + (clip->x1 * sizeof(u16));
> - size_t src_len = (clip->x2 - clip->x1) * sizeof(u32);
> + size_t linepixels = clip->x2 - clip->x1;
> + size_t dst_len = linepixels * sizeof(u16);
> + unsigned y, lines = clip->y2 - clip->y1;
> + void *dbuf;
>
> - drm_fb_xrgb8888_to_rgb565_lines(dst + dst_offset, dst_pitch,
> - vaddr + src_offset, fb->pitches[0],
> - src_len, clip->y2 - clip->y1,
> - swap);
> + dbuf = kmalloc(dst_len, GFP_KERNEL);
> + if (!dbuf)
> + return;
> +
> + vaddr += clip_offset(clip, fb->pitches[0], sizeof(u32));
> + dst += clip_offset(clip, dst_pitch, sizeof(u16));
> + for (y = 0; y < lines; y++) {
> + drm_fb_xrgb8888_to_rgb565_line(dbuf, vaddr, linepixels, swab);
> + memcpy_toio(dst, dbuf, dst_len);
> + vaddr += fb->pitches[0];
> + dst += dst_len;
> + }
> +
> + kfree(dbuf);
> }
> EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565_dstclip);
>
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 3/3] drm: switch drm_fb_xrgb8888_to_rgb888_dstclip to accept __iomem dst
2019-04-10 6:38 ` Gerd Hoffmann
@ 2019-04-10 9:45 ` Noralf Trønnes
-1 siblings, 0 replies; 19+ messages in thread
From: Noralf Trønnes @ 2019-04-10 9:45 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Maxime Ripard,
Dave Airlie, Sean Paul
Den 10.04.2019 08.38, skrev Gerd Hoffmann:
> Not all archs have the __io_virt() macro, so cirrus can't simply convert
> pointers that way. The drm format helpers have to use memcpy_toio()
> instead.
>
> This patch makes drm_fb_xrgb8888_to_rgb888_dstclip() accept a __iomem
> dst pointer and use memcpy_toio() instead of memcpy(). The helper
> function (drm_fb_xrgb8888_to_rgb888_line) has been changed to process a
> single scanline.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 3/3] drm: switch drm_fb_xrgb8888_to_rgb888_dstclip to accept __iomem dst
2019-04-10 6:38 ` Gerd Hoffmann
(?)
@ 2019-04-10 9:45 ` Noralf Trønnes
-1 siblings, 0 replies; 19+ messages in thread
From: Noralf Trønnes @ 2019-04-10 9:45 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Maxime Ripard,
Dave Airlie, Sean Paul
Den 10.04.2019 08.38, skrev Gerd Hoffmann:
> Not all archs have the __io_virt() macro, so cirrus can't simply convert
> pointers that way. The drm format helpers have to use memcpy_toio()
> instead.
>
> This patch makes drm_fb_xrgb8888_to_rgb888_dstclip() accept a __iomem
> dst pointer and use memcpy_toio() instead of memcpy(). The helper
> function (drm_fb_xrgb8888_to_rgb888_line) has been changed to process a
> single scanline.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v2 3/3] drm: switch drm_fb_xrgb8888_to_rgb888_dstclip to accept __iomem dst
@ 2019-04-10 9:45 ` Noralf Trønnes
0 siblings, 0 replies; 19+ messages in thread
From: Noralf Trønnes @ 2019-04-10 9:45 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: David Airlie, open list,
open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE, Maxime Ripard,
Dave Airlie, Sean Paul
Den 10.04.2019 08.38, skrev Gerd Hoffmann:
> Not all archs have the __io_virt() macro, so cirrus can't simply convert
> pointers that way. The drm format helpers have to use memcpy_toio()
> instead.
>
> This patch makes drm_fb_xrgb8888_to_rgb888_dstclip() accept a __iomem
> dst pointer and use memcpy_toio() instead of memcpy(). The helper
> function (drm_fb_xrgb8888_to_rgb888_line) has been changed to process a
> single scanline.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2019-04-10 9:45 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-10 6:38 [PATCH v2 0/3] drm: fix cirrus build failure on powerpc Gerd Hoffmann
2019-04-10 6:38 ` [PATCH v2 1/3] drm: switch drm_fb_memcpy_dstclip to accept __iomem dst Gerd Hoffmann
2019-04-10 6:38 ` Gerd Hoffmann
2019-04-10 9:42 ` Noralf Trønnes
2019-04-10 9:42 ` Noralf Trønnes
2019-04-10 9:42 ` Noralf Trønnes
2019-04-10 6:38 ` Gerd Hoffmann
2019-04-10 6:38 ` [PATCH v2 2/3] drm: switch drm_fb_xrgb8888_to_rgb565_dstclip " Gerd Hoffmann
2019-04-10 6:38 ` Gerd Hoffmann
2019-04-10 9:44 ` Noralf Trønnes
2019-04-10 9:44 ` Noralf Trønnes
2019-04-10 9:44 ` Noralf Trønnes
2019-04-10 6:38 ` Gerd Hoffmann
2019-04-10 6:38 ` [PATCH v2 3/3] drm: switch drm_fb_xrgb8888_to_rgb888_dstclip " Gerd Hoffmann
2019-04-10 6:38 ` Gerd Hoffmann
2019-04-10 9:45 ` Noralf Trønnes
2019-04-10 9:45 ` Noralf Trønnes
2019-04-10 9:45 ` Noralf Trønnes
2019-04-10 6:38 ` Gerd Hoffmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.