LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: Add macros for the ibm_architecture_vec[] lengths
From: Michael Ellerman @ 2014-08-29  7:01 UTC (permalink / raw)
  To: linuxppc-dev

The encoding of the lengths in the ibm_architecture_vec array is
"interesting" to say the least. It's non-obvious how the number of bytes
we provide relates to the length value.

In fact we already got it wrong once, see 11e9ed43ca8a "Fix up
ibm_architecture_vec definition".

So add some macros to make it (hopefully) clearer. These at least have
the property that the integer present in the code is equal to the number
of bytes that follows it.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/prom_init.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 1a85d8f96739..962ac852ce0b 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -642,6 +642,15 @@ static void __init early_cmdline_parse(void)
 #define W(x)	((x) >> 24) & 0xff, ((x) >> 16) & 0xff, \
 		((x) >> 8) & 0xff, (x) & 0xff
 
+/* Firmware expects the value to be n - 1, where n is the # of vectors */
+#define NUM_VECTORS(n)		((n) - 1)
+
+/*
+ * Firmware expects 1 + n - 2, where n is the length of the option vector in
+ * bytes. The 1 accounts for the length byte itself, the - 2 .. ?
+ */
+#define VECTOR_LENGTH(n)	(1 + (n) - 2)
+
 unsigned char ibm_architecture_vec[] = {
 	W(0xfffe0000), W(0x003a0000),	/* POWER5/POWER5+ */
 	W(0xffff0000), W(0x003e0000),	/* POWER6 */
@@ -652,16 +661,16 @@ unsigned char ibm_architecture_vec[] = {
 	W(0xffffffff), W(0x0f000003),	/* all 2.06-compliant */
 	W(0xffffffff), W(0x0f000002),	/* all 2.05-compliant */
 	W(0xfffffffe), W(0x0f000001),	/* all 2.04-compliant and earlier */
-	6 - 1,				/* 6 option vectors */
+	NUM_VECTORS(6),			/* 6 option vectors */
 
 	/* option vector 1: processor architectures supported */
-	3 - 2,				/* length */
+	VECTOR_LENGTH(2),		/* length */
 	0,				/* don't ignore, don't halt */
 	OV1_PPC_2_00 | OV1_PPC_2_01 | OV1_PPC_2_02 | OV1_PPC_2_03 |
 	OV1_PPC_2_04 | OV1_PPC_2_05 | OV1_PPC_2_06 | OV1_PPC_2_07,
 
 	/* option vector 2: Open Firmware options supported */
-	34 - 2,				/* length */
+	VECTOR_LENGTH(33),		/* length */
 	OV2_REAL_MODE,
 	0, 0,
 	W(0xffffffff),			/* real_base */
@@ -675,17 +684,17 @@ unsigned char ibm_architecture_vec[] = {
 	48,				/* max log_2(hash table size) */
 
 	/* option vector 3: processor options supported */
-	3 - 2,				/* length */
+	VECTOR_LENGTH(2),		/* length */
 	0,				/* don't ignore, don't halt */
 	OV3_FP | OV3_VMX | OV3_DFP,
 
 	/* option vector 4: IBM PAPR implementation */
-	3 - 2,				/* length */
+	VECTOR_LENGTH(2),		/* length */
 	0,				/* don't halt */
 	OV4_MIN_ENT_CAP,		/* minimum VP entitled capacity */
 
 	/* option vector 5: PAPR/OF options */
-	19 - 2,				/* length */
+	VECTOR_LENGTH(18),		/* length */
 	0,				/* don't ignore, don't halt */
 	OV5_FEAT(OV5_LPAR) | OV5_FEAT(OV5_SPLPAR) | OV5_FEAT(OV5_LARGE_PAGES) |
 	OV5_FEAT(OV5_DRCONF_MEMORY) | OV5_FEAT(OV5_DONATE_DEDICATE_CPU) |
@@ -718,12 +727,12 @@ unsigned char ibm_architecture_vec[] = {
 	OV5_FEAT(OV5_PFO_HW_RNG) | OV5_FEAT(OV5_PFO_HW_ENCR) |
 	OV5_FEAT(OV5_PFO_HW_842),
 	OV5_FEAT(OV5_SUB_PROCESSORS),
+
 	/* option vector 6: IBM PAPR hints */
-	4 - 2,				/* length */
+	VECTOR_LENGTH(3),		/* length */
 	0,
 	0,
 	OV6_LINUX,
-
 };
 
 /* Old method - ELF header with PT_NOTE sections only works on BE */
-- 
1.9.1

^ permalink raw reply related

* Re: [PATCH] powerpc: Check flat device tree version at boot
From: Michael Ellerman @ 2014-08-29  1:55 UTC (permalink / raw)
  To: Rob Herring; +Cc: Grant Likely, linuxppc-dev, Rob Herring
In-Reply-To: <CAL_Jsq+DSC4DW-ULuFfUjowsCOXbRnXvYSQcLY4inuBuztuh7A@mail.gmail.com>

On Thu, 2014-08-28 at 09:27 -0500, Rob Herring wrote:
> On Thu, Aug 28, 2014 at 3:40 AM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> > In commit e6a6928c3ea1 "of/fdt: Convert FDT functions to use libfdt",
> > the kernel stopped supporting old flat device tree formats. The minimum
> > supported version is now 0x10.
> 
> Ugg. Is that something which needs to be supported? Supporting it at
> this point would mean adding support to libfdt.

Well it would have been nice to keep supporting v2, dropping it broke
kexec-tools for example. But it's done now, so we'll just deal with the
fallout.

If you can CC linuxppc-dev in future on patches that fundamentally change the
device tree parsing that would be appreciated :)

cheers

^ permalink raw reply

* Re: [PATCH v2] cpufreq: powernv: Set the cpus to nominal frequency during reboot/kexec
From: Viresh Kumar @ 2014-08-29  0:03 UTC (permalink / raw)
  To: Shilpasri G Bhat
  Cc: linux-pm@vger.kernel.org, Rafael J. Wysocki,
	Linux Kernel Mailing List, Preeti U Murthy,
	linuxppc-dev@lists.ozlabs.org
In-Reply-To: <1409234816-10802-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com>

On 28 August 2014 19:36, Shilpasri G Bhat
<shilpa.bhat@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 set the cpus to nominal frequncy.
>
> Changes v1->v2:
> Invoke .target() driver callback to set the cpus to nominal frequency
> in reboot notifier, instead of calling cpufreq_suspend() as suggested
> by Viresh Kumar.
> Modified the commit message.

This changelog will get commited, is this what you want?

> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
> Reviewed-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
> ---
>  drivers/cpufreq/powernv-cpufreq.c | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
>
> diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
> index 379c083..ba27c49 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>
> @@ -35,6 +36,7 @@
>  #define POWERNV_MAX_PSTATES    256
>
>  static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1];
> +static bool rebooting;
>
>  /*
>   * Note: The set of pstates consists of contiguous integers, the
> @@ -284,6 +286,15 @@ static void set_pstate(void *freq_data)
>  }
>
>  /*
> + * get_nominal_index: Returns the index corresponding to the nominal
> + * pstate in the cpufreq table
> + */
> +static inline unsigned int get_nominal_index(void)
> +{
> +       return powernv_pstate_info.max - powernv_pstate_info.nominal;
> +}
> +
> +/*
>   * powernv_cpufreq_target_index: Sets the frequency corresponding to
>   * the cpufreq table entry indexed by new_index on the cpus in the
>   * mask policy->cpus
> @@ -293,6 +304,9 @@ static int powernv_cpufreq_target_index(struct cpufreq_policy *policy,
>  {
>         struct powernv_smp_call_data freq_data;
>
> +       if (unlikely(rebooting) && new_index != get_nominal_index())
> +               return -EBUSY;

Have you placed the unlikely only around 'rebooting' intentionally or
should it cover whole if statement?

> +
>         freq_data.pstate_id = powernv_freqs[new_index].driver_data;
>
>         /*
> @@ -317,6 +331,25 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
>         return cpufreq_table_validate_and_show(policy, powernv_freqs);
>  }
>
> +static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
> +                               unsigned long action, void *unused)
> +{
> +       int cpu;
> +       struct cpufreq_policy cpu_policy;
> +
> +       rebooting = true;
> +       for_each_online_cpu(cpu) {
> +               cpufreq_get_policy(&cpu_policy, cpu);
> +               powernv_cpufreq_target_index(&cpu_policy, get_nominal_index());
> +       }
> +
> +       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,
> @@ -342,12 +375,14 @@ static int __init powernv_cpufreq_init(void)
>                 return rc;
>         }
>
> +       register_reboot_notifier(&powernv_cpufreq_reboot_nb);
>         return cpufreq_register_driver(&powernv_cpufreq_driver);
>  }
>  module_init(powernv_cpufreq_init);
>
>  static void __exit powernv_cpufreq_exit(void)
>  {
> +       unregister_reboot_notifier(&powernv_cpufreq_reboot_nb);
>         cpufreq_unregister_driver(&powernv_cpufreq_driver);
>  }
>  module_exit(powernv_cpufreq_exit);

Looks fine otherwise.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

^ permalink raw reply

* Re: Linux 3.16: all my drivers on SPI bus report WARNING: at drivers/base/dd.c:286
From: Stijn Devriendt @ 2014-08-28 20:28 UTC (permalink / raw)
  To: leroy christophe
  Cc: LinuxPPC-dev, linux-spi, Axel Lin, linux-kernel@vger.kernel.org,
	Mark Brown
In-Reply-To: <53FF5097.7090000@c-s.fr>

On Thu, Aug 28, 2014 at 5:53 PM, leroy christophe
<christophe.leroy@c-s.fr> wrote:
>
> I've been able to identify the origin of the issue. It happens since the below commit.
> Do you know what should be done to fix that ?
>
> Christophe
>
>

Actually, more things are wrong with what the driver is doing.
If inside spi_add_device() the call to device_add() fails, then that
code bails out without any call to spi_cleanup() and the same
memory will leak (Is this intended?).

Basically, fsl_spi_setup allocates memory using devm_kzalloc, while
device_add expects that any memory allocated via this way is only
done in the device's probe function.

The simple fix would be to do a normal allocation (revert the patch) and
add a free to the cleanup() function. Unfortunately that doesn't fix the
memleak I mentioned above.

So, some outside-the-box thinking brings me to conclude that another way
to fix this problem is to allocate the devm_kzalloc not on the device's
resource
list but on the controller's resources (it's controller state after all...).

Regards,
Stijn

^ permalink raw reply

* Re: Linux 3.16: all my drivers on SPI bus report WARNING: at drivers/base/dd.c:286
From: Stijn Devriendt @ 2014-08-28 20:26 UTC (permalink / raw)
  To: leroy christophe
  Cc: LinuxPPC-dev, linux-spi, Axel Lin, linux-kernel@vger.kernel.org,
	Mark Brown
In-Reply-To: <53FF5097.7090000@c-s.fr>

[-- Attachment #1: Type: text/plain, Size: 1067 bytes --]

On Thu, Aug 28, 2014 at 5:53 PM, leroy christophe <christophe.leroy@c-s.fr>
wrote:

> I've been able to identify the origin of the issue. It happens since the
> below commit.
> Do you know what should be done to fix that ?
>
> Christophe
>

Actually, more things are wrong with what the driver is doing.
If inside spi_add_device() the call to device_add() fails, then that
code bails out without any call to spi_cleanup() and the same
memory will leak (Is this intended?).

Basically, fsl_spi_setup allocates memory using devm_kzalloc, while
device_add expects that any memory allocated via this way is only
done in the device's probe function.

The simple fix would be to do a normal allocation (revert the patch) and
add a free to the cleanup() function. Unfortunately that doesn't fix the
memleak I mentioned above.

So, some outside-the-box thinking brings me to conclude that another way
to fix this problem is to allocate the devm_kzalloc not on the device's
resource
list but on the controller's resources (it's controller state after all...).

Regards,
Stijn

[-- Attachment #2: Type: text/html, Size: 1561 bytes --]

^ permalink raw reply

* Re: [RESEND] clk: ppc-corenet: Add Freescale ARM-based platforms CLK_OF_DECLARE support
From: Scott Wood @ 2014-08-28 16:25 UTC (permalink / raw)
  To: Lu Jingchang-B35083
  Cc: linuxppc-dev@lists.ozlabs.org, mturquette@linaro.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
In-Reply-To: <f7b4263f189346a391d66c85756b4907@BL2PR03MB467.namprd03.prod.outlook.com>

On Thu, 2014-08-28 at 05:05 -0500, Lu Jingchang-B35083 wrote:
> >-----Original Message-----
> >From: Wood Scott-B07421
> >Sent: Thursday, August 28, 2014 7:34 AM
> >To: Lu Jingchang-B35083
> >Cc: mturquette@linaro.org; linuxppc-dev@lists.ozlabs.org; linux-
> >kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org
> >Subject: Re: [RESEND] clk: ppc-corenet: Add Freescale ARM-based platforms
> >CLK_OF_DECLARE support
> >
> >On Tue, 2014-08-26 at 21:19 -0500, Lu Jingchang-B35083 wrote:
> >> >-----Original Message-----
> >> >From: Wood Scott-B07421
> >> >Sent: Wednesday, August 27, 2014 6:51 AM
> >> >To: Lu Jingchang-B35083
> >> >Cc: mturquette@linaro.org; linuxppc-dev@lists.ozlabs.org; linux-
> >> >kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org
> >> >Subject: Re: [RESEND] clk: ppc-corenet: Add Freescale ARM-based
> >> >platforms CLK_OF_DECLARE support
> >> >
> >> >On Fri, 2014-08-22 at 17:34 +0800, Jingchang Lu wrote:
> >> >> +CLK_OF_DECLARE(ppc_core_pll_v1, "fsl,qoriq-core-pll-1.0",
> >> >core_pll_init);
> >> >> +CLK_OF_DECLARE(ppc_core_pll_v2, "fsl,qoriq-core-pll-2.0",
> >> >core_pll_init);
> >> >> +CLK_OF_DECLARE(ppc_core_mux_v1, "fsl,qoriq-core-mux-1.0",
> >> >core_mux_init);
> >> >> +CLK_OF_DECLARE(ppc_core_mux_v2, "fsl,qoriq-core-mux-2.0",
> >> >core_mux_init);
> >> >
> >> >What does this do that the existing platform driver and match table
> >> >don't?  Why is it needed for ARM when PPC didn't need it?
> >> >
> >> >-Scott
> >> >
> >> Common clk init on ARM platform is initialized earlier via
> >> of_clk_init() instead of driver probe method, the of_clk_init will
> >> walk a __clk_of_table to init each clk provider in the table, the
> >> CLK_OF_DECLARE() macro puts a supported clk in the __clk_of_table for it
> >initializing on starup, and the clk system has added some common clk such
> >as "fixed-clk"
> >> to this table already.
> >> So here I add our specific clk init declaration to consist this
> >> framework, and the driver probe function will not be needed on ARM.
> >
> >OK... Is there any reason why the new method won't work on PPC?
> >
> PPC has little dependence on the clock tree but frequency, it will work well
> if adopted I think.

I'm just saying it seems redundant to have both.  Even on ARM, won't
this result in the clock getting registered twice (albeit with one of
those times being too late)?

Regardless of what dependence PPC has on the clock tree, what stops this
method of enumeration from working on PPC?  Is there anything required
other than inserting a call to of_clk_init(NULL) in the arch init code?

-Scott

^ permalink raw reply

* Re: Linux 3.16: all my drivers on SPI bus report WARNING: at drivers/base/dd.c:286
From: leroy christophe @ 2014-08-28 15:53 UTC (permalink / raw)
  To: Axel Lin, Mark Brown
  Cc: LinuxPPC-dev, linux-kernel@vger.kernel.org, linux-spi
In-Reply-To: <53F31707.4040300@c-s.fr>

I've been able to identify the origin of the issue. It happens since the below commit.
Do you know what should be done to fix that ?

Christophe


 From 7a40054361162d2f78f332aa868fed137beb7901 Mon Sep 17 00:00:00 2001
From: Axel Lin <axel.lin@ingics.com>
Date: Sun, 30 Mar 2014 16:42:57 +0800
Subject: spi: fsl-spi: Fix memory leak

mpc8xxx_spi_probe() has set master->cleanup = mpc8xxx_spi_cleanup,
however current code overrides the setting in fsl_spi_probe() and set
master->cleanup = fsl_spi_cleanup.
Thus the memory allocated for cs is not freed anywhere.
Convert to use devm_kzalloc to fix the memory leak.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>

diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index b3e7775..98ccd23 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -431,7 +431,7 @@ static int fsl_spi_setup(struct spi_device *spi)
  		return -EINVAL;
  
  	if (!cs) {
-		cs = kzalloc(sizeof *cs, GFP_KERNEL);
+		cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL);
  		if (!cs)
  			return -ENOMEM;
  		spi->controller_state = cs;
-- 
cgit v0.10.1


Le 19/08/2014 11:21, leroy christophe a écrit :
> Since Linux 3.16, for all drivers tied to SPI bus, I get the following 
> warning on a PowerPC 8xx.
> It doesn't happen with Linux 3.15
>
> What can be the reason / what should I look at ?
>
> [    3.086957] device: 'spi32766.1': device_add
> [    3.087179] bus: 'spi': add device spi32766.1
> [    3.087653] bus: 'spi': driver_probe_device: matched device 
> spi32766.1 with driver lm70
> [    3.087743] bus: 'spi': really_probe: probing driver lm70 with 
> device spi32766.1
> [    3.088014] ------------[ cut here ]------------
> [    3.092348] WARNING: at drivers/base/dd.c:286
> [    3.096637] Modules linked in:
> [    3.099697] CPU: 0 PID: 25 Comm: kworker/u2:1 Tainted: G W 
> 3.16.1-s3k-drv-999-svn5771_knld-999 #158
> [    3.109610] Workqueue: deferwq deferred_probe_work_func
> [    3.114736] task: c787f020 ti: c790c000 task.ti: c790c000
> [    3.120062] NIP: c01df158 LR: c01df144 CTR: 00000000
> [    3.124983] REGS: c790db30 TRAP: 0700   Tainted: G        W 
> (3.16.1-s3k-drv-999-svn5771_knld-999)
> [    3.134162] MSR: 00029032 <EE,ME,IR,DR,RI>  CR: 22002082 XER: 20000000
> [    3.140703]
> [    3.140703] GPR00: 00000001 c790dbe0 c787f020 00000044 00000054 
> 00000308 c056da0e 20737069
> [    3.140703] GPR08: 33323736 000ebfe0 00000308 000ebfdf 22002082 
> 00000000 c046c5a0 c046c608
> [    3.140703] GPR16: c046c614 c046c620 c046c62c c046c638 c046c648 
> c046c654 c046c68c c046c6c4
> [    3.140703] GPR24: 00000000 00000000 00000003 c0401aa0 c0596638 
> c059662c c054e7a8 c7996800
> [    3.170102] NIP [c01df158] driver_probe_device+0xf8/0x334
> [    3.175431] LR [c01df144] driver_probe_device+0xe4/0x334
> [    3.180633] Call Trace:
> [    3.183093] [c790dbe0] [c01df144] driver_probe_device+0xe4/0x334 
> (unreliable)
> [    3.190147] [c790dc10] [c01dd15c] bus_for_each_drv+0x7c/0xc0
> [    3.195741] [c790dc40] [c01df5fc] device_attach+0xcc/0xf8
> [    3.201076] [c790dc60] [c01dd6d4] bus_probe_device+0xb4/0xc4
> [    3.206666] [c790dc80] [c01db9f8] device_add+0x270/0x564
> [    3.211923] [c790dcc0] [c0219e84] spi_add_device+0xc0/0x190
> [    3.217427] [c790dce0] [c021a79c] spi_register_master+0x720/0x834
> [    3.223455] [c790dd40] [c021cb48] of_fsl_spi_probe+0x55c/0x614
> [    3.229234] [c790dda0] [c01e0d2c] platform_drv_probe+0x30/0x74
> [    3.234987] [c790ddb0] [c01df18c] driver_probe_device+0x12c/0x334
> [    3.241008] [c790dde0] [c01dd15c] bus_for_each_drv+0x7c/0xc0
> [    3.246602] [c790de10] [c01df5fc] device_attach+0xcc/0xf8
> [    3.251937] [c790de30] [c01dd6d4] bus_probe_device+0xb4/0xc4
> [    3.257536] [c790de50] [c01de9d8] deferred_probe_work_func+0x98/0xe0
> [    3.263816] [c790de70] [c00305b8] process_one_work+0x18c/0x440
> [    3.269577] [c790dea0] [c0030a00] worker_thread+0x194/0x67c
> [    3.275105] [c790def0] [c0039198] kthread+0xd0/0xe4
> [    3.279911] [c790df40] [c000c6d0] ret_from_kernel_thread+0x5c/0x64
> [    3.285970] Instruction dump:
> [    3.288900] 80de0000 419e01d0 3b7b0038 3c60c046 7f65db78 38635264 
> 48211b99 813f00a0
> [    3.296559] 381f00a0 7d290278 3169ffff 7c0b4910 <0f000000> 93df0044 
> 7fe3fb78 4bfffd4d
> [    3.304401] ---[ end trace c75d3461bf9e2961 ]---
> [    3.309598] device: 'hwmon1': device_add
> [    3.310246] driver: 'lm70': driver_bound: bound to device 'spi32766.1'
> [    3.310342] bus: 'spi': really_probe: bound device spi32766.1 to 
> driver lm70
>
> Christophe

^ permalink raw reply related

* [PATCH] drivers: char: hw_random: printk replacement
From: Sudip Mukherjee @ 2014-08-28 15:02 UTC (permalink / raw)
  To: Matt Mackall, Herbert Xu, Olof Johansson
  Cc: linuxppc-dev, Sudip Mukherjee, linux-geode, linux-kernel

as pr_* macros are more preffered over printk, so printk replaced with corresponding pr_* macros

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---

The replacement was done by a bash script to avoid copy paste error. The script is as follows :

OLD="printk(KERN_ERR \?"
OLD1="printk(KERN_NOTICE \?"
OLD2="printk(KERN_WARNING \?"
OLD3="printk(KERN_INFO \?"
NEW="pr_err("
NEW1="pr_notice("
NEW2="pr_warn("
NEW3="pr_info("
TFILE="/tmp/out.tmp.$$"
for f in *.c
do
sed -e "s/$OLD/$NEW/g" -e "s/$OLD1/$NEW1/g" -e "s/$OLD2/$NEW2/g" -e "s/$OLD3/$NEW3/g" "$f" > $TFILE && mv $TFILE "$f"
done

Frankly speaking this script has missed one instance of printk(warning) in intel-rng.c file , and this one was edited manually.

 drivers/char/hw_random/amd-rng.c     |  4 ++--
 drivers/char/hw_random/geode-rng.c   |  4 ++--
 drivers/char/hw_random/intel-rng.c   | 12 ++++++------
 drivers/char/hw_random/pasemi-rng.c  |  2 +-
 drivers/char/hw_random/pseries-rng.c |  2 +-
 drivers/char/hw_random/via-rng.c     |  8 ++++----
 6 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/char/hw_random/amd-rng.c b/drivers/char/hw_random/amd-rng.c
index c6af038..48f6a83 100644
--- a/drivers/char/hw_random/amd-rng.c
+++ b/drivers/char/hw_random/amd-rng.c
@@ -142,10 +142,10 @@ found:
 	amd_rng.priv = (unsigned long)pmbase;
 	amd_pdev = pdev;
 
-	printk(KERN_INFO "AMD768 RNG detected\n");
+	pr_info("AMD768 RNG detected\n");
 	err = hwrng_register(&amd_rng);
 	if (err) {
-		printk(KERN_ERR PFX "RNG registering failed (%d)\n",
+		pr_err(PFX "RNG registering failed (%d)\n",
 		       err);
 		release_region(pmbase + 0xF0, 8);
 		goto out;
diff --git a/drivers/char/hw_random/geode-rng.c b/drivers/char/hw_random/geode-rng.c
index 4c4d4e1..0d0579f 100644
--- a/drivers/char/hw_random/geode-rng.c
+++ b/drivers/char/hw_random/geode-rng.c
@@ -109,10 +109,10 @@ found:
 		goto out;
 	geode_rng.priv = (unsigned long)mem;
 
-	printk(KERN_INFO "AMD Geode RNG detected\n");
+	pr_info("AMD Geode RNG detected\n");
 	err = hwrng_register(&geode_rng);
 	if (err) {
-		printk(KERN_ERR PFX "RNG registering failed (%d)\n",
+		pr_err(PFX "RNG registering failed (%d)\n",
 		       err);
 		goto err_unmap;
 	}
diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
index 86fe45c..3122376 100644
--- a/drivers/char/hw_random/intel-rng.c
+++ b/drivers/char/hw_random/intel-rng.c
@@ -199,7 +199,7 @@ static int intel_rng_init(struct hwrng *rng)
 	if ((hw_status & INTEL_RNG_ENABLED) == 0)
 		hw_status = hwstatus_set(mem, hw_status | INTEL_RNG_ENABLED);
 	if ((hw_status & INTEL_RNG_ENABLED) == 0) {
-		printk(KERN_ERR PFX "cannot enable RNG, aborting\n");
+		pr_err(PFX "cannot enable RNG, aborting\n");
 		goto out;
 	}
 	err = 0;
@@ -216,7 +216,7 @@ static void intel_rng_cleanup(struct hwrng *rng)
 	if (hw_status & INTEL_RNG_ENABLED)
 		hwstatus_set(mem, hw_status & ~INTEL_RNG_ENABLED);
 	else
-		printk(KERN_WARNING PFX "unusual: RNG already disabled\n");
+		pr_warn(PFX "unusual: RNG already disabled\n");
 }
 
 
@@ -274,7 +274,7 @@ static int __init intel_rng_hw_init(void *_intel_rng_hw)
 	if (mfc != INTEL_FWH_MANUFACTURER_CODE ||
 	    (dvc != INTEL_FWH_DEVICE_CODE_8M &&
 	     dvc != INTEL_FWH_DEVICE_CODE_4M)) {
-		printk(KERN_NOTICE PFX "FWH not detected\n");
+		pr_notice(PFX "FWH not detected\n");
 		return -ENODEV;
 	}
 
@@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
 
 		if (no_fwh_detect)
 			return -ENODEV;
-		printk(warning);
+		pr_warn(warning);
 		return -EBUSY;
 	}
 
@@ -392,10 +392,10 @@ fwh_done:
 		goto out;
 	}
 
-	printk(KERN_INFO "Intel 82802 RNG detected\n");
+	pr_info("Intel 82802 RNG detected\n");
 	err = hwrng_register(&intel_rng);
 	if (err) {
-		printk(KERN_ERR PFX "RNG registering failed (%d)\n",
+		pr_err(PFX "RNG registering failed (%d)\n",
 		       err);
 		iounmap(mem);
 	}
diff --git a/drivers/char/hw_random/pasemi-rng.c b/drivers/char/hw_random/pasemi-rng.c
index c66279b..c0347d1 100644
--- a/drivers/char/hw_random/pasemi-rng.c
+++ b/drivers/char/hw_random/pasemi-rng.c
@@ -113,7 +113,7 @@ static int rng_probe(struct platform_device *ofdev)
 
 	pasemi_rng.priv = (unsigned long)rng_regs;
 
-	printk(KERN_INFO "Registering PA Semi RNG\n");
+	pr_info("Registering PA Semi RNG\n");
 
 	err = hwrng_register(&pasemi_rng);
 
diff --git a/drivers/char/hw_random/pseries-rng.c b/drivers/char/hw_random/pseries-rng.c
index ab7ffde..6226aa0 100644
--- a/drivers/char/hw_random/pseries-rng.c
+++ b/drivers/char/hw_random/pseries-rng.c
@@ -86,7 +86,7 @@ static struct vio_driver pseries_rng_driver = {
 
 static int __init rng_init(void)
 {
-	printk(KERN_INFO "Registering IBM pSeries RNG driver\n");
+	pr_info("Registering IBM pSeries RNG driver\n");
 	return vio_register_driver(&pseries_rng_driver);
 }
 
diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c
index de5a6dc..a3bebef 100644
--- a/drivers/char/hw_random/via-rng.c
+++ b/drivers/char/hw_random/via-rng.c
@@ -141,7 +141,7 @@ static int via_rng_init(struct hwrng *rng)
 	 * register */
 	if ((c->x86 == 6) && (c->x86_model >= 0x0f)) {
 		if (!cpu_has_xstore_enabled) {
-			printk(KERN_ERR PFX "can't enable hardware RNG "
+			pr_err(PFX "can't enable hardware RNG "
 				"if XSTORE is not enabled\n");
 			return -ENODEV;
 		}
@@ -180,7 +180,7 @@ static int via_rng_init(struct hwrng *rng)
 	   unneeded */
 	rdmsr(MSR_VIA_RNG, lo, hi);
 	if ((lo & VIA_RNG_ENABLE) == 0) {
-		printk(KERN_ERR PFX "cannot enable VIA C3 RNG, aborting\n");
+		pr_err(PFX "cannot enable VIA C3 RNG, aborting\n");
 		return -ENODEV;
 	}
 
@@ -202,10 +202,10 @@ static int __init mod_init(void)
 
 	if (!cpu_has_xstore)
 		return -ENODEV;
-	printk(KERN_INFO "VIA RNG detected\n");
+	pr_info("VIA RNG detected\n");
 	err = hwrng_register(&via_rng);
 	if (err) {
-		printk(KERN_ERR PFX "RNG registering failed (%d)\n",
+		pr_err(PFX "RNG registering failed (%d)\n",
 		       err);
 		goto out;
 	}
-- 
1.8.1.2

^ permalink raw reply related

* Re: [PATCH] powerpc: Check flat device tree version at boot
From: Rob Herring @ 2014-08-28 14:27 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Grant Likely, linuxppc-dev, Rob Herring
In-Reply-To: <1409215247-10195-1-git-send-email-mpe@ellerman.id.au>

On Thu, Aug 28, 2014 at 3:40 AM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> In commit e6a6928c3ea1 "of/fdt: Convert FDT functions to use libfdt",
> the kernel stopped supporting old flat device tree formats. The minimum
> supported version is now 0x10.

Ugg. Is that something which needs to be supported? Supporting it at
this point would mean adding support to libfdt.

Rob

> There was a checking function added, early_init_dt_verify(), but it's
> not called on powerpc.
>
> The result is, if you boot with an old flat device tree, the kernel will
> fail to parse it correctly, think you have no memory etc. and hilarity
> ensues.
>
> We can't really fix it, but we can at least catch the fact that the
> device tree is in an unsupported format and panic(). We can't call
> BUG(), it's too early.
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/kernel/prom.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index 4e139f8a69ef..bb777b255b1c 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -641,6 +641,10 @@ void __init early_init_devtree(void *params)
>
>         DBG(" -> early_init_devtree(%p)\n", params);
>
> +       /* Too early to BUG_ON(), do it by hand */
> +       if (!early_init_dt_verify(params))
> +               panic("BUG: Failed verifying flat device tree, bad version?");
> +
>         /* Setup flat device-tree pointer */
>         initial_boot_params = params;
>
> --
> 1.9.1
>

^ permalink raw reply

* [PATCH v2] cpufreq: powernv: Set the cpus to nominal frequency during reboot/kexec
From: Shilpasri G Bhat @ 2014-08-28 14:06 UTC (permalink / raw)
  To: viresh.kumar, benh
  Cc: linux-pm, rjw, linux-kernel, Shilpasri G Bhat, preeti,
	linuxppc-dev

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 set the cpus to nominal frequncy.

Changes v1->v2:
Invoke .target() driver callback to set the cpus to nominal frequency
in reboot notifier, instead of calling cpufreq_suspend() as suggested
by Viresh Kumar.
Modified the commit message.

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

diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 379c083..ba27c49 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>
@@ -35,6 +36,7 @@
 #define POWERNV_MAX_PSTATES	256
 
 static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1];
+static bool rebooting;
 
 /*
  * Note: The set of pstates consists of contiguous integers, the
@@ -284,6 +286,15 @@ static void set_pstate(void *freq_data)
 }
 
 /*
+ * get_nominal_index: Returns the index corresponding to the nominal
+ * pstate in the cpufreq table
+ */
+static inline unsigned int get_nominal_index(void)
+{
+	return powernv_pstate_info.max - powernv_pstate_info.nominal;
+}
+
+/*
  * powernv_cpufreq_target_index: Sets the frequency corresponding to
  * the cpufreq table entry indexed by new_index on the cpus in the
  * mask policy->cpus
@@ -293,6 +304,9 @@ static int powernv_cpufreq_target_index(struct cpufreq_policy *policy,
 {
 	struct powernv_smp_call_data freq_data;
 
+	if (unlikely(rebooting) && new_index != get_nominal_index())
+		return -EBUSY;
+
 	freq_data.pstate_id = powernv_freqs[new_index].driver_data;
 
 	/*
@@ -317,6 +331,25 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	return cpufreq_table_validate_and_show(policy, powernv_freqs);
 }
 
+static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
+				unsigned long action, void *unused)
+{
+	int cpu;
+	struct cpufreq_policy cpu_policy;
+
+	rebooting = true;
+	for_each_online_cpu(cpu) {
+		cpufreq_get_policy(&cpu_policy, cpu);
+		powernv_cpufreq_target_index(&cpu_policy, get_nominal_index());
+	}
+
+	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,
@@ -342,12 +375,14 @@ static int __init powernv_cpufreq_init(void)
 		return rc;
 	}
 
+	register_reboot_notifier(&powernv_cpufreq_reboot_nb);
 	return cpufreq_register_driver(&powernv_cpufreq_driver);
 }
 module_init(powernv_cpufreq_init);
 
 static void __exit powernv_cpufreq_exit(void)
 {
+	unregister_reboot_notifier(&powernv_cpufreq_reboot_nb);
 	cpufreq_unregister_driver(&powernv_cpufreq_driver);
 }
 module_exit(powernv_cpufreq_exit);
-- 
1.9.3

^ permalink raw reply related

* RE: [RESEND] clk: ppc-corenet: Add Freescale ARM-based platforms CLK_OF_DECLARE support
From: Jingchang Lu @ 2014-08-28 10:05 UTC (permalink / raw)
  To: Scott Wood
  Cc: linuxppc-dev@lists.ozlabs.org, mturquette@linaro.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
In-Reply-To: <1409182412.6510.129.camel@snotra.buserror.net>

Pi0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+RnJvbTogV29vZCBTY290dC1CMDc0MjENCj5T
ZW50OiBUaHVyc2RheSwgQXVndXN0IDI4LCAyMDE0IDc6MzQgQU0NCj5UbzogTHUgSmluZ2NoYW5n
LUIzNTA4Mw0KPkNjOiBtdHVycXVldHRlQGxpbmFyby5vcmc7IGxpbnV4cHBjLWRldkBsaXN0cy5v
emxhYnMub3JnOyBsaW51eC0NCj5rZXJuZWxAdmdlci5rZXJuZWwub3JnOyBsaW51eC1hcm0ta2Vy
bmVsQGxpc3RzLmluZnJhZGVhZC5vcmcNCj5TdWJqZWN0OiBSZTogW1JFU0VORF0gY2xrOiBwcGMt
Y29yZW5ldDogQWRkIEZyZWVzY2FsZSBBUk0tYmFzZWQgcGxhdGZvcm1zDQo+Q0xLX09GX0RFQ0xB
UkUgc3VwcG9ydA0KPg0KPk9uIFR1ZSwgMjAxNC0wOC0yNiBhdCAyMToxOSAtMDUwMCwgTHUgSmlu
Z2NoYW5nLUIzNTA4MyB3cm90ZToNCj4+ID4tLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPj4g
PkZyb206IFdvb2QgU2NvdHQtQjA3NDIxDQo+PiA+U2VudDogV2VkbmVzZGF5LCBBdWd1c3QgMjcs
IDIwMTQgNjo1MSBBTQ0KPj4gPlRvOiBMdSBKaW5nY2hhbmctQjM1MDgzDQo+PiA+Q2M6IG10dXJx
dWV0dGVAbGluYXJvLm9yZzsgbGludXhwcGMtZGV2QGxpc3RzLm96bGFicy5vcmc7IGxpbnV4LQ0K
Pj4gPmtlcm5lbEB2Z2VyLmtlcm5lbC5vcmc7IGxpbnV4LWFybS1rZXJuZWxAbGlzdHMuaW5mcmFk
ZWFkLm9yZw0KPj4gPlN1YmplY3Q6IFJlOiBbUkVTRU5EXSBjbGs6IHBwYy1jb3JlbmV0OiBBZGQg
RnJlZXNjYWxlIEFSTS1iYXNlZA0KPj4gPnBsYXRmb3JtcyBDTEtfT0ZfREVDTEFSRSBzdXBwb3J0
DQo+PiA+DQo+PiA+T24gRnJpLCAyMDE0LTA4LTIyIGF0IDE3OjM0ICswODAwLCBKaW5nY2hhbmcg
THUgd3JvdGU6DQo+PiA+PiArQ0xLX09GX0RFQ0xBUkUocHBjX2NvcmVfcGxsX3YxLCAiZnNsLHFv
cmlxLWNvcmUtcGxsLTEuMCIsDQo+PiA+Y29yZV9wbGxfaW5pdCk7DQo+PiA+PiArQ0xLX09GX0RF
Q0xBUkUocHBjX2NvcmVfcGxsX3YyLCAiZnNsLHFvcmlxLWNvcmUtcGxsLTIuMCIsDQo+PiA+Y29y
ZV9wbGxfaW5pdCk7DQo+PiA+PiArQ0xLX09GX0RFQ0xBUkUocHBjX2NvcmVfbXV4X3YxLCAiZnNs
LHFvcmlxLWNvcmUtbXV4LTEuMCIsDQo+PiA+Y29yZV9tdXhfaW5pdCk7DQo+PiA+PiArQ0xLX09G
X0RFQ0xBUkUocHBjX2NvcmVfbXV4X3YyLCAiZnNsLHFvcmlxLWNvcmUtbXV4LTIuMCIsDQo+PiA+
Y29yZV9tdXhfaW5pdCk7DQo+PiA+DQo+PiA+V2hhdCBkb2VzIHRoaXMgZG8gdGhhdCB0aGUgZXhp
c3RpbmcgcGxhdGZvcm0gZHJpdmVyIGFuZCBtYXRjaCB0YWJsZQ0KPj4gPmRvbid0PyAgV2h5IGlz
IGl0IG5lZWRlZCBmb3IgQVJNIHdoZW4gUFBDIGRpZG4ndCBuZWVkIGl0Pw0KPj4gPg0KPj4gPi1T
Y290dA0KPj4gPg0KPj4gQ29tbW9uIGNsayBpbml0IG9uIEFSTSBwbGF0Zm9ybSBpcyBpbml0aWFs
aXplZCBlYXJsaWVyIHZpYQ0KPj4gb2ZfY2xrX2luaXQoKSBpbnN0ZWFkIG9mIGRyaXZlciBwcm9i
ZSBtZXRob2QsIHRoZSBvZl9jbGtfaW5pdCB3aWxsDQo+PiB3YWxrIGEgX19jbGtfb2ZfdGFibGUg
dG8gaW5pdCBlYWNoIGNsayBwcm92aWRlciBpbiB0aGUgdGFibGUsIHRoZQ0KPj4gQ0xLX09GX0RF
Q0xBUkUoKSBtYWNybyBwdXRzIGEgc3VwcG9ydGVkIGNsayBpbiB0aGUgX19jbGtfb2ZfdGFibGUg
Zm9yIGl0DQo+aW5pdGlhbGl6aW5nIG9uIHN0YXJ1cCwgYW5kIHRoZSBjbGsgc3lzdGVtIGhhcyBh
ZGRlZCBzb21lIGNvbW1vbiBjbGsgc3VjaA0KPmFzICJmaXhlZC1jbGsiDQo+PiB0byB0aGlzIHRh
YmxlIGFscmVhZHkuDQo+PiBTbyBoZXJlIEkgYWRkIG91ciBzcGVjaWZpYyBjbGsgaW5pdCBkZWNs
YXJhdGlvbiB0byBjb25zaXN0IHRoaXMNCj4+IGZyYW1ld29yaywgYW5kIHRoZSBkcml2ZXIgcHJv
YmUgZnVuY3Rpb24gd2lsbCBub3QgYmUgbmVlZGVkIG9uIEFSTS4NCj4NCj5PSy4uLiBJcyB0aGVy
ZSBhbnkgcmVhc29uIHdoeSB0aGUgbmV3IG1ldGhvZCB3b24ndCB3b3JrIG9uIFBQQz8NCj4NClBQ
QyBoYXMgbGl0dGxlIGRlcGVuZGVuY2Ugb24gdGhlIGNsb2NrIHRyZWUgYnV0IGZyZXF1ZW5jeSwg
aXQgd2lsbCB3b3JrIHdlbGwNCmlmIGFkb3B0ZWQgSSB0aGluay4NCg0KDQoNCkJlc3QgUmVnYXJk
cywNCkppbmdjaGFuZw0KDQoNCg0K

^ permalink raw reply

* [PATCH] powerpc: Check flat device tree version at boot
From: Michael Ellerman @ 2014-08-28  8:40 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: grant.likely, robh+dt

In commit e6a6928c3ea1 "of/fdt: Convert FDT functions to use libfdt",
the kernel stopped supporting old flat device tree formats. The minimum
supported version is now 0x10.

There was a checking function added, early_init_dt_verify(), but it's
not called on powerpc.

The result is, if you boot with an old flat device tree, the kernel will
fail to parse it correctly, think you have no memory etc. and hilarity
ensues.

We can't really fix it, but we can at least catch the fact that the
device tree is in an unsupported format and panic(). We can't call
BUG(), it's too early.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/prom.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 4e139f8a69ef..bb777b255b1c 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -641,6 +641,10 @@ void __init early_init_devtree(void *params)
 
 	DBG(" -> early_init_devtree(%p)\n", params);
 
+	/* Too early to BUG_ON(), do it by hand */
+	if (!early_init_dt_verify(params))
+		panic("BUG: Failed verifying flat device tree, bad version?");
+
 	/* Setup flat device-tree pointer */
 	initial_boot_params = params;
 
-- 
1.9.1

^ permalink raw reply related

* [PATCH] powerpc: dts: t4240: Change T4240 USB controller version
From: Nikhil Badola @ 2014-08-28  3:51 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: devicetree, Nikhil Badola

Change USB controller version to 2.5 in compatible string for T4240

Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
---
 arch/powerpc/boot/dts/fsl/t4240si-post.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/dts/fsl/t4240si-post.dtsi b/arch/powerpc/boot/dts/fsl/t4240si-post.dtsi
index a3d582e..7e2fc7c 100644
--- a/arch/powerpc/boot/dts/fsl/t4240si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/t4240si-post.dtsi
@@ -498,13 +498,13 @@
 /include/ "qoriq-gpio-3.dtsi"
 /include/ "qoriq-usb2-mph-0.dtsi"
 		usb0: usb@210000 {
-			compatible = "fsl-usb2-mph-v2.4", "fsl-usb2-mph";
+			compatible = "fsl-usb2-mph-v2.5", "fsl-usb2-mph";
 			phy_type = "utmi";
 			port0;
 		};
 /include/ "qoriq-usb2-dr-0.dtsi"
 		usb1: usb@211000 {
-			compatible = "fsl-usb2-dr-v2.4", "fsl-usb2-dr";
+			compatible = "fsl-usb2-dr-v2.5", "fsl-usb2-dr";
 			dr_mode = "host";
 			phy_type = "utmi";
 		};
-- 
1.7.11.7

^ permalink raw reply related

* Re: [PATCH V7 04/17] PCI: Take additional IOV BAR alignment in sizing and assigning
From: Wei Yang @ 2014-08-28  2:34 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, qiudayu, benh, linuxppc-dev, gwshan
In-Reply-To: <20140820061402.GA8381@richard>

Bjorn,

Is my understanding correct? Could I send another version based on your
comment, so that we can see it meets your requirement? 

On Wed, Aug 20, 2014 at 02:14:02PM +0800, Wei Yang wrote:
>On Tue, Aug 19, 2014 at 09:08:41PM -0600, Bjorn Helgaas wrote:
>>On Thu, Jul 24, 2014 at 02:22:14PM +0800, Wei Yang wrote:
>>> At resource sizing/assigning stage, resources are divided into two lists,
>>> requested list and additional list, while the alignement of the additional
>>> IOV BAR is not taken into the sizeing and assigning procedure.
>>> 
>>> This is reasonable in the original implementation, since IOV BAR's alignment is
>>> mostly the size of a PF BAR alignemt. This means the alignment is already taken
>>> into consideration. While this rule may be violated on some platform.
>>> 
>>> This patch take the additional IOV BAR alignment in sizing and assigning stage
>>> explicitly.
>>> 
>>> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
>>> ---
>>>  drivers/pci/setup-bus.c |   68 +++++++++++++++++++++++++++++++++++++++++------
>>>  1 file changed, 60 insertions(+), 8 deletions(-)
>>> 
>>> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
>>> index a5a63ec..d83681f 100644
>>> --- a/drivers/pci/setup-bus.c
>>> +++ b/drivers/pci/setup-bus.c
>>> @@ -120,6 +120,28 @@ static resource_size_t get_res_add_size(struct list_head *head,
>>>  	return 0;
>>>  }
>>>  
>>> +static resource_size_t get_res_add_align(struct list_head *head,
>>> +		struct resource *res)
>>> +{
>>> +	struct pci_dev_resource *dev_res;
>>> +
>>> +	list_for_each_entry(dev_res, head, list) {
>>> +		if (dev_res->res == res) {
>>> +			int idx = res - &dev_res->dev->resource[0];
>>> +
>>> +			dev_printk(KERN_DEBUG, &dev_res->dev->dev,
>>> +				   "res[%d]=%pR get_res_add_align min_align %llx\n",
>>> +				   idx, dev_res->res,
>>> +				   (unsigned long long)dev_res->min_align);
>>> +
>>> +			return dev_res->min_align;
>>> +		}
>>> +	}
>>> +
>>> +	return 0;
>>> +}
>>
>>I see that you copied the structure of the existing get_res_add_size()
>>here.  But I don't understand *that* function.  It looks basically like
>>this:
>>
>>  resource_size_t get_res_add_size(list, res)
>>  {
>>    list_for_each_entry(dev_res, head, list) {
>>      if (dev_res->res == res)
>>        return dev_res->add_size;
>>    }
>>    return 0;
>>  }
>>
>>and we call it like this:
>>
>>  dev_res->res->end += get_res_add_size(realloc_head, dev_res->res);
>>
>>So we start out with dev_res", pass in dev_res->res, search the
>>realloc_head list to find dev_res again, and return dev_res->add_size.
>>That looks equivalent to just:
>>
>>  dev_res->res->end += dev_res->add_size;
>>
>>It looks like get_res_add_size() merely adds a printk and some complexity.
>>Am I missing something?
>>
>
>Let me try to explain it, if not correct, please let know :-)
>
>  dev_res->res->end += get_res_add_size(realloc_head, dev_res->res);
>
>would be expanded to:
>
>  dev_res->res->end += dev_res_1->add_size;
>
>with the dev_res_1 is another one from dev_res which is stored in realloc_head.
>
>>I do see that there are other callers where we don't actually start with
>>dev_res, which makes it a little more complicated.  But I think you should
>>either add something like this:
>>
>>  struct pci_dev_resource *res_to_dev_res(list, res)
>>  {
>>    list_for_each_entry(dev_res, head, list) {
>>      if (dev_res->res == res)
>>        return dev_res;
>>    }
>>    return NULL;
>>  }
>>
>
>Ok, we can extract the common part of these two functions.
>
>>which can be used to replace get_res_add_size() and get_res_add_align(), OR
>>figure out whether the dev_res of interest is always one we've just added.
>>If it is, maybe you can just make add_to_list() return the dev_res pointer
>>instead of an errno, and hang onto the pointer.  I'd like that much better
>>if that's possible.
>>
>
>Sorry, I don't get this point.
>
>add_to_list() is used to create the pci_dev_resource list, get_res_add_size()
>and get_res_add_align() is to retrieve the information in the list. I am not
>sure how to leverage add_to_list() in these two functions?
>
>>> +
>>> +
>>>  /* Sort resources by alignment */
>>>  static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
>>>  {
>>> @@ -368,8 +390,9 @@ static void __assign_resources_sorted(struct list_head *head,
>>>  	LIST_HEAD(save_head);
>>>  	LIST_HEAD(local_fail_head);
>>>  	struct pci_dev_resource *save_res;
>>> -	struct pci_dev_resource *dev_res, *tmp_res;
>>> +	struct pci_dev_resource *dev_res, *tmp_res, *dev_res2;
>>>  	unsigned long fail_type;
>>> +	resource_size_t add_align, align;
>>>  
>>>  	/* Check if optional add_size is there */
>>>  	if (!realloc_head || list_empty(realloc_head))
>>> @@ -384,10 +407,31 @@ static void __assign_resources_sorted(struct list_head *head,
>>>  	}
>>>  
>>>  	/* Update res in head list with add_size in realloc_head list */
>>> -	list_for_each_entry(dev_res, head, list)
>>> +	list_for_each_entry_safe(dev_res, tmp_res, head, list) {
>>>  		dev_res->res->end += get_res_add_size(realloc_head,
>>>  							dev_res->res);
>>>  
>>> +		if (!(dev_res->res->flags & IORESOURCE_STARTALIGN))
>>> +			continue;
>>> +
>>> +		add_align = get_res_add_align(realloc_head, dev_res->res);
>>> +
>>> +		if (add_align > dev_res->res->start) {
>>> +			dev_res->res->start = add_align;
>>> +			dev_res->res->end = add_align +
>>> +				            resource_size(dev_res->res);
>>> +
>>> +			list_for_each_entry(dev_res2, head, list) {
>>> +				align = pci_resource_alignment(dev_res2->dev,
>>> +							       dev_res2->res);
>>> +				if (add_align > align)
>>> +					list_move_tail(&dev_res->list,
>>> +						       &dev_res2->list);
>>> +			}
>>> +               }
>>> +
>>> +	}
>>> +
>>>  	/* Try updated head list with add_size added */
>>>  	assign_requested_resources_sorted(head, &local_fail_head);
>>>  
>>> @@ -930,6 +974,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
>>>  	struct resource *b_res = find_free_bus_resource(bus,
>>>  					mask | IORESOURCE_PREFETCH, type);
>>>  	resource_size_t children_add_size = 0;
>>> +	resource_size_t children_add_align = 0;
>>> +	resource_size_t add_align = 0;
>>>  
>>>  	if (!b_res)
>>>  		return -ENOSPC;
>>> @@ -954,6 +1000,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
>>>  			/* put SRIOV requested res to the optional list */
>>>  			if (realloc_head && i >= PCI_IOV_RESOURCES &&
>>>  					i <= PCI_IOV_RESOURCE_END) {
>>> +				add_align = max(pci_resource_alignment(dev, r), add_align);
>>>  				r->end = r->start - 1;
>>>  				add_to_list(realloc_head, dev, r, r_size, 0/* don't care */);
>>>  				children_add_size += r_size;
>>> @@ -984,8 +1031,11 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
>>>  			if (order > max_order)
>>>  				max_order = order;
>>>  
>>> -			if (realloc_head)
>>> +			if (realloc_head) {
>>>  				children_add_size += get_res_add_size(realloc_head, r);
>>> +				children_add_align = get_res_add_align(realloc_head, r);
>>> +				add_align = max(add_align, children_add_align);
>>> +			}
>>>  		}
>>>  	}
>>>  
>>> @@ -996,7 +1046,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
>>>  		add_size = children_add_size;
>>>  	size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 :
>>>  		calculate_memsize(size, min_size, add_size,
>>> -				resource_size(b_res), min_align);
>>> +				resource_size(b_res), max(min_align, add_align));
>>>  	if (!size0 && !size1) {
>>>  		if (b_res->start || b_res->end)
>>>  			dev_info(&bus->self->dev, "disabling bridge window %pR to %pR (unused)\n",
>>> @@ -1008,10 +1058,12 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
>>>  	b_res->end = size0 + min_align - 1;
>>>  	b_res->flags |= IORESOURCE_STARTALIGN;
>>>  	if (size1 > size0 && realloc_head) {
>>> -		add_to_list(realloc_head, bus->self, b_res, size1-size0, min_align);
>>> -		dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window %pR to %pR add_size %llx\n",
>>> -			   b_res, &bus->busn_res,
>>> -			   (unsigned long long)size1-size0);
>>> +		add_to_list(realloc_head, bus->self, b_res, size1-size0,
>>> +				max(min_align, add_align));
>>> +		dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window "
>>> +				 "%pR to %pR add_size %llx add_align %llx\n", b_res,
>>> +				 &bus->busn_res, (unsigned long long)size1-size0,
>>> +				 max(min_align, add_align));
>>
>>Factor out this "max(min_align, add_align)" thing so we don't have to
>>change these lines.  Bonus points if you can also factor it out of the
>>calculate_memsize() call above.  That one is a pretty complicated ternary
>>expression that should probably be turned into an "if" instead anyway.
>>
>
>Ok, I get your point. Let me make it more easy to read.
>
>>>  	}
>>>  	return 0;
>>>  }
>>> -- 
>>> 1.7.9.5
>>> 
>
>-- 
>Richard Yang
>Help you, Help me

-- 
Richard Yang
Help you, Help me

^ permalink raw reply

* Re: [PATCH] Documentation: dts: fsl-usb: Document USB node compatible string for IP version
From: Scott Wood @ 2014-08-27 23:34 UTC (permalink / raw)
  To: Mehresh Ramneek-B31383
  Cc: devicetree@vger.kernel.org, Badola Nikhil-B46172,
	linuxppc-dev@lists.ozlabs.org
In-Reply-To: <7032a06004444bc3af8d71c799e974e0@BL2PR03MB161.namprd03.prod.outlook.com>

On Wed, 2014-08-27 at 00:46 -0500, Mehresh Ramneek-B31383 wrote:
> 
> > -----Original Message-----
> > From: Wood Scott-B07421
> > Sent: Wednesday, August 27, 2014 4:23 AM
> > To: Mehresh Ramneek-B31383
> > Cc: Badola Nikhil-B46172; linuxppc-dev@lists.ozlabs.org;
> > devicetree@vger.kernel.org
> > Subject: Re: [PATCH] Documentation: dts: fsl-usb: Document USB node
> > compatible string for IP version
> > 
> > On Fri, 2014-08-22 at 00:05 -0500, Mehresh Ramneek-B31383 wrote:
> > >
> > > -----Original Message-----
> > > From: Badola Nikhil-B46172
> > > Sent: Friday, August 22, 2014 10:18 AM
> > > To: Wood Scott-B07421
> > > Cc: linuxppc-dev@lists.ozlabs.org; devicetree@vger.kernel.org; Mehresh
> > > Ramneek-B31383
> > > Subject: RE: [PATCH] Documentation: dts: fsl-usb: Document USB node
> > > compatible string for IP version
> > >
> > > Adding Ramneek
> > >
> > > > -----Original Message-----
> > > > From: Wood Scott-B07421
> > > > Sent: Friday, August 22, 2014 3:53 AM
> > > > To: Badola Nikhil-B46172
> > > > Cc: linuxppc-dev@lists.ozlabs.org; devicetree@vger.kernel.org
> > > > Subject: Re: [PATCH] Documentation: dts: fsl-usb: Document USB node
> > > > compatible string for IP version
> > > >
> > > > On Thu, 2014-08-21 at 14:48 +0530, Nikhil Badola wrote:
> > > > > Document compatible string containing IP version in USB device
> > > > > tree node
> > > > >
> > > > > Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
> > > > > ---
> > > > >  Documentation/devicetree/bindings/usb/fsl-usb.txt | 13
> > > > > ++++++++-----
> > > > >  1 file changed, 8 insertions(+), 5 deletions(-)
> > > >
> > > > Please CC devicetree@vger.kernel.org on all device tree patches (in
> > > > addition to linuxppc-dev).
> > > >
> > > > >
> > > > > diff --git a/Documentation/devicetree/bindings/usb/fsl-usb.txt
> > > > > b/Documentation/devicetree/bindings/usb/fsl-usb.txt
> > > > > index 4779c02..5a3a0a8 100644
> > > > > --- a/Documentation/devicetree/bindings/usb/fsl-usb.txt
> > > > > +++ b/Documentation/devicetree/bindings/usb/fsl-usb.txt
> > > > > @@ -10,7 +10,10 @@ Required properties :
> > > > >     controllers, or "fsl-usb2-dr" for dual role USB controllers
> > > > >     or "fsl,mpc5121-usb2-dr" for dual role USB controllers of MPC5121.
> > > > >     Wherever applicable, the IP version of the USB controller should
> > > > > -   also be mentioned (for eg. fsl-usb2-dr-v2.2 for bsc9132).
> > > > > +   also be mentioned in another string.
> > > > > +   For multi port host USB controller with IP version <IP_Ver>, it should
> > be
> > > > > +   "fsl-usb2-mph-<IP_Ver>". For dual role USB controller with IP version
> > > > > +   <IP_Ver>, it should be "fsl-usb2-dr-<IP_Ver>".
> > > >
> > > > It was documented before -- this is just making it more explicit, right?
> > > >
> > > > FWIW, the version number can be read out of a USB register, so I'd
> > > > rather remove the suggestion to specify the version number and
> > > > replace it with a reference to the ID register.
> > > we have following two issues -
> > > (a) our USBIP version register doesn't have consistent "version field
> > > size" over multiple version(s). This is why we couldn't use it for
> > > reading version info across various IP versions
> > > (b) this register is not exposed in all SoC RMs (probably because of
> > > above reason)
> > 
> > :-(
> > 
> > If this is just a problem with older chips, we could have a new compatible name
> > that designates the family of USB block versions with a sane version register.
> > 
> we could have done...but we have a requirement to write version specific code...
> for instance, usb controller init sequence has changes from version 2.5 onwards...
> then there are version specific errata fixe(s) also. Hence we decided to go for
> compatible string containing hw ip version (major no.) so that our workaround/code is
> consistent with hw ip version(s) published in errata(s)

I wasn't saying ignore version differences.  I was suggesting that we
make a special case out of older versions where the version register is
different/broken.

-Scott

^ permalink raw reply

* Re: [RESEND] clk: ppc-corenet: Add Freescale ARM-based platforms CLK_OF_DECLARE support
From: Scott Wood @ 2014-08-27 23:33 UTC (permalink / raw)
  To: Lu Jingchang-B35083
  Cc: linuxppc-dev@lists.ozlabs.org, mturquette@linaro.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
In-Reply-To: <164af7b3be3747a0be3fe3a6cf83d3b1@BL2PR03MB467.namprd03.prod.outlook.com>

On Tue, 2014-08-26 at 21:19 -0500, Lu Jingchang-B35083 wrote:
> >-----Original Message-----
> >From: Wood Scott-B07421
> >Sent: Wednesday, August 27, 2014 6:51 AM
> >To: Lu Jingchang-B35083
> >Cc: mturquette@linaro.org; linuxppc-dev@lists.ozlabs.org; linux-
> >kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org
> >Subject: Re: [RESEND] clk: ppc-corenet: Add Freescale ARM-based platforms
> >CLK_OF_DECLARE support
> >
> >On Fri, 2014-08-22 at 17:34 +0800, Jingchang Lu wrote:
> >> +CLK_OF_DECLARE(ppc_core_pll_v1, "fsl,qoriq-core-pll-1.0",
> >core_pll_init);
> >> +CLK_OF_DECLARE(ppc_core_pll_v2, "fsl,qoriq-core-pll-2.0",
> >core_pll_init);
> >> +CLK_OF_DECLARE(ppc_core_mux_v1, "fsl,qoriq-core-mux-1.0",
> >core_mux_init);
> >> +CLK_OF_DECLARE(ppc_core_mux_v2, "fsl,qoriq-core-mux-2.0",
> >core_mux_init);
> >
> >What does this do that the existing platform driver and match table
> >don't?  Why is it needed for ARM when PPC didn't need it?
> >
> >-Scott
> >
> Common clk init on ARM platform is initialized earlier via of_clk_init() instead of
> driver probe method, the of_clk_init will walk a __clk_of_table to init each clk provider
> in the table, the CLK_OF_DECLARE() macro puts a supported clk in the __clk_of_table for
> it initializing on starup, and the clk system has added some common clk such as "fixed-clk"
> to this table already.
> So here I add our specific clk init declaration to consist this framework, and the driver
> probe function will not be needed on ARM.

OK... Is there any reason why the new method won't work on PPC?

-Scott

^ permalink raw reply

* Re: [PATCH V3 3/3] powerpc, ptrace: Enable support for miscellaneous registers
From: Sukadev Bhattiprolu @ 2014-08-27 21:35 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: mikey, james.hogan, avagin, Paul.Clothier, davem, peterz, palves,
	linux-kernel, oleg, dhowells, linuxppc-dev, davej, akpm, tglx
In-Reply-To: <1400858138-3939-4-git-send-email-khandual@linux.vnet.ibm.com>


Anshuman Khandual [khandual@linux.vnet.ibm.com] wrote:
| This patch enables get and set of miscellaneous registers through ptrace
| PTRACE_GETREGSET/PTRACE_SETREGSET interface by implementing new powerpc
| specific register set REGSET_MISC support corresponding to the new ELF
| core note NT_PPC_MISC added previously in this regard.
| 
| Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
| ---
|  arch/powerpc/kernel/ptrace.c | 81 ++++++++++++++++++++++++++++++++++++++++++++
|  1 file changed, 81 insertions(+)
| 
| diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
| index 17642ef..63b883a 100644
| --- a/arch/powerpc/kernel/ptrace.c
| +++ b/arch/powerpc/kernel/ptrace.c
| @@ -1149,6 +1149,76 @@ static int tm_cvmx_set(struct task_struct *target, const struct user_regset *reg
|  #endif	/* CONFIG_PPC_TRANSACTIONAL_MEM */
|  
|  /*
| + * Miscellaneous Registers
| + *
| + * struct {
| + * 	unsigned long dscr;
| + *	unsigned long ppr;
| + * 	unsigned long tar;
| + * };
| + */
| +static int misc_get(struct task_struct *target, const struct user_regset *regset,
| +		   unsigned int pos, unsigned int count,
| +		   void *kbuf, void __user *ubuf)
| +{
| +	int ret;
| +
| +	/* DSCR register */
| +	ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +					&target->thread.dscr, 0,
| +					sizeof(unsigned long));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, dscr) + sizeof(unsigned long) +
| +				sizeof(unsigned long) != offsetof(struct thread_struct, ppr));


I see these in  arch/powerpc/include/asm/processor.h

#ifdef CONFIG_PPC64
        unsigned long   dscr;
        int             dscr_inherit;
        unsigned long   ppr;    /* used to save/restore SMT priority */
#endif

where there is an 'int' between ppr and dscr. So, should one of
the above sizeof(unsigned long) be changed to sizeof(int) ?

Also, since we use offsetof(struct thread_struct, field) heavily, a
macro local to the file, may simplify the code.

#define	TSO(f)	(offsetof(struct thread_struct, f))

| +
| +	/* PPR register */
| +	if (!ret)
| +		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +					  &target->thread.ppr, sizeof(unsigned long),
| +					  2 * sizeof(unsigned long));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, ppr) + sizeof(unsigned long)
| +						!= offsetof(struct thread_struct, tar));
| +	/* TAR register */
| +	if (!ret)
| +		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +					  &target->thread.tar, 2 * sizeof(unsigned long),
| +					  3 * sizeof(unsigned long));
| +	return ret;
| +}
| +
| +static int misc_set(struct task_struct *target, const struct user_regset *regset,
| +		   unsigned int pos, unsigned int count,
| +		   const void *kbuf, const void __user *ubuf)
| +{
| +	int ret;
| +
| +	/* DSCR register */
| +	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +					&target->thread.dscr, 0,
| +					sizeof(unsigned long));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, dscr) + sizeof(unsigned long) +
| +			sizeof(unsigned long) != offsetof(struct thread_struct, ppr));
| +
| +	/* PPR register */
| +	if (!ret)
| +		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +						&target->thread.ppr, sizeof(unsigned long),
| +						2 * sizeof(unsigned long));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, ppr) + sizeof(unsigned long)
| +						!= offsetof(struct thread_struct, tar));
| +
| +	/* TAR register */
| +	if (!ret)
| +		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +						&target->thread.tar, 2 * sizeof(unsigned long),
| +						3 * sizeof(unsigned long));
| +	return ret;
| +}
| +
| +/*
|   * These are our native regset flavors.
|   */
|  enum powerpc_regset {
| @@ -1169,6 +1239,7 @@ enum powerpc_regset {
|  	REGSET_TM_CFPR,		/* TM checkpointed FPR */
|  	REGSET_TM_CVMX,		/* TM checkpointed VMX */
|  #endif
| +	REGSET_MISC		/* Miscellaneous */
|  };
|  
|  static const struct user_regset native_regsets[] = {
| @@ -1225,6 +1296,11 @@ static const struct user_regset native_regsets[] = {
|  		.active = tm_cvmx_active, .get = tm_cvmx_get, .set = tm_cvmx_set
|  	},
|  #endif
| +	[REGSET_MISC] = {
| +		.core_note_type = NT_PPC_MISC, .n = 3,
| +		.size = sizeof(u64), .align = sizeof(u64),
| +		.get = misc_get, .set = misc_set
| +	},
|  };
|  
|  static const struct user_regset_view user_ppc_native_view = {
| @@ -1566,6 +1642,11 @@ static const struct user_regset compat_regsets[] = {
|  		.active = tm_cvmx_active, .get = tm_cvmx_get, .set = tm_cvmx_set
|  	},
|  #endif
| +	[REGSET_MISC] = {
| +		.core_note_type = NT_PPC_MISC, .n = 3,
| +		.size = sizeof(u64), .align = sizeof(u64),
| +		.get = misc_get, .set = misc_set
| +	},

Since the .n = 3 is used more than once, how about a macro for the
number of misc registers ?

|  };
|  
|  static const struct user_regset_view user_ppc_compat_view = {
| -- 
| 1.7.11.7
| 
| _______________________________________________
| Linuxppc-dev mailing list
| Linuxppc-dev@lists.ozlabs.org
| https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [PATCH V3 2/3] powerpc, ptrace: Enable support for transactional memory register sets
From: Sukadev Bhattiprolu @ 2014-08-27 21:35 UTC (permalink / raw)
  To: Anshuman Khandual
  Cc: mikey, james.hogan, avagin, Paul.Clothier, davem, peterz, palves,
	linux-kernel, oleg, dhowells, linuxppc-dev, davej, akpm, tglx
In-Reply-To: <1400858138-3939-3-git-send-email-khandual@linux.vnet.ibm.com>

Anshuman Khandual [khandual@linux.vnet.ibm.com] wrote:
| This patch enables get and set of transactional memory related register
| sets through PTRACE_GETREGSET/PTRACE_SETREGSET interface by implementing
| four new powerpc specific register sets i.e REGSET_TM_SPR, REGSET_TM_CGPR,
| REGSET_TM_CFPR, REGSET_CVMX support corresponding to these following new
| ELF core note types added previously in this regard.
| 
| 	(1) NT_PPC_TM_SPR
| 	(2) NT_PPC_TM_CGPR
| 	(3) NT_PPC_TM_CFPR
| 	(4) NT_PPC_TM_CVMX
| 
| Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
| ---
|  arch/powerpc/include/asm/switch_to.h |   8 +
|  arch/powerpc/kernel/process.c        |  24 ++
|  arch/powerpc/kernel/ptrace.c         | 792 +++++++++++++++++++++++++++++++++--
|  3 files changed, 795 insertions(+), 29 deletions(-)
| 
| diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h
| index 0e83e7d..2737f46 100644
| --- a/arch/powerpc/include/asm/switch_to.h
| +++ b/arch/powerpc/include/asm/switch_to.h
| @@ -80,6 +80,14 @@ static inline void flush_spe_to_thread(struct task_struct *t)
|  }
|  #endif
|  
| +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
| +extern void flush_tmregs_to_thread(struct task_struct *);
| +#else
| +static inline void flush_tmregs_to_thread(struct task_struct *t)
| +{
| +}
| +#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
| +
|  static inline void clear_task_ebb(struct task_struct *t)
|  {
|  #ifdef CONFIG_PPC_BOOK3S_64
| diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
| index 31d0215..e247898 100644
| --- a/arch/powerpc/kernel/process.c
| +++ b/arch/powerpc/kernel/process.c
| @@ -695,6 +695,30 @@ static inline void __switch_to_tm(struct task_struct *prev)
|  	}
|  }
|  
| +void flush_tmregs_to_thread(struct task_struct *tsk)
| +{
| +	/*
| +	 * If task is not current, it should have been flushed
| +	 * already to it's thread_struct during __switch_to().
| +	 */
| +	if (tsk != current)
| +		return;
| +
| +	preempt_disable();
| +	if (tsk->thread.regs) {
| +		/*
| +		 * If we are still current, the TM state need to
| +		 * be flushed to thread_struct as it will be still
| +		 * present in the current cpu.
| +		 */
| +		if (MSR_TM_ACTIVE(tsk->thread.regs->msr)) {
| +			__switch_to_tm(tsk);
| +			tm_recheckpoint_new_task(tsk);
| +		}
| +	}
| +	preempt_enable();
| +}
| +
|  /*
|   * This is called if we are on the way out to userspace and the
|   * TIF_RESTORE_TM flag is set.  It checks if we need to reload
| diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
| index 2e3d2bf..17642ef 100644
| --- a/arch/powerpc/kernel/ptrace.c
| +++ b/arch/powerpc/kernel/ptrace.c
| @@ -357,6 +357,17 @@ static int gpr_set(struct task_struct *target, const struct user_regset *regset,
|  	return ret;
|  }
|  
| +/*
| + * When any transaction is active, "thread_struct->transact_fp" holds
| + * the current running value of all FPR registers and "thread_struct->
| + * fp_state" holds the last checkpointed FPR registers state for the
| + * current transaction.
| + *
| + * struct data {
| + * 	u64	fpr[32];
| + * 	u64	fpscr;
| + * };
| + */

