Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5778255imm; Wed, 12 Sep 2018 10:56:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYFc3e3/0KV/2fENIKEzHzHuppjXNeQzFY7ncZJ2ySFSUXHDsBtcL4KoM0EixTS08olSKlA X-Received: by 2002:a62:c98e:: with SMTP id l14-v6mr3659404pfk.10.1536775008179; Wed, 12 Sep 2018 10:56:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536775008; cv=none; d=google.com; s=arc-20160816; b=YLlnkD7VBfS6dQ/gJyi1GgIM+615wI35v7UPQiF9YmA/EvYbq6iOBw7zrVt2KKZq7R ENCkq1LedHsMJraFVbHggFnFEl7T0x1ioi5GgpmE7JX6Td5yKdXuQmuC1yem7+x1V9hb etc7eDRPooIPykJh4d8Mv8fi+yDpG9W0+6iYrc0GRbjCEDX33XT2T1xDAD0RMnf1J5ZX 1AokC8lZ9emS/5ig+U9kW7etzWX89nPadpRY+B8E2WjSEmcqPvcr0NKAGbYUhiirzEBI gAp3Bs0vWa9rNb7b2BFlnMyOiyFpBej/4vjpReI05WXneoUEQAMiPzr19nSuujjLv0DP 3mwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=aiNczZuMoItFKdR4bSmidmqhjBxiKxdS2BV4VPxPL4Y=; b=LdOkLIItE0/qeNjgX2JcL6zsy5neqAdaBt6UQ7M109TNCcZkPUkGmpdD/I4Hh+uXlE 5ILd3Lx9kxhuWsb4c13dRD/r0hID92lhySaVuNT5Anh+47bLsVAQVq9B6XW1Y25KWT1/ lUSq4Kdh1HBxrgo+zdGcqIn8kDHLiUzB/O5dBDWxrcdqnC2TXRi6LTrj02nIuxWqDzcr fZVkQownSBOa9lxiq+Vpp+P/e6XezZsJh5msiMcaGpKEkyh3ZR5FKE+ozSf4+iTlky/S iqRd1jNb1AtlWi2hAkJwsAahQ5KEDd06l8N6OsQloWqepM1slnypc2mv2GrdyqQhNT+j 4kOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11-v6si1432233plg.453.2018.09.12.10.56.32; Wed, 12 Sep 2018 10:56:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727834AbeILXAU (ORCPT + 99 others); Wed, 12 Sep 2018 19:00:20 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:36866 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727788AbeILXAT (ORCPT ); Wed, 12 Sep 2018 19:00:19 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 81C521596; Wed, 12 Sep 2018 10:54:42 -0700 (PDT) Received: from [10.4.12.111] (ostrya.Emea.Arm.com [10.4.12.111]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 49E083F557; Wed, 12 Sep 2018 10:54:40 -0700 (PDT) Subject: Re: [RFC PATCH v2 08/10] vfio/type1: Add domain at(de)taching group helpers To: Lu Baolu , Joerg Roedel , David Woodhouse , Alex Williamson , Kirti Wankhede Cc: "kevin.tian@intel.com" , "ashok.raj@intel.com" , "tiwei.bie@intel.com" , "sanjay.k.kumar@intel.com" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "yi.y.sun@intel.com" , "jacob.jun.pan@intel.com" , "kvm@vger.kernel.org" References: <20180830040922.30426-1-baolu.lu@linux.intel.com> <20180830040922.30426-9-baolu.lu@linux.intel.com> From: Jean-Philippe Brucker Message-ID: <04f5dc9d-71b1-37ec-402b-fae5f9e08664@arm.com> Date: Wed, 12 Sep 2018 18:54:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/09/2018 06:02, Lu Baolu wrote: > Hi, > > On 09/11/2018 12:23 AM, Jean-Philippe Brucker wrote: >> On 30/08/2018 05:09, Lu Baolu wrote: >>> +static int vfio_detach_aux_domain(struct device *dev, void *data) >>> +{ >>> + struct iommu_domain *domain = data; >>> + >>> + vfio_mdev_set_aux_domain(dev, NULL); >>> + iommu_detach_device(domain, dev->parent); >> >> I think that's only going to work for vt-d, which doesn't use a >> default_domain. For other drivers, iommu.c ends up calling >> domain->ops->attach_dev(default_domain, dev) here, which isn't what we want. > > This doesn't break any functionality. It takes effect only if iommu > hardware supports finer granular translation and advertises it through > the API.> >> That was my concern with reusing attach/detach_dev callbacks for PASID >> management. The attach_dev code of IOMMU drivers already has to deal >> with toggling between default and unmanaged domain. Dealing with more >> state transitions in the same path is going to be difficult. > > Let's consider it from the API point of view. > > We have iommu_a(de)ttach_device() APIs to attach or detach a domain > to/from a device. We should avoid applying a limitation of "these are > only for single domain case, for multiple domains, use another API". That's an idealized view of the API, the actual semantics aren't as simple. For IOMMU drivers that implement IOMMU_DOMAIN_DMA in their domain_alloc operation (Arm SMMU, AMD IOMMU, ...), attach_dev attaches an unmanaged domain, detach_dev reattaches the default DMA domain, and the detach_dev IOMMU op is not called. We can't change that now, so it's difficult to add more functionality to attach_dev and detach_dev. Thanks, Jean