Re: [PATCH] dma-debug: Add dma map/unmap error tracking support

From: Konrad Rzeszutek Wilk
Date: Wed Sep 05 2012 - 07:57:37 EST


On Tue, Sep 04, 2012 at 04:57:56PM -0600, Shuah Khan wrote:
> On Tue, 2012-09-04 at 17:05 -0400, Konrad Rzeszutek Wilk wrote:
> > On Sun, Sep 02, 2012 at 08:14:17AM -0600, Shuah Khan wrote:
> > > A recent dma mapping error analysis effort showed that a large precentage
> > > of dma_map_single() and dma_map_page() returns are not checked for mapping
> > > errors. Reference: https://lkml.org/lkml/2012/8/10/326
> > >
> >
> > So were you able to catch some naughty drivers with this?
>
> I did compile a complete list of drivers that don't check dma mapping
> errors from my analysis. Are you interested in seeing the full analysis?

Yes, plus the authors of the drivers are probably interested in it as
well.
..snip..
> > I was initially thinking that this patch would contain a state for the driver
> > of whether after map it has called dma_mapping_error. So this function would
> > increment some internal state, and if dma_mapping_error on that specific dma_addr
> > it would decrement it. If it never occured, then we would print on the unmap
> > that the device never had called dma_mapping_error on said dma_addr?
>
> That is a good idea. Let me see if I understand what you are saying
> correctly. Add a new field to dma_debug_entry structure and keep state
> and clear it if dma_mapping_error() is called. This will require adding
> a debug interface for dma_mapping_error() which is not hard to do. Is
> this close to what you are thinking?

Right. It is more complex than this patch but it should provide a nicer
"trap" mechanism to alert driver writers that they are not checking DMA
addresses properly.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/