Messages in this thread | | | Date | Wed, 25 Feb 2009 12:14:19 +0100 | From | Joerg Roedel <> | Subject | Re: [PATCH 15/16] dma-debug: x86 architecture bindings |
| |
On Sun, Feb 22, 2009 at 03:50:46PM +0900, FUJITA Tomonori wrote: > On Mon, 19 Jan 2009 15:47:02 +0100 > Joerg Roedel <joerg.roedel@amd.com> wrote: > > > Impact: make use of DMA-API debugging code in x86 > > > > Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> > > --- > > arch/x86/Kconfig | 1 + > > arch/x86/include/asm/dma-mapping.h | 45 +++++++++++++++++++++++++++++++---- > > arch/x86/kernel/pci-dma.c | 6 ++++ > > 3 files changed, 46 insertions(+), 6 deletions(-) > > (snip) > > > static inline int > > @@ -79,9 +86,13 @@ dma_map_sg(struct device *hwdev, struct scatterlist *sg, > > int nents, enum dma_data_direction dir) > > { > > struct dma_map_ops *ops = get_dma_ops(hwdev); > > + int ents; > > > > BUG_ON(!valid_dma_direction(dir)); > > - return ops->map_sg(hwdev, sg, nents, dir, NULL); > > + ents = ops->map_sg(hwdev, sg, nents, dir, NULL); > > + debug_dma_map_sg(hwdev, sg, ents, dir); > > The way to handle dma_map_sg and dma_unmap_sg looks wrong. > > ents could be smaller than nents here with IOMMU implementations that > merge several sg entries into one. > > > > + return ents; > > } > > > > static inline void > > @@ -91,6 +102,7 @@ dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents, > > struct dma_map_ops *ops = get_dma_ops(hwdev); > > > > BUG_ON(!valid_dma_direction(dir)); > > + debug_dma_unmap_sg(hwdev, sg, nents, dir); > > Here the nents is the same one you passed into dma_map_sg call. It is > not the value returned from dma_map_sg (see DMA-mapping.txt). > > So we call check_unmap for entries that we didn't call add_dma_entry > for on dma_map_sg. These entries are not initialized so we could get any > kinds of warnings from check_unmap.
Ah, you are right. I mis-read the documentation. I will fix this in the next release.
Joerg
-- | Advanced Micro Devices GmbH Operating | Karl-Hammerschmidt-Str. 34, 85609 Dornach bei München System | Research | Geschäftsführer: Jochen Polster, Thomas M. McCoy, Giuliano Meroni Center | Sitz: Dornach, Gemeinde Aschheim, Landkreis München | Registergericht München, HRB Nr. 43632
-- 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/
| |