Re: [PATCH v4 3/3] powerpc/powernv: Introduce sysfs control for fastsleep workaround behavior

2015-04-14 Thread Preeti U Murthy
Hi Shreyas,

On 04/14/2015 07:26 AM, Shreyas B. Prabhu wrote:
 Fastsleep is one of the idle state which cpuidle subsystem currently
 uses on power8 machines. In this state L2 cache is brought down to a
 threshold voltage. Therefore when the core is in fastsleep, the
 communication between L2 and L3 needs to be fenced. But there is a bug
 in the current power8 chips surrounding this fencing.
 
 OPAL provides a workaround which precludes the possibility of hitting
 this bug. But running with this workaround applied causes checkstop
 if any correctable error in L2 cache directory is detected. Hence OPAL
 also provides a way to undo the workaround.
 
 In the existing implementation, workaround is applied by the last thread
 of the core entering fastsleep and undone by the first thread waking up.
 But this has a performance cost. These OPAL calls account for roughly
 4000 cycles everytime the core has to enter or wakeup from fastsleep.
 
 This patch introduces a sysfs attribute (fastsleep_workaround_state)
 to choose the behavior of this workaround.
 
 By default, fastsleep_workaround_state = dynamic. In this case, workaround
 is applied/undone everytime the core enters/exits fastsleep.
 
 fastsleep_workaround_state = applyonce. In this case the workaround is
 applied once on all the cores and never undone. This can be triggered by
 echo applyonce  /sys/devices/system/cpu/fastsleep_workaround_state

I was wondering if we really need such an elaborate design for this
sysfs file. Why not a sysfs file called fastsleep_workaround_apply_once,
which is set to '0' by default and the only value that it can take is
'1' ? The name easily implies that the workaround is applied only once
if it is set. I can see that this can cut down a good chunk of code from
this patch. I just didn't find too much value in having so much code for
a simple 'on' knob.

Regards
Preeti U Murthy

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v9 06/11] powerpc/perf: Implement get_cpu_str()

2015-04-14 Thread Sukadev Bhattiprolu
With a file ~/.cache/pmu-events/004d0100-core.json describing Power8
PMU events we would need to run:

perf stat \
--events-file ~/.cache/pmu-events/004d0100-core.json \
-e pm_cyc sleep 1

With this get_cpu_str(), on Powerpc, we can skip the --events-file option
and run:

perf stat -e pm_cyc sleep 1

Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
---
Changelog[v9] by Sukadev Bhattiprolu
Rebase to 4.0.

Changelog[v3]:
[Tobias Klauser]: Fix some changelog damage to patch.

Changelog[v2]:
[Michael Ellerman]: Use PVR instead of AUXV variables
---
 tools/perf/arch/powerpc/util/header.c |   12 
 1 file changed, 12 insertions(+)

diff --git a/tools/perf/arch/powerpc/util/header.c 
b/tools/perf/arch/powerpc/util/header.c
index 6c1b8a7..306bf35 100644
--- a/tools/perf/arch/powerpc/util/header.c
+++ b/tools/perf/arch/powerpc/util/header.c
@@ -6,6 +6,7 @@
 
 #include ../../util/header.h
 #include ../../util/util.h
+#include ../../util/jevents.h
 
 #define mfspr(rn)   ({unsigned long rval; \
 asm volatile(mfspr %0, __stringify(rn) \
@@ -32,3 +33,14 @@ get_cpuid(char *buffer, size_t sz)
}
return -1;
 }
+
+char *
+get_cpu_str(void)
+{
+   char *bufp;
+
+   if (asprintf(bufp, %.8lx-core, mfspr(SPRN_PVR))  0)
+   bufp = NULL;
+
+   return bufp;
+}
-- 
1.7.9.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v9 11/11] perf-download: Download the events json file

2015-04-14 Thread Sukadev Bhattiprolu
Add a downloader to automatically download the right files from a
download site.

This is implemented as a script calling curl, similar to perf archive.
The perf driver automatically calls the right binary. The downloader is
extensible, but currently only implements an Intel and Powerpc event
download.  It would be straightforward to add support for other architectures.

For now, there could be slight variations in how individual architectures
organize the JSON files. Eg. Powerpc has a simple mapping from its PVR
to cpu family eg power8's events file, which x86 uses, CPU vendor, family
model to locate the specific file to download.

The downloaded event files are put into ~/.cache/pmu-events, where the
builtin event parser in util/* can find them automatically.

Signed-off-by: Andi Kleen a...@linux.intel.com
Link: 
http://lkml.kernel.org/n/1405123165-22666-8-git-send-email-a...@firstfloor.org
Signed-off-by: Jiri Olsa jo...@kernel.org
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com

Changelog[v9] (by Sukadev Bhattiprolu)
Add the perf-download script back into patchset. Set default
download location to the tools/perf/pmu-events/ directory in
Linus's tree.
Include code to parse/download powerpc JSON files.
Remove Acked-by: Namhyung Kim since this patch has major changes
---
 tools/perf/Documentation/perf-download.txt |   31 +
 tools/perf/Documentation/perf-list.txt |   12 +-
 tools/perf/Makefile.perf   |5 +-
 tools/perf/perf-download.sh|  171 
 4 files changed, 217 insertions(+), 2 deletions(-)
 create mode 100644 tools/perf/Documentation/perf-download.txt
 create mode 100755 tools/perf/perf-download.sh

diff --git a/tools/perf/Documentation/perf-download.txt 
b/tools/perf/Documentation/perf-download.txt
new file mode 100644
index 000..9e5b28e
--- /dev/null
+++ b/tools/perf/Documentation/perf-download.txt
@@ -0,0 +1,31 @@
+perf-download(1)
+===
+
+NAME
+
+perf-download - Download event files for current CPU.
+
+SYNOPSIS
+
+[verse]
+'perf download' [vendor-family-model]
+
+DESCRIPTION
+---
+This command automatically downloads the event list for the current CPU and
+stores them in $XDG_CACHE_HOME/pmu-events (or $HOME/.cache/pmu-events).
+The other tools automatically look for them there. The CPU can be also
+specified at the command line.
+
+The downloading is done using http through wget, which needs
+to be installed. When behind a firewall the proxies
+may also need to be set up using export https_proxy=
+
+The user should regularly call this to download updated event lists
+for the current CPU.
+
+Note the downloaded files are stored per user, so if perf is
+used as both normal user and with sudo the event files may
+also need to be moved to root's home directory with
+sudo mkdir /root/.cache ; sud cp -r ~/.cache/pmu-events /root/.cache
+after downloading.
diff --git a/tools/perf/Documentation/perf-list.txt 
b/tools/perf/Documentation/perf-list.txt
index 7479efe..98637e8 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -66,6 +66,16 @@ Sampling). Examples to use IBS:
  perf record -a -e r076:p ...  # same as -e cpu-cycles:p
  perf record -a -e r0C1:p ...  # use ibs op counting micro-ops
 
+PER CPU EVENT LISTS
+---
+
+For some CPUs (particularly modern Intel CPUs) perf download can
+download additional CPU specific event definitions, which then
+become visible in perf list and available in the other perf tools.
+
+This obsoletes the raw event description method described below
+for most cases.
+
 RAW HARDWARE EVENT DESCRIPTOR
 -
 Even when an event is not available in a symbolic form within perf right now,
@@ -141,6 +151,6 @@ types specified.
 SEE ALSO
 
 linkperf:perf-stat[1], linkperf:perf-top[1],
-linkperf:perf-record[1],
+linkperf:perf-record[1], linkperf:perf-download[1],
 http://www.intel.com/Assets/PDF/manual/253669.pdf[Intel® 64 and IA-32 
Architectures Software Developer's Manual Volume 3B: System Programming Guide],
 http://support.amd.com/us/Processor_TechDocs/24593_APM_v2.pdf[AMD64 
Architecture Programmer’s Manual Volume 2: System Programming]
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index d9c03c4..9f955b1 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -136,6 +136,7 @@ SCRIPT_SH =
 
 SCRIPT_SH += perf-archive.sh
 SCRIPT_SH += perf-with-kcore.sh
+SCRIPT_SH += perf-download.sh
 
 grep-libs = $(filter -l%,$(1))
 strip-libs = $(filter-out -l%,$(1))
@@ -946,6 +947,8 @@ endif
$(INSTALL) $(OUTPUT)perf-archive -t 
'$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
$(call QUIET_INSTALL, perf-with-kcore) \
$(INSTALL) $(OUTPUT)perf-with-kcore -t 
'$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
+   $(call QUIET_INSTALL, perf-download) \
+   

[PATCH v9 03/11] perf, tools, list: Update perf list to output descriptions

2015-04-14 Thread Sukadev Bhattiprolu
From: Andi Kleen a...@linux.intel.com

Add support to perf list to print aliases with descriptions.
Support word wrapping for descriptions.
Fix up the sorting code to put aliases with descriptions
last.

Signed-off-by: Andi Kleen a...@linux.intel.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
---

Changelov[v9] by Sukadev Bhattiprolu
Rebase to 4.0 and fix conflicts in tools/perf/util/pmu.c
---
 tools/perf/util/pmu.c |   86 -
 1 file changed, 70 insertions(+), 16 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 527da74..623b107 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -877,11 +877,51 @@ static char *format_alias_or(char *buf, int len, struct 
perf_pmu *pmu,
return buf;
 }
 
-static int cmp_string(const void *a, const void *b)
+struct pair {
+   char *name;
+   char *desc;
+};
+
+static int cmp_pair(const void *a, const void *b)
 {
-   const char * const *as = a;
-   const char * const *bs = b;
-   return strcmp(*as, *bs);
+   const struct pair *as = a;
+   const struct pair *bs = b;
+
+   /* Put downloaded event list last */
+   if (!!as-desc != !!bs-desc)
+   return !!as-desc - !!bs-desc;
+   return strcmp(as-name, bs-name);
+}
+
+static void wordwrap(char *s, int start, int max, int corr)
+{
+   int column = start;
+   int n;
+
+   while (*s) {
+   int wlen = strcspn(s,  \t);
+
+   if (column + wlen = max  column  start) {
+   printf(\n%*s, start, );
+   column = start + corr;
+   }
+   n = printf(%s%.*s, column  start ?   : , wlen, s);
+   if (n = 0)
+   break;
+   s += wlen;
+   column += n;
+   while (isspace(*s))
+   s++;
+   }
+}
+
+static int get_columns(void)
+{
+   /*
+* Should ask the terminal with TIOCGWINSZ here, but we
+* need the original fd before the pager.
+*/
+   return 79;
 }
 
 void print_pmu_events(const char *event_glob, bool name_only)
@@ -891,7 +931,9 @@ void print_pmu_events(const char *event_glob, bool 
name_only)
char buf[1024];
int printed = 0;
int len, j;
-   char **aliases;
+   struct pair *aliases;
+   int numdesc = 0;
+   int columns = get_columns();
 
