Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp165587pxb; Tue, 24 Aug 2021 23:40:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMBGnk1ZC0NcWHmNRbAk/D5XmNSHOtf81mjgW9MMQ/Grt1wLfWU/698cG2AD2O4CM8iPab X-Received: by 2002:a17:906:d52:: with SMTP id r18mr44235960ejh.47.1629873604886; Tue, 24 Aug 2021 23:40:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629873604; cv=none; d=google.com; s=arc-20160816; b=LO2TrcbaoqXNrMaR8Z76ITSjCRtwLCMqzur2dH/azQ4Mgzl9BZkU1vp/B3d+yYvvXV hNVTnqt82hKdOzaKkZfOYi79YGRxKUbkqzvaLB0kP6v/GUy8pw4kAdXUNhm82YtsYeeo 7zwLDJbVV9t9Sb7bCe60efWxKbG2Di/zoOuPmgpIc0QEXzbRptjvS4POVtAVig+LctF7 jygw6Re/whNMG+89F8hhb3aGBZsagF1cPHyVaMRcStoqiSEjjj1WnyOBe3YTk0BBfRm2 DQw9+6Xj5rOK8t77Q1JvZNaNbmV3yKDUC9RwwB/PRVIR6UjxDZWrzyJpsdE7xvN7cH55 Kijg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4XCVzr5iz0QopfEgURb1CQv1P9/gHJdLhnjxwl27c/s=; b=YCSiRCx/GrrvyCp3Z/iE1GnktZxZCYI2pUoiQmzW9gOSa5kJQkJbEVMbyB3/DJmxE3 4TEgadn4LOcQLdJ170trsGu0SZM8K8bVjnbvEnPRCbjJvMqOoe5HA85277WjNYAQrEud fIbI9cDuDPIcw7Msl1VFHHJnkuK7ycWSNkZzXOdUcEczY8OvKkKwBjDrP31Q3RQ8AmLw YP82qUc/vvYCqbz2VZ28scH6TWI2gUPI0s3qKxiAt6edDOjBBFAYqmNcWxaV14WNBAZi VYf1EsMPk8bANcoqWB973lo6ZubNANJM6mbgKqXt6UdKFFmDpnfPA44RPHIS0gS+z6KQ fQog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OSCABazI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w9si8891357eds.206.2021.08.24.23.39.39; Tue, 24 Aug 2021 23:40:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OSCABazI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239206AbhHYGf2 (ORCPT + 99 others); Wed, 25 Aug 2021 02:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239256AbhHYGfZ (ORCPT ); Wed, 25 Aug 2021 02:35:25 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C68C5C0613C1 for ; Tue, 24 Aug 2021 23:34:40 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id n18so22110658pgm.12 for ; Tue, 24 Aug 2021 23:34:40 -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=4XCVzr5iz0QopfEgURb1CQv1P9/gHJdLhnjxwl27c/s=; b=OSCABazIpuHyd7hIDQTR8xjHANpAJY8mVw/lMwMZAwBneWnPcgnttkDh2iZ/60ivoL pTrwGGLw7RTpT3FYMjCxF8x3hpVJaHrw9keEA77PxIv/Gbb49+gBlsptb8sCQ6GrBd4D 5qW6Kz21+aJnzT9z/MTpPBeMpeORXzsfr1FEg= 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=4XCVzr5iz0QopfEgURb1CQv1P9/gHJdLhnjxwl27c/s=; b=LUN0oUGp3Al4HwB9Rxj8l2MyMfDCOTFWHLuR94NkbCz/FkQYQJrHzFhIR+O+hgrhfu Gafw0ufrySmODZvOmnj64dhkocQI2qmVYE1jAifq5xMth5lLiTfO28Wp2VXCrS03oVJl Ar8XHm72it0ZAsFylR5LIHCoA8q4D3U8g6GPLSQh1TOA4GGkuPMghVe8viXH7rvugazI VhCBFc2nQBt1Bhf33LDkACWgyo8/DZ6zzOwAutw5m2SBVIMPFc34Squ5dWgiTzRGvW3C sX0RZMW8k0RBVIjZh3QYtxvfQeKwptOL0JJ1CfxNnOHKXyeErY1n23j7HS1b8H3/r5vp D+gQ== X-Gm-Message-State: AOAM532eJ/zsSfBqUm0oj0Bp4sylvgsx9TPVI5B4GCDCVw6ySU/vhCs9 /8TS+1py3jok8jHMo9O/x2XtGejOUMvBbw== X-Received: by 2002:a63:8f4a:: with SMTP id r10mr39177630pgn.337.1629873280107; Tue, 24 Aug 2021 23:34:40 -0700 (PDT) Received: from localhost ([2401:fa00:9:14:3f2f:9e23:8a5:952]) by smtp.gmail.com with UTF8SMTPSA id v1sm23681435pgj.40.2021.08.24.23.34.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Aug 2021 23:34:39 -0700 (PDT) From: Eizan Miyamoto To: linux-kernel@vger.kernel.org Cc: chunkuang.hu@kernel.org, yong.wu@mediatek.com, wenst@chromium.org, ck.hu@mediatek.com, houlong.wei@mediatek.com, enric.balletbo@collabora.com, yongqiang.niu@mediatek.com, Eizan Miyamoto , Andrew-CT Chen , Matthias Brugger , Mauro Carvalho Chehab , Minghsiu Tsai , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v7 7/7] media: mtk-mdp: use mdp-rdma0 alias to point to MDP master Date: Wed, 25 Aug 2021 16:33:23 +1000 Message-Id: <20210825163247.v7.7.I2049e180dca12e0d1b3178bfc7292dcf9e05ac28@changeid> X-Mailer: git-send-email 2.33.0.rc2.250.ged5fa647cd-goog In-Reply-To: <20210825063323.3607738-1-eizan@chromium.org> References: <20210825063323.3607738-1-eizan@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); -- 2.33.0.rc2.250.ged5fa647cd-goog