lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAD=FV=X23iLd+Xho0VK+LQtPR6zCm=UGuTPpAihvgsQ=g+b4dQ@mail.gmail.com>
Date:	Wed, 14 Jan 2015 14:56:36 -0800
From:	Doug Anderson <dianders@...omium.org>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Sonny Rao <sonnyrao@...omium.org>,
	Chris Zhong <zyw@...k-chips.com>,
	Heiko Stübner <heiko@...ech.de>,
	"open list:ARM/Rockchip SoC..." <linux-rockchip@...ts.infradead.org>,
	Alessandro Zummo <a.zummo@...ertech.it>,
	rtc-linux@...glegroups.com,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] RTC: RK808: fix the rtc time reading issue

Andrew,

On Wed, Jan 14, 2015 at 2:53 PM, Andrew Morton
<akpm@...ux-foundation.org> wrote:
> On Wed, 14 Jan 2015 11:44:02 -0800 Sonny Rao <sonnyrao@...omium.org> wrote:
>
>> On Wed, Jan 14, 2015 at 10:36 AM, Doug Anderson <dianders@...omium.org> wrote:
>> > Sonny,
>> >
>> >> Chris, it looks like you swapped the set and the clear of this bit,
>> >> and you're relying on the fact that the i2c transaction takes a
>> >> certain amount of time after the RTC_GET_TIME BIT is set.   I'm not
>> >> sure how long it actually takes, but why not just put in a usleep()
>> >> for the minimum wait time?
>> >
>> > I think we are safe.
>> >
>> > At 400kHz (the max speed of this part) each bit can be transferred no
>> > faster than 2.5us.  In order to do a valid i2c transaction we need to
>> > _at least_ write the address of the device and the data onto the bus,
>> > which is 16 bits.  16 * 2.5us = 40us.  That's above the 31.25us
>> >
>> > Personally I think what Chris has is fine, with the comment.
>>
>> Ok, I'm fine with that if we're sure it's slow enough.  Comment
>> explaining would certainly help.
>
> Thanks, all.  I did this:
>
> --- a/drivers/rtc/rtc-rk808.c~rtc-rk808-fix-the-rtc-time-reading-issue-fix
> +++ a/drivers/rtc/rtc-rk808.c
> @@ -73,10 +73,11 @@ static int rk808_rtc_readtime(struct dev
>                 return ret;
>         }
>
> -       /* After we set the GET_TIME bit, the rtc time couldn't be read
> -        * immediately, we should wait up to 31.25 us, about one cycle of
> +       /*
> +        * After we set the GET_TIME bit, the rtc time can't be read
> +        * immediately. So we should wait up to 31.25 us, about one cycle of
>          * 32khz. If we clear the GET_TIME bit here, the time of i2c transfer
> -        * certainly more than 31.25us.
> +        * certainly more than 31.25us: 16 * 2.5us at 400kHz bus frequency.
>          */
>         ret = regmap_update_bits(rk808->regmap, RK808_RTC_CTRL_REG,
>                                  BIT_RTC_CTRL_REG_RTC_GET_TIME,

Looks great to me, thanks.

-Doug
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