From patchwork Mon Aug 2 12:12:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eizan Miyamoto X-Patchwork-Id: 12413847 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86D99C4338F for ; Mon, 2 Aug 2021 12:15:26 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3BEEE60FA0 for ; Mon, 2 Aug 2021 12:15:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3BEEE60FA0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lrdtW7tcvkdXLNj/KrksdetOWgq+wSQq523JnjcxO6E=; b=a3aqcKDXb1yBEY hiUInez4Io2foBg/dh9kOjdhf+e2biCHvZ36bHv5Uqc2M39S3sn9kVOeR8cfGTwtvkxIT0yNPjdRn R/8kMRJ9YnN/5Rm/kpPis/yG9fJ5UUKOhRI20UWn914dKiGgtWwSGTiY5bSfTvPEQoieISJv8Npo2 39oe/laF7gJ+PNggL2EiobscEi4Wa9BjzmA9KV/NaKJMHA+mNM5UYLtlZWdFKbQ9KiMkIeU9OYzkg IbQoedo5WW9kVRBN9FWA/+8COaU9LSaHi7TmQl0/SC4ZqKQHv5apTItyB3FRnFzcF9QeSWa/PNtuY kUW/gK8GpD0MEC9TxcDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWoO-00G7nC-3B; Mon, 02 Aug 2021 12:12:52 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWoA-00G7g2-0t for linux-arm-kernel@lists.infradead.org; Mon, 02 Aug 2021 12:12:39 +0000 Received: by mail-pl1-x636.google.com with SMTP id k2so1824954plk.13 for ; Mon, 02 Aug 2021 05:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZviZKKS5zt5VRJZud/1hXXwMNiDi17ry2eyhIG3EEHA=; b=eLK7SeiVe0xtM1i3VwFTzL+lvc07HgEwOf/UxdpuKGWXrPufUHub2C+iAvFg3iAAaj e48gy8OAJo/pPUK6JNmRbtBYLqUq+3FvM7sNw4jmDslD8Wt0n/3HVANJTy8Zgzt3mmKH SuHWI4FX6sgetm8GJSOkmvYZWpjGJdcpK/TD4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZviZKKS5zt5VRJZud/1hXXwMNiDi17ry2eyhIG3EEHA=; b=GZu6TcuFiiAn6zekkuAHxJuG4rnoy6PgXzlX+VMND0tKNooKBam2QWrTdNrulATqWK dPUIQhV9wzDVwnJ5xrDsW8TYw3JOkVHe1HMtV+LgDZvUqCLNFXRWfpyolbiGre5WZMMJ gC1kD2NLCkATunWowZ1t04h0uvufseqZibzLne1rgCfF/dWx09gJeT7gir8hxcIFaz59 r4BV6ch16fBhDV5NeMktaiy9KBaxGMS6I4XXoDiUElap1Utn3+UQWe19C3uxkwT1yX4y LIMNZiZ23XA7iGMvK2IPqTDkAfukvFwS1bbKFfFhVVdlSclSOooX4ebU9pRmlgaOf+D1 6QeQ== X-Gm-Message-State: AOAM530zKFoSMV6IlQnXle/3QWsLrZVpBCxjnhXM0fh+nKQ/KnN27Nso W2xofARAfK4KGVWjel/SK7M38g== X-Google-Smtp-Source: ABdhPJzufei59mRMqQWISJty4OzpCb27BEq+4Hyc8ne/YBqVK51kUqGp4k9uK7LYhl4yBPjLoUVu5w== X-Received: by 2002:a65:6243:: with SMTP id q3mr681044pgv.297.1627906355381; Mon, 02 Aug 2021 05:12:35 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:cd34:e942:c094:baef]) by smtp.gmail.com with UTF8SMTPSA id j5sm7603827pjv.56.2021.08.02.05.12.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Aug 2021 05:12:35 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: wenst@chromium.org, houlong.wei@mediatek.com, yong.wu@mediatek.com, enric.balletbo@collabora.com, devicetree@vger.kernel.org, chunkuang.hu@kernel.org, Eizan Miyamoto , Andrew-CT Chen , Matthias Brugger , Mauro Carvalho Chehab , Minghsiu Tsai , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v6 1/9] mtk-mdp: propagate errors from clock_on Date: Mon, 2 Aug 2021 22:12:07 +1000 Message-Id: <20210802220943.v6.1.I9db0d408ef79d300672ec0311a6bee9556801631@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210802121215.703023-1-eizan@chromium.org> References: <20210802121215.703023-1-eizan@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210802_051238_077176_E26E59AB X-CRM114-Status: GOOD ( 18.81 ) 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 Up until this change, many errors were logged but ignored when powering on clocks inside mtk_mdp_core. This change tries to do a better job at propagating errors back to the power management framework. Signed-off-by: Eizan Miyamoto Reviewed-by: Enric Balletbo i Serra Reviewed-by: Houlong Wei --- (no changes since v1) drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 25 ++++++++++++----- drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 2 +- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 27 ++++++++++++++----- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index b3426a551bea..76e295c8d9bc 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c @@ -13,10 +13,9 @@ #include "mtk_mdp_comp.h" - -void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) +int mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) { - int i, err; + int i, err, status; if (comp->larb_dev) { err = mtk_smi_larb_get(comp->larb_dev); @@ -30,11 +29,23 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) if (IS_ERR(comp->clk[i])) continue; err = clk_prepare_enable(comp->clk[i]); - if (err) - dev_err(dev, - "failed to enable clock, err %d. type:%d i:%d\n", - err, comp->type, i); + if (err) { + status = err; + dev_err(dev, "failed to enable clock, err %d. i:%d\n", err, i); + goto err_clk_prepare_enable; + } + } + + return 0; + +err_clk_prepare_enable: + for (--i; i >= 0; i--) { + if (IS_ERR(comp->clk[i])) + continue; + clk_disable_unprepare(comp->clk[i]); } + + return status; } void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h index 7897766c96bb..92ab5249bcad 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h @@ -41,7 +41,7 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, struct mtk_mdp_comp *comp, enum mtk_mdp_comp_type comp_type); void mtk_mdp_comp_deinit(struct device *dev, struct mtk_mdp_comp *comp); -void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp); +int mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp); void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp); diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c index 976aa1f4829b..412bbec0f735 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c @@ -52,13 +52,28 @@ static const struct of_device_id mtk_mdp_of_ids[] = { }; MODULE_DEVICE_TABLE(of, mtk_mdp_of_ids); -static void mtk_mdp_clock_on(struct mtk_mdp_dev *mdp) +static int mtk_mdp_clock_on(struct mtk_mdp_dev *mdp) { - struct device *dev = &mdp->pdev->dev; struct mtk_mdp_comp *comp_node; + int status; + struct device *dev = &mdp->pdev->dev; + int err; - list_for_each_entry(comp_node, &mdp->comp_list, node) - mtk_mdp_comp_clock_on(dev, comp_node); + list_for_each_entry(comp_node, &mdp->comp_list, node) { + err = mtk_mdp_comp_clock_on(dev, comp_node); + if (err) { + status = err; + goto err_mtk_mdp_comp_clock_on; + } + } + + return 0; + +err_mtk_mdp_comp_clock_on: + list_for_each_entry_continue_reverse(comp_node, &mdp->comp_list, node) + mtk_mdp_comp_clock_off(dev, comp_node); + + return status; } static void mtk_mdp_clock_off(struct mtk_mdp_dev *mdp) @@ -274,9 +289,7 @@ static int __maybe_unused mtk_mdp_pm_resume(struct device *dev) { struct mtk_mdp_dev *mdp = dev_get_drvdata(dev); - mtk_mdp_clock_on(mdp); - - return 0; + return mtk_mdp_clock_on(mdp); } static int __maybe_unused mtk_mdp_suspend(struct device *dev)