qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 4/7] arm: remove muldiv64()


From: Laurent Vivier
Subject: Re: [Qemu-devel] [PATCH 4/7] arm: remove muldiv64()
Date: Tue, 25 Aug 2015 23:36:01 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0


On 25/08/2015 23:11, Peter Crosthwaite wrote:
> On Tue, Aug 25, 2015 at 1:44 PM, Laurent Vivier <address@hidden> wrote:
>> muldiv64() is used to convert microseconds to nanoseconds.
>>
>> Use qemu_clock_get_ns() instead of qemu_clock_get_us()
>> to avoid this operation.
>>
>> Signed-off-by: Laurent Vivier <address@hidden>
>> ---
>>  target-arm/helper.c | 9 +++------
>>  1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/target-arm/helper.c b/target-arm/helper.c
>> index 1568aa6..f5e8fd8 100644
>> --- a/target-arm/helper.c
>> +++ b/target-arm/helper.c
>> @@ -678,8 +678,7 @@ void pmccntr_sync(CPUARMState *env)
>>  {
>>      uint64_t temp_ticks;
>>
>> -    temp_ticks = muldiv64(qemu_clock_get_us(QEMU_CLOCK_VIRTUAL),
>> -                          get_ticks_per_sec(), 1000000);
>> +    temp_ticks = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
>>
>>      if (env->cp15.c9_pmcr & PMCRD) {
>>          /* Increment once every 64 processor clock cycles */
>> @@ -717,8 +716,7 @@ static uint64_t pmccntr_read(CPUARMState *env, const 
>> ARMCPRegInfo *ri)
>>          return env->cp15.c15_ccnt;
>>      }
>>
>> -    total_ticks = muldiv64(qemu_clock_get_us(QEMU_CLOCK_VIRTUAL),
>> -                           get_ticks_per_sec(), 1000000);
>> +    total_ticks = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
>>
> 
> The long term goal here was to replace get_ticks_per_sec with a
> parameterizable CPU frequency so ideally the math should remain. The
> ARM CPU frequency == get_ticks_per_sec is the bigger issue.

OK, I will remove this one from the series.

Perhaps a comment in the original functions would help to understand
what we are doing here...

or something like that:

#define ARM_CPU_FREQ 1000000000 /* FIXME: should be parameterizable */
#define NSEC_PER_SEC 1000000000

total_ticks = muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
ARM_CPU_FREQ, NSEC_PER_SEC);

Laurent
> Regards,
> Peter
> 
>>      if (env->cp15.c9_pmcr & PMCRD) {
>>          /* Increment once every 64 processor clock cycles */
>> @@ -738,8 +736,7 @@ static void pmccntr_write(CPUARMState *env, const 
>> ARMCPRegInfo *ri,
>>          return;
>>      }
>>
>> -    total_ticks = muldiv64(qemu_clock_get_us(QEMU_CLOCK_VIRTUAL),
>> -                           get_ticks_per_sec(), 1000000);
>> +    total_ticks = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
>>
>>      if (env->cp15.c9_pmcr & PMCRD) {
>>          /* Increment once every 64 processor clock cycles */
>> --
>> 2.1.0
>>
>>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]