Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6482934pxb; Tue, 15 Feb 2022 03:31:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJweJtrD759E5hkU3P2v/3hfzZr4WxMCaM6aaoKijv2siqH75/0q/agQSAJI6KkVG100Af+T X-Received: by 2002:a17:90a:aa14:: with SMTP id k20mr3894642pjq.8.1644924694228; Tue, 15 Feb 2022 03:31:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644924694; cv=none; d=google.com; s=arc-20160816; b=Hx1oT8pFse4vsxmmXmA7ahNt2mvhAtAJpsV7ZjrC0lhrVUt9YGw1JCHyh2pe3OQueD n4H0gOabVSkBixIb1J5gwD405Sn0gAVVnLQrFK8ezfJQFMkcabarBS+CpJHvFnVsHPe8 joBX0fVP6Dy7K7dE3IwvPuptx+FBxpaNqSlxxcV42o0TPjd8JfbwBvr6nL8rkI3ZAHMB V25grT6xGcfgQTbNQLRWYMGaDDQysyCFz/VMnCKrjndz34Z51fbxS49cMRCRiSpDjZs4 icZ+6AyNGf91eBZhpXLeKtbK32xqfd+6QZ7en+ENvNH10LVwRLLqEKtc9w6NS/e0R4Lf BZLQ== 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=ZX//uPyOAXWlRCd0nql0D3SOwUG0Re8FQ3qwadYavWk=; b=KA+RGCL8l5SPnxikYDj+AkRsWGg8oqQDbi5jT1wKEloqv2gor57FlNLbFOqt5znXY8 jnlE/z2Afebb+s8xHoEVVKCC4MO7j9V3ZGBqWdrGKl/EhcDYluD+LxTgbRRc3HmDvRCb yaqMW0YSOGg42XHjdD6T+eG6QF/min7HzrRFLkm6hFNYMwY0V3ObmRsiX1qQVW0JLs2y qRy+BBr0PcPqplYoV2nDt9GZSy6fbc4Y5pxJp7yjnGxBwkYyjjesWAtmcFMM5G+1Cpbf M1dEhtT9Xhb3wZGw71oSS3pmDgMBnOtiaa/eGgon3iiZaxc1qcwl959a0RLOJRbKif2D Q7cQ== 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=8bytes.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a4si8864528plh.64.2022.02.15.03.31.19; Tue, 15 Feb 2022 03:31:34 -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=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235668AbiBOJLQ (ORCPT + 99 others); Tue, 15 Feb 2022 04:11:16 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbiBOJLO (ORCPT ); Tue, 15 Feb 2022 04:11:14 -0500 Received: from theia.8bytes.org (8bytes.org [81.169.241.247]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0645913DD4; Tue, 15 Feb 2022 01:11:04 -0800 (PST) Received: by theia.8bytes.org (Postfix, from userid 1000) id CA08436D; Tue, 15 Feb 2022 10:11:02 +0100 (CET) Date: Tue, 15 Feb 2022 10:11:01 +0100 From: Joerg Roedel To: Jason Gunthorpe Cc: Lu Baolu , Alex Williamson , Robin Murphy , 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 Subject: Re: [PATCH v1 5/8] iommu/amd: Use iommu_attach/detach_device() Message-ID: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220214150059.GE4160@nvidia.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 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. > 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