Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3638697pxb; Mon, 24 Jan 2022 14:08:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwAaV0CYJxnvCC5y1JG+NGBaMc0v/7sPjA7DwSQ59Kz180yCKnzakEBZ+/p8nh5iVlHrvw4 X-Received: by 2002:a17:903:1107:b0:149:98f7:9629 with SMTP id n7-20020a170903110700b0014998f79629mr16052881plh.160.1643062000045; Mon, 24 Jan 2022 14:06:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643062000; cv=none; d=google.com; s=arc-20160816; b=SmLVhkCGrHCfXrirDH26rs9TrMKI5DJm1M2rAStukrFkiGRzY8aV2VESxKSQ7FYvCM 6dbtj9hMhtsD3Y84U+SteG01hkv9+AaB79F2PWDGCBL5nrf40PpejkRqSjV94iKLGLgd dIbykh7RupgMzII7P9+DZjC7A4Q587B49IGLOcWn/+N/sJqui1fEyBePficjnfp73Z5w 4dmoDClV74xqdQrpFOEUcscmZ0dLCgGBLmaGySD1LTiX/L0k6vWebVf+Qf+GQvU45qGn nlZ5dGAIo0/z9uhM8OHoOnNxpCWJnR/shL8NTsBOmnKjM+Oj5SiUNFs4yYFVJZpRg2De psLw== 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=1XExWPUX31TEewfQAGCbG56MyMPw3IZtHzoOJCKb094=; b=DCPYEQZPInELU0rgLJy2zAxKboOI8KOowc8mECFjU4PtSzuf1mS0Mi59mV7FlNb1Xk 7QyXPlZI0c/5nQKq7u0fGZIer3glxaqNOG6nZaXnHkc776InjGwprp2ByhPBFsDzYacw k7jvcV4J00cGkUF5wPDalZvtGpCc7lCA3iTo+ylcmGOMGn7/hVG3HVT9BhDuKKk7i0xB fRgNFlZ6Z3qLNx9DDBCzjYAHP8Xr2lVuhu4REpyij+Juo/vpgtZSwDUaZXfJhe5FNwe9 AErjhOWZoaEZc0pDyH/TuXX/TPZWKR24yhXMIrQrvDy4z2XgeKYcWIy65jgj1kyEDneO Br2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yQqCazad; 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 i14si14928263pgh.832.2022.01.24.14.06.28; Mon, 24 Jan 2022 14:06:40 -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=yQqCazad; 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 S1576199AbiAXVxH (ORCPT + 99 others); Mon, 24 Jan 2022 16:53:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1450608AbiAXVVC (ORCPT ); Mon, 24 Jan 2022 16:21:02 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB643C0604CE; Mon, 24 Jan 2022 12:14:20 -0800 (PST) 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 A905CB8119E; Mon, 24 Jan 2022 20:14:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D37A1C340E5; Mon, 24 Jan 2022 20:14:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055258; bh=kIFTmGOqxmq1gqY/FA6XoEWymldT6h8yR+1fDhp7Wfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yQqCazadumb/8KZzfO5y4ZR5WEeT5uT26DaaTnka/hn/lcTiYiYrrj7NKQuHYNEyU 8m+bO9+zAMO4+mOKgR0AaFty8zB2P8HOgVWlNcz7UVRZLiDwfmhNCWi0XihdTNltH8 s99tBhrM6xVDGvQHQMUR62X9i7MHuDLY5Kb3i9cc= 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.15 093/846] drm/vc4: hdmi: Rework the pre_crtc_configure error handling Date: Mon, 24 Jan 2022 19:33:30 +0100 Message-Id: <20220124184104.199473166@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 2087717f1cce9..49944644a9b36 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