Re: [HPDD-discuss] [PATCH 15/16] staging: lustre: lnet: lnet: fix error return code

2015-04-05 Thread Zhen, Liang
Julia, yes this is a bug that we have already fixed in the latest Lustre.
Sorry we havenĀ¹t submitted this patch to kernel on time.

Thanks
Liang

On 4/5/15, 8:06 PM, "Julia Lawall"  wrote:

>Return a negative error code on failure.
>
>A simplified version of the semantic match that finds this problem is as
>follows: (http://coccinelle.lip6.fr/)
>
>// 
>@@
>identifier ret; expression e1,e2;
>@@
>(
>if (\(ret < 0\|ret != 0\))
> { ... return ret; }
>|
>ret = 0
>)
>... when != ret = e1
>when != &ret
>*if(...)
>{
>  ... when != ret = e2
>  when forall
> return ret;
>}
>// 
>
>Signed-off-by: Julia Lawall 
>
>---
> drivers/staging/lustre/lnet/lnet/api-ni.c |8 ++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c
>b/drivers/staging/lustre/lnet/lnet/api-ni.c
>index faceb95..4a14e51 100644
>--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
>+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
>@@ -650,15 +650,19 @@ lnet_prepare(lnet_pid_t requested_pid)
> 
>   recs = lnet_res_containers_create(LNET_COOKIE_TYPE_ME, LNET_FL_MAX_MES,
> sizeof(lnet_me_t));
>-  if (recs == NULL)
>+  if (recs == NULL) {
>+  rc = -ENOMEM;
>   goto failed;
>+  }
> 
>   the_lnet.ln_me_containers = recs;
> 
>   recs = lnet_res_containers_create(LNET_COOKIE_TYPE_MD, LNET_FL_MAX_MDS,
> sizeof(lnet_libmd_t));
>-  if (recs == NULL)
>+  if (recs == NULL) {
>+  rc = -ENOMEM;
>   goto failed;
>+  }
> 
>   the_lnet.ln_md_containers = recs;
> 
>
>___
>HPDD-discuss mailing list
>hpdd-disc...@lists.01.org
>https://lists.01.org/mailman/listinfo/hpdd-discuss

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] time: allow gcc to fold constants when using msecs_to_jiffies

2015-04-05 Thread Nicholas Mc Guire
On Sun, 05 Apr 2015, Joe Perches wrote:

> On Mon, 2015-04-06 at 06:26 +0200, Nicholas Mc Guire wrote:
> > On Sun, 05 Apr 2015, Joe Perches wrote:
> > > Try it and look at the generated .lst files with and
> > > without the patch I sent.
> []
> > from all that I understood it should
> > be doable both as macro and inline.
> 
> I think it _should_ be doable too but I also think
> the only reason gcc doesn't optimize the inline
> is because gcc's optimizer isn't good enough yet.
> 

"unfortunately" I can't blame it on gcc - here is the initial toy-case 
- test.c and either testi.h or testm.h included
- m = TIMEOUT or m = atoi(argv[1]);
both in the inline and the macro case gcc reduced the code to a single 
load mediate or register instruction for the constant - so the optimizer
is doing its job.

test.c:
#include 
#define HZ 100
#define MSECS_PER_SEC 1000
#define TIMEOUT 100
#include "testi.h"  /* inline msecs_to_jiffies */
//#include "testm.h"/* macro versions */

int main(int argc, char **argv) {
//int m = atoi(argv[0]);/* non-const */
int m = TIMEOUT;/* const */
printf("%lu\n",msecs_to_jiffies(m));
return 0;
}

testm.h:

#define msecs_to_jiffies(m) \
  (__builtin_constant_p (m) \
  ? ((m) * HZ / MSECS_PER_SEC ) : __msecs_to_jiffies(m))

unsigned long __msecs_to_jiffies(int m)
{
return m * HZ / MSECS_PER_SEC ;
}

first case with a non-const
main:
.LFB12:
.cfi_startproc
subq$8, %rsp#,
.cfi_def_cfa_offset 16
movq8(%rsi), %rdi   # MEM[(char * *)argv_2(D) + 8B], MEM[(char * 
*)argv_2(D) + 8B]
xorl%eax, %eax  #
callatoi#
movl$1717986919, %edx   #, tmp69
movl%eax, %ecx  #, m
movl$.LC0, %edi #,
imull   %edx# tmp69
sarl$31, %ecx   #, tmp71
xorl%eax, %eax  #
sarl$2, %edx#, tmp67
subl%ecx, %edx  # tmp71, tmp67
movslq  %edx, %rsi  # tmp67, tmp72
callprintf  #

o
second with a constant:
main:
.LFB12:
.cfi_startproc
subq$8, %rsp#,
.cfi_def_cfa_offset 16
movl$10, %esi   #,
movl$.LC0, %edi #,
xorl%eax, %eax  #
callprintf  #


inline:
---

testi.h:
static inline unsigned long __msecs_to_jiffies(int m)
{
return m * HZ / MSECS_PER_SEC;
}

static inline unsigned long msecs_to_jiffies(int m)
{
return __builtin_constant_p (m) ?
(m) * HZ / MSECS_PER_SEC  : __msecs_to_jiffies(m);
}

first case with a non-const
main:
.LFB13:
.cfi_startproc
subq$8, %rsp#,
.cfi_def_cfa_offset 16
movq(%rsi), %rdi# *argv_1(D),
xorl%eax, %eax  #
callatoi#
movl$1717986919, %edx   #, tmp68
movl%eax, %ecx  #, m
movl$.LC0, %edi #,
imull   %edx# tmp68
sarl$31, %ecx   #, tmp70
xorl%eax, %eax  #
sarl$2, %edx#, tmp66
subl%ecx, %edx  # tmp70, tmp66
movslq  %edx, %rsi  # tmp66, tmp71
callprintf  #

second with a constant:
main:
.LFB13:
.cfi_startproc
subq$8, %rsp#,
.cfi_def_cfa_offset 16
xorl%esi, %esi  #
movl$.LC0, %edi #,
xorl%eax, %eax  #
callprintf  #

giving it another run from scratch somewhere I simply screwed up or 
overlooked some detail.

thx!
hofrat
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 02/86] i2c/i801: linux/pci_ids.h -> uapi/linux/pci_ids.h

2015-04-05 Thread Jean Delvare
Hi Wolfram,

On Fri, 3 Apr 2015 21:09:17 +0200, Wolfram Sang wrote:
> On Sun, Mar 29, 2015 at 03:37:30PM +0200, Michael S. Tsirkin wrote:
> > Header moved from linux/pci_ids.h to uapi/linux/pci_ids.h,
> > update i2c documentation accordingly.
> > 
> > Signed-off-by: Michael S. Tsirkin 
> 
> Acked-by: Wolfram Sang 
> 
> I don't know if I should take it. If so, let me know.

Don't, the series was nacked meanwhile.

Thanks,
-- 
Jean Delvare
SUSE L3 Support
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] ath9k_htc: check seq number instead of cmd id for timeout

2015-04-05 Thread Fred Chou
Hi all,

May I have an update on the patch status please?

Thanks and regards,
Fred

On 13/3/2015 4:32 PM, Fred Chou wrote:
> From: Fred Chou 
> 
> As the driver may send multiple wmi commands with identical cmd id,
> it is more robust to check seq number for timeout instead.
> 
> Signed-off-by: Fred Chou 
> ---
>  drivers/net/wireless/ath/ath9k/wmi.c | 12 ++--
>  drivers/net/wireless/ath/ath9k/wmi.h |  2 +-
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/wmi.c 
> b/drivers/net/wireless/ath/ath9k/wmi.c
> index 65c8894..aba909f 100644
> --- a/drivers/net/wireless/ath/ath9k/wmi.c
> +++ b/drivers/net/wireless/ath/ath9k/wmi.c
> @@ -224,7 +224,7 @@ static void ath9k_wmi_ctrl_rx(void *priv, struct sk_buff 
> *skb,
>  
>   /* Check if there has been a timeout. */
>   spin_lock(&wmi->wmi_lock);
> - if (cmd_id != wmi->last_cmd_id) {
> + if (be16_to_cpu(hdr->seq_no) != wmi->last_seq_id) {
>   spin_unlock(&wmi->wmi_lock);
>   goto free_skb;
>   }
> @@ -272,11 +272,16 @@ static int ath9k_wmi_cmd_issue(struct wmi *wmi,
>  enum wmi_cmd_id cmd, u16 len)
>  {
>   struct wmi_cmd_hdr *hdr;
> + unsigned long flags;
>  
>   hdr = (struct wmi_cmd_hdr *) skb_push(skb, sizeof(struct wmi_cmd_hdr));
>   hdr->command_id = cpu_to_be16(cmd);
>   hdr->seq_no = cpu_to_be16(++wmi->tx_seq_id);
>  
> + spin_lock_irqsave(&wmi->wmi_lock, flags);
> + wmi->last_seq_id = wmi->tx_seq_id;
> + spin_unlock_irqrestore(&wmi->wmi_lock, flags);
> +
>   return htc_send_epid(wmi->htc, skb, wmi->ctrl_epid);
>  }
>  
> @@ -292,7 +297,6 @@ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id,
>   struct sk_buff *skb;
>   u8 *data;
>   int time_left, ret = 0;
> - unsigned long flags;
>  
>   if (ah->ah_flags & AH_UNPLUGGED)
>   return 0;
> @@ -320,10 +324,6 @@ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id 
> cmd_id,
>   wmi->cmd_rsp_buf = rsp_buf;
>   wmi->cmd_rsp_len = rsp_len;
>  
> - spin_lock_irqsave(&wmi->wmi_lock, flags);
> - wmi->last_cmd_id = cmd_id;
> - spin_unlock_irqrestore(&wmi->wmi_lock, flags);
> -
>   ret = ath9k_wmi_cmd_issue(wmi, skb, cmd_id, cmd_len);
>   if (ret)
>   goto out;
> diff --git a/drivers/net/wireless/ath/ath9k/wmi.h 
> b/drivers/net/wireless/ath/ath9k/wmi.h
> index 0db37f2..2aad6dc 100644
> --- a/drivers/net/wireless/ath/ath9k/wmi.h
> +++ b/drivers/net/wireless/ath/ath9k/wmi.h
> @@ -143,7 +143,7 @@ struct wmi {
>   enum htc_endpoint_id ctrl_epid;
>   struct mutex op_mutex;
>   struct completion cmd_wait;
> - enum wmi_cmd_id last_cmd_id;
> + u16 last_seq_id;
>   struct sk_buff_head wmi_event_queue;
>   struct tasklet_struct wmi_event_tasklet;
>   u16 tx_seq_id;
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


My name is Gatan Magsino

2015-04-05 Thread Adriaansen, B.C.


My name is Gatan Magsino, I work with Mediterranean Bank in Malta. Can i trust 
you with a business worth 8.3 million USD? Please reply ONLY to my private 
email: ta...@rogers.com for more information.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/9] perf kmem: Support sort keys on page analysis

2015-04-05 Thread Namhyung Kim
Add new sort keys for page: page, order, migtype, gfp - existing
'bytes', 'hit' and 'callsite' sort keys also work for page.  Note that
-s/--sort option should be preceded by either of --slab or --page
option to determine where the sort keys applies.

Now it properly groups and sorts allocation stats - so same
page/caller with different order/migtype/gfp will be printed on a
different line.

  # perf kmem stat --page --caller -l 10 -s order,hit

  

   Total alloc (KB) |  Hits | Order | Mig.type | GFP flags | Callsite
  

 64 | 4 | 2 |  RECLAIM |  00285250 | new_slab
 50,144 |12,536 | 0 |  MOVABLE |  0102005a | 
__page_cache_alloc
 52 |13 | 0 | UNMOVABL |  002084d0 | pte_alloc_one
 40 |10 | 0 |  MOVABLE |  000280da | handle_mm_fault
 28 | 7 | 0 | UNMOVABL |  00d0 | __pollwait
 20 | 5 | 0 |  MOVABLE |  000200da | do_wp_page
 20 | 5 | 0 |  MOVABLE |  000200da | do_cow_fault
 16 | 4 | 0 | UNMOVABL |  0200 | 
__tlb_remove_page
 16 | 4 | 0 | UNMOVABL |  84d0 | __pmd_alloc
  8 | 2 | 0 | UNMOVABL |  84d0 | __pud_alloc
   ...  | ...   | ...   | ...  | ...   | ...
  


Signed-off-by: Namhyung Kim 
---
 tools/perf/Documentation/perf-kmem.txt |   6 +-
 tools/perf/builtin-kmem.c  | 398 ++---
 2 files changed, 317 insertions(+), 87 deletions(-)

diff --git a/tools/perf/Documentation/perf-kmem.txt 
b/tools/perf/Documentation/perf-kmem.txt
index 23219c65c16f..69e181272c51 100644
--- a/tools/perf/Documentation/perf-kmem.txt
+++ b/tools/perf/Documentation/perf-kmem.txt
@@ -37,7 +37,11 @@ OPTIONS
 
 -s ::
 --sort=::
-   Sort the output (default: frag,hit,bytes)
+   Sort the output (default: 'frag,hit,bytes' for slab and 'bytes,hit'
+   for page).  Available sort keys are 'ptr, callsite, bytes, hit,
+   pingpong, frag' for slab and 'page, callsite, bytes, hit, order,
+   migtype, gfp' for page.  This option should be preceded by one of the
+   mode selection options - i.e. --slab, --page, --alloc and/or --caller.
 
 -l ::
 --line=::
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 5b3ed17c293a..719aaf782116 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -30,7 +30,7 @@ static intkmem_page;
 static longkmem_page_size;
 
 struct alloc_stat;
-typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *);
+typedef int (*sort_fn_t)(void *, void *);
 
 static int alloc_flag;
 static int caller_flag;
@@ -181,8 +181,8 @@ static int perf_evsel__process_alloc_node_event(struct 
perf_evsel *evsel,
return ret;
 }
 
-static int ptr_cmp(struct alloc_stat *, struct alloc_stat *);
-static int callsite_cmp(struct alloc_stat *, struct alloc_stat *);
+static int ptr_cmp(void *, void *);
+static int slab_callsite_cmp(void *, void *);
 
 static struct alloc_stat *search_alloc_stat(unsigned long ptr,
unsigned long call_site,
@@ -223,7 +223,8 @@ static int perf_evsel__process_free_event(struct perf_evsel 
*evsel,
s_alloc->pingpong++;
 
s_caller = search_alloc_stat(0, s_alloc->call_site,
-&root_caller_stat, callsite_cmp);
+&root_caller_stat,
+slab_callsite_cmp);
if (!s_caller)
return -1;
s_caller->pingpong++;
@@ -397,6 +398,7 @@ static u64 find_callsite(struct perf_evsel *evsel, struct 
perf_sample *sample)
return sample->ip;
 }
 
+
 static struct page_stat *search_page(u64 page, bool create)
 {
struct rb_node **node = &page_tree.rb_node;
@@ -432,40 +434,35 @@ static struct page_stat *search_page(u64 page, bool 
create)
return data;
 }
 
-static int page_stat_cmp(struct page_stat *a, struct page_stat *b)
-{
-   if (a->page > b->page)
-   return -1;
-   if (a->page < b->page)
-   return 1;
-   if (a->order > b->order)
-   return -1;
-   if (a->order < b->order)
-   return 1;
-   if (a->migrate_type > b->migrate_type)
-   return -1;
-   if (a->migrate_type < b->migrate_type)
-   return 1;
-   if (a->gfp_flags > b->gfp_flags)
-   return -1;
-   if (a->gfp_flags < b->gfp_flags)
-   return 1;

[PATCH 6/9] perf kmem: Add --live option for current allocation stat

2015-04-05 Thread Namhyung Kim
Currently perf kmem shows total (page) allocation stat by default, but
sometimes one might want to see live (total alloc-only) requests/pages
only.  The new --live option does this by subtracting freed allocation
from the stat.

Signed-off-by: Namhyung Kim 
---
 tools/perf/Documentation/perf-kmem.txt |   5 ++
 tools/perf/builtin-kmem.c  | 103 -
 2 files changed, 69 insertions(+), 39 deletions(-)

diff --git a/tools/perf/Documentation/perf-kmem.txt 
b/tools/perf/Documentation/perf-kmem.txt
index 69e181272c51..ff0f433b3fce 100644
--- a/tools/perf/Documentation/perf-kmem.txt
+++ b/tools/perf/Documentation/perf-kmem.txt
@@ -56,6 +56,11 @@ OPTIONS
 --page::
Analyze page allocator events
 
+--live::
+   Show live page stat.  The perf kmem shows total allocation stat by
+   default, but this option shows live (currently allocated) pages
+   instead.  (This option works with --page option only)
+
 SEE ALSO
 
 linkperf:perf-record[1]
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 719aaf782116..3311ebdd4fb8 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -244,6 +244,7 @@ static unsigned long nr_page_fails;
 static unsigned long nr_page_nomatch;
 
 static bool use_pfn;
+static bool live_page;
 static struct perf_session *kmem_session;
 
 #define MAX_MIGRATE_TYPES  6
@@ -264,7 +265,7 @@ struct page_stat {
int nr_free;
 };
 
-static struct rb_root page_tree;
+static struct rb_root page_live_tree;
 static struct rb_root page_alloc_tree;
 static struct rb_root page_alloc_sorted;
 static struct rb_root page_caller_tree;
@@ -398,10 +399,19 @@ static u64 find_callsite(struct perf_evsel *evsel, struct 
perf_sample *sample)
return sample->ip;
 }
 
+struct sort_dimension {
+   const char  name[20];
+   sort_fn_t   cmp;
+   struct list_headlist;
+};
+
+static LIST_HEAD(page_alloc_sort_input);
+static LIST_HEAD(page_caller_sort_input);
 
-static struct page_stat *search_page(u64 page, bool create)
+static struct page_stat *search_page_live_stat(struct page_stat *this,
+  bool create)
 {
-   struct rb_node **node = &page_tree.rb_node;
+   struct rb_node **node = &page_live_tree.rb_node;
struct rb_node *parent = NULL;
struct page_stat *data;
 
@@ -411,7 +421,7 @@ static struct page_stat *search_page(u64 page, bool create)
parent = *node;
data = rb_entry(*node, struct page_stat, node);
 
-   cmp = data->page - page;
+   cmp = data->page - this->page;
if (cmp < 0)
node = &parent->rb_left;
else if (cmp > 0)
@@ -425,24 +435,17 @@ static struct page_stat *search_page(u64 page, bool 
create)
 
data = zalloc(sizeof(*data));
if (data != NULL) {
-   data->page = page;
+   data->page = this->page;
+   data->order = this->order;
+   data->migrate_type = this->migrate_type;
+   data->gfp_flags = this->gfp_flags;
 
rb_link_node(&data->node, parent, node);
-   rb_insert_color(&data->node, &page_tree);
+   rb_insert_color(&data->node, &page_live_tree);
}
 
return data;
 }
-
-struct sort_dimension {
-   const char  name[20];
-   sort_fn_t   cmp;
-   struct list_headlist;
-};
-
-static LIST_HEAD(page_alloc_sort_input);
-static LIST_HEAD(page_caller_sort_input);
-
 static struct page_stat *search_page_alloc_stat(struct page_stat *this,
bool create)
 {
@@ -580,17 +583,8 @@ static int perf_evsel__process_page_alloc_event(struct 
perf_evsel *evsel,
 * This is to find the current page (with correct gfp flags and
 * migrate type) at free event.
 */
-   stat = search_page(page, true);
-   if (stat == NULL)
-   return -ENOMEM;
-
-   stat->order = order;
-   stat->gfp_flags = gfp_flags;
-   stat->migrate_type = migrate_type;
-   stat->callsite = callsite;
-
this.page = page;
-   stat = search_page_alloc_stat(&this, true);
+   stat = search_page_live_stat(&this, true);
if (stat == NULL)
return -ENOMEM;
 
@@ -598,6 +592,16 @@ static int perf_evsel__process_page_alloc_event(struct 
perf_evsel *evsel,
stat->alloc_bytes += bytes;
stat->callsite = callsite;
 
+   if (!live_page) {
+   stat = search_page_alloc_stat(&this, true);
+   if (stat == NULL)
+   return -ENOMEM;
+
+   stat->nr_alloc++;
+   stat->alloc_bytes += bytes;
+   stat->callsite = callsite;
+   }
+
this.callsite = callsite;
stat = search_page_caller_stat(&this, true);
if (stat == NULL)

[PATCH 1/9] perf kmem: Respect -i option

2015-04-05 Thread Namhyung Kim
From: Jiri Olsa 

Currently the perf kmem does not respect -i option.
Initializing the file.path properly after options
get parsed.

Signed-off-by: Jiri Olsa 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-kmem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index ac303ef9f2f0..4ebf65c79434 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -663,7 +663,6 @@ int cmd_kmem(int argc, const char **argv, const char 
*prefix __maybe_unused)
 {
const char * const default_sort_order = "frag,hit,bytes";
struct perf_data_file file = {
-   .path = input_name,
.mode = PERF_DATA_MODE_READ,
};
const struct option kmem_options[] = {
@@ -701,6 +700,8 @@ int cmd_kmem(int argc, const char **argv, const char 
*prefix __maybe_unused)
return __cmd_record(argc, argv);
}
 
+   file.path = input_name;
+
session = perf_session__new(&file, false, &perf_kmem);
if (session == NULL)
return -1;
-- 
2.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 9/9] tools lib traceevent: Honor operator priority

2015-04-05 Thread Namhyung Kim
Currently it ignores operator priority and just sets processed args as a
right operand.  But it could result in priority inversion in case that
the right operand is also a operator arg and its priority is lower.

For example, following print format is from new kmem events.

  "page=%p", REC->pfn != -1UL ? (((struct page *)(0xea00UL)) + 
(REC->pfn)) : ((void *)0)

But this was treated as below:

  REC->pfn != ((null - 1UL) ? ((struct page *)0xea00UL + REC->pfn) 
: (void *) 0)

In this case, the right arg was '?' operator which has lower priority.
But it just sets the whole arg so making the output confusing - page was
always 0 or 1 since that's the result of logical operation.

With this patch, it can handle it properly like following:

  ((REC->pfn != (null - 1UL)) ? ((struct page *)0xea00UL + 
REC->pfn) : (void *) 0)

Cc: Steven Rostedt 
Signed-off-by: Namhyung Kim 
---
 tools/lib/traceevent/event-parse.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/event-parse.c 
b/tools/lib/traceevent/event-parse.c
index 6d31b6419d37..604bea5c3fb0 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -1939,7 +1939,22 @@ process_op(struct event_format *event, struct print_arg 
*arg, char **tok)
goto out_warn_free;
 
type = process_arg_token(event, right, tok, type);
-   arg->op.right = right;
+
+   if (right->type == PRINT_OP &&
+   get_op_prio(arg->op.op) < get_op_prio(right->op.op)) {
+   struct print_arg tmp;
+
+   /* swap ops according to the priority */
+   arg->op.right = right->op.left;
+
+   tmp = *arg;
+   *arg = *right;
+   *right = tmp;
+
+   arg->op.left = right;
+   } else {
+   arg->op.right = right;
+   }
 
} else if (strcmp(token, "[") == 0) {
 
-- 
2.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 7/9] perf kmem: Print gfp flags in human readable string

2015-04-05 Thread Namhyung Kim
Save libtraceevent output and print it in the header.

  # perf kmem stat --page --caller
  # GFP flags
  # -
  # 0010:   NI: GFP_NOIO
  # 00d0:K: GFP_KERNEL
  # 0200:  NWR: GFP_NOWARN
  # 84d0:K|R|Z: GFP_KERNEL|GFP_REPEAT|GFP_ZERO
  # 000200d2:   HU: GFP_HIGHUSER
  # 000200da:  HUM: GFP_HIGHUSER_MOVABLE
  # 000280da:HUM|Z: GFP_HIGHUSER_MOVABLE|GFP_ZERO
  # 002084d0: K|R|Z|NT: GFP_KERNEL|GFP_REPEAT|GFP_ZERO|GFP_NOTRACK
  # 0102005a:  NF|HW|M: GFP_NOFS|GFP_HARDWALL|GFP_MOVABLE

  
-
   Total alloc (KB) | Hits  | Order | Migration type | GFP flags | Callsite
  
-
 60 |15 | 0 |  UNMOVABLE | K|R|Z|NT  | 
pte_alloc_one
 40 |10 | 0 |MOVABLE | HUM|Z | 
handle_mm_fault
 24 | 6 | 0 |MOVABLE | HUM   | 
do_wp_page
 24 | 6 | 0 |  UNMOVABLE | K | 
__pollwait
   ...

Requested-by: Joonsoo Kim 
Suggested-by: Minchan Kim 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-kmem.c | 221 +++---
 1 file changed, 208 insertions(+), 13 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 3311ebdd4fb8..bf0f8bf56375 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -545,6 +545,176 @@ static bool valid_page(u64 pfn_or_page)
return true;
 }
 
+struct gfp_flag {
+   unsigned int flags;
+   char *compact_str;
+   char *human_readable;
+};
+
+static struct gfp_flag *gfps;
+static int nr_gfps;
+
+static int gfpcmp(const void *a, const void *b)
+{
+   const struct gfp_flag *fa = a;
+   const struct gfp_flag *fb = b;
+
+   return fa->flags - fb->flags;
+}
+
+/* see include/trace/events/gfpflags.h */
+static const struct {
+   const char *original;
+   const char *compact;
+} gfp_compact_table[] = {
+   { "GFP_TRANSHUGE",  "THP" },
+   { "GFP_HIGHUSER_MOVABLE",   "HUM" },
+   { "GFP_HIGHUSER",   "HU" },
+   { "GFP_USER",   "U" },
+   { "GFP_TEMPORARY",  "TMP" },
+   { "GFP_KERNEL", "K" },
+   { "GFP_NOFS",   "NF" },
+   { "GFP_ATOMIC", "A" },
+   { "GFP_NOIO",   "NI" },
+   { "GFP_HIGH",   "H" },
+   { "GFP_WAIT",   "W" },
+   { "GFP_IO", "I" },
+   { "GFP_COLD",   "CO" },
+   { "GFP_NOWARN", "NWR" },
+   { "GFP_REPEAT", "R" },
+   { "GFP_NOFAIL", "NF" },
+   { "GFP_NORETRY","NR" },
+   { "GFP_COMP",   "C" },
+   { "GFP_ZERO",   "Z" },
+   { "GFP_NOMEMALLOC", "NMA" },
+   { "GFP_MEMALLOC",   "MA" },
+   { "GFP_HARDWALL",   "HW" },
+   { "GFP_THISNODE",   "TN" },
+   { "GFP_RECLAIMABLE","RC" },
+   { "GFP_MOVABLE","M" },
+   { "GFP_NOTRACK","NT" },
+   { "GFP_NO_KSWAPD",  "NK" },
+   { "GFP_OTHER_NODE", "ON" },
+   { "GFP_NOWAIT", "NW" },
+};
+
+static size_t max_gfp_len;
+
+static char *compact_gfp_flags(char *gfp_flags)
+{
+   char *orig_flags = strdup(gfp_flags);
+   char *new_flags = NULL;
+   char *str, *pos;
+   size_t len = 0;
+
+   if (orig_flags == NULL)
+   return NULL;
+
+   str = strtok_r(orig_flags, "|", &pos);
+   while (str) {
+   size_t i;
+   char *new;
+   const char *cpt;
+
+   for (i = 0; i < ARRAY_SIZE(gfp_compact_table); i++) {
+   if (strcmp(gfp_compact_table[i].original, str))
+   continue;
+
+   cpt = gfp_compact_table[i].compact;
+   new = realloc(new_flags, len + strlen(cpt) + 2);
+   if (new == NULL) {
+   free(new_flags);
+   return NULL;
+   }
+
+   new_flags = new;
+
+   if (!len) {
+   strcpy(new_flags, cpt);
+   } else {
+   strcat(new_flags, "|");
+   strcat(new_flags, cpt);
+   len++;
+   }
+
+   len += strlen(cpt);
+   }
+
+   str = strtok_r(NULL, "|", &pos);
+   }
+
+   if (max_gfp_len < len)
+   max_gfp_len = len;

[PATCH 2/9] tracing, mm: Record pfn instead of pointer to struct page

2015-04-05 Thread Namhyung Kim
The struct page is opaque for userspace tools, so it'd be better to save
pfn in order to identify page frames.

The textual output of $debugfs/tracing/trace file remains unchanged and
only raw (binary) data format is changed - but thanks to libtraceevent,
userspace tools which deal with the raw data (like perf and trace-cmd)
can parse the format easily.  So impact on the userspace will also be
minimal.

Based-on-patch-by: Joonsoo Kim 
Acked-by: Ingo Molnar 
Acked-by: Steven Rostedt 
Cc: linux...@kvack.org
Signed-off-by: Namhyung Kim 
---
 include/trace/events/filemap.h |  8 
 include/trace/events/kmem.h| 42 +-
 include/trace/events/vmscan.h  |  8 
 3 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/include/trace/events/filemap.h b/include/trace/events/filemap.h
index 0421f49a20f7..42febb6bc1d5 100644
--- a/include/trace/events/filemap.h
+++ b/include/trace/events/filemap.h
@@ -18,14 +18,14 @@ DECLARE_EVENT_CLASS(mm_filemap_op_page_cache,
TP_ARGS(page),
 
TP_STRUCT__entry(
-   __field(struct page *, page)
+   __field(unsigned long, pfn)
__field(unsigned long, i_ino)
__field(unsigned long, index)
__field(dev_t, s_dev)
),
 
TP_fast_assign(
-   __entry->page = page;
+   __entry->pfn = page_to_pfn(page);
__entry->i_ino = page->mapping->host->i_ino;
__entry->index = page->index;
if (page->mapping->host->i_sb)
@@ -37,8 +37,8 @@ DECLARE_EVENT_CLASS(mm_filemap_op_page_cache,
TP_printk("dev %d:%d ino %lx page=%p pfn=%lu ofs=%lu",
MAJOR(__entry->s_dev), MINOR(__entry->s_dev),
__entry->i_ino,
-   __entry->page,
-   page_to_pfn(__entry->page),
+   pfn_to_page(__entry->pfn),
+   __entry->pfn,
__entry->index << PAGE_SHIFT)
 );
 
diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index 4ad10baecd4d..81ea59812117 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -154,18 +154,18 @@ TRACE_EVENT(mm_page_free,
TP_ARGS(page, order),
 
TP_STRUCT__entry(
-   __field(struct page *,  page)
+   __field(unsigned long,  pfn )
__field(unsigned int,   order   )
),
 
TP_fast_assign(
-   __entry->page   = page;
+   __entry->pfn= page_to_pfn(page);
__entry->order  = order;
),
 
TP_printk("page=%p pfn=%lu order=%d",
-   __entry->page,
-   page_to_pfn(__entry->page),
+   pfn_to_page(__entry->pfn),
+   __entry->pfn,
__entry->order)
 );
 
@@ -176,18 +176,18 @@ TRACE_EVENT(mm_page_free_batched,
TP_ARGS(page, cold),
 
TP_STRUCT__entry(
-   __field(struct page *,  page)
+   __field(unsigned long,  pfn )
__field(int,cold)
),
 
TP_fast_assign(
-   __entry->page   = page;
+   __entry->pfn= page_to_pfn(page);
__entry->cold   = cold;
),
 
TP_printk("page=%p pfn=%lu order=0 cold=%d",
-   __entry->page,
-   page_to_pfn(__entry->page),
+   pfn_to_page(__entry->pfn),
+   __entry->pfn,
__entry->cold)
 );
 
@@ -199,22 +199,22 @@ TRACE_EVENT(mm_page_alloc,
TP_ARGS(page, order, gfp_flags, migratetype),
 
TP_STRUCT__entry(
-   __field(struct page *,  page)
+   __field(unsigned long,  pfn )
__field(unsigned int,   order   )
__field(gfp_t,  gfp_flags   )
__field(int,migratetype )
),
 
TP_fast_assign(
-   __entry->page   = page;
+   __entry->pfn= page ? page_to_pfn(page) : -1UL;
__entry->order  = order;
__entry->gfp_flags  = gfp_flags;
__entry->migratetype= migratetype;
),
 
TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
-   __entry->page,
-   __entry->page ? page_to_pfn(__entry->page) : 0,
+   __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL,
+   __entry->pfn != -1UL ? __entry->pfn : 0,
__entry->order,
__entry->migratetype,
show_gfp_flags(__entry->gfp_flags))
@@ -227,20 +227,20 @@ DECLARE_EV

[PATCH 3/9] perf kmem: Analyze page allocator events also

2015-04-05 Thread Namhyung Kim
The perf kmem command records and analyze kernel memory allocation
only for SLAB objects.  This patch implement a simple page allocator
analyzer using kmem:mm_page_alloc and kmem:mm_page_free events.

It adds two new options of --slab and --page.  The --slab option is
for analyzing SLAB allocator and that's what perf kmem currently does.

The new --page option enables page allocator events and analyze kernel
memory usage in page unit.  Currently, 'stat --alloc' subcommand is
implemented only.

If none of these --slab nor --page is specified, --slab is implied.

  # perf kmem stat --page --alloc --line 10

  
---
   PFN  | Total alloc (KB) | Hits | Order | Mig.type | GFP flags
  
---
4045014 |   16 |1 | 2 |  RECLAIM |  00285250
4143980 |   16 |1 | 2 |  RECLAIM |  00285250
3938658 |   16 |1 | 2 |  RECLAIM |  00285250
4045400 |   16 |1 | 2 |  RECLAIM |  00285250
3568708 |   16 |1 | 2 |  RECLAIM |  00285250
3729824 |   16 |1 | 2 |  RECLAIM |  00285250
3657210 |   16 |1 | 2 |  RECLAIM |  00285250
4120750 |   16 |1 | 2 |  RECLAIM |  00285250
3678850 |   16 |1 | 2 |  RECLAIM |  00285250
3693874 |   16 |1 | 2 |  RECLAIM |  00285250
   ...  | ...  | ...  | ...   | ...  | ...
  
---

  SUMMARY (page allocator)
  
  Total allocation requests :   44,260   [  177,256 KB ]
  Total free requests   :  117   [  468 KB ]

  Total alloc+freed requests:   49   [  196 KB ]
  Total alloc-only requests :   44,211   [  177,060 KB ]
  Total free-only requests  :   68   [  272 KB ]

  Total allocation failures :0   [0 KB ]

  Order Unmovable   Reclaimable   Movable  Reserved  CMA/Isolated
  -          
  032 .44,210 . .
  1 . . . . .
  2 .18 . . .
  3 . . . . .
  4 . . . . .
  5 . . . . .
  6 . . . . .
  7 . . . . .
  8 . . . . .
  9 . . . . .
 10 . . . . .

Signed-off-by: Namhyung Kim 
---
 tools/perf/Documentation/perf-kmem.txt |   8 +-
 tools/perf/builtin-kmem.c  | 500 +++--
 2 files changed, 491 insertions(+), 17 deletions(-)

diff --git a/tools/perf/Documentation/perf-kmem.txt 
b/tools/perf/Documentation/perf-kmem.txt
index 150253cc3c97..23219c65c16f 100644
--- a/tools/perf/Documentation/perf-kmem.txt
+++ b/tools/perf/Documentation/perf-kmem.txt
@@ -3,7 +3,7 @@ perf-kmem(1)
 
 NAME
 
-perf-kmem - Tool to trace/measure kernel memory(slab) properties
+perf-kmem - Tool to trace/measure kernel memory properties
 
 SYNOPSIS
 
@@ -46,6 +46,12 @@ OPTIONS
 --raw-ip::
Print raw ip instead of symbol
 
+--slab::
+   Analyze SLAB allocator events.
+
+--page::
+   Analyze page allocator events
+
 SEE ALSO
 
 linkperf:perf-record[1]
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 4ebf65c79434..63ea01349b6e 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -22,6 +22,11 @@
 #include 
 #include 
 
+static int kmem_slab;
+static int kmem_page;
+
+static longkmem_page_size;
+
 struct alloc_stat;
 typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *);
 
@@ -226,6 +231,244 @@ static int perf_evsel__process_free_event(struct 
perf_evsel *evsel,
return 0;
 }
 
+static u64 total_page_alloc_bytes;
+static u64 total_page_free_bytes;
+static u64 total_page_nomatch_bytes;
+static u64 total_page_fail_bytes;
+static unsigned long nr_page_allocs;
+static unsigned long nr_page_frees;
+static unsigned long nr_page_fails;
+static unsign

[PATCH 4/9] perf kmem: Implement stat --page --caller

2015-04-05 Thread Namhyung Kim
It perf kmem support caller statistics for page.  Unlike slab case,
the tracepoints in page allocator don't provide callsite info.  So
it records with callchain and extracts callsite info.

Note that the callchain contains several memory allocation functions
which has no meaning for users.  So skip those functions to get proper
callsites.  I used following regex pattern to skip the allocator
functions:

  ^_?_?(alloc|get_free|get_zeroed)_pages?

This gave me a following list of functions:

  # perf kmem record --page sleep 3
  # perf kmem stat --page -v
  ...
  alloc func: __get_free_pages
  alloc func: get_zeroed_page
  alloc func: alloc_pages_exact
  alloc func: __alloc_pages_direct_compact
  alloc func: __alloc_pages_nodemask
  alloc func: alloc_page_interleave
  alloc func: alloc_pages_current
  alloc func: alloc_pages_vma
  alloc func: alloc_page_buffers
  alloc func: alloc_pages_exact_nid
  ...

The output looks mostly same as --alloc (I also added callsite column
to that) but groups entries by callsite.  Currently, the order,
migrate type and GFP flag info is for the last allocation and not
guaranteed to be same for all allocations from the callsite.

  
-
   Total_alloc (KB) | Hits  | Order | Mig.type | GFP flags | Callsite
  
-
  1,064 |   266 | 0 | UNMOVABL |  00d0 | __pollwait
 52 |13 | 0 | UNMOVABL |  002084d0 | pte_alloc_one
 44 |11 | 0 |  MOVABLE |  000280da | handle_mm_fault
 20 | 5 | 0 |  MOVABLE |  000200da | do_cow_fault
 20 | 5 | 0 |  MOVABLE |  000200da | do_wp_page
 16 | 4 | 0 | UNMOVABL |  84d0 | __pmd_alloc
 16 | 4 | 0 | UNMOVABL |  0200 | 
__tlb_remove_page
 12 | 3 | 0 | UNMOVABL |  84d0 | __pud_alloc
  8 | 2 | 0 | UNMOVABL |  0010 | 
bio_copy_user_iov
  4 | 1 | 0 | UNMOVABL |  000200d2 | pipe_write
  4 | 1 | 0 |  MOVABLE |  000280da | do_wp_page
  4 | 1 | 0 | UNMOVABL |  002084d0 | pgd_alloc
  
-

Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-kmem.c | 279 +++---
 1 file changed, 263 insertions(+), 16 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 63ea01349b6e..5b3ed17c293a 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -10,6 +10,7 @@
 #include "util/header.h"
 #include "util/session.h"
 #include "util/tool.h"
+#include "util/callchain.h"
 
 #include "util/parse-options.h"
 #include "util/trace-event.h"
@@ -21,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static int kmem_slab;
 static int kmem_page;
@@ -241,6 +243,7 @@ static unsigned long nr_page_fails;
 static unsigned long nr_page_nomatch;
 
 static bool use_pfn;
+static struct perf_session *kmem_session;
 
 #define MAX_MIGRATE_TYPES  6
 #define MAX_PAGE_ORDER 11
@@ -250,6 +253,7 @@ static int order_stats[MAX_PAGE_ORDER][MAX_MIGRATE_TYPES];
 struct page_stat {
struct rb_node  node;
u64 page;
+   u64 callsite;
int order;
unsignedgfp_flags;
unsignedmigrate_type;
@@ -262,8 +266,138 @@ struct page_stat {
 static struct rb_root page_tree;
 static struct rb_root page_alloc_tree;
 static struct rb_root page_alloc_sorted;
+static struct rb_root page_caller_tree;
+static struct rb_root page_caller_sorted;
 
-static struct page_stat *search_page(unsigned long page, bool create)
+struct alloc_func {
+   u64 start;
+   u64 end;
+   char *name;
+};
+
+static int nr_alloc_funcs;
+static struct alloc_func *alloc_func_list;
+
+static int funcmp(const void *a, const void *b)
+{
+   const struct alloc_func *fa = a;
+   const struct alloc_func *fb = b;
+
+   if (fa->start > fb->start)
+   return 1;
+   else
+   return -1;
+}
+
+static int callcmp(const void *a, const void *b)
+{
+   const struct alloc_func *fa = a;
+   const struct alloc_func *fb = b;
+
+   if (fb->start <= fa->start && fa->end < fb->end)
+   return 0;
+
+   if (fa->start > fb->start)
+   return 1;
+   else
+   return -1;
+}
+
+static int build_alloc_func_list(void)
+{
+   int ret;
+   struct map *kernel_map;
+   struct symbol *sym;
+   struct rb_node *node;
+   struct alloc_func *func;
+   struct machine *machine = &kmem_session->machines.host;
+
+   regex_t alloc_func_regex;
+   const char pattern

[PATCHSET 0/9] perf kmem: Implement page allocation analysis (v6)

2015-04-05 Thread Namhyung Kim
Hello,

Currently perf kmem command only analyzes SLAB memory allocation.  And
I'd like to introduce page allocation analysis also.  Users can use
 --slab and/or --page option to select it.  If none of these options
 are used, it does slab allocation analysis for backward compatibility.

 * changes in v6)
   - add -i option fix  (Jiri)
   - libtraceevent operator priority fix

* changes in v5)
   - print migration type and gfp flags in more compact form  (Arnaldo)
   - add kmem.default config option

 * changes in v4)
   - use pfn instead of struct page * in tracepoints  (Joonsoo, Ingo)
   - print gfp flags in human readable string  (Joonsoo, Minchan)

* changes in v3)
  - add live page statistics

 * changes in v2)
   - Use thousand grouping for big numbers - i.e. 12345 -> 12,345  (Ingo)
   - Improve output stat readability  (Ingo)
   - Remove alloc size column as it can be calculated from hits and order

Patch 1 is to convert tracepoint to save pfn instead of struct page *.
Patch 2 implements basic support for page allocation analysis, patch 3
deals with the callsite and patch 4 implements sorting.  Patch 5
introduces live page analysis which is to focus on currently allocated
pages only.  Finally patch 6 prints gfp flags in human readable string.

In this patchset, I used two kmem events: kmem:mm_page_alloc and
kmem_page_free for analysis as they can track almost all of memory
allocation/free path AFAIK.  However, unlike slab tracepoint events,
those page allocation events don't provide callsite info directly.  So
I recorded callchains and extracted callsites like below:

Normal page allocation callchains look like this:

  360a7e __alloc_pages_nodemask
  3a711c alloc_pages_current
  357bc7 __page_cache_alloc   <-- callsite
  357cf6 pagecache_get_page
   48b0a prepare_pages
   494d3 __btrfs_buffered_write
   49cdf btrfs_file_write_iter
  3ceb6e new_sync_write
  3cf447 vfs_write
  3cff99 sys_write
  7556e9 system_call
f880 __write_nocancel
   33eb9 cmd_record
   4b38e cmd_kmem
   7aa23 run_builtin
   27a9a main
   20800 __libc_start_main

But first two are internal page allocation functions so it should be
skipped.  To determine such allocation functions, I used following regex:

  ^_?_?(alloc|get_free|get_zeroed)_pages?

This gave me a following list of functions (you can see this with -v):

  alloc func: __get_free_pages
  alloc func: get_zeroed_page
  alloc func: alloc_pages_exact
  alloc func: __alloc_pages_direct_compact
  alloc func: __alloc_pages_nodemask
  alloc func: alloc_page_interleave
  alloc func: alloc_pages_current
  alloc func: alloc_pages_vma
  alloc func: alloc_page_buffers
  alloc func: alloc_pages_exact_nid

After skipping those function, it got '__page_cache_alloc'.

Other information such as allocation order, migration type and gfp
flags are provided by tracepoint events.

Basically the output will be sorted by total allocation bytes, but you
can change it by using -s/--sort option.  The following sort keys are
added to support page analysis: page, order, mtype, gfp.  Existing
'callsite', 'bytes' and 'hit' sort keys also can be used.

An example follows:

  # perf kmem record --page sleep 5
  [ perf record: Woken up 2 times to write data ]
  [ perf record: Captured and wrote 1.065 MB perf.data (2949 samples) ]

  # perf kmem stat --page --caller -l 10
  # GFP flags
  # -
  # 0010: GFP_NOIO
  # 00d0: GFP_KERNEL
  # 0200: GFP_NOWARN
  # 52d0: GFP_KERNEL|GFP_NOWARN|GFP_NORETRY|GFP_COMP
  # 84d0: GFP_KERNEL|GFP_REPEAT|GFP_ZERO
  # 000200d0: GFP_USER
  # 000200d2: GFP_HIGHUSER
  # 000200da: GFP_HIGHUSER_MOVABLE
  # 000280da: GFP_HIGHUSER_MOVABLE|GFP_ZERO
  # 002084d0: GFP_KERNEL|GFP_REPEAT|GFP_ZERO|GFP_NOTRACK
  # 0102005a: GFP_NOFS|GFP_HARDWALL|GFP_MOVABLE
  
-
   Total alloc (KB) | Hits  | Order | Migration type | GFP flags | Callsite
  
-
 16 | 1 | 2 |  UNMOVABLE |  52d0 | 
alloc_skb_with_frags
 24 | 3 | 1 |  UNMOVABLE |  52d0 | 
alloc_skb_with_frags
  3,876 |   969 | 0 |MOVABLE |  000200da | 
shmem_alloc_page
972 |   243 | 0 |  UNMOVABLE |  00d0 | 
__pollwait
624 |   156 | 0 |MOVABLE |  0102005a | 
__page_cache_alloc
304 |76 | 0 |  UNMOVABLE |  000200d0 | 
dma_generic_alloc_coherent
108 |27 | 0 |MOVABLE |  000280da | 
handle_mm_fault
 56 |14 | 0 |  UNMOVABLE |  002084d0 | 
pte_alloc_one
 24 | 6 | 0 |MOVABLE |  000200da | 
do_wp_page
 16 | 4 | 0 |  UNMOVABLE |  0200 | 
__tlb_remove_page
   ...  | ...   

[PATCH 8/9] perf kmem: Add kmem.default config option

2015-04-05 Thread Namhyung Kim
Currently perf kmem command will select --slab if neither --slab nor
--page is given for backward compatibility.  Add kmem.default config
option to select the default value ('page' or 'slab').

  # cat ~/.perfconfig
  [kmem]
default = page

  # perf kmem stat

  SUMMARY (page allocator)
  
  Total allocation requests :1,518   [6,096 KB ]
  Total free requests   :1,431   [5,748 KB ]

  Total alloc+freed requests:1,330   [5,344 KB ]
  Total alloc-only requests :  188   [  752 KB ]
  Total free-only requests  :  101   [  404 KB ]

  Total allocation failures :0   [0 KB ]
  ...

Cc: Taeung Song 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-kmem.c | 32 +---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index bf0f8bf56375..d2dfcabdf684 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -28,6 +28,10 @@ static int   kmem_slab;
 static int kmem_page;
 
 static longkmem_page_size;
+static enum {
+   KMEM_SLAB,
+   KMEM_PAGE,
+} kmem_default = KMEM_SLAB;  /* for backward compatibility */
 
 struct alloc_stat;
 typedef int (*sort_fn_t)(void *, void *);
@@ -1673,7 +1677,8 @@ static int parse_sort_opt(const struct option *opt 
__maybe_unused,
if (!arg)
return -1;
 
-   if (kmem_page > kmem_slab) {
+   if (kmem_page > kmem_slab ||
+   (kmem_page == 0 && kmem_slab == 0 && kmem_default == KMEM_PAGE)) {
if (caller_flag > alloc_flag)
return setup_page_sorting(&page_caller_sort, arg);
else
@@ -1789,6 +1794,22 @@ static int __cmd_record(int argc, const char **argv)
return cmd_record(i, rec_argv, NULL);
 }
 
+static int kmem_config(const char *var, const char *value, void *cb)
+{
+   if (!strcmp(var, "kmem.default")) {
+   if (!strcmp(value, "slab"))
+   kmem_default = KMEM_SLAB;
+   else if (!strcmp(value, "page"))
+   kmem_default = KMEM_PAGE;
+   else
+   pr_err("invalid default value ('slab' or 'page' 
required): %s\n",
+  value);
+   return 0;
+   }
+
+   return perf_default_config(var, value, cb);
+}
+
 int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
 {
struct perf_data_file file = {
@@ -1825,14 +1846,19 @@ int cmd_kmem(int argc, const char **argv, const char 
*prefix __maybe_unused)
struct perf_session *session;
int ret = -1;
 
+   perf_config(kmem_config, NULL);
argc = parse_options_subcommand(argc, argv, kmem_options,
kmem_subcommands, kmem_usage, 0);
 
if (!argc)
usage_with_options(kmem_usage, kmem_options);
 
-   if (kmem_slab == 0 && kmem_page == 0)
-   kmem_slab = 1;  /* for backward compatibility */
+   if (kmem_slab == 0 && kmem_page == 0) {
+   if (kmem_default == KMEM_SLAB)
+   kmem_slab = 1;
+   else
+   kmem_page = 1;
+   }
 
if (!strncmp(argv[0], "rec", 3)) {
symbol__init(NULL);
-- 
2.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 07/18 v3] tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values

2015-04-05 Thread Namhyung Kim
Hi Steve,

On Thu, Apr 02, 2015 at 09:38:09PM -0400, Steven Rostedt wrote:
> From: "Steven Rostedt (Red Hat)" 
> 
> Several tracepoints use the helper functions __print_symbolic() or
> __print_flags() and pass in enums that do the mapping between the
> binary data stored and the value to print. This works well for reading
> the ASCII trace files, but when the data is read via userspace tools
> such as perf and trace-cmd, the conversion of the binary value to a
> human string format is lost if an enum is used, as userspace does not
> have access to what the ENUM is.
> 
> For example, the tracepoint trace_tlb_flush() has:
> 
>  __print_symbolic(REC->reason,
> { TLB_FLUSH_ON_TASK_SWITCH, "flush on task switch" },
> { TLB_REMOTE_SHOOTDOWN, "remote shootdown" },
> { TLB_LOCAL_SHOOTDOWN, "local shootdown" },
> { TLB_LOCAL_MM_SHOOTDOWN, "local mm shootdown" })
> 
> Which maps the enum values to the strings they represent. But perf and
> trace-cmd do no know what value TLB_LOCAL_MM_SHOOTDOWN is, and would
> not be able to map it.
> 
> With TRACE_DEFINE_ENUM(), developers can place these in the event header
> files and ftrace will convert the enums to their values:
> 
> By adding:
> 
>  TRACE_DEFINE_ENUM(TLB_FLUSH_ON_TASK_SWITCH);
>  TRACE_DEFINE_ENUM(TLB_REMOTE_SHOOTDOWN);
>  TRACE_DEFINE_ENUM(TLB_LOCAL_SHOOTDOWN);
>  TRACE_DEFINE_ENUM(TLB_LOCAL_MM_SHOOTDOWN);
> 
>  $ cat /sys/kernel/debug/tracing/events/tlb/tlb_flush/format
> [...]
>  __print_symbolic(REC->reason,
> { 0, "flush on task switch" },
> { 1, "remote shootdown" },
> { 2, "local shootdown" },
> { 3, "local mm shootdown" })
> 
> The above is what userspace expects to see, and tools do not need to
> be modified to parse them.
> 
> Cc: Guilherme Cox 
> Cc: Tony Luck 
> Cc: Xie XiuQi 
> Signed-off-by: Steven Rostedt 
> ---

[SNIP]
> +static void update_event_printk(struct ftrace_event_call *call,
> + struct trace_enum_map *map)
> +{
> + char *ptr;
> + int quote = 0;
> + int len = strlen(map->enum_string);
> +
> + for (ptr = call->print_fmt; *ptr; ptr++) {
> + if (*ptr == '\\') {
> + ptr++;
> + /* paranoid */
> + if (!*ptr)
> + break;
> + continue;
> + }
> + if (*ptr == '"') {
> + quote ^= 1;
> + continue;
> + }
> + if (quote)
> + continue;
> + if (isdigit(*ptr)) {
> + /* skip numbers */
> + do {
> + ptr++;
> + /* Check for alpha chars like ULL */
> + } while (isalnum(*ptr));
> + /*
> +  * A number must have some kind of delimiter after
> +  * it, and we can ignore that too.
> +  */
> + continue;
> + }
> + if (isalpha(*ptr) || *ptr == '_') {
> + if (strncmp(map->enum_string, ptr, len) == 0 &&
> + !isalnum(ptr[len]) && ptr[len] != '_') {
> + ptr = enum_replace(ptr, map, len);
> + /* Hmm, enum string smaller than value */
> + if (WARN_ON_ONCE(!ptr))
> + return;
> + /*
> +  * No need to decrement here, as enum_replace()
> +  * returns the pointer to the character passed
> +  * the enum, and two enums can not be placed
> +  * back to back without something in between.
> +  * We can skip that something in between.
> +  */
> + continue;

Maybe I'm becoming a bit paranoid, what I worried was like this:

  ENUM1\"ENUM2\"

In this case, it skips the backslash and makes quotation effective..


> + }
> + skip_more:
> + do {
> + ptr++;
> + } while (isalnum(*ptr) || *ptr == '_');
> + /*
> +  * If what comes after this variable is a '.' or
> +  * '->' then we can continue to ignore that string.
> +  */
> + if (*ptr == '.' || (ptr[0] == '-' && ptr[1] == '>')) {
> + ptr += *ptr == '.' ? 1 : 2;
> + goto skip_more;
> + }
> + /*
> +  * Once again, we can skip the delimiter that came
> +  * after the string.
> +  */
> + continue;
> + }
> + }
> +}
> +
> +void trace_eve

[PATCH] blk-mq: remove unnecessary check in blk_mq_alloc_tag_set

2015-04-05 Thread nimisolo
already check set->nr_hw_queues above :
if (!set->nr_hw_queues)
return -EINVAL;

Signed-off-by: nimisolo 
---
 block/blk-mq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index b7b8933..3ae21c4 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2161,7 +2161,7 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
if (set->queue_depth < set->reserved_tags + BLK_MQ_TAG_MIN)
return -EINVAL;
 
-   if (!set->nr_hw_queues || !set->ops->queue_rq || !set->ops->map_queue)
+   if (!set->ops->queue_rq || !set->ops->map_queue)
return -EINVAL;
 
if (set->queue_depth > BLK_MQ_MAX_DEPTH) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] crypto: remove instance when test failed

2015-04-05 Thread Herbert Xu
On Fri, Apr 03, 2015 at 09:29:44PM +0200, Stephan Mueller wrote:
>
> What about moving the current crypto_unregister_instance into 
> __crypto_unregister_instance and creating a new crypto_unregister_instance 
> that takes the ref count and once it got it, it calls 
> __crypto_unregister_instance. If it did not get the ref count, it simply 
> returns because the inst apparently was already removed.
> 
> Only the crypto_unregister_instance is EXPORT_SYMBOL whereas the 
> __crypto_unregister_instance is static.

That's not going to work because you need to grab the reference
count before you release the mutex.  Let me fix up crypto_user first
and then you can use it for your case too (or at least borrow the
idea).

Cheers,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] time: allow gcc to fold constants when using msecs_to_jiffies

2015-04-05 Thread Joe Perches
On Mon, 2015-04-06 at 06:26 +0200, Nicholas Mc Guire wrote:
> On Sun, 05 Apr 2015, Joe Perches wrote:
> > Try it and look at the generated .lst files with and
> > without the patch I sent.
[]
> from all that I understood it should
> be doable both as macro and inline.

I think it _should_ be doable too but I also think
the only reason gcc doesn't optimize the inline
is because gcc's optimizer isn't good enough yet.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tip:timers/core] clockevents: Fix cpu_down() race for hrtimer based broadcasting

2015-04-05 Thread Preeti U Murthy
On 04/03/2015 04:20 PM, Ingo Molnar wrote:
> 
> * Preeti U Murthy  wrote:
> 
>> On 04/02/2015 08:00 PM, tip-bot for Preeti U Murthy wrote:
>>> Commit-ID:  345527b1edce8df719e0884500c76832a18211c3
>>> Gitweb: 
>>> http://git.kernel.org/tip/345527b1edce8df719e0884500c76832a18211c3
>>> Author: Preeti U Murthy 
>>> AuthorDate: Mon, 30 Mar 2015 14:59:19 +0530
>>> Committer:  Ingo Molnar 
>>> CommitDate: Thu, 2 Apr 2015 14:25:39 +0200
>>>
>>> clockevents: Fix cpu_down() race for hrtimer based broadcasting
>>>
>>> It was found when doing a hotplug stress test on POWER, that the
>>> machine either hit softlockups or rcu_sched stall warnings.  The
>>> issue was traced to commit:
>>>
>>>   7cba160ad789 ("powernv/cpuidle: Redesign idle states management")
>>>
>>> which exposed the cpu_down() race with hrtimer based broadcast mode:
>>>
>>>   5d1638acb9f6 ("tick: Introduce hrtimer based broadcast")
>>>
>>> The race is the following:
>>>
>>> Assume CPU1 is the CPU which holds the hrtimer broadcasting duty
>>> before it is taken down.
>>>
>>> CPU0CPU1
>>>
>>> cpu_down()  take_cpu_down()
>>> disable_interrupts()
>>>
>>> cpu_die()
>>>
>>> while (CPU1 != CPU_DEAD) {
>>> msleep(100);
>>> switch_to_idle();
>>> stop_cpu_timer();
>>> schedule_broadcast();
>>> }
>>>
>>> tick_cleanup_cpu_dead()
>>> take_over_broadcast()
>>>
>>> So after CPU1 disabled interrupts it cannot handle the broadcast
>>> hrtimer anymore, so CPU0 will be stuck forever.
>>>
>>> Fix this by explicitly taking over broadcast duty before cpu_die().
>>>
>>> This is a temporary workaround. What we really want is a callback
>>> in the clockevent device which allows us to do that from the dying
>>> CPU by pushing the hrtimer onto a different cpu. That might involve
>>> an IPI and is definitely more complex than this immediate fix.
>>>
>>> Changelog was picked up from:
>>>
>>> https://lkml.org/lkml/2015/2/16/213
>>>
>>> Suggested-by: Thomas Gleixner 
>>> Tested-by: Nicolas Pitre 
>>> Signed-off-by: Preeti U. Murthy 
>>> Cc: linuxppc-...@lists.ozlabs.org
>>> Cc: m...@ellerman.id.au
>>> Cc: nicolas.pi...@linaro.org
>>> Cc: pet...@infradead.org
>>> Cc: r...@rjwysocki.net
>>> Fixes: 
>>> http://linuxppc.10917.n7.nabble.com/offlining-cpus-breakage-td88619.html
>>> Link: 
>>> http://lkml.kernel.org/r/20150330092410.24979.59887.st...@preeti.in.ibm.com
>>> [ Merged it to the latest timer tree, renamed the callback, tidied up the 
>>> changelog. ]
>>> Signed-off-by: Ingo Molnar 
>>
>> Can this be marked for stable too please?
> 
> It can be forwarded to -stable once it has gone upstream in the merge 
> window and has gone through some testing upstream as well. The 
> breakage itself was introduced in the v3.19 merge window, so it's an 
> older regression - and the fix is not simple either.

Ok I see.

Thanks

Regards
Preeti U Murthy
> 
> Thanks,
> 
>   Ingo
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] time: allow gcc to fold constants when using msecs_to_jiffies

2015-04-05 Thread Nicholas Mc Guire
On Sun, 05 Apr 2015, Joe Perches wrote:

> On Mon, 2015-04-06 at 03:00 +0200, Nicholas Mc Guire wrote:
> > On Sun, 05 Apr 2015, Joe Perches wrote:
> > 
> > > On Sun, 2015-04-05 at 09:23 +0200, Nicholas Mc Guire wrote:
> > > > The majority of the msecs_to_jiffies() users in the kernel are passing 
> > > > in
> > > > constants which would allow gcc to do constant folding by checking with
> > > > __builtin_constant_p() in msecs_to_jiffies().
> > > > 
> > > > The original msecs_to_jiffies is renamed to __msecs_to_jiffies and aside
> > > > from the removal of the check for negative values being moved out, is
> > > > unaltered.
> > > 
> > > At least for gcc 4.9, this doesn't allow the compiler
> > > to optimize / precalculation msecs_to_jiffies calls
> > > with a constant.
> > > 
> > > This does: (on top of your patch x86-64 defconfig)
> > > 
> > > $ size vmlinux.o.*
> > >text  data bss dec hex filename
> > > 11770523  1505971 1018454 14294948 da1fa4 
> > > vmlinux.o.next-b0a12fb5bc8
> > > 11770530  1505971 1018454 14294955 da1fab 
> > > vmlinux.o.next-b0a12fb5bc8-inline
> > > 11768734  1505971 1018454 14293159 da18a7 
> > > vmlinux.o.next-b0a12fb5bc8-macro
> > > 
> > > I think this should still move the if (m) < 0 back into the
> > > original __msecs_to_jiffies function.
> > >
> > 
> > could you check if you can reproduce the results below ?
> > my assumption was that gcc would always optimize out an 
> > if(CONST < 0) return CONST; reducing it to the return CONST; 
> > only and thus this should not make any difference but Im not 
> > that familiar with gcc.
> > 
> > gcc versions here are:
> >  for x86 gcc version 4.7.2 (Debian 4.7.2-5) 
> >  for powerpc it is a gcc version 4.9.2 (crosstool-NG 1.20.0)
> >  for arm gcc version 4.9.2 20140904 (prerelease) (crosstool-NG 
> > linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09)
> > 
> > Procedure used:
> > root@debian:~/linux-next# make distclean
> > root@debian:~/linux-next# make defconfig
> > root@debian:~/linux-next# make drivers/net/wireless/p54/p54usb.lst
> > root@debian:~/linux-next# make drivers/net/wireless/p54/p54usb.s
> > 
> > same setup in unpatched /usr/src/linux-next/
> > 
> > e.g:
> > root@debian:/usr/src/linux-next# grep msecs_to_jiffies 
> > drivers/net/wireless/p54/p54usb.c
> > timeout = jiffies + msecs_to_jiffies(1000);
> > timeout = jiffies + msecs_to_jiffies(1000);
> > 
> > So both calls are constants and should be optimized out if it works as
> > expected.
> > 
> > without the patch applied:
> > 
> > root@debian:/usr/src/linux-next# grep msecs_to_jiffies  
> > drivers/net/wireless/p54/p54usb.s
> > callmsecs_to_jiffies#
> > callmsecs_to_jiffies#
> > root@debian:/usr/src/linux-next# grep msecs_to_jiffies 
> > drivers/net/wireless/p54/p54usb.lst
> > timeout = jiffies + msecs_to_jiffies(1000);
> > e19: R_X86_64_PC32  
> > msecs_to_jiffies+0xfffc
> > timeout = jiffies + msecs_to_jiffies(1000);
> > timeout = jiffies + msecs_to_jiffies(1000);
> > fd8: R_X86_64_PC32  
> > msecs_to_jiffies+0xfffc
> > timeout = jiffies + msecs_to_jiffies(1000);
> > 
> > 
> > with the patch applied this then gives me:
> > 
> > root@debian:~/linux-next# grep msecs_to_jiffies  
> > drivers/net/wireless/p54/p54usb.s
> > root@debian:~/linux-next# grep msecs_to_jiffies 
> > drivers/net/wireless/p54/p54usb.lst
> > timeout = jiffies + msecs_to_jiffies(1000);
> > timeout = jiffies + msecs_to_jiffies(1000);
> > timeout = jiffies + msecs_to_jiffies(1000);
> > timeout = jiffies + msecs_to_jiffies(1000);
> > 
> > Conversely in kernel/sched/core.c the msecs_to_jiffies is not a constant
> > and the result is that it calls __msecs_to_jiffies
> > 
> > patched:
> > root@debian:~/linux-next# grep msecs_to_jiffies kernel/sched/core.s
> > call__msecs_to_jiffies  #
> > 
> > unpatched:
> > root@debian:/usr/src/linux-next# grep msecs_to_jiffies kernel/sched/core.s
> > callmsecs_to_jiffies#
> > 
> > 
> > Could you check if you get these results for this test-case ?
> > If this really were compiler dependant that would be very bad.
> 
> Hi Nicholas.
> 
> Your inline version has not worked with any of
> x86-64 gcc 4.4, 4.6, 4.7, or 4.9
> 
> I suggest you add some lines to
> lib/test_module.c/test_module_init like:
> 
>   unsigned int m;
> 
>   for (m = 10; m < 200; m += 10)
>   pr_info("msecs_to_jiffies(%u) is %lu\n",
>   m, msecs_to_jiffies(m));
> 
>   pr_info("msecs_to_jiffies(%u) is %lu\n",
>   10, msecs_to_jiffies(10));
>   pr_info("msecs_to_jiffies(%u) is %lu\n",
>   100, msecs_to_jiffies(100));
>   pr_info("msecs_to_jiffies(%u) is %lu\n",
>   1000, msecs_to_jiffies(1000));
> 
> Then it's pretty easy to look at the assembly/.lst fil

Re: [RFC PATCH] sched: Add cpu based entries to debugfs

2015-04-05 Thread Mike Galbraith
On Sun, 2015-04-05 at 20:10 -0600, David Ahern wrote:
> 
> Can someone clarify on the duplication concerns and such?

My concern was eg you display flags in /sys, but to tweak flags etc, 
you must visit /proc.  Seems to me the missing info should either be 
added to /proc (some under DEBUG?), or the lot should move to /sys.

I don't care all that much, making span etc visible anywhere is an win 
over boot flag + big box (esp. + serial console).

-Mike
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Hang on large copy_from_user with PREEMPT_NONE

2015-04-05 Thread Sasha Levin
Hi all,

I'm seeing an interesting hang when trinity is trying to load a large module, 
where
the size passed by userspace is larger than the amount of memory actually 
allocated
in userspace and passed in the 'from' parameter:

[ 1549.080032] NMI watchdog: BUG: soft lockup - CPU#11 stuck for 22s! 
[trinity-c11:12699]
[ 1549.080032] Modules linked in:
[ 1549.080032] hardirqs last enabled at (4202427): restore_args 
(arch/x86/kernel/entry_64.S:750)
[ 1549.080032] hardirqs last disabled at (4202428): apic_timer_interrupt 
(arch/x86/kernel/entry_64.S:890)
[ 1549.080032] softirqs last enabled at (4202426): __do_softirq 
(./arch/x86/include/asm/preempt.h:22 kernel/softirq.c:300)
[ 1549.080032] softirqs last disabled at (4202421): irq_exit 
(kernel/softirq.c:350 kernel/softirq.c:391)
[ 1549.080032] CPU: 11 PID: 12699 Comm: trinity-c11 Not tainted 
4.0.0-rc6-next-20150402-sasha-00039-ge0bdae3-dirty #2125
[ 1549.080032] task: 880260f3 ti: 88025ebe8000 task.ti: 
88025ebe8000
[ 1549.080032] RIP: copy_user_handle_tail (arch/x86/lib/usercopy_64.c:85)
[ 1549.080032] RSP: :88025ebefe38  EFLAGS: 00010202
[ 1549.080032] RAX: 356cb494 RBX: 11004bd7dfcb RCX: 
[ 1549.080032] RDX: 9277d652 RSI: c90078bba001 RDI: c90078bba000
[ 1549.080032] RBP: 88025ebefe38 R08:  R09: 02f75001
[ 1549.080032] R10:  R11:  R12: 88025ebefe78
[ 1549.080032] R13: 88025ebeff18 R14: 94949494 R15: 00da91be
[ 1549.080032] FS:  7f1f669df700() GS:8803f280() 
knlGS:
[ 1549.080032] CS:  0010 DS:  ES:  CR0: 8005003b
[ 1549.080032] CR2: 02f75000 CR3: 00025d031000 CR4: 07a0
[ 1549.080032] Stack:
[ 1549.080032]  88025ebeff48 963c5ef0 c9001993c000 
00da91be
[ 1549.080032]  41b58ab3 a32918f3 963c5da0 
0286
[ 1549.080032]  c9001993c000 94949494  

[ 1549.080032] Call Trace:
[ 1549.080032] SyS_init_module (kernel/module.c:2505 kernel/module.c:3401 
kernel/module.c:3388)
[ 1549.080032] ? load_module (kernel/module.c:3388)
[ 1549.080032] ia32_do_call (arch/x86/ia32/ia32entry.S:501)
[ 1549.080032] Code: d0 66 66 90 8a 06 66 66 90 45 85 c0 74 d3 85 c9 74 23 89 
d0 45 31 c0 eb 08 83 e8 01 48 89 f7 74 14 48 8d 77 01 44 89 c1 66 66 90  07 
00 66 66 90 85 c9 74 e4 89 d0 66 66 90 5d c3 0f 1f 44 00
All code

   0:   d0 66 66shlb   0x66(%rsi)
   3:   90  nop
   4:   8a 06   mov(%rsi),%al
   6:   66 66 90data32 xchg %ax,%ax
   9:   45 85 c0test   %r8d,%r8d
   c:   74 d3   je 0xffe1
   e:   85 c9   test   %ecx,%ecx
  10:   74 23   je 0x35
  12:   89 d0   mov%edx,%eax
  14:   45 31 c0xor%r8d,%r8d
  17:   eb 08   jmp0x21
  19:   83 e8 01sub$0x1,%eax
  1c:   48 89 f7mov%rsi,%rdi
  1f:   74 14   je 0x35
  21:   48 8d 77 01 lea0x1(%rdi),%rsi
  25:   44 89 c1mov%r8d,%ecx
  28:   66 66 90data32 xchg %ax,%ax
  2b:*  c6 07 00movb   $0x0,(%rdi)  <-- trapping 
instruction
  2e:   66 66 90data32 xchg %ax,%ax
  31:   85 c9   test   %ecx,%ecx
  33:   74 e4   je 0x19
  35:   89 d0   mov%edx,%eax
  37:   66 66 90data32 xchg %ax,%ax
  3a:   5d  pop%rbp
  3b:   c3  retq
  3c:   0f 1f 44 00 00  nopl   0x0(%rax,%rax,1)

Code starting with the faulting instruction
===
   0:   c6 07 00movb   $0x0,(%rdi)
   3:   66 66 90data32 xchg %ax,%ax
   6:   85 c9   test   %ecx,%ecx
   8:   74 e4   je 0xffee
   a:   89 d0   mov%edx,%eax
   c:   66 66 90data32 xchg %ax,%ax
   f:   5d  pop%rbp
  10:   c3  retq
  11:   0f 1f 44 00 00  nopl   0x0(%rax,%rax,1)


This is the result of getting copy_user_handle_tail to zero out a large block of
kernel memory very inefficiently:

for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
if (__put_user_nocheck(c, to++, sizeof(char)))
break;


Thanks,
Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v7 0/5] vfs: Non-blockling buffered fs read (page cache only)

2015-04-05 Thread Milosz Tanski
On Fri, Apr 3, 2015 at 11:42 PM, Andrew Morton
 wrote:
> On Mon, 30 Mar 2015 13:26:25 -0700 Andrew Morton  
> wrote:
>
>> d) fincore() is more expensive
>
> Actually, I kinda take that back.  fincore() will be faster than
> preadv2() in the case of a pagecache miss, and slower in the case of a
> pagecache hit.
>
> The breakpoint appears to be a hit rate of 30% - if fewer than 30% of
> queries find the page in pagecache, fincore() will be faster than
> preadv2().

In my application (motivation for this patch), web-serving
applications (familiar to me), and Samba I'm going to that the
majority of requests are going to be cached. Only some small
percentage will be uncached (say 20%). I'll add to that: a small
percentage but of a large number.

A lot of IO falls into zipfan / sequential pattern. And that makes
send to me a small number of frequently access files and large
streaming data (with read ahead).

>
> This is because for a pagecache miss, fincore() will be about twice as
> fast as preadv2().  For a pagecache hit, fincore()+pread() is 55%
> slower than preadv2().  If there are lots of misses, fincore() is
> faster overall.
>


>
>
>
> Minimal fincore() implementation is below.  It doesn't implement the
> page_map!=NULL mode at all and will be slow for large areas - it needs
> to be taught about radix_tree_for_each_*().  But it's good enough for
> testing.

I'm glad you took the time to do this. It's simple, but your
implementation is much cleaner then the last round of fincore() from 3
years back.

>
> On a slow machine, in nanoseconds:
>
> null syscall:   528
> fincore (miss): 674
> fincore (hit):  729
> single byte pread:  1026
> single byte preadv: 1134

I'm not surprised, fincore() doesn't have to go through all the vfs /
fs machinery that pread or preadv do. By chance if you compare pread /
preadv with a larger read (say 4k) is the difference negligible.

>
> pread() is a bit faster than preadv() and samba uses pread(), so the
> implementations are:
>
> if (fincore(fd, NULL, offset, len) == len)
> pread();
> else
> punt();
>
> if (preadv2(fd, ..., offset, len) == len)
> ...
> else
> punt();
>
> fincore+pread, pagecache-hit:   1755ns
> fincore+pread, pagecache-miss:  674ns
> preadv():   1134ns (preadv2() will be a little faster for 
> misses)
>
>
>
> Now, a pagecache hit rate of 30% sounds high so one would think that
> fincore+pread is clearly ahead.  But the pagecache hit rate in this
> code will actually be quite high, because of readahead.
>
> For a large linear read of a file which is perfectly laid out on disk
> and is fully *uncached*, the hit rates will be as good as 99.8%,
> because readahead is bringing in data in 2MB blobs.
>
> In practice I expect that fincore()+pread() will be slower for linear
> reads of medium to large files and faster for small files and seeky
> accesses.
>
> How much does all this matter?  Not much.  On a fast machine a
> single-byte pread() takes 240ns.  So if your server thread is handling
> 25000 requests/sec, we're only talking 0.6% overhead.
>
> Note that we can trivially monitor the hit rate with either preadv2()
> or fincore()+pread(): just count how many times all the data is there
> versus how many times it isn't.
>
>
>
> Also, note that we can use *both* fincore() and preadv2() to detect the
> problematic page-just-disappeared race:
>
> if (fincore(fd, NULL, offset, len) == len) {
> if (preadv2(fd, offset, len) != len)
> printf("race just happened");
>
> It would be great if someone could apply the below, modify the
> preadv2() callsite as above and determine under what conditions (if
> any) the page-stealing race occurs.
>
>

Let me see what I can do.

>
>  arch/x86/syscalls/syscall_64.tbl |1
>  include/linux/syscalls.h |2
>  mm/Makefile  |2
>  mm/fincore.c |   65 +
>  4 files changed, 69 insertions(+), 1 deletion(-)
>
> diff -puN arch/x86/syscalls/syscall_64.tbl~fincore 
> arch/x86/syscalls/syscall_64.tbl
> --- a/arch/x86/syscalls/syscall_64.tbl~fincore
> +++ a/arch/x86/syscalls/syscall_64.tbl
> @@ -331,6 +331,7 @@
>  32264  execveatstub_execveat
>  32364  preadv2 sys_preadv2
>  32464  pwritev2sys_pwritev2
> +325common  fincore sys_fincore
>
>  #
>  # x32-specific system call numbers start at 512 to avoid cache impact
> diff -puN include/linux/syscalls.h~fincore include/linux/syscalls.h
> --- a/include/linux/syscalls.h~fincore
> +++ a/include/linux/syscalls.h
> @@ -880,6 +880,8 @@ asmlinkage long sys_process_vm_writev(pi
>  asmlinkage long sys_kcmp(pid_t pid1, pid_t pid2, int type,
>  unsigned long idx1, unsigned long idx2);
>  asmlinkage long sys_finit_module(

Re: [PATCH V2] tty: serial: Add const to struct uart_ops declarations

2015-04-05 Thread Sƶren Brinkmann
On Sun, 2015-04-05 at 11:24AM -0700, Joe Perches wrote:
> These structs can be const, so make them const.
> 
> Miscellanea:
> 
> o Add static to struct uart_ops declaration in bfin_sport_uart
> 
> Signed-off-by: Joe Perches 
> ---
[...]

For:
>  drivers/tty/serial/xilinx_uartps.c  | 2 +-

Tested-by: Sƶren Brinkmann 

Sƶren
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] time: allow gcc to fold constants when using msecs_to_jiffies

2015-04-05 Thread Joe Perches
On Mon, 2015-04-06 at 03:00 +0200, Nicholas Mc Guire wrote:
> On Sun, 05 Apr 2015, Joe Perches wrote:
> 
> > On Sun, 2015-04-05 at 09:23 +0200, Nicholas Mc Guire wrote:
> > > The majority of the msecs_to_jiffies() users in the kernel are passing in
> > > constants which would allow gcc to do constant folding by checking with
> > > __builtin_constant_p() in msecs_to_jiffies().
> > > 
> > > The original msecs_to_jiffies is renamed to __msecs_to_jiffies and aside
> > > from the removal of the check for negative values being moved out, is
> > > unaltered.
> > 
> > At least for gcc 4.9, this doesn't allow the compiler
> > to optimize / precalculation msecs_to_jiffies calls
> > with a constant.
> > 
> > This does: (on top of your patch x86-64 defconfig)
> > 
> > $ size vmlinux.o.*
> >textdata bss dec hex filename
> > 117705231505971 1018454 14294948 da1fa4 
> > vmlinux.o.next-b0a12fb5bc8
> > 117705301505971 1018454 14294955 da1fab 
> > vmlinux.o.next-b0a12fb5bc8-inline
> > 117687341505971 1018454 14293159 da18a7 
> > vmlinux.o.next-b0a12fb5bc8-macro
> > 
> > I think this should still move the if (m) < 0 back into the
> > original __msecs_to_jiffies function.
> >
> 
> could you check if you can reproduce the results below ?
> my assumption was that gcc would always optimize out an 
> if(CONST < 0) return CONST; reducing it to the return CONST; 
> only and thus this should not make any difference but Im not 
> that familiar with gcc.
> 
> gcc versions here are:
>  for x86 gcc version 4.7.2 (Debian 4.7.2-5) 
>  for powerpc it is a gcc version 4.9.2 (crosstool-NG 1.20.0)
>  for arm gcc version 4.9.2 20140904 (prerelease) (crosstool-NG 
> linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09)
> 
> Procedure used:
> root@debian:~/linux-next# make distclean
> root@debian:~/linux-next# make defconfig
> root@debian:~/linux-next# make drivers/net/wireless/p54/p54usb.lst
> root@debian:~/linux-next# make drivers/net/wireless/p54/p54usb.s
> 
> same setup in unpatched /usr/src/linux-next/
> 
> e.g:
> root@debian:/usr/src/linux-next# grep msecs_to_jiffies 
> drivers/net/wireless/p54/p54usb.c
> timeout = jiffies + msecs_to_jiffies(1000);
> timeout = jiffies + msecs_to_jiffies(1000);
> 
> So both calls are constants and should be optimized out if it works as
> expected.
> 
> without the patch applied:
> 
> root@debian:/usr/src/linux-next# grep msecs_to_jiffies  
> drivers/net/wireless/p54/p54usb.s
> callmsecs_to_jiffies#
> callmsecs_to_jiffies#
> root@debian:/usr/src/linux-next# grep msecs_to_jiffies 
> drivers/net/wireless/p54/p54usb.lst
> timeout = jiffies + msecs_to_jiffies(1000);
> e19: R_X86_64_PC32  
> msecs_to_jiffies+0xfffc
> timeout = jiffies + msecs_to_jiffies(1000);
> timeout = jiffies + msecs_to_jiffies(1000);
> fd8: R_X86_64_PC32  
> msecs_to_jiffies+0xfffc
> timeout = jiffies + msecs_to_jiffies(1000);
> 
> 
> with the patch applied this then gives me:
> 
> root@debian:~/linux-next# grep msecs_to_jiffies  
> drivers/net/wireless/p54/p54usb.s
> root@debian:~/linux-next# grep msecs_to_jiffies 
> drivers/net/wireless/p54/p54usb.lst
> timeout = jiffies + msecs_to_jiffies(1000);
> timeout = jiffies + msecs_to_jiffies(1000);
> timeout = jiffies + msecs_to_jiffies(1000);
> timeout = jiffies + msecs_to_jiffies(1000);
> 
> Conversely in kernel/sched/core.c the msecs_to_jiffies is not a constant
> and the result is that it calls __msecs_to_jiffies
> 
> patched:
> root@debian:~/linux-next# grep msecs_to_jiffies kernel/sched/core.s
> call__msecs_to_jiffies  #
> 
> unpatched:
> root@debian:/usr/src/linux-next# grep msecs_to_jiffies kernel/sched/core.s
> callmsecs_to_jiffies#
> 
> 
> Could you check if you get these results for this test-case ?
> If this really were compiler dependant that would be very bad.

Hi Nicholas.

Your inline version has not worked with any of
x86-64 gcc 4.4, 4.6, 4.7, or 4.9

I suggest you add some lines to
lib/test_module.c/test_module_init like:

unsigned int m;

for (m = 10; m < 200; m += 10)
pr_info("msecs_to_jiffies(%u) is %lu\n",
m, msecs_to_jiffies(m));

pr_info("msecs_to_jiffies(%u) is %lu\n",
10, msecs_to_jiffies(10));
pr_info("msecs_to_jiffies(%u) is %lu\n",
100, msecs_to_jiffies(100));
pr_info("msecs_to_jiffies(%u) is %lu\n",
1000, msecs_to_jiffies(1000));

Then it's pretty easy to look at the assembly/.lst file

Your inline function doesn't allow gcc to precompute
the msecs_to_jiffies value.  The macro one does for all
those gcc versions.

Try it and look at the generated .lst files with and
without the patch I sent.

cheers, Joe

--
To unsubscribe from this list: send the line 

Re: [RFC PATCH] sched: Add cpu based entries to debugfs

2015-04-05 Thread David Ahern

On 3/31/15 3:13 AM, Ingo Molnar wrote:


* Peter Zijlstra  wrote:


On Mon, Mar 30, 2015 at 10:43:14AM +0200, Mike Galbraith wrote:


I think it would be a good thing if we can get away with it, but I
also think you could safely bet your life that somebody will
squeak.


The thing I worry most about is that squeaking only happening 5
years later :/


So lets start by keeping the sysctl thing with the very
scheduler-internal names, but all zeroes and no effect of any change -
i.e. a dead API in all but appearance. I don't think there's any
legitimate use of those, beyond debugging, as we could change the
internal implementation anymore and moot many of those flags.

So lets trigger the squeaking that way. If any complaint comes in
beyond 1-2 kernel releases then I don't think it's a regression, it
turns into a feature request ...


Sorry to be so dense but I am not clear on what is acceptable and not. 
As mentioned in a previous response, these are the scheduler related 
files I am aware of:


- debufs file for sched_features (/sys/kernel/debug/sched_features)

- /proc/sys/kernel/sched_domain for tweaking scheduling parameters

- /proc/sched_debug - various internal stats

- /sys/devices/system/cpu entries. e.g., for cpu topology (physical 
package id, core id, sibling cores and threads)


None of them show the sched_domain information which is the subject of 
this patch.


Can someone clarify on the duplication concerns and such?

Thanks,
David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 14/16] soc: ti: knav_qmss_queue: fix error return code

2015-04-05 Thread santosh.shilim...@oracle.com

On 4/5/15 5:06 AM, Julia Lawall wrote:

Return a negative error code on failure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// 
@@
identifier ret; expression e1,e2;
@@
(
if (\(ret < 0\|ret != 0\))
  { ... return ret; }
|
ret = 0
)
... when != ret = e1
 when != &ret
*if(...)
{
   ... when != ret = e2
   when forall
  return ret;
}
// 

Signed-off-by: Julia Lawall 

---

Acked-by: Santosh Shilimkar 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] mtd: Make MTD tests cancelable

2015-04-05 Thread Brian Norris
On Sun, Mar 29, 2015 at 09:52:06PM +0200, Richard Weinberger wrote:
> I always go nuts when I start an MTD test on a slow device
> and have to wait forever until it finishes.

As do I.

As an additional measure, I'm tempted to add an 'ebcnt' parameter for
some of the tests that don't have them, for when I want a quicker test.

> From the debug output I already know what the issue is but I
> have to wait or reset the board hard.
> Resetting is often not an option
> (remote access, you don't want lose the current state, etc...).
> 
> The solution is easy, check for pending signals at key positions
> in the code. Using that one can even stop a test by pressing CTRL-C
> as insmod/modprobe have SIGINT pending.
> 
> Signed-off-by: Richard Weinberger 
> ---
> v2: First patch was missing two hunks from my working tree.
> git commit -a vs. git commit ;-\

Awesome! Pushed to l2-mtd.git. Thanks.

Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6] spi: Add SPI driver for Mikrotik RB4xx series boards

2015-04-05 Thread Bert Vermeulen
This driver mediates access between the connected CPLD and other devices
on the bus.

The m25p80-compatible boot flash and (some models) MMC use regular SPI,
bitbanged as required by the SoC. However the SPI-connected CPLD has
a "fast write" mode, in which two bits are transferred by SPI clock
cycle. The second bit is transmitted with the SoC's CS2 pin.

Protocol drivers using this fast write facility signal this by setting
the cs_change flag on transfers.

Signed-off-by: Bert Vermeulen 
---
Changes in v6:
- removed unnecessary SPI mode check
- whitespace fixes


 drivers/spi/Kconfig |   6 ++
 drivers/spi/Makefile|   1 +
 drivers/spi/spi-rb4xx.c | 239 
 3 files changed, 246 insertions(+)
 create mode 100644 drivers/spi/spi-rb4xx.c

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index ab8dfbe..8b1beaf6 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -429,6 +429,12 @@ config SPI_ROCKCHIP
  The main usecase of this controller is to use spi flash as boot
  device.
 
+config SPI_RB4XX
+   tristate "Mikrotik RB4XX SPI master"
+   depends on SPI_MASTER && ATH79
+   help
+ SPI controller driver for the Mikrotik RB4xx series boards.
+
 config SPI_RSPI
tristate "Renesas RSPI/QSPI controller"
depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index d8cbf65..0218f39 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -66,6 +66,7 @@ obj-$(CONFIG_SPI_PXA2XX)  += spi-pxa2xx-platform.o
 obj-$(CONFIG_SPI_PXA2XX_PCI)   += spi-pxa2xx-pci.o
 obj-$(CONFIG_SPI_QUP)  += spi-qup.o
 obj-$(CONFIG_SPI_ROCKCHIP) += spi-rockchip.o
+obj-$(CONFIG_SPI_RB4XX)+= spi-rb4xx.o
 obj-$(CONFIG_SPI_RSPI) += spi-rspi.o
 obj-$(CONFIG_SPI_S3C24XX)  += spi-s3c24xx-hw.o
 spi-s3c24xx-hw-y   := spi-s3c24xx.o
diff --git a/drivers/spi/spi-rb4xx.c b/drivers/spi/spi-rb4xx.c
new file mode 100644
index 000..0cead2e
--- /dev/null
+++ b/drivers/spi/spi-rb4xx.c
@@ -0,0 +1,239 @@
+/*
+ * SPI controller driver for the Mikrotik RB4xx boards
+ *
+ * Copyright (C) 2010 Gabor Juhos 
+ * Copyright (C) 2015 Bert Vermeulen 
+ *
+ * This file was based on the patches for Linux 2.6.27.39 published by
+ * MikroTik for their RouterBoard 4xx series devices.
+ *
+ * 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.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define SPI_CLOCK_FASTEST  0x40
+#define SPI_HZ 3334
+#define CPLD_CMD_WRITE_NAND0x08 /* bulk write mode */
+
+struct rb4xx_spi {
+   void __iomem*base;
+   struct spi_master   *master;
+};
+
+static inline u32 rb4xx_read(struct rb4xx_spi *rbspi, u32 reg)
+{
+   return __raw_readl(rbspi->base + reg);
+}
+
+static inline void rb4xx_write(struct rb4xx_spi *rbspi, u32 reg, u32 value)
+{
+   __raw_writel(value, rbspi->base + reg);
+}
+
+static inline void do_spi_clk(struct rb4xx_spi *rbspi, u32 spi_ioc, int value)
+{
+   u32 regval;
+
+   regval = spi_ioc;
+   if (value & BIT(0))
+   regval |= AR71XX_SPI_IOC_DO;
+
+   rb4xx_write(rbspi, AR71XX_SPI_REG_IOC, regval);
+   rb4xx_write(rbspi, AR71XX_SPI_REG_IOC, regval | AR71XX_SPI_IOC_CLK);
+}
+
+static void do_spi_byte(struct rb4xx_spi *rbspi, u32 spi_ioc, u8 byte)
+{
+   int i;
+
+   for (i = 7; i >= 0; i--)
+   do_spi_clk(rbspi, spi_ioc, byte >> i);
+}
+
+static inline void do_spi_clk_fast(struct rb4xx_spi *rbspi, u32 spi_ioc,
+  u8 value)
+{
+   u32 regval;
+
+   regval = spi_ioc;
+   if (value & BIT(1))
+   regval |= AR71XX_SPI_IOC_DO;
+   if (value & BIT(0))
+   regval |= AR71XX_SPI_IOC_CS2;
+
+   rb4xx_write(rbspi, AR71XX_SPI_REG_IOC, regval);
+   rb4xx_write(rbspi, AR71XX_SPI_REG_IOC, regval | AR71XX_SPI_IOC_CLK);
+}
+
+/* Two bits at a time, msb first */
+static void do_spi_byte_fast(struct rb4xx_spi *rbspi, u32 spi_ioc, u8 byte)
+{
+   do_spi_clk_fast(rbspi, spi_ioc, byte >> 6);
+   do_spi_clk_fast(rbspi, spi_ioc, byte >> 4);
+   do_spi_clk_fast(rbspi, spi_ioc, byte >> 2);
+   do_spi_clk_fast(rbspi, spi_ioc, byte >> 0);
+}
+
+static void rb4xx_set_cs(struct spi_device *spi, bool enable)
+{
+   struct rb4xx_spi *rbspi = spi_master_get_devdata(spi->master);
+
+   /*
+* Setting CS is done along with bitbanging the actual values,
+* since it's all on the same hardware register. However the
+* CPLD needs CS deselected after every command.
+*/
+   if (!enable)
+   rb4xx_write(rbspi, AR71XX_SPI_REG_IOC,
+   

[PATCH] mfd: Add support for CPLD chip on Mikrotik RB4xx boards

2015-04-05 Thread Bert Vermeulen
The SPI-connected CPLD chip controls access to the main NAND flash
chip and five LEDs.

Signed-off-by: Bert Vermeulen 
---
 arch/mips/include/asm/mach-ath79/rb4xx_cpld.h |  49 +
 drivers/mfd/Kconfig   |   7 +
 drivers/mfd/Makefile  |   1 +
 drivers/mfd/rb4xx-cpld.c  | 279 ++
 4 files changed, 336 insertions(+)
 create mode 100644 arch/mips/include/asm/mach-ath79/rb4xx_cpld.h
 create mode 100644 drivers/mfd/rb4xx-cpld.c

diff --git a/arch/mips/include/asm/mach-ath79/rb4xx_cpld.h 
b/arch/mips/include/asm/mach-ath79/rb4xx_cpld.h
new file mode 100644
index 000..40c109c
--- /dev/null
+++ b/arch/mips/include/asm/mach-ath79/rb4xx_cpld.h
@@ -0,0 +1,49 @@
+/*
+ * SPI driver definitions for the CPLD chip on the Mikrotik RB4xx boards
+ *
+ * Copyright (C) 2010 Gabor Juhos 
+ *
+ * This file was based on the patches for Linux 2.6.27.39 published by
+ * MikroTik for their RouterBoard 4xx series devices.
+ *
+ * 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.
+ */
+
+#define CPLD_GPIO_LED1 0
+#define CPLD_GPIO_LED2 1
+#define CPLD_GPIO_LED3 2
+#define CPLD_GPIO_LED4 3
+#define CPLD_GPIO_FAN  4
+#define CPLD_GPIO_ALE  5
+#define CPLD_GPIO_CLE  6
+#define CPLD_GPIO_nCE  7
+#define CPLD_GPIO_LED5 8
+
+#define CPLD_NUM_GPIOS 9
+
+#define CPLD_CFG_LED1  BIT(CPLD_GPIO_LED1)
+#define CPLD_CFG_LED2  BIT(CPLD_GPIO_LED2)
+#define CPLD_CFG_LED3  BIT(CPLD_GPIO_LED3)
+#define CPLD_CFG_LED4  BIT(CPLD_GPIO_LED4)
+#define CPLD_CFG_FAN   BIT(CPLD_GPIO_FAN)
+#define CPLD_CFG_ALE   BIT(CPLD_GPIO_ALE)
+#define CPLD_CFG_CLE   BIT(CPLD_GPIO_CLE)
+#define CPLD_CFG_nCE   BIT(CPLD_GPIO_nCE)
+#define CPLD_CFG_LED5  BIT(CPLD_GPIO_LED5)
+
+#define CPLD_CMD_WRITE_NAND0x08 /* send cmd, n x send data, send idle */
+#define CPLD_CMD_WRITE_CFG 0x09 /* send cmd, n x send cfg */
+#define CPLD_CMD_READ_NAND 0x0a /* send cmd, send idle, n x read data */
+#define CPLD_CMD_READ_FAST 0x0b /* send cmd, 4 x idle, n x read data */
+#define CPLD_CMD_LED5_ON   0x0c /* send cmd */
+#define CPLD_CMD_LED5_OFF  0x0d /* send cmd */
+
+struct rb4xx_cpld_platform_data {
+   unsigned gpio_base;
+};
+
+extern int rb4xx_cpld_read(struct spi_device *spi, unsigned char *rx_buf,
+  unsigned len);
+extern int rb4xx_cpld_write(struct spi_device *spi, const u8 *buf, int len);
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 38356e3..c4a6a4e 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -631,6 +631,13 @@ config MFD_SPMI_PMIC
  Say M here if you want to include support for the SPMI PMIC
  series as a module.  The module will be called "qcom-spmi-pmic".
 
+config MFD_RB4XX_CPLD
+   tristate "MikroTik RB4XX CPLD driver"
+   depends on ATH79 && SPI_RB4XX
+   help
+ Driver for the CPLD chip present on MikroTik RB4xx boards.
+ It controls CPU access to NAND flash and user LEDs.
+
 config MFD_RDC321X
tristate "RDC R-321x southbridge"
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 19f3d74..6cc9fe3 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -155,6 +155,7 @@ obj-$(CONFIG_MFD_OMAP_USB_HOST) += omap-usb-host.o 
omap-usb-tll.o
 obj-$(CONFIG_MFD_PM8921_CORE)  += pm8921-core.o ssbi.o
 obj-$(CONFIG_MFD_QCOM_RPM) += qcom_rpm.o
 obj-$(CONFIG_MFD_SPMI_PMIC)+= qcom-spmi-pmic.o
+obj-$(CONFIG_MFD_RB4XX_CPLD)   += rb4xx-cpld.o
 obj-$(CONFIG_TPS65911_COMPARATOR)  += tps65911-comparator.o
 obj-$(CONFIG_MFD_TPS65090) += tps65090.o
 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
diff --git a/drivers/mfd/rb4xx-cpld.c b/drivers/mfd/rb4xx-cpld.c
new file mode 100644
index 000..0f8de62
--- /dev/null
+++ b/drivers/mfd/rb4xx-cpld.c
@@ -0,0 +1,279 @@
+/*
+ * SPI driver for the CPLD chip on the Mikrotik RB4xx boards
+ *
+ * Copyright (C) 2010 Gabor Juhos 
+ *
+ * This file was based on the patches for Linux 2.6.27.39 published by
+ * MikroTik for their RouterBoard 4xx series devices.
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+struct rb4xx_cpld {
+   struct spi_device *spi;
+   struct mutex lock;
+   struct gpio_chip chip;
+   unsigned int config;
+};
+
+static inline struct rb4xx_cpld *gpio_to_cpld(struct gpio_chip *chip)
+{
+   return container_of(chip, struct rb4xx_cpld, chip);
+}
+
+static int rb4xx_cpld_write_cmd(st

Re: [PATCH 1/2] mtd: mtd_oobtest: Fix bitflip_limit usage in test case 3

2015-04-05 Thread Brian Norris
On Fri, Dec 05, 2014 at 05:18:39PM +0200, Roger Quadros wrote:
> In test case 3, we set vary_offset to write at different
> offsets and lengths in the OOB available area. We need to
> do the bitflip_limit check while checking for 0xff outside the
> OOB offset + length area that we didn't modify during write.
> 
> Signed-off-by: Roger Quadros 

Applied patch 1 to l2-mtd.git. Patch 2 couldn't be applied cleanly.

Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mtd: fsl_ifc_nand: use msecs_to_jiffies for time conversion

2015-04-05 Thread Brian Norris
On Fri, Mar 13, 2015 at 07:23:47AM -0400, Nicholas Mc Guire wrote:
> This is only an API consolidation and should make things more readable
> it replaces var * HZ / 1000 by msecs_to_jiffies(var) which helps readability
> and also handles all corner-cases properly.
> 
> Signed-off-by: Nicholas Mc Guire 

Pushed to l2-mtd.git.

I'm not sure the objections about an extra function call are important
right now; if they are, then it shouldn't be too hard to patch in a
__builtin_constant_p() variant of msecs_to_jiffies(), as Joe suggested.

Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/3] time: allow gcc to fold constants when using msecs_to_jiffies

2015-04-05 Thread Nicholas Mc Guire
On Sun, 05 Apr 2015, Joe Perches wrote:

> On Sun, 2015-04-05 at 09:23 +0200, Nicholas Mc Guire wrote:
> > The majority of the msecs_to_jiffies() users in the kernel are passing in
> > constants which would allow gcc to do constant folding by checking with
> > __builtin_constant_p() in msecs_to_jiffies().
> > 
> > The original msecs_to_jiffies is renamed to __msecs_to_jiffies and aside
> > from the removal of the check for negative values being moved out, is
> > unaltered.
> 
> At least for gcc 4.9, this doesn't allow the compiler
> to optimize / precalculation msecs_to_jiffies calls
> with a constant.
> 
> This does: (on top of your patch x86-64 defconfig)
> 
> $ size vmlinux.o.*
>text  data bss dec hex filename
> 11770523  1505971 1018454 14294948 da1fa4 
> vmlinux.o.next-b0a12fb5bc8
> 11770530  1505971 1018454 14294955 da1fab 
> vmlinux.o.next-b0a12fb5bc8-inline
> 11768734  1505971 1018454 14293159 da18a7 
> vmlinux.o.next-b0a12fb5bc8-macro
> 
> I think this should still move the if (m) < 0 back into the
> original __msecs_to_jiffies function.
>

could you check if you can reproduce the results below ?
my assumption was that gcc would always optimize out an 
if(CONST < 0) return CONST; reducing it to the return CONST; 
only and thus this should not make any difference but Im not 
that familiar with gcc.

gcc versions here are:
 for x86 gcc version 4.7.2 (Debian 4.7.2-5) 
 for powerpc it is a gcc version 4.9.2 (crosstool-NG 1.20.0)
 for arm gcc version 4.9.2 20140904 (prerelease) (crosstool-NG 
linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09)

Procedure used:
root@debian:~/linux-next# make distclean
root@debian:~/linux-next# make defconfig
root@debian:~/linux-next# make drivers/net/wireless/p54/p54usb.lst
root@debian:~/linux-next# make drivers/net/wireless/p54/p54usb.s

same setup in unpatched /usr/src/linux-next/

e.g:
root@debian:/usr/src/linux-next# grep msecs_to_jiffies 
drivers/net/wireless/p54/p54usb.c
timeout = jiffies + msecs_to_jiffies(1000);
timeout = jiffies + msecs_to_jiffies(1000);

So both calls are constants and should be optimized out if it works as
expected.

without the patch applied:

root@debian:/usr/src/linux-next# grep msecs_to_jiffies  
drivers/net/wireless/p54/p54usb.s
callmsecs_to_jiffies#
callmsecs_to_jiffies#
root@debian:/usr/src/linux-next# grep msecs_to_jiffies 
drivers/net/wireless/p54/p54usb.lst
timeout = jiffies + msecs_to_jiffies(1000);
e19: R_X86_64_PC32  
msecs_to_jiffies+0xfffc
timeout = jiffies + msecs_to_jiffies(1000);
timeout = jiffies + msecs_to_jiffies(1000);
fd8: R_X86_64_PC32  
msecs_to_jiffies+0xfffc
timeout = jiffies + msecs_to_jiffies(1000);


with the patch applied this then gives me:

root@debian:~/linux-next# grep msecs_to_jiffies  
drivers/net/wireless/p54/p54usb.s
root@debian:~/linux-next# grep msecs_to_jiffies 
drivers/net/wireless/p54/p54usb.lst
timeout = jiffies + msecs_to_jiffies(1000);
timeout = jiffies + msecs_to_jiffies(1000);
timeout = jiffies + msecs_to_jiffies(1000);
timeout = jiffies + msecs_to_jiffies(1000);

Conversely in kernel/sched/core.c the msecs_to_jiffies is not a constant
and the result is that it calls __msecs_to_jiffies

patched:
root@debian:~/linux-next# grep msecs_to_jiffies kernel/sched/core.s
call__msecs_to_jiffies  #

unpatched:
root@debian:/usr/src/linux-next# grep msecs_to_jiffies kernel/sched/core.s
callmsecs_to_jiffies#


Could you check if you get these results for this test-case ?
If this really were compiler dependant that would be very bad.

I did move the < 0 check - but that did not change the situation here.
but it well may be that there are some cases where this does make a
difference 

thx!
hofrat
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] ARM: kexec: Relax SMP validation to improve DT compatibility

2015-04-05 Thread Simon Horman
On Wed, Apr 01, 2015 at 02:30:47PM +0200, Geert Uytterhoeven wrote:
> When trying to kexec into a new kernel on a platform where multiple CPU
> cores are present, but no SMP bringup code is available yet, the
> kexec_load system call fails with:
> 
> kexec_load failed: Invalid argument
> 
> The SMP test added to machine_kexec_prepare() in commit 2103f6cba61a8b8b
> ("ARM: 7807/1: kexec: validate CPU hotplug support") wants to prohibit
> kexec on SMP platforms where it cannot disable secondary CPUs.
> However, this test is too strict: if the secondary CPUs couldn't be
> enabled in the first place, there's no need to disable them later at
> kexec time.  Hence skip the test in the absence of SMP bringup code.
> 
> This allows to add all CPU cores to the DTS from the beginning, without
> having to implement SMP bringup first, improving DT compatibility.
> 
> Signed-off-by: Geert Uytterhoeven 
> Acked-by: Stephen Warren 

Reviewed-by: Simon Horman 

> ---
> v2:
>   - Add Acked-by.
> ---
>  arch/arm/include/asm/smp_plat.h | 1 +
>  arch/arm/kernel/machine_kexec.c | 3 ++-
>  arch/arm/kernel/smp.c   | 5 +
>  3 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/include/asm/smp_plat.h b/arch/arm/include/asm/smp_plat.h
> index 0ad7d490ee6f2657..993e5224d8f7eeeb 100644
> --- a/arch/arm/include/asm/smp_plat.h
> +++ b/arch/arm/include/asm/smp_plat.h
> @@ -104,6 +104,7 @@ static inline u32 mpidr_hash_size(void)
>   return 1 << mpidr_hash.bits;
>  }
>  
> +extern int platform_can_secondary_boot(void);
>  extern int platform_can_cpu_hotplug(void);
>  
>  #endif
> diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
> index de2b085ad7535da7..8bf3b7c098881b95 100644
> --- a/arch/arm/kernel/machine_kexec.c
> +++ b/arch/arm/kernel/machine_kexec.c
> @@ -46,7 +46,8 @@ int machine_kexec_prepare(struct kimage *image)
>* and implements CPU hotplug for the current HW. If not, we won't be
>* able to kexec reliably, so fail the prepare operation.
>*/
> - if (num_possible_cpus() > 1 && !platform_can_cpu_hotplug())
> + if (num_possible_cpus() > 1 && platform_can_secondary_boot() &&
> + !platform_can_cpu_hotplug())
>   return -EINVAL;
>  
>   /*
> diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
> index 86ef244c5a24b4fa..cca5b87581855244 100644
> --- a/arch/arm/kernel/smp.c
> +++ b/arch/arm/kernel/smp.c
> @@ -145,6 +145,11 @@ void __init smp_init_cpus(void)
>   smp_ops.smp_init_cpus();
>  }
>  
> +int platform_can_secondary_boot(void)
> +{
> + return !!smp_ops.smp_boot_secondary;
> +}
> +
>  int platform_can_cpu_hotplug(void)
>  {
>  #ifdef CONFIG_HOTPLUG_CPU
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] Revert "staging: board: disable as it breaks the build"

2015-04-05 Thread Simon Horman
On Fri, Apr 03, 2015 at 02:41:58PM +0200, Geert Uytterhoeven wrote:
> This reverts commit d13778d537a0ed6115d2a79a942af999cfb8eec6.
> 
> Commit 13c11072536f2613 ("staging:board: remove unnecessary function")
> fixed the build of drivers/staging/board/board.c.
> 
> Signed-off-by: Geert Uytterhoeven 

Signed-off-by: Simon Horman 

> ---
>  drivers/staging/board/Kconfig | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/staging/board/Kconfig b/drivers/staging/board/Kconfig
> index 0a89ad16371f7ded..b8ee81840666ad35 100644
> --- a/drivers/staging/board/Kconfig
> +++ b/drivers/staging/board/Kconfig
> @@ -1,7 +1,6 @@
>  config STAGING_BOARD
>   bool "Staging Board Support"
>   depends on OF_ADDRESS
> - depends on BROKEN
>   help
> Select to enable per-board staging support code.
>  
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2] tty: serial: Add const to struct uart_ops declarations

2015-04-05 Thread Joe Perches
On Mon, 2015-04-06 at 01:09 +0200, Stefan Agner wrote:
> On 2015-04-05 20:24, Joe Perches wrote:
> > Still compiled only x86 and not cross-compiled or tested.
> 
> Cross-compiled with multi_v7_defconfig
[]
> >  drivers/tty/serial/fsl_lpuart.c | 4 ++--
> 
> Tested that driver on actual hardware, looks fine.

> This driver seems to alter the startup function on initialization:
> 
>   CC  drivers/video/of_display_timing.o
> ../drivers/tty/serial/samsung.c: In function 's3c24xx_serial_init_port':
> ../drivers/tty/serial/samsung.c:1702:3: error: assignment of member
> 'startup' in read-only object
>s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
>^

Thanks Stefan.  Then that one can't be const.

> That is the only thing which popped up with multi_v7_defconfig.

I appreciate the testing.

Greg, Jiri, I'll resend with this fixed in a week or so
after waiting for any other comment or sign of brokenness.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] regulator: add a data summary tree in debugfs

2015-04-05 Thread Heiko StĆ¼bner
On modern systems the regulator hierarchy can get quite long and nested
with regulators supplying other regulators. In some cases when debugging
it might be nice to get a tree of these regulators, their consumers
and the regulation constraints in one go.

To achieve this add a regulator_summary sysfs node, similar to
clk_summary in the common clock framework, that walks the regulator
list and creates a tree out of the regulators, their consumers and
core per-regulator settings.

On a rk3288-firefly the regulator_summary would for example look
something like:

 regulator  use,open,bypass  valueminmax

 vcc_sys  0,  12, 0 5000mV 5000mV 5000mV
vcc_lan   1,   1, 0 3300mV 3300mV 3300mV
   ff29.ethernet  0mV0mV
vcca_33   0,   0, 0 3300mV 3300mV 3300mV
vcca_18   0,   0, 0 1800mV 1800mV 1800mV
vdd10_lcd 0,   0, 0 1000mV 1000mV 1000mV
vccio_sd  0,   0, 0 3300mV 3300mV 3300mV
vcc_200,   3, 0 2000mV 2000mV 2000mV
   vcc18_lcd  0,   0, 0 1800mV 1800mV 1800mV
   vcc_18 0,   2, 0 1800mV 1800mV 1800mV
  ff10.saradc 0mV0mV
  ff0d.dwmmc   1650mV 1950mV
   vdd_10 0,   0, 0 1000mV 1000mV 1000mV
vdd_log   0,   0, 0 1100mV 1100mV 1100mV
vcc_io0,   3, 0 3300mV 3300mV 3300mV
   ff0f.dwmmc  3300mV 3400mV
   vcc_flash  1,   1, 0 1800mV 1800mV 1800mV
  ff0f.dwmmc   1700mV 1950mV
   vcc_sd 1,   1, 0 3300mV 3300mV 3300mV
  ff0c.dwmmc   3300mV 3400mV
vcc_ddr   0,   0, 0 1200mV 1200mV 1200mV
vdd_gpu   0,   0, 0 1000mV  850mV 1350mV
vdd_cpu   0,   1, 0  900mV  850mV 1350mV
   cpu0 900mV  900mV
vcc_5v0,   2, 0 5000mV 5000mV 5000mV
   vcc_otg_5v 0,   0, 0 5000mV 5000mV 5000mV
   vcc_host_5v0,   0, 0 5000mV 5000mV 5000mV

Signed-off-by: Heiko Stuebner 
---
 drivers/regulator/core.c | 113 +++
 1 file changed, 113 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a4a8a6d..950fe22 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3936,6 +3936,116 @@ static const struct file_operations supply_map_fops = {
 #endif
 };
 
+#ifdef CONFIG_DEBUG_FS
+static void regulator_summary_show_subtree(struct seq_file *s,
+  struct regulator_dev *rdev,
+  int level)
+{
+   struct list_head *list = s->private;
+   struct regulator_dev *child;
+   struct regulation_constraints *c;
+   struct regulator *consumer;
+
+   if (!rdev)
+   return;
+
+   mutex_lock(&rdev->mutex);
+
+   seq_printf(s, "%*s%-*s %3d,%4d,%6d ",
+  level * 3 + 1, "",
+  30 - level * 3, rdev_get_name(rdev),
+  rdev->use_count, rdev->open_count, rdev->bypass_count);
+
+   switch (rdev->desc->type) {
+   case REGULATOR_VOLTAGE:
+   seq_printf(s, "%8dmV ",
+  _regulator_get_voltage(rdev) / 1000);
+   break;
+   case REGULATOR_CURRENT:
+   seq_printf(s, "%8dmA ",
+  _regulator_get_current_limit(rdev) / 1000);
+   break;
+   }
+
+   c = rdev->constraints;
+   if (c) {
+   switch (rdev->desc->type) {
+   case REGULATOR_VOLTAGE:
+   seq_printf(s, "%8dmV %8dmV ",
+  c->min_uV / 1000, c->max_uV / 1000);
+   break;
+   case REGULATOR_CURRENT:
+   seq_printf(s, "%8dmA %8dmA ",
+  c->min_uA / 1000, c->max_uA / 1000);
+   break;
+   }
+   }
+
+   seq_puts(s, "\n");
+
+   list_for_each_entry(consumer, &rdev->consumer_list, list) {
+   if

Re: [PATCH 2/3] time: allow gcc to fold constants when using msecs_to_jiffies

2015-04-05 Thread Joe Perches
On Sun, 2015-04-05 at 09:23 +0200, Nicholas Mc Guire wrote:
> The majority of the msecs_to_jiffies() users in the kernel are passing in
> constants which would allow gcc to do constant folding by checking with
> __builtin_constant_p() in msecs_to_jiffies().
> 
> The original msecs_to_jiffies is renamed to __msecs_to_jiffies and aside
> from the removal of the check for negative values being moved out, is
> unaltered.

At least for gcc 4.9, this doesn't allow the compiler
to optimize / precalculation msecs_to_jiffies calls
with a constant.

This does: (on top of your patch x86-64 defconfig)

$ size vmlinux.o.*
   textdata bss dec hex filename
117705231505971 1018454 14294948 da1fa4 
vmlinux.o.next-b0a12fb5bc8
117705301505971 1018454 14294955 da1fab 
vmlinux.o.next-b0a12fb5bc8-inline
117687341505971 1018454 14293159 da18a7 
vmlinux.o.next-b0a12fb5bc8-macro

I think this should still move the if (m) < 0 back into the
original __msecs_to_jiffies function.

---

 include/linux/jiffies.h | 71 -
 1 file changed, 46 insertions(+), 25 deletions(-)

diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index a75158e..f8fe9f7 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -291,6 +291,39 @@ static inline u64 jiffies_to_nsecs(const unsigned long j)
 
 extern unsigned long __msecs_to_jiffies(const unsigned int m);
 
+#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
+#define const_msecs_to_jiffies(m)  \
+({ \
+   unsigned long j;\
+   if ((int)m < 0) \
+   j = MAX_JIFFY_OFFSET;   \
+   else\
+   j = (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ); \
+   j;  \
+})
+#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
+#define const_msecs_to_jiffies(m)  \
+({ \
+   unsigned long j;\
+   if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET)) \
+   j = MAX_JIFFY_OFFSET;   \
+   else\
+   j = m * (HZ / MSEC_PER_SEC);\
+   j;  \
+})
+#else
+#define const_msecs_to_jiffies(m)  \
+({ \
+   unsigned long j;\
+   if (HZ > MSEC_PER_SEC && m > jiffies_to_msecs(MAX_JIFFY_OFFSET))\
+   j = MAX_JIFFY_OFFSET;   \
+   else\
+   j = (MSEC_TO_HZ_MUL32 * m + MSEC_TO_HZ_ADJ32)   \
+   >> MSEC_TO_HZ_SHR32;\
+   j;  \
+})
+#endif
+
 /**
  * msecs_to_jiffies: - convert milliseconds to jiffies
  * @m: time in millisecons 
@@ -313,31 +346,19 @@ extern unsigned long __msecs_to_jiffies(const unsigned 
int m);
  * allow constant folding and the actual conversion must be done at
  * runtime.
  */
-static inline unsigned long msecs_to_jiffies(const unsigned int m)
-{
-   /*
-* Negative value, means infinite timeout:
-*/
-   if ((int)m < 0)
-   return MAX_JIFFY_OFFSET;
-
-   if (__builtin_constant_p(m)) {
-#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
-   return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);
-#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
-   if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
-   return MAX_JIFFY_OFFSET;
-   return m * (HZ / MSEC_PER_SEC);
-#else
-   if (HZ > MSEC_PER_SEC && m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
-   return MAX_JIFFY_OFFSET;
-
-   return (MSEC_TO_HZ_MUL32 * m + MSEC_TO_HZ_ADJ32)
-   >> MSEC_TO_HZ_SHR32;
-#endif
-   } else
-   return __msecs_to_jiffies(m);
-}
+#define msecs_to_jiffies(m)\
+({ \
+   unsigned long j;\
+   if (__builtin_constant_p(m)) {  \
+   if ((int)m < 0) \
+  

Re: [PATCH] Input: atkbd: Fix release quirk for Dell models

2015-04-05 Thread Dmitry Torokhov
On Mon, Apr 06, 2015 at 12:00:32AM +0200, Pali RohƔr wrote:
> On Sunday 05 April 2015 23:48:33 Dmitry Torokhov wrote:
> > Hi Pali,
> > 
> > On Sun, Mar 29, 2015 at 04:36:19PM +0200, Pali RohƔr wrote:
> > > This patch fixes commit 61579ba83934 ("Input: atkbd - expand
> > > Latitude's force release quirk to other Dells"). Before
> > > that commit release quirks were called for all Dell
> > > Latitude models. After that commit only for Portable Dell
> > > devices. But lot of Latitude models are Laptop or Notebook
> > > DMI devices so quirks are not called.
> > > 
> > > Release quirks are still needed also for new Dell Latitude
> > > models, so this patch enables quirks for all Portable,
> > > Laptop, Notebook and Sub-Notebook Dell devices.
> > 
> > Does Dell use all these types for their laptops? What models
> > do you know that need this quirk?
> > 
> > Thanks.
> > 
> 
> I do not if Dell use all types, but months ago Matthew wrote to 
> include also other numbers not only 9 (Laptop) and you agreed.

Hmm, I tried looking back but I could not quite find the discussion.

> 
> I do not know exact list of models which needs these quirks, but 
> before that commit (61579ba83934) it was used for all Latitude 
> models. At least I see that switches do not generate release 
> events and on older Latitude machines some Fn keys do not 
> generate them too.

So the question is still: what models do need this quirk and what
chassis type they are used.

Regardless, I have not accepted quirks for force_release and atkbd
keymaps for many years now as the task to adjust both keymap and
force_release list has been offloaded to udev.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 07/11] ARM: allow MULTIPLATFORM with !MMU

2015-04-05 Thread Stefan Agner
On 2015-04-06 00:44, Russell King - ARM Linux wrote:
> On Mon, Apr 06, 2015 at 12:19:43AM +0200, Stefan Agner wrote:
>> On 2015-04-05 18:10, Russell King - ARM Linux wrote:
>> > config ARM_SINGLE_ARMV7M
>> >bool "ARM architecture v7M compliant (Cortex-M0/M3/M4) SoC"
>> >depends on !MMU
>> >select ARM_NVIC
>> >... etc ...
>>
>> I guess that would be ARCH_SINGLE_ARMV7M?
> 
> No, I meant ARM_SINGLE_xxx
> 
>> > which then allows a /multiplatform/ v7M kernel to be built, allowing the
>> > selection of EFM32, SOC_VF610, and any other v7M compliant SoC.
>>
>> In my view, that wouldn't end up being much different than what that
>> patchset is doing:
> 
> It's different.  It's different because we are _not_ enabling multiplatform.
> Multiplatform brings with it all the MMU-full stuff that we don't want on
> !MMU.

You mean config symbols? There are 2-3 config symbols we don't want with
ARCH_MULTI_V7M and we have to exclude. But there would be also a
duplication of some already given by multiplatform when creating a new
top level config symbol...
 
> You're thinking far too specifically about V7M here.  We have other !MMU
> CPUs, such as ARM946 and ARM940 which are older generation mmuless CPUs.
> 
> The problem with the ARCH_MULTI_V7M approach is that they're V4T and V5
> CPUs, and we _really_ don't want to enable ARCH_MULTI_V4T and
> ARCH_MULTI_V5.  If we did that, we'll allow _every_ V4T and V5
> multiplatform to be selected, whether they're compatible with nommu
> or not - and whether they're compatible with each other or not.

Just from a selection view, ARM946 and ARM940 would still _not_ be
selectable because this change makes ARCH_MULTI_V4T/V5 being dependent
on MMU.

> 
> So, that kind of solution _doesn't_ scale to what we _once_ already
> allowed.
> 
>> As far as I can tell, this is already the case with that patchset.
> 
> What I'm trying to do here is to fix the cockup that the multiplatform
> conversion has created with previous generation noMMU and restore it
> back to where it should be without excluding the newer stuff from it.

Would be a partial revert (remove ARCH_MULTI_* from CPU_ARM940T and
CPU_ARM946E) of dc680b989d51 ("ARM: fix multiplatform allmodcompile") be
the right thing to do then? Given that ARCH_MULTI_V4T/V5 is MMU
dependent, those CPU's will not be selected even when building the
integrator multiplatform image... However, due to the selection
limitations outlined above, this would only be cosmetic anyway.
 
> What you're interested in is just the newer stuff.  You're approaching
> the problem from a different angle and thinking that your solution is
> the best.  I'm saying it has deficiencies.

When keeping the old CPU's out of multiplatform game properly, what
would speak against ARCH_MULTI_V7M? I still think if we allow a
multiplatform v7M image, it is cleaner to align that to the MMU
multiplatform stuff.

Maybe I don't really get the grasp of ARM_SINGLE_ARMV7M. In my
understanding it would be a new top level config symbol which kind of
merges ARCH_MULTIPLATFORM and ARCH_MULTI_V7M.

It is not my goal to enable !MMU on MULTIARCH per se. It's just that
when enabling V7M with ARCH_MULTIPLATFORM, it makes it easier to enable
the Cortex-M4 for the HMP platforms on those multiplatform only SoC's.
When creating a new config symbol on a high level, this advantage is
gone... I then could also create a top level ARCH_MXCV7M, which selects
multiplatform only ARCH_MXC.

--
Stefan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] staging: dgnc: remove dead code in dgnc_tty_write()

2015-04-05 Thread Giedrius Statkevičius
Forgot to put "v2" in the title. Should I resend? Sorry for the confusion. Still
making some patch submitting mistakes from time to time. :(

On Mon, 6 Apr 2015, Giedrius Statkevicius wrote:

> Remove the dead code protected by in_user in dgnc_tty_write() because it is 
> set
> to 0 and never changed to 1 thus the code in ifs never gets executed.
> 
> Signed-off-by: Giedrius Statkevičius 
> ---
> v2: Just remove the dead code protected by in_user and join the first and 
> third
> patches.
> 
>  drivers/staging/dgnc/dgnc_tty.c | 45 
> +
>  1 file changed, 1 insertion(+), 44 deletions(-)
> 
> diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
> index ce4187f..cf2eb21 100644
> --- a/drivers/staging/dgnc/dgnc_tty.c
> +++ b/drivers/staging/dgnc/dgnc_tty.c
> @@ -42,16 +42,11 @@
>  #include "dgnc_sysfs.h"
>  #include "dgnc_utils.h"
>  
> -#define init_MUTEX(sem)   sema_init(sem, 1)
> -#define DECLARE_MUTEX(name) \
> - struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
> -
>  /*
>   * internal variables
>   */
>  static struct dgnc_board *dgnc_BoardsByMajor[256];
>  static unsigned char *dgnc_TmpWriteBuf;
> -static DECLARE_MUTEX(dgnc_TmpWriteSem);
>  
>  /*
>   * Default transparent print information.
> @@ -1705,7 +1700,6 @@ static int dgnc_tty_write(struct tty_struct *tty,
>   ushort tail;
>   ushort tmask;
>   uint remain;
> - int from_user = 0;
>  
>   if (tty == NULL || dgnc_TmpWriteBuf == NULL)
>   return 0;
> @@ -1785,38 +1779,6 @@ static int dgnc_tty_write(struct tty_struct *tty,
>   if (count <= 0)
>   goto exit_retry;
>  
> - if (from_user) {
> -
> - count = min(count, WRITEBUFLEN);
> -
> - spin_unlock_irqrestore(&ch->ch_lock, flags);
> -
> - /*
> -  * If data is coming from user space, copy it into a temporary
> -  * buffer so we don't get swapped out while doing the copy to
> -  * the board.
> -  */
> - /* we're allowed to block if it's from_user */
> - if (down_interruptible(&dgnc_TmpWriteSem))
> - return -EINTR;
> -
> - /*
> -  * copy_from_user() returns the number
> -  * of bytes that could *NOT* be copied.
> -  */
> - count -= copy_from_user(dgnc_TmpWriteBuf, (const unsigned char 
> __user *) buf, count);
> -
> - if (!count) {
> - up(&dgnc_TmpWriteSem);
> - return -EFAULT;
> - }
> -
> - spin_lock_irqsave(&ch->ch_lock, flags);
> -
> - buf = dgnc_TmpWriteBuf;
> -
> - }
> -
>   n = count;
>  
>   /*
> @@ -1853,12 +1815,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
>   ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps;
>   }
>  
> - if (from_user) {
> - spin_unlock_irqrestore(&ch->ch_lock, flags);
> - up(&dgnc_TmpWriteSem);
> - } else {
> - spin_unlock_irqrestore(&ch->ch_lock, flags);
> - }
> + spin_unlock_irqrestore(&ch->ch_lock, flags);
>  
>   if (count) {
>   /*
> -- 
> 2.3.5
> 
> 

Su pagarba / Regards,
Giedrius

Re: [PATCH 16/16] NFC: pn533: fix error return code

2015-04-05 Thread Samuel Ortiz
Hi Julia,

On Sun, Apr 05, 2015 at 02:06:36PM +0200, Julia Lawall wrote:
> Return a negative error code on failure.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // 
> @@
> identifier ret; expression e1,e2;
> @@
> (
> if (\(ret < 0\|ret != 0\))
>  { ... return ret; }
> |
> ret = 0
> )
> ... when != ret = e1
> when != &ret
> *if(...)
> {
>   ... when != ret = e2
>   when forall
>  return ret;
> }
> // 
> 
> Signed-off-by: Julia Lawall 
> 
> ---
>  drivers/nfc/pn533.c |4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
Applied, thanks.

Cheers,
Samuel.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] staging: dgnc: remove redundant check

2015-04-05 Thread Giedrius Statkevicius
count doesn't get changed in between identical checks in dgnc_tty_write() so
remove the second check

Signed-off-by: Giedrius Statkevičius 
---
v2: no change

 drivers/staging/dgnc/dgnc_tty.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index cf2eb21..61d5a8e 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1773,12 +1773,6 @@ static int dgnc_tty_write(struct tty_struct *tty,
ch->ch_flags &= ~CH_PRON;
}
 
-   /*
-* If there is nothing left to copy, or I can't handle any more data, 
leave.
-*/
-   if (count <= 0)
-   goto exit_retry;
-
n = count;
 
/*
-- 
2.3.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] staging: dgnc: remove dead code in dgnc_tty_write()

2015-04-05 Thread Giedrius Statkevicius
Remove the dead code protected by in_user in dgnc_tty_write() because it is set
to 0 and never changed to 1 thus the code in ifs never gets executed.

Signed-off-by: Giedrius Statkevičius 
---
v2: Just remove the dead code protected by in_user and join the first and third
patches.

 drivers/staging/dgnc/dgnc_tty.c | 45 +
 1 file changed, 1 insertion(+), 44 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index ce4187f..cf2eb21 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -42,16 +42,11 @@
 #include "dgnc_sysfs.h"
 #include "dgnc_utils.h"
 
-#define init_MUTEX(sem) sema_init(sem, 1)
-#define DECLARE_MUTEX(name) \
-   struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-
 /*
  * internal variables
  */
 static struct dgnc_board   *dgnc_BoardsByMajor[256];
 static unsigned char   *dgnc_TmpWriteBuf;
-static DECLARE_MUTEX(dgnc_TmpWriteSem);
 
 /*
  * Default transparent print information.
@@ -1705,7 +1700,6 @@ static int dgnc_tty_write(struct tty_struct *tty,
ushort tail;
ushort tmask;
uint remain;
-   int from_user = 0;
 
if (tty == NULL || dgnc_TmpWriteBuf == NULL)
return 0;
@@ -1785,38 +1779,6 @@ static int dgnc_tty_write(struct tty_struct *tty,
if (count <= 0)
goto exit_retry;
 
-   if (from_user) {
-
-   count = min(count, WRITEBUFLEN);
-
-   spin_unlock_irqrestore(&ch->ch_lock, flags);
-
-   /*
-* If data is coming from user space, copy it into a temporary
-* buffer so we don't get swapped out while doing the copy to
-* the board.
-*/
-   /* we're allowed to block if it's from_user */
-   if (down_interruptible(&dgnc_TmpWriteSem))
-   return -EINTR;
-
-   /*
-* copy_from_user() returns the number
-* of bytes that could *NOT* be copied.
-*/
-   count -= copy_from_user(dgnc_TmpWriteBuf, (const unsigned char 
__user *) buf, count);
-
-   if (!count) {
-   up(&dgnc_TmpWriteSem);
-   return -EFAULT;
-   }
-
-   spin_lock_irqsave(&ch->ch_lock, flags);
-
-   buf = dgnc_TmpWriteBuf;
-
-   }
-
n = count;
 
/*
@@ -1853,12 +1815,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps;
}
 
-   if (from_user) {
-   spin_unlock_irqrestore(&ch->ch_lock, flags);
-   up(&dgnc_TmpWriteSem);
-   } else {
-   spin_unlock_irqrestore(&ch->ch_lock, flags);
-   }
+   spin_unlock_irqrestore(&ch->ch_lock, flags);
 
if (count) {
/*
-- 
2.3.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2] tty: serial: Add const to struct uart_ops declarations

2015-04-05 Thread Stefan Agner
On 2015-04-05 20:24, Joe Perches wrote:
> Still compiled only x86 and not cross-compiled or tested.

Cross-compiled with multi_v7_defconfig

> 
>  drivers/tty/serial/21285.c  | 2 +-
>  drivers/tty/serial/altera_jtaguart.c| 2 +-
>  drivers/tty/serial/altera_uart.c| 2 +-
>  drivers/tty/serial/amba-pl010.c | 2 +-
>  drivers/tty/serial/amba-pl011.c | 2 +-
>  drivers/tty/serial/apbuart.c| 2 +-
>  drivers/tty/serial/ar933x_uart.c| 2 +-
>  drivers/tty/serial/arc_uart.c   | 2 +-
>  drivers/tty/serial/atmel_serial.c   | 2 +-
>  drivers/tty/serial/bcm63xx_uart.c   | 2 +-
>  drivers/tty/serial/bfin_sport_uart.c| 2 +-
>  drivers/tty/serial/bfin_uart.c  | 2 +-
>  drivers/tty/serial/cpm_uart/cpm_uart_core.c | 2 +-
>  drivers/tty/serial/dz.c | 2 +-
>  drivers/tty/serial/efm32-uart.c | 2 +-
>  drivers/tty/serial/fsl_lpuart.c | 4 ++--

Tested that driver on actual hardware, looks fine.

>  drivers/tty/serial/icom.c   | 2 +-
>  drivers/tty/serial/imx.c| 2 +-
>  drivers/tty/serial/ioc3_serial.c| 2 +-
>  drivers/tty/serial/ioc4_serial.c| 2 +-
>  drivers/tty/serial/ip22zilog.c  | 2 +-
>  drivers/tty/serial/jsm/jsm_tty.c| 2 +-
>  drivers/tty/serial/lantiq.c | 2 +-
>  drivers/tty/serial/lpc32xx_hs.c | 2 +-
>  drivers/tty/serial/m32r_sio.c   | 2 +-
>  drivers/tty/serial/max3100.c| 2 +-
>  drivers/tty/serial/men_z135_uart.c  | 2 +-
>  drivers/tty/serial/meson_uart.c | 2 +-
>  drivers/tty/serial/mpc52xx_uart.c   | 2 +-
>  drivers/tty/serial/mpsc.c   | 2 +-
>  drivers/tty/serial/msm_serial.c | 2 +-
>  drivers/tty/serial/mux.c| 2 +-
>  drivers/tty/serial/mxs-auart.c  | 2 +-
>  drivers/tty/serial/netx-serial.c| 2 +-
>  drivers/tty/serial/nwpserial.c  | 2 +-
>  drivers/tty/serial/omap-serial.c| 2 +-
>  drivers/tty/serial/pch_uart.c   | 2 +-
>  drivers/tty/serial/pmac_zilog.c | 2 +-
>  drivers/tty/serial/pnx8xxx_uart.c   | 2 +-
>  drivers/tty/serial/pxa.c| 2 +-
>  drivers/tty/serial/sa1100.c | 2 +-
>  drivers/tty/serial/samsung.c| 2 +-

This driver seems to alter the startup function on initialization:

  CC  drivers/video/of_display_timing.o
../drivers/tty/serial/samsung.c: In function 's3c24xx_serial_init_port':
../drivers/tty/serial/samsung.c:1702:3: error: assignment of member
'startup' in read-only object
   s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
   ^

>  drivers/tty/serial/serial-tegra.c   | 2 +-
>  drivers/tty/serial/serial_ks8695.c  | 2 +-
>  drivers/tty/serial/serial_txx9.c| 2 +-
>  drivers/tty/serial/sh-sci.c | 2 +-
>  drivers/tty/serial/sirfsoc_uart.c   | 2 +-
>  drivers/tty/serial/sn_console.c | 2 +-
>  drivers/tty/serial/sprd_serial.c| 2 +-
>  drivers/tty/serial/st-asc.c | 2 +-
>  drivers/tty/serial/sunhv.c  | 2 +-
>  drivers/tty/serial/sunsab.c | 2 +-
>  drivers/tty/serial/sunsu.c  | 2 +-
>  drivers/tty/serial/sunzilog.c   | 2 +-
>  drivers/tty/serial/timbuart.c   | 2 +-
>  drivers/tty/serial/uartlite.c   | 2 +-
>  drivers/tty/serial/ucc_uart.c   | 2 +-
>  drivers/tty/serial/vr41xx_siu.c | 2 +-
>  drivers/tty/serial/vt8500_serial.c  | 2 +-
>  drivers/tty/serial/xilinx_uartps.c  | 2 +-
>  drivers/tty/serial/zs.c | 2 +-
>  61 files changed, 62 insertions(+), 62 deletions(-)

That is the only thing which popped up with multi_v7_defconfig.

--
Stefan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 07/11] ARM: allow MULTIPLATFORM with !MMU

2015-04-05 Thread Russell King - ARM Linux
On Mon, Apr 06, 2015 at 12:19:43AM +0200, Stefan Agner wrote:
> On 2015-04-05 18:10, Russell King - ARM Linux wrote:
> > config ARM_SINGLE_ARMV7M
> > bool "ARM architecture v7M compliant (Cortex-M0/M3/M4) SoC"
> > depends on !MMU
> > select ARM_NVIC
> > ... etc ...
> 
> I guess that would be ARCH_SINGLE_ARMV7M?

No, I meant ARM_SINGLE_xxx

> > which then allows a /multiplatform/ v7M kernel to be built, allowing the
> > selection of EFM32, SOC_VF610, and any other v7M compliant SoC.
> 
> In my view, that wouldn't end up being much different than what that
> patchset is doing:

It's different.  It's different because we are _not_ enabling multiplatform.
Multiplatform brings with it all the MMU-full stuff that we don't want on
!MMU.

You're thinking far too specifically about V7M here.  We have other !MMU
CPUs, such as ARM946 and ARM940 which are older generation mmuless CPUs.

The problem with the ARCH_MULTI_V7M approach is that they're V4T and V5
CPUs, and we _really_ don't want to enable ARCH_MULTI_V4T and
ARCH_MULTI_V5.  If we did that, we'll allow _every_ V4T and V5
multiplatform to be selected, whether they're compatible with nommu
or not - and whether they're compatible with each other or not.

So, that kind of solution _doesn't_ scale to what we _once_ already
allowed.

> As far as I can tell, this is already the case with that patchset.

What I'm trying to do here is to fix the cockup that the multiplatform
conversion has created with previous generation noMMU and restore it
back to where it should be without excluding the newer stuff from it.

What you're interested in is just the newer stuff.  You're approaching
the problem from a different angle and thinking that your solution is
the best.  I'm saying it has deficiencies.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2] tty: serial: Add const to struct uart_ops declarations

2015-04-05 Thread Maciej W. Rozycki
On Sun, 5 Apr 2015, Joe Perches wrote:

>  drivers/tty/serial/dz.c | 2 +-
>  drivers/tty/serial/zs.c | 2 +-

 For these verified that the change works correctly, thanks for your work.

Acked-by: Maciej W. Rozycki 

  Maciej
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 07/11] ARM: allow MULTIPLATFORM with !MMU

2015-04-05 Thread Stefan Agner
On 2015-04-05 18:10, Russell King - ARM Linux wrote:
> On Sat, Apr 04, 2015 at 01:56:20AM +0200, Stefan Agner wrote:
>> On 2015-04-03 22:09, Russell King - ARM Linux wrote:
>> > On Fri, Apr 03, 2015 at 09:44:48PM +0200, Stefan Agner wrote:
>> >> In order to support SoC with heterogenous CPU architectures (such
>> >> as Freescale Vybrid/i.MXSX) it is preferable to use the same
>> >> architecture (ARCH_MXC in this case) for the MMU enabled and !MMU
>> >> CPU. Hence allow to select MULTIPLATFORM even without MMU.
>> >>
>> >> Signed-off-by: Stefan Agner 
>> >> ---
>> >>  arch/arm/Kconfig | 21 ++---
>> >>  1 file changed, 10 insertions(+), 11 deletions(-)
>> >>
>> >> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>> >> index 9f1f09a..636cb3f 100644
>> >> --- a/arch/arm/Kconfig
>> >> +++ b/arch/arm/Kconfig
>> >> @@ -230,7 +230,7 @@ config VECTORS_BASE
>> >> in size.
>> >>
>> >>  config ARM_PATCH_PHYS_VIRT
>> >> - bool "Patch physical to virtual translations at runtime" if EMBEDDED
>> >> + bool "Patch physical to virtual translations at runtime" if EMBEDDED || 
>> >> (ARCH_MULTIPLATFORM && MMU)
>> >>   default y
>> >
>> > This makes no sense.  Multiplatform MMU _requires_ this feature, so why
>> > offer it to the user when multiplatform is enabled _and_ MMU is enabled?
>>
>> I see, this is plain wrong. Will replace that with a select ... if MMU
>> in multiplatform.
> 
> I think what I'd like to see is, in the top level choice:
> 
> config ARM_SINGLE_ARMV7M
>   bool "ARM architecture v7M compliant (Cortex-M0/M3/M4) SoC"
>   depends on !MMU
>   select ARM_NVIC
>   ... etc ...

I guess that would be ARCH_SINGLE_ARMV7M?

> 
> which then allows a /multiplatform/ v7M kernel to be built, allowing the
> selection of EFM32, SOC_VF610, and any other v7M compliant SoC.

In my view, that wouldn't end up being much different than what that
patchset is doing:
With the introduction of ARCH_MULTI_V7M, we add something like a top
level v7M compliant selection. Due to the !MMU dependencies of all other
CPU families the family selection is minimal (when selecting !MMU):

*** CPU Core family selection *** 
[*] ARMv7-M based platforms (Cortex-M)

And since ARCH_MULTI_V7M is not part of ARCH_MULTI_V6_V7 or anything,
the whole SoC selection contains only sensible SoC's without further
changes (also within the i.MX family, currently only "Vybrid Family
VF610 support" is selectable):

[ ] MMU-based Paged Memory Management Support   
ARM system type (Allow multiple platforms to be selected)  ---> 
Multiple platform selection  --->   
[*] Energy Micro efm32  
[*] Freescale i.MX family  --->
*** Processor Type ***
...

> So, it's very similar to multiplatform in the sense that several SoCs
> can be built together, but we preserve the need not to build
> incompatible stuff together.

As far as I can tell, this is already the case with that patchset.

The differences boil down to on which level we split the v7M CPU
selection apart: On ARCH_* level or ARCH_MULTI_* level. Given that we
allow a multiplatform _v7M kernel, the latter sounds more natural to
me...

Are there arguments to split v7M CPU selection apart on ARCH_* level
which I don't see?

--
Stefan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Input: atkbd: Fix release quirk for Dell models

2015-04-05 Thread Pali RohƔr
On Sunday 05 April 2015 23:48:33 Dmitry Torokhov wrote:
> Hi Pali,
> 
> On Sun, Mar 29, 2015 at 04:36:19PM +0200, Pali RohƔr wrote:
> > This patch fixes commit 61579ba83934 ("Input: atkbd - expand
> > Latitude's force release quirk to other Dells"). Before
> > that commit release quirks were called for all Dell
> > Latitude models. After that commit only for Portable Dell
> > devices. But lot of Latitude models are Laptop or Notebook
> > DMI devices so quirks are not called.
> > 
> > Release quirks are still needed also for new Dell Latitude
> > models, so this patch enables quirks for all Portable,
> > Laptop, Notebook and Sub-Notebook Dell devices.
> 
> Does Dell use all these types for their laptops? What models
> do you know that need this quirk?
> 
> Thanks.
> 

I do not if Dell use all types, but months ago Matthew wrote to 
include also other numbers not only 9 (Laptop) and you agreed.

I do not know exact list of models which needs these quirks, but 
before that commit (61579ba83934) it was used for all Latitude 
models. At least I see that switches do not generate release 
events and on older Latitude machines some Fn keys do not 
generate them too.

-- 
Pali RohƔr
pali.ro...@gmail.com


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


Re: [PATCH 02/16] vfs: check kiocb->ki_flags instead filp->fl_flags

2015-04-05 Thread Al Viro
On Sun, Apr 05, 2015 at 07:11:45PM +0100, Al Viro wrote:
> On Sun, Apr 05, 2015 at 02:03:22PM +0300, Dmitry Monakhov wrote:
> 
> > I'm not sure I have get your point about ocfs2 because it does
> > iov_iter_truncate() right after generic_write_checks()
> 
> This
> ret = ocfs2_prepare_inode_for_write(file, ppos, count, appending,
> &can_do_direct, &has_refcount);
> being done before generic_write_checks().  It actually duplicates some
> parts of generic_write_checks() inside (O_APPEND-related, and AFAICS
> they _are_ triggered twice that way).

XFS seems to be buggered as well:
/* DIO must be aligned to device logical sector size */
if ((pos | count) & target->bt_logical_sectormask)
return -EINVAL;

/* "unaligned" here means not aligned to a filesystem block */
if ((pos & mp->m_blockmask) || ((pos + count) & mp->m_blockmask))
unaligned_io = 1;
...
ret = xfs_file_aio_write_checks(file, &pos, &count, &iolock);

now, play with rlimit() and suddenly the alignment checks above have nothing
to do with what'll actually happen after that sucker - it's calling
generic_write_checks(), so...

Incidentally, we want the result of alignment check to decide how to take
the lock that protects the file size, so simply lifting O_APPEND treatment
above those won't do.  I suspect that in case of lock taken shared we
need to redo alignment checks and treat "it became unaligned" as "unlock
and redo it with lock taken exclusive".

BTW, xfs_break_layouts() having dropped and regained lock would invalidate
the O_APPEND treatment in generic_write_checks() just prior (both in
xfs_file_aio_write_checks())...

Al "really not fond of xfs_rw_ilock()" Viro...

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Input: atkbd: Fix release quirk for Dell models

2015-04-05 Thread Dmitry Torokhov
Hi Pali,

On Sun, Mar 29, 2015 at 04:36:19PM +0200, Pali RohƔr wrote:
> This patch fixes commit 61579ba83934 ("Input: atkbd - expand Latitude's force
> release quirk to other Dells"). Before that commit release quirks were called
> for all Dell Latitude models. After that commit only for Portable Dell 
> devices.
> But lot of Latitude models are Laptop or Notebook DMI devices so quirks are 
> not
> called.
> 
> Release quirks are still needed also for new Dell Latitude models, so this 
> patch
> enables quirks for all Portable, Laptop, Notebook and Sub-Notebook Dell 
> devices.

Does Dell use all these types for their laptops? What models do you know
that need this quirk?

Thanks.

> 
> Signed-off-by: Pali RohƔr 
> ---
>  drivers/input/keyboard/atkbd.c |   48 
> 
>  1 file changed, 48 insertions(+)
> 
> diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
> index 387c51f..3188493 100644
> --- a/drivers/input/keyboard/atkbd.c
> +++ b/drivers/input/keyboard/atkbd.c
> @@ -1664,6 +1664,30 @@ static const struct dmi_system_id 
> atkbd_dmi_quirk_table[] __initconst = {
>   },
>   {
>   .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /* Laptop */
> + },
> + .callback = atkbd_setup_forced_release,
> + .driver_data = atkbd_dell_laptop_forced_release_keys,
> + },
> + {
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */
> + },
> + .callback = atkbd_setup_forced_release,
> + .driver_data = atkbd_dell_laptop_forced_release_keys,
> + },
> + {
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
> + DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */
> + },
> + .callback = atkbd_setup_forced_release,
> + .driver_data = atkbd_dell_laptop_forced_release_keys,
> + },
> + {
> + .matches = {
>   DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
>   DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */
>   },
> @@ -1672,6 +1696,30 @@ static const struct dmi_system_id 
> atkbd_dmi_quirk_table[] __initconst = {
>   },
>   {
>   .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
> + DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /* Laptop */
> + },
> + .callback = atkbd_setup_forced_release,
> + .driver_data = atkbd_dell_laptop_forced_release_keys,
> + },
> + {
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
> + DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */
> + },
> + .callback = atkbd_setup_forced_release,
> + .driver_data = atkbd_dell_laptop_forced_release_keys,
> + },
> + {
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Dell Computer Corporation"),
> + DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */
> + },
> + .callback = atkbd_setup_forced_release,
> + .driver_data = atkbd_dell_laptop_forced_release_keys,
> + },
> + {
> + .matches = {
>   DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
>   DMI_MATCH(DMI_PRODUCT_NAME, "HP 2133"),
>   },
> -- 
> 1.7.9.5
> 

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] staging: dgnc: improve the coding style in unlocking part of dgnc_tty_write()

2015-04-05 Thread Giedrius Statkevicius
do

if (blah) foo();
bar();

instead of

if (blah) {
foo();
bar();
} else {
bar();
}

Signed-off-by: Giedrius Statkevičius 
---
 drivers/staging/dgnc/dgnc_tty.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 651a925..c59a784 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1843,12 +1843,10 @@ static int dgnc_tty_write(struct tty_struct *tty,
ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps;
}
 
-   if (from_user) {
-   spin_unlock_irqrestore(&ch->ch_lock, flags);
+   if (from_user)
mutex_unlock(&dgnc_TmpWriteSem);
-   } else {
-   spin_unlock_irqrestore(&ch->ch_lock, flags);
-   }
+
+   spin_unlock_irqrestore(&ch->ch_lock, flags);
 
if (count) {
/*
-- 
2.3.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] staging: dgnc: remove redundant check

2015-04-05 Thread Giedrius Statkevicius
count doesn't change between the last check a few lines before so remove this
redundant check

Signed-off-by: Giedrius Statkevičius 
---
 drivers/staging/dgnc/dgnc_tty.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 0b9bed4..651a925 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1775,12 +1775,6 @@ static int dgnc_tty_write(struct tty_struct *tty,
ch->ch_flags &= ~CH_PRON;
}
 
-   /*
-* If there is nothing left to copy, or I can't handle any more data, 
leave.
-*/
-   if (count <= 0)
-   goto exit_retry;
-
if (from_user) {
 
count = min(count, WRITEBUFLEN);
-- 
2.3.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] staging: dgnc: use a real mutex instead of masquerading a semaphore as a mutex

2015-04-05 Thread Giedrius Statkevicius
A mutex should be used here (and it's name even says that) so remove the hiding
of a semaphore behind a #define and use a real mutex that the kernel provides.

Signed-off-by: Giedrius Statkevičius 
---
 drivers/staging/dgnc/dgnc_tty.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index ce4187f..0b9bed4 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -42,16 +42,12 @@
 #include "dgnc_sysfs.h"
 #include "dgnc_utils.h"
 
-#define init_MUTEX(sem) sema_init(sem, 1)
-#define DECLARE_MUTEX(name) \
-   struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-
 /*
  * internal variables
  */
 static struct dgnc_board   *dgnc_BoardsByMajor[256];
 static unsigned char   *dgnc_TmpWriteBuf;
-static DECLARE_MUTEX(dgnc_TmpWriteSem);
+static DEFINE_MUTEX(dgnc_TmpWriteSem);
 
 /*
  * Default transparent print information.
@@ -1797,7 +1793,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
 * the board.
 */
/* we're allowed to block if it's from_user */
-   if (down_interruptible(&dgnc_TmpWriteSem))
+   if (mutex_lock_interruptible(&dgnc_TmpWriteSem))
return -EINTR;
 
/*
@@ -1807,7 +1803,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
count -= copy_from_user(dgnc_TmpWriteBuf, (const unsigned char 
__user *) buf, count);
 
if (!count) {
-   up(&dgnc_TmpWriteSem);
+   mutex_unlock(&dgnc_TmpWriteSem);
return -EFAULT;
}
 
@@ -1855,7 +1851,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
 
if (from_user) {
spin_unlock_irqrestore(&ch->ch_lock, flags);
-   up(&dgnc_TmpWriteSem);
+   mutex_unlock(&dgnc_TmpWriteSem);
} else {
spin_unlock_irqrestore(&ch->ch_lock, flags);
}
-- 
2.3.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] MAINTAINERS: Add me on list of Dell laptop drivers

2015-04-05 Thread Pali RohƔr
On Thursday 02 April 2015 07:10:27 Darren Hart wrote:
> On Sun, Mar 29, 2015 at 03:38:50PM +0200, Pali RohƔr wrote:
> 
> Please include why. No empty commit messages please.
> 
> For example, you've written nearly a third of the dell-wmi.c
> driver, and all the dell-smo8800.c driver.
> 

Ok. If you need description include this:

===
MAINTAINERS: Add me on list of Dell laptop drivers

I have written more parts of dell laptop drivers dell-laptop.c, 
dell-wmi.c and dell-smo8800.c
===

> Dell Laptop is still pending the keyboard backlight patches
> though I believe (have I missed them?), so you don't
> currently have code ownership there. I agree you should be on
> the MAINTAINERS list, but it would be good to get your
> keyboard backlight changes in first.
> 

ok.

> Gosh... sure seems like we should have merged that already...
> am I missing something? The last thing I see in master,
> testing, and next is the revert from Jan 21
> 

backlight support was merged for 3.19, but has small problem with 
ALS settings. And then you decided to revert it for 3.19. After 
that problem was fixed and last (2015-03-06) you wrote that you 
queued patch again for 4.1 release.

> Also, Matthew, you're the listed maintainer for these, do you
> agree to adding Pali?
> 
> > Signed-off-by: Pali RohƔr 
> > ---
> > 
> >  MAINTAINERS |7 +++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 88c09ca..72a08ef 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -3058,10 +3058,16 @@ F:  drivers/net/fddi/defxx.*
> > 
> >  DELL LAPTOP DRIVER
> >  M: Matthew Garrett 
> > 
> > +M: Pali RohƔr 
> > 
> >  L: platform-driver-...@vger.kernel.org
> >  S: Maintained
> >  F: drivers/platform/x86/dell-laptop.c
> > 
> > +DELL LAPTOP FREEFALL DRIVER
> > +M: Pali RohƔr 
> > +S: Maintained
> > +F: drivers/platform/x86/dell-smo8800.c
> > +
> > 
> >  DELL LAPTOP SMM DRIVER
> >  M: Guenter Roeck 
> >  S: Maintained
> > 
> > @@ -3076,6 +3082,7 @@ F:drivers/firmware/dcdbas.*
> > 
> >  DELL WMI EXTRAS DRIVER
> >  M: Matthew Garrett 
> > 
> > +M: Pali RohƔr 
> > 
> >  S: Maintained
> >  F: drivers/platform/x86/dell-wmi.c

-- 
Pali RohƔr
pali.ro...@gmail.com


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


Re: [PATCH 9/16] HID: logitech-hidpp: fix error return code

2015-04-05 Thread Jiri Kosina
On Sun, 5 Apr 2015, Julia Lawall wrote:

> Return a negative error code on failure.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // 
> @@
> identifier ret; expression e1,e2;
> @@
> (
> if (\(ret < 0\|ret != 0\))
>  { ... return ret; }
> |
> ret = 0
> )
> ... when != ret = e1
> when != &ret
> *if(...)
> {
>   ... when != ret = e2
>   when forall
>  return ret;
> }
> // 
> 
> Signed-off-by: Julia Lawall 

Applied to for-4.1/logitech, thanks.

-- 
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 0/3] Balanced slots, attempt #2

2015-04-05 Thread Dmitry Torokhov
On Tue, Mar 31, 2015 at 05:26:31PM +0200, Henrik Rydberg wrote:
> On 03/31/2015 05:07 PM, Benjamin Tissoires wrote:
> > Hi,
> > 
> > so this is the v2 with Hans' ack and Henrik's respin of the first patch.
> 
> The whole series looks good, thank you Benjamin.
> 
> Acked-by: Henrik Rydberg 

Queued for 4.1, thank you.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Charity Project

2015-04-05 Thread Bill William And Andrea Groner
I saw your email address during the course of my  research today. My name is 
Bill William Groner my wife and I won a Jackpot Lottery of $50 Million Dollars 
in December 2013, we are donating the sum of $1 million Dollars to 6 lucky 
individual all over the world as part of our charity project. Do get back to us 
for further details on how to get the donation.

http://www.huffingtonpost.ca/2014/07/22/50-million-edmonton-lotto_n_5610890.html

Good luck,
Bill William And Andrean Groner
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2] UBI: power cut emulation for testing

2015-04-05 Thread Richard Weinberger
Am 05.04.2015 um 22:25 schrieb Pavel Machek:
> I guess so. So maybe warning in the documentation somewhere that real
> hardware is nastier than designed-to-be-nasty emulation would be
> nice..?

Yeah, that's a good idea. David, can you please create a patch
against mtd-www.git?
Please also cover the existing powercut emulation of UBIFS.

The reason why David added emulation for UBI was to stress-test
UBI fastmap. The crucial operation of UBI changing the mapping between
LEB and PEBs. This is why this emulation intercepts writes to the UBI
VID header. For the sake of completeness interception of EC writes
is also possible.

Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[GIT PULL] at91: clocksource-driver for 4.1 #2

2015-04-05 Thread Nicolas Ferre
Arnd, Olof, Kevin,

This is the patch that was extracted from my previous pull request and that
would go on top of your at91/clocksource-driver branch.

Thanks, best regards,

The following changes since commit 8590ca655a19f9e124b52bfbf28f14eb16a05bec:

  ARM: at91: remove useless include (2015-03-16 17:03:08 +0100)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nferre/linux-at91.git 
tags/at91-clocksource-driver2

for you to fetch changes up to 7ab7ef741a467e7af50c9b7446ec992bec9ea6a7:

  clocksource: atmel-st: select MFD_SYSCON (2015-04-05 22:19:50 +0200)


A fix for the ST clocksource driver Kconfig option


Alexandre Belloni (1):
  clocksource: atmel-st: select MFD_SYSCON

 drivers/clocksource/Kconfig | 1 +
 1 file changed, 1 insertion(+)

-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2] UBI: power cut emulation for testing

2015-04-05 Thread Pavel Machek
On Sun 2015-04-05 22:09:27, Richard Weinberger wrote:
> Am 05.04.2015 um 22:04 schrieb Pavel Machek:
> > On Sun 2015-04-05 21:49:27, Richard Weinberger wrote:
> >> On Sun, Apr 5, 2015 at 9:31 PM, Pavel Machek  wrote:
> >>> On Thu 2015-03-26 23:59:50, david.oberhollen...@sigma-star.at wrote:
>  Emulate random power cuts by switching device to ro after a number of
>  writes to allow simple power cut testing with nand-sim.
> 
>  Maximum and minimum number of successful writes before power cut and
>  what kind of writes (EC header, VID header or none) to interrupt
>  configurable via debugfs.
> 
>  Signed-off-by: David Oberhollenzer 
>  ---
>  V2: Remove broken check to prevent multiple triggering
> >>>
> >>> Does NAND always finish write of full block during powerfail?
> >>
> >> Not sure if I correctly understand your question.
> >> Unless you don't have special hardware a write can be interrupted and
> >> can cause problems.
> > 
> > But this only emulates fail after a full block written, no?
> 
> Emulating all aspects of real hardware is almost impossible.

I guess so. So maybe warning in the documentation somewhere that real
hardware is nastier than designed-to-be-nasty emulation would be
nice..?
Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[GIT PULL] at91: cleanup for 4.1 #4 (bis)

2015-04-05 Thread Nicolas Ferre
Arnd, Olof, Kevin,

This is a re-spin of my 4th "cleanup" pull-request following the comments made
by Olof.  So, now these patches about PM are based on the "at91-cleanup2" that
you would merge in your next/cleanup branch.

I'm preparing another pull-request for the other patch that would stack on our
at91/clocksource-driver branch.

Thanks for your advice, bye.

The following changes since commit 598e085590fc5ac1fecff00e842a8a6c2ae010e5:

  ARM: at91: remove old setup (2015-03-13 18:01:10 +0100)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/nferre/linux-at91.git 
tags/at91-cleanup4_bis

for you to fetch changes up to 2e57dc087c27b8b0bd4a9e5f2c6f28f3cd0b47ff:

  ARM: at91/pm: move AT91_MEMCTRL_* to pm.h (2015-04-05 21:59:52 +0200)


Fourth batch of cleanup for 4.1:
- 1 issues revealed by the kbuild test robot fixed
- move of some functions and macros into relevant files to be able to
  streamline the at91 specific header afterwards


Alexandre Belloni (3):
  ARM: at91: fix pm_suspend.S compilation when ARMv6 is selected
  ARM: at91/pm: move the standby functions to pm.c
  ARM: at91/pm: move AT91_MEMCTRL_* to pm.h

 arch/arm/mach-at91/Makefile |  3 +
 arch/arm/mach-at91/include/mach/at91_ramc.h |  4 --
 arch/arm/mach-at91/pm.c | 89 ++
 arch/arm/mach-at91/pm.h | 96 ++---
 4 files changed, 96 insertions(+), 96 deletions(-)

-- 
Nicolas Ferre
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4] earlycon: 8250: Fix command line regression

2015-04-05 Thread Yinghai Lu
On Sun, Apr 5, 2015 at 6:06 AM, Peter Hurley  wrote:
> On 04/05/2015 03:09 AM, Yinghai Lu wrote:

> On what planet is 27 loc across 4 source files cleaner than
> 6 loc that might be reducible to 2?

loc is not only thing to decide if it is cleaner.

Let's Greg and Andrew to check which one is clean.
Subject: [PATCH -v3] earlycon: Fix earlycon/console handover without options

commit c7cef0a84912 ("console: Add extensible console matching")
broke the earlycon/handover when booting
console=uart8250,io,0x3f8

the bootloader is using 115200, and the earlycon continue
use 115200, but console revert back to 9600.

Before the commit, probed baud rate is passed via console_cmdline
from earlycon to normal console.
That commit remove that and only check boot command line.

This patch use port match to get hold earlycon, and use earlycon
device options to update options for console.

With that we restore the original behavior.

Fixes: commit c7cef0a84912 ("console: Add extensible console matching")
Signed-off-by: Yinghai Lu 

---
-v2: simplify serial8250_get_earlycon_options and don't update
 console_cmdline.
-v3: add earlycon_match to restore original behavior.
---

---
 drivers/tty/serial/8250/8250_core.c  |3 +++
 drivers/tty/serial/8250/8250_early.c |7 +++
 drivers/tty/serial/earlycon.c|   15 +++
 include/linux/serial_core.h  |2 ++
 4 files changed, 27 insertions(+)

Index: linux-2.6/drivers/tty/serial/8250/8250_core.c
===
--- linux-2.6.orig/drivers/tty/serial/8250/8250_core.c
+++ linux-2.6/drivers/tty/serial/8250/8250_core.c
@@ -3490,6 +3490,9 @@ static int univ8250_console_match(struct
 		if (iotype == UPIO_PORT && port->iobase != addr)
 			continue;
 
+		if (!earlycon_match(port, &options))
+			return -ENODEV;
+
 		co->index = i;
 		return univ8250_console_setup(co, options);
 	}
Index: linux-2.6/drivers/tty/serial/8250/8250_early.c
===
--- linux-2.6.orig/drivers/tty/serial/8250/8250_early.c
+++ linux-2.6/drivers/tty/serial/8250/8250_early.c
@@ -105,6 +105,12 @@ static void __init early_serial8250_writ
 		serial8250_early_out(port, UART_IER, ier);
 }
 
+static int serial8250_earlycon_match(struct earlycon_device *device,
+ struct uart_port *up)
+{
+	return uart_match_port(up, &device->port);
+}
+
 static unsigned int __init probe_baud(struct uart_port *port)
 {
 	unsigned char lcr, dll, dlm;
@@ -161,6 +167,7 @@ static int __init early_serial8250_setup
 	} else
 		init_port(device);
 
+	device->match = serial8250_earlycon_match;
 	device->con->write = early_serial8250_write;
 	return 0;
 }
Index: linux-2.6/drivers/tty/serial/earlycon.c
===
--- linux-2.6.orig/drivers/tty/serial/earlycon.c
+++ linux-2.6/drivers/tty/serial/earlycon.c
@@ -127,6 +127,21 @@ static int __init register_earlycon(char
 	return 0;
 }
 
+int earlycon_match(struct uart_port *up, char **options_p)
+{
+	struct earlycon_device *device = &early_console_dev;
+
+	if (!device->con || !(device->con->flags & CON_ENABLED))
+		return 0;
+
+	if (device->match && device->match(device, up)) {
+		*options_p = device->options;
+		return 1;
+	}
+
+	return 0;
+}
+
 /**
  *	setup_earlycon - match and register earlycon console
  *	@buf:	earlycon param string
Index: linux-2.6/include/linux/serial_core.h
===
--- linux-2.6.orig/include/linux/serial_core.h
+++ linux-2.6/include/linux/serial_core.h
@@ -337,6 +337,7 @@ struct earlycon_device {
 	struct uart_port port;
 	char options[16];		/* e.g., 115200n8 */
 	unsigned int baud;
+	int (*match)(struct earlycon_device *, struct uart_port *);
 };
 
 struct earlycon_id {
@@ -344,6 +345,7 @@ struct earlycon_id {
 	int	(*setup)(struct earlycon_device *, const char *options);
 };
 
+extern int earlycon_match(struct uart_port *up, char **options_p);
 extern int setup_earlycon(char *buf);
 extern int of_setup_earlycon(unsigned long addr,
 			 int (*setup)(struct earlycon_device *, const char *));


Re: [PATCH V2] UBI: power cut emulation for testing

2015-04-05 Thread Richard Weinberger
Am 05.04.2015 um 22:04 schrieb Pavel Machek:
> On Sun 2015-04-05 21:49:27, Richard Weinberger wrote:
>> On Sun, Apr 5, 2015 at 9:31 PM, Pavel Machek  wrote:
>>> On Thu 2015-03-26 23:59:50, david.oberhollen...@sigma-star.at wrote:
 Emulate random power cuts by switching device to ro after a number of
 writes to allow simple power cut testing with nand-sim.

 Maximum and minimum number of successful writes before power cut and
 what kind of writes (EC header, VID header or none) to interrupt
 configurable via debugfs.

 Signed-off-by: David Oberhollenzer 
 ---
 V2: Remove broken check to prevent multiple triggering
>>>
>>> Does NAND always finish write of full block during powerfail?
>>
>> Not sure if I correctly understand your question.
>> Unless you don't have special hardware a write can be interrupted and
>> can cause problems.
> 
> But this only emulates fail after a full block written, no?

Emulating all aspects of real hardware is almost impossible.

Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Linux-nvdimm] [PATCH 1/2] x86: add support for the non-standard protected e820 type

2015-04-05 Thread Yinghai Lu
On Sun, Apr 5, 2015 at 2:18 AM, Boaz Harrosh  wrote:
> On 04/03/2015 08:12 PM, Yinghai Lu wrote:
>> On Fri, Apr 3, 2015 at 9:14 AM, Toshi Kani  wrote:
>>> On Wed, 2015-04-01 at 09:12 +0200, Christoph Hellwig wrote:
>>>   :
 @@ -748,7 +758,7 @@ u64 __init early_reserve_e820(u64 size, u64 align)
  /*
   * Find the highest page frame number we have available
   */
 -static unsigned long __init e820_end_pfn(unsigned long limit_pfn, 
 unsigned type)
 +static unsigned long __init e820_end_pfn(unsigned long limit_pfn)
  {
   int i;
   unsigned long last_pfn = 0;
 @@ -759,7 +769,11 @@ static unsigned long __init e820_end_pfn(unsigned 
 long limit_pfn, unsigned type)
   unsigned long start_pfn;
   unsigned long end_pfn;

 - if (ei->type != type)
 + /*
 +  * Persistent memory is accounted as ram for purposes of
 +  * establishing max_pfn and mem_map.
 +  */
 + if (ei->type != E820_RAM && ei->type != E820_PRAM)
   continue;
>>>
>>> Should we also delete this code, accounting E820_PRAM as ram, along with
>>> the deletion of reserve_pmem() in this version?
>>
>
> Hi Yinghai, Toshi
>
> In my old patches I did not have these updates as well, and everything
> was very much usable, for a long time.
>
> However. I actually liked these changes in Christoph's patches and
> thought they should stay, here is why.
>
> Today I will be sending patches to make pmem be supported with
> page-struct as an optional alternative to the use of ioremap.
> This is for advanced users that wants to RDMA direct_IO and so
> on directly out of pmem.

but it is not related.  Should just remove those lines.

And even his original changes about memblock is not needed.

| You did not modify memblock_x86_fill() to treat
| E820_PRAM as E820_RAM, so memblock will not have any
| entry for E820_PRAM, so you do not need to call memblock_reserve
| there.
|
| And the same time, init_memory_mapping() will call
| init_range_memory_mapping/for_each_mem_pfn_range() to
| set kernel mapping for memory range in memblock only.
| So here calling init_memory_mapping will not do anything.
| then just drop calling to that init_memory_mapping.
| --- so will not kernel mapping pmem, is that what you intended to have?
|
| After those two changes, You do not need this reserve_pmem at all.
| Just drop it.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH/RFC 5/6] staging: board: Add support for devices with complex dependencies

2015-04-05 Thread Laurent Pinchart
Hi Geert,

On Sunday 05 April 2015 11:00:56 Geert Uytterhoeven wrote:
> On Sat, Apr 4, 2015 at 2:46 PM, Laurent Pinchart wrote:
> >> + for (i = 0; i < dev->ngpios; i++)
> >> + gpio_request_one(dev->gpios[i].gpio, dev->gpios[i].flags,
> >> +  pdev->name);
> > 
> > Aren't GPIO numbers dynamic too in DT-based systems ? Beside, shouldn't it
> > be
>
> Apparently not, as the old legacy number still works, and it doesn't work
> without.

I think we're just lucky there that the SoC main GPIO controller gets 
registered first and starts counting GPIOs with a zero offset.
 
> > the responsibility of the drievr to request the GPIOs it needs ?
> 
> As far as I understand it, on Armadillo this is used more for platform
> configuration than for device configuration, as it affects multiple devices
> (the comment says DBGMD/LCDC0/FSIA MUX).
> 
> I guess I could use a "gpio-hog" subnode in DT instead, but then we're
> already implementing the conversion to DT ;-)

But that's the goal :-) I'd rather move GPIO and pinctrl to DT directly as we 
already have the infrastructure to do so.

-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2] UBI: power cut emulation for testing

2015-04-05 Thread Pavel Machek
On Sun 2015-04-05 21:49:27, Richard Weinberger wrote:
> On Sun, Apr 5, 2015 at 9:31 PM, Pavel Machek  wrote:
> > On Thu 2015-03-26 23:59:50, david.oberhollen...@sigma-star.at wrote:
> >> Emulate random power cuts by switching device to ro after a number of
> >> writes to allow simple power cut testing with nand-sim.
> >>
> >> Maximum and minimum number of successful writes before power cut and
> >> what kind of writes (EC header, VID header or none) to interrupt
> >> configurable via debugfs.
> >>
> >> Signed-off-by: David Oberhollenzer 
> >> ---
> >> V2: Remove broken check to prevent multiple triggering
> >
> > Does NAND always finish write of full block during powerfail?
> 
> Not sure if I correctly understand your question.
> Unless you don't have special hardware a write can be interrupted and
> can cause problems.

But this only emulates fail after a full block written, no?
Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5] earlycon: 8250: Fix command line regression

2015-04-05 Thread Yinghai Lu
On Sun, Apr 5, 2015 at 7:52 AM, Peter Hurley  wrote:
> Restore undocumented behavior of kernel command line parameters of
> the forms:
> console=uart[8250],io|mmio|mmio32,[,options]
> console=uart[8250],[,options]
> where 'options' have not been specified; in this case, the hardware
> is assumed to be initialized.
>
> Document the required behavior of the original implementation.
>
> Fixes: c7cef0a84912cab3c9df8 ("console: Add extensible console matching")
> Reported-by: Yinghai Lu 
> Signed-off-by: Peter Hurley 
> ---
> v5: Refactored serial8250_console_setup() & univ8250_console_setup()
> to eliminate open-coding; net +1 LOC (excludes documentation)
>
> v4: Removed FIXME comment
>
> v3: Fixed automatic console to port line settings initialization;
> open-coded serial8250_console_setup() so the baud can be probed;
> added sha reference in commit log
>
> v2: Fixed regression which allowed "console=uart1337,..." to start a
> console (but not an earlycon)
>   + fixed earlycon= documentation related required behavior fixed by
> this patch
>
>  Documentation/kernel-parameters.txt  | 18 ---
>  drivers/tty/serial/8250/8250_core.c  | 45 
> 
>  drivers/tty/serial/8250/8250_early.c | 19 ---
>  3 files changed, 50 insertions(+), 32 deletions(-)
>
> diff --git a/Documentation/kernel-parameters.txt 
> b/Documentation/kernel-parameters.txt
> index bfcb1a6..1facf0b 100644
> --- a/Documentation/kernel-parameters.txt
> +++ b/Documentation/kernel-parameters.txt
> @@ -713,10 +713,18 @@ bytes respectively. Such letter suffixes can also be 
> entirely omitted.
>
> uart[8250],io,[,options]
> uart[8250],mmio,[,options]
> +   uart[8250],mmio32,[,options]
> +   uart[8250],0x[,options]

You just don't listen.

I wasted too much time on this.

Greg,

Please just drop c7cef0a84912cab3c9df8 ("console: Add extensible
console matching").

Thanks

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2] UBI: power cut emulation for testing

2015-04-05 Thread Richard Weinberger
On Sun, Apr 5, 2015 at 9:31 PM, Pavel Machek  wrote:
> On Thu 2015-03-26 23:59:50, david.oberhollen...@sigma-star.at wrote:
>> Emulate random power cuts by switching device to ro after a number of
>> writes to allow simple power cut testing with nand-sim.
>>
>> Maximum and minimum number of successful writes before power cut and
>> what kind of writes (EC header, VID header or none) to interrupt
>> configurable via debugfs.
>>
>> Signed-off-by: David Oberhollenzer 
>> ---
>> V2: Remove broken check to prevent multiple triggering
>
> Does NAND always finish write of full block during powerfail?

Not sure if I correctly understand your question.
Unless you don't have special hardware a write can be interrupted and
can cause problems.

-- 
Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Please respond!!!

2015-04-05 Thread Giorgio Guerra
Please respond!!!
Hello friend!

I would like to contact you personally for an important proposal that could of 
interest to you.
I send this email only to know if this email address is functional.
I have something very important to discuss with you. Contact me for details by: 
 Email: fernrodyu...@aol.jp with your direct contacts.

Kind regards.
Antonio Vinal.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH V2] UBI: power cut emulation for testing

2015-04-05 Thread Pavel Machek
On Thu 2015-03-26 23:59:50, david.oberhollen...@sigma-star.at wrote:
> Emulate random power cuts by switching device to ro after a number of
> writes to allow simple power cut testing with nand-sim.
> 
> Maximum and minimum number of successful writes before power cut and
> what kind of writes (EC header, VID header or none) to interrupt
> configurable via debugfs.
> 
> Signed-off-by: David Oberhollenzer 
> ---
> V2: Remove broken check to prevent multiple triggering

Does NAND always finish write of full block during powerfail?

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH V2] tty: serial: Add const to struct uart_ops declarations

2015-04-05 Thread Joe Perches
These structs can be const, so make them const.

Miscellanea:

o Add static to struct uart_ops declaration in bfin_sport_uart

Signed-off-by: Joe Perches 
---
On Sun, 2015-04-05 at 00:04 +0200, Stefan Agner wrote:
> On 2015-04-04 19:47, Joe Perches wrote:
> > Done with:
> > sed -r -i -e 's/\bstruct\s+uart_ops\s+(\w+)\s*=\s*/const struct
> > uart_ops \1 = /g' drivers/tty/serial/*.c
[]
> +++ b/drivers/tty/serial/fsl_lpuart.c
> Something went wrong in this driver, const is twice...

Apologies, thanks for noticing.
The sed was mistakenly done twice on that file.

V2:

o Fix duplicate const in fsl_lpuart.c
o Add static to drivers/tty/serial/bfin_sport_uart.c

Still compiled only x86 and not cross-compiled or tested.

 drivers/tty/serial/21285.c  | 2 +-
 drivers/tty/serial/altera_jtaguart.c| 2 +-
 drivers/tty/serial/altera_uart.c| 2 +-
 drivers/tty/serial/amba-pl010.c | 2 +-
 drivers/tty/serial/amba-pl011.c | 2 +-
 drivers/tty/serial/apbuart.c| 2 +-
 drivers/tty/serial/ar933x_uart.c| 2 +-
 drivers/tty/serial/arc_uart.c   | 2 +-
 drivers/tty/serial/atmel_serial.c   | 2 +-
 drivers/tty/serial/bcm63xx_uart.c   | 2 +-
 drivers/tty/serial/bfin_sport_uart.c| 2 +-
 drivers/tty/serial/bfin_uart.c  | 2 +-
 drivers/tty/serial/cpm_uart/cpm_uart_core.c | 2 +-
 drivers/tty/serial/dz.c | 2 +-
 drivers/tty/serial/efm32-uart.c | 2 +-
 drivers/tty/serial/fsl_lpuart.c | 4 ++--
 drivers/tty/serial/icom.c   | 2 +-
 drivers/tty/serial/imx.c| 2 +-
 drivers/tty/serial/ioc3_serial.c| 2 +-
 drivers/tty/serial/ioc4_serial.c| 2 +-
 drivers/tty/serial/ip22zilog.c  | 2 +-
 drivers/tty/serial/jsm/jsm_tty.c| 2 +-
 drivers/tty/serial/lantiq.c | 2 +-
 drivers/tty/serial/lpc32xx_hs.c | 2 +-
 drivers/tty/serial/m32r_sio.c   | 2 +-
 drivers/tty/serial/max3100.c| 2 +-
 drivers/tty/serial/men_z135_uart.c  | 2 +-
 drivers/tty/serial/meson_uart.c | 2 +-
 drivers/tty/serial/mpc52xx_uart.c   | 2 +-
 drivers/tty/serial/mpsc.c   | 2 +-
 drivers/tty/serial/msm_serial.c | 2 +-
 drivers/tty/serial/mux.c| 2 +-
 drivers/tty/serial/mxs-auart.c  | 2 +-
 drivers/tty/serial/netx-serial.c| 2 +-
 drivers/tty/serial/nwpserial.c  | 2 +-
 drivers/tty/serial/omap-serial.c| 2 +-
 drivers/tty/serial/pch_uart.c   | 2 +-
 drivers/tty/serial/pmac_zilog.c | 2 +-
 drivers/tty/serial/pnx8xxx_uart.c   | 2 +-
 drivers/tty/serial/pxa.c| 2 +-
 drivers/tty/serial/sa1100.c | 2 +-
 drivers/tty/serial/samsung.c| 2 +-
 drivers/tty/serial/serial-tegra.c   | 2 +-
 drivers/tty/serial/serial_ks8695.c  | 2 +-
 drivers/tty/serial/serial_txx9.c| 2 +-
 drivers/tty/serial/sh-sci.c | 2 +-
 drivers/tty/serial/sirfsoc_uart.c   | 2 +-
 drivers/tty/serial/sn_console.c | 2 +-
 drivers/tty/serial/sprd_serial.c| 2 +-
 drivers/tty/serial/st-asc.c | 2 +-
 drivers/tty/serial/sunhv.c  | 2 +-
 drivers/tty/serial/sunsab.c | 2 +-
 drivers/tty/serial/sunsu.c  | 2 +-
 drivers/tty/serial/sunzilog.c   | 2 +-
 drivers/tty/serial/timbuart.c   | 2 +-
 drivers/tty/serial/uartlite.c   | 2 +-
 drivers/tty/serial/ucc_uart.c   | 2 +-
 drivers/tty/serial/vr41xx_siu.c | 2 +-
 drivers/tty/serial/vt8500_serial.c  | 2 +-
 drivers/tty/serial/xilinx_uartps.c  | 2 +-
 drivers/tty/serial/zs.c | 2 +-
 61 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/drivers/tty/serial/21285.c b/drivers/tty/serial/21285.c
index 9b208bd..804632b 100644
--- a/drivers/tty/serial/21285.c
+++ b/drivers/tty/serial/21285.c
@@ -334,7 +334,7 @@ static int serial21285_verify_port(struct uart_port *port, 
struct serial_struct
return ret;
 }
 
-static struct uart_ops serial21285_ops = {
+static const struct uart_ops serial21285_ops = {
.tx_empty   = serial21285_tx_empty,
.get_mctrl  = serial21285_get_mctrl,
.set_mctrl  = serial21285_set_mctrl,
diff --git a/drivers/tty/serial/altera_jtaguart.c 
b/drivers/tty/serial/altera_jtaguart.c
index 0fefdd8..668158a1 100644
--- a/drivers/tty/serial/altera_jtaguart.c
+++ b/drivers/tty/serial/altera_jtaguart.c
@@ -280,7 +280,7 @@ static int altera_jtaguart_verify_port(struct uart_port 
*port,
 /*
  * Define the basic serial functions we support.
  */
-static struct uart_ops altera_jtaguart_ops = {
+static const struct uart_ops altera_jtaguart_ops = {
.tx_empty   = altera_jtaguart_tx_empty,
.g

Re: [PATCH 02/16] vfs: check kiocb->ki_flags instead filp->fl_flags

2015-04-05 Thread Al Viro
On Sun, Apr 05, 2015 at 02:03:22PM +0300, Dmitry Monakhov wrote:

> I'm not sure I have get your point about ocfs2 because it does
> iov_iter_truncate() right after generic_write_checks()

This
ret = ocfs2_prepare_inode_for_write(file, ppos, count, appending,
&can_do_direct, &has_refcount);
being done before generic_write_checks().  It actually duplicates some
parts of generic_write_checks() inside (O_APPEND-related, and AFAICS
they _are_ triggered twice that way).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 12/16] ib_srpt: fix error return code

2015-04-05 Thread Bart Van Assche

On 04/05/15 14:06, Julia Lawall wrote:

Return a negative error code on failure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// 
@@
identifier ret; expression e1,e2;
@@
(
if (\(ret < 0\|ret != 0\))
  { ... return ret; }
|
ret = 0
)
... when != ret = e1
 when != &ret
*if(...)
{
   ... when != ret = e2
   when forall
  return ret;
}
// 

In the first case, the printk is changed to use the ret value, rather
than duplicating PTR_ERR(ch->thread).  This requires changing the format
from %ld to %d, to account for the type of ret.

Signed-off-by: Julia Lawall 

---
  drivers/infiniband/ulp/srpt/ib_srpt.c |6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c 
b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 6e0a477..5ec98f5 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -2143,8 +2143,8 @@ retry:

ch->thread = kthread_run(srpt_compl_thread, ch, "ib_srpt_compl");
if (IS_ERR(ch->thread)) {
-   printk(KERN_ERR "failed to create kernel thread %ld\n",
-  PTR_ERR(ch->thread));
+   ret = PTR_ERR(ch->thread);
+   printk(KERN_ERR "failed to create kernel thread %d\n", ret);
ch->thread = NULL;
goto err_destroy_qp;
}
@@ -2590,6 +2590,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
   " configured yet for initiator %s.\n", ch->sess_name);
rej->reason = __constant_cpu_to_be32(
SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED);
+   ret = -EINVAL;
goto destroy_ib;
}

@@ -2598,6 +2599,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
rej->reason = __constant_cpu_to_be32(
SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES);
pr_debug("Failed to create session\n");
+   ret = PTR_ERR(ch->sess);
goto deregister_session;
}
ch->sess->se_node_acl = &nacl->nacl;


This is not the proper way to fix srpt_cm_req_recv(). The kthread_run() 
call must be moved from srpt_create_ch_ib() to after the session 
registration code in srpt_cm_req_recv(), and the session registration 
call + the kthread_run() call must be protected via a mutex against 
concurrent HCA hot-plug removal events (see also srpt_remove_one() and 
srpt_remove_sdev()).


Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] PM suspend/hibernate: Call notifier after freezing processes

2015-04-05 Thread Pali RohƔr
To prevent race conditions on userspace processes with I/O some taks must be
called after processes are freezed. This patch adds new events which are
delivered by pm_notifier_call_chain() after freezing processes when doing
suspend or hibernate action.

Signed-off-by: Pali RohƔr 
---
 include/linux/suspend.h  |2 ++
 kernel/power/hibernate.c |2 ++
 kernel/power/suspend.c   |4 +++-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 5efe743..bc743c8 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -368,6 +368,8 @@ static inline bool hibernation_available(void) { return 
false; }
 #define PM_POST_SUSPEND0x0004 /* Suspend finished */
 #define PM_RESTORE_PREPARE 0x0005 /* Going to restore a saved image */
 #define PM_POST_RESTORE0x0006 /* Restore failed */
+#define PM_HIBERNATION_AFTER_FREEZE0x0007 /* After hibernation freeze */
+#define PM_SUSPEND_AFTER_FREEZE0x0008 /* After suspend freeze 
*/
 
 extern struct mutex pm_mutex;
 
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 2329daa..184f7ee 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -671,6 +671,8 @@ int hibernate(void)
if (error)
goto Exit;
 
+   pm_notifier_call_chain(PM_HIBERNATION_AFTER_FREEZE);
+
lock_device_hotplug();
/* Allocate memory management structures */
error = create_basic_memory_bitmaps();
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index b7d6b3a..1776938 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -268,8 +268,10 @@ static int suspend_prepare(suspend_state_t state)
trace_suspend_resume(TPS("freeze_processes"), 0, true);
error = suspend_freeze_processes();
trace_suspend_resume(TPS("freeze_processes"), 0, false);
-   if (!error)
+   if (!error) {
+   pm_notifier_call_chain(PM_SUSPEND_AFTER_FREEZE);
return 0;
+   }
 
suspend_stats.failed_freeze++;
dpm_save_failed_step(SUSPEND_FREEZE);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] dm-crypt: Adds support for wiping key when doing suspend/hibernation

2015-04-05 Thread Pali RohƔr
This patch series increase security of suspend and hibernate actions. It allows
user to safely wipe crypto keys before suspend and hibernate actions starts
without race conditions on userspace process with heavy I/O.

To automatically wipe cryto key for  before hibernate action call:
$ dmsetup message  0 key wipe_on_hibernation 1

To automatically wipe cryto key for  before suspend action call:
$ dmsetup message  0 key wipe_on_suspend 1

(Value 0 after wipe_* string reverts original behaviour - to not wipe key)

Pali RohƔr (3):
  PM suspend/hibernate: Call notifier after freezing processes
  dm: Export function dm_suspend_md()
  dm-crypt: Adds support for wiping key when doing suspend/hibernation

 drivers/md/dm-crypt.c|  109 +++---
 drivers/md/dm.c  |6 +++
 drivers/md/dm.h  |5 +++
 include/linux/suspend.h  |2 +
 kernel/power/hibernate.c |2 +
 kernel/power/suspend.c   |4 +-
 6 files changed, 120 insertions(+), 8 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] dm-crypt: Adds support for wiping key when doing suspend/hibernation

2015-04-05 Thread Pali RohƔr
This patch adds dm message commands and option strings to optionally wipe key
from dm-crypt device before entering suspend or hibernate state.

Before key is wiped dm device must be suspended. To prevent race conditions with
I/O and userspace processes, wiping action must be called after processes are
freezed. Otherwise userspace processes could start reading/writing to disk after
dm device is suspened and freezing processes before suspend/hibernate action
will fail.

Signed-off-by: Pali RohƔr 
---
 drivers/md/dm-crypt.c |  109 +
 1 file changed, 102 insertions(+), 7 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 713a962..9b02824 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -31,6 +32,8 @@
 
 #include 
 
