From patchwork Wed Oct 14 21:35:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 7398791 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AD97DBEEA4 for ; Wed, 14 Oct 2015 21:35:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1C112042A for ; Wed, 14 Oct 2015 21:35:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D727B20774 for ; Wed, 14 Oct 2015 21:35:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932424AbbJNVfn (ORCPT ); Wed, 14 Oct 2015 17:35:43 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:44438 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932399AbbJNVfm (ORCPT ); Wed, 14 Oct 2015 17:35:42 -0400 Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZmThz-0003EM-PD; Wed, 14 Oct 2015 21:35:40 +0000 Message-ID: <1444858536.125804.195.camel@infradead.org> Subject: Re: [PATCH v2 04/10] iommu/vt-d: Assume BIOS lies about ATSR for integrated gfx From: David Woodhouse To: iommu@lists.linux-foundation.org, intel-gfx@lists.freedesktop.org, Jesse Barnes Cc: linux-pci@vger.kernel.org, Bjorn Helgaas Date: Wed, 14 Oct 2015 22:35:36 +0100 In-Reply-To: <1444772049.125804.62.camel@infradead.org> References: <1444771787.125804.50.camel@infradead.org> <1444772049.125804.62.camel@infradead.org> X-Mailer: Evolution 3.16.5 (3.16.5-3.fc22) Mime-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 2015-10-13 at 22:34 +0100, David Woodhouse wrote: > If the device itself reports ATS in its PCIe capabilities, but the BIOS > neglects to provide an ATSR structure to indicate that the root port can > also cope, then assume the latter is lying. Except, of course, that integrated devices aren't behind a root port. I think this should fix it the correct way? diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 4f2eab6..70a031d 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -4280,14 +4280,17 @@ int dmar_find_matched_atsr_unit(struct pci_dev *dev) dev = pci_physfn(dev); for (bus = dev->bus; bus; bus = bus->parent) { bridge = bus->self; - if (!bridge || !pci_is_pcie(bridge) || + /* If it's an integrated device, allow ATS */ + if (!bridge) + return 1; + /* Connected via non-PCIe: no ATS */ + if (!pci_is_pcie(bridge) || pci_pcie_type(bridge) == PCI_EXP_TYPE_PCI_BRIDGE) return 0; + /* If we found the root port, look it up in the ATSR */ if (pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT) break; } - if (!bridge) - return 0; rcu_read_lock(); list_for_each_entry_rcu(atsru, &dmar_atsr_units, list) {