AnsweredAssumed Answered

dma_alloc_coherent() Fails when increasing system memory larger than 4GB on T1040

Question asked by Alexander Lopez on May 8, 2020
Latest reply on May 19, 2020 by Yiping Wang
  • Using Kernel 5.1.9
  • dma_alloc_coherent() call works as expected when total system memory is 2GB / 3GB


The call is used within Kernel PCI Driver within the code snippet below:

  • int32_t alloc_ob_mem(fsl_crypto_dev_t*dev, struct crypto_dev_config*config)
    void *
    struct pci_bar_info*mem;
  • /* First get the total obmem required */
    ob_mem_len= calc_ob_mem_len(dev, config);
    mem = &(dev->
  • print_debug("alloc_ob_mementered...\n");
    print_debug("Total obmem returned: %d\n", ob_mem_len);
  • host_v_addr= dma_alloc_coherent(&dev->priv_dev->dev->dev, ob_mem_len,
    host_dma_addr), GFP_KERNEL);
    if (!
  • { print_error("Allocating obmem failed...\n"); return -ENOMEM; }


Log of failure:


Uboot PCI configuration:

#define CONFIG_SYS_PCIE2_MEM_VIRT 0x90000000
#define CONFIG_SYS_PCIE2_MEM_BUS 0xe0000000
#define CONFIG_SYS_PCIE2_MEM_PHYS 0xc10000000ull
#define CONFIG_SYS_PCIE2_MEM_SIZE 0x10000000 /* 256M */
#define CONFIG_SYS_PCIE2_IO_VIRT 0xf8010000
#define CONFIG_SYS_PCIE2_IO_BUS 0x00000000
#define CONFIG_SYS_PCIE2_IO_PHYS 0xff8010000ull
#define CONFIG_SYS_PCIE2_IO_SIZE 0x00010000 /* 64k */


Kernel DTS:

pci1: pcie@ffe250000 {
reg = <0xf 0xfe250000 0 0x10000>;
ranges = <0x02000000 0x0 0xe0000000 0xc 0x10000000 0x0 0x10000000
0x01000000 0x0 0x00000000 0xf 0xf8010000 0x0 0x00010000>;
pcie@0 {
ranges = <0x02000000 0 0xe0000000
0x02000000 0 0xe0000000
0 0x10000000

0x01000000 0 0x00000000
0x01000000 0 0x00000000
0 0x00010000>;

My main questions from this are:

-  Is there specific kernel configuration or any kernel drivers necessary to allow the dma_alloc_coherent() call

to successfully work past the 32 bit addressing ? 


If any more details are required please let me know so that I can provide them.


Thanks in advance!