From patchwork Mon Mar 16 18:19:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 45865 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A82B221547 for ; Mon, 16 Mar 2015 18:20:09 +0000 (UTC) Received: by widex7 with SMTP id ex7sf9387072wid.2 for ; Mon, 16 Mar 2015 11:20:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:user-agent:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=qfGSztIu/k8taEnbrjXvedHZ8cSntF1t+ysbw7a/qTE=; b=k42PDvrooGPwg6l3RNSaOG9YS7b9ftDdyhREZtDdPonu8EO1sbtuqtjOsrIte/rWmV rvzxpwFbDnpd9SJeNVIzxos7JpRT+mCZjwBQI7sTPh6eaSOv537YiGRMp2J1yGhmp8vm 9ad/p99iDVHeTd+kR6V7lavFYsS1VNkXsDdcgWa804y5VEU5YdosvhBDcD0ILe8U0A/L FSLILfPFzB5RP/8s+ZuD/9uGWofDqBlwkKu3GKzpuj3K4d6CtT9FMu7+VQDzfutV+5GZ x5pRX4xudMkVUwbFwr+5+33MjPPwyI5flQIxLxxYUyRSbYU8npczYauZgS6UawLRdsjL Mx3Q== X-Gm-Message-State: ALoCoQnuvaJ0fexz5fMFgjnJR1oK7xM0LNQ89C2cQ2KxbogW1Ub6zHY8OLMmo4M5PPzn4Kd4Ryz9 X-Received: by 10.112.35.135 with SMTP id h7mr9297737lbj.23.1426530008597; Mon, 16 Mar 2015 11:20:08 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.10.132 with SMTP id i4ls677231lab.25.gmail; Mon, 16 Mar 2015 11:20:08 -0700 (PDT) X-Received: by 10.152.36.138 with SMTP id q10mr55730169laj.113.1426530008446; Mon, 16 Mar 2015 11:20:08 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id cy2si8714793lac.174.2015.03.16.11.20.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Mar 2015 11:20:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by ladw1 with SMTP id w1so47382201lad.0 for ; Mon, 16 Mar 2015 11:20:08 -0700 (PDT) X-Received: by 10.112.185.66 with SMTP id fa2mr55409284lbc.117.1426530008151; Mon, 16 Mar 2015 11:20:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp16887lbj; Mon, 16 Mar 2015 11:20:07 -0700 (PDT) X-Received: by 10.50.79.161 with SMTP id k1mr111379303igx.14.1426530006453; Mon, 16 Mar 2015 11:20:06 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c5si24057722pas.157.2015.03.16.11.20.05; Mon, 16 Mar 2015 11:20:06 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932940AbbCPSUE (ORCPT + 5 others); Mon, 16 Mar 2015 14:20:04 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:38167 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932524AbbCPSUD (ORCPT ); Mon, 16 Mar 2015 14:20:03 -0400 Received: by wifj2 with SMTP id j2so50865219wif.1 for ; Mon, 16 Mar 2015 11:20:01 -0700 (PDT) X-Received: by 10.194.175.137 with SMTP id ca9mr61648961wjc.67.1426530001327; Mon, 16 Mar 2015 11:20:01 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by mx.google.com with ESMTPSA id n6sm16483478wjy.8.2015.03.16.11.19.59 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 16 Mar 2015 11:20:00 -0700 (PDT) Date: Mon, 16 Mar 2015 18:19:57 +0000 From: Leif Lindholm To: Hans de Goede Cc: Grant Likely , Rob Herring , Greg Kroah-Hartman , stable , devicetree@vger.kernel.org Subject: Re: [REGRESSION stable] "of: fix handling of '/' in options for of_find_node_by_path()" breaks stdout-path Message-ID: <20150316181957.GJ4278@bivouac.eciton.net> References: <5506FC72.80800@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5506FC72.80800@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: leif.lindholm@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Hi Hans, On Mon, Mar 16, 2015 at 04:53:22PM +0100, Hans de Goede wrote: > While updating my local working tree to 4.0-rc4 this morning I noticed that I no longer > got any console (neither video output not serial console) on an Allwinner A20 ARM > board. > > This is caused by: > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/of?id=106937e8ccdcf0f4b95fbf0fe9abd42766cade33 > > Reverting this commit fixes the serial console being gone for me. Sorry about that. > After this there still is an issue that tty0 no longer is seen as console, where it > used to be properly used as console in 3.19, I'll investigate that further and send > a separate mail about this. > > Greg, this commit has a: "Cc: # 3.19" please do not apply > this commit to stable! > > u-boot sets stdout-path to this value on the board in question: > "/soc@01c00000/serial@01c28000:115200" > > Looking at the first hunk of the patch in question, the problem is obvious: > > @@ -714,16 +714,17 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent, > const char *path) > { > struct device_node *child; > - int len = strchrnul(path, '/') - path; > - int term; > + int len; > + const char *end; > + end = strchr(path, ':'); > + if (!end) > + end = strchrnul(path, '/'); > + > + len = end - path; > 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)) > > The new code to determine len will match (when starting at root) the name of > all child nodes against: "soc@01c00000/serial@01c28000" as it checks for > the ":" first and then uses everything before it. Where as the old code > would match against: "soc@01c00000" which is the correct thing to do. > > The best fix I can come up with is to check for both ":" and "/" and use > the earlier one as end to calculate the length. I've not coded this out / > tested this due to -ENOTIME. Note that I've also not audited the rest of > the patch for similar issues. > > I will happily test any patches to fix this. Can you give this one a try for the first part of your problem? And if you're happy with that, I can revert the previous version and send a new combined fix. Rob/Grant: am I OK to assume the existence of the phandle-tests subnode for my unrelated test? / Leif >From cbb150ddd277e5fe1c109e6a675f075f0611f71d Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 16 Mar 2015 17:58:22 +0000 Subject: [PATCH] of: fix regression in of_find_node_opts_by_path() This fixes a regression for dealing with paths that contain both a ':' option separator and a '/' in the path preceding it. And adds a test case to prove it. Fixes: 106937e8ccdc ("of: fix handling of '/' in options for of_find_node_by_path()") Reported-by: Hans de Goede Signed-off-by: Leif Lindholm --- drivers/of/base.c | 10 ++++------ drivers/of/unittest.c | 5 +++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index adb8764..2ee7265 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -715,13 +715,11 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent, { struct device_node *child; int len; - const char *end; + const char *p1, *p2; - end = strchr(path, ':'); - if (!end) - end = strchrnul(path, '/'); - - len = end - path; + p1 = strchrnul(path, ':'); + p2 = strchrnul(path, '/'); + len = (p1 < p2 ? p1 : p2) - path; if (!len) return NULL; diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index aba8946..8d94349 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -97,6 +97,11 @@ static void __init of_selftest_find_node_by_name(void) "option path test, subcase #1 failed\n"); of_node_put(np); + np = of_find_node_opts_by_path("/testcase-data/phandle-tests:test/option", &options); + selftest(np && !strcmp("test/option", options), + "option path test, subcase #2 failed\n"); + of_node_put(np); + np = of_find_node_opts_by_path("/testcase-data:testoption", NULL); selftest(np, "NULL option path test failed\n"); of_node_put(np);