2023-02-17 06:53:15

by Liu Ying

[permalink] [raw]
Subject: [PATCH v4 0/6] drm: lcdif: Add i.MX93 LCDIF support

Hi,

This patch set aims to add i.MX93 LCDIF display controller support
in the existing LCDIF DRM driver. The LCDIF embedded in i.MX93 SoC
is essentially the same to those embedded in i.MX8mp SoC. Through
internal bridges, i.MX93 LCDIF may drive a MIPI DSI display or a LVDS
display or a parallel display.

Patch 1/6 adds device tree binding support for i.MX93 LCDIF in the
existing fsl,lcdif.yaml.

Patch 2/6 drops lcdif->bridge NULL pointer check as a cleanup patch.

Patch 3/6~5/6 prepare for adding i.MX93 LCDIF support step by step.

Patch 6/6 adds i.MX93 LCDIF compatible string as the last step of
adding i.MX93 LCDIF support.

v3->v4:
* Improve warning message when ignoring invalid LCDIF OF endpoint ids in
patch 5/6. (Alexander)
* Use 'new_{c,p}state' instead of 'new_{crtc,plane}_state' in patch 3/6.
(Alexander)
* Simplify lcdif_crtc_reset() by calling lcdif_crtc_atomic_destroy_state()
in patch 3/6. (Alexander)
* Add '!crtc->state' check in lcdif_crtc_atomic_duplicate_state() in patch 3/6.
(Alexander)
* Collect Alexander's R-b tags on patch 1/6, 2/6 and 6/6.

v2->v3:
* Fix a trivial typo in patch 6/6's commit message.

v1->v2:
* Add Krzysztof's A-b and Marek's R-b tags on patch 1/6.
* Split patch 2/2 in v1 into patch 2/6~6/6 in v2. (Marek, Alexander)
* Drop '!remote ||' from lcdif_attach_bridge(). (Lothar)
* Add comment on the 'base' member of lcdif_crtc_state structure to
note it should always be the first member. (Lothar)
* Drop unneeded 'bridges' member from lcdif_drm_private structure.
* Drop a comment about bridge input bus format from lcdif_crtc_atomic_check().

Liu Ying (6):
dt-bindings: lcdif: Add i.MX93 LCDIF support
drm: lcdif: Drop unnecessary NULL pointer check on lcdif->bridge
drm: lcdif: Determine bus format and flags in ->atomic_check()
drm: lcdif: Check consistent bus format and flags across first bridges
drm: lcdif: Add multiple encoders and first bridges support
drm: lcdif: Add i.MX93 LCDIF compatible string

.../bindings/display/fsl,lcdif.yaml | 7 +-
drivers/gpu/drm/mxsfb/lcdif_drv.c | 71 ++++++-
drivers/gpu/drm/mxsfb/lcdif_drv.h | 5 +-
drivers/gpu/drm/mxsfb/lcdif_kms.c | 198 ++++++++++++------
4 files changed, 206 insertions(+), 75 deletions(-)

--
2.37.1



2023-02-17 06:53:18

by Liu Ying

[permalink] [raw]
Subject: [PATCH v4 1/6] dt-bindings: lcdif: Add i.MX93 LCDIF support

There is one LCDIF embedded in i.MX93 SoC to connect with
MIPI DSI controller through LCDIF cross line pattern(controlled
by mediamix blk-ctrl) or connect with LVDS display bridge(LDB)
directly or connect with a parallel display through parallel
display format(also controlled by mediamix blk-ctrl). i.MX93
LCDIF IP is essentially the same to i.MX8MP LCDIF IP. Add device
tree binding for i.MX93 LCDIF.

Acked-by: Krzysztof Kozlowski <[email protected]>
Reviewed-by: Marek Vasut <[email protected]>
Reviewed-by: Alexander Stein <[email protected]>
Signed-off-by: Liu Ying <[email protected]>
---
v3->v4:
* Add Alexander's R-b tag.

v2->v3:
* No change.

v1->v2:
* Add Krzysztof's A-b and Marek's R-b tags.

Documentation/devicetree/bindings/display/fsl,lcdif.yaml | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/fsl,lcdif.yaml b/Documentation/devicetree/bindings/display/fsl,lcdif.yaml
index 75b4efd70ba8..fc11ab5fc465 100644
--- a/Documentation/devicetree/bindings/display/fsl,lcdif.yaml
+++ b/Documentation/devicetree/bindings/display/fsl,lcdif.yaml
@@ -21,6 +21,7 @@ properties:
- fsl,imx28-lcdif
- fsl,imx6sx-lcdif
- fsl,imx8mp-lcdif
+ - fsl,imx93-lcdif
- items:
- enum:
- fsl,imx6sl-lcdif
@@ -88,7 +89,9 @@ allOf:
properties:
compatible:
contains:
- const: fsl,imx8mp-lcdif
+ enum:
+ - fsl,imx8mp-lcdif
+ - fsl,imx93-lcdif
then:
properties:
clocks:
@@ -107,6 +110,7 @@ allOf:
enum:
- fsl,imx6sx-lcdif
- fsl,imx8mp-lcdif
+ - fsl,imx93-lcdif
then:
properties:
clocks:
@@ -123,6 +127,7 @@ allOf:
- fsl,imx8mm-lcdif
- fsl,imx8mn-lcdif
- fsl,imx8mp-lcdif
+ - fsl,imx93-lcdif
then:
required:
- power-domains
--
2.37.1


2023-02-17 06:53:32

by Liu Ying

[permalink] [raw]
Subject: [PATCH v4 2/6] drm: lcdif: Drop unnecessary NULL pointer check on lcdif->bridge

A valid bridge is already found in lcdif_attach_bridge() and set
to lcdif->bridge, so lcdif->bridge cannot be a NULL pointer. Drop
the unnecessary NULL pointer check in KMS stage.

Reviewed-by: Alexander Stein <[email protected]>
Signed-off-by: Liu Ying <[email protected]>
---
v3->v4:
* Add Alexander's R-b tag.

v2->v3:
* No change.

v1->v2:
* Split from patch 2/2 in v1. (Marek, Alexander)

drivers/gpu/drm/mxsfb/lcdif_kms.c | 33 +++++++++++--------------------
1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c
index 262bc43b1079..e54200a9fcb9 100644
--- a/drivers/gpu/drm/mxsfb/lcdif_kms.c
+++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c
@@ -394,7 +394,7 @@ static void lcdif_crtc_mode_set_nofb(struct lcdif_drm_private *lcdif,
struct drm_display_mode *m = &lcdif->crtc.state->adjusted_mode;
u32 bus_flags = 0;

- if (lcdif->bridge && lcdif->bridge->timings)
+ if (lcdif->bridge->timings)
bus_flags = lcdif->bridge->timings->input_bus_flags;
else if (bridge_state)
bus_flags = bridge_state->input_bus_cfg.flags;
@@ -463,30 +463,21 @@ static void lcdif_crtc_atomic_enable(struct drm_crtc *crtc,
struct drm_display_mode *m = &lcdif->crtc.state->adjusted_mode;
struct drm_bridge_state *bridge_state = NULL;
struct drm_device *drm = lcdif->drm;
- u32 bus_format = 0;
+ u32 bus_format;
dma_addr_t paddr;

- /* If there is a bridge attached to the LCDIF, use its bus format */
- if (lcdif->bridge) {
- bridge_state =
- drm_atomic_get_new_bridge_state(state,
- lcdif->bridge);
- if (!bridge_state)
- bus_format = MEDIA_BUS_FMT_FIXED;
- else
- bus_format = bridge_state->input_bus_cfg.format;
-
- if (bus_format == MEDIA_BUS_FMT_FIXED) {
- dev_warn_once(drm->dev,
- "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n"
- "Please fix bridge driver by handling atomic_get_input_bus_fmts.\n");
- bus_format = MEDIA_BUS_FMT_RGB888_1X24;
- }
- }
+ bridge_state = drm_atomic_get_new_bridge_state(state, lcdif->bridge);
+ if (!bridge_state)
+ bus_format = MEDIA_BUS_FMT_FIXED;
+ else
+ bus_format = bridge_state->input_bus_cfg.format;

- /* If all else fails, default to RGB888_1X24 */
- if (!bus_format)
+ if (bus_format == MEDIA_BUS_FMT_FIXED) {
+ dev_warn_once(drm->dev,
+ "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n"
+ "Please fix bridge driver by handling atomic_get_input_bus_fmts.\n");
bus_format = MEDIA_BUS_FMT_RGB888_1X24;
+ }

clk_set_rate(lcdif->clk, m->crtc_clock * 1000);

--
2.37.1


2023-02-17 06:53:40

by Liu Ying

[permalink] [raw]
Subject: [PATCH v4 3/6] drm: lcdif: Determine bus format and flags in ->atomic_check()

Instead of determining LCDIF output bus format and bus flags in
->atomic_enable(), do that in ->atomic_check(). This is a
preparation for the upcoming patch to check consistent bus format
and bus flags across all first downstream bridges in ->atomic_check().
New lcdif_crtc_state structure is introduced to cache bus format
and bus flags states in ->atomic_check() so that they can be read
in ->atomic_enable().

Signed-off-by: Liu Ying <[email protected]>
---
v3->v4:
* Use 'new_{c,p}state' instead of 'new_{crtc,plane}_state'. (Alexander)
* Simplify lcdif_crtc_reset() by calling lcdif_crtc_atomic_destroy_state().
(Alexander)
* Add '!crtc->state' check in lcdif_crtc_atomic_duplicate_state(). (Alexander)

v2->v3:
* No change.

v1->v2:
* Split from patch 2/2 in v1. (Marek, Alexander)
* Add comment on the 'base' member of lcdif_crtc_state structure to
note it should always be the first member. (Lothar)

drivers/gpu/drm/mxsfb/lcdif_kms.c | 134 ++++++++++++++++++++++--------
1 file changed, 99 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c
index e54200a9fcb9..d46de433cd8e 100644
--- a/drivers/gpu/drm/mxsfb/lcdif_kms.c
+++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c
@@ -30,6 +30,18 @@
#include "lcdif_drv.h"
#include "lcdif_regs.h"

+struct lcdif_crtc_state {
+ struct drm_crtc_state base; /* always be the first member */
+ u32 bus_format;
+ u32 bus_flags;
+};
+
+static inline struct lcdif_crtc_state *
+to_lcdif_crtc_state(struct drm_crtc_state *s)
+{
+ return container_of(s, struct lcdif_crtc_state, base);
+}
+
/* -----------------------------------------------------------------------------
* CRTC
*/
@@ -385,48 +397,72 @@ static void lcdif_reset_block(struct lcdif_drm_private *lcdif)
readl(lcdif->base + LCDC_V8_CTRL);
}

-static void lcdif_crtc_mode_set_nofb(struct lcdif_drm_private *lcdif,
- struct drm_plane_state *plane_state,
- struct drm_bridge_state *bridge_state,
- const u32 bus_format)
+static void lcdif_crtc_mode_set_nofb(struct drm_crtc_state *crtc_state,
+ struct drm_plane_state *plane_state)
{
- struct drm_device *drm = lcdif->crtc.dev;
- struct drm_display_mode *m = &lcdif->crtc.state->adjusted_mode;
- u32 bus_flags = 0;
-
- if (lcdif->bridge->timings)
- bus_flags = lcdif->bridge->timings->input_bus_flags;
- else if (bridge_state)
- bus_flags = bridge_state->input_bus_cfg.flags;
+ struct lcdif_crtc_state *lcdif_crtc_state = to_lcdif_crtc_state(crtc_state);
+ struct drm_device *drm = crtc_state->crtc->dev;
+ struct lcdif_drm_private *lcdif = to_lcdif_drm_private(drm);
+ struct drm_display_mode *m = &crtc_state->adjusted_mode;

DRM_DEV_DEBUG_DRIVER(drm->dev, "Pixel clock: %dkHz (actual: %dkHz)\n",
m->crtc_clock,
(int)(clk_get_rate(lcdif->clk) / 1000));
DRM_DEV_DEBUG_DRIVER(drm->dev, "Bridge bus_flags: 0x%08X\n",
- bus_flags);
+ lcdif_crtc_state->bus_flags);
DRM_DEV_DEBUG_DRIVER(drm->dev, "Mode flags: 0x%08X\n", m->flags);

/* Mandatory eLCDIF reset as per the Reference Manual */
lcdif_reset_block(lcdif);

- lcdif_set_formats(lcdif, plane_state, bus_format);
+ lcdif_set_formats(lcdif, plane_state, lcdif_crtc_state->bus_format);

- lcdif_set_mode(lcdif, bus_flags);
+ lcdif_set_mode(lcdif, lcdif_crtc_state->bus_flags);
}

static int lcdif_crtc_atomic_check(struct drm_crtc *crtc,
struct drm_atomic_state *state)
{
+ struct drm_device *drm = crtc->dev;
+ struct lcdif_drm_private *lcdif = to_lcdif_drm_private(drm);
struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
crtc);
+ struct lcdif_crtc_state *lcdif_crtc_state = to_lcdif_crtc_state(crtc_state);
bool has_primary = crtc_state->plane_mask &
drm_plane_mask(crtc->primary);
+ struct drm_bridge_state *bridge_state;
+ struct drm_bridge *bridge = lcdif->bridge;
+ int ret;

/* The primary plane has to be enabled when the CRTC is active. */
if (crtc_state->active && !has_primary)
return -EINVAL;

- return drm_atomic_add_affected_planes(state, crtc);
+ ret = drm_atomic_add_affected_planes(state, crtc);
+ if (ret)
+ return ret;
+
+ bridge_state = drm_atomic_get_new_bridge_state(state, bridge);
+ if (!bridge_state)
+ lcdif_crtc_state->bus_format = MEDIA_BUS_FMT_FIXED;
+ else
+ lcdif_crtc_state->bus_format = bridge_state->input_bus_cfg.format;
+
+ if (lcdif_crtc_state->bus_format == MEDIA_BUS_FMT_FIXED) {
+ dev_warn_once(drm->dev,
+ "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n"
+ "Please fix bridge driver by handling atomic_get_input_bus_fmts.\n");
+ lcdif_crtc_state->bus_format = MEDIA_BUS_FMT_RGB888_1X24;
+ }
+
+ if (bridge->timings)
+ lcdif_crtc_state->bus_flags = bridge->timings->input_bus_flags;
+ else if (bridge_state)
+ lcdif_crtc_state->bus_flags = bridge_state->input_bus_cfg.flags;
+ else
+ lcdif_crtc_state->bus_flags = 0;
+
+ return 0;
}

static void lcdif_crtc_atomic_flush(struct drm_crtc *crtc,
@@ -458,32 +494,18 @@ static void lcdif_crtc_atomic_enable(struct drm_crtc *crtc,
struct drm_atomic_state *state)
{
struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->dev);
+ struct drm_crtc_state *new_cstate = drm_atomic_get_new_crtc_state(state, crtc);
struct drm_plane_state *new_pstate = drm_atomic_get_new_plane_state(state,
crtc->primary);
struct drm_display_mode *m = &lcdif->crtc.state->adjusted_mode;
- struct drm_bridge_state *bridge_state = NULL;
struct drm_device *drm = lcdif->drm;
- u32 bus_format;
dma_addr_t paddr;

- bridge_state = drm_atomic_get_new_bridge_state(state, lcdif->bridge);
- if (!bridge_state)
- bus_format = MEDIA_BUS_FMT_FIXED;
- else
- bus_format = bridge_state->input_bus_cfg.format;
-
- if (bus_format == MEDIA_BUS_FMT_FIXED) {
- dev_warn_once(drm->dev,
- "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n"
- "Please fix bridge driver by handling atomic_get_input_bus_fmts.\n");
- bus_format = MEDIA_BUS_FMT_RGB888_1X24;
- }
-
clk_set_rate(lcdif->clk, m->crtc_clock * 1000);

pm_runtime_get_sync(drm->dev);

- lcdif_crtc_mode_set_nofb(lcdif, new_pstate, bridge_state, bus_format);
+ lcdif_crtc_mode_set_nofb(new_cstate, new_pstate);

/* Write cur_buf as well to avoid an initial corrupt frame */
paddr = drm_fb_dma_get_gem_addr(new_pstate->fb, new_pstate, 0);
@@ -520,6 +542,48 @@ static void lcdif_crtc_atomic_disable(struct drm_crtc *crtc,
pm_runtime_put_sync(drm->dev);
}

+static void lcdif_crtc_atomic_destroy_state(struct drm_crtc *crtc,
+ struct drm_crtc_state *state)
+{
+ __drm_atomic_helper_crtc_destroy_state(state);
+ kfree(to_lcdif_crtc_state(state));
+}
+
+static void lcdif_crtc_reset(struct drm_crtc *crtc)
+{
+ struct lcdif_crtc_state *state;
+
+ if (crtc->state)
+ lcdif_crtc_atomic_destroy_state(crtc, crtc->state);
+
+ crtc->state = NULL;
+
+ state = kzalloc(sizeof(*state), GFP_KERNEL);
+ if (state)
+ __drm_atomic_helper_crtc_reset(crtc, &state->base);
+}
+
+static struct drm_crtc_state *
+lcdif_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
+{
+ struct lcdif_crtc_state *old = to_lcdif_crtc_state(crtc->state);
+ struct lcdif_crtc_state *new;
+
+ if (WARN_ON(!crtc->state))
+ return NULL;
+
+ new = kzalloc(sizeof(*new), GFP_KERNEL);
+ if (!new)
+ return NULL;
+
+ __drm_atomic_helper_crtc_duplicate_state(crtc, &new->base);
+
+ new->bus_format = old->bus_format;
+ new->bus_flags = old->bus_flags;
+
+ return &new->base;
+}
+
static int lcdif_crtc_enable_vblank(struct drm_crtc *crtc)
{
struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->dev);
@@ -548,12 +612,12 @@ static const struct drm_crtc_helper_funcs lcdif_crtc_helper_funcs = {
};

static const struct drm_crtc_funcs lcdif_crtc_funcs = {
- .reset = drm_atomic_helper_crtc_reset,
+ .reset = lcdif_crtc_reset,
.destroy = drm_crtc_cleanup,
.set_config = drm_atomic_helper_set_config,
.page_flip = drm_atomic_helper_page_flip,
- .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
- .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+ .atomic_duplicate_state = lcdif_crtc_atomic_duplicate_state,
+ .atomic_destroy_state = lcdif_crtc_atomic_destroy_state,
.enable_vblank = lcdif_crtc_enable_vblank,
.disable_vblank = lcdif_crtc_disable_vblank,
};
--
2.37.1


2023-02-17 06:54:00

by Liu Ying

[permalink] [raw]
Subject: [PATCH v4 5/6] drm: lcdif: Add multiple encoders and first bridges support

The single LCDIF embedded in i.MX93 SoC may drive multiple displays
simultaneously. Look at LCDIF output port's remote port parents to
find all enabled first bridges. Add an encoder for each found bridge
and attach the bridge to the encoder. This is a preparation for
adding i.MX93 LCDIF support.

Signed-off-by: Liu Ying <[email protected]>
---
v3->v4:
* Improve warning message when ignoring invalid LCDIF OF endpoint ids.
(Alexander)

v2->v3:
* No change.

v1->v2:
* Split from patch 2/2 in v1. (Marek, Alexander)
* Drop '!remote ||' from lcdif_attach_bridge(). (Lothar)
* Drop unneeded 'bridges' member from lcdif_drm_private structure.

drivers/gpu/drm/mxsfb/lcdif_drv.c | 68 +++++++++++++++++++++++++++----
drivers/gpu/drm/mxsfb/lcdif_drv.h | 4 +-
drivers/gpu/drm/mxsfb/lcdif_kms.c | 21 ++--------
3 files changed, 66 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c
index b5b9a8e273c6..f1f5caef390a 100644
--- a/drivers/gpu/drm/mxsfb/lcdif_drv.c
+++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c
@@ -9,13 +9,16 @@
#include <linux/dma-mapping.h>
#include <linux/io.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/of_device.h>
+#include <linux/of_graph.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>

#include <drm/drm_atomic_helper.h>
#include <drm/drm_bridge.h>
#include <drm/drm_drv.h>
+#include <drm/drm_encoder.h>
#include <drm/drm_fbdev_generic.h>
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
@@ -38,19 +41,68 @@ static const struct drm_mode_config_helper_funcs lcdif_mode_config_helpers = {
.atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
};

+static const struct drm_encoder_funcs lcdif_encoder_funcs = {
+ .destroy = drm_encoder_cleanup,
+};
+
static int lcdif_attach_bridge(struct lcdif_drm_private *lcdif)
{
- struct drm_device *drm = lcdif->drm;
+ struct device *dev = lcdif->drm->dev;
+ struct device_node *ep;
struct drm_bridge *bridge;
int ret;

- bridge = devm_drm_of_get_bridge(drm->dev, drm->dev->of_node, 0, 0);
- if (IS_ERR(bridge))
- return PTR_ERR(bridge);
-
- ret = drm_bridge_attach(&lcdif->encoder, bridge, NULL, 0);
- if (ret)
- return dev_err_probe(drm->dev, ret, "Failed to attach bridge\n");
+ for_each_endpoint_of_node(dev->of_node, ep) {
+ struct device_node *remote;
+ struct of_endpoint of_ep;
+ struct drm_encoder *encoder;
+
+ remote = of_graph_get_remote_port_parent(ep);
+ if (!of_device_is_available(remote)) {
+ of_node_put(remote);
+ continue;
+ }
+ of_node_put(remote);
+
+ ret = of_graph_parse_endpoint(ep, &of_ep);
+ if (ret < 0) {
+ dev_err(dev, "Failed to parse endpoint %pOF\n", ep);
+ of_node_put(ep);
+ return ret;
+ }
+
+ if (of_ep.id >= MAX_DISPLAYS) {
+ dev_warn(dev, "ingoring invalid endpoint id %u\n", of_ep.id);
+ continue;
+ }
+
+ bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0, of_ep.id);
+ if (IS_ERR(bridge)) {
+ of_node_put(ep);
+ return dev_err_probe(dev, PTR_ERR(bridge),
+ "Failed to get bridge for endpoint%u\n",
+ of_ep.id);
+ }
+
+ encoder = &lcdif->encoders[of_ep.id];
+ encoder->possible_crtcs = drm_crtc_mask(&lcdif->crtc);
+ ret = drm_encoder_init(lcdif->drm, encoder, &lcdif_encoder_funcs,
+ DRM_MODE_ENCODER_NONE, NULL);
+ if (ret) {
+ dev_err(dev, "Failed to initialize encoder for endpoint%u: %d\n",
+ of_ep.id, ret);
+ of_node_put(ep);
+ return ret;
+ }
+
+ ret = drm_bridge_attach(encoder, bridge, NULL, 0);
+ if (ret) {
+ of_node_put(ep);
+ return dev_err_probe(dev, ret,
+ "Failed to attach bridge for endpoint%u\n",
+ of_ep.id);
+ }
+ }

return 0;
}
diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.h b/drivers/gpu/drm/mxsfb/lcdif_drv.h
index aa6d099a1897..c7400bd9bbd9 100644
--- a/drivers/gpu/drm/mxsfb/lcdif_drv.h
+++ b/drivers/gpu/drm/mxsfb/lcdif_drv.h
@@ -14,6 +14,8 @@
#include <drm/drm_encoder.h>
#include <drm/drm_plane.h>

+#define MAX_DISPLAYS 3
+
struct clk;

struct lcdif_drm_private {
@@ -30,7 +32,7 @@ struct lcdif_drm_private {
/* i.MXRT does support overlay planes, add them here. */
} planes;
struct drm_crtc crtc;
- struct drm_encoder encoder;
+ struct drm_encoder encoders[MAX_DISPLAYS];
};

static inline struct lcdif_drm_private *
diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c
index d6009b353a16..c35d769f91dd 100644
--- a/drivers/gpu/drm/mxsfb/lcdif_kms.c
+++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c
@@ -656,14 +656,6 @@ static const struct drm_crtc_funcs lcdif_crtc_funcs = {
.disable_vblank = lcdif_crtc_disable_vblank,
};

-/* -----------------------------------------------------------------------------
- * Encoder
- */
-
-static const struct drm_encoder_funcs lcdif_encoder_funcs = {
- .destroy = drm_encoder_cleanup,
-};
-
/* -----------------------------------------------------------------------------
* Planes
*/
@@ -756,7 +748,6 @@ int lcdif_kms_init(struct lcdif_drm_private *lcdif)
BIT(DRM_COLOR_YCBCR_BT2020);
const u32 supported_ranges = BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
BIT(DRM_COLOR_YCBCR_FULL_RANGE);
- struct drm_encoder *encoder = &lcdif->encoder;
struct drm_crtc *crtc = &lcdif->crtc;
int ret;

@@ -780,13 +771,7 @@ int lcdif_kms_init(struct lcdif_drm_private *lcdif)
return ret;

drm_crtc_helper_add(crtc, &lcdif_crtc_helper_funcs);
- ret = drm_crtc_init_with_planes(lcdif->drm, crtc,
- &lcdif->planes.primary, NULL,
- &lcdif_crtc_funcs, NULL);
- if (ret)
- return ret;
-
- encoder->possible_crtcs = drm_crtc_mask(crtc);
- return drm_encoder_init(lcdif->drm, encoder, &lcdif_encoder_funcs,
- DRM_MODE_ENCODER_NONE, NULL);
+ return drm_crtc_init_with_planes(lcdif->drm, crtc,
+ &lcdif->planes.primary, NULL,
+ &lcdif_crtc_funcs, NULL);
}
--
2.37.1


2023-02-17 06:54:02

by Liu Ying

[permalink] [raw]
Subject: [PATCH v4 4/6] drm: lcdif: Check consistent bus format and flags across first bridges

The single LCDIF embedded in i.MX93 SoC may drive multiple displays
simultaneously. Check bus format and flags across first bridges in
->atomic_check() to ensure they are consistent. This is a preparation
for adding i.MX93 LCDIF support.

Signed-off-by: Liu Ying <[email protected]>
---
v3->v4:
* No change.

v2->v3:
* No change.

v1->v2:
* Split from patch 2/2 in v1. (Marek, Alexander)
* Drop a comment about bridge input bus format from lcdif_crtc_atomic_check().

drivers/gpu/drm/mxsfb/lcdif_drv.c | 2 -
drivers/gpu/drm/mxsfb/lcdif_drv.h | 1 -
drivers/gpu/drm/mxsfb/lcdif_kms.c | 76 ++++++++++++++++++++++---------
3 files changed, 55 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c
index cc2ceb301b96..b5b9a8e273c6 100644
--- a/drivers/gpu/drm/mxsfb/lcdif_drv.c
+++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c
@@ -52,8 +52,6 @@ static int lcdif_attach_bridge(struct lcdif_drm_private *lcdif)
if (ret)
return dev_err_probe(drm->dev, ret, "Failed to attach bridge\n");

- lcdif->bridge = bridge;
-
return 0;
}

diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.h b/drivers/gpu/drm/mxsfb/lcdif_drv.h
index 6cdba6e20c02..aa6d099a1897 100644
--- a/drivers/gpu/drm/mxsfb/lcdif_drv.h
+++ b/drivers/gpu/drm/mxsfb/lcdif_drv.h
@@ -31,7 +31,6 @@ struct lcdif_drm_private {
} planes;
struct drm_crtc crtc;
struct drm_encoder encoder;
- struct drm_bridge *bridge;
};

static inline struct lcdif_drm_private *
diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c
index d46de433cd8e..d6009b353a16 100644
--- a/drivers/gpu/drm/mxsfb/lcdif_kms.c
+++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c
@@ -17,6 +17,7 @@
#include <drm/drm_atomic_helper.h>
#include <drm/drm_bridge.h>
#include <drm/drm_color_mgmt.h>
+#include <drm/drm_connector.h>
#include <drm/drm_crtc.h>
#include <drm/drm_encoder.h>
#include <drm/drm_fb_dma_helper.h>
@@ -424,15 +425,19 @@ static int lcdif_crtc_atomic_check(struct drm_crtc *crtc,
struct drm_atomic_state *state)
{
struct drm_device *drm = crtc->dev;
- struct lcdif_drm_private *lcdif = to_lcdif_drm_private(drm);
struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
crtc);
struct lcdif_crtc_state *lcdif_crtc_state = to_lcdif_crtc_state(crtc_state);
bool has_primary = crtc_state->plane_mask &
drm_plane_mask(crtc->primary);
+ struct drm_connector_state *connector_state;
+ struct drm_connector *connector;
+ struct drm_encoder *encoder;
struct drm_bridge_state *bridge_state;
- struct drm_bridge *bridge = lcdif->bridge;
- int ret;
+ struct drm_bridge *bridge;
+ u32 bus_format, bus_flags;
+ bool format_set = false, flags_set = false;
+ int ret, i;

