linux_dsm_epyc7002/arch/powerpc/platforms
Arnd Bergmann 22db552b50 powerpc/powermac: Fix rtc read/write functions
As Mathieu pointed out, my conversion to time64_t was incorrect and
resulted in negative times to be read from the RTC. The problem is
that during the conversion from a byte array to a time64_t, the
'unsigned char' variable holding the top byte gets turned into a
negative signed 32-bit integer before being assigned to the 64-bit
variable for any times after 1972.

This changes the logic to cast to an unsigned 32-bit number first for
the Macintosh time and then convert that to the Unix time, which then
gives us a time in the documented 1904..2040 year range. I decided not
to use the longer 1970..2106 range that other drivers use, for
consistency with the literal interpretation of the register, but that
could be easily changed if we decide we want to support any Mac after
2040.

Just to be on the safe side, I'm also adding a WARN_ON that will
trigger if either the year 2040 has come and is observed by this
driver, or we run into an RTC that got set back to a pre-1970 date for
some reason (the two are indistinguishable).

For the RTC write functions, Andreas found another problem: both
pmu_request() and cuda_request() are varargs functions, so changing
the type of the arguments passed into them from 32 bit to 64 bit
breaks the API for the set_rtc_time functions. This changes it back to
32 bits.

The same code exists in arch/m68k/ and is patched in an identical way
now in a separate patch.

Fixes: 5bfd643583 ("powerpc: use time64_t in read_persistent_clock")
Reported-by: Mathieu Malaterre <malat@debian.org>
Reported-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-06-27 13:48:49 +10:00
..
4xx treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
8xx powerpc/8xx: Remove RTC clock on 88x 2018-06-04 00:39:18 +10:00
40x License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
44x powerpc/44x/fsp2: Add irq error handlers 2017-12-11 13:03:34 +11:00
52xx powerpc/mpc52xx_gpt: make use of raw_spinlock variants 2018-01-27 21:12:04 +11:00
82xx License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
83xx powerpc: remove retired sbc834x support 2018-05-03 22:32:30 +10:00
85xx powerpc/64: Use array of paca pointers and allocate pacas individually 2018-03-30 23:34:23 +11:00
86xx powerpc: Use pr_warn instead of pr_warning 2017-12-04 11:54:34 +11:00
512x powerpc: Use pr_warn instead of pr_warning 2017-12-04 11:54:34 +11:00
amigaone License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cell powerpc updates for 4.18 2018-06-07 10:23:33 -07:00
chrp powerpc/chrp/time: Make some functions static, add missing header include 2018-05-25 12:04:45 +10:00
embedded6xx powerpc/embedded6xx: Remove C2K board support 2018-06-04 00:39:22 +10:00
maple powerpc: use time64_t in read_persistent_clock 2018-06-03 20:43:33 +10:00
pasemi powerpc: use time64_t in read_persistent_clock 2018-06-03 20:43:33 +10:00
powermac powerpc/powermac: Fix rtc read/write functions 2018-06-27 13:48:49 +10:00
powernv treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
ps3 powerpc: remove unused to_tm() helper 2018-06-03 20:43:34 +10:00
pseries powerpc updates for 4.18 2018-06-07 10:23:33 -07:00
fsl_uli1575.c of/irq: Refactor interrupt-map parsing 2013-10-24 11:43:04 +01:00
Kconfig powerpc/cell: Remove axonram driver 2018-01-28 17:00:36 +11:00
Kconfig.cputype powerpc updates for 4.18 2018-06-07 10:23:33 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00