From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032820AbdAJQJy (ORCPT ); Tue, 10 Jan 2017 11:09:54 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:57286 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1765913AbdAJQJw (ORCPT ); Tue, 10 Jan 2017 11:09:52 -0500 X-AuditID: b6c32a3c-f79826d000002380-da-5875074de8e0 From: Bartlomiej Zolnierkiewicz To: Takashi Iwai Cc: Tomi Valkeinen , Greg Kroah-Hartman , Jiri Slaby , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton Subject: Re: [PATCH] fbcon: Fix vc attr at deinit Date: Tue, 10 Jan 2017 17:09:43 +0100 Message-id: <1500556.Az9hZml9Y8@amdc3058> User-Agent: KMail/4.13.3 (Linux/3.13.0-96-generic; KDE/4.13.3; x86_64; ; ) In-reply-to: MIME-version: 1.0 Content-transfer-encoding: 7Bit Content-type: text/plain; charset=us-ascii X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOKsWRmVeSWpSXmKPExsWy7bCmga4ve2mEwcxzYhZz1q9hs2hevJ7N 4vPvXawWJ/o+sFpc3jWHzeLl5jdMFuvn32JzYPc4MeM3i8f+uWvYPc4sOMLusfl0tcfxG9uZ PD5vkgtgi+KySUnNySxLLdK3S+DKeLOohbXgqE3F40krmBoY1+l3MXJySAiYSLTfaGKGsMUk Ltxbz9bFyMUhJLCDUeLVlPPsEE47k8TeF2uBHA6wjg33/SHicxgl7h1pYIRwvjJKbHy3kwlk FJuAlcTE9lWMILaIgILEm1f3wIqYBZ4wSnxbsRIsISxgKPH/1RR2EJtFQFWi9/hnVhCbV0BT 4teqxWCDRAW8JLbsawezOQW0Jc69P8AOUSMo8WPyPRYQm1lAXmLf/qmsELaOxNlj68CWSQhs Ype4vL+RDeJsWYlNB6D+dJGYsXohE4QtLPHq+BZ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FZWpRblxxeV5qQWH2I0BfpwIrOUaHI+MBHklcQbmpibmBsbWJhbWpoYKYnz Ns5+Fi4kkJ5YkpqdmlqQWgTTx8TBKdXA2LBWWUJlG8NHGY3zulNuKnR8kc2Z9/Tl58Tosyo7 +GuLxJtyzfaqpB2an+A2Z6mAuVRKQvou2ZRLHZWPOSuFN18wvbg+MjD0JlvR5pbf/I9kVZK4 TtZe9W/p48jRM2N5z+NXwjRvfsDy/ZsXPKhNb6ub9sDS5j+P5M/NHAptfatNfxYd/hurxFKc kWioxVxUnAgAxfO4/MwCAAA= X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170110160948epcas1p17d60f65a1abd3782c1968aa531bcab00 X-Msg-Generator: CA X-Sender-IP: 203.254.230.26 X-Local-Sender: =?UTF-8?B?QmFydGxvbWllaiBab2xuaWVya2lld2ljehtTUlBPTC1LZXJu?= =?UTF-8?B?ZWwgKFRQKRvsgrzshLHsoITsnpAbU2VuaW9yIFNvZnR3YXJlIEVuZ2luZWVy?= X-Global-Sender: =?UTF-8?B?QmFydGxvbWllaiBab2xuaWVya2lld2ljehtTUlBPTC1LZXJu?= =?UTF-8?B?ZWwgKFRQKRtTYW1zdW5nIEVsZWN0cm9uaWNzG1NlbmlvciBTb2Z0d2FyZSBF?= =?UTF-8?B?bmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDAyQ0QwMjczOTI=?= CMS-TYPE: 101P X-HopCount: 7 X-CMS-RootMailID: 20170110154805epcas1p27230b321e48ecef42e623fbcdbe5151e X-RootMTR: 20170110154805epcas1p27230b321e48ecef42e623fbcdbe5151e References: <20170103150322.10350-1-tiwai@suse.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tuesday, January 10, 2017 04:47:30 PM Takashi Iwai wrote: > On Thu, 05 Jan 2017 13:26:07 +0100, > Tomi Valkeinen wrote: > > > > On 04/01/17 15:50, Takashi Iwai wrote: > > > On Tue, 03 Jan 2017 16:03:22 +0100, > > > Takashi Iwai wrote: > > >> > > >> fbcon can deal with vc_hi_font_mask (the upper 256 chars) and adjust > > >> the vc attrs dynamically when vc_hi_font_mask is changed at > > >> fbcon_init(). When the vc_hi_font_mask is set, it remaps the attrs in > > >> the existing console buffer with one bit shift up (for 9 bits), while > > >> it remaps with one bit shift down (for 8 bits) when the value is > > >> cleared. It works fine as long as the font gets updated after fbcon > > >> was initialized. > > >> > > >> However, we hit a bizarre problem when the console is switched to > > >> another fb driver (typically from vesafb or efifb to drmfb). At > > >> switching to the new fb driver, we temporarily rebind the console to > > >> the dummy console, then rebind to the new driver. During the > > >> switching, we leave the modified attrs as is. Thus, the new fbcon > > >> takes over the old buffer as if it were to contain 8 bits chars > > >> (although the attrs are still shifted for 9 bits), and effectively > > >> this results in the yellow color texts instead of the original white > > >> color, as found in the bugzilla entry below. > > >> > > >> An easy fix for this is to re-adjust the attrs before leaving the > > >> fbcon at con_deinit callback. Since the code to adjust the attrs is > > >> already present in the current fbcon code, in this patch, we simply > > >> factor out the relevant code, and call it from fbcon_deinit(). > > >> > > >> Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1000619 > > >> Signed-off-by: Takashi Iwai > > > > > > Actually not only checkpatch but also I can't find the proper > > > maintainer for this... > > > > > > Tomi, could you check and take if it's OK? > > > > > > Ideally, this kind of stuff should have been in rather vt side, I > > > suppose. But since the code is already present in fbcon, it's easier > > > to reuse it as a fix for now. > > > > I'm not fbdev maintainer anymore. Added Bartlomiej (and Andrew). > > Bartlomiej (or Andrew), could you check the patch? In case you missed > it, I attach it below again. Thanks, it is on TODO (should be processed till the end of the week). Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics > thanks, > > Takashi > > -- 8< -- > From: Takashi Iwai > Subject: [PATCH] fbcon: Fix vc attr at deinit > > fbcon can deal with vc_hi_font_mask (the upper 256 chars) and adjust > the vc attrs dynamically when vc_hi_font_mask is changed at > fbcon_init(). When the vc_hi_font_mask is set, it remaps the attrs in > the existing console buffer with one bit shift up (for 9 bits), while > it remaps with one bit shift down (for 8 bits) when the value is > cleared. It works fine as long as the font gets updated after fbcon > was initialized. > > However, we hit a bizarre problem when the console is switched to > another fb driver (typically from vesafb or efifb to drmfb). At > switching to the new fb driver, we temporarily rebind the console to > the dummy console, then rebind to the new driver. During the > switching, we leave the modified attrs as is. Thus, the new fbcon > takes over the old buffer as if it were to contain 8 bits chars > (although the attrs are still shifted for 9 bits), and effectively > this results in the yellow color texts instead of the original white > color, as found in the bugzilla entry below. > > An easy fix for this is to re-adjust the attrs before leaving the > fbcon at con_deinit callback. Since the code to adjust the attrs is > already present in the current fbcon code, in this patch, we simply > factor out the relevant code, and call it from fbcon_deinit(). > > Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1000619 > Signed-off-by: Takashi Iwai > --- > drivers/video/console/fbcon.c | 67 ++++++++++++++++++++++++++----------------- > 1 file changed, 40 insertions(+), 27 deletions(-) > > diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c > index a44f5627b82a..f4daadff8a6c 100644 > --- a/drivers/video/console/fbcon.c > +++ b/drivers/video/console/fbcon.c > @@ -1165,6 +1165,8 @@ static void fbcon_free_font(struct display *p, bool freefont) > p->userfont = 0; > } > > +static void set_vc_hi_font(struct vc_data *vc, bool set); > + > static void fbcon_deinit(struct vc_data *vc) > { > struct display *p = &fb_display[vc->vc_num]; > @@ -1200,6 +1202,9 @@ static void fbcon_deinit(struct vc_data *vc) > if (free_font) > vc->vc_font.data = NULL; > > + if (vc->vc_hi_font_mask) > + set_vc_hi_font(vc, false); > + > if (!con_is_bound(&fb_con)) > fbcon_exit(); > > @@ -2436,32 +2441,10 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font) > return 0; > } > > -static int fbcon_do_set_font(struct vc_data *vc, int w, int h, > - const u8 * data, int userfont) > +/* set/clear vc_hi_font_mask and update vc attrs accordingly */ > +static void set_vc_hi_font(struct vc_data *vc, bool set) > { > - struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; > - struct fbcon_ops *ops = info->fbcon_par; > - struct display *p = &fb_display[vc->vc_num]; > - int resize; > - int cnt; > - char *old_data = NULL; > - > - if (con_is_visible(vc) && softback_lines) > - fbcon_set_origin(vc); > - > - resize = (w != vc->vc_font.width) || (h != vc->vc_font.height); > - if (p->userfont) > - old_data = vc->vc_font.data; > - if (userfont) > - cnt = FNTCHARCNT(data); > - else > - cnt = 256; > - vc->vc_font.data = (void *)(p->fontdata = data); > - if ((p->userfont = userfont)) > - REFCOUNT(data)++; > - vc->vc_font.width = w; > - vc->vc_font.height = h; > - if (vc->vc_hi_font_mask && cnt == 256) { > + if (!set) { > vc->vc_hi_font_mask = 0; > if (vc->vc_can_do_color) { > vc->vc_complement_mask >>= 1; > @@ -2484,7 +2467,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, > ((c & 0xfe00) >> 1) | (c & 0xff); > vc->vc_attr >>= 1; > } > - } else if (!vc->vc_hi_font_mask && cnt == 512) { > + } else { > vc->vc_hi_font_mask = 0x100; > if (vc->vc_can_do_color) { > vc->vc_complement_mask <<= 1; > @@ -2516,8 +2499,38 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, > } else > vc->vc_video_erase_char = c & ~0x100; > } > - > } > +} > + > +static int fbcon_do_set_font(struct vc_data *vc, int w, int h, > + const u8 * data, int userfont) > +{ > + struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; > + struct fbcon_ops *ops = info->fbcon_par; > + struct display *p = &fb_display[vc->vc_num]; > + int resize; > + int cnt; > + char *old_data = NULL; > + > + if (con_is_visible(vc) && softback_lines) > + fbcon_set_origin(vc); > + > + resize = (w != vc->vc_font.width) || (h != vc->vc_font.height); > + if (p->userfont) > + old_data = vc->vc_font.data; > + if (userfont) > + cnt = FNTCHARCNT(data); > + else > + cnt = 256; > + vc->vc_font.data = (void *)(p->fontdata = data); > + if ((p->userfont = userfont)) > + REFCOUNT(data)++; > + vc->vc_font.width = w; > + vc->vc_font.height = h; > + if (vc->vc_hi_font_mask && cnt == 256) > + set_vc_hi_font(vc, false); > + else if (!vc->vc_hi_font_mask && cnt == 512) > + set_vc_hi_font(vc, true); > > if (resize) { > int cols, rows;