Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756857AbYKUQ3t (ORCPT ); Fri, 21 Nov 2008 11:29:49 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756907AbYKUQ1A (ORCPT ); Fri, 21 Nov 2008 11:27:00 -0500 Received: from outbound-va3.frontbridge.com ([216.32.180.16]:3674 "EHLO VA3EHSOBE001.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756253AbYKUQ0c (ORCPT ); Fri, 21 Nov 2008 11:26:32 -0500 X-BigFish: VPS-2(zz4015Mzzzzz32i43j62h) X-Spam-TCS-SCL: 1:0 X-FB-SS: 5, X-WSS-ID: 0KAOYZK-03-S7V-01 From: Joerg Roedel To: Ingo Molnar , Thomas Gleixner CC: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, iommu@lists.linux-foundation.org Subject: [PATCH 0/10] DMA-API debugging facility Date: Fri, 21 Nov 2008 17:26:00 +0100 Message-ID: <1227284770-19215-1-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.5.6.4 X-OriginalArrivalTime: 21 Nov 2008 16:26:10.0469 (UTC) FILETIME=[DD108D50:01C94BF5] MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3715 Lines: 87 Hi, this patchset introduces code to debug drivers usage of the DMA-API. Tests with hardware IOMMUs have shown several bugs in drivers regarding the usage of that API. Problems were found especially in network card drivers. These bugs often don't show up or have any negative impact if there is no hardware IOMMU in use in the system. But with an hardware IOMMU these bugs turn the hardware unusable or, in the worst case, cause data corruption on devices which are managed by other (good) drivers. With the code these patches introduce driver developers can find several bugs of misusing the DMA-API in their drivers. But be aware, it can not find all possible bugs. If it finds a problem it prints out messages like tg3 0000:08:04.0: PCI-DMA: device driver tries to free DMA memory it has not allocated [device address=0x000000042f0f3ae7] [size=48 bytes] Pid: 6285, comm: bash Not tainted 2.6.28-rc5-00176-g6ae6379-dirty #6 Call Trace: [] check_unmap+0x52/0x1ce [] debug_unmap_single+0x61/0xa4 [] skb_dma_unmap+0xf2/0x10c [] tg3_poll+0xe8/0x822 [] mix_pool_bytes_extract+0x5c/0x155 [] net_rx_action+0x9d/0x170 [] __do_softirq+0x7a/0x13d [] call_softirq+0x1c/0x28 [] do_softirq+0x2c/0x68 [] irq_exit+0x3f/0x85 [] do_IRQ+0x14d/0x16f [] ret_from_intr+0x0/0xa [] memcmp+0xb/0x22 [] __d_lookup+0xb9/0xf9 [] do_lookup+0x2a/0x1c1 [] __link_path_walk+0x331/0xc0d [] path_walk+0x46/0x8b [] do_path_lookup+0xff/0x121 [] path_lookup_open+0x54/0x95 [] do_filp_open+0x9d/0x782 [] alloc_fd+0x69/0x10c [] do_sys_open+0x48/0xcc [] system_call_fastpath+0x16/0x1b or (from another machine with AMD IOMMU): ixgbe 0000:02:00.0: PCI-DMA: device driver frees DMA memory with different size [device address=0x0000000003fed812] [map size=258 bytes] [unmap size=256 bytes] Pid: 6178, comm: rmmod Not tainted 2.6.28-rc5 #4 Call Trace: [] iommu_queue_inv_iommu_pages+0x5e/0x70 [] check_unmap+0x1c6/0x240 [] debug_unmap_single+0xb5/0x110 [] ixgbe_clean_rx_ring+0x147/0x220 [] ixgbe_down+0x2fd/0x3d0 [ixgbe] [] ixgbe_close+0x13/0xc0 [ixgbe] [] dev_close+0x56/0xa0 [] rollback_registered+0x43/0x220 [] unregister_netdevice+0x15/0x60 [] unregister_netdev+0x11/0x20 [] ixgbe_remove+0x48/0x16e [ixgbe] [] pci_device_remove+0x2c/0x60 [] __device_release_driver+0x99/0x100 [] driver_detach+0xb8/0xc0 [] bus_remove_driver+0x8e/0xd0 [] pci_unregister_driver+0x34/0x90 [] sys_delete_module+0x1c7/0x2a0 [] do_munmap+0x349/0x390 [] __up_write+0x21/0x150 [] system_call_fastpath+0x16/0x1b This way driver developers get an idea where the problem is in their code. Please review and send any objections or, if there are none, consider for inclusion ;) Thanks, Joerg -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/