Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1082452pxy; Thu, 22 Apr 2021 23:00:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvdskZcOOpAmOiPhM+qNzhLJ0h+sXy82pWQHg2W0Az5kNvBhvYSiruxNxo3s0ITsr3oSXw X-Received: by 2002:a17:902:bc47:b029:eb:5074:dc04 with SMTP id t7-20020a170902bc47b02900eb5074dc04mr2551023plz.28.1619157600917; Thu, 22 Apr 2021 23:00:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619157600; cv=none; d=google.com; s=arc-20160816; b=I8E+3q4OM0kG7LCORLwvDSx9P93NRqD3YwLo+oI6LntKIMJG9jaEyEhREP4iSqOvNc BdequSl/j3/E0keJE8ifveHMnObkFjgeGnKdJ/6EzW+pfIbONAs3SRYBaY1m/Z2qs5Uf 0qlPUHdrmq86ctNphO2DDd0tUTdzLyxvQgzZwjg3sxBeC+v3NRHij2BaHJb2aUWLPRof WrjlN9FutgmWTFaWoL47gOR3PdvTsnW+PzRIaQNkbk7eY6QR2OsrHivxkQvHUwMd7e6C cJEjo/MtbJ7UCGhzxm06zbWIogPSsc/9fwDUnS0rg/9zLPvGp217CNdRGEhmaNpTkBm9 neAg== 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=yiAcF7/EwGsVTnm/KaKw4OR9M6sL1Co2VCdZKQI4p/0=; b=0+BrofLcqLOpIFMX+BlVvKZFDUrVh2LMZATJUTIEL86aY4khvfmK3H4hamspVFj89R V1SYcGrCPK3yJLP/RPiJewP4At2eO3CJTziDBDWbxav/bHl3wWT4gwgYmVOiJwFq+WB5 amz7bxUzY0UzooCh5wiGWrb33RnADx3jkImBa28UGRBMSaoaH1I9F1ErVug/nFQUNbds tt99Alr+GYwNq0yV3TB97zkdtQePLG8SnQaA/NBYRgdoGKZYjOZevExDzGfwsQVN+eGB onhsSQy8iYOh0+GjxewLdB12kbUaWpXWSW1uUZhGxc7POHCx+v3bk7AkYikX6d5giXzA 3LZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Zjglmk7B; 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 17si5627464pfw.63.2021.04.22.22.59.47; Thu, 22 Apr 2021 23:00:00 -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=Zjglmk7B; 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 S240609AbhDWF7l (ORCPT + 99 others); Fri, 23 Apr 2021 01:59:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240604AbhDWF7k (ORCPT ); Fri, 23 Apr 2021 01:59:40 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A75F0C061574 for ; Thu, 22 Apr 2021 22:59:04 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id lr7so6407950pjb.2 for ; Thu, 22 Apr 2021 22:59: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=FgCc75EPNjglBTbGCU9gjhjQ7x0kQ1RUEcu4YlmPSP9cNVi+WAsJwG66XfGF7a7ikr tzrHj+ctvHeCE2g7qTtTE6Kw6PRuY3SzvcArMdxlpvIoKpo819YoHvpGVoaZ4ZFB6Q0y JjAn4jtvD8fKBsaxVYTQkobamtQugJzOmRUW+zu1Ww1aw8pE5vftZ3ojilRvaAo3lBZX uRg72tzI796wVzJgq0qpiRt8wIie/7mejDzIk/zigRV0L2g9hBGdz+FtIIFW+GG+0adT 7r8FvfVPtFtQpjlVQ5evgvnLzbHk+PLzIN1X+FZ72cxqSiTQcUEYtA58uP3UY+rCHSaL X2Gg== X-Gm-Message-State: AOAM530P7Bi/QydxSze+2LMpokpcIlldQdGL7AaiyfZVOia3mrSR46i7 ocuboNDP6KmFnXrIlI3Ztb9CFQjh3hjEaJ3I 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 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 --- 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) -- 2.31.1.498.g6c1eba8ee3d-goog