Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
* [RESEND PATCH 01/13] drm/msm/dpu: Remove call to drm_mode_set_crtcinfo
@ 2019-06-17 20:03 Sean Paul
  2019-06-17 20:03 ` [RESEND PATCH 02/13] drm/msm/dpu: Fix mmu init/destroy functions Sean Paul
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Sean Paul @ 2019-06-17 20:03 UTC (permalink / raw)
  To: dri-devel, freedreno
  Cc: Sean Paul, Rob Clark, Sean Paul, David Airlie, Daniel Vetter,
	linux-arm-msm

From: Sean Paul <seanpaul@chromium.org>

Now that mode_fixup has been removed, we can just rely on the call
from drm_helper_probe_single_connector_modes(),

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index 82bf16d61a45..94ba4a577ee1 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -622,9 +622,6 @@ static int dpu_encoder_virt_atomic_check(
 		}
 	}
 
-	if (!ret)
-		drm_mode_set_crtcinfo(adj_mode, 0);
-
 	trace_dpu_enc_atomic_check_flags(DRMID(drm_enc), adj_mode->flags,
 			adj_mode->private_flags);
 
-- 
Sean Paul, Software Engineer, Google / Chromium OS


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RESEND PATCH 02/13] drm/msm/dpu: Fix mmu init/destroy functions
  2019-06-17 20:03 [RESEND PATCH 01/13] drm/msm/dpu: Remove call to drm_mode_set_crtcinfo Sean Paul
@ 2019-06-17 20:03 ` Sean Paul
  2019-06-17 20:09 ` [PATCH 03/13] drm/msm/phy/dsi_phy: Set pll to NULL in case initialization fails Sean Paul
  2019-06-17 20:12 ` [PATCH 04/13] drm/msm/dsi_pll_10nm: Release clk hw on destroy and failure Sean Paul
  2 siblings, 0 replies; 13+ messages in thread
From: Sean Paul @ 2019-06-17 20:03 UTC (permalink / raw)
  To: dri-devel, freedreno
  Cc: Sean Paul, Rob Clark, Sean Paul, David Airlie, Daniel Vetter,
	linux-arm-msm

From: Sean Paul <seanpaul@chromium.org>

There's a comment in _dpu_kms_hw_destroy() that reads "safe to call
these more than once during shutdown", referring to
_dpu_kms_mmu_destroy(). Unfortunately that's not the case, mmu_destroy
will fail hard if it's called twice. So fix that function to ensure it
can be called multiple times without burning.

While I'm at it, fix the error paths in _dpu_kms_mmu_init() to properly
clean up the iommu domain and not call _dpu_kms_mmu_destroy() when
things are only partially setup.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 885bf88afa3e..d50afbb37a0a 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -729,12 +729,16 @@ static int _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms)
 {
 	struct msm_mmu *mmu;
 
+	if (!dpu_kms->base.aspace)
+		return 0;
+
 	mmu = dpu_kms->base.aspace->mmu;
 
 	mmu->funcs->detach(mmu, (const char **)iommu_ports,
 			ARRAY_SIZE(iommu_ports));
 	msm_gem_address_space_put(dpu_kms->base.aspace);
 
+	dpu_kms->base.aspace = NULL;
 	return 0;
 }
 
@@ -754,25 +758,20 @@ static int _dpu_kms_mmu_init(struct dpu_kms *dpu_kms)
 	aspace = msm_gem_address_space_create(dpu_kms->dev->dev,
 			domain, "dpu1");
 	if (IS_ERR(aspace)) {
-		ret = PTR_ERR(aspace);
-		goto fail;
+		iommu_domain_free(domain);
+		return PTR_ERR(aspace);
 	}
 
-	dpu_kms->base.aspace = aspace;
-
 	ret = aspace->mmu->funcs->attach(aspace->mmu, iommu_ports,
 			ARRAY_SIZE(iommu_ports));
 	if (ret) {
 		DPU_ERROR("failed to attach iommu %d\n", ret);
 		msm_gem_address_space_put(aspace);
-		goto fail;
+		return ret;
 	}
 
+	dpu_kms->base.aspace = aspace;
 	return 0;
-fail:
-	_dpu_kms_mmu_destroy(dpu_kms);
-
-	return ret;
 }
 
 static struct dss_clk *_dpu_kms_get_clk(struct dpu_kms *dpu_kms,
-- 
Sean Paul, Software Engineer, Google / Chromium OS


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 03/13] drm/msm/phy/dsi_phy: Set pll to NULL in case initialization fails
  2019-06-17 20:03 [RESEND PATCH 01/13] drm/msm/dpu: Remove call to drm_mode_set_crtcinfo Sean Paul
  2019-06-17 20:03 ` [RESEND PATCH 02/13] drm/msm/dpu: Fix mmu init/destroy functions Sean Paul
@ 2019-06-17 20:09 ` Sean Paul
  2019-06-17 20:12 ` [PATCH 04/13] drm/msm/dsi_pll_10nm: Release clk hw on destroy and failure Sean Paul
  2 siblings, 0 replies; 13+ messages in thread
From: Sean Paul @ 2019-06-17 20:09 UTC (permalink / raw)
  To: dri-devel, freedreno
  Cc: Sean Paul, Rob Clark, Sean Paul, David Airlie, Daniel Vetter,
	linux-arm-msm

From: Sean Paul <seanpaul@chromium.org>

We have if (!phy->pll) checks scattered through the driver and if
phy->pll is an error pointer, those checks will pass and bad things will
happen :(

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
index 1760483b247e..6491b0ceab23 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
@@ -616,10 +616,12 @@ static int dsi_phy_driver_probe(struct platform_device *pdev)
 		goto fail;
 
 	phy->pll = msm_dsi_pll_init(pdev, phy->cfg->type, phy->id);
-	if (IS_ERR_OR_NULL(phy->pll))
+	if (IS_ERR_OR_NULL(phy->pll)) {
 		DRM_DEV_INFO(dev,
 			"%s: pll init failed: %ld, need separate pll clk driver\n",
 			__func__, PTR_ERR(phy->pll));
+		phy->pll = NULL;
+	}
 
 	dsi_phy_disable_resource(phy);
 
-- 
Sean Paul, Software Engineer, Google / Chromium OS


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 04/13] drm/msm/dsi_pll_10nm: Release clk hw on destroy and failure
  2019-06-17 20:03 [RESEND PATCH 01/13] drm/msm/dpu: Remove call to drm_mode_set_crtcinfo Sean Paul
  2019-06-17 20:03 ` [RESEND PATCH 02/13] drm/msm/dpu: Fix mmu init/destroy functions Sean Paul
  2019-06-17 20:09 ` [PATCH 03/13] drm/msm/phy/dsi_phy: Set pll to NULL in case initialization fails Sean Paul
@ 2019-06-17 20:12 ` Sean Paul
  2019-06-17 20:12   ` [PATCH 05/13] drm/msm/dsi_pll_10nm: Remove impossible check Sean Paul
                     ` (8 more replies)
  2 siblings, 9 replies; 13+ messages in thread
From: Sean Paul @ 2019-06-17 20:12 UTC (permalink / raw)
  To: dri-devel, freedreno
  Cc: Sean Paul, Rob Clark, Sean Paul, David Airlie, Daniel Vetter,
	linux-arm-msm

From: Sean Paul <seanpaul@chromium.org>

The 10nm pll driver didn't have any failure-path cleanup in register,
and the destroy function didn't unregister any of the hardware. This
patch adds both.

The reason things haven't been blowing up horribly is that msm_drv has a
reference count issue that keeps devices alive, so the destroy function
was never called. That will be fixed in a follow-up patch.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c | 103 +++++++++++++++------
 1 file changed, 73 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c
index aabab6311043..618b49838293 100644
--- a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c
+++ b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c
@@ -104,8 +104,13 @@ struct dsi_pll_10nm {
 	struct dsi_pll_regs reg_setup;
 
 	/* private clocks: */
-	struct clk_hw *hws[NUM_DSI_CLOCKS_MAX];
-	u32 num_hws;
+	struct clk_hw *out_div_clk_hw;
+	struct clk_hw *bit_clk_hw;
+	struct clk_hw *byte_clk_hw;
+	struct clk_hw *by_2_bit_clk_hw;
+	struct clk_hw *post_out_div_clk_hw;
+	struct clk_hw *pclk_mux_hw;
+	struct clk_hw *out_dsiclk_hw;
 
 	/* clock-provider: */
 	struct clk_hw_onecell_data *hw_data;
@@ -617,8 +622,19 @@ static int dsi_pll_10nm_get_provider(struct msm_dsi_pll *pll,
 static void dsi_pll_10nm_destroy(struct msm_dsi_pll *pll)
 {
 	struct dsi_pll_10nm *pll_10nm = to_pll_10nm(pll);
+	struct device *dev = &pll_10nm->pdev->dev;
 
 	DBG("DSI PLL%d", pll_10nm->id);
+	of_clk_del_provider(dev->of_node);
+
+	clk_hw_unregister_divider(pll_10nm->out_dsiclk_hw);
+	clk_hw_unregister_mux(pll_10nm->pclk_mux_hw);
+	clk_hw_unregister_fixed_factor(pll_10nm->post_out_div_clk_hw);
+	clk_hw_unregister_fixed_factor(pll_10nm->by_2_bit_clk_hw);
+	clk_hw_unregister_fixed_factor(pll_10nm->byte_clk_hw);
+	clk_hw_unregister_divider(pll_10nm->bit_clk_hw);
+	clk_hw_unregister_divider(pll_10nm->out_div_clk_hw);
+	clk_hw_unregister(&pll_10nm->base.clk_hw);
 }
 
 /*
@@ -639,10 +655,8 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
 		.ops = &clk_ops_dsi_pll_10nm_vco,
 	};
 	struct device *dev = &pll_10nm->pdev->dev;
-	struct clk_hw **hws = pll_10nm->hws;
 	struct clk_hw_onecell_data *hw_data;
 	struct clk_hw *hw;
-	int num = 0;
 	int ret;
 
 	DBG("DSI%d", pll_10nm->id);
@@ -660,8 +674,6 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
 	if (ret)
 		return ret;
 
-	hws[num++] = &pll_10nm->base.clk_hw;
-
 	snprintf(clk_name, 32, "dsi%d_pll_out_div_clk", pll_10nm->id);
 	snprintf(parent, 32, "dsi%dvco_clk", pll_10nm->id);
 
@@ -670,10 +682,12 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
 				     pll_10nm->mmio +
 				     REG_DSI_10nm_PHY_PLL_PLL_OUTDIV_RATE,
 				     0, 2, CLK_DIVIDER_POWER_OF_TWO, NULL);
-	if (IS_ERR(hw))
-		return PTR_ERR(hw);
+	if (IS_ERR(hw)) {
+		ret = PTR_ERR(hw);
+		goto err_base_clk_hw;
+	}
 
-	hws[num++] = hw;
+	pll_10nm->out_div_clk_hw = hw;
 
 	snprintf(clk_name, 32, "dsi%d_pll_bit_clk", pll_10nm->id);
 	snprintf(parent, 32, "dsi%d_pll_out_div_clk", pll_10nm->id);
@@ -685,10 +699,12 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
 				     REG_DSI_10nm_PHY_CMN_CLK_CFG0,
 				     0, 4, CLK_DIVIDER_ONE_BASED,
 				     &pll_10nm->postdiv_lock);
-	if (IS_ERR(hw))
-		return PTR_ERR(hw);
+	if (IS_ERR(hw)) {
+		ret = PTR_ERR(hw);
+		goto err_out_div_clk_hw;
+	}
 
-	hws[num++] = hw;
+	pll_10nm->bit_clk_hw = hw;
 
 	snprintf(clk_name, 32, "dsi%d_phy_pll_out_byteclk", pll_10nm->id);
 	snprintf(parent, 32, "dsi%d_pll_bit_clk", pll_10nm->id);
@@ -696,10 +712,12 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
 	/* DSI Byte clock = VCO_CLK / OUT_DIV / BIT_DIV / 8 */
 	hw = clk_hw_register_fixed_factor(dev, clk_name, parent,
 					  CLK_SET_RATE_PARENT, 1, 8);
-	if (IS_ERR(hw))
-		return PTR_ERR(hw);
+	if (IS_ERR(hw)) {
+		ret = PTR_ERR(hw);
+		goto err_bit_clk_hw;
+	}
 
-	hws[num++] = hw;
+	pll_10nm->byte_clk_hw = hw;
 	hw_data->hws[DSI_BYTE_PLL_CLK] = hw;
 
 	snprintf(clk_name, 32, "dsi%d_pll_by_2_bit_clk", pll_10nm->id);
@@ -707,20 +725,24 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
 
 	hw = clk_hw_register_fixed_factor(dev, clk_name, parent,
 					  0, 1, 2);
-	if (IS_ERR(hw))
-		return PTR_ERR(hw);
+	if (IS_ERR(hw)) {
+		ret = PTR_ERR(hw);
+		goto err_byte_clk_hw;
+	}
 
-	hws[num++] = hw;
+	pll_10nm->by_2_bit_clk_hw = hw;
 
 	snprintf(clk_name, 32, "dsi%d_pll_post_out_div_clk", pll_10nm->id);
 	snprintf(parent, 32, "dsi%d_pll_out_div_clk", pll_10nm->id);
 
 	hw = clk_hw_register_fixed_factor(dev, clk_name, parent,
 					  0, 1, 4);
-	if (IS_ERR(hw))
-		return PTR_ERR(hw);
+	if (IS_ERR(hw)) {
+		ret = PTR_ERR(hw);
+		goto err_by_2_bit_clk_hw;
+	}
 
-	hws[num++] = hw;
+	pll_10nm->post_out_div_clk_hw = hw;
 
 	snprintf(clk_name, 32, "dsi%d_pclk_mux", pll_10nm->id);
 	snprintf(parent, 32, "dsi%d_pll_bit_clk", pll_10nm->id);
@@ -734,10 +756,12 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
 				 }, 4, 0, pll_10nm->phy_cmn_mmio +
 				 REG_DSI_10nm_PHY_CMN_CLK_CFG1,
 				 0, 2, 0, NULL);
