Re: [PATCH v2] Allow for riscv-clock to pick up mmio address.

From: Conor Dooley
Date: Thu Apr 10 2025 - 06:22:32 EST


On Wed, Apr 09, 2025 at 02:38:55PM +0000, Aleksa Paunovic wrote:
> From: Dragan Mladjenovic <Dragan.Mladjenovic@xxxxxxxxxx>
>
> Allows faster rdtime access via GCR.U mtime shadow register on p8700.
>
> Signed-off-by: Aleksa Paunovic <aleksa.paunovic@xxxxxxxxxxxxx>

> +#if defined(CONFIG_RISCV_TIME_MMIO)
> + gcru = of_find_compatible_node(NULL, NULL, "mti,p8700-gcru");

Firstly, this is an undocumented compatible, so you'll need to create a
binding for it before you can use it. Not much to say on the use of the
compatible in the driver without more information on what the device
looks like.

Secondly, the option you have added is generically named and described,
yet only functions on this p8700 platform. At a minimum, it needs to
explain the platforms where it is relevant, and probably also should
depend on the kconfig option that enables building a dt etc for the
p8700 platform in the first place.

Cheers,
Conor.

> + if (gcru) {
> + if (!of_property_read_u64_index(gcru, "reg", 0, &mmio_addr)) {
> + riscv_time_val = ioremap((long)mmio_addr, 8);
> + if (riscv_time_val) {
> + pr_info("Using mmio time register at 0x%llx\n",
> + mmio_addr);
> + static_branch_enable(
> + &riscv_time_mmio_available);
> + } else {
> + pr_warn("Unable to use mmio time at 0x%llx\n",
> + mmio_addr);
> + }
> + of_node_put(gcru);
> + }
> + }
> +#endif

Attachment: signature.asc
Description: PGP signature