iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* dma_alloc_coherent not allocating memory from CMA Reserved.
       [not found] <CGME20200918045919epcms5p170ffa89ef95533e98706f6bbdd744fc0@epcms5p1>
@ 2020-09-18  4:59 ` ANKIT SONI
  0 siblings, 0 replies; 3+ messages in thread
From: ANKIT SONI @ 2020-09-18  4:59 UTC (permalink / raw)
  To: iommu; +Cc: Sathyavathi M


[-- Attachment #1.1: Type: text/html, Size: 5033 bytes --]

[-- Attachment #1.2: Type: image/gif, Size: 13402 bytes --]

[-- Attachment #2: Type: text/plain, Size: 156 bytes --]

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dma_alloc_coherent not allocating memory from CMA Reserved
  2020-09-23  7:43 ` Sathyavathi M
@ 2020-09-23 13:53   ` Robin Murphy
  0 siblings, 0 replies; 3+ messages in thread
From: Robin Murphy @ 2020-09-23 13:53 UTC (permalink / raw)
  To: sathya.m, iommu

On 2020-09-23 08:43, Sathyavathi M wrote:
> Hi All,
> 
> I am trying to allocate coherent memory for 33 MB in kerenl driver. and for that
> i have reserved CMA of 1024 MB, but from dmesg, i can see that address reserved
> for cma is different and what i get with dma_alloc_coherent is different. My pc
> is intel x86 machine and tried in different motherboard, but this issue is
> occuring in some specific PCs. please help me in debugging the actual issue,
> below are kernel bootup logs
> 
> 
> [ 0.014362] No NUMA configuration found
> [ 0.014363] Faking a node at [mem 0x0000000000000000-0x000000021edfffff]
> [ 0.014374] NODE_DATA(0) allocated [mem 0x21edd5000-0x21edfffff]
> [ 0.014538] *cma: Reserved 400 MiB at 0x0000000205c00000*
> [ 0.014541] Reserving 640MB of memory at 2512MB for crashkernel (System RAM: 8046MB)
> [ 0.014553] Zone ranges:
> [ 0.014554] DMA [mem 0x0000000000001000-0x0000000000ffffff]
> [ 0.014554] DMA32 [mem 0x0000000001000000-0x00000000ffffffff]
> [ 0.014555] Normal [mem 0x0000000100000000-0x000000021edfffff]
> 
> 
> *at dma_alloc_coherent call
> [ 27.816062] dev->dma_33M_addr is f8000000*

I'm confused - if you got a DMA address back, then the allocation must 
have succeeded, so what exactly is the issue there? If the allocator 
managed to find a suitable amount of memory that your device can 
address, does it really matter exactly where it came from?

Also bear in mind that a DMA address is not necessarily the same as a 
physical address anyway, if for instance you have an IOMMU or other 
forms of interconnect translation. In fact the default behaviour of the 
intel-iommu driver for a PCI device is to allocate DMA addresses in 
naturally-aligned regions downwards from 4GB - if the first request in 
an empty address space was for 33MB, it would get rounded up to 64MB, 
wouldn't fit at 4GB - 64MB (0xfc000000) because that would clash with 
the IOAPIC region, so would end up at 4GB - 128MB (0xf8000000). Now 
where have I seen that before?...

Robin.

> ---------------------------------------------------------------------------------------------------------------
> and below are the logs in working case, at driver dma_alloc_coherent api call we
> have address which is in range of what reserved for cma.
> at boot i get..
> Faking a node at [mem 0x0000000000000000-0x000000019fdfffff]
> NODE_DATA(0) allocated [mem 0x19fdd3000-0x19fdfdfff]
> *cma: Reserved 800 MiB at 0x000000016dc00000*
> Reserving 640MB of memory at 1792MB for crashkernel (System RAM: 6016MB)
> Zone ranges:
> DMA [mem 0x0000000000001000-0x0000000000ffffff]
> DMA32 [mem 0x0000000001000000-0x00000000ffffffff]
> Normal [mem 0x0000000100000000-0x000000019fdfffff]
> 
> *at dma_alloc_coherent call
> dev->dma_33M_addr is 16e200000*
> 
> Please help me in solving this iissue, or can suggest any alternative way to
> allocate big coherent memory.
> 
> Regards,
> 
> Sathya
> 
> 
> _______________________________________________
> iommu mailing list
> iommu@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu
> 
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* dma_alloc_coherent not allocating memory from CMA Reserved
       [not found] <CGME20200923074314epcms5p8cfc65267615d27472df670f5806cb5a4@epcms5p8>
@ 2020-09-23  7:43 ` Sathyavathi M
  2020-09-23 13:53   ` Robin Murphy
  0 siblings, 1 reply; 3+ messages in thread
From: Sathyavathi M @ 2020-09-23  7:43 UTC (permalink / raw)
  To: iommu


[-- Attachment #1.1: Type: text/html, Size: 5066 bytes --]

[-- Attachment #1.2: 201602111742151_N3WZA6X7.png --]
[-- Type: image/png, Size: 33527 bytes --]

[-- Attachment #2: Type: text/plain, Size: 156 bytes --]

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-23 13:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20200918045919epcms5p170ffa89ef95533e98706f6bbdd744fc0@epcms5p1>
2020-09-18  4:59 ` dma_alloc_coherent not allocating memory from CMA Reserved ANKIT SONI
     [not found] <CGME20200923074314epcms5p8cfc65267615d27472df670f5806cb5a4@epcms5p8>
2020-09-23  7:43 ` Sathyavathi M
2020-09-23 13:53   ` Robin Murphy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).