Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3027604imb; Mon, 4 Mar 2019 22:11:40 -0800 (PST) X-Google-Smtp-Source: APXvYqzGwoLKixlQ2ocMxAKK9Gxwr2DeYiBIJ2jwvpo6xGCVkdTJqoibgI9lQGRBURwT++TIeUk2 X-Received: by 2002:aa7:8243:: with SMTP id e3mr280534pfn.40.1551766300850; Mon, 04 Mar 2019 22:11:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551766300; cv=none; d=google.com; s=arc-20160816; b=kAZCvRpur1gzQamm+dp2EXpdQrKN3Ij1wHQJzcxy14ebE7iImRZGLbgrZ2N9TO20iV tPRm772QUfLuFZdAnXQCzUTwc+wOcHLMQBiREAMhsWa2/Z0hXBSlpa+ZuDIMFXU0nmZu ZASSQJq1erJPRi5lWcyCis+jvwxZesQfy29k0NOERxcIATg1qsqE0hHg41IiwpfJv9ik zsw2BVPy/Yab6vW1jKUetui98I/2xMX+kbSjn4uiwbQuBUo47nMfzRF+SOIfv6DHto/G 3ZiVv87xZt6kmDNJZjYS8W+ABD0uBAUqThZDLNrINrpZ3jHTxY2leVFYA4T0JBDiZVRe Uhng== 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=Fndk3tg1rZ0L47qTmzJIRdfofkWBcvJN02uplpi+Jlc=; b=oc7EFExzuEatXw30eDYsr3TxYwLEYCfPtr61JSXcLf7nkDRwmunSkj/s+q/tJPeJM5 En6jHEbN2siULtsBhzSBprm9d4vVkKjZygB+eF4Np2GttLvNYy4KAmfJl+GlOW3PiNGw 9Dza8c7uTD4wa3N8vWem/Umx7NDB2bgGMQJNX/f3+fJx/IB60YrKL4Nr2Utgd+StR2FL r57JEC7jEDqj4zJlUFdgqwTUdU1QzfZnNEZUMa5PHubbg5hbBAgU4EEKn7aq0Nm9ypvf +NNjJnydDaEIG2kolH1l+6FYFNasAIgjLUcsYgCl0CELU+2T6sdCTbr0kLVwsAnq2bYL zyZg== 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 g8si7836193plb.146.2019.03.04.22.11.13; Mon, 04 Mar 2019 22:11:40 -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 S1726783AbfCEGKn (ORCPT + 99 others); Tue, 5 Mar 2019 01:10:43 -0500 Received: from mga12.intel.com ([192.55.52.136]:57644 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726026AbfCEGKm (ORCPT ); Tue, 5 Mar 2019 01:10:42 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2019 22:10:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,442,1544515200"; d="scan'208";a="119670991" Received: from allen-box.sh.intel.com (HELO [10.239.159.136]) ([10.239.159.136]) by orsmga007.jf.intel.com with ESMTP; 04 Mar 2019 22:10:40 -0800 Cc: baolu.lu@linux.intel.com, Tom Murphy , Dmitry Safonov , Jacob Pan , linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/4] iommu/vt-d: Fix-up device-domain relationship by refactoring to use iommu group default domain. To: James Sewart , iommu@lists.linux-foundation.org References: <0F0C82BE-86E5-4BAC-938C-6F7629E18D27@arista.com> From: Lu Baolu Message-ID: Date: Tue, 5 Mar 2019 14:05:26 +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: <0F0C82BE-86E5-4BAC-938C-6F7629E18D27@arista.com> 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 James, Very glad to see this. Thank you! On 3/4/19 11:41 PM, James Sewart wrote: > Hey, > > This patchset moves IOMMU_DOMAIN_DMA iommu domain management to iommu.c. > This avoids the use of find_or_alloc_domain whose domain assignment is > inconsistent with the iommu grouping as determined by pci_device_group. Is this a bug fix or an improvement? What's the real issue will it cause if we go without this patch set? Best regards, Lu Baolu > > Patch 3 permits domain type IOMMU_DOMAIN_DMA to be allocated via the > iommu_ops api, allowing the default_domain of an iommu group to be set in > iommu.c. This domain will be attached to every device that is brought up > with an iommu group, and the devices reserved regions will be mapped using > regions returned by get_resv_regions. > > In intel_iommu_domain_alloc we don’t know the IOMMU this domain will be > associated with so we defer full initialisation until > intel_iommu_attach_device. Currently iommu.c:iommu_group_add_device will > try to map a devices reserved regions before attaching the domain which > would cause issue if the domain is not fully initialised. This is > addressed in patch 1 by moving the mapping to after attaching. > > Patch 2 implements function apply_resv_region, used in > iommu_group_create_direct_mappings to mark the reserved regions as non > mappable for the dma_map_ops api. > > Patch 4 removes the domain lazy allocation logic. Before this patch the > lazy allocation logic would not be used as any domain allocated using > these paths would be replaced when attaching the group default domain. > Default domain allocation has been tested with and without this patch on > 4.19. > > Cheers, > James. > > James Sewart (4): > iommu: Move iommu_group_create_direct_mappings to after device_attach > iommu/vt-d: Implement apply_resv_region for reserving IOVA ranges > iommu/vt-d: Allow IOMMU_DOMAIN_DMA and IOMMU_DOMAIN_IDENTITY to be allocated > iommu/vt-d: Remove lazy allocation of domains > > drivers/iommu/intel-iommu.c | 329 ++++++++++++------------------------ > drivers/iommu/iommu.c | 4 +- > 2 files changed, 108 insertions(+), 225 deletions(-) >