All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] Using CMA with devicetree generated devices
@ 2012-10-26 21:02 ` Laura Abbott
  0 siblings, 0 replies; 4+ messages in thread
From: Laura Abbott @ 2012-10-26 21:02 UTC (permalink / raw)
  To: linaro-mm-sig, linux-arm-kernel, Marek Szyprowski
  Cc: linux-arm-msm, Russell King, vgandhi

Is it possible to use the devices generated from device tree for use 
with CMA? The API for reserving a CMA region (dma_declare_contiguous) 
requires a device pointer to properly associate a region with a device. 
By the time the devices from devicetree are actually available 
(generally during machine_init), dma_contiguous_remap has already been 
called so it's too late to have a properly setup region.

I currently see several options:

1) All CMA devices must be statically declared in the board file
2) Scan the FDT to set up 'dummy' devices early which can later be used 
to set up CMA with the 'proper' devices
3) My assumption is completely wrong and the check that I was using is 
invalid:

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 8404601..6d37516 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -368,9 +368,11 @@ struct dma_contig_early_reserve {
  static struct dma_contig_early_reserve dma_mmu_remap[MAX_CMA_AREAS] 
__initdata;

  static int dma_mmu_remap_num __initdata;
+static int is_remapped;

  void __init dma_contiguous_early_fixup(phys_addr_t base, unsigned long 
size)
  {
+       BUG_ON(is_remapped);
         dma_mmu_remap[dma_mmu_remap_num].base = base;
         dma_mmu_remap[dma_mmu_remap_num].size = size;
         dma_mmu_remap_num++;
@@ -404,6 +406,7 @@ void __init dma_contiguous_remap(void)

                 iotable_init(&map, 1);
         }
+       is_remapped = 1;
  }

  static void *

I'm currently leaning towards setting up #2 unless I'm missing something
obvious here. Thanks.

Laura
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

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

* [RFC] Using CMA with devicetree generated devices
@ 2012-10-26 21:02 ` Laura Abbott
  0 siblings, 0 replies; 4+ messages in thread
From: Laura Abbott @ 2012-10-26 21:02 UTC (permalink / raw)
  To: linux-arm-kernel

Is it possible to use the devices generated from device tree for use 
with CMA? The API for reserving a CMA region (dma_declare_contiguous) 
requires a device pointer to properly associate a region with a device. 
By the time the devices from devicetree are actually available 
(generally during machine_init), dma_contiguous_remap has already been 
called so it's too late to have a properly setup region.

I currently see several options:

1) All CMA devices must be statically declared in the board file
2) Scan the FDT to set up 'dummy' devices early which can later be used 
to set up CMA with the 'proper' devices
3) My assumption is completely wrong and the check that I was using is 
invalid:

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 8404601..6d37516 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -368,9 +368,11 @@ struct dma_contig_early_reserve {
  static struct dma_contig_early_reserve dma_mmu_remap[MAX_CMA_AREAS] 
__initdata;

  static int dma_mmu_remap_num __initdata;
+static int is_remapped;

  void __init dma_contiguous_early_fixup(phys_addr_t base, unsigned long 
size)
  {
+       BUG_ON(is_remapped);
         dma_mmu_remap[dma_mmu_remap_num].base = base;
         dma_mmu_remap[dma_mmu_remap_num].size = size;
         dma_mmu_remap_num++;
@@ -404,6 +406,7 @@ void __init dma_contiguous_remap(void)

                 iotable_init(&map, 1);
         }
+       is_remapped = 1;
  }

  static void *

I'm currently leaning towards setting up #2 unless I'm missing something
obvious here. Thanks.

Laura
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

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

* Re: [RFC] Using CMA with devicetree generated devices
  2012-10-26 21:02 ` Laura Abbott
@ 2012-10-29 14:09   ` Marek Szyprowski
  -1 siblings, 0 replies; 4+ messages in thread
From: Marek Szyprowski @ 2012-10-29 14:09 UTC (permalink / raw)
  To: Laura Abbott
  Cc: linaro-mm-sig, linux-arm-kernel, linux-arm-msm, Russell King, vgandhi

Hello,

On 10/26/2012 11:02 PM, Laura Abbott wrote:
> Is it possible to use the devices generated from device tree for use
> with CMA? The API for reserving a CMA region (dma_declare_contiguous)
> requires a device pointer to properly associate a region with a device.
> By the time the devices from devicetree are actually available
> (generally during machine_init), dma_contiguous_remap has already been
> called so it's too late to have a properly setup region.
>
> I currently see several options:
>
> 1) All CMA devices must be statically declared in the board file
> 2) Scan the FDT to set up 'dummy' devices early which can later be used
> to set up CMA with the 'proper' devices
> 3) My assumption is completely wrong and the check that I was using is
> invalid:

dma_declare_contiguous() must be called very early, before any dynamic 
structures has been created and before core memory management subsystem 
has been set up. IMHO it should be possible to add support for DT 
directly in drivers/base/dma-contiguous.c. CMA code can iterate over DT 
nodes to initialize its internal structures and then use them once the 
DT devices are being probed/set-up.

> (...)

> I'm currently leaning towards setting up #2 unless I'm missing something
> obvious here. Thanks.

Best regards
-- 
Marek Szyprowski
Samsung Poland R&D Center

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

* [RFC] Using CMA with devicetree generated devices
@ 2012-10-29 14:09   ` Marek Szyprowski
  0 siblings, 0 replies; 4+ messages in thread
From: Marek Szyprowski @ 2012-10-29 14:09 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

On 10/26/2012 11:02 PM, Laura Abbott wrote:
> Is it possible to use the devices generated from device tree for use
> with CMA? The API for reserving a CMA region (dma_declare_contiguous)
> requires a device pointer to properly associate a region with a device.
> By the time the devices from devicetree are actually available
> (generally during machine_init), dma_contiguous_remap has already been
> called so it's too late to have a properly setup region.
>
> I currently see several options:
>
> 1) All CMA devices must be statically declared in the board file
> 2) Scan the FDT to set up 'dummy' devices early which can later be used
> to set up CMA with the 'proper' devices
> 3) My assumption is completely wrong and the check that I was using is
> invalid:

dma_declare_contiguous() must be called very early, before any dynamic 
structures has been created and before core memory management subsystem 
has been set up. IMHO it should be possible to add support for DT 
directly in drivers/base/dma-contiguous.c. CMA code can iterate over DT 
nodes to initialize its internal structures and then use them once the 
DT devices are being probed/set-up.

> (...)

> I'm currently leaning towards setting up #2 unless I'm missing something
> obvious here. Thanks.

Best regards
-- 
Marek Szyprowski
Samsung Poland R&D Center

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

end of thread, other threads:[~2012-10-29 14:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-26 21:02 [RFC] Using CMA with devicetree generated devices Laura Abbott
2012-10-26 21:02 ` Laura Abbott
2012-10-29 14:09 ` Marek Szyprowski
2012-10-29 14:09   ` Marek Szyprowski

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.