/* The primary plane has to be enabled when the CRTC is active. */
if (crtc_state->active && !has_primary)
@@ -442,26 +447,55 @@ static int lcdif_crtc_atomic_check(struct drm_crtc *crtc,
if (ret)
return ret;

- bridge_state = drm_atomic_get_new_bridge_state(state, bridge);
- if (!bridge_state)
- lcdif_crtc_state->bus_format = MEDIA_BUS_FMT_FIXED;
- else
- lcdif_crtc_state->bus_format = bridge_state->input_bus_cfg.format;
-
- if (lcdif_crtc_state->bus_format == MEDIA_BUS_FMT_FIXED) {
- dev_warn_once(drm->dev,
- "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n"
- "Please fix bridge driver by handling atomic_get_input_bus_fmts.\n");
- lcdif_crtc_state->bus_format = MEDIA_BUS_FMT_RGB888_1X24;
+ /* Try to find consistent bus format and flags across first bridges. */
+ for_each_new_connector_in_state(state, connector, connector_state, i) {
+ if (!connector_state->crtc)
+ continue;
+
+ encoder = connector_state->best_encoder;
+
+ bridge = drm_bridge_chain_get_first_bridge(encoder);
+ if (!bridge)
+ continue;
+
+ bridge_state = drm_atomic_get_new_bridge_state(state, bridge);
+ if (!bridge_state)
+ bus_format = MEDIA_BUS_FMT_FIXED;
+ else
+ bus_format = bridge_state->input_bus_cfg.format;
+
+ if (bus_format == MEDIA_BUS_FMT_FIXED) {
+ dev_warn(drm->dev,
+ "[ENCODER:%d:%s]'s bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n"
+ "Please fix bridge driver by handling atomic_get_input_bus_fmts.\n",
+ encoder->base.id, encoder->name);
+ bus_format = MEDIA_BUS_FMT_RGB888_1X24;
+ }
+
+ if (!format_set) {
+ lcdif_crtc_state->bus_format = bus_format;
+ format_set = true;
+ } else if (lcdif_crtc_state->bus_format != bus_format) {
+ DRM_DEV_DEBUG_DRIVER(drm->dev, "inconsistent bus format\n");
+ return -EINVAL;
+ }
+
+ if (bridge->timings)
+ bus_flags = bridge->timings->input_bus_flags;
+ else if (bridge_state)
+ bus_flags = bridge_state->input_bus_cfg.flags;
+ else
+ bus_flags = 0;
+
+ if (!flags_set) {
+ lcdif_crtc_state->bus_flags = bus_flags;
+ flags_set = true;
+ } else if (lcdif_crtc_state->bus_flags != bus_flags) {
+ DRM_DEV_DEBUG_DRIVER(drm->dev, "inconsistent bus flags\n");
+ return -EINVAL;
+ }
}

- if (bridge->timings)
- lcdif_crtc_state->bus_flags = bridge->timings->input_bus_flags;
- else if (bridge_state)
- lcdif_crtc_state->bus_flags = bridge_state->input_bus_cfg.flags;
- else
- lcdif_crtc_state->bus_flags = 0;
-
return 0;
}

--
2.37.1


2023-02-17 06:54:21

by Liu Ying

[permalink] [raw]
Subject: [PATCH v4 6/6] drm: lcdif: Add i.MX93 LCDIF compatible string

With all previous preparations done to make it possible for the
single LCDIF embedded in i.MX93 SoC to drive multiple displays
simultaneously, add i.MX93 LCDIF compatible string as the last
step of adding i.MX93 LCDIF support.

Reviewed-by: Alexander Stein <[email protected]>
Signed-off-by: Liu Ying <[email protected]>
---
v3->v4:
* Add Alexander's R-b tag.

v2->v3:
* Fix a trivial typo in commit message.

v1->v2:
* Split from patch 2/2 in v1. (Marek, Alexander)

drivers/gpu/drm/mxsfb/lcdif_drv.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c
index f1f5caef390a..0eb132cad181 100644
--- a/drivers/gpu/drm/mxsfb/lcdif_drv.c
+++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c
@@ -249,6 +249,7 @@ static const struct drm_driver lcdif_driver = {

static const struct of_device_id lcdif_dt_ids[] = {
{ .compatible = "fsl,imx8mp-lcdif" },
+ { .compatible = "fsl,imx93-lcdif" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, lcdif_dt_ids);
--
2.37.1


2023-02-17 08:09:23

by Alexander Stein

[permalink] [raw]
Subject: Re: [PATCH v4 3/6] drm: lcdif: Determine bus format and flags in ->atomic_check()

Hi Liu,

thanks for the update.

Am Freitag, 17. Februar 2023, 07:54:04 CET schrieb Liu Ying:
> Instead of determining LCDIF output bus format and bus flags in
> ->atomic_enable(), do that in ->atomic_check(). This is a
> preparation for the upcoming patch to check consistent bus format
> and bus flags across all first downstream bridges in ->atomic_check().
> New lcdif_crtc_state structure is introduced to cache bus format
> and bus flags states in ->atomic_check() so that they can be read
> in ->atomic_enable().
>
> Signed-off-by: Liu Ying <[email protected]>

Look good to me.
Reviewed-by: Alexander Stein <[email protected]>

> ---
> v3->v4:
> * Use 'new_{c,p}state' instead of 'new_{crtc,plane}_state'. (Alexander)
> * Simplify lcdif_crtc_reset() by calling lcdif_crtc_atomic_destroy_state().
> (Alexander)
> * Add '!crtc->state' check in lcdif_crtc_atomic_duplicate_state().
> (Alexander)
>
> v2->v3:
> * No change.
>
> v1->v2:
> * Split from patch 2/2 in v1. (Marek, Alexander)
> * Add comment on the 'base' member of lcdif_crtc_state structure to
> note it should always be the first member. (Lothar)
>
> drivers/gpu/drm/mxsfb/lcdif_kms.c | 134 ++++++++++++++++++++++--------
> 1 file changed, 99 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c
> b/drivers/gpu/drm/mxsfb/lcdif_kms.c index e54200a9fcb9..d46de433cd8e 100644
> --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c
> +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c
> @@ -30,6 +30,18 @@
> #include "lcdif_drv.h"
> #include "lcdif_regs.h"
>
> +struct lcdif_crtc_state {
> + struct drm_crtc_state base; /* always be the first
member */
> + u32 bus_format;
> + u32 bus_flags;
> +};
> +
> +static inline struct lcdif_crtc_state *
> +to_lcdif_crtc_state(struct drm_crtc_state *s)
> +{
> + return container_of(s, struct lcdif_crtc_state, base);
> +}
> +
> /*
> ---------------------------------------------------------------------------
> -- * CRTC
> */
> @@ -385,48 +397,72 @@ static void lcdif_reset_block(struct lcdif_drm_private
> *lcdif) readl(lcdif->base + LCDC_V8_CTRL);
> }
>
> -static void lcdif_crtc_mode_set_nofb(struct lcdif_drm_private *lcdif,
> - struct drm_plane_state
*plane_state,
> - struct drm_bridge_state
*bridge_state,
> - const u32 bus_format)
> +static void lcdif_crtc_mode_set_nofb(struct drm_crtc_state *crtc_state,
> + struct drm_plane_state
*plane_state)
> {
> - struct drm_device *drm = lcdif->crtc.dev;
> - struct drm_display_mode *m = &lcdif->crtc.state->adjusted_mode;
> - u32 bus_flags = 0;
> -
> - if (lcdif->bridge->timings)
> - bus_flags = lcdif->bridge->timings->input_bus_flags;
> - else if (bridge_state)
> - bus_flags = bridge_state->input_bus_cfg.flags;
> + struct lcdif_crtc_state *lcdif_crtc_state =
> to_lcdif_crtc_state(crtc_state); + struct drm_device *drm =
> crtc_state->crtc->dev;
> + struct lcdif_drm_private *lcdif = to_lcdif_drm_private(drm);
> + struct drm_display_mode *m = &crtc_state->adjusted_mode;
>
> DRM_DEV_DEBUG_DRIVER(drm->dev, "Pixel clock: %dkHz (actual: %dkHz)
\n",
> m->crtc_clock,
> (int)(clk_get_rate(lcdif->clk) / 1000));
> DRM_DEV_DEBUG_DRIVER(drm->dev, "Bridge bus_flags: 0x%08X\n",
> - bus_flags);
> + lcdif_crtc_state->bus_flags);
> DRM_DEV_DEBUG_DRIVER(drm->dev, "Mode flags: 0x%08X\n", m->flags);
>
> /* Mandatory eLCDIF reset as per the Reference Manual */
> lcdif_reset_block(lcdif);
>
> - lcdif_set_formats(lcdif, plane_state, bus_format);
> + lcdif_set_formats(lcdif, plane_state, lcdif_crtc_state->bus_format);
>
> - lcdif_set_mode(lcdif, bus_flags);
> + lcdif_set_mode(lcdif, lcdif_crtc_state->bus_flags);
> }
>
> static int lcdif_crtc_atomic_check(struct drm_crtc *crtc,
> struct drm_atomic_state *state)
> {
> + struct drm_device *drm = crtc->dev;
> + struct lcdif_drm_private *lcdif = to_lcdif_drm_private(drm);
> struct drm_crtc_state *crtc_state =
drm_atomic_get_new_crtc_state(state,
>
crtc);
> + struct lcdif_crtc_state *lcdif_crtc_state =
> to_lcdif_crtc_state(crtc_state); bool has_primary = crtc_state->plane_mask
> &
> drm_plane_mask(crtc->primary);
> + struct drm_bridge_state *bridge_state;
> + struct drm_bridge *bridge = lcdif->bridge;
> + int ret;
>
> /* The primary plane has to be enabled when the CRTC is active. */
> if (crtc_state->active && !has_primary)
> return -EINVAL;
>
> - return drm_atomic_add_affected_planes(state, crtc);
> + ret = drm_atomic_add_affected_planes(state, crtc);
> + if (ret)
> + return ret;
> +
> + bridge_state = drm_atomic_get_new_bridge_state(state, bridge);
> + if (!bridge_state)
> + lcdif_crtc_state->bus_format = MEDIA_BUS_FMT_FIXED;
> + else
> + lcdif_crtc_state->bus_format = bridge_state-
>input_bus_cfg.format;
> +
> + if (lcdif_crtc_state->bus_format == MEDIA_BUS_FMT_FIXED) {
> + dev_warn_once(drm->dev,
> + "Bridge does not provide bus format,
assuming
> MEDIA_BUS_FMT_RGB888_1X24.\n" + "Please fix
bridge driver by
> handling atomic_get_input_bus_fmts.\n"); + lcdif_crtc_state-
>bus_format =
> MEDIA_BUS_FMT_RGB888_1X24;
> + }
> +
> + if (bridge->timings)
> + lcdif_crtc_state->bus_flags = bridge->timings-
>input_bus_flags;
> + else if (bridge_state)
> + lcdif_crtc_state->bus_flags = bridge_state-
>input_bus_cfg.flags;
> + else
> + lcdif_crtc_state->bus_flags = 0;
> +
> + return 0;
> }
>
> static void lcdif_crtc_atomic_flush(struct drm_crtc *crtc,
> @@ -458,32 +494,18 @@ static void lcdif_crtc_atomic_enable(struct drm_crtc
> *crtc, struct drm_atomic_state *state)
> {
> struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->dev);
> + struct drm_crtc_state *new_cstate =
drm_atomic_get_new_crtc_state(state,
> crtc); struct drm_plane_state *new_pstate =
> drm_atomic_get_new_plane_state(state, crtc->primary);
> struct drm_display_mode *m = &lcdif->crtc.state->adjusted_mode;
> - struct drm_bridge_state *bridge_state = NULL;
> struct drm_device *drm = lcdif->drm;
> - u32 bus_format;
> dma_addr_t paddr;
>
> - bridge_state = drm_atomic_get_new_bridge_state(state, lcdif-
>bridge);
> - if (!bridge_state)
> - bus_format = MEDIA_BUS_FMT_FIXED;
> - else
> - bus_format = bridge_state->input_bus_cfg.format;
> -
> - if (bus_format == MEDIA_BUS_FMT_FIXED) {
> - dev_warn_once(drm->dev,
> - "Bridge does not provide bus format,
assuming
> MEDIA_BUS_FMT_RGB888_1X24.\n" - "Please fix
bridge driver by
> handling atomic_get_input_bus_fmts.\n"); - bus_format =
> MEDIA_BUS_FMT_RGB888_1X24;
> - }
> -
> clk_set_rate(lcdif->clk, m->crtc_clock * 1000);
>
> pm_runtime_get_sync(drm->dev);
>
> - lcdif_crtc_mode_set_nofb(lcdif, new_pstate, bridge_state,
bus_format);
> + lcdif_crtc_mode_set_nofb(new_cstate, new_pstate);
>
> /* Write cur_buf as well to avoid an initial corrupt frame */
> paddr = drm_fb_dma_get_gem_addr(new_pstate->fb, new_pstate, 0);
> @@ -520,6 +542,48 @@ static void lcdif_crtc_atomic_disable(struct drm_crtc
> *crtc, pm_runtime_put_sync(drm->dev);
> }
>
> +static void lcdif_crtc_atomic_destroy_state(struct drm_crtc *crtc,
> + struct drm_crtc_state
*state)
> +{
> + __drm_atomic_helper_crtc_destroy_state(state);
> + kfree(to_lcdif_crtc_state(state));
> +}
> +
> +static void lcdif_crtc_reset(struct drm_crtc *crtc)
> +{
> + struct lcdif_crtc_state *state;
> +
> + if (crtc->state)
> + lcdif_crtc_atomic_destroy_state(crtc, crtc->state);
> +
> + crtc->state = NULL;
> +
> + state = kzalloc(sizeof(*state), GFP_KERNEL);
> + if (state)
> + __drm_atomic_helper_crtc_reset(crtc, &state->base);
> +}
> +
> +static struct drm_crtc_state *
> +lcdif_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
> +{
> + struct lcdif_crtc_state *old = to_lcdif_crtc_state(crtc->state);
> + struct lcdif_crtc_state *new;
> +
> + if (WARN_ON(!crtc->state))
> + return NULL;
> +
> + new = kzalloc(sizeof(*new), GFP_KERNEL);
> + if (!new)
> + return NULL;
> +
> + __drm_atomic_helper_crtc_duplicate_state(crtc, &new->base);
> +
> + new->bus_format = old->bus_format;
> + new->bus_flags = old->bus_flags;
> +
> + return &new->base;
> +}
> +
> static int lcdif_crtc_enable_vblank(struct drm_crtc *crtc)
> {
> struct lcdif_drm_private *lcdif = to_lcdif_drm_private(crtc->dev);
> @@ -548,12 +612,12 @@ static const struct drm_crtc_helper_funcs
> lcdif_crtc_helper_funcs = { };
>
> static const struct drm_crtc_funcs lcdif_crtc_funcs = {
> - .reset = drm_atomic_helper_crtc_reset,
> + .reset = lcdif_crtc_reset,
> .destroy = drm_crtc_cleanup,
> .set_config = drm_atomic_helper_set_config,
> .page_flip = drm_atomic_helper_page_flip,
> - .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
> - .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
> + .atomic_duplicate_state = lcdif_crtc_atomic_duplicate_state,
> + .atomic_destroy_state = lcdif_crtc_atomic_destroy_state,
> .enable_vblank = lcdif_crtc_enable_vblank,
> .disable_vblank = lcdif_crtc_disable_vblank,
> };


--
TQ-Systems GmbH | M?hlstra?e 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht M?nchen, HRB 105018
Gesch?ftsf?hrer: Detlef Schneider, R?diger Stahl, Stefan Schneider
http://www.tq-group.com/



2023-02-17 08:10:42

by Alexander Stein

[permalink] [raw]
Subject: Re: [PATCH v4 4/6] drm: lcdif: Check consistent bus format and flags across first bridges

Hi Liu,

thanks for this update.

Am Freitag, 17. Februar 2023, 07:54:05 CET schrieb Liu Ying:
> The single LCDIF embedded in i.MX93 SoC may drive multiple displays
> simultaneously. Check bus format and flags across first bridges in
> ->atomic_check() to ensure they are consistent. This is a preparation
> for adding i.MX93 LCDIF support.
>
> Signed-off-by: Liu Ying <[email protected]>

Acked-by: Alexander Stein <[email protected]>
> ---
> v3->v4:
> * No change.
>
> v2->v3:
> * No change.
>
> v1->v2:
> * Split from patch 2/2 in v1. (Marek, Alexander)
> * Drop a comment about bridge input bus format from
> lcdif_crtc_atomic_check().
>
> drivers/gpu/drm/mxsfb/lcdif_drv.c | 2 -
> drivers/gpu/drm/mxsfb/lcdif_drv.h | 1 -
> drivers/gpu/drm/mxsfb/lcdif_kms.c | 76 ++++++++++++++++++++++---------
> 3 files changed, 55 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c
> b/drivers/gpu/drm/mxsfb/lcdif_drv.c index cc2ceb301b96..b5b9a8e273c6 100644
> --- a/drivers/gpu/drm/mxsfb/lcdif_drv.c
> +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c
> @@ -52,8 +52,6 @@ static int lcdif_attach_bridge(struct lcdif_drm_private
> *lcdif) if (ret)
> return dev_err_probe(drm->dev, ret, "Failed to attach
bridge\n");
>
> - lcdif->bridge = bridge;
> -
> return 0;
> }
>
> diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.h
> b/drivers/gpu/drm/mxsfb/lcdif_drv.h index 6cdba6e20c02..aa6d099a1897 100644
> --- a/drivers/gpu/drm/mxsfb/lcdif_drv.h
> +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.h
> @@ -31,7 +31,6 @@ struct lcdif_drm_private {
> } planes;
> struct drm_crtc crtc;
> struct drm_encoder encoder;
> - struct drm_bridge *bridge;
> };
>
> static inline struct lcdif_drm_private *
> diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c
> b/drivers/gpu/drm/mxsfb/lcdif_kms.c index d46de433cd8e..d6009b353a16 100644
> --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c
> +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c
> @@ -17,6 +17,7 @@
> #include <drm/drm_atomic_helper.h>
> #include <drm/drm_bridge.h>
> #include <drm/drm_color_mgmt.h>
> +#include <drm/drm_connector.h>
> #include <drm/drm_crtc.h>
> #include <drm/drm_encoder.h>
> #include <drm/drm_fb_dma_helper.h>
> @@ -424,15 +425,19 @@ static int lcdif_crtc_atomic_check(struct drm_crtc
> *crtc, struct drm_atomic_state *state)
> {
> struct drm_device *drm = crtc->dev;
> - struct lcdif_drm_private *lcdif = to_lcdif_drm_private(drm);
> struct drm_crtc_state *crtc_state =
drm_atomic_get_new_crtc_state(state,
>
crtc);
> struct lcdif_crtc_state *lcdif_crtc_state =
> to_lcdif_crtc_state(crtc_state); bool has_primary = crtc_state->plane_mask
> &
> drm_plane_mask(crtc->primary);
> + struct drm_connector_state *connector_state;
> + struct drm_connector *connector;
> + struct drm_encoder *encoder;
> struct drm_bridge_state *bridge_state;
> - struct drm_bridge *bridge = lcdif->bridge;
> - int ret;
> + struct drm_bridge *bridge;
> + u32 bus_format, bus_flags;
> + bool format_set = false, flags_set = false;
> + int ret, i;
>
> /* The primary plane has to be enabled when the CRTC is active. */
> if (crtc_state->active && !has_primary)
> @@ -442,26 +447,55 @@ static int lcdif_crtc_atomic_check(struct drm_crtc
> *crtc, if (ret)
> return ret;
>
> - bridge_state = drm_atomic_get_new_bridge_state(state, bridge);
> - if (!bridge_state)
> - lcdif_crtc_state->bus_format = MEDIA_BUS_FMT_FIXED;
> - else
> - lcdif_crtc_state->bus_format = bridge_state-
>input_bus_cfg.format;
> -
> - if (lcdif_crtc_state->bus_format == MEDIA_BUS_FMT_FIXED) {
> - dev_warn_once(drm->dev,
> - "Bridge does not provide bus format,
assuming
> MEDIA_BUS_FMT_RGB888_1X24.\n" - "Please fix
bridge driver by
> handling atomic_get_input_bus_fmts.\n"); - lcdif_crtc_state-
>bus_format =
> MEDIA_BUS_FMT_RGB888_1X24;
> + /* Try to find consistent bus format and flags across first bridges.
*/
> + for_each_new_connector_in_state(state, connector, connector_state,
i) {
> + if (!connector_state->crtc)
> + continue;
> +
> + encoder = connector_state->best_encoder;
> +
> + bridge = drm_bridge_chain_get_first_bridge(encoder);
> + if (!bridge)
> + continue;
> +
> + bridge_state = drm_atomic_get_new_bridge_state(state,
bridge);
> + if (!bridge_state)
> + bus_format = MEDIA_BUS_FMT_FIXED;
> + else
> + bus_format = bridge_state->input_bus_cfg.format;
> +
> + if (bus_format == MEDIA_BUS_FMT_FIXED) {
> + dev_warn(drm->dev,
> + "[ENCODER:%d:%s]'s bridge does not
provide bus format, assuming
> MEDIA_BUS_FMT_RGB888_1X24.\n" +
"Please fix bridge driver by handling
> atomic_get_input_bus_fmts.\n", +
encoder->base.id, encoder->name);
> + bus_format = MEDIA_BUS_FMT_RGB888_1X24;
> + }
> +
> + if (!format_set) {
> + lcdif_crtc_state->bus_format = bus_format;
> + format_set = true;
> + } else if (lcdif_crtc_state->bus_format != bus_format) {
> + DRM_DEV_DEBUG_DRIVER(drm->dev, "inconsistent bus
format\n");
> + return -EINVAL;
> + }
> +
> + if (bridge->timings)
> + bus_flags = bridge->timings->input_bus_flags;
> + else if (bridge_state)
> + bus_flags = bridge_state->input_bus_cfg.flags;
> + else
> + bus_flags = 0;
> +
> + if (!flags_set) {
> + lcdif_crtc_state->bus_flags = bus_flags;
> + flags_set = true;
> + } else if (lcdif_crtc_state->bus_flags != bus_flags) {
> + DRM_DEV_DEBUG_DRIVER(drm->dev, "inconsistent bus
flags\n");
> + return -EINVAL;
> + }
> }
>
> - if (bridge->timings)
> - lcdif_crtc_state->bus_flags = bridge->timings-
>input_bus_flags;
> - else if (bridge_state)
> - lcdif_crtc_state->bus_flags = bridge_state-
>input_bus_cfg.flags;
> - else
> - lcdif_crtc_state->bus_flags = 0;
> -
> return 0;
> }


--
TQ-Systems GmbH | M?hlstra?e 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht M?nchen, HRB 105018
Gesch?ftsf?hrer: Detlef Schneider, R?diger Stahl, Stefan Schneider
http://www.tq-group.com/



2023-02-17 08:12:49

by Alexander Stein

[permalink] [raw]
Subject: Re: [PATCH v4 5/6] drm: lcdif: Add multiple encoders and first bridges support

Hi Liu,

thanks for the update.

Am Freitag, 17. Februar 2023, 07:54:06 CET schrieb Liu Ying:
> The single LCDIF embedded in i.MX93 SoC may drive multiple displays
> simultaneously. Look at LCDIF output port's remote port parents to
> find all enabled first bridges. Add an encoder for each found bridge
> and attach the bridge to the encoder. This is a preparation for
> adding i.MX93 LCDIF support.
>
> Signed-off-by: Liu Ying <[email protected]>

Acked-by: Alexander Stein <[email protected]>

> ---
> v3->v4:
> * Improve warning message when ignoring invalid LCDIF OF endpoint ids.
> (Alexander)
>
> v2->v3:
> * No change.
>
> v1->v2:
> * Split from patch 2/2 in v1. (Marek, Alexander)
> * Drop '!remote ||' from lcdif_attach_bridge(). (Lothar)
> * Drop unneeded 'bridges' member from lcdif_drm_private structure.
>
> drivers/gpu/drm/mxsfb/lcdif_drv.c | 68 +++++++++++++++++++++++++++----
> drivers/gpu/drm/mxsfb/lcdif_drv.h | 4 +-
> drivers/gpu/drm/mxsfb/lcdif_kms.c | 21 ++--------
> 3 files changed, 66 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c
> b/drivers/gpu/drm/mxsfb/lcdif_drv.c index b5b9a8e273c6..f1f5caef390a 100644
> --- a/drivers/gpu/drm/mxsfb/lcdif_drv.c
> +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c
> @@ -9,13 +9,16 @@
> #include <linux/dma-mapping.h>
> #include <linux/io.h>
> #include <linux/module.h>
> +#include <linux/of.h>
> #include <linux/of_device.h>
> +#include <linux/of_graph.h>
> #include <linux/platform_device.h>
> #include <linux/pm_runtime.h>
>
> #include <drm/drm_atomic_helper.h>
> #include <drm/drm_bridge.h>
> #include <drm/drm_drv.h>
> +#include <drm/drm_encoder.h>
> #include <drm/drm_fbdev_generic.h>
> #include <drm/drm_gem_dma_helper.h>
> #include <drm/drm_gem_framebuffer_helper.h>
> @@ -38,19 +41,68 @@ static const struct drm_mode_config_helper_funcs
> lcdif_mode_config_helpers = { .atomic_commit_tail =
> drm_atomic_helper_commit_tail_rpm,
> };
>
> +static const struct drm_encoder_funcs lcdif_encoder_funcs = {
> + .destroy = drm_encoder_cleanup,
> +};
> +
> static int lcdif_attach_bridge(struct lcdif_drm_private *lcdif)
> {
> - struct drm_device *drm = lcdif->drm;
> + struct device *dev = lcdif->drm->dev;
> + struct device_node *ep;
> struct drm_bridge *bridge;
> int ret;
>
> - bridge = devm_drm_of_get_bridge(drm->dev, drm->dev->of_node, 0, 0);
> - if (IS_ERR(bridge))
> - return PTR_ERR(bridge);
> -
> - ret = drm_bridge_attach(&lcdif->encoder, bridge, NULL, 0);
> - if (ret)
> - return dev_err_probe(drm->dev, ret, "Failed to attach
bridge\n");
> + for_each_endpoint_of_node(dev->of_node, ep) {
> + struct device_node *remote;
> + struct of_endpoint of_ep;
> + struct drm_encoder *encoder;
> +
> + remote = of_graph_get_remote_port_parent(ep);
> + if (!of_device_is_available(remote)) {
> + of_node_put(remote);
> + continue;
> + }
> + of_node_put(remote);
> +
> + ret = of_graph_parse_endpoint(ep, &of_ep);
> + if (ret < 0) {
> + dev_err(dev, "Failed to parse endpoint %pOF\n",
ep);
> + of_node_put(ep);
> + return ret;
> + }
> +
> + if (of_ep.id >= MAX_DISPLAYS) {
> + dev_warn(dev, "ingoring invalid endpoint id
%u\n", of_ep.id);
> + continue;
> + }
> +
> + bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0,
of_ep.id);
> + if (IS_ERR(bridge)) {
> + of_node_put(ep);
> + return dev_err_probe(dev, PTR_ERR(bridge),
> + "Failed to get bridge
for endpoint%u\n",
> + of_ep.id);
> + }
> +
> + encoder = &lcdif->encoders[of_ep.id];
> + encoder->possible_crtcs = drm_crtc_mask(&lcdif->crtc);
> + ret = drm_encoder_init(lcdif->drm, encoder,
&lcdif_encoder_funcs,
> + DRM_MODE_ENCODER_NONE, NULL);
> + if (ret) {
> + dev_err(dev, "Failed to initialize encoder for
endpoint%u: %d\n",
> + of_ep.id, ret);
> + of_node_put(ep);
> + return ret;
> + }
> +
> + ret = drm_bridge_attach(encoder, bridge, NULL, 0);
> + if (ret) {
> + of_node_put(ep);
> + return dev_err_probe(dev, ret,
> + "Failed to attach
bridge for endpoint%u\n",
> + of_ep.id);
> + }
> + }
>
> return 0;
> }
> diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.h
> b/drivers/gpu/drm/mxsfb/lcdif_drv.h index aa6d099a1897..c7400bd9bbd9 100644
> --- a/drivers/gpu/drm/mxsfb/lcdif_drv.h
> +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.h
> @@ -14,6 +14,8 @@
> #include <drm/drm_encoder.h>
> #include <drm/drm_plane.h>
>
> +#define MAX_DISPLAYS 3
> +
> struct clk;
>
> struct lcdif_drm_private {
> @@ -30,7 +32,7 @@ struct lcdif_drm_private {
> /* i.MXRT does support overlay planes, add them here. */
> } planes;
> struct drm_crtc crtc;
> - struct drm_encoder encoder;
> + struct drm_encoder encoders[MAX_DISPLAYS];
> };
>
> static inline struct lcdif_drm_private *
> diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c
> b/drivers/gpu/drm/mxsfb/lcdif_kms.c index d6009b353a16..c35d769f91dd 100644
> --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c
> +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c
> @@ -656,14 +656,6 @@ static const struct drm_crtc_funcs lcdif_crtc_funcs = {
> .disable_vblank = lcdif_crtc_disable_vblank,
> };
>
> -/*
> ---------------------------------------------------------------------------
> -- - * Encoder
> - */
> -
> -static const struct drm_encoder_funcs lcdif_encoder_funcs = {
> - .destroy = drm_encoder_cleanup,
> -};
> -
> /*
> ---------------------------------------------------------------------------
> -- * Planes
> */
> @@ -756,7 +748,6 @@ int lcdif_kms_init(struct lcdif_drm_private *lcdif)
> BIT(DRM_COLOR_YCBCR_BT2020);
> const u32 supported_ranges = BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
> BIT(DRM_COLOR_YCBCR_FULL_RANGE);
> - struct drm_encoder *encoder = &lcdif->encoder;
> struct drm_crtc *crtc = &lcdif->crtc;
> int ret;
>
> @@ -780,13 +771,7 @@ int lcdif_kms_init(struct lcdif_drm_private *lcdif)
> return ret;
>
> drm_crtc_helper_add(crtc, &lcdif_crtc_helper_funcs);
> - ret = drm_crtc_init_with_planes(lcdif->drm, crtc,
> - &lcdif->planes.primary,
NULL,
> - &lcdif_crtc_funcs, NULL);
> - if (ret)
> - return ret;
> -
> - encoder->possible_crtcs = drm_crtc_mask(crtc);
> - return drm_encoder_init(lcdif->drm, encoder, &lcdif_encoder_funcs,
> - DRM_MODE_ENCODER_NONE, NULL);
> + return drm_crtc_init_with_planes(lcdif->drm, crtc,
> + &lcdif->planes.primary,
NULL,
> + &lcdif_crtc_funcs, NULL);
> }


--
TQ-Systems GmbH | M?hlstra?e 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht M?nchen, HRB 105018
Gesch?ftsf?hrer: Detlef Schneider, R?diger Stahl, Stefan Schneider
http://www.tq-group.com/



2023-02-17 08:18:35

by Alexander Stein

[permalink] [raw]
Subject: Re: [PATCH v4 0/6] drm: lcdif: Add i.MX93 LCDIF support

Hi Liu,

Am Freitag, 17. Februar 2023, 07:54:01 CET schrieb Liu Ying:
> Hi,
>
> This patch set aims to add i.MX93 LCDIF display controller support
> in the existing LCDIF DRM driver. The LCDIF embedded in i.MX93 SoC
> is essentially the same to those embedded in i.MX8mp SoC. Through
> internal bridges, i.MX93 LCDIF may drive a MIPI DSI display or a LVDS
> display or a parallel display.
>
> Patch 1/6 adds device tree binding support for i.MX93 LCDIF in the
> existing fsl,lcdif.yaml.
>
> Patch 2/6 drops lcdif->bridge NULL pointer check as a cleanup patch.
>
> Patch 3/6~5/6 prepare for adding i.MX93 LCDIF support step by step.
>
> Patch 6/6 adds i.MX93 LCDIF compatible string as the last step of
> adding i.MX93 LCDIF support.

Thanks for the series. I could test this on my TQMa93xxLA/MBa93xxCA with a
single LVDS display attached, so no DSI or parallel display. Hence I could not
test the bus format and flags checks, but they look okay.
So you can add
Tested-by: Alexander Stein <[email protected]>
to the whole series as well.

One thing I noticed is that, sometimes it seems that before probing lcdif my
system completely freezes. Adding some debug output it seems that's during
powering up the IMX93_MEDIABLK_PD_LCDIF power domain there is some race
condition. But adding more more detailed output made the problem go away.
Did you notice something similar? It might be a red hering though.

Best regards,
Alexander

>
> v3->v4:
> * Improve warning message when ignoring invalid LCDIF OF endpoint ids in
> patch 5/6. (Alexander)
> * Use 'new_{c,p}state' instead of 'new_{crtc,plane}_state' in patch 3/6.
> (Alexander)
> * Simplify lcdif_crtc_reset() by calling lcdif_crtc_atomic_destroy_state()
> in patch 3/6. (Alexander)
> * Add '!crtc->state' check in lcdif_crtc_atomic_duplicate_state() in patch
> 3/6. (Alexander)
> * Collect Alexander's R-b tags on patch 1/6, 2/6 and 6/6.
>
> v2->v3:
> * Fix a trivial typo in patch 6/6's commit message.
>
> v1->v2:
> * Add Krzysztof's A-b and Marek's R-b tags on patch 1/6.
> * Split patch 2/2 in v1 into patch 2/6~6/6 in v2. (Marek, Alexander)
> * Drop '!remote ||' from lcdif_attach_bridge(). (Lothar)
> * Add comment on the 'base' member of lcdif_crtc_state structure to
> note it should always be the first member. (Lothar)
> * Drop unneeded 'bridges' member from lcdif_drm_private structure.
> * Drop a comment about bridge input bus format from
> lcdif_crtc_atomic_check().
>
> Liu Ying (6):
> dt-bindings: lcdif: Add i.MX93 LCDIF support
> drm: lcdif: Drop unnecessary NULL pointer check on lcdif->bridge
> drm: lcdif: Determine bus format and flags in ->atomic_check()
> drm: lcdif: Check consistent bus format and flags across first bridges
> drm: lcdif: Add multiple encoders and first bridges support
> drm: lcdif: Add i.MX93 LCDIF compatible string
>
> .../bindings/display/fsl,lcdif.yaml | 7 +-
> drivers/gpu/drm/mxsfb/lcdif_drv.c | 71 ++++++-
> drivers/gpu/drm/mxsfb/lcdif_drv.h | 5 +-
> drivers/gpu/drm/mxsfb/lcdif_kms.c | 198 ++++++++++++------
> 4 files changed, 206 insertions(+), 75 deletions(-)


--
TQ-Systems GmbH | M?hlstra?e 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht M?nchen, HRB 105018
Gesch?ftsf?hrer: Detlef Schneider, R?diger Stahl, Stefan Schneider
http://www.tq-group.com/



2023-02-17 09:00:13

by Liu Ying

[permalink] [raw]
Subject: Re: [PATCH v4 0/6] drm: lcdif: Add i.MX93 LCDIF support

On Fri, 2023-02-17 at 09:18 +0100, Alexander Stein wrote:
> Hi Liu,

Hi Alexander,

>
> Am Freitag, 17. Februar 2023, 07:54:01 CET schrieb Liu Ying:
> > Hi,
> >
> > This patch set aims to add i.MX93 LCDIF display controller support
> > in the existing LCDIF DRM driver. The LCDIF embedded in i.MX93 SoC
> > is essentially the same to those embedded in i.MX8mp SoC. Through
> > internal bridges, i.MX93 LCDIF may drive a MIPI DSI display or a LVDS
> > display or a parallel display.
> >
> > Patch 1/6 adds device tree binding support for i.MX93 LCDIF in the
> > existing fsl,lcdif.yaml.
> >
> > Patch 2/6 drops lcdif->bridge NULL pointer check as a cleanup patch.
> >
> > Patch 3/6~5/6 prepare for adding i.MX93 LCDIF support step by step.
> >
> > Patch 6/6 adds i.MX93 LCDIF compatible string as the last step of
> > adding i.MX93 LCDIF support.
>
> Thanks for the series. I could test this on my TQMa93xxLA/MBa93xxCA with a
> single LVDS display attached, so no DSI or parallel display. Hence I could not
> test the bus format and flags checks, but they look okay.
> So you can add
> Tested-by: Alexander Stein <[email protected]>
> to the whole series as well.

Thanks for your test.

>
> One thing I noticed is that, sometimes it seems that before probing lcdif my
> system completely freezes. Adding some debug output it seems that's during
> powering up the IMX93_MEDIABLK_PD_LCDIF power domain there is some race
> condition. But adding more more detailed output made the problem go away.
> Did you notice something similar? It might be a red hering though.

I don't see system freezing with my i.MX93 11x11 EVK when probing
lcdif. I did try to boot the system several times. All look ok. This is
a snippet of dmesg when lcdif probes:

--------------------------8<------------------------------------------
[ 0.753083] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[ 0.761669] SuperH (H)SCI(F) driver initialized
[ 0.766523] msm_serial: driver initialized
[ 0.780523] printk: console [ttyLP0] enabled0x44380010 (irq = 16,
base_baud = 1500000) is a FSL_LPUART
[ 0.780523] printk: console [ttyLP0] enabled
[ 0.788928] printk: bootconsole [lpuart32] disabled
[ 0.788928] printk: bootconsole [lpuart32] disabled
[ 0.804632] panel-simple lvds_panel: supply power not found, using
dummy regulator
[ 0.814741] [drm] Initialized imx-lcdif 1.0.0 20220417 for
4ae30000.lcd-controller on minor 0
[ 1.195930] Console: switching to colour frame buffer device 160x50
[ 1.218385] imx-lcdif 4ae30000.lcd-controller: [drm] fb0: imx-
lcdifdrmfb frame buffer device
[ 1.227099] cacheinfo: Unable to detect cache hierarchy for CPU 0
[ 1.236725] loop: module loaded
--------------------------8<------------------------------------------

~300 milliseconds are consumed by the enablement delay required by the
"boe,ev121wxm-n10-1850" LVDS panel I use.

Regards,
Liu Ying

>
> Best regards,
> Alexander
>
> > v3->v4:
> > * Improve warning message when ignoring invalid LCDIF OF endpoint ids in
> > patch 5/6. (Alexander)
> > * Use 'new_{c,p}state' instead of 'new_{crtc,plane}_state' in patch 3/6.
> > (Alexander)
> > * Simplify lcdif_crtc_reset() by calling lcdif_crtc_atomic_destroy_state()
> > in patch 3/6. (Alexander)
> > * Add '!crtc->state' check in lcdif_crtc_atomic_duplicate_state() in patch
> > 3/6. (Alexander)
> > * Collect Alexander's R-b tags on patch 1/6, 2/6 and 6/6.
> >
> > v2->v3:
> > * Fix a trivial typo in patch 6/6's commit message.
> >
> > v1->v2:
> > * Add Krzysztof's A-b and Marek's R-b tags on patch 1/6.
> > * Split patch 2/2 in v1 into patch 2/6~6/6 in v2. (Marek, Alexander)
> > * Drop '!remote ||' from lcdif_attach_bridge(). (Lothar)
> > * Add comment on the 'base' member of lcdif_crtc_state structure to
> > note it should always be the first member. (Lothar)
> > * Drop unneeded 'bridges' member from lcdif_drm_private structure.
> > * Drop a comment about bridge input bus format from
> > lcdif_crtc_atomic_check().
> >
> > Liu Ying (6):
> > dt-bindings: lcdif: Add i.MX93 LCDIF support
> > drm: lcdif: Drop unnecessary NULL pointer check on lcdif->bridge
> > drm: lcdif: Determine bus format and flags in ->atomic_check()
> > drm: lcdif: Check consistent bus format and flags across first bridges
> > drm: lcdif: Add multiple encoders and first bridges support
> > drm: lcdif: Add i.MX93 LCDIF compatible string
> >
> > .../bindings/display/fsl,lcdif.yaml | 7 +-
> > drivers/gpu/drm/mxsfb/lcdif_drv.c | 71 ++++++-
> > drivers/gpu/drm/mxsfb/lcdif_drv.h | 5 +-
> > drivers/gpu/drm/mxsfb/lcdif_kms.c | 198 ++++++++++++------
> > 4 files changed, 206 insertions(+), 75 deletions(-)
>
>


2023-02-20 08:55:32

by Alexander Stein

[permalink] [raw]
Subject: Re: [PATCH v4 0/6] drm: lcdif: Add i.MX93 LCDIF support

Hi Liu,

Am Freitag, 17. Februar 2023, 09:59:14 CET schrieb Liu Ying:
> On Fri, 2023-02-17 at 09:18 +0100, Alexander Stein wrote:
> > Hi Liu,
>
> Hi Alexander,
>
> > Am Freitag, 17. Februar 2023, 07:54:01 CET schrieb Liu Ying:
> > > Hi,
> > >
> > > This patch set aims to add i.MX93 LCDIF display controller support
> > > in the existing LCDIF DRM driver. The LCDIF embedded in i.MX93 SoC
> > > is essentially the same to those embedded in i.MX8mp SoC. Through
> > > internal bridges, i.MX93 LCDIF may drive a MIPI DSI display or a LVDS
> > > display or a parallel display.
> > >
> > > Patch 1/6 adds device tree binding support for i.MX93 LCDIF in the
> > > existing fsl,lcdif.yaml.
> > >
> > > Patch 2/6 drops lcdif->bridge NULL pointer check as a cleanup patch.
> > >
> > > Patch 3/6~5/6 prepare for adding i.MX93 LCDIF support step by step.
> > >
> > > Patch 6/6 adds i.MX93 LCDIF compatible string as the last step of
> > > adding i.MX93 LCDIF support.
> >
> > Thanks for the series. I could test this on my TQMa93xxLA/MBa93xxCA with a
> > single LVDS display attached, so no DSI or parallel display. Hence I could
> > not test the bus format and flags checks, but they look okay.
> > So you can add
> > Tested-by: Alexander Stein <[email protected]>
> > to the whole series as well.
>
> Thanks for your test.
>
> > One thing I noticed is that, sometimes it seems that before probing lcdif
> > my system completely freezes. Adding some debug output it seems that's
> > during powering up the IMX93_MEDIABLK_PD_LCDIF power domain there is some
> > race condition. But adding more more detailed output made the problem go
> > away. Did you notice something similar? It might be a red hering though.
> I don't see system freezing with my i.MX93 11x11 EVK when probing
> lcdif. I did try to boot the system several times. All look ok. This is
> a snippet of dmesg when lcdif probes:
>
> --------------------------8<------------------------------------------
> [ 0.753083] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
> [ 0.761669] SuperH (H)SCI(F) driver initialized
> [ 0.766523] msm_serial: driver initialized
> [ 0.780523] printk: console [ttyLP0] enabled0x44380010 (irq = 16,
> base_baud = 1500000) is a FSL_LPUART
> [ 0.780523] printk: console [ttyLP0] enabled
> [ 0.788928] printk: bootconsole [lpuart32] disabled
> [ 0.788928] printk: bootconsole [lpuart32] disabled
> [ 0.804632] panel-simple lvds_panel: supply power not found, using
> dummy regulator
> [ 0.814741] [drm] Initialized imx-lcdif 1.0.0 20220417 for
> 4ae30000.lcd-controller on minor 0
> [ 1.195930] Console: switching to colour frame buffer device 160x50
> [ 1.218385] imx-lcdif 4ae30000.lcd-controller: [drm] fb0: imx-
> lcdifdrmfb frame buffer device
> [ 1.227099] cacheinfo: Unable to detect cache hierarchy for CPU 0
> [ 1.236725] loop: module loaded
> --------------------------8<------------------------------------------
>
> ~300 milliseconds are consumed by the enablement delay required by the
> "boe,ev121wxm-n10-1850" LVDS panel I use.

It seems you have the drivers compiled in. I use modules in my case and
simple-panel as well. But this is unrelated, because lcdif_probe() is yet to
be called. Using the debug diff from below I get the following output:

[ 16.111197] imx93-blk-ctrl 4ac10000.system-controller:
imx93_blk_ctrl_power_on: 1
[ 16.122491] imx93-blk-ctrl 4ac10000.system-controller:
imx93_blk_ctrl_power_on: 2
[ 16.137766] imx93-blk-ctrl 4ac10000.system-controller:
imx93_blk_ctrl_power_on: 3
[ 16.154905] imx93-blk-ctrl 4ac10000.system-controller:
imx93_blk_ctrl_power_on: 4

It seems setting BLK_CLK_EN blocks the whole system, even reading is not
possible. I don't have any details on the hardware, but it seems that either
some clock or power domain is not enabled. This can also happen if I'm loading
the lcdif module manually after boot. But I can't detect any differences in /
sys/kernel/debug/clk/clk_summary.

---8<---
diff --git a/drivers/soc/imx/imx93-blk-ctrl.c b/drivers/soc/imx/imx93-blk-
ctrl.c
index 2c600329436cf..50aeb20ce90dc 100644
--- a/drivers/soc/imx/imx93-blk-ctrl.c
+++ b/drivers/soc/imx/imx93-blk-ctrl.c
@@ -129,12 +129,14 @@ static int imx93_blk_ctrl_power_on(struct
generic_pm_domain *genpd)
struct imx93_blk_ctrl *bc = domain->bc;
int ret;

+ dev_info(bc->dev, "%s: 1\n", __func__);
ret = clk_bulk_prepare_enable(bc->num_clks, bc->clks);
if (ret) {
dev_err(bc->dev, "failed to enable bus clocks\n");
return ret;
}

+ dev_info(bc->dev, "%s: 2\n", __func__);
ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
if (ret) {
clk_bulk_disable_unprepare(bc->num_clks, bc->clks);
@@ -142,6 +144,7 @@ static int imx93_blk_ctrl_power_on(struct
generic_pm_domain *genpd)
return ret;
}

+ dev_info(bc->dev, "%s: 3\n", __func__);
ret = pm_runtime_get_sync(bc->dev);
if (ret < 0) {
pm_runtime_put_noidle(bc->dev);
@@ -149,11 +152,15 @@ static int imx93_blk_ctrl_power_on(struct
generic_pm_domain *genpd)
goto disable_clk;
}

+ dev_info(bc->dev, "%s: 4\n", __func__);
+
/* ungate clk */
regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
+ dev_info(bc->dev, "%s: 5\n", __func__);

/* release reset */
regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+ dev_info(bc->dev, "%s: 6\n", __func__);

dev_dbg(bc->dev, "pd_on: name: %s\n", genpd->name);


---8<---

Best regards,
Alexander

> Regards,
> Liu Ying
>
> > Best regards,
> > Alexander
> >
> > > v3->v4:
> > > * Improve warning message when ignoring invalid LCDIF OF endpoint ids in
> > >
> > > patch 5/6. (Alexander)
> > >
> > > * Use 'new_{c,p}state' instead of 'new_{crtc,plane}_state' in patch 3/6.
> > >
> > > (Alexander)
> > >
> > > * Simplify lcdif_crtc_reset() by calling
> > > lcdif_crtc_atomic_destroy_state()
> > >
> > > in patch 3/6. (Alexander)
> > >
> > > * Add '!crtc->state' check in lcdif_crtc_atomic_duplicate_state() in
> > > patch
> > > 3/6. (Alexander)
> > > * Collect Alexander's R-b tags on patch 1/6, 2/6 and 6/6.
> > >
> > > v2->v3:
> > > * Fix a trivial typo in patch 6/6's commit message.
> > >
> > > v1->v2:
> > > * Add Krzysztof's A-b and Marek's R-b tags on patch 1/6.
> > > * Split patch 2/2 in v1 into patch 2/6~6/6 in v2. (Marek, Alexander)
> > > * Drop '!remote ||' from lcdif_attach_bridge(). (Lothar)
> > > * Add comment on the 'base' member of lcdif_crtc_state structure to
> > >
> > > note it should always be the first member. (Lothar)
> > >
> > > * Drop unneeded 'bridges' member from lcdif_drm_private structure.
> > > * Drop a comment about bridge input bus format from
> > > lcdif_crtc_atomic_check().
> > >
> > > Liu Ying (6):
> > > dt-bindings: lcdif: Add i.MX93 LCDIF support
> > > drm: lcdif: Drop unnecessary NULL pointer check on lcdif->bridge
> > > drm: lcdif: Determine bus format and flags in ->atomic_check()
> > > drm: lcdif: Check consistent bus format and flags across first bridges
> > > drm: lcdif: Add multiple encoders and first bridges support
> > > drm: lcdif: Add i.MX93 LCDIF compatible string
> > >
> > > .../bindings/display/fsl,lcdif.yaml | 7 +-
> > > drivers/gpu/drm/mxsfb/lcdif_drv.c | 71 ++++++-
> > > drivers/gpu/drm/mxsfb/lcdif_drv.h | 5 +-
> > > drivers/gpu/drm/mxsfb/lcdif_kms.c | 198 ++++++++++++------
> > > 4 files changed, 206 insertions(+), 75 deletions(-)


--
TQ-Systems GmbH | M?hlstra?e 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht M?nchen, HRB 105018
Gesch?ftsf?hrer: Detlef Schneider, R?diger Stahl, Stefan Schneider
http://www.tq-group.com/



2023-02-20 10:16:51

by Alexander Stein

[permalink] [raw]
Subject: Re: [PATCH v4 0/6] drm: lcdif: Add i.MX93 LCDIF support

Hi Liu,

Am Montag, 20. Februar 2023, 09:55:19 CET schrieb Alexander Stein:
> Hi Liu,
>
> Am Freitag, 17. Februar 2023, 09:59:14 CET schrieb Liu Ying:
> > On Fri, 2023-02-17 at 09:18 +0100, Alexander Stein wrote:
> > > Hi Liu,
> >
> > Hi Alexander,
> >
> > > Am Freitag, 17. Februar 2023, 07:54:01 CET schrieb Liu Ying:
> > > > Hi,
> > > >
> > > > This patch set aims to add i.MX93 LCDIF display controller support
> > > > in the existing LCDIF DRM driver. The LCDIF embedded in i.MX93 SoC
> > > > is essentially the same to those embedded in i.MX8mp SoC. Through
> > > > internal bridges, i.MX93 LCDIF may drive a MIPI DSI display or a LVDS
> > > > display or a parallel display.
> > > >
> > > > Patch 1/6 adds device tree binding support for i.MX93 LCDIF in the
> > > > existing fsl,lcdif.yaml.
> > > >
> > > > Patch 2/6 drops lcdif->bridge NULL pointer check as a cleanup patch.
> > > >
> > > > Patch 3/6~5/6 prepare for adding i.MX93 LCDIF support step by step.
> > > >
> > > > Patch 6/6 adds i.MX93 LCDIF compatible string as the last step of
> > > > adding i.MX93 LCDIF support.
> > >
> > > Thanks for the series. I could test this on my TQMa93xxLA/MBa93xxCA with
> > > a
> > > single LVDS display attached, so no DSI or parallel display. Hence I
> > > could
> > > not test the bus format and flags checks, but they look okay.
> > > So you can add
> > > Tested-by: Alexander Stein <[email protected]>
> > > to the whole series as well.
> >
> > Thanks for your test.
> >
> > > One thing I noticed is that, sometimes it seems that before probing
> > > lcdif
> > > my system completely freezes. Adding some debug output it seems that's
> > > during powering up the IMX93_MEDIABLK_PD_LCDIF power domain there is
> > > some
> > > race condition. But adding more more detailed output made the problem go
> > > away. Did you notice something similar? It might be a red hering though.
> >
> > I don't see system freezing with my i.MX93 11x11 EVK when probing
> > lcdif. I did try to boot the system several times. All look ok. This is
> > a snippet of dmesg when lcdif probes:
> >
> > --------------------------8<------------------------------------------
> > [ 0.753083] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
> > [ 0.761669] SuperH (H)SCI(F) driver initialized
> > [ 0.766523] msm_serial: driver initialized
> > [ 0.780523] printk: console [ttyLP0] enabled0x44380010 (irq = 16,
> > base_baud = 1500000) is a FSL_LPUART
> > [ 0.780523] printk: console [ttyLP0] enabled
> > [ 0.788928] printk: bootconsole [lpuart32] disabled
> > [ 0.788928] printk: bootconsole [lpuart32] disabled
> > [ 0.804632] panel-simple lvds_panel: supply power not found, using
> > dummy regulator
> > [ 0.814741] [drm] Initialized imx-lcdif 1.0.0 20220417 for
> > 4ae30000.lcd-controller on minor 0
> > [ 1.195930] Console: switching to colour frame buffer device 160x50
> > [ 1.218385] imx-lcdif 4ae30000.lcd-controller: [drm] fb0: imx-
> > lcdifdrmfb frame buffer device
> > [ 1.227099] cacheinfo: Unable to detect cache hierarchy for CPU 0
> > [ 1.236725] loop: module loaded
> > --------------------------8<------------------------------------------
> >
> > ~300 milliseconds are consumed by the enablement delay required by the
> > "boe,ev121wxm-n10-1850" LVDS panel I use.
>
> It seems you have the drivers compiled in. I use modules in my case and
> simple-panel as well. But this is unrelated, because lcdif_probe() is yet to
> be called. Using the debug diff from below I get the following output:
>
> [ 16.111197] imx93-blk-ctrl 4ac10000.system-controller:
> imx93_blk_ctrl_power_on: 1
> [ 16.122491] imx93-blk-ctrl 4ac10000.system-controller:
> imx93_blk_ctrl_power_on: 2
> [ 16.137766] imx93-blk-ctrl 4ac10000.system-controller:
> imx93_blk_ctrl_power_on: 3
> [ 16.154905] imx93-blk-ctrl 4ac10000.system-controller:
> imx93_blk_ctrl_power_on: 4
>
> It seems setting BLK_CLK_EN blocks the whole system, even reading is not
> possible. I don't have any details on the hardware, but it seems that either
> some clock or power domain is not enabled. This can also happen if I'm
> loading the lcdif module manually after boot. But I can't detect any
> differences in / sys/kernel/debug/clk/clk_summary.

I think I found the cause. It's the maximum clock frequency for media_axi and
media_apb. These clocks were not explicitly configured, most probably
exceeding the maximum frequency allowed.

Best regards,
Alexander

> ---8<---
> diff --git a/drivers/soc/imx/imx93-blk-ctrl.c b/drivers/soc/imx/imx93-blk-
> ctrl.c
> index 2c600329436cf..50aeb20ce90dc 100644
> --- a/drivers/soc/imx/imx93-blk-ctrl.c
> +++ b/drivers/soc/imx/imx93-blk-ctrl.c
> @@ -129,12 +129,14 @@ static int imx93_blk_ctrl_power_on(struct
> generic_pm_domain *genpd)
> struct imx93_blk_ctrl *bc = domain->bc;
> int ret;
>
> + dev_info(bc->dev, "%s: 1\n", __func__);
> ret = clk_bulk_prepare_enable(bc->num_clks, bc->clks);
> if (ret) {
> dev_err(bc->dev, "failed to enable bus clocks\n");
> return ret;
> }
>
> + dev_info(bc->dev, "%s: 2\n", __func__);
> ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
> if (ret) {
> clk_bulk_disable_unprepare(bc->num_clks, bc->clks);
> @@ -142,6 +144,7 @@ static int imx93_blk_ctrl_power_on(struct
> generic_pm_domain *genpd)
> return ret;
> }
>
> + dev_info(bc->dev, "%s: 3\n", __func__);
> ret = pm_runtime_get_sync(bc->dev);
> if (ret < 0) {
> pm_runtime_put_noidle(bc->dev);
> @@ -149,11 +152,15 @@ static int imx93_blk_ctrl_power_on(struct
> generic_pm_domain *genpd)
> goto disable_clk;
> }
>
> + dev_info(bc->dev, "%s: 4\n", __func__);
> +
> /* ungate clk */
> regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
> + dev_info(bc->dev, "%s: 5\n", __func__);
>
> /* release reset */
> regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
> + dev_info(bc->dev, "%s: 6\n", __func__);
>
> dev_dbg(bc->dev, "pd_on: name: %s\n", genpd->name);
>
>
> ---8<---
>
> Best regards,
> Alexander
>
> > Regards,
> > Liu Ying
> >
> > > Best regards,
> > > Alexander
> > >
> > > > v3->v4:
> > > > * Improve warning message when ignoring invalid LCDIF OF endpoint ids
> > > > in
> > > >
> > > > patch 5/6. (Alexander)
> > > >
> > > > * Use 'new_{c,p}state' instead of 'new_{crtc,plane}_state' in patch
> > > > 3/6.
> > > >
> > > > (Alexander)
> > > >
> > > > * Simplify lcdif_crtc_reset() by calling
> > > > lcdif_crtc_atomic_destroy_state()
> > > >
> > > > in patch 3/6. (Alexander)
> > > >
> > > > * Add '!crtc->state' check in lcdif_crtc_atomic_duplicate_state() in
> > > > patch
> > > > 3/6. (Alexander)
> > > > * Collect Alexander's R-b tags on patch 1/6, 2/6 and 6/6.
> > > >
> > > > v2->v3:
> > > > * Fix a trivial typo in patch 6/6's commit message.
> > > >
> > > > v1->v2:
> > > > * Add Krzysztof's A-b and Marek's R-b tags on patch 1/6.
> > > > * Split patch 2/2 in v1 into patch 2/6~6/6 in v2. (Marek, Alexander)
> > > > * Drop '!remote ||' from lcdif_attach_bridge(). (Lothar)
> > > > * Add comment on the 'base' member of lcdif_crtc_state structure to
> > > >
> > > > note it should always be the first member. (Lothar)
> > > >
> > > > * Drop unneeded 'bridges' member from lcdif_drm_private structure.
> > > > * Drop a comment about bridge input bus format from
> > > > lcdif_crtc_atomic_check().
> > > >
> > > > Liu Ying (6):
> > > > dt-bindings: lcdif: Add i.MX93 LCDIF support
> > > > drm: lcdif: Drop unnecessary NULL pointer check on lcdif->bridge
> > > > drm: lcdif: Determine bus format and flags in ->atomic_check()
> > > > drm: lcdif: Check consistent bus format and flags across first
> > > > bridges
> > > > drm: lcdif: Add multiple encoders and first bridges support
> > > > drm: lcdif: Add i.MX93 LCDIF compatible string
> > > >
> > > > .../bindings/display/fsl,lcdif.yaml | 7 +-
> > > > drivers/gpu/drm/mxsfb/lcdif_drv.c | 71 ++++++-
> > > > drivers/gpu/drm/mxsfb/lcdif_drv.h | 5 +-
> > > > drivers/gpu/drm/mxsfb/lcdif_kms.c | 198
> > > > ++++++++++++------
> > > > 4 files changed, 206 insertions(+), 75 deletions(-)


--
TQ-Systems GmbH | M?hlstra?e 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht M?nchen, HRB 105018
Gesch?ftsf?hrer: Detlef Schneider, R?diger Stahl, Stefan Schneider
http://www.tq-group.com/



2023-02-20 12:19:50

by Rasmus Villemoes

[permalink] [raw]
Subject: Re: [PATCH v4 0/6] drm: lcdif: Add i.MX93 LCDIF support

On 17/02/2023 09.18, Alexander Stein wrote:
> Hi Liu,
>
> Am Freitag, 17. Februar 2023, 07:54:01 CET schrieb Liu Ying:
>> Hi,
>>
>> This patch set aims to add i.MX93 LCDIF display controller support
>> in the existing LCDIF DRM driver. The LCDIF embedded in i.MX93 SoC
>> is essentially the same to those embedded in i.MX8mp SoC. Through
>> internal bridges, i.MX93 LCDIF may drive a MIPI DSI display or a LVDS
>> display or a parallel display.
>>
>> Patch 1/6 adds device tree binding support for i.MX93 LCDIF in the
>> existing fsl,lcdif.yaml.
>>
>> Patch 2/6 drops lcdif->bridge NULL pointer check as a cleanup patch.
>>
>> Patch 3/6~5/6 prepare for adding i.MX93 LCDIF support step by step.
>>
>> Patch 6/6 adds i.MX93 LCDIF compatible string as the last step of
>> adding i.MX93 LCDIF support.
>
> Thanks for the series. I could test this on my TQMa93xxLA/MBa93xxCA with a
> single LVDS display attached, so no DSI or parallel display. Hence I could not
> test the bus format and flags checks, but they look okay.
> So you can add
> Tested-by: Alexander Stein <[email protected]>
> to the whole series as well.
>
> One thing I noticed is that, sometimes it seems that before probing lcdif my
> system completely freezes. Adding some debug output it seems that's during
> powering up the IMX93_MEDIABLK_PD_LCDIF power domain there is some race
> condition. But adding more more detailed output made the problem go away.
> Did you notice something similar? It might be a red hering though.

Interesting. Sounds similar to what I encountered on several
imx8mp-based boards, both the NXP EVK and our custom design, running a
mainline U-Boot and downstream NXP kernel:

https://lore.kernel.org/u-boot/[email protected]/

I never really found a real solution, but as the hack I ended up
applying in U-Boot does involve some clock settings, and you apparently
now figured out some connection to "overclocking", I do think these
issues are related.

Rasmus


2023-02-20 12:47:46

by Liu Ying

[permalink] [raw]
Subject: Re: [PATCH v4 0/6] drm: lcdif: Add i.MX93 LCDIF support

On Mon, 2023-02-20 at 11:16 +0100, Alexander Stein wrote:
> Hi Liu,

Hi Alexander,

>
> Am Montag, 20. Februar 2023, 09:55:19 CET schrieb Alexander Stein:
> > Hi Liu,
> >
> > Am Freitag, 17. Februar 2023, 09:59:14 CET schrieb Liu Ying:
> > > On Fri, 2023-02-17 at 09:18 +0100, Alexander Stein wrote:
> > > > Hi Liu,
> > >
> > > Hi Alexander,
> > >
> > > > Am Freitag, 17. Februar 2023, 07:54:01 CET schrieb Liu Ying:
> > > > > Hi,
> > > > >
> > > > > This patch set aims to add i.MX93 LCDIF display controller
> > > > > support
> > > > > in the existing LCDIF DRM driver. The LCDIF embedded in
> > > > > i.MX93 SoC
> > > > > is essentially the same to those embedded in i.MX8mp
> > > > > SoC. Through
> > > > > internal bridges, i.MX93 LCDIF may drive a MIPI DSI display
> > > > > or a LVDS
> > > > > display or a parallel display.
> > > > >
> > > > > Patch 1/6 adds device tree binding support for i.MX93 LCDIF
> > > > > in the
> > > > > existing fsl,lcdif.yaml.
> > > > >
> > > > > Patch 2/6 drops lcdif->bridge NULL pointer check as a cleanup
> > > > > patch.
> > > > >
> > > > > Patch 3/6~5/6 prepare for adding i.MX93 LCDIF support step by
> > > > > step.
> > > > >
> > > > > Patch 6/6 adds i.MX93 LCDIF compatible string as the last
> > > > > step of
> > > > > adding i.MX93 LCDIF support.
> > > >
> > > > Thanks for the series. I could test this on my
> > > > TQMa93xxLA/MBa93xxCA with
> > > > a
> > > > single LVDS display attached, so no DSI or parallel display.
> > > > Hence I
> > > > could
> > > > not test the bus format and flags checks, but they look okay.
> > > > So you can add
> > > > Tested-by: Alexander Stein <[email protected]>
> > > > to the whole series as well.
> > >
> > > Thanks for your test.
> > >
> > > > One thing I noticed is that, sometimes it seems that before
> > > > probing
> > > > lcdif
> > > > my system completely freezes. Adding some debug output it seems
> > > > that's
> > > > during powering up the IMX93_MEDIABLK_PD_LCDIF power domain
> > > > there is
> > > > some
> > > > race condition. But adding more more detailed output made the
> > > > problem go
> > > > away. Did you notice something similar? It might be a red
> > > > hering though.
> > >
> > > I don't see system freezing with my i.MX93 11x11 EVK when probing
> > > lcdif. I did try to boot the system several times. All look ok.
> > > This is
> > > a snippet of dmesg when lcdif probes:
> > >
> > > --------------------------8<-------------------------------------
> > > -----
> > > [ 0.753083] Serial: 8250/16550 driver, 4 ports, IRQ sharing
> > > enabled
> > > [ 0.761669] SuperH (H)SCI(F) driver initialized
> > > [ 0.766523] msm_serial: driver initialized
> > > [ 0.780523] printk: console [ttyLP0] enabled0x44380010 (irq =
> > > 16,
> > > base_baud = 1500000) is a FSL_LPUART
> > > [ 0.780523] printk: console [ttyLP0] enabled
> > > [ 0.788928] printk: bootconsole [lpuart32] disabled
> > > [ 0.788928] printk: bootconsole [lpuart32] disabled
> > > [ 0.804632] panel-simple lvds_panel: supply power not found,
> > > using
> > > dummy regulator
> > > [ 0.814741] [drm] Initialized imx-lcdif 1.0.0 20220417 for
> > > 4ae30000.lcd-controller on minor 0
> > > [ 1.195930] Console: switching to colour frame buffer device
> > > 160x50
> > > [ 1.218385] imx-lcdif 4ae30000.lcd-controller: [drm] fb0: imx-
> > > lcdifdrmfb frame buffer device
> > > [ 1.227099] cacheinfo: Unable to detect cache hierarchy for
> > > CPU 0
> > > [ 1.236725] loop: module loaded
> > > --------------------------8<-------------------------------------
> > > -----
> > >
> > > ~300 milliseconds are consumed by the enablement delay required
> > > by the
> > > "boe,ev121wxm-n10-1850" LVDS panel I use.
> >
> > It seems you have the drivers compiled in. I use modules in my case
> > and
> > simple-panel as well. But this is unrelated, because lcdif_probe()
> > is yet to
> > be called. Using the debug diff from below I get the following
> > output:
> >
> > [ 16.111197] imx93-blk-ctrl 4ac10000.system-controller:
> > imx93_blk_ctrl_power_on: 1
> > [ 16.122491] imx93-blk-ctrl 4ac10000.system-controller:
> > imx93_blk_ctrl_power_on: 2
> > [ 16.137766] imx93-blk-ctrl 4ac10000.system-controller:
> > imx93_blk_ctrl_power_on: 3
> > [ 16.154905] imx93-blk-ctrl 4ac10000.system-controller:
> > imx93_blk_ctrl_power_on: 4
> >
> > It seems setting BLK_CLK_EN blocks the whole system, even reading
> > is not
> > possible. I don't have any details on the hardware, but it seems
> > that either
> > some clock or power domain is not enabled. This can also happen if
> > I'm
> > loading the lcdif module manually after boot. But I can't detect
> > any
> > differences in / sys/kernel/debug/clk/clk_summary.
>
> I think I found the cause. It's the maximum clock frequency for
> media_axi and
> media_apb. These clocks were not explicitly configured, most
> probably
> exceeding the maximum frequency allowed.

Thanks for sharing the cause. I use 400MHz media_axi and 133MHz
media_apb.

Regards,
Liu Ying

>
> Best regards,
> Alexander
>
> > ---8<---
> > diff --git a/drivers/soc/imx/imx93-blk-ctrl.c
> > b/drivers/soc/imx/imx93-blk-
> > ctrl.c
> > index 2c600329436cf..50aeb20ce90dc 100644
> > --- a/drivers/soc/imx/imx93-blk-ctrl.c
> > +++ b/drivers/soc/imx/imx93-blk-ctrl.c
> > @@ -129,12 +129,14 @@ static int imx93_blk_ctrl_power_on(struct
> > generic_pm_domain *genpd)
> > struct imx93_blk_ctrl *bc = domain->bc;
> > int ret;
> >
> > + dev_info(bc->dev, "%s: 1\n", __func__);
> > ret = clk_bulk_prepare_enable(bc->num_clks, bc->clks);
> > if (ret) {
> > dev_err(bc->dev, "failed to enable bus clocks\n");
> > return ret;
> > }
> >
> > + dev_info(bc->dev, "%s: 2\n", __func__);
> > ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
> > if (ret) {
> > clk_bulk_disable_unprepare(bc->num_clks, bc->clks);
> > @@ -142,6 +144,7 @@ static int imx93_blk_ctrl_power_on(struct
> > generic_pm_domain *genpd)
> > return ret;
> > }
> >
> > + dev_info(bc->dev, "%s: 3\n", __func__);
> > ret = pm_runtime_get_sync(bc->dev);
> > if (ret < 0) {
> > pm_runtime_put_noidle(bc->dev);
> > @@ -149,11 +152,15 @@ static int imx93_blk_ctrl_power_on(struct
> > generic_pm_domain *genpd)
> > goto disable_clk;
> > }
> >
> > + dev_info(bc->dev, "%s: 4\n", __func__);
> > +
> > /* ungate clk */
> > regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
> > + dev_info(bc->dev, "%s: 5\n", __func__);
> >
> > /* release reset */
> > regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
> > + dev_info(bc->dev, "%s: 6\n", __func__);
> >
> > dev_dbg(bc->dev, "pd_on: name: %s\n", genpd->name);
> >
> >
> > ---8<---
> >
> > Best regards,
> > Alexander
> >
> > > Regards,
> > > Liu Ying
> > >
> > > > Best regards,
> > > > Alexander
> > > >
> > > > > v3->v4:
> > > > > * Improve warning message when ignoring invalid LCDIF OF
> > > > > endpoint ids
> > > > > in
> > > > >
> > > > > patch 5/6. (Alexander)
> > > > >
> > > > > * Use 'new_{c,p}state' instead of 'new_{crtc,plane}_state' in
> > > > > patch
> > > > > 3/6.
> > > > >
> > > > > (Alexander)
> > > > >
> > > > > * Simplify lcdif_crtc_reset() by calling
> > > > > lcdif_crtc_atomic_destroy_state()
> > > > >
> > > > > in patch 3/6. (Alexander)
> > > > >
> > > > > * Add '!crtc->state' check in
> > > > > lcdif_crtc_atomic_duplicate_state() in
> > > > > patch
> > > > > 3/6. (Alexander)
> > > > > * Collect Alexander's R-b tags on patch 1/6, 2/6 and 6/6.
> > > > >
> > > > > v2->v3:
> > > > > * Fix a trivial typo in patch 6/6's commit message.
> > > > >
> > > > > v1->v2:
> > > > > * Add Krzysztof's A-b and Marek's R-b tags on patch 1/6.
> > > > > * Split patch 2/2 in v1 into patch 2/6~6/6 in v2. (Marek,
> > > > > Alexander)
> > > > > * Drop '!remote ||' from lcdif_attach_bridge(). (Lothar)
> > > > > * Add comment on the 'base' member of lcdif_crtc_state
> > > > > structure to
> > > > >
> > > > > note it should always be the first member. (Lothar)
> > > > >
> > > > > * Drop unneeded 'bridges' member from lcdif_drm_private
> > > > > structure.
> > > > > * Drop a comment about bridge input bus format from
> > > > > lcdif_crtc_atomic_check().
> > > > >
> > > > > Liu Ying (6):
> > > > > dt-bindings: lcdif: Add i.MX93 LCDIF support
> > > > > drm: lcdif: Drop unnecessary NULL pointer check on lcdif-
> > > > > >bridge
> > > > > drm: lcdif: Determine bus format and flags in
> > > > > ->atomic_check()
> > > > > drm: lcdif: Check consistent bus format and flags across
> > > > > first
> > > > > bridges
> > > > > drm: lcdif: Add multiple encoders and first bridges support
> > > > > drm: lcdif: Add i.MX93 LCDIF compatible string
> > > > >
> > > > > .../bindings/display/fsl,lcdif.yaml | 7 +-
> > > > > drivers/gpu/drm/mxsfb/lcdif_drv.c | 71 ++++++-
> > > > > drivers/gpu/drm/mxsfb/lcdif_drv.h | 5 +-
> > > > > drivers/gpu/drm/mxsfb/lcdif_kms.c | 198
> > > > > ++++++++++++------
> > > > > 4 files changed, 206 insertions(+), 75 deletions(-)
>
>