Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aarch32: CLK_MAGIC, CLK_SHIFT inconsistencies #1352

Open
Indanz opened this issue Nov 19, 2024 · 1 comment
Open

Aarch32: CLK_MAGIC, CLK_SHIFT inconsistencies #1352

Indanz opened this issue Nov 19, 2024 · 1 comment

Comments

@Indanz
Copy link
Contributor

Indanz commented Nov 19, 2024

What is the correct value as input to the kernel/tools/reciprocal.py script? The value in HZ or the value in MHz?

For example, for TIMER_FREQUENCY 24000000:

  • am335x, exynos4/5 have CLK_MAGIC 2863311531llu and CLK_SHIFT 36u as they used 24 MHz as input.
  • odroidc2/4 have CLK_MAGIC 375299969llu and CLK_SHIFT 53u as they used the HZ value as input.

I haven't checked all other boards, but surely using the wrong values would mess up timing?

@Indanz
Copy link
Contributor Author

Indanz commented Nov 19, 2024

Looking at the code (assuming USE_KHZ is false) it does:

static inline CONST time_t ticksToUs(ticks_t ticks)
{
    /* simulate 64bit division using multiplication by reciprocal */
    return (ticks * CLK_MAGIC) >> CLK_SHIFT;
}

So it seems that using 24 as input is the correct thing to do and that the odroid defines are wrong.

Not sure what you're supposed to do when you don't have a round MHz value and USE_KHZ is true though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant