From patchwork Fri Aug 16 12:32:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13766058 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 55F2FC3DA4A for ; Fri, 16 Aug 2024 12:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yVxZXuTJqaJ10E0yGjjv9nH2alidPK1Y4VYj7sM9de4=; b=wdeQR8MznFJEgNLe/lcL+mhlXy vDRc6quXCzP5yNkulOjvDgHAZvXD/Ir9VvO6Pr9cSMgUFZkGSmdLyBRKEUeFXmlQyTUwThjbx3604 KL+etaK41AcvePBBnboGGDUxEX4DlDnkGgzmIrXsY8B3VxELpUpPihZIU3nQKv7bwlm1MUoFOlZt8 CjqT53ScyLbj8hu5S8mGO05VC3pnlZPadLywHOTOfK4mQtTiIotdLuFMgJSUdjgKLovHHO1N/BXAh 4t93n1KR7LBEVytZilmx2pm0wxU8I6HWv+fHGJ6/hsIcThtZ0VCLl9ypOEReorRFuObz5zElSfYev 97PBXJIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sewAt-0000000CtVC-3qUU; Fri, 16 Aug 2024 12:35:23 +0000 Received: from mail-qv1-xf2e.google.com ([2607:f8b0:4864:20::f2e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sew7m-0000000CsgE-0iGa for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 12:32:12 +0000 Received: by mail-qv1-xf2e.google.com with SMTP id 6a1803df08f44-6bf7ec5c837so3636396d6.1 for ; Fri, 16 Aug 2024 05:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723811528; x=1724416328; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yVxZXuTJqaJ10E0yGjjv9nH2alidPK1Y4VYj7sM9de4=; b=FwBLhip8Yu+p2AgovlMOSnKoYxBZjV0DDmHC/JSvQF/ftyg23URYqZ6DEAM3TVJMYh +Nbxkbwh2Mt5yDhoFYYqZwJ6BUQqReD0F83bY4tgUc98TLjOJ4Rm15y1j6p5beeQU3ak FYwu2in/wG1Ebipsf83VtdaQ9GERqBpE1EMLU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723811528; x=1724416328; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yVxZXuTJqaJ10E0yGjjv9nH2alidPK1Y4VYj7sM9de4=; b=e6YrcaMmldsk4iY3/BH+80Z7Uk8pLk4ku/bR0v7IE0frCgAkl1pjFfkEU9JdrPj3qF uA9QWPn2DBEUAdg4ZPMLGAuTMJK8mNbRUvLOxEC2+BB7CnPQSecvk6wMC6kDGwYjNMHb hxMcW22n65DNnyHyiR70kaWW+JGR+YFW7fSVrOxQP/GyvA/R1oMk2YfkkQV2DRM2WWJ/ dVKpeHQ44AWwdMTK3svM/XkHwWQPRYrojm5cGS+QAF6jvQsXQQjh3DoQMQ9tGgAElgd8 OKsEb0Z70oECBAbm3+mKvNBqEWa9iS9kQ5mgkrpzb4STr9Yr2/h9XVKy1deMDu5b5lGR +62A== X-Forwarded-Encrypted: i=1; AJvYcCV/AGAr2H4Di3kn6V07VJ2uke0XRrubCn7aSUyXEA9mXhZRNgZb0s7v2B//sN9chOclRoOAuAGKX7gJtmUHnZohAPZUI/GX08tuZqn1AqhsTRgZilM= X-Gm-Message-State: AOJu0YxdTbSn+LQ70mSoEOauRHYzAie9TGzILjtPu7TTaJrtQ7U72/ZM jMClUsnItEomSQqpAUkz0e7xGUXx/5a+Xpu4tsu2jcdHZtALsgyxQIAP9tWhNg== X-Google-Smtp-Source: AGHT+IHxo1lFSQMX1cM/4MwpLU2TEtbVsyk63XfQG/g27+OnQuVnbh1zDXFyHf9x2ZFHVGoE5m/EQQ== X-Received: by 2002:a05:6214:540a:b0:6bf:700f:a3b7 with SMTP id 6a1803df08f44-6bf7cd7ac78mr23067056d6.9.1723811528290; Fri, 16 Aug 2024 05:32:08 -0700 (PDT) Received: from denia.c.googlers.com (123.178.145.34.bc.googleusercontent.com. [34.145.178.123]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bf6fef3107sm16881426d6.121.2024.08.16.05.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 05:32:07 -0700 (PDT) From: Ricardo Ribalda Date: Fri, 16 Aug 2024 12:32:04 +0000 Subject: [PATCH v2 6/6] media: meson: vdec: hevc: Refactor vdec_hevc_start and vdec_hevc_stop MIME-Version: 1.0 Message-Id: <20240816-smatch-clock-v2-6-c63105db07e8@chromium.org> References: <20240816-smatch-clock-v2-0-c63105db07e8@chromium.org> In-Reply-To: <20240816-smatch-clock-v2-0-c63105db07e8@chromium.org> To: Sakari Ailus , =?utf-8?q?Krzysztof_Ha?= =?utf-8?q?=C5=82asa?= , Mauro Carvalho Chehab , Sylwester Nawrocki , Andrzej Hajda , Neil Armstrong , Greg Kroah-Hartman , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Ricardo Ribalda X-Mailer: b4 0.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_053210_221991_8EAE46F9 X-CRM114-Status: GOOD ( 15.17 ) 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 Make a new function __vdec_hevc_start(), that does all the initialization, except the clock initialization for G12A and SM1. Factor out all the stop logic, except the clk_disable_unprepare(), to a new function __vdec_hevc_stop. This allows vdec_hevc_start() to explicitly celan-out the clock during the error-path. The following smatch warnings are fixed: drivers/staging/media/meson/vdec/vdec_hevc.c:227 vdec_hevc_start() warn: 'core->vdec_hevc_clk' from clk_prepare_enable() not released on lines: 227. drivers/staging/media/meson/vdec/vdec_hevc.c:227 vdec_hevc_start() warn: 'core->vdec_hevcf_clk' from clk_prepare_enable() not released on lines: 227. Signed-off-by: Ricardo Ribalda --- drivers/staging/media/meson/vdec/vdec_hevc.c | 43 +++++++++++++++++++++------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/drivers/staging/media/meson/vdec/vdec_hevc.c b/drivers/staging/media/meson/vdec/vdec_hevc.c index afced435c907..1939c47def58 100644 --- a/drivers/staging/media/meson/vdec/vdec_hevc.c +++ b/drivers/staging/media/meson/vdec/vdec_hevc.c @@ -110,7 +110,7 @@ static u32 vdec_hevc_vififo_level(struct amvdec_session *sess) return readl_relaxed(sess->core->dos_base + HEVC_STREAM_LEVEL); } -static int vdec_hevc_stop(struct amvdec_session *sess) +static void __vdec_hevc_stop(struct amvdec_session *sess) { struct amvdec_core *core = sess->core; struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops; @@ -142,6 +142,13 @@ static int vdec_hevc_stop(struct amvdec_session *sess) else regmap_update_bits(core->regmap_ao, AO_RTI_GEN_PWR_SLEEP0, GEN_PWR_VDEC_HEVC, GEN_PWR_VDEC_HEVC); +} + +static int vdec_hevc_stop(struct amvdec_session *sess) +{ + struct amvdec_core *core = sess->core; + + __vdec_hevc_stop(sess); clk_disable_unprepare(core->vdec_hevc_clk); if (core->platform->revision == VDEC_REVISION_G12A || @@ -151,20 +158,12 @@ static int vdec_hevc_stop(struct amvdec_session *sess) return 0; } -static int vdec_hevc_start(struct amvdec_session *sess) +static int __vdec_hevc_start(struct amvdec_session *sess) { int ret; struct amvdec_core *core = sess->core; struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops; - if (core->platform->revision == VDEC_REVISION_G12A || - core->platform->revision == VDEC_REVISION_SM1) { - clk_set_rate(core->vdec_hevcf_clk, 666666666); - ret = clk_prepare_enable(core->vdec_hevcf_clk); - if (ret) - return ret; - } - clk_set_rate(core->vdec_hevc_clk, 666666666); ret = clk_prepare_enable(core->vdec_hevc_clk); if (ret) { @@ -223,10 +222,32 @@ static int vdec_hevc_start(struct amvdec_session *sess) return 0; stop: - vdec_hevc_stop(sess); + __vdec_hevc_stop(sess); + clk_disable_unprepare(core->vdec_hevc_clk); return ret; } +static int vdec_hevc_start(struct amvdec_session *sess) +{ + struct amvdec_core *core = sess->core; + int ret; + + if (core->platform->revision == VDEC_REVISION_G12A || + core->platform->revision == VDEC_REVISION_SM1) { + clk_set_rate(core->vdec_hevcf_clk, 666666666); + ret = clk_prepare_enable(core->vdec_hevcf_clk); + if (ret) + return ret; + + ret = __vdec_hevc_start(sess); + if (ret) + clk_disable_unprepare(core->vdec_hevcf_clk); + return ret; + } + + return __vdec_hevc_start(sess); +} + struct amvdec_ops vdec_hevc_ops = { .start = vdec_hevc_start, .stop = vdec_hevc_stop,