Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4175748pxb; Tue, 25 Jan 2022 05:10:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaILRI00He77g9DILucupuSQZW+f2Qj71tqHGpRNIzf0d51xDFCWhlNkmP1zAEeZse/6jr X-Received: by 2002:a17:907:a40b:: with SMTP id sg11mr16061639ejc.496.1643116233746; Tue, 25 Jan 2022 05:10:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643116233; cv=none; d=google.com; s=arc-20160816; b=Gr9y6fZFvYoakdKTEZ6JC9G0ZAI7YXgDa+skEf5YvI7Xfj1Q6OyTwDQVDbO9wlZRoQ G7mcRZ65eqZjVHGcQ+duEJYNwXvKMiFoBktJN1mtflHVUoTcicUAuNXDrMeo1/7VOVGu j/ZkDEa72LH2vZEf/dDeMgQ+922A3au+8EC7UGi+E3LkhyQr9i1YyURUUVd0DHfbX1w+ 2JEMrxfbEsNi8lhkz/4lq80Qfsj682AFatHBp2XjaCAZu5Eurw+0sY2SlWp5rAYa7aJX OmfREAB3sIkz9RysCkf7QvMoNrFV26mrzfKNS9rtgK8ZjxuejbUTE2r4Wni0QAh6IAkU /FnQ== 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=U53adgNUXSSwyM6wJYxKoj9z4eWogE69bvnNNMIXY5c=; b=JVfPTtKZgoUu/SP+Ip5BHVTzAtlDLqTkY7XydaCdJW/amTCPuRMCA3AaIrMSN5/9wl +SZ6PrvmNxdSGZtAL9BSiwBBThSdqvPO0Shx5KVp5jmacg/hkmTpu9ZUD1BKak44LIZA gbAmqWbWGRgrQeAUkJq5SfziZeBonAb2LhLkkfO6Cv4Cwe9gxo46gzr6yGRWlvdIqGMz 2tdxkWoSbUS1zUuxjytKquNomhk04wD2SXqb+uOssPqRVJvXsQhqkAgeOJp7wXAJUh6x 6abCunvCauNWllMUnhO+JoOPYM6Y9qR+DCtRvmjBT7Ad11m3JIV55AHnU0xD7mpBYNky mrEw== 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 f10si11307237edd.4.2022.01.25.05.10.08; Tue, 25 Jan 2022 05:10:33 -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 S1456814AbiAYJNB (ORCPT + 99 others); Tue, 25 Jan 2022 04:13:01 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:36166 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S235782AbiAYI5Y (ORCPT ); Tue, 25 Jan 2022 03:57:24 -0500 X-UUID: 3a34ca8f93ff4b7b8c3f69c55b079165-20220125 X-UUID: 3a34ca8f93ff4b7b8c3f69c55b079165-20220125 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 433771288; Tue, 25 Jan 2022 16:57:15 +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:57:14 +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:57:13 +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 03/35] iommu/mediatek: Fix 2 HW sharing pgtable issue Date: Tue, 25 Jan 2022 16:56:02 +0800 Message-ID: <20220125085634.17972-4-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 In the commit 4f956c97d26b ("iommu/mediatek: Move domain_finalise into attach_device"), I overlooked the sharing pgtable case. After that commit, the "data" in the mtk_iommu_domain_finalise always is the data of the current IOMMU HW. Fix this for the sharing pgtable case. Only affect mt2712 which is the only SoC that share pgtable currently. Fixes: 4f956c97d26b ("iommu/mediatek: Move domain_finalise into attach_device") Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index eb43e7edb9dc..a92b01805232 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -446,7 +446,7 @@ static void mtk_iommu_domain_free(struct iommu_domain *domain) static int mtk_iommu_attach_device(struct iommu_domain *domain, struct device *dev) { - struct mtk_iommu_data *data = dev_iommu_priv_get(dev); + struct mtk_iommu_data *data = dev_iommu_priv_get(dev), *frstdata; struct mtk_iommu_domain *dom = to_mtk_domain(domain); struct device *m4udev = data->dev; int ret, domid; @@ -456,7 +456,10 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain, return domid; if (!dom->data) { - if (mtk_iommu_domain_finalise(dom, data, domid)) + /* Data is in the frstdata in sharing pgtable case. */ + frstdata = mtk_iommu_get_m4u_data(); + + if (mtk_iommu_domain_finalise(dom, frstdata, domid)) return -ENODEV; dom->data = data; } -- 2.18.0