[PATCH v3 34/36] ALSA/dummy: Replace tasklet with softirq hrtimer

2017-11-29 Thread Anna-Maria Gleixner
From: Thomas Gleixner 

The tasklet is used to defer the execution of snd_pcm_period_elapsed() to
the softirq context. Using the HRTIMER_MODE_SOFT mode invokes the timer
callback in softirq context as well which renders the tasklet useless.

[o-takashi: avoid stall due to a call of hrtimer_cancel() on a callback
of hrtimer]

Signed-off-by: Thomas Gleixner 
Signed-off-by: Anna-Maria Gleixner 
Cc: alsa-de...@alsa-project.org
Cc: Takashi Sakamoto 
Cc: Takashi Iwai 
Cc: Jaroslav Kysela 
Link: http://lkml.kernel.org/r/20170905161820.jtysvxtfleunb...@breakpoint.cc
---
 sound/drivers/dummy.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index 7b2b1f766b00..6ad2ff57833d 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -375,17 +375,9 @@ struct dummy_hrtimer_pcm {
ktime_t period_time;
atomic_t running;
struct hrtimer timer;
-   struct tasklet_struct tasklet;
struct snd_pcm_substream *substream;
 };
 
-static void dummy_hrtimer_pcm_elapsed(unsigned long priv)
-{
-   struct dummy_hrtimer_pcm *dpcm = (struct dummy_hrtimer_pcm *)priv;
-   if (atomic_read(>running))
-   snd_pcm_period_elapsed(dpcm->substream);
-}
-
 static enum hrtimer_restart dummy_hrtimer_callback(struct hrtimer *timer)
 {
struct dummy_hrtimer_pcm *dpcm;
@@ -393,7 +385,14 @@ static enum hrtimer_restart dummy_hrtimer_callback(struct 
hrtimer *timer)
dpcm = container_of(timer, struct dummy_hrtimer_pcm, timer);
if (!atomic_read(>running))
return HRTIMER_NORESTART;
-   tasklet_schedule(>tasklet);
+   /*
+* In cases of XRUN and draining, this calls .trigger to stop PCM
+* substream.
+*/
+   snd_pcm_period_elapsed(dpcm->substream);
+   if (!atomic_read(>running))
+   return HRTIMER_NORESTART;
+
hrtimer_forward_now(timer, dpcm->period_time);
return HRTIMER_RESTART;
 }
@@ -403,7 +402,7 @@ static int dummy_hrtimer_start(struct snd_pcm_substream 
*substream)
struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data;
 
dpcm->base_time = hrtimer_cb_get_time(>timer);
-   hrtimer_start(>timer, dpcm->period_time, HRTIMER_MODE_REL);
+   hrtimer_start(>timer, dpcm->period_time, HRTIMER_MODE_REL_SOFT);
atomic_set(>running, 1);
return 0;
 }
@@ -413,14 +412,14 @@ static int dummy_hrtimer_stop(struct snd_pcm_substream 
*substream)
struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data;
 
atomic_set(>running, 0);
-   hrtimer_cancel(>timer);
+   if (!hrtimer_callback_running(>timer))
+   hrtimer_cancel(>timer);
return 0;
 }
 
 static inline void dummy_hrtimer_sync(struct dummy_hrtimer_pcm *dpcm)
 {
hrtimer_cancel(>timer);
-   tasklet_kill(>tasklet);
 }
 
 static snd_pcm_uframes_t
@@ -465,12 +464,10 @@ static int dummy_hrtimer_create(struct snd_pcm_substream 
*substream)
if (!dpcm)
return -ENOMEM;
substream->runtime->private_data = dpcm;
-   hrtimer_init(>timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+   hrtimer_init(>timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT);
dpcm->timer.function = dummy_hrtimer_callback;
dpcm->substream = substream;
atomic_set(>running, 0);
-   tasklet_init(>tasklet, dummy_hrtimer_pcm_elapsed,
-(unsigned long)dpcm);
return 0;
 }
 
-- 
2.11.0



[PATCH v3 26/36] hrtimer: Add clock bases and hrtimer mode for soft irq context

2017-11-29 Thread Anna-Maria Gleixner
hrtimer callback functions are always executed in hard interrupt
context. Users of hrtimer which need their timer function to be executed
in soft interrupt context, make use of tasklets to get the proper context.

Add additional hrtimer clock bases for timers which must expire in softirq
context, so the detour via the tasklet can be avoided. This is also
required for RT, where the majority of hrtimer is moved into softirq
hrtimer context.

The selection of the expiry mode happens via a mode bit. Introduce
HRTIMER_MODE_SOFT and the matching combinations with the ABS/REL/PINNED
bits and update the decoding of hrtimer_mode in tracepoints.

Signed-off-by: Anna-Maria Gleixner 
---
 include/linux/hrtimer.h  | 14 ++
 include/trace/events/timer.h |  6 +-
 kernel/time/hrtimer.c| 20 
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 98ed35767ac5..26ae8a868ea8 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -33,14 +33,24 @@ struct hrtimer_cpu_base;
  * HRTIMER_MODE_REL- Time value is relative to now
  * HRTIMER_MODE_PINNED - Timer is bound to CPU (is only considered
  *   when starting the timer)
+ * HRTIMER_MODE_SOFT   - Timer callback function will be executed in
+ *   soft irq context
  */
 enum hrtimer_mode {
HRTIMER_MODE_ABS= 0x00,
HRTIMER_MODE_REL= 0x01,
HRTIMER_MODE_PINNED = 0x02,
+   HRTIMER_MODE_SOFT   = 0x04,
 
HRTIMER_MODE_ABS_PINNED = HRTIMER_MODE_ABS | HRTIMER_MODE_PINNED,
HRTIMER_MODE_REL_PINNED = HRTIMER_MODE_REL | HRTIMER_MODE_PINNED,
+
+   HRTIMER_MODE_ABS_SOFT   = HRTIMER_MODE_ABS | HRTIMER_MODE_SOFT,
+   HRTIMER_MODE_REL_SOFT   = HRTIMER_MODE_REL | HRTIMER_MODE_SOFT,
+
+   HRTIMER_MODE_ABS_PINNED_SOFT = HRTIMER_MODE_ABS_PINNED | 
HRTIMER_MODE_SOFT,
+   HRTIMER_MODE_REL_PINNED_SOFT = HRTIMER_MODE_REL_PINNED | 
HRTIMER_MODE_SOFT,
+
 };
 
 /*
@@ -151,6 +161,10 @@ enum  hrtimer_base_type {
HRTIMER_BASE_REALTIME,
HRTIMER_BASE_BOOTTIME,
HRTIMER_BASE_TAI,
+   HRTIMER_BASE_MONOTONIC_SOFT,
+   HRTIMER_BASE_REALTIME_SOFT,
+   HRTIMER_BASE_BOOTTIME_SOFT,
+   HRTIMER_BASE_TAI_SOFT,
HRTIMER_MAX_CLOCK_BASES,
 };
 
diff --git a/include/trace/events/timer.h b/include/trace/events/timer.h
index 744b4310b24b..a57e4ee989d6 100644
--- a/include/trace/events/timer.h
+++ b/include/trace/events/timer.h
@@ -148,7 +148,11 @@ DEFINE_EVENT(timer_class, timer_cancel,
{ HRTIMER_MODE_ABS, "ABS"   },  \
{ HRTIMER_MODE_REL, "REL"   },  \
{ HRTIMER_MODE_ABS_PINNED,  "ABS|PINNED"},  \
-   { HRTIMER_MODE_REL_PINNED,  "REL|PINNED"})
+   { HRTIMER_MODE_REL_PINNED,  "REL|PINNED"},  \
+   { HRTIMER_MODE_ABS_SOFT,"ABS|SOFT"  },  \
+   { HRTIMER_MODE_REL_SOFT,"REL|SOFT"  },  \
+   { HRTIMER_MODE_ABS_PINNED_SOFT, "ABS|PINNED|SOFT" },\
+   { HRTIMER_MODE_REL_PINNED_SOFT, "REL|PINNED|SOFT" })
 
 /**
  * hrtimer_init - called when the hrtimer is initialized
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index afb54c47e81c..e2724f8a2340 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -92,6 +92,26 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
.clockid = CLOCK_TAI,
.get_time = _get_clocktai,
},
+   {
+   .index = HRTIMER_BASE_MONOTONIC_SOFT,
+   .clockid = CLOCK_MONOTONIC,
+   .get_time = _get,
+   },
+   {
+   .index = HRTIMER_BASE_REALTIME_SOFT,
+   .clockid = CLOCK_REALTIME,
+   .get_time = _get_real,
+   },
+   {
+   .index = HRTIMER_BASE_BOOTTIME_SOFT,
+   .clockid = CLOCK_BOOTTIME,
+   .get_time = _get_boottime,
+   },
+   {
+   .index = HRTIMER_BASE_TAI_SOFT,
+   .clockid = CLOCK_TAI,
+   .get_time = _get_clocktai,
+   },
}
 };
 
-- 
2.11.0



Re: [Xen-devel] [PATCH V2] Xen/pciback: Implement PCI slot or bus reset with 'do_flr' SysFS attribute

2017-11-29 Thread Govinda Tatti

Jan,

Please see below for my comments.

On 11/9/2017 2:49 AM, Jan Beulich wrote:

On 09.11.17 at 00:06,  wrote:

--- a/drivers/xen/xen-pciback/pci_stub.c
+++ b/drivers/xen/xen-pciback/pci_stub.c
@@ -244,6 +244,91 @@ struct pci_dev *pcistub_get_pci_dev(struct 
xen_pcibk_device *pdev,
return found_dev;
  }
  
+struct pcistub_args {

+   struct pci_dev *dev;

Please don't ignore prior review comments: Either carry out what
was requested, or explain why the request can't be fulfilled. You
saying "This field will point to first device that is not owned by
pcistub" to Roger's request to make this a pointer to const is not a
valid reason to not do the adjustment; in fact your reply is entirely
unrelated to the request.

We can use "const" with above field since we will set this field only once.
I will change it.



+static int pcistub_search_dev(struct pci_dev *dev, void *data)
+{
+   struct pcistub_device *psdev;
+   struct pcistub_args *arg = data;
+   bool found_dev = false;

Purely cosmetical, but anyway: Why not just "found"? What else
could be (not) found here other than the device in question?

Sure, I will change it to "found".




+   unsigned long flags;
+
+   spin_lock_irqsave(_devices_lock, flags);
+
+   list_for_each_entry(psdev, _devices, dev_list) {
+   if (psdev->dev == dev) {
+   found_dev = true;
+   arg->dcount++;
+   break;
+   }
+   }
+
+   spin_unlock_irqrestore(_devices_lock, flags);
+
+   /* Device not owned by pcistub, someone owns it. Abort the walk */
+   if (!found_dev)
+   arg->dev = dev;
+
+   return found_dev ? 0 : 1;

Despite the function needing to return int, this can be simplified to
"return !found_dev". I'd also like to note that the part of the
earlier comment related to this is sort of disconnected. How about

/* Device not owned by pcistub, someone owns it. Abort the walk */
if (!found_dev) {
arg->dev = dev;
return 1;
}

return 0;

Fine with me.


And finally - I don't think the comment is entirely correct - the
device not being owned by pciback doesn't necessarily mean it's
owned by another driver. It could as well be unowned.
OK. I will modify this comment as " Device not owned by pcistub. Abort 
the walk".



