Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5955468pxb; Mon, 14 Feb 2022 11:37:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxb1CQ6/B/9T5Z8idvRa3UVgHJzZs4UCeusCG3kjjW91r7iTa3CVX9RsFdkRxmeBMIKcWRo X-Received: by 2002:a17:903:32d1:: with SMTP id i17mr298210plr.55.1644867443800; Mon, 14 Feb 2022 11:37:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644867443; cv=none; d=google.com; s=arc-20160816; b=Xi74ug+PF1+wbMTSAKeCLVmW5k+kslcGeXaoLdvS+vPN6zFTrfaV2+c6qSeang8CHp 29XM6bYh67vKyubudIG6FjQqZp8AaSDCISB8FmqE3O1N1p4V0AXt3VblKxE68itsQlGb yMs4+AC4aFwhDvWUNSBm5R5cpK9IOmnkXlhXTHJw1ufDCfjIg/zwbmdyGpKchsIiGxFk qxXxbiHY7UIsuOXZulqo+wOrN9BBqiZQKe7hdp/BDVqLwMLmUxQRsQIAVkErk1TrPmXH JKlLtxPWHqHIVM+J7rFumQklQvp6pQbh1Fw9PkOA8PX8eUBdZXd/HyE9JUvffhMeJ9BQ H3uA== 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=S7jl558yWAaqZ9VtT2xw8cbn43RhyT2AY8qNvqkRq38=; b=eEDDyOUAAt3xWq6+M98JdfpSvquithDZXcvjoKj+imZIc3sHtNVXZ13U17aQlflMHL ytZ8r5puC+g0mJTNSahnqBYf9lkxl7xEMgADJuS9sAdSdClld3fsWAGMxmjq7vFswa67 P7H9/CX/n99D1ah4jwwIPwiYtAdhSeRbk2rODQ4okU6w5mfeuf+xTTgN3MC1JdezWeRX vSQFgJCaF4aUCmE9tDnVyZPdocmGCHlTlDKDPugF0rVDYnpKUFPhsQwptzAq8oJTa+ok E7Br49Gz6+OcTmnJGYt0xcNVqSojcbpIiKUFWb3qq3IvHyg71VO7FRT1KmK2nLgyZvq9 DHMA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q141si526742pgq.557.2022.02.14.11.37.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 11:37:23 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 45A81D4CAD; Mon, 14 Feb 2022 11:24:45 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354955AbiBNOKi (ORCPT + 99 others); Mon, 14 Feb 2022 09:10:38 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354341AbiBNOKh (ORCPT ); Mon, 14 Feb 2022 09:10:37 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 93DD0AE65; Mon, 14 Feb 2022 06:10:29 -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 3FC2F1042; Mon, 14 Feb 2022 06:10:29 -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 4E40A3F66F; Mon, 14 Feb 2022 06:10:24 -0800 (PST) Message-ID: <1347f0ef-e046-1332-32f0-07347cc2079c@arm.com> Date: Mon, 14 Feb 2022 14:10:19 +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 1/8] iommu: Add iommu_group_replace_domain() Content-Language: en-GB To: Jason Gunthorpe Cc: Lu Baolu , Joerg Roedel , Alex Williamson , Christoph Hellwig , Kevin Tian , Ashok Raj , kvm@vger.kernel.org, rafael@kernel.org, David Airlie , linux-pci@vger.kernel.org, Thierry Reding , Diana Craciun , Dmitry Osipenko , Will Deacon , Stuart Yoder , Jonathan Hunter , Chaitanya Kulkarni , Bjorn Helgaas , Dan Williams , Greg Kroah-Hartman , Cornelia Huck , linux-kernel@vger.kernel.org, Li Yang , iommu@lists.linux-foundation.org, Jacob jun Pan , Daniel Vetter References: <20220106022053.2406748-1-baolu.lu@linux.intel.com> <20220106022053.2406748-2-baolu.lu@linux.intel.com> <43f2fc07-19ea-53a4-af86-a9192a950c96@arm.com> <20220214124518.GU4160@nvidia.com> From: Robin Murphy In-Reply-To: <20220214124518.GU4160@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-14 12:45, Jason Gunthorpe wrote: > On Mon, Feb 14, 2022 at 12:09:36PM +0000, Robin Murphy wrote: >> On 2022-01-06 02:20, Lu Baolu wrote: >>> Expose an interface to replace the domain of an iommu group for frameworks >>> like vfio which claims the ownership of the whole iommu group. >> >> But if the underlying point is the new expectation that >> iommu_{attach,detach}_device() operate on the device's whole group where >> relevant, why should we invent some special mechanism for VFIO to be >> needlessly inconsistent? >> >> I said before that it's trivial for VFIO to resolve a suitable device if it >> needs to; by now I've actually written the patch ;) >> >> https://gitlab.arm.com/linux-arm/linux-rm/-/commit/9f37d8c17c9b606abc96e1f1001c0b97c8b93ed5 > > Er, how does locking work there? What keeps busdev from being > concurrently unplugged? Same thing that prevents the bus pointer from suddenly becoming invalid in the current code, I guess :) But yes, holding a group reference alone can't prevent the group itself from changing, and the finer points of locking still need working out - there's a reason you got a link to a WIP branch in my tree rather than a proper patch in your inbox (TBH at the moment that one represents about a 5:1 ratio of time spent on the reasoning behind the commit message vs. the implementation itself). > How can iommu_group_get() be safely called on > this pointer? VFIO hardly needs to retrieve the iommu_group from a device which it derived from the iommu_group it holds in the first place. What matters is being able to call *other* device-based IOMMU API interfaces in the long term. And once a robust solution for that is in place, it should inevitably work for a device-based attach interface too. > All of the above only works normally inside a probe/remove context > where the driver core is blocking concurrent unplug and descruction. > > I think I said this last time you brought it up that lifetime was the > challenge with this idea. Indeed, but it's a challenge that needs tackling, because the bus-based interfaces need to go away. So either we figure it out now and let this attach interface rework benefit immediately, or I spend three times as long solving it on my own and end up deleting iommu_group_replace_domain() in about 6 months' time anyway. Thanks, Robin.