From patchwork Fri Feb 6 02:27:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wright X-Patchwork-Id: 22248 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id EF7F4DDE23 for ; Fri, 6 Feb 2009 13:28:31 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753122AbZBFC23 (ORCPT ); Thu, 5 Feb 2009 21:28:29 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752573AbZBFC22 (ORCPT ); Thu, 5 Feb 2009 21:28:28 -0500 Received: from sous-sol.org ([216.99.217.87]:53246 "EHLO sequoia.sous-sol.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750885AbZBFC22 (ORCPT ); Thu, 5 Feb 2009 21:28:28 -0500 Received: from sequoia.sous-sol.org (sequoia.sous-sol.org [127.0.0.1]) by sequoia.sous-sol.org (8.14.2/8.14.2) with ESMTP id n162RxpD023048; Thu, 5 Feb 2009 18:28:00 -0800 Received: (from chrisw@localhost) by sequoia.sous-sol.org (8.14.2/8.14.2/Submit) id n162RxUm023047; Thu, 5 Feb 2009 18:27:59 -0800 Date: Thu, 5 Feb 2009 18:27:59 -0800 From: Chris Wright To: David Woodhouse Cc: Joerg Roedel , fujita.tomonori@lab.ntt.co.jp, netdev@vger.kernel.org, iommu@lists.linux-foundation.org, mingo@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/16] DMA-API debugging facility v2 Message-ID: <20090206022759.GF27684@sequoia.sous-sol.org> References: <1231517970-20288-1-git-send-email-joerg.roedel@amd.com> <1233874352.8135.12.camel@macbook.infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1233874352.8135.12.camel@macbook.infradead.org> User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: ClamAV version 0.93.3, clamav-milter version 0.93.3 on sequoia.sous-sol.org X-Virus-Status: Clean Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org * David Woodhouse (dwmw2@infradead.org) wrote: > This adds a function to dump the DMA mappings that the debugging code is > aware of -- either for a single device, or for _all_ devices. > > This can be useful for debugging -- sticking a call to it in the DMA > page fault handler, for example, to see if the faulting address _should_ > be mapped or not, and hence work out whether it's IOMMU bugs we're > seeing, or driver bugs. BTW, here's how I hooked it up: --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index c933980..df593d1 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c @@ -1072,6 +1072,34 @@ void dmar_msi_read(int irq, struct msi_msg *msg) spin_unlock_irqrestore(&iommu->register_lock, flag); } +static struct pci_dev *domain_find_pdev(u8 bus, u8 devfn) +{ + unsigned long flags; + struct pci_dev *pdev = NULL; + struct device_domain_info *info; + + spin_lock_irqsave(&device_domain_lock, flags); + list_for_each_entry(info, &device_domain_list, global) { + if (info->bus == bus && info->devfn == devfn) { + pdev = info->dev; + break; + } + } + spin_unlock_irqrestore(&device_domain_lock, flags); + return pdev; +} + +static void dump_mappings(u16 source_id) +{ + struct pci_dev *pdev; + u8 bus = source_id >> 8; + u8 devfn = source_id & 0xff; + + pdev = domain_find_pdev(bus, devfn); + if (pdev) + debug_dma_dump_mappings(&pdev->dev); +} + static int iommu_page_fault_do_one(struct intel_iommu *iommu, int type, u8 fault_reason, u16 source_id, unsigned long long addr) { @@ -1086,6 +1114,8 @@ static int iommu_page_fault_do_one(struct intel_iommu *iommu, int type, (type ? "DMA Read" : "DMA Write"), (source_id >> 8), PCI_SLOT(source_id & 0xFF), PCI_FUNC(source_id & 0xFF), addr, fault_reason, reason); + + dump_mappings(source_id); return 0; }