Message ID | 20230901151442.1830095-1-xu.zhang@hexintek.com |
---|---|
State | Not Applicable |
Headers | show |
Series | lib: utils/timer: mtimer: Change to use correct condition | expand |
On 2023-09-01 10:14 AM, Xu Zhang wrote: > It should use mt->mtime_addr to check align. > > Signed-off-by: Xu Zhang <xu.zhang@hexintek.com> > --- > lib/utils/timer/aclint_mtimer.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c > index 271e625..ddfa2bd 100644 > --- a/lib/utils/timer/aclint_mtimer.c > +++ b/lib/utils/timer/aclint_mtimer.c > @@ -187,7 +187,7 @@ int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt, > /* Sanity checks */ > if (!mt || > (mt->hart_count && !mt->mtimecmp_size) || > - (mt->mtime_size && (mt->mtime_addr & (ACLINT_MTIMER_ALIGN - 1))) || > + (mt->mtime_addr && (mt->mtime_addr & (ACLINT_MTIMER_ALIGN - 1))) || The original code is correct. The purpose is to skip the alignment check if mtime_size == 0, or in other words, if the mtime register is not implemented. In that case, we don't care what mtime_addr is, because it is not used. Regards, Samuel > (mt->mtime_size && (mt->mtime_size & (ACLINT_MTIMER_ALIGN - 1))) || > (mt->mtimecmp_addr & (ACLINT_MTIMER_ALIGN - 1)) || > (mt->mtimecmp_size & (ACLINT_MTIMER_ALIGN - 1)) ||
diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c index 271e625..ddfa2bd 100644 --- a/lib/utils/timer/aclint_mtimer.c +++ b/lib/utils/timer/aclint_mtimer.c @@ -187,7 +187,7 @@ int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt, /* Sanity checks */ if (!mt || (mt->hart_count && !mt->mtimecmp_size) || - (mt->mtime_size && (mt->mtime_addr & (ACLINT_MTIMER_ALIGN - 1))) || + (mt->mtime_addr && (mt->mtime_addr & (ACLINT_MTIMER_ALIGN - 1))) || (mt->mtime_size && (mt->mtime_size & (ACLINT_MTIMER_ALIGN - 1))) || (mt->mtimecmp_addr & (ACLINT_MTIMER_ALIGN - 1)) || (mt->mtimecmp_size & (ACLINT_MTIMER_ALIGN - 1)) ||
It should use mt->mtime_addr to check align. Signed-off-by: Xu Zhang <xu.zhang@hexintek.com> --- lib/utils/timer/aclint_mtimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)