Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2073782ybb; Sat, 11 Apr 2020 19:53:40 -0700 (PDT) X-Google-Smtp-Source: APiQypKwoiTVL/BWIykFcQ7PacLr8jKWz+k/WDYSH8HtDvX7X6Z06bn+Ee9LbRwg3OIdoLYKJ2bP X-Received: by 2002:a05:620a:1f3:: with SMTP id x19mr10596912qkn.306.1586660019876; Sat, 11 Apr 2020 19:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586660019; cv=none; d=google.com; s=arc-20160816; b=Yliq+0fBtYfE6YuOh7Y+xIOBg9NhNv9B3N6LTi0wesL1l2dAgxDWll83IeYjkZwrcu 7m7AaTsRLsohp3/9EKCJp4N2XfCI8IBgew9VNNhbM+uG3IuqwWLLJbRxdQ3YudXH7OmJ CPfeLG3EKBnOEu1T8TehLPT+zO9HBtqSRTcgC49FzVMFWJPKfgNkr7wGJMAC1Z2wTuNT U0eOFdFu2FIqB5ZNKn9KySmYyHl0+X5h+2mnjniNr1588DQCvVZStkpzKBy/D+s4OKG6 TmtwcLSFPcVIiyms8Ce9vJAQS1KgoEOLiIDelyW4pjvmgquJ7X9oH2yNkffR9kIHzH5u i5WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=VogcAM4f+7ZYGZP3VmVCoYpWE3MtWwpRfqsHtlQY+ws=; b=0kDhBeiUY5RqnIFOgwWE9aZk0hvXEUCsKpvUyNbLrVQvZAuyAf91/Z2KT4ythxAmEw ik57IygqyVnfv+6VpK9/UqZvi+xzIVGOki8AZukTzMQbPc+DA9EytwsEcRKI+aYoV6tv ed2UHeb1CK2Tz0jp6hsKSXA1+1JI651ZXzYWK/XWogcW+U4ywSvKRHOaw4wgIu27OvrT u7FIP8fOCX+jNvXuonB6SzZZwN7d3iHTEGAoQ2lXrQIpCWVxBuhYRxIFKkSU4usXkp5L tXfWg4CWn7k4/8tal1bkDESoYes45Jfi+4wWxkBcUxWk9xNInnVzDq4MDf0fLiuEJoJV jgIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ABKvW/nR"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s5si3663926qtb.246.2020.04.11.19.52.52; Sat, 11 Apr 2020 19:53:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ABKvW/nR"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726708AbgDLCtj (ORCPT + 99 others); Sat, 11 Apr 2020 22:49:39 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:45370 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726108AbgDLCtj (ORCPT ); Sat, 11 Apr 2020 22:49:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586659778; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=VogcAM4f+7ZYGZP3VmVCoYpWE3MtWwpRfqsHtlQY+ws=; b=ABKvW/nRIPaYrJHY508S/C0Hey0yIhO4eklFiMZcWhzITuxTfmExjp1aETVWoSzzxXjtxI E5qQdCzCCnRhEGyngQ697x/BitEQkhfIBoStNovgZZibeTLtovL/m+AE+WOdfnfAqJsD5x 5X4YH/CgfyN48a3cWx5x2U7tbXSMxlo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-415-iwefRy8oOki2qNz0nU7NVA-1; Sat, 11 Apr 2020 22:49:34 -0400 X-MC-Unique: iwefRy8oOki2qNz0nU7NVA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C977A107ACC9; Sun, 12 Apr 2020 02:49:33 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-12-101.pek2.redhat.com [10.72.12.101]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5514CFDE3; Sun, 12 Apr 2020 02:49:31 +0000 (UTC) Date: Sun, 12 Apr 2020 10:49:27 +0800 From: Dave Young To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] efi/earlycon: fix early printk for wider fonts Message-ID: <20200412024927.GA6884@dhcp-128-65.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When I play with terminus fonts I noticed the efi early printk does not work because the earlycon code assumes font width is 8. Here add the code to adapt with larger fonts. Tested with all kinds of kernel built-in fonts on my laptop. Also tested with a local draft patch for 14x28 !bold terminus font. Signed-off-by: Dave Young --- drivers/firmware/efi/earlycon.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- linux-x86.orig/drivers/firmware/efi/earlycon.c +++ linux-x86/drivers/firmware/efi/earlycon.c @@ -114,14 +114,16 @@ static void efi_earlycon_write_char(u32 const u32 color_black = 0x00000000; const u32 color_white = 0x00ffffff; const u8 *src; - u8 s8; - int m; + int m, n, bytes; + u8 x; - src = font->data + c * font->height; - s8 = *(src + h); + bytes = BITS_TO_BYTES(font->width); + src = font->data + c * font->height * bytes + h * bytes; - for (m = 0; m < 8; m++) { - if ((s8 >> (7 - m)) & 1) + for (m = 0; m < font->width; m++) { + n = m % 8; + x = *(src + m / 8); + if ((x >> (7 - n)) & 1) *dst = color_white; else *dst = color_black;