All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: Arnd Bergmann <arnd@arndb.de>, Paul Mackerras <paulus@samba.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Joshua Thompson <funaho@jurai.org>
Cc: Mathieu Malaterre <malat@debian.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Greg Ungerer <gerg@linux-m68k.org>,
	linux-m68k@lists.linux-m68k.org, linuxppc-dev@lists.ozlabs.org,
	linux-kernel@vger.kernel.org, y2038@lists.linaro.org,
	Meelis Roos <mroos@linux.ee>,
	Andreas Schwab <schwab@linux-m68k.org>,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH 1/3] [v2] powerpc: mac: fix rtc read/write functions
Date: Wed, 27 Jun 2018 14:32:17 +1000	[thread overview]
Message-ID: <87y3f06e9a.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <20180619140229.3615110-1-arnd@arndb.de>

Arnd Bergmann <arnd@arndb.de> writes:

> 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: 5bfd643583b2 ("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>
> ---
>  arch/powerpc/platforms/powermac/time.c | 29 ++++++++++++++++++++---------
>  1 file changed, 20 insertions(+), 9 deletions(-)

So I think I can take this patch in isolation via the powerpc tree as a
fix for 4.18.

I'll leave the other two alone.

cheers

  parent reply	other threads:[~2018-06-27  4:32 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 14:02 [PATCH 1/3] [v2] powerpc: mac: fix rtc read/write functions Arnd Bergmann
2018-06-19 14:02 ` [PATCH 2/3] [v2] m68k: mac: use time64_t in RTC handling Arnd Bergmann
2018-06-22  5:26   ` Finn Thain
2018-06-22  8:54     ` Arnd Bergmann
2018-07-08 10:49       ` Geert Uytterhoeven
2018-07-08 11:45         ` Finn Thain
2018-07-18 11:36   ` Geert Uytterhoeven
2018-07-18 12:02     ` Finn Thain
2018-07-18 12:20       ` Arnd Bergmann
2018-07-18 13:49         ` Finn Thain
2018-07-18 14:26           ` Arnd Bergmann
2018-07-22 11:56           ` Finn Thain
2018-07-23  8:08             ` Geert Uytterhoeven
2018-06-19 14:02 ` [PATCH 3/3] [v2] m68k: remove unused set_clock_mmss() helpers Arnd Bergmann
2018-07-18 11:37   ` Geert Uytterhoeven
2018-06-20  7:16 ` [PATCH 1/3] [v2] powerpc: mac: fix rtc read/write functions Mathieu Malaterre
2018-07-01 15:47   ` Meelis Roos
2018-07-09 21:31     ` Arnd Bergmann
2018-07-09 21:31       ` Arnd Bergmann
2018-07-10  1:18       ` Finn Thain
2018-07-10  1:18         ` Finn Thain
2018-06-27  4:32 ` Michael Ellerman [this message]
2018-06-27 10:36   ` Arnd Bergmann
2018-06-27 12:41     ` Michael Ellerman
2018-06-27 21:41 ` [1/3,v2] " Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y3f06e9a.fsf@concordia.ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=arnd@arndb.de \
    --cc=benh@kernel.crashing.org \
    --cc=funaho@jurai.org \
    --cc=geert@linux-m68k.org \
    --cc=gerg@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=malat@debian.org \
    --cc=mroos@linux.ee \
    --cc=paulus@samba.org \
    --cc=schwab@linux-m68k.org \
    --cc=y2038@lists.linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.