From patchwork Fri Jun 11 04:01:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eizan Miyamoto X-Patchwork-Id: 12314705 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=-16.9 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,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 0CC55C4743D for ; Fri, 11 Jun 2021 04:07:14 +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 D1F0361073 for ; Fri, 11 Jun 2021 04:07:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D1F0361073 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@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=csdIX+rtf3KPyKg2d3vD5WIVlgFtgVSmJx9lachTkM4=; b=PWtR0MKM9R3hlB qhyrVStsxCTHdu1+/OFwWkVfMeSXBG0NjzmdAwLgmN4JEuPKyprx2dEzDTFka1TjWBOcjLaUSdxt4 JQnI4BvY3aMwD0FaTkViD8zAm7MpLmHpPBbRxwLnKYgaehy2szLF1SqN1J/IjT7NxWdEkbMNUtN4Z voYRFX1iEWp5/sUrFgIiozTuzpR1uVdbWn3DYhC+2Se8OVVCs1wS+bJGKPJYk4hy4ua6mnDTwLxU0 FtI7rHgWz7c1wkpKndHKJPaQhTvBEXYTANr0cnCalrKocMBAUKNRzr5taEV4C02VyNJ/WmmiQywkB BSkQvBsWyDquF4AgJ5Bg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lrYPt-003SzJ-F2; Fri, 11 Jun 2021 04:05:10 +0000 Received: from mail-pf1-f177.google.com ([209.85.210.177]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lrYO7-003RxG-Qf for linux-arm-kernel@lists.infradead.org; Fri, 11 Jun 2021 04:03:21 +0000 Received: by mail-pf1-f177.google.com with SMTP id p13so3397784pfw.0 for ; Thu, 10 Jun 2021 21:03:19 -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=14tRWP95MvRyDR2xGdaAtK3vhQBCp92E5g6fXW2EjCA=; b=eHXwoJ79HlOWrMmfhR2c8lRCNXtkCS9V+2WwC0vqpEIfXtRTuVXFPPdnjAoNT29msY zX6RtQ8XuDbLRmMpRPG8Lckc0ASi6H+2I+Yc3Ktk32fZJ+7ftzfDrWeORRptrAdPKNt7 NCnYnceOYCNidgxXN5a7UWuTFwmGyKo/5X1v0= 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=14tRWP95MvRyDR2xGdaAtK3vhQBCp92E5g6fXW2EjCA=; b=KfrsB7YwoCpsXPwbyjTN2/aY988Q/nJbjx5gSsvkPV9x1zS0/fn6s312X2S1KUJBR7 qbNvVOEgGCLXOhRKt0GpHUFHgsh67eZw6saERizi2unI0PhgFmSJ5I72dgaEZhcMUAEr IDzMsmx48O+ht8inQshj42S4e2fo9DhllTyJsU4Cqlo7Eud8Xle2kb3uulzc2pUxJ4po GKNlCF2PmZkbiAYetRkz1mvrGbyj0EpAmqm0GzwaQDX71MjnU9zL1vRD8+UJ0Qv8FAyi 5/zUGzSBayYkTf/MsAGHZbAp7bcLhOXmNn104BPacHOgSxvUuZ/RtqFej2JkEUMokT+5 JA8Q== X-Gm-Message-State: AOAM5321BwNSrS5w8G9+qbeCgNzj/jwRy9TYydlYJmRX7IMyYi9AdUPE N1I5MLv/091RB1YdVj6jsXwZWw== X-Google-Smtp-Source: ABdhPJyUr7z/1J+gcl1i6CL2nNrUDRA0ntBY6Rioo+/Lrl1/dgFUbmH5RIiSh5uZcPcD9FfTJFSsMw== X-Received: by 2002:a63:dd48:: with SMTP id g8mr1618116pgj.102.1623384139015; Thu, 10 Jun 2021 21:02:19 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:db52:e918:e5f9:9e14]) by smtp.gmail.com with UTF8SMTPSA id u9sm3867172pgp.90.2021.06.10.21.02.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Jun 2021 21:02:18 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: houlong.wei@mediatek.com, enric.balletbo@collabora.com, yong.wu@mediatek.com, 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 v2 2/8] mtk-mdp: use pm_runtime in MDP component driver Date: Fri, 11 Jun 2021 14:01:39 +1000 Message-Id: <20210611140124.v2.2.I909f5375d930f5d0cc877128e30e2a67078b674c@changeid> X-Mailer: git-send-email 2.32.0.272.g935e593368-goog In-Reply-To: <20210611040145.2085329-1-eizan@chromium.org> References: <20210611040145.2085329-1-eizan@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210610_210319_931229_02CF7EFE X-CRM114-Status: GOOD ( 24.24 ) 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 Without this change, the MDP components are not fully integrated into the runtime power management subsystem, and the MDP driver does not work. For each of the component device drivers to be able to call pm_runtime_get/put_sync() a pointer to the component's device struct had to be added to struct mtk_mdp_comp, set by mtk_mdp_comp_init(). Note that the dev argument to mtk_mdp_comp_clock_on/off() has been removed. Those functions used to be called from the "master" mdp driver in mtk_mdp_core.c, but the component's device pointer no longer corresponds to the mdp master device pointer, which is not the right device to pass to pm_runtime_put/get_sync() which we had to add to get the driver to work properly. Signed-off-by: Eizan Miyamoto --- (no changes since v1) drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 21 ++++++++++++++----- drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 6 ++++-- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 6 ++---- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index aced0029b7cd..8cebc3565826 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include "mtk_mdp_comp.h" #include "mtk_mdp_core.h" @@ -51,22 +53,26 @@ static const struct of_device_id mtk_mdp_comp_driver_dt_match[] = { }; MODULE_DEVICE_TABLE(of, mtk_mdp_comp_driver_dt_match); -void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) +void mtk_mdp_comp_clock_on(struct mtk_mdp_comp *comp) { int i, err; + err = pm_runtime_get_sync(comp->dev); + if (err < 0) + dev_err(comp->dev, + "failed to runtime get, err %d.\n", + err); + for (i = 0; i < ARRAY_SIZE(comp->clk); i++) { 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. i:%d\n", - err, i); + dev_err(comp->dev, "failed to enable clock, err %d. i:%d\n", err, i); } } -void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp) +void mtk_mdp_comp_clock_off(struct mtk_mdp_comp *comp) { int i; @@ -75,6 +81,8 @@ void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp) continue; clk_disable_unprepare(comp->clk[i]); } + + pm_runtime_put_sync(comp->dev); } static int mtk_mdp_comp_bind(struct device *dev, struct device *master, @@ -84,6 +92,7 @@ static int mtk_mdp_comp_bind(struct device *dev, struct device *master, struct mtk_mdp_dev *mdp = data; mtk_mdp_register_component(mdp, comp); + pm_runtime_enable(dev); return 0; } @@ -94,6 +103,7 @@ static void mtk_mdp_comp_unbind(struct device *dev, struct device *master, struct mtk_mdp_dev *mdp = data; struct mtk_mdp_comp *comp = dev_get_drvdata(dev); + pm_runtime_disable(dev); mtk_mdp_unregister_component(mdp, comp); } @@ -111,6 +121,7 @@ int mtk_mdp_comp_init(struct mtk_mdp_comp *comp, struct device *dev) (enum mtk_mdp_comp_type)of_device_get_match_data(dev); INIT_LIST_HEAD(&comp->node); + comp->dev = dev; for (i = 0; i < ARRAY_SIZE(comp->clk); i++) { comp->clk[i] = of_clk_get(node, i); diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h index 956d20c01e34..355e226d74fe 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h @@ -11,16 +11,18 @@ * struct mtk_mdp_comp - the MDP's function component data * @node: list node to track sibing MDP components * @clk: clocks required for component + * @dev: component's device */ struct mtk_mdp_comp { struct list_head node; struct clk *clk[2]; + struct device *dev; }; int mtk_mdp_comp_init(struct mtk_mdp_comp *comp, struct device *dev); -void 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); +void mtk_mdp_comp_clock_on(struct mtk_mdp_comp *comp); +void mtk_mdp_comp_clock_off(struct mtk_mdp_comp *comp); extern struct platform_driver mtk_mdp_component_driver; diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c index d79bf7f0031a..c55bcfe4cbb7 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c @@ -51,20 +51,18 @@ MODULE_DEVICE_TABLE(of, mtk_mdp_of_ids); static void mtk_mdp_clock_on(struct mtk_mdp_dev *mdp) { - struct device *dev = &mdp->pdev->dev; struct mtk_mdp_comp *comp_node; list_for_each_entry(comp_node, &mdp->comp_list, node) - mtk_mdp_comp_clock_on(dev, comp_node); + mtk_mdp_comp_clock_on(comp_node); } static void mtk_mdp_clock_off(struct mtk_mdp_dev *mdp) { - struct device *dev = &mdp->pdev->dev; struct mtk_mdp_comp *comp_node; list_for_each_entry(comp_node, &mdp->comp_list, node) - mtk_mdp_comp_clock_off(dev, comp_node); + mtk_mdp_comp_clock_off(comp_node); } static void mtk_mdp_wdt_worker(struct work_struct *work)