[RESEND PATCH 2/7] time: Change posix clocks ops interfaces to use timespec64

2017-03-18 Thread Deepa Dinamani
 struct timespec is not y2038 safe.
 Replace the posix_clock ops interfaces to use
 struct timespec64.
 The patch also changes struct itimerspec interfaces to
 struct itimerspec64 as itimerspec internally uses timespec
 and itimerspec64 uses timespec64.
 PTP clocks is the only module that sets up these interfaces.
 All individual drivers rely on PTP class driver for exposure
 to userspace. Hence, the change also deals with fixing up these
 PTP interfaces.
 The patch also changes dynamic posix clock implementation to
 reflect the changes in the functional clock interface.

Signed-off-by: Deepa Dinamani 
---
 drivers/ptp/ptp_clock.c | 18 +++---
 include/linux/posix-clock.h | 10 +-
 kernel/time/posix-clock.c   | 34 --
 3 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index e814280..b774357 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -97,30 +97,26 @@ static s32 scaled_ppm_to_ppb(long ppm)
 
 /* posix clock implementation */
 
-static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp)
+static int ptp_clock_getres(struct posix_clock *pc, struct timespec64 *tp)
 {
tp->tv_sec = 0;
tp->tv_nsec = 1;
return 0;
 }
 
-static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp)
+static int ptp_clock_settime(struct posix_clock *pc, const struct timespec64 
*tp)
 {
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
-   struct timespec64 ts = timespec_to_timespec64(*tp);
 
-   return  ptp->info->settime64(ptp->info, );
+   return  ptp->info->settime64(ptp->info, tp);
 }
 
-static int ptp_clock_gettime(struct posix_clock *pc, struct timespec *tp)
+static int ptp_clock_gettime(struct posix_clock *pc, struct timespec64 *tp)
 {
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
-   struct timespec64 ts;
int err;
 
-   err = ptp->info->gettime64(ptp->info, );
-   if (!err)
-   *tp = timespec64_to_timespec(ts);
+   err = ptp->info->gettime64(ptp->info, tp);
return err;
 }
 
@@ -133,7 +129,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct 
timex *tx)
ops = ptp->info;
 
if (tx->modes & ADJ_SETOFFSET) {
-   struct timespec ts;
+   struct timespec64 ts;
ktime_t kt;
s64 delta;
 
@@ -146,7 +142,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct 
timex *tx)
if ((unsigned long) ts.tv_nsec >= NSEC_PER_SEC)
return -EINVAL;
 
-   kt = timespec_to_ktime(ts);
+   kt = timespec64_to_ktime(ts);
delta = ktime_to_ns(kt);
err = ops->adjtime(ops, delta);
} else if (tx->modes & ADJ_FREQUENCY) {
diff --git a/include/linux/posix-clock.h b/include/linux/posix-clock.h
index 34c4498..83b22ae 100644
--- a/include/linux/posix-clock.h
+++ b/include/linux/posix-clock.h
@@ -59,23 +59,23 @@ struct posix_clock_operations {
 
int  (*clock_adjtime)(struct posix_clock *pc, struct timex *tx);
 
-   int  (*clock_gettime)(struct posix_clock *pc, struct timespec *ts);
+   int  (*clock_gettime)(struct posix_clock *pc, struct timespec64 *ts);
 
-   int  (*clock_getres) (struct posix_clock *pc, struct timespec *ts);
+   int  (*clock_getres) (struct posix_clock *pc, struct timespec64 *ts);
 
int  (*clock_settime)(struct posix_clock *pc,
- const struct timespec *ts);
+ const struct timespec64 *ts);
 
int  (*timer_create) (struct posix_clock *pc, struct k_itimer *kit);
 
int  (*timer_delete) (struct posix_clock *pc, struct k_itimer *kit);
 
void (*timer_gettime)(struct posix_clock *pc,
- struct k_itimer *kit, struct itimerspec *tsp);
+ struct k_itimer *kit, struct itimerspec64 *tsp);
 
int  (*timer_settime)(struct posix_clock *pc,
  struct k_itimer *kit, int flags,
- struct itimerspec *tsp, struct itimerspec *old);
+ struct itimerspec64 *tsp, struct itimerspec64 
*old);
/*
 * Optional character device methods:
 */
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 9cff0ab..f2af1b5 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -300,14 +300,17 @@ static int pc_clock_adjtime(clockid_t id, struct timex 
*tx)
 static int pc_clock_gettime(clockid_t id, struct timespec *ts)
 {
struct posix_clock_desc cd;
+   struct timespec64 ts64;
int err;
 
err = get_clock_desc(id, );
if (err)
return err;
 
-   if (cd.clk->ops.clock_gettime)
-   err = 

[RESEND PATCH 2/7] time: Change posix clocks ops interfaces to use timespec64

2017-03-18 Thread Deepa Dinamani
 struct timespec is not y2038 safe.
 Replace the posix_clock ops interfaces to use
 struct timespec64.
 The patch also changes struct itimerspec interfaces to
 struct itimerspec64 as itimerspec internally uses timespec
 and itimerspec64 uses timespec64.
 PTP clocks is the only module that sets up these interfaces.
 All individual drivers rely on PTP class driver for exposure
 to userspace. Hence, the change also deals with fixing up these
 PTP interfaces.
 The patch also changes dynamic posix clock implementation to
 reflect the changes in the functional clock interface.

Signed-off-by: Deepa Dinamani 
---
 drivers/ptp/ptp_clock.c | 18 +++---
 include/linux/posix-clock.h | 10 +-
 kernel/time/posix-clock.c   | 34 --
 3 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index e814280..b774357 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -97,30 +97,26 @@ static s32 scaled_ppm_to_ppb(long ppm)
 
 /* posix clock implementation */
 
-static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp)
+static int ptp_clock_getres(struct posix_clock *pc, struct timespec64 *tp)
 {
tp->tv_sec = 0;
tp->tv_nsec = 1;
return 0;
 }
 
-static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp)
+static int ptp_clock_settime(struct posix_clock *pc, const struct timespec64 
*tp)
 {
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
-   struct timespec64 ts = timespec_to_timespec64(*tp);
 
-   return  ptp->info->settime64(ptp->info, );
+   return  ptp->info->settime64(ptp->info, tp);
 }
 
-static int ptp_clock_gettime(struct posix_clock *pc, struct timespec *tp)
+static int ptp_clock_gettime(struct posix_clock *pc, struct timespec64 *tp)
 {
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
-   struct timespec64 ts;
int err;
 
-   err = ptp->info->gettime64(ptp->info, );
-   if (!err)
-   *tp = timespec64_to_timespec(ts);
+   err = ptp->info->gettime64(ptp->info, tp);
return err;
 }
 
@@ -133,7 +129,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct 
timex *tx)
ops = ptp->info;
 
if (tx->modes & ADJ_SETOFFSET) {
-   struct timespec ts;
+   struct timespec64 ts;
ktime_t kt;
s64 delta;
 
@@ -146,7 +142,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct 
timex *tx)
if ((unsigned long) ts.tv_nsec >= NSEC_PER_SEC)
return -EINVAL;
 
-   kt = timespec_to_ktime(ts);
+   kt = timespec64_to_ktime(ts);
delta = ktime_to_ns(kt);
err = ops->adjtime(ops, delta);
} else if (tx->modes & ADJ_FREQUENCY) {
diff --git a/include/linux/posix-clock.h b/include/linux/posix-clock.h
index 34c4498..83b22ae 100644
--- a/include/linux/posix-clock.h
+++ b/include/linux/posix-clock.h
@@ -59,23 +59,23 @@ struct posix_clock_operations {
 
int  (*clock_adjtime)(struct posix_clock *pc, struct timex *tx);
 
-   int  (*clock_gettime)(struct posix_clock *pc, struct timespec *ts);
+   int  (*clock_gettime)(struct posix_clock *pc, struct timespec64 *ts);
 
-   int  (*clock_getres) (struct posix_clock *pc, struct timespec *ts);
+   int  (*clock_getres) (struct posix_clock *pc, struct timespec64 *ts);
 
int  (*clock_settime)(struct posix_clock *pc,
- const struct timespec *ts);
+ const struct timespec64 *ts);
 
int  (*timer_create) (struct posix_clock *pc, struct k_itimer *kit);
 
int  (*timer_delete) (struct posix_clock *pc, struct k_itimer *kit);
 
void (*timer_gettime)(struct posix_clock *pc,
- struct k_itimer *kit, struct itimerspec *tsp);
+ struct k_itimer *kit, struct itimerspec64 *tsp);
 
int  (*timer_settime)(struct posix_clock *pc,
  struct k_itimer *kit, int flags,
- struct itimerspec *tsp, struct itimerspec *old);
+ struct itimerspec64 *tsp, struct itimerspec64 
*old);
/*
 * Optional character device methods:
 */
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 9cff0ab..f2af1b5 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -300,14 +300,17 @@ static int pc_clock_adjtime(clockid_t id, struct timex 
*tx)
 static int pc_clock_gettime(clockid_t id, struct timespec *ts)
 {
struct posix_clock_desc cd;
+   struct timespec64 ts64;
int err;
 
err = get_clock_desc(id, );
if (err)
return err;
 
-   if (cd.clk->ops.clock_gettime)
-   err = cd.clk->ops.clock_gettime(cd.clk, ts);
+   

[RESEND PATCH 3/7] Change k_clock clock_get() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c |  4 ++--
 include/linux/posix-timers.h   |  2 +-
 include/linux/timekeeping.h|  5 +
 kernel/time/alarmtimer.c   |  4 ++--
 kernel/time/posix-clock.c  |  9 +++--
 kernel/time/posix-cpu-timers.c | 10 +-
 kernel/time/posix-stubs.c  |  9 ++---
 kernel/time/posix-timers.c | 32 +---
 8 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index b708c85..40d880b 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -478,13 +478,13 @@ static int sgi_clock_period;
 static struct timespec sgi_clock_offset;
 static int sgi_clock_period;
 
-static int sgi_clock_get(clockid_t clockid, struct timespec *tp)
+static int sgi_clock_get(clockid_t clockid, struct timespec64 *tp)
 {
u64 nsec;
 
nsec = rtc_time() * sgi_clock_period
+ sgi_clock_offset.tv_nsec;
-   *tp = ns_to_timespec(nsec);
+   *tp = ns_to_timespec64(nsec);
tp->tv_sec += sgi_clock_offset.tv_sec;
return 0;
 };
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 64aa189..db54f1b 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -90,7 +90,7 @@ struct k_clock {
int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
int (*clock_set) (const clockid_t which_clock,
  const struct timespec *tp);
-   int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
+   int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
int (*nsleep) (const clockid_t which_clock, int flags,
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 3617a78..ddc229f 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -258,6 +258,11 @@ static inline void timekeeping_clocktai(struct timespec 
*ts)
*ts = ktime_to_timespec(ktime_get_clocktai());
 }
 
+static inline void timekeeping_clocktai64(struct timespec64 *ts)
+{
+   *ts = ktime_to_timespec64(ktime_get_clocktai());
+}
+
 /*
  * RTC specific
  */
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index ce3a31e..944ca6e 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -558,14 +558,14 @@ static int alarm_clock_getres(const clockid_t 
which_clock, struct timespec *tp)
  *
  * Provides the underlying alarm base time.
  */
-static int alarm_clock_get(clockid_t which_clock, struct timespec *tp)
+static int alarm_clock_get(clockid_t which_clock, struct timespec64 *tp)
 {
struct alarm_base *base = _bases[clock2alarm(which_clock)];
 
if (!alarmtimer_get_rtcdev())
return -EINVAL;
 
-   *tp = ktime_to_timespec(base->gettime());
+   *tp = ktime_to_timespec64(base->gettime());
return 0;
 }
 
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index f2af1b5..0427c8c 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -297,20 +297,17 @@ static int pc_clock_adjtime(clockid_t id, struct timex 
*tx)
return err;
 }
 
-static int pc_clock_gettime(clockid_t id, struct timespec *ts)
+static int pc_clock_gettime(clockid_t id, struct timespec64 *ts)
 {
struct posix_clock_desc cd;
-   struct timespec64 ts64;
int err;
 
err = get_clock_desc(id, );
if (err)
return err;
 
-   if (cd.clk->ops.clock_gettime) {
-   err = cd.clk->ops.clock_gettime(cd.clk, );
-   *ts = timespec64_to_timespec(ts64);
-   }
+   if (cd.clk->ops.clock_gettime)
+   err = cd.clk->ops.clock_gettime(cd.clk, ts);
else
err = -EOPNOTSUPP;
 
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 4513ad1..6c509ea 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -261,7 +261,7 @@ static int cpu_clock_sample_group(const clockid_t 
which_clock,
 
 static int posix_cpu_clock_get_task(struct task_struct *tsk,
const clockid_t which_clock,
-   struct timespec *tp)
+   struct timespec64 *tp)
 {
int err = -EINVAL;
u64 rtn;
@@ -275,13 +275,13 @@ static int posix_cpu_clock_get_task(struct task_struct 
*tsk,
}
 
if (!err)
-   *tp = ns_to_timespec(rtn);
+   *tp = ns_to_timespec64(rtn);
 
return err;
 }
 

[RESEND PATCH 4/7] Change k_clock clock_getres() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c |  2 +-
 include/linux/posix-timers.h   |  2 +-
 kernel/time/alarmtimer.c   |  2 +-
 kernel/time/posix-clock.c  |  9 +++--
 kernel/time/posix-cpu-timers.c |  6 +++---
 kernel/time/posix-timers.c | 10 ++
 6 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 40d880b..79d8ada 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -765,7 +765,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return err;
 }
 
-static int sgi_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int sgi_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
 {
tp->tv_sec = 0;
tp->tv_nsec = sgi_clock_period;
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index db54f1b..2555d1c 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -87,7 +87,7 @@ struct k_itimer {
 };
 
 struct k_clock {
-   int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
+   int (*clock_getres) (const clockid_t which_clock, struct timespec64 
*tp);
int (*clock_set) (const clockid_t which_clock,
  const struct timespec *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 944ca6e..e8a45e2 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -541,7 +541,7 @@ static enum alarmtimer_restart alarm_handle_timer(struct 
alarm *alarm,
  *
  * Returns the granularity of underlying alarm base clock
  */
-static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int alarm_clock_getres(const clockid_t which_clock, struct timespec64 
*tp)
 {
if (!alarmtimer_get_rtcdev())
return -EINVAL;
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 0427c8c..d5a4bec 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -316,20 +316,17 @@ static int pc_clock_gettime(clockid_t id, struct 
timespec64 *ts)
return err;
 }
 
-static int pc_clock_getres(clockid_t id, struct timespec *ts)
+static int pc_clock_getres(clockid_t id, struct timespec64 *ts)
 {
struct posix_clock_desc cd;
-   struct timespec64 ts64;
int err;
 
err = get_clock_desc(id, );
if (err)
return err;
 
-   if (cd.clk->ops.clock_getres) {
-   err = cd.clk->ops.clock_getres(cd.clk, );
-   *ts = timespec64_to_timespec(ts64);
-   }
+   if (cd.clk->ops.clock_getres)
+   err = cd.clk->ops.clock_getres(cd.clk, ts);
else
err = -EOPNOTSUPP;
 
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 6c509ea..42ca205 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -116,7 +116,7 @@ static inline u64 virt_ticks(struct task_struct *p)
 }
 
 static int
-posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *tp)
+posix_cpu_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
 {
int error = check_clock(which_clock);
if (!error) {
@@ -1364,7 +1364,7 @@ static long posix_cpu_nsleep_restart(struct restart_block 
*restart_block)
 #define THREAD_CLOCK   MAKE_THREAD_CPUCLOCK(0, CPUCLOCK_SCHED)
 
 static int process_cpu_clock_getres(const clockid_t which_clock,
-   struct timespec *tp)
+   struct timespec64 *tp)
 {
return posix_cpu_clock_getres(PROCESS_CLOCK, tp);
 }
@@ -1389,7 +1389,7 @@ static long process_cpu_nsleep_restart(struct 
restart_block *restart_block)
return -EINVAL;
 }
 static int thread_cpu_clock_getres(const clockid_t which_clock,
-  struct timespec *tp)
+  struct timespec64 *tp)
 {
return posix_cpu_clock_getres(THREAD_CLOCK, tp);
 }
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index ba0c472..a314a63 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -258,9 +258,9 @@ static int posix_get_monotonic_coarse(clockid_t which_clock,
return 0;
 }
 
-static int posix_get_coarse_res(const clockid_t which_clock, struct timespec 
*tp)
+static int posix_get_coarse_res(const clockid_t which_clock, struct timespec64 
*tp)
 {
-   *tp = ktime_to_timespec(KTIME_LOW_RES);
+   *tp = ktime_to_timespec64(KTIME_LOW_RES);
return 0;
 }
 
@@ -276,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, 

[RESEND PATCH 3/7] Change k_clock clock_get() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c |  4 ++--
 include/linux/posix-timers.h   |  2 +-
 include/linux/timekeeping.h|  5 +
 kernel/time/alarmtimer.c   |  4 ++--
 kernel/time/posix-clock.c  |  9 +++--
 kernel/time/posix-cpu-timers.c | 10 +-
 kernel/time/posix-stubs.c  |  9 ++---
 kernel/time/posix-timers.c | 32 +---
 8 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index b708c85..40d880b 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -478,13 +478,13 @@ static int sgi_clock_period;
 static struct timespec sgi_clock_offset;
 static int sgi_clock_period;
 
-static int sgi_clock_get(clockid_t clockid, struct timespec *tp)
+static int sgi_clock_get(clockid_t clockid, struct timespec64 *tp)
 {
u64 nsec;
 
nsec = rtc_time() * sgi_clock_period
+ sgi_clock_offset.tv_nsec;
-   *tp = ns_to_timespec(nsec);
+   *tp = ns_to_timespec64(nsec);
tp->tv_sec += sgi_clock_offset.tv_sec;
return 0;
 };
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 64aa189..db54f1b 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -90,7 +90,7 @@ struct k_clock {
int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
int (*clock_set) (const clockid_t which_clock,
  const struct timespec *tp);
-   int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
+   int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
int (*nsleep) (const clockid_t which_clock, int flags,
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 3617a78..ddc229f 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -258,6 +258,11 @@ static inline void timekeeping_clocktai(struct timespec 
*ts)
*ts = ktime_to_timespec(ktime_get_clocktai());
 }
 
+static inline void timekeeping_clocktai64(struct timespec64 *ts)
+{
+   *ts = ktime_to_timespec64(ktime_get_clocktai());
+}
+
 /*
  * RTC specific
  */
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index ce3a31e..944ca6e 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -558,14 +558,14 @@ static int alarm_clock_getres(const clockid_t 
which_clock, struct timespec *tp)
  *
  * Provides the underlying alarm base time.
  */
-static int alarm_clock_get(clockid_t which_clock, struct timespec *tp)
+static int alarm_clock_get(clockid_t which_clock, struct timespec64 *tp)
 {
struct alarm_base *base = _bases[clock2alarm(which_clock)];
 
if (!alarmtimer_get_rtcdev())
return -EINVAL;
 
-   *tp = ktime_to_timespec(base->gettime());
+   *tp = ktime_to_timespec64(base->gettime());
return 0;
 }
 
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index f2af1b5..0427c8c 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -297,20 +297,17 @@ static int pc_clock_adjtime(clockid_t id, struct timex 
*tx)
return err;
 }
 
-static int pc_clock_gettime(clockid_t id, struct timespec *ts)
+static int pc_clock_gettime(clockid_t id, struct timespec64 *ts)
 {
struct posix_clock_desc cd;
-   struct timespec64 ts64;
int err;
 
err = get_clock_desc(id, );
if (err)
return err;
 
-   if (cd.clk->ops.clock_gettime) {
-   err = cd.clk->ops.clock_gettime(cd.clk, );
-   *ts = timespec64_to_timespec(ts64);
-   }
+   if (cd.clk->ops.clock_gettime)
+   err = cd.clk->ops.clock_gettime(cd.clk, ts);
else
err = -EOPNOTSUPP;
 
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 4513ad1..6c509ea 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -261,7 +261,7 @@ static int cpu_clock_sample_group(const clockid_t 
which_clock,
 
 static int posix_cpu_clock_get_task(struct task_struct *tsk,
const clockid_t which_clock,
-   struct timespec *tp)
+   struct timespec64 *tp)
 {
int err = -EINVAL;
u64 rtn;
@@ -275,13 +275,13 @@ static int posix_cpu_clock_get_task(struct task_struct 
*tsk,
}
 
if (!err)
-   *tp = ns_to_timespec(rtn);
+   *tp = ns_to_timespec64(rtn);
 
return err;
 }
 
 
-static int 

[RESEND PATCH 4/7] Change k_clock clock_getres() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c |  2 +-
 include/linux/posix-timers.h   |  2 +-
 kernel/time/alarmtimer.c   |  2 +-
 kernel/time/posix-clock.c  |  9 +++--
 kernel/time/posix-cpu-timers.c |  6 +++---
 kernel/time/posix-timers.c | 10 ++
 6 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 40d880b..79d8ada 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -765,7 +765,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return err;
 }
 
-static int sgi_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int sgi_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
 {
tp->tv_sec = 0;
tp->tv_nsec = sgi_clock_period;
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index db54f1b..2555d1c 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -87,7 +87,7 @@ struct k_itimer {
 };
 
 struct k_clock {
-   int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
+   int (*clock_getres) (const clockid_t which_clock, struct timespec64 
*tp);
int (*clock_set) (const clockid_t which_clock,
  const struct timespec *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 944ca6e..e8a45e2 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -541,7 +541,7 @@ static enum alarmtimer_restart alarm_handle_timer(struct 
alarm *alarm,
  *
  * Returns the granularity of underlying alarm base clock
  */
-static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int alarm_clock_getres(const clockid_t which_clock, struct timespec64 
*tp)
 {
if (!alarmtimer_get_rtcdev())
return -EINVAL;
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 0427c8c..d5a4bec 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -316,20 +316,17 @@ static int pc_clock_gettime(clockid_t id, struct 
timespec64 *ts)
return err;
 }
 
-static int pc_clock_getres(clockid_t id, struct timespec *ts)
+static int pc_clock_getres(clockid_t id, struct timespec64 *ts)
 {
struct posix_clock_desc cd;
-   struct timespec64 ts64;
int err;
 
err = get_clock_desc(id, );
if (err)
return err;
 
-   if (cd.clk->ops.clock_getres) {
-   err = cd.clk->ops.clock_getres(cd.clk, );
-   *ts = timespec64_to_timespec(ts64);
-   }
+   if (cd.clk->ops.clock_getres)
+   err = cd.clk->ops.clock_getres(cd.clk, ts);
else
err = -EOPNOTSUPP;
 
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 6c509ea..42ca205 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -116,7 +116,7 @@ static inline u64 virt_ticks(struct task_struct *p)
 }
 
 static int
-posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *tp)
+posix_cpu_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
 {
int error = check_clock(which_clock);
if (!error) {
@@ -1364,7 +1364,7 @@ static long posix_cpu_nsleep_restart(struct restart_block 
*restart_block)
 #define THREAD_CLOCK   MAKE_THREAD_CPUCLOCK(0, CPUCLOCK_SCHED)
 
 static int process_cpu_clock_getres(const clockid_t which_clock,
-   struct timespec *tp)
+   struct timespec64 *tp)
 {
return posix_cpu_clock_getres(PROCESS_CLOCK, tp);
 }
@@ -1389,7 +1389,7 @@ static long process_cpu_nsleep_restart(struct 
restart_block *restart_block)
return -EINVAL;
 }
 static int thread_cpu_clock_getres(const clockid_t which_clock,
-  struct timespec *tp)
+  struct timespec64 *tp)
 {
return posix_cpu_clock_getres(THREAD_CLOCK, tp);
 }
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index ba0c472..a314a63 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -258,9 +258,9 @@ static int posix_get_monotonic_coarse(clockid_t which_clock,
return 0;
 }
 
-static int posix_get_coarse_res(const clockid_t which_clock, struct timespec 
*tp)
+static int posix_get_coarse_res(const clockid_t which_clock, struct timespec64 
*tp)
 {
-   *tp = ktime_to_timespec(KTIME_LOW_RES);
+   *tp = ktime_to_timespec64(KTIME_LOW_RES);
return 0;
 }
 
@@ -276,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct 
timespec64 *tp)
   

[RESEND PATCH 6/7] Change k_clock timer_set() and timer_get() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c | 20 ++--
 include/linux/posix-timers.h   |  6 +++---
 kernel/time/alarmtimer.c   | 14 +++---
 kernel/time/posix-clock.c  | 21 +++--
 kernel/time/posix-cpu-timers.c | 28 
 kernel/time/posix-timers.c | 33 +++--
 6 files changed, 62 insertions(+), 60 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index ba1b892..863a111 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -657,7 +657,7 @@ static int sgi_timer_del(struct k_itimer *timr)
 }
 
 /* Assumption: it_lock is already held with irq's disabled */
-static void sgi_timer_get(struct k_itimer *timr, struct itimerspec 
*cur_setting)
+static void sgi_timer_get(struct k_itimer *timr, struct itimerspec64 
*cur_setting)
 {
 
if (timr->it.mmtimer.clock == TIMER_OFF) {
@@ -668,14 +668,14 @@ static void sgi_timer_get(struct k_itimer *timr, struct 
itimerspec *cur_setting)
return;
}
 
-   cur_setting->it_interval = ns_to_timespec(timr->it.mmtimer.incr * 
sgi_clock_period);
-   cur_setting->it_value = ns_to_timespec((timr->it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
+   cur_setting->it_interval = ns_to_timespec64(timr->it.mmtimer.incr * 
sgi_clock_period);
+   cur_setting->it_value = ns_to_timespec64((timr->it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
 }
 
 
 static int sgi_timer_set(struct k_itimer *timr, int flags,
-   struct itimerspec * new_setting,
-   struct itimerspec * old_setting)
+   struct itimerspec64 * new_setting,
+   struct itimerspec64 * old_setting)
 {
unsigned long when, period, irqflags;
int err = 0;
@@ -687,8 +687,8 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
sgi_timer_get(timr, old_setting);
 
sgi_timer_del(timr);
-   when = timespec_to_ns(_setting->it_value);
-   period = timespec_to_ns(_setting->it_interval);
+   when = timespec64_to_ns(_setting->it_value);
+   period = timespec64_to_ns(_setting->it_interval);
 
if (when == 0)
/* Clear timer */
@@ -699,11 +699,11 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return -ENOMEM;
 
if (flags & TIMER_ABSTIME) {
-   struct timespec n;
+   struct timespec64 n;
unsigned long now;
 
-   getnstimeofday();
-   now = timespec_to_ns();
+   getnstimeofday64();
+   now = timespec64_to_ns();
if (when > now)
when -= now;
else
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 249429c..f608941 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -97,12 +97,12 @@ struct k_clock {
   struct timespec *, struct timespec __user *);
long (*nsleep_restart) (struct restart_block *restart_block);
int (*timer_set) (struct k_itimer * timr, int flags,
- struct itimerspec * new_setting,
- struct itimerspec * old_setting);
+ struct itimerspec64 * new_setting,
+ struct itimerspec64 * old_setting);
int (*timer_del) (struct k_itimer * timr);
 #define TIMER_RETRY 1
void (*timer_get) (struct k_itimer * timr,
-  struct itimerspec * cur_setting);
+  struct itimerspec64 * cur_setting);
 };
 
 extern struct k_clock clock_posix_cpu;
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index e8a45e2..81db6df 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -598,19 +598,19 @@ static int alarm_timer_create(struct k_itimer *new_timer)
  * Copies out the current itimerspec data
  */
 static void alarm_timer_get(struct k_itimer *timr,
-   struct itimerspec *cur_setting)
+   struct itimerspec64 *cur_setting)
 {
ktime_t relative_expiry_time =
alarm_expires_remaining(&(timr->it.alarm.alarmtimer));
 
if (ktime_to_ns(relative_expiry_time) > 0) {
-   cur_setting->it_value = ktime_to_timespec(relative_expiry_time);
+   cur_setting->it_value = 
ktime_to_timespec64(relative_expiry_time);
} else {
cur_setting->it_value.tv_sec = 0;
cur_setting->it_value.tv_nsec = 0;
}
 
-   cur_setting->it_interval = ktime_to_timespec(timr->it.alarm.interval);
+   cur_setting->it_interval = 

[RESEND PATCH 6/7] Change k_clock timer_set() and timer_get() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c | 20 ++--
 include/linux/posix-timers.h   |  6 +++---
 kernel/time/alarmtimer.c   | 14 +++---
 kernel/time/posix-clock.c  | 21 +++--
 kernel/time/posix-cpu-timers.c | 28 
 kernel/time/posix-timers.c | 33 +++--
 6 files changed, 62 insertions(+), 60 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index ba1b892..863a111 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -657,7 +657,7 @@ static int sgi_timer_del(struct k_itimer *timr)
 }
 
 /* Assumption: it_lock is already held with irq's disabled */
-static void sgi_timer_get(struct k_itimer *timr, struct itimerspec 
*cur_setting)
+static void sgi_timer_get(struct k_itimer *timr, struct itimerspec64 
*cur_setting)
 {
 
if (timr->it.mmtimer.clock == TIMER_OFF) {
@@ -668,14 +668,14 @@ static void sgi_timer_get(struct k_itimer *timr, struct 
itimerspec *cur_setting)
return;
}
 
-   cur_setting->it_interval = ns_to_timespec(timr->it.mmtimer.incr * 
sgi_clock_period);
-   cur_setting->it_value = ns_to_timespec((timr->it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
+   cur_setting->it_interval = ns_to_timespec64(timr->it.mmtimer.incr * 
sgi_clock_period);
+   cur_setting->it_value = ns_to_timespec64((timr->it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
 }
 
 
 static int sgi_timer_set(struct k_itimer *timr, int flags,
-   struct itimerspec * new_setting,
-   struct itimerspec * old_setting)
+   struct itimerspec64 * new_setting,
+   struct itimerspec64 * old_setting)
 {
unsigned long when, period, irqflags;
int err = 0;
@@ -687,8 +687,8 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
sgi_timer_get(timr, old_setting);
 
sgi_timer_del(timr);
-   when = timespec_to_ns(_setting->it_value);
-   period = timespec_to_ns(_setting->it_interval);
+   when = timespec64_to_ns(_setting->it_value);
+   period = timespec64_to_ns(_setting->it_interval);
 
if (when == 0)
/* Clear timer */
@@ -699,11 +699,11 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return -ENOMEM;
 
if (flags & TIMER_ABSTIME) {
-   struct timespec n;
+   struct timespec64 n;
unsigned long now;
 
-   getnstimeofday();
-   now = timespec_to_ns();
+   getnstimeofday64();
+   now = timespec64_to_ns();
if (when > now)
when -= now;
else
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 249429c..f608941 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -97,12 +97,12 @@ struct k_clock {
   struct timespec *, struct timespec __user *);
long (*nsleep_restart) (struct restart_block *restart_block);
int (*timer_set) (struct k_itimer * timr, int flags,
- struct itimerspec * new_setting,
- struct itimerspec * old_setting);
+ struct itimerspec64 * new_setting,
+ struct itimerspec64 * old_setting);
int (*timer_del) (struct k_itimer * timr);
 #define TIMER_RETRY 1
void (*timer_get) (struct k_itimer * timr,
-  struct itimerspec * cur_setting);
+  struct itimerspec64 * cur_setting);
 };
 
 extern struct k_clock clock_posix_cpu;
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index e8a45e2..81db6df 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -598,19 +598,19 @@ static int alarm_timer_create(struct k_itimer *new_timer)
  * Copies out the current itimerspec data
  */
 static void alarm_timer_get(struct k_itimer *timr,
-   struct itimerspec *cur_setting)
+   struct itimerspec64 *cur_setting)
 {
ktime_t relative_expiry_time =
alarm_expires_remaining(&(timr->it.alarm.alarmtimer));
 
if (ktime_to_ns(relative_expiry_time) > 0) {
-   cur_setting->it_value = ktime_to_timespec(relative_expiry_time);
+   cur_setting->it_value = 
ktime_to_timespec64(relative_expiry_time);
} else {
cur_setting->it_value.tv_sec = 0;
cur_setting->it_value.tv_nsec = 0;
}
 
-   cur_setting->it_interval = ktime_to_timespec(timr->it.alarm.interval);
+   cur_setting->it_interval = 

[RESEND PATCH 5/7] Change k_clock clock_set() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c |  2 +-
 include/linux/posix-timers.h   |  2 +-
 kernel/time/posix-clock.c  |  5 ++---
 kernel/time/posix-cpu-timers.c |  2 +-
 kernel/time/posix-timers.c | 11 +--
 5 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 79d8ada..ba1b892 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -489,7 +489,7 @@ static int sgi_clock_get(clockid_t clockid, struct 
timespec64 *tp)
return 0;
 };
 
-static int sgi_clock_set(const clockid_t clockid, const struct timespec *tp)
+static int sgi_clock_set(const clockid_t clockid, const struct timespec64 *tp)
 {
 
u64 nsec;
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 2555d1c..249429c 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -89,7 +89,7 @@ struct k_itimer {
 struct k_clock {
int (*clock_getres) (const clockid_t which_clock, struct timespec64 
*tp);
int (*clock_set) (const clockid_t which_clock,
- const struct timespec *tp);
+ const struct timespec64 *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index d5a4bec..6378fc6 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -335,10 +335,9 @@ static int pc_clock_getres(clockid_t id, struct timespec64 
*ts)
return err;
 }
 
-static int pc_clock_settime(clockid_t id, const struct timespec *ts)
+static int pc_clock_settime(clockid_t id, const struct timespec64 *ts)
 {
struct posix_clock_desc cd;
-   struct timespec64 ts64 = timespec_to_timespec64(*ts);
int err;
 
err = get_clock_desc(id, );
@@ -351,7 +350,7 @@ static int pc_clock_settime(clockid_t id, const struct 
timespec *ts)
}
 
if (cd.clk->ops.clock_settime)
-   err = cd.clk->ops.clock_settime(cd.clk, );
+   err = cd.clk->ops.clock_settime(cd.clk, ts);
else
err = -EOPNOTSUPP;
 out:
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 42ca205..0db0e16 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -135,7 +135,7 @@ posix_cpu_clock_getres(const clockid_t which_clock, struct 
timespec64 *tp)
 }
 
 static int
-posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *tp)
+posix_cpu_clock_set(const clockid_t which_clock, const struct timespec64 *tp)
 {
/*
 * You can never reset a CPU clock, but we check for other errors
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index a314a63..6c09f87 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -212,12 +212,9 @@ static int posix_clock_realtime_get(clockid_t which_clock, 
struct timespec64 *tp
 
 /* Set clock_realtime */
 static int posix_clock_realtime_set(const clockid_t which_clock,
-   const struct timespec *tp)
+   const struct timespec64 *tp)
 {
-   struct timespec64 tp64;
-
-   tp64 = timespec_to_timespec64(*tp);
-   return do_sys_settimeofday64(, NULL);
+   return do_sys_settimeofday64(tp, NULL);
 }
 
 static int posix_clock_realtime_adj(const clockid_t which_clock,
@@ -1018,14 +1015,16 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, 
which_clock,
 {
struct k_clock *kc = clockid_to_kclock(which_clock);
struct timespec new_tp;
+   struct timespec64 new_tp64;
 
if (!kc || !kc->clock_set)
return -EINVAL;
 
if (copy_from_user(_tp, tp, sizeof (*tp)))
return -EFAULT;
+   new_tp64 = timespec_to_timespec64(new_tp);
 
-   return kc->clock_set(which_clock, _tp);
+   return kc->clock_set(which_clock, _tp64);
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
-- 
2.7.4



[RESEND PATCH 5/7] Change k_clock clock_set() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c |  2 +-
 include/linux/posix-timers.h   |  2 +-
 kernel/time/posix-clock.c  |  5 ++---
 kernel/time/posix-cpu-timers.c |  2 +-
 kernel/time/posix-timers.c | 11 +--
 5 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 79d8ada..ba1b892 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -489,7 +489,7 @@ static int sgi_clock_get(clockid_t clockid, struct 
timespec64 *tp)
return 0;
 };
 
-static int sgi_clock_set(const clockid_t clockid, const struct timespec *tp)
+static int sgi_clock_set(const clockid_t clockid, const struct timespec64 *tp)
 {
 
u64 nsec;
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 2555d1c..249429c 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -89,7 +89,7 @@ struct k_itimer {
 struct k_clock {
int (*clock_getres) (const clockid_t which_clock, struct timespec64 
*tp);
int (*clock_set) (const clockid_t which_clock,
- const struct timespec *tp);
+ const struct timespec64 *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index d5a4bec..6378fc6 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -335,10 +335,9 @@ static int pc_clock_getres(clockid_t id, struct timespec64 
*ts)
return err;
 }
 
-static int pc_clock_settime(clockid_t id, const struct timespec *ts)
+static int pc_clock_settime(clockid_t id, const struct timespec64 *ts)
 {
struct posix_clock_desc cd;
-   struct timespec64 ts64 = timespec_to_timespec64(*ts);
int err;
 
err = get_clock_desc(id, );
@@ -351,7 +350,7 @@ static int pc_clock_settime(clockid_t id, const struct 
timespec *ts)
}
 
if (cd.clk->ops.clock_settime)
-   err = cd.clk->ops.clock_settime(cd.clk, );
+   err = cd.clk->ops.clock_settime(cd.clk, ts);
else
err = -EOPNOTSUPP;
 out:
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 42ca205..0db0e16 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -135,7 +135,7 @@ posix_cpu_clock_getres(const clockid_t which_clock, struct 
timespec64 *tp)
 }
 
 static int
-posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *tp)
+posix_cpu_clock_set(const clockid_t which_clock, const struct timespec64 *tp)
 {
/*
 * You can never reset a CPU clock, but we check for other errors
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index a314a63..6c09f87 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -212,12 +212,9 @@ static int posix_clock_realtime_get(clockid_t which_clock, 
struct timespec64 *tp
 
 /* Set clock_realtime */
 static int posix_clock_realtime_set(const clockid_t which_clock,
-   const struct timespec *tp)
+   const struct timespec64 *tp)
 {
-   struct timespec64 tp64;
-
-   tp64 = timespec_to_timespec64(*tp);
-   return do_sys_settimeofday64(, NULL);
+   return do_sys_settimeofday64(tp, NULL);
 }
 
 static int posix_clock_realtime_adj(const clockid_t which_clock,
@@ -1018,14 +1015,16 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, 
which_clock,
 {
struct k_clock *kc = clockid_to_kclock(which_clock);
struct timespec new_tp;
+   struct timespec64 new_tp64;
 
if (!kc || !kc->clock_set)
return -EINVAL;
 
if (copy_from_user(_tp, tp, sizeof (*tp)))
return -EFAULT;
+   new_tp64 = timespec_to_timespec64(new_tp);
 
-   return kc->clock_set(which_clock, _tp);
+   return kc->clock_set(which_clock, _tp64);
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
-- 
2.7.4



[PATCH tip:x86/mm] x86/tls: Forcibly set the accessed bit in TLS segments

2017-03-18 Thread Andy Lutomirski
For mysterious historical reasons, struct user_desc doesn't indicate
whether segments are accessed.  set_thread_area() has always
programmed segments as non-accessed, so the first write will set the
accessed bit.  This will fault if the GDT is read-only.

Fix it by making TLS segments start out accessed.

If this ends up breaking something, we could, in principle, leave
TLS segments non-accessed and fix them up when we get the page
fault.  I'd be surprised, though -- AFAIK all the nasty legacy
segmented programs (DOSEMU, Wine, things that run on DOSEMU and
Wine, etc.) do their nasty segmented things using the LDT and not
the GDT.  I assume this is mainly because old OSes (Linux and
otherwise) didn't historically provide APIs to do nasty things in
the GDT.

Fixes: 45fc8757d1d2 ("x86: Make the GDT remapping read-only on 64-bit")
Signed-off-by: Andy Lutomirski 
---

Normally this would come with a test case update, but the relevant
testcase (ldt_gdt_32) currently has some issues.  I'm working on it,
but I don't want to delay this bugfix.

 arch/x86/kernel/tls.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
index 6c8934406dc9..dcd699baea1b 100644
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -92,10 +92,17 @@ static void set_tls_desc(struct task_struct *p, int idx,
cpu = get_cpu();
 
while (n-- > 0) {
-   if (LDT_empty(info) || LDT_zero(info))
+   if (LDT_empty(info) || LDT_zero(info)) {
desc->a = desc->b = 0;
-   else
+   } else {
fill_ldt(desc, info);
+
+   /*
+* Always set the accessed bit so that the CPU
+* doesn't try to write to the (read-only) GDT.
+*/
+   desc->type |= 1;
+   }
++info;
++desc;
}
-- 
2.9.3



[PATCH tip:x86/mm] x86/tls: Forcibly set the accessed bit in TLS segments

2017-03-18 Thread Andy Lutomirski
For mysterious historical reasons, struct user_desc doesn't indicate
whether segments are accessed.  set_thread_area() has always
programmed segments as non-accessed, so the first write will set the
accessed bit.  This will fault if the GDT is read-only.

Fix it by making TLS segments start out accessed.

If this ends up breaking something, we could, in principle, leave
TLS segments non-accessed and fix them up when we get the page
fault.  I'd be surprised, though -- AFAIK all the nasty legacy
segmented programs (DOSEMU, Wine, things that run on DOSEMU and
Wine, etc.) do their nasty segmented things using the LDT and not
the GDT.  I assume this is mainly because old OSes (Linux and
otherwise) didn't historically provide APIs to do nasty things in
the GDT.

Fixes: 45fc8757d1d2 ("x86: Make the GDT remapping read-only on 64-bit")
Signed-off-by: Andy Lutomirski 
---

Normally this would come with a test case update, but the relevant
testcase (ldt_gdt_32) currently has some issues.  I'm working on it,
but I don't want to delay this bugfix.

 arch/x86/kernel/tls.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
index 6c8934406dc9..dcd699baea1b 100644
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -92,10 +92,17 @@ static void set_tls_desc(struct task_struct *p, int idx,
cpu = get_cpu();
 
while (n-- > 0) {
-   if (LDT_empty(info) || LDT_zero(info))
+   if (LDT_empty(info) || LDT_zero(info)) {
desc->a = desc->b = 0;
-   else
+   } else {
fill_ldt(desc, info);
+
+   /*
+* Always set the accessed bit so that the CPU
+* doesn't try to write to the (read-only) GDT.
+*/
+   desc->type |= 1;
+   }
++info;
++desc;
}
-- 
2.9.3



[RESEND PATCH 1/7] time: Delete do_sys_setimeofday()

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces will be changed in a separate
series.
Call to do_sys_setimeofday() is superfluous as all
the necessary checks and functions are done by the
underlying function do_sys_setimeofday64().
Replace do_sys_setimeofday64() directly instead of
do_sys_settimeofday(). The do_sys_setimeofday64()
calls timespec64_valid() internally, which is the
same as timespec_valid().

Signed-off-by: Deepa Dinamani 
---
 include/linux/timekeeping.h | 15 ---
 kernel/compat.c |  4 ++--
 kernel/time/posix-stubs.c   |  5 -
 kernel/time/posix-timers.c  |  5 -
 kernel/time/time.c  |  4 ++--
 5 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index b598cbc..3617a78 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -19,21 +19,6 @@ extern void do_gettimeofday(struct timeval *tv);
 extern int do_settimeofday64(const struct timespec64 *ts);
 extern int do_sys_settimeofday64(const struct timespec64 *tv,
 const struct timezone *tz);
-static inline int do_sys_settimeofday(const struct timespec *tv,
- const struct timezone *tz)
-{
-   struct timespec64 ts64;
-
-   if (!tv)
-   return do_sys_settimeofday64(NULL, tz);
-
-   if (!timespec_valid(tv))
-   return -EINVAL;
-
-   ts64 = timespec_to_timespec64(*tv);
-   return do_sys_settimeofday64(, tz);
-}
-
 /*
  * Kernel time accessors
  */
diff --git a/kernel/compat.c b/kernel/compat.c
index 19aec5d..e29a01a 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -109,7 +109,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval 
__user *, tv,
   struct timezone __user *, tz)
 {
struct timeval user_tv;
-   struct timespec new_ts;
+   struct timespec64 new_ts;
struct timezone new_tz;
 
if (tv) {
@@ -123,7 +123,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval 
__user *, tv,
return -EFAULT;
}
 
-   return do_sys_settimeofday(tv ? _ts : NULL, tz ? _tz : NULL);
+   return do_sys_settimeofday64(tv ? _ts : NULL, tz ? _tz : NULL);
 }
 
 static int __compat_get_timeval(struct timeval *tv, const struct 
compat_timeval __user *ctv)
diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c
index cd6716e..df275db 100644
--- a/kernel/time/posix-stubs.c
+++ b/kernel/time/posix-stubs.c
@@ -50,12 +50,15 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
const struct timespec __user *, tp)
 {
struct timespec new_tp;
+   struct timespec64 new_tp64;
 
if (which_clock != CLOCK_REALTIME)
return -EINVAL;
if (copy_from_user(_tp, tp, sizeof (*tp)))
return -EFAULT;
-   return do_sys_settimeofday(_tp, NULL);
+
+   new_tp64 = timespec_to_timespec64(new_tp);
+   return do_sys_settimeofday64(_tp64, NULL);
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 50a6a47..f215ef7 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -214,7 +214,10 @@ static int posix_clock_realtime_get(clockid_t which_clock, 
struct timespec *tp)
 static int posix_clock_realtime_set(const clockid_t which_clock,
const struct timespec *tp)
 {
-   return do_sys_settimeofday(tp, NULL);
+   struct timespec64 tp64;
+
+   tp64 = timespec_to_timespec64(*tp);
+   return do_sys_settimeofday64(, NULL);
 }
 
 static int posix_clock_realtime_adj(const clockid_t which_clock,
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 25bdd25..450e8a1 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -194,7 +194,7 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
struct timezone __user *, tz)
 {
struct timeval user_tv;
-   struct timespec new_ts;
+   struct timespec64 new_ts;
struct timezone new_tz;
 
if (tv) {
@@ -212,7 +212,7 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
return -EFAULT;
}
 
-   return do_sys_settimeofday(tv ? _ts : NULL, tz ? _tz : NULL);
+   return do_sys_settimeofday64(tv ? _ts : NULL, tz ? _tz : NULL);
 }
 
 SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)
-- 
2.7.4



[RESEND PATCH 7/7] Change k_clock nsleep() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 include/linux/hrtimer.h|  2 +-
 include/linux/posix-timers.h   |  2 +-
 kernel/compat.c|  6 --
 kernel/time/alarmtimer.c   |  4 ++--
 kernel/time/hrtimer.c  | 10 ++
 kernel/time/posix-cpu-timers.c | 36 ++--
 kernel/time/posix-stubs.c  |  6 --
 kernel/time/posix-timers.c | 10 ++
 8 files changed, 42 insertions(+), 34 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 249e579..7d019c0 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -456,7 +456,7 @@ static inline u64 hrtimer_forward_now(struct hrtimer *timer,
 }
 
 /* Precise sleep: */
-extern long hrtimer_nanosleep(struct timespec *rqtp,
+extern long hrtimer_nanosleep(struct timespec64 *rqtp,
  struct timespec __user *rmtp,
  const enum hrtimer_mode mode,
  const clockid_t clockid);
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index f608941..97a883a 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -94,7 +94,7 @@ struct k_clock {
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
int (*nsleep) (const clockid_t which_clock, int flags,
-  struct timespec *, struct timespec __user *);
+  struct timespec64 *, struct timespec __user *);
long (*nsleep_restart) (struct restart_block *restart_block);
int (*timer_set) (struct k_itimer * timr, int flags,
  struct itimerspec64 * new_setting,
diff --git a/kernel/compat.c b/kernel/compat.c
index e29a01a..8ec15d1 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -240,18 +240,20 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec 
__user *, rqtp,
   struct compat_timespec __user *, rmtp)
 {
struct timespec tu, rmt;
+   struct timespec64 tu64;
mm_segment_t oldfs;
long ret;
 
if (compat_get_timespec(, rqtp))
return -EFAULT;
 
-   if (!timespec_valid())
+   tu64 = timespec_to_timespec64(tu);
+   if (!timespec64_valid())
return -EINVAL;
 
oldfs = get_fs();
set_fs(KERNEL_DS);
-   ret = hrtimer_nanosleep(,
+   ret = hrtimer_nanosleep(,
rmtp ? (struct timespec __user *) : NULL,
HRTIMER_MODE_REL, CLOCK_MONOTONIC);
set_fs(oldfs);
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 81db6df..cc20417 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -790,7 +790,7 @@ static long __sched alarm_timer_nsleep_restart(struct 
restart_block *restart)
  * Handles clock_nanosleep calls against _ALARM clockids
  */
 static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
-struct timespec *tsreq, struct timespec __user *rmtp)
+struct timespec64 *tsreq, struct timespec __user *rmtp)
 {
enum  alarmtimer_type type = clock2alarm(which_clock);
struct alarm alarm;
@@ -809,7 +809,7 @@ static int alarm_timer_nsleep(const clockid_t which_clock, 
int flags,
 
alarm_init(, type, alarmtimer_nsleep_wakeup);
 
-   exp = timespec_to_ktime(*tsreq);
+   exp = timespec64_to_ktime(*tsreq);
/* Convert (if necessary) to absolute time */
if (flags != TIMER_ABSTIME) {
ktime_t now = alarm_bases[type].gettime();
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index ec08f52..f530295 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1506,7 +1506,7 @@ long __sched hrtimer_nanosleep_restart(struct 
restart_block *restart)
return ret;
 }
 
-long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
+long hrtimer_nanosleep(struct timespec64 *rqtp, struct timespec __user *rmtp,
   const enum hrtimer_mode mode, const clockid_t clockid)
 {
struct restart_block *restart;
@@ -1519,7 +1519,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct 
timespec __user *rmtp,
slack = 0;
 
hrtimer_init_on_stack(, clockid, mode);
-   hrtimer_set_expires_range_ns(, timespec_to_ktime(*rqtp), slack);
+   hrtimer_set_expires_range_ns(, timespec64_to_ktime(*rqtp), 
slack);
if (do_nanosleep(, mode))
goto out;
 
@@ -1551,14 +1551,16 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, 
rqtp,
struct timespec __user *, rmtp)
 {
struct timespec tu;

[RESEND PATCH 1/7] time: Delete do_sys_setimeofday()

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces will be changed in a separate
series.
Call to do_sys_setimeofday() is superfluous as all
the necessary checks and functions are done by the
underlying function do_sys_setimeofday64().
Replace do_sys_setimeofday64() directly instead of
do_sys_settimeofday(). The do_sys_setimeofday64()
calls timespec64_valid() internally, which is the
same as timespec_valid().

Signed-off-by: Deepa Dinamani 
---
 include/linux/timekeeping.h | 15 ---
 kernel/compat.c |  4 ++--
 kernel/time/posix-stubs.c   |  5 -
 kernel/time/posix-timers.c  |  5 -
 kernel/time/time.c  |  4 ++--
 5 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index b598cbc..3617a78 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -19,21 +19,6 @@ extern void do_gettimeofday(struct timeval *tv);
 extern int do_settimeofday64(const struct timespec64 *ts);
 extern int do_sys_settimeofday64(const struct timespec64 *tv,
 const struct timezone *tz);
-static inline int do_sys_settimeofday(const struct timespec *tv,
- const struct timezone *tz)
-{
-   struct timespec64 ts64;
-
-   if (!tv)
-   return do_sys_settimeofday64(NULL, tz);
-
-   if (!timespec_valid(tv))
-   return -EINVAL;
-
-   ts64 = timespec_to_timespec64(*tv);
-   return do_sys_settimeofday64(, tz);
-}
-
 /*
  * Kernel time accessors
  */
diff --git a/kernel/compat.c b/kernel/compat.c
index 19aec5d..e29a01a 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -109,7 +109,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval 
__user *, tv,
   struct timezone __user *, tz)
 {
struct timeval user_tv;
-   struct timespec new_ts;
+   struct timespec64 new_ts;
struct timezone new_tz;
 
if (tv) {
@@ -123,7 +123,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval 
__user *, tv,
return -EFAULT;
}
 
-   return do_sys_settimeofday(tv ? _ts : NULL, tz ? _tz : NULL);
+   return do_sys_settimeofday64(tv ? _ts : NULL, tz ? _tz : NULL);
 }
 
 static int __compat_get_timeval(struct timeval *tv, const struct 
compat_timeval __user *ctv)
diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c
index cd6716e..df275db 100644
--- a/kernel/time/posix-stubs.c
+++ b/kernel/time/posix-stubs.c
@@ -50,12 +50,15 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
const struct timespec __user *, tp)
 {
struct timespec new_tp;
+   struct timespec64 new_tp64;
 
if (which_clock != CLOCK_REALTIME)
return -EINVAL;
if (copy_from_user(_tp, tp, sizeof (*tp)))
return -EFAULT;
-   return do_sys_settimeofday(_tp, NULL);
+
+   new_tp64 = timespec_to_timespec64(new_tp);
+   return do_sys_settimeofday64(_tp64, NULL);
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 50a6a47..f215ef7 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -214,7 +214,10 @@ static int posix_clock_realtime_get(clockid_t which_clock, 
struct timespec *tp)
 static int posix_clock_realtime_set(const clockid_t which_clock,
const struct timespec *tp)
 {
-   return do_sys_settimeofday(tp, NULL);
+   struct timespec64 tp64;
+
+   tp64 = timespec_to_timespec64(*tp);
+   return do_sys_settimeofday64(, NULL);
 }
 
 static int posix_clock_realtime_adj(const clockid_t which_clock,
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 25bdd25..450e8a1 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -194,7 +194,7 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
struct timezone __user *, tz)
 {
struct timeval user_tv;
-   struct timespec new_ts;
+   struct timespec64 new_ts;
struct timezone new_tz;
 
if (tv) {
@@ -212,7 +212,7 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
return -EFAULT;
}
 
-   return do_sys_settimeofday(tv ? _ts : NULL, tz ? _tz : NULL);
+   return do_sys_settimeofday64(tv ? _ts : NULL, tz ? _tz : NULL);
 }
 
 SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)
-- 
2.7.4



[RESEND PATCH 7/7] Change k_clock nsleep() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 include/linux/hrtimer.h|  2 +-
 include/linux/posix-timers.h   |  2 +-
 kernel/compat.c|  6 --
 kernel/time/alarmtimer.c   |  4 ++--
 kernel/time/hrtimer.c  | 10 ++
 kernel/time/posix-cpu-timers.c | 36 ++--
 kernel/time/posix-stubs.c  |  6 --
 kernel/time/posix-timers.c | 10 ++
 8 files changed, 42 insertions(+), 34 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 249e579..7d019c0 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -456,7 +456,7 @@ static inline u64 hrtimer_forward_now(struct hrtimer *timer,
 }
 
 /* Precise sleep: */
-extern long hrtimer_nanosleep(struct timespec *rqtp,
+extern long hrtimer_nanosleep(struct timespec64 *rqtp,
  struct timespec __user *rmtp,
  const enum hrtimer_mode mode,
  const clockid_t clockid);
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index f608941..97a883a 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -94,7 +94,7 @@ struct k_clock {
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
int (*nsleep) (const clockid_t which_clock, int flags,
-  struct timespec *, struct timespec __user *);
+  struct timespec64 *, struct timespec __user *);
long (*nsleep_restart) (struct restart_block *restart_block);
int (*timer_set) (struct k_itimer * timr, int flags,
  struct itimerspec64 * new_setting,
diff --git a/kernel/compat.c b/kernel/compat.c
index e29a01a..8ec15d1 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -240,18 +240,20 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec 
__user *, rqtp,
   struct compat_timespec __user *, rmtp)
 {
struct timespec tu, rmt;
+   struct timespec64 tu64;
mm_segment_t oldfs;
long ret;
 
if (compat_get_timespec(, rqtp))
return -EFAULT;
 
-   if (!timespec_valid())
+   tu64 = timespec_to_timespec64(tu);
+   if (!timespec64_valid())
return -EINVAL;
 
oldfs = get_fs();
set_fs(KERNEL_DS);
-   ret = hrtimer_nanosleep(,
+   ret = hrtimer_nanosleep(,
rmtp ? (struct timespec __user *) : NULL,
HRTIMER_MODE_REL, CLOCK_MONOTONIC);
set_fs(oldfs);
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 81db6df..cc20417 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -790,7 +790,7 @@ static long __sched alarm_timer_nsleep_restart(struct 
restart_block *restart)
  * Handles clock_nanosleep calls against _ALARM clockids
  */
 static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
-struct timespec *tsreq, struct timespec __user *rmtp)
+struct timespec64 *tsreq, struct timespec __user *rmtp)
 {
enum  alarmtimer_type type = clock2alarm(which_clock);
struct alarm alarm;
@@ -809,7 +809,7 @@ static int alarm_timer_nsleep(const clockid_t which_clock, 
int flags,
 
alarm_init(, type, alarmtimer_nsleep_wakeup);
 
-   exp = timespec_to_ktime(*tsreq);
+   exp = timespec64_to_ktime(*tsreq);
/* Convert (if necessary) to absolute time */
if (flags != TIMER_ABSTIME) {
ktime_t now = alarm_bases[type].gettime();
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index ec08f52..f530295 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1506,7 +1506,7 @@ long __sched hrtimer_nanosleep_restart(struct 
restart_block *restart)
return ret;
 }
 
-long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
+long hrtimer_nanosleep(struct timespec64 *rqtp, struct timespec __user *rmtp,
   const enum hrtimer_mode mode, const clockid_t clockid)
 {
struct restart_block *restart;
@@ -1519,7 +1519,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct 
timespec __user *rmtp,
slack = 0;
 
hrtimer_init_on_stack(, clockid, mode);
-   hrtimer_set_expires_range_ns(, timespec_to_ktime(*rqtp), slack);
+   hrtimer_set_expires_range_ns(, timespec64_to_ktime(*rqtp), 
slack);
if (do_nanosleep(, mode))
goto out;
 
@@ -1551,14 +1551,16 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, 
rqtp,
struct timespec __user *, rmtp)
 {
struct timespec tu;
+   struct 

[RESEND PATCH 0/7] Change k_clock interfaces to use timespec64

2017-03-18 Thread Deepa Dinamani
Resending to update author id in patch 7/7.

The series is aimed at replacing struct timespec which is not
y2038 safe with y2038 safe struct timespec64 for k_clock interfaces.

The series does not change the syscall interface.
This will be done in a follow up series.

A few existing checkpatch-noted style issues, such as the 80 line
character limit, have been left as-is to facilitate easier review.

Deepa Dinamani (7):
  time: Delete do_sys_setimeofday()
  time: Change posix clocks ops interfaces to use timespec64
  Change k_clock clock_get() to use timespec64
  Change k_clock clock_getres() to use timespec64
  Change k_clock clock_set() to use timespec64
  Change k_clock timer_set() and timer_get() to use timespec64
  Change k_clock nsleep() to use timespec64

 drivers/char/mmtimer.c | 28 ++---
 drivers/ptp/ptp_clock.c| 18 
 include/linux/hrtimer.h|  2 +-
 include/linux/posix-clock.h| 10 ++---
 include/linux/posix-timers.h   | 14 +++
 include/linux/timekeeping.h| 20 +++--
 kernel/compat.c| 10 +++--
 kernel/time/alarmtimer.c   | 24 +--
 kernel/time/hrtimer.c  | 10 +++--
 kernel/time/posix-clock.c  | 10 ++---
 kernel/time/posix-cpu-timers.c | 66 --
 kernel/time/posix-stubs.c  | 20 ++---
 kernel/time/posix-timers.c | 93 --
 kernel/time/time.c |  4 +-
 14 files changed, 172 insertions(+), 157 deletions(-)

-- 
2.7.4



[RESEND PATCH 0/7] Change k_clock interfaces to use timespec64

2017-03-18 Thread Deepa Dinamani
Resending to update author id in patch 7/7.

The series is aimed at replacing struct timespec which is not
y2038 safe with y2038 safe struct timespec64 for k_clock interfaces.

The series does not change the syscall interface.
This will be done in a follow up series.

A few existing checkpatch-noted style issues, such as the 80 line
character limit, have been left as-is to facilitate easier review.

Deepa Dinamani (7):
  time: Delete do_sys_setimeofday()
  time: Change posix clocks ops interfaces to use timespec64
  Change k_clock clock_get() to use timespec64
  Change k_clock clock_getres() to use timespec64
  Change k_clock clock_set() to use timespec64
  Change k_clock timer_set() and timer_get() to use timespec64
  Change k_clock nsleep() to use timespec64

 drivers/char/mmtimer.c | 28 ++---
 drivers/ptp/ptp_clock.c| 18 
 include/linux/hrtimer.h|  2 +-
 include/linux/posix-clock.h| 10 ++---
 include/linux/posix-timers.h   | 14 +++
 include/linux/timekeeping.h| 20 +++--
 kernel/compat.c| 10 +++--
 kernel/time/alarmtimer.c   | 24 +--
 kernel/time/hrtimer.c  | 10 +++--
 kernel/time/posix-clock.c  | 10 ++---
 kernel/time/posix-cpu-timers.c | 66 --
 kernel/time/posix-stubs.c  | 20 ++---
 kernel/time/posix-timers.c | 93 --
 kernel/time/time.c |  4 +-
 14 files changed, 172 insertions(+), 157 deletions(-)

-- 
2.7.4



[PATCH v2 3/3] staging: speakup: Simplify "NULL" comparisons

2017-03-18 Thread Arushi Singhal
Fixed coding style for null comparisons in speakup driver to be more
consistant with the rest of the kernel coding style.
Replaced 'x != NULL' with 'x' and 'x = NULL' with '!x'.

Signed-off-by: Arushi Singhal 
---
changes in v2
 - no change

 drivers/staging/speakup/selection.c   | 2 +-
 drivers/staging/speakup/varhandlers.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/speakup/selection.c 
b/drivers/staging/speakup/selection.c
index afd9a446a06f..4417c00e68a7 100644
--- a/drivers/staging/speakup/selection.c
+++ b/drivers/staging/speakup/selection.c
@@ -175,7 +175,7 @@ static struct speakup_paste_work speakup_paste_work = {
 
 int speakup_paste_selection(struct tty_struct *tty)
 {
-   if (cmpxchg(_paste_work.tty, NULL, tty) != NULL)
+   if (cmpxchg(_paste_work.tty, NULL, tty))
return -EBUSY;
 
tty_kref_get(tty);
diff --git a/drivers/staging/speakup/varhandlers.c 
b/drivers/staging/speakup/varhandlers.c
index cc984196020f..5910fe0b1365 100644
--- a/drivers/staging/speakup/varhandlers.c
+++ b/drivers/staging/speakup/varhandlers.c
@@ -98,7 +98,7 @@ void speakup_register_var(struct var_t *var)
}
}
p_header = var_ptrs[var->var_id];
-   if (p_header->data != NULL)
+   if (p_header->data)
return;
p_header->data = var;
switch (p_header->var_type) {
@@ -210,11 +210,11 @@ int spk_set_num_var(int input, struct st_var_header *var, 
int how)
return -ERANGE;
 
var_data->u.n.value = val;
-   if (var->var_type == VAR_TIME && p_val != NULL) {
+   if (var->var_type == VAR_TIME && p_val) {
*p_val = msecs_to_jiffies(val);
return 0;
}
-   if (p_val != NULL)
+   if (p_val)
*p_val = val;
if (var->var_id == PUNC_LEVEL) {
spk_punc_mask = spk_punc_masks[val];
-- 
2.11.0



[PATCH v2 3/3] staging: speakup: Simplify "NULL" comparisons

2017-03-18 Thread Arushi Singhal
Fixed coding style for null comparisons in speakup driver to be more
consistant with the rest of the kernel coding style.
Replaced 'x != NULL' with 'x' and 'x = NULL' with '!x'.

Signed-off-by: Arushi Singhal 
---
changes in v2
 - no change

 drivers/staging/speakup/selection.c   | 2 +-
 drivers/staging/speakup/varhandlers.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/speakup/selection.c 
b/drivers/staging/speakup/selection.c
index afd9a446a06f..4417c00e68a7 100644
--- a/drivers/staging/speakup/selection.c
+++ b/drivers/staging/speakup/selection.c
@@ -175,7 +175,7 @@ static struct speakup_paste_work speakup_paste_work = {
 
 int speakup_paste_selection(struct tty_struct *tty)
 {
-   if (cmpxchg(_paste_work.tty, NULL, tty) != NULL)
+   if (cmpxchg(_paste_work.tty, NULL, tty))
return -EBUSY;
 
tty_kref_get(tty);
diff --git a/drivers/staging/speakup/varhandlers.c 
b/drivers/staging/speakup/varhandlers.c
index cc984196020f..5910fe0b1365 100644
--- a/drivers/staging/speakup/varhandlers.c
+++ b/drivers/staging/speakup/varhandlers.c
@@ -98,7 +98,7 @@ void speakup_register_var(struct var_t *var)
}
}
p_header = var_ptrs[var->var_id];
-   if (p_header->data != NULL)
+   if (p_header->data)
return;
p_header->data = var;
switch (p_header->var_type) {
@@ -210,11 +210,11 @@ int spk_set_num_var(int input, struct st_var_header *var, 
int how)
return -ERANGE;
 
var_data->u.n.value = val;
-   if (var->var_type == VAR_TIME && p_val != NULL) {
+   if (var->var_type == VAR_TIME && p_val) {
*p_val = msecs_to_jiffies(val);
return 0;
}
-   if (p_val != NULL)
+   if (p_val)
*p_val = val;
if (var->var_id == PUNC_LEVEL) {
spk_punc_mask = spk_punc_masks[val];
-- 
2.11.0



[PATCH v2 2/3] staging: speakup: Remove multiple assignments

2017-03-18 Thread Arushi Singhal
This patch fixes the checkpatch.pl warning "multiple assignments
should be avoided."

Signed-off-by: Arushi Singhal 
---
changes in v2
 - no change.

 drivers/staging/speakup/main.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index f71206878363..f8fccc8bf6b2 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -270,9 +270,12 @@ static unsigned char get_attributes(struct vc_data *vc, 
u16 *pos)
 
 static void speakup_date(struct vc_data *vc)
 {
-   spk_x = spk_cx = vc->vc_x;
-   spk_y = spk_cy = vc->vc_y;
-   spk_pos = spk_cp = vc->vc_pos;
+   spk_x = vc->vc_x;
+   spk_cx = spk_x;
+   spk_y = vc->vc_y;
+   spk_cy = spk_y;
+   spk_pos = vc->vc_pos;
+   spk_cp = spk_pos;
spk_old_attr = spk_attr;
spk_attr = get_attributes(vc, (u_short *)spk_pos);
 }
@@ -1655,9 +1658,12 @@ static int speak_highlight(struct vc_data *vc)
spk_do_flush();
spkup_write(speakup_console[vc_num]->ht.highbuf[hc],
speakup_console[vc_num]->ht.highsize[hc]);
-   spk_pos = spk_cp = speakup_console[vc_num]->ht.rpos[hc];
-   spk_x = spk_cx = speakup_console[vc_num]->ht.rx[hc];
-   spk_y = spk_cy = speakup_console[vc_num]->ht.ry[hc];
+   spk_pos = speakup_console[vc_num]->ht.rpos[hc];
+   spk_cp = spk_pos;
+   spk_x = speakup_console[vc_num]->ht.rx[hc];
+   spk_cx = spk_x;
+   spk_y = speakup_console[vc_num]->ht.ry[hc];
+   spk_cy = spk_y;
return 1;
}
return 0;
-- 
2.11.0



[PATCH v2 0/3] staging: speakup: Multiple checkpatch issues

2017-03-18 Thread Arushi Singhal
Improve readability by fixing multiple checkpatch.pl
issues in speakup driver.

Arushi Singhal (3):
  staging: speakup: Moved logical to previous line.
  staging: speakup: Remove multiple assignments
  staging: speakup: Simplify "NULL" comparisons

 drivers/staging/speakup/main.c| 30 ++
 drivers/staging/speakup/selection.c   |  2 +-
 drivers/staging/speakup/varhandlers.c |  6 +++---
 3 files changed, 22 insertions(+), 16 deletions(-)

-- 
changes in v2
 -change the commit message of [patch 1/3] as was wrong
2.11.0



[PATCH v2 1/3] staging: speakup: Moved logical to previous line.

2017-03-18 Thread Arushi Singhal
Moved logical AND operator to previous line to fix the following
checkpatch issue:

CHECK: Logical continuations should be on the previous line.

Signed-off-by: Arushi Singhal 
---
changes in v2
 - Change the commit message.

 drivers/staging/speakup/main.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index f280e22d7e15..f71206878363 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -905,8 +905,8 @@ static int get_sentence_buf(struct vc_data *vc, int 
read_punc)
while (start < end) {
sentbuf[bn][i] = get_char(vc, (u_short *)start, );
if (i > 0) {
-   if (sentbuf[bn][i] == SPACE && sentbuf[bn][i - 1] == '.'
-   && numsentences[bn] < 9) {
+   if (sentbuf[bn][i] == SPACE && sentbuf[bn][i - 1] == 
'.' &&
+   numsentences[bn] < 9) {
/* Sentence Marker */
numsentences[bn]++;
sentmarks[bn][numsentences[bn]] =
@@ -1292,8 +1292,8 @@ void spk_reset_default_chars(void)
 
/* First, free any non-default */
for (i = 0; i < 256; i++) {
-   if ((spk_characters[i] != NULL)
-   && (spk_characters[i] != spk_default_chars[i]))
+   if (spk_characters[i] &&
+   (spk_characters[i] != spk_default_chars[i]))
kfree(spk_characters[i]);
}
 
@@ -2088,8 +2088,8 @@ speakup_key(struct vc_data *vc, int shift_state, int 
keycode, u_short keysym,
tty = vc->port.tty;
if (type >= 0xf0)
type -= 0xf0;
-   if (type == KT_PAD
-   && (vt_get_leds(fg_console, VC_NUMLOCK))) {
+   if (type == KT_PAD &&
+   (vt_get_leds(fg_console, VC_NUMLOCK))) {
if (up_flag) {
spk_keydown = 0;
goto out;
-- 
2.11.0



[PATCH v2 0/3] staging: speakup: Multiple checkpatch issues

2017-03-18 Thread Arushi Singhal
Improve readability by fixing multiple checkpatch.pl
issues in speakup driver.

Arushi Singhal (3):
  staging: speakup: Moved logical to previous line.
  staging: speakup: Remove multiple assignments
  staging: speakup: Simplify "NULL" comparisons

 drivers/staging/speakup/main.c| 30 ++
 drivers/staging/speakup/selection.c   |  2 +-
 drivers/staging/speakup/varhandlers.c |  6 +++---
 3 files changed, 22 insertions(+), 16 deletions(-)

-- 
changes in v2
 -change the commit message of [patch 1/3] as was wrong
2.11.0



[PATCH v2 1/3] staging: speakup: Moved logical to previous line.

2017-03-18 Thread Arushi Singhal
Moved logical AND operator to previous line to fix the following
checkpatch issue:

CHECK: Logical continuations should be on the previous line.

Signed-off-by: Arushi Singhal 
---
changes in v2
 - Change the commit message.

 drivers/staging/speakup/main.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index f280e22d7e15..f71206878363 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -905,8 +905,8 @@ static int get_sentence_buf(struct vc_data *vc, int 
read_punc)
while (start < end) {
sentbuf[bn][i] = get_char(vc, (u_short *)start, );
if (i > 0) {
-   if (sentbuf[bn][i] == SPACE && sentbuf[bn][i - 1] == '.'
-   && numsentences[bn] < 9) {
+   if (sentbuf[bn][i] == SPACE && sentbuf[bn][i - 1] == 
'.' &&
+   numsentences[bn] < 9) {
/* Sentence Marker */
numsentences[bn]++;
sentmarks[bn][numsentences[bn]] =
@@ -1292,8 +1292,8 @@ void spk_reset_default_chars(void)
 
/* First, free any non-default */
for (i = 0; i < 256; i++) {
-   if ((spk_characters[i] != NULL)
-   && (spk_characters[i] != spk_default_chars[i]))
+   if (spk_characters[i] &&
+   (spk_characters[i] != spk_default_chars[i]))
kfree(spk_characters[i]);
}
 
@@ -2088,8 +2088,8 @@ speakup_key(struct vc_data *vc, int shift_state, int 
keycode, u_short keysym,
tty = vc->port.tty;
if (type >= 0xf0)
type -= 0xf0;
-   if (type == KT_PAD
-   && (vt_get_leds(fg_console, VC_NUMLOCK))) {
+   if (type == KT_PAD &&
+   (vt_get_leds(fg_console, VC_NUMLOCK))) {
if (up_flag) {
spk_keydown = 0;
goto out;
-- 
2.11.0



[PATCH v2 2/3] staging: speakup: Remove multiple assignments

2017-03-18 Thread Arushi Singhal
This patch fixes the checkpatch.pl warning "multiple assignments
should be avoided."

Signed-off-by: Arushi Singhal 
---
changes in v2
 - no change.

 drivers/staging/speakup/main.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index f71206878363..f8fccc8bf6b2 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -270,9 +270,12 @@ static unsigned char get_attributes(struct vc_data *vc, 
u16 *pos)
 
 static void speakup_date(struct vc_data *vc)
 {
-   spk_x = spk_cx = vc->vc_x;
-   spk_y = spk_cy = vc->vc_y;
-   spk_pos = spk_cp = vc->vc_pos;
+   spk_x = vc->vc_x;
+   spk_cx = spk_x;
+   spk_y = vc->vc_y;
+   spk_cy = spk_y;
+   spk_pos = vc->vc_pos;
+   spk_cp = spk_pos;
spk_old_attr = spk_attr;
spk_attr = get_attributes(vc, (u_short *)spk_pos);
 }
@@ -1655,9 +1658,12 @@ static int speak_highlight(struct vc_data *vc)
spk_do_flush();
spkup_write(speakup_console[vc_num]->ht.highbuf[hc],
speakup_console[vc_num]->ht.highsize[hc]);
-   spk_pos = spk_cp = speakup_console[vc_num]->ht.rpos[hc];
-   spk_x = spk_cx = speakup_console[vc_num]->ht.rx[hc];
-   spk_y = spk_cy = speakup_console[vc_num]->ht.ry[hc];
+   spk_pos = speakup_console[vc_num]->ht.rpos[hc];
+   spk_cp = spk_pos;
+   spk_x = speakup_console[vc_num]->ht.rx[hc];
+   spk_cx = spk_x;
+   spk_y = speakup_console[vc_num]->ht.ry[hc];
+   spk_cy = spk_y;
return 1;
}
return 0;
-- 
2.11.0



[PATCH] ARM: dts: sun7i: lamobo-r1: Fix CPU port RGMII settings

2017-03-18 Thread Florian Fainelli
The CPU port of the BCM53125 is configured with RGMII (no delays) but
this should actually be RGMII with transmit delay (rgmii-txid) because
STMMAC takes care of inserting the transmitter delay. This fixes
occasional packet loss encountered.

Fixes: d7b9eaff5f0c ("ARM: dts: sun7i: Add BCM53125 switch nodes to the 
lamobo-r1 board")
Reported-by: Hartmut Knaack 
Signed-off-by: Florian Fainelli 
---
 arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts 
b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
index 72ec0d5ae052..bbf1c8cbaac6 100644
--- a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
+++ b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
@@ -167,7 +167,7 @@
reg = <8>;
label = "cpu";
ethernet = <>;
-   phy-mode = "rgmii";
+   phy-mode = "rgmii-txid";
fixed-link {
speed = <1000>;
full-duplex;
-- 
2.9.3



[PATCH] ARM: dts: sun7i: lamobo-r1: Fix CPU port RGMII settings

2017-03-18 Thread Florian Fainelli
The CPU port of the BCM53125 is configured with RGMII (no delays) but
this should actually be RGMII with transmit delay (rgmii-txid) because
STMMAC takes care of inserting the transmitter delay. This fixes
occasional packet loss encountered.

Fixes: d7b9eaff5f0c ("ARM: dts: sun7i: Add BCM53125 switch nodes to the 
lamobo-r1 board")
Reported-by: Hartmut Knaack 
Signed-off-by: Florian Fainelli 
---
 arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts 
b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
index 72ec0d5ae052..bbf1c8cbaac6 100644
--- a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
+++ b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
@@ -167,7 +167,7 @@
reg = <8>;
label = "cpu";
ethernet = <>;
-   phy-mode = "rgmii";
+   phy-mode = "rgmii-txid";
fixed-link {
speed = <1000>;
full-duplex;
-- 
2.9.3



Re: [PATCH/RFC] staging/lustre: Rework class_process_proc_param

2017-03-18 Thread Oleg Drokin

On Mar 19, 2017, at 12:41 AM, Greg Kroah-Hartman wrote:

> On Sat, Mar 18, 2017 at 02:24:08AM -0400, Oleg Drokin wrote:
>> Ever since sysfs migration, class_process_proc_param stopped working
>> correctly as all the useful params were no longer present as lvars.
>> Replace all the nasty fake proc writes with hopefully less nasty
>> kobject attribute search and then update the attributes as needed.
>> 
>> Signed-off-by: Oleg Drokin 
>> Reported-by: Al Viro 
>> ---
>> Al has quite rightfully complained in the past that class_process_proc_param
>> is a terrible piece of code and needs to go.
>> This patch is an attempt at improving it somewhat and in process drop
>> all the user/kernel address space games we needed to play to make it work
>> in the past (and which I suspect attracted Al's attention in the first 
>> place).
>> 
>> Now I wonder if iterating kobject attributes like that would be ok with
>> you Greg, or do you think there is a better way?
>> class_find_write_attr could be turned into something generic since it's
>> certainly convenient to reuse same table of name-write_method pairs,
>> but I did some cursory research and nobody else seems to need anything
>> of the sort in-tree.
>> 
>> I know ll_process_config is still awful and I will likely just
>> replace the current hack with kset_find_obj, but I just wanted to make
>> sure this new approach would be ok before spending too much time on it.
>> 
>> Thanks!
>> 
>> drivers/staging/lustre/lustre/include/obd_class.h  |  4 +-
>> drivers/staging/lustre/lustre/llite/llite_lib.c| 10 +--
>> drivers/staging/lustre/lustre/lov/lov_obd.c|  3 +-
>> drivers/staging/lustre/lustre/mdc/mdc_request.c|  3 +-
>> .../staging/lustre/lustre/obdclass/obd_config.c| 78 
>> ++
>> drivers/staging/lustre/lustre/osc/osc_request.c|  3 +-
>> 6 files changed, 44 insertions(+), 57 deletions(-)
>> 
>> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
>> b/drivers/staging/lustre/lustre/include/obd_class.h
>> index 083a6ff..badafb8 100644
>> --- a/drivers/staging/lustre/lustre/include/obd_class.h
>> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
>> @@ -114,8 +114,8 @@ typedef int (*llog_cb_t)(const struct lu_env *, struct 
>> llog_handle *,
>>   struct llog_rec_hdr *, void *);
>> /* obd_config.c */
>> int class_process_config(struct lustre_cfg *lcfg);
>> -int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
>> - struct lustre_cfg *lcfg, void *data);
>> +int class_process_attr_param(char *prefix, struct kobject *kobj,
>> + struct lustre_cfg *lcfg);
> 
> As you are exporting these functions, they will need to end up with a
> lustre_* prefix eventually :)

ok.

> 
>> struct obd_device *class_incref(struct obd_device *obd,
>>  const char *scope, const void *source);
>> void class_decref(struct obd_device *obd,
>> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
>> b/drivers/staging/lustre/lustre/llite/llite_lib.c
>> index 7b80040..192b877 100644
>> --- a/drivers/staging/lustre/lustre/llite/llite_lib.c
>> +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
>> @@ -2259,7 +2259,7 @@ int ll_obd_statfs(struct inode *inode, void __user 
>> *arg)
>> int ll_process_config(struct lustre_cfg *lcfg)
>> {
>>  char *ptr;
>> -void *sb;
>> +struct super_block *sb;
>>  struct lprocfs_static_vars lvars;
>>  unsigned long x;
>>  int rc = 0;
>> @@ -2273,15 +2273,15 @@ int ll_process_config(struct lustre_cfg *lcfg)
>>  rc = kstrtoul(ptr, 16, );
>>  if (rc != 0)
>>  return -EINVAL;
>> -sb = (void *)x;
>> +sb = (struct super_block *)x;
>>  /* This better be a real Lustre superblock! */
>> -LASSERT(s2lsi((struct super_block *)sb)->lsi_lmd->lmd_magic == 
>> LMD_MAGIC);
>> +LASSERT(s2lsi(sb)->lsi_lmd->lmd_magic == LMD_MAGIC);
>> 
>>  /* Note we have not called client_common_fill_super yet, so
>>   * proc fns must be able to handle that!
>>   */
>> -rc = class_process_proc_param(PARAM_LLITE, lvars.obd_vars,
>> -  lcfg, sb);
>> +rc = class_process_attr_param(PARAM_LLITE, _s2sbi(sb)->ll_kobj,
>> +  lcfg);
>>  if (rc > 0)
>>  rc = 0;
>>  return rc;
>> diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c 
>> b/drivers/staging/lustre/lustre/lov/lov_obd.c
>> index b3161fb..c33a327 100644
>> --- a/drivers/staging/lustre/lustre/lov/lov_obd.c
>> +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
>> @@ -926,8 +926,7 @@ int lov_process_config_base(struct obd_device *obd, 
>> struct lustre_cfg *lcfg,
>> 
>>  lprocfs_lov_init_vars();
>> 
>> -rc = class_process_proc_param(PARAM_LOV, lvars.obd_vars,
>> -  lcfg, obd);
>> +rc = 

[PATCH] ARM: dts: sun7i: lamobo-r1: Fix CPU port RGMII settings

2017-03-18 Thread Florian Fainelli
The CPU port of the BCM53125 is configured with RGMII (no delays) but
this should actually be RGMII with transmit delay (rgmii-txid) because
STMMAC takes care of inserting the transmitter delay. This fixes
occasional packet loss encountered.

Fixes: d7b9eaff5f0c ("ARM: dts: sun7i: Add BCM53125 switch nodes to the 
lamobo-r1 board")
Reported-by: Hartmut Knaack 
Signed-off-by: Florian Fainelli 
---
 arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts 
b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
index 72ec0d5ae052..bbf1c8cbaac6 100644
--- a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
+++ b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
@@ -167,7 +167,7 @@
reg = <8>;
label = "cpu";
ethernet = <>;
-   phy-mode = "rgmii";
+   phy-mode = "rgmii-txid";
fixed-link {
speed = <1000>;
full-duplex;
-- 
2.9.3



Re: [PATCH/RFC] staging/lustre: Rework class_process_proc_param

2017-03-18 Thread Oleg Drokin

On Mar 19, 2017, at 12:41 AM, Greg Kroah-Hartman wrote:

> On Sat, Mar 18, 2017 at 02:24:08AM -0400, Oleg Drokin wrote:
>> Ever since sysfs migration, class_process_proc_param stopped working
>> correctly as all the useful params were no longer present as lvars.
>> Replace all the nasty fake proc writes with hopefully less nasty
>> kobject attribute search and then update the attributes as needed.
>> 
>> Signed-off-by: Oleg Drokin 
>> Reported-by: Al Viro 
>> ---
>> Al has quite rightfully complained in the past that class_process_proc_param
>> is a terrible piece of code and needs to go.
>> This patch is an attempt at improving it somewhat and in process drop
>> all the user/kernel address space games we needed to play to make it work
>> in the past (and which I suspect attracted Al's attention in the first 
>> place).
>> 
>> Now I wonder if iterating kobject attributes like that would be ok with
>> you Greg, or do you think there is a better way?
>> class_find_write_attr could be turned into something generic since it's
>> certainly convenient to reuse same table of name-write_method pairs,
>> but I did some cursory research and nobody else seems to need anything
>> of the sort in-tree.
>> 
>> I know ll_process_config is still awful and I will likely just
>> replace the current hack with kset_find_obj, but I just wanted to make
>> sure this new approach would be ok before spending too much time on it.
>> 
>> Thanks!
>> 
>> drivers/staging/lustre/lustre/include/obd_class.h  |  4 +-
>> drivers/staging/lustre/lustre/llite/llite_lib.c| 10 +--
>> drivers/staging/lustre/lustre/lov/lov_obd.c|  3 +-
>> drivers/staging/lustre/lustre/mdc/mdc_request.c|  3 +-
>> .../staging/lustre/lustre/obdclass/obd_config.c| 78 
>> ++
>> drivers/staging/lustre/lustre/osc/osc_request.c|  3 +-
>> 6 files changed, 44 insertions(+), 57 deletions(-)
>> 
>> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
>> b/drivers/staging/lustre/lustre/include/obd_class.h
>> index 083a6ff..badafb8 100644
>> --- a/drivers/staging/lustre/lustre/include/obd_class.h
>> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
>> @@ -114,8 +114,8 @@ typedef int (*llog_cb_t)(const struct lu_env *, struct 
>> llog_handle *,
>>   struct llog_rec_hdr *, void *);
>> /* obd_config.c */
>> int class_process_config(struct lustre_cfg *lcfg);
>> -int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
>> - struct lustre_cfg *lcfg, void *data);
>> +int class_process_attr_param(char *prefix, struct kobject *kobj,
>> + struct lustre_cfg *lcfg);
> 
> As you are exporting these functions, they will need to end up with a
> lustre_* prefix eventually :)

ok.

> 
>> struct obd_device *class_incref(struct obd_device *obd,
>>  const char *scope, const void *source);
>> void class_decref(struct obd_device *obd,
>> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
>> b/drivers/staging/lustre/lustre/llite/llite_lib.c
>> index 7b80040..192b877 100644
>> --- a/drivers/staging/lustre/lustre/llite/llite_lib.c
>> +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
>> @@ -2259,7 +2259,7 @@ int ll_obd_statfs(struct inode *inode, void __user 
>> *arg)
>> int ll_process_config(struct lustre_cfg *lcfg)
>> {
>>  char *ptr;
>> -void *sb;
>> +struct super_block *sb;
>>  struct lprocfs_static_vars lvars;
>>  unsigned long x;
>>  int rc = 0;
>> @@ -2273,15 +2273,15 @@ int ll_process_config(struct lustre_cfg *lcfg)
>>  rc = kstrtoul(ptr, 16, );
>>  if (rc != 0)
>>  return -EINVAL;
>> -sb = (void *)x;
>> +sb = (struct super_block *)x;
>>  /* This better be a real Lustre superblock! */
>> -LASSERT(s2lsi((struct super_block *)sb)->lsi_lmd->lmd_magic == 
>> LMD_MAGIC);
>> +LASSERT(s2lsi(sb)->lsi_lmd->lmd_magic == LMD_MAGIC);
>> 
>>  /* Note we have not called client_common_fill_super yet, so
>>   * proc fns must be able to handle that!
>>   */
>> -rc = class_process_proc_param(PARAM_LLITE, lvars.obd_vars,
>> -  lcfg, sb);
>> +rc = class_process_attr_param(PARAM_LLITE, _s2sbi(sb)->ll_kobj,
>> +  lcfg);
>>  if (rc > 0)
>>  rc = 0;
>>  return rc;
>> diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c 
>> b/drivers/staging/lustre/lustre/lov/lov_obd.c
>> index b3161fb..c33a327 100644
>> --- a/drivers/staging/lustre/lustre/lov/lov_obd.c
>> +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
>> @@ -926,8 +926,7 @@ int lov_process_config_base(struct obd_device *obd, 
>> struct lustre_cfg *lcfg,
>> 
>>  lprocfs_lov_init_vars();
>> 
>> -rc = class_process_proc_param(PARAM_LOV, lvars.obd_vars,
>> -  lcfg, obd);
>> +rc = class_process_attr_param(PARAM_LOV, >obd_kobj, lcfg);
>> 

[PATCH] ARM: dts: sun7i: lamobo-r1: Fix CPU port RGMII settings

2017-03-18 Thread Florian Fainelli
The CPU port of the BCM53125 is configured with RGMII (no delays) but
this should actually be RGMII with transmit delay (rgmii-txid) because
STMMAC takes care of inserting the transmitter delay. This fixes
occasional packet loss encountered.

Fixes: d7b9eaff5f0c ("ARM: dts: sun7i: Add BCM53125 switch nodes to the 
lamobo-r1 board")
Reported-by: Hartmut Knaack 
Signed-off-by: Florian Fainelli 
---
 arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts 
b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
index 72ec0d5ae052..bbf1c8cbaac6 100644
--- a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
+++ b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts
@@ -167,7 +167,7 @@
reg = <8>;
label = "cpu";
ethernet = <>;
-   phy-mode = "rgmii";
+   phy-mode = "rgmii-txid";
fixed-link {
speed = <1000>;
full-duplex;
-- 
2.9.3



[PATCH] staging: speakup: fix: braces {} should used on all arms of statement

2017-03-18 Thread Arushi Singhal
This patch fixes the checks reported by checkpatch.pl
for braces {} should be used on all arms of this statement.

Signed-off-by: Arushi Singhal 
---
 drivers/staging/speakup/main.c   | 35 +++-
 drivers/staging/speakup/speakup_decext.c |  6 +++---
 drivers/staging/speakup/speakup_decpc.c  |  6 +++---
 drivers/staging/speakup/speakup_dectlk.c |  6 +++---
 drivers/staging/speakup/varhandlers.c| 12 ++-
 5 files changed, 37 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index f8fccc8bf6b2..21e76b031449 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -409,8 +409,9 @@ static void say_attributes(struct vc_data *vc)
if (bg > 7) {
synth_printf(" %s ", spk_msg_get(MSG_ON_BLINKING));
bg -= 8;
-   } else
+   } else {
synth_printf(" %s ", spk_msg_get(MSG_ON));
+   }
synth_printf("%s\n", spk_msg_get(MSG_COLORS_START + bg));
 }
 
@@ -643,8 +644,9 @@ static void say_prev_word(struct vc_data *vc)
break;
spk_y--;
spk_x = vc->vc_cols - 1;
-   } else
+   } else {
spk_x--;
+   }
spk_pos -= 2;
ch = get_char(vc, (u_short *)spk_pos, );
if (ch == SPACE || ch == 0)
@@ -697,8 +699,9 @@ static void say_next_word(struct vc_data *vc)
spk_y++;
spk_x = 0;
edge_said = edge_right;
-   } else
+   } else {
spk_x++;
+   }
spk_pos += 2;
last_state = state;
}
@@ -729,8 +732,9 @@ static void spell_word(struct vc_data *vc)
spk_pitch_shift++;
else/* synth has no pitch */
last_cap = spk_str_caps_stop;
-   } else
+   } else {
str_cap = spk_str_caps_stop;
+   }
if (str_cap != last_cap) {
synth_printf("%s", str_cap);
last_cap = str_cap;
@@ -1343,8 +1347,9 @@ static int speakup_allocate(struct vc_data *vc)
if (!speakup_console[vc_num])
return -ENOMEM;
speakup_date(vc);
-   } else if (!spk_parked)
+   } else if (!spk_parked) {
speakup_date(vc);
+   }
 
return 0;
 }
@@ -1397,9 +1402,9 @@ static void read_all_doc(struct vc_data *vc)
prev_cursor_track = cursor_track;
cursor_track = read_all_mode;
spk_reset_index_count(0);
-   if (get_sentence_buf(vc, 0) == -1)
+   if (get_sentence_buf(vc, 0) == -1) {
kbd_fakekey2(vc, RA_DOWN_ARROW);
-   else {
+   } else {
say_sentence_num(0, 0);
synth_insert_next_index(0);
start_read_all_timer(vc, RA_TIMER);
@@ -1446,8 +1451,9 @@ static void handle_cursor_read_all(struct vc_data *vc, 
int command)
if (!say_sentence_num(sentcount + 1, 1)) {
sn = 1;
spk_reset_index_count(sn);
-   } else
+   } else {
synth_insert_next_index(0);
+   }
if (!say_sentence_num(sn, 0)) {
kbd_fakekey2(vc, RA_FIND_NEXT_SENT);
return;
@@ -1476,9 +1482,9 @@ static void handle_cursor_read_all(struct vc_data *vc, 
int command)
rv = get_sentence_buf(vc, 0);
if (rv == -1)
read_all_doc(vc);
-   if (rv == 0)
+   if (rv == 0) {
kbd_fakekey2(vc, RA_FIND_NEXT_SENT);
-   else {
+   } else {
say_sentence_num(1, 0);
synth_insert_next_index(0);
start_read_all_timer(vc, RA_TIMER);
@@ -2177,10 +2183,11 @@ speakup_key(struct vc_data *vc, int shift_state, int 
keycode, u_short keysym,
if (type == KT_SPEC && value == 1) {
value = '\n';
type = KT_LATIN;
-   } else if (type == KT_LETTER)
+   } else if (type == KT_LETTER) {
type = KT_LATIN;
-   else if (value == 0x7f)
+   } else if (value == 0x7f) {
value = 8;  /* make del = backspace */
+   }
ret = (*spk_special_handler) (vc, type, value, keycode);
spk_close_press = 0;
if (ret < 0)
@@ -2274,9 +2281,9 @@ static int 

Re: [PATCH/RFC] staging/lustre: Rework class_process_proc_param

2017-03-18 Thread Greg Kroah-Hartman
On Sun, Mar 19, 2017 at 12:41:20AM -0400, Oleg Drokin wrote:
> 
> On Mar 19, 2017, at 12:29 AM, Greg Kroah-Hartman wrote:
> 
> > On Sat, Mar 18, 2017 at 11:17:55AM -0400, Oleg Drokin wrote:
> >> 
> >> On Mar 18, 2017, at 6:34 AM, Greg Kroah-Hartman wrote:
> >> 
> >>> On Sat, Mar 18, 2017 at 02:24:08AM -0400, Oleg Drokin wrote:
>  Ever since sysfs migration, class_process_proc_param stopped working
>  correctly as all the useful params were no longer present as lvars.
>  Replace all the nasty fake proc writes with hopefully less nasty
>  kobject attribute search and then update the attributes as needed.
>  
>  Signed-off-by: Oleg Drokin 
>  Reported-by: Al Viro 
>  ---
>  Al has quite rightfully complained in the past that 
>  class_process_proc_param
>  is a terrible piece of code and needs to go.
>  This patch is an attempt at improving it somewhat and in process drop
>  all the user/kernel address space games we needed to play to make it work
>  in the past (and which I suspect attracted Al's attention in the first 
>  place).
>  
>  Now I wonder if iterating kobject attributes like that would be ok with
>  you Greg, or do you think there is a better way?
>  class_find_write_attr could be turned into something generic since it's
>  certainly convenient to reuse same table of name-write_method pairs,
>  but I did some cursory research and nobody else seems to need anything
>  of the sort in-tree.
>  
>  I know ll_process_config is still awful and I will likely just
>  replace the current hack with kset_find_obj, but I just wanted to make
>  sure this new approach would be ok before spending too much time on it.
> >>> 
> >>> I'm not quite sure what exactly you are even trying to do here.  What is
> >>> this interface?  Who calls it, and how?  What does it want to do?
> >> 
> >> This is a configuration client code.
> >> Management server has ability to pass down config information in the form 
> >> of:
> >> fsname.subsystem.attribute=value to clients and other servers
> >> (subsystem determines if it's something of interest of clients or servers 
> >> or
> >> both).
> >> This could be changed in the real time - i.e. you update it on the server 
> >> and
> >> that gets propagated to all the clients/servers, so no need to ssh into
> >> every node to manually apply those changes and worry about client restarts
> >> (the config is remembered at the management server and would be applied to 
> >> any
> >> new nodes connecting/across server restarts and such).
> >> 
> >> So the way it then works then is once the string 
> >> fsname.subsystem.attribute=value is delivered to the client, we find all 
> >> instances of filesystem with fsname and then
> >> all subsystems within it (one kobject per subsystem instance) and then 
> >> update the
> >> attributes to the value supplied.
> >> 
> >> The same filesystem might be mounted more than once and then some layers 
> >> might have
> >> multiple instances inside a single filesystems.
> >> 
> >> In the end it would turn something like lustre.osc.max_dirty_mb=128 into
> >> writes to
> >> /sys/fs/lustre/osc/lustre-OST-osc-8800d75ca000/max_dirty_mb and
> >> /sys/fs/lustre/osc/lustre-OST0001-osc-8800d75ca000/max_dirty_mb
> >> without actually iterating in sysfs namespace.
> > 
> > Wait, who is doing the "write"?  From within the kernel?  Or some
> > userspace app?  I'm guessing from within the kernel, you are receiving
> > the data from some other transport within the filesystem and then need
> > to apply the settings?
> 
> Yes, kernel code gets the notification "hey, there's a config change, come 
> get it",
> then it requests the diff in the config and does the "write' by updating the
> attributes.
> 
> >> The alternative we considered is we can probably just do an upcall and have
> >> a userspace tool called with the parameter verbatim and try to figure it 
> >> out,
> >> but that seems a lot less ideal, and also we'll get a bunch of 
> >> complications from
> >> containers and such too, I imagine.
> > 
> > Yeah, no, don't do an upcall, that's a mess.
> > 
> >> The function pre-this patch is assuming that all these values are part of
> >> a list of procfs values (no longer true after sysfs migration) so just 
> >> iterates
> >> that list and calls the write for matched names (but also needs to supply 
> >> a userspace
> >> buffer so looks much uglier too).
> > 
> > For kobjects, you don't need userspace buffers, so this should be
> > easier.
> 
> Right, it's less of a mess due to that.
> 
> >> Hopefully this makes at least some sense.
> > 
> > Yes, a bit more, but ugh, what a mess :)
> 
> Overall big systems are quite messy in many ways no matter what you do,
> so it's always a case of pick your poison.

Oh I know, I wasn't complaining, it's just a fact of life :)

> >>> You can look up attributes for a kobject 

[PATCH] staging: speakup: fix: braces {} should used on all arms of statement

2017-03-18 Thread Arushi Singhal
This patch fixes the checks reported by checkpatch.pl
for braces {} should be used on all arms of this statement.

Signed-off-by: Arushi Singhal 
---
 drivers/staging/speakup/main.c   | 35 +++-
 drivers/staging/speakup/speakup_decext.c |  6 +++---
 drivers/staging/speakup/speakup_decpc.c  |  6 +++---
 drivers/staging/speakup/speakup_dectlk.c |  6 +++---
 drivers/staging/speakup/varhandlers.c| 12 ++-
 5 files changed, 37 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index f8fccc8bf6b2..21e76b031449 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -409,8 +409,9 @@ static void say_attributes(struct vc_data *vc)
if (bg > 7) {
synth_printf(" %s ", spk_msg_get(MSG_ON_BLINKING));
bg -= 8;
-   } else
+   } else {
synth_printf(" %s ", spk_msg_get(MSG_ON));
+   }
synth_printf("%s\n", spk_msg_get(MSG_COLORS_START + bg));
 }
 
@@ -643,8 +644,9 @@ static void say_prev_word(struct vc_data *vc)
break;
spk_y--;
spk_x = vc->vc_cols - 1;
-   } else
+   } else {
spk_x--;
+   }
spk_pos -= 2;
ch = get_char(vc, (u_short *)spk_pos, );
if (ch == SPACE || ch == 0)
@@ -697,8 +699,9 @@ static void say_next_word(struct vc_data *vc)
spk_y++;
spk_x = 0;
edge_said = edge_right;
-   } else
+   } else {
spk_x++;
+   }
spk_pos += 2;
last_state = state;
}
@@ -729,8 +732,9 @@ static void spell_word(struct vc_data *vc)
spk_pitch_shift++;
else/* synth has no pitch */
last_cap = spk_str_caps_stop;
-   } else
+   } else {
str_cap = spk_str_caps_stop;
+   }
if (str_cap != last_cap) {
synth_printf("%s", str_cap);
last_cap = str_cap;
@@ -1343,8 +1347,9 @@ static int speakup_allocate(struct vc_data *vc)
if (!speakup_console[vc_num])
return -ENOMEM;
speakup_date(vc);
-   } else if (!spk_parked)
+   } else if (!spk_parked) {
speakup_date(vc);
+   }
 
return 0;
 }
@@ -1397,9 +1402,9 @@ static void read_all_doc(struct vc_data *vc)
prev_cursor_track = cursor_track;
cursor_track = read_all_mode;
spk_reset_index_count(0);
-   if (get_sentence_buf(vc, 0) == -1)
+   if (get_sentence_buf(vc, 0) == -1) {
kbd_fakekey2(vc, RA_DOWN_ARROW);
-   else {
+   } else {
say_sentence_num(0, 0);
synth_insert_next_index(0);
start_read_all_timer(vc, RA_TIMER);
@@ -1446,8 +1451,9 @@ static void handle_cursor_read_all(struct vc_data *vc, 
int command)
if (!say_sentence_num(sentcount + 1, 1)) {
sn = 1;
spk_reset_index_count(sn);
-   } else
+   } else {
synth_insert_next_index(0);
+   }
if (!say_sentence_num(sn, 0)) {
kbd_fakekey2(vc, RA_FIND_NEXT_SENT);
return;
@@ -1476,9 +1482,9 @@ static void handle_cursor_read_all(struct vc_data *vc, 
int command)
rv = get_sentence_buf(vc, 0);
if (rv == -1)
read_all_doc(vc);
-   if (rv == 0)
+   if (rv == 0) {
kbd_fakekey2(vc, RA_FIND_NEXT_SENT);
-   else {
+   } else {
say_sentence_num(1, 0);
synth_insert_next_index(0);
start_read_all_timer(vc, RA_TIMER);
@@ -2177,10 +2183,11 @@ speakup_key(struct vc_data *vc, int shift_state, int 
keycode, u_short keysym,
if (type == KT_SPEC && value == 1) {
value = '\n';
type = KT_LATIN;
-   } else if (type == KT_LETTER)
+   } else if (type == KT_LETTER) {
type = KT_LATIN;
-   else if (value == 0x7f)
+   } else if (value == 0x7f) {
value = 8;  /* make del = backspace */
+   }
ret = (*spk_special_handler) (vc, type, value, keycode);
spk_close_press = 0;
if (ret < 0)
@@ -2274,9 +2281,9 @@ static int vt_notifier_call(struct notifier_block *nb,
  

Re: [PATCH/RFC] staging/lustre: Rework class_process_proc_param

2017-03-18 Thread Greg Kroah-Hartman
On Sun, Mar 19, 2017 at 12:41:20AM -0400, Oleg Drokin wrote:
> 
> On Mar 19, 2017, at 12:29 AM, Greg Kroah-Hartman wrote:
> 
> > On Sat, Mar 18, 2017 at 11:17:55AM -0400, Oleg Drokin wrote:
> >> 
> >> On Mar 18, 2017, at 6:34 AM, Greg Kroah-Hartman wrote:
> >> 
> >>> On Sat, Mar 18, 2017 at 02:24:08AM -0400, Oleg Drokin wrote:
>  Ever since sysfs migration, class_process_proc_param stopped working
>  correctly as all the useful params were no longer present as lvars.
>  Replace all the nasty fake proc writes with hopefully less nasty
>  kobject attribute search and then update the attributes as needed.
>  
>  Signed-off-by: Oleg Drokin 
>  Reported-by: Al Viro 
>  ---
>  Al has quite rightfully complained in the past that 
>  class_process_proc_param
>  is a terrible piece of code and needs to go.
>  This patch is an attempt at improving it somewhat and in process drop
>  all the user/kernel address space games we needed to play to make it work
>  in the past (and which I suspect attracted Al's attention in the first 
>  place).
>  
>  Now I wonder if iterating kobject attributes like that would be ok with
>  you Greg, or do you think there is a better way?
>  class_find_write_attr could be turned into something generic since it's
>  certainly convenient to reuse same table of name-write_method pairs,
>  but I did some cursory research and nobody else seems to need anything
>  of the sort in-tree.
>  
>  I know ll_process_config is still awful and I will likely just
>  replace the current hack with kset_find_obj, but I just wanted to make
>  sure this new approach would be ok before spending too much time on it.
> >>> 
> >>> I'm not quite sure what exactly you are even trying to do here.  What is
> >>> this interface?  Who calls it, and how?  What does it want to do?
> >> 
> >> This is a configuration client code.
> >> Management server has ability to pass down config information in the form 
> >> of:
> >> fsname.subsystem.attribute=value to clients and other servers
> >> (subsystem determines if it's something of interest of clients or servers 
> >> or
> >> both).
> >> This could be changed in the real time - i.e. you update it on the server 
> >> and
> >> that gets propagated to all the clients/servers, so no need to ssh into
> >> every node to manually apply those changes and worry about client restarts
> >> (the config is remembered at the management server and would be applied to 
> >> any
> >> new nodes connecting/across server restarts and such).
> >> 
> >> So the way it then works then is once the string 
> >> fsname.subsystem.attribute=value is delivered to the client, we find all 
> >> instances of filesystem with fsname and then
> >> all subsystems within it (one kobject per subsystem instance) and then 
> >> update the
> >> attributes to the value supplied.
> >> 
> >> The same filesystem might be mounted more than once and then some layers 
> >> might have
> >> multiple instances inside a single filesystems.
> >> 
> >> In the end it would turn something like lustre.osc.max_dirty_mb=128 into
> >> writes to
> >> /sys/fs/lustre/osc/lustre-OST-osc-8800d75ca000/max_dirty_mb and
> >> /sys/fs/lustre/osc/lustre-OST0001-osc-8800d75ca000/max_dirty_mb
> >> without actually iterating in sysfs namespace.
> > 
> > Wait, who is doing the "write"?  From within the kernel?  Or some
> > userspace app?  I'm guessing from within the kernel, you are receiving
> > the data from some other transport within the filesystem and then need
> > to apply the settings?
> 
> Yes, kernel code gets the notification "hey, there's a config change, come 
> get it",
> then it requests the diff in the config and does the "write' by updating the
> attributes.
> 
> >> The alternative we considered is we can probably just do an upcall and have
> >> a userspace tool called with the parameter verbatim and try to figure it 
> >> out,
> >> but that seems a lot less ideal, and also we'll get a bunch of 
> >> complications from
> >> containers and such too, I imagine.
> > 
> > Yeah, no, don't do an upcall, that's a mess.
> > 
> >> The function pre-this patch is assuming that all these values are part of
> >> a list of procfs values (no longer true after sysfs migration) so just 
> >> iterates
> >> that list and calls the write for matched names (but also needs to supply 
> >> a userspace
> >> buffer so looks much uglier too).
> > 
> > For kobjects, you don't need userspace buffers, so this should be
> > easier.
> 
> Right, it's less of a mess due to that.
> 
> >> Hopefully this makes at least some sense.
> > 
> > Yes, a bit more, but ugh, what a mess :)
> 
> Overall big systems are quite messy in many ways no matter what you do,
> so it's always a case of pick your poison.

Oh I know, I wasn't complaining, it's just a fact of life :)

> >>> You can look up attributes for a kobject easily in the show/store
> >>> functions (and 

[PATCH] staging: speakup: Remove multiple assignments

2017-03-18 Thread Arushi Singhal
This patch fixes the checkpatch.pl warning "multiple assignments
should be avoided."

Signed-off-by: Arushi Singhal 
---
 drivers/staging/speakup/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index 21e76b031449..c10445624e92 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -2106,7 +2106,8 @@ speakup_key(struct vc_data *vc, int shift_state, int 
keycode, u_short keysym,
spk_keydown = 0;
goto out;
}
-   value = spk_lastkey = pad_chars[value];
+   value = pad_chars[value];
+   spk_lastkey = value;
spk_keydown++;
spk_parked &= 0xfe;
goto no_map;
-- 
2.11.0



[PATCH] staging: speakup: Remove multiple assignments

2017-03-18 Thread Arushi Singhal
This patch fixes the checkpatch.pl warning "multiple assignments
should be avoided."

Signed-off-by: Arushi Singhal 
---
 drivers/staging/speakup/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index 21e76b031449..c10445624e92 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -2106,7 +2106,8 @@ speakup_key(struct vc_data *vc, int shift_state, int 
keycode, u_short keysym,
spk_keydown = 0;
goto out;
}
-   value = spk_lastkey = pad_chars[value];
+   value = pad_chars[value];
+   spk_lastkey = value;
spk_keydown++;
spk_parked &= 0xfe;
goto no_map;
-- 
2.11.0



Re: [PATCH/RFC] staging/lustre: Rework class_process_proc_param

2017-03-18 Thread Oleg Drokin

On Mar 19, 2017, at 12:29 AM, Greg Kroah-Hartman wrote:

> On Sat, Mar 18, 2017 at 11:17:55AM -0400, Oleg Drokin wrote:
>> 
>> On Mar 18, 2017, at 6:34 AM, Greg Kroah-Hartman wrote:
>> 
>>> On Sat, Mar 18, 2017 at 02:24:08AM -0400, Oleg Drokin wrote:
 Ever since sysfs migration, class_process_proc_param stopped working
 correctly as all the useful params were no longer present as lvars.
 Replace all the nasty fake proc writes with hopefully less nasty
 kobject attribute search and then update the attributes as needed.
 
 Signed-off-by: Oleg Drokin 
 Reported-by: Al Viro 
 ---
 Al has quite rightfully complained in the past that 
 class_process_proc_param
 is a terrible piece of code and needs to go.
 This patch is an attempt at improving it somewhat and in process drop
 all the user/kernel address space games we needed to play to make it work
 in the past (and which I suspect attracted Al's attention in the first 
 place).
 
 Now I wonder if iterating kobject attributes like that would be ok with
 you Greg, or do you think there is a better way?
 class_find_write_attr could be turned into something generic since it's
 certainly convenient to reuse same table of name-write_method pairs,
 but I did some cursory research and nobody else seems to need anything
 of the sort in-tree.
 
 I know ll_process_config is still awful and I will likely just
 replace the current hack with kset_find_obj, but I just wanted to make
 sure this new approach would be ok before spending too much time on it.
>>> 
>>> I'm not quite sure what exactly you are even trying to do here.  What is
>>> this interface?  Who calls it, and how?  What does it want to do?
>> 
>> This is a configuration client code.
>> Management server has ability to pass down config information in the form of:
>> fsname.subsystem.attribute=value to clients and other servers
>> (subsystem determines if it's something of interest of clients or servers or
>> both).
>> This could be changed in the real time - i.e. you update it on the server and
>> that gets propagated to all the clients/servers, so no need to ssh into
>> every node to manually apply those changes and worry about client restarts
>> (the config is remembered at the management server and would be applied to 
>> any
>> new nodes connecting/across server restarts and such).
>> 
>> So the way it then works then is once the string 
>> fsname.subsystem.attribute=value is delivered to the client, we find all 
>> instances of filesystem with fsname and then
>> all subsystems within it (one kobject per subsystem instance) and then 
>> update the
>> attributes to the value supplied.
>> 
>> The same filesystem might be mounted more than once and then some layers 
>> might have
>> multiple instances inside a single filesystems.
>> 
>> In the end it would turn something like lustre.osc.max_dirty_mb=128 into
>> writes to
>> /sys/fs/lustre/osc/lustre-OST-osc-8800d75ca000/max_dirty_mb and
>> /sys/fs/lustre/osc/lustre-OST0001-osc-8800d75ca000/max_dirty_mb
>> without actually iterating in sysfs namespace.
> 
> Wait, who is doing the "write"?  From within the kernel?  Or some
> userspace app?  I'm guessing from within the kernel, you are receiving
> the data from some other transport within the filesystem and then need
> to apply the settings?

Yes, kernel code gets the notification "hey, there's a config change, come get 
it",
then it requests the diff in the config and does the "write' by updating the
attributes.

>> The alternative we considered is we can probably just do an upcall and have
>> a userspace tool called with the parameter verbatim and try to figure it out,
>> but that seems a lot less ideal, and also we'll get a bunch of complications 
>> from
>> containers and such too, I imagine.
> 
> Yeah, no, don't do an upcall, that's a mess.
> 
>> The function pre-this patch is assuming that all these values are part of
>> a list of procfs values (no longer true after sysfs migration) so just 
>> iterates
>> that list and calls the write for matched names (but also needs to supply a 
>> userspace
>> buffer so looks much uglier too).
> 
> For kobjects, you don't need userspace buffers, so this should be
> easier.

Right, it's less of a mess due to that.

>> Hopefully this makes at least some sense.
> 
> Yes, a bit more, but ugh, what a mess :)

Overall big systems are quite messy in many ways no matter what you do,
so it's always a case of pick your poison.

>>> You can look up attributes for a kobject easily in the show/store
>>> functions (and some drivers just have a generic one and then you look at
>>> the string to see which attribute you are wanting to reference.)  But
>>> you seem to be working backwards here, why do you have to look up a
>>> kobject?
>> 
>> But that leads to the need to list attribute names essentially twice:
>> once for the 

Re: [PATCH/RFC] staging/lustre: Rework class_process_proc_param

2017-03-18 Thread Oleg Drokin

On Mar 19, 2017, at 12:29 AM, Greg Kroah-Hartman wrote:

> On Sat, Mar 18, 2017 at 11:17:55AM -0400, Oleg Drokin wrote:
>> 
>> On Mar 18, 2017, at 6:34 AM, Greg Kroah-Hartman wrote:
>> 
>>> On Sat, Mar 18, 2017 at 02:24:08AM -0400, Oleg Drokin wrote:
 Ever since sysfs migration, class_process_proc_param stopped working
 correctly as all the useful params were no longer present as lvars.
 Replace all the nasty fake proc writes with hopefully less nasty
 kobject attribute search and then update the attributes as needed.
 
 Signed-off-by: Oleg Drokin 
 Reported-by: Al Viro 
 ---
 Al has quite rightfully complained in the past that 
 class_process_proc_param
 is a terrible piece of code and needs to go.
 This patch is an attempt at improving it somewhat and in process drop
 all the user/kernel address space games we needed to play to make it work
 in the past (and which I suspect attracted Al's attention in the first 
 place).
 
 Now I wonder if iterating kobject attributes like that would be ok with
 you Greg, or do you think there is a better way?
 class_find_write_attr could be turned into something generic since it's
 certainly convenient to reuse same table of name-write_method pairs,
 but I did some cursory research and nobody else seems to need anything
 of the sort in-tree.
 
 I know ll_process_config is still awful and I will likely just
 replace the current hack with kset_find_obj, but I just wanted to make
 sure this new approach would be ok before spending too much time on it.
>>> 
>>> I'm not quite sure what exactly you are even trying to do here.  What is
>>> this interface?  Who calls it, and how?  What does it want to do?
>> 
>> This is a configuration client code.
>> Management server has ability to pass down config information in the form of:
>> fsname.subsystem.attribute=value to clients and other servers
>> (subsystem determines if it's something of interest of clients or servers or
>> both).
>> This could be changed in the real time - i.e. you update it on the server and
>> that gets propagated to all the clients/servers, so no need to ssh into
>> every node to manually apply those changes and worry about client restarts
>> (the config is remembered at the management server and would be applied to 
>> any
>> new nodes connecting/across server restarts and such).
>> 
>> So the way it then works then is once the string 
>> fsname.subsystem.attribute=value is delivered to the client, we find all 
>> instances of filesystem with fsname and then
>> all subsystems within it (one kobject per subsystem instance) and then 
>> update the
>> attributes to the value supplied.
>> 
>> The same filesystem might be mounted more than once and then some layers 
>> might have
>> multiple instances inside a single filesystems.
>> 
>> In the end it would turn something like lustre.osc.max_dirty_mb=128 into
>> writes to
>> /sys/fs/lustre/osc/lustre-OST-osc-8800d75ca000/max_dirty_mb and
>> /sys/fs/lustre/osc/lustre-OST0001-osc-8800d75ca000/max_dirty_mb
>> without actually iterating in sysfs namespace.
> 
> Wait, who is doing the "write"?  From within the kernel?  Or some
> userspace app?  I'm guessing from within the kernel, you are receiving
> the data from some other transport within the filesystem and then need
> to apply the settings?

Yes, kernel code gets the notification "hey, there's a config change, come get 
it",
then it requests the diff in the config and does the "write' by updating the
attributes.

>> The alternative we considered is we can probably just do an upcall and have
>> a userspace tool called with the parameter verbatim and try to figure it out,
>> but that seems a lot less ideal, and also we'll get a bunch of complications 
>> from
>> containers and such too, I imagine.
> 
> Yeah, no, don't do an upcall, that's a mess.
> 
>> The function pre-this patch is assuming that all these values are part of
>> a list of procfs values (no longer true after sysfs migration) so just 
>> iterates
>> that list and calls the write for matched names (but also needs to supply a 
>> userspace
>> buffer so looks much uglier too).
> 
> For kobjects, you don't need userspace buffers, so this should be
> easier.

Right, it's less of a mess due to that.

>> Hopefully this makes at least some sense.
> 
> Yes, a bit more, but ugh, what a mess :)

Overall big systems are quite messy in many ways no matter what you do,
so it's always a case of pick your poison.

>>> You can look up attributes for a kobject easily in the show/store
>>> functions (and some drivers just have a generic one and then you look at
>>> the string to see which attribute you are wanting to reference.)  But
>>> you seem to be working backwards here, why do you have to look up a
>>> kobject?
>> 
>> But that leads to the need to list attribute names essentially twice:
>> once for the attributes list, once in the show/set function 

Re: [PATCH/RFC] staging/lustre: Rework class_process_proc_param

2017-03-18 Thread Greg Kroah-Hartman
On Sat, Mar 18, 2017 at 02:24:08AM -0400, Oleg Drokin wrote:
> Ever since sysfs migration, class_process_proc_param stopped working
> correctly as all the useful params were no longer present as lvars.
> Replace all the nasty fake proc writes with hopefully less nasty
> kobject attribute search and then update the attributes as needed.
> 
> Signed-off-by: Oleg Drokin 
> Reported-by: Al Viro 
> ---
> Al has quite rightfully complained in the past that class_process_proc_param
> is a terrible piece of code and needs to go.
> This patch is an attempt at improving it somewhat and in process drop
> all the user/kernel address space games we needed to play to make it work
> in the past (and which I suspect attracted Al's attention in the first place).
> 
> Now I wonder if iterating kobject attributes like that would be ok with
> you Greg, or do you think there is a better way?
> class_find_write_attr could be turned into something generic since it's
> certainly convenient to reuse same table of name-write_method pairs,
> but I did some cursory research and nobody else seems to need anything
> of the sort in-tree.
> 
> I know ll_process_config is still awful and I will likely just
> replace the current hack with kset_find_obj, but I just wanted to make
> sure this new approach would be ok before spending too much time on it.
> 
> Thanks!
> 
>  drivers/staging/lustre/lustre/include/obd_class.h  |  4 +-
>  drivers/staging/lustre/lustre/llite/llite_lib.c| 10 +--
>  drivers/staging/lustre/lustre/lov/lov_obd.c|  3 +-
>  drivers/staging/lustre/lustre/mdc/mdc_request.c|  3 +-
>  .../staging/lustre/lustre/obdclass/obd_config.c| 78 
> ++
>  drivers/staging/lustre/lustre/osc/osc_request.c|  3 +-
>  6 files changed, 44 insertions(+), 57 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
> b/drivers/staging/lustre/lustre/include/obd_class.h
> index 083a6ff..badafb8 100644
> --- a/drivers/staging/lustre/lustre/include/obd_class.h
> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
> @@ -114,8 +114,8 @@ typedef int (*llog_cb_t)(const struct lu_env *, struct 
> llog_handle *,
>struct llog_rec_hdr *, void *);
>  /* obd_config.c */
>  int class_process_config(struct lustre_cfg *lcfg);
> -int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
> -  struct lustre_cfg *lcfg, void *data);
> +int class_process_attr_param(char *prefix, struct kobject *kobj,
> +  struct lustre_cfg *lcfg);

As you are exporting these functions, they will need to end up with a
lustre_* prefix eventually :)

>  struct obd_device *class_incref(struct obd_device *obd,
>   const char *scope, const void *source);
>  void class_decref(struct obd_device *obd,
> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
> b/drivers/staging/lustre/lustre/llite/llite_lib.c
> index 7b80040..192b877 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_lib.c
> +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
> @@ -2259,7 +2259,7 @@ int ll_obd_statfs(struct inode *inode, void __user *arg)
>  int ll_process_config(struct lustre_cfg *lcfg)
>  {
>   char *ptr;
> - void *sb;
> + struct super_block *sb;
>   struct lprocfs_static_vars lvars;
>   unsigned long x;
>   int rc = 0;
> @@ -2273,15 +2273,15 @@ int ll_process_config(struct lustre_cfg *lcfg)
>   rc = kstrtoul(ptr, 16, );
>   if (rc != 0)
>   return -EINVAL;
> - sb = (void *)x;
> + sb = (struct super_block *)x;
>   /* This better be a real Lustre superblock! */
> - LASSERT(s2lsi((struct super_block *)sb)->lsi_lmd->lmd_magic == 
> LMD_MAGIC);
> + LASSERT(s2lsi(sb)->lsi_lmd->lmd_magic == LMD_MAGIC);
>  
>   /* Note we have not called client_common_fill_super yet, so
>* proc fns must be able to handle that!
>*/
> - rc = class_process_proc_param(PARAM_LLITE, lvars.obd_vars,
> -   lcfg, sb);
> + rc = class_process_attr_param(PARAM_LLITE, _s2sbi(sb)->ll_kobj,
> +   lcfg);
>   if (rc > 0)
>   rc = 0;
>   return rc;
> diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c 
> b/drivers/staging/lustre/lustre/lov/lov_obd.c
> index b3161fb..c33a327 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_obd.c
> +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
> @@ -926,8 +926,7 @@ int lov_process_config_base(struct obd_device *obd, 
> struct lustre_cfg *lcfg,
>  
>   lprocfs_lov_init_vars();
>  
> - rc = class_process_proc_param(PARAM_LOV, lvars.obd_vars,
> -   lcfg, obd);
> + rc = class_process_attr_param(PARAM_LOV, >obd_kobj, lcfg);
>   if (rc > 0)
>   rc = 0;
>   goto out;
> diff --git 

Re: [PATCH/RFC] staging/lustre: Rework class_process_proc_param

2017-03-18 Thread Greg Kroah-Hartman
On Sat, Mar 18, 2017 at 02:24:08AM -0400, Oleg Drokin wrote:
> Ever since sysfs migration, class_process_proc_param stopped working
> correctly as all the useful params were no longer present as lvars.
> Replace all the nasty fake proc writes with hopefully less nasty
> kobject attribute search and then update the attributes as needed.
> 
> Signed-off-by: Oleg Drokin 
> Reported-by: Al Viro 
> ---
> Al has quite rightfully complained in the past that class_process_proc_param
> is a terrible piece of code and needs to go.
> This patch is an attempt at improving it somewhat and in process drop
> all the user/kernel address space games we needed to play to make it work
> in the past (and which I suspect attracted Al's attention in the first place).
> 
> Now I wonder if iterating kobject attributes like that would be ok with
> you Greg, or do you think there is a better way?
> class_find_write_attr could be turned into something generic since it's
> certainly convenient to reuse same table of name-write_method pairs,
> but I did some cursory research and nobody else seems to need anything
> of the sort in-tree.
> 
> I know ll_process_config is still awful and I will likely just
> replace the current hack with kset_find_obj, but I just wanted to make
> sure this new approach would be ok before spending too much time on it.
> 
> Thanks!
> 
>  drivers/staging/lustre/lustre/include/obd_class.h  |  4 +-
>  drivers/staging/lustre/lustre/llite/llite_lib.c| 10 +--
>  drivers/staging/lustre/lustre/lov/lov_obd.c|  3 +-
>  drivers/staging/lustre/lustre/mdc/mdc_request.c|  3 +-
>  .../staging/lustre/lustre/obdclass/obd_config.c| 78 
> ++
>  drivers/staging/lustre/lustre/osc/osc_request.c|  3 +-
>  6 files changed, 44 insertions(+), 57 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
> b/drivers/staging/lustre/lustre/include/obd_class.h
> index 083a6ff..badafb8 100644
> --- a/drivers/staging/lustre/lustre/include/obd_class.h
> +++ b/drivers/staging/lustre/lustre/include/obd_class.h
> @@ -114,8 +114,8 @@ typedef int (*llog_cb_t)(const struct lu_env *, struct 
> llog_handle *,
>struct llog_rec_hdr *, void *);
>  /* obd_config.c */
>  int class_process_config(struct lustre_cfg *lcfg);
> -int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
> -  struct lustre_cfg *lcfg, void *data);
> +int class_process_attr_param(char *prefix, struct kobject *kobj,
> +  struct lustre_cfg *lcfg);

As you are exporting these functions, they will need to end up with a
lustre_* prefix eventually :)

>  struct obd_device *class_incref(struct obd_device *obd,
>   const char *scope, const void *source);
>  void class_decref(struct obd_device *obd,
> diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
> b/drivers/staging/lustre/lustre/llite/llite_lib.c
> index 7b80040..192b877 100644
> --- a/drivers/staging/lustre/lustre/llite/llite_lib.c
> +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
> @@ -2259,7 +2259,7 @@ int ll_obd_statfs(struct inode *inode, void __user *arg)
>  int ll_process_config(struct lustre_cfg *lcfg)
>  {
>   char *ptr;
> - void *sb;
> + struct super_block *sb;
>   struct lprocfs_static_vars lvars;
>   unsigned long x;
>   int rc = 0;
> @@ -2273,15 +2273,15 @@ int ll_process_config(struct lustre_cfg *lcfg)
>   rc = kstrtoul(ptr, 16, );
>   if (rc != 0)
>   return -EINVAL;
> - sb = (void *)x;
> + sb = (struct super_block *)x;
>   /* This better be a real Lustre superblock! */
> - LASSERT(s2lsi((struct super_block *)sb)->lsi_lmd->lmd_magic == 
> LMD_MAGIC);
> + LASSERT(s2lsi(sb)->lsi_lmd->lmd_magic == LMD_MAGIC);
>  
>   /* Note we have not called client_common_fill_super yet, so
>* proc fns must be able to handle that!
>*/
> - rc = class_process_proc_param(PARAM_LLITE, lvars.obd_vars,
> -   lcfg, sb);
> + rc = class_process_attr_param(PARAM_LLITE, _s2sbi(sb)->ll_kobj,
> +   lcfg);
>   if (rc > 0)
>   rc = 0;
>   return rc;
> diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c 
> b/drivers/staging/lustre/lustre/lov/lov_obd.c
> index b3161fb..c33a327 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_obd.c
> +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
> @@ -926,8 +926,7 @@ int lov_process_config_base(struct obd_device *obd, 
> struct lustre_cfg *lcfg,
>  
>   lprocfs_lov_init_vars();
>  
> - rc = class_process_proc_param(PARAM_LOV, lvars.obd_vars,
> -   lcfg, obd);
> + rc = class_process_attr_param(PARAM_LOV, >obd_kobj, lcfg);
>   if (rc > 0)
>   rc = 0;
>   goto out;
> diff --git 

Re: [PATCH/RFC] staging/lustre: Rework class_process_proc_param

2017-03-18 Thread Greg Kroah-Hartman
On Sat, Mar 18, 2017 at 11:17:55AM -0400, Oleg Drokin wrote:
> 
> On Mar 18, 2017, at 6:34 AM, Greg Kroah-Hartman wrote:
> 
> > On Sat, Mar 18, 2017 at 02:24:08AM -0400, Oleg Drokin wrote:
> >> Ever since sysfs migration, class_process_proc_param stopped working
> >> correctly as all the useful params were no longer present as lvars.
> >> Replace all the nasty fake proc writes with hopefully less nasty
> >> kobject attribute search and then update the attributes as needed.
> >> 
> >> Signed-off-by: Oleg Drokin 
> >> Reported-by: Al Viro 
> >> ---
> >> Al has quite rightfully complained in the past that 
> >> class_process_proc_param
> >> is a terrible piece of code and needs to go.
> >> This patch is an attempt at improving it somewhat and in process drop
> >> all the user/kernel address space games we needed to play to make it work
> >> in the past (and which I suspect attracted Al's attention in the first 
> >> place).
> >> 
> >> Now I wonder if iterating kobject attributes like that would be ok with
> >> you Greg, or do you think there is a better way?
> >> class_find_write_attr could be turned into something generic since it's
> >> certainly convenient to reuse same table of name-write_method pairs,
> >> but I did some cursory research and nobody else seems to need anything
> >> of the sort in-tree.
> >> 
> >> I know ll_process_config is still awful and I will likely just
> >> replace the current hack with kset_find_obj, but I just wanted to make
> >> sure this new approach would be ok before spending too much time on it.
> > 
> > I'm not quite sure what exactly you are even trying to do here.  What is
> > this interface?  Who calls it, and how?  What does it want to do?
> 
> This is a configuration client code.
> Management server has ability to pass down config information in the form of:
> fsname.subsystem.attribute=value to clients and other servers
> (subsystem determines if it's something of interest of clients or servers or
> both).
> This could be changed in the real time - i.e. you update it on the server and
> that gets propagated to all the clients/servers, so no need to ssh into
> every node to manually apply those changes and worry about client restarts
> (the config is remembered at the management server and would be applied to any
> new nodes connecting/across server restarts and such).
> 
> So the way it then works then is once the string 
> fsname.subsystem.attribute=value is delivered to the client, we find all 
> instances of filesystem with fsname and then
> all subsystems within it (one kobject per subsystem instance) and then update 
> the
> attributes to the value supplied.
> 
> The same filesystem might be mounted more than once and then some layers 
> might have
> multiple instances inside a single filesystems.
> 
> In the end it would turn something like lustre.osc.max_dirty_mb=128 into
> writes to
> /sys/fs/lustre/osc/lustre-OST-osc-8800d75ca000/max_dirty_mb and
> /sys/fs/lustre/osc/lustre-OST0001-osc-8800d75ca000/max_dirty_mb
> without actually iterating in sysfs namespace.

Wait, who is doing the "write"?  From within the kernel?  Or some
userspace app?  I'm guessing from within the kernel, you are receiving
the data from some other transport within the filesystem and then need
to apply the settings?

> The alternative we considered is we can probably just do an upcall and have
> a userspace tool called with the parameter verbatim and try to figure it out,
> but that seems a lot less ideal, and also we'll get a bunch of complications 
> from
> containers and such too, I imagine.

Yeah, no, don't do an upcall, that's a mess.

> The function pre-this patch is assuming that all these values are part of
> a list of procfs values (no longer true after sysfs migration) so just 
> iterates
> that list and calls the write for matched names (but also needs to supply a 
> userspace
> buffer so looks much uglier too).

For kobjects, you don't need userspace buffers, so this should be
easier.

> Hopefully this makes at least some sense.

Yes, a bit more, but ugh, what a mess :)

> > You can look up attributes for a kobject easily in the show/store
> > functions (and some drivers just have a generic one and then you look at
> > the string to see which attribute you are wanting to reference.)  But
> > you seem to be working backwards here, why do you have to look up a
> > kobject?
> 
> But that leads to the need to list attribute names essentially twice:
> once for the attributes list, once in the show/set function to figure
> out how to deal with that name.

Yes, you don't need/want to do that.

Let me go review the code now with that info, thanks, it makes more
sense.

greg k-h


Re: [PATCH/RFC] staging/lustre: Rework class_process_proc_param

2017-03-18 Thread Greg Kroah-Hartman
On Sat, Mar 18, 2017 at 11:17:55AM -0400, Oleg Drokin wrote:
> 
> On Mar 18, 2017, at 6:34 AM, Greg Kroah-Hartman wrote:
> 
> > On Sat, Mar 18, 2017 at 02:24:08AM -0400, Oleg Drokin wrote:
> >> Ever since sysfs migration, class_process_proc_param stopped working
> >> correctly as all the useful params were no longer present as lvars.
> >> Replace all the nasty fake proc writes with hopefully less nasty
> >> kobject attribute search and then update the attributes as needed.
> >> 
> >> Signed-off-by: Oleg Drokin 
> >> Reported-by: Al Viro 
> >> ---
> >> Al has quite rightfully complained in the past that 
> >> class_process_proc_param
> >> is a terrible piece of code and needs to go.
> >> This patch is an attempt at improving it somewhat and in process drop
> >> all the user/kernel address space games we needed to play to make it work
> >> in the past (and which I suspect attracted Al's attention in the first 
> >> place).
> >> 
> >> Now I wonder if iterating kobject attributes like that would be ok with
> >> you Greg, or do you think there is a better way?
> >> class_find_write_attr could be turned into something generic since it's
> >> certainly convenient to reuse same table of name-write_method pairs,
> >> but I did some cursory research and nobody else seems to need anything
> >> of the sort in-tree.
> >> 
> >> I know ll_process_config is still awful and I will likely just
> >> replace the current hack with kset_find_obj, but I just wanted to make
> >> sure this new approach would be ok before spending too much time on it.
> > 
> > I'm not quite sure what exactly you are even trying to do here.  What is
> > this interface?  Who calls it, and how?  What does it want to do?
> 
> This is a configuration client code.
> Management server has ability to pass down config information in the form of:
> fsname.subsystem.attribute=value to clients and other servers
> (subsystem determines if it's something of interest of clients or servers or
> both).
> This could be changed in the real time - i.e. you update it on the server and
> that gets propagated to all the clients/servers, so no need to ssh into
> every node to manually apply those changes and worry about client restarts
> (the config is remembered at the management server and would be applied to any
> new nodes connecting/across server restarts and such).
> 
> So the way it then works then is once the string 
> fsname.subsystem.attribute=value is delivered to the client, we find all 
> instances of filesystem with fsname and then
> all subsystems within it (one kobject per subsystem instance) and then update 
> the
> attributes to the value supplied.
> 
> The same filesystem might be mounted more than once and then some layers 
> might have
> multiple instances inside a single filesystems.
> 
> In the end it would turn something like lustre.osc.max_dirty_mb=128 into
> writes to
> /sys/fs/lustre/osc/lustre-OST-osc-8800d75ca000/max_dirty_mb and
> /sys/fs/lustre/osc/lustre-OST0001-osc-8800d75ca000/max_dirty_mb
> without actually iterating in sysfs namespace.

Wait, who is doing the "write"?  From within the kernel?  Or some
userspace app?  I'm guessing from within the kernel, you are receiving
the data from some other transport within the filesystem and then need
to apply the settings?

> The alternative we considered is we can probably just do an upcall and have
> a userspace tool called with the parameter verbatim and try to figure it out,
> but that seems a lot less ideal, and also we'll get a bunch of complications 
> from
> containers and such too, I imagine.

Yeah, no, don't do an upcall, that's a mess.

> The function pre-this patch is assuming that all these values are part of
> a list of procfs values (no longer true after sysfs migration) so just 
> iterates
> that list and calls the write for matched names (but also needs to supply a 
> userspace
> buffer so looks much uglier too).

For kobjects, you don't need userspace buffers, so this should be
easier.

> Hopefully this makes at least some sense.

Yes, a bit more, but ugh, what a mess :)

> > You can look up attributes for a kobject easily in the show/store
> > functions (and some drivers just have a generic one and then you look at
> > the string to see which attribute you are wanting to reference.)  But
> > you seem to be working backwards here, why do you have to look up a
> > kobject?
> 
> But that leads to the need to list attribute names essentially twice:
> once for the attributes list, once in the show/set function to figure
> out how to deal with that name.

Yes, you don't need/want to do that.

Let me go review the code now with that info, thanks, it makes more
sense.

greg k-h


Re: [GIT PULL] target fixes for v4.11-rc3

2017-03-18 Thread Nicholas A. Bellinger
On Sat, 2017-03-18 at 19:08 -0700, Nicholas A. Bellinger wrote:
> Hello Linus,
> 
> Here are the target-pending fixes for v4.11-rc3 code.  Please go ahead
> and pull from:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master
> 
> The bulk of the changes are in qla2xxx target driver code to address
> various issues found during Cavium/QLogic's internal testing (stable
> CC's included), along with a few other stability and smaller
> miscellaneous improvements.

Wrt the other qla2xxx improvements in this PULL request..

They where originally intended for v4.11-rc1, but missed the merge
window due to a regression reported on the list.

Since then, they have gone through 4 revisions over the last 7 weeks,
and Cavium/QLogic folks have addressed the outstanding regression +
feedback, and this series has passed their internal Q/A testing.

So while I acknowledge they aren't all strictly bug-fixes (5 of them are
CC'ed for stable), all are self contained within qla2xxx and I do trust
the Cavium/QLogic team's sign-off for the complete series.

Please consider pulling the series.



Re: [GIT PULL] target fixes for v4.11-rc3

2017-03-18 Thread Nicholas A. Bellinger
On Sat, 2017-03-18 at 19:08 -0700, Nicholas A. Bellinger wrote:
> Hello Linus,
> 
> Here are the target-pending fixes for v4.11-rc3 code.  Please go ahead
> and pull from:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master
> 
> The bulk of the changes are in qla2xxx target driver code to address
> various issues found during Cavium/QLogic's internal testing (stable
> CC's included), along with a few other stability and smaller
> miscellaneous improvements.

Wrt the other qla2xxx improvements in this PULL request..

They where originally intended for v4.11-rc1, but missed the merge
window due to a regression reported on the list.

Since then, they have gone through 4 revisions over the last 7 weeks,
and Cavium/QLogic folks have addressed the outstanding regression +
feedback, and this series has passed their internal Q/A testing.

So while I acknowledge they aren't all strictly bug-fixes (5 of them are
CC'ed for stable), all are self contained within qla2xxx and I do trust
the Cavium/QLogic team's sign-off for the complete series.

Please consider pulling the series.



[PATCH 5/7] Change k_clock clock_set() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c |  2 +-
 include/linux/posix-timers.h   |  2 +-
 kernel/time/posix-clock.c  |  5 ++---
 kernel/time/posix-cpu-timers.c |  2 +-
 kernel/time/posix-timers.c | 11 +--
 5 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 79d8ada..ba1b892 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -489,7 +489,7 @@ static int sgi_clock_get(clockid_t clockid, struct 
timespec64 *tp)
return 0;
 };
 
-static int sgi_clock_set(const clockid_t clockid, const struct timespec *tp)
+static int sgi_clock_set(const clockid_t clockid, const struct timespec64 *tp)
 {
 
u64 nsec;
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 2555d1c..249429c 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -89,7 +89,7 @@ struct k_itimer {
 struct k_clock {
int (*clock_getres) (const clockid_t which_clock, struct timespec64 
*tp);
int (*clock_set) (const clockid_t which_clock,
- const struct timespec *tp);
+ const struct timespec64 *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index d5a4bec..6378fc6 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -335,10 +335,9 @@ static int pc_clock_getres(clockid_t id, struct timespec64 
*ts)
return err;
 }
 
-static int pc_clock_settime(clockid_t id, const struct timespec *ts)
+static int pc_clock_settime(clockid_t id, const struct timespec64 *ts)
 {
struct posix_clock_desc cd;
-   struct timespec64 ts64 = timespec_to_timespec64(*ts);
int err;
 
err = get_clock_desc(id, );
@@ -351,7 +350,7 @@ static int pc_clock_settime(clockid_t id, const struct 
timespec *ts)
}
 
if (cd.clk->ops.clock_settime)
-   err = cd.clk->ops.clock_settime(cd.clk, );
+   err = cd.clk->ops.clock_settime(cd.clk, ts);
else
err = -EOPNOTSUPP;
 out:
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 42ca205..0db0e16 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -135,7 +135,7 @@ posix_cpu_clock_getres(const clockid_t which_clock, struct 
timespec64 *tp)
 }
 
 static int
-posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *tp)
+posix_cpu_clock_set(const clockid_t which_clock, const struct timespec64 *tp)
 {
/*
 * You can never reset a CPU clock, but we check for other errors
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index a314a63..6c09f87 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -212,12 +212,9 @@ static int posix_clock_realtime_get(clockid_t which_clock, 
struct timespec64 *tp
 
 /* Set clock_realtime */
 static int posix_clock_realtime_set(const clockid_t which_clock,
-   const struct timespec *tp)
+   const struct timespec64 *tp)
 {
-   struct timespec64 tp64;
-
-   tp64 = timespec_to_timespec64(*tp);
-   return do_sys_settimeofday64(, NULL);
+   return do_sys_settimeofday64(tp, NULL);
 }
 
 static int posix_clock_realtime_adj(const clockid_t which_clock,
@@ -1018,14 +1015,16 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, 
which_clock,
 {
struct k_clock *kc = clockid_to_kclock(which_clock);
struct timespec new_tp;
+   struct timespec64 new_tp64;
 
if (!kc || !kc->clock_set)
return -EINVAL;
 
if (copy_from_user(_tp, tp, sizeof (*tp)))
return -EFAULT;
+   new_tp64 = timespec_to_timespec64(new_tp);
 
-   return kc->clock_set(which_clock, _tp);
+   return kc->clock_set(which_clock, _tp64);
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
-- 
2.7.4



[PATCH 5/7] Change k_clock clock_set() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c |  2 +-
 include/linux/posix-timers.h   |  2 +-
 kernel/time/posix-clock.c  |  5 ++---
 kernel/time/posix-cpu-timers.c |  2 +-
 kernel/time/posix-timers.c | 11 +--
 5 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 79d8ada..ba1b892 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -489,7 +489,7 @@ static int sgi_clock_get(clockid_t clockid, struct 
timespec64 *tp)
return 0;
 };
 
-static int sgi_clock_set(const clockid_t clockid, const struct timespec *tp)
+static int sgi_clock_set(const clockid_t clockid, const struct timespec64 *tp)
 {
 
u64 nsec;
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 2555d1c..249429c 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -89,7 +89,7 @@ struct k_itimer {
 struct k_clock {
int (*clock_getres) (const clockid_t which_clock, struct timespec64 
*tp);
int (*clock_set) (const clockid_t which_clock,
- const struct timespec *tp);
+ const struct timespec64 *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index d5a4bec..6378fc6 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -335,10 +335,9 @@ static int pc_clock_getres(clockid_t id, struct timespec64 
*ts)
return err;
 }
 
-static int pc_clock_settime(clockid_t id, const struct timespec *ts)
+static int pc_clock_settime(clockid_t id, const struct timespec64 *ts)
 {
struct posix_clock_desc cd;
-   struct timespec64 ts64 = timespec_to_timespec64(*ts);
int err;
 
err = get_clock_desc(id, );
@@ -351,7 +350,7 @@ static int pc_clock_settime(clockid_t id, const struct 
timespec *ts)
}
 
if (cd.clk->ops.clock_settime)
-   err = cd.clk->ops.clock_settime(cd.clk, );
+   err = cd.clk->ops.clock_settime(cd.clk, ts);
else
err = -EOPNOTSUPP;
 out:
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 42ca205..0db0e16 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -135,7 +135,7 @@ posix_cpu_clock_getres(const clockid_t which_clock, struct 
timespec64 *tp)
 }
 
 static int
-posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *tp)
+posix_cpu_clock_set(const clockid_t which_clock, const struct timespec64 *tp)
 {
/*
 * You can never reset a CPU clock, but we check for other errors
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index a314a63..6c09f87 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -212,12 +212,9 @@ static int posix_clock_realtime_get(clockid_t which_clock, 
struct timespec64 *tp
 
 /* Set clock_realtime */
 static int posix_clock_realtime_set(const clockid_t which_clock,
-   const struct timespec *tp)
+   const struct timespec64 *tp)
 {
-   struct timespec64 tp64;
-
-   tp64 = timespec_to_timespec64(*tp);
-   return do_sys_settimeofday64(, NULL);
+   return do_sys_settimeofday64(tp, NULL);
 }
 
 static int posix_clock_realtime_adj(const clockid_t which_clock,
@@ -1018,14 +1015,16 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, 
which_clock,
 {
struct k_clock *kc = clockid_to_kclock(which_clock);
struct timespec new_tp;
+   struct timespec64 new_tp64;
 
if (!kc || !kc->clock_set)
return -EINVAL;
 
if (copy_from_user(_tp, tp, sizeof (*tp)))
return -EFAULT;
+   new_tp64 = timespec_to_timespec64(new_tp);
 
-   return kc->clock_set(which_clock, _tp);
+   return kc->clock_set(which_clock, _tp64);
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
-- 
2.7.4



[PATCH 2/7] time: Change posix clocks ops interfaces to use timespec64

2017-03-18 Thread Deepa Dinamani
 struct timespec is not y2038 safe.
 Replace the posix_clock ops interfaces to use
 struct timespec64.
 The patch also changes struct itimerspec interfaces to
 struct itimerspec64 as itimerspec internally uses timespec
 and itimerspec64 uses timespec64.
 PTP clocks is the only module that sets up these interfaces.
 All individual drivers rely on PTP class driver for exposure
 to userspace. Hence, the change also deals with fixing up these
 PTP interfaces.
 The patch also changes dynamic posix clock implementation to
 reflect the changes in the functional clock interface.

Signed-off-by: Deepa Dinamani 
---
 drivers/ptp/ptp_clock.c | 18 +++---
 include/linux/posix-clock.h | 10 +-
 kernel/time/posix-clock.c   | 34 --
 3 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index e814280..b774357 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -97,30 +97,26 @@ static s32 scaled_ppm_to_ppb(long ppm)
 
 /* posix clock implementation */
 
-static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp)
+static int ptp_clock_getres(struct posix_clock *pc, struct timespec64 *tp)
 {
tp->tv_sec = 0;
tp->tv_nsec = 1;
return 0;
 }
 
-static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp)
+static int ptp_clock_settime(struct posix_clock *pc, const struct timespec64 
*tp)
 {
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
-   struct timespec64 ts = timespec_to_timespec64(*tp);
 
-   return  ptp->info->settime64(ptp->info, );
+   return  ptp->info->settime64(ptp->info, tp);
 }
 
-static int ptp_clock_gettime(struct posix_clock *pc, struct timespec *tp)
+static int ptp_clock_gettime(struct posix_clock *pc, struct timespec64 *tp)
 {
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
-   struct timespec64 ts;
int err;
 
-   err = ptp->info->gettime64(ptp->info, );
-   if (!err)
-   *tp = timespec64_to_timespec(ts);
+   err = ptp->info->gettime64(ptp->info, tp);
return err;
 }
 
@@ -133,7 +129,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct 
timex *tx)
ops = ptp->info;
 
if (tx->modes & ADJ_SETOFFSET) {
-   struct timespec ts;
+   struct timespec64 ts;
ktime_t kt;
s64 delta;
 
@@ -146,7 +142,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct 
timex *tx)
if ((unsigned long) ts.tv_nsec >= NSEC_PER_SEC)
return -EINVAL;
 
-   kt = timespec_to_ktime(ts);
+   kt = timespec64_to_ktime(ts);
delta = ktime_to_ns(kt);
err = ops->adjtime(ops, delta);
} else if (tx->modes & ADJ_FREQUENCY) {
diff --git a/include/linux/posix-clock.h b/include/linux/posix-clock.h
index 34c4498..83b22ae 100644
--- a/include/linux/posix-clock.h
+++ b/include/linux/posix-clock.h
@@ -59,23 +59,23 @@ struct posix_clock_operations {
 
int  (*clock_adjtime)(struct posix_clock *pc, struct timex *tx);
 
-   int  (*clock_gettime)(struct posix_clock *pc, struct timespec *ts);
+   int  (*clock_gettime)(struct posix_clock *pc, struct timespec64 *ts);
 
-   int  (*clock_getres) (struct posix_clock *pc, struct timespec *ts);
+   int  (*clock_getres) (struct posix_clock *pc, struct timespec64 *ts);
 
int  (*clock_settime)(struct posix_clock *pc,
- const struct timespec *ts);
+ const struct timespec64 *ts);
 
int  (*timer_create) (struct posix_clock *pc, struct k_itimer *kit);
 
int  (*timer_delete) (struct posix_clock *pc, struct k_itimer *kit);
 
void (*timer_gettime)(struct posix_clock *pc,
- struct k_itimer *kit, struct itimerspec *tsp);
+ struct k_itimer *kit, struct itimerspec64 *tsp);
 
int  (*timer_settime)(struct posix_clock *pc,
  struct k_itimer *kit, int flags,
- struct itimerspec *tsp, struct itimerspec *old);
+ struct itimerspec64 *tsp, struct itimerspec64 
*old);
/*
 * Optional character device methods:
 */
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 9cff0ab..f2af1b5 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -300,14 +300,17 @@ static int pc_clock_adjtime(clockid_t id, struct timex 
*tx)
 static int pc_clock_gettime(clockid_t id, struct timespec *ts)
 {
struct posix_clock_desc cd;
+   struct timespec64 ts64;
int err;
 
err = get_clock_desc(id, );
if (err)
return err;
 
-   if (cd.clk->ops.clock_gettime)
-   err = 

[PATCH 7/7] Change k_clock nsleep() to use timespec64

2017-03-18 Thread Deepa Dinamani
From: Deepa Dinamani 

struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 include/linux/hrtimer.h|  2 +-
 include/linux/posix-timers.h   |  2 +-
 kernel/compat.c|  6 --
 kernel/time/alarmtimer.c   |  4 ++--
 kernel/time/hrtimer.c  | 10 ++
 kernel/time/posix-cpu-timers.c | 36 ++--
 kernel/time/posix-stubs.c  |  6 --
 kernel/time/posix-timers.c | 10 ++
 8 files changed, 42 insertions(+), 34 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 249e579..7d019c0 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -456,7 +456,7 @@ static inline u64 hrtimer_forward_now(struct hrtimer *timer,
 }
 
 /* Precise sleep: */
-extern long hrtimer_nanosleep(struct timespec *rqtp,
+extern long hrtimer_nanosleep(struct timespec64 *rqtp,
  struct timespec __user *rmtp,
  const enum hrtimer_mode mode,
  const clockid_t clockid);
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index f608941..97a883a 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -94,7 +94,7 @@ struct k_clock {
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
int (*nsleep) (const clockid_t which_clock, int flags,
-  struct timespec *, struct timespec __user *);
+  struct timespec64 *, struct timespec __user *);
long (*nsleep_restart) (struct restart_block *restart_block);
int (*timer_set) (struct k_itimer * timr, int flags,
  struct itimerspec64 * new_setting,
diff --git a/kernel/compat.c b/kernel/compat.c
index e29a01a..8ec15d1 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -240,18 +240,20 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec 
__user *, rqtp,
   struct compat_timespec __user *, rmtp)
 {
struct timespec tu, rmt;
+   struct timespec64 tu64;
mm_segment_t oldfs;
long ret;
 
if (compat_get_timespec(, rqtp))
return -EFAULT;
 
-   if (!timespec_valid())
+   tu64 = timespec_to_timespec64(tu);
+   if (!timespec64_valid())
return -EINVAL;
 
oldfs = get_fs();
set_fs(KERNEL_DS);
-   ret = hrtimer_nanosleep(,
+   ret = hrtimer_nanosleep(,
rmtp ? (struct timespec __user *) : NULL,
HRTIMER_MODE_REL, CLOCK_MONOTONIC);
set_fs(oldfs);
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 81db6df..cc20417 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -790,7 +790,7 @@ static long __sched alarm_timer_nsleep_restart(struct 
restart_block *restart)
  * Handles clock_nanosleep calls against _ALARM clockids
  */
 static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
-struct timespec *tsreq, struct timespec __user *rmtp)
+struct timespec64 *tsreq, struct timespec __user *rmtp)
 {
enum  alarmtimer_type type = clock2alarm(which_clock);
struct alarm alarm;
@@ -809,7 +809,7 @@ static int alarm_timer_nsleep(const clockid_t which_clock, 
int flags,
 
alarm_init(, type, alarmtimer_nsleep_wakeup);
 
-   exp = timespec_to_ktime(*tsreq);
+   exp = timespec64_to_ktime(*tsreq);
/* Convert (if necessary) to absolute time */
if (flags != TIMER_ABSTIME) {
ktime_t now = alarm_bases[type].gettime();
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index ec08f52..f530295 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1506,7 +1506,7 @@ long __sched hrtimer_nanosleep_restart(struct 
restart_block *restart)
return ret;
 }
 
-long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
+long hrtimer_nanosleep(struct timespec64 *rqtp, struct timespec __user *rmtp,
   const enum hrtimer_mode mode, const clockid_t clockid)
 {
struct restart_block *restart;
@@ -1519,7 +1519,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct 
timespec __user *rmtp,
slack = 0;
 
hrtimer_init_on_stack(, clockid, mode);
-   hrtimer_set_expires_range_ns(, timespec_to_ktime(*rqtp), slack);
+   hrtimer_set_expires_range_ns(, timespec64_to_ktime(*rqtp), 
slack);
if (do_nanosleep(, mode))
goto out;
 
@@ -1551,14 +1551,16 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, 
rqtp,
struct 

[PATCH 2/7] time: Change posix clocks ops interfaces to use timespec64

2017-03-18 Thread Deepa Dinamani
 struct timespec is not y2038 safe.
 Replace the posix_clock ops interfaces to use
 struct timespec64.
 The patch also changes struct itimerspec interfaces to
 struct itimerspec64 as itimerspec internally uses timespec
 and itimerspec64 uses timespec64.
 PTP clocks is the only module that sets up these interfaces.
 All individual drivers rely on PTP class driver for exposure
 to userspace. Hence, the change also deals with fixing up these
 PTP interfaces.
 The patch also changes dynamic posix clock implementation to
 reflect the changes in the functional clock interface.

Signed-off-by: Deepa Dinamani 
---
 drivers/ptp/ptp_clock.c | 18 +++---
 include/linux/posix-clock.h | 10 +-
 kernel/time/posix-clock.c   | 34 --
 3 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index e814280..b774357 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -97,30 +97,26 @@ static s32 scaled_ppm_to_ppb(long ppm)
 
 /* posix clock implementation */
 
-static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp)
+static int ptp_clock_getres(struct posix_clock *pc, struct timespec64 *tp)
 {
tp->tv_sec = 0;
tp->tv_nsec = 1;
return 0;
 }
 
-static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp)
+static int ptp_clock_settime(struct posix_clock *pc, const struct timespec64 
*tp)
 {
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
-   struct timespec64 ts = timespec_to_timespec64(*tp);
 
-   return  ptp->info->settime64(ptp->info, );
+   return  ptp->info->settime64(ptp->info, tp);
 }
 
-static int ptp_clock_gettime(struct posix_clock *pc, struct timespec *tp)
+static int ptp_clock_gettime(struct posix_clock *pc, struct timespec64 *tp)
 {
struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock);
-   struct timespec64 ts;
int err;
 
-   err = ptp->info->gettime64(ptp->info, );
-   if (!err)
-   *tp = timespec64_to_timespec(ts);
+   err = ptp->info->gettime64(ptp->info, tp);
return err;
 }
 
@@ -133,7 +129,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct 
timex *tx)
ops = ptp->info;
 
if (tx->modes & ADJ_SETOFFSET) {
-   struct timespec ts;
+   struct timespec64 ts;
ktime_t kt;
s64 delta;
 
@@ -146,7 +142,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct 
timex *tx)
if ((unsigned long) ts.tv_nsec >= NSEC_PER_SEC)
return -EINVAL;
 
-   kt = timespec_to_ktime(ts);
+   kt = timespec64_to_ktime(ts);
delta = ktime_to_ns(kt);
err = ops->adjtime(ops, delta);
} else if (tx->modes & ADJ_FREQUENCY) {
diff --git a/include/linux/posix-clock.h b/include/linux/posix-clock.h
index 34c4498..83b22ae 100644
--- a/include/linux/posix-clock.h
+++ b/include/linux/posix-clock.h
@@ -59,23 +59,23 @@ struct posix_clock_operations {
 
int  (*clock_adjtime)(struct posix_clock *pc, struct timex *tx);
 
-   int  (*clock_gettime)(struct posix_clock *pc, struct timespec *ts);
+   int  (*clock_gettime)(struct posix_clock *pc, struct timespec64 *ts);
 
-   int  (*clock_getres) (struct posix_clock *pc, struct timespec *ts);
+   int  (*clock_getres) (struct posix_clock *pc, struct timespec64 *ts);
 
int  (*clock_settime)(struct posix_clock *pc,
- const struct timespec *ts);
+ const struct timespec64 *ts);
 
int  (*timer_create) (struct posix_clock *pc, struct k_itimer *kit);
 
int  (*timer_delete) (struct posix_clock *pc, struct k_itimer *kit);
 
void (*timer_gettime)(struct posix_clock *pc,
- struct k_itimer *kit, struct itimerspec *tsp);
+ struct k_itimer *kit, struct itimerspec64 *tsp);
 
int  (*timer_settime)(struct posix_clock *pc,
  struct k_itimer *kit, int flags,
- struct itimerspec *tsp, struct itimerspec *old);
+ struct itimerspec64 *tsp, struct itimerspec64 
*old);
/*
 * Optional character device methods:
 */
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 9cff0ab..f2af1b5 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -300,14 +300,17 @@ static int pc_clock_adjtime(clockid_t id, struct timex 
*tx)
 static int pc_clock_gettime(clockid_t id, struct timespec *ts)
 {
struct posix_clock_desc cd;
+   struct timespec64 ts64;
int err;
 
err = get_clock_desc(id, );
if (err)
return err;
 
-   if (cd.clk->ops.clock_gettime)
-   err = cd.clk->ops.clock_gettime(cd.clk, ts);
+   

[PATCH 7/7] Change k_clock nsleep() to use timespec64

2017-03-18 Thread Deepa Dinamani
From: Deepa Dinamani 

struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 include/linux/hrtimer.h|  2 +-
 include/linux/posix-timers.h   |  2 +-
 kernel/compat.c|  6 --
 kernel/time/alarmtimer.c   |  4 ++--
 kernel/time/hrtimer.c  | 10 ++
 kernel/time/posix-cpu-timers.c | 36 ++--
 kernel/time/posix-stubs.c  |  6 --
 kernel/time/posix-timers.c | 10 ++
 8 files changed, 42 insertions(+), 34 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 249e579..7d019c0 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -456,7 +456,7 @@ static inline u64 hrtimer_forward_now(struct hrtimer *timer,
 }
 
 /* Precise sleep: */
-extern long hrtimer_nanosleep(struct timespec *rqtp,
+extern long hrtimer_nanosleep(struct timespec64 *rqtp,
  struct timespec __user *rmtp,
  const enum hrtimer_mode mode,
  const clockid_t clockid);
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index f608941..97a883a 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -94,7 +94,7 @@ struct k_clock {
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
int (*nsleep) (const clockid_t which_clock, int flags,
-  struct timespec *, struct timespec __user *);
+  struct timespec64 *, struct timespec __user *);
long (*nsleep_restart) (struct restart_block *restart_block);
int (*timer_set) (struct k_itimer * timr, int flags,
  struct itimerspec64 * new_setting,
diff --git a/kernel/compat.c b/kernel/compat.c
index e29a01a..8ec15d1 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -240,18 +240,20 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec 
__user *, rqtp,
   struct compat_timespec __user *, rmtp)
 {
struct timespec tu, rmt;
+   struct timespec64 tu64;
mm_segment_t oldfs;
long ret;
 
if (compat_get_timespec(, rqtp))
return -EFAULT;
 
-   if (!timespec_valid())
+   tu64 = timespec_to_timespec64(tu);
+   if (!timespec64_valid())
return -EINVAL;
 
oldfs = get_fs();
set_fs(KERNEL_DS);
-   ret = hrtimer_nanosleep(,
+   ret = hrtimer_nanosleep(,
rmtp ? (struct timespec __user *) : NULL,
HRTIMER_MODE_REL, CLOCK_MONOTONIC);
set_fs(oldfs);
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 81db6df..cc20417 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -790,7 +790,7 @@ static long __sched alarm_timer_nsleep_restart(struct 
restart_block *restart)
  * Handles clock_nanosleep calls against _ALARM clockids
  */
 static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
-struct timespec *tsreq, struct timespec __user *rmtp)
+struct timespec64 *tsreq, struct timespec __user *rmtp)
 {
enum  alarmtimer_type type = clock2alarm(which_clock);
struct alarm alarm;
@@ -809,7 +809,7 @@ static int alarm_timer_nsleep(const clockid_t which_clock, 
int flags,
 
alarm_init(, type, alarmtimer_nsleep_wakeup);
 
-   exp = timespec_to_ktime(*tsreq);
+   exp = timespec64_to_ktime(*tsreq);
/* Convert (if necessary) to absolute time */
if (flags != TIMER_ABSTIME) {
ktime_t now = alarm_bases[type].gettime();
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index ec08f52..f530295 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1506,7 +1506,7 @@ long __sched hrtimer_nanosleep_restart(struct 
restart_block *restart)
return ret;
 }
 
-long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
+long hrtimer_nanosleep(struct timespec64 *rqtp, struct timespec __user *rmtp,
   const enum hrtimer_mode mode, const clockid_t clockid)
 {
struct restart_block *restart;
@@ -1519,7 +1519,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct 
timespec __user *rmtp,
slack = 0;
 
hrtimer_init_on_stack(, clockid, mode);
-   hrtimer_set_expires_range_ns(, timespec_to_ktime(*rqtp), slack);
+   hrtimer_set_expires_range_ns(, timespec64_to_ktime(*rqtp), 
slack);
if (do_nanosleep(, mode))
goto out;
 
@@ -1551,14 +1551,16 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, 
rqtp,
struct timespec __user *, rmtp)
 {
struct timespec tu;

[PATCH 1/7] time: Delete do_sys_setimeofday()

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces will be changed in a separate
series.
Call to do_sys_setimeofday() is superfluous as all
the necessary checks and functions are done by the
underlying function do_sys_setimeofday64().
Replace do_sys_setimeofday64() directly instead of
do_sys_settimeofday(). The do_sys_setimeofday64()
calls timespec64_valid() internally, which is the
same as timespec_valid().

Signed-off-by: Deepa Dinamani 
---
 include/linux/timekeeping.h | 15 ---
 kernel/compat.c |  4 ++--
 kernel/time/posix-stubs.c   |  5 -
 kernel/time/posix-timers.c  |  5 -
 kernel/time/time.c  |  4 ++--
 5 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index b598cbc..3617a78 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -19,21 +19,6 @@ extern void do_gettimeofday(struct timeval *tv);
 extern int do_settimeofday64(const struct timespec64 *ts);
 extern int do_sys_settimeofday64(const struct timespec64 *tv,
 const struct timezone *tz);
-static inline int do_sys_settimeofday(const struct timespec *tv,
- const struct timezone *tz)
-{
-   struct timespec64 ts64;
-
-   if (!tv)
-   return do_sys_settimeofday64(NULL, tz);
-
-   if (!timespec_valid(tv))
-   return -EINVAL;
-
-   ts64 = timespec_to_timespec64(*tv);
-   return do_sys_settimeofday64(, tz);
-}
-
 /*
  * Kernel time accessors
  */
diff --git a/kernel/compat.c b/kernel/compat.c
index 19aec5d..e29a01a 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -109,7 +109,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval 
__user *, tv,
   struct timezone __user *, tz)
 {
struct timeval user_tv;
-   struct timespec new_ts;
+   struct timespec64 new_ts;
struct timezone new_tz;
 
if (tv) {
@@ -123,7 +123,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval 
__user *, tv,
return -EFAULT;
}
 
-   return do_sys_settimeofday(tv ? _ts : NULL, tz ? _tz : NULL);
+   return do_sys_settimeofday64(tv ? _ts : NULL, tz ? _tz : NULL);
 }
 
 static int __compat_get_timeval(struct timeval *tv, const struct 
compat_timeval __user *ctv)
diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c
index cd6716e..df275db 100644
--- a/kernel/time/posix-stubs.c
+++ b/kernel/time/posix-stubs.c
@@ -50,12 +50,15 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
const struct timespec __user *, tp)
 {
struct timespec new_tp;
+   struct timespec64 new_tp64;
 
if (which_clock != CLOCK_REALTIME)
return -EINVAL;
if (copy_from_user(_tp, tp, sizeof (*tp)))
return -EFAULT;
-   return do_sys_settimeofday(_tp, NULL);
+
+   new_tp64 = timespec_to_timespec64(new_tp);
+   return do_sys_settimeofday64(_tp64, NULL);
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 50a6a47..f215ef7 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -214,7 +214,10 @@ static int posix_clock_realtime_get(clockid_t which_clock, 
struct timespec *tp)
 static int posix_clock_realtime_set(const clockid_t which_clock,
const struct timespec *tp)
 {
-   return do_sys_settimeofday(tp, NULL);
+   struct timespec64 tp64;
+
+   tp64 = timespec_to_timespec64(*tp);
+   return do_sys_settimeofday64(, NULL);
 }
 
 static int posix_clock_realtime_adj(const clockid_t which_clock,
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 25bdd25..450e8a1 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -194,7 +194,7 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
struct timezone __user *, tz)
 {
struct timeval user_tv;
-   struct timespec new_ts;
+   struct timespec64 new_ts;
struct timezone new_tz;
 
if (tv) {
@@ -212,7 +212,7 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
return -EFAULT;
}
 
-   return do_sys_settimeofday(tv ? _ts : NULL, tz ? _tz : NULL);
+   return do_sys_settimeofday64(tv ? _ts : NULL, tz ? _tz : NULL);
 }
 
 SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)
-- 
2.7.4



[PATCH 1/7] time: Delete do_sys_setimeofday()

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces will be changed in a separate
series.
Call to do_sys_setimeofday() is superfluous as all
the necessary checks and functions are done by the
underlying function do_sys_setimeofday64().
Replace do_sys_setimeofday64() directly instead of
do_sys_settimeofday(). The do_sys_setimeofday64()
calls timespec64_valid() internally, which is the
same as timespec_valid().

Signed-off-by: Deepa Dinamani 
---
 include/linux/timekeeping.h | 15 ---
 kernel/compat.c |  4 ++--
 kernel/time/posix-stubs.c   |  5 -
 kernel/time/posix-timers.c  |  5 -
 kernel/time/time.c  |  4 ++--
 5 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index b598cbc..3617a78 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -19,21 +19,6 @@ extern void do_gettimeofday(struct timeval *tv);
 extern int do_settimeofday64(const struct timespec64 *ts);
 extern int do_sys_settimeofday64(const struct timespec64 *tv,
 const struct timezone *tz);
-static inline int do_sys_settimeofday(const struct timespec *tv,
- const struct timezone *tz)
-{
-   struct timespec64 ts64;
-
-   if (!tv)
-   return do_sys_settimeofday64(NULL, tz);
-
-   if (!timespec_valid(tv))
-   return -EINVAL;
-
-   ts64 = timespec_to_timespec64(*tv);
-   return do_sys_settimeofday64(, tz);
-}
-
 /*
  * Kernel time accessors
  */
diff --git a/kernel/compat.c b/kernel/compat.c
index 19aec5d..e29a01a 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -109,7 +109,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval 
__user *, tv,
   struct timezone __user *, tz)
 {
struct timeval user_tv;
-   struct timespec new_ts;
+   struct timespec64 new_ts;
struct timezone new_tz;
 
if (tv) {
@@ -123,7 +123,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval 
__user *, tv,
return -EFAULT;
}
 
-   return do_sys_settimeofday(tv ? _ts : NULL, tz ? _tz : NULL);
+   return do_sys_settimeofday64(tv ? _ts : NULL, tz ? _tz : NULL);
 }
 
 static int __compat_get_timeval(struct timeval *tv, const struct 
compat_timeval __user *ctv)
diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c
index cd6716e..df275db 100644
--- a/kernel/time/posix-stubs.c
+++ b/kernel/time/posix-stubs.c
@@ -50,12 +50,15 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
const struct timespec __user *, tp)
 {
struct timespec new_tp;
+   struct timespec64 new_tp64;
 
if (which_clock != CLOCK_REALTIME)
return -EINVAL;
if (copy_from_user(_tp, tp, sizeof (*tp)))
return -EFAULT;
-   return do_sys_settimeofday(_tp, NULL);
+
+   new_tp64 = timespec_to_timespec64(new_tp);
+   return do_sys_settimeofday64(_tp64, NULL);
 }
 
 SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 50a6a47..f215ef7 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -214,7 +214,10 @@ static int posix_clock_realtime_get(clockid_t which_clock, 
struct timespec *tp)
 static int posix_clock_realtime_set(const clockid_t which_clock,
const struct timespec *tp)
 {
-   return do_sys_settimeofday(tp, NULL);
+   struct timespec64 tp64;
+
+   tp64 = timespec_to_timespec64(*tp);
+   return do_sys_settimeofday64(, NULL);
 }
 
 static int posix_clock_realtime_adj(const clockid_t which_clock,
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 25bdd25..450e8a1 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -194,7 +194,7 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
struct timezone __user *, tz)
 {
struct timeval user_tv;
-   struct timespec new_ts;
+   struct timespec64 new_ts;
struct timezone new_tz;
 
if (tv) {
@@ -212,7 +212,7 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
return -EFAULT;
}
 
-   return do_sys_settimeofday(tv ? _ts : NULL, tz ? _tz : NULL);
+   return do_sys_settimeofday64(tv ? _ts : NULL, tz ? _tz : NULL);
 }
 
 SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)
-- 
2.7.4



[PATCH 4/7] Change k_clock clock_getres() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c |  2 +-
 include/linux/posix-timers.h   |  2 +-
 kernel/time/alarmtimer.c   |  2 +-
 kernel/time/posix-clock.c  |  9 +++--
 kernel/time/posix-cpu-timers.c |  6 +++---
 kernel/time/posix-timers.c | 10 ++
 6 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 40d880b..79d8ada 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -765,7 +765,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return err;
 }
 
-static int sgi_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int sgi_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
 {
tp->tv_sec = 0;
tp->tv_nsec = sgi_clock_period;
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index db54f1b..2555d1c 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -87,7 +87,7 @@ struct k_itimer {
 };
 
 struct k_clock {
-   int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
+   int (*clock_getres) (const clockid_t which_clock, struct timespec64 
*tp);
int (*clock_set) (const clockid_t which_clock,
  const struct timespec *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 944ca6e..e8a45e2 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -541,7 +541,7 @@ static enum alarmtimer_restart alarm_handle_timer(struct 
alarm *alarm,
  *
  * Returns the granularity of underlying alarm base clock
  */
-static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int alarm_clock_getres(const clockid_t which_clock, struct timespec64 
*tp)
 {
if (!alarmtimer_get_rtcdev())
return -EINVAL;
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 0427c8c..d5a4bec 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -316,20 +316,17 @@ static int pc_clock_gettime(clockid_t id, struct 
timespec64 *ts)
return err;
 }
 
-static int pc_clock_getres(clockid_t id, struct timespec *ts)
+static int pc_clock_getres(clockid_t id, struct timespec64 *ts)
 {
struct posix_clock_desc cd;
-   struct timespec64 ts64;
int err;
 
err = get_clock_desc(id, );
if (err)
return err;
 
-   if (cd.clk->ops.clock_getres) {
-   err = cd.clk->ops.clock_getres(cd.clk, );
-   *ts = timespec64_to_timespec(ts64);
-   }
+   if (cd.clk->ops.clock_getres)
+   err = cd.clk->ops.clock_getres(cd.clk, ts);
else
err = -EOPNOTSUPP;
 
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 6c509ea..42ca205 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -116,7 +116,7 @@ static inline u64 virt_ticks(struct task_struct *p)
 }
 
 static int
-posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *tp)
+posix_cpu_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
 {
int error = check_clock(which_clock);
if (!error) {
@@ -1364,7 +1364,7 @@ static long posix_cpu_nsleep_restart(struct restart_block 
*restart_block)
 #define THREAD_CLOCK   MAKE_THREAD_CPUCLOCK(0, CPUCLOCK_SCHED)
 
 static int process_cpu_clock_getres(const clockid_t which_clock,
-   struct timespec *tp)
+   struct timespec64 *tp)
 {
return posix_cpu_clock_getres(PROCESS_CLOCK, tp);
 }
@@ -1389,7 +1389,7 @@ static long process_cpu_nsleep_restart(struct 
restart_block *restart_block)
return -EINVAL;
 }
 static int thread_cpu_clock_getres(const clockid_t which_clock,
-  struct timespec *tp)
+  struct timespec64 *tp)
 {
return posix_cpu_clock_getres(THREAD_CLOCK, tp);
 }
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index ba0c472..a314a63 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -258,9 +258,9 @@ static int posix_get_monotonic_coarse(clockid_t which_clock,
return 0;
 }
 
-static int posix_get_coarse_res(const clockid_t which_clock, struct timespec 
*tp)
+static int posix_get_coarse_res(const clockid_t which_clock, struct timespec64 
*tp)
 {
-   *tp = ktime_to_timespec(KTIME_LOW_RES);
+   *tp = ktime_to_timespec64(KTIME_LOW_RES);
return 0;
 }
 
@@ -276,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, 

[PATCH 3/7] Change k_clock clock_get() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c |  4 ++--
 include/linux/posix-timers.h   |  2 +-
 include/linux/timekeeping.h|  5 +
 kernel/time/alarmtimer.c   |  4 ++--
 kernel/time/posix-clock.c  |  9 +++--
 kernel/time/posix-cpu-timers.c | 10 +-
 kernel/time/posix-stubs.c  |  9 ++---
 kernel/time/posix-timers.c | 32 +---
 8 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index b708c85..40d880b 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -478,13 +478,13 @@ static int sgi_clock_period;
 static struct timespec sgi_clock_offset;
 static int sgi_clock_period;
 
-static int sgi_clock_get(clockid_t clockid, struct timespec *tp)
+static int sgi_clock_get(clockid_t clockid, struct timespec64 *tp)
 {
u64 nsec;
 
nsec = rtc_time() * sgi_clock_period
+ sgi_clock_offset.tv_nsec;
-   *tp = ns_to_timespec(nsec);
+   *tp = ns_to_timespec64(nsec);
tp->tv_sec += sgi_clock_offset.tv_sec;
return 0;
 };
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 64aa189..db54f1b 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -90,7 +90,7 @@ struct k_clock {
int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
int (*clock_set) (const clockid_t which_clock,
  const struct timespec *tp);
-   int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
+   int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
int (*nsleep) (const clockid_t which_clock, int flags,
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 3617a78..ddc229f 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -258,6 +258,11 @@ static inline void timekeeping_clocktai(struct timespec 
*ts)
*ts = ktime_to_timespec(ktime_get_clocktai());
 }
 
+static inline void timekeeping_clocktai64(struct timespec64 *ts)
+{
+   *ts = ktime_to_timespec64(ktime_get_clocktai());
+}
+
 /*
  * RTC specific
  */
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index ce3a31e..944ca6e 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -558,14 +558,14 @@ static int alarm_clock_getres(const clockid_t 
which_clock, struct timespec *tp)
  *
  * Provides the underlying alarm base time.
  */
-static int alarm_clock_get(clockid_t which_clock, struct timespec *tp)
+static int alarm_clock_get(clockid_t which_clock, struct timespec64 *tp)
 {
struct alarm_base *base = _bases[clock2alarm(which_clock)];
 
if (!alarmtimer_get_rtcdev())
return -EINVAL;
 
-   *tp = ktime_to_timespec(base->gettime());
+   *tp = ktime_to_timespec64(base->gettime());
return 0;
 }
 
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index f2af1b5..0427c8c 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -297,20 +297,17 @@ static int pc_clock_adjtime(clockid_t id, struct timex 
*tx)
return err;
 }
 
-static int pc_clock_gettime(clockid_t id, struct timespec *ts)
+static int pc_clock_gettime(clockid_t id, struct timespec64 *ts)
 {
struct posix_clock_desc cd;
-   struct timespec64 ts64;
int err;
 
err = get_clock_desc(id, );
if (err)
return err;
 
-   if (cd.clk->ops.clock_gettime) {
-   err = cd.clk->ops.clock_gettime(cd.clk, );
-   *ts = timespec64_to_timespec(ts64);
-   }
+   if (cd.clk->ops.clock_gettime)
+   err = cd.clk->ops.clock_gettime(cd.clk, ts);
else
err = -EOPNOTSUPP;
 
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 4513ad1..6c509ea 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -261,7 +261,7 @@ static int cpu_clock_sample_group(const clockid_t 
which_clock,
 
 static int posix_cpu_clock_get_task(struct task_struct *tsk,
const clockid_t which_clock,
-   struct timespec *tp)
+   struct timespec64 *tp)
 {
int err = -EINVAL;
u64 rtn;
@@ -275,13 +275,13 @@ static int posix_cpu_clock_get_task(struct task_struct 
*tsk,
}
 
if (!err)
-   *tp = ns_to_timespec(rtn);
+   *tp = ns_to_timespec64(rtn);
 
return err;
 }
 

[PATCH 6/7] Change k_clock timer_set() and timer_get() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c | 20 ++--
 include/linux/posix-timers.h   |  6 +++---
 kernel/time/alarmtimer.c   | 14 +++---
 kernel/time/posix-clock.c  | 21 +++--
 kernel/time/posix-cpu-timers.c | 28 
 kernel/time/posix-timers.c | 33 +++--
 6 files changed, 62 insertions(+), 60 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index ba1b892..863a111 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -657,7 +657,7 @@ static int sgi_timer_del(struct k_itimer *timr)
 }
 
 /* Assumption: it_lock is already held with irq's disabled */
-static void sgi_timer_get(struct k_itimer *timr, struct itimerspec 
*cur_setting)
+static void sgi_timer_get(struct k_itimer *timr, struct itimerspec64 
*cur_setting)
 {
 
if (timr->it.mmtimer.clock == TIMER_OFF) {
@@ -668,14 +668,14 @@ static void sgi_timer_get(struct k_itimer *timr, struct 
itimerspec *cur_setting)
return;
}
 
-   cur_setting->it_interval = ns_to_timespec(timr->it.mmtimer.incr * 
sgi_clock_period);
-   cur_setting->it_value = ns_to_timespec((timr->it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
+   cur_setting->it_interval = ns_to_timespec64(timr->it.mmtimer.incr * 
sgi_clock_period);
+   cur_setting->it_value = ns_to_timespec64((timr->it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
 }
 
 
 static int sgi_timer_set(struct k_itimer *timr, int flags,
-   struct itimerspec * new_setting,
-   struct itimerspec * old_setting)
+   struct itimerspec64 * new_setting,
+   struct itimerspec64 * old_setting)
 {
unsigned long when, period, irqflags;
int err = 0;
@@ -687,8 +687,8 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
sgi_timer_get(timr, old_setting);
 
sgi_timer_del(timr);
-   when = timespec_to_ns(_setting->it_value);
-   period = timespec_to_ns(_setting->it_interval);
+   when = timespec64_to_ns(_setting->it_value);
+   period = timespec64_to_ns(_setting->it_interval);
 
if (when == 0)
/* Clear timer */
@@ -699,11 +699,11 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return -ENOMEM;
 
if (flags & TIMER_ABSTIME) {
-   struct timespec n;
+   struct timespec64 n;
unsigned long now;
 
-   getnstimeofday();
-   now = timespec_to_ns();
+   getnstimeofday64();
+   now = timespec64_to_ns();
if (when > now)
when -= now;
else
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 249429c..f608941 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -97,12 +97,12 @@ struct k_clock {
   struct timespec *, struct timespec __user *);
long (*nsleep_restart) (struct restart_block *restart_block);
int (*timer_set) (struct k_itimer * timr, int flags,
- struct itimerspec * new_setting,
- struct itimerspec * old_setting);
+ struct itimerspec64 * new_setting,
+ struct itimerspec64 * old_setting);
int (*timer_del) (struct k_itimer * timr);
 #define TIMER_RETRY 1
void (*timer_get) (struct k_itimer * timr,
-  struct itimerspec * cur_setting);
+  struct itimerspec64 * cur_setting);
 };
 
 extern struct k_clock clock_posix_cpu;
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index e8a45e2..81db6df 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -598,19 +598,19 @@ static int alarm_timer_create(struct k_itimer *new_timer)
  * Copies out the current itimerspec data
  */
 static void alarm_timer_get(struct k_itimer *timr,
-   struct itimerspec *cur_setting)
+   struct itimerspec64 *cur_setting)
 {
ktime_t relative_expiry_time =
alarm_expires_remaining(&(timr->it.alarm.alarmtimer));
 
if (ktime_to_ns(relative_expiry_time) > 0) {
-   cur_setting->it_value = ktime_to_timespec(relative_expiry_time);
+   cur_setting->it_value = 
ktime_to_timespec64(relative_expiry_time);
} else {
cur_setting->it_value.tv_sec = 0;
cur_setting->it_value.tv_nsec = 0;
}
 
-   cur_setting->it_interval = ktime_to_timespec(timr->it.alarm.interval);
+   cur_setting->it_interval = 

[PATCH 0/7] Change k_clock interfaces to use timespec64

2017-03-18 Thread Deepa Dinamani
The series is aimed at replacing struct timespec which is not
y2038 safe with y2038 safe struct timespec64 for k_clock interfaces.

The series does not change the syscall interface.
This will be done in a follow up series.

A few existing checkpatch-noted style issues, such as the 80 line
character limit, have been left as-is to facilitate easier review.

Deepa Dinamani (7):
  time: Delete do_sys_setimeofday()
  time: Change posix clocks ops interfaces to use timespec64
  Change k_clock clock_get() to use timespec64
  Change k_clock clock_getres() to use timespec64
  Change k_clock clock_set() to use timespec64
  Change k_clock timer_set() and timer_get() to use timespec64
  Change k_clock nsleep() to use timespec64

 drivers/char/mmtimer.c | 28 ++---
 drivers/ptp/ptp_clock.c| 18 
 include/linux/hrtimer.h|  2 +-
 include/linux/posix-clock.h| 10 ++---
 include/linux/posix-timers.h   | 14 +++
 include/linux/timekeeping.h| 20 +++--
 kernel/compat.c| 10 +++--
 kernel/time/alarmtimer.c   | 24 +--
 kernel/time/hrtimer.c  | 10 +++--
 kernel/time/posix-clock.c  | 10 ++---
 kernel/time/posix-cpu-timers.c | 66 --
 kernel/time/posix-stubs.c  | 20 ++---
 kernel/time/posix-timers.c | 93 --
 kernel/time/time.c |  4 +-
 14 files changed, 172 insertions(+), 157 deletions(-)

-- 
2.7.4



[PATCH 4/7] Change k_clock clock_getres() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c |  2 +-
 include/linux/posix-timers.h   |  2 +-
 kernel/time/alarmtimer.c   |  2 +-
 kernel/time/posix-clock.c  |  9 +++--
 kernel/time/posix-cpu-timers.c |  6 +++---
 kernel/time/posix-timers.c | 10 ++
 6 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 40d880b..79d8ada 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -765,7 +765,7 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return err;
 }
 
-static int sgi_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int sgi_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
 {
tp->tv_sec = 0;
tp->tv_nsec = sgi_clock_period;
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index db54f1b..2555d1c 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -87,7 +87,7 @@ struct k_itimer {
 };
 
 struct k_clock {
-   int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
+   int (*clock_getres) (const clockid_t which_clock, struct timespec64 
*tp);
int (*clock_set) (const clockid_t which_clock,
  const struct timespec *tp);
int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index 944ca6e..e8a45e2 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -541,7 +541,7 @@ static enum alarmtimer_restart alarm_handle_timer(struct 
alarm *alarm,
  *
  * Returns the granularity of underlying alarm base clock
  */
-static int alarm_clock_getres(const clockid_t which_clock, struct timespec *tp)
+static int alarm_clock_getres(const clockid_t which_clock, struct timespec64 
*tp)
 {
if (!alarmtimer_get_rtcdev())
return -EINVAL;
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index 0427c8c..d5a4bec 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -316,20 +316,17 @@ static int pc_clock_gettime(clockid_t id, struct 
timespec64 *ts)
return err;
 }
 
-static int pc_clock_getres(clockid_t id, struct timespec *ts)
+static int pc_clock_getres(clockid_t id, struct timespec64 *ts)
 {
struct posix_clock_desc cd;
-   struct timespec64 ts64;
int err;
 
err = get_clock_desc(id, );
if (err)
return err;
 
-   if (cd.clk->ops.clock_getres) {
-   err = cd.clk->ops.clock_getres(cd.clk, );
-   *ts = timespec64_to_timespec(ts64);
-   }
+   if (cd.clk->ops.clock_getres)
+   err = cd.clk->ops.clock_getres(cd.clk, ts);
else
err = -EOPNOTSUPP;
 
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 6c509ea..42ca205 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -116,7 +116,7 @@ static inline u64 virt_ticks(struct task_struct *p)
 }
 
 static int
-posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *tp)
+posix_cpu_clock_getres(const clockid_t which_clock, struct timespec64 *tp)
 {
int error = check_clock(which_clock);
if (!error) {
@@ -1364,7 +1364,7 @@ static long posix_cpu_nsleep_restart(struct restart_block 
*restart_block)
 #define THREAD_CLOCK   MAKE_THREAD_CPUCLOCK(0, CPUCLOCK_SCHED)
 
 static int process_cpu_clock_getres(const clockid_t which_clock,
-   struct timespec *tp)
+   struct timespec64 *tp)
 {
return posix_cpu_clock_getres(PROCESS_CLOCK, tp);
 }
@@ -1389,7 +1389,7 @@ static long process_cpu_nsleep_restart(struct 
restart_block *restart_block)
return -EINVAL;
 }
 static int thread_cpu_clock_getres(const clockid_t which_clock,
-  struct timespec *tp)
+  struct timespec64 *tp)
 {
return posix_cpu_clock_getres(THREAD_CLOCK, tp);
 }
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index ba0c472..a314a63 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -258,9 +258,9 @@ static int posix_get_monotonic_coarse(clockid_t which_clock,
return 0;
 }
 
-static int posix_get_coarse_res(const clockid_t which_clock, struct timespec 
*tp)
+static int posix_get_coarse_res(const clockid_t which_clock, struct timespec64 
*tp)
 {
-   *tp = ktime_to_timespec(KTIME_LOW_RES);
+   *tp = ktime_to_timespec64(KTIME_LOW_RES);
return 0;
 }
 
@@ -276,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct 
timespec64 *tp)
   

[PATCH 3/7] Change k_clock clock_get() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c |  4 ++--
 include/linux/posix-timers.h   |  2 +-
 include/linux/timekeeping.h|  5 +
 kernel/time/alarmtimer.c   |  4 ++--
 kernel/time/posix-clock.c  |  9 +++--
 kernel/time/posix-cpu-timers.c | 10 +-
 kernel/time/posix-stubs.c  |  9 ++---
 kernel/time/posix-timers.c | 32 +---
 8 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index b708c85..40d880b 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -478,13 +478,13 @@ static int sgi_clock_period;
 static struct timespec sgi_clock_offset;
 static int sgi_clock_period;
 
-static int sgi_clock_get(clockid_t clockid, struct timespec *tp)
+static int sgi_clock_get(clockid_t clockid, struct timespec64 *tp)
 {
u64 nsec;
 
nsec = rtc_time() * sgi_clock_period
+ sgi_clock_offset.tv_nsec;
-   *tp = ns_to_timespec(nsec);
+   *tp = ns_to_timespec64(nsec);
tp->tv_sec += sgi_clock_offset.tv_sec;
return 0;
 };
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 64aa189..db54f1b 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -90,7 +90,7 @@ struct k_clock {
int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
int (*clock_set) (const clockid_t which_clock,
  const struct timespec *tp);
-   int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
+   int (*clock_get) (const clockid_t which_clock, struct timespec64 * tp);
int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
int (*timer_create) (struct k_itimer *timer);
int (*nsleep) (const clockid_t which_clock, int flags,
diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
index 3617a78..ddc229f 100644
--- a/include/linux/timekeeping.h
+++ b/include/linux/timekeeping.h
@@ -258,6 +258,11 @@ static inline void timekeeping_clocktai(struct timespec 
*ts)
*ts = ktime_to_timespec(ktime_get_clocktai());
 }
 
+static inline void timekeeping_clocktai64(struct timespec64 *ts)
+{
+   *ts = ktime_to_timespec64(ktime_get_clocktai());
+}
+
 /*
  * RTC specific
  */
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index ce3a31e..944ca6e 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -558,14 +558,14 @@ static int alarm_clock_getres(const clockid_t 
which_clock, struct timespec *tp)
  *
  * Provides the underlying alarm base time.
  */
-static int alarm_clock_get(clockid_t which_clock, struct timespec *tp)
+static int alarm_clock_get(clockid_t which_clock, struct timespec64 *tp)
 {
struct alarm_base *base = _bases[clock2alarm(which_clock)];
 
if (!alarmtimer_get_rtcdev())
return -EINVAL;
 
-   *tp = ktime_to_timespec(base->gettime());
+   *tp = ktime_to_timespec64(base->gettime());
return 0;
 }
 
diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
index f2af1b5..0427c8c 100644
--- a/kernel/time/posix-clock.c
+++ b/kernel/time/posix-clock.c
@@ -297,20 +297,17 @@ static int pc_clock_adjtime(clockid_t id, struct timex 
*tx)
return err;
 }
 
-static int pc_clock_gettime(clockid_t id, struct timespec *ts)
+static int pc_clock_gettime(clockid_t id, struct timespec64 *ts)
 {
struct posix_clock_desc cd;
-   struct timespec64 ts64;
int err;
 
err = get_clock_desc(id, );
if (err)
return err;
 
-   if (cd.clk->ops.clock_gettime) {
-   err = cd.clk->ops.clock_gettime(cd.clk, );
-   *ts = timespec64_to_timespec(ts64);
-   }
+   if (cd.clk->ops.clock_gettime)
+   err = cd.clk->ops.clock_gettime(cd.clk, ts);
else
err = -EOPNOTSUPP;
 
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 4513ad1..6c509ea 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -261,7 +261,7 @@ static int cpu_clock_sample_group(const clockid_t 
which_clock,
 
 static int posix_cpu_clock_get_task(struct task_struct *tsk,
const clockid_t which_clock,
-   struct timespec *tp)
+   struct timespec64 *tp)
 {
int err = -EINVAL;
u64 rtn;
@@ -275,13 +275,13 @@ static int posix_cpu_clock_get_task(struct task_struct 
*tsk,
}
 
if (!err)
-   *tp = ns_to_timespec(rtn);
+   *tp = ns_to_timespec64(rtn);
 
return err;
 }
 
 
-static int 

[PATCH 6/7] Change k_clock timer_set() and timer_get() to use timespec64

2017-03-18 Thread Deepa Dinamani
struct timespec is not y2038 safe. The plan is to
get rid of all uses of timespec internally in the
kernel. Replace uses of timespec with timespec64.
The syscall interfaces themselves will be changed
in a separate series.

Signed-off-by: Deepa Dinamani 
---
 drivers/char/mmtimer.c | 20 ++--
 include/linux/posix-timers.h   |  6 +++---
 kernel/time/alarmtimer.c   | 14 +++---
 kernel/time/posix-clock.c  | 21 +++--
 kernel/time/posix-cpu-timers.c | 28 
 kernel/time/posix-timers.c | 33 +++--
 6 files changed, 62 insertions(+), 60 deletions(-)

diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index ba1b892..863a111 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -657,7 +657,7 @@ static int sgi_timer_del(struct k_itimer *timr)
 }
 
 /* Assumption: it_lock is already held with irq's disabled */
-static void sgi_timer_get(struct k_itimer *timr, struct itimerspec 
*cur_setting)
+static void sgi_timer_get(struct k_itimer *timr, struct itimerspec64 
*cur_setting)
 {
 
if (timr->it.mmtimer.clock == TIMER_OFF) {
@@ -668,14 +668,14 @@ static void sgi_timer_get(struct k_itimer *timr, struct 
itimerspec *cur_setting)
return;
}
 
-   cur_setting->it_interval = ns_to_timespec(timr->it.mmtimer.incr * 
sgi_clock_period);
-   cur_setting->it_value = ns_to_timespec((timr->it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
+   cur_setting->it_interval = ns_to_timespec64(timr->it.mmtimer.incr * 
sgi_clock_period);
+   cur_setting->it_value = ns_to_timespec64((timr->it.mmtimer.expires - 
rtc_time()) * sgi_clock_period);
 }
 
 
 static int sgi_timer_set(struct k_itimer *timr, int flags,
-   struct itimerspec * new_setting,
-   struct itimerspec * old_setting)
+   struct itimerspec64 * new_setting,
+   struct itimerspec64 * old_setting)
 {
unsigned long when, period, irqflags;
int err = 0;
@@ -687,8 +687,8 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
sgi_timer_get(timr, old_setting);
 
sgi_timer_del(timr);
-   when = timespec_to_ns(_setting->it_value);
-   period = timespec_to_ns(_setting->it_interval);
+   when = timespec64_to_ns(_setting->it_value);
+   period = timespec64_to_ns(_setting->it_interval);
 
if (when == 0)
/* Clear timer */
@@ -699,11 +699,11 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
return -ENOMEM;
 
if (flags & TIMER_ABSTIME) {
-   struct timespec n;
+   struct timespec64 n;
unsigned long now;
 
-   getnstimeofday();
-   now = timespec_to_ns();
+   getnstimeofday64();
+   now = timespec64_to_ns();
if (when > now)
when -= now;
else
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 249429c..f608941 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -97,12 +97,12 @@ struct k_clock {
   struct timespec *, struct timespec __user *);
long (*nsleep_restart) (struct restart_block *restart_block);
int (*timer_set) (struct k_itimer * timr, int flags,
- struct itimerspec * new_setting,
- struct itimerspec * old_setting);
+ struct itimerspec64 * new_setting,
+ struct itimerspec64 * old_setting);
int (*timer_del) (struct k_itimer * timr);
 #define TIMER_RETRY 1
void (*timer_get) (struct k_itimer * timr,
-  struct itimerspec * cur_setting);
+  struct itimerspec64 * cur_setting);
 };
 
 extern struct k_clock clock_posix_cpu;
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index e8a45e2..81db6df 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -598,19 +598,19 @@ static int alarm_timer_create(struct k_itimer *new_timer)
  * Copies out the current itimerspec data
  */
 static void alarm_timer_get(struct k_itimer *timr,
-   struct itimerspec *cur_setting)
+   struct itimerspec64 *cur_setting)
 {
ktime_t relative_expiry_time =
alarm_expires_remaining(&(timr->it.alarm.alarmtimer));
 
if (ktime_to_ns(relative_expiry_time) > 0) {
-   cur_setting->it_value = ktime_to_timespec(relative_expiry_time);
+   cur_setting->it_value = 
ktime_to_timespec64(relative_expiry_time);
} else {
cur_setting->it_value.tv_sec = 0;
cur_setting->it_value.tv_nsec = 0;
}
 
-   cur_setting->it_interval = ktime_to_timespec(timr->it.alarm.interval);
+   cur_setting->it_interval = 

[PATCH 0/7] Change k_clock interfaces to use timespec64

2017-03-18 Thread Deepa Dinamani
The series is aimed at replacing struct timespec which is not
y2038 safe with y2038 safe struct timespec64 for k_clock interfaces.

The series does not change the syscall interface.
This will be done in a follow up series.

A few existing checkpatch-noted style issues, such as the 80 line
character limit, have been left as-is to facilitate easier review.

Deepa Dinamani (7):
  time: Delete do_sys_setimeofday()
  time: Change posix clocks ops interfaces to use timespec64
  Change k_clock clock_get() to use timespec64
  Change k_clock clock_getres() to use timespec64
  Change k_clock clock_set() to use timespec64
  Change k_clock timer_set() and timer_get() to use timespec64
  Change k_clock nsleep() to use timespec64

 drivers/char/mmtimer.c | 28 ++---
 drivers/ptp/ptp_clock.c| 18 
 include/linux/hrtimer.h|  2 +-
 include/linux/posix-clock.h| 10 ++---
 include/linux/posix-timers.h   | 14 +++
 include/linux/timekeeping.h| 20 +++--
 kernel/compat.c| 10 +++--
 kernel/time/alarmtimer.c   | 24 +--
 kernel/time/hrtimer.c  | 10 +++--
 kernel/time/posix-clock.c  | 10 ++---
 kernel/time/posix-cpu-timers.c | 66 --
 kernel/time/posix-stubs.c  | 20 ++---
 kernel/time/posix-timers.c | 93 --
 kernel/time/time.c |  4 +-
 14 files changed, 172 insertions(+), 157 deletions(-)

-- 
2.7.4



Re: [PATCH 4/4] mfd: cpcap: Fix bad use of IRQ sense register

2017-03-18 Thread Sebastian Reichel
On Thu, Mar 16, 2017 at 05:36:33PM -0700, Tony Lindgren wrote:
> The cpcap INTS registers are for getting the value of the line,
> not for configuring the type.
> 
> Cc: Lee Jones 
> Cc: Marcel Partap 
> Cc: Michael Scott 
> Cc: Sebastian Reichel 

Reviewed-By: Sebastian Reichel 

> Signed-off-by: Tony Lindgrne 

https://lwn.net/Articles/717281/ ;)

-- Sebastian

> ---
>  drivers/mfd/motorola-cpcap.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c
> --- a/drivers/mfd/motorola-cpcap.c
> +++ b/drivers/mfd/motorola-cpcap.c
> @@ -115,7 +115,6 @@ static struct regmap_irq_chip 
> cpcap_irq_chip[CPCAP_NR_IRQ_CHIPS] = {
>   .status_base = CPCAP_REG_INT1,
>   .ack_base = CPCAP_REG_INT1,
>   .mask_base = CPCAP_REG_INTM1,
> - .type_base = CPCAP_REG_INTS1,
>   .use_ack = true,
>   .handle_reread = true,
>   .ack_invert = true,
> -- 
> 2.11.1


signature.asc
Description: PGP signature


Re: [PATCH 4/4] mfd: cpcap: Fix bad use of IRQ sense register

2017-03-18 Thread Sebastian Reichel
On Thu, Mar 16, 2017 at 05:36:33PM -0700, Tony Lindgren wrote:
> The cpcap INTS registers are for getting the value of the line,
> not for configuring the type.
> 
> Cc: Lee Jones 
> Cc: Marcel Partap 
> Cc: Michael Scott 
> Cc: Sebastian Reichel 

Reviewed-By: Sebastian Reichel 

> Signed-off-by: Tony Lindgrne 

https://lwn.net/Articles/717281/ ;)

-- Sebastian

> ---
>  drivers/mfd/motorola-cpcap.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c
> --- a/drivers/mfd/motorola-cpcap.c
> +++ b/drivers/mfd/motorola-cpcap.c
> @@ -115,7 +115,6 @@ static struct regmap_irq_chip 
> cpcap_irq_chip[CPCAP_NR_IRQ_CHIPS] = {
>   .status_base = CPCAP_REG_INT1,
>   .ack_base = CPCAP_REG_INT1,
>   .mask_base = CPCAP_REG_INTM1,
> - .type_base = CPCAP_REG_INTS1,
>   .use_ack = true,
>   .handle_reread = true,
>   .ack_invert = true,
> -- 
> 2.11.1


signature.asc
Description: PGP signature


Re: [sched/core] 8a8c69c327: WARNING: CPU: 0 PID: 8 at kernel/locking/lockdep.c:3548 lock_release

2017-03-18 Thread Wanpeng Li
2017-03-17 22:13 GMT+08:00 Peter Zijlstra :
> On Fri, Mar 17, 2017 at 03:09:09PM +0100, Peter Zijlstra wrote:
>> On Fri, Mar 17, 2017 at 09:24:11PM +0800, Wanpeng Li wrote:
>> > I have another version of patch which utilizes raw_spin_lock_irqsave()
>> > instead of rq_lock_irqsave() in __balance_callback() as before, which
>> > one do you like, Peterz?
>>
>> Hurm.. the raw_spin_lock_irqsave() one I suspect. No point in pinning
>> and then unpinning.
>
> Took your other version and edited that to make it do this.

Please refer to https://lkml.org/lkml/2017/3/17/704 :)

Regards,
Wanpeng Li


Re: [sched/core] 8a8c69c327: WARNING: CPU: 0 PID: 8 at kernel/locking/lockdep.c:3548 lock_release

2017-03-18 Thread Wanpeng Li
2017-03-17 22:13 GMT+08:00 Peter Zijlstra :
> On Fri, Mar 17, 2017 at 03:09:09PM +0100, Peter Zijlstra wrote:
>> On Fri, Mar 17, 2017 at 09:24:11PM +0800, Wanpeng Li wrote:
>> > I have another version of patch which utilizes raw_spin_lock_irqsave()
>> > instead of rq_lock_irqsave() in __balance_callback() as before, which
>> > one do you like, Peterz?
>>
>> Hurm.. the raw_spin_lock_irqsave() one I suspect. No point in pinning
>> and then unpinning.
>
> Took your other version and edited that to make it do this.

Please refer to https://lkml.org/lkml/2017/3/17/704 :)

Regards,
Wanpeng Li


[GIT PULL] target fixes for v4.11-rc3

2017-03-18 Thread Nicholas A. Bellinger
Hello Linus,

Here are the target-pending fixes for v4.11-rc3 code.  Please go ahead
and pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master

The bulk of the changes are in qla2xxx target driver code to address
various issues found during Cavium/QLogic's internal testing (stable
CC's included), along with a few other stability and smaller
miscellaneous improvements.

There are also a couple of different patch sets from Mike Christie,
which have been a result of his work to use target-core ALUA logic
together with tcm-user backend driver.

Finally, a patch to address some long standing issues with pass-through
SCSI export of TYPE_TAPE + TYPE_MEDIUM_CHANGER devices, which will make
folks using physical (or virtual) magnetic tape happy.

Thank you,

--nab

Anil Gurumurthy (1):
  qla2xxx: Export DIF stats via debugfs

Himanshu Madhani (2):
  qla2xxx: Add DebugFS node to display Port Database
  qla2xxx: Update driver version to 9.00.00.00-k

Joe Carnuccio (1):
  qla2xxx: Allow vref count to timeout on vport delete.

Max Lohrmann (1):
  target: Fix VERIFY_16 handling in sbc_parse_cdb

Mike Christie (10):
  tcmu: allow hw_max_sectors greater than 128
  tcmu: return on first Opt parse failure
  target: allow ALUA setup for some passthrough backends
  target: fail ALUA transitions for pscsi
  target: Use system workqueue for ALUA transitions
  target: fix ALUA transition timeout handling
  target: allow userspace to set state to transitioning
  target: fix race during implicit transition work flushes
  tcmu: add helper to check if dev was configured
  tcmu: make cmd timeout configurable

Nicholas Bellinger (3):
  target/pscsi: Fix TYPE_TAPE + TYPE_MEDIMUM_CHANGER export
  target: Drop pointless tfo->check_stop_free check
  tcmu: Convert cmd_time_out into backend device attribute

Quinn Tran (10):
  qla2xxx: Fix memory leak for abts processing
  qla2xxx: Fix request queue corruption.
  qla2xxx: Fix inadequate lock protection for ABTS.
  qla2xxx: Fix sess_lock & hardware_lock lock order problem.
  qla2xxx: Allow relogin to proceed if remote login did not finish
  qla2xxx: Improve T10-DIF/PI handling in driver.
  qla2xxx: Add async new target notification
  qla2xxx: Use IOCB interface to submit non-critical MBX.
  qla2xxx: Change scsi host lookup method.
  qla2xxx: Fix delayed response to command for loop mode/direct connect.

 drivers/scsi/qla2xxx/Kconfig   |   1 +
 drivers/scsi/qla2xxx/qla_attr.c|   4 +-
 drivers/scsi/qla2xxx/qla_dbg.h |   1 +
 drivers/scsi/qla2xxx/qla_def.h |  56 ++-
 drivers/scsi/qla2xxx/qla_dfs.c | 107 -
 drivers/scsi/qla2xxx/qla_gbl.h |  18 +-
 drivers/scsi/qla2xxx/qla_init.c|  85 ++--
 drivers/scsi/qla2xxx/qla_iocb.c|  13 +-
 drivers/scsi/qla2xxx/qla_isr.c |  41 +-
 drivers/scsi/qla2xxx/qla_mbx.c | 304 --
 drivers/scsi/qla2xxx/qla_mid.c |  14 +-
 drivers/scsi/qla2xxx/qla_os.c  |  23 +-
 drivers/scsi/qla2xxx/qla_target.c  | 748 +
 drivers/scsi/qla2xxx/qla_target.h  |  39 +-
 drivers/scsi/qla2xxx/qla_version.h |   6 +-
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |  49 ++-
 drivers/target/target_core_alua.c  |  82 ++--
 drivers/target/target_core_configfs.c  |   4 +
 drivers/target/target_core_pscsi.c |  50 +--
 drivers/target/target_core_sbc.c   |  10 +-
 drivers/target/target_core_tpg.c   |   3 +-
 drivers/target/target_core_transport.c |   3 +-
 drivers/target/target_core_user.c  | 152 +--
 include/target/target_core_backend.h   |   7 +-
 include/target/target_core_base.h  |   2 +-
 25 files changed, 1274 insertions(+), 548 deletions(-)



[GIT PULL] target fixes for v4.11-rc3

2017-03-18 Thread Nicholas A. Bellinger
Hello Linus,

Here are the target-pending fixes for v4.11-rc3 code.  Please go ahead
and pull from:

  git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master

The bulk of the changes are in qla2xxx target driver code to address
various issues found during Cavium/QLogic's internal testing (stable
CC's included), along with a few other stability and smaller
miscellaneous improvements.

There are also a couple of different patch sets from Mike Christie,
which have been a result of his work to use target-core ALUA logic
together with tcm-user backend driver.

Finally, a patch to address some long standing issues with pass-through
SCSI export of TYPE_TAPE + TYPE_MEDIUM_CHANGER devices, which will make
folks using physical (or virtual) magnetic tape happy.

Thank you,

--nab

Anil Gurumurthy (1):
  qla2xxx: Export DIF stats via debugfs

Himanshu Madhani (2):
  qla2xxx: Add DebugFS node to display Port Database
  qla2xxx: Update driver version to 9.00.00.00-k

Joe Carnuccio (1):
  qla2xxx: Allow vref count to timeout on vport delete.

Max Lohrmann (1):
  target: Fix VERIFY_16 handling in sbc_parse_cdb

Mike Christie (10):
  tcmu: allow hw_max_sectors greater than 128
  tcmu: return on first Opt parse failure
  target: allow ALUA setup for some passthrough backends
  target: fail ALUA transitions for pscsi
  target: Use system workqueue for ALUA transitions
  target: fix ALUA transition timeout handling
  target: allow userspace to set state to transitioning
  target: fix race during implicit transition work flushes
  tcmu: add helper to check if dev was configured
  tcmu: make cmd timeout configurable

Nicholas Bellinger (3):
  target/pscsi: Fix TYPE_TAPE + TYPE_MEDIMUM_CHANGER export
  target: Drop pointless tfo->check_stop_free check
  tcmu: Convert cmd_time_out into backend device attribute

Quinn Tran (10):
  qla2xxx: Fix memory leak for abts processing
  qla2xxx: Fix request queue corruption.
  qla2xxx: Fix inadequate lock protection for ABTS.
  qla2xxx: Fix sess_lock & hardware_lock lock order problem.
  qla2xxx: Allow relogin to proceed if remote login did not finish
  qla2xxx: Improve T10-DIF/PI handling in driver.
  qla2xxx: Add async new target notification
  qla2xxx: Use IOCB interface to submit non-critical MBX.
  qla2xxx: Change scsi host lookup method.
  qla2xxx: Fix delayed response to command for loop mode/direct connect.

 drivers/scsi/qla2xxx/Kconfig   |   1 +
 drivers/scsi/qla2xxx/qla_attr.c|   4 +-
 drivers/scsi/qla2xxx/qla_dbg.h |   1 +
 drivers/scsi/qla2xxx/qla_def.h |  56 ++-
 drivers/scsi/qla2xxx/qla_dfs.c | 107 -
 drivers/scsi/qla2xxx/qla_gbl.h |  18 +-
 drivers/scsi/qla2xxx/qla_init.c|  85 ++--
 drivers/scsi/qla2xxx/qla_iocb.c|  13 +-
 drivers/scsi/qla2xxx/qla_isr.c |  41 +-
 drivers/scsi/qla2xxx/qla_mbx.c | 304 --
 drivers/scsi/qla2xxx/qla_mid.c |  14 +-
 drivers/scsi/qla2xxx/qla_os.c  |  23 +-
 drivers/scsi/qla2xxx/qla_target.c  | 748 +
 drivers/scsi/qla2xxx/qla_target.h  |  39 +-
 drivers/scsi/qla2xxx/qla_version.h |   6 +-
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |  49 ++-
 drivers/target/target_core_alua.c  |  82 ++--
 drivers/target/target_core_configfs.c  |   4 +
 drivers/target/target_core_pscsi.c |  50 +--
 drivers/target/target_core_sbc.c   |  10 +-
 drivers/target/target_core_tpg.c   |   3 +-
 drivers/target/target_core_transport.c |   3 +-
 drivers/target/target_core_user.c  | 152 +--
 include/target/target_core_backend.h   |   7 +-
 include/target/target_core_base.h  |   2 +-
 25 files changed, 1274 insertions(+), 548 deletions(-)



[PATCH] drm/nouveau/mpeg: mthd returns true on success now

2017-03-18 Thread Ilia Mirkin
Signed-off-by: Ilia Mirkin 
Fixes: 590801c1a3 ("drm/nouveau/mpeg: remove dependence on namedb/engctx 
lookup")
Cc: sta...@vger.kernel.org # v4.3+
---

This is just a nice-to-have, as it only affects an error print afterwards.

 drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c | 2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c
index 003ac91..8a88952 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c
@@ -198,7 +198,7 @@ nv31_mpeg_intr(struct nvkm_engine *engine)
}
 
if (type == 0x0010) {
-   if (!nv31_mpeg_mthd(mpeg, mthd, data))
+   if (nv31_mpeg_mthd(mpeg, mthd, data))
show &= ~0x0100;
}
}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c
index e536f37..c3cf02e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c
@@ -172,7 +172,7 @@ nv44_mpeg_intr(struct nvkm_engine *engine)
}
 
if (type == 0x0010) {
-   if (!nv44_mpeg_mthd(subdev->device, mthd, data))
+   if (nv44_mpeg_mthd(subdev->device, mthd, data))
show &= ~0x0100;
}
}
-- 
2.10.2



[PATCH] drm/nouveau/mpeg: mthd returns true on success now

2017-03-18 Thread Ilia Mirkin
Signed-off-by: Ilia Mirkin 
Fixes: 590801c1a3 ("drm/nouveau/mpeg: remove dependence on namedb/engctx 
lookup")
Cc: sta...@vger.kernel.org # v4.3+
---

This is just a nice-to-have, as it only affects an error print afterwards.

 drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c | 2 +-
 drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c
index 003ac91..8a88952 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv31.c
@@ -198,7 +198,7 @@ nv31_mpeg_intr(struct nvkm_engine *engine)
}
 
if (type == 0x0010) {
-   if (!nv31_mpeg_mthd(mpeg, mthd, data))
+   if (nv31_mpeg_mthd(mpeg, mthd, data))
show &= ~0x0100;
}
}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c 
b/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c
index e536f37..c3cf02e 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/mpeg/nv44.c
@@ -172,7 +172,7 @@ nv44_mpeg_intr(struct nvkm_engine *engine)
}
 
if (type == 0x0010) {
-   if (!nv44_mpeg_mthd(subdev->device, mthd, data))
+   if (nv44_mpeg_mthd(subdev->device, mthd, data))
show &= ~0x0100;
}
}
-- 
2.10.2



Re: [PATCH 07/17] net: convert sock.sk_refcnt from atomic_t to refcount_t

2017-03-18 Thread David Miller
From: Herbert Xu 
Date: Sun, 19 Mar 2017 00:47:59 +0800

> Eric Dumazet  wrote:
>> On Fri, 2017-03-17 at 07:42 +, Reshetova, Elena wrote:
>> 
>>> Should we then first measure the actual numbers to understand what we
>>> are talking here about? 
>>> I would be glad to do it if you suggest what is the correct way to do
>>> measurements here to actually reflect the real life use cases. 
>> 
>> How have these patches been tested in real life exactly ?
>> 
>> Can you quantify number of added cycles per TCP packet, where I expect
>> we have maybe 20 atomic operations in all layers ...
> 
> I completely agree.  I think this thing needs to default to the
> existing atomic_t behaviour.

I totally agree as well, the refcount_t facility as-is is unacceptable
for networking.


Re: [PATCH 07/17] net: convert sock.sk_refcnt from atomic_t to refcount_t

2017-03-18 Thread David Miller
From: Herbert Xu 
Date: Sun, 19 Mar 2017 00:47:59 +0800

> Eric Dumazet  wrote:
>> On Fri, 2017-03-17 at 07:42 +, Reshetova, Elena wrote:
>> 
>>> Should we then first measure the actual numbers to understand what we
>>> are talking here about? 
>>> I would be glad to do it if you suggest what is the correct way to do
>>> measurements here to actually reflect the real life use cases. 
>> 
>> How have these patches been tested in real life exactly ?
>> 
>> Can you quantify number of added cycles per TCP packet, where I expect
>> we have maybe 20 atomic operations in all layers ...
> 
> I completely agree.  I think this thing needs to default to the
> existing atomic_t behaviour.

I totally agree as well, the refcount_t facility as-is is unacceptable
for networking.


[PATCH V1] mmc: core: fix still flush cache when eMMC cache off

2017-03-18 Thread Bean Huo (beanhuo)
This patch fixes the issue that mmc_blk_issue_rq still
flushes cache when eMMC cache has already been off
through user space tool, such as mmc-utils.
The reason is that card->ext_csd.cache_ctrl isn't reset.

Signed-off-by: beanhuo 
---
 drivers/mmc/core/block.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 1621fa0..fb3635ac 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -64,6 +64,7 @@ MODULE_ALIAS("mmc:block");
 #define MMC_BLK_TIMEOUT_MS  (10 * 60 * 1000)/* 10 minute timeout */
 #define MMC_SANITIZE_REQ_TIMEOUT 24
 #define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF) >> 16)
+#define MMC_EXTRACT_VALUE_FROM_ARG(x) ((x & 0xFF00) >> 8)
 
 #define mmc_req_rel_wr(req)((req->cmd_flags & REQ_FUA) && \
  (rq_data_dir(req) == WRITE))
@@ -535,6 +536,14 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, 
struct mmc_blk_data *md,
return data.error;
}
 
+   if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_CACHE_CTRL) &&
+   (cmd.opcode == MMC_SWITCH) && (card->ext_csd.cache_size > 0)) {
+   if (MMC_EXTRACT_VALUE_FROM_ARG(cmd.arg) & 1)
+   card->ext_csd.cache_ctrl = 1;
+   else
+   card->ext_csd.cache_ctrl = 0;
+   }
+
/*
 * According to the SD specs, some commands require a delay after
 * issuing the command.
-- 
2.7.4


[PATCH V1] mmc: core: fix still flush cache when eMMC cache off

2017-03-18 Thread Bean Huo (beanhuo)
This patch fixes the issue that mmc_blk_issue_rq still
flushes cache when eMMC cache has already been off
through user space tool, such as mmc-utils.
The reason is that card->ext_csd.cache_ctrl isn't reset.

Signed-off-by: beanhuo 
---
 drivers/mmc/core/block.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 1621fa0..fb3635ac 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -64,6 +64,7 @@ MODULE_ALIAS("mmc:block");
 #define MMC_BLK_TIMEOUT_MS  (10 * 60 * 1000)/* 10 minute timeout */
 #define MMC_SANITIZE_REQ_TIMEOUT 24
 #define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF) >> 16)
+#define MMC_EXTRACT_VALUE_FROM_ARG(x) ((x & 0xFF00) >> 8)
 
 #define mmc_req_rel_wr(req)((req->cmd_flags & REQ_FUA) && \
  (rq_data_dir(req) == WRITE))
@@ -535,6 +536,14 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, 
struct mmc_blk_data *md,
return data.error;
}
 
+   if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_CACHE_CTRL) &&
+   (cmd.opcode == MMC_SWITCH) && (card->ext_csd.cache_size > 0)) {
+   if (MMC_EXTRACT_VALUE_FROM_ARG(cmd.arg) & 1)
+   card->ext_csd.cache_ctrl = 1;
+   else
+   card->ext_csd.cache_ctrl = 0;
+   }
+
/*
 * According to the SD specs, some commands require a delay after
 * issuing the command.
-- 
2.7.4


[PATCH] Staging: rtl8192e - fixed style of block comments

2017-03-18 Thread Derek Robson
Fixed style of block comment across whole driver
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/rtl8192e/rtl8192e/r8190P_def.h |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c  |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h  |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h |  2 +-
 .../staging/rtl8192e/rtl8192e/r8192E_firmware.c|  2 +-
 .../staging/rtl8192e/rtl8192e/r8192E_firmware.h|  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_hw.h  |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_hwimg.h   |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h  |  4 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_cam.c|  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_cam.h|  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   | 30 ++---
 drivers/staging/rtl8192e/rtl8192e/rtl_core.h   |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c |  4 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.h |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.h |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_pm.c |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_pm.h |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.h |  2 +-
 drivers/staging/rtl8192e/rtl819x_BA.h  |  2 +-
 drivers/staging/rtl8192e/rtl819x_HT.h  |  2 +-
 drivers/staging/rtl8192e/rtl819x_Qos.h |  2 +-
 drivers/staging/rtl8192e/rtl819x_TS.h  |  2 +-
 drivers/staging/rtl8192e/rtllib.h  |  6 ++-
 drivers/staging/rtl8192e/rtllib_debug.h|  2 +-
 drivers/staging/rtl8192e/rtllib_module.c   | 52 +++---
 drivers/staging/rtl8192e/rtllib_wx.c   | 52 +++---
 34 files changed, 103 insertions(+), 101 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h 
b/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h
index 34453e38ba93..03421033d14a 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h
@@ -11,7 +11,7 @@
  *
  * Contact Information:
  * wlanfae 
-**/
+ */
 
 
 #ifndef R8190P_DEF_H
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c 
b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
index 81b3cf6588d4..85f93056d28b 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
@@ -11,7 +11,7 @@
  *
  * Contact Information:
  * wlanfae 
-**/
+ */
 
 #include "rtl_core.h"
 #include "r8192E_phyreg.h"
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h 
b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h
index 7873a73a2f76..bbea13b452b2 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h
@@ -11,7 +11,7 @@
  *
  * Contact Information:
  * wlanfae 
-**/
+ */
 
 #ifndef RTL8225H
 #define RTL8225H
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c
index 757ffd4f2f89..467287ae6c1c 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c
@@ -11,7 +11,7 @@
  *
  * Contact Information:
  * wlanfae 
-**/
+ */
 
 #include "rtl_core.h"
 #include "r8192E_hw.h"
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h
index 7dd15d993481..a8c63ad2ac2e 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h
@@ -11,7 +11,7 @@
  *
  * Contact Information:
  * wlanfae 
-**/
+ */
 

[PATCH] Staging: rtl8192e - fixed style of block comments

2017-03-18 Thread Derek Robson
Fixed style of block comment across whole driver
Found using checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/rtl8192e/rtl8192e/r8190P_def.h |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c  |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h  |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h |  2 +-
 .../staging/rtl8192e/rtl8192e/r8192E_firmware.c|  2 +-
 .../staging/rtl8192e/rtl8192e/r8192E_firmware.h|  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_hw.h  |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_hwimg.h   |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_phy.h |  2 +-
 drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h  |  4 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_cam.c|  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_cam.h|  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   | 30 ++---
 drivers/staging/rtl8192e/rtl8192e/rtl_core.h   |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.c |  4 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_dm.h |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.h |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_pm.c |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_pm.h |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c |  2 +-
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.h |  2 +-
 drivers/staging/rtl8192e/rtl819x_BA.h  |  2 +-
 drivers/staging/rtl8192e/rtl819x_HT.h  |  2 +-
 drivers/staging/rtl8192e/rtl819x_Qos.h |  2 +-
 drivers/staging/rtl8192e/rtl819x_TS.h  |  2 +-
 drivers/staging/rtl8192e/rtllib.h  |  6 ++-
 drivers/staging/rtl8192e/rtllib_debug.h|  2 +-
 drivers/staging/rtl8192e/rtllib_module.c   | 52 +++---
 drivers/staging/rtl8192e/rtllib_wx.c   | 52 +++---
 34 files changed, 103 insertions(+), 101 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h 
b/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h
index 34453e38ba93..03421033d14a 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_def.h
@@ -11,7 +11,7 @@
  *
  * Contact Information:
  * wlanfae 
-**/
+ */
 
 
 #ifndef R8190P_DEF_H
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c 
b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
index 81b3cf6588d4..85f93056d28b 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
@@ -11,7 +11,7 @@
  *
  * Contact Information:
  * wlanfae 
-**/
+ */
 
 #include "rtl_core.h"
 #include "r8192E_phyreg.h"
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h 
b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h
index 7873a73a2f76..bbea13b452b2 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.h
@@ -11,7 +11,7 @@
  *
  * Contact Information:
  * wlanfae 
-**/
+ */
 
 #ifndef RTL8225H
 #define RTL8225H
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c
index 757ffd4f2f89..467287ae6c1c 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c
@@ -11,7 +11,7 @@
  *
  * Contact Information:
  * wlanfae 
-**/
+ */
 
 #include "rtl_core.h"
 #include "r8192E_hw.h"
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h
index 7dd15d993481..a8c63ad2ac2e 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.h
@@ -11,7 +11,7 @@
  *
  * Contact Information:
  * wlanfae 
-**/
+ */
 #ifndef R819XUSB_CMDPKT_H
 #define R819XUSB_CMDPKT_H
 
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 

Re: [PATCH v5 00/39] i.MX Media Driver

2017-03-18 Thread Russell King - ARM Linux
On Sat, Mar 18, 2017 at 08:41:14PM -0400, Nicolas Dufresne wrote:
> Le samedi 18 mars 2017 à 20:43 +, Russell King - ARM Linux a
> écrit :
> > On Sat, Mar 18, 2017 at 12:58:27PM -0700, Steve Longerbeam wrote:
> > > Can you share your gstreamer pipeline? For now, until
> > > VIDIOC_ENUM_FRAMESIZES is implemented, try a pipeline that
> > > does not attempt to specify a frame rate. I use the attached
> > > script for testing, which works for me.
> > 
> > It's nothing more than
> > 
> >   gst-launch-1.0 -v v4l2src !  ! xvimagesink
> > 
> > in my case, the conversions are bayer2rgbneon.  However, this only
> > shows
> > you the frame rate negotiated on the pads (which is actually good
> > enough
> > to show the issue.)
> > 
> > How I stumbled across though this was when I was trying to encode:
> > 
> >  gst-launch-1.0 v4l2src device=/dev/video9 ! bayer2rgbneon ! \
> > videoconvert ! x264enc speed-preset=1 ! avimux ! \
> > filesink location=test.avi
> > 
> > I noticed that vlc would always say it was playing the resulting AVI
> > at 30fps.
> 
> In practice, I have the impression there is a fair reason why framerate
> enumeration isn't implemented (considering there is only 1 valid rate).

That's actually completely incorrect.

With the capture device interfacing directly with CSI, it's possible
_today_ to select:

* the CSI sink pad's resolution
* the CSI sink pad's resolution with the width and/or height halved
* the CSI sink pad's frame rate
* the CSI sink pad's frame rate divided by the frame drop factor

To put it another way, these are possible:

# v4l2-ctl -d /dev/video10 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index   : 0
Type: Video Capture
Pixel Format: 'RGGB'
Name: 8-bit Bayer RGRG/GBGB
Size: Discrete 816x616
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.048s (20.833 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.053s (18.750 fps)
Interval: Discrete 0.060s (16.667 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.080s (12.500 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.120s (8.333 fps)
Interval: Discrete 0.160s (6.250 fps)
Interval: Discrete 0.200s (5.000 fps)
Interval: Discrete 0.240s (4.167 fps)
Size: Discrete 408x616

Size: Discrete 816x308

Size: Discrete 408x308


These don't become possible as a result of implementing the enums,
they're all already requestable through /dev/video10.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


Re: [PATCH v5 00/39] i.MX Media Driver

2017-03-18 Thread Russell King - ARM Linux
On Sat, Mar 18, 2017 at 08:41:14PM -0400, Nicolas Dufresne wrote:
> Le samedi 18 mars 2017 à 20:43 +, Russell King - ARM Linux a
> écrit :
> > On Sat, Mar 18, 2017 at 12:58:27PM -0700, Steve Longerbeam wrote:
> > > Can you share your gstreamer pipeline? For now, until
> > > VIDIOC_ENUM_FRAMESIZES is implemented, try a pipeline that
> > > does not attempt to specify a frame rate. I use the attached
> > > script for testing, which works for me.
> > 
> > It's nothing more than
> > 
> >   gst-launch-1.0 -v v4l2src !  ! xvimagesink
> > 
> > in my case, the conversions are bayer2rgbneon.  However, this only
> > shows
> > you the frame rate negotiated on the pads (which is actually good
> > enough
> > to show the issue.)
> > 
> > How I stumbled across though this was when I was trying to encode:
> > 
> >  gst-launch-1.0 v4l2src device=/dev/video9 ! bayer2rgbneon ! \
> > videoconvert ! x264enc speed-preset=1 ! avimux ! \
> > filesink location=test.avi
> > 
> > I noticed that vlc would always say it was playing the resulting AVI
> > at 30fps.
> 
> In practice, I have the impression there is a fair reason why framerate
> enumeration isn't implemented (considering there is only 1 valid rate).

That's actually completely incorrect.

With the capture device interfacing directly with CSI, it's possible
_today_ to select:

* the CSI sink pad's resolution
* the CSI sink pad's resolution with the width and/or height halved
* the CSI sink pad's frame rate
* the CSI sink pad's frame rate divided by the frame drop factor

To put it another way, these are possible:

# v4l2-ctl -d /dev/video10 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index   : 0
Type: Video Capture
Pixel Format: 'RGGB'
Name: 8-bit Bayer RGRG/GBGB
Size: Discrete 816x616
Interval: Discrete 0.040s (25.000 fps)
Interval: Discrete 0.048s (20.833 fps)
Interval: Discrete 0.050s (20.000 fps)
Interval: Discrete 0.053s (18.750 fps)
Interval: Discrete 0.060s (16.667 fps)
Interval: Discrete 0.067s (15.000 fps)
Interval: Discrete 0.080s (12.500 fps)
Interval: Discrete 0.100s (10.000 fps)
Interval: Discrete 0.120s (8.333 fps)
Interval: Discrete 0.160s (6.250 fps)
Interval: Discrete 0.200s (5.000 fps)
Interval: Discrete 0.240s (4.167 fps)
Size: Discrete 408x616

Size: Discrete 816x308

Size: Discrete 408x308


These don't become possible as a result of implementing the enums,
they're all already requestable through /dev/video10.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


Re: [PATCH v5 00/39] i.MX Media Driver

2017-03-18 Thread Nicolas Dufresne
Le samedi 18 mars 2017 à 20:43 +, Russell King - ARM Linux a
écrit :
> On Sat, Mar 18, 2017 at 12:58:27PM -0700, Steve Longerbeam wrote:
> > Can you share your gstreamer pipeline? For now, until
> > VIDIOC_ENUM_FRAMESIZES is implemented, try a pipeline that
> > does not attempt to specify a frame rate. I use the attached
> > script for testing, which works for me.
> 
> It's nothing more than
> 
>   gst-launch-1.0 -v v4l2src !  ! xvimagesink
> 
> in my case, the conversions are bayer2rgbneon.  However, this only
> shows
> you the frame rate negotiated on the pads (which is actually good
> enough
> to show the issue.)
> 
> How I stumbled across though this was when I was trying to encode:
> 
>  gst-launch-1.0 v4l2src device=/dev/video9 ! bayer2rgbneon ! \
> videoconvert ! x264enc speed-preset=1 ! avimux ! \
> filesink location=test.avi
> 
> I noticed that vlc would always say it was playing the resulting AVI
> at 30fps.

In practice, I have the impression there is a fair reason why framerate
enumeration isn't implemented (considering there is only 1 valid rate).
Along with the norm fallback, GStreamer could could also consider the
currently set framerate as returned by VIDIOC_G_PARM. At the same time,
implementing that enumeration shall be straightforward, and will make a
large amount of existing userspace work.

regards,
Nicolas

signature.asc
Description: This is a digitally signed message part


Re: [PATCH v5 00/39] i.MX Media Driver

2017-03-18 Thread Nicolas Dufresne
Le samedi 18 mars 2017 à 20:43 +, Russell King - ARM Linux a
écrit :
> On Sat, Mar 18, 2017 at 12:58:27PM -0700, Steve Longerbeam wrote:
> > Can you share your gstreamer pipeline? For now, until
> > VIDIOC_ENUM_FRAMESIZES is implemented, try a pipeline that
> > does not attempt to specify a frame rate. I use the attached
> > script for testing, which works for me.
> 
> It's nothing more than
> 
>   gst-launch-1.0 -v v4l2src !  ! xvimagesink
> 
> in my case, the conversions are bayer2rgbneon.  However, this only
> shows
> you the frame rate negotiated on the pads (which is actually good
> enough
> to show the issue.)
> 
> How I stumbled across though this was when I was trying to encode:
> 
>  gst-launch-1.0 v4l2src device=/dev/video9 ! bayer2rgbneon ! \
> videoconvert ! x264enc speed-preset=1 ! avimux ! \
> filesink location=test.avi
> 
> I noticed that vlc would always say it was playing the resulting AVI
> at 30fps.

In practice, I have the impression there is a fair reason why framerate
enumeration isn't implemented (considering there is only 1 valid rate).
Along with the norm fallback, GStreamer could could also consider the
currently set framerate as returned by VIDIOC_G_PARM. At the same time,
implementing that enumeration shall be straightforward, and will make a
large amount of existing userspace work.

regards,
Nicolas

signature.asc
Description: This is a digitally signed message part


Re: Passionate Partner

2017-03-18 Thread Castano Giovanni
Dear Sir,
Did you recieved my mail? 
I have sent it twice without a response.

Castano Giovanni


Re: Passionate Partner

2017-03-18 Thread Castano Giovanni
Dear Sir,
Did you recieved my mail? 
I have sent it twice without a response.

Castano Giovanni


[PATCH] Staging: ks7010 - fixed style block comments

2017-03-18 Thread Derek Robson
Fixed style of all block comments across whole driver
Found by checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/ks7010/ks7010_sdio.c |  3 ++-
 drivers/staging/ks7010/ks_hostif.h   | 35 +-
 drivers/staging/ks7010/ks_wlan.h |  3 ++-
 drivers/staging/ks7010/ks_wlan_net.c | 41 +++-
 4 files changed, 55 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 6f9f746a3a61..1311e83b99d8 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -496,7 +496,8 @@ static void ks7010_rw_function(struct work_struct *work)
while (time_after(priv->last_wakeup + ((30 * HZ) / 1000), jiffies)) {
DPRINTK(4, "wait after WAKEUP\n");
 /* 
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,>ks_wlan_hw.rw_wq,
-   (priv->last_wakeup + ((30*HZ)/1000) - jiffies));*/
+ * (priv->last_wakeup + ((30*HZ)/1000) - jiffies));
+ */
dev_info(>ks_wlan_hw.sdio_card->func->dev,
 "wake: %lu %lu\n",
 priv->last_wakeup + (30 * HZ) / 1000,
diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index 30c49b699d62..c7636e829c40 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -360,8 +360,11 @@ struct hostif_ps_adhoc_set_request_t {
 #define CTS_MODE_TRUE  1
uint16_t channel;
struct rate_set16_t rate_set;
-   uint16_t capability;/* bit5:preamble bit6:pbcc pbcc not supported 
always 0 
-* bit10:ShortSlotTime bit13:DSSS-OFDM 
DSSS-OFDM not supported always 0 */
+   uint16_t capability;/* bit5:preamble
+* bit6:pbcc pbcc not supported always 0
+* bit10:ShortSlotTime
+* bit13:DSSS-OFDM DSSS-OFDM not supported 
always 0
+*/
uint16_t scan_type;
 } __packed;
 
@@ -376,8 +379,11 @@ struct hostif_infrastructure_set_request_t {
uint16_t cts_mode;
struct rate_set16_t rate_set;
struct ssid_t ssid;
-   uint16_t capability;/* bit5:preamble bit6:pbcc pbcc not supported 
always 0 
-* bit10:ShortSlotTime bit13:DSSS-OFDM 
DSSS-OFDM not supported always 0 */
+   uint16_t capability;/* bit5:preamble
+* bit6:pbcc pbcc not supported always 0
+* bit10:ShortSlotTime
+* bit13:DSSS-OFDM DSSS-OFDM not supported 
always 0
+*/
uint16_t beacon_lost_count;
uint16_t auth_type;
 #define AUTH_TYPE_OPEN_SYSTEM 0
@@ -392,8 +398,11 @@ struct hostif_infrastructure_set2_request_t {
uint16_t cts_mode;
struct rate_set16_t rate_set;
struct ssid_t ssid;
-   uint16_t capability;/* bit5:preamble bit6:pbcc pbcc not supported 
always 0 
-* bit10:ShortSlotTime bit13:DSSS-OFDM 
DSSS-OFDM not supported always 0 */
+   uint16_t capability;/* bit5:preamble
+* bit6:pbcc pbcc not supported always 0
+* bit10:ShortSlotTime
+* bit13:DSSS-OFDM DSSS-OFDM not supported 
always 0
+*/
uint16_t beacon_lost_count;
uint16_t auth_type;
 #define AUTH_TYPE_OPEN_SYSTEM 0
@@ -415,8 +424,11 @@ struct hostif_adhoc_set_request_t {
uint16_t channel;
struct rate_set16_t rate_set;
struct ssid_t ssid;
-   uint16_t capability;/* bit5:preamble bit6:pbcc pbcc not supported 
always 0 
-* bit10:ShortSlotTime bit13:DSSS-OFDM 
DSSS-OFDM not supported always 0 */
+   uint16_t capability;/* bit5:preamble
+* bit6:pbcc pbcc not supported always 0
+* bit10:ShortSlotTime
+* bit13:DSSS-OFDM DSSS-OFDM not supported 
always 0
+*/
uint16_t scan_type;
 } __packed;
 
@@ -427,8 +439,11 @@ struct hostif_adhoc_set2_request_t {
uint16_t reserved;
struct rate_set16_t rate_set;
struct ssid_t ssid;
-   uint16_t capability;/* bit5:preamble bit6:pbcc pbcc not supported 
always 0 
-* bit10:ShortSlotTime bit13:DSSS-OFDM 
DSSS-OFDM not supported always 0 */
+   uint16_t capability;/* bit5:preamble
+* bit6:pbcc pbcc not supported always 0
+* bit10:ShortSlotTime
+* bit13:DSSS-OFDM DSSS-OFDM not supported 
always 0
+*/
uint16_t 

[PATCH] Staging: ks7010 - fixed style block comments

2017-03-18 Thread Derek Robson
Fixed style of all block comments across whole driver
Found by checkpatch

Signed-off-by: Derek Robson 
---
 drivers/staging/ks7010/ks7010_sdio.c |  3 ++-
 drivers/staging/ks7010/ks_hostif.h   | 35 +-
 drivers/staging/ks7010/ks_wlan.h |  3 ++-
 drivers/staging/ks7010/ks_wlan_net.c | 41 +++-
 4 files changed, 55 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 6f9f746a3a61..1311e83b99d8 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -496,7 +496,8 @@ static void ks7010_rw_function(struct work_struct *work)
while (time_after(priv->last_wakeup + ((30 * HZ) / 1000), jiffies)) {
DPRINTK(4, "wait after WAKEUP\n");
 /* 
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,>ks_wlan_hw.rw_wq,
-   (priv->last_wakeup + ((30*HZ)/1000) - jiffies));*/
+ * (priv->last_wakeup + ((30*HZ)/1000) - jiffies));
+ */
dev_info(>ks_wlan_hw.sdio_card->func->dev,
 "wake: %lu %lu\n",
 priv->last_wakeup + (30 * HZ) / 1000,
diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index 30c49b699d62..c7636e829c40 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -360,8 +360,11 @@ struct hostif_ps_adhoc_set_request_t {
 #define CTS_MODE_TRUE  1
uint16_t channel;
struct rate_set16_t rate_set;
-   uint16_t capability;/* bit5:preamble bit6:pbcc pbcc not supported 
always 0 
-* bit10:ShortSlotTime bit13:DSSS-OFDM 
DSSS-OFDM not supported always 0 */
+   uint16_t capability;/* bit5:preamble
+* bit6:pbcc pbcc not supported always 0
+* bit10:ShortSlotTime
+* bit13:DSSS-OFDM DSSS-OFDM not supported 
always 0
+*/
uint16_t scan_type;
 } __packed;
 
@@ -376,8 +379,11 @@ struct hostif_infrastructure_set_request_t {
uint16_t cts_mode;
struct rate_set16_t rate_set;
struct ssid_t ssid;
-   uint16_t capability;/* bit5:preamble bit6:pbcc pbcc not supported 
always 0 
-* bit10:ShortSlotTime bit13:DSSS-OFDM 
DSSS-OFDM not supported always 0 */
+   uint16_t capability;/* bit5:preamble
+* bit6:pbcc pbcc not supported always 0
+* bit10:ShortSlotTime
+* bit13:DSSS-OFDM DSSS-OFDM not supported 
always 0
+*/
uint16_t beacon_lost_count;
uint16_t auth_type;
 #define AUTH_TYPE_OPEN_SYSTEM 0
@@ -392,8 +398,11 @@ struct hostif_infrastructure_set2_request_t {
uint16_t cts_mode;
struct rate_set16_t rate_set;
struct ssid_t ssid;
-   uint16_t capability;/* bit5:preamble bit6:pbcc pbcc not supported 
always 0 
-* bit10:ShortSlotTime bit13:DSSS-OFDM 
DSSS-OFDM not supported always 0 */
+   uint16_t capability;/* bit5:preamble
+* bit6:pbcc pbcc not supported always 0
+* bit10:ShortSlotTime
+* bit13:DSSS-OFDM DSSS-OFDM not supported 
always 0
+*/
uint16_t beacon_lost_count;
uint16_t auth_type;
 #define AUTH_TYPE_OPEN_SYSTEM 0
@@ -415,8 +424,11 @@ struct hostif_adhoc_set_request_t {
uint16_t channel;
struct rate_set16_t rate_set;
struct ssid_t ssid;
-   uint16_t capability;/* bit5:preamble bit6:pbcc pbcc not supported 
always 0 
-* bit10:ShortSlotTime bit13:DSSS-OFDM 
DSSS-OFDM not supported always 0 */
+   uint16_t capability;/* bit5:preamble
+* bit6:pbcc pbcc not supported always 0
+* bit10:ShortSlotTime
+* bit13:DSSS-OFDM DSSS-OFDM not supported 
always 0
+*/
uint16_t scan_type;
 } __packed;
 
@@ -427,8 +439,11 @@ struct hostif_adhoc_set2_request_t {
uint16_t reserved;
struct rate_set16_t rate_set;
struct ssid_t ssid;
-   uint16_t capability;/* bit5:preamble bit6:pbcc pbcc not supported 
always 0 
-* bit10:ShortSlotTime bit13:DSSS-OFDM 
DSSS-OFDM not supported always 0 */
+   uint16_t capability;/* bit5:preamble
+* bit6:pbcc pbcc not supported always 0
+* bit10:ShortSlotTime
+* bit13:DSSS-OFDM DSSS-OFDM not supported 
always 0
+*/
uint16_t scan_type;
struct 

[GIT PULL] Openrisc fixes for 4.11

2017-03-18 Thread Stafford Horne
Hi Linus

Please consider for pull,

OpenRISC fixes for build issues that were exposed by kbuild robots after
4.11 merge. All from allmodconfig builds. This includes:
 - bug handling 8 byte get_user calls
 - module build failure due to multile missing symbol exports

Also, FYI, there is a build warning due to statx syscall missing in
asm-generic/unistd.h.  I have patch for that waiting for ok from arm64 guys
who also use asm-generic:

  https://lkml.org/lkml/2017/3/13/657

I figure that will go in through another queue, if not, I can pick it up.

The following changes since commit 4495c08e84729385774601b5146d51d9e5849f81:

  Linux 4.11-rc2 (2017-03-12 14:47:08 -0700)

are available in the git repository at:

  https://github.com/openrisc/linux.git tags/openrisc-for-linus

for you to fetch changes up to 363dad58e4a0f72dce0bf12d361d617239a80317:

  openrisc: Export symbols needed by modules (2017-03-16 00:12:57 +0900)


OpenRISC fixes for 4.11


Stafford Horne (3):
  openrisc: xchg: fix `computed is not used` warning
  openrisc: fix issue handling 8 byte get_user calls
  openrisc: Export symbols needed by modules

 arch/openrisc/include/asm/cmpxchg.h | 8 ++--
 arch/openrisc/include/asm/uaccess.h | 2 +-
 arch/openrisc/kernel/or32_ksyms.c   | 4 
 arch/openrisc/kernel/process.c  | 1 +
 4 files changed, 12 insertions(+), 3 deletions(-)

-Stafford


[GIT PULL] Openrisc fixes for 4.11

2017-03-18 Thread Stafford Horne
Hi Linus

Please consider for pull,

OpenRISC fixes for build issues that were exposed by kbuild robots after
4.11 merge. All from allmodconfig builds. This includes:
 - bug handling 8 byte get_user calls
 - module build failure due to multile missing symbol exports

Also, FYI, there is a build warning due to statx syscall missing in
asm-generic/unistd.h.  I have patch for that waiting for ok from arm64 guys
who also use asm-generic:

  https://lkml.org/lkml/2017/3/13/657

I figure that will go in through another queue, if not, I can pick it up.

The following changes since commit 4495c08e84729385774601b5146d51d9e5849f81:

  Linux 4.11-rc2 (2017-03-12 14:47:08 -0700)

are available in the git repository at:

  https://github.com/openrisc/linux.git tags/openrisc-for-linus

for you to fetch changes up to 363dad58e4a0f72dce0bf12d361d617239a80317:

  openrisc: Export symbols needed by modules (2017-03-16 00:12:57 +0900)


OpenRISC fixes for 4.11


Stafford Horne (3):
  openrisc: xchg: fix `computed is not used` warning
  openrisc: fix issue handling 8 byte get_user calls
  openrisc: Export symbols needed by modules

 arch/openrisc/include/asm/cmpxchg.h | 8 ++--
 arch/openrisc/include/asm/uaccess.h | 2 +-
 arch/openrisc/kernel/or32_ksyms.c   | 4 
 arch/openrisc/kernel/process.c  | 1 +
 4 files changed, 12 insertions(+), 3 deletions(-)

-Stafford


[PATCH] perf report: enable sorting by srcline as key

2017-03-18 Thread Milian Wolff
Often it is interesting to know how costly a given source line is in
total. Previously, one had to build these sums manually based on all
addresses that pointed to the same source line. This patch introduces
srcline as a sort key, which will do the aggregation for us.

Paired with the recent addition of showing inline frames, this makes
perf report much more useful for many C++ work loads.

The following shows the new feature in action. First, let's show the
status quo output when we sort by address. The result contains many
hist entries that generate the same output:


$ perf report --stdio --inline -g address
# Children  Self  Command   Shared ObjectSymbol
#       ...  
.
#
99.89%35.34%  cpp-inlining  cpp-inlining [.] main
|
|--64.55%--main complex:655
|  
/home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
 (inline)
|  /usr/include/c++/6.3.1/complex:664 (inline)
|  |
|  |--60.31%--hypot +20
|  |  |
|  |  |--8.52%--__hypot_finite +273
|  |  |
|  |  |--7.32%--__hypot_finite +411
...
 --35.34%--_start +4194346
   __libc_start_main +241
   |
   |--6.65%--main random.tcc:3326
   |  
/home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
 (inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1809 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1818 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:185 
(inline)
   |
   |--2.70%--main random.tcc:3326
   |  
/home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
 (inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1809 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1818 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:185 
(inline)
   |
   |--1.69%--main random.tcc:3326
   |  
/home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
 (inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1809 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1818 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:185 
(inline)
...


With this patch and `-g srcline` we instead get the following output:


$ perf report --stdio --inline -g srcline
# Children  Self  Command   Shared ObjectSymbol
#       ...  
.
#
99.89%35.34%  cpp-inlining  cpp-inlining [.] main
|
|--64.55%--main complex:655
|  
/home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
 (inline)
|  /usr/include/c++/6.3.1/complex:664 (inline)
|  |
|  |--64.02%--hypot
|  |  |
|  |   --59.81%--__hypot_finite
|  |
|   --0.53%--cabs
|
 --35.34%--_start
   __libc_start_main
   |
   |--12.48%--main random.tcc:3326
   |  
/home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
 (inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1809 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1818 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:185 
(inline)
...


Signed-off-by: Milian Wolff 
---
 tools/perf/Documentation/perf-report.txt |  1 +
 tools/perf/ui/browsers/hists.c   |  3 +-
 tools/perf/ui/stdio/hist.c   |  3 +-
 tools/perf/util/annotate.c   |  3 +-
 tools/perf/util/callchain.c  | 52 +---
 tools/perf/util/callchain.h  |  3 +-
 tools/perf/util/map.c|  3 +-
 tools/perf/util/sort.c   | 16 ++
 tools/perf/util/srcline.c| 11 +--
 tools/perf/util/util.h   |  4 +--
 10 files changed, 78 insertions(+), 21 deletions(-)

diff --git a/tools/perf/Documentation/perf-report.txt 

[PATCH] perf report: enable sorting by srcline as key

2017-03-18 Thread Milian Wolff
Often it is interesting to know how costly a given source line is in
total. Previously, one had to build these sums manually based on all
addresses that pointed to the same source line. This patch introduces
srcline as a sort key, which will do the aggregation for us.

Paired with the recent addition of showing inline frames, this makes
perf report much more useful for many C++ work loads.

The following shows the new feature in action. First, let's show the
status quo output when we sort by address. The result contains many
hist entries that generate the same output:


$ perf report --stdio --inline -g address
# Children  Self  Command   Shared ObjectSymbol
#       ...  
.
#
99.89%35.34%  cpp-inlining  cpp-inlining [.] main
|
|--64.55%--main complex:655
|  
/home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
 (inline)
|  /usr/include/c++/6.3.1/complex:664 (inline)
|  |
|  |--60.31%--hypot +20
|  |  |
|  |  |--8.52%--__hypot_finite +273
|  |  |
|  |  |--7.32%--__hypot_finite +411
...
 --35.34%--_start +4194346
   __libc_start_main +241
   |
   |--6.65%--main random.tcc:3326
   |  
/home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
 (inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1809 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1818 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:185 
(inline)
   |
   |--2.70%--main random.tcc:3326
   |  
/home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
 (inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1809 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1818 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:185 
(inline)
   |
   |--1.69%--main random.tcc:3326
   |  
/home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
 (inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1809 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1818 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:185 
(inline)
...


With this patch and `-g srcline` we instead get the following output:


$ perf report --stdio --inline -g srcline
# Children  Self  Command   Shared ObjectSymbol
#       ...  
.
#
99.89%35.34%  cpp-inlining  cpp-inlining [.] main
|
|--64.55%--main complex:655
|  
/home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
 (inline)
|  /usr/include/c++/6.3.1/complex:664 (inline)
|  |
|  |--64.02%--hypot
|  |  |
|  |   --59.81%--__hypot_finite
|  |
|   --0.53%--cabs
|
 --35.34%--_start
   __libc_start_main
   |
   |--12.48%--main random.tcc:3326
   |  
/home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
 (inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1809 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:1818 
(inline)
   |  /usr/include/c++/6.3.1/bits/random.h:185 
(inline)
...


Signed-off-by: Milian Wolff 
---
 tools/perf/Documentation/perf-report.txt |  1 +
 tools/perf/ui/browsers/hists.c   |  3 +-
 tools/perf/ui/stdio/hist.c   |  3 +-
 tools/perf/util/annotate.c   |  3 +-
 tools/perf/util/callchain.c  | 52 +---
 tools/perf/util/callchain.h  |  3 +-
 tools/perf/util/map.c|  3 +-
 tools/perf/util/sort.c   | 16 ++
 tools/perf/util/srcline.c| 11 +--
 tools/perf/util/util.h   |  4 +--
 10 files changed, 78 insertions(+), 21 deletions(-)

diff --git a/tools/perf/Documentation/perf-report.txt 

Attention please;

2017-03-18 Thread Mrs Bazaira Zurmati


Attention please;

Please forgive my intrusion into your privacy, I am Mrs Bazira Zurmati, and I 
am a banker. It is true that we have not meet each other in person, but I 
strongly believe that no trust, no friendship in every business.
  I have the deceased customer’s abandoned fund, which I am his personal 
financial adviser before his accidental death, that is the major reason I am 
doing everything with carefulness in the bank here I, know much about the 
existence of this fund and the secrets surrounding this money, But before I 
disclose the full details to you, I will like to know your interest and 
willingness to assist me by reverting back to me with your 
Private Email ID………
Age………  
Private Phone no…….
For further confidential details about the said fund, you can get back to me 
with my private id(mrsbazaira.zurma...@gmail.com)

Thank You
Mrs Bazaira Zurmati


Attention please;

2017-03-18 Thread Mrs Bazaira Zurmati


Attention please;

Please forgive my intrusion into your privacy, I am Mrs Bazira Zurmati, and I 
am a banker. It is true that we have not meet each other in person, but I 
strongly believe that no trust, no friendship in every business.
  I have the deceased customer’s abandoned fund, which I am his personal 
financial adviser before his accidental death, that is the major reason I am 
doing everything with carefulness in the bank here I, know much about the 
existence of this fund and the secrets surrounding this money, But before I 
disclose the full details to you, I will like to know your interest and 
willingness to assist me by reverting back to me with your 
Private Email ID………
Age………  
Private Phone no…….
For further confidential details about the said fund, you can get back to me 
with my private id(mrsbazaira.zurma...@gmail.com)

Thank You
Mrs Bazaira Zurmati


[PATCH] staging: speakup: fixes braces {} used on all arms of this statement

2017-03-18 Thread Arushi Singhal
This patch fixes the checks reported by checkpatch.pl
for braces {} should be used on all arms of this statement.

Signed-off-by: Arushi Singhal 
---
 drivers/staging/speakup/main.c   | 35 +++-
 drivers/staging/speakup/speakup_decext.c |  6 +++---
 drivers/staging/speakup/speakup_decpc.c  |  6 +++---
 drivers/staging/speakup/speakup_dectlk.c |  6 +++---
 drivers/staging/speakup/varhandlers.c| 12 ++-
 5 files changed, 37 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index f8fccc8bf6b2..21e76b031449 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -409,8 +409,9 @@ static void say_attributes(struct vc_data *vc)
if (bg > 7) {
synth_printf(" %s ", spk_msg_get(MSG_ON_BLINKING));
bg -= 8;
-   } else
+   } else {
synth_printf(" %s ", spk_msg_get(MSG_ON));
+   }
synth_printf("%s\n", spk_msg_get(MSG_COLORS_START + bg));
 }
 
@@ -643,8 +644,9 @@ static void say_prev_word(struct vc_data *vc)
break;
spk_y--;
spk_x = vc->vc_cols - 1;
-   } else
+   } else {
spk_x--;
+   }
spk_pos -= 2;
ch = get_char(vc, (u_short *)spk_pos, );
if (ch == SPACE || ch == 0)
@@ -697,8 +699,9 @@ static void say_next_word(struct vc_data *vc)
spk_y++;
spk_x = 0;
edge_said = edge_right;
-   } else
+   } else {
spk_x++;
+   }
spk_pos += 2;
last_state = state;
}
@@ -729,8 +732,9 @@ static void spell_word(struct vc_data *vc)
spk_pitch_shift++;
else/* synth has no pitch */
last_cap = spk_str_caps_stop;
-   } else
+   } else {
str_cap = spk_str_caps_stop;
+   }
if (str_cap != last_cap) {
synth_printf("%s", str_cap);
last_cap = str_cap;
@@ -1343,8 +1347,9 @@ static int speakup_allocate(struct vc_data *vc)
if (!speakup_console[vc_num])
return -ENOMEM;
speakup_date(vc);
-   } else if (!spk_parked)
+   } else if (!spk_parked) {
speakup_date(vc);
+   }
 
return 0;
 }
@@ -1397,9 +1402,9 @@ static void read_all_doc(struct vc_data *vc)
prev_cursor_track = cursor_track;
cursor_track = read_all_mode;
spk_reset_index_count(0);
-   if (get_sentence_buf(vc, 0) == -1)
+   if (get_sentence_buf(vc, 0) == -1) {
kbd_fakekey2(vc, RA_DOWN_ARROW);
-   else {
+   } else {
say_sentence_num(0, 0);
synth_insert_next_index(0);
start_read_all_timer(vc, RA_TIMER);
@@ -1446,8 +1451,9 @@ static void handle_cursor_read_all(struct vc_data *vc, 
int command)
if (!say_sentence_num(sentcount + 1, 1)) {
sn = 1;
spk_reset_index_count(sn);
-   } else
+   } else {
synth_insert_next_index(0);
+   }
if (!say_sentence_num(sn, 0)) {
kbd_fakekey2(vc, RA_FIND_NEXT_SENT);
return;
@@ -1476,9 +1482,9 @@ static void handle_cursor_read_all(struct vc_data *vc, 
int command)
rv = get_sentence_buf(vc, 0);
if (rv == -1)
read_all_doc(vc);
-   if (rv == 0)
+   if (rv == 0) {
kbd_fakekey2(vc, RA_FIND_NEXT_SENT);
-   else {
+   } else {
say_sentence_num(1, 0);
synth_insert_next_index(0);
start_read_all_timer(vc, RA_TIMER);
@@ -2177,10 +2183,11 @@ speakup_key(struct vc_data *vc, int shift_state, int 
keycode, u_short keysym,
if (type == KT_SPEC && value == 1) {
value = '\n';
type = KT_LATIN;
-   } else if (type == KT_LETTER)
+   } else if (type == KT_LETTER) {
type = KT_LATIN;
-   else if (value == 0x7f)
+   } else if (value == 0x7f) {
value = 8;  /* make del = backspace */
+   }
ret = (*spk_special_handler) (vc, type, value, keycode);
spk_close_press = 0;
if (ret < 0)
@@ -2274,9 +2281,9 @@ static int 

[PATCH] staging: speakup: fixes braces {} used on all arms of this statement

2017-03-18 Thread Arushi Singhal
This patch fixes the checks reported by checkpatch.pl
for braces {} should be used on all arms of this statement.

Signed-off-by: Arushi Singhal 
---
 drivers/staging/speakup/main.c   | 35 +++-
 drivers/staging/speakup/speakup_decext.c |  6 +++---
 drivers/staging/speakup/speakup_decpc.c  |  6 +++---
 drivers/staging/speakup/speakup_dectlk.c |  6 +++---
 drivers/staging/speakup/varhandlers.c| 12 ++-
 5 files changed, 37 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index f8fccc8bf6b2..21e76b031449 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -409,8 +409,9 @@ static void say_attributes(struct vc_data *vc)
if (bg > 7) {
synth_printf(" %s ", spk_msg_get(MSG_ON_BLINKING));
bg -= 8;
-   } else
+   } else {
synth_printf(" %s ", spk_msg_get(MSG_ON));
+   }
synth_printf("%s\n", spk_msg_get(MSG_COLORS_START + bg));
 }
 
@@ -643,8 +644,9 @@ static void say_prev_word(struct vc_data *vc)
break;
spk_y--;
spk_x = vc->vc_cols - 1;
-   } else
+   } else {
spk_x--;
+   }
spk_pos -= 2;
ch = get_char(vc, (u_short *)spk_pos, );
if (ch == SPACE || ch == 0)
@@ -697,8 +699,9 @@ static void say_next_word(struct vc_data *vc)
spk_y++;
spk_x = 0;
edge_said = edge_right;
-   } else
+   } else {
spk_x++;
+   }
spk_pos += 2;
last_state = state;
}
@@ -729,8 +732,9 @@ static void spell_word(struct vc_data *vc)
spk_pitch_shift++;
else/* synth has no pitch */
last_cap = spk_str_caps_stop;
-   } else
+   } else {
str_cap = spk_str_caps_stop;
+   }
if (str_cap != last_cap) {
synth_printf("%s", str_cap);
last_cap = str_cap;
@@ -1343,8 +1347,9 @@ static int speakup_allocate(struct vc_data *vc)
if (!speakup_console[vc_num])
return -ENOMEM;
speakup_date(vc);
-   } else if (!spk_parked)
+   } else if (!spk_parked) {
speakup_date(vc);
+   }
 
return 0;
 }
@@ -1397,9 +1402,9 @@ static void read_all_doc(struct vc_data *vc)
prev_cursor_track = cursor_track;
cursor_track = read_all_mode;
spk_reset_index_count(0);
-   if (get_sentence_buf(vc, 0) == -1)
+   if (get_sentence_buf(vc, 0) == -1) {
kbd_fakekey2(vc, RA_DOWN_ARROW);
-   else {
+   } else {
say_sentence_num(0, 0);
synth_insert_next_index(0);
start_read_all_timer(vc, RA_TIMER);
@@ -1446,8 +1451,9 @@ static void handle_cursor_read_all(struct vc_data *vc, 
int command)
if (!say_sentence_num(sentcount + 1, 1)) {
sn = 1;
spk_reset_index_count(sn);
-   } else
+   } else {
synth_insert_next_index(0);
+   }
if (!say_sentence_num(sn, 0)) {
kbd_fakekey2(vc, RA_FIND_NEXT_SENT);
return;
@@ -1476,9 +1482,9 @@ static void handle_cursor_read_all(struct vc_data *vc, 
int command)
rv = get_sentence_buf(vc, 0);
if (rv == -1)
read_all_doc(vc);
-   if (rv == 0)
+   if (rv == 0) {
kbd_fakekey2(vc, RA_FIND_NEXT_SENT);
-   else {
+   } else {
say_sentence_num(1, 0);
synth_insert_next_index(0);
start_read_all_timer(vc, RA_TIMER);
@@ -2177,10 +2183,11 @@ speakup_key(struct vc_data *vc, int shift_state, int 
keycode, u_short keysym,
if (type == KT_SPEC && value == 1) {
value = '\n';
type = KT_LATIN;
-   } else if (type == KT_LETTER)
+   } else if (type == KT_LETTER) {
type = KT_LATIN;
-   else if (value == 0x7f)
+   } else if (value == 0x7f) {
value = 8;  /* make del = backspace */
+   }
ret = (*spk_special_handler) (vc, type, value, keycode);
spk_close_press = 0;
if (ret < 0)
@@ -2274,9 +2281,9 @@ static int vt_notifier_call(struct notifier_block *nb,
  

[tip:WIP.x86/boot 35/62] WARNING: vmlinux.o(.text.unlikely+0x2f69): Section mismatch in reference from the function can_free_region() to the function .init.text:e820__mapped_all()

2017-03-18 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git WIP.x86/boot
head:   687d77a5f7b2aae4ea0507888648823f7c24e974
commit: 3bce64f019a801f526cc38523c77ffda4e846155 [35/62] x86/boot/e820: Rename 
e820_any_mapped()/e820_all_mapped() to e820__mapped_any()/e820__mapped_all()
config: x86_64-randconfig-in0-03190222 (attached as .config)
compiler: gcc-4.6 (Debian 4.6.4-7) 4.6.4
reproduce:
git checkout 3bce64f019a801f526cc38523c77ffda4e846155
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

>> WARNING: vmlinux.o(.text.unlikely+0x2f69): Section mismatch in reference 
>> from the function can_free_region() to the function 
>> .init.text:e820__mapped_all()
   The function can_free_region() references
   the function __init e820__mapped_all().
   This is often because can_free_region lacks a __init
   annotation or the annotation of e820__mapped_all is wrong.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[tip:WIP.x86/boot 35/62] WARNING: vmlinux.o(.text.unlikely+0x2f69): Section mismatch in reference from the function can_free_region() to the function .init.text:e820__mapped_all()

2017-03-18 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git WIP.x86/boot
head:   687d77a5f7b2aae4ea0507888648823f7c24e974
commit: 3bce64f019a801f526cc38523c77ffda4e846155 [35/62] x86/boot/e820: Rename 
e820_any_mapped()/e820_all_mapped() to e820__mapped_any()/e820__mapped_all()
config: x86_64-randconfig-in0-03190222 (attached as .config)
compiler: gcc-4.6 (Debian 4.6.4-7) 4.6.4
reproduce:
git checkout 3bce64f019a801f526cc38523c77ffda4e846155
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

>> WARNING: vmlinux.o(.text.unlikely+0x2f69): Section mismatch in reference 
>> from the function can_free_region() to the function 
>> .init.text:e820__mapped_all()
   The function can_free_region() references
   the function __init e820__mapped_all().
   This is often because can_free_region lacks a __init
   annotation or the annotation of e820__mapped_all is wrong.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH 0/6 v3] [GIT PULL] ftrace/x86: Ftrace cleanup and add support for -mfentry on x86_32

2017-03-18 Thread Steven Rostedt

[
 Ingo, Thomas or Peter,

 I believe this is all set to go now. I updated those patches that Linus
 commented on and I don't believe there are any more issues. I ran this
 through several tests (although some of my tests are failing due to
 bugs introduced by others in 4.11-rc2). You can take this as a patch
 series, or you can pull from my tree defined below. It's based on 4.11-rc2
 as I noticed that tip/x86/core is rather outdated, and Linus is fine with
 basing off of his tagged releases.
]

With the issues of gcc screwing around with the mcount stack frame causing
function graph tracer to panic on x86_32, and with Linus saying that we
should start deprecating mcount (at least on x86), I figured that x86_32
needs to support fentry.

First, I renamed mcount_64.S to ftrace_64.S. As we want to get away from
mcount, having the ftrace code in a file called mcount seems rather backwards.

Next I moved the ftrace code out of entry_32.S. It's not in entry_64.S
and it does not belong in entry_32.S.

I noticed that the x86_32 code has the same issue as the x86_64 did
in the past with respect to a stack frame. I fixed that just for the main
ftrace_caller. The ftrace_regs_caller is rather special, and so is
function graph tracing.

I realized the ftrace_regs_caller code was complex due to me aggressively
saving flags, even though I could still do push, lea and mov without
changing them. That made the logic a little nicer.

Finally I added the fentry code.

I tested this with an older compiler (for mcount) with and without
FRAME_POINTER set. I also did it with a new compiler (with fentry), with and
without FRAME_POINTER. I tested function tracing, stack tracing, function_graph
tracing, and kprobes (as that uses the ftrace_regs_caller).

Please pull (or take the patch series) from:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
tip/x86/ftrace

Head SHA1: 7506fa66bcd267c587b43d39f9fc9acb48925b5a


Steven Rostedt (VMware) (6):
  ftrace/x86_64: Rename mcount_64.S to ftrace_64.S
  ftrace/x86_32: Move the ftrace specific code out of entry_32.S
  ftrace/x86_32: Add stack frame pointer to ftrace_caller
  ftrace/x86_32: Clean up ftrace_regs_caller
  ftrace/x86_32: Add -mfentry support to x86_32 with DYNAMIC_FTRACE set
  ftrace/x86: Use Makefile logic instead of #ifdef of compling ftrace_*.o


Changes from v2:

 * removed accidental committing of asm goto code from someone else

 * Better code for ftrace_regs_caller (Linus Torvalds)

 * Added patch to only compile ftrace_*.o if FUNCTION_TRACER is defined
(Josh Poimboeuf)

 * Fixed comment whitespace issue (Peter Zijlstra)


 arch/x86/Kconfig |   2 +-
 arch/x86/entry/entry_32.S| 169 --
 arch/x86/kernel/Makefile |   5 +-
 arch/x86/kernel/ftrace_32.S  | 246 +++
 arch/x86/kernel/{mcount_64.S => ftrace_64.S} |   4 -
 5 files changed, 250 insertions(+), 176 deletions(-)
 create mode 100644 arch/x86/kernel/ftrace_32.S
 rename arch/x86/kernel/{mcount_64.S => ftrace_64.S} (99%)

Diff against v2:

diff --git a/Makefile b/Makefile
index 7df3247..b841fb3 100644
--- a/Makefile
+++ b/Makefile
@@ -653,12 +653,6 @@ KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
 # Tell gcc to never replace conditional load with a non-conditional one
 KBUILD_CFLAGS  += $(call cc-option,--param=allow-store-data-races=0)
 
-# check for 'asm goto'
-ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) 
$(KBUILD_CFLAGS)), y)
-   KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
-   KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
-endif
-
 include scripts/Makefile.gcc-plugins
 
 ifdef CONFIG_READABLE_ASM
@@ -804,6 +798,12 @@ KBUILD_CFLAGS   += $(call 
cc-option,-Werror=incompatible-pointer-types)
 # use the deterministic mode of AR if available
 KBUILD_ARFLAGS := $(call ar-option,D)
 
+# check for 'asm goto'
+ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) 
$(KBUILD_CFLAGS)), y)
+   KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
+   KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
+endif
+
 include scripts/Makefile.kasan
 include scripts/Makefile.extrawarn
 include scripts/Makefile.ubsan
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index c576352..169b3b0 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -35,7 +35,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 55e8902..4b99423 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -46,8 +46,7 @@ obj-$(CONFIG_MODIFY_LDT_SYSCALL)  += ldt.o
 obj-y  += setup.o x86_init.o i8259.o irqinit.o jump_label.o
 obj-$(CONFIG_IRQ_WORK)  += irq_work.o
 obj-y  += probe_roms.o
-obj-$(CONFIG_X86_64)   += sys_x86_64.o ftrace_64.o
-obj-$(CONFIG_X86_32)   += ftrace_32.o
+obj-$(CONFIG_X86_64)   += 

[PATCH 5/6 v3] ftrace/x86_32: Add -mfentry support to x86_32 with DYNAMIC_FTRACE set

2017-03-18 Thread Steven Rostedt
From: "Steven Rostedt (VMware)" 

x86_64 has had fentry support for some time. I did not add support to x86_32
as I was unsure if it will be used much in the future. It is still very much
used, and there's issues with function graph tracing with gcc playing around
with the mcount frames, causing function graph to panic. The fentry code
does not have this issue, and is able to cope as there is no frame to mess
up.

Note, this only add support for fentry when DYNAMIC_FTRACE is set. There's
really no reason to not have that set, because the performance of the
machine drops significantly when it's not enabled. I only keep
!DYNAMIC_FTRACE around to test it off, as there's still some archs that have
FTRACE but not DYNAMIC_FTRACE.

Reviewed-by: Masami Hiramatsu 
Signed-off-by: Steven Rostedt (VMware) 
---
 arch/x86/Kconfig|  2 +-
 arch/x86/kernel/ftrace_32.S | 82 +++--
 2 files changed, 73 insertions(+), 11 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index cc98d5a294ee..8c17146427ca 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -127,7 +127,7 @@ config X86
select HAVE_EBPF_JITif X86_64
select HAVE_EFFICIENT_UNALIGNED_ACCESS
select HAVE_EXIT_THREAD
-   select HAVE_FENTRY  if X86_64
+   select HAVE_FENTRY  if X86_64 || DYNAMIC_FTRACE
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
diff --git a/arch/x86/kernel/ftrace_32.S b/arch/x86/kernel/ftrace_32.S
index 7cd27cf56578..fe64fa596266 100644
--- a/arch/x86/kernel/ftrace_32.S
+++ b/arch/x86/kernel/ftrace_32.S
@@ -11,26 +11,68 @@
 #include 
 
 #ifdef CONFIG_FUNCTION_TRACER
+
+#ifdef CC_USING_FENTRY
+# define function_hook __fentry__
+EXPORT_SYMBOL(__fentry__)
+#else
+# define function_hook mcount
+EXPORT_SYMBOL(mcount)
+#endif
+
 #ifdef CONFIG_DYNAMIC_FTRACE
 
-ENTRY(mcount)
+/* mcount uses a frame pointer even if CONFIG_FRAME_POINTER is not set */
+#if !defined(CC_USING_FENTRY) || defined(CONFIG_FRAME_POINTER)
+# define USING_FRAME_POINTER
+#endif
+
+#ifdef USING_FRAME_POINTER
+# define MCOUNT_FRAME  1   /* using frame = true  */
+#else
+# define MCOUNT_FRAME  0   /* using frame = false */
+#endif
+
+ENTRY(function_hook)
ret
-END(mcount)
+END(function_hook)
 
 ENTRY(ftrace_caller)
 
+#ifdef USING_FRAME_POINTER
+# ifdef CC_USING_FENTRY
+   /*
+* Frame pointers are of ip followed by bp.
+* Since fentry is an immediate jump, we are left with
+* parent-ip, function-ip. We need to add a frame with
+* parent-ip followed by ebp.
+*/
+   pushl   4(%esp) /* parent ip */
pushl   %ebp
movl%esp, %ebp
-
+   pushl   2*4(%esp)   /* function ip */
+# endif
+   /* For mcount, the function ip is directly above */
+   pushl   %ebp
+   movl%esp, %ebp
+#endif
pushl   %eax
pushl   %ecx
pushl   %edx
pushl   $0  /* Pass NULL as regs pointer */
-   movl5*4(%esp), %eax
-   /* Copy original ebp into %edx */
+
+#ifdef USING_FRAME_POINTER
+   /* Load parent ebp into edx */
movl4*4(%esp), %edx
+#else
+   /* There's no frame pointer, load the appropriate stack addr instead */
+   lea 4*4(%esp), %edx
+#endif
+
+   movl(MCOUNT_FRAME+4)*4(%esp), %eax  /* load the rip */
/* Get the parent ip */
-   movl0x4(%edx), %edx
+   movl4(%edx), %edx   /* edx has ebp */
+
movlfunction_trace_op, %ecx
subl$MCOUNT_INSN_SIZE, %eax
 
@@ -42,7 +84,14 @@ ftrace_call:
popl%edx
popl%ecx
popl%eax
+#ifdef USING_FRAME_POINTER
popl%ebp
+# ifdef CC_USING_FENTRY
+   addl$4,%esp /* skip function ip */
+   popl%ebp/* this is the orig bp */
+   addl$4, %esp/* skip parent ip */
+# endif
+#endif
 .Lftrace_ret:
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 .globl ftrace_graph_call
@@ -83,6 +132,10 @@ ENTRY(ftrace_regs_caller)
pushl   %edx
pushl   %ecx
pushl   %ebx
+#ifdef CC_USING_FENTRY
+   /* Load 4 off of the parent ip addr into ebp */
+   lea 14*4(%esp), %ebp
+#endif
 
movl12*4(%esp), %eax/* Load ip (1st parameter) */
subl$MCOUNT_INSN_SIZE, %eax /* Adjust ip */
@@ -121,7 +174,7 @@ GLOBAL(ftrace_regs_call)
jmp .Lftrace_ret
 #else /* ! CONFIG_DYNAMIC_FTRACE */
 
-ENTRY(mcount)
+ENTRY(function_hook)
cmpl$__PAGE_OFFSET, %esp
jb  ftrace_stub /* Paging not enabled yet? */
 
@@ -153,9 +206,8 @@ ftrace_stub:

[PATCH 0/6 v3] [GIT PULL] ftrace/x86: Ftrace cleanup and add support for -mfentry on x86_32

2017-03-18 Thread Steven Rostedt

[
 Ingo, Thomas or Peter,

 I believe this is all set to go now. I updated those patches that Linus
 commented on and I don't believe there are any more issues. I ran this
 through several tests (although some of my tests are failing due to
 bugs introduced by others in 4.11-rc2). You can take this as a patch
 series, or you can pull from my tree defined below. It's based on 4.11-rc2
 as I noticed that tip/x86/core is rather outdated, and Linus is fine with
 basing off of his tagged releases.
]

With the issues of gcc screwing around with the mcount stack frame causing
function graph tracer to panic on x86_32, and with Linus saying that we
should start deprecating mcount (at least on x86), I figured that x86_32
needs to support fentry.

First, I renamed mcount_64.S to ftrace_64.S. As we want to get away from
mcount, having the ftrace code in a file called mcount seems rather backwards.

Next I moved the ftrace code out of entry_32.S. It's not in entry_64.S
and it does not belong in entry_32.S.

I noticed that the x86_32 code has the same issue as the x86_64 did
in the past with respect to a stack frame. I fixed that just for the main
ftrace_caller. The ftrace_regs_caller is rather special, and so is
function graph tracing.

I realized the ftrace_regs_caller code was complex due to me aggressively
saving flags, even though I could still do push, lea and mov without
changing them. That made the logic a little nicer.

Finally I added the fentry code.

I tested this with an older compiler (for mcount) with and without
FRAME_POINTER set. I also did it with a new compiler (with fentry), with and
without FRAME_POINTER. I tested function tracing, stack tracing, function_graph
tracing, and kprobes (as that uses the ftrace_regs_caller).

Please pull (or take the patch series) from:

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
tip/x86/ftrace

Head SHA1: 7506fa66bcd267c587b43d39f9fc9acb48925b5a


Steven Rostedt (VMware) (6):
  ftrace/x86_64: Rename mcount_64.S to ftrace_64.S
  ftrace/x86_32: Move the ftrace specific code out of entry_32.S
  ftrace/x86_32: Add stack frame pointer to ftrace_caller
  ftrace/x86_32: Clean up ftrace_regs_caller
  ftrace/x86_32: Add -mfentry support to x86_32 with DYNAMIC_FTRACE set
  ftrace/x86: Use Makefile logic instead of #ifdef of compling ftrace_*.o


Changes from v2:

 * removed accidental committing of asm goto code from someone else

 * Better code for ftrace_regs_caller (Linus Torvalds)

 * Added patch to only compile ftrace_*.o if FUNCTION_TRACER is defined
(Josh Poimboeuf)

 * Fixed comment whitespace issue (Peter Zijlstra)


 arch/x86/Kconfig |   2 +-
 arch/x86/entry/entry_32.S| 169 --
 arch/x86/kernel/Makefile |   5 +-
 arch/x86/kernel/ftrace_32.S  | 246 +++
 arch/x86/kernel/{mcount_64.S => ftrace_64.S} |   4 -
 5 files changed, 250 insertions(+), 176 deletions(-)
 create mode 100644 arch/x86/kernel/ftrace_32.S
 rename arch/x86/kernel/{mcount_64.S => ftrace_64.S} (99%)

Diff against v2:

diff --git a/Makefile b/Makefile
index 7df3247..b841fb3 100644
--- a/Makefile
+++ b/Makefile
@@ -653,12 +653,6 @@ KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
 # Tell gcc to never replace conditional load with a non-conditional one
 KBUILD_CFLAGS  += $(call cc-option,--param=allow-store-data-races=0)
 
-# check for 'asm goto'
-ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) 
$(KBUILD_CFLAGS)), y)
-   KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
-   KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
-endif
-
 include scripts/Makefile.gcc-plugins
 
 ifdef CONFIG_READABLE_ASM
@@ -804,6 +798,12 @@ KBUILD_CFLAGS   += $(call 
cc-option,-Werror=incompatible-pointer-types)
 # use the deterministic mode of AR if available
 KBUILD_ARFLAGS := $(call ar-option,D)
 
+# check for 'asm goto'
+ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) 
$(KBUILD_CFLAGS)), y)
+   KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
+   KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
+endif
+
 include scripts/Makefile.kasan
 include scripts/Makefile.extrawarn
 include scripts/Makefile.ubsan
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index c576352..169b3b0 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -35,7 +35,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 55e8902..4b99423 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -46,8 +46,7 @@ obj-$(CONFIG_MODIFY_LDT_SYSCALL)  += ldt.o
 obj-y  += setup.o x86_init.o i8259.o irqinit.o jump_label.o
 obj-$(CONFIG_IRQ_WORK)  += irq_work.o
 obj-y  += probe_roms.o
-obj-$(CONFIG_X86_64)   += sys_x86_64.o ftrace_64.o
-obj-$(CONFIG_X86_32)   += ftrace_32.o
+obj-$(CONFIG_X86_64)   += 

[PATCH 5/6 v3] ftrace/x86_32: Add -mfentry support to x86_32 with DYNAMIC_FTRACE set

2017-03-18 Thread Steven Rostedt
From: "Steven Rostedt (VMware)" 

x86_64 has had fentry support for some time. I did not add support to x86_32
as I was unsure if it will be used much in the future. It is still very much
used, and there's issues with function graph tracing with gcc playing around
with the mcount frames, causing function graph to panic. The fentry code
does not have this issue, and is able to cope as there is no frame to mess
up.

Note, this only add support for fentry when DYNAMIC_FTRACE is set. There's
really no reason to not have that set, because the performance of the
machine drops significantly when it's not enabled. I only keep
!DYNAMIC_FTRACE around to test it off, as there's still some archs that have
FTRACE but not DYNAMIC_FTRACE.

Reviewed-by: Masami Hiramatsu 
Signed-off-by: Steven Rostedt (VMware) 
---
 arch/x86/Kconfig|  2 +-
 arch/x86/kernel/ftrace_32.S | 82 +++--
 2 files changed, 73 insertions(+), 11 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index cc98d5a294ee..8c17146427ca 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -127,7 +127,7 @@ config X86
select HAVE_EBPF_JITif X86_64
select HAVE_EFFICIENT_UNALIGNED_ACCESS
select HAVE_EXIT_THREAD
-   select HAVE_FENTRY  if X86_64
+   select HAVE_FENTRY  if X86_64 || DYNAMIC_FTRACE
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_TRACER
diff --git a/arch/x86/kernel/ftrace_32.S b/arch/x86/kernel/ftrace_32.S
index 7cd27cf56578..fe64fa596266 100644
--- a/arch/x86/kernel/ftrace_32.S
+++ b/arch/x86/kernel/ftrace_32.S
@@ -11,26 +11,68 @@
 #include 
 
 #ifdef CONFIG_FUNCTION_TRACER
+
+#ifdef CC_USING_FENTRY
+# define function_hook __fentry__
+EXPORT_SYMBOL(__fentry__)
+#else
+# define function_hook mcount
+EXPORT_SYMBOL(mcount)
+#endif
+
 #ifdef CONFIG_DYNAMIC_FTRACE
 
-ENTRY(mcount)
+/* mcount uses a frame pointer even if CONFIG_FRAME_POINTER is not set */
+#if !defined(CC_USING_FENTRY) || defined(CONFIG_FRAME_POINTER)
+# define USING_FRAME_POINTER
+#endif
+
+#ifdef USING_FRAME_POINTER
+# define MCOUNT_FRAME  1   /* using frame = true  */
+#else
+# define MCOUNT_FRAME  0   /* using frame = false */
+#endif
+
+ENTRY(function_hook)
ret
-END(mcount)
+END(function_hook)
 
 ENTRY(ftrace_caller)
 
+#ifdef USING_FRAME_POINTER
+# ifdef CC_USING_FENTRY
+   /*
+* Frame pointers are of ip followed by bp.
+* Since fentry is an immediate jump, we are left with
+* parent-ip, function-ip. We need to add a frame with
+* parent-ip followed by ebp.
+*/
+   pushl   4(%esp) /* parent ip */
pushl   %ebp
movl%esp, %ebp
-
+   pushl   2*4(%esp)   /* function ip */
+# endif
+   /* For mcount, the function ip is directly above */
+   pushl   %ebp
+   movl%esp, %ebp
+#endif
pushl   %eax
pushl   %ecx
pushl   %edx
pushl   $0  /* Pass NULL as regs pointer */
-   movl5*4(%esp), %eax
-   /* Copy original ebp into %edx */
+
+#ifdef USING_FRAME_POINTER
+   /* Load parent ebp into edx */
movl4*4(%esp), %edx
+#else
+   /* There's no frame pointer, load the appropriate stack addr instead */
+   lea 4*4(%esp), %edx
+#endif
+
+   movl(MCOUNT_FRAME+4)*4(%esp), %eax  /* load the rip */
/* Get the parent ip */
-   movl0x4(%edx), %edx
+   movl4(%edx), %edx   /* edx has ebp */
+
movlfunction_trace_op, %ecx
subl$MCOUNT_INSN_SIZE, %eax
 
@@ -42,7 +84,14 @@ ftrace_call:
popl%edx
popl%ecx
popl%eax
+#ifdef USING_FRAME_POINTER
popl%ebp
+# ifdef CC_USING_FENTRY
+   addl$4,%esp /* skip function ip */
+   popl%ebp/* this is the orig bp */
+   addl$4, %esp/* skip parent ip */
+# endif
+#endif
 .Lftrace_ret:
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 .globl ftrace_graph_call
@@ -83,6 +132,10 @@ ENTRY(ftrace_regs_caller)
pushl   %edx
pushl   %ecx
pushl   %ebx
+#ifdef CC_USING_FENTRY
+   /* Load 4 off of the parent ip addr into ebp */
+   lea 14*4(%esp), %ebp
+#endif
 
movl12*4(%esp), %eax/* Load ip (1st parameter) */
subl$MCOUNT_INSN_SIZE, %eax /* Adjust ip */
@@ -121,7 +174,7 @@ GLOBAL(ftrace_regs_call)
jmp .Lftrace_ret
 #else /* ! CONFIG_DYNAMIC_FTRACE */
 
-ENTRY(mcount)
+ENTRY(function_hook)
cmpl$__PAGE_OFFSET, %esp
jb  ftrace_stub /* Paging not enabled yet? */
 
@@ -153,9 +206,8 @@ ftrace_stub:
popl%ecx
popl%eax
jmp ftrace_stub

[PATCH 2/6 v3] ftrace/x86_32: Move the ftrace specific code out of entry_32.S

2017-03-18 Thread Steven Rostedt
From: "Steven Rostedt (VMware)" 

The function tracing hook code for ftrace is not an entry point from
userspace and does not belong in the entry_*.S files. It has already been
moved out of entry_64.S. This moves it out of entry_32.S into its own
ftrace_32.S file.

Signed-off-by: Steven Rostedt (VMware) 
---
 arch/x86/entry/entry_32.S   | 169 --
 arch/x86/kernel/Makefile|   1 +
 arch/x86/kernel/ftrace_32.S | 177 
 3 files changed, 178 insertions(+), 169 deletions(-)
 create mode 100644 arch/x86/kernel/ftrace_32.S

diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index 57f7ec35216e..169b3b0c5ec6 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -35,16 +35,13 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
.section .entry.text, "ax"
@@ -886,172 +883,6 @@ BUILD_INTERRUPT3(hyperv_callback_vector, 
HYPERVISOR_CALLBACK_VECTOR,
 
 #endif /* CONFIG_HYPERV */
 
-#ifdef CONFIG_FUNCTION_TRACER
-#ifdef CONFIG_DYNAMIC_FTRACE
-
-ENTRY(mcount)
-   ret
-END(mcount)
-
-ENTRY(ftrace_caller)
-   pushl   %eax
-   pushl   %ecx
-   pushl   %edx
-   pushl   $0  /* Pass NULL as regs pointer */
-   movl4*4(%esp), %eax
-   movl0x4(%ebp), %edx
-   movlfunction_trace_op, %ecx
-   subl$MCOUNT_INSN_SIZE, %eax
-
-.globl ftrace_call
-ftrace_call:
-   callftrace_stub
-
-   addl$4, %esp/* skip NULL pointer */
-   popl%edx
-   popl%ecx
-   popl%eax
-.Lftrace_ret:
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
-.globl ftrace_graph_call
-ftrace_graph_call:
-   jmp ftrace_stub
-#endif
-
-/* This is weak to keep gas from relaxing the jumps */
-WEAK(ftrace_stub)
-   ret
-END(ftrace_caller)
-
-ENTRY(ftrace_regs_caller)
-   pushf   /* push flags before compare (in cs location) */
-
-   /*
-* i386 does not save SS and ESP when coming from kernel.
-* Instead, to get sp, >sp is used (see ptrace.h).
-* Unfortunately, that means eflags must be at the same location
-* as the current return ip is. We move the return ip into the
-* ip location, and move flags into the return ip location.
-*/
-   pushl   4(%esp) /* save return ip into ip slot 
*/
-
-   pushl   $0  /* Load 0 into orig_ax */
-   pushl   %gs
-   pushl   %fs
-   pushl   %es
-   pushl   %ds
-   pushl   %eax
-   pushl   %ebp
-   pushl   %edi
-   pushl   %esi
-   pushl   %edx
-   pushl   %ecx
-   pushl   %ebx
-
-   movl13*4(%esp), %eax/* Get the saved flags */
-   movl%eax, 14*4(%esp)/* Move saved flags into 
regs->flags location */
-   /* clobbering return ip */
-   movl$__KERNEL_CS, 13*4(%esp)
-
-   movl12*4(%esp), %eax/* Load ip (1st parameter) */
-   subl$MCOUNT_INSN_SIZE, %eax /* Adjust ip */
-   movl0x4(%ebp), %edx /* Load parent ip (2nd 
parameter) */
-   movlfunction_trace_op, %ecx /* Save ftrace_pos in 3rd 
parameter */
-   pushl   %esp/* Save pt_regs as 4th 
parameter */
-
-GLOBAL(ftrace_regs_call)
-   callftrace_stub
-
-   addl$4, %esp/* Skip pt_regs */
-   movl14*4(%esp), %eax/* Move flags back into cs */
-   movl%eax, 13*4(%esp)/* Needed to keep addl  from 
modifying flags */
-   movl12*4(%esp), %eax/* Get return ip from regs->ip 
*/
-   movl%eax, 14*4(%esp)/* Put return ip back for ret */
-
-   popl%ebx
-   popl%ecx
-   popl%edx
-   popl%esi
-   popl%edi
-   popl%ebp
-   popl%eax
-   popl%ds
-   popl%es
-   popl%fs
-   popl%gs
-   addl$8, %esp/* Skip orig_ax and ip */
-   popf/* Pop flags at end (no addl to 
corrupt flags) */
-   jmp .Lftrace_ret
-
-   popf
-   jmp ftrace_stub
-#else /* ! CONFIG_DYNAMIC_FTRACE */
-
-ENTRY(mcount)
-   cmpl$__PAGE_OFFSET, %esp
-   jb  ftrace_stub /* Paging not enabled yet? */
-
-   cmpl$ftrace_stub, ftrace_trace_function
-   jnz .Ltrace
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
-   cmpl$ftrace_stub, ftrace_graph_return
-   jnz ftrace_graph_caller
-
-   cmpl$ftrace_graph_entry_stub, ftrace_graph_entry
-   jnz ftrace_graph_caller
-#endif
-.globl ftrace_stub
-ftrace_stub:

[PATCH 2/6 v3] ftrace/x86_32: Move the ftrace specific code out of entry_32.S

2017-03-18 Thread Steven Rostedt
From: "Steven Rostedt (VMware)" 

The function tracing hook code for ftrace is not an entry point from
userspace and does not belong in the entry_*.S files. It has already been
moved out of entry_64.S. This moves it out of entry_32.S into its own
ftrace_32.S file.

Signed-off-by: Steven Rostedt (VMware) 
---
 arch/x86/entry/entry_32.S   | 169 --
 arch/x86/kernel/Makefile|   1 +
 arch/x86/kernel/ftrace_32.S | 177 
 3 files changed, 178 insertions(+), 169 deletions(-)
 create mode 100644 arch/x86/kernel/ftrace_32.S

diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index 57f7ec35216e..169b3b0c5ec6 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -35,16 +35,13 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 
.section .entry.text, "ax"
@@ -886,172 +883,6 @@ BUILD_INTERRUPT3(hyperv_callback_vector, 
HYPERVISOR_CALLBACK_VECTOR,
 
 #endif /* CONFIG_HYPERV */
 
-#ifdef CONFIG_FUNCTION_TRACER
-#ifdef CONFIG_DYNAMIC_FTRACE
-
-ENTRY(mcount)
-   ret
-END(mcount)
-
-ENTRY(ftrace_caller)
-   pushl   %eax
-   pushl   %ecx
-   pushl   %edx
-   pushl   $0  /* Pass NULL as regs pointer */
-   movl4*4(%esp), %eax
-   movl0x4(%ebp), %edx
-   movlfunction_trace_op, %ecx
-   subl$MCOUNT_INSN_SIZE, %eax
-
-.globl ftrace_call
-ftrace_call:
-   callftrace_stub
-
-   addl$4, %esp/* skip NULL pointer */
-   popl%edx
-   popl%ecx
-   popl%eax
-.Lftrace_ret:
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
-.globl ftrace_graph_call
-ftrace_graph_call:
-   jmp ftrace_stub
-#endif
-
-/* This is weak to keep gas from relaxing the jumps */
-WEAK(ftrace_stub)
-   ret
-END(ftrace_caller)
-
-ENTRY(ftrace_regs_caller)
-   pushf   /* push flags before compare (in cs location) */
-
-   /*
-* i386 does not save SS and ESP when coming from kernel.
-* Instead, to get sp, >sp is used (see ptrace.h).
-* Unfortunately, that means eflags must be at the same location
-* as the current return ip is. We move the return ip into the
-* ip location, and move flags into the return ip location.
-*/
-   pushl   4(%esp) /* save return ip into ip slot 
*/
-
-   pushl   $0  /* Load 0 into orig_ax */
-   pushl   %gs
-   pushl   %fs
-   pushl   %es
-   pushl   %ds
-   pushl   %eax
-   pushl   %ebp
-   pushl   %edi
-   pushl   %esi
-   pushl   %edx
-   pushl   %ecx
-   pushl   %ebx
-
-   movl13*4(%esp), %eax/* Get the saved flags */
-   movl%eax, 14*4(%esp)/* Move saved flags into 
regs->flags location */
-   /* clobbering return ip */
-   movl$__KERNEL_CS, 13*4(%esp)
-
-   movl12*4(%esp), %eax/* Load ip (1st parameter) */
-   subl$MCOUNT_INSN_SIZE, %eax /* Adjust ip */
-   movl0x4(%ebp), %edx /* Load parent ip (2nd 
parameter) */
-   movlfunction_trace_op, %ecx /* Save ftrace_pos in 3rd 
parameter */
-   pushl   %esp/* Save pt_regs as 4th 
parameter */
-
-GLOBAL(ftrace_regs_call)
-   callftrace_stub
-
-   addl$4, %esp/* Skip pt_regs */
-   movl14*4(%esp), %eax/* Move flags back into cs */
-   movl%eax, 13*4(%esp)/* Needed to keep addl  from 
modifying flags */
-   movl12*4(%esp), %eax/* Get return ip from regs->ip 
*/
-   movl%eax, 14*4(%esp)/* Put return ip back for ret */
-
-   popl%ebx
-   popl%ecx
-   popl%edx
-   popl%esi
-   popl%edi
-   popl%ebp
-   popl%eax
-   popl%ds
-   popl%es
-   popl%fs
-   popl%gs
-   addl$8, %esp/* Skip orig_ax and ip */
-   popf/* Pop flags at end (no addl to 
corrupt flags) */
-   jmp .Lftrace_ret
-
-   popf
-   jmp ftrace_stub
-#else /* ! CONFIG_DYNAMIC_FTRACE */
-
-ENTRY(mcount)
-   cmpl$__PAGE_OFFSET, %esp
-   jb  ftrace_stub /* Paging not enabled yet? */
-
-   cmpl$ftrace_stub, ftrace_trace_function
-   jnz .Ltrace
-#ifdef CONFIG_FUNCTION_GRAPH_TRACER
-   cmpl$ftrace_stub, ftrace_graph_return
-   jnz ftrace_graph_caller
-
-   cmpl$ftrace_graph_entry_stub, ftrace_graph_entry
-   jnz ftrace_graph_caller
-#endif
-.globl ftrace_stub
-ftrace_stub:
-   ret
-
-   /* taken from glibc 

  1   2   3   4   >