Re: [PATCH v4 2/6] dmaengine: Add dma_chan_is_in_use() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 26, 2008 at 6:23 AM, Haavard Skinnemoen
<haavard.skinnemoen@xxxxxxxxx> wrote:
> This moves the code checking if a DMA channel is in use from
> show_in_use() into an inline helper function, dma_is_in_use(). DMA
> controllers can use this in order to give clients exclusive access to
> channels (usually necessary when setting up slave DMA.)
>
> I have to admit that I don't really understand the channel refcounting
> logic at all... dma_chan_get() simply increments a per-cpu value. How
> can we be sure that whatever CPU calls dma_chan_is_in_use() sees the
> same value?

As Chris noted in the comments at the top of dmaengine.c this is an
implementation Rusty's 'bigref'.  It seeks to avoid the
cache-line-bouncing overhead of maintaining a single global refcount
in hot paths like tcp_v{4,6}_rcv().  When the channel is being
removed, a rare event, we transition to the accurate, yet slow, global
method.

Your observation is correct, dma_chan_is_in_use() may lie in the case
when the current cpu is not using the channel.  For this particular
test I think you can look to see if this channel's resources are
already allocated.  If they are then some other client got a hold of
this channel before the current attempt.  Hmm... that would also
require that we free the channel's resources in the case where the
client replies with DMA_NAK, probably something we should do anyways.

Thoughts?

--
Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Gstreamer Embedded]     [Linux MMC Devel]     [U-Boot V2]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux ARM Kernel]     [Linux OMAP]     [Linux SCSI]

  Powered by Linux