+#include "dm.h"
+
 #define DM_MSG_PREFIX "crypt"
 
 /*
@@ -112,13 +115,18 @@ struct iv_tcw_private {
  * and encrypts / decrypts at the same time.
  */
 enum flags { DM_CRYPT_SUSPENDED, DM_CRYPT_KEY_VALID,
-DM_CRYPT_SAME_CPU, DM_CRYPT_NO_OFFLOAD };
+DM_CRYPT_SAME_CPU, DM_CRYPT_NO_OFFLOAD,
+DM_CRYPT_KEY_WIPE_ON_HIBERNATION,
+DM_CRYPT_KEY_WIPE_ON_SUSPEND,
+};
 
 /*
  * The fields in here must be read only after initialization.
  */
 struct crypt_config {
struct dm_dev *dev;
+   struct dm_target *ti;
+   struct list_head entry;
sector_t start;
 
/*
@@ -181,6 +189,9 @@ struct crypt_config {
 
 #define MIN_IOS16
 
+static LIST_HEAD(crypt_list);
+static DEFINE_MUTEX(crypt_list_mtx);
+
 static void clone_init(struct dm_crypt_io *, struct bio *);
 static void kcryptd_queue_crypt(struct dm_crypt_io *io);
 static u8 *iv_of_dmreq(struct crypt_config *cc, struct dm_crypt_request 
*dmreq);
@@ -1497,12 +1508,26 @@ out:
 
 static int crypt_wipe_key(struct crypt_config *cc)
 {
+   int ret;
+
+   if (cc->iv_gen_ops && cc->iv_gen_ops->wipe) {
+   ret = cc->iv_gen_ops->wipe(cc);
+   if (ret)
+   return ret;
+   }
+
clear_bit(DM_CRYPT_KEY_VALID, &cc->flags);
memset(&cc->key, 0, cc->key_size * sizeof(u8));
 
return crypt_setkey_allcpus(cc);
 }
 
+static void crypt_suspend_and_wipe_key(struct crypt_config *cc)
+{
+   dm_suspend_md(dm_table_get_md(cc->ti->table));
+   crypt_wipe_key(cc);
+}
+
 static void crypt_dtr(struct dm_target *ti)
 {
struct crypt_config *cc = ti->private;
@@ -1512,6 +1537,10 @@ static void crypt_dtr(struct dm_target *ti)
if (!cc)
return;
 
+   mutex_lock(&crypt_list_mtx);
+   list_del(&cc->entry);
+   mutex_unlock(&crypt_list_mtx);
+
if (cc->write_thread)
kthread_stop(cc->write_thread);
 
@@ -1738,6 +1767,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int 
argc, char **argv)
cc->key_size = key_size;
 
ti->private = cc;
+   cc->ti = ti;
ret = crypt_ctr_cipher(ti, argv[0], argv[1]);
if (ret < 0)
goto bad;
@@ -1832,7 +1862,14 @@ static int crypt_ctr(struct dm_target *ti, unsigned int 
argc, char **argv)
else if (!strcasecmp(opt_string, 
"submit_from_crypt_cpus"))
set_bit(DM_CRYPT_NO_OFFLOAD, &cc->flags);
 
+   else if (!strcasecmp(opt_string, 
"key_wipe_on_hibernation"))
+   set_bit(DM_CRYPT_KEY_WIPE_ON_HIBERNATION, 
&cc->flags);
+
+   else if (!strcasecmp(opt_string, "key_wipe_on_suspend"))
+   set_bit(DM_CRYPT_KEY_WIPE_ON_SUSPEND, 
&cc->flags);
+
else {
+   ret = -EINVAL;
ti->error = "Invalid feature arguments";
goto bad;
}
@@ -1871,6 +1908,10 @@ static int crypt_ctr(struct dm_target *ti, unsigned int 
argc, char **argv)
ti->num_flush_bios = 1;
ti->discard_zeroes_data_unsupported = true;
 
+   mutex_lock(&crypt_list_mtx);
+   list_add(&cc->entry, &crypt_list);
+   mutex_unlock(&crypt_list_mtx);
+
return 0;
 
 bad:
@@ -1979,6 +2020,8 @@ static void crypt_resume(struct dm_target *ti)
 /* Message interface
  * key set 
  * key wipe
+ * key wipe_on_hibernation <0|1>
+ * key wipe_on_suspend <0|1>
  */
 static int crypt_message(struct dm_target *ti, unsigned argc, char **argv)
 {
@@ -1989,6 +2032,30 @@ static int crypt_message(struct dm_target *ti, unsigned 
argc, char **argv)
goto error;
 
if (!strcasecmp(argv[0], "key")) {
+   if (argc == 3 && !strcasecmp(argv[1], "wipe_on_hibernation")) {
+   if (!strcmp(argv[2], "1")) {
+   set_bit(DM_CRYPT_KEY_WIPE_ON_HIBERNATION, 
&cc->flags);
+ 

[PATCH 2/3] dm: Export function dm_suspend_md()

2015-04-05 Thread Pali RohƔr
This patch exports function dm_suspend_md() which suspend mapped device so other
kernel drivers can use it and could suspend mapped device when needed.

Signed-off-by: Pali RohƔr 
---
 drivers/md/dm.c |6 ++
 drivers/md/dm.h |5 +
 2 files changed, 11 insertions(+)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 8001fe9..919ce95 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -3053,6 +3053,12 @@ out:
return r;
 }
 
+int dm_suspend_md(struct mapped_device *md)
+{
+   return dm_suspend(md, DM_SUSPEND_LOCKFS_FLAG);
+}
+EXPORT_SYMBOL_GPL(dm_suspend_md);
+
 /*
  * Internal suspend/resume works like userspace-driven suspend. It waits
  * until all bios finish and prevents issuing new bios to the target drivers.
diff --git a/drivers/md/dm.h b/drivers/md/dm.h
index 59f53e7..623c9a8 100644
--- a/drivers/md/dm.h
+++ b/drivers/md/dm.h
@@ -152,6 +152,11 @@ int dm_test_deferred_remove_flag(struct mapped_device *md);
 void dm_deferred_remove(void);
 
 /*
+ * Suspend mapped_device
+ */
+int dm_suspend_md(struct mapped_device *md);
+
+/*
  * The device-mapper can be driven through one of two interfaces;
  * ioctl or filesystem, depending which patch you have applied.
  */
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 2/2] watchdog: add watchdog_exclude sysctl to assist nohz

2015-04-05 Thread Ulrich Obergfell

Chris,

I'd like to comment on the following proposed change:

+int proc_dowatchdog_exclude(struct ctl_table *table, int write,
+void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+int err;
+
+mutex_lock(&watchdog_proc_mutex);
+err = proc_do_large_bitmap(table, write, buffer, lenp, ppos);
+if (!err && write && watchdog_user_enabled) {
+watchdog_disable_all_cpus();
+watchdog_enable_all_cpus(false);
+}
+mutex_unlock(&watchdog_proc_mutex);
+return err;
+}

The watchdog mechanism is enabled if watchdog_user_enabled and watchdog_thresh
are both non-zero. Hence, I think the if-statement in the above snippet of code
should look like this:

 if (!err && write && watchdog_user_enabled && watchdog_thresh)

Please see proc_dowatchdog() which checks the content of both variables before
it calls watchdog_enable_all_cpus():

  
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/watchdog.c?id=refs/tags/v4.0-rc6#n682


For completeness, I'd also like to point out that if the patch series at
https://lkml.org/lkml/2015/2/5/626 gets accepted upstream, the if-statement
will have to be adjusted. I think it should then look like this:

 if (!err && write && watchdog_enabled && watchdog_thresh) {
 watchdog_disable_all_cpus();
 watchdog_enable_all_cpus();
 }

Please see proc_watchdog_update() here which is similar to the above.

  
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/kernel/watchdog.c?id=refs/tags/next-20150402#n710


Regards,

Uli
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] sched/fair: correct inaccurate comment in __update_group_entity_contrib

2015-04-05 Thread Alex Dowad
Signed-off-by: Alex Dowad 
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index bcfe320..1bae5ea 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2648,7 +2648,7 @@ static inline void __update_group_entity_contrib(struct 
sched_entity *se)
 * lower-bound on the true value.
 *
 * Consider the aggregate of 2 contributions.  Either they are disjoint
-* (and the sum represents true value) or they are disjoint and we are
+* (and the sum represents true value) or they intersect and we are
 * understating by the aggregate of their overlap.
 *
 * Extending this to N cpus, for a given overlap, the maximum amount we
-- 
2.0.0.GIT

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] block: export blkdev_reread_part()

2015-04-05 Thread Ming Lei
On Mon, Apr 6, 2015 at 12:12 AM, Christoph Hellwig  wrote:
>> +/*
>> + * This is exported as API for block driver, can be called
>> + * with requiring bd_mutex or not.
>> + */
>> +int __blkdev_reread_part(struct block_device *bdev, bool lock)
>>  {
>>   struct gendisk *disk = bdev->bd_disk;
>>   int res;
>> @@ -159,12 +163,14 @@ static int blkdev_reread_part(struct block_device 
>> *bdev)
>>   return -EINVAL;
>>   if (!capable(CAP_SYS_ADMIN))
>>   return -EACCES;
>> - if (!mutex_trylock(&bdev->bd_mutex))
>> + if (lock && !mutex_trylock(&bdev->bd_mutex))
>>   return -EBUSY;
>
> Please don't add funtions that do conditional locking, instead move
> all the code into blkdev_reread_part_nolock, and then wrap it:
>
> int blkdev_reread_part(struct block_device *bdev)
> {
> if (!mutex_trylock(&bdev->bd_mutex))
> return -EBUSY;
> blkdev_reread_part_nolock(bdev);
> mutex_unlock(&bdev->bd_mutex);
> }

Yes, it is more clean, but with extra acquiring lock cost for the
failure cases, especially when we replace trylock with mutex_lock().

>
> Please also add a lockdep_assert_held to blkdev_reread_part_nolock to
> ensure callers actually do hold the lock.

Good point!

Thanks,
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[char-misc-next 3/8 RESEND] mei: add a reference from the host client to the me client

2015-04-05 Thread Tomas Winkler
From: Alexander Usyskin 

Keep a pointer to associated me client in the host client object to
eliminate me client searches. Check if the me client is active in the
firmware by checking if its is linked on the me clients list
Add accessors for the me client properties from host client.

Signed-off-by: Alexander Usyskin 
Signed-off-by: Tomas Winkler 
---
 drivers/misc/mei/amthif.c|  19 ++-
 drivers/misc/mei/bus.c   |  27 +++---
 drivers/misc/mei/client.c| 118 +++
 drivers/misc/mei/client.h|  84 +++---
 drivers/misc/mei/debugfs.c   |   2 +-
 drivers/misc/mei/hbm.c   |   4 +-
 drivers/misc/mei/interrupt.c |   4 +-
 drivers/misc/mei/main.c  |  31 +---
 drivers/misc/mei/mei_dev.h   |  17 ---
 drivers/misc/mei/nfc.c   |  50 --
 drivers/misc/mei/wd.c|  22 ++--
 11 files changed, 207 insertions(+), 171 deletions(-)

diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index 3c1fd87ee10b..a0209f02a31a 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -60,28 +60,19 @@ void mei_amthif_reset_params(struct mei_device *dev)
  * mei_amthif_host_init - mei initialization amthif client.
  *
  * @dev: the device structure
+ * @me_cl: me client
  *
  * Return: 0 on success, <0 on failure.
  */
-int mei_amthif_host_init(struct mei_device *dev)
+int mei_amthif_host_init(struct mei_device *dev, struct mei_me_client *me_cl)
 {
struct mei_cl *cl = &dev->iamthif_cl;
-   struct mei_me_client *me_cl;
int ret;
 
dev->iamthif_state = MEI_IAMTHIF_IDLE;
 
mei_cl_init(cl, dev);
 
-   me_cl = mei_me_cl_by_uuid(dev, &mei_amthif_guid);
-   if (!me_cl) {
-   dev_info(dev->dev, "amthif: failed to find the client");
-   return -ENOTTY;
-   }
-
-   cl->me_client_id = me_cl->client_id;
-   cl->cl_uuid = me_cl->props.protocol_name;
-
/* Assign iamthif_mtu to the value received from ME  */
 
dev->iamthif_mtu = me_cl->props.max_msg_length;
@@ -91,15 +82,13 @@ int mei_amthif_host_init(struct mei_device *dev)
ret = mei_cl_link(cl, MEI_IAMTHIF_HOST_CLIENT_ID);
if (ret < 0) {
dev_err(dev->dev, "amthif: failed cl_link %d\n", ret);
-   goto out;
+   return ret;
}
 
-   ret = mei_cl_connect(cl, NULL);
+   ret = mei_cl_connect(cl, me_cl, NULL);
 
dev->iamthif_state = MEI_IAMTHIF_IDLE;
 
-out:
-   mei_me_cl_put(me_cl);
return ret;
 }
 
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 00b0cb2075fb..0236ba8270d6 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -133,7 +133,13 @@ static struct bus_type mei_cl_bus_type = {
 
 static void mei_cl_dev_release(struct device *dev)
 {
-   kfree(to_mei_cl_device(dev));
+   struct mei_cl_device *device = to_mei_cl_device(dev);
+
+   if (!device)
+   return;
+
+   mei_me_cl_put(device->me_cl);
+   kfree(device);
 }
 
 static struct device_type mei_cl_device_type = {
@@ -146,13 +152,15 @@ struct mei_cl *mei_cl_bus_find_cl_by_uuid(struct 
mei_device *dev,
struct mei_cl *cl;
 
list_for_each_entry(cl, &dev->device_list, device_link) {
-   if (!uuid_le_cmp(uuid, cl->cl_uuid))
+   if (cl->me_cl && !uuid_le_cmp(uuid, *mei_cl_uuid(cl)))
return cl;
}
 
return NULL;
 }
+
 struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,
+   struct mei_me_client *me_cl,
uuid_le uuid, char *name,
struct mei_cl_ops *ops)
 {
@@ -168,6 +176,11 @@ struct mei_cl_device *mei_cl_add_device(struct mei_device 
*dev,
if (!device)
return NULL;
 
+   device->me_cl = mei_me_cl_get(me_cl);
+   if (!device->me_cl) {
+   kfree(device);
+   return NULL;
+   }
device->cl = cl;
device->ops = ops;
 
@@ -180,6 +193,7 @@ struct mei_cl_device *mei_cl_add_device(struct mei_device 
*dev,
status = device_register(&device->dev);
if (status) {
dev_err(dev->dev, "Failed to register MEI device\n");
+   mei_me_cl_put(device->me_cl);
kfree(device);
return NULL;
}
@@ -228,7 +242,6 @@ static ssize_t ___mei_cl_send(struct mei_cl *cl, u8 *buf, 
size_t length,
bool blocking)
 {
struct mei_device *dev;
-   struct mei_me_client *me_cl = NULL;
struct mei_cl_cb *cb = NULL;
ssize_t rets;
 
@@ -244,13 +257,12 @@ static ssize_t ___mei_cl_send(struct mei_cl *cl, u8 *buf, 
size_t length,
}
 
/* Check if we have an ME client device */
-   me_cl = mei_me_cl_by_uuid_id(dev, &cl->cl_uuid, cl->me_client_id);
-   if (!me_cl) {
+   i

[char-misc-next 4/8 RESEND] mei: fix flow control for single buffer clients

2015-04-05 Thread Tomas Winkler
From: Alexander Usyskin 

For ME clients that use single receiving buffer
the driver tracks credentials on mei_me_clients structure
for all connections. The driver needs to book keep the shared
resource correctly and track the connections, particularly
the credit has to be cleaned when there is no active connection
to a particular me client. This solves issue when subsequent
connection will not get an ill impression that it can write.

We add active connection counter the particular ME client and
when the counter reach zero, we clear the credits.

Signed-off-by: Alexander Usyskin 
Signed-off-by: Tomas Winkler 
---
 drivers/misc/mei/client.c  | 29 +++--
 drivers/misc/mei/mei_dev.h |  4 
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index a8a3b9d15231..3475200c3850 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -749,10 +749,31 @@ void mei_cl_set_disconnected(struct mei_cl *cl)
cl->mei_flow_ctrl_creds = 0;
cl->timer_count = 0;
 
+   if (!cl->me_cl)
+   return;
+
+   if (!WARN_ON(cl->me_cl->connect_count == 0))
+   cl->me_cl->connect_count--;
+
+   if (cl->me_cl->connect_count == 0)
+   cl->me_cl->mei_flow_ctrl_creds = 0;
+
mei_me_cl_put(cl->me_cl);
cl->me_cl = NULL;
 }
 
+static int mei_cl_set_connecting(struct mei_cl *cl, struct mei_me_client 
*me_cl)
+{
+   cl->me_cl = mei_me_cl_get(me_cl);
+   if (!cl->me_cl)
+   return -ENOENT;
+
+   cl->state = MEI_FILE_CONNECTING;
+   cl->me_cl->connect_count++;
+
+   return 0;
+}
+
 /*
  * mei_cl_send_disconnect - send disconnect request
  *
@@ -1009,13 +1030,9 @@ int mei_cl_connect(struct mei_cl *cl, struct 
mei_me_client *me_cl,
if (rets)
goto out;
 
-   cl->me_cl = mei_me_cl_get(me_cl);
-   if (!cl->me_cl) {
-   rets = -ENODEV;
+   rets = mei_cl_set_connecting(cl, me_cl);
+   if (rets)
goto out;
-   }
-
-   cl->state = MEI_FILE_CONNECTING;
list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
 
/* run hbuf acquire last so we don't have to undo */
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 711e4fa8b708..f17979c680a9 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -177,6 +177,8 @@ struct mei_fw_status {
  * @props: client properties
  * @client_id: me client id
  * @mei_flow_ctrl_creds: flow control credits
+ * @connect_count: number connections to this client
+ * @reserved: reserved
  */
 struct mei_me_client {
struct list_head list;
@@ -184,6 +186,8 @@ struct mei_me_client {
struct mei_client_properties props;
u8 client_id;
u8 mei_flow_ctrl_creds;
+   u8 connect_count;
+   u8 reserved;
 };
 
 
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[char-misc-next 1/8 RESEND] mei: revamp client disconnection flow

2015-04-05 Thread Tomas Winkler
Split disconnected state into two parts first reception disconnect
response from the firmware and second actually setting of disconnected
state.  Book keeping data are needed for processing and after firmware
disconnected the client and are cleaned when setting the disconnected
state in mei_cl_set_disconneted() function.
Add mei_cl_send_disconnect to reduce code duplication.

Signed-off-by: Tomas Winkler 
Signed-off-by: Alexander Usyskin 
---
 drivers/misc/mei/bus.c   |   2 -
 drivers/misc/mei/client.c| 158 +--
 drivers/misc/mei/client.h|   3 +
 drivers/misc/mei/hbm.c   |   8 +--
 drivers/misc/mei/interrupt.c |  46 +
 drivers/misc/mei/main.c  |   9 +--
 drivers/misc/mei/mei_dev.h   |   3 +-
 7 files changed, 134 insertions(+), 95 deletions(-)

diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 4cf38c39878a..873c1b6e45e8 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -480,8 +480,6 @@ int mei_cl_disable_device(struct mei_cl_device *device)
goto out;
}
 
-   cl->state = MEI_FILE_DISCONNECTING;
-
err = mei_cl_disconnect(cl);
if (err < 0) {
dev_err(dev->dev, "Could not disconnect from the ME client");
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 1e99ef6a54a2..eba5fc971378 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -546,6 +546,7 @@ void mei_cl_init(struct mei_cl *cl, struct mei_device *dev)
INIT_LIST_HEAD(&cl->link);
INIT_LIST_HEAD(&cl->device_link);
cl->writing_state = MEI_IDLE;
+   cl->state = MEI_FILE_INITIALIZING;
cl->dev = dev;
 }
 
@@ -715,6 +716,88 @@ bool mei_hbuf_acquire(struct mei_device *dev)
 }
 
 /**
+ * mei_cl_set_disconnected - set disconnected state and clear
+ *   associated states and resources
+ *
+ * @cl: host client
+ */
+void mei_cl_set_disconnected(struct mei_cl *cl)
+{
+   struct mei_device *dev = cl->dev;
+
+   if (cl->state == MEI_FILE_DISCONNECTED ||
+   cl->state == MEI_FILE_INITIALIZING)
+   return;
+
+   cl->state = MEI_FILE_DISCONNECTED;
+   mei_io_list_flush(&dev->ctrl_rd_list, cl);
+   mei_io_list_flush(&dev->ctrl_wr_list, cl);
+   cl->mei_flow_ctrl_creds = 0;
+   cl->timer_count = 0;
+}
+
+/*
+ * mei_cl_send_disconnect - send disconnect request
+ *
+ * @cl: host client
+ * @cb: callback block
+ *
+ * Return: 0, OK; otherwise, error.
+ */
+static int mei_cl_send_disconnect(struct mei_cl *cl, struct mei_cl_cb *cb)
+{
+   struct mei_device *dev;
+   int ret;
+
+   dev = cl->dev;
+
+   ret = mei_hbm_cl_disconnect_req(dev, cl);
+   cl->status = ret;
+   if (ret) {
+   cl->state = MEI_FILE_DISCONNECT_REPLY;
+   return ret;
+   }
+
+   list_move_tail(&cb->list, &dev->ctrl_rd_list.list);
+   cl->timer_count = MEI_CONNECT_TIMEOUT;
+
+   return 0;
+}
+
+/**
+ * mei_cl_irq_disconnect - processes close related operation from
+ * interrupt thread context - send disconnect request
+ *
+ * @cl: client
+ * @cb: callback block.
+ * @cmpl_list: complete list.
+ *
+ * Return: 0, OK; otherwise, error.
+ */
+int mei_cl_irq_disconnect(struct mei_cl *cl, struct mei_cl_cb *cb,
+   struct mei_cl_cb *cmpl_list)
+{
+   struct mei_device *dev = cl->dev;
+   u32 msg_slots;
+   int slots;
+   int ret;
+
+   msg_slots = mei_data2slots(sizeof(struct hbm_client_connect_request));
+   slots = mei_hbuf_empty_slots(dev);
+
+   if (slots < msg_slots)
+   return -EMSGSIZE;
+
+   ret = mei_cl_send_disconnect(cl, cb);
+   if (ret)
+   list_move_tail(&cb->list, &cmpl_list->list);
+
+   return ret;
+}
+
+
+
+/**
  * mei_cl_disconnect - disconnect host client from the me one
  *
  * @cl: host client
@@ -736,7 +819,7 @@ int mei_cl_disconnect(struct mei_cl *cl)
 
cl_dbg(dev, cl, "disconnecting");
 
-   if (cl->state != MEI_FILE_DISCONNECTING)
+   if (!mei_cl_is_connected(cl))
return 0;
 
rets = pm_runtime_get(dev->dev);
@@ -746,44 +829,41 @@ int mei_cl_disconnect(struct mei_cl *cl)
return rets;
}
 
+   cl->state = MEI_FILE_DISCONNECTING;
+
cb = mei_io_cb_init(cl, MEI_FOP_DISCONNECT, NULL);
rets = cb ? 0 : -ENOMEM;
if (rets)
-   goto free;
+   goto out;
+
+   cl_dbg(dev, cl, "add disconnect cb to control write list\n");
+   list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
 
if (mei_hbuf_acquire(dev)) {
-   if (mei_hbm_cl_disconnect_req(dev, cl)) {
-   rets = -ENODEV;
+   rets = mei_cl_send_disconnect(cl, cb);
+   if (rets) {
cl_err(dev, cl, "failed to disconnect.\n");
-   goto free;
+   goto out;
}
-

[char-misc-next 5/8 RESEND] mei: support for fixed address clients

2015-04-05 Thread Tomas Winkler
From: Alexander Usyskin 

Fixed address is simplified FW client that doesn't require
connection and doesn't support flow control.
So it can be only one host client per fixed FW client.
Fixed client access is available only for drivers on mei bus,
connection from user-space is blocked.

Signed-off-by: Alexander Usyskin 
Signed-off-by: Tomas Winkler 
---
 drivers/misc/mei/client.c| 69 ++--
 drivers/misc/mei/client.h| 12 
 drivers/misc/mei/hbm.c   |  4 +--
 drivers/misc/mei/interrupt.c |  2 +-
 4 files changed, 68 insertions(+), 19 deletions(-)

diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 3475200c3850..82f62d560877 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -764,10 +764,18 @@ void mei_cl_set_disconnected(struct mei_cl *cl)
 
 static int mei_cl_set_connecting(struct mei_cl *cl, struct mei_me_client 
*me_cl)
 {
-   cl->me_cl = mei_me_cl_get(me_cl);
-   if (!cl->me_cl)
+   if (!mei_me_cl_get(me_cl))
return -ENOENT;
 
+   /* only one connection is allowed for fixed address clients */
+   if (me_cl->props.fixed_address) {
+   if (me_cl->connect_count) {
+   mei_me_cl_put(me_cl);
+   return -EBUSY;
+   }
+   }
+
+   cl->me_cl = me_cl;
cl->state = MEI_FILE_CONNECTING;
cl->me_cl->connect_count++;
 
@@ -860,6 +868,11 @@ int mei_cl_disconnect(struct mei_cl *cl)
if (!mei_cl_is_connected(cl))
return 0;
 
+   if (mei_cl_is_fixed_address(cl)) {
+   mei_cl_set_disconnected(cl);
+   return 0;
+   }
+
rets = pm_runtime_get(dev->dev);
if (rets < 0 && rets != -EINPROGRESS) {
pm_runtime_put_noidle(dev->dev);
@@ -1013,16 +1026,25 @@ int mei_cl_connect(struct mei_cl *cl, struct 
mei_me_client *me_cl,
struct mei_cl_cb *cb;
int rets;
 
-   if (WARN_ON(!cl || !cl->dev))
+   if (WARN_ON(!cl || !cl->dev || !me_cl))
return -ENODEV;
 
dev = cl->dev;
 
+   rets = mei_cl_set_connecting(cl, me_cl);
+   if (rets)
+   return rets;
+
+   if (mei_cl_is_fixed_address(cl)) {
+   cl->state = MEI_FILE_CONNECTED;
+   return 0;
+   }
+
rets = pm_runtime_get(dev->dev);
if (rets < 0 && rets != -EINPROGRESS) {
pm_runtime_put_noidle(dev->dev);
cl_err(dev, cl, "rpm: get failed %d\n", rets);
-   return rets;
+   goto nortpm;
}
 
cb = mei_io_cb_init(cl, MEI_FOP_CONNECT, file);
@@ -1030,9 +1052,6 @@ int mei_cl_connect(struct mei_cl *cl, struct 
mei_me_client *me_cl,
if (rets)
goto out;
 
-   rets = mei_cl_set_connecting(cl, me_cl);
-   if (rets)
-   goto out;
list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
 
/* run hbuf acquire last so we don't have to undo */
@@ -1063,6 +1082,7 @@ out:
 
mei_io_cb_free(cb);
 
+nortpm:
if (!mei_cl_is_connected(cl))
mei_cl_set_disconnected(cl);
 
@@ -1109,12 +1129,21 @@ err:
  */
 int mei_cl_flow_ctrl_creds(struct mei_cl *cl)
 {
+   int rets;
+
if (WARN_ON(!cl || !cl->me_cl))
return -EINVAL;
 
if (cl->mei_flow_ctrl_creds > 0)
return 1;
 
+   if (mei_cl_is_fixed_address(cl)) {
+   rets = mei_cl_read_start(cl, mei_cl_mtu(cl), NULL);
+   if (rets && rets != -EBUSY)
+   return rets;
+   return 1;
+   }
+
if (mei_cl_is_single_recv_buf(cl)) {
if (cl->me_cl->mei_flow_ctrl_creds > 0)
return 1;
@@ -1136,6 +1165,9 @@ int mei_cl_flow_ctrl_reduce(struct mei_cl *cl)
if (WARN_ON(!cl || !cl->me_cl))
return -EINVAL;
 
+   if (mei_cl_is_fixed_address(cl))
+   return 0;
+
if (mei_cl_is_single_recv_buf(cl)) {
if (WARN_ON(cl->me_cl->mei_flow_ctrl_creds <= 0))
return -EINVAL;
@@ -1179,21 +1211,25 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length, 
struct file *fp)
cl_err(dev, cl, "no such me client\n");
return  -ENOTTY;
}
+
/* always allocate at least client max message */
length = max_t(size_t, length, mei_cl_mtu(cl));
+   cb = mei_cl_alloc_cb(cl, length, MEI_FOP_READ, fp);
+   if (!cb)
+   return -ENOMEM;
+
+   if (mei_cl_is_fixed_address(cl)) {
+   list_add_tail(&cb->list, &cl->rd_pending);
+   return 0;
+   }
 
rets = pm_runtime_get(dev->dev);
if (rets < 0 && rets != -EINPROGRESS) {
pm_runtime_put_noidle(dev->dev);
cl_err(dev, cl, "rpm: get failed %d\n", rets);
-   return rets;
+   goto nortpm;
}
 
-

[char-misc-next 2/8 RESEND] mei: revamp client connection

2015-04-05 Thread Tomas Winkler
Simplify connect state machine by changing the logic around
Connection request in progress - only check if we have a callback in
relevant queue.
Extract common code into mei_cl_send_connect() function

Signed-off-by: Tomas Winkler 
Signed-off-by: Alexander Usyskin 
---
 drivers/misc/mei/bus.c   |  6 +++
 drivers/misc/mei/client.c| 97 ++--
 drivers/misc/mei/client.h|  3 +-
 drivers/misc/mei/interrupt.c | 43 
 4 files changed, 83 insertions(+), 66 deletions(-)

diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 873c1b6e45e8..00b0cb2075fb 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -436,6 +436,12 @@ int mei_cl_enable_device(struct mei_cl_device *device)
 
mutex_lock(&dev->device_lock);
 
+   if (mei_cl_is_connected(cl)) {
+   mutex_unlock(&dev->device_lock);
+   dev_warn(dev->dev, "Already connected");
+   return -EBUSY;
+   }
+
err = mei_cl_connect(cl, NULL);
if (err < 0) {
mutex_unlock(&dev->device_lock);
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index eba5fc971378..755e1e9efd0b 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -881,28 +881,83 @@ out:
  *
  * Return: true if other client is connected, false - otherwise.
  */
-bool mei_cl_is_other_connecting(struct mei_cl *cl)
+static bool mei_cl_is_other_connecting(struct mei_cl *cl)
 {
struct mei_device *dev;
-   struct mei_cl *ocl; /* the other client */
-
-   if (WARN_ON(!cl || !cl->dev))
-   return false;
+   struct mei_cl_cb *cb;
 
dev = cl->dev;
 
-   list_for_each_entry(ocl, &dev->file_list, link) {
-   if (ocl->state == MEI_FILE_CONNECTING &&
-   ocl != cl &&
-   cl->me_client_id == ocl->me_client_id)
+   list_for_each_entry(cb, &dev->ctrl_rd_list.list, list) {
+   if (cb->fop_type == MEI_FOP_CONNECT &&
+   cl->me_client_id == cb->cl->me_client_id)
return true;
-
}
 
return false;
 }
 
 /**
+ * mei_cl_send_connect - send connect request
+ *
+ * @cl: host client
+ * @cb: callback block
+ *
+ * Return: 0, OK; otherwise, error.
+ */
+static int mei_cl_send_connect(struct mei_cl *cl, struct mei_cl_cb *cb)
+{
+   struct mei_device *dev;
+   int ret;
+
+   dev = cl->dev;
+
+   ret = mei_hbm_cl_connect_req(dev, cl);
+   cl->status = ret;
+   if (ret) {
+   cl->state = MEI_FILE_DISCONNECT_REPLY;
+   return ret;
+   }
+
+   list_move_tail(&cb->list, &dev->ctrl_rd_list.list);
+   cl->timer_count = MEI_CONNECT_TIMEOUT;
+   return 0;
+}
+
+/**
+ * mei_cl_irq_connect - send connect request in irq_thread context
+ *
+ * @cl: host client
+ * @cb: callback block
+ * @cmpl_list: complete list
+ *
+ * Return: 0, OK; otherwise, error.
+ */
+int mei_cl_irq_connect(struct mei_cl *cl, struct mei_cl_cb *cb,
+ struct mei_cl_cb *cmpl_list)
+{
+   struct mei_device *dev = cl->dev;
+   u32 msg_slots;
+   int slots;
+   int rets;
+
+   msg_slots = mei_data2slots(sizeof(struct hbm_client_connect_request));
+   slots = mei_hbuf_empty_slots(dev);
+
+   if (mei_cl_is_other_connecting(cl))
+   return 0;
+
+   if (slots < msg_slots)
+   return -EMSGSIZE;
+
+   rets = mei_cl_send_connect(cl, cb);
+   if (rets)
+   list_move_tail(&cb->list, &cmpl_list->list);
+
+   return rets;
+}
+
+/**
  * mei_cl_connect - connect host client to the me one
  *
  * @cl: host client
@@ -935,18 +990,14 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file)
if (rets)
goto out;
 
+   cl->state = MEI_FILE_CONNECTING;
+   list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
+
/* run hbuf acquire last so we don't have to undo */
if (!mei_cl_is_other_connecting(cl) && mei_hbuf_acquire(dev)) {
-   cl->state = MEI_FILE_CONNECTING;
-   if (mei_hbm_cl_connect_req(dev, cl)) {
-   rets = -ENODEV;
+   rets = mei_cl_send_connect(cl, cb);
+   if (rets)
goto out;
-   }
-   cl->timer_count = MEI_CONNECT_TIMEOUT;
-   list_add_tail(&cb->list, &dev->ctrl_rd_list.list);
-   } else {
-   cl->state = MEI_FILE_INITIALIZING;
-   list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
}
 
mutex_unlock(&dev->device_lock);
@@ -957,20 +1008,22 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file)
mutex_lock(&dev->device_lock);
 
if (!mei_cl_is_connected(cl)) {
-   /* something went really wrong */
+   /* timeout or something went really wrong */
if (!cl->status)
cl->

[char-misc-next 6/8 RESEND] mei: connection to fixed address clients from user-space

2015-04-05 Thread Tomas Winkler
From: Alexander Usyskin 

This should be used for debug only.
The feaure is gated by "allow_fixed_address" control exposed in debugfs.

Signed-off-by: Alexander Usyskin 
Signed-off-by: Tomas Winkler 
---
 drivers/misc/mei/debugfs.c | 6 ++
 drivers/misc/mei/main.c| 8 +++-
 drivers/misc/mei/mei_dev.h | 4 
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/mei/debugfs.c b/drivers/misc/mei/debugfs.c
index 3f6d855a7ecb..3cac3bc82185 100644
--- a/drivers/misc/mei/debugfs.c
+++ b/drivers/misc/mei/debugfs.c
@@ -209,6 +209,12 @@ int mei_dbgfs_register(struct mei_device *dev, const char 
*name)
dev_err(dev->dev, "devstate: registration failed\n");
goto err;
}
+   f = debugfs_create_bool("allow_fixed_address", S_IROTH | S_IWOTH, dir,
+   &dev->allow_fixed_address);
+   if (!f) {
+   dev_err(dev->dev, "allow_fixed_address: registration failed\n");
+   goto err;
+   }
dev->dbgfs_dir = dir;
return 0;
 err:
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index dcaa7658e742..ca128e2aaf10 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -216,6 +216,11 @@ static ssize_t mei_read(struct file *file, char __user 
*ubuf,
 
cb = mei_cl_read_cb(cl, file);
if (!cb) {
+   if (mei_cl_is_fixed_address(cl) && dev->allow_fixed_address) {
+   cb = mei_cl_read_cb(cl, NULL);
+   if (cb)
+   goto copy_buffer;
+   }
rets = 0;
goto out;
}
@@ -390,7 +395,8 @@ static int mei_ioctl_connect_client(struct file *file,
 
/* find ME client we're trying to connect to */
me_cl = mei_me_cl_by_uuid(dev, &data->in_client_uuid);
-   if (!me_cl || me_cl->props.fixed_address) {
+   if (!me_cl ||
+   (me_cl->props.fixed_address && !dev->allow_fixed_address)) {
dev_dbg(dev->dev, "Cannot connect to FW Client UUID = %pUl\n",
&data->in_client_uuid);
mei_me_cl_put(me_cl);
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index f17979c680a9..6cbcb11a6974 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -475,6 +475,8 @@ const char *mei_pg_state_str(enum mei_pg_state state);
  * @host_clients_map : host clients id pool
  * @me_client_index : last FW client index in enumeration
  *
+ * @allow_fixed_address: allow user space to connect a fixed client
+ *
  * @wd_cl   : watchdog client
  * @wd_state: watchdog client state
  * @wd_pending  : watchdog command is pending
@@ -566,6 +568,8 @@ struct mei_device {
DECLARE_BITMAP(host_clients_map, MEI_CLIENTS_MAX);
unsigned long me_client_index;
 
+   u32 allow_fixed_address;
+
struct mei_cl wd_cl;
enum mei_wd_states wd_state;
bool wd_pending;
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[char-misc-next 8/8 RESEND] mei: txe: fix incorrect indentation

2015-04-05 Thread Tomas Winkler
Remove spurious blank

Signed-off-by: Tomas Winkler 
---
 drivers/misc/mei/pci-txe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/mei/pci-txe.c b/drivers/misc/mei/pci-txe.c
index dcfcba44b6f7..0882c0201907 100644
--- a/drivers/misc/mei/pci-txe.c
+++ b/drivers/misc/mei/pci-txe.c
@@ -338,7 +338,7 @@ static int mei_txe_pm_runtime_suspend(struct device *device)
 * However if device is not wakeable we do not enter
 * D-low state and we need to keep the interrupt kicking
 */
-if (!ret && pci_dev_run_wake(pdev))
+   if (!ret && pci_dev_run_wake(pdev))
mei_disable_interrupts(dev);
 
dev_dbg(&pdev->dev, "rpm: txe: runtime suspend ret=%d\n", ret);
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[char-misc-next 7/8 RESEND] mei: drop iamthif_mtu from device structure

2015-04-05 Thread Tomas Winkler
From: Alexander Usyskin 

We can receive mtu with one call now, no need to store it.

Signed-off-by: Alexander Usyskin 
Signed-off-by: Tomas Winkler 
---
 drivers/misc/mei/amthif.c  | 9 +
 drivers/misc/mei/mei_dev.h | 2 --
 2 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index a0209f02a31a..fd49c8b0fb8a 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -73,12 +73,6 @@ int mei_amthif_host_init(struct mei_device *dev, struct 
mei_me_client *me_cl)
 
mei_cl_init(cl, dev);
 
-   /* Assign iamthif_mtu to the value received from ME  */
-
-   dev->iamthif_mtu = me_cl->props.max_msg_length;
-   dev_dbg(dev->dev, "IAMTHIF_MTU = %d\n", dev->iamthif_mtu);
-
-
ret = mei_cl_link(cl, MEI_IAMTHIF_HOST_CLIENT_ID);
if (ret < 0) {
dev_err(dev->dev, "amthif: failed cl_link %d\n", ret);
@@ -240,7 +234,6 @@ static int mei_amthif_read_start(struct mei_cl *cl, struct 
file *file)
 {
struct mei_device *dev = cl->dev;
struct mei_cl_cb *cb;
-   size_t length = dev->iamthif_mtu;
int rets;
 
cb = mei_io_cb_init(cl, MEI_FOP_READ, file);
@@ -249,7 +242,7 @@ static int mei_amthif_read_start(struct mei_cl *cl, struct 
file *file)
goto err;
}
 
-   rets = mei_io_cb_alloc_buf(cb, length);
+   rets = mei_io_cb_alloc_buf(cb, mei_cl_mtu(cl));
if (rets)
goto err;
 
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 6cbcb11a6974..5184758643fc 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -489,7 +489,6 @@ const char *mei_pg_state_str(enum mei_pg_state state);
  * @iamthif_cl  : amthif host client
  * @iamthif_current_cb : amthif current operation callback
  * @iamthif_open_count : number of opened amthif connections
- * @iamthif_mtu : amthif client max message length
  * @iamthif_timer : time stamp of current amthif command completion
  * @iamthif_stall_timer : timer to detect amthif hang
  * @iamthif_state : amthif processor state
@@ -585,7 +584,6 @@ struct mei_device {
struct mei_cl iamthif_cl;
struct mei_cl_cb *iamthif_current_cb;
long iamthif_open_count;
-   int iamthif_mtu;
unsigned long iamthif_timer;
u32 iamthif_stall_timer;
enum iamthif_states iamthif_state;
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC PATCH 0/5] Remove rw parameter from direct_IO()

2015-04-05 Thread Al Viro
On Mon, Mar 16, 2015 at 04:33:48AM -0700, Omar Sandoval wrote:
> Hi,
> 
> Al, here's some cleanup that you mentioned back in December that I got
> around to (https://lkml.org/lkml/2014/12/15/28).

Applied.  See #for-next
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/6] block: loop: don't hold lo_ctl_mutex in lo_open

2015-04-05 Thread Ming Lei
On Sun, Apr 5, 2015 at 3:24 PM, Ming Lei  wrote:
> The lo_ctl_mutex is held for running all ioctl handlers, and
> in some ioctl handlers, ioctl_by_bdev(BLKRRPART) is called for
> rereading partitions, which requires bd_mutex.
>
> So it is easy to cause failure because trylock(bd_mutex) may
> fail inside blkdev_reread_part(), and follows the lock context:
>
> blkid or other application:
> ->open()
> ->mutex_lock(bd_mutex)
> ->lo_open()
> ->mutex_lock(lo_ctl_mutex)
>
> losetup(set fd ioctl):
> ->mutex_lock(lo_ctl_mutex)
> ->ioctl_by_bdev(BLKRRPART)
> ->trylock(bd_mutex)
>
> This patch trys to eliminate the ABBA lock dependency by removing
> lo_ctl_mutext in lo_open() with the following approach:
>
> 1) introduce lo_open_mutex to protect lo_refcnt and avoid acquiring
> lo_ctl_mutex in lo_open():
> - for open vs. add/del loop, no any problem because of 
> loop_index_mutex
> - lo_open_mutex is used for syncing open() and loop_clr_fd()
> - both open() and release() have been serialized by bd_mutex already
>
> 2) don't hold lo_ctl_mutex for decreasing/checking lo_refcnt in
> lo_release(), then lo_ctl_mutex is only required for the last release.

Another simpler way is to make lo_refcnt as atomic_t and remove
lo_ctrl_mutext in lo_open(), and freeze request queue during clearing
fd, and better to freeze queue during setting fd too, so will update in
v1 with this way.

Thanks,
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] block: export blkdev_reread_part()

2015-04-05 Thread Christoph Hellwig
> +/*
> + * This is exported as API for block driver, can be called
> + * with requiring bd_mutex or not.
> + */
> +int __blkdev_reread_part(struct block_device *bdev, bool lock)
>  {
>   struct gendisk *disk = bdev->bd_disk;
>   int res;
> @@ -159,12 +163,14 @@ static int blkdev_reread_part(struct block_device *bdev)
>   return -EINVAL;
>   if (!capable(CAP_SYS_ADMIN))
>   return -EACCES;
> - if (!mutex_trylock(&bdev->bd_mutex))
> + if (lock && !mutex_trylock(&bdev->bd_mutex))
>   return -EBUSY;

Please don't add funtions that do conditional locking, instead move
all the code into blkdev_reread_part_nolock, and then wrap it:

int blkdev_reread_part(struct block_device *bdev)
{
if (!mutex_trylock(&bdev->bd_mutex))
return -EBUSY;
blkdev_reread_part_nolock(bdev);
mutex_unlock(&bdev->bd_mutex);
}

Please also add a lockdep_assert_held to blkdev_reread_part_nolock to
ensure callers actually do hold the lock.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 07/11] ARM: allow MULTIPLATFORM with !MMU

2015-04-05 Thread Russell King - ARM Linux
On Sat, Apr 04, 2015 at 01:56:20AM +0200, Stefan Agner wrote:
> On 2015-04-03 22:09, Russell King - ARM Linux wrote:
> > On Fri, Apr 03, 2015 at 09:44:48PM +0200, Stefan Agner wrote:
> >> In order to support SoC with heterogenous CPU architectures (such
> >> as Freescale Vybrid/i.MXSX) it is preferable to use the same
> >> architecture (ARCH_MXC in this case) for the MMU enabled and !MMU
> >> CPU. Hence allow to select MULTIPLATFORM even without MMU.
> >>
> >> Signed-off-by: Stefan Agner 
> >> ---
> >>  arch/arm/Kconfig | 21 ++---
> >>  1 file changed, 10 insertions(+), 11 deletions(-)
> >>
> >> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> >> index 9f1f09a..636cb3f 100644
> >> --- a/arch/arm/Kconfig
> >> +++ b/arch/arm/Kconfig
> >> @@ -230,7 +230,7 @@ config VECTORS_BASE
> >>  in size.
> >>
> >>  config ARM_PATCH_PHYS_VIRT
> >> -  bool "Patch physical to virtual translations at runtime" if EMBEDDED
> >> +  bool "Patch physical to virtual translations at runtime" if EMBEDDED || 
> >> (ARCH_MULTIPLATFORM && MMU)
> >>default y
> > 
> > This makes no sense.  Multiplatform MMU _requires_ this feature, so why
> > offer it to the user when multiplatform is enabled _and_ MMU is enabled?
> 
> I see, this is plain wrong. Will replace that with a select ... if MMU
> in multiplatform.

I think what I'd like to see is, in the top level choice:

config ARM_SINGLE_ARMV7M
bool "ARM architecture v7M compliant (Cortex-M0/M3/M4) SoC"
depends on !MMU
select ARM_NVIC
... etc ...

which then allows a /multiplatform/ v7M kernel to be built, allowing the
selection of EFM32, SOC_VF610, and any other v7M compliant SoC.

So, it's very similar to multiplatform in the sense that several SoCs
can be built together, but we preserve the need not to build
incompatible stuff together.

Thoughts?

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 00/20] mpt3sas: driver update

2015-04-05 Thread Christoph Hellwig
This seems to be missing the corresponding mpt2 updates.  Nak to
anything that gets these drivers further out of sync.

Btw, I still need a second ACK for
http://www.spinics.net/lists/linux-scsi/msg82027.html
as well, so we can start getting rid of this duplication mess.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [alsa-devel] [PATCH 13/16] ALSA: au1x00: fix error return code

2015-04-05 Thread Takashi Iwai
At Sun,  5 Apr 2015 14:06:33 +0200,
Julia Lawall wrote:
> 
> Return a negative error code on failure.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // 
> @@
> identifier ret; expression e1,e2;
> @@
> (
> if (\(ret < 0\|ret != 0\))
>  { ... return ret; }
> |
> ret = 0
> )
> ... when != ret = e1
> when != &ret
> *if(...)
> {
>   ... when != ret = e2
>   when forall
>  return ret;
> }
> // 
> 
> Signed-off-by: Julia Lawall 

Applied, thanks.


Takashi

> 
> ---
>  sound/mips/au1x00.c |   12 +---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c
> index fbcaa54..1e30e84 100644
> --- a/sound/mips/au1x00.c
> +++ b/sound/mips/au1x00.c
> @@ -633,19 +633,25 @@ static int au1000_ac97_probe(struct platform_device 
> *pdev)
>  
>   au1000->stream[PLAYBACK] = kmalloc(sizeof(struct audio_stream),
>  GFP_KERNEL);
> - if (!au1000->stream[PLAYBACK])
> + if (!au1000->stream[PLAYBACK]) {
> + err = -ENOMEM;
>   goto out;
> + }
>   au1000->stream[PLAYBACK]->dma = -1;
>  
>   au1000->stream[CAPTURE] = kmalloc(sizeof(struct audio_stream),
> GFP_KERNEL);
> - if (!au1000->stream[CAPTURE])
> + if (!au1000->stream[CAPTURE]) {
> + err = -ENOMEM;
>   goto out;
> + }
>   au1000->stream[CAPTURE]->dma = -1;
>  
>   r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (!r)
> + if (!r) {
> + err = -ENODEV;
>   goto out;
> + }
>  
>   err = -EBUSY;
>   au1000->ac97_res_port = request_mem_region(r->start, resource_size(r),
> 
> ___
> Alsa-devel mailing list
> alsa-de...@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 6/7] mpt2sas: store scsi io tracker data in the scsi command / request

2015-04-05 Thread Christoph Hellwig
On Fri, Apr 03, 2015 at 09:58:22AM -0600, Jens Axboe wrote:
> +struct scsiio_tracker *
> +mpt2sas_get_st_from_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid)
> +{
> + if (shost_use_blk_mq(ioc->shost)) {
> + struct scsi_cmnd *scmd;
> +
> + scmd = scsi_mq_find_tag(ioc->shost, smid - 1);
> + if (!scmd)
> + return NULL;
> + return scsi_mq_scmd_to_pdu(scmd);
> + } else
> + return &ioc->scsi_lookup[smid - 1];
> +}

The mq case will also work for the !mq case when you call
scsi_host_find_tag and scsi_cmd_priv.   In general all the mq-specific
codepathes you add should become the default and only one, even if this
requires a lit bit of additional core work.

> @@ -1724,6 +1739,18 @@ mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER 
> *ioc, u8 cb_idx,
>   struct scsiio_tracker *request;
>   u16 smid;
>  
> + if (shost_use_blk_mq(ioc->shost)) {
> + /*
> +  * If we don't have a SCSI command associated with this smid,
> +  * bump it to high-prio
> +  */
> + if (!scmd)
> + return mpt2sas_base_get_smid_hpr(ioc, cb_idx);

Seems like _ctl_do_mpt_command should be changed to just
call mpt2sas_base_get_smid_hpr unconditionally instead of adding this
hack  Preferably as a standalone preparatory patch.


>   unsigned long flags;
>   int i;
> - struct chain_tracker *chain_req, *next;
> +
> + if (shost_use_blk_mq(ioc->shost) && smid < ioc->hi_priority_smid) {
> + struct scsiio_tracker *st;
> +
> + st = mpt2sas_get_st_from_smid(ioc, smid);
> + if (!st)
> + return;
> +
> + st->direct_io = 0;
> +
> + if (!list_empty(&st->chain_list)) {
> + spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
> + _dechain_st(ioc, st);
> + spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
> + }

This whole chain list thing looks bonkers to me.  We always allocated
a fixed multiple of the queue depth in ->chain_lookup, but then do this
required list manipulation at least once per I/O submission and completion.

Seems like we should instead add an array of (cpu address, dma address)
tuples to the scsiio_tracker and avoid all the chain_lookup / chain_list
lookups entirely.

> + if (shost_use_blk_mq(ioc->shost)) {
> + scmd = scsi_mq_find_tag(ioc->shost,  i);
> + if (scsi_mq_scmd_started(scmd))
> + pending++;

Ok, I guess we should move the request_started check into the _find_tag
helpers, as tags that aren't started aren't something that driver
should ever lookup.

> +static bool
> +_scmd_match(struct scsi_cmnd *scmd, u16 handle, u32 lun)
> +{
> + struct MPT2SAS_DEVICE *priv_data;
> +
> + if (scmd == NULL || scmd->device == NULL ||
> + scmd->device->hostdata == NULL)
> + return false;

If the queue is started this can't ever happen.

> + if (lun != scmd->device->lun)
> + return false;

If you pass in a specific scsi_device and thus request_queue  this
can't happen.

> +static u16
> +_ctl_find_smid(struct MPT2SAS_ADAPTER *ioc, u16 handle, u32 lun)
> +{
> + if (shost_use_blk_mq(ioc->shost))
> + return _ctl_find_smid_mq(ioc, handle, lun);
> + else
> + return _ctl_find_smid_legacy(ioc, handle, lun);
> +}

The caller of this looks entirely broken.  It's a driver specific API
to submit task management commands, duplicating the mid level code,
and it doesn't even allow which task to target.  I think we should
just return a error when invoking MPI2_FUNCTION_SCSI_TASK_MGMT instead
of digging us an even deeper grave here.  If someone complains we'll
have to find a way to redirect it to the generic EH ioctls.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


GOOD NEWS

2015-04-05 Thread Karbiru Ahmed
Dear Friend,

I'm happy to inform you about my success in getting the fund
transferred under the cooperation of a new partner from London.
Presently I'm in London for investment projects with my own share of
the total sum. Meanwhile, I didn't forget your past efforts
andattempts to assist me in transferring those funds despite that it
failed us some how.

Now contact my secretary, his name is John Smith and his Email Address
secretary email:( johnsimth...@gmail.com )ask him to send you the
total $7,000.000.00 which i kept for your compensation for all the
past efforts and attempts to assist me in this matter. I appreciated
your efforts at that time very much. so feel free and get in touched
with my secretary Mr John Smith and instruct him where to send the
amount to you.

Please do let me know immediately you receive it so that we can share
the joy after all the sufferness at that time. In the moment, i am
very busy here because of the investment projects which me and the new
partner are having at hand, finally, remember that I had forwarded
instruction to the secretary on your behalf to receive that money, so
feel free to get in touch with Mr John Smith and he will send the
amount to you without any delay.

With best regards
Mr Karbiru Ahmed
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/7] scsi: add host template init/exit_command hooks

2015-04-05 Thread Christoph Hellwig
On Fri, Apr 03, 2015 at 09:58:21AM -0600, Jens Axboe wrote:
> If a LLD has hardware commands in the request pdu, then we need some
> helper hooks to help the driver initialize state at load time, and
> potentially to tear down state at rmmod time. Add a host template
> ->init_command() and ->exit_command() hook to help with that.
> 
> Signed-off-by: Jens Axboe 

Looks good in general, but please ensure these callsbacks also get invoked
in the !mq case.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/7] scsi: add scsi-mq helpers to retrieve pdu and check started state

2015-04-05 Thread Christoph Hellwig
On Fri, Apr 03, 2015 at 09:58:19AM -0600, Jens Axboe wrote:
> +static inline void *scsi_mq_scmd_to_pdu(struct scsi_cmnd *scmd)
> +{
> + return blk_mq_rq_to_pdu(scmd->request) + sizeof(*scmd);
> +}

We've already got scsi_cmd_priv to cover this.

> +static inline bool scsi_mq_scmd_started(struct scsi_cmnd *scmd)
> +{
> + return blk_mq_request_started(scmd->request);
> +}

I don't really think we want to expose this functionality, but more
on that in my reply to the mpt2 patch.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   >