Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* bug in fbmem.c,
@ 1999-06-22  8:57 Vignaud Jean-Baptiste
       [not found] ` <3770E2AF.4BC00019@pobox.com>
       [not found] ` <376F7E90.B2646D23@pobox.com>
  0 siblings, 2 replies; 7+ messages in thread
From: Vignaud Jean-Baptiste @ 1999-06-22  8:57 UTC (permalink / raw)
  To: axp-list, FrameBuffer; +Cc: Linux kernel, Bibek Sahu, Adam C. Powell IV

Hi,

I'v traced a little bug in the fbmem code. i don't know if it's the right
way to
correct it, but on my SX164 alpha this seems to work.

before the patch: cat /dev/fb0 > foo end with an execption.
after the patch: cat /dev/fb0 > foo ; cat foo > /dev/fb0 work.

There are others problems with the fbdriver on alpha:
mmapping the /dev/fb0 and writing to it give me a *RANDOM* 'PYXIS machine
check NOT expected'
with no effect on the screen.
Maybe someone have an idea?


Jean-Baptiste Vignaud.

--- fbmem.c     Wed Mar 17 18:17:22 1999
+++ fbmem.c.new Tue Jun 22 11:04:03 1999
@@ -30,7 +30,7 @@
 #if defined(__mc68000__) || defined(CONFIG_APUS)
 #include <asm/setup.h>
 #endif
-#ifdef __powerpc__
+#if defined(__powerpc__) || defined(__alpha__)
 #include <asm/io.h>
 #endif
 #include <asm/uaccess.h>
@@ -251,8 +251,7 @@
        fb->fb_get_fix(&fix,PROC_CONSOLE(), info);
        base_addr=info->disp->screen_base;
        copy_size=(count + p <= fix.smem_len ? count : fix.smem_len - p);
-       if (copy_to_user(buf, base_addr+p, copy_size))
-           return -EFAULT;
+       memcpy_fromio(buf, base_addr+p, copy_size);
        *ppos += copy_size;
        return copy_size;
 }
@@ -275,8 +274,7 @@
        fb->fb_get_fix(&fix, PROC_CONSOLE(), info);
        base_addr=info->disp->screen_base;
        copy_size=(count + p <= fix.smem_len ? count : fix.smem_len - p);
-       if (copy_from_user(base_addr+p, buf, copy_size))
-           return -EFAULT;
+       memcpy_toio(base_addr+p, buf, copy_size);
        file->f_pos += copy_size;
        return copy_size;
 }



^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: bug in fbmem.c,
       [not found] <19990622130211.05844@atrey.karlin.mff.cuni.cz>
@ 1999-06-22 11:03 ` Vignaud Jean-Baptiste
  0 siblings, 0 replies; 7+ messages in thread
From: Vignaud Jean-Baptiste @ 1999-06-22 11:03 UTC (permalink / raw)
  To: Pavel Machek, FrameBuffer, axp-list


>
> Hi!
>
> > I'v traced a little bug in the fbmem code. i don't know if it's
> the right
> > way to
> > correct it, but on my SX164 alpha this seems to work.
> >
> > before the patch: cat /dev/fb0 > foo end with an execption.
> > after the patch: cat /dev/fb0 > foo ; cat foo > /dev/fb0 work.
>
> Can you try to
> 	h = open (/dev/fb0, )
> 	read(h, 0, 256)
> ? Yes, I want you to read into null. I suspect you need something like
> memcpy_fromio_to_user() which does not actually exist :-).
>

Yes, that's right, maybe this 'memcpy_fromio_to_user' is needed.
An other way to do this, as VANDROVE@vc.cvut.cz wrote, is to use a buffer
and
to do  copy_from_user and memcpy_fromio...

Is there another way to perform this?

Jean-Baptiste Vignaud.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug in fbmem.c,
       [not found] ` <3770E2AF.4BC00019@pobox.com>
@ 1999-06-28 19:55   ` Richard Henderson
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 1999-06-28 19:55 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Vignaud Jean-Baptiste, axp-list, FrameBuffer, Linux kernel,
	Bibek Sahu, Adam C. Powell IV

On Wed, Jun 23, 1999 at 09:35:43AM -0400, Jeff Garzik wrote:
> +	if (copy_size > 0) {
> +		char tmpbuf [copy_size];

You can't do dynamic stack allocation in the kernel.
You'll have to use kmalloc or get_free_page or something.


r~


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug in fbmem.c,
       [not found] <Pine.LNX.3.95.990628173155.278A-100000@chaos.analogic.com>
@ 1999-06-28 21:46 ` Jeff Garzik
  1999-06-28 22:49   ` Richard Henderson
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff Garzik @ 1999-06-28 21:46 UTC (permalink / raw)
  To: root; +Cc: Richard Henderson, axp-list, FrameBuffer

"Richard B. Johnson" wrote:
> 
> On Mon, 28 Jun 1999, Richard Henderson wrote:
> 
> > On Wed, Jun 23, 1999 at 09:35:43AM -0400, Jeff Garzik wrote:
> > > +   if (copy_size > 0) {
> > > +           char tmpbuf [copy_size];
> >
> > You can't do dynamic stack allocation in the kernel.
> > You'll have to use kmalloc or get_free_page or something.
> >
> > r~
> >
> 
> Are you sure? With some limits-checking it should work, compiler
> just subtracts N words from the stack-pointer to make room and
> since the compiler 'knows' it did this, it still 'knows' where
> everything else is.

Even if the compiler can do it the fix is not correct because data
copying need only occur on the Alpha, not on all platforms.

	Jeff


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: bug in fbmem.c,
  1999-06-28 21:46 ` Jeff Garzik
