This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

gpmc_cs_request exception

Guru 20755 points

Hello,

I am using kernel module for testing and get exception, when using gpmc_cs_request() call.

Does anyone have any idea ?


~ # insmod sram_test.ko
[ 22.299072] sramtest_init
[ 22.301879] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[ 22.310424] pgd = cd3f4000


static void __iomem *vaddr;

#define SRAM_CS 2
#define SRAM_ADDR 0x18000000
void __iomem *sram_map_addr;


static struct cdev sramtest_cdev;

static struct file_operations sramtest_fops =
{
.owner = THIS_MODULE,
.unlocked_ioctl = sramtest_ioctl,

};

static int __init sramtest_init(void)

{

   dev_t dev;
   int ret = 0;
   int i = 0;
   int val = 0;
   unsigned long startaddr = 0;


   dev = MKDEV(SRAMTEST_MAJOR, SRAMTEST_MINOR);

   ret = register_chrdev_region(dev, 1, "sramtest");
   if(ret)
   {
    printk("cdev fail on register\n");
   return ret;
   }

   cdev_init(&sramtest_cdev, &sramtest_fops);
   sramtest_cdev.owner = THIS_MODULE;
   sramtest_cdev.ops = &sramtest_fops;

   ret = cdev_add(&sramtest_cdev, dev, 1);
   if(ret)
   {
     unregister_chrdev_region(dev, 1);
     return ret;
   }
  ret = gpmc_cs_request(SRAM_CS, SZ_1M - 1, (unsigned long *) &startaddr);

  vaddr = ioremap_nocache(SRAM_ADDR, SZ_1M);

  if (vaddr == NULL)
  {
    printk ("Failed to map address\n");
   return -1;  }

}

return 0;

}

static void __exit sramtest_exit(void)
{
   iounmap(vaddr);
  cdev_del(&sramtest_cdev);
  unregister_chrdev_region(MKDEV(SRAMTEST_MAJOR, SRAMTEST_MINOR), 1);

}

module_init(sramtest_init);
module_exit(sramtest_exit);

Thanks,

Ran

  • Hi Ran,

    Are you initialized the memory for the same CS no. (requested) in u-boot before ?

    How did you confirm that "gpmc_cs_request" would causing the panic ?

    Put some prints before and after the "gpmc_cs_request" API function and confirm, I hope that you done this before.

    [ 22.299072] sramtest_init
    [ 22.301879] Unable to handle kernel NULL pointer dereference at virtual address 00000000
    [ 22.310424] pgd = cd3f4000

    I don't see the "sramtest_init" print on your kernel module driver.

    Please find out the exact code which causing the error.

       unsigned long startaddr = 0;

      ret = gpmc_cs_request(SRAM_CS, SZ_1M - 1, (unsigned long *) &startaddr);

    You can't query the start address is to 'zero' for GPMC, please refer the TRM of your device,

    You have to use start address as after 1MB of GPMC address space.

    Please refer the "Cortex-A8 memory map, chapter 2.1 and note -1, page no 175"

    The first 1MB of address space 0x0-0xFFFFF is inaccessible externally.