pmu = NULL;
len = 0;
@@ -901,14 +943,15 @@ void print_pmu_events(const char *event_glob, bool 
name_only)
if (pmu-selectable)
len++;
}
-   aliases = zalloc(sizeof(char *) * len);
+   aliases = zalloc(sizeof(struct pair) * len);
if (!aliases)
goto out_enomem;
pmu = NULL;
j = 0;
while ((pmu = perf_pmu__scan(pmu)) != NULL) {
list_for_each_entry(alias, pmu-aliases, list) {
-   char *name = format_alias(buf, sizeof(buf), pmu, alias);
+   char *name = alias-desc ? alias-name :
+   format_alias(buf, sizeof(buf), pmu, alias);
bool is_cpu = !strcmp(pmu-name, cpu);
 
if (event_glob != NULL 
@@ -917,11 +960,14 @@ void print_pmu_events(const char *event_glob, bool 
name_only)
   event_glob
continue;
 
-   if (is_cpu  !name_only)
-   name = format_alias_or(buf, sizeof(buf), pmu, 
alias);
+   aliases[j].name = name;
+   if (is_cpu  !name_only  !alias-desc)
+   aliases[j].name = format_alias_or(buf,
+   sizeof(buf), pmu, alias);
 
-   aliases[j] = strdup(name);
-   if (aliases[j] == NULL)
+   aliases[j].name = strdup(aliases[j].name);
+   aliases[j].desc = alias-desc;
+   if (aliases[j].name == NULL)
goto out_enomem;
j++;
}
@@ -929,25 +975,33 @@ void print_pmu_events(const char *event_glob, bool 
name_only)
char *s;
if (asprintf(s, %s//, pmu-name)  0)
goto out_enomem;
-   aliases[j] = s;
+   aliases[j].name = s;
j++;
}
}
len = j;
-   qsort(aliases, len, sizeof(char *), cmp_string);
+   qsort(aliases, len, sizeof(struct pair), cmp_pair);
for (j = 0; j  len; j++) {
if (name_only) {
-   printf(%s , aliases[j]);
+   printf(%s , aliases[j].name);
continue;
}

[PATCH v9 08/11] perf, tools: Add a new pmu interface to iterate over all events

2015-04-14 Thread Sukadev Bhattiprolu
From: Andi Kleen a...@linux.intel.com

With calling a callback. To be used in test code added in the next
patch.

Signed-off-by: Andi Kleen a...@linux.intel.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
---
Changelog[v9] by Sukadev Bhattiprolu
Rebase to 4.0 and fix conflicts in:
tools/perf/util/pmu.c
tools/perf/util/pmu.h
---
 tools/perf/util/pmu.c |   18 ++
 tools/perf/util/pmu.h |1 +
 2 files changed, 19 insertions(+)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 2150455..82f7654 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -1068,3 +1068,21 @@ int perf_pmu__scan_file(struct perf_pmu *pmu, const char 
*name, const char *fmt,
va_end(args);
return ret;
 }
+
+int pmu_iterate_events(int (*func)(const char *pmu, const char *name))
+{
+   int ret = 0;
+   struct perf_pmu *pmu;
+   struct perf_pmu_alias *alias;
+
+   perf_pmu__find(cpu); /* Load PMUs */
+   pmu = NULL;
+   while ((pmu = perf_pmu__scan(pmu)) != NULL) {
+   list_for_each_entry(alias, pmu-aliases, list) {
+   ret = func(pmu-name, alias-name);
+   if (ret != 0)
+   break;
+   }
+   }
+   return ret;
+}
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index f8dac0f..889cadf 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -76,6 +76,7 @@ int perf_pmu__scan_file(struct perf_pmu *pmu, const char 
*name, const char *fmt,
 int perf_pmu__test(void);
 
 struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu);
+int pmu_iterate_events(int (*func)(const char *, const char *name));
 
 extern const char *json_file;
 #endif /* __PMU_H */
-- 
1.7.9.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v9 10/11] perf, tools: Add a --no-desc flag to perf list

2015-04-14 Thread Sukadev Bhattiprolu
From: Andi Kleen a...@linux.intel.com

Add a --no-desc flag to perf list to not print the event descriptions
that were earlier added for JSON events. This may be useful to
get a less crowded listing.

It's still default to print descriptions as that is the more useful
default for most users.

Before:

% perf list
...
  baclears.any   [Counts the total number 
when the front end is
  resteered, mainly when 
the BPU cannot provide a
  correct prediction and 
this is corrected by other
  branch handling 
mechanisms at the front end]
  br_inst_exec.all_branches  [Speculative and retired 
branches]

After:

% perf list --no-desc
...
  baclears.any   [Kernel PMU event]
  br_inst_exec.all_branches  [Kernel PMU event]

Signed-off-by: Andi Kleen a...@linux.intel.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
---
Changelog[v9] by Sukadev Bhattiprolu
Rebase to 4.0 and fix conflicts in
tools/perf/builtin-list.c
v2: Rename --quiet to --no-desc. Add option to man page.
---
 tools/perf/Documentation/perf-list.txt |5 -
 tools/perf/builtin-list.c  |   16 +++-
 tools/perf/util/parse-events.c |4 ++--
 tools/perf/util/parse-events.h |2 +-
 tools/perf/util/pmu.c  |4 ++--
 tools/perf/util/pmu.h  |2 +-
 6 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/tools/perf/Documentation/perf-list.txt 
b/tools/perf/Documentation/perf-list.txt
index 205ac40..7479efe 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -8,7 +8,7 @@ perf-list - List all symbolic event types
 SYNOPSIS
 
 [verse]
-'perf list' [hw|sw|cache|tracepoint|pmu|event_glob]
+'perf list' [--no-desc] [hw|sw|cache|tracepoint|pmu|event_glob]
 
 DESCRIPTION
 ---
@@ -23,6 +23,9 @@ automatically downloaded with perf download.
 The JSON event file can be also specified with the EVENTMAP environment
 variable.
 
+--no-desc::
+Don't print descriptions.
+
 
 [[EVENT_MODIFIERS]] EVENT MODIFIERS
 ---
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index fd07cc1..76dc23b 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -16,6 +16,8 @@
 #include util/pmu.h
 #include util/parse-options.h
 
+static bool desc_flag = true;
+
 int cmd_list(int argc, const char **argv, const char *prefix __maybe_unused)
 {
int i;
@@ -24,10 +26,12 @@ int cmd_list(int argc, const char **argv, const char 
*prefix __maybe_unused)
OPT_BOOLEAN(0, raw-dump, raw_dump, Dump raw events),
OPT_STRING(0, events-file, json_file, json file,
   Read event json file),
+   OPT_BOOLEAN('d', desc, desc_flag,
+   Print extra event descriptions. --no-desc to not 
print.),
OPT_END()
};
const char * const list_usage[] = {
-   perf list [hw|sw|cache|tracepoint|pmu|event_glob],
+   perf list [--events-file FILE] [--no-desc] 
[hw|sw|cache|tracepoint|pmu|event_glob],
NULL
};
 
@@ -39,12 +43,12 @@ int cmd_list(int argc, const char **argv, const char 
*prefix __maybe_unused)
setup_pager();
 
if (raw_dump) {
-   print_events(NULL, true);
+   print_events(NULL, true, !desc_flag);
return 0;
}
 
if (argc == 0) {
-   print_events(NULL, false);
+   print_events(NULL, false, !desc_flag);
return 0;
}
 
@@ -63,13 +67,15 @@ int cmd_list(int argc, const char **argv, const char 
*prefix __maybe_unused)
 strcmp(argv[i], hwcache) == 0)
print_hwcache_events(NULL, false);
else if (strcmp(argv[i], pmu) == 0)
-   print_pmu_events(NULL, false);
+   print_pmu_events(NULL, false, !desc_flag);
+   else if (strcmp(argv[i], --raw-dump) == 0)
+   print_events(NULL, true, !desc_flag);
else {
char *sep = strchr(argv[i], ':'), *s;
int sep_idx;
 
if (sep == NULL) {
-   print_events(argv[i], false);
+   print_events(argv[i], false, !desc_flag);
continue;
}
sep_idx = sep - argv[i];
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 7f8ec6c..039ba78 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1336,7 +1336,7 @@ 

[PATCH v9 02/11] perf, tools: Add support for text descriptions of events and alias add

2015-04-14 Thread Sukadev Bhattiprolu
From: Andi Kleen a...@linux.intel.com

Change pmu.c to allow descriptions of events and add interfaces
to add aliases at runtime from another file. To be used by jevents in
a followon patch

Acked-by: Namhyung Kim namhy...@kernel.org
Signed-off-by: Andi Kleen a...@linux.intel.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
---
Changelog[v9] by Sukadev Bhattiprolu
Rebase to 4.0
v2: Move perf list changes to other patch.
---
 tools/perf/util/json.c |1 +
 tools/perf/util/pmu.c  |   48 +---
 tools/perf/util/pmu.h  |1 +
 3 files changed, 35 insertions(+), 15 deletions(-)

diff --git a/tools/perf/util/json.c b/tools/perf/util/json.c
index e20001f..2219844 100644
--- a/tools/perf/util/json.c
+++ b/tools/perf/util/json.c
@@ -38,6 +38,7 @@
 #include jsmn.h
 #include json.h
 #include linux/kernel.h
+#include debug.h
 
 static char *mapfile(const char *fn, size_t *size)
 {
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 4841167..527da74 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -198,17 +198,12 @@ static int perf_pmu__parse_snapshot(struct perf_pmu_alias 
*alias,
return 0;
 }
 
-static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, 
FILE *file)
+static int __perf_pmu__new_alias(struct list_head *list, char *name, char *dir,
+   char *desc, char *val)
 {
struct perf_pmu_alias *alias;
-   char buf[256];
int ret;
 
-   ret = fread(buf, 1, sizeof(buf), file);
-   if (ret == 0)
-   return -EINVAL;
-   buf[ret] = 0;
-
alias = malloc(sizeof(*alias));
if (!alias)
return -ENOMEM;
@@ -218,26 +213,49 @@ static int perf_pmu__new_alias(struct list_head *list, 
char *dir, char *name, FI
alias-unit[0] = '\0';
alias-per_pkg = false;
 
-   ret = parse_events_terms(alias-terms, buf);
+   ret = parse_events_terms(alias-terms, val);
if (ret) {
+   pr_err(Cannot parse alias %s: %d\n, val, ret);
free(alias);
return ret;
}
 
alias-name = strdup(name);
-   /*
-* load unit name and scale if available
-*/
-   perf_pmu__parse_unit(alias, dir, name);
-   perf_pmu__parse_scale(alias, dir, name);
-   perf_pmu__parse_per_pkg(alias, dir, name);
-   perf_pmu__parse_snapshot(alias, dir, name);
+
+   if (dir) {
+   /*
+* load unit name and scale if available
+*/
+   perf_pmu__parse_unit(alias, dir, name);
+   perf_pmu__parse_scale(alias, dir, name);
+   perf_pmu__parse_per_pkg(alias, dir, name);
+   perf_pmu__parse_snapshot(alias, dir, name);
+   }
+
+   alias-desc = desc ? strdup(desc) : NULL;
 
list_add_tail(alias-list, list);
 
return 0;
 }
 
+static int perf_pmu__new_alias(struct list_head *list,
+   char *dir,
+   char *name,
+   FILE *file)
+{
+   char buf[256];
+   int ret;
+
+   ret = fread(buf, 1, sizeof(buf), file);
+   if (ret == 0)
+   return -EINVAL;
+   buf[ret] = 0;
+
+   return __perf_pmu__new_alias(list, name, dir, NULL, buf);
+}
+
+
 static inline bool pmu_alias_info_file(char *name)
 {
size_t len;
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 6b1249f..d06496d 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -37,6 +37,7 @@ struct perf_pmu_info {
 
 struct perf_pmu_alias {
char *name;
+   char *desc;
struct list_head terms; /* HEAD struct parse_events_term - list */
struct list_head list;  /* ELEM */
char unit[UNIT_MAX_LEN+1];
-- 
1.7.9.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v9 09/11] perf, tools, test: Add test case for alias and JSON parsing

2015-04-14 Thread Sukadev Bhattiprolu
From: Andi Kleen a...@linux.intel.com

Add a simple test case to perf test that parses all the available
events, including json events.

This needs adding an all event iterator to pmu.c

Acked-by: Namhyung Kim namhy...@kernel.org
Signed-off-by: Andi Kleen a...@linux.intel.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
---
Changelog[v9] by Sukadev Bhattiprolu
Rebase to 4.0 and fix conflicts in:
tools/perf/tests/builtin-test.c
tools/perf/tests/tests.h
Changelog:
v2: Rename identifiers
v3: Only iterate cpu pmu to avoid bogus errors.
Move pmu iterator to extra patch
v4: Include aliases.c again
v5: Include util/debug.h
---
 tools/perf/Makefile.perf|1 +
 tools/perf/tests/aliases.c  |   59 +++
 tools/perf/tests/builtin-test.c |4 +++
 tools/perf/tests/tests.h|1 +
 4 files changed, 65 insertions(+)
 create mode 100644 tools/perf/tests/aliases.c

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index d9c1a4c..d9c03c4 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -456,6 +456,7 @@ endif
 LIB_OBJS += $(OUTPUT)tests/code-reading.o
 LIB_OBJS += $(OUTPUT)tests/sample-parsing.o
 LIB_OBJS += $(OUTPUT)tests/parse-no-sample-id-all.o
+LIB_OBJS += $(OUTPUT)tests/aliases.o
 ifndef NO_DWARF_UNWIND
 ifeq ($(ARCH),$(filter $(ARCH),x86 arm))
 LIB_OBJS += $(OUTPUT)tests/dwarf-unwind.o
diff --git a/tools/perf/tests/aliases.c b/tools/perf/tests/aliases.c
new file mode 100644
index 000..4209e51
--- /dev/null
+++ b/tools/perf/tests/aliases.c
@@ -0,0 +1,59 @@
+/* Check if we can set up all aliases and can read JSON files */
+#include stdlib.h
+#include tests.h
+#include pmu.h
+#include evlist.h
+#include parse-events.h
+#include util/debug.h
+
+static struct perf_evlist *evlist;
+
+static int num_events;
+static int failed;
+
+static int test__event(const char *pmu, const char *name)
+{
+   int ret;
+
+   /* Not supported for now */
+   if (strcmp(pmu, cpu))
+   return 0;
+
+   ret = parse_events(evlist, name);
+
+   if (ret) {
+   /*
+* We only print on failure because common perf setups
+* have events that cannot be parsed.
+*/
+   fprintf(stderr, invalid or unsupported event: '%s'\n, name);
+   ret = 0;
+   failed++;
+   } else
+   num_events++;
+   return ret;
+}
+
+int test__aliases(void)
+{
+   int err;
+
+   /* Download JSON files */
+   /* XXX assumes perf is installed */
+   /* For now user must manually download */
+   if (0  system(perf download  /dev/null)  0) {
+   /* Don't error out for this for now */
+   fprintf(stderr, perf download failed\n);
+   }
+
+   evlist = perf_evlist__new();
+   if (evlist == NULL)
+   return -ENOMEM;
+
+   err = pmu_iterate_events(test__event);
+   fprintf(stderr,  Parsed %d events :, num_events);
+   if (failed  0)
+   pr_debug( %d events failed, failed);
+   perf_evlist__delete(evlist);
+   return err;
+}
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 4b7d9ab..2324b1c 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -167,6 +167,10 @@ static struct test {
.func = test__fdarray__add,
},
{
+   .desc = Test parsing JSON aliases,
+   .func = test__aliases,
+   },
+   {
.func = NULL,
},
 };
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 00e776a..ddce231 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -51,6 +51,7 @@ int test__hists_cumulate(void);
 int test__switch_tracking(void);
 int test__fdarray__filter(void);
 int test__fdarray__add(void);
+int test__aliases(void);
 
 #if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
-- 
1.7.9.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 2/2] powerpc/cell: Fix iommu breakage caused by controller_ops change

2015-04-14 Thread Michael Ellerman
The recent patch to convert cell to use pci_controller_ops had a small
bug which broke machines using an iommu.

The set of phb-controller_ops was added after the check for name !=
pci, meaning pcix/pcie PHBs weren't getting their ops set correctly.

Fixes: 9c1368fc50e7 (powerpc/cell: Move controller ops from ppc_md to 
controller_ops)
Signed-off-by: Michael Ellerman m...@ellerman.id.au
---
 arch/powerpc/platforms/cell/setup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/cell/setup.c 
b/arch/powerpc/platforms/cell/setup.c
index d1be268b1e6e..36cff28d0293 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -127,13 +127,13 @@ static int cell_setup_phb(struct pci_controller *phb)
if (rc)
return rc;
 
+   phb-controller_ops = cell_pci_controller_ops;
+
np = phb-dn;
model = of_get_property(np, model, NULL);
if (model == NULL || strcmp(np-name, pci))
return 0;
 
-   phb-controller_ops = cell_pci_controller_ops;
-
/* Setup workarounds for spider */
if (strcmp(model, Spider))
return 0;
-- 
2.1.0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v9 00/11] Add support for JSON event files.

2015-04-14 Thread Sukadev Bhattiprolu
This is another attempt to resurrect Andi Kleen's patchset so users
can specify perf events by their event names rather than raw codes.

This is a rebase of Andi Kleen's patchset from Jul 30, 2014[1] to 4.0.
(I fixed minor and not so minor conflicts).

This patchset includes the perf-download tool that was dropped and sets
the default download location to the (tools/perf/pmu-events/arch/...
directory in Linus's tree.

A follow-on patchset will include the actual JSON files for Powerpc, which
are currently available on github[2].

[1] https://lkml.org/lkml/2014/7/30/693
[2] https://github.com/open-power/power-pmu-events

Andi Kleen (9):
  perf, tools: Add jsmn `jasmine' JSON parser
  perf, tools: Add support for text descriptions of events and alias
add
  perf, tools, list: Update perf list to output descriptions
  perf, tools: Add support for reading JSON event files
  perf, tools: Automatically look for event file name for cpu
  perf, tools: Query terminal width and use in perf list
  perf, tools: Add a new pmu interface to iterate over all events
  perf, tools, test: Add test case for alias and JSON parsing
  perf, tools: Add a --no-desc flag to perf list

Sukadev Bhattiprolu (2):
  powerpc/perf: Implement get_cpu_str()
  perf-download: Download the events json file

 tools/perf/Documentation/perf-download.txt |   31 +++
 tools/perf/Documentation/perf-list.txt |   29 ++-
 tools/perf/Documentation/perf-record.txt   |9 +-
 tools/perf/Documentation/perf-stat.txt |8 +-
 tools/perf/Makefile.perf   |   12 +-
 tools/perf/arch/powerpc/util/header.c  |   12 ++
 tools/perf/arch/x86/util/header.c  |   19 +-
 tools/perf/builtin-list.c  |   18 +-
 tools/perf/builtin-record.c|3 +
 tools/perf/builtin-stat.c  |2 +
 tools/perf/perf-download.sh|  171 +++
 tools/perf/tests/aliases.c |   59 ++
 tools/perf/tests/builtin-test.c|4 +
 tools/perf/tests/tests.h   |1 +
 tools/perf/util/cache.h|1 +
 tools/perf/util/jevents.c  |  287 +
 tools/perf/util/jevents.h  |9 +
 tools/perf/util/jsmn.c |  313 
 tools/perf/util/jsmn.h |   67 ++
 tools/perf/util/json.c |  162 ++
 tools/perf/util/json.h |   13 ++
 tools/perf/util/pager.c|   15 ++
 tools/perf/util/parse-events.c |4 +-
 tools/perf/util/parse-events.h |2 +-
 tools/perf/util/pmu.c  |  160 +++---
 tools/perf/util/pmu.h  |5 +-
 26 files changed, 1365 insertions(+), 51 deletions(-)
 create mode 100644 tools/perf/Documentation/perf-download.txt
 create mode 100755 tools/perf/perf-download.sh
 create mode 100644 tools/perf/tests/aliases.c
 create mode 100644 tools/perf/util/jevents.c
 create mode 100644 tools/perf/util/jevents.h
 create mode 100644 tools/perf/util/jsmn.c
 create mode 100644 tools/perf/util/jsmn.h
 create mode 100644 tools/perf/util/json.c
 create mode 100644 tools/perf/util/json.h

-- 
1.7.9.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v9 07/11] perf, tools: Query terminal width and use in perf list

2015-04-14 Thread Sukadev Bhattiprolu
From: Andi Kleen a...@linux.intel.com

Automatically adapt the now wider and word wrapped perf list
output to wider terminals. This requires querying the terminal
before the auto pager takes over, and exporting this
information from the pager subsystem.

Acked-by: Namhyung Kim namhy...@kernel.org
Signed-off-by: Andi Kleen a...@linux.intel.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com

---
Changelog[v9] by Sukadev Bhattiprolu
Rebase to 4.0.
---
 tools/perf/util/cache.h |1 +
 tools/perf/util/pager.c |   15 +++
 tools/perf/util/pmu.c   |   12 ++--
 3 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index d04d770..f1990c9 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -32,6 +32,7 @@ extern void setup_pager(void);
 extern const char *pager_program;
 extern int pager_in_use(void);
 extern int pager_use_color;
+int pager_get_columns(void);
 
 char *alias_lookup(const char *alias);
 int split_cmdline(char *cmdline, const char ***argv);
diff --git a/tools/perf/util/pager.c b/tools/perf/util/pager.c
index 31ee02d..9761202 100644
--- a/tools/perf/util/pager.c
+++ b/tools/perf/util/pager.c
@@ -1,6 +1,7 @@
 #include cache.h
 #include run-command.h
 #include sigchain.h
+#include sys/ioctl.h
 
 /*
  * This is split up from the rest of git so that we can do
@@ -8,6 +9,7 @@
  */
 
 static int spawned_pager;
+static int pager_columns;
 
 static void pager_preexec(void)
 {
@@ -47,9 +49,12 @@ static void wait_for_pager_signal(int signo)
 void setup_pager(void)
 {
const char *pager = getenv(PERF_PAGER);
+   struct winsize sz;
 
if (!isatty(1))
return;
+   if (ioctl(1, TIOCGWINSZ, sz) == 0)
+   pager_columns = sz.ws_col;
if (!pager) {
if (!pager_program)
perf_config(perf_default_config, NULL);
@@ -98,3 +103,13 @@ int pager_in_use(void)
env = getenv(PERF_PAGER_IN_USE);
return env ? perf_config_bool(PERF_PAGER_IN_USE, env) : 0;
 }
+
+int pager_get_columns(void)
+{
+   char *s;
+
+   s = getenv(COLUMNS);
+   if (s)
+   return atoi(s);
+   return (pager_columns ? pager_columns : 80) - 2;
+}
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 274aa18..2150455 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -11,6 +11,7 @@
 #include pmu.h
 #include parse-events.h
 #include cpumap.h
+#include cache.h
 #include jevents.h
 
 const char *json_file;
@@ -929,15 +930,6 @@ static void wordwrap(char *s, int start, int max, int corr)
}
 }
 
-static int get_columns(void)
-{
-   /*
-* Should ask the terminal with TIOCGWINSZ here, but we
-* need the original fd before the pager.
-*/
-   return 79;
-}
-
 void print_pmu_events(const char *event_glob, bool name_only)
 {
struct perf_pmu *pmu;
@@ -947,7 +939,7 @@ void print_pmu_events(const char *event_glob, bool 
name_only)
int len, j;
struct pair *aliases;
int numdesc = 0;
-   int columns = get_columns();
+   int columns = pager_get_columns();
 
pmu = NULL;
len = 0;
-- 
1.7.9.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 1/2] powerpc/eeh: Fix crash in eeh_add_device_early() on Cell

2015-04-14 Thread Michael Ellerman
The recent change to the EEH probing causes a crash on Cell because
eeh_ops is NULL.

Check if EEH is enabled and if not bail out.

Fixes: ff57b454ddb9 (powerpc/eeh: Do probe on pci_dn)
Signed-off-by: Michael Ellerman m...@ellerman.id.au
---
 arch/powerpc/kernel/eeh.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 76253eb146be..a4c62eb0ee48 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1053,7 +1053,7 @@ void eeh_add_device_early(struct pci_dn *pdn)
struct pci_controller *phb;
struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
 
-   if (!edev)
+   if (!edev || !eeh_enabled())
return;
 
/* USB Bus children of PCI devices will not have BUID's */
-- 
2.1.0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] powerpc/hugetlb: Call mm_dec_nr_pmds() in hugetlb_free_pmd_range()

2015-04-14 Thread Aneesh Kumar K.V
Scott Wood scottw...@freescale.com writes:

 Commit dc6c9a35b66b5 (mm: account pmd page tables to the process)
 added a counter that is incremented whenever a PMD is allocated and
 decremented whenever a PMD is freed.  For hugepages on PPC, common code
 is used to allocated PMDs, but arch-specific code is used to free PMDs.

 This results in kernel output such as BUG: non-zero nr_pmds on freeing
 mm: 1 when using hugepages.

 Update the PPC hugepage PMD freeing code to decrement the count, just
 as the above commit did for free_pmd_range().

 Fixes: dc6c9a35b66b5 (mm: account pmd page tables to the process)
 Signed-off-by: Scott Wood scottw...@freescale.com

Reviewed-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com

May be we need to move that mm_dec_nr_pmds to pmd_free_tlb() ?

 ---
 Should we also be touching nr_ptes when we alloc/free hugepage PTEs?

  arch/powerpc/mm/hugetlbpage.c | 1 +
  1 file changed, 1 insertion(+)

 diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
 index 7e408bf..cecbe00 100644
 --- a/arch/powerpc/mm/hugetlbpage.c
 +++ b/arch/powerpc/mm/hugetlbpage.c
 @@ -581,6 +581,7 @@ static void hugetlb_free_pmd_range(struct mmu_gather 
 *tlb, pud_t *pud,
   pmd = pmd_offset(pud, start);
   pud_clear(pud);
   pmd_free_tlb(tlb, pmd, start);
 + mm_dec_nr_pmds(tlb-mm);
  }
  
  static void hugetlb_free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
 -- 
 2.1.0

 ___
 Linuxppc-dev mailing list
 Linuxppc-dev@lists.ozlabs.org
 https://lists.ozlabs.org/listinfo/linuxppc-dev

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v9 01/11] perf, tools: Add jsmn `jasmine' JSON parser

2015-04-14 Thread Sukadev Bhattiprolu
From: Andi Kleen a...@linux.intel.com

I need a JSON parser. This adds the simplest JSON
parser I could find -- Serge Zaitsev's jsmn `jasmine' --
to the perf library. I merely converted it to (mostly)
Linux style and added support for non 0 terminated input.

The parser is quite straight forward and does not
copy any data, just returns tokens with offsets
into the input buffer. So it's relatively efficient
and simple to use.

The code is not fully checkpatch clean, but I didn't
want to completely fork the upstream code.

Original source: http://zserge.bitbucket.org/jsmn.html

In addition I added a simple wrapper that mmaps a json
file and provides some straight forward access functions.

Used in follow-on patches to parse event files.

Acked-by: Namhyung Kim namhy...@kernel.org
Signed-off-by: Andi Kleen a...@linux.intel.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
---

Changelog[v9] (by Sukadev Bhattiprolu)
Rebase to 4.0 and fix minor conflicts in tools/perf/Makefile.perf
Report error if specified events file is invalid.

v2: Address review feedback.
v3: Minor checkpatch fixes.
---
 tools/perf/Makefile.perf |4 +
 tools/perf/util/jsmn.c   |  313 ++
 tools/perf/util/jsmn.h   |   67 ++
 tools/perf/util/json.c   |  160 
 tools/perf/util/json.h   |   13 ++
 5 files changed, 557 insertions(+)
 create mode 100644 tools/perf/util/jsmn.c
 create mode 100644 tools/perf/util/jsmn.h
 create mode 100644 tools/perf/util/json.c
 create mode 100644 tools/perf/util/json.h

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index aa6a504..a558eb3 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -331,6 +331,8 @@ LIB_H += ui/ui.h
 LIB_H += util/data.h
 LIB_H += util/kvm-stat.h
 LIB_H += util/thread-stack.h
+LIB_H += util/jsmn.h
+LIB_H += util/json.h
 
 LIB_OBJS += $(OUTPUT)util/abspath.o
 LIB_OBJS += $(OUTPUT)util/alias.o
@@ -410,6 +412,8 @@ LIB_OBJS += $(OUTPUT)util/data.o
 LIB_OBJS += $(OUTPUT)util/tsc.o
 LIB_OBJS += $(OUTPUT)util/cloexec.o
 LIB_OBJS += $(OUTPUT)util/thread-stack.o
+LIB_OBJS += $(OUTPUT)util/jsmn.o
+LIB_OBJS += $(OUTPUT)util/json.o
 
 LIB_OBJS += $(OUTPUT)ui/setup.o
 LIB_OBJS += $(OUTPUT)ui/helpline.o
diff --git a/tools/perf/util/jsmn.c b/tools/perf/util/jsmn.c
new file mode 100644
index 000..11d1fa1
--- /dev/null
+++ b/tools/perf/util/jsmn.c
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2010 Serge A. Zaitsev
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the Software), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * Slightly modified by AK to not assume 0 terminated input.
+ */
+
+#include stdlib.h
+#include jsmn.h
+
+/*
+ * Allocates a fresh unused token from the token pool.
+ */
+static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
+  jsmntok_t *tokens, size_t num_tokens)
+{
+   jsmntok_t *tok;
+
+   if ((unsigned)parser-toknext = num_tokens)
+   return NULL;
+   tok = tokens[parser-toknext++];
+   tok-start = tok-end = -1;
+   tok-size = 0;
+   return tok;
+}
+
+/*
+ * Fills token type and boundaries.
+ */
+static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
+   int start, int end)
+{
+   token-type = type;
+   token-start = start;
+   token-end = end;
+   token-size = 0;
+}
+
+/*
+ * Fills next available token with JSON primitive.
+ */
+static jsmnerr_t jsmn_parse_primitive(jsmn_parser *parser, const char *js,
+ size_t len,
+ jsmntok_t *tokens, size_t num_tokens)
+{
+   jsmntok_t *token;
+   int start;
+
+   start = parser-pos;
+
+   for (; parser-pos  len; parser-pos++) {
+   switch (js[parser-pos]) {
+#ifndef JSMN_STRICT
+   /*
+* In strict mode primitive must be followed by ,
+* or } or ]
+*/
+  

[PATCH v9 05/11] perf, tools: Automatically look for event file name for cpu

2015-04-14 Thread Sukadev Bhattiprolu
From: Andi Kleen a...@linux.intel.com

When no JSON event file is specified automatically look
for a suitable file in ~/.cache/pmu-events.

The event file format is per architecture, but can be
extended for other architectures.

Acked-by: Namhyung Kim namhy...@kernel.org
Signed-off-by: Andi Kleen a...@linux.intel.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
---
Changelog[v9] by Sukadev Bhattiprolu
Rebase to 4.0 and fix.
v2: Supports XDG_CACHE_HOME and defaults to ~/.cache/pmu-events
v3: Minor updates and handle EVENTMAP.
v4: Unify with header.c. Now uses CPUID directly.
---
 tools/perf/arch/x86/util/header.c |   19 +++---
 tools/perf/util/jevents.c |   40 +
 tools/perf/util/jevents.h |1 +
 tools/perf/util/pmu.c |2 +-
 4 files changed, 58 insertions(+), 4 deletions(-)

diff --git a/tools/perf/arch/x86/util/header.c 
b/tools/perf/arch/x86/util/header.c
index 146d12a..76e0ece 100644
--- a/tools/perf/arch/x86/util/header.c
+++ b/tools/perf/arch/x86/util/header.c
@@ -5,6 +5,7 @@
 #include string.h
 
 #include ../../util/header.h
+#include ../../util/jevents.h
 
 static inline void
 cpuid(unsigned int op, unsigned int *a, unsigned int *b, unsigned int *c,
@@ -19,8 +20,8 @@ cpuid(unsigned int op, unsigned int *a, unsigned int *b, 
unsigned int *c,
: a (op));
 }
 
-int
-get_cpuid(char *buffer, size_t sz)
+static int
+__get_cpuid(char *buffer, size_t sz, const char *fmt)
 {
unsigned int a, b, c, d, lvl;
int family = -1, model = -1, step = -1;
@@ -48,7 +49,7 @@ get_cpuid(char *buffer, size_t sz)
if (family = 0x6)
model += ((a  16)  0xf)  4;
}
-   nb = scnprintf(buffer, sz, %s,%u,%u,%u$, vendor, family, model, step);
+   nb = scnprintf(buffer, sz, fmt, vendor, family, model, step);
 
/* look for end marker to ensure the entire data fit */
if (strchr(buffer, '$')) {
@@ -57,3 +58,15 @@ get_cpuid(char *buffer, size_t sz)
}
return -1;
 }
+
+int get_cpuid(char *buffer, size_t sz)
+{
+   return __get_cpuid(buffer, sz, %s,%u,%u,%u$);
+}
+
+char *get_cpu_str(void)
+{
+   char *buf = malloc(128);
+   __get_cpuid(buf, 128, %s-%d-%X-core);
+   return buf;
+}
diff --git a/tools/perf/util/jevents.c b/tools/perf/util/jevents.c
index 023757c..ef4c047 100644
--- a/tools/perf/util/jevents.c
+++ b/tools/perf/util/jevents.c
@@ -39,6 +39,44 @@
 #include json.h
 #include jevents.h
 
+__attribute__((weak)) char *get_cpu_str(void)
+{
+   return NULL;
+}
+
+static const char *json_default_name(void)
+{
+   char *cache;
+   char *idstr = get_cpu_str();
+   char *res = NULL;
+   char *home = NULL;
+   char *emap;
+
+   emap = getenv(EVENTMAP);
+   if (emap) {
+   if (access(emap, R_OK) == 0)
+   return emap;
+   if (asprintf(idstr, %s-core, emap)  0)
+   return NULL;
+   }
+
+   cache = getenv(XDG_CACHE_HOME);
+   if (!cache) {
+   home = getenv(HOME);
+   if (!home || asprintf(cache, %s/.cache, home)  0)
+   goto out;
+   }
+   if (cache  idstr)
+   res = mkpath(%s/pmu-events/%s.json,
+cache,
+idstr);
+   if (home)
+   free(cache);
+out:
+   free(idstr);
+   return res;
+}
+
 static void addfield(char *map, char **dst, const char *sep,
 const char *a, jsmntok_t *bt)
 {
@@ -171,6 +209,8 @@ int json_events(const char *fn,
int i, j, len;
char *map;
 
+   if (!fn)
+   fn = json_default_name();
tokens = parse_json(fn, map, size, len);
if (!tokens)
return -EIO;
diff --git a/tools/perf/util/jevents.h b/tools/perf/util/jevents.h
index fbc4549..86a94dd 100644
--- a/tools/perf/util/jevents.h
+++ b/tools/perf/util/jevents.h
@@ -4,5 +4,6 @@
 int json_events(const char *fn,
int (*func)(void *data, char *name, char *event, char *desc),
void *data);
+char *get_cpu_str(void);
 
 #endif
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index d7e5e1b..274aa18 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -482,7 +482,7 @@ static struct perf_pmu *pmu_lookup(const char *name)
if (pmu_aliases(name, aliases))
return NULL;
 
-   if (!strcmp(name, cpu)  json_file)
+   if (!strcmp(name, cpu))
json_events(json_file, add_alias, aliases);
 
if (pmu_type(name, type))
-- 
1.7.9.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v9 04/11] perf, tools: Add support for reading JSON event files

2015-04-14 Thread Sukadev Bhattiprolu
From: Andi Kleen a...@linux.intel.com

Add a parser for Intel style JSON event files. This allows
to use an Intel event list directly with perf. The Intel
event lists can be quite large and are too big to store
in unswappable kernel memory.

The parser code knows how to convert the JSON fields
to perf fields. The conversion code is straight forward.
It knows (very little) Intel specific information, and can be easily
extended to handle fields for other CPUs.

The parser code is partially shared with an independent parsing
library, which is 2-clause BSD licenced. To avoid any conflicts I marked
those files as BSD licenced too. As part of perf they become GPLv2.

The events are handled using the existing alias machinery.

We output the BriefDescription in perf list.

Right now the json file can be specified as an argument
to perf stat/record/list. Followon patches will automate this.

JSON files look like this:

[
  {
EventCode: 0x00,
UMask: 0x01,
EventName: INST_RETIRED.ANY,
BriefDescription: Instructions retired from execution.,
PublicDescription: Instructions retired from execution.,
Counter: Fixed counter 1,
CounterHTOff: Fixed counter 1,
SampleAfterValue: 203,
MSRIndex: 0,
MSRValue: 0,
TakenAlone: 0,
CounterMask: 0,
Invert: 0,
AnyThread: 0,
EdgeDetect: 0,
PEBS: 0,
PRECISE_STORE: 0,
Errata: null,
Offcore: 0
  }
]

Acked-by: Namhyung Kim namhy...@kernel.org
Signed-off-by: Andi Kleen a...@linux.intel.com
Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com
---
Changelog[v9] by Sukadev Bhattiprolu
Rebase to 4.0 and fix conflicts in:
tools/perf/Documentation/perf-record.txt
tools/perf/builtin-list.c
tools/perf/builtin-record.c
tools/perf/util/pmu.h
v2: Address review feedback. Rename option to --event-files
v3: Add JSON example
v4: Update manpages.
v5: Don't remove dot in fixname. Fix compile error. Add include
protection. Comment realloc.
v6: Include debug/util.h
---
 tools/perf/Documentation/perf-list.txt   |   12 +-
 tools/perf/Documentation/perf-record.txt |9 +-
 tools/perf/Documentation/perf-stat.txt   |8 +-
 tools/perf/Makefile.perf |2 +
 tools/perf/builtin-list.c|2 +
 tools/perf/builtin-record.c  |3 +
 tools/perf/builtin-stat.c|2 +
 tools/perf/util/jevents.c|  247 ++
 tools/perf/util/jevents.h|8 +
 tools/perf/util/json.c   |1 +
 tools/perf/util/pmu.c|   14 ++
 tools/perf/util/pmu.h|1 +
 12 files changed, 305 insertions(+), 4 deletions(-)
 create mode 100644 tools/perf/util/jevents.c
 create mode 100644 tools/perf/util/jevents.h

diff --git a/tools/perf/Documentation/perf-list.txt 
b/tools/perf/Documentation/perf-list.txt
index 3e2aec9..205ac40 100644
--- a/tools/perf/Documentation/perf-list.txt
+++ b/tools/perf/Documentation/perf-list.txt
@@ -15,8 +15,16 @@ DESCRIPTION
 This command displays the symbolic event types which can be selected in the
 various perf commands with the -e option.
 
-[[EVENT_MODIFIERS]]
-EVENT MODIFIERS
+OPTIONS
+---
+--events-file=::
+Specify JSON event list file to use for parsing events. Files can be
+automatically downloaded with perf download.
+The JSON event file can be also specified with the EVENTMAP environment
+variable.
+
+
+[[EVENT_MODIFIERS]] EVENT MODIFIERS
 ---
 
 Events can optionally have a modifier by appending a colon and one or
diff --git a/tools/perf/Documentation/perf-record.txt 
b/tools/perf/Documentation/perf-record.txt
index 31e9774..13f34b0 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -235,6 +235,13 @@ Capture machine state (registers) at interrupt, i.e., on 
counter overflows for
 each sample. List of captured registers depends on the architecture. This 
option
 is off by default.
 
+--events-file=::
+Specify JSON event list file to use for parsing events. Must be specified
+before the -e option. Files can be automatically downloaded with perf download.
+The JSON event file can be also specified with the EVENTMAP environment
+variable.
+
+
 SEE ALSO
 
-linkperf:perf-stat[1], linkperf:perf-list[1]
+linkperf:perf-stat[1], linkperf:perf-list[1], linkperf:perf-download[1]
diff --git a/tools/perf/Documentation/perf-stat.txt 
b/tools/perf/Documentation/perf-stat.txt
index 04e150d..3853245 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -154,6 +154,12 @@ filter out the startup phase of the program, which is 
often very different.
 
 Print statistics of transactional execution if supported.
 
+--events-file=::
+Specify JSON event list file to use for parsing events. Must be specified 
before
+the -e option. Files can be automatically downloaded with perf 

[PATCH kernel] powerpc/pseries: Fix compile of memory hotplug without CONFIG_MEMORY_HOTREMOVE

2015-04-14 Thread Alexey Kardashevskiy
51925fb3c5 powerpc/pseries: Implement memory hotplug remove in the kernel
broke compile when CONFIG_MEMORY_HOTREMOVE is not defined due to missing
symbols. This fixes the issue by adding the missing symbols.

Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru
---

This is made against ad30cb99465 (mpe/next) and can be squashed into 51925fb3c5
if not too late.


---
 arch/powerpc/platforms/pseries/hotplug-memory.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c 
b/arch/powerpc/platforms/pseries/hotplug-memory.c
index 5cefcad..0ced387 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -369,6 +369,19 @@ static inline int dlpar_memory_remove(struct 
pseries_hp_errorlog *hp_elog)
 {
return -EOPNOTSUPP;
 }
+static int dlpar_remove_lmb(struct of_drconf_cell *lmb)
+{
+   return -EOPNOTSUPP;
+}
+static int dlpar_memory_remove_by_count(u32 lmbs_to_remove,
+   struct property *prop)
+{
+   return -EOPNOTSUPP;
+}
+static int dlpar_memory_remove_by_index(u32 drc_index, struct property *prop)
+{
+   return -EOPNOTSUPP;
+}
 
 #endif /* CONFIG_MEMORY_HOTREMOVE */
 
-- 
2.0.0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v4 3/3] powerpc/powernv: Introduce sysfs control for fastsleep workaround behavior

2015-04-14 Thread Preeti U Murthy
On 04/14/2015 01:40 PM, Shreyas B Prabhu wrote:
 

 By default, fastsleep_workaround_state = dynamic. In this case, workaround
 is applied/undone everytime the core enters/exits fastsleep.

 fastsleep_workaround_state = applyonce. In this case the workaround is
 applied once on all the cores and never undone. This can be triggered by
 echo applyonce  /sys/devices/system/cpu/fastsleep_workaround_state

 I was wondering if we really need such an elaborate design for this
 sysfs file. Why not a sysfs file called fastsleep_workaround_apply_once,
 which is set to '0' by default and the only value that it can take is
 '1' ? The name easily implies that the workaround is applied only once
 if it is set. I can see that this can cut down a good chunk of code from
 this patch. I just didn't find too much value in having so much code for
 a simple 'on' knob.
 
 I was considering something similar too. But then moved to this format
 as I thought this was unambiguous. Also moving to a binary attribute
 will reduces code only in show_fastsleep_workaround_state which I don't
 feel is much.
 That said, if you feel strongly about it, I can change it to the format
 you suggested.

It cuts down two of your data structures:
fastsleep_workaround_avail_states[] and the enum and the parsing of the
input string in store_fastsleep_workaround_state() too.

Regards
Preeti U Murthy
 
 Thanks,
 Shreyas
 
 ___
 Linuxppc-dev mailing list
 Linuxppc-dev@lists.ozlabs.org
 https://lists.ozlabs.org/listinfo/linuxppc-dev
 

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v4 3/3] powerpc/powernv: Introduce sysfs control for fastsleep workaround behavior

2015-04-14 Thread Preeti U Murthy
Hi Shreyas,

On 04/14/2015 07:26 AM, Shreyas B. Prabhu wrote:
 +  * fastsleep_workaround_state = WORKAROUND_APPLYONCE implies
 +  * fastsleep workaround needs to be left in 'applied' state on all
 +  * the cores. Do this by-
 +  * 1. Patching out the call to 'undo' workaround in fastsleep exit path
 +  * 2. Sending ipi to all the cores which have atleast one online thread
 +  * 3. Patching out the call to 'apply' workaround in fastsleep entry
 +  * path
 +  * There is no need to send ipi to cores which have all threads
 +  * offlined, as last thread of the core entering fastsleep or deeper
 +  * state would have applied workaround.
 +  */
 + err = patch_instruction(
 + (unsigned int *)pnv_fastsleep_workaround_at_exit,
 + PPC_INST_NOP);
 + if (err) {
 + pr_err(fastsleep_workaround_state change failed while patching 
 pnv_fastsleep_workaround_at_exit);
 + goto fail;
 + }
 +
 + primary_thread_mask = cpu_online_cores_map();
 + on_each_cpu_mask(primary_thread_mask,
 + pnv_fastsleep_workaround_apply,
 + err, 1);
 + if (err) {
 + pr_err(fastsleep_workaround_state change failed while running 
 pnv_fastsleep_workaround_apply);
 + goto fail;
 + }
 +
 + err = patch_instruction(
 + (unsigned int *)pnv_fastsleep_workaround_at_entry,
 + PPC_INST_NOP);
 + if (err) {
 + pr_err(fastsleep_workaround_state change failed while patching 
 pnv_fastsleep_workaround_at_entry);
 + goto fail;
 + }

A point that bothers me here is if we can potentially race with cpu
hotplug ? If cpuX and its siblings are offline and it was interrupted to
come online:

cpuX cpuY
Interrupted to come online
Undo workaround

Nop the fastsleep_workaround_exit path
IPI online cores: apply workaround once

Set yourself in the online mask
Nop the fastsleep_workaround_entry path


This results in cpuX undoing the workaround on its core, never to set it
back again.

So should we protect the region between the beginning and end of
patching instructions with get_online_cpus() and put_online_cpus() ?

Regards
Preeti U Murthy

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

'perf upgrade' (was: Re: [PATCH v9 00/11] Add support for JSON event files.)

2015-04-14 Thread Ingo Molnar

* Sukadev Bhattiprolu suka...@linux.vnet.ibm.com wrote:

 This is another attempt to resurrect Andi Kleen's patchset so users
 can specify perf events by their event names rather than raw codes.
 
 This is a rebase of Andi Kleen's patchset from Jul 30, 2014[1] to 4.0.
 (I fixed minor and not so minor conflicts).

So this series shows some progress, but instead of this limited 
checkout ability I'd still prefer it if 'perf download' downloaded the 
latest perf code itself and built it - it shouldn't be limited to just 
a small subset of the perf source code!

There's a few Git tricks we can use to make this palatable on most 
systems.

To save disk space and network bandwith this could be done using Git's 
'shallow clone' feature:

   git clone --depth 1 --bare

The initial checkout finishes in 1.5 minutes here, a continent away 
from korg. The resulting repository size is just 143MB.

The code could also check whether the user has already a ~/linux.git 
repository around, and use --reference ~/linux.git in that case. In 
such a case the cloning takes just 2 seconds.

To get the source code we could use Git's 'sparse checkout' feature:

   git config core.sparsecheckout true
   echo tools/  .git/info/sparse-checkout
   git checkout tools/

Note that a sparse checkout build will need a few relatively simple 
other files as well, for the few files not in tools/ that the perf 
build needs - mostly include files.

I've attached below a working test script that will create a buildable 
tools/perf/ repository into ~/.perf/git/ of the latest tip/perf/core 
tree from kernel.org.

With ~/linux.git primed it takes under 10 seconds to execute. perf 
builds fine in the directory. The whole directory together with the 
Git repo is 53 MB - that could be shrunk some more if needed.

If there's no local Linux repository to fall back on to then the 
initial step takes 1.5 minutes (depending on network bandwidth) and 
another 140MB for the Git objects. It's a lot faster after that.

That way 'perf download' could also be renamed to 'perf upgrade'.

Building perf ought to be possible even on fairly limited development 
systems and our auto-detection and library install suggestions are 
pretty good.

And note that once we have that there's no reason to move the event 
descriptions into a separate file - it can be part of the perf binary 
itself.

 This patchset includes the perf-download tool that was dropped and 
 sets the default download location to the 
 (tools/perf/pmu-events/arch/... directory in Linus's tree.

So the way I think this would work best is for 'perf upgrade' to have 
different levels, similar to what the kernel has:

  perf upgrade devel   # pick files up from Arnaldo's korg tree
  perf upgrade next# pick files up from tip.git on korg
  perf upgrade rc  # pick files up from linus's Git tree
  perf upgrade stable  # pick files up the latest -stable version

'perf upgrade' would default to the most conservative, -stable 
variant, but of course users could pick whichever variant they prefer.

There's some limitations (such as if the build fails - but we want to 
fix such cases anyway), but note the fundamental power of this 
approach: 'perf upgrade' could turn any developer who has a perf 
binary into a perf tester and even into a contributor.

There's no need to even know Git or other development details - the 
latest code could be picked up and built.

'perf upgrade distro' could be offered as a way to downgrade to 
whatever previous (distro) perf version the user was using.

Likewise, later on this approach could be generalized into 
tools/build/ to enable self-hosting for other tools in tools/ as well, 
if they so desire.

Thanks,

Ingo


#!/bin/bash
#
# Simple script that fetches the 'perf' utility from Linus's tree, builds and
# installs it, by creating a shallow clone and a sparse checkout for Linux's
# tools/ directory and related dependencies:
#

DIR=~/.perf/git

rm -rf $DIR
mkdir -p $DIR || { echo 'error: No write permissions in the current 
directory?'; exit -1; }
cd $DIR

#REPO=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
#BRANCH=HEAD
REPO=git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
BRANCH=perf/core

REFERENCE=.
[ -d ~/linux/.git ]  REFERENCE=~/linux/
[ -d ~/linux.git/.git ]  REFERENCE=~/linux.git/
[ -d ~/tip/.git   ]  REFERENCE=~/tip/
[ -d ~/tip.git/.git   ]  REFERENCE=~/tip.git/

git clone --reference $REFERENCE --depth 1 --bare $REPO --branch $BRANCH .git
git config --local core.bare false

git config --local core.sparseCheckout true
git remote remove origin
git remote add -f origin $REPO -t $BRANCH

(
  echo '/tools/*'
  echo '/lib/*'
  echo '/include/*'
  echo '/arch/x86/lib/*'
  echo '/arch/x86/include/*'
  echo 'Makefile'
  echo '/scripts/*'

)  .git/info/sparse-checkout

git checkout $BRANCH

make -C tools/perf/ install


[PATCH V2] powerpc/mm: Add trace point for tracking hash pte fault

2015-04-14 Thread Aneesh Kumar K.V
This enables us to understand how many hash fault we are taking
when running benchmarks.

For ex:
-bash-4.2# ./perf stat -e  powerpc:hash_fault -e page-faults /tmp/ebizzy.ppc64 
-S 30  -P -n 1000
...

 Performance counter stats for '/tmp/ebizzy.ppc64 -S 30 -P -n 1000':

   1,10,04,075  powerpc:hash_fault
   1,10,03,429  page-faults

  30.865978991 seconds time elapsed

NOTE:
The impact of the tracepoint was not noticeable when running test. It was
within the run-time variance of the test. For ex:

without-patch:
--

 Performance counter stats for './a.out 3000 300':

   643  page-faults   #0.089 M/sec
  7.236562  task-clock (msec) #0.928 CPUs utilized
 2,179,213  stalled-cycles-frontend   #0.00% frontend cycles 
idle
17,174,367  stalled-cycles-backend#0.00% backend  cycles 
idle
 0  context-switches  #0.000 K/sec

   0.007794658 seconds time elapsed

And with-patch:
---

 Performance counter stats for './a.out 3000 300':

   643  page-faults   #0.089 M/sec
  7.233746  task-clock (msec) #0.921 CPUs utilized
 0  context-switches  #0.000 K/sec

   0.007854876 seconds time elapsed

 Performance counter stats for './a.out 3000 300':

   643  page-faults   #0.087 M/sec
   649  powerpc:hash_fault#0.087 M/sec
  7.430376  task-clock (msec) #0.938 CPUs utilized
 2,347,174  stalled-cycles-frontend   #0.00% frontend cycles 
idle
17,524,282  stalled-cycles-backend#0.00% backend  cycles 
idle
 0  context-switches  #0.000 K/sec

   0.007920284 seconds time elapsed

Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/trace.h | 21 +
 arch/powerpc/mm/hash_utils_64.c  |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/arch/powerpc/include/asm/trace.h b/arch/powerpc/include/asm/trace.h
index c15da6073cb8..ded56b183888 100644
--- a/arch/powerpc/include/asm/trace.h
+++ b/arch/powerpc/include/asm/trace.h
@@ -142,8 +142,29 @@ TRACE_EVENT_FN(opal_exit,
 
opal_tracepoint_regfunc, opal_tracepoint_unregfunc
 );
+
 #endif
 
+TRACE_EVENT(hash_fault,
+
+   TP_PROTO(unsigned long addr, unsigned long access, unsigned long 
trap),
+   TP_ARGS(addr, access, trap),
+   TP_STRUCT__entry(
+   __field(unsigned long, addr)
+   __field(unsigned long, access)
+   __field(unsigned long, trap)
+   ),
+
+   TP_fast_assign(
+   __entry-addr = addr;
+   __entry-access = access;
+   __entry-trap = trap;
+   ),
+
+   TP_printk(hash fault with addr 0x%lx and access = 0x%lx trap = 
0x%lx,
+ __entry-addr, __entry-access, __entry-trap)
+);
+
 #endif /* _TRACE_POWERPC_H */
 
 #undef TRACE_INCLUDE_PATH
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 2c2022d16059..7e88470a876f 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -57,6 +57,7 @@
 #include asm/fadump.h
 #include asm/firmware.h
 #include asm/tm.h
+#include asm/trace.h
 
 #ifdef DEBUG
 #define DBG(fmt...) udbg_printf(fmt)
@@ -1004,6 +1005,7 @@ int hash_page_mm(struct mm_struct *mm, unsigned long ea,
 
DBG_LOW(hash_page(ea=%016lx, access=%lx, trap=%lx\n,
ea, access, trap);
+   trace_hash_fault(ea, access, trap);
 
/* Get region  vsid */
switch (REGION_ID(ea)) {
-- 
2.1.0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v4 3/3] powerpc/powernv: Introduce sysfs control for fastsleep workaround behavior

2015-04-14 Thread Shreyas B Prabhu


 By default, fastsleep_workaround_state = dynamic. In this case, workaround
 is applied/undone everytime the core enters/exits fastsleep.

 fastsleep_workaround_state = applyonce. In this case the workaround is
 applied once on all the cores and never undone. This can be triggered by
 echo applyonce  /sys/devices/system/cpu/fastsleep_workaround_state
 
 I was wondering if we really need such an elaborate design for this
 sysfs file. Why not a sysfs file called fastsleep_workaround_apply_once,
 which is set to '0' by default and the only value that it can take is
 '1' ? The name easily implies that the workaround is applied only once
 if it is set. I can see that this can cut down a good chunk of code from
 this patch. I just didn't find too much value in having so much code for
 a simple 'on' knob.

I was considering something similar too. But then moved to this format
as I thought this was unambiguous. Also moving to a binary attribute
will reduces code only in show_fastsleep_workaround_state which I don't
feel is much.
That said, if you feel strongly about it, I can change it to the format
you suggested.

Thanks,
Shreyas

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 02/10] KVM: define common __KVM_GUESTDBG_USE_SW/HW_BP values

2015-04-14 Thread Christoffer Dall
On Mon, Apr 13, 2015 at 03:51:33PM +0100, Alex Bennée wrote:
 
 Christoffer Dall christoffer.d...@linaro.org writes:
 
  On Tue, Mar 31, 2015 at 04:08:00PM +0100, Alex Bennée wrote:
  Currently x86, powerpc and soon arm64 use the same two architecture
  specific bits for guest debug support for software and hardware
  breakpoints. This makes the shared values explicit while leaving the
  gate open for another architecture to use some other value if they
  really really want to.
  
  Signed-off-by: Alex Bennée alex.ben...@linaro.org
  
  diff --git a/arch/powerpc/include/uapi/asm/kvm.h 
  b/arch/powerpc/include/uapi/asm/kvm.h
  index ab4d473..1731569 100644
  --- a/arch/powerpc/include/uapi/asm/kvm.h
  +++ b/arch/powerpc/include/uapi/asm/kvm.h
  @@ -310,8 +310,8 @@ struct kvm_guest_debug_arch {
* and upper 16 bits are architecture specific. Architecture specific 
  defines
* that ioctl is for setting hardware breakpoint or software breakpoint.
*/
  -#define KVM_GUESTDBG_USE_SW_BP0x0001
  -#define KVM_GUESTDBG_USE_HW_BP0x0002
  +#define KVM_GUESTDBG_USE_SW_BP__KVM_GUESTDBG_USE_SW_BP
  +#define KVM_GUESTDBG_USE_HW_BP__KVM_GUESTDBG_USE_HW_BP
   
   /* definition of registers in kvm_run */
   struct kvm_sync_regs {
  diff --git a/arch/x86/include/uapi/asm/kvm.h 
  b/arch/x86/include/uapi/asm/kvm.h
  index d7dcef5..1438202 100644
  --- a/arch/x86/include/uapi/asm/kvm.h
  +++ b/arch/x86/include/uapi/asm/kvm.h
  @@ -250,8 +250,8 @@ struct kvm_debug_exit_arch {
 __u64 dr7;
   };
   
  -#define KVM_GUESTDBG_USE_SW_BP0x0001
  -#define KVM_GUESTDBG_USE_HW_BP0x0002
  +#define KVM_GUESTDBG_USE_SW_BP__KVM_GUESTDBG_USE_SW_BP
  +#define KVM_GUESTDBG_USE_HW_BP__KVM_GUESTDBG_USE_HW_BP
   #define KVM_GUESTDBG_INJECT_DB0x0004
   #define KVM_GUESTDBG_INJECT_BP0x0008
   
  diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
  index 5eedf84..ce2db14 100644
  --- a/include/uapi/linux/kvm.h
  +++ b/include/uapi/linux/kvm.h
  @@ -525,8 +525,16 @@ struct kvm_s390_irq {
   
   /* for KVM_SET_GUEST_DEBUG */
   
  -#define KVM_GUESTDBG_ENABLE   0x0001
  -#define KVM_GUESTDBG_SINGLESTEP   0x0002
  +#define KVM_GUESTDBG_ENABLE   (1  0)
  +#define KVM_GUESTDBG_SINGLESTEP   (1  1)
  +
  +/*
  + * Architecture specific stuff uses the top 16 bits of the field,
 
  can you be more specific than 'stuff' here?  features?
 
  + * however there is some shared commonality for the common cases
 
  I don't like this sentence; shared commonality is a pleonasm and the use
  of however makes it sounds like there's some caveat here.
 
 OK I can see that - after I looked it up ;-)
 
  If the top 16 bits are indeed arhictecture specific, then I think they
  should just be defined in their architecture specific headers.  Unless
  the idea here is that there's a fixed set of of flags that architectures
  can choose to support, in which case it should simply be defined in the
  common header.
 
 Well an architecture might not support some features and want to use
 those bits for something else? I didn't want to force the bottom two
 of the architecture specific bits to wasted if the features don't exist.
 
In that case I think the definition is local to each architecture and
should indeed just be duplicated.  The __ definitions complicate more
than they help as they are exported to userspace etc.  The KVM
maintainers may have a different view on this though.

-Christoffer
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [RESEND PATCH v3 1/2] mm: Introducing arch_remap hook

2015-04-14 Thread Laurent Dufour
On 13/04/2015 22:59, Andrew Morton wrote:
 On Mon, 13 Apr 2015 17:02:19 +0300 Kirill A. Shutemov 
 kir...@shutemov.name wrote:
 
 Kirill, if I'm right with it, can you suggest the header where to put
 the generic mremap hook's (empty) body?

 I initially thought it would be enough to put it into
 asm-generic/mmu_context.h, expecting it works as
 asm-generic/pgtable.h. But that's not the case.

 It probably worth at some point rework all asm/mmu_context.h to include
 asm-generic/mmu_context.h at the end as we do for asm/pgtable.h.
 But that's outside the scope of the patchset, I guess.

 I don't see any better candidate for such dummy header. :-/
 
 Do away with __HAVE_ARCH_REMAP and do it like this:
 
 arch/x/include/asm/y.h:
 
   extern void arch_remap(...);
   #define arch_remap arch_remap
 
 include/linux/z.h:
 
   #include asm/y.h
 
   #ifndef arch_remap
   static inline void arch_remap(...) { }
   #define arch_remap arch_remap
   #endif

Hi Andrew,

I like your idea, but I can't find any good candidate for asm/y.h and
linux/z.h.

I tried with linux/mm.h and asm/mmu_context.h but
asm/mmu_context.h is already including linux/mm.h.

Do you have any suggestion ?

Another option could be to do it like the actual arch_unmap() in
asm-generic/mm_hooks.h but this is the opposite of your idea, and Ingo
was not comfortable with this idea due to the impact of the other
architectures.

Cheers,
Laurent.

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 2/3] Remove celleb-only SCC PATA drivers

2015-04-14 Thread Bartlomiej Zolnierkiewicz

Hi,

On Tuesday, April 14, 2015 03:28:45 PM Daniel Axtens wrote:
 The SCC PATA interface is only used by celleb.
 celleb has been dropped [1], so drop the drivers.
 
 [1] http://patchwork.ozlabs.org/patch/451730/
 
 CC: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
 CC: Tejun Heo t...@kernel.org
 CC: David S. Miller da...@davemloft.net
 CC: linux-...@vger.kernel.org
 CC: Valentin Rothberg valentinrothb...@gmail.com
 CC: m...@ellerman.id.au
 CC: linuxppc-dev@lists.ozlabs.org
 Signed-off-by: Daniel Axtens d...@axtens.net
 
 ---
 v2: get name of ozlab*s*.org right. Sorry all.
 ---
  drivers/ata/Kconfig|9 -
  drivers/ata/Makefile   |1 -
  drivers/ata/pata_scc.c | 1110 
 
  drivers/ide/Kconfig|9 -
  drivers/ide/Makefile   |1 -
  drivers/ide/scc_pata.c |  887 --
  6 files changed, 2017 deletions(-)
  delete mode 100644 drivers/ata/pata_scc.c
  delete mode 100644 drivers/ide/scc_pata.c

For PATA part:

Acked-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com

If Tejun  Dave are OK with it this patch can go through libata tree.
Otherwise you will need to split it on separate libata/IDE patches.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung RD Institute Poland
Samsung Electronics

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 2/3] Remove celleb-only SCC PATA drivers

2015-04-14 Thread Tejun Heo
On Tue, Apr 14, 2015 at 01:58:14PM +0200, Bartlomiej Zolnierkiewicz wrote:
 If Tejun  Dave are OK with it this patch can go through libata tree.
 Otherwise you will need to split it on separate libata/IDE patches.

I really don't care which tree this goes through.  Dave, if you wanna
take it, please feel free to add my acked-by.  If not, I'll route it.

Thanks.

-- 
tejun
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: 'perf upgrade' (was: Re: [PATCH v9 00/11] Add support for JSON event files.)

2015-04-14 Thread Michael Ellerman
On Tue, 2015-04-14 at 10:55 +0200, Ingo Molnar wrote:
 * Sukadev Bhattiprolu suka...@linux.vnet.ibm.com wrote:
 
  This is another attempt to resurrect Andi Kleen's patchset so users
  can specify perf events by their event names rather than raw codes.
  
  This is a rebase of Andi Kleen's patchset from Jul 30, 2014[1] to 4.0.
  (I fixed minor and not so minor conflicts).
 
 So this series shows some progress, but instead of this limited 
 checkout ability I'd still prefer it if 'perf download' downloaded the 
 latest perf code itself and built it - it shouldn't be limited to just 
 a small subset of the perf source code!

Ingo, can you please stop blocking this? It's getting ridiculous.

We've been waiting over 8 months for this to go in.

While we've been waiting most of our users have learnt to use operf instead,
which doesn't require raw codes.

I would also add that exactly zero users have asked for a feature where perf
downloads and rebuilds itself. In fact many of them would consider that a
security breach.

cheers


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] dt/bindings: qoriq-clock: Update core PLL binding

2015-04-14 Thread Igal . Liberman
From: Igal Liberman igal.liber...@freescale.com

Added optional divider to fsl,qoriq-core-pll-2.0.
This option might be used by Freescale hardware accelerators.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 .../devicetree/bindings/clock/qoriq-clock.txt  |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/clock/qoriq-clock.txt 
b/Documentation/devicetree/bindings/clock/qoriq-clock.txt
index df4a259..b0d7b73 100644
--- a/Documentation/devicetree/bindings/clock/qoriq-clock.txt
+++ b/Documentation/devicetree/bindings/clock/qoriq-clock.txt
@@ -68,11 +68,17 @@ Required properties:
 - #clock-cells: From common clock binding. The number of cells in a
clock-specifier. Should be 0 for fsl,qoriq-sysclk-[1,2].0
clocks, or 1 for fsl,qoriq-core-pll-[1,2].0 clocks.
-   For fsl,qoriq-core-pll-[1,2].0 clocks, the single
+   For fsl,qoriq-core-pll-1.0 clocks, the single
clock-specifier cell may take the following values:
* 0 - equal to the PLL frequency
* 1 - equal to the PLL frequency divided by 2
* 2 - equal to the PLL frequency divided by 4
+   For fsl,qoriq-core-pll-2.0 clocks, the single
+   clock-specifier cell may take the following values:
+   * 0 - equal to the PLL frequency
+   * 1 - equal to the PLL frequency divided by 2
+   * 2 - equal to the PLL frequency divided by 3
+   * 3 - equal to the PLL frequency divided by 4
 
 Recommended properties:
 - clocks: Should be the phandle of input parent clock
-- 
1.7.9.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[v3] dt/bindings: qoriq-clock: Add binding for FMan clock mux

2015-04-14 Thread Igal . Liberman
From: Igal Liberman igal.liber...@freescale.com

v3: Addressed feedback from Scott:
- Removed clock specifier description.

v2: Addressed feedback from Scott:
- Moved the fman-clk-mux clock provider details
  under clocks property.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 .../devicetree/bindings/clock/qoriq-clock.txt  |   17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/clock/qoriq-clock.txt 
b/Documentation/devicetree/bindings/clock/qoriq-clock.txt
index b0d7b73..2bb3b38 100644
--- a/Documentation/devicetree/bindings/clock/qoriq-clock.txt
+++ b/Documentation/devicetree/bindings/clock/qoriq-clock.txt
@@ -65,9 +65,10 @@ Required properties:
It takes parent's clock-frequency as its clock.
* fsl,qoriq-platform-pll-1.0 for the platform PLL clock (v1.0)
* fsl,qoriq-platform-pll-2.0 for the platform PLL clock (v2.0)
+   * fsl,fman-clk-mux for the Frame Manager clock.
 - #clock-cells: From common clock binding. The number of cells in a
-   clock-specifier. Should be 0 for fsl,qoriq-sysclk-[1,2].0
-   clocks, or 1 for fsl,qoriq-core-pll-[1,2].0 clocks.
+   clock-specifier. Should be 0 for fsl,qoriq-sysclk-[1,2].0 and
+   fsl,fman-clk-mux clocks or 1 for fsl,qoriq-core-pll-[1,2].0.
For fsl,qoriq-core-pll-1.0 clocks, the single
clock-specifier cell may take the following values:
* 0 - equal to the PLL frequency
@@ -145,6 +146,18 @@ Example for clock block and clock provider:
clocks = sysclk;
clock-output-names = platform-pll, 
platform-pll-div2;
};
+
+   fm0clk: fm0-clk-mux {
+   #clock-cells = 0;
+   reg = 0x10 4
+   compatible = fsl,fman-clk-mux;
+   clocks = pll0 0, pll0 1, pll0 2, pll0 3,
+platform_pll 0, pll1 1, pll1 2;
+   clock-names = pll0, pll0-div2, pll0-div3,
+ pll0-div4, platform-pll, pll1-div2,
+ pll1-div3;
+   clock-output-names = fm0-clk;
+   };
};
 };
 
-- 
1.7.9.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH kernel] powerpc/pseries: Fix compile of memory hotplug without CONFIG_MEMORY_HOTREMOVE

2015-04-14 Thread Nathan Fontenot
On 04/14/2015 02:01 AM, Alexey Kardashevskiy wrote:
 51925fb3c5 powerpc/pseries: Implement memory hotplug remove in the kernel
 broke compile when CONFIG_MEMORY_HOTREMOVE is not defined due to missing
 symbols. This fixes the issue by adding the missing symbols.
 
I think the real fix should be a more invasive patch so that these routines
are not used outside of CONFIG_MEMORY_HOPLUG. These symbols really
are only needed for memory remove.

I'm fine with this patch to correct the build break and will work
on a patch to move code aound when I return from vacation next week.

 Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru
Acked-by: Nathan Fontenot nf...@linux.vnet.ibm.com

 ---
 
 This is made against ad30cb99465 (mpe/next) and can be squashed into 
 51925fb3c5
 if not too late.
 
 
 ---
  arch/powerpc/platforms/pseries/hotplug-memory.c | 13 +
  1 file changed, 13 insertions(+)
 
 diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c 
 b/arch/powerpc/platforms/pseries/hotplug-memory.c
 index 5cefcad..0ced387 100644
 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c
 +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
 @@ -369,6 +369,19 @@ static inline int dlpar_memory_remove(struct 
 pseries_hp_errorlog *hp_elog)
  {
   return -EOPNOTSUPP;
  }
 +static int dlpar_remove_lmb(struct of_drconf_cell *lmb)
 +{
 + return -EOPNOTSUPP;
 +}
 +static int dlpar_memory_remove_by_count(u32 lmbs_to_remove,
 + struct property *prop)
 +{
 + return -EOPNOTSUPP;
 +}
 +static int dlpar_memory_remove_by_index(u32 drc_index, struct property *prop)
 +{
 + return -EOPNOTSUPP;
 +}
 
  #endif /* CONFIG_MEMORY_HOTREMOVE */
 

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[v2] dt/bindings: fsl/guts: Added global-utilities compatibles

2015-04-14 Thread Igal . Liberman
From: Igal Liberman igal.liber...@freescale.com

v2 - Addressed Scott's feedback

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 .../devicetree/bindings/powerpc/fsl/guts.txt   |4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/powerpc/fsl/guts.txt 
b/Documentation/devicetree/bindings/powerpc/fsl/guts.txt
index 7f150b5..69644e6 100644
--- a/Documentation/devicetree/bindings/powerpc/fsl/guts.txt
+++ b/Documentation/devicetree/bindings/powerpc/fsl/guts.txt
@@ -9,6 +9,10 @@ Required properties:
 
  - compatible : Should define the compatible device type for
global-utilities.
+   Possible compatibles:
+   fsl,qoriq-device-config-1.0
+   fsl,qoriq-device-config-2.0
+   fsl,chip-device-config
  - reg : Offset and length of the register set for the device.
 
 Recommended properties:
-- 
1.7.9.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[v2] powerpc/dts: Add some SoC specific fsl, *-device-config compatibles

2015-04-14 Thread Igal . Liberman
From: Igal Liberman igal.liber...@freescale.com

This patch adds fsl,chip-device-config compatibles to guts node.
The added compatibles used in Freescale FMan clock initialization.
 
This patches is described by the following binding document update:
https://patchwork.ozlabs.org/patch/461153/

v2: Updated commit message

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 arch/powerpc/boot/dts/fsl/b4420si-post.dtsi |3 ++-
 arch/powerpc/boot/dts/fsl/b4860si-post.dtsi |3 ++-
 arch/powerpc/boot/dts/fsl/b4si-post.dtsi|3 ++-
 arch/powerpc/boot/dts/fsl/p2041si-post.dtsi |3 ++-
 arch/powerpc/boot/dts/fsl/p3041si-post.dtsi |3 ++-
 arch/powerpc/boot/dts/fsl/p4080si-post.dtsi |3 ++-
 arch/powerpc/boot/dts/fsl/p5020si-post.dtsi |3 ++-
 7 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/boot/dts/fsl/b4420si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/b4420si-post.dtsi
index 1ea8602..9b14f24 100644
--- a/arch/powerpc/boot/dts/fsl/b4420si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/b4420si-post.dtsi
@@ -77,7 +77,8 @@
};
 
guts: global-utilities@e {
-   compatible = fsl,b4420-device-config, 
fsl,qoriq-device-config-2.0;
+   compatible = fsl,b4420-device-config, fsl,b4-device-config,
+ fsl,qoriq-device-config-2.0;
};
 
global-utilities@e1000 {
diff --git a/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi
index 02ccde6..74a9f5f 100644
--- a/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi
@@ -248,7 +248,8 @@
};
 
guts: global-utilities@e {
-   compatible = fsl,b4860-device-config, 
fsl,qoriq-device-config-2.0;
+   compatible = fsl,b4860-device-config, fsl,b4-device-config,
+fsl,qoriq-device-config-2.0;
};
 
global-utilities@e1000 {
diff --git a/arch/powerpc/boot/dts/fsl/b4si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/b4si-post.dtsi
index f8c325e..babb076 100644
--- a/arch/powerpc/boot/dts/fsl/b4si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/b4si-post.dtsi
@@ -391,7 +391,8 @@
 /include/ qoriq-mpic4.3.dtsi
 
guts: global-utilities@e {
-   compatible = fsl,b4-device-config;
+   compatible = fsl,b4-device-config,
+ fsl,qoriq-device-config-2.0;
reg = 0xe 0xe00;
fsl,has-rstcr;
fsl,liodn-bits = 12;
diff --git a/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi
index 1f18b8b..a7ae5ae 100644
--- a/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi
@@ -311,7 +311,8 @@
 /include/ qoriq-mpic.dtsi
 
guts: global-utilities@e {
-   compatible = fsl,qoriq-device-config-1.0;
+   compatible = fsl,p2041-device-config,
+ fsl,qoriq-device-config-1.0;
reg = 0xe 0xe00;
fsl,has-rstcr;
#sleep-cells = 1;
diff --git a/arch/powerpc/boot/dts/fsl/p3041si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/p3041si-post.dtsi
index a555d24..89d08d6 100644
--- a/arch/powerpc/boot/dts/fsl/p3041si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p3041si-post.dtsi
@@ -338,7 +338,8 @@
 /include/ qoriq-mpic.dtsi
 
guts: global-utilities@e {
-   compatible = fsl,qoriq-device-config-1.0;
+   compatible = fsl,p3041-device-config,
+ fsl,qoriq-device-config-1.0;
reg = 0xe 0xe00;
fsl,has-rstcr;
#sleep-cells = 1;
diff --git a/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi
index 0fe7281..1863d6a 100644
--- a/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi
@@ -358,7 +358,8 @@
 /include/ qoriq-mpic.dtsi
 
guts: global-utilities@e {
-   compatible = fsl,qoriq-device-config-1.0;
+   compatible = fsl,p4080-device-config,
+ fsl,qoriq-device-config-1.0;
reg = 0xe 0xe00;
fsl,has-rstcr;
#sleep-cells = 1;
diff --git a/arch/powerpc/boot/dts/fsl/p5020si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/p5020si-post.dtsi
index a34ca20..d979d01 100644
--- a/arch/powerpc/boot/dts/fsl/p5020si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/p5020si-post.dtsi
@@ -343,7 +343,8 @@
 /include/ qoriq-mpic.dtsi
 
guts: global-utilities@e {
-   compatible = fsl,qoriq-device-config-1.0;
+   compatible = fsl,p5020-device-config,
+ fsl,qoriq-device-config-1.0;
reg = 0xe 0xe00;
fsl,has-rstcr;
#sleep-cells = 1;
-- 
1.7.9.5

___

[v3] clk: qoriq: Add support for the FMan clock

2015-04-14 Thread Igal . Liberman
From: Igal Liberman igal.liber...@freescale.com

This patch depends on the following patches:
https://patchwork.ozlabs.org/patch/461151/
https://patchwork.ozlabs.org/patch/461155/

This patche is described by the following binding document update:
https://patchwork.ozlabs.org/patch/461166/

v3: Updated commit message

v2: - Added clock maintainers
- Cached FMan clock parent during initialization
- Register the clock after checking if the hardware exists
- updated error messages

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/clk/clk-qoriq.c |  208 +++
 1 file changed, 208 insertions(+)

diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
index cda90a9..d588e90 100644
--- a/drivers/clk/clk-qoriq.c
+++ b/drivers/clk/clk-qoriq.c
@@ -19,6 +19,8 @@
 #include linux/of.h
 #include linux/slab.h
 
+#include asm/fsl_guts.h
+
 struct cmux_clk {
struct clk_hw hw;
void __iomem *reg;
@@ -155,6 +157,211 @@ err_name:
kfree(parent_names);
 }
 
+/* Table for matching compatible strings, for device tree
+ * guts node, for QorIQ SOCs.
+ * fsl,qoriq-device-config-2.0 corresponds to T4  B4
+ * SOCs. For the older SOCs fsl,qoriq-device-config-1.0
+ * string would be used.
+ */
+
+static const struct of_device_id guts_device_ids[] = {
+   { .compatible = fsl,qoriq-device-config-1.0, },
+   { .compatible = fsl,qoriq-device-config-2.0, },
+   {}
+};
+
+/* P2, P3, P4, P5 */
+#define FM1_CLK_SEL_SHIFT  30
+#define FM1_CLK_SELBIT(FM1_CLK_SEL_SHIFT)
+#define FM2_CLK_SEL_SHIFT  29
+#define FM2_CLK_SELBIT(FM2_CLK_SEL_SHIFT)
+#define HWA_ASYNC_DIV_SHIFT26
+#define HWA_ASYNC_DIV  BIT(HWA_ASYNC_DIV_SHIFT)
+
+/* B4, T2 */
+#define HWA_CGA_M1_CLK_SEL_SHIFT   29
+#define HWA_CGA_M1_CLK_SEL (BIT(HWA_CGA_M1_CLK_SEL_SHIFT + 2) |\
+BIT(HWA_CGA_M1_CLK_SEL_SHIFT + 1) |\
+BIT(HWA_CGA_M1_CLK_SEL_SHIFT))
+
+/* T4240 */
+#define HWA_CGB_M1_CLK_SEL_SHIFT   26
+#define HWA_CGB_M1_CLK_SEL (BIT(HWA_CGB_M1_CLK_SEL_SHIFT + 2) |\
+BIT(HWA_CGB_M1_CLK_SEL_SHIFT + 1) |\
+BIT(HWA_CGB_M1_CLK_SEL_SHIFT))
+#define HWA_CGB_M2_CLK_SEL_SHIFT   3
+#define HWA_CGB_M2_CLK_SEL (BIT(HWA_CGB_M2_CLK_SEL_SHIFT + 2) |\
+BIT(HWA_CGB_M2_CLK_SEL_SHIFT + 1) |\
+BIT(HWA_CGB_M2_CLK_SEL_SHIFT))
+
+static u8 get_fm_clk_parent(struct clk_hw *hw)
+{
+   return hw-init-flags;
+}
+
+static const struct clk_ops fm_clk_ops = {
+   .get_parent = get_fm_clk_parent,
+};
+
+static int get_fm_clk_idx(int fm_id, int *fm_clk_idx)
+{
+   struct ccsr_guts __iomem *guts_regs = NULL;
+   struct device_node *guts;
+   uint32_t reg = 0;
+   int clk_src = 0;
+
+   guts = of_find_matching_node(NULL, guts_device_ids);
+   if (!guts) {
+   pr_err(could not find GUTS node\n);
+   return -ENODEV;
+   }
+
+   guts_regs = of_iomap(guts, 0);
+   of_node_put(guts);
+   if (!guts_regs) {
+   pr_err(ioremap of GUTS node failed\n);
+   return -ENODEV;
+   }
+
+   if (of_device_is_compatible(guts, fsl,p1023-guts) ||
+   of_device_is_compatible(guts, fsl,t1040-device-config)) {
+   /* P1023 and T1040 have only one optional clock source */
+   *fm_clk_idx = 0;
+   } else if (of_device_is_compatible(guts, fsl,p2041-device-config) ||
+  of_device_is_compatible(guts, fsl,p3041-device-config) ||
+  of_device_is_compatible(guts, fsl,p4080-device-config)) {
+   /* Read RCW*/
+   reg = ioread32be(guts_regs-rcwsr[7]);
+
+   if (fm_id == 0)
+   *fm_clk_idx = (reg  FM1_CLK_SEL) 
+   FM1_CLK_SEL_SHIFT;
+   else
+   *fm_clk_idx = (reg  FM2_CLK_SEL) 
+   FM2_CLK_SEL_SHIFT;
+   } else if (of_device_is_compatible(guts, fsl,p5020-device-config) ||
+  of_device_is_compatible(guts, fsl,p5040-device-config)) {
+   /* Read RCW */
+   reg = ioread32be(guts_regs-rcwsr[7]);
+
+   if (fm_id == 0)
+   clk_src = (reg  FM1_CLK_SEL)  FM1_CLK_SEL_SHIFT;
+   else
+   clk_src = (reg  FM2_CLK_SEL)  FM2_CLK_SEL_SHIFT;
+
+   if (clk_src == 0) {
+   *fm_clk_idx = 0;
+   } else {
+   clk_src = (reg  HWA_ASYNC_DIV)  HWA_ASYNC_DIV_SHIFT;
+   *fm_clk_idx = clk_src + 1;
+

[PATCH] powerpc: Show utsname-machine in boot-up banner

2015-04-14 Thread Michael Ellerman
Currently we print Starting Linux PPC64 at boot. But we don't mention
anywhere whether the kernel is big or little endian.

If we print the utsname-machine value instead we get either ppc64 or
ppc64le which is much more informative, eg:

  Starting Linux ppc64le #1 SMP Wed Apr 15 12:12:20 AEST 2015

Signed-off-by: Michael Ellerman m...@ellerman.id.au
---
 arch/powerpc/kernel/setup_64.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 49f553bbb360..dfbeabad523b 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -522,7 +522,8 @@ void __init setup_system(void)
smp_release_cpus();
 #endif
 
-   pr_info(Starting Linux PPC64 %s\n, init_utsname()-version);
+   pr_info(Starting Linux %s %s\n, init_utsname()-machine,
+init_utsname()-version);
 
pr_info(-\n);
pr_info(ppc64_pft_size= 0x%llx\n, ppc64_pft_size);
-- 
2.1.0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 1/4 v4] powerpc/fsl-booke: Add device tree support for T1024/T1023 SoC

2015-04-14 Thread Shengzhou Liu
The T1024 SoC includes the following function and features:
- Two 64-bit Power architecture e5500 cores, up to 1.4GHz
- private 256KB L2 cache each core and shared 256KB CoreNet platform cache (CPC)
- 32-/64-bit DDR3L/DDR4 SDRAM memory controller with ECC and interleaving 
support
- Data Path Acceleration Architecture (DPAA) incorporating acceleration
- Four MAC for 1G/2.5G/10G network interfaces (RGMII, SGMII, QSGMII, XFI)
- High-speed peripheral interfaces
  - Three PCI Express 2.0 controllers
- Additional peripheral interfaces
  - One SATA 2.0 controller
  - Two USB 2.0 controllers with integrated PHY
  - Enhanced secure digital host controller (SD/eSDHC/eMMC)
  - Enhanced serial peripheral interface (eSPI)
  - Four I2C controllers
  - Four 2-pin UARTs or two 4-pin UARTs
  - Integrated Flash Controller supporting NAND and NOR flash
- Two 8-channel DMA engines
- Multicore programmable interrupt controller (PIC)
- LCD interface (DIU) with 12 bit dual data rate
- QUICC Engine block supporting TDM, HDLC, and UART
- Deep Sleep power implementaion (wakeup from GPIO/Timer/Ethernet/USB)
- Support for hardware virtualization and partitioning enforcement
- QorIQ Platform's Trust Architecture 2.0

Signed-off-by: Shengzhou Liu shengzhou@freescale.com
---
v4: removed qoriq-tdm1.0.dtsi
v3: use qoriq-clockgen2.dtsi
v2: removed sleep.

 arch/powerpc/boot/dts/fsl/t1023si-post.dtsi | 330 
 arch/powerpc/boot/dts/fsl/t1024si-post.dtsi | 100 +
 arch/powerpc/boot/dts/fsl/t102xsi-pre.dtsi  |  87 
 3 files changed, 517 insertions(+)
 create mode 100644 arch/powerpc/boot/dts/fsl/t1023si-post.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/t1024si-post.dtsi
 create mode 100644 arch/powerpc/boot/dts/fsl/t102xsi-pre.dtsi

diff --git a/arch/powerpc/boot/dts/fsl/t1023si-post.dtsi 
b/arch/powerpc/boot/dts/fsl/t1023si-post.dtsi
new file mode 100644
index 000..dbe6578
--- /dev/null
+++ b/arch/powerpc/boot/dts/fsl/t1023si-post.dtsi
@@ -0,0 +1,330 @@
+/*
+ * T1023 Silicon/SoC Device Tree Source (post include)
+ *
+ * Copyright 2014 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+ifc {
+   #address-cells = 2;
+   #size-cells = 1;
+   compatible = fsl,ifc, simple-bus;
+   interrupts = 25 2 0 0;
+};
+
+pci0 {
+   compatible = fsl,t1023-pcie, fsl,qoriq-pcie-v2.4, fsl,qoriq-pcie;
+   device_type = pci;
+   #size-cells = 2;
+   #address-cells = 3;
+   bus-range = 0x0 0xff;
+   interrupts = 20 2 0 0;
+   fsl,iommu-parent = pamu0;
+   pcie@0 {
+   reg = 0 0 0 0 0;
+   #interrupt-cells = 1;
+   #size-cells = 2;
+   #address-cells = 3;
+   device_type = pci;
+   interrupts = 20 2 0 0;
+   interrupt-map-mask = 0xf800 0 0 7;
+   interrupt-map = 
+   /* IDSEL 0x0 */
+    0 0 1 mpic 40 1 0 0
+    0 0 2 mpic 1 1 0 0
+    0 0 3 mpic 2 1 0 0
+    0 0 4 mpic 3 1 0 0
+   ;
+   };
+};
+
+pci1 {
+   compatible = fsl,t1023-pcie, fsl,qoriq-pcie-v2.4, fsl,qoriq-pcie;
+   device_type = pci;
+ 

Re: [v3, 01/11] powerpc/8xx: remove remaining unnecessary code in FixupDAR

2015-04-14 Thread Scott Wood
On Tue, 2015-04-14 at 00:19 +0200, leroy christophe wrote:
 
 Le 13/04/2015 22:26, Scott Wood a écrit :
  On Sun, 2015-04-12 at 18:16 +0200, leroy christophe wrote:
  Le 26/03/2015 22:32, Scott Wood a écrit :
  On Tue, Feb 03, 2015 at 12:38:16PM +0100, LEROY Christophe wrote:
  Since commit 33fb845a6f01 (powerpc/8xx: Don't use MD_TWC for walk), 
  MD_EPN and
  MD_TWC are not writen anymore in FixupDAR so saving r3 has become 
  useless.
 
  Signed-off-by: Christophe Leroy christophe.le...@c-s.fr
  ---
  v2: no change
  v3: no change
  This doesn't apply cleanly.
 
 
  You already applied part of that patchset it in your next tree,
  including that one (commit 2374d0a).
  You told me to re-submit a patchset with only the remaining ones,
  therefore I sent v4 on the 4th of Feb, based on your tree.
  OK.  I applied v2, and didn't remember that when I came across v3 in
  patchwork.
 
 
 What about v4 (the remaining ones) ? You got comments on the last one of 
 the set, have you applied the other ones or shall I re-sumbit a full v5 ?

I haven't applied them yet.

-Scott


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [v3] clk: qoriq: Add support for the FMan clock

2015-04-14 Thread Scott Wood
On Tue, 2015-04-14 at 14:15 +0300, Igal.Liberman wrote:
 +static int get_fm_clk_idx(int fm_id, int *fm_clk_idx)
 +{
 + struct ccsr_guts __iomem *guts_regs = NULL;
 + struct device_node *guts;
 + uint32_t reg = 0;
 + int clk_src = 0;
 +
 + guts = of_find_matching_node(NULL, guts_device_ids);
 + if (!guts) {
 + pr_err(could not find GUTS node\n);
 + return -ENODEV;
 + }
 +
 + guts_regs = of_iomap(guts, 0);
 + of_node_put(guts);
 + if (!guts_regs) {
 + pr_err(ioremap of GUTS node failed\n);
 + return -ENODEV;
 + }

Error messages should include more context -- at least __func__.

-Scott


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

RE: [1/3][PATCH][v2] Device Tree bindings for Freescale TDM controller

2015-04-14 Thread sand...@freescale.com
Hi Scott,

Thanks for your comments. Reply inline.

Regards
Sandeep

 -Original Message-
 From: Wood Scott-B07421
 Sent: Friday, April 03, 2015 6:45 AM
 To: Singh Sandeep-B37400
 Cc: linuxppc-...@ozlabs.org
 Subject: Re: [1/3][PATCH][v2] Device Tree bindings for Freescale TDM 
 controller
 
 On Thu, 2015-04-02 at 16:17 +0530, sand...@freescale.com wrote:
  From: Sandeep Singh sand...@freescale.com
 
  This controller is available on many Freescale SOCs like MPC8315,
  P1020, P1010,
  P1022 and P1024
 
  Signed-off-by: Sandeep Singh sand...@freescale.com
  Signed-off-by: Poonam Aggrwal poonam.aggr...@freescale.com
  ---
   Documentation/devicetree/bindings/tdm/fsl-tdm.txt |   65
 +
   1 files changed, 65 insertions(+), 0 deletions(-)  create mode 100644
  Documentation/devicetree/bindings/tdm/fsl-tdm.txt
 
 Add devicet...@vger.kernel.org to CC for device tree patches.
 
 
  diff --git a/Documentation/devicetree/bindings/tdm/fsl-tdm.txt
  b/Documentation/devicetree/bindings/tdm/fsl-tdm.txt
  new file mode 100644
  index 000..1258b89
  --- /dev/null
  +++ b/Documentation/devicetree/bindings/tdm/fsl-tdm.txt
  @@ -0,0 +1,65 @@
 
 +=
 
  +TDM Device Tree Binding
  +Copyright (C) 2012 Freescale Semiconductor Inc.
  +
  +NOTE: The bindings described in this document are preliminary and
  +subject to change.
 
 Get rid of this note.  Bindings are expected to be stable ABI once merged.
 
 
 +=
 
  +TDM (Time Division Multiplexing)
  +
  +DESCRIPTION
  +
  +The TDM is full duplex serial port designed to allow various devices
  +including digital signal processors (DSPs) to communicate with a
  +variety of serial devices including industry standard framers, codecs, 
  other
 DSPs and microprocessors.
  +
  +The below properties describe the device tree bindings for Freescale
  +TDM controller.
  +This TDM controller is available on various Freescale Processors like
  +MPC8313, P1020, P1022 and P1010.
  +
  +PROPERTIES
  +
  +  - compatible
  +  Usage: required
  +  Value type: string
  +  Definition: Should contain fsl,tdm1.0.
 
 What does 1.0 refer to?  Is the TDM block identical on all the chips that 
 currently
 have it?  Is this a real version number scheme (public or
 otherwise) or something made up for software?
[Sandeep] Starlite TDM block is identical on all the chips. This is a software 
only version.
 
  +  - reg
  +  Usage: required
  +  Definition: A standard property. The first reg specifier describes 
  the
  +  TDM registers, and the second describes the TDM DMAC registers.
  +
  +  - clock-frequency
  +  Usage: optional
  +  Value type: u32 or u64
  +  Definition: The frequency at which the TDM block is operating.
 
 It'd be nice if new bindings used clock nodes rather than relying on U-Boot 
 fixups.
[Sandeep] This field is not currently used, but is planned to be used in future.
 
  +  - interrupts
  +  Usage: required
  +  Definition: Definition: Two interrupt specifiers.  The first is TDM
  +  error, and the second is TDM EMAC.
  +
  +  - phy-handle
  +  Usage: optional
  +  Value type: phandle
  +  Definition: Phandle of the line controller node or framer node eg. 
  SLIC,
  +  E1/T1 etc.
  +
  +  - fsl,max-time-slots
  +  Usage: required
  +  Value type: u32
  +  Definition: Maximum number of 8-bit time slots in one TDM frame.
  +  This is the maximum number which TDM hardware supports.
  +
  +EXAMPLE
  +
  +   tdm@16000 {
  +   compatible = fsl,tdm1.0;
  +   reg = 0x16000 0x200 0x2c000 0x2000;
  +   clock-frequency = 0;
  +   interrupts = 16 8 62 8;
  +   phy-handle = zarlink1;
  +   fsl,max-time-slots = 128;
  +   };
 
 The example refers to a zarlink1 node but it is not present.  What does a 
 line
 controller or framer node look like?
[Sandeep] phy-handle again is currently not being used. Added for future use.
 
 -Scott
 

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] powerpc/dts: Update the core cluster PLL node(s)

2015-04-14 Thread Igal . Liberman
From: Igal Liberman igal.liber...@freescale.com

This patch replaces the following:
https://patchwork.ozlabs.org/patch/427664/

This patch is described by the following binding document update:
https://patchwork.ozlabs.org/patch/461150/

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi 
b/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi
index 48e0b6e..7e1f074 100644
--- a/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi
+++ b/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi
@@ -49,14 +49,16 @@ global-utilities@e1000 {
reg = 0x800 0x4;
compatible = fsl,qoriq-core-pll-2.0;
clocks = sysclk;
-   clock-output-names = pll0, pll0-div2, pll0-div4;
+   clock-output-names = pll0, pll0-div2, pll0-div3,
+ pll0-div4;
};
pll1: pll1@820 {
#clock-cells = 1;
reg = 0x820 0x4;
compatible = fsl,qoriq-core-pll-2.0;
clocks = sysclk;
-   clock-output-names = pll1, pll1-div2, pll1-div4;
+   clock-output-names = pll1, pll1-div2, pll1-div3,
+ pll1-div4;
};
platform_pll: platform-pll@c00 {
#clock-cells = 1;
-- 
1.7.9.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 2/2] leds/powernv: Add driver for PowerNV platform

2015-04-14 Thread Jacek Anaszewski

Hi Vasant,

On 03/20/2015 12:04 PM, Vasant Hegde wrote:

From: Anshuman Khandual khand...@linux.vnet.ibm.com

This patch implements LED driver for PowerNV platform using the existing
generic LED class framework. It registers classdev structures for all
individual LEDs detected on the system through LED specific device tree
nodes. Device tree nodes specify what all kind of LEDs present on the
same location code. It registers LED classdev structure for each of them.

The platform level implementation of LED get and set state has been
achieved through OPAL calls. These calls are made available for the
driver by exporting from architecture specific codes.

As per the LED class framework, the 'brightness_set' function should not
sleep. Hence these functions have been implemented through global work
queue tasks which might sleep on OPAL async call completion.


Wouldn't it be easier to implement synchronization on the OPAL side?


All the system LEDs can be found in the same regular path /sys/class/leds/.
There are two different kind of LEDs present for the same location code,
one being the identify indicator and other one being the fault indicator.
We don't use LED colors. Hence our LEDs have names in this format.

 location_code:ATTENTION|IDENTIFY|FAULT

Any positive brightness value would turn on the LED and a zero value
would turn off the LED. The driver will return LED_FULL (255) for any
turned on LED and LED_OFF for any turned off LED.

Signed-off-by: Anshuman Khandual khand...@linux.vnet.ibm.com
Signed-off-by: Vasant Hegde hegdevas...@linux.vnet.ibm.com
Acked-by: Stewart Smith stew...@linux.vnet.ibm.com
Tested-by: Stewart Smith stew...@linux.vnet.ibm.com
---
Changes in v2:
   - Added System Attention indicator support
   - Moved common code to powernv_led_set_queue()

-Vasant


  arch/powerpc/platforms/powernv/opal.c |   12 +
  drivers/leds/Kconfig  |9
  drivers/leds/Makefile |1
  drivers/leds/leds-powernv.c   |  620 +
  4 files changed, 641 insertions(+), 1 deletion(-)
  create mode 100644 drivers/leds/leds-powernv.c

diff --git a/arch/powerpc/platforms/powernv/opal.c 
b/arch/powerpc/platforms/powernv/opal.c
index 142a08a..fbfd9c1 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -746,7 +746,7 @@ static void __init opal_irq_init(struct device_node *dn)

  static int __init opal_init(void)
  {
-   struct device_node *np, *consoles;
+   struct device_node *np, *consoles, *led;
int rc;

opal_node = of_find_node_by_path(/ibm,opal);
@@ -772,6 +772,13 @@ static int __init opal_init(void)
/* Create i2c platform devices */
opal_i2c_create_devs();

+   /* Create led platform devices */
+   led = of_find_node_by_path(/ibm,opal/led);
+   if (led) {
+   of_platform_device_create(led, opal_led, NULL);
+   of_node_put(led);
+   }
+
/* Find all OPAL interrupts and request them */
opal_irq_init(opal_node);

@@ -904,3 +911,6 @@ EXPORT_SYMBOL_GPL(opal_rtc_write);
  EXPORT_SYMBOL_GPL(opal_tpo_read);
  EXPORT_SYMBOL_GPL(opal_tpo_write);
  EXPORT_SYMBOL_GPL(opal_i2c_request);
+/* Export these symbols for PowerNV LED class driver */
+EXPORT_SYMBOL_GPL(opal_leds_get_ind);
+EXPORT_SYMBOL_GPL(opal_leds_set_ind);


Please split the above part to the separate patch and put it in the
series before this one.


diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 25b320d..a93223c 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -508,6 +508,15 @@ config LEDS_BLINKM
  This option enables support for the BlinkM RGB LED connected
  through I2C. Say Y to enable support for the BlinkM LED.

+config LEDS_POWERNV
+   tristate LED support for PowerNV Platform
+   depends on LEDS_CLASS
+   depends on PPC_POWERNV


OF dependency is missing here.


+   help
+ This option enables support for the system LEDs present on
+ PowerNV platforms. Say 'y' to enable this support in kernel.
+ Say 'm' enable this support as module.


Please change the last line to:

To compile this driver as a module, choose M here: the module will
be called leds-powernv.



+
  config LEDS_SYSCON
bool LED support for LEDs on system controllers
depends on LEDS_CLASS=y
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index cbba921..604ffc9 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o
  obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o
  obj-$(CONFIG_LEDS_VERSATILE)  += leds-versatile.o
  obj-$(CONFIG_LEDS_MENF21BMC)  += leds-menf21bmc.o
+obj-$(CONFIG_LEDS_POWERNV) += leds-powernv.o

  # LED SPI Drivers
  obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
diff --git a/drivers/leds/leds-powernv.c 

[PATCH] powerpc: Fix build error seen with powermac smp builds

2015-04-14 Thread Guenter Roeck
powermac smp builds fail with

arch/powerpc/platforms/powermac/smp.c: In function 'smp_psurge_probe':
arch/powerpc/platforms/powermac/smp.c:278:3: error:
'return' with a value, in function returning void

There are several instances of this error.

Cc: Michael Ellerman m...@ellerman.id.au
Fixes: a7f4ee1fe93a (powerpc: Drop return value of smp_ops-probe())
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
Seen in next-20150414.

 arch/powerpc/platforms/powermac/smp.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/platforms/powermac/smp.c 
b/arch/powerpc/platforms/powermac/smp.c
index f84ac7e..28a147c 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -275,7 +275,7 @@ static void __init smp_psurge_probe(void)
 
/* We don't do SMP on the PPC601 -- paulus */
if (PVR_VER(mfspr(SPRN_PVR)) == 1)
-   return 1;
+   return;
 
/*
 * The powersurge cpu board can be used in the generation
@@ -289,7 +289,7 @@ static void __init smp_psurge_probe(void)
 */
dn = of_find_node_by_name(NULL, hammerhead);
if (dn == NULL)
-   return 1;
+   return;
of_node_put(dn);
 
hhead_base = ioremap(HAMMERHEAD_BASE, 0x800);
@@ -310,13 +310,13 @@ static void __init smp_psurge_probe(void)
/* not a dual-cpu card */
iounmap(hhead_base);
psurge_type = PSURGE_NONE;
-   return 1;
+   return;
}
ncpus = 2;
}
 
if (psurge_secondary_ipi_init())
-   return 1;
+   return;
 
psurge_start = ioremap(PSURGE_START, 4);
psurge_pri_intr = ioremap(PSURGE_PRI_INTR, 4);
@@ -332,8 +332,6 @@ static void __init smp_psurge_probe(void)
set_cpu_present(i, true);
 
if (ppc_md.progress) ppc_md.progress(smp_psurge_probe - done, 0x352);
-
-   return ncpus;
 }
 
 static int __init smp_psurge_kick_cpu(int nr)
-- 
2.1.0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] dt/bindings: qoriq-clock: Update core PLL binding

2015-04-14 Thread Scott Wood
On Tue, 2015-04-14 at 12:42 +0300, Igal.Liberman wrote:
 From: Igal Liberman igal.liber...@freescale.com
 
 Added optional divider to fsl,qoriq-core-pll-2.0.
 This option might be used by Freescale hardware accelerators.
 
 Signed-off-by: Igal Liberman igal.liber...@freescale.com
 ---
  .../devicetree/bindings/clock/qoriq-clock.txt  |8 +++-
  1 file changed, 7 insertions(+), 1 deletion(-)
 
 diff --git a/Documentation/devicetree/bindings/clock/qoriq-clock.txt 
 b/Documentation/devicetree/bindings/clock/qoriq-clock.txt
 index df4a259..b0d7b73 100644
 --- a/Documentation/devicetree/bindings/clock/qoriq-clock.txt
 +++ b/Documentation/devicetree/bindings/clock/qoriq-clock.txt
 @@ -68,11 +68,17 @@ Required properties:
  - #clock-cells: From common clock binding. The number of cells in a
   clock-specifier. Should be 0 for fsl,qoriq-sysclk-[1,2].0
   clocks, or 1 for fsl,qoriq-core-pll-[1,2].0 clocks.
 - For fsl,qoriq-core-pll-[1,2].0 clocks, the single
 + For fsl,qoriq-core-pll-1.0 clocks, the single
   clock-specifier cell may take the following values:
   * 0 - equal to the PLL frequency
   * 1 - equal to the PLL frequency divided by 2
   * 2 - equal to the PLL frequency divided by 4
 + For fsl,qoriq-core-pll-2.0 clocks, the single
 + clock-specifier cell may take the following values:
 + * 0 - equal to the PLL frequency
 + * 1 - equal to the PLL frequency divided by 2
 + * 2 - equal to the PLL frequency divided by 3
 + * 3 - equal to the PLL frequency divided by 4

Thanks.  Please update the driver to use the compatible to distinguish
as documented above, rather than the number of clock-output-names.

-Scott


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] powerpc/dts: Update the core cluster PLL node(s)

2015-04-14 Thread Scott Wood
On Tue, 2015-04-14 at 15:21 -0500, Scott Wood wrote:
 On Tue, 2015-04-14 at 12:55 +0300, Igal.Liberman wrote:
  From: Igal Liberman igal.liber...@freescale.com
  
  This patch replaces the following:
  https://patchwork.ozlabs.org/patch/427664/
  
  This patch is described by the following binding document update:
  https://patchwork.ozlabs.org/patch/461150/
  
  Signed-off-by: Igal Liberman igal.liber...@freescale.com
  ---
   arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi |6 --
   1 file changed, 4 insertions(+), 2 deletions(-)
  
  diff --git a/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi 
  b/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi
  index 48e0b6e..7e1f074 100644
  --- a/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi
  +++ b/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi
  @@ -49,14 +49,16 @@ global-utilities@e1000 {
  reg = 0x800 0x4;
  compatible = fsl,qoriq-core-pll-2.0;
  clocks = sysclk;
  -   clock-output-names = pll0, pll0-div2, pll0-div4;
  +   clock-output-names = pll0, pll0-div2, pll0-div3,
  + pll0-div4;
  };
  pll1: pll1@820 {
  #clock-cells = 1;
  reg = 0x820 0x4;
  compatible = fsl,qoriq-core-pll-2.0;
  clocks = sysclk;
  -   clock-output-names = pll1, pll1-div2, pll1-div4;
  +   clock-output-names = pll1, pll1-div2, pll1-div3,
  + pll1-div4;
 
 Wait, so if the driver implements the binding you submitted, you'll
 break compatibility with these older device trees...
 
 I think we need to just accept the ugly count-the-clock-names approach
 and document it.

Is there any current 2.0 clock consumer that references pll-div4?

-Scott

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [RESEND PATCH v3 1/2] mm: Introducing arch_remap hook

2015-04-14 Thread Andrew Morton
On Tue, 14 Apr 2015 11:26:13 +0200 Laurent Dufour lduf...@linux.vnet.ibm.com 
wrote:

  Do away with __HAVE_ARCH_REMAP and do it like this:
  
  arch/x/include/asm/y.h:
  
  extern void arch_remap(...);
  #define arch_remap arch_remap
  
  include/linux/z.h:
  
  #include asm/y.h
  
  #ifndef arch_remap
  static inline void arch_remap(...) { }
  #define arch_remap arch_remap
  #endif
 
 Hi Andrew,
 
 I like your idea, but I can't find any good candidate for asm/y.h and
 linux/z.h.
 
 I tried with linux/mm.h and asm/mmu_context.h but
 asm/mmu_context.h is already including linux/mm.h.
 
 Do you have any suggestion ?
 
 Another option could be to do it like the actual arch_unmap() in
 asm-generic/mm_hooks.h but this is the opposite of your idea, and Ingo
 was not comfortable with this idea due to the impact of the other
 architectures.

I don't see any appropriate header files for this.  mman.h is kinda
close.

So we create new header files, that's not a problem.  I'm torn between

a) include/linux/mm-arch-hooks.h (and 31
   arch/X/include/asm/mm-arch-hooks.h).  Mandate: mm stuff which can be
   overridded by arch

versus

b) include/linux/mremap.h (+31), with a narrower mandate.


This comes up fairly regularly so I suspect a) is better.  We'll add
things to it over time, and various bits of existing ad-hackery can be
moved over as cleanups.

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] powerpc/dts: Update the core cluster PLL node(s)

2015-04-14 Thread Scott Wood
On Tue, 2015-04-14 at 12:55 +0300, Igal.Liberman wrote:
 From: Igal Liberman igal.liber...@freescale.com
 
 This patch replaces the following:
   https://patchwork.ozlabs.org/patch/427664/
 
 This patch is described by the following binding document update:
   https://patchwork.ozlabs.org/patch/461150/
 
 Signed-off-by: Igal Liberman igal.liber...@freescale.com
 ---
  arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi |6 --
  1 file changed, 4 insertions(+), 2 deletions(-)
 
 diff --git a/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi 
 b/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi
 index 48e0b6e..7e1f074 100644
 --- a/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi
 +++ b/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi
 @@ -49,14 +49,16 @@ global-utilities@e1000 {
   reg = 0x800 0x4;
   compatible = fsl,qoriq-core-pll-2.0;
   clocks = sysclk;
 - clock-output-names = pll0, pll0-div2, pll0-div4;
 + clock-output-names = pll0, pll0-div2, pll0-div3,
 +   pll0-div4;
   };
   pll1: pll1@820 {
   #clock-cells = 1;
   reg = 0x820 0x4;
   compatible = fsl,qoriq-core-pll-2.0;
   clocks = sysclk;
 - clock-output-names = pll1, pll1-div2, pll1-div4;
 + clock-output-names = pll1, pll1-div2, pll1-div3,
 +   pll1-div4;

Wait, so if the driver implements the binding you submitted, you'll
break compatibility with these older device trees...

I think we need to just accept the ugly count-the-clock-names approach
and document it.

-Scott


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [v2] dt/bindings: fsl/guts: Added global-utilities compatibles

2015-04-14 Thread Scott Wood
On Tue, 2015-04-14 at 13:12 +0300, Igal.Liberman wrote:
 From: Igal Liberman igal.liber...@freescale.com
 
 v2 - Addressed Scott's feedback
 
 Signed-off-by: Igal Liberman igal.liber...@freescale.com
 ---
  .../devicetree/bindings/powerpc/fsl/guts.txt   |4 
  1 file changed, 4 insertions(+)
 
 diff --git a/Documentation/devicetree/bindings/powerpc/fsl/guts.txt 
 b/Documentation/devicetree/bindings/powerpc/fsl/guts.txt
 index 7f150b5..69644e6 100644
 --- a/Documentation/devicetree/bindings/powerpc/fsl/guts.txt
 +++ b/Documentation/devicetree/bindings/powerpc/fsl/guts.txt
 @@ -9,6 +9,10 @@ Required properties:
  
   - compatible : Should define the compatible device type for
 global-utilities.
 +   Possible compatibles:
 + fsl,qoriq-device-config-1.0
 + fsl,qoriq-device-config-2.0
 + fsl,chip-device-config

fsl,chip-guts is also possible on non-corenet chips.

-Scott


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [1/3][PATCH][v2] Device Tree bindings for Freescale TDM controller

2015-04-14 Thread Scott Wood
On Tue, 2015-04-14 at 08:50 -0500, Singh Sandeep-B37400 wrote:
   +TDM (Time Division Multiplexing)
   +
   +DESCRIPTION
   +
   +The TDM is full duplex serial port designed to allow various devices
   +including digital signal processors (DSPs) to communicate with a
   +variety of serial devices including industry standard framers, codecs, 
   other
  DSPs and microprocessors.
   +
   +The below properties describe the device tree bindings for Freescale
   +TDM controller.
   +This TDM controller is available on various Freescale Processors like
   +MPC8313, P1020, P1022 and P1010.
   +
   +PROPERTIES
   +
   +  - compatible
   +  Usage: required
   +  Value type: string
   +  Definition: Should contain fsl,tdm1.0.
  
  What does 1.0 refer to?  Is the TDM block identical on all the chips that 
  currently
  have it?  Is this a real version number scheme (public or
  otherwise) or something made up for software?
 [Sandeep] Starlite TDM block is identical on all the chips. This is a 
 software only version.

Then I recommend arbitrarily picking one of the chips and naming the
compatible after that: fsl,mpc8313-tdm.

   +  - reg
   +  Usage: required
   +  Definition: A standard property. The first reg specifier describes 
   the
   +  TDM registers, and the second describes the TDM DMAC registers.
   +
   +  - clock-frequency
   +  Usage: optional
   +  Value type: u32 or u64
   +  Definition: The frequency at which the TDM block is operating.
  
  It'd be nice if new bindings used clock nodes rather than relying on U-Boot 
  fixups.
 [Sandeep] This field is not currently used, but is planned to be used in 
 future.

I don't see how that answers my request.

   +EXAMPLE
   +
   + tdm@16000 {
   + compatible = fsl,tdm1.0;
   + reg = 0x16000 0x200 0x2c000 0x2000;
   + clock-frequency = 0;
   + interrupts = 16 8 62 8;
   + phy-handle = zarlink1;
   + fsl,max-time-slots = 128;
   + };
  
  The example refers to a zarlink1 node but it is not present.  What does a 
  line
  controller or framer node look like?
 [Sandeep] phy-handle again is currently not being used. Added for future use.

Please submit a complete binding.

-Scott


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 4/5] ibmveth: Add support for Large Receive Offload

2015-04-14 Thread Thomas Falcon
Enables receiving large packets from other LPARs. These packets
have a -1 IP header checksum, so we must recalculate to have
a valid checksum.

Signed-off-by: Brian King brk...@linux.vnet.ibm.com
Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com
---
 drivers/net/ethernet/ibm/ibmveth.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ibm/ibmveth.c 
b/drivers/net/ethernet/ibm/ibmveth.c
index 08970c7..05eaca6a 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1092,6 +1092,7 @@ static int ibmveth_poll(struct napi_struct *napi, int 
budget)
struct net_device *netdev = adapter-netdev;
int frames_processed = 0;
unsigned long lpar_rc;
+   struct iphdr *iph;
 
 restart_poll:
while (frames_processed  budget) {
@@ -1134,8 +1135,20 @@ restart_poll:
skb_put(skb, length);
skb-protocol = eth_type_trans(skb, netdev);
 
-   if (csum_good)
+   if (csum_good) {
skb-ip_summed = CHECKSUM_UNNECESSARY;
+   if (be16_to_cpu(skb-protocol) == ETH_P_IP) {
+   skb_set_network_header(skb, 0);
+   skb_set_transport_header(skb, 
sizeof(struct iphdr));
+   iph = ip_hdr(skb);
+
+   /* If the IP checksum is not offloaded 
and if the packet
+*  is large send, the checksum must be 
rebuilt.
+*/
+   if (iph-check == 0x)
+   iph-check = 
ip_fast_csum((unsigned char *)iph, iph-ihl);
+   }
+   }
 
napi_gro_receive(napi, skb);/* send it up */
 
-- 
1.8.3.1

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [v2] powerpc/dts: Add some SoC specific fsl,*-device-config compatibles

2015-04-14 Thread Scott Wood
On Tue, 2015-04-14 at 13:25 +0300, Igal.Liberman wrote:
 From: Igal Liberman igal.liber...@freescale.com
 
 This patch adds fsl,chip-device-config compatibles to guts node.
 The added compatibles used in Freescale FMan clock initialization.
  
 This patches is described by the following binding document update:
   https://patchwork.ozlabs.org/patch/461153/
 
 v2: Updated commit message
 
 Signed-off-by: Igal Liberman igal.liber...@freescale.com
 ---
  arch/powerpc/boot/dts/fsl/b4420si-post.dtsi |3 ++-
  arch/powerpc/boot/dts/fsl/b4860si-post.dtsi |3 ++-
  arch/powerpc/boot/dts/fsl/b4si-post.dtsi|3 ++-
  arch/powerpc/boot/dts/fsl/p2041si-post.dtsi |3 ++-
  arch/powerpc/boot/dts/fsl/p3041si-post.dtsi |3 ++-
  arch/powerpc/boot/dts/fsl/p4080si-post.dtsi |3 ++-
  arch/powerpc/boot/dts/fsl/p5020si-post.dtsi |3 ++-
  7 files changed, 14 insertions(+), 7 deletions(-)
 
 diff --git a/arch/powerpc/boot/dts/fsl/b4420si-post.dtsi 
 b/arch/powerpc/boot/dts/fsl/b4420si-post.dtsi
 index 1ea8602..9b14f24 100644
 --- a/arch/powerpc/boot/dts/fsl/b4420si-post.dtsi
 +++ b/arch/powerpc/boot/dts/fsl/b4420si-post.dtsi
 @@ -77,7 +77,8 @@
   };
  
   guts: global-utilities@e {
 - compatible = fsl,b4420-device-config, 
 fsl,qoriq-device-config-2.0;
 + compatible = fsl,b4420-device-config, fsl,b4-device-config,
 +   fsl,qoriq-device-config-2.0;
   };

I thought you said you were going to drop this?  Please just use the
existing compatibles.

-Scott


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: 'perf upgrade' (was: Re: [PATCH v9 00/11] Add support for JSON event files.)

2015-04-14 Thread Andi Kleen
On Tue, Apr 14, 2015 at 10:55:41AM +0200, Ingo Molnar wrote:
 
 * Sukadev Bhattiprolu suka...@linux.vnet.ibm.com wrote:
 
  This is another attempt to resurrect Andi Kleen's patchset so users
  can specify perf events by their event names rather than raw codes.
  
  This is a rebase of Andi Kleen's patchset from Jul 30, 2014[1] to 4.0.
  (I fixed minor and not so minor conflicts).
 
 So this series shows some progress, but instead of this limited 
 checkout ability I'd still prefer it if 'perf download' downloaded the 
 latest perf code itself and built it - it shouldn't be limited to just 
 a small subset of the perf source code!

I'm not against that idea (and can see it being useful in some cases[1]), 
but this would need some authentication. 

Otherwise it would be a $bigbrother/nsa/anyone controling your network
can run everything on your computer style hole.

The original JSON files don't have this problem because they didn't contain
any code.

-Andi

[1] especially to work around the broken perf setup on d./u. distros.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 2/5] ibmveth: Add support for TSO

2015-04-14 Thread Thomas Falcon
Add support for TSO.  TSO is turned off by default and
must be enabled and configured by the user.  The driver
version number is increased so that users can be sure
that they are using ibmveth with TSO support.

Cc: Brian King brk...@linux.vnet.ibm.com
Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com
---
 drivers/net/ethernet/ibm/ibmveth.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ibm/ibmveth.c 
b/drivers/net/ethernet/ibm/ibmveth.c
index 0210622..2911a57 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -58,7 +58,7 @@ static struct kobj_type ktype_veth_pool;
 
 static const char ibmveth_driver_name[] = ibmveth;
 static const char ibmveth_driver_string[] = IBM Power Virtual Ethernet 
Driver;
-#define ibmveth_driver_version 1.04
+#define ibmveth_driver_version 1.05
 
 MODULE_AUTHOR(Santiago Leon san...@linux.vnet.ibm.com);
 MODULE_DESCRIPTION(IBM Power Virtual Ethernet Driver);
@@ -852,6 +852,10 @@ static int ibmveth_set_features(struct net_device *dev,
struct ibmveth_adapter *adapter = netdev_priv(dev);
int rx_csum = !!(features  NETIF_F_RXCSUM);
int rc;
+   netdev_features_t changed = features ^ dev-features;
+
+   if (features  NETIF_F_TSO  changed)
+   netdev_info(dev, TSO feature requires all partitions to have 
updated driver);
 
if (rx_csum == adapter-rx_csum)
return 0;
@@ -1035,6 +1039,14 @@ retry_bounce:
descs[i+1].fields.address = dma_addr;
}
 
+   if (skb_is_gso(skb)  !skb_is_gso_v6(skb)) {
+   /* Put -1 in the IP checksum to tell phyp it
+*  is a largesend packet and put the mss in the TCP checksum.
+*/
+   ip_hdr(skb)-check = 0x;
+   tcp_hdr(skb)-check = cpu_to_be16(skb_shinfo(skb)-gso_size);
+   }
+
if (ibmveth_send(adapter, descs)) {
adapter-tx_send_failed++;
netdev-stats.tx_dropped++;
@@ -1422,6 +1434,9 @@ static int ibmveth_probe(struct vio_dev *dev, const 
struct vio_device_id *id)
NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
netdev-features |= netdev-hw_features;
 
+   /* TSO is disabled by default */
+   netdev-hw_features |= NETIF_F_TSO;
+
memcpy(netdev-dev_addr, mac_addr_p, ETH_ALEN);
 
if (firmware_has_feature(FW_FEATURE_CMO))
-- 
1.8.3.1

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 3/5] ibmveth: Add GRO support

2015-04-14 Thread Thomas Falcon
Cc: Brian King brk...@linux.vnet.ibm.com
Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com
---
 drivers/net/ethernet/ibm/ibmveth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ibm/ibmveth.c 
b/drivers/net/ethernet/ibm/ibmveth.c
index 2911a57..08970c7 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1137,7 +1137,7 @@ restart_poll:
if (csum_good)
skb-ip_summed = CHECKSUM_UNNECESSARY;
 
-   netif_receive_skb(skb); /* send it up */
+   napi_gro_receive(napi, skb);/* send it up */
 
netdev-stats.rx_packets++;
netdev-stats.rx_bytes += length;
-- 
1.8.3.1

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 1/5] ibmveth: change rx buffer default allocation for CMO

2015-04-14 Thread Thomas Falcon
This patch enables 64k rx buffer pools by default.  If Cooperative
Memory Overcommitment (CMO) is enabled, the number of 64k buffers
is reduced to save memory.

Cc: Brian King brk...@linux.vnet.ibm.com
Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com
---
 drivers/net/ethernet/ibm/ibmveth.c | 3 +++
 drivers/net/ethernet/ibm/ibmveth.h | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ibm/ibmveth.c 
b/drivers/net/ethernet/ibm/ibmveth.c
index cd7675a..0210622 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1424,6 +1424,9 @@ static int ibmveth_probe(struct vio_dev *dev, const 
struct vio_device_id *id)
 
memcpy(netdev-dev_addr, mac_addr_p, ETH_ALEN);
 
+   if (firmware_has_feature(FW_FEATURE_CMO))
+   memcpy(pool_count, pool_count_cmo, sizeof(pool_count));
+
for (i = 0; i  IBMVETH_NUM_BUFF_POOLS; i++) {
struct kobject *kobj = adapter-rx_buff_pool[i].kobj;
int error;
diff --git a/drivers/net/ethernet/ibm/ibmveth.h 
b/drivers/net/ethernet/ibm/ibmveth.h
index 1f37499..0dc664b 100644
--- a/drivers/net/ethernet/ibm/ibmveth.h
+++ b/drivers/net/ethernet/ibm/ibmveth.h
@@ -104,7 +104,8 @@ static inline long h_illan_attributes(unsigned long 
unit_address,
 
 static int pool_size[] = { 512, 1024 * 2, 1024 * 16, 1024 * 32, 1024 * 64 };
 static int pool_count[] = { 256, 512, 256, 256, 256 };
-static int pool_active[] = { 1, 1, 0, 0, 0};
+static int pool_count_cmo[] = { 256, 512, 256, 256, 64 };
+static int pool_active[] = { 1, 1, 0, 0, 1};
 
 #define IBM_VETH_INVALID_MAP ((u16)0x)
 
-- 
1.8.3.1

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 5/5] ibmveth: Add ethtool statistics for tx and rx large packets

2015-04-14 Thread Thomas Falcon
This patch includes counters for transmitted and received large
packets.

Cc: Brian King brk...@linux.vnet.ibm.com
Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com
---
 drivers/net/ethernet/ibm/ibmveth.c | 4 
 drivers/net/ethernet/ibm/ibmveth.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/ibm/ibmveth.c 
b/drivers/net/ethernet/ibm/ibmveth.c
index 05eaca6a..39ab41e 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -100,6 +100,8 @@ struct ibmveth_stat ibmveth_stats[] = {
{ tx_send_failed, IBMVETH_STAT_OFF(tx_send_failed) },
{ fw_enabled_ipv4_csum, IBMVETH_STAT_OFF(fw_ipv4_csum_support) },
{ fw_enabled_ipv6_csum, IBMVETH_STAT_OFF(fw_ipv6_csum_support) },
+   { tx_large_packets, IBMVETH_STAT_OFF(tx_large_packets) },
+   { rx_large_packets, IBMVETH_STAT_OFF(rx_large_packets) }
 };
 
 /* simple methods of getting data from the current rxq entry */
@@ -1045,6 +1047,7 @@ retry_bounce:
 */
ip_hdr(skb)-check = 0x;
tcp_hdr(skb)-check = cpu_to_be16(skb_shinfo(skb)-gso_size);
+   adapter-tx_large_packets++;
}
 
if (ibmveth_send(adapter, descs)) {
@@ -1147,6 +1150,7 @@ restart_poll:
 */
if (iph-check == 0x)
iph-check = 
ip_fast_csum((unsigned char *)iph, iph-ihl);
+   adapter-rx_large_packets++;
}
}
 
diff --git a/drivers/net/ethernet/ibm/ibmveth.h 
b/drivers/net/ethernet/ibm/ibmveth.h
index 0dc664b..41dedb1 100644
--- a/drivers/net/ethernet/ibm/ibmveth.h
+++ b/drivers/net/ethernet/ibm/ibmveth.h
@@ -161,6 +161,8 @@ struct ibmveth_adapter {
 u64 rx_no_buffer;
 u64 tx_map_failed;
 u64 tx_send_failed;
+u64 tx_large_packets;
+u64 rx_large_packets;
 };
 
 /*
-- 
1.8.3.1

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 4/5] ibmveth: Add support for Large Receive Offload

2015-04-14 Thread Eric Dumazet
On Tue, 2015-04-14 at 15:35 -0500, Thomas Falcon wrote:
 Enables receiving large packets from other LPARs. These packets
 have a -1 IP header checksum, so we must recalculate to have
 a valid checksum.
 
 Signed-off-by: Brian King brk...@linux.vnet.ibm.com
 Signed-off-by: Thomas Falcon tlfal...@linux.vnet.ibm.com
 ---
  drivers/net/ethernet/ibm/ibmveth.c | 15 ++-
  1 file changed, 14 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/net/ethernet/ibm/ibmveth.c 
 b/drivers/net/ethernet/ibm/ibmveth.c
 index 08970c7..05eaca6a 100644
 --- a/drivers/net/ethernet/ibm/ibmveth.c
 +++ b/drivers/net/ethernet/ibm/ibmveth.c
 @@ -1092,6 +1092,7 @@ static int ibmveth_poll(struct napi_struct *napi, int 
 budget)
   struct net_device *netdev = adapter-netdev;
   int frames_processed = 0;
   unsigned long lpar_rc;
 + struct iphdr *iph;
  
  restart_poll:
   while (frames_processed  budget) {
 @@ -1134,8 +1135,20 @@ restart_poll:
   skb_put(skb, length);
   skb-protocol = eth_type_trans(skb, netdev);
  
 - if (csum_good)
 + if (csum_good) {
   skb-ip_summed = CHECKSUM_UNNECESSARY;
 + if (be16_to_cpu(skb-protocol) == ETH_P_IP) {
 + skb_set_network_header(skb, 0);
 + skb_set_transport_header(skb, 
 sizeof(struct iphdr));
 + iph = ip_hdr(skb);
 +
 + /* If the IP checksum is not offloaded 
 and if the packet
 +  *  is large send, the checksum must be 
 rebuilt.
 +  */
 + if (iph-check == 0x)
 + iph-check = 
 ip_fast_csum((unsigned char *)iph, iph-ihl);


How can this possibly work ?

Normally you would have to set iph-check to 0 before calling
ip_fast_csum(), as done in ip_send_check()


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 2/2] powerpc/cell: Fix iommu breakage caused by controller_ops change

2015-04-14 Thread Daniel Axtens
On Tue, 2015-04-14 at 16:49 +1000, Michael Ellerman wrote:
 The recent patch to convert cell to use pci_controller_ops had a small
 bug which broke machines using an iommu.
 
Oops.

 The set of phb-controller_ops was added after the check for name !=
 pci, meaning pcix/pcie PHBs weren't getting their ops set correctly.
 
 Fixes: 9c1368fc50e7 (powerpc/cell: Move controller ops from ppc_md to 
 controller_ops)
 Signed-off-by: Michael Ellerman m...@ellerman.id.au


Thanks for that.

Acked-by: Daniel Axtens d...@axtens.net

Regards,
Daniel


signature.asc
Description: This is a digitally signed message part
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: 'perf upgrade' (was: Re: [PATCH v9 00/11] Add support for JSON event files.)

2015-04-14 Thread Michael Ellerman
On Tue, 2015-04-14 at 14:58 +0200, Ingo Molnar wrote:
 * Michael Ellerman m...@ellerman.id.au wrote:
 
  On Tue, 2015-04-14 at 10:55 +0200, Ingo Molnar wrote:
   * Sukadev Bhattiprolu suka...@linux.vnet.ibm.com wrote:
   
This is another attempt to resurrect Andi Kleen's patchset so users
can specify perf events by their event names rather than raw codes.

This is a rebase of Andi Kleen's patchset from Jul 30, 2014[1] to 4.0.
(I fixed minor and not so minor conflicts).
   
   So this series shows some progress, but instead of this limited 
   checkout ability I'd still prefer it if 'perf download' downloaded 
   the latest perf code itself and built it - it shouldn't be limited 
   to just a small subset of the perf source code!
  
  Ingo, can you please stop blocking this? It's getting ridiculous.
  
  We've been waiting over 8 months for this to go in.
 
 We just merged a patch series that was first sent in 2013. Some things 
 take time to get right.

The first attempt to get symbolic event name support into perf was sent in
2010, that's FIVE years ago [1].

And what complicated feature are we asking for? The ability to map a human
readable name to a hex code, it has the complexity of a first year programming
assignment.

Variations have been submitted by IBM [1], by Facebook [2], now by Intel, and
Google have just given up and carry the libpfm4 patch in their perf tool [3].

Can we please just get this merged.

If you *then* want to add support for perf auto-updating that's fine, but don't
conflate the two.
 
cheers


[1]: https://lkml.org/lkml/2010/3/11/146
[2]: http://article.gmane.org/gmane.comp.linux.perfmon2.devel/2912
[3]: 
https://github.com/David-Levinthal/gooda/blob/master/gooda-analyzer/perf-patches/linux-v3.17/0001-perf-tools-add-support-for-libpfm4.patch


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: 'perf upgrade' (was: Re: [PATCH v9 00/11] Add support for JSON event files.)

2015-04-14 Thread Ingo Molnar

* Michael Ellerman m...@ellerman.id.au wrote:

 On Tue, 2015-04-14 at 10:55 +0200, Ingo Molnar wrote:
  * Sukadev Bhattiprolu suka...@linux.vnet.ibm.com wrote:
  
   This is another attempt to resurrect Andi Kleen's patchset so users
   can specify perf events by their event names rather than raw codes.
   
   This is a rebase of Andi Kleen's patchset from Jul 30, 2014[1] to 4.0.
   (I fixed minor and not so minor conflicts).
  
  So this series shows some progress, but instead of this limited 
  checkout ability I'd still prefer it if 'perf download' downloaded 
  the latest perf code itself and built it - it shouldn't be limited 
  to just a small subset of the perf source code!
 
 Ingo, can you please stop blocking this? It's getting ridiculous.
 
 We've been waiting over 8 months for this to go in.

We just merged a patch series that was first sent in 2013. Some things 
take time to get right.

 While we've been waiting most of our users have learnt to use operf 
 instead, which doesn't require raw codes.
 
 I would also add that exactly zero users have asked for a feature 
 where perf downloads and rebuilds itself. In fact many of them would 
 consider that a security breach.

Fetching tracing scripts, plugins or other instrumentation scripts can 
be considered a 'security breach' as well. Fetching external tables 
(or network access to begin with) can be considered a 'security 
breach' as well, depending on how restricted an environment is.

But we don't design our code based on the most restrictive 
environments that are hostile to open source concepts!

Unfortunate users that are not allowed to update open source code that 
they are using should probably not update it. The other 99.9% of perf 
users would benefit from a properly done upgrading/updating feature.

Please stop thinking in terms of restricted, closed environments. 
Packaged perf will still work fine for them, and changes will still 
trickle down to them.

Thanks,

Ingo
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH 1/5] ibmveth: change rx buffer default allocation for CMO

2015-04-14 Thread David Miller

The net-next tree is closed, so new feature submissions are not appropriate at 
this
time.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev