Skip to content

Commit 5882578

Browse files
krzkAbhinav Kumar
authored andcommitted
drm/msm/dsi/phy: Protect PHY_CMN_CLK_CFG0 updated from driver side
PHY_CMN_CLK_CFG0 register is updated by the PHY driver and by two divider clocks from Common Clock Framework: devm_clk_hw_register_divider_parent_hw(). Concurrent access by the clocks side is protected with spinlock, however driver's side in restoring state is not. Restoring state is called from msm_dsi_phy_enable(), so there could be a path leading to concurrent and conflicting updates with clock framework. Add missing lock usage on the PHY driver side, encapsulated in its own function so the code will be still readable. While shuffling the code, define and use PHY_CMN_CLK_CFG0 bitfields to make the code more readable and obvious. Fixes: 1ef7c99 ("drm/msm/dsi: add support for 7nm DSI PHY/PLL") Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Patchwork: https://patchwork.freedesktop.org/patch/637376/ Link: https://lore.kernel.org/r/20250214-drm-msm-phy-pll-cfg-reg-v3-1-0943b850722c@linaro.org Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
1 parent 5e192ee commit 5882578

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,15 @@ static void dsi_pll_enable_pll_bias(struct dsi_pll_7nm *pll)
372372
ndelay(250);
373373
}
374374

375+
static void dsi_pll_cmn_clk_cfg0_write(struct dsi_pll_7nm *pll, u32 val)
376+
{
377+
unsigned long flags;
378+
379+
spin_lock_irqsave(&pll->postdiv_lock, flags);
380+
writel(val, pll->phy->base + REG_DSI_7nm_PHY_CMN_CLK_CFG0);
381+
spin_unlock_irqrestore(&pll->postdiv_lock, flags);
382+
}
383+
375384
static void dsi_pll_disable_global_clk(struct dsi_pll_7nm *pll)
376385
{
377386
u32 data;
@@ -574,8 +583,9 @@ static int dsi_7nm_pll_restore_state(struct msm_dsi_phy *phy)
574583
val |= cached->pll_out_div;
575584
writel(val, pll_7nm->phy->pll_base + REG_DSI_7nm_PHY_PLL_PLL_OUTDIV_RATE);
576585

577-
writel(cached->bit_clk_div | (cached->pix_clk_div << 4),
578-
phy_base + REG_DSI_7nm_PHY_CMN_CLK_CFG0);
586+
dsi_pll_cmn_clk_cfg0_write(pll_7nm,
587+
DSI_7nm_PHY_CMN_CLK_CFG0_DIV_CTRL_3_0(cached->bit_clk_div) |
588+
DSI_7nm_PHY_CMN_CLK_CFG0_DIV_CTRL_7_4(cached->pix_clk_div));
579589

580590
val = readl(phy_base + REG_DSI_7nm_PHY_CMN_CLK_CFG1);
581591
val &= ~0x3;

drivers/gpu/drm/msm/registers/display/dsi_phy_7nm.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ xsi:schemaLocation="https://gitlab.freedesktop.org/freedreno/ rules-fd.xsd">
99
<reg32 offset="0x00004" name="REVISION_ID1"/>
1010
<reg32 offset="0x00008" name="REVISION_ID2"/>
1111
<reg32 offset="0x0000c" name="REVISION_ID3"/>
12-
<reg32 offset="0x00010" name="CLK_CFG0"/>
12+
<reg32 offset="0x00010" name="CLK_CFG0">
13+
<bitfield name="DIV_CTRL_3_0" low="0" high="3" type="uint"/>
14+
<bitfield name="DIV_CTRL_7_4" low="4" high="7" type="uint"/>
15+
</reg32>
1316
<reg32 offset="0x00014" name="CLK_CFG1"/>
1417
<reg32 offset="0x00018" name="GLBL_CTRL"/>
1518
<reg32 offset="0x0001c" name="RBUF_CTRL"/>

0 commit comments

Comments
 (0)