mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 12:31:52 -04:00
drm: rcar-du: Don't leak device_link to CMM
The DU driver creates device_link instances between the DU and CMMs, but never deletes them. Fix it by introducing a rcar_du_cmm structure to group the CMM device and device_link, and deleting the links at cleanup time. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Link: https://patch.msgid.link/20260323164526.2292491-5-laurent.pinchart+renesas@ideasonboard.com Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
This commit is contained in:
committed by
Tomi Valkeinen
parent
a93b8739b5
commit
3bce3fdd1f
@@ -513,13 +513,13 @@ static void rcar_du_cmm_setup(struct drm_crtc *crtc)
|
|||||||
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
|
struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
|
||||||
struct rcar_cmm_config cmm_config = {};
|
struct rcar_cmm_config cmm_config = {};
|
||||||
|
|
||||||
if (!rcrtc->cmm)
|
if (!rcrtc->cmm->dev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (drm_lut)
|
if (drm_lut)
|
||||||
cmm_config.lut.table = (struct drm_color_lut *)drm_lut->data;
|
cmm_config.lut.table = (struct drm_color_lut *)drm_lut->data;
|
||||||
|
|
||||||
rcar_cmm_setup(rcrtc->cmm, &cmm_config);
|
rcar_cmm_setup(rcrtc->cmm->dev, &cmm_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
@@ -667,8 +667,8 @@ static void rcar_du_crtc_stop(struct rcar_du_crtc *rcrtc)
|
|||||||
if (rcar_du_has(rcrtc->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
|
if (rcar_du_has(rcrtc->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
|
||||||
rcar_du_vsp_disable(rcrtc);
|
rcar_du_vsp_disable(rcrtc);
|
||||||
|
|
||||||
if (rcrtc->cmm)
|
if (rcrtc->cmm->dev)
|
||||||
rcar_cmm_disable(rcrtc->cmm);
|
rcar_cmm_disable(rcrtc->cmm->dev);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Select switch sync mode. This stops display operation and configures
|
* Select switch sync mode. This stops display operation and configures
|
||||||
@@ -726,8 +726,8 @@ static void rcar_du_crtc_atomic_enable(struct drm_crtc *crtc,
|
|||||||
struct rcar_du_crtc_state *rstate = to_rcar_crtc_state(crtc->state);
|
struct rcar_du_crtc_state *rstate = to_rcar_crtc_state(crtc->state);
|
||||||
struct rcar_du_device *rcdu = rcrtc->dev;
|
struct rcar_du_device *rcdu = rcrtc->dev;
|
||||||
|
|
||||||
if (rcrtc->cmm)
|
if (rcrtc->cmm->dev)
|
||||||
rcar_cmm_enable(rcrtc->cmm);
|
rcar_cmm_enable(rcrtc->cmm->dev);
|
||||||
rcar_du_crtc_get(rcrtc);
|
rcar_du_crtc_get(rcrtc);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1300,8 +1300,8 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int swindex,
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* CMM might be disabled for this CRTC. */
|
/* CMM might be disabled for this CRTC. */
|
||||||
if (rcdu->cmms[swindex]) {
|
if (rcdu->cmms[swindex].dev) {
|
||||||
rcrtc->cmm = rcdu->cmms[swindex];
|
rcrtc->cmm = &rcdu->cmms[swindex];
|
||||||
rgrp->cmms_mask |= BIT(hwindex % 2);
|
rgrp->cmms_mask |= BIT(hwindex % 2);
|
||||||
|
|
||||||
drm_mode_crtc_set_gamma_size(crtc, CM2_LUT_SIZE);
|
drm_mode_crtc_set_gamma_size(crtc, CM2_LUT_SIZE);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <media/vsp1.h>
|
#include <media/vsp1.h>
|
||||||
|
|
||||||
|
struct rcar_du_cmm;
|
||||||
struct rcar_du_group;
|
struct rcar_du_group;
|
||||||
struct rcar_du_vsp;
|
struct rcar_du_vsp;
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@ struct rcar_du_crtc {
|
|||||||
unsigned int vblank_count;
|
unsigned int vblank_count;
|
||||||
|
|
||||||
struct rcar_du_group *group;
|
struct rcar_du_group *group;
|
||||||
struct device *cmm;
|
struct rcar_du_cmm *cmm;
|
||||||
struct rcar_du_vsp *vsp;
|
struct rcar_du_vsp *vsp;
|
||||||
unsigned int vsp_pipe;
|
unsigned int vsp_pipe;
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
struct clk;
|
struct clk;
|
||||||
struct device;
|
struct device;
|
||||||
|
struct device_link;
|
||||||
struct drm_bridge;
|
struct drm_bridge;
|
||||||
struct drm_property;
|
struct drm_property;
|
||||||
struct rcar_du_device;
|
struct rcar_du_device;
|
||||||
@@ -88,6 +89,11 @@ struct rcar_du_device_info {
|
|||||||
unsigned int lvds_clk_mask;
|
unsigned int lvds_clk_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct rcar_du_cmm {
|
||||||
|
struct device *dev;
|
||||||
|
struct device_link *link;
|
||||||
|
};
|
||||||
|
|
||||||
#define RCAR_DU_MAX_CRTCS 4
|
#define RCAR_DU_MAX_CRTCS 4
|
||||||
#define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
|
#define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
|
||||||
#define RCAR_DU_MAX_VSPS 4
|
#define RCAR_DU_MAX_VSPS 4
|
||||||
@@ -106,7 +112,7 @@ struct rcar_du_device {
|
|||||||
unsigned int num_crtcs;
|
unsigned int num_crtcs;
|
||||||
|
|
||||||
struct rcar_du_group groups[RCAR_DU_MAX_GROUPS];
|
struct rcar_du_group groups[RCAR_DU_MAX_GROUPS];
|
||||||
struct device *cmms[RCAR_DU_MAX_CRTCS];
|
struct rcar_du_cmm cmms[RCAR_DU_MAX_CRTCS];
|
||||||
struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS];
|
struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS];
|
||||||
struct drm_bridge *lvds[RCAR_DU_MAX_LVDS];
|
struct drm_bridge *lvds[RCAR_DU_MAX_LVDS];
|
||||||
struct drm_bridge *dsi[RCAR_DU_MAX_DSI];
|
struct drm_bridge *dsi[RCAR_DU_MAX_DSI];
|
||||||
|
|||||||
@@ -769,23 +769,23 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < cells; ++i) {
|
for (i = 0; i < cells; ++i) {
|
||||||
struct device_node *cmm __free(device_node) = NULL;
|
struct device_node *cmm_node __free(device_node) = NULL;
|
||||||
|
struct rcar_du_cmm *cmm = &rcdu->cmms[i];
|
||||||
struct platform_device *pdev;
|
struct platform_device *pdev;
|
||||||
struct device_link *link;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
cmm = of_parse_phandle(np, "renesas,cmms", i);
|
cmm_node = of_parse_phandle(np, "renesas,cmms", i);
|
||||||
if (!cmm) {
|
if (!cmm_node) {
|
||||||
dev_err(rcdu->dev,
|
dev_err(rcdu->dev,
|
||||||
"Failed to parse 'renesas,cmms' property\n");
|
"Failed to parse 'renesas,cmms' property\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!of_device_is_available(cmm))
|
if (!of_device_is_available(cmm_node))
|
||||||
/* It's fine to have a phandle to a non-enabled CMM. */
|
/* It's fine to have a phandle to a non-enabled CMM. */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pdev = of_find_device_by_node(cmm);
|
pdev = of_find_device_by_node(cmm_node);
|
||||||
if (!pdev) {
|
if (!pdev) {
|
||||||
dev_err(rcdu->dev, "No device found for CMM%u\n", i);
|
dev_err(rcdu->dev, "No device found for CMM%u\n", i);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -801,14 +801,15 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
|
|||||||
return ret == -ENODEV ? 0 : ret;
|
return ret == -ENODEV ? 0 : ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
rcdu->cmms[i] = &pdev->dev;
|
cmm->dev = &pdev->dev;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enforce suspend/resume ordering by making the CMM a provider
|
* Enforce suspend/resume ordering by making the CMM a provider
|
||||||
* of the DU: CMM is suspended after and resumed before the DU.
|
* of the DU: CMM is suspended after and resumed before the DU.
|
||||||
*/
|
*/
|
||||||
link = device_link_add(rcdu->dev, &pdev->dev, DL_FLAG_STATELESS);
|
cmm->link = device_link_add(rcdu->dev, cmm->dev,
|
||||||
if (!link) {
|
DL_FLAG_STATELESS);
|
||||||
|
if (!cmm->link) {
|
||||||
dev_err(rcdu->dev,
|
dev_err(rcdu->dev,
|
||||||
"Failed to create device link to CMM%u\n", i);
|
"Failed to create device link to CMM%u\n", i);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@@ -823,8 +824,14 @@ static void rcar_du_modeset_cleanup(struct drm_device *dev, void *res)
|
|||||||
struct rcar_du_device *rcdu = to_rcar_du_device(dev);
|
struct rcar_du_device *rcdu = to_rcar_du_device(dev);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(rcdu->cmms); ++i)
|
for (i = 0; i < ARRAY_SIZE(rcdu->cmms); ++i) {
|
||||||
put_device(rcdu->cmms[i]);
|
struct rcar_du_cmm *cmm = &rcdu->cmms[i];
|
||||||
|
|
||||||
|
if (cmm->link)
|
||||||
|
device_link_del(cmm->link);
|
||||||
|
|
||||||
|
put_device(cmm->dev);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int rcar_du_modeset_init(struct rcar_du_device *rcdu)
|
int rcar_du_modeset_init(struct rcar_du_device *rcdu)
|
||||||
|
|||||||
Reference in New Issue
Block a user