Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3354599ybh; Mon, 5 Aug 2019 17:08:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTRr3aozJoX82BtdIiyE3mhakpgtys3ie2TU2vPlfqytBoGDVjBO31nndx5890SM00HjZW X-Received: by 2002:a62:7641:: with SMTP id r62mr635814pfc.35.1565050135919; Mon, 05 Aug 2019 17:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565050135; cv=none; d=google.com; s=arc-20160816; b=htSrxrhvPyvlpdaubAK/w/kJj13n7y0oDflwdtPq9N/g9HPjZJeZ+TmKI9HyQ6IjQ2 +o8HGJ0lEZaJjkFTDn920Gn2UjnmWFZnvhGjIReZWDWk3oXY3vi20kVVSGwgCVIrBMeo FEBuxbiQ+dMpI8xM3MYWRaSgvqq5mxtrA3ls8AT2H9v3bgjRLDqqpDjpXnJ23/ivR1oj oGfA/C7Nqy/XilMZhftBs/0/rvVCgUf6s+hgvUStW94ZiCj3us2tRXjHvgKHqggVSbQC 4ot/k81TMX7cL0DWctRjBjkIrnGX/SpACrlMzhrduW/xi1bWutjYCv6mzulNGCg3yMBi dkQA== 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=9j7nhZpvpNTQmUnRHfRAMbXzrpRCXlTJmi4lbAy1TsI=; b=lTwE2IzWc2aOTyszODTGyvC4GZObErlZa5frWnRwExB+3lma2TYbRKk54ae5JpTeY7 sYSheVW0cfDznTrTCbjSvxdr1LimAVxHcwiS3lazVEpB0bHBxbE/5mEzbKPQS0RwKKuK wybH8cUQKI+UgurQc7tZ4gkykpzLt5i4CaKcTkIyvXlwYIvvn7oTcoS+Ga8qryddTT5b g+099b5ski6/XtonCFndGgEpCQFP5l/PPd/lXMdye4088x4j26SJIjdEwMHY1NdBSIUe T40uX/A4b2tOK4ZQx02H3HYaIfMqmHSHkCHfswWpF6BhjrNyizgpllEtsniVM0QYNOew qZbA== 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 s23si41435016plq.81.2019.08.05.17.08.40; Mon, 05 Aug 2019 17:08:55 -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 S1731081AbfHFAHl (ORCPT + 99 others); Mon, 5 Aug 2019 20:07:41 -0400 Received: from mga18.intel.com ([134.134.136.126]:19456 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728851AbfHFAHl (ORCPT ); Mon, 5 Aug 2019 20:07:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Aug 2019 17:07:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,350,1559545200"; d="scan'208";a="185478216" Received: from allen-box.sh.intel.com (HELO [10.239.159.136]) ([10.239.159.136]) by orsmga002.jf.intel.com with ESMTP; 05 Aug 2019 17:07:38 -0700 Cc: baolu.lu@linux.intel.com, kevin.tian@intel.com, ashok.raj@intel.com, dima@arista.com, tmurphy@arista.com, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, jacob.jun.pan@intel.com, David Woodhouse , Joerg Roedel Subject: Re: [PATCH v4 12/15] iommu/vt-d: Cleanup get_valid_domain_for_dev() To: Alex Williamson References: <20190525054136.27810-1-baolu.lu@linux.intel.com> <20190525054136.27810-13-baolu.lu@linux.intel.com> <20190717211226.5ffbf524@x1.home> <9957afdd-4075-e7ee-e1e6-97acb870e17a@linux.intel.com> <20190719092303.751659a0@x1.home> <20190801193013.19444803@x1.home> <5258f18f-101e-8a43-edea-3f4bb88ca58b@linux.intel.com> <20190802105406.53cd9977@x1.home> From: Lu Baolu Message-ID: <605e3cdb-35bd-45c6-73be-d3263c11def8@linux.intel.com> Date: Tue, 6 Aug 2019 08:06:49 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190802105406.53cd9977@x1.home> 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 Alex, On 8/3/19 12:54 AM, Alex Williamson wrote: > On Fri, 2 Aug 2019 15:17:45 +0800 > Lu Baolu wrote: > >> Hi Alex, >> >> Thanks for reporting this. I will try to find a machine with a >> pcie-to-pci bridge and get this issue fixed. I will update you >> later. > > Further debug below... > >> On 8/2/19 9:30 AM, Alex Williamson wrote: >>> DMAR: No ATSR found >>> DMAR: dmar0: Using Queued invalidation >>> DMAR: dmar1: Using Queued invalidation >>> pci 0000:00:00.0: DMAR: Software identity mapping >>> pci 0000:00:01.0: DMAR: Software identity mapping >>> pci 0000:00:02.0: DMAR: Software identity mapping >>> pci 0000:00:16.0: DMAR: Software identity mapping >>> pci 0000:00:1a.0: DMAR: Software identity mapping >>> pci 0000:00:1b.0: DMAR: Software identity mapping >>> pci 0000:00:1c.0: DMAR: Software identity mapping >>> pci 0000:00:1c.5: DMAR: Software identity mapping >>> pci 0000:00:1c.6: DMAR: Software identity mapping >>> pci 0000:00:1c.7: DMAR: Software identity mapping >>> pci 0000:00:1d.0: DMAR: Software identity mapping >>> pci 0000:00:1f.0: DMAR: Software identity mapping >>> pci 0000:00:1f.2: DMAR: Software identity mapping >>> pci 0000:00:1f.3: DMAR: Software identity mapping >>> pci 0000:01:00.0: DMAR: Software identity mapping >>> pci 0000:01:00.1: DMAR: Software identity mapping >>> pci 0000:03:00.0: DMAR: Software identity mapping >>> pci 0000:04:00.0: DMAR: Software identity mapping >>> DMAR: Setting RMRR: >>> pci 0000:00:02.0: DMAR: Setting identity map [0xbf800000 - 0xcf9fffff] >>> pci 0000:00:1a.0: DMAR: Setting identity map [0xbe8d1000 - 0xbe8dffff] >>> pci 0000:00:1d.0: DMAR: Setting identity map [0xbe8d1000 - 0xbe8dffff] >>> DMAR: Prepare 0-16MiB unity mapping for LPC >>> pci 0000:00:1f.0: DMAR: Setting identity map [0x0 - 0xffffff] >>> pci 0000:00:00.0: Adding to iommu group 0 >>> pci 0000:00:00.0: Using iommu direct mapping >>> pci 0000:00:01.0: Adding to iommu group 1 >>> pci 0000:00:01.0: Using iommu direct mapping >>> pci 0000:00:02.0: Adding to iommu group 2 >>> pci 0000:00:02.0: Using iommu direct mapping >>> pci 0000:00:16.0: Adding to iommu group 3 >>> pci 0000:00:16.0: Using iommu direct mapping >>> pci 0000:00:1a.0: Adding to iommu group 4 >>> pci 0000:00:1a.0: Using iommu direct mapping >>> pci 0000:00:1b.0: Adding to iommu group 5 >>> pci 0000:00:1b.0: Using iommu direct mapping >>> pci 0000:00:1c.0: Adding to iommu group 6 >>> pci 0000:00:1c.0: Using iommu direct mapping >>> pci 0000:00:1c.5: Adding to iommu group 7 >>> pci 0000:00:1c.5: Using iommu direct mapping >>> pci 0000:00:1c.6: Adding to iommu group 8 >>> pci 0000:00:1c.6: Using iommu direct mapping >>> pci 0000:00:1c.7: Adding to iommu group 9 > > Note that group 9 contains device 00:1c.7 > >>> pci 0000:00:1c.7: Using iommu direct mapping > > I'm booted with iommu=pt, so the domain type is IOMMU_DOMAIN_PT > >>> pci 0000:00:1d.0: Adding to iommu group 10 >>> pci 0000:00:1d.0: Using iommu direct mapping >>> pci 0000:00:1f.0: Adding to iommu group 11 >>> pci 0000:00:1f.0: Using iommu direct mapping >>> pci 0000:00:1f.2: Adding to iommu group 11 >>> pci 0000:00:1f.3: Adding to iommu group 11 >>> pci 0000:01:00.0: Adding to iommu group 1 >>> pci 0000:01:00.1: Adding to iommu group 1 >>> pci 0000:03:00.0: Adding to iommu group 12 >>> pci 0000:03:00.0: Using iommu direct mapping >>> pci 0000:04:00.0: Adding to iommu group 13 >>> pci 0000:04:00.0: Using iommu direct mapping >>> pci 0000:05:00.0: Adding to iommu group 9 > > 05:00.0 is downstream of 00:1c.7 and in the same group. As above, the > domain is type IOMMU_DOMAIN_IDENTITY, so we take the following branch: > > } else { > if (device_def_domain_type(dev) == IOMMU_DOMAIN_DMA) { > > Default domain type is IOMMU_DOMAIN_DMA because of the code block in > device_def_domain_type() handling bridges to conventional PCI and > conventional PCI endpoints. > > ret = iommu_request_dma_domain_for_dev(dev); > > This fails in request_default_domain_for_dev() because there's more > than one device in the group. > > if (ret) { > dmar_domain->flags |= DOMAIN_FLAG_LOSE_CHILDREN; > if (!get_private_domain_for_dev(dev)) { > > With this commit, this now returns NULL because find_domain() does find > a domain, the same one we found before this code block. > > dev_warn(dev, > "Failed to get a private domain.\n"); > return -ENOMEM; > } > > So the key factors are that I'm booting with iommu=pt and I have a > PCIe-to-PCI bridge grouped with its parent root port. The bridge > wants an IOMMU_DOMAIN_DMA, but the group domain is already of type > IOMMU_DOMAIN_IDENTITY. A temporary workaround is to not use > passthrough mode, but this is a regression versus previous kernels. > Thanks, > I can reproduce this issue with a local setup. I will submit the fix and cc it to you. Please let me know if that fix doesn't solve this problem. Best regards, Baolu