Maybe a reference to 'struct thread_fp_state' in the comments will help ?


|  static int fpr_get(struct task_struct *target, const struct user_regset *regset,
|  		   unsigned int pos, unsigned int count,
|  		   void *kbuf, void __user *ubuf)
| @@ -365,21 +376,41 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset,
|  	u64 buf[33];
|  	int i;
|  #endif
| -	flush_fp_to_thread(target);
| +	if (MSR_TM_ACTIVE(target->thread.regs->msr)) {
| +		flush_fp_to_thread(target);
| +		flush_altivec_to_thread(target);
| +		flush_tmregs_to_thread(target);
| +	} else {
| +		flush_fp_to_thread(target);
| +	}

flush_fp_to_thread(target) is uncondtional - so could be outside
the if and else blocks ?

|  
|  #ifdef CONFIG_VSX
|  	/* copy to local buffer then write that out */
| -	for (i = 0; i < 32 ; i++)
| -		buf[i] = target->thread.TS_FPR(i);
| -	buf[32] = target->thread.fp_state.fpscr;
| +	if (MSR_TM_ACTIVE(target->thread.regs->msr)) {
| +		for (i = 0; i < 32 ; i++)
| +			buf[i] = target->thread.TS_TRANS_FPR(i);
| +		buf[32] = target->thread.transact_fp.fpscr;
| +	} else {
| +		for (i = 0; i < 32 ; i++)
| +			buf[i] = target->thread.TS_FPR(i);
| +		buf[32] = target->thread.fp_state.fpscr;
| +	}
|  	return user_regset_copyout(&pos, &count, &kbuf, &ubuf, buf, 0, -1);
|  
|  #else
| -	BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
| -		     offsetof(struct thread_fp_state, fpr[32][0]));
| +	if (MSR_TM_ACTIVE(tsk->thread.regs->msr)) {
| +		BUILD_BUG_ON(offsetof(struct transact_fp, fpscr) !=
| +				offsetof(struct transact_fp, fpr[32][0]));

Is MSR_TM_ACTIVE() a run time check or compile time ?
ie is there a reason to move the compile time check into the if block ?

|  
| -	return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +		return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +				   &target->thread.transact_fp, 0, -1);
| +	} esle {
| +		BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
| +			     offsetof(struct thread_fp_state, fpr[32][0]));
| +
| +		return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
|  				   &target->thread.fp_state, 0, -1);
| +	}
|  #endif
|  }
|  
| @@ -391,23 +422,44 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,
|  	u64 buf[33];
|  	int i;
|  #endif
| -	flush_fp_to_thread(target);
| +	if (MSR_TM_ACTIVE(target->thread.regs->msr)) {
| +		flush_fp_to_thread(target);
| +		flush_altivec_to_thread(target);
| +		flush_tmregs_to_thread(target);
| +	} else {
| +		flush_fp_to_thread(target);
| +	}
|  

As mentioned above, flush_fp_to_thread() could be outside the if block.
|  #ifdef CONFIG_VSX
|  	/* copy to local buffer then write that out */
|  	i = user_regset_copyin(&pos, &count, &kbuf, &ubuf, buf, 0, -1);
|  	if (i)
|  		return i;
| -	for (i = 0; i < 32 ; i++)
| -		target->thread.TS_FPR(i) = buf[i];
| -	target->thread.fp_state.fpscr = buf[32];
| +	for (i = 0; i < 32 ; i++) {
| +		if (MSR_TM_ACTIVE(target->thread.regs->msr))
| +			target->thread.TS_TRANS_FPR(i) = buf[i];
| +		else
| +			target->thread.TS_FPR(i) = buf[i];
| +	}
| +	if (MSR_TM_ACTIVE(target->thread.regs->msr))
| +		target->thread.transact_fp.fpscr = buf[32];
| +	else
| +		target->thread.fp_state.fpscr = buf[32];

I think this code is easier to read than the similar code above
in fpr_get() where you have the 'for' loop in both if and else blocks.

|  	return 0;
|  #else
| -	BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
| -		     offsetof(struct thread_fp_state, fpr[32][0]));
| +	if (MSR_TM_ACTIVE(target->thread.regs->msr)) {
| +		BUILD_BUG_ON(offsetof(struct transact_fp, fpscr) !=
| +			     offsetof(struct transact_fp, fpr[32][0]));
|  
| -	return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| -				  &target->thread.fp_state, 0, -1);
| +		return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +					  &target->thread.transact_fp, 0, -1);
| +	} else {
| +		BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
| +			     offsetof(struct thread_fp_state, fpr[32][0]));
| +
| +		return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +				&target->thread.fp_state, 0, -1);
| +	}
|  #endif
|  }
|  
| @@ -432,20 +484,44 @@ static int vr_active(struct task_struct *target,
|  	return target->thread.used_vr ? regset->n : 0;
|  }
|  
| +/*
| + * When any transaction is active, "thread_struct->transact_vr" holds
| + * the current running value of all VMX registers and "thread_struct->
| + * vr_state" holds the last checkpointed value of VMX registers for the
| + * current transaction.
| + *
| + * struct data {
| + * 	vector128	vr[32];
| + * 	vector128	vscr;
| + * 	vector128	vrsave;
| + * };
| + */
|  static int vr_get(struct task_struct *target, const struct user_regset *regset,
|  		  unsigned int pos, unsigned int count,
|  		  void *kbuf, void __user *ubuf)
|  {
|  	int ret;
| +	struct thread_vr_state *addr;
|  
| -	flush_altivec_to_thread(target);
| +	if (MSR_TM_ACTIVE(target->thread.regs->msr)) {
| +		flush_fp_to_thread(target);
| +		flush_altivec_to_thread(target);

Is order of flush_fp_to_thread() and flush_altivec_to_thread()
significant or can we call flush_altivec_to_thread() unconditionally
outside the if block ?
| +		flush_tmregs_to_thread(target);
| +	} else {
| +		flush_altivec_to_thread(target);
| +	}
|  
|  	BUILD_BUG_ON(offsetof(struct thread_vr_state, vscr) !=
|  		     offsetof(struct thread_vr_state, vr[32]));
|  
| +	if (MSR_TM_ACTIVE(target->thread.regs->msr))
| +		addr = &target->thread.transact_vr;
| +	else
| +		addr = &target->thread.vr_state;
| +
|  	ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| -				  &target->thread.vr_state, 0,
| -				  33 * sizeof(vector128));
| +				addr, 0, 33 * sizeof(vector128));
| +
|  	if (!ret) {
|  		/*
|  		 * Copy out only the low-order word of vrsave.
| @@ -455,11 +531,14 @@ static int vr_get(struct task_struct *target, const struct user_regset *regset,
|  			u32 word;
|  		} vrsave;
|  		memset(&vrsave, 0, sizeof(vrsave));
| -		vrsave.word = target->thread.vrsave;
| +		if (MSR_TM_ACTIVE(target->thread.regs->msr))
| +			vrsave.word = target->thread.transact_vrsave;
| +		else
| +			vrsave.word = target->thread.vrsave;
| +
|  		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &vrsave,
|  					  33 * sizeof(vector128), -1);
|  	}
| -
|  	return ret;
|  }
|  
| @@ -467,16 +546,27 @@ static int vr_set(struct task_struct *target, const struct user_regset *regset,
|  		  unsigned int pos, unsigned int count,
|  		  const void *kbuf, const void __user *ubuf)
|  {
| +	struct thread_vr_state *addr;
|  	int ret;
|  
| -	flush_altivec_to_thread(target);
| +	if (MSR_TM_ACTIVE(target->thread.regs->msr)) {
| +		flush_fp_to_thread(target);
| +		flush_altivec_to_thread(target);
| +		flush_tmregs_to_thread(target);
| +	} else {
| +		flush_altivec_to_thread(target);
| +	}
|  
|  	BUILD_BUG_ON(offsetof(struct thread_vr_state, vscr) !=
|  		     offsetof(struct thread_vr_state, vr[32]));
|  
| +	if (MSR_TM_ACTIVE(target->thread.regs->msr))
| +		addr = &target->thread.transact_vr;
| +	else
| +		addr = &target->thread.vr_state;
|  	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| -				 &target->thread.vr_state, 0,
| -				 33 * sizeof(vector128));
| +			addr, 0, 33 * sizeof(vector128));
| +
|  	if (!ret && count > 0) {
|  		/*
|  		 * We use only the first word of vrsave.
| @@ -486,13 +576,21 @@ static int vr_set(struct task_struct *target, const struct user_regset *regset,
|  			u32 word;
|  		} vrsave;
|  		memset(&vrsave, 0, sizeof(vrsave));
| -		vrsave.word = target->thread.vrsave;
| +
| +		if (MSR_TM_ACTIVE(target->thread.regs->msr))
| +			vrsave.word = target->thread.transact_vrsave;
| +		else
| +			vrsave.word = target->thread.vrsave;
| +
|  		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &vrsave,
|  					 33 * sizeof(vector128), -1);
| -		if (!ret)
| -			target->thread.vrsave = vrsave.word;
| +		if (!ret) {
| +			if (MSR_TM_ACTIVE(target->thread.regs->msr))
| +				target->thread.transact_vrsave = vrsave.word;
| +			else
| +				target->thread.vrsave = vrsave.word;
| +		}
|  	}
| -
|  	return ret;
|  }
|  #endif /* CONFIG_ALTIVEC */
| @@ -613,6 +711,442 @@ static int evr_set(struct task_struct *target, const struct user_regset *regset,
|  }
|  #endif /* CONFIG_SPE */
|  
| +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
| +
| +static int tm_spr_active(struct task_struct *target,
| +				const struct user_regset *regset)
| +{
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return 0;
| +
| +	return regset->n;
| +}
| +/*
| + *  Transactional memory SPR
| + *
| + * struct {
| + * 	u64		tm_tfhar;
| + *	u64		tm_texasr;
| + *	u64		tm_tfiar;
| + *	unsigned long	tm_orig_msr;
| + * 	unsigned long	tm_tar;
| + *	unsigned long	tm_ppr;
| + *	unsigned long	tm_dscr;
| + * };
| + */
| +static int tm_spr_get(struct task_struct *target, const struct user_regset *regset,
| +		   unsigned int pos, unsigned int count,
| +		   void *kbuf, void __user *ubuf)
| +{
| +	int ret;
| +
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return -ENODATA;
| +
| +	flush_fp_to_thread(target);
| +	flush_altivec_to_thread(target);
| +	flush_tmregs_to_thread(target);
| +

Can we copy all the values ot a local buf and then do a single
copyout to user space ?

| +	/* TFHAR register */
| +	ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +			&target->thread.tm_tfhar, 0, sizeof(u64));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, tm_tfhar) +
| +			sizeof(u64) != offsetof(struct thread_struct, tm_texasr));
| +
| +	/* TEXASR register */
| +	if (!ret)
| +		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +			&target->thread.tm_texasr, sizeof(u64), 2 * sizeof(u64));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, tm_texasr) +
| +			sizeof(u64) != offsetof(struct thread_struct, tm_tfiar));
| +
| +	/* TFIAR register */
| +	if (!ret)
| +		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +			&target->thread.tm_tfiar, 2 * sizeof(u64), 3 * sizeof(u64));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, tm_tfiar) +
| +			sizeof(u64) != offsetof(struct thread_struct, tm_orig_msr));
| +
| +	/* TM checkpointed original MSR */
| +	if (!ret)
| +		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +			&target->thread.tm_orig_msr, 3 * sizeof(u64),
| +				3 * sizeof(u64) + sizeof(unsigned long));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, tm_orig_msr) +
| +			sizeof(unsigned long) + sizeof(struct pt_regs)
| +				!= offsetof(struct thread_struct, tm_tar));
| +
| +	/* TM checkpointed TAR register */
| +	if (!ret)
| +		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +			&target->thread.tm_tar, 3 * sizeof(u64) +
| +				sizeof(unsigned long) , 3 * sizeof(u64) +
| +					2 * sizeof(unsigned long));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, tm_tar)
| +			+ sizeof(unsigned long) !=
| +				offsetof(struct thread_struct, tm_ppr));
| +
| +	/* TM checkpointed PPR register */
| +	if (!ret)
| +		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +				&target->thread.tm_ppr, 3 * sizeof(u64) +
| +					2 * sizeof(unsigned long), 3 * sizeof(u64) +
| +						3 * sizeof(unsigned long));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, tm_ppr) +
| +			sizeof(unsigned long) !=
| +				offsetof(struct thread_struct, tm_dscr));
| +
| +	/* TM checkpointed DSCR register */
| +	if (!ret)
| +		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +			&target->thread.tm_dscr, 3 * sizeof(u64)
| +				+ 3 * sizeof(unsigned long), 3 * sizeof(u64)
| +						+ 4 * sizeof(unsigned long));
| +	return ret;
| +}
| +
| +static int tm_spr_set(struct task_struct *target, const struct user_regset *regset,
| +		   unsigned int pos, unsigned int count,
| +		   const void *kbuf, const void __user *ubuf)
| +{
| +	int ret;
| +
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return -ENODATA;
| +
| +	flush_fp_to_thread(target);
| +	flush_altivec_to_thread(target);
| +	flush_tmregs_to_thread(target);
| +
| +	/* TFHAR register */
| +	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +				&target->thread.tm_tfhar, 0, sizeof(u64));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, tm_tfhar)
| +		+ sizeof(u64) != offsetof(struct thread_struct, tm_texasr));

