From patchwork Tue Nov 25 14:35:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 5380001 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 196749F3D0 for ; Tue, 25 Nov 2014 14:37:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F3AA20142 for ; Tue, 25 Nov 2014 14:37:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1A2892013D for ; Tue, 25 Nov 2014 14:37:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XtHDN-0001S9-Ao; Tue, 25 Nov 2014 14:35:37 +0000 Received: from mail-wi0-f171.google.com ([209.85.212.171]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XtHDI-0001Gx-TJ for linux-arm-kernel@lists.infradead.org; Tue, 25 Nov 2014 14:35:33 +0000 Received: by mail-wi0-f171.google.com with SMTP id bs8so9317630wib.10 for ; Tue, 25 Nov 2014 06:35:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=Wj7abrdq1p7bwNE0NtIjJk4yts+HZAYndrLUFq6It4I=; b=goHDpaEiiRRmxpSmKkMk7lvuc1XOUtk6ahTc0ant9fO90hD52EQ21eoguM2SFAQB66 tGXX+wKBWwXgAnV0SEm1abVR6e7468BMNBtY9eja1lxllqZ2AIEBSJ/HSV4sFaW3sB3b nWtJIIo9AOPWS+9nhD96Chp/QNql9LDjWJmShspxcTETl+zZ4jqY1go4PyEgGBR9a1GE VTuiaSDUaRu5lvEmc1kHRUb3qO1reFLT4BCYwcYajLnZrX7BygZ4a7Uqs7FZQbugsP+4 h/luFE0C3FBHpF+9YkgkpQ6mPK+37ftEIOnNWUQ5ySu5WN2icUDEliz0SJfHcRDNlkYK UFzg== X-Gm-Message-State: ALoCoQlYRoweEeiY8HJJKU/5EfWOehPLoou937X6iAHazloDrpmWLr5Ua7DQUuOEYRAipYbAh61N X-Received: by 10.180.187.67 with SMTP id fq3mr31087604wic.37.1416926103286; Tue, 25 Nov 2014 06:35:03 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by mx.google.com with ESMTPSA id rx8sm2133522wjb.30.2014.11.25.06.35.02 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 25 Nov 2014 06:35:02 -0800 (PST) Date: Tue, 25 Nov 2014 14:35:00 +0000 From: Leif Lindholm To: Ian Campbell Subject: Re: [PATCH] of: support passing console options with stdout-path Message-ID: <20141125143500.GE2361@bivouac.eciton.net> References: <1416867838-18652-1-git-send-email-leif.lindholm@linaro.org> <20141125103504.GA21525@leverpostej> <20141125111724.GC2361@bivouac.eciton.net> <1416917249.32327.15.camel@debian.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1416917249.32327.15.camel@debian.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141125_063533_098154_4866FAA0 X-CRM114-Status: GOOD ( 27.14 ) X-Spam-Score: -0.7 (/) Cc: Mark Rutland , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "robh+dt@kernel.org" , "grant.likely@linaro.org" , "plagnioj@jcrosoft.com" , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Nov 25, 2014 at 12:07:29PM +0000, Ian Campbell wrote: > My concern is that this is Linux specific, other OSes may have different > ideas about how stdout options should be formatted within this property. > (At least I don't know of any standardisation of the 115200n8 thing -- > I'd love to be corrected!) > > If I were a firmware author I'd be wary of specifying a stdout-path with > a Linux specific suffix. > Search ePAPR for baud it seems that the generic serial binding includes > a current-speed property in 6.2.1.2. It then goes on a bit ambiguously > to talk about the NS16550 in 6.2.2 but I think 6.2.1.2 was intended to > be generic. No mention of stop-bits/parity etc though, they are assumed > to be set already I think > > One thought I had was to define a dt-stdout "pseudo-console" so that > console=dt-stdout,115200n8 or something could be used. I'll wait for others to comment on the above. > Anyway I applied your patch to v3.18-rc5 and ran it on a Mustang and it > didn't work for some reason. I'm using: > > fdt set /chosen stdout-path "/soc/serial@1c020000:115200" > setenv bootargs "earlycon=uart8250,mmio32,0x1c020000 root=/dev/sda3 rw debug" > > So I get earlycon but then no proper console. Removing earlycon just > makes that stop working. Right, so having debugged this a bit offline, I'm amazed I booted anything at all, given how badly I broke path scanning... Please ignore previous version - a fixed one follows: / Leif From aef87fd958902afe881720286d525e10997462b8 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 24 Nov 2014 22:23:58 +0000 Subject: [PATCH] of: support passing console options with stdout-path Support specifying console options (like with console=ttyXN,) by appending them to the stdout-path property after a separating ':'. Example: stdout-path = "uart0:115200"; This patch also modifies of_find_node_by_path() to match only the portion of the path before a ':'. Signed-off-by: Leif Lindholm --- drivers/of/base.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 3823edf..ecd6290 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -37,6 +37,7 @@ EXPORT_SYMBOL(of_allnodes); struct device_node *of_chosen; struct device_node *of_aliases; struct device_node *of_stdout; +static char *of_stdout_options; struct kset *of_kset; @@ -699,10 +700,15 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent, { struct device_node *child; int len = strchrnul(path, '/') - path; + int term; if (!len) return NULL; + term = strchrnul(path, ':') - path; + if (term < len) + len = term; + __for_each_child_of_node(parent, child) { const char *name = strrchr(child->full_name, '/'); if (WARN(!name, "malformed device_node %s\n", child->full_name)) @@ -742,11 +748,16 @@ struct device_node *of_find_node_by_path(const char *path) if (*path != '/') { char *p = strchrnul(path, '/'); int len = p - path; + int term; /* of_aliases must not be NULL */ if (!of_aliases) return NULL; + term = strchrnul(path, ':') - path; + if (term < len) + len = term; + for_each_property_of_node(of_aliases, pp) { if (strlen(pp->name) == len && !strncmp(pp->name, path, len)) { np = of_find_node_by_path(pp->value); @@ -1830,8 +1841,12 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)) name = of_get_property(of_chosen, "linux,stdout-path", NULL); if (IS_ENABLED(CONFIG_PPC) && !name) name = of_get_property(of_aliases, "stdout", NULL); - if (name) + if (name) { of_stdout = of_find_node_by_path(name); + of_stdout_options = strchr(name, ':'); + if (of_stdout_options != NULL) + of_stdout_options++; + } } if (!of_aliases) @@ -1957,7 +1972,7 @@ bool of_console_check(struct device_node *dn, char *name, int index) { if (!dn || dn != of_stdout || console_set_on_cmdline) return false; - return !add_preferred_console(name, index, NULL); + return !add_preferred_console(name, index, of_stdout_options); } EXPORT_SYMBOL_GPL(of_console_check);