Skip to contentSkip to conversation

drm/msm: provide fb_dirty implemenation

PATCH Applied Dmitry Baryshkov 4 participants 14 messages Jun 12, 2023 – Jun 15, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/msm: provide fb_dirty implemenation

Since commit 93e81e38e197 ("drm/fb_helper: Minimize damage-helper overhead") the drm_fb_helper_funcs::fb_dirty helper is required for proper dirty/damage processing. The drm/msm driver requires that to function to let CMD panels to work. Use simplified version of drm_fbdev_generic_helper_fb_dirty() to fix support for CMD mode panels.

Fixes 93e81e38e197 ("drm/fb_helper: Minimize damage-helper overhead")
Cc Thomas Zimmermann <[email protected]>
---
 drivers/gpu/drm/msm/msm_fbdev.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/gpu/drm/msm/msm_fbdev.c +20 -0
index fa9c1cbffae3..b933a85420f6 100644
@@ -139,8 +139,28 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
 	return ret;
 }
 
+static int msm_fbdev_fb_dirty(struct drm_fb_helper *helper,
+			      struct drm_clip_rect *clip)
+{
+	struct drm_device *dev = helper->dev;
+	int ret;
+
+	/* Call damage handlers only if necessary */
+	if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
+		return 0;
+
+	if (helper->fb->funcs->dirty) {
+		ret = helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, clip, 1);
+		if (drm_WARN_ONCE(dev, ret, "Dirty helper failed: ret=%d\n", ret))
+			return ret;
+	}
+
+	return 0;
+}
+
 static const struct drm_fb_helper_funcs msm_fb_helper_funcs = {
 	.fb_probe = msm_fbdev_create,
+	.fb_dirty = msm_fbdev_fb_dirty,
 };
 
 /*
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/2 drm/msm/dsi: don't allow enabling 7nm VCO with unprogrammed rate

CCF can try enabling VCO before the rate has been programmed. This can cause clock lockups and/or other boot issues. Program the VCO to the minimal PLL rate if the read rate is 0 Hz.

Fixes 1ef7c99d145c ("drm/msm/dsi: add support for 7nm DSI PHY/PLL")
---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +5 -0
index 3b1ed02f644d..6979d35eb7c3 100644
@@ -395,11 +395,16 @@ static void dsi_pll_phy_dig_reset(struct dsi_pll_7nm *pll)
 	wmb(); /* Ensure that the reset is deasserted */
 }
 
+static unsigned long dsi_pll_7nm_vco_recalc_rate(struct clk_hw *hw,
+						  unsigned long parent_rate);
 static int dsi_pll_7nm_vco_prepare(struct clk_hw *hw)
 {
 	struct dsi_pll_7nm *pll_7nm = to_pll_7nm(hw);
 	int rc;
 
+	if (dsi_pll_7nm_vco_recalc_rate(hw, VCO_REF_CLK_RATE) == 0)
+		dsi_pll_7nm_vco_set_rate(hw, pll_7nm->phy->cfg->min_pll_rate, VCO_REF_CLK_RATE);
+
 	dsi_pll_enable_pll_bias(pll_7nm);
 	if (pll_7nm->slave)
 		dsi_pll_enable_pll_bias(pll_7nm->slave);
Signature · 1 line
2.39.2
Tested-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/msm/dsi: don't allow enabling 7nm VCO with unprogrammed rate

[Dmitry Baryshkov],

Thank you for sharing the patches. I have reviewed and tested all three patches, and they seem to be working correctly.

Please let me know if you need any further information or assistance.

Best regards,
Degdag Mohamed

Quoted 39 lines · Dmitry Baryshkov

CCF can try enabling VCO before the rate has been programmed. This can cause clock lockups and/or other boot issues. Program the VCO to the minimal PLL rate if the read rate is 0 Hz.

Fixes 1ef7c99d145c ("drm/msm/dsi: add support for 7nm DSI PHY/PLL")
---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +5 -0
index 3b1ed02f644d..6979d35eb7c3 100644
@@ -395,11 +395,16 @@ static void dsi_pll_phy_dig_reset(struct dsi_pll_7nm
 *pll)
 	wmb(); /* Ensure that the reset is deasserted */
 }
 
+static unsigned long dsi_pll_7nm_vco_recalc_rate(struct clk_hw *hw,
+						  unsigned long parent_rate);
 static int dsi_pll_7nm_vco_prepare(struct clk_hw *hw)
 {
 	struct dsi_pll_7nm *pll_7nm = to_pll_7nm(hw);
 	int rc;
 
+	if (dsi_pll_7nm_vco_recalc_rate(hw, VCO_REF_CLK_RATE) == 0)
+		dsi_pll_7nm_vco_set_rate(hw, pll_7nm->phy->cfg->min_pll_rate,
 VCO_REF_CLK_RATE);
+
 	dsi_pll_enable_pll_bias(pll_7nm);
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +0 -1
 	if (pll_7nm->slave)
 		dsi_pll_enable_pll_bias(pll_7nm->slave);
--

2.39.2

#3 lore raw

Re: [PATCH 2/2] drm/msm/dsi: don't allow enabling 7nm VCO with unprogrammed rate

In reply to Dmitry Baryshkov
Quoted 7 lines · Dmitry Baryshkov

CCF can try enabling VCO before the rate has been programmed. This can cause clock lockups and/or other boot issues. Program the VCO to the minimal PLL rate if the read rate is 0 Hz.

Fixes 1ef7c99d145c ("drm/msm/dsi: add support for 7nm DSI PHY/PLL")

This unfortunately regresses my Xperia 5 (sofef01 panel driver that's on the lists) to now run at 30~33Hz instead of 60Hz. I can provide debugging and clk trees later, if needed.

- Marijn

Quoted 28 lines
---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +5 -0
index 3b1ed02f644d..6979d35eb7c3 100644
@@ -395,11 +395,16 @@ static void dsi_pll_phy_dig_reset(struct dsi_pll_7nm *pll)
 	wmb(); /* Ensure that the reset is deasserted */
 }
 
+static unsigned long dsi_pll_7nm_vco_recalc_rate(struct clk_hw *hw,
+						  unsigned long parent_rate);
 static int dsi_pll_7nm_vco_prepare(struct clk_hw *hw)
 {
 	struct dsi_pll_7nm *pll_7nm = to_pll_7nm(hw);
 	int rc;
 
+	if (dsi_pll_7nm_vco_recalc_rate(hw, VCO_REF_CLK_RATE) == 0)
+		dsi_pll_7nm_vco_set_rate(hw, pll_7nm->phy->cfg->min_pll_rate, VCO_REF_CLK_RATE);
+
 	dsi_pll_enable_pll_bias(pll_7nm);
 	if (pll_7nm->slave)
 		dsi_pll_enable_pll_bias(pll_7nm->slave);
Signature · 1 line
2.39.2
#4 lore raw

Re: [PATCH 2/2] drm/msm/dsi: don't allow enabling 7nm VCO with unprogrammed rate

Quoted 5 lines · Marijn Suijten
Quoted 4 lines · Dmitry Baryshkov

CCF can try enabling VCO before the rate has been programmed. This can cause clock lockups and/or other boot issues. Program the VCO to the minimal PLL rate if the read rate is 0 Hz.

Quoted 7 lines
Quoted 3 lines
Fixes 1ef7c99d145c ("drm/msm/dsi: add support for 7nm DSI PHY/PLL")

This unfortunately regresses my Xperia 5 (sofef01 panel driver that's on the lists) to now run at 30~33Hz instead of 60Hz. I can provide debugging and clk trees later, if needed.

I'll also retest the Xperia 1 with this, which has a 4k DSC panel.

Is this intended to get rid of:

msm_dsi_phy ae94400.phy: [drm:dsi_pll_7nm_vco_prepare] *ERROR* DSI PLL(0) lock failed, status=0x00000000: -110 PLL(0) lock failed

... at startup (and relevant rcg2 update_config failures, unbalanced disables etc)? It locks after a couple tries but it's still unnecessarily spammy.

- Marijn

Quoted 31 lines

- Marijn

Quoted 28 lines
---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +5 -0
index 3b1ed02f644d..6979d35eb7c3 100644
@@ -395,11 +395,16 @@ static void dsi_pll_phy_dig_reset(struct dsi_pll_7nm *pll)
 	wmb(); /* Ensure that the reset is deasserted */
 }
 
+static unsigned long dsi_pll_7nm_vco_recalc_rate(struct clk_hw *hw,
+						  unsigned long parent_rate);
 static int dsi_pll_7nm_vco_prepare(struct clk_hw *hw)
 {
 	struct dsi_pll_7nm *pll_7nm = to_pll_7nm(hw);
 	int rc;
 
+	if (dsi_pll_7nm_vco_recalc_rate(hw, VCO_REF_CLK_RATE) == 0)
+		dsi_pll_7nm_vco_set_rate(hw, pll_7nm->phy->cfg->min_pll_rate, VCO_REF_CLK_RATE);
+
 	dsi_pll_enable_pll_bias(pll_7nm);
 	if (pll_7nm->slave)
 		dsi_pll_enable_pll_bias(pll_7nm->slave);
Signature · 1 line
2.39.2
#5 lore raw

Re: [PATCH 2/2] drm/msm/dsi: don't allow enabling 7nm VCO with unprogrammed rate

Quoted 16 lines · Marijn Suijten
Quoted 5 lines · Marijn Suijten
Quoted 4 lines · Dmitry Baryshkov

CCF can try enabling VCO before the rate has been programmed. This can cause clock lockups and/or other boot issues. Program the VCO to the minimal PLL rate if the read rate is 0 Hz.

Quoted 7 lines
Quoted 3 lines
Fixes 1ef7c99d145c ("drm/msm/dsi: add support for 7nm DSI PHY/PLL")

This unfortunately regresses my Xperia 5 (sofef01 panel driver that's on the lists) to now run at 30~33Hz instead of 60Hz. I can provide debugging and clk trees later, if needed.

I'll also retest the Xperia 1 with this, which has a 4k DSC panel.

Quoted 8 lines

Is this intended to get rid of:

msm_dsi_phy ae94400.phy: [drm:dsi_pll_7nm_vco_prepare] *ERROR* DSI PLL(0) lock failed, status=0x00000000: -110 PLL(0) lock failed

... at startup (and relevant rcg2 update_config failures, unbalanced disables etc)? It locks after a couple tries but it's still unnecessarily spammy.

Yes.

Quoted 34 lines

- Marijn

Quoted 31 lines

- Marijn

Quoted 28 lines
---
  drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +5 -0
index 3b1ed02f644d..6979d35eb7c3 100644
@@ -395,11 +395,16 @@ static void dsi_pll_phy_dig_reset(struct dsi_pll_7nm *pll)
  	wmb(); /* Ensure that the reset is deasserted */
  }
 
+static unsigned long dsi_pll_7nm_vco_recalc_rate(struct clk_hw *hw,
+						  unsigned long parent_rate);
  static int dsi_pll_7nm_vco_prepare(struct clk_hw *hw)
  {
  	struct dsi_pll_7nm *pll_7nm = to_pll_7nm(hw);
  	int rc;
 
+	if (dsi_pll_7nm_vco_recalc_rate(hw, VCO_REF_CLK_RATE) == 0)
+		dsi_pll_7nm_vco_set_rate(hw, pll_7nm->phy->cfg->min_pll_rate, VCO_REF_CLK_RATE);
+
  	dsi_pll_enable_pll_bias(pll_7nm);
  	if (pll_7nm->slave)
  		dsi_pll_enable_pll_bias(pll_7nm->slave);
Signature · 1 line
2.39.2
Signature · 2 lines
With best wishes
Dmitry
#6 lore raw

Re: [PATCH 2/2] drm/msm/dsi: don't allow enabling 7nm VCO with unprogrammed rate

Quoted 7 lines · Dmitry Baryshkov
Quoted 6 lines · Marijn Suijten
Quoted 5 lines · Marijn Suijten
Quoted 4 lines · Dmitry Baryshkov

CCF can try enabling VCO before the rate has been programmed. This can cause clock lockups and/or other boot issues. Program the VCO to the minimal PLL rate if the read rate is 0 Hz.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Fixes 1ef7c99d145c ("drm/msm/dsi: add support for 7nm DSI PHY/PLL")

This unfortunately regresses my Xperia 5 (sofef01 panel driver that's on the lists) to now run at 30~33Hz instead of 60Hz. I can provide debugging and clk trees later, if needed.

The clktree before and after this patch remains identical (Xperia 5):

    bi_tcxo                          11       11        0    19200000          0     0  50000         Y
       dsi0vco_clk                    1        1        0  1132181982          0     0  50000         Y
          dsi0_pll_out_div_clk        1        1        0  1132181982          0     0  50000         Y
             dsi0_pll_post_out_div_clk       0        0        0   283045495          0     0  50000         Y
             dsi0_pll_bit_clk         2        2        0  1132181982          0     0  50000         Y
                dsi0_pclk_mux         1        1        0  1132181982          0     0  50000         Y
                   dsi0_phy_pll_out_dsiclk       1        1        0   188696997          0     0  50000         Y
                      disp_cc_mdss_pclk0_clk_src       1        1        0   188696997          0     0  50000         Y
                         disp_cc_mdss_pclk0_clk       1        1        0   188696997          0     0  50000         Y
                dsi0_pll_by_2_bit_clk       0        0        0   566090991          0     0  50000         Y
                dsi0_phy_pll_out_byteclk       1        1        0   141522747          0     0  50000         Y
                   disp_cc_mdss_byte0_clk_src       2        2        0   141522747          0     0  50000         Y
                      disp_cc_mdss_byte0_div_clk_src       1        1        0    70761374          0     0  50000         Y
                         disp_cc_mdss_byte0_intf_clk       1        1        0    70761374          0     0  50000         Y
                      disp_cc_mdss_byte0_clk       1        1        0   141522747          0     0  50000         Y

But the word-diff from debugcc -p sm8150 -b disp -a pre and post shows that the clocks were at first ticking exactly how Linux expects them to (accurate on kHz it seems), but significantly lower after this patch:

    diff --git a/bahamut_pre_debugcc b/bahamut_post_debugcc
    index be8269ef34ae5..395048a9f37fe 100644
    --- a/bahamut_pre_debugcc
    +++ b/bahamut_post_debugcc
    @@ -1,6 +1,6 @@
                                  disp_cc_mdss_ahb_clk: 19.199412MHz (19199412Hz)
                                disp_cc_mdss_byte0_clk: [-141.522568MHz (141522568Hz)-]{+124.998840MHz (124998840Hz)+}
                           disp_cc_mdss_byte0_intf_clk: [-70.761796MHz (70761796Hz)-]{+62.500812MHz (62500812Hz)+}
                                disp_cc_mdss_byte1_clk: off
                           disp_cc_mdss_byte1_intf_clk: off
                              disp_cc_mdss_dp_aux1_clk: off
    @@ -19,15 +19,15 @@
                             disp_cc_mdss_edp_link_clk: off
                        disp_cc_mdss_edp_link_intf_clk: off
                            disp_cc_mdss_edp_pixel_clk: off
                                 disp_cc_mdss_esc0_clk: [-19.200000MHz (19200000Hz)-]{+19.199412MHz (19199412Hz)+}
                                 disp_cc_mdss_esc1_clk: off
                                  disp_cc_mdss_mdp_clk: [-200.000692MHz (200000692Hz)-]{+200.001280MHz (200001280Hz)+}
                              disp_cc_mdss_mdp_lut_clk: [-200.000108MHz (200000108Hz)-]{+200.001280MHz (200001280Hz)+}
                         disp_cc_mdss_non_gdsc_ahb_clk: [-19.199412MHz (19199412Hz)-]{+19.199704MHz (19199704Hz)+}
                                disp_cc_mdss_pclk0_clk: [-188.697976MHz (188697976Hz)-]{+166.668196MHz (166668196Hz)+}
                                disp_cc_mdss_pclk1_clk: off
                                  disp_cc_mdss_rot_clk: 19.200000MHz (19200000Hz)
                             disp_cc_mdss_rscc_ahb_clk: 19.200000MHz (19200000Hz)
                           disp_cc_mdss_rscc_vsync_clk:[-19.200000MHz (19200000Hz)-]
    [-                            disp_cc_mdss_vsync_clk:-] 19.199704MHz (19199704Hz)
                                {+disp_cc_mdss_vsync_clk: 19.200292MHz (19200292Hz)+}
                                        disp_cc_xo_clk: [-19.199704MHz (19199704Hz)-]{+19.200000MHz (19200000Hz)+}
Quoted 1 line
Quoted 1 line

I'll also retest the Xperia 1 with this, which has a 4k DSC panel.

On the Xperia 1 modetest also reports 30 instead of 60Hz now (4k mode, not the 2.5k mode, if you've kept up with my panel series) but it remains black.
(Note that this panel uses DSC, so the byte and pixel clock for this
1644x3840 panel are ticking slower than for a 1080x2520 one :) )

Same story for the clk tree here, it is the same before and after this patch:

    bi_tcxo                          11       11        0    19200000          0     0  50000         Y
       dsi0vco_clk                    1        1        0  1736017822          0     0  50000         Y
          dsi0_pll_out_div_clk        1        1        0   868008911          0     0  50000         Y
             dsi0_pll_post_out_div_clk       0        0        0   217002227          0     0  50000         Y
             dsi0_pll_bit_clk         2        2        0   868008911          0     0  50000         Y
                dsi0_pclk_mux         1        1        0   868008911          0     0  50000         Y
                   dsi0_phy_pll_out_dsiclk       1        1        0   144668152          0     0  50000         Y
                      disp_cc_mdss_pclk0_clk_src       1        1        0   144668152          0     0  50000         Y
                         disp_cc_mdss_pclk0_clk       1        1        0   144668152          0     0  50000         Y
                dsi0_pll_by_2_bit_clk       0        0        0   434004455          0     0  50000         Y
                dsi0_phy_pll_out_byteclk       1        1        0   108501113          0     0  50000         Y
                   disp_cc_mdss_byte0_clk_src       2        2        0   108501113          0     0  50000         Y
                      disp_cc_mdss_byte0_div_clk_src       1        1        0    54250557          0     0  50000         Y
                         disp_cc_mdss_byte0_intf_clk       1        1        0    54250557          0     0  50000         Y
                      disp_cc_mdss_byte0_clk       1        1        0   108501113          0     0  50000         Y

The measured clocks are now about half of what they're supposed to be:

    diff --git a/griffin_pre_debugcc b/griffin_post_debugcc
    index a5987e1671d3b..8c8618e60ad1c 100644
    --- a/griffin_pre_debugcc
    +++ b/griffin_post_debugcc
    @@ -1,6 +1,6 @@
                                  disp_cc_mdss_ahb_clk: [-19.200000MHz (19200000Hz)-]{+19.199704MHz (19199704Hz)+}
                                disp_cc_mdss_byte0_clk: [-108.502356MHz (108502356Hz)-]{+62.499932MHz (62499932Hz)+}
                           disp_cc_mdss_byte0_intf_clk: [-54.250372MHz (54250372Hz)-]{+31.250040MHz (31250040Hz)+}
                                disp_cc_mdss_byte1_clk: off
                           disp_cc_mdss_byte1_intf_clk: off
                              disp_cc_mdss_dp_aux1_clk: off
    @@ -21,13 +21,13 @@
                            disp_cc_mdss_edp_pixel_clk: off
                                 disp_cc_mdss_esc0_clk: 19.200000MHz (19200000Hz)
                                 disp_cc_mdss_esc1_clk: off
                                  disp_cc_mdss_mdp_clk: [-460.001848MHz (460001848Hz)-]{+460.000384MHz (460000384Hz)+}
                              disp_cc_mdss_mdp_lut_clk: [-460.001556MHz (460001556Hz)-]{+459.996280MHz (459996280Hz)+}
                         disp_cc_mdss_non_gdsc_ahb_clk: 19.200000MHz (19200000Hz)
                                disp_cc_mdss_pclk0_clk: [-144.668004MHz (144668004Hz)-]{+83.333584MHz (83333584Hz)+}
                                disp_cc_mdss_pclk1_clk: off
                                  disp_cc_mdss_rot_clk: [-19.199704MHz (19199704Hz)-]{+19.200000MHz (19200000Hz)+}
                             disp_cc_mdss_rscc_ahb_clk: [-19.200292MHz (19200292Hz)-]{+19.200000MHz (19200000Hz)+}
                           disp_cc_mdss_rscc_vsync_clk:[-19.199412MHz (19199412Hz)-]
    [-                            disp_cc_mdss_vsync_clk:-] 19.200000MHz (19200000Hz)
                                {+disp_cc_mdss_vsync_clk: 19.199412MHz (19199412Hz)+}
                                        disp_cc_xo_clk: 19.199704MHz (19199704Hz)
Quoted 10 lines
Quoted 8 lines

Is this intended to get rid of:

msm_dsi_phy ae94400.phy: [drm:dsi_pll_7nm_vco_prepare] *ERROR* DSI PLL(0) lock failed, status=0x00000000: -110 PLL(0) lock failed

... at startup (and relevant rcg2 update_config failures, unbalanced disables etc)? It locks after a couple tries but it's still unnecessarily spammy.

Yes.

It is still occuring twice, with the unbalanced disable/unprepare warnings for dsi0_phy_pll_out_{bytes,dsi}clk.

- Marijn

Quoted 40 lines
Quoted 35 lines

- Marijn

Quoted 31 lines

- Marijn

Quoted 28 lines
---
  drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +5 -0
index 3b1ed02f644d..6979d35eb7c3 100644
@@ -395,11 +395,16 @@ static void dsi_pll_phy_dig_reset(struct dsi_pll_7nm *pll)
  	wmb(); /* Ensure that the reset is deasserted */
  }
 
+static unsigned long dsi_pll_7nm_vco_recalc_rate(struct clk_hw *hw,
+						  unsigned long parent_rate);
  static int dsi_pll_7nm_vco_prepare(struct clk_hw *hw)
  {
  	struct dsi_pll_7nm *pll_7nm = to_pll_7nm(hw);
  	int rc;
 
+	if (dsi_pll_7nm_vco_recalc_rate(hw, VCO_REF_CLK_RATE) == 0)
+		dsi_pll_7nm_vco_set_rate(hw, pll_7nm->phy->cfg->min_pll_rate, VCO_REF_CLK_RATE);
+
  	dsi_pll_enable_pll_bias(pll_7nm);
  	if (pll_7nm->slave)
  		dsi_pll_enable_pll_bias(pll_7nm->slave);
Signature · 1 line
2.39.2
Signature · 2 lines
With best wishes
Dmitry
Reviewed-by on v1 1/2
#7 lore raw
In reply to Dmitry Baryshkov

Hi

Am 12.06.23 um 05:16 schrieb Dmitry Baryshkov:

Quoted 10 lines

Since commit 93e81e38e197 ("drm/fb_helper: Minimize damage-helper overhead") the drm_fb_helper_funcs::fb_dirty helper is required for proper dirty/damage processing. The drm/msm driver requires that to function to let CMD panels to work. Use simplified version of drm_fbdev_generic_helper_fb_dirty() to fix support for CMD mode panels.

Fixes 93e81e38e197 ("drm/fb_helper: Minimize damage-helper overhead")
Cc Thomas Zimmermann <[email protected]>

To make mmap work correctly, you'll also need deferred I/O in the fbdev code. AFAICT the driver never supported that.

Best regards
Thomas

Quoted 37 lines
---
  drivers/gpu/drm/msm/msm_fbdev.c | 20 ++++++++++++++++++++
  1 file changed, 20 insertions(+)
drivers/gpu/drm/msm/msm_fbdev.c +20 -0
index fa9c1cbffae3..b933a85420f6 100644
@@ -139,8 +139,28 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
  	return ret;
  }
 
+static int msm_fbdev_fb_dirty(struct drm_fb_helper *helper,
+			      struct drm_clip_rect *clip)
+{
+	struct drm_device *dev = helper->dev;
+	int ret;
+
+	/* Call damage handlers only if necessary */
+	if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
+		return 0;
+
+	if (helper->fb->funcs->dirty) {
+		ret = helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, clip, 1);
+		if (drm_WARN_ONCE(dev, ret, "Dirty helper failed: ret=%d\n", ret))
+			return ret;
+	}
+
+	return 0;
+}
+
  static const struct drm_fb_helper_funcs msm_fb_helper_funcs = {
  	.fb_probe = msm_fbdev_create,
+	.fb_dirty = msm_fbdev_fb_dirty,
  };
 
  /*
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#8 lore raw
Quoted 9 lines · Thomas Zimmermann

Hi

Am 12.06.23 um 05:16 schrieb Dmitry Baryshkov:

Quoted 6 lines

Since commit 93e81e38e197 ("drm/fb_helper: Minimize damage-helper overhead") the drm_fb_helper_funcs::fb_dirty helper is required for proper dirty/damage processing. The drm/msm driver requires that to function to let CMD panels to work. Use simplified version of drm_fbdev_generic_helper_fb_dirty() to fix support for CMD mode panels.

Quoted 8 lines
Quoted 4 lines
Fixes 93e81e38e197 ("drm/fb_helper: Minimize damage-helper overhead")
Cc Thomas Zimmermann <[email protected]>

To make mmap work correctly, you'll also need deferred I/O in the fbdev code. AFAICT the driver never supported that.

We do not use the deferred I/O. The damage/dirty tracking is used to check whether we should ping the CMD panel or not. See [1]

[1] https://lore.kernel.org/all/[email protected]/

Quoted 42 lines

Best regards
Thomas

Quoted 37 lines

---
  drivers/gpu/drm/msm/msm_fbdev.c | 20 ++++++++++++++++++++

  1 file changed, 20 insertions(+)
drivers/gpu/drm/msm/msm_fbdev.c +20 -0
index fa9c1cbffae3..b933a85420f6 100644
@@ -139,8 +139,28 @@ static int msm_fbdev_create(struct drm_fb_helper 
 *helper,
       return ret;
   }
+static int msm_fbdev_fb_dirty(struct drm_fb_helper *helper,
+                  struct drm_clip_rect *clip)
+{
+    struct drm_device *dev = helper->dev;
+    int ret;
+
+    /* Call damage handlers only if necessary */
+    if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
+        return 0;
+
+    if (helper->fb->funcs->dirty) {
+        ret = helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, clip, 1);
+        if (drm_WARN_ONCE(dev, ret, "Dirty helper failed: ret=%d\n", 
 ret))
+            return ret;
+    }
+
+    return 0;
+}
+
   static const struct drm_fb_helper_funcs msm_fb_helper_funcs = {
       .fb_probe = msm_fbdev_create,
+    .fb_dirty = msm_fbdev_fb_dirty,
   };
   /*
Signature · 2 lines
With best wishes
Dmitry
reviewer Reviewed-by on v1 1/2
#9 lore raw
In reply to Dmitry Baryshkov
Quoted 10 lines · Dmitry Baryshkov

Since commit 93e81e38e197 ("drm/fb_helper: Minimize damage-helper overhead") the drm_fb_helper_funcs::fb_dirty helper is required for proper dirty/damage processing. The drm/msm driver requires that to function to let CMD panels to work. Use simplified version of drm_fbdev_generic_helper_fb_dirty() to fix support for CMD mode panels.

Fixes 93e81e38e197 ("drm/fb_helper: Minimize damage-helper overhead")
Cc Thomas Zimmermann <[email protected]>

Thanks, this solves the following warning:

    msm_dpu ae01000.display-controller: drm_WARN_ON_ONCE(!helper->funcs->fb_dirty)
    WARNING: CPU: 0 PID: 9 at drivers/gpu/drm/drm_fb_helper.c:381 drm_fb_helper_damage_work+0x1c0/0x20c

Note that drm_fb_helper_funcs documents this as "This callback is optional": is it no longer optional, or are we enabling a damage feature that makes it not-optional?

- Marijn

Quoted 40 lines
---
 drivers/gpu/drm/msm/msm_fbdev.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/gpu/drm/msm/msm_fbdev.c +20 -0
index fa9c1cbffae3..b933a85420f6 100644
@@ -139,8 +139,28 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
 	return ret;
 }
 
+static int msm_fbdev_fb_dirty(struct drm_fb_helper *helper,
+			      struct drm_clip_rect *clip)
+{
+	struct drm_device *dev = helper->dev;
+	int ret;
+
+	/* Call damage handlers only if necessary */
+	if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
+		return 0;
+
+	if (helper->fb->funcs->dirty) {
+		ret = helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, clip, 1);
+		if (drm_WARN_ONCE(dev, ret, "Dirty helper failed: ret=%d\n", ret))
+			return ret;
+	}
+
+	return 0;
+}
+
 static const struct drm_fb_helper_funcs msm_fb_helper_funcs = {
 	.fb_probe = msm_fbdev_create,
+	.fb_dirty = msm_fbdev_fb_dirty,
 };
 
 /*
Signature · 1 line
2.39.2
#10 lore raw

Hi

Am 12.06.23 um 11:14 schrieb Marijn Suijten:

Quoted 14 lines · Dmitry Baryshkov
Quoted 10 lines

Since commit 93e81e38e197 ("drm/fb_helper: Minimize damage-helper overhead") the drm_fb_helper_funcs::fb_dirty helper is required for proper dirty/damage processing. The drm/msm driver requires that to function to let CMD panels to work. Use simplified version of drm_fbdev_generic_helper_fb_dirty() to fix support for CMD mode panels.

Fixes 93e81e38e197 ("drm/fb_helper: Minimize damage-helper overhead")
Cc Thomas Zimmermann <[email protected]>

Thanks, this solves the following warning:

Quoted 8 lines
     msm_dpu ae01000.display-controller: drm_WARN_ON_ONCE(!helper->funcs->fb_dirty)
     WARNING: CPU: 0 PID: 9 at drivers/gpu/drm/drm_fb_helper.c:381 drm_fb_helper_damage_work+0x1c0/0x20c

Note that drm_fb_helper_funcs documents this as "This callback is optional": is it no longer optional, or are we enabling a damage feature that makes it not-optional?

It is optional in the sense that most hardware and drivers don't require damage handling. Those that do, also require this callback.

Best regards
Thomas

Quoted 43 lines

- Marijn

Quoted 40 lines
---
  drivers/gpu/drm/msm/msm_fbdev.c | 20 ++++++++++++++++++++
  1 file changed, 20 insertions(+)
drivers/gpu/drm/msm/msm_fbdev.c +20 -0
index fa9c1cbffae3..b933a85420f6 100644
@@ -139,8 +139,28 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
  	return ret;
  }
 
+static int msm_fbdev_fb_dirty(struct drm_fb_helper *helper,
+			      struct drm_clip_rect *clip)
+{
+	struct drm_device *dev = helper->dev;
+	int ret;
+
+	/* Call damage handlers only if necessary */
+	if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
+		return 0;
+
+	if (helper->fb->funcs->dirty) {
+		ret = helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, clip, 1);
+		if (drm_WARN_ONCE(dev, ret, "Dirty helper failed: ret=%d\n", ret))
+			return ret;
+	}
+
+	return 0;
+}
+
  static const struct drm_fb_helper_funcs msm_fb_helper_funcs = {
  	.fb_probe = msm_fbdev_create,
+	.fb_dirty = msm_fbdev_fb_dirty,
  };
 
  /*
Signature · 1 line
2.39.2
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#11 lore raw
Quoted 20 lines · Thomas Zimmermann

Hi

Am 12.06.23 um 11:14 schrieb Marijn Suijten:

Quoted 17 lines · Dmitry Baryshkov
Quoted 10 lines

Since commit 93e81e38e197 ("drm/fb_helper: Minimize damage-helper overhead") the drm_fb_helper_funcs::fb_dirty helper is required for proper dirty/damage processing. The drm/msm driver requires that to function to let CMD panels to work. Use simplified version of drm_fbdev_generic_helper_fb_dirty() to fix support for CMD mode panels.

Fixes 93e81e38e197 ("drm/fb_helper: Minimize damage-helper overhead")
Cc Thomas Zimmermann <[email protected]>

Thanks, this solves the following warning:

     msm_dpu ae01000.display-controller: drm_WARN_ON_ONCE(!helper->funcs->fb_dirty)

     WARNING: CPU: 0 PID: 9 at drivers/gpu/drm/drm_fb_helper.c:381 drm_fb_helper_damage_work+0x1c0/0x20c
Quoted 7 lines
Quoted 5 lines

Note that drm_fb_helper_funcs documents this as "This callback is optional": is it no longer optional, or are we enabling a damage feature that makes it not-optional?

It is optional in the sense that most hardware and drivers don't require damage handling. Those that do, also require this callback.

Can we please get this documented? I think it was really optional beforehand.

Quoted 49 lines

Best regards
Thomas

Quoted 44 lines

- Marijn

Quoted 41 lines

---
  drivers/gpu/drm/msm/msm_fbdev.c | 20 ++++++++++++++++++++

  1 file changed, 20 insertions(+)
drivers/gpu/drm/msm/msm_fbdev.c +20 -0
index fa9c1cbffae3..b933a85420f6 100644
@@ -139,8 +139,28 @@ static int msm_fbdev_create(struct drm_fb_helper 
 *helper,
       return ret;
   }
+static int msm_fbdev_fb_dirty(struct drm_fb_helper *helper,
+                  struct drm_clip_rect *clip)
+{
+    struct drm_device *dev = helper->dev;
+    int ret;
+
+    /* Call damage handlers only if necessary */
+    if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
+        return 0;
+
+    if (helper->fb->funcs->dirty) {
+        ret = helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, clip, 
 1);
+        if (drm_WARN_ONCE(dev, ret, "Dirty helper failed: ret=%d\n", 
 ret))
+            return ret;
+    }
+
+    return 0;
+}
+
   static const struct drm_fb_helper_funcs msm_fb_helper_funcs = {
       .fb_probe = msm_fbdev_create,
+    .fb_dirty = msm_fbdev_fb_dirty,
   };

  /*

Signature · 1 line
2.39.2
Signature · 2 lines
With best wishes
Dmitry
author Applied
#13 lore raw
In reply to Dmitry Baryshkov
Quoted 8 lines · Dmitry Baryshkov

Since commit 93e81e38e197 ("drm/fb_helper: Minimize damage-helper overhead") the drm_fb_helper_funcs::fb_dirty helper is required for proper dirty/damage processing. The drm/msm driver requires that to function to let CMD panels to work. Use simplified version of drm_fbdev_generic_helper_fb_dirty() to fix support for CMD mode panels.

[...]

Applied, thanks!

[1/2] drm/msm: provide fb_dirty implemenation

      https://gitlab.freedesktop.org/lumag/msm/-/commit/fda520976ef4

Best regards,

Signature · 1 line
Dmitry Baryshkov <[email protected]>