Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4949798imm; Tue, 11 Sep 2018 22:03:43 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbf9iRNCBTaE7yfZ/UlwmLR72UBbfisbtrn5OHAxdBbSGe8Atyxq11WGWb0ojjrF6Y21VhP X-Received: by 2002:a63:9551:: with SMTP id t17-v6mr105269pgn.432.1536728623877; Tue, 11 Sep 2018 22:03:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536728623; cv=none; d=google.com; s=arc-20160816; b=ucE1ZLUuC3tQ1X7+h8yafdeBE9Uxjghj1LKzBZC68s7RBkK7YHgVyg6WqEAQ7zEY4g UXTndRQENRr8kNKTVJDlnWM9KwfSkF4nvz4OOOGui7nHD7q4iVwzgJhSIC7TqUTRtl3c HuOMcW50F0gFuls0QlO6RfQLParM7a7sjP1IXMyjeBZ7o6QeNlaTyfIcLFuXXAzm0Qaf fJwws3GqBT7EeVCQj9+JITGUzgZnuGog3+ZsxfktO0d0GmUTdbEAjjRwsl+rb0QqKWIc AdaXE0kOzSAtxxcL91QOGQr/i5yrBDOe1BQsfs4Bk27wEKcsg7befYTe3ejsD7Xrklwq X0+A== 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:to:subject:cc; bh=5nflaB9z3H0pXHlL+3NIoxojHkF5MF39FxsYSpjCEv4=; b=RkoIL8oNka9FZAJ6WxvPmXG2PZ7UWLK3iOLN7yE0tQ/k3GBnkgG4J7HZx6px50yIr4 rFfv86CYnhCSJ265NYjvo06375Lwxq3274qH17jg9FEWsfAuC27woyTaRIOycLrYIq/s ophJGeAANvAv/wLFTw1iMLaiqPpwz5NwjYb+sA849R7bRZdc285uNlhYTfOj30vjFXWF 6HrAJOeoWhzd46DmGCLLhUXckwLmn1Lq0AC+meJBRqVwFOk97cpX9k5HUDrbYdITD/HK 5K8+Qwdu7T49kc1SChe63tmedXPFhXbnn4zqXGl6pNkz537FbKZsfUz77PfshzK+NnMX nW5A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11-v6si23097786pgo.525.2018.09.11.22.03.27; Tue, 11 Sep 2018 22:03:43 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726166AbeILKGG (ORCPT + 99 others); Wed, 12 Sep 2018 06:06:06 -0400 Received: from mga18.intel.com ([134.134.136.126]:8843 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725738AbeILKGG (ORCPT ); Wed, 12 Sep 2018 06:06:06 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2018 22:03:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,363,1531810800"; d="scan'208";a="69321952" Received: from allen-box.sh.intel.com (HELO [10.239.161.122]) ([10.239.161.122]) by fmsmga007.fm.intel.com with ESMTP; 11 Sep 2018 22:03:11 -0700 Cc: baolu.lu@linux.intel.com, 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 Subject: Re: [RFC PATCH v2 08/10] vfio/type1: Add domain at(de)taching group helpers To: Jean-Philippe Brucker , Joerg Roedel , David Woodhouse , Alex Williamson , Kirti Wankhede References: <20180830040922.30426-1-baolu.lu@linux.intel.com> <20180830040922.30426-9-baolu.lu@linux.intel.com> From: Lu Baolu Message-ID: Date: Wed, 12 Sep 2018 13:02:00 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed 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 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". Best regards, Lu Baolu