drm/vc4: Enable SCALER_CONTROL early in HVS init
authorTim Gover <tim.gover@raspberrypi.com>
Thu, 13 Jul 2023 16:47:22 +0000 (17:47 +0100)
committerDom Cobley <popcornmix@gmail.com>
Mon, 19 Feb 2024 11:34:56 +0000 (11:34 +0000)
Always enable SCALER_CONTROL before attempting other HVS
operations. It's safe to write to some parts of the HVS but
in general it's dangerous to do this because it can cause bus
lockups.

Signed-off-by: Tim Gover <tim.gover@raspberrypi.com>
drivers/gpu/drm/vc4/vc4_hvs.c

index 113d3c9..b4250b3 100644 (file)
@@ -1293,6 +1293,10 @@ static int vc4_hvs_hw_init(struct vc4_hvs *hvs)
        struct vc4_dev *vc4 = hvs->vc4;
        u32 dispctrl, reg;
 
+       dispctrl = HVS_READ(SCALER_DISPCTRL);
+       dispctrl |= SCALER_DISPCTRL_ENABLE;
+       HVS_WRITE(SCALER_DISPCTRL, dispctrl);
+
        reg = HVS_READ(SCALER_DISPECTRL);
        reg &= ~SCALER_DISPECTRL_DSP2_MUX_MASK;
        HVS_WRITE(SCALER_DISPECTRL,
@@ -1314,8 +1318,6 @@ static int vc4_hvs_hw_init(struct vc4_hvs *hvs)
                  reg | VC4_SET_FIELD(3, SCALER_DISPDITHER_DSP5_MUX));
 
        dispctrl = HVS_READ(SCALER_DISPCTRL);
-
-       dispctrl |= SCALER_DISPCTRL_ENABLE;
        dispctrl |= SCALER_DISPCTRL_DISPEIRQ(0) |
                    SCALER_DISPCTRL_DISPEIRQ(1) |
                    SCALER_DISPCTRL_DISPEIRQ(2);
@@ -1511,6 +1513,10 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
        else
                hvs->dlist = hvs->regs + SCALER5_DLIST_START;
 
+       ret = vc4_hvs_hw_init(hvs);
+       if (ret)
+               return ret;
+
        /* Upload filter kernels.  We only have the one for now, so we
         * keep it around for the lifetime of the driver.
         */
@@ -1520,10 +1526,6 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
        if (ret)
                return ret;
 
-       ret = vc4_hvs_hw_init(hvs);
-       if (ret)
-               return ret;
-
        ret = vc4_hvs_cob_init(hvs);
        if (ret)
                return ret;