Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3565007rwb; Fri, 30 Sep 2022 05:30:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76c77oYS67Otctr2/mzxraRKi8JC10A0sbXUYaUY3vwfcUxP/dcF260rRbSjTgM721qRXs X-Received: by 2002:a17:907:1b22:b0:741:8809:b4e6 with SMTP id mp34-20020a1709071b2200b007418809b4e6mr6333042ejc.84.1664541019771; Fri, 30 Sep 2022 05:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664541019; cv=none; d=google.com; s=arc-20160816; b=XjbtfmvENUSpYGyuOtlKWdGmDlxrQzm8Uu84R58MFH6p6lW7M73iyXe/a+OyFyDQVU RS5htleDdrubF9yPp+krVJbN/ixY6AKu1az7eIhin53gjSRCkzucU83D2GAFvsj7qWyC jMT1tpAppHe1wpN4/qPL8pzbUDcEPHKC0dZ9Rg3+XA/tE75wLOpsFZbI1Yb2gGS8o1mZ aFsE9ZrkpuVsctLR0SFiwuELqEG9leR4vWQW43GHcvlYZXTTi6uK/4hUjojqsjXOq8Vr tzshs380qojjgw83iH8q2XU5J/l3xOS9Exs6fV+LWICR2u8Zxk7i5XPvSdnhjSQErnMq QZFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=tV/KVA60N8wCrcyq8E7sO7XclkqoZK3ThaqZXfyJ8nU=; b=N7P3yPVUgTaQqexeGz+VuBajsSDYSme4kEGMiUyUIKk+HKKiX3/U/1/lKHApmZnH0H P7Jzc0fMKhR6dwVrloRqpnECCAav6sPfpOJ9DyqyVj/vx/2JF100SzWHbu/lajjzNxSR mQaWQLzLIAQZzsqzONu+OZwasWw19OqGJZ1T2FOEqvGv13rjj89vvANll8v4jTVF/mCI +QsaC1E83c95sEwfHL+/4MXGsCuPwXo5ZVzTtxGscN/GLifjuSKVQzsHnC2MKka/W6f5 yjRwhhmGYZId4INhUeFlysbZaaPAFQGz9kcQlCAdHkoCRuMwDR+tkUJZn0mS2skjivJp 7ERA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hevf7flj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho42-20020a1709070eaa00b007825bd02a6asi2194460ejc.54.2022.09.30.05.29.53; Fri, 30 Sep 2022 05:30:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hevf7flj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231464AbiI3MNA (ORCPT + 99 others); Fri, 30 Sep 2022 08:13:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231191AbiI3MM5 (ORCPT ); Fri, 30 Sep 2022 08:12:57 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1415E1794A0; Fri, 30 Sep 2022 05:12:56 -0700 (PDT) Received: from [192.168.1.100] (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 7AC7666022C7; Fri, 30 Sep 2022 13:12:53 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1664539973; bh=S/w2ZgDqdlLU+Y5Jz0E2rWA2oIr8YVBO+H3Z2byFScQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=hevf7fljW2fs3JHeop1tzitdLhD8iz5jrvS7rn8C/rOSMgWjZRC1Q4lLTJ0mP7CI8 /8Qi8JZUNjqKWTyeQepFo0BGGdmrDWmKfUFDZ/GLVQ+GaO7NGULQQKyLELx+vah0Pk ZCkZVykNQA3PB+GlOgmkayfWBlGopjGyizLGZCm6pZu03exvacZbXE9eW+Bh9iihpz aJ5TNK1jiHC/w0ULE6VFqYXSYCegkqrNfvR4yXBUnJzNOX8mxg+8YuVSnnrt4YpwuX UoPrv90Gm8hGWsWj1iMvh/aNYSO2O1UKLcdu+cr92ZVIdRWtfH5rlPjyWvvqYVLkH0 f+0wlhOZm0mYQ== Message-ID: <8afa9c8e-079e-6e50-a8d7-21e0b1698f76@collabora.com> Date: Fri, 30 Sep 2022 14:12:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH v1 2/2] media: platform: mtk-mdp3: fix error handling about components clock_on Content-Language: en-US To: Moudy Ho , Mauro Carvalho Chehab , Matthias Brugger , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Project_Global_Chrome_Upstream_Group@mediatek.com References: <20220930102306.13201-1-moudy.ho@mediatek.com> <20220930102306.13201-3-moudy.ho@mediatek.com> From: AngeloGioacchino Del Regno In-Reply-To: <20220930102306.13201-3-moudy.ho@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Il 30/09/22 12:23, Moudy Ho ha scritto: > Add goto statement in mdp_comp_clock_on() to avoid error code not being > propagated or returning positive values. > This change also performs a well-timed clock_off when an error occurs, and > reduces unnecessary error logging in mdp_cmdq_send(). > > Fixes: 61890ccaefaf ("media: platform: mtk-mdp3: add MediaTek MDP3 driver") > Signed-off-by: Moudy Ho > --- > .../platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 4 +--- > .../platform/mediatek/mdp3/mtk-mdp3-comp.c | 24 ++++++++++++++----- > 2 files changed, 19 insertions(+), 9 deletions(-) > > diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c > index e194dec8050a..124c1b96e96b 100644 > --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c > +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c > @@ -433,10 +433,8 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) > cmd->mdp_ctx = param->mdp_ctx; > > ret = mdp_comp_clocks_on(&mdp->pdev->dev, cmd->comps, cmd->num_comps); > - if (ret) { > - dev_err(dev, "comp %d failed to enable clock!\n", ret); > + if (ret) > goto err_free_path; > - } > > dma_sync_single_for_device(mdp->cmdq_clt->chan->mbox->dev, > cmd->pkt.pa_base, cmd->pkt.cmd_buf_size, > diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c > index d3eaf8884412..fe6a39315e88 100644 > --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c > +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c > @@ -699,12 +699,22 @@ int mdp_comp_clock_on(struct device *dev, struct mdp_comp *comp) > dev_err(dev, > "Failed to enable clk %d. type:%d id:%d\n", > i, comp->type, comp->id); > - pm_runtime_put(comp->comp_dev); > - return ret; > + goto err_unwind; > } > } > > return 0; > + > +err_unwind: For this label to be clearer, I would rename it as `err_revert`, or `clocks_off`, or even simply `err`, as the `unwind` word may create some confusion here. > + while (--i >= 0) { > + if (IS_ERR_OR_NULL(comp->clks[i])) > + continue; > + clk_disable_unprepare(comp->clks[i]); > + } > + if (comp->comp_dev) > + pm_runtime_put_sync(comp->comp_dev); > + > + return ret; > } > > void mdp_comp_clock_off(struct device *dev, struct mdp_comp *comp) > @@ -723,11 +733,13 @@ void mdp_comp_clock_off(struct device *dev, struct mdp_comp *comp) > > int mdp_comp_clocks_on(struct device *dev, struct mdp_comp *comps, int num) > { > - int i; > + int i, ret; > > - for (i = 0; i < num; i++) > - if (mdp_comp_clock_on(dev, &comps[i]) != 0) > - return ++i; > + for (i = 0; i < num; i++) { > + ret = mdp_comp_clock_on(dev, &comps[i]); > + if (ret) > + return ret; > + } > > return 0; > } >