Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp778320rdb; Wed, 1 Nov 2023 02:21:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFfv21s3C/GlCkOPo85wsP/1ajvE2SAMj+n5MX8AgBElFgbPx9Q+nGa9E2KHJKpj+wTq/f X-Received: by 2002:a17:902:e846:b0:1cc:703d:20fe with SMTP id t6-20020a170902e84600b001cc703d20femr3494807plg.42.1698830498811; Wed, 01 Nov 2023 02:21:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698830498; cv=none; d=google.com; s=arc-20160816; b=d1ViK7i3ZAGZOO/0b8wyzLYZswBqRJ99ZQwtu0QtjVfwLcjSN2ltymrBBo/zNHDSWt BxODcsxapAZbG6n7Rs92Wq8WVw5EHvpntO5s755vEcZypnzZPD6tYMRd28x6n2zY7t6K 4ajFeSLE/V/gAw4wNGvXxzUggV19uJNRnWKeYu3jUfeoYmxZubkZMbrUXxCloduPiZTZ camWAq1ZJ187WIR3+tPn8dtnYPa1DxMeCuByBeaP3HqG/QdY36WJNzk+MGjjmNCOWXSM tAXqPw9jEqu1jPqmpHNvRqYPJ92bta5IOXrxy88FHb4vTHfOEOKIXJDm7CkgHNoyqoca VHQg== 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=QTE05KeiuezyEKTX9mkuL9VK77vBOJIH+1LpvM0ag34=; fh=IpenHstmzluQ2qG4rgZds4W72uLPbZNMEjQq5GLr0+k=; b=R/sGsPGfQ+A9kglI1PTnZgNY4PPDXREzAOwRrPpOKBKCEZwUSmwP+oHpncvzFjo3YZ r6rVrORHC4xO418GhTzZYok1XbaVNRSvKTyHbKASX681wY1yJUvtwcHu9uRukPr6jboS qyRxODIgcYhOtSJCXl4BEmYM+JxAfYwP3u9QLaJpxM9ixxmW2azd2FCHCSooBAVqUjvJ O+9oX/Maa1NHJhzi9dDOebYmMiqXn52dX3Z72YSxqO6v5liUV7RkSh7F9UgAMZXScUAF uvNimdFF+d26nzyZymfykR2tvTgHpK0BhOAPMtmqZU7HQMeBZAt1UhyRpean4wD4AyKi lhWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=X28UD5Bs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id s3-20020a170903214300b001c3a06b4fd7si2462980ple.561.2023.11.01.02.21.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 02:21:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=X28UD5Bs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id BAE07808494C; Wed, 1 Nov 2023 02:21:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232240AbjKAJTQ (ORCPT + 99 others); Wed, 1 Nov 2023 05:19:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234894AbjKAJTH (ORCPT ); Wed, 1 Nov 2023 05:19:07 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF9F910F for ; Wed, 1 Nov 2023 02:18:56 -0700 (PDT) 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 A4C6F1BAE; Wed, 1 Nov 2023 10:18:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698830303; bh=dkl3jtDooC1JFtaD0YoyJ131w9qjC5vo5eQl2h7Sweo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=X28UD5BsxO8OYz1iBNC/hEargVmbvL7kBwjtoMi4DnBqAbZdZszrGVIWyp4s7IAbd 1AVMmwshLM8JHaJF9zrLfFeCQiw9mP3h8QvHnB7ZqeYqMGPxhnBQd1qdX8h6NcqhVh dXK95kbx1eUUPcBu2f0noTr9DHcB7CGyqUs9AbLc= From: Tomi Valkeinen Date: Wed, 01 Nov 2023 11:17:44 +0200 Subject: [PATCH 07/10] drm/tidss: Fix dss reset MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231101-tidss-probe-v1-7-45149e0f9415@ideasonboard.com> References: <20231101-tidss-probe-v1-0-45149e0f9415@ideasonboard.com> In-Reply-To: <20231101-tidss-probe-v1-0-45149e0f9415@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 , Tomi Valkeinen X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2654; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=dkl3jtDooC1JFtaD0YoyJ131w9qjC5vo5eQl2h7Sweo=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBlQhfnclbJel7gQ5GXPPWj5UOUtsFOinZZ0pugH /NxyVI+gV+JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZUIX5wAKCRD6PaqMvJYe 9XdDD/9FXC7yP4L2ixb760gH7/wVpJyGAsTsAlYaoBTFTw5xeGwhs8RjwMtFnhLBbF5zmmMqyNF OxZnojctXWY/mBYxSHUjx/a9PELtelP094ZjhLD9EG4Ng4GiPRst8TMeE8DhioLT+b0E66EevUf /FObJE4gO2GA1AXutg7+AHqAXIoFXS5E67u4rJuRbOzbfTyOW5R/NhVp2IcCQGxMAMFcINI1/gW kKlX7uos1wVdGxsWnQkezqPjrLodBtph11X+URZvvnUlKtJDXc8+UwtJHx06axtrPHZd88NL6U/ EMmY6NQ5GHscG/6GmskW2ojmPIF1M1VyfFzFwkxt5pi95dhfOn02C8IOmyGY/tOBPWDZa237Yk7 G9xRRjuJ6jJTO/Cu6WKL0fW5HDkIA0kg3i93lvSOBHleAcvqBTo9FnvviNEPdlw+BJMbsMErdPH RFnvCGWdgEk/6F/JulnQ1UW5E9ObYsQ0RjmbmC1mO68zShNkdQ34cE+gJ9SRBRAr9QSBfF5XKHZ IbEr5z0JPIapFTgVYGFCxjXDS2rWq974WtIk/f1KBKKr7i10KU+cp/lY1omCsH1hjeGpMwWYVuL j01zWpoSgc3ciZJVzOOM3aNlZo3gABubkDqOPk2VKmhXhDJ9sC8pyCNZIvHRWWnJfHRayHKAQ2y 3uSypv0sboLvj8Q== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Wed, 01 Nov 2023 02:21:21 -0700 (PDT) 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. 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 f204a0701e9f..13db062892e3 100644 --- a/drivers/gpu/drm/tidss/tidss_dispc.c +++ b/drivers/gpu/drm/tidss/tidss_dispc.c @@ -2724,6 +2724,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; @@ -2835,7 +2878,7 @@ int dispc_init(struct tidss_device *tidss) tidss->dispc = dispc; - r = dispc_softreset(dispc); + r = dispc_init_hw(dispc); if (r) return r; -- 2.34.1