Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4195814pxb; Tue, 25 Jan 2022 05:35:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJywT91YwfmFL/nWzxLpCkRFgDOPfWxV1mqYfr9mDJ3V5rRiR1sP+ojxYizxhhO1ytYj9Vlt X-Received: by 2002:a62:3003:0:b0:4c1:6983:f1c3 with SMTP id w3-20020a623003000000b004c16983f1c3mr18161103pfw.20.1643117730566; Tue, 25 Jan 2022 05:35:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643117730; cv=none; d=google.com; s=arc-20160816; b=uBQD04E/DsomIyWhtCLve3xwug7TF6I8Y38qjnsSN/8aKwp9w1ZuHU//dueefJXM9i 5zvCPvDrxOAACQFFrkpJ5hxsz5Evr5snEvxXdhYeJJByAOH/Q60O0TOi5QB2D5Tx9bPG b/s1/Oe9FK9JZiwEPhVT3bHRZ7cC+ADImSMFHRkFbOryyj9qqLbsZ3YO/WwM3LPagYnN I6c+iv4gONCBCoqXV2HQycvmYQo62O/KeJ4rXQxM11NCLubAzJi6L66Gamh3j2cIVbfA +0uFzB0O9gmlgBi7tlj7N6wH0h+SrIdF0TfOO6QWIcqRPMdRB0QV/zxbOKbEhI+RPAal RYzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=0edzcHGBXRSvpz9My8K4F4kVAWZLvklcmwT6CuXEjoc=; b=gaYd6/rVVWc3qqURat8QGeQrvRN+TVmsTnw1WnXPrqrM07n1ZgedLLayM3hIuEz5Dl XdUCfgsXS4S4fKspNo7HGOVbC3kmy8NTlH7mhVPjwCT+rl50a/zQiB6PjokZzA+xzXmg URvQtMz125gwPdEqrgR1IlhjXvamNQCi4kxZoPD1VOWEm6rfVq/w+nu34HK5RHkoorPQ Ae2SExRUxgt9aFm0XwIWGaUz5WCuFz+dAsmWuYqP8Ep4D5VD+VdFY+uJVoK8MMA9bMDt ygFsr5nwUrOpjUet4lJ2wqWst7BfrVdQ2O2vf8vOZDVnd+1OFxGQBJxeKskueXho8tNI 4gfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y2si7610138plg.43.2022.01.25.05.35.16; Tue, 25 Jan 2022 05:35:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1457537AbiAYJPx (ORCPT + 99 others); Tue, 25 Jan 2022 04:15:53 -0500 Received: from mailgw01.mediatek.com ([60.244.123.138]:59672 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S245144AbiAYJAA (ORCPT ); Tue, 25 Jan 2022 04:00:00 -0500 X-UUID: 64000213096a498fa612694f46a8d1ff-20220125 X-UUID: 64000213096a498fa612694f46a8d1ff-20220125 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1183919896; Tue, 25 Jan 2022 16:59:24 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Tue, 25 Jan 2022 16:59:22 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 25 Jan 2022 16:59:21 +0800 From: Yong Wu To: Joerg Roedel , Rob Herring , "Matthias Brugger" , Will Deacon CC: Robin Murphy , Krzysztof Kozlowski , Tomasz Figa , , , , , , , Hsin-Yi Wang , , , , , , "AngeloGioacchino Del Regno" , , , , Subject: [PATCH v4 18/35] iommu/mediatek: Adjust device link when it is sub-common Date: Tue, 25 Jan 2022 16:56:17 +0800 Message-ID: <20220125085634.17972-19-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220125085634.17972-1-yong.wu@mediatek.com> References: <20220125085634.17972-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For MM IOMMU, We always add device link between smi-common and IOMMU HW. In mt8195, we add smi-sub-common. Thus, if the node is sub-common, we still need find again to get smi-common, then do device link. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 71f3acd00d8c..f676085af13d 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -798,9 +798,9 @@ static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **match, struct mtk_iommu_data *data) { + struct device_node *larbnode, *smicomm_node, *smi_subcomm_node; struct platform_device *plarbdev; struct device_link *link; - struct device_node *larbnode, *smicomm_node; int i, larb_nr, ret; larb_nr = of_count_phandle_with_args(dev->of_node, "mediatek,larbs", NULL); @@ -834,11 +834,21 @@ static int mtk_iommu_mm_dts_parse(struct device *dev, compare_of, larbnode); } - /* Get smi-common dev from the last larb. */ - smicomm_node = of_parse_phandle(larbnode, "mediatek,smi", 0); - if (!smicomm_node) + /* Get smi-(sub)-common dev from the last larb. */ + smi_subcomm_node = of_parse_phandle(larbnode, "mediatek,smi", 0); + if (!smi_subcomm_node) return -EINVAL; + /* + * It may have two level smi-common. the node is smi-sub-common if it + * has a new mediatek,smi property. otherwise it is smi-commmon. + */ + smicomm_node = of_parse_phandle(smi_subcomm_node, "mediatek,smi", 0); + if (smicomm_node) + of_node_put(smi_subcomm_node); + else + smicomm_node = smi_subcomm_node; + plarbdev = of_find_device_by_node(smicomm_node); of_node_put(smicomm_node); data->smicomm_dev = &plarbdev->dev; -- 2.18.0