Path: csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod From: Sergey Senozhatsky Newsgroups: linux.kernel Subject: Re: [PATCH v9 3/3] printk: fix double printing with earlycon Date: Sat, 13 May 2017 13:50:01 +0200 Message-ID: References: X-Original-To: Petr Mladek Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=UnBHqCkZ+e3eNtX3yndV7+A+/f5X3WM1CvXiBZu1WTU=; b=tZl5l0JoGqom6Jls13ue4WYMW+NjmBwj4vh8fajcV8vEhbKxRo4cb45pvkWHnquYJR CuhJKKkLnJDwPikcyMyOQOA6sab2kmkKQhNAzg2j+wE6YhG2UNe2mymJKmp+BNgvMAXa x6qEDlGkkqtsOaNYFeCM88GOqEPZp6CYyADWptp5U7a+XJA8lh9/2+BBF0N8Mx4XmBPe 3hHMe1+d9sv56+cUSb/iJ8rwmxADWm9EXJXVMLRPiJnpIjXkhZIlTjy5KuNxVcexVlBd XRbDq8c1+MLhm1i69Ta5eyXJ16wknxFauq+k2UHEjANg/qRM+Vh1u9EsAd8ASwJj6lGU 8Q/Q== X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=UnBHqCkZ+e3eNtX3yndV7+A+/f5X3WM1CvXiBZu1WTU=; b=Fscfp043BpSb134SOVks/jRN/MwtTs49/uRhMJtgC4s/W014Sc6xQeIO4a7zy64If6 IJNSLVhvscO8NXDOMCG0dfEyTOimVmg01RlK2fA6UEpbHOQ1/X8epY5MR8ZLwTP9l9PB kvtDEEzCVpvpshlvKgOpvUTrcoTyxuEEzos/M1Iao2o7m4eocXrmuPM+L8Ogrf6xoue/ 4ZrkHv1KVIcPoi/udJ/NS/Pp67lyHfi3eKIk7q1mxz12xQ+eTJaPcCrff+LwEYP5zOGH UblxAmw+dTT08igBKx+Z+vmt0UIOrjZhtWirjPu9r8nUTiPgRxiJpHpxZe0qnzdF/kbQ 0HoA== X-Gm-Message-State: AODbwcCLRHNfFEz+r/upMixzIPr+/uGcnOBRfcooII/jOpgMrKEu+A/o AV+NL4MWjZo7Dg== X-Received: by 10.98.88.4 with SMTP id m4mr9391003pfb.41.1494676159883; Sat, 13 May 2017 04:49:19 -0700 (PDT) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.8.2 (2017-04-18) Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 76 Organization: linux.* mail to news gateway X-Original-Cc: Sergey Senozhatsky , Aleksey Makarov , Sabrina Dubroca , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Sudeep Holla , Greg Kroah-Hartman , Peter Hurley , Jiri Slaby , Robin Murphy , Steven Rostedt , "Nair, Jayachandran" , Sergey Senozhatsky X-Original-Date: Sat, 13 May 2017 20:48:40 +0900 X-Original-Message-ID: <20170513114840.GA420@tigerII.localdomain> X-Original-References: <20170315102854.1763-1-aleksey.makarov@linaro.org> <20170405202006.18234-1-aleksey.makarov@linaro.org> <20170509082915.GA13236@bistromath.localdomain> <20170511082433.GA421@jagdpanzerIV.localdomain> <20170511084158.GB421@jagdpanzerIV.localdomain> <20170512125729.GO3452@pathway.suse.cz> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1640883 On (05/12/17 14:57), Petr Mladek wrote: [..] > I have tried to reproduce the problem and started kernel with > console=ttyS1 console=ttyS0 in qemu. It created: > > console_cmdline = {{ > .name = "ttyS"; > .index = 1; // from ttyS1 > },{ > .name = "ttyS" > .index = 0; // from ttyS0 > }}; > preferred_console = 1; // ttyuS0; > > > Then register_console() is called twice here. First time > from con_init() that registers: > > static struct console vt_console_driver = { > .name = "tty", > .write = vt_console_print, > .device = vt_console_device, > .unblank = unblank_screen, > .flags = CON_PRINTBUFFER, > .index = -1, > }; > > It does not match and it is not enabled here. > > > 2nd times from univ8250_console_init() that registers: > > static struct console univ8250_console = { > .name = "ttyS", > .write = univ8250_console_write, > .device = uart_console_device, > .setup = univ8250_console_setup, > .match = univ8250_console_match, > .flags = CON_PRINTBUFFER | CON_ANYTIME, > .index = -1, > .data = &serial8250_reg, > }; > > It matches both console_cmdline entries because index = -1. > The first tested is selected. yes, that's what I observed on my host. I didn't try it with qemu, just 86_64. and the behaviour was different. [..] > In fact, it always was kind of random because both init calls are > defined as > > console_initcall(con_init); > console_initcall(univ8250_console_init); > > They are put into special elf section and called from console_init() > the following way: > > call = __con_initcall_start; > while (call < __con_initcall_end) { > (*call)(); > call++; > } > > By other words, the order depends on the linking order which is > kind of weak order enforcement. > > I am not sure if we broke some backward compatibility or actually made > it more predictable in the long term. well, we changed the behaviour. some automated scripts somewhere might get broken. so may be this is the case when "a bug" becomes "a feature". well, just saying. -ss