From patchwork Fri Jun 18 07:52:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eizan Miyamoto X-Patchwork-Id: 12330447 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,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 CB6BBC48BDF for ; Fri, 18 Jun 2021 07:55:22 +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 9B5DD61396 for ; Fri, 18 Jun 2021 07:55:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B5DD61396 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=WCd1vwd9fmQnY4MlKlYZfs0fl+5nhen49137V0CpcPU=; b=XLRBP157wGro60 NdbulMkfQI4BfhMjzlE8d2ZnGLl45DEvxkCoiN8xBsLbi0U0Lly71Mw3CyZknDZuQWfB0ubM4QWSM aK/2IUfDtRWYtLTkIVctj+1r5Cs4DS/7auxfw/u1OgFjmhaD+jvPcKHmx0QNfHkxv8iZk/0BWFCFj oi1eqk77t8KX4t82xIKG1ruwS0mcJ4/AycWuzpPcoumgZ+5wuONMU3w3V5RcdH9Vl4XTNDSwvDNFv 5IhtIdts2PWxI2ZHuTwxD3HHaBC0QOW+/NgoXCMGY/4KS5PuVUm7674OFDilav6bHMWA9gvOE4Vln U73qSm3f92XFRIh+87vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lu9JR-00D8up-NT; Fri, 18 Jun 2021 07:53:14 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lu9It-00D8gP-5W for linux-arm-kernel@lists.infradead.org; Fri, 18 Jun 2021 07:52:41 +0000 Received: by mail-pj1-x102e.google.com with SMTP id t19-20020a17090ae513b029016f66a73701so260914pjy.3 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=fsPLHMsQDtkIhfr2WkMg+07yxzg11ZAIyacxSXwiNhBa6k+ZsfiPKrPM28OCnZiufk lqYXLl/eHJYC4DMeSI8e6g+IWR5Dty16LyLkqSbDm1c7u0L/VsmAZOlOUcK0D4eXw4TJ SWOlW6gfZz7T4rmYb53N6Qqfwu1GERA8l93Whl8GYZ1uai9ULf7R+SxWCHnhPAmNqBD1 CHXIwsf68m9EFMMyOZ50Uo9opGuvdT9F4bRcUp7r7CYOUaIPhvoWYjzY5GjwcE2JVEgS MtFKvPQP1bW7uSM4zlilwoBJrBTmAjxpw4S3q9RJXpHLyIMEX2hd6brPi7jInTblc4FT vivA== X-Gm-Message-State: AOAM530cNHCDrhy/zyHnLFcnZk2B919Z3LqhM1CqVmRihBLDY5u0x9YT LQNrIpTEue7KhZJ0OBLRkqEyyg== X-Google-Smtp-Source: ABdhPJygzvW6ybvx4M9AYprO8tG1mLj+0bWTOj97Kfvpknqlnl6Vw5kgFu9iDCml0RlBSyYoPBLEuQ== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210618_005239_284125_BAD5536C X-CRM114-Status: GOOD ( 24.35 ) 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)