Skip to contentSkip to conversation

drm/lsdc: add drm driver for loongson display controller

PATCH Superseded Sui Jingfeng 3 participants 6 messages Jan 30, 2022 – Jan 31, 2022

Subsystems (3)

v3 of 15 Superseded Latest is v15 →

lore
Share & tools
lore
#0 lore raw

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

v3: fix more grammar mistakes in Kconfig reported by Randy Dunlap and give
more details about lsdc.
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. Each way has a DVO output interface and the CRTC is able to scanout from 1920x1080 resolution at 60Hz.

  +----------+          +-----------------------+------------+
  | LS3A4000 |<-------->|         LS7A1000      |    DDR3    |   +------+
  |    CPU   |  HT Bus  | +--------+  +-------+ |    1333    |<->| VRAM |
  | LS3A5000 |<-------->| | GC1000 |  |  LSDC | | controller |   +------+
  +----------+          | +--------+  +-+---+-+ +------------|
                        +---------------|---|----------------+
                                        |   |
                    +-------+    DVO0   |   |  DVO1  +------+
                    |ADV7125|-----------+   +------->|TFP410|--> DVI/HDMI
                    +-------+                        +------+

The above picture give a simple usage, the encoder is not necessary adv7125 or tfp410, it is a choice of the downstream board manufacturer. Other candicate encoder can be ch7034b, sil9022 and ite66121 etc this is the reason why we still need device to provide board specific information. The downstream kernel use self made vbios instead of device tree which is hard to upstream. The display controller is uncommon outside of china, it don't have rich document either. Nevertheless, this patch try to provided a minimal support for this display controller which is for graphic environment bring up. Hope that 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. For ladc, there is only a 1:1 mapping of encoders and connectors.

     +-------------------+                                      _________
     |                   |                                     |         |
     |  CRTC0 --> DVO0 ---------> Encoder0 --> Connector0 ---> | Monotor |
     |                   |           ^            ^            |_________|
     |                   |           |            |
     |                <----- i2c0 ----------------+
     |   LSDC IP CORE    |
     |                <----- i2c1 ----------------+
     |                   |           |            |             _________
     |                   |           |            |            |         |
     |  CRTC1 --> DVO1 ---------> Encoder1 --> Connector1 ---> |  Panel  |
     |                   |                                     |_________|
     +-------------------+

Below is a brief introduction of loongson's CPU, bridge chip and SoC. 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     | 688 +++++++++++++++++++++
 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, 4149 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 v3 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. Each way has a DVO output interface and the CRTC is able to scanout from 1920x1080 resolution at 60Hz.

  +----------+          +-----------------------+------------+
  | LS3A4000 |<-------->|         LS7A1000      |    DDR3    |   +------+
  |    CPU   |  HT Bus  | +--------+  +-------+ |    1333    |<->| VRAM |
  | LS3A5000 |<-------->| | GC1000 |  |  LSDC | | controller |   +------+
  +----------+          | +--------+  +-+---+-+ +------------|
                        +---------------|---|----------------+
                                        |   |
                    +-------+    DVO0   |   |  DVO1  +------+
                    |ADV7125|-----------+   +------->|TFP410|--> DVI/HDMI
                    +-------+                        +------+

The above picture give a simple usage, the encoder is not necessary adv7125 or tfp410, it is a choice of the downstream board manufacturer. Other candicate encoder can be ch7034b, sil9022 and ite66121 etc this is the reason why we still need device to provide board specific information. The downstream kernel use self made vbios instead of device tree which is hard to upstream. The display controller is uncommon outside of china, it don't have rich document either. Nevertheless, this patch try to provided a minimal support for this display controller which is for graphic environment bring up. Hope that 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. For ladc, there is only a 1:1 mapping of encoders and connectors.

     +-------------------+                                      _________
     |                   |                                     |         |
     |  CRTC0 --> DVO0 ---------> Encoder0 --> Connector0 ---> | Monotor |
     |                   |           ^            ^            |_________|
     |                   |           |            |
     |                <----- i2c0 ----------------+
     |   LSDC IP CORE    |
     |                <----- i2c1 ----------------+
     |                   |           |            |             _________
     |                   |           |            |            |         |
     |  CRTC1 --> DVO1 ---------> Encoder1 --> Connector1 ---> |  Panel  |
     |                   |                                     |_________|
     +-------------------+

Below is a brief introduction of loongson's CPU, bridge chip and SoC. 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     | 688 +++++++++++++++++++++
 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, 4149 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..8c908787b4aa
@@ -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 has 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 has dedicated video RAM. Using
+	  "lsdc.use_vram_helper=1" in the kernel command 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 +688 -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,
The Kconfig text is looking good. Just one minor nit below:

Quoted 31 lines · Sui Jingfeng
drivers/gpu/drm/lsdc/Kconfig new file +25 -0
new file mode 100644
index 000000000000..8c908787b4aa
@@ -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 has 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".
+

drivers/gpu/drm/lsdc/Kconfig line 35

Quoted 10 lines
drivers/gpu/drm/lsdc/Kconfig new file +10 -0
+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 has dedicated video RAM. Using
+	  "lsdc.use_vram_helper=1" in the kernel command line will enable
+	  this driver mode and then the framebuffer will located at the

will be located at the

drivers/gpu/drm/lsdc/Kconfig line 36

Quoted 1 line
drivers/gpu/drm/lsdc/Kconfig new file +1 -0
+	  VRAM at the price of losing PRIME support.

thanks.

Signature · 1 line
~Randy
#3 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-rc2 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/20220131-043734
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: parisc-randconfig-s031-20220131 (https://download.01.org/0day-ci/archive/20220131/202201311300.pgcsprIS-lkp(a)intel.com/config)
compiler: hppa-linux-gcc (GCC) 11.2.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.4-dirty
# https://github.com/0day-ci/linux/commit/219048b8904ab97749c0bc3ea426b858d9562de0
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/20220131-043734
git checkout 219048b8904ab97749c0bc3ea426b858d9562de0
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=parisc SHELL=/bin/bash drivers/gpu/drm/lsdc/

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

sparse warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/lsdc/lsdc_pll.c:190:9: sparse: sparse: cast removes address space '__iomem' of expression
>> drivers/gpu/drm/lsdc/lsdc_pll.c:404:34: sparse: sparse: shift too big (42) for type long
>> drivers/gpu/drm/lsdc/lsdc_pll.c:405:47: sparse: sparse: shift too big (32) for type unsigned long

vim +/__iomem +190 drivers/gpu/drm/lsdc/lsdc_pll.c

184
185
186 static int lsdc_pixpll_setup(struct lsdc_pll * const this)
187 {
188 this->mmio = ioremap(this->reg_base, this->reg_size);
189

 > 190		drm_info(this->ddev, "PIXPLL%u REG[%x, %u] map to %llx\n",

191 this->index, this->reg_base, this->reg_size, (u64)this->mmio);
192
193 return 0;
194 }
195

---
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! 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-rc2 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/20220131-043734
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: riscv-randconfig-r016-20220131 (https://download.01.org/0day-ci/archive/20220131/202201311423.sZVV3fVK-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 2cdbaca3943a4d6259119f185656328bd3805b68)

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 riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/219048b8904ab97749c0bc3ea426b858d9562de0
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/20220131-043734 git checkout 219048b8904ab97749c0bc3ea426b858d9562de0
# 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=riscv SHELL=/bin/bash drivers/gpu/drm/lsdc/

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

All error/warnings (new ones prefixed by >>):

>> drivers/gpu/drm/lsdc/lsdc_drv.c:581:55: warning: format specifies type 'unsigned long long' but the argument has type 'resource_size_t' (aka 'unsigned int') [-Wformat]
           drm_info(ddev, "vram start: 0x%llx, size: %lluMB\n", base, size >> 20);
                                         ~~~~                   ^~~~
                                         %x
   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_drv.c:581:61: warning: format specifies type 'unsigned long long' but the argument has type 'resource_size_t' (aka 'unsigned int') [-Wformat]
           drm_info(ddev, "vram start: 0x%llx, size: %lluMB\n", base, size >> 20);
                                                     ~~~~             ^~~~~~~~~~
                                                     %u
   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__);                       \
                                ~~~    ^~~~~~~~~~~
   2 warnings generated.
--
>> drivers/gpu/drm/lsdc/lsdc_pll.c:395:12: error: implicit declaration of function 'readq' [-Werror,-Wimplicit-function-declaration]
           u64 val = readq(reg);
                     ^
>> drivers/gpu/drm/lsdc/lsdc_pll.c:402:2: error: implicit declaration of function 'writeq' [-Werror,-Wimplicit-function-declaration]
           writeq(val, reg);
           ^
>> drivers/gpu/drm/lsdc/lsdc_pll.c:404:24: warning: shift count >= width of type [-Wshift-count-overflow]
           val = (1L << 7) | (1L << 42) | (3L << 10);   /* allow L1 PLL locked */
                                 ^  ~~
   drivers/gpu/drm/lsdc/lsdc_pll.c:405:37: warning: shift count >= width of type [-Wshift-count-overflow]
           val |= (unsigned long)param->loopc << 32;    /* set loopc   */
                                              ^  ~~
   drivers/gpu/drm/lsdc/lsdc_pll.c:439:8: error: implicit declaration of function 'readq' [-Werror,-Wimplicit-function-declaration]
           val = readq(reg);
                 ^
   drivers/gpu/drm/lsdc/lsdc_pll.c:441:2: error: implicit declaration of function 'writeq' [-Werror,-Wimplicit-function-declaration]
           writeq(val, reg);
           ^
   drivers/gpu/drm/lsdc/lsdc_pll.c:499:20: error: implicit declaration of function 'readq' [-Werror,-Wimplicit-function-declaration]
                   parms.qword[0] = readq(this->mmio);
                                    ^
   drivers/gpu/drm/lsdc/lsdc_pll.c:504:20: error: implicit declaration of function 'readq' [-Werror,-Wimplicit-function-declaration]
                   parms.qword[0] = readq(this->mmio);
                                    ^

2 warnings and 6 errors generated.

vim +/readq +395 drivers/gpu/drm/lsdc/lsdc_pll.c

386
387
388 /*
389 * the PIX PLL be software configurable when SYS_CLKSEL[1:0] is 10b
390 */
391 static int ls2k1000_pixpll_param_update(struct lsdc_pll * const this,
392 const struct lsdc_pll_core_values * const param)
393 {
394 void __iomem *reg = this->mmio;

 > 395		u64 val = readq(reg);
   396		bool locked;
   397		unsigned int counter = 0;
   398	
   399		val &= ~(1 << 0);    /* Bypass the PLL, using refclk directly */
   400		val |= (1 << 19);    /* powerdown the PLL */
   401		val &= ~(1 << 2);    /* don't use the software configure param */
 > 402		writeq(val, reg);
   403	
 > 404		val = (1L << 7) | (1L << 42) | (3L << 10);   /* allow L1 PLL locked */
   405		val |= (unsigned long)param->loopc << 32;    /* set loopc   */
   406		val |= (unsigned long)param->div_ref << 26;  /* set div_ref */

407 writeq(val, reg);
408 writeq(param->div_out, reg + 8); /* set div_out */
409
410 val = readq(reg);
411 val |= (1 << 2); /* use the software configure param */
412 val &= ~(1 << 19); /* powerup the PLL */
413 writeq(val, reg);
414
415 /* wait pll setup and locked */
416 do {
417 val = readl(reg);
418 locked = val & 0x10000;
419 counter++;
420 } while (locked == false);
421
422 drm_dbg_kms(this->ddev, "%u loop waited\n", counter);
423
424 val = readq(reg);
425 val |= (1 << 0); /* switch to the software configured pll */
426 writeq(val, reg);
427
428 return 0;
429 }
430

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

#5 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-rc2 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/20220131-043734
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: ia64-randconfig-m031-20220131 (https://download.01.org/0day-ci/archive/20220131/202201311829.RZamTj6t-lkp(a)intel.com/config)
compiler: ia64-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/219048b8904ab97749c0bc3ea426b858d9562de0
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/20220131-043734 git checkout 219048b8904ab97749c0bc3ea426b858d9562de0
# 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=ia64 SHELL=/bin/bash drivers/gpu/drm/lsdc/

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

All errors (new ones prefixed by >>):

In file included from arch/ia64/include/asm/pgtable.h:153,

                    from include/linux/pgtable.h:6,
                    from arch/ia64/include/asm/uaccess.h:40,
                    from include/linux/uaccess.h:11,
                    from include/linux/sched/task.h:11,
                    from include/linux/sched/signal.h:9,
                    from include/linux/rcuwait.h:6,
                    from include/linux/percpu-rwsem.h:7,
                    from include/linux/fs.h:33,
                    from include/linux/poll.h:10,
                    from include/drm/drm_vblank.h:29,
                    from drivers/gpu/drm/lsdc/lsdc_irq.c:30:
   arch/ia64/include/asm/mmu_context.h: In function 'reload_context':
   arch/ia64/include/asm/mmu_context.h:127:48: warning: variable 'old_rr4' set but not used [-Wunused-but-set-variable]
     127 |         unsigned long rr0, rr1, rr2, rr3, rr4, old_rr4;
         |                                                ^~~~~~~
   drivers/gpu/drm/lsdc/lsdc_irq.c: In function 'lsdc_irq_handler_cb':
>> drivers/gpu/drm/lsdc/lsdc_irq.c:69:17: error: implicit declaration of function 'drm_warn'; did you mean 'dev_warn'? [-Werror=implicit-function-declaration]
      69 |                 drm_warn(ddev, "no interrupt occurs\n");
         |                 ^~~~~~~~
         |                 dev_warn

cc1: some warnings being treated as errors

vim +69 drivers/gpu/drm/lsdc/lsdc_irq.c

  > 30	#include <drm/drm_vblank.h>
    31	
    32	#include "lsdc_drv.h"
    33	#include "lsdc_regs.h"
    34	#include "lsdc_irq.h"
    35	
    36	/* Function to be called in a threaded interrupt context. */
    37	irqreturn_t lsdc_irq_thread_cb(int irq, void *arg)
    38	{
    39		struct drm_device *ddev = arg;
    40		struct lsdc_device *ldev = to_lsdc(ddev);
    41		struct drm_crtc *crtc;
    42	
    43		/* trigger the vblank event */
    44		if (ldev->irq_status & INT_CRTC0_VS) {
    45			crtc = drm_crtc_from_index(ddev, 0);
    46			drm_crtc_handle_vblank(crtc);
    47		}
    48	
    49		if (ldev->irq_status & INT_CRTC1_VS) {
    50			crtc = drm_crtc_from_index(ddev, 1);
    51			drm_crtc_handle_vblank(crtc);
    52		}
    53	
    54		lsdc_reg_write32(ldev, LSDC_INT_REG, INT_CRTC0_VS_EN | INT_CRTC1_VS_EN);
    55	
    56		return IRQ_HANDLED;
    57	}
    58	
    59	
    60	/* Function to be called when the IRQ occurs */
    61	irqreturn_t lsdc_irq_handler_cb(int irq, void *arg)
    62	{
    63		struct drm_device *ddev = arg;
    64		struct lsdc_device *ldev = to_lsdc(ddev);
    65	
    66		/* Read & Clear the interrupt status */
    67		ldev->irq_status = lsdc_reg_read32(ldev, LSDC_INT_REG);
    68		if ((ldev->irq_status & INT_STATUS_MASK) == 0) {
  > 69			drm_warn(ddev, "no interrupt occurs\n");

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