Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp284605pxv; Thu, 8 Jul 2021 02:29:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzf5OV52b4Jg8ndIL0lVVCF+o/HjOMnEyKTmM1Lf4X+C25b09LJ7DtY9zRb7uhlSeNzuhFF X-Received: by 2002:aa7:dad3:: with SMTP id x19mr19451507eds.310.1625736565824; Thu, 08 Jul 2021 02:29:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625736565; cv=none; d=google.com; s=arc-20160816; b=rluzGGs4vFlvYyMBHl65NX9IfADZ/lvCKT8cmrqrkXmc7HCzQGdmse/dUJ2yuXvA/L hXl5hVshL2FJQ8F39WqAhwYdpRcwuKrt8sm7KWzCMchd6ixo+UidQEB2MI0OL9m+fYVQ 1n6JelrXAZ8odC9BbIhSCdXMBLOkN01uchiICzcfkwQ9ay0nkucUtCOKEzoSo3I3Om/v N0GwJRVIC3dB9xrN8zK62HMSIv5kwKuYudNCMgZksm6V3Q4yZRphF4YdjNGJIuIiUO0E nZLbOAN++oJH9F4KrzXWm7XhvqmH/g5drXQJA2kdL7574Fn8XUOqWbLyoMFIoJkqMOc7 ZEcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=TAVATU5f3bZPcRGAbVtJuN9qIepdt4X6UbIj+um0BYQ=; b=XiBTZv47yTBqVKE7EBkBiAHKBv1fg+wZ8SPeEjUc6jJGh4CnW7r7aaBIf7VHNNN6qb Obf5TQSXgroHeq5uUNiGSXP5DwcQEVsr9mHgFM/u4SBqOQSJ6bP00AJURR7daKPl0Zsb 77IcXonaRWXHygnroMWAlSiGf8yF/qX+egCiJZKLiMh4cw3qAgRI3laDb56YHBaOuG0O ZNQfCSLYmm+nv5K8whhF6fcezJMPiUx9OByosqLWgaQiMCIcEe5B4dFkuE6pJt5e8HN+ VZV3ut9Rd8ugfDj4J9Yq6ani6v43A20nM2eQ8MT/92hW9ImE9XLFpO7iUFjV01kKJApo z19A== 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=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h3si2237462edf.193.2021.07.08.02.29.03; Thu, 08 Jul 2021 02:29:25 -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=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231336AbhGHJav (ORCPT + 99 others); Thu, 8 Jul 2021 05:30:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231254AbhGHJau (ORCPT ); Thu, 8 Jul 2021 05:30:50 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE971C061574 for ; Thu, 8 Jul 2021 02:28:08 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id 91EC8312; Thu, 8 Jul 2021 11:28:06 +0200 (CEST) Date: Thu, 8 Jul 2021 11:28:05 +0200 From: Joerg Roedel To: Kai-Heng Feng Cc: will@kernel.org, Robin Murphy , "open list:AMD IOMMU (AMD-VI)" , open list Subject: Re: [PATCH] iommu/amd: Enable swiotlb if any device supports iommu v2 and uses identity mapping Message-ID: References: <20210708074232.924844-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210708074232.924844-1-kai.heng.feng@canonical.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 08, 2021 at 03:42:32PM +0800, Kai-Heng Feng wrote: > @@ -344,6 +344,9 @@ static int iommu_init_device(struct device *dev) > > iommu = amd_iommu_rlookup_table[dev_data->devid]; > dev_data->iommu_v2 = iommu->is_iommu_v2; > + > + if (dev_data->iommu_v2) > + swiotlb = 1; This looks like the big hammer, as it will affect all other systems where the AMD GPUs are in their own group. What is needed here is an explicit check whether a non-iommu-v2 device is direct-mapped because it shares a group with the GPU, and only enable swiotlb in this case. Thanks, Joerg