@ 1999-06-28 22:49   ` Richard Henderson
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 1999-06-28 22:49 UTC (permalink / raw)
  To: axp-list; +Cc: root, FrameBuffer

On Mon, Jun 28, 1999 at 05:46:08PM -0400, Jeff Garzik wrote:
> "Richard B. Johnson" wrote:
> > Are you sure? With some limits-checking it should work, compiler
> > just subtracts N words from the stack-pointer to make room and
> > since the compiler 'knows' it did this, it still 'knows' where
> > everything else is.

How much room is left on the kernel stack?  You don't know,
so you don't know how to bound such a limits check.

> Even if the compiler can do it the fix is not correct because data
> copying need only occur on the Alpha, not on all platforms.

If it were up to me, I'd do it for all platforms, since it's
more Correct.  This isn't exactly a speed-critical interface.

But it's not up to me -- the fbdev maintainers may do whatever
they wish.


r~


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-fbdev] Re: bug in fbmem.c,
       [not found] ` <376F7E90.B2646D23@pobox.com>
@ 1999-07-08 17:46   ` Jes Sorensen
  1999-07-08 17:46     ` Jes Sorensen
  0 siblings, 1 reply; 7+ messages in thread
From: Jes Sorensen @ 1999-07-08 17:46 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Vignaud Jean-Baptiste, axp-list, FrameBuffer, Linux kernel,
	Bibek Sahu, Adam C. Powell IV

>>>>> "Jeff" == Jeff Garzik <jgarzik@pobox.com> writes:

Jeff> Vignaud Jean-Baptiste wrote:
>> I'v traced a little bug in the fbmem code. i don't know if it's the
>> right way to correct it, but on my SX164 alpha this seems to work.

Jeff> Good catch!  I guess I shouldn't only use the sight of a penguin
Jeff> and running XF86_FBDev as tests.  ;-)

Jeff> You cannot eliminate the copy_to_user() and copy_from_user()
Jeff> calls.  I don't recall what type of addresses copy_xxx_user()
Jeff> wants, but I suspect you either need a copy buffer

Jeff> 	memcpy_fromio (bufruf, base_addr+p, copy_size); if
Jeff> (copy_to_user(buf, bufruf, copy_size)) ...

Jeff> or maybe you can get away with some variant of

Jeff> 	if (copy_to_user(buf, __phys_to_virt (base_addr+p), copy_size)
Jeff> ...

You generally cannot apply phys_to_virt to frame buffer memory
addresses, you are not guaranteed a 1->1 mapping of it.

Jes


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-fbdev] Re: bug in fbmem.c,
  1999-07-08 17:46   ` [linux-fbdev] " Jes Sorensen
@ 1999-07-08 17:46     ` Jes Sorensen
  0 siblings, 0 replies; 7+ messages in thread
From: Jes Sorensen @ 1999-07-08 17:46 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: Vignaud Jean-Baptiste, axp-list, FrameBuffer, Linux kernel,
	Bibek Sahu, Adam C. Powell IV


>>>>> "Jeff" == Jeff Garzik <jgarzik@pobox.com> writes:

Jeff> Vignaud Jean-Baptiste wrote:
>> I'v traced a little bug in the fbmem code. i don't know if it's the
>> right way to correct it, but on my SX164 alpha this seems to work.

Jeff> Good catch!  I guess I shouldn't only use the sight of a penguin
Jeff> and running XF86_FBDev as tests.  ;-)

Jeff> You cannot eliminate the copy_to_user() and copy_from_user()
Jeff> calls.  I don't recall what type of addresses copy_xxx_user()
Jeff> wants, but I suspect you either need a copy buffer

Jeff> 	memcpy_fromio (bufruf, base_addr+p, copy_size); if
Jeff> (copy_to_user(buf, bufruf, copy_size)) ...

Jeff> or maybe you can get away with some variant of

Jeff> 	if (copy_to_user(buf, __phys_to_virt (base_addr+p), copy_size)
Jeff> ...

You generally cannot apply phys_to_virt to frame buffer memory
addresses, you are not guaranteed a 1->1 mapping of it.

Jes

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1999-07-23 12:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-06-22  8:57 bug in fbmem.c, Vignaud Jean-Baptiste
     [not found] ` <3770E2AF.4BC00019@pobox.com>
1999-06-28 19:55   ` Richard Henderson
     [not found] ` <376F7E90.B2646D23@pobox.com>
1999-07-08 17:46   ` [linux-fbdev] " Jes Sorensen
1999-07-08 17:46     ` Jes Sorensen
     [not found] <19990622130211.05844@atrey.karlin.mff.cuni.cz>
1999-06-22 11:03 ` Vignaud Jean-Baptiste
     [not found] <Pine.LNX.3.95.990628173155.278A-100000@chaos.analogic.com>
1999-06-28 21:46 ` Jeff Garzik
1999-06-28 22:49   ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox