drm/loongson: Introduce component framework support
Subsystems (4)
v2 cover drm/loongson: Introduce component framework support
Introduce component framework to bind child and sibling devices, for better modularity and offload the deferral probe issue to submodule if it need to attach exterinal module someday. Also for better reflect the hardware layout.
Hardware units that come with PCIe are all ready to drive, but there are some board specific modules will return -EPROBE_DEFER to us. We need all submodules ready to use before we can register the drm device to userspace.
The idea is to device the exterinal module dependent part and exterinal module independent part. For example, the display controller and the GPIO-I2C just belong to exterinal module independent part. While the outputs are just belong to exterinal module dependent part.
We abstract the output ports as child devices, the output ports may consists of encoder phy and level shifter. Well, the GPU are standalone siblings relative to the DC. Those units are relatively separated hardware units from display controller itself.
By design, the display controller PCI(e) is selected as master, gpio-i2c go with master. Manually created virtual subdevice functional as agents for the master, it could return the -EPROBE_DEFER back to the drvier core. This allows the master don't have to tear down everything, thereore majority setups work can be preserved. The potential cyclic dependency problem can be solved then.
v1 -> v2:
* Squash patch 0002 and patch 0003 into one
* Fill type and improve commit message
Sui Jingfeng (3):
drm/loongson: Add a helper for creating child devices drm/loongson: Introduce component framework support drm/loongson: Add dummy gpu driver as a subcomponent
drivers/gpu/drm/loongson/Makefile | 4 + drivers/gpu/drm/loongson/loong_gpu_pci_drv.c | 90 ++++++++ drivers/gpu/drm/loongson/loong_gpu_pci_drv.h | 27 +++ drivers/gpu/drm/loongson/loongson_device.c | 42 ++++ drivers/gpu/drm/loongson/loongson_module.c | 26 ++- drivers/gpu/drm/loongson/loongson_module.h | 8 + drivers/gpu/drm/loongson/lsdc_drv.c | 217 +++++++++++------- drivers/gpu/drm/loongson/lsdc_drv.h | 45 +--- drivers/gpu/drm/loongson/lsdc_i2c.c | 5 +- drivers/gpu/drm/loongson/lsdc_i2c.h | 3 - drivers/gpu/drm/loongson/lsdc_output.c | 176 ++++++++++++++ drivers/gpu/drm/loongson/lsdc_output.h | 38 ++- drivers/gpu/drm/loongson/lsdc_output_7a1000.c | 3 +- drivers/gpu/drm/loongson/lsdc_output_7a2000.c | 17 +- 14 files changed, 564 insertions(+), 137 deletions(-) create mode 100644 drivers/gpu/drm/loongson/loong_gpu_pci_drv.c create mode 100644 drivers/gpu/drm/loongson/loong_gpu_pci_drv.h create mode 100644 drivers/gpu/drm/loongson/lsdc_output.c
Signature · 1 line
2.34.1
PATCH v2 1/3 drm/loongson: Add a helper for creating child devices
In some display subsystems, the functionality of a PCIe device may too complex to be managed by a single driver. A split of the functionality into child devices can helpful to achieve better modularity.
Another benefit is that we could migrate the dependency on exterinal modules to a submodule level with the helper created. For example, it's not uncommon that some exterinal module will return -EPROBE_DEFER to our driver during probe time. KMS driver has to tear down everything when it receives -EPROBE_DEFER, the problem is that it's completely not necessary and rising cyclic dependency problems if not process correctly.
Add the loongson_create_platform_device() function, which allows the KMS driver to create sub-devices for it. The manually created decice acts as agents for the principal part, migrate the potential issue to submodule.
--- drivers/gpu/drm/loongson/loongson_device.c | 42 ++++++++++++++++++++++ drivers/gpu/drm/loongson/lsdc_drv.h | 6 ++++ 2 files changed, 48 insertions(+)
drivers/gpu/drm/loongson/loongson_device.c +42 -0
@@ -4,6 +4,7 @@*/ #include <linux/pci.h> +#include <linux/platform_device.h> #include "lsdc_drv.h"
@@ -100,3 +101,44 @@ lsdc_device_probe(struct pci_dev *pdev, enum loongson_chip_id chip_id) {return __chip_id_desc_table[chip_id]; } + +int loongson_create_platform_device (struct device *parent, +const char *name,int id, +struct resource *pres, +void *data, +struct platform_device **ppdev) +{ +struct platform_device *pdev; +int ret; + + pdev =platform_device_alloc (name, id); +if (!pdev) +return -ENOMEM ; + + pdev->dev.parent = parent; + +if (pres) { + ret =platform_device_add_resources (pdev, pres,1 ); +if (ret) { +platform_device_put (pdev); +return ret; + } + } + +if (data) { +void *pdata =kmalloc (sizeof (void *),GFP_KERNEL ); + + *(void **)pdata = data; + pdev->dev.platform_data = pdata; + } + + ret =platform_device_add (pdev); +if (ret) { +platform_device_put (pdev); +return ret; + } + + *ppdev = pdev; + +return 0 ; +}
drivers/gpu/drm/loongson/lsdc_drv.h +6 -0
@@ -47,6 +47,12 @@ enum loongson_chip_id {const struct lsdc_desc *lsdc_device_probe (struct pci_dev *pdev,enum loongson_chip_id chip); +int loongson_create_platform_device (struct device *parent, +const char *name,int id, +struct resource *pres, +void *data, +struct platform_device **ppdev); +struct lsdc_kms_funcs ;/* DC specific */
Signature · 1 line
2.34.1
Re: [PATCH v2 1/3] drm/loongson: Add a helper for creating child devices
Quoted 63 lines · Sui Jingfeng
In some display subsystems, the functionality of a PCIe device may too complex to be managed by a single driver. A split of the functionality into child devices can helpful to achieve better modularity.
Another benefit is that we could migrate the dependency on exterinal modules to a submodule level with the helper created. For example, it's not uncommon that some exterinal module will return -EPROBE_DEFER to our driver during probe time. KMS driver has to tear down everything when it receives -EPROBE_DEFER, the problem is that it's completely not necessary and rising cyclic dependency problems if not process correctly.
Add the
loongson_create_platform_device()function, which allows the KMS driver to create sub-devices for it. The manually created decice acts as agents for the principal part, migrate the potential issue to submodule.Signed-off-by Sui Jingfeng <[email protected]>--- drivers/gpu/drm/loongson/loongson_device.c | 42 ++++++++++++++++++++++ drivers/gpu/drm/loongson/lsdc_drv.h | 6 ++++ 2 files changed, 48 insertions(+)drivers/gpu/drm/loongson/loongson_device.c +27
-0@@ -4,6 +4,7 @@*/ #include <linux/pci.h> +#include <linux/platform_device.h> #include "lsdc_drv.h" @@ -100,3 +101,44 @@ lsdc_device_probe(struct pci_dev *pdev, enum loongson_chip_id chip_id) {return __chip_id_desc_table[chip_id]; } + +int loongson_create_platform_device (struct device *parent, +const char *name,int id, +struct resource *pres, +void *data, +struct platform_device **ppdev) +{ +struct platform_device *pdev; +int ret; + + pdev =platform_device_alloc (name, id); +if (!pdev) +return -ENOMEM ; + + pdev->dev.parent = parent; + +if (pres) { + ret =platform_device_add_resources (pdev, pres,1 ); +if (ret) { +platform_device_put (pdev); +return ret; + } + } + +if (data) { +void *pdata =kmalloc (sizeof (void *),GFP_KERNEL );
drivers/gpu/drm/loongson/loongson_device.c lsdc_device_probe(struct pci_dev *pdev, enum loongson_chip_id chip_id) · line 139
Quoted 10 lines
drivers/gpu/drm/loongson/loongson_device.c +10
-0+ + *(void **)pdata = data; + pdev->dev.platform_data = pdata; + } + + ret =platform_device_add (pdev); +if (ret) { +platform_device_put (pdev); +return ret; + }
Please use platform_device_register_resndata().
Quoted 25 lines
drivers/gpu/drm/loongson/loongson_device.c +5
-0+ + *ppdev = pdev; + +return 0 ; +}drivers/gpu/drm/loongson/lsdc_drv.h +6
-0@@ -47,6 +47,12 @@ enum loongson_chip_id {const struct lsdc_desc *lsdc_device_probe (struct pci_dev *pdev,enum loongson_chip_id chip); +int loongson_create_platform_device (struct device *parent, +const char *name,int id, +struct resource *pres, +void *data, +struct platform_device **ppdev); +struct lsdc_kms_funcs ;/* DC specific */ Signature · 1 line
2.34.1
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v2 1/3] drm/loongson: Add a helper for creating child devices
In reply to Sui JingfengQuoted 1 line
In some display subsystems, the functionality of a PCIe device may too
might be?
…
Quoted 1 line
into child devices can helpful to …
be?
Quoted 1 line
Another benefit is that we could migrate the dependency on exterinal
external?
…
Quoted 1 line
and rising cyclic dependency problems if not process correctly.
processed?
…
Quoted 1 line
driver to create sub-devices for it. The manually created decice acts as
device?
Quoted 1 line
agents for the principal part, migrate the potential issue to submodule.
an agent?
Please improve your change descriptions considerably.
…
Quoted 1 line
+++
b/drivers/gpu/drm/loongson/loongson_device.c
…
Quoted 11 lines
drivers/gpu/drm/loongson/loongson_device.c +7
-0@@ -100,3 +101,44 @@ lsdc_device_probe(struct pci_dev *pdev, enum loongson_chip_id chip_id) {return __chip_id_desc_table[chip_id]; } + +int loongson_create_platform_device (struct device *parent, +const char *name,int id, +struct resource *pres, +void *data, +struct platform_device **ppdev) +{
…
Quoted 5 lines
drivers/gpu/drm/loongson/loongson_device.c +5
-0+ ret =platform_device_add_resources (pdev, pres,1 ); +if (ret) { +platform_device_put (pdev); +return ret; + }
…
drivers/gpu/drm/loongson/loongson_device.c lsdc_device_probe(struct pci_dev *pdev, enum loongson_chip_id chip_id) · line 139
Quoted 5 lines
drivers/gpu/drm/loongson/loongson_device.c +5
-0+ ret =platform_device_add (pdev); +if (ret) { +platform_device_put (pdev); +return ret; + }
…
Please use a goto chain for common exception handling.
https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a+goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+resources
Regards,
Markus
PATCH v2 2/3 drm/loongson: Introduce component framework support
In reply to Sui JingfengHardware units come with PCIe are actually all ready to be driven, but there has some board specific modules could return '-EPROBE_DEFER'. However, the driver needs all of the subcompoments ready to use before it can register the drm service to userspace.
Introduce the component framework to tackle such problems, move DRM device related code into loongson_drm_master_bind() function. Move output related things into subdriver. Display controller and GPIO-I2C goes with the PCIe master, sinch they has no dependency on exterinal modules.
While the outputs drivers, such as encoders and conectors, may has some dependency on exterinal modules. Those hardware units are relatively independent hardware IPs from the CRTC. Hence, offload them to submodules. This design allows subdriver return '-EPROBE_DEFER' to the driver core if it need to do so, the master drvier won't bind until all submodules are ready.
--- drivers/gpu/drm/loongson/Makefile | 1 + drivers/gpu/drm/loongson/loongson_module.c | 17 +- drivers/gpu/drm/loongson/loongson_module.h | 1 + drivers/gpu/drm/loongson/lsdc_drv.c | 205 +++++++++++------- drivers/gpu/drm/loongson/lsdc_drv.h | 31 +-- drivers/gpu/drm/loongson/lsdc_i2c.c | 5 +- drivers/gpu/drm/loongson/lsdc_i2c.h | 3 - drivers/gpu/drm/loongson/lsdc_output.c | 176 +++++++++++++++ drivers/gpu/drm/loongson/lsdc_output.h | 38 +++- drivers/gpu/drm/loongson/lsdc_output_7a1000.c | 3 +- drivers/gpu/drm/loongson/lsdc_output_7a2000.c | 17 +- 11 files changed, 367 insertions(+), 130 deletions(-) create mode 100644 drivers/gpu/drm/loongson/lsdc_output.c
drivers/gpu/drm/loongson/Makefile +1 -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 \
drivers/gpu/drm/loongson/loongson_module.c +16 -1
@@ -4,6 +4,7 @@*/ #include <linux/pci.h> +#include <linux/platform_device.h> #include <video/nomodeset.h>
@@ -19,15 +20,29 @@ module_param_named(vblank, loongson_vblank, int, 0400);static int __init loongson_module_init (void ) { +int ret; +if (!loongson_modeset ||video_firmware_drivers_only ())return -ENODEV ; -return pci_register_driver (&lsdc_pci_driver); + ret =platform_driver_register (&lsdc_output_port_platform_driver); +if (ret) +return ret; + + ret =pci_register_driver (&lsdc_pci_driver); +if (ret) { +platform_driver_unregister (&lsdc_output_port_platform_driver); +return ret; + } + +return 0 ; }module_init (loongson_module_init); static void __exit loongson_module_exit(void) {pci_unregister_driver (&lsdc_pci_driver); + +platform_driver_unregister (&lsdc_output_port_platform_driver); }module_exit (loongson_module_exit);
drivers/gpu/drm/loongson/loongson_module.h +1 -0
@@ -8,5 +8,6 @@extern int loongson_vblank;extern struct pci_driver lsdc_pci_driver; +extern struct platform_driver lsdc_output_port_platform_driver;#endif
drivers/gpu/drm/loongson/lsdc_drv.c +126 -79
314 lines not on this page · raw message
drivers/gpu/drm/loongson/lsdc_drv.h +4 -27
@@ -173,47 +173,22 @@ struct lsdc_cursor {struct lsdc_device *ldev; }; -struct lsdc_output { -struct drm_encoder encoder; -struct drm_connector connector; -}; - -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); -} -struct lsdc_display_pipe {struct lsdc_crtc crtc;struct lsdc_primary primary;struct lsdc_cursor cursor; -struct lsdc_output output; -struct lsdc_i2c *li2c; +struct lsdc_output *output;unsigned int index; }; -static inline struct lsdc_display_pipe * -output_to_display_pipe (struct lsdc_output *output) -{ - return container_of(output, struct lsdc_display_pipe, output); -} -struct lsdc_kms_funcs {irqreturn_t (*irq_handler)(int irq,void *arg);int (*create_i2c)(struct drm_device *ddev, -struct lsdc_display_pipe *dispipe,unsigned int index);int (*output_init)(struct drm_device *ddev, -struct lsdc_display_pipe *dispipe, +struct lsdc_output *output,struct i2c_adapter *ddc,unsigned int index);
@@ -290,6 +265,8 @@ struct lsdc_device {resource_size_t gtt_size;struct lsdc_display_pipe dispipe[LSDC_NUM_CRTC ]; +struct platform_device *child[LSDC_NUM_CRTC ]; +struct i2c_adapter *i2c[LSDC_NUM_CRTC ];struct lsdc_gem gem;
drivers/gpu/drm/loongson/lsdc_i2c.c +2 -3
@@ -115,7 +115,6 @@ static void lsdc_destroy_i2c(struct drm_device *ddev, void *data)* @index: output channel index, 0 for PIPE0, 1 for PIPE1 */ int lsdc_create_i2c_chan (struct drm_device *ddev, -struct lsdc_display_pipe *dispipe,unsigned int index) {struct lsdc_device *ldev =to_lsdc (ddev);
@@ -127,8 +126,6 @@ int lsdc_create_i2c_chan(struct drm_device *ddev,if (!li2c)return -ENOMEM ; - dispipe->li2c = li2c; -if (index ==0 ) { li2c->sda =0x01 ;/* pin 0 */ li2c->scl =0x02 ;/* pin 1 */
@@ -171,6 +168,8 @@ int lsdc_create_i2c_chan(struct drm_device *ddev,if (ret)return ret; + ldev->i2c[index] = adapter; +drm_info (ddev,"%s(sda pin mask=%u, scl pin mask=%u) created\n" , adapter->name, li2c->sda, li2c->scl);
drivers/gpu/drm/loongson/lsdc_i2c.h +0 -3
@@ -20,10 +20,7 @@ struct lsdc_i2c { u8 scl; }; -struct lsdc_display_pipe ; -int lsdc_create_i2c_chan (struct drm_device *ddev, -struct lsdc_display_pipe *dispipe,unsigned int index);#endif
drivers/gpu/drm/loongson/lsdc_output.c new file +176 -0
176 lines not on this page · raw message
drivers/gpu/drm/loongson/lsdc_output.h +35 -3
@@ -6,16 +6,48 @@#ifndef __LSDC_OUTPUT_H__#define __LSDC_OUTPUT_H__ -#include "lsdc_drv.h" +#include <drm/drm_encoder.h> +#include <drm/drm_connector.h> + +struct lsdc_desc ; + +struct lsdc_output_desc { +u32 pipe; +const char type[32 ]; +}; + +struct lsdc_output { +struct device *dev; +struct drm_encoder encoder; +struct drm_connector connector; +struct lsdc_output_desc *descp; +}; + +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, +unsigned int index, +struct platform_device **ppdev); +#endif
drivers/gpu/drm/loongson/lsdc_output_7a1000.c +1 -2
@@ -140,11 +140,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;
drivers/gpu/drm/loongson/lsdc_output_7a2000.c +5 -12
@@ -284,8 +284,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->descp->pipe;struct drm_device *ddev = encoder->dev;struct lsdc_device *ldev =to_lsdc (ddev);struct hdmi_avi_infoframe infoframe;
@@ -335,8 +334,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->descp->pipe;struct drm_device *ddev = encoder->dev;struct lsdc_device *ldev =to_lsdc (ddev);u32 val;
@@ -360,8 +358,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->descp->pipe;u32 val;/* datasheet say it should larger than 48 */
@@ -482,8 +479,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->descp->pipe;struct drm_device *ddev = encoder->dev;struct lsdc_device *ldev =to_lsdc (ddev);struct drm_display_mode *mode = &crtc_state->mode;
@@ -512,11 +508,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 +531,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);
Signature · 1 line
2.34.1
…
Quoted 1 line
However, the driver needs all of the subcompoments ready to use before
subcomponents?
…
Quoted 1 line
goes with the PCIe master, sinch they has no dependency on exterinal
since they have no dependencies on external?
Quoted 3 lines
modules.
While the outputs drivers, such as encoders and conectors, may has some
output? connectors, might have?
…
Quoted 1 line
if it need to do so, the master drvier won't bind until all submodules
…
Please improve your change descriptions considerably.
Regards,
Markus
PATCH v2 3/3 drm/loongson: Add dummy gpu driver as a subcomponent
In reply to Sui JingfengLoongson Graphics are PCIe multi-functional devices, the GPU device and the display controller are two distinct devices. Drivers of them should loose coupling, but still be able to works togather to provide a unified service to userspace.
Add a dummy driver for the GPU, it functional as a subcomponent as well.
--- drivers/gpu/drm/loongson/Makefile | 3 + drivers/gpu/drm/loongson/loong_gpu_pci_drv.c | 90 ++++++++++++++++++++ drivers/gpu/drm/loongson/loong_gpu_pci_drv.h | 27 ++++++ drivers/gpu/drm/loongson/loongson_module.c | 9 ++ drivers/gpu/drm/loongson/loongson_module.h | 7 ++ drivers/gpu/drm/loongson/lsdc_drv.c | 12 ++- drivers/gpu/drm/loongson/lsdc_drv.h | 8 +- 7 files changed, 149 insertions(+), 7 deletions(-) create mode 100644 drivers/gpu/drm/loongson/loong_gpu_pci_drv.c create mode 100644 drivers/gpu/drm/loongson/loong_gpu_pci_drv.h
drivers/gpu/drm/loongson/Makefile +3 -0
@@ -17,6 +17,9 @@ loongson-y := \ lsdc_probe.o \ lsdc_ttm.o +loongson-y += \ + loong_gpu_pci_drv.o + loongson-y += loongson_device.o \ loongson_module.o
drivers/gpu/drm/loongson/loong_gpu_pci_drv.c new file +90 -0
90 lines not on this page · raw message
drivers/gpu/drm/loongson/loong_gpu_pci_drv.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef __LOONG_GPU_PCI_DRV_H__ +#define __LOONG_GPU_PCI_DRV_H__ + +#include <linux/pci.h> + +struct loong_gpu_device { +struct pci_dev *pdev; +void __iomem *reg_base; + +u32 ver_major; +u32 ver_minor; +u32 revision; +}; + +static inline u32 loong_rreg32 (struct loong_gpu_device *ldev,u32 offset) +{ +return readl (ldev->reg_base + offset); +} + +static inline void loong_wreg32 (struct loong_gpu_device *ldev,u32 offset,u32 val) +{ +writel (val, ldev->reg_base + offset); +} + +#endif
drivers/gpu/drm/loongson/loongson_module.c +9 -0
@@ -29,8 +29,15 @@ static int __init loongson_module_init(void)if (ret)return ret; + ret =pci_register_driver (&loong_gpu_pci_driver); +if (ret) { +platform_driver_unregister (&lsdc_output_port_platform_driver); +return ret; + } + ret =pci_register_driver (&lsdc_pci_driver);if (ret) { +pci_unregister_driver (&loong_gpu_pci_driver);platform_driver_unregister (&lsdc_output_port_platform_driver);return ret; }
@@ -43,6 +50,8 @@ static void __exit loongson_module_exit(void) {pci_unregister_driver (&lsdc_pci_driver); +pci_unregister_driver (&loong_gpu_pci_driver); +platform_driver_unregister (&lsdc_output_port_platform_driver); }module_exit (loongson_module_exit);
drivers/gpu/drm/loongson/loongson_module.h +7 -0
@@ -6,8 +6,15 @@#ifndef __LOONGSON_MODULE_H__#define __LOONGSON_MODULE_H__ +enum loongson_chip_id { +CHIP_LS7A1000 =0 , +CHIP_LS7A2000 =1 , +CHIP_LS_LAST , +}; +extern int loongson_vblank;extern struct pci_driver lsdc_pci_driver; +extern struct pci_driver loong_gpu_pci_driver;extern struct platform_driver lsdc_output_port_platform_driver;#endif
drivers/gpu/drm/loongson/lsdc_drv.c +11 -1
@@ -154,9 +154,10 @@ static int lsdc_get_dedicated_vram(struct lsdc_device *ldev, base =pci_resource_start (pdev_gpu,2 ); size =pci_resource_len (pdev_gpu,2 ); +pci_dev_put (pdev_gpu); + ldev->vram_base = base; ldev->vram_size = size; - ldev->gpu = pdev_gpu;drm_info (ddev,"Dedicated vram start: 0x%llx, size: %uMiB\n" , (u64 )base, (u32)(size >>20 ));
@@ -281,6 +282,7 @@ static const struct component_master_ops loongson_drm_master_ops = {static int lsdc_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent) { +struct pci_dev *gpu =NULL ;struct component_match *matches =NULL ;const struct lsdc_desc *descp;struct lsdc_device *ldev;
@@ -339,6 +341,14 @@ static int lsdc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) &ldev->child[i]->dev); } + gpu =pci_get_device (PCI_VENDOR_ID_LOONGSON ,0x7a25 ,NULL ); +if (gpu) { +component_match_add (&pdev->dev, &matches, + component_compare_dev, + &gpu->dev); +pci_dev_put (gpu); + } + ret =component_master_add_with_match (&pdev->dev, &loongson_drm_master_ops, matches);
drivers/gpu/drm/loongson/lsdc_drv.h +2 -6
@@ -16,6 +16,8 @@#include <drm/drm_plane.h> #include <drm/ttm/ttm_device.h> +#include "loongson_module.h" +#include "lsdc_i2c.h" #include "lsdc_irq.h" #include "lsdc_gfxpll.h"
@@ -38,12 +40,6 @@* display pipe 1 = crtc1 + dvo1 + encoder1 + connectro1 + cursor1 + primary1 */ -enum loongson_chip_id { -CHIP_LS7A1000 =0 , -CHIP_LS7A2000 =1 , -CHIP_LS_LAST , -}; -const struct lsdc_desc *lsdc_device_probe (struct pci_dev *pdev,enum loongson_chip_id chip);
Signature · 1 line
2.34.1
Re: [PATCH v2 3/3] drm/loongson: Add dummy gpu driver as a subcomponent
…
Quoted 1 line
loose coupling, but still be able to works togather to provide a unified
use loose? should? work together? an?
…
Quoted 1 line
Add a dummy driver for the GPU, it functional as a subcomponent as well.
is?
Please improve your change descriptions considerably.
…
Quoted 7 lines
+++
b/drivers/gpu/drm/loongson/loongson_module.cdrivers/gpu/drm/loongson/loongson_module.c +2
-0@@ -29,8 +29,15 @@ static int __init loongson_module_init(void)if (ret)return ret; + ret =pci_register_driver (&loong_gpu_pci_driver); +if (ret) {
drivers/gpu/drm/loongson/loongson_module.c static int __init loongson_module_init(void) · line 43
Quoted 10 lines
drivers/gpu/drm/loongson/loongson_module.c +5
-0+platform_driver_unregister (&lsdc_output_port_platform_driver); +return ret; + } + ret =pci_register_driver (&lsdc_pci_driver);if (ret) { +pci_unregister_driver (&loong_gpu_pci_driver);platform_driver_unregister (&lsdc_output_port_platform_driver);return ret; }
How do you think about to use another goto chain for common exception handling?
https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a+goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+resources
Would you become interested in the application of scope-based resource management here?
drivers/gpu/drm/loongson/loongson_module.c static void __exit loongson_module_exit(void) · line 56
Quoted 8 lines
drivers/gpu/drm/loongson/loongson_module.c +2
-0@@ -43,6 +50,8 @@ static void __exit loongson_module_exit(void) {pci_unregister_driver (&lsdc_pci_driver); +pci_unregister_driver (&loong_gpu_pci_driver); +platform_driver_unregister (&lsdc_output_port_platform_driver); }
I suggest to avoid blank lines for this function implementation.
Regards,
Markus
Quoted 2 lines
Introduce component framework to bind child and sibling devices, for better modularity and offload the deferral probe issue to submodule if it need to
needs?
Quoted 1 line
attach exterinal module someday. Also for better reflect the hardware
external? Reflect the hardware layout better?
Quoted 1 line
layout.
…
Quoted 1 line
consists of encoder phy and level shifter. Well, the GPU are standalone
is stand-alone?
…
Quoted 1 line
for the master, it could return the -EPROBE_DEFER back to the drvier core.
driver?
Quoted 1 line
This allows the master don't have to tear down everything, thereore
therefore?
Less typos would be nicer also for such a cover letter.
Regards,
Markus