Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1955859yba; Sun, 5 May 2019 18:42:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1YDHfMCCBBU3GDxbvObXEuxZn9C9P1YV4C9YDWL64XnfPQFEpIfGrIQcCWhQ5XK3eH6Gy X-Received: by 2002:a62:e508:: with SMTP id n8mr29838842pff.189.1557106958170; Sun, 05 May 2019 18:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557106958; cv=none; d=google.com; s=arc-20160816; b=OwTJ79LIcTa5+2XPVUkzx8KY0pTp9qpmO02b4ZkvvZrgoOAnwhBQ/vb1XoKrDgzw7F jYGx/IyuRv65xKlC27WgoNdjMI5K/+CXJCfHbmw/mqIhTLjEWuqxv4S8dJX0i7O8WtZ6 VigBi7iA4QARoXOTjsITyGYMspo6Q+RtEE5XhITnr1t9+gw/BjGO1io56vTUwTKcUlAU V5dCyClRAzaZ6N6Xf2R+jZpUQOFq1mSBOtPA4JZGHxt3G4m2H1wXRwXbf4tiptMWNU7R PkoMJD4alquNmF920a9e3B41WTKsw9KixQCPNd7ybd6C6JROKXvXbYQpT63MAgSaq2hP gaEw== 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=rzzLcNtoJmzH46fmQ6jRFjd3vNBSbskxmPXxeWrCMJU=; b=qlon4MCfoBnn1I2rvMTrTaqKjbFzC3z1cU9+B7DyiUd+B0gtGX5DNADLcaLDcHiusJ vDYyZCzc07SVgEbMtVUrs531n1cYfxWw2tUgCjATB38rNAvVIeRMz3+u0099OSMai0RV IdgDYKhT0DFcO42YerpaZfDKamYzal4awnk5e+CXBgZHqSEnyc/hkih377JpVjYZGnmK qkVDB6lBJDF24SAk/4GrAUskqj/cVw+JL9Ie8SGpaa5Rc4da17i6cDhLBGZthtmqN1am 1QyoN0c8bBGCX9g9rFvSKMCUR/uNeQd7N+YSIkua5+1QeBHT38y/AqknhXjbWUelyi9/ QnzQ== 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 70si13767148plc.88.2019.05.05.18.42.22; Sun, 05 May 2019 18:42:38 -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 S1726218AbfEFBla (ORCPT + 99 others); Sun, 5 May 2019 21:41:30 -0400 Received: from mga04.intel.com ([192.55.52.120]:62134 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725786AbfEFBl3 (ORCPT ); Sun, 5 May 2019 21:41:29 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 May 2019 18:41:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,435,1549958400"; d="scan'208";a="146639249" Received: from allen-box.sh.intel.com (HELO [10.239.159.136]) ([10.239.159.136]) by fmsmga008.fm.intel.com with ESMTP; 05 May 2019 18:41:24 -0700 Cc: baolu.lu@linux.intel.com, iommu@lists.linux-foundation.org, Tom Murphy , Joerg Roedel , Will Deacon , Robin Murphy , Marek Szyprowski , Kukjin Kim , Krzysztof Kozlowski , David Woodhouse , Andy Gross , David Brown , Matthias Brugger , Rob Clark , Heiko Stuebner , Gerald Schaefer , Thierry Reding , Jonathan Hunter , Alex Williamson , Thomas Gleixner , Marc Zyngier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-tegra@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [RFC 6/7] iommu/vt-d: convert the intel iommu driver to the dma-iommu ops api To: Tom Murphy References: <20190504132327.27041-1-tmurphy@arista.com> <20190504132327.27041-7-tmurphy@arista.com> <602b77a2-9c68-ad14-b64f-904a7ff27a15@linux.intel.com> From: Lu Baolu Message-ID: <2419e94d-bfdb-e70d-bbfd-425671886e99@linux.intel.com> Date: Mon, 6 May 2019 09:34:59 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.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 5/6/19 1:03 AM, Tom Murphy wrote: > On Sun, May 5, 2019 at 3:44 AM Lu Baolu wrote: >> Hi, >> >> On 5/4/19 9:23 PM, Tom Murphy wrote: >>> static int intel_iommu_add_device(struct device *dev) >>> { >>> + struct dmar_domain *dmar_domain; >>> + struct iommu_domain *domain; >>> struct intel_iommu *iommu; >>> struct iommu_group *group; >>> - struct iommu_domain *domain; >>> + dma_addr_t base; >>> u8 bus, devfn; >>> >>> iommu = device_to_iommu(dev, &bus, &devfn); >>> @@ -4871,9 +4514,12 @@ static int intel_iommu_add_device(struct device *dev) >>> if (IS_ERR(group)) >>> return PTR_ERR(group); >>> >>> + base = IOVA_START_PFN << VTD_PAGE_SHIFT; >>> domain = iommu_get_domain_for_dev(dev); >>> + dmar_domain = to_dmar_domain(domain); >>> if (domain->type == IOMMU_DOMAIN_DMA) >>> - dev->dma_ops = &intel_dma_ops; >>> + iommu_setup_dma_ops(dev, base, >>> + __DOMAIN_MAX_ADDR(dmar_domain->gaw) - base); >> I didn't find the implementation of iommu_setup_dma_ops() in this >> series. Will the iova resource be initialized in this function? > Ah sorry, I should've mentioned this is based on the > http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/dma-iommu-ops.3 > branch with the "iommu/vt-d: Delegate DMA domain to generic iommu" and > "iommu/amd: Convert the AMD iommu driver to the dma-iommu api" patch > sets applied. > >> If so, will this block iommu_group_create_direct_mappings() which >> reserves and maps the reserved iova ranges. > The reserved regions will be reserved by the > iova_reserve_iommu_regions function instead: > (https://github.com/torvalds/linux/blob/6203838dec05352bc357625b1e9ba0a10d3bca35/drivers/iommu/dma-iommu.c#L238 > ) > iommu_setup_dma_ops calls iommu_dma_init_domain which calls > iova_reserve_iommu_regions. > iommu_group_create_direct_mappings will still execute normally but it > won't be able to call the intel_iommu_apply_resv_region function > because it's been removed in this patchset. > This shouldn't change any behavior and the same regions should be reserved. > Okay, I understand it now. Thanks for the explanation. Best regards, Lu Baolu