Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp501164pxb; Thu, 23 Sep 2021 05:02:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+j/LNP16Go00q8L5EOLuhcNEJ5zDJ4jWL+n30+39p14yfY0Kcuhg9+WvOtipVCOrLYC/W X-Received: by 2002:a17:907:2624:: with SMTP id aq4mr4624447ejc.448.1632398575127; Thu, 23 Sep 2021 05:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632398575; cv=none; d=google.com; s=arc-20160816; b=wkaEyq/zHODpj259sVJBadFJuCyXlSC/w3Ctyr63EN6zsDHw3sgpGUoKMxtkySzS1T KAyuLDqKV+7wberLtEIFe0gjQZpEwZ7OyVflvpkMvwKt2CwnP5X3yAJv6oocK/NB3qct OGOSh27C9mH88UlnrDZFj4KNcUPP+Dp4uoPQQ4AxZpCl9NVCjQhfld0WJ14D5QEIwhRa BMEYfCzsZtQ1E76VSSJPnI+MAvO24vCyTU+tlsKaLZR9MF/niZ9Ho0oUMUF2zNBdywQV iH2LuRR14j8T8ahhexmNhl9bIBBpCKY2A5xLCo/kidoJNw0K+zhDa5O+0RoQX/yajeQm leJQ== 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=NcwCoRQ1IO7Whcoe32IPAacRge8t4CjSfWCi9V6SCd8=; b=Isy9lGxeeZwSPZxv7axNsDcT+7B1I9nb4JAO4DkxoQcfpFKjsXHcxHjc4ht1MHjqI7 53hkUNGZzAVBEwscVkPdlMjGDPPd7dqQTPRizM9CzRX3wTacrmkMCDPrhmJXpOiH0Rst lgsxTIrTZQQRKZ5UrLhU9LQzQSoiwaCtUa73XXy/OzlkaJAORarOEKkIhNUpktlmhJlB PpSOV2XZ2y84hVcgquAhbl/4AlHkdVGG4M/5HXrB9lIC3+mU2/fnIsXyHveryyx5i2Df lEHDkFRx2YPLWnsYPgdzbz7V2vhrpe4YI0jCjTVvjFMKqNl4rCEYGz/sNrk7ZNIC36fr S+AQ== 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 a99si5852703edf.71.2021.09.23.05.02.30; Thu, 23 Sep 2021 05:02:55 -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 S240737AbhIWMA7 (ORCPT + 99 others); Thu, 23 Sep 2021 08:00:59 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:48374 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S240743AbhIWMA5 (ORCPT ); Thu, 23 Sep 2021 08:00:57 -0400 X-UUID: fc9c943ab4914ebbb2966de184455dad-20210923 X-UUID: fc9c943ab4914ebbb2966de184455dad-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 1970080684; Thu, 23 Sep 2021 19:59:23 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 23 Sep 2021 19:59:22 +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 19:59:21 +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 03/33] iommu/mediatek: Fix 2 HW sharing pgtable issue Date: Thu, 23 Sep 2021 19:58:10 +0800 Message-ID: <20210923115840.17813-4-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 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 d837adfd1da5..3e8f0164d26c 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -451,7 +451,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; @@ -461,7 +461,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