Re: [PATCH v2 3/4] drm/plane: add drmm_universal_plane_alloc()

2020-08-27 Thread kernel test robot
Hi Philipp,

I love your patch! Perhaps something to improve:

[auto build test WARNING on drm-intel/for-linux-next]
[also build test WARNING on drm-tip/drm-tip linus/master v5.9-rc2 next-20200827]
[cannot apply to drm/drm-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Philipp-Zabel/drm-add-drmm_encoder_alloc/20200828-000957
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: arm-randconfig-r003-20200827 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 
c10e63677f5d20f18010f8f68c631ddc97546f7d)
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 arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/drm_plane.c:301:6: warning: variable 'ap' is used 
>> uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
   if (name)
   ^~~~
   drivers/gpu/drm/drm_plane.c:305:19: note: uninitialized use occurs here
type, name, ap);
^~
   drivers/gpu/drm/drm_plane.c:301:2: note: remove the 'if' if its condition is 
always true
   if (name)
   ^
   drivers/gpu/drm/drm_plane.c:298:2: note: variable 'ap' is declared here
   va_list ap;
   ^
   drivers/gpu/drm/drm_plane.c:344:6: warning: variable 'ap' is used 
uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
   if (name)
   ^~~~
   drivers/gpu/drm/drm_plane.c:348:19: note: uninitialized use occurs here
type, name, ap);
^~
   drivers/gpu/drm/drm_plane.c:344:2: note: remove the 'if' if its condition is 
always true
   if (name)
   ^
   drivers/gpu/drm/drm_plane.c:332:2: note: variable 'ap' is declared here
   va_list ap;
   ^
   2 warnings generated.

# 
https://github.com/0day-ci/linux/commit/5f2373dfa20624f32ff28097eb734511ed8ca13e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Philipp-Zabel/drm-add-drmm_encoder_alloc/20200828-000957
git checkout 5f2373dfa20624f32ff28097eb734511ed8ca13e
vim +301 drivers/gpu/drm/drm_plane.c

   271  
   272  /**
   273   * drm_universal_plane_init - Initialize a new universal plane object
   274   * @dev: DRM device
   275   * @plane: plane object to init
   276   * @possible_crtcs: bitmask of possible CRTCs
   277   * @funcs: callbacks for the new plane
   278   * @formats: array of supported formats (DRM_FORMAT\_\*)
   279   * @format_count: number of elements in @formats
   280   * @format_modifiers: array of struct drm_format modifiers terminated by
   281   *DRM_FORMAT_MOD_INVALID
   282   * @type: type of plane (overlay, primary, cursor)
   283   * @name: printf style format string for the plane name, or NULL for 
default name
   284   *
   285   * Initializes a plane object of type @type.
   286   *
   287   * Returns:
   288   * Zero on success, error code on failure.
   289   */
   290  int drm_universal_plane_init(struct drm_device *dev, struct drm_plane 
*plane,
   291   uint32_t possible_crtcs,
   292   const struct drm_plane_funcs *funcs,
   293   const uint32_t *formats, unsigned int 
format_count,
   294   const uint64_t *format_modifiers,
   295   enum drm_plane_type type,
   296   const char *name, ...)
   297  {
   298  va_list ap;
   299  int ret;
   300  
 > 301  if (name)
   302  va_start(ap, name);
   303  ret = __drm_universal_plane_init(dev, plane, possible_crtcs, 
funcs,
   304   formats, format_count, 
format_modifiers,
   305   type, name, ap);
   306  if (name)
   307  va_end(ap);
   308  return ret;
   309  }
   310  EXPORT_SYMBOL(drm_universal_plane_init);
   311  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip

[PATCH v2 3/4] drm/plane: add drmm_universal_plane_alloc()

2020-08-27 Thread Philipp Zabel
Add an alternative to drm_universal_plane_init() that allocates
and initializes a plane and registers drm_plane_cleanup() with
drmm_add_action_or_reset().

Signed-off-by: Philipp Zabel 
---
Changes since v1:
 - add __printf annotation to __drm_universal_plane_init() and make it static
