* [PATCH 0/5] drm: Provide framebuffer vmap helpers
@ 2021-07-15 18:01 Thomas Zimmermann
2021-07-15 18:01 ` [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES Thomas Zimmermann
` (4 more replies)
0 siblings, 5 replies; 20+ messages in thread
From: Thomas Zimmermann @ 2021-07-15 18:01 UTC (permalink / raw)
To: maarten.lankhorst, mripard, airlied, daniel, noralf,
rodrigosiqueiramelo, melissa.srw, hamohammed.sa
Cc: Thomas Zimmermann, dri-devel
Add the new helpers drm_gem_fb_vmap() and drm_gem_fb_vunmap(), which
provide vmap/vunmap for all BOs of a framebuffer. Convert shadow-
plane helpers, gud and vkms.
Callers of GEM vmap and vunmap functions used to do the minumum work
or get some detail wrong. Therefore shadow-plane helpers were intro-
duced to implement the details for all callers. The vmapping code in
the shadow-plane helpers is also useful for gud and vkms. So it makes
sense to provide rsp helpers. Simply call drm_gem_fb_vmap() to
retrieve mappings of all of a framebuffer's BOs.
Future work: besides the mapping's addresses, drm_gem_fb_vmap() should
also return the mappings with the frambuffer data offset added. These
are the addresses were the actual image data is located. A follow-up
set of patches will implement this feature.
Thomas Zimmermann (5):
drm: Define DRM_FORMAT_MAX_PLANES
drm/gem: Provide drm_gem_fb_{vmap,vunmap}()
drm/gem: Clear mapping addresses for unused framebuffer planes
drm/gud: Map framebuffer BOs with drm_gem_fb_vmap()
drm/vkms: Map output framebuffer BOs with drm_gem_fb_vmap()
drivers/gpu/drm/drm_gem_atomic_helper.c | 37 +-------
drivers/gpu/drm/drm_gem_framebuffer_helper.c | 88 ++++++++++++++++++--
drivers/gpu/drm/gud/gud_pipe.c | 11 +--
drivers/gpu/drm/vkms/vkms_composer.c | 2 +-
drivers/gpu/drm/vkms/vkms_drv.h | 6 +-
drivers/gpu/drm/vkms/vkms_writeback.c | 21 +++--
include/drm/drm_fourcc.h | 13 ++-
include/drm/drm_framebuffer.h | 8 +-
include/drm/drm_gem_atomic_helper.h | 3 +-
include/drm/drm_gem_framebuffer_helper.h | 5 ++
10 files changed, 127 insertions(+), 67 deletions(-)
base-commit: 4d00e2309398147acdbfefbe1deb4b0e78868466
--
2.32.0
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES
2021-07-15 18:01 [PATCH 0/5] drm: Provide framebuffer vmap helpers Thomas Zimmermann
@ 2021-07-15 18:01 ` Thomas Zimmermann
2021-07-16 7:30 ` Maxime Ripard
2021-07-18 13:23 ` kernel test robot
2021-07-15 18:01 ` [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap,vunmap}() Thomas Zimmermann
` (3 subsequent siblings)
4 siblings, 2 replies; 20+ messages in thread
From: Thomas Zimmermann @ 2021-07-15 18:01 UTC (permalink / raw)
To: maarten.lankhorst, mripard, airlied, daniel, noralf,
rodrigosiqueiramelo, melissa.srw, hamohammed.sa
Cc: Thomas Zimmermann, dri-devel
DRM uses a magic number of 4 for the maximum number of planes per color
format. Declare this constant via DRM_FORMAT_MAX_PLANES and update the
related code.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/drm_gem_framebuffer_helper.c | 14 ++++++++------
include/drm/drm_fourcc.h | 13 +++++++++----
include/drm/drm_framebuffer.h | 8 ++++----
include/drm/drm_gem_atomic_helper.h | 2 +-
4 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
index e2c68822e05c..975a3df0561e 100644
--- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c
+++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
@@ -48,7 +48,7 @@
struct drm_gem_object *drm_gem_fb_get_obj(struct drm_framebuffer *fb,
unsigned int plane)
{
- if (plane >= 4)
+ if (plane >= ARRAY_SIZE(fb->obj))
return NULL;
return fb->obj[plane];
@@ -62,7 +62,8 @@ drm_gem_fb_init(struct drm_device *dev,
struct drm_gem_object **obj, unsigned int num_planes,
const struct drm_framebuffer_funcs *funcs)
{
- int ret, i;
+ unsigned int i;
+ int ret;
drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
@@ -86,9 +87,9 @@ drm_gem_fb_init(struct drm_device *dev,
*/
void drm_gem_fb_destroy(struct drm_framebuffer *fb)
{
- int i;
+ size_t i;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < ARRAY_SIZE(fb->obj); i++)
drm_gem_object_put(fb->obj[i]);
drm_framebuffer_cleanup(fb);
@@ -145,8 +146,9 @@ int drm_gem_fb_init_with_funcs(struct drm_device *dev,
const struct drm_framebuffer_funcs *funcs)
{
const struct drm_format_info *info;
- struct drm_gem_object *objs[4];
- int ret, i;
+ struct drm_gem_object *objs[DRM_FORMAT_MAX_PLANES];
+ unsigned int i;
+ int ret;
info = drm_get_format_info(dev, mode_cmd);
if (!info) {
diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
index 3b138d4ae67e..22aa64d07c79 100644
--- a/include/drm/drm_fourcc.h
+++ b/include/drm/drm_fourcc.h
@@ -25,6 +25,11 @@
#include <linux/types.h>
#include <uapi/drm/drm_fourcc.h>
+/**
+ * DRM_FORMAT_MAX_PLANES - maximum number of planes a DRM format can have
+ */
+#define DRM_FORMAT_MAX_PLANES 4u
+
/*
* DRM formats are little endian. Define host endian variants for the
* most common formats here, to reduce the #ifdefs needed in drivers.
@@ -78,7 +83,7 @@ struct drm_format_info {
* triplet @char_per_block, @block_w, @block_h for better
* describing the pixel format.
*/
- u8 cpp[4];
+ u8 cpp[DRM_FORMAT_MAX_PLANES];
/**
* @char_per_block:
@@ -104,7 +109,7 @@ struct drm_format_info {
* information from their drm_mode_config.get_format_info hook
* if they want the core to be validating the pitch.
*/
- u8 char_per_block[4];
+ u8 char_per_block[DRM_FORMAT_MAX_PLANES];
};
/**
@@ -113,7 +118,7 @@ struct drm_format_info {
* Block width in pixels, this is intended to be accessed through
* drm_format_info_block_width()
*/
- u8 block_w[4];
+ u8 block_w[DRM_FORMAT_MAX_PLANES];
/**
* @block_h:
@@ -121,7 +126,7 @@ struct drm_format_info {
* Block height in pixels, this is intended to be accessed through
* drm_format_info_block_height()
*/
- u8 block_h[4];
+ u8 block_h[DRM_FORMAT_MAX_PLANES];
/** @hsub: Horizontal chroma subsampling factor */
u8 hsub;
diff --git a/include/drm/drm_framebuffer.h b/include/drm/drm_framebuffer.h
index be658ebbec72..f67c5b7bcb68 100644
--- a/include/drm/drm_framebuffer.h
+++ b/include/drm/drm_framebuffer.h
@@ -27,12 +27,12 @@
#include <linux/list.h>
#include <linux/sched.h>
+#include <drm/drm_fourcc.h>
#include <drm/drm_mode_object.h>
struct drm_clip_rect;
struct drm_device;
struct drm_file;
-struct drm_format_info;
struct drm_framebuffer;
struct drm_gem_object;
@@ -147,7 +147,7 @@ struct drm_framebuffer {
* @pitches: Line stride per buffer. For userspace created object this
* is copied from drm_mode_fb_cmd2.
*/
- unsigned int pitches[4];
+ unsigned int pitches[DRM_FORMAT_MAX_PLANES];
/**
* @offsets: Offset from buffer start to the actual pixel data in bytes,
* per buffer. For userspace created object this is copied from
@@ -165,7 +165,7 @@ struct drm_framebuffer {
* data (even for linear buffers). Specifying an x/y pixel offset is
* instead done through the source rectangle in &struct drm_plane_state.
*/
- unsigned int offsets[4];
+ unsigned int offsets[DRM_FORMAT_MAX_PLANES];
/**
* @modifier: Data layout modifier. This is used to describe
* tiling, or also special layouts (like compression) of auxiliary
@@ -210,7 +210,7 @@ struct drm_framebuffer {
* This is used by the GEM framebuffer helpers, see e.g.
* drm_gem_fb_create().
*/
- struct drm_gem_object *obj[4];
+ struct drm_gem_object *obj[DRM_FORMAT_MAX_PLANES];
};
#define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
diff --git a/include/drm/drm_gem_atomic_helper.h b/include/drm/drm_gem_atomic_helper.h
index d82c23622156..b2b441361051 100644
--- a/include/drm/drm_gem_atomic_helper.h
+++ b/include/drm/drm_gem_atomic_helper.h
@@ -40,7 +40,7 @@ struct drm_shadow_plane_state {
* The memory mappings stored in map should be established in the plane's
* prepare_fb callback and removed in the cleanup_fb callback.
*/
- struct dma_buf_map map[4];
+ struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];
};
/**
--
2.32.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap,vunmap}()
2021-07-15 18:01 [PATCH 0/5] drm: Provide framebuffer vmap helpers Thomas Zimmermann
2021-07-15 18:01 ` [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES Thomas Zimmermann
@ 2021-07-15 18:01 ` Thomas Zimmermann
2021-07-15 22:31 ` [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap, vunmap}() kernel test robot
2021-07-16 0:52 ` [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap, vunmap}() kernel test robot
2021-07-15 18:01 ` [PATCH 3/5] drm/gem: Clear mapping addresses for unused framebuffer planes Thomas Zimmermann
` (2 subsequent siblings)
4 siblings, 2 replies; 20+ messages in thread
From: Thomas Zimmermann @ 2021-07-15 18:01 UTC (permalink / raw)
To: maarten.lankhorst, mripard, airlied, daniel, noralf,
rodrigosiqueiramelo, melissa.srw, hamohammed.sa
Cc: Thomas Zimmermann, dri-devel
Move framebuffer vmap code from shadow-buffered plane state into the new
interfaces drm_gem_fb_vmap() and drm_gem_fb_vunmap(). These functions
provide mappings of a framebuffer's BOs into kernel address space. No
functional changes.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/drm_gem_atomic_helper.c | 37 +----------
drivers/gpu/drm/drm_gem_framebuffer_helper.c | 70 ++++++++++++++++++++
include/drm/drm_gem_atomic_helper.h | 1 +
include/drm/drm_gem_framebuffer_helper.h | 5 ++
4 files changed, 79 insertions(+), 34 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem_atomic_helper.c b/drivers/gpu/drm/drm_gem_atomic_helper.c
index 26af09b959d4..b1cc19e47165 100644
--- a/drivers/gpu/drm/drm_gem_atomic_helper.c
+++ b/drivers/gpu/drm/drm_gem_atomic_helper.c
@@ -330,10 +330,7 @@ int drm_gem_prepare_shadow_fb(struct drm_plane *plane, struct drm_plane_state *p
{
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
struct drm_framebuffer *fb = plane_state->fb;
- struct drm_gem_object *obj;
- struct dma_buf_map map;
int ret;
- size_t i;
if (!fb)
return 0;
@@ -342,27 +339,7 @@ int drm_gem_prepare_shadow_fb(struct drm_plane *plane, struct drm_plane_state *p
if (ret)
return ret;
- for (i = 0; i < ARRAY_SIZE(shadow_plane_state->map); ++i) {
- obj = drm_gem_fb_get_obj(fb, i);
- if (!obj)
- continue;
- ret = drm_gem_vmap(obj, &map);
- if (ret)
- goto err_drm_gem_vunmap;
- shadow_plane_state->map[i] = map;
- }
-
- return 0;
-
-err_drm_gem_vunmap:
- while (i) {
- --i;
- obj = drm_gem_fb_get_obj(fb, i);
- if (!obj)
- continue;
- drm_gem_vunmap(obj, &shadow_plane_state->map[i]);
- }
- return ret;
+ return drm_gem_fb_vmap(fb, shadow_plane_state->map);
}
EXPORT_SYMBOL(drm_gem_prepare_shadow_fb);
@@ -374,25 +351,17 @@ EXPORT_SYMBOL(drm_gem_prepare_shadow_fb);
* This function implements struct &drm_plane_helper_funcs.cleanup_fb.
* This function unmaps all buffer objects of the plane's framebuffer.
*
- * See drm_gem_prepare_shadow_fb() for more inforamtion.
+ * See drm_gem_prepare_shadow_fb() for more information.
*/
void drm_gem_cleanup_shadow_fb(struct drm_plane *plane, struct drm_plane_state *plane_state)
{
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state);
struct drm_framebuffer *fb = plane_state->fb;
- size_t i = ARRAY_SIZE(shadow_plane_state->map);
- struct drm_gem_object *obj;
if (!fb)
return;
- while (i) {
- --i;
- obj = drm_gem_fb_get_obj(fb, i);
- if (!obj)
- continue;
- drm_gem_vunmap(obj, &shadow_plane_state->map[i]);
- }
+ drm_gem_fb_vunmap(fb, shadow_plane_state->map);
}
EXPORT_SYMBOL(drm_gem_cleanup_shadow_fb);
diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
index 975a3df0561e..cc4465100cc2 100644
--- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c
+++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
@@ -15,6 +15,8 @@
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_modeset_helper.h>
+#include "drm_internal.h"
+
#define AFBC_HEADER_SIZE 16
#define AFBC_TH_LAYOUT_ALIGNMENT 8
#define AFBC_HDR_ALIGN 64
@@ -308,6 +310,74 @@ drm_gem_fb_create_with_dirty(struct drm_device *dev, struct drm_file *file,
}
EXPORT_SYMBOL_GPL(drm_gem_fb_create_with_dirty);
+/**
+ * drm_gem_fb_vmap - maps all framebuffer BOs into kernel address space
+ * @fb: the framebuffer
+ * @map: returns the mapping's address for each BO
+ *
+ * This function maps all buffer objects of the given framebuffer into
+ * kernel address space and stores them in struct dma_buf_map. If the
+ * mapping operation fails for one of the BOs, the function unmaps the
+ * already established mappings automatically.
+ *
+ * See drm_gem_fb_vunmap() for unmapping.
+ *
+ * Returns:
+ * 0 on success, or a negative errno code otherwise.
+ */
+int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES])
+{
+ struct drm_gem_object *obj;
+ unsigned int i;
+ int ret;
+
+ for (i = 0; i < DRM_FORMAT_MAX_PLANES; ++i) {
+ obj = drm_gem_fb_get_obj(fb, i);
+ if (!obj)
+ continue;
+ ret = drm_gem_vmap(obj, &map[i]);
+ if (ret)
+ goto err_drm_gem_vunmap;
+ }
+
+ return 0;
+
+err_drm_gem_vunmap:
+ while (i) {
+ --i;
+ obj = drm_gem_fb_get_obj(fb, i);
+ if (!obj)
+ continue;
+ drm_gem_vunmap(obj, &map[i]);
+ }
+ return ret;
+}
+EXPORT_SYMBOL(drm_gem_fb_vmap);
+
+/**
+ * drm_gem_fb_vunmap - unmaps framebuffer BOs from kernel address space
+ * @fb: the framebuffer
+ * @map: mapping addresses as returned by drm_gem_fb_vmap()
+ *
+ * This function unmaps all buffer objects of the given framebuffer.
+ *
+ * See drm_gem_fb_vmap() for more information.
+ */
+void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES])
+{
+ unsigned int i = DRM_FORMAT_MAX_PLANES;
+ struct drm_gem_object *obj;
+
+ while (i) {
+ --i;
+ obj = drm_gem_fb_get_obj(fb, i);
+ if (!obj)
+ continue;
+ drm_gem_vunmap(obj, &map[i]);
+ }
+}
+EXPORT_SYMBOL(drm_gem_fb_vunmap);
+
static __u32 drm_gem_afbc_get_bpp(struct drm_device *dev,
const struct drm_mode_fb_cmd2 *mode_cmd)
{
diff --git a/include/drm/drm_gem_atomic_helper.h b/include/drm/drm_gem_atomic_helper.h
index b2b441361051..f9f8b6f0494a 100644
--- a/include/drm/drm_gem_atomic_helper.h
+++ b/include/drm/drm_gem_atomic_helper.h
@@ -5,6 +5,7 @@
#include <linux/dma-buf-map.h>
+#include <drm/drm_fourcc.h>
#include <drm/drm_plane.h>
struct drm_simple_display_pipe;
diff --git a/include/drm/drm_gem_framebuffer_helper.h b/include/drm/drm_gem_framebuffer_helper.h
index 6bdffc7aa124..485617b54221 100644
--- a/include/drm/drm_gem_framebuffer_helper.h
+++ b/include/drm/drm_gem_framebuffer_helper.h
@@ -1,6 +1,8 @@
#ifndef __DRM_GEM_FB_HELPER_H__
#define __DRM_GEM_FB_HELPER_H__
+#include <linux/dma-buf-map.h>
+
struct drm_afbc_framebuffer;
struct drm_device;
struct drm_fb_helper_surface_size;
@@ -34,6 +36,9 @@ struct drm_framebuffer *
drm_gem_fb_create_with_dirty(struct drm_device *dev, struct drm_file *file,
const struct drm_mode_fb_cmd2 *mode_cmd);
+int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
+void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
+
#define drm_is_afbc(modifier) \
(((modifier) & AFBC_VENDOR_AND_TYPE_MASK) == DRM_FORMAT_MOD_ARM_AFBC(0))
--
2.32.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 3/5] drm/gem: Clear mapping addresses for unused framebuffer planes
2021-07-15 18:01 [PATCH 0/5] drm: Provide framebuffer vmap helpers Thomas Zimmermann
2021-07-15 18:01 ` [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES Thomas Zimmermann
2021-07-15 18:01 ` [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap,vunmap}() Thomas Zimmermann
@ 2021-07-15 18:01 ` Thomas Zimmermann
2021-07-15 18:01 ` [PATCH 4/5] drm/gud: Map framebuffer BOs with drm_gem_fb_vmap() Thomas Zimmermann
2021-07-15 18:01 ` [PATCH 5/5] drm/vkms: Map output " Thomas Zimmermann
4 siblings, 0 replies; 20+ messages in thread
From: Thomas Zimmermann @ 2021-07-15 18:01 UTC (permalink / raw)
To: maarten.lankhorst, mripard, airlied, daniel, noralf,
rodrigosiqueiramelo, melissa.srw, hamohammed.sa
Cc: Thomas Zimmermann, dri-devel
Set the returned mapping address to NULL if a framebuffer plane does
not have a BO associated with it. Likewise, ignore mappings of NULL
during framebuffer unmap operations. Allows users of the functions to
perform unmap operations of certain BOs by themselfes.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/drm_gem_framebuffer_helper.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
index cc4465100cc2..15b0fe3ee7b6 100644
--- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c
+++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
@@ -333,8 +333,10 @@ int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMA
for (i = 0; i < DRM_FORMAT_MAX_PLANES; ++i) {
obj = drm_gem_fb_get_obj(fb, i);
- if (!obj)
+ if (!obj) {
+ dma_buf_map_clear(&map[i]);
continue;
+ }
ret = drm_gem_vmap(obj, &map[i]);
if (ret)
goto err_drm_gem_vunmap;
@@ -373,6 +375,8 @@ void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FO
obj = drm_gem_fb_get_obj(fb, i);
if (!obj)
continue;
+ if (dma_buf_map_is_null(&map[i]))
+ continue;
drm_gem_vunmap(obj, &map[i]);
}
}
--
2.32.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 4/5] drm/gud: Map framebuffer BOs with drm_gem_fb_vmap()
2021-07-15 18:01 [PATCH 0/5] drm: Provide framebuffer vmap helpers Thomas Zimmermann
` (2 preceding siblings ...)
2021-07-15 18:01 ` [PATCH 3/5] drm/gem: Clear mapping addresses for unused framebuffer planes Thomas Zimmermann
@ 2021-07-15 18:01 ` Thomas Zimmermann
2021-07-22 11:49 ` Noralf Trønnes
2021-07-15 18:01 ` [PATCH 5/5] drm/vkms: Map output " Thomas Zimmermann
4 siblings, 1 reply; 20+ messages in thread
From: Thomas Zimmermann @ 2021-07-15 18:01 UTC (permalink / raw)
To: maarten.lankhorst, mripard, airlied, daniel, noralf,
rodrigosiqueiramelo, melissa.srw, hamohammed.sa
Cc: Thomas Zimmermann, dri-devel
Abstract the framebuffer details by mapping its BOs with a call
to drm_gem_fb_vmap(). Unmap with drm_gem_fb_vunmap().
The call to drm_gem_fb_vmap() ensures that all BOs are mapped
correctly. Gud still only supports single-plane formats.
No functional changes.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/gud/gud_pipe.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c
index 8f56bf618ac2..8243c8682366 100644
--- a/drivers/gpu/drm/gud/gud_pipe.c
+++ b/drivers/gpu/drm/gud/gud_pipe.c
@@ -15,7 +15,8 @@
#include <drm/drm_format_helper.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
-#include <drm/drm_gem_shmem_helper.h>
+#include <drm/drm_gem.h>
+#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_print.h>
#include <drm/drm_rect.h>
#include <drm/drm_simple_kms_helper.h>
@@ -152,7 +153,7 @@ static int gud_prep_flush(struct gud_device *gdrm, struct drm_framebuffer *fb,
{
struct dma_buf_attachment *import_attach = fb->obj[0]->import_attach;
u8 compression = gdrm->compression;
- struct dma_buf_map map;
+ struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];
void *vaddr, *buf;
size_t pitch, len;
int ret = 0;
@@ -162,11 +163,11 @@ static int gud_prep_flush(struct gud_device *gdrm, struct drm_framebuffer *fb,
if (len > gdrm->bulk_len)
return -E2BIG;
- ret = drm_gem_shmem_vmap(fb->obj[0], &map);
+ ret = drm_gem_fb_vmap(fb, map);
if (ret)
return ret;
- vaddr = map.vaddr + fb->offsets[0];
+ vaddr = map[0].vaddr + fb->offsets[0];
if (import_attach) {
ret = dma_buf_begin_cpu_access(import_attach->dmabuf, DMA_FROM_DEVICE);
@@ -228,7 +229,7 @@ static int gud_prep_flush(struct gud_device *gdrm, struct drm_framebuffer *fb,
if (import_attach)
dma_buf_end_cpu_access(import_attach->dmabuf, DMA_FROM_DEVICE);
vunmap:
- drm_gem_shmem_vunmap(fb->obj[0], &map);
+ drm_gem_fb_vunmap(fb, map);
return ret;
}
--
2.32.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 5/5] drm/vkms: Map output framebuffer BOs with drm_gem_fb_vmap()
2021-07-15 18:01 [PATCH 0/5] drm: Provide framebuffer vmap helpers Thomas Zimmermann
` (3 preceding siblings ...)
2021-07-15 18:01 ` [PATCH 4/5] drm/gud: Map framebuffer BOs with drm_gem_fb_vmap() Thomas Zimmermann
@ 2021-07-15 18:01 ` Thomas Zimmermann
2021-07-16 2:28 ` kernel test robot
4 siblings, 1 reply; 20+ messages in thread
From: Thomas Zimmermann @ 2021-07-15 18:01 UTC (permalink / raw)
To: maarten.lankhorst, mripard, airlied, daniel, noralf,
rodrigosiqueiramelo, melissa.srw, hamohammed.sa
Cc: Thomas Zimmermann, dri-devel
Abstract the framebuffer details by mappings its BOs with a call
to drm_gem_fb_vmap(). Unmap with drm_gem_fb_vunamp().
Before, the output address with stored as raw pointer in the priv
field of struct drm_writeback_job. Introduce the new type
struct vkms_writeback_job, which holds the output mappings addresses
while the writeback job is active.
The patchset also cleans up some internal casting an setup of the
output addresses. No functional changes.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/vkms/vkms_composer.c | 2 +-
drivers/gpu/drm/vkms/vkms_drv.h | 6 +++++-
drivers/gpu/drm/vkms/vkms_writeback.c | 21 ++++++++++-----------
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index ead8fff81f30..49f109c3a2b3 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -257,7 +257,7 @@ void vkms_composer_worker(struct work_struct *work)
return;
if (wb_pending)
- vaddr_out = crtc_state->active_writeback;
+ vaddr_out = crtc_state->active_writeback->map[0].vaddr;
ret = compose_active_planes(&vaddr_out, primary_composer,
crtc_state);
diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
index 8c731b6dcba7..8bc9e3f52e1f 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.h
+++ b/drivers/gpu/drm/vkms/vkms_drv.h
@@ -20,6 +20,10 @@
#define XRES_MAX 8192
#define YRES_MAX 8192
+struct vkms_writeback_job {
+ struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];
+};
+
struct vkms_composer {
struct drm_framebuffer fb;
struct drm_rect src, dst;
@@ -57,7 +61,7 @@ struct vkms_crtc_state {
int num_active_planes;
/* stack of active planes for crc computation, should be in z order */
struct vkms_plane_state **active_planes;
- void *active_writeback;
+ struct vkms_writeback_job *active_writeback;
/* below four are protected by vkms_output.composer_lock */
bool crc_pending;
diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c
index 0935686475a0..765bb85ba76c 100644
--- a/drivers/gpu/drm/vkms/vkms_writeback.c
+++ b/drivers/gpu/drm/vkms/vkms_writeback.c
@@ -65,21 +65,23 @@ static int vkms_wb_connector_get_modes(struct drm_connector *connector)
static int vkms_wb_prepare_job(struct drm_writeback_connector *wb_connector,
struct drm_writeback_job *job)
{
- struct drm_gem_object *gem_obj;
- struct dma_buf_map map;
+ struct vkms_writeback_job *vkmsjob;
int ret;
if (!job->fb)
return 0;
- gem_obj = drm_gem_fb_get_obj(job->fb, 0);
- ret = drm_gem_shmem_vmap(gem_obj, &map);
+ vkmsjob = kzalloc(sizeof(*vkmsjob), GFP_KERNEL);
+ if (!vkmsjob)
+ return -ENOMEM;
+
+ ret = drm_gem_fb_vmap(job->fb, vkmsjob->map);
if (ret) {
DRM_ERROR("vmap failed: %d\n", ret);
return ret;
}
- job->priv = map.vaddr;
+ job->priv = vkmsjob;
return 0;
}
@@ -87,18 +89,15 @@ static int vkms_wb_prepare_job(struct drm_writeback_connector *wb_connector,
static void vkms_wb_cleanup_job(struct drm_writeback_connector *connector,
struct drm_writeback_job *job)
{
- struct drm_gem_object *gem_obj;
+ struct vkms_writeback_job *vkmsjob = job->priv;
struct vkms_device *vkmsdev;
- struct dma_buf_map map;
if (!job->fb)
return;
- gem_obj = drm_gem_fb_get_obj(job->fb, 0);
- dma_buf_map_set_vaddr(&map, job->priv);
- drm_gem_shmem_vunmap(gem_obj, &map);
+ drm_gem_fb_vunmap(job->fb, vkmsjob->map);
- vkmsdev = drm_device_to_vkms_device(gem_obj->dev);
+ vkmsdev = drm_device_to_vkms_device(job->fb->dev);
vkms_set_composer(&vkmsdev->output, false);
}
--
2.32.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap,vunmap}()
2021-07-15 18:01 ` [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap,vunmap}() Thomas Zimmermann
@ 2021-07-15 22:31 ` kernel test robot
2021-07-16 0:52 ` [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap, vunmap}() kernel test robot
1 sibling, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-07-15 22:31 UTC (permalink / raw)
To: Thomas Zimmermann, maarten.lankhorst, mripard, airlied, daniel,
noralf, rodrigosiqueiramelo, melissa.srw, hamohammed.sa
Cc: kbuild-all, dri-devel, Thomas Zimmermann
[-- Attachment #1: Type: text/plain, Size: 3670 bytes --]
Hi Thomas,
I love your patch! Yet something to improve:
[auto build test ERROR on 4d00e2309398147acdbfefbe1deb4b0e78868466]
url: https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
base: 4d00e2309398147acdbfefbe1deb4b0e78868466
config: nios2-randconfig-s032-20210715 (attached as .config)
compiler: nios2-linux-gcc (GCC) 10.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-341-g8af24329-dirty
# https://github.com/0day-ci/linux/commit/8a0708f4cf232e7fbc4eb6f58cf782200be8912e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
git checkout 8a0708f4cf232e7fbc4eb6f58cf782200be8912e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=nios2 SHELL=/bin/bash drivers/gpu/drm/arm/display/komeda/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c:11:
>> include/drm/drm_gem_framebuffer_helper.h:39:72: error: 'DRM_FORMAT_MAX_PLANES' undeclared here (not in a function)
39 | int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
| ^~~~~~~~~~~~~~~~~~~~~
include/drm/drm_gem_framebuffer_helper.h:40:75: error: 'DRM_FORMAT_MAX_PLANES' undeclared here (not in a function)
40 | void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
| ^~~~~~~~~~~~~~~~~~~~~
vim +/DRM_FORMAT_MAX_PLANES +39 include/drm/drm_gem_framebuffer_helper.h
16
17 struct drm_gem_object *drm_gem_fb_get_obj(struct drm_framebuffer *fb,
18 unsigned int plane);
19 void drm_gem_fb_destroy(struct drm_framebuffer *fb);
20 int drm_gem_fb_create_handle(struct drm_framebuffer *fb, struct drm_file *file,
21 unsigned int *handle);
22
23 int drm_gem_fb_init_with_funcs(struct drm_device *dev,
24 struct drm_framebuffer *fb,
25 struct drm_file *file,
26 const struct drm_mode_fb_cmd2 *mode_cmd,
27 const struct drm_framebuffer_funcs *funcs);
28 struct drm_framebuffer *
29 drm_gem_fb_create_with_funcs(struct drm_device *dev, struct drm_file *file,
30 const struct drm_mode_fb_cmd2 *mode_cmd,
31 const struct drm_framebuffer_funcs *funcs);
32 struct drm_framebuffer *
33 drm_gem_fb_create(struct drm_device *dev, struct drm_file *file,
34 const struct drm_mode_fb_cmd2 *mode_cmd);
35 struct drm_framebuffer *
36 drm_gem_fb_create_with_dirty(struct drm_device *dev, struct drm_file *file,
37 const struct drm_mode_fb_cmd2 *mode_cmd);
38
> 39 int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
40 void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
41
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30515 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap, vunmap}()
@ 2021-07-15 22:31 ` kernel test robot
0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-07-15 22:31 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 3740 bytes --]
Hi Thomas,
I love your patch! Yet something to improve:
[auto build test ERROR on 4d00e2309398147acdbfefbe1deb4b0e78868466]
url: https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
base: 4d00e2309398147acdbfefbe1deb4b0e78868466
config: nios2-randconfig-s032-20210715 (attached as .config)
compiler: nios2-linux-gcc (GCC) 10.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-341-g8af24329-dirty
# https://github.com/0day-ci/linux/commit/8a0708f4cf232e7fbc4eb6f58cf782200be8912e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
git checkout 8a0708f4cf232e7fbc4eb6f58cf782200be8912e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=nios2 SHELL=/bin/bash drivers/gpu/drm/arm/display/komeda/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c:11:
>> include/drm/drm_gem_framebuffer_helper.h:39:72: error: 'DRM_FORMAT_MAX_PLANES' undeclared here (not in a function)
39 | int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
| ^~~~~~~~~~~~~~~~~~~~~
include/drm/drm_gem_framebuffer_helper.h:40:75: error: 'DRM_FORMAT_MAX_PLANES' undeclared here (not in a function)
40 | void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
| ^~~~~~~~~~~~~~~~~~~~~
vim +/DRM_FORMAT_MAX_PLANES +39 include/drm/drm_gem_framebuffer_helper.h
16
17 struct drm_gem_object *drm_gem_fb_get_obj(struct drm_framebuffer *fb,
18 unsigned int plane);
19 void drm_gem_fb_destroy(struct drm_framebuffer *fb);
20 int drm_gem_fb_create_handle(struct drm_framebuffer *fb, struct drm_file *file,
21 unsigned int *handle);
22
23 int drm_gem_fb_init_with_funcs(struct drm_device *dev,
24 struct drm_framebuffer *fb,
25 struct drm_file *file,
26 const struct drm_mode_fb_cmd2 *mode_cmd,
27 const struct drm_framebuffer_funcs *funcs);
28 struct drm_framebuffer *
29 drm_gem_fb_create_with_funcs(struct drm_device *dev, struct drm_file *file,
30 const struct drm_mode_fb_cmd2 *mode_cmd,
31 const struct drm_framebuffer_funcs *funcs);
32 struct drm_framebuffer *
33 drm_gem_fb_create(struct drm_device *dev, struct drm_file *file,
34 const struct drm_mode_fb_cmd2 *mode_cmd);
35 struct drm_framebuffer *
36 drm_gem_fb_create_with_dirty(struct drm_device *dev, struct drm_file *file,
37 const struct drm_mode_fb_cmd2 *mode_cmd);
38
> 39 int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
40 void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
41
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 30515 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap,vunmap}()
2021-07-15 18:01 ` [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap,vunmap}() Thomas Zimmermann
@ 2021-07-16 0:52 ` kernel test robot
2021-07-16 0:52 ` [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap, vunmap}() kernel test robot
1 sibling, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-07-16 0:52 UTC (permalink / raw)
To: Thomas Zimmermann, maarten.lankhorst, mripard, airlied, daniel,
noralf, rodrigosiqueiramelo, melissa.srw, hamohammed.sa
Cc: clang-built-linux, kbuild-all, dri-devel, Thomas Zimmermann
[-- Attachment #1: Type: text/plain, Size: 3681 bytes --]
Hi Thomas,
I love your patch! Yet something to improve:
[auto build test ERROR on 4d00e2309398147acdbfefbe1deb4b0e78868466]
url: https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
base: 4d00e2309398147acdbfefbe1deb4b0e78868466
config: arm64-randconfig-r035-20210715 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 0e49c54a8cbd3e779e5526a5888c683c01cc3c50)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/8a0708f4cf232e7fbc4eb6f58cf782200be8912e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
git checkout 8a0708f4cf232e7fbc4eb6f58cf782200be8912e
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/gpu/drm/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c:11:
>> include/drm/drm_gem_framebuffer_helper.h:39:72: error: use of undeclared identifier 'DRM_FORMAT_MAX_PLANES'
int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
^
include/drm/drm_gem_framebuffer_helper.h:40:75: error: use of undeclared identifier 'DRM_FORMAT_MAX_PLANES'
void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
^
2 errors generated.
vim +/DRM_FORMAT_MAX_PLANES +39 include/drm/drm_gem_framebuffer_helper.h
16
17 struct drm_gem_object *drm_gem_fb_get_obj(struct drm_framebuffer *fb,
18 unsigned int plane);
19 void drm_gem_fb_destroy(struct drm_framebuffer *fb);
20 int drm_gem_fb_create_handle(struct drm_framebuffer *fb, struct drm_file *file,
21 unsigned int *handle);
22
23 int drm_gem_fb_init_with_funcs(struct drm_device *dev,
24 struct drm_framebuffer *fb,
25 struct drm_file *file,
26 const struct drm_mode_fb_cmd2 *mode_cmd,
27 const struct drm_framebuffer_funcs *funcs);
28 struct drm_framebuffer *
29 drm_gem_fb_create_with_funcs(struct drm_device *dev, struct drm_file *file,
30 const struct drm_mode_fb_cmd2 *mode_cmd,
31 const struct drm_framebuffer_funcs *funcs);
32 struct drm_framebuffer *
33 drm_gem_fb_create(struct drm_device *dev, struct drm_file *file,
34 const struct drm_mode_fb_cmd2 *mode_cmd);
35 struct drm_framebuffer *
36 drm_gem_fb_create_with_dirty(struct drm_device *dev, struct drm_file *file,
37 const struct drm_mode_fb_cmd2 *mode_cmd);
38
> 39 int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
40 void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
41
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34148 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap, vunmap}()
@ 2021-07-16 0:52 ` kernel test robot
0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-07-16 0:52 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 3753 bytes --]
Hi Thomas,
I love your patch! Yet something to improve:
[auto build test ERROR on 4d00e2309398147acdbfefbe1deb4b0e78868466]
url: https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
base: 4d00e2309398147acdbfefbe1deb4b0e78868466
config: arm64-randconfig-r035-20210715 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 0e49c54a8cbd3e779e5526a5888c683c01cc3c50)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/8a0708f4cf232e7fbc4eb6f58cf782200be8912e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
git checkout 8a0708f4cf232e7fbc4eb6f58cf782200be8912e
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/gpu/drm/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c:11:
>> include/drm/drm_gem_framebuffer_helper.h:39:72: error: use of undeclared identifier 'DRM_FORMAT_MAX_PLANES'
int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
^
include/drm/drm_gem_framebuffer_helper.h:40:75: error: use of undeclared identifier 'DRM_FORMAT_MAX_PLANES'
void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
^
2 errors generated.
vim +/DRM_FORMAT_MAX_PLANES +39 include/drm/drm_gem_framebuffer_helper.h
16
17 struct drm_gem_object *drm_gem_fb_get_obj(struct drm_framebuffer *fb,
18 unsigned int plane);
19 void drm_gem_fb_destroy(struct drm_framebuffer *fb);
20 int drm_gem_fb_create_handle(struct drm_framebuffer *fb, struct drm_file *file,
21 unsigned int *handle);
22
23 int drm_gem_fb_init_with_funcs(struct drm_device *dev,
24 struct drm_framebuffer *fb,
25 struct drm_file *file,
26 const struct drm_mode_fb_cmd2 *mode_cmd,
27 const struct drm_framebuffer_funcs *funcs);
28 struct drm_framebuffer *
29 drm_gem_fb_create_with_funcs(struct drm_device *dev, struct drm_file *file,
30 const struct drm_mode_fb_cmd2 *mode_cmd,
31 const struct drm_framebuffer_funcs *funcs);
32 struct drm_framebuffer *
33 drm_gem_fb_create(struct drm_device *dev, struct drm_file *file,
34 const struct drm_mode_fb_cmd2 *mode_cmd);
35 struct drm_framebuffer *
36 drm_gem_fb_create_with_dirty(struct drm_device *dev, struct drm_file *file,
37 const struct drm_mode_fb_cmd2 *mode_cmd);
38
> 39 int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
40 void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct dma_buf_map map[DRM_FORMAT_MAX_PLANES]);
41
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34148 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 5/5] drm/vkms: Map output framebuffer BOs with drm_gem_fb_vmap()
2021-07-15 18:01 ` [PATCH 5/5] drm/vkms: Map output " Thomas Zimmermann
@ 2021-07-16 2:28 ` kernel test robot
0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-07-16 2:28 UTC (permalink / raw)
To: Thomas Zimmermann, maarten.lankhorst, mripard, airlied, daniel,
noralf, rodrigosiqueiramelo, melissa.srw, hamohammed.sa
Cc: kbuild-all, dri-devel, Thomas Zimmermann
[-- Attachment #1: Type: text/plain, Size: 1765 bytes --]
Hi Thomas,
I love your patch! Yet something to improve:
[auto build test ERROR on 4d00e2309398147acdbfefbe1deb4b0e78868466]
url: https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
base: 4d00e2309398147acdbfefbe1deb4b0e78868466
config: arc-allyesconfig (attached as .config)
compiler: arceb-elf-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/2369821ddd70d806874995047363a25d43229cfe
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
git checkout 2369821ddd70d806874995047363a25d43229cfe
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from drivers/gpu/drm/vkms/vkms_output.c:3:
>> drivers/gpu/drm/vkms/vkms_drv.h:23:21: error: array type has incomplete element type 'struct dma_buf_map'
23 | struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];
| ^~~
vim +23 drivers/gpu/drm/vkms/vkms_drv.h
21
22 struct vkms_writeback_job {
> 23 struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];
24 };
25
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 68205 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 5/5] drm/vkms: Map output framebuffer BOs with drm_gem_fb_vmap()
@ 2021-07-16 2:28 ` kernel test robot
0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-07-16 2:28 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 1810 bytes --]
Hi Thomas,
I love your patch! Yet something to improve:
[auto build test ERROR on 4d00e2309398147acdbfefbe1deb4b0e78868466]
url: https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
base: 4d00e2309398147acdbfefbe1deb4b0e78868466
config: arc-allyesconfig (attached as .config)
compiler: arceb-elf-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/2369821ddd70d806874995047363a25d43229cfe
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
git checkout 2369821ddd70d806874995047363a25d43229cfe
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from drivers/gpu/drm/vkms/vkms_output.c:3:
>> drivers/gpu/drm/vkms/vkms_drv.h:23:21: error: array type has incomplete element type 'struct dma_buf_map'
23 | struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];
| ^~~
vim +23 drivers/gpu/drm/vkms/vkms_drv.h
21
22 struct vkms_writeback_job {
> 23 struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];
24 };
25
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 68205 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES
2021-07-15 18:01 ` [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES Thomas Zimmermann
@ 2021-07-16 7:30 ` Maxime Ripard
2021-07-16 8:50 ` Thomas Zimmermann
2021-07-18 13:23 ` kernel test robot
1 sibling, 1 reply; 20+ messages in thread
From: Maxime Ripard @ 2021-07-16 7:30 UTC (permalink / raw)
To: Thomas Zimmermann
Cc: hamohammed.sa, rodrigosiqueiramelo, airlied, dri-devel,
melissa.srw, noralf
Hi,
On Thu, Jul 15, 2021 at 08:01:29PM +0200, Thomas Zimmermann wrote:
> DRM uses a magic number of 4 for the maximum number of planes per color
> format. Declare this constant via DRM_FORMAT_MAX_PLANES and update the
> related code.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
> drivers/gpu/drm/drm_gem_framebuffer_helper.c | 14 ++++++++------
> include/drm/drm_fourcc.h | 13 +++++++++----
> include/drm/drm_framebuffer.h | 8 ++++----
> include/drm/drm_gem_atomic_helper.h | 2 +-
> 4 files changed, 22 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
> index e2c68822e05c..975a3df0561e 100644
> --- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c
> +++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
> @@ -48,7 +48,7 @@
> struct drm_gem_object *drm_gem_fb_get_obj(struct drm_framebuffer *fb,
> unsigned int plane)
> {
> - if (plane >= 4)
> + if (plane >= ARRAY_SIZE(fb->obj))
> return NULL;
This doesn't look related to what's mentionned in the commit log though?
> return fb->obj[plane];
> @@ -62,7 +62,8 @@ drm_gem_fb_init(struct drm_device *dev,
> struct drm_gem_object **obj, unsigned int num_planes,
> const struct drm_framebuffer_funcs *funcs)
> {
> - int ret, i;
> + unsigned int i;
> + int ret;
>
> drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
>
> @@ -86,9 +87,9 @@ drm_gem_fb_init(struct drm_device *dev,
> */
> void drm_gem_fb_destroy(struct drm_framebuffer *fb)
> {
> - int i;
> + size_t i;
>
> - for (i = 0; i < 4; i++)
> + for (i = 0; i < ARRAY_SIZE(fb->obj); i++)
> drm_gem_object_put(fb->obj[i]);
Ditto
Both these changes look fine though, but I guess you should just mention it
Maxime
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES
2021-07-16 7:30 ` Maxime Ripard
@ 2021-07-16 8:50 ` Thomas Zimmermann
0 siblings, 0 replies; 20+ messages in thread
From: Thomas Zimmermann @ 2021-07-16 8:50 UTC (permalink / raw)
To: Maxime Ripard
Cc: hamohammed.sa, rodrigosiqueiramelo, airlied, dri-devel,
melissa.srw, noralf
[-- Attachment #1.1: Type: text/plain, Size: 2366 bytes --]
Hi
Am 16.07.21 um 09:30 schrieb Maxime Ripard:
> Hi,
>
> On Thu, Jul 15, 2021 at 08:01:29PM +0200, Thomas Zimmermann wrote:
>> DRM uses a magic number of 4 for the maximum number of planes per color
>> format. Declare this constant via DRM_FORMAT_MAX_PLANES and update the
>> related code.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> ---
>> drivers/gpu/drm/drm_gem_framebuffer_helper.c | 14 ++++++++------
>> include/drm/drm_fourcc.h | 13 +++++++++----
>> include/drm/drm_framebuffer.h | 8 ++++----
>> include/drm/drm_gem_atomic_helper.h | 2 +-
>> 4 files changed, 22 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
>> index e2c68822e05c..975a3df0561e 100644
>> --- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c
>> +++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
>> @@ -48,7 +48,7 @@
>> struct drm_gem_object *drm_gem_fb_get_obj(struct drm_framebuffer *fb,
>> unsigned int plane)
>> {
>> - if (plane >= 4)
>> + if (plane >= ARRAY_SIZE(fb->obj))
>> return NULL;
>
> This doesn't look related to what's mentionned in the commit log though?
>
>> return fb->obj[plane];
>> @@ -62,7 +62,8 @@ drm_gem_fb_init(struct drm_device *dev,
>> struct drm_gem_object **obj, unsigned int num_planes,
>> const struct drm_framebuffer_funcs *funcs)
>> {
>> - int ret, i;
>> + unsigned int i;
>> + int ret;
>>
>> drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
>>
>> @@ -86,9 +87,9 @@ drm_gem_fb_init(struct drm_device *dev,
>> */
>> void drm_gem_fb_destroy(struct drm_framebuffer *fb)
>> {
>> - int i;
>> + size_t i;
>>
>> - for (i = 0; i < 4; i++)
>> + for (i = 0; i < ARRAY_SIZE(fb->obj); i++)
>> drm_gem_object_put(fb->obj[i]);
>
> Ditto
>
> Both these changes look fine though, but I guess you should just mention it
Well, good point. I thought it would be cleaner than using
FORMAT_MAX_PLANES here. I'll leave a note in the commit log.
Best regards
Thomas
>
> Maxime
>
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES
2021-07-15 18:01 ` [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES Thomas Zimmermann
@ 2021-07-18 13:23 ` kernel test robot
2021-07-18 13:23 ` kernel test robot
1 sibling, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-07-18 13:23 UTC (permalink / raw)
To: Thomas Zimmermann, maarten.lankhorst, mripard, airlied, daniel,
noralf, rodrigosiqueiramelo, melissa.srw, hamohammed.sa
Cc: kbuild-all, dri-devel, Thomas Zimmermann
[-- Attachment #1: Type: text/plain, Size: 7733 bytes --]
Hi Thomas,
I love your patch! Perhaps something to improve:
[auto build test WARNING on 4d00e2309398147acdbfefbe1deb4b0e78868466]
url: https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
base: 4d00e2309398147acdbfefbe1deb4b0e78868466
config: x86_64-randconfig-m001-20210718 (attached as .config)
compiler: gcc-10 (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
smatch warnings:
drivers/gpu/drm/drm_gem_framebuffer_helper.c:192 drm_gem_fb_init_with_funcs() warn: always true condition '(i >= 0) => (0-u32max >= 0)'
drivers/gpu/drm/drm_gem_framebuffer_helper.c:192 drm_gem_fb_init_with_funcs() warn: always true condition '(i >= 0) => (0-u32max >= 0)'
vim +192 drivers/gpu/drm/drm_gem_framebuffer_helper.c
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 119
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 120 /**
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 121 * drm_gem_fb_init_with_funcs() - Helper function for implementing
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 122 * &drm_mode_config_funcs.fb_create
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 123 * callback in cases when the driver
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 124 * allocates a subclass of
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 125 * struct drm_framebuffer
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 126 * @dev: DRM device
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 127 * @fb: framebuffer object
2e187b2099034a Noralf Trønnes 2017-09-22 128 * @file: DRM file that holds the GEM handle(s) backing the framebuffer
2e187b2099034a Noralf Trønnes 2017-09-22 129 * @mode_cmd: Metadata from the userspace framebuffer creation request
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 130 * @funcs: vtable to be used for the new framebuffer object
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 131 *
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 132 * This function can be used to set &drm_framebuffer_funcs for drivers that need
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 133 * custom framebuffer callbacks. Use drm_gem_fb_create() if you don't need to
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 134 * change &drm_framebuffer_funcs. The function does buffer size validation.
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 135 * The buffer size validation is for a general case, though, so users should
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 136 * pay attention to the checks being appropriate for them or, at least,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 137 * non-conflicting.
2e187b2099034a Noralf Trønnes 2017-09-22 138 *
2e187b2099034a Noralf Trønnes 2017-09-22 139 * Returns:
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 140 * Zero or a negative error code.
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 141 */
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 142 int drm_gem_fb_init_with_funcs(struct drm_device *dev,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 143 struct drm_framebuffer *fb,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 144 struct drm_file *file,
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 145 const struct drm_mode_fb_cmd2 *mode_cmd,
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 146 const struct drm_framebuffer_funcs *funcs)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 147 {
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 148 const struct drm_format_info *info;
6065e7036e073e Thomas Zimmermann 2021-07-15 149 struct drm_gem_object *objs[DRM_FORMAT_MAX_PLANES];
6065e7036e073e Thomas Zimmermann 2021-07-15 150 unsigned int i;
6065e7036e073e Thomas Zimmermann 2021-07-15 151 int ret;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 152
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 153 info = drm_get_format_info(dev, mode_cmd);
f7f525030854b1 Simon Ser 2021-05-03 154 if (!info) {
f7f525030854b1 Simon Ser 2021-05-03 155 drm_dbg_kms(dev, "Failed to get FB format info\n");
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 156 return -EINVAL;
f7f525030854b1 Simon Ser 2021-05-03 157 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 158
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 159 for (i = 0; i < info->num_planes; i++) {
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 160 unsigned int width = mode_cmd->width / (i ? info->hsub : 1);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 161 unsigned int height = mode_cmd->height / (i ? info->vsub : 1);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 162 unsigned int min_size;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 163
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 164 objs[i] = drm_gem_object_lookup(file, mode_cmd->handles[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 165 if (!objs[i]) {
24f03be4aa7922 Jani Nikula 2019-12-10 166 drm_dbg_kms(dev, "Failed to lookup GEM object\n");
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 167 ret = -ENOENT;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 168 goto err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 169 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 170
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 171 min_size = (height - 1) * mode_cmd->pitches[i]
042bf753842ddb Alexandru Gheorghe 2018-11-01 172 + drm_format_info_min_pitch(info, i, width)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 173 + mode_cmd->offsets[i];
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 174
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 175 if (objs[i]->size < min_size) {
f7f525030854b1 Simon Ser 2021-05-03 176 drm_dbg_kms(dev,
f7f525030854b1 Simon Ser 2021-05-03 177 "GEM object size (%zu) smaller than minimum size (%u) for plane %d\n",
f7f525030854b1 Simon Ser 2021-05-03 178 objs[i]->size, min_size, i);
be6ee102341bc4 Emil Velikov 2020-05-15 179 drm_gem_object_put(objs[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 180 ret = -EINVAL;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 181 goto err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 182 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 183 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 184
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 185 ret = drm_gem_fb_init(dev, fb, mode_cmd, objs, i, funcs);
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 186 if (ret)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 187 goto err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 188
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 189 return 0;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 190
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 191 err_gem_object_put:
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 @192 for (i--; i >= 0; i--)
be6ee102341bc4 Emil Velikov 2020-05-15 193 drm_gem_object_put(objs[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 194
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 195 return ret;
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 196 }
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 197 EXPORT_SYMBOL_GPL(drm_gem_fb_init_with_funcs);
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 198
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 39958 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES
@ 2021-07-18 13:23 ` kernel test robot
0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-07-18 13:23 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 7886 bytes --]
Hi Thomas,
I love your patch! Perhaps something to improve:
[auto build test WARNING on 4d00e2309398147acdbfefbe1deb4b0e78868466]
url: https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
base: 4d00e2309398147acdbfefbe1deb4b0e78868466
config: x86_64-randconfig-m001-20210718 (attached as .config)
compiler: gcc-10 (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
smatch warnings:
drivers/gpu/drm/drm_gem_framebuffer_helper.c:192 drm_gem_fb_init_with_funcs() warn: always true condition '(i >= 0) => (0-u32max >= 0)'
drivers/gpu/drm/drm_gem_framebuffer_helper.c:192 drm_gem_fb_init_with_funcs() warn: always true condition '(i >= 0) => (0-u32max >= 0)'
vim +192 drivers/gpu/drm/drm_gem_framebuffer_helper.c
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 119
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 120 /**
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 121 * drm_gem_fb_init_with_funcs() - Helper function for implementing
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 122 * &drm_mode_config_funcs.fb_create
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 123 * callback in cases when the driver
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 124 * allocates a subclass of
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 125 * struct drm_framebuffer
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 126 * @dev: DRM device
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 127 * @fb: framebuffer object
2e187b2099034a Noralf Trønnes 2017-09-22 128 * @file: DRM file that holds the GEM handle(s) backing the framebuffer
2e187b2099034a Noralf Trønnes 2017-09-22 129 * @mode_cmd: Metadata from the userspace framebuffer creation request
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 130 * @funcs: vtable to be used for the new framebuffer object
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 131 *
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 132 * This function can be used to set &drm_framebuffer_funcs for drivers that need
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 133 * custom framebuffer callbacks. Use drm_gem_fb_create() if you don't need to
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 134 * change &drm_framebuffer_funcs. The function does buffer size validation.
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 135 * The buffer size validation is for a general case, though, so users should
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 136 * pay attention to the checks being appropriate for them or, at least,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 137 * non-conflicting.
2e187b2099034a Noralf Trønnes 2017-09-22 138 *
2e187b2099034a Noralf Trønnes 2017-09-22 139 * Returns:
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 140 * Zero or a negative error code.
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 141 */
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 142 int drm_gem_fb_init_with_funcs(struct drm_device *dev,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 143 struct drm_framebuffer *fb,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 144 struct drm_file *file,
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 145 const struct drm_mode_fb_cmd2 *mode_cmd,
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 146 const struct drm_framebuffer_funcs *funcs)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 147 {
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 148 const struct drm_format_info *info;
6065e7036e073e Thomas Zimmermann 2021-07-15 149 struct drm_gem_object *objs[DRM_FORMAT_MAX_PLANES];
6065e7036e073e Thomas Zimmermann 2021-07-15 150 unsigned int i;
6065e7036e073e Thomas Zimmermann 2021-07-15 151 int ret;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 152
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 153 info = drm_get_format_info(dev, mode_cmd);
f7f525030854b1 Simon Ser 2021-05-03 154 if (!info) {
f7f525030854b1 Simon Ser 2021-05-03 155 drm_dbg_kms(dev, "Failed to get FB format info\n");
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 156 return -EINVAL;
f7f525030854b1 Simon Ser 2021-05-03 157 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 158
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 159 for (i = 0; i < info->num_planes; i++) {
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 160 unsigned int width = mode_cmd->width / (i ? info->hsub : 1);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 161 unsigned int height = mode_cmd->height / (i ? info->vsub : 1);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 162 unsigned int min_size;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 163
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 164 objs[i] = drm_gem_object_lookup(file, mode_cmd->handles[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 165 if (!objs[i]) {
24f03be4aa7922 Jani Nikula 2019-12-10 166 drm_dbg_kms(dev, "Failed to lookup GEM object\n");
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 167 ret = -ENOENT;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 168 goto err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 169 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 170
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 171 min_size = (height - 1) * mode_cmd->pitches[i]
042bf753842ddb Alexandru Gheorghe 2018-11-01 172 + drm_format_info_min_pitch(info, i, width)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 173 + mode_cmd->offsets[i];
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 174
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 175 if (objs[i]->size < min_size) {
f7f525030854b1 Simon Ser 2021-05-03 176 drm_dbg_kms(dev,
f7f525030854b1 Simon Ser 2021-05-03 177 "GEM object size (%zu) smaller than minimum size (%u) for plane %d\n",
f7f525030854b1 Simon Ser 2021-05-03 178 objs[i]->size, min_size, i);
be6ee102341bc4 Emil Velikov 2020-05-15 179 drm_gem_object_put(objs[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 180 ret = -EINVAL;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 181 goto err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 182 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 183 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 184
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 185 ret = drm_gem_fb_init(dev, fb, mode_cmd, objs, i, funcs);
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 186 if (ret)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 187 goto err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 188
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 189 return 0;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 190
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 191 err_gem_object_put:
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 @192 for (i--; i >= 0; i--)
be6ee102341bc4 Emil Velikov 2020-05-15 193 drm_gem_object_put(objs[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 194
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 195 return ret;
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 196 }
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 197 EXPORT_SYMBOL_GPL(drm_gem_fb_init_with_funcs);
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 198
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 39958 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/5] drm/gud: Map framebuffer BOs with drm_gem_fb_vmap()
2021-07-15 18:01 ` [PATCH 4/5] drm/gud: Map framebuffer BOs with drm_gem_fb_vmap() Thomas Zimmermann
@ 2021-07-22 11:49 ` Noralf Trønnes
0 siblings, 0 replies; 20+ messages in thread
From: Noralf Trønnes @ 2021-07-22 11:49 UTC (permalink / raw)
To: Thomas Zimmermann, maarten.lankhorst, mripard, airlied, daniel,
rodrigosiqueiramelo, melissa.srw, hamohammed.sa
Cc: dri-devel
Den 15.07.2021 20.01, skrev Thomas Zimmermann:
> Abstract the framebuffer details by mapping its BOs with a call
> to drm_gem_fb_vmap(). Unmap with drm_gem_fb_vunmap().
>
> The call to drm_gem_fb_vmap() ensures that all BOs are mapped
> correctly. Gud still only supports single-plane formats.
>
> No functional changes.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
Acked-by: Noralf Trønnes <noralf@tronnes.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES
2021-07-15 23:17 [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES kernel test robot
@ 2021-07-16 9:03 ` kernel test robot
0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-07-16 9:03 UTC (permalink / raw)
To: Thomas Zimmermann, maarten.lankhorst, mripard, airlied, daniel,
noralf, rodrigosiqueiramelo, melissa.srw, hamohammed.sa
Cc: kbuild-all, dri-devel, Thomas Zimmermann
Hi Thomas,
I love your patch! Perhaps something to improve:
[auto build test WARNING on 4d00e2309398147acdbfefbe1deb4b0e78868466]
url:
https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
base: 4d00e2309398147acdbfefbe1deb4b0e78868466
compiler: hppa-linux-gcc (GCC) 10.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
>> drivers/gpu/drm/drm_gem_framebuffer_helper.c:192:14: warning: Unsigned variable 'i' can't be negative so it is unnecessary to test it. [unsignedPositive]
for (i--; i >= 0; i--)
^
vim +192 drivers/gpu/drm/drm_gem_framebuffer_helper.c
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 119 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 120 /**
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 121 *
drm_gem_fb_init_with_funcs() - Helper function for implementing
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 122 *
&drm_mode_config_funcs.fb_create
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 123 * callback
in cases when the driver
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 124 * allocates
a subclass of
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 125 * struct
drm_framebuffer
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 126 * @dev: DRM device
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 127 * @fb:
framebuffer object
2e187b2099034a Noralf Trønnes 2017-09-22 128 * @file: DRM file
that holds the GEM handle(s) backing the framebuffer
2e187b2099034a Noralf Trønnes 2017-09-22 129 * @mode_cmd:
Metadata from the userspace framebuffer creation request
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 130 * @funcs: vtable
to be used for the new framebuffer object
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 131 *
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 132 * This function
can be used to set &drm_framebuffer_funcs for drivers that need
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 133 * custom
framebuffer callbacks. Use drm_gem_fb_create() if you don't need to
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 134 * change
&drm_framebuffer_funcs. The function does buffer size validation.
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 135 * The buffer size
validation is for a general case, though, so users should
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 136 * pay attention
to the checks being appropriate for them or, at least,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 137 * non-conflicting.
2e187b2099034a Noralf Trønnes 2017-09-22 138 *
2e187b2099034a Noralf Trønnes 2017-09-22 139 * Returns:
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 140 * Zero or a
negative error code.
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 141 */
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 142 int
drm_gem_fb_init_with_funcs(struct drm_device *dev,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 143 struct
drm_framebuffer *fb,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 144 struct
drm_file *file,
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 145 const
struct drm_mode_fb_cmd2 *mode_cmd,
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 146 const
struct drm_framebuffer_funcs *funcs)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 147 {
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 148 const struct
drm_format_info *info;
6065e7036e073e Thomas Zimmermann 2021-07-15 149 struct
drm_gem_object *objs[DRM_FORMAT_MAX_PLANES];
6065e7036e073e Thomas Zimmermann 2021-07-15 150 unsigned int i;
6065e7036e073e Thomas Zimmermann 2021-07-15 151 int ret;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 152 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 153 info = drm_get_format_info(dev,
mode_cmd);
f7f525030854b1 Simon Ser 2021-05-03 154 if (!info) {
f7f525030854b1 Simon Ser 2021-05-03 155 drm_dbg_kms(dev,
"Failed to get FB format info\n");
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 156 return -EINVAL;
f7f525030854b1 Simon Ser 2021-05-03 157 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 158 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 159 for (i = 0; i <
info->num_planes; i++) {
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 160 unsigned int
width = mode_cmd->width / (i ? info->hsub : 1);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 161 unsigned int
height = mode_cmd->height / (i ? info->vsub : 1);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 162 unsigned int
min_size;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 163 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 164 objs[i] =
drm_gem_object_lookup(file, mode_cmd->handles[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 165 if (!objs[i]) {
24f03be4aa7922 Jani Nikula 2019-12-10 166
drm_dbg_kms(dev, "Failed to lookup GEM object\n");
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 167 ret = -ENOENT;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 168 goto
err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 169 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 170 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 171 min_size = (height - 1) *
mode_cmd->pitches[i]
042bf753842ddb Alexandru Gheorghe 2018-11-01 172 +
drm_format_info_min_pitch(info, i, width)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 173 +
mode_cmd->offsets[i];
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 174 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 175 if (objs[i]->size < min_size) {
f7f525030854b1 Simon Ser 2021-05-03 176 drm_dbg_kms(dev,
f7f525030854b1 Simon Ser 2021-05-03 177 "GEM
object size (%zu) smaller than minimum size (%u) for plane %d\n",
f7f525030854b1 Simon Ser 2021-05-03 178
objs[i]->size, min_size, i);
be6ee102341bc4 Emil Velikov 2020-05-15 179
drm_gem_object_put(objs[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 180 ret = -EINVAL;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 181 goto
err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 182 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 183 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 184 f2b816d78a9431
Andrzej Pietrasiewicz 2020-03-11 185 ret = drm_gem_fb_init(dev, fb,
mode_cmd, objs, i, funcs);
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 186 if (ret)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 187 goto
err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 188 f2b816d78a9431
Andrzej Pietrasiewicz 2020-03-11 189 return 0;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 190 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 191 err_gem_object_put:
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 @192 for (i--; i >= 0;
i--)
be6ee102341bc4 Emil Velikov 2020-05-15 193
drm_gem_object_put(objs[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 194 f2b816d78a9431
Andrzej Pietrasiewicz 2020-03-11 195 return ret;
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 196 }
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 197
EXPORT_SYMBOL_GPL(drm_gem_fb_init_with_funcs);
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 198
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES
@ 2021-07-16 9:03 ` kernel test robot
0 siblings, 0 replies; 20+ messages in thread
From: kernel test robot @ 2021-07-16 9:03 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 7879 bytes --]
Hi Thomas,
I love your patch! Perhaps something to improve:
[auto build test WARNING on 4d00e2309398147acdbfefbe1deb4b0e78868466]
url:
https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
base: 4d00e2309398147acdbfefbe1deb4b0e78868466
compiler: hppa-linux-gcc (GCC) 10.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
>> drivers/gpu/drm/drm_gem_framebuffer_helper.c:192:14: warning: Unsigned variable 'i' can't be negative so it is unnecessary to test it. [unsignedPositive]
for (i--; i >= 0; i--)
^
vim +192 drivers/gpu/drm/drm_gem_framebuffer_helper.c
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 119 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 120 /**
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 121 *
drm_gem_fb_init_with_funcs() - Helper function for implementing
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 122 *
&drm_mode_config_funcs.fb_create
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 123 * callback
in cases when the driver
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 124 * allocates
a subclass of
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 125 * struct
drm_framebuffer
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 126 * @dev: DRM device
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 127 * @fb:
framebuffer object
2e187b2099034a Noralf Trønnes 2017-09-22 128 * @file: DRM file
that holds the GEM handle(s) backing the framebuffer
2e187b2099034a Noralf Trønnes 2017-09-22 129 * @mode_cmd:
Metadata from the userspace framebuffer creation request
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 130 * @funcs: vtable
to be used for the new framebuffer object
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 131 *
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 132 * This function
can be used to set &drm_framebuffer_funcs for drivers that need
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 133 * custom
framebuffer callbacks. Use drm_gem_fb_create() if you don't need to
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 134 * change
&drm_framebuffer_funcs. The function does buffer size validation.
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 135 * The buffer size
validation is for a general case, though, so users should
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 136 * pay attention
to the checks being appropriate for them or, at least,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 137 * non-conflicting.
2e187b2099034a Noralf Trønnes 2017-09-22 138 *
2e187b2099034a Noralf Trønnes 2017-09-22 139 * Returns:
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 140 * Zero or a
negative error code.
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 141 */
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 142 int
drm_gem_fb_init_with_funcs(struct drm_device *dev,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 143 struct
drm_framebuffer *fb,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 144 struct
drm_file *file,
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 145 const
struct drm_mode_fb_cmd2 *mode_cmd,
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 146 const
struct drm_framebuffer_funcs *funcs)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 147 {
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 148 const struct
drm_format_info *info;
6065e7036e073e Thomas Zimmermann 2021-07-15 149 struct
drm_gem_object *objs[DRM_FORMAT_MAX_PLANES];
6065e7036e073e Thomas Zimmermann 2021-07-15 150 unsigned int i;
6065e7036e073e Thomas Zimmermann 2021-07-15 151 int ret;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 152 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 153 info = drm_get_format_info(dev,
mode_cmd);
f7f525030854b1 Simon Ser 2021-05-03 154 if (!info) {
f7f525030854b1 Simon Ser 2021-05-03 155 drm_dbg_kms(dev,
"Failed to get FB format info\n");
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 156 return -EINVAL;
f7f525030854b1 Simon Ser 2021-05-03 157 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 158 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 159 for (i = 0; i <
info->num_planes; i++) {
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 160 unsigned int
width = mode_cmd->width / (i ? info->hsub : 1);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 161 unsigned int
height = mode_cmd->height / (i ? info->vsub : 1);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 162 unsigned int
min_size;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 163 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 164 objs[i] =
drm_gem_object_lookup(file, mode_cmd->handles[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 165 if (!objs[i]) {
24f03be4aa7922 Jani Nikula 2019-12-10 166
drm_dbg_kms(dev, "Failed to lookup GEM object\n");
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 167 ret = -ENOENT;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 168 goto
err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 169 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 170 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 171 min_size = (height - 1) *
mode_cmd->pitches[i]
042bf753842ddb Alexandru Gheorghe 2018-11-01 172 +
drm_format_info_min_pitch(info, i, width)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 173 +
mode_cmd->offsets[i];
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 174 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 175 if (objs[i]->size < min_size) {
f7f525030854b1 Simon Ser 2021-05-03 176 drm_dbg_kms(dev,
f7f525030854b1 Simon Ser 2021-05-03 177 "GEM
object size (%zu) smaller than minimum size (%u) for plane %d\n",
f7f525030854b1 Simon Ser 2021-05-03 178
objs[i]->size, min_size, i);
be6ee102341bc4 Emil Velikov 2020-05-15 179
drm_gem_object_put(objs[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 180 ret = -EINVAL;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 181 goto
err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 182 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 183 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 184 f2b816d78a9431
Andrzej Pietrasiewicz 2020-03-11 185 ret = drm_gem_fb_init(dev, fb,
mode_cmd, objs, i, funcs);
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 186 if (ret)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 187 goto
err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 188 f2b816d78a9431
Andrzej Pietrasiewicz 2020-03-11 189 return 0;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 190 4c3dbb2c312c9f
Noralf Trønnes 2017-08-13 191 err_gem_object_put:
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 @192 for (i--; i >= 0;
i--)
be6ee102341bc4 Emil Velikov 2020-05-15 193
drm_gem_object_put(objs[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 194 f2b816d78a9431
Andrzej Pietrasiewicz 2020-03-11 195 return ret;
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 196 }
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 197
EXPORT_SYMBOL_GPL(drm_gem_fb_init_with_funcs);
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 198
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES
@ 2021-07-15 23:17 kernel test robot
2021-07-16 9:03 ` kernel test robot
0 siblings, 1 reply; 20+ messages in thread
From: kernel test robot @ 2021-07-15 23:17 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 8379 bytes --]
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210715180133.3675-2-tzimmermann@suse.de>
References: <20210715180133.3675-2-tzimmermann@suse.de>
TO: Thomas Zimmermann <tzimmermann@suse.de>
TO: maarten.lankhorst(a)linux.intel.com
TO: mripard(a)kernel.org
TO: airlied(a)linux.ie
TO: daniel(a)ffwll.ch
TO: noralf(a)tronnes.org
TO: rodrigosiqueiramelo(a)gmail.com
TO: melissa.srw(a)gmail.com
TO: hamohammed.sa(a)gmail.com
CC: Thomas Zimmermann <tzimmermann@suse.de>
CC: dri-devel(a)lists.freedesktop.org
Hi Thomas,
I love your patch! Perhaps something to improve:
[auto build test WARNING on 4d00e2309398147acdbfefbe1deb4b0e78868466]
url: https://github.com/0day-ci/linux/commits/Thomas-Zimmermann/drm-Provide-framebuffer-vmap-helpers/20210716-020508
base: 4d00e2309398147acdbfefbe1deb4b0e78868466
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
compiler: hppa-linux-gcc (GCC) 10.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
>> drivers/gpu/drm/drm_gem_framebuffer_helper.c:192:14: warning: Unsigned variable 'i' can't be negative so it is unnecessary to test it. [unsignedPositive]
for (i--; i >= 0; i--)
^
vim +192 drivers/gpu/drm/drm_gem_framebuffer_helper.c
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 119
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 120 /**
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 121 * drm_gem_fb_init_with_funcs() - Helper function for implementing
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 122 * &drm_mode_config_funcs.fb_create
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 123 * callback in cases when the driver
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 124 * allocates a subclass of
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 125 * struct drm_framebuffer
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 126 * @dev: DRM device
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 127 * @fb: framebuffer object
2e187b2099034a Noralf Trønnes 2017-09-22 128 * @file: DRM file that holds the GEM handle(s) backing the framebuffer
2e187b2099034a Noralf Trønnes 2017-09-22 129 * @mode_cmd: Metadata from the userspace framebuffer creation request
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 130 * @funcs: vtable to be used for the new framebuffer object
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 131 *
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 132 * This function can be used to set &drm_framebuffer_funcs for drivers that need
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 133 * custom framebuffer callbacks. Use drm_gem_fb_create() if you don't need to
dbd62e16fd53d3 Noralf Trønnes 2019-01-15 134 * change &drm_framebuffer_funcs. The function does buffer size validation.
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 135 * The buffer size validation is for a general case, though, so users should
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 136 * pay attention to the checks being appropriate for them or, at least,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 137 * non-conflicting.
2e187b2099034a Noralf Trønnes 2017-09-22 138 *
2e187b2099034a Noralf Trønnes 2017-09-22 139 * Returns:
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 140 * Zero or a negative error code.
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 141 */
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 142 int drm_gem_fb_init_with_funcs(struct drm_device *dev,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 143 struct drm_framebuffer *fb,
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 144 struct drm_file *file,
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 145 const struct drm_mode_fb_cmd2 *mode_cmd,
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 146 const struct drm_framebuffer_funcs *funcs)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 147 {
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 148 const struct drm_format_info *info;
6065e7036e073e Thomas Zimmermann 2021-07-15 149 struct drm_gem_object *objs[DRM_FORMAT_MAX_PLANES];
6065e7036e073e Thomas Zimmermann 2021-07-15 150 unsigned int i;
6065e7036e073e Thomas Zimmermann 2021-07-15 151 int ret;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 152
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 153 info = drm_get_format_info(dev, mode_cmd);
f7f525030854b1 Simon Ser 2021-05-03 154 if (!info) {
f7f525030854b1 Simon Ser 2021-05-03 155 drm_dbg_kms(dev, "Failed to get FB format info\n");
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 156 return -EINVAL;
f7f525030854b1 Simon Ser 2021-05-03 157 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 158
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 159 for (i = 0; i < info->num_planes; i++) {
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 160 unsigned int width = mode_cmd->width / (i ? info->hsub : 1);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 161 unsigned int height = mode_cmd->height / (i ? info->vsub : 1);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 162 unsigned int min_size;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 163
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 164 objs[i] = drm_gem_object_lookup(file, mode_cmd->handles[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 165 if (!objs[i]) {
24f03be4aa7922 Jani Nikula 2019-12-10 166 drm_dbg_kms(dev, "Failed to lookup GEM object\n");
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 167 ret = -ENOENT;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 168 goto err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 169 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 170
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 171 min_size = (height - 1) * mode_cmd->pitches[i]
042bf753842ddb Alexandru Gheorghe 2018-11-01 172 + drm_format_info_min_pitch(info, i, width)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 173 + mode_cmd->offsets[i];
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 174
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 175 if (objs[i]->size < min_size) {
f7f525030854b1 Simon Ser 2021-05-03 176 drm_dbg_kms(dev,
f7f525030854b1 Simon Ser 2021-05-03 177 "GEM object size (%zu) smaller than minimum size (%u) for plane %d\n",
f7f525030854b1 Simon Ser 2021-05-03 178 objs[i]->size, min_size, i);
be6ee102341bc4 Emil Velikov 2020-05-15 179 drm_gem_object_put(objs[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 180 ret = -EINVAL;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 181 goto err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 182 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 183 }
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 184
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 185 ret = drm_gem_fb_init(dev, fb, mode_cmd, objs, i, funcs);
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 186 if (ret)
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 187 goto err_gem_object_put;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 188
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 189 return 0;
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 190
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 191 err_gem_object_put:
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 @192 for (i--; i >= 0; i--)
be6ee102341bc4 Emil Velikov 2020-05-15 193 drm_gem_object_put(objs[i]);
4c3dbb2c312c9f Noralf Trønnes 2017-08-13 194
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 195 return ret;
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 196 }
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 197 EXPORT_SYMBOL_GPL(drm_gem_fb_init_with_funcs);
f2b816d78a9431 Andrzej Pietrasiewicz 2020-03-11 198
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2021-07-22 11:49 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 18:01 [PATCH 0/5] drm: Provide framebuffer vmap helpers Thomas Zimmermann
2021-07-15 18:01 ` [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES Thomas Zimmermann
2021-07-16 7:30 ` Maxime Ripard
2021-07-16 8:50 ` Thomas Zimmermann
2021-07-18 13:23 ` kernel test robot
2021-07-18 13:23 ` kernel test robot
2021-07-15 18:01 ` [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap,vunmap}() Thomas Zimmermann
2021-07-15 22:31 ` kernel test robot
2021-07-15 22:31 ` [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap, vunmap}() kernel test robot
2021-07-16 0:52 ` [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap,vunmap}() kernel test robot
2021-07-16 0:52 ` [PATCH 2/5] drm/gem: Provide drm_gem_fb_{vmap, vunmap}() kernel test robot
2021-07-15 18:01 ` [PATCH 3/5] drm/gem: Clear mapping addresses for unused framebuffer planes Thomas Zimmermann
2021-07-15 18:01 ` [PATCH 4/5] drm/gud: Map framebuffer BOs with drm_gem_fb_vmap() Thomas Zimmermann
2021-07-22 11:49 ` Noralf Trønnes
2021-07-15 18:01 ` [PATCH 5/5] drm/vkms: Map output " Thomas Zimmermann
2021-07-16 2:28 ` kernel test robot
2021-07-16 2:28 ` kernel test robot
2021-07-15 23:17 [PATCH 1/5] drm: Define DRM_FORMAT_MAX_PLANES kernel test robot
2021-07-16 9:03 ` kernel test robot
2021-07-16 9:03 ` kernel test robot
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.