Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755169AbYLAMBq (ORCPT ); Mon, 1 Dec 2008 07:01:46 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753045AbYLAMBh (ORCPT ); Mon, 1 Dec 2008 07:01:37 -0500 Received: from sh.osrg.net ([192.16.179.4]:37082 "EHLO sh.osrg.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753083AbYLAMBg (ORCPT ); Mon, 1 Dec 2008 07:01:36 -0500 Date: Mon, 1 Dec 2008 21:01:06 +0900 To: joro@8bytes.org Cc: tsbogend@alpha.franken.de, linux-kernel@vger.kernel.org, mingo@elte.hu Subject: Re: [PATCH v3] Fix dma_mapping_error for 32bit x86 From: FUJITA Tomonori In-Reply-To: <20081201113451.GA24323@8bytes.org> References: <20081129124627.F2ABDFA8C8@solo.franken.de> <20081201113451.GA24323@8bytes.org> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20081201210110L.fujita.tomonori@lab.ntt.co.jp> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3119 Lines: 69 On Mon, 1 Dec 2008 12:34:51 +0100 Joerg Roedel wrote: > On Sat, Nov 29, 2008 at 01:46:27PM +0100, Thomas Bogendoerfer wrote: > > Devices like b44 ethernet can't dma from addresses above 1GB. The driver > > handles this cases by falling back to GFP_DMA allocation. But for detecting > > the problem it needs to get an indication from dma_mapping_error. > > The bug is triggered by using a VMSPLIT option of 2G/2G. > > Looks like your system uses swiotlb as the dma_ops backend. Its the only > implementation providing the ops->mapping_error callback and does not > use bad_dma_address as the error value. I think that you misunderstand the problem. He uses X86_32 so swiotlb should not be used (which is available on only X86_64 and IA64 for now). b44 needs an address under 1GB so it sets device->dma_mask to DMA_30BIT_MASK. With VMSPLIT option of 2G/2G, I guess that b44 could get addresses above 1GB from the networking subsystem. In such case, nommu_map_single returns bad_dma_address properly, but on X86_32, dma_mapping_error always returns 0 (success). So b44 wrongly thinks that the address is under 1GB. This patch fixes dma_mapping_error() to check a passed address properly (compares it with bad_dma_address). As I already wrote, the current git needs a patch modified slightly: http://marc.info/?l=linux-kernel&m=122797163405377&w=2 > > Signed-off-by: Thomas Bogendoerfer > > Acked-by: Joerg Roedel > > > > > diff -ru orig/linux-2.6.27.4/include/asm-x86/dma-mapping.h linux-2.6.27.4/include/asm-x86/dma-mapping.h > > --- orig/linux-2.6.27.4/include/asm-x86/dma-mapping.h 2008-10-26 00:05:07.000000000 +0200 > > +++ linux-2.6.27.4/include/asm-x86/dma-mapping.h 2008-10-26 11:06:14.000000000 +0100 > > @@ -74,15 +74,13 @@ > > /* Make sure we keep the same behaviour */ > > static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr) > > { > > -#ifdef CONFIG_X86_32 > > - return 0; > > -#else > > +#ifdef CONFIG_X86_64 > > struct dma_mapping_ops *ops = get_dma_ops(dev); > > if (ops->mapping_error) > > return ops->mapping_error(dev, dma_addr); > > > > - return (dma_addr == bad_dma_address); > > #endif > > + return (dma_addr == bad_dma_address); > > } > > > > #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) > > -- > > 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/ > -- > 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/ -- 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/