[alsa-devel] [PATCH] ASoC: omap-pcm: Lower the dma coherent mask to 32bits

Peter Ujfalusi peter.ujfalusi at ti.com
Thu Dec 5 16:33:46 CET 2013

On 12/05/2013 11:56 AM, Russell King - ARM Linux wrote:
> On Thu, Dec 05, 2013 at 10:06:42AM +0200, Peter Ujfalusi wrote:
>> The underlying API dma_coerce_mask_and_coherent() checks the requested bits
>> mask against the size of dma_addr_t which is 32bits on OMAP.
>> Because of the previously used 64bits mask audio was not probing after
>> commit c9bd5e6 (and 4dcfa6007).
>> 32bits for the DMA_BIT_MASK looks to be the correct one to use.
>> Signed-off-by: Peter Ujfalusi <peter.ujfalusi at ti.com>
>> ---
>> Hi Mark,
>> This is the fix for OMAP audio for 3.13-rc2+. The dma coherent changes went in
>> between -rc1 and -rc2 which broke things because omap-pcm was using 64bits for
>> dma coherent mask.
> Can you please try to understand _why_ it broke and post an explanation.
> This breakage wasn't expected and shouldn't have happened.

I'm not that familiar with this part of the code (mm, dma-mapping) but so far
this is what I found:

ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(64));
is successful, no failure to set the mask to 64.

later on when requesting the dma channel however:
arm_dma_alloc() -> get_coherent_dma_mask()  fails.

As far I can see we have different checks in case of
dma_coerce_mask_and_coherent() and arm_dma_alloc():

[1] dma_coerce_mask_and_coherent() -> dma_supported()

 	if (sizeof(mask) != sizeof(dma_addr_t) &&
 	    mask > (dma_addr_t)~0 &&
 	    dma_to_pfn(dev, ~0) > arm_dma_pfn_limit)  /* !!! */
 		return 0;

[2] arm_dma_alloc() -> get_coherent_dma_mask()

 	if (sizeof(mask) != sizeof(dma_addr_t) &&
 	    mask > (dma_addr_t)~0 &&
 	    dma_to_pfn(dev, ~0) > min(max_pfn, arm_dma_pfn_limit)) /* !!! */
 		return 0;

On omap4:
max_pfn: 0xc0000, arm_dma_pfn_limit: 0xfffff

Not sure which check is the correct one but I think in both cases we should
have the same check in this way we can catch the issue at
dma_coerce_mask_and_coherent() time and try to figure out what to do.
In case of omap-pcm we request for 64 bit because of future SoCs, but I think
it would be fine to try first 64 and in case it is not supported fall back to 32.


More information about the Alsa-devel mailing list