deprecating fix->mmio_start and smem_start
Hi !
We currently have a problem with those two members of struct fb_fix_screeninfo. The struct contains an "unsigned long" which means that:
- 64 bits kernels with 32 bits userspace can't pass a complete address
- 32 bits machines with 64 bits resource_size_t can't pass a complete address
- The structure isn't even properly padded to be 32/64 bits neutral in the first place.
We could define new versions of the struct with new get/set ioctls, or we could try to just deprecate those fields. What do you guys think ?
If we do the later, we need another way to convey the informations.
For smem, I'm not sure it's very useful, we should just be able to mmap the fbdev. The problem is more with mmio_start.
Thus the idea that we could do something to allow mmap'ing mmio via mmap of /dev/fb via some specific offset... what do you think ?
Or we can just do a fb_fix_screeninfo2, with proper padding and u64 addresses, replace the kernel one with that, have translators for the old ioctl's, and new ioctl's.
What do you guys think ?
Cheers,
Ben.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Quoted 4 lines · Benjamin Herrenschmidt
We currently have a problem with those two members of struct
fb_fix_screeninfo. The struct contains an "unsigned long" which means that:
Quoted 8 lines
- 64 bits kernels with 32 bits userspace can't pass a complete address
- 32 bits machines with 64 bitsresource_size_tcan't pass a complete address
- The structure isn't even properly padded to be 32/64 bits neutral in the first place.We could define new versions of the struct with new get/set ioctls, or we could try to just deprecate those fields. What do you guys think ?
As userspace doesn't really need those fields[1], we can easily deprecate them.
Quoted 7 lines
If we do the later, we need another way to convey the informations.
For smem, I'm not sure it's very useful, we should just be able to mmap the fbdev. The problem is more with
mmio_start.Thus the idea that we could do something to allow mmap'ing mmio via mmap of
/dev/fbvia some specific offset... what do you think ?
That's exactly what drivers/video/fbmem.c:fb_mmap() does[2].
But fb_mmap() does need the correct (resource_size_t) information. That can be done by changing the offending fields in the kernel variant of fb_fix_screeninfo to resource_size_t.
The user variant of fb_fix_screeninfo would stay the same, and only the FBIOGET_FSCREENINFO case in drivers/video/fbmem.c:fb_ioctl() has to be changed to convert from the kernel to the user variant.
Quoted 3 lines
Or we can just do a
fb_fix_screeninfo2, with proper padding and u64 addresses, replace the kernel one with that, have translators for the old ioctl's, and new ioctl's.
I don't think the new ioctls are needed.
[1] Except when it wants to mmap /dev/mem using this info, but that can be done using [2].
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Quoted 5 lines
Quoted 3 lines
We could define new versions of the struct with new get/set ioctls, or we could try to just deprecate those fields. What do you guys think ?
As userspace doesn't really need those fields[1], we can easily deprecate them.
Well... yes and no. At least some X drivers use the mmio_start field to map registers via /dev/mem no ?
Quoted 9 lines
Quoted 7 lines
If we do the later, we need another way to convey the informations.
For smem, I'm not sure it's very useful, we should just be able to mmap the fbdev. The problem is more with
mmio_start.Thus the idea that we could do something to allow mmap'ing mmio via mmap of
/dev/fbvia some specific offset... what do you think ?That's exactly what drivers/video/fbmem.c:fb_mmap() does[2].
Ok, I had a look at it does indeed make MMIO appear after the fb. The funny thing here is that it does use fix for that which means it's broken on those platforms.
Quoted 3 lines
But
fb_mmap()does need the correct (resource_size_t) information. That can be done by changing the offending fields in the kernel variant offb_fix_screeninfotoresource_size_t.
Yup, and we need to add some conversion to the "user" variant.
Quoted 3 lines
The user variant of
fb_fix_screeninfowould stay the same, and only theFBIOGET_FSCREENINFOcase in drivers/video/fbmem.c:fb_ioctl() has to be changed to convert from the kernel to the user variant.
Yup. I could always set smem_start to 0 and mmio_stat to smem_len in there while at it. This will break the day we have 4G of video RAM though. Which is why I wonder if we should -also- make the new kernel structure user-visible with a new ioctl, so that user space can migrate and the day we have such monsters, we aren't totally broken ?
Quoted 2 lines
[1] Except when it wants to mmap
/dev/memusing this info, but that can be done using [2].
Yes, but there are existing broken programs. I'm pretty sure there used to be at least...
One option here is we can test if the values are > 32 bits, when converting from the in-kernel 64 bits structure.
If that's not the case, we copy them as usual, thus we stay compatible for cases that work today (such as a 64 bits G5 with 32 bits userspace as all MMIO on the G5 is below 4G).
If they are >4G, we do something like putting 0xffffffff in smem_start and mmio_start, which should make mmap attempts via /dev/mem to fail and keep smem_len and mmio_len to the right values.
What do you think ?
Cheers,
Ben.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 4 lines
Quoted 2 lines
We could define new versions of the struct with new get/set ioctls, or we could try to just deprecate those fields. What do you guys think ?
As userspace doesn't really need those fields[1], we can easily deprecate them.
Well... yes and no. At least some X drivers use the
mmio_startfield to map registers via/dev/memno ?
Perhaps some do. But they're supposed to map mmio by mapping /dev/fb beyond smem_len.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
If we do the later, we need another way to convey the informations.
For smem, I'm not sure it's very useful, we should just be able to mmap the fbdev. The problem is more with
mmio_start.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Thus the idea that we could do something to allow mmap'ing mmio via mmap of
/dev/fbvia some specific offset... what do you think ?That's exactly what drivers/video/fbmem.c:fb_mmap() does[2].
Ok, I had a look at it does indeed make MMIO appear after the fb. The funny thing here is that it does use fix for that which means it's broken on those platforms.
Yes, that's true.
Quoted 4 lines
Quoted 3 lines
But
fb_mmap()does need the correct (resource_size_t) information. That can be done by changing the offending fields in the kernel variant offb_fix_screeninfotoresource_size_t.
Quoted 8 lines
Yup, and we need to add some conversion to the "user" variant.
Quoted 3 lines
The user variant of
fb_fix_screeninfowould stay the same, and only theFBIOGET_FSCREENINFOcase in drivers/video/fbmem.c:fb_ioctl() has to be changed to convert from the kernel to the user variant.Yup. I could always set
smem_startto 0 andmmio_stattosmem_lenin there while at it. This will break the day we have 4G of video RAM
What does this solve? If userspace uses this to map /dev/mem, it will map physical address 0?
Won't hurt on all platforms, but it will definitely hurt x86, as they have system RAM at 0 ;-)
Quoted 3 lines
though. Which is why I wonder if we should -also- make the new kernel structure user-visible with a new ioctl, so that user space can migrate and the day we have such monsters, we aren't totally broken ?
Hmm, that definitely means a new fb_fix_screeninfo, as smem_len is currently u32, even on 64-bit.
Quoted 6 lines
Quoted 2 lines
[1] Except when it wants to mmap
/dev/memusing this info, but that can be done using [2].Yes, but there are existing broken programs. I'm pretty sure there used to be at least...
Quoted 6 lines
One option here is we can test if the values are > 32 bits, when converting from the in-kernel 64 bits structure.
If that's not the case, we copy them as usual, thus we stay compatible for cases that work today (such as a 64 bits G5 with 32 bits userspace as all MMIO on the G5 is below 4G).
Sounds OK to me.
Quoted 3 lines
If they are >4G, we do something like putting
0xffffffffinsmem_startandmmio_start, which should make mmap attempts via/dev/memto fail and keepsmem_lenandmmio_lento the right values.
Sounds OK, too.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Quoted 8 lines · Geert Uytterhoeven
Quoted 1 line
though. Which is why I wonder if we should -also- make the new
kernel
Quoted 1 line
structure user-visible with a new ioctl, so that user space can
migrate
Quoted 1 line
and the day we have such monsters, we aren't totally broken ?
Hmm, that definitely means a new
fb_fix_screeninfo, assmem_lenis currently u32, even on 64-bit.
Yup, I think that's the way to go.
I'll cook up a patch one of these days.
Cheers,
Ben.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Quoted 11 lines · Benjamin Herrenschmidt
Quoted 10 lines
We currently have a problem with those two members of struct
fb_fix_screeninfo. The struct contains an "unsigned long" which means that:- 64 bits kernels with 32 bits userspace can't pass a complete address
- 32 bits machines with 64 bitsresource_size_tcan't pass a complete address
- The structure isn't even properly padded to be 32/64 bits neutral in the first place.
Quoted 6 lines
Quoted 2 lines
We could define new versions of the struct with new get/set ioctls,
or we could try to just deprecate those fields. What do you guys think ?As userspace doesn't really need those fields[1], we can easily deprecate them.
kexec uses FBIOGET_FSCREENINFO and FBIOGET_VSCREENINFO. So if these ioctls changes, it will possibly break kexec under vesafb and efifb.
Scott
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Quoted 11 lines · Scott D. Davilla
Quoted 11 lines · Benjamin Herrenschmidt
Quoted 10 lines
We currently have a problem with those two members of struct
fb_fix_screeninfo. The struct contains an "unsigned long" which means that:- 64 bits kernels with 32 bits userspace can't pass a complete address
- 32 bits machines with 64 bitsresource_size_tcan't pass a complete address
- The structure isn't even properly padded to be 32/64 bits neutral in the first place.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
We could define new versions of the struct with new get/set ioctls,
or we could try to just deprecate those fields. What do you guys think ?As userspace doesn't really need those fields[1], we can easily deprecate them.
kexec uses
FBIOGET_FSCREENINFOandFBIOGET_VSCREENINFO. So if these ioctls changes, it will possibly break kexec under vesafb and efifb.
Does kexec use the smem_start and mmio_start fields of fb_fix_screeninfo?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Quoted 15 lines · Scott D. Davilla
Quoted 14 lines
Quoted 14 lines · Benjamin Herrenschmidt
Quoted 12 lines
We currently have a problem with those two members of struct
fb_fix_screeninfo. The struct contains an "unsigned long" which means that:- 64 bits kernels with 32 bits userspace can't pass a complete address
- 32 bits machines with 64 bitsresource_size_tcan't pass a complete address
- The structure isn't even properly padded to be 32/64 bits neutral in the first place.We could define new versions of the struct with new get/set ioctls,
or we could try to just deprecate those fields. What do you guys think ?
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
As userspace doesn't really need those fields[1], we can easily deprecate them.
kexec uses
FBIOGET_FSCREENINFOandFBIOGET_VSCREENINFO. So if these ioctls changes, it will possibly break kexec under vesafb and efifb.Does kexec use the
smem_startandmmio_startfields offb_fix_screeninfo?
In "kexec/arch/i386/x86-linux-setup.c", the routine "setup_linux_vesafb" uses smem_start, smem_len, and line_length.
This is used for vesafb and efifb framebuffer kernel boot param setup. This is required for PC hardware that do not contain a PC-BIOS and need the bootloader to setup the kernel video boot params.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Quoted 28 lines · Scott D. Davilla
Quoted 18 lines · Scott D. Davilla
Quoted 17 lines
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 5 lines
We currently have a problem with those two members of struct
fb_fix_screeninfo. The struct contains an "unsigned long" which means that:- 64 bits kernels with 32 bits userspace can't pass a complete
address
Quoted 3 lines
Quoted 3 lines
- 32 bits machines with 64 bits
resource_size_tcan't pass a complete address
- The structure isn't even properly padded to be 32/64 bits neutralin
Quoted 4 lines
Quoted 4 lines
the first place.
We could define new versions of the struct with new get/set ioctls,
or we could try to just deprecate those fields. What do you guysthink ?
Quoted 1 line
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
As userspace doesn't really need those fields[1], we can easily deprecate them.
kexec uses
FBIOGET_FSCREENINFOandFBIOGET_VSCREENINFO. So if these ioctls changes, it will possibly break kexec under vesafb and efifb.Does kexec use the
smem_startandmmio_startfields offb_fix_screeninfo?
Quoted 6 lines
In "
kexec/arch/i386/x86-linux-setup.c", the routine "setup_linux_vesafb" usessmem_start,smem_len, andline_length.This is used for vesafb and efifb framebuffer kernel boot param setup. This is required for PC hardware that do not contain a PC-BIOS and need the bootloader to setup the kernel video boot params.
OK, but the problem doesn't show up on x86-32 (no >32-bit physical addresses yet), as x86_linux_param_header.lfb_base is uint32_t and there's no way it's gonna change.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Quoted 42 lines · Scott D. Davilla
Quoted 35 lines
Quoted 4 lines · Scott D. Davilla
Quoted 3 lines
Quoted 3 lines · Benjamin Herrenschmidt
Quoted 2 lines
We currently have a problem with those two members of struct
fb_fix_screeninfo. The struct contains an "unsigned long"which means
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
that:
- 64 bits kernels with 32 bits userspace can't pass a complete
address
Quoted 1 line
Quoted 1 line
- 32 bits machines with 64 bits
resource_size_tcan'tpass a complete
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
address
- The structure isn't even properly padded to be 32/64 bits neutralin
Quoted 3 lines
Quoted 3 lines
the first place.
We could define new versions of the struct with new
get/set ioctls,
Quoted 12 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
or we could try to just deprecate those fields. What do you guys
think ?
Quoted 3 lines
As userspace doesn't really need those fields[1], we can easily deprecate them.
kexec uses
FBIOGET_FSCREENINFOandFBIOGET_VSCREENINFO. So if these ioctls changes, it will possibly break kexec under vesafb and efifb.Does kexec use the
smem_startandmmio_startfields offb_fix_screeninfo?In "
kexec/arch/i386/x86-linux-setup.c", the routine
"setup_linux_vesafb" uses
smem_start,smem_len, andline_length.Quoted 5 lines
This is used for vesafb and efifb framebuffer kernel boot param
setup. This is
required for PC hardware that do not contain a PC-BIOS and need
the bootloader
to setup the kernel video boot params.
Quoted 4 lines
OK, but the problem doesn't show up on x86-32 (no >32-bit physical addresses yet), as x86_linux_param_header.lfb_base is
uint32_tand there's no way it's gonna change.
I seem to remember the EFI/kexec guys have been doing kexec from 32->64 kernel and I think 64->32. I'm 32 bit only so I have no experience under 64 bit kernels and don't really pay much attention to 64 bit kernel patches. Huang Ying was doing the EFI/kexec patches a few months ago.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Quoted 11 lines · Geert Uytterhoeven
Quoted 10 lines · Benjamin Herrenschmidt
We currently have a problem with those two members of struct
fb_fix_screeninfo. The struct contains an "unsigned long" which means that:- 64 bits kernels with 32 bits userspace can't pass a complete address
- 32 bits machines with 64 bitsresource_size_tcan't pass a complete address
- The structure isn't even properly padded to be 32/64 bits neutral in the first place.
Quoted 4 lines
Quoted 2 lines
We could define new versions of the struct with new get/set ioctls, or we could try to just deprecate those fields. What do you guys think ?
As userspace doesn't really need those fields[1], we can easily deprecate them.
DirectFB uses both.
smem_start is used to get the physical address of the frambuffer for v4l capture purposes at least. It's also used by several of the hw specific gfxdrivers for various reasons. For example the matrox driver uses it to figure out the offset from the beginning of the video memory to the portion allocated for CRTC2 by matroxfb. This only applies when matroxfb is left in control of CRTC2. I doubt may people use DirectFB this way since DirectFB can drive CRTC2+TVout itself and manage the full memory for both heads. But the support is still there in the code FWIW. I'm not actually sure what the other gfxdrivers use it for but I see several references when I grep for it.
mmio_start is used to figure out where the registers actually lie within the mmapped MMIO area. atyfb is the only fb driver that I know to need this. The problem is that with new chips the aux register aperture is used and the registers are at the beginning of that aperture but when the aux register aperture is not used the registers occupy the last 2K of the framebuffer. That means an offset of 2K on typical systems.
Signature · 9 lines
Ville Syrjälä [email protected] http://www.sci.fi/~syrjala/ ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
Quoted 13 lines · Ville Syrjälä
DirectFB uses both.
smem_startis used to get the physical address of the frambuffer for v4l capture purposes at least. It's also used by several of the hw specific gfxdrivers for various reasons. For example the matrox driver uses it to figure out the offset from the beginning of the video memory to the portion allocated for CRTC2 by matroxfb. This only applies when matroxfb is left in control of CRTC2. I doubt may people use DirectFB this way since DirectFB can drive CRTC2+TVout itself and manage the full memory for both heads. But the support is still there in the code FWIW. I'm not actually sure what the other gfxdrivers use it for but I see several references when I grep for it.
Quoted 6 lines
mmio_startis used to figure out where the registers actually lie within the mmapped MMIO area. atyfb is the only fb driver that I know to need this. The problem is that with new chips the aux register aperture is used and the registers are at the beginning of that aperture but when the aux register aperture is not used the registers occupy the last 2K of the framebuffer. That means an offset of 2K on typical systems.
So DirectFB can be fixed to use the "new" structure with 64 bits offsets if we define such a thing right ? (with new ioctl's to access it).
Cheers,
Ben.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Linux-fbdev-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel