Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp152715lqh; Thu, 30 May 2024 18:04:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUmPOLsXa6ZT4zfk0hv9PyY4N8UntNigIoFo9UVjaiIT0WnwlgQ5TvxW/VlESGL772mwXZ9jDRK5yyFKsotPCYf9p2f7kiJQGDg6P+QgQ== X-Google-Smtp-Source: AGHT+IFkI9dF/eOC3Tir0lybZsyT15IR39IgfIrlZkDsfWWJ2sTzW2kyLUBsYRGxTtR1k0l+uDPs X-Received: by 2002:a17:906:a985:b0:a59:9c58:763a with SMTP id a640c23a62f3a-a6820902b4bmr23234466b.46.1717117446911; Thu, 30 May 2024 18:04:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717117446; cv=pass; d=google.com; s=arc-20160816; b=0bh2pwckrrAoFSekxS9aGhI2sVSVpepw0o8yQgi/PYhQZnYly+rf3JR/CdWDbhJYjn 77vzIO7e0TipmX8vPgeouyH8MM0ihp+Xa49X958iPEsGFHZ+mPA228538LkDM+83M8/E 9sFLqOKWpnfLHohpFTQ8HrlRrB2fSpQLXFiSkOEOUBxsAZY9yTjOIZjjk64l95IVrJLu qyZTs5f8glqE18JCGueYwDWAs8Xc23/CYBngrmFFpMCLyJPWHFQj3JYLxSHjgmP509Mf flt6dGnQGMI/Soum4Eqamde2VhqDLLneZ/SfTrWIUClyNp5rY53DrFWuQLvkBkSpY3fN v4jQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=y7WzYgdIEvW7nnDkebCaW6JH3R3KFmRLwqU5rMmw1gM=; fh=/zy0yt0KzF+qkC4gHsTYdCob2kK/uJSjP+aqRxoV5cE=; b=ZHmIqaVMPSriGyTBJ4go+kaei7dGBplXTtWTLLrQ+mJfp3ub2+IWf1FGrXrgEl1Fkk sn+3ti6+lJiLCfuDKfED8jHvm/E4xENWXGvXRwuQFhyu3Y9B+N5+nvx9z1JoTaVQiQWC wSR6UrUikJPst5sOEkUnc3/JVoNOOfUvH4w8p9KpHEkNcbe3N81IUxQIw9VUoFyWChEi Gl3DkgvOzs2pkjxpIcY+q7k9BMGO+sep8XqNWRKrbeYpmD1T7fLVF4XyKj7FqD8RBUIc DNicPHJSxwzt1aSQ1Er0e9m2Cf5QXUTQTQq1/wDiy9Ow+reIxlxnoFdDUsPgsUsCEkqk mkbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fbZ2ocmr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196114-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196114-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-a67eaf65144si30779566b.865.2024.05.30.18.04.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 18:04:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196114-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=fbZ2ocmr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-196114-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196114-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 9AF4A1F25059 for ; Fri, 31 May 2024 01:04:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0264C175A6; Fri, 31 May 2024 01:03:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fbZ2ocmr" 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 274F1EEBA; Fri, 31 May 2024 01:03:37 +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=1717117418; cv=none; b=JJTX/IEmBeVqEPWkIx5+uBranSUeyvhFBnJGgnorC7dAGWTcx5Hy2lZhOWeKvo4QU3r1JAhEafX9lJCST6cKTEAxQhdoIVURLEmqWSMMMhTP30uh0rJ7EhrHRTtMEJIJ966RJmipwnTBhZW+r7rXh7+vQmXc7YttX8e0ovnSH5I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717117418; c=relaxed/simple; bh=TBi8BiVNfed7a3wLohEOqAfZBAjmUXKDQITmxlZkrSQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XXCBw6XTnXkHlqaPU9J7ac3PczKUrbr3vwRzcycw/fQyEa13tGzbs203k6T35NceaoNQ7W7XktFVqwxtvGmURoBZ7zBLGQFeQ25DlToBcmERhrbswRV87lo9TleSmzh3TQwUzW9ttZdioShuwLO4MXUmTQPR3Mvccump6gi7yxc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fbZ2ocmr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B9C0C32789; Fri, 31 May 2024 01:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717117417; bh=TBi8BiVNfed7a3wLohEOqAfZBAjmUXKDQITmxlZkrSQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fbZ2ocmr2pO4+9KIvoZiSh2nbnmh1KrrQTtyfraADcqRxrTVQY+321sjiJHkJsrZL lEJYXiARvf3jrS9etlJJcs1GFhMLaMmDTOUVEKSUxGalp68oymgdtuytqZ1Emrl8bv t+gOvrZhLugtX8itN0wapYNqV5RWmQXzLBwTo30UA2j55Yr0PkARUio0wiJjsrD+BD YhZujCwU+3FIJXVzIoxRPlSpNTALoGHt9sbroGr1jtUAN2NKWRnD5AULcicNKx7C81 DlHe1hEWP9aX5QHWq39mPupaj+BUJ4uDAdAUNm0hXj+DMq5Cp3PnBbSiV8REI5wcx1 rCrT4HiT5wuIg== From: "Rob Herring (Arm)" Date: Thu, 30 May 2024 20:03:28 -0500 Subject: [PATCH 2/3] of: Add missing locking to of_(bus_)?n_(size|addr)_cells() 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="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240530-dt-interrupt-map-fix-v1-2-2331d8732f08@kernel.org> References: <20240530-dt-interrupt-map-fix-v1-0-2331d8732f08@kernel.org> In-Reply-To: <20240530-dt-interrupt-map-fix-v1-0-2331d8732f08@kernel.org> To: Saravana Kannan Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14-dev 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; + struct device_node *parent __free(device_node) = of_get_parent(np); - return of_bus_n_addr_cells(np); + return of_bus_n_addr_cells(parent); } EXPORT_SYMBOL(of_n_addr_cells); @@ -112,8 +111,8 @@ int of_bus_n_size_cells(struct device_node *np) { u32 cells; - for (; np; np = np->parent) - if (!of_property_read_u32(np, "#size-cells", &cells)) + for_each_parent_of_node_scoped(parent, np) + if (!of_property_read_u32(parent, "#size-cells", &cells)) return cells; /* No #size-cells property for the root node */ @@ -122,10 +121,9 @@ int of_bus_n_size_cells(struct device_node *np) int of_n_size_cells(struct device_node *np) { - if (np->parent) - np = np->parent; + struct device_node *parent __free(device_node) = of_get_parent(np); - return of_bus_n_size_cells(np); + return of_bus_n_size_cells(parent); } EXPORT_SYMBOL(of_n_size_cells); -- 2.43.0