Re: [RESEND RFC PATCH v3] rtc: Fix the AltCentury value on AMD/Hygon platform
From: Jinke Fan
Date: Sun Oct 20 2019 - 23:16:46 EST
On 2019/10/20 6:04, Alexandre Belloni wrote:
> On 15/10/2019 16:08:27+0800, Jinke Fan wrote:
>> save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
>> - CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
>> +
>> +#ifdef CONFIG_X86
>> + if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
>> + boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
>> + CMOS_WRITE((save_freq_select & (~RTC_DV0)), RTC_FREQ_SELECT);
>
> This should probably use ~RTC_DIV_RESET2.
Yes, ~RTC_DIV_RESET2 can actually achieve the same effect, because of
bit5-bit6 is defined as reserved.
>> + else
>> + CMOS_WRITE((save_freq_select | RTC_DIV_RESET2), RTC_FREQ_SELECT);
>> +#else
>> + CMOS_WRITE((save_freq_select | RTC_DIV_RESET2), RTC_FREQ_SELECT);
>> +#endif
>
> Also, later you have:
>
> CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
>
> This may write bit4 again which would make mc146818_get_time fail so you
> probably want to update save_freq_select.
Yes, thanks for reminding me.
--
Best Regards,
Jinke Fan.