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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 671E2C433F5 for ; Wed, 6 Apr 2022 13:32:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232900AbiDFNeO (ORCPT ); Wed, 6 Apr 2022 09:34:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233257AbiDFNds (ORCPT ); Wed, 6 Apr 2022 09:33:48 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DFAA7273807; Wed, 6 Apr 2022 03:33:50 -0700 (PDT) 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 8EAB223A; Wed, 6 Apr 2022 03:32:23 -0700 (PDT) Received: from [10.57.41.19] (unknown [10.57.41.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 923B13F718; Wed, 6 Apr 2022 03:32:21 -0700 (PDT) Message-ID: <0c9a1581-728c-6a5c-b65d-80a4f0948d19@arm.com> Date: Wed, 6 Apr 2022 11:32:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v3 1/4] iommu: Introduce device_iommu_capable() Content-Language: en-GB To: Christoph Hellwig Cc: joro@8bytes.org, baolu.lu@linux.intel.com, andreas.noever@gmail.com, michael.jamet@intel.com, mika.westerberg@linux.intel.com, YehezkelShB@gmail.com, iommu@lists.linux-foundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, mario.limonciello@amd.com References: <37ec2f9f67098d0caf60dcec558fbe1756ea2621.1649089693.git.robin.murphy@arm.com> <20220406052812.GA10507@lst.de> From: Robin Murphy In-Reply-To: <20220406052812.GA10507@lst.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-04-06 06:28, Christoph Hellwig wrote: > On Tue, Apr 05, 2022 at 11:41:01AM +0100, Robin Murphy wrote: >> iommu_capable() only really works for systems where all IOMMU instances >> are completely homogeneous, and all devices are IOMMU-mapped. Implement >> the new variant which can give an accurate answer for whichever device >> the caller is actually interested in. >> >> Signed-off-by: Robin Murphy >> --- >> >> v3: New patch; now that the dev_iommu_ops() work has landed we can go >> straight to a proper implementation. Also s/dev/device/ to match >> the precedent of device_iommu_mapped() for the public API. > > I'm a little worrited about a method with a parameter than can be > NULL. FWIW, the intent is that that's only temporary. > Also usnic, vmd, and vdpa really want to use your new > device_iommu_capable as they check based on a device. Just VFIO > is special as usual.. Indeed, I have those patches in my stack already, I'm just waiting for this to land before I think about posting them. Once the DMA ownership series lands in parallel, VFIO can also get converted and iommu_capable() goes away entirely. At that point I have a patch for the Arm SMMU drivers to start actually using the new device argument, but Jason's new proposal now puts a twist on that... On reflection, there's no real need for the internal method to change in lock-step with the external interface. I've no objection to holding off on adding that new parameter until it's reliably useful, and indeed now that I'm looking at it outside the context of the entire cleanup mission, that does sound like the right thing to do anyway :) (also it turns out I need to respin this patch regardless since I generated it from the wrong point in my branch, where iommu_present() was already gone from the context in iommu.h...) Cheers, Robin.