Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2203516iof; Tue, 7 Jun 2022 23:06:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQpiz5wGURbggZv9TTNM56RcuKV/sDvJaXk80cuyHzKRmfwWMdYJESfuLivyYOYrdo//bu X-Received: by 2002:a17:90a:c4f:b0:1df:a178:897f with SMTP id u15-20020a17090a0c4f00b001dfa178897fmr36080939pje.19.1654668405917; Tue, 07 Jun 2022 23:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668405; cv=none; d=google.com; s=arc-20160816; b=xArJb6U/WMlmjX9gaKZ7v0sZf3ADINsdun7qYANfldcoJg/2qU+/aCkbmxouhGYNYK IHICU1RcyNIvNgxaq5WzcOFpQ7ZPqEdsR368ZYyyKiZvw2OSvwsNHoF4AqJXaGj9UHw/ 0jXr0N1jP6iNnkFeovGix2xZ9lY5bz+Uv/vTz7rGeFkJwNS23kXX2527CePNpHzDg/ah CYLRuubjI/s4NlmXVI0dQe8g83WSPosiXHwfwzqK1zU65hhsqBLr+LQQsIEFFDcoRumA WVon9oVdEJqcyAcieYv3aGDPe3a1YSTxZItNIoNtWuGfe4tarE8/mk+VqMxqFfg/dEDn V32Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8YdayoeW3lxeHtbwRW/wgaJ0UPvvfQ0Yi+8eEGN6fQ8=; b=vU6XIzZ8GWoPKe1dwX8rNbNFljYvoioM83R8/JAnPafL5ayfvQZyw8sUZw4A5vEIeI EdwCWyvREJ4QS6j8gxI8zMclBGudBX02T4AHBM7zWi/Up1LbN6dToZoPD778FGGpvtY0 bzbtgqGx9VyTaYhoC3ccUgpbve2h8GCc+TveeV8QdXtDwvuvbUYX4vp69J37EljJY7AC lLFyTA2KO1picEYOpHT/doAlABqJeEic1LvrGwgJ4nBPJue4aZa0kyqhLclwFRkXG44N d6YzixU2HfqpoTxLnbWZ3RTTLvbPy79X7bXdVFokTGFzGMvTmntDNRGXJZcKXgRhlUNF FEsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ede9HT0K; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w123-20020a636281000000b003c219383924si25897093pgb.465.2022.06.07.23.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:06:45 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ede9HT0K; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7E68A10636C; Tue, 7 Jun 2022 22:30:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390157AbiFHB3C (ORCPT + 99 others); Tue, 7 Jun 2022 21:29:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382591AbiFGWEw (ORCPT ); Tue, 7 Jun 2022 18:04:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ACA8195911; Tue, 7 Jun 2022 12:16:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 275EA61846; Tue, 7 Jun 2022 19:16:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BE2AC385A2; Tue, 7 Jun 2022 19:16:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629364; bh=XWpk6V/154R5tELQENQl5ceIwIAimCa0bLUYtlrSCjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ede9HT0Kg5kHnwAkf7R7a100f5SsZM+3hQhMvkcn2NJ+pFhH0eEcq/NgcdmPSYaZz GsaDEIrQVhF4XXkvsEtY5rYv0/fIFoDJgkQt9LllU4Mz9TcLOQQWsVjpvGx+xWyyyH HV2FU78HiowTeTbokQXtSHf7oXhWuHuD8UGt0PSg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yong Wu , AngeloGioacchino Del Regno , Matthias Brugger , Joerg Roedel , Sasha Levin Subject: [PATCH 5.18 664/879] iommu/mediatek: Fix 2 HW sharing pgtable issue Date: Tue, 7 Jun 2022 19:03:02 +0200 Message-Id: <20220607165022.119559056@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yong Wu [ Upstream commit 645b87c190c959e9bb4f216b8c4add4ee880451a ] 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 Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Matthias Brugger Link: https://lore.kernel.org/r/20220503071427.2285-5-yong.wu@mediatek.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- 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 6fd75a60abd6..95c82b8bcc35 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.35.1