Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1012910ybk; Wed, 20 May 2020 18:40:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzewqCh6DuwK+EgU2zGY+0wLqJXKwrAV5zctTDHBvxt7RMMypeweG27WJOppYlPuSxTAaua X-Received: by 2002:a17:906:404c:: with SMTP id y12mr1653197ejj.9.1590025246198; Wed, 20 May 2020 18:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590025246; cv=none; d=google.com; s=arc-20160816; b=pjZUX2EK00esKBshPR9UppXY3IRRHFJvhcFDyEKNtztmneXCPwy29T9LD6vF5paQQw w53LK6zKhXK4es8nUSck9M9wCUvIqMv+KHUaPUHOnfAHxndG6a2OgLotB72d/6IyVQcl Oe9HGy7ku7z+3Zf31XqAc5UusvQbk4LpZTlh/5IgOtjUU+nSdP3GhK8rU/Y88+s/vWCm 27MSqQsnBOIZk3ysijHtOgOSF4VxjS4QaZ3mbXRwBF4O8l29SLa02N770vwpHKMgFNjm reDhEvNZ4J+Wb4XlOVPQXfF9/E3Lxd/cQIpaBSCYmMFE2SVN1qpEDP+9Ag382mhSujho ZW+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=oUriGfgjkQX3LYY7wtj+RwTpaaRdDlt+3hTHB1vDTro=; b=zjDSjKQYQJK0aE2URHyQ8ONrTGYugK1dBFQAKNlOR89bexTHfwOwvGJNJczYQikr9m S7YsdYv5+s3r9eqAQg9SsYZ+eGgivFtNQtbqc5MAEVrg2/kdjlrET7vUQmyDt1+EOBOz NtBe/6tWyNeNZdMAy2cildc3QvIQ/9k9/p2zuXxqSejkAhrXLJr5jW+D39BqgAyuY+2q QqP2eAE0gD26AqLN2LES/MZJQtSZgVOfFWaUE5kRvs55kmR4qgOfblfqpcU6SHcPNirO KVvAxQVs23RFM22EqqllBbjyl8cmu7Eu0b2lEja7F+bVGF1T0ikim3vgnBeqi2xKXsIb 2r6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="qUG0/EH6"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p2si2261877eds.136.2020.05.20.18.40.22; Wed, 20 May 2020 18:40:46 -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=@google.com header.s=20161025 header.b="qUG0/EH6"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728004AbgEUBg6 (ORCPT + 99 others); Wed, 20 May 2020 21:36:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727974AbgEUBg5 (ORCPT ); Wed, 20 May 2020 21:36:57 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77265C061A0F for ; Wed, 20 May 2020 18:36:56 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id dh1so2348850qvb.13 for ; Wed, 20 May 2020 18:36:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oUriGfgjkQX3LYY7wtj+RwTpaaRdDlt+3hTHB1vDTro=; b=qUG0/EH6XgLuxNXbQdJGezJbSQnq0Y0S/9ctlrDqDZzBmDJvsxq7FBzhGpk11Ot+cT UsLryIJ+nLWIYzsIV6Gu/Gb2PxgGUbjh0zqQVnPG4bzFl45QemjVJQaDawNLUKoLvCC9 QJ8VqGPOjpv3ayUyQtnOU0LD/9bRdnFGsbRl64BkFPt8mD+QhsPumB/jzYiHyLkVE4B0 902XwQS+EUOGGd8kT064L7blhtHZHmZ24U4MraCQJQSV6gr+SfKf9DRh/zaCfYbaRUPl uuGzpzGRkVx78pLUo5Smp49BsBnHwC+RAjbVqMp24UtmQT38yD4UGvKQGeuitvt76b7K MitQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oUriGfgjkQX3LYY7wtj+RwTpaaRdDlt+3hTHB1vDTro=; b=g+6aJ9M4LbCWTAfTl034J9PD1q/jElj29/FV0TFlvWIRM59ctJDem0HNry1mSc0ftM AVl0iY6nrAD8i/D8VSw5f3o9IqsptduYjPnIzlYWl1/EkeVftM5SzkWHl82AWbay+p6M yO5P/xnu+hSo8l4OFqW7NePbbrDXa40EEdmXYi+Fo5AS4qVybQTU9sBU0esTUfwR+Fgy OqMI10OGP89Gm2Z0dMB7j0pbwrdwLhm7uPF7NfkUAOMTmG2RIKMltTpeGF4DViR2FXhU XTaXdVZqj2RndNzVF2iLugbD6z3diJS0Wt30QZiQflFfDJ1QVfvvoNCpQ4oojLYea0Cx 1B4g== X-Gm-Message-State: AOAM532rxQT2MlNNfdcEV9GzCeHYEpjz1K5hIF8qwBc9gSowZ0MpTzqI zM/kQJ/PkpthzYsvWuRpxhb/wJygXDOoSZvNj1PflA== X-Received: by 2002:a0c:ed21:: with SMTP id u1mr7831281qvq.206.1590025015219; Wed, 20 May 2020 18:36:55 -0700 (PDT) MIME-Version: 1.0 References: <20200506084039.249977-1-eizan@chromium.org> <20200506184018.v2.2.I87cf35a058328c780bd3b8b2191209a5011b7016@changeid> In-Reply-To: From: Eizan Miyamoto Date: Thu, 21 May 2020 11:36:43 +1000 Message-ID: Subject: Re: [PATCH v2 2/2] [media] mtk-mdp: use pm_runtime in MDP component driver To: Enric Balletbo Serra Cc: Eizan Miyamoto , LKML , Andrew-CT Chen , Minghsiu Tsai , Houlong Wei , "moderated list:ARM/Mediatek SoC support" , Matthias Brugger , Mauro Carvalho Chehab , Linux ARM , linux-media@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 7, 2020 at 3:07 AM Enric Balletbo Serra wrote: > > Hi Eizan, > > Thank you for the patch. > > Missatge de Eizan Miyamoto del dia dc., 6 de maig > 2020 a les 10:42: > > > > 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 > > --- > > > > Changes in v2: > > Ah, I guess this change log corresponds to the first patch. > > > - remove empty mtk_mdp_comp_init > > - update documentation for enum mtk_mdp_comp_type > > - remove comma after last element of mtk_mdp_comp_driver_dt_match > > > > drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 22 ++++++++++++++----- > > drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 6 +++-- > > drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 6 ++--- > > 3 files changed, 23 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 5b4d482df778..228c58f92c8c 100644 > > --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c > > +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c > > @@ -15,6 +15,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "mtk_mdp_comp.h" > > #include "mtk_mdp_core.h" > > @@ -53,7 +54,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; > > > > @@ -62,25 +63,31 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) > > if (err) { > > enum mtk_mdp_comp_type comp_type = > > (enum mtk_mdp_comp_type) > > - of_device_get_match_data(dev); > > - dev_err(dev, > > + of_device_get_match_data(comp->dev); > > + dev_err(comp->dev, > > "failed to get larb, err %d. type:%d\n", > > err, comp_type); > > } > > } > > > > + err = pm_runtime_get_sync(comp->dev); > > + if (err < 0) > > + dev_err(comp->dev, > > + "failed to runtime get, err %d.\n", > > + err); > > Should you really ignore this error? If that's the case I'd just call > pm_runtime_get_sync() without adding the logic to just print an error > message. This is mostly consistent with style elsewhere, e.g., in mtk_mdp_m2m.c mtk_mdp_m2m_start_streaming and mtk_mdp_m2m_stop_streaming. > > > + > > 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); > > Although ignoring errors seems to be a common pattern in this file and > I know you did not introduce this. Maybe the issue is that since no action is taken, logging at the 'error' log level is not the right thing? IOW, should it be changed to an informational message instead? Nevertheless, I think we should defer these changes to a follow-up patch instead. > > > } > > } > > > > -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; > > > > @@ -92,6 +99,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, > > @@ -101,6 +110,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; > > } > > @@ -111,6 +121,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); > > } > > > > @@ -129,6 +140,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..de158d3712f6 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 *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 539a7942e3cb..133d107aa4e6 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.26.2.526.g744177e7f7-goog > > > > > > _______________________________________________ > > Linux-mediatek mailing list > > Linux-mediatek@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-mediatek