doesn't ioremap() retrun contigious addressess...?
Hi All Please find a piece of code that i wrote in my driver, void __iomem *tcpm_base = ioremap_nocache(0x03900000, SZ_16KB); printk("Virtual addresss %x\n",tcpm_base); if(tcpm_base!=NULL) { printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies); for(i=0;i<(SZ_16KB-1);i++) src = readl(tcpm_base+i); printk("%d\n",src); printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies); } else printk("unable to map \n"); When i execute this code, i am seeing a kernel panic telling ----- LOG -------- "Virtual addresss ea880000" "Unable to handle kernel paging request at virtual address ea890000" -----LOG----- If you observe, virtual address of tcpm_base is ea880000. if ioremap() returns all contigious memory, There should be no dereferencing of "ea890000"(the max address should be ea88fffe) But in kernel logs show, it is dereferencing that address. My question now is... doesn't ioremap() returns contigious address space? With regards, Sandeep Kumar Anantapalli,
Sorry, Neglect the question. i am using a readl() which reads 4 bytes at a time. In the last iteration, it is trying to read next 4 unmapped locations. On Thu, Feb 28, 2013 at 4:06 PM, sandeep kumar <coolsandyforyou@gmail.com>wrote:
Hi All Please find a piece of code that i wrote in my driver,
void __iomem *tcpm_base = ioremap_nocache(0x03900000, SZ_16KB); printk("Virtual addresss %x\n",tcpm_base); if(tcpm_base!=NULL) { printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies); for(i=0;i<(SZ_16KB-1);i++) src = readl(tcpm_base+i); printk("%d\n",src); printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies); } else printk("unable to map \n");
When i execute this code, i am seeing a kernel panic telling ----- LOG -------- "Virtual addresss ea880000" "Unable to handle kernel paging request at virtual address ea890000" -----LOG-----
If you observe, virtual address of tcpm_base is ea880000. if ioremap() returns all contigious memory, There should be no dereferencing of "ea890000"(the max address should be ea88fffe)
But in kernel logs show, it is dereferencing that address.
My question now is... doesn't ioremap() returns contigious address space?
With regards, Sandeep Kumar Anantapalli,
-- With regards, Sandeep Kumar Anantapalli,
Le jeudi 28 février 2013 à 16:25 +0530, sandeep kumar a écrit :
Sorry, Neglect the question. i am using a readl() which reads 4 bytes at a time. In the last iteration, it is trying to read next 4 unmapped locations.
So you probably have to do this instead: for(i=0;i<(SZ_16KB-1)/4;i++) src = readl(tcpm_base+(i * 4)); Regards -- Yann Droneaud OPTEYA
Yep. On Thu, Feb 28, 2013 at 5:10 PM, Yann Droneaud <ydroneaud@opteya.com> wrote:
Le jeudi 28 février 2013 à 16:25 +0530, sandeep kumar a écrit :
Sorry, Neglect the question. i am using a readl() which reads 4 bytes at a time. In the last iteration, it is trying to read next 4 unmapped locations.
So you probably have to do this instead:
for(i=0;i<(SZ_16KB-1)/4;i++) src = readl(tcpm_base+(i * 4));
Regards
-- Yann Droneaud OPTEYA
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Thank you all, It worked :) On Thu, Feb 28, 2013 at 5:33 PM, Prabhu nath <gprabhunath@gmail.com> wrote:
Yep.
On Thu, Feb 28, 2013 at 5:10 PM, Yann Droneaud <ydroneaud@opteya.com>wrote:
Le jeudi 28 février 2013 à 16:25 +0530, sandeep kumar a écrit :
Sorry, Neglect the question. i am using a readl() which reads 4 bytes at a time. In the last iteration, it is trying to read next 4 unmapped locations.
So you probably have to do this instead:
for(i=0;i<(SZ_16KB-1)/4;i++) src = readl(tcpm_base+(i * 4));
Regards
-- Yann Droneaud OPTEYA
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-- With regards, Sandeep Kumar Anantapalli,
Yes, ioremap() maps the given physical address to contiguous Kernel virtual address above high_memory and returns the first address of the mapped kernel virtual address. Regards, Prabhu On Thu, Feb 28, 2013 at 4:06 PM, sandeep kumar <coolsandyforyou@gmail.com>wrote:
Hi All Please find a piece of code that i wrote in my driver,
void __iomem *tcpm_base = ioremap_nocache(0x03900000, SZ_16KB); printk("Virtual addresss %x\n",tcpm_base); if(tcpm_base!=NULL) { printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies); for(i=0;i<(SZ_16KB-1);i++) src = readl(tcpm_base+i); printk("%d\n",src); printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies); } else printk("unable to map \n");
When i execute this code, i am seeing a kernel panic telling ----- LOG -------- "Virtual addresss ea880000" "Unable to handle kernel paging request at virtual address ea890000" -----LOG-----
If you observe, virtual address of tcpm_base is ea880000. if ioremap() returns all contigious memory, There should be no dereferencing of "ea890000"(the max address should be ea88fffe)
But in kernel logs show, it is dereferencing that address.
My question now is... doesn't ioremap() returns contigious address space?
With regards, Sandeep Kumar Anantapalli,
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
I guess your reading is wrong. If you are mapping 16KB of physical address from 0x03900000. The mapping is as follows. 0x03900000 to 0x03903FFF --> 0xEA880000 to 0xEA883FFF For every iteration you are reading 4 bytes. hence you have to reduce your loop as follows and also declare tcpm_base as unsigned int * unsigned int __iomem *tcpm_base; *tcpm_base = ioremap_nocache(0x03900000, SZ_16KB); printk("Virtual addresss %x\n",tcpm_base); if(tcpm_base!=NULL) { printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies); for(i=0;i<*0xFFF*;i++) src = readl(tcpm_base+i); printk("%d\n",src); printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies); } else printk("unable to map \n"); Regards, Prabhu On Thu, Feb 28, 2013 at 4:41 PM, Prabhu nath <gprabhunath@gmail.com> wrote:
Yes, ioremap() maps the given physical address to contiguous Kernel virtual address above high_memory and returns the first address of the mapped kernel virtual address.
Regards, Prabhu
On Thu, Feb 28, 2013 at 4:06 PM, sandeep kumar <coolsandyforyou@gmail.com>wrote:
Hi All Please find a piece of code that i wrote in my driver,
void __iomem *tcpm_base = ioremap_nocache(0x03900000, SZ_16KB); printk("Virtual addresss %x\n",tcpm_base); if(tcpm_base!=NULL) { printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies); for(i=0;i<(SZ_16KB-1);i++) src = readl(tcpm_base+i); printk("%d\n",src); printk("Jiffies %x %ld\n\n\n\n", jiffies, jiffies); } else printk("unable to map \n");
When i execute this code, i am seeing a kernel panic telling ----- LOG -------- "Virtual addresss ea880000" "Unable to handle kernel paging request at virtual address ea890000" -----LOG-----
If you observe, virtual address of tcpm_base is ea880000. if ioremap() returns all contigious memory, There should be no dereferencing of "ea890000"(the max address should be ea88fffe)
But in kernel logs show, it is dereferencing that address.
My question now is... doesn't ioremap() returns contigious address space?
With regards, Sandeep Kumar Anantapalli,
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
participants (3)
-
Prabhu nath -
sandeep kumar -
Yann Droneaud