drm/loongson: Introduce component framework support
Subsystems (3)
v5 cover drm/loongson: Introduce component framework support
Introduce component framework to bind modules and to avoid potential cyclic dependency problem.
v1 -> v2:
* Squash patch 0002 and patch 0003 into one
* Fill typos and improve commit message
v2 -> v3:
* Squash all patch into one
* Create another platform device as drm proxy master.
* Make LSDC PCI driver as a subcomponent as well.
v3 -> v4:
* Split sharable structure from struct lsdc_device.
* Make LSDC as a subcomponent.
v4 -> v5:
* Split to two patch.
* Fix typos and cleanup.
Tested with ls3a6000+ls7a2000, dmesg | grep loongson:
[ 10.357813] loongson.lsdc 0000:00:06.1: Found LS7A2000 bridge chipset, revision: 2 [ 10.370737] loongson.lsdc 0000:00:06.1: i2c-6(sda pin mask=1, scl pin mask=2) created [ 10.466747] loongson.lsdc 0000:00:06.1: i2c-7(sda pin mask=4, scl pin mask=8) created [ 10.479231] loongson.lsdc 0000:00:06.1: lsdc.output.agent.0 probed, type: HDMI-or-VGA [ 10.507553] loongson.lsdc 0000:00:06.1: lsdc.output.agent.1 probed, type: HDMI [ 11.595162] loongson.loonggpu 0000:00:06.0: LoongGPU(TM) PCI driver probed [ 11.699961] loongson.drm.proxy loongson.drm.proxy: probed [ 11.717768] loongson.lsdc 0000:00:06.1: [drm] Dedicated vram start: 0xe0020000000, size: 256MiB [ 11.727041] loongson.lsdc 0000:00:06.1: [drm] dc: 400MHz, gmc: 1200MHz, gpu: 480MHz [ 11.735138] loongson.drm.proxy loongson.drm.proxy: bound lsdc.output.agent.0 (ops lsdc_output_component_ops [loongson]) [ 11.746343] loongson.drm.proxy loongson.drm.proxy: bound lsdc.output.agent.1 (ops lsdc_output_component_ops [loongson]) [ 11.763218] loongson.lsdc 0000:00:06.1: lsdc irq: 61 [ 11.768258] loongson.drm.proxy loongson.drm.proxy: bound 0000:00:06.1 (ops lsdc_pci_component_ops [loongson]) [ 11.778138] loongson.lsdc 0000:00:06.1: [drm] LoongGPU(TM): LG110, revision: 0, Host: LS7A2000 [ 11.786711] loongson.lsdc 0000:00:06.1: [drm] LoongGPU(TM) irq: 62 [ 11.792853] loongson.drm.proxy loongson.drm.proxy: bound 0000:00:06.0 (ops loonggpu_pci_component_ops [loongson]) [ 11.843337] loongson.lsdc 0000:00:06.1: [drm] VRAM: 16384 pages ready [ 11.849757] loongson.lsdc 0000:00:06.1: [drm] GTT: 32768 pages ready [ 11.856399] [drm] Initialized loongson 1.0.0 for 0000:00:06.1 on minor 1 [ 11.931176] loongson.lsdc 0000:00:06.1: [drm] fb0: loongsondrmfb frame buffer device [ 11.963180] loongson: total 4 drivers registered [ 16.040603] loongson.lsdc 0000:00:06.1: vgaarb: VGA decodes changed: olddecodes=io+mem,decodes=none:owns=io+mem
Tested with ls3a5000+ls7a1000, dmesg | grep loongson:
[ 10.887229] loongson.lsdc 0000:00:06.1: Found LS7A1000 bridge chipset, revision: 1 [ 10.907694] loongson.lsdc 0000:00:06.1: i2c-6(sda pin mask=1, scl pin mask=2) created [ 10.940652] loongson.lsdc 0000:00:06.1: i2c-7(sda pin mask=4, scl pin mask=8) created [ 10.973292] loongson.lsdc 0000:00:06.1: lsdc.output.agent.0 probed, type: DVO [ 10.993424] loongson.lsdc 0000:00:06.1: lsdc.output.agent.1 probed, type: DVO [ 11.011791] loongson.drm.proxy loongson.drm.proxy: probed [ 11.048820] loongson.lsdc 0000:00:06.1: [drm] Dedicated vram start: 0xe0030000000, size: 64MiB [ 11.087580] loongson.lsdc 0000:00:06.1: [drm] dc: 264MHz, gmc: 529MHz, gpu: 529MHz [ 11.095885] loongson.drm.proxy loongson.drm.proxy: bound lsdc.output.agent.0 (ops lsdc_output_component_ops [loongson]) [ 11.106794] loongson.drm.proxy loongson.drm.proxy: bound lsdc.output.agent.1 (ops lsdc_output_component_ops [loongson]) [ 11.128480] loongson.lsdc 0000:00:06.1: lsdc irq: 55 [ 11.135618] loongson.drm.proxy loongson.drm.proxy: bound 0000:00:06.1 (ops lsdc_pci_component_ops [loongson]) [ 11.146096] loongson.lsdc 0000:00:06.1: [drm] VRAM: 4096 pages ready [ 11.152492] loongson.lsdc 0000:00:06.1: [drm] GTT: 32768 pages ready [ 11.159720] [drm] Initialized loongson 1.0.0 for 0000:00:06.1 on minor 0 [ 11.243566] loongson.lsdc 0000:00:06.1: [drm] fb0: loongsondrmfb frame buffer device [ 11.285817] loongson: total 4 drivers registered
Tested with builtin debugfs interface:
[root@fedora 0]# cd /sys/kernel/debug/dri/0000\:00\:06.1/ [root@fedora 0000:00:06.1]# ls
benchmark clients crtc-1 framebuffer HDMI-A-1 mm vram_mm bos clocks encoder-0 gem_names HDMI-A-2 name chips crtc-0 encoder-1 gtt_mm internal_clients state
[root@fedora 0000:00:06.1]# cat bos
bo[0000][0000000033d33c9c]: size: 8112KiB VRAM offset: 0
bo[0001][0000000059581d0a]: size: 8112KiB VRAM offset: 7ec000
bo[0002][00000000e7eec263]: size: 16KiB VRAM offset: 0
bo[0003][00000000d4fb6ef2]: size: 16KiB VRAM offset: fff8000
Pinned BO size: VRAM: 8128KiB, GTT: 0 KiB
[root@fedora 0000:00:06.1]# cat chips
Running on cpu 0xc0, cpu revision: 0x11
Contained in: LS7A2000 bridge chipset
[root@fedora 0000:00:06.1]# cat benchmark
Copy bo of 8100KiB 60 times from GTT to GTT in 48ms: 10125MB/s Copy bo of 8100KiB 60 times from GTT to VRAM in 104ms: 4673MB/s Copy bo of 8100KiB 60 times from VRAM to GTT in 13480ms: 36MB/s
Also run IGT kms_flip and fbdev tests, no obvious problems found.
Sui Jingfeng (2):
drm/loongson: Introduce component framework support drm/loongson: Add dummy gpu driver as a subcomponent
drivers/gpu/drm/loongson/Makefile | 5 + drivers/gpu/drm/loongson/loonggpu_pci_drv.c | 163 +++++++++ drivers/gpu/drm/loongson/loonggpu_pci_drv.h | 35 ++ drivers/gpu/drm/loongson/loongson_device.c | 30 ++ drivers/gpu/drm/loongson/loongson_drv.c | 299 +++++++++++++++ drivers/gpu/drm/loongson/loongson_drv.h | 108 ++++++ drivers/gpu/drm/loongson/loongson_module.c | 84 ++++- drivers/gpu/drm/loongson/loongson_module.h | 32 ++ drivers/gpu/drm/loongson/lsdc_benchmark.c | 12 +- drivers/gpu/drm/loongson/lsdc_benchmark.h | 2 +- drivers/gpu/drm/loongson/lsdc_crtc.c | 4 +- drivers/gpu/drm/loongson/lsdc_debugfs.c | 41 +-- drivers/gpu/drm/loongson/lsdc_drv.c | 346 +++++------------- drivers/gpu/drm/loongson/lsdc_drv.h | 89 +---- drivers/gpu/drm/loongson/lsdc_gem.c | 42 ++- drivers/gpu/drm/loongson/lsdc_gem.h | 13 + drivers/gpu/drm/loongson/lsdc_gfxpll.c | 33 +- drivers/gpu/drm/loongson/lsdc_gfxpll.h | 3 +- drivers/gpu/drm/loongson/lsdc_i2c.c | 55 ++- drivers/gpu/drm/loongson/lsdc_i2c.h | 21 +- drivers/gpu/drm/loongson/lsdc_output.c | 183 +++++++++ drivers/gpu/drm/loongson/lsdc_output.h | 33 +- drivers/gpu/drm/loongson/lsdc_output_7a1000.c | 6 +- drivers/gpu/drm/loongson/lsdc_output_7a2000.c | 20 +- drivers/gpu/drm/loongson/lsdc_pixpll.c | 4 +- drivers/gpu/drm/loongson/lsdc_plane.c | 4 +- drivers/gpu/drm/loongson/lsdc_ttm.c | 70 ++-- drivers/gpu/drm/loongson/lsdc_ttm.h | 4 +- 28 files changed, 1233 insertions(+), 508 deletions(-) create mode 100644 drivers/gpu/drm/loongson/loonggpu_pci_drv.c create mode 100644 drivers/gpu/drm/loongson/loonggpu_pci_drv.h create mode 100644 drivers/gpu/drm/loongson/loongson_drv.c create mode 100644 drivers/gpu/drm/loongson/loongson_drv.h create mode 100644 drivers/gpu/drm/loongson/lsdc_output.c
Signature · 1 line
2.43.0
PATCH v5 1/2 drm/loongson: Introduce component framework support
In some display subsystems, the functionality of a PCIe device might be too complex to manage with a single driver. A split of the functionality into child devices can help to achieve better modularity. For example, KMS drivers who have dependencies on external modules will suffer from the deferral probe problem. The problem is that the DRM driver has to tear down everything when it receives '-EPROBE_DEFER', even though the independent part of the driver is not related to this error.
The idea is to migrate (offload) the dependency to submodules, creating submodule by creating platform devices manually during driver load time. Submodules are functional as agents, which will be responsible for attaching needed external modules for the main body of the whole KMS driver. Submodules are also responsible for returning '-EPROBE_DEFER' to the driver core if it needs to do so.
Make LSDC PCI driver as a subcomponent and creating a platform device as a DRM proxy, which will attach the common DRM routines to our hardware after all submodules bound. The proxy is a fake master which is working at the foreground.
Move DRM-related codes into the loongson_drm_master_bind(), move output related things into the submodule, because the output hardware units are relatively standalone IPs.
Initialize the GPIO-I2Cs in the driver probe() of the LSDC PCIe device, tie its lifetime to the LSDC.
Assign GFX PLL, TTM memory manager part, and power management part to the DRM proxy, as those entities do not belong to the LSDC itself. They are common resources.
--- drivers/gpu/drm/loongson/Makefile | 2 + drivers/gpu/drm/loongson/loongson_device.c | 30 ++ drivers/gpu/drm/loongson/loongson_drv.c | 298 +++++++++++++++ drivers/gpu/drm/loongson/loongson_drv.h | 108 ++++++ drivers/gpu/drm/loongson/loongson_module.c | 80 +++- drivers/gpu/drm/loongson/loongson_module.h | 31 ++ drivers/gpu/drm/loongson/lsdc_benchmark.c | 12 +- drivers/gpu/drm/loongson/lsdc_benchmark.h | 2 +- drivers/gpu/drm/loongson/lsdc_crtc.c | 4 +- drivers/gpu/drm/loongson/lsdc_debugfs.c | 41 +-- drivers/gpu/drm/loongson/lsdc_drv.c | 346 +++++------------- drivers/gpu/drm/loongson/lsdc_drv.h | 89 +---- drivers/gpu/drm/loongson/lsdc_gem.c | 42 ++- drivers/gpu/drm/loongson/lsdc_gem.h | 13 + drivers/gpu/drm/loongson/lsdc_gfxpll.c | 33 +- drivers/gpu/drm/loongson/lsdc_gfxpll.h | 3 +- drivers/gpu/drm/loongson/lsdc_i2c.c | 55 ++- drivers/gpu/drm/loongson/lsdc_i2c.h | 21 +- drivers/gpu/drm/loongson/lsdc_output.c | 183 +++++++++ drivers/gpu/drm/loongson/lsdc_output.h | 33 +- drivers/gpu/drm/loongson/lsdc_output_7a1000.c | 6 +- drivers/gpu/drm/loongson/lsdc_output_7a2000.c | 20 +- drivers/gpu/drm/loongson/lsdc_pixpll.c | 4 +- drivers/gpu/drm/loongson/lsdc_plane.c | 4 +- drivers/gpu/drm/loongson/lsdc_ttm.c | 70 ++-- drivers/gpu/drm/loongson/lsdc_ttm.h | 4 +- 26 files changed, 1026 insertions(+), 508 deletions(-) create mode 100644 drivers/gpu/drm/loongson/loongson_drv.c create mode 100644 drivers/gpu/drm/loongson/loongson_drv.h create mode 100644 drivers/gpu/drm/loongson/lsdc_output.c
drivers/gpu/drm/loongson/Makefile +2 -0
@@ -9,6 +9,7 @@ loongson-y := \ lsdc_gfxpll.o \ lsdc_i2c.o \ lsdc_irq.o \ + lsdc_output.o \ lsdc_output_7a1000.o \ lsdc_output_7a2000.o \ lsdc_plane.o \
@@ -17,6 +18,7 @@ loongson-y := \ lsdc_ttm.o loongson-y += loongson_device.o \ + loongson_drv.o \ loongson_module.o obj-$(CONFIG_DRM_LOONGSON) += loongson.o
drivers/gpu/drm/loongson/loongson_device.c +30 -0
@@ -4,6 +4,7 @@*/ #include <linux/pci.h> +#include <linux/platform_device.h> #include "lsdc_drv.h"
@@ -100,3 +101,32 @@ lsdc_device_probe(struct pci_dev *pdev, enum loongson_chip_id chip_id) {return __chip_id_desc_table[chip_id]; } + +static void loongson_device_postfini (void *data) +{ +struct platform_device *proxy = data; + +platform_device_unregister (proxy); +} + +int loongson_device_preinit (struct device *parent) +{ +struct platform_device *proxy; +int ret; + + proxy =platform_device_register_resndata (parent, +"loongson.drm.proxy" , +PLATFORM_DEVID_NONE , +NULL ,0 , +NULL ,0 ); +if (IS_ERR (proxy)) { +dev_err (parent,"failed to register loongson proxy device\n" ); +return PTR_ERR (proxy); + } + + ret =devm_add_action_or_reset (parent, loongson_device_postfini, proxy); +if (ret) +return ret; + +return 0 ; +}
drivers/gpu/drm/loongson/loongson_drv.c new file +298 -0
298 lines not on this page · raw message
drivers/gpu/drm/loongson/loongson_drv.h new file +108 -0
108 lines not on this page · raw message
drivers/gpu/drm/loongson/loongson_module.c +78 -2
101 lines not on this page · raw message
drivers/gpu/drm/loongson/loongson_module.h +31 -0
@@ -6,7 +6,38 @@#ifndef __LOONGSON_MODULE_H__#define __LOONGSON_MODULE_H__ +#define DRIVER_AUTHOR "Sui Jingfeng <[email protected]>" +#define DRIVER_NAME "loongson" +#define DRIVER_DESC "drm driver for loongson graphics" +#define DRIVER_DATE "20220701" +#define DRIVER_MAJOR 1 +#define DRIVER_MINOR 0 +#define DRIVER_PATCHLEVEL 0 + +enum loongson_chip_id { +CHIP_LS7A1000 =0 , +CHIP_LS7A2000 =1 , +CHIP_LS_LAST , +}; + +enum loongson_driver_type { +LOONGSON_DRIVER_FLAG_UNKNOWN =0 , +LOONGSON_DRIVER_FLAG_FAKE_MASTER =1 , +LOONGSON_DRIVER_FLAG_PCI =2 , +LOONGSON_DRIVER_FLAG_PLATFORM =4 , +}; + +struct loongson_driver_info { +struct device_driver *driver; +u64 type; +}; + +const struct loongson_driver_info *loongson_get_driver_info_array (int *num); +extern int loongson_vblank; +extern struct pci_driver lsdc_pci_driver; +extern struct platform_driver lsdc_output_platform_driver; +extern struct platform_driver loongson_drm_platform_driver;#endif
drivers/gpu/drm/loongson/lsdc_benchmark.c +6 -6
@@ -5,6 +5,7 @@#include <drm/drm_debugfs.h> +#include "loongson_drv.h" #include "lsdc_benchmark.h" #include "lsdc_drv.h" #include "lsdc_gem.h"
@@ -60,7 +61,7 @@ static void lsdc_copy_gtt_to_gtt_cpu(struct lsdc_bo *src_bo,lsdc_bo_kunmap (dst_bo); } -static void lsdc_benchmark_copy(struct lsdc_device *ldev, +static void lsdc_benchmark_copy(struct drm_device *ddev, unsigned int size, unsigned int n, u32 src_domain,
@@ -68,7 +69,6 @@ static void lsdc_benchmark_copy(struct lsdc_device *ldev,lsdc_copy_proc_t copy_proc, struct drm_printer *p) { - struct drm_device *ddev = &ldev->base; struct lsdc_bo *src_bo;struct lsdc_bo *dst_bo;unsigned long start_jiffies;
@@ -100,12 +100,12 @@ static void lsdc_benchmark_copy(struct lsdc_device *ldev, time, throughput); } -int lsdc_show_benchmark_copy (struct lsdc_device *ldev,struct drm_printer *p) +int lsdc_show_benchmark_copy (struct drm_device *ddev,struct drm_printer *p) {unsigned int buffer_size =1920 *1080 *4 ;unsigned int iteration =60 ; - lsdc_benchmark_copy(ldev, + lsdc_benchmark_copy(ddev, buffer_size, iteration, LSDC_GEM_DOMAIN_GTT,
@@ -113,7 +113,7 @@ int lsdc_show_benchmark_copy(struct lsdc_device *ldev, struct drm_printer *p) lsdc_copy_gtt_to_gtt_cpu, p); - lsdc_benchmark_copy(ldev, + lsdc_benchmark_copy(ddev, buffer_size, iteration, LSDC_GEM_DOMAIN_GTT,
@@ -121,7 +121,7 @@ int lsdc_show_benchmark_copy(struct lsdc_device *ldev, struct drm_printer *p) lsdc_copy_gtt_to_vram_cpu, p); - lsdc_benchmark_copy(ldev, + lsdc_benchmark_copy(ddev, buffer_size, iteration, LSDC_GEM_DOMAIN_VRAM,
drivers/gpu/drm/loongson/lsdc_benchmark.h +1 -1
@@ -8,6 +8,6 @@#include "lsdc_drv.h" -int lsdc_show_benchmark_copy (struct lsdc_device *ldev,struct drm_printer *p); +int lsdc_show_benchmark_copy (struct drm_device *ddev,struct drm_printer *p);#endif
drivers/gpu/drm/loongson/lsdc_crtc.c +2 -2
@@ -84,7 +84,7 @@ static void lsdc_crtc0_enable(struct lsdc_crtc *lcrtc)* something if it happens. */ if (val &CRTC_ANCHORED ) { -drm_warn (&ldev->base,"%s stall\n" , lcrtc->base.name); +drm_warn (ldev->drm,"%s stall\n" , lcrtc->base.name);return lsdc_crtc0_soft_reset (lcrtc); }
@@ -112,7 +112,7 @@ static void lsdc_crtc1_enable(struct lsdc_crtc *lcrtc)*/ val =lsdc_rreg32 (ldev,LSDC_CRTC1_CFG_REG );if (val &CRTC_ANCHORED ) { -drm_warn (&ldev->base,"%s stall\n" , lcrtc->base.name); +drm_warn (ldev->drm,"%s stall\n" , lcrtc->base.name);return lsdc_crtc1_soft_reset (lcrtc); }
drivers/gpu/drm/loongson/lsdc_debugfs.c +9 -32
84 lines not on this page · raw message
drivers/gpu/drm/loongson/lsdc_drv.c +85 -261
478 lines not on this page · raw message
drivers/gpu/drm/loongson/lsdc_drv.h +16 -73
155 lines not on this page · raw message
drivers/gpu/drm/loongson/lsdc_gem.c +28 -14
95 lines not on this page · raw message
drivers/gpu/drm/loongson/lsdc_gem.h +13 -0
@@ -6,9 +6,22 @@#ifndef __LSDC_GEM_H__#define __LSDC_GEM_H__ +#include <linux/types.h> +#include <drm/drm_device.h> #include <drm/drm_gem.h> +struct loongson_gem { +/* @mutex: protect objects list */ +struct mutex mutex; +struct list_head objects; +}; + +struct lsdc_bo ; + +void lsdc_gem_list_add_lbo (struct drm_device *ddev,struct lsdc_bo *lbo); +void lsdc_gem_list_rm_lbo (struct drm_device *ddev,struct lsdc_bo *lbo); +struct drm_gem_object * lsdc_prime_import_sg_table(struct drm_device *ddev, struct dma_buf_attachment *attach,
drivers/gpu/drm/loongson/lsdc_gfxpll.c +9 -24
@@ -10,6 +10,7 @@#include <drm/drm_print.h> #include "lsdc_drv.h" +#include "lsdc_gfxpll.h" /* * GFX PLL is the PLL used by DC, GMC and GPU, the structure of the GFX PLL
@@ -143,8 +144,6 @@ static void loongson_gfxpll_fini(struct drm_device *ddev, void *data)struct loongson_gfxpll *this = (struct loongson_gfxpll *)data;iounmap (this->mmio); - -kfree (this); }static int loongson_gfxpll_init (struct loongson_gfxpll *const this)
@@ -160,7 +159,7 @@ static int loongson_gfxpll_init(struct loongson_gfxpll * const this) this->funcs->return 0 ; +return drmm_add_action_or_reset (this->ddev, loongson_gfxpll_fini, this); }static const struct loongson_gfxpll_funcs lsdc_gmc_gpu_funcs = {
@@ -170,30 +169,16 @@ static const struct loongson_gfxpll_funcs lsdc_gmc_gpu_funcs = { .print = loongson_gfxpll_print, }; -int loongson_gfxpll_create (struct drm_device *ddev, -struct loongson_gfxpll **ppout) +int loongson_gfxpll_preinit (struct drm_device *ddev) { -struct lsdc_device *ldev =to_lsdc (ddev); -const struct loongson_gfx_desc *gfx =to_loongson_gfx (ldev->descp); -struct loongson_gfxpll *this; -int ret; - - this =kzalloc (sizeof (*this),GFP_KERNEL ); -if (IS_ERR_OR_NULL (this)) -return -ENOMEM ; +struct loongson_drm *ldrm =to_loongson_drm (ddev); +const struct loongson_gfx_desc *gfxinfo = ldrm->gfxinfo; +struct loongson_gfxpll *this = &ldrm->gfxpll; this->ddev = ddev; - this->reg_size = gfx->gfxpll.reg_size; - this->reg_base = gfx->conf_reg_base + gfx->gfxpll.reg_offset; + this->reg_size = gfxinfo->gfxpll.reg_size; + this->reg_base = gfxinfo->conf_reg_base + gfxinfo->gfxpll.reg_offset; this->funcs = &lsdc_gmc_gpu_funcs; - ret = this->funcs->init (this); -if (unlikely (ret)) { -kfree (this); -return ret; - } - - *ppout = this; - -return drmm_add_action_or_reset (ddev, loongson_gfxpll_fini, this); +return this->funcs->init (this); }
drivers/gpu/drm/loongson/lsdc_gfxpll.h +1 -2
@@ -46,7 +46,6 @@ struct loongson_gfxpll { struct loongson_gfxpll_parms parms; }; -int loongson_gfxpll_create (struct drm_device *ddev, -struct loongson_gfxpll **ppout); +int loongson_gfxpll_preinit (struct drm_device *ddev);#endif
drivers/gpu/drm/loongson/lsdc_i2c.c +40 -15
113 lines not on this page · raw message
drivers/gpu/drm/loongson/lsdc_i2c.h +7 -14
@@ -9,21 +9,14 @@#include <linux/i2c.h> #include <linux/i2c-algo-bit.h> -struct lsdc_i2c { -struct i2c_adapter adapter; -struct i2c_algo_bit_data bit; -struct drm_device *ddev; -void __iomem *dir_reg; -void __iomem *dat_reg; -/* pin bit mask */ -u8 sda; -u8 scl; -}; +struct lsdc_device ; +struct lsdc_desc ; -struct lsdc_display_pipe ; +int lsdc_create_i2c_chan (struct device *parent, +unsigned int index, +struct i2c_adapter **ppadapter); -int lsdc_create_i2c_chan (struct drm_device *ddev, -struct lsdc_display_pipe *dispipe, -unsigned int index); +int lsdc_i2c_preinit (struct device *parent, +const struct lsdc_desc *descp);#endif
drivers/gpu/drm/loongson/lsdc_output.c new file +183 -0
183 lines not on this page · raw message
drivers/gpu/drm/loongson/lsdc_output.h +30 -3
@@ -6,16 +6,43 @@#ifndef __LSDC_OUTPUT_H__#define __LSDC_OUTPUT_H__ -#include "lsdc_drv.h" +#include <linux/component.h> + +#include <drm/drm_encoder.h> +#include <drm/drm_connector.h> + +struct lsdc_desc ; + +struct lsdc_output { +struct device *dev; +struct drm_encoder encoder; +struct drm_connector connector; +unsigned int pipe; +}; + +static inline struct lsdc_output * +connector_to_lsdc_output (struct drm_connector *connector) +{ + return container_of(connector, struct lsdc_output, connector); +} + +static inline struct lsdc_output * +encoder_to_lsdc_output (struct drm_encoder *encoder) +{ + return container_of(encoder, struct lsdc_output, encoder); +}int ls7a1000_output_init (struct drm_device *ddev, -struct lsdc_display_pipe *dispipe, +struct lsdc_output *output,struct i2c_adapter *ddc,unsigned int index);int ls7a2000_output_init (struct drm_device *ldev, -struct lsdc_display_pipe *dispipe, +struct lsdc_output *output,struct i2c_adapter *ddc,unsigned int index); +int lsdc_output_preinit (struct device *parent, +const struct lsdc_desc *descp); +#endif
drivers/gpu/drm/loongson/lsdc_output_7a1000.c +2 -4
@@ -7,6 +7,7 @@#include <drm/drm_edid.h> #include <drm/drm_probe_helper.h> +#include "loongson_drv.h" #include "lsdc_drv.h" #include "lsdc_output.h"
@@ -140,11 +141,10 @@ static const struct drm_encoder_funcs ls7a1000_encoder_funcs[2] = { };int ls7a1000_output_init (struct drm_device *ddev, -struct lsdc_display_pipe *dispipe, +struct lsdc_output *output,struct i2c_adapter *ddc,unsigned int index) { -struct lsdc_output *output = &dispipe->output;struct drm_encoder *encoder = &output->encoder;struct drm_connector *connector = &output->connector;int ret;
@@ -162,8 +162,6 @@ int ls7a1000_output_init(struct drm_device *ddev,if (ret)return ret; -drm_info (ddev,"display pipe-%u has a DVO\n" , index); -drm_connector_helper_add (connector, &ls7a1000_dpi_connector_helpers);drm_connector_attach_encoder (connector, encoder);
drivers/gpu/drm/loongson/lsdc_output_7a2000.c +7 -13
@@ -10,6 +10,7 @@#include <drm/drm_edid.h> #include <drm/drm_probe_helper.h> +#include "loongson_drv.h" #include "lsdc_drv.h" #include "lsdc_output.h"
@@ -284,8 +285,7 @@ static int ls7a2000_hdmi_set_avi_infoframe(struct drm_encoder *encoder, struct drm_display_mode *mode) {struct lsdc_output *output =encoder_to_lsdc_output (encoder); -struct lsdc_display_pipe *dispipe =output_to_display_pipe (output); -unsigned int index = dispipe->index; +unsigned int index = output->pipe;struct drm_device *ddev = encoder->dev;struct lsdc_device *ldev =to_lsdc (ddev);struct hdmi_avi_infoframe infoframe;
@@ -335,8 +335,7 @@ static void ls7a2000_hdmi_atomic_disable(struct drm_encoder *encoder, struct drm_atomic_state *state) {struct lsdc_output *output =encoder_to_lsdc_output (encoder); -struct lsdc_display_pipe *dispipe =output_to_display_pipe (output); -unsigned int index = dispipe->index; +unsigned int index = output->pipe;struct drm_device *ddev = encoder->dev;struct lsdc_device *ldev =to_lsdc (ddev);u32 val;
@@ -360,8 +359,7 @@ static void ls7a2000_hdmi_atomic_enable(struct drm_encoder *encoder,struct drm_device *ddev = encoder->dev;struct lsdc_device *ldev =to_lsdc (ddev);struct lsdc_output *output =encoder_to_lsdc_output (encoder); -struct lsdc_display_pipe *dispipe =output_to_display_pipe (output); -unsigned int index = dispipe->index; +unsigned int index = output->pipe;u32 val;/* datasheet say it should larger than 48 */
@@ -415,7 +413,7 @@ static void ls7a2000_hdmi_phy_pll_config(struct lsdc_device *ldev, int fin, unsigned int index) { -struct drm_device *ddev = &ldev->base; +struct drm_device *ddev = ldev->drm;int count =0 ;u32 val;
@@ -482,8 +480,7 @@ static void ls7a2000_hdmi_atomic_mode_set(struct drm_encoder *encoder, struct drm_connector_state *conn_state) {struct lsdc_output *output =encoder_to_lsdc_output (encoder); -struct lsdc_display_pipe *dispipe =output_to_display_pipe (output); -unsigned int index = dispipe->index; +unsigned int index = output->pipe;struct drm_device *ddev = encoder->dev;struct lsdc_device *ldev =to_lsdc (ddev);struct drm_display_mode *mode = &crtc_state->mode;
@@ -512,11 +509,10 @@ static const struct drm_encoder_helper_funcs ls7a2000_encoder_helper_funcs = {* writing hdmi register do no harms. */ int ls7a2000_output_init (struct drm_device *ddev, -struct lsdc_display_pipe *dispipe, +struct lsdc_output *output,struct i2c_adapter *ddc,unsigned int pipe) { -struct lsdc_output *output = &dispipe->output;struct drm_encoder *encoder = &output->encoder;struct drm_connector *connector = &output->connector;int ret;
@@ -536,8 +532,6 @@ int ls7a2000_output_init(struct drm_device *ddev,if (ret)return ret; -drm_info (ddev,"display pipe-%u has HDMI %s\n" , pipe, pipe ?"" :"and/or VGA" ); -drm_connector_helper_add (connector, &ls7a2000_connector_helpers);drm_connector_attach_encoder (connector, encoder);
drivers/gpu/drm/loongson/lsdc_pixpll.c +1 -3
@@ -470,9 +470,7 @@ int lsdc_pixpll_init(struct lsdc_pixpll * const this, struct drm_device *ddev, unsigned int index) { -struct lsdc_device *ldev =to_lsdc (ddev); -const struct lsdc_desc *descp = ldev->descp; -const struct loongson_gfx_desc *gfx =to_loongson_gfx (descp); +const struct loongson_gfx_desc *gfx =to_loongson_gfxinfo (ddev); this->ddev = ddev; this->reg_size =8 ;
drivers/gpu/drm/loongson/lsdc_plane.c +2 -2
@@ -10,6 +10,7 @@#include <drm/drm_framebuffer.h> #include <drm/drm_gem_atomic_helper.h> +#include "loongson_drv.h" #include "lsdc_drv.h" #include "lsdc_regs.h" #include "lsdc_ttm.h"
@@ -40,10 +41,9 @@ static unsigned int lsdc_get_fb_offset(struct drm_framebuffer *fb,static u64 lsdc_fb_base_addr (struct drm_framebuffer *fb) { -struct lsdc_device *ldev =to_lsdc (fb->dev);struct lsdc_bo *lbo =gem_to_lsdc_bo (fb->obj[0 ]); -return lsdc_bo_gpu_offset (lbo) + ldev->vram_base; +return lsdc_bo_gpu_offset (lbo) +loongson_drm_vram_base (fb->dev); } static int lsdc_primary_atomic_check(struct drm_plane *plane,
drivers/gpu/drm/loongson/lsdc_ttm.c +35 -35
180 lines not on this page · raw message
drivers/gpu/drm/loongson/lsdc_ttm.h +2 -2
@@ -93,7 +93,7 @@ void lsdc_bo_clear(struct lsdc_bo *lbo);int lsdc_bo_evict_vram (struct drm_device *ddev); -int lsdc_ttm_init (struct lsdc_device *ldev); -void lsdc_ttm_debugfs_init (struct lsdc_device *ldev); +int lsdc_ttm_init (struct drm_device *ddev); +void lsdc_ttm_debugfs_init (struct drm_device *ddev);#endif
Signature · 1 line
2.43.0
…
Quoted 2 lines
+++
b/drivers/gpu/drm/loongson/loongson_drv.c(quoted diff) +0
-0@@ -0,0 +1,298 @@
…
Quoted 2 lines
(quoted diff) +2
-0+static int loongson_drm_freeze(struct drm_device *ddev) +{
…
Quoted 2 lines
drivers/gpu/drm/loongson/loongson_drv.c new file +2
-0+/* unpin all of buffers in the VRAM */ +mutex_lock (&ldrm->gem.mutex);
…
drivers/gpu/drm/loongson/loongson_drv.c line 176
Quoted 3 lines
drivers/gpu/drm/loongson/loongson_drv.c new file +3
-0+mutex_unlock (&ldrm->gem.mutex); + +lsdc_bo_evict_vram (ddev);
…
Under which circumstances would you become interested to apply a statement like “guard(mutex)(&ldrm->gem.mutex);”?
https://elixir.bootlin.com/linux/v6.10.2/source/include/linux/mutex.h#L196
Regards,
Markus
…
Quoted 2 lines
+++
b/drivers/gpu/drm/loongson/loongson_drv.h(quoted diff) +0
-0@@ -0,0 +1,108 @@
…
drivers/gpu/drm/loongson/loongson_drv.h line 8
Quoted 2 lines
drivers/gpu/drm/loongson/loongson_drv.h new file +2
-0+#ifndef __LOONGSON_DRV_H__ +#define __LOONGSON_DRV_H__
…
I suggest to omit leading underscores from such identifiers.
https://wiki.sei.cmu.edu/confluence/display/c/DCL37-C.+Do+not+declare+or+define+a+reserved+identifier
Regards,
Markus
Hi,
Quoted 10 lines · Markus Elfring
…
Quoted 2 lines
+++
b/drivers/gpu/drm/loongson/loongson_drv.h(quoted diff) +0
-0@@ -0,0 +1,108 @@…
drivers/gpu/drm/loongson/loongson_drv.h line 8
Quoted 2 lines
drivers/gpu/drm/loongson/loongson_drv.h new file +2
-0+#ifndef __LOONGSON_DRV_H__ +#define __LOONGSON_DRV_H__…
I suggest to omit leading underscores from such identifiers.
https://wiki.sei.cmu.edu/confluence/display/c/DCL37-C.+Do+not+declare+or+define+a+reserved+identifier
I suggest add this rules to the checkpatch.pl script,
It's more safe to follow *after* your suggestion is accepted.
After all, the checkpatch.pl is de-facto standard.
checkpatch.pl is happy about my patch for now.
Quoted 2 lines
Regards,
Markus
Signature · 2 lines
Best regards, Sui
Quoted 9 lines
Quoted 9 lines
…
Quoted 2 lines
+++
b/drivers/gpu/drm/loongson/loongson_drv.h(quoted diff) +0
-0@@ -0,0 +1,108 @@…
drivers/gpu/drm/loongson/loongson_drv.h line 8
Quoted 2 lines
drivers/gpu/drm/loongson/loongson_drv.h new file +2
-0+#ifndef __LOONGSON_DRV_H__ +#define __LOONGSON_DRV_H__…
I suggest to omit leading underscores from such identifiers.
…
Quoted 1 line
I suggest add this rules to the checkpatch.pl script,
…
I hope that you would also like to reduce risks according to undefined behaviour another bit.
https://wiki.sei.cmu.edu/confluence/display/c/DCL37-C.+Do+not+declare+or+define+a+reserved+identifier#DCL37C.Donotdeclareordefineareservedidentifier-AutomatedDetection
Regards,
Markus
…
Quoted 2 lines
+++
b/drivers/gpu/drm/loongson/loongson_drv.c(quoted diff) +0
-0@@ -0,0 +1,298 @@
…
Quoted 2 lines
(quoted diff) +2
-0+static int loongson_drm_driver_probe(struct platform_device *pdev) +{
…
Quoted 1 line
drivers/gpu/drm/loongson/loongson_drv.c new file +1
-0+dev_info (&pdev->dev,"probed\n" );
…
Quoted 1 line
+}
…
Do you find such information really relevant?
Regards,
Markus
Hi,
Quoted 7 lines · Markus Elfring
…
Quoted 2 lines
+++
b/drivers/gpu/drm/loongson/loongson_drv.c(quoted diff) +0
-0@@ -0,0 +1,298 @@…
Quoted 2 lines
(quoted diff) +2
-0+static int loongson_drm_driver_probe(struct platform_device *pdev) +{…
Quoted 6 lines
Quoted 1 line
drivers/gpu/drm/loongson/loongson_drv.c new file +1
-0+dev_info (&pdev->dev,"probed\n" );…
Quoted 1 line
+}
…
Do you find such information really relevant?
This helps to see the probe order of all drivers,
this also help us to know the name of the fake master device.
Quoted 2 lines
Regards,
Markus
Signature · 2 lines
Best regards, Sui
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Sui,
kernel test robot noticed the following build warnings:
[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on linus/master v6.11-rc1 next-20240802] [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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sui-Jingfeng/drm-loongson-Introduce-component-framework-support/20240728-233029 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20240728152858.346211-2-sui.jingfeng%40linux.dev patch subject: [PATCH v5 1/2] drm/loongson: Introduce component framework support config: mips-randconfig-r111-20240802 (https://download.01.org/0day-ci/archive/20240803/[email protected]/config) compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 430b90f04533b099d788db2668176038be38c53b) reproduce: (https://download.01.org/0day-ci/archive/20240803/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/gpu/drm/loongson/lsdc_drv.c:154:28: sparse: sparse: symbol 'lsdc_pci_component_ops' was not declared. Should it be static?
vim +/lsdc_pci_component_ops +154 drivers/gpu/drm/loongson/lsdc_drv.c
153
> 154 const struct component_ops lsdc_pci_component_ops = { 155 .bind = lsdc_pci_component_bind,
156 .unbind = lsdc_pci_component_unbind,
157 };
158
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v5 2/2 drm/loongson: Add dummy gpu driver as a subcomponent
In reply to Sui JingfengLoongson Graphics are PCIe multifunctional devices, the GPU and the display controller are two distinct devices. Despite hardware units that come along with PCIe are already ready to be driven by the time the driver is loaded, drm/loongson driver still need to wait all of its dependencies ready before it can register DRM service to user space. The newly introduced component framework allow us to use loose coupling design. Therefore, add a dummy driver for the GPU, it is functional as a subcomponent as well.
--- drivers/gpu/drm/loongson/Makefile | 3 + drivers/gpu/drm/loongson/loonggpu_pci_drv.c | 163 ++++++++++++++++++++ drivers/gpu/drm/loongson/loonggpu_pci_drv.h | 35 +++++ drivers/gpu/drm/loongson/loongson_drv.c | 1 + drivers/gpu/drm/loongson/loongson_module.c | 4 + drivers/gpu/drm/loongson/loongson_module.h | 1 + 6 files changed, 207 insertions(+) create mode 100644 drivers/gpu/drm/loongson/loonggpu_pci_drv.c create mode 100644 drivers/gpu/drm/loongson/loonggpu_pci_drv.h
drivers/gpu/drm/loongson/Makefile +3 -0
@@ -17,6 +17,9 @@ loongson-y := \ lsdc_probe.o \ lsdc_ttm.o +loongson-y += \ + loonggpu_pci_drv.o + loongson-y += loongson_device.o \ loongson_drv.o \ loongson_module.o
drivers/gpu/drm/loongson/loonggpu_pci_drv.c new file +163 -0
163 lines not on this page · raw message
drivers/gpu/drm/loongson/loonggpu_pci_drv.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Authors: +* Sui Jingfeng <[email protected]> +*/ + +#ifndef __LOONGGPU_PCI_DRV_H__ +#define __LOONGGPU_PCI_DRV_H__ + +#include <linux/component.h> +#include <linux/pci.h> + +struct loonggpu_device { +struct pci_dev *pdev; +struct drm_device *drm; + +void __iomem *reg_base; +int irq; + +u32 ver_major; +u32 ver_minor; +u32 revision; +}; + +static inline u32 loong_rreg32 (struct loonggpu_device *ldev,u32 offset) +{ +return readl (ldev->reg_base + offset); +} + +static inline void loong_wreg32 (struct loonggpu_device *ldev,u32 offset,u32 val) +{ +writel (val, ldev->reg_base + offset); +} + +#endif
drivers/gpu/drm/loongson/loongson_drv.c +1 -0
@@ -19,6 +19,7 @@#include "loongson_drv.h" #include "loongson_module.h" +#include "loonggpu_pci_drv.h" #include "lsdc_drv.h" #include "lsdc_gem.h" #include "lsdc_output.h"
drivers/gpu/drm/loongson/loongson_module.c +4 -0
@@ -27,6 +27,10 @@ static const struct loongson_driver_info loongson_driver_array[] = { .driver = &lsdc_pci_driver.driver, .type = LOONGSON_DRIVER_FLAG_PCI, }, + { + .driver = &loonggpu_pci_driver.driver, + .type = LOONGSON_DRIVER_FLAG_PCI, + }, { .driver = &loongson_drm_platform_driver.driver, .type = LOONGSON_DRIVER_FLAG_PLATFORM | LOONGSON_DRIVER_FLAG_FAKE_MASTER,
drivers/gpu/drm/loongson/loongson_module.h +1 -0
@@ -37,6 +37,7 @@ const struct loongson_driver_info *loongson_get_driver_info_array(int *num);extern int loongson_vblank;extern struct pci_driver lsdc_pci_driver; +extern struct pci_driver loonggpu_pci_driver;extern struct platform_driver lsdc_output_platform_driver;extern struct platform_driver loongson_drm_platform_driver;
Signature · 1 line
2.43.0
Re: [PATCH v5 2/2] drm/loongson: Add dummy gpu driver as a subcomponent
…
Quoted 1 line
the driver is loaded, drm/loongson driver still need to wait all of
needs to wait on …?
…
Quoted 1 line
design. Therefore, add a dummy driver for the GPU, …
Is there a need to reconsider the categorisation and usability descriptions another bit for such a software component?
Regards,
Markus
Re: [PATCH v5 2/2] drm/loongson: Add dummy gpu driver as a subcomponent
Hi,
Quoted 9 lines · Markus Elfring
…
Quoted 1 line
the driver is loaded, drm/loongson driver still need to wait all of
needs to wait on …?
…
Quoted 1 line
design. Therefore, add a dummy driver for the GPU, …
Is there a need to reconsider the categorisation and usability descriptions another bit for such a software component?
For honoring the framework and testing the framework purpose.
The GPU can possibly be the master of the all sub-components, this definitely need some extra
consideration and negotiation with the DC and the fake master device. Depend on configuration
and user space expectation. The problem should be solved earlier.
Quoted 2 lines
Regards,
Markus
Signature · 2 lines
Best regards, Sui
Re: [PATCH v5 2/2] drm/loongson: Add dummy gpu driver as a subcomponent
In reply to Sui Jingfeng…
drivers/gpu/drm/loongson/Makefile loongson-y := \ · line 23
Quoted 9 lines
+++ b/drivers/gpu/drm/loongson/Makefile
drivers/gpu/drm/loongson/Makefile +3
-0@@ -17,6 +17,9 @@ loongson-y := \ lsdc_probe.o \ lsdc_ttm.o +loongson-y += \ + loonggpu_pci_drv.o + loongson-y += loongson_device.o \
…
Why do you propose to adjust the macro contents multiple times here? (Can it be sufficient to specify the desired file dependencies directly?)
Regards,
Markus