A single copyin into a local buffer followed by a local assignment would
be easier to read ?

It could be easier to read if all BUILD_BUG_ON() calls are in one place
maybe near the beginning of the function or in the header file.

| +
| +	/* TEXASR register */
| +	if (!ret)
| +		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +			&target->thread.tm_texasr, sizeof(u64), 2 * sizeof(u64));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, tm_texasr)
| +		+ sizeof(u64) != offsetof(struct thread_struct, tm_tfiar));
| +
| +	/* TFIAR register */
| +	if (!ret)
| +		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +			&target->thread.tm_tfiar, 2 * sizeof(u64), 3 * sizeof(u64));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, tm_tfiar)
| +		+ sizeof(u64) != offsetof(struct thread_struct, tm_orig_msr));
| +
| +	/* TM checkpointed orig MSR */
| +	if (!ret)
| +		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +			&target->thread.tm_orig_msr, 3 * sizeof(u64),
| +				3 * sizeof(u64) + sizeof(unsigned long));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, tm_orig_msr)
| +		+ sizeof(unsigned long) + sizeof(struct pt_regs) !=
| +			offsetof(struct thread_struct, tm_tar));
| +
| +	/* TM checkpointed TAR register */
| +	if (!ret)
| +		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +			&target->thread.tm_tar, 3 * sizeof(u64) +
| +				sizeof(unsigned long), 3 * sizeof(u64) +
| +					2 * sizeof(unsigned long));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, tm_tar)
| +			+ sizeof(unsigned long) != offsetof(struct thread_struct, tm_ppr));
| +
| +	/* TM checkpointed PPR register */
| +	if (!ret)
| +		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +				&target->thread.tm_ppr, 3 * sizeof(u64)
| +					+ 2 * sizeof(unsigned long), 3 * sizeof(u64)
| +					+ 3 * sizeof(unsigned long));
| +
| +	BUILD_BUG_ON(offsetof(struct thread_struct, tm_ppr) +
| +			sizeof(unsigned long) !=
| +				offsetof(struct thread_struct, tm_dscr));
| +
| +	/* TM checkpointed DSCR register */
| +	if (!ret)
| +		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +				&target->thread.tm_dscr,
| +					3 * sizeof(u64) + 3 * sizeof(unsigned long),
| +					3 * sizeof(u64) + 4 * sizeof(unsigned long));
| +
| +	return ret;
| +}
| +
| +static int tm_cgpr_active(struct task_struct *target,
| +				const struct user_regset *regset)
| +{
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return 0;
| +
| +	return regset->n;
| +}
| +
| +/*
| + * TM Checkpointed GPR
| + *
| + * struct data {
| + * 	struct pt_regs ckpt_regs;
| + * };
| + */
| +static int tm_cgpr_get(struct task_struct *target, const struct user_regset *regset,
| +		   unsigned int pos, unsigned int count,
| +		   void *kbuf, void __user *ubuf)
| +{
| +	int ret;
| +
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return -ENODATA;
| +
| +	flush_fp_to_thread(target);
| +	flush_altivec_to_thread(target);
| +	flush_tmregs_to_thread(target);
| +	ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +			&target->thread.ckpt_regs, 0,
| +				sizeof(struct pt_regs));
| +	return ret;
| +}
| +
| +static int tm_cgpr_set(struct task_struct *target, const struct user_regset *regset,
| +		   unsigned int pos, unsigned int count,
| +		   const void *kbuf, const void __user *ubuf)
| +{
| +	int ret;
| +
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return -ENODATA;
| +
| +	flush_fp_to_thread(target);
| +	flush_altivec_to_thread(target);
| +	flush_tmregs_to_thread(target);
| +	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +					&target->thread.ckpt_regs, 0,
| +						sizeof(struct pt_regs));
| +	return ret;
| +}
| +
| +static int tm_cfpr_active(struct task_struct *target,
| +				const struct user_regset *regset)
| +{
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return 0;
| +
| +	return regset->n;
| +}
| +
| +/*
| + * TM Checkpointed FPR
| + *
| + * struct data {
| + * 	u64	fpr[32];
| + * 	u64	fpscr;
| + * };
| + */
| +static int tm_cfpr_get(struct task_struct *target, const struct user_regset *regset,
| +		   unsigned int pos, unsigned int count,
| +		   void *kbuf, void __user *ubuf)
| +{
| +#ifdef CONFIG_VSX
| +	u64 buf[33];
| +	int i;
| +#endif
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return -ENODATA;
| +
| +	flush_fp_to_thread(target);
| +	flush_altivec_to_thread(target);
| +	flush_tmregs_to_thread(target);
| +
| +#ifdef CONFIG_VSX
| +	/* copy to local buffer then write that out */
| +	for (i = 0; i < 32 ; i++)
| +		buf[i] = target->thread.TS_FPR(i);
| +	buf[32] = target->thread.fp_state.fpscr;
| +	return user_regset_copyout(&pos, &count, &kbuf, &ubuf, buf, 0, -1);
| +
| +#else
| +	BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
| +		offsetof(struct thread_fp_state, fpr[32][0]));
| +
| +	return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +			&target->thread.thread_fp_state, 0, -1);
| +#endif
| +}
| +
| +static int tm_cfpr_set(struct task_struct *target, const struct user_regset *regset,
| +		   unsigned int pos, unsigned int count,
| +		   const void *kbuf, const void __user *ubuf)
| +{
| +#ifdef CONFIG_VSX
| +	u64 buf[33];
| +	int i;
| +#endif
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return -ENODATA;
| +
| +	flush_fp_to_thread(target);
| +	flush_altivec_to_thread(target);
| +	flush_tmregs_to_thread(target);
| +
| +#ifdef CONFIG_VSX
| +	/* copy to local buffer then write that out */
| +	i = user_regset_copyin(&pos, &count, &kbuf, &ubuf, buf, 0, -1);
| +	if (i)
| +		return i;
| +	for (i = 0; i < 32 ; i++)
| +		target->thread.TS_FPR(i) = buf[i];
| +	target->thread.fp_state.fpscr = buf[32];
| +	return 0;
| +#else
| +	BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
| +		      offsetof(struct thread_fp_state, fpr[32][0]));
| +
| +	return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +				&target->thread.fp_state, 0, -1);
| +#endif
| +}
| +
| +static int tm_cvmx_active(struct task_struct *target,
| +				const struct user_regset *regset)
| +{
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return 0;
| +
| +	return regset->n;
| +}

