Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5425975pxj; Wed, 23 Jun 2021 00:37:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwi4so1RWnYrnb32nVkltENpTKsDdbgx3ogleii4bqJNc8KshVAYowobJqo7bjnYYdTYGN0 X-Received: by 2002:a50:9e6b:: with SMTP id z98mr10710864ede.210.1624433857875; Wed, 23 Jun 2021 00:37:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624433857; cv=none; d=google.com; s=arc-20160816; b=tKR1aRui/e+I/dnqr8ZaTvqN06EJFDUE/jVeb7m7BQ9bDRhJfZoDbxU3TZ8uqSWMnG ZrITiOOu1pJnv01ScG+S96eKxl3XeuwBbbQhlv2kFYGnJWzarvriv1QB4cEZ3Vqpf4zo ZbzxlqJ7m5EPhcsVcjgeU8nFYQfQRpFiCRhDQFKgGKDbbqLJZGcsrSLfAq9Cs2q3JXli OHP4YED3ybFDefHzT4g6NZYo87uIkQbAkO9a+MRUPhc3oO71Vf4Mz1UY68s0hkxnm1Je cGbG9XodGctyR0VuyLqPJxtHEtLNQkMaNEyaxkDI3jwhkF6vWjEVUv6iNYo9kaRNorQ5 cWJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=TuLfJLRROGrbAsWKlU6vPPD0tP+7U4wMi6qBjWdUZbg=; b=UMeB7EDBTVK4AXom6UwM8Jm7cKz8JhNSUkHZkAoRE2ZL1SRvnQ7NFuFr38Ot5ZR9hl aFuJFhK77p6p/0Xoupq+29z3caf9uAFIt6bXNifi6SLkRZdHiq7q6NgCQ2O4vW7pyLGD dEIgNMZNxtMdACJ8zZtVFxpK9/wlvOgZlepApo4BW9/psLicqHjiqlsUh4zpyu+BmTmb Sp9zrLjKLJ4PgOJ5v++GPEB8uYSsjsLRS2xBWvsj7Q5pIH6M92n5ic9tF6+2BCWqmOVb WtB2t7MffoJJxnkmEoSFTiUi4U13eIaWpGSTVqtG3HMmk2XZAJy1oyKyDzY2jZ7wQ2Zp LWMA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j4si16749326ejj.545.2021.06.23.00.37.15; Wed, 23 Jun 2021 00:37:37 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230274AbhFWHiZ (ORCPT + 99 others); Wed, 23 Jun 2021 03:38:25 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:32792 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230189AbhFWHiU (ORCPT ); Wed, 23 Jun 2021 03:38:20 -0400 X-UUID: 7ecef9c80dd74b319bfc22e54ffb7d48-20210623 X-UUID: 7ecef9c80dd74b319bfc22e54ffb7d48-20210623 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 655790490; Wed, 23 Jun 2021 15:35:58 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 23 Jun 2021 15:35:56 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 23 Jun 2021 15:35:56 +0800 From: Moudy Ho To: Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Hans Verkuil , Jernej Skrabec CC: Maoguang Meng , Krzysztof Kozlowski , daoyuan huang , Ping-Hsun Wu , Geert Uytterhoeven , Rob Landley , Laurent Pinchart , , , , , , , , , , , , , , , , Subject: [RFC PATCH V0 03/10] media: mtk-mdp3: revise suspend strategy Date: Wed, 23 Jun 2021 15:35:42 +0800 Message-ID: <20210623073549.24170-3-moudy.ho@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210623073549.24170-1-moudy.ho@mediatek.com> References: <20210623073549.24170-1-moudy.ho@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: daoyuan huang 1.The wait queue check for incomplete running task should be put in mdp_suspend instead of mdp_pm_suspend; Due to mdp_suspend could be called while task is running; Add error return value in suspend fail situation. 2.modify dma modules' power control from larb device to modules' device self; For support real mdp_pm_suspend callback. Signed-off-by: daoyuan huang --- .../media/platform/mtk-mdp3/mtk-mdp3-comp.c | 36 ++++++++----------- .../media/platform/mtk-mdp3/mtk-mdp3-comp.h | 2 +- .../media/platform/mtk-mdp3/mtk-mdp3-core.c | 34 +++++------------- 3 files changed, 23 insertions(+), 49 deletions(-) diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c b/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c index 3033cd32340c..23dd413f3423 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.c @@ -1039,8 +1039,8 @@ void mdp_comp_clock_on(struct device *dev, struct mdp_comp *comp) { int i, err; - if (comp->larb_dev) { - err = pm_runtime_get_sync(comp->larb_dev); + if (comp->comp_dev) { + err = pm_runtime_get_sync(comp->comp_dev); if (err < 0) dev_err(dev, "Failed to get larb, err %d. type:%d id:%d\n", @@ -1068,8 +1068,8 @@ void mdp_comp_clock_off(struct device *dev, struct mdp_comp *comp) clk_disable_unprepare(comp->clks[i]); } - if (comp->larb_dev) - pm_runtime_put(comp->larb_dev); + if (comp->comp_dev) + pm_runtime_put(comp->comp_dev); } static int mdp_get_subsys_id(struct device *dev, struct device_node *node, @@ -1153,8 +1153,7 @@ static int mdp_comp_init(struct device *dev, struct mdp_dev *mdp, struct device_node *node, struct mdp_comp *comp, enum mdp_comp_id id) { - struct device_node *larb_node; - struct platform_device *larb_pdev; + struct platform_device *pdev; int i; if (id < 0 || id >= MDP_MAX_COMP_COUNT) { @@ -1176,29 +1175,22 @@ static int mdp_comp_init(struct device *dev, struct mdp_dev *mdp, mdp_get_subsys_id(dev, node, comp); - /* Only DMA capable components need the LARB property */ - comp->larb_dev = NULL; + /* Only DMA capable components need the pm control */ + comp->comp_dev = NULL; if (comp->type != MDP_COMP_TYPE_RDMA && comp->type != MDP_COMP_TYPE_WROT && comp->type != MDP_COMP_TYPE_WDMA) return 0; - larb_node = of_parse_phandle(node, "mediatek,larb", 0); - if (!larb_node) { - dev_err(dev, "Missing mediatek,larb phandle in %pOF node\n", - node); - return -EINVAL; - } - - larb_pdev = of_find_device_by_node(larb_node); - if (!larb_pdev) { - dev_warn(dev, "Waiting for larb device %pOF\n", larb_node); - of_node_put(larb_node); - return -EPROBE_DEFER; + pdev = of_find_device_by_node(node); + if (!pdev) { + dev_warn(dev, "can't find platform device of node:%s\n", + node->name); + return -ENODEV; } - of_node_put(larb_node); - comp->larb_dev = &larb_pdev->dev; + comp->comp_dev = &pdev->dev; + pm_runtime_enable(comp->comp_dev); return 0; } diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h b/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h index 77d2c3e989c4..27d58dc51dce 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-comp.h @@ -113,7 +113,7 @@ struct mdp_comp { phys_addr_t reg_base; u8 subsys_id; struct clk *clks[2]; - struct device *larb_dev; + struct device *comp_dev; enum mdp_comp_type type; enum mdp_comp_id id; u32 alias_id; diff --git a/drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c b/drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c index 4a59dec8cfd9..eaf5b07e720f 100644 --- a/drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c +++ b/drivers/media/platform/mtk-mdp3/mtk-mdp3-core.c @@ -152,7 +152,6 @@ static int mdp_probe(struct platform_device *pdev) #endif vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32)); - pm_runtime_enable(dev); ret = v4l2_device_register(dev, &mdp->v4l2_dev); if (ret) { @@ -212,7 +211,7 @@ static int mdp_remove(struct platform_device *pdev) return 0; } -static int __maybe_unused mdp_pm_suspend(struct device *dev) +static int __maybe_unused mdp_suspend(struct device *dev) { struct mdp_dev *mdp = dev_get_drvdata(dev); int ret; @@ -222,19 +221,19 @@ static int __maybe_unused mdp_pm_suspend(struct device *dev) if (atomic_read(&mdp->job_count)) { ret = wait_event_timeout(mdp->callback_wq, !atomic_read(&mdp->job_count), - HZ); - if (ret == 0) + 2 * HZ); + if (ret == 0) { dev_err(dev, - "%s:flushed cmdq task incomplete\n", - __func__); - else//need to remove - pr_err("%s:ret=%d\n", __func__, ret); + "%s:flushed cmdq task incomplete, count=%d\n", + __func__, atomic_read(&mdp->job_count)); + return -EBUSY; + } } return 0; } -static int __maybe_unused mdp_pm_resume(struct device *dev) +static int __maybe_unused mdp_resume(struct device *dev) { struct mdp_dev *mdp = dev_get_drvdata(dev); @@ -243,25 +242,8 @@ static int __maybe_unused mdp_pm_resume(struct device *dev) return 0; } -static int __maybe_unused mdp_suspend(struct device *dev) -{ - if (pm_runtime_suspended(dev)) - return 0; - - return mdp_pm_suspend(dev); -} - -static int __maybe_unused mdp_resume(struct device *dev) -{ - if (pm_runtime_suspended(dev)) - return 0; - - return mdp_pm_resume(dev); -} - static const struct dev_pm_ops mdp_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(mdp_suspend, mdp_resume) - SET_RUNTIME_PM_OPS(mdp_pm_suspend, mdp_pm_resume, NULL) }; static struct platform_driver mdp_driver = { -- 2.18.0