Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp221041pxv; Thu, 8 Jul 2021 19:25:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp02oW18Gla1mLieOFYlEHt9jcsB+mDmFe9kJ0H21s5qQ2HRXXiKbe9JMDyrf3GkSD+JKn X-Received: by 2002:a05:6402:cb4:: with SMTP id cn20mr42121392edb.254.1625797524967; Thu, 08 Jul 2021 19:25:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625797524; cv=none; d=google.com; s=arc-20160816; b=rWI4BGMopSo2xB2E84JQdfwH+1g8MB81Ty94KQAJ9TdtX1yv9gdzkkjveRiBxxGMzT YU3k153YGvue2nxWUbgi8q5i3gDRpAOR38DN21iXpeq1cGt0l/zJcjXtEtHTLUWx4TJV /9yHKSn+poSgtqu3eVlAwP18zMWmbpWkGOnTjsnzyyil/0GdsevcY2bj6LKKTYF9MRqc szqNe1/zqyFrr7XHJkPeIq1E6L7LRep4pN0RMwa/Srmc+WM/1WZYKVK0i3KQtb0FTbFP OxnRKjQKGa5YV5OwSor9clLh5JSirDgnjKZRAT9L8X7yqJFrHX0U/KDeWU/ZRP2jzsgl vqdw== 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=Y3PbmVcTpze3gwdTv7DQDH8U+vHuO9NjQ57GmGzSR5k=; b=Xxl9TsE2BHeqH0w0/kDc05H2AgQ+sFXHTXwZ/UTnLM9EYPEGdGtCLb4nEOzaf/WyOv LlDoRq7Jcci9OEVL7XOjqMR2TRrGGpNng07y5Lk7Bt3Jo7oBmMj8AMf5B/z99NQyzTlA TCGp/rO+FQHSrPs8pA0arMqx/pKLHf3ik0H1Q071pC1UPJ/WjaQRayD4sVCZ+BhanytU lF3rdj5F7MfmgNUDCwrP47RDsWMmbZjMz7uxbeDPx/79j8TWec8f3Ol/XPCqgohjZmCV IsCx1yf3L1iq1/fnsq0HC2df0ZdzLLovASkOw2nrDD580MGC6A4jk5LvCsVZ5zEnvyEB 5umQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=fKISDI2C; 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 d26si5022402ejc.620.2021.07.08.19.25.02; Thu, 08 Jul 2021 19:25:24 -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=fKISDI2C; 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 S230440AbhGIC0f (ORCPT + 99 others); Thu, 8 Jul 2021 22:26:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbhGIC0f (ORCPT ); Thu, 8 Jul 2021 22:26:35 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66CCAC06175F for ; Thu, 8 Jul 2021 19:23:52 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id x3so3740994pfc.11 for ; Thu, 08 Jul 2021 19:23:52 -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=Y3PbmVcTpze3gwdTv7DQDH8U+vHuO9NjQ57GmGzSR5k=; b=fKISDI2CZvoPa9D7Tu7CBPZuMeyZFHBtoW2slWybkcwEHtyDLRM/zxOmr4TDlcvUmf 3k7RYvR/wl4+9i5yGop34x0oy9pXRzVf5Ahe0huT+oVyCbnDrmTs0vu3s51RHNlkmOPB JjztqCAYEz/EqYrxChDldCLYOmJUs271gVdhg= 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=Y3PbmVcTpze3gwdTv7DQDH8U+vHuO9NjQ57GmGzSR5k=; b=PGzoHL1ROIej+ekqNxzOrduWRltbtqGFDEaZ6enmWMgcK5zd6tQCFJM22aoFeb6PqE 8AXCHeLGP2jLqoYKThBjvM0lGjTGaduROtpeuKmuurT4wQARNs8Fn1PsK1Z60qdPlxFL snSJ4XzWAJV6gFyWVPDu5LXhPsgDkZX+zySSfWk2SJSUlcAgNCRAgJsT/rJ+/s1Mh5pH rU0v8rlUVM106QY/wlIpk2Rf/RSWSS8i6BPBSBcOR8aHrZsN2pEOj4O6aKZNsck8EH8A mLKf41A6gm1rSBFb8up4hPlHefB+CTuRDna0mVqSsVgI6MgUaXTrNTBAzyZ9p0T1oJ5u dEtw== X-Gm-Message-State: AOAM530mvKALuk2pKBL45DpQIa4r1S0sUUz5zU042XWF7AEbVxeuA8un 3ZcVkM3AL0Ky+zR9i8ZMFv0BS7pSSusy0w== X-Received: by 2002:a63:e841:: with SMTP id a1mr35114724pgk.197.1625797431737; Thu, 08 Jul 2021 19:23:51 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:d956:2966:7910:2bd2]) by smtp.gmail.com with UTF8SMTPSA id c7sm4747596pgq.22.2021.07.08.19.23.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Jul 2021 19:23:51 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: wenst@chromium.org, chunkuang.hu@kernel.org, yong.wu@mediatek.com, enric.balletbo@collabora.com, houlong.wei@mediatek.com, 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 v5 2/8] mtk-mdp: use pm_runtime in MDP component driver Date: Fri, 9 Jul 2021 12:23:18 +1000 Message-Id: <20210709122040.v5.2.I909f5375d930f5d0cc877128e30e2a67078b674c@changeid> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog In-Reply-To: <20210709022324.1607884-1-eizan@chromium.org> References: <20210709022324.1607884-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 | 20 ++++++++++++++----- drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 8 +++++--- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 6 ++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index aec1cb5c4261..8b6158379f41 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "mtk_mdp_comp.h" #include "mtk_mdp_core.h" @@ -52,7 +53,7 @@ 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; @@ -63,18 +64,22 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) "failed to get larb, err %d.\n", 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; @@ -86,6 +91,8 @@ void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp) if (comp->larb_dev) mtk_smi_larb_put(comp->larb_dev); + + pm_runtime_put_sync(comp->dev); } static int mtk_mdp_comp_bind(struct device *dev, struct device *master, @@ -95,6 +102,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; } @@ -105,6 +113,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); } @@ -124,6 +133,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 b5a18fe567aa..5e2ee94a1b37 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h @@ -12,17 +12,19 @@ * @node: list node to track sibing MDP components * @clk: clocks required for component * @larb_dev: SMI device required for component + * @dev: component's device */ struct mtk_mdp_comp { struct list_head node; struct clk *clk[2]; - struct device *larb_dev; + struct device *larb_dev; + 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 aca236dbd348..78c40a61df1d 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c @@ -52,20 +52,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.93.g670b81a890-goog