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

Re: [PATCH 1/2] xen/riscv: implement udelay()



> udelay() is still a stub that hits BUG_ON(), so mdelay() can't be used
> on RISC-V, for example to honour the delay in machine_restart().
> 
> Busy-wait on the time CSR instead, as Linux's RISC-V __delay() does.
Instead of what? Maybe:

  Implement udelay() by busy-waiting on the time CSR, as Linux's RISC-V
  __delay() does.

> Convert the delay to timer ticks once, multiplying before dividing and
> rounding up so that short delays aren't cut to zero ticks, then spin
> until that many ticks have passed.
> 
> cpu_khz is only set by preinit_xen_time(). Before that it is 0, so the
> tick count is 0 and udelay() returns without waiting. This is also why
> the loop doesn't use get_s_time(): it divides by cpu_khz, which is a
> division by zero before then.
> 
> Assisted-by: Claude
Nit: according to sending-patches.pandoc the form should be Assisted-by:
AGENT:MODEL, e.g. "Assisted-by: Claude:claude-opus-5-5".

> [ ... 33 lines skipped ... ]
> +
> +void udelay(unsigned long usecs)
> +{
When cpu_khz is 0 there is nothing to wait for, so there is no need to
compute ticks or read the counter. Wouldn't an explicit early return be
clearer? It would also make the comment unnecessary:

    if ( !cpu_khz )
        return;

-- 
Baptiste Le Duc <baptiste.le-duc@xxxxxxxxxx>



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.