From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>,
Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, Mark Brown <broonie@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Jarkko Nikula <jarkko.nikula@bitmer.com>
Subject: Re: [PATCH] ASoC: omap-pcm: Lower the dma coherent mask to 32bits
Date: Tue, 10 Dec 2013 12:00:37 +0200 [thread overview]
Message-ID: <52A6E645.3080507@ti.com> (raw)
In-Reply-To: <52A6E0C5.1080103@ti.com>
One note for the patch:
On 12/10/2013 11:37 AM, Peter Ujfalusi wrote:
> Hi Russell,
>
> On 12/09/2013 07:03 PM, Russell King - ARM Linux wrote:
>> Yes, that's a good idea. Revised version of the patch. Peter, can you
>> retest please, thanks.
>
> With this patch PandaES and BeagleXM works fine on top of today's mainline.
>
> Thank you Russell and Takashi!
>
> Tested-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
>
>> diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
>> index f6b6bfa88ecf..86c564e52ea7 100644
>> --- a/arch/arm/mm/dma-mapping.c
>> +++ b/arch/arm/mm/dma-mapping.c
>> @@ -158,6 +158,44 @@ struct dma_map_ops arm_coherent_dma_ops = {
>> };
>> EXPORT_SYMBOL(arm_coherent_dma_ops);
>>
>> +static int __dma_supported(struct device *dev, u64 mask, bool warn)
>> +{
>> + unsigned long max_dma_pfn;
>> +
>> + /*
>> + * If the mask allows for more memory than we can address,
>> + * and we actually have that much memory, then we must
>> + * indicate that DMA to this device is not supported.
>> + */
>> + if (sizeof(mask) != sizeof(dma_addr_t) &&
>> + mask > (dma_addr_t)~0 &&
>> + dma_to_pfn(dev, ~0) < max_pfn) {
>> + if (warn) {
>> + dev_warn(dev, "Coherent DMA mask %#llx is larger than dma_addr_t allows\n",
>> + mask);
>> + dev_warn(dev, "Driver did not use or check the return value from dma_set_coherent_mask()?\n");
>> + }
>> + return 0;
>> + }
>> +
>> + max_dma_pfn = min(max_pfn, arm_dma_pfn_limit);
>> +
>> + /*
>> + * Translate the device's DMA mask to a PFN limit. This
>> + * PFN number includes the page which we can DMA to.
>> + */
>> + if (dma_to_pfn(dev, mask) < max_dma_pfn) {
>> + if (warn)
>> + dev_warn(dev, "Coherent DMA mask %#llx (pfn %#lx-%#lx) covers a smaller range of system memory than the DMA zone pfn 0x0-%#lx\n",
>> + mask,
>> + dma_to_pfn(dev, 0), dma_to_pfn(dev, mask) + 1,
>> + max_dma_pfn + 1);
>> + return 0;
>> + }
>> +
>> + return 1;
>> +}
>> +
>> static u64 get_coherent_dma_mask(struct device *dev)
>> {
>> u64 mask = (u64)DMA_BIT_MASK(32);
CC arch/arm/mach-omap2/control.o
arch/arm/mm/dma-mapping.c: In function ‘get_coherent_dma_mask’:
arch/arm/mm/dma-mapping.c:204:17: warning: unused variable ‘max_dma_pfn’ [-Wunused-variable]
unsigned long max_dma_pfn;
^
>> @@ -176,34 +214,8 @@ static u64 get_coherent_dma_mask(struct device *dev)
>> return 0;
>> }
>>
>> - max_dma_pfn = min(max_pfn, arm_dma_pfn_limit);
>> -
>> - /*
>> - * If the mask allows for more memory than we can address,
>> - * and we actually have that much memory, then fail the
>> - * allocation.
>> - */
>> - if (sizeof(mask) != sizeof(dma_addr_t) &&
>> - mask > (dma_addr_t)~0 &&
>> - dma_to_pfn(dev, ~0) > max_dma_pfn) {
>> - dev_warn(dev, "Coherent DMA mask %#llx is larger than dma_addr_t allows\n",
>> - mask);
>> - dev_warn(dev, "Driver did not use or check the return value from dma_set_coherent_mask()?\n");
>> - return 0;
>> - }
>> -
>> - /*
>> - * Now check that the mask, when translated to a PFN,
>> - * fits within the allowable addresses which we can
>> - * allocate.
>> - */
>> - if (dma_to_pfn(dev, mask) < max_dma_pfn) {
>> - dev_warn(dev, "Coherent DMA mask %#llx (pfn %#lx-%#lx) covers a smaller range of system memory than the DMA zone pfn 0x0-%#lx\n",
>> - mask,
>> - dma_to_pfn(dev, 0), dma_to_pfn(dev, mask) + 1,
>> - arm_dma_pfn_limit + 1);
>> + if (!__dma_supported(dev, mask, true))
>> return 0;
>> - }
>> }
>>
>> return mask;
>> @@ -1032,28 +1044,7 @@ void arm_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
>> */
>> int dma_supported(struct device *dev, u64 mask)
>> {
>> - unsigned long limit;
>> -
>> - /*
>> - * If the mask allows for more memory than we can address,
>> - * and we actually have that much memory, then we must
>> - * indicate that DMA to this device is not supported.
>> - */
>> - if (sizeof(mask) != sizeof(dma_addr_t) &&
>> - mask > (dma_addr_t)~0 &&
>> - dma_to_pfn(dev, ~0) > arm_dma_pfn_limit)
>> - return 0;
>> -
>> - /*
>> - * Translate the device's DMA mask to a PFN limit. This
>> - * PFN number includes the page which we can DMA to.
>> - */
>> - limit = dma_to_pfn(dev, mask);
>> -
>> - if (limit < arm_dma_pfn_limit)
>> - return 0;
>> -
>> - return 1;
>> + return __dma_supported(dev, mask, false);
>> }
>> EXPORT_SYMBOL(dma_supported);
>>
>>
>
>
--
Péter
next prev parent reply other threads:[~2013-12-10 10:00 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-05 8:06 [PATCH] ASoC: omap-pcm: Lower the dma coherent mask to 32bits Peter Ujfalusi
2013-12-05 9:56 ` Russell King - ARM Linux
2013-12-05 15:33 ` Peter Ujfalusi
2013-12-05 19:28 ` Russell King - ARM Linux
2013-12-05 20:11 ` Takashi Iwai
2013-12-05 21:07 ` Russell King - ARM Linux
2013-12-06 8:12 ` Takashi Iwai
2013-12-06 12:25 ` Russell King - ARM Linux
2013-12-06 13:04 ` Takashi Iwai
2013-12-09 9:56 ` Peter Ujfalusi
2013-12-09 17:03 ` Russell King - ARM Linux
2013-12-10 9:37 ` Peter Ujfalusi
2013-12-10 10:00 ` Peter Ujfalusi [this message]
2013-12-13 11:46 ` Peter Ujfalusi
2013-12-13 11:49 ` Russell King - ARM Linux
2013-12-13 11:50 ` Peter Ujfalusi
2013-12-06 9:31 ` Peter Ujfalusi
2013-12-06 12:33 ` Russell King - ARM Linux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52A6E645.3080507@ti.com \
--to=peter.ujfalusi@ti.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=jarkko.nikula@bitmer.com \
--cc=lgirdwood@gmail.com \
--cc=linux@arm.linux.org.uk \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.