Skip to content

Commit

Permalink
Merge tag 'powerpc-4.18-3' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/git/powerpc/linux

Pull powerpc fixes from Michael Ellerman:
 "Two regression fixes, and a new syscall wire-up:

   - A fix for the recent conversion to time64_t in the powermac RTC
     routines, which caused time to go backward.

   - Another fix for fallout from the split PMD PTL conversion.

   - Wire up the new io_pgetevents() syscall.

  Thanks to: Aneesh Kumar K.V, Arnd Bergmann, Breno Leitao, Mathieu
  Malaterre"

* tag 'powerpc-4.18-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
  powerpc/powermac: Fix rtc read/write functions
  powerpc/mm/32: Fix pgtable_page_dtor call
  powerpc: Wire up io_pgetevents
  • Loading branch information
torvalds committed Jun 30, 2018
2 parents 0d55ec6 + 22db552 commit 1904148
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
1 change: 0 additions & 1 deletion arch/powerpc/include/asm/book3s/32/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ static inline void pgtable_free_tlb(struct mmu_gather *tlb,
static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
unsigned long address)
{
pgtable_page_dtor(table);
pgtable_free_tlb(tlb, page_address(table), 0);
}
#endif /* _ASM_POWERPC_BOOK3S_32_PGALLOC_H */
1 change: 0 additions & 1 deletion arch/powerpc/include/asm/nohash/32/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
unsigned long address)
{
tlb_flush_pgtable(tlb, address);
pgtable_page_dtor(table);
pgtable_free_tlb(tlb, page_address(table), 0);
}
#endif /* _ASM_POWERPC_PGALLOC_32_H */
1 change: 1 addition & 0 deletions arch/powerpc/include/asm/systbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,4 @@ SYSCALL(pkey_alloc)
SYSCALL(pkey_free)
SYSCALL(pkey_mprotect)
SYSCALL(rseq)
COMPAT_SYS(io_pgetevents)
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <uapi/asm/unistd.h>


#define NR_syscalls 388
#define NR_syscalls 389

#define __NR__exit __NR_exit

Expand Down
1 change: 1 addition & 0 deletions arch/powerpc/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,5 +399,6 @@
#define __NR_pkey_free 385
#define __NR_pkey_mprotect 386
#define __NR_rseq 387
#define __NR_io_pgetevents 388

#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
29 changes: 20 additions & 9 deletions arch/powerpc/platforms/powermac/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
#define DBG(x...)
#endif

/* Apparently the RTC stores seconds since 1 Jan 1904 */
/*
* Offset between Unix time (1970-based) and Mac time (1904-based). Cuda and PMU
* times wrap in 2040. If we need to handle later times, the read_time functions
* need to be changed to interpret wrapped times as post-2040.
*/
#define RTC_OFFSET 2082844800

/*
Expand Down Expand Up @@ -97,19 +101,22 @@ static time64_t cuda_get_time(void)
if (req.reply_len != 7)
printk(KERN_ERR "cuda_get_time: got %d byte reply\n",
req.reply_len);
now = (req.reply[3] << 24) + (req.reply[4] << 16)
+ (req.reply[5] << 8) + req.reply[6];
now = (u32)((req.reply[3] << 24) + (req.reply[4] << 16) +
(req.reply[5] << 8) + req.reply[6]);
/* it's either after year 2040, or the RTC has gone backwards */
WARN_ON(now < RTC_OFFSET);

return now - RTC_OFFSET;
}

#define cuda_get_rtc_time(tm) rtc_time64_to_tm(cuda_get_time(), (tm))

static int cuda_set_rtc_time(struct rtc_time *tm)
{
time64_t nowtime;
u32 nowtime;
struct adb_request req;

nowtime = rtc_tm_to_time64(tm) + RTC_OFFSET;
nowtime = lower_32_bits(rtc_tm_to_time64(tm) + RTC_OFFSET);
if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME,
nowtime >> 24, nowtime >> 16, nowtime >> 8,
nowtime) < 0)
Expand Down Expand Up @@ -140,19 +147,23 @@ static time64_t pmu_get_time(void)
if (req.reply_len != 4)
printk(KERN_ERR "pmu_get_time: got %d byte reply from PMU\n",
req.reply_len);
now = (req.reply[0] << 24) + (req.reply[1] << 16)
+ (req.reply[2] << 8) + req.reply[3];
now = (u32)((req.reply[0] << 24) + (req.reply[1] << 16) +
(req.reply[2] << 8) + req.reply[3]);

/* it's either after year 2040, or the RTC has gone backwards */
WARN_ON(now < RTC_OFFSET);

return now - RTC_OFFSET;
}

#define pmu_get_rtc_time(tm) rtc_time64_to_tm(pmu_get_time(), (tm))

static int pmu_set_rtc_time(struct rtc_time *tm)
{
time64_t nowtime;
u32 nowtime;
struct adb_request req;

nowtime = rtc_tm_to_time64(tm) + RTC_OFFSET;
nowtime = lower_32_bits(rtc_tm_to_time64(tm) + RTC_OFFSET);
if (pmu_request(&req, NULL, 5, PMU_SET_RTC, nowtime >> 24,
nowtime >> 16, nowtime >> 8, nowtime) < 0)
return -ENXIO;
Expand Down

0 comments on commit 1904148

Please sign in to comment.