Re: [PATCH] cpufreq: powernv: Register the driver with reboot notifier

2014-08-18 Thread Viresh Kumar
On 14 August 2014 16:49, Shilpasri G Bhat
shilpa.b...@linux.vnet.ibm.com wrote:
 This patch ensures the cpus to kexec/reboot at nominal frequency.
 Nominal frequency is the highest cpu frequency on PowerPC at
 which the cores can run without getting throttled.

 If the host kernel had set the cpus to a low pstate and then it
 kexecs/reboots to a cpufreq disabled kernel it would cause the target
 kernel to perform poorly. It will also increase the boot up time of
 the target kernel. So set the cpus to high pstate, in this case to
 nominal frequency before rebooting to avoid such scenarios.

 The reboot notifier will suspend the cpufreq governor and enable
 nominal frequency to be set during a reboot/kexec similar to the
 suspend operartion.

 Signed-off-by: Shilpasri G Bhat shilpa.b...@linux.vnet.ibm.com
 Reviewed-by: Preeti U Murthy pre...@linux.vnet.ibm.com
 ---
  drivers/cpufreq/powernv-cpufreq.c | 16 
  1 file changed, 16 insertions(+)

 diff --git a/drivers/cpufreq/powernv-cpufreq.c 
 b/drivers/cpufreq/powernv-cpufreq.c
 index 379c083..e9f3d3a 100644
 --- a/drivers/cpufreq/powernv-cpufreq.c
 +++ b/drivers/cpufreq/powernv-cpufreq.c
 @@ -26,6 +26,7 @@
  #include linux/cpufreq.h
  #include linux/smp.h
  #include linux/of.h
 +#include linux/reboot.h

  #include asm/cputhreads.h
  #include asm/firmware.h
 @@ -314,9 +315,21 @@ static int powernv_cpufreq_cpu_init(struct 
 cpufreq_policy *policy)
 for (i = 0; i  threads_per_core; i++)
 cpumask_set_cpu(base + i, policy-cpus);

 +   policy-suspend_freq = pstate_id_to_freq(powernv_pstate_info.nominal);
 return cpufreq_table_validate_and_show(policy, powernv_freqs);
  }

 +static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
 +   unsigned long action, void *unused)
 +{
 +   cpufreq_suspend();
 +   return NOTIFY_DONE;
 +}
 +
 +static struct notifier_block powernv_cpufreq_reboot_nb = {
 +   .notifier_call = powernv_cpufreq_reboot_notifier,
 +};
 +
  static struct cpufreq_driver powernv_cpufreq_driver = {
 .name   = powernv-cpufreq,
 .flags  = CPUFREQ_CONST_LOOPS,
 @@ -325,6 +338,7 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
 .target_index   = powernv_cpufreq_target_index,
 .get= powernv_cpufreq_get,
 .attr   = powernv_cpu_freq_attr,
 +   .suspend= cpufreq_generic_suspend,

I couldn't understand why you have added a notifier here. This callback
by itself should be enough. Isn't it?

And then you have called cpufreq_suspend(), which is absolutely wrong,
from that notifier..
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [GIT PULL 00/18] perf/core improvements and fixes

2014-08-18 Thread Ingo Molnar

* Arnaldo Carvalho de Melo a...@kernel.org wrote:

 Hi Ingo,
 
   Please consider pulling,
 
 - Arnaldo
 
 The following changes since commit f373da34282560c60f0c197690eecb1b2dc49fc0:
 
   Merge tag 'perf-core-for-mingo' of 
 git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core 
 (2014-08-14 10:38:40 +0200)
 
 are available in the git repository at:
 
 
   git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git 
 tags/perf-core-for-mingo
 
 for you to fetch changes up to 759e612bf96627b64fcafe4174b3f6f2dedf2c0d:
 
   perf stat: Use strerror_r instead of strerror (2014-08-15 13:08:40 -0300)
 
 
 perf/core improvements and fixes:
 
 User visible:
 
 . Warn user to rebuild target with debuginfo in 'perf probe' (Masami 
 Hiramatsu)
 
 . Don't truncate Intel style addresses in 'annotate'. (Alex Converse)
 
 Developer stuff:
 
 . Annotate PMU related list_head members with type info. (Cody P Schafer)
 
 . Add the triplet used for arm64 by Android (Elliott Hughes)
 
 . Replace thread unsafe strerror() with strerror_r() accross the
   whole tools/perf/ tree (Masami Hiramatsu)
 
 Signed-off-by: Arnaldo Carvalho de Melo a...@redhat.com
 
 
 Alex Converse (1):
   perf annotate: Don't truncate Intel style addresses
 
 Cody P Schafer (1):
   perf tools: Annotate PMU related list_head members with type info
 
 Elliott Hughes (1):
   perf tools: Add arm64 triplets
 
 Masami Hiramatsu (14):
   perf probe: Warn user to rebuild target with debuginfo
   perf probe: Don't use strerror if strlist__add failed
   perf: Use strerror_r instead of strerror
   perf probe: Make error messages thread-safe
   perf util: Replace strerror with strerror_r for thread-safety
   perf top: Use strerror_r instead of strerror
   perf trace: Use strerror_r instead of strerror
   perf record: Use strerror_r instead of strerror
   perf test: Use strerror_r instead of strerror
   perf sched: Use strerror_r instead of strerror
   perf buildid-cache: Use strerror_r instead of strerror
   perf kvm: Use strerror_r instead of strerror
   perf help: Use strerror_r instead of strerror
   perf stat: Use strerror_r instead of strerror
 
 Namhyung Kim (1):
   perf report: Relax -g option parsing not to limit the option order
 
  tools/perf/arch/common.c  |  9 +++
  tools/perf/builtin-buildid-cache.c|  7 ++-
  tools/perf/builtin-help.c | 20 +--
  tools/perf/builtin-kvm.c  |  7 ++-
  tools/perf/builtin-probe.c|  5 +-
  tools/perf/builtin-record.c   |  7 ++-
  tools/perf/builtin-sched.c|  4 +-
  tools/perf/builtin-stat.c |  2 +-
  tools/perf/builtin-top.c  |  2 +-
  tools/perf/builtin-trace.c|  6 +-
  tools/perf/perf.c | 10 +++-
  tools/perf/tests/builtin-test.c   |  4 +-
  tools/perf/tests/mmap-basic.c |  7 ++-
  tools/perf/tests/open-syscall-all-cpus.c  |  5 +-
  tools/perf/tests/open-syscall-tp-fields.c |  7 ++-
  tools/perf/tests/open-syscall.c   |  3 +-
  tools/perf/tests/perf-record.c| 13 +++--
  tools/perf/tests/rdpmc.c  |  6 +-
  tools/perf/tests/sw-clock.c   |  6 +-
  tools/perf/tests/task-exit.c  |  6 +-
  tools/perf/util/annotate.c| 12 +++-
  tools/perf/util/callchain.c   | 95 
 +--
  tools/perf/util/cloexec.c |  6 +-
  tools/perf/util/data.c|  8 ++-
  tools/perf/util/debug.h   |  3 +
  tools/perf/util/dso.c |  8 ++-
  tools/perf/util/evlist.c  |  2 +-
  tools/perf/util/evsel.c   |  7 ++-
  tools/perf/util/parse-events.c|  5 +-
  tools/perf/util/pmu.c |  4 +-
  tools/perf/util/pmu.h |  6 +-
  tools/perf/util/probe-event.c | 75 +---
  tools/perf/util/probe-finder.c|  7 ++-
  tools/perf/util/run-command.c |  9 ++-
  tools/perf/util/util.c|  5 +-
  35 files changed, 234 insertions(+), 154 deletions(-)

Pulled, thanks a lot Arnaldo!

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

[PATCH V1 1/3] ASoC: fsl: Kconfig: remove dependence of SND_IMX_SOC for SND_SOC_IMX_PCM_DMA

2014-08-18 Thread Shengjiu Wang
Build kernel with SND_SOC_IMC_PCM_DMA=m  SND_IMX_SOC=n leads the following
error:

   sound/built-in.o: In function `fsl_sai_probe':
 fsl_sai.c:(.text+0x5f662): undefined reference to `imx_pcm_dma_init'
   sound/built-in.o: In function `fsl_esai_probe':
 fsl_esai.c:(.text+0x6044b): undefined reference to `imx_pcm_dma_init'

Most cpu driver in soc/fsl has use the function 'imx_pcm_dma_init' which is
defined in imx-pcm-dma.c, so need to select SND_SOC_IMX_PCM_DMA, but it depends
on SND_IMX_SOC, if SND_IMX_SOC=n, then SND_SOC_IMX_PCM_DMA will not be
selected.
So remove the dependence of SND_IMX_SOC for SND_SOC_IMX_PCM_DMA.

Reported-by: kbuild test robot fengguang...@intel.com
Signed-off-by: Shengjiu Wang shengjiu.w...@freescale.com
---
 sound/soc/fsl/Kconfig |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 5ae777a..3a3732c 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -15,7 +15,7 @@ config SND_SOC_FSL_ASRC
 config SND_SOC_FSL_SAI
tristate Synchronous Audio Interface (SAI) module support
select REGMAP_MMIO
-   select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n
+   select SND_SOC_IMX_PCM_DMA
select SND_SOC_GENERIC_DMAENGINE_PCM
help
  Say Y if you want to add Synchronous Audio Interface (SAI)
@@ -25,7 +25,7 @@ config SND_SOC_FSL_SAI
 
 config SND_SOC_FSL_SSI
tristate Synchronous Serial Interface module support
-   select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n
+   select SND_SOC_IMX_PCM_DMA
select SND_SOC_IMX_PCM_FIQ if SND_IMX_SOC != n  (MXC_TZIC || MXC_AVIC)
select REGMAP_MMIO
help
@@ -37,7 +37,7 @@ config SND_SOC_FSL_SSI
 config SND_SOC_FSL_SPDIF
tristate Sony/Philips Digital Interface module support
select REGMAP_MMIO
-   select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n
+   select SND_SOC_IMX_PCM_DMA
select SND_SOC_IMX_PCM_FIQ if SND_IMX_SOC != n  (MXC_TZIC || MXC_AVIC)
help
  Say Y if you want to add Sony/Philips Digital Interface (SPDIF)
@@ -48,7 +48,7 @@ config SND_SOC_FSL_SPDIF
 config SND_SOC_FSL_ESAI
tristate Enhanced Serial Audio Interface (ESAI) module support
select REGMAP_MMIO
-   select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n
+   select SND_SOC_IMX_PCM_DMA
help
  Say Y if you want to add Enhanced Synchronous Audio Interface
  (ESAI) support for the Freescale CPUs.
-- 
1.7.9.5

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

[PATCH V1 2/3] ASoC: fsl-asoc-card: Fix build warning for maybe-uninitialized

2014-08-18 Thread Shengjiu Wang
When build fsl-asoc-card as module, there is following error:

sound/soc/fsl/fsl-asoc-card.c: In function 'fsl_asoc_card_probe':
 sound/soc/fsl/fsl-asoc-card.c:547:13: warning: 'asrc_np' may be used 
 uninitialized in this function [-Wmaybe-uninitialized]
 of_node_put(asrc_np);
^

vim +/asrc_np +547 sound/soc/fsl/fsl-asoc-card.c

   531  if (width == 24)
   532  priv-asrc_format = SNDRV_PCM_FORMAT_S24_LE;
   533  else
   534  priv-asrc_format = SNDRV_PCM_FORMAT_S16_LE;
   535  }
   536
   537  /* Finish card registering */
   538  platform_set_drvdata(pdev, priv);
   539  snd_soc_card_set_drvdata(priv-card, priv);
   540
   541  ret = devm_snd_soc_register_card(pdev-dev, priv-card);
   542  if (ret)
   543  dev_err(pdev-dev, snd_soc_register_card failed 
(%d)\n, ret);
   544
   545  fail:
   546  of_node_put(codec_np);
  547  of_node_put(asrc_np);
   548  of_node_put(cpu_np);
   549
   550  return ret;
   551  }
   552
   553  static const struct of_device_id fsl_asoc_card_dt_ids[] = {
   554  { .compatible = fsl,imx-audio-cs42888, },
   555  { .compatible = fsl,imx-audio-sgtl5000, },

Add 'asrc_fail' branch for error jump after asrc_np initialized.

Reported-by: kbuild test robot fengguang...@intel.com
Signed-off-by: Shengjiu Wang shengjiu.w...@freescale.com
---
 sound/soc/fsl/fsl-asoc-card.c |9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index cf3f1f4..007c772 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -469,7 +469,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
ret = fsl_asoc_card_audmux_init(np, priv);
if (ret) {
dev_err(pdev-dev, failed to init audmux\n);
-   goto fail;
+   goto asrc_fail;
}
} else if (strstr(cpu_np-name, esai)) {
priv-cpu_priv.sysclk_id[1] = ESAI_HCKT_EXTAL;
@@ -518,14 +518,14 @@ static int fsl_asoc_card_probe(struct platform_device 
*pdev)
if (ret) {
dev_err(pdev-dev, failed to get output rate\n);
ret = -EINVAL;
-   goto fail;
+   goto asrc_fail;
}
 
ret = of_property_read_u32(asrc_np, fsl,asrc-width, width);
if (ret) {
dev_err(pdev-dev, failed to get output rate\n);
ret = -EINVAL;
-   goto fail;
+   goto asrc_fail;
}
 
if (width == 24)
@@ -542,9 +542,10 @@ static int fsl_asoc_card_probe(struct platform_device 
*pdev)
if (ret)
dev_err(pdev-dev, snd_soc_register_card failed (%d)\n, ret);
 
+asrc_fail:
+   of_node_put(asrc_np);
 fail:
of_node_put(codec_np);
-   of_node_put(asrc_np);
of_node_put(cpu_np);
 
return ret;
-- 
1.7.9.5

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

[PATCH V1 0/3] fix build error/warning in sound/soc/fsl

2014-08-18 Thread Shengjiu Wang
This series patch is for fixing build error/waring in sound/soc/fsl

Shengjiu Wang (3):
  ASoC: fsl: Kconfig: remove dependence of SND_IMX_SOC for
SND_SOC_IMX_PCM_DMA
  ASoC: fsl-asoc-card: Fix build warning for maybe-uninitialized
  ASoC: fsl: fsl-asoc-card: Select SND_SOC_IMX_AUDMUX

 sound/soc/fsl/Kconfig |9 +
 sound/soc/fsl/fsl-asoc-card.c |9 +
 2 files changed, 10 insertions(+), 8 deletions(-)

-- 
1.7.9.5

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

[PATCH V1 3/3] ASoC: fsl: fsl-asoc-card: Select SND_SOC_IMX_AUDMUX

2014-08-18 Thread Shengjiu Wang
Building kernel with SND_SOC_IMX_AUDMUX=n leads to the following error:

   sound/built-in.o: In function `fsl_asoc_card_probe':
 fsl-asoc-card.c:(.text+0x1467b5): undefined reference to 
 `imx_audmux_v2_configure_port'
 fsl-asoc-card.c:(.text+0x1467d0): undefined reference to 
 `imx_audmux_v2_configure_port'
 fsl-asoc-card.c:(.text+0x1467ed): undefined reference to 
 `imx_audmux_v2_configure_port'
 fsl-asoc-card.c:(.text+0x146807): undefined reference to 
 `imx_audmux_v2_configure_port'

Update Kconfig to select SND_SOC_IMX_AUDMUX when SND_SOC_FSL_ASOC_CARD=y.

Reported-by: kbuild test robot fengguang...@intel.com
Signed-off-by: Shengjiu Wang shengjiu.w...@freescale.com
---
 sound/soc/fsl/Kconfig |1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 3a3732c..dc0d08b 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -61,6 +61,7 @@ config SND_SOC_FSL_UTILS
 config SND_SOC_FSL_ASOC_CARD
tristate Generic ASoC Sound Card with ASRC support
depends on OF  I2C
+   select SND_SOC_IMX_AUDMUX
select SND_SOC_IMX_PCM_DMA
select SND_SOC_FSL_ESAI
select SND_SOC_FSL_SAI
-- 
1.7.9.5

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

[PATCH 0/3] powerpc: Make sstep.c more generally useful

2014-08-18 Thread Paul Mackerras
This patch series modifies the code in arch/powerpc/lib/sstep.c so
that it can be used by KVM in its instruction emulation, thereby
reducing the number of different PowerPC instruction emulators that we
have in the kernel.  It does this by splitting the existing
emulate_step() function into two: an analyse_instr() function that
decodes an instruction and executes the easy ones, and an
emulate_step() function that uses analyse_instr() and then executes
the loads and stores.  The subsequent two patches add emulation of
some extra instructions.

The patch series is against v3.17-rc1.

 arch/powerpc/include/asm/sstep.h |  62 +++
 arch/powerpc/lib/sstep.c | 992 +--
 2 files changed, 694 insertions(+), 360 deletions(-)

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

[PATCH 1/3] powerpc: Split out instruction analysis part of emulate_step()

2014-08-18 Thread Paul Mackerras
This splits out the instruction analysis part of emulate_step() into
a separate analyse_instr() function, which decodes the instruction,
but doesn't execute any load or store instructions.  It does execute
integer instructions and branches which can be executed purely by
updating register values in the pt_regs struct.  For other instructions,
it returns the instruction type and other details in a new
instruction_op struct.  emulate_step() then uses that information
to execute loads, stores, cache operations, mfmsr, mtmsr[d], and
(on 64-bit) sc instructions.

The reason for doing this is so that the KVM code can use it instead
of having its own separate instruction emulation code.  Possibly the
alignment interrupt handler could also use this.

Signed-off-by: Paul Mackerras pau...@samba.org
---
 arch/powerpc/include/asm/sstep.h |  61 +++
 arch/powerpc/lib/sstep.c | 893 +++
 2 files changed, 594 insertions(+), 360 deletions(-)

diff --git a/arch/powerpc/include/asm/sstep.h b/arch/powerpc/include/asm/sstep.h
index f593b0f..1a693b1 100644
--- a/arch/powerpc/include/asm/sstep.h
+++ b/arch/powerpc/include/asm/sstep.h
@@ -25,3 +25,64 @@ struct pt_regs;
 
 /* Emulate instructions that cause a transfer of control. */
 extern int emulate_step(struct pt_regs *regs, unsigned int instr);
+
+enum instruction_type {
+   COMPUTE,/* arith/logical/CR op, etc. */
+   LOAD,
+   LOAD_MULTI,
+   LOAD_FP,
+   LOAD_VMX,
+   LOAD_VSX,
+   STORE,
+   STORE_MULTI,
+   STORE_FP,
+   STORE_VMX,
+   STORE_VSX,
+   LARX,
+   STCX,
+   BRANCH,
+   MFSPR,
+   MTSPR,
+   CACHEOP,
+   BARRIER,
+   SYSCALL,
+   MFMSR,
+   MTMSR,
+   RFI,
+   INTERRUPT,
+   UNKNOWN
+};
+
+#define INSTR_TYPE_MASK0x1f
+
+/* Load/store flags, ORed in with type */
+#define SIGNEXT0x20
+#define UPDATE 0x40/* matches bit in opcode 31 instructions */
+#define BYTEREV0x80
+
+/* Cacheop values, ORed in with type */
+#define CACHEOP_MASK   0x700
+#define DCBST  0
+#define DCBF   0x100
+#define DCBTST 0x200
+#define DCBT   0x300
+
+/* Size field in type word */
+#define SIZE(n)((n)  8)
+#define GETSIZE(w) ((w)  8)
+
+#define MKOP(t, f, s)  ((t) | (f) | SIZE(s))
+
+struct instruction_op {
+   int type;
+   int reg;
+   unsigned long val;
+   /* For LOAD/STORE/LARX/STCX */
+   unsigned long ea;
+   int update_reg;
+   /* For MFSPR */
+   int spr;
+};
+
+extern int analyse_instr(struct instruction_op *op, struct pt_regs *regs,
+unsigned int instr);
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 5c09f36..4f2a7d0 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -98,13 +98,8 @@ static unsigned long __kprobes dform_ea(unsigned int instr, 
struct pt_regs *regs
 
ra = (instr  16)  0x1f;
ea = (signed short) instr;  /* sign-extend */
-   if (ra) {
+   if (ra)
ea += regs-gpr[ra];
-   if (instr  0x0400) {   /* update forms */
-   if ((instr26) != 47)  /* stmw is not an 
update form */
-   regs-gpr[ra] = ea;
-   }
-   }
 
return truncate_if_32bit(regs-msr, ea);
 }
@@ -120,11 +115,8 @@ static unsigned long __kprobes dsform_ea(unsigned int 
instr, struct pt_regs *reg
 
ra = (instr  16)  0x1f;
ea = (signed short) (instr  ~3);   /* sign-extend */
-   if (ra) {
+   if (ra)
ea += regs-gpr[ra];
-   if ((instr  3) == 1)   /* update forms */
-   regs-gpr[ra] = ea;
-   }
 
return truncate_if_32bit(regs-msr, ea);
 }
@@ -133,8 +125,8 @@ static unsigned long __kprobes dsform_ea(unsigned int 
instr, struct pt_regs *reg
 /*
  * Calculate effective address for an X-form instruction
  */
-static unsigned long __kprobes xform_ea(unsigned int instr, struct pt_regs 
*regs,
-int do_update)
+static unsigned long __kprobes xform_ea(unsigned int instr,
+   struct pt_regs *regs)
 {
int ra, rb;
unsigned long ea;
@@ -142,11 +134,8 @@ static unsigned long __kprobes xform_ea(unsigned int 
instr, struct pt_regs *regs
ra = (instr  16)  0x1f;
rb = (instr  11)  0x1f;
ea = regs-gpr[rb];
-   if (ra) {
+   if (ra)
ea += regs-gpr[ra];
-   if (do_update)  /* update forms */
-   regs-gpr[ra] = ea;
-   }
 
return truncate_if_32bit(regs-msr, ea);
 }
@@ -627,26 +616,27 @@ static void __kprobes do_cmp_unsigned(struct pt_regs 
*regs, unsigned long v1,
 #define ROTATE(x, n)   ((n) ? (((x)  (n)) | ((x)  (8 * sizeof(long) - 
(n : (x))

[PATCH 2/3] powerpc: Emulate icbi, mcrf and conditional-trap instructions

2014-08-18 Thread Paul Mackerras
This extends the instruction emulation done by analyse_instr() and
emulate_step() to handle a few more instructions that are found in
the kernel.

Signed-off-by: Paul Mackerras pau...@samba.org
---
 arch/powerpc/include/asm/sstep.h |  1 +
 arch/powerpc/lib/sstep.c | 60 
 2 files changed, 61 insertions(+)

diff --git a/arch/powerpc/include/asm/sstep.h b/arch/powerpc/include/asm/sstep.h
index 1a693b1..d3a42cc 100644
--- a/arch/powerpc/include/asm/sstep.h
+++ b/arch/powerpc/include/asm/sstep.h
@@ -66,6 +66,7 @@ enum instruction_type {
 #define DCBF   0x100
 #define DCBTST 0x200
 #define DCBT   0x300
+#define ICBI   0x400
 
 /* Size field in type word */
 #define SIZE(n)((n)  8)
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 4f2a7d0..57e2873 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -600,6 +600,23 @@ static void __kprobes do_cmp_unsigned(struct pt_regs 
*regs, unsigned long v1,
regs-ccr = (regs-ccr  ~(0xf  shift)) | (crval  shift);
 }
 
+static int __kprobes trap_compare(long v1, long v2)
+{
+   int ret = 0;
+
+   if (v1  v2)
+   ret |= 0x10;
+   else if (v1  v2)
+   ret |= 0x08;
+   else
+   ret |= 0x04;
+   if ((unsigned long)v1  (unsigned long)v2)
+   ret |= 0x02;
+   else if ((unsigned long)v1  (unsigned long)v2)
+   ret |= 0x01;
+   return ret;
+}
+
 /*
  * Elements of 32-bit rotate and mask instructions.
  */
@@ -669,6 +686,13 @@ int __kprobes analyse_instr(struct instruction_op *op, 
struct pt_regs *regs,
return 1;
case 19:
switch ((instr  1)  0x3ff) {
+   case 0: /* mcrf */
+   rd = (instr  21)  0x1c;
+   ra = (instr  16)  0x1c;
+   val = (regs-ccr  ra)  0xf;
+   regs-ccr = (regs-ccr  ~(0xfUL  rd)) | (val  rd);
+   goto instr_done;
+
case 16:/* bclr */
case 528:   /* bcctr */
op-type = BRANCH;
@@ -745,6 +769,17 @@ int __kprobes analyse_instr(struct instruction_op *op, 
struct pt_regs *regs,
rb = (instr  11)  0x1f;
 
switch (opcode) {
+#ifdef __powerpc64__
+   case 2: /* tdi */
+   if (rd  trap_compare(regs-gpr[ra], (short) instr))
+   goto trap;
+   goto instr_done;
+#endif
+   case 3: /* twi */
+   if (rd  trap_compare((int)regs-gpr[ra], (short) instr))
+   goto trap;
+   goto instr_done;
+
case 7: /* mulli */
regs-gpr[rd] = regs-gpr[ra] * (short) instr;
goto instr_done;
@@ -893,6 +928,18 @@ int __kprobes analyse_instr(struct instruction_op *op, 
struct pt_regs *regs,
 
case 31:
switch ((instr  1)  0x3ff) {
+   case 4: /* tw */
+   if (rd == 0x1f ||
+   (rd  trap_compare((int)regs-gpr[ra],
+  (int)regs-gpr[rb])))
+   goto trap;
+   goto instr_done;
+#ifdef __powerpc64__
+   case 68:/* td */
+   if (rd  trap_compare(regs-gpr[ra], regs-gpr[rb]))
+   goto trap;
+   goto instr_done;
+#endif
case 83:/* mfmsr */
if (regs-msr  MSR_PR)
goto priv;
@@ -1269,6 +1316,11 @@ int __kprobes analyse_instr(struct instruction_op *op, 
struct pt_regs *regs,
op-ea = xform_ea(instr, regs);
op-reg = rd;
return 0;
+
+   case 982:   /* icbi */
+   op-type = MKOP(CACHEOP, ICBI, 0);
+   op-ea = xform_ea(instr, regs);
+   return 0;
}
break;
}
@@ -1597,6 +1649,11 @@ int __kprobes analyse_instr(struct instruction_op *op, 
struct pt_regs *regs,
op-val = SRR1_PROGPRIV;
return 0;
 
+ trap:
+   op-type = INTERRUPT | 0x700;
+   op-val = SRR1_PROGTRAP;
+   return 0;
+
 #ifdef CONFIG_PPC_FPU
  fpunavail:
op-type = INTERRUPT | 0x800;
@@ -1714,6 +1771,9 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned 
int instr)
if (op.reg == 0)
prefetch((void *) op.ea);
break;
+   case ICBI:
+   __cacheop_user_asmx(op.ea, err, icbi);
+   break;
}
if (err)
return 0;
-- 
2.1.0.rc1

___
Linuxppc-dev mailing list

[PATCH 3/3] powerpc: Implement emulation of string loads and stores

2014-08-18 Thread Paul Mackerras
The size field of the op.type word is now the total number of bytes
to be loaded or stored.

Signed-off-by: Paul Mackerras pau...@samba.org
---
 arch/powerpc/lib/sstep.c | 59 
 1 file changed, 49 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 57e2873..39ed4b7 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1433,11 +1433,24 @@ int __kprobes analyse_instr(struct instruction_op *op, 
struct pt_regs *regs,
break;
 
 #endif
+   case 533:   /* lswx */
+   op-type = MKOP(LOAD_MULTI, 0, regs-xer  0x7f);
+   break;
 
case 534:   /* lwbrx */
op-type = MKOP(LOAD, BYTEREV, 4);
break;
 
+   case 597:   /* lswi */
+   if (rb == 0)
+   rb = 32;/* # bytes to load */
+   op-type = MKOP(LOAD_MULTI, 0, rb);
+   op-ea = 0;
+   if (ra)
+   op-ea = truncate_if_32bit(regs-msr,
+  regs-gpr[ra]);
+   break;
+
 #ifdef CONFIG_PPC_FPU
case 535:   /* lfsx */
case 567:   /* lfsux */
@@ -1475,11 +1488,25 @@ int __kprobes analyse_instr(struct instruction_op *op, 
struct pt_regs *regs,
break;
 
 #endif
+   case 661:   /* stswx */
+   op-type = MKOP(STORE_MULTI, 0, regs-xer  0x7f);
+   break;
+
case 662:   /* stwbrx */
op-type = MKOP(STORE, BYTEREV, 4);
op-val = byterev_4(regs-gpr[rd]);
break;
 
+   case 725:
+   if (rb == 0)
+   rb = 32;/* # bytes to store */
+   op-type = MKOP(STORE_MULTI, 0, rb);
+   op-ea = 0;
+   if (ra)
+   op-ea = truncate_if_32bit(regs-msr,
+  regs-gpr[ra]);
+   break;
+
case 790:   /* lhbrx */
op-type = MKOP(LOAD, BYTEREV, 2);
break;
@@ -1553,15 +1580,14 @@ int __kprobes analyse_instr(struct instruction_op *op, 
struct pt_regs *regs,
break;
 
case 46:/* lmw */
-   ra = (instr  16)  0x1f;
if (ra = rd)
break;  /* invalid form, ra in range to load */
-   op-type = MKOP(LOAD_MULTI, 0, 4);
+   op-type = MKOP(LOAD_MULTI, 0, 4 * (32 - rd));
op-ea = dform_ea(instr, regs);
break;
 
case 47:/* stmw */
-   op-type = MKOP(STORE_MULTI, 0, 4);
+   op-type = MKOP(STORE_MULTI, 0, 4 * (32 - rd));
op-ea = dform_ea(instr, regs);
break;
 
@@ -1744,7 +1770,7 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned 
int instr)
int r, err, size;
unsigned long val;
unsigned int cr;
-   int rd;
+   int i, rd, nb;
 
r = analyse_instr(op, regs, instr);
if (r != 0)
@@ -1864,12 +1890,18 @@ int __kprobes emulate_step(struct pt_regs *regs, 
unsigned int instr)
if (regs-msr  MSR_LE)
return 0;
rd = op.reg;
-   do {
-   err = read_mem(regs-gpr[rd], op.ea, 4, regs);
+   for (i = 0; i  size; i += 4) {
+   nb = size - i;
+   if (nb  4)
+   nb = 4;
+   err = read_mem(regs-gpr[rd], op.ea, nb, regs);
if (err)
return 0;
+   if (nb  4) /* left-justify last bytes */
+   regs-gpr[rd] = 32 - 8 * nb;
op.ea += 4;
-   } while (++rd  32);
+   ++rd;
+   }
goto instr_done;
 
case STORE:
@@ -1910,12 +1942,19 @@ int __kprobes emulate_step(struct pt_regs *regs, 
unsigned int instr)
if (regs-msr  MSR_LE)
return 0;
rd = op.reg;
-   do {
-   err = write_mem(regs-gpr[rd], op.ea, 4, regs);
+   for (i = 0; i  size; i += 4) {
+   val = regs-gpr[rd];
+   nb = size - i;
+   if (nb  4)
+   nb = 4;
+   else
+   val = 32 - 8 * nb;
+   err = write_mem(val, op.ea, nb, regs);
  

Re: [PATCH V1 2/3] ASoC: fsl-asoc-card: Fix build warning for maybe-uninitialized

2014-08-18 Thread Mark Brown
On Mon, Aug 18, 2014 at 04:38:39PM +0800, Shengjiu Wang wrote:
 When build fsl-asoc-card as module, there is following error:

Applied, thanks.


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

Re: [PATCH V1 3/3] ASoC: fsl: fsl-asoc-card: Select SND_SOC_IMX_AUDMUX

2014-08-18 Thread Mark Brown
On Mon, Aug 18, 2014 at 04:38:40PM +0800, Shengjiu Wang wrote:
 Building kernel with SND_SOC_IMX_AUDMUX=n leads to the following error:

Applied, thanks.


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

Re: [alsa-devel] [PATCH V1 1/3] ASoC: fsl: Kconfig: remove dependence of SND_IMX_SOC for SND_SOC_IMX_PCM_DMA

2014-08-18 Thread Lars-Peter Clausen

On 08/18/2014 10:38 AM, Shengjiu Wang wrote:

Build kernel with SND_SOC_IMC_PCM_DMA=m  SND_IMX_SOC=n leads the following
error:

sound/built-in.o: In function `fsl_sai_probe':

fsl_sai.c:(.text+0x5f662): undefined reference to `imx_pcm_dma_init'

sound/built-in.o: In function `fsl_esai_probe':

fsl_esai.c:(.text+0x6044b): undefined reference to `imx_pcm_dma_init'


Most cpu driver in soc/fsl has use the function 'imx_pcm_dma_init' which is
defined in imx-pcm-dma.c, so need to select SND_SOC_IMX_PCM_DMA, but it depends
on SND_IMX_SOC, if SND_IMX_SOC=n, then SND_SOC_IMX_PCM_DMA will not be
selected.
So remove the dependence of SND_IMX_SOC for SND_SOC_IMX_PCM_DMA.

Reported-by: kbuild test robot fengguang...@intel.com
Signed-off-by: Shengjiu Wang shengjiu.w...@freescale.com


Those if conditions where just added[1] by Arnd to avoid other build 
failures. So just removing them again makes little sense.


As far as I can see imx_pcm_dma_init() should be stubbed out when 
SND_SOC_IMX_PCM_DMA is not selected. So what's going on here?


[1] 
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=ff40260f79dc0436604452bccd449bffd25ebafb


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

Re: [PATCH] powerpc: Fix build failure for PPC_32

2014-08-18 Thread Geert Uytterhoeven
Hi Pranith,

On Mon, Aug 18, 2014 at 9:01 PM, Pranith Kumar bobby.pr...@gmail.com wrote:
 Fix ppc 32 build failure as reported here:

 http://kisskb.ellerman.id.au/kisskb/buildresult/11663513/

| arch/powerpc/include/asm/floppy.h:142:20: error: 'isa_bridge_pcidev'
undeclared (first use in this function)
| make[3]: *** [drivers/block/floppy.o] Error 1

The definition of isa_bridge_pcidev is only available if CONFIG_PCI=y...

 The error is that pci_32.o was not being built for PPC_32. Fix error by adding
 it in the Makefile. Tested using the ppc cross compiler.

... so how can adding this make the floppy.h error go away?

Note that arch/powerpc/kernel/Makefile does add
pci_$(CONFIG_WORD_SIZE).o, but only if CONFIG_PCI=y.

So, thanks for your patch, but I don't think your fix is the right solution.

However, drivers/block/floppy.o is enabled by BLK_DEV_FD, which
depends on ARCH_MAY_HAVE_PC_FDC.

arch/powerpc/Kconfig has:

config ARCH_MAY_HAVE_PC_FDC
bool
default !PPC_PSERIES || PCI

PCI is not set, and PPC_PSERIES is also not set, so this
defaults to y, which is obviously not correct, as floppy.h needs PCI.

As this symbol doesn't enable floppy support in-se, probably it should just
be:

config ARCH_MAY_HAVE_PC_FDC
bool
depends on PCI

This config line was last touched by
commit bed59275810a55500e885cbdc5c2a0507f13c00e
Author: Stephen Rothwell s...@canb.auug.org.au
Date:   Sun Mar 4 17:04:44 2007 +1100

[POWERPC] Allow pSeries to build without CONFIG_PCI

Signed-off-by: Stephen Rothwell s...@canb.auug.org.au
Signed-off-by: Paul Mackerras pau...@samba.org

 Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
 Reported-by: Geert Uytterhoeven ge...@linux-m68k.org
 CC: Andrew Morton a...@linux-foundation.org
 ---
  arch/powerpc/kernel/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
 index 670c312..3206ba1 100644
 --- a/arch/powerpc/kernel/Makefile
 +++ b/arch/powerpc/kernel/Makefile
 @@ -89,7 +89,7 @@ extra-y   += vmlinux.lds

  obj-$(CONFIG_RELOCATABLE_PPC32)+= reloc_32.o

 -obj-$(CONFIG_PPC32)+= entry_32.o setup_32.o
 +obj-$(CONFIG_PPC32)+= entry_32.o setup_32.o pci_32.o
  obj-$(CONFIG_PPC64)+= dma-iommu.o iommu.o
  obj-$(CONFIG_KGDB) += kgdb.o
  obj-$(CONFIG_MODULES)  += ppc_ksyms.o

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
-- Linus Torvalds
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] powerpc: Fix build failure for PPC_32

2014-08-18 Thread Geert Uytterhoeven
Hi Pranith,

On Mon, Aug 18, 2014 at 10:52 PM, Pranith Kumar bobby.pr...@gmail.com wrote:
 On Mon, Aug 18, 2014 at 3:28 PM, Geert Uytterhoeven ge...@linux-m68k.org
 wrote:
 On Mon, Aug 18, 2014 at 9:01 PM, Pranith Kumar bobby.pr...@gmail.com
 wrote:
  Fix ppc 32 build failure as reported here:
 
  http://kisskb.ellerman.id.au/kisskb/buildresult/11663513/

 | arch/powerpc/include/asm/floppy.h:142:20: error: 'isa_bridge_pcidev'
 undeclared (first use in this function)
 | make[3]: *** [drivers/block/floppy.o] Error 1

 The definition of isa_bridge_pcidev is only available if CONFIG_PCI=y...

  The error is that pci_32.o was not being built for PPC_32. Fix error by
  adding
  it in the Makefile. Tested using the ppc cross compiler.

 ... so how can adding this make the floppy.h error go away?

 So the definition which you are talking about within CONFIG_PCI=y is an
 extern definition

 arch/powerpc/include/asm/ppc-pci.h:28:extern struct pci_dev
 *isa_bridge_pcidev;

 If you build pci_32.o unconditionally, there is an

 EXPORT_SYMBOL(isa_bridge_pcidev);

 which supplies the required symbol.

Yes, but the error in floppy.h is from the compiler, not from the linker.
Supplying the symbol for the linker doesn't help the compiler when
building floppy.c.

 But yes, you are right in that we should not unconditionally compile
 pci_32.o. Making floppy depend on PCI is the right thing to do. However,

 Note that arch/powerpc/kernel/Makefile does add
 pci_$(CONFIG_WORD_SIZE).o, but only if CONFIG_PCI=y.

 So, thanks for your patch, but I don't think your fix is the right
 solution.

 However, drivers/block/floppy.o is enabled by BLK_DEV_FD, which
 depends on ARCH_MAY_HAVE_PC_FDC.

 arch/powerpc/Kconfig has:

 config ARCH_MAY_HAVE_PC_FDC
 bool
 default !PPC_PSERIES || PCI

 PCI is not set, and PPC_PSERIES is also not set, so this
 defaults to y, which is obviously not correct, as floppy.h needs PCI.

 As this symbol doesn't enable floppy support in-se, probably it should
 just
 be:

 config ARCH_MAY_HAVE_PC_FDC
 bool
 depends on PCI

 the right thing I guess here is to depend on !PPC_PSERIES  PCI since I
 guess pSeries does not support floppy.h (hence the original condition
 check?).

Note that PowerPC supports multi-platform kernels.
A kernel with PPC_PSERIES and something else with PCI may still want to
have floppy support.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
-- Linus Torvalds
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] tools/perf/powerpc: Fix build break

2014-08-18 Thread Sukadev Bhattiprolu
I posted a patch for this to LKML last week:

https://lkml.org/lkml/2014/8/7/77

Aneesh Kumar K.V [aneesh.ku...@linux.vnet.ibm.com] wrote:
|   CC   arch/powerpc/util/skip-callchain-idx.o
| arch/powerpc/util/skip-callchain-idx.c: In function ‘check_return_reg’:
| arch/powerpc/util/skip-callchain-idx.c:55:3: error: implicit declaration of 
function ‘pr_debug’ [-Werror=implicit-function-declaration]
|pr_debug(dwarf_frame_register() %s\n, dwarf_errmsg(-1));
| 
| Signed-off-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
| ---
|  tools/perf/arch/powerpc/util/skip-callchain-idx.c | 1 +
|  1 file changed, 1 insertion(+)
| 
| diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c 
b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
| index a7c23a4b3778..d73ef8bb08c7 100644
| --- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c
| +++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
| @@ -15,6 +15,7 @@
|  
|  #include util/thread.h
|  #include util/callchain.h
| +#include util/debug.h
|  
|  /*
|   * When saving the callchain on Power, the kernel conservatively saves
| -- 
| 1.9.1
| 
| ___
| 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] powerpc/eeh: fix crashing when passing VF

2014-08-18 Thread Wei Yang
When doing vfio passthrough a VF, the kernel will crash with following
message:

[  442.656459] Unable to handle kernel paging request for data at address 
0x0060
[  442.656593] Faulting instruction address: 0xc0038b88
[  442.656706] Oops: Kernel access of bad area, sig: 11 [#1]
[  442.656798] SMP NR_CPUS=1024 NUMA PowerNV
[  442.656890] Modules linked in: vfio_pci mlx4_core nf_conntrack_netbios_ns 
nf_conntrack_broadcast ipt_MASQUERADE ip6t_REJECT xt_conntrack bnep bluetooth 
rfkill ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables 
ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle 
ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat 
nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle 
iptable_security iptable_raw tg3 nfsd be2net nfs_acl ses lockd ptp enclosure 
pps_core kvm_hv kvm_pr shpchp binfmt_misc kvm sunrpc uinput lpfc 
scsi_transport_fc ipr scsi_tgt [last unloaded: mlx4_core]
[  442.658152] CPU: 40 PID: 14948 Comm: qemu-system-ppc Not tainted 
3.10.42yw-pkvm+ #37
[  442.658219] task: c00f7e2a9a00 ti: c00f6dc3c000 task.ti: 
c00f6dc3c000
[  442.658287] NIP: c0038b88 LR: c04435a8 CTR: c0455bc0
[  442.658352] REGS: c00f6dc3f580 TRAP: 0300   Not tainted  
(3.10.42yw-pkvm+)
[  442.658419] MSR: 90009032 SF,HV,EE,ME,IR,DR,RI  CR: 28004882  XER: 
2000
[  442.658577] CFAR: c000908c DAR: 0060 DSISR: 4000 
SOFTE: 1
GPR00: c04435a8 c00f6dc3f800 c12b1c10 cda24000
GPR04: 0003 1004 15b3 
GPR08: c127f5d8   
GPR12: c0068078 cfdd6800 01003c320c80 01003c3607f0
GPR16: 0001 105480c8 1055aaa8 01003c31ab18
GPR20: 01003c10fb40 01003c360ae8 1063bcf0 1063bdb0
GPR24: 01003c15ed70 10548f40 c01fe5514c88 c01fe5514cb0
GPR28: cda24000  cda24000 0003
[  442.659471] NIP [c0038b88] .pcibios_set_pcie_reset_state+0x28/0x130
[  442.659530] LR [c04435a8] .pci_set_pcie_reset_state+0x28/0x40
[  442.659585] Call Trace:
[  442.659610] [c00f6dc3f800] [000719e0] 0x719e0 (unreliable)
[  442.659677] [c00f6dc3f880] [c04435a8] 
.pci_set_pcie_reset_state+0x28/0x40
[  442.659757] [c00f6dc3f900] [c0455bf8] 
.reset_fundamental+0x38/0x80
[  442.659835] [c00f6dc3f980] [c04562a8] 
.pci_dev_specific_reset+0xa8/0xf0
[  442.659913] [c00f6dc3fa00] [c04448c4] .__pci_dev_reset+0x44/0x430
[  442.659980] [c00f6dc3fab0] [c0444d5c] 
.pci_reset_function+0x7c/0xc0
[  442.660059] [c00f6dc3fb30] [d0001c141ab8] .vfio_pci_open+0xe8/0x2b0 
[vfio_pci]
[  442.660139] [c00f6dc3fbd0] [c0586c30] 
.vfio_group_fops_unl_ioctl+0x3a0/0x630
[  442.660219] [c00f6dc3fc90] [c0255fbc] .do_vfs_ioctl+0x4ec/0x7c0
[  442.660286] [c00f6dc3fd80] [c0256364] .SyS_ioctl+0xd4/0xf0
[  442.660354] [c00f6dc3fe30] [c0009e54] syscall_exit+0x0/0x98
[  442.660420] Instruction dump:
[  442.660454] 4bfffce9 4bfffee4 7c0802a6 fbc1fff0 fbe1fff8 f8010010 f821ff81 
7c7e1b78
[  442.660566] 7c9f2378 6000 6000 e93e02c8 e8690060 2fa3 41de00c4 
2b9f0002
[  442.660679] ---[ end trace a64ac9546bcf0328 ]---
[  442.660724]

The reason is current VF is not EEH enabled.

This patch is a quick fix for this problem.

Signed-off-by: Wei Yang weiy...@linux.vnet.ibm.com
---
 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 0ba4392..d2d2130 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -630,7 +630,7 @@ int eeh_pci_enable(struct eeh_pe *pe, int function)
 int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state 
state)
 {
struct eeh_dev *edev = pci_dev_to_eeh_dev(dev);
-   struct eeh_pe *pe = edev-pe;
+   struct eeh_pe *pe = edev ? edev-pe:NULL;
 
if (!pe) {
pr_err(%s: No PE found on PCI device %s\n,
-- 
1.7.9.5

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

[PATCH] powerpc: Fix build failure for PPC_32

2014-08-18 Thread Pranith Kumar
Fix ppc 32 build failure as reported here:

http://kisskb.ellerman.id.au/kisskb/buildresult/11663513/

The error is that pci_32.o was not being built for PPC_32. Fix error by adding
it in the Makefile. Tested using the ppc cross compiler.

Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
Reported-by: Geert Uytterhoeven ge...@linux-m68k.org
CC: Andrew Morton a...@linux-foundation.org
---
 arch/powerpc/kernel/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 670c312..3206ba1 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -89,7 +89,7 @@ extra-y   += vmlinux.lds
 
 obj-$(CONFIG_RELOCATABLE_PPC32)+= reloc_32.o
 
-obj-$(CONFIG_PPC32)+= entry_32.o setup_32.o
+obj-$(CONFIG_PPC32)+= entry_32.o setup_32.o pci_32.o
 obj-$(CONFIG_PPC64)+= dma-iommu.o iommu.o
 obj-$(CONFIG_KGDB) += kgdb.o
 obj-$(CONFIG_MODULES)  += ppc_ksyms.o
-- 
1.9.1

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

Re: [PATCH] powerpc: Fix build failure for PPC_32

2014-08-18 Thread Pranith Kumar
On Mon, Aug 18, 2014 at 3:28 PM, Geert Uytterhoeven ge...@linux-m68k.org
wrote:

 Hi Pranith,

 On Mon, Aug 18, 2014 at 9:01 PM, Pranith Kumar bobby.pr...@gmail.com
 wrote:
  Fix ppc 32 build failure as reported here:
 
  http://kisskb.ellerman.id.au/kisskb/buildresult/11663513/

 | arch/powerpc/include/asm/floppy.h:142:20: error: 'isa_bridge_pcidev'
 undeclared (first use in this function)
 | make[3]: *** [drivers/block/floppy.o] Error 1

 The definition of isa_bridge_pcidev is only available if CONFIG_PCI=y...

  The error is that pci_32.o was not being built for PPC_32. Fix error by
 adding
  it in the Makefile. Tested using the ppc cross compiler.

 ... so how can adding this make the floppy.h error go away?


So the definition which you are talking about within CONFIG_PCI=y is an
extern definition

arch/powerpc/include/asm/ppc-pci.h:28:extern struct pci_dev
*isa_bridge_pcidev;

If you build pci_32.o unconditionally, there is an

EXPORT_SYMBOL(isa_bridge_pcidev);

which supplies the required symbol.

But yes, you are right in that we should not unconditionally compile
pci_32.o. Making floppy depend on PCI is the right thing to do. However,



 Note that arch/powerpc/kernel/Makefile does add
 pci_$(CONFIG_WORD_SIZE).o, but only if CONFIG_PCI=y.

 So, thanks for your patch, but I don't think your fix is the right
 solution.

 However, drivers/block/floppy.o is enabled by BLK_DEV_FD, which
 depends on ARCH_MAY_HAVE_PC_FDC.

 arch/powerpc/Kconfig has:

 config ARCH_MAY_HAVE_PC_FDC
 bool
 default !PPC_PSERIES || PCI

 PCI is not set, and PPC_PSERIES is also not set, so this
 defaults to y, which is obviously not correct, as floppy.h needs PCI.

 As this symbol doesn't enable floppy support in-se, probably it should just
 be:

 config ARCH_MAY_HAVE_PC_FDC
 bool
 depends on PCI


the right thing I guess here is to depend on !PPC_PSERIES  PCI since I
guess pSeries does not support floppy.h (hence the original condition
check?).

Note that there are other unrelated errors which do not let me complete the
PPC 32 build with the config there yet. I just verified this symbol error.


 This config line was last touched by
 commit bed59275810a55500e885cbdc5c2a0507f13c00e
 Author: Stephen Rothwell s...@canb.auug.org.au
 Date:   Sun Mar 4 17:04:44 2007 +1100

 [POWERPC] Allow pSeries to build without CONFIG_PCI

 Signed-off-by: Stephen Rothwell s...@canb.auug.org.au
 Signed-off-by: Paul Mackerras pau...@samba.org



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

Re: [PATCH] powerpc: Fix build failure for PPC_32

2014-08-18 Thread Pranith Kumar
On Mon, Aug 18, 2014 at 4:57 PM, Geert Uytterhoeven
ge...@linux-m68k.org wrote:

 Note that PowerPC supports multi-platform kernels.
 A kernel with PPC_PSERIES and something else with PCI may still want to
 have floppy support.

OK, I tested with your change and it works. I needed to make one more
change for it compile all the way through though.

I will send both of the patches shortly.

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

[PATCH v2] ppc: Fix build error with CONFIG_PCI=n

2014-08-18 Thread Pranith Kumar
Fix ppc 32 build failure as reported here:

http://kisskb.ellerman.id.au/kisskb/buildresult/11663513/

The error is as follows:

arch/powerpc/include/asm/floppy.h:142:20: error: 'isa_bridge_pcidev' undeclared
(first use in this function)

This is happening since floppy.o is enabled by BLK_DEV_FD which depends on
ARCH_MAY_HAVE_PC_FDC which is in-turn enabled if PPC_PSERIES=n. 

The following commit changes the dependency so that ARCH_MAY_HAVE_PC_FDC is
dependent exclusively on PCI since otherwise it will not compile.

Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
Reported-by: Geert Uytterhoeven ge...@linux-m68k.org
CC: Andrew Morton a...@linux-foundation.org
---
 arch/powerpc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index a577609f..9c1aa77 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -182,7 +182,7 @@ config SCHED_OMIT_FRAME_POINTER
 
 config ARCH_MAY_HAVE_PC_FDC
bool
-   default !PPC_PSERIES || PCI
+   default PCI
 
 config PPC_OF
def_bool y
-- 
1.9.1

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

[PATCH 1/4] powerpc/powernv: Add OPAL check token call

2014-08-18 Thread Michael Neuling
Currently there is no way to generically check if an OPAL call exists or not
from the host kernel.

This adds an OPAL call opal_check_token() which tells you if the given token is
present in OPAL or not.

Signed-off-by: Michael Neuling mi...@neuling.org
---
 arch/powerpc/include/asm/opal.h| 7 +++
 arch/powerpc/platforms/powernv/opal-wrappers.S | 1 +
 2 files changed, 8 insertions(+)

diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 86055e5..4593a93 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -135,6 +135,7 @@ struct opal_sg_list {
 #define OPAL_FLASH_MANAGE  77
 #define OPAL_FLASH_UPDATE  78
 #define OPAL_RESYNC_TIMEBASE   79
+#define OPAL_CHECK_TOKEN   80
 #define OPAL_DUMP_INIT 81
 #define OPAL_DUMP_INFO 82
 #define OPAL_DUMP_READ 83
@@ -417,6 +418,11 @@ struct opal_msg {
__be64 params[8];
 };
 
+enum OpalCheckTokenStatus {
+   OPAL_TOKEN_ABSENT = 0,
+   OPAL_TOKEN_PRESENT = 1
+};
+
 struct opal_machine_check_event {
enum OpalMCE_Versionversion:8;  /* 0x00 */
uint8_t in_use; /* 0x01 */
@@ -887,6 +893,7 @@ int64_t opal_pci_next_error(uint64_t phb_id, __be64 
*first_frozen_pe,
__be16 *pci_error_type, __be16 *severity);
 int64_t opal_pci_poll(uint64_t phb_id);
 int64_t opal_return_cpu(void);
+int64_t opal_check_token(uint64_t token);
 int64_t opal_reinit_cpus(uint64_t flags);
 
 int64_t opal_xscom_read(uint32_t gcid, uint64_t pcb_addr, __be64 *val);
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S 
b/arch/powerpc/platforms/powernv/opal-wrappers.S
index 2e6ce1b..5718855 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -232,6 +232,7 @@ OPAL_CALL(opal_validate_flash,  
OPAL_FLASH_VALIDATE);
 OPAL_CALL(opal_manage_flash,   OPAL_FLASH_MANAGE);
 OPAL_CALL(opal_update_flash,   OPAL_FLASH_UPDATE);
 OPAL_CALL(opal_resync_timebase,OPAL_RESYNC_TIMEBASE);
+OPAL_CALL(opal_check_token,OPAL_CHECK_TOKEN);
 OPAL_CALL(opal_dump_init,  OPAL_DUMP_INIT);
 OPAL_CALL(opal_dump_info,  OPAL_DUMP_INFO);
 OPAL_CALL(opal_dump_info2, OPAL_DUMP_INFO2);
-- 
1.9.1

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

[PATCH 2/4] powerpc/powernv: Check OPAL RTC calls exists before using

2014-08-18 Thread Michael Neuling
Check that the OPAL_RTC_READ token exists before we use the OPAL RTC.

Refactors the code a little to merge error paths.

This avoids littering the OPAL console with:
  OPAL: Called with bad token 3.

Signed-off-by: Michael Neuling mi...@neuling.org
---
 arch/powerpc/platforms/powernv/opal-rtc.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal-rtc.c 
b/arch/powerpc/platforms/powernv/opal-rtc.c
index b1885db..499707d 100644
--- a/arch/powerpc/platforms/powernv/opal-rtc.c
+++ b/arch/powerpc/platforms/powernv/opal-rtc.c
@@ -42,6 +42,9 @@ unsigned long __init opal_get_boot_time(void)
__be64 __h_m_s_ms;
long rc = OPAL_BUSY;
 
+   if (!opal_check_token(OPAL_RTC_READ))
+   goto out;
+
while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
rc = opal_rtc_read(__y_m_d, __h_m_s_ms);
if (rc == OPAL_BUSY_EVENT)
@@ -49,16 +52,18 @@ unsigned long __init opal_get_boot_time(void)
else
mdelay(10);
}
-   if (rc != OPAL_SUCCESS) {
-   ppc_md.get_rtc_time = NULL;
-   ppc_md.set_rtc_time = NULL;
-   return 0;
-   }
+   if (rc != OPAL_SUCCESS)
+   goto out;
+
y_m_d = be32_to_cpu(__y_m_d);
h_m_s_ms = be64_to_cpu(__h_m_s_ms);
opal_to_tm(y_m_d, h_m_s_ms, tm);
return mktime(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
  tm.tm_hour, tm.tm_min, tm.tm_sec);
+out:
+   ppc_md.get_rtc_time = NULL;
+   ppc_md.set_rtc_time = NULL;
+   return 0;
 }
 
 void opal_get_rtc_time(struct rtc_time *tm)
-- 
1.9.1

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

[PATCH 3/4] powerpc/powernv: Check OPAL elog calls exist before using

2014-08-18 Thread Michael Neuling
Check that the OPAL_ELOG_READ token exists before initalising the elog
infrastructure.

This avoids littering the OPAL console with:
  OPAL: Called with bad token 74

Signed-off-by: Michael Neuling mi...@neuling.org
---
 arch/powerpc/platforms/powernv/opal-elog.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/platforms/powernv/opal-elog.c 
b/arch/powerpc/platforms/powernv/opal-elog.c
index bbdb3ff..518fe95 100644
--- a/arch/powerpc/platforms/powernv/opal-elog.c
+++ b/arch/powerpc/platforms/powernv/opal-elog.c
@@ -295,6 +295,10 @@ int __init opal_elog_init(void)
 {
int rc = 0;
 
+   /* ELOG not supported by firmware */
+   if (!opal_check_token(OPAL_ELOG_READ))
+   return -1;
+
elog_kset = kset_create_and_add(elog, NULL, opal_kobj);
if (!elog_kset) {
pr_warn(%s: failed to create elog kset\n, __func__);
-- 
1.9.1

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

[PATCH 4/4] powerpc/powernv: Check OPAL dump calls exist before using

2014-08-18 Thread Michael Neuling
Check that the OPAL_DUMP_READ token exists before initalising the elog
infrastructure.

This avoids littering the OPAL console with:
  OPAL: Called with bad token 91

Signed-off-by: Michael Neuling mi...@neuling.org
---
 arch/powerpc/platforms/powernv/opal-dump.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/platforms/powernv/opal-dump.c 
b/arch/powerpc/platforms/powernv/opal-dump.c
index 85bb8ff..c7577f9 100644
--- a/arch/powerpc/platforms/powernv/opal-dump.c
+++ b/arch/powerpc/platforms/powernv/opal-dump.c
@@ -423,6 +423,10 @@ void __init opal_platform_dump_init(void)
 {
int rc;
 
+   /* ELOG not supported by firmware */
+   if (!opal_check_token(OPAL_DUMP_READ))
+   return;
+
dump_kset = kset_create_and_add(dump, NULL, opal_kobj);
if (!dump_kset) {
pr_warn(%s: Failed to create dump kset\n, __func__);
-- 
1.9.1

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

[PATCH 1/2] KVM: PPC: Book3S HV: Cleanup kvmppc_load/save_fp

2014-08-18 Thread Michael Neuling
This cleans up kvmppc_load/save_fp.  It removes unnecessary isyncs.  It also
removes the unnecessary resetting of the MSR bits on exit of kvmppc_save_fp.

Signed-off-by: Michael Neuling mi...@neuling.org
Signed-off-by: Paul Mackerras pau...@samba.org
---
 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S 
b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index f0c4db7..c4bd2d7 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -2434,7 +2434,6 @@ BEGIN_FTR_SECTION
 END_FTR_SECTION_IFSET(CPU_FTR_VSX)
 #endif
mtmsrd  r8
-   isync
addir3,r3,VCPU_FPRS
bl  store_fp_state
 #ifdef CONFIG_ALTIVEC
@@ -2470,7 +2469,6 @@ BEGIN_FTR_SECTION
 END_FTR_SECTION_IFSET(CPU_FTR_VSX)
 #endif
mtmsrd  r8
-   isync
addir3,r4,VCPU_FPRS
bl  load_fp_state
 #ifdef CONFIG_ALTIVEC
-- 
1.9.1

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

[PATCH 2/2] KVM: PPC: Book3S HV: Add register name when loading toc

2014-08-18 Thread Michael Neuling
Add 'r' to register name r2 in kvmppc_hv_enter.

Also update comment at the top of kvmppc_hv_enter to indicate that R2/TOC is
non-volatile.

Signed-off-by: Michael Neuling mi...@neuling.org
Signed-off-by: Paul Mackerras pau...@samba.org
---
 arch/powerpc/kvm/book3s_hv_rmhandlers.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S 
b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index c4bd2d7..1e8c480 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -355,6 +355,7 @@ kvmppc_hv_entry:
 * MSR = ~IR|DR
 * R13 = PACA
 * R1 = host R1
+* R2 = TOC
 * all other volatile GPRS = free
 */
mflrr0
@@ -503,7 +504,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 toc_tlbie_lock:
.tc native_tlbie_lock[TC],native_tlbie_lock
.previous
-   ld  r3,toc_tlbie_lock@toc(2)
+   ld  r3,toc_tlbie_lock@toc(r2)
 #ifdef __BIG_ENDIAN__
lwz r8,PACA_LOCK_TOKEN(r13)
 #else
-- 
1.9.1

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

Re: [PATCH 1/2] KVM: PPC: Book3S HV: Cleanup kvmppc_load/save_fp

2014-08-18 Thread Paul Mackerras
On Tue, Aug 19, 2014 at 02:59:29PM +1000, Michael Neuling wrote:
 This cleans up kvmppc_load/save_fp.  It removes unnecessary isyncs.

NAK - they are necessary on PPC970, which we (still) support.  You
could put them in a feature section if they are really annoying you.

  It also
 removes the unnecessary resetting of the MSR bits on exit of kvmppc_save_fp.

... except it doesn't. :)  That got folded into e4e38121507a (KVM:
PPC: Book3S HV: Add transactional memory support).

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

Re: [PATCH 1/2] KVM: PPC: Book3S HV: Cleanup kvmppc_load/save_fp

2014-08-18 Thread Michael Neuling
On Tue, 2014-08-19 at 15:24 +1000, Paul Mackerras wrote:
 On Tue, Aug 19, 2014 at 02:59:29PM +1000, Michael Neuling wrote:
  This cleans up kvmppc_load/save_fp.  It removes unnecessary isyncs.
 
 NAK - they are necessary on PPC970, which we (still) support.  You
 could put them in a feature section if they are really annoying you.

I'm not fussed, but we should at least have a comment there for why we
need them.

   It also
  removes the unnecessary resetting of the MSR bits on exit of kvmppc_save_fp.
 
 ... except it doesn't. :)  That got folded into e4e38121507a (KVM:
 PPC: Book3S HV: Add transactional memory support).

Arrh, thanks.  This patch was cleaning up stuff from an old local tree
and couldn't see where it had been upstreamed.  I missed this.

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