* [PATCH 0/8] drm/atmel-hlcdc: make more use of helpers
@ 2025-11-21 15:04 Ludovic Desroches
2025-11-21 15:04 ` [PATCH 1/8] drm/atmel-hlcdc: use managed device resources for the display controller Ludovic Desroches
` (7 more replies)
0 siblings, 8 replies; 10+ messages in thread
From: Ludovic Desroches @ 2025-11-21 15:04 UTC (permalink / raw)
To: Manikandan Muralidharan, Dharma Balasubiramani, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
Cc: dri-devel, linux-arm-kernel, linux-kernel, Ludovic Desroches
Hi,
This set of patches is mostly about using available helpers when
possible to simplify the code and ease the maintenance.
There is a dependency on "drm/panel: simple: restore connector_type
fallback" that I just submitted, otherwise the atmel-hlcdc driver may
fail during the probe.
Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
---
Ludovic Desroches (8):
drm/atmel-hlcdc: use managed device resources for the display controller
drm/atmel-hlcdc: add support for the nomodeset kernel parameter
drm/atmel-hlcdc: use drmm_simple_encoder_alloc()
drm/atmel-hlcdc: use drm_crtc_mask()
drm/atmel-hlcdc: use devm_drm_of_get_bridge()
drm/atmel-hlcdc: use drmm_crtc_alloc_with_planes()
drm/atmel-hlcdc: use drmm_universal_plane_alloc()
drm/atmel-hlcdc: destroy properly the plane state in the reset callback
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 32 ++---------
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 40 +++++++------
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h | 1 +
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 43 ++++----------
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 73 +++++++++++-------------
5 files changed, 73 insertions(+), 116 deletions(-)
---
base-commit: 88cbd8ac379cf5ce68b7efcfd4d1484a6871ee0b
change-id: 20251121-lcd_cleanup_mainline-b6acc75b5a09
Best regards,
--
Ludovic Desroches <ludovic.desroches@microchip.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/8] drm/atmel-hlcdc: use managed device resources for the display controller
2025-11-21 15:04 [PATCH 0/8] drm/atmel-hlcdc: make more use of helpers Ludovic Desroches
@ 2025-11-21 15:04 ` Ludovic Desroches
2025-11-21 15:04 ` [PATCH 2/8] drm/atmel-hlcdc: add support for the nomodeset kernel parameter Ludovic Desroches
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Ludovic Desroches @ 2025-11-21 15:04 UTC (permalink / raw)
To: Manikandan Muralidharan, Dharma Balasubiramani, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
Cc: dri-devel, linux-arm-kernel, linux-kernel, Ludovic Desroches
Take benefit of managed device resources to reduce the risk of memory
leak and to simplify error paths.
Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Reviewed-by: Manikandan Muralidharan <manikandan.m@microchip.com>
---
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 25 ++++++++++++-------------
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h | 1 +
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index dd70894c8f38e7303e06167594ac289cb345b510..8ed029381c555db10d596efc8d52753c47767633 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -751,11 +751,16 @@ static int atmel_hlcdc_dc_modeset_init(struct drm_device *dev)
return 0;
}
+static struct atmel_hlcdc_dc *atmel_hlcdc_dc_of_dev(struct drm_device *dev)
+{
+ return container_of(dev, struct atmel_hlcdc_dc, dev);
+}
+
static int atmel_hlcdc_dc_load(struct drm_device *dev)
{
struct platform_device *pdev = to_platform_device(dev->dev);
const struct of_device_id *match;
- struct atmel_hlcdc_dc *dc;
+ struct atmel_hlcdc_dc *dc = atmel_hlcdc_dc_of_dev(dev);
int ret;
match = of_match_node(atmel_hlcdc_of_match, dev->dev->parent->of_node);
@@ -769,10 +774,6 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev)
return -EINVAL;
}
- dc = devm_kzalloc(dev->dev, sizeof(*dc), GFP_KERNEL);
- if (!dc)
- return -ENOMEM;
-
dc->desc = match->data;
dc->hlcdc = dev_get_drvdata(dev->dev->parent);
dev->dev_private = dc;
@@ -853,16 +854,18 @@ static const struct drm_driver atmel_hlcdc_dc_driver = {
static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev)
{
+ struct atmel_hlcdc_dc *dc;
struct drm_device *ddev;
int ret;
- ddev = drm_dev_alloc(&atmel_hlcdc_dc_driver, &pdev->dev);
- if (IS_ERR(ddev))
- return PTR_ERR(ddev);
+ dc = devm_drm_dev_alloc(&pdev->dev, &atmel_hlcdc_dc_driver, struct atmel_hlcdc_dc, dev);
+ if (IS_ERR(dc))
+ return PTR_ERR(dc);
+ ddev = &dc->dev;
ret = atmel_hlcdc_dc_load(ddev);
if (ret)
- goto err_put;
+ return ret;
ret = drm_dev_register(ddev, 0);
if (ret)
@@ -875,9 +878,6 @@ static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev)
err_unload:
atmel_hlcdc_dc_unload(ddev);
-err_put:
- drm_dev_put(ddev);
-
return ret;
}
@@ -887,7 +887,6 @@ static void atmel_hlcdc_dc_drm_remove(struct platform_device *pdev)
drm_dev_unregister(ddev);
atmel_hlcdc_dc_unload(ddev);
- drm_dev_put(ddev);
}
static void atmel_hlcdc_dc_drm_shutdown(struct platform_device *pdev)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
index 53d47f01db0bd4d906b73f9f2a46f2ef7326d8c6..26b26185cf34ac1678f385982caabd2dbbc22630 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.h
@@ -350,6 +350,7 @@ struct atmel_hlcdc_dc {
struct dma_pool *dscrpool;
struct atmel_hlcdc *hlcdc;
struct drm_crtc *crtc;
+ struct drm_device dev;
struct atmel_hlcdc_layer *layers[ATMEL_HLCDC_MAX_LAYERS];
struct {
u32 imr;
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/8] drm/atmel-hlcdc: add support for the nomodeset kernel parameter
2025-11-21 15:04 [PATCH 0/8] drm/atmel-hlcdc: make more use of helpers Ludovic Desroches
2025-11-21 15:04 ` [PATCH 1/8] drm/atmel-hlcdc: use managed device resources for the display controller Ludovic Desroches
@ 2025-11-21 15:04 ` Ludovic Desroches
2025-11-21 15:04 ` [PATCH 3/8] drm/atmel-hlcdc: use drmm_simple_encoder_alloc() Ludovic Desroches
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Ludovic Desroches @ 2025-11-21 15:04 UTC (permalink / raw)
To: Manikandan Muralidharan, Dharma Balasubiramani, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
Cc: dri-devel, linux-arm-kernel, linux-kernel, Ludovic Desroches
According to Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.
Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Reviewed-by: Dharma Balasubiramani <dharma.b@microchip.com>
Reviewed-by: Manikandan Muralidharan <manikandan.m@microchip.com>
---
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 8ed029381c555db10d596efc8d52753c47767633..8ff582a394794aacf84f9e23fd59f123445926a3 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -858,6 +858,9 @@ static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev)
struct drm_device *ddev;
int ret;
+ if (drm_firmware_drivers_only())
+ return -ENODEV;
+
dc = devm_drm_dev_alloc(&pdev->dev, &atmel_hlcdc_dc_driver, struct atmel_hlcdc_dc, dev);
if (IS_ERR(dc))
return PTR_ERR(dc);
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/8] drm/atmel-hlcdc: use drmm_simple_encoder_alloc()
2025-11-21 15:04 [PATCH 0/8] drm/atmel-hlcdc: make more use of helpers Ludovic Desroches
2025-11-21 15:04 ` [PATCH 1/8] drm/atmel-hlcdc: use managed device resources for the display controller Ludovic Desroches
2025-11-21 15:04 ` [PATCH 2/8] drm/atmel-hlcdc: add support for the nomodeset kernel parameter Ludovic Desroches
@ 2025-11-21 15:04 ` Ludovic Desroches
2025-11-21 15:04 ` [PATCH 4/8] drm/atmel-hlcdc: use drm_crtc_mask() Ludovic Desroches
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Ludovic Desroches @ 2025-11-21 15:04 UTC (permalink / raw)
To: Manikandan Muralidharan, Dharma Balasubiramani, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
Cc: dri-devel, linux-arm-kernel, linux-kernel, Ludovic Desroches
Simplify the code using drmm_simple_encoder_alloc to handle allocation
and initialization at once.
Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Reviewed-by: Manikandan Muralidharan <manikandan.m@microchip.com>
---
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 27 ++++++++----------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
index 0b8a86afb0965ca3085dd5524983a0072199ec0b..1f43e0feeedae54321a17efc266654e72e8b9d8e 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
@@ -73,22 +73,19 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
struct drm_bridge *bridge;
int ret;
- ep = of_graph_get_endpoint_by_regs(dev->dev->of_node, 0, endpoint);
- if (!ep)
- return -ENODEV;
-
ret = drm_of_find_panel_or_bridge(dev->dev->of_node, 0, endpoint,
&panel, &bridge);
- if (ret) {
- of_node_put(ep);
+ if (ret)
return ret;
- }
- output = devm_kzalloc(dev->dev, sizeof(*output), GFP_KERNEL);
- if (!output) {
- of_node_put(ep);
- return -ENOMEM;
- }
+ output = drmm_simple_encoder_alloc(dev, struct atmel_hlcdc_rgb_output,
+ encoder, DRM_MODE_ENCODER_NONE);
+ if (IS_ERR(output))
+ return PTR_ERR(output);
+
+ ep = of_graph_get_endpoint_by_regs(dev->dev->of_node, 0, endpoint);
+ if (!ep)
+ return -ENODEV;
output->bus_fmt = atmel_hlcdc_of_bus_fmt(ep);
of_node_put(ep);
@@ -97,10 +94,6 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
return -EINVAL;
}
- ret = drm_simple_encoder_init(dev, &output->encoder,
- DRM_MODE_ENCODER_NONE);
- if (ret)
- return ret;
output->encoder.possible_crtcs = 0x1;
@@ -120,8 +113,6 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
drm_panel_bridge_remove(bridge);
}
- drm_encoder_cleanup(&output->encoder);
-
return ret;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/8] drm/atmel-hlcdc: use drm_crtc_mask()
2025-11-21 15:04 [PATCH 0/8] drm/atmel-hlcdc: make more use of helpers Ludovic Desroches
` (2 preceding siblings ...)
2025-11-21 15:04 ` [PATCH 3/8] drm/atmel-hlcdc: use drmm_simple_encoder_alloc() Ludovic Desroches
@ 2025-11-21 15:04 ` Ludovic Desroches
2025-11-21 15:04 ` [PATCH 5/8] drm/atmel-hlcdc: use devm_drm_of_get_bridge() Ludovic Desroches
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Ludovic Desroches @ 2025-11-21 15:04 UTC (permalink / raw)
To: Manikandan Muralidharan, Dharma Balasubiramani, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
Cc: dri-devel, linux-arm-kernel, linux-kernel, Ludovic Desroches
Prefer using the drm_crtc_mask() helper instead of a raw value. It
involves reordering components initialization as we need a valid crtc.
Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Reviewed-by: Manikandan Muralidharan <manikandan.m@microchip.com>
---
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c | 12 ++++++------
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 4 +++-
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 8ff582a394794aacf84f9e23fd59f123445926a3..d1f5451ebfeaf81c382b49d0c1a6c3c32e44866b 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -723,12 +723,6 @@ static int atmel_hlcdc_dc_modeset_init(struct drm_device *dev)
drm_mode_config_init(dev);
- ret = atmel_hlcdc_create_outputs(dev);
- if (ret) {
- drm_err(dev, "failed to create HLCDC outputs: %d\n", ret);
- return ret;
- }
-
ret = atmel_hlcdc_create_planes(dev);
if (ret) {
drm_err(dev, "failed to create planes: %d\n", ret);
@@ -741,6 +735,12 @@ static int atmel_hlcdc_dc_modeset_init(struct drm_device *dev)
return ret;
}
+ ret = atmel_hlcdc_create_outputs(dev);
+ if (ret) {
+ drm_err(dev, "failed to create HLCDC outputs: %d\n", ret);
+ return ret;
+ }
+
dev->mode_config.min_width = dc->desc->min_width;
dev->mode_config.min_height = dc->desc->min_height;
dev->mode_config.max_width = dc->desc->max_width;
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
index 1f43e0feeedae54321a17efc266654e72e8b9d8e..e582315f70a119f2b39057ff112bc427117b85f5 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
@@ -71,6 +71,8 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
struct device_node *ep;
struct drm_panel *panel;
struct drm_bridge *bridge;
+ struct atmel_hlcdc_dc *dc = dev->dev_private;
+ struct drm_crtc *crtc = dc->crtc;
int ret;
ret = drm_of_find_panel_or_bridge(dev->dev->of_node, 0, endpoint,
@@ -95,7 +97,6 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
}
- output->encoder.possible_crtcs = 0x1;
if (panel) {
bridge = drm_panel_bridge_add_typed(panel,
@@ -103,6 +104,7 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
if (IS_ERR(bridge))
return PTR_ERR(bridge);
}
+ output->encoder.possible_crtcs = drm_crtc_mask(crtc);
if (bridge) {
ret = drm_bridge_attach(&output->encoder, bridge, NULL, 0);
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/8] drm/atmel-hlcdc: use devm_drm_of_get_bridge()
2025-11-21 15:04 [PATCH 0/8] drm/atmel-hlcdc: make more use of helpers Ludovic Desroches
` (3 preceding siblings ...)
2025-11-21 15:04 ` [PATCH 4/8] drm/atmel-hlcdc: use drm_crtc_mask() Ludovic Desroches
@ 2025-11-21 15:04 ` Ludovic Desroches
2025-11-22 18:40 ` kernel test robot
2025-11-21 15:04 ` [PATCH 6/8] drm/atmel-hlcdc: use drmm_crtc_alloc_with_planes() Ludovic Desroches
` (2 subsequent siblings)
7 siblings, 1 reply; 10+ messages in thread
From: Ludovic Desroches @ 2025-11-21 15:04 UTC (permalink / raw)
To: Manikandan Muralidharan, Dharma Balasubiramani, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
Cc: dri-devel, linux-arm-kernel, linux-kernel, Ludovic Desroches
Get rid of drm_of_find_panel_or_bridge() as it is deprecated and use
devm_drm_of_get_bridge() instead.
Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Reviewed-by: Manikandan Muralidharan <manikandan.m@microchip.com>
---
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
index e582315f70a119f2b39057ff112bc427117b85f5..99bc7790d47ffc7e6df26768559407df0184565b 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
@@ -69,16 +69,14 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
{
struct atmel_hlcdc_rgb_output *output;
struct device_node *ep;
- struct drm_panel *panel;
struct drm_bridge *bridge;
struct atmel_hlcdc_dc *dc = dev->dev_private;
struct drm_crtc *crtc = dc->crtc;
int ret;
- ret = drm_of_find_panel_or_bridge(dev->dev->of_node, 0, endpoint,
- &panel, &bridge);
- if (ret)
- return ret;
+ bridge = devm_drm_of_get_bridge(dev->dev, dev->dev->of_node, 0, endpoint);
+ if (IS_ERR(bridge))
+ return PTR_ERR(bridge);
output = drmm_simple_encoder_alloc(dev, struct atmel_hlcdc_rgb_output,
encoder, DRM_MODE_ENCODER_NONE);
@@ -97,22 +95,12 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
}
-
- if (panel) {
- bridge = drm_panel_bridge_add_typed(panel,
- DRM_MODE_CONNECTOR_Unknown);
- if (IS_ERR(bridge))
- return PTR_ERR(bridge);
- }
output->encoder.possible_crtcs = drm_crtc_mask(crtc);
if (bridge) {
ret = drm_bridge_attach(&output->encoder, bridge, NULL, 0);
if (!ret)
return 0;
-
- if (panel)
- drm_panel_bridge_remove(bridge);
}
return ret;
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/8] drm/atmel-hlcdc: use drmm_crtc_alloc_with_planes()
2025-11-21 15:04 [PATCH 0/8] drm/atmel-hlcdc: make more use of helpers Ludovic Desroches
` (4 preceding siblings ...)
2025-11-21 15:04 ` [PATCH 5/8] drm/atmel-hlcdc: use devm_drm_of_get_bridge() Ludovic Desroches
@ 2025-11-21 15:04 ` Ludovic Desroches
2025-11-21 15:04 ` [PATCH 7/8] drm/atmel-hlcdc: use drmm_universal_plane_alloc() Ludovic Desroches
2025-11-21 15:04 ` [PATCH 8/8] drm/atmel-hlcdc: destroy properly the plane state in the reset callback Ludovic Desroches
7 siblings, 0 replies; 10+ messages in thread
From: Ludovic Desroches @ 2025-11-21 15:04 UTC (permalink / raw)
To: Manikandan Muralidharan, Dharma Balasubiramani, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
Cc: dri-devel, linux-arm-kernel, linux-kernel, Ludovic Desroches
Use drmm_crtc_alloc_with_planes() to simplify the code. As we no longer
have to take care about cleanup, we can get rid of
atmel_hlcdc_crtc_destroy().
Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Reviewed-by: Manikandan Muralidharan <manikandan.m@microchip.com>
---
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 32 +++++---------------------
1 file changed, 6 insertions(+), 26 deletions(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index e0efc7309b1b256520eff29462431476f8589255..b075f291847f9eb91e07b7844382871f38ed5f81 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -509,14 +509,6 @@ static const struct drm_crtc_helper_funcs lcdc_crtc_helper_funcs = {
.atomic_disable = atmel_hlcdc_crtc_atomic_disable,
};
-static void atmel_hlcdc_crtc_destroy(struct drm_crtc *c)
-{
- struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
-
- drm_crtc_cleanup(c);
- kfree(crtc);
-}
-
static void atmel_hlcdc_crtc_finish_page_flip(struct atmel_hlcdc_crtc *crtc)
{
struct drm_device *dev = crtc->base.dev;
@@ -607,7 +599,6 @@ static void atmel_hlcdc_crtc_disable_vblank(struct drm_crtc *c)
static const struct drm_crtc_funcs atmel_hlcdc_crtc_funcs = {
.page_flip = drm_atomic_helper_page_flip,
.set_config = drm_atomic_helper_set_config,
- .destroy = atmel_hlcdc_crtc_destroy,
.reset = atmel_hlcdc_crtc_reset,
.atomic_duplicate_state = atmel_hlcdc_crtc_duplicate_state,
.atomic_destroy_state = atmel_hlcdc_crtc_destroy_state,
@@ -620,15 +611,8 @@ int atmel_hlcdc_crtc_create(struct drm_device *dev)
struct atmel_hlcdc_plane *primary = NULL, *cursor = NULL;
struct atmel_hlcdc_dc *dc = dev->dev_private;
struct atmel_hlcdc_crtc *crtc;
- int ret;
int i;
- crtc = kzalloc(sizeof(*crtc), GFP_KERNEL);
- if (!crtc)
- return -ENOMEM;
-
- crtc->dc = dc;
-
for (i = 0; i < ATMEL_HLCDC_MAX_LAYERS; i++) {
if (!dc->layers[i])
continue;
@@ -646,13 +630,13 @@ int atmel_hlcdc_crtc_create(struct drm_device *dev)
break;
}
}
+ crtc = drmm_crtc_alloc_with_planes(dev, struct atmel_hlcdc_crtc, base,
+ &primary->base, &cursor->base, &atmel_hlcdc_crtc_funcs,
+ NULL);
+ if (IS_ERR(crtc))
+ return PTR_ERR(crtc);
- ret = drm_crtc_init_with_planes(dev, &crtc->base, &primary->base,
- &cursor->base, &atmel_hlcdc_crtc_funcs,
- NULL);
- if (ret < 0)
- goto fail;
-
+ crtc->dc = dc;
crtc->id = drm_crtc_index(&crtc->base);
for (i = 0; i < ATMEL_HLCDC_MAX_LAYERS; i++) {
@@ -674,8 +658,4 @@ int atmel_hlcdc_crtc_create(struct drm_device *dev)
dc->crtc = &crtc->base;
return 0;
-
-fail:
- atmel_hlcdc_crtc_destroy(&crtc->base);
- return ret;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 7/8] drm/atmel-hlcdc: use drmm_universal_plane_alloc()
2025-11-21 15:04 [PATCH 0/8] drm/atmel-hlcdc: make more use of helpers Ludovic Desroches
` (5 preceding siblings ...)
2025-11-21 15:04 ` [PATCH 6/8] drm/atmel-hlcdc: use drmm_crtc_alloc_with_planes() Ludovic Desroches
@ 2025-11-21 15:04 ` Ludovic Desroches
2025-11-21 15:04 ` [PATCH 8/8] drm/atmel-hlcdc: destroy properly the plane state in the reset callback Ludovic Desroches
7 siblings, 0 replies; 10+ messages in thread
From: Ludovic Desroches @ 2025-11-21 15:04 UTC (permalink / raw)
To: Manikandan Muralidharan, Dharma Balasubiramani, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
Cc: dri-devel, linux-arm-kernel, linux-kernel, Ludovic Desroches
Use the drmm_universal_plane_alloc() helper to simplify the code. Using
it, we no longer need to register the destroy callback for
drm_plane_funcs.
Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Reviewed-by: Manikandan Muralidharan <manikandan.m@microchip.com>
---
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index 92132be9823f1e705d266f9547702ea9530bd043..c1f3aaae29fb9f6b947f81e2fb4e7a61e10ac5d9 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -1225,7 +1225,6 @@ static void atmel_hlcdc_plane_atomic_destroy_state(struct drm_plane *p,
static const struct drm_plane_funcs layer_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
- .destroy = drm_plane_cleanup,
.reset = atmel_hlcdc_plane_reset,
.atomic_duplicate_state = atmel_hlcdc_plane_atomic_duplicate_state,
.atomic_destroy_state = atmel_hlcdc_plane_atomic_destroy_state,
@@ -1239,12 +1238,6 @@ static int atmel_hlcdc_plane_create(struct drm_device *dev,
enum drm_plane_type type;
int ret;
- plane = devm_kzalloc(dev->dev, sizeof(*plane), GFP_KERNEL);
- if (!plane)
- return -ENOMEM;
-
- atmel_hlcdc_layer_init(&plane->layer, desc, dc->hlcdc->regmap);
-
if (desc->type == ATMEL_HLCDC_BASE_LAYER)
type = DRM_PLANE_TYPE_PRIMARY;
else if (desc->type == ATMEL_HLCDC_CURSOR_LAYER)
@@ -1252,13 +1245,13 @@ static int atmel_hlcdc_plane_create(struct drm_device *dev,
else
type = DRM_PLANE_TYPE_OVERLAY;
- ret = drm_universal_plane_init(dev, &plane->base, 0,
- &layer_plane_funcs,
- desc->formats->formats,
- desc->formats->nformats,
- NULL, type, NULL);
- if (ret)
- return ret;
+ plane = drmm_universal_plane_alloc(dev, struct atmel_hlcdc_plane, base, 0,
+ &layer_plane_funcs, desc->formats->formats,
+ desc->formats->nformats, NULL, type, NULL);
+ if (IS_ERR(plane))
+ return PTR_ERR(plane);
+
+ atmel_hlcdc_layer_init(&plane->layer, desc, dc->hlcdc->regmap);
drm_plane_helper_add(&plane->base,
&atmel_hlcdc_layer_plane_helper_funcs);
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 8/8] drm/atmel-hlcdc: destroy properly the plane state in the reset callback
2025-11-21 15:04 [PATCH 0/8] drm/atmel-hlcdc: make more use of helpers Ludovic Desroches
` (6 preceding siblings ...)
2025-11-21 15:04 ` [PATCH 7/8] drm/atmel-hlcdc: use drmm_universal_plane_alloc() Ludovic Desroches
@ 2025-11-21 15:04 ` Ludovic Desroches
7 siblings, 0 replies; 10+ messages in thread
From: Ludovic Desroches @ 2025-11-21 15:04 UTC (permalink / raw)
To: Manikandan Muralidharan, Dharma Balasubiramani, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
Cc: dri-devel, linux-arm-kernel, linux-kernel, Ludovic Desroches
If there is a plane state to destroy when doing a plane reset, destroy
it using the atmel_hlcdc_plane_destroy_state() function. So we call
__drm_atomic_helper_plane_destroy_state() and avoid code duplication.
Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
---
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 52 ++++++++++++-------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
index c1f3aaae29fb9f6b947f81e2fb4e7a61e10ac5d9..81dc730362322a4bae9b48dca97b06baa1e331e7 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
@@ -1155,32 +1155,6 @@ static int atmel_hlcdc_plane_alloc_dscrs(struct drm_plane *p,
return -ENOMEM;
}
-static void atmel_hlcdc_plane_reset(struct drm_plane *p)
-{
- struct atmel_hlcdc_plane_state *state;
-
- if (p->state) {
- state = drm_plane_state_to_atmel_hlcdc_plane_state(p->state);
-
- if (state->base.fb)
- drm_framebuffer_put(state->base.fb);
-
- kfree(state);
- p->state = NULL;
- }
-
- state = kzalloc(sizeof(*state), GFP_KERNEL);
- if (state) {
- if (atmel_hlcdc_plane_alloc_dscrs(p, state)) {
- kfree(state);
- drm_err(p->dev,
- "Failed to allocate initial plane state\n");
- return;
- }
- __drm_atomic_helper_plane_reset(p, &state->base);
- }
-}
-
static struct drm_plane_state *
atmel_hlcdc_plane_atomic_duplicate_state(struct drm_plane *p)
{
@@ -1222,6 +1196,32 @@ static void atmel_hlcdc_plane_atomic_destroy_state(struct drm_plane *p,
kfree(state);
}
+static void atmel_hlcdc_plane_reset(struct drm_plane *p)
+{
+ struct atmel_hlcdc_plane_state *state;
+ struct atmel_hlcdc_dc *dc = p->dev->dev_private;
+ struct atmel_hlcdc_plane *plane = drm_plane_to_atmel_hlcdc_plane(p);
+
+ if (p->state) {
+ atmel_hlcdc_plane_atomic_destroy_state(p, p->state);
+ p->state = NULL;
+ }
+
+ state = kzalloc(sizeof(*state), GFP_KERNEL);
+ if (state) {
+ if (atmel_hlcdc_plane_alloc_dscrs(p, state)) {
+ kfree(state);
+ drm_err(p->dev,
+ "Failed to allocate initial plane state\n");
+ return;
+ }
+ __drm_atomic_helper_plane_reset(p, &state->base);
+ }
+
+ if (plane->layer.desc->layout.csc)
+ dc->desc->ops->lcdc_csc_init(plane, plane->layer.desc);
+}
+
static const struct drm_plane_funcs layer_plane_funcs = {
.update_plane = drm_atomic_helper_update_plane,
.disable_plane = drm_atomic_helper_disable_plane,
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 5/8] drm/atmel-hlcdc: use devm_drm_of_get_bridge()
2025-11-21 15:04 ` [PATCH 5/8] drm/atmel-hlcdc: use devm_drm_of_get_bridge() Ludovic Desroches
@ 2025-11-22 18:40 ` kernel test robot
0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2025-11-22 18:40 UTC (permalink / raw)
To: Ludovic Desroches, Manikandan Muralidharan, Dharma Balasubiramani,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
Cc: llvm, oe-kbuild-all, dri-devel, linux-arm-kernel, linux-kernel,
Ludovic Desroches
Hi Ludovic,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 88cbd8ac379cf5ce68b7efcfd4d1484a6871ee0b]
url: https://github.com/intel-lab-lkp/linux/commits/Ludovic-Desroches/drm-atmel-hlcdc-use-managed-device-resources-for-the-display-controller/20251121-231107
base: 88cbd8ac379cf5ce68b7efcfd4d1484a6871ee0b
patch link: https://lore.kernel.org/r/20251121-lcd_cleanup_mainline-v1-5-2587e6fe4d67%40microchip.com
patch subject: [PATCH 5/8] drm/atmel-hlcdc: use devm_drm_of_get_bridge()
config: arm-randconfig-001-20251123 (https://download.01.org/0day-ci/archive/20251123/202511230240.NYBAiUV4-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9e9fe08b16ea2c4d9867fb4974edf2a3776d6ece)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251123/202511230240.NYBAiUV4-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511230240.NYBAiUV4-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c:100:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
100 | if (bridge) {
| ^~~~~~
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c:106:9: note: uninitialized use occurs here
106 | return ret;
| ^~~
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c:100:2: note: remove the 'if' if its condition is always true
100 | if (bridge) {
| ^~~~~~~~~~~
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c:75:9: note: initialize the variable 'ret' to silence this warning
75 | int ret;
| ^
| = 0
1 warning generated.
vim +100 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
b6e075c3cb6e57d Peter Rosin 2018-08-25 67
6bee9b78a7a5ea2 Boris Brezillon 2017-05-18 68 static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
17a8e03e7e97d34 Boris Brezillon 2016-01-06 69 {
b6e075c3cb6e57d Peter Rosin 2018-08-25 70 struct atmel_hlcdc_rgb_output *output;
b6e075c3cb6e57d Peter Rosin 2018-08-25 71 struct device_node *ep;
17a8e03e7e97d34 Boris Brezillon 2016-01-06 72 struct drm_bridge *bridge;
ec29c94011469e7 Ludovic Desroches 2025-11-21 73 struct atmel_hlcdc_dc *dc = dev->dev_private;
ec29c94011469e7 Ludovic Desroches 2025-11-21 74 struct drm_crtc *crtc = dc->crtc;
17a8e03e7e97d34 Boris Brezillon 2016-01-06 75 int ret;
1a396789f65a227 Boris Brezillon 2015-01-06 76
524bfe4ade6dbed Ludovic Desroches 2025-11-21 77 bridge = devm_drm_of_get_bridge(dev->dev, dev->dev->of_node, 0, endpoint);
524bfe4ade6dbed Ludovic Desroches 2025-11-21 78 if (IS_ERR(bridge))
524bfe4ade6dbed Ludovic Desroches 2025-11-21 79 return PTR_ERR(bridge);
6bee9b78a7a5ea2 Boris Brezillon 2017-05-18 80
e38758ed5aece5d Ludovic Desroches 2025-11-21 81 output = drmm_simple_encoder_alloc(dev, struct atmel_hlcdc_rgb_output,
e38758ed5aece5d Ludovic Desroches 2025-11-21 82 encoder, DRM_MODE_ENCODER_NONE);
e38758ed5aece5d Ludovic Desroches 2025-11-21 83 if (IS_ERR(output))
e38758ed5aece5d Ludovic Desroches 2025-11-21 84 return PTR_ERR(output);
e38758ed5aece5d Ludovic Desroches 2025-11-21 85
e38758ed5aece5d Ludovic Desroches 2025-11-21 86 ep = of_graph_get_endpoint_by_regs(dev->dev->of_node, 0, endpoint);
e38758ed5aece5d Ludovic Desroches 2025-11-21 87 if (!ep)
e38758ed5aece5d Ludovic Desroches 2025-11-21 88 return -ENODEV;
b6e075c3cb6e57d Peter Rosin 2018-08-25 89
b6e075c3cb6e57d Peter Rosin 2018-08-25 90 output->bus_fmt = atmel_hlcdc_of_bus_fmt(ep);
b6e075c3cb6e57d Peter Rosin 2018-08-25 91 of_node_put(ep);
b6e075c3cb6e57d Peter Rosin 2018-08-25 92 if (output->bus_fmt < 0) {
3379655524e613e Eslam Khafagy 2025-08-14 93 drm_err(dev, "endpoint %d: invalid bus width\n", endpoint);
17a8e03e7e97d34 Boris Brezillon 2016-01-06 94 return -EINVAL;
b6e075c3cb6e57d Peter Rosin 2018-08-25 95 }
1a396789f65a227 Boris Brezillon 2015-01-06 96
1a396789f65a227 Boris Brezillon 2015-01-06 97
ec29c94011469e7 Ludovic Desroches 2025-11-21 98 output->encoder.possible_crtcs = drm_crtc_mask(crtc);
17a8e03e7e97d34 Boris Brezillon 2016-01-06 99
17a8e03e7e97d34 Boris Brezillon 2016-01-06 @100 if (bridge) {
a25b988ff83f3ca Laurent Pinchart 2020-02-26 101 ret = drm_bridge_attach(&output->encoder, bridge, NULL, 0);
17a8e03e7e97d34 Boris Brezillon 2016-01-06 102 if (!ret)
17a8e03e7e97d34 Boris Brezillon 2016-01-06 103 return 0;
17a8e03e7e97d34 Boris Brezillon 2016-01-06 104 }
1a396789f65a227 Boris Brezillon 2015-01-06 105
1a396789f65a227 Boris Brezillon 2015-01-06 106 return ret;
1a396789f65a227 Boris Brezillon 2015-01-06 107 }
1a396789f65a227 Boris Brezillon 2015-01-06 108
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-11-22 18:41 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-21 15:04 [PATCH 0/8] drm/atmel-hlcdc: make more use of helpers Ludovic Desroches
2025-11-21 15:04 ` [PATCH 1/8] drm/atmel-hlcdc: use managed device resources for the display controller Ludovic Desroches
2025-11-21 15:04 ` [PATCH 2/8] drm/atmel-hlcdc: add support for the nomodeset kernel parameter Ludovic Desroches
2025-11-21 15:04 ` [PATCH 3/8] drm/atmel-hlcdc: use drmm_simple_encoder_alloc() Ludovic Desroches
2025-11-21 15:04 ` [PATCH 4/8] drm/atmel-hlcdc: use drm_crtc_mask() Ludovic Desroches
2025-11-21 15:04 ` [PATCH 5/8] drm/atmel-hlcdc: use devm_drm_of_get_bridge() Ludovic Desroches
2025-11-22 18:40 ` kernel test robot
2025-11-21 15:04 ` [PATCH 6/8] drm/atmel-hlcdc: use drmm_crtc_alloc_with_planes() Ludovic Desroches
2025-11-21 15:04 ` [PATCH 7/8] drm/atmel-hlcdc: use drmm_universal_plane_alloc() Ludovic Desroches
2025-11-21 15:04 ` [PATCH 8/8] drm/atmel-hlcdc: destroy properly the plane state in the reset callback Ludovic Desroches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).