-	if (IS_ERR(hw))
-		return PTR_ERR(hw);
+	if (IS_ERR(hw)) {
+		ret = PTR_ERR(hw);
+		goto err_post_out_div_clk_hw;
+	}
 
-	hws[num++] = hw;
+	pll_10nm->pclk_mux_hw = hw;
 
 	snprintf(clk_name, 32, "dsi%d_phy_pll_out_dsiclk", pll_10nm->id);
 	snprintf(parent, 32, "dsi%d_pclk_mux", pll_10nm->id);
@@ -748,14 +772,14 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
 					REG_DSI_10nm_PHY_CMN_CLK_CFG0,
 				     4, 4, CLK_DIVIDER_ONE_BASED,
 				     &pll_10nm->postdiv_lock);
-	if (IS_ERR(hw))
-		return PTR_ERR(hw);
+	if (IS_ERR(hw)) {
+		ret = PTR_ERR(hw);
+		goto err_pclk_mux_hw;
+	}
 
-	hws[num++] = hw;
+	pll_10nm->out_dsiclk_hw = hw;
 	hw_data->hws[DSI_PIXEL_PLL_CLK] = hw;
 
-	pll_10nm->num_hws = num;
-
 	hw_data->num = NUM_PROVIDED_CLKS;
 	pll_10nm->hw_data = hw_data;
 
@@ -763,10 +787,29 @@ static int pll_10nm_register(struct dsi_pll_10nm *pll_10nm)
 				     pll_10nm->hw_data);
 	if (ret) {
 		DRM_DEV_ERROR(dev, "failed to register clk provider: %d\n", ret);
-		return ret;
+		goto err_dsiclk_hw;
 	}
 
 	return 0;
+
+err_dsiclk_hw:
+	clk_hw_unregister_divider(pll_10nm->out_dsiclk_hw);
+err_pclk_mux_hw:
+	clk_hw_unregister_mux(pll_10nm->pclk_mux_hw);
+err_post_out_div_clk_hw:
+	clk_hw_unregister_fixed_factor(pll_10nm->post_out_div_clk_hw);
+err_by_2_bit_clk_hw:
+	clk_hw_unregister_fixed_factor(pll_10nm->by_2_bit_clk_hw);
+err_byte_clk_hw:
+	clk_hw_unregister_fixed_factor(pll_10nm->byte_clk_hw);
+err_bit_clk_hw:
+	clk_hw_unregister_divider(pll_10nm->bit_clk_hw);
+err_out_div_clk_hw:
+	clk_hw_unregister_divider(pll_10nm->out_div_clk_hw);
+err_base_clk_hw:
+	clk_hw_unregister(&pll_10nm->base.clk_hw);
+
+	return ret;
 }
 
 struct msm_dsi_pll *msm_dsi_pll_10nm_init(struct platform_device *pdev, int id)
-- 
Sean Paul, Software Engineer, Google / Chromium OS


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 05/13] drm/msm/dsi_pll_10nm: Remove impossible check
  2019-06-17 20:12 ` [PATCH 04/13] drm/msm/dsi_pll_10nm: Release clk hw on destroy and failure Sean Paul
@ 2019-06-17 20:12   ` Sean Paul
  2019-06-17 20:12   ` [PATCH 06/13] drm/msm: Depopulate platform on probe failure Sean Paul
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Sean Paul @ 2019-06-17 20:12 UTC (permalink / raw)
  To: dri-devel, freedreno
  Cc: Sean Paul, Rob Clark, Sean Paul, David Airlie, Daniel Vetter,
	linux-arm-msm

From: Sean Paul <seanpaul@chromium.org>

While I'm in here, cut this out, pdev can't be NULL

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c
index 618b49838293..8f6100db90ed 100644
--- a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c
+++ b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_10nm.c
@@ -818,9 +818,6 @@ struct msm_dsi_pll *msm_dsi_pll_10nm_init(struct platform_device *pdev, int id)
 	struct msm_dsi_pll *pll;
 	int ret;
 
-	if (!pdev)
-		return ERR_PTR(-ENODEV);
-
 	pll_10nm = devm_kzalloc(&pdev->dev, sizeof(*pll_10nm), GFP_KERNEL);
 	if (!pll_10nm)
 		return ERR_PTR(-ENOMEM);
-- 
Sean Paul, Software Engineer, Google / Chromium OS


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 06/13] drm/msm: Depopulate platform on probe failure
  2019-06-17 20:12 ` [PATCH 04/13] drm/msm/dsi_pll_10nm: Release clk hw on destroy and failure Sean Paul
  2019-06-17 20:12   ` [PATCH 05/13] drm/msm/dsi_pll_10nm: Remove impossible check Sean Paul
@ 2019-06-17 20:12   ` Sean Paul
  2019-06-17 20:12   ` [PATCH 07/13] drm/msm/dsi: Split mode_flags out of msm_dsi_host_get_panel() Sean Paul
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Sean Paul @ 2019-06-17 20:12 UTC (permalink / raw)
  To: dri-devel, freedreno
  Cc: Sean Paul, Rob Clark, Sean Paul, David Airlie, Daniel Vetter,
	linux-arm-msm

From: Sean Paul <seanpaul@chromium.org>

add_display_components() calls of_platform_populate, and we depopluate
on pdev remove, but not when probe fails. So if we get a probe deferral
in one of the components, we won't depopulate the platform. This causes
the core to keep references to devices which should be destroyed, which
causes issues when those same devices try to re-initialize on the next
probe attempt.

I think this is the reason we had issues with the gmu's device-managed
resources on deferral (worked around in commit 94e3a17f33a5).

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/msm_drv.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 31deb87abfc6..bf99ee138601 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -1317,16 +1317,24 @@ static int msm_pdev_probe(struct platform_device *pdev)
 
 	ret = add_gpu_components(&pdev->dev, &match);
 	if (ret)
-		return ret;
+		goto fail;
 
 	/* on all devices that I am aware of, iommu's which can map
 	 * any address the cpu can see are used:
 	 */
 	ret = dma_set_mask_and_coherent(&pdev->dev, ~0);
 	if (ret)
-		return ret;
+		goto fail;
+
+	ret = component_master_add_with_match(&pdev->dev, &msm_drm_ops, match);
+	if (ret)
+		goto fail;
 
-	return component_master_add_with_match(&pdev->dev, &msm_drm_ops, match);
+	return 0;
+
+fail:
+	of_platform_depopulate(&pdev->dev);
+	return ret;
 }
 
 static int msm_pdev_remove(struct platform_device *pdev)
-- 
Sean Paul, Software Engineer, Google / Chromium OS


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 07/13] drm/msm/dsi: Split mode_flags out of msm_dsi_host_get_panel()
  2019-06-17 20:12 ` [PATCH 04/13] drm/msm/dsi_pll_10nm: Release clk hw on destroy and failure Sean Paul
  2019-06-17 20:12   ` [PATCH 05/13] drm/msm/dsi_pll_10nm: Remove impossible check Sean Paul
  2019-06-17 20:12   ` [PATCH 06/13] drm/msm: Depopulate platform on probe failure Sean Paul
@ 2019-06-17 20:12   ` Sean Paul
  2019-06-17 20:12   ` [PATCH 08/13] drm/msm/dsi: Don't store dsi host mode_flags in msm_dsi Sean Paul
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Sean Paul @ 2019-06-17 20:12 UTC (permalink / raw)
  To: dri-devel, freedreno
  Cc: Sean Paul, Rob Clark, Sean Paul, David Airlie, Daniel Vetter,
	linux-arm-msm

From: Sean Paul <seanpaul@chromium.org>

We use the flags in more places than just get_panel, so split them out
into a separate function.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/dsi/dsi.h         |  4 ++--
 drivers/gpu/drm/msm/dsi/dsi_host.c    | 15 ++++++---------
 drivers/gpu/drm/msm/dsi/dsi_manager.c |  7 ++++---
 3 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi.h b/drivers/gpu/drm/msm/dsi/dsi.h
index 9c6b31c2d79f..8bdc48ca0b67 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.h
+++ b/drivers/gpu/drm/msm/dsi/dsi.h
@@ -169,8 +169,8 @@ int msm_dsi_host_power_on(struct mipi_dsi_host *host,
 int msm_dsi_host_power_off(struct mipi_dsi_host *host);
 int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
 				  const struct drm_display_mode *mode);
-struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host,
-					unsigned long *panel_flags);
+struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host);
+unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host);
 struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host);
 int msm_dsi_host_register(struct mipi_dsi_host *host, bool check_defer);
 void msm_dsi_host_unregister(struct mipi_dsi_host *host);
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 610183db1daf..daa08a033b59 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -2442,17 +2442,14 @@ int msm_dsi_host_set_display_mode(struct mipi_dsi_host *host,
 	return 0;
 }
 
-struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host,
-				unsigned long *panel_flags)
+struct drm_panel *msm_dsi_host_get_panel(struct mipi_dsi_host *host)
 {
-	struct msm_dsi_host *msm_host = to_msm_dsi_host(host);
-	struct drm_panel *panel;
-
-	panel = of_drm_find_panel(msm_host->device_node);
-	if (panel_flags)
-			*panel_flags = msm_host->mode_flags;
+	return of_drm_find_panel(to_msm_dsi_host(host)->device_node);
+}
 
-	return panel;
+unsigned long msm_dsi_host_get_mode_flags(struct mipi_dsi_host *host)
+{
+	return to_msm_dsi_host(host)->mode_flags;
 }
 
 struct drm_bridge *msm_dsi_host_get_bridge(struct mipi_dsi_host *host)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
index 979a8e929341..56b8091b75e7 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
@@ -244,8 +244,9 @@ static enum drm_connector_status dsi_mgr_connector_detect(
 
 	DBG("id=%d", id);
 	if (!msm_dsi->panel) {
-		msm_dsi->panel = msm_dsi_host_get_panel(msm_dsi->host,
-						&msm_dsi->device_flags);
+		msm_dsi->panel = msm_dsi_host_get_panel(msm_dsi->host);
+		msm_dsi->device_flags = msm_dsi_host_get_mode_flags(
+						msm_dsi->host);
 
 		/* There is only 1 panel in the global panel list
 		 * for dual DSI mode. Therefore slave dsi should get
@@ -255,7 +256,7 @@ static enum drm_connector_status dsi_mgr_connector_detect(
 		if (!msm_dsi->panel && IS_DUAL_DSI() &&
 			!IS_MASTER_DSI_LINK(id) && other_dsi)
 			msm_dsi->panel = msm_dsi_host_get_panel(
-					other_dsi->host, NULL);
+						other_dsi->host);
 
 
 		if (msm_dsi->panel && kms->funcs->set_encoder_mode) {
-- 
Sean Paul, Software Engineer, Google / Chromium OS


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 08/13] drm/msm/dsi: Don't store dsi host mode_flags in msm_dsi
  2019-06-17 20:12 ` [PATCH 04/13] drm/msm/dsi_pll_10nm: Release clk hw on destroy and failure Sean Paul
                     ` (2 preceding siblings ...)
  2019-06-17 20:12   ` [PATCH 07/13] drm/msm/dsi: Split mode_flags out of msm_dsi_host_get_panel() Sean Paul
@ 2019-06-17 20:12   ` Sean Paul
  2019-06-17 20:12   ` [PATCH 09/13] drm/msm/dsi: Pull out panel init code into function Sean Paul
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Sean Paul @ 2019-06-17 20:12 UTC (permalink / raw)
  To: dri-devel, freedreno
  Cc: Sean Paul, Rob Clark, Sean Paul, David Airlie, Daniel Vetter,
	linux-arm-msm

From: Sean Paul <seanpaul@chromium.org>

It's a bit dangerous to store the flags in msm_dsi since there's no way to
tell when they're populated. Fortunately the only place that uses them
is the same place that fills them. So just use a local variable and
delete the struct member.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/dsi/dsi.h         |  1 -
 drivers/gpu/drm/msm/dsi/dsi_manager.c | 17 +++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi.h b/drivers/gpu/drm/msm/dsi/dsi.h
index 8bdc48ca0b67..e0bbe8128aef 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.h
+++ b/drivers/gpu/drm/msm/dsi/dsi.h
@@ -79,7 +79,6 @@ struct msm_dsi {
 	 */
 	struct drm_panel *panel;
 	struct drm_bridge *external_bridge;
-	unsigned long device_flags;
 
 	struct device *phy_dev;
 	bool phy_enabled;
diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
index 56b8091b75e7..735fff79ae67 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
@@ -233,6 +233,12 @@ static int dsi_mgr_bridge_get_id(struct drm_bridge *bridge)
 	return dsi_bridge->id;
 }
 
+static bool dsi_mgr_is_cmd_mode(struct msm_dsi *msm_dsi)
+{
+	unsigned long host_flags = msm_dsi_host_get_mode_flags(msm_dsi->host);
+	return !(host_flags & MIPI_DSI_MODE_VIDEO);
+}
+
 static enum drm_connector_status dsi_mgr_connector_detect(
 		struct drm_connector *connector, bool force)
 {
@@ -241,17 +247,15 @@ static enum drm_connector_status dsi_mgr_connector_detect(
 	struct msm_dsi *other_dsi = dsi_mgr_get_other_dsi(id);
 	struct msm_drm_private *priv = connector->dev->dev_private;
 	struct msm_kms *kms = priv->kms;
+	bool cmd_mode;
 
 	DBG("id=%d", id);
 	if (!msm_dsi->panel) {
 		msm_dsi->panel = msm_dsi_host_get_panel(msm_dsi->host);
-		msm_dsi->device_flags = msm_dsi_host_get_mode_flags(
-						msm_dsi->host);
 
 		/* There is only 1 panel in the global panel list
 		 * for dual DSI mode. Therefore slave dsi should get
-		 * the drm_panel instance from master dsi, and
-		 * keep using the panel flags got from the current DSI link.
+		 * the drm_panel instance from master dsi.
 		 */
 		if (!msm_dsi->panel && IS_DUAL_DSI() &&
 			!IS_MASTER_DSI_LINK(id) && other_dsi)
@@ -259,9 +263,8 @@ static enum drm_connector_status dsi_mgr_connector_detect(
 						other_dsi->host);
 
 
+		cmd_mode = dsi_mgr_is_cmd_mode(msm_dsi);
 		if (msm_dsi->panel && kms->funcs->set_encoder_mode) {
-			bool cmd_mode = !(msm_dsi->device_flags &
-					  MIPI_DSI_MODE_VIDEO);
 			struct drm_encoder *encoder =
 					msm_dsi_get_encoder(msm_dsi);
 
@@ -277,8 +280,6 @@ static enum drm_connector_status dsi_mgr_connector_detect(
 		 */
 		if (msm_dsi->panel && IS_DUAL_DSI() &&
 			other_dsi && other_dsi->panel) {
-			bool cmd_mode = !(msm_dsi->device_flags &
-						MIPI_DSI_MODE_VIDEO);
 			struct drm_encoder *encoder = msm_dsi_get_encoder(
 					dsi_mgr_get_dsi(DSI_ENCODER_MASTER));
 			struct drm_encoder *slave_enc = msm_dsi_get_encoder(
-- 
Sean Paul, Software Engineer, Google / Chromium OS


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 09/13] drm/msm/dsi: Pull out panel init code into function
  2019-06-17 20:12 ` [PATCH 04/13] drm/msm/dsi_pll_10nm: Release clk hw on destroy and failure Sean Paul
                     ` (3 preceding siblings ...)
  2019-06-17 20:12   ` [PATCH 08/13] drm/msm/dsi: Don't store dsi host mode_flags in msm_dsi Sean Paul
@ 2019-06-17 20:12   ` Sean Paul
  2019-06-17 20:12   ` [PATCH 10/13] drm/msm/dsi: Simplify the logic in msm_dsi_manager_panel_init() Sean Paul
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Sean Paul @ 2019-06-17 20:12 UTC (permalink / raw)
  To: dri-devel, freedreno
  Cc: Sean Paul, Rob Clark, Sean Paul, David Airlie, Daniel Vetter,
	linux-arm-msm

From: Sean Paul <seanpaul@chromium.org>

Pull all of the panel init code out of detect() and put it in its own
function. This will be useful in future patches where it's moved from
detect().

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/dsi/dsi_manager.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
index 735fff79ae67..855139195769 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
@@ -239,17 +239,14 @@ static bool dsi_mgr_is_cmd_mode(struct msm_dsi *msm_dsi)
 	return !(host_flags & MIPI_DSI_MODE_VIDEO);
 }
 
-static enum drm_connector_status dsi_mgr_connector_detect(
-		struct drm_connector *connector, bool force)
+static void msm_dsi_manager_panel_init(struct drm_connector *connector, u8 id)
 {
-	int id = dsi_mgr_connector_get_id(connector);
 	struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
 	struct msm_dsi *other_dsi = dsi_mgr_get_other_dsi(id);
 	struct msm_drm_private *priv = connector->dev->dev_private;
 	struct msm_kms *kms = priv->kms;
 	bool cmd_mode;
 
-	DBG("id=%d", id);
 	if (!msm_dsi->panel) {
 		msm_dsi->panel = msm_dsi_host_get_panel(msm_dsi->host);
 
@@ -292,6 +289,17 @@ static enum drm_connector_status dsi_mgr_connector_detect(
 				pr_err("mdp does not support dual DSI\n");
 		}
 	}
+}
+
+static enum drm_connector_status dsi_mgr_connector_detect(
+		struct drm_connector *connector, bool force)
+{
+	int id = dsi_mgr_connector_get_id(connector);
+	struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
+
+	DBG("id=%d", id);
+	if (!msm_dsi->panel)
+		msm_dsi_manager_panel_init(connector, id);
 
 	return msm_dsi->panel ? connector_status_connected :
 		connector_status_disconnected;
-- 
Sean Paul, Software Engineer, Google / Chromium OS


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 10/13] drm/msm/dsi: Simplify the logic in msm_dsi_manager_panel_init()
  2019-06-17 20:12 ` [PATCH 04/13] drm/msm/dsi_pll_10nm: Release clk hw on destroy and failure Sean Paul
                     ` (4 preceding siblings ...)
  2019-06-17 20:12   ` [PATCH 09/13] drm/msm/dsi: Pull out panel init code into function Sean Paul
@ 2019-06-17 20:12   ` Sean Paul
  2019-06-17 20:12   ` [PATCH 11/13] drm/msm/dsi: Use the new setup_encoder function in attach_dsi_device Sean Paul
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Sean Paul @ 2019-06-17 20:12 UTC (permalink / raw)
  To: dri-devel, freedreno
  Cc: Sean Paul, Rob Clark, Sean Paul, David Airlie, Daniel Vetter,
	linux-arm-msm

From: Sean Paul <seanpaul@chromium.org>

This patch moves things around a bit to be a little more readable and
pulls out the set_encoder_mode() call into its own function for later
use.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/dsi/dsi_manager.c | 100 +++++++++++++++-----------
 1 file changed, 59 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
index 855139195769..1ee3197a9bdd 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
@@ -239,56 +239,71 @@ static bool dsi_mgr_is_cmd_mode(struct msm_dsi *msm_dsi)
 	return !(host_flags & MIPI_DSI_MODE_VIDEO);
 }
 
-static void msm_dsi_manager_panel_init(struct drm_connector *connector, u8 id)
+static void msm_dsi_manager_setup_encoder(int id)
 {
 	struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
-	struct msm_dsi *other_dsi = dsi_mgr_get_other_dsi(id);
-	struct msm_drm_private *priv = connector->dev->dev_private;
+	struct msm_drm_private *priv = msm_dsi->dev->dev_private;
 	struct msm_kms *kms = priv->kms;
-	bool cmd_mode;
+	struct drm_encoder *encoder = msm_dsi_get_encoder(msm_dsi);
 
-	if (!msm_dsi->panel) {
-		msm_dsi->panel = msm_dsi_host_get_panel(msm_dsi->host);
+	if (encoder && kms->funcs->set_encoder_mode)
+		kms->funcs->set_encoder_mode(kms, encoder,
+					     dsi_mgr_is_cmd_mode(msm_dsi));
+}
 
-		/* There is only 1 panel in the global panel list
-		 * for dual DSI mode. Therefore slave dsi should get
-		 * the drm_panel instance from master dsi.
-		 */
-		if (!msm_dsi->panel && IS_DUAL_DSI() &&
-			!IS_MASTER_DSI_LINK(id) && other_dsi)
-			msm_dsi->panel = msm_dsi_host_get_panel(
-						other_dsi->host);
+static int msm_dsi_manager_panel_init(struct drm_connector *conn, u8 id)
+{
+	struct msm_drm_private *priv = conn->dev->dev_private;
+	struct msm_kms *kms = priv->kms;
+	struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
+	struct msm_dsi *other_dsi = dsi_mgr_get_other_dsi(id);
+	struct msm_dsi *master_dsi, *slave_dsi;
+	struct drm_panel *panel;
 
+	if (IS_DUAL_DSI() && !IS_MASTER_DSI_LINK(id)) {
+		master_dsi = other_dsi;
+		slave_dsi = msm_dsi;
+	} else {
+		master_dsi = msm_dsi;
+		slave_dsi = other_dsi;
+	}
 
-		cmd_mode = dsi_mgr_is_cmd_mode(msm_dsi);
-		if (msm_dsi->panel && kms->funcs->set_encoder_mode) {
-			struct drm_encoder *encoder =
-					msm_dsi_get_encoder(msm_dsi);
+	/*
+	 * There is only 1 panel in the global panel list for dual DSI mode.
+	 * Therefore slave dsi should get the drm_panel instance from master
+	 * dsi.
+	 */
+	panel = msm_dsi_host_get_panel(master_dsi->host);
+	if (IS_ERR(panel)) {
+		DRM_ERROR("Could not find panel for %u (%ld)\n", msm_dsi->id,
+			  PTR_ERR(panel));
+		return PTR_ERR(panel);
+	}
 
-			kms->funcs->set_encoder_mode(kms, encoder, cmd_mode);
-		}
+	if (!panel)
+		return 0;
 
-		if (msm_dsi->panel && IS_DUAL_DSI())
-			drm_object_attach_property(&connector->base,
-				connector->dev->mode_config.tile_property, 0);
+	msm_dsi_manager_setup_encoder(id);
 
-		/* Set split display info to kms once dual DSI panel is
-		 * connected to both hosts.
-		 */
-		if (msm_dsi->panel && IS_DUAL_DSI() &&
-			other_dsi && other_dsi->panel) {
-			struct drm_encoder *encoder = msm_dsi_get_encoder(
-					dsi_mgr_get_dsi(DSI_ENCODER_MASTER));
-			struct drm_encoder *slave_enc = msm_dsi_get_encoder(
-					dsi_mgr_get_dsi(DSI_ENCODER_SLAVE));
-
-			if (kms->funcs->set_split_display)
-				kms->funcs->set_split_display(kms, encoder,
-							slave_enc, cmd_mode);
-			else
-				pr_err("mdp does not support dual DSI\n");
-		}
+	if (!IS_DUAL_DSI())
+		goto out;
+
+	drm_object_attach_property(&conn->base,
+				   conn->dev->mode_config.tile_property, 0);
+
+	/*
+	 * Set split display info to kms once dual DSI panel is connected to
+	 * both hosts.
+	 */
+	if (other_dsi && other_dsi->panel && kms->funcs->set_split_display) {
+		kms->funcs->set_split_display(kms, master_dsi->encoder,
+					      slave_dsi->encoder,
+					      dsi_mgr_is_cmd_mode(msm_dsi));
 	}
+
+out:
+	msm_dsi->panel = panel;
+	return 0;
 }
 
 static enum drm_connector_status dsi_mgr_connector_detect(
@@ -298,8 +313,11 @@ static enum drm_connector_status dsi_mgr_connector_detect(
 	struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
 
 	DBG("id=%d", id);
-	if (!msm_dsi->panel)
-		msm_dsi_manager_panel_init(connector, id);
+	if (!msm_dsi->panel) {
+		int ret = msm_dsi_manager_panel_init(connector, id);
+		if (ret)
+			return connector_status_disconnected;
+	}
 
 	return msm_dsi->panel ? connector_status_connected :
 		connector_status_disconnected;
-- 
Sean Paul, Software Engineer, Google / Chromium OS


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 11/13] drm/msm/dsi: Use the new setup_encoder function in attach_dsi_device
  2019-06-17 20:12 ` [PATCH 04/13] drm/msm/dsi_pll_10nm: Release clk hw on destroy and failure Sean Paul
                     ` (5 preceding siblings ...)
  2019-06-17 20:12   ` [PATCH 10/13] drm/msm/dsi: Simplify the logic in msm_dsi_manager_panel_init() Sean Paul
@ 2019-06-17 20:12   ` Sean Paul
  2019-06-17 20:12   ` [PATCH 12/13] drm/msm/dsi: Move dsi panel init into modeset init path Sean Paul
  2019-06-17 20:12   ` [PATCH 13/13] drm/msm/dsi: Move setup_encoder to modeset_init Sean Paul
  8 siblings, 0 replies; 13+ messages in thread
From: Sean Paul @ 2019-06-17 20:12 UTC (permalink / raw)
  To: dri-devel, freedreno
  Cc: Sean Paul, Rob Clark, Sean Paul, David Airlie, Daniel Vetter,
	linux-arm-msm

From: Sean Paul <seanpaul@chromium.org>

Now that we have a function to call set_encoder_mode() for us, use it.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/dsi/dsi.h         |  2 +-
 drivers/gpu/drm/msm/dsi/dsi_host.c    |  2 +-
 drivers/gpu/drm/msm/dsi/dsi_manager.c | 15 ++-------------
 3 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi.h b/drivers/gpu/drm/msm/dsi/dsi.h
index e0bbe8128aef..f8a611725f2e 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.h
+++ b/drivers/gpu/drm/msm/dsi/dsi.h
@@ -96,7 +96,7 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id);
 struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id);
 int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
 bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
-void msm_dsi_manager_attach_dsi_device(int id, u32 device_flags);
+void msm_dsi_manager_attach_dsi_device(int id);
 int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
 void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
 bool msm_dsi_manager_validate_current_config(u8 id);
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index daa08a033b59..effea0db5626 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1598,7 +1598,7 @@ static int dsi_host_attach(struct mipi_dsi_host *host,
 	msm_host->format = dsi->format;
 	msm_host->mode_flags = dsi->mode_flags;
 
-	msm_dsi_manager_attach_dsi_device(msm_host->id, dsi->mode_flags);
+	msm_dsi_manager_attach_dsi_device(msm_host->id);
 
 	/* Some gpios defined in panel DT need to be controlled by host */
 	ret = dsi_host_init_panel_gpios(msm_host, &dsi->dev);
diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
index 1ee3197a9bdd..602953b90cab 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
@@ -787,14 +787,10 @@ bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len)
 	return true;
 }
 
-void msm_dsi_manager_attach_dsi_device(int id, u32 device_flags)
+void msm_dsi_manager_attach_dsi_device(int id)
 {
 	struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
 	struct drm_device *dev = msm_dsi->dev;
-	struct msm_drm_private *priv;
-	struct msm_kms *kms;
-	struct drm_encoder *encoder;
-	bool cmd_mode;
 
 	/*
 	 * drm_device pointer is assigned to msm_dsi only in the modeset_init
@@ -806,14 +802,7 @@ void msm_dsi_manager_attach_dsi_device(int id, u32 device_flags)
 	if (!dev)
 		return;
 
-	priv = dev->dev_private;
-	kms = priv->kms;
-	encoder = msm_dsi_get_encoder(msm_dsi);
-	cmd_mode = !(device_flags &
-				 MIPI_DSI_MODE_VIDEO);
-
-	if (encoder && kms->funcs->set_encoder_mode)
-		kms->funcs->set_encoder_mode(kms, encoder, cmd_mode);
+	msm_dsi_manager_setup_encoder(id);
 }
 
 int msm_dsi_manager_register(struct msm_dsi *msm_dsi)
-- 
Sean Paul, Software Engineer, Google / Chromium OS


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 12/13] drm/msm/dsi: Move dsi panel init into modeset init path
  2019-06-17 20:12 ` [PATCH 04/13] drm/msm/dsi_pll_10nm: Release clk hw on destroy and failure Sean Paul
                     ` (6 preceding siblings ...)
  2019-06-17 20:12   ` [PATCH 11/13] drm/msm/dsi: Use the new setup_encoder function in attach_dsi_device Sean Paul
@ 2019-06-17 20:12   ` Sean Paul
  2019-06-17 20:12   ` [PATCH 13/13] drm/msm/dsi: Move setup_encoder to modeset_init Sean Paul
  8 siblings, 0 replies; 13+ messages in thread
From: Sean Paul @ 2019-06-17 20:12 UTC (permalink / raw)
  To: dri-devel, freedreno
  Cc: Sean Paul, Rob Clark, Sean Paul, David Airlie, Daniel Vetter,
	linux-arm-msm

From: Sean Paul <seanpaul@chromium.org>

Since deferred probe from the modeset init path now works, we can move
the panel initialization from detect() into connector init. This
avoids doing work in detect() and hopefully will result in a more
deterministic boot sequence between devices with a dsi panel, and those
with an external bridge.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/dsi/dsi_manager.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
index 602953b90cab..5db43c7ffafc 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
@@ -312,13 +312,6 @@ static enum drm_connector_status dsi_mgr_connector_detect(
 	int id = dsi_mgr_connector_get_id(connector);
 	struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
 
-	DBG("id=%d", id);
-	if (!msm_dsi->panel) {
-		int ret = msm_dsi_manager_panel_init(connector, id);
-		if (ret)
-			return connector_status_disconnected;
-	}
-
 	return msm_dsi->panel ? connector_status_connected :
 		connector_status_disconnected;
 }
@@ -631,7 +624,17 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id)
 
 	drm_connector_attach_encoder(connector, msm_dsi->encoder);
 
+	ret = msm_dsi_manager_panel_init(connector, id);
+	if (ret) {
+		DRM_DEV_ERROR(msm_dsi->dev->dev, "init panel failed %d\n", ret);
+		goto fail;
+	}
+
 	return connector;
+
+fail:
+	connector->funcs->destroy(msm_dsi->connector);
+	return ERR_PTR(ret);
 }
 
 bool msm_dsi_manager_validate_current_config(u8 id)
-- 
Sean Paul, Software Engineer, Google / Chromium OS


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 13/13] drm/msm/dsi: Move setup_encoder to modeset_init
  2019-06-17 20:12 ` [PATCH 04/13] drm/msm/dsi_pll_10nm: Release clk hw on destroy and failure Sean Paul
                     ` (7 preceding siblings ...)
  2019-06-17 20:12   ` [PATCH 12/13] drm/msm/dsi: Move dsi panel init into modeset init path Sean Paul
@ 2019-06-17 20:12   ` Sean Paul
  8 siblings, 0 replies; 13+ messages in thread
From: Sean Paul @ 2019-06-17 20:12 UTC (permalink / raw)
  To: dri-devel, freedreno
  Cc: Sean Paul, Rob Clark, Sean Paul, David Airlie, Daniel Vetter,
	linux-arm-msm

From: Sean Paul <seanpaul@chromium.org>

Now that the panel probe/setup is in the modeset path, we can call
dsi_manager_setup_encoder() in a common place for both internal and
external bridge setups.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/dsi/dsi.c         |  2 ++
 drivers/gpu/drm/msm/dsi/dsi.h         |  2 +-
 drivers/gpu/drm/msm/dsi/dsi_host.c    |  2 --
 drivers/gpu/drm/msm/dsi/dsi_manager.c | 27 ++-------------------------
 4 files changed, 5 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
index 7b2a1e6a8810..d45b0a40aaf3 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.c
+++ b/drivers/gpu/drm/msm/dsi/dsi.c
@@ -250,6 +250,8 @@ int msm_dsi_modeset_init(struct msm_dsi *msm_dsi, struct drm_device *dev,
 		goto fail;
 	}
 
+	msm_dsi_manager_setup_encoder(msm_dsi->id);
+
 	priv->bridges[priv->num_bridges++]       = msm_dsi->bridge;
 	priv->connectors[priv->num_connectors++] = msm_dsi->connector;
 
diff --git a/drivers/gpu/drm/msm/dsi/dsi.h b/drivers/gpu/drm/msm/dsi/dsi.h
index f8a611725f2e..53bb124e8259 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.h
+++ b/drivers/gpu/drm/msm/dsi/dsi.h
@@ -96,7 +96,7 @@ struct drm_connector *msm_dsi_manager_connector_init(u8 id);
 struct drm_connector *msm_dsi_manager_ext_bridge_init(u8 id);
 int msm_dsi_manager_cmd_xfer(int id, const struct mipi_dsi_msg *msg);
 bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len);
-void msm_dsi_manager_attach_dsi_device(int id);
+void msm_dsi_manager_setup_encoder(int id);
 int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
 void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
 bool msm_dsi_manager_validate_current_config(u8 id);
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index effea0db5626..04db0c806aa4 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1598,8 +1598,6 @@ static int dsi_host_attach(struct mipi_dsi_host *host,
 	msm_host->format = dsi->format;
 	msm_host->mode_flags = dsi->mode_flags;
 
-	msm_dsi_manager_attach_dsi_device(msm_host->id);
-
 	/* Some gpios defined in panel DT need to be controlled by host */
 	ret = dsi_host_init_panel_gpios(msm_host, &dsi->dev);
 	if (ret)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
index 5db43c7ffafc..ff39ce6150ad 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
@@ -239,7 +239,7 @@ static bool dsi_mgr_is_cmd_mode(struct msm_dsi *msm_dsi)
 	return !(host_flags & MIPI_DSI_MODE_VIDEO);
 }
 
-static void msm_dsi_manager_setup_encoder(int id)
+void msm_dsi_manager_setup_encoder(int id)
 {
 	struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
 	struct msm_drm_private *priv = msm_dsi->dev->dev_private;
@@ -280,12 +280,7 @@ static int msm_dsi_manager_panel_init(struct drm_connector *conn, u8 id)
 		return PTR_ERR(panel);
 	}
 
-	if (!panel)
-		return 0;
-
-	msm_dsi_manager_setup_encoder(id);
-
-	if (!IS_DUAL_DSI())
+	if (!panel || !IS_DUAL_DSI())
 		goto out;
 
 	drm_object_attach_property(&conn->base,
@@ -790,24 +785,6 @@ bool msm_dsi_manager_cmd_xfer_trigger(int id, u32 dma_base, u32 len)
 	return true;
 }
 
-void msm_dsi_manager_attach_dsi_device(int id)
-{
-	struct msm_dsi *msm_dsi = dsi_mgr_get_dsi(id);
-	struct drm_device *dev = msm_dsi->dev;
-
-	/*
-	 * drm_device pointer is assigned to msm_dsi only in the modeset_init
-	 * path. If mipi_dsi_attach() happens in DSI driver's probe path
-	 * (generally the case when we're connected to a drm_panel of the type
-	 * mipi_dsi_device), this would be NULL. In such cases, try to set the
-	 * encoder mode in the DSI connector's detect() op.
-	 */
-	if (!dev)
-		return;
-
-	msm_dsi_manager_setup_encoder(id);
-}
-
 int msm_dsi_manager_register(struct msm_dsi *msm_dsi)
 {
 	struct msm_dsi_manager *msm_dsim = &msm_dsim_glb;
-- 
Sean Paul, Software Engineer, Google / Chromium OS


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, back to index

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-17 20:03 [RESEND PATCH 01/13] drm/msm/dpu: Remove call to drm_mode_set_crtcinfo Sean Paul
2019-06-17 20:03 ` [RESEND PATCH 02/13] drm/msm/dpu: Fix mmu init/destroy functions Sean Paul
2019-06-17 20:09 ` [PATCH 03/13] drm/msm/phy/dsi_phy: Set pll to NULL in case initialization fails Sean Paul
2019-06-17 20:12 ` [PATCH 04/13] drm/msm/dsi_pll_10nm: Release clk hw on destroy and failure Sean Paul
2019-06-17 20:12   ` [PATCH 05/13] drm/msm/dsi_pll_10nm: Remove impossible check Sean Paul
2019-06-17 20:12   ` [PATCH 06/13] drm/msm: Depopulate platform on probe failure Sean Paul
2019-06-17 20:12   ` [PATCH 07/13] drm/msm/dsi: Split mode_flags out of msm_dsi_host_get_panel() Sean Paul
2019-06-17 20:12   ` [PATCH 08/13] drm/msm/dsi: Don't store dsi host mode_flags in msm_dsi Sean Paul
2019-06-17 20:12   ` [PATCH 09/13] drm/msm/dsi: Pull out panel init code into function Sean Paul
2019-06-17 20:12   ` [PATCH 10/13] drm/msm/dsi: Simplify the logic in msm_dsi_manager_panel_init() Sean Paul
2019-06-17 20:12   ` [PATCH 11/13] drm/msm/dsi: Use the new setup_encoder function in attach_dsi_device Sean Paul
2019-06-17 20:12   ` [PATCH 12/13] drm/msm/dsi: Move dsi panel init into modeset init path Sean Paul
2019-06-17 20:12   ` [PATCH 13/13] drm/msm/dsi: Move setup_encoder to modeset_init Sean Paul

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org linux-arm-msm@archiver.kernel.org
	public-inbox-index linux-arm-msm


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/ public-inbox