drm/rockchip: migrate to common dw-mipi-dsi bridge and dual-dsi
Subsystems (6)
Heiko Stuebner
maintainerv3 cover drm/rockchip: migrate to common dw-mipi-dsi bridge and dual-dsi
The Rockchip DSI driver was separate till now, not using the common bridge driver that was introduced a bit later. So this series migrates over to use that common bridge driver and then also adds support for dual-dsi to both the bridge and Rockchip glue code.
The bridge-migration itself is based on Nickeys earlier v8 work, but adapted to current kernels and with a new split between probe and bind, so that we do not create and drop the dsi-host on each deferred bind attempt.
changes in v2:
- rebase against newer drm code (dsi-bridge+rockchip changes)
- add SPDX header to new glue driver
- expect regular interface lanes from panel (like 4) not the double number Similar to tegra
- keep links to both master and slave
changes in v3:
- don't defer in bridge_attach, instead add ability to check for finalized panel attachement, for example in bind
- address bridge-conversion comments from Andrzej:
- include ordering
- moved hwaccess from mode_set to enable callback
- move pllref_clk enablement to bind (needed by bridge mode_set->lane_mbps)
- limited slave settings to dw_mipi_dsi_set_slave
- address dual-dsi comments from Philippe:
- remove unneeded separate variables
- remove unneeded second slave settings
- disable slave before master
- lane-sum calculation comments
Unchanged from review comments:
- kept dw_mipi_dsi_bind, as the dsi->bridge member is only part of the bridge drivers struct, so not accessible from glue drivers
- kept panel deferral in rk-bind, as the dsi bus containing the panel will only be created during probe, so this gives the system a chance to probe the panel between probe and bind calls, saving around 2 deferral rounds on my Gru-Scarlet - when compared to always deferring during probe. (panel module-load time + async probing)
+ of course saving time not re-creating the dsi bus on each probe try
- kept helper to find second host, as I think it's pretty near to Archit's description
- kept dual-dsi handling that mimicks tegra for now
Cover-letter blurb from v2:
---------------------------
The dual-dsi setup follows the port description introduced by Archit [0], in that the panel defines two input ports that get connected to both dsi-controllers instances. So on Gru-Scarlett this looks for example like:
&mipi_dsi {
status = "okay";
clock-master;
ports {
mipi_out: port@1 {
reg = <1>;
mipi_out_panel: endpoint {
remote-endpoint = <&mipi_in_panel>;
};
};
};
mipi_panel: panel@0 {
/* 2 different panels are used, compatibles are in dts files */
reg = <0>;
backlight = <&backlight>;
enable-gpios = <&gpio4 25 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&display_rst_l>;
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
mipi_in_panel: endpoint {
remote-endpoint = <&mipi_out_panel>;
};
};
port@1 {
reg = <1>;
mipi1_in_panel: endpoint@1 {
remote-endpoint = <&mipi1_out_panel>;
};
};
};
};
};&mipi_dsi1 {
status = "okay";
ports {
mipi1_out: port@1 {
reg = <1>;
mipi1_out_panel: endpoint {
remote-endpoint = <&mipi1_in_panel>;
};
};
};
};The driver internal setup is pretty similar to what tegra does with its ganged-mode [1][2]. But here a new helper function allows to traverse the devicetree from one controller port through the panel to find another dsi-controller using that same panel. This way we don't need a special phandle-property to link the controllers together.
For the CRTC it is still one single display to handle, only with an additional switch that enables the dual-dsi output.
For practical purposes it is possible to just pick half the series (till patch 5) to get the migration to the bridge driver first, so that we can get rid of the dw-dsi copy in the Rockchip driver.
But of course Acks / Reviews of the dsi-bridge changes would be needed.
[0] https://patchwork.kernel.org/patch/10172381/
[1] https://lkml.org/lkml/2014/8/5/396
[2] https://patchwork.kernel.org/patch/5075161/
Heiko Stuebner (5):
drm/bridge/synopsys: dsi: move mipi_dsi_host_unregister to
__dw_mipi_dsi_remove
drm/bridge/synopsys: dsi: don't call __dw_mipi_dsi_probe from
dw_mipi_dsi_bind
drm/bridge/synopsys: dsi: add ability to check dsi-device attachment drm/dsi: add helper function to find the second host in a dual-dsi
setup
drm/rockchip: dsi: add dual mipi support
Nickey Yang (3):
dt-bindings: display: rockchip: update DSI controller drm/rockchip: dsi: migrate to use dw-mipi-dsi bridge driver drm/bridge/synopsys: dsi: add dual-dsi support
.../display/rockchip/dw_mipi_dsi_rockchip.txt | 23 +- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 124 +- drivers/gpu/drm/drm_mipi_dsi.c | 56 + drivers/gpu/drm/rockchip/Kconfig | 2 +- drivers/gpu/drm/rockchip/Makefile | 2 +- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 1005 ++++++++++++ drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 1349 ----------------- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 3 +- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 + drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 4 + drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 1 + include/drm/bridge/dw_mipi_dsi.h | 7 +- include/drm/drm_mipi_dsi.h | 2 + 14 files changed, 1204 insertions(+), 1379 deletions(-) create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerPATCH v3 1/8 drm/bridge/synopsys: dsi: move mipi_dsi_host_unregister to __dw_mipi_dsi_remove
Right now the host is only unregistered when the driver is used via the bridge api and not via the component api, leading to the host staying registered in cases like probe deferral.
So move the host unregister to the general remove function, so that it gets cleaned up in all cases.
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2 -2
@@ -941,6 +941,8 @@ __dw_mipi_dsi_probe(struct platform_device *pdev,static void __dw_mipi_dsi_remove (struct dw_mipi_dsi *dsi) { +mipi_dsi_host_unregister (&dsi->dsi_host); +pm_runtime_disable (dsi->dev); }
@@ -957,8 +959,6 @@ EXPORT_SYMBOL_GPL(dw_mipi_dsi_probe);void dw_mipi_dsi_remove (struct dw_mipi_dsi *dsi) { -mipi_dsi_host_unregister (&dsi->dsi_host); -__dw_mipi_dsi_remove (dsi); }EXPORT_SYMBOL_GPL (dw_mipi_dsi_remove);
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerPATCH v3 2/8 drm/bridge/synopsys: dsi: don't call __dw_mipi_dsi_probe from dw_mipi_dsi_bind
In reply to Heiko Stuebner__dw_mipi_dsi_probe() does all the grabbing of resources and does it using devm-helpers. So this is happening on each try of master bringup possibly slowing down things a lot.
Drivers using the component framework may instead want call dw_mipi_dsi_probe separately in their probe function setup resources early. That way the dsi bus also gets created earlier and also not recreated on each bind-try, so that attached panels can load their modules and be probed way before the bridge-attach in the bind call.
So drop the call to __dw_mipi_dsi_probe and modify the function to take a struct dw_mipi_dsi instead of the platform-device.
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 15 +++------------ include/drm/bridge/dw_mipi_dsi.h | 5 +---- 2 files changed, 4 insertions(+), 16 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +3 -12
@@ -966,31 +966,22 @@ EXPORT_SYMBOL_GPL(dw_mipi_dsi_remove);/* * Bind/unbind API, used from platforms based on the component framework. */ -struct dw_mipi_dsi * -dw_mipi_dsi_bind (struct platform_device *pdev,struct drm_encoder *encoder, -const struct dw_mipi_dsi_plat_data *plat_data) +int dw_mipi_dsi_bind (struct dw_mipi_dsi *dsi,struct drm_encoder *encoder) { -struct dw_mipi_dsi *dsi;int ret; - dsi =__dw_mipi_dsi_probe (pdev, plat_data); -if (IS_ERR (dsi)) -return dsi; - ret =drm_bridge_attach (encoder, &dsi->bridge,NULL );if (ret) { -dw_mipi_dsi_remove (dsi);DRM_ERROR ("Failed to initialize bridge with drm\n" ); -return ERR_PTR (ret); +return ret; } -return dsi; +return ret; }EXPORT_SYMBOL_GPL (dw_mipi_dsi_bind);void dw_mipi_dsi_unbind (struct dw_mipi_dsi *dsi) { -__dw_mipi_dsi_remove (dsi); }EXPORT_SYMBOL_GPL (dw_mipi_dsi_unbind);
include/drm/bridge/dw_mipi_dsi.h +1 -4
@@ -35,10 +35,7 @@ struct dw_mipi_dsi *dw_mipi_dsi_probe(struct platform_device *pdev,const struct dw_mipi_dsi_plat_data *plat_data);void dw_mipi_dsi_remove (struct dw_mipi_dsi *dsi); -struct dw_mipi_dsi *dw_mipi_dsi_bind (struct platform_device *pdev, -struct drm_encoder *encoder, -const struct dw_mipi_dsi_plat_data - *plat_data); +int dw_mipi_dsi_bind (struct dw_mipi_dsi *dsi,struct drm_encoder *encoder);void dw_mipi_dsi_unbind (struct dw_mipi_dsi *dsi);#endif /* __DW_MIPI_DSI__ */
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerPATCH v3 3/8 drm/bridge/synopsys: dsi: add ability to check dsi-device attachment
In reply to Heiko StuebnerWhen the panel-driver is build as a module it currently fails hard as the panel cannot be probed directly:
dw_mipi_dsi_bind()
__dw_mipi_dsi_probe()
creates dsi bus
creates panel device
triggers panel module load
panel not probed (module not loaded or panel probe slow)
drm_bridge_attach
fails with -EINVAL due to empty panel_bridge
Additionally the panel probing can run concurrently with dsi bringup making it possible that the panel can already be found but dsi-attach hasn't finished running.
The newly added function provides the ability for glue drivers to check if a dsi device was actually attached and also protects the attach part to prevent concurrency issues from panel-assignment and drm_bridge_create.
Using that check glue drivers are able to for example defer probe/bind in the case that the panel is not completely set up yet.
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 25 +++++++++++++++++++ include/drm/bridge/dw_mipi_dsi.h | 1 + 2 files changed, 26 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +25 -0
@@ -12,6 +12,7 @@#include <linux/component.h> #include <linux/iopoll.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/of_device.h> #include <linux/pm_runtime.h> #include <linux/reset.h>
@@ -219,6 +220,7 @@ struct dw_mipi_dsi {struct drm_bridge bridge;struct mipi_dsi_host dsi_host;struct drm_bridge *panel_bridge; +struct mutex panel_mutex;struct device *dev;void __iomem *base;
@@ -296,10 +298,14 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,return PTR_ERR (bridge); } +mutex_lock (&dsi->panel_mutex); + dsi->panel_bridge = bridge;drm_bridge_add (&dsi->bridge); +mutex_unlock (&dsi->panel_mutex); +return 0 ; }
@@ -308,13 +314,30 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, {struct dw_mipi_dsi *dsi =host_to_dsi (host); +mutex_lock (&dsi->panel_mutex); + + dsi->panel_bridge =NULL ;drm_of_panel_bridge_remove (host->dev->of_node,1 ,0 );drm_bridge_remove (&dsi->bridge); +mutex_unlock (&dsi->panel_mutex); +return 0 ; } +bool dw_mipi_dsi_device_attached (struct dw_mipi_dsi *dsi) +{ +bool output; + +mutex_lock (&dsi->panel_mutex); + output = !!dsi->panel_bridge; +mutex_unlock (&dsi->panel_mutex); + +return output; +} +EXPORT_SYMBOL_GPL (dw_mipi_dsi_device_attached); +static void dw_mipi_message_config (struct dw_mipi_dsi *dsi,const struct mipi_dsi_msg *msg) {
@@ -867,6 +890,8 @@ __dw_mipi_dsi_probe(struct platform_device *pdev, dsi->dev = dev; dsi->plat_data = plat_data; +mutex_init (&dsi->panel_mutex); +if (!plat_data->phy_ops->init || !plat_data->phy_ops->get_lane_mbps) {DRM_ERROR ("Phy not properly configured\n" );return ERR_PTR (-ENODEV );
include/drm/bridge/dw_mipi_dsi.h +1 -0
@@ -31,6 +31,7 @@ struct dw_mipi_dsi_plat_data {void *priv_data; }; +bool dw_mipi_dsi_device_attached (struct dw_mipi_dsi *dsi);struct dw_mipi_dsi *dw_mipi_dsi_probe (struct platform_device *pdev,const struct dw_mipi_dsi_plat_data *plat_data);
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerPATCH v3 4/8 dt-bindings: display: rockchip: update DSI controller
In reply to Heiko StuebnerFrom: Nickey Yang <[email protected]>
This patch update describe panel/port links, including unit addresses in documentation of device tree bindings for the rockchip DSI controller based on the Synopsys DesignWare MIPI DSI host controller.
--- .../display/rockchip/dw_mipi_dsi_rockchip.txt | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/display/rockchip/dw_mipi_dsi_rockchip.txt +21 -2
@@ -14,6 +14,8 @@ Required properties: - rockchip,grf: this soc should set GRF regs to mux vopl/vopb. - ports: contain a port node with endpoint definitions as defined in [2]. For vopb,set the reg = <0> and set the reg = <1> for vopl. +- video port 0 for the VOP input, the remote endpoint maybe vopb or vopl +- video port 1 for either a panel or subsequent encoder Optional properties: - power-domains: a phandle to mipi dsi power domain node.
@@ -40,11 +42,12 @@ Example: ports { #address-cells = <1>; #size-cells = <0>; - reg = <1>; - mipi_in: port { + mipi_in: port@0 { + reg = <0>; #address-cells = <1>; #size-cells = <0>; + mipi_in_vopb: endpoint@0 { reg = <0>; remote-endpoint = <&vopb_out_mipi>;
@@ -54,6 +57,16 @@ Example: remote-endpoint = <&vopl_out_mipi>; }; }; + + mipi_out: port@1 { + reg = <1>; + #address-cells = <1>; + #size-cells = <0>; + + mipi_out_panel: endpoint { + remote-endpoint = <&panel_in_mipi>; + }; + }; }; panel {
@@ -64,5 +77,11 @@ Example: pinctrl-names = "default"; pinctrl-0 = <&lcd_en>; backlight = <&backlight>; + + port { + panel_in_mipi: endpoint { + remote-endpoint = <&mipi_out_panel>; + }; + }; }; };
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerPATCH v3 5/8 drm/rockchip: dsi: migrate to use dw-mipi-dsi bridge driver
In reply to Heiko StuebnerFrom: Nickey Yang <[email protected]>
Add the ROCKCHIP DSI controller driver that uses the Synopsys DesignWare MIPI DSI host controller bridge and remove the old separate one.
changes:
v2:
add err_pllref, remove unnecessary encoder.enable & disable correct spelling mistakes
v3:
call dw_mipi_dsi_unbind() in dw_mipi_dsi_rockchip_unbind() fix typo, use of_device_get_match_data(),
change some bind() logic into probe()
add 'dev_set_drvdata()'
v4:
return -EINVAL when can not get best_freq
add a clarifying comment when get vco
add review tag
v5:
keep our power domain enabled while touching GRF
v6:
change func name dw_mipi_encoder_disable to dw_mipi_dsi_encoder_disable
v7:
none
v8: Heiko
add Archit's Review tag
adapt to recent changes in the original rockchip-dsi driver beautify grf-handling
split hw-setup (resources, dsi-host) from bind into probe
v2-new: Heiko
add SPDX header instead of license blurb
drop old versioning to not confuse people
v3-new: Heiko
include ordering
moved hwaccess from mode_set to enable callback
move pllref_clk enablement to bind (needed by bridge mode_set->lane_mbps)
--- drivers/gpu/drm/rockchip/Kconfig | 2 +- drivers/gpu/drm/rockchip/Makefile | 2 +- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 933 ++++++++++++ drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 1349 ----------------- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 2 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 +- 6 files changed, 937 insertions(+), 1353 deletions(-) create mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c delete mode 100644 drivers/gpu/drm/rockchip/dw-mipi-dsi.c
drivers/gpu/drm/rockchip/Kconfig +1 -1
@@ -7,7 +7,7 @@ config DRM_ROCKCHIP select VIDEOMODE_HELPERS select DRM_ANALOGIX_DP if ROCKCHIP_ANALOGIX_DP select DRM_DW_HDMI if ROCKCHIP_DW_HDMI - select DRM_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI + select DRM_DW_MIPI_DSI if ROCKCHIP_DW_MIPI_DSI select SND_SOC_HDMI_CODEC if ROCKCHIP_CDN_DP && SND_SOC help Choose this option if you have a Rockchip soc chipset.
drivers/gpu/drm/rockchip/Makefile +1 -1
@@ -11,7 +11,7 @@ rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += rockchip_drm_fbdev.o rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o -rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o +rockchipdrm-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi-rockchip.o rockchipdrm-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o rockchipdrm-$(CONFIG_ROCKCHIP_LVDS) += rockchip_lvds.o
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c new file +933 -0
933 lines not on this page · raw message
drivers/gpu/drm/rockchip/dw-mipi-dsi.c deleted +0 -1349
1,349 lines not on this page · raw message
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -1
@@ -477,7 +477,7 @@ static int __init rockchip_drm_init(void)ADD_ROCKCHIP_SUB_DRIVER (cdn_dp_driver,CONFIG_ROCKCHIP_CDN_DP );ADD_ROCKCHIP_SUB_DRIVER (dw_hdmi_rockchip_pltfm_driver,CONFIG_ROCKCHIP_DW_HDMI ); -ADD_ROCKCHIP_SUB_DRIVER (dw_mipi_dsi_driver, +ADD_ROCKCHIP_SUB_DRIVER (dw_mipi_dsi_rockchip_driver,CONFIG_ROCKCHIP_DW_MIPI_DSI );ADD_ROCKCHIP_SUB_DRIVER (inno_hdmi_driver,CONFIG_ROCKCHIP_INNO_HDMI );
drivers/gpu/drm/rockchip/rockchip_drm_drv.h +1 -1
@@ -67,7 +67,7 @@ int rockchip_drm_wait_vact_end(struct drm_crtc *crtc, unsigned int mstimeout);extern struct platform_driver cdn_dp_driver;extern struct platform_driver dw_hdmi_rockchip_pltfm_driver; -extern struct platform_driver dw_mipi_dsi_driver; +extern struct platform_driver dw_mipi_dsi_rockchip_driver;extern struct platform_driver inno_hdmi_driver;extern struct platform_driver rockchip_dp_driver;extern struct platform_driver rockchip_lvds_driver;
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerPATCH v3 6/8 drm/dsi: add helper function to find the second host in a dual-dsi setup
In reply to Heiko StuebnerFrom a specified output port of one dsi controller this function allows to iterate over the list of registered dsi controllers trying to find a second instance connected to the same display, like it is used in dual-dsi setups.
--- drivers/gpu/drm/drm_mipi_dsi.c | 56 ++++++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 2 ++ 2 files changed, 58 insertions(+)
drivers/gpu/drm/drm_mipi_dsi.c +56 -0
@@ -30,6 +30,7 @@#include <linux/device.h> #include <linux/module.h> #include <linux/of_device.h> +#include <linux/of_graph.h> #include <linux/pm_runtime.h> #include <linux/slab.h>
@@ -282,6 +283,61 @@ struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node) }EXPORT_SYMBOL (of_find_mipi_dsi_host_by_node); +struct device_node *of_mipi_dsi_find_second_host (struct device_node *first_np, +int port,int endpoint) +{ +struct mipi_dsi_host *first, *host; +struct device_node *remote, *np, *second_np =NULL ; +int num =0 ; + + first =of_find_mipi_dsi_host_by_node (first_np); +if (!first) { +pr_err ("no dsi-host for node %s\n" , first_np->full_name); +return ERR_PTR (-ENODEV ); + } + +/* output-node of the known dsi-host */ + remote =of_graph_get_remote_node (first_np, port, endpoint); +if (!remote) { +dev_err (first->dev,"no output node found\n" ); +return ERR_PTR (-ENODEV ); + } + +mutex_lock (&host_lock); + +list_for_each_entry (host, &host_list, list) { + np =of_graph_get_remote_node (host->dev->of_node, + port, endpoint); + +/* found a host connected to this panel */ +if (np == remote) + num++; + +/* found one second host */ +if (host->dev->of_node != first_np) + second_np = host->dev->of_node; + +of_node_put (np); + } + +/* of_node_get the node under host_lock */ +if (num ==2 ) +of_node_get (second_np); + +mutex_unlock (&host_lock); + +of_node_put (remote); + +if (num >2 ) { +dev_err (first->dev, +"too many DSI links for output: %d links\n" , num); +return ERR_PTR (-EINVAL ); + } + +return second_np; +} +EXPORT_SYMBOL (of_mipi_dsi_find_second_host); +int mipi_dsi_host_register (struct mipi_dsi_host *host) {struct device_node *node;
include/drm/drm_mipi_dsi.h +2 -0
@@ -107,6 +107,8 @@ struct mipi_dsi_host {int mipi_dsi_host_register (struct mipi_dsi_host *host);void mipi_dsi_host_unregister (struct mipi_dsi_host *host);struct mipi_dsi_host *of_find_mipi_dsi_host_by_node (struct device_node *node); +struct device_node *of_mipi_dsi_find_second_host (struct device_node *first_np, +int port,int endpoint);/* DSI mode flags */
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 7/8 drm/bridge/synopsys: dsi: add dual-dsi support
In reply to a message not in the archiveFrom: Nickey Yang <[email protected]>
Allow to also drive a slave dw-mipi-dsi controller in a dual-dsi setup. This will require additional implementation-specific code to look up the slave instance and do specific setup. Also will probably need code in the specific crtcs as dual-dsi does not equal two separate dsi outputs.
To activate, the implementation-specific code should set the slave using dw_mipi_dsi_set_slave() before calling __dw_mipi_dsi_bind().
v2:
- expect real interface number of lanes
- keep links to both master and slave
v3:
- remove unneeded separate variables
- remove unneeded second slave settings
- disable slave before master
- lane-sum calculation comments
--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 80 +++++++++++++++++-- include/drm/bridge/dw_mipi_dsi.h | 1 + 2 files changed, 75 insertions(+), 6 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +74 -6
@@ -232,9 +232,20 @@ struct dw_mipi_dsi {u32 format;unsigned long mode_flags; +struct dw_mipi_dsi *master;/* dual-dsi master ptr */ +struct dw_mipi_dsi *slave;/* dual-dsi slave ptr */ +const struct dw_mipi_dsi_plat_data *plat_data; }; +/* +* Check if either a link to a master or slave is present +*/ +static inline bool dw_mipi_is_dual_mode (struct dw_mipi_dsi *dsi) +{ +return dsi->slave || dsi->master; +} +/* * The controller should generate 2 frames before * preparing the peripheral.
@@ -464,10 +475,17 @@ static ssize_t dw_mipi_dsi_host_transfer(struct mipi_dsi_host *host, }dw_mipi_message_config (dsi, msg); +if (dsi->slave) +dw_mipi_message_config (dsi->slave, msg); ret =dw_mipi_dsi_write (dsi, &packet);if (ret)return ret; +if (dsi->slave) { + ret =dw_mipi_dsi_write (dsi->slave, &packet); +if (ret) +return ret; + }if (msg->rx_buf && msg->rx_len) { ret =dw_mipi_dsi_read (dsi, msg);
@@ -606,7 +624,11 @@ static void dw_mipi_dsi_video_packet_config(struct dw_mipi_dsi *dsi,* DSI_VNPCR.NPSIZE... especially because this driver supports * non-burst video modes, see dw_mipi_dsi_video_mode_config()... */ -dsi_write (dsi,DSI_VID_PKT_SIZE ,VID_PKT_SIZE (mode->hdisplay)); + +dsi_write (dsi,DSI_VID_PKT_SIZE , +dw_mipi_is_dual_mode (dsi) ? +VID_PKT_SIZE (mode->hdisplay /2 ) : +VID_PKT_SIZE (mode->hdisplay)); }static void dw_mipi_dsi_command_mode_config (struct dw_mipi_dsi *dsi)
@@ -778,24 +800,43 @@ static void dw_mipi_dsi_bridge_post_disable(struct drm_bridge *bridge)*/ dsi->panel_bridge->funcs->post_disable (dsi->panel_bridge); +if (dsi->slave) { +dw_mipi_dsi_disable (dsi->slave); +clk_disable_unprepare (dsi->slave->pclk); +pm_runtime_put (dsi->slave->dev); + }dw_mipi_dsi_disable (dsi); +clk_disable_unprepare (dsi->pclk);pm_runtime_put (dsi->dev); } -static void dw_mipi_dsi_bridge_mode_set (struct drm_bridge *bridge, -struct drm_display_mode *mode, -struct drm_display_mode *adjusted_mode) +static unsigned int dw_mipi_dsi_get_lanes (struct dw_mipi_dsi *dsi) +{ +/* this instance is the slave, so add the master's lanes */ +if (dsi->master) +return dsi->master->lanes + dsi->lanes; + +/* this instance is the master, so add the slave's lanes */ +if (dsi->slave) +return dsi->lanes + dsi->slave->lanes; + +/* single-dsi, so no other instance to consider */ +return dsi->lanes; +} + +static void dw_mipi_dsi_mode_set (struct dw_mipi_dsi *dsi, +struct drm_display_mode *adjusted_mode) { -struct dw_mipi_dsi *dsi =bridge_to_dsi (bridge);const struct dw_mipi_dsi_phy_ops *phy_ops = dsi->plat_data->phy_ops;void *priv_data = dsi->plat_data->priv_data;int ret; +u32 lanes =dw_mipi_dsi_get_lanes (dsi);clk_prepare_enable (dsi->pclk); ret = phy_ops->get_lane_mbps (priv_data, adjusted_mode, dsi->mode_flags, - dsi->lanes, dsi->format, &dsi->lane_mbps); + lanes, dsi->format, &dsi->lane_mbps);if (ret)DRM_DEBUG_DRIVER ("Phy get_lane_mbps() failed\n" );
@@ -827,12 +868,25 @@ static void dw_mipi_dsi_bridge_mode_set(struct drm_bridge *bridge,dw_mipi_dsi_set_mode (dsi,0 ); } +static void dw_mipi_dsi_bridge_mode_set (struct drm_bridge *bridge, +struct drm_display_mode *mode, +struct drm_display_mode *adjusted_mode) +{ +struct dw_mipi_dsi *dsi =bridge_to_dsi (bridge); + +dw_mipi_dsi_mode_set (dsi, adjusted_mode); +if (dsi->slave) +dw_mipi_dsi_mode_set (dsi->slave, adjusted_mode); +} +static void dw_mipi_dsi_bridge_enable (struct drm_bridge *bridge) {struct dw_mipi_dsi *dsi =bridge_to_dsi (bridge);/* Switch to video mode for panel-bridge enable & panel enable */ dw_mipi_dsi_set_mode (dsi,MIPI_DSI_MODE_VIDEO ); +if (dsi->slave) +dw_mipi_dsi_set_mode (dsi->slave,MIPI_DSI_MODE_VIDEO ); } static enum drm_mode_status
@@ -971,6 +1025,20 @@ static void __dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi)pm_runtime_disable (dsi->dev); } +void dw_mipi_dsi_set_slave (struct dw_mipi_dsi *dsi,struct dw_mipi_dsi *slave) +{ +/* introduce controllers to each other */ + dsi->slave = slave; + dsi->slave->master = dsi; + +/* migrate settings for already attached displays */ + dsi->slave->lanes = dsi->lanes; + dsi->slave->channel = dsi->channel; + dsi->slave->format = dsi->format; + dsi->slave->mode_flags = dsi->mode_flags; +} +EXPORT_SYMBOL_GPL (dw_mipi_dsi_set_slave); +/* * Probe/remove API, used from platforms based on the DRM bridge API. */
include/drm/bridge/dw_mipi_dsi.h +1 -0
@@ -38,5 +38,6 @@ struct dw_mipi_dsi *dw_mipi_dsi_probe(struct platform_device *pdev,void dw_mipi_dsi_remove (struct dw_mipi_dsi *dsi);int dw_mipi_dsi_bind (struct dw_mipi_dsi *dsi,struct drm_encoder *encoder);void dw_mipi_dsi_unbind (struct dw_mipi_dsi *dsi); +void dw_mipi_dsi_set_slave (struct dw_mipi_dsi *dsi,struct dw_mipi_dsi *slave);#endif /* __DW_MIPI_DSI__ */
Signature · 1 line
2.17.0
PATCH v3 8/8 drm/rockchip: dsi: add dual mipi support
In reply to a message not in the archiveAdd the Rockchip-sepcific dual-dsi setup and hook it into the VOP as well. As described in the general dual-dsi devicetree binding, the panel should define two input ports and point each of them to one of the used dsi- controllers, as well as declare one of them as clock-master. This is used to determine the dual-dsi state and get access to both controller instances.
--- .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 76 ++++++++++++++++++- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 1 + drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 + drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 4 + drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 1 + 5 files changed, 83 insertions(+), 2 deletions(-)
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +74 -2
@@ -218,6 +218,10 @@ struct dw_mipi_dsi_rockchip {struct clk *grf_clk;struct clk *phy_cfg_clk; +/* dual-channel */ +bool is_slave; +struct dw_mipi_dsi_rockchip *slave; +unsigned int lane_mbps;/* per lane */ u16 input_div;u16 feedback_div;
@@ -602,6 +606,8 @@ dw_mipi_dsi_encoder_atomic_check(struct drm_encoder *encoder, } s->output_type =DRM_MODE_CONNECTOR_DSI ; +if (dsi->slave) + s->output_flags =ROCKCHIP_OUTPUT_DSI_DUAL ;return 0 ; }
@@ -617,6 +623,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder)return ;pm_runtime_get_sync (dsi->dev); +if (dsi->slave) +pm_runtime_get_sync (dsi->slave->dev);/* * For the RK3399, the clk of grf must be enabled before writing grf
@@ -630,6 +638,8 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) }dw_mipi_dsi_rockchip_config (dsi, mux); +if (dsi->slave) +dw_mipi_dsi_rockchip_config (dsi->slave, mux);clk_disable_unprepare (dsi->grf_clk); }
@@ -638,6 +648,8 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder) {struct dw_mipi_dsi_rockchip *dsi =to_dsi (encoder); +if (dsi->slave) +pm_runtime_put (dsi->slave->dev);pm_runtime_put (dsi->dev); }
@@ -679,25 +691,82 @@ static int dw_mipi_dsi_rockchip_bind(struct device *dev, {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev);struct drm_device *drm_dev = data; +struct device_node *second_np;struct drm_bridge *bridge;struct drm_panel *panel; +bool master1, master2;int ret;/* -* Handle probe-deferrals due to missing display. +* At this point both DSIs (if in use) should have probed and found +* any connected displays or bridges. +* This also takes care of handling possible probe-deferrals. */ ret =drm_of_find_panel_or_bridge (dsi->dev->of_node,1 ,0 , &panel, &bridge);if (ret)return ret; + second_np =of_mipi_dsi_find_second_host (dsi->dev->of_node,1 ,0 ); +if (IS_ERR (second_np)) +return PTR_ERR (second_np); +/* * We know that there is a panel present but it may not have * finished attaching to the host. Defer in that case. +* Single-DSI case. */ -if (!dw_mipi_dsi_device_attached (dsi->dmd)) +if (!second_np && !dw_mipi_dsi_device_attached (dsi->dmd))return -EPROBE_DEFER ; +if (second_np) { +struct platform_device *pdev; + + master1 =of_property_read_bool (dsi->dev->of_node, +"clock-master" ); + master2 =of_property_read_bool (second_np,"clock-master" ); + +if (master1 && master2) { +DRM_DEV_ERROR (dsi->dev,"only one clock-master allowed\n" ); +of_node_put (second_np); +return -EINVAL ; + } + +if (!master1 && !master2) { +DRM_DEV_ERROR (dsi->dev,"no clock-master defined\n" ); +of_node_put (second_np); +return -EINVAL ; + } + +/* we are the slave in dual-DSI */ +if (!master1) { + dsi->is_slave = true; +of_node_put (second_np); +return 0 ; + } + +/* make sure, panel is attached to the master */ +if (!dw_mipi_dsi_device_attached (dsi->dmd)) +return -EPROBE_DEFER ; + + pdev =of_find_device_by_node (second_np); +if (!pdev) { +DRM_DEV_ERROR (dev,"could not find slave controller\n" ); +return -ENODEV ; + } + + dsi->slave =platform_get_drvdata (pdev); +if (!dsi->slave) { +DRM_DEV_ERROR (dev,"could not get slaves platform-data\n" ); +return -ENODEV ; + } + + dsi->slave->is_slave = true; +dw_mipi_dsi_set_slave (dsi->dmd, dsi->slave->dmd); + +of_node_put (second_np); + } + ret =clk_prepare_enable (dsi->pllref_clk);if (ret) {DRM_DEV_ERROR (dev,"Failed to enable pllref_clk: %d\n" , ret);
@@ -725,6 +794,9 @@ static void dw_mipi_dsi_rockchip_unbind(struct device *dev, {struct dw_mipi_dsi_rockchip *dsi =dev_get_drvdata (dev); +if (dsi->is_slave) +return ; +dw_mipi_dsi_unbind (dsi->dmd);clk_disable_unprepare (dsi->pllref_clk);
drivers/gpu/drm/rockchip/rockchip_drm_drv.h +1 -0
@@ -37,6 +37,7 @@ struct rockchip_crtc_state {int output_type;int output_mode;int output_bpc; +int output_flags; };#define to_rockchip_crtc_state (s) \ container_of(s, struct rockchip_crtc_state, base)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +3 -0
@@ -916,6 +916,7 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc, pin_pol |= (adjusted_mode->flags &DRM_MODE_FLAG_PVSYNC ) ?BIT (VSYNC_POSITIVE ) :0 ;VOP_REG_SET (vop, output, pin_pol, pin_pol); +VOP_REG_SET (vop, output, mipi_dual_channel_en,0 );switch (s->output_type) {case DRM_MODE_CONNECTOR_LVDS :
@@ -933,6 +934,8 @@ static void vop_crtc_atomic_enable(struct drm_crtc *crtc,case DRM_MODE_CONNECTOR_DSI :VOP_REG_SET (vop, output, mipi_pin_pol, pin_pol);VOP_REG_SET (vop, output, mipi_en,1 ); +VOP_REG_SET (vop, output, mipi_dual_channel_en, + !!(s->output_flags &ROCKCHIP_OUTPUT_DSI_DUAL ));break ;case DRM_MODE_CONNECTOR_DisplayPort: pin_pol &= ~BIT (DCLK_INVERT );
drivers/gpu/drm/rockchip/rockchip_drm_vop.h +4 -0
@@ -60,6 +60,7 @@ struct vop_output {struct vop_reg edp_en;struct vop_reg hdmi_en;struct vop_reg mipi_en; +struct vop_reg mipi_dual_channel_en;struct vop_reg rgb_en; };
@@ -213,6 +214,9 @@ struct vop_data {/* for use special outface */ #define ROCKCHIP_OUT_MODE_AAAA 15 +/* output flags */ +#define ROCKCHIP_OUTPUT_DSI_DUAL BIT(0) +enum alpha_mode {ALPHA_STRAIGHT ,ALPHA_INVERSE ,
drivers/gpu/drm/rockchip/rockchip_vop_reg.c +1 -0
@@ -421,6 +421,7 @@ static const struct vop_output rk3399_output = { .hdmi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 13), .edp_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 14), .mipi_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 15), + .mipi_dual_channel_en = VOP_REG(RK3288_SYS_CTRL, 0x1, 3), };static const struct vop_data rk3399_vop_big = {
Signature · 1 line
2.17.0
Re: [PATCH v3 2/8] drm/bridge/synopsys: dsi: don't call __dw_mipi_dsi_probe from dw_mipi_dsi_bind
In reply to Heiko StuebnerQuoted 10 lines · Heiko Stuebner
__dw_mipi_dsi_probe()does all the grabbing of resources and does it using devm-helpers. So this is happening on each try of master bringup possibly slowing down things a lot.Drivers using the component framework may instead want call
dw_mipi_dsi_probeseparately in their probe function setup resources early. That way the dsi bus also gets created earlier and also not recreated on each bind-try, so that attached panels can load their modules and be probed way before the bridge-attach in the bind call.
Quoted 4 lines
So drop the call to
__dw_mipi_dsi_probeand modify the function to take a structdw_mipi_dsiinstead of the platform-device.Signed-off-by Heiko Stuebner <[email protected]>
--
Regards
Andrzej
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 3/8] drm/bridge/synopsys: dsi: add ability to check dsi-device attachment
In reply to Heiko StuebnerQuoted 82 lines · Heiko Stuebner
When the panel-driver is build as a module it currently fails hard as the panel cannot be probed directly:
dw_mipi_dsi_bind()
__dw_mipi_dsi_probe()
creates dsi bus
creates panel device
triggers panel module load
panel not probed (module not loaded or panel probe slow)
drm_bridge_attach
fails with-EINVALdue to emptypanel_bridgeAdditionally the panel probing can run concurrently with dsi bringup making it possible that the panel can already be found but dsi-attach hasn't finished running.
The newly added function provides the ability for glue drivers to check if a dsi device was actually attached and also protects the attach part to prevent concurrency issues from panel-assignment and
drm_bridge_create.Using that check glue drivers are able to for example defer probe/bind in the case that the panel is not completely set up yet.
Signed-off-by Heiko Stuebner <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 25 +++++++++++++++++++ include/drm/bridge/dw_mipi_dsi.h | 1 + 2 files changed, 26 insertions(+)drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +12
-0@@ -12,6 +12,7 @@#include <linux/component.h> #include <linux/iopoll.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/of_device.h> #include <linux/pm_runtime.h> #include <linux/reset.h> @@ -219,6 +220,7 @@ struct dw_mipi_dsi {struct drm_bridge bridge;struct mipi_dsi_host dsi_host;struct drm_bridge *panel_bridge; +struct mutex panel_mutex;struct device *dev;void __iomem *base;@@ -296,10 +298,14 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,return PTR_ERR (bridge); } +mutex_lock (&dsi->panel_mutex); + dsi->panel_bridge = bridge;drm_bridge_add (&dsi->bridge); +mutex_unlock (&dsi->panel_mutex); +return 0 ; }@@ -308,13 +314,30 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, {struct dw_mipi_dsi *dsi =host_to_dsi (host); +mutex_lock (&dsi->panel_mutex); + + dsi->panel_bridge =NULL ;drm_of_panel_bridge_remove (host->dev->of_node,1 ,0 );drm_bridge_remove (&dsi->bridge); +mutex_unlock (&dsi->panel_mutex); +return 0 ; } +bool dw_mipi_dsi_device_attached (struct dw_mipi_dsi *dsi)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, · line 339
Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +10
-0+{ +bool output; + +mutex_lock (&dsi->panel_mutex); + output = !!dsi->panel_bridge; +mutex_unlock (&dsi->panel_mutex); + +return output; +} +EXPORT_SYMBOL_GPL (dw_mipi_dsi_device_attached);
The function does not make sense. After releasing panel_mutex device can be detached/(re-)attached multiple times. Ie it reports useless information. Of course in most cases it will work as expected, but for sure it is not bulletproof.
Regards
Andrzej
Quoted 18 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +3
-0+static void dw_mipi_message_config (struct dw_mipi_dsi *dsi,const struct mipi_dsi_msg *msg) {@@ -867,6 +890,8 @@ __dw_mipi_dsi_probe(struct platform_device *pdev, dsi->dev = dev; dsi->plat_data = plat_data; +mutex_init (&dsi->panel_mutex); +if (!plat_data->phy_ops->init || !plat_data->phy_ops->get_lane_mbps) {DRM_ERROR ("Phy not properly configured\n" );return ERR_PTR (-ENODEV );include/drm/bridge/dw_mipi_dsi.h +0
-0
include/drm/bridge/dw_mipi_dsi.h struct dw_mipi_dsi_plat_data { · line 37
Quoted 7 lines
include/drm/bridge/dw_mipi_dsi.h +1
-0@@ -31,6 +31,7 @@ struct dw_mipi_dsi_plat_data {void *priv_data; }; +bool dw_mipi_dsi_device_attached (struct dw_mipi_dsi *dsi);struct dw_mipi_dsi *dw_mipi_dsi_probe (struct platform_device *pdev,const struct dw_mipi_dsi_plat_data *plat_data);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerRe: [PATCH v3 3/8] drm/bridge/synopsys: dsi: add ability to check dsi-device attachment
Hi Andrzej,
Am Montag, 13. August 2018, 10:28:39 CEST schrieb Andrzej Hajda:
Quoted 82 lines · Heiko Stuebner
Quoted 81 lines
When the panel-driver is build as a module it currently fails hard as the panel cannot be probed directly:
dw_mipi_dsi_bind()
__dw_mipi_dsi_probe()
creates dsi bus
creates panel device
triggers panel module load
panel not probed (module not loaded or panel probe slow)
drm_bridge_attach
fails with-EINVALdue to emptypanel_bridgeAdditionally the panel probing can run concurrently with dsi bringup making it possible that the panel can already be found but dsi-attach hasn't finished running.
The newly added function provides the ability for glue drivers to check if a dsi device was actually attached and also protects the attach part to prevent concurrency issues from panel-assignment and
drm_bridge_create.Using that check glue drivers are able to for example defer probe/bind in the case that the panel is not completely set up yet.
Signed-off-by Heiko Stuebner <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 25 +++++++++++++++++++ include/drm/bridge/dw_mipi_dsi.h | 1 + 2 files changed, 26 insertions(+)drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +11
-0@@ -12,6 +12,7 @@#include <linux/component.h> #include <linux/iopoll.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/of_device.h> #include <linux/pm_runtime.h> #include <linux/reset.h> @@ -219,6 +220,7 @@ struct dw_mipi_dsi {struct drm_bridge bridge;struct mipi_dsi_host dsi_host;struct drm_bridge *panel_bridge; +struct mutex panel_mutex;struct device *dev;void __iomem *base;@@ -296,10 +298,14 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,return PTR_ERR (bridge); } +mutex_lock (&dsi->panel_mutex); + dsi->panel_bridge = bridge;drm_bridge_add (&dsi->bridge); +mutex_unlock (&dsi->panel_mutex); +return 0 ; }@@ -308,13 +314,30 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, {struct dw_mipi_dsi *dsi =host_to_dsi (host); +mutex_lock (&dsi->panel_mutex); + + dsi->panel_bridge =NULL ;drm_of_panel_bridge_remove (host->dev->of_node,1 ,0 );drm_bridge_remove (&dsi->bridge); +mutex_unlock (&dsi->panel_mutex); +return 0 ; }
Quoted 16 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, · line 339
Quoted 11 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +11
-0+bool dw_mipi_dsi_device_attached (struct dw_mipi_dsi *dsi) +{ +bool output; + +mutex_lock (&dsi->panel_mutex); + output = !!dsi->panel_bridge; +mutex_unlock (&dsi->panel_mutex); + +return output; +} +EXPORT_SYMBOL_GPL (dw_mipi_dsi_device_attached);The function does not make sense. After releasing
panel_mutexdevice can be detached/(re-)attached multiple times. Ie it reports useless information. Of course in most cases it will work as expected, but for sure it is not bulletproof.
Ok. Can you suggest how we should check for the described case? I.e. initially I tried to simply defer in dw_mipi_dsi_bridge_attach [0] where you suggested to do that in probe.
I moved the check to bind - see patch 5 - to fix the issue regarding panel only probing after the dsi bus gets created, so this function is a means to check if the panel has finished attaching, or to defer binding - see dw_mipi_dsi_rockchip_bind in patch 5.
So I'm somewhat out of ideas right now, how to do this right.
Thanks
Heiko
[0] https://patchwork.kernel.org/patch/10470821/
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 3/8] drm/bridge/synopsys: dsi: add ability to check dsi-device attachment
Quoted 104 lines · Heiko Stuebner
Hi Andrzej,
Am Montag, 13. August 2018, 10:28:39 CEST schrieb Andrzej Hajda:
Quoted 82 lines · Heiko Stuebner
Quoted 81 lines
When the panel-driver is build as a module it currently fails hard as the panel cannot be probed directly:
dw_mipi_dsi_bind()
__dw_mipi_dsi_probe()
creates dsi bus
creates panel device
triggers panel module load
panel not probed (module not loaded or panel probe slow)
drm_bridge_attach
fails with-EINVALdue to emptypanel_bridgeAdditionally the panel probing can run concurrently with dsi bringup making it possible that the panel can already be found but dsi-attach hasn't finished running.
The newly added function provides the ability for glue drivers to check if a dsi device was actually attached and also protects the attach part to prevent concurrency issues from panel-assignment and
drm_bridge_create.Using that check glue drivers are able to for example defer probe/bind in the case that the panel is not completely set up yet.
Signed-off-by Heiko Stuebner <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 25 +++++++++++++++++++ include/drm/bridge/dw_mipi_dsi.h | 1 + 2 files changed, 26 insertions(+)drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +11
-0@@ -12,6 +12,7 @@#include <linux/component.h> #include <linux/iopoll.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/of_device.h> #include <linux/pm_runtime.h> #include <linux/reset.h> @@ -219,6 +220,7 @@ struct dw_mipi_dsi {struct drm_bridge bridge;struct mipi_dsi_host dsi_host;struct drm_bridge *panel_bridge; +struct mutex panel_mutex;struct device *dev;void __iomem *base;@@ -296,10 +298,14 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,return PTR_ERR (bridge); } +mutex_lock (&dsi->panel_mutex); + dsi->panel_bridge = bridge;drm_bridge_add (&dsi->bridge); +mutex_unlock (&dsi->panel_mutex); +return 0 ; }@@ -308,13 +314,30 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, {struct dw_mipi_dsi *dsi =host_to_dsi (host); +mutex_lock (&dsi->panel_mutex); + + dsi->panel_bridge =NULL ;drm_of_panel_bridge_remove (host->dev->of_node,1 ,0 );drm_bridge_remove (&dsi->bridge); +mutex_unlock (&dsi->panel_mutex); +return 0 ; }Quoted 15 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, · line 339
Quoted 11 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +11
-0+bool dw_mipi_dsi_device_attached (struct dw_mipi_dsi *dsi) +{ +bool output; + +mutex_lock (&dsi->panel_mutex); + output = !!dsi->panel_bridge; +mutex_unlock (&dsi->panel_mutex); + +return output; +} +EXPORT_SYMBOL_GPL (dw_mipi_dsi_device_attached);The function does not make sense. After releasing
panel_mutexdevice can be detached/(re-)attached multiple times. Ie it reports useless information. Of course in most cases it will work as expected, but for sure it is not bulletproof.Ok. Can you suggest how we should check for the described case? I.e. initially I tried to simply defer in
dw_mipi_dsi_bridge_attach[0] where you suggested to do that in probe.
Quoted 6 lines
I moved the check to bind - see patch 5 - to fix the issue regarding panel only probing after the dsi bus gets created, so this function is a means to check if the panel has finished attaching, or to defer binding - see
dw_mipi_dsi_rockchip_bindin patch 5.So I'm somewhat out of ideas right now, how to do this right.
I am just after vacation, so please be kind if I write sth stupid :)
I would stick to the rule "do not expose functionality until you gather required resources".
With this in mind I would try this way:
1. In bridge probe create mipi bus, but do not expose drm_bridge and do not call component_add - because we still do not have the sink (downstream panel or bridge).
2. In mipi_dsi_host_attach callback gather sink resource and then expose drm_bridge and the component (by calling component_add) - it will work with assumption the sink is registered/added before attaching to dsi bus [*].
3. Similar way it should be done in remove path.
This way in bind callback all resources should be there.
[*]: This could be seen as sth against the rule "first resources, then exposition", but since panel/bridge framework does not provide notification about appearance of the objects, it works as a workaround for missing notification system.
Regards
Andrzej
Quoted 10 lines
Thanks
Heiko
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Heiko Stuebner
maintainerRe: [PATCH v3 3/8] drm/bridge/synopsys: dsi: add ability to check dsi-device attachment
Hi Andrzej,
Am Montag, 13. August 2018, 12:23:21 CEST schrieb Andrzej Hajda:
Quoted 31 lines · Heiko Stuebner
Quoted 21 lines
Am Montag, 13. August 2018, 10:28:39 CEST schrieb Andrzej Hajda:
Quoted 8 lines · Heiko Stuebner
Quoted 7 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +7
-0+bool dw_mipi_dsi_device_attached (struct dw_mipi_dsi *dsi) +{ +bool output; + +mutex_lock (&dsi->panel_mutex); + output = !!dsi->panel_bridge; +mutex_unlock (&dsi->panel_mutex);Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, · line 339
Quoted 4 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +4
-0+ +return output; +} +EXPORT_SYMBOL_GPL (dw_mipi_dsi_device_attached);The function does not make sense. After releasing
panel_mutexdevice can be detached/(re-)attached multiple times. Ie it reports useless information. Of course in most cases it will work as expected, but for sure it is not bulletproof.Ok. Can you suggest how we should check for the described case? I.e. initially I tried to simply defer in
dw_mipi_dsi_bridge_attach[0] where you suggested to do that in probe.Quoted 6 lines
I moved the check to bind - see patch 5 - to fix the issue regarding panel only probing after the dsi bus gets created, so this function is a means to check if the panel has finished attaching, or to defer binding - see
dw_mipi_dsi_rockchip_bindin patch 5.So I'm somewhat out of ideas right now, how to do this right.
I am just after vacation, so please be kind if I write sth stupid :)
Quoted 9 lines
I would stick to the rule "do not expose functionality until you gather required resources".
With this in mind I would try this way:
1. In bridge probe create mipi bus, but do not exposedrm_bridgeand do not callcomponent_add- because we still do not have the sink (downstream panel or bridge).
2. Inmipi_dsi_host_attachcallback gather sink resource and then exposedrm_bridgeand the component (by callingcomponent_add) - it will work with assumption the sink is registered/added before attaching to dsi bus
I think that is the general consensus in all kernel parts, like when you request an irq, the driver should be able to handle it firing immediately, so similarly a dsi-sink should in a position to be directly usable after it attached to the dsi host.
Quoted 4 lines
[*].
3. Similar way it should be done in remove path.This way in bind callback all resources should be there.
You're a genius ... That seems to work like a charm :-D .
v4 following shortly :-)
Quoted 4 lines
[*]: This could be seen as sth against the rule "first resources, then exposition", but since panel/bridge framework does not provide notification about appearance of the objects, it works as a workaround for missing notification system.
Actually I'd say it follows that paradigm way better now, as the component framework only tries to bring up the component hierarchy after all resources are in place.
And now I even don't get any deferrals at all, where it was around 2 deferrals waiting for the panel before. So in terms of being deterministic this feels like a plus :-)
Heiko
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel