From patchwork Mon Aug 2 12:12:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eizan Miyamoto X-Patchwork-Id: 12413847 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86D99C4338F for ; Mon, 2 Aug 2021 12:15:26 +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 3BEEE60FA0 for ; Mon, 2 Aug 2021 12:15:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3BEEE60FA0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lrdtW7tcvkdXLNj/KrksdetOWgq+wSQq523JnjcxO6E=; b=a3aqcKDXb1yBEY hiUInez4Io2foBg/dh9kOjdhf+e2biCHvZ36bHv5Uqc2M39S3sn9kVOeR8cfGTwtvkxIT0yNPjdRn R/8kMRJ9YnN/5Rm/kpPis/yG9fJ5UUKOhRI20UWn914dKiGgtWwSGTiY5bSfTvPEQoieISJv8Npo2 39oe/laF7gJ+PNggL2EiobscEi4Wa9BjzmA9KV/NaKJMHA+mNM5UYLtlZWdFKbQ9KiMkIeU9OYzkg IbQoedo5WW9kVRBN9FWA/+8COaU9LSaHi7TmQl0/SC4ZqKQHv5apTItyB3FRnFzcF9QeSWa/PNtuY kUW/gK8GpD0MEC9TxcDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWoO-00G7nC-3B; Mon, 02 Aug 2021 12:12:52 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWoA-00G7g2-0t for linux-arm-kernel@lists.infradead.org; Mon, 02 Aug 2021 12:12:39 +0000 Received: by mail-pl1-x636.google.com with SMTP id k2so1824954plk.13 for ; Mon, 02 Aug 2021 05:12:35 -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=ZviZKKS5zt5VRJZud/1hXXwMNiDi17ry2eyhIG3EEHA=; b=eLK7SeiVe0xtM1i3VwFTzL+lvc07HgEwOf/UxdpuKGWXrPufUHub2C+iAvFg3iAAaj e48gy8OAJo/pPUK6JNmRbtBYLqUq+3FvM7sNw4jmDslD8Wt0n/3HVANJTy8Zgzt3mmKH SuHWI4FX6sgetm8GJSOkmvYZWpjGJdcpK/TD4= 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=ZviZKKS5zt5VRJZud/1hXXwMNiDi17ry2eyhIG3EEHA=; b=GZu6TcuFiiAn6zekkuAHxJuG4rnoy6PgXzlX+VMND0tKNooKBam2QWrTdNrulATqWK dPUIQhV9wzDVwnJ5xrDsW8TYw3JOkVHe1HMtV+LgDZvUqCLNFXRWfpyolbiGre5WZMMJ gC1kD2NLCkATunWowZ1t04h0uvufseqZibzLne1rgCfF/dWx09gJeT7gir8hxcIFaz59 r4BV6ch16fBhDV5NeMktaiy9KBaxGMS6I4XXoDiUElap1Utn3+UQWe19C3uxkwT1yX4y LIMNZiZ23XA7iGMvK2IPqTDkAfukvFwS1bbKFfFhVVdlSclSOooX4ebU9pRmlgaOf+D1 6QeQ== X-Gm-Message-State: AOAM530zKFoSMV6IlQnXle/3QWsLrZVpBCxjnhXM0fh+nKQ/KnN27Nso W2xofARAfK4KGVWjel/SK7M38g== X-Google-Smtp-Source: ABdhPJzufei59mRMqQWISJty4OzpCb27BEq+4Hyc8ne/YBqVK51kUqGp4k9uK7LYhl4yBPjLoUVu5w== X-Received: by 2002:a65:6243:: with SMTP id q3mr681044pgv.297.1627906355381; Mon, 02 Aug 2021 05:12:35 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:cd34:e942:c094:baef]) by smtp.gmail.com with UTF8SMTPSA id j5sm7603827pjv.56.2021.08.02.05.12.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Aug 2021 05:12:35 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: wenst@chromium.org, houlong.wei@mediatek.com, yong.wu@mediatek.com, enric.balletbo@collabora.com, devicetree@vger.kernel.org, chunkuang.hu@kernel.org, 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 v6 1/9] mtk-mdp: propagate errors from clock_on Date: Mon, 2 Aug 2021 22:12:07 +1000 Message-Id: <20210802220943.v6.1.I9db0d408ef79d300672ec0311a6bee9556801631@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210802121215.703023-1-eizan@chromium.org> References: <20210802121215.703023-1-eizan@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210802_051238_077176_E26E59AB X-CRM114-Status: GOOD ( 18.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Up until this change, many errors were logged but ignored when powering on clocks inside mtk_mdp_core. This change tries to do a better job at propagating errors back to the power management framework. Signed-off-by: Eizan Miyamoto Reviewed-by: Enric Balletbo i Serra Reviewed-by: Houlong Wei --- (no changes since v1) drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 25 ++++++++++++----- drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 2 +- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 27 ++++++++++++++----- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index b3426a551bea..76e295c8d9bc 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c @@ -13,10 +13,9 @@ #include "mtk_mdp_comp.h" - -void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) +int mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) { - int i, err; + int i, err, status; if (comp->larb_dev) { err = mtk_smi_larb_get(comp->larb_dev); @@ -30,11 +29,23 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) 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. type:%d i:%d\n", - err, comp->type, i); + if (err) { + status = err; + dev_err(dev, "failed to enable clock, err %d. i:%d\n", err, i); + goto err_clk_prepare_enable; + } + } + + return 0; + +err_clk_prepare_enable: + for (--i; i >= 0; i--) { + if (IS_ERR(comp->clk[i])) + continue; + clk_disable_unprepare(comp->clk[i]); } + + return status; } void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h index 7897766c96bb..92ab5249bcad 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h @@ -41,7 +41,7 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, struct mtk_mdp_comp *comp, enum mtk_mdp_comp_type comp_type); void mtk_mdp_comp_deinit(struct device *dev, struct mtk_mdp_comp *comp); -void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp); +int 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); diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c index 976aa1f4829b..412bbec0f735 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c @@ -52,13 +52,28 @@ static const struct of_device_id mtk_mdp_of_ids[] = { }; MODULE_DEVICE_TABLE(of, mtk_mdp_of_ids); -static void mtk_mdp_clock_on(struct mtk_mdp_dev *mdp) +static int mtk_mdp_clock_on(struct mtk_mdp_dev *mdp) { - struct device *dev = &mdp->pdev->dev; struct mtk_mdp_comp *comp_node; + int status; + struct device *dev = &mdp->pdev->dev; + int err; - list_for_each_entry(comp_node, &mdp->comp_list, node) - mtk_mdp_comp_clock_on(dev, comp_node); + list_for_each_entry(comp_node, &mdp->comp_list, node) { + err = mtk_mdp_comp_clock_on(dev, comp_node); + if (err) { + status = err; + goto err_mtk_mdp_comp_clock_on; + } + } + + return 0; + +err_mtk_mdp_comp_clock_on: + list_for_each_entry_continue_reverse(comp_node, &mdp->comp_list, node) + mtk_mdp_comp_clock_off(dev, comp_node); + + return status; } static void mtk_mdp_clock_off(struct mtk_mdp_dev *mdp) @@ -274,9 +289,7 @@ static int __maybe_unused mtk_mdp_pm_resume(struct device *dev) { struct mtk_mdp_dev *mdp = dev_get_drvdata(dev); - mtk_mdp_clock_on(mdp); - - return 0; + return mtk_mdp_clock_on(mdp); } static int __maybe_unused mtk_mdp_suspend(struct device *dev) From patchwork Mon Aug 2 12:12:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eizan Miyamoto X-Patchwork-Id: 12413849 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89BD9C4338F for ; Mon, 2 Aug 2021 12:16:01 +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 5C4BA60EFD for ; Mon, 2 Aug 2021 12:16:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5C4BA60EFD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HNb9hNo8eBqQN2gLjfH+mi+HeTR0BCRFS39jjPuFjdk=; b=AdFeuyZHGHG2Wc 7/lSsSkohTz1RYswGXk11i9CBFgF9YBpZ9pftCUr0XyOWF4042g5jg3+lTibC8PSCD1DddyEQAk9/ jMdXsZ6F7Qdjn95ZIUgbPqZwDj8t8dLeejuR/Jec+qT9rh1NSOl6vEMerPN+lY/uuUBp60rRv9JHX MMmSdPj0+2AAK9moDjfSCUtVmxh36QIUEWiPSQdbHCkNU6YCl9o3oWtyUN5pKpsNkohu4V6xttCrE y5fTQXbXfDGbw3jDNYrznxvtiESXdNCQskqf8gkxZNvay02vRUwNnlkHfWlhELw2sAdDlUOUBEs5a gHJPIkjZ6iY/FmN6fn9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWoj-00G80X-ID; Mon, 02 Aug 2021 12:13:13 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWoG-00G7jt-Bj for linux-arm-kernel@lists.infradead.org; Mon, 02 Aug 2021 12:12:47 +0000 Received: by mail-pj1-x102b.google.com with SMTP id mz5-20020a17090b3785b0290176ecf64922so31333900pjb.3 for ; Mon, 02 Aug 2021 05:12:43 -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=/7jvr3WD1JXtDvi+RPp9GZKfb7MRrG+rx9+74mxstaE=; b=oPrI2f0d/Di95u/t1/xd/L7L3kipMRsYIXKeA3XUZsLoXUh0yZXiJZPWWdgJtR/I5v QPn44y8DuKoedY3gAMGoi+q1SUl9/6++S/VZu82wehLSFVVSGc/7Uow36RwNg8bRzh0C WsYJA5WkuTpGHZF7cVacPP9IY7qhFX1aRcQT0= 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=/7jvr3WD1JXtDvi+RPp9GZKfb7MRrG+rx9+74mxstaE=; b=eP1z/+aVAdTPluCy3QTyizrYvULiRnSzMIQQZmXvo6Lt43nNA3xbLRLVsGiN8k1VEM cwr14Eu4Q/BrPWXjzcJ+7AACLFrl2AskxiB86/lUyk3gr7dbSlCUqUMUAN0SaQr3Mm1V z0U/PppnJImvW8WM1i1f5yNNXFLgmxEUQgyt2tEZeXRv/I6FbPQ5AEPpo9DqudCZTwfL h8XmjFRet4hxlJO8bmPxmBsD5oprjTtHEH0teGY0QK4GjpMkBjwRtPMHQYd/L46tamC9 ZTyk+Rz13k3OvKjv0JodH/2gKMgwAs7mqbSCiMmZ+aM5x/asPlJzqDIKilKwScPthsTt l8wg== X-Gm-Message-State: AOAM530W8MWLQsqVwpvL1qwstOnmQNgaaLK2lhVZmWZl7+zrodOeL4wV pLBHZyeD5z1jE0uc28GxzT9A3WnaJTSDtg== X-Google-Smtp-Source: ABdhPJw8QxwVfwlkjCFE2DbDdtfJA+frgPmvg4+yd2AdiZcT1Ln1hjJYusE03+/6M/VkiHDVSY1mLQ== X-Received: by 2002:a63:ef45:: with SMTP id c5mr391185pgk.78.1627906363074; Mon, 02 Aug 2021 05:12:43 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:cd34:e942:c094:baef]) by smtp.gmail.com with UTF8SMTPSA id z14sm11821821pfr.121.2021.08.02.05.12.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Aug 2021 05:12:42 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: wenst@chromium.org, houlong.wei@mediatek.com, yong.wu@mediatek.com, enric.balletbo@collabora.com, devicetree@vger.kernel.org, chunkuang.hu@kernel.org, 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 v6 2/9] mtk-mdp: add driver to probe mdp components Date: Mon, 2 Aug 2021 22:12:08 +1000 Message-Id: <20210802220943.v6.2.Ie6d1e6e39cf9b5d6b2108ae1096af34c3d55880b@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210802121215.703023-1-eizan@chromium.org> References: <20210802121215.703023-1-eizan@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210802_051244_495881_D1F882A3 X-CRM114-Status: GOOD ( 40.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Broadly, this patch (1) adds a driver for various MTK MDP components to go alongside the main MTK MDP driver, and (2) hooks them all together using the component framework. (1) Up until now, the MTK MDP driver controls 8 devices in the device tree on its own. When running tests for the hardware video decoder, we found that the iommus and LARBs were not being properly configured. To configure them, a driver for each be added to mtk_mdp_comp so that mtk_iommu_add_device() can (eventually) be called from dma_configure() inside really_probe(). (2) The integration into the component framework allows us to defer the registration with the v4l2 subsystem until all the MDP-related devices have been probed, so that the relevant device node does not become available until initialization of all the components is complete. Some notes about how the component framework has been integrated: - The driver for the rdma0 component serves double duty as the "master" (aggregate) driver as well as a component driver. This is a non-ideal compromise until a better solution is developed. This device is differentiated from the rest by checking for a "mediatek,vpu" property in the device node. - The list of mdp components remains hard-coded as mtk_mdp_comp_dt_ids[] in mtk_mdp_core.c, and as mtk_mdp_comp_driver_dt_match[] in mtk_mdp_comp.c. This unfortunate duplication of information is addressed in a following patch in this series. - The component driver calls component_add() for each device that is probed. - In mtk_mdp_probe (the "master" device), we scan the device tree for any matching nodes against mtk_mdp_comp_dt_ids, and add component matches for them. The match criteria is a matching device node pointer. - When the set of components devices that have been probed corresponds with the list that is generated by the "master", the callback to mtk_mdp_master_bind() is made, which then calls the component bind functions. - Inside mtk_mdp_master_bind(), once all the component bind functions have been called, we can then register our device to the v4l2 subsystem. - The call to pm_runtime_enable() in the master device is called after all the components have been registered by their bind() functions called by mtk_mtp_master_bind(). As a result, the list of components will not change while power management callbacks mtk_mdp_suspend()/ resume() are accessing the list of components. Signed-off-by: Eizan Miyamoto Reviewed-by: Enric Balletbo i Serra Reviewed-by: Houlong Wei --- (no changes since v1) drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 143 ++++++++++++-- drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 25 +-- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 174 +++++++++++++----- drivers/media/platform/mtk-mdp/mtk_mdp_core.h | 1 + 4 files changed, 252 insertions(+), 91 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index 76e295c8d9bc..7a0e3acffab9 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c @@ -5,13 +5,50 @@ */ #include +#include #include #include +#include #include #include #include #include "mtk_mdp_comp.h" +#include "mtk_mdp_core.h" + +/** + * enum mtk_mdp_comp_type - the MDP component + * @MTK_MDP_RDMA: Read DMA + * @MTK_MDP_RSZ: Reszer + * @MTK_MDP_WDMA: Write DMA + * @MTK_MDP_WROT: Write DMA with rotation + * @MTK_MDP_COMP_TYPE_MAX: Placeholder for num elems in this enum + */ +enum mtk_mdp_comp_type { + MTK_MDP_RDMA, + MTK_MDP_RSZ, + MTK_MDP_WDMA, + MTK_MDP_WROT, + MTK_MDP_COMP_TYPE_MAX, +}; + +static const struct of_device_id mtk_mdp_comp_driver_dt_match[] = { + { + .compatible = "mediatek,mt8173-mdp-rdma", + .data = (void *)MTK_MDP_RDMA + }, { + .compatible = "mediatek,mt8173-mdp-rsz", + .data = (void *)MTK_MDP_RSZ + }, { + .compatible = "mediatek,mt8173-mdp-wdma", + .data = (void *)MTK_MDP_WDMA + }, { + .compatible = "mediatek,mt8173-mdp-wrot", + .data = (void *)MTK_MDP_WROT + }, + { } +}; +MODULE_DEVICE_TABLE(of, mtk_mdp_comp_driver_dt_match); int mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) { @@ -20,9 +57,7 @@ int mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) if (comp->larb_dev) { err = mtk_smi_larb_get(comp->larb_dev); if (err) - dev_err(dev, - "failed to get larb, err %d. type:%d\n", - err, comp->type); + dev_err(dev, "failed to get larb, err %d.\n", err); } for (i = 0; i < ARRAY_SIZE(comp->clk); i++) { @@ -62,17 +97,41 @@ void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp) mtk_smi_larb_put(comp->larb_dev); } -int mtk_mdp_comp_init(struct device *dev, struct device_node *node, - struct mtk_mdp_comp *comp, - enum mtk_mdp_comp_type comp_type) +static int mtk_mdp_comp_bind(struct device *dev, struct device *master, void *data) +{ + struct mtk_mdp_comp *comp = dev_get_drvdata(dev); + struct mtk_mdp_dev *mdp = data; + + mtk_mdp_register_component(mdp, comp); + + return 0; +} + +static void mtk_mdp_comp_unbind(struct device *dev, struct device *master, + void *data) +{ + struct mtk_mdp_comp *comp = dev_get_drvdata(dev); + struct mtk_mdp_dev *mdp = data; + + mtk_mdp_unregister_component(mdp, comp); +} + +static const struct component_ops mtk_mdp_component_ops = { + .bind = mtk_mdp_comp_bind, + .unbind = mtk_mdp_comp_unbind, +}; + +int mtk_mdp_comp_init(struct mtk_mdp_comp *comp, struct device *dev) { struct device_node *larb_node; struct platform_device *larb_pdev; int ret; int i; + struct device_node *node = dev->of_node; + enum mtk_mdp_comp_type comp_type = + (enum mtk_mdp_comp_type)of_device_get_match_data(dev); - comp->dev_node = of_node_get(node); - comp->type = comp_type; + INIT_LIST_HEAD(&comp->node); for (i = 0; i < ARRAY_SIZE(comp->clk); i++) { comp->clk[i] = of_clk_get(node, i); @@ -80,19 +139,17 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, if (PTR_ERR(comp->clk[i]) != -EPROBE_DEFER) dev_err(dev, "Failed to get clock\n"); ret = PTR_ERR(comp->clk[i]); - goto put_dev; + goto err; } /* Only RDMA needs two clocks */ - if (comp->type != MTK_MDP_RDMA) + if (comp_type != MTK_MDP_RDMA) break; } /* Only DMA capable components need the LARB property */ comp->larb_dev = NULL; - if (comp->type != MTK_MDP_RDMA && - comp->type != MTK_MDP_WDMA && - comp->type != MTK_MDP_WROT) + if (comp_type != MTK_MDP_RDMA && comp_type != MTK_MDP_WDMA && comp_type != MTK_MDP_WROT) return 0; larb_node = of_parse_phandle(node, "mediatek,larb", 0); @@ -100,7 +157,7 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, dev_err(dev, "Missing mediadek,larb phandle in %pOF node\n", node); ret = -EINVAL; - goto put_dev; + goto err; } larb_pdev = of_find_device_by_node(larb_node); @@ -108,7 +165,7 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, dev_warn(dev, "Waiting for larb device %pOF\n", larb_node); of_node_put(larb_node); ret = -EPROBE_DEFER; - goto put_dev; + goto err; } of_node_put(larb_node); @@ -116,13 +173,59 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, return 0; -put_dev: - of_node_put(comp->dev_node); - +err: return ret; } -void mtk_mdp_comp_deinit(struct device *dev, struct mtk_mdp_comp *comp) +static int mtk_mdp_comp_probe(struct platform_device *pdev) { - of_node_put(comp->dev_node); + struct device *dev = &pdev->dev; + struct device_node *vpu_node; + int status; + struct mtk_mdp_comp *comp; + + vpu_node = of_parse_phandle(dev->of_node, "mediatek,vpu", 0); + if (vpu_node) { + of_node_put(vpu_node); + /* + * The device tree node with a mediatek,vpu property is deemed + * the MDP "master" device, we don't want to add a component + * for it in this function because the initialization for the + * master is done elsewhere. + */ + dev_info(dev, "vpu node found, not probing\n"); + return -ENODEV; + } + + comp = devm_kzalloc(dev, sizeof(*comp), GFP_KERNEL); + if (!comp) + return -ENOMEM; + + status = mtk_mdp_comp_init(comp, dev); + if (status) { + dev_err(dev, "Failed to initialize component: %d\n", status); + return status; + } + + dev_set_drvdata(dev, comp); + + return component_add(dev, &mtk_mdp_component_ops); } + +static int mtk_mdp_comp_remove(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + + component_del(dev, &mtk_mdp_component_ops); + return 0; +} + +struct platform_driver mtk_mdp_component_driver = { + .probe = mtk_mdp_comp_probe, + .remove = mtk_mdp_comp_remove, + .driver = { + .name = "mediatek-mdp-comp", + .owner = THIS_MODULE, + .of_match_table = mtk_mdp_comp_driver_dt_match, + }, +}; diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h index 92ab5249bcad..df5fc4c94f90 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h @@ -7,42 +7,23 @@ #ifndef __MTK_MDP_COMP_H__ #define __MTK_MDP_COMP_H__ -/** - * enum mtk_mdp_comp_type - the MDP component - * @MTK_MDP_RDMA: Read DMA - * @MTK_MDP_RSZ: Riszer - * @MTK_MDP_WDMA: Write DMA - * @MTK_MDP_WROT: Write DMA with rotation - */ -enum mtk_mdp_comp_type { - MTK_MDP_RDMA, - MTK_MDP_RSZ, - MTK_MDP_WDMA, - MTK_MDP_WROT, -}; - /** * struct mtk_mdp_comp - the MDP's function component data * @node: list node to track sibing MDP components - * @dev_node: component device node * @clk: clocks required for component * @larb_dev: SMI device required for component - * @type: component type */ struct mtk_mdp_comp { struct list_head node; - struct device_node *dev_node; struct clk *clk[2]; struct device *larb_dev; - enum mtk_mdp_comp_type type; }; -int mtk_mdp_comp_init(struct device *dev, struct device_node *node, - struct mtk_mdp_comp *comp, - enum mtk_mdp_comp_type comp_type); -void mtk_mdp_comp_deinit(struct device *dev, struct mtk_mdp_comp *comp); +int mtk_mdp_comp_init(struct mtk_mdp_comp *comp, struct device *dev); + int 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); +extern struct platform_driver mtk_mdp_component_driver; #endif /* __MTK_MDP_COMP_H__ */ diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c index 412bbec0f735..b813a822439a 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include +#include "mtk_mdp_comp.h" #include "mtk_mdp_core.h" #include "mtk_mdp_m2m.h" #include "mtk_vpu.h" @@ -32,16 +34,12 @@ module_param(mtk_mdp_dbg_level, int, 0644); static const struct of_device_id mtk_mdp_comp_dt_ids[] = { { .compatible = "mediatek,mt8173-mdp-rdma", - .data = (void *)MTK_MDP_RDMA }, { .compatible = "mediatek,mt8173-mdp-rsz", - .data = (void *)MTK_MDP_RSZ }, { .compatible = "mediatek,mt8173-mdp-wdma", - .data = (void *)MTK_MDP_WDMA }, { .compatible = "mediatek,mt8173-mdp-wrot", - .data = (void *)MTK_MDP_WROT }, { }, }; @@ -106,6 +104,63 @@ static void mtk_mdp_reset_handler(void *priv) queue_work(mdp->wdt_wq, &mdp->wdt_work); } +static int compare_of(struct device *dev, void *data) +{ + return dev->of_node == data; +} + +static void release_of(struct device *dev, void *data) +{ + of_node_put(data); +} + +static int mtk_mdp_master_bind(struct device *dev) +{ + int status; + struct mtk_mdp_dev *mdp = dev_get_drvdata(dev); + + mtk_mdp_register_component(mdp, &mdp->comp_self); + + status = component_bind_all(dev, mdp); + if (status) { + dev_err(dev, "Failed to bind all components: %d\n", status); + goto err_component_bind_all; + } + + status = mtk_mdp_register_m2m_device(mdp); + if (status) { + dev_err(dev, "Failed to register m2m device: %d\n", status); + goto err_mtk_mdp_register_m2m_device; + } + + pm_runtime_enable(dev); + + return 0; + +err_mtk_mdp_register_m2m_device: + component_unbind_all(dev, mdp); + +err_component_bind_all: + mtk_mdp_unregister_component(mdp, &mdp->comp_self); + + return status; +} + +static void mtk_mdp_master_unbind(struct device *dev) +{ + struct mtk_mdp_dev *mdp = dev_get_drvdata(dev); + + pm_runtime_disable(dev); + mtk_mdp_unregister_m2m_device(mdp); + component_unbind_all(dev, mdp); + mtk_mdp_unregister_component(mdp, &mdp->comp_self); +} + +static const struct component_master_ops mtk_mdp_com_ops = { + .bind = mtk_mdp_master_bind, + .unbind = mtk_mdp_master_unbind, +}; + void mtk_mdp_register_component(struct mtk_mdp_dev *mdp, struct mtk_mdp_comp *comp) { @@ -123,8 +178,8 @@ static int mtk_mdp_probe(struct platform_device *pdev) struct mtk_mdp_dev *mdp; struct device *dev = &pdev->dev; struct device_node *node, *parent; - struct mtk_mdp_comp *comp, *comp_temp; - int ret = 0; + int i, ret = 0; + struct component_match *match = NULL; mdp = devm_kzalloc(dev, sizeof(*mdp), GFP_KERNEL); if (!mdp) @@ -149,36 +204,43 @@ static int mtk_mdp_probe(struct platform_device *pdev) } /* Iterate over sibling MDP function blocks */ + i = 0; for_each_child_of_node(parent, node) { - const struct of_device_id *of_id; - enum mtk_mdp_comp_type comp_type; + struct platform_device *pdev; - of_id = of_match_node(mtk_mdp_comp_dt_ids, node); - if (!of_id) + if (!of_match_node(mtk_mdp_comp_dt_ids, node)) continue; - if (!of_device_is_available(node)) { - dev_err(dev, "Skipping disabled component %pOF\n", - node); + if (!of_device_is_available(node)) continue; - } - - comp_type = (enum mtk_mdp_comp_type)of_id->data; - comp = devm_kzalloc(dev, sizeof(*comp), GFP_KERNEL); - if (!comp) { - ret = -ENOMEM; - of_node_put(node); - goto err_comp; + pdev = of_find_device_by_node(node); + if (!pdev) { + dev_warn(dev, "Unable to find comp device %s\n", + node->full_name); + continue; } - ret = mtk_mdp_comp_init(dev, node, comp, comp_type); - if (ret) { - of_node_put(node); - goto err_comp; + /* + * Do not add a match for my own (rdma0) device node. + * I will be managing it directly instead using comp_self. + */ + if (&pdev->dev != dev) { + dev_dbg(dev, "adding match %d for: %pOF\n", i++, node); + component_match_add_release(dev, &match, release_of, + compare_of, + of_node_get(node)); } + } - mtk_mdp_register_component(mdp, comp); + /* + * Create a component for myself so that clocks can be toggled in + * clock_on(). + */ + ret = mtk_mdp_comp_init(&mdp->comp_self, dev); + if (ret) { + dev_err(dev, "Failed to initialize component\n"); + goto err_comp; } mdp->job_wq = create_singlethread_workqueue(MTK_MDP_MODULE_NAME); @@ -203,18 +265,12 @@ static int mtk_mdp_probe(struct platform_device *pdev) goto err_dev_register; } - ret = mtk_mdp_register_m2m_device(mdp); - if (ret) { - v4l2_err(&mdp->v4l2_dev, "Failed to init mem2mem device\n"); - goto err_m2m_register; - } - mdp->vpu_dev = vpu_get_plat_device(pdev); ret = vpu_wdt_reg_handler(mdp->vpu_dev, mtk_mdp_reset_handler, mdp, VPU_RST_MDP); if (ret) { dev_err(&pdev->dev, "Failed to register reset handler\n"); - goto err_m2m_register; + goto err_wdt_reg; } platform_set_drvdata(pdev, mdp); @@ -222,15 +278,25 @@ static int mtk_mdp_probe(struct platform_device *pdev) ret = vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32)); if (ret) { dev_err(&pdev->dev, "Failed to set vb2 dma mag seg size\n"); - goto err_m2m_register; + goto err_set_max_seg_size; + } + + ret = component_master_add_with_match(dev, &mtk_mdp_com_ops, match); + if (ret) { + dev_err(dev, "Component master add failed\n"); + goto err_component_master_add; } - pm_runtime_enable(dev); dev_dbg(dev, "mdp-%d registered successfully\n", mdp->id); return 0; -err_m2m_register: +err_component_master_add: + vb2_dma_contig_clear_max_seg_size(&pdev->dev); + +err_set_max_seg_size: + +err_wdt_reg: v4l2_device_unregister(&mdp->v4l2_dev); err_dev_register: @@ -242,11 +308,6 @@ static int mtk_mdp_probe(struct platform_device *pdev) err_alloc_job_wq: err_comp: - list_for_each_entry_safe(comp, comp_temp, &mdp->comp_list, node) { - mtk_mdp_unregister_component(mdp, comp); - mtk_mdp_comp_deinit(dev, comp); - } - dev_dbg(dev, "err %d\n", ret); return ret; } @@ -254,11 +315,10 @@ static int mtk_mdp_probe(struct platform_device *pdev) static int mtk_mdp_remove(struct platform_device *pdev) { struct mtk_mdp_dev *mdp = platform_get_drvdata(pdev); - struct mtk_mdp_comp *comp, *comp_temp; - pm_runtime_disable(&pdev->dev); + component_master_del(&pdev->dev, &mtk_mdp_com_ops); + vb2_dma_contig_clear_max_seg_size(&pdev->dev); - mtk_mdp_unregister_m2m_device(mdp); v4l2_device_unregister(&mdp->v4l2_dev); flush_workqueue(mdp->wdt_wq); @@ -267,10 +327,8 @@ static int mtk_mdp_remove(struct platform_device *pdev) flush_workqueue(mdp->job_wq); destroy_workqueue(mdp->job_wq); - list_for_each_entry_safe(comp, comp_temp, &mdp->comp_list, node) { - mtk_mdp_unregister_component(mdp, comp); - mtk_mdp_comp_deinit(&pdev->dev, comp); - } + if (!list_empty(&mdp->comp_list)) + dev_warn(&pdev->dev, "not all components removed\n"); dev_dbg(&pdev->dev, "%s driver unloaded\n", pdev->name); return 0; @@ -323,7 +381,25 @@ static struct platform_driver mtk_mdp_driver = { } }; -module_platform_driver(mtk_mdp_driver); +static struct platform_driver * const mtk_mdp_drivers[] = { + &mtk_mdp_driver, + &mtk_mdp_component_driver, +}; + +static int __init mtk_mdp_init(void) +{ + return platform_register_drivers(mtk_mdp_drivers, + ARRAY_SIZE(mtk_mdp_drivers)); +} + +static void __exit mtk_mdp_exit(void) +{ + platform_unregister_drivers(mtk_mdp_drivers, + ARRAY_SIZE(mtk_mdp_drivers)); +} + +module_init(mtk_mdp_init); +module_exit(mtk_mdp_exit); MODULE_AUTHOR("Houlong Wei "); MODULE_DESCRIPTION("Mediatek image processor driver"); diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h index a6e6dc36307b..8a52539b15d4 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h @@ -155,6 +155,7 @@ struct mtk_mdp_dev { struct mtk_mdp_variant *variant; u16 id; struct list_head comp_list; + struct mtk_mdp_comp comp_self; struct v4l2_m2m_dev *m2m_dev; struct list_head ctx_list; struct video_device *vdev; From patchwork Mon Aug 2 12:12:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eizan Miyamoto X-Patchwork-Id: 12413851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A56AC4320A for ; Mon, 2 Aug 2021 12:16:10 +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 5ABCB60EB2 for ; Mon, 2 Aug 2021 12:16:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5ABCB60EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9H1X1GDYb5OZXFOysdpBq6WLUrXxXmWxq5dOQTtFxJs=; b=zIyhtNDhpBxKLx DZNBF76ZO8+7z9y/OUZlmsTKAjKZDxkMNt0X7Em2rmhtNJRAJq0zrYrG12Da5yqGmUTC+xLAxL1sV y8FQq1lSWSO89IfvJQekU9Sb7i5TW1OltILp5bjYILMigsgBVBLLhrRn9694PNL2uIug08B1T9vYH S+1btmmpsuK1o4gcu0ZDby6E30mGmThb0diCBkDvg6tUWtX8mN1mX5gWDfS6lCGKAsp+APvoxR5Me NaN4ShgV07UXib1z0vUsgUcKXxHmDvZZHk1JN05a3dHHnmtC16SbY9x9sNm1ZUa9Sujp3VUaulub/ ZCnO7hXNdu/O2wJiAffw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWp9-00G8Ep-Vt; Mon, 02 Aug 2021 12:13:41 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWoP-00G7nQ-2s for linux-arm-kernel@lists.infradead.org; Mon, 02 Aug 2021 12:12:54 +0000 Received: by mail-pj1-x1032.google.com with SMTP id m10-20020a17090a34cab0290176b52c60ddso24330252pjf.4 for ; Mon, 02 Aug 2021 05:12:50 -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=okgNoCKW32CSCXrXrpg4NQCsqYV2tcQ4nicTugm8UgE=; b=lIJ8Dn8WhpZzBYunBjVvxEr04KAFSLRuuuN5OtW5cXqrLMN+EOJkra86vU1D9c8Mrb imdAnf8EjITVKF6JspUGD5aI3IIjDUXvtaTRX2KxtJ/zkWc/j0p655Ae4x26Z6mWfx/g WmDdf/xaon1QDLjEov2xyerP1kyVHtxkwa0e0= 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=okgNoCKW32CSCXrXrpg4NQCsqYV2tcQ4nicTugm8UgE=; b=lJKptqmWP2A5eTaeleCi+Fiv2xb5IAKS2XgDR0mnQFizmar9HISXP3PrqSVVr9sRjI ebn0CT4pexjt5B0EefzG0uc+Vp14PYE+4b6SrQcCCJry4odzjLGcnvVngvngYA+pBMBq jXq4BpOnIjGNqQSYEWvbfwPeWsMIp/q0xitEW8GEZPRPx+y59C9J0SChVG/e5HQdaznT ajQfR+W+tPVtcrjJyNdkUTEWO1Ujc0SXWwCFX4/yOSzonOIvJwWevIanMCSkwHVXGdkg MSYBNtfrkC6hkI+fr6tQiG7hQ1bM0kpD6+7tpPFsdeAzqdyAfU4WatDLZ7YZuFzDxa1+ upIw== X-Gm-Message-State: AOAM5338sN9vTsYaU4fTb41OzqAjcJLq8V2a2+U+CMZVGg5Z2TuoJ6fr hNhXy4YwogDM/7Rk3dS47p/aYQ== X-Google-Smtp-Source: ABdhPJy8xnwtZ9BF77lQKBzrnTUwfooI+Onr4HXjQemH2mTi0/N2oS0DDwHLErURv9b5uS4o8Eq4mg== X-Received: by 2002:a65:6a0b:: with SMTP id m11mr299972pgu.380.1627906370479; Mon, 02 Aug 2021 05:12:50 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:cd34:e942:c094:baef]) by smtp.gmail.com with UTF8SMTPSA id w18sm11311942pjg.50.2021.08.02.05.12.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Aug 2021 05:12:50 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: wenst@chromium.org, houlong.wei@mediatek.com, yong.wu@mediatek.com, enric.balletbo@collabora.com, devicetree@vger.kernel.org, chunkuang.hu@kernel.org, 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 v6 3/9] mtk-mdp: use pm_runtime in MDP component driver Date: Mon, 2 Aug 2021 22:12:09 +1000 Message-Id: <20210802220943.v6.3.I909f5375d930f5d0cc877128e30e2a67078b674c@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210802121215.703023-1-eizan@chromium.org> References: <20210802121215.703023-1-eizan@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210802_051253_138283_AA630218 X-CRM114-Status: GOOD ( 25.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.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 Miyamoto Reviewed-by: Enric Balletbo i Serra Reviewed-by: Houlong Wei --- (no changes since v1) drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 24 +++++++++++++++---- drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 6 +++-- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 7 +++--- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index 7a0e3acffab9..472c261b01e8 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "mtk_mdp_comp.h" #include "mtk_mdp_core.h" @@ -50,14 +51,22 @@ static const struct of_device_id mtk_mdp_comp_driver_dt_match[] = { }; MODULE_DEVICE_TABLE(of, mtk_mdp_comp_driver_dt_match); -int mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) +int mtk_mdp_comp_clock_on(struct mtk_mdp_comp *comp) { int i, err, status; if (comp->larb_dev) { err = mtk_smi_larb_get(comp->larb_dev); if (err) - dev_err(dev, "failed to get larb, err %d.\n", err); + dev_err(comp->dev, "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); + return err; } for (i = 0; i < ARRAY_SIZE(comp->clk); i++) { @@ -66,7 +75,7 @@ int mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) err = clk_prepare_enable(comp->clk[i]); if (err) { status = 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); goto err_clk_prepare_enable; } } @@ -80,10 +89,12 @@ int mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) clk_disable_unprepare(comp->clk[i]); } + pm_runtime_put_sync(comp->dev); + return status; } -void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp) +int mtk_mdp_comp_clock_off(struct mtk_mdp_comp *comp) { int i; @@ -95,6 +106,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); + + return pm_runtime_put_sync(comp->dev); } static int mtk_mdp_comp_bind(struct device *dev, struct device *master, void *data) @@ -103,6 +116,7 @@ static int mtk_mdp_comp_bind(struct device *dev, struct device *master, void *da struct mtk_mdp_dev *mdp = data; mtk_mdp_register_component(mdp, comp); + pm_runtime_enable(dev); return 0; } @@ -113,6 +127,7 @@ static void mtk_mdp_comp_unbind(struct device *dev, struct device *master, struct mtk_mdp_comp *comp = dev_get_drvdata(dev); struct mtk_mdp_dev *mdp = data; + pm_runtime_disable(dev); mtk_mdp_unregister_component(mdp, comp); } @@ -132,6 +147,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 df5fc4c94f90..f2e22e7e7c45 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 *dev; struct device *larb_dev; }; int mtk_mdp_comp_init(struct mtk_mdp_comp *comp, struct device *dev); -int 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); +int mtk_mdp_comp_clock_on(struct mtk_mdp_comp *comp); +int 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 b813a822439a..714154450981 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c @@ -58,7 +58,7 @@ static int mtk_mdp_clock_on(struct mtk_mdp_dev *mdp) int err; list_for_each_entry(comp_node, &mdp->comp_list, node) { - err = mtk_mdp_comp_clock_on(dev, comp_node); + err = mtk_mdp_comp_clock_on(comp_node); if (err) { status = err; goto err_mtk_mdp_comp_clock_on; @@ -69,18 +69,17 @@ static int mtk_mdp_clock_on(struct mtk_mdp_dev *mdp) err_mtk_mdp_comp_clock_on: list_for_each_entry_continue_reverse(comp_node, &mdp->comp_list, node) - mtk_mdp_comp_clock_off(dev, comp_node); + mtk_mdp_comp_clock_off(comp_node); return status; } 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) From patchwork Mon Aug 2 12:12:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eizan Miyamoto X-Patchwork-Id: 12413853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF399C4338F for ; Mon, 2 Aug 2021 12:16:17 +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 8C5DC60EB2 for ; Mon, 2 Aug 2021 12:16:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8C5DC60EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i7GWrV7KhjsFlKq+krlA3dKQjGdkQCD1mitHTL8i9b4=; b=eA1LcNlKXQq9UF aJa7O++Oix6U9lCPmKPML8sIcQxAzF43Bw4+PQklZ/CnlnU2voR7vf192VzZkGtmpApYskRWQ7cSS Ktlt8XRDkeyLFQXVOPCz61+rnlobTjmdt3rpiEtx6uCIlzRtJEOSSsHBh34a2wnv/mn38AmqAdyCt 0LP/aYddbZUbszkhrHg90cGanzo1m03njtMersFtrTg46yANHlLxdmlWN4UUsTbEzxaNpnL/u/FVR 3vRHMWLT+b1ZoueItZ2ehOsSh8+rdvzVOHXJbq4+xA6OrSJDFIT/XZJt19IjhWJYAR2+S743glCNs /mPxdEMocSDCw0uFu1bA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWpU-00G8SY-NU; Mon, 02 Aug 2021 12:14:01 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWoV-00G7sH-Bz for linux-arm-kernel@lists.infradead.org; Mon, 02 Aug 2021 12:13:04 +0000 Received: by mail-pl1-x62a.google.com with SMTP id a20so19442057plm.0 for ; Mon, 02 Aug 2021 05:12:58 -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=9YE2CSKXzatBaBz6pUhkx3L6pdQbsiKGTJg7v/y1N7E=; b=AwDh9a1bWgPNKbzE2mjTv88z7kFGwJaEx5S5g0h8AYzF15kl4BNZgSSVONxy9OVhAw /jv7S7R3rEfPCxtFeMMaTVTR9Nhf3AF+EmKDmTn8T+UWTwV8wUmUSCV1VRsVEaTCgzuH PDbAW1WZC0wUW5lxyuj1fAXPRTpzCwuazOLaY= 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=9YE2CSKXzatBaBz6pUhkx3L6pdQbsiKGTJg7v/y1N7E=; b=VcPyiUYrlrq1lIRVQUNZlqrWJ4vYjMDcEgYL842y6GjJswPngsd2mQjkmhIqmuFYbM Se+i5lO7Qgj7nFTszHyfOjkShBvhpzXlGdHJHrj9r7a5M+3wxh99tkK+kHUrzgD+sgan t6aPJ3CFgxwLSGWmACFSAafzB9QIZ1egEXwj2MOAGEr+wed4Sp4a6+1icLLxdKiSExiL 9DspiuvpnvuXZi0fHa67ogd/l2dYi/q/8s61OTyzJOftomNMsrTceEulKTWw6w4E16GX 3lp07E1ANL5zBH9FMi3jrwDCM3AdZLkURSizulAwUEUX2lw1qshojDdVI5ajWdCZEMfN bR3w== X-Gm-Message-State: AOAM533Uqv39yRJl4MDg1/0CrZpgs3udGVoqmR+uWT30LyQSushExGEM SjcAwnGaZ4K51DKFZWCb7fHviw== X-Google-Smtp-Source: ABdhPJzRSfMsrNLvL7fZd8R8HreyLVsNsDouuxxOLpPu579M666g2ZFjWYYJUbXV546RAcnpSHKTcw== X-Received: by 2002:a63:ef12:: with SMTP id u18mr2256136pgh.331.1627906378008; Mon, 02 Aug 2021 05:12:58 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:cd34:e942:c094:baef]) by smtp.gmail.com with UTF8SMTPSA id u129sm5428687pfc.59.2021.08.02.05.12.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Aug 2021 05:12:57 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: wenst@chromium.org, houlong.wei@mediatek.com, yong.wu@mediatek.com, enric.balletbo@collabora.com, devicetree@vger.kernel.org, chunkuang.hu@kernel.org, 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 v6 4/9] media: mtk-mdp: don't pm_run_time_get/put for master comp in clock_on Date: Mon, 2 Aug 2021 22:12:10 +1000 Message-Id: <20210802220943.v6.4.Ifd87681955689a08cce4c65e72ee5e8c6d09af95@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210802121215.703023-1-eizan@chromium.org> References: <20210802121215.703023-1-eizan@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210802_051259_454907_2E66C2E8 X-CRM114-Status: GOOD ( 27.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The original intent of commit 86698b9505bbc ("media: mtk-mdp: convert mtk_mdp_dev.comp array to list") was to create a list to track all the MDP components that needed to have their clocks enabled/disabled when calling mtk_mdp_comp_clock_on/off. However, there was a bug inside mtk_mdp_register_component where the args to a call to list_add were swapped. The result is that only one component was added to mtk_mdp_dev.comp_list because comp_list was instead being repeatedly added to the single element lists headed by each mtk_mdp_comp. The order of the args to list_add in mtk_mdp_register_component was fixed in https://patchwork.kernel.org/patch/11742895/ (Fix Null pointer dereference when calling list_add). Then, as a result of https://patchwork.kernel.org/patch/11530769/ (mtk-mdp: use pm_runtime in MDP component driver) if all the components are added to the component list, the mdp "master" / rdma0 component ends up having pm_runtime_get_sync() called on it twice recursively: rpm_resume+0x694/0x8f8 __pm_runtime_resume+0x7c/0xa0 ***NOTE*** mtk_mdp_comp_clock_on+0x48/0x104 [mtk_mdp] mtk_mdp_pm_resume+0x2c/0x44 [mtk_mdp] pm_generic_runtime_resume+0x34/0x48 __genpd_runtime_resume+0x6c/0x80 genpd_runtime_resume+0x104/0x1ac __rpm_callback+0x120/0x238 rpm_callback+0x34/0x8c rpm_resume+0x7a0/0x8f8 __pm_runtime_resume+0x7c/0xa0 ***NOTE*** mtk_mdp_m2m_start_streaming+0x2c/0x3c [mtk_mdp] (The calls to pm_runtime_get_sync are inlined and correspond to the calls to __pm_runtime_resume). It is not correct to have pm_runtime_get_sync called recursively and the second call will block indefinitely. As a result of all that, this change factors mtk_mdp_comp_clock_on/off into mtk_mdp_comp_power_on/off and moves the calls to pm_runtime_get/put into the power_on/off functions. This change then special-cases the master/rdma0 MDP component and does these things: - the master/rdma0 component is not added to mtk_mdp_dev.comp_list - the master/rdma0 component has its clocks (*but not power*) toggled by mtk_mpd_comp_clock_on/off inside mtk_mdp_clock_on/off. - the other components have their clocks *and* power toggled with mtk_mdp_comp_power_on/off. This change introduces the assumption that mtk_mdp_pm_resume will always be called though a callback from pm_runtime_get_sync made on the master / rdma0 component. Signed-off-by: Eizan Miyamoto Reviewed-by: Houlong Wei --- (no changes since v1) drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 57 ++++++++++++++--- drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 5 +- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 62 ++++++++++++++----- 3 files changed, 98 insertions(+), 26 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index 472c261b01e8..7b6c8a3f3455 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c @@ -51,9 +51,9 @@ static const struct of_device_id mtk_mdp_comp_driver_dt_match[] = { }; MODULE_DEVICE_TABLE(of, mtk_mdp_comp_driver_dt_match); -int mtk_mdp_comp_clock_on(struct mtk_mdp_comp *comp) +int mtk_mdp_comp_power_on(struct mtk_mdp_comp *comp) { - int i, err, status; + int status, err; if (comp->larb_dev) { err = mtk_smi_larb_get(comp->larb_dev); @@ -63,12 +63,54 @@ int mtk_mdp_comp_clock_on(struct mtk_mdp_comp *comp) err = pm_runtime_get_sync(comp->dev); if (err < 0) { - dev_err(comp->dev, - "failed to runtime get, err %d.\n", - err); + dev_err(comp->dev, "failed to runtime get, err %d.\n", err); return err; } + err = mtk_mdp_comp_clock_on(comp); + if (err) { + dev_err(comp->dev, "failed to turn on clock. err=%d", err); + status = err; + goto err_mtk_mdp_comp_clock_on; + } + + return 0; + +err_mtk_mdp_comp_clock_on: + err = pm_runtime_put_sync(comp->dev); + if (err) + dev_err(comp->dev, "failed to runtime put in cleanup. err=%d", err); + + return status; +} + +int mtk_mdp_comp_power_off(struct mtk_mdp_comp *comp) +{ + int status, err; + + mtk_mdp_comp_clock_off(comp); + + err = pm_runtime_put_sync(comp->dev); + if (err < 0) { + dev_err(comp->dev, "failed to runtime put, err %d.\n", err); + status = err; + goto err_pm_runtime_put_sync; + } + + return 0; + +err_pm_runtime_put_sync: + err = mtk_mdp_comp_clock_on(comp); + if (err) + dev_err(comp->dev, "failed to turn on clock in cleanup. err=%d", err); + + return status; +} + +int mtk_mdp_comp_clock_on(struct mtk_mdp_comp *comp) +{ + int i, err, status; + for (i = 0; i < ARRAY_SIZE(comp->clk); i++) { if (IS_ERR(comp->clk[i])) continue; @@ -94,7 +136,8 @@ int mtk_mdp_comp_clock_on(struct mtk_mdp_comp *comp) return status; } -int mtk_mdp_comp_clock_off(struct mtk_mdp_comp *comp) + +void mtk_mdp_comp_clock_off(struct mtk_mdp_comp *comp) { int i; @@ -106,8 +149,6 @@ int mtk_mdp_comp_clock_off(struct mtk_mdp_comp *comp) if (comp->larb_dev) mtk_smi_larb_put(comp->larb_dev); - - return pm_runtime_put_sync(comp->dev); } static int mtk_mdp_comp_bind(struct device *dev, struct device *master, void *data) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h index f2e22e7e7c45..e3d6aef52869 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.h @@ -23,8 +23,11 @@ struct mtk_mdp_comp { int mtk_mdp_comp_init(struct mtk_mdp_comp *comp, struct device *dev); +int mtk_mdp_comp_power_on(struct mtk_mdp_comp *comp); +int mtk_mdp_comp_power_off(struct mtk_mdp_comp *comp); + int mtk_mdp_comp_clock_on(struct mtk_mdp_comp *comp); -int mtk_mdp_comp_clock_off(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 714154450981..a72a9ba41ea6 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c @@ -57,29 +57,64 @@ static int mtk_mdp_clock_on(struct mtk_mdp_dev *mdp) struct device *dev = &mdp->pdev->dev; int err; + /* + * The master / rdma0 component will have pm_runtime_get_sync called + * on it through mtk_mdp_m2m_start_streaming, making it unnecessary to + * have mtk_mdp_comp_power_on called on it. + */ + err = mtk_mdp_comp_clock_on(&mdp->comp_self); + if (err) + return err; + list_for_each_entry(comp_node, &mdp->comp_list, node) { - err = mtk_mdp_comp_clock_on(comp_node); + err = mtk_mdp_comp_power_on(comp_node); if (err) { status = err; - goto err_mtk_mdp_comp_clock_on; + goto err_mtk_mdp_comp_power_on; } } return 0; -err_mtk_mdp_comp_clock_on: - list_for_each_entry_continue_reverse(comp_node, &mdp->comp_list, node) - mtk_mdp_comp_clock_off(comp_node); - +err_mtk_mdp_comp_power_on: + list_for_each_entry_continue_reverse(comp_node, &mdp->comp_list, node) { + err = mtk_mdp_comp_power_off(comp_node); + if (err) + dev_err(&mdp->pdev->dev, "failed to power off after error. err=%d", err); + } return status; } -static void mtk_mdp_clock_off(struct mtk_mdp_dev *mdp) +static int mtk_mdp_clock_off(struct mtk_mdp_dev *mdp) { struct mtk_mdp_comp *comp_node; + int status, err; + + list_for_each_entry(comp_node, &mdp->comp_list, node) { + err = mtk_mdp_comp_power_off(comp_node); + if (err) { + status = err; + goto err_mtk_mdp_comp_power_off; + } + } - list_for_each_entry(comp_node, &mdp->comp_list, node) - mtk_mdp_comp_clock_off(comp_node); + /* + * The master / rdma0 component will have pm_runtime_put called + * on it through mtk_mdp_m2m_stop_streaming, making it unnecessary to + * have mtk_mdp_comp_power_off called on it. + */ + mtk_mdp_comp_clock_off(&mdp->comp_self); + + return 0; + +err_mtk_mdp_comp_power_off: + list_for_each_entry_continue_reverse(comp_node, &mdp->comp_list, node) { + err = mtk_mdp_comp_power_on(comp_node); + if (err) + dev_err(&mdp->pdev->dev, "failed to power on after error. err=%d", err); + } + + return status; } static void mtk_mdp_wdt_worker(struct work_struct *work) @@ -118,8 +153,6 @@ static int mtk_mdp_master_bind(struct device *dev) int status; struct mtk_mdp_dev *mdp = dev_get_drvdata(dev); - mtk_mdp_register_component(mdp, &mdp->comp_self); - status = component_bind_all(dev, mdp); if (status) { dev_err(dev, "Failed to bind all components: %d\n", status); @@ -140,8 +173,6 @@ static int mtk_mdp_master_bind(struct device *dev) component_unbind_all(dev, mdp); err_component_bind_all: - mtk_mdp_unregister_component(mdp, &mdp->comp_self); - return status; } @@ -152,7 +183,6 @@ static void mtk_mdp_master_unbind(struct device *dev) pm_runtime_disable(dev); mtk_mdp_unregister_m2m_device(mdp); component_unbind_all(dev, mdp); - mtk_mdp_unregister_component(mdp, &mdp->comp_self); } static const struct component_master_ops mtk_mdp_com_ops = { @@ -337,9 +367,7 @@ static int __maybe_unused mtk_mdp_pm_suspend(struct device *dev) { struct mtk_mdp_dev *mdp = dev_get_drvdata(dev); - mtk_mdp_clock_off(mdp); - - return 0; + return mtk_mdp_clock_off(mdp); } static int __maybe_unused mtk_mdp_pm_resume(struct device *dev) From patchwork Mon Aug 2 12:12:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eizan Miyamoto X-Patchwork-Id: 12413855 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C12AC4338F for ; Mon, 2 Aug 2021 12:16:44 +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 286CC60F35 for ; Mon, 2 Aug 2021 12:16:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 286CC60F35 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=G+Jz+nBEx7Tb6vrvXQrnycjLclt6gVPLdsNuQtgPDms=; b=3RonIeSgyagqvc aFuPVs0dRn7yeAOwkRst3zL1biFPi5EUPVyP9h5O3gkHZoJOGAqHOVLFGepf0zXpP3n0d4UvLrTjw xn2YSQuKwPIgzW6avIpsE1fktTwSmQg4s8qPz8sOmjRlHm6U9YaUZZZoo+ajbQM2lFi47cJ4mUpE4 vGOA2QedqyjFG91fkdgU8hUSboGQaqs3UdHa9nGpLvZgaevCSxQQcmb6hrIl+iSs3C7uFKXR/jP8R azcVojYufNgTpeJjVWTDd2LxlOmJ7MRj1xwWlBmYsTjue5tCrTc0f9p7pxU6Cglz8b60ghtI5dMD4 qpk/2KN/bTTyw604EdhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWpq-00G8ca-1u; Mon, 02 Aug 2021 12:14:23 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWob-00G7xG-VF for linux-arm-kernel@lists.infradead.org; Mon, 02 Aug 2021 12:13:08 +0000 Received: by mail-pl1-x632.google.com with SMTP id u16so10839470ple.2 for ; Mon, 02 Aug 2021 05:13:05 -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=B785Zqy1TAAD5y33P7L0xAGDKCH9+Gd3Q5ZCXvE+Xgg=; b=nG9o5eHn7eElaBxQkWRS3Tmc3VEPaOALY8du5eobEwo3GIASWE6N5dX47QCyoVA01C dlak2htAr9QABwIL6tEfyNoELJXM7msE20VrgoF0359pN9Bs2Vph4HDnGHRRuNVYQLqO 3jy1nqOPj2VAovCeyXd/OXYk+qhiA62jB+VEw= 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=B785Zqy1TAAD5y33P7L0xAGDKCH9+Gd3Q5ZCXvE+Xgg=; b=O7+lMPrlSYEF8re4Brx9JKtpS9r+3CbCIFd1AkyP/3wIi0wlh/o6s1C74AedEuBBjT rP2/TxQ1y/IZWqH/fo9MEqhIhe+rtvkafskKBE88BBC8pERc1umZDgBNtw7Y1PyXb6MM u9H5n8OFZ7xWZHme/UItvbuiRe1VWPcENW2B2X8IYC2RZsPjCc4c0P5uNekEGbAv/Toi YIKj0H5OsWRk3JbACKWFNfWmiu6OkFhSv/cvPlQ1p/Ht2+TtXJGoCR+UgBzkIVRGbjrN AVsboNFQIIdrcZcLsXHUdZsfqxCIVX890fEO1707yyNd2vXox9j0tAH1UVdtccgZd7pu f2ww== X-Gm-Message-State: AOAM532cvS3rI/wIDqefDwN6xGoE+2+EPiwxNTILYYlK0/YKkqno7qEs bWcVIN3e7pE/wFzabpgmYLXkxQ== X-Google-Smtp-Source: ABdhPJySSJn3ZEFSWk4L+Rk1m6eeyIpdv8Cc/Qz+rkyBGSQom6cOC2Bw7xMVq1jgKcdrA5kWR+w8NA== X-Received: by 2002:a17:90b:153:: with SMTP id em19mr17770419pjb.158.1627906385400; Mon, 02 Aug 2021 05:13:05 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:cd34:e942:c094:baef]) by smtp.gmail.com with UTF8SMTPSA id n33sm12980186pgm.55.2021.08.02.05.13.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Aug 2021 05:13:05 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: wenst@chromium.org, houlong.wei@mediatek.com, yong.wu@mediatek.com, enric.balletbo@collabora.com, devicetree@vger.kernel.org, chunkuang.hu@kernel.org, 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 v6 5/9] mtk-mdp: make mdp driver to be loadable by platform_device_register*() Date: Mon, 2 Aug 2021 22:12:11 +1000 Message-Id: <20210802220943.v6.5.Iedb6b4f47788548b0cf7bfffae85cac917344c2f@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210802121215.703023-1-eizan@chromium.org> References: <20210802121215.703023-1-eizan@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210802_051306_071848_2DE59647 X-CRM114-Status: GOOD ( 39.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rather than hanging the MDP master component driver off of the rdma0 device, make it possible too create a "virtual" device by registering it with platform_device_register_*() to be probed by the mtk_mdp_core driver. Broadly, three interdependent things are done by this change: - Make it is possible to search for MDP devices in the device tree through the grandparent device's of_node. - v4l-related setup is moved into from the mtk_mdp_core driver to the mtk_mdp_comp driver. - Presence of a mediatek,vpu property in an MDP component device node is used to determine what device to use when dispatching DMA ops from the relevant ioctl, and also do V4L2 initialization in this case. Signed-off-by: Eizan Miyamoto Reviewed-by: Enric Balletbo i Serra Reviewed-by: Houlong Wei --- Changes in v6: - Don't propagate errors from clock_on/off as an afterthought. - Split apart modifying mdp driver to be loadable from mmsys from actually loading it from mmsys into two changs to make review easier. - Update devicetree bindings to reflect no longer needing the mediatek,vpu property in the mdp_rdma0 device node. - Some stylistic cleanups. Changes in v5: - rebase and test on 5.13-next @ e2f74b13dbe6 Changes in v4: - rebase and test on 5.13 - don't depend on https://patchwork.kernel.org/project/linux-mediatek/list/?series=464873 Changes in v3: - get mdp master from aliases instead of strcmp against of_node->name Changes in v2: - rebased onto Linux 5.12 - 100 char line length allowance was utilized in a few places - Removal of a redundant dev_err() print at the end of mtk_mdp_comp_init() - Instead of printing errors and ignoring them, I've added a patch to correctly propagate them. - Use of C style comments. - Three additional patches were added to eliminate dependency on the mediatek,vpu property inside the mdp_rdma0 device node. drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 51 ++++++++++----- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 62 ++++++------------- drivers/media/platform/mtk-mdp/mtk_mdp_core.h | 2 + drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 4 +- 4 files changed, 60 insertions(+), 59 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index 7b6c8a3f3455..85ef274841a3 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c @@ -155,8 +155,45 @@ static int mtk_mdp_comp_bind(struct device *dev, struct device *master, void *da { struct mtk_mdp_comp *comp = dev_get_drvdata(dev); struct mtk_mdp_dev *mdp = data; + struct device_node *vpu_node; mtk_mdp_register_component(mdp, comp); + + /* + * If this component has a "mediatek-vpu" property, it is responsible for + * notifying the mdp master driver about it so it can be further initialized + * later. + */ + vpu_node = of_parse_phandle(dev->of_node, "mediatek,vpu", 0); + if (vpu_node) { + int ret; + + mdp->vpu_dev = of_find_device_by_node(vpu_node); + if (WARN_ON(!mdp->vpu_dev)) { + dev_err(dev, "vpu pdev failed\n"); + of_node_put(vpu_node); + } + + ret = v4l2_device_register(dev, &mdp->v4l2_dev); + if (ret) { + dev_err(dev, "Failed to register v4l2 device\n"); + return -EINVAL; + } + + ret = vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32)); + if (ret) { + dev_err(dev, "Failed to set vb2 dma mag seg size\n"); + return -EINVAL; + } + + /* + * presence of the "mediatek,vpu" property in a device node + * indicates that it is the primary MDP rdma device and MDP DMA + * ops should be handled by its DMA callbacks. + */ + mdp->rdma_dev = dev; + } + pm_runtime_enable(dev); return 0; @@ -237,23 +274,9 @@ int mtk_mdp_comp_init(struct mtk_mdp_comp *comp, struct device *dev) static int mtk_mdp_comp_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *vpu_node; int status; struct mtk_mdp_comp *comp; - vpu_node = of_parse_phandle(dev->of_node, "mediatek,vpu", 0); - if (vpu_node) { - of_node_put(vpu_node); - /* - * The device tree node with a mediatek,vpu property is deemed - * the MDP "master" device, we don't want to add a component - * for it in this function because the initialization for the - * master is done elsewhere. - */ - dev_info(dev, "vpu node found, not probing\n"); - return -ENODEV; - } - comp = devm_kzalloc(dev, sizeof(*comp), GFP_KERNEL); if (!comp) return -ENOMEM; diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c index a72a9ba41ea6..50eafcc9993d 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c @@ -159,6 +159,17 @@ static int mtk_mdp_master_bind(struct device *dev) goto err_component_bind_all; } + if (mdp->vpu_dev) { + int ret = vpu_wdt_reg_handler(mdp->vpu_dev, mtk_mdp_reset_handler, mdp, + VPU_RST_MDP); + if (ret) { + dev_err(dev, "Failed to register reset handler\n"); + goto err_wdt_reg; + } + } else { + dev_err(dev, "no vpu_dev found\n"); + } + status = mtk_mdp_register_m2m_device(mdp); if (status) { dev_err(dev, "Failed to register m2m device: %d\n", status); @@ -170,6 +181,8 @@ static int mtk_mdp_master_bind(struct device *dev) return 0; err_mtk_mdp_register_m2m_device: + +err_wdt_reg: component_unbind_all(dev, mdp); err_component_bind_all: @@ -228,8 +241,13 @@ static int mtk_mdp_probe(struct platform_device *pdev) of_node_put(node); parent = dev->of_node; dev_warn(dev, "device tree is out of date\n"); - } else { + } else if (dev->of_node) { parent = dev->of_node->parent; + } else if (dev->parent) { + /* maybe we were created from a call to platform_device_register_data() */ + parent = dev->parent->parent->of_node; + } else { + return -ENODEV; } /* Iterate over sibling MDP function blocks */ @@ -262,16 +280,6 @@ static int mtk_mdp_probe(struct platform_device *pdev) } } - /* - * Create a component for myself so that clocks can be toggled in - * clock_on(). - */ - ret = mtk_mdp_comp_init(&mdp->comp_self, dev); - if (ret) { - dev_err(dev, "Failed to initialize component\n"); - goto err_comp; - } - mdp->job_wq = create_singlethread_workqueue(MTK_MDP_MODULE_NAME); if (!mdp->job_wq) { dev_err(&pdev->dev, "unable to alloc job workqueue\n"); @@ -287,29 +295,8 @@ static int mtk_mdp_probe(struct platform_device *pdev) } INIT_WORK(&mdp->wdt_work, mtk_mdp_wdt_worker); - ret = v4l2_device_register(dev, &mdp->v4l2_dev); - if (ret) { - dev_err(&pdev->dev, "Failed to register v4l2 device\n"); - ret = -EINVAL; - goto err_dev_register; - } - - mdp->vpu_dev = vpu_get_plat_device(pdev); - ret = vpu_wdt_reg_handler(mdp->vpu_dev, mtk_mdp_reset_handler, mdp, - VPU_RST_MDP); - if (ret) { - dev_err(&pdev->dev, "Failed to register reset handler\n"); - goto err_wdt_reg; - } - platform_set_drvdata(pdev, mdp); - ret = vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32)); - if (ret) { - dev_err(&pdev->dev, "Failed to set vb2 dma mag seg size\n"); - goto err_set_max_seg_size; - } - ret = component_master_add_with_match(dev, &mtk_mdp_com_ops, match); if (ret) { dev_err(dev, "Component master add failed\n"); @@ -321,22 +308,12 @@ static int mtk_mdp_probe(struct platform_device *pdev) return 0; err_component_master_add: - vb2_dma_contig_clear_max_seg_size(&pdev->dev); - -err_set_max_seg_size: - -err_wdt_reg: - v4l2_device_unregister(&mdp->v4l2_dev); - -err_dev_register: destroy_workqueue(mdp->wdt_wq); err_alloc_wdt_wq: destroy_workqueue(mdp->job_wq); err_alloc_job_wq: - -err_comp: dev_dbg(dev, "err %d\n", ret); return ret; } @@ -404,7 +381,6 @@ static struct platform_driver mtk_mdp_driver = { .driver = { .name = MTK_MDP_MODULE_NAME, .pm = &mtk_mdp_pm_ops, - .of_match_table = mtk_mdp_of_ids, } }; diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h index 8a52539b15d4..9fcd8b8e7c25 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.h +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.h @@ -133,6 +133,7 @@ struct mtk_mdp_variant { * struct mtk_mdp_dev - abstraction for image processor entity * @lock: the mutex protecting this data structure * @vpulock: the mutex protecting the communication with VPU + * @rdma_dev: device pointer to rdma device for MDP * @pdev: pointer to the image processor platform device * @variant: the IP variant information * @id: image processor device index (0..MTK_MDP_MAX_DEVS) @@ -151,6 +152,7 @@ struct mtk_mdp_variant { struct mtk_mdp_dev { struct mutex lock; struct mutex vpulock; + struct device *rdma_dev; struct platform_device *pdev; struct mtk_mdp_variant *variant; u16 id; diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c index f14779e7596e..9834d3bbe851 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c @@ -929,7 +929,7 @@ static int mtk_mdp_m2m_queue_init(void *priv, struct vb2_queue *src_vq, src_vq->mem_ops = &vb2_dma_contig_memops; src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; - src_vq->dev = &ctx->mdp_dev->pdev->dev; + src_vq->dev = ctx->mdp_dev->rdma_dev; src_vq->lock = &ctx->mdp_dev->lock; ret = vb2_queue_init(src_vq); @@ -944,7 +944,7 @@ static int mtk_mdp_m2m_queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->mem_ops = &vb2_dma_contig_memops; dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; - dst_vq->dev = &ctx->mdp_dev->pdev->dev; + dst_vq->dev = ctx->mdp_dev->rdma_dev; dst_vq->lock = &ctx->mdp_dev->lock; return vb2_queue_init(dst_vq); From patchwork Mon Aug 2 12:12:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eizan Miyamoto X-Patchwork-Id: 12413857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87E6FC4338F for ; Mon, 2 Aug 2021 12:17:26 +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 5669760EB2 for ; Mon, 2 Aug 2021 12:17:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5669760EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WMt2uEA1c17VO3mYH98+A3jmgdF4nTu4HvaDK3bc/cw=; b=snjBFmgogAipma M9anFGXPETq6etzlIh7UZ7yCnbirhye24w+rvhV2WkO7mByZXaS7ziC7xHp12Bu34RCw1Rs12Fta2 GPfjlmh9T3jdUcPCyzB0vwPo1Ry70H35n8v+Cp4wxwGM16EnM3K1sOPUlmeq+CNetdYnIoN0KiugS zDrBn4yaslbDXwEMI5HAlH82OjJjiylc1N0wGAZFmNexA5SrUiDwPGUXGxxOk7ytpOWUCXo+cFZQM OHeGrBenp3+2MG71eeEtXlQJAbqHZnMkk96hjptGdf7xaYyjvRS5e2bI8ssMAVEPxpGXRwFflkUjJ 0w4Q9lP+j9zcwcIpisjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWqQ-00G8ut-1O; Mon, 02 Aug 2021 12:14:58 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWoi-00G80p-KD for linux-arm-kernel@lists.infradead.org; Mon, 02 Aug 2021 12:13:14 +0000 Received: by mail-pj1-x102a.google.com with SMTP id q17-20020a17090a2e11b02901757deaf2c8so24535686pjd.0 for ; Mon, 02 Aug 2021 05:13: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=x2JtECa2IcVydNG9W9omBIT16d7EqW3TFLgJK31zJ7o=; b=eUvsQdPL/VkVnjaMbKYUtiGlRVNvPiAkh5fuwmShF9oNk/WZQ0kSW/XOFks1faLV9A RMDuDFpF3fcrm2RRfaR+8cXVmZPgqtFwsvxfahHuqk0gmcUfhKM/PHT1kHA5jEmJ+Zli YQG12rziTEbbsWhrj/rcEnlI8L7MboOCLrL9E= 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=x2JtECa2IcVydNG9W9omBIT16d7EqW3TFLgJK31zJ7o=; b=QUdxcf2bjyGnc2K0NKmI1Hbd6yEicIR18e388BSmOrYror0ApCEtAjVHYMb61NtLkg tMPgSviOBsr0DtYJRVLi+fxWOShANyn79y0ZHwZ+h3mTRmiMcGRKIfr0JhR+UUuhw+Kj V+8T+F3Nly81O7X4eF8hiX0fmW0MM6wZhrEqO3P5wxws/RVwooslOuvPG+93j1g47q0P hXXaS7Yd+obN2O0Vz5qC50m2srKelH4sM+s5PWZD9rX8FH8ADB5VxMjA9Es83R6aWl4B l8Smue3EnCd9NaAb9oE0tDY4R7y48gIbguQNcc6Kv0oZpoAsSnlY+i7JYgd2VptVX54m ZCzw== X-Gm-Message-State: AOAM530BCxrD5oG2vhSZrkxfYWQ8rkdUQTmZjwpnYz126rmRE2ElSWlO utxWtuIHPkIDVkY8BVEmEYxVMw== X-Google-Smtp-Source: ABdhPJwDDACME/3b7TMkfgVYpZwoXd52Lpsw79m+gpQ1U876rXmkAZoCr6Z2s93D5COFlJv9y4ZIlA== X-Received: by 2002:a62:ea1a:0:b029:329:a95a:fab with SMTP id t26-20020a62ea1a0000b0290329a95a0fabmr16889563pfh.31.1627906392167; Mon, 02 Aug 2021 05:13:12 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:cd34:e942:c094:baef]) by smtp.gmail.com with UTF8SMTPSA id ns4sm691855pjb.51.2021.08.02.05.13.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Aug 2021 05:13:11 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: wenst@chromium.org, houlong.wei@mediatek.com, yong.wu@mediatek.com, enric.balletbo@collabora.com, devicetree@vger.kernel.org, chunkuang.hu@kernel.org, Eizan Miyamoto , Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v6 6/9] soc: mediatek: mmsys: instantiate mdp virtual device from mmsys Date: Mon, 2 Aug 2021 22:12:12 +1000 Message-Id: <20210802220943.v6.6.Ie4214d2cc73ab276dd7c41d4f63c98e011fb42d4@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210802121215.703023-1-eizan@chromium.org> References: <20210802121215.703023-1-eizan@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210802_051312_729662_1D6B174F X-CRM114-Status: GOOD ( 17.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org A virtual device that is probed by the mtk_mdp_core driver is instantiated by the mtk_mmsys driver. This better reflects the logical organization of the hardware and driver: there are a number of hardware blocks that are used by the MDP that have no strict hierarchy, and the software driver is responsible for driving them properly. Signed-off-by: Eizan Miyamoto Reviewed-by: Enric Balletbo i Serra Reviewed-by: Houlong Wei --- (no changes since v1) drivers/soc/mediatek/mtk-mmsys.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c index 080660ef11bf..e681029fe804 100644 --- a/drivers/soc/mediatek/mtk-mmsys.c +++ b/drivers/soc/mediatek/mtk-mmsys.c @@ -97,6 +97,7 @@ static int mtk_mmsys_probe(struct platform_device *pdev) struct platform_device *clks; struct platform_device *drm; struct mtk_mmsys *mmsys; + struct platform_device *mdp; int ret; mmsys = devm_kzalloc(dev, sizeof(*mmsys), GFP_KERNEL); @@ -122,10 +123,27 @@ static int mtk_mmsys_probe(struct platform_device *pdev) PLATFORM_DEVID_AUTO, NULL, 0); if (IS_ERR(drm)) { platform_device_unregister(clks); - return PTR_ERR(drm); + ret = PTR_ERR(drm); + goto err_drm; + } + + mdp = platform_device_register_data(&pdev->dev, "mtk-mdp", + PLATFORM_DEVID_AUTO, NULL, 0); + if (IS_ERR(mdp)) { + ret = PTR_ERR(mdp); + dev_err(dev, "Failed to register mdp: %d\n", ret); + goto err_mdp; } return 0; + +err_mdp: + platform_device_unregister(drm); + +err_drm: + platform_device_unregister(clks); + + return ret; } static const struct of_device_id of_match_mtk_mmsys[] = { From patchwork Mon Aug 2 12:12:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eizan Miyamoto X-Patchwork-Id: 12413859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1480C4338F for ; Mon, 2 Aug 2021 12:18:20 +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 BAE5C60F35 for ; Mon, 2 Aug 2021 12:18:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BAE5C60F35 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ia+eLi5VoV3hO5E11/A9+1WmNRbadHxY6fgGXZW+bYI=; b=jRePv6Ynt/MMak l4RB0pPTlGKjpD9uyZcnImTbX1aFv58upITKmjRgfYLKIYwnNtAKmIcKdRIq1M0De6blHRJVRiwBi iq8Des1dRb1jp7oQmysd4gQA/iPFqhSXctmVKgC9BpQKRhsbk6YPHokxgJH4/9zbHYKcknUB6gDBy fx/8gvBbG5kMZhs6c3un0i8yOaurbgHKmX1WCRotoY91jk9aDxFTQi9VzvrwJioGoz6Vm5+9ngvgd TnIzhHeoyWN/t7NCK7czVUTAVzIkMZF1Aou6avDmvGqxzn9vw/cVQRcm+CcdIoYPmEDyqCA/GfV0g zvcfE1X4Fzl5W9jTu2Kw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWrD-00G9Km-Kd; Mon, 02 Aug 2021 12:15:48 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWoq-00G84e-Gx for linux-arm-kernel@lists.infradead.org; Mon, 02 Aug 2021 12:13:22 +0000 Received: by mail-pj1-x1033.google.com with SMTP id mz5-20020a17090b3785b0290176ecf64922so31336519pjb.3 for ; Mon, 02 Aug 2021 05:13:19 -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=/gpbHjM64OYAz0gCPb+rpa0wf0KHTzT63UhDl+3ycjs=; b=Z/TO6g1Zij/fBArk0YnbvQSOkqHr84fGjMN+iJVqk3Rty1w2ez0lW2B7fLPtL2VpPs 8PKdqlACShNdDI82PcqdTCcHzSf3aPmByJZkZ4vmayVDk9w4LMtfog890kYhmnhBBjPE DhsyddQI1l2bd1OJIH0jcLGmRcAnRF8cYjNdI= 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=/gpbHjM64OYAz0gCPb+rpa0wf0KHTzT63UhDl+3ycjs=; b=uoFbd8fgtGsSIAiLfK8yZytEiFVyl/YBwQNx3fJkvFfxJtIlwrAI9u0ypILTG9iY7+ zCZWE7hB4HjtghkpiGo+VTqNWAmei5vgzPglXEM+awIyQypfeUFJmJJWXZ8LLX0bvf27 LY3sv+g7Q3koTVrep/zY6RpGCtETrQUJEbQZpHM/Am6UJOrlMgafZl1m3lQ3rV1e25LP FzUdQo1p+3x8Uim2TtOzu7Z44hCuj9qlxWvHMins9X/EdSOprIxVW2zWCvYAZEnhAX5B odlHQfugs8jUDF6SeRs+tqLctWc0R14NDWwZTRLvwK39NLZceO0uznbDXAHJ7ltwqz8W Ncyg== X-Gm-Message-State: AOAM533Ttb/m0VaKuv6f5+85xh1R/db9/IP8bb0VyS0WHoNK029H8CeL qJE8xIOFJstM8mLHQRaZxmE8/A== X-Google-Smtp-Source: ABdhPJx31tmsHkXc1g/IvZT5EnJtmvH8V0ecEeQRWJQdPQfiS56KXi3f7RRhHyrKDzwLEzy5D+yo3A== X-Received: by 2002:a17:90a:b387:: with SMTP id e7mr16710085pjr.77.1627906399511; Mon, 02 Aug 2021 05:13:19 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:cd34:e942:c094:baef]) by smtp.gmail.com with UTF8SMTPSA id l11sm10375060pjg.22.2021.08.02.05.13.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Aug 2021 05:13:19 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: wenst@chromium.org, houlong.wei@mediatek.com, yong.wu@mediatek.com, enric.balletbo@collabora.com, devicetree@vger.kernel.org, chunkuang.hu@kernel.org, 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 v6 7/9] media: mtk-mdp: use mdp-rdma0 alias to point to MDP master Date: Mon, 2 Aug 2021 22:12:13 +1000 Message-Id: <20210802220943.v6.7.I2049e180dca12e0d1b3178bfc7292dcf9e05ac28@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210802121215.703023-1-eizan@chromium.org> References: <20210802121215.703023-1-eizan@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210802_051320_602186_EDC298C7 X-CRM114-Status: GOOD ( 28.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ... Instead of depending on the presence of a mediatek,vpu property in the device node. That property was originally added to link to the vpu node so that the mtk_mdp_core driver could pass the right device to vpu_wdt_reg_handler(). However in a previous patch in this series, the driver has been modified to search the device tree for that node instead. That property was also used to indicate the primary MDP device, so that it can be passed to the V4L2 subsystem as well as register it to be used when setting up queues in the open() callback for the filesystem device node that is created. In this case, assuming that the primary MDP device is the one with a specific alias seems useable because the alternative is to add a property to the device tree which doesn't actually represent any facet of hardware (i.e., this being the primary MDP device is a software decision). In other words, this solution is equally as arbitrary, but at least it doesn't add a property to a device node where said property is unrelated to the hardware present. Signed-off-by: Eizan Miyamoto Reviewed-by: Enric Balletbo i Serra --- (no changes since v1) drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 56 +++++++++++++------ drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 36 ++++++++---- 2 files changed, 64 insertions(+), 28 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index 85ef274841a3..9527649de98e 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c @@ -151,29 +151,50 @@ void mtk_mdp_comp_clock_off(struct mtk_mdp_comp *comp) mtk_smi_larb_put(comp->larb_dev); } -static int mtk_mdp_comp_bind(struct device *dev, struct device *master, void *data) +/* + * The MDP master device node is identified by the device tree alias + * "mdp-rdma0". + */ +static bool is_mdp_master(struct device *dev) +{ + struct device_node *aliases, *mdp_rdma0_node; + const char *mdp_rdma0_path; + + if (!dev->of_node) + return false; + + aliases = of_find_node_by_path("/aliases"); + if (!aliases) { + dev_err(dev, "no aliases found for mdp-rdma0"); + return false; + } + + mdp_rdma0_path = of_get_property(aliases, "mdp-rdma0", NULL); + if (!mdp_rdma0_path) { + dev_err(dev, "get mdp-rdma0 property of /aliases failed"); + return false; + } + + mdp_rdma0_node = of_find_node_by_path(mdp_rdma0_path); + if (!mdp_rdma0_node) { + dev_err(dev, "path resolution failed for %s", mdp_rdma0_path); + return false; + } + + return dev->of_node == mdp_rdma0_node; +} + +static int mtk_mdp_comp_bind(struct device *dev, struct device *master, + void *data) { struct mtk_mdp_comp *comp = dev_get_drvdata(dev); struct mtk_mdp_dev *mdp = data; - struct device_node *vpu_node; mtk_mdp_register_component(mdp, comp); - /* - * If this component has a "mediatek-vpu" property, it is responsible for - * notifying the mdp master driver about it so it can be further initialized - * later. - */ - vpu_node = of_parse_phandle(dev->of_node, "mediatek,vpu", 0); - if (vpu_node) { + if (is_mdp_master(dev)) { int ret; - mdp->vpu_dev = of_find_device_by_node(vpu_node); - if (WARN_ON(!mdp->vpu_dev)) { - dev_err(dev, "vpu pdev failed\n"); - of_node_put(vpu_node); - } - ret = v4l2_device_register(dev, &mdp->v4l2_dev); if (ret) { dev_err(dev, "Failed to register v4l2 device\n"); @@ -187,9 +208,8 @@ static int mtk_mdp_comp_bind(struct device *dev, struct device *master, void *da } /* - * presence of the "mediatek,vpu" property in a device node - * indicates that it is the primary MDP rdma device and MDP DMA - * ops should be handled by its DMA callbacks. + * MDP DMA ops will be handled by the DMA callbacks associated with this + * device; */ mdp->rdma_dev = dev; } diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c index 50eafcc9993d..6a775463399c 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_core.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_core.c @@ -150,8 +150,9 @@ static void release_of(struct device *dev, void *data) static int mtk_mdp_master_bind(struct device *dev) { - int status; struct mtk_mdp_dev *mdp = dev_get_drvdata(dev); + struct device_node *vpu_node; + int status; status = component_bind_all(dev, mdp); if (status) { @@ -159,15 +160,30 @@ static int mtk_mdp_master_bind(struct device *dev) goto err_component_bind_all; } - if (mdp->vpu_dev) { - int ret = vpu_wdt_reg_handler(mdp->vpu_dev, mtk_mdp_reset_handler, mdp, - VPU_RST_MDP); - if (ret) { - dev_err(dev, "Failed to register reset handler\n"); - goto err_wdt_reg; - } - } else { - dev_err(dev, "no vpu_dev found\n"); + if (mdp->rdma_dev == NULL) { + dev_err(dev, "Primary MDP device not found"); + status = -ENODEV; + goto err_component_bind_all; + } + + vpu_node = of_find_node_by_name(NULL, "vpu"); + if (!vpu_node) { + dev_err(dev, "unable to find vpu node"); + status = -ENODEV; + goto err_wdt_reg; + } + + mdp->vpu_dev = of_find_device_by_node(vpu_node); + if (!mdp->vpu_dev) { + dev_err(dev, "unable to find vpu device"); + status = -ENODEV; + goto err_wdt_reg; + } + + status = vpu_wdt_reg_handler(mdp->vpu_dev, mtk_mdp_reset_handler, mdp, VPU_RST_MDP); + if (status) { + dev_err(dev, "Failed to register reset handler\n"); + goto err_wdt_reg; } status = mtk_mdp_register_m2m_device(mdp); From patchwork Mon Aug 2 12:12:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eizan Miyamoto X-Patchwork-Id: 12413861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68B06C4338F for ; Mon, 2 Aug 2021 12:18:51 +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 3880660EB2 for ; Mon, 2 Aug 2021 12:18:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3880660EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hODb4/Fdm59rJSVWPhjWu8xeFE47IWIHive5eVtbXwQ=; b=ad9kG0bZi8oJ9h fnm3nzxduAx35tpyKYAjB+yV6+9/k2j/+BS29NN1eYzTa4YE7Mp01JrH8IUidvVVvf5Bup0u+29DN xLBM0Zhu9Rn3sanF7x6Ao/oiLTpdoMuQn+sSrWhj1O+ZzmnH+QHAioWj5MyL8fFTEo/DUXzipPvfh PGewybluMkSB3QLA1rN9m5bWIkty2F6pv2OW4jR/CYGfYQBKxdv43zfybn0b53E+UPqu1+Vo6v3kh Sn9l9inms14IRhpoiA1mkQ0O2CMHa3W399tTUwSJMtiDyEeEpj4hNFn9pRQqfEBoKoNtXo86GdWI1 0Rk+soiY+SOO0J0RREiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWs7-00G9ok-Jw; Mon, 02 Aug 2021 12:16:45 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWoy-00G89v-61 for linux-arm-kernel@lists.infradead.org; Mon, 02 Aug 2021 12:13:29 +0000 Received: by mail-pl1-x629.google.com with SMTP id e21so19374195pla.5 for ; Mon, 02 Aug 2021 05:13:27 -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=evSHLz+4lNWA1wocPlr6Y/PTZYLO3lc3/HELCGdrACQ=; b=YSApFs5j+k2H73a+L1BNT9+q1XyqgEUnnviS0LX9f02fjTbK8BRORyy0OeqXf+2Akr gRQ3CKxc282UmhLCDUaMoWNYAH4s+tHIBAUt+nfSy+8YSj3aWgh9LUUOomOW0YoyDucB 19bj4rIWcNxSb7uGQ4IBbe2n/FdrYR01+kxM4= 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=evSHLz+4lNWA1wocPlr6Y/PTZYLO3lc3/HELCGdrACQ=; b=dUTHDRBfSDT821bsa6BJjGjYkaQUIOHaiinqnbVUfH87tGWX0y5t3Drg0/RQ0Kjip3 aZgFIR6MKEwVHN681wY2CIr2E7hqdaZI+HALq6ZQmIztGjYOl+VPxuXfTsw4qEPyHI3v lqEqrhHM6k7dsfLT+GiEycXUfK3XOQ3k2PegYEWMA0UyaM0pvPY2N1od9JN8VaNgJ2LY szcvUdSrYHeFyaZThQnNxUfVTvVX7PgKGr899PPadmiYoxnom8X4cBC9C0fVUksdPEwq oYvXLYjQJZ4QQtoKQyTgyEgGKIjf+Ej7wqxIQetEDvRzo9k/rNnlYtYrQab1ndI2f5yF 54TA== X-Gm-Message-State: AOAM531Te3gq5eVqIOmD+Wh6GsKdg5r8jZ3sOMrS6G7oU13gCh3Q3qIF idTz5RdVIsJgGwEePQrAb8uT4A== X-Google-Smtp-Source: ABdhPJyMcEQ1oS5cazN7DJMVgqfk+TFt9nioGxs8aVS0gcCs7ra+9cu8JMdrbm9zXFDO7EkpYs3szw== X-Received: by 2002:a17:90a:c912:: with SMTP id v18mr16846980pjt.135.1627906407125; Mon, 02 Aug 2021 05:13:27 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:cd34:e942:c094:baef]) by smtp.gmail.com with UTF8SMTPSA id n12sm13435252pgr.2.2021.08.02.05.13.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Aug 2021 05:13:26 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: wenst@chromium.org, houlong.wei@mediatek.com, yong.wu@mediatek.com, enric.balletbo@collabora.com, devicetree@vger.kernel.org, chunkuang.hu@kernel.org, Eizan Miyamoto , Matthias Brugger , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v6 8/9] dts: mtk-mdp: remove mediatek, vpu property from primary MDP device Date: Mon, 2 Aug 2021 22:12:14 +1000 Message-Id: <20210802220943.v6.8.Ib681f06d5189351b7fda0e3dcd6b15f3863a0071@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210802121215.703023-1-eizan@chromium.org> References: <20210802121215.703023-1-eizan@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210802_051328_239335_AFF47E92 X-CRM114-Status: GOOD ( 11.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org It is no longer used by the mediatek MDP driver. Signed-off-by: Eizan Miyamoto Reviewed-by: Enric Balletbo i Serra --- (no changes since v1) arch/arm64/boot/dts/mediatek/mt8173.dtsi | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi index d502073b551f..872427748110 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi @@ -1010,7 +1010,6 @@ mdp_rdma0: rdma@14001000 { power-domains = <&spm MT8173_POWER_DOMAIN_MM>; iommus = <&iommu M4U_PORT_MDP_RDMA0>; mediatek,larb = <&larb0>; - mediatek,vpu = <&vpu>; }; mdp_rdma1: rdma@14002000 { From patchwork Mon Aug 2 12:12:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eizan Miyamoto X-Patchwork-Id: 12413863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3BDBC4338F for ; Mon, 2 Aug 2021 12:19:23 +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 8A52F60FC2 for ; Mon, 2 Aug 2021 12:19:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8A52F60FC2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4VGSQgx2DcQ+KPLV5r54tzTOokMwt4YTi7tv58ihhGg=; b=IUkdP6Ddhecaax zoeor+jU15rBtsZnFCBTglKVCzloNVJr7m9vqW9Ul3jEuQVtDRuqr1/keiqo+vdWlhMyfLTD5KF6o Hd1LN1/9v9wF6qtkwBIx7egOEwwtdaYODjoa3DjBF4TsaiGYBXaYM+fIPhIkfWvqXjQhm7cQdwifB wffSfWOwZjwFSaJWnRncoZvlQqBs5DrG7ofZAxVioCkNEUOhalABlaFk0mkKlEYSyOx8tYvVHMngp NDQVu4wpINRvNXCKJ1n8XjTcuK4RzFW9bmopssONlF6YXVXZAmyd0PoWxrW2rBjdLnngSVxHoWvoA 92d3a9xTWF2XkWmaYoNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWsr-00GAD1-Et; Mon, 02 Aug 2021 12:17:30 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAWp5-00G8F8-7R for linux-arm-kernel@lists.infradead.org; Mon, 02 Aug 2021 12:13:38 +0000 Received: by mail-pl1-x62a.google.com with SMTP id t3so17263418plg.9 for ; Mon, 02 Aug 2021 05:13:35 -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=HDPzoYjZtoVX4U5Es17iDsWrlk5dXQdhxxWK8WvZJKk=; b=HameHyIb+/s0EEF3wfW+k+xsNePhdcg72nrFLgZfi6a40siVuJWf8qwoRWpsdNhUol Ot0L6yQ0sC4+nuiyK5KdSz5PYaBFbTveqjyYaj4yu/BAffYZwt3Ibn0bzzo22mteK8Ll hPjOeb0pswAwia42lc1i8yZt+8XLUYFZiEILc= 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=HDPzoYjZtoVX4U5Es17iDsWrlk5dXQdhxxWK8WvZJKk=; b=TJXGRjyaPrl5lMVTHxRkQn1p0TzRA9epDDiiPLBJB6dso/1IEU91VP9eTu6yCW1HN1 KNcj19O1bbvBrzNhgD2UFac1Mr94ykiMEmDz9BN857Bz4DiVfwgB+sd0SeHR0tQB8wQP 5Dt6VV/ekm+AsCgP5fv3XG2Q/m0822JDX3wvV8AHKGrxAS81qIiXeKMRZWZ2wJVyHI8d ePpPXKrRUkpo8ZaTSR0Y/oJ/yAMNTtL7hgyz8UgdPVytd8jMYJQsdfSFEIY6ZVaTFx9S foONYj3mTWx9V0fhKf8phzSuoaWxH29XcbJj3w6bgxOqINqI1bZu7njW6a1WR2xPJhjx fbxQ== X-Gm-Message-State: AOAM531v7YM46Co0t9uy4kMY5twG8ZeZPUaoZst+ab7NE4f7Lc33zhge m+SReTRIwyBSKDbbcIs3mfCJyA== X-Google-Smtp-Source: ABdhPJxNe95Bvo0uxDfI4w/MLwItpJuNHSmDwr9PfTqtnF5875XwqVD2aRlV7qfPD4tT31EMdTqkdg== X-Received: by 2002:a17:90b:33ce:: with SMTP id lk14mr5959359pjb.118.1627906414646; Mon, 02 Aug 2021 05:13:34 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:cd34:e942:c094:baef]) by smtp.gmail.com with UTF8SMTPSA id i24sm11931639pfr.207.2021.08.02.05.13.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Aug 2021 05:13:34 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: wenst@chromium.org, houlong.wei@mediatek.com, yong.wu@mediatek.com, enric.balletbo@collabora.com, devicetree@vger.kernel.org, chunkuang.hu@kernel.org, Eizan Miyamoto , Andrew-CT Chen , Matthias Brugger , Mauro Carvalho Chehab , Minghsiu Tsai , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v6 9/9] dt-bindings: mediatek: remove vpu requirement from mtk-mdp Date: Mon, 2 Aug 2021 22:12:15 +1000 Message-Id: <20210802220943.v6.9.If10dbdfade9f48710e485efe79e53e6e65144a2f@changeid> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog In-Reply-To: <20210802121215.703023-1-eizan@chromium.org> References: <20210802121215.703023-1-eizan@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210802_051335_375858_D1BDD197 X-CRM114-Status: GOOD ( 11.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org It is no longer needed by the mtk-mdp driver Signed-off-by: Eizan Miyamoto Reviewed-by: Enric Balletbo i Serra Acked-by: Rob Herring --- (no changes since v1) Documentation/devicetree/bindings/media/mediatek-mdp.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/Documentation/devicetree/bindings/media/mediatek-mdp.txt b/Documentation/devicetree/bindings/media/mediatek-mdp.txt index caa24943da33..4c325585f68f 100644 --- a/Documentation/devicetree/bindings/media/mediatek-mdp.txt +++ b/Documentation/devicetree/bindings/media/mediatek-mdp.txt @@ -4,8 +4,6 @@ Media Data Path is used for scaling and color space conversion. Required properties (controller node): - compatible: "mediatek,mt8173-mdp" -- mediatek,vpu: the node of video processor unit, see - Documentation/devicetree/bindings/media/mediatek-vpu.txt for details. Required properties (all function blocks, child node): - compatible: Should be one of @@ -41,7 +39,6 @@ Example: power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>; iommus = <&iommu M4U_PORT_MDP_RDMA0>; mediatek,larb = <&larb0>; - mediatek,vpu = <&vpu>; }; mdp_rdma1: rdma@14002000 {