From: "Petr Vandrovec" <VANDROVE@vc.cvut.cz>
To: Antonino Daplas <adaplas@pol.net>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-fbdev-devel@lists.sourceforge.net
Subject: Re: [PATCH 1/3: FBDEV: VGA State Save/Restore module
Date: Wed, 4 Dec 2002 19:41:09 +0100 [thread overview]
Message-ID: <962842B4859@vcnet.vc.cvut.cz> (raw)
On 4 Dec 02 at 22:26, Antonino Daplas wrote:
> +static void vga_cleanup(struct fb_vgastate *state)
> +{
> + if (state->fbbase)
> + iounmap(state->fbbase);
> +}
Nobody is setting state->fbbase to NULL, so
"save_vga(SAVE_FONT); restore_vga(); save_vga(0); restore_vga();"
will badly die. I think that you should change save prototype to
int fb_save_vga(int whattosave, struct fb_vgastate* state);, and at
the beginning of save you should do "memset(state, 0, sizeof(*state));"
And fbbase should not be in state variable, as this value is valid
only during duration of save or restore, not outside of them. Pass it
to function which needs it as an explicit argument.
It looks easier to me to make fb_vgastate larger structure with
crt/seq/cmap fields embeded, instead of kmallocing these portions.
Or at least allocate them together depending on 'whattosave' flag,
doing four kmalloc() to allocate about 64 bytes is waste of resources.
And do not use kmalloc() for > 4KB regions, use vmalloc (in
fonts save).
> + state->attr = kmalloc(state->num_attr, GFP_KERNEL);
> + state->crtc = kmalloc(state->num_crtc, GFP_KERNEL);
> + state->gfx = kmalloc(state->num_gfx, GFP_KERNEL);
> + state->seq = kmalloc(state->num_seq, GFP_KERNEL);
...
> + state->vga_font0 = kmalloc(8192 * 8, GFP_KERNEL);
...
> + state->vga_font1 = kmalloc(8192 * 8, GFP_KERNEL);
...
> + state->vga_text = kmalloc(8192 * 4, GFP_KERNEL);
And if my VGA documentation is correct, you are saving random
data into vga_text: first 8192 chars interleaved with
8192 bytes of garbage, plus attributes from chars 8192-16383 interleaved
with 8192 bytes of garbage.
When you program hardware to get access to planes (vga 16 color
graphics mode), every second byte from plane 0 contains character,
and every second byte from plane 1 contains character attribute
(it is that way because of bit A0 selects plane, while A15-A1.0
selects memory address, so odd in memory addresses are unreachable
in vga text mode).
And if you are using standard hardware, then font data live only in
plane 2, plane 3 is unused on VGA hardware in text mode. I think that
you should either save whole 256KB of memory, without deeper understanding,
or you should just save FONT 0 (first 32*256 bytes from plane 2) if you
want to save memory and you know that console was driven by vgacon in
text mode.
Petr Vandrovec
vandrove@vc.cvut.cz
next reply other threads:[~2002-12-04 18:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-04 18:41 Petr Vandrovec [this message]
2002-12-05 1:05 ` [PATCH 1/3: FBDEV: VGA State Save/Restore module Antonino Daplas
-- strict thread matches above, loose matches on Subject: below --
2002-12-04 22:33 Petr Vandrovec
2002-12-05 2:53 ` Antonino Daplas
2002-12-05 2:41 ` Petr Vandrovec
2002-12-05 17:39 ` James Simmons
2002-12-04 17:26 Antonino Daplas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=962842B4859@vcnet.vc.cvut.cz \
--to=vandrove@vc.cvut.cz \
--cc=adaplas@pol.net \
--cc=linux-fbdev-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).