Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.


  Search this Thread
Old 12-10-2008, 10:52 AM   #1
LQ Newbie
Registered: Oct 2008
Posts: 11

Rep: Reputation: 0
Kernel crashes while accessing the IO mapped memory


I am writing a framebuffer driver and the kernel seems to crash while accessing the IO re-mapped memory.

Here is what I did:
In my platform specific file, I added the platform_device


static struct resource lcdc_resources[] = {
	// Resource 0 is framebuffer
	[0] = {
		.start	= DK_LCDC_BASE + SZ_2M,
		.end	= DK_LCDC_BASE + SZ_4M - 1,
		.flags	= IORESOURCE_MEM,
	// Resource 1 is register space
	[1] = {
		.start	= DK_LCDC_BASE,
		.end	= DK_LCDC_BASE + SZ_2M - 1,
		.flags	= IORESOURCE_MEM,

static struct platform_device at91_lcdc_device = {
	.name		= "s1d13513fb",
	.id		= -1, // only one
	.dev		= {
				.platform_data		= NULL,
	.resource	= lcdc_resources,
	.num_resources	= ARRAY_SIZE(lcdc_resources),

And in the framebuffer driver, I added the platform_driver

static int __devinit
s1d13xxxfb_probe(struct platform_device *pdev)

	if (!request_mem_region(pdev->resource[0].start,
		pdev->resource[0].end - pdev->resource[0].start +1, "s1d13xxxfb mem")) {
		dev_dbg(&pdev->dev, "request_mem_region failed\n");
		ret = -EBUSY;
		goto bail;

	if (!request_mem_region(pdev->resource[1].start,
		pdev->resource[1].end - pdev->resource[1].start +1, "s1d13xxxfb regs")) {
		dev_dbg(&pdev->dev, "request_mem_region failed\n");
		ret = -EBUSY;
		goto bail;

	default_par = info->par;
	default_par->regs = ioremap_nocache(pdev->resource[1].start,
			pdev->resource[1].end - pdev->resource[1].start +1);
	if (!default_par->regs) {
		printk(KERN_ERR PFX "unable to map registers\n");
		ret = -ENOMEM;
		goto bail;
	info->pseudo_palette = default_par->pseudo_palette;

	info->screen_base = ioremap_nocache(pdev->resource[0].start,
			pdev->resource[0].end - pdev->resource[0].start +1);

	if (!info->screen_base) {
		printk(KERN_ERR PFX "unable to map framebuffer\n");
		ret = -ENOMEM;
		goto bail;

Now, all this succeeds as observed by the debug messages. However, when I access the IO memory using ioread16 or iowrite16 functions or even the old readw or writew functions, the kernel crashes.

Why is it happening even after the success of request_mem_region and ioremap calls?

I have tried the following:
1. Disable most of the other peripherals so that they don't interfere with this peripheral.
2. Comment out the initialization code that acceses this IO memory and try to access it from user space using cat > /dev/fb0.
But when I access it from a user space, the kernel crashes confirming that indeed the problem is in the access.

Please help me identifying where I am going wrong.


crash, framebuffer, kernel

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
fc8 desktop crashes when accessing large file 'properties' terry-duell Fedora 10 04-25-2008 08:13 PM
Memory mapped device access in Linux tsik Linux - Software 1 10-31-2006 10:26 PM
MTD - Accessing Video Memory. qwijibow Linux - Hardware 0 09-06-2006 08:45 AM
Accessing shared memory from kernel awang987 Linux - Kernel 5 04-29-2006 04:57 PM
Memory Mapped file IO problems legogt Programming 0 08-01-2003 02:52 PM > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 12:54 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration