Re: [RFC PATCH v1 1/1] base/of/cacheinfo: support l1 entry in dt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 27 Jan 2025 12:11:36 +0000
Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> wrote:

> On Fri, 24 Jan 2025 15:20:08 +0000
> Alireza Sanaee <alireza.sanaee@xxxxxxxxxx> wrote:
> 
> > This commit simply assumes that CPU node entries may point to a
> > cache node that basically act as a l1-cache and there are some CPU
> > nodes without describing any caches but a next-level-cache property
> > that points to l1-cache.
> > 
> > Signed-off-by: Alireza Sanaee <alireza.sanaee@xxxxxxxxxx>
> > ---
> >  drivers/base/cacheinfo.c | 54
> > +++++++++++++++++++++++++++------------- 1 file changed, 37
> > insertions(+), 17 deletions(-)
> > 
> > diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
> > index cf0d455209d7..d119228fc392 100644
> > --- a/drivers/base/cacheinfo.c
> > +++ b/drivers/base/cacheinfo.c
> > @@ -83,7 +83,31 @@ bool last_level_cache_is_shared(unsigned int
> > cpu_x, unsigned int cpu_y) 
> >  #ifdef CONFIG_OF
> >  
> > -static bool of_check_cache_nodes(struct device_node *np);
> > +static bool of_check_cache_node(struct device_node *np) {
> > +	if (of_property_present(np, "cache-size")   ||
> > +	    of_property_present(np, "i-cache-size") ||
> > +	    of_property_present(np, "d-cache-size") ||
> > +	    of_property_present(np, "cache-unified"))
> > +		return true;
> > +	return false;
> > +}
> > +
> > +static bool of_check_cache_nodes(struct device_node *np)
> > +{
> > +	if (of_property_present(np, "cache-size")   ||
> > +	    of_property_present(np, "i-cache-size") ||
> > +	    of_property_present(np, "d-cache-size") ||
> > +	    of_property_present(np, "cache-unified"))
> > +		return true;  
> 
> 	if (of_check_cache_node(np))
> 		return true;
Hi Jonathan,

Thanks for the feedback, I'll replace this.
> > +
> > +	struct device_node *next __free(device_node) =
> > of_find_next_cache_node(np);
> > +	if (next) {  
> 
> Hmm. Was like this before, but general kernel style is no brackets
> for single statement if block.

Makes sense, will change this too on the next version.

Thanks,
Alireza
> 
> > +		return true;
> > +	}
> > +
> > +	return false;
> > +}
> > +
> >  
> >  /* OF properties to query for a given cache type */
> >  struct cache_type_info {
> > @@ -218,11 +242,23 @@ static int cache_setup_of_node(unsigned int
> > cpu) while (index < cache_leaves(cpu)) {
> >  		this_leaf = per_cpu_cacheinfo_idx(cpu, index);
> >  		if (this_leaf->level != 1) {
> > +			/* Always go one level down for level > 1
> > */ struct device_node *prev __free(device_node) = np;
> >  			np = of_find_next_cache_node(np);
> >  			if (!np)
> >  				break;
> > +		} else {
> > +			/* For level 1, check compatibility */
> > +			if (!of_device_is_compatible(np, "cache")
> > &&
> > +			    !of_check_cache_node(np)) {
> > +				struct device_node *prev
> > __free(device_node) = np;
> > +				np = of_find_next_cache_node(np);
> > +				if (!np)
> > +					break;
> > +				continue; /* Skip to next index
> > without processing */
> > +			}
> >  		}
> > +
> >  		cache_of_set_props(this_leaf, np);
> >  		this_leaf->fw_token = np;
> >  		index++;
> > @@ -234,22 +270,6 @@ static int cache_setup_of_node(unsigned int
> > cpu) return 0;
> >  }
> >  
> > -static bool of_check_cache_nodes(struct device_node *np)
> > -{
> > -	if (of_property_present(np, "cache-size")   ||
> > -	    of_property_present(np, "i-cache-size") ||
> > -	    of_property_present(np, "d-cache-size") ||
> > -	    of_property_present(np, "cache-unified"))
> > -		return true;
> > -
> > -	struct device_node *next __free(device_node) =
> > of_find_next_cache_node(np);
> > -	if (next) {
> > -		return true;
> > -	}
> > -
> > -	return false;
> > -}
> > -
> >  static int of_count_cache_leaves(struct device_node *np)
> >  {
> >  	unsigned int leaves = 0;  
> 





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux