diff options
| -rw-r--r-- | arch/tile/Kconfig | 1 | ||||
| -rw-r--r-- | arch/tile/gxio/mpipe.c | 37 | ||||
| -rw-r--r-- | arch/tile/include/asm/sections.h | 3 | ||||
| -rw-r--r-- | arch/tile/include/asm/vdso.h | 20 | ||||
| -rw-r--r-- | arch/tile/include/uapi/arch/sim_def.h | 10 | ||||
| -rw-r--r-- | arch/tile/kernel/time.c | 61 | ||||
| -rw-r--r-- | arch/tile/kernel/traps.c | 2 | ||||
| -rw-r--r-- | arch/tile/kernel/vdso/vdso.lds.S | 2 | ||||
| -rw-r--r-- | arch/tile/kernel/vdso/vgettimeofday.c | 176 | ||||
| -rw-r--r-- | arch/tile/kernel/vmlinux.lds.S | 2 | ||||
| -rw-r--r-- | arch/tile/mm/init.c | 12 | ||||
| -rw-r--r-- | drivers/char/tile-srom.c | 13 |
12 files changed, 245 insertions, 94 deletions
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig index 7fcd492adbfc..7cca41842a9e 100644 --- a/arch/tile/Kconfig +++ b/arch/tile/Kconfig | |||
| @@ -134,6 +134,7 @@ config TILEGX | |||
| 134 | select HAVE_KPROBES | 134 | select HAVE_KPROBES |
| 135 | select HAVE_KRETPROBES | 135 | select HAVE_KRETPROBES |
| 136 | select HAVE_ARCH_KGDB | 136 | select HAVE_ARCH_KGDB |
| 137 | select ARCH_SUPPORTS_ATOMIC_RMW | ||
| 137 | 138 | ||
| 138 | config TILEPRO | 139 | config TILEPRO |
| 139 | def_bool !TILEGX | 140 | def_bool !TILEGX |
diff --git a/arch/tile/gxio/mpipe.c b/arch/tile/gxio/mpipe.c index 5301a9ffbae1..320ff5e6e61e 100644 --- a/arch/tile/gxio/mpipe.c +++ b/arch/tile/gxio/mpipe.c | |||
| @@ -29,6 +29,32 @@ | |||
| 29 | /* HACK: Avoid pointless "shadow" warnings. */ | 29 | /* HACK: Avoid pointless "shadow" warnings. */ |
| 30 | #define link link_shadow | 30 | #define link link_shadow |
| 31 | 31 | ||
| 32 | /** | ||
| 33 | * strscpy - Copy a C-string into a sized buffer, but only if it fits | ||
| 34 | * @dest: Where to copy the string to | ||
| 35 | * @src: Where to copy the string from | ||
| 36 | * @size: size of destination buffer | ||
| 37 | * | ||
| 38 | * Use this routine to avoid copying too-long strings. | ||
| 39 | * The routine returns the total number of bytes copied | ||
| 40 | * (including the trailing NUL) or zero if the buffer wasn't | ||
| 41 | * big enough. To ensure that programmers pay attention | ||
| 42 | * to the return code, the destination has a single NUL | ||
| 43 | * written at the front (if size is non-zero) when the | ||
| 44 | * buffer is not big enough. | ||
| 45 | */ | ||
| 46 | static size_t strscpy(char *dest, const char *src, size_t size) | ||
| 47 | { | ||
| 48 | size_t len = strnlen(src, size) + 1; | ||
| 49 | if (len > size) { | ||
| 50 | if (size) | ||
| 51 | dest[0] = '\0'; | ||
| 52 | return 0; | ||
| 53 | } | ||
| 54 | memcpy(dest, src, len); | ||
| 55 | return len; | ||
| 56 | } | ||
| 57 | |||
| 32 | int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index) | 58 | int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index) |
| 33 | { | 59 | { |
| 34 | char file[32]; | 60 | char file[32]; |
| @@ -511,8 +537,8 @@ int gxio_mpipe_link_instance(const char *link_name) | |||
| 511 | if (!context) | 537 | if (!context) |
| 512 | return GXIO_ERR_NO_DEVICE; | 538 | return GXIO_ERR_NO_DEVICE; |
| 513 | 539 | ||
| 514 | strncpy(name.name, link_name, sizeof(name.name)); | 540 | if (strscpy(name.name, link_name, sizeof(name.name)) == 0) |
| 515 | name.name[GXIO_MPIPE_LINK_NAME_LEN - 1] = '\0'; | 541 | return GXIO_ERR_NO_DEVICE; |
| 516 | 542 | ||
| 517 | return gxio_mpipe_info_instance_aux(context, name); | 543 | return gxio_mpipe_info_instance_aux(context, name); |
| 518 | } | 544 | } |
| @@ -529,7 +555,8 @@ int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac) | |||
| 529 | 555 | ||
| 530 | rv = gxio_mpipe_info_enumerate_aux(context, idx, &name, &mac); | 556 | rv = gxio_mpipe_info_enumerate_aux(context, idx, &name, &mac); |
| 531 | if (rv >= 0) { | 557 | if (rv >= 0) { |
| 532 | strncpy(link_name, name.name, sizeof(name.name)); | 558 | if (strscpy(link_name, name.name, sizeof(name.name)) == 0) |
| 559 | return GXIO_ERR_INVAL_MEMORY_SIZE; | ||
| 533 | memcpy(link_mac, mac.mac, sizeof(mac.mac)); | 560 | memcpy(link_mac, mac.mac, sizeof(mac.mac)); |
| 534 | } | 561 | } |
| 535 | 562 | ||
| @@ -545,8 +572,8 @@ int gxio_mpipe_link_open(gxio_mpipe_link_t *link, | |||
| 545 | _gxio_mpipe_link_name_t name; | 572 | _gxio_mpipe_link_name_t name; |
| 546 | int rv; | 573 | int rv; |
| 547 | 574 | ||
| 548 | strncpy(name.name, link_name, sizeof(name.name)); | 575 | if (strscpy(name.name, link_name, sizeof(name.name)) == 0) |
| 549 | name.name[GXIO_MPIPE_LINK_NAME_LEN - 1] = '\0'; | 576 | return GXIO_ERR_NO_DEVICE; |
| 550 | 577 | ||
| 551 | rv = gxio_mpipe_link_open_aux(context, name, flags); | 578 | rv = gxio_mpipe_link_open_aux(context, name, flags); |
| 552 | if (rv < 0) | 579 | if (rv < 0) |
diff --git a/arch/tile/include/asm/sections.h b/arch/tile/include/asm/sections.h index 5d5d3b739a6b..86a746243dc8 100644 --- a/arch/tile/include/asm/sections.h +++ b/arch/tile/include/asm/sections.h | |||
| @@ -19,9 +19,6 @@ | |||
| 19 | 19 | ||
| 20 | #include <asm-generic/sections.h> | 20 | #include <asm-generic/sections.h> |
| 21 | 21 | ||
| 22 | /* Text and data are at different areas in the kernel VA space. */ | ||
| 23 | extern char _sinitdata[], _einitdata[]; | ||
| 24 | |||
| 25 | /* Write-once data is writable only till the end of initialization. */ | 22 | /* Write-once data is writable only till the end of initialization. */ |
| 26 | extern char __w1data_begin[], __w1data_end[]; | 23 | extern char __w1data_begin[], __w1data_end[]; |
| 27 | 24 | ||
diff --git a/arch/tile/include/asm/vdso.h b/arch/tile/include/asm/vdso.h index 9f6a78d665fa..9b069692153f 100644 --- a/arch/tile/include/asm/vdso.h +++ b/arch/tile/include/asm/vdso.h | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #ifndef __TILE_VDSO_H__ | 15 | #ifndef __TILE_VDSO_H__ |
| 16 | #define __TILE_VDSO_H__ | 16 | #define __TILE_VDSO_H__ |
| 17 | 17 | ||
| 18 | #include <linux/seqlock.h> | ||
| 18 | #include <linux/types.h> | 19 | #include <linux/types.h> |
| 19 | 20 | ||
| 20 | /* | 21 | /* |
| @@ -26,15 +27,20 @@ | |||
| 26 | */ | 27 | */ |
| 27 | 28 | ||
| 28 | struct vdso_data { | 29 | struct vdso_data { |
| 29 | __u64 tz_update_count; /* Timezone atomicity ctr */ | 30 | seqcount_t tz_seq; /* Timezone seqlock */ |
| 30 | __u64 tb_update_count; /* Timebase atomicity ctr */ | 31 | seqcount_t tb_seq; /* Timebase seqlock */ |
| 31 | __u64 xtime_tod_stamp; /* TOD clock for xtime */ | 32 | __u64 cycle_last; /* TOD clock for xtime */ |
| 32 | __u64 xtime_clock_sec; /* Kernel time second */ | 33 | __u64 mask; /* Cycle mask */ |
| 33 | __u64 xtime_clock_nsec; /* Kernel time nanosecond */ | ||
| 34 | __u64 wtom_clock_sec; /* Wall to monotonic clock second */ | ||
| 35 | __u64 wtom_clock_nsec; /* Wall to monotonic clock nanosecond */ | ||
| 36 | __u32 mult; /* Cycle to nanosecond multiplier */ | 34 | __u32 mult; /* Cycle to nanosecond multiplier */ |
| 37 | __u32 shift; /* Cycle to nanosecond divisor (power of two) */ | 35 | __u32 shift; /* Cycle to nanosecond divisor (power of two) */ |
| 36 | __u64 wall_time_sec; | ||
| 37 | __u64 wall_time_snsec; | ||
| 38 | __u64 monotonic_time_sec; | ||
| 39 | __u64 monotonic_time_snsec; | ||
| 40 | __u64 wall_time_coarse_sec; | ||
| 41 | __u64 wall_time_coarse_nsec; | ||
| 42 | __u64 monotonic_time_coarse_sec; | ||
| 43 | __u64 monotonic_time_coarse_nsec; | ||
| 38 | __u32 tz_minuteswest; /* Minutes west of Greenwich */ | 44 | __u32 tz_minuteswest; /* Minutes west of Greenwich */ |
| 39 | __u32 tz_dsttime; /* Type of dst correction */ | 45 | __u32 tz_dsttime; /* Type of dst correction */ |
| 40 | }; | 46 | }; |
diff --git a/arch/tile/include/uapi/arch/sim_def.h b/arch/tile/include/uapi/arch/sim_def.h index 4b44a2b6a09a..1c069537ae41 100644 --- a/arch/tile/include/uapi/arch/sim_def.h +++ b/arch/tile/include/uapi/arch/sim_def.h | |||
| @@ -360,19 +360,19 @@ | |||
| 360 | * @{ | 360 | * @{ |
| 361 | */ | 361 | */ |
| 362 | 362 | ||
| 363 | /** Use with with SIM_PROFILER_CHIP_xxx to control the memory controllers. */ | 363 | /** Use with SIM_PROFILER_CHIP_xxx to control the memory controllers. */ |
| 364 | #define SIM_CHIP_MEMCTL 0x001 | 364 | #define SIM_CHIP_MEMCTL 0x001 |
| 365 | 365 | ||
| 366 | /** Use with with SIM_PROFILER_CHIP_xxx to control the XAUI interface. */ | 366 | /** Use with SIM_PROFILER_CHIP_xxx to control the XAUI interface. */ |
| 367 | #define SIM_CHIP_XAUI 0x002 | 367 | #define SIM_CHIP_XAUI 0x002 |
| 368 | 368 | ||
| 369 | /** Use with with SIM_PROFILER_CHIP_xxx to control the PCIe interface. */ | 369 | /** Use with SIM_PROFILER_CHIP_xxx to control the PCIe interface. */ |
| 370 | #define SIM_CHIP_PCIE 0x004 | 370 | #define SIM_CHIP_PCIE 0x004 |
| 371 | 371 | ||
| 372 | /** Use with with SIM_PROFILER_CHIP_xxx to control the MPIPE interface. */ | 372 | /** Use with SIM_PROFILER_CHIP_xxx to control the MPIPE interface. */ |
| 373 | #define SIM_CHIP_MPIPE 0x008 | 373 | #define SIM_CHIP_MPIPE 0x008 |
| 374 | 374 | ||
| 375 | /** Use with with SIM_PROFILER_CHIP_xxx to control the TRIO interface. */ | 375 | /** Use with SIM_PROFILER_CHIP_xxx to control the TRIO interface. */ |
| 376 | #define SIM_CHIP_TRIO 0x010 | 376 | #define SIM_CHIP_TRIO 0x010 |
| 377 | 377 | ||
| 378 | /** Reference all chip devices. */ | 378 | /** Reference all chip devices. */ |
diff --git a/arch/tile/kernel/time.c b/arch/tile/kernel/time.c index d8fbc289e680..c1b362277fb7 100644 --- a/arch/tile/kernel/time.c +++ b/arch/tile/kernel/time.c | |||
| @@ -249,33 +249,52 @@ cycles_t ns2cycles(unsigned long nsecs) | |||
| 249 | 249 | ||
| 250 | void update_vsyscall_tz(void) | 250 | void update_vsyscall_tz(void) |
| 251 | { | 251 | { |
| 252 | /* Userspace gettimeofday will spin while this value is odd. */ | 252 | write_seqcount_begin(&vdso_data->tz_seq); |
| 253 | ++vdso_data->tz_update_count; | ||
| 254 | smp_wmb(); | ||
| 255 | vdso_data->tz_minuteswest = sys_tz.tz_minuteswest; | 253 | vdso_data->tz_minuteswest = sys_tz.tz_minuteswest; |
| 256 | vdso_data->tz_dsttime = sys_tz.tz_dsttime; | 254 | vdso_data->tz_dsttime = sys_tz.tz_dsttime; |
| 257 | smp_wmb(); | 255 | write_seqcount_end(&vdso_data->tz_seq); |
| 258 | ++vdso_data->tz_update_count; | ||
| 259 | } | 256 | } |
| 260 | 257 | ||
| 261 | void update_vsyscall(struct timekeeper *tk) | 258 | void update_vsyscall(struct timekeeper *tk) |
| 262 | { | 259 | { |
| 263 | struct timespec *wtm = &tk->wall_to_monotonic; | 260 | if (tk->tkr.clock != &cycle_counter_cs) |
| 264 | struct clocksource *clock = tk->tkr.clock; | ||
| 265 | |||
| 266 | if (clock != &cycle_counter_cs) | ||
| 267 | return; | 261 | return; |
| 268 | 262 | ||
| 269 | /* Userspace gettimeofday will spin while this value is odd. */ | 263 | write_seqcount_begin(&vdso_data->tb_seq); |
| 270 | ++vdso_data->tb_update_count; | 264 | |
| 271 | smp_wmb(); | 265 | vdso_data->cycle_last = tk->tkr.cycle_last; |
| 272 | vdso_data->xtime_tod_stamp = tk->tkr.cycle_last; | 266 | vdso_data->mask = tk->tkr.mask; |
| 273 | vdso_data->xtime_clock_sec = tk->xtime_sec; | 267 | vdso_data->mult = tk->tkr.mult; |
| 274 | vdso_data->xtime_clock_nsec = tk->tkr.xtime_nsec; | 268 | vdso_data->shift = tk->tkr.shift; |
| 275 | vdso_data->wtom_clock_sec = wtm->tv_sec; | 269 | |
| 276 | vdso_data->wtom_clock_nsec = wtm->tv_nsec; | 270 | vdso_data->wall_time_sec = tk->xtime_sec; |
| 277 | vdso_data->mult = tk->tkr.mult; | 271 | vdso_data->wall_time_snsec = tk->tkr.xtime_nsec; |
| 278 | vdso_data->shift = tk->tkr.shift; | 272 | |
| 279 | smp_wmb(); | 273 | vdso_data->monotonic_time_sec = tk->xtime_sec |
| 280 | ++vdso_data->tb_update_count; | 274 | + tk->wall_to_monotonic.tv_sec; |
| 275 | vdso_data->monotonic_time_snsec = tk->tkr.xtime_nsec | ||
| 276 | + ((u64)tk->wall_to_monotonic.tv_nsec | ||
| 277 | << tk->tkr.shift); | ||
| 278 | while (vdso_data->monotonic_time_snsec >= | ||
| 279 | (((u64)NSEC_PER_SEC) << tk->tkr.shift)) { | ||
| 280 | vdso_data->monotonic_time_snsec -= | ||
| 281 | ((u64)NSEC_PER_SEC) << tk->tkr.shift; | ||
| 282 | vdso_data->monotonic_time_sec++; | ||
| 283 | } | ||
| 284 | |||
| 285 | vdso_data->wall_time_coarse_sec = tk->xtime_sec; | ||
| 286 | vdso_data->wall_time_coarse_nsec = (long)(tk->tkr.xtime_nsec >> | ||
| 287 | tk->tkr.shift); | ||
| 288 | |||
| 289 | vdso_data->monotonic_time_coarse_sec = | ||
| 290 | vdso_data->wall_time_coarse_sec + tk->wall_to_monotonic.tv_sec; | ||
| 291 | vdso_data->monotonic_time_coarse_nsec = | ||
| 292 | vdso_data->wall_time_coarse_nsec + tk->wall_to_monotonic.tv_nsec; | ||
| 293 | |||
| 294 | while (vdso_data->monotonic_time_coarse_nsec >= NSEC_PER_SEC) { | ||
| 295 | vdso_data->monotonic_time_coarse_nsec -= NSEC_PER_SEC; | ||
| 296 | vdso_data->monotonic_time_coarse_sec++; | ||
| 297 | } | ||
| 298 | |||
| 299 | write_seqcount_end(&vdso_data->tb_seq); | ||
| 281 | } | 300 | } |
diff --git a/arch/tile/kernel/traps.c b/arch/tile/kernel/traps.c index f3ceb6308e42..86900ccd4977 100644 --- a/arch/tile/kernel/traps.c +++ b/arch/tile/kernel/traps.c | |||
| @@ -277,7 +277,7 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num, | |||
| 277 | if (fixup_exception(regs)) /* ILL_TRANS or UNALIGN_DATA */ | 277 | if (fixup_exception(regs)) /* ILL_TRANS or UNALIGN_DATA */ |
| 278 | return; | 278 | return; |
| 279 | if (fault_num >= 0 && | 279 | if (fault_num >= 0 && |
| 280 | fault_num < sizeof(int_name)/sizeof(int_name[0]) && | 280 | fault_num < ARRAY_SIZE(int_name) && |
| 281 | int_name[fault_num] != NULL) | 281 | int_name[fault_num] != NULL) |
| 282 | name = int_name[fault_num]; | 282 | name = int_name[fault_num]; |
| 283 | else | 283 | else |
diff --git a/arch/tile/kernel/vdso/vdso.lds.S b/arch/tile/kernel/vdso/vdso.lds.S index 041cd6c39c83..731529f3f06f 100644 --- a/arch/tile/kernel/vdso/vdso.lds.S +++ b/arch/tile/kernel/vdso/vdso.lds.S | |||
| @@ -82,6 +82,8 @@ VERSION | |||
| 82 | __vdso_rt_sigreturn; | 82 | __vdso_rt_sigreturn; |
| 83 | __vdso_gettimeofday; | 83 | __vdso_gettimeofday; |
| 84 | gettimeofday; | 84 | gettimeofday; |
| 85 | __vdso_clock_gettime; | ||
| 86 | clock_gettime; | ||
| 85 | local:*; | 87 | local:*; |
| 86 | }; | 88 | }; |
| 87 | } | 89 | } |
diff --git a/arch/tile/kernel/vdso/vgettimeofday.c b/arch/tile/kernel/vdso/vgettimeofday.c index e933fb9fbf5c..8bb21eda07d8 100644 --- a/arch/tile/kernel/vdso/vgettimeofday.c +++ b/arch/tile/kernel/vdso/vgettimeofday.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #define VDSO_BUILD /* avoid some shift warnings for -m32 in <asm/page.h> */ | 15 | #define VDSO_BUILD /* avoid some shift warnings for -m32 in <asm/page.h> */ |
| 16 | #include <linux/time.h> | 16 | #include <linux/time.h> |
| 17 | #include <asm/timex.h> | 17 | #include <asm/timex.h> |
| 18 | #include <asm/unistd.h> | ||
| 18 | #include <asm/vdso.h> | 19 | #include <asm/vdso.h> |
| 19 | 20 | ||
| 20 | #if CHIP_HAS_SPLIT_CYCLE() | 21 | #if CHIP_HAS_SPLIT_CYCLE() |
| @@ -35,6 +36,11 @@ static inline cycles_t get_cycles_inline(void) | |||
| 35 | #define get_cycles get_cycles_inline | 36 | #define get_cycles get_cycles_inline |
| 36 | #endif | 37 | #endif |
| 37 | 38 | ||
| 39 | struct syscall_return_value { | ||
| 40 | long value; | ||
| 41 | long error; | ||
| 42 | }; | ||
| 43 | |||
| 38 | /* | 44 | /* |
| 39 | * Find out the vDSO data page address in the process address space. | 45 | * Find out the vDSO data page address in the process address space. |
| 40 | */ | 46 | */ |
| @@ -50,59 +56,143 @@ inline unsigned long get_datapage(void) | |||
| 50 | return ret; | 56 | return ret; |
| 51 | } | 57 | } |
| 52 | 58 | ||
| 53 | int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz) | 59 | static inline u64 vgetsns(struct vdso_data *vdso) |
| 60 | { | ||
| 61 | return ((get_cycles() - vdso->cycle_last) & vdso->mask) * vdso->mult; | ||
| 62 | } | ||
| 63 | |||
| 64 | static inline int do_realtime(struct vdso_data *vdso, struct timespec *ts) | ||
| 65 | { | ||
| 66 | unsigned count; | ||
| 67 | u64 ns; | ||
| 68 | |||
| 69 | do { | ||
| 70 | count = read_seqcount_begin(&vdso->tb_seq); | ||
| 71 | ts->tv_sec = vdso->wall_time_sec; | ||
| 72 | ns = vdso->wall_time_snsec; | ||
| 73 | ns += vgetsns(vdso); | ||
| 74 | ns >>= vdso->shift; | ||
| 75 | } while (unlikely(read_seqcount_retry(&vdso->tb_seq, count))); | ||
| 76 | |||
| 77 | ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns); | ||
| 78 | ts->tv_nsec = ns; | ||
| 79 | |||
| 80 | return 0; | ||
| 81 | } | ||
| 82 | |||
| 83 | static inline int do_monotonic(struct vdso_data *vdso, struct timespec *ts) | ||
| 84 | { | ||
| 85 | unsigned count; | ||
| 86 | u64 ns; | ||
| 87 | |||
| 88 | do { | ||
| 89 | count = read_seqcount_begin(&vdso->tb_seq); | ||
| 90 | ts->tv_sec = vdso->monotonic_time_sec; | ||
| 91 | ns = vdso->monotonic_time_snsec; | ||
| 92 | ns += vgetsns(vdso); | ||
| 93 | ns >>= vdso->shift; | ||
| 94 | } while (unlikely(read_seqcount_retry(&vdso->tb_seq, count))); | ||
| 95 | |||
| 96 | ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns); | ||
| 97 | ts->tv_nsec = ns; | ||
| 98 | |||
| 99 | return 0; | ||
| 100 | } | ||
| 101 | |||
| 102 | static inline int do_realtime_coarse(struct vdso_data *vdso, | ||
| 103 | struct timespec *ts) | ||
| 104 | { | ||
| 105 | unsigned count; | ||
| 106 | |||
| 107 | do { | ||
| 108 | count = read_seqcount_begin(&vdso->tb_seq); | ||
| 109 | ts->tv_sec = vdso->wall_time_coarse_sec; | ||
| 110 | ts->tv_nsec = vdso->wall_time_coarse_nsec; | ||
| 111 | } while (unlikely(read_seqcount_retry(&vdso->tb_seq, count))); | ||
| 112 | |||
| 113 | return 0; | ||
| 114 | } | ||
| 115 | |||
| 116 | static inline int do_monotonic_coarse(struct vdso_data *vdso, | ||
| 117 | struct timespec *ts) | ||
| 54 | { | 118 | { |
| 55 | cycles_t cycles; | 119 | unsigned count; |
| 56 | unsigned long count, sec, ns; | 120 | |
| 57 | volatile struct vdso_data *vdso_data; | 121 | do { |
| 122 | count = read_seqcount_begin(&vdso->tb_seq); | ||
| 123 | ts->tv_sec = vdso->monotonic_time_coarse_sec; | ||
| 124 | ts->tv_nsec = vdso->monotonic_time_coarse_nsec; | ||
| 125 | } while (unlikely(read_seqcount_retry(&vdso->tb_seq, count))); | ||
| 126 | |||
| 127 | return 0; | ||
| 128 | } | ||
| 129 | |||
| 130 | struct syscall_return_value __vdso_gettimeofday(struct timeval *tv, | ||
| 131 | struct timezone *tz) | ||
| 132 | { | ||
| 133 | struct syscall_return_value ret = { 0, 0 }; | ||
| 134 | unsigned count; | ||
| 135 | struct vdso_data *vdso = (struct vdso_data *)get_datapage(); | ||
| 58 | 136 | ||
| 59 | vdso_data = (struct vdso_data *)get_datapage(); | ||
| 60 | /* The use of the timezone is obsolete, normally tz is NULL. */ | 137 | /* The use of the timezone is obsolete, normally tz is NULL. */ |
| 61 | if (unlikely(tz != NULL)) { | 138 | if (unlikely(tz != NULL)) { |
| 62 | while (1) { | 139 | do { |
| 63 | /* Spin until the update finish. */ | 140 | count = read_seqcount_begin(&vdso->tz_seq); |
| 64 | count = vdso_data->tz_update_count; | 141 | tz->tz_minuteswest = vdso->tz_minuteswest; |
| 65 | if (count & 1) | 142 | tz->tz_dsttime = vdso->tz_dsttime; |
| 66 | continue; | 143 | } while (unlikely(read_seqcount_retry(&vdso->tz_seq, count))); |
| 67 | |||
| 68 | tz->tz_minuteswest = vdso_data->tz_minuteswest; | ||
| 69 | tz->tz_dsttime = vdso_data->tz_dsttime; | ||
| 70 | |||
| 71 | /* Check whether updated, read again if so. */ | ||
| 72 | if (count == vdso_data->tz_update_count) | ||
| 73 | break; | ||
| 74 | } | ||
| 75 | } | 144 | } |
| 76 | 145 | ||
| 77 | if (unlikely(tv == NULL)) | 146 | if (unlikely(tv == NULL)) |
| 78 | return 0; | 147 | return ret; |
| 79 | |||
| 80 | while (1) { | ||
| 81 | /* Spin until the update finish. */ | ||
| 82 | count = vdso_data->tb_update_count; | ||
| 83 | if (count & 1) | ||
| 84 | continue; | ||
| 85 | |||
| 86 | sec = vdso_data->xtime_clock_sec; | ||
| 87 | cycles = get_cycles() - vdso_data->xtime_tod_stamp; | ||
| 88 | ns = (cycles * vdso_data->mult) + vdso_data->xtime_clock_nsec; | ||
| 89 | ns >>= vdso_data->shift; | ||
| 90 | |||
| 91 | if (ns >= NSEC_PER_SEC) { | ||
| 92 | ns -= NSEC_PER_SEC; | ||
| 93 | sec += 1; | ||
| 94 | } | ||
| 95 | |||
| 96 | /* Check whether updated, read again if so. */ | ||
| 97 | if (count == vdso_data->tb_update_count) | ||
| 98 | break; | ||
| 99 | } | ||
| 100 | 148 | ||
| 101 | tv->tv_sec = sec; | 149 | do_realtime(vdso, (struct timespec *)tv); |
| 102 | tv->tv_usec = ns / 1000; | 150 | tv->tv_usec /= 1000; |
| 103 | 151 | ||
| 104 | return 0; | 152 | return ret; |
| 105 | } | 153 | } |
| 106 | 154 | ||
| 107 | int gettimeofday(struct timeval *tv, struct timezone *tz) | 155 | int gettimeofday(struct timeval *tv, struct timezone *tz) |
| 108 | __attribute__((weak, alias("__vdso_gettimeofday"))); | 156 | __attribute__((weak, alias("__vdso_gettimeofday"))); |
| 157 | |||
| 158 | static struct syscall_return_value vdso_fallback_gettime(long clock, | ||
| 159 | struct timespec *ts) | ||
| 160 | { | ||
| 161 | struct syscall_return_value ret; | ||
| 162 | __asm__ __volatile__ ( | ||
| 163 | "swint1" | ||
| 164 | : "=R00" (ret.value), "=R01" (ret.error) | ||
| 165 | : "R10" (__NR_clock_gettime), "R00" (clock), "R01" (ts) | ||
| 166 | : "r2", "r3", "r4", "r5", "r6", "r7", | ||
| 167 | "r8", "r9", "r11", "r12", "r13", "r14", "r15", | ||
| 168 | "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", | ||
| 169 | "r24", "r25", "r26", "r27", "r28", "r29", "memory"); | ||
| 170 | return ret; | ||
| 171 | } | ||
| 172 | |||
| 173 | struct syscall_return_value __vdso_clock_gettime(clockid_t clock, | ||
| 174 | struct timespec *ts) | ||
| 175 | { | ||
| 176 | struct vdso_data *vdso = (struct vdso_data *)get_datapage(); | ||
| 177 | struct syscall_return_value ret = { 0, 0 }; | ||
| 178 | |||
| 179 | switch (clock) { | ||
| 180 | case CLOCK_REALTIME: | ||
| 181 | do_realtime(vdso, ts); | ||
| 182 | return ret; | ||
| 183 | case CLOCK_MONOTONIC: | ||
| 184 | do_monotonic(vdso, ts); | ||
| 185 | return ret; | ||
| 186 | case CLOCK_REALTIME_COARSE: | ||
| 187 | do_realtime_coarse(vdso, ts); | ||
| 188 | return ret; | ||
| 189 | case CLOCK_MONOTONIC_COARSE: | ||
| 190 | do_monotonic_coarse(vdso, ts); | ||
| 191 | return ret; | ||
| 192 | default: | ||
| 193 | return vdso_fallback_gettime(clock, ts); | ||
| 194 | } | ||
| 195 | } | ||
| 196 | |||
| 197 | int clock_gettime(clockid_t clock, struct timespec *ts) | ||
| 198 | __attribute__((weak, alias("__vdso_clock_gettime"))); | ||
diff --git a/arch/tile/kernel/vmlinux.lds.S b/arch/tile/kernel/vmlinux.lds.S index f1819423ffc9..0e059a0101ea 100644 --- a/arch/tile/kernel/vmlinux.lds.S +++ b/arch/tile/kernel/vmlinux.lds.S | |||
| @@ -66,11 +66,9 @@ SECTIONS | |||
| 66 | 66 | ||
| 67 | . = ALIGN(PAGE_SIZE); | 67 | . = ALIGN(PAGE_SIZE); |
| 68 | __init_begin = .; | 68 | __init_begin = .; |
| 69 | VMLINUX_SYMBOL(_sinitdata) = .; | ||
| 70 | INIT_DATA_SECTION(16) :data =0 | 69 | INIT_DATA_SECTION(16) :data =0 |
| 71 | PERCPU_SECTION(L2_CACHE_BYTES) | 70 | PERCPU_SECTION(L2_CACHE_BYTES) |
| 72 | . = ALIGN(PAGE_SIZE); | 71 | . = ALIGN(PAGE_SIZE); |
| 73 | VMLINUX_SYMBOL(_einitdata) = .; | ||
| 74 | __init_end = .; | 72 | __init_end = .; |
| 75 | 73 | ||
| 76 | _sdata = .; /* Start of data section */ | 74 | _sdata = .; /* Start of data section */ |
diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c index bfb3127b4df9..a092e393bd20 100644 --- a/arch/tile/mm/init.c +++ b/arch/tile/mm/init.c | |||
| @@ -254,8 +254,8 @@ static pgprot_t __init init_pgprot(ulong address) | |||
| 254 | * Everything else that isn't data or bss is heap, so mark it | 254 | * Everything else that isn't data or bss is heap, so mark it |
| 255 | * with the initial heap home (hash-for-home, or this cpu). This | 255 | * with the initial heap home (hash-for-home, or this cpu). This |
| 256 | * includes any addresses after the loaded image and any address before | 256 | * includes any addresses after the loaded image and any address before |
| 257 | * _einitdata, since we already captured the case of text before | 257 | * __init_end, since we already captured the case of text before |
| 258 | * _sinittext, and __pa(einittext) is approximately __pa(sinitdata). | 258 | * _sinittext, and __pa(einittext) is approximately __pa(__init_begin). |
| 259 | * | 259 | * |
| 260 | * All the LOWMEM pages that we mark this way will get their | 260 | * All the LOWMEM pages that we mark this way will get their |
| 261 | * struct page homecache properly marked later, in set_page_homes(). | 261 | * struct page homecache properly marked later, in set_page_homes(). |
| @@ -263,7 +263,7 @@ static pgprot_t __init init_pgprot(ulong address) | |||
| 263 | * homes, but with a zero free_time we don't have to actually | 263 | * homes, but with a zero free_time we don't have to actually |
| 264 | * do a flush action the first time we use them, either. | 264 | * do a flush action the first time we use them, either. |
| 265 | */ | 265 | */ |
| 266 | if (address >= (ulong) _end || address < (ulong) _einitdata) | 266 | if (address >= (ulong) _end || address < (ulong) __init_end) |
| 267 | return construct_pgprot(PAGE_KERNEL, initial_heap_home()); | 267 | return construct_pgprot(PAGE_KERNEL, initial_heap_home()); |
| 268 | 268 | ||
| 269 | /* Use hash-for-home if requested for data/bss. */ | 269 | /* Use hash-for-home if requested for data/bss. */ |
| @@ -632,7 +632,7 @@ int devmem_is_allowed(unsigned long pagenr) | |||
| 632 | { | 632 | { |
| 633 | return pagenr < kaddr_to_pfn(_end) && | 633 | return pagenr < kaddr_to_pfn(_end) && |
| 634 | !(pagenr >= kaddr_to_pfn(&init_thread_union) || | 634 | !(pagenr >= kaddr_to_pfn(&init_thread_union) || |
| 635 | pagenr < kaddr_to_pfn(_einitdata)) && | 635 | pagenr < kaddr_to_pfn(__init_end)) && |
| 636 | !(pagenr >= kaddr_to_pfn(_sinittext) || | 636 | !(pagenr >= kaddr_to_pfn(_sinittext) || |
| 637 | pagenr <= kaddr_to_pfn(_einittext-1)); | 637 | pagenr <= kaddr_to_pfn(_einittext-1)); |
| 638 | } | 638 | } |
| @@ -975,8 +975,8 @@ void free_initmem(void) | |||
| 975 | 975 | ||
| 976 | /* Free the data pages that we won't use again after init. */ | 976 | /* Free the data pages that we won't use again after init. */ |
| 977 | free_init_pages("unused kernel data", | 977 | free_init_pages("unused kernel data", |
| 978 | (unsigned long)_sinitdata, | 978 | (unsigned long)__init_begin, |
| 979 | (unsigned long)_einitdata); | 979 | (unsigned long)__init_end); |
| 980 | 980 | ||
| 981 | /* | 981 | /* |
| 982 | * Free the pages mapped from 0xc0000000 that correspond to code | 982 | * Free the pages mapped from 0xc0000000 that correspond to code |
diff --git a/drivers/char/tile-srom.c b/drivers/char/tile-srom.c index bd377472dcfb..02e76ac6d282 100644 --- a/drivers/char/tile-srom.c +++ b/drivers/char/tile-srom.c | |||
| @@ -76,6 +76,7 @@ MODULE_LICENSE("GPL"); | |||
| 76 | 76 | ||
| 77 | static int srom_devs; /* Number of SROM partitions */ | 77 | static int srom_devs; /* Number of SROM partitions */ |
| 78 | static struct cdev srom_cdev; | 78 | static struct cdev srom_cdev; |
| 79 | static struct platform_device *srom_parent; | ||
| 79 | static struct class *srom_class; | 80 | static struct class *srom_class; |
| 80 | static struct srom_dev *srom_devices; | 81 | static struct srom_dev *srom_devices; |
| 81 | 82 | ||
| @@ -350,7 +351,7 @@ static int srom_setup_minor(struct srom_dev *srom, int index) | |||
| 350 | SROM_PAGE_SIZE_OFF, sizeof(srom->page_size)) < 0) | 351 | SROM_PAGE_SIZE_OFF, sizeof(srom->page_size)) < 0) |
| 351 | return -EIO; | 352 | return -EIO; |
| 352 | 353 | ||
| 353 | dev = device_create(srom_class, &platform_bus, | 354 | dev = device_create(srom_class, &srom_parent->dev, |
| 354 | MKDEV(srom_major, index), srom, "%d", index); | 355 | MKDEV(srom_major, index), srom, "%d", index); |
| 355 | return PTR_ERR_OR_ZERO(dev); | 356 | return PTR_ERR_OR_ZERO(dev); |
| 356 | } | 357 | } |
| @@ -415,6 +416,13 @@ static int srom_init(void) | |||
| 415 | if (result < 0) | 416 | if (result < 0) |
| 416 | goto fail_chrdev; | 417 | goto fail_chrdev; |
| 417 | 418 | ||
| 419 | /* Create a parent device */ | ||
| 420 | srom_parent = platform_device_register_simple("srom", -1, NULL, 0); | ||
| 421 | if (IS_ERR(srom_parent)) { | ||
| 422 | result = PTR_ERR(srom_parent); | ||
| 423 | goto fail_pdev; | ||
| 424 | } | ||
| 425 | |||
| 418 | /* Create a sysfs class. */ | 426 | /* Create a sysfs class. */ |
| 419 | srom_class = class_create(THIS_MODULE, "srom"); | 427 | srom_class = class_create(THIS_MODULE, "srom"); |
| 420 | if (IS_ERR(srom_class)) { | 428 | if (IS_ERR(srom_class)) { |
| @@ -438,6 +446,8 @@ fail_class: | |||
| 438 | device_destroy(srom_class, MKDEV(srom_major, i)); | 446 | device_destroy(srom_class, MKDEV(srom_major, i)); |
| 439 | class_destroy(srom_class); | 447 | class_destroy(srom_class); |
| 440 | fail_cdev: | 448 | fail_cdev: |
| 449 | platform_device_unregister(srom_parent); | ||
| 450 | fail_pdev: | ||
| 441 | cdev_del(&srom_cdev); | 451 | cdev_del(&srom_cdev); |
| 442 | fail_chrdev: | 452 | fail_chrdev: |
| 443 | unregister_chrdev_region(dev, srom_devs); | 453 | unregister_chrdev_region(dev, srom_devs); |
| @@ -454,6 +464,7 @@ static void srom_cleanup(void) | |||
| 454 | device_destroy(srom_class, MKDEV(srom_major, i)); | 464 | device_destroy(srom_class, MKDEV(srom_major, i)); |
| 455 | class_destroy(srom_class); | 465 | class_destroy(srom_class); |
| 456 | cdev_del(&srom_cdev); | 466 | cdev_del(&srom_cdev); |
| 467 | platform_device_unregister(srom_parent); | ||
| 457 | unregister_chrdev_region(MKDEV(srom_major, 0), srom_devs); | 468 | unregister_chrdev_region(MKDEV(srom_major, 0), srom_devs); |
| 458 | kfree(srom_devices); | 469 | kfree(srom_devices); |
| 459 | } | 470 | } |
