Skip to contentSkip to conversation

drm/lsdc: add drm driver for loongson display controller

PATCH Superseded Sui Jingfeng 3 participants 5 messages Jan 30, 2022

Subsystems (3)

v2 of 15 Superseded Latest is v15 →

lore
Share & tools
lore
#0 lore raw

v2 cover drm/lsdc: add drm driver for loongson display controller

v2: fixup warnings reported by kernel test robot

There is a display controller in loongson's LS2K1000 SoC and LS7A1000 bridge, and the DC in those chip is a PCI device. This display controller have two display pipes but with only one hardware cursor.

This display controller is uncommon outside of china, it don't have rich document either. This patch try to provided a minimal support for this display controller which is for graphic environment bring up. Hope the code can speak for itself.

For ls7a1000, there are 4 gpios who register is located at dc register space which is used to emulation i2c. LS2K1000 and LS2K0500 SoC don't have those hardware, they use general purpose gpio or hardware i2c to serve this purpose.

LS2K1000 is a double core 1.0Ghz mips64r2 compatible SoC[1]. LS7A1000 is a bridge chip made by Loongson corporation which act as north and/or south bridge of loongson's desktop and server level processor. It is equivalent to RS780E or something like that. More details can be read from its user manual[2].

This bridge chip is typically use with LS3A3000, LS3A4000 and LS3A5000 cpu. LS3A3000 is 4 core 1.45gHz mips64r2 compatible cpu.
LS3A4000 is 4 core 1.8gHz mips64r5 compatible cpu.
LS3A5000 is 4 core 2.5gHz loongarch cpu[3].

[1] https://wiki.debian.org/InstallingDebianOn/Lemote/Loongson2K1000
[2] https://loongson.github.io/LoongArch-Documentation/Loongson-7A1000-usermanual-EN.html
[3] https://loongson.github.io/LoongArch-Documentation/Loongson-3A5000-usermanual-EN.html

suijingfeng (1):
drm/lsdc: add drm driver for loongson display controller

 drivers/gpu/drm/Kconfig               |   2 +
 drivers/gpu/drm/Makefile              |   1 +
 drivers/gpu/drm/lsdc/Kconfig          |  38 ++
 drivers/gpu/drm/lsdc/Makefile         |  15 +
 drivers/gpu/drm/lsdc/lsdc_connector.c | 439 ++++++++++++++
 drivers/gpu/drm/lsdc/lsdc_connector.h |  60 ++
 drivers/gpu/drm/lsdc/lsdc_crtc.c      | 438 ++++++++++++++
 drivers/gpu/drm/lsdc/lsdc_drv.c       | 824 ++++++++++++++++++++++++++
 drivers/gpu/drm/lsdc/lsdc_drv.h       | 214 +++++++
 drivers/gpu/drm/lsdc/lsdc_encoder.c   |  79 +++
 drivers/gpu/drm/lsdc/lsdc_i2c.c       | 220 +++++++
 drivers/gpu/drm/lsdc/lsdc_i2c.h       |  61 ++
 drivers/gpu/drm/lsdc/lsdc_irq.c       |  77 +++
 drivers/gpu/drm/lsdc/lsdc_irq.h       |  37 ++
 drivers/gpu/drm/lsdc/lsdc_plane.c     | 694 ++++++++++++++++++++++
 drivers/gpu/drm/lsdc/lsdc_pll.c       | 605 +++++++++++++++++++
 drivers/gpu/drm/lsdc/lsdc_pll.h       | 109 ++++
 drivers/gpu/drm/lsdc/lsdc_regs.h      | 242 ++++++++
 18 files changed, 4155 insertions(+)
 create mode 100644 drivers/gpu/drm/lsdc/Kconfig
 create mode 100644 drivers/gpu/drm/lsdc/Makefile
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_connector.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_connector.h
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_crtc.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_drv.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_drv.h
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_encoder.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_i2c.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_i2c.h
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_irq.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_irq.h
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_plane.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_pll.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_pll.h
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_regs.h
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/1 drm/lsdc: add drm driver for loongson display controller

From: suijingfeng <[email protected]>

