Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1343115 > unrolled thread
| Started by | Robert Richter <rrichter@caviumnetworks.com> |
|---|---|
| First post | 2016-02-25 12:20 +0100 |
| Last post | 2016-03-01 13:50 +0100 |
| Articles | 7 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH 0/2] arm64, cma, gicv3-its: Use CMA for allocation of large device tables Robert Richter <rrichter@caviumnetworks.com> - 2016-02-25 12:20 +0100
[PATCH 1/2] mm: cma: arm64: Introduce dma_activate_contiguous() for early activation Robert Richter <rrichter@caviumnetworks.com> - 2016-02-25 12:20 +0100
Re: [PATCH 0/2] arm64, cma, gicv3-its: Use CMA for allocation of large device tables Marc Zyngier <marc.zyngier@arm.com> - 2016-02-29 11:50 +0100
Re: [PATCH 0/2] arm64, cma, gicv3-its: Use CMA for allocation of large device tables Robert Richter <robert.richter@caviumnetworks.com> - 2016-02-29 13:30 +0100
Re: [PATCH 0/2] arm64, cma, gicv3-its: Use CMA for allocation of large device tables Marc Zyngier <marc.zyngier@arm.com> - 2016-02-29 14:40 +0100
Re: [PATCH 0/2] arm64, cma, gicv3-its: Use CMA for allocation of large device tables Laura Abbott <labbott@redhat.com> - 2016-03-01 00:20 +0100
Re: [PATCH 0/2] arm64, cma, gicv3-its: Use CMA for allocation of large device tables Robert Richter <robert.richter@caviumnetworks.com> - 2016-03-01 13:50 +0100
| From | Robert Richter <rrichter@caviumnetworks.com> |
|---|---|
| Date | 2016-02-25 12:20 +0100 |
| Subject | [PATCH 0/2] arm64, cma, gicv3-its: Use CMA for allocation of large device tables |
| Message-ID | <r627D-2Zd-3@gated-at.bofh.it> |
From: Robert Richter <rrichter@cavium.com>
This series implements the use of CMA for allocation of large device
tables for the arm64 gicv3 interrupt controller.
There are 2 patches, the first is for early activation of cma, which
needs to be done before interrupt initialization to make it available
to the gicv3. The second implements the use of CMA to allocate
gicv3-its device tables.
This solves the problem where mem allocation is limited to 4MB. A
previous patch sent to the list to address this that instead increases
FORCE_MAX_ZONEORDER becomes obsolete.
Robert Richter (2):
mm: cma: arm64: Introduce dma_activate_contiguous() for early
activation
irqchip, gicv3-its, cma: Use CMA for allocation of large device tables
arch/arm64/kernel/irq.c | 4 ++++
drivers/base/dma-contiguous.c | 14 ++++++++++++++
drivers/irqchip/irq-gic-v3-its.c | 30 +++++++++++++++++++++---------
include/linux/cma.h | 1 +
include/linux/dma-contiguous.h | 8 ++++++++
mm/cma.c | 6 +++++-
6 files changed, 53 insertions(+), 10 deletions(-)
--
2.7.0.rc3
[toc] | [next] | [standalone]
| From | Robert Richter <rrichter@caviumnetworks.com> |
|---|---|
| Date | 2016-02-25 12:20 +0100 |
| Subject | [PATCH 1/2] mm: cma: arm64: Introduce dma_activate_contiguous() for early activation |
| Message-ID | <r627E-2Zd-11@gated-at.bofh.it> |
| In reply to | #1343115 |
From: Robert Richter <rrichter@cavium.com>
For the arm64 gicv3 interrupt controller we need CMA to allocate large
blocks of physically contiguous memory. Usually page_alloc() is
limited by 2^(MAX_ORDER - 1), which is typically 4MB at 4k pagesize.
A current gicv3-its device table may have a size of up to 16MB.
Since the interrupt controller is initialized before other subsystems
(initcall functions), current dma activation (core_initcall) is too
late and makes it unusable for gicv3. On the other side, it is
generally possible to activate dma alloc right after the kernel's
memory initialization.
Now, this patch implements dma_activate_contiguous() to allow
architectures to enable dma alloc earlier. It also enables early dma
activation for the arm64 subsystem directly before interrupt
initialization and thus makes CMA usable for gicv3's memory
allocation.
Signed-off-by: Robert Richter <rrichter@cavium.com>
---
arch/arm64/kernel/irq.c | 4 ++++
drivers/base/dma-contiguous.c | 14 ++++++++++++++
include/linux/cma.h | 1 +
include/linux/dma-contiguous.h | 8 ++++++++
mm/cma.c | 6 +++++-
5 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c
index 9f17ec071ee0..913b32021f50 100644
--- a/arch/arm64/kernel/irq.c
+++ b/arch/arm64/kernel/irq.c
@@ -27,6 +27,7 @@
#include <linux/init.h>
#include <linux/irqchip.h>
#include <linux/seq_file.h>
+#include <linux/dma-contiguous.h>
unsigned long irq_err_count;
@@ -49,6 +50,9 @@ void __init set_handle_irq(void (*handle_irq)(struct pt_regs *))
void __init init_IRQ(void)
{
+ /* early activate cma since some gic controllers need it */
+ dma_activate_contiguous();
+
irqchip_init();
if (!handle_arch_irq)
panic("No interrupt controller found.");
diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index e167a1e1bccb..1c73d4899e8d 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -212,6 +212,20 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
return cma_release(dev_get_cma_area(dev), pages, count);
}
+/**
+ * dma_activate_contiguous() - activate reserved areas for contiguous
+ * memory handling
+ *
+ * This function enables contiguous memory allocation. It can be used
+ * by archs for early initialization right after the kernel memory
+ * subsystem (like slab allocator) is available and if the
+ * core_initcall for it is too late.
+ */
+int __init dma_activate_contiguous(void)
+{
+ return cma_init_reserved_areas();
+}
+
/*
* Support for reserved memory regions defined in device tree
*/
diff --git a/include/linux/cma.h b/include/linux/cma.h
index 29f9e774ab76..c2ab619769e6 100644
--- a/include/linux/cma.h
+++ b/include/linux/cma.h
@@ -23,6 +23,7 @@ extern int __init cma_declare_contiguous(phys_addr_t base,
phys_addr_t size, phys_addr_t limit,
phys_addr_t alignment, unsigned int order_per_bit,
bool fixed, struct cma **res_cma);
+extern int __init cma_init_reserved_areas(void);
extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
unsigned int order_per_bit,
struct cma **res_cma);
diff --git a/include/linux/dma-contiguous.h b/include/linux/dma-contiguous.h
index fec734df1524..07d542b8bb4d 100644
--- a/include/linux/dma-contiguous.h
+++ b/include/linux/dma-contiguous.h
@@ -111,6 +111,8 @@ static inline int dma_declare_contiguous(struct device *dev, phys_addr_t size,
return ret;
}
+int __init dma_activate_contiguous(void);
+
struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
unsigned int order);
bool dma_release_from_contiguous(struct device *dev, struct page *pages,
@@ -157,6 +159,12 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
return false;
}
+static inline
+int dma_activate_contiguous(void)
+{
+ return -ENOSYS;
+}
+
#endif
#endif
diff --git a/mm/cma.c b/mm/cma.c
index ea506eb18cd6..be1f55782c25 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -142,10 +142,14 @@ static int __init cma_activate_area(struct cma *cma)
return -EINVAL;
}
-static int __init cma_init_reserved_areas(void)
+int __init cma_init_reserved_areas(void)
{
int i;
+ if (cma_area_count && cma_areas[0].bitmap)
+ /* Already activated */
+ return 0;
+
for (i = 0; i < cma_area_count; i++) {
int ret = cma_activate_area(&cma_areas[i]);
--
2.7.0.rc3
[toc] | [prev] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2016-02-29 11:50 +0100 |
| Subject | Re: [PATCH 0/2] arm64, cma, gicv3-its: Use CMA for allocation of large device tables |
| Message-ID | <r7tyN-1SB-17@gated-at.bofh.it> |
| In reply to | #1343115 |
Hi Robert, On 25/02/16 11:02, Robert Richter wrote: > From: Robert Richter <rrichter@cavium.com> > > This series implements the use of CMA for allocation of large device > tables for the arm64 gicv3 interrupt controller. > > There are 2 patches, the first is for early activation of cma, which > needs to be done before interrupt initialization to make it available > to the gicv3. The second implements the use of CMA to allocate > gicv3-its device tables. > > This solves the problem where mem allocation is limited to 4MB. A > previous patch sent to the list to address this that instead increases > FORCE_MAX_ZONEORDER becomes obsolete. I think you're looking at the problem the wrong way. Instead of going through CMA directly, I'd rather go through the normal DMA API (dma_alloc_coherent), which can itself try CMA (should it be enabled). That will give you all the benefit of the CMA allocation, and also make the driver more robust. I meant to do this for a while, and never found the time. Any chance you could have a look? Thanks, M. -- Jazz is not dead. It just smells funny...
[toc] | [prev] | [next] | [standalone]
| From | Robert Richter <robert.richter@caviumnetworks.com> |
|---|---|
| Date | 2016-02-29 13:30 +0100 |
| Subject | Re: [PATCH 0/2] arm64, cma, gicv3-its: Use CMA for allocation of large device tables |
| Message-ID | <r7v7B-2Wa-31@gated-at.bofh.it> |
| In reply to | #1345638 |
On 29.02.16 10:46:49, Marc Zyngier wrote:
> On 25/02/16 11:02, Robert Richter wrote:
> > From: Robert Richter <rrichter@cavium.com>
> >
> > This series implements the use of CMA for allocation of large device
> > tables for the arm64 gicv3 interrupt controller.
> >
> > There are 2 patches, the first is for early activation of cma, which
> > needs to be done before interrupt initialization to make it available
> > to the gicv3. The second implements the use of CMA to allocate
> > gicv3-its device tables.
> >
> > This solves the problem where mem allocation is limited to 4MB. A
> > previous patch sent to the list to address this that instead increases
> > FORCE_MAX_ZONEORDER becomes obsolete.
>
> I think you're looking at the problem the wrong way. Instead of going
> through CMA directly, I'd rather go through the normal DMA API
> (dma_alloc_coherent), which can itself try CMA (should it be enabled).
>
> That will give you all the benefit of the CMA allocation, and also make
> the driver more robust. I meant to do this for a while, and never found
> the time. Any chance you could have a look?
I was considering this first, and in fact the backend used is the
same. The problem is that irq initialization is much more earlier than
standard device probing. The gic even does not have its own struct
device and is not initialized like devices are. This makes the whole
dma_alloc_coherent() approach not feasable, at least this would
require introducing and using a dev struct for the gic. But still this
migth not work as it could be too early during boot. I also think
there were reasons not implementing the gic as a device.
I was following more the approach of iommu/mmu implementations which
use dma_alloc_from_contiguous() directly. I think this is more close
to the device tables for its.
Code path of dma_alloc_coherent():
dma_alloc_coherent()
v
dma_alloc_attrs() <---- Requires get_dma_ops(dev) != NULL
v
dma_alloc_from_coherent()
v
...
The difference it that dma_alloc_coherent() tries cma first and then
proceeds with ops->alloc() (which is __dma_alloc() for arm64) if
dma_alloc_from_coherent() fails. In my implementation I am directly
using dma_alloc_from_coherent() and only for large mem sizes.
So both approaches uses finally the same allocation, but for gicv3-its
the generic dma framework is not used since the gic is not implemented
as a device.
Does this makes sense to you?
Thanks,
-Robert
[toc] | [prev] | [next] | [standalone]
| From | Marc Zyngier <marc.zyngier@arm.com> |
|---|---|
| Date | 2016-02-29 14:40 +0100 |
| Subject | Re: [PATCH 0/2] arm64, cma, gicv3-its: Use CMA for allocation of large device tables |
| Message-ID | <r7wdk-3Cq-11@gated-at.bofh.it> |
| In reply to | #1345749 |
On 29/02/16 12:25, Robert Richter wrote: > On 29.02.16 10:46:49, Marc Zyngier wrote: >> On 25/02/16 11:02, Robert Richter wrote: >>> From: Robert Richter <rrichter@cavium.com> >>> >>> This series implements the use of CMA for allocation of large device >>> tables for the arm64 gicv3 interrupt controller. >>> >>> There are 2 patches, the first is for early activation of cma, which >>> needs to be done before interrupt initialization to make it available >>> to the gicv3. The second implements the use of CMA to allocate >>> gicv3-its device tables. >>> >>> This solves the problem where mem allocation is limited to 4MB. A >>> previous patch sent to the list to address this that instead increases >>> FORCE_MAX_ZONEORDER becomes obsolete. >> >> I think you're looking at the problem the wrong way. Instead of going >> through CMA directly, I'd rather go through the normal DMA API >> (dma_alloc_coherent), which can itself try CMA (should it be enabled). >> >> That will give you all the benefit of the CMA allocation, and also make >> the driver more robust. I meant to do this for a while, and never found >> the time. Any chance you could have a look? > > I was considering this first, and in fact the backend used is the > same. The problem is that irq initialization is much more earlier than > standard device probing. The gic even does not have its own struct > device and is not initialized like devices are. This makes the whole > dma_alloc_coherent() approach not feasable, at least this would > require introducing and using a dev struct for the gic. But still this > migth not work as it could be too early during boot. I also think > there were reasons not implementing the gic as a device. > > I was following more the approach of iommu/mmu implementations which > use dma_alloc_from_contiguous() directly. I think this is more close > to the device tables for its. > > Code path of dma_alloc_coherent(): > > dma_alloc_coherent() > v > dma_alloc_attrs() <---- Requires get_dma_ops(dev) != NULL > v > dma_alloc_from_coherent() > v > ... > > The difference it that dma_alloc_coherent() tries cma first and then > proceeds with ops->alloc() (which is __dma_alloc() for arm64) if > dma_alloc_from_coherent() fails. In my implementation I am directly > using dma_alloc_from_coherent() and only for large mem sizes. > > So both approaches uses finally the same allocation, but for gicv3-its > the generic dma framework is not used since the gic is not implemented > as a device. And that's what I propose we change. The core GIC itself indeed isn't a device, and I'm not proposing we make it a device (yet). But the ITS is only used much later in the game, and we could move the table allocation to a different time (when the actual domains are allocated, for example...). Then, we'd have a set of devices available, and the DMA API is our friend again. M. -- Jazz is not dead. It just smells funny...
[toc] | [prev] | [next] | [standalone]
| From | Laura Abbott <labbott@redhat.com> |
|---|---|
| Date | 2016-03-01 00:20 +0100 |
| Subject | Re: [PATCH 0/2] arm64, cma, gicv3-its: Use CMA for allocation of large device tables |
| Message-ID | <r7FgC-14T-9@gated-at.bofh.it> |
| In reply to | #1345819 |
On 02/29/2016 05:30 AM, Marc Zyngier wrote:
> On 29/02/16 12:25, Robert Richter wrote:
>> On 29.02.16 10:46:49, Marc Zyngier wrote:
>>> On 25/02/16 11:02, Robert Richter wrote:
>>>> From: Robert Richter <rrichter@cavium.com>
>>>>
>>>> This series implements the use of CMA for allocation of large device
>>>> tables for the arm64 gicv3 interrupt controller.
>>>>
>>>> There are 2 patches, the first is for early activation of cma, which
>>>> needs to be done before interrupt initialization to make it available
>>>> to the gicv3. The second implements the use of CMA to allocate
>>>> gicv3-its device tables.
>>>>
>>>> This solves the problem where mem allocation is limited to 4MB. A
>>>> previous patch sent to the list to address this that instead increases
>>>> FORCE_MAX_ZONEORDER becomes obsolete.
>>>
>>> I think you're looking at the problem the wrong way. Instead of going
>>> through CMA directly, I'd rather go through the normal DMA API
>>> (dma_alloc_coherent), which can itself try CMA (should it be enabled).
>>>
>>> That will give you all the benefit of the CMA allocation, and also make
>>> the driver more robust. I meant to do this for a while, and never found
>>> the time. Any chance you could have a look?
>>
>> I was considering this first, and in fact the backend used is the
>> same. The problem is that irq initialization is much more earlier than
>> standard device probing. The gic even does not have its own struct
>> device and is not initialized like devices are. This makes the whole
>> dma_alloc_coherent() approach not feasable, at least this would
>> require introducing and using a dev struct for the gic. But still this
>> migth not work as it could be too early during boot. I also think
>> there were reasons not implementing the gic as a device.
>>
>> I was following more the approach of iommu/mmu implementations which
>> use dma_alloc_from_contiguous() directly. I think this is more close
>> to the device tables for its.
>>
>> Code path of dma_alloc_coherent():
>>
>> dma_alloc_coherent()
>> v
>> dma_alloc_attrs() <---- Requires get_dma_ops(dev) != NULL
>> v
>> dma_alloc_from_coherent()
>> v
>> ...
>>
>> The difference it that dma_alloc_coherent() tries cma first and then
>> proceeds with ops->alloc() (which is __dma_alloc() for arm64) if
>> dma_alloc_from_coherent() fails. In my implementation I am directly
>> using dma_alloc_from_coherent() and only for large mem sizes.
>>
>> So both approaches uses finally the same allocation, but for gicv3-its
>> the generic dma framework is not used since the gic is not implemented
>> as a device.
>
> And that's what I propose we change.
>
> The core GIC itself indeed isn't a device, and I'm not proposing we make
> it a device (yet). But the ITS is only used much later in the game, and
> we could move the table allocation to a different time (when the actual
> domains are allocated, for example...). Then, we'd have a set of devices
> available, and the DMA API is our friend again.
>
> M.
>
I did the first drop of CMA in the DMA APIs for arm64. When adding that,
it was decided to disallow dma_alloc calls without a valid device pointer
(c666e8d5cae7 "arm64: Warn on NULL device structure for dma APIs") so
if the GIC code wants to use dma_alloc it _must_ have a proper device.
If the device shift still isn't feasible, a better approach might be
what powerpc did for kvm (arch/powerpc/kvm/book3s_hv_builtin.c). This
calls the cma_alloc functions directly and skips trying to work around
the DMA layer.
With either option, I don't think the early initialization approach
proposed is great. If we want CMA early, it's probably be just to
explicitly initialize it early rather than trying to do it from
two places. Something like:
diff --git a/include/linux/cma.h b/include/linux/cma.h
index 29f9e77..a26712a 100644
--- a/include/linux/cma.h
+++ b/include/linux/cma.h
@@ -28,4 +28,5 @@ extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
struct cma **res_cma);
extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align);
extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count);
+extern int __init cma_init_reserved_areas(void);
#endif
diff --git a/init/main.c b/init/main.c
index 58c9e37..a92bdb8 100644
--- a/init/main.c
+++ b/init/main.c
@@ -81,6 +81,7 @@
#include <linux/integrity.h>
#include <linux/proc_ns.h>
#include <linux/io.h>
+#include <linux/cma.h>
#include <asm/io.h>
#include <asm/bugs.h>
@@ -492,6 +493,7 @@ static void __init mm_init(void)
pgtable_init();
vmalloc_init();
ioremap_huge_init();
+ cma_init_reserved_areas();
}
asmlinkage __visible void __init start_kernel(void)
diff --git a/mm/cma.c b/mm/cma.c
index ea506eb..42278d4 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -142,7 +142,7 @@ err:
return -EINVAL;
}
-static int __init cma_init_reserved_areas(void)
+int __init cma_init_reserved_areas(void)
{
int i;
@@ -155,7 +155,6 @@ static int __init cma_init_reserved_areas(void)
return 0;
}
-core_initcall(cma_init_reserved_areas);
/**
* cma_init_reserved_mem() - create custom contiguous area from reserved memory
Thanks,
Laura
[toc] | [prev] | [next] | [standalone]
| From | Robert Richter <robert.richter@caviumnetworks.com> |
|---|---|
| Date | 2016-03-01 13:50 +0100 |
| Subject | Re: [PATCH 0/2] arm64, cma, gicv3-its: Use CMA for allocation of large device tables |
| Message-ID | <r7RUu-LY-9@gated-at.bofh.it> |
| In reply to | #1346241 |
On 29.02.16 15:17:53, Laura Abbott wrote:
> On 02/29/2016 05:30 AM, Marc Zyngier wrote:
> >On 29/02/16 12:25, Robert Richter wrote:
> >>On 29.02.16 10:46:49, Marc Zyngier wrote:
> >>>On 25/02/16 11:02, Robert Richter wrote:
> >>>>From: Robert Richter <rrichter@cavium.com>
> >>>>
> >>>>This series implements the use of CMA for allocation of large device
> >>>>tables for the arm64 gicv3 interrupt controller.
> >>>>
> >>>>There are 2 patches, the first is for early activation of cma, which
> >>>>needs to be done before interrupt initialization to make it available
> >>>>to the gicv3. The second implements the use of CMA to allocate
> >>>>gicv3-its device tables.
> >>>>
> >>>>This solves the problem where mem allocation is limited to 4MB. A
> >>>>previous patch sent to the list to address this that instead increases
> >>>>FORCE_MAX_ZONEORDER becomes obsolete.
> >>>
> >>>I think you're looking at the problem the wrong way. Instead of going
> >>>through CMA directly, I'd rather go through the normal DMA API
> >>>(dma_alloc_coherent), which can itself try CMA (should it be enabled).
> >>>
> >>>That will give you all the benefit of the CMA allocation, and also make
> >>>the driver more robust. I meant to do this for a while, and never found
> >>>the time. Any chance you could have a look?
> >>
> >>I was considering this first, and in fact the backend used is the
> >>same. The problem is that irq initialization is much more earlier than
> >>standard device probing. The gic even does not have its own struct
> >>device and is not initialized like devices are. This makes the whole
> >>dma_alloc_coherent() approach not feasable, at least this would
> >>require introducing and using a dev struct for the gic. But still this
> >>migth not work as it could be too early during boot. I also think
> >>there were reasons not implementing the gic as a device.
> >>
> >>I was following more the approach of iommu/mmu implementations which
> >>use dma_alloc_from_contiguous() directly. I think this is more close
> >>to the device tables for its.
> >>
> >>Code path of dma_alloc_coherent():
> >>
> >> dma_alloc_coherent()
> >> v
> >> dma_alloc_attrs() <---- Requires get_dma_ops(dev) != NULL
> >> v
> >> dma_alloc_from_coherent()
> >> v
> >> ...
> >>
> >>The difference it that dma_alloc_coherent() tries cma first and then
> >>proceeds with ops->alloc() (which is __dma_alloc() for arm64) if
> >>dma_alloc_from_coherent() fails. In my implementation I am directly
> >>using dma_alloc_from_coherent() and only for large mem sizes.
> >>
> >>So both approaches uses finally the same allocation, but for gicv3-its
> >>the generic dma framework is not used since the gic is not implemented
> >>as a device.
> >
> >And that's what I propose we change.
> >
> >The core GIC itself indeed isn't a device, and I'm not proposing we make
> >it a device (yet). But the ITS is only used much later in the game, and
> >we could move the table allocation to a different time (when the actual
> >domains are allocated, for example...). Then, we'd have a set of devices
> >available, and the DMA API is our friend again.
> >
> > M.
> >
>
> I did the first drop of CMA in the DMA APIs for arm64. When adding that,
> it was decided to disallow dma_alloc calls without a valid device pointer
> (c666e8d5cae7 "arm64: Warn on NULL device structure for dma APIs") so
> if the GIC code wants to use dma_alloc it _must_ have a proper device.
>
> If the device shift still isn't feasible, a better approach might be
> what powerpc did for kvm (arch/powerpc/kvm/book3s_hv_builtin.c). This
> calls the cma_alloc functions directly and skips trying to work around
> the DMA layer.
>
> With either option, I don't think the early initialization approach
> proposed is great. If we want CMA early, it's probably be just to
> explicitly initialize it early rather than trying to do it from
> two places. Something like:
I wasn't sure whether this works for all archs if called directly in
mm_init(). If so, ok your proposed change would be better, though a
stub for !CONFIG_CMA needs to be added. Any comment on the change
below as a replacement for patch #1?
On the other side, if we use device enablement for its, then early cma
enablement is not needed anymore. Will check how that could work.
-Robert
>
> diff --git a/include/linux/cma.h b/include/linux/cma.h
> index 29f9e77..a26712a 100644
> --- a/include/linux/cma.h
> +++ b/include/linux/cma.h
> @@ -28,4 +28,5 @@ extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
> struct cma **res_cma);
> extern struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align);
> extern bool cma_release(struct cma *cma, const struct page *pages, unsigned int count);
> +extern int __init cma_init_reserved_areas(void);
> #endif
> diff --git a/init/main.c b/init/main.c
> index 58c9e37..a92bdb8 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -81,6 +81,7 @@
> #include <linux/integrity.h>
> #include <linux/proc_ns.h>
> #include <linux/io.h>
> +#include <linux/cma.h>
> #include <asm/io.h>
> #include <asm/bugs.h>
> @@ -492,6 +493,7 @@ static void __init mm_init(void)
> pgtable_init();
> vmalloc_init();
> ioremap_huge_init();
> + cma_init_reserved_areas();
> }
> asmlinkage __visible void __init start_kernel(void)
> diff --git a/mm/cma.c b/mm/cma.c
> index ea506eb..42278d4 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -142,7 +142,7 @@ err:
> return -EINVAL;
> }
> -static int __init cma_init_reserved_areas(void)
> +int __init cma_init_reserved_areas(void)
> {
> int i;
> @@ -155,7 +155,6 @@ static int __init cma_init_reserved_areas(void)
> return 0;
> }
> -core_initcall(cma_init_reserved_areas);
> /**
> * cma_init_reserved_mem() - create custom contiguous area from reserved memory
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web