Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp527674pxb; Thu, 12 Aug 2021 23:56:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbveNg6L/8SJnkhQXpEo/RHXeB228yoI+zPEAO0YNRz7gcMZ8bemxgefxWaYhst8s+OAXl X-Received: by 2002:a02:cb46:: with SMTP id k6mr900936jap.15.1628837777301; Thu, 12 Aug 2021 23:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628837777; cv=none; d=google.com; s=arc-20160816; b=C0Cdst+h2018oW/fs+vkBgIEt+iLPjkzqrJX3r+kiIhNAUQfg8VkaoUs5YX4i5r8UH VW1uFOEaQQwrWiRb0fKVgB/yoycT4iqjirHBCcoXX0L+xwlBTLVxAQYjjQlzLQh2bwGq aAdsTiDAEgb//7VjlHVlDuwqDQOB7/m9l2EgpE50f5XJpOqp9QYG8AXEFiJQqg0oZtA8 4PTvurnMGxW0XAaoxCwIxmA06S+hCRWKDv7Hi0nu9MuctseLyGp3jZZ9I/Jo9OWW1SF+ j17A32jlWHEmsHonpno12myfTjQUz++QfKQe9czWWtUcY/hUMcUrmwJ6xcGci2yoFve/ Q4NA== 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=djRoGhbnqwIcm1NPrzp7/shmnstSA+vjreMJjG7EdKc=; b=bdEdfCncXhmSNGC8TDbV3Q1e/YZC0z1+e1H22/Bd/fHedVqucIjdzQsL87zL1fh7e+ gBLFapqwSkB6x0ftTI3spxq2ZBjHUEPqdTrp7Kslh+oiTQamgnd/TjsOqK7YFiE6R/sd Ca8Cvnzu16SW4cfFe8HhhHUz5VqkIclwQiR4W4JqZ1bvlTs8Iy+TVauzM4Fx7cj2XnpC Vh5Rkfe++2kTKP0VhOFuZMApvyC7uFwunoEe1aypOYZ+FJmQ0AYxqX6t7xn3PJftrSrn KxoSHRpRGa6sj3hSa9XXchOX50my5ZMtKqSuq1ogisy4KtEL8Nc2Xf5rGlyyhyeANz/i dKNg== 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 x22si729138jat.14.2021.08.12.23.56.06; Thu, 12 Aug 2021 23:56:17 -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 S238998AbhHMGyf (ORCPT + 99 others); Fri, 13 Aug 2021 02:54:35 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:35034 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S239001AbhHMGye (ORCPT ); Fri, 13 Aug 2021 02:54:34 -0400 X-UUID: 444af124558d4efd83f0d05142a13c92-20210813 X-UUID: 444af124558d4efd83f0d05142a13c92-20210813 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1513341168; Fri, 13 Aug 2021 14:54:05 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 13 Aug 2021 14:54:03 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 13 Aug 2021 14:54:02 +0800 From: Yong Wu To: Joerg Roedel , Rob Herring , Matthias Brugger , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Subject: [PATCH v2 03/29] iommu/mediatek: Fix 2 HW sharing pgtable issue Date: Fri, 13 Aug 2021 14:52:58 +0800 Message-ID: <20210813065324.29220-4-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210813065324.29220-1-yong.wu@mediatek.com> References: <20210813065324.29220-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 6f7c69688ce2..2fd2a3ae88f0 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -458,7 +458,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; @@ -468,7 +468,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