Re: [PATCH 4/4] drm/crtc: add drmm_crtc_alloc_with_planes()

2020-08-31 Thread Dan Carpenter
Hi Philipp,

https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Philipp-Zabel/drm-add-drmm_encoder_alloc/20200826-203629
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-randconfig-m001-20200826 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

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

smatch warnings:
drivers/gpu/drm/drm_crtc.c:343 drm_crtc_init_with_planes() error: uninitialized 
symbol 'ap'.
drivers/gpu/drm/drm_crtc.c:383 __drmm_crtc_alloc_with_planes() error: 
uninitialized symbol 'ap'.

# 
https://github.com/0day-ci/linux/commit/236b7bc44ae0fdecc8e80c5aba0655ca14fdfb23
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Philipp-Zabel/drm-add-drmm_encoder_alloc/20200826-203629
git checkout 236b7bc44ae0fdecc8e80c5aba0655ca14fdfb23
vim +/ap +343 drivers/gpu/drm/drm_crtc.c

236b7bc44ae0fd Philipp Zabel 2020-08-26  331  int 
drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,
236b7bc44ae0fd Philipp Zabel 2020-08-26  332  struct 
drm_plane *primary,
236b7bc44ae0fd Philipp Zabel 2020-08-26  333  struct 
drm_plane *cursor,
236b7bc44ae0fd Philipp Zabel 2020-08-26  334  const 
struct drm_crtc_funcs *funcs,
236b7bc44ae0fd Philipp Zabel 2020-08-26  335  const 
char *name, ...)
236b7bc44ae0fd Philipp Zabel 2020-08-26  336  {
236b7bc44ae0fd Philipp Zabel 2020-08-26  337va_list ap;
236b7bc44ae0fd Philipp Zabel 2020-08-26  338int ret;
236b7bc44ae0fd Philipp Zabel 2020-08-26  339  
236b7bc44ae0fd Philipp Zabel 2020-08-26  340if (name)
236b7bc44ae0fd Philipp Zabel 2020-08-26  341va_start(ap, name);
236b7bc44ae0fd Philipp Zabel 2020-08-26  342ret = 
drm_crtc_init_with_planes(dev, crtc, primary, cursor, funcs,
236b7bc44ae0fd Philipp Zabel 2020-08-26 @343
name, ap);

  ^^

236b7bc44ae0fd Philipp Zabel 2020-08-26  344if (name)
236b7bc44ae0fd Philipp Zabel 2020-08-26  345va_end(ap);
236b7bc44ae0fd Philipp Zabel 2020-08-26  346  
236b7bc44ae0fd Philipp Zabel 2020-08-26  347return ret;
236b7bc44ae0fd Philipp Zabel 2020-08-26  348  }
e13161af80c185 Matt Roper2014-04-01  349  
EXPORT_SYMBOL(drm_crtc_init_with_planes);
f453ba0460742a Dave Airlie   2008-11-07  350  
236b7bc44ae0fd Philipp Zabel 2020-08-26  351  static void 
drmm_crtc_alloc_with_planes_cleanup(struct drm_device *dev,
236b7bc44ae0fd Philipp Zabel 2020-08-26  352
void *ptr)
236b7bc44ae0fd Philipp Zabel 2020-08-26  353  {
236b7bc44ae0fd Philipp Zabel 2020-08-26  354struct drm_crtc *crtc = ptr;
236b7bc44ae0fd Philipp Zabel 2020-08-26  355  
236b7bc44ae0fd Philipp Zabel 2020-08-26  356drm_crtc_cleanup(crtc);
236b7bc44ae0fd Philipp Zabel 2020-08-26  357  }
236b7bc44ae0fd Philipp Zabel 2020-08-26  358  
236b7bc44ae0fd Philipp Zabel 2020-08-26  359  void 
*__drmm_crtc_alloc_with_planes(struct drm_device *dev,
236b7bc44ae0fd Philipp Zabel 2020-08-26  360
size_t size, size_t offset,
236b7bc44ae0fd Philipp Zabel 2020-08-26  361
struct drm_plane *primary,
236b7bc44ae0fd Philipp Zabel 2020-08-26  362
struct drm_plane *cursor,
236b7bc44ae0fd Philipp Zabel 2020-08-26  363
const struct drm_crtc_funcs *funcs,
236b7bc44ae0fd Philipp Zabel 2020-08-26  364
const char *name, ...)
236b7bc44ae0fd Philipp Zabel 2020-08-26  365  {
236b7bc44ae0fd Philipp Zabel 2020-08-26  366void *container;
236b7bc44ae0fd Philipp Zabel 2020-08-26  367struct drm_crtc *crtc;
236b7bc44ae0fd Philipp Zabel 2020-08-26  368va_list ap;
236b7bc44ae0fd Philipp Zabel 2020-08-26  369int ret;
236b7bc44ae0fd Philipp Zabel 2020-08-26  370  
236b7bc44ae0fd Philipp Zabel 2020-08-26  371if (!funcs || funcs->destroy)
236b7bc44ae0fd Philipp Zabel 2020-08-26  372return ERR_PTR(-EINVAL);
236b7bc44ae0fd Philipp Zabel 2020-08-26  373  
236b7bc44ae0fd Philipp Zabel 2020-08-26  374container = drmm_kzalloc(dev, 
size, GFP_KERNEL);
236b7bc44ae0fd Philipp Zabel 2020-08-26  375if (!container)
236b7bc44ae0fd Philipp Zabel 2020-08-26  376return ERR_PTR(-ENOMEM);
236b7bc44ae0fd Philipp Zabel 2020-08-26  377  
236b7bc44ae0fd Philipp Zabel 2020-08-26  378crtc = container + offset;
236b7bc44ae0fd Philipp Zabel 2020-08-26  379  
236b7bc44ae0fd Philipp Zabel 2020-08-26  380if (name)
236b7bc44ae0fd Philipp Zabel 2020-08-26  381va_start(ap, name);
236b7bc44ae0fd Philipp Zabel 2020-08-26  382ret = 
__drm_crtc_init_with_planes(dev, crtc, primary, cursor, funcs,

Re: [PATCH 4/4] drm/crtc: add drmm_crtc_alloc_with_planes()

2020-08-26 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-20200826]
[cannot apply to tegra-drm/drm/tegra/for-next drm-exynos/exynos-drm-next 
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/20200826-203629
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-randconfig-a003-20200826 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 
7cfcecece0e0430937cf529ce74d3a071a4dedc6)
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 x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

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_crtc.c:336:1: warning: all paths through this function 
>> will call itself [-Winfinite-recursion]
   {
   ^
   1 warning generated.

# 
https://github.com/0day-ci/linux/commit/236b7bc44ae0fdecc8e80c5aba0655ca14fdfb23
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Philipp-Zabel/drm-add-drmm_encoder_alloc/20200826-203629
git checkout 236b7bc44ae0fdecc8e80c5aba0655ca14fdfb23
vim +336 drivers/gpu/drm/drm_crtc.c

   311  
   312  /**
   313   * drm_crtc_init_with_planes - Initialise a new CRTC object with
   314   *specified primary and cursor planes.
   315   * @dev: DRM device
   316   * @crtc: CRTC object to init
   317   * @primary: Primary plane for CRTC
   318   * @cursor: Cursor plane for CRTC
   319   * @funcs: callbacks for the new CRTC
   320   * @name: printf style format string for the CRTC name, or NULL for 
default name
   321   *
   322   * Inits a new object created as base part of a driver crtc object. 
Drivers
   323   * should use this function instead of drm_crtc_init(), which is only 
provided
   324   * for backwards compatibility with drivers which do not yet support 
universal
   325   * planes). For really simple hardware which has only 1 plane look at
   326   * drm_simple_display_pipe_init() instead.
   327   *
   328   * Returns:
   329   * Zero on success, error code on failure.
   330   */
   331  int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc 
*crtc,
   332struct drm_plane *primary,
   333struct drm_plane *cursor,
   334const struct drm_crtc_funcs *funcs,
   335const char *name, ...)
 > 336  {
   337  va_list ap;
   338  int ret;
   339  
   340  if (name)
   341  va_start(ap, name);
   342  ret = drm_crtc_init_with_planes(dev, crtc, primary, cursor, 
funcs,
   343  name, ap);
   344  if (name)
   345  va_end(ap);
   346  
   347  return ret;
   348  }
   349  EXPORT_SYMBOL(drm_crtc_init_with_planes);
   350  

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


.config.gz
Description: application/gzip
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4/4] drm/crtc: add drmm_crtc_alloc_with_planes()

2020-08-26 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-20200826]
[cannot apply to tegra-drm/drm/tegra/for-next drm-exynos/exynos-drm-next 
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/20200826-203629
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: arm-randconfig-r001-20200826 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.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
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 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_crtc.c: In function '__drm_crtc_init_with_planes':
>> drivers/gpu/drm/drm_crtc.c:267:3: warning: function 
>> '__drm_crtc_init_with_planes' might be a candidate for 'gnu_printf' format 
>> attribute [-Wsuggest-attribute=format]
 267 |   crtc->name = kvasprintf(GFP_KERNEL, name, ap);
 |   ^~~~

# 
https://github.com/0day-ci/linux/commit/236b7bc44ae0fdecc8e80c5aba0655ca14fdfb23
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Philipp-Zabel/drm-add-drmm_encoder_alloc/20200826-203629
git checkout 236b7bc44ae0fdecc8e80c5aba0655ca14fdfb23
vim +267 drivers/gpu/drm/drm_crtc.c

35f8cc3b9a92c66 Gustavo Padovan 2016-12-06  207  
e954f77f6330028 Simon Ser   2020-05-21  208  /**
e954f77f6330028 Simon Ser   2020-05-21  209   * DOC: standard CRTC 
properties
e954f77f6330028 Simon Ser   2020-05-21  210   *
e954f77f6330028 Simon Ser   2020-05-21  211   * DRM CRTCs have a few 
standardized properties:
e954f77f6330028 Simon Ser   2020-05-21  212   *
e954f77f6330028 Simon Ser   2020-05-21  213   * ACTIVE:
e954f77f6330028 Simon Ser   2020-05-21  214   * Atomic property 
for setting the power state of the CRTC. When set to 1
e954f77f6330028 Simon Ser   2020-05-21  215   * the CRTC will 
actively display content. When set to 0 the CRTC will be
e954f77f6330028 Simon Ser   2020-05-21  216   * powered off. 
There is no expectation that user-space will reset CRTC
e954f77f6330028 Simon Ser   2020-05-21  217   * resources like 
the mode and planes when setting ACTIVE to 0.
e954f77f6330028 Simon Ser   2020-05-21  218   *
e954f77f6330028 Simon Ser   2020-05-21  219   * User-space can 
rely on an ACTIVE change to 1 to never fail an atomic
e954f77f6330028 Simon Ser   2020-05-21  220   * test as long as 
no other property has changed. If a change to ACTIVE
e954f77f6330028 Simon Ser   2020-05-21  221   * fails an atomic 
test, this is a driver bug. For this reason setting
e954f77f6330028 Simon Ser   2020-05-21  222   * ACTIVE to 0 
must not release internal resources (like reserved memory
e954f77f6330028 Simon Ser   2020-05-21  223   * bandwidth or 
clock generators).
e954f77f6330028 Simon Ser   2020-05-21  224   *
e954f77f6330028 Simon Ser   2020-05-21  225   * Note that the 
legacy DPMS property on connectors is internally routed
e954f77f6330028 Simon Ser   2020-05-21  226   * to control this 
property for atomic drivers.
e954f77f6330028 Simon Ser   2020-05-21  227   * MODE_ID:
e954f77f6330028 Simon Ser   2020-05-21  228   * Atomic property 
for setting the CRTC display timings. The value is the
e954f77f6330028 Simon Ser   2020-05-21  229   * ID of a blob 
containing the DRM mode info. To disable the CRTC,
e954f77f6330028 Simon Ser   2020-05-21  230   * user-space must 
set this property to 0.
e954f77f6330028 Simon Ser   2020-05-21  231   *
e954f77f6330028 Simon Ser   2020-05-21  232   * Setting MODE_ID 
to 0 will release reserved resources for the CRTC.
e954f77f6330028 Simon Ser   2020-05-21  233   */
e954f77f6330028 Simon Ser   2020-05-21  234  
236b7bc44ae0fde Philipp Zabel   2020-08-26  235  static int 
__drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,
e13161af80c185e Matt Roper  2014-04-01  236 
   struct drm_plane *primary,
fc1d3e44ef7c1db Matt Roper  2014-06-10  237 
   struct drm_plane *cursor,
f98828769c8838f Ville Syrjälä   

[PATCH 4/4] drm/crtc: add drmm_crtc_alloc_with_planes()

2020-08-26 Thread Philipp Zabel
Add an alternative to drm_crtc_init_with_planes() that allocates
and initializes a crtc and registers drm_crtc_cleanup() with
drmm_add_action_or_reset().

Signed-off-by: Philipp Zabel 
---
 drivers/gpu/drm/drm_crtc.c | 119 -
 include/drm/drm_crtc.h |  33 ++
 2 files changed, 124 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 283bcc4362ca..a31dcfa6b579 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -231,30 +232,11 @@ struct dma_fence *drm_crtc_create_fence(struct drm_crtc 
*crtc)
  * Setting MODE_ID to 0 will release reserved resources for the CRTC.
  */
 
-/**
- * drm_crtc_init_with_planes - Initialise a new CRTC object with
- *specified primary and cursor planes.
- * @dev: DRM device
- * @crtc: CRTC object to init
- * @primary: Primary plane for CRTC
- * @cursor: Cursor plane for CRTC
- * @funcs: callbacks for the new CRTC
- * @name: printf style format string for the CRTC name, or NULL for default 
name
- *
- * Inits a new object created as base part of a driver crtc object. Drivers
- * should use this function instead of drm_crtc_init(), which is only provided
- * for backwards compatibility with drivers which do not yet support universal
- * planes). For really simple hardware which has only 1 plane look at
- * drm_simple_display_pipe_init() instead.
- *
- * Returns:
- * Zero on success, error code on failure.
- */
-int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,
- struct drm_plane *primary,
- struct drm_plane *cursor,
- const struct drm_crtc_funcs *funcs,
- const char *name, ...)
+static int __drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc 
*crtc,
+  struct drm_plane *primary,
+  struct drm_plane *cursor,
+  const struct drm_crtc_funcs *funcs,
+  const char *name, va_list ap)
 {
struct drm_mode_config *config = >mode_config;
int ret;
@@ -282,11 +264,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, 
struct drm_crtc *crtc,
return ret;
 
if (name) {
-   va_list ap;
-
-   va_start(ap, name);
crtc->name = kvasprintf(GFP_KERNEL, name, ap);
-   va_end(ap);
} else {
crtc->name = kasprintf(GFP_KERNEL, "crtc-%d",
   drm_num_crtcs(dev));
@@ -330,8 +308,93 @@ int drm_crtc_init_with_planes(struct drm_device *dev, 
struct drm_crtc *crtc,
 
return 0;
 }
+
+/**
+ * drm_crtc_init_with_planes - Initialise a new CRTC object with
+ *specified primary and cursor planes.
+ * @dev: DRM device
+ * @crtc: CRTC object to init
+ * @primary: Primary plane for CRTC
+ * @cursor: Cursor plane for CRTC
+ * @funcs: callbacks for the new CRTC
+ * @name: printf style format string for the CRTC name, or NULL for default 
name
+ *
+ * Inits a new object created as base part of a driver crtc object. Drivers
+ * should use this function instead of drm_crtc_init(), which is only provided
+ * for backwards compatibility with drivers which do not yet support universal
+ * planes). For really simple hardware which has only 1 plane look at
+ * drm_simple_display_pipe_init() instead.
+ *
+ * Returns:
+ * Zero on success, error code on failure.
+ */
+int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,
+ struct drm_plane *primary,
+ struct drm_plane *cursor,
+ const struct drm_crtc_funcs *funcs,
+ const char *name, ...)
+{
+   va_list ap;
+   int ret;
+
+   if (name)
+   va_start(ap, name);
+   ret = drm_crtc_init_with_planes(dev, crtc, primary, cursor, funcs,
+   name, ap);
+   if (name)
+   va_end(ap);
+
+   return ret;
+}
 EXPORT_SYMBOL(drm_crtc_init_with_planes);
 
+static void drmm_crtc_alloc_with_planes_cleanup(struct drm_device *dev,
+   void *ptr)
+{
+   struct drm_crtc *crtc = ptr;
+
+   drm_crtc_cleanup(crtc);
+}
+
+void *__drmm_crtc_alloc_with_planes(struct drm_device *dev,
+   size_t size, size_t offset,
+   struct drm_plane *primary,
+   struct drm_plane *cursor,
+   const struct drm_crtc_funcs *funcs,
+   const char *name, ...)
+{
+   void *container;
+   struct drm_crtc *crtc;
+   va_list