* [PATCH] riscv: Enable CMA support
@ 2020-10-31 6:01 Kefeng Wang
2020-11-12 8:55 ` Kefeng Wang
0 siblings, 1 reply; 4+ messages in thread
From: Kefeng Wang @ 2020-10-31 6:01 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-riscv; +Cc: Kefeng Wang
riscv has selected HAVE_DMA_CONTIGUOUS, but don't call
dma_contiguous_reserve(). let's enable CMA as expect.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
arch/riscv/mm/init.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index ea933b789a88..87ae4b99442a 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -13,6 +13,7 @@
#include <linux/of_fdt.h>
#include <linux/libfdt.h>
#include <linux/set_memory.h>
+#include <linux/dma-map-ops.h>
#include <asm/fixmap.h>
#include <asm/tlbflush.h>
@@ -41,13 +42,14 @@ struct pt_alloc_ops {
#endif
};
+static phys_addr_t dma32_phys_limit __ro_after_init;
+
static void __init zone_sizes_init(void)
{
unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
#ifdef CONFIG_ZONE_DMA32
- max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G,
- (unsigned long) PFN_PHYS(max_low_pfn)));
+ max_zone_pfns[ZONE_DMA32] = PFN_DOWN(dma32_phys_limit);
#endif
max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
@@ -185,6 +187,7 @@ void __init setup_bootmem(void)
max_pfn = PFN_DOWN(memblock_end_of_DRAM());
max_low_pfn = max_pfn;
+ dma32_phys_limit = min(4UL * SZ_1G, (unsigned long)PFN_PHYS(max_low_pfn));
set_max_mapnr(max_low_pfn);
#ifdef CONFIG_BLK_DEV_INITRD
@@ -198,6 +201,7 @@ void __init setup_bootmem(void)
memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va));
early_init_fdt_scan_reserved_mem();
+ dma_contiguous_reserve(dma32_phys_limit);
memblock_allow_resize();
memblock_dump_all();
}
--
2.26.2
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: Enable CMA support
2020-10-31 6:01 [PATCH] riscv: Enable CMA support Kefeng Wang
@ 2020-11-12 8:55 ` Kefeng Wang
2020-11-21 2:03 ` Palmer Dabbelt
0 siblings, 1 reply; 4+ messages in thread
From: Kefeng Wang @ 2020-11-12 8:55 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, linux-riscv
Any comments, kindly ping...
On 2020/10/31 14:01, Kefeng Wang wrote:
> riscv has selected HAVE_DMA_CONTIGUOUS, but don't call
> dma_contiguous_reserve(). let's enable CMA as expect.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> arch/riscv/mm/init.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index ea933b789a88..87ae4b99442a 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -13,6 +13,7 @@
> #include <linux/of_fdt.h>
> #include <linux/libfdt.h>
> #include <linux/set_memory.h>
> +#include <linux/dma-map-ops.h>
>
> #include <asm/fixmap.h>
> #include <asm/tlbflush.h>
> @@ -41,13 +42,14 @@ struct pt_alloc_ops {
> #endif
> };
>
> +static phys_addr_t dma32_phys_limit __ro_after_init;
> +
> static void __init zone_sizes_init(void)
> {
> unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
>
> #ifdef CONFIG_ZONE_DMA32
> - max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G,
> - (unsigned long) PFN_PHYS(max_low_pfn)));
> + max_zone_pfns[ZONE_DMA32] = PFN_DOWN(dma32_phys_limit);
> #endif
> max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
>
> @@ -185,6 +187,7 @@ void __init setup_bootmem(void)
>
> max_pfn = PFN_DOWN(memblock_end_of_DRAM());
> max_low_pfn = max_pfn;
> + dma32_phys_limit = min(4UL * SZ_1G, (unsigned long)PFN_PHYS(max_low_pfn));
> set_max_mapnr(max_low_pfn);
>
> #ifdef CONFIG_BLK_DEV_INITRD
> @@ -198,6 +201,7 @@ void __init setup_bootmem(void)
> memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va));
>
> early_init_fdt_scan_reserved_mem();
> + dma_contiguous_reserve(dma32_phys_limit);
> memblock_allow_resize();
> memblock_dump_all();
> }
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: Enable CMA support
2020-11-12 8:55 ` Kefeng Wang
@ 2020-11-21 2:03 ` Palmer Dabbelt
2020-11-21 5:35 ` Kefeng Wang
0 siblings, 1 reply; 4+ messages in thread
From: Palmer Dabbelt @ 2020-11-21 2:03 UTC (permalink / raw)
To: wangkefeng.wang; +Cc: linux-riscv, aou, Paul Walmsley
On Thu, 12 Nov 2020 00:55:30 PST (-0800), wangkefeng.wang@huawei.com wrote:
> Any comments, kindly ping...
Sorry, I must have missed this one. It's on for-next. Thanks!
>
> On 2020/10/31 14:01, Kefeng Wang wrote:
>> riscv has selected HAVE_DMA_CONTIGUOUS, but don't call
>> dma_contiguous_reserve(). let's enable CMA as expect.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>> arch/riscv/mm/init.c | 8 ++++++--
>> 1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
>> index ea933b789a88..87ae4b99442a 100644
>> --- a/arch/riscv/mm/init.c
>> +++ b/arch/riscv/mm/init.c
>> @@ -13,6 +13,7 @@
>> #include <linux/of_fdt.h>
>> #include <linux/libfdt.h>
>> #include <linux/set_memory.h>
>> +#include <linux/dma-map-ops.h>
>>
>> #include <asm/fixmap.h>
>> #include <asm/tlbflush.h>
>> @@ -41,13 +42,14 @@ struct pt_alloc_ops {
>> #endif
>> };
>>
>> +static phys_addr_t dma32_phys_limit __ro_after_init;
>> +
>> static void __init zone_sizes_init(void)
>> {
>> unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
>>
>> #ifdef CONFIG_ZONE_DMA32
>> - max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G,
>> - (unsigned long) PFN_PHYS(max_low_pfn)));
>> + max_zone_pfns[ZONE_DMA32] = PFN_DOWN(dma32_phys_limit);
>> #endif
>> max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
>>
>> @@ -185,6 +187,7 @@ void __init setup_bootmem(void)
>>
>> max_pfn = PFN_DOWN(memblock_end_of_DRAM());
>> max_low_pfn = max_pfn;
>> + dma32_phys_limit = min(4UL * SZ_1G, (unsigned long)PFN_PHYS(max_low_pfn));
>> set_max_mapnr(max_low_pfn);
>>
>> #ifdef CONFIG_BLK_DEV_INITRD
>> @@ -198,6 +201,7 @@ void __init setup_bootmem(void)
>> memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va));
>>
>> early_init_fdt_scan_reserved_mem();
>> + dma_contiguous_reserve(dma32_phys_limit);
>> memblock_allow_resize();
>> memblock_dump_all();
>> }
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] riscv: Enable CMA support
2020-11-21 2:03 ` Palmer Dabbelt
@ 2020-11-21 5:35 ` Kefeng Wang
0 siblings, 0 replies; 4+ messages in thread
From: Kefeng Wang @ 2020-11-21 5:35 UTC (permalink / raw)
To: Palmer Dabbelt; +Cc: linux-riscv, aou, Paul Walmsley
On 2020/11/21 10:03, Palmer Dabbelt wrote:
> On Thu, 12 Nov 2020 00:55:30 PST (-0800), wangkefeng.wang@huawei.com
> wrote:
>> Any comments, kindly ping...
>
> Sorry, I must have missed this one. It's on for-next. Thanks!
and could you take a look at the two patches, thanks ;)
https://patchwork.kernel.org/project/linux-riscv/patch/20201111115216.31447-1-wangkefeng.wang@huawei.com/
https://patchwork.kernel.org/project/linux-riscv/patch/20201116081238.44223-1-wangkefeng.wang@huawei.com/
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-21 5:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-31 6:01 [PATCH] riscv: Enable CMA support Kefeng Wang
2020-11-12 8:55 ` Kefeng Wang
2020-11-21 2:03 ` Palmer Dabbelt
2020-11-21 5:35 ` Kefeng Wang
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.