Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3603758pxb; Mon, 24 Jan 2022 13:18:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZ+9zbkSt5gfoOi8Z+iTQ7jc5HZ/RJ6dMlQrdWbmAM4tzcN1vOOUc0Rcp1Fobv5z7y7o0J X-Received: by 2002:a17:902:aa03:b0:14a:c57b:b570 with SMTP id be3-20020a170902aa0300b0014ac57bb570mr16348534plb.8.1643059087451; Mon, 24 Jan 2022 13:18:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643059087; cv=none; d=google.com; s=arc-20160816; b=Jgj2CaIEtrZbwERdbVsn5UnxGjqYpY/W54gHg6fahRwRL6bopC2SQEO4uTc16TrlqB 0vuCBcsqtMwPvywz2VHobXm3WoFyyE2fQ4peGcgV6qhvTONfb7Q4qOBf2CMo8UWD4RKc 7TlSPMcTclF1pRCWqDgn7NXDg8Wyo3T2IM1mEoR87UZ1HO+H6CcsqRIgTxygiiEWysx9 cWmoiV2BiNKk+B9pQBc0AX8Bru/NktBi04B+yOPtR6A18JunF35zRI/TfNwxihNNoxQk IAY/glBdJ+tJRY+CCYZCAOgvlRg8h/I/ujhUjJACOTSb927AdjFIriULy3LMot7zmXZp G4Ng== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=98+762IzeJxYZVqDA1r3O6eAWpVao6YXV/QpfdZimr8=; b=oKl5WZigg4zQtawRHSnPH4b23ViFj9fo3mIv7qS9ACU1vDzoqZZDYLaO7Ltf2+2jg9 C/SpET1OlK2eUKOeRKwlRfz+MYWrEMpVYeNBrP510tuIqQfIGpiZgDaSVbVKUf8Z4iNi SrbeQIt2VJFf6V3K8OChe7gjzEyPijD///l+kLun7bnTR8M+alM6N68A6dw1dn35fywe U1u+W0VAcuWQltJ7X5aY1SI/GleWlQcIxc8LnJmV6/N/24pPwT0SNHLwuRNC5OJP9BrY 68qxfg34bUZKuHB6KCoM+tDA6w4F5wdfasR6ZlIKUabKWJYlfoKn4MsO/Zg1G2PQY5IT p2yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="g9KUG/hd"; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t1si14702468pfj.309.2022.01.24.13.17.55; Mon, 24 Jan 2022 13:18:07 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b="g9KUG/hd"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352714AbiAXUyD (ORCPT + 99 others); Mon, 24 Jan 2022 15:54:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384815AbiAXUaf (ORCPT ); Mon, 24 Jan 2022 15:30:35 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16F33C07A968; Mon, 24 Jan 2022 11:43:08 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C6F79B8122F; Mon, 24 Jan 2022 19:43:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7D91C340EA; Mon, 24 Jan 2022 19:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643053385; bh=PqqgOMdQYsjVK+c5rEKxPaFKwUlR+y4hoxNyhmOITC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g9KUG/hdbiBkuL/OMM0UyxuSG5B6dZNNeEIaiMRdI1Rgh07MWzXJMUForknH2E7a9 ZO3GBGkrKyqu+iQtE5dq/WYgEfQyJQ/CDuU+mNg1rnuWvXw4E9z8rs1Rdrhr8llOd0 DB7QowVmhDgVYalPQhAIGC4dzELH8dI1SSE8xM2A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, aleksandr.o.makarov@gmail.com, Brian Norris , "=?UTF-8?q?N=C3=ADcolas=20F . =20R . =20A . =20Prado?=" , Chen-Yu Tsai , Heiko Stuebner Subject: [PATCH 5.10 048/563] drm/rockchip: dsi: Hold pm-runtime across bind/unbind Date: Mon, 24 Jan 2022 19:36:53 +0100 Message-Id: <20220124184026.078735949@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184024.407936072@linuxfoundation.org> References: <20220124184024.407936072@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Brian Norris 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: Cc: Signed-off-by: Brian Norris Tested-by: NĂ­colas F. R. A. Prado Reviewed-by: Chen-Yu Tsai Signed-off-by: Heiko Stuebner Link: https://patchwork.freedesktop.org/patch/msgid/20210928143413.v3.1.Ic2904d37f30013a7f3d8476203ad3733c186827e@changeid Signed-off-by: Greg Kroah-Hartman --- 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 @@ -753,10 +753,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, @@ -775,20 +771,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, @@ -918,10 +904,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; } /* @@ -933,7 +923,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); @@ -945,16 +935,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, @@ -969,6 +966,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 = {