From patchwork Fri Apr 23 05:58: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: 12219685 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.8 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 AEA9FC433B4 for ; Fri, 23 Apr 2021 06:06:32 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 163A5601FC for ; Fri, 23 Apr 2021 06:06:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 163A5601FC 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=desiato.20200630; 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=mL5qoAS53vaR6nYbxKeg+6cPYEmQc0/32KR2nlo1eK0=; b=o9lzYbZN71BtGQpPRVxR82Z6l gNGpyRko0r3z93SkqX+M/RUfKMcCDQBLyXkqGIMzhF+cEp0Xhf2p+8Pkw8o5jTTo5ywPN8J8FtLqI GG3NssesT6kmkNg7M+QZI+a+nsBavCX4bCCAv/bo64gB9NBYsM/+rWUavh6NsmA0Kr9BHGyCfocfm HeX1TSru3AtYKwtzkP7ncg66QjNv3D+l2H/C30GnDGDqN3Sm2z/Ro8REWc8SLEc/IetZqLx0xfSNQ xCydEz+ja9VFJ01zBxj+ccjR9JoAdktWbbkn1bS/Bd8eKb2HZOPWzEbx8rNY3Chd+BNSn3WjxaSX+ OBGCXC9qA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZovD-000ngO-8N; Fri, 23 Apr 2021 06:04:11 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZosD-000nBl-6U for linux-arm-kernel@lists.infradead.org; Fri, 23 Apr 2021 06:01:52 +0000 Received: by mail-pj1-x1030.google.com with SMTP id u11so18895646pjr.0 for ; Thu, 22 Apr 2021 23:01:04 -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=yiAcF7/EwGsVTnm/KaKw4OR9M6sL1Co2VCdZKQI4p/0=; b=Zjglmk7B7C3da6aWjzL2ebSM1WB1jlSPt927qLqbJ+/9q+L9IsbnMK/Pz/6SW7LxHE GQL5wmlG0bzs7Ooesq0mHdrODpUF65y7dVPLpRrni1O9xPc7qCB17nz9nLb6iYZRv2Ln dAtE+qwiCn4d1gTK4co7+mESQy5U6dBG6dksI= 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=yiAcF7/EwGsVTnm/KaKw4OR9M6sL1Co2VCdZKQI4p/0=; b=LCZAw5fWRvd1noxNKaXOaA98DPsUa9qhiMYOuTvySsnWhB/Wt/qA1taRMD1qMwx1kT K5vUk2ngUbblLJ0hBYw2eY6tmcUzqkOOnlIcdbW9iK6XLkzcgVAaN4/Fkaj9E/vNexgC vPD9WlHPErCmtnCMPJQmmP0e3rEQR6kr7cNyAYD19En9s8lzGWQ33uYBuebKMbSzjTIF HWV8MMyCCz9gw8bPQqcraobxFq3SuqrjEeZ2hSoMxA1ZXHHq1kFcHrR7wxTl5ySLgCsn d9edOgpn4zdjiww4I3kvMYZTFUu9lJ1OdEQXVB7Xny/vVZtMpbcBy5YhiyzEUBAuMbJ0 5Ixg== X-Gm-Message-State: AOAM530XPqmzudhfmgEY/DJSuUbzwr+HZqqaNfu+wvuHna5ct5AYkjMn xyDCR74TO1l0t0pa5zhuIiTWmA== X-Google-Smtp-Source: ABdhPJyZDeeqBMLrYrovs9jwIPtJnn0qpnzmHzSKWb84On4ThfdJXfv1HZfAPSSnZ2F0GYiCc4r0mA== X-Received: by 2002:a17:90a:de17:: with SMTP id m23mr2698590pjv.16.1619157543910; Thu, 22 Apr 2021 22:59:03 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:308c:235d:f7a2:53a1]) by smtp.gmail.com with UTF8SMTPSA id a1sm3681575pfi.161.2021.04.22.22.58.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Apr 2021 22:59:03 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: enric.balletbo@collabora.com, chunkuang.hu@kernel.org, yong.wu@mediatek.com, Eizan Miyamoto , Andrew-CT Chen , Houlong Wei , 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 v1 2/4] mtk-mdp: use pm_runtime in MDP component driver Date: Fri, 23 Apr 2021 15:58:39 +1000 Message-Id: <20210423155824.v1.2.I909f5375d930f5d0cc877128e30e2a67078b674c@changeid> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423055842.2490679-1-eizan@chromium.org> References: <20210423055842.2490679-1-eizan@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210423_070123_755006_8505D164 X-CRM114-Status: GOOD ( 23.47 ) 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 --- drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 19 ++++++++++++++++--- 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(+), 9 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index 3fbbcf05440a..84f9c529d74a 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,28 @@ 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, + 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 +83,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 +94,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 +105,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 +123,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)