qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 3/7] s390x/tcg: properly implement the TOD


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH v2 3/7] s390x/tcg: properly implement the TOD
Date: Wed, 20 Jun 2018 11:00:19 -1000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 06/20/2018 10:33 AM, David Hildenbrand wrote:
> On 20.06.2018 21:33, Richard Henderson wrote:
>> On 06/20/2018 12:08 AM, David Hildenbrand wrote:
>>> +/* Converts ns to s390's clock format */
>>> +static inline uint64_t time2tod(uint64_t ns)
>>> +{
>>> +    return (ns << 9) / 125;
>>> +}
>>> +
>>> +/* Converts s390's clock format to ns */
>>> +static inline uint64_t tod2time(uint64_t t)
>>> +{
>>> +    return (t * 125) >> 9;
>>> +}
>>
> 
> In this patch I'm only moving the code. If we find this is a problem,
> this should go into a separate patch.

Ah, right.


>> How many significant bits on input here?
> 
> Basically all are significant, and as it is a clock, we will reach these
> bits at one point.
> 
>> Do you in fact want to be using muldiv64?
> 
> Looking at linux:
> 
> arch/s390/include/asm/timex.h
> 
> They have a lengthy documentation, resulting in (a spli to avoid overflows)
> 
> return ((todval >> 9) * 125) + (((todval & 0x1ff) * 125) >> 9);
> 
> Maybe we should do the same?

That would work too.


r~



reply via email to

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