lkml.org 
[lkml]   [2022]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.16 0080/1039] drm/rockchip: dsi: Hold pm-runtime across bind/unbind
    Date
    From: Brian Norris <briannorris@chromium.org>

    commit 514db871922f103886ad4d221cf406b4fcc5e74a upstream.

    In commit 43c2de1002d2 ("drm/rockchip: dsi: move all lane config except
    LCDC mux to bind()"), we moved most HW configuration to bind(), but we
    didn't move the runtime PM management. Therefore, depending on initial
    boot state, runtime-PM workqueue delays, and other timing factors, we
    may disable our power domain in between the hardware configuration
    (bind()) and when we enable the display. This can cause us to lose
    hardware state and fail to configure our display. For example:

    dw-mipi-dsi-rockchip ff968000.mipi: failed to write command FIFO
    panel-innolux-p079zca ff960000.mipi.0: failed to write command 0

    or:

    dw-mipi-dsi-rockchip ff968000.mipi: failed to write command FIFO
    panel-kingdisplay-kd097d04 ff960000.mipi.0: failed write init cmds: -110

    We should match the runtime PM to the lifetime of the bind()/unbind()
    cycle.

    Tested on Acer Chrometab 10 (RK3399 Gru-Scarlet), with panel drivers
    built either as modules or built-in.

    Side notes: it seems one is more likely to see this problem when the
    panel driver is built into the kernel. I've also seen this problem
    bisect down to commits that simply changed Kconfig dependencies, because
    it changed the order in which driver init functions were compiled into
    the kernel, and therefore the ordering and timing of built-in device
    probe.

    Fixes: 43c2de1002d2 ("drm/rockchip: dsi: move all lane config except LCDC mux to bind()")
    Link: https://lore.kernel.org/linux-rockchip/9aedfb528600ecf871885f7293ca4207c84d16c1.camel@gmail.com/
    Reported-by: <aleksandr.o.makarov@gmail.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Brian Norris <briannorris@chromium.org>
    Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
    Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
    Signed-off-by: Heiko Stuebner <heiko@sntech.de>
    Link: https://patchwork.freedesktop.org/patch/msgid/20210928143413.v3.1.Ic2904d37f30013a7f3d8476203ad3733c186827e@changeid
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 37 ++++++++++++------------
    1 file changed, 19 insertions(+), 18 deletions(-)

    --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
    +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c
    @@ -772,10 +772,6 @@ static void dw_mipi_dsi_encoder_enable(s
    if (mux < 0)
    return;

    - pm_runtime_get_sync(dsi->dev);
    - if (dsi->slave)
    - pm_runtime_get_sync(dsi->slave->dev);
    -
    /*
    * For the RK3399, the clk of grf must be enabled before writing grf
    * register. And for RK3288 or other soc, this grf_clk must be NULL,
    @@ -794,20 +790,10 @@ static void dw_mipi_dsi_encoder_enable(s
    clk_disable_unprepare(dsi->grf_clk);
    }

    -static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder)
    -{
    - struct dw_mipi_dsi_rockchip *dsi = to_dsi(encoder);
    -
    - if (dsi->slave)
    - pm_runtime_put(dsi->slave->dev);
    - pm_runtime_put(dsi->dev);
    -}
    -
    static const struct drm_encoder_helper_funcs
    dw_mipi_dsi_encoder_helper_funcs = {
    .atomic_check = dw_mipi_dsi_encoder_atomic_check,
    .enable = dw_mipi_dsi_encoder_enable,
    - .disable = dw_mipi_dsi_encoder_disable,
    };

    static int rockchip_dsi_drm_create_encoder(struct dw_mipi_dsi_rockchip *dsi,
    @@ -937,10 +923,14 @@ static int dw_mipi_dsi_rockchip_bind(str
    put_device(second);
    }

    + pm_runtime_get_sync(dsi->dev);
    + if (dsi->slave)
    + pm_runtime_get_sync(dsi->slave->dev);
    +
    ret = clk_prepare_enable(dsi->pllref_clk);
    if (ret) {
    DRM_DEV_ERROR(dev, "Failed to enable pllref_clk: %d\n", ret);
    - return ret;
    + goto out_pm_runtime;
    }

    /*
    @@ -952,7 +942,7 @@ static int dw_mipi_dsi_rockchip_bind(str
    ret = clk_prepare_enable(dsi->grf_clk);
    if (ret) {
    DRM_DEV_ERROR(dsi->dev, "Failed to enable grf_clk: %d\n", ret);
    - return ret;
    + goto out_pm_runtime;
    }

    dw_mipi_dsi_rockchip_config(dsi);
    @@ -964,16 +954,23 @@ static int dw_mipi_dsi_rockchip_bind(str
    ret = rockchip_dsi_drm_create_encoder(dsi, drm_dev);
    if (ret) {
    DRM_DEV_ERROR(dev, "Failed to create drm encoder\n");
    - return ret;
    + goto out_pm_runtime;
    }

    ret = dw_mipi_dsi_bind(dsi->dmd, &dsi->encoder);
    if (ret) {
    DRM_DEV_ERROR(dev, "Failed to bind: %d\n", ret);
    - return ret;
    + goto out_pm_runtime;
    }

    return 0;
    +
    +out_pm_runtime:
    + pm_runtime_put(dsi->dev);
    + if (dsi->slave)
    + pm_runtime_put(dsi->slave->dev);
    +
    + return ret;
    }

    static void dw_mipi_dsi_rockchip_unbind(struct device *dev,
    @@ -988,6 +985,10 @@ static void dw_mipi_dsi_rockchip_unbind(
    dw_mipi_dsi_unbind(dsi->dmd);

    clk_disable_unprepare(dsi->pllref_clk);
    +
    + pm_runtime_put(dsi->dev);
    + if (dsi->slave)
    + pm_runtime_put(dsi->slave->dev);
    }

    static const struct component_ops dw_mipi_dsi_rockchip_ops = {

    \
     
     \ /
      Last update: 2022-01-25 01:14    [W:2.718 / U:1.780 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site