+static int pcistub_reset_dev(struct pci_dev *dev)
+{
+   struct xen_pcibk_dev_data *dev_data;
+   bool slot = false, bus = false;
+   struct pcistub_args arg = {};
+
+   if (!dev)
+   return -EINVAL;
+
+   dev_dbg(>dev, "[%s]\n", __func__);
+
+   if (!pci_probe_reset_slot(dev->slot))
+   slot = true;
+   else if ((!pci_probe_reset_bus(dev->bus)) &&
+(!pci_is_root_bus(dev->bus)))
+   bus = true;
+
+   if (!bus && !slot)
+   return -EOPNOTSUPP;
+
+   /*
+* Make sure all devices on this bus are owned by the
+* PCI backend so that we can safely reset the whole bus.
+*/

Is that really the case when you mean to do a slot reset? It was for
a reason that I had asked about a missing "else" in v1 review,
rather than questioning the conditional around the logic.


In the case of bus or slot reset, our goal is to reset connected PCIe 
fabric/card/endpoint.
The connected card/endpoint can be multi-function device. So, same 
walk-through and checking

is needed irrespective of type of reset being used.




+   pci_walk_bus(dev->bus, pcistub_search_dev, );
+
+   /* All devices under the bus should be part of pcistub! */
+   if (arg.dev) {
+   dev_err(>dev, "%s device on bus 0x%x is not owned by 
pcistub\n",

%#x

Yet then, thinking about what would be useful information should the
situation really arise, I'm not convinced printing a bare bus number
here is useful either. Especially for the case of multiple parallel
requests you want to make it possible to match each message to the
original request (guest start or whatever). Hence I think you want
something like

"%s on the same bus as %s is not owned by " DRV_NAME "\n"

Sure, I will make this change.



+   pci_name(arg.dev), dev->bus->number);
+
+   return -EBUSY;
+   }
+
+   dev_dbg(>dev, "pcistub owns %d devices on bus 0x%x\n",
+   arg.dcount, dev->bus->number);

While here the original device is perhaps not necessary to print,
the bare bus number doesn't carry enough information: You'll
want to prefix it by the segment number. Plus you'll want to use
canonical formatting (:bb), so one can get matches when
suitably grep-ing the log. Perhaps bus->name is what you're
after.

Sure, I can change it to

dev_dbg(>dev, "pcistub owns %d devices on PCI Bus %04x:%02x", 
pci_domain_nr(bus), bus->number);

Cheers
GOVINDA


Re: [PATCH] net: stmmac: dwmac-sun8i: fix allwinner,leds-active-low handling

2017-11-29 Thread Andrew Lunn
On Wed, Nov 29, 2017 at 10:02:40AM +0100, Corentin Labbe wrote:
> On Tue, Nov 28, 2017 at 06:38:26PM +0100, Andrew Lunn wrote:
> > On Tue, Nov 28, 2017 at 05:48:22PM +0100, Corentin Labbe wrote:
> > > The driver expect "allwinner,leds-active-low" to be in PHY node, but
> > > the binding doc expect it to be in MAC node.
> > > 
> > > Since all board DT use it also in MAC node, the driver need to search
> > > allwinner,leds-active-low in MAC node.
> > 
> > Hi Corentin
> > 
> > I'm having trouble working out how this worked before. This is code
> > you moved around, when adding external/internal MDIOs. But the very
> > first version of this driver code used priv->plat->phy_node. Did that
> > somehow point to the MAC node when the internal PHY is used? Or has it
> > been broken all the time?
> > 
> 
> Hello
> 

> Since this feature control only when the activity LED need to blink,
> nobody see that it was broken.

Hi Corentin

So it never worked?

If it never worked, moving the DT properties into the PHY node, where
they belong, won't introduce a regression :-)

 Andrew


[PATCH 1/2] lockdep: finer-grained completion key for kthread

2017-11-29 Thread Daniel Vetter
Ideally we'd create the key through a macro at the real callers and
pass it all the way down. This would give us better coverage for cases
where a bunch of kthreads are created for the same thing.
But this gets the job done meanwhile and unblocks our CI. Refining
later on is always possible.

v2:
- make it compile
- use the right map (Tvrtko)

v3:

lockdep insist on a static key, so the cheap way didn't work. Wire
2 keys through all the callers.

I didn't extend this up to alloc_workqueue because the
lockdep_invariant_state() call should separate the work functions from
the workqueue kthread logic and prevent cross-release state from
leaking between unrelated work queues that happen to reuse the same
kthreads.

v4: CI found more compile fail :-/

Cc: Tvrtko Ursulin 
Cc: Marta Lofstedt 
References: https://bugs.freedesktop.org/show_bug.cgi?id=103950
Signed-off-by: Daniel Vetter 
---
 include/linux/kthread.h | 48 -
 kernel/kthread.c| 70 ++---
 2 files changed, 90 insertions(+), 28 deletions(-)

diff --git a/include/linux/kthread.h b/include/linux/kthread.h
index c1961761311d..7a9463f0be5c 100644
--- a/include/linux/kthread.h
+++ b/include/linux/kthread.h
@@ -6,10 +6,12 @@
 #include 
 #include 
 
-__printf(4, 5)
-struct task_struct *kthread_create_on_node(int (*threadfn)(void *data),
+__printf(6, 7)
+struct task_struct *_kthread_create_on_node(int (*threadfn)(void *data),
   void *data,
   int node,
+  struct lock_class_key *exited_key,
+  struct lock_class_key *parked_key,
   const char namefmt[], ...);
 
 /**
@@ -25,12 +27,27 @@ struct task_struct *kthread_create_on_node(int 
(*threadfn)(void *data),
  */
 #define kthread_create(threadfn, data, namefmt, arg...) \
kthread_create_on_node(threadfn, data, NUMA_NO_NODE, namefmt, ##arg)
+#define kthread_create_on_node(threadfn, data, node, namefmt, arg...)  \
+({ \
+   static struct lock_class_key __exited_key, __parked_key;\
+   _kthread_create_on_node(threadfn, data, node, &__exited_key,\
+  &__parked_key, namefmt, ##arg);  \
+})
 
 
-struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
+struct task_struct *_kthread_create_on_cpu(int (*threadfn)(void *data),
  void *data,
  unsigned int cpu,
+ struct lock_class_key *exited_key,
+ struct lock_class_key *parked_key,
  const char *namefmt);
+#define kthread_create_on_cpu(threadfn, data, cpu, namefmt)\
+({ \
+   static struct lock_class_key __exited_key, __parked_key;\
+   _kthread_create_on_cpu(threadfn, data, cpu, &__exited_key,\
+  &__parked_key, namefmt); \
+})
+
 
 /**
  * kthread_run - create and wake a thread.
@@ -171,13 +188,30 @@ extern void __kthread_init_worker(struct kthread_worker 
*worker,
 
 int kthread_worker_fn(void *worker_ptr);
 
-__printf(2, 3)
+__printf(4, 5)
 struct kthread_worker *
-kthread_create_worker(unsigned int flags, const char namefmt[], ...);
+_kthread_create_worker(unsigned int flags,
+  struct lock_class_key *exited_key,
+  struct lock_class_key *parked_key,
+  const char namefmt[], ...);
+#define kthread_create_worker(flags, namefmt...)   
\
+({ \
+   static struct lock_class_key __exited_key, __parked_key;\
+   _kthread_create_worker(flags, &__exited_key, &__parked_key, \
+  ##namefmt);  \
+})
 
-__printf(3, 4) struct kthread_worker *
-kthread_create_worker_on_cpu(int cpu, unsigned int flags,
+__printf(5, 6) struct kthread_worker *
+_kthread_create_worker_on_cpu(int cpu, unsigned int flags,
+  struct lock_class_key *exited_key,
+  struct lock_class_key *parked_key,
 const char namefmt[], ...);
+#define kthread_create_worker_on_cpu(cpu, flags, namefmt...)   \
+({ \
+   static struct lock_class_key __exited_key, __parked_key;\
+   _kthread_create_worker_on_cpu(cpu, flags, &__exited_key, &__parked_key,\
+  ##namefmt);   

[PATCH 0/2] lockdep cross-release fallout from -rc1

2017-11-29 Thread Daniel Vetter
Hi all,

-rc1 set our CI on fire with a pile of issues that cross-release
highlights. The two patches in this series get things back into working
order on our side, so we pulled them into our local branches to unblock CI
and drm/i915.

But they're ofc far from polished, so pls look at this more as a bug
report than bugfix submission :-)

Cheers, Daniel

Daniel Vetter (2):
  lockdep: finer-grained completion key for kthread
  lockdep: Up MAX_LOCKDEP_CHAINS

 include/linux/kthread.h| 48 ++
 kernel/kthread.c   | 70 ++
 kernel/locking/lockdep_internals.h |  2 +-
 3 files changed, 91 insertions(+), 29 deletions(-)

-- 
2.15.0



[PATCH v3 13/36] hrtimer: Reduce conditional code (hres_active)

2017-11-29 Thread Anna-Maria Gleixner
The hrtimer_cpu_base struct has the CONFIG_HIGH_RES_TIMERS conditional
struct member hres_active. All related functions to this member are
conditional as well.

There is no functional change, when the hres_active member is
unconditional with all related functions and is set to zero during
initialization.

The conditional code sections can be avoided by adding IS_ENABLED(HIGHRES)
conditionals into common functions, which ensures dead code elimination.

Suggested-by: Thomas Gleixner 
Signed-off-by: Anna-Maria Gleixner 
---
 include/linux/hrtimer.h | 20 
 kernel/time/hrtimer.c   | 31 +++
 2 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 56e56bcb6f0f..22627b3a33fe 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -161,8 +161,8 @@ enum  hrtimer_base_type {
  * @cpu:   cpu number
  * @active_bases:  Bitfield to mark bases with active timers
  * @clock_was_set_seq: Sequence counter of clock was set events
- * @in_hrtirq: hrtimer_interrupt() is currently executing
  * @hres_active:   State of high resolution mode
+ * @in_hrtirq: hrtimer_interrupt() is currently executing
  * @hang_detected: The last hrtimer interrupt detected a hang
  * @expires_next:  absolute time of the next event, is required for remote
  * hrtimer enqueue
@@ -182,9 +182,9 @@ struct hrtimer_cpu_base {
unsigned intcpu;
unsigned intactive_bases;
unsigned intclock_was_set_seq;
+   unsigned inthres_active : 1;
 #ifdef CONFIG_HIGH_RES_TIMERS
unsigned intin_hrtirq   : 1,
-   hres_active : 1,
hang_detected   : 1;
ktime_t expires_next;
struct hrtimer  *next_timer;
@@ -266,16 +266,17 @@ static inline ktime_t hrtimer_cb_get_time(struct hrtimer 
*timer)
return timer->base->get_time();
 }
 
+static inline int hrtimer_is_hres_active(struct hrtimer *timer)
+{
+   return IS_ENABLED(CONFIG_HIGH_RES_TIMERS) ?
+   timer->base->cpu_base->hres_active : 0;
+}
+
 #ifdef CONFIG_HIGH_RES_TIMERS
 struct clock_event_device;
 
 extern void hrtimer_interrupt(struct clock_event_device *dev);
 
-static inline int hrtimer_is_hres_active(struct hrtimer *timer)
-{
-   return timer->base->cpu_base->hres_active;
-}
-
 /*
  * The resolution of the clocks. The resolution value is returned in
  * the clock_getres() system call to give application programmers an
@@ -298,11 +299,6 @@ extern unsigned int hrtimer_resolution;
 
 #define hrtimer_resolution (unsigned int)LOW_RES_NSEC
 
-static inline int hrtimer_is_hres_active(struct hrtimer *timer)
-{
-   return 0;
-}
-
 static inline void clock_was_set_delayed(void) { }
 
 #endif
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 046b509beed6..8453dca6e0c5 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -512,6 +512,20 @@ static inline ktime_t hrtimer_update_base(struct 
hrtimer_cpu_base *base)
offs_real, offs_boot, offs_tai);
 }
 
+/*
+ * Is the high resolution mode active ?
+ */
+static inline int __hrtimer_hres_active(struct hrtimer_cpu_base *cpu_base)
+{
+   return IS_ENABLED(CONFIG_HIGH_RES_TIMERS) ?
+   cpu_base->hres_active : 0;
+}
+
+static inline int hrtimer_hres_active(void)
+{
+   return __hrtimer_hres_active(this_cpu_ptr(_bases));
+}
+
 /* High resolution timer related functions */
 #ifdef CONFIG_HIGH_RES_TIMERS
 
@@ -541,19 +555,6 @@ static inline int hrtimer_is_hres_enabled(void)
 }
 
 /*
- * Is the high resolution mode active ?
- */
-static inline int __hrtimer_hres_active(struct hrtimer_cpu_base *cpu_base)
-{
-   return cpu_base->hres_active;
-}
-
-static inline int hrtimer_hres_active(void)
-{
-   return __hrtimer_hres_active(this_cpu_ptr(_bases));
-}
-
-/*
  * Reprogram the event source with checking both queues for the
  * next event
  * Called with interrupts disabled and base->lock held
@@ -661,7 +662,6 @@ static void hrtimer_reprogram(struct hrtimer *timer,
 static inline void hrtimer_init_hres(struct hrtimer_cpu_base *base)
 {
base->expires_next = KTIME_MAX;
-   base->hres_active = 0;
 }
 
 /*
@@ -720,8 +720,6 @@ void clock_was_set_delayed(void)
 
 #else
 
-static inline int __hrtimer_hres_active(struct hrtimer_cpu_base *b) { return 
0; }
-static inline int hrtimer_hres_active(void) { return 0; }
 static inline int hrtimer_is_hres_enabled(void) { return 0; }
 static inline void hrtimer_switch_to_hres(void) { }
 static inline void
@@ -1600,6 +1598,7 @@ int hrtimers_prepare_cpu(unsigned int cpu)
}
 
cpu_base->cpu = cpu;
+   

[PATCH v3 01/36] timers: Use static keys for migrate_enable/nohz_active

2017-11-29 Thread Anna-Maria Gleixner
From: Thomas Gleixner 

The members migrate_enable and nohz_active in the timer/hrtimer per CPU
bases have been introduced to avoid accessing global variables for these
decisions.

Still that results in a (cache hot) load and conditional branch, which can
be avoided by using static keys.

Implement it with static keys and optimize for the most critical case of
high performance networking which tends to disable the timer migration
functionality.

Signed-off-by: Thomas Gleixner 
Signed-off-by: Anna-Maria Gleixner 
---
 include/linux/hrtimer.h |  4 --
 kernel/time/hrtimer.c   | 17 +++--
 kernel/time/tick-internal.h | 19 ++
 kernel/time/tick-sched.c|  2 +-
 kernel/time/timer.c | 91 +++--
 5 files changed, 65 insertions(+), 68 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 012c37fdb688..79b2a8d29d8c 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -153,8 +153,6 @@ enum  hrtimer_base_type {
  * @cpu:   cpu number
  * @active_bases:  Bitfield to mark bases with active timers
  * @clock_was_set_seq: Sequence counter of clock was set events
- * @migration_enabled: The migration of hrtimers to other cpus is enabled
- * @nohz_active:   The nohz functionality is enabled
  * @expires_next:  absolute time of the next event which was scheduled
  * via clock_set_next_event()
  * @next_timer:Pointer to the first expiring timer
@@ -178,8 +176,6 @@ struct hrtimer_cpu_base {
unsigned intcpu;
unsigned intactive_bases;
unsigned intclock_was_set_seq;
-   boolmigration_enabled;
-   boolnohz_active;
 #ifdef CONFIG_HIGH_RES_TIMERS
unsigned intin_hrtirq   : 1,
hres_active : 1,
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index d32520840fde..69d203d8b12d 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -178,23 +178,16 @@ hrtimer_check_target(struct hrtimer *timer, struct 
hrtimer_clock_base *new_base)
 #endif
 }
 
-#ifdef CONFIG_NO_HZ_COMMON
-static inline
-struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base *base,
-int pinned)
-{
-   if (pinned || !base->migration_enabled)
-   return base;
-   return _cpu(hrtimer_bases, get_nohz_timer_target());
-}
-#else
 static inline
 struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base *base,
 int pinned)
 {
+#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
+   if (static_branch_unlikely(_migration_enabled) && !pinned)
+   return _cpu(hrtimer_bases, get_nohz_timer_target());
+#endif
return base;
 }
-#endif
 
 /*
  * We switch the timer base to a power-optimized selected CPU target,
@@ -969,7 +962,7 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t 
tim,
 * Kick to reschedule the next tick to handle the new timer
 * on dynticks target.
 */
-   if (new_base->cpu_base->nohz_active)
+   if (is_timers_nohz_active())
wake_up_nohz_cpu(new_base->cpu_base->cpu);
} else {
hrtimer_reprogram(timer, new_base);
diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h
index f8e1845aa464..4ac74dff59f0 100644
--- a/kernel/time/tick-internal.h
+++ b/kernel/time/tick-internal.h
@@ -150,14 +150,19 @@ static inline void tick_nohz_init(void) { }
 
 #ifdef CONFIG_NO_HZ_COMMON
 extern unsigned long tick_nohz_active;
-#else
+extern void timers_update_nohz(void);
+extern struct static_key_false timers_nohz_active;
+static inline bool is_timers_nohz_active(void)
+{
+   return static_branch_unlikely(_nohz_active);
+}
+# ifdef CONFIG_SMP
+extern struct static_key_false timers_migration_enabled;
+# endif
+#else /* CONFIG_NO_HZ_COMMON */
+static inline void timers_update_nohz(void) { }
 #define tick_nohz_active (0)
-#endif
-
-#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
-extern void timers_update_migration(bool update_nohz);
-#else
-static inline void timers_update_migration(bool update_nohz) { }
+static inline bool is_timers_nohz_active(void) { return false; }
 #endif
 
 DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 99578f06c8d4..f371f25f3510 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -1079,7 +1079,7 @@ static inline void tick_nohz_activate(struct tick_sched 
*ts, int mode)
ts->nohz_mode = mode;
/* One update is enough */
if (!test_and_set_bit(0, _nohz_active))
-   

[PATCH v3 02/36] hrtimer: Correct blantanly wrong comment

2017-11-29 Thread Anna-Maria Gleixner
From: Thomas Gleixner 

The protection of a hrtimer which runs its callback against migration to a
different CPU has nothing to do with hard interrupt context.

The protection against migration of a hrtimer running the expiry callback
is the pointer in the cpu_base which holds a pointer to the currently
running timer. This pointer is evaluated in the code which potentially
switches the timer base and makes sure it's kept on the CPU on which the
callback is running.

Reported-by: Anna-Maria Gleixner 
Signed-off-by: Thomas Gleixner 
Signed-off-by: Anna-Maria Gleixner 
---
 kernel/time/hrtimer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 69d203d8b12d..aee49c0c58b9 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1195,9 +1195,9 @@ static void __run_hrtimer(struct hrtimer_cpu_base 
*cpu_base,
timer->is_rel = false;
 
/*
-* Because we run timers from hardirq context, there is no chance
-* they get migrated to another cpu, therefore its safe to unlock
-* the timer base.
+* The timer is marked as running in the cpu base, so it is
+* protected against migration to a different CPU even if the lock
+* is dropped.
 */
raw_spin_unlock(_base->lock);
trace_hrtimer_expire_entry(timer, now);
-- 
2.11.0



[PATCH 00/36] hrtimer: Provide softirq context hrtimers

2017-11-29 Thread Anna-Maria Gleixner
There are quite some places in the kernel which use a combination of
hrtimers and tasklets to make use of the precise expiry of hrtimers, which
schedule a tasklet to bring the actual function into softirq context.

This was introduced when the previous hrtimer softirq code was
removed. That code was implemented by expiring the timer in hard irq
context and then deferring the execution of the callback into softirq
context. That caused a lot of pointless shuffling between the rbtree and a
linked list.

In recent discussions it turned out that more potential users of hrtimers
in softirq context might come up. Aside of that the RT patches need this
functionality as well to defer hrtimers into softirq context if their
callbacks are not interrupt safe on RT.

This series implements a new approach by adding SOFT hrtimer mode and
instead of doing the list shuffle, timers started with this mode are put
into separate soft expiry hrtimer queues. These queues are evaluated only
when the hardirq context detects that the first expiring timer in the
softirq queues has expired. That makes the overhead in the hardirq context
minimal.

The series reworks the code to reuse as much as possible from the existing
facilities for the new softirq hrtimers and integrates them with all
flavours of hrtimers (HIGH_RES=y/n - NOHZ=y/n).

To achieve this quite some of the conditionals in the existing code are
removed for the price of adding some pointless data and state tracking to
the HIGH_RES=n case. That's minimal, but well worth it as it increases the
readability and maintainability of the code.

The first part of the series implements the new functionality and the
second part converts the hrtimer/tasklet users to make use of it and
removes struct hrtimer_tasklet and the surrounding helper functions.

This series is available from git as well:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git WIP.timers

Thanks,

Anna-Maria

---
v2..v3:

  - Use static keys for migrate_enable and nohz_active
  - fix missing struct documentation
  - integrate Sebastian Siewiors suggestions and fix bug he mentioned:
https://lkml.kernel.org/r/20171110124224.ykr6n4z7zgypo...@breakpoint.cc


v1..v2:

  - integration of Peter Zijlstras patch:

https://lkml.kernel.org/r/20170927164025.gi17...@worktop.programming.kicks-ass.net
  - using hrtimer_mode instead of additional hrtimer clock bases
  - folding the fix for updating the base offsets:
https://lkml.kernel.org/r/20171006102820.ou4wpm56ed6m3...@linutronix.de
  - rework of 08/25 - 10/25 (all of those patches are facing reduction of
conditional code) and make hrtimer_force_reprogram() unconditional as well
  - integration of new versions of "ALSA/dummy: Replace tasklet with
softirq hrtimer" and "net/cdc_ncm: Replace tasklet with softirq
hrtimer"
  - additional hrtimer/tasklet user conversion: "net/mvpp2: Replace tasklet
with softirq hrtimer"
  - additional fixes of several wrong comments
  - update hrtimer tracing (mode and clock bases)


 drivers/net/ethernet/marvell/mvpp2.c  |   62 +--
 drivers/net/wireless/mac80211_hwsim.c |   44 +-
 drivers/usb/gadget/function/f_ncm.c   |   30 -
 include/linux/hrtimer.h   |  113 +++--
 include/linux/interrupt.h |   25 -
 include/net/xfrm.h|2 
 include/trace/events/timer.h  |   37 +
 kernel/softirq.c  |   51 --
 kernel/time/hrtimer.c |  643 +-
 kernel/time/tick-internal.h   |   13 
 kernel/time/tick-sched.c  |2 
 kernel/time/timer.c   |   98 ++---
 net/can/bcm.c |  156 ++--
 net/xfrm/xfrm_state.c |   30 -
 sound/drivers/dummy.c |   27 -
 15 files changed, 702 insertions(+), 631 deletions(-)





Re: [Xen-devel] [PATCH V2] Xen/pciback: Implement PCI slot or bus reset with 'do_flr' SysFS attribute

2017-11-29 Thread Jan Beulich
>>> On 29.11.17 at 16:37,  wrote:
> On 11/9/2017 2:49 AM, Jan Beulich wrote:
> On 09.11.17 at 00:06,  wrote:
>>> +static int pcistub_reset_dev(struct pci_dev *dev)
>>> +{
>>> +   struct xen_pcibk_dev_data *dev_data;
>>> +   bool slot = false, bus = false;
>>> +   struct pcistub_args arg = {};
>>> +
>>> +   if (!dev)
>>> +   return -EINVAL;
>>> +
>>> +   dev_dbg(>dev, "[%s]\n", __func__);
>>> +
>>> +   if (!pci_probe_reset_slot(dev->slot))
>>> +   slot = true;
>>> +   else if ((!pci_probe_reset_bus(dev->bus)) &&
>>> +(!pci_is_root_bus(dev->bus)))
>>> +   bus = true;
>>> +
>>> +   if (!bus && !slot)
>>> +   return -EOPNOTSUPP;
>>> +
>>> +   /*
>>> +* Make sure all devices on this bus are owned by the
>>> +* PCI backend so that we can safely reset the whole bus.
>>> +*/
>> Is that really the case when you mean to do a slot reset? It was for
>> a reason that I had asked about a missing "else" in v1 review,
>> rather than questioning the conditional around the logic.
> 
> In the case of bus or slot reset, our goal is to reset connected PCIe 
> fabric/card/endpoint.
> The connected card/endpoint can be multi-function device. So, same 
> walk-through and checking
> is needed irrespective of type of reset being used.

I don't follow: The scope of other devices/functions possibly
affected by a reset depends on the type of reset, doesn't it?

Jan



Re: [PATCH] net: stmmac: dwmac-sun8i: fix allwinner,leds-active-low handling

2017-11-29 Thread Chen-Yu Tsai
On Wed, Nov 29, 2017 at 11:46 PM, Andrew Lunn  wrote:
> Hi ChenYu
>
>> It worked at one point. During some previous iteration, they lit up as
>> they were supposed to.
>
> For a released version of the kernel? Or during development work?  If
> they did work, but broken, it would be good to know which commit broke
> it. We can then add a fixes: tag to the patch as proposed.

During development work. The bindings / driver was never released.

ChenYu


Re: [PATCH v4 7/8] netdev: octeon-ethernet: Add Cavium Octeon III support.

2017-11-29 Thread Souptick Joarder
On Wed, Nov 29, 2017 at 4:00 PM, Souptick Joarder  wrote:
> On Wed, Nov 29, 2017 at 6:25 AM, David Daney  wrote:
>> From: Carlos Munoz 
>>
>> The Cavium OCTEON cn78xx and cn73xx SoCs have network packet I/O
>> hardware that is significantly different from previous generations of
>> the family.

>> diff --git a/drivers/net/ethernet/cavium/octeon/octeon3-bgx-port.c 
>> b/drivers/net/ethernet/cavium/octeon/octeon3-bgx-port.c
>> new file mode 100644
>> index ..4dad35fa4270
>> --- /dev/null
>> +++ b/drivers/net/ethernet/cavium/octeon/octeon3-bgx-port.c
>> @@ -0,0 +1,2033 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/* Copyright (c) 2017 Cavium, Inc.
>> + *
>> + * This file is subject to the terms and conditions of the GNU General 
>> Public
>> + * License.  See the file "COPYING" in the main directory of this archive
>> + * for more details.
>> + */
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +

>> +static void bgx_port_sgmii_set_link_down(struct bgx_port_priv *priv)
>> +{
>> +   u64 data;

>> +   data = oct_csr_read(BGX_GMP_PCS_MISC_CTL(priv->node, priv->bgx, 
>> priv->index));
>> +   data |= BIT(11);
>> +   oct_csr_write(data, BGX_GMP_PCS_MISC_CTL(priv->node, priv->bgx, 
>> priv->index));
>> +   data = oct_csr_read(BGX_GMP_PCS_MISC_CTL(priv->node, priv->bgx, 
>> priv->index));
>
> Any particular reason to read immediately after write ?



>> +static int bgx_port_sgmii_set_link_speed(struct bgx_port_priv *priv, struct 
>> port_status status)
>> +{
>> +   u64 data;
>> +   u64 prtx;
>> +   u64 miscx;
>> +   int timeout;
>> +

>> +
>> +   switch (status.speed) {
>> +   case 10:
>
> In my opinion, instead of hard coding the value, is it fine to use ENUM ?
   Similar comments applicable in other places where hard coded values are used.



>> +static int bgx_port_gser_27882(struct bgx_port_priv *priv)
>> +{
>> +   u64 data;
>> +   u64 addr;
>
>> +   int timeout = 200;
>> +
>> +   //timeout = 200;
Better to initialize the timeout value


>> +static int bgx_port_qlm_rx_equalization(struct bgx_port_priv *priv, int 
>> qlm, int lane)
>> +{
>> +   lmode = oct_csr_read(GSER_LANE_MODE(priv->node, qlm));
>> +   lmode &= 0xf;
>> +   addr = GSER_LANE_P_MODE_1(priv->node, qlm, lmode);
>> +   data = oct_csr_read(addr);
>> +   /* Don't complete rx equalization if in VMA manual mode */
>> +   if (data & BIT(14))
>> +   return 0;
>> +
>> +   /* Apply rx equalization for speed > 6250 */
>> +   if (bgx_port_get_qlm_speed(priv, qlm) < 6250)
>> +   return 0;
>> +
>> +   /* Wait until rx data is valid (CDRLOCK) */
>> +   timeout = 500;
>
> 500 us is the min required value or it can be further reduced ?


>> +static int bgx_port_init_xaui_link(struct bgx_port_priv *priv)
>> +{

>> +
>> +   if (use_ber) {
>> +   timeout = 1;
>> +   do {
>> +   data =
>> +   oct_csr_read(BGX_SPU_BR_STATUS1(priv->node, 
>> priv->bgx, priv->index));
>> +   if (data & BIT(0))
>> +   break;
>> +   timeout--;
>> +   udelay(1);
>> +   } while (timeout);
>
> In my opinion, it's better to implement similar kind of loops inside macros.
>
>> +   if (!timeout) {
>> +   pr_debug("BGX%d:%d:%d: BLK_LOCK timeout\n",
>> +priv->bgx, priv->index, priv->node);
>> +   return -1;
>> +   }
>> +   } else {
>> +   timeout = 1;
>> +   do {
>> +   data =
>> +   oct_csr_read(BGX_SPU_BX_STATUS(priv->node, 
>> priv->bgx, priv->index));
>> +   if (data & BIT(12))
>> +   break;
>> +   timeout--;
>> +   udelay(1);
>> +   } while (timeout);
> same here


Re: [PATCH] staging: nvec: Fix usleep_range is preferred over udelay

2017-11-29 Thread Mikko Perttunen

On 11/29/2017 06:00 PM, Joshua Abraham wrote:

Signed-off-by: Joshua Abraham 

This patch fixes the issue:

CHECK: usleep_range is preferred over udelay; see
Documentation/timers/timers-howto.txt

---
  drivers/staging/nvec/nvec.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 4ff8f47385da..2a01ef4b54ff 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -631,7 +631,7 @@ static irqreturn_t nvec_interrupt(int irq, void *dev)
break;
case 2: /* first byte after command */
if (status == (I2C_SL_IRQ | RNW | RCVD)) {
-   udelay(33);
+   usleep_range(30, 35);
if (nvec->rx->data[0] != 0x01) {
dev_err(nvec->dev,
"Read without prior read command\n");



This is incorrect, as this function is an interrupt handler and we 
cannot sleep in interrupt context.


Cheers,
Mikko


Re: [PATCH] drm/fb_helper: Disable all crtc's when initial setup fails.

2017-11-29 Thread Maarten Lankhorst
Op 28-11-17 om 16:13 schreef Thomas Voegtle:
> On Tue, 28 Nov 2017, Daniel Vetter wrote:
>
>> On Tue, Nov 28, 2017 at 12:16:03PM +0100, Maarten Lankhorst wrote:
>>> Some drivers like i915 start with crtc's enabled, but with deferred
>>> fbcon setup they were no longer disabled as part of fbdev setup.
>>> Headless units could no longer enter pc3 state because the crtc was
>>> still enabled.
>>>
>>> Fix this by calling restore_fbdev_mode when we would have called
>>> it otherwise once during initial fbdev setup.
>>>
>>> Signed-off-by: Maarten Lankhorst 
>>> Fixes: ca91a2758fce ("drm/fb-helper: Support deferred setup")
>>
>> Please use dim fixes to get a more complete Cc: list for regression fixes.
>>
>>> Cc:  # v4.14+
>>> Reported-by: Thomas Voegtle 
>>
>> Reviewed-by: Daniel Vetter 
>>
>> But please confirm with the reporter that it indeed fixes the issue before
>> pushing.
>> -Daniel
>
> I re-checked the latest version of the patch and it indeed fixes the problem.
>
> Thanks,
>
>    Thomas
>
Pushed, thanks for the report. :)

~Maarten



Re: [PATCH] ARM: dts: imx6qdl-udoo: add support for powering off

2017-11-29 Thread Shawn Guo
On Mon, Nov 27, 2017 at 11:22:28PM +0100, Maciej S. Szmigiero wrote:
> UDOO board has a possibility to disable most of imx6 SoC power supplies via
> "EN_5V" signal, which is connected to "NANDF_D4" pad.
> 
> This reduces current consumption after shutdown from ~350 mA to ~40 mA and
> prevents a SoC watchdog from starting it again on its own after the
> watchdog timeout expires (previously it was not possible to shut down the
> SoC permanently if its watchdog was ever enabled since it was still ticking
> after the shutdown).
> 
> Unfortunately, this does not extinguish the "Power" LED (as it is powered
> from an always-on voltage regulator).
> 
> To power the SoC up again press the power button (SW2, the one with a long
> shaft).
> 
> Signed-off-by: Maciej S. Szmigiero 

Applied, thanks.


Re: [PATCH v4] ARM: dts: imx6qdl-nitrogen6x: Add SPI NOR partitions

2017-11-29 Thread Shawn Guo
On Tue, Nov 28, 2017 at 03:49:24PM -0200, Otavio Salvador wrote:
> This adds the partitions definition for the SPI NOR to provide
> backward compatibility with the documented[1] layout used with
> Boundary Devices BSP.
> 
> 1. https://boundarydevices.com/boot-flash-access-linux/
> 
> It exports to Linux:
> 
>  mtd0: bootloader
>  mtd1: env
>  mtd2: splash
> 
> Signed-off-by: Otavio Salvador 

Applied, thanks.


Re: [RFC PATCH] KVM: x86: Allow Qemu/KVM to use PVH entry point

2017-11-29 Thread Andrew Cooper
On 29/11/17 14:47, Juergen Gross wrote:
> On 29/11/17 15:44, Paolo Bonzini wrote:
>> On 29/11/2017 15:25, Boris Ostrovsky wrote:
>> zeropage is x86/Linux-specific so we'd need some sort of firmware (like
>> grub) between a hypervisor and Linux to convert hvm_start_info to
>> bootparams.
> qemu?
>>> I think KVM folks didn't want to do this. I can't find the thread but I
>>> believe it was somewhere during Clear Containers discussion. Paolo?
>> QEMU is the right place to parse the ELF file and save it in memory.
>> You would have to teach QEMU to find the Xen note in ELF-format kernels
>> (just like it looks for the multiboot header), and use a different
>> option ROM ("pvhboot.c" for example).
>>
>> However I don't like to bypass the BIOS; for -kernel, KVM starts the
>> guest with an option ROM (linuxboot-dma.c or multiboot.S in QEMU
>> sources) that takes care of boot.
>>
>> In either case, you would have a new option ROM.  It could either be
>> very simple and similar to multiboot.S, or it could be larger and do the
>> same task as xen-pvh.S and enlighten_pvh.c (then get the address of
>> startup_32 or startup_64 from FW_CFG_KERNEL_ENTRY and jump there).  The
>> ugly part is that the option ROM would have to know more details about
>> what it is going to boot, including for example whether it's 32-bit or
>> 64-bit, so I don't really think it is a good idea.
> As grub2 doesn't have to know, qemu shouldn't have to know either.

An underlying requirement for this boot protocol was to remove the
requirement for a priori knowledge of the eventual mode of the guest,
which plagues Xen PV guests.  (One way or another, we need to parse the
kernel which will end up running to work out how to build the domain for
it.)

32bit flat mode is easy to set up, sufficiently large for any reasonable
bootstrapping, and provides no restrictions to what the eventual guest
wants to do.

~Andrew


Re: [PATCH] ethernet: dwmac-stm32: Fix copyright

2017-11-29 Thread David Miller
From: Benjamin Gaignard 
Date: Wed, 29 Nov 2017 15:20:00 +0100

> Uniformize STMicroelectronics copyrights header
> 
> Signed-off-by: Benjamin Gaignard 

Applied.


Re: [PATCH] watchdog: stm32: Fix copyright

2017-11-29 Thread Alexandre Torgue



On 11/29/2017 03:27 PM, Benjamin Gaignard wrote:

Uniformize STMicroelectronics copyrights header

Signed-off-by: Benjamin Gaignard 
CC: Yannick Fertre 
---
  drivers/watchdog/stm32_iwdg.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c
index be64a8699de3..c6c8351f1598 100644
--- a/drivers/watchdog/stm32_iwdg.c
+++ b/drivers/watchdog/stm32_iwdg.c
@@ -1,8 +1,8 @@
  /*
   * Driver for STM32 Independent Watchdog
   *
- * Copyright (C) Yannick Fertre 2017
- * Author: Yannick Fertre 
+ * Copyright (C) STMicroelectronics SA 2017
+ * Author: Yannick Fertre  for STMicroelectronics.
   *
   * This driver is based on tegra_wdt.c
   *


Acked-by: Alexandre TORGUE 


Re: [PATCH v2 27/35] irqchip: Andestech Internal Vector Interrupt Controller driver

2017-11-29 Thread Greentime Hu
Hi, Marc:

2017-11-28 17:37 GMT+08:00 Marc Zyngier :
> On 27/11/17 12:28, Greentime Hu wrote:
>> +static void ativic32_ack_irq(struct irq_data *data)
>> +{
>> + __nds32__mtsr_dsb(1 << data->hwirq, NDS32_SR_INT_PEND2);
>
> Consider writing (1 << data->hwirq) as BIT(data->hwirq).

Thanks for this suggestion. I will modify it in the next version patch.

>> +}
>> +
>> +static void ativic32_mask_irq(struct irq_data *data)
>> +{
>> + unsigned long int_mask2 = __nds32__mfsr(NDS32_SR_INT_MASK2);
>> + __nds32__mtsr_dsb(int_mask2 & (~(1 << data->hwirq)), 
>> NDS32_SR_INT_MASK2);
>
> Same here.

Thanks for this suggestion. I will modify it in the next version patch.

>> +}
>> +
>> +static void ativic32_mask_ack_irq(struct irq_data *data)
>> +{
>> + unsigned long int_mask2 = __nds32__mfsr(NDS32_SR_INT_MASK2);
>> + __nds32__mtsr_dsb(int_mask2 & (~(1 << data->hwirq)), 
>> NDS32_SR_INT_MASK2);
>> + __nds32__mtsr_dsb((1 << data->hwirq), NDS32_SR_INT_PEND2);
>
> This is effectively MASK+ACK, so you're better off just writing it as
> such. And since there is no advantage in your implementation in having
> MASK_ACK over MASK+ACK, I suggest you remove this function completely,
> and rely on the core code which will call them in sequence.

I think mask_ack is still better than mask + ack because we don't need
to do two function call.
We can save a prologue and a epilogue. It will benefit interrupt latency.

>> +
>> +}
>> +
>> +static void ativic32_unmask_irq(struct irq_data *data)
>> +{
>> + unsigned long int_mask2 = __nds32__mfsr(NDS32_SR_INT_MASK2);
>> + __nds32__mtsr_dsb(int_mask2 | (1 << data->hwirq), NDS32_SR_INT_MASK2);
>
> Same BIT() here.
>
Thanks for this suggestion. I will modify it in the next version patch.

>> +}
>> +
>> +static struct irq_chip ativic32_chip = {
>> + .name = "ativic32",
>> + .irq_ack = ativic32_ack_irq,
>> + .irq_mask = ativic32_mask_irq,
>> + .irq_mask_ack = ativic32_mask_ack_irq,
>> + .irq_unmask = ativic32_unmask_irq,
>> +};
>> +
>> +static unsigned int __initdata nivic_map[6] = { 6, 2, 10, 16, 24, 32 };
>> +
>> +static struct irq_domain *root_domain;
>> +static int ativic32_irq_domain_map(struct irq_domain *id, unsigned int virq,
>> +   irq_hw_number_t hw)
>> +{
>> +
>> + unsigned long int_trigger_type;
>> + int_trigger_type = __nds32__mfsr(NDS32_SR_INT_TRIGGER);
>> + if (int_trigger_type & (1 << hw))
>
> And here.
>
Thanks for this suggestion. I will modify it in the next version patch.

>> + irq_set_chip_and_handler(virq, _chip, 
>> handle_edge_irq);
>> + else
>> + irq_set_chip_and_handler(virq, _chip, 
>> handle_level_irq);
>
> Since you do not express the trigger in DT, you need to tell the core
> about it by calling irqd_set_trigger_type() with the right setting.
>

Since the comments say so, I will add ativic32_set_type() for irq_set_type()
in the next version patch.

/*
 * Must only be called inside irq_chip.irq_set_type() functions.
 */
static inline void irqd_set_trigger_type(struct irq_data *d, u32 type)
{
__irqd_to_state(d) &= ~IRQD_TRIGGER_MASK;
__irqd_to_state(d) |= type & IRQD_TRIGGER_MASK;
}

It will be like this.
static int ativic32_set_type(struct irq_data *data, unsigned int flow_type)
{
irqd_set_trigger_type(data, flow_type);
return IRQ_SET_MASK_OK;
}

>> +
>> + return 0;
>> +}
>> +
>> +static struct irq_domain_ops ativic32_ops = {
>> + .map = ativic32_irq_domain_map,
>> + .xlate = irq_domain_xlate_onecell
>> +};
>> +
>> +static int get_intr_src(void)
>
> I'm not sure "int" is the best return type here. I suspect something
> unsigned would be preferable, or even the irq_hw_number_t type.

Thanks for this suggestion. I will modify it in the next version patch.

>> +{
>> + return ((__nds32__mfsr(NDS32_SR_ITYPE)_mskVECTOR) >> 
>> ITYPE_offVECTOR)
>
> Spaces around '&'.
>
Thanks for this suggestion. I will modify it in the next version patch.

>> + - NDS32_VECTOR_offINTERRUPT;
>> +}
>> +
>> +asmlinkage void asm_do_IRQ(struct pt_regs *regs)
>> +{
>> + int hwirq = get_intr_src();
>
> irq_hw_number_t.
>
Thanks for this suggestion. I will modify it in the next version patch.

>> + handle_domain_irq(root_domain, hwirq, regs);
>> +}
>> +
>> +int __init ativic32_init_irq(struct device_node *node, struct device_node 
>> *parent)
>> +{
>> + unsigned long int_vec_base, nivic;
>> +
>> + if (WARN(parent, "non-root ativic32 are not supported"))
>> + return -EINVAL;
>> +
>> + int_vec_base = __nds32__mfsr(NDS32_SR_IVB);
>> +
>> + if (((int_vec_base & IVB_mskIVIC_VER) >> IVB_offIVIC_VER) == 0)
>> + panic("Unable to use atcivic32 for this cpu.\n");
>> +
>> + nivic = (int_vec_base & IVB_mskNIVIC) >> IVB_offNIVIC;
>> + if (nivic >= (sizeof nivic_map / sizeof nivic_map[0]))
>
> This should be:
> if (nivic >= ARRAY_SIZE(NIVIC_MAP))
>

[PATCH 4/5] MIPS: Execute any partial write of the last register with PTRACE_SETREGSET

2017-11-29 Thread Maciej W. Rozycki
Fix a commit d614fd58a283 ("mips/ptrace: Preserve previous registers for 
short regset write") bug and allow the last register requested with a 
ptrace(2) PTRACE_SETREGSET call to be partially written if supplied this 
way by the caller, like with other register sets.

Cc: sta...@vger.kernel.org # v4.11+
Fixes: d614fd58a283 ("mips/ptrace: Preserve previous registers for short regset 
write")
Signed-off-by: Maciej W. Rozycki 
---
 arch/mips/kernel/ptrace.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

linux-mips-nt-prfpreg-count.diff
Index: linux-sfr-test/arch/mips/kernel/ptrace.c
===
--- linux-sfr-test.orig/arch/mips/kernel/ptrace.c   2017-11-21 
22:12:00.0 +
+++ linux-sfr-test/arch/mips/kernel/ptrace.c2017-11-21 22:13:13.47197 
+
@@ -484,7 +484,7 @@ static int fpr_set_msa(struct task_struc
int err;
 
BUILD_BUG_ON(sizeof(fpr_val) != sizeof(elf_fpreg_t));
-   for (i = 0; i < NUM_FPU_REGS && *count >= sizeof(elf_fpreg_t); i++) {
+   for (i = 0; i < NUM_FPU_REGS && *count > 0; i++) {
err = user_regset_copyin(pos, count, kbuf, ubuf,
 _val, i * sizeof(elf_fpreg_t),
 (i + 1) * sizeof(elf_fpreg_t));


Re: [kernel-hardening] Re: [PATCH v5 next 5/5] net: modules: use request_module_cap() to load 'netdev-%s' modules

2017-11-29 Thread Geo Kozey
> From: Linus Torvalds 
> Sent: Wed Nov 29 01:17:05 CET 2017
> To: Geo Kozey 
> Subject: Re: [kernel-hardening] Re: [PATCH v5 next 5/5] net: modules: use 
> request_module_cap() to load 'netdev-%s' modules
> 
> 
> On Tue, Nov 28, 2017 at 3:51 PM, Linus Torvalds
>  wrote:
> >
> > So a patch that avoids breaking existing users, but also doesn't
> > actually improve anything for existing users, simply shouldn't be part
> > of the mainline kernel.
> 
> Just to clarify: maybe it ends up being truly impossible to make the
> default be more restrictive. The default certainly won't be the most
> restrictive option.
> 
> But at the same time, if people can't even be bothered to try to
> improve the general case, and only do things that you have to opt in
> for, it really isn't much of an improvement. We had this whole
> "opt-in" discussion for another thread entirely, and it basically
> didn't improve anything for anybody for the better half of a decade.
> 
> Hardening that only works for special cases isn't hardening at all. It
> will just mean that 99+% of all kernel developers won't see the
> fallout at all.
> 
> Yes, something like Android may be 99% of the devices, but it's a very
> small portion of the core developer base because the hardware is all
> locked down, and it's an even smaller portion of the usage patterns.
> 
> So I can see some people say "We can use this for android and protect
> the 99%". But if it then is basically invisible to the rest of the
> user base, it means that all those servers etc aren't getting the kind
> of protection they should have.
> 
> Just to take that DCCP thing as an example: being a module wasn't what
> made it vulnerable. It would have been vulnerable compiled in too.
> What made it vulnerable was that the DCCP code simply isn't widely
> enough used and tested, and basically barely on life support. And it
> was available much too widely despite that.
> 
> So all this is about is to make for a smaller attack surface.
> 
> But if it turns out that we can make the attack surface smaller by
> simply white-listing a few modules that we know are actively used and
> feel better about the quality of, that makes for a much smaller attack
> surface _too_. And it does so in general, without having to set some
> flag that 99% of all MIS people won't even really know about.
> 
> So that's why I want people to look at a different approach. Yes, the
> opt-in model means that by default nothing changes. That protects
> against the whole "oops, we don't break user space". But it has a huge
> downside.
> 
> The model that I am a proponent of is to take a softer approach
> initially: don't forbid module loading (because that breaks users),
> but instead _warn_ about non-root module loading. And then we can
> start fixing the cases that we find.
> 
> See? This is *exactly* the same thing that the user-mode access thing
> was about. Hardening people need to get over their "hard rules"
> mindset. We don't kill processes or forbid them from doing things that
> might be bad. We start by warning about them, to see what "might be
> bad" cases are actually normal, and not actually bad at all. And then
> we use that information to guide our notion of what should actually
> trigger a stronger response.
> 
>Linus

I followed your last week discussion and I agreed with your arguments so
it's unfortunate for me that You put me on the opposite side. I agree that
improving kernel code by finding and fixing existing bugs is the ultimate
goal for security features.

On the other hand the whole debugging process (find, report, wait for fix)
takes a lot of time and work and is basically never ending story. That's why
some kind of prevention which protects users in-between is important for
users which priorities maximal security on their systems.

I like your idea about printing warnings. What about:

modules_autoload_mode =0 (default)
_warn_ about non-root module loading and allow

modules_autoload_mode =1
_warn_ about non-root module loading and deny

This way we can start fixing found cases and also give users option for 
proactive
defense at the same time without breaking general public. The end game (after
a lot of fixes) would be to make 0 and 1 mostly indistinguishable from security
perspective. 

Yours sincerely

G. K.


[PATCH] ARC: Enable machine_desc->init_per_cpu for non-SMP configs

2017-11-29 Thread Alexey Brodkin
As of today we assumed that "machine_desc->init_per_cpu" calls
are only usable on SMP systems when we want to run some piece of
code on early boot for each and every core, I guess assumption was
we have "machine_desc->init_early" for single-core cases where
the one and only master core can do all the things.

But it turned out for platforms which might be both UP and SMP it
might be benificial to use "init_per_cpu" for both UP and SMP cases
with which we achieve 2 things simultaneously:
 1) Exactly the same one code will be used for UP for
things required to be done on each an every core regardless if it's
a master and the only core in UP system or any other slave core in SMP
setup.
 1) There will be no "ifdef CONFIG_SMP" around "init_per_cpu".

Signed-off-by: Alexey Brodkin 
---
 arch/arc/include/asm/mach_desc.h | 2 --
 arch/arc/kernel/irq.c| 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arc/include/asm/mach_desc.h b/arch/arc/include/asm/mach_desc.h
index c28e6c347b49..871f3cb16af9 100644
--- a/arch/arc/include/asm/mach_desc.h
+++ b/arch/arc/include/asm/mach_desc.h
@@ -34,9 +34,7 @@ struct machine_desc {
const char  *name;
const char  **dt_compat;
void(*init_early)(void);
-#ifdef CONFIG_SMP
void(*init_per_cpu)(unsigned int);
-#endif
void(*init_machine)(void);
void(*init_late)(void);
 
diff --git a/arch/arc/kernel/irq.c b/arch/arc/kernel/irq.c
index 538b36afe89e..62b185057c04 100644
--- a/arch/arc/kernel/irq.c
+++ b/arch/arc/kernel/irq.c
@@ -31,10 +31,10 @@ void __init init_IRQ(void)
/* a SMP H/w block could do IPI IRQ request here */
if (plat_smp_ops.init_per_cpu)
plat_smp_ops.init_per_cpu(smp_processor_id());
+#endif
 
if (machine_desc->init_per_cpu)
machine_desc->init_per_cpu(smp_processor_id());
-#endif
 }
 
 /*
-- 
2.11.0



[PATCH net 2/3] rxrpc: Fix ACK generation from the connection event processor

2017-11-29 Thread David Howells
Repeat terminal ACKs and now terminal ACKs are now generated from the
connection event processor rather from call handling as this allows us to
discard client call structures as soon as possible and free up the channel
for a follow on call.

However, in ACKs so generated, the additional information trailer is
malformed because the padding that's meant to be in the middle isn't
included in what's transmitted.

Fix it so that the 3 bytes of padding are included in the transmission.

Further, the trailer is misaligned because of the padding, so assigment to
the u16 and u32 fields inside it might cause problems on some arches, so
fix this by breaking the padding and the trailer out of the packed struct.

(This also deals with potential compiler weirdies where some of the nested
structs are packed and some aren't).

The symptoms can be seen in wireshark as terminal DUPLICATE or IDLE ACK
packets in which the Max MTU, Interface MTU and rwind fields have weird
values and the Max Packets field is apparently missing.

Reported-by: Jeffrey Altman 
Signed-off-by: David Howells 
---

 net/rxrpc/conn_event.c |   50 
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/net/rxrpc/conn_event.c b/net/rxrpc/conn_event.c
index 9e9a8db1bc9c..4ca11be6be3c 100644
--- a/net/rxrpc/conn_event.c
+++ b/net/rxrpc/conn_event.c
@@ -30,22 +30,18 @@ static void rxrpc_conn_retransmit_call(struct 
rxrpc_connection *conn,
struct rxrpc_skb_priv *sp = skb ? rxrpc_skb(skb) : NULL;
struct rxrpc_channel *chan;
struct msghdr msg;
-   struct kvec iov;
+   struct kvec iov[3];
struct {
struct rxrpc_wire_header whdr;
union {
-   struct {
-   __be32 code;
-   } abort;
-   struct {
-   struct rxrpc_ackpacket ack;
-   u8 padding[3];
-   struct rxrpc_ackinfo info;
-   };
+   __be32 abort_code;
+   struct rxrpc_ackpacket ack;
};
} __attribute__((packed)) pkt;
+   struct rxrpc_ackinfo ack_info;
size_t len;
-   u32 serial, mtu, call_id;
+   int ioc;
+   u32 serial, mtu, call_id, padding;
 
_enter("%d", conn->debug_id);
 
@@ -66,6 +62,13 @@ static void rxrpc_conn_retransmit_call(struct 
rxrpc_connection *conn,
msg.msg_controllen = 0;
msg.msg_flags   = 0;
 
+   iov[0].iov_base = 
+   iov[0].iov_len  = sizeof(pkt.whdr);
+   iov[1].iov_base = 
+   iov[1].iov_len  = 3;
+   iov[2].iov_base = _info;
+   iov[2].iov_len  = sizeof(ack_info);
+
pkt.whdr.epoch  = htonl(conn->proto.epoch);
pkt.whdr.cid= htonl(conn->proto.cid);
pkt.whdr.callNumber = htonl(call_id);
@@ -80,8 +83,10 @@ static void rxrpc_conn_retransmit_call(struct 
rxrpc_connection *conn,
len = sizeof(pkt.whdr);
switch (chan->last_type) {
case RXRPC_PACKET_TYPE_ABORT:
-   pkt.abort.code  = htonl(chan->last_abort);
-   len += sizeof(pkt.abort);
+   pkt.abort_code  = htonl(chan->last_abort);
+   iov[0].iov_len += sizeof(pkt.abort_code);
+   len += sizeof(pkt.abort_code);
+   ioc = 1;
break;
 
case RXRPC_PACKET_TYPE_ACK:
@@ -94,13 +99,19 @@ static void rxrpc_conn_retransmit_call(struct 
rxrpc_connection *conn,
pkt.ack.serial  = htonl(skb ? sp->hdr.serial : 0);
pkt.ack.reason  = skb ? RXRPC_ACK_DUPLICATE : 
RXRPC_ACK_IDLE;
pkt.ack.nAcks   = 0;
-   pkt.info.rxMTU  = htonl(rxrpc_rx_mtu);
-   pkt.info.maxMTU = htonl(mtu);
-   pkt.info.rwind  = htonl(rxrpc_rx_window_size);
-   pkt.info.jumbo_max  = htonl(rxrpc_rx_jumbo_max);
+   ack_info.rxMTU  = htonl(rxrpc_rx_mtu);
+   ack_info.maxMTU = htonl(mtu);
+   ack_info.rwind  = htonl(rxrpc_rx_window_size);
+   ack_info.jumbo_max  = htonl(rxrpc_rx_jumbo_max);
pkt.whdr.flags  |= RXRPC_SLOW_START_OK;
-   len += sizeof(pkt.ack) + sizeof(pkt.info);
+   padding = 0;
+   iov[0].iov_len += sizeof(pkt.ack);
+   len += sizeof(pkt.ack) + 3 + sizeof(ack_info);
+   ioc = 3;
break;
+
+   default:
+   return;
}
 
/* Resync with __rxrpc_disconnect_call() and check that the last call
@@ -110,9 +121,6 @@ static void rxrpc_conn_retransmit_call(struct 
rxrpc_connection *conn,
if (READ_ONCE(chan->last_call) != call_id)
return;
 
-   

[PATCH v3 36/36] net/mvpp2: Replace tasklet with softirq hrtimer

2017-11-29 Thread Anna-Maria Gleixner
From: Thomas Gleixner 

The tx_done_tasklet tasklet is used in invoke the hrtimer
(mvpp2_hr_timer_cb) in softirq context. This can be also achieved without
the tasklet but with HRTIMER_MODE_SOFT as hrtimer mode.

Signed-off-by: Thomas Gleixner 
Signed-off-by: Anna-Maria Gleixner 
Cc: Thomas Petazzoni 
Cc: net...@vger.kernel.org
Cc: "David S. Miller" 
---
 drivers/net/ethernet/marvell/mvpp2.c | 62 +++-
 1 file changed, 25 insertions(+), 37 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2.c 
b/drivers/net/ethernet/marvell/mvpp2.c
index 6c20e811f973..ab77f68c7fba 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -901,9 +901,8 @@ struct mvpp2_pcpu_stats {
 /* Per-CPU port control */
 struct mvpp2_port_pcpu {
struct hrtimer tx_done_timer;
+   struct net_device *dev;
bool timer_scheduled;
-   /* Tasklet for egress finalization */
-   struct tasklet_struct tx_done_tasklet;
 };
 
 struct mvpp2_queue_vector {
@@ -6181,46 +6180,34 @@ static void mvpp2_link_event(struct net_device *dev)
}
 }
 
-static void mvpp2_timer_set(struct mvpp2_port_pcpu *port_pcpu)
-{
-   ktime_t interval;
-
-   if (!port_pcpu->timer_scheduled) {
-   port_pcpu->timer_scheduled = true;
-   interval = MVPP2_TXDONE_HRTIMER_PERIOD_NS;
-   hrtimer_start(_pcpu->tx_done_timer, interval,
- HRTIMER_MODE_REL_PINNED);
-   }
-}
-
-static void mvpp2_tx_proc_cb(unsigned long data)
+static enum hrtimer_restart mvpp2_hr_timer_cb(struct hrtimer *timer)
 {
-   struct net_device *dev = (struct net_device *)data;
-   struct mvpp2_port *port = netdev_priv(dev);
-   struct mvpp2_port_pcpu *port_pcpu = this_cpu_ptr(port->pcpu);
+   struct net_device *dev;
+   struct mvpp2_port *port;
+   struct mvpp2_port_pcpu *port_pcpu;
unsigned int tx_todo, cause;
 
+   port_pcpu = container_of(timer, struct mvpp2_port_pcpu, tx_done_timer);
+   dev = port_pcpu->dev;
+
if (!netif_running(dev))
-   return;
+   return HRTIMER_NORESTART;
+
port_pcpu->timer_scheduled = false;
+   port = netdev_priv(dev);
 
/* Process all the Tx queues */
cause = (1 << port->ntxqs) - 1;
tx_todo = mvpp2_tx_done(port, cause, smp_processor_id());
 
/* Set the timer in case not all the packets were processed */
-   if (tx_todo)
-   mvpp2_timer_set(port_pcpu);
-}
-
-static enum hrtimer_restart mvpp2_hr_timer_cb(struct hrtimer *timer)
-{
-   struct mvpp2_port_pcpu *port_pcpu = container_of(timer,
-struct mvpp2_port_pcpu,
-tx_done_timer);
-
-   tasklet_schedule(_pcpu->tx_done_tasklet);
+   if (tx_todo && !port_pcpu->timer_scheduled) {
+   port_pcpu->timer_scheduled = true;
+   hrtimer_forward_now(_pcpu->tx_done_timer,
+   MVPP2_TXDONE_HRTIMER_PERIOD_NS);
 
+   return HRTIMER_RESTART;
+   }
return HRTIMER_NORESTART;
 }
 
@@ -6698,7 +6685,12 @@ static int mvpp2_tx(struct sk_buff *skb, struct 
net_device *dev)
txq_pcpu->count > 0) {
struct mvpp2_port_pcpu *port_pcpu = this_cpu_ptr(port->pcpu);
 
-   mvpp2_timer_set(port_pcpu);
+   if (!port_pcpu->timer_scheduled) {
+   port_pcpu->timer_scheduled = true;
+   hrtimer_start(_pcpu->tx_done_timer,
+ MVPP2_TXDONE_HRTIMER_PERIOD_NS,
+ HRTIMER_MODE_REL_PINNED_SOFT);
+   }
}
 
return NETDEV_TX_OK;
@@ -7127,7 +7119,6 @@ static int mvpp2_stop(struct net_device *dev)
 
hrtimer_cancel(_pcpu->tx_done_timer);
port_pcpu->timer_scheduled = false;
-   tasklet_kill(_pcpu->tx_done_tasklet);
}
}
mvpp2_cleanup_rxqs(port);
@@ -7918,13 +7909,10 @@ static int mvpp2_port_probe(struct platform_device 
*pdev,
port_pcpu = per_cpu_ptr(port->pcpu, cpu);
 
hrtimer_init(_pcpu->tx_done_timer, CLOCK_MONOTONIC,
-HRTIMER_MODE_REL_PINNED);
+HRTIMER_MODE_REL_PINNED_SOFT);
port_pcpu->tx_done_timer.function = mvpp2_hr_timer_cb;
port_pcpu->timer_scheduled = false;
-
-   tasklet_init(_pcpu->tx_done_tasklet,
-mvpp2_tx_proc_cb,
-(unsigned long)dev);
+   port_pcpu->dev = dev;
}
 

[PATCH net-next 0/3] rxrpc: Fixes

2017-11-29 Thread David Howells

Here are three patches for AF_RXRPC.  One removes some whitespace, one
fixes terminal ACK generation and the third makes a couple of places
actually use the timeout value just determined rather than ignoring it.

The patches can be found here also:


http://git.kernel.org/cgit/linux/kernel/git/dhowells/linux-fs.git/log/?h=rxrpc-fixes

Tagged thusly:

git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git
rxrpc-fixes-20171129

David
---
David Howells (2):
  rxrpc: Clean up whitespace
  rxrpc: Fix ACK generation from the connection event processor

Gustavo A. R. Silva (1):
  rxrpc: Fix variable overwrite


 net/rxrpc/call_event.c  |4 ++--
 net/rxrpc/conn_event.c  |   50 +++
 net/rxrpc/conn_object.c |2 +-
 net/rxrpc/input.c   |4 ++--
 net/rxrpc/sendmsg.c |2 +-
 5 files changed, 35 insertions(+), 27 deletions(-)



[PATCH net 1/3] rxrpc: Clean up whitespace

2017-11-29 Thread David Howells
Clean up some whitespace from rxrpc.

Signed-off-by: David Howells 
---

 net/rxrpc/call_event.c  |2 +-
 net/rxrpc/conn_object.c |2 +-
 net/rxrpc/input.c   |4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
index bda952ffe6a6..555274ddc514 100644
--- a/net/rxrpc/call_event.c
+++ b/net/rxrpc/call_event.c
@@ -426,7 +426,7 @@ void rxrpc_process_call(struct work_struct *work)
next = call->expect_rx_by;
 
 #define set(T) { t = READ_ONCE(T); if (time_before(t, next)) next = t; }
-   
+
set(call->expect_req_by);
set(call->expect_term_by);
set(call->ack_at);
diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c
index 1aad04a32d5e..c628351eb900 100644
--- a/net/rxrpc/conn_object.c
+++ b/net/rxrpc/conn_object.c
@@ -424,7 +424,7 @@ void rxrpc_service_connection_reaper(struct work_struct 
*work)
if (earliest != now + MAX_JIFFY_OFFSET) {
_debug("reschedule reaper %ld", (long)earliest - (long)now);
ASSERT(time_after(earliest, now));
-   rxrpc_set_service_reap_timer(rxnet, earliest);  
+   rxrpc_set_service_reap_timer(rxnet, earliest);
}
 
while (!list_empty()) {
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 23a5e61d8f79..6fc61400337f 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -976,7 +976,7 @@ static void rxrpc_input_call_packet(struct rxrpc_call *call,
rxrpc_reduce_call_timer(call, expect_rx_by, now,
rxrpc_timer_set_for_normal);
}
-   
+
switch (sp->hdr.type) {
case RXRPC_PACKET_TYPE_DATA:
rxrpc_input_data(call, skb, skew);
@@ -1213,7 +1213,7 @@ void rxrpc_data_ready(struct sock *udp_sk)
goto reupgrade;
conn->service_id = sp->hdr.serviceId;
}
-   
+
if (sp->hdr.callNumber == 0) {
/* Connection-level packet */
_debug("CONN %p {%d}", conn, conn->debug_id);



[PATCH v3 18/36] hrtimer: Make hrtimer_force_reprogramm() unconditionally available

2017-11-29 Thread Anna-Maria Gleixner
hrtimer_force_reprogram() needs to be available unconditionally for softirq
based hrtimers. Move the function and all required struct members out of
the CONFIG_HIGH_RES_TIMERS #ifdef.

There is no functional change because hrtimer_force_reprogram() is only
invoked when hrtimer_cpu_base.hres_active is true and
CONFIG_HIGH_RES_TIMERS=y.

Making it unconditional increases the text size for the
CONFIG_HIGH_RES_TIMERS=n case slightly, but avoids replication of that code
for the upcoming softirq based hrtimers support. Most of the code gets
eliminated in the CONFIG_HIGH_RES_TIMERS=n case by the compiler.

Signed-off-by: Anna-Maria Gleixner 
---
 kernel/time/hrtimer.c | 58 +--
 1 file changed, 28 insertions(+), 30 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index c9173699b549..0502b8b6e0bc 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -513,34 +513,6 @@ static inline int hrtimer_hres_active(void)
return __hrtimer_hres_active(this_cpu_ptr(_bases));
 }
 
-/* High resolution timer related functions */
-#ifdef CONFIG_HIGH_RES_TIMERS
-
-/*
- * High resolution timer enabled ?
- */
-static bool hrtimer_hres_enabled __read_mostly  = true;
-unsigned int hrtimer_resolution __read_mostly = LOW_RES_NSEC;
-EXPORT_SYMBOL_GPL(hrtimer_resolution);
-
-/*
- * Enable / Disable high resolution mode
- */
-static int __init setup_hrtimer_hres(char *str)
-{
-   return (kstrtobool(str, _hres_enabled) == 0);
-}
-
-__setup("highres=", setup_hrtimer_hres);
-
-/*
- * hrtimer_high_res_enabled - query, if the highres mode is enabled
- */
-static inline int hrtimer_is_hres_enabled(void)
-{
-   return hrtimer_hres_enabled;
-}
-
 /*
  * Reprogram the event source with checking both queues for the
  * next event
@@ -581,6 +553,34 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, 
int skip_equal)
tick_program_event(cpu_base->expires_next, 1);
 }
 
+/* High resolution timer related functions */
+#ifdef CONFIG_HIGH_RES_TIMERS
+
+/*
+ * High resolution timer enabled ?
+ */
+static bool hrtimer_hres_enabled __read_mostly  = true;
+unsigned int hrtimer_resolution __read_mostly = LOW_RES_NSEC;
+EXPORT_SYMBOL_GPL(hrtimer_resolution);
+
+/*
+ * Enable / Disable high resolution mode
+ */
+static int __init setup_hrtimer_hres(char *str)
+{
+   return (kstrtobool(str, _hres_enabled) == 0);
+}
+
+__setup("highres=", setup_hrtimer_hres);
+
+/*
+ * hrtimer_high_res_enabled - query, if the highres mode is enabled
+ */
+static inline int hrtimer_is_hres_enabled(void)
+{
+   return hrtimer_hres_enabled;
+}
+
 /*
  * Retrigger next event is called after clock was set
  *
@@ -639,8 +639,6 @@ void clock_was_set_delayed(void)
 
 static inline int hrtimer_is_hres_enabled(void) { return 0; }
 static inline void hrtimer_switch_to_hres(void) { }
-static inline void
-hrtimer_force_reprogram(struct hrtimer_cpu_base *base, int skip_equal) { }
 static inline void retrigger_next_event(void *arg) { }
 
 #endif /* CONFIG_HIGH_RES_TIMERS */
-- 
2.11.0



Re: [PATCH v6 04/11] x86: define IA32_FEATUE_CONTROL.SGX_LC

2017-11-29 Thread Jarkko Sakkinen
On Wed, Nov 29, 2017 at 12:21:41AM +0200, Jarkko Sakkinen wrote:
> On Tue, Nov 28, 2017 at 02:00:03PM -0800, Sean Christopherson wrote:
> > What about SGX_LC_ENABLE?  The title in the MSR section of the SDM is
> > "SGX Launch Control Enable", and it's more consistent with the other
> > bits defined in feature control.  I'd also prefer that name for the
> > actual #define too, SGX_LAUNCH_CONTROL_ENABLE is overly verbose IMO.
> 
> This is a bit ugly name but it is also very clear:
> 
>   FEATURE_CONTROL_SGX_LEPUBKEYHASH_WRITE_ENABLE
> 
> Just pushed update to the le branch. SGX_LC_ENABLE is a nice short name
> but it does not reflect the semantics.
> 
> Maybe we could combine these and name it as
> 
>   FEATURE_CONTROL_SGX_LC_WRITE_ENABLE
> 
> It is not as ugly and is very clear what it does.

I ended up with FEATURE_CONTROL_SGX_LC_WR. I think that is fairly
reasonable name for bit 17.

/Jarkko


[PATCH v3 25/36] hrtimer: Use irqsave/irqrestore around __run_hrtimer()

2017-11-29 Thread Anna-Maria Gleixner
__run_hrtimer() is called with the hrtimer_cpu_base.lock held and
interrupts disabled. Before invoking the timer callback the base lock is
dropped, but interrupts stay disabled.

The upcoming support for softirq based hrtimers requires that interrupts
are enabled before the timer callback is invoked.

To avoid code duplication, take hrtimer_cpu_base.lock with
raw_spin_lock_irqsave(flags) at the call site and hand in the flags as
argument. So raw_spin_unlock_irqrestore() before the callback invocation
will either keep interrupts disabled in interrupt context or restore to
interrupt enabled state when called from softirq context.

Suggested-by: Peter Zijlstra 
Signed-off-by: Anna-Maria Gleixner 
---
 kernel/time/hrtimer.c | 31 ++-
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 1bb369b1accf..afb54c47e81c 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1161,7 +1161,8 @@ EXPORT_SYMBOL_GPL(hrtimer_active);
 
 static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base,
  struct hrtimer_clock_base *base,
- struct hrtimer *timer, ktime_t *now)
+ struct hrtimer *timer, ktime_t *now,
+ unsigned long flags)
 {
enum hrtimer_restart (*fn)(struct hrtimer *);
int restart;
@@ -1196,11 +1197,11 @@ static void __run_hrtimer(struct hrtimer_cpu_base 
*cpu_base,
 * protected against migration to a different CPU even if the lock
 * is dropped.
 */
-   raw_spin_unlock(_base->lock);
+   raw_spin_unlock_irqrestore(_base->lock, flags);
trace_hrtimer_expire_entry(timer, now);
restart = fn(timer);
trace_hrtimer_expire_exit(timer);
-   raw_spin_lock(_base->lock);
+   raw_spin_lock_irq(_base->lock);
 
/*
 * Note: We clear the running state after enqueue_hrtimer and
@@ -1228,7 +1229,8 @@ static void __run_hrtimer(struct hrtimer_cpu_base 
*cpu_base,
base->running = NULL;
 }
 
-static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t 
now)
+static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t 
now,
+unsigned long flags)
 {
struct hrtimer_clock_base *base;
unsigned int active = cpu_base->active_bases;
@@ -1259,7 +1261,7 @@ static void __hrtimer_run_queues(struct hrtimer_cpu_base 
*cpu_base, ktime_t now)
if (basenow < hrtimer_get_softexpires_tv64(timer))
break;
 
-   __run_hrtimer(cpu_base, base, timer, );
+   __run_hrtimer(cpu_base, base, timer, , flags);
}
}
 }
@@ -1274,13 +1276,14 @@ void hrtimer_interrupt(struct clock_event_device *dev)
 {
struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(_bases);
ktime_t expires_next, now, entry_time, delta;
+   unsigned long flags;
int retries = 0;
 
BUG_ON(!cpu_base->hres_active);
cpu_base->nr_events++;
dev->next_event = KTIME_MAX;
 
-   raw_spin_lock(_base->lock);
+   raw_spin_lock_irqsave(_base->lock, flags);
entry_time = now = hrtimer_update_base(cpu_base);
 retry:
cpu_base->in_hrtirq = 1;
@@ -1293,7 +1296,7 @@ void hrtimer_interrupt(struct clock_event_device *dev)
 */
cpu_base->expires_next = KTIME_MAX;
 
-   __hrtimer_run_queues(cpu_base, now);
+   __hrtimer_run_queues(cpu_base, now, flags);
 
/* Reevaluate the clock bases for the next expiry */
expires_next = __hrtimer_get_next_event(cpu_base);
@@ -1303,7 +1306,7 @@ void hrtimer_interrupt(struct clock_event_device *dev)
 */
cpu_base->expires_next = expires_next;
cpu_base->in_hrtirq = 0;
-   raw_spin_unlock(_base->lock);
+   raw_spin_unlock_irqrestore(_base->lock, flags);
 
/* Reprogramming necessary ? */
if (!tick_program_event(expires_next, 0)) {
@@ -1324,7 +1327,7 @@ void hrtimer_interrupt(struct clock_event_device *dev)
 * Acquire base lock for updating the offsets and retrieving
 * the current time.
 */
-   raw_spin_lock(_base->lock);
+   raw_spin_lock_irqsave(_base->lock, flags);
now = hrtimer_update_base(cpu_base);
cpu_base->nr_retries++;
if (++retries < 3)
@@ -1337,7 +1340,8 @@ void hrtimer_interrupt(struct clock_event_device *dev)
 */
cpu_base->nr_hangs++;
cpu_base->hang_detected = 1;
-   raw_spin_unlock(_base->lock);
+   raw_spin_unlock_irqrestore(_base->lock, flags);
+
delta = ktime_sub(now, entry_time);
if ((unsigned int)delta > cpu_base->max_hang_time)
cpu_base->max_hang_time = (unsigned int) delta;
@@ -1379,6 +1383,7 @@ static inline void __hrtimer_peek_ahead_timers(void) { }
 void 

[PATCH v3 24/36] hrtimer: Split __hrtimer_get_next_event()

2017-11-29 Thread Anna-Maria Gleixner
Preparatory patch for softirq based hrtimers to avoid code duplication. No
functional change.

Signed-off-by: Anna-Maria Gleixner 
---
 kernel/time/hrtimer.c | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index c1412e9dcfea..1bb369b1accf 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -459,13 +459,13 @@ __next_base(struct hrtimer_cpu_base *cpu_base, unsigned 
int *active)
while ((base = __next_base((cpu_base), &(active
 
 #if defined(CONFIG_NO_HZ_COMMON) || defined(CONFIG_HIGH_RES_TIMERS)
-static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base)
+static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base,
+unsigned int active,
+ktime_t expires_next)
 {
struct hrtimer_clock_base *base;
-   unsigned int active = cpu_base->active_bases;
-   ktime_t expires, expires_next = KTIME_MAX;
+   ktime_t expires;
 
-   cpu_base->next_timer = NULL;
for_each_active_base(base, cpu_base, active) {
struct timerqueue_node *next;
struct hrtimer *timer;
@@ -487,6 +487,18 @@ static ktime_t __hrtimer_get_next_event(struct 
hrtimer_cpu_base *cpu_base)
expires_next = 0;
return expires_next;
 }
+
+static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base)
+{
+   unsigned int active = cpu_base->active_bases;
+   ktime_t expires_next = KTIME_MAX;
+
+   cpu_base->next_timer = NULL;
+
+   expires_next = __hrtimer_next_event_base(cpu_base, active, 
expires_next);
+
+   return expires_next;
+}
 #endif
 
 static inline ktime_t hrtimer_update_base(struct hrtimer_cpu_base *base)
-- 
2.11.0



[PATCH v3 23/36] hrtimer: Split hrtimer_start_range_ns()

2017-11-29 Thread Anna-Maria Gleixner
Preparatory patch for softirq based hrtimers to avoid code duplication. No
functional change.

Signed-off-by: Anna-Maria Gleixner 
---
 kernel/time/hrtimer.c | 44 
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 771f3463502e..c1412e9dcfea 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -907,22 +907,11 @@ static inline ktime_t hrtimer_update_lowres(struct 
hrtimer *timer, ktime_t tim,
return tim;
 }
 
-/**
- * hrtimer_start_range_ns - (re)start an hrtimer
- * @timer: the timer to be added
- * @tim:   expiry time
- * @delta_ns:  "slack" range for the timer
- * @mode:  timer mode: absolute (HRTIMER_MODE_ABS) or
- * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED)
- */
-void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
-   u64 delta_ns, const enum hrtimer_mode mode)
+static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
+   u64 delta_ns, const enum hrtimer_mode mode,
+   struct hrtimer_clock_base *base)
 {
-   struct hrtimer_clock_base *base, *new_base;
-   unsigned long flags;
-   int leftmost;
-
-   base = lock_hrtimer_base(timer, );
+   struct hrtimer_clock_base *new_base;
 
/* Remove an active timer from the queue: */
remove_hrtimer(timer, base, true);
@@ -937,12 +926,27 @@ void hrtimer_start_range_ns(struct hrtimer *timer, 
ktime_t tim,
/* Switch the timer base, if necessary: */
new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED);
 
-   leftmost = enqueue_hrtimer(timer, new_base, mode);
-   if (!leftmost)
-   goto unlock;
+   return enqueue_hrtimer(timer, new_base, mode);
+}
+/**
+ * hrtimer_start_range_ns - (re)start an hrtimer
+ * @timer: the timer to be added
+ * @tim:   expiry time
+ * @delta_ns:  "slack" range for the timer
+ * @mode:  timer mode: absolute (HRTIMER_MODE_ABS) or
+ * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED)
+ */
+void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
+   u64 delta_ns, const enum hrtimer_mode mode)
+{
+   struct hrtimer_clock_base *base;
+   unsigned long flags;
+
+   base = lock_hrtimer_base(timer, );
+
+   if (__hrtimer_start_range_ns(timer, tim, delta_ns, mode, base))
+   hrtimer_reprogram(timer);
 
-   hrtimer_reprogram(timer);
-unlock:
unlock_hrtimer_base(timer, );
 }
 EXPORT_SYMBOL_GPL(hrtimer_start_range_ns);
-- 
2.11.0



[PATCH v3 05/36] hrtimer: Fix hrtimer function description

2017-11-29 Thread Anna-Maria Gleixner
The hrtimer_start[_range_ns]() starts a timer reliable on this CPU only
when HRTIMER_MODE_PINNED is set. Furthermore the HRTIMER_MODE_PINNED mode
is not considered, when a hrtimer is initialized.

Signed-off-by: Anna-Maria Gleixner 
---
 include/linux/hrtimer.h | 6 +++---
 kernel/time/hrtimer.c   | 9 +
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 931ce9c89c93..4e6a8841dcbe 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -361,11 +361,11 @@ extern void hrtimer_start_range_ns(struct hrtimer *timer, 
ktime_t tim,
   u64 range_ns, const enum hrtimer_mode mode);
 
 /**
- * hrtimer_start - (re)start an hrtimer on the current CPU
+ * hrtimer_start - (re)start an hrtimer
  * @timer: the timer to be added
  * @tim:   expiry time
- * @mode:  expiry mode: absolute (HRTIMER_MODE_ABS) or
- * relative (HRTIMER_MODE_REL)
+ * @mode:  timer mode: absolute (HRTIMER_MODE_ABS) or
+ * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED)
  */
 static inline void hrtimer_start(struct hrtimer *timer, ktime_t tim,
 const enum hrtimer_mode mode)
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 74a64db375d1..ae7b29c4e03e 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -924,12 +924,12 @@ static inline ktime_t hrtimer_update_lowres(struct 
hrtimer *timer, ktime_t tim,
 }
 
 /**
- * hrtimer_start_range_ns - (re)start an hrtimer on the current CPU
+ * hrtimer_start_range_ns - (re)start an hrtimer
  * @timer: the timer to be added
  * @tim:   expiry time
  * @delta_ns:  "slack" range for the timer
- * @mode:  expiry mode: absolute (HRTIMER_MODE_ABS) or
- * relative (HRTIMER_MODE_REL)
+ * @mode:  timer mode: absolute (HRTIMER_MODE_ABS) or
+ * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED)
  */
 void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
u64 delta_ns, const enum hrtimer_mode mode)
@@ -1107,7 +1107,8 @@ static void __hrtimer_init(struct hrtimer *timer, 
clockid_t clock_id,
  * hrtimer_init - initialize a timer to the given clock
  * @timer: the timer to be initialized
  * @clock_id:  the clock to be used
- * @mode:  timer mode abs/rel
+ * @mode:  timer mode: absolute (HRTIMER_MODE_ABS) or
+ * relative (HRTIMER_MODE_REL); pinned is not considered here!
  */
 void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
  enum hrtimer_mode mode)
-- 
2.11.0



[PATCH v3 03/36] hrtimer: Fix kerneldoc for struct hrtimer_cpu_base

2017-11-29 Thread Anna-Maria Gleixner
The sequence '/**' marks the start of a struct description. Add the
missing second asterisk. While at it adapt the ordering of the struct
members to the struct definition and document the purpose of
expires_next more precisely.

Signed-off-by: Anna-Maria Gleixner 
---
 include/linux/hrtimer.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 79b2a8d29d8c..b3a382be8db0 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -144,7 +144,7 @@ enum  hrtimer_base_type {
HRTIMER_MAX_CLOCK_BASES,
 };
 
-/*
+/**
  * struct hrtimer_cpu_base - the per cpu clock bases
  * @lock:  lock protecting the base and associated clock bases
  * and timers
@@ -153,12 +153,12 @@ enum  hrtimer_base_type {
  * @cpu:   cpu number
  * @active_bases:  Bitfield to mark bases with active timers
  * @clock_was_set_seq: Sequence counter of clock was set events
- * @expires_next:  absolute time of the next event which was scheduled
- * via clock_set_next_event()
- * @next_timer:Pointer to the first expiring timer
  * @in_hrtirq: hrtimer_interrupt() is currently executing
  * @hres_active:   State of high resolution mode
  * @hang_detected: The last hrtimer interrupt detected a hang
+ * @expires_next:  absolute time of the next event, is required for remote
+ * hrtimer enqueue
+ * @next_timer:Pointer to the first expiring timer
  * @nr_events: Total number of hrtimer interrupt events
  * @nr_retries:Total number of hrtimer interrupt retries
  * @nr_hangs:  Total number of hrtimer interrupt hangs
-- 
2.11.0



[PATCH v3 08/36] tracing/hrtimer: Take all clock bases and modes into account

2017-11-29 Thread Anna-Maria Gleixner
So far only CLOCK_MONOTONIC and CLOCK_REALTIME were taken into account as
well as HRTIMER_MODE_ABS/REL in hrtimer_init tracepoint. The query for
detecting timer mode ABS or REL is not valid, since the introduction of
HRTIMER_MODE_PINNED.

HRTIMER_MODE_PINNED is not evaluated in hrtimer_init() call. But for the
sake of completeness print all given modes.

Signed-off-by: Anna-Maria Gleixner 
---
 include/trace/events/timer.h | 20 
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/include/trace/events/timer.h b/include/trace/events/timer.h
index 16e305e69f34..c6f728037c53 100644
--- a/include/trace/events/timer.h
+++ b/include/trace/events/timer.h
@@ -136,6 +136,20 @@ DEFINE_EVENT(timer_class, timer_cancel,
TP_ARGS(timer)
 );
 
+#define decode_clockid(type)   \
+   __print_symbolic(type,  \
+   { CLOCK_REALTIME,   "CLOCK_REALTIME"},  \
+   { CLOCK_MONOTONIC,  "CLOCK_MONOTONIC"   },  \
+   { CLOCK_BOOTTIME,   "CLOCK_BOOTTIME"},  \
+   { CLOCK_TAI,"CLOCK_TAI" })
+
+#define decode_hrtimer_mode(mode)  \
+   __print_symbolic(mode,  \
+   { HRTIMER_MODE_ABS, "ABS"   },  \
+   { HRTIMER_MODE_REL, "REL"   },  \
+   { HRTIMER_MODE_ABS_PINNED,  "ABS|PINNED"},  \
+   { HRTIMER_MODE_REL_PINNED,  "REL|PINNED"})
+
 /**
  * hrtimer_init - called when the hrtimer is initialized
  * @hrtimer:   pointer to struct hrtimer
@@ -162,10 +176,8 @@ TRACE_EVENT(hrtimer_init,
),
 
TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
- __entry->clockid == CLOCK_REALTIME ?
-   "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
- __entry->mode == HRTIMER_MODE_ABS ?
-   "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
+ decode_clockid(__entry->clockid),
+ decode_hrtimer_mode(__entry->mode))
 );
 
 /**
-- 
2.11.0



[PATCH v3 06/36] hrtimer: Ensure POSIX compliance (relative CLOCK_REALTIME hrtimers)

2017-11-29 Thread Anna-Maria Gleixner
POSIX specification defines, that relative CLOCK_REALTIME timers are not
affected by clock modifications. Those timers have to use CLOCK_MONOTONIC
to ensure POSIX compliance.

The introduction of the additional mode HRTIMER_MODE_PINNED broke this
requirement for pinned timers. There is no user space visible impact
because user space timers are not using the pinned mode, but for
consistency reasons this needs to be fixed.

Check whether the mode has the HRTIMER_MODE_REL bit set instead of
comparing with HRTIMER_MODE_ABS.


Fixes: 597d0275736d ("timers: Framework for identifying pinned timers")
Signed-off-by: Anna-Maria Gleixner 
---
 kernel/time/hrtimer.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index ae7b29c4e03e..9945ea6b0e5c 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1095,7 +1095,12 @@ static void __hrtimer_init(struct hrtimer *timer, 
clockid_t clock_id,
 
cpu_base = raw_cpu_ptr(_bases);
 
-   if (clock_id == CLOCK_REALTIME && mode != HRTIMER_MODE_ABS)
+   /*
+* Posix magic: Relative CLOCK_REALTIME timers are not affected by
+* clock modifications, so they needs to become CLOCK_MONOTONIC to
+* ensure Posix compliance.
+*/
+   if (clock_id == CLOCK_REALTIME && mode & HRTIMER_MODE_REL)
clock_id = CLOCK_MONOTONIC;
 
base = hrtimer_clockid_to_base(clock_id);
-- 
2.11.0



[PATCH v3 04/36] hrtimer: Cleanup clock argument in schedule_hrtimeout_range_clock()

2017-11-29 Thread Anna-Maria Gleixner
schedule_hrtimeout_range_clock() uses an integer for the clock id
instead of the predefined type "clockid_t". The ID of the clock is
indicated in hrtimer code as clock_id. Therefore change the name of
the variable as well to make it consistent.

While at it, clean up the description for the function parameters clock_id
and mode. The clock modes and the clock ids are not restricted as the
comment suggests. Fix the mode description as well for the callers of
schedule_hrtimeout_range_clock().

No functional change.

Signed-off-by: Anna-Maria Gleixner 
---
 include/linux/hrtimer.h |  2 +-
 kernel/time/hrtimer.c   | 12 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index b3a382be8db0..931ce9c89c93 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -462,7 +462,7 @@ extern int schedule_hrtimeout_range(ktime_t *expires, u64 
delta,
 extern int schedule_hrtimeout_range_clock(ktime_t *expires,
  u64 delta,
  const enum hrtimer_mode mode,
- int clock);
+ clockid_t clock_id);
 extern int schedule_hrtimeout(ktime_t *expires, const enum hrtimer_mode mode);
 
 /* Soft interrupt function to run the hrtimer queues: */
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index aee49c0c58b9..74a64db375d1 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1662,12 +1662,12 @@ void __init hrtimers_init(void)
  * schedule_hrtimeout_range_clock - sleep until timeout
  * @expires:   timeout value (ktime_t)
  * @delta: slack in expires timeout (ktime_t)
- * @mode:  timer mode, HRTIMER_MODE_ABS or HRTIMER_MODE_REL
- * @clock: timer clock, CLOCK_MONOTONIC or CLOCK_REALTIME
+ * @mode:  timer mode
+ * @clock_id:  timer clock to be used
  */
 int __sched
 schedule_hrtimeout_range_clock(ktime_t *expires, u64 delta,
-  const enum hrtimer_mode mode, int clock)
+  const enum hrtimer_mode mode, clockid_t clock_id)
 {
struct hrtimer_sleeper t;
 
@@ -1688,7 +1688,7 @@ schedule_hrtimeout_range_clock(ktime_t *expires, u64 
delta,
return -EINTR;
}
 
-   hrtimer_init_on_stack(, clock, mode);
+   hrtimer_init_on_stack(, clock_id, mode);
hrtimer_set_expires_range_ns(, *expires, delta);
 
hrtimer_init_sleeper(, current);
@@ -1710,7 +1710,7 @@ schedule_hrtimeout_range_clock(ktime_t *expires, u64 
delta,
  * schedule_hrtimeout_range - sleep until timeout
  * @expires:   timeout value (ktime_t)
  * @delta: slack in expires timeout (ktime_t)
- * @mode:  timer mode, HRTIMER_MODE_ABS or HRTIMER_MODE_REL
+ * @mode:  timer mode
  *
  * Make the current task sleep until the given expiry time has
  * elapsed. The routine will return immediately unless
@@ -1749,7 +1749,7 @@ EXPORT_SYMBOL_GPL(schedule_hrtimeout_range);
 /**
  * schedule_hrtimeout - sleep until timeout
  * @expires:   timeout value (ktime_t)
- * @mode:  timer mode, HRTIMER_MODE_ABS or HRTIMER_MODE_REL
+ * @mode:  timer mode
  *
  * Make the current task sleep until the given expiry time has
  * elapsed. The routine will return immediately unless
-- 
2.11.0



Re: [PATCH] net: stmmac: dwmac-sun8i: fix allwinner,leds-active-low handling

2017-11-29 Thread Maxime Ripard
On Wed, Nov 29, 2017 at 04:37:12PM +0100, Andrew Lunn wrote:
> On Wed, Nov 29, 2017 at 10:02:40AM +0100, Corentin Labbe wrote:
> > On Tue, Nov 28, 2017 at 06:38:26PM +0100, Andrew Lunn wrote:
> > > On Tue, Nov 28, 2017 at 05:48:22PM +0100, Corentin Labbe wrote:
> > > > The driver expect "allwinner,leds-active-low" to be in PHY node, but
> > > > the binding doc expect it to be in MAC node.
> > > > 
> > > > Since all board DT use it also in MAC node, the driver need to search
> > > > allwinner,leds-active-low in MAC node.
> > > 
> > > Hi Corentin
> > > 
> > > I'm having trouble working out how this worked before. This is code
> > > you moved around, when adding external/internal MDIOs. But the very
> > > first version of this driver code used priv->plat->phy_node. Did that
> > > somehow point to the MAC node when the internal PHY is used? Or has it
> > > been broken all the time?
> > > 
> > 
> > Hello
> > 
> 
> > Since this feature control only when the activity LED need to blink,
> > nobody see that it was broken.
> 
> Hi Corentin
> 
> So it never worked?
> 
> If it never worked, moving the DT properties into the PHY node, where
> they belong, won't introduce a regression :-)

That's even truer since it's been queued for 4.15 which hasn't been
released yet.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


signature.asc
Description: PGP signature


Re: [PATCH 3/5] media: i2c: Add TDA1997x HDMI receiver driver

2017-11-29 Thread Tim Harvey
On Thu, Nov 23, 2017 at 12:08 AM, Hans Verkuil  wrote:
> On 11/23/2017 05:27 AM, Tim Harvey wrote:
>> On Mon, Nov 20, 2017 at 7:39 AM, Hans Verkuil  wrote:
>>> Hi Tim,
>>>
>>> Some more review comments:
>>>
>>> On 11/09/2017 07:45 PM, Tim Harvey wrote:
 Add support for the TDA1997x HDMI receivers.
>> 
 + */
 +struct color_matrix_coefs {
 + const char *name;
 + /* Input offsets */
 + s16 offint1;
 + s16 offint2;
 + s16 offint3;
 + /* Coeficients */
 + s16 p11coef;
 + s16 p12coef;
 + s16 p13coef;
 + s16 p21coef;
 + s16 p22coef;
 + s16 p23coef;
 + s16 p31coef;
 + s16 p32coef;
 + s16 p33coef;
 + /* Output offsets */
 + s16 offout1;
 + s16 offout2;
 + s16 offout3;
 +};
 +
 +enum {
 + ITU709_RGBLIMITED,
 + ITU709_RGBFULL,
 + ITU601_RGBLIMITED,
 + ITU601_RGBFULL,
 + RGBLIMITED_RGBFULL,
 + RGBLIMITED_ITU601,
 + RGBFULL_ITU601,
>>>
>>> This can't be right.
>>> ITU709_RGBLIMITED
>>> You have these conversions:
>>>
>>> ITU709_RGBFULL
>>> ITU601_RGBFULL
>>> RGBLIMITED_RGBFULL
>>> RGBLIMITED_ITU601
>>> RGBFULL_ITU601
>>> RGBLIMITED_ITU709
>>> RGBFULL_ITU709
>>>
>>> I.e. on the HDMI receiver side you can receive RGB full/limited or 
>>> ITU601/709.
>>> On the output side you have RGB full or ITU601/709.
>>>
>>> So something like ITU709_RGBLIMITED makes no sense.
>>>
>>
>> I misunderstood the V4L2_CID_DV_RX_RGB_RANGE thinking that it allowed
>> you to configure the output range. If output to the SoC is only ever
>> full quant range for RGB then I can drop the
>> ITU709_RGBLIMITED/ITU601_RGBLIMITED conversions.
>
> Output for RGB is always full range. The reason is simply that the V4L2 API
> has no way of selecting the quantization range it wants to receive. I made
> a patch for that a few years back, but there really is no demand for it (yet).
> Userspace expects full range RGB and limited range YUV.
>
>>
>> However, If the output is YUV how do I know if I need to convert to
>> ITU709 or ITU601 and what are my conversion matrices for
>> RGBLIMITED_ITU709/RGBFULL_ITU709?
>
> You can choose yourself whether you convert to YUV 601 or 709. I would
> recommend to use 601 for SDTV resolutions (i.e. width/height <= 720x576)
> and 709 for HDTV.
>
> I made a little program that calculates the values for RGB lim/full to
> YUV 601/709:
>
> -
> #include 
> #include 
>
> #define COEFF(v, r) ((v) * (r) * 16.0)
>
> static const double bt601[3][3] = {
> { COEFF(0.299, 219),   COEFF(0.587, 219),   COEFF(0.114, 219)   },
> { COEFF(-0.1687, 224), COEFF(-0.3313, 224), COEFF(0.5, 224) },
> { COEFF(0.5, 224), COEFF(-0.4187, 224), COEFF(-0.0813, 224) },
> };
> static const double rec709[3][3] = {
> { COEFF(0.2126, 219),  COEFF(0.7152, 219),  COEFF(0.0722, 219)  },
> { COEFF(-0.1146, 224), COEFF(-0.3854, 224), COEFF(0.5, 224) },
> { COEFF(0.5, 224), COEFF(-0.4542, 224), COEFF(-0.0458, 224) },
> };
>
> int main(int argc, char **argv)
> {
> int i, j;
> int mapi[] = { 0, 2, 1 };
> int mapj[] = { 1, 0, 2 };
>
> printf("rgb full -> 601\n");
> printf("0, 0, 0,\n");
> for (i = 0; i < 3; i++) {
> for (j = 0; j < 3; j++) {
> printf("%5d, ",  (int)(0.5 + 
> bt601[mapi[i]][mapj[j]]));
> }
> printf("\n");
> }
> printf("  256,  2048,  2048,\n\n");
>
> printf("rgb lim -> 601\n");
> printf(" -256,  -256,  -256,\n");
> for (i = 0; i < 3; i++) {
> for (j = 0; j < 3; j++) {
> printf("%5d, ",  (int)(0.5 + 255.0 / 219.0 * 
> bt601[mapi[i]][mapj[j]]));
> }
> printf("\n");
> }
> printf("  256,  2048,  2048,\n\n");
>
> printf("rgb full -> 709\n");
> printf("0, 0, 0,\n");
> for (i = 0; i < 3; i++) {
> for (j = 0; j < 3; j++) {
> printf("%5d, ",  (int)(0.5 + 
> rec709[mapi[i]][mapj[j]]));
> }
> printf("\n");
> }
> printf("  256,  2048,  2048,\n\n");
>
> printf("rgb lim -> 709\n");
> printf(" -256,  -256,  -256,\n");
> for (i = 0; i < 3; i++) {
> for (j = 0; j < 3; j++) {
> printf("%5d, ",  (int)(0.5 + 255.0 / 219.0 * 
> rec709[mapi[i]][mapj[j]]));
> }
> printf("\n");
> }
> printf("  256,  2048,  2048,\n\n");
> return 0;
> }
> -
>
> This should give you the needed matrices. It's up to you whether to keep the
> existing matrices for 601 or replace them with these. Probably 

Re: [PATCH V15 00/22] mmc: Add Command Queue support

2017-11-29 Thread Ulf Hansson
Hi Adrian,

On 29 November 2017 at 14:40, Adrian Hunter  wrote:
> Hi
>
> Here is V15 of the hardware command queue patches without the software
> command queue patches, now using blk-mq and now with blk-mq support for
> non-CQE I/O.

I have applied patches 1->19 for next.  Deferring patch 21->23 for a while.

For those patches that was more or less the same as in v14, I added Linus' ack.

Hopefully we get some help for the community to test this series on
different HW (and I will be checking kernelci's boot reports). I
haven't added Bartlomiej's tested-by and neither Linus' (because of
the changes that has been made), so I hoping that will happen sooner
or later.

Moreover, I will gladly add more peoples acks/reviewed-by and
tested-by tags, at any point during this release cycle.

Thanks and kind regards
Uffe

>
> V14 included a number of fixes to existing code, changes to default to
> blk-mq, and adds patches to remove legacy code.
>
> HW CMDQ offers 25% - 50% better random multi-threaded I/O.  I see a slight
> 2% drop in sequential read speed but no change to sequential write.
>
> Non-CQE blk-mq showed a 3% decrease in sequential read performance.  This
> seemed to be coming from the inferior latency of running work items compared
> with a dedicated thread.  Hacking blk-mq workqueue to be unbound reduced the
> performance degradation from 3% to 1%.
>
> While we should look at changing blk-mq to give better workqueue performance,
> a bigger gain is likely to be made by adding a new host API to enable the
> next already-prepared request to be issued directly from within ->done()
> callback of the current request.
>
> Changes since V14:
>   mmc: block: Fix missing blk_put_request()
>   mmc: block: Check return value of blk_get_request()
>   mmc: core: Do not leave the block driver in a suspended state
>   mmc: block: Ensure that debugfs files are removed
> Dropped because they have been applied
>   mmc: block: Use data timeout in card_busy_detect()
> Replaced by other patches
>   mmc: block: Add blk-mq support
> Rename mmc_blk_ss_read() to mmc_blk_read_single()
> Add more error handling to single sector read
> Let mmc_blk_mq_complete_rq() cater for requests already "updated" by 
> recovery
> Rename mmc_blk_mq_acct_req_done() to mmc_blk_mq_dec_in_flight()
> Add comments about synchronization
> Add comment about not dispatching in parallel
> Add comment about the queue depth
>   mmc: block: Add CQE support
> Add coment about CQE queue depth
>   mmc: block: blk-mq: Add support for direct completion
> Rename mmc_queue_direct_complete() to mmc_host_done_complete()
> Rename MMC_CAP_DIRECT_COMPLETE to MMC_CAP_DONE_COMPLETE
>   mmc: block: blk-mq: Separate card polling from recovery
> Ensure to report gen_err as an error
>   mmc: block: Make card_busy_detect() accumulate all response error bits
> Patch moved later in the patch set and adjusted accordingly
>   mmc: block: blk-mq: Check error bits and save the exception bit when 
> polling card busy
> Adjusted due to patch re-ordering
>   mmc: block: Check the timeout correctly in card_busy_detect()
> New patch.
>   mmc: block: Add timeout_clks when calculating timeout
> New patch.
>   mmc: block: Reduce polling timeout from 10 minutes to 10 seconds
> New patch.
>
> Changes since V13:
>   mmc: block: Fix missing blk_put_request()
> New patch.
>   mmc: block: Check return value of blk_get_request()
> New patch.
>   mmc: core: Do not leave the block driver in a suspended state
> New patch.
>   mmc: block: Ensure that debugfs files are removed
> New patch.
>   mmc: block: No need to export mmc_cleanup_queue()
> New patch.
>   mmc: block: Simplify cleaning up the queue
> New patch.
>   mmc: block: Use data timeout in card_busy_detect()
> New patch.
>   mmc: block: Check for transfer state in card_busy_detect()
> New patch.
>   mmc: block: Make card_busy_detect() accumulate all response error bits
> New patch.
>   mmc: core: Make mmc_pre_req() and mmc_post_req() available
> New patch.
>   mmc: core: Add parameter use_blk_mq
> Default to y
>   mmc: block: Add blk-mq support
> Wrap blk_mq_end_request / blk_end_request_all
> Rename mmc_blk_rw_recovery -> mmc_blk_mq_rw_recovery
> Additional parentheses to '==' expressions
> Use mmc_pre_req() / mmc_post_req()
> Fix missing tuning release on error after mmc_start_request()
> Expand comment about timeouts
> Allow for possibility that the queue is quiesced when removing
> Ensure complete_work is flushed when removing
>   mmc: block: Add CQE support
> Additional parentheses to '==' expressions
>   

Re: [PATCH] quota: Check for register_shrinker() failure.

2017-11-29 Thread Jan Kara
On Wed 29-11-17 14:42:51, Michal Hocko wrote:
> On Wed 29-11-17 22:34:50, Tetsuo Handa wrote:
> > register_shrinker() might return -ENOMEM error since Linux 3.12.
> > Call panic() as with other failure checks in this function if
> > register_shrinker() failed.
> > 
> > Signed-off-by: Tetsuo Handa 
> 
> Fixes: 1d3d4437eae1 ("vmscan: per-node deferred work")
> 
> > Cc: Jan Kara 
> > Cc: Michal Hocko 
> 
> From my very limited understanding of the code this looks correct.
> FWIW
> Reviewed-by: Michal Hocko 

Thanks. Added to my tree.

Honza
-- 
Jan Kara 
SUSE Labs, CR


Re: [PATCH 1/2] watchdog: introduce watchdog.open_timeout commandline parameter

2017-11-29 Thread Guenter Roeck
On Wed, Nov 29, 2017 at 11:56:57AM +0100, Rasmus Villemoes wrote:
> On 2017-11-28 23:14, Guenter Roeck wrote:
> > On Tue, Nov 28, 2017 at 11:35:49AM +0100, Rasmus Villemoes wrote:
> >>
> >> The unit is milliseconds rather than seconds because that covers more
> >> use cases. For example, one can effectively disable the kernel handling
> >> by setting the open_timeout to 1 ms. There are also customers with very
> >> strict requirements that may want to set the open_timeout to something
> >> like 4500 ms, which combined with a hardware watchdog that must be
> >> pinged every 250 ms ensures userspace is up no more than 5 seconds after
> >> the bootloader hands control to the kernel (250 ms until the driver gets
> >> registered and kernel handling starts, 4500 ms of kernel handling, and
> >> then up to 250 ms from the last ping until userspace takes over).
> > 
> > This is quite vague, especially since it doesn't count the time from
> > boot to starting the watchdog driver,
> 
> My example is bad, and I now realize one cannot really get such precise
> guarantees. But the example _did_ actually account for the time from
> boot to device registration - it allowed 250 ms for the kernel to get
> that far.
> 
> which can vary even across boots.
> > Why not make it specific, for example by adjusting the open timeout with
> > ktime_get_boot_ns() ?
> 
> If by "boot" we mean the moment the bootloader hands control to the
> kernel, ktime_get_boot_ns() doesn't give that either - at best, it gives
> an approximation of the time since timekeeping_init(), but it's not very
> accurate that early (I simply injected printks of ktime_get_boot_ns at
> various places in init/main.c and timestamped the output lines). If it
> overshoots, we'd be subtracting more of the allowance than we should,
> and I don't think we have any way of knowing when that happens or to
> correct for it. So I'd rather keep the code simple and let it count from
> the time the watchdog framework knows about the device, which is also
> around the time when the kernel's timekeeping is reasonably accurate.
> 
We should try to make things as accurate as possible. "It won't be perfect"
is not an argument against that.

> > I would actually make it even more specific and calculate the open
> > timeout such that the system would reboot after open_timeout, not
> > after . Any reason for not doing that ?
> > The upside would be more accuracy, and I don't really see a downside.
> 
> I don't think it would be that much more accurate - we schedule the
> pings at a frequency of half the max_hw_heartbeat_ms==$x, with the
> current code we'd get rebooted somewhere between [open_deadline + $x/2,
> open_deadline + $x], and subtracting $x from the open_timeout that would
> become [open_deadline - $x/2, open_deadline]. I'd rather not have the
> reboot happen before the open_deadline. Sure, we could subtract $x/2
> instead. Then there's the case where ->max_hw_heartbeat_ms is not set,
> so we have to use ->timeout for $x, and then there's the case of $x (or
> $x/2) being greater than $open_timeout. I'd really like to keep the code
> simple. If it helps, I'd be happy to document the exact semantics of the
> open_timeout with a nice ascii art timeline.
> 
It was not much of a problem to get that right after a watchdog was opened,
by timing pings accordingly such that the HW times out when it should.
It should not be that hard to get it working for the pre-open case as well.

Guenter


Re: [PATCH 2/5] media: dt-bindings: Add bindings for TDA1997X

2017-11-29 Thread Tim Harvey
On Thu, Nov 23, 2017 at 12:25 AM, Sakari Ailus  wrote:
> On Wed, Nov 22, 2017 at 08:37:04PM -0800, Tim Harvey wrote:
>> On Tue, Nov 21, 2017 at 11:36 PM, Sakari Ailus  wrote:
>> > Hi Tim,
>> >
>> > On Thu, Nov 09, 2017 at 10:45:33AM -0800, Tim Harvey wrote:
>> >> Cc: Rob Herring 
>> >> Signed-off-by: Tim Harvey 
>> >> ---
>> >> v3:
>> >>  - fix typo
>> >>
>> >> v2:
>> >>  - add vendor prefix and remove _ from vidout-portcfg
>> >>  - remove _ from labels
>> >>  - remove max-pixel-rate property
>> >>  - describe and provide example for single output port
>> >>  - update to new audio port bindings
>> >> ---
>> >>  .../devicetree/bindings/media/i2c/tda1997x.txt | 179 
>> >> +
>> >>  1 file changed, 179 insertions(+)
>> >>  create mode 100644 
>> >> Documentation/devicetree/bindings/media/i2c/tda1997x.txt
>> >>
>> >> diff --git a/Documentation/devicetree/bindings/media/i2c/tda1997x.txt 
>> >> b/Documentation/devicetree/bindings/media/i2c/tda1997x.txt
>> >> new file mode 100644
>> >> index 000..dd37f14
>> >> --- /dev/null
>> >> +++ b/Documentation/devicetree/bindings/media/i2c/tda1997x.txt
>> >> @@ -0,0 +1,179 @@
>> >> +Device-Tree bindings for the NXP TDA1997x HDMI receiver
>> >> +
>> >> +The TDA19971/73 are HDMI video receivers.
>> >> +
>> >> +The TDA19971 Video port output pins can be used as follows:
>> >> + - RGB 8bit per color (24 bits total): R[11:4] B[11:4] G[11:4]
>> >> + - YUV444 8bit per color (24 bits total): Y[11:4] Cr[11:4] Cb[11:4]
>> >> + - YUV422 semi-planar 8bit per component (16 bits total): Y[11:4] 
>> >> CbCr[11:4]
>> >> + - YUV422 semi-planar 10bit per component (20 bits total): Y[11:2] 
>> >> CbCr[11:2]
>> >> + - YUV422 semi-planar 12bit per component (24 bits total): - Y[11:0] 
>> >> CbCr[11:0]
>> >> + - YUV422 BT656 8bit per component (8 bits total): YCbCr[11:4] (2-cycles)
>> >> + - YUV422 BT656 10bit per component (10 bits total): YCbCr[11:2] 
>> >> (2-cycles)
>> >> + - YUV422 BT656 12bit per component (12 bits total): YCbCr[11:0] 
>> >> (2-cycles)
>> >> +
>> >> +The TDA19973 Video port output pins can be used as follows:
>> >> + - RGB 12bit per color (36 bits total): R[11:0] B[11:0] G[11:0]
>> >> + - YUV444 12bit per color (36 bits total): Y[11:0] Cb[11:0] Cr[11:0]
>> >> + - YUV422 semi-planar 12bit per component (24 bits total): Y[11:0] 
>> >> CbCr[11:0]
>> >> + - YUV422 BT656 12bit per component (12 bits total): YCbCr[11:0] 
>> >> (2-cycles)
>> >> +
>> >> +The Video port output pins are mapped via 4-bit 'pin groups' allowing
>> >> +for a variety of connection possibilities including swapping pin order 
>> >> within
>> >> +pin groups. The video_portcfg device-tree property consists of register 
>> >> mapping
>> >> +pairs which map a chip-specific VP output register to a 4-bit pin group. 
>> >> If
>> >> +the pin group needs to be bit-swapped you can use the *_S pin-group 
>> >> defines.
>> >> +
>> >> +Required Properties:
>> >> + - compatible  :
>> >> +  - "nxp,tda19971" for the TDA19971
>> >> +  - "nxp,tda19973" for the TDA19973
>> >> + - reg : I2C slave address
>> >> + - interrupts  : The interrupt number
>> >> + - DOVDD-supply: Digital I/O supply
>> >> + - DVDD-supply : Digital Core supply
>> >> + - AVDD-supply : Analog supply
>> >> + - nxp,vidout-portcfg  : array of pairs mapping VP output pins to pin 
>> >> groups.
>> >> +
>> >> +Optional Properties:
>> >> + - nxp,audout-format   : DAI bus format: "i2s" or "spdif".
>> >> + - nxp,audout-width: width of audio output data bus (1-4).
>> >> + - nxp,audout-layout   : data layout (0=AP0 used, 1=AP0/AP1/AP2/AP3 
>> >> used).
>> >> + - nxp,audout-mclk-fs  : Multiplication factor between stream rate and 
>> >> codec
>> >> + mclk.
>> >> +
>> >> +The device node must contain one 'port' child node for its digital output
>> >> +video port, in accordance with the video interface bindings defined in
>> >> +Documentation/devicetree/bindings/media/video-interfaces.txt.
>> >
>> > Could you add that this port has one endpoint node as well? (Unless you
>> > support multiple, that is.)
>>
>> Sure... will clarify as:
>>
>> The device node must contain one endpoint 'port' child node for its
>> digital output
>> video port, in accordance with the video interface bindings defined in
>> Documentation/devicetree/bindings/media/video-interfaces.txt.
>
> I think it'd be clearer if you just add "The port node shall contain one
> endpoint child node".

ok

>
>>
>> >> +
>> >> +Optional Endpoint Properties:
>> >> +  The following three properties are defined in video-interfaces.txt and
>> >> +  are valid for source endpoints only:
>> >
>> > Transmitters? Don't you have an endpoint only in the port representing the
>> > transmitter?
>>
>> I'm not usre what you mean.
>>
>> The TDA1997x is an HDMI receiver meaning it receives HDMI and decodes
>> it to a parallel video bus. 

Re: [PATCH v2 05/18] drm/sun4i: Force the mixer rate at 150MHz

2017-11-29 Thread Maxime Ripard
On Tue, Nov 28, 2017 at 10:56:31PM +0100, Jernej Škrabec wrote:
> Hi!
> 
> Dne torek, 28. november 2017 ob 09:58:26 CET je Maxime Ripard napisal(a):
> > On Mon, Nov 27, 2017 at 05:07:04PM +0100, Jernej Škrabec wrote:
> > > Hi Maxime,
> > > 
> > > Dne ponedeljek, 27. november 2017 ob 16:41:29 CET je Maxime Ripard 
> napisal(a):
> > > > It seems like the mixer can only run properly when clocked at 150MHz. In
> > > > order to have something more robust than simply a fire-and-forget
> > > > assigned-clocks-rate, let's put that in the code.
> > > > 
> > > > Signed-off-by: Maxime Ripard 
> > > > ---
> > > > 
> > > >  drivers/gpu/drm/sun4i/sun8i_mixer.c | 7 +++
> > > >  1 file changed, 7 insertions(+)
> > > > 
> > > > diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c
> > > > b/drivers/gpu/drm/sun4i/sun8i_mixer.c index cb193c5f1686..c0cdccf772a2
> > > > 100644
> > > > --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c
> > > > +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c
> > > > @@ -315,6 +315,13 @@ static int sun8i_mixer_bind(struct device *dev,
> > > > struct
> > > > device *master, }
> > > > 
> > > > clk_prepare_enable(mixer->mod_clk);
> > > > 
> > > > +   /*
> > > > +* It seems that we need to enforce that rate for whatever
> > > > +* reason for the mixer to be functional. Make sure it's the
> > > > +* case.
> > > > +*/
> > > > +   clk_set_rate(mixer->mod_clk, 15000);
> > > > +
> > > 
> > > H3 mixer works at much higher rate and if we want to support tv out, it
> > > must be dividable by 432 MHz, so either 432 MHz or maybe even 864 MHz.
> > > 
> > > We talked about that few months ago.
> > > 
> > > I guess this should be read from mixer configuration structure.
> > 
> > That works for me. Actually, I didn't need it at all for the LVDS
> > output on the A83t, the default seems to work just fine. Do you know
> > what it's related to? Maybe we can make that a bit more dynamic?
> 
> There doesn't seem to be any rule to determine which frequency is best, 
> except 
> on H3. Obviously, it must be high enough to process data for current 
> resolution, which means 150 MHz should be just enough for 1920x1080@60Hz. I 
> guess we should just check BSP configuration and use same rate since AW 
> engineers may know something we don't.

Yeah, that makes sense. And the fact that it's in the kernel allows us
to change for something smarter when we want (and if we need) to.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


signature.asc
Description: PGP signature


Re: [PATCH v5 next 1/5] modules:capabilities: add request_module_cap()

2017-11-29 Thread Theodore Ts'o
On Wed, Nov 29, 2017 at 09:50:14AM -0500, David Miller wrote:
> From: Alan Cox 
> Date: Wed, 29 Nov 2017 13:46:12 +
> 
> > I really don't care what the module loading rules end up with and
> > whether we add CAP_SYS_YET_ANOTHER_MEANINGLESS_FLAG but what is
> > actually needed is to properly incorporate it into securiy ruiles
> > for whatever LSM you are using.
> 
> I'm surprised we're not using the SHA1 hashes or whatever we compute
> for the modules to make sure we are loading the foo.ko that we expect
> to be.

We do have signed modules.  But this won't help us if the user is
using a distro kernel which has compiled some module which is known to
be unmaintained which everyone in the know *expects* to have 0-day
bugs, such as DCCP.  That's because the DCCP module is signed.

We could fix this by adding to the signature used for module signing
to include the module name, so that the bad guy can't rename dccp.ko
to be ppp.ko, I suppose

> All of this capability stuff seems to dance a circle around the
> problem rather than fix it.

Half the problem here is that with containers, people are changing the
security model, because they want to let untrusted users have "root",
without really having "root".  Part of the fundamental problem is that
there are some well-meaning, but fundamentally misguided people, who
have been asserting: "Containers are just as secure as VM's".

Well, they are not.  And the sooner people get past this, the better
off they'll be

- Ted


Re: [PATCH] watchdog: stm32: Fix copyright

2017-11-29 Thread Guenter Roeck
On Wed, Nov 29, 2017 at 03:27:53PM +0100, Benjamin Gaignard wrote:
> Uniformize STMicroelectronics copyrights header
> 
> Signed-off-by: Benjamin Gaignard 
> CC: Yannick Fertre 
> ---
>  drivers/watchdog/stm32_iwdg.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c
> index be64a8699de3..c6c8351f1598 100644
> --- a/drivers/watchdog/stm32_iwdg.c
> +++ b/drivers/watchdog/stm32_iwdg.c
> @@ -1,8 +1,8 @@
>  /*
>   * Driver for STM32 Independent Watchdog
>   *
> - * Copyright (C) Yannick Fertre 2017
> - * Author: Yannick Fertre 
> + * Copyright (C) STMicroelectronics SA 2017
> + * Author: Yannick Fertre  for STMicroelectronics.

This will require an Ack from Yannick.

Guenter


Re: [PATCH v5 next 1/5] modules:capabilities: add request_module_cap()

2017-11-29 Thread David Miller
From: Theodore Ts'o 
Date: Wed, 29 Nov 2017 10:54:06 -0500

> On Wed, Nov 29, 2017 at 09:50:14AM -0500, David Miller wrote:
>> From: Alan Cox 
>> Date: Wed, 29 Nov 2017 13:46:12 +
>> 
>> > I really don't care what the module loading rules end up with and
>> > whether we add CAP_SYS_YET_ANOTHER_MEANINGLESS_FLAG but what is
>> > actually needed is to properly incorporate it into securiy ruiles
>> > for whatever LSM you are using.
>> 
>> I'm surprised we're not using the SHA1 hashes or whatever we compute
>> for the modules to make sure we are loading the foo.ko that we expect
>> to be.
> 
> We do have signed modules.  But this won't help us if the user is
> using a distro kernel which has compiled some module which is known to
> be unmaintained which everyone in the know *expects* to have 0-day
> bugs, such as DCCP.  That's because the DCCP module is signed.

That's not what we're talking about.

We're talking about making sure that loading "ppp.ko" really gets
ppp.ko rather than some_other_module.ko renamed to ppp.ko via some
other mechanism.

Both modules have legitimate signatures so the kernel will happily
load both.



Re: [PATCH 0/6] more KAISER bits

2017-11-29 Thread Thomas Gleixner
On Wed, 29 Nov 2017, Thomas Gleixner wrote:

> On Wed, 29 Nov 2017, Peter Zijlstra wrote:
> 
> > Here's more patches, includes the TLB invalidate rework.
> > 
> > Has not actually been tested on a INVPCID machine yet, but does seem to
> > work fine on my IVB-EP (which is PCID only).
> 
> I've picked all of that up including other bits and pieces which have been
> circulated in various threads.
> 
> Note that the next series will have
> 
>  - a rename as lots of people complained about KAISER
> 
>  - stuff folded back where ever it makes sense
>  
>  - reordering of the queue to put fixes and preparatory changes first
> 
> Will take a bit, but this needs to be done before I completely drown in
> conflicting patches and patch snippets of all sorts.

Current pile at:

https://tglx.de/~tglx/patches.tar

I need to walk the dogs and run some errands. Will finish and post later
tonight.

Thanks,

tglx


Re: [PATCH] PM: Provide a config snippet for disabling PM

2017-11-29 Thread Rafael J. Wysocki
On Wed, Nov 29, 2017 at 12:12 PM, Mark Brown  wrote:
> A frequent source of build problems is poor handling of optional PM
> support, almost all development is done with the PM options enabled
> but they can be turned off.  Currently few if any of the build test
> services do this as standard as there is no standard config for it and
> the use of selects and def_bool means that simply setting CONFIG_PM=n
> doesn't do what is expected.  To make this easier provide a fragement
> that can be used with KCONFIG_ALLCONFIG to force PM off.
>
> CONFIG_XEN is disabled as Xen uses hibernation callbacks which end up
> turning on power management on architectures with Xen.  Some cpuidle
> implementations on ARM select PM so CONFIG_CPU_IDLE is disabled, and
> some ARM architectures unconditionally enable PM so they are also
> disabled.
>
> Signed-off-by: Mark Brown 

I'm going to apply this shortly, sorry for the delay.

> ---
>  MAINTAINERS|  1 +
>  kernel/configs/nopm.config | 15 +++
>  2 files changed, 16 insertions(+)
>  create mode 100644 kernel/configs/nopm.config
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 07d9067f68fd..539808dc7928 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -10895,6 +10895,7 @@ F:  include/linux/pm.h
>  F: include/linux/pm_*
>  F: include/linux/powercap.h
>  F: drivers/powercap/
> +F: kernel/configs/nopm.config
>
>  POWER STATE COORDINATION INTERFACE (PSCI)
>  M: Mark Rutland 
> diff --git a/kernel/configs/nopm.config b/kernel/configs/nopm.config
> new file mode 100644
> index ..81ff07863576
> --- /dev/null
> +++ b/kernel/configs/nopm.config
> @@ -0,0 +1,15 @@
> +CONFIG_PM=n
> +CONFIG_SUSPEND=n
> +CONFIG_HIBERNATION=n
> +
> +# Triggers PM on OMAP
> +CONFIG_CPU_IDLE=n
> +
> +# Triggers enablement via hibernate callbacks
> +CONFIG_XEN=n
> +
> +# ARM/ARM64 architectures that select PM unconditionally
> +CONFIG_ARCH_OMAP2PLUS_TYPICAL=n
> +CONFIG_ARCH_RENESAS=n
> +CONFIG_ARCH_TEGRA=n
> +CONFIG_ARCH_VEXPRESS=n
> --
> 2.15.0
>


[PATCH 1/2] mm: introduce MAP_FIXED_SAFE

2017-11-29 Thread Michal Hocko
From: Michal Hocko 

MAP_FIXED is used quite often to enforce mapping at the particular
range. The main problem of this flag is, however, that it is inherently
dangerous because it unmaps existing mappings covered by the requested
range. This can cause silent memory corruptions. Some of them even with
serious security implications. While the current semantic might be
really desiderable in many cases there are others which would want to
enforce the given range but rather see a failure than a silent memory
corruption on a clashing range. Please note that there is no guarantee
that a given range is obeyed by the mmap even when it is free - e.g.
arch specific code is allowed to apply an alignment.

Introduce a new MAP_FIXED_SAFE flag for mmap to achieve this behavior.
It has the same semantic as MAP_FIXED wrt. the given address request
with a single exception that it fails with EEXIST if the requested
address is already covered by an existing mapping. We still do rely on
get_unmaped_area to handle all the arch specific MAP_FIXED treatment and
check for a conflicting vma after it returns.

[fail on clashing range with EEXIST as per Florian Weimer]
[set MAP_FIXED before round_hint_to_min as per Khalid Aziz]
Reviewed-by: Khalid Aziz 
Signed-off-by: Michal Hocko 
---
 arch/alpha/include/uapi/asm/mman.h   |  2 ++
 arch/mips/include/uapi/asm/mman.h|  2 ++
 arch/parisc/include/uapi/asm/mman.h  |  2 ++
 arch/powerpc/include/uapi/asm/mman.h |  1 +
 arch/sparc/include/uapi/asm/mman.h   |  1 +
 arch/tile/include/uapi/asm/mman.h|  1 +
 arch/xtensa/include/uapi/asm/mman.h  |  2 ++
 include/uapi/asm-generic/mman.h  |  1 +
 mm/mmap.c| 11 +++
 9 files changed, 23 insertions(+)

diff --git a/arch/alpha/include/uapi/asm/mman.h 
b/arch/alpha/include/uapi/asm/mman.h
index 6bf730063e3f..ef3770262925 100644
--- a/arch/alpha/include/uapi/asm/mman.h
+++ b/arch/alpha/include/uapi/asm/mman.h
@@ -32,6 +32,8 @@
 #define MAP_STACK  0x8 /* give out an address that is best 
suited for process/thread stacks */
 #define MAP_HUGETLB0x10/* create a huge page mapping */
 
+#define MAP_FIXED_SAFE 0x20/* MAP_FIXED which doesn't unmap 
underlying mapping */
+
 #define MS_ASYNC   1   /* sync memory asynchronously */
 #define MS_SYNC2   /* synchronous memory sync */
 #define MS_INVALIDATE  4   /* invalidate the caches */
diff --git a/arch/mips/include/uapi/asm/mman.h 
b/arch/mips/include/uapi/asm/mman.h
index 20c3df7a8fdd..f1e15890345c 100644
--- a/arch/mips/include/uapi/asm/mman.h
+++ b/arch/mips/include/uapi/asm/mman.h
@@ -50,6 +50,8 @@
 #define MAP_STACK  0x4 /* give out an address that is best 
suited for process/thread stacks */
 #define MAP_HUGETLB0x8 /* create a huge page mapping */
 
+#define MAP_FIXED_SAFE 0x10/* MAP_FIXED which doesn't unmap 
underlying mapping */
+
 /*
  * Flags for msync
  */
diff --git a/arch/parisc/include/uapi/asm/mman.h 
b/arch/parisc/include/uapi/asm/mman.h
index d1af0d74a188..daf0282ac417 100644
--- a/arch/parisc/include/uapi/asm/mman.h
+++ b/arch/parisc/include/uapi/asm/mman.h
@@ -26,6 +26,8 @@
 #define MAP_STACK  0x4 /* give out an address that is best 
suited for process/thread stacks */
 #define MAP_HUGETLB0x8 /* create a huge page mapping */
 
+#define MAP_FIXED_SAFE 0x10/* MAP_FIXED which doesn't unmap 
underlying mapping */
+
 #define MS_SYNC1   /* synchronous memory sync */
 #define MS_ASYNC   2   /* sync memory asynchronously */
 #define MS_INVALIDATE  4   /* invalidate the caches */
diff --git a/arch/powerpc/include/uapi/asm/mman.h 
b/arch/powerpc/include/uapi/asm/mman.h
index e63bc37e33af..3ffd284e7160 100644
--- a/arch/powerpc/include/uapi/asm/mman.h
+++ b/arch/powerpc/include/uapi/asm/mman.h
@@ -29,5 +29,6 @@
 #define MAP_NONBLOCK   0x1 /* do not block on IO */
 #define MAP_STACK  0x2 /* give out an address that is best 
suited for process/thread stacks */
 #define MAP_HUGETLB0x4 /* create a huge page mapping */
+#define MAP_FIXED_SAFE 0x80/* MAP_FIXED which doesn't unmap 
underlying mapping */
 
 #endif /* _UAPI_ASM_POWERPC_MMAN_H */
diff --git a/arch/sparc/include/uapi/asm/mman.h 
b/arch/sparc/include/uapi/asm/mman.h
index 715a2c927e79..0c282c09fae8 100644
--- a/arch/sparc/include/uapi/asm/mman.h
+++ b/arch/sparc/include/uapi/asm/mman.h
@@ -24,6 +24,7 @@
 #define MAP_NONBLOCK   0x1 /* do not block on IO */
 #define MAP_STACK  0x2 /* give out an address that is best 
suited for process/thread stacks */
 #define MAP_HUGETLB0x4 /* create a huge page mapping */
+#define MAP_FIXED_SAFE 0x8 /* MAP_FIXED which doesn't unmap 
underlying mapping */
 
 
 

[PATCH 0/2] mm: introduce MAP_FIXED_SAFE

2017-11-29 Thread Michal Hocko
Hi,
I am resending with RFC dropped and ask for inclusion. There haven't
been any fundamental objections for the RFC [1]. I have also prepared
a man page patch which is 0/3 of this series.

This has started as a follow up discussion [2][3] resulting in the
runtime failure caused by hardening patch [4] which removes MAP_FIXED
from the elf loader because MAP_FIXED is inherently dangerous as it
might silently clobber an existing underlying mapping (e.g. stack). The
reason for the failure is that some architectures enforce an alignment
for the given address hint without MAP_FIXED used (e.g. for shared or
file backed mappings).

One way around this would be excluding those archs which do alignment
tricks from the hardening [5]. The patch is really trivial but it has
been objected, rightfully so, that this screams for a more generic
solution. We basically want a non-destructive MAP_FIXED.

The first patch introduced MAP_FIXED_SAFE which enforces the given
address but unlike MAP_FIXED it fails with ENOMEM if the given range
conflicts with an existing one. The flag is introduced as a completely
new one rather than a MAP_FIXED extension because of the backward
compatibility. We really want a never-clobber semantic even on older
kernels which do not recognize the flag. Unfortunately mmap sucks wrt.
flags evaluation because we do not EINVAL on unknown flags. On those
kernels we would simply use the traditional hint based semantic so the
caller can still get a different address (which sucks) but at least not
silently corrupt an existing mapping. I do not see a good way around
that. Except we won't export expose the new semantic to the userspace at
all. 

It seems there are users who would like to have something like that.
Jemalloc has been mentioned by Michael Ellerman [6]

Florian Weimer has mentioned the following:
: glibc ld.so currently maps DSOs without hints.  This means that the kernel
: will map right next to each other, and the offsets between them a completely
: predictable.  We would like to change that and supply a random address in a
: window of the address space.  If there is a conflict, we do not want the
: kernel to pick a non-random address. Instead, we would try again with a
: random address.

John Hubbard has mentioned CUDA example
: a) Searches /proc//maps for a "suitable" region of available
: VA space.  "Suitable" generally means it has to have a base address
: within a certain limited range (a particular device model might
: have odd limitations, for example), it has to be large enough, and
: alignment has to be large enough (again, various devices may have
: constraints that lead us to do this).
: 
: This is of course subject to races with other threads in the process.
: 
: Let's say it finds a region starting at va.
: 
: b) Next it does: 
: p = mmap(va, ...) 
: 
: *without* setting MAP_FIXED, of course (so va is just a hint), to
: attempt to safely reserve that region. If p != va, then in most cases,
: this is a failure (almost certainly due to another thread getting a
: mapping from that region before we did), and so this layer now has to
: call munmap(), before returning a "failure: retry" to upper layers.
: 
: IMPROVEMENT: --> if instead, we could call this:
: 
: p = mmap(va, ... MAP_FIXED_SAFE ...)
: 
: , then we could skip the munmap() call upon failure. This
: is a small thing, but it is useful here. (Thanks to Piotr
: Jaroszynski and Mark Hairgrove for helping me get that detail
: exactly right, btw.)
: 
: c) After that, CUDA suballocates from p, via: 
:  
:  q = mmap(sub_region_start, ... MAP_FIXED ...)
: 
: Interestingly enough, "freeing" is also done via MAP_FIXED, and
: setting PROT_NONE to the subregion. Anyway, I just included (c) for
: general interest.

Atomic address range probing in the multithreaded programs in general
sounds like an interesting thing to me.

The second patch simply replaces MAP_FIXED use in elf loader by
MAP_FIXED_SAFE. I believe other places which rely on MAP_FIXED should
follow. Actually real MAP_FIXED usages should be docummented properly
and they should be more of an exception.

Does anybody see any fundamental reasons why this is a wrong approach?

Diffstat says
 arch/alpha/include/uapi/asm/mman.h   |  2 ++
 arch/metag/kernel/process.c  |  6 +-
 arch/mips/include/uapi/asm/mman.h|  2 ++
 arch/parisc/include/uapi/asm/mman.h  |  2 ++
 arch/powerpc/include/uapi/asm/mman.h |  1 +
 arch/sparc/include/uapi/asm/mman.h   |  1 +
 arch/tile/include/uapi/asm/mman.h|  1 +
 arch/xtensa/include/uapi/asm/mman.h  |  2 ++
 fs/binfmt_elf.c  | 12 
 include/uapi/asm-generic/mman.h  |  1 +
 mm/mmap.c| 11 +++
 11 files changed, 36 insertions(+), 5 deletions(-)

[1] http://lkml.kernel.org/r/20171116101900.13621-1-mho...@kernel.org
[2] http://lkml.kernel.org/r/20171107162217.382cd...@canb.auug.org.au
[3] 

Re: [PATCH] net: ethernet: xilinx: Mark XILINX_LL_TEMAC broken on 64-bit

2017-11-29 Thread David Miller
From: Geert Uytterhoeven 
Date: Wed, 29 Nov 2017 11:01:09 +0100

> On 64-bit (e.g. powerpc64/allmodconfig):
> 
> drivers/net/ethernet/xilinx/ll_temac_main.c: In function 
> 'temac_start_xmit_done':
> drivers/net/ethernet/xilinx/ll_temac_main.c:633:22: warning: cast to 
> pointer from integer of different size [-Wint-to-pointer-cast]
>   dev_kfree_skb_irq((struct sk_buff *)cur_p->app4);
> ^
> 
> cdmac_bd.app4 is u32, so it is too small to hold a kernel pointer.
> 
> Note that several other fields in struct cdmac_bd are also too small to
> hold physical addresses on 64-bit platforms.
> 
> Signed-off-by: Geert Uytterhoeven 

Yeah, I can't see much value in implementing a hash table converting between
32-bit cookies and 64-bit points just for this if it'll never be actually
used.

Applied, thanks Geert.


Re: Regression: unable to boot after commit bd9240a18edf ("x86/apic: Add TSC_DEADLINE quirk due to errata") - Surface Pro 4 SKL

2017-11-29 Thread Zhang Rui
On Tue, 2017-11-28 at 13:36 +0100, Peter Zijlstra wrote:
> On Tue, Nov 28, 2017 at 06:59:01PM +0800, Zhang Rui wrote:
> > 
> > > 
> > > > 
> > > > > 
> > > > > > 
> > > > > > My Surface Pro 4 is unable to boot after 4.12. The symptom
> > > > > > is
> > 
> > yes. Tried 4.4 distro and 4.12 vanilla kernel, kernel always
> > freezes
> > with boot option "notscdeadline"/"lapic=notscdeadline".
> Then for some mysterious reason, your Surface thing has a borked
> LAPIC.
> 
I agree. But however, on this platform, forcing a cpu microcode upgrade
after upgrading kernel does not seem like a good solution to users.
Thus I still like to dig into the problem further to see if we can
workaround this "regression" in software.
As the kernel freezes at a very early stage, do you have any advice on
how to narrow down the problem?

thanks,
rui


Re: [RFC PATCH] KVM: x86: Allow Qemu/KVM to use PVH entry point

2017-11-29 Thread Paolo Bonzini
On 29/11/2017 15:25, Boris Ostrovsky wrote:
 zeropage is x86/Linux-specific so we'd need some sort of firmware (like
 grub) between a hypervisor and Linux to convert hvm_start_info to
 bootparams.
>>> qemu?
>
> I think KVM folks didn't want to do this. I can't find the thread but I
> believe it was somewhere during Clear Containers discussion. Paolo?

QEMU is the right place to parse the ELF file and save it in memory.
You would have to teach QEMU to find the Xen note in ELF-format kernels
(just like it looks for the multiboot header), and use a different
option ROM ("pvhboot.c" for example).

However I don't like to bypass the BIOS; for -kernel, KVM starts the
guest with an option ROM (linuxboot-dma.c or multiboot.S in QEMU
sources) that takes care of boot.

In either case, you would have a new option ROM.  It could either be
very simple and similar to multiboot.S, or it could be larger and do the
same task as xen-pvh.S and enlighten_pvh.c (then get the address of
startup_32 or startup_64 from FW_CFG_KERNEL_ENTRY and jump there).  The
ugly part is that the option ROM would have to know more details about
what it is going to boot, including for example whether it's 32-bit or
64-bit, so I don't really think it is a good idea.

I actually like this patch, except that I'd get the e820 memory map from
fw_cfg (see the first part of
https://github.com/bonzini/qboot/blob/master/fw_cfg.c, and extract_e820
in https://github.com/bonzini/qboot/blob/master/main.c) instead of the
second module.

Thanks,

Paolo

> 
>> But then it won't be using the PVH entry point, and would just use the
>> native one?
>>
>> My understanding was that the PVH shim inside of Linux will prepare a
>> zero-page when booted using the PVH entry point, and then jump into
>> the native boot path.
> Right, but that's not what Juergen's second option is. IIUIC with that
> option Linux starts with zeropage already prepared. No shim in the kernel.



[PATCH v2] arch: arm: mach-stm32: Fix copyright

2017-11-29 Thread Benjamin Gaignard
Uniformize STMicroelectronics copyrights header
Add SPDX identifier

Signed-off-by: Benjamin Gaignard 
---
 arch/arm/mach-stm32/board-dt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-stm32/board-dt.c b/arch/arm/mach-stm32/board-dt.c
index e918686e4191..b01f40543e6e 100644
--- a/arch/arm/mach-stm32/board-dt.c
+++ b/arch/arm/mach-stm32/board-dt.c
@@ -1,5 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (C) Maxime Coquelin 2015
+ * Copyright (C) STMicroelectronics SA 2017
  * Author:  Maxime Coquelin 
  * License terms:  GNU General Public License (GPL), version 2
  */
-- 
2.15.0



Re: [PATCH] firmware: Use PTR_ERR_OR_ZERO()

2017-11-29 Thread Gabriel L. Somlo
Acked-by: Gabriel Somlo 

On Tue, Nov 28, 2017 at 10:40:27PM +0100, Vasyl Gomonovych wrote:
> Fix ptr_ret.cocci warnings:
> drivers/firmware/efi/efi.c:610:8-14: WARNING: PTR_ERR_OR_ZERO can be used
> 
> Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
> 
> Generated by: scripts/coccinelle/api/ptr_ret.cocci
> 
> Signed-off-by: Vasyl Gomonovych 
> ---
>  drivers/firmware/qemu_fw_cfg.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> index 5cfe39f7a45f..18489b6a696d 100644
> --- a/drivers/firmware/qemu_fw_cfg.c
> +++ b/drivers/firmware/qemu_fw_cfg.c
> @@ -693,10 +693,8 @@ static int fw_cfg_cmdline_set(const char *arg, const 
> struct kernel_param *kp)
>*/
>   fw_cfg_cmdline_dev = platform_device_register_simple("fw_cfg",
>   PLATFORM_DEVID_NONE, res, processed);
> - if (IS_ERR(fw_cfg_cmdline_dev))
> - return PTR_ERR(fw_cfg_cmdline_dev);
>  
> - return 0;
> + return PTR_ERR_OR_ZERO(fw_cfg_cmdline_dev);
>  }
>  
>  static int fw_cfg_cmdline_get(char *buf, const struct kernel_param *kp)
> -- 
> 1.9.1
> 


Re: [PATCH] x86/syscalls: Mark expected switch fall-throughs

2017-11-29 Thread Gustavo A. R. Silva


Quoting Thomas Gleixner :



So I have to ask WHY this information was not in the changelog of the patch
in question:

   1) How it works

   2) Why comments have been chosen over macros



I will add this info and send the patch again.


In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.


It's not a reviewers job to chase that information down.

While I can understand that the comments are intentional due to existing
tools, I still prefer the macro/annotation. But I'm not religious about it
when there is common consensus. :)



Awesome

Thanks, Thomas.
--
Gustavo A. R. Silva








Re: [PATCH v3 00/11] perf stat: Enable '--per-thread' on all thread

2017-11-29 Thread Jiri Olsa
On Wed, Nov 29, 2017 at 08:05:47PM +0800, Jin Yao wrote:
> v3:
> ---
> Update according to Jiri's comments. The major modifications are:
> 
> 1. Fix the crash issue when performing the git bisect.
>Move the removing of runtime_saved_values to the switching point
>(perf util: Remove a set of shadow stats static variables).
> 
> 2. Still add struct perf_stat_config::*stats|stats_num in earlier
>patch because 'stats' will be used in
>'perf util: Update and print per-thread shadow stats'.
>If it's moved to 'perf stat: Allocate shadow stats buffer for threads',
>the compilation would be failed.

sure, that's why also that hunk from 'perf util: Update and print per-thread 
shadow stats'
needs to be moved to 'perf stat: Allocate shadow stats buffer for threads'

this one:

+   if (stat_config.stats)
+   stat = _config.stats[thread];
+   else
+   stat = _stat;
+
+   printout(thread, 0, counter, uval, prefix, run, ena, 1.0,
+stat);

you already did that in 'perf stat: Allocate shadow stats buffer for threads' 
for:

+   if (config->aggr_mode == AGGR_THREAD) {
+   if (config->stats)
+   perf_stat__update_shadow_stats(evsel,
+   count->val, 0, >stats[thread]);
+   else
+   perf_stat__update_shadow_stats(evsel,
+   count->val, 0, _stat);
+   }


thanks,
jirka


[PATCH 2/5] MIPS: Fix an FCSR access API regression with NT_PRFPREG and MSA

2017-11-29 Thread Maciej W. Rozycki
Fix a commit 72b22bbad1e7 ("MIPS: Don't assume 64-bit FP registers for 
FP regset") public API regression, then activated by commit 1db1af84d6df 
("MIPS: Basic MSA context switching support"), that caused the FCSR 
register not to be read or written for CONFIG_CPU_HAS_MSA kernel 
configurations (regardless of actual presence or absence of the MSA 
feature in a given processor) with ptrace(2) PTRACE_GETREGSET and 
PTRACE_SETREGSET requests nor recorded in core dumps.

This is because with !CONFIG_CPU_HAS_MSA configurations the whole of 
`elf_fpregset_t' array is bulk-copied as it is, which includes the FCSR 
in one half of the last, 33rd slot, whereas with CONFIG_CPU_HAS_MSA 
configurations array elements are copied individually, and then only the 
leading 32 FGR slots while the remaining slot is ignored.

Correct the code then such that only FGR slots are copied in the 
respective !MSA and MSA helpers an then the FCSR slot is handled 
separately in common code.  Use `ptrace_setfcr31' to update the FCSR 
too, so that the read-only mask is respected.

Retrieving a correct value of FCSR is important in debugging not only 
for the human to be able to get the right interpretation of the 
situation, but for correct operation of GDB as well.  This is because 
the condition code bits in FSCR are used by GDB to determine the 
location to place a breakpoint at when single-stepping through an FPU 
branch instruction.  If such a breakpoint is placed incorrectly (i.e. 
with the condition reversed), then it will be missed, likely causing the 
debuggee to run away from the control of GDB and consequently breaking 
the process of investigation.

Fortunately GDB continues using the older PTRACE_GETFPREGS ptrace(2) 
request which is unaffected, so the regression only really hits with 
post-mortem debug sessions using a core dump file, in which case 
execution, and consequently single-stepping through branches is not 
possible.  Of course core files created by buggy kernels out there will 
have the value of FCSR recorded clobbered, but such core files cannot be 
corrected and the person using them simply will have to be aware that 
the value of FCSR retrieved is not reliable.

Which also means we can likely get away without defining a replacement 
API which would ensure a correct value of FSCR to be retrieved, or none 
at all.

This is based on previous work by Alex Smith, extensively rewritten.

Cc: sta...@vger.kernel.org # v3.15+
Fixes: 72b22bbad1e7 ("MIPS: Don't assume 64-bit FP registers for FP regset")
Signed-off-by: Alex Smith 
Signed-off-by: James Hogan 
Signed-off-by: Maciej W. Rozycki 
---

 I think the fix to use `ptrace_setfcr31' could be a separate change, but 
given how its absence has been entangled with the inconsistency between
!MSA and MSA I cannot imagine how to do it in a sane manner:

1. If done first, then it would have to be applied to the !MSA case only,
   only to be moved to shared code in the next step.

2. If done second, then new incorrect shared code would have to be written
   only to be fixed in the next step.

So I think it has to go along with the main fix.  Though maybe choosing #2 
would make backporting easier, as `ptrace_setfcr31' is v4.1+ only and:

target->thread.fpu.fcr31 = fcr31;

has to be used before that (previously the read-only mask wasn't defined
and you could write arbitrary rubbish to FCSR, especially in the emulated
case).

 Thoughts?

  Maciej

---
 arch/mips/kernel/ptrace.c |   51 +++---
 1 file changed, 39 insertions(+), 12 deletions(-)

linux-mips-nt-prfpreg-fcsr.diff
Index: linux-sfr-test/arch/mips/kernel/ptrace.c
===
--- linux-sfr-test.orig/arch/mips/kernel/ptrace.c   2017-11-28 
22:44:11.0 +
+++ linux-sfr-test/arch/mips/kernel/ptrace.c2017-11-28 23:33:33.395023000 
+
@@ -413,7 +413,7 @@ static int gpr64_set(struct task_struct 
 /*
  * Copy the floating-point context to the supplied NT_PRFPREG buffer,
  * !CONFIG_CPU_HAS_MSA variant.  FP context's general register slots
- * correspond 1:1 to buffer slots.
+ * correspond 1:1 to buffer slots.  Only general registers are copied.
  */
 static int fpr_get_fpa(struct task_struct *target,
   unsigned int *pos, unsigned int *count,
@@ -421,13 +421,14 @@ static int fpr_get_fpa(struct task_struc
 {
return user_regset_copyout(pos, count, kbuf, ubuf,
   >thread.fpu,
-  0, sizeof(elf_fpregset_t));
+  0, NUM_FPU_REGS * sizeof(elf_fpreg_t));
 }
 
 /*
  * Copy the floating-point context to the supplied NT_PRFPREG buffer,
  * CONFIG_CPU_HAS_MSA variant.  Only lower 64 bits of FP context's
- * general register slots are copied to buffer slots.
+ * general register slots are copied to buffer slots.  Only general
+ 

[PATCH 3/5] MIPS: Also verify sizeof `elf_fpreg_t' with PTRACE_SETREGSET

2017-11-29 Thread Maciej W. Rozycki
Complement commit d614fd58a283 ("mips/ptrace: Preserve previous 
registers for short regset write") and like with the PTRACE_GETREGSET 
ptrace(2) request also apply a BUILD_BUG_ON check for the size of the 
`elf_fpreg_t' type in the PTRACE_SETREGSET request handler.

Cc: sta...@vger.kernel.org # v4.11+
Fixes: d614fd58a283 ("mips/ptrace: Preserve previous registers for short regset 
write")
Signed-off-by: Maciej W. Rozycki 
---
 arch/mips/kernel/ptrace.c |1 +
 1 file changed, 1 insertion(+)

linux-mips-nt-prfpreg-build-bug.diff
Index: linux-sfr-test/arch/mips/kernel/ptrace.c
===
--- linux-sfr-test.orig/arch/mips/kernel/ptrace.c   2017-11-28 
23:33:33.395023000 +
+++ linux-sfr-test/arch/mips/kernel/ptrace.c2017-11-28 23:52:34.944549000 
+
@@ -438,6 +438,7 @@ static int fpr_get_msa(struct task_struc
u64 fpr_val;
int err;
 
+   BUILD_BUG_ON(sizeof(fpr_val) != sizeof(elf_fpreg_t));
for (i = 0; i < NUM_FPU_REGS; i++) {
fpr_val = get_fpr64(>thread.fpu.fpr[i], 0);
err = user_regset_copyout(pos, count, kbuf, ubuf,


[PATCH 3/3] drm/ttm: Fix comment syntax

2017-11-29 Thread Will Deacon
"/**" identifies a kerneldoc comment, so avoid using it for comments that
don't conform to kerneldoc syntax. Without this patch, kerneldoc throws
errors when building the kernel with W=1.

Cc: David Airlie 
Cc: Thomas Hellstrom 
Signed-off-by: Will Deacon 
---
 drivers/gpu/drm/ttm/ttm_object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_object.c b/drivers/gpu/drm/ttm/ttm_object.c
index 26a7ad0f4789..0f5800c1a57d 100644
--- a/drivers/gpu/drm/ttm/ttm_object.c
+++ b/drivers/gpu/drm/ttm/ttm_object.c
@@ -41,7 +41,7 @@
  */
 
 
-/**
+/*
  * struct ttm_object_file
  *
  * @tdev: Pointer to the ttm_object_device.
-- 
2.1.4



Re: [PATCH 0/2] mm: introduce MAP_FIXED_SAFE

2017-11-29 Thread Rasmus Villemoes
On 2017-11-29 15:42, Michal Hocko wrote:
> 
> The first patch introduced MAP_FIXED_SAFE which enforces the given
> address but unlike MAP_FIXED it fails with ENOMEM if the given range
> conflicts with an existing one.

[s/ENOMEM/EEXIST/, as it seems you also did in the actual patch and
changelog]

>The flag is introduced as a completely
> new one rather than a MAP_FIXED extension because of the backward
> compatibility. We really want a never-clobber semantic even on older
> kernels which do not recognize the flag. Unfortunately mmap sucks wrt.
> flags evaluation because we do not EINVAL on unknown flags. On those
> kernels we would simply use the traditional hint based semantic so the
> caller can still get a different address (which sucks) but at least not
> silently corrupt an existing mapping. I do not see a good way around
> that.

I think it would be nice if this rationale was in the 1/2 changelog,
along with the hint about what userspace that wants to be compatible
with old kernels will have to do (namely, check that it got what it
requested) - which I see you did put in the man page.

-- 
Rasmus Villemoes
Software Developer
Prevas A/S
Hedeager 3
DK-8200 Aarhus N
+45 51210274
rasmus.villem...@prevas.dk
www.prevas.dk


[PATCH 2/3] brcmfmac: Fix comment syntax

2017-11-29 Thread Will Deacon
"/**" identifies a kerneldoc comment, so avoid using it for comments that
don't conform to kerneldoc syntax. Without this patch, kerneldoc throws
errors when building the kernel with W=1.

Cc: Arend van Spriel 
Cc: Franky Lin 
Signed-off-by: Will Deacon 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 310c4e2746aa..604afff4b6a1 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -2070,7 +2070,7 @@ static int brcmf_sdio_txpkt_hdalign(struct brcmf_sdio 
*bus, struct sk_buff *pkt)
return head_pad;
 }
 
-/**
+/*
  * struct brcmf_skbuff_cb reserves first two bytes in sk_buff::cb for
  * bus layer usage.
  */
-- 
2.1.4



[PATCH 1/3] scripts/kernel-doc: Don't fail with status != 0 if error encountered with -none

2017-11-29 Thread Will Deacon
My bisect scripts starting running into build failures when trying to
compile 4.15-rc1 with the builds failing with things like:

drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c:2078: error: Cannot 
parse struct or union!

The line in question is actually just a #define, but after some digging
it turns out that my scripts pass W=1 and since commit 3a025e1d1c2ea
("Add optional check for bad kernel-doc comments") that results in
kernel-doc running on each source file. The file in question has a
badly formatted comment immediately before the #define:

/**
 * struct brcmf_skbuff_cb reserves first two bytes in sk_buff::cb for
 * bus layer usage.
 */

which causes the regex in dump_struct to fail (lack of braces following
struct declaration) and kernel-doc returns 1, which causes the build
to fail.

Fix the issue by always returning 0 from kernel-doc when invoked with
-none. It successfully generates no documentation, and prints out any
issues.

Cc: Matthew Wilcox 
Cc: Jonathan Corbet 
Signed-off-by: Will Deacon 
---
 scripts/kernel-doc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index bd29a92b4b48..df0f045a9a89 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -3248,4 +3248,4 @@ if ($verbose && $warnings) {
   print STDERR "$warnings warnings\n";
 }
 
-exit($errors);
+exit($output_mode eq "none" ? 0 : $errors);
-- 
2.1.4



Re: [PATCH v8 0/6] vfs: Use dlock list for SB's s_inodes list

2017-11-29 Thread Davidlohr Bueso

Are you planning on sending a v9 with the discussed changes? afaict:

- Drop last two patches
- Fix tearing (WRITE/READ_ONCE())
- Reduce barrier usage for dlock_lists_empty() -- which I'll be sending
 you shortly.

Thanks,
Davidlohr

On Tue, 31 Oct 2017, Waiman Long wrote:


v7->v8:
- Integrate the additional patches 8, 9 and 10 sent to fix issues in
  the original v7 patchset into patch 1 and adjust the other patches
  accordingly.

v6->v7:
- Fix outdated email address.
- Add a comment to patch 4 to explain allocation issue & fix a
  compilation problem with cpumask.
- Replace patch 6 with another one that adds an irqsafe mode argument
  in alloc_dlock_list_heads() instead of adding new APIs.

v5->v6:
- Rebased the patch to 4.14-rc3.
- Drop the fsnotify patch as it had been merged somehow.
- Add a new patch 5 with alternative way of selecting list by hashing
  instead of cpu #.
- Add a new patch 6 to proivde a set irq safe APIs to be used in
  interrupt context.
- Update the CPU to index mapping code.

v4->v5:
- Rebased the patch to 4.8-rc1 (changes to fs/fs-writeback.c was
  dropped).
- Use kcalloc() instead of percpu_alloc() to allocate the dlock list
  heads structure as suggested by Christoph Lameter.
- Replaced patch 5 by another one that made sibling CPUs use the same
  dlock list head thus reducing the number of list heads that needed
  to be maintained.

v3->v4:
- As suggested by Al, encapsulate the dlock list mechanism into
  the dlist_for_each_entry() and dlist_for_each_entry_safe()
  which are the equivalent of list_for_each_entry() and
  list_for_each_entry_safe() for regular linked list. That simplifies
  the changes in the call sites that perform dlock list iterations.
- Add a new patch to make the percpu head structure cacheline aligned
  to prevent cacheline contention from disrupting the performance
  of nearby percpu variables.

v2->v3:
- Remove the 2 persubnode API patches.
- Merge __percpu tag patch 2 into patch 1.
- As suggested by Tejun Heo, restructure the dlock_list_head data
  structure to hide the __percpu tag and rename some of the functions
  and structures.
- Move most of the code from dlock_list.h to dlock_list.c and export
  the symbols.

v1->v2:
- Add a set of simple per-subnode APIs that is between percpu and
  per-node in granularity.
- Make dlock list to use the per-subnode APIs so as to reduce the
  total number of separate linked list that needs to be managed
  and iterated.
- There is no change in patches 1-5.

This patchset provides new APIs for a set of distributed locked lists
(one/CPU core) to minimize lock and cacheline contention. Insertion
and deletion to the list will be cheap and relatively contention free.
Lookup, on the other hand, may be a bit more costly as there are
multiple lists to iterate. This is not really a problem for the
replacement of superblock's inode list by dlock list included in
the patchset as lookup isn't needed.

For use cases that need to do lookup, the dlock list can also be
treated as a set of hashed lists that scales with the number of CPU
cores in the system.

Both patches 5 and 6 are added to support other use cases like epoll
nested callbacks, for example, which could use the dlock-list to
reduce lock contention problem.

Patch 1 introduces the dlock list. The list heads are allocated
by kcalloc() instead of percpu_alloc(). Each list head entry is
cacheline aligned to minimize contention.

Patch 2 replaces the use of list_for_each_entry_safe() in
evict_inodes() and invalidate_inodes() by list_for_each_entry().

Patch 3 modifies the superblock and inode structures to use the dlock
list. The corresponding functions that reference those structures
are modified.

Patch 4 makes the sibling CPUs use the same dlock list head to reduce
the number of list heads that need to be iterated.

Patch 5 enables alternative use case of as a set of hashed lists.

Patch 6 provides an irq safe mode specified at dlock-list allocation
time so that it can be used within interrupt context.

Jan Kara (1):
 vfs: Remove unnecessary list_for_each_entry_safe() variants

Waiman Long (5):
 lib/dlock-list: Distributed and lock-protected lists
 vfs: Use dlock list for superblock's inode list
 lib/dlock-list: Make sibling CPUs share the same linked list
 lib/dlock-list: Enable faster lookup with hashing
 lib/dlock-list: Add an IRQ-safe mode to be used in interrupt handler

fs/block_dev.c |   9 +-
fs/drop_caches.c   |   9 +-
fs/inode.c |  38 ++
fs/notify/fsnotify.c   |   9 +-
fs/quota/dquot.c   |  14 +-
fs/super.c |   7 +-
include/linux/dlock-list.h | 263 +++
include/linux/fs.h |   8 +-
lib/Makefile   |   2 +-
lib/dlock-list.c   | 333 +
10 files changed, 638 insertions(+), 54 deletions(-)
create mode 100644 include/linux/dlock-list.h
create mode 100644 lib/dlock-list.c

--
1.8.3.1



[PATCH v3 33/36] softirq: Remove tasklet_hrtimer

2017-11-29 Thread Anna-Maria Gleixner
From: Thomas Gleixner 

There are no more tasklet_hrtimer users of this interface.
Remove it.

Signed-off-by: Thomas Gleixner 
Signed-off-by: Anna-Maria Gleixner 
---
 include/linux/interrupt.h | 25 ---
 kernel/softirq.c  | 51 ---
 2 files changed, 76 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 69c238210325..af15bfd89598 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -618,31 +618,6 @@ extern void tasklet_kill_immediate(struct tasklet_struct 
*t, unsigned int cpu);
 extern void tasklet_init(struct tasklet_struct *t,
 void (*func)(unsigned long), unsigned long data);
 
-struct tasklet_hrtimer {
-   struct hrtimer  timer;
-   struct tasklet_struct   tasklet;
-   enum hrtimer_restart(*function)(struct hrtimer *);
-};
-
-extern void
-tasklet_hrtimer_init(struct tasklet_hrtimer *ttimer,
-enum hrtimer_restart (*function)(struct hrtimer *),
-clockid_t which_clock, enum hrtimer_mode mode);
-
-static inline
-void tasklet_hrtimer_start(struct tasklet_hrtimer *ttimer, ktime_t time,
-  const enum hrtimer_mode mode)
-{
-   hrtimer_start(>timer, time, mode);
-}
-
-static inline
-void tasklet_hrtimer_cancel(struct tasklet_hrtimer *ttimer)
-{
-   hrtimer_cancel(>timer);
-   tasklet_kill(>tasklet);
-}
-
 /*
  * Autoprobing for irqs:
  *
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 2f5e87f1bae2..d0dd7795409f 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -584,57 +584,6 @@ void tasklet_kill(struct tasklet_struct *t)
 }
 EXPORT_SYMBOL(tasklet_kill);
 
-/*
- * tasklet_hrtimer
- */
-
-/*
- * The trampoline is called when the hrtimer expires. It schedules a tasklet
- * to run __tasklet_hrtimer_trampoline() which in turn will call the intended
- * hrtimer callback, but from softirq context.
- */
-static enum hrtimer_restart __hrtimer_tasklet_trampoline(struct hrtimer *timer)
-{
-   struct tasklet_hrtimer *ttimer =
-   container_of(timer, struct tasklet_hrtimer, timer);
-
-   tasklet_hi_schedule(>tasklet);
-   return HRTIMER_NORESTART;
-}
-
-/*
- * Helper function which calls the hrtimer callback from
- * tasklet/softirq context
- */
-static void __tasklet_hrtimer_trampoline(unsigned long data)
-{
-   struct tasklet_hrtimer *ttimer = (void *)data;
-   enum hrtimer_restart restart;
-
-   restart = ttimer->function(>timer);
-   if (restart != HRTIMER_NORESTART)
-   hrtimer_restart(>timer);
-}
-
-/**
- * tasklet_hrtimer_init - Init a tasklet/hrtimer combo for softirq callbacks
- * @ttimer: tasklet_hrtimer which is initialized
- * @function:   hrtimer callback function which gets called from softirq 
context
- * @which_clock: clock id (CLOCK_MONOTONIC/CLOCK_REALTIME)
- * @mode:   hrtimer mode (HRTIMER_MODE_ABS/HRTIMER_MODE_REL)
- */
-void tasklet_hrtimer_init(struct tasklet_hrtimer *ttimer,
- enum hrtimer_restart (*function)(struct hrtimer *),
- clockid_t which_clock, enum hrtimer_mode mode)
-{
-   hrtimer_init(>timer, which_clock, mode);
-   ttimer->timer.function = __hrtimer_tasklet_trampoline;
-   tasklet_init(>tasklet, __tasklet_hrtimer_trampoline,
-(unsigned long)ttimer);
-   ttimer->function = function;
-}
-EXPORT_SYMBOL_GPL(tasklet_hrtimer_init);
-
 void __init softirq_init(void)
 {
int cpu;
-- 
2.11.0



[PATCH] zswap: Update with same-value filled page feature

2017-11-29 Thread Srividya Desireddy
From: Srividya Desireddy 
Date: Wed, 29 Nov 2017 20:23:15 +0530
Subject: [PATCH] zswap: Update with same-value filled page feature

Updated zswap document with details on same-value filled
pages identification feature.
The usage of zswap.same_filled_pages_enabled module parameter
is explained.

Signed-off-by: Srividya Desireddy 
---
 Documentation/vm/zswap.txt | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/Documentation/vm/zswap.txt b/Documentation/vm/zswap.txt
index 89fff7d..cc015b5 100644
--- a/Documentation/vm/zswap.txt
+++ b/Documentation/vm/zswap.txt
@@ -98,5 +98,25 @@ request is made for a page in an old zpool, it is 
uncompressed using its
 original compressor.  Once all pages are removed from an old zpool, the zpool
 and its compressor are freed.
 
+Some of the pages in zswap are same-value filled pages (i.e. contents of the
+page have same value or repetitive pattern). These pages include zero-filled
+pages and they are handled differently. During store operation, a page is
+checked if it is a same-value filled page before compressing it. If true, the
+compressed length of the page is set to zero and the pattern or same-filled
+value is stored.
+
+Same-value filled pages identification feature is enabled by default and can be
+disabled at boot time by setting the "same_filled_pages_enabled" attribute to 
0,
+e.g. zswap.same_filled_pages_enabled=0. It can also be enabled and disabled at
+runtime using the sysfs "same_filled_pages_enabled" attribute, e.g.
+
+echo 1 > /sys/module/zswap/parameters/same_filled_pages_enabled
+
+When zswap same-filled page identification is disabled at runtime, it will stop
+checking for the same-value filled pages during store operation. However, the
+existing pages which are marked as same-value filled pages will be loaded or
+invalidated.
+
 A debugfs interface is provided for various statistic about pool size, number
-of pages stored, and various counters for the reasons pages are rejected.
+of pages stored, same-value filled pages and various counters for the reasons
+pages are rejected.
-- 
2.7.4



[PATCH net 3/3] rxrpc: Fix variable overwrite

2017-11-29 Thread David Howells
From: Gustavo A. R. Silva 

Values assigned to both variable resend_at and ack_at are overwritten
before they can be used.

The correct fix here is to add 'now' to the previously computed value in
resend_at and ack_at.

Addresses-Coverity-ID: 1462262
Addresses-Coverity-ID: 1462263
Addresses-Coverity-ID: 1462264
Fixes: beb8e5e4f38c ("rxrpc: Express protocol timeouts in terms of RTT")
Link: https://marc.info/?i=17004.1511808959%40warthog.procyon.org.uk
Signed-off-by: Gustavo A. R. Silva 
Signed-off-by: David Howells 
---

 net/rxrpc/call_event.c |2 +-
 net/rxrpc/sendmsg.c|2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
index 555274ddc514..ad2ab1103189 100644
--- a/net/rxrpc/call_event.c
+++ b/net/rxrpc/call_event.c
@@ -123,7 +123,7 @@ static void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 
ack_reason,
else
ack_at = expiry;
 
-   ack_at = jiffies + expiry;
+   ack_at += now;
if (time_before(ack_at, call->ack_at)) {
WRITE_ONCE(call->ack_at, ack_at);
rxrpc_reduce_call_timer(call, ack_at, now,
diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index a1c53ac066a1..09f2a3e05221 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -233,7 +233,7 @@ static void rxrpc_queue_packet(struct rxrpc_sock *rx, 
struct rxrpc_call *call,
if (resend_at < 1)
resend_at = 1;
 
-   resend_at = now + rxrpc_resend_timeout;
+   resend_at += now;
WRITE_ONCE(call->resend_at, resend_at);
rxrpc_reduce_call_timer(call, resend_at, now,
rxrpc_timer_set_for_send);



Re: [linux-sunxi] Cedrus driver

2017-11-29 Thread Thomas van Kleef
Hi Maxime,
> 
> So there's a couple of issues with those patches (the pull request
> itself is fine though :))
> 
> I'll try to break them down as much as possible.
> 
> A) If you want to have proper commit logs, you will usually do two
>things: first create a commit title, which is what appears in the
>above summary. That commit title should not be longer than 72
>characters, and it should explain roughly what you're trying to
>do. The actual description should be in the commit log itself, and
>you should document what is the issue you're trying to fix /
>improve, how you're doing it and why you've done it that way.
Ah, so the pull-request commits are not proper, I will try do that from
now on. these last ones are quite bad.
> 
>The final line of that commit log shoud be your Signed-off-by,
>which is your agreement to the Developer Certificate of Origin
>(DCO), that you'll find documented here:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst#n429
> 
> B) Please base your work on a known release (4.14) and not the middle
>of Linus' branch.
Should be fixed now.
> 
> C) I'm not sure what you tried to do with the application of the
>request API patches (such as e1ca861c168f) but we want to have the
>whole commits in there, and not a patch adding all of them. This
>will make the work so much easier to rebase to a later version when
>some patches wouldn't have been merged and some would have.
> 
> D) Rebase :)
Thank you. Giulio asked before if I could add a repo and commit the 
patches so that is what I did. I will push a different code where the
full history is present in commits.

So, I got it setup. As I did test it before on the slightly newer branch,
I did not verify, again, if the video-decoder worked on this specific 
state of the linux kernel, 4.14. But it should x:
If you rather wait for me to tell if it work let me know, but we could do
a pull request then again anyway.

So here is the new pull-request
The following changes since commit bebc6082da0a9f5d47a1ea2edc099bf671058bd4:

  Linux 4.14 (2017-11-12 10:46:13 -0800)

are available in the git repository at:

  https://github.com/thomas-vitsch/linux-a20-cedrus.git linux-sunxi-cedrus

for you to fetch changes up to 26701eca67a07ab002c7fd18038fa299b9589939:

  Fix the sun5i and sun8i dts files (2017-11-29 15:18:05 +0100)


Bob Ham (1):
  sunxi-cedrus: Fix compilation errors from bad types under GCC 6.2

Florent Revest (8):
  Both mainline and cedrus had added their own formats with both are added.
  v4l: Add MPEG2 low-level decoder API control
  v4l: Add MPEG4 low-level decoder API control
  media: platform: Add Sunxi Cedrus decoder driver
  sunxi-cedrus: Add a MPEG 2 codec
  sunxi-cedrus: Add a MPEG 4 codec
  sunxi-cedrus: Add device tree binding document
  ARM: dts: sun5i: Use video-engine node

Hans Verkuil (15):
  videodev2.h: add max_reqs to struct v4l2_query_ext_ctrl
  videodev2.h: add request to v4l2_ext_controls
  videodev2.h: add request field to v4l2_buffer.
  vb2: add allow_requests flag
  v4l2-ctrls: add request support
  v4l2-ctrls: add function to apply a request.
  v4l2-ctrls: implement delete request(s)
  v4l2-ctrls: add VIDIOC_REQUEST_CMD
  v4l2: add initial V4L2_REQ_CMD_QUEUE support
  vb2: add helper function to queue request-specific buffer.
  v4l2-device: keep track of registered video_devices
  v4l2-device: add v4l2_device_req_queue
  vivid: add request support for video capture.
  v4l2-ctrls: add REQ_KEEP flag
  Documentation: add v4l2-requests.txt

Icenowy Zheng (2):
  sunxi-cedrus: add syscon support
  ARM: dts: sun8i: add video engine support for A33

Thomas van Kleef (4):
  Merged requests2 into linux 4.14
  Fix merge error
  Remove reject file from merge
  Fix the sun5i and sun8i dts files

 .../devicetree/bindings/media/sunxi-cedrus.txt |  44 ++
 Documentation/video4linux/v4l2-requests.txt| 233 
 arch/arm/boot/dts/sun5i-a13-difrnce-dit4350.dts|  50 --
 arch/arm/boot/dts/sun5i-a13.dtsi   |  30 ++
 arch/arm/boot/dts/sun8i-a33.dtsi   |  39 ++
 drivers/media/platform/Kconfig |  13 +
 drivers/media/platform/Makefile|   1 +
 drivers/media/platform/sunxi-cedrus/Makefile   |   4 +
 drivers/media/platform/sunxi-cedrus/sunxi_cedrus.c | 285 ++
 .../platform/sunxi-cedrus/sunxi_cedrus_common.h| 104 
 .../media/platform/sunxi-cedrus/sunxi_cedrus_dec.c | 588 +
 .../media/platform/sunxi-cedrus/sunxi_cedrus_dec.h |  33 ++
 .../media/platform/sunxi-cedrus/sunxi_cedrus_hw.c  | 180 +++
 .../media/platform/sunxi-cedrus/sunxi_cedrus_hw.h  |  39 ++
 .../platform/sunxi-cedrus/sunxi_cedrus_mpeg2.c   

[PATCH v3 27/36] hrtimer: Prepare handling of hard and softirq based hrtimers

2017-11-29 Thread Anna-Maria Gleixner
The softirq based hrtimer can utilize most of the existing hrtimers
functions, but need to operate on a different data set.

Add an active_mask argument to various functions so the hard and soft bases
can be selected. Fixup the existing callers and hand in the ACTIVE_HARD
mask.

Signed-off-by: Anna-Maria Gleixner 
---
 kernel/time/hrtimer.c | 38 +-
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index e2724f8a2340..65211fd7288d 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -60,6 +60,15 @@
 #include "tick-internal.h"
 
 /*
+ * Masks for selecting the soft and hard context timers from
+ * cpu_base->active
+ */
+#define MASK_SHIFT (HRTIMER_BASE_MONOTONIC_SOFT)
+#define HRTIMER_ACTIVE_HARD((1U << MASK_SHIFT) - 1)
+#define HRTIMER_ACTIVE_SOFT(HRTIMER_ACTIVE_HARD << MASK_SHIFT)
+#define HRTIMER_ACTIVE_ALL (HRTIMER_ACTIVE_SOFT | HRTIMER_ACTIVE_HARD)
+
+/*
  * The timer bases:
  *
  * There are more clockids than hrtimer bases. Thus, we index
@@ -508,13 +517,24 @@ static ktime_t __hrtimer_next_event_base(struct 
hrtimer_cpu_base *cpu_base,
return expires_next;
 }
 
-static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base)
+/*
+ * Recomputes cpu_base::*next_timer and returns the earliest expires_next but
+ * does not set cpu_base::*expires_next, that is done by hrtimer_reprogram.
+ *
+ * @active_mask must be one of:
+ *  - HRTIMER_ACTIVE,
+ *  - HRTIMER_ACTIVE_SOFT, or
+ *  - HRTIMER_ACTIVE_HARD.
+ */
+static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base,
+   unsigned int active_mask)
 {
-   unsigned int active = cpu_base->active_bases;
+   unsigned int active;
ktime_t expires_next = KTIME_MAX;
 
cpu_base->next_timer = NULL;
 
+   active = cpu_base->active_bases & active_mask;
expires_next = __hrtimer_next_event_base(cpu_base, active, 
expires_next);
 
return expires_next;
@@ -555,7 +575,7 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, 
int skip_equal)
 {
ktime_t expires_next;
 
-   expires_next = __hrtimer_get_next_event(cpu_base);
+   expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_HARD);
 
if (skip_equal && expires_next == cpu_base->expires_next)
return;
@@ -1076,7 +1096,7 @@ u64 hrtimer_get_next_event(void)
raw_spin_lock_irqsave(_base->lock, flags);
 
if (!__hrtimer_hres_active(cpu_base))
-   expires = __hrtimer_get_next_event(cpu_base);
+   expires = __hrtimer_get_next_event(cpu_base, 
HRTIMER_ACTIVE_HARD);
 
raw_spin_unlock_irqrestore(_base->lock, flags);
 
@@ -1250,10 +1270,10 @@ static void __run_hrtimer(struct hrtimer_cpu_base 
*cpu_base,
 }
 
 static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t 
now,
-unsigned long flags)
+unsigned long flags, unsigned int active_mask)
 {
struct hrtimer_clock_base *base;
-   unsigned int active = cpu_base->active_bases;
+   unsigned int active = cpu_base->active_bases & active_mask;
 
for_each_active_base(base, cpu_base, active) {
struct timerqueue_node *node;
@@ -1316,10 +1336,10 @@ void hrtimer_interrupt(struct clock_event_device *dev)
 */
cpu_base->expires_next = KTIME_MAX;
 
-   __hrtimer_run_queues(cpu_base, now, flags);
+   __hrtimer_run_queues(cpu_base, now, flags, HRTIMER_ACTIVE_HARD);
 
/* Reevaluate the clock bases for the next expiry */
-   expires_next = __hrtimer_get_next_event(cpu_base);
+   expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_HARD);
/*
 * Store the new expiry value so the migration code can verify
 * against it.
@@ -1423,7 +1443,7 @@ void hrtimer_run_queues(void)
 
raw_spin_lock_irqsave(_base->lock, flags);
now = hrtimer_update_base(cpu_base);
-   __hrtimer_run_queues(cpu_base, now, flags);
+   __hrtimer_run_queues(cpu_base, now, flags, HRTIMER_ACTIVE_HARD);
raw_spin_unlock_irqrestore(_base->lock, flags);
 }
 
-- 
2.11.0



Re: [PATCH v8 1/6] lib/dlock-list: Distributed and lock-protected lists

2017-11-29 Thread Davidlohr Bueso

On Tue, 31 Oct 2017, Waiman Long wrote:


Linked list is used everywhere in the Linux kernel. However, if many
threads are trying to add or delete entries into the same linked list,
it can create a performance bottleneck.

This patch introduces a new list APIs that provide a set of distributed
lists (one per CPU), each of which is protected by its own spinlock.
To the callers, however, the set of lists acts like a single
consolidated list.  This allows list entries insertion and deletion
operations to happen in parallel instead of being serialized with a
global list and lock.

List entry insertion is strictly per cpu. List deletion, however, can
happen in a cpu other than the one that did the insertion. So we still
need lock to protect the list. Because of that, there may still be
a small amount of contention when deletion is being done.

A new header file include/linux/dlock-list.h will be added with the
associated dlock_list_head and dlock_list_node structures. The following
functions are provided to manage the per-cpu list:

1. int alloc_dlock_list_heads(struct dlock_list_heads *dlist)
2. void free_dlock_list_heads(struct dlock_list_heads *dlist)
3. void dlock_list_add(struct dlock_list_node *node,
struct dlock_list_heads *dlist)
4. void dlock_list_del(struct dlock_list *node)

Iteration of all the list entries within a dlock list array
is done by calling either the dlist_for_each_entry() or
dlist_for_each_entry_safe() macros. They correspond to the
list_for_each_entry() and list_for_each_entry_safe() macros
respectively. The iteration states are keep in a dlock_list_iter
structure that is passed to the iteration macros.

Signed-off-by: Waiman Long 
Reviewed-by: Jan Kara 


Reviewed-by: Davidlohr Bueso 


[PATCH v3 29/36] hrtimer: Implement SOFT/HARD clock base selection

2017-11-29 Thread Anna-Maria Gleixner
All prerequisites to handle hrtimers for expiry in either hard or soft
interrupt context are in place.

Add the missing bit in hrtimer_init() which associates the timer to the
hard or the soft irq clock base.

Signed-off-by: Anna-Maria Gleixner 
---
 kernel/time/hrtimer.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 40b14f025829..68328ceefc7f 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1218,8 +1218,9 @@ static inline int hrtimer_clockid_to_base(clockid_t 
clock_id)
 static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
   enum hrtimer_mode mode)
 {
+   bool softtimer = !!(mode & HRTIMER_MODE_SOFT);
+   int base = softtimer ? HRTIMER_MAX_CLOCK_BASES / 2 : 0;
struct hrtimer_cpu_base *cpu_base;
-   int base;
 
memset(timer, 0, sizeof(struct hrtimer));
 
@@ -1233,7 +1234,8 @@ static void __hrtimer_init(struct hrtimer *timer, 
clockid_t clock_id,
if (clock_id == CLOCK_REALTIME && mode & HRTIMER_MODE_REL)
clock_id = CLOCK_MONOTONIC;
 
-   base = hrtimer_clockid_to_base(clock_id);
+   base += hrtimer_clockid_to_base(clock_id);
+   timer->is_soft = softtimer;
timer->base = _base->clock_base[base];
timerqueue_init(>node);
 }
@@ -1242,8 +1244,13 @@ static void __hrtimer_init(struct hrtimer *timer, 
clockid_t clock_id,
  * hrtimer_init - initialize a timer to the given clock
  * @timer: the timer to be initialized
  * @clock_id:  the clock to be used
- * @mode:  timer mode: absolute (HRTIMER_MODE_ABS) or
- * relative (HRTIMER_MODE_REL); pinned is not considered here!
+ * @mode:   The modes which are relevant for intitialization:
+ *  HRTIMER_MODE_ABS, HRTIMER_MODE_REL, HRTIMER_MODE_ABS_SOFT,
+ *  HRTIMER_MODE_REL_SOFT
+ *
+ *  The PINNED variants of the above can be handed in,
+ *  but the PINNED bit is ignored as pinning happens
+ *  when the hrtimer is started
  */
 void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
  enum hrtimer_mode mode)
-- 
2.11.0



[PATCH v3 15/36] hrtimer: Make the remote enqueue check unconditional

2017-11-29 Thread Anna-Maria Gleixner
hrtimer_cpu_base.expires_next is used to cache the next event armed in the
timer hardware. The value is used to check whether an hrtimer can be
enqueued remotely. If the new hrtimer is expiring before expires_next, then
remote enqueue is not possible as the remote hrtimer hardware cannot be
accessed for reprogramming to an earlier expiry time.

The remote enqueue check is currently conditional on
CONFIG_HIGH_RES_TIMERS=y and hrtimer_cpu_base.hres_active. There is no
compelling reason to make this conditional.

Move hrtimer_cpu_base.expires_next out of the CONFIG_HIGH_RES_TIMERS=y
guarded area and remove the conditionals in hrtimer_check_target().

The check is currently a NOOP for the CONFIG_HIGH_RES_TIMERS=n and the
!hrtimer_cpu_base.hres_active case because in these cases nothing updates
hrtimer_cpu_base.expires_next yet. This will be changed with later patches
which further reduce the #ifdef zoo in this code.

Signed-off-by: Anna-Maria Gleixner 
---
 include/linux/hrtimer.h |  6 +++---
 kernel/time/hrtimer.c   | 26 ++
 2 files changed, 9 insertions(+), 23 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 22627b3a33fe..bb7270e8bc37 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -164,13 +164,13 @@ enum  hrtimer_base_type {
  * @hres_active:   State of high resolution mode
  * @in_hrtirq: hrtimer_interrupt() is currently executing
  * @hang_detected: The last hrtimer interrupt detected a hang
- * @expires_next:  absolute time of the next event, is required for remote
- * hrtimer enqueue
  * @next_timer:Pointer to the first expiring timer
  * @nr_events: Total number of hrtimer interrupt events
  * @nr_retries:Total number of hrtimer interrupt retries
  * @nr_hangs:  Total number of hrtimer interrupt hangs
  * @max_hang_time: Maximum time spent in hrtimer_interrupt
+ * @expires_next:  absolute time of the next event, is required for remote
+ * hrtimer enqueue
  * @clock_base:array of clock bases for this cpu
  *
  * Note: next_timer is just an optimization for __remove_hrtimer().
@@ -186,13 +186,13 @@ struct hrtimer_cpu_base {
 #ifdef CONFIG_HIGH_RES_TIMERS
unsigned intin_hrtirq   : 1,
hang_detected   : 1;
-   ktime_t expires_next;
struct hrtimer  *next_timer;
unsigned intnr_events;
unsigned short  nr_retries;
unsigned short  nr_hangs;
unsigned intmax_hang_time;
 #endif
+   ktime_t expires_next;
struct hrtimer_clock_base   clock_base[HRTIMER_MAX_CLOCK_BASES];
 } cacheline_aligned;
 
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 0a1804c65a15..069e3dfd0e3c 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -154,26 +154,21 @@ struct hrtimer_clock_base *lock_hrtimer_base(const struct 
hrtimer *timer,
 }
 
 /*
- * With HIGHRES=y we do not migrate the timer when it is expiring
- * before the next event on the target cpu because we cannot reprogram
- * the target cpu hardware and we would cause it to fire late.
+ * We do not migrate the timer when it is expiring before the next
+ * event on the target cpu. When high resolution is enabled, we cannot
+ * reprogram the target cpu hardware and we would cause it to fire
+ * late. To keep it simple, we handle the high resolution enabled and
+ * disabled case similar.
  *
  * Called with cpu_base->lock of target cpu held.
  */
 static int
 hrtimer_check_target(struct hrtimer *timer, struct hrtimer_clock_base 
*new_base)
 {
-#ifdef CONFIG_HIGH_RES_TIMERS
ktime_t expires;
 
-   if (!new_base->cpu_base->hres_active)
-   return 0;
-
expires = ktime_sub(hrtimer_get_expires(timer), new_base->offset);
return expires <= new_base->cpu_base->expires_next;
-#else
-   return 0;
-#endif
 }
 
 static inline
@@ -657,14 +652,6 @@ static void hrtimer_reprogram(struct hrtimer *timer,
 }
 
 /*
- * Initialize the high resolution related parts of cpu_base
- */
-static inline void hrtimer_init_hres(struct hrtimer_cpu_base *base)
-{
-   base->expires_next = KTIME_MAX;
-}
-
-/*
  * Retrigger next event is called after clock was set
  *
  * Called with interrupts disabled via on_each_cpu()
@@ -729,7 +716,6 @@ static inline int hrtimer_reprogram(struct hrtimer *timer,
 {
return 0;
 }
-static inline void hrtimer_init_hres(struct hrtimer_cpu_base *base) { }
 static inline void retrigger_next_event(void *arg) { }
 
 #endif /* CONFIG_HIGH_RES_TIMERS */
@@ -1599,7 +1585,7 @@ int hrtimers_prepare_cpu(unsigned int cpu)
 
cpu_base->cpu = cpu;
cpu_base->hres_active = 0;
-   

[PATCH v3 11/36] hrtimer: Store running timer in hrtimer_clock_base

2017-11-29 Thread Anna-Maria Gleixner
The pointer to the currently running timer is stored in hrtimer_cpu_base
before the base lock is dropped and the callback is invoked.

This results in two levels of indirections and the upcoming support for
softirq based hrtimer requires splitting the "running" storage into soft
and hard irq context expiry.

Storing both in the cpu base would require conditionals in all code paths
accessing that information.

It's possible to have a per clock base sequence count and running pointer
without changing the semantics of the related mechanisms because the timer
base pointer cannot be changed while a timer is running the callback.

Unfortunately this makes cpu_clock base larger than 32 bytes on 32bit
kernels. Instead of having huge gaps due to alignment, remove the alignment
and let the compiler pack cpu base for 32bit. The resulting cache access
patterns are fortunately not really different from the current
behaviour. On 64bit kernels the 64byte alignment stays and the behaviour is
unchanged. This was determined by analyzing the resulting layout and
looking at the number of cache lines involved for the frequently used
clocks.

Signed-off-by: Anna-Maria Gleixner 
---
 include/linux/hrtimer.h | 20 +---
 kernel/time/hrtimer.c   | 28 +---
 2 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 28f267cf2851..1bae7b9f071d 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -118,9 +118,9 @@ struct hrtimer_sleeper {
 };
 
 #ifdef CONFIG_64BIT
-# define HRTIMER_CLOCK_BASE_ALIGN  64
+# define __hrtimer_clock_base_aligncacheline_aligned
 #else
-# define HRTIMER_CLOCK_BASE_ALIGN  32
+# define __hrtimer_clock_base_align
 #endif
 
 /**
@@ -129,18 +129,22 @@ struct hrtimer_sleeper {
  * @index: clock type index for per_cpu support when moving a
  * timer to a base on another cpu.
  * @clockid:   clock id for per_cpu support
+ * @seq:   seqcount around __run_hrtimer
+ * @running:   pointer to the currently running hrtimer
  * @active:red black tree root node for the active timers
  * @get_time:  function to retrieve the current time of the clock
  * @offset:offset of this clock to the monotonic base
  */
 struct hrtimer_clock_base {
struct hrtimer_cpu_base *cpu_base;
-   int index;
+   unsigned intindex;
clockid_t   clockid;
+   seqcount_t  seq;
+   struct hrtimer  *running;
struct timerqueue_head  active;
ktime_t (*get_time)(void);
ktime_t offset;
-} __attribute__((__aligned__(HRTIMER_CLOCK_BASE_ALIGN)));
+} __hrtimer_clock_base_align;
 
 enum  hrtimer_base_type {
HRTIMER_BASE_MONOTONIC,
@@ -154,8 +158,6 @@ enum  hrtimer_base_type {
  * struct hrtimer_cpu_base - the per cpu clock bases
  * @lock:  lock protecting the base and associated clock bases
  * and timers
- * @seq:   seqcount around __run_hrtimer
- * @running:   pointer to the currently running hrtimer
  * @cpu:   cpu number
  * @active_bases:  Bitfield to mark bases with active timers
  * @clock_was_set_seq: Sequence counter of clock was set events
@@ -177,8 +179,6 @@ enum  hrtimer_base_type {
  */
 struct hrtimer_cpu_base {
raw_spinlock_t  lock;
-   seqcount_t  seq;
-   struct hrtimer  *running;
unsigned intcpu;
unsigned intactive_bases;
unsigned intclock_was_set_seq;
@@ -198,8 +198,6 @@ struct hrtimer_cpu_base {
 
 static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
 {
-   BUILD_BUG_ON(sizeof(struct hrtimer_clock_base) > 
HRTIMER_CLOCK_BASE_ALIGN);
-
timer->node.expires = time;
timer->_softexpires = time;
 }
@@ -424,7 +422,7 @@ static inline int hrtimer_is_queued(struct hrtimer *timer)
  */
 static inline int hrtimer_callback_running(struct hrtimer *timer)
 {
-   return timer->base->cpu_base->running == timer;
+   return timer->base->running == timer;
 }
 
 /* Forward a hrtimer so it expires after now: */
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 326faa5719ff..046b509beed6 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -70,7 +70,6 @@
 DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
 {
.lock = __RAW_SPIN_LOCK_UNLOCKED(hrtimer_bases.lock),
-   .seq = SEQCNT_ZERO(hrtimer_bases.seq),
.clock_base =
{
{
@@ -118,7 +117,6 @@ static const int hrtimer_clock_to_base_table[MAX_CLOCKS] = {
  * timer->base->cpu_base
  */
 static struct hrtimer_cpu_base migration_cpu_base = {
-   .seq = 

[PATCH v3 20/36] hrtimer: Unify handling of remote enqueue

2017-11-29 Thread Anna-Maria Gleixner
hrtimer_reprogram() is conditionally invoked from hrtimer_start_range_ns()
when hrtimer_cpu_base.hres_active is true.

In the !hres_active case there is a special condition for the nohz_active
case:

  If the newly enqueued timer expires before the first expiring timer on a
  remote CPU then the remote CPU needs to be notified and woken up from a
  NOHZ idle sleep to take the new first expiring timer into account.

Previous changes have already established the prerequisites to make the
remote enqueue behaviour the same whether high resolution mode is active or
not:

  If the to be enqueued timer expires before the first expiring timer on a
  remote CPU, then it cannot be enqueued there.

This was done for the high resolution mode because there is no way to
access the remote CPU timer hardware. The same is true for NOHZ, but was
handled differently by unconditionally enqueuing the timer and waking up
the remote CPU so it can reprogram its timer. Again there is no compelling
reason for this difference.

hrtimer_check_target(), which makes the 'can remote enqueue' decision is
already unconditional, but not yet functional because nothing updates
hrtimer_cpu_base.expires_next in the !hres_active case.

To unify this the following changes are required:

 1) Make the store of the new first expiry time unconditonal in
hrtimer_reprogram() and check __hrtimer_hres_active() before proceeding
to the actual hardware access. This check also lets the compiler
eliminate the rest of the function in case of CONFIG_HIGH_RES_TIMERS=n.

 2) Invoke hrtimer_reprogram() unconditionally from
hrtimer_start_range_ns()

 3) Remove the remote wakeup special case for the !high_res && nohz_active
case.

Confine the timers_nohz_active static key to timer.c which is the only user
now.

Signed-off-by: Anna-Maria Gleixner 
---
 kernel/time/hrtimer.c   | 18 ++
 kernel/time/tick-internal.h |  6 --
 kernel/time/timer.c |  9 -
 3 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 617573109398..90a8aa9a7fa2 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -687,21 +687,24 @@ static void hrtimer_reprogram(struct hrtimer *timer,
 
/* Update the pointer to the next expiring timer */
cpu_base->next_timer = timer;
+   cpu_base->expires_next = expires;
 
/*
+* If hres is not active, hardware does not have to be
+* programmed yet.
+*
 * If a hang was detected in the last timer interrupt then we
 * do not schedule a timer which is earlier than the expiry
 * which we enforced in the hang detection. We want the system
 * to make progress.
 */
-   if (cpu_base->hang_detected)
+   if (!__hrtimer_hres_active(cpu_base) || cpu_base->hang_detected)
return;
 
/*
 * Program the timer hardware. We enforce the expiry for
 * events which are already in the past.
 */
-   cpu_base->expires_next = expires;
tick_program_event(expires, 1);
 }
 
@@ -938,16 +941,7 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t 
tim,
if (!leftmost)
goto unlock;
 
-   if (!hrtimer_is_hres_active(timer)) {
-   /*
-* Kick to reschedule the next tick to handle the new timer
-* on dynticks target.
-*/
-   if (is_timers_nohz_active())
-   wake_up_nohz_cpu(new_base->cpu_base->cpu);
-   } else {
-   hrtimer_reprogram(timer, new_base);
-   }
+   hrtimer_reprogram(timer, new_base);
 unlock:
unlock_hrtimer_base(timer, );
 }
diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h
index 4ac74dff59f0..e277284c2831 100644
--- a/kernel/time/tick-internal.h
+++ b/kernel/time/tick-internal.h
@@ -151,18 +151,12 @@ static inline void tick_nohz_init(void) { }
 #ifdef CONFIG_NO_HZ_COMMON
 extern unsigned long tick_nohz_active;
 extern void timers_update_nohz(void);
-extern struct static_key_false timers_nohz_active;
-static inline bool is_timers_nohz_active(void)
-{
-   return static_branch_unlikely(_nohz_active);
-}
 # ifdef CONFIG_SMP
 extern struct static_key_false timers_migration_enabled;
 # endif
 #else /* CONFIG_NO_HZ_COMMON */
 static inline void timers_update_nohz(void) { }
 #define tick_nohz_active (0)
-static inline bool is_timers_nohz_active(void) { return false; }
 #endif
 
 DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 1e2140a23044..4b39029fbe99 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -210,7 +210,7 @@ static DEFINE_PER_CPU(struct timer_base, 
timer_bases[NR_BASES]);
 
 #ifdef CONFIG_NO_HZ_COMMON
 
-DEFINE_STATIC_KEY_FALSE(timers_nohz_active);
+static DEFINE_STATIC_KEY_FALSE(timers_nohz_active);
 static 

[GIT] Networking

2017-11-29 Thread David Miller

There is a small overlapping conflict to net/rxrpc/call_object.c, it should
be easy to resolve.  In your tree there was a setup_timer() --> timer_setup()
conversion, and in my tree there are new lines adding a lockdep_set_class()
call right beforehand.

1) The forcedeth conversion from pci_*() DMA interfaces to dma_*() ones
   missed one spot.  From Zhu Yanjun.

2) Missing CRYPTO_SHA256 Kconfig dep in cfg80211, from Johannes Berg.

3) Fix checksum offloading in thunderx driver, from Sunil Goutham.

4) Add SPDX to vm_sockets_diag.h, from Stephen Hemminger.

5) Fix use after free of packet headers in TIPC, from Jon Maloy.

6) "sizeof(ptr)" vs "sizeof(*ptr)" bug in i40e, from Gustavo A R
   Silva.

7) Tunneling fixes in mlxsw driver, from Petr Machata.

8) Fix crash in fanout_demux_rollover() of AF_PACKET, from Mike
   Maloney.

9) Fix race in AF_PACKET bind() vs. NETDEV_UP notifier, from Eric
   Dumazet.

10) Fix regression in sch_sfq.c due to one of the timer_setup()
conversions.  From Paolo Abeni.

11) SCTP does list_for_each_entry() using wrong struct member,
fix from Xin Long.

12) Don't use big endian netlink attribute read for
IFLA_BOND_AD_ACTOR_SYSTEM, it is in cpu endianness.
Also from Xin Long.

13) Fix mis-initialization of q->link.clock in CBQ scheduler, preventing
adding filters there.  From Jiri Pirko.

Please pull, thanks a lot!

The following changes since commit 1d3b78bbc6e983fabb3fbf91b76339bf66e4a12c:

  Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (2017-11-23 
21:18:46 -1000)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 

for you to fetch changes up to f6454f80e8a965fca203dab28723f68ec78db608:

  ethernet: dwmac-stm32: Fix copyright (2017-11-29 10:08:09 -0500)


Ahmad Fatoum (1):
  e1000: Fix off-by-one in debug message

Amritha Nambiar (1):
  i40e: Fix reporting incorrect error codes

Antoine Tenart (4):
  net: mvpp2: fix the txq_init error path
  net: mvpp2: cleanup probed ports in the probe error path
  net: mvpp2: check ethtool sets the Tx ring size is to a valid min value
  net: phy: marvell10g: fix the PHY id mask

Benjamin Gaignard (1):
  ethernet: dwmac-stm32: Fix copyright

Christophe JAILLET (1):
  bnxt_en: Fix an error handling path in 'bnxt_get_module_eeprom()'

Chun-Yeow Yeoh (1):
  mac80211: fix the update of path metric for RANN frame

Colin Ian King (5):
  ambassador: fix incorrect indentation of assignment statement
  atm: fore200e: use %pK to format kernel addresses instead of %x
  atm: lanai: use %p to format kernel addresses instead of %x
  atm: suni: remove extraneous space to fix indentation
  net: via: via-rhine: use %p to format void * address instead of %x

David Howells (12):
  rxrpc: The mutex lock returned by rxrpc_accept_call() needs releasing
  rxrpc: Don't set upgrade by default in sendmsg()
  rxrpc: Provide a different lockdep key for call->user_mutex for kernel 
calls
  rxrpc: Delay terminal ACK transmission on a client call
  rxrpc: Split the call params from the operation params
  rxrpc: Fix call timeouts
  rxrpc: Don't transmit DELAY ACKs immediately on proposal
  rxrpc: Express protocol timeouts in terms of RTT
  rxrpc: Add a timeout for detecting lost ACKs/lost DATA
  rxrpc: Add keepalive for a call
  rxrpc: Fix service endpoint expiry
  rxrpc: Fix conn expiry timers

David S. Miller (7):
  Merge tag 'rxrpc-fixes-20171124' of 
git://git.kernel.org/.../dhowells/linux-fs
  Merge branch 'sctp-stream-reconfig-fixes'
  Merge tag 'mac80211-for-davem-2017-11-27' of 
git://git.kernel.org/.../jberg/mac80211
  Merge branch '40GbE' of git://git.kernel.org/.../jkirsher/net-queue
  Merge branch 'mlxsw-GRE-offloading-fixes'
  Merge branch 'mvpp2-fixes'
  Merge branch 'sctp-fix-sparse-errors'

Eduardo Otubo (1):
  xen-netfront: remove warning when unloading module

Eric Dumazet (1):
  net/packet: fix a race in packet_bind() and packet_notifier()

Geert Uytterhoeven (1):
  net: ethernet: xilinx: Mark XILINX_LL_TEMAC broken on 64-bit

Gustavo A R Silva (1):
  i40e/virtchnl: fix application of sizeof to pointer

Gustavo A. R. Silva (1):
  net: openvswitch: datapath: fix data type in queue_gso_packets

Hyong-Youb Kim (1):
  myri10ge: Update MAINTAINERS

Jakub Kicinski (1):
  cls_bpf: don't decrement net's refcount when offload fails

Jiri Pirko (1):
  net: sched: cbq: create block for q->link.block

Johannes Berg (2):
  cfg80211: select CRYPTO_SHA256 if needed
  mac80211: use QoS NDP for AP probing

Jon Maloy (1):
  tipc: eliminate access after delete in group_filter_msg()

Jorgen Hansen (2):
  VSOCK: Don't call vsock_stream_has_data in atomic context
  VSOCK: Don't set sk_state to TCP_CLOSE before testing it

Mika Westerberg (1):
 

[PATCH v3 16/36] hrtimer: Make hrtimer_cpu_base.next_timer handling unconditional

2017-11-29 Thread Anna-Maria Gleixner
hrtimer_cpu_base.next_timer stores the pointer to the next expiring timer
in a cpu base.

This pointer cannot be dereferenced and is solely used to check whether a
hrtimer which is removed is the hrtimer which is the first to expire in the
CPU base. If this is the case, then the timer hardware needs to be
reprogrammed to avoid an extra interrupt for nothing.

Again, this is conditional functionality, but there is no compelling reason
to make this conditional. As a preparation, hrtimer_cpu_base.next_timer
needs to be available unconditonal. Aside of that the upcoming support for
softirq based hrtimers requires access to this pointer unconditionally.

Make the update of hrtimer_cpu_base.next_timer unconditional and remove the
ifdef cruft. The impact on CONFIG_HIGH_RES_TIMERS=n && CONFIG_NOHZ=n is
marginal as it's just a store on an already dirtied cacheline.

No functional change.

Signed-off-by: Anna-Maria Gleixner 
---
 include/linux/hrtimer.h |  4 ++--
 kernel/time/hrtimer.c   | 12 ++--
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index bb7270e8bc37..2d3e1d678a4d 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -164,13 +164,13 @@ enum  hrtimer_base_type {
  * @hres_active:   State of high resolution mode
  * @in_hrtirq: hrtimer_interrupt() is currently executing
  * @hang_detected: The last hrtimer interrupt detected a hang
- * @next_timer:Pointer to the first expiring timer
  * @nr_events: Total number of hrtimer interrupt events
  * @nr_retries:Total number of hrtimer interrupt retries
  * @nr_hangs:  Total number of hrtimer interrupt hangs
  * @max_hang_time: Maximum time spent in hrtimer_interrupt
  * @expires_next:  absolute time of the next event, is required for remote
  * hrtimer enqueue
+ * @next_timer:Pointer to the first expiring timer
  * @clock_base:array of clock bases for this cpu
  *
  * Note: next_timer is just an optimization for __remove_hrtimer().
@@ -186,13 +186,13 @@ struct hrtimer_cpu_base {
 #ifdef CONFIG_HIGH_RES_TIMERS
unsigned intin_hrtirq   : 1,
hang_detected   : 1;
-   struct hrtimer  *next_timer;
unsigned intnr_events;
unsigned short  nr_retries;
unsigned short  nr_hangs;
unsigned intmax_hang_time;
 #endif
ktime_t expires_next;
+   struct hrtimer  *next_timer;
struct hrtimer_clock_base   clock_base[HRTIMER_MAX_CLOCK_BASES];
 } cacheline_aligned;
 
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 069e3dfd0e3c..b424331dffae 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -459,21 +459,13 @@ __next_base(struct hrtimer_cpu_base *cpu_base, unsigned 
int *active)
while ((base = __next_base((cpu_base), &(active
 
 #if defined(CONFIG_NO_HZ_COMMON) || defined(CONFIG_HIGH_RES_TIMERS)
-static inline void hrtimer_update_next_timer(struct hrtimer_cpu_base *cpu_base,
-struct hrtimer *timer)
-{
-#ifdef CONFIG_HIGH_RES_TIMERS
-   cpu_base->next_timer = timer;
-#endif
-}
-
 static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base)
 {
struct hrtimer_clock_base *base;
unsigned int active = cpu_base->active_bases;
ktime_t expires, expires_next = KTIME_MAX;
 
-   hrtimer_update_next_timer(cpu_base, NULL);
+   cpu_base->next_timer = NULL;
for_each_active_base(base, cpu_base, active) {
struct timerqueue_node *next;
struct hrtimer *timer;
@@ -483,7 +475,7 @@ static ktime_t __hrtimer_get_next_event(struct 
hrtimer_cpu_base *cpu_base)
expires = ktime_sub(hrtimer_get_expires(timer), base->offset);
if (expires < expires_next) {
expires_next = expires;
-   hrtimer_update_next_timer(cpu_base, timer);
+   cpu_base->next_timer = timer;
}
}
/*
-- 
2.11.0



[PATCH v3 17/36] hrtimer: Make hrtimer_reprogramm() unconditional

2017-11-29 Thread Anna-Maria Gleixner
hrtimer_reprogram() needs to be available unconditionally for softirq based
hrtimers. Move the function and all required struct members out of the
CONFIG_HIGH_RES_TIMERS #ifdef.

There is no functional change because hrtimer_reprogram() is only invoked
when hrtimer_cpu_base.hres_active is true. Making it unconditional
increases the text size for the CONFIG_HIGH_RES_TIMERS=n case, but avoids
replication of that code for the upcoming softirq based hrtimers support.

Signed-off-by: Anna-Maria Gleixner 
---
 include/linux/hrtimer.h |   6 +--
 kernel/time/hrtimer.c   | 129 +++-
 2 files changed, 65 insertions(+), 70 deletions(-)

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 2d3e1d678a4d..98ed35767ac5 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -182,10 +182,10 @@ struct hrtimer_cpu_base {
unsigned intcpu;
unsigned intactive_bases;
unsigned intclock_was_set_seq;
-   unsigned inthres_active : 1;
-#ifdef CONFIG_HIGH_RES_TIMERS
-   unsigned intin_hrtirq   : 1,
+   unsigned inthres_active : 1,
+   in_hrtirq   : 1,
hang_detected   : 1;
+#ifdef CONFIG_HIGH_RES_TIMERS
unsigned intnr_events;
unsigned short  nr_retries;
unsigned short  nr_hangs;
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index b424331dffae..c9173699b549 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -582,68 +582,6 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, 
int skip_equal)
 }
 
 /*
- * When a timer is enqueued and expires earlier than the already enqueued
- * timers, we have to check, whether it expires earlier than the timer for
- * which the clock event device was armed.
- *
- * Called with interrupts disabled and base->cpu_base.lock held
- */
-static void hrtimer_reprogram(struct hrtimer *timer,
- struct hrtimer_clock_base *base)
-{
-   struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(_bases);
-   ktime_t expires = ktime_sub(hrtimer_get_expires(timer), base->offset);
-
-   WARN_ON_ONCE(hrtimer_get_expires_tv64(timer) < 0);
-
-   /*
-* If the timer is not on the current cpu, we cannot reprogram
-* the other cpus clock event device.
-*/
-   if (base->cpu_base != cpu_base)
-   return;
-
-   /*
-* If the hrtimer interrupt is running, then it will
-* reevaluate the clock bases and reprogram the clock event
-* device. The callbacks are always executed in hard interrupt
-* context so we don't need an extra check for a running
-* callback.
-*/
-   if (cpu_base->in_hrtirq)
-   return;
-
-   /*
-* CLOCK_REALTIME timer might be requested with an absolute
-* expiry time which is less than base->offset. Set it to 0.
-*/
-   if (expires < 0)
-   expires = 0;
-
-   if (expires >= cpu_base->expires_next)
-   return;
-
-   /* Update the pointer to the next expiring timer */
-   cpu_base->next_timer = timer;
-
-   /*
-* If a hang was detected in the last timer interrupt then we
-* do not schedule a timer which is earlier than the expiry
-* which we enforced in the hang detection. We want the system
-* to make progress.
-*/
-   if (cpu_base->hang_detected)
-   return;
-
-   /*
-* Program the timer hardware. We enforce the expiry for
-* events which are already in the past.
-*/
-   cpu_base->expires_next = expires;
-   tick_program_event(expires, 1);
-}
-
-/*
  * Retrigger next event is called after clock was set
  *
  * Called with interrupts disabled via on_each_cpu()
@@ -703,16 +641,73 @@ static inline int hrtimer_is_hres_enabled(void) { return 
0; }
 static inline void hrtimer_switch_to_hres(void) { }
 static inline void
 hrtimer_force_reprogram(struct hrtimer_cpu_base *base, int skip_equal) { }
-static inline int hrtimer_reprogram(struct hrtimer *timer,
-   struct hrtimer_clock_base *base)
-{
-   return 0;
-}
 static inline void retrigger_next_event(void *arg) { }
 
 #endif /* CONFIG_HIGH_RES_TIMERS */
 
 /*
+ * When a timer is enqueued and expires earlier than the already enqueued
+ * timers, we have to check, whether it expires earlier than the timer for
+ * which the clock event device was armed.
+ *
+ * Called with interrupts disabled and base->cpu_base.lock held
+ */
+static void hrtimer_reprogram(struct hrtimer *timer,
+ struct hrtimer_clock_base *base)
+{
+   struct hrtimer_cpu_base *cpu_base = 

[PATCH v3 14/36] hrtimer: Use accesor functions instead of direct access

2017-11-29 Thread Anna-Maria Gleixner
__hrtimer_hres_active() is now available unconditionally. Replace the
direct access to hrtimer_cpu_base.hres_active.

No functional change.

Signed-off-by: Anna-Maria Gleixner 
---
 kernel/time/hrtimer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 8453dca6e0c5..0a1804c65a15 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -564,7 +564,7 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, 
int skip_equal)
 {
ktime_t expires_next;
 
-   if (!cpu_base->hres_active)
+   if (!__hrtimer_hres_active(cpu_base))
return;
 
expires_next = __hrtimer_get_next_event(cpu_base);
@@ -673,7 +673,7 @@ static void retrigger_next_event(void *arg)
 {
struct hrtimer_cpu_base *base = this_cpu_ptr(_bases);
 
-   if (!base->hres_active)
+   if (!__hrtimer_hres_active(base))
return;
 
raw_spin_lock(>lock);
-- 
2.11.0



Re: [PATCH] net: stmmac: dwmac-sun8i: fix allwinner,leds-active-low handling

2017-11-29 Thread Andrew Lunn
Hi ChenYu
 
> It worked at one point. During some previous iteration, they lit up as
> they were supposed to.

For a released version of the kernel? Or during development work?  If
they did work, but broken, it would be good to know which commit broke
it. We can then add a fixes: tag to the patch as proposed.

Andrew


[PATCH v3 3/3] virt: Add vboxguest driver for Virtual Box Guest integration

2017-11-29 Thread Hans de Goede
This commit adds a driver for the Virtual Box Guest PCI device used in
Virtual Box virtual machines. Enabling this driver will add support for
Virtual Box Guest integration features such as copy-and-paste, seamless
mode and OpenGL pass-through.

This driver also offers vboxguest IPC functionality which is needed
for the vboxfs driver which offers folder sharing support.

Signed-off-by: Hans de Goede 
Reviewed-by: Larry Finger 
---
Changes in v2:
-Change all uapi headers to kernel coding style: Drop struct and enum typedefs
 make type and struct-member names all lowercase, enum values all uppercase.
-Remove unused struct type declarations from some headers (shaving of another
 1000 lines)
-Remove or fixup doxygen style comments
-Get rid of CHECK macros, use a function taking in_ and out_size args instead
-Some other small codyingstyle fixes
-Split into multiple patches

Changes in v3:
-Add Larry's Reviewed-by
-Clarify / improve some comments
-Do not deref possible "NULL" req pointer in vbg_set_session_event_filter
 and vbg_set_session_capabilities
---
 drivers/virt/Kconfig   |1 +
 drivers/virt/Makefile  |1 +
 drivers/virt/vboxguest/Kconfig |   18 +
 drivers/virt/vboxguest/Makefile|3 +
 drivers/virt/vboxguest/vboxguest_core.c| 1582 
 drivers/virt/vboxguest/vboxguest_core.h|  187 
 drivers/virt/vboxguest/vboxguest_linux.c   |  469 +
 drivers/virt/vboxguest/vboxguest_version.h |   18 +
 8 files changed, 2279 insertions(+)
 create mode 100644 drivers/virt/vboxguest/Kconfig
 create mode 100644 drivers/virt/vboxguest/Makefile
 create mode 100644 drivers/virt/vboxguest/vboxguest_core.c
 create mode 100644 drivers/virt/vboxguest/vboxguest_core.h
 create mode 100644 drivers/virt/vboxguest/vboxguest_linux.c
 create mode 100644 drivers/virt/vboxguest/vboxguest_version.h

diff --git a/drivers/virt/Kconfig b/drivers/virt/Kconfig
index 99ebdde590f8..8d9cdfbd6bcc 100644
--- a/drivers/virt/Kconfig
+++ b/drivers/virt/Kconfig
@@ -30,4 +30,5 @@ config FSL_HV_MANAGER
   4) A kernel interface for receiving callbacks when a managed
 partition shuts down.
 
+source "drivers/virt/vboxguest/Kconfig"
 endif
diff --git a/drivers/virt/Makefile b/drivers/virt/Makefile
index c47f04dd343b..d3f7b2540890 100644
--- a/drivers/virt/Makefile
+++ b/drivers/virt/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_FSL_HV_MANAGER)   += fsl_hypervisor.o
+obj-y  += vboxguest/
diff --git a/drivers/virt/vboxguest/Kconfig b/drivers/virt/vboxguest/Kconfig
new file mode 100644
index ..fffd318a10fe
--- /dev/null
+++ b/drivers/virt/vboxguest/Kconfig
@@ -0,0 +1,18 @@
+config VBOXGUEST
+   tristate "Virtual Box Guest integration support"
+   depends on X86 && PCI && INPUT
+   help
+ This is a driver for the Virtual Box Guest PCI device used in
+ Virtual Box virtual machines. Enabling this driver will add
+ support for Virtual Box Guest integration features such as
+ copy-and-paste, seamless mode and OpenGL pass-through.
+
+ This driver also offers vboxguest IPC functionality which is needed
+ for the vboxfs driver which offers folder sharing support.
+
+ If you enable this driver you should also enable the VBOXVIDEO option.
+
+ Although it is possible to build this module in, it is advised
+ to build this driver as a module, so that it can be updated
+ independently of the kernel. Select M to build this driver as a
+ module.
diff --git a/drivers/virt/vboxguest/Makefile b/drivers/virt/vboxguest/Makefile
new file mode 100644
index ..203b8f465817
--- /dev/null
+++ b/drivers/virt/vboxguest/Makefile
@@ -0,0 +1,3 @@
+vboxguest-y := vboxguest_linux.o vboxguest_core.o vboxguest_utils.o
+
+obj-$(CONFIG_VBOXGUEST) += vboxguest.o
diff --git a/drivers/virt/vboxguest/vboxguest_core.c 
b/drivers/virt/vboxguest/vboxguest_core.c
new file mode 100644
index ..631101578c2a
--- /dev/null
+++ b/drivers/virt/vboxguest/vboxguest_core.c
@@ -0,0 +1,1582 @@
+/*
+ * vboxguest core guest-device handling code, VBoxGuest.cpp in upstream svn.
+ *
+ * Copyright (C) 2007-2016 Oracle Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, in which case the provisions of the CDDL are applicable
+ * instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 

[PATCH v3 2/3] virt: Add vboxguest VMMDEV communication code

2017-11-29 Thread Hans de Goede
This commits adds a header describing the hardware interface for the
Virtual Box Guest PCI device used in Virtual Box virtual machines and
utility functions for talking to the Virtual Box hypervisor over this
interface.

These utility functions will used both by the vboxguest driver for the
PCI device which offers the /dev/vboxguest ioctl API and by the vboxfs
driver which offers folder sharing support.

Signed-off-by: Hans de Goede 
Reviewed-by: Larry Finger 
---
Changes in v2:
-Change all uapi headers to kernel coding style: Drop struct and enum typedefs
 make type and struct-member names all lowercase, enum values all uppercase.
-Remove unused struct type declarations from some headers (shaving of another
 1000 lines)
-Remove or fixup doxygen style comments
-Get rid of CHECK macros, use a function taking in_ and out_size args instead
-Some other small codyingstyle fixes
-Split into multiple patches

Changes in v3:
-Add Larry's Reviewed-by
-Add a "Fall Through" comment to a default: in a switch-case which falls-
 through to other handling
---
 MAINTAINERS  |   2 +
 drivers/virt/vboxguest/vboxguest_utils.c | 812 +++
 drivers/virt/vboxguest/vmmdev.h  | 460 +
 include/linux/vbox_utils.h   |  92 
 4 files changed, 1366 insertions(+)
 create mode 100644 drivers/virt/vboxguest/vboxguest_utils.c
 create mode 100644 drivers/virt/vboxguest/vmmdev.h
 create mode 100644 include/linux/vbox_utils.h

diff --git a/MAINTAINERS b/MAINTAINERS
index fe3dc0e9b901..01b30c12c267 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14554,7 +14554,9 @@ M:  Hans de Goede 
 M: Arnd Bergmann 
 M: Greg Kroah-Hartman 
 S: Maintained
+F: include/linux/vbox_utils.h
 F: include/uapi/linux/vbox*.h
+F: drivers/virt/vboxguest/
 
 VIRTUAL SERIO DEVICE DRIVER
 M: Stephen Chandler Paul 
diff --git a/drivers/virt/vboxguest/vboxguest_utils.c 
b/drivers/virt/vboxguest/vboxguest_utils.c
new file mode 100644
index ..7a5278fba498
--- /dev/null
+++ b/drivers/virt/vboxguest/vboxguest_utils.c
@@ -0,0 +1,812 @@
+/*
+ * vboxguest vmm-req and hgcm-call code, VBoxGuestR0LibHGCMInternal.cpp,
+ * VBoxGuestR0LibGenericRequest.cpp and RTErrConvertToErrno.cpp in vbox svn.
+ *
+ * Copyright (C) 2006-2016 Oracle Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, in which case the provisions of the CDDL are applicable
+ * instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "vboxguest_core.h"
+
+/* Get the pointer to the first parameter of a HGCM call request. */
+#define VMMDEV_HGCM_CALL_PARMS(a) \
+   ((struct vmmdev_hgcm_function_parameter *)( \
+   (u8 *)(a) + sizeof(struct vmmdev_hgcm_call)))
+
+/* The max parameter buffer size for a user request. */
+#define VBG_MAX_HGCM_USER_PARM (24 * SZ_1M)
+/* The max parameter buffer size for a kernel request. */
+#define VBG_MAX_HGCM_KERNEL_PARM   (16 * SZ_1M)
+
+#define VBG_DEBUG_PORT 0x504
+
+/* This protects vbg_log_buf and serializes VBG_DEBUG_PORT accesses */
+static DEFINE_SPINLOCK(vbg_log_lock);
+static char vbg_log_buf[128];
+
+#define VBG_LOG(name, pr_func) \
+void name(const char *fmt, ...)
\
+{  \
+   unsigned long flags;\
+   va_list args;   \
+   int i, count;   \
+   \
+   va_start(args, fmt);\
+   spin_lock_irqsave(_log_lock, flags);\
+   \
+   count = vscnprintf(vbg_log_buf, sizeof(vbg_log_buf), fmt, args);\
+   for (i = 0; i < count; i++) \
+   outb(vbg_log_buf[i], VBG_DEBUG_PORT);   \
+   \
+   pr_func("%s", vbg_log_buf); \
+   \
+   

Re: [PATCH 3/5] PCI: cadence: Add host driver for Cadence PCIe controller

2017-11-29 Thread Bjorn Helgaas
On Wed, Nov 29, 2017 at 09:19:29AM +0100, Thomas Petazzoni wrote:
> Hello,
> 
> On Tue, 28 Nov 2017 14:41:14 -0600, Bjorn Helgaas wrote:
> 
> > > + * struct cdns_pcie_rc_data - hardware specific data  
> > 
> > "cdns" is a weird abbreviation for "Cadence", since "Cadence" doesn't
> > contain an "s".
> 
> cdns is the official Device Tree binding vendor prefix for Cadence:
> 
> $ grep Cadence Documentation/devicetree/bindings/vendor-prefixes.txt
> cdns  Cadence Design Systems Inc.
> 
> And it is already widely used throughout the kernel for Cadence
> drivers. See drivers/watchdog/cadence_wdt.c, drivers/spi/spi-cadence.c,
> drivers/i2c/busses/i2c-cadence.c, etc.

Hard to argue with that!  Thanks!


[PATCH v3 1/3] virt: Add vboxguest driver for Virtual Box Guest integration UAPI

2017-11-29 Thread Hans de Goede
This commit adds the headers describing the ioctl API for the
/dev/vboxguest device used by the Virtual Box Guest Additions
in Virtual Box virtual machines.

The driver providing the /dev/vboxguest device will allow Virtual Box
Guest Additions features such as copy-and-paste, seamless mode and
OpenGL pass-through.

Signed-off-by: Hans de Goede 
Reviewed-by: Larry Finger 
---
Changes in v2:
-Change all uapi headers to kernel coding style: Drop struct and enum typedefs
 make type and struct-member names all lowercase, enum values all uppercase.
-Remove unused struct type declarations from some headers (shaving of another
 1000 lines)
-Remove or fixup doxygen style comments
-Get rid of CHECK macros, use a function taking in_ and out_size args instead
-Some other small codyingstyle fixes
-Split into multiple patches

Changes in v3:
-Add Larry's Reviewed-by
---
 MAINTAINERS|   7 +
 include/uapi/linux/vbox_err.h  | 170 
 include/uapi/linux/vbox_vmmdev_types.h | 237 +++
 include/uapi/linux/vboxguest.h | 341 +
 4 files changed, 755 insertions(+)
 create mode 100644 include/uapi/linux/vbox_err.h
 create mode 100644 include/uapi/linux/vbox_vmmdev_types.h
 create mode 100644 include/uapi/linux/vboxguest.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 275815e2ef44..fe3dc0e9b901 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14549,6 +14549,13 @@ S: Maintained
 F: drivers/virtio/virtio_input.c
 F: include/uapi/linux/virtio_input.h
 
+VIRTUAL BOX GUEST DEVICE DRIVER
+M: Hans de Goede 
+M: Arnd Bergmann 
+M: Greg Kroah-Hartman 
+S: Maintained
+F: include/uapi/linux/vbox*.h
+
 VIRTUAL SERIO DEVICE DRIVER
 M: Stephen Chandler Paul 
 S: Maintained
diff --git a/include/uapi/linux/vbox_err.h b/include/uapi/linux/vbox_err.h
new file mode 100644
index ..6f56d2952621
--- /dev/null
+++ b/include/uapi/linux/vbox_err.h
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2017 Oracle Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __UAPI_VBOX_ERR_H__
+#define __UAPI_VBOX_ERR_H__
+
+#define VINF_SUCCESS0
+#define VERR_GENERAL_FAILURE(-1)
+#define VERR_INVALID_PARAMETER  (-2)
+#define VERR_INVALID_MAGIC  (-3)
+#define VERR_INVALID_HANDLE (-4)
+#define VERR_LOCK_FAILED(-5)
+#define VERR_INVALID_POINTER(-6)
+#define VERR_IDT_FAILED (-7)
+#define VERR_NO_MEMORY  (-8)
+#define VERR_ALREADY_LOADED (-9)
+#define VERR_PERMISSION_DENIED  (-10)
+#define VERR_VERSION_MISMATCH   (-11)
+#define VERR_NOT_IMPLEMENTED(-12)
+#define VERR_INVALID_FLAGS  (-13)
+
+#define VERR_NOT_EQUAL  (-18)
+#define VERR_NOT_SYMLINK(-19)
+#define VERR_NO_TMP_MEMORY  (-20)
+#define VERR_INVALID_FMODE  (-21)
+#define VERR_WRONG_ORDER(-22)
+#define VERR_NO_TLS_FOR_SELF(-23)
+#define VERR_FAILED_TO_SET_SELF_TLS (-24)
+#define VERR_NO_CONT_MEMORY (-26)
+#define VERR_NO_PAGE_MEMORY (-27)
+#define VERR_THREAD_IS_DEAD (-29)
+#define VERR_THREAD_NOT_WAITABLE(-30)
+#define VERR_PAGE_TABLE_NOT_PRESENT (-31)
+#define VERR_INVALID_CONTEXT(-32)
+#define VERR_TIMER_BUSY (-33)
+#define VERR_ADDRESS_CONFLICT   (-34)
+#define VERR_UNRESOLVED_ERROR   (-35)
+#define VERR_INVALID_FUNCTION   (-36)
+#define VERR_NOT_SUPPORTED  (-37)
+#define 

Re: [PATCH resend] mm/page_alloc: fix comment is __get_free_pages

2017-11-29 Thread Michal Hocko
On Mon 27-11-17 12:33:41, Michal Hocko wrote:
> On Mon 27-11-17 19:09:24, JianKang Chen wrote:
> > From: Jiankang Chen 
> > 
> > __get_free_pages will return an virtual address, 
> > but it is not just 32-bit address, for example a 64-bit system. 
> > And this comment really confuse new bigenner of mm.
> 
> s@bigenner@beginner@
> 
> Anyway, do we really need a bug on for this? Has this actually caught
> any wrong usage? VM_BUG_ON tends to be enabled these days AFAIK and
> panicking the kernel seems like an over-reaction. If there is a real
> risk then why don't we simply mask __GFP_HIGHMEM off when calling
> alloc_pages?

I meant this
---
>From 000bb422fe07adbfa8cd8ed953b18f48647a45d6 Mon Sep 17 00:00:00 2001
From: Michal Hocko 
Date: Wed, 29 Nov 2017 17:02:33 +0100
Subject: [PATCH] mm: drop VM_BUG_ON from __get_free_pages

There is no real reason to blow up just because the caller doesn't know
that __get_free_pages cannot return highmem pages. Simply fix that up
silently. Even if we have some confused users such a fixup will not be
harmful.

Signed-off-by: Michal Hocko 
---
 mm/page_alloc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 0d518e9b2ee8..3dd960ea8c13 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4284,9 +4284,7 @@ unsigned long __get_free_pages(gfp_t gfp_mask, unsigned 
int order)
 * __get_free_pages() returns a virtual address, which cannot represent
 * a highmem page
 */
-   VM_BUG_ON((gfp_mask & __GFP_HIGHMEM) != 0);
-
-   page = alloc_pages(gfp_mask, order);
+   page = alloc_pages(gfp_mask & ~__GFP_HIGHMEM, order);
if (!page)
return 0;
return (unsigned long) page_address(page);
-- 
2.15.0

-- 
Michal Hocko
SUSE Labs


Re: [PATCH 4.14 000/193] 4.14.3-stable review

2017-11-29 Thread Zdenek Kaspar
On 11/28/2017 11:24 AM, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.14.3 release.
> There are 193 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Thu Nov 30 10:05:26 UTC 2017.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.3-rc1.gz
> or in the git tree and branch at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.14.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

... snip ...

> Paolo Bonzini 
> kvm: vmx: Reinstate support for CPUs without virtual NMI

KVM works again on old Core2 CPU ... thanks, Z.


Re: [PATCH] x86/entry/64: Fix native_load_gs_index() SWAPGS handling with IRQ state tracing enabled

2017-11-29 Thread Andy Lutomirski


> On Nov 29, 2017, at 4:47 AM, Peter Zijlstra  wrote:
> 
>> On Wed, Nov 29, 2017 at 08:09:51AM +0100, Ingo Molnar wrote:
>> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
>> index f81d50d7ceac..c0b52df8ee4f 100644
>> --- a/arch/x86/entry/entry_64.S
>> +++ b/arch/x86/entry/entry_64.S
>> @@ -945,16 +945,16 @@ idtentry simd_coprocessor_error
>> do_simd_coprocessor_errorhas_error_code=0
>> */
>> ENTRY(native_load_gs_index)
>>FRAME_BEGIN
>> +SWAPGS/* switch from user GS to kernel GS */
>>pushfq
>>DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI)
>>TRACE_IRQS_OFF
>> -SWAPGS
> 
> I'm thinking those moves it too far back; we should at least have
> interrupts disabled when we do SWAPGS, no? Also, curse paravirt.
> 

I'll look in a few hours.

But we definitely can't have irqs on when running with user gs.

Re: [kernel-hardening] Re: [PATCH v5 next 5/5] net: modules: use request_module_cap() to load 'netdev-%s' modules

2017-11-29 Thread Geo Kozey
> From: Theodore Ts'o 
> Sent: Wed Nov 29 00:49:20 CET 2017
> Subject: Re: [kernel-hardening] Re: [PATCH v5 next 5/5] net: modules: use 
> request_module_cap() to load 'netdev-%s' modules
> 
> OK, but if the goal is to protect users who are running distro
> kernels, then a kernel config that breaks some percentage of users is
> highly unlikely to be enabled by Red Hat and SuSE, right?  And
> many of these users either can't (from a skills perspective) or won't
> (because they lose all support from the enterprise distro's help desk)
> recompile their kernel to enable an "might break 3% of all users ---
> oh, well" config option.
> 
> Which argues for being extremely conservative about making something
> that has an extremely low probability of breaking users, and it points
> out why Geo Kozey's "who cares about breaking users; security is
> IMPORTANT" argument is so wrong-headed.
> 

My argument was the opposite - don't break anything by default. Nobody here 
wanted to break any users. Some of them may choose stricter option because it 
actually doesn't break anything relevant for them. That's all. It's the same as 
perf_event_paranoid, kptr_restrict, yama.ptrace_scope sysctls are working 
currently.

We're talking about runtime, not compile time option. I doubt RH or SUSE 
prevent users from changing anything at runtime.


G. K.


Re: [RFC PATCH] KVM: x86: Allow Qemu/KVM to use PVH entry point

2017-11-29 Thread Paolo Bonzini
On 29/11/2017 15:47, Juergen Gross wrote:
> On 29/11/17 15:44, Paolo Bonzini wrote:
>> In either case, you would have a new option ROM.  It could either be
>> very simple and similar to multiboot.S, or it could be larger and do the
>> same task as xen-pvh.S and enlighten_pvh.c (then get the address of
>> startup_32 or startup_64 from FW_CFG_KERNEL_ENTRY and jump there).  The
>> ugly part is that the option ROM would have to know more details about
>> what it is going to boot, including for example whether it's 32-bit or
>> 64-bit, so I don't really think it is a good idea.
> 
> As grub2 doesn't have to know, qemu shouldn't have to know either.

That would be exactly what linuxboot-dma.c does already, but it's slower
than PVH because Linux has to uncompress itself.

The above thought experiment would make QEMU able to boot a PVH kernel
without any changes to Linux.

Paolo


Re: linux-next: Signed-off-by missing for commits in the mfd-fixes tree

2017-11-29 Thread Johan Hovold
On Thu, Nov 30, 2017 at 01:43:05AM +1100, Stephen Rothwell wrote:
> Hi Lee,
> 
> Commits
> 
>   5f6bf7b9f96e ("mfd: twl4030-audio: Fix sibling-node lookup")
>   38c021ee7af3 ("mfd: twl6040: Fix child-node lookup")
> 
> are missing a Signed-off-by from their author.

Ouch, sorry about that.

Lee, can you still fix them up? Want me to resubmit?

Thanks,
Johan


Re: [PATCH v2] arch: arm: mach-stm32: Fix copyright

2017-11-29 Thread Alexandre Torgue



On 11/29/2017 03:55 PM, Benjamin Gaignard wrote:

Uniformize STMicroelectronics copyrights header
Add SPDX identifier

Signed-off-by: Benjamin Gaignard 
---
  arch/arm/mach-stm32/board-dt.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-stm32/board-dt.c b/arch/arm/mach-stm32/board-dt.c
index e918686e4191..b01f40543e6e 100644
--- a/arch/arm/mach-stm32/board-dt.c
+++ b/arch/arm/mach-stm32/board-dt.c
@@ -1,5 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
  /*
   * Copyright (C) Maxime Coquelin 2015
+ * Copyright (C) STMicroelectronics SA 2017
   * Author:  Maxime Coquelin 
   * License terms:  GNU General Public License (GPL), version 2
   */


Acked-by: Alexandre TORGUE 


Re: [PATCH] pinctrl: stm32: Fix copyright

2017-11-29 Thread Alexandre Torgue



On 11/29/2017 03:25 PM, Benjamin Gaignard wrote:

Uniformize STMicroelectronics copyrights header

Signed-off-by: Benjamin Gaignard 
---
  drivers/pinctrl/stm32/pinctrl-stm32.c | 1 +
  drivers/pinctrl/stm32/pinctrl-stm32.h | 1 +
  drivers/pinctrl/stm32/pinctrl-stm32f429.c | 1 +
  drivers/pinctrl/stm32/pinctrl-stm32f469.c | 4 ++--
  drivers/pinctrl/stm32/pinctrl-stm32f746.c | 1 +
  drivers/pinctrl/stm32/pinctrl-stm32h743.c | 4 ++--
  6 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c 
b/drivers/pinctrl/stm32/pinctrl-stm32.c
index a276c61be217..0676a254caeb 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -1,5 +1,6 @@
  /*
   * Copyright (C) Maxime Coquelin 2015
+ * Copyright (C) STMicroelectronics SA 2017
   * Author:  Maxime Coquelin 
   * License terms:  GNU General Public License (GPL), version 2
   *
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.h 
b/drivers/pinctrl/stm32/pinctrl-stm32.h
index 8702a9992ce5..76027765144b 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.h
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.h
@@ -1,5 +1,6 @@
  /*
   * Copyright (C) Maxime Coquelin 2015
+ * Copyright (C) STMicroelectronics SA 2017
   * Author:  Maxime Coquelin 
   * License terms:  GNU General Public License (GPL), version 2
   */
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32f429.c 
b/drivers/pinctrl/stm32/pinctrl-stm32f429.c
index 4bbade25acc6..4987fe553a1a 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32f429.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32f429.c
@@ -1,5 +1,6 @@
  /*
   * Copyright (C) Maxime Coquelin 2015
+ * Copyright (C) STMicroelectronics SA 2017
   * Author:  Maxime Coquelin 
   * License terms:  GNU General Public License (GPL), version 2
   */
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32f469.c 
b/drivers/pinctrl/stm32/pinctrl-stm32f469.c
index 86c8cebfa9b9..292ec13d7364 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32f469.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32f469.c
@@ -1,6 +1,6 @@
  /*
- * Copyright (C) Alexandre Torgue 2016
- * Author:  Alexandre Torgue 
+ * Copyright (C) STMicroelectronics SA 2017
+ * Author:  Alexandre Torgue  for STMicroelectronics.
   * License terms:  GNU General Public License (GPL), version 2
   */
  #include 
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32f746.c 
b/drivers/pinctrl/stm32/pinctrl-stm32f746.c
index a2fae7357c36..c22972e4b96c 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32f746.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32f746.c
@@ -1,5 +1,6 @@
  /*
   * Copyright (C) Maxime Coquelin 2015
+ * Copyright (C) STMicroelectronics SA 2017
   * Author:  Maxime Coquelin 
   * License terms:  GNU General Public License (GPL), version 2
   */
diff --git a/drivers/pinctrl/stm32/pinctrl-stm32h743.c 
b/drivers/pinctrl/stm32/pinctrl-stm32h743.c
index e34b2b9217ce..34ed8220ffdf 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32h743.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32h743.c
@@ -1,6 +1,6 @@
  /*
- * Copyright (C) Alexandre Torgue 2017
- * Author:  Alexandre Torgue 
+ * Copyright (C) STMicroelectronics SA 2017
+ * Author:  Alexandre Torgue  for STMicroelectronics.
   * License terms:  GNU General Public License (GPL), version 2
   */
  #include 


Acked-by: Alexandre TORGUE 


Re: [PATCH] irqchip: stm32: Fix copyright

2017-11-29 Thread Alexandre Torgue



On 11/29/2017 03:22 PM, Benjamin Gaignard wrote:

Uniformize STMicroelectronics copyrights header

Signed-off-by: Benjamin Gaignard 
---
  drivers/irqchip/irq-stm32-exti.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/irqchip/irq-stm32-exti.c b/drivers/irqchip/irq-stm32-exti.c
index 31ab0dee2ce7..c54217878af7 100644
--- a/drivers/irqchip/irq-stm32-exti.c
+++ b/drivers/irqchip/irq-stm32-exti.c
@@ -1,5 +1,6 @@
  /*
   * Copyright (C) Maxime Coquelin 2015
+ * Copyright (C) STMicroelectronics SA 2017
   * Author:  Maxime Coquelin 
   * License terms:  GNU General Public License (GPL), version 2
   */


Acked-by: Alexandre TORGUE 


Re: [PATCH] rtc: stm32: Fix copyright

2017-11-29 Thread Alexandre Torgue



On 11/29/2017 03:26 PM, Benjamin Gaignard wrote:

Uniformize STMicroelectronics copyrights header

Signed-off-by: Benjamin Gaignard 
CC: Amelie Delaunay 
---
  drivers/rtc/rtc-stm32.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-stm32.c b/drivers/rtc/rtc-stm32.c
index 3a5c3d7d0c77..f25dabe8fd02 100644
--- a/drivers/rtc/rtc-stm32.c
+++ b/drivers/rtc/rtc-stm32.c
@@ -1,6 +1,6 @@
  /*
- * Copyright (C) Amelie Delaunay 2016
- * Author:  Amelie Delaunay 
+ * Copyright (C) STMicroelectronics SA 2017
+ * Author:  Amelie Delaunay  for STMicroelectronics.
   * License terms:  GNU General Public License (GPL), version 2
   */
  


Acked-by: Alexandre TORGUE 


[PATCH] [RESEND] drivers:mtd:spi-nor:checkup FSR error bits

2017-11-29 Thread Bean Huo (beanhuo)
For the Micron SPI NOR, when the erase/program operation fails, especially,
for the failure results from intending to modify protected space, spi-nor
upper layers still get the return which shows the operation succeeds.
This because spi_nor_fsr_ready() only uses bit.7 to device whether ready.
For the most cases, even the error of erase/program occurs, SPI NOR device
is still ready. The device ready and the error are two different cases.
This patch is to fixup this issue and adding FSR (flag status register)
error bits checkup.
The FSR(flag status register) is a powerful tool to investigate the staus
of device, checking information regarding what is actually doing the memory
and detecting possible error conditions.

Signed-off-by: beanhuo 
---
 drivers/mtd/spi-nor/spi-nor.c | 18 --
 include/linux/mtd/spi-nor.h   |  6 +-
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index 19c00072..b87c04f 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -328,8 +328,22 @@ static inline int spi_nor_fsr_ready(struct spi_nor *nor)
int fsr = read_fsr(nor);
if (fsr < 0)
return fsr;
-   else
-   return fsr & FSR_READY;
+
+   if (fsr & (FSR_E_ERR | FSR_P_ERR)) {
+   if (fsr & FSR_E_ERR)
+   dev_err(nor->dev, "Erase operation failed.\n");
+   else
+   dev_err(nor->dev, "Program operation failed.\n");
+
+   if (fsr & FSR_PT_ERR)
+   dev_err(nor->dev,
+   "Attempted to modify the protected sectors.\n");
+
+   nor->write_reg(nor, SPINOR_OP_CLFSR, NULL, 0);
+   return -EIO;
+   }
+
+   return fsr & FSR_READY;
 }
 
 static int spi_nor_ready(struct spi_nor *nor)
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 1f0a7fc..b6187e3 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -61,6 +61,7 @@
 #define SPINOR_OP_RDSFDP   0x5a/* Read SFDP */
 #define SPINOR_OP_RDCR 0x35/* Read configuration register */
 #define SPINOR_OP_RDFSR0x70/* Read flag status register */
+#define SPINOR_OP_CLFSR0x50/* Clear flag status register */
 
 /* 4-byte address opcodes - used on Spansion and some Macronix flashes. */
 #define SPINOR_OP_READ_4B  0x13/* Read data bytes (low frequency) */
@@ -130,7 +131,10 @@
 #define EVCR_QUAD_EN_MICRONBIT(7)  /* Micron Quad I/O */
 
 /* Flag Status Register bits */
-#define FSR_READY  BIT(7)
+#define FSR_READY  BIT(7)  /* Device status, 0 = Busy,1 = Ready */
+#define FSR_E_ERR  BIT(5)  /* Erase operation status */
+#define FSR_P_ERR  BIT(4)  /* Program operation status */
+#define FSR_PT_ERR BIT(1)  /* Protection error bit */
 
 /* Configuration Register bits. */
 #define CR_QUAD_EN_SPANBIT(1)  /* Spansion Quad I/O */
-- 
2.7.4


Re: drm/amd/display: Restructuring and cleaning up DML

2017-11-29 Thread Harry Wentland
On 2017-11-28 10:34 PM, Cheng, Tony wrote:
> That code is to handle NAN (not a number) in float.  Unfortunately our HW 
> architect decided NAN is one of the way to determine if something isn't 
> supported.  We have feed this back to our HW team and they will look into 
> improving this for next next generation.
> 

We should probably macro this check to an isNaN(number) macro and remove the 
check for dcn_bw_max which uses unsigned int.

We should also explain that these files are coming pretty much straight from HW 
teams and should be treated as HW gospel.

I'll send patches.

Harry

> -Original Message-
> From: Dave Jones [mailto:da...@codemonkey.org.uk] 
> Sent: Tuesday, November 28, 2017 10:06 PM
> To: Linux Kernel Mailing List 
> Cc: Laktyushkin, Dmytro ; Cheng, Tony 
> ; Wentland, Harry ; Deucher, 
> Alexander 
> Subject: Re: drm/amd/display: Restructuring and cleaning up DML
> 
> On Sat, Nov 18, 2017 at 12:02:01AM +, Linux Kernel wrote:
>  > Web:
> https://git.kernel.org/torvalds/c/6d04ee9dc10149db842d41de66eca201c9d91b60
>  > Commit: 6d04ee9dc10149db842d41de66eca201c9d91b60
>  > Parent: 19b7fe4a48efbe0f7e8c496b040c4eb16ff02313
>  > Refname:refs/heads/master
>  > Author: Dmytro Laktyushkin 
>  > AuthorDate: Wed Aug 23 16:43:17 2017 -0400  > Committer:  Alex Deucher 
>   > CommitDate: Sat Oct 21 16:45:24 2017 -0400  > 
>  > drm/amd/display: Restructuring and cleaning up DML
>  > 
>  > Signed-off-by: Dmytro Laktyushkin 
>  > Reviewed-by: Tony Cheng 
>  > Acked-by: Harry Wentland 
>  > Signed-off-by: Alex Deucher 
>  > ---
> 
> 
>  > diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c 
> b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c
>  > index a18474437990..b6abe0f3bb15 100644  > --- 
> a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c
>  > +++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c
>  > @@ -27,20 +27,36 @@
>  >
>  >  float dcn_bw_mod(const float arg1, const float arg2)  >  {
>  > +  if (arg1 != arg1)
>  > +  return arg2;
>  > +  if (arg2 != arg2)
>  > +  return arg1;
>  >return arg1 - arg1 * ((int) (arg1 / arg2));
>  >  }
>  >
>  >  float dcn_bw_min2(const float arg1, const float arg2)  >  {
>  > +  if (arg1 != arg1)
>  > +  return arg2;
>  > +  if (arg2 != arg2)
>  > +  return arg1;
>  >return arg1 < arg2 ? arg1 : arg2;
>  >  }
>  >
>  >  unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2) 
>  >  {
>  > +  if (arg1 != arg1)
>  > +  return arg2;
>  > +  if (arg2 != arg2)
>  > +  return arg1;
>  >return arg1 > arg2 ? arg1 : arg2;
>  >  }
>  >  float dcn_bw_max2(const float arg1, const float arg2)  >  {
>  > +  if (arg1 != arg1)
>  > +  return arg2;
>  > +  if (arg2 != arg2)
>  > +  return arg1;
>  >return arg1 > arg2 ? arg1 : arg2;
>  >  }
> 
> This looks really, really bizarre. What was the intention here ?
> 
> (This, and a bunch of other stuff in this driver picked up by Coverity,  sign 
> up at scan.coverity.com if you want access, and I'll approve.)
> 
>   Dave
> 


[PATCH 5/5] MIPS: Disallow outsized PTRACE_SETREGSET NT_PRFPREG regset accesses

2017-11-29 Thread Maciej W. Rozycki
Complement commit c23b3d1a5311 ("MIPS: ptrace: Change GP regset to use 
correct core dump register layout") and also reject outsized 
PTRACE_SETREGSET requests to the NT_PRFPREG regset, like with the 
NT_PRSTATUS regset.

Cc: sta...@vger.kernel.org # v3.17+
Fixes: c23b3d1a5311 ("MIPS: ptrace: Change GP regset to use correct core dump 
register layout")
Signed-off-by: Maciej W. Rozycki 
---
 arch/mips/kernel/ptrace.c |3 +++
 1 file changed, 3 insertions(+)

linux-mips-nt-prfpreg-size.diff
Index: linux-sfr-test/arch/mips/kernel/ptrace.c
===
--- linux-sfr-test.orig/arch/mips/kernel/ptrace.c   2017-11-28 
23:52:40.373594000 +
+++ linux-sfr-test/arch/mips/kernel/ptrace.c2017-11-28 23:52:47.058649000 
+
@@ -533,6 +533,9 @@ static int fpr_set(struct task_struct *t
u32 fcr31;
int err;
 
+   if (pos + count > sizeof(elf_fpregset_t))
+   return -EIO;
+
init_fp_ctx(target);
 
if (sizeof(target->thread.fpu.fpr[0]) == sizeof(elf_fpreg_t))


Re: [PATCH 13/17] drm/sun4i: Add DE2 CSC library

2017-11-29 Thread Maxime Ripard
On Tue, Nov 28, 2017 at 10:43:39PM +0100, Jernej Škrabec wrote:
> Hi!
> 
> Dne torek, 28. november 2017 ob 21:55:50 CET je Maxime Ripard napisal(a):
> > On Mon, Nov 27, 2017 at 09:57:46PM +0100, Jernej Skrabec wrote:
> > > DE2 have many CSC units - channel input CSC, channel output CSC and
> > > mixer output CSC and maybe more.
> > > 
> > > Fortunately, they have all same register layout, only base offsets
> > > differs.
> > > 
> > > Add support only for channel output CSC for now.
> > > 
> > > Signed-off-by: Jernej Skrabec 
> > > ---
> > > 
> > >  drivers/gpu/drm/sun4i/Makefile|  2 +-
> > >  drivers/gpu/drm/sun4i/sun8i_csc.c | 90
> > >  +++
> > >  drivers/gpu/drm/sun4i/sun8i_csc.h | 36 
> > >  3 files changed, 127 insertions(+), 1 deletion(-)
> > >  create mode 100644 drivers/gpu/drm/sun4i/sun8i_csc.c
> > >  create mode 100644 drivers/gpu/drm/sun4i/sun8i_csc.h
> > > 
> > > diff --git a/drivers/gpu/drm/sun4i/Makefile
> > > b/drivers/gpu/drm/sun4i/Makefile index 70df480792f9..f82cc69ede72 100644
> > > --- a/drivers/gpu/drm/sun4i/Makefile
> > > +++ b/drivers/gpu/drm/sun4i/Makefile
> > > @@ -9,7 +9,7 @@ sun4i-drm-hdmi-y  += sun4i_hdmi_enc.o
> > > 
> > >  sun4i-drm-hdmi-y += sun4i_hdmi_i2c.o
> > >  sun4i-drm-hdmi-y += sun4i_hdmi_tmds_clk.o
> > > 
> > > -sun8i-mixer-y+= sun8i_mixer.o sun8i_layer.o 
> > > sun8i_scaler.o
> > > +sun8i-mixer-y+= sun8i_mixer.o sun8i_layer.o 
> > > sun8i_scaler.o 
> sun8i_csc.o
> > 
> > Please wrap that line.
> > 
> > >  sun4i-tcon-y += sun4i_crtc.o
> > >  sun4i-tcon-y += sun4i_dotclock.o
> > > 
> > > diff --git a/drivers/gpu/drm/sun4i/sun8i_csc.c
> > > b/drivers/gpu/drm/sun4i/sun8i_csc.c new file mode 100644
> > > index ..d48c28f8d568
> > > --- /dev/null
> > > +++ b/drivers/gpu/drm/sun4i/sun8i_csc.c
> > > @@ -0,0 +1,90 @@
> > > +/*
> > > + * Copyright (C) Jernej Skrabec 
> > > + *
> > > + * This program is free software; you can redistribute it and/or
> > > + * modify it under the terms of the GNU General Public License as
> > > + * published by the Free Software Foundation; either version 2 of
> > > + * the License, or (at your option) any later version.
> > > + */
> > > +
> > > +#include "sun8i_csc.h"
> > > +
> > > +static const u32 ccsc_base[2][2] = {
> > > + {CCSC00_OFFSET, CCSC01_OFFSET},
> > > + {CCSC10_OFFSET, CCSC11_OFFSET},
> > > +};
> > > +
> > > +/*
> > > + * Factors are in two's complement format, 10 bits for fractinal part.
> > > + * First tree values in each line are multiplication factor and last
> > > + * value is constant, which is added at the end.
> > > + */
> > > +static const u32 yuv2rgb[] = {
> > > + 0x04A8, 0x, 0x0662, 0xFFFC845A,
> > > + 0x04A8, 0xFE6F, 0xFCBF, 0x00021DF4,
> > > + 0x04A8, 0x0813, 0x, 0xFFFBAC4A,
> > > +};
> > > +
> > > +static const u32 yvu2rgb[] = {
> > > + 0x04A8, 0x0662, 0x, 0xFFFC845A,
> > > + 0x04A8, 0xFCBF, 0xFE6F, 0x00021DF4,
> > > + 0x04A8, 0x, 0x0813, 0xFFFBAC4A,
> > > +};
> > > +
> > > +static void sun8i_csc_set_coefficients(struct regmap *map, u32 base,
> > > +enum sun8i_csc_mode mode)
> > > +{
> > > + const u32 *table;
> > > + int i, data;
> > > +
> > > + switch (mode) {
> > > + case SUN8I_CSC_MODE_YUV2RGB:
> > > + table = yuv2rgb;
> > > + break;
> > > + case SUN8I_CSC_MODE_YVU2RGB:
> > > + table = yvu2rgb;
> > > + break;
> > > + default:
> > > + WARN(1, "Wrong CSC mode specified.");
> > 
> > A hard warn is a bit overkill here. What about a dev_warn?
> 
> dev_warn requires device, which is not available here and seems a bit 
> overkill 
> to have it as parameter just to print warning. What about DRM_WARN()?

Anything that doesn't make it look like the world just blew up is fine
by me :)

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


signature.asc
Description: PGP signature


Re: [PATCH v8 0/6] vfs: Use dlock list for SB's s_inodes list

2017-11-29 Thread Waiman Long
On 11/29/2017 10:26 AM, Davidlohr Bueso wrote:
> Are you planning on sending a v9 with the discussed changes? afaict:
>
> - Drop last two patches
> - Fix tearing (WRITE/READ_ONCE())
> - Reduce barrier usage for dlock_lists_empty() -- which I'll be sending
>  you shortly.
>
> Thanks,
> Davidlohr 

Yes, I am planning to do so when I have some free time as I am working
on a high-priority task at the moment.

Regards,
Longman


<    1   2   3   4   5   6   7   8   9   10   >