Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp28929pxb; Tue, 28 Sep 2021 14:37:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwk7/ZDNzLoWXn6BmlDnjQ5iGSXNWQoxvoF/ilWgffJu+7ip2zrJfrEi1eh2S5+4Y2KPMBw X-Received: by 2002:a17:90a:312:: with SMTP id 18mr2404043pje.178.1632865062963; Tue, 28 Sep 2021 14:37:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632865062; cv=none; d=google.com; s=arc-20160816; b=VNQgyUvCP1OhWjhOwypj8KrL6YCzUCQke90oo7fj8dwbMIAhdq+kv1SeCnYhjpPm3B TgpdX/VSmv11amZrR3jzc/xAlAeRSr4Guv1AZv5xX1ITzoAz7FxrOV9Ma6RtdO0Lng4N J1todVNS3OgXGkfeZvQjvTm78BLC9FPE1SvkLYvxmJ2gj0B0UIdRkq9WcY2vthpMPcET grP8Ph+aJBPfpj0LIhGyMN34tEmELWK4DdfxgpO+UUPaqiVnUmM1UPO20tIxgQfD5l+N qidsGEweVSXlIUQk5KZm1hzLmQ5IfTjU+DAArUALdLOS67V10C9umUxhKoKetVeGTS3Y MLpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BvgM4m2pXG/PIUkUjK73FJ7j4ardNCogAkvXuK07AJc=; b=oQwGoQT0OwLXDVQbnxoTcV0aFnTdFSTqn6srhMFguQU3hL9SMbzNZaQaITd0ST9yh4 RZTjcjD2R8Jmd+yX/YVe+vLspMuLsjqMoFLMwIj0k52IHo0zd+nqJE+WNfbd+2WbsZV0 9KCNPdj6D2WUiTgUVkZJQTnBoMEiXkVO1PgJQEr/o+zogHS80WAP2rIhajDPGo1PyoqK zOi1fdk4MgrFkk4eemGZT8/hiEurCuMYBvMMTJwHA24xntAsqRiP5XDQG5c4+2Gcv53M GzWERAgeFy6R8wbLhHPn+BeetbZnmj+hx3f1j4L7HJAqy1WjjeClxIPuZDjAVeFCIPVo aepg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PeeFov8q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s30si433594pgm.37.2021.09.28.14.37.30; Tue, 28 Sep 2021 14:37:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PeeFov8q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242947AbhI1Vht (ORCPT + 99 others); Tue, 28 Sep 2021 17:37:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242934AbhI1Vhr (ORCPT ); Tue, 28 Sep 2021 17:37:47 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C54B9C06161C for ; Tue, 28 Sep 2021 14:36:06 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id m26so154689pff.3 for ; Tue, 28 Sep 2021 14:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BvgM4m2pXG/PIUkUjK73FJ7j4ardNCogAkvXuK07AJc=; b=PeeFov8qVje38hwQE1/feYtxaMpRkaXGWrx5zgYmfRhTQa8AbjATUWcYuE4sNTy0jc NzTMXMdnRkmlW7O8FqV/jpXabij0r1eBzE1+47CCs2eRykDvxNMvVT62RAW5lSmIO8de qpcOP5VzseHI2aOAYmtEvQyxXOcmwqewSG+gs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BvgM4m2pXG/PIUkUjK73FJ7j4ardNCogAkvXuK07AJc=; b=nKoGZ6WUUngiaQtIryDbeZAwqOwcNa5tDCfUIUbPnBtgGBzHKoqc4HeyD3b65bODSq E5P8fsSa8z8HLLOhtSOEVNuxDZsdl8ckeCmVhJvtyF7UuUTKlHjIBM/b9aLFmVFv1FOC GxaywQ+d06WJtyF290GP4SzMHWknoz639vggxfjwUMDya5YYyE9MHzCFB0Qhmk+NQvcn 3cpPgcHLri1Bqj7rHykZyWt9+gcbdx6aZZi4osO+u0O2uQNeEWuzbsqZ2RDsIY00dGjV eSiKMJf7YV+NjFhAAiwkYmbujfFyfjr//A9dzyslDR9Bq7SamnvdiEggiHyEHp+KUKCk sUlA== X-Gm-Message-State: AOAM530Z0sNgyMLdvA9iy2s/gs7yQPDbdeXh0rqB7xbLT6e5fxyo7ZYe UqnAEchG64WEmYE02hLjOGcKCA== X-Received: by 2002:a62:7a4f:0:b0:448:6a41:14bb with SMTP id v76-20020a627a4f000000b004486a4114bbmr7479777pfc.31.1632864966354; Tue, 28 Sep 2021 14:36:06 -0700 (PDT) Received: from localhost ([2620:15c:202:201:d7ca:580:94ab:8af8]) by smtp.gmail.com with UTF8SMTPSA id q19sm105131pgn.81.2021.09.28.14.36.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Sep 2021 14:36:05 -0700 (PDT) From: Brian Norris To: =?UTF-8?q?Heiko=20St=C3=BCbner?= Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Sandy Huang , Chen-Yu Tsai , Thomas Hebb , Brian Norris , aleksandr.o.makarov@gmail.com, stable@vger.kernel.org, =?UTF-8?q?N=C3=ADcolas=20F=20=2E=20R=20=2E=20A=20=2E=20Prado?= Subject: [PATCH v3 1/4] drm/rockchip: dsi: Hold pm-runtime across bind/unbind Date: Tue, 28 Sep 2021 14:35:49 -0700 Message-Id: <20210928143413.v3.1.Ic2904d37f30013a7f3d8476203ad3733c186827e@changeid> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog In-Reply-To: <20210928213552.1001939-1-briannorris@chromium.org> References: <20210928213552.1001939-1-briannorris@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In commit 43c2de1002d2, 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: Cc: Signed-off-by: Brian Norris Tested-by: NĂ­colas F. R. A. Prado --- (no changes since v2) Changes in v2: - Clean up pm-runtime state in error cases. - Correct git hash for Fixes. .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c index a2262bee5aa4..45676b23c019 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c @@ -773,10 +773,6 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) 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, @@ -795,20 +791,10 @@ static void dw_mipi_dsi_encoder_enable(struct drm_encoder *encoder) 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, @@ -938,10 +924,14 @@ static int dw_mipi_dsi_rockchip_bind(struct device *dev, 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; } /* @@ -953,7 +943,7 @@ static int dw_mipi_dsi_rockchip_bind(struct device *dev, 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); @@ -965,16 +955,23 @@ static int dw_mipi_dsi_rockchip_bind(struct device *dev, 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, @@ -989,6 +986,10 @@ static void dw_mipi_dsi_rockchip_unbind(struct device *dev, 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 = { -- 2.33.0.685.g46640cef36-goog