Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile
Browse files Browse the repository at this point in the history
Pull arch/tile updates from Chris Metcalf:
 "The only substantive pieces in this batch are some more vDSO support,
  and removing the reference to &platform_bus in tile-srom.c.

  The rest are minor issues reported to me"

* git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile:
  tile: add clock_gettime support to vDSO
  tile: switch to using seqlocks for the vDSO time code
  tile gxio: use better string copy primitive
  char: tile-srom: Add real platform bus parent
  Removed repeated word in comments
  tilegx: Enable ARCH_SUPPORTS_ATOMIC_RMW
  tile: Remove tile-specific _sinitdata and _einitdata
  tile: use ARRAY_SIZE
  • Loading branch information
torvalds committed Oct 8, 2014
2 parents 6325e94 + 78410af commit f8e4fae
Show file tree
Hide file tree
Showing 12 changed files with 245 additions and 94 deletions.
1 change: 1 addition & 0 deletions arch/tile/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ config TILEGX
select HAVE_KPROBES
select HAVE_KRETPROBES
select HAVE_ARCH_KGDB
select ARCH_SUPPORTS_ATOMIC_RMW

config TILEPRO
def_bool !TILEGX
Expand Down
37 changes: 32 additions & 5 deletions arch/tile/gxio/mpipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,32 @@
/* HACK: Avoid pointless "shadow" warnings. */
#define link link_shadow

/**
* strscpy - Copy a C-string into a sized buffer, but only if it fits
* @dest: Where to copy the string to
* @src: Where to copy the string from
* @size: size of destination buffer
*
* Use this routine to avoid copying too-long strings.
* The routine returns the total number of bytes copied
* (including the trailing NUL) or zero if the buffer wasn't
* big enough. To ensure that programmers pay attention
* to the return code, the destination has a single NUL
* written at the front (if size is non-zero) when the
* buffer is not big enough.
*/
static size_t strscpy(char *dest, const char *src, size_t size)
{
size_t len = strnlen(src, size) + 1;
if (len > size) {
if (size)
dest[0] = '\0';
return 0;
}
memcpy(dest, src, len);
return len;
}

int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index)
{
char file[32];
Expand Down Expand Up @@ -511,8 +537,8 @@ int gxio_mpipe_link_instance(const char *link_name)
if (!context)
return GXIO_ERR_NO_DEVICE;

strncpy(name.name, link_name, sizeof(name.name));
name.name[GXIO_MPIPE_LINK_NAME_LEN - 1] = '\0';
if (strscpy(name.name, link_name, sizeof(name.name)) == 0)
return GXIO_ERR_NO_DEVICE;

return gxio_mpipe_info_instance_aux(context, name);
}
Expand All @@ -529,7 +555,8 @@ int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac)

rv = gxio_mpipe_info_enumerate_aux(context, idx, &name, &mac);
if (rv >= 0) {
strncpy(link_name, name.name, sizeof(name.name));
if (strscpy(link_name, name.name, sizeof(name.name)) == 0)
return GXIO_ERR_INVAL_MEMORY_SIZE;
memcpy(link_mac, mac.mac, sizeof(mac.mac));
}

Expand All @@ -545,8 +572,8 @@ int gxio_mpipe_link_open(gxio_mpipe_link_t *link,
_gxio_mpipe_link_name_t name;
int rv;

strncpy(name.name, link_name, sizeof(name.name));
name.name[GXIO_MPIPE_LINK_NAME_LEN - 1] = '\0';
if (strscpy(name.name, link_name, sizeof(name.name)) == 0)
return GXIO_ERR_NO_DEVICE;

rv = gxio_mpipe_link_open_aux(context, name, flags);
if (rv < 0)
Expand Down
3 changes: 0 additions & 3 deletions arch/tile/include/asm/sections.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@

#include <asm-generic/sections.h>

/* Text and data are at different areas in the kernel VA space. */
extern char _sinitdata[], _einitdata[];

/* Write-once data is writable only till the end of initialization. */
extern char __w1data_begin[], __w1data_end[];

Expand Down
20 changes: 13 additions & 7 deletions arch/tile/include/asm/vdso.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef __TILE_VDSO_H__
#define __TILE_VDSO_H__

#include <linux/seqlock.h>
#include <linux/types.h>

/*
Expand All @@ -26,15 +27,20 @@
*/

struct vdso_data {
__u64 tz_update_count; /* Timezone atomicity ctr */
__u64 tb_update_count; /* Timebase atomicity ctr */
__u64 xtime_tod_stamp; /* TOD clock for xtime */
__u64 xtime_clock_sec; /* Kernel time second */
__u64 xtime_clock_nsec; /* Kernel time nanosecond */
__u64 wtom_clock_sec; /* Wall to monotonic clock second */
__u64 wtom_clock_nsec; /* Wall to monotonic clock nanosecond */
seqcount_t tz_seq; /* Timezone seqlock */
seqcount_t tb_seq; /* Timebase seqlock */
__u64 cycle_last; /* TOD clock for xtime */
__u64 mask; /* Cycle mask */
__u32 mult; /* Cycle to nanosecond multiplier */
__u32 shift; /* Cycle to nanosecond divisor (power of two) */
__u64 wall_time_sec;
__u64 wall_time_snsec;
__u64 monotonic_time_sec;
__u64 monotonic_time_snsec;
__u64 wall_time_coarse_sec;
__u64 wall_time_coarse_nsec;
__u64 monotonic_time_coarse_sec;
__u64 monotonic_time_coarse_nsec;
__u32 tz_minuteswest; /* Minutes west of Greenwich */
__u32 tz_dsttime; /* Type of dst correction */
};
Expand Down
10 changes: 5 additions & 5 deletions arch/tile/include/uapi/arch/sim_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,19 +360,19 @@
* @{
*/

/** Use with with SIM_PROFILER_CHIP_xxx to control the memory controllers. */
/** Use with SIM_PROFILER_CHIP_xxx to control the memory controllers. */
#define SIM_CHIP_MEMCTL 0x001

/** Use with with SIM_PROFILER_CHIP_xxx to control the XAUI interface. */
/** Use with SIM_PROFILER_CHIP_xxx to control the XAUI interface. */
#define SIM_CHIP_XAUI 0x002

/** Use with with SIM_PROFILER_CHIP_xxx to control the PCIe interface. */
/** Use with SIM_PROFILER_CHIP_xxx to control the PCIe interface. */
#define SIM_CHIP_PCIE 0x004

/** Use with with SIM_PROFILER_CHIP_xxx to control the MPIPE interface. */
/** Use with SIM_PROFILER_CHIP_xxx to control the MPIPE interface. */
#define SIM_CHIP_MPIPE 0x008

/** Use with with SIM_PROFILER_CHIP_xxx to control the TRIO interface. */
/** Use with SIM_PROFILER_CHIP_xxx to control the TRIO interface. */
#define SIM_CHIP_TRIO 0x010

/** Reference all chip devices. */
Expand Down
61 changes: 40 additions & 21 deletions arch/tile/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,33 +249,52 @@ cycles_t ns2cycles(unsigned long nsecs)

void update_vsyscall_tz(void)
{
/* Userspace gettimeofday will spin while this value is odd. */
++vdso_data->tz_update_count;
smp_wmb();
write_seqcount_begin(&vdso_data->tz_seq);
vdso_data->tz_minuteswest = sys_tz.tz_minuteswest;
vdso_data->tz_dsttime = sys_tz.tz_dsttime;
smp_wmb();
++vdso_data->tz_update_count;
write_seqcount_end(&vdso_data->tz_seq);
}

void update_vsyscall(struct timekeeper *tk)
{
struct timespec *wtm = &tk->wall_to_monotonic;
struct clocksource *clock = tk->tkr.clock;

if (clock != &cycle_counter_cs)
if (tk->tkr.clock != &cycle_counter_cs)
return;

/* Userspace gettimeofday will spin while this value is odd. */
++vdso_data->tb_update_count;
smp_wmb();
vdso_data->xtime_tod_stamp = tk->tkr.cycle_last;
vdso_data->xtime_clock_sec = tk->xtime_sec;
vdso_data->xtime_clock_nsec = tk->tkr.xtime_nsec;
vdso_data->wtom_clock_sec = wtm->tv_sec;
vdso_data->wtom_clock_nsec = wtm->tv_nsec;
vdso_data->mult = tk->tkr.mult;
vdso_data->shift = tk->tkr.shift;
smp_wmb();
++vdso_data->tb_update_count;
write_seqcount_begin(&vdso_data->tb_seq);

vdso_data->cycle_last = tk->tkr.cycle_last;
vdso_data->mask = tk->tkr.mask;
vdso_data->mult = tk->tkr.mult;
vdso_data->shift = tk->tkr.shift;

vdso_data->wall_time_sec = tk->xtime_sec;
vdso_data->wall_time_snsec = tk->tkr.xtime_nsec;

vdso_data->monotonic_time_sec = tk->xtime_sec
+ tk->wall_to_monotonic.tv_sec;
vdso_data->monotonic_time_snsec = tk->tkr.xtime_nsec
+ ((u64)tk->wall_to_monotonic.tv_nsec
<< tk->tkr.shift);
while (vdso_data->monotonic_time_snsec >=
(((u64)NSEC_PER_SEC) << tk->tkr.shift)) {
vdso_data->monotonic_time_snsec -=
((u64)NSEC_PER_SEC) << tk->tkr.shift;
vdso_data->monotonic_time_sec++;
}

vdso_data->wall_time_coarse_sec = tk->xtime_sec;
vdso_data->wall_time_coarse_nsec = (long)(tk->tkr.xtime_nsec >>
tk->tkr.shift);

vdso_data->monotonic_time_coarse_sec =
vdso_data->wall_time_coarse_sec + tk->wall_to_monotonic.tv_sec;
vdso_data->monotonic_time_coarse_nsec =
vdso_data->wall_time_coarse_nsec + tk->wall_to_monotonic.tv_nsec;

while (vdso_data->monotonic_time_coarse_nsec >= NSEC_PER_SEC) {
vdso_data->monotonic_time_coarse_nsec -= NSEC_PER_SEC;
vdso_data->monotonic_time_coarse_sec++;
}

write_seqcount_end(&vdso_data->tb_seq);
}
2 changes: 1 addition & 1 deletion arch/tile/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void __kprobes do_trap(struct pt_regs *regs, int fault_num,
if (fixup_exception(regs)) /* ILL_TRANS or UNALIGN_DATA */
return;
if (fault_num >= 0 &&
fault_num < sizeof(int_name)/sizeof(int_name[0]) &&
fault_num < ARRAY_SIZE(int_name) &&
int_name[fault_num] != NULL)
name = int_name[fault_num];
else
Expand Down
2 changes: 2 additions & 0 deletions arch/tile/kernel/vdso/vdso.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ VERSION
__vdso_rt_sigreturn;
__vdso_gettimeofday;
gettimeofday;
__vdso_clock_gettime;
clock_gettime;
local:*;
};
}
Loading

0 comments on commit f8e4fae

Please sign in to comment.