Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp118961pxb; Tue, 15 Feb 2022 06:43:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWacfWEF1M7ci+QLVFE8+FBRNRPStctm19bQasTq/XU8P9S5XV5Y26MJIo+1O9mcImG7/m X-Received: by 2002:a17:907:8a1a:: with SMTP id sc26mr3178817ejc.310.1644936198790; Tue, 15 Feb 2022 06:43:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644936198; cv=none; d=google.com; s=arc-20160816; b=JHiY9NlVie26uqRLpTErdc301aw+WT3Imo4AcjaIAxY59ig0jLzt51kcCCNo4RxQkG y3aX+BFVGv51zm6PS2AaxhAaB8B/X5kIXH5gQtddD+oNY8deWVQ7B1OFvxdQotx+tQBo yYgbJWmrGdqNXRgxQOrgBjntpv984L50FRG0VXAsHKDr8SZ3i56m+7k4ElkRbcHu97Vn kW/cVoITEQQ6RRWJR40XlsEWvHQafmW+yF9SgOFM6ujdMkk2voJ9yLQ94xRmoJ6aDWe3 zA2CMqhO1lLNrNs4WvuZVeHxoMBEuSWD2FtuHXvN8Kq5URZd2oYOdh6+wrgrbjbGnC8l p5GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=tH/LNUVkeuyf/BHonLIlkK3yZ7J2XhjPcuur6ISslUY=; b=WkoXxLXvUVQ1iicN/CHaA4zBmKxZzv3IVmQT7I8RT4tF5DE4n/lGzcEzpDb7Qajh2y fxuEbumlMFGjYUhShNjsj/DwMgBxHODfsqtxEV1EGgQgdk9+5od4/yIRwAtenmRKaO98 8hbnLBRKpHRH8ghDqKD7SvhGO3qo3gPyGnJxdI2AeFUJ2r3OSWLv18049WI+VV56qEcl 4y3xDv+D7fmGrgV6iPq45gDVzhJNlISgtxo/YldJbAQYX6XSIC0lhYT7iuLFswyGJjH4 HfRgkffJQ4JvaTyAQ9yyo4jdX1uEueYWhrN01PLa9UXczfBwPbHhdGE+rJItL7o2upsR M6ug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa13si5741210ejc.770.2022.02.15.06.42.55; Tue, 15 Feb 2022 06:43:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238056AbiBONDS (ORCPT + 99 others); Tue, 15 Feb 2022 08:03:18 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235227AbiBONDR (ORCPT ); Tue, 15 Feb 2022 08:03:17 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7E8899FB52; Tue, 15 Feb 2022 05:03:07 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2C0581480; Tue, 15 Feb 2022 05:03:07 -0800 (PST) Received: from [10.57.70.89] (unknown [10.57.70.89]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D094A3F718; Tue, 15 Feb 2022 05:03:02 -0800 (PST) Message-ID: Date: Tue, 15 Feb 2022 13:02:58 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [PATCH v1 5/8] iommu/amd: Use iommu_attach/detach_device() Content-Language: en-GB To: Joerg Roedel , Jason Gunthorpe Cc: Lu Baolu , Alex Williamson , Christoph Hellwig , Kevin Tian , Ashok Raj , Greg Kroah-Hartman , Bjorn Helgaas , Will Deacon , Dan Williams , rafael@kernel.org, Diana Craciun , Cornelia Huck , Eric Auger , Liu Yi L , Jacob jun Pan , Chaitanya Kulkarni , Stuart Yoder , Laurentiu Tudor , Thierry Reding , David Airlie , Daniel Vetter , Jonathan Hunter , Li Yang , Dmitry Osipenko , iommu@lists.linux-foundation.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220106022053.2406748-1-baolu.lu@linux.intel.com> <20220106022053.2406748-6-baolu.lu@linux.intel.com> <20220106143345.GC2328285@nvidia.com> <20220214131544.GX4160@nvidia.com> <20220214140236.GC929467@nvidia.com> <20220214150059.GE4160@nvidia.com> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On 2022-02-15 09:11, Joerg Roedel wrote: > On Mon, Feb 14, 2022 at 11:00:59AM -0400, Jason Gunthorpe wrote: >> On Mon, Feb 14, 2022 at 03:23:07PM +0100, Joerg Roedel wrote: >> >>> Device drivers calling into iommu_attach_device() is seldom a good >>> idea. In this case the sound device has some generic hardware >>> interface so that an existing sound driver can be re-used. Making this >>> driver call iommu-specific functions for some devices is something hard >>> to justify. >> >> Er, so this is transparent to the generic sound device? I guess >> something fixed up the dma_api on that device to keep working? > > Right, this is completly transparent to the sound device. The IOMMU code > will not set dma_ops on the device because it uses a direct mapping and > so the standard implementation will be used. > >> But, then, the requirement is that nobody is using the dma API when we >> make this change? > > That is the tricky part. DMA-API keeps working after the change is made, > because the new domain is also direct mapped. The new domain just has > the ability to assign host page-tables to device PASIDs, so that DMA > requests with a PASID TLP will be remapped. > > It was actually a requirement for this code that when it jumps in, the > DMA-API mappings stay live. And the reason a direct mapping is used at > all is that the page-table walker of the IOMMU is a two-dimensional > walker, which will treat the addresses found in the host page-tables as > IO-virtual an translates them through the underlying page-table. So to > use host-pagetables the underlying mapping must be direct mapped. Given how things have evolved since that code was originally written, and that we seemingly now have the def_domain_type override kicking in as soon as we first see an IOMMUv2-capable device, do we even need to then subsequently switch to this special unmanaged domain with its pagetable sucked out, or could we just install the PASID table in the default domain itself? Robin. >> I don't think it matters how big/small the group is, only that when we >> change the domain we know everything flowing through the domain is >> still happy. > > Yes, that matters. The group size matters too for DMA-API performance. > If two devices compete for the same lock in the allocator and/or the > same cached magazines, things will slow down. That only matters for > high-throughput devices, but still... > > Regards, > > Joerg >