Skip to contentSkip to conversation

omapfb: Reorder Register_framebuffer call

PATCH In review Sergio Aguirre 6 participants 12 messages Sep 12, 2009 – Sep 25, 2009 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 omapfb: Reorder Register_framebuffer call

This fixes the issue in which mm_lock mutex was attempted to be used without initializing previously.

Thanks to the testers!
- OMAP3430 SDP (Anand Gadiyar)
- OMAP3530 EVM (Vaibhav Hiremath)
- LogicPD's OMAP boards (Peter Brada)
- Beagleboard Rev. C2 (Eric Witcher)

---
 drivers/video/omap/omapfb_main.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)
drivers/video/omap/omapfb_main.c +11 -9
index 125e605..60f9482 100644
@@ -1503,12 +1503,21 @@ static int fbinfo_init(struct omapfb_device *fbdev, struct fb_info *info)
 	var->rotate	  = def_rotate;
 	var->bits_per_pixel = fbdev->panel->bpp;
 
+	r = register_framebuffer(info);
+	if (r != 0) {
+		dev_err(fbdev->dev,
+			"registering framebuffer failed\n");
+		return r;
+	}
+
 	set_fb_var(info, var);
 	set_fb_fix(info);
 
 	r = fb_alloc_cmap(&info->cmap, 16, 0);
-	if (r != 0)
+	if (r != 0) {
 		dev_err(fbdev->dev, "unable to allocate color map memory\n");
+		unregister_framebuffer(info);
+	}
 
 	return r;
 }
@@ -1773,15 +1782,8 @@ static int omapfb_do_probe(struct platform_device *pdev,
 	init_state++;
 
 	vram = 0;
-	for (i = 0; i < fbdev->mem_desc.region_cnt; i++) {
-		r = register_framebuffer(fbdev->fb_info[i]);
-		if (r != 0) {
-			dev_err(fbdev->dev,
-				"registering framebuffer %d failed\n", i);
-			goto cleanup;
-		}
+	for (i = 0; i < fbdev->mem_desc.region_cnt; i++)
 		vram += fbdev->mem_desc.region[i].size;
-	}
 
 	fbdev->state = OMAPFB_ACTIVE;
 
Signature · 1 line
1.6.3.2
#1 lore raw

Hi,

This patch has been lying around for some weeks now, with just responses about successful testing (detailed in the description).

Is there anything holding it for merge? Or should I try sending it to other ML?

BTW, It applies cleanly on mainline aswell.

Regards,
Sergio

Quoted 77 lines

-----Original Message-----
From: Sergio Aguirre [mailto:[email protected]] On Behalf Of Sergio Aguirre
Sent: Saturday, September 12, 2009 11:34 AM
To: Imre Deak
Cc: [email protected]; [email protected]; Aguirre Rodriguez, Sergio Alberto
Subject: [PATCH] omapfb: Reorder Register_framebuffer call

This fixes the issue in which mm_lock mutex was attempted to be used without initializing previously.

Thanks to the testers!
- OMAP3430 SDP (Anand Gadiyar)
- OMAP3530 EVM (Vaibhav Hiremath)
- LogicPD's OMAP boards (Peter Brada)
- Beagleboard Rev. C2 (Eric Witcher)

---
 drivers/video/omap/omapfb_main.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)
drivers/video/omap/omapfb_main.c +10 -1
index 125e605..60f9482 100644
@@ -1503,12 +1503,21 @@ static int fbinfo_init(struct omapfb_device
 *fbdev, struct fb_info *info)
 	var->rotate	  = def_rotate;
 	var->bits_per_pixel = fbdev->panel->bpp;
 
+	r = register_framebuffer(info);
+	if (r != 0) {
+		dev_err(fbdev->dev,
+			"registering framebuffer failed\n");
+		return r;
+	}
+
 	set_fb_var(info, var);
 	set_fb_fix(info);
 
 	r = fb_alloc_cmap(&info->cmap, 16, 0);
-	if (r != 0)
+	if (r != 0) {
 		dev_err(fbdev->dev, "unable to allocate color map memory\n");
+		unregister_framebuffer(info);
+	}
 
 	return r;

}

