From patchwork Tue May 5 07:44:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eizan Miyamoto X-Patchwork-Id: 11528363 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 848AD17E8 for ; Tue, 5 May 2020 07:45:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 1C496206CC for ; Tue, 5 May 2020 07:45:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uEAIGf8f"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Spo1Xkqa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C496206CC 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SiFfMXtM334URNybB+/vKPFSqMv8x1dm9/uVMS4EtBs=; b=uEAIGf8fdkIK5D mhri/NdG6ZYvOq8Qy5dc1gt+pCj1q23GASe7CzGiWJamgIzWzK8wajMpT5X8yhI2ZnVMmAbkfKtwZ USF8uYo0Fn/kuuENDaG+/PKZCLhqjjs3+kXhPmf1bil7FkYyEiTTNHYAYFQ3mS0v9WhM4ssChmNC/ n2Crs+8B0gwt4MCos8t1FLEq4fjS/j26amKdqnzJ8fNRFtLUpum1C4KXjL4+4d2pzNBCyTuxlCxZ8 Qns93vo0+oPEaAxl12tEEWIb3fO9D7+fqx9FzIBPcuYbcZ5aYi69nXRCVvks19reiSzSHaz8Cf2Ls UHr/Oz+h7TFujib0mSYA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jVsGn-0006R5-1z; Tue, 05 May 2020 07:45:37 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jVsGP-0005Kx-FA for linux-arm-kernel@lists.infradead.org; Tue, 05 May 2020 07:45:15 +0000 Received: by mail-pl1-x641.google.com with SMTP id b6so446316plz.13 for ; Tue, 05 May 2020 00:45:12 -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=Z77U7Rzk3P4AZGQXqWQW2bj00iC0wA8+k91tTTD8eGQ=; b=Spo1XkqalSjyLbt8gkj8e9HR46TKpNeFOcdbglpNb0OLp9ZSqaY/ydgMbcEpeQ0dbE pHBE/RHcQSngGg/jXsvpupVYtzf+mlFHrZcxXQGpSr/dWkC6v5fKpF9qHnLF+ldP+CVQ Xx00oALTHfK9vwdt+HT6e0ZvxVMhgMXwZLzQg= 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=Z77U7Rzk3P4AZGQXqWQW2bj00iC0wA8+k91tTTD8eGQ=; b=kzHYcdyYjSj/Nj7Jw69/nf9iAuAO7wY5aI+AO2wfunCh46SdPjvGyBMb13R63MmA0x edMnPQhzQZ/9b69uzQ3C3m4nDP5Ig8c9XaPTWrwwYDTbVL2nVTe6aOcLOXuExyw2L92Y +rCNrTibQiO363PcWSSPQkncbMAR45I+TvZzrkzikpVa4UCW01CudCbBHojRFzs9KggH ja3nmRCd1nOMYp9tKrQAlOBc2cLUs/swto37+SxTCQUTxgRszXajsHrVYfSRQZz0J/GV 0Zias9QvcFquS346/U6SS8G5AzZKuDCTSyaD9YH6C1CWW7j4NioeuwT+A68nl5bz7Lk6 DmTg== X-Gm-Message-State: AGi0PuYQMIG8f2Z2xPfOeM7ejbM3vSfLZUqqyB2Gir+kvWTDQTzS7WRY r9rGfqq5TFu0yMvKPu1AjRZ8Fg== X-Google-Smtp-Source: APiQypKPwQ7nGL9/OqTxIalmLbYaYXaB4DlIbpLu8OgPZWPvXezPxD5jRhqXZItQCN7L3kvnPBHqJw== X-Received: by 2002:a17:902:6b0a:: with SMTP id o10mr1886461plk.32.1588664711630; Tue, 05 May 2020 00:45:11 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:a92f:c47d:76a8:b09e]) by smtp.gmail.com with ESMTPSA id gl12sm1156753pjb.27.2020.05.05.00.45.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 May 2020 00:45:11 -0700 (PDT) From: Eizan Miyamoto X-Google-Original-From: Eizan Miyamoto To: LKML Subject: [PATCH v1 2/2] [media] mtk-mdp: use pm_runtime in MDP component driver Date: Tue, 5 May 2020 17:44:31 +1000 Message-Id: <20200505174351.v1.2.I87cf35a058328c780bd3b8b2191209a5011b7016@changeid> X-Mailer: git-send-email 2.26.2.526.g744177e7f7-goog In-Reply-To: <20200505074431.242840-1-eizan@google.com> References: <20200505074431.242840-1-eizan@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200505_004513_640293_1246CD9B X-CRM114-Status: GOOD ( 18.24 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:641 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew-CT Chen , Minghsiu Tsai , Houlong Wei , Eizan Miyamoto , eizan@chromium.org, linux-mediatek@lists.infradead.org, Matthias Brugger , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.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@chromium.org Signed-off-by: Eizan Miyamoto --- 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 4c77a582c79a..6716baaf8788 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" @@ -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; @@ -61,25 +62,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); + 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; @@ -91,6 +98,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, @@ -100,6 +109,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; } @@ -110,6 +120,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); } @@ -128,6 +139,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 edc2ece717b5..91407150ac9e 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h @@ -12,18 +12,20 @@ * @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_deinit(struct mtk_mdp_comp *comp); -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 fe8ae4ad0d3e..33c68133e2eb 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)