Skip to content

Commit

Permalink
Merge tag 'y2038-for-4.21' of ssh://gitolite.kernel.org:/pub/scm/linu…
Browse files Browse the repository at this point in the history
…x/kernel/git/arnd/playground

Pull y2038 updates from Arnd Bergmann:
 "More syscalls and cleanups

  This concludes the main part of the system call rework for 64-bit
  time_t, which has spread over most of year 2018, the last six system
  calls being

    - ppoll
    - pselect6
    - io_pgetevents
    - recvmmsg
    - futex
    - rt_sigtimedwait

  As before, nothing changes for 64-bit architectures, while 32-bit
  architectures gain another entry point that differs only in the layout
  of the timespec structure. Hopefully in the next release we can wire
  up all 22 of those system calls on all 32-bit architectures, which
  gives us a baseline version for glibc to start using them.

  This does not include the clock_adjtime, getrusage/waitid, and
  getitimer/setitimer system calls. I still plan to have new versions of
  those as well, but they are not required for correct operation of the
  C library since they can be emulated using the old 32-bit time_t based
  system calls.

  Aside from the system calls, there are also a few cleanups here,
  removing old kernel internal interfaces that have become unused after
  all references got removed. The arch/sh cleanups are part of this,
  there were posted several times over the past year without a reaction
  from the maintainers, while the corresponding changes made it into all
  other architectures"

* tag 'y2038-for-4.21' of ssh://gitolite.kernel.org:/pub/scm/linux/kernel/git/arnd/playground:
  timekeeping: remove obsolete time accessors
  vfs: replace current_kernel_time64 with ktime equivalent
  timekeeping: remove timespec_add/timespec_del
  timekeeping: remove unused {read,update}_persistent_clock
  sh: remove board_time_init() callback
  sh: remove unused rtc_sh_get/set_time infrastructure
  sh: sh03: rtc: push down rtc class ops into driver
  sh: dreamcast: rtc: push down rtc class ops into driver
  y2038: signal: Add compat_sys_rt_sigtimedwait_time64
  y2038: signal: Add sys_rt_sigtimedwait_time32
  y2038: socket: Add compat_sys_recvmmsg_time64
  y2038: futex: Add support for __kernel_timespec
  y2038: futex: Move compat implementation into futex.c
  io_pgetevents: use __kernel_timespec
  pselect6: use __kernel_timespec
  ppoll: use __kernel_timespec
  signal: Add restore_user_sigmask()
  signal: Add set_user_sigmask()
  • Loading branch information
torvalds committed Dec 28, 2018
2 parents 1a80dad + e4b92b1 commit b12a912
Show file tree
Hide file tree
Showing 35 changed files with 847 additions and 755 deletions.
8 changes: 0 additions & 8 deletions Documentation/sh/new-machine.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ might look something like:
* arch/sh/boards/vapor/setup.c - Setup code for imaginary board
*/
#include <linux/init.h>
#include <asm/rtc.h> /* for board_time_init() */

const char *get_system_type(void)
{
Expand All @@ -132,13 +131,6 @@ int __init platform_setup(void)
* this board.
*/

/*
* Presume all FooTech boards have the same broken timer,
* and also presume that we've defined foo_timer_init to
* do something useful.
*/
board_time_init = foo_timer_init;

/* Start-up imaginary PCI ... */

/* And whatever else ... */
Expand Down
4 changes: 2 additions & 2 deletions arch/sh/boards/mach-dreamcast/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# Makefile for the Sega Dreamcast specific parts of the kernel
#

obj-y := setup.o irq.o rtc.o

obj-y := setup.o irq.o
obj-$(CONFIG_RTC_DRV_GENERIC) += rtc.o
45 changes: 31 additions & 14 deletions arch/sh/boards/mach-dreamcast/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
*/

#include <linux/time.h>
#include <asm/rtc.h>
#include <asm/io.h>
#include <linux/rtc.h>
#include <linux/io.h>
#include <linux/platform_device.h>

/* The AICA RTC has an Epoch of 1/1/1950, so we must subtract 20 years (in
seconds) to get the standard Unix Epoch when getting the time, and add
Expand All @@ -26,13 +27,15 @@

/**
* aica_rtc_gettimeofday - Get the time from the AICA RTC
* @ts: pointer to resulting timespec
* @dev: the RTC device (ignored)
* @tm: pointer to resulting RTC time structure
*
* Grabs the current RTC seconds counter and adjusts it to the Unix Epoch.
*/
static void aica_rtc_gettimeofday(struct timespec *ts)
static int aica_rtc_gettimeofday(struct device *dev, struct rtc_time *tm)
{
unsigned long val1, val2;
time64_t t;

do {
val1 = ((__raw_readl(AICA_RTC_SECS_H) & 0xffff) << 16) |
Expand All @@ -42,22 +45,26 @@ static void aica_rtc_gettimeofday(struct timespec *ts)
(__raw_readl(AICA_RTC_SECS_L) & 0xffff);
} while (val1 != val2);

ts->tv_sec = val1 - TWENTY_YEARS;
/* normalize to 1970..2106 time range */
t = (u32)(val1 - TWENTY_YEARS);

/* Can't get nanoseconds with just a seconds counter. */
ts->tv_nsec = 0;
rtc_time64_to_tm(t, tm);

return 0;
}

/**
* aica_rtc_settimeofday - Set the AICA RTC to the current time
* @secs: contains the time_t to set
* @dev: the RTC device (ignored)
* @tm: pointer to new RTC time structure
*
* Adjusts the given @tv to the AICA Epoch and sets the RTC seconds counter.
*/
static int aica_rtc_settimeofday(const time_t secs)
static int aica_rtc_settimeofday(struct device *dev, struct rtc_time *tm)
{
unsigned long val1, val2;
unsigned long adj = secs + TWENTY_YEARS;
time64_t secs = rtc_tm_to_time64(tm);
u32 adj = secs + TWENTY_YEARS;

do {
__raw_writel((adj & 0xffff0000) >> 16, AICA_RTC_SECS_H);
Expand All @@ -73,9 +80,19 @@ static int aica_rtc_settimeofday(const time_t secs)
return 0;
}

void aica_time_init(void)
static const struct rtc_class_ops rtc_generic_ops = {
.read_time = aica_rtc_gettimeofday,
.set_time = aica_rtc_settimeofday,
};

static int __init aica_time_init(void)
{
rtc_sh_get_time = aica_rtc_gettimeofday;
rtc_sh_set_time = aica_rtc_settimeofday;
}
struct platform_device *pdev;

pdev = platform_device_register_data(NULL, "rtc-generic", -1,
&rtc_generic_ops,
sizeof(rtc_generic_ops));

return PTR_ERR_OR_ZERO(pdev);
}
arch_initcall(aica_time_init);
1 change: 0 additions & 1 deletion arch/sh/boards/mach-dreamcast/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

static void __init dreamcast_setup(char **cmdline_p)
{
board_time_init = aica_time_init;
}

static struct sh_machine_vector mv_dreamcast __initmv = {
Expand Down
3 changes: 2 additions & 1 deletion arch/sh/boards/mach-sh03/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
# Makefile for the Interface (CTP/PCI-SH03) specific parts of the kernel
#

obj-y := setup.o rtc.o
obj-y := setup.o
obj-$(CONFIG_RTC_DRV_GENERIC) += rtc.o
51 changes: 31 additions & 20 deletions arch/sh/boards/mach-sh03/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
#include <linux/bcd.h>
#include <linux/rtc.h>
#include <linux/spinlock.h>
#include <asm/io.h>
#include <asm/rtc.h>
#include <linux/io.h>
#include <linux/rtc.h>
#include <linux/platform_device.h>

#define RTC_BASE 0xb0000000
#define RTC_SEC1 (RTC_BASE + 0)
Expand All @@ -38,7 +39,7 @@

static DEFINE_SPINLOCK(sh03_rtc_lock);

unsigned long get_cmos_time(void)
static int sh03_rtc_gettimeofday(struct device *dev, struct rtc_time *tm)
{
unsigned int year, mon, day, hour, min, sec;

Expand Down Expand Up @@ -75,17 +76,18 @@ unsigned long get_cmos_time(void)
}

spin_unlock(&sh03_rtc_lock);
return mktime(year, mon, day, hour, min, sec);
}

void sh03_rtc_gettimeofday(struct timespec *tv)
{
tm->tm_sec = sec;
tm->tm_min = min;
tm->tm_hour = hour;
tm->tm_mday = day;
tm->tm_mon = mon;
tm->tm_year = year - 1900;

tv->tv_sec = get_cmos_time();
tv->tv_nsec = 0;
return 0;
}

static int set_rtc_mmss(unsigned long nowtime)
static int set_rtc_mmss(struct rtc_time *tm)
{
int retval = 0;
int real_seconds, real_minutes, cmos_minutes;
Expand All @@ -97,8 +99,8 @@ static int set_rtc_mmss(unsigned long nowtime)
if (!(__raw_readb(RTC_CTL) & RTC_BUSY))
break;
cmos_minutes = (__raw_readb(RTC_MIN1) & 0xf) + (__raw_readb(RTC_MIN10) & 0xf) * 10;
real_seconds = nowtime % 60;
real_minutes = nowtime / 60;
real_seconds = tm->tm_sec;
real_minutes = tm->tm_min;
if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
real_minutes += 30; /* correct for half hour time zone */
real_minutes %= 60;
Expand All @@ -112,22 +114,31 @@ static int set_rtc_mmss(unsigned long nowtime)
printk_once(KERN_NOTICE
"set_rtc_mmss: can't update from %d to %d\n",
cmos_minutes, real_minutes);
retval = -1;
retval = -EINVAL;
}
spin_unlock(&sh03_rtc_lock);

return retval;
}

int sh03_rtc_settimeofday(const time_t secs)
int sh03_rtc_settimeofday(struct device *dev, struct rtc_time *tm)
{
unsigned long nowtime = secs;

return set_rtc_mmss(nowtime);
return set_rtc_mmss(tm);
}

void sh03_time_init(void)
static const struct rtc_class_ops rtc_generic_ops = {
.read_time = sh03_rtc_gettimeofday,
.set_time = sh03_rtc_settimeofday,
};

static int __init sh03_time_init(void)
{
rtc_sh_get_time = sh03_rtc_gettimeofday;
rtc_sh_set_time = sh03_rtc_settimeofday;
struct platform_device *pdev;

pdev = platform_device_register_data(NULL, "rtc-generic", -1,
&rtc_generic_ops,
sizeof(rtc_generic_ops));

return PTR_ERR_OR_ZERO(pdev);
}
arch_initcall(sh03_time_init);
9 changes: 0 additions & 9 deletions arch/sh/boards/mach-sh03/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ static void __init init_sh03_IRQ(void)
plat_irq_setup_pins(IRQ_MODE_IRQ);
}

/* arch/sh/boards/sh03/rtc.c */
void sh03_time_init(void);

static void __init sh03_setup(char **cmdline_p)
{
board_time_init = sh03_time_init;
}

static struct resource cf_ide_resources[] = {
[0] = {
.start = 0x1f0,
Expand Down Expand Up @@ -101,6 +93,5 @@ device_initcall(sh03_devices_setup);

static struct sh_machine_vector mv_sh03 __initmv = {
.mv_name = "Interface (CTP/PCI-SH03)",
.mv_setup = sh03_setup,
.mv_init_irq = init_sh03_IRQ,
};
8 changes: 0 additions & 8 deletions arch/sh/boards/of-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,10 @@ static void __init sh_of_mem_reserve(void)
early_init_fdt_scan_reserved_mem();
}

static void __init sh_of_time_init(void)
{
pr_info("SH generic board support: scanning for clocksource devices\n");
timer_probe();
}

static void __init sh_of_setup(char **cmdline_p)
{
struct device_node *root;

board_time_init = sh_of_time_init;

sh_mv.mv_name = "Unknown SH model";
root = of_find_node_by_path("/");
if (root) {
Expand Down
2 changes: 2 additions & 0 deletions arch/sh/configs/dreamcast_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ CONFIG_PROC_KCORE=y
CONFIG_TMPFS=y
CONFIG_HUGETLBFS=y
# CONFIG_CRYPTO_ANSI_CPRNG is not set
CONFIG_RTC_CLASS=y
CONFIG_RTC_DRV_GENERIC=y
2 changes: 2 additions & 0 deletions arch/sh/configs/sh03_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,5 @@ CONFIG_CRYPTO_SHA1=y
CONFIG_CRYPTO_DEFLATE=y
# CONFIG_CRYPTO_ANSI_CPRNG is not set
CONFIG_CRC_CCITT=y
CONFIG_RTC_CLASS=y
CONFIG_RTC_DRV_GENERIC=y
3 changes: 0 additions & 3 deletions arch/sh/include/asm/rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
#define _ASM_RTC_H

void time_init(void);
extern void (*board_time_init)(void);
extern void (*rtc_sh_get_time)(struct timespec *);
extern int (*rtc_sh_set_time)(const time_t);

#define RTC_CAP_4_DIGIT_YEAR (1 << 0)

Expand Down
1 change: 0 additions & 1 deletion arch/sh/include/mach-dreamcast/mach/sysasic.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
/* arch/sh/boards/mach-dreamcast/irq.c */
extern int systemasic_irq_demux(int);
extern void systemasic_irq_init(void);
extern void aica_time_init(void);

#endif /* __ASM_SH_DREAMCAST_SYSASIC_H */

74 changes: 1 addition & 73 deletions arch/sh/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,77 +22,6 @@
#include <asm/clock.h>
#include <asm/rtc.h>

/* Dummy RTC ops */
static void null_rtc_get_time(struct timespec *tv)
{
tv->tv_sec = mktime(2000, 1, 1, 0, 0, 0);
tv->tv_nsec = 0;
}

static int null_rtc_set_time(const time_t secs)
{
return 0;
}

void (*rtc_sh_get_time)(struct timespec *) = null_rtc_get_time;
int (*rtc_sh_set_time)(const time_t) = null_rtc_set_time;

void read_persistent_clock(struct timespec *ts)
{
rtc_sh_get_time(ts);
}

#ifdef CONFIG_GENERIC_CMOS_UPDATE
int update_persistent_clock(struct timespec now)
{
return rtc_sh_set_time(now.tv_sec);
}
#endif

static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm)
{
struct timespec tv;

rtc_sh_get_time(&tv);
rtc_time_to_tm(tv.tv_sec, tm);
return 0;
}

static int rtc_generic_set_time(struct device *dev, struct rtc_time *tm)
{
unsigned long secs;

rtc_tm_to_time(tm, &secs);
if ((rtc_sh_set_time == null_rtc_set_time) ||
(rtc_sh_set_time(secs) < 0))
return -EOPNOTSUPP;

return 0;
}

static const struct rtc_class_ops rtc_generic_ops = {
.read_time = rtc_generic_get_time,
.set_time = rtc_generic_set_time,
};

static int __init rtc_generic_init(void)
{
struct platform_device *pdev;

if (rtc_sh_get_time == null_rtc_get_time)
return -ENODEV;

pdev = platform_device_register_data(NULL, "rtc-generic", -1,
&rtc_generic_ops,
sizeof(rtc_generic_ops));


return PTR_ERR_OR_ZERO(pdev);
}
device_initcall(rtc_generic_init);

void (*board_time_init)(void);

static void __init sh_late_time_init(void)
{
/*
Expand All @@ -110,8 +39,7 @@ static void __init sh_late_time_init(void)

void __init time_init(void)
{
if (board_time_init)
board_time_init();
timer_probe();

clk_init();

Expand Down
Loading

0 comments on commit b12a912

Please sign in to comment.