[RFC PATCH v1 08/21] RISC-V: ACPI: RHCT: Add function to get CBO block sizes

Sunil V L sunilvl at ventanamicro.com
Fri Aug 4 02:33:29 PDT 2023


On Fri, Aug 04, 2023 at 09:00:45AM +0300, Andy Shevchenko wrote:
> On Thu, Aug 03, 2023 at 11:29:03PM +0530, Sunil V L wrote:
> > CBO related block size in ACPI is provided by RHCT. Add
> > support to read the CMO node in RHCT to get this information.
> 
> ...
> 
> > +	if (!table) {
> 
> Why not positive conditional?
> 
Sure.

> > +		rhct = (struct acpi_table_rhct *)acpi_get_rhct();
> > +		if (!rhct)
> > +			return -ENOENT;
> > +	} else {
> > +		rhct = (struct acpi_table_rhct *)table;
> > +	}
> 
> ...
> 
> > +	end = ACPI_ADD_PTR(struct acpi_rhct_node_header, rhct, rhct->header.length);
> 
> > +
> 
> Blank line here is not needed.
> 
Okay.

> > +	for (node = ACPI_ADD_PTR(struct acpi_rhct_node_header, rhct, rhct->node_offset);
> > +	     node < end;
> > +	     node = ACPI_ADD_PTR(struct acpi_rhct_node_header, node, node->length)) {
> 
> > +			for (int i = 0; i < hart_info->num_offsets; i++) {
> > +				ref_node = ACPI_ADD_PTR(struct acpi_rhct_node_header,
> > +							rhct, hart_info_node_offset[i]);
> > +				if (ref_node->type == ACPI_RHCT_NODE_TYPE_CMO) {
> > +					cmo_node = ACPI_ADD_PTR(struct acpi_rhct_cmo_node,
> > +								ref_node, size_hdr);
> > +					if (cbom_size)
> > +						*cbom_size = 1 << cmo_node->cbom_size;
> > +
> > +					if (cboz_size)
> > +						*cboz_size = 1 << cmo_node->cboz_size;
> > +
> > +					if (cbop_size)
> > +						*cbop_size = 1 << cmo_node->cbop_size;
> 
> BIT() in all three cases?
>
Sure.
 
> But how you guarantee it will not overflow? I mean who prevents cboX_size to be
> bigger than 30 (note also that 31 in your case is Undefined Behaviour in
> accordance with the C standard).
> 
Good catch!. Let me add a check that the value is not more than 30.

Thanks!
Sunil



More information about the linux-arm-kernel mailing list