Find the answer to your Linux question:
Results 1 to 3 of 3
Hi I have a problem with allocating high memory in my kernel driver running at a 64 bit 4 GB ram (Linux RedHatEnteprise 5). I have reserved 40 Mb of ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2011
    Posts
    2

    Smile Allocating memory for DMA on 64 bit system


    Hi

    I have a problem with allocating high memory in my kernel driver running at a 64 bit 4 GB ram (Linux RedHatEnteprise 5). I have reserved 40 Mb of memory by using the mem= parameter (mem=4056), so there should be some memory available for DMA. The driver is working perfect at a 32 bit system but when running at a 64 bit system I have problem writing and reading information from the allocated memory. (I have to set the mem to 2048 for getting the driver to work on a 64 bit system)

    Here is some code to better explain what my driver do.

    // (1 Mb) Memory to allocate each cycle
    const unsigned long alloc_size = 0x100000;

    // Calculate the start position for the high memory
    const unsigned long phy_highmem = num_physpages << PAGE_SHIFT;

    void* remapped = ioremap(phy_highmem, alloc_size);

    // Verify that the memory area is accessible to us
    if(!testMemory(remapped, page_size))
    {
    printk(KERN_ERR The memory test failed, this indicates that we are accessing memory areas that are forbidden, please check that there is enough high memory left.\n");
    goto fail_init;
    }
    iounmap((void*)remapped); ...
    ...

    bool testMemory(void* memory, unsigned long size) {
    unsigned index;
    char c;

    // Insert a value in the memory to verify that it is accessible
    for(index = 0; index < size; index++)
    {
    c = index&0xff;
    iowrite8(c, memory + index);
    if(c != (char)ioread8(memory + index))
    {
    printk(KERN_ERR ERROR: Did not manage to insert the value [%d] at index [%d]\n", (int)c, index);
    return false;
    }
    }
    return true;
    }

    I hope someone can explain to me what I clearly donít understand! :o)

    Best redards,
    Per

  2. #2
    Banned
    Join Date
    Nov 2011
    Posts
    13
    Please look out for an e820 map. First run your system, without mem= flag and note the regions, this will give you overall memory regions (see regions with usable flags). On command line you run dmesg command, and look for e820 messages there.
    Last edited by oz; 11-26-2011 at 01:38 PM. Reason: spam removal

  3. #3
    Just Joined!
    Join Date
    Oct 2011
    Posts
    2
    Thank you for your response, I had almost given up on this one! I will check out the BIOS memory regions. Thanks again :o)

    Best regards,
    Per

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •