From patchwork Thu Nov 9 07:38:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 163265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp274515vqs; Wed, 8 Nov 2023 23:39:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHH7kTuuNyd+1fDNH5rUPQ+Km712C9wv2KzPYuPBmYUOacf3czUx9kV5buyBgn08TFEPEkc X-Received: by 2002:a05:6358:e499:b0:168:ea15:f193 with SMTP id by25-20020a056358e49900b00168ea15f193mr3973302rwb.23.1699515551660; Wed, 08 Nov 2023 23:39:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699515551; cv=none; d=google.com; s=arc-20160816; b=Z7XdxrRtkxs7EdFS3nEJ2gbi/8+hi+FotllnjzEjJSGty/iaPud+GcO5SOwzYmYhuz CJ2wUuboRJkyx/7Nh4Yt3GVW740p90ZFg4/lSbAhUpCAYLRroNISjHAT2sjU+mtCpSDB 4SgJuTFHY4Ahh05X+VBJ6N7hQ+gSPTjzIKuGxrSY/zY70X63uS/e3NySH0j+YBwabkNd z/DYpRj+gSeuVG+m0ug7GId/Ono1CHdro6QvSKiYwl0A1/trPyoC6ct9o29MIFSU3EY9 G40NanzPzVUB4Mli0owCuPVFua2zeaqd9pjwKT5sr+KTVyfsYF2wzpb3NcOuUYEQR4ac Nq5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Cs6aJm5nEmXcKgK3azSny1lhNdVgx61huATu38cdrVE=; fh=ar9Kuonru+6un71Fc3+cR+miWSr4t5vPPiuWh6IeKvI=; b=JG0jvAlnyEAZoQjN+rkDpvJ/H8Eh96O7fpOuOqYjc0zHb7sZE6xrSqY659jodkdRhi NsRtkdgKJeDjBfBFpcFCd8ch/LaGvL8oh6BHm0f8mPfQbTOEzyvKHAk2smsaOWphoZX4 tTiTrpWWWKthFjaXs6x/s3rAVqmC4HI1tfNzBT9jr0jeI+qs3yJjEgz+bQSR7ghPCxF0 zfTG1lHIIDFT9j4y97OBf4c4Z4PcvdJ3niTxoHKEwkyVwfDJw/T/WjtjPcustWfGEKj4 aBfdanT6jNeESq/TER0TR7xCGUlkK2V+UPSYU5tmRONE6qEwbfbOs4EMS78VVfBQOZ3F NQzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=BwTNgUW6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id o14-20020a656a4e000000b005b8f24e6526si7424096pgu.234.2023.11.08.23.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 23:39:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=BwTNgUW6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B4DED8328FC8; Wed, 8 Nov 2023 23:39:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232832AbjKIHjH (ORCPT + 32 others); Thu, 9 Nov 2023 02:39:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232970AbjKIHix (ORCPT ); Thu, 9 Nov 2023 02:38:53 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1F282D4F for ; Wed, 8 Nov 2023 23:38:51 -0800 (PST) Received: from [127.0.1.1] (91-158-149-209.elisa-laajakaista.fi [91.158.149.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E774E1BA7; Thu, 9 Nov 2023 08:38:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1699515507; bh=VyQFOHUX27qoYp+sEZHLrOOnAGthD9ucCI4/pfyGBgw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=BwTNgUW6HHSjGvrI/xQoVOgNcJJSymBeJ1IwQYT3VnMqE3zMJ28jh6WegKgj48+q0 bA8KGaYB2vUFhpfeBfBiaPrXrjZOuarBHjnkS/PCzE9OO5Pq4CBJW9QvmuOowoJncY FhE6xEDT05EBQTT4BnjG0rXjPtkeiEXAlg1ev4Vg= From: Tomi Valkeinen Date: Thu, 09 Nov 2023 09:38:01 +0200 Subject: [PATCH v2 08/11] drm/tidss: Fix dss reset MIME-Version: 1.0 Message-Id: <20231109-tidss-probe-v2-8-ac91b5ea35c0@ideasonboard.com> References: <20231109-tidss-probe-v2-0-ac91b5ea35c0@ideasonboard.com> In-Reply-To: <20231109-tidss-probe-v2-0-ac91b5ea35c0@ideasonboard.com> To: Aradhya Bhatia , Devarsh Thakkar , Jyri Sarha , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Laurent Pinchart , Francesco Dolcini , Tomi Valkeinen X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2802; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=VyQFOHUX27qoYp+sEZHLrOOnAGthD9ucCI4/pfyGBgw=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBlTIyA7lAsXjoKndhmceZLoKWYp42ow/HZpdLXl v4dYGJXejyJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZUyMgAAKCRD6PaqMvJYe 9VK0EACmedDicf6gu2jeCVhtFxLC9E7UeAPCWk8iDpU8txnM2UKnf/2Go7QKMtArXh7urR+JczJ lPIcEj+cKoKoelW+JOkyhfKtMHFknHr+0G+yMV9G0aVG6CPrN8jXKnUyUr9Rf6j0LJGYM3svaxw gUTPMrQXlwjH510BZra9/VwGvOdYT6DZK1eBfqQwVufSrIAw//M8JDnXhuBNgLNxOIoMO//SbUH 0zQwWL7Au8mypN65+rf9hoZuvJs2D6T2nenjZ/lQ26eJcvIsWefgzWjJKq3HJUdRWdHzriIlkQD Pr4MiGGXTvMlZxmXWP/jK3sHUpFm7+IjeI40nVdZ1Jg+PrzlrhrX0TfzMJpAj3XvGg3yKfeAPFE mMHfvUwDI3UL8MxSdwtjgMSd3GjFAQX2Oe9NHY0RDAiQL/SeryP9GxHM+/+VZzcV/a5u3aschyA 645hz2iFhRKX+lom9GWv5ZVe2zHl5WBI/aw0ExkpSriVkiX+usBZzBDuSlcT3GsSC8Rh2cVKQDR TK6F5pv3ddLcvg2zoqHdiLxnovgQavANTbXML4TIpZ35iqGA0MZ/iE2XGJxWcsRsd/QuFw67m0y OLfH9hQuOOxpWdB1EMpiarxQ3CWJxY/lJKuRx2KIrYVxqGzXY1ZJvv2PqoPMDW/vEspDmy843wJ 8nEq+2DvwXOJN5Q== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 08 Nov 2023 23:39:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782071219102850927 X-GMAIL-MSGID: 1782071219102850927 The probe function calls dispc_softreset() before runtime PM is enabled and without enabling any of the DSS clocks. This happens to work by luck, and we need to make sure the DSS HW is active and the fclk is enabled. To fix the above, add a new function, dispc_init_hw(), which does: - pm_runtime_set_active() - clk_prepare_enable(fclk) - dispc_softreset(). This ensures that the reset can be successfully accomplished. Note that we use pm_runtime_set_active(), not the normal pm_runtime_get(). The reason for this is that at this point we haven't enabled the runtime PM yet and also we don't want the normal resume callback to be called: the dispc resume callback does some initial HW setup, and it expects that the HW was off (no video ports are streaming). If the bootloader has enabled the DSS and has set up a boot time splash-screen, the DSS would be enabled and streaming which might lead to issues with the normal resume callback. Fixes: c9b2d923befd ("drm/tidss: Soft Reset DISPC on startup") Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/tidss/tidss_dispc.c | 45 ++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c index a5c0b72596e8..8d6ac618c539 100644 --- a/drivers/gpu/drm/tidss/tidss_dispc.c +++ b/drivers/gpu/drm/tidss/tidss_dispc.c @@ -2738,6 +2738,49 @@ static int dispc_softreset(struct dispc_device *dispc) return 0; } +static int dispc_init_hw(struct dispc_device *dispc) +{ + struct device *dev = dispc->dev; + int ret; + + ret = pm_runtime_set_active(dev); + if (ret) { + dev_err(dev, "Failed to set DSS PM to active\n"); + return ret; + } + + ret = clk_prepare_enable(dispc->fclk); + if (ret) { + dev_err(dev, "Failed to enable DSS fclk\n"); + goto err_runtime_suspend; + } + + ret = dispc_softreset(dispc); + if (ret) + goto err_clk_disable; + + clk_disable_unprepare(dispc->fclk); + ret = pm_runtime_set_suspended(dev); + if (ret) { + dev_err(dev, "Failed to set DSS PM to suspended\n"); + return ret; + } + + return 0; + +err_clk_disable: + clk_disable_unprepare(dispc->fclk); + +err_runtime_suspend: + ret = pm_runtime_set_suspended(dev); + if (ret) { + dev_err(dev, "Failed to set DSS PM to suspended\n"); + return ret; + } + + return ret; +} + int dispc_init(struct tidss_device *tidss) { struct device *dev = tidss->dev; @@ -2847,7 +2890,7 @@ int dispc_init(struct tidss_device *tidss) of_property_read_u32(dispc->dev->of_node, "max-memory-bandwidth", &dispc->memory_bandwidth_limit); - r = dispc_softreset(dispc); + r = dispc_init_hw(dispc); if (r) return r;