Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3623217pxb; Mon, 24 Jan 2022 13:45:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdwP/RzrioVQ5gsP3t+snqRjk/C8f4VfD0MH4kdlEr85h/Q69ToilyEk4ZRUTkEz9Hucfr X-Received: by 2002:a05:6a00:1a87:b0:4c4:ff65:749 with SMTP id e7-20020a056a001a8700b004c4ff650749mr15482748pfv.32.1643060625495; Mon, 24 Jan 2022 13:43:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060625; cv=none; d=google.com; s=arc-20160816; b=sZqZGN4Y2aZEdbh9gdG1YrcTdFRu+8Dx9d5kb0wll6cYQ1ZvToIYRcG1rYI9fVb0vu B7hKEEuFMHCAP0jY1teNFDD5AWcA0WfWgfKMIHcCSnny/PxEPnHhDhnkzr6quZCMd+uz xUDSmUDbo98Q8lEYCpcaG7gXJP/PTIHoCl4j6kCdjbgdIlTRBrpipXXUkJ5GCu7LDRvQ ua+RoU4InJzMWA+JnfOHAKn5UofgJFcRJb8TXUjqTEaG9LWUwLFzl3cQAFZsP/kByv86 YjWq3AOz8/6J/pxTIwoc1R9/QJlG48JpXQVjK2qqZQ0X5L+A8RO62eIBpG0yxUfU8nTR CR5g== 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=rhpsWm6k3ghbMnE67CJmIC/gg/QWmEJgNt23uwJgOyI=; b=EsuoXm/sizhjAJwM6lIQev+bT79Z5JiRNP8DGSFnvUQXOBBVBgdmPCjWjqoH4Pt8It aFEKCvvw3kURr64i2yFyEnu5Lg4ZvkjYDPYzQfdCZc8BuUNj+A/hzFpkZwb/CjViD08H 8iBsC7UgyKRaFMh/fjr9ZjSPlCkZ06uT3T+b8drbqmmPS2YOtuVNW8cR7w6gLaed1OlO r4mPOSfCKXiYkw0JJqlBmAurXQv/FWPqISyFnC+zFclHCv+j9DZpSaDmCEN3gUnQ8jm4 58bFpy6iJfQkzRAVoYlxWxj9Xgd0FbuKl/oCEkBhh5syj3lWHyjFsTIGfXWUd+v3y/zR PG/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0RS3GaUc; 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 n88si433047pji.26.2022.01.24.13.43.26; Mon, 24 Jan 2022 13:43:45 -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=0RS3GaUc; 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 S1452193AbiAXVYP (ORCPT + 99 others); Mon, 24 Jan 2022 16:24:15 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:52674 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443611AbiAXU5h (ORCPT ); Mon, 24 Jan 2022 15:57:37 -0500 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 5FD6BB8122A; Mon, 24 Jan 2022 20:57:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 798F4C340E5; Mon, 24 Jan 2022 20:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057850; bh=4+fnPt3xejjbJuigf7xg5qAXgpyUntNLIODFTb80xCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0RS3GaUcqzeqdvzzw47IByelnZXnj0XQWuKKVPdqP5piFMRJWLPE43eeqTmoJGpPA +CaqFi4Z4zfRdcWkaxQVrs+bGM58T0X5uzDCap1plJGjEGikHBBP5d5RCIeIUTZPKx M9rf+7d2iqSDo6OS1lsB6TGFklX2GM+Q49TKZYu0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Stevenson , Maxime Ripard , Sasha Levin Subject: [PATCH 5.16 0100/1039] drm/vc4: hdmi: Rework the pre_crtc_configure error handling Date: Mon, 24 Jan 2022 19:31:29 +0100 Message-Id: <20220124184128.527876920@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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: Maxime Ripard [ Upstream commit caa51a4c11f1cadba9bcf61ed9e0105711952ce7 ] 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") Link: https://patchwork.freedesktop.org/patch/msgid/20210819135931.895976-4-maxime@cerno.tech Reviewed-by: Dave Stevenson Signed-off-by: Maxime Ripard Signed-off-by: Sasha Levin --- drivers/gpu/drm/vc4/vc4_hdmi.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 29ee9264b0870..05fd54fbb773e 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -933,15 +933,16 @@ 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; } + vc4_hdmi_cec_update_clk_div(vc4_hdmi); if (pixel_rate > 297000000) @@ -954,15 +955,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) @@ -975,6 +974,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.34.1