From patchwork Wed Sep 22 12:54:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12510603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 669EDC4332F for ; Wed, 22 Sep 2021 12:59:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 318CC61181 for ; Wed, 22 Sep 2021 12:59:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 318CC61181 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=c2GdUuVTssvCwhJViz3EsXyPFfv582exreVemZ8utKg=; b=Bn/C1EiMdRwIh2 e4T0soNpOEBniDP6iwbUqMxTjvNM2gMKAnCbsTiYRuXjYd+1Lbe99SeQr+i3h5EpdS8ozHeK2bfz/ Zjn+Q8YFeafQsuRocYdNlRVEnN5qKEWlah6JRBoAH0c74LqBws76REu2Tg4N/VCuZIxmzWCOowV5u 0mXJmLJ6H+4cu6SYAKKrMULg4afxMLrRCbjmZBHQArTFK+8LLNqUbSZhypIvGN3eLmro8RZWGaCHE HKpH9XJefjtGky0DTk+3WlwjYm4PEJDem1XtXXrSKpjKVaz4jiYUQeSxJ4ZcxJ5grm4PDVDLRZHo5 F7wwNTe0muSwoIe0eRjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mT1oZ-008THo-8Y; Wed, 22 Sep 2021 12:57:32 +0000 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mT1le-008S7u-7b; Wed, 22 Sep 2021 12:54:31 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.west.internal (Postfix) with ESMTP id C8B0F2B015E6; Wed, 22 Sep 2021 08:54:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 22 Sep 2021 08:54:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=mct8oUUoPQCmb XzWWfTX5bHQO1PQnsAmowWUCVA6sbM=; b=kPF2S1eZC/yeq7ngJhq+C5+2SGDMc 6g4R1BAPfpAat8lECFY5Qkoq65WHuTO4E9HX6wzqtzj7+ox3OBgqrBqJ/T3b8A5e YF/1b8e9aNnEFQ8TqltOXD3/V9EowkY0/51V3bT0fLv3S6kreDMiWHYPiP1nZw9L RLwvioBr+1SE8H3YchGUGW3p6JO1Cgm2Fog8Y3OIAiy6zb6zWHXEmp8L16CNAQBh vk/zMEcmZ9yO50LS4ngIOh1Zm0A9cliUHFPRn26rG0ndnhGpf3oTfHq7V7SR4i1M BfmrwlDPXF6Ue84DaTvUMHbS3+54opSA4lpCNoksBRbmnW+QBbCqCsU8Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=mct8oUUoPQCmbXzWWfTX5bHQO1PQnsAmowWUCVA6sbM=; b=DN6t97Tw jSFK2L1Ng+NOpe/Ux3Nfrhg911RsZFPi5WMrMM948WsA/MdHOePn22GLZtktEoN5 yp/6eDN3XI3krIVZFZKEHxnOw+PaE7b7+pe4oZ5QJ/kG+ki1w8sMytUUE1cQGxGf Wau11+mkxauchihXfXmrq9t+ARPJ8vr4ScdI5aJ0nMx9PMlDtPOaouycXxJpzPxH /8QtimTVWDikFMxhNvFE0iilOKSll7dm7BxzwGiE+32/e2xf5fc3Gf7lqvpCObj/ 8beVmUwFb0na+XbUrFkZnnSbQJmISEzrkjDynGnYwfUcZKifY+aLzZWYHtImHaui gM8setN182W/YQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudeijedgheeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Sep 2021 08:54:27 -0400 (EDT) From: Maxime Ripard To: Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Daniel Vetter , David Airlie Cc: linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Mike Turquette , Stephen Boyd , Nicolas Saenz Julienne , Florian Fainelli , Michael Stapelberg , Linus Torvalds Subject: [PATCH 1/5] clk: bcm-2835: Pick the closest clock rate Date: Wed, 22 Sep 2021 14:54:15 +0200 Message-Id: <20210922125419.4125779-2-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210922125419.4125779-1-maxime@cerno.tech> References: <20210922125419.4125779-1-maxime@cerno.tech> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210922_055430_341183_E3F19928 X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The driver currently tries to pick the closest rate that is lower than the rate being requested. This causes an issue with clk_set_min_rate() since it actively checks for the rounded rate to be above the minimum that was just set. Let's change the logic a bit to pick the closest rate to the requested rate, no matter if it's actually higher or lower. Fixes: 6d18b8adbe67 ("clk: bcm2835: Support for clock parent selection") Signed-off-by: Maxime Ripard Reviewed-by: Nicolas Saenz Julienne Tested-by: Nicolas Saenz Julienne # boot and basic functionality Acked-by: Stephen Boyd --- drivers/clk/bcm/clk-bcm2835.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index a254512965eb..bf97b2b2a63f 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -1216,7 +1216,7 @@ static int bcm2835_clock_determine_rate(struct clk_hw *hw, rate = bcm2835_clock_choose_div_and_prate(hw, i, req->rate, &div, &prate, &avgrate); - if (rate > best_rate && rate <= req->rate) { + if (abs(req->rate - rate) < abs(req->rate - best_rate)) { best_parent = parent; best_prate = prate; best_rate = rate; From patchwork Wed Sep 22 12:54:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12510605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F06DC433EF for ; Wed, 22 Sep 2021 13:00:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4855D61181 for ; Wed, 22 Sep 2021 13:00:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4855D61181 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=o85intdQhO+vnjYLpLEM2vciq2pt+ui/W9BLFaA/rBY=; b=sT0aRqftYU2zYm ymLRZ+5CC1bET4pkqYJEisKwP5xhSScAYIg9YsvhT7vhBDG9VJashBFESIAHo9kNkpjIcAGqnuenY CzpOjw96IofOeV6NCZMJ53YBX5yeNcWivQzah8boAgShXBEynce0TIbqkke9snf/o3zwhf6cSJUs/ 1bIcteVKUm7EABIb5uLhas7rJ0+DZsc1NjR+NAnn68MnT01Vo1cOmJBMv+xO7hHO7iddP6zhTZJEU acGEIIvrARKy4izUWi9HqySqFYbZ95oZGNfsGPsMlXFmTPkpA8w3OlfQTuwkYKuyyHbeD2y/oypIR sJtkWRcHRT/PIttiOgSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mT1pm-008ThY-Hy; Wed, 22 Sep 2021 12:58:50 +0000 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mT1lh-008SA1-IA; Wed, 22 Sep 2021 12:54:35 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.west.internal (Postfix) with ESMTP id 210B82B015E3; Wed, 22 Sep 2021 08:54:32 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 22 Sep 2021 08:54:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=+VQJ1qYl9kyaC FZ/5gVwTnLYe2FgtAOmnjOeyAZZK+U=; b=Vz4YqM9th7Z8btkrBP/p7azTBzutJ bH7yQ3YzfvBNRxLVCXOd9b3s2BkYCVpu29PdjIoU67yAZZ3cI6phfAoj+e0CU/Ry bMtX3SNSqHZOQPqYkOtsGXCUwk75+S28L9xajb0y7SNZ+yUiKG26cTgyWSw7P1fL Un5tASKgvUMDxqyx0AFGtK+DqIHD/BmqyRt24jYsRHZv41AXrMa39jR/LqACjWGG u7VVbXfidXMvHWhnvCQ6x39hMjmMiqNe8UP2K+mpjdYbikCL7M6SHXslscagSYmW /YB8p9GtD1A9K9zSv6GdGaSx+Qocq4fO3oTV8ANl9L6ZTO+l279FXOLSw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=+VQJ1qYl9kyaCFZ/5gVwTnLYe2FgtAOmnjOeyAZZK+U=; b=pZjKibEi QOIqeSrzP8z6t+kE8XdxfwcfXw57igiwFN+rJL0tQdBAXMzodGKso4Yvd9UwKWDt nHECACDZctEY5y/Ks1Hy5tIrX4xZotYwSX0e7gQIVYXOLe5HfuvxAZ6xK7spwng8 MoY8NN3KcQm5LBra3+xz2bj5cJYAqp6XJatmGqXiUuIHN1Elfhbl467paYLLh84B 3J92k6DWuPWJpx/joXR1ZqlPCLzBx2AxRKQi1B0PcMboEB2kHCfClSjrZKBxgdHs bdxT08N3QBKf1YKNgI6afBcQp1PLjcV0UQdK0fe4bWohq68FkezzcCXm59rBCIbN kEIJwLykZ8XVuA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudeijedgheeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Sep 2021 08:54:31 -0400 (EDT) From: Maxime Ripard To: Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Daniel Vetter , David Airlie Cc: linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Mike Turquette , Stephen Boyd , Nicolas Saenz Julienne , Florian Fainelli , Michael Stapelberg , Linus Torvalds Subject: [PATCH 2/5] clk: bcm-2835: Remove rounding up the dividers Date: Wed, 22 Sep 2021 14:54:16 +0200 Message-Id: <20210922125419.4125779-3-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210922125419.4125779-1-maxime@cerno.tech> References: <20210922125419.4125779-1-maxime@cerno.tech> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210922_055433_681134_D53F4208 X-CRM114-Status: GOOD ( 14.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The driver, once it found a divider, tries to round it up by increasing the least significant bit of the fractional part by one when the round_up argument is set and there's a remainder. However, since it increases the divider it will actually reduce the clock rate below what we were asking for, leading to issues with clk_set_min_rate() that will complain that our rounded clock rate is below the minimum of the rate. Since the dividers are fairly precise already, let's remove that part so that we can have clk_set_min_rate() working. This is effectively a revert of 9c95b32ca093 ("clk: bcm2835: add a round up ability to the clock divisor"). Fixes: 9c95b32ca093 ("clk: bcm2835: add a round up ability to the clock divisor") Signed-off-by: Maxime Ripard Reviewed-by: Nicolas Saenz Julienne Tested-by: Nicolas Saenz Julienne # boot and basic functionality Acked-by: Stephen Boyd --- drivers/clk/bcm/clk-bcm2835.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index bf97b2b2a63f..3667b4d731e7 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -932,8 +932,7 @@ static int bcm2835_clock_is_on(struct clk_hw *hw) static u32 bcm2835_clock_choose_div(struct clk_hw *hw, unsigned long rate, - unsigned long parent_rate, - bool round_up) + unsigned long parent_rate) { struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw); const struct bcm2835_clock_data *data = clock->data; @@ -945,10 +944,6 @@ static u32 bcm2835_clock_choose_div(struct clk_hw *hw, rem = do_div(temp, rate); div = temp; - - /* Round up and mask off the unused bits */ - if (round_up && ((div & unused_frac_mask) != 0 || rem != 0)) - div += unused_frac_mask + 1; div &= ~unused_frac_mask; /* different clamping limits apply for a mash clock */ @@ -1079,7 +1074,7 @@ static int bcm2835_clock_set_rate(struct clk_hw *hw, struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw); struct bcm2835_cprman *cprman = clock->cprman; const struct bcm2835_clock_data *data = clock->data; - u32 div = bcm2835_clock_choose_div(hw, rate, parent_rate, false); + u32 div = bcm2835_clock_choose_div(hw, rate, parent_rate); u32 ctl; spin_lock(&cprman->regs_lock); @@ -1130,7 +1125,7 @@ static unsigned long bcm2835_clock_choose_div_and_prate(struct clk_hw *hw, if (!(BIT(parent_idx) & data->set_rate_parent)) { *prate = clk_hw_get_rate(parent); - *div = bcm2835_clock_choose_div(hw, rate, *prate, true); + *div = bcm2835_clock_choose_div(hw, rate, *prate); *avgrate = bcm2835_clock_rate_from_divisor(clock, *prate, *div); From patchwork Wed Sep 22 12:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12510607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A483C433F5 for ; Wed, 22 Sep 2021 13:02:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 617B3611C0 for ; Wed, 22 Sep 2021 13:02:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 617B3611C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8GUIydYlF695OTX7Mwl5yYXmTZJU/H3i+lwicH92duQ=; b=GnwFocLSkaHAK+ E3iQJ9lByeO4F5Ph8GqnUIJmcI+L26rmsFvLRRXe6VfMw0HgUdAMaeMg44CV34TiPnRXxqqfnwaJb 3MmK/XYMESsR6AUON312Sb1M4nsNVgawq/XORmB79P7j9uuXmKSgON8IYEpP/+P8Q/EppFHKY6dqW 7ZcPAm2A4f32VJ70UKhCeLdyFox+Ob8XeDFjRLE6Mc83V7UJigQt6nd/5WB0gkVjO8QNpf7zk/l2v 73Nx2ZNqNA1SQze5KwjTkIOMFG6/08OzNxGBM5ugNEYUPYRATL+DvABy6cNi0bUfT1fJj7QSfKG6J MDDXxTvOQ1ngsJ0n6DCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mT1qy-008UEf-78; Wed, 22 Sep 2021 13:00:00 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mT1lm-008SBe-C0; Wed, 22 Sep 2021 12:54:39 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailnew.nyi.internal (Postfix) with ESMTP id C2BB2580460; Wed, 22 Sep 2021 08:54:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 22 Sep 2021 08:54:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=4e/P9dQE+b90j QHmfImUYpGrWO8DGPe+LWkJUYv0Syw=; b=xbhnSNp5VUssGFsGthY3KwxtjkejP iTroEfJAsRysfHcmp4ShTRd1lEU3DD3Za8LgTNdOcSlmY/3d0Zl+gyppTZQ8N+h5 8z4M5bqm7WuecVC9zsUPFU0NATPF5+LURdlzDNCEPDTV6bA/SvJFjmt87HlAvScE 2iuOpjMHQEc5nE0MSd3QeZSvKK6qDCIzSDtQEfmmDsG19gdrSzyovEnG9b+64wwe mbglJLG1gWITR8yw1u+8T+XvXMqMV+rj/NQYF1Y0O+2KZAdk6t7mIrQzJFjVLQWQ Llx1ErzMwYvHd1EOT0TNS764rYTs2tItwM0/hKSk84J7mYDBnDiTbz5mw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=4e/P9dQE+b90jQHmfImUYpGrWO8DGPe+LWkJUYv0Syw=; b=ocnNNTxe zCyItCVcjJj9253OhYSTnswwP8TW2lJiz9LzfcLcQmteqewqlLk9jP3NoqPhUGyH UY3BgHKASmEenb7Uek/jQtoTxHicLFoTTV7X2L9a0PCCCohZvW5ts8lCNQWTRy0u T7CdmWokwHohjpeiGenYNt/vqXt1PiPdux8ZcUvsMhbZz7BJYgi25m361e3ul6+o B1A5zP+ZXOg7utysPXTP3muhHXI36oavBeYTG206/ujstoWGqdZoBzgrD6iLRe0A frluPW+HyNrohhoLL/+19ZenXKTPmBAtE1HyX2wyMUR0znFCvuPwiYTjnTUKaQA4 ajUAawHrpvBlMQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudeijedgheeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Sep 2021 08:54:34 -0400 (EDT) From: Maxime Ripard To: Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Daniel Vetter , David Airlie Cc: linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Mike Turquette , Stephen Boyd , Nicolas Saenz Julienne , Florian Fainelli , Michael Stapelberg , Linus Torvalds Subject: [PATCH 3/5] drm/vc4: hdmi: Set a default HSM rate Date: Wed, 22 Sep 2021 14:54:17 +0200 Message-Id: <20210922125419.4125779-4-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210922125419.4125779-1-maxime@cerno.tech> References: <20210922125419.4125779-1-maxime@cerno.tech> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210922_055438_519440_DD80CC41 X-CRM114-Status: GOOD ( 12.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When the firmware doesn't setup the HSM rate (such as when booting without an HDMI cable plugged in), its rate is 0 and thus any register access results in a CPU stall, even though HSM is enabled. Let's enforce a minimum rate at boot to avoid this issue. Fixes: 4f6e3d66ac52 ("drm/vc4: Add runtime PM support to the HDMI encoder driver") Signed-off-by: Maxime Ripard Reviewed-by: Nicolas Saenz Julienne Tested-by: Nicolas Saenz Julienne --- drivers/gpu/drm/vc4/vc4_hdmi.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index b4b4653fe301..74222b12f8c8 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -94,6 +94,7 @@ # define VC4_HD_M_SW_RST BIT(2) # define VC4_HD_M_ENABLE BIT(0) +#define HSM_MIN_CLOCK_FREQ 120000000 #define CEC_CLOCK_FREQ 40000 #define HDMI_14_MAX_TMDS_CLK (340 * 1000 * 1000) @@ -2169,6 +2170,19 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) vc4_hdmi->disable_4kp60 = true; } + /* + * If we boot without any cable connected to the HDMI connector, + * the firmware will skip the HSM initialization and leave it + * with a rate of 0, resulting in a bus lockup when we're + * accessing the registers even if it's enabled. + * + * Let's put a sensible default at runtime_resume so that we + * don't end up in this situation. + */ + ret = clk_set_min_rate(vc4_hdmi->hsm_clock, HSM_MIN_CLOCK_FREQ); + if (ret) + goto err_put_ddc; + if (vc4_hdmi->variant->reset) vc4_hdmi->variant->reset(vc4_hdmi); From patchwork Wed Sep 22 12:54:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12510629 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A945DC433F5 for ; Wed, 22 Sep 2021 13:03:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7C07F611C0 for ; Wed, 22 Sep 2021 13:03:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7C07F611C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Nq0hAe3/jRkVPlJcitrkMLKdcPk7ddmtm49A3A5r2Jg=; b=Zl0chu7Qrcu8AC O4yf9KjN+31mzcDeiIRbpGM0CnxbAPlLRwEwXMCyGjJpkrgEdWbKy4YKOi9RnhcRIH/McDKsgDKzg tPaA+Ua/TfxdZ5MFNNlTWq0SbZJcGSchYrPMYJtkDKaXSclUCQrb11qyIBC66DhhagAXLXKDLSqQY 3Kk/wpdsbPjA0MaYB6liLGmDS1P/0p6/IOn+DsJBBdfmHyAJFYfuvS62lpvU612guWiruIeIqsAkM Gvtv4KZypk4L1s4gu/70Ojjsn0qzjBdatqoclP0UgTSOWYyuq64lTNTOT00PU2ShCeWYnZvfK+11R /eFpXETjHmydjnfGt5Mg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mT1rr-008UaU-JC; Wed, 22 Sep 2021 13:00:57 +0000 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mT1lo-008SD4-BE; Wed, 22 Sep 2021 12:54:42 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id EA4C52B015E3; Wed, 22 Sep 2021 08:54:38 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 22 Sep 2021 08:54:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=8/Bpu9acEXldv a+wZpg5ifbt3qvSfup55XXA8eYcvds=; b=su9z6mk+4SElcMYFRCSTwtT95CrRw VldVXOTdHKJbTmWKCu4ySSPtkqRKuRlhH/0T/DXzf3SGG3dbJqyAiSc3WpHng2P7 8k0EaEMGG9kBAVHQla8mCevFyn0AKM8Xy7zLV0anXTa4Y+xNzsiSvVVYmrRIBzIp vPp0ADsABgr2nXu15diV05BGPLhiCEO7avZdcv1NNF+Yth7FOMsfm+0uITIwQz2f lzy2LjHMB1qAicw8GQYFSuYveJbaRE5E4K9qW2oMzAQxzTFv54dU9oF7+wtQFQrQ brUT+FtCIEEQU+CS5kpI3beY3XkSY5iNQQQ8VPVS15bRieFA20wt7TWDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=8/Bpu9acEXldva+wZpg5ifbt3qvSfup55XXA8eYcvds=; b=M4PQbjds Ooq4L6nbPNXz776XHgRAgs3A1qlIjFTFvEITcJDvEgT7igQZY8yVh4bS4Z9ZlHHA lSTVf1oj1qAsDOBVfBM+bcTgrDuk8Afee4gH24I1rumlI/VyoNMWM5YD77gIZwBm 9VTXPc/DoEnHa2DY/vN+C/bIgySml+0TmdwPerc8MCPWhmeW1VO0K7xzFK88FzRc F2PdTBCII89yyAdUGnTo3I/5WkXd5AsTW8zU8OyE5VRGnpYsTeKjY2oOGPdEqGBH e4rZVpgO5qEPWp5qZGOwPvKJeQ+1rIis4WDQ55NiOYGJftbptpsE36vKun3M5LAm GIlloPcVV2rEgQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudeijedgheejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Sep 2021 08:54:36 -0400 (EDT) From: Maxime Ripard To: Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Daniel Vetter , David Airlie Cc: linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Mike Turquette , Stephen Boyd , Nicolas Saenz Julienne , Florian Fainelli , Michael Stapelberg , Linus Torvalds , Dave Stevenson Subject: [PATCH 4/5] drm/vc4: hdmi: Move the HSM clock enable to runtime_pm Date: Wed, 22 Sep 2021 14:54:18 +0200 Message-Id: <20210922125419.4125779-5-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210922125419.4125779-1-maxime@cerno.tech> References: <20210922125419.4125779-1-maxime@cerno.tech> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210922_055440_516281_E6C9C9D6 X-CRM114-Status: GOOD ( 17.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In order to access the HDMI controller, we need to make sure the HSM clock is enabled. If we were to access it with the clock disabled, the CPU would completely hang, resulting in an hard crash. Since we have different code path that would require it, let's move that clock enable / disable to runtime_pm that will take care of the reference counting for us. Since we also want to change the HSM clock rate and it's only valid while the clock is disabled, we need to move the clk_set_min_rate() call on the HSM clock above pm_runtime_get_and_sync(). Fixes: 4f6e3d66ac52 ("drm/vc4: Add runtime PM support to the HDMI encoder driver") Signed-off-by: Maxime Ripard Reviewed-by: Dave Stevenson Reviewed-by: Nicolas Saenz Julienne Tested-by: Nicolas Saenz Julienne --- drivers/gpu/drm/vc4/vc4_hdmi.c | 72 ++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 74222b12f8c8..630b84ab73a2 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -628,7 +628,6 @@ static void vc4_hdmi_encoder_post_crtc_powerdown(struct drm_encoder *encoder, vc4_hdmi->variant->phy_disable(vc4_hdmi); clk_disable_unprepare(vc4_hdmi->pixel_bvb_clock); - clk_disable_unprepare(vc4_hdmi->hsm_clock); clk_disable_unprepare(vc4_hdmi->pixel_clock); ret = pm_runtime_put(&vc4_hdmi->pdev->dev); @@ -894,28 +893,10 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder, conn_state_to_vc4_hdmi_conn_state(conn_state); struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); - unsigned long bvb_rate, pixel_rate, hsm_rate; + unsigned long pixel_rate = vc4_conn_state->pixel_rate; + unsigned long bvb_rate, hsm_rate; int ret; - ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev); - if (ret < 0) { - DRM_ERROR("Failed to retain power domain: %d\n", ret); - return; - } - - pixel_rate = vc4_conn_state->pixel_rate; - ret = clk_set_rate(vc4_hdmi->pixel_clock, pixel_rate); - if (ret) { - DRM_ERROR("Failed to set pixel clock rate: %d\n", ret); - return; - } - - ret = clk_prepare_enable(vc4_hdmi->pixel_clock); - if (ret) { - DRM_ERROR("Failed to turn on pixel clock: %d\n", ret); - return; - } - /* * As stated in RPi's vc4 firmware "HDMI state machine (HSM) clock must * be faster than pixel clock, infinitesimally faster, tested in @@ -939,10 +920,21 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder, return; } - ret = clk_prepare_enable(vc4_hdmi->hsm_clock); + ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev); + if (ret < 0) { + DRM_ERROR("Failed to retain power domain: %d\n", ret); + return; + } + + ret = clk_set_rate(vc4_hdmi->pixel_clock, pixel_rate); if (ret) { - DRM_ERROR("Failed to turn on HSM clock: %d\n", ret); - clk_disable_unprepare(vc4_hdmi->pixel_clock); + DRM_ERROR("Failed to set pixel clock rate: %d\n", ret); + return; + } + + ret = clk_prepare_enable(vc4_hdmi->pixel_clock); + if (ret) { + DRM_ERROR("Failed to turn on pixel clock: %d\n", ret); return; } @@ -958,7 +950,6 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder, ret = clk_set_min_rate(vc4_hdmi->pixel_bvb_clock, bvb_rate); if (ret) { DRM_ERROR("Failed to set pixel bvb clock rate: %d\n", ret); - clk_disable_unprepare(vc4_hdmi->hsm_clock); clk_disable_unprepare(vc4_hdmi->pixel_clock); return; } @@ -966,7 +957,6 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder, ret = clk_prepare_enable(vc4_hdmi->pixel_bvb_clock); if (ret) { DRM_ERROR("Failed to turn on pixel bvb clock: %d\n", ret); - clk_disable_unprepare(vc4_hdmi->hsm_clock); clk_disable_unprepare(vc4_hdmi->pixel_clock); return; } @@ -2107,6 +2097,29 @@ static int vc5_hdmi_init_resources(struct vc4_hdmi *vc4_hdmi) return 0; } +#ifdef CONFIG_PM +static int vc4_hdmi_runtime_suspend(struct device *dev) +{ + struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); + + clk_disable_unprepare(vc4_hdmi->hsm_clock); + + return 0; +} + +static int vc4_hdmi_runtime_resume(struct device *dev) +{ + struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(vc4_hdmi->hsm_clock); + if (ret) + return ret; + + return 0; +} +#endif + static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data) { const struct vc4_hdmi_variant *variant = of_device_get_match_data(dev); @@ -2374,11 +2387,18 @@ static const struct of_device_id vc4_hdmi_dt_match[] = { {} }; +static const struct dev_pm_ops vc4_hdmi_pm_ops = { + SET_RUNTIME_PM_OPS(vc4_hdmi_runtime_suspend, + vc4_hdmi_runtime_resume, + NULL) +}; + struct platform_driver vc4_hdmi_driver = { .probe = vc4_hdmi_dev_probe, .remove = vc4_hdmi_dev_remove, .driver = { .name = "vc4_hdmi", .of_match_table = vc4_hdmi_dt_match, + .pm = &vc4_hdmi_pm_ops, }, }; From patchwork Wed Sep 22 12:54:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12510631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A154FC433F5 for ; Wed, 22 Sep 2021 13:04:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6D4FA611C0 for ; Wed, 22 Sep 2021 13:04:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6D4FA611C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uJTjLssgvtvkRDsOpE5Z8p2hK59PQIgtu9pJhWsP2f8=; b=fW6fopMcg7JO0p wMcdDsLsqlmeAhjhKY/mT0ACubF16ApD1cbjPqVphsS76sw2OvmOxlg9NrHUZiR0i1IcsomZ/Qhh4 o9D2NuotnMzhkgHORo3t7x9ASTFc74Y43UxI6017QzyH4zho0aUeYAY43cm1nO6Fts9nbNhsUJ1EM bAxDiGqeSjH/Mr7Rs60lVe4rDqFPEMFVjIDqnAJUmeLbxUX9WuahisFQYxNUUcIa1OPT41Wx2UOHA 7IdJ6bcxL6dkRMYs7Dxzp/O6wJi/9yPW0sXJGi7h7OCUv4rX3GvOZWYAWgHX5VN23PB9qJkOWdFan QzxbagvaE5kLxEI6eJUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mT1sq-008Uwa-8A; Wed, 22 Sep 2021 13:01:57 +0000 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mT1lr-008SEF-Q6; Wed, 22 Sep 2021 12:54:45 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id 61D722B015E3; Wed, 22 Sep 2021 08:54:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 22 Sep 2021 08:54:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=/i2wIOW8fG63Q +xqJpbK2PRWLCguAPaHH1zfAMA+Z2g=; b=et5KajvVXSLjYc0w39FhVvyrcYBuf 2CpC9e58Ine7wjkWb9o2lPvQlsnxhsy4naoRM3rX3VuGF03V7rW9P5+uKV9bf7X8 ZvgRwxuYEX10jEX1i60jDIxX40sLdXyQNdqHWGacnv8k9An4coIPmM4QlFVSjnU4 khWug5WBYCzBDYeWCoY1eSPUkCqooB2Qry2mBzaK9LZRI14TfFxLDBpPmHjJIFP9 xwwbulmQhQwLnXAMiavnnGlmPThsEdOBFMm4qw3xGHzuJmfkBdHUtMco2Fd7SgSv jNnteCch2lfmS7DW5ZP0W0C1YOTfapVkKDTnwzFcHl4yvpWc5Vu5LeM+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=/i2wIOW8fG63Q+xqJpbK2PRWLCguAPaHH1zfAMA+Z2g=; b=qWbANZJB KvPmz172JXRBJQPkJJVfpzxMpMlcz7++0tcme5yY/YSV95ixoA+xfI29zqFGyiZR l523IzmZ2Y/XvLF7N8bGjqfa6OD25aywEKAYC+UHRQ8iGAQ7uAdJUzOm+44Yy1ab o7+SWyJDXbEDQslvCs82e27yy+0+zAciYwU0EDlnZS9OwM2SZ9IQlOFWdZdUfl1V seDAEA2U5OULoaGZ2EQfJrSvSjdaVWRkBHt9jPtGKZVTGWdL1iiRZPZKqIX4lVzs nsLaOnFcMRqKRwF+h63P9OcLlw1NoobBwO3wf4uuI+Z017RHC9FbzSAcMpXDfYDt X2i10U+t95/8aQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudeijedgheejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Sep 2021 08:54:41 -0400 (EDT) From: Maxime Ripard To: Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Daniel Vetter , David Airlie Cc: linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, Mike Turquette , Stephen Boyd , Nicolas Saenz Julienne , Florian Fainelli , Michael Stapelberg , Linus Torvalds , Dave Stevenson Subject: [PATCH 5/5] drm/vc4: hdmi: Make sure the controller is powered in detect Date: Wed, 22 Sep 2021 14:54:19 +0200 Message-Id: <20210922125419.4125779-6-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210922125419.4125779-1-maxime@cerno.tech> References: <20210922125419.4125779-1-maxime@cerno.tech> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210922_055443_958046_1D0EBB83 X-CRM114-Status: GOOD ( 10.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If the HPD GPIO is not available and drm_probe_ddc fails, we end up reading the HDMI_HOTPLUG register, but the controller might be powered off resulting in a CPU hang. Make sure we have the power domain and the HSM clock powered during the detect cycle to prevent the hang from happening. Fixes: 4f6e3d66ac52 ("drm/vc4: Add runtime PM support to the HDMI encoder driver") Signed-off-by: Maxime Ripard Reviewed-by: Dave Stevenson Reviewed-by: Nicolas Saenz Julienne Tested-by: Nicolas Saenz Julienne --- drivers/gpu/drm/vc4/vc4_hdmi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 630b84ab73a2..8e6d7e1af200 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -168,6 +168,8 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force) struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector); bool connected = false; + WARN_ON(pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev)); + if (vc4_hdmi->hpd_gpio && gpiod_get_value_cansleep(vc4_hdmi->hpd_gpio)) { connected = true; @@ -188,10 +190,12 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force) } } + pm_runtime_put(&vc4_hdmi->pdev->dev); return connector_status_connected; } cec_phys_addr_invalidate(vc4_hdmi->cec_adap); + pm_runtime_put(&vc4_hdmi->pdev->dev); return connector_status_disconnected; }