Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp6852656imm; Wed, 27 Jun 2018 14:46:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLqoPoUtvi0mqRLSmHF6ZQFzbaPj9IKi2xLafL3e/oy0tGBfdROdel3jajCRoXpn/KjZOnQ X-Received: by 2002:a65:62c7:: with SMTP id m7-v6mr6478240pgv.286.1530135979026; Wed, 27 Jun 2018 14:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530135978; cv=none; d=google.com; s=arc-20160816; b=wRgyyMvSLqakwQ6szk2ZSBPo5dw3zCex9zAy8g1ODj8GMXlLfzdmJskzgzs2r6z/9P aJ+rbsBkF+VXz3qlQiOLIS7dviSYBw6UeAXTkmnyB9oJm/KjlquRyFUnDXFreAxSypRM VYRGZkA7yHctKOFFnJ0v9zw+xAdX38Qvzov3RbKm9+MDJwkA6zXpmiQBcqaZ/1grh6jM rhZnf7WR/ws+Rbh8SBGoYmzVCGcNQYB3tC1qNRkbRb1u4UrRXNJOFg93GXDohJ28JMce h8vhp/TqlWmtiRa0TyrIOqNvW9Ynmt8NNiIKC9Wiw4fwAxXvSKkHX1CtvdPSdNjPNR18 zG0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:subject:cc:from:to :in-reply-to:arc-authentication-results; bh=98nVLr1cBS7Z7XJRhW6wYmSEd1tk93UxSKS/GDdacC8=; b=N9GdAMhszems1b7bNX3vf70e5pQEX7eDGaE4gAf6QwrqejFr/l+cPoC81KyJB3BC6+ OwisahzBG1vU3lQ4pVvfnKHFg7pzwLPjMPUpWOlRTgT+jjpeOmiC45GOO8FiUphvcdVz S0NEau9uJp/Ia2WetT5zDwDhbLwBCadAZ02SEhZyinVFqN+2p5bERjsNP+Vs80aQoosN CYxfLOA3jJpPlTVonsK8Bab3a1+Kje34cRyrE+IAc6N5JI1V2F6UoKvE2dHYhMnHcf2a vFT3mrB482Tdk5rAC7Wy2X2kpzWr+AfQ+M4qpxnFE8gcptrO576Cu0pCUGwKagDk1G7w ltzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67-v6si4853314pfe.49.2018.06.27.14.46.03; Wed, 27 Jun 2018 14:46:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966041AbeF0Vl0 (ORCPT + 99 others); Wed, 27 Jun 2018 17:41:26 -0400 Received: from ozlabs.org ([203.11.71.1]:49583 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965789AbeF0VlZ (ORCPT ); Wed, 27 Jun 2018 17:41:25 -0400 Received: by ozlabs.org (Postfix, from userid 1034) id 41GGZC26Lyz9s1R; Thu, 28 Jun 2018 07:41:23 +1000 (AEST) X-powerpc-patch-notification: thanks X-powerpc-patch-commit: 22db552b50fa11d8c1d171de908a1f9ef62172b7 In-Reply-To: <20180619140229.3615110-1-arnd@arndb.de> To: Arnd Bergmann , Paul Mackerras , Geert Uytterhoeven , Joshua Thompson From: Michael Ellerman Cc: Arnd Bergmann , Mathieu Malaterre , Meelis Roos , linux-kernel@vger.kernel.org, y2038@lists.linaro.org, linux-m68k@lists.linux-m68k.org, Andreas Schwab , linuxppc-dev@lists.ozlabs.org, Greg Ungerer Subject: Re: [1/3,v2] powerpc: mac: fix rtc read/write functions Message-Id: <41GGZC26Lyz9s1R@ozlabs.org> Date: Thu, 28 Jun 2018 07:41:23 +1000 (AEST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-06-19 at 14:02:27 UTC, Arnd Bergmann wrote: > 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 > Reported-by: Andreas Schwab > Signed-off-by: Arnd Bergmann > Tested-by: Mathieu Malaterre Applied to powerpc fixes, thanks. https://git.kernel.org/powerpc/c/22db552b50fa11d8c1d171de908a1f cheers