Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4249222imm; Tue, 11 Sep 2018 09:03:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbfeEE6VZUoZHLOSPZhWutamasXTBlbdmVB+Qr81k98CQ3nGEcdBz7ZiOLxBsOq7DQ+RUwo X-Received: by 2002:a17:902:7d87:: with SMTP id a7-v6mr28545178plm.103.1536681804077; Tue, 11 Sep 2018 09:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536681804; cv=none; d=google.com; s=arc-20160816; b=nFi2BehubcvplBO22fkRHoJS2un6ykUh5IKquRyUGQh5jl2HTzQYquglkMeHx4rEK6 /RF9iuufx/NBQzzSAqERQoNxj2u2H3/eRCuzIArNpYVS4L4jDphwM3Zv6yvNqrzuYJOx dajCycuy6PoomWJ/q8mTjzjd8OaPxgCPk3Fzh7JFX9W57mVVHNj0Mrn6t+m95PWzNU+t p40oJf4PU6XUUyzVClqiw7m27CVVJyHugBg6EV1JWcm9wCrh35/SzmlZtgy4+/m1I0sG FMuvmkcd0UGRvBzMuG6mGfgbJ9FdmxNuP8KdCHlnDqF5N9sVSLi89Wfi2hJo0DfQmahj 7TjQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Z8un5poNynW9nk3OSiZNF95fwbQEXI2dh5fivhzcI6Q=; b=lHg4CPelosjeL6HTU11bHRQT8sTpeXcdHmf9A9PF+l2ChxOWiO7wvxM0oi7w5hhlrI ZZw4tvDYiPpqF1UFrazNBp8PlJhH6MNIc1Jr7MkuLn86oLStxO2Ao7rf94saHnz7uzkD 9HYTzlC1N13EwaWtvJjS4rGzBA91N5frYi0kP5TWfpM3NwfHSXAlZr7B/rv8YS1+xTnB VWZsaW6NkoqQk5/Z5EqgsH1pzdrC6gSixFJ59rEv7rfOQqZGvxeoFBwvFjJzchyg7NTG vvG1YapqNiQHlHVOOGTin3HqJOtOvt2I/cEh7c3VJ1R+i/GY5/T0YiF9T+PaWsKgBbtD ciAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YDr9wjH5; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 136-v6si21883594pfc.187.2018.09.11.09.03.02; Tue, 11 Sep 2018 09:03:24 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YDr9wjH5; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727419AbeIKVCo (ORCPT + 99 others); Tue, 11 Sep 2018 17:02:44 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:33151 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726689AbeIKVCo (ORCPT ); Tue, 11 Sep 2018 17:02:44 -0400 Received: by mail-oi0-f66.google.com with SMTP id 8-v6so48223177oip.0; Tue, 11 Sep 2018 09:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Z8un5poNynW9nk3OSiZNF95fwbQEXI2dh5fivhzcI6Q=; b=YDr9wjH5/EbyJlwpN6A0MoE8FmX1m+GQQZ5kFnbHuYpGOYu2SCRCIaB/mLoa8pcOKu TEMz52lGR+PrH0eopfLUOlWNJ3h1LSAL83F9mKcvKlpK14Y47Ks6iOIw/3zvskxB7GhK 0F05ZMHikzH/3GZ5+qQZGCCInpJRvrAz8z8IYDy/63qTSe8NjilTHtWgi3CbWES5Tyd1 E961Pw7E3cJfUeNAn+FunrMAkZseMiCag6/NDtqi7ZaUmpQnlNqy+AQ76UOIepqNclOU QtGVCYJKKbz8OrU/NbAvtm5Bhar/kJf1Rqcj+3aBcCjaiH4Tai3d89bzopcBrmCEZu0t 0RMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Z8un5poNynW9nk3OSiZNF95fwbQEXI2dh5fivhzcI6Q=; b=C0710ethZdgtrTHiZFnzQJU9Ii9wGwZYqsJ4gFNvmPxhERTuMg5ZsVo8sP3A/mupaW O52eyERxANN6c77Mej6gjaI4gODwL0koF2S8ZsY+mSXDG+eXDI1DZ1irSI/iJrwMlG0J MeSRuQihSMiybWnDnA07YNV/yvZMhmVoDATaVApBQX4CBLr5XHiRQ2g3NHfUMm9RjIT6 WfxzMU7fx6EKiI5QJyE9uLlAtqMUMRsn0l21DSZHZEBE7kfbG5VmYZqBb/3u/dcTxbs6 YU3GT/HXBe67GKriG26gjmue0sr9EMMGcHeeER7f7v2wln1zuOu4NqonyuyPT/jTbX6S smKg== X-Gm-Message-State: APzg51DtXBdJzVO51ULoKhqIdQwbPfy6FJZG0I/LRMgnwu4sL1Lmee5f joHXvG8+1u+yy4DTxjVpsDA= X-Received: by 2002:aca:305:: with SMTP id 5-v6mr25393388oid.84.1536681766593; Tue, 11 Sep 2018 09:02:46 -0700 (PDT) Received: from [192.168.0.113] (47-208-214-43.trckcmtc01.res.dyn.suddenlink.net. [47.208.214.43]) by smtp.gmail.com with ESMTPSA id q124-v6sm19932760oif.8.2018.09.11.09.02.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 09:02:46 -0700 (PDT) Subject: Re: [PATCH] of: fix phandle cache creation for DTs with no phandles To: Rob Herring , Finn Thain , Stan Johnson , Benjamin Herrenschmidt Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, stable@vger.kernel.org References: <20180911145607.6009-1-robh@kernel.org> From: Frank Rowand Message-ID: <0ecd44b5-3faa-6b30-d47f-dd06efbcadd6@gmail.com> Date: Tue, 11 Sep 2018 09:02:43 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180911145607.6009-1-robh@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/11/18 07:56, Rob Herring wrote: > With commit 0b3ce78e90fc ("of: cache phandle nodes to reduce cost of > of_find_node_by_phandle()"), a G3 PowerMac fails to boot. The root cause > is the DT for this system has no phandle properties when booted with > BootX. of_populate_phandle_cache() does not handle the case of no > phandles correctly. The problem is roundup_pow_of_two() for 0 is > undefined. The implementation subtracts 1 underflowing and then things > are in the weeds. > > Fixes: 0b3ce78e90fc ("of: cache phandle nodes to reduce cost of of_find_node_by_phandle()") > Cc: stable@vger.kernel.org # 4.17+ > Reported-by: Finn Thain > Tested-by: Stan Johnson > Cc: Frank Rowand > Cc: Benjamin Herrenschmidt > Signed-off-by: Rob Herring > --- > Here's a formal patch of what Stan tested. Will send to Linus this week. > > Rob > > drivers/of/base.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index a055cd1ef96d..17ae594b7014 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -140,6 +140,9 @@ void of_populate_phandle_cache(void) > if (np->phandle && np->phandle != OF_PHANDLE_ILLEGAL) > phandles++; > > + if (!phandles) > + goto out; > + > cache_entries = roundup_pow_of_two(phandles); > phandle_cache_mask = cache_entries - 1; > > Reviewed-by: Frank Rowand