Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp598185pxb; Thu, 19 Aug 2021 07:01:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypMOQVtRcul4LsMIlBzef04M/cMeR+2FfTR4eHlIkmtFH1wwC96EYZ5VfyDjDMMqZ5tI9S X-Received: by 2002:a92:c212:: with SMTP id j18mr9581757ilo.77.1629381713759; Thu, 19 Aug 2021 07:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629381713; cv=none; d=google.com; s=arc-20160816; b=PR5PsIz6bVaJ9NP/OcTqi6I2ujWtyj0C7BacrJ6nzzqVUFavLzcBCJBjhfwDbi/RBk FTA+8WXrS88zeuhStXskkX6kGcdp/0vUfm4YY9dIgECKjXbxJ9/yy38E1q19S47l5ruj LpUlVni4zK6sIfGob/JFfGhHtQ3moLYm2bv34tda+CtXvO1n2i+0/xTtt8xHEN+76Oqf zefQ+Vy/J9kiMMnVC4PAd/ffxfnIMmzf4n7qdSvm2EZk7waXkBB1JtgBTtojZhlZR7Uo u4UrJT37AUeBwEBfikO8UMxDQvW6QdDh1tecvzNI/l3z+rm2LLr8wVyHHs2vA3Ltqxkc HxVA== 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:dkim-signature; bh=B7PVCG/bjNEUBGbiDile2HwXPPbm4HndIsVkTjHJmZY=; b=YeCnjLTy59J0eVsm+pwwn6im0WuGRD+kS+4pOoMBQIOgjOkFPK4yajlr1ZhMJjoa3t zOe02j6AMfvcqU1BieZ1BIvHwTQsUzpaV4kwFE3j5pGpH3I27PNLJ7kDlMiZWkCg64tE UUjZN0E6F1HXbk7zvvm/9+2cK9SeA4DLt0a/zuMknjK1XFTVI+u8OTZ3jNwg7cQ7kDbR amu2M94/jNbPGyPa42ZaBKl6kfbkyvXGsIkx6FbnXEP+lT6951z7DNGJEdCXujQExmfq phXI/N7PetFxPqN/is9WfnMe7uAMzPkimJyBYRTBlObxi/v4LK4JDpVhPGZhxNC76z5P ASpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=tEyJoadM; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=iAz4GljU; 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=cerno.tech Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t62si103655jaa.113.2021.08.19.07.01.40; Thu, 19 Aug 2021 07:01:53 -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=@cerno.tech header.s=fm3 header.b=tEyJoadM; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=iAz4GljU; 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=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240423AbhHSOAa (ORCPT + 99 others); Thu, 19 Aug 2021 10:00:30 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:57057 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240428AbhHSOA1 (ORCPT ); Thu, 19 Aug 2021 10:00:27 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id DB3CA2B005D0; Thu, 19 Aug 2021 09:59:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 19 Aug 2021 09:59:51 -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=B7PVCG/bjNEUB GbiDile2HwXPPbm4HndIsVkTjHJmZY=; b=tEyJoadMYYS67bulDamhewQ4S+MCa wHnSaLpdPydvx+j8hPDBSR6xZLwGsKSPl2cM5KUgdxp8XmtowlUIv91XMkdpjhny nmk20Tll51EbqJBn0kB6sdMkjdn4U6rGD4MppSsZltDimRdoQ13ETHCxszFU906P yuJ5vNwHJiHiZsAZsf/wevgKhjeKEyw3dIlLYZpGRZEQUDg1WC+8IEZ+7RhQtosl qDRUeJdFdjj2K7GqsGoCtOncUG1UtUIzuQ32IsKRKMwnU8p/391L9kGOxRIujqPH H1z7lq3XgJlGZPB37Up/d+GtBYpRvZG6kOZg/K6my6fIz9MBse2mPqY3g== 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=B7PVCG/bjNEUBGbiDile2HwXPPbm4HndIsVkTjHJmZY=; b=iAz4GljU YPKcBJcAz6Q91TDmlIUDHnKboiDxoUBQ4UYJMgjc9Yn/Jfkbx36IV66yI4JnU3Nc ScBbZRnH7p9t0Hb6Wec9L60anNNEO2UzByAUy6gzpqKVhRFXpk8iVRIR8KVg+n3T R0N7pv10lvOfe8VOt8DZUduvAPNE6Am3zhRcOzfU/8SRcHtLUSnD/gnEVG7Nztm6 hOVb10CEPcq+KB521hTUYeccXRIM/JwD9rOU613Shir8IhnR/K7m6zxuyZ3/ZINj 7YamLfj9fzUkUWC+gxhl19fUU4wldiAy5osKiE1+9jnN0PRjgzKKD6xHZH4736Cp fk/GEAXvCJmfSQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrleejgdejtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrg igihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 19 Aug 2021 09:59:48 -0400 (EDT) From: Maxime Ripard To: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard Cc: linux-kernel@vger.kernel.org, Dave Stevenson , Phil Elwell , Tim Gover , Dom Cobley , Boris Brezillon , linux-rpi-kernel@lists.infradead.org, Hans Verkuil , bcm-kernel-feedback-list@broadcom.com, Emma Anholt , Nicolas Saenz Julienne , Maxime Ripard Subject: [PATCH v3 3/6] drm/vc4: hdmi: Rework the pre_crtc_configure error handling Date: Thu, 19 Aug 2021 15:59:28 +0200 Message-Id: <20210819135931.895976-4-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819135931.895976-1-maxime@cerno.tech> References: <20210819135931.895976-1-maxime@cerno.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since our pre_crtc_configure hook returned void, we didn't implement a goto-based error path handling, leading to errors like failing to put back the device in pm_runtime in all the error paths, but also failing to disable the pixel clock if clk_set_min_rate on the HSM clock fails. Move to a goto-based implementation to have an easier consitency. Fixes: 4f6e3d66ac52 ("drm/vc4: Add runtime PM support to the HDMI encoder driver") Reviewed-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_hdmi.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 5dde3e5c1d7f..8458f38e2883 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -913,13 +913,13 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder, ret = clk_set_rate(vc4_hdmi->pixel_clock, pixel_rate); if (ret) { DRM_ERROR("Failed to set pixel clock rate: %d\n", ret); - return; + goto err_put_runtime_pm; } ret = clk_prepare_enable(vc4_hdmi->pixel_clock); if (ret) { DRM_ERROR("Failed to turn on pixel clock: %d\n", ret); - return; + goto err_put_runtime_pm; } /* @@ -942,7 +942,7 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder, ret = clk_set_min_rate(vc4_hdmi->hsm_clock, hsm_rate); if (ret) { DRM_ERROR("Failed to set HSM clock rate: %d\n", ret); - return; + goto err_disable_pixel_clock; } vc4_hdmi_cec_update_clk_div(vc4_hdmi); @@ -957,15 +957,13 @@ 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->pixel_clock); - return; + goto err_disable_pixel_clock; } 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->pixel_clock); - return; + goto err_disable_pixel_clock; } if (vc4_hdmi->variant->phy_init) @@ -978,6 +976,15 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder, if (vc4_hdmi->variant->set_timings) vc4_hdmi->variant->set_timings(vc4_hdmi, conn_state, mode); + + return; + +err_disable_pixel_clock: + clk_disable_unprepare(vc4_hdmi->pixel_clock); +err_put_runtime_pm: + pm_runtime_put(&vc4_hdmi->pdev->dev); + + return; } static void vc4_hdmi_encoder_pre_crtc_enable(struct drm_encoder *encoder, -- 2.31.1