Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp502991pxb; Thu, 23 Sep 2021 05:04:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyLcSYgrmWaDfx+d3mvZRF6XQywkv16VgkcYIs/e+Pow5imxf4UPNaRZiqXWCs9+aYuzbz X-Received: by 2002:a50:e14b:: with SMTP id i11mr1244274edl.382.1632398686124; Thu, 23 Sep 2021 05:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632398686; cv=none; d=google.com; s=arc-20160816; b=wQMrEzdj2UuBmGgs5lY4/rgwcCxOxSSnEWQqAhGfM+b7dXQJYKyQWN3Dntf1c8shzn l+us+Ua6OfzSQ+wzIYWG5kOmQtM31wIBrfEB97wz3pmaxVWht28WlGnjYNvGlvsx1VS+ oiK5utfHEgYoUPvwDsDPG7Y/gXWgVbsGu+/38Smmsx/Ym8ogxMdh5Fnc4MZclf7krBjG Dtg/6YvpRr1YIyhvT6E4vGo3GWlXUU9orIjQE1jsyS02iVTis57fiyb/5ml9bJtse/Pp o4BLSJjVWLtu2EHkHbWOT0LSWgz0VCxCYJ3KhsYEf22BFVcwJ8dN5XK3G3QrRB+IJ+Yk VC4g== 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=aQVR1vbBuClhcqfn2lGJCym+IVWzpkB26hvV/CbL94I=; b=h9UCSyEm90FKhzoIXTF04hHSkBOpVQ0uBgp/fZy4wEzn3VXT0ze3zphf/UNRhmn+8Y NBdDvB+VbRIQJqTIZyF4v3KJmhzWPAPt5Q+XNS7Gz93p4Kr6q4oSsIHOUXDWzOZZMsub lOQtjV/1yqXZ6FguQwefYTeDbLJyChDYqd0HN7mINWWpLiaKVvQkulbSUUYnYwDwx71D tUV7Bzhe9D/En2hSWltZlV/Do3GJCYo6ak1X42g3C5Ac9PSeolqPAEK4ypQb0ADbL00N iVRzdJBD/SsupaTpRbMp4gFOj2nBnspuUru0blDEota0nhk2voqWj03nZKKLUF0D/XPq bCTA== 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 m17si5593129ejl.668.2021.09.23.05.04.19; Thu, 23 Sep 2021 05:04:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240906AbhIWMDg (ORCPT + 99 others); Thu, 23 Sep 2021 08:03:36 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:54094 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S240847AbhIWMDc (ORCPT ); Thu, 23 Sep 2021 08:03:32 -0400 X-UUID: 83d4b37d4b0e46f78f745f080b91e9b5-20210923 X-UUID: 83d4b37d4b0e46f78f745f080b91e9b5-20210923 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1506941841; Thu, 23 Sep 2021 20:01:59 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 23 Sep 2021 20:01:57 +0800 Received: from localhost.localdomain (10.17.3.154) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 23 Sep 2021 20:01:56 +0800 From: Yong Wu To: Joerg Roedel , Rob Herring , Matthias Brugger , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Tomasz Figa , , , , , , , Hsin-Yi Wang , , , , , Subject: [PATCH v3 18/33] iommu/mediatek: Adjust device link when it is sub-common Date: Thu, 23 Sep 2021 19:58:25 +0800 Message-ID: <20210923115840.17813-19-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210923115840.17813-1-yong.wu@mediatek.com> References: <20210923115840.17813-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 --- 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 2ebbb3412cb9..faea4a0d922f 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -786,9 +786,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); @@ -822,11 +822,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