Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752879AbZAKIJT (ORCPT ); Sun, 11 Jan 2009 03:09:19 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751183AbZAKIJA (ORCPT ); Sun, 11 Jan 2009 03:09:00 -0500 Received: from 8bytes.org ([88.198.83.132]:56052 "EHLO 8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751134AbZAKII7 (ORCPT ); Sun, 11 Jan 2009 03:08:59 -0500 Date: Sun, 11 Jan 2009 09:08:58 +0100 From: Joerg Roedel To: FUJITA Tomonori Cc: joerg.roedel@amd.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, mingo@redhat.com Subject: Re: [PATCH 15/16] dma-debug: x86 architecture bindings Message-ID: <20090111080858.GL9466@8bytes.org> References: <1231517970-20288-1-git-send-email-joerg.roedel@amd.com> <1231517970-20288-16-git-send-email-joerg.roedel@amd.com> <20090111152209D.fujita.tomonori@lab.ntt.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090111152209D.fujita.tomonori@lab.ntt.co.jp> User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2547 Lines: 70 On Sun, Jan 11, 2009 at 03:25:47PM +0900, FUJITA Tomonori wrote: > On Fri, 9 Jan 2009 17:19:29 +0100 > Joerg Roedel wrote: > > > Impact: make use of DMA-API debugging code in x86 > > > > Signed-off-by: Joerg Roedel > > --- > > arch/x86/Kconfig | 1 + > > arch/x86/include/asm/dma-mapping.h | 30 ++++++++++++++++++++++++++---- > > arch/x86/kernel/pci-dma.c | 5 +++++ > > 3 files changed, 32 insertions(+), 4 deletions(-) > > > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > > index 862adb9..68a806c 100644 > > --- a/arch/x86/Kconfig > > +++ b/arch/x86/Kconfig > > @@ -39,6 +39,7 @@ config X86 > > select HAVE_GENERIC_DMA_COHERENT if X86_32 > > select HAVE_EFFICIENT_UNALIGNED_ACCESS > > select USER_STACKTRACE_SUPPORT > > + select HAVE_DMA_API_DEBUG > > > > config ARCH_DEFCONFIG > > string > > diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h > > index 4035357..939d5b3 100644 > > --- a/arch/x86/include/asm/dma-mapping.h > > +++ b/arch/x86/include/asm/dma-mapping.h > > @@ -7,6 +7,7 @@ > > */ > > > > #include > > +#include > > #include > > #include > > #include > > @@ -93,9 +94,12 @@ dma_map_single(struct device *hwdev, void *ptr, size_t size, > > int direction) > > { > > struct dma_mapping_ops *ops = get_dma_ops(hwdev); > > + dma_addr_t addr; > > > > BUG_ON(!valid_dma_direction(direction)); > > - return ops->map_single(hwdev, virt_to_phys(ptr), size, direction); > > + addr = ops->map_single(hwdev, virt_to_phys(ptr), size, direction); > > + debug_map_single(hwdev, ptr, size, direction, addr); > > + return addr; > > What happens if ops->map_single fails? > > Seems that debug_map_single doesn't check the dma mapping fails. So it > allocates a new entries and nobody frees it? Ah true. The debug_map_single function has to check for dma_mapping_error. Same is true for debug_map_sg. > Another problem is that what happens if ops->map_single succeeds but > debug_map_single fails? Seems that it gives a false warning. No, this can not happen. If the code fails it disables itself so no more warnings will be printed. 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/