There is a display controller in loongson's LS2K1000 SoC and LS7A1000 bridge, and the DC in those chip is a PCI device. This display controller have two display pipes but with only one hardware cursor.

This display controller is uncommon outside of china, it don't have rich document either. This patch try to provided a minimal support for this display controller which is for graphic environment bring up. Hope the code can speak for itself.

For ls7a1000, there are 4 gpios who register is located at dc register space which is used to emulation i2c. LS2K1000 and LS2K0500 SoC don't have those hardware, they use general purpose gpio or hardware i2c to serve this purpose.

LS2K1000 is a double core 1.0Ghz mips64r2 compatible SoC[1]. LS7A1000 is a bridge chip made by Loongson corporation which act as north and/or south bridge of loongson's desktop and server level processor. It is equivalent to RS780E or something like that. More details can be read from its user manual[2].

This bridge chip is typically use with LS3A3000, LS3A4000 and LS3A5000 cpu. LS3A3000 is 4 core 1.45gHz mips64r2 compatible cpu.
LS3A4000 is 4 core 1.8gHz mips64r5 compatible cpu.
LS3A5000 is 4 core 2.5gHz loongarch cpu[3].

[1] https://wiki.debian.org/InstallingDebianOn/Lemote/Loongson2K1000
[2] https://loongson.github.io/LoongArch-Documentation/Loongson-7A1000-usermanual-EN.html
[3] https://loongson.github.io/LoongArch-Documentation/Loongson-3A5000-usermanual-EN.html

---
 drivers/gpu/drm/Kconfig               |   2 +
 drivers/gpu/drm/Makefile              |   1 +
 drivers/gpu/drm/lsdc/Kconfig          |  38 ++
 drivers/gpu/drm/lsdc/Makefile         |  15 +
 drivers/gpu/drm/lsdc/lsdc_connector.c | 439 ++++++++++++++
 drivers/gpu/drm/lsdc/lsdc_connector.h |  60 ++
 drivers/gpu/drm/lsdc/lsdc_crtc.c      | 438 ++++++++++++++
 drivers/gpu/drm/lsdc/lsdc_drv.c       | 824 ++++++++++++++++++++++++++
 drivers/gpu/drm/lsdc/lsdc_drv.h       | 214 +++++++
 drivers/gpu/drm/lsdc/lsdc_encoder.c   |  79 +++
 drivers/gpu/drm/lsdc/lsdc_i2c.c       | 220 +++++++
 drivers/gpu/drm/lsdc/lsdc_i2c.h       |  61 ++
 drivers/gpu/drm/lsdc/lsdc_irq.c       |  77 +++
 drivers/gpu/drm/lsdc/lsdc_irq.h       |  37 ++
 drivers/gpu/drm/lsdc/lsdc_plane.c     | 694 ++++++++++++++++++++++
 drivers/gpu/drm/lsdc/lsdc_pll.c       | 605 +++++++++++++++++++
 drivers/gpu/drm/lsdc/lsdc_pll.h       | 109 ++++
 drivers/gpu/drm/lsdc/lsdc_regs.h      | 242 ++++++++
 18 files changed, 4155 insertions(+)
 create mode 100644 drivers/gpu/drm/lsdc/Kconfig
 create mode 100644 drivers/gpu/drm/lsdc/Makefile
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_connector.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_connector.h
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_crtc.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_drv.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_drv.h
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_encoder.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_i2c.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_i2c.h
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_irq.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_irq.h
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_plane.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_pll.c
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_pll.h
 create mode 100644 drivers/gpu/drm/lsdc/lsdc_regs.h
drivers/gpu/drm/Kconfig +2 -0
index dfdd3ec5f793..18de1485e2ed 100644
@@ -405,6 +405,8 @@ source "drivers/gpu/drm/gud/Kconfig"
 
 source "drivers/gpu/drm/sprd/Kconfig"
 
+source "drivers/gpu/drm/lsdc/Kconfig"
+
 config DRM_HYPERV
 	tristate "DRM Support for Hyper-V synthetic video device"
 	depends on DRM && PCI && MMU && HYPERV
drivers/gpu/drm/Makefile +1 -0
index 8675c2af7ae1..2c5a76ced323 100644
@@ -133,3 +133,4 @@ obj-y			+= xlnx/
 obj-y			+= gud/
 obj-$(CONFIG_DRM_HYPERV) += hyperv/
 obj-$(CONFIG_DRM_SPRD) += sprd/
+obj-$(CONFIG_DRM_LSDC) += lsdc/
drivers/gpu/drm/lsdc/Kconfig new file +38 -0
new file mode 100644
index 000000000000..f470892ddf60
@@ -0,0 +1,38 @@
+config DRM_LSDC
+	tristate "DRM Support for loongson's display controller"
+	depends on DRM && PCI
+	depends on MACH_LOONGSON64 || LOONGARCH || MIPS || COMPILE_TEST
+	select OF
+	select CMA if HAVE_DMA_CONTIGUOUS
+	select DMA_CMA if HAVE_DMA_CONTIGUOUS
+	select DRM_KMS_HELPER
+	select DRM_KMS_FB_HELPER
+	select DRM_GEM_CMA_HELPER
+	select VIDEOMODE_HELPERS
+	select BACKLIGHT_PWM if CPU_LOONGSON2K
+	select I2C_GPIO if CPU_LOONGSON2K
+	select I2C_LS2X if CPU_LOONGSON2K
+	default m
+	help
+	  This is a KMS driver for the display controller in the LS7A1000
+	  bridge chip and LS2K1000 SoC. The display controller have two
+	  display pipes and it is a PCI device.
+	  When using this driver on LS2K1000/LS2K0500 SoC, its framebuffer
+	  is located at system memory.
+	  If "M" is selected, the module will be called lsdc.
+
+	  If in doubt, say "Y".
+
+config DRM_LSDC_VRAM_DRIVER
+	bool "vram helper based device driver support"
+	depends on DRM_LSDC
+	select DRM_VRAM_HELPER
+	default y
+	help
+	  When using this driver on LS7A1000 + LS3A3000/LS3A4000/LS3A5000
+	  platform, the LS7A1000 bridge chip have dedicated video RAM.
+	  Pass lsdc.use_vram_helper = 1 to the kernel cmd line will enable
+	  this driver mode and then the framebuffer will located at the
+	  VRAM at the price of losing PRIME support.
+
+	  If in doubt, say "Y".
drivers/gpu/drm/lsdc/Makefile new file +15 -0
new file mode 100644
index 000000000000..342990654478
@@ -0,0 +1,15 @@
+#
+# Makefile for the lsdc drm device driver.
+#
+
+lsdc-y := \
+	lsdc_drv.o \
+	lsdc_crtc.o \
+	lsdc_irq.o \
+	lsdc_plane.o \
+	lsdc_pll.o \
+	lsdc_i2c.o \
+	lsdc_encoder.o \
+	lsdc_connector.o
+
+obj-$(CONFIG_DRM_LSDC) += lsdc.o
drivers/gpu/drm/lsdc/lsdc_connector.c new file +439 -0

439 lines not on this page · raw message

drivers/gpu/drm/lsdc/lsdc_connector.h new file +60 -0

60 lines not on this page · raw message

drivers/gpu/drm/lsdc/lsdc_crtc.c new file +438 -0

438 lines not on this page · raw message

drivers/gpu/drm/lsdc/lsdc_drv.c new file +824 -0

824 lines not on this page · raw message

drivers/gpu/drm/lsdc/lsdc_drv.h new file +214 -0

214 lines not on this page · raw message

drivers/gpu/drm/lsdc/lsdc_encoder.c new file +79 -0

79 lines not on this page · raw message

drivers/gpu/drm/lsdc/lsdc_i2c.c new file +220 -0

220 lines not on this page · raw message

drivers/gpu/drm/lsdc/lsdc_i2c.h new file +61 -0

61 lines not on this page · raw message

drivers/gpu/drm/lsdc/lsdc_irq.c new file +77 -0

77 lines not on this page · raw message

