Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5290873ybe; Tue, 17 Sep 2019 05:57:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjRdZSnhqJsmtG1kBs9CCz0phCBoYXBGjk/VnrmZafPfqYA2X+y6qyA5cuvzE3l5+FYnTx X-Received: by 2002:a17:906:529a:: with SMTP id c26mr4700281ejm.232.1568725035433; Tue, 17 Sep 2019 05:57:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568725035; cv=none; d=google.com; s=arc-20160816; b=m5F3e0ruiT7rhPTha/RRpta+iwFv1mmxIWJIUM0+BET8pBEXBIX0F21QSlxhBdENpK TgvPr3x2VXKkOYJnluhxLya+zaM3MGgsKaILF1iEb/td4LbdbRmaTU+Zqj4u1h9tH4f6 Axq19a1lYAbYScpYWbwqu3ep3S6p5XLvgSPyv4g3VQb3CBCPTimg5uWBPRHXc3ItvklP 9yV/2bNq5NtZrxd58Rn0acqBk8nhRAbzG4AP9aEKMsOinQNYgvxirVo+qndh/SWJteSM sMtD2D14VEsrcXA9dwX/YPbBZzT7jR+p2ywH1nLTN0ye+l8/UkTJnb2+tj0C2es6kv0g Sbfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=68Ag2x+3VHeG35J7CQJtoj1qV0RkmOmyMGfD+8FKo/4=; b=E0GQimrq+mU0/hLy4lvyljvnTdbpcY4dJwqPpaGMPrkMj0wl5MTEnXvkB3XL7PLezM 3mHAJ4N4AflNEeq+U4oU2Tq/8Px5lgpEYQOQLDRbSWIriE2ZkvWv8WFmjiaMXhGUF9aD dSyUDYV56tahVat99lAy8f1+tMAw3f7LUBpgyYQPzUQgKQZk0KDqiiVbx/m0ENGVapUF mlkLTnbgbGOrcF2JS3NzoNQ2Rpum4EmZc6ceUkUSBWVce9HBn21aBAe0pNi6Y1BX9O6J FpIe/gg8uZfJKwHNgbVEkHly82Y1H4f/NOD2cCg8ZwFfmsiPbYYLE8DemIv+vModFNa6 2HYQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c12si1291395edb.394.2019.09.17.05.56.51; Tue, 17 Sep 2019 05:57:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726988AbfIQMwo convert rfc822-to-8bit (ORCPT + 99 others); Tue, 17 Sep 2019 08:52:44 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:38247 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725901AbfIQMwo (ORCPT ); Tue, 17 Sep 2019 08:52:44 -0400 Received: by mail-ot1-f66.google.com with SMTP id e11so1761990otl.5; Tue, 17 Sep 2019 05:52:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=cGu+OKqa8P9FhmcrfusKIEOBVN7wjkZzGzIlcpxnAM4=; b=YDGHOiH8Z2ke//JikJFiTQ4b+CXgil1DYPxcbgdq0fkW34HGDqEwrkiZJPiVsYWIHu 8/ss3Jmsnr3Et0gzx2GCOMuHXT5tPqjCyELSeuzuJ42j3HZuuO7Vi3nWowO7psxK5/oW 1GV73nRMwcjDbCj+7CPfIgTAwfLsGRtpCwTAAZvFbpkAcN0V+A2C82tZnAZ5dqQDHwdM PngDPryYsnZLrqDXhS8iWYVLIvb7tOC1pTlXGe+0ovnOZrainDfkPCo2HdsGp6UnNwOi /8z5ASbhbXjWXwO84ZSkROA+IrsAq4kph4eyb5pygXufmgfwb5pUyyll1KM/EoWRIU07 qMIw== X-Gm-Message-State: APjAAAUOIsG/ZD3xV9QLOI5PG26S7lQBnUeYNY0t1LXU+8T4AqXKUEQ6 bbilXmhC7wi36l4yQS8Llug0NK6t/430rUNQ9us= X-Received: by 2002:a9d:5a06:: with SMTP id v6mr2514884oth.250.1568724762614; Tue, 17 Sep 2019 05:52:42 -0700 (PDT) MIME-Version: 1.0 References: <20190824132846.8589-1-u.kleine-koenig@pengutronix.de> <20190824132846.8589-2-u.kleine-koenig@pengutronix.de> <20190913215809.GA11833@bogus> <20190917101303.t5otztdus7y3ayau@pengutronix.de> <489c90fb-a135-4fd8-ecb9-46404bd3c234@axentia.se> <20190917122530.3xy7sut3xdvzlomj@pengutronix.de> In-Reply-To: <20190917122530.3xy7sut3xdvzlomj@pengutronix.de> From: Geert Uytterhoeven Date: Tue, 17 Sep 2019 14:52:31 +0200 Message-ID: Subject: Re: [PATCH v1 2/2] of: Let of_for_each_phandle fallback to non-negative cell_count To: =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= Cc: Peter Rosin , Rob Herring , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Will Deacon , Joerg Roedel , Linux Kernel Mailing List , Linux IOMMU , "linux-mediatek@lists.infradead.org" , Sascha Hauer , Matthias Brugger , Frank Rowand , Linux ARM , Robin Murphy , Wolfram Sang , Linux I2C , Linux-Renesas Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Uwe, On Tue, Sep 17, 2019 at 2:25 PM Uwe Kleine-König wrote: > On Tue, Sep 17, 2019 at 11:25:46AM +0000, Peter Rosin wrote: > > On 2019-09-17 12:13, Uwe Kleine-König wrote: > > > On Tue, Sep 17, 2019 at 11:40:25AM +0200, Geert Uytterhoeven wrote: > > >> On Fri, Sep 13, 2019 at 11:58 PM Rob Herring wrote: > > >>> On Sat, 24 Aug 2019 15:28:46 +0200, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= wrote: > > >>>> Referencing device tree nodes from a property allows to pass arguments. > > >>>> This is for example used for referencing gpios. This looks as follows: > > >>>> > > >>>> gpio_ctrl: gpio-controller { > > >>>> #gpio-cells = <2> > > >>>> ... > > >>>> } > > >>>> > > >>>> someothernode { > > >>>> gpios = <&gpio_ctrl 5 0 &gpio_ctrl 3 0>; > > >>>> ... > > >>>> } > > >>>> > > >>>> To know the number of arguments this must be either fixed, or the > > >>>> referenced node is checked for a $cells_name (here: "#gpio-cells") > > >>>> property and with this information the start of the second reference can > > >>>> be determined. > > >>>> > > >>>> Currently regulators are referenced with no additional arguments. To > > >>>> allow some optional arguments without having to change all referenced > > >>>> nodes this change introduces a way to specify a default cell_count. So > > >>>> when a phandle is parsed we check for the $cells_name property and use > > >>>> it as before if present. If it is not present we fall back to > > >>>> cells_count if non-negative and only fail if cells_count is smaller than > > >>>> zero. > > >>>> > > >>>> Signed-off-by: Uwe Kleine-König > > >> > > >> This is now commit e42ee61017f58cd9 ("of: Let of_for_each_phandle fallback > > >> to non-negative cell_count") in robh/for-next, which causes a lock-up when > > >> booting a shmobile_defconfig kernel on r8a7791/koelsch: > > >> > > >> rcu: INFO: rcu_sched self-detected stall on CPU > Oh yeah, you're right. I'm a bit disappointed that I didn't spot this > myself :-| > > Untested patch to fix this problem: > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index 2f25d2dfecfa..26f7a21d7187 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -1284,6 +1284,13 @@ int of_phandle_iterator_init(struct of_phandle_iterator *it, > const __be32 *list; > int size; > > + /* > + * one of cell_count or cells_name must be provided to determine the > + * argument length. > + */ > + if (cell_count < 0 && !cells_name) > + return -EINVAL; > + > memset(it, 0, sizeof(*it)); > > list = of_get_property(np, list_name, &size); > @@ -1765,6 +1772,18 @@ int of_count_phandle_with_args(const struct device_node *np, const char *list_na > struct of_phandle_iterator it; > int rc, cur_index = 0; > > + /* If cells_name is NULL we assume an cell_count of 0 */ a cell count > + if (cells_name == NULL) { > + const __be32 *list; > + int size; > + > + list = of_get_property(np, list_name, &size); > + if (!list) > + return -ENOENT; > + > + return size / sizeof(*list); > + } > + > rc = of_phandle_iterator_init(&it, np, list_name, cells_name, -1); > if (rc) > return rc; Thanks, that fixes the boot for me! Tested-by: Geert Uytterhoeven Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds