Hello

2017-06-25 Thread Maria
Financial Donation to you. For details contact email:
maria.c...@yandex.com   


Hello

2017-06-25 Thread Maria
Financial Donation to you. For details contact email:
maria.c...@yandex.com   


Re: [linux-sunxi] [PATCH v4 1/6] clk: sunxi-ng: div: Add support for fixed post-divider

2017-06-25 Thread Priit Laes
On Mon, Jun 26, 2017 at 08:05:16AM +1000, Jonathan Liu wrote:
> Hi Priit,
> 
> This is showing from clock rate of 171428572 in the output of "cat
> /sys/kernel/debug/clk/clk_summary" for pll-periph-sata.
> The clock rate should be 1 (100 MHz) when read from the hardware.

This is what I see on Cubietruck. Can you check with sunxi-ccu-wip branch?

$ cat /sys/kernel/debug/clk/clk_summary  |grep -i sata
  pll-periph-sata 11   1  0 
0  
 sata 11   1  0 
0  
ahb-sata  11   3  0 
0  

> 
> On 26 June 2017 at 06:45, Priit Laes  wrote:
> > SATA clock on sun4i/sun7i is of type (parent) / M / 6 where
> > 6 is fixed post-divider.
> >
> > Signed-off-by: Priit Laes 
> > ---
> >  drivers/clk/sunxi-ng/ccu_div.c | 12 ++--
> >  drivers/clk/sunxi-ng/ccu_div.h |  3 ++-
> >  2 files changed, 12 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/clk/sunxi-ng/ccu_div.c b/drivers/clk/sunxi-ng/ccu_div.c
> > index c0e5c10..de30e15 100644
> > --- a/drivers/clk/sunxi-ng/ccu_div.c
> > +++ b/drivers/clk/sunxi-ng/ccu_div.c
> 
> Missing handling of fixed_post_div in ccu_div_round_rate.
> ccu_div_round_rate should multiply the rate by the postdiv before
> looking up the divider using divider_get_val and divide val by postdiv
> just before returning.
> 
> > @@ -62,8 +62,13 @@ static unsigned long ccu_div_recalc_rate(struct clk_hw 
> > *hw,
> > parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
> >   parent_rate);
> >
> > -   return divider_recalc_rate(hw, parent_rate, val, cd->div.table,
> > -  cd->div.flags);
> > +   val = divider_recalc_rate(hw, parent_rate, val, cd->div.table,
> > + cd->div.flags);
> > +
> > +   if (cd->common.features & CCU_FEATURE_FIXED_POSTDIV)
> > +   val /= cd->fixed_post_div;
> > +
> > +   return val;
> >  }
> >
> >  static int ccu_div_determine_rate(struct clk_hw *hw,
> 
> > @@ -89,6 +94,9 @@ static int ccu_div_set_rate(struct clk_hw *hw, unsigned 
> > long rate,
> > val = divider_get_val(rate, parent_rate, cd->div.table, 
> > cd->div.width,
> >   cd->div.flags);
> >
> > +   if (cd->common.features & CCU_FEATURE_FIXED_POSTDIV)
> > +   val *= cd->fixed_post_div;
> > +
> > spin_lock_irqsave(cd->common.lock, flags);
> >
> > reg = readl(cd->common.base + cd->common.reg);
> 
> val here is the divider value that is stored in the clock register
> field not the actual rate so this is incorrect. Instead the rate needs
> to be multiplied by postdiv just before divider_get_val.

OK, thanks, this one I wasn't really sure about.

> 
> > diff --git a/drivers/clk/sunxi-ng/ccu_div.h b/drivers/clk/sunxi-ng/ccu_div.h
> > index 08d0744..f3a5028 100644
> > --- a/drivers/clk/sunxi-ng/ccu_div.h
> > +++ b/drivers/clk/sunxi-ng/ccu_div.h
> > @@ -86,9 +86,10 @@ struct ccu_div_internal {
> >  struct ccu_div {
> > u32 enable;
> >
> > -   struct ccu_div_internal div;
> > +   struct ccu_div_internal div;
> > struct ccu_mux_internal mux;
> > struct ccu_common   common;
> > +   unsigned intfixed_post_div;
> >  };
> >
> >  #define SUNXI_CCU_DIV_TABLE_WITH_GATE(_struct, _name, _parent, _reg,   \
> > --
> > git-series 0.9.1
> 
> Thanks.
> 
> Regards,
> Jonathan


Re: [linux-sunxi] [PATCH v4 1/6] clk: sunxi-ng: div: Add support for fixed post-divider

2017-06-25 Thread Priit Laes
On Mon, Jun 26, 2017 at 08:05:16AM +1000, Jonathan Liu wrote:
> Hi Priit,
> 
> This is showing from clock rate of 171428572 in the output of "cat
> /sys/kernel/debug/clk/clk_summary" for pll-periph-sata.
> The clock rate should be 1 (100 MHz) when read from the hardware.

This is what I see on Cubietruck. Can you check with sunxi-ccu-wip branch?

$ cat /sys/kernel/debug/clk/clk_summary  |grep -i sata
  pll-periph-sata 11   1  0 
0  
 sata 11   1  0 
0  
ahb-sata  11   3  0 
0  

> 
> On 26 June 2017 at 06:45, Priit Laes  wrote:
> > SATA clock on sun4i/sun7i is of type (parent) / M / 6 where
> > 6 is fixed post-divider.
> >
> > Signed-off-by: Priit Laes 
> > ---
> >  drivers/clk/sunxi-ng/ccu_div.c | 12 ++--
> >  drivers/clk/sunxi-ng/ccu_div.h |  3 ++-
> >  2 files changed, 12 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/clk/sunxi-ng/ccu_div.c b/drivers/clk/sunxi-ng/ccu_div.c
> > index c0e5c10..de30e15 100644
> > --- a/drivers/clk/sunxi-ng/ccu_div.c
> > +++ b/drivers/clk/sunxi-ng/ccu_div.c
> 
> Missing handling of fixed_post_div in ccu_div_round_rate.
> ccu_div_round_rate should multiply the rate by the postdiv before
> looking up the divider using divider_get_val and divide val by postdiv
> just before returning.
> 
> > @@ -62,8 +62,13 @@ static unsigned long ccu_div_recalc_rate(struct clk_hw 
> > *hw,
> > parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
> >   parent_rate);
> >
> > -   return divider_recalc_rate(hw, parent_rate, val, cd->div.table,
> > -  cd->div.flags);
> > +   val = divider_recalc_rate(hw, parent_rate, val, cd->div.table,
> > + cd->div.flags);
> > +
> > +   if (cd->common.features & CCU_FEATURE_FIXED_POSTDIV)
> > +   val /= cd->fixed_post_div;
> > +
> > +   return val;
> >  }
> >
> >  static int ccu_div_determine_rate(struct clk_hw *hw,
> 
> > @@ -89,6 +94,9 @@ static int ccu_div_set_rate(struct clk_hw *hw, unsigned 
> > long rate,
> > val = divider_get_val(rate, parent_rate, cd->div.table, 
> > cd->div.width,
> >   cd->div.flags);
> >
> > +   if (cd->common.features & CCU_FEATURE_FIXED_POSTDIV)
> > +   val *= cd->fixed_post_div;
> > +
> > spin_lock_irqsave(cd->common.lock, flags);
> >
> > reg = readl(cd->common.base + cd->common.reg);
> 
> val here is the divider value that is stored in the clock register
> field not the actual rate so this is incorrect. Instead the rate needs
> to be multiplied by postdiv just before divider_get_val.

OK, thanks, this one I wasn't really sure about.

> 
> > diff --git a/drivers/clk/sunxi-ng/ccu_div.h b/drivers/clk/sunxi-ng/ccu_div.h
> > index 08d0744..f3a5028 100644
> > --- a/drivers/clk/sunxi-ng/ccu_div.h
> > +++ b/drivers/clk/sunxi-ng/ccu_div.h
> > @@ -86,9 +86,10 @@ struct ccu_div_internal {
> >  struct ccu_div {
> > u32 enable;
> >
> > -   struct ccu_div_internal div;
> > +   struct ccu_div_internal div;
> > struct ccu_mux_internal mux;
> > struct ccu_common   common;
> > +   unsigned intfixed_post_div;
> >  };
> >
> >  #define SUNXI_CCU_DIV_TABLE_WITH_GATE(_struct, _name, _parent, _reg,   \
> > --
> > git-series 0.9.1
> 
> Thanks.
> 
> Regards,
> Jonathan


[PATCH] staging: sm750fb: always take the lock

2017-06-25 Thread AbdAllah-MEZITI
This patch
- will always take the lock
- fix the sparse warning:
drivers/staging/sm750fb/sm750.c:159:13: warning: context imbalance in 
'lynxfb_ops_fillrect' - different lock contexts for basic block
drivers/staging/sm750fb/sm750.c:231:9: warning: context imbalance in 
'lynxfb_ops_copyarea' - different lock contexts for basic block
drivers/staging/sm750fb/sm750.c:235:13: warning: context imbalance in 
'lynxfb_ops_imageblit' - different lock contexts for basic block

Signed-off-by: AbdAllah MEZITI 
---
 drivers/staging/sm750fb/sm750.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 386d4ad..4a22190 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -186,16 +186,14 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
 * If not use spin_lock,system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
-   spin_lock(_dev->slock);
+   spin_lock(_dev->slock);
 
sm750_dev->accel.de_fillrect(_dev->accel,
 base, pitch, Bpp,
 region->dx, region->dy,
 region->width, region->height,
 color, rop);
-   if (sm750_dev->fb_count > 1)
-   spin_unlock(_dev->slock);
+   spin_unlock(_dev->slock);
 }
 
 static void lynxfb_ops_copyarea(struct fb_info *info,
@@ -220,16 +218,14 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
 * If not use spin_lock, system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
-   spin_lock(_dev->slock);
+   spin_lock(_dev->slock);
 
sm750_dev->accel.de_copyarea(_dev->accel,
 base, pitch, region->sx, region->sy,
 base, pitch, Bpp, region->dx, region->dy,
 region->width, region->height,
 HW_ROP2_COPY);
-   if (sm750_dev->fb_count > 1)
-   spin_unlock(_dev->slock);
+   spin_unlock(_dev->slock);
 }
 
 static void lynxfb_ops_imageblit(struct fb_info *info,
@@ -269,8 +265,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
 * If not use spin_lock, system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
-   spin_lock(_dev->slock);
+   spin_lock(_dev->slock);
 
sm750_dev->accel.de_imageblit(_dev->accel,
  image->data, image->width >> 3, 0,
@@ -278,8 +273,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
  image->dx, image->dy,
  image->width, image->height,
  fgcol, bgcol, HW_ROP2_COPY);
-   if (sm750_dev->fb_count > 1)
-   spin_unlock(_dev->slock);
+   spin_unlock(_dev->slock);
 }
 
 static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
-- 
2.7.4



[PATCH] staging: sm750fb: always take the lock

2017-06-25 Thread AbdAllah-MEZITI
This patch
- will always take the lock
- fix the sparse warning:
drivers/staging/sm750fb/sm750.c:159:13: warning: context imbalance in 
'lynxfb_ops_fillrect' - different lock contexts for basic block
drivers/staging/sm750fb/sm750.c:231:9: warning: context imbalance in 
'lynxfb_ops_copyarea' - different lock contexts for basic block
drivers/staging/sm750fb/sm750.c:235:13: warning: context imbalance in 
'lynxfb_ops_imageblit' - different lock contexts for basic block

Signed-off-by: AbdAllah MEZITI 
---
 drivers/staging/sm750fb/sm750.c | 18 ++
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 386d4ad..4a22190 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -186,16 +186,14 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
 * If not use spin_lock,system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
-   spin_lock(_dev->slock);
+   spin_lock(_dev->slock);
 
sm750_dev->accel.de_fillrect(_dev->accel,
 base, pitch, Bpp,
 region->dx, region->dy,
 region->width, region->height,
 color, rop);
-   if (sm750_dev->fb_count > 1)
-   spin_unlock(_dev->slock);
+   spin_unlock(_dev->slock);
 }
 
 static void lynxfb_ops_copyarea(struct fb_info *info,
@@ -220,16 +218,14 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
 * If not use spin_lock, system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
-   spin_lock(_dev->slock);
+   spin_lock(_dev->slock);
 
sm750_dev->accel.de_copyarea(_dev->accel,
 base, pitch, region->sx, region->sy,
 base, pitch, Bpp, region->dx, region->dy,
 region->width, region->height,
 HW_ROP2_COPY);
-   if (sm750_dev->fb_count > 1)
-   spin_unlock(_dev->slock);
+   spin_unlock(_dev->slock);
 }
 
 static void lynxfb_ops_imageblit(struct fb_info *info,
@@ -269,8 +265,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
 * If not use spin_lock, system will die if user load driver
 * and immediately unload driver frequently (dual)
 */
-   if (sm750_dev->fb_count > 1)
-   spin_lock(_dev->slock);
+   spin_lock(_dev->slock);
 
sm750_dev->accel.de_imageblit(_dev->accel,
  image->data, image->width >> 3, 0,
@@ -278,8 +273,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
  image->dx, image->dy,
  image->width, image->height,
  fgcol, bgcol, HW_ROP2_COPY);
-   if (sm750_dev->fb_count > 1)
-   spin_unlock(_dev->slock);
+   spin_unlock(_dev->slock);
 }
 
 static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
-- 
2.7.4



Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-25 Thread David Gstir
Herbert,

> On 20 Jun 2017, at 03:28, Herbert Xu  wrote:
> 
> On Mon, Jun 19, 2017 at 10:31:27AM +, Horia Geantă wrote:
>> 
>> IIUC, IV update is required only in case of CBC.
>> Since this callback is used also for CTR, we should avoid the copy:
>> if ((ctx->cdata.algtype & OP_ALG_AAI_MASK) == OP_ALG_AAI_CBC) ...
> 
> No it is needed for CTR too.

So, am I correct in assuming that it is required for all modes including AEAD 
modes like GCM?
In that case I'll include a fix for the CAAM GCM mode too.

Thanks,
David


Re: [RFC PATCH 1/2] crypto: caam - properly set IV after {en,de}crypt

2017-06-25 Thread David Gstir
Herbert,

> On 20 Jun 2017, at 03:28, Herbert Xu  wrote:
> 
> On Mon, Jun 19, 2017 at 10:31:27AM +, Horia Geantă wrote:
>> 
>> IIUC, IV update is required only in case of CBC.
>> Since this callback is used also for CTR, we should avoid the copy:
>> if ((ctx->cdata.algtype & OP_ALG_AAI_MASK) == OP_ALG_AAI_CBC) ...
> 
> No it is needed for CTR too.

So, am I correct in assuming that it is required for all modes including AEAD 
modes like GCM?
In that case I'll include a fix for the CAAM GCM mode too.

Thanks,
David


[PATCH v4 2/3] tracing: Add support for display of tgid in trace output

2017-06-25 Thread Joel Fernandes
Earlier patches introduced ability to record the tgid using the 'record-tgid'
option. Here we read the tgid and output it if the option is enabled.

Cc: kernel-t...@android.com
Cc: Steven Rostedt 
Cc: Ingo Molnar 
Tested-by: Michael Sartain 
Signed-off-by: Joel Fernandes 
---
 kernel/trace/trace.c| 36 ++--
 kernel/trace/trace_output.c |  9 +
 2 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 6dec7bef63c7..65878211f26f 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3331,23 +3331,29 @@ static void print_event_info(struct trace_buffer *buf, 
struct seq_file *m)
seq_puts(m, "#\n");
 }
 
-static void print_func_help_header(struct trace_buffer *buf, struct seq_file 
*m)
+static void print_func_help_header(struct trace_buffer *buf, struct seq_file 
*m,
+  unsigned int flags)
 {
+   bool tgid = flags & TRACE_ITER_RECORD_TGID;
+
print_event_info(buf, m);
-   seq_puts(m, "#   TASK-PID   CPU#  TIMESTAMP  FUNCTION\n"
-   "#  | |   |  | |\n");
+
+   seq_printf(m, "#   TASK-PID   CPU#   %s  TIMESTAMP  
FUNCTION\n", tgid ? "TGID " : "");
+   seq_printf(m, "#  | |   |%s | |\n", 
 tgid ? "  |  " : "");
 }
 
-static void print_func_help_header_irq(struct trace_buffer *buf, struct 
seq_file *m)
+static void print_func_help_header_irq(struct trace_buffer *buf, struct 
seq_file *m,
+  unsigned int flags)
 {
-   print_event_info(buf, m);
-   seq_puts(m, "#  _-=> irqs-off\n"
-   "# / _=> need-resched\n"
-   "#| / _---=> hardirq/softirq\n"
-   "#|| / _--=> preempt-depth\n"
-   "#||| / delay\n"
-   "#   TASK-PID   CPU#  TIMESTAMP  FUNCTION\n"
-   "#  | |   |      | |\n");
+   bool tgid = flags & TRACE_ITER_RECORD_TGID;
+
+   seq_printf(m, "#  %s  _-=> irqs-off\n", 
tgid ? "  " : "");
+   seq_printf(m, "#  %s / _=> need-resched\n", 
tgid ? "  " : "");
+   seq_printf(m, "#  %s| / _---=> 
hardirq/softirq\n",  tgid ? "  " : "");
+   seq_printf(m, "#  %s|| / _--=> 
preempt-depth\n",tgid ? "  " : "");
+   seq_printf(m, "#  %s||| / delay\n", 
tgid ? "  " : "");
+   seq_printf(m, "#   TASK-PID   CPU#%sTIMESTAMP  
FUNCTION\n", tgid ? "   TGID   " : "");
+   seq_printf(m, "#  | |   | %s   | |\n",  
tgid ? " |" : "");
 }
 
 void
@@ -3663,9 +3669,11 @@ void trace_default_header(struct seq_file *m)
} else {
if (!(trace_flags & TRACE_ITER_VERBOSE)) {
if (trace_flags & TRACE_ITER_IRQ_INFO)
-   print_func_help_header_irq(iter->trace_buffer, 
m);
+   print_func_help_header_irq(iter->trace_buffer,
+  m, trace_flags);
else
-   print_func_help_header(iter->trace_buffer, m);
+   print_func_help_header(iter->trace_buffer, m,
+  trace_flags);
}
}
 }
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 08f9bab8089e..55c743295874 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -587,6 +587,15 @@ int trace_print_context(struct trace_iterator *iter)
trace_seq_printf(s, "%16s-%-5d [%03d] ",
   comm, entry->pid, iter->cpu);
 
+   if (tr->trace_flags & TRACE_ITER_RECORD_TGID) {
+   unsigned int tgid = trace_find_tgid(entry->pid);
+
+   if (!tgid)
+   trace_seq_printf(s, "(-) ");
+   else
+   trace_seq_printf(s, "(%5d) ", tgid);
+   }
+
if (tr->trace_flags & TRACE_ITER_IRQ_INFO)
trace_print_lat_fmt(s, entry);
 
-- 
2.13.1.611.g7e3b11ae1-goog



[PATCH v4 1/3] tracing: Add support for recording tgid of tasks

2017-06-25 Thread Joel Fernandes
Inorder to support recording of tgid, the following changes are made:

* Introduce a new API (tracing_record_taskinfo) to additionally record the tgid
  along with the task's comm at the same time. This has has the benefit of not
  setting trace_cmdline_save before all the information for a task is saved.
* Add a new API tracing_record_taskinfo_sched_switch to record task information
  for 2 tasks at a time (previous and next) and use it from sched_switch probe.
* Preserve the old API (tracing_record_cmdline) and create it as a wrapper
  around the new one so that existing callers aren't affected.
* Reuse the existing sched_switch and sched_wakeup probes to record tgid
  information and add a new option 'record-tgid' to enable recording of tgid

When record-tgid option isn't enabled to being with, we take care to make sure
that there's isn't memory or runtime overhead.

Cc: kernel-t...@android.com
Cc: Steven Rostedt 
Cc: Ingo Molnar 
Tested-by: Michael Sartain 
Signed-off-by: Joel Fernandes 
---
 include/linux/trace_events.h  |  13 -
 kernel/trace/trace.c  | 106 ++
 kernel/trace/trace.h  |   9 
 kernel/trace/trace_events.c   |  42 ++-
 kernel/trace/trace_sched_switch.c |  75 ++-
 5 files changed, 219 insertions(+), 26 deletions(-)

diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index a556805eff8a..f73cedfa2e0b 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -151,7 +151,15 @@ trace_event_buffer_lock_reserve(struct ring_buffer 
**current_buffer,
int type, unsigned long len,
unsigned long flags, int pc);
 
-void tracing_record_cmdline(struct task_struct *tsk);
+#define TRACE_RECORD_CMDLINE   BIT(0)
+#define TRACE_RECORD_TGID  BIT(1)
+
+void tracing_record_taskinfo(struct task_struct *task, int flags);
+void tracing_record_taskinfo_sched_switch(struct task_struct *prev,
+ struct task_struct *next, int flags);
+
+void tracing_record_cmdline(struct task_struct *task);
+void tracing_record_tgid(struct task_struct *task);
 
 int trace_output_call(struct trace_iterator *iter, char *name, char *fmt, ...);
 
@@ -290,6 +298,7 @@ struct trace_subsystem_dir;
 enum {
EVENT_FILE_FL_ENABLED_BIT,
EVENT_FILE_FL_RECORDED_CMD_BIT,
+   EVENT_FILE_FL_RECORDED_TGID_BIT,
EVENT_FILE_FL_FILTERED_BIT,
EVENT_FILE_FL_NO_SET_FILTER_BIT,
EVENT_FILE_FL_SOFT_MODE_BIT,
@@ -303,6 +312,7 @@ enum {
  * Event file flags:
  *  ENABLED  - The event is enabled
  *  RECORDED_CMD  - The comms should be recorded at sched_switch
+ *  RECORDED_TGID - The tgids should be recorded at sched_switch
  *  FILTERED - The event has a filter attached
  *  NO_SET_FILTER - Set when filter has error and is to be ignored
  *  SOFT_MODE - The event is enabled/disabled by SOFT_DISABLED
@@ -315,6 +325,7 @@ enum {
 enum {
EVENT_FILE_FL_ENABLED   = (1 << EVENT_FILE_FL_ENABLED_BIT),
EVENT_FILE_FL_RECORDED_CMD  = (1 << EVENT_FILE_FL_RECORDED_CMD_BIT),
+   EVENT_FILE_FL_RECORDED_TGID = (1 << 
EVENT_FILE_FL_RECORDED_TGID_BIT),
EVENT_FILE_FL_FILTERED  = (1 << EVENT_FILE_FL_FILTERED_BIT),
EVENT_FILE_FL_NO_SET_FILTER = (1 << 
EVENT_FILE_FL_NO_SET_FILTER_BIT),
EVENT_FILE_FL_SOFT_MODE = (1 << EVENT_FILE_FL_SOFT_MODE_BIT),
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 1122f151466f..6dec7bef63c7 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -87,7 +87,7 @@ dummy_set_flag(struct trace_array *tr, u32 old_flags, u32 
bit, int set)
  * tracing is active, only save the comm when a trace event
  * occurred.
  */
-static DEFINE_PER_CPU(bool, trace_cmdline_save);
+static DEFINE_PER_CPU(bool, trace_taskinfo_save);
 
 /*
  * Kill all tracing for good (never come back).
@@ -790,7 +790,7 @@ EXPORT_SYMBOL_GPL(tracing_on);
 static __always_inline void
 __buffer_unlock_commit(struct ring_buffer *buffer, struct ring_buffer_event 
*event)
 {
-   __this_cpu_write(trace_cmdline_save, true);
+   __this_cpu_write(trace_taskinfo_save, true);
 
/* If this is the temp buffer, we need to commit fully */
if (this_cpu_read(trace_buffered_event) == event) {
@@ -1709,6 +1709,18 @@ void tracing_reset_all_online_cpus(void)
}
 }
 
+int *tgid_map;
+
+void tracing_alloc_tgid_map(void)
+{
+   if (tgid_map)
+   return;
+
+   tgid_map = kzalloc((PID_MAX_DEFAULT + 1) * sizeof(*tgid_map),
+  GFP_KERNEL);
+   WARN_ONCE(!tgid_map, "Allocation of tgid_map failed\n");
+}
+
 #define SAVED_CMDLINES_DEFAULT 128
 #define NO_CMDLINE_MAP UINT_MAX
 static arch_spinlock_t trace_cmdline_lock = __ARCH_SPIN_LOCK_UNLOCKED;
@@ -1722,7 

[PATCH v4 3/3] tracing/ftrace: Add support to record and display tgid

2017-06-25 Thread Joel Fernandes
Make function tracer able to record tgid if/when record-tgid is enabled.

Cc: kernel-t...@android.com
Cc: Steven Rostedt 
Cc: Ingo Molnar 
Tested-by: Michael Sartain 
Signed-off-by: Joel Fernandes 
---
 kernel/trace/trace_functions.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index a3bddbfd0874..d6bdc38ab273 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -27,6 +27,7 @@ static void
 function_stack_trace_call(unsigned long ip, unsigned long parent_ip,
  struct ftrace_ops *op, struct pt_regs *pt_regs);
 static struct tracer_flags func_flags;
+static bool tgid_recorded;
 
 /* Our option */
 enum {
@@ -104,6 +105,11 @@ static int function_trace_init(struct trace_array *tr)
put_cpu();
 
tracing_start_cmdline_record();
+
+   if (tr->trace_flags & TRACE_ITER_RECORD_TGID) {
+   tgid_recorded = true;
+   tracing_start_tgid_record();
+   }
tracing_start_function_trace(tr);
return 0;
 }
@@ -112,6 +118,10 @@ static void function_trace_reset(struct trace_array *tr)
 {
tracing_stop_function_trace(tr);
tracing_stop_cmdline_record();
+   if (tgid_recorded) {
+   tracing_stop_tgid_record();
+   tgid_recorded = false;
+   }
ftrace_reset_array_ops(tr);
 }
 
@@ -252,6 +262,21 @@ func_set_flag(struct trace_array *tr, u32 old_flags, u32 
bit, int set)
return 0;
 }
 
+static int
+func_tracer_flag_changed(struct trace_array *tr, unsigned int mask,
+int enabled)
+{
+   if (mask == TRACE_ITER_RECORD_TGID) {
+   tgid_recorded = !!enabled;
+   if (enabled)
+   tracing_start_tgid_record();
+   else
+   tracing_stop_tgid_record();
+   }
+
+   return 0;
+}
+
 static struct tracer function_trace __tracer_data =
 {
.name   = "function",
@@ -260,6 +285,7 @@ static struct tracer function_trace __tracer_data =
.start  = function_trace_start,
.flags  = _flags,
.set_flag   = func_set_flag,
+   .flag_changed   = func_tracer_flag_changed,
.allow_instances = true,
 #ifdef CONFIG_FTRACE_SELFTEST
.selftest   = trace_selftest_startup_function,
-- 
2.13.1.611.g7e3b11ae1-goog



Re: [PATCH] pci: Add and use PCI_GENERIC_SETUP Kconfig entry

2017-06-25 Thread kbuild test robot
Hi Palmer,

[auto build test WARNING on linus/master]
[also build test WARNING on v4.12-rc6]
[cannot apply to next-20170623]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/pci-Add-and-use-PCI_GENERIC_SETUP-Kconfig-entry/20170626-043558
config: m68k-allnoconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=m68k 

All warnings (new ones prefixed by >>):

warning: (M68K) selects PCI_GENERIC_SETUP which has unmet direct dependencies 
(MMU)

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


.config.gz
Description: application/gzip


[PATCH v4 2/3] tracing: Add support for display of tgid in trace output

2017-06-25 Thread Joel Fernandes
Earlier patches introduced ability to record the tgid using the 'record-tgid'
option. Here we read the tgid and output it if the option is enabled.

Cc: kernel-t...@android.com
Cc: Steven Rostedt 
Cc: Ingo Molnar 
Tested-by: Michael Sartain 
Signed-off-by: Joel Fernandes 
---
 kernel/trace/trace.c| 36 ++--
 kernel/trace/trace_output.c |  9 +
 2 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 6dec7bef63c7..65878211f26f 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3331,23 +3331,29 @@ static void print_event_info(struct trace_buffer *buf, 
struct seq_file *m)
seq_puts(m, "#\n");
 }
 
-static void print_func_help_header(struct trace_buffer *buf, struct seq_file 
*m)
+static void print_func_help_header(struct trace_buffer *buf, struct seq_file 
*m,
+  unsigned int flags)
 {
+   bool tgid = flags & TRACE_ITER_RECORD_TGID;
+
print_event_info(buf, m);
-   seq_puts(m, "#   TASK-PID   CPU#  TIMESTAMP  FUNCTION\n"
-   "#  | |   |  | |\n");
+
+   seq_printf(m, "#   TASK-PID   CPU#   %s  TIMESTAMP  
FUNCTION\n", tgid ? "TGID " : "");
+   seq_printf(m, "#  | |   |%s | |\n", 
 tgid ? "  |  " : "");
 }
 
-static void print_func_help_header_irq(struct trace_buffer *buf, struct 
seq_file *m)
+static void print_func_help_header_irq(struct trace_buffer *buf, struct 
seq_file *m,
+  unsigned int flags)
 {
-   print_event_info(buf, m);
-   seq_puts(m, "#  _-=> irqs-off\n"
-   "# / _=> need-resched\n"
-   "#| / _---=> hardirq/softirq\n"
-   "#|| / _--=> preempt-depth\n"
-   "#||| / delay\n"
-   "#   TASK-PID   CPU#  TIMESTAMP  FUNCTION\n"
-   "#  | |   |      | |\n");
+   bool tgid = flags & TRACE_ITER_RECORD_TGID;
+
+   seq_printf(m, "#  %s  _-=> irqs-off\n", 
tgid ? "  " : "");
+   seq_printf(m, "#  %s / _=> need-resched\n", 
tgid ? "  " : "");
+   seq_printf(m, "#  %s| / _---=> 
hardirq/softirq\n",  tgid ? "  " : "");
+   seq_printf(m, "#  %s|| / _--=> 
preempt-depth\n",tgid ? "  " : "");
+   seq_printf(m, "#  %s||| / delay\n", 
tgid ? "  " : "");
+   seq_printf(m, "#   TASK-PID   CPU#%sTIMESTAMP  
FUNCTION\n", tgid ? "   TGID   " : "");
+   seq_printf(m, "#  | |   | %s   | |\n",  
tgid ? " |" : "");
 }
 
 void
@@ -3663,9 +3669,11 @@ void trace_default_header(struct seq_file *m)
} else {
if (!(trace_flags & TRACE_ITER_VERBOSE)) {
if (trace_flags & TRACE_ITER_IRQ_INFO)
-   print_func_help_header_irq(iter->trace_buffer, 
m);
+   print_func_help_header_irq(iter->trace_buffer,
+  m, trace_flags);
else
-   print_func_help_header(iter->trace_buffer, m);
+   print_func_help_header(iter->trace_buffer, m,
+  trace_flags);
}
}
 }
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 08f9bab8089e..55c743295874 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -587,6 +587,15 @@ int trace_print_context(struct trace_iterator *iter)
trace_seq_printf(s, "%16s-%-5d [%03d] ",
   comm, entry->pid, iter->cpu);
 
+   if (tr->trace_flags & TRACE_ITER_RECORD_TGID) {
+   unsigned int tgid = trace_find_tgid(entry->pid);
+
+   if (!tgid)
+   trace_seq_printf(s, "(-) ");
+   else
+   trace_seq_printf(s, "(%5d) ", tgid);
+   }
+
if (tr->trace_flags & TRACE_ITER_IRQ_INFO)
trace_print_lat_fmt(s, entry);
 
-- 
2.13.1.611.g7e3b11ae1-goog



[PATCH v4 1/3] tracing: Add support for recording tgid of tasks

2017-06-25 Thread Joel Fernandes
Inorder to support recording of tgid, the following changes are made:

* Introduce a new API (tracing_record_taskinfo) to additionally record the tgid
  along with the task's comm at the same time. This has has the benefit of not
  setting trace_cmdline_save before all the information for a task is saved.
* Add a new API tracing_record_taskinfo_sched_switch to record task information
  for 2 tasks at a time (previous and next) and use it from sched_switch probe.
* Preserve the old API (tracing_record_cmdline) and create it as a wrapper
  around the new one so that existing callers aren't affected.
* Reuse the existing sched_switch and sched_wakeup probes to record tgid
  information and add a new option 'record-tgid' to enable recording of tgid

When record-tgid option isn't enabled to being with, we take care to make sure
that there's isn't memory or runtime overhead.

Cc: kernel-t...@android.com
Cc: Steven Rostedt 
Cc: Ingo Molnar 
Tested-by: Michael Sartain 
Signed-off-by: Joel Fernandes 
---
 include/linux/trace_events.h  |  13 -
 kernel/trace/trace.c  | 106 ++
 kernel/trace/trace.h  |   9 
 kernel/trace/trace_events.c   |  42 ++-
 kernel/trace/trace_sched_switch.c |  75 ++-
 5 files changed, 219 insertions(+), 26 deletions(-)

diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index a556805eff8a..f73cedfa2e0b 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -151,7 +151,15 @@ trace_event_buffer_lock_reserve(struct ring_buffer 
**current_buffer,
int type, unsigned long len,
unsigned long flags, int pc);
 
-void tracing_record_cmdline(struct task_struct *tsk);
+#define TRACE_RECORD_CMDLINE   BIT(0)
+#define TRACE_RECORD_TGID  BIT(1)
+
+void tracing_record_taskinfo(struct task_struct *task, int flags);
+void tracing_record_taskinfo_sched_switch(struct task_struct *prev,
+ struct task_struct *next, int flags);
+
+void tracing_record_cmdline(struct task_struct *task);
+void tracing_record_tgid(struct task_struct *task);
 
 int trace_output_call(struct trace_iterator *iter, char *name, char *fmt, ...);
 
@@ -290,6 +298,7 @@ struct trace_subsystem_dir;
 enum {
EVENT_FILE_FL_ENABLED_BIT,
EVENT_FILE_FL_RECORDED_CMD_BIT,
+   EVENT_FILE_FL_RECORDED_TGID_BIT,
EVENT_FILE_FL_FILTERED_BIT,
EVENT_FILE_FL_NO_SET_FILTER_BIT,
EVENT_FILE_FL_SOFT_MODE_BIT,
@@ -303,6 +312,7 @@ enum {
  * Event file flags:
  *  ENABLED  - The event is enabled
  *  RECORDED_CMD  - The comms should be recorded at sched_switch
+ *  RECORDED_TGID - The tgids should be recorded at sched_switch
  *  FILTERED - The event has a filter attached
  *  NO_SET_FILTER - Set when filter has error and is to be ignored
  *  SOFT_MODE - The event is enabled/disabled by SOFT_DISABLED
@@ -315,6 +325,7 @@ enum {
 enum {
EVENT_FILE_FL_ENABLED   = (1 << EVENT_FILE_FL_ENABLED_BIT),
EVENT_FILE_FL_RECORDED_CMD  = (1 << EVENT_FILE_FL_RECORDED_CMD_BIT),
+   EVENT_FILE_FL_RECORDED_TGID = (1 << 
EVENT_FILE_FL_RECORDED_TGID_BIT),
EVENT_FILE_FL_FILTERED  = (1 << EVENT_FILE_FL_FILTERED_BIT),
EVENT_FILE_FL_NO_SET_FILTER = (1 << 
EVENT_FILE_FL_NO_SET_FILTER_BIT),
EVENT_FILE_FL_SOFT_MODE = (1 << EVENT_FILE_FL_SOFT_MODE_BIT),
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 1122f151466f..6dec7bef63c7 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -87,7 +87,7 @@ dummy_set_flag(struct trace_array *tr, u32 old_flags, u32 
bit, int set)
  * tracing is active, only save the comm when a trace event
  * occurred.
  */
-static DEFINE_PER_CPU(bool, trace_cmdline_save);
+static DEFINE_PER_CPU(bool, trace_taskinfo_save);
 
 /*
  * Kill all tracing for good (never come back).
@@ -790,7 +790,7 @@ EXPORT_SYMBOL_GPL(tracing_on);
 static __always_inline void
 __buffer_unlock_commit(struct ring_buffer *buffer, struct ring_buffer_event 
*event)
 {
-   __this_cpu_write(trace_cmdline_save, true);
+   __this_cpu_write(trace_taskinfo_save, true);
 
/* If this is the temp buffer, we need to commit fully */
if (this_cpu_read(trace_buffered_event) == event) {
@@ -1709,6 +1709,18 @@ void tracing_reset_all_online_cpus(void)
}
 }
 
+int *tgid_map;
+
+void tracing_alloc_tgid_map(void)
+{
+   if (tgid_map)
+   return;
+
+   tgid_map = kzalloc((PID_MAX_DEFAULT + 1) * sizeof(*tgid_map),
+  GFP_KERNEL);
+   WARN_ONCE(!tgid_map, "Allocation of tgid_map failed\n");
+}
+
 #define SAVED_CMDLINES_DEFAULT 128
 #define NO_CMDLINE_MAP UINT_MAX
 static arch_spinlock_t trace_cmdline_lock = __ARCH_SPIN_LOCK_UNLOCKED;
@@ -1722,7 +1734,7 @@ struct saved_cmdlines_buffer {
 static struct saved_cmdlines_buffer 

[PATCH v4 3/3] tracing/ftrace: Add support to record and display tgid

2017-06-25 Thread Joel Fernandes
Make function tracer able to record tgid if/when record-tgid is enabled.

Cc: kernel-t...@android.com
Cc: Steven Rostedt 
Cc: Ingo Molnar 
Tested-by: Michael Sartain 
Signed-off-by: Joel Fernandes 
---
 kernel/trace/trace_functions.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index a3bddbfd0874..d6bdc38ab273 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -27,6 +27,7 @@ static void
 function_stack_trace_call(unsigned long ip, unsigned long parent_ip,
  struct ftrace_ops *op, struct pt_regs *pt_regs);
 static struct tracer_flags func_flags;
+static bool tgid_recorded;
 
 /* Our option */
 enum {
@@ -104,6 +105,11 @@ static int function_trace_init(struct trace_array *tr)
put_cpu();
 
tracing_start_cmdline_record();
+
+   if (tr->trace_flags & TRACE_ITER_RECORD_TGID) {
+   tgid_recorded = true;
+   tracing_start_tgid_record();
+   }
tracing_start_function_trace(tr);
return 0;
 }
@@ -112,6 +118,10 @@ static void function_trace_reset(struct trace_array *tr)
 {
tracing_stop_function_trace(tr);
tracing_stop_cmdline_record();
+   if (tgid_recorded) {
+   tracing_stop_tgid_record();
+   tgid_recorded = false;
+   }
ftrace_reset_array_ops(tr);
 }
 
@@ -252,6 +262,21 @@ func_set_flag(struct trace_array *tr, u32 old_flags, u32 
bit, int set)
return 0;
 }
 
+static int
+func_tracer_flag_changed(struct trace_array *tr, unsigned int mask,
+int enabled)
+{
+   if (mask == TRACE_ITER_RECORD_TGID) {
+   tgid_recorded = !!enabled;
+   if (enabled)
+   tracing_start_tgid_record();
+   else
+   tracing_stop_tgid_record();
+   }
+
+   return 0;
+}
+
 static struct tracer function_trace __tracer_data =
 {
.name   = "function",
@@ -260,6 +285,7 @@ static struct tracer function_trace __tracer_data =
.start  = function_trace_start,
.flags  = _flags,
.set_flag   = func_set_flag,
+   .flag_changed   = func_tracer_flag_changed,
.allow_instances = true,
 #ifdef CONFIG_FTRACE_SELFTEST
.selftest   = trace_selftest_startup_function,
-- 
2.13.1.611.g7e3b11ae1-goog



Re: [PATCH] pci: Add and use PCI_GENERIC_SETUP Kconfig entry

2017-06-25 Thread kbuild test robot
Hi Palmer,

[auto build test WARNING on linus/master]
[also build test WARNING on v4.12-rc6]
[cannot apply to next-20170623]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Palmer-Dabbelt/pci-Add-and-use-PCI_GENERIC_SETUP-Kconfig-entry/20170626-043558
config: m68k-allnoconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=m68k 

All warnings (new ones prefixed by >>):

warning: (M68K) selects PCI_GENERIC_SETUP which has unmet direct dependencies 
(MMU)

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


.config.gz
Description: application/gzip


[PATCH v4 0/3] tracing: Add support for recording tgid of tasks

2017-06-25 Thread Joel Fernandes
Hi Steven,

Following your comments in [1], I reworked the patches. I agree its much
cleaner now. Please check them out and thanks.

Android systrace viewer heavily depends on the tgid to group tasks. tgid is
also useful for analyzing traces and generating analysis results for groups of
tasks. Also Michael Sartain said he also has a need for it and helped test the
series (I have added him to CC).

[1] https://lkml.org/lkml/2017/6/13/754

Joel Fernandes (3):
  tracing: Add support for recording tgid of tasks
  tracing: Add support for display of tgid in trace output
  tracing/ftrace: Add support to record and display tgid

 include/linux/trace_events.h  |  13 +++-
 kernel/trace/trace.c  | 142 +++---
 kernel/trace/trace.h  |   9 +++
 kernel/trace/trace_events.c   |  42 ++-
 kernel/trace/trace_functions.c|  26 +++
 kernel/trace/trace_output.c   |   9 +++
 kernel/trace/trace_sched_switch.c |  75 
 7 files changed, 276 insertions(+), 40 deletions(-)


Cc: Steven Rostedt 
Cc: Ingo Molnar 
Cc: kernel-t...@android.com
Cc: Michael Sartain 
-- 
2.13.1.611.g7e3b11ae1-goog



[PATCH v4 0/3] tracing: Add support for recording tgid of tasks

2017-06-25 Thread Joel Fernandes
Hi Steven,

Following your comments in [1], I reworked the patches. I agree its much
cleaner now. Please check them out and thanks.

Android systrace viewer heavily depends on the tgid to group tasks. tgid is
also useful for analyzing traces and generating analysis results for groups of
tasks. Also Michael Sartain said he also has a need for it and helped test the
series (I have added him to CC).

[1] https://lkml.org/lkml/2017/6/13/754

Joel Fernandes (3):
  tracing: Add support for recording tgid of tasks
  tracing: Add support for display of tgid in trace output
  tracing/ftrace: Add support to record and display tgid

 include/linux/trace_events.h  |  13 +++-
 kernel/trace/trace.c  | 142 +++---
 kernel/trace/trace.h  |   9 +++
 kernel/trace/trace_events.c   |  42 ++-
 kernel/trace/trace_functions.c|  26 +++
 kernel/trace/trace_output.c   |   9 +++
 kernel/trace/trace_sched_switch.c |  75 
 7 files changed, 276 insertions(+), 40 deletions(-)


Cc: Steven Rostedt 
Cc: Ingo Molnar 
Cc: kernel-t...@android.com
Cc: Michael Sartain 
-- 
2.13.1.611.g7e3b11ae1-goog



[PATCH] cpuidle: menu: allow state 0 to be disabled

2017-06-25 Thread Nicholas Piggin
The menu driver does not allow state0 to be disabled completely.
If it is disabled but other enabled states don't meet latency
requirements, it is still used.

Fix this by starting with the first enabled idle state. Fall back
to state 0 if no idle states are enabled (arguably this should be
-EINVAL if it is attempted, but this is the minimal fix).

Acked-by: Gautham R. Shenoy 
Signed-off-by: Nicholas Piggin 
---

Hi Rafael,

This patch is helpful when measuring power draw of polling,
latency cost of idle states, etc. Please consider merging if
you agree.

Thanks,
Nick


 drivers/cpuidle/governors/menu.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index b2330fd69e34..61b64c2b2cb8 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -286,6 +286,8 @@ static int menu_select(struct cpuidle_driver *drv, struct 
cpuidle_device *dev)
struct device *device = get_cpu_device(dev->cpu);
int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
int i;
+   int first_idx;
+   int idx;
unsigned int interactivity_req;
unsigned int expected_interval;
unsigned long nr_iowaiters, cpu_load;
@@ -335,11 +337,11 @@ static int menu_select(struct cpuidle_driver *drv, struct 
cpuidle_device *dev)
if (data->next_timer_us > polling_threshold &&
latency_req > s->exit_latency && !s->disabled &&
!dev->states_usage[CPUIDLE_DRIVER_STATE_START].disable)
-   data->last_state_idx = CPUIDLE_DRIVER_STATE_START;
+   first_idx = CPUIDLE_DRIVER_STATE_START;
else
-   data->last_state_idx = CPUIDLE_DRIVER_STATE_START - 1;
+   first_idx = CPUIDLE_DRIVER_STATE_START - 1;
} else {
-   data->last_state_idx = CPUIDLE_DRIVER_STATE_START;
+   first_idx = 0;
}
 
/*
@@ -359,20 +361,28 @@ static int menu_select(struct cpuidle_driver *drv, struct 
cpuidle_device *dev)
 * Find the idle state with the lowest power while satisfying
 * our constraints.
 */
-   for (i = data->last_state_idx + 1; i < drv->state_count; i++) {
+   idx = -1;
+   for (i = first_idx; i < drv->state_count; i++) {
struct cpuidle_state *s = >states[i];
struct cpuidle_state_usage *su = >states_usage[i];
 
if (s->disabled || su->disable)
continue;
+   if (idx == -1)
+   idx = i; /* first enabled state */
if (s->target_residency > data->predicted_us)
break;
if (s->exit_latency > latency_req)
break;
 
-   data->last_state_idx = i;
+   idx = i;
}
 
+   if (idx == -1)
+   idx = 0; /* No states enabled. Must use 0. */
+
+   data->last_state_idx = idx;
+
return data->last_state_idx;
 }
 
-- 
2.11.0



[PATCH] cpuidle: menu: allow state 0 to be disabled

2017-06-25 Thread Nicholas Piggin
The menu driver does not allow state0 to be disabled completely.
If it is disabled but other enabled states don't meet latency
requirements, it is still used.

Fix this by starting with the first enabled idle state. Fall back
to state 0 if no idle states are enabled (arguably this should be
-EINVAL if it is attempted, but this is the minimal fix).

Acked-by: Gautham R. Shenoy 
Signed-off-by: Nicholas Piggin 
---

Hi Rafael,

This patch is helpful when measuring power draw of polling,
latency cost of idle states, etc. Please consider merging if
you agree.

Thanks,
Nick


 drivers/cpuidle/governors/menu.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index b2330fd69e34..61b64c2b2cb8 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -286,6 +286,8 @@ static int menu_select(struct cpuidle_driver *drv, struct 
cpuidle_device *dev)
struct device *device = get_cpu_device(dev->cpu);
int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
int i;
+   int first_idx;
+   int idx;
unsigned int interactivity_req;
unsigned int expected_interval;
unsigned long nr_iowaiters, cpu_load;
@@ -335,11 +337,11 @@ static int menu_select(struct cpuidle_driver *drv, struct 
cpuidle_device *dev)
if (data->next_timer_us > polling_threshold &&
latency_req > s->exit_latency && !s->disabled &&
!dev->states_usage[CPUIDLE_DRIVER_STATE_START].disable)
-   data->last_state_idx = CPUIDLE_DRIVER_STATE_START;
+   first_idx = CPUIDLE_DRIVER_STATE_START;
else
-   data->last_state_idx = CPUIDLE_DRIVER_STATE_START - 1;
+   first_idx = CPUIDLE_DRIVER_STATE_START - 1;
} else {
-   data->last_state_idx = CPUIDLE_DRIVER_STATE_START;
+   first_idx = 0;
}
 
/*
@@ -359,20 +361,28 @@ static int menu_select(struct cpuidle_driver *drv, struct 
cpuidle_device *dev)
 * Find the idle state with the lowest power while satisfying
 * our constraints.
 */
-   for (i = data->last_state_idx + 1; i < drv->state_count; i++) {
+   idx = -1;
+   for (i = first_idx; i < drv->state_count; i++) {
struct cpuidle_state *s = >states[i];
struct cpuidle_state_usage *su = >states_usage[i];
 
if (s->disabled || su->disable)
continue;
+   if (idx == -1)
+   idx = i; /* first enabled state */
if (s->target_residency > data->predicted_us)
break;
if (s->exit_latency > latency_req)
break;
 
-   data->last_state_idx = i;
+   idx = i;
}
 
+   if (idx == -1)
+   idx = 0; /* No states enabled. Must use 0. */
+
+   data->last_state_idx = idx;
+
return data->last_state_idx;
 }
 
-- 
2.11.0



Re: [PATCH 11/14] mm, memory_hotplug: do not associate hotadded memory to zones until online

2017-06-25 Thread Michal Hocko
On Sun 25-06-17 08:14:13, Wei Yang wrote:
> On Mon, May 15, 2017 at 10:58:24AM +0200, Michal Hocko wrote:
> >From: Michal Hocko 
> >
> [...]
> >+void move_pfn_range_to_zone(struct zone *zone,
> >+unsigned long start_pfn, unsigned long nr_pages)
> >+{
> >+struct pglist_data *pgdat = zone->zone_pgdat;
> >+int nid = pgdat->node_id;
> >+unsigned long flags;
> >+unsigned long i;
> 
> This is an unused variable:
> 
>   mm/memory_hotplug.c: In function ‘move_pfn_range_to_zone’:
>   mm/memory_hotplug.c:895:16: warning: unused variable ‘i’ [-Wunused-variable]
> 
> Do you suggest me to write a patch or you would fix it in your later rework?

Please send a fix for your
http://lkml.kernel.org/r/20170616092335.5177-2-richard.weiy...@gmail.com
Andrew will fold it into that patch.

> 
> >+
> >+if (zone_is_empty(zone))
> >+init_currently_empty_zone(zone, start_pfn, nr_pages);
> >+
> >+clear_zone_contiguous(zone);
> >+
> >+/* TODO Huh pgdat is irqsave while zone is not. It used to be like that 
> >before */
> >+pgdat_resize_lock(pgdat, );
> >+zone_span_writelock(zone);
> >+resize_zone_range(zone, start_pfn, nr_pages);
> >+zone_span_writeunlock(zone);
> >+resize_pgdat_range(pgdat, start_pfn, nr_pages);
> >+pgdat_resize_unlock(pgdat, );
> >+
> >+/*
> >+ * TODO now we have a visible range of pages which are not associated
> >+ * with their zone properly. Not nice but set_pfnblock_flags_mask
> >+ * expects the zone spans the pfn range. All the pages in the range
> >+ * are reserved so nobody should be touching them so we should be safe
> >+ */
> >+memmap_init_zone(nr_pages, nid, zone_idx(zone), start_pfn, 
> >MEMMAP_HOTPLUG);
> >+for (i = 0; i < nr_pages; i++) {
> >+unsigned long pfn = start_pfn + i;
> >+set_page_links(pfn_to_page(pfn), zone_idx(zone), nid, pfn);
> > }
> > 
> >2.11.0
> 
> -- 
> Wei Yang
> Help you, Help me



-- 
Michal Hocko
SUSE Labs


Re: [PATCH 11/14] mm, memory_hotplug: do not associate hotadded memory to zones until online

2017-06-25 Thread Michal Hocko
On Sun 25-06-17 08:14:13, Wei Yang wrote:
> On Mon, May 15, 2017 at 10:58:24AM +0200, Michal Hocko wrote:
> >From: Michal Hocko 
> >
> [...]
> >+void move_pfn_range_to_zone(struct zone *zone,
> >+unsigned long start_pfn, unsigned long nr_pages)
> >+{
> >+struct pglist_data *pgdat = zone->zone_pgdat;
> >+int nid = pgdat->node_id;
> >+unsigned long flags;
> >+unsigned long i;
> 
> This is an unused variable:
> 
>   mm/memory_hotplug.c: In function ‘move_pfn_range_to_zone’:
>   mm/memory_hotplug.c:895:16: warning: unused variable ‘i’ [-Wunused-variable]
> 
> Do you suggest me to write a patch or you would fix it in your later rework?

Please send a fix for your
http://lkml.kernel.org/r/20170616092335.5177-2-richard.weiy...@gmail.com
Andrew will fold it into that patch.

> 
> >+
> >+if (zone_is_empty(zone))
> >+init_currently_empty_zone(zone, start_pfn, nr_pages);
> >+
> >+clear_zone_contiguous(zone);
> >+
> >+/* TODO Huh pgdat is irqsave while zone is not. It used to be like that 
> >before */
> >+pgdat_resize_lock(pgdat, );
> >+zone_span_writelock(zone);
> >+resize_zone_range(zone, start_pfn, nr_pages);
> >+zone_span_writeunlock(zone);
> >+resize_pgdat_range(pgdat, start_pfn, nr_pages);
> >+pgdat_resize_unlock(pgdat, );
> >+
> >+/*
> >+ * TODO now we have a visible range of pages which are not associated
> >+ * with their zone properly. Not nice but set_pfnblock_flags_mask
> >+ * expects the zone spans the pfn range. All the pages in the range
> >+ * are reserved so nobody should be touching them so we should be safe
> >+ */
> >+memmap_init_zone(nr_pages, nid, zone_idx(zone), start_pfn, 
> >MEMMAP_HOTPLUG);
> >+for (i = 0; i < nr_pages; i++) {
> >+unsigned long pfn = start_pfn + i;
> >+set_page_links(pfn_to_page(pfn), zone_idx(zone), nid, pfn);
> > }
> > 
> >2.11.0
> 
> -- 
> Wei Yang
> Help you, Help me



-- 
Michal Hocko
SUSE Labs


[PATCH V5] powerpc/powernv : Add support for OPAL-OCC command/response interface

2017-06-25 Thread Shilpasri G Bhat
In P9, OCC (On-Chip-Controller) supports shared memory based
commad-response interface. Within the shared memory there is an OPAL
command buffer and OCC response buffer that can be used to send
inband commands to OCC. This patch adds a platform driver to support
the command/response interface between OCC and the host.

Signed-off-by: Shilpasri G Bhat 
---
The skiboot patch for the interface is posted here:
https://lists.ozlabs.org/pipermail/skiboot/2017-June/007960.html

Changes from V4:
- Add token as a parameter to the opal_occ_command()
- Use per-occ counter for command request_id instead of using async
  token.

 arch/powerpc/include/asm/opal-api.h|  41 +++-
 arch/powerpc/include/asm/opal.h|   3 +
 arch/powerpc/platforms/powernv/Makefile|   2 +-
 arch/powerpc/platforms/powernv/opal-occ.c  | 303 +
 arch/powerpc/platforms/powernv/opal-wrappers.S |   1 +
 arch/powerpc/platforms/powernv/opal.c  |   8 +
 6 files changed, 356 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/platforms/powernv/opal-occ.c

diff --git a/arch/powerpc/include/asm/opal-api.h 
b/arch/powerpc/include/asm/opal-api.h
index cb3e624..011d86c 100644
--- a/arch/powerpc/include/asm/opal-api.h
+++ b/arch/powerpc/include/asm/opal-api.h
@@ -42,6 +42,10 @@
 #define OPAL_I2C_STOP_ERR  -24
 #define OPAL_XIVE_PROVISIONING -31
 #define OPAL_XIVE_FREE_ACTIVE  -32
+#define OPAL_OCC_INVALID_STATE -33
+#define OPAL_OCC_BUSY  -34
+#define OPAL_OCC_CMD_TIMEOUT   -35
+#define OPAL_OCC_RSP_MISMATCH  -36
 
 /* API Tokens (in r0) */
 #define OPAL_INVALID_CALL -1
@@ -190,7 +194,8 @@
 #define OPAL_NPU_INIT_CONTEXT  146
 #define OPAL_NPU_DESTROY_CONTEXT   147
 #define OPAL_NPU_MAP_LPAR  148
-#define OPAL_LAST  148
+#define OPAL_OCC_COMMAND   149
+#define OPAL_LAST  149
 
 /* Device tree flags */
 
@@ -829,6 +834,40 @@ struct opal_prd_msg_header {
 
 struct opal_prd_msg;
 
+enum occ_cmd {
+   OCC_CMD_AMESTER_PASS_THRU = 0,
+   OCC_CMD_CLEAR_SENSOR_DATA,
+   OCC_CMD_SET_POWER_CAP,
+   OCC_CMD_SET_POWER_SHIFTING_RATIO,
+   OCC_CMD_SELECT_SENSOR_GROUPS,
+   OCC_CMD_LAST
+};
+
+struct opal_occ_cmd_rsp_msg {
+   __be64 cdata;
+   __be64 rdata;
+   __be16 cdata_size;
+   __be16 rdata_size;
+   u8 cmd;
+   u8 request_id;
+   u8 status;
+};
+
+struct opal_occ_cmd_data {
+   __be16 size;
+   u8 cmd;
+   u8 data[];
+};
+
+struct opal_occ_rsp_data {
+   __be16 size;
+   u8 status;
+   u8 data[];
+};
+
+#define MAX_OPAL_CMD_DATA_LENGTH4090
+#define MAX_OCC_RSP_DATA_LENGTH 8698
+
 #define OCC_RESET   0
 #define OCC_LOAD1
 #define OCC_THROTTLE2
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 03ed493..84659bd 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -346,6 +346,9 @@ static inline int opal_get_async_rc(struct opal_msg msg)
 
 void opal_wake_poller(void);
 
+int64_t opal_occ_command(int chip_id, struct opal_occ_cmd_rsp_msg *msg,
+int token, bool retry);
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* _ASM_POWERPC_OPAL_H */
diff --git a/arch/powerpc/platforms/powernv/Makefile 
b/arch/powerpc/platforms/powernv/Makefile
index b5d98cb..f5f0902 100644
--- a/arch/powerpc/platforms/powernv/Makefile
+++ b/arch/powerpc/platforms/powernv/Makefile
@@ -2,7 +2,7 @@ obj-y   += setup.o opal-wrappers.o opal.o 
opal-async.o idle.o
 obj-y  += opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o
 obj-y  += rng.o opal-elog.o opal-dump.o opal-sysparam.o 
opal-sensor.o
 obj-y  += opal-msglog.o opal-hmi.o opal-power.o opal-irqchip.o
-obj-y  += opal-kmsg.o
+obj-y  += opal-kmsg.o opal-occ.o
 
 obj-$(CONFIG_SMP)  += smp.o subcore.o subcore-asm.o
 obj-$(CONFIG_PCI)  += pci.o pci-ioda.o npu-dma.o
diff --git a/arch/powerpc/platforms/powernv/opal-occ.c 
b/arch/powerpc/platforms/powernv/opal-occ.c
new file mode 100644
index 000..440304f
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/opal-occ.c
@@ -0,0 +1,303 @@
+/*
+ * Copyright IBM Corporation 2017
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#define pr_fmt(fmt) "opal-occ: " fmt
+
+#include 
+#include 
+#include 
+#include 

[PATCH V5] powerpc/powernv : Add support for OPAL-OCC command/response interface

2017-06-25 Thread Shilpasri G Bhat
In P9, OCC (On-Chip-Controller) supports shared memory based
commad-response interface. Within the shared memory there is an OPAL
command buffer and OCC response buffer that can be used to send
inband commands to OCC. This patch adds a platform driver to support
the command/response interface between OCC and the host.

Signed-off-by: Shilpasri G Bhat 
---
The skiboot patch for the interface is posted here:
https://lists.ozlabs.org/pipermail/skiboot/2017-June/007960.html

Changes from V4:
- Add token as a parameter to the opal_occ_command()
- Use per-occ counter for command request_id instead of using async
  token.

 arch/powerpc/include/asm/opal-api.h|  41 +++-
 arch/powerpc/include/asm/opal.h|   3 +
 arch/powerpc/platforms/powernv/Makefile|   2 +-
 arch/powerpc/platforms/powernv/opal-occ.c  | 303 +
 arch/powerpc/platforms/powernv/opal-wrappers.S |   1 +
 arch/powerpc/platforms/powernv/opal.c  |   8 +
 6 files changed, 356 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/platforms/powernv/opal-occ.c

diff --git a/arch/powerpc/include/asm/opal-api.h 
b/arch/powerpc/include/asm/opal-api.h
index cb3e624..011d86c 100644
--- a/arch/powerpc/include/asm/opal-api.h
+++ b/arch/powerpc/include/asm/opal-api.h
@@ -42,6 +42,10 @@
 #define OPAL_I2C_STOP_ERR  -24
 #define OPAL_XIVE_PROVISIONING -31
 #define OPAL_XIVE_FREE_ACTIVE  -32
+#define OPAL_OCC_INVALID_STATE -33
+#define OPAL_OCC_BUSY  -34
+#define OPAL_OCC_CMD_TIMEOUT   -35
+#define OPAL_OCC_RSP_MISMATCH  -36
 
 /* API Tokens (in r0) */
 #define OPAL_INVALID_CALL -1
@@ -190,7 +194,8 @@
 #define OPAL_NPU_INIT_CONTEXT  146
 #define OPAL_NPU_DESTROY_CONTEXT   147
 #define OPAL_NPU_MAP_LPAR  148
-#define OPAL_LAST  148
+#define OPAL_OCC_COMMAND   149
+#define OPAL_LAST  149
 
 /* Device tree flags */
 
@@ -829,6 +834,40 @@ struct opal_prd_msg_header {
 
 struct opal_prd_msg;
 
+enum occ_cmd {
+   OCC_CMD_AMESTER_PASS_THRU = 0,
+   OCC_CMD_CLEAR_SENSOR_DATA,
+   OCC_CMD_SET_POWER_CAP,
+   OCC_CMD_SET_POWER_SHIFTING_RATIO,
+   OCC_CMD_SELECT_SENSOR_GROUPS,
+   OCC_CMD_LAST
+};
+
+struct opal_occ_cmd_rsp_msg {
+   __be64 cdata;
+   __be64 rdata;
+   __be16 cdata_size;
+   __be16 rdata_size;
+   u8 cmd;
+   u8 request_id;
+   u8 status;
+};
+
+struct opal_occ_cmd_data {
+   __be16 size;
+   u8 cmd;
+   u8 data[];
+};
+
+struct opal_occ_rsp_data {
+   __be16 size;
+   u8 status;
+   u8 data[];
+};
+
+#define MAX_OPAL_CMD_DATA_LENGTH4090
+#define MAX_OCC_RSP_DATA_LENGTH 8698
+
 #define OCC_RESET   0
 #define OCC_LOAD1
 #define OCC_THROTTLE2
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 03ed493..84659bd 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -346,6 +346,9 @@ static inline int opal_get_async_rc(struct opal_msg msg)
 
 void opal_wake_poller(void);
 
+int64_t opal_occ_command(int chip_id, struct opal_occ_cmd_rsp_msg *msg,
+int token, bool retry);
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* _ASM_POWERPC_OPAL_H */
diff --git a/arch/powerpc/platforms/powernv/Makefile 
b/arch/powerpc/platforms/powernv/Makefile
index b5d98cb..f5f0902 100644
--- a/arch/powerpc/platforms/powernv/Makefile
+++ b/arch/powerpc/platforms/powernv/Makefile
@@ -2,7 +2,7 @@ obj-y   += setup.o opal-wrappers.o opal.o 
opal-async.o idle.o
 obj-y  += opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o
 obj-y  += rng.o opal-elog.o opal-dump.o opal-sysparam.o 
opal-sensor.o
 obj-y  += opal-msglog.o opal-hmi.o opal-power.o opal-irqchip.o
-obj-y  += opal-kmsg.o
+obj-y  += opal-kmsg.o opal-occ.o
 
 obj-$(CONFIG_SMP)  += smp.o subcore.o subcore-asm.o
 obj-$(CONFIG_PCI)  += pci.o pci-ioda.o npu-dma.o
diff --git a/arch/powerpc/platforms/powernv/opal-occ.c 
b/arch/powerpc/platforms/powernv/opal-occ.c
new file mode 100644
index 000..440304f
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/opal-occ.c
@@ -0,0 +1,303 @@
+/*
+ * Copyright IBM Corporation 2017
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#define pr_fmt(fmt) "opal-occ: " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+

Re: Linux 4.4.74

2017-06-25 Thread Greg KH
diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index ca64ca566099..7c77d7edb851 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -3580,6 +3580,13 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
spia_pedr=
spia_peddr=
 
+   stack_guard_gap=[MM]
+   override the default stack gap protection. The value
+   is in page units and it defines how many pages prior
+   to (for stacks growing down) resp. after (for stacks
+   growing up) the main stack are reserved for no other
+   mapping. Default value is 256 pages.
+
stacktrace  [FTRACE]
Enabled the stack tracer on boot up.
 
diff --git a/Makefile b/Makefile
index ba5a70b6e32c..1f75507acbf4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 4
 PATCHLEVEL = 4
-SUBLEVEL = 73
+SUBLEVEL = 74
 EXTRAVERSION =
 NAME = Blurry Fish Butt
 
diff --git a/arch/arc/mm/mmap.c b/arch/arc/mm/mmap.c
index 2e06d56e987b..cf4ae6958240 100644
--- a/arch/arc/mm/mmap.c
+++ b/arch/arc/mm/mmap.c
@@ -64,7 +64,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 407dc786583a..c469c0665752 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -89,7 +89,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
@@ -140,7 +140,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const 
unsigned long addr0,
addr = PAGE_ALIGN(addr);
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
index 836f14707a62..efa59f1f8022 100644
--- a/arch/frv/mm/elf-fdpic.c
+++ b/arch/frv/mm/elf-fdpic.c
@@ -74,7 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, 
unsigned long addr, unsi
addr = PAGE_ALIGN(addr);
vma = find_vma(current->mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
goto success;
}
 
diff --git a/arch/mips/kernel/branch.c b/arch/mips/kernel/branch.c
index d8f9b357b222..e9fed8ca9b42 100644
--- a/arch/mips/kernel/branch.c
+++ b/arch/mips/kernel/branch.c
@@ -816,8 +816,10 @@ int __compute_return_epc_for_insn(struct pt_regs *regs,
break;
}
/* Compact branch: BNEZC || JIALC */
-   if (insn.i_format.rs)
+   if (!insn.i_format.rs) {
+   /* JIALC: set $31/ra */
regs->regs[31] = epc + 4;
+   }
regs->cp0_epc += 8;
break;
 #endif
diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
index 5c81fdd032c3..025cb31aa0a2 100644
--- a/arch/mips/mm/mmap.c
+++ b/arch/mips/mm/mmap.c
@@ -92,7 +92,7 @@ static unsigned long arch_get_unmapped_area_common(struct 
file *filp,
 
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 5aba01ac457f..4dda73c44fee 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -88,7 +88,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, 
unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags)
 {
struct mm_struct *mm = current->mm;
-   struct vm_area_struct *vma;
+   struct vm_area_struct *vma, *prev;
unsigned long task_size = TASK_SIZE;
int do_color_align, last_mmap;
struct vm_unmapped_area_info info;
@@ -115,9 +115,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, 
unsigned long addr,
else
addr = PAGE_ALIGN(addr);
 
-   vma = find_vma(mm, addr);
+

Re: Linux 4.4.74

2017-06-25 Thread Greg KH
diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index ca64ca566099..7c77d7edb851 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -3580,6 +3580,13 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
spia_pedr=
spia_peddr=
 
+   stack_guard_gap=[MM]
+   override the default stack gap protection. The value
+   is in page units and it defines how many pages prior
+   to (for stacks growing down) resp. after (for stacks
+   growing up) the main stack are reserved for no other
+   mapping. Default value is 256 pages.
+
stacktrace  [FTRACE]
Enabled the stack tracer on boot up.
 
diff --git a/Makefile b/Makefile
index ba5a70b6e32c..1f75507acbf4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 4
 PATCHLEVEL = 4
-SUBLEVEL = 73
+SUBLEVEL = 74
 EXTRAVERSION =
 NAME = Blurry Fish Butt
 
diff --git a/arch/arc/mm/mmap.c b/arch/arc/mm/mmap.c
index 2e06d56e987b..cf4ae6958240 100644
--- a/arch/arc/mm/mmap.c
+++ b/arch/arc/mm/mmap.c
@@ -64,7 +64,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 407dc786583a..c469c0665752 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -89,7 +89,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
@@ -140,7 +140,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const 
unsigned long addr0,
addr = PAGE_ALIGN(addr);
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
index 836f14707a62..efa59f1f8022 100644
--- a/arch/frv/mm/elf-fdpic.c
+++ b/arch/frv/mm/elf-fdpic.c
@@ -74,7 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, 
unsigned long addr, unsi
addr = PAGE_ALIGN(addr);
vma = find_vma(current->mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
goto success;
}
 
diff --git a/arch/mips/kernel/branch.c b/arch/mips/kernel/branch.c
index d8f9b357b222..e9fed8ca9b42 100644
--- a/arch/mips/kernel/branch.c
+++ b/arch/mips/kernel/branch.c
@@ -816,8 +816,10 @@ int __compute_return_epc_for_insn(struct pt_regs *regs,
break;
}
/* Compact branch: BNEZC || JIALC */
-   if (insn.i_format.rs)
+   if (!insn.i_format.rs) {
+   /* JIALC: set $31/ra */
regs->regs[31] = epc + 4;
+   }
regs->cp0_epc += 8;
break;
 #endif
diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
index 5c81fdd032c3..025cb31aa0a2 100644
--- a/arch/mips/mm/mmap.c
+++ b/arch/mips/mm/mmap.c
@@ -92,7 +92,7 @@ static unsigned long arch_get_unmapped_area_common(struct 
file *filp,
 
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 5aba01ac457f..4dda73c44fee 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -88,7 +88,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, 
unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags)
 {
struct mm_struct *mm = current->mm;
-   struct vm_area_struct *vma;
+   struct vm_area_struct *vma, *prev;
unsigned long task_size = TASK_SIZE;
int do_color_align, last_mmap;
struct vm_unmapped_area_info info;
@@ -115,9 +115,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, 
unsigned long addr,
else
addr = PAGE_ALIGN(addr);
 
-   vma = find_vma(mm, addr);
+

Linux 4.4.74

2017-06-25 Thread Greg KH
I'm announcing the release of the 4.4.74 kernel.

All users of the 4.4 kernel series must upgrade.

The updated 4.4.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git 
linux-4.4.y
and can be browsed at the normal kernel.org git web browser:

http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary

thanks,

greg k-h



 Documentation/kernel-parameters.txt|7 +
 Makefile   |2 
 arch/arc/mm/mmap.c |2 
 arch/arm/mm/mmap.c |4 
 arch/frv/mm/elf-fdpic.c|2 
 arch/mips/kernel/branch.c  |4 
 arch/mips/mm/mmap.c|2 
 arch/parisc/kernel/sys_parisc.c|   15 +-
 arch/powerpc/mm/slice.c|2 
 arch/s390/mm/mmap.c|4 
 arch/sh/mm/mmap.c  |4 
 arch/sparc/kernel/sys_sparc_64.c   |4 
 arch/sparc/mm/hugetlbpage.c|2 
 arch/tile/mm/hugetlbpage.c |2 
 arch/x86/kernel/sys_x86_64.c   |4 
 arch/x86/mm/hugetlbpage.c  |2 
 arch/x86/mm/numa_32.c  |1 
 arch/xtensa/kernel/syscall.c   |2 
 drivers/cpufreq/cpufreq_conservative.c |4 
 drivers/iio/proximity/as3935.c |6 -
 drivers/media/usb/pvrusb2/pvrusb2-eeprom.c |   13 --
 drivers/media/v4l2-core/videobuf2-core.c   |2 
 drivers/mfd/omap-usb-tll.c |2 
 drivers/misc/c2port/c2port-duramar2150.c   |4 
 drivers/net/can/usb/gs_usb.c   |2 
 drivers/staging/rtl8188eu/core/rtw_ap.c|2 
 drivers/tty/serial/efm32-uart.c|   11 +
 drivers/usb/core/hcd.c |1 
 drivers/usb/core/hub.c |8 +
 drivers/usb/dwc3/dwc3-exynos.c |4 
 drivers/usb/gadget/legacy/inode.c  |5 
 drivers/usb/gadget/udc/dummy_hcd.c |   19 +--
 drivers/usb/gadget/udc/net2280.c   |9 -
 drivers/usb/host/r8a66597-hcd.c|6 -
 drivers/usb/host/xhci-pci.c|3 
 fs/configfs/symlink.c  |3 
 fs/hugetlbfs/inode.c   |2 
 fs/proc/task_mmu.c |4 
 include/linux/mm.h |   53 -
 include/uapi/linux/usb/ch11.h  |3 
 kernel/irq/manage.c|4 
 kernel/time/alarmtimer.c   |   14 +-
 mm/gup.c   |5 
 mm/memory-failure.c|5 
 mm/memory.c|   38 --
 mm/mmap.c  |  160 +
 mm/swap_cgroup.c   |3 
 net/mac80211/ibss.c|6 -
 net/mac80211/rx.c  |6 -
 net/mac80211/wpa.c |9 -
 50 files changed, 253 insertions(+), 228 deletions(-)

Alan Stern (1):
  USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks

Anton Bondarenko (1):
  usb: core: fix potential memory leak in error path during hcd creation

Arnd Bergmann (1):
  pvrusb2: reduce stack usage pvr2_eeprom_analyze()

Chris Brandt (2):
  usb: r8a66597-hcd: select a different endpoint on timeout
  usb: r8a66597-hcd: decrease timeout

Christophe JAILLET (2):
  vb2: Fix an off by one error in 'vb2_plane_vaddr'
  serial: efm32: Fix parity management in 'efm32_uart_console_get_options()'

Corentin Labbe (1):
  usb: xhci: ASMedia ASM1042A chipset need shorts TX quirk

Dan Carpenter (2):
  staging: rtl8188eu: prevent an underflow in rtw_check_beacon_data()
  drivers/misc/c2port/c2port-duramar2150.c: checking for NULL instead of 
IS_ERR()

Emmanuel Grumbach (1):
  mac80211: don't look at the PM bit of BAR frames

Greg Kroah-Hartman (1):
  Linux 4.4.74

Heiner Kallweit (1):
  genirq: Release resources in __setup_irq() error path

Helge Deller (1):
  Allow stack to grow up to address space limit

Hugh Dickins (2):
  mm: larger stack guard gap, between vmas
  mm: fix new crash in unmapped_area_topdown()

James Morse (1):
  mm/memory-failure.c: use compound_head() flags for huge pages

Jason A. Donenfeld (1):
  mac80211/wpa: use constant time memory comparison for MACs

Johan Hovold (2):
  USB: hub: fix SS max number of ports
  USB: gadget: dummy_hcd: fix hub-descriptor removable fields

Johannes Berg (1):
  mac80211: fix IBSS presp allocation size

Koen Vandeputte (1):
  mac80211: fix CSA in IBSS mode

Laura Abbott (1):
  x86/mm/32: Set the '__vmalloc_start_set' flag in initmem_init()

Marc Kleine-Budde (1):
  can: gs_usb: fix memory leak in gs_cmd_reset()

Matt Ranostay (1):
  iio: proximity: as3935: recalibrate RCO 

Linux 4.4.74

2017-06-25 Thread Greg KH
I'm announcing the release of the 4.4.74 kernel.

All users of the 4.4 kernel series must upgrade.

The updated 4.4.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git 
linux-4.4.y
and can be browsed at the normal kernel.org git web browser:

http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary

thanks,

greg k-h



 Documentation/kernel-parameters.txt|7 +
 Makefile   |2 
 arch/arc/mm/mmap.c |2 
 arch/arm/mm/mmap.c |4 
 arch/frv/mm/elf-fdpic.c|2 
 arch/mips/kernel/branch.c  |4 
 arch/mips/mm/mmap.c|2 
 arch/parisc/kernel/sys_parisc.c|   15 +-
 arch/powerpc/mm/slice.c|2 
 arch/s390/mm/mmap.c|4 
 arch/sh/mm/mmap.c  |4 
 arch/sparc/kernel/sys_sparc_64.c   |4 
 arch/sparc/mm/hugetlbpage.c|2 
 arch/tile/mm/hugetlbpage.c |2 
 arch/x86/kernel/sys_x86_64.c   |4 
 arch/x86/mm/hugetlbpage.c  |2 
 arch/x86/mm/numa_32.c  |1 
 arch/xtensa/kernel/syscall.c   |2 
 drivers/cpufreq/cpufreq_conservative.c |4 
 drivers/iio/proximity/as3935.c |6 -
 drivers/media/usb/pvrusb2/pvrusb2-eeprom.c |   13 --
 drivers/media/v4l2-core/videobuf2-core.c   |2 
 drivers/mfd/omap-usb-tll.c |2 
 drivers/misc/c2port/c2port-duramar2150.c   |4 
 drivers/net/can/usb/gs_usb.c   |2 
 drivers/staging/rtl8188eu/core/rtw_ap.c|2 
 drivers/tty/serial/efm32-uart.c|   11 +
 drivers/usb/core/hcd.c |1 
 drivers/usb/core/hub.c |8 +
 drivers/usb/dwc3/dwc3-exynos.c |4 
 drivers/usb/gadget/legacy/inode.c  |5 
 drivers/usb/gadget/udc/dummy_hcd.c |   19 +--
 drivers/usb/gadget/udc/net2280.c   |9 -
 drivers/usb/host/r8a66597-hcd.c|6 -
 drivers/usb/host/xhci-pci.c|3 
 fs/configfs/symlink.c  |3 
 fs/hugetlbfs/inode.c   |2 
 fs/proc/task_mmu.c |4 
 include/linux/mm.h |   53 -
 include/uapi/linux/usb/ch11.h  |3 
 kernel/irq/manage.c|4 
 kernel/time/alarmtimer.c   |   14 +-
 mm/gup.c   |5 
 mm/memory-failure.c|5 
 mm/memory.c|   38 --
 mm/mmap.c  |  160 +
 mm/swap_cgroup.c   |3 
 net/mac80211/ibss.c|6 -
 net/mac80211/rx.c  |6 -
 net/mac80211/wpa.c |9 -
 50 files changed, 253 insertions(+), 228 deletions(-)

Alan Stern (1):
  USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks

Anton Bondarenko (1):
  usb: core: fix potential memory leak in error path during hcd creation

Arnd Bergmann (1):
  pvrusb2: reduce stack usage pvr2_eeprom_analyze()

Chris Brandt (2):
  usb: r8a66597-hcd: select a different endpoint on timeout
  usb: r8a66597-hcd: decrease timeout

Christophe JAILLET (2):
  vb2: Fix an off by one error in 'vb2_plane_vaddr'
  serial: efm32: Fix parity management in 'efm32_uart_console_get_options()'

Corentin Labbe (1):
  usb: xhci: ASMedia ASM1042A chipset need shorts TX quirk

Dan Carpenter (2):
  staging: rtl8188eu: prevent an underflow in rtw_check_beacon_data()
  drivers/misc/c2port/c2port-duramar2150.c: checking for NULL instead of 
IS_ERR()

Emmanuel Grumbach (1):
  mac80211: don't look at the PM bit of BAR frames

Greg Kroah-Hartman (1):
  Linux 4.4.74

Heiner Kallweit (1):
  genirq: Release resources in __setup_irq() error path

Helge Deller (1):
  Allow stack to grow up to address space limit

Hugh Dickins (2):
  mm: larger stack guard gap, between vmas
  mm: fix new crash in unmapped_area_topdown()

James Morse (1):
  mm/memory-failure.c: use compound_head() flags for huge pages

Jason A. Donenfeld (1):
  mac80211/wpa: use constant time memory comparison for MACs

Johan Hovold (2):
  USB: hub: fix SS max number of ports
  USB: gadget: dummy_hcd: fix hub-descriptor removable fields

Johannes Berg (1):
  mac80211: fix IBSS presp allocation size

Koen Vandeputte (1):
  mac80211: fix CSA in IBSS mode

Laura Abbott (1):
  x86/mm/32: Set the '__vmalloc_start_set' flag in initmem_init()

Marc Kleine-Budde (1):
  can: gs_usb: fix memory leak in gs_cmd_reset()

Matt Ranostay (1):
  iio: proximity: as3935: recalibrate RCO 

Re: Linux 3.18.58

2017-06-25 Thread Greg KH
diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index b2bdea1953e6..9abe55280cf6 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -3324,6 +3324,13 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
spia_pedr=
spia_peddr=
 
+   stack_guard_gap=[MM]
+   override the default stack gap protection. The value
+   is in page units and it defines how many pages prior
+   to (for stacks growing down) resp. after (for stacks
+   growing up) the main stack are reserved for no other
+   mapping. Default value is 256 pages.
+
stacktrace  [FTRACE]
Enabled the stack tracer on boot up.
 
diff --git a/Makefile b/Makefile
index 8ad497f954d7..e44d3f45b72a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 3
 PATCHLEVEL = 18
-SUBLEVEL = 57
+SUBLEVEL = 58
 EXTRAVERSION =
 NAME = Diseased Newt
 
diff --git a/arch/arc/mm/mmap.c b/arch/arc/mm/mmap.c
index 2e06d56e987b..cf4ae6958240 100644
--- a/arch/arc/mm/mmap.c
+++ b/arch/arc/mm/mmap.c
@@ -64,7 +64,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 5e85ed371364..8f9d1cf505dd 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -89,7 +89,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
@@ -140,7 +140,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const 
unsigned long addr0,
addr = PAGE_ALIGN(addr);
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
index 836f14707a62..efa59f1f8022 100644
--- a/arch/frv/mm/elf-fdpic.c
+++ b/arch/frv/mm/elf-fdpic.c
@@ -74,7 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, 
unsigned long addr, unsi
addr = PAGE_ALIGN(addr);
vma = find_vma(current->mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
goto success;
}
 
diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
index f1baadd56e82..9be924f08f34 100644
--- a/arch/mips/mm/mmap.c
+++ b/arch/mips/mm/mmap.c
@@ -92,7 +92,7 @@ static unsigned long arch_get_unmapped_area_common(struct 
file *filp,
 
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 5aba01ac457f..4dda73c44fee 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -88,7 +88,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, 
unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags)
 {
struct mm_struct *mm = current->mm;
-   struct vm_area_struct *vma;
+   struct vm_area_struct *vma, *prev;
unsigned long task_size = TASK_SIZE;
int do_color_align, last_mmap;
struct vm_unmapped_area_info info;
@@ -115,9 +115,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, 
unsigned long addr,
else
addr = PAGE_ALIGN(addr);
 
-   vma = find_vma(mm, addr);
+   vma = find_vma_prev(mm, addr, );
if (task_size - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)) &&
+   (!prev || addr >= vm_end_gap(prev)))
goto found_addr;
}
 
@@ -141,7 +142,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const 
unsigned long addr0,
  const unsigned long len, const unsigned long pgoff,
  const unsigned long flags)
 {
-   struct vm_area_struct *vma;
+   struct 

Re: Linux 3.18.58

2017-06-25 Thread Greg KH
diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index b2bdea1953e6..9abe55280cf6 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -3324,6 +3324,13 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
spia_pedr=
spia_peddr=
 
+   stack_guard_gap=[MM]
+   override the default stack gap protection. The value
+   is in page units and it defines how many pages prior
+   to (for stacks growing down) resp. after (for stacks
+   growing up) the main stack are reserved for no other
+   mapping. Default value is 256 pages.
+
stacktrace  [FTRACE]
Enabled the stack tracer on boot up.
 
diff --git a/Makefile b/Makefile
index 8ad497f954d7..e44d3f45b72a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 3
 PATCHLEVEL = 18
-SUBLEVEL = 57
+SUBLEVEL = 58
 EXTRAVERSION =
 NAME = Diseased Newt
 
diff --git a/arch/arc/mm/mmap.c b/arch/arc/mm/mmap.c
index 2e06d56e987b..cf4ae6958240 100644
--- a/arch/arc/mm/mmap.c
+++ b/arch/arc/mm/mmap.c
@@ -64,7 +64,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 5e85ed371364..8f9d1cf505dd 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -89,7 +89,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
@@ -140,7 +140,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const 
unsigned long addr0,
addr = PAGE_ALIGN(addr);
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
index 836f14707a62..efa59f1f8022 100644
--- a/arch/frv/mm/elf-fdpic.c
+++ b/arch/frv/mm/elf-fdpic.c
@@ -74,7 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, 
unsigned long addr, unsi
addr = PAGE_ALIGN(addr);
vma = find_vma(current->mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
goto success;
}
 
diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
index f1baadd56e82..9be924f08f34 100644
--- a/arch/mips/mm/mmap.c
+++ b/arch/mips/mm/mmap.c
@@ -92,7 +92,7 @@ static unsigned long arch_get_unmapped_area_common(struct 
file *filp,
 
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
 
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 5aba01ac457f..4dda73c44fee 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -88,7 +88,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, 
unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags)
 {
struct mm_struct *mm = current->mm;
-   struct vm_area_struct *vma;
+   struct vm_area_struct *vma, *prev;
unsigned long task_size = TASK_SIZE;
int do_color_align, last_mmap;
struct vm_unmapped_area_info info;
@@ -115,9 +115,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, 
unsigned long addr,
else
addr = PAGE_ALIGN(addr);
 
-   vma = find_vma(mm, addr);
+   vma = find_vma_prev(mm, addr, );
if (task_size - len >= addr &&
-   (!vma || addr + len <= vma->vm_start))
+   (!vma || addr + len <= vm_start_gap(vma)) &&
+   (!prev || addr >= vm_end_gap(prev)))
goto found_addr;
}
 
@@ -141,7 +142,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const 
unsigned long addr0,
  const unsigned long len, const unsigned long pgoff,
  const unsigned long flags)
 {
-   struct vm_area_struct *vma;
+   struct 

Linux 3.18.58

2017-06-25 Thread Greg KH
I'm announcing the release of the 3.18.58 kernel.

All users of the 3.18 kernel series must upgrade.

The updated 3.18.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git 
linux-3.18.y
and can be browsed at the normal kernel.org git web browser:

http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary

thanks,

greg k-h



 Documentation/kernel-parameters.txt   |7 +
 Makefile  |2 
 arch/arc/mm/mmap.c|2 
 arch/arm/mm/mmap.c|4 
 arch/frv/mm/elf-fdpic.c   |2 
 arch/mips/mm/mmap.c   |2 
 arch/parisc/kernel/sys_parisc.c   |   15 +-
 arch/powerpc/mm/slice.c   |2 
 arch/s390/mm/vmem.c   |2 
 arch/sh/mm/mmap.c |4 
 arch/sparc/kernel/sys_sparc_64.c  |4 
 arch/sparc/kernel/traps_64.c  |4 
 arch/sparc/mm/hugetlbpage.c   |2 
 arch/tile/mm/hugetlbpage.c|2 
 arch/x86/kernel/sys_x86_64.c  |4 
 arch/x86/mm/hugetlbpage.c |2 
 arch/x86/mm/numa_32.c |1 
 arch/xtensa/kernel/syscall.c  |2 
 block/partitions/msdos.c  |2 
 drivers/cpufreq/cpufreq_conservative.c|4 
 drivers/iio/proximity/as3935.c|6 
 drivers/media/usb/pvrusb2/pvrusb2-eeprom.c|   13 --
 drivers/media/v4l2-core/videobuf2-core.c  |2 
 drivers/mfd/omap-usb-tll.c|2 
 drivers/misc/c2port/c2port-duramar2150.c  |4 
 drivers/net/can/usb/gs_usb.c  |2 
 drivers/net/ethernet/xilinx/xilinx_emaclite.c |  126 +++-
 drivers/staging/rtl8188eu/core/rtw_ap.c   |2 
 drivers/tty/serial/efm32-uart.c   |   11 +
 drivers/usb/core/hcd.c|1 
 drivers/usb/core/hub.c|8 +
 drivers/usb/gadget/udc/dummy_hcd.c|6 
 drivers/usb/host/r8a66597-hcd.c   |6 
 drivers/usb/host/xhci-pci.c   |3 
 fs/cifs/connect.c |   24 ++-
 fs/configfs/symlink.c |3 
 fs/hugetlbfs/inode.c  |2 
 fs/proc/task_mmu.c|4 
 include/linux/log2.h  |   13 +-
 include/linux/mm.h|   53 
 include/uapi/linux/usb/ch11.h |3 
 kernel/irq/manage.c   |4 
 kernel/time/alarmtimer.c  |8 +
 mm/gup.c  |5 
 mm/memory-failure.c   |5 
 mm/memory.c   |   38 --
 mm/mmap.c |  160 +++---
 mm/page_cgroup.c  |3 
 net/ipv6/datagram.c   |   14 +-
 net/ipv6/ip6_output.c |3 
 net/ipv6/tcp_ipv6.c   |   11 +
 net/ipv6/udp.c|4 
 net/mac80211/rx.c |6 
 53 files changed, 353 insertions(+), 271 deletions(-)

Anssi Hannula (2):
  net: xilinx_emaclite: fix freezes due to unordered I/O
  net: xilinx_emaclite: fix receive buffer overflow

Anton Bondarenko (1):
  usb: core: fix potential memory leak in error path during hcd creation

Ard Biesheuvel (1):
  log2: make order_base_2() behave correctly on const input value zero

Arnd Bergmann (1):
  pvrusb2: reduce stack usage pvr2_eeprom_analyze()

Chris Brandt (2):
  usb: r8a66597-hcd: select a different endpoint on timeout
  usb: r8a66597-hcd: decrease timeout

Christophe JAILLET (2):
  vb2: Fix an off by one error in 'vb2_plane_vaddr'
  serial: efm32: Fix parity management in 'efm32_uart_console_get_options()'

Corentin Labbe (1):
  usb: xhci: ASMedia ASM1042A chipset need shorts TX quirk

Dan Carpenter (3):
  sparc64: make string buffers large enough
  staging: rtl8188eu: prevent an underflow in rtw_check_beacon_data()
  drivers/misc/c2port/c2port-duramar2150.c: checking for NULL instead of 
IS_ERR()

Emmanuel Grumbach (1):
  mac80211: don't look at the PM bit of BAR frames

Greg Kroah-Hartman (1):
  Linux 3.18.58

Heiko Carstens (1):
  s390/vmem: fix identity mapping

Heiner Kallweit (1):
  genirq: Release resources in __setup_irq() error path

Helge Deller (1):
  Allow stack to grow up to address space limit

Hugh Dickins (2):
  mm: larger stack guard gap, between vmas
  mm: fix new crash in unmapped_area_topdown()

James Morse (1):
  mm/memory-failure.c: use compound_head() flags 

Linux 3.18.58

2017-06-25 Thread Greg KH
I'm announcing the release of the 3.18.58 kernel.

All users of the 3.18 kernel series must upgrade.

The updated 3.18.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git 
linux-3.18.y
and can be browsed at the normal kernel.org git web browser:

http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary

thanks,

greg k-h



 Documentation/kernel-parameters.txt   |7 +
 Makefile  |2 
 arch/arc/mm/mmap.c|2 
 arch/arm/mm/mmap.c|4 
 arch/frv/mm/elf-fdpic.c   |2 
 arch/mips/mm/mmap.c   |2 
 arch/parisc/kernel/sys_parisc.c   |   15 +-
 arch/powerpc/mm/slice.c   |2 
 arch/s390/mm/vmem.c   |2 
 arch/sh/mm/mmap.c |4 
 arch/sparc/kernel/sys_sparc_64.c  |4 
 arch/sparc/kernel/traps_64.c  |4 
 arch/sparc/mm/hugetlbpage.c   |2 
 arch/tile/mm/hugetlbpage.c|2 
 arch/x86/kernel/sys_x86_64.c  |4 
 arch/x86/mm/hugetlbpage.c |2 
 arch/x86/mm/numa_32.c |1 
 arch/xtensa/kernel/syscall.c  |2 
 block/partitions/msdos.c  |2 
 drivers/cpufreq/cpufreq_conservative.c|4 
 drivers/iio/proximity/as3935.c|6 
 drivers/media/usb/pvrusb2/pvrusb2-eeprom.c|   13 --
 drivers/media/v4l2-core/videobuf2-core.c  |2 
 drivers/mfd/omap-usb-tll.c|2 
 drivers/misc/c2port/c2port-duramar2150.c  |4 
 drivers/net/can/usb/gs_usb.c  |2 
 drivers/net/ethernet/xilinx/xilinx_emaclite.c |  126 +++-
 drivers/staging/rtl8188eu/core/rtw_ap.c   |2 
 drivers/tty/serial/efm32-uart.c   |   11 +
 drivers/usb/core/hcd.c|1 
 drivers/usb/core/hub.c|8 +
 drivers/usb/gadget/udc/dummy_hcd.c|6 
 drivers/usb/host/r8a66597-hcd.c   |6 
 drivers/usb/host/xhci-pci.c   |3 
 fs/cifs/connect.c |   24 ++-
 fs/configfs/symlink.c |3 
 fs/hugetlbfs/inode.c  |2 
 fs/proc/task_mmu.c|4 
 include/linux/log2.h  |   13 +-
 include/linux/mm.h|   53 
 include/uapi/linux/usb/ch11.h |3 
 kernel/irq/manage.c   |4 
 kernel/time/alarmtimer.c  |8 +
 mm/gup.c  |5 
 mm/memory-failure.c   |5 
 mm/memory.c   |   38 --
 mm/mmap.c |  160 +++---
 mm/page_cgroup.c  |3 
 net/ipv6/datagram.c   |   14 +-
 net/ipv6/ip6_output.c |3 
 net/ipv6/tcp_ipv6.c   |   11 +
 net/ipv6/udp.c|4 
 net/mac80211/rx.c |6 
 53 files changed, 353 insertions(+), 271 deletions(-)

Anssi Hannula (2):
  net: xilinx_emaclite: fix freezes due to unordered I/O
  net: xilinx_emaclite: fix receive buffer overflow

Anton Bondarenko (1):
  usb: core: fix potential memory leak in error path during hcd creation

Ard Biesheuvel (1):
  log2: make order_base_2() behave correctly on const input value zero

Arnd Bergmann (1):
  pvrusb2: reduce stack usage pvr2_eeprom_analyze()

Chris Brandt (2):
  usb: r8a66597-hcd: select a different endpoint on timeout
  usb: r8a66597-hcd: decrease timeout

Christophe JAILLET (2):
  vb2: Fix an off by one error in 'vb2_plane_vaddr'
  serial: efm32: Fix parity management in 'efm32_uart_console_get_options()'

Corentin Labbe (1):
  usb: xhci: ASMedia ASM1042A chipset need shorts TX quirk

Dan Carpenter (3):
  sparc64: make string buffers large enough
  staging: rtl8188eu: prevent an underflow in rtw_check_beacon_data()
  drivers/misc/c2port/c2port-duramar2150.c: checking for NULL instead of 
IS_ERR()

Emmanuel Grumbach (1):
  mac80211: don't look at the PM bit of BAR frames

Greg Kroah-Hartman (1):
  Linux 3.18.58

Heiko Carstens (1):
  s390/vmem: fix identity mapping

Heiner Kallweit (1):
  genirq: Release resources in __setup_irq() error path

Helge Deller (1):
  Allow stack to grow up to address space limit

Hugh Dickins (2):
  mm: larger stack guard gap, between vmas
  mm: fix new crash in unmapped_area_topdown()

James Morse (1):
  mm/memory-failure.c: use compound_head() flags 

Re: [PATCH 6/6] mm, migration: do not trigger OOM killer when migrating memory

2017-06-25 Thread Michal Hocko
On Fri 23-06-17 13:43:05, Andrew Morton wrote:
> On Fri, 23 Jun 2017 10:53:45 +0200 Michal Hocko  wrote:
> 
> > From: Michal Hocko 
> > 
> > Page migration (for memory hotplug, soft_offline_page or mbind) needs
> > to allocate a new memory. This can trigger an oom killer if the target
> > memory is depleated. Although quite unlikely, still possible, especially
> > for the memory hotplug (offlining of memoery). Up to now we didn't
> > really have reasonable means to back off. __GFP_NORETRY can fail just
> > too easily and __GFP_THISNODE sticks to a single node and that is not
> > suitable for all callers.
> > 
> > But now that we have __GFP_RETRY_MAYFAIL we should use it.  It is
> > preferable to fail the migration than disrupt the system by killing some
> > processes.
> 
> I'm not sure which tree this is against...

next-20170623

> 
> > --- a/mm/memory-failure.c
> > +++ b/mm/memory-failure.c
> > @@ -1492,7 +1492,8 @@ static struct page *new_page(struct page *p, unsigned 
> > long private, int **x)
> >  
> > return alloc_huge_page_node(hstate, nid);
> > } else {
> > -   return __alloc_pages_node(nid, GFP_HIGHUSER_MOVABLE, 0);
> > +   return __alloc_pages_node(nid,
> > +   GFP_HIGHUSER_MOVABLE | __GFP_RETRY_MAYFAIL, 0);
> > }
> >  }
> 
> new_page() is now
> 
> static struct page *new_page(struct page *p, unsigned long private, int **x)
> {
>   int nid = page_to_nid(p);
> 
>   return new_page_nodemask(p, nid, _states[N_MEMORY]);
> }
> 
> and new_page_nodemask() uses __GFP_RETRY_MAYFAIL so I simply dropped
> the above hunk.

Ohh, right. This is
http://lkml.kernel.org/r/20170622193034.28972-4-mho...@kernel.org. I've
just didn't realize it was not in mmotm yet. So yes the hunk can be
dropped, new_page_nodemask does what we need.
 
Sorry about that
-- 
Michal Hocko
SUSE Labs


Re: [PATCH 6/6] mm, migration: do not trigger OOM killer when migrating memory

2017-06-25 Thread Michal Hocko
On Fri 23-06-17 13:43:05, Andrew Morton wrote:
> On Fri, 23 Jun 2017 10:53:45 +0200 Michal Hocko  wrote:
> 
> > From: Michal Hocko 
> > 
> > Page migration (for memory hotplug, soft_offline_page or mbind) needs
> > to allocate a new memory. This can trigger an oom killer if the target
> > memory is depleated. Although quite unlikely, still possible, especially
> > for the memory hotplug (offlining of memoery). Up to now we didn't
> > really have reasonable means to back off. __GFP_NORETRY can fail just
> > too easily and __GFP_THISNODE sticks to a single node and that is not
> > suitable for all callers.
> > 
> > But now that we have __GFP_RETRY_MAYFAIL we should use it.  It is
> > preferable to fail the migration than disrupt the system by killing some
> > processes.
> 
> I'm not sure which tree this is against...

next-20170623

> 
> > --- a/mm/memory-failure.c
> > +++ b/mm/memory-failure.c
> > @@ -1492,7 +1492,8 @@ static struct page *new_page(struct page *p, unsigned 
> > long private, int **x)
> >  
> > return alloc_huge_page_node(hstate, nid);
> > } else {
> > -   return __alloc_pages_node(nid, GFP_HIGHUSER_MOVABLE, 0);
> > +   return __alloc_pages_node(nid,
> > +   GFP_HIGHUSER_MOVABLE | __GFP_RETRY_MAYFAIL, 0);
> > }
> >  }
> 
> new_page() is now
> 
> static struct page *new_page(struct page *p, unsigned long private, int **x)
> {
>   int nid = page_to_nid(p);
> 
>   return new_page_nodemask(p, nid, _states[N_MEMORY]);
> }
> 
> and new_page_nodemask() uses __GFP_RETRY_MAYFAIL so I simply dropped
> the above hunk.

Ohh, right. This is
http://lkml.kernel.org/r/20170622193034.28972-4-mho...@kernel.org. I've
just didn't realize it was not in mmotm yet. So yes the hunk can be
dropped, new_page_nodemask does what we need.
 
Sorry about that
-- 
Michal Hocko
SUSE Labs


Re: [PATCH V4] acpi: acpica: fix acpi parse and parseext cache leaks

2017-06-25 Thread Seunghun Han
Hello, Andy.

Thank you for your reply.

Patch V4 is the last patch which is applied all changes from original code.
Due to maintainer's advice, Patch V1, V2, V3 have reverted and I made
the latest patch, Patch V4.
(the review is here, https://github.com/acpica/acpica/pull/278)

Therefore, it seems that incremental patch is not needed.

If you have any request, please let me know.

Best regards.

ps) I am sending email again after removing HTML part.

2017-06-26 7:12 GMT+09:00 Seunghun Han :
> Hello, Andy.
>
> Thank you for your reply.
>
> Patch V4 is the last patch which is applied all changes from original code.
> Due to reviewer's advice, Patch V1, V2, V3 has reverted and I made the
> latest patch, Patch V4.
> Therefore, it seems that incremental patch is not needed.
>
> If you have any requests, please let me know.
>
> Best regards.
>
>
> 2017년 6월 26일 (월) 오전 1:13, Andy Shevchenko 님이 작성:
>>
>> On Fri, Jun 23, 2017 at 12:36 PM, Seunghun Han  wrote:
>> > I'm Seunghun Han, and I work for National Security Research Institute of
>> > South Korea.
>>
>>
>> > -   /* Clean up */
>> > -   do {
>> > -   if (op) {
>> > -   status2 =
>> > -
>> > acpi_ps_complete_this_op
>> > -   (walk_state,
>> > op);
>> > -   if (ACPI_FAILURE
>> > -   (status2)) {
>> > -
>> > return_ACPI_STATUS
>> > -
>> > (status2);
>> > -   }
>> > -   }
>> > -
>> > -   acpi_ps_pop_scope(&
>> > -
>> > (walk_state->
>> > -
>> > parser_state),
>> > - ,
>> > -
>> > _state->
>> > -
>> > arg_types,
>> > -
>> > _state->
>> > -
>> > arg_count);
>> > -
>> > -   } while (op);
>>
>> I didn't get, do you send an incremental patch as a new version?!
>>
>> --
>> With Best Regards,
>> Andy Shevchenko


Re: [PATCH V4] acpi: acpica: fix acpi parse and parseext cache leaks

2017-06-25 Thread Seunghun Han
Hello, Andy.

Thank you for your reply.

Patch V4 is the last patch which is applied all changes from original code.
Due to maintainer's advice, Patch V1, V2, V3 have reverted and I made
the latest patch, Patch V4.
(the review is here, https://github.com/acpica/acpica/pull/278)

Therefore, it seems that incremental patch is not needed.

If you have any request, please let me know.

Best regards.

ps) I am sending email again after removing HTML part.

2017-06-26 7:12 GMT+09:00 Seunghun Han :
> Hello, Andy.
>
> Thank you for your reply.
>
> Patch V4 is the last patch which is applied all changes from original code.
> Due to reviewer's advice, Patch V1, V2, V3 has reverted and I made the
> latest patch, Patch V4.
> Therefore, it seems that incremental patch is not needed.
>
> If you have any requests, please let me know.
>
> Best regards.
>
>
> 2017년 6월 26일 (월) 오전 1:13, Andy Shevchenko 님이 작성:
>>
>> On Fri, Jun 23, 2017 at 12:36 PM, Seunghun Han  wrote:
>> > I'm Seunghun Han, and I work for National Security Research Institute of
>> > South Korea.
>>
>>
>> > -   /* Clean up */
>> > -   do {
>> > -   if (op) {
>> > -   status2 =
>> > -
>> > acpi_ps_complete_this_op
>> > -   (walk_state,
>> > op);
>> > -   if (ACPI_FAILURE
>> > -   (status2)) {
>> > -
>> > return_ACPI_STATUS
>> > -
>> > (status2);
>> > -   }
>> > -   }
>> > -
>> > -   acpi_ps_pop_scope(&
>> > -
>> > (walk_state->
>> > -
>> > parser_state),
>> > - ,
>> > -
>> > _state->
>> > -
>> > arg_types,
>> > -
>> > _state->
>> > -
>> > arg_count);
>> > -
>> > -   } while (op);
>>
>> I didn't get, do you send an incremental patch as a new version?!
>>
>> --
>> With Best Regards,
>> Andy Shevchenko


[GIT PULL] one last s390 patch for 4.12-rc8/4.12

2017-06-25 Thread Martin Schwidefsky
Hi Linus,

please pull from the 'for-linus' branch of

git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git for-linus

to receive the following updates:

Revert the re-IPL semantics back to the v4.7 state. It turned out that
the memory layout may change due to memory hotplug if load-normal is used.

Heiko Carstens (1):
  s390/ipl: revert Load Normal semantics for LPAR CCW-type re-IPL

 arch/s390/kernel/ipl.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index e545ffe..8e622bb5 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -564,8 +564,6 @@ static struct kset *ipl_kset;
 
 static void __ipl_run(void *unused)
 {
-   if (MACHINE_IS_LPAR && ipl_info.type == IPL_TYPE_CCW)
-   diag308(DIAG308_LOAD_NORMAL_DUMP, NULL);
diag308(DIAG308_LOAD_CLEAR, NULL);
if (MACHINE_IS_VM)
__cpcmd("IPL", NULL, 0, NULL);
@@ -1088,10 +1086,7 @@ static void __reipl_run(void *unused)
break;
case REIPL_METHOD_CCW_DIAG:
diag308(DIAG308_SET, reipl_block_ccw);
-   if (MACHINE_IS_LPAR)
-   diag308(DIAG308_LOAD_NORMAL_DUMP, NULL);
-   else
-   diag308(DIAG308_LOAD_CLEAR, NULL);
+   diag308(DIAG308_LOAD_CLEAR, NULL);
break;
case REIPL_METHOD_FCP_RW_DIAG:
diag308(DIAG308_SET, reipl_block_fcp);



[GIT PULL] one last s390 patch for 4.12-rc8/4.12

2017-06-25 Thread Martin Schwidefsky
Hi Linus,

please pull from the 'for-linus' branch of

git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git for-linus

to receive the following updates:

Revert the re-IPL semantics back to the v4.7 state. It turned out that
the memory layout may change due to memory hotplug if load-normal is used.

Heiko Carstens (1):
  s390/ipl: revert Load Normal semantics for LPAR CCW-type re-IPL

 arch/s390/kernel/ipl.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
index e545ffe..8e622bb5 100644
--- a/arch/s390/kernel/ipl.c
+++ b/arch/s390/kernel/ipl.c
@@ -564,8 +564,6 @@ static struct kset *ipl_kset;
 
 static void __ipl_run(void *unused)
 {
-   if (MACHINE_IS_LPAR && ipl_info.type == IPL_TYPE_CCW)
-   diag308(DIAG308_LOAD_NORMAL_DUMP, NULL);
diag308(DIAG308_LOAD_CLEAR, NULL);
if (MACHINE_IS_VM)
__cpcmd("IPL", NULL, 0, NULL);
@@ -1088,10 +1086,7 @@ static void __reipl_run(void *unused)
break;
case REIPL_METHOD_CCW_DIAG:
diag308(DIAG308_SET, reipl_block_ccw);
-   if (MACHINE_IS_LPAR)
-   diag308(DIAG308_LOAD_NORMAL_DUMP, NULL);
-   else
-   diag308(DIAG308_LOAD_CLEAR, NULL);
+   diag308(DIAG308_LOAD_CLEAR, NULL);
break;
case REIPL_METHOD_FCP_RW_DIAG:
diag308(DIAG308_SET, reipl_block_fcp);



Re: [PATCH 2/3] iio: adc: mt7622: add support for suspend/resume.

2017-06-25 Thread Jonathan Cameron


On 26 June 2017 04:54:52 CEST, zhiyong tao  wrote:
>On Sat, 2017-06-24 at 21:00 +0100, Jonathan Cameron wrote:
>> On Thu, 22 Jun 2017 13:44:33 +0800
>> Zhiyong Tao  wrote:
>> 
>> > This patch supports auxadc suspend/resume flow.
>> > Disable auxadc clk and power in suspend function.
>> > Enable axuadc clk and power in resume function.
>> > 
>> > Signed-off-by: Zhiyong Tao 
>> Worth handling the cases where power management is not configured
>into the
>> kernel properly.
>> 
>> So a few minor suggestions.  Otherwise looks good to me.
>> > ---
>> >  drivers/iio/adc/mt6577_auxadc.c |   37
>+
>> >  1 file changed, 37 insertions(+)
>> > 
>> > diff --git a/drivers/iio/adc/mt6577_auxadc.c
>b/drivers/iio/adc/mt6577_auxadc.c
>> > index 2d104c8..2dd7c74 100644
>> > --- a/drivers/iio/adc/mt6577_auxadc.c
>> > +++ b/drivers/iio/adc/mt6577_auxadc.c
>> > @@ -184,6 +184,37 @@ static int mt6577_auxadc_read_raw(struct
>iio_dev *indio_dev,
>> >.read_raw = _auxadc_read_raw,
>> >  };
>> >  
>> > +static int mt6577_auxadc_resume(struct device *dev)
>> > +{
>> > +  struct iio_dev *indio_dev = dev_get_drvdata(dev);
>> > +  struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
>> > +  int ret;
>> > +
>> > +  ret = clk_prepare_enable(adc_dev->adc_clk);
>> > +  if (ret) {
>> > +  pr_err("failed to enable auxadc clock\n");
>> > +  return ret;
>> > +  }
>> > +
>> > +  mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
>> > +MT6577_AUXADC_PDN_EN, 0);
>> > +  mdelay(MT6577_AUXADC_POWER_READY_MS);
>> > +
>> > +  return 0;
>> > +}
>> > +
>> > +static int mt6577_auxadc_suspend(struct device *dev)
>> Mark these __maybe_unused for the CONFIG_PM but not CONFIG_PM_SLEEP
>case.
Preferred to mark __maybe_unused and use the macro mentioned below.
>
>==> ok, We will add CONFIG_PM_SLEEP for the suspend/resume case in v2.
>thanks!
>
>> > +{
>> > +  struct iio_dev *indio_dev = dev_get_drvdata(dev);
>> > +  struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
>> > +
>> > +  mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
>> > +0, MT6577_AUXADC_PDN_EN);
>> > +  clk_disable_unprepare(adc_dev->adc_clk);
>> > +
>> > +  return 0;
>> > +}
>> > +
>> >  static int mt6577_auxadc_probe(struct platform_device *pdev)
>> >  {
>> >struct mt6577_auxadc_device *adc_dev;
>> > @@ -269,6 +300,11 @@ static int mt6577_auxadc_remove(struct
>platform_device *pdev)
>> >return 0;
>> >  }
>> >  
>> > +static const struct dev_pm_ops mt6577_auxadc_pm_ops = {
>> > +  .suspend = mt6577_auxadc_suspend,
>> > +  .resume = mt6577_auxadc_resume,
>> > +};
>> > +
>> Use the SIMPLE_SYSTEM_PM_OPS macro to make these assignments
>magically go away
>> if PM_CONFIG_SLEEP is not defined.
>
>==> ok, We will use SIMPLE_DEV_PM_OPS macro to change it in v2. Thanks.
>>>  static const struct of_device_id mt6577_auxadc_of_match[] = {
>> >{ .compatible = "mediatek,mt2701-auxadc", },
>> >{ .compatible = "mediatek,mt8173-auxadc", },
>> > @@ -280,6 +316,7 @@ static int mt6577_auxadc_remove(struct
>platform_device *pdev)
>> >.driver = {
>> >.name   = "mt6577-auxadc",
>> >.of_match_table = mt6577_auxadc_of_match,
>> > +  .pm = _auxadc_pm_ops,
>> >},
>> >.probe  = mt6577_auxadc_probe,
>> >.remove = mt6577_auxadc_remove,
>> 
>
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>the body of a message to majord...@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


Re: [PATCH 2/3] iio: adc: mt7622: add support for suspend/resume.

2017-06-25 Thread Jonathan Cameron


On 26 June 2017 04:54:52 CEST, zhiyong tao  wrote:
>On Sat, 2017-06-24 at 21:00 +0100, Jonathan Cameron wrote:
>> On Thu, 22 Jun 2017 13:44:33 +0800
>> Zhiyong Tao  wrote:
>> 
>> > This patch supports auxadc suspend/resume flow.
>> > Disable auxadc clk and power in suspend function.
>> > Enable axuadc clk and power in resume function.
>> > 
>> > Signed-off-by: Zhiyong Tao 
>> Worth handling the cases where power management is not configured
>into the
>> kernel properly.
>> 
>> So a few minor suggestions.  Otherwise looks good to me.
>> > ---
>> >  drivers/iio/adc/mt6577_auxadc.c |   37
>+
>> >  1 file changed, 37 insertions(+)
>> > 
>> > diff --git a/drivers/iio/adc/mt6577_auxadc.c
>b/drivers/iio/adc/mt6577_auxadc.c
>> > index 2d104c8..2dd7c74 100644
>> > --- a/drivers/iio/adc/mt6577_auxadc.c
>> > +++ b/drivers/iio/adc/mt6577_auxadc.c
>> > @@ -184,6 +184,37 @@ static int mt6577_auxadc_read_raw(struct
>iio_dev *indio_dev,
>> >.read_raw = _auxadc_read_raw,
>> >  };
>> >  
>> > +static int mt6577_auxadc_resume(struct device *dev)
>> > +{
>> > +  struct iio_dev *indio_dev = dev_get_drvdata(dev);
>> > +  struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
>> > +  int ret;
>> > +
>> > +  ret = clk_prepare_enable(adc_dev->adc_clk);
>> > +  if (ret) {
>> > +  pr_err("failed to enable auxadc clock\n");
>> > +  return ret;
>> > +  }
>> > +
>> > +  mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
>> > +MT6577_AUXADC_PDN_EN, 0);
>> > +  mdelay(MT6577_AUXADC_POWER_READY_MS);
>> > +
>> > +  return 0;
>> > +}
>> > +
>> > +static int mt6577_auxadc_suspend(struct device *dev)
>> Mark these __maybe_unused for the CONFIG_PM but not CONFIG_PM_SLEEP
>case.
Preferred to mark __maybe_unused and use the macro mentioned below.
>
>==> ok, We will add CONFIG_PM_SLEEP for the suspend/resume case in v2.
>thanks!
>
>> > +{
>> > +  struct iio_dev *indio_dev = dev_get_drvdata(dev);
>> > +  struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
>> > +
>> > +  mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
>> > +0, MT6577_AUXADC_PDN_EN);
>> > +  clk_disable_unprepare(adc_dev->adc_clk);
>> > +
>> > +  return 0;
>> > +}
>> > +
>> >  static int mt6577_auxadc_probe(struct platform_device *pdev)
>> >  {
>> >struct mt6577_auxadc_device *adc_dev;
>> > @@ -269,6 +300,11 @@ static int mt6577_auxadc_remove(struct
>platform_device *pdev)
>> >return 0;
>> >  }
>> >  
>> > +static const struct dev_pm_ops mt6577_auxadc_pm_ops = {
>> > +  .suspend = mt6577_auxadc_suspend,
>> > +  .resume = mt6577_auxadc_resume,
>> > +};
>> > +
>> Use the SIMPLE_SYSTEM_PM_OPS macro to make these assignments
>magically go away
>> if PM_CONFIG_SLEEP is not defined.
>
>==> ok, We will use SIMPLE_DEV_PM_OPS macro to change it in v2. Thanks.
>>>  static const struct of_device_id mt6577_auxadc_of_match[] = {
>> >{ .compatible = "mediatek,mt2701-auxadc", },
>> >{ .compatible = "mediatek,mt8173-auxadc", },
>> > @@ -280,6 +316,7 @@ static int mt6577_auxadc_remove(struct
>platform_device *pdev)
>> >.driver = {
>> >.name   = "mt6577-auxadc",
>> >.of_match_table = mt6577_auxadc_of_match,
>> > +  .pm = _auxadc_pm_ops,
>> >},
>> >.probe  = mt6577_auxadc_probe,
>> >.remove = mt6577_auxadc_remove,
>> 
>
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>the body of a message to majord...@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


Re: [PATCH] staging: sm750fb: always take the lock

2017-06-25 Thread Greg Kroah-Hartman
On Sun, Jun 25, 2017 at 11:39:20PM +0200, AbdAllah-MEZITI wrote:
> Signed-off-by: AbdAllah MEZITI 

I can't take patches without any changelog text, sorry.

greg k-h


Re: [PATCH] staging: sm750fb: always take the lock

2017-06-25 Thread Greg Kroah-Hartman
On Sun, Jun 25, 2017 at 11:39:20PM +0200, AbdAllah-MEZITI wrote:
> Signed-off-by: AbdAllah MEZITI 

I can't take patches without any changelog text, sorry.

greg k-h


[PATCH] fs: jbd2: transaction: Add kernel-doc parameter descriptions

2017-06-25 Thread sayli karnik
Add function parameters in kernel-doc comments to fix warnings in the
Sphinx build:
transaction.c:511: warning: No description found for parameter 'type'
transaction.c:511: warning: No description found for parameter 'line_no'

Signed-off-by: sayli karnik 
---
 fs/jbd2/transaction.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 8b08044..bca5f9f 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -497,6 +497,8 @@ EXPORT_SYMBOL(jbd2_journal_free_reserved);
 /**
  * int jbd2_journal_start_reserved(handle_t *handle) - start reserved handle
  * @handle: handle to start
+ * @type: type of handle
+ * @line_no: line number of handle
  *
  * Start handle that has been previously reserved with jbd2_journal_reserve().
  * This attaches @handle to the running transaction (or creates one if there's
-- 
2.7.4



[PATCH] fs: jbd2: transaction: Add kernel-doc parameter descriptions

2017-06-25 Thread sayli karnik
Add function parameters in kernel-doc comments to fix warnings in the
Sphinx build:
transaction.c:511: warning: No description found for parameter 'type'
transaction.c:511: warning: No description found for parameter 'line_no'

Signed-off-by: sayli karnik 
---
 fs/jbd2/transaction.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 8b08044..bca5f9f 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -497,6 +497,8 @@ EXPORT_SYMBOL(jbd2_journal_free_reserved);
 /**
  * int jbd2_journal_start_reserved(handle_t *handle) - start reserved handle
  * @handle: handle to start
+ * @type: type of handle
+ * @line_no: line number of handle
  *
  * Start handle that has been previously reserved with jbd2_journal_reserve().
  * This attaches @handle to the running transaction (or creates one if there's
-- 
2.7.4



Re: [RFC v3 02/23] powerpc: introduce set_hidx_slot helper

2017-06-25 Thread Benjamin Herrenschmidt
On Mon, 2017-06-26 at 09:03 +1000, Balbir Singh wrote:
> On Wed, 2017-06-21 at 18:39 -0700, Ram Pai wrote:
> > Introduce set_hidx_slot() which sets the (H_PAGE_F_SECOND|H_PAGE_F_GIX)
> > bits at  the  appropriate  location  in  the  PTE  of  4K  PTE.  In the
> > case of 64K PTE, it sets the bits in the second part of the PTE. Though
> > the implementation for the former just needs the slot parameter, it does
> > take some additional parameters to keep the prototype consistent.
> > 
> > This function will come in handy as we  work  towards  re-arranging the
> > bits in the later patches.

The name somewhat sucks. Something like pte_set_hash_slot() or
something like that would be much more meaningful.

> > Signed-off-by: Ram Pai 
> > ---
> >  arch/powerpc/include/asm/book3s/64/hash-4k.h  |  7 +++
> >  arch/powerpc/include/asm/book3s/64/hash-64k.h | 16 
> >  2 files changed, 23 insertions(+)
> > 
> > diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h 
> > b/arch/powerpc/include/asm/book3s/64/hash-4k.h
> > index 9c2c8f1..cef644c 100644
> > --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
> > +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
> > @@ -55,6 +55,13 @@ static inline int hash__hugepd_ok(hugepd_t hpd)
> >  }
> >  #endif
> >  
> > +static inline unsigned long set_hidx_slot(pte_t *ptep, real_pte_t rpte,
> > +   unsigned int subpg_index, unsigned long slot)
> > +{
> > +   return (slot << H_PAGE_F_GIX_SHIFT) &
> > +   (H_PAGE_F_SECOND | H_PAGE_F_GIX);
> > +}
> > +
> 
> A comment on top would help explain that 4k and 64k are different, 64k
> is a new layout.
> 
> >  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> >  
> >  static inline char *get_hpte_slot_array(pmd_t *pmdp)
> > diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h 
> > b/arch/powerpc/include/asm/book3s/64/hash-64k.h
> > index 3f49941..4bac70a 100644
> > --- a/arch/powerpc/include/asm/book3s/64/hash-64k.h
> > +++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h
> > @@ -75,6 +75,22 @@ static inline unsigned long __rpte_to_hidx(real_pte_t 
> > rpte, unsigned long index)
> > return (pte_val(rpte.pte) >> H_PAGE_F_GIX_SHIFT) & 0xf;
> >  }
> >  
> > +static inline unsigned long set_hidx_slot(pte_t *ptep, real_pte_t rpte,
> > +   unsigned int subpg_index, unsigned long slot)
> > +{
> > +   unsigned long *hidxp = (unsigned long *)(ptep + PTRS_PER_PTE);
> > +
> > +   rpte.hidx &= ~(0xfUL << (subpg_index << 2));
> > +   *hidxp = rpte.hidx  | (slot << (subpg_index << 2));
> > +   /*
> > +* Avoid race with __real_pte()
> > +* hidx must be committed to memory before committing
> > +* the pte.
> > +*/
> > +   smp_wmb();
> 
> Whats the other paired barrier, is it in set_pte()?
> 
> > +   return 0x0UL;
> > +}
> 
> We return 0 here and slot information for 4k pages, it is not that
> clear
> 
> Balbir Singh.


Re: [RFC v3 02/23] powerpc: introduce set_hidx_slot helper

2017-06-25 Thread Benjamin Herrenschmidt
On Mon, 2017-06-26 at 09:03 +1000, Balbir Singh wrote:
> On Wed, 2017-06-21 at 18:39 -0700, Ram Pai wrote:
> > Introduce set_hidx_slot() which sets the (H_PAGE_F_SECOND|H_PAGE_F_GIX)
> > bits at  the  appropriate  location  in  the  PTE  of  4K  PTE.  In the
> > case of 64K PTE, it sets the bits in the second part of the PTE. Though
> > the implementation for the former just needs the slot parameter, it does
> > take some additional parameters to keep the prototype consistent.
> > 
> > This function will come in handy as we  work  towards  re-arranging the
> > bits in the later patches.

The name somewhat sucks. Something like pte_set_hash_slot() or
something like that would be much more meaningful.

> > Signed-off-by: Ram Pai 
> > ---
> >  arch/powerpc/include/asm/book3s/64/hash-4k.h  |  7 +++
> >  arch/powerpc/include/asm/book3s/64/hash-64k.h | 16 
> >  2 files changed, 23 insertions(+)
> > 
> > diff --git a/arch/powerpc/include/asm/book3s/64/hash-4k.h 
> > b/arch/powerpc/include/asm/book3s/64/hash-4k.h
> > index 9c2c8f1..cef644c 100644
> > --- a/arch/powerpc/include/asm/book3s/64/hash-4k.h
> > +++ b/arch/powerpc/include/asm/book3s/64/hash-4k.h
> > @@ -55,6 +55,13 @@ static inline int hash__hugepd_ok(hugepd_t hpd)
> >  }
> >  #endif
> >  
> > +static inline unsigned long set_hidx_slot(pte_t *ptep, real_pte_t rpte,
> > +   unsigned int subpg_index, unsigned long slot)
> > +{
> > +   return (slot << H_PAGE_F_GIX_SHIFT) &
> > +   (H_PAGE_F_SECOND | H_PAGE_F_GIX);
> > +}
> > +
> 
> A comment on top would help explain that 4k and 64k are different, 64k
> is a new layout.
> 
> >  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> >  
> >  static inline char *get_hpte_slot_array(pmd_t *pmdp)
> > diff --git a/arch/powerpc/include/asm/book3s/64/hash-64k.h 
> > b/arch/powerpc/include/asm/book3s/64/hash-64k.h
> > index 3f49941..4bac70a 100644
> > --- a/arch/powerpc/include/asm/book3s/64/hash-64k.h
> > +++ b/arch/powerpc/include/asm/book3s/64/hash-64k.h
> > @@ -75,6 +75,22 @@ static inline unsigned long __rpte_to_hidx(real_pte_t 
> > rpte, unsigned long index)
> > return (pte_val(rpte.pte) >> H_PAGE_F_GIX_SHIFT) & 0xf;
> >  }
> >  
> > +static inline unsigned long set_hidx_slot(pte_t *ptep, real_pte_t rpte,
> > +   unsigned int subpg_index, unsigned long slot)
> > +{
> > +   unsigned long *hidxp = (unsigned long *)(ptep + PTRS_PER_PTE);
> > +
> > +   rpte.hidx &= ~(0xfUL << (subpg_index << 2));
> > +   *hidxp = rpte.hidx  | (slot << (subpg_index << 2));
> > +   /*
> > +* Avoid race with __real_pte()
> > +* hidx must be committed to memory before committing
> > +* the pte.
> > +*/
> > +   smp_wmb();
> 
> Whats the other paired barrier, is it in set_pte()?
> 
> > +   return 0x0UL;
> > +}
> 
> We return 0 here and slot information for 4k pages, it is not that
> clear
> 
> Balbir Singh.


Re: [PATCH v3 0/7] Isolate time_t data types for clock/timer syscalls

2017-06-25 Thread Al Viro
On Mon, Jun 26, 2017 at 03:35:25AM +0100, Al Viro wrote:
> On Sat, Jun 24, 2017 at 11:45:01AM -0700, Deepa Dinamani wrote:
> > The series aims at isolating data conversions of time_t based structures:
> > struct timespec and struct itimerspec at user space boundaries.
> > This helps to later change the underlying types to handle y2038 changes
> > to these.
> 
> Nice...  A few questions:
> 
> * what about setitimer(2)?  Right now that's the only remaining user of
> get_compat_itimerval(); similar for getitimer(2) and put_compat_itimerval().
> 
> * you have two callers of get_compat_itimerspec64(); one is followed by
> itimerspec64_valid(), another - by its open-coded analogue.  The same
> goes for get_itimerspec64(); wouldn't it be better to have both check
> the validity immediately and simply fail with -EINVAL?  Matter of taste,
> but...
> 
> * should __sys_recvmmsg() switch to timespec64?

While we are at it - do we need any locking for accesses of ->sk_stamp?
* ax25, ipx, netrom, qrtr: sock_get_timestamp() done under lock_sock().
* bluetooth: without (and case next door in the same switch is
grabbing/dropping lock_sock, so it's not held by caller either)
* ipv4, ipv6, packet, can: without
* irda: without, checks for NULL sock->sk for some reason (other
cases do not, so if we ever get there with NULL ->sk, we are fucked).
Incidentally, TIOCINQ in there looks fishy - what's to prevent us from
losing CPU just as skb_peek() returns, with skb getting freed by the
time we regain it and go looking at skb->len?  Don't we need at least
to hold ->lock on queue we are peeking into?
* rose: without, and TIOCINQ there looks similar to irda one
* x25: without, with the same odd check for NULL sock->sk
* atm: without, apparently.  Same unprotected skb_peek() on
TIOCINQ...
* atalk: ditto.



Re: [PATCH v3 0/7] Isolate time_t data types for clock/timer syscalls

2017-06-25 Thread Al Viro
On Mon, Jun 26, 2017 at 03:35:25AM +0100, Al Viro wrote:
> On Sat, Jun 24, 2017 at 11:45:01AM -0700, Deepa Dinamani wrote:
> > The series aims at isolating data conversions of time_t based structures:
> > struct timespec and struct itimerspec at user space boundaries.
> > This helps to later change the underlying types to handle y2038 changes
> > to these.
> 
> Nice...  A few questions:
> 
> * what about setitimer(2)?  Right now that's the only remaining user of
> get_compat_itimerval(); similar for getitimer(2) and put_compat_itimerval().
> 
> * you have two callers of get_compat_itimerspec64(); one is followed by
> itimerspec64_valid(), another - by its open-coded analogue.  The same
> goes for get_itimerspec64(); wouldn't it be better to have both check
> the validity immediately and simply fail with -EINVAL?  Matter of taste,
> but...
> 
> * should __sys_recvmmsg() switch to timespec64?

While we are at it - do we need any locking for accesses of ->sk_stamp?
* ax25, ipx, netrom, qrtr: sock_get_timestamp() done under lock_sock().
* bluetooth: without (and case next door in the same switch is
grabbing/dropping lock_sock, so it's not held by caller either)
* ipv4, ipv6, packet, can: without
* irda: without, checks for NULL sock->sk for some reason (other
cases do not, so if we ever get there with NULL ->sk, we are fucked).
Incidentally, TIOCINQ in there looks fishy - what's to prevent us from
losing CPU just as skb_peek() returns, with skb getting freed by the
time we regain it and go looking at skb->len?  Don't we need at least
to hold ->lock on queue we are peeking into?
* rose: without, and TIOCINQ there looks similar to irda one
* x25: without, with the same odd check for NULL sock->sk
* atm: without, apparently.  Same unprotected skb_peek() on
TIOCINQ...
* atalk: ditto.



Re: [PATCH net-next v2 5/5] net: add netlink_ext_ack argument to rtnl_link_ops.slave_validate

2017-06-25 Thread David Ahern
On 6/25/17 10:05 PM, David Ahern wrote:
> On 6/25/17 3:56 PM, Matthias Schiffer wrote:
>> Add support for extended error reporting.
>>
>> Signed-off-by: Matthias Schiffer 
>> ---
> 
> Acked-by: David Ahern 
> 

And slave_validate is not used; it should be removed.


Re: [PATCH net-next v2 5/5] net: add netlink_ext_ack argument to rtnl_link_ops.slave_validate

2017-06-25 Thread David Ahern
On 6/25/17 10:05 PM, David Ahern wrote:
> On 6/25/17 3:56 PM, Matthias Schiffer wrote:
>> Add support for extended error reporting.
>>
>> Signed-off-by: Matthias Schiffer 
>> ---
> 
> Acked-by: David Ahern 
> 

And slave_validate is not used; it should be removed.


Re: [PATCH net-next v2 4/5] net: add netlink_ext_ack argument to rtnl_link_ops.slave_changelink

2017-06-25 Thread David Ahern
On 6/25/17 10:04 PM, David Ahern wrote:
> On 6/25/17 3:56 PM, Matthias Schiffer wrote:
>> Add support for extended error reporting.
>>
>> Signed-off-by: Matthias Schiffer 
>> ---
> 
> 
> Acked-by: David Ahern 
> 

Actually, you are missing the chagne to br_port_slave_changelink.


Re: [PATCH net-next v2 4/5] net: add netlink_ext_ack argument to rtnl_link_ops.slave_changelink

2017-06-25 Thread David Ahern
On 6/25/17 10:04 PM, David Ahern wrote:
> On 6/25/17 3:56 PM, Matthias Schiffer wrote:
>> Add support for extended error reporting.
>>
>> Signed-off-by: Matthias Schiffer 
>> ---
> 
> 
> Acked-by: David Ahern 
> 

Actually, you are missing the chagne to br_port_slave_changelink.


Re: [PATCH net-next v2 5/5] net: add netlink_ext_ack argument to rtnl_link_ops.slave_validate

2017-06-25 Thread David Ahern
On 6/25/17 3:56 PM, Matthias Schiffer wrote:
> Add support for extended error reporting.
> 
> Signed-off-by: Matthias Schiffer 
> ---

Acked-by: David Ahern 


Re: [PATCH net-next v2 5/5] net: add netlink_ext_ack argument to rtnl_link_ops.slave_validate

2017-06-25 Thread David Ahern
On 6/25/17 3:56 PM, Matthias Schiffer wrote:
> Add support for extended error reporting.
> 
> Signed-off-by: Matthias Schiffer 
> ---

Acked-by: David Ahern 


Re: [PATCH net-next v2 4/5] net: add netlink_ext_ack argument to rtnl_link_ops.slave_changelink

2017-06-25 Thread David Ahern
On 6/25/17 3:56 PM, Matthias Schiffer wrote:
> Add support for extended error reporting.
> 
> Signed-off-by: Matthias Schiffer 
> ---


Acked-by: David Ahern 


Re: [PATCH net-next v2 3/5] net: add netlink_ext_ack argument to rtnl_link_ops.validate

2017-06-25 Thread David Ahern
On 6/25/17 3:56 PM, Matthias Schiffer wrote:
> Add support for extended error reporting.
> 
> Signed-off-by: Matthias Schiffer 
> ---

Acked-by: David Ahern 


Re: [PATCH net-next v2 4/5] net: add netlink_ext_ack argument to rtnl_link_ops.slave_changelink

2017-06-25 Thread David Ahern
On 6/25/17 3:56 PM, Matthias Schiffer wrote:
> Add support for extended error reporting.
> 
> Signed-off-by: Matthias Schiffer 
> ---


Acked-by: David Ahern 


Re: [PATCH net-next v2 3/5] net: add netlink_ext_ack argument to rtnl_link_ops.validate

2017-06-25 Thread David Ahern
On 6/25/17 3:56 PM, Matthias Schiffer wrote:
> Add support for extended error reporting.
> 
> Signed-off-by: Matthias Schiffer 
> ---

Acked-by: David Ahern 


Re: [PATCH net-next v2 2/5] net: add netlink_ext_ack argument to rtnl_link_ops.changelink

2017-06-25 Thread David Ahern
On 6/25/17 3:56 PM, Matthias Schiffer wrote:
> Add support for extended error reporting.
> 
> Signed-off-by: Matthias Schiffer 

Acked-by: David Ahern 


Re: [PATCH net-next v2 2/5] net: add netlink_ext_ack argument to rtnl_link_ops.changelink

2017-06-25 Thread David Ahern
On 6/25/17 3:56 PM, Matthias Schiffer wrote:
> Add support for extended error reporting.
> 
> Signed-off-by: Matthias Schiffer 

Acked-by: David Ahern 


Re: [PATCH net-next v2 1/5] net: add netlink_ext_ack argument to rtnl_link_ops.newlink

2017-06-25 Thread David Ahern
On 6/25/17 3:55 PM, Matthias Schiffer wrote:
> Add support for extended error reporting.
> 
> Signed-off-by: Matthias Schiffer 
> ---

Acked-by: David Ahern 


Re: [PATCH net-next v2 1/5] net: add netlink_ext_ack argument to rtnl_link_ops.newlink

2017-06-25 Thread David Ahern
On 6/25/17 3:55 PM, Matthias Schiffer wrote:
> Add support for extended error reporting.
> 
> Signed-off-by: Matthias Schiffer 
> ---

Acked-by: David Ahern 


[PATCH] mm/memory_hotplug: just build zonelist for new added node

2017-06-25 Thread Wei Yang
In commit (9adb62a5df9c0fbef7) "mm/hotplug: correctly setup fallback
zonelists when creating new pgdat" tries to build the correct zonelist for
a new added node, while it is not necessary to rebuild it for already exist
nodes.

In build_zonelists(), it will iterate on nodes with memory. For a new added
node, it will have memory until node_states_set_node() is called in
online_pages().

This patch will avoid to rebuild the zonelists for already exist nodes.

Signed-off-by: Wei Yang 
---
 mm/page_alloc.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 560eafe8234d..fc8181b44fd8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5200,15 +5200,17 @@ static int __build_all_zonelists(void *data)
memset(node_load, 0, sizeof(node_load));
 #endif
 
-   if (self && !node_online(self->node_id)) {
+   /* This node is hotadded and no memory preset yet.
+* So just build zonelists is fine, no need to touch other nodes.
+*/
+   if (self && !node_online(self->node_id))
build_zonelists(self);
-   }
-
-   for_each_online_node(nid) {
-   pg_data_t *pgdat = NODE_DATA(nid);
+   else
+   for_each_online_node(nid) {
+   pg_data_t *pgdat = NODE_DATA(nid);
 
-   build_zonelists(pgdat);
-   }
+   build_zonelists(pgdat);
+   }
 
/*
 * Initialize the boot_pagesets that are going to be used
-- 
2.11.0



[PATCH] mm/memory_hotplug: just build zonelist for new added node

2017-06-25 Thread Wei Yang
In commit (9adb62a5df9c0fbef7) "mm/hotplug: correctly setup fallback
zonelists when creating new pgdat" tries to build the correct zonelist for
a new added node, while it is not necessary to rebuild it for already exist
nodes.

In build_zonelists(), it will iterate on nodes with memory. For a new added
node, it will have memory until node_states_set_node() is called in
online_pages().

This patch will avoid to rebuild the zonelists for already exist nodes.

Signed-off-by: Wei Yang 
---
 mm/page_alloc.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 560eafe8234d..fc8181b44fd8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5200,15 +5200,17 @@ static int __build_all_zonelists(void *data)
memset(node_load, 0, sizeof(node_load));
 #endif
 
-   if (self && !node_online(self->node_id)) {
+   /* This node is hotadded and no memory preset yet.
+* So just build zonelists is fine, no need to touch other nodes.
+*/
+   if (self && !node_online(self->node_id))
build_zonelists(self);
-   }
-
-   for_each_online_node(nid) {
-   pg_data_t *pgdat = NODE_DATA(nid);
+   else
+   for_each_online_node(nid) {
+   pg_data_t *pgdat = NODE_DATA(nid);
 
-   build_zonelists(pgdat);
-   }
+   build_zonelists(pgdat);
+   }
 
/*
 * Initialize the boot_pagesets that are going to be used
-- 
2.11.0



Re: [PATCH] kernel/power/suspend: use CONFIG_HAVE_SET_MEMORY for include condition

2017-06-25 Thread Balbir Singh
On Sat, Jun 3, 2017 at 11:27 PM, Pavel Machek  wrote:
> On Sat 2017-06-03 20:52:32, Balbir Singh wrote:
>> Kbuild reported a build failure when CONFIG_STRICT_KERNEL_RWX was
>> enabled on powerpc. We don't yet have ARCH_HAS_SET_MEMORY and ppc32
>> saw a build failure.
>>
>> fixes(50327dd kernel/power/snapshot.c: use set_memory.h header)
>>
>> I've only done a basic compile test with a config that has
>> hibernation enabled.
>>
>> Cc: "Rafael J. Wysocki" 
>> Cc: Len Brown 
> Acked-by: Pavel Machek 

Ping. Could we please pick this up? it breaks any attempt to support
STRICT_KERNEL_RWX on powerpc

Balbir Singh.


Re: [PATCH] kernel/power/suspend: use CONFIG_HAVE_SET_MEMORY for include condition

2017-06-25 Thread Balbir Singh
On Sat, Jun 3, 2017 at 11:27 PM, Pavel Machek  wrote:
> On Sat 2017-06-03 20:52:32, Balbir Singh wrote:
>> Kbuild reported a build failure when CONFIG_STRICT_KERNEL_RWX was
>> enabled on powerpc. We don't yet have ARCH_HAS_SET_MEMORY and ppc32
>> saw a build failure.
>>
>> fixes(50327dd kernel/power/snapshot.c: use set_memory.h header)
>>
>> I've only done a basic compile test with a config that has
>> hibernation enabled.
>>
>> Cc: "Rafael J. Wysocki" 
>> Cc: Len Brown 
> Acked-by: Pavel Machek 

Ping. Could we please pick this up? it breaks any attempt to support
STRICT_KERNEL_RWX on powerpc

Balbir Singh.


Re: [PATCH v2 4/4] arm64: dts: rockchip: use cs-gpios for cros_ec_spi

2017-06-25 Thread jeffy

Hi Doug,

On 06/24/2017 12:14 AM, Doug Anderson wrote:

Jeffy

On Fri, Jun 23, 2017 at 5:18 AM, jeffy  wrote:

So how do we fix this?  IMHO:

Add 4 new pinctrl states in rk3399.dtsi:

 cs_low_clk_low, cs_low_clk_high, cs_high_clk_low, cs_high_clk_high

These would each look something like this:

spi5_cs_low_data_low: spi5-cs-low-data-low {
 rockchip,pins = <2 22 RK_FUNC_0 _output_low>,
   <2 23 RK_FUNC_0 _output_low>;
};

Where "pcfg_output_low" would be moved from the existing location in
"rk3399-gru.dtsi" to the main "rk3399.dtsi" file.


...now, you'd define runtime_suspend and runtime_resume functions
where you'd look at the current state of the chip select and output
and select one of these 4 pinmuxes so that things _don't_ change.




*** NOTE *** The more I look at this, the more I'm getting convinced
that the right thing to do is to just disable Runtime PM while the
chip select is asserted.  ...so probably you can just skip the next
chunk of text and go straight to "PROPOSAL".

ok



it looks like the clk would be low when spi idle, so do we only need
*_clk_low?


You're only looking at one polarity.  From Wikipedia
, the
source of all that is "true":

* At CPOL=0 the base value of the clock is zero, i.e. the idle state
is 0 and active state is 1.
-> For CPHA=0, data are captured and output on the clock's rising edge
(low→high transition)
-> For CPHA=1, data are captured and output on the clock's falling edge.

* At CPOL=1 the base value of the clock is one (inversion of CPOL=0),
i.e. the idle state is 1 and active state is 0.
-> For CPHA=0, data are captured and output on clock's falling edge.
-> For CPHA=1, data are captured and output on clock's rising edge.

If you're adding code to the generic Rockchip SPI driver you need to
handle both polarities.



and the rockchip spi supports 2 cs, so should we use cs0_low_cs1_low_clk_low
or should we put these pinmux into sub spi device?


By default the pinctrl for rk3399.dtsi just sets up cs0, so I'd worry
about that.  If someone wants to make cs1 work then they'd have to
specify the right pinctrl there.



* You'd want to add the pinmux configs to the main rk3399.dtsi file
and then add code to the rockchip SPI driver to select the right
pinmux (depending on the current state of the chip select and the
current polarity) at runtime suspend.  ...then go back to "default"
mode at runtime resume.


i uploaded 2 testonly CLs:
remote:   https://chromium-review.googlesource.com/544391 TESTONLY: spi:
rockchip: use pinmux to config cs
remote:   https://chromium-review.googlesource.com/544392 TESTONLY: dts:
bob: only enable ec spi

but they are not working well, not sure why, maybe cs still toggled will
switching pinmux? will use scope to check it next week.


Yeah, scope is probably the right thing to do.  One thing you'd have
to make sure is that everything is being done glitch free.  In other
words, if this is happening:

A) Pinmux to GPIO
B) Set GPIO to output
C) Drive GPIO state low

Then that's bad because:

After step A but before step B, you might still be an input and pulls
might take effect.  Thus you could glitch the line.

After step B but before step C, you might be outputting something else
if the GPIO had previously been configured to output high.


You need to make sure that the sequence is instead:

A) Drive GPIO state high
B) Set GPIO to output
C) Pinmux to GPIO


Ensuring things are glitch free and dealing with two chip selects
means it might be cleaner would be to do all the GPIO stuff yourself
in the driver.  Then you'd have to specify the GPIOs in the device
tree.

==

OK, I took a look at your CL and I'm now of the opinion that we should
disable Runtime PM when the chip select is asserted.  Maybe just
ignore the above and instead look at:


PROPOSAL: Disable Runtime PM when chip select is asserted

I think this proposal will be very easy and is pretty clean.
Basically go into "rockchip_spi_set_cs()" and adjust the
"pm_runtime_get_sync()" and "pm_runtime_put_sync()" calls.  Only call
the "get_sync" at the top of the function if you're asserting the chip
select (and it wasn't already asserted).  Only call the "put_sync" at
the bottom of the function if you're deasserting the chip select (and
it wasn't already deasserted).
hmm, looks like a better way to solve this, but i think we need to call 
pm_runtime_get_sync unconditionally to make sure the read ser register safe.


This should avoid entering PM sleep any time a transaction is midway
through happening.

Secondly, make sure that the chip selects have a pullup on them (they
already do).  When you Runtime PM then the SPI part will stop driving
the pins and the pull will take effect.  Since we can only Runtime PM
when the chip select is deasserted then this pull will always be
correct.  Also: since we Runtime PM when the chip select is deasserted
then the state of the other pins isn't 

Re: [PATCH v2 4/4] arm64: dts: rockchip: use cs-gpios for cros_ec_spi

2017-06-25 Thread jeffy

Hi Doug,

On 06/24/2017 12:14 AM, Doug Anderson wrote:

Jeffy

On Fri, Jun 23, 2017 at 5:18 AM, jeffy  wrote:

So how do we fix this?  IMHO:

Add 4 new pinctrl states in rk3399.dtsi:

 cs_low_clk_low, cs_low_clk_high, cs_high_clk_low, cs_high_clk_high

These would each look something like this:

spi5_cs_low_data_low: spi5-cs-low-data-low {
 rockchip,pins = <2 22 RK_FUNC_0 _output_low>,
   <2 23 RK_FUNC_0 _output_low>;
};

Where "pcfg_output_low" would be moved from the existing location in
"rk3399-gru.dtsi" to the main "rk3399.dtsi" file.


...now, you'd define runtime_suspend and runtime_resume functions
where you'd look at the current state of the chip select and output
and select one of these 4 pinmuxes so that things _don't_ change.




*** NOTE *** The more I look at this, the more I'm getting convinced
that the right thing to do is to just disable Runtime PM while the
chip select is asserted.  ...so probably you can just skip the next
chunk of text and go straight to "PROPOSAL".

ok



it looks like the clk would be low when spi idle, so do we only need
*_clk_low?


You're only looking at one polarity.  From Wikipedia
, the
source of all that is "true":

* At CPOL=0 the base value of the clock is zero, i.e. the idle state
is 0 and active state is 1.
-> For CPHA=0, data are captured and output on the clock's rising edge
(low→high transition)
-> For CPHA=1, data are captured and output on the clock's falling edge.

* At CPOL=1 the base value of the clock is one (inversion of CPOL=0),
i.e. the idle state is 1 and active state is 0.
-> For CPHA=0, data are captured and output on clock's falling edge.
-> For CPHA=1, data are captured and output on clock's rising edge.

If you're adding code to the generic Rockchip SPI driver you need to
handle both polarities.



and the rockchip spi supports 2 cs, so should we use cs0_low_cs1_low_clk_low
or should we put these pinmux into sub spi device?


By default the pinctrl for rk3399.dtsi just sets up cs0, so I'd worry
about that.  If someone wants to make cs1 work then they'd have to
specify the right pinctrl there.



* You'd want to add the pinmux configs to the main rk3399.dtsi file
and then add code to the rockchip SPI driver to select the right
pinmux (depending on the current state of the chip select and the
current polarity) at runtime suspend.  ...then go back to "default"
mode at runtime resume.


i uploaded 2 testonly CLs:
remote:   https://chromium-review.googlesource.com/544391 TESTONLY: spi:
rockchip: use pinmux to config cs
remote:   https://chromium-review.googlesource.com/544392 TESTONLY: dts:
bob: only enable ec spi

but they are not working well, not sure why, maybe cs still toggled will
switching pinmux? will use scope to check it next week.


Yeah, scope is probably the right thing to do.  One thing you'd have
to make sure is that everything is being done glitch free.  In other
words, if this is happening:

A) Pinmux to GPIO
B) Set GPIO to output
C) Drive GPIO state low

Then that's bad because:

After step A but before step B, you might still be an input and pulls
might take effect.  Thus you could glitch the line.

After step B but before step C, you might be outputting something else
if the GPIO had previously been configured to output high.


You need to make sure that the sequence is instead:

A) Drive GPIO state high
B) Set GPIO to output
C) Pinmux to GPIO


Ensuring things are glitch free and dealing with two chip selects
means it might be cleaner would be to do all the GPIO stuff yourself
in the driver.  Then you'd have to specify the GPIOs in the device
tree.

==

OK, I took a look at your CL and I'm now of the opinion that we should
disable Runtime PM when the chip select is asserted.  Maybe just
ignore the above and instead look at:


PROPOSAL: Disable Runtime PM when chip select is asserted

I think this proposal will be very easy and is pretty clean.
Basically go into "rockchip_spi_set_cs()" and adjust the
"pm_runtime_get_sync()" and "pm_runtime_put_sync()" calls.  Only call
the "get_sync" at the top of the function if you're asserting the chip
select (and it wasn't already asserted).  Only call the "put_sync" at
the bottom of the function if you're deasserting the chip select (and
it wasn't already deasserted).
hmm, looks like a better way to solve this, but i think we need to call 
pm_runtime_get_sync unconditionally to make sure the read ser register safe.


This should avoid entering PM sleep any time a transaction is midway
through happening.

Secondly, make sure that the chip selects have a pullup on them (they
already do).  When you Runtime PM then the SPI part will stop driving
the pins and the pull will take effect.  Since we can only Runtime PM
when the chip select is deasserted then this pull will always be
correct.  Also: since we Runtime PM when the chip select is deasserted
then the state of the other pins isn't 

Re: [PATCH v2 4/4] arm64: dts: rockchip: use cs-gpios for cros_ec_spi

2017-06-25 Thread jeffy

Hi Doug,

On 06/24/2017 12:14 AM, Doug Anderson wrote:

Jeffy

On Fri, Jun 23, 2017 at 5:18 AM, jeffy  wrote:

So how do we fix this?  IMHO:

Add 4 new pinctrl states in rk3399.dtsi:

 cs_low_clk_low, cs_low_clk_high, cs_high_clk_low, cs_high_clk_high

These would each look something like this:

spi5_cs_low_data_low: spi5-cs-low-data-low {
 rockchip,pins = <2 22 RK_FUNC_0 _output_low>,
   <2 23 RK_FUNC_0 _output_low>;
};

Where "pcfg_output_low" would be moved from the existing location in
"rk3399-gru.dtsi" to the main "rk3399.dtsi" file.


...now, you'd define runtime_suspend and runtime_resume functions
where you'd look at the current state of the chip select and output
and select one of these 4 pinmuxes so that things _don't_ change.




*** NOTE *** The more I look at this, the more I'm getting convinced
that the right thing to do is to just disable Runtime PM while the
chip select is asserted.  ...so probably you can just skip the next
chunk of text and go straight to "PROPOSAL".

ok



it looks like the clk would be low when spi idle, so do we only need
*_clk_low?


You're only looking at one polarity.  From Wikipedia
, the
source of all that is "true":

* At CPOL=0 the base value of the clock is zero, i.e. the idle state
is 0 and active state is 1.
-> For CPHA=0, data are captured and output on the clock's rising edge
(low→high transition)
-> For CPHA=1, data are captured and output on the clock's falling edge.

* At CPOL=1 the base value of the clock is one (inversion of CPOL=0),
i.e. the idle state is 1 and active state is 0.
-> For CPHA=0, data are captured and output on clock's falling edge.
-> For CPHA=1, data are captured and output on clock's rising edge.

If you're adding code to the generic Rockchip SPI driver you need to
handle both polarities.



and the rockchip spi supports 2 cs, so should we use cs0_low_cs1_low_clk_low
or should we put these pinmux into sub spi device?


By default the pinctrl for rk3399.dtsi just sets up cs0, so I'd worry
about that.  If someone wants to make cs1 work then they'd have to
specify the right pinctrl there.



* You'd want to add the pinmux configs to the main rk3399.dtsi file
and then add code to the rockchip SPI driver to select the right
pinmux (depending on the current state of the chip select and the
current polarity) at runtime suspend.  ...then go back to "default"
mode at runtime resume.


i uploaded 2 testonly CLs:
remote:   https://chromium-review.googlesource.com/544391 TESTONLY: spi:
rockchip: use pinmux to config cs
remote:   https://chromium-review.googlesource.com/544392 TESTONLY: dts:
bob: only enable ec spi

but they are not working well, not sure why, maybe cs still toggled will
switching pinmux? will use scope to check it next week.


Yeah, scope is probably the right thing to do.  One thing you'd have
to make sure is that everything is being done glitch free.  In other
words, if this is happening:

A) Pinmux to GPIO
B) Set GPIO to output
C) Drive GPIO state low

Then that's bad because:

After step A but before step B, you might still be an input and pulls
might take effect.  Thus you could glitch the line.

After step B but before step C, you might be outputting something else
if the GPIO had previously been configured to output high.


You need to make sure that the sequence is instead:

A) Drive GPIO state high
B) Set GPIO to output
C) Pinmux to GPIO


Ensuring things are glitch free and dealing with two chip selects
means it might be cleaner would be to do all the GPIO stuff yourself
in the driver.  Then you'd have to specify the GPIOs in the device
tree.

==

OK, I took a look at your CL and I'm now of the opinion that we should
disable Runtime PM when the chip select is asserted.  Maybe just
ignore the above and instead look at:


PROPOSAL: Disable Runtime PM when chip select is asserted

I think this proposal will be very easy and is pretty clean.
Basically go into "rockchip_spi_set_cs()" and adjust the
"pm_runtime_get_sync()" and "pm_runtime_put_sync()" calls.  Only call
the "get_sync" at the top of the function if you're asserting the chip
select (and it wasn't already asserted).  Only call the "put_sync" at
the bottom of the function if you're deasserting the chip select (and
it wasn't already deasserted).
hmm, looks like a better way to solve this, but i think we need to call 
pm_runtime_get_sync unconditionally to make sure the read ser register safe.


This should avoid entering PM sleep any time a transaction is midway
through happening.

Secondly, make sure that the chip selects have a pullup on them (they
already do).  When you Runtime PM then the SPI part will stop driving
the pins and the pull will take effect.  Since we can only Runtime PM
when the chip select is deasserted then this pull will always be
correct.  Also: since we Runtime PM when the chip select is deasserted
then the state of the other pins isn't terribly important (though 

Re: [PATCH v2 4/4] arm64: dts: rockchip: use cs-gpios for cros_ec_spi

2017-06-25 Thread jeffy

Hi Doug,

On 06/24/2017 12:14 AM, Doug Anderson wrote:

Jeffy

On Fri, Jun 23, 2017 at 5:18 AM, jeffy  wrote:

So how do we fix this?  IMHO:

Add 4 new pinctrl states in rk3399.dtsi:

 cs_low_clk_low, cs_low_clk_high, cs_high_clk_low, cs_high_clk_high

These would each look something like this:

spi5_cs_low_data_low: spi5-cs-low-data-low {
 rockchip,pins = <2 22 RK_FUNC_0 _output_low>,
   <2 23 RK_FUNC_0 _output_low>;
};

Where "pcfg_output_low" would be moved from the existing location in
"rk3399-gru.dtsi" to the main "rk3399.dtsi" file.


...now, you'd define runtime_suspend and runtime_resume functions
where you'd look at the current state of the chip select and output
and select one of these 4 pinmuxes so that things _don't_ change.




*** NOTE *** The more I look at this, the more I'm getting convinced
that the right thing to do is to just disable Runtime PM while the
chip select is asserted.  ...so probably you can just skip the next
chunk of text and go straight to "PROPOSAL".

ok



it looks like the clk would be low when spi idle, so do we only need
*_clk_low?


You're only looking at one polarity.  From Wikipedia
, the
source of all that is "true":

* At CPOL=0 the base value of the clock is zero, i.e. the idle state
is 0 and active state is 1.
-> For CPHA=0, data are captured and output on the clock's rising edge
(low→high transition)
-> For CPHA=1, data are captured and output on the clock's falling edge.

* At CPOL=1 the base value of the clock is one (inversion of CPOL=0),
i.e. the idle state is 1 and active state is 0.
-> For CPHA=0, data are captured and output on clock's falling edge.
-> For CPHA=1, data are captured and output on clock's rising edge.

If you're adding code to the generic Rockchip SPI driver you need to
handle both polarities.



and the rockchip spi supports 2 cs, so should we use cs0_low_cs1_low_clk_low
or should we put these pinmux into sub spi device?


By default the pinctrl for rk3399.dtsi just sets up cs0, so I'd worry
about that.  If someone wants to make cs1 work then they'd have to
specify the right pinctrl there.



* You'd want to add the pinmux configs to the main rk3399.dtsi file
and then add code to the rockchip SPI driver to select the right
pinmux (depending on the current state of the chip select and the
current polarity) at runtime suspend.  ...then go back to "default"
mode at runtime resume.


i uploaded 2 testonly CLs:
remote:   https://chromium-review.googlesource.com/544391 TESTONLY: spi:
rockchip: use pinmux to config cs
remote:   https://chromium-review.googlesource.com/544392 TESTONLY: dts:
bob: only enable ec spi

but they are not working well, not sure why, maybe cs still toggled will
switching pinmux? will use scope to check it next week.


Yeah, scope is probably the right thing to do.  One thing you'd have
to make sure is that everything is being done glitch free.  In other
words, if this is happening:

A) Pinmux to GPIO
B) Set GPIO to output
C) Drive GPIO state low

Then that's bad because:

After step A but before step B, you might still be an input and pulls
might take effect.  Thus you could glitch the line.

After step B but before step C, you might be outputting something else
if the GPIO had previously been configured to output high.


You need to make sure that the sequence is instead:

A) Drive GPIO state high
B) Set GPIO to output
C) Pinmux to GPIO


Ensuring things are glitch free and dealing with two chip selects
means it might be cleaner would be to do all the GPIO stuff yourself
in the driver.  Then you'd have to specify the GPIOs in the device
tree.

==

OK, I took a look at your CL and I'm now of the opinion that we should
disable Runtime PM when the chip select is asserted.  Maybe just
ignore the above and instead look at:


PROPOSAL: Disable Runtime PM when chip select is asserted

I think this proposal will be very easy and is pretty clean.
Basically go into "rockchip_spi_set_cs()" and adjust the
"pm_runtime_get_sync()" and "pm_runtime_put_sync()" calls.  Only call
the "get_sync" at the top of the function if you're asserting the chip
select (and it wasn't already asserted).  Only call the "put_sync" at
the bottom of the function if you're deasserting the chip select (and
it wasn't already deasserted).
hmm, looks like a better way to solve this, but i think we need to call 
pm_runtime_get_sync unconditionally to make sure the read ser register safe.


This should avoid entering PM sleep any time a transaction is midway
through happening.

Secondly, make sure that the chip selects have a pullup on them (they
already do).  When you Runtime PM then the SPI part will stop driving
the pins and the pull will take effect.  Since we can only Runtime PM
when the chip select is deasserted then this pull will always be
correct.  Also: since we Runtime PM when the chip select is deasserted
then the state of the other pins isn't terribly important (though 

[PATCH] spi: rockchip: Keep master alive when CS asserted

2017-06-25 Thread Jeffy Chen
The cros_ec requires CS line to be active after last message. But the CS
would be toggled when powering off/on rockchip spi, which breaks ec xfer.

Keep spi alive after CS asserted to prevent that.

Suggested-by: Doug Anderson 
Signed-off-by: Jeffy Chen 

---

 drivers/spi/spi-rockchip.c | 22 +-
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index acf31f3..df016a1 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -264,7 +264,7 @@ static inline u32 rx_max(struct rockchip_spi *rs)
 
 static void rockchip_spi_set_cs(struct spi_device *spi, bool enable)
 {
-   u32 ser;
+   u32 ser, new_ser;
struct spi_master *master = spi->master;
struct rockchip_spi *rs = spi_master_get_devdata(master);
 
@@ -288,13 +288,25 @@ static void rockchip_spi_set_cs(struct spi_device *spi, 
bool enable)
 * Note: enable(rockchip_spi_set_cs) = !enable(spi_set_cs)
 */
if (!enable)
-   ser |= 1 << spi->chip_select;
+   new_ser = ser | BIT(spi->chip_select);
else
-   ser &= ~(1 << spi->chip_select);
+   new_ser = ser & ~BIT(spi->chip_select);
 
-   writel_relaxed(ser, rs->regs + ROCKCHIP_SPI_SER);
+   if (new_ser == ser)
+   goto out;
 
-   pm_runtime_put_sync(rs->dev);
+   writel_relaxed(new_ser, rs->regs + ROCKCHIP_SPI_SER);
+
+   /*
+* The rockchip spi would stop driving CS when power down.
+* So we need to keep it alive after CS asserted
+*/
+   if (!enable)
+   return;
+   pm_runtime_put(rs->dev);
+
+out:
+   pm_runtime_put(rs->dev);
 }
 
 static int rockchip_spi_prepare_message(struct spi_master *master,
-- 
2.1.4




[PATCH] spi: rockchip: Keep master alive when CS asserted

2017-06-25 Thread Jeffy Chen
The cros_ec requires CS line to be active after last message. But the CS
would be toggled when powering off/on rockchip spi, which breaks ec xfer.

Keep spi alive after CS asserted to prevent that.

Suggested-by: Doug Anderson 
Signed-off-by: Jeffy Chen 

---

 drivers/spi/spi-rockchip.c | 22 +-
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index acf31f3..df016a1 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -264,7 +264,7 @@ static inline u32 rx_max(struct rockchip_spi *rs)
 
 static void rockchip_spi_set_cs(struct spi_device *spi, bool enable)
 {
-   u32 ser;
+   u32 ser, new_ser;
struct spi_master *master = spi->master;
struct rockchip_spi *rs = spi_master_get_devdata(master);
 
@@ -288,13 +288,25 @@ static void rockchip_spi_set_cs(struct spi_device *spi, 
bool enable)
 * Note: enable(rockchip_spi_set_cs) = !enable(spi_set_cs)
 */
if (!enable)
-   ser |= 1 << spi->chip_select;
+   new_ser = ser | BIT(spi->chip_select);
else
-   ser &= ~(1 << spi->chip_select);
+   new_ser = ser & ~BIT(spi->chip_select);
 
-   writel_relaxed(ser, rs->regs + ROCKCHIP_SPI_SER);
+   if (new_ser == ser)
+   goto out;
 
-   pm_runtime_put_sync(rs->dev);
+   writel_relaxed(new_ser, rs->regs + ROCKCHIP_SPI_SER);
+
+   /*
+* The rockchip spi would stop driving CS when power down.
+* So we need to keep it alive after CS asserted
+*/
+   if (!enable)
+   return;
+   pm_runtime_put(rs->dev);
+
+out:
+   pm_runtime_put(rs->dev);
 }
 
 static int rockchip_spi_prepare_message(struct spi_master *master,
-- 
2.1.4




RE: [PATCH 1/9] clk: clk-divider: add CLK_DIVIDER_ZERO_GATE clk support

2017-06-25 Thread A.s. Dong
Hi Stephen,

> -Original Message-
> From: Dong Aisheng [mailto:donga...@gmail.com]
> Sent: Tuesday, June 20, 2017 5:08 PM
> To: Stephen Boyd
> Cc: A.s. Dong; linux-...@vger.kernel.org; linux-kernel@vger.kernel.org;
> linux-arm-ker...@lists.infradead.org; mturque...@baylibre.com;
> shawn...@kernel.org; Anson Huang; Jacky Bai
> Subject: Re: [PATCH 1/9] clk: clk-divider: add CLK_DIVIDER_ZERO_GATE clk
> support
> 
> Hi Stephen,
> 
> On Mon, Jun 19, 2017 at 06:45:12PM -0700, Stephen Boyd wrote:
> > On 05/15, Dong Aisheng wrote:
> > > ---
> > >  drivers/clk/clk-divider.c| 2 ++
> > >  include/linux/clk-provider.h | 4 
> > >  2 files changed, 6 insertions(+)
> > >
> > > diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
> > > index 96386ff..f78ba7a 100644
> > > --- a/drivers/clk/clk-divider.c
> > > +++ b/drivers/clk/clk-divider.c
> > > @@ -125,6 +125,8 @@ unsigned long divider_recalc_rate(struct clk_hw
> > > *hw, unsigned long parent_rate,
> > >
> > >   div = _get_div(table, val, flags, divider->width);
> > >   if (!div) {
> > > + if (flags & CLK_DIVIDER_ZERO_GATE)
> > > + return 0;
> > >   WARN(!(flags & CLK_DIVIDER_ALLOW_ZERO),
> >
> > Why not use the CLK_DIVIDER_ALLOW_ZERO flag? A clk being off doesn't
> > mean the rate is 0. The divider is just disabled, so we would consider
> > the rate as whatever the parent is, which is what this code does
> > before this patch. Similarly, we don't do anything about gate clocks
> > and return a rate of 0 when they're disabled.
> >
> 
> The semantic of CLK_DIVIDER_ALLOW_ZERO seems a bit different.
> 
> See below definition:
> * CLK_DIVIDER_ALLOW_ZERO - Allow zero divisors.  For dividers which have
> *  CLK_DIVIDER_ONE_BASED set, it is possible to end up with a zero
> divisor.
> *  Some hardware implementations gracefully handle this case and allow
> a
> *  zero divisor by not modifying their input clock
> *  (divide by one / bypass).
> 
> zero divisor is simply as divide by one or bypass which is supported by
> hardware.
> 
> But it's not true for this hardware.
> 
> If we consider the rate as whatever the parent is if divider is zero, we
> may got an issue like below:
> e.g.
> Assuming spll_bus_clk divider is 0x0 and it may be enabled by users
> directly without setting a rate first.
> 
> Then the clock tree looks like:
> ...
> spll_pfd011   500210526  0 0
>   spll_pfd_sel  11   500210526  0 0
> spll_sel   11   500210526  0 0
>   spll_bus_clk   11   500210526  0 0
> 
> But the spll_bus_clk clock rate actually is wrong and it's even not
> enabled, not like CLK_DIVIDER_ALLOW_ZERO which zero divider means simply
> bypass.
> 
> So for this case, we probably can't simply assume zero divider rate as its
> parent, it is actually set to 0 in hw, although it's something like gate,
> but a bit different from gate as the normal gate does not affect divider
> where you can keep the rate.
> 
> How would you suggest for this?
> 

Any suggestions?

Regards
Dong Aisheng

> Regards
> Dong Aisheng
> 
> > >   "%s: Zero divisor and CLK_DIVIDER_ALLOW_ZERO not set\n",
> > >   clk_hw_get_name(hw));
> >
> > --
> > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
> > Linux Foundation Collaborative Project
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-clk"
> > in the body of a message to majord...@vger.kernel.org More majordomo
> > info at  http://vger.kernel.org/majordomo-info.html


bfq/ext4 disk IO hangs forever on resume

2017-06-25 Thread Alex Xu
Hi,

I get hangs when resuming when using bfq-mq with ext4 on 4.12-rc6+
(currently a4fd8b3accf43d407472e34403d4b0a4df5c0e71).

Steps to reproduce:
1. boot computer
2. systemctl suspend
3. wait few seconds
4. press power button
5. type "ls" into console or SSH or do anything that does disk IO

Expected results:
Command is executed.

Actual results:
Command hangs.

lockdep has no comments, but sysrq-d shows that i_mutex_dir_key and
jbd2_handle are held by multiple processes, leading me to suspect that
ext4 is at least partially involved. [0]

sysrq-w lists many blocked processes [1]

This happens consistently, every time I resume the system from
suspend-to-RAM using this configuration. Switching to noop IO scheduler
makes it stop happening. I haven't tried switching filesystems yet.

I can do more debugging (enable KASAN or whatever), but usually when I
bother doing that I find someone has already sent a patch for the issue.

Please CC me on replies.

Cheers,
Alex.

[0]

4 locks held by systemd/384:

 
 #0:  (sb_writers#3){.+.+.+}, at: [] mnt_want_write+0x1f/0x50
 #1:  (>i_mutex_dir_key/1){+.+.+.}, at: [] 
do_rmdir+0x15e/0x1e0
 #2:  (>i_mutex_dir_key){++}, at: [] 
vfs_rmdir+0x50/0x130
 #3:  (jbd2_handle){..}, at: [] 
start_this_handle+0xff/0x430
4 locks held by syncthing/279: 
 #0:  (>f_pos_lock){+.+.+.}, at: [] __fdget_pos+0x3e/0x50
 #1:  (sb_writers#3){.+.+.+}, at: [] vfs_write+0x17c/0x1d0
 #2:  (>s_type->i_mutex_key#9){+.+.+.}, at: [] 
ext4_file_write_iter+0x57/0x350
 #3:  (jbd2_handle){..}, at: [] 
start_this_handle+0xff/0x430
2 locks held by zsh/238:
 #0:  (>ldisc_sem){.+}, at: [] 
ldsem_down_read+0x1f/0x30
 #1:  (>atomic_read_lock){+.+...}, at: [] 
n_tty_read+0xb0/0x8b0
2 locks held by sddm-greeter/267:
 #0:  (sb_writers#3){.+.+.+}, at: [] mnt_want_write+0x1f/0x50
 #1:  (>i_mutex_dir_key){++}, at: [] 
path_openat+0x2d8/0xa10
2 locks held by kworker/u16:28/330:
 #0:  ("events_unbound"){.+.+.+}, at: [] 
process_one_work+0x1c3/0x420
 #1:  ((>work)){+.+.+.}, at: [] 
process_one_work+0x1c3/0x420
1 lock held by zsh/382:
 #0:  (>cred_guard_mutex){+.+.+.}, at: [] 
prepare_bprm_creds+0x30/0x70

[1]

  taskPC stack   pid father
systemd D0   384  0 0x   
Call Trace:
 __schedule+0x295/0x7c0
 ? bit_wait+0x50/0x50
 ? bit_wait+0x50/0x50
 schedule+0x31/0x80
 io_schedule+0x11/0x40
 bit_wait_io+0xc/0x50
 __wait_on_bit+0x53/0x80
 ? bit_wait+0x50/0x50
 out_of_line_wait_on_bit+0x6e/0x80
 ? autoremove_wake_function+0x30/0x30
 do_get_write_access+0x20b/0x420
 jbd2_journal_get_write_access+0x2c/0x60
 __ext4_journal_get_write_access+0x55/0xa0
 ext4_delete_entry+0x8c/0x140
 ? __ext4_journal_start_sb+0x4e/0xa0
 ext4_rmdir+0x114/0x250
 vfs_rmdir+0x6e/0x130
 do_rmdir+0x1a3/0x1e0
 SyS_unlinkat+0x1d/0x30
 entry_SYSCALL_64_fastpath+0x18/0xad
jbd2/sda1-8 D081  2 0x   
Call Trace:
 __schedule+0x295/0x7c0
 ? bit_wait+0x50/0x50
 schedule+0x31/0x80
 io_schedule+0x11/0x40
 bit_wait_io+0xc/0x50
 __wait_on_bit+0x53/0x80
 ? bit_wait+0x50/0x50
 out_of_line_wait_on_bit+0x6e/0x80
 ? autoremove_wake_function+0x30/0x30
 __wait_on_buffer+0x2d/0x30
 jbd2_journal_commit_transaction+0xe6a/0x1700
 kjournald2+0xc8/0x270
 ? kjournald2+0xc8/0x270
 ? wake_atomic_t_function+0x50/0x50
 kthread+0xfe/0x130
 ? commit_timeout+0x10/0x10
 ? kthread_create_on_node+0x40/0x40
 ret_from_fork+0x27/0x40
[ more processes follow, some different tracebacks ]


RE: [PATCH 1/9] clk: clk-divider: add CLK_DIVIDER_ZERO_GATE clk support

2017-06-25 Thread A.s. Dong
Hi Stephen,

> -Original Message-
> From: Dong Aisheng [mailto:donga...@gmail.com]
> Sent: Tuesday, June 20, 2017 5:08 PM
> To: Stephen Boyd
> Cc: A.s. Dong; linux-...@vger.kernel.org; linux-kernel@vger.kernel.org;
> linux-arm-ker...@lists.infradead.org; mturque...@baylibre.com;
> shawn...@kernel.org; Anson Huang; Jacky Bai
> Subject: Re: [PATCH 1/9] clk: clk-divider: add CLK_DIVIDER_ZERO_GATE clk
> support
> 
> Hi Stephen,
> 
> On Mon, Jun 19, 2017 at 06:45:12PM -0700, Stephen Boyd wrote:
> > On 05/15, Dong Aisheng wrote:
> > > ---
> > >  drivers/clk/clk-divider.c| 2 ++
> > >  include/linux/clk-provider.h | 4 
> > >  2 files changed, 6 insertions(+)
> > >
> > > diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
> > > index 96386ff..f78ba7a 100644
> > > --- a/drivers/clk/clk-divider.c
> > > +++ b/drivers/clk/clk-divider.c
> > > @@ -125,6 +125,8 @@ unsigned long divider_recalc_rate(struct clk_hw
> > > *hw, unsigned long parent_rate,
> > >
> > >   div = _get_div(table, val, flags, divider->width);
> > >   if (!div) {
> > > + if (flags & CLK_DIVIDER_ZERO_GATE)
> > > + return 0;
> > >   WARN(!(flags & CLK_DIVIDER_ALLOW_ZERO),
> >
> > Why not use the CLK_DIVIDER_ALLOW_ZERO flag? A clk being off doesn't
> > mean the rate is 0. The divider is just disabled, so we would consider
> > the rate as whatever the parent is, which is what this code does
> > before this patch. Similarly, we don't do anything about gate clocks
> > and return a rate of 0 when they're disabled.
> >
> 
> The semantic of CLK_DIVIDER_ALLOW_ZERO seems a bit different.
> 
> See below definition:
> * CLK_DIVIDER_ALLOW_ZERO - Allow zero divisors.  For dividers which have
> *  CLK_DIVIDER_ONE_BASED set, it is possible to end up with a zero
> divisor.
> *  Some hardware implementations gracefully handle this case and allow
> a
> *  zero divisor by not modifying their input clock
> *  (divide by one / bypass).
> 
> zero divisor is simply as divide by one or bypass which is supported by
> hardware.
> 
> But it's not true for this hardware.
> 
> If we consider the rate as whatever the parent is if divider is zero, we
> may got an issue like below:
> e.g.
> Assuming spll_bus_clk divider is 0x0 and it may be enabled by users
> directly without setting a rate first.
> 
> Then the clock tree looks like:
> ...
> spll_pfd011   500210526  0 0
>   spll_pfd_sel  11   500210526  0 0
> spll_sel   11   500210526  0 0
>   spll_bus_clk   11   500210526  0 0
> 
> But the spll_bus_clk clock rate actually is wrong and it's even not
> enabled, not like CLK_DIVIDER_ALLOW_ZERO which zero divider means simply
> bypass.
> 
> So for this case, we probably can't simply assume zero divider rate as its
> parent, it is actually set to 0 in hw, although it's something like gate,
> but a bit different from gate as the normal gate does not affect divider
> where you can keep the rate.
> 
> How would you suggest for this?
> 

Any suggestions?

Regards
Dong Aisheng

> Regards
> Dong Aisheng
> 
> > >   "%s: Zero divisor and CLK_DIVIDER_ALLOW_ZERO not set\n",
> > >   clk_hw_get_name(hw));
> >
> > --
> > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
> > Linux Foundation Collaborative Project
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-clk"
> > in the body of a message to majord...@vger.kernel.org More majordomo
> > info at  http://vger.kernel.org/majordomo-info.html


bfq/ext4 disk IO hangs forever on resume

2017-06-25 Thread Alex Xu
Hi,

I get hangs when resuming when using bfq-mq with ext4 on 4.12-rc6+
(currently a4fd8b3accf43d407472e34403d4b0a4df5c0e71).

Steps to reproduce:
1. boot computer
2. systemctl suspend
3. wait few seconds
4. press power button
5. type "ls" into console or SSH or do anything that does disk IO

Expected results:
Command is executed.

Actual results:
Command hangs.

lockdep has no comments, but sysrq-d shows that i_mutex_dir_key and
jbd2_handle are held by multiple processes, leading me to suspect that
ext4 is at least partially involved. [0]

sysrq-w lists many blocked processes [1]

This happens consistently, every time I resume the system from
suspend-to-RAM using this configuration. Switching to noop IO scheduler
makes it stop happening. I haven't tried switching filesystems yet.

I can do more debugging (enable KASAN or whatever), but usually when I
bother doing that I find someone has already sent a patch for the issue.

Please CC me on replies.

Cheers,
Alex.

[0]

4 locks held by systemd/384:

 
 #0:  (sb_writers#3){.+.+.+}, at: [] mnt_want_write+0x1f/0x50
 #1:  (>i_mutex_dir_key/1){+.+.+.}, at: [] 
do_rmdir+0x15e/0x1e0
 #2:  (>i_mutex_dir_key){++}, at: [] 
vfs_rmdir+0x50/0x130
 #3:  (jbd2_handle){..}, at: [] 
start_this_handle+0xff/0x430
4 locks held by syncthing/279: 
 #0:  (>f_pos_lock){+.+.+.}, at: [] __fdget_pos+0x3e/0x50
 #1:  (sb_writers#3){.+.+.+}, at: [] vfs_write+0x17c/0x1d0
 #2:  (>s_type->i_mutex_key#9){+.+.+.}, at: [] 
ext4_file_write_iter+0x57/0x350
 #3:  (jbd2_handle){..}, at: [] 
start_this_handle+0xff/0x430
2 locks held by zsh/238:
 #0:  (>ldisc_sem){.+}, at: [] 
ldsem_down_read+0x1f/0x30
 #1:  (>atomic_read_lock){+.+...}, at: [] 
n_tty_read+0xb0/0x8b0
2 locks held by sddm-greeter/267:
 #0:  (sb_writers#3){.+.+.+}, at: [] mnt_want_write+0x1f/0x50
 #1:  (>i_mutex_dir_key){++}, at: [] 
path_openat+0x2d8/0xa10
2 locks held by kworker/u16:28/330:
 #0:  ("events_unbound"){.+.+.+}, at: [] 
process_one_work+0x1c3/0x420
 #1:  ((>work)){+.+.+.}, at: [] 
process_one_work+0x1c3/0x420
1 lock held by zsh/382:
 #0:  (>cred_guard_mutex){+.+.+.}, at: [] 
prepare_bprm_creds+0x30/0x70

[1]

  taskPC stack   pid father
systemd D0   384  0 0x   
Call Trace:
 __schedule+0x295/0x7c0
 ? bit_wait+0x50/0x50
 ? bit_wait+0x50/0x50
 schedule+0x31/0x80
 io_schedule+0x11/0x40
 bit_wait_io+0xc/0x50
 __wait_on_bit+0x53/0x80
 ? bit_wait+0x50/0x50
 out_of_line_wait_on_bit+0x6e/0x80
 ? autoremove_wake_function+0x30/0x30
 do_get_write_access+0x20b/0x420
 jbd2_journal_get_write_access+0x2c/0x60
 __ext4_journal_get_write_access+0x55/0xa0
 ext4_delete_entry+0x8c/0x140
 ? __ext4_journal_start_sb+0x4e/0xa0
 ext4_rmdir+0x114/0x250
 vfs_rmdir+0x6e/0x130
 do_rmdir+0x1a3/0x1e0
 SyS_unlinkat+0x1d/0x30
 entry_SYSCALL_64_fastpath+0x18/0xad
jbd2/sda1-8 D081  2 0x   
Call Trace:
 __schedule+0x295/0x7c0
 ? bit_wait+0x50/0x50
 schedule+0x31/0x80
 io_schedule+0x11/0x40
 bit_wait_io+0xc/0x50
 __wait_on_bit+0x53/0x80
 ? bit_wait+0x50/0x50
 out_of_line_wait_on_bit+0x6e/0x80
 ? autoremove_wake_function+0x30/0x30
 __wait_on_buffer+0x2d/0x30
 jbd2_journal_commit_transaction+0xe6a/0x1700
 kjournald2+0xc8/0x270
 ? kjournald2+0xc8/0x270
 ? wake_atomic_t_function+0x50/0x50
 kthread+0xfe/0x130
 ? commit_timeout+0x10/0x10
 ? kthread_create_on_node+0x40/0x40
 ret_from_fork+0x27/0x40
[ more processes follow, some different tracebacks ]


Re: zram hot_add device busy

2017-06-25 Thread Sergey Senozhatsky
On (06/26/17 11:39), Sergey Senozhatsky wrote:
[..]
> ok... I don't think I see what we can do in zram about the
> issue in question.

... check init_done() in reset_store() and avoid the whole ->bd_openers
branch if the device is already reset?

// not compile tested. just a sketch. //

---

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index debee952dcc1..79b1a957a6bd 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1047,6 +1047,14 @@ static ssize_t reset_store(struct device *dev,
return -EINVAL;
 
zram = dev_to_zram(dev);
+
+   down_write(>init_lock);
+   if (!init_done(zram)) {
+   up_write(>init_lock);
+   return len;
+   }
+   up_write(>init_lock);
+
bdev = bdget_disk(zram->disk, 0);
if (!bdev)
return -ENOMEM;

---

-ss


Re: zram hot_add device busy

2017-06-25 Thread Sergey Senozhatsky
On (06/26/17 11:39), Sergey Senozhatsky wrote:
[..]
> ok... I don't think I see what we can do in zram about the
> issue in question.

... check init_done() in reset_store() and avoid the whole ->bd_openers
branch if the device is already reset?

// not compile tested. just a sketch. //

---

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index debee952dcc1..79b1a957a6bd 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1047,6 +1047,14 @@ static ssize_t reset_store(struct device *dev,
return -EINVAL;
 
zram = dev_to_zram(dev);
+
+   down_write(>init_lock);
+   if (!init_done(zram)) {
+   up_write(>init_lock);
+   return len;
+   }
+   up_write(>init_lock);
+
bdev = bdget_disk(zram->disk, 0);
if (!bdev)
return -ENOMEM;

---

-ss


Re: [PATCH] dmaengine: qcom_hidma: allow ACPI/DT parameters to be overridden

2017-06-25 Thread Vinod Koul
On Thu, Jun 22, 2017 at 02:59:22PM -0400, Sinan Kaya wrote:
> Parameters like maximum read/write request size and the maximum
> number of active transactions are currently configured in DT/ACPI.
> 
> This patch allows a user to override these to fine tune performance
> for their application.

Applied, thanks

-- 
~Vinod


Re: [PATCH] dmaengine: qcom_hidma: allow ACPI/DT parameters to be overridden

2017-06-25 Thread Vinod Koul
On Thu, Jun 22, 2017 at 02:59:22PM -0400, Sinan Kaya wrote:
> Parameters like maximum read/write request size and the maximum
> number of active transactions are currently configured in DT/ACPI.
> 
> This patch allows a user to override these to fine tune performance
> for their application.

Applied, thanks

-- 
~Vinod


Re: [PATCH 2/3] iio: adc: mt7622: add support for suspend/resume.

2017-06-25 Thread zhiyong tao
On Sat, 2017-06-24 at 21:00 +0100, Jonathan Cameron wrote:
> On Thu, 22 Jun 2017 13:44:33 +0800
> Zhiyong Tao  wrote:
> 
> > This patch supports auxadc suspend/resume flow.
> > Disable auxadc clk and power in suspend function.
> > Enable axuadc clk and power in resume function.
> > 
> > Signed-off-by: Zhiyong Tao 
> Worth handling the cases where power management is not configured into the
> kernel properly.
> 
> So a few minor suggestions.  Otherwise looks good to me.
> > ---
> >  drivers/iio/adc/mt6577_auxadc.c |   37 
> > +
> >  1 file changed, 37 insertions(+)
> > 
> > diff --git a/drivers/iio/adc/mt6577_auxadc.c 
> > b/drivers/iio/adc/mt6577_auxadc.c
> > index 2d104c8..2dd7c74 100644
> > --- a/drivers/iio/adc/mt6577_auxadc.c
> > +++ b/drivers/iio/adc/mt6577_auxadc.c
> > @@ -184,6 +184,37 @@ static int mt6577_auxadc_read_raw(struct iio_dev 
> > *indio_dev,
> > .read_raw = _auxadc_read_raw,
> >  };
> >  
> > +static int mt6577_auxadc_resume(struct device *dev)
> > +{
> > +   struct iio_dev *indio_dev = dev_get_drvdata(dev);
> > +   struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
> > +   int ret;
> > +
> > +   ret = clk_prepare_enable(adc_dev->adc_clk);
> > +   if (ret) {
> > +   pr_err("failed to enable auxadc clock\n");
> > +   return ret;
> > +   }
> > +
> > +   mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
> > + MT6577_AUXADC_PDN_EN, 0);
> > +   mdelay(MT6577_AUXADC_POWER_READY_MS);
> > +
> > +   return 0;
> > +}
> > +
> > +static int mt6577_auxadc_suspend(struct device *dev)
> Mark these __maybe_unused for the CONFIG_PM but not CONFIG_PM_SLEEP case.

==> ok, We will add CONFIG_PM_SLEEP for the suspend/resume case in v2.
thanks!

> > +{
> > +   struct iio_dev *indio_dev = dev_get_drvdata(dev);
> > +   struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
> > +
> > +   mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
> > + 0, MT6577_AUXADC_PDN_EN);
> > +   clk_disable_unprepare(adc_dev->adc_clk);
> > +
> > +   return 0;
> > +}
> > +
> >  static int mt6577_auxadc_probe(struct platform_device *pdev)
> >  {
> > struct mt6577_auxadc_device *adc_dev;
> > @@ -269,6 +300,11 @@ static int mt6577_auxadc_remove(struct platform_device 
> > *pdev)
> > return 0;
> >  }
> >  
> > +static const struct dev_pm_ops mt6577_auxadc_pm_ops = {
> > +   .suspend = mt6577_auxadc_suspend,
> > +   .resume = mt6577_auxadc_resume,
> > +};
> > +
> Use the SIMPLE_SYSTEM_PM_OPS macro to make these assignments magically go away
> if PM_CONFIG_SLEEP is not defined.

==> ok, We will use SIMPLE_DEV_PM_OPS macro to change it in v2. Thanks.
>>  static const struct of_device_id mt6577_auxadc_of_match[] = {
> > { .compatible = "mediatek,mt2701-auxadc", },
> > { .compatible = "mediatek,mt8173-auxadc", },
> > @@ -280,6 +316,7 @@ static int mt6577_auxadc_remove(struct platform_device 
> > *pdev)
> > .driver = {
> > .name   = "mt6577-auxadc",
> > .of_match_table = mt6577_auxadc_of_match,
> > +   .pm = _auxadc_pm_ops,
> > },
> > .probe  = mt6577_auxadc_probe,
> > .remove = mt6577_auxadc_remove,
> 




Re: [PATCH 2/3] iio: adc: mt7622: add support for suspend/resume.

2017-06-25 Thread zhiyong tao
On Sat, 2017-06-24 at 21:00 +0100, Jonathan Cameron wrote:
> On Thu, 22 Jun 2017 13:44:33 +0800
> Zhiyong Tao  wrote:
> 
> > This patch supports auxadc suspend/resume flow.
> > Disable auxadc clk and power in suspend function.
> > Enable axuadc clk and power in resume function.
> > 
> > Signed-off-by: Zhiyong Tao 
> Worth handling the cases where power management is not configured into the
> kernel properly.
> 
> So a few minor suggestions.  Otherwise looks good to me.
> > ---
> >  drivers/iio/adc/mt6577_auxadc.c |   37 
> > +
> >  1 file changed, 37 insertions(+)
> > 
> > diff --git a/drivers/iio/adc/mt6577_auxadc.c 
> > b/drivers/iio/adc/mt6577_auxadc.c
> > index 2d104c8..2dd7c74 100644
> > --- a/drivers/iio/adc/mt6577_auxadc.c
> > +++ b/drivers/iio/adc/mt6577_auxadc.c
> > @@ -184,6 +184,37 @@ static int mt6577_auxadc_read_raw(struct iio_dev 
> > *indio_dev,
> > .read_raw = _auxadc_read_raw,
> >  };
> >  
> > +static int mt6577_auxadc_resume(struct device *dev)
> > +{
> > +   struct iio_dev *indio_dev = dev_get_drvdata(dev);
> > +   struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
> > +   int ret;
> > +
> > +   ret = clk_prepare_enable(adc_dev->adc_clk);
> > +   if (ret) {
> > +   pr_err("failed to enable auxadc clock\n");
> > +   return ret;
> > +   }
> > +
> > +   mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
> > + MT6577_AUXADC_PDN_EN, 0);
> > +   mdelay(MT6577_AUXADC_POWER_READY_MS);
> > +
> > +   return 0;
> > +}
> > +
> > +static int mt6577_auxadc_suspend(struct device *dev)
> Mark these __maybe_unused for the CONFIG_PM but not CONFIG_PM_SLEEP case.

==> ok, We will add CONFIG_PM_SLEEP for the suspend/resume case in v2.
thanks!

> > +{
> > +   struct iio_dev *indio_dev = dev_get_drvdata(dev);
> > +   struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
> > +
> > +   mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
> > + 0, MT6577_AUXADC_PDN_EN);
> > +   clk_disable_unprepare(adc_dev->adc_clk);
> > +
> > +   return 0;
> > +}
> > +
> >  static int mt6577_auxadc_probe(struct platform_device *pdev)
> >  {
> > struct mt6577_auxadc_device *adc_dev;
> > @@ -269,6 +300,11 @@ static int mt6577_auxadc_remove(struct platform_device 
> > *pdev)
> > return 0;
> >  }
> >  
> > +static const struct dev_pm_ops mt6577_auxadc_pm_ops = {
> > +   .suspend = mt6577_auxadc_suspend,
> > +   .resume = mt6577_auxadc_resume,
> > +};
> > +
> Use the SIMPLE_SYSTEM_PM_OPS macro to make these assignments magically go away
> if PM_CONFIG_SLEEP is not defined.

==> ok, We will use SIMPLE_DEV_PM_OPS macro to change it in v2. Thanks.
>>  static const struct of_device_id mt6577_auxadc_of_match[] = {
> > { .compatible = "mediatek,mt2701-auxadc", },
> > { .compatible = "mediatek,mt8173-auxadc", },
> > @@ -280,6 +316,7 @@ static int mt6577_auxadc_remove(struct platform_device 
> > *pdev)
> > .driver = {
> > .name   = "mt6577-auxadc",
> > .of_match_table = mt6577_auxadc_of_match,
> > +   .pm = _auxadc_pm_ops,
> > },
> > .probe  = mt6577_auxadc_probe,
> > .remove = mt6577_auxadc_remove,
> 




Re: [PATCH v2 1/2] dt-bindings: i2c: Add Spreadtrum I2C controller documentation

2017-06-25 Thread Baolin Wang
Hi Rob,

On 五,  6月 23, 2017 at 05:20:16下午 -0500, Rob Herring wrote:
> On Wed, Jun 21, 2017 at 03:23:03PM +0800, Baolin Wang wrote:
> > This patch adds the binding documentation for Spreadtrum I2C
> > controller device.
> > 
> > Signed-off-by: Baolin Wang 
> > ---
> > Changes since v1:
> >  - No updates.
> > ---
> >  Documentation/devicetree/bindings/i2c/i2c-sprd.txt |   31 
> > 
> >  1 file changed, 31 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/i2c/i2c-sprd.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/i2c/i2c-sprd.txt 
> > b/Documentation/devicetree/bindings/i2c/i2c-sprd.txt
> > new file mode 100644
> > index 000..f285e5b
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/i2c/i2c-sprd.txt
> > @@ -0,0 +1,31 @@
> > +I2C for Spreadtrum platforms
> > +
> > +Required properties:
> > +- compatible: Should be "sprd,r8p0-i2c".
> 
> Compatible strings should be SoC specific.

Will fix this in next version. Thanks.

> 
> > +- reg: Specify the physical base address of the controller and length
> > +  of memory mapped region.
> > +- interrupts: Should contain I2C interrupt.
> > +- clock-names: Should contain following entries:
> > +  "i2c" for I2C clock,
> > +  "source" for I2C source (parent) clock,
> > +  "enable" for I2C module enable clock.
> > +- clocks: Should contain a clock specifier for each entry in clock-names.
> > +- clock-frequency: Constains desired I2C bus clock frequency in Hz.
> > +- #address-cells: Should be 1 to describe address cells for I2C device 
> > address.
> > +- #size-cells: Should be 0 means no size cell for I2C device address.
> > +
> > +Optional properties:
> > +- Child nodes conforming to I2C bus binding
> > +
> > +Examples:
> > +i2c0: i2c@7050 {
> > +   compatible = "sprd,r8p0-i2c";
> > +   reg = <0 0x7050 0 0x1000>;
> > +   interrupts = ;
> > +   clock-names = "i2c", "source", "enable";
> > +   clocks = <_i2c3>, <_26m>, <_ap_apb_gates 11>;
> > +   clock-frequency = <40>;
> > +   #address-cells = <1>;
> > +   #size-cells = <0>;
> > +};
> > +
> > -- 
> > 1.7.9.5
> > 


Re: [PATCH v2 1/2] dt-bindings: i2c: Add Spreadtrum I2C controller documentation

2017-06-25 Thread Baolin Wang
Hi Rob,

On 五,  6月 23, 2017 at 05:20:16下午 -0500, Rob Herring wrote:
> On Wed, Jun 21, 2017 at 03:23:03PM +0800, Baolin Wang wrote:
> > This patch adds the binding documentation for Spreadtrum I2C
> > controller device.
> > 
> > Signed-off-by: Baolin Wang 
> > ---
> > Changes since v1:
> >  - No updates.
> > ---
> >  Documentation/devicetree/bindings/i2c/i2c-sprd.txt |   31 
> > 
> >  1 file changed, 31 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/i2c/i2c-sprd.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/i2c/i2c-sprd.txt 
> > b/Documentation/devicetree/bindings/i2c/i2c-sprd.txt
> > new file mode 100644
> > index 000..f285e5b
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/i2c/i2c-sprd.txt
> > @@ -0,0 +1,31 @@
> > +I2C for Spreadtrum platforms
> > +
> > +Required properties:
> > +- compatible: Should be "sprd,r8p0-i2c".
> 
> Compatible strings should be SoC specific.

Will fix this in next version. Thanks.

> 
> > +- reg: Specify the physical base address of the controller and length
> > +  of memory mapped region.
> > +- interrupts: Should contain I2C interrupt.
> > +- clock-names: Should contain following entries:
> > +  "i2c" for I2C clock,
> > +  "source" for I2C source (parent) clock,
> > +  "enable" for I2C module enable clock.
> > +- clocks: Should contain a clock specifier for each entry in clock-names.
> > +- clock-frequency: Constains desired I2C bus clock frequency in Hz.
> > +- #address-cells: Should be 1 to describe address cells for I2C device 
> > address.
> > +- #size-cells: Should be 0 means no size cell for I2C device address.
> > +
> > +Optional properties:
> > +- Child nodes conforming to I2C bus binding
> > +
> > +Examples:
> > +i2c0: i2c@7050 {
> > +   compatible = "sprd,r8p0-i2c";
> > +   reg = <0 0x7050 0 0x1000>;
> > +   interrupts = ;
> > +   clock-names = "i2c", "source", "enable";
> > +   clocks = <_i2c3>, <_26m>, <_ap_apb_gates 11>;
> > +   clock-frequency = <40>;
> > +   #address-cells = <1>;
> > +   #size-cells = <0>;
> > +};
> > +
> > -- 
> > 1.7.9.5
> > 


linux-next: manual merge of the block tree with Linus' tree

2017-06-25 Thread Stephen Rothwell
Hi Jens,

Today's linux-next merge of the block tree got a conflict in:

  drivers/md/dm-raid1.c

between commit:

  cd15fb64ee56 ("Revert "dm mirror: use all available legs on multiple 
failures"")

from Linus' tree and commits:

  9966afaf91b3 ("dm: fix REQ_RAHEAD handling")
  1be569098458 ("dm: change ->end_io calling convention")
  4e4cbee93d56 ("block: switch bios to blk_status_t")

from the block tree.

I fixed it up (I think - see below) and can carry the fix as necessary.
This is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/dm-raid1.c
index 4da8858856fb,3ab584b686e0..
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@@ -1255,26 -1253,16 +1256,26 @@@ static int mirror_end_io(struct dm_targ
if (!(bio->bi_opf & REQ_PREFLUSH) &&
bio_op(bio) != REQ_OP_DISCARD)
dm_rh_dec(ms->rh, bio_record->write_region);
-   return error;
+   return DM_ENDIO_DONE;
}
  
-   if (error == -EOPNOTSUPP)
+   if (*error == BLK_STS_NOTSUPP)
 -  return DM_ENDIO_DONE;
 +  goto out;
  
-   if ((error == -EWOULDBLOCK) && (bio->bi_opf & REQ_RAHEAD))
+   if (bio->bi_opf & REQ_RAHEAD)
 -  return DM_ENDIO_DONE;
 +  goto out;
  
-   if (unlikely(error)) {
+   if (unlikely(*error)) {
 +  if (!bio_record->details.bi_bdev) {
 +  /*
 +   * There wasn't enough memory to record necessary
 +   * information for a retry or there was no other
 +   * mirror in-sync.
 +   */
 +  DMERR_LIMIT("Mirror read failed.");
-   return -EIO;
++  return BLK_STS_IOERR;
 +  }
 +
m = bio_record->m;
  
DMERR("Mirror read failed from %s. Trying alternative device.",
@@@ -1290,8 -1278,7 +1291,8 @@@
bd = _record->details;
  
dm_bio_restore(bd, bio);
 +  bio_record->details.bi_bdev = NULL;
-   bio->bi_error = 0;
+   bio->bi_status = 0;
  
queue_bio(ms, bio, rw);
return DM_ENDIO_INCOMPLETE;
@@@ -1299,10 -1286,7 +1300,10 @@@
DMERR("All replicated volumes dead, failing I/O");
}
  
 +out:
 +  bio_record->details.bi_bdev = NULL;
 +
-   return error;
+   return DM_ENDIO_DONE;
  }
  
  static void mirror_presuspend(struct dm_target *ti)


linux-next: manual merge of the block tree with Linus' tree

2017-06-25 Thread Stephen Rothwell
Hi Jens,

Today's linux-next merge of the block tree got a conflict in:

  drivers/md/dm-raid1.c

between commit:

  cd15fb64ee56 ("Revert "dm mirror: use all available legs on multiple 
failures"")

from Linus' tree and commits:

  9966afaf91b3 ("dm: fix REQ_RAHEAD handling")
  1be569098458 ("dm: change ->end_io calling convention")
  4e4cbee93d56 ("block: switch bios to blk_status_t")

from the block tree.

I fixed it up (I think - see below) and can carry the fix as necessary.
This is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/dm-raid1.c
index 4da8858856fb,3ab584b686e0..
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@@ -1255,26 -1253,16 +1256,26 @@@ static int mirror_end_io(struct dm_targ
if (!(bio->bi_opf & REQ_PREFLUSH) &&
bio_op(bio) != REQ_OP_DISCARD)
dm_rh_dec(ms->rh, bio_record->write_region);
-   return error;
+   return DM_ENDIO_DONE;
}
  
-   if (error == -EOPNOTSUPP)
+   if (*error == BLK_STS_NOTSUPP)
 -  return DM_ENDIO_DONE;
 +  goto out;
  
-   if ((error == -EWOULDBLOCK) && (bio->bi_opf & REQ_RAHEAD))
+   if (bio->bi_opf & REQ_RAHEAD)
 -  return DM_ENDIO_DONE;
 +  goto out;
  
-   if (unlikely(error)) {
+   if (unlikely(*error)) {
 +  if (!bio_record->details.bi_bdev) {
 +  /*
 +   * There wasn't enough memory to record necessary
 +   * information for a retry or there was no other
 +   * mirror in-sync.
 +   */
 +  DMERR_LIMIT("Mirror read failed.");
-   return -EIO;
++  return BLK_STS_IOERR;
 +  }
 +
m = bio_record->m;
  
DMERR("Mirror read failed from %s. Trying alternative device.",
@@@ -1290,8 -1278,7 +1291,8 @@@
bd = _record->details;
  
dm_bio_restore(bd, bio);
 +  bio_record->details.bi_bdev = NULL;
-   bio->bi_error = 0;
+   bio->bi_status = 0;
  
queue_bio(ms, bio, rw);
return DM_ENDIO_INCOMPLETE;
@@@ -1299,10 -1286,7 +1300,10 @@@
DMERR("All replicated volumes dead, failing I/O");
}
  
 +out:
 +  bio_record->details.bi_bdev = NULL;
 +
-   return error;
+   return DM_ENDIO_DONE;
  }
  
  static void mirror_presuspend(struct dm_target *ti)


Re: zram hot_add device busy

2017-06-25 Thread Sergey Senozhatsky
Hello,

(Cc Andrew, Karel)

On (06/24/17 11:08), Sami Kerola wrote:
> Hello,
> 
> While going through if there are new util-linux bugs reported I came a
> cross this https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/1645846
> 
> Simple way to reproduce the issue is:
> d=$(cat /sys/class/zram-control/hot_add) && zramctl --size 256M /dev/zram$d
> 
> I am not entirely sure, but drivers/block/zram/zram_drv.c function
> zram_add() should block until the device is usable. Looking the code
> that it might be the device_add_disk() from block/genhd.c that should
> do the blocking. But perhaps it's best if I leave such detail to
> people who know the code a bit better.
> 
> One thing annoys me. I expected 'zramctl --find --size 256M' to suffer
> from same issue but it does not. I can only reproduce the issue when
> triggering hot_add separately, and as quick as possibly using the
> path. Notice that sometimes it takes second try before the hot_add and
> use triggers the issue. That is almost certainly down to speed the
> system in hand, e.g., quicker the computer less likely to trigger.


ok... I don't think I see what we can do in zram about the
issue in question. what I see on my system is that systemd
udevd is racing with zramctl.


so, the "failed" case looks like this


process action

[  761.191697] zram: >>[systemd-udevd]>>> zram_open
^^^ systemd opens the device. we have 
->bd_openers now

[  761.194057] zram: >>[zramctl]>>> reset_store
^^^ fails, because device is opened by 
systemd.
if (bdev->bd_openers || zram->claim) is 
true, we can't reset

[  761.195105] zram: >>[systemd-udevd]>>> zram_release
^^^ now system releases the device

[  761.198655] zram: >>[zramctl]>>> reset_store
^^^ succeeds, because we don't have 
->bd_openers anymore

[  761.198669] zram: >>[zramctl]>>> zram_reset_device
[  761.198721] zram: >>[zramctl]>>> disksize_store
[  761.199279] zram0: detected capacity change from 0 to 268435456


normal case,

process action


[  761.203989] zram: >>[systemd-udevd]>>> zram_open
[  761.204461] zram: >>[systemd-udevd]>>> zram_release
[  761.204940] zram: >>[zramctl]>>> reset_store
[  761.204948] zram: >>[zramctl]>>> zram_reset_device
[  761.204972] zram: >>[zramctl]>>> disksize_store
[  761.205409] zram1: detected capacity change from 0 to 268435456


as you can see, systemd-udevd releases the device before zramctl
attempts to reset it.

-ss


Re: zram hot_add device busy

2017-06-25 Thread Sergey Senozhatsky
Hello,

(Cc Andrew, Karel)

On (06/24/17 11:08), Sami Kerola wrote:
> Hello,
> 
> While going through if there are new util-linux bugs reported I came a
> cross this https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/1645846
> 
> Simple way to reproduce the issue is:
> d=$(cat /sys/class/zram-control/hot_add) && zramctl --size 256M /dev/zram$d
> 
> I am not entirely sure, but drivers/block/zram/zram_drv.c function
> zram_add() should block until the device is usable. Looking the code
> that it might be the device_add_disk() from block/genhd.c that should
> do the blocking. But perhaps it's best if I leave such detail to
> people who know the code a bit better.
> 
> One thing annoys me. I expected 'zramctl --find --size 256M' to suffer
> from same issue but it does not. I can only reproduce the issue when
> triggering hot_add separately, and as quick as possibly using the
> path. Notice that sometimes it takes second try before the hot_add and
> use triggers the issue. That is almost certainly down to speed the
> system in hand, e.g., quicker the computer less likely to trigger.


ok... I don't think I see what we can do in zram about the
issue in question. what I see on my system is that systemd
udevd is racing with zramctl.


so, the "failed" case looks like this


process action

[  761.191697] zram: >>[systemd-udevd]>>> zram_open
^^^ systemd opens the device. we have 
->bd_openers now

[  761.194057] zram: >>[zramctl]>>> reset_store
^^^ fails, because device is opened by 
systemd.
if (bdev->bd_openers || zram->claim) is 
true, we can't reset

[  761.195105] zram: >>[systemd-udevd]>>> zram_release
^^^ now system releases the device

[  761.198655] zram: >>[zramctl]>>> reset_store
^^^ succeeds, because we don't have 
->bd_openers anymore

[  761.198669] zram: >>[zramctl]>>> zram_reset_device
[  761.198721] zram: >>[zramctl]>>> disksize_store
[  761.199279] zram0: detected capacity change from 0 to 268435456


normal case,

process action


[  761.203989] zram: >>[systemd-udevd]>>> zram_open
[  761.204461] zram: >>[systemd-udevd]>>> zram_release
[  761.204940] zram: >>[zramctl]>>> reset_store
[  761.204948] zram: >>[zramctl]>>> zram_reset_device
[  761.204972] zram: >>[zramctl]>>> disksize_store
[  761.205409] zram1: detected capacity change from 0 to 268435456


as you can see, systemd-udevd releases the device before zramctl
attempts to reset it.

-ss


Re: [PATCH v3 0/7] Isolate time_t data types for clock/timer syscalls

2017-06-25 Thread Al Viro
On Sat, Jun 24, 2017 at 11:45:01AM -0700, Deepa Dinamani wrote:
> The series aims at isolating data conversions of time_t based structures:
> struct timespec and struct itimerspec at user space boundaries.
> This helps to later change the underlying types to handle y2038 changes
> to these.

Nice...  A few questions:

* what about setitimer(2)?  Right now that's the only remaining user of
get_compat_itimerval(); similar for getitimer(2) and put_compat_itimerval().

* you have two callers of get_compat_itimerspec64(); one is followed by
itimerspec64_valid(), another - by its open-coded analogue.  The same
goes for get_itimerspec64(); wouldn't it be better to have both check
the validity immediately and simply fail with -EINVAL?  Matter of taste,
but...

* should __sys_recvmmsg() switch to timespec64?


Re: [PATCH v3 0/7] Isolate time_t data types for clock/timer syscalls

2017-06-25 Thread Al Viro
On Sat, Jun 24, 2017 at 11:45:01AM -0700, Deepa Dinamani wrote:
> The series aims at isolating data conversions of time_t based structures:
> struct timespec and struct itimerspec at user space boundaries.
> This helps to later change the underlying types to handle y2038 changes
> to these.

Nice...  A few questions:

* what about setitimer(2)?  Right now that's the only remaining user of
get_compat_itimerval(); similar for getitimer(2) and put_compat_itimerval().

* you have two callers of get_compat_itimerspec64(); one is followed by
itimerspec64_valid(), another - by its open-coded analogue.  The same
goes for get_itimerspec64(); wouldn't it be better to have both check
the validity immediately and simply fail with -EINVAL?  Matter of taste,
but...

* should __sys_recvmmsg() switch to timespec64?


linux-next: manual merge of the block tree with Linus' tree

2017-06-25 Thread Stephen Rothwell
Hi Jens,

Today's linux-next merge of the block tree got a conflict in:

  drivers/md/dm-io.c

between commit:

  feb7695fe9fb ("dm io: fix duplicate bio completion due to missing ref count")

from Linus' tree and commit:

  4e4cbee93d56 ("block: switch bios to blk_status_t")

from the block tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/dm-io.c
index 8d5ca30f6551,81248a8a8b57..
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@@ -317,9 -318,9 +318,9 @@@ static void do_region(int op, int op_fl
else if (op == REQ_OP_WRITE_SAME)
special_cmd_max_sectors = q->limits.max_write_same_sectors;
if ((op == REQ_OP_DISCARD || op == REQ_OP_WRITE_ZEROES ||
 -   op == REQ_OP_WRITE_SAME)  &&
 -  special_cmd_max_sectors == 0) {
 +   op == REQ_OP_WRITE_SAME) && special_cmd_max_sectors == 0) {
 +  atomic_inc(>count);
-   dec_count(io, region, -EOPNOTSUPP);
+   dec_count(io, region, BLK_STS_NOTSUPP);
return;
}
  


linux-next: manual merge of the block tree with Linus' tree

2017-06-25 Thread Stephen Rothwell
Hi Jens,

Today's linux-next merge of the block tree got a conflict in:

  drivers/md/dm-io.c

between commit:

  feb7695fe9fb ("dm io: fix duplicate bio completion due to missing ref count")

from Linus' tree and commit:

  4e4cbee93d56 ("block: switch bios to blk_status_t")

from the block tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/dm-io.c
index 8d5ca30f6551,81248a8a8b57..
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@@ -317,9 -318,9 +318,9 @@@ static void do_region(int op, int op_fl
else if (op == REQ_OP_WRITE_SAME)
special_cmd_max_sectors = q->limits.max_write_same_sectors;
if ((op == REQ_OP_DISCARD || op == REQ_OP_WRITE_ZEROES ||
 -   op == REQ_OP_WRITE_SAME)  &&
 -  special_cmd_max_sectors == 0) {
 +   op == REQ_OP_WRITE_SAME) && special_cmd_max_sectors == 0) {
 +  atomic_inc(>count);
-   dec_count(io, region, -EOPNOTSUPP);
+   dec_count(io, region, BLK_STS_NOTSUPP);
return;
}
  


Re: zram hot_add device busy

2017-06-25 Thread Minchan Kim
Hello,

On Sat, Jun 24, 2017 at 11:08:01AM +0100, Sami Kerola wrote:
> Hello,
> 
> While going through if there are new util-linux bugs reported I came a
> cross this https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/1645846
> 
> Simple way to reproduce the issue is:
> d=$(cat /sys/class/zram-control/hot_add) && zramctl --size 256M /dev/zram$d

To know the problem comes from any side, could you test it without zramctl
command?

IOW,
d=$(cat /sys/class/zram-control/hot_add) && echo $((256<<20)) 
/dev/zram$d

If it still has a problem, please show your test code which helps
understanding of fundamental problem a lot. ;-)

> 
> I am not entirely sure, but drivers/block/zram/zram_drv.c function
> zram_add() should block until the device is usable. Looking the code
> that it might be the device_add_disk() from block/genhd.c that should
> do the blocking. But perhaps it's best if I leave such detail to
> people who know the code a bit better.

I might miss something but I believe device is usable state after zram_add done.
Just in case, please test return value after some operation.

if [ $? -ne 0  ];
then
echo "fail to some op"
blah blah
fi

Thanks.

> 
> One thing annoys me. I expected 'zramctl --find --size 256M' to suffer
> from same issue but it does not. I can only reproduce the issue when
> triggering hot_add separately, and as quick as possibly using the
> path. Notice that sometimes it takes second try before the hot_add and
> use triggers the issue. That is almost certainly down to speed the
> system in hand, e.g., quicker the computer less likely to trigger.
> 
> -- 
> Sami Kerola
> http://www.iki.fi/kerolasa/


Re: zram hot_add device busy

2017-06-25 Thread Minchan Kim
Hello,

On Sat, Jun 24, 2017 at 11:08:01AM +0100, Sami Kerola wrote:
> Hello,
> 
> While going through if there are new util-linux bugs reported I came a
> cross this https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/1645846
> 
> Simple way to reproduce the issue is:
> d=$(cat /sys/class/zram-control/hot_add) && zramctl --size 256M /dev/zram$d

To know the problem comes from any side, could you test it without zramctl
command?

IOW,
d=$(cat /sys/class/zram-control/hot_add) && echo $((256<<20)) 
/dev/zram$d

If it still has a problem, please show your test code which helps
understanding of fundamental problem a lot. ;-)

> 
> I am not entirely sure, but drivers/block/zram/zram_drv.c function
> zram_add() should block until the device is usable. Looking the code
> that it might be the device_add_disk() from block/genhd.c that should
> do the blocking. But perhaps it's best if I leave such detail to
> people who know the code a bit better.

I might miss something but I believe device is usable state after zram_add done.
Just in case, please test return value after some operation.

if [ $? -ne 0  ];
then
echo "fail to some op"
blah blah
fi

Thanks.

> 
> One thing annoys me. I expected 'zramctl --find --size 256M' to suffer
> from same issue but it does not. I can only reproduce the issue when
> triggering hot_add separately, and as quick as possibly using the
> path. Notice that sometimes it takes second try before the hot_add and
> use triggers the issue. That is almost certainly down to speed the
> system in hand, e.g., quicker the computer less likely to trigger.
> 
> -- 
> Sami Kerola
> http://www.iki.fi/kerolasa/


Re: linux-next: build failure after merge of the i2c tree

2017-06-25 Thread Shawn Guo
Hi Stephen,

On Mon, Jun 26, 2017 at 11:09:07AM +1000, Stephen Rothwell wrote:
> Hi Wolfram,
> 
> After merging the i2c tree, today's linux-next build (x86_64 allmodconfig)
> failed like this:
> 
> drivers/i2c/busses/i2c-zx2967.c: In function 'zx2967_i2c_writesb':
> drivers/i2c/busses/i2c-zx2967.c:87:2: error: implicit declaration of function 
> 'writesb' [-Werror=implicit-function-declaration]
>   writesb(i2c->reg_base + reg, data, len);
>   ^
> drivers/i2c/busses/i2c-zx2967.c: In function 'zx2967_i2c_readsb':
> drivers/i2c/busses/i2c-zx2967.c:93:2: error: implicit declaration of function 
> 'readsb' [-Werror=implicit-function-declaration]
>   readsb(i2c->reg_base + reg, data, len);
>   ^
> 
> Caused by commit
> 
>   9615a01f71ca ("i2c: zx2967: add i2c controller driver for ZTE's zx2967 
> family")
> 
> Forgotten some include file, presumably.  And COMPILE_TEST may have
> been a bit hopeful :-)

Thanks for reporting it.  I have sent a fix [1] for it yesterday, which
hopefully will be applied soon.

Shawn

[1] https://patchwork.ozlabs.org/patch/780357/


Re: linux-next: build failure after merge of the i2c tree

2017-06-25 Thread Shawn Guo
Hi Stephen,

On Mon, Jun 26, 2017 at 11:09:07AM +1000, Stephen Rothwell wrote:
> Hi Wolfram,
> 
> After merging the i2c tree, today's linux-next build (x86_64 allmodconfig)
> failed like this:
> 
> drivers/i2c/busses/i2c-zx2967.c: In function 'zx2967_i2c_writesb':
> drivers/i2c/busses/i2c-zx2967.c:87:2: error: implicit declaration of function 
> 'writesb' [-Werror=implicit-function-declaration]
>   writesb(i2c->reg_base + reg, data, len);
>   ^
> drivers/i2c/busses/i2c-zx2967.c: In function 'zx2967_i2c_readsb':
> drivers/i2c/busses/i2c-zx2967.c:93:2: error: implicit declaration of function 
> 'readsb' [-Werror=implicit-function-declaration]
>   readsb(i2c->reg_base + reg, data, len);
>   ^
> 
> Caused by commit
> 
>   9615a01f71ca ("i2c: zx2967: add i2c controller driver for ZTE's zx2967 
> family")
> 
> Forgotten some include file, presumably.  And COMPILE_TEST may have
> been a bit hopeful :-)

Thanks for reporting it.  I have sent a fix [1] for it yesterday, which
hopefully will be applied soon.

Shawn

[1] https://patchwork.ozlabs.org/patch/780357/


[PATCH v2 04/22] fpga: mgr: add region_id to fpga_image_info

2017-06-25 Thread Wu Hao
This patch adds region_id to fpga_image_info data structure, it
allows driver to pass region id information to fpga-mgr via
fpga_image_info for fpga reconfiguration function.

Signed-off-by: Wu Hao 
---
 include/linux/fpga/fpga-mgr.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
index 66d0e32..b222a57 100644
--- a/include/linux/fpga/fpga-mgr.h
+++ b/include/linux/fpga/fpga-mgr.h
@@ -95,6 +95,7 @@ struct fpga_image_info {
struct sg_table *sgt;
const char *buf;
size_t count;
+   int region_id;
 #ifdef CONFIG_OF
struct device_node *overlay;
 #endif
-- 
1.8.3.1



[PATCH v2 04/22] fpga: mgr: add region_id to fpga_image_info

2017-06-25 Thread Wu Hao
This patch adds region_id to fpga_image_info data structure, it
allows driver to pass region id information to fpga-mgr via
fpga_image_info for fpga reconfiguration function.

Signed-off-by: Wu Hao 
---
 include/linux/fpga/fpga-mgr.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
index 66d0e32..b222a57 100644
--- a/include/linux/fpga/fpga-mgr.h
+++ b/include/linux/fpga/fpga-mgr.h
@@ -95,6 +95,7 @@ struct fpga_image_info {
struct sg_table *sgt;
const char *buf;
size_t count;
+   int region_id;
 #ifdef CONFIG_OF
struct device_node *overlay;
 #endif
-- 
1.8.3.1



[PATCH v2 06/22] fpga: intel: add FPGA PCIe device driver

2017-06-25 Thread Wu Hao
From: Zhang Yi 

The Intel FPGA device appears as a PCIe device on the system. This patch
implements the basic framework of the driver for Intel PCIe device which
locates between CPU and Accelerated Function Units (AFUs).

Signed-off-by: Tim Whisonant 
Signed-off-by: Enno Luebbers 
Signed-off-by: Shiva Rao 
Signed-off-by: Christopher Rauer 
Signed-off-by: Zhang Yi 
Signed-off-by: Xiao Guangrong 
Signed-off-by: Wu Hao 
---
v2: moved the code to drivers/fpga folder as suggested by Alan Tull.
switched to GPLv2 license.
fixed comments from Moritz Fischer.
---
 drivers/fpga/Kconfig  |  28 +++
 drivers/fpga/Makefile |   5 ++
 drivers/fpga/intel-pcie.c | 126 ++
 3 files changed, 159 insertions(+)
 create mode 100644 drivers/fpga/intel-pcie.c

diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig
index c1d8f41..3f3b7f4 100644
--- a/drivers/fpga/Kconfig
+++ b/drivers/fpga/Kconfig
@@ -117,6 +117,34 @@ config XILINX_PR_DECOUPLER
  region of the FPGA from the busses while that region is
  being reprogrammed during partial reconfig.
 
+menuconfig INTEL_FPGA
+   tristate "Intel(R) FPGA support"
+   depends on FPGA_DEVICE
+   help
+ Select this option to enable driver support for Intel(R)
+ Field-Programmable Gate Array (FPGA) solutions. This driver
+ provides interfaces for userspace applications to configure,
+ enumerate, open, and access FPGA accelerators on platforms
+ equipped with Intel(R) FPGA solutions and enables system
+ level management functions such as FPGA reconfiguration,
+ power management, and virtualization.
+
+ Say Y if your platform has this technology. Say N if unsure.
+
+if INTEL_FPGA
+
+config INTEL_FPGA_PCI
+   tristate "Intel FPGA PCIe Driver"
+   depends on PCI
+   help
+ This is the driver for the PCIe device which locates between
+ CPU and Accelerated Function Units (AFUs) and allows them to
+ communicate with each other.
+
+ To compile this as a module, choose M here.
+
+endif
+
 endif # FPGA
 
 endmenu
diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile
index 8950a8f..5613133 100644
--- a/drivers/fpga/Makefile
+++ b/drivers/fpga/Makefile
@@ -27,3 +27,8 @@ obj-$(CONFIG_XILINX_PR_DECOUPLER) += xilinx-pr-decoupler.o
 # High Level Interfaces
 obj-$(CONFIG_FPGA_REGION)  += fpga-region.o
 obj-$(CONFIG_OF_FPGA_REGION)   += of-fpga-region.o
+
+# Intel FPGA Support
+obj-$(CONFIG_INTEL_FPGA_PCI)   += intel-fpga-pci.o
+
+intel-fpga-pci-objs := intel-pcie.o
diff --git a/drivers/fpga/intel-pcie.c b/drivers/fpga/intel-pcie.c
new file mode 100644
index 000..f697de4
--- /dev/null
+++ b/drivers/fpga/intel-pcie.c
@@ -0,0 +1,126 @@
+/*
+ * Driver for Intel FPGA PCIe device
+ *
+ * Copyright (C) 2017 Intel Corporation, Inc.
+ *
+ * Authors:
+ *   Zhang Yi 
+ *   Xiao Guangrong 
+ *   Joseph Grecco 
+ *   Enno Luebbers 
+ *   Tim Whisonant 
+ *   Ananda Ravuri 
+ *   Henry Mitchel 
+ *
+ * This work is licensed under the terms of the GNU GPL version 2. See
+ * the COPYING file in the top-level directory.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DRV_VERSION"0.8"
+#define DRV_NAME   "intel-fpga-pci"
+
+/* PCI Device ID */
+#define PCIe_DEVICE_ID_PF_INT_5_X  0xBCBD
+#define PCIe_DEVICE_ID_PF_INT_6_X  0xBCC0
+#define PCIe_DEVICE_ID_PF_DSC_1_X  0x09C4
+/* VF Device */
+#define PCIe_DEVICE_ID_VF_INT_5_X  0xBCBF
+#define PCIe_DEVICE_ID_VF_INT_6_X  0xBCC1
+#define PCIe_DEVICE_ID_VF_DSC_1_X  0x09C5
+
+static struct pci_device_id cci_pcie_id_tbl[] = {
+   {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIe_DEVICE_ID_PF_INT_5_X),},
+   {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIe_DEVICE_ID_VF_INT_5_X),},
+   {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIe_DEVICE_ID_PF_INT_6_X),},
+   {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIe_DEVICE_ID_VF_INT_6_X),},
+   {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIe_DEVICE_ID_PF_DSC_1_X),},
+   {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIe_DEVICE_ID_VF_DSC_1_X),},
+   {0,}
+};
+MODULE_DEVICE_TABLE(pci, cci_pcie_id_tbl);
+
+static
+int cci_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *pcidevid)
+{
+   int ret;
+
+   ret = pci_enable_device(pcidev);
+   if (ret < 0) {
+   dev_err(>dev, "Failed to enable device %d.\n", ret);
+   return ret;
+   }
+
+   ret = pci_enable_pcie_error_reporting(pcidev);
+   if (ret && ret != -EINVAL)
+   dev_info(>dev, 

[PATCH v2 08/22] fpga: intel: pcie: add chardev support for feature devices

2017-06-25 Thread Wu Hao
From: Xiao Guangrong 

For feature devices drivers, both the FPGA Management Engine (FME) and
Accelerated Function Unit (AFU) driver need to expose user interfaces via
the device file, for example, mmap and ioctls.

This patch adds chardev support in the pcie driver for feature devices,
FME and AFU. It reserves the chardev regions for FME and AFU, and provide
interfaces for FME and AFU driver to register their device file operations.

Signed-off-by: Tim Whisonant 
Signed-off-by: Enno Luebbers 
Signed-off-by: Shiva Rao 
Signed-off-by: Christopher Rauer 
Signed-off-by: Zhang Yi 
Signed-off-by: Xiao Guangrong 
Signed-off-by: Wu Hao 
---
v2: rebased
---
 drivers/fpga/intel-feature-dev.c | 76 
 drivers/fpga/intel-feature-dev.h | 16 +
 drivers/fpga/intel-pcie.c| 18 +-
 3 files changed, 109 insertions(+), 1 deletion(-)

diff --git a/drivers/fpga/intel-feature-dev.c b/drivers/fpga/intel-feature-dev.c
index 68f9cba..45788fe 100644
--- a/drivers/fpga/intel-feature-dev.c
+++ b/drivers/fpga/intel-feature-dev.c
@@ -51,6 +51,82 @@ int port_feature_num(void)
return PORT_FEATURE_ID_MAX;
 }
 
+struct fpga_chardev_info {
+   const char *name;
+   dev_t devt;
+};
+
+/* indexed by enum fpga_devt_type */
+struct fpga_chardev_info fpga_chrdevs[] = {
+   {.name = FPGA_FEATURE_DEV_FME}, /* FPGA_DEVT_FME */
+   {.name = FPGA_FEATURE_DEV_PORT},/* FPGA_DEVT_AFU */
+};
+
+void fpga_chardev_uinit(void)
+{
+   int i;
+
+   for (i = 0; i < FPGA_DEVT_MAX; i++)
+   if (MAJOR(fpga_chrdevs[i].devt)) {
+   unregister_chrdev_region(fpga_chrdevs[i].devt,
+MINORMASK);
+   fpga_chrdevs[i].devt = MKDEV(0, 0);
+   }
+}
+
+int fpga_chardev_init(void)
+{
+   int i, ret;
+
+   for (i = 0; i < FPGA_DEVT_MAX; i++) {
+   ret = alloc_chrdev_region(_chrdevs[i].devt, 0, MINORMASK,
+ fpga_chrdevs[i].name);
+   if (ret)
+   goto exit;
+   }
+
+   return 0;
+
+exit:
+   fpga_chardev_uinit();
+   return ret;
+}
+
+dev_t fpga_get_devt(enum fpga_devt_type type, int id)
+{
+   WARN_ON(type >= FPGA_DEVT_MAX);
+
+   return MKDEV(MAJOR(fpga_chrdevs[type].devt), id);
+}
+
+int fpga_register_dev_ops(struct platform_device *pdev,
+ const struct file_operations *fops,
+ struct module *owner)
+{
+   struct feature_platform_data *pdata = dev_get_platdata(>dev);
+
+   cdev_init(>cdev, fops);
+   pdata->cdev.owner = owner;
+
+   /*
+* set parent to the feature device so that its refcount is
+* decreased after the last refcount of cdev is gone, that
+* makes sure the feature device is valid during device
+* file's life-cycle.
+*/
+   pdata->cdev.kobj.parent = >dev.kobj;
+   return cdev_add(>cdev, pdev->dev.devt, 1);
+}
+EXPORT_SYMBOL_GPL(fpga_register_dev_ops);
+
+void fpga_unregister_dev_ops(struct platform_device *pdev)
+{
+   struct feature_platform_data *pdata = dev_get_platdata(>dev);
+
+   cdev_del(>cdev);
+}
+EXPORT_SYMBOL_GPL(fpga_unregister_dev_ops);
+
 int fpga_port_id(struct platform_device *pdev)
 {
struct feature_port_header *port_hdr;
diff --git a/drivers/fpga/intel-feature-dev.h b/drivers/fpga/intel-feature-dev.h
index f67784a..d64a51e 100644
--- a/drivers/fpga/intel-feature-dev.h
+++ b/drivers/fpga/intel-feature-dev.h
@@ -17,6 +17,7 @@
 #define __INTEL_FPGA_FEATURE_H
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -230,6 +231,7 @@ struct feature_platform_data {
/* list the feature dev to cci_drvdata->port_dev_list. */
struct list_head node;
struct mutex lock;
+   struct cdev cdev;
struct platform_device *dev;
unsigned int disable_count; /* count for port disable */
 
@@ -276,6 +278,20 @@ static inline int feature_platform_data_size(const int num)
 struct feature_platform_data *
 feature_platform_data_alloc_and_init(struct platform_device *dev, int num);
 
+enum fpga_devt_type {
+   FPGA_DEVT_FME,
+   FPGA_DEVT_PORT,
+   FPGA_DEVT_MAX,
+};
+
+void fpga_chardev_uinit(void);
+int fpga_chardev_init(void);
+dev_t fpga_get_devt(enum fpga_devt_type type, int id);
+int fpga_register_dev_ops(struct platform_device *pdev,
+ const struct file_operations *fops,
+ struct module *owner);
+void fpga_unregister_dev_ops(struct platform_device *pdev);
+
 int fpga_port_id(struct platform_device *pdev);
 
 static inline int fpga_port_check_id(struct platform_device *pdev,
diff --git 

  1   2   3   4   5   6   >