Thread: Linux Kernel Using ioremap().

  1. #1
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065

    Linux Kernel Using ioremap().

    This would be the reason that my brain was totally fried last night.

    this would be an example of the code:
    Code:
    static void *mmio, *control;
    int32_t register_my_system(MY_SYSTEM_USER *user)
    {
    
            // request memory region is done at insmod time and _should_not_ be where the problem is.
    
            mmio = ioremap(0x080C0000, 0x100);
    
            control = mmio + 0x28;
    
    
            iowrite16(6, control);  // enables bits 2 and 3 (one of these is an IRQ enable)
            return 0;
    }
    EXPORT_SYMBOL(register_my_system);
    
    void unregister_my_system(MY_SYSTEM_USER *user)
    {
            iounmap(mmio);
            control = NULL;
            mmio = NULL;
    }
    Now, the issue is this: If I unregister_my_system then attempt to register_my_system I hang. Sometimes I get an error from the kernel:
    Quote Originally Posted by Linux Kernel
    Unable to handle kernel paging request at virtual address 464c457f
    pgd = c9f78000
    [464c457f] *pgd=00000000Function entered at [<c0096c14>] from [<c0096cbc>]
    r5:00000000 r4:00000002
    Function entered at [<c0096c64>] from [<c0096d84>]
    r8:c002e764 r7:00000005 r6:bebfbb74 r5:4001ce14 r4:00000000
    Function entered at [<c0096d60>] from [<c002df60>]
    Code: e597300c e1d320b0 e1a02a02 e1a02a22 (e18420b1)
    but this is the ONLY thing I can get from it. The actual virtual address is 0xCAA6C028 and is that address each time I reboot and register with the driver.

    So, my question is what could possibly be hanging the system? I have tried absolutely everything I can think of but still cannot figure this one out. Any help would be greatly appreciated.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > iowrite16(6, control); // enables bits 2 and 3 (one of these is an IRQ enable)
    Are you counting bits from 0 or 1 ?

    Because counting from 0, bits 2 and 3 are 0xC
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Yes, that is an issue that I had to overcome. A hardware guy wrote the info on that one, but did lay out the bits in a table so that I know that bits 2 and 3 are actually 2^1 and 2^2 respectively.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Are you sure that 0x080C0000 is the correct bus address? I'm not sure what hardware you are working on, but it seems like this address is well within the RAM address on a normal desktop machine.
    bit∙hub [bit-huhb] n. A source and destination for information.

  5. #5
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    ARM XScale.

  6. #6
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Not sure if you stripped out some code for readability, but are you checking to make sure that ioremap() isn't returning NULL? If it's returning NULL, and you don't check it, then that means you are calling iowrite16 at a virtual address of 0x28 which would probably cause problems.
    bit∙hub [bit-huhb] n. A source and destination for information.

  7. #7
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Not only do I check for NULL, but I also have 30 different registers that I set. I have gone so far as to printk() each one to make sure that it is set. Also, I have some insane paranoia type if statements that test to be sure that each location is not NULL.

    What can I same, I'm a safety boy.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. priorities in Linux kernel??
    By micke_b in forum Linux Programming
    Replies: 0
    Last Post: 02-22-2008, 08:10 AM
  2. OpenGL on Linux - Kernel Panic
    By psychopath in forum Game Programming
    Replies: 2
    Last Post: 04-15-2006, 04:07 PM
  3. Compiling Linux kernel on Windows
    By jmd15 in forum Linux Programming
    Replies: 9
    Last Post: 04-10-2006, 07:28 AM
  4. Linux kernel not compiling
    By frenchfry164 in forum Tech Board
    Replies: 2
    Last Post: 04-29-2003, 04:10 PM
  5. linux kernel 2.5
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 07-31-2002, 11:17 PM