drivers/gpu/drm/lsdc/lsdc_irq.h new file +37 -0
new file mode 100644
index 000000000000..ac187538d746
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 Loongson Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+
+/*
+ * Authors:
+ *      Sui Jingfeng <[email protected]>
+ */
+
+#ifndef __LSDC_IRQ_H__
+#define __LSDC_IRQ_H__
+
+irqreturn_t lsdc_irq_thread_cb(int irq, void *arg);
+irqreturn_t lsdc_irq_handler_cb(int irq, void *arg);
+
+#endif
drivers/gpu/drm/lsdc/lsdc_plane.c new file +694 -0

486 lines not on this page · raw message

drivers/gpu/drm/lsdc/lsdc_pll.c new file +605 -0

605 lines not on this page · raw message

drivers/gpu/drm/lsdc/lsdc_pll.h new file +109 -0

109 lines not on this page · raw message

drivers/gpu/drm/lsdc/lsdc_regs.h new file +242 -0

242 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.20.1

Part of the diff is not shown here. View the raw message.

#2 lore raw

Hi--

Quoted 14 lines · Sui Jingfeng
drivers/gpu/drm/lsdc/Kconfig new file +8 -0
new file mode 100644
index 000000000000..f470892ddf60
@@ -0,0 +1,38 @@
+config DRM_LSDC
+	tristate "DRM Support for loongson's display controller"
+	depends on DRM && PCI
+	depends on MACH_LOONGSON64 || LOONGARCH || MIPS || COMPILE_TEST
+	select OF
+	select CMA if HAVE_DMA_CONTIGUOUS
+	select DMA_CMA if HAVE_DMA_CONTIGUOUS
+	select DRM_KMS_HELPER

drivers/gpu/drm/lsdc/Kconfig line 18

Quoted 10 lines
drivers/gpu/drm/lsdc/Kconfig new file +10 -0
+	select DRM_KMS_FB_HELPER
+	select DRM_GEM_CMA_HELPER
+	select VIDEOMODE_HELPERS
+	select BACKLIGHT_PWM if CPU_LOONGSON2K
+	select I2C_GPIO if CPU_LOONGSON2K
+	select I2C_LS2X if CPU_LOONGSON2K
+	default m
+	help
+	  This is a KMS driver for the display controller in the LS7A1000
+	  bridge chip and LS2K1000 SoC. The display controller have two

has two

Quoted 5 lines
drivers/gpu/drm/lsdc/Kconfig new file +5 -0
+	  display pipes and it is a PCI device.
+	  When using this driver on LS2K1000/LS2K0500 SoC, its framebuffer
+	  is located at system memory.
+	  If "M" is selected, the module will be called lsdc.
+

drivers/gpu/drm/lsdc/Kconfig line 33

Quoted 10 lines
drivers/gpu/drm/lsdc/Kconfig new file +10 -0
+	  If in doubt, say "Y".
+
+config DRM_LSDC_VRAM_DRIVER
+	bool "vram helper based device driver support"
+	depends on DRM_LSDC
+	select DRM_VRAM_HELPER
+	default y
+	help
+	  When using this driver on LS7A1000 + LS3A3000/LS3A4000/LS3A5000
+	  platform, the LS7A1000 bridge chip have dedicated video RAM.

has

drivers/gpu/drm/lsdc/Kconfig line 34

Quoted 1 line
drivers/gpu/drm/lsdc/Kconfig new file +1 -0
+	  Pass lsdc.use_vram_helper = 1 to the kernel cmd line will enable

Using "lsdc.use_vram_helper=1" in the kernel command line will enable

(No spaces allowed in the kernel command line.)

Quoted 2 lines
drivers/gpu/drm/lsdc/Kconfig new file +2 -0
+	  this driver mode and then the framebuffer will located at the
+	  VRAM at the price of losing PRIME support.
Signature · 1 line
~Randy
#3 lore raw
In reply to Sui Jingfeng
Thank you for the patch! Yet something to improve:

Hi Sui,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm/drm-next]
[also build test ERROR on v5.17-rc1 next-20220128]
[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/Sui-Jingfeng/drm-lsdc-add-drm-driver-for-loongson-display-controller/20220130-150458
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: powerpc64-randconfig-r013-20220130 (https://download.01.org/0day-ci/archive/20220130/202201302236.DGA9Yyr5-lkp(a)intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 11.2.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/cdef436d42a3499744f8fd5a1613a157dd703819
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Sui-Jingfeng/drm-lsdc-add-drm-driver-for-loongson-display-controller/20220130-150458 git checkout cdef436d42a3499744f8fd5a1613a157dd703819
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=powerpc SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "drm_gem_ttm_dumb_map_offset" [drivers/gpu/drm/lsdc/lsdc.ko] undefined!
>> ERROR: modpost: "drm_gem_ttm_print_info" [drivers/gpu/drm/drm_vram_helper.ko] undefined!
>> ERROR: modpost: "ttm_bo_eviction_valuable" [drivers/gpu/drm/drm_vram_helper.ko] undefined!
>> ERROR: modpost: ".ttm_device_init" [drivers/gpu/drm/drm_vram_helper.ko] undefined!
>> ERROR: modpost: ".ttm_range_man_init_nocheck" [drivers/gpu/drm/drm_vram_helper.ko] undefined!
>> ERROR: modpost: ".ttm_bo_init" [drivers/gpu/drm/drm_vram_helper.ko] undefined!
>> ERROR: modpost: ".ttm_bo_move_to_lru_tail" [drivers/gpu/drm/drm_vram_helper.ko] undefined!
>> ERROR: modpost: ".ttm_device_fini" [drivers/gpu/drm/drm_vram_helper.ko] undefined!
>> ERROR: modpost: ".ttm_bo_put" [drivers/gpu/drm/drm_vram_helper.ko] undefined!
>> ERROR: modpost: ".ttm_bo_vunmap" [drivers/gpu/drm/drm_vram_helper.ko] undefined!

WARNING: modpost: suppressed 8 unresolved symbol warnings because there were too many)

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

#4 lore raw
In reply to Sui Jingfeng
Thank you for the patch! Perhaps something to improve:

Hi Sui,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm/drm-next]
[also build test WARNING on v5.17-rc1 next-20220128]
[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/Sui-Jingfeng/drm-lsdc-add-drm-driver-for-loongson-display-controller/20220130-150458
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: arm64-allmodconfig (https://download.01.org/0day-ci/archive/20220131/202201310032.kOqILulA-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project f1c18acb07aa40f42b87b70462a6d1ab77a4825c)

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/cdef436d42a3499744f8fd5a1613a157dd703819
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Sui-Jingfeng/drm-lsdc-add-drm-driver-for-loongson-display-controller/20220130-150458 git checkout cdef436d42a3499744f8fd5a1613a157dd703819
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/gpu/drm/lsdc/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/lsdc/lsdc_plane.c:139:13: warning: variable 'val' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           } else if (index == 1) {
                      ^~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:147:32: note: uninitialized use occurs here
                   index, lsdc_pixfmt_to_string(val));
                                                ^~~
   include/drm/drm_print.h:429:36: note: expanded from macro 'drm_info'
           __drm_printk((drm), info,, fmt, ##__VA_ARGS__)
                                             ^~~~~~~~~~~
   include/drm/drm_print.h:425:48: note: expanded from macro '__drm_printk'
           dev_##level##type((drm)->dev, "[drm] " fmt, ##__VA_ARGS__)
                                                         ^~~~~~~~~~~
   include/linux/dev_printk.h:150:67: note: expanded from macro 'dev_info'
           dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__)
                                                                            ^~~~~~~~~~~
   include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
                   _p_func(dev, fmt, ##__VA_ARGS__);                       \
                                       ^~~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:139:9: note: remove the 'if' if its condition is always true
           } else if (index == 1) {
                  ^~~~~~~~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:113:9: note: initialize the variable 'val' to silence this warning
           u32 val;
                  ^
                   = 0
>> drivers/gpu/drm/lsdc/lsdc_plane.c:167:3: warning: variable 'priv_crtc_state' is uninitialized when used here [-Wuninitialized]
                   priv_crtc_state->pix_fmt = LSDC_PF_NONE;
                   ^~~~~~~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:155:41: note: initialize the variable 'priv_crtc_state' to silence this warning
           struct lsdc_crtc_state *priv_crtc_state;
                                                  ^
                                                   = NULL
   drivers/gpu/drm/lsdc/lsdc_plane.c:162:12: warning: variable 'val' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
                   else if (index == 1)
                            ^~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:165:30: note: uninitialized use occurs here
                   priv_crtc_state->pix_fmt = val & CFG_PIX_FMT_MASK;
                                              ^~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:162:8: note: remove the 'if' if its condition is always true
                   else if (index == 1)
                        ^~~~~~~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:156:9: note: initialize the variable 'val' to silence this warning
           u32 val;
                  ^
                   = 0
>> drivers/gpu/drm/lsdc/lsdc_plane.c:201:13: warning: variable 'addr_reg' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           } else if (index == 1) {
                      ^~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:216:25: note: uninitialized use occurs here
           lsdc_reg_write32(ldev, addr_reg, paddr);
                                  ^~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:201:9: note: remove the 'if' if its condition is always true
           } else if (index == 1) {
                  ^~~~~~~~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:179:14: note: initialize the variable 'addr_reg' to silence this warning
           u32 addr_reg;
                       ^
                        = 0
>> drivers/gpu/drm/lsdc/lsdc_plane.c:201:13: warning: variable 'cfg_reg' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           } else if (index == 1) {
                      ^~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:222:25: note: uninitialized use occurs here
           lsdc_reg_write32(ldev, cfg_reg, val | CFG_PAGE_FLIP_BIT);
                                  ^~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:201:9: note: remove the 'if' if its condition is always true
           } else if (index == 1) {
                  ^~~~~~~~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:180:13: note: initialize the variable 'cfg_reg' to silence this warning
           u32 cfg_reg;
                      ^
                       = 0
   drivers/gpu/drm/lsdc/lsdc_plane.c:201:13: warning: variable 'val' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           } else if (index == 1) {
                      ^~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:222:34: note: uninitialized use occurs here
           lsdc_reg_write32(ldev, cfg_reg, val | CFG_PAGE_FLIP_BIT);
                                           ^~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:201:9: note: remove the 'if' if its condition is always true
           } else if (index == 1) {
                  ^~~~~~~~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:181:9: note: initialize the variable 'val' to silence this warning
           u32 val;
                  ^
                   = 0
   drivers/gpu/drm/lsdc/lsdc_plane.c:583:19: warning: variable 'crtc' set but not used [-Wunused-but-set-variable]
           struct drm_crtc *crtc;
                            ^
>> drivers/gpu/drm/lsdc/lsdc_plane.c:660:7: warning: variable 'format_count' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
           case DRM_PLANE_TYPE_OVERLAY:
                ^~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:667:21: note: uninitialized use occurs here
                                          formats, format_count,
                                                   ^~~~~~~~~~~~
   drivers/gpu/drm/lsdc/lsdc_plane.c:644:27: note: initialize the variable 'format_count' to silence this warning
           unsigned int format_count;
                                    ^
                                     = 0

8 warnings generated.

vim +139 drivers/gpu/drm/lsdc/lsdc_plane.c

104
105
106
107 static void lsdc_update_fb_format(struct lsdc_device *ldev,
108 struct drm_crtc *crtc,
109 const struct drm_format_info *fmt_info)
110 {
111 unsigned int index = drm_crtc_index(crtc);
112 u32 fmt;
113 u32 val;
114
115 switch (fmt_info->format) {
116 case DRM_FORMAT_RGB565:
117 fmt = LSDC_PF_RGB565;
118 break;
119 case DRM_FORMAT_XRGB8888:
120 fmt = LSDC_PF_XRGB8888;
121 break;
122 case DRM_FORMAT_ARGB8888:
123 fmt = LSDC_PF_XRGB8888;
124 break;
125 default:
126 fmt = LSDC_PF_XRGB8888;
127 break;
128 }
129
130 drm_dbg_kms(&ldev->drm, "fmt wanted is %s\n",
131 lsdc_pixfmt_to_string(fmt));
132
133 if (index == 0) {
134 val = lsdc_reg_read32(ldev, LSDC_CRTC0_CFG_REG);
135 val = (val & ~CFG_PIX_FMT_MASK) | fmt;
136 lsdc_reg_write32(ldev, LSDC_CRTC0_CFG_REG, val);
137 val = lsdc_reg_read32(ldev, LSDC_CRTC0_CFG_REG);
138

 > 139		} else if (index == 1) {
   140			val = lsdc_reg_read32(ldev, LSDC_CRTC1_CFG_REG);
   141			val = (val & ~CFG_PIX_FMT_MASK) | fmt;
   142			lsdc_reg_write32(ldev, LSDC_CRTC1_CFG_REG, val);
   143			val = lsdc_reg_read32(ldev, LSDC_CRTC1_CFG_REG);
   144		}
   145	
   146		drm_info(&ldev->drm, "after update fb%d format is %s\n",
   147			index, lsdc_pixfmt_to_string(val));
   148	}
   149	
   150	
   151	static void lsdc_primary_get_default_format(struct drm_crtc *crtc)
   152	{
   153		struct lsdc_device *ldev = to_lsdc(crtc->dev);
   154		unsigned int index = drm_crtc_index(crtc);
   155		struct lsdc_crtc_state *priv_crtc_state;
   156		u32 val;
   157	
   158		if (crtc->state) {
   159			priv_crtc_state = to_lsdc_crtc_state(crtc->state);
   160			if (index == 0)
   161				val = lsdc_reg_read32(ldev, LSDC_CRTC0_CFG_REG);
   162			else if (index == 1)
   163				val = lsdc_reg_read32(ldev, LSDC_CRTC1_CFG_REG);
   164	
   165			priv_crtc_state->pix_fmt = val & CFG_PIX_FMT_MASK;
   166		} else
 > 167			priv_crtc_state->pix_fmt = LSDC_PF_NONE;
   168	
   169		drm_dbg_kms(crtc->dev, "current fb format: %d\n",
   170					priv_crtc_state->pix_fmt);
   171	}
   172	
   173	
   174	static void lsdc_update_fb_start_addr(struct lsdc_device *ldev,
   175					      struct drm_crtc *crtc,
   176					      u64 paddr)
   177	{
   178		unsigned int index = drm_crtc_index(crtc);
   179		u32 addr_reg;
   180		u32 cfg_reg;
   181		u32 val;
   182	
   183		/*
   184		 * Find which framebuffer address register should update.
   185		 * if FB_ADDR0_REG is in using, we write the addr to FB_ADDR1_REG,
   186		 * if FB_ADDR1_REG is in using, we write the addr to FB_ADDR0_REG
   187		 */
   188		if (index == 0) {
   189			/* CRTC0 */
   190			val = lsdc_reg_read32(ldev, LSDC_CRTC0_CFG_REG);
   191	
   192			cfg_reg = LSDC_CRTC0_CFG_REG;
   193	
   194			if (val & CFG_FB_IDX_BIT) {
   195				addr_reg = LSDC_CRTC0_FB_ADDR0_REG;
   196				drm_dbg_kms(&ldev->drm, "CRTC0 FB0 will be use\n");
   197			} else {
   198				addr_reg = LSDC_CRTC0_FB_ADDR1_REG;
   199				drm_dbg_kms(&ldev->drm, "CRTC0 FBq will be use\n");
   200			}
 > 201		} else if (index == 1) {

202 /* CRTC1 */
203 val = lsdc_reg_read32(ldev, LSDC_CRTC1_CFG_REG);
204
205 cfg_reg = LSDC_CRTC1_CFG_REG;
206
207 if (val & CFG_FB_IDX_BIT) {
208 addr_reg = LSDC_CRTC1_FB_ADDR0_REG;
209 drm_dbg_kms(&ldev->drm, "CRTC1 FB0 will be use\n");
210 } else {
211 addr_reg = LSDC_CRTC1_FB_ADDR1_REG;
212 drm_dbg_kms(&ldev->drm, "CRTC1 FBq will be use\n");
213 }
214 }
215
216 lsdc_reg_write32(ldev, addr_reg, paddr);
217
218 /*
219 * Then, we triger the fb switch, the switch of the framebuffer
220 * to be scanout will complete at the next vblank.
221 */
222 lsdc_reg_write32(ldev, cfg_reg, val | CFG_PAGE_FLIP_BIT);
223
224 drm_dbg_kms(&ldev->drm, "crtc%u scantout from 0x%llx\n", index, paddr);
225 }
226

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