[Freedreno] [PATCH 2/9] drm/msm: Don't track encoders in msm private struct

Sean Paul sean at poorly.run
Wed Dec 5 16:29:34 UTC 2018


From: Sean Paul <seanpaul at chromium.org>

drm core already tracks this, so we can just lean on that instead of
tracking ourselves.

Signed-off-by: Sean Paul <seanpaul at chromium.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c  | 16 ++++++++--------
 drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c |  5 -----
 drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 12 ++++--------
 drivers/gpu/drm/msm/msm_drv.h            |  3 ---
 4 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 3796a2978a40b..cbebc04e2d6ef 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -457,8 +457,6 @@ static void _dpu_kms_initialize_dsi(struct drm_device *dev,
 		return;
 	}
 
-	priv->encoders[priv->num_encoders++] = encoder;
-
 	for (i = 0; i < ARRAY_SIZE(priv->dsi); i++) {
 		if (!priv->dsi[i]) {
 			DPU_DEBUG("invalid msm_dsi for ctrl %d\n", i);
@@ -498,6 +496,7 @@ static void _dpu_kms_drm_obj_destroy(struct dpu_kms *dpu_kms)
 {
 	struct msm_drm_private *priv;
 	struct drm_crtc *crtc;
+	struct drm_encoder *encoder;
 	int i;
 
 	if (!dpu_kms) {
@@ -523,9 +522,8 @@ static void _dpu_kms_drm_obj_destroy(struct dpu_kms *dpu_kms)
 		priv->connectors[i]->funcs->destroy(priv->connectors[i]);
 	priv->num_connectors = 0;
 
-	for (i = 0; i < priv->num_encoders; i++)
-		priv->encoders[i]->funcs->destroy(priv->encoders[i]);
-	priv->num_encoders = 0;
+	drm_for_each_encoder(encoder, dpu_kms->dev)
+		encoder->funcs->destroy(encoder);
 }
 
 static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
@@ -534,6 +532,7 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 	struct drm_plane *primary_planes[MAX_PLANES], *plane;
 	struct drm_plane *cursor_planes[MAX_PLANES] = { NULL };
 	struct drm_crtc *crtc;
+	struct drm_encoder *encoder;
 
 	struct msm_drm_private *priv;
 	struct dpu_mdss_cfg *catalog;
@@ -556,7 +555,8 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 	 */
 	_dpu_kms_setup_displays(dev, priv, dpu_kms);
 
-	max_crtc_count = min(catalog->mixer_count, priv->num_encoders);
+	max_crtc_count = min(catalog->mixer_count,
+			     (u32)dev->mode_config.num_encoder);
 
 	/* Create the planes, keeping track of one primary/cursor per crtc */
 	for (i = 0; i < catalog->sspp_count; i++) {
@@ -601,8 +601,8 @@ static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
 	}
 
 	/* All CRTCs are compatible with all encoders */
-	for (i = 0; i < priv->num_encoders; i++)
-		priv->encoders[i]->possible_crtcs = (1 << max_crtc_count) - 1;
+	drm_for_each_encoder(encoder, dpu_kms->dev)
+		encoder->possible_crtcs = (1 << max_crtc_count) - 1;
 
 	return 0;
 fail:
diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
index f7f678c55e3ac..527a4ee06819f 100644
--- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
+++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
@@ -266,7 +266,6 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,
 			return PTR_ERR(connector);
 		}
 
-		priv->encoders[priv->num_encoders++] = encoder;
 		priv->connectors[priv->num_connectors++] = connector;
 
 		break;
@@ -288,9 +287,6 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,
 				return ret;
 			}
 		}
-
-		priv->encoders[priv->num_encoders++] = encoder;
-
 		break;
 	case DRM_MODE_ENCODER_DSI:
 		/* only DSI1 supported for now */
@@ -309,7 +305,6 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,
 
 		/* TODO: Add DMA_S later? */
 		encoder->possible_crtcs = 1 << DMA_P;
-		priv->encoders[priv->num_encoders++] = encoder;
 
 		ret = msm_dsi_modeset_init(priv->dsi[dsi_id], dev, encoder);
 		if (ret) {
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
index 4fb70532b0484..7cf54737944e4 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
@@ -332,7 +332,6 @@ static struct drm_encoder *construct_encoder(struct mdp5_kms *mdp5_kms,
 					     struct mdp5_ctl *ctl)
 {
 	struct drm_device *dev = mdp5_kms->dev;
-	struct msm_drm_private *priv = dev->dev_private;
 	struct drm_encoder *encoder;
 
 	encoder = mdp5_encoder_init(dev, intf, ctl);
@@ -341,8 +340,6 @@ static struct drm_encoder *construct_encoder(struct mdp5_kms *mdp5_kms,
 		return encoder;
 	}
 
-	priv->encoders[priv->num_encoders++] = encoder;
-
 	return encoder;
 }
 
@@ -455,6 +452,7 @@ static int modeset_init(struct mdp5_kms *mdp5_kms)
 {
 	struct drm_device *dev = mdp5_kms->dev;
 	struct msm_drm_private *priv = dev->dev_private;
+	struct drm_encoder *encoder;
 	const struct mdp5_cfg_hw *hw_cfg;
 	unsigned int num_crtcs;
 	int i, ret, pi = 0, ci = 0;
@@ -478,7 +476,8 @@ static int modeset_init(struct mdp5_kms *mdp5_kms)
 	 * the MDP5 interfaces) than the number of layer mixers present in HW,
 	 * but let's be safe here anyway
 	 */
-	num_crtcs = min(priv->num_encoders, mdp5_kms->num_hwmixers);
+	num_crtcs = min((unsigned)dev->mode_config.num_encoder,
+			mdp5_kms->num_hwmixers);
 
 	/*
 	 * Construct planes equaling the number of hw pipes, and CRTCs for the
@@ -526,11 +525,8 @@ static int modeset_init(struct mdp5_kms *mdp5_kms)
 	 * Now that we know the number of crtcs we've created, set the possible
 	 * crtcs for the encoders
 	 */
-	for (i = 0; i < priv->num_encoders; i++) {
-		struct drm_encoder *encoder = priv->encoders[i];
-
+	drm_for_each_encoder(encoder, dev)
 		encoder->possible_crtcs = (1 << num_crtcs) - 1;
-	}
 
 	return 0;
 
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index fc677da06e33b..c6eff08e80170 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -197,9 +197,6 @@ struct msm_drm_private {
 	struct msm_drm_thread disp_thread[MAX_CRTCS];
 	struct msm_drm_thread event_thread[MAX_CRTCS];
 
-	unsigned int num_encoders;
-	struct drm_encoder *encoders[MAX_ENCODERS];
-
 	unsigned int num_bridges;
 	struct drm_bridge *bridges[MAX_BRIDGES];
 
-- 
Sean Paul, Software Engineer, Google / Chromium OS



More information about the Freedreno mailing list