Re: [PATCH 9/9] x86/iommu: use dma_ops_list in get_dma_ops

From: Joerg Roedel
Date: Sun Sep 28 2008 - 14:44:40 EST


On Sun, Sep 28, 2008 at 11:21:23PM +0900, FUJITA Tomonori wrote:
> > +struct dma_mapping_ops *find_dma_ops_for_device(struct device *dev)
> > +{
> > + int i;
> > + unsigned long flags;
> > + struct dma_mapping_ops *entry, *ops = NULL;
> > +
> > + read_lock_irqsave(&dma_ops_list_lock, flags);
> > +
> > + for (i = 0; i < DMA_OPS_TYPE_MAX; ++i)
> > + list_for_each_entry(entry, &dma_ops_list[i], list) {
> > + if (!entry->device_supported)
> > + continue;
> > + if (entry->device_supported(dev)) {
> > + ops = entry;
> > + goto out;
> > + }
> > + }
> > +out:
> > + read_unlock_irqrestore(&dma_ops_list_lock, flags);
>
> Hmm, every time we call dma_sg/map_single, we call
> read_lock_irqsave(&dma_ops_list_lock, flags). It's likely that we see
> notable performance drop?

Hmm, we should only call find_dma_ops_for_device() the first time a
dma api call is done (look into get_dma_ops). But I also thought about
how this lock can be avoided. In the real world it should not be
necessary because the dma_ops list is initialized before dma api calls
are done. But since there is now a register function which can be called
its safer this way. What do you think, are we still safe enough without
this lock?

Joerg

--
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/