drivers/video/omap/omapfb_main.c +1 -9
@@ -1773,15 +1782,8 @@ static int omapfb_do_probe(struct platform_device
 *pdev,
 	init_state++;
 
 	vram = 0;
-	for (i = 0; i < fbdev->mem_desc.region_cnt; i++) {
-		r = register_framebuffer(fbdev->fb_info[i]);
-		if (r != 0) {
-			dev_err(fbdev->dev,
-				"registering framebuffer %d failed\n", i);
-			goto cleanup;
-		}
+	for (i = 0; i < fbdev->mem_desc.region_cnt; i++)
 		vram += fbdev->mem_desc.region[i].size;
-	}
 
 	fbdev->state = OMAPFB_ACTIVE;
 
--

1.6.3.2

#2 lore raw
Quoted 7 lines · Sergio Alberto

Hi,

This patch has been lying around for some weeks now, with just responses about successful testing (detailed in the description).

Is there anything holding it for merge? Or should I try sending it to other ML?

BTW, It applies cleanly on mainline aswell.

Try running 'get_maintainer' script to find other people that have worked on this code:
Trilok Soni <[email protected]>
Andrew Morton <[email protected]>
Tony Lindgren <[email protected]>
Russell King <[email protected]>
Krzysztof Helt <[email protected]>

My feedback is: please mention in the message how the bug can be triggered.

And watch your uppercases:
omapfb: reorder register_framebuffer call

Signature · 1 line
Felipe Contreras
#3 lore raw

PATCH 1/1 omapfb: Reorder Register_framebuffer call

In reply to Sergio Aguirre

This patch has been applied to the linux-omap
by youw fwiendly patch wobot.

Branch in linux-omap: omap-fixes

Initial commit ID (Likely to change): 9aef1066fb5ca8506068eaab1c552ecca4c85475

PatchWorks
http://patchwork.kernel.org/patch/47089/

Git (Likely to change, and takes a while to get mirrored)
http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git;a=commit;h=9aef1066fb5ca8506068eaab1c552ecca4c85475

#4 lore raw
Quoted 10 lines · Tony Lindgren

This patch has been applied to the linux-omap
by youw fwiendly patch wobot.

Branch in linux-omap: omap-fixes

Initial commit ID (Likely to change): 9aef1066fb5ca8506068eaab1c552ecca4c85475

PatchWorks
http://patchwork.kernel.org/patch/47089/

Is it actually safe to do this? The framebuffer can be used directly after it is registered. In this case it would mean it is used before it is even fully initialized (set_fb_var(), set_fb_fix(), ... are being called).

Thanks,
Jan

#5 lore raw
Quoted 4 lines · Jan Blunck
Quoted 3 lines · Tony Lindgren

This patch has been applied to the linux-omap
by youw fwiendly patch wobot.

Quoted 8 lines
Quoted 7 lines

Branch in linux-omap: omap-fixes

Initial commit ID (Likely to change): 9aef1066fb5ca8506068eaab1c552ecca4c85475

PatchWorks
http://patchwork.kernel.org/patch/47089/

Added back the original Cc's that were dropped from the linux-omap commit message.

Quoted 4 lines

Is it actually safe to do this? The framebuffer can be used directly after it is registered. In this case it would mean it is used before it is even fully initialized (set_fb_var(), set_fb_fix(), ... are being called).

Good point, dropping the patch.

Also, let's let Tomi Valkeinen deal with queueing up the omap fb code. I can then merge Tomi's branck into linux-omap master branch as needed.

Regards,

Tony

#6 lore raw

From: Tony Lindgren [[email protected]]
Sent: Tuesday, September 22, 2009 11:28 AM

Quoted 17 lines · Jan Blunck
Quoted 12 lines · Tony Lindgren
Quoted 10 lines

This patch has been applied to the linux-omap
by youw fwiendly patch wobot.

Branch in linux-omap: omap-fixes

Initial commit ID (Likely to change): 9aef1066fb5ca8506068eaab1c552ecca4c85475

PatchWorks
http://patchwork.kernel.org/patch/47089/

Added back the original Cc's that were dropped from the linux-omap commit message.

Quoted 6 lines
Quoted 4 lines

Is it actually safe to do this? The framebuffer can be used directly after it is registered. In this case it would mean it is used before it is even fully initialized (set_fb_var(), set_fb_fix(), ... are being called).

Good point, dropping the patch.

Hmm, ok. I guess i'll rework this patch considering that..

I ran some framebuffer tests with this patch applied, and they worked fine for me.

The only thing is that i didn't saw Tux on bootup...

Actually, nobody ever gave this kind of feedback, which was the initial idea.

Just people worried about booting properly.

Anyways, thanks for your time! I appreciate it.

Regards,
Sergio

Quoted 9 lines

Also, let's let Tomi Valkeinen deal with queueing up the omap fb code. I can then merge Tomi's branck into linux-omap master branch as needed.

Regards,

Tony

#7 lore raw
Quoted 26 lines · Sergio Alberto

From: Tony Lindgren [[email protected]]
Sent: Tuesday, September 22, 2009 11:28 AM

Quoted 17 lines · Jan Blunck
Quoted 12 lines · Tony Lindgren
Quoted 10 lines

This patch has been applied to the linux-omap
by youw fwiendly patch wobot.

Branch in linux-omap: omap-fixes

Initial commit ID (Likely to change): 9aef1066fb5ca8506068eaab1c552ecca4c85475

PatchWorks
http://patchwork.kernel.org/patch/47089/

Added back the original Cc's that were dropped from the linux-omap commit message.

Quoted 6 lines
Quoted 4 lines

Is it actually safe to do this? The framebuffer can be used directly after it is registered. In this case it would mean it is used before it is even fully initialized (set_fb_var(), set_fb_fix(), ... are being called).

Good point, dropping the patch.

Quoted 8 lines

Hmm, ok. I guess i'll rework this patch considering that..

I ran some framebuffer tests with this patch applied, and they worked fine for me.

The only thing is that i didn't saw Tux on bootup...

Actually, nobody ever gave this kind of feedback, which was the initial idea.

Sorry, I didn't look into it earlier.

BTW, I actually wonder if it's really necessary to initialize the mutex in register_framebuffer() or why it couldn't be done during allocation.

Cheers,
Jan

#8 lore raw
Quoted 30 lines · Jan Blunck
Quoted 28 lines · Sergio Alberto

From: Tony Lindgren [[email protected]]
Sent: Tuesday, September 22, 2009 11:28 AM

Quoted 12 lines · Jan Blunck
Quoted 11 lines · Tony Lindgren
Quoted 10 lines

This patch has been applied to the linux-omap
by youw fwiendly patch wobot.

Branch in linux-omap: omap-fixes

Initial commit ID (Likely to change): 9aef1066fb5ca8506068eaab1c552ecca4c85475

PatchWorks
http://patchwork.kernel.org/patch/47089/

Quoted 8 lines

Added back the original Cc's that were dropped from the linux-omap commit message.

Quoted 4 lines

Is it actually safe to do this? The framebuffer can be used directly after it is registered. In this case it would mean it is used before it is even fully initialized (set_fb_var(), set_fb_fix(), ... are being called).

Good point, dropping the patch.

Hmm, ok. I guess i'll rework this patch considering that..

I ran some framebuffer tests with this patch applied, and they worked fine for me.

The only thing is that i didn't saw Tux on bootup...

Quoted 8 lines
Quoted 2 lines

Actually, nobody ever gave this kind of feedback, which was the initial idea.

Sorry, I didn't look into it earlier.

BTW, I actually wonder if it's really necessary to initialize the mutex in register_framebuffer() or why it couldn't be done during allocation.

This small discussion between Linus and Krzysztof might explain it:
http://marc.info/?l=linux-kernel&m=124703449332064&w=2
or to summarize:
It is done the way it is done to keep drivers working that use statically declared fb_info.

Although I agree, that it would be cleaner the other way around.

Regards,

Florian Tobias Schandinat

#9 lore raw
In reply to Tony Lindgren
Quoted 21 lines · Tony Lindgren
Quoted 11 lines · Jan Blunck
Quoted 10 lines · Tony Lindgren

This patch has been applied to the linux-omap
by youw fwiendly patch wobot.

Branch in linux-omap: omap-fixes

Initial commit ID (Likely to change): 9aef1066fb5ca8506068eaab1c552ecca4c85475

PatchWorks
http://patchwork.kernel.org/patch/47089/

Added back the original Cc's that were dropped from the linux-omap commit message.

Quoted 4 lines

Is it actually safe to do this? The framebuffer can be used directly after it is registered. In this case it would mean it is used before it is even fully initialized (set_fb_var(), set_fb_fix(), ... are being called).

Quoted 8 lines

Good point, dropping the patch.

Also, let's let Tomi Valkeinen deal with queueing up the omap fb code. I can then merge Tomi's branck into linux-omap master branch as needed.

Regards,

Tony

Hello,

This patch doesn't work for us at linwizard project (omap850). The commit 537a1bf059fa312355696fa6db80726e655e7f17 makes the HTC Wizard crash at boot due to usage of uninitialized mutex. Applying the referred patch prevents the crash but the LCD screen goes black and doesn't show any data.

- Angelo

#10 lore raw

From: [email protected] [[email protected]] On Behalf Of Angelo Arrifano [[email protected]]
Sent: Tuesday, September 22, 2009 12:21 PM

Quoted 35 lines

To: Tony Lindgren
Cc: Alistair Buxton; [email protected]
Subject: Re: [APPLIED] [PATCH] omapfb: Reorder Register_framebuffer call

Quoted 21 lines · Tony Lindgren
Quoted 11 lines · Jan Blunck
Quoted 10 lines · Tony Lindgren

This patch has been applied to the linux-omap
by youw fwiendly patch wobot.

Branch in linux-omap: omap-fixes

Initial commit ID (Likely to change): 9aef1066fb5ca8506068eaab1c552ecca4c85475

PatchWorks
http://patchwork.kernel.org/patch/47089/

Added back the original Cc's that were dropped from the linux-omap commit message.

Quoted 4 lines

Is it actually safe to do this? The framebuffer can be used directly after it is registered. In this case it would mean it is used before it is even fully initialized (set_fb_var(), set_fb_fix(), ... are being called).

Quoted 8 lines

Good point, dropping the patch.

Also, let's let Tomi Valkeinen deal with queueing up the omap fb code. I can then merge Tomi's branck into linux-omap master branch as needed.

Regards,

Tony

Quoted 7 lines

Hello,

This patch doesn't work for us at linwizard project (omap850). The commit 537a1bf059fa312355696fa6db80726e655e7f17 makes the HTC Wizard crash at boot due to usage of uninitialized mutex. Applying the referred patch prevents the crash but the LCD screen goes black and doesn't show any data.

Angelo,

Some people gave his ACK, because it was booting. and also i kept it since some framebuffer tests in my 3430SDP passed (i.e. it was showing the intended data.)

However, didn't show the Tux during bootup. Isn't the same case as you?

Anyways, Thanks for sharing your results... I'll rework this patch and resend once i'm done.

Regards,
Sergio

Quoted 7 lines

- Angelo
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw
Quoted 42 lines · Sergio Alberto

From: [email protected] [[email protected]] On Behalf Of Angelo Arrifano [[email protected]]
Sent: Tuesday, September 22, 2009 12:21 PM

Quoted 31 lines

To: Tony Lindgren
Cc: Alistair Buxton; [email protected]
Subject: Re: [APPLIED] [PATCH] omapfb: Reorder Register_framebuffer call

Quoted 26 lines · Tony Lindgren
Quoted 11 lines · Jan Blunck
Quoted 10 lines · Tony Lindgren

This patch has been applied to the linux-omap
by youw fwiendly patch wobot.

Branch in linux-omap: omap-fixes

Initial commit ID (Likely to change): 9aef1066fb5ca8506068eaab1c552ecca4c85475

PatchWorks
http://patchwork.kernel.org/patch/47089/

Added back the original Cc's that were dropped from the linux-omap commit message.

Quoted 4 lines

Is it actually safe to do this? The framebuffer can be used directly after it is registered. In this case it would mean it is used before it is even fully initialized (set_fb_var(), set_fb_fix(), ... are being called).

Good point, dropping the patch.

Also, let's let Tomi Valkeinen deal with queueing up the omap fb code. I can then merge Tomi's branck into linux-omap master branch as needed.

Regards,

Quoted 8 lines
Quoted 1 line

Tony

Hello,

This patch doesn't work for us at linwizard project (omap850). The commit 537a1bf059fa312355696fa6db80726e655e7f17 makes the HTC Wizard crash at boot due to usage of uninitialized mutex. Applying the referred patch prevents the crash but the LCD screen goes black and doesn't show any data.

Quoted 4 lines

Angelo,

Some people gave his ACK, because it was booting. and also i kept it since some framebuffer tests in my 3430SDP passed (i.e. it was showing the intended data.)

Yeah, sorry for the late reply. I was going to add a test-by reply to the patch but I didn't have much info to offer other than it doesn't work for me. At the time USB was also not working so I really didn't have a way to debug in case it was asked.

Quoted 2 lines

However, didn't show the Tux during bootup. Isn't the same case as you?

No tux, no text, just a black screen.

Quoted 2 lines

Anyways, Thanks for sharing your results... I'll rework this patch and resend once i'm done.

Thanks,
- Angelo

Quoted 4 lines

Regards,
Sergio

Quoted 1 line

- Angelo