Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp165014ybz; Thu, 30 Apr 2020 18:46:46 -0700 (PDT) X-Google-Smtp-Source: APiQypKiZe6EstT42R/D1GoJSqj3NGtZ+54lXnoIlfX6j8xdf5bppTqBd2Dwd9kqniOi4F/urKjQ X-Received: by 2002:aa7:c34e:: with SMTP id j14mr1619588edr.195.1588297606756; Thu, 30 Apr 2020 18:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588297606; cv=none; d=google.com; s=arc-20160816; b=XikbnSIP5v3cKq3XFkmF7pVRsJWS+oTcw6+IcuenRWvFfkppak79GFNfkjNfIPG0aY dAvfG/InXAJzvQjFjDArg0FljeJ44udRCGwIhltWqqTBtR837TQrz8Ff8KXi+Bzav1En P+Z9UgX2kfUVCQH88jMhYYBBPVItVXU7sYI54sEFRR25BZrQAEvy5PhdMrIDD6Hn37l8 XEZP/aCfgEQfbh1ZXwVlRXv6x57113ASU2DDZ81aHiSIuyHPoTAvdGM5HA+rAehpw60Y C+XKVRCm5qF2yMsp3OZbr/Lkwn9heEzLMlrvesLLMk75qG46Qw8pwSV4s6/aJRUSE1ju gqRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :dkim-signature; bh=BJDB9lPyIL7yqfOmHsy2HCj6CJV5Y/ygJ4a/Yt4ueRw=; b=Y0MHnHQUJFLP9BIVS3UxeTpuTbPY2jSX7jZfOB31vnM7HRP6pnIrU08jQpY8oVWYG0 i2trYyDf6wRFFVLdo37J5ZuXuSdx50lI869ucMKY5ueGpIk2J/7yuiohnwrYIFtwbEm/ QHHgShP+duqu50edH0pkYFtH+Z3AsTZH5U4GpgFOqxr2weOS0MEr3Hua3ELazhZ0hiZh qW7hCLIrWkPmLrsKPow5ng2e1p6vLYoklF2bgAtuxJZycMXj8WdSHJewtIWHfDcEf3Ji 7KHgxp3ZUyTnvQKAuGoEoUnKxzLOdnPfOd6FJOKDKQyuANb1Gwgc8wEI3l/uZjt2WD9w rUFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Tcshg76Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s8si708911edw.484.2020.04.30.18.46.22; Thu, 30 Apr 2020 18:46:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Tcshg76Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728042AbgEABo6 (ORCPT + 99 others); Thu, 30 Apr 2020 21:44:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727114AbgEABo5 (ORCPT ); Thu, 30 Apr 2020 21:44:57 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF7B6C035494; Thu, 30 Apr 2020 18:44:57 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id n24so3120957plp.13; Thu, 30 Apr 2020 18:44:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=BJDB9lPyIL7yqfOmHsy2HCj6CJV5Y/ygJ4a/Yt4ueRw=; b=Tcshg76Y97lKweEKu4Gzgm583bqlkziZ4JStrZoKgao6MtHeAoodWQhMVO/lXjIY2G FvsHOLLcC0UIstahZaZG+KZ1bEgNSTltcuxq5krvhF6cOgx9Rh62+aJTs5Ho+2hC1v/i V/0Q+bgjzZQqIT5kvZzSa/8UWZi1+rWuqj3VP1iNWOL43pzieMbHk4n/WkLOh3uiq6sn VA4Y6GIn4cKd1U2WqH8DlczT3VzTPWI2DaO+ZuGk93UcqyB3SQ/rCq9jOTYNSXV1GJk2 I/N01tnibHm6+a7oRtKOCa1vkElQ/Nxn5qwvm7yJQmzRGlMHW3zA8RMgLEfDq0HeWpOh v2UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=BJDB9lPyIL7yqfOmHsy2HCj6CJV5Y/ygJ4a/Yt4ueRw=; b=nin/uEBjSoD4c/5FEt0TEzvRMtHRD55QWEahE4F6fFHL9zc7BpUdDdXdxLOh5jmxEI E/yWGmXvvtUYFhLHvT6GQzabuokc0uiXgx9c522DhxabeI3ulkirVdQWMD4uhA2GDKNV OASbvmnAnNiOWMMvm7t0FvBl716Z8rLwGY9wJN0aTrNXCOB4tOOPY0B3Ho6+Jt/9M8+e AaCTJuO6XtbsGcqOfrbhQ/oa+B1k26HmndzPcq++EithKgm/hj4fc/OLM6o/KzVl3czt wGgWtBZo7094XXFoF4/9CihIsymztzxx1oN1dGOMuPCknhzuow0k9PErgaXnrKQ/gR8k 1h4Q== X-Gm-Message-State: AGi0Pub5KrAfzvy+PzKq7DYvcqfEOnOFn9b+d/H3SDRS87Kys48B+4UY ZA9Pv0w7pHUREBLSMZOYDxA= X-Received: by 2002:a17:90a:2606:: with SMTP id l6mr1770330pje.188.1588297497099; Thu, 30 Apr 2020 18:44:57 -0700 (PDT) Received: from localhost (146.85.30.125.dy.iij4u.or.jp. [125.30.85.146]) by smtp.gmail.com with ESMTPSA id d18sm850855pfq.177.2020.04.30.18.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 18:44:56 -0700 (PDT) From: Sergey Senozhatsky X-Google-Original-From: Sergey Senozhatsky Date: Fri, 1 May 2020 10:44:54 +0900 To: Alper Nebi Yasak Cc: Greg Kroah-Hartman , Jiri Slaby , Petr Mladek , Sergey Senozhatsky , linux-serial@vger.kernel.org, Steven Rostedt , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Morton , Andy Shevchenko , Arvind Sankar , Benjamin Herrenschmidt , "David S. Miller" , Feng Tang Subject: Re: [RFC PATCH v2 1/3] printk: Add function to set console to preferred console's driver Message-ID: <20200501014454.GB288759@jagdpanzerIV.localdomain> References: <20200430161438.17640-1-alpernebiyasak@gmail.com> <20200430161438.17640-2-alpernebiyasak@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200430161438.17640-2-alpernebiyasak@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (20/04/30 19:14), Alper Nebi Yasak wrote: > Currently, add_preferred_console sets a preferred console, but doesn't > actually change /dev/console to match it. That part is handled within > register_device, where a newly registered console driver will be set as > /dev/console if it matches the preferred console. > > However, if the relevant driver is already registered, the only way to > set it as /dev/console is by un-registering and re-registering it. Hmm. Preferred console selection is very fragile, there are too many setups and workarounds that even minor tweaks introduce regressions oftentimes. We have, by the way, a pending patchset which changes the same are - preferred console selection. git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk.git for-5.7-preferred-console [..] > An example is the xenfb_make_preferred_console() function: > > console_lock(); > for_each_console(c) { > if (!strcmp(c->name, "tty") && c->index == 0) > break; > } > console_unlock(); > if (c) { > unregister_console(c); > c->flags |= CON_CONSDEV; > c->flags &= ~CON_PRINTBUFFER; /* don't print again */ > register_console(c); > } I didn't know about this code. > The code above was introduced in commit 9e124fe16ff2 ("xen: Enable > console tty by default in domU if it's not a dummy"). In short, it's aim > is to set VT as the preferred console only after a working framebuffer > is registered and thus VT is not the dummy device. > > This patch introduces an update_console_to_preferred function that > handles the necessary /dev/console change. With this change, the example > above can be replaced with: > > console_lock(); > add_preferred_console("tty", 0, NULL); > update_console_to_preferred(); > console_unlock(); > > More importantly, these two calls can be moved to vt.c in order to bump > its priority when a non-dummy backend for it is introduced, solving that > problem in general. Let me take a look over the weekend. -ss