Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp9265imc; Sat, 9 Mar 2019 18:58:37 -0800 (PST) X-Google-Smtp-Source: APXvYqwV/1qGvdwkv7pLJg6yUU6DxjICpFUKjnD44YIlDN7q6rP9MpHKA73fqTMVYPyQ5nic3KYp X-Received: by 2002:a65:6259:: with SMTP id q25mr24127782pgv.235.1552186717088; Sat, 09 Mar 2019 18:58:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552186717; cv=none; d=google.com; s=arc-20160816; b=ggRCmGYlORtB0p60EPPDNVEBfcot3lLW7UOL5x/wffIDB8g0KMlg7AX7ux09uPcEkK mlBxWlL1DW2XirPBv5pBKZ3RPsa9E5h6OyzQSzjbEUgtyaM2AAK5+N8KQO+bve13Qyor 5RMMoSr5m+KHVawCYGzPLAutnRjpl/Cr7X24Zq6aRvm+DU3eI5DqElR16MFzA5TrnrOF 0URFYuXkGhdIGa5aCp3o1m7XjW1QOqbCeD8rK0AOC9eWOljswShZmECNBVHOFl6xinhW dH6oMr00EQGNF6WpQMHKuTyaCNg5Ccih6mO4PhQfAWgdhc+YEw+H8pi+VlRUQxRsUJFO 2mtw== 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=su0bbcN0jaWOdZl00P6NYr+VXkWoQS5BVhmPFr1XpmA=; b=swpza4qruOAsSBjDqU6KEhGmVnOPVUoHLkApX475BFaY0U8nV56I9VEcF90dvzIdSW qmWXGQGP9jSpU8NS8CCB1ABce6JfXNL05tWC0BR+rD4bJQmK17hKYeI9umX6POH15ubB VVi6FZQTCqtA6/USY2WhjxcbvPgderTZmHqEfpnD7q/Hxri1w2RfO4WkBuxZs4xXRZ5p 8DEJu89OYj2Q18GpbmW7gMPpvgJhveMgZylVmzsIb+Xj/gQJzPYd06l4V//NAG7/8B+n 4ET1Ux+qp7K9V+DT6AuyrzqRojBGWgfjxhN1dcdPWXI/l/I8MeuaAgNLPMTnRCk4T8MX zwOw== 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 f12si1821970pgf.184.2019.03.09.18.58.01; Sat, 09 Mar 2019 18:58:37 -0800 (PST) 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 S1726409AbfCJC5W (ORCPT + 99 others); Sat, 9 Mar 2019 21:57:22 -0500 Received: from mga18.intel.com ([134.134.136.126]:56481 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726352AbfCJC5V (ORCPT ); Sat, 9 Mar 2019 21:57:21 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Mar 2019 18:57:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,462,1544515200"; d="scan'208";a="125615654" Received: from allen-box.sh.intel.com (HELO [10.239.159.136]) ([10.239.159.136]) by orsmga006.jf.intel.com with ESMTP; 09 Mar 2019 18:57:18 -0800 Cc: baolu.lu@linux.intel.com, iommu@lists.linux-foundation.org, Tom Murphy , Dmitry Safonov , Jacob Pan , linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4] iommu/vt-d: Remove lazy allocation of domains To: James Sewart References: <0F0C82BE-86E5-4BAC-938C-6F7629E18D27@arista.com> <2C75F46E-78FE-45E9-9E7D-280B3138EA13@arista.com> <7F6B5F6A-EC76-4A9F-8EB6-AEAB9994D91A@arista.com> <4B054B40-0B13-4F1E-87D6-8D2F072B5B9C@arista.com> <06aa306a-278a-a22f-7718-200f6f9e5e87@linux.intel.com> <4b3e29ce-1dff-eb7d-9b7e-1cde54a24dec@linux.intel.com> <8ED1B579-C6B9-49E0-BD9A-5751474682D1@arista.com> From: Lu Baolu Message-ID: <514452e0-ba9d-3eb8-e219-944b93e48ad2@linux.intel.com> Date: Sun, 10 Mar 2019 10:51:59 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 3/9/19 7:49 PM, James Sewart wrote: > Hey Lu, > >> On 9 Mar 2019, at 01:53, Lu Baolu wrote: >> >> Hi James, >> >> On 3/9/19 12:57 AM, James Sewart wrote: >>> Hey Lu, >>>> On 8 Mar 2019, at 03:09, Lu Baolu wrote: >>>>>> >>>>>> Do you mind if I work on top of your patches for further cleanups and >>>>>> sign off a v2 together with you? >>>>> Sure, sounds good. I’ll fixup patch 3 and have a go at integrating >>>>> iommu_prepare_isa into get_resv_regions. This should make the initial >>>>> domain logic here quite concise. >>>> Here attached three extra patches which I think should be added before >>>> PATCH 3/4, and some further cleanup changes which you can merge with >>>> PATCH 4/4. >>>> >>>> ---------------- >>>> >>>> 0006-iommu-Add-ops-entry-for-vendor-specific-default-doma.patch >>>> 0007-iommu-vt-d-Add-is_identity_map-ops-entry.patch >>>> >>>> These two patches aim to add a generic method for vendor specific iommu >>>> drivers to specify the type of the default domain for a device. Intel >>>> iommu driver will register an ops for this since it already has its own >>>> identity map adjudicator for a long time. >>> This seems like a good idea, but as domain alloc is only called for the >>> default domain on first device attached to a group, we may miss checking >>> whether a device added later should have an identity domain. Should there >>> be paths to downgrade a groups domain if one of the devices requires one? >> >> Good catch! >> >> This is supposed to be handled in iommu_no_mapping(). But, obviously >> current code sticks to lazy domain allocation. I'm not sure whether >> there are any real such cases, but we should handle it in a clean way. >> My idea is that we could downgrade to multiple domains per group (just >> like what we have now) in this case and print a kernel message for this. > > I think if a device requires an identity domain, then it should ignore > attempts to attach to something else. A print to warn a user about this > would be a good idea. > > I figure during attach: if iommu_no_mapping() then attach to si_domain and > print, else continue with the given domain. Yes, agree. Best regards, Lu Baolu