[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v3 06/14] xen/riscv: dt_processor_hartid() implementation
On 5/26/25 12:46 PM, Oleksii Kurochko
wrote:
Oops, I meant here size_t_max instead of (sizeof(size_t) * BIT_PER_BYTE), lost power of 2 minus 1. Probably, SIZE_T_MAX or something similar exists. I have to check. ~ Oleksii + return ~0UL; + + return dt_read_number(cell, ac); +} + +/* + * Returns the hartid of the given device tree node, or -ENODEV if the node + * isn't an enabled and valid RISC-V hart node. + */ +int dt_processor_hartid(const struct dt_device_node *node, + unsigned long *hartid) +{ + const char *isa; + int ret; + + if ( !dt_device_is_compatible(node, "riscv") ) + { + printk("Found incompatible CPU\n"); + return -ENODEV; + } + + *hartid = dt_get_hartid(node); + if ( *hartid == ~0UL ) + { + printk("Found CPU without CPU ID\n"); + return -ENODATA; + } + + if ( !dt_device_is_available(node)) + { + printk("CPU with hartid=%lu is not available\n", *hartid);Considering that hart ID assignment is outside of our control, would we perhaps better (uniformly) log such using %#lx?It makes sense, DTC when generates dts from dtb also uses hex number, so it could help to find a failure node faster.+ return -ENODEV; + } + + if ( (ret = dt_property_read_string(node, "riscv,isa", &isa)) ) + { + printk("CPU with hartid=%lu has no \"riscv,isa\" property\n", *hartid); + return ret; + } + + if ( isa[0] != 'r' || isa[1] != 'v' ) + { + printk("CPU with hartid=%lu has an invalid ISA of \"%s\"\n", *hartid, + isa); + return -EINVAL;As before -EINVAL is appropriate when input arguments have wrong values. Here, however, you found an unexpected value in something the platform has presented to you. While not entirely appropriate either, maybe -ENODEV again (if nothing better can be found)?I don't see better candidate. Interesting if some reserved region exists for user defined errors. ~ Oleksii
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |