Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp211760lqb; Tue, 4 Jun 2024 09:08:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWkDAUkH4wAt66euvG0UYB7jYMeL6hY02L2Id0w1aA0Ng7OjXG0SeUTm+wrmjkrp8Hs7x2y+ZRmiCSl5WSHpFlYhC472eYXfTj7sEjlSA== X-Google-Smtp-Source: AGHT+IHRsretUph10AVXdSL0WvNm/lclixhZxUTgj6lFlaryEahWqa1CtEcl+RyR1rL91YdqyfKw X-Received: by 2002:a05:6512:1390:b0:52b:962f:a82b with SMTP id 2adb3069b0e04-52b962fa894mr8603160e87.66.1717517311119; Tue, 04 Jun 2024 09:08:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717517311; cv=pass; d=google.com; s=arc-20160816; b=QpW/UI7ApBPh8fhd+5QfvOgOtzM74YvG22iimCaGiC9jLv+6opOt6B+wFvRqmJTQ8y cla2tn7et3cZ/x99agW6njeo0YpsRVN9ajO89wn+nYf8BrrlbkD5NQiGSccJRDBzMD56 lrsywjZTJ7p0Z5oqL4pWulxlXskxGH93aggXElYjBohT4+pMXQVvYylDrZ5/cpZS5qQe 4MHz6kDg37fUUIu5JuxtzVeAxtqNUC6/pxc1aR+4jY+/p3JgAoZ/iT0WTnkfjaMHs6JM Bm5U0zTgmVT2pGlRgj2sTFNv3FU9FkHILM6+0JUROghZgMCgl+rgpk0GAEOPrheJdoLI drIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vt/c1vDb9xCz9dDlmJCnIuIKLpvbqlXfla8BOulAhzA=; fh=/zy0yt0KzF+qkC4gHsTYdCob2kK/uJSjP+aqRxoV5cE=; b=fbtphbSt+f2C1cYNVgUFMCbXHo5ln7F0cX32LalrDhaEYBbqNcYZfd2PzbxA/rt4M6 cZjdt2d8DABa1QwCLrP5HiQHX9LxBdIFQkLHwVeKuLm4o0DNBF4qU120uFXW5BFT6k7H Ivamyt0iQI46asSl3RRlmZtqcyM8mxbiUlO+7pSBI+oQ9bNUyBqPef4RXcivTi9U8lUX S3GOMhu4sD7g+TOdc9fk/tae+khHC9gjMsiS+1VrgN1Zx6nUhYGdcr+Xzx5GwP3jUW+W PI/uPQkWpCD8vh8TMap4YVnOomH0+BILpTsLvb5+9lSSUvws5thRuti4tibhWpYPtLHm z6hA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jJ2Apo2Z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201042-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201042-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a68e0af24efsi309492466b.812.2024.06.04.09.08.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 09:08:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201042-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jJ2Apo2Z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201042-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201042-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BEE2E1F21009 for ; Tue, 4 Jun 2024 16:08:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7379148318; Tue, 4 Jun 2024 16:08:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jJ2Apo2Z" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00D091474D4; Tue, 4 Jun 2024 16:08:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717517292; cv=none; b=MjW4Z0SxbjlRik8bOCGi2MrhbBe/0LR1V6FfeETOQXteOO0WZgwD+DY48fePTj34GBjG6zQ2b6ke9wa5Fgd6EinxkYuQTbYCSe3b/0FPvB4SiRZH2IEYYlgybe0FpBIujlTwIsY3aHn0NLoeZMMc9IYnDgIQOvkjeD8Ekvu8zf8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717517292; c=relaxed/simple; bh=nei+SOKSc6thGKa4Dt93c6j8LtKtL1IB/f1d/ptLbA0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XOpkzZq3ERDTBI7rJG6uFrpCl5GSgq8p6kT+vF2rQQcqJAZ9hz1fpfnZ7C93ClNuBaYMTwnqNDChtSGjunnjxG+92KgYeS1ejbIp1TieqtggL0pLbCfJYhQoveulVG7TYssT8/c3biTmDvTE8Ezxb8mlO81vxzM96F2FetwAuv8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jJ2Apo2Z; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54F96C2BBFC; Tue, 4 Jun 2024 16:08:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717517291; bh=nei+SOKSc6thGKa4Dt93c6j8LtKtL1IB/f1d/ptLbA0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jJ2Apo2ZBxetosKifpxr+CgZtwcGzOvva32RymAgiBeGK5SAFdWYjAXt6Ox9SnwJv yUQXKf0TUft3VcdUXaEhCBwcwul2/xfQ17Nx6MTxxAa5fteq/Jg+maV5Ga5LHjsyj4 QO1na6Ga3KN1//KwGNRQ5GEFr5yofQAwvZ7H/nxZYQweqFx/qTxF7I4CgKzBMTWPA7 E1aH6IUkPebZTUL8qH8IUS1hTNLXV0vPfdCoW4HIdPYnlVDjN1BDor81xWfZVL5ieq 4NhS1b+P0C2gRtUmoIA+Gokclp9NcqcsVMkxGE2DGcXDu9uYk/nvGSAIdOiM0yYeT/ OWVRm7xZ/aOKA== Date: Tue, 4 Jun 2024 11:08:09 -0500 From: Rob Herring To: Saravana Kannan Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] of: Add missing locking to of_(bus_)?n_(size|addr)_cells() Message-ID: <20240604160809.GA1060206-robh@kernel.org> References: <20240530-dt-interrupt-map-fix-v1-0-2331d8732f08@kernel.org> <20240530-dt-interrupt-map-fix-v1-2-2331d8732f08@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240530-dt-interrupt-map-fix-v1-2-2331d8732f08@kernel.org> On Thu, May 30, 2024 at 08:03:28PM -0500, Rob Herring (Arm) wrote: > When accessing parent/child/sibling pointers the DT spinlock needs to > be held. The of_(bus_)?n_(size|addr)_cells() functions are missing that > when walking up the parent nodes. In reality, it rarely matters as most > nodes are static. > > Signed-off-by: Rob Herring (Arm) > --- > drivers/of/base.c | 18 ++++++++---------- > 1 file changed, 8 insertions(+), 10 deletions(-) > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index 20603d3c9931..61fff13bbee5 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -91,8 +91,8 @@ int of_bus_n_addr_cells(struct device_node *np) > { > u32 cells; > > - for (; np; np = np->parent) > - if (!of_property_read_u32(np, "#address-cells", &cells)) > + for_each_parent_of_node_scoped(parent, np) > + if (!of_property_read_u32(parent, "#address-cells", &cells)) > return cells; > > /* No #address-cells property for the root node */ > @@ -101,10 +101,9 @@ int of_bus_n_addr_cells(struct device_node *np) > > int of_n_addr_cells(struct device_node *np) > { > - if (np->parent) > - np = np->parent; This isn't going to work... This drops of_n_addr_cells working for the root node. Callers wanting to get root node's properties need to use the of_bus_n variant instead, so those callers will have to be checked and fixed first. Rob