devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Dawei Li <dawei.li@shingroup.cn>
Cc: frowand.list@gmail.com, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, set_pte_at@outlook.com
Subject: Re: [PATCH 2/2] of: Implment cache update operation on device node attach
Date: Wed, 31 Jan 2024 15:12:27 -0600	[thread overview]
Message-ID: <20240131211227.GA2303754-robh@kernel.org> (raw)
In-Reply-To: <20240130105236.3097126-3-dawei.li@shingroup.cn>

On Tue, Jan 30, 2024 at 06:52:36PM +0800, Dawei Li wrote:
> Use implemented __of_phandle_update_cache to update phandle cache on
> device node attachment.
> 
> While at it, make explicit assertion on locking dependency for
> __of_phandle_cache_inv_entry.

'While at it' is a red flag for should be a separate commit.

> 
> Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> ---
>  drivers/of/base.c    | 6 ++++--
>  drivers/of/dynamic.c | 2 ++
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 8b7da27835eb..44e542b566e1 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -153,6 +153,8 @@ void __of_phandle_cache_inv_entry(phandle handle)
>  	u32 handle_hash;
>  	struct device_node *np;
>  
> +	lockdep_assert_held(&devtree_lock);
> +
>  	if (!handle)
>  		return;
>  
> @@ -195,8 +197,8 @@ void __init of_core_init(void)
>  	}
>  	for_each_of_allnodes(np) {
>  		__of_attach_node_sysfs(np);
> -		if (np->phandle && !phandle_cache[of_phandle_cache_hash(np->phandle)])
> -			phandle_cache[of_phandle_cache_hash(np->phandle)] = np;
> +
> +		__of_phandle_update_cache(np, false);
>  	}
>  	mutex_unlock(&of_mutex);
>  
> diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
> index 3bf27052832f..a68bf58f2c24 100644
> --- a/drivers/of/dynamic.c
> +++ b/drivers/of/dynamic.c
> @@ -219,6 +219,8 @@ static void __of_attach_node(struct device_node *np)
>  			np->phandle = 0;
>  	}
>  
> +	__of_phandle_update_cache(np, true);
> +
>  	np->child = NULL;
>  	np->sibling = np->parent->child;
>  	np->parent->child = np;
> -- 
> 2.27.0
> 

  reply	other threads:[~2024-01-31 21:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30 10:52 [PATCH 0/2] Update phandle cache on device node attach Dawei Li
2024-01-30 10:52 ` [PATCH 1/2] of: Introduce __of_phandle_update_cache Dawei Li
2024-01-31 21:29   ` Rob Herring
2024-02-01 10:00     ` Dawei Li
2024-02-01 21:09       ` Rob Herring
2024-01-30 10:52 ` [PATCH 2/2] of: Implment cache update operation on device node attach Dawei Li
2024-01-31 21:12   ` Rob Herring [this message]
2024-02-01 10:03     ` Dawei Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240131211227.GA2303754-robh@kernel.org \
    --to=robh@kernel.org \
    --cc=dawei.li@shingroup.cn \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=set_pte_at@outlook.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).