Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1221931pxj; Fri, 18 Jun 2021 02:16:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBwlnL4LsDEKfHWmBRdnxYxWBKFmiIc9IqzfnMD/c4TsVgF2P6gMC3v503ukM2BP7YJjXW X-Received: by 2002:a17:906:9bef:: with SMTP id de47mr9706635ejc.78.1624007817568; Fri, 18 Jun 2021 02:16:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624007817; cv=none; d=google.com; s=arc-20160816; b=M9crbRw1azPN7Cain/it+xCUCWu17KqLlBci7QNkkcL5QhMHW6K0Ef8a3dGH5EXNCH 6TsZJyp+G2DaA+qXpQL3nalf5NBVIqua6fXAQeaC1iIAnxAF1dpkD5mR6APId1fARCxe pBgUyENrqsuPrb2M5ecf/rLYaOT+Kkp+HnZkjCwLGZeXTPhBSizcFM+s2zQkTDzfy+JP OsOjZgFXMcqa10kxoXmvFIDLFMDJfSCg+13S4hq1ijPXzWahoTpQi7uk4yLfkaMPd59M AjGqLLpd9z2Ud/azwqfSp9XPar/hjfmVN4EGhwpirILx+4pBRf+A1V5e0lTwFz5T+BtV sC+w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E2/XL5tq2Hcv7mIY83UW91knd3J3s5ZhjuCcYvSa7WQ=; b=wZK+um/efVwJGqQ//32lpn9pB4ECQME7y0JQ3WEI19xCf/7xJQOBkNmYDC/P1wq7iT ZSQAt3miE7dAyT86bj3xMh3gWwpXblyBgfz9K4xudnn25v7ETXZYYX7yCldAllnq5BqS V+CoS3hxEJ4NS370+4LKgf+VFgua/m9639HAIpqzZPjZtNu/sTTgqko0677zmRzPO7ku QEyJ2SZiA8EnBetgbYRj48ivpMLY1wgKJfsdTieOVrKvxdwhJnglJWzgQxp9cL7+SzSm GHJG1TVz1lpWYqBBwLIBgrrgWLrupRYlv4OkioLoBlw3n49581tHLAlgmufdxn/XJ0ey JuuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Sy4VWbQB; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e25si1786801ejm.685.2021.06.18.02.16.35; Fri, 18 Jun 2021 02:16:57 -0700 (PDT) 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=@chromium.org header.s=google header.b=Sy4VWbQB; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233467AbhFRHyv (ORCPT + 99 others); Fri, 18 Jun 2021 03:54:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233448AbhFRHyr (ORCPT ); Fri, 18 Jun 2021 03:54:47 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4BADC061760 for ; Fri, 18 Jun 2021 00:52:38 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id bb10-20020a17090b008ab029016eef083425so7224465pjb.5 for ; Fri, 18 Jun 2021 00:52:38 -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=E2/XL5tq2Hcv7mIY83UW91knd3J3s5ZhjuCcYvSa7WQ=; b=Sy4VWbQBWyfAZD882ua7QB60gv52suGM5wA+MTdeyt8jrhoTmJV+OLD/EpaApD+9d0 UbDomOuvVqZbGGsvKBx7XP2V/mXe9Sx3XK0hP53Z0HRfr7c5HLRGz/ruVqquoqW1s1OO cs8l3zKbYVGoYBomU+EKESyzYknEVlVMLC7js= 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=E2/XL5tq2Hcv7mIY83UW91knd3J3s5ZhjuCcYvSa7WQ=; b=n5K6lsywysUU+fCFVvLXrwpqMornLMSpjHMUyCdeHrzRgse8eL9r++nGUtnK1BNtqz CevqESs2b6bQzQi+XDXKd7W8fuLFmgfQ8/msM/NigG5V+L7O67Y9Wu2wL/66H0gDKgtd tl9Z/+AaxNbbZgZcjKmHVYW2xt5v8UpTj9vuiMiQAQSx0euF6DmL18+3U7RkZ4WV/8J8 n2eMFIOPcyd0o8MK5y4fF5U3htAyCidQ/6R/8J0Yhr2u9kb3AeDk+/WfjsM/OS1++0jE FxB38svuskhRcT6cUQIGIuL7LJzWEa3tPVQdM3AvEXouEdENoAQb9YqfirTCIXO8UxiS A0mw== X-Gm-Message-State: AOAM532MHchylygMIBsERN3qkDBETl0R4HCnt+kQF60zUXvYjSdCQTnP l6Fs4cxFWk9h9YU63fMKKT3fz7/v3onFT5ex X-Received: by 2002:a17:902:6847:b029:11e:b703:83f9 with SMTP id f7-20020a1709026847b029011eb70383f9mr3670198pln.47.1624002758035; Fri, 18 Jun 2021 00:52:38 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:3e8:19ca:3d8a:e112]) by smtp.gmail.com with UTF8SMTPSA id t2sm4456065pjj.19.2021.06.18.00.52.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Jun 2021 00:52:37 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: yong.wu@mediatek.com, houlong.wei@mediatek.com, enric.balletbo@collabora.com, chunkuang.hu@kernel.org, wenst@chromium.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 v3 2/8] mtk-mdp: use pm_runtime in MDP component driver Date: Fri, 18 Jun 2021 17:52:03 +1000 Message-Id: <20210618175059.v3.2.I909f5375d930f5d0cc877128e30e2a67078b674c@changeid> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog In-Reply-To: <20210618075209.1157766-1-eizan@chromium.org> References: <20210618075209.1157766-1-eizan@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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) -- 2.32.0.288.g62a8d224e6-goog