From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C899C07E96 for ; Thu, 8 Jul 2021 09:28:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62AE861993 for ; Thu, 8 Jul 2021 09:28:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231324AbhGHJav (ORCPT ); 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