---
 drivers/gpu/drm/drm_plane.c | 130 
 include/drm/drm_plane.h |  42 
 2 files changed, 143 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index b7b90b3a2e38..ddf7f0724260 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "drm_crtc_internal.h"
@@ -152,31 +153,16 @@ static int create_in_format_blob(struct drm_device *dev, 
struct drm_plane *plane
return 0;
 }
 
-/**
- * drm_universal_plane_init - Initialize a new universal plane object
- * @dev: DRM device
- * @plane: plane object to init
- * @possible_crtcs: bitmask of possible CRTCs
- * @funcs: callbacks for the new plane
- * @formats: array of supported formats (DRM_FORMAT\_\*)
- * @format_count: number of elements in @formats
- * @format_modifiers: array of struct drm_format modifiers terminated by
- *DRM_FORMAT_MOD_INVALID
- * @type: type of plane (overlay, primary, cursor)
- * @name: printf style format string for the plane name, or NULL for default 
name
- *
- * Initializes a plane object of type @type.
- *
- * Returns:
- * Zero on success, error code on failure.
- */
-int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
-uint32_t possible_crtcs,
-const struct drm_plane_funcs *funcs,
-const uint32_t *formats, unsigned int format_count,
-const uint64_t *format_modifiers,
-enum drm_plane_type type,
-const char *name, ...)
+__printf(9, 0)
+static int __drm_universal_plane_init(struct drm_device *dev,
+ struct drm_plane *plane,
+ uint32_t possible_crtcs,
+ const struct drm_plane_funcs *funcs,
+ const uint32_t *formats,
+ unsigned int format_count,
+ const uint64_t *format_modifiers,
+ enum drm_plane_type type,
+ const char *name, va_list ap)
 {
struct drm_mode_config *config = >mode_config;
unsigned int format_modifier_count = 0;
@@ -237,11 +223,7 @@ int drm_universal_plane_init(struct drm_device *dev, 
struct drm_plane *plane,
}
 
if (name) {
-   va_list ap;
-
-   va_start(ap, name);
plane->name = kvasprintf(GFP_KERNEL, name, ap);
-   va_end(ap);
} else {
plane->name = kasprintf(GFP_KERNEL, "plane-%d",
drm_num_planes(dev));
@@ -286,8 +268,98 @@ int drm_universal_plane_init(struct drm_device *dev, 
struct drm_plane *plane,
 
return 0;
 }
+
+/**
+ * drm_universal_plane_init - Initialize a new universal plane object
+ * @dev: DRM device
+ * @plane: plane object to init
+ * @possible_crtcs: bitmask of possible CRTCs
+ * @funcs: callbacks for the new plane
+ * @formats: array of supported formats (DRM_FORMAT\_\*)
+ * @format_count: number of elements in @formats
+ * @format_modifiers: array of struct drm_format modifiers terminated by
+ *DRM_FORMAT_MOD_INVALID
+ * @type: type of plane (overlay, primary, cursor)
+ * @name: printf style format string for the plane name, or NULL for default 
name
+ *
+ * Initializes a plane object of type @type.
+ *
+ * Returns:
+ * Zero on success, error code on failure.
+ */
+int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
+uint32_t possible_crtcs,
+const struct drm_plane_funcs *funcs,
+const uint32_t *formats, unsigned int format_count,
+const uint64_t *format_modifiers,
+enum drm_plane_type type,
+const char *name, ...)
+{
+   va_list ap;
+   int ret;
+
+   if (name)
+   va_start(ap, name);
+   ret = __drm_universal_plane_init(dev, plane, possible_crtcs, funcs,
+formats, format_count, 
format_modifiers,
+type, name, ap);
+   if (name)
+   va_end(ap);
+   return ret;
+}
 EXPORT_SYMBOL(drm_universal_plane_init);
 
+static void drmm_universal_plane_alloc_release(struct drm_device *dev, void 
*ptr)
+{
+   struct drm_plane *plane = ptr;