Behaviour change of /dev/fb0?
Ignoring whether this is a good idea or not, under 2.6.15 you could run
dd if=/dev/zero of=/dev/fb0
which would clear the framebuffer. It would end up saying "dd: /dev/fb0:
No space left on device".
Under 2.6.16 (and a recent git kernel), the same command clears the screen but then hangs. Was the change in behaviour intentional?
I've noticed this on a couple of ARM based Zaurus handhelds under both w100fb and pxafb.
Richard
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
Quoted 4 lines · Richard Purdie
Ignoring whether this is a good idea or not, under 2.6.15 you could run
dd if=/dev/zero of=/dev/fb0
Quoted 9 lines
which would clear the framebuffer. It would end up saying "dd:
/dev/fb0:
No space left on device".Under 2.6.16 (and a recent git kernel), the same command clears the screen but then hangs. Was the change in behaviour intentional?
I've noticed this on a couple of ARM based Zaurus handhelds under both w100fb and pxafb.
There is a change in behavior of fb_read and fb_write committed Jan 2006. They return the number of bytes read or written if the requested size is bigger than the remaining space. Previously, they returned -ENOSPC.
But I haven't experienced hangs...
Tony
Quoted 15 lines · Antonino A. Daplas
Quoted 4 lines · Richard Purdie
Ignoring whether this is a good idea or not, under 2.6.15 you could run
dd if=/dev/zero of=/dev/fb0
Quoted 9 lines
which would clear the framebuffer. It would end up saying "dd:
/dev/fb0:
No space left on device".Under 2.6.16 (and a recent git kernel), the same command clears the screen but then hangs. Was the change in behaviour intentional?
I've noticed this on a couple of ARM based Zaurus handhelds under both w100fb and pxafb.
Quoted 5 lines
There is a change in behavior of
fb_readandfb_writecommitted Jan 2006. They return the number of bytes read or written if the requested size is bigger than the remaining space. Previously, they returned-ENOSPC.But I haven't experienced hangs...
The change in question is:
@@ -661,19 +664,19 @@ fb_write(struct file *file, const char _
return info->fbops->fb_write(file, buf, count, ppos);
total_size = info->screen_size;
+
if (total_size == 0)
total_size = info->fix.smem_len;
if (p > total_size)
- return -ENOSPC;
+ return 0;
+
if (count >= total_size)
- count = total_size;
- err = 0;
- if (count + p > total_size) {
- count = total_size - p;
- err = -ENOSPC;
- }
- cnt = 0;
+ count = total_size;
+
+ if (count + p > total_size)
+ count = total_size - p;
+
buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count,
GFP_KERNEL);
if (!buffer)
I agree with the latter part of this but not the change for the "if (p > total_size)" case. If we return zero here, the writer will just keep retrying to write to the device indefinitely and therefore hang. Would it make sense to revert that part of the change?:
If we reach the end of the framebuffer, we should return an out of space error, not zero. Returning zero implies we might be able to write further bytes at some future time which isn't true.
drivers/video/fbmem.c +1 -1
@@ -674,7 +674,7 @@ total_size = info->fix.smem_len;if (p > total_size) -return 0 ; +return -ENOSPC ;if (count >= total_size) count = total_size;
Quoted 4 lines · Richard Purdie
Ignoring whether this is a good idea or not, under 2.6.15 you could run
dd if=/dev/zero of=/dev/fb0
Quoted 9 lines
which would clear the framebuffer. It would end up saying "dd:
/dev/fb0:
No space left on device".Under 2.6.16 (and a recent git kernel), the same command clears the screen but then hangs. Was the change in behaviour intentional?
I've noticed this on a couple of ARM based Zaurus handhelds under both w100fb and pxafb.
After reading 'man 2 read' more thoroughly, I've adjusted fb_write()'s return codes appropriately. Can you try this patch and let me know if it fixes your problem.
Tony
fbdev: Fix return error of fb_write()
- return -EFBIG if file offset is past the maximum allowable offset
- return -EFBIG and write to end of framebuffer if size is bigger than the framebuffer length
- return -ENOSPC and write to end of framebuffer if size is bigger than the framebuffer length - file offset
---
drivers/video/fbmem.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
drivers/video/fbmem.c +9 -3
@@ -669,13 +669,19 @@ fb_write(struct file *file, const char _ total_size = info->fix.smem_len;if (p > total_size) -return 0 ; +return -EFBIG ; -if (count >= total_size) +if (count >= total_size) { + err = -EFBIG ; count = total_size; + } + +if (count + p > total_size) { +if (!err) + err = -ENOSPC ; -if (count + p > total_size) count = total_size - p; + } buffer =kmalloc ((count >PAGE_SIZE ) ?PAGE_SIZE : count,GFP_KERNEL );
Quoted 20 lines · Antonino A. Daplas
Quoted 4 lines · Richard Purdie
Ignoring whether this is a good idea or not, under 2.6.15 you could run
dd if=/dev/zero of=/dev/fb0
Quoted 9 lines
which would clear the framebuffer. It would end up saying "dd:
/dev/fb0:
No space left on device".Under 2.6.16 (and a recent git kernel), the same command clears the screen but then hangs. Was the change in behaviour intentional?
I've noticed this on a couple of ARM based Zaurus handhelds under both w100fb and pxafb.
After reading 'man 2 read' more thoroughly, I've adjusted fb_write()'s return codes appropriately. Can you try this patch and let me know if it fixes your problem.
Quoted 5 lines
Tony
fbdev: Fix return error of
fb_write()- return
-EFBIGif file offset is past the maximum allowable offset
OK.
Quoted 2 lines
- return
-EFBIGand write to end of framebuffer if size is bigger than the framebuffer length
We should return the number of bytes written in this case.
Quoted 2 lines
- return
-ENOSPCand write to end of framebuffer if size is bigger than the framebuffer length - file offset
Also here.
If we can transfer _any_ bytes, we should do so, then return the number of bytes transferred. If no bytes were transferrable then we should return -Ewhatever.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
PATCH 1/1 fbdev: Fix return error of fb_write
Fix return code of fb_write():
If at least 1 byte was transferred to the device, return number of bytes, otherwise:
- return -EFBIG - if file offset is past the maximum allowable offset or size is greater than framebuffer length
- return -ENOSPC - if size is greater than framebuffer length - offset
---
Quoted 15 lines · Andrew Morton
Quoted 3 lines · Antonino A. Daplas
Richard Purdie wrote:
- return
-EFBIGif file offset is past the maximum allowable offsetOK.
Quoted 2 lines
- return
-EFBIGand write to end of framebuffer if size is bigger than the framebuffer lengthWe should return the number of bytes written in this case.
Quoted 2 lines
- return
-ENOSPCand write to end of framebuffer if size is bigger than the framebuffer length - file offset
Quoted 8 lines
Also here.
If we can transfer _any_ bytes, we should do so, then return the number of bytes transferred. If no bytes were transferrable then we should return -Ewhatever.
Okay, here's try #2:
drivers/video/fbmem.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
drivers/video/fbmem.c +10 -4
@@ -669,13 +669,19 @@ fb_write(struct file *file, const char _ total_size = info->fix.smem_len;if (p > total_size) -return 0 ; +return -EFBIG ; -if (count >= total_size) +if (count > total_size) { + err = -EFBIG ; count = total_size; + } + +if (count + p > total_size) { +if (!err) + err = -ENOSPC ; -if (count + p > total_size) count = total_size - p; + } buffer =kmalloc ((count >PAGE_SIZE ) ?PAGE_SIZE : count,GFP_KERNEL );
@@ -717,7 +723,7 @@ fb_write(struct file *file, const char _kfree (buffer); -return (err) ? err : cnt; +return (cnt) ? cnt : err; }#ifdef CONFIG_KMOD
Re: [PATCH] fbdev: Fix return error of fb_write
Quoted 10 lines · Antonino A. Daplas
Fix return code of
fb_write():If at least 1 byte was transferred to the device, return number of bytes, otherwise:
- return
-EFBIG- if file offset is past the maximum allowable offset or size is greater than framebuffer length
- return-ENOSPC- if size is greater than framebuffer length - offsetSigned-off-by Antonino Daplas <[email protected]>
I can confirm this fixes the problem I reported, thanks!
Richard
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642