All these tm_*_active() functions do the same checks - maybe they could all
call a common function ?

| +
| +/*
| + * TM Checkpointed VMX
| + *
| + * struct data {
| + * 	vector128	vr[32];
| + * 	vector128	vscr;
| + * 	vector128	vrsave;
| + *};
| + */
| +static int tm_cvmx_get(struct task_struct *target, const struct user_regset *regset,
| +		   unsigned int pos, unsigned int count,
| +		   void *kbuf, void __user *ubuf)
| +{
| +	int ret;
| +
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return -ENODATA;
| +
| +	flush_fp_to_thread(target);
| +	flush_altivec_to_thread(target);
| +	flush_tmregs_to_thread(target);
| +
| +	BUILD_BUG_ON(offsetof(struct thread_vr_state, vscr) !=
| +		     offsetof(struct thread_vr_state, vr[32]));
| +
| +	ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
| +				  &target->thread.vr_state, 0,
| +				  33 * sizeof(vector128));
| +	if (!ret) {
| +		/*
| +		 * Copy out only the low-order word of vrsave.
| +		 */
| +		union {
| +			elf_vrreg_t reg;
| +			u32 word;
| +		} vrsave;
| +		memset(&vrsave, 0, sizeof(vrsave));
| +		vrsave.word = target->thread.vrsave;
| +		ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &vrsave,
| +					  33 * sizeof(vector128), -1);
| +	}
| +	return ret;
| +}
| +
| +static int tm_cvmx_set(struct task_struct *target, const struct user_regset *regset,
| +		   unsigned int pos, unsigned int count,
| +		   const void *kbuf, const void __user *ubuf)
| +{
| +	int ret;
| +
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return -ENODATA;
| +
| +	flush_fp_to_thread(target);
| +	flush_altivec_to_thread(target);
| +	flush_tmregs_to_thread(target);
| +
| +	BUILD_BUG_ON(offsetof(struct thread_vr_state, vscr) !=
| +		offsetof(struct thread_vr_state, vr[32]));
| +
| +	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
| +				 &target->thread.vr_state, 0,
| +				 33 * sizeof(vector128));
| +	if (!ret && count > 0) {
| +		/*
| +		 * We use only the first word of vrsave.
| +		 */
| +		union {
| +			elf_vrreg_t reg;
| +			u32 word;
| +		} vrsave;
| +		memset(&vrsave, 0, sizeof(vrsave));
| +		vrsave.word = target->thread.vrsave;
| +		ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &vrsave,
| +					 33 * sizeof(vector128), -1);
| +		if (!ret)
| +			target->thread.vrsave = vrsave.word;
| +	}
| +	return ret;
| +}
| +#endif	/* CONFIG_PPC_TRANSACTIONAL_MEM */
|  
|  /*
|   * These are our native regset flavors.
| @@ -629,6 +1163,12 @@ enum powerpc_regset {
|  #ifdef CONFIG_SPE
|  	REGSET_SPE,
|  #endif
| +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
| +	REGSET_TM_SPR,		/* TM specific SPR */
| +	REGSET_TM_CGPR,		/* TM checkpointed GPR */
| +	REGSET_TM_CFPR,		/* TM checkpointed FPR */
| +	REGSET_TM_CVMX,		/* TM checkpointed VMX */
| +#endif
|  };
|  
|  static const struct user_regset native_regsets[] = {
| @@ -663,6 +1203,28 @@ static const struct user_regset native_regsets[] = {
|  		.active = evr_active, .get = evr_get, .set = evr_set
|  	},
|  #endif
| +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
| +	[REGSET_TM_SPR] = {
| +		.core_note_type = NT_PPC_TM_SPR, .n = 7,

How about adding a macro ELF_NSPRREG for the 7 special registers ?

| +		.size = sizeof(u64), .align = sizeof(u64),
| +		.active = tm_spr_active, .get = tm_spr_get, .set = tm_spr_set
| +	},
| +	[REGSET_TM_CGPR] = {
| +		.core_note_type = NT_PPC_TM_CGPR, .n = ELF_NGREG,
| +		.size = sizeof(long), .align = sizeof(long),
| +		.active = tm_cgpr_active, .get = tm_cgpr_get, .set = tm_cgpr_set
| +	},
| +	[REGSET_TM_CFPR] = {
| +		.core_note_type = NT_PPC_TM_CFPR, .n = ELF_NFPREG,
| +		.size = sizeof(double), .align = sizeof(double),
| +		.active = tm_cfpr_active, .get = tm_cfpr_get, .set = tm_cfpr_set
| +	},
| +	[REGSET_TM_CVMX] = {
| +		.core_note_type = NT_PPC_TM_CVMX, .n = 34,

Similarly for the .n = 34

| +		.size = sizeof(vector128), .align = sizeof(vector128),
| +		.active = tm_cvmx_active, .get = tm_cvmx_get, .set = tm_cvmx_set
| +	},
| +#endif
|  };
|  
|  static const struct user_regset_view user_ppc_native_view = {
| @@ -690,7 +1252,7 @@ static int gpr32_get(struct task_struct *target,
|  	if (!FULL_REGS(target->thread.regs)) {
|  		/* We have a partial register set.  Fill 14-31 with bogus values */
|  		for (i = 14; i < 32; i++)
| -			target->thread.regs->gpr[i] = NV_REG_POISON; 
| +			target->thread.regs->gpr[i] = NV_REG_POISON;
|  	}
|  
|  	pos /= sizeof(reg);
| @@ -803,6 +1365,157 @@ static int gpr32_set(struct task_struct *target,
|  					 (PT_TRAP + 1) * sizeof(reg), -1);
|  }
|  
| +static int tm_cgpr32_get(struct task_struct *target,
| +		     const struct user_regset *regset,
| +		     unsigned int pos, unsigned int count,
| +		     void *kbuf, void __user *ubuf)
| +{
| +	const unsigned long *regs = &target->thread.ckpt_regs.gpr[0];
| +	compat_ulong_t *k = kbuf;
| +	compat_ulong_t __user *u = ubuf;
| +	compat_ulong_t reg;
| +	int i;
| +
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return -ENODATA;
| +
| +	flush_fp_to_thread(target);
| +	flush_altivec_to_thread(target);
| +	flush_tmregs_to_thread(target);
| +
| +	if (target->thread.regs == NULL)
| +		return -EIO;
| +
| +	if (!FULL_REGS(target->thread.regs)) {
| +		/* We have a partial register set.  Fill 14-31 with bogus values */
| +		for (i = 14; i < 32; i++)
| +			target->thread.regs->gpr[i] = NV_REG_POISON; 
| +	}
| +
| +	pos /= sizeof(reg);
| +	count /= sizeof(reg);
| +
| +	if (kbuf)
| +		for (; count > 0 && pos < PT_MSR; --count)
| +			*k++ = regs[pos++];
| +	else
| +		for (; count > 0 && pos < PT_MSR; --count)
| +			if (__put_user((compat_ulong_t) regs[pos++], u++))
| +				return -EFAULT;
| +
| +	if (count > 0 && pos == PT_MSR) {
| +		reg = get_user_msr(target);
| +		if (kbuf)
| +			*k++ = reg;
| +		else if (__put_user(reg, u++))
| +			return -EFAULT;
| +		++pos;
| +		--count;
| +	}
| +
| +	if (kbuf)
| +		for (; count > 0 && pos < PT_REGS_COUNT; --count)
| +			*k++ = regs[pos++];
| +	else
| +		for (; count > 0 && pos < PT_REGS_COUNT; --count)
| +			if (__put_user((compat_ulong_t) regs[pos++], u++))
| +				return -EFAULT;
| +
| +	kbuf = k;
| +	ubuf = u;
| +	pos *= sizeof(reg);
| +	count *= sizeof(reg);
| +	return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
| +					PT_REGS_COUNT * sizeof(reg), -1);
| +}
| +
| +static int tm_cgpr32_set(struct task_struct *target,
| +		     const struct user_regset *regset,
| +		     unsigned int pos, unsigned int count,
| +		     const void *kbuf, const void __user *ubuf)
| +{
| +	unsigned long *regs = &target->thread.ckpt_regs.gpr[0];
| +	const compat_ulong_t *k = kbuf;
| +	const compat_ulong_t __user *u = ubuf;
| +	compat_ulong_t reg;
| +
| +	if (!cpu_has_feature(CPU_FTR_TM))
| +		return -ENODEV;
| +
| +	if(!MSR_TM_ACTIVE(target->thread.regs->msr))
| +		return -ENODATA;
| +
| +	flush_fp_to_thread(target);
| +	flush_altivec_to_thread(target);
| +	flush_tmregs_to_thread(target);
| +
| +	if (target->thread.regs == NULL)
| +		return -EIO;
| +
| +	CHECK_FULL_REGS(target->thread.regs);
| +
| +	pos /= sizeof(reg);
| +	count /= sizeof(reg);
| +
| +	if (kbuf)
| +		for (; count > 0 && pos < PT_MSR; --count)
| +			regs[pos++] = *k++;
| +	else
| +		for (; count > 0 && pos < PT_MSR; --count) {
| +			if (__get_user(reg, u++))
| +				return -EFAULT;
| +			regs[pos++] = reg;
| +		}
| +
| +
| +	if (count > 0 && pos == PT_MSR) {
| +		if (kbuf)
| +			reg = *k++;
| +		else if (__get_user(reg, u++))
| +			return -EFAULT;
| +		set_user_msr(target, reg);
| +		++pos;
| +		--count;
| +	}
| +
| +	if (kbuf) {
| +		for (; count > 0 && pos <= PT_MAX_PUT_REG; --count)
| +			regs[pos++] = *k++;
| +		for (; count > 0 && pos < PT_TRAP; --count, ++pos)
| +			++k;
| +	} else {
| +		for (; count > 0 && pos <= PT_MAX_PUT_REG; --count) {
| +			if (__get_user(reg, u++))
| +				return -EFAULT;
| +			regs[pos++] = reg;
| +		}
| +		for (; count > 0 && pos < PT_TRAP; --count, ++pos)
| +			if (__get_user(reg, u++))
| +				return -EFAULT;
| +	}
| +
| +	if (count > 0 && pos == PT_TRAP) {
| +		if (kbuf)
| +			reg = *k++;
| +		else if (__get_user(reg, u++))
| +			return -EFAULT;
| +		set_user_trap(target, reg);
| +		++pos;
| +		--count;
| +	}
| +
| +	kbuf = k;
| +	ubuf = u;
| +	pos *= sizeof(reg);
| +	count *= sizeof(reg);
| +	return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
| +					 (PT_TRAP + 1) * sizeof(reg), -1);
| +}
| +
| +
|  /*
|   * These are the regset flavors matching the CONFIG_PPC32 native set.
|   */
| @@ -831,6 +1544,28 @@ static const struct user_regset compat_regsets[] = {
|  		.active = evr_active, .get = evr_get, .set = evr_set
|  	},
|  #endif
| +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
| +	[REGSET_TM_SPR] = {
| +		.core_note_type = NT_PPC_TM_SPR, .n = 7,
| +		.size = sizeof(u64), .align = sizeof(u64),
| +		.active = tm_spr_active, .get = tm_spr_get, .set = tm_spr_set
| +	},
| +	[REGSET_TM_CGPR] = {
| +		.core_note_type = NT_PPC_TM_CGPR, .n = ELF_NGREG,
| +		.size = sizeof(long), .align = sizeof(long),
| +		.active = tm_cgpr_active, .get = tm_cgpr32_get, .set = tm_cgpr32_set
| +	},
| +	[REGSET_TM_CFPR] = {
| +		.core_note_type = NT_PPC_TM_CFPR, .n = ELF_NFPREG,
| +		.size = sizeof(double), .align = sizeof(double),
| +		.active = tm_cfpr_active, .get = tm_cfpr_get, .set = tm_cfpr_set
| +	},
| +	[REGSET_TM_CVMX] = {
| +		.core_note_type = NT_PPC_TM_CVMX, .n = 34,
| +		.size = sizeof(vector128), .align = sizeof(vector128),
| +		.active = tm_cvmx_active, .get = tm_cvmx_get, .set = tm_cvmx_set
| +	},
| +#endif
|  };
|  
|  static const struct user_regset_view user_ppc_compat_view = {
| @@ -1754,7 +2489,6 @@ long arch_ptrace(struct task_struct *child, long request,
|  					     REGSET_SPE, 0, 35 * sizeof(u32),
|  					     datavp);
|  #endif
| -
|  	default:
|  		ret = ptrace_request(child, request, addr, data);
|  		break;
| -- 
| 1.7.11.7
| 
| _______________________________________________
| Linuxppc-dev mailing list
| Linuxppc-dev@lists.ozlabs.org
| https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [PATCH 1/2][v3] powerpc/fsl-booke: Add initial T1040/T1042 RDB board support
From: Emil Medve @ 2014-08-27 19:04 UTC (permalink / raw)
  To: Priyanka Jain, linuxppc-dev, devicetree, scottwood
  Cc: Poonam Aggrwal, Prabhakar Kushwaha
In-Reply-To: <1407741488-2661-1-git-send-email-Priyanka.Jain__34501.3199876577$1407741762$gmane$org@freescale.com>

Hello Priyanka,


On 08/11/2014 02:18 AM, Priyanka Jain wrote:
> T1040/T1042RDB is Freescale Reference Design Board.
> The board can support both T1040/T1042 QorIQ Power Architecture™ processor.
> 
> T1040/T1042RDB board Overview
> -----------------------
> - SERDES Connections, 8 lanes supporting:
> 	- PCI
> 	- SGMII
>     	- QSGMII
>     	- SATA 2.0
> - DDR Controller
>     	- Supports rates of up to 1600 MHz data-rate
>     	- Supports one DDR3LP UDIMM
> -IFC/Local Bus
>     	- NAND flash: 1GB 8-bit NAND flash
>     	- NOR: 128MB 16-bit NOR Flash
> - Ethernet
>     	- Two on-board RGMII 10/100/1G ethernet ports.
>     	- PHY #0 remains powered up during deep-sleep
> - CPLD
> - Clocks
>     	- System and DDR clock (SYSCLK, “DDRCLK”)
>     	- SERDES clocks
> - Power Supplies
> - USB
>     	- Supports two USB 2.0 ports with integrated PHYs
>     	- Two type A ports with 5V@1.5A per port.
> - SDHC
>     	- SDHC/SDXC connector
> - SPI
>     	- On-board 64MB SPI flash
> - I2C
>     	- Devices connected: EEPROM, thermal monitor, VID controller
> - Other IO
>     	- Two Serial ports
>     	- ProfiBus port
> 
> Add support for T1040/T1042 RDB board:
>     -add device tree
>     -add entry in Kconfig to build
>     -Add entry in corenet_generic.c, as it is similar to other corenet platforms
> 
> Signed-off-by: Priyanka Jain <Priyanka.Jain@freescale.com>
> Signed-off-by: Poonam Aggrwal <poonam.aggrwal@freescale.com>
> Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
> ---
> changes for v3: Incorporated Scott comments on moving cpld compatible
>  field to board specific file as cpld binaries are different
> 
> changes for v2: Incorporated Scott comments on using common name
>  for compatible string for cpld as register set is same
> 
>  arch/powerpc/boot/dts/t1040rdb.dts            |   48 ++++++++
>  arch/powerpc/boot/dts/t1042rdb.dts            |   48 ++++++++
>  arch/powerpc/boot/dts/t104xrdb.dtsi           |  156 +++++++++++++++++++++++++
>  arch/powerpc/platforms/85xx/Kconfig           |    2 +-
>  arch/powerpc/platforms/85xx/corenet_generic.c |    2 +
>  5 files changed, 255 insertions(+), 1 deletions(-)
>  create mode 100644 arch/powerpc/boot/dts/t1040rdb.dts
>  create mode 100644 arch/powerpc/boot/dts/t1042rdb.dts
>  create mode 100644 arch/powerpc/boot/dts/t104xrdb.dtsi
> 
> diff --git a/arch/powerpc/boot/dts/t1040rdb.dts b/arch/powerpc/boot/dts/t1040rdb.dts
> new file mode 100644
> index 0000000..79a0bed
> --- /dev/null
> +++ b/arch/powerpc/boot/dts/t1040rdb.dts
> @@ -0,0 +1,48 @@
> +/*
> + * T1040RDB Device Tree Source
> + *
> + * 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.
> + */
> +
> +/include/ "fsl/t104xsi-pre.dtsi"
> +/include/ "t104xrdb.dtsi"
> +
> +/ {
> +	model = "fsl,T1040RDB";
> +	compatible = "fsl,T1040RDB";

I suggest you leave an empty line between the properties and subnodes

> +	ifc: localbus@ffe124000 {
> +		cpld@3,0 {
> +			compatible = "fsl,t1040rdb-cpld";
> +		};
> +	};

I believe Scott's point was that you shouldn't have a plethora of
compatibles in a common file for a device that's identical across
boards. If the device is not really identical and a separate compatible
is needed to differentiate it across boards, then the node should move
into the board specific file with different compatibles. Here, you've
moved the CPLD node in the board specific file but you used the same
compatible

> +};
> +
> +/include/ "fsl/t1040si-post.dtsi"
> diff --git a/arch/powerpc/boot/dts/t1042rdb.dts b/arch/powerpc/boot/dts/t1042rdb.dts
> new file mode 100644
> index 0000000..228a635
> --- /dev/null
> +++ b/arch/powerpc/boot/dts/t1042rdb.dts
> @@ -0,0 +1,48 @@
> +/*
> + * T1042RDB Device Tree Source
> + *
> + * 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.
> + */
> +
> +/include/ "fsl/t104xsi-pre.dtsi"
> +/include/ "t104xrdb.dtsi"
> +
> +/ {
> +	model = "fsl,T1042RDB";
> +	compatible = "fsl,T1042RDB";
> +	ifc: localbus@ffe124000 {
> +		cpld@3,0 {
> +			compatible = "fsl,t1040rdb-cpld";
> +		};
> +	};

Same as above

> +};
> +
> +/include/ "fsl/t1042si-post.dtsi"
> diff --git a/arch/powerpc/boot/dts/t104xrdb.dtsi b/arch/powerpc/boot/dts/t104xrdb.dtsi
> new file mode 100644
> index 0000000..1cf0f3c
> --- /dev/null
> +++ b/arch/powerpc/boot/dts/t104xrdb.dtsi
> @@ -0,0 +1,156 @@
> +/*
> + * T1040RDB/T1042RDB Device Tree Source
> + *
> + * 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.
> + */
> +
> +/ {
> +

Remove the empty line

> +	ifc: localbus@ffe124000 {
> +		reg = <0xf 0xfe124000 0 0x2000>;
> +		ranges = <0 0 0xf 0xe8000000 0x08000000
> +			  2 0 0xf 0xff800000 0x00010000
> +			  3 0 0xf 0xffdf0000 0x00008000>;
> +
> +		nor@0,0 {
> +			#address-cells = <1>;
> +			#size-cells = <1>;
> +			compatible = "cfi-flash";
> +			reg = <0x0 0x0 0x8000000>;
> +			bank-width = <2>;
> +			device-width = <1>;
> +		};
> +
> +		nand@2,0 {
> +			#address-cells = <1>;
> +			#size-cells = <1>;
> +			compatible = "fsl,ifc-nand";
> +			reg = <0x2 0x0 0x10000>;
> +		};
> +
> +		cpld@3,0 {
> +			reg = <3 0 0x300>;
> +		};
> +	};
> +
> +	memory {
> +		device_type = "memory";
> +	};
> +
> +	dcsr: dcsr@f00000000 {
> +		ranges = <0x00000000 0xf 0x00000000 0x01072000>;
> +	};
> +
> +	soc: soc@ffe000000 {
> +		ranges = <0x00000000 0xf 0xfe000000 0x1000000>;
> +		reg = <0xf 0xfe000000 0 0x00001000>;
> +
> +		spi@110000 {
> +			flash@0 {
> +				#address-cells = <1>;
> +				#size-cells = <1>;
> +				compatible = "micron,n25q512a";
> +				reg = <0>;
> +				spi-max-frequency = <10000000>; /* input clock */
> +			};
> +		};
> +
> +		i2c@118100 {
> +			pca9546@77 {
> +				compatible = "nxp,pca9546";
> +				reg = <0x77>;
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +			};
> +		};
> +

Remove the empty line


Cheers,


> +	};
> +
> +	pci0: pcie@ffe240000 {
> +		reg = <0xf 0xfe240000 0 0x10000>;
> +		ranges = <0x02000000 0 0xe0000000 0xc 0x00000000 0x0 0x10000000
> +			  0x01000000 0 0x00000000 0xf 0xf8000000 0x0 0x00010000>;
> +		pcie@0 {
> +			ranges = <0x02000000 0 0xe0000000
> +				  0x02000000 0 0xe0000000
> +				  0 0x10000000
> +
> +				  0x01000000 0 0x00000000
> +				  0x01000000 0 0x00000000
> +				  0 0x00010000>;
> +		};
> +	};
> +
> +	pci1: pcie@ffe250000 {
> +		reg = <0xf 0xfe250000 0 0x10000>;
> +		ranges = <0x02000000 0x0 0xe0000000 0xc 0x10000000 0x0 0x10000000
> +			  0x01000000 0x0 0x00000000 0xf 0xf8010000 0x0 0x00010000>;
> +		pcie@0 {
> +			ranges = <0x02000000 0 0xe0000000
> +				  0x02000000 0 0xe0000000
> +				  0 0x10000000
> +
> +				  0x01000000 0 0x00000000
> +				  0x01000000 0 0x00000000
> +				  0 0x00010000>;
> +		};
> +	};
> +
> +	pci2: pcie@ffe260000 {
> +		reg = <0xf 0xfe260000 0 0x10000>;
> +		ranges = <0x02000000 0 0xe0000000 0xc 0x20000000 0 0x10000000
> +			  0x01000000 0 0x00000000 0xf 0xf8020000 0 0x00010000>;
> +		pcie@0 {
> +			ranges = <0x02000000 0 0xe0000000
> +				  0x02000000 0 0xe0000000
> +				  0 0x10000000
> +
> +				  0x01000000 0 0x00000000
> +				  0x01000000 0 0x00000000
> +				  0 0x00010000>;
> +		};
> +	};
> +
> +	pci3: pcie@ffe270000 {
> +		reg = <0xf 0xfe270000 0 0x10000>;
> +		ranges = <0x02000000 0 0xe0000000 0xc 0x30000000 0 0x10000000
> +			  0x01000000 0 0x00000000 0xf 0xf8030000 0 0x00010000>;
> +		pcie@0 {
> +			ranges = <0x02000000 0 0xe0000000
> +				  0x02000000 0 0xe0000000
> +				  0 0x10000000
> +
> +				  0x01000000 0 0x00000000
> +				  0x01000000 0 0x00000000
> +				  0 0x00010000>;
> +		};
> +	};
> +};
> diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
> index 5063696..157a1a4 100644
> --- a/arch/powerpc/platforms/85xx/Kconfig
> +++ b/arch/powerpc/platforms/85xx/Kconfig
> @@ -276,7 +276,7 @@ config CORENET_GENERIC
>  	  For 64bit kernel, the following boards are supported:
>  	    T208x QDS, T4240 QDS/RDB and B4 QDS
>  	  The following boards are supported for both 32bit and 64bit kernel:
> -	    P5020 DS, P5040 DS and T104xQDS
> +	    P5020 DS, P5040 DS and T104xQDS/RDB
>  
>  endif # FSL_SOC_BOOKE
>  
> diff --git a/arch/powerpc/platforms/85xx/corenet_generic.c b/arch/powerpc/platforms/85xx/corenet_generic.c
> index 4f22ad1..c268f89 100644
> --- a/arch/powerpc/platforms/85xx/corenet_generic.c
> +++ b/arch/powerpc/platforms/85xx/corenet_generic.c
> @@ -128,6 +128,8 @@ static const char * const boards[] __initconst = {
>  	"fsl,B4220QDS",
>  	"fsl,T1040QDS",
>  	"fsl,T1042QDS",
> +	"fsl,T1040RDB",
> +	"fsl,T1042RDB",
>  	"keymile,kmcoge4",
>  	NULL
>  };

^ permalink raw reply

* [PATCH] of: make sure of_alias is initialized before accessing it
From: Laurentiu Tudor @ 2014-08-27 14:09 UTC (permalink / raw)
  To: devicetree, linux-kernel, linuxppc-dev; +Cc: Grant Likely, Laurentiu Tudor

Simply swap of_alias and of_chosen initialization so
that of_alias ends up read first. This must be done
because it is accessed couple of lines below when
trying to initialize the of_stdout using the alias
based legacy method.

[Fixes a752ee5 - tty: Update hypervisor tty drivers to                          
use core stdout parsing code]

Signed-off-by: Laurentiu Tudor <Laurentiu.Tudor@freescale.com>
Cc: Grant Likely <grant.likely@linaro.org>
---
 drivers/of/base.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index d8574ad..52f8506 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1847,6 +1847,10 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
 {
 	struct property *pp;
 
+	of_aliases = of_find_node_by_path("/aliases");
+	if (!of_aliases)
+		return;
+
 	of_chosen = of_find_node_by_path("/chosen");
 	if (of_chosen == NULL)
 		of_chosen = of_find_node_by_path("/chosen@0");
@@ -1862,10 +1866,6 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
 			of_stdout = of_find_node_by_path(name);
 	}
 
-	of_aliases = of_find_node_by_path("/aliases");
-	if (!of_aliases)
-		return;
-
 	for_each_property_of_node(of_aliases, pp) {
 		const char *start = pp->name;
 		const char *end = start + strlen(start);
-- 
1.8.3.1

^ permalink raw reply related

* Re: [PATCH v4 0/6] KVM: PPC: Book3e: AltiVec support
From: Alexander Graf @ 2014-08-27 12:16 UTC (permalink / raw)
  To: Mihai Caraman, kvm-ppc; +Cc: linuxppc-dev, kvm
In-Reply-To: <1408541787-24625-1-git-send-email-mihai.caraman@freescale.com>



On 20.08.14 15:36, Mihai Caraman wrote:
> Add KVM Book3e AltiVec support.
> 
> Changes:
> 
> v4:
>  - use CONFIG_SPE_POSSIBLE and a new ifdef for CONFIG_ALTIVEC
>  - remove SPE handlers from bookehv
>  - split ONE_REG powerpc generic and ONE_REG AltiVec
>  - add setters for IVPR, IVOR2 and IVOR8
>  - add api documentation for ONE_REG IVPR and IVORs
>  - don't enable e6500 core since hardware threads are not yet supported
> 
> v3:
>  - use distinct SPE/AltiVec exception handlers
>  - make ONE_REG AltiVec support powerpc generic
>  - add ONE_REG IVORs support
> 
>  v2:
>  - integrate Paul's FP/VMX/VSX changes that landed in kvm-ppc-queue
>    in January and take into account feedback
> 
> Mihai Caraman (6):
>   KVM: PPC: Book3E: Increase FPU laziness
>   KVM: PPC: Book3e: Add AltiVec support
>   KVM: PPC: Make ONE_REG powerpc generic
>   KVM: PPC: Move ONE_REG AltiVec support to powerpc
>   KVM: PPC: Booke: Add setter functions for IVPR, IVOR2 and IVOR8
>     emulation
>   KVM: PPC: Booke: Add ONE_REG support for IVPR and IVORs

Thanks, applied 1-4 to kvm-ppc-queue.


Alex

^ permalink raw reply

* Re: [PATCH v4 5/6] KVM: PPC: Booke: Add setter functions for IVPR, IVOR2 and IVOR8 emulation
From: Alexander Graf @ 2014-08-27 12:16 UTC (permalink / raw)
  To: Mihai Caraman, kvm-ppc; +Cc: linuxppc-dev, kvm
In-Reply-To: <1408541787-24625-6-git-send-email-mihai.caraman@freescale.com>



On 20.08.14 15:36, Mihai Caraman wrote:
> Add setter functions for IVPR, IVOR2 and IVOR8 emulation in preparation
> for ONE_REG support.
> 
> Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>

What about the other GIVORs?

Also, I would prefer to have a common helper for IVOR setting that
simply covers SPRN_GIVOR setting along the way. Something like

void kvmppc_set_ivor(struct kvm_vcpu *vcpu, int irqprio_ivor, u16 new_ivor)
{
    vcpu->arch.ivor[irqprio_ivor] = new_ivor;
    switch (irqprio_ivor) {
    case BOOKE_IRQPRIO_DATA_STORAGE:
        mtspr(SPRN_GIVOR2, new_ivor);
        break;
    ...
    }
}

which you can just call from all the IVOR setters. In fact, you can
probably combine all of the ONE_REG handlers into a single handler that
just does a quick table lookup for its irqprio.


Alex

^ permalink raw reply

* Re: [PATCH 2/2] KVM: PPC: Book3S HV: Add register name when loading toc
From: Alexander Graf @ 2014-08-27 11:20 UTC (permalink / raw)
  To: Michael Neuling, Paul Mackerras; +Cc: linuxppc-dev, kvm-ppc, kvm
In-Reply-To: <1408424370-16960-2-git-send-email-mikey@neuling.org>



On 19.08.14 06:59, Michael Neuling wrote:
> 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 <mikey@neuling.org>
> Signed-off-by: Paul Mackerras <paulus@samba.org>

Thanks, applied to kvm-ppc-queue.


Alex

^ permalink raw reply

* Re: [PATCH v2 1/2] powerpc/booke: Restrict SPE exception handlers to e200/e500 cores
From: Alexander Graf @ 2014-08-27 11:19 UTC (permalink / raw)
  To: Mihai Caraman, linuxppc-dev; +Cc: Scott Wood, kvm-ppc
In-Reply-To: <1408540144-24436-1-git-send-email-mihai.caraman@freescale.com>



On 20.08.14 15:09, Mihai Caraman wrote:
> SPE exception handlers are now defined for 32-bit e500mc cores even though
> SPE unit is not present and CONFIG_SPE is undefined.
> 
> Restrict SPE exception handlers to e200/e500 cores adding CONFIG_SPE_POSSIBLE
> and consequently guard __stup_ivors and __setup_cpu functions.
> 
> Signed-off-by: Mihai Caraman <mihai.caraman@freescale.com>
> Cc: Scott Wood <scottwood@freescale.com>
> Cc: Alexander Graf <agraf@suse.de>

Thanks, applied both to kvm-ppc-queue.


Alex

^ permalink raw reply

* [RFC PATCH v3 3/3] powerpc: some changes in numa_setup_cpu()
From: Li Zhong @ 2014-08-27  9:34 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Li Zhong, Nishanth Aravamudan, paulus, Nathan Fontenot
In-Reply-To: <1409132041-11890-1-git-send-email-zhong@linux.vnet.ibm.com>

this patches changes some error handling logics in numa_setup_cpu(),
when cpu node is not found, so:

if the cpu is possible, but not present, -1 is kept in numa_cpu_lookup_table,
so later, if the cpu is added, we could set correct numa information for it.

if the cpu is present, then we set the first online node to
numa_cpu_lookup_table instead of 0 ( in case 0 might not be an online node? )

Cc: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: Li Zhong <zhong@linux.vnet.ibm.com>
---
 arch/powerpc/mm/numa.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 3a9061e..ec32d46 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -538,7 +538,7 @@ static int of_drconf_to_nid_single(struct of_drconf_cell *drmem,
  */
 static int numa_setup_cpu(unsigned long lcpu)
 {
-	int nid;
+	int nid = -1;
 	struct device_node *cpu;
 
 	/*
@@ -555,19 +555,21 @@ static int numa_setup_cpu(unsigned long lcpu)
 
 	if (!cpu) {
 		WARN_ON(1);
-		nid = 0;
-		goto out;
+		if (cpu_present(lcpu))
+			goto out_present;
+		else
+			goto out;
 	}
 
 	nid = of_node_to_nid_single(cpu);
 
+out_present:
 	if (nid < 0 || !node_online(nid))
 		nid = first_online_node;
-out:
-	map_cpu_to_node(lcpu, nid);
 
+	map_cpu_to_node(lcpu, nid);
 	of_node_put(cpu);
-
+out:
 	return nid;
 }
 
-- 
1.9.1

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox