Re: [PATCH v2 2/2] ASoC: fsl_ssi: add 20-bit sample format for AC'97 and use it for capture

2017-11-24 Thread kbuild test robot
Hi Maciej,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on sound/for-next]
[also build test ERROR on v4.14 next-20171124]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Maciej-S-Szmigiero/ALSA-pcm-add-SNDRV_PCM_FORMAT_-S-U-20_4/20171125-082039
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64 

All errors (new ones prefixed by >>):

>> sound/soc/fsl/fsl_ssi.c:1237:37: error: 'SNDRV_PCM_FMTBIT_S20' undeclared 
>> here (not in a function); did you mean 'SNDRV_PCM_FMTBIT_S24'?
  .formats = SNDRV_PCM_FMTBIT_S16 | SNDRV_PCM_FMTBIT_S20,
^~~~
SNDRV_PCM_FMTBIT_S24

vim +1237 sound/soc/fsl/fsl_ssi.c

  1228  
  1229  static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
  1230  .bus_control = true,
  1231  .probe = fsl_ssi_dai_probe,
  1232  .playback = {
  1233  .stream_name = "AC97 Playback",
  1234  .channels_min = 2,
  1235  .channels_max = 2,
  1236  .rates = SNDRV_PCM_RATE_8000_48000,
> 1237  .formats = SNDRV_PCM_FMTBIT_S16 | SNDRV_PCM_FMTBIT_S20,
  1238  },
  1239  .capture = {
  1240  .stream_name = "AC97 Capture",
  1241  .channels_min = 2,
  1242  .channels_max = 2,
  1243  .rates = SNDRV_PCM_RATE_48000,
  1244  /* 16-bit capture is broken (errata ERR003778) */
  1245  .formats = SNDRV_PCM_FMTBIT_S20,
  1246  },
  1247  .ops = &fsl_ssi_dai_ops,
  1248  };
  1249  
  1250  

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


.config.gz
Description: application/gzip


Re: [PATCH v2 2/2] ASoC: fsl_ssi: add 20-bit sample format for AC'97 and use it for capture

2017-11-24 Thread kbuild test robot
Hi Maciej,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on sound/for-next]
[also build test ERROR on v4.14 next-20171124]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Maciej-S-Szmigiero/ALSA-pcm-add-SNDRV_PCM_FORMAT_-S-U-20_4/20171125-082039
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
config: x86_64-randconfig-x012-201747 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> sound/soc//fsl/fsl_ssi.c:1237:37: error: 'SNDRV_PCM_FMTBIT_S20' undeclared 
>> here (not in a function)
  .formats = SNDRV_PCM_FMTBIT_S16 | SNDRV_PCM_FMTBIT_S20,
^~~~

vim +/SNDRV_PCM_FMTBIT_S20 +1237 sound/soc//fsl/fsl_ssi.c

  1228  
  1229  static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
  1230  .bus_control = true,
  1231  .probe = fsl_ssi_dai_probe,
  1232  .playback = {
  1233  .stream_name = "AC97 Playback",
  1234  .channels_min = 2,
  1235  .channels_max = 2,
  1236  .rates = SNDRV_PCM_RATE_8000_48000,
> 1237  .formats = SNDRV_PCM_FMTBIT_S16 | SNDRV_PCM_FMTBIT_S20,
  1238  },
  1239  .capture = {
  1240  .stream_name = "AC97 Capture",
  1241  .channels_min = 2,
  1242  .channels_max = 2,
  1243  .rates = SNDRV_PCM_RATE_48000,
  1244  /* 16-bit capture is broken (errata ERR003778) */
  1245  .formats = SNDRV_PCM_FMTBIT_S20,
  1246  },
  1247  .ops = &fsl_ssi_dai_ops,
  1248  };
  1249  
  1250  

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


.config.gz
Description: application/gzip


Re: [PATCH] cxl: Add support for ASB_Notify on POWER9

2017-11-24 Thread Benjamin Herrenschmidt
On Fri, 2017-11-24 at 17:37 +0100, christophe lombard wrote:
> You are right. We will insert a checking in the cxl driver to allow
> updating the TIDR if a P9 is present. This will be in the patch V2.
> Thanks

Best is to actually:

 1) Add something to the device-tree in skiboot (and work with pHyp &
KVM to do the same if not already in ibm,pa-features)

 2) Key off htat.

Nick, anything in your new feature stuff too ?

Ben.



Re: [PATCH] cxl: Add support for ASB_Notify on POWER9

2017-11-24 Thread christophe lombard

Le 24/11/2017 à 14:02, Benjamin Herrenschmidt a écrit :

On Fri, 2017-11-24 at 11:14 +0100, christophe lombard wrote:

To my knowledge, there is no property (or similar), somewhere, that
indicating that the TIDR is supported or not.
For the time being, if I am not wrong, the only check we have, is
this condition in the function set_thread_tidr(struct task_struct *t):

 if (!cpu_has_feature(CPU_FTR_ARCH_300))
 return -EINVAL;


Christophe


Then we need to fix that

Ben.



You are right. We will insert a checking in the cxl driver to allow
updating the TIDR if a P9 is present. This will be in the patch V2.
Thanks

Christophe



Re: [PATCH] cxl: Add support for ASB_Notify on POWER9

2017-11-24 Thread Benjamin Herrenschmidt
On Fri, 2017-11-24 at 11:14 +0100, christophe lombard wrote:
> To my knowledge, there is no property (or similar), somewhere, that
> indicating that the TIDR is supported or not.
> For the time being, if I am not wrong, the only check we have, is
> this condition in the function set_thread_tidr(struct task_struct *t):
> 
> if (!cpu_has_feature(CPU_FTR_ARCH_300))
> return -EINVAL;
> 
> 
> Christophe

Then we need to fix that

Ben.



[GIT PULL] Please pull powerpc/linux.git powerpc-4.15-2 tag

2017-11-24 Thread Michael Ellerman
Hi Linus,

Please pull some powerpc fixes for 4.15.

These would be nice to have in rc1, but none of them are actually that
crucial. So they can wait until Monday if you're busy eating pumpkin
pie.

cheers


The following changes since commit 3ffa9d9e2a7c10127d8cbf91ea2be15390b450ed:

  powerpc/64s: Fix Power9 DD2.0 workarounds by adding DD2.1 feature (2017-11-15 
14:25:42 +1100)

are available in the Git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
powerpc-4.15-2

for you to fetch changes up to 4d6c51b107cc73b15a377224549aa5593f90df89:

  powerpc/64s: Fix Power9 DD2.1 logic in DT CPU features (2017-11-22 23:17:01 
+1100)


powerpc fixes for 4.15 #2

A small batch of fixes, about 50% tagged for stable and the rest for recently
merged code.

There's one more fix for the >128T handling on hash. Once a process had
requested a single mmap above 128T we would then always search above 128T. The
correct behaviour is to consider the hint address in isolation for each mmap
request.

Then a couple of fixes for the IMC PMU, a missing EXPORT_SYMBOL in VAS, a fix
for STRICT_KERNEL_RWX on 32-bit, and a fix to correctly identify P9 DD2.1 but in
code that is currently not used by default.

Thanks to:
  Aneesh Kumar K.V, Christophe Leroy, Madhavan Srinivasan, Sukadev Bhattiprolu.


Aneesh Kumar K.V (1):
  powerpc/64s/slice: Use addr limit when computing slice mask

Christophe Leroy (1):
  powerpc: Fix boot on BOOK3S_32 with CONFIG_STRICT_KERNEL_RWX

Madhavan Srinivasan (2):
  powerpc/perf: Fix pmu_count to count only nest imc pmus
  powerpc/perf: Fix IMC_MAX_PMU macro

Michael Ellerman (2):
  powerpc/perf/imc: Use cpu_to_node() not topology_physical_package_id()
  powerpc/64s: Fix Power9 DD2.1 logic in DT CPU features

Sukadev Bhattiprolu (1):
  powerpc/vas: Export chip_to_vas_id()

 arch/powerpc/include/asm/imc-pmu.h|  6 +-
 arch/powerpc/kernel/dt_cpu_ftrs.c |  4 ++--
 arch/powerpc/lib/code-patching.c  |  6 ++
 arch/powerpc/mm/slice.c   | 34 ---
 arch/powerpc/perf/imc-pmu.c   | 27 
 arch/powerpc/platforms/powernv/opal-imc.c | 22 ++--
 arch/powerpc/platforms/powernv/vas.c  |  1 +
 7 files changed, 66 insertions(+), 34 deletions(-)


signature.asc
Description: PGP signature


Re: [PATCH] cxl: Add support for ASB_Notify on POWER9

2017-11-24 Thread christophe lombard

Le 23/11/2017 à 21:41, Benjamin Herrenschmidt a écrit :

On Thu, 2017-11-23 at 12:05 +0100, Christophe Lombard wrote:

The POWER9 core supports a new feature: ASB_Notify which requires the
support of the Special Purpose Register: TIDR.

The ASB_Notify command, generated by the AFU, will attempt to
wake-up the host thread identified by the particular LPID:PID:TID.

This patch assign a unique TIDR (thread id) for the current thread which
will be used in the process element entry.


Is that keyd off some device-tree property or similar ? There is no
guarantee that the TIDR and ASB_Notify still exist on future chips...

Ben.



To my knowledge, there is no property (or similar), somewhere, that
indicating that the TIDR is supported or not.
For the time being, if I am not wrong, the only check we have, is
this condition in the function set_thread_tidr(struct task_struct *t):

if (!cpu_has_feature(CPU_FTR_ARCH_300))
return -EINVAL;


Christophe



[PATCH] USB: gadget: udc: fix spelling mistake "unexpect" -> "unexpected"

2017-11-24 Thread Colin King
From: Colin Ian King 

Trival fix to spelling mistake in ERR message

Signed-off-by: Colin Ian King 
---
 drivers/usb/gadget/udc/fsl_udc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c 
b/drivers/usb/gadget/udc/fsl_udc_core.c
index d606d4f13098..e5b4ee96c4bf 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -1543,7 +1543,7 @@ static void ep0_req_complete(struct fsl_udc *udc, struct 
fsl_ep *ep0,
udc->ep0_state = WAIT_FOR_SETUP;
break;
case WAIT_FOR_SETUP:
-   ERR("Unexpect ep0 packets\n");
+   ERR("Unexpected ep0 packets\n");
break;
default:
ep0stall(udc);
-- 
2.14.1



Re: powerpc/kexec: Fix kexec/kdump in P9 guest kernels

2017-11-24 Thread Michael Ellerman
On Fri, 2017-11-24 at 03:51:02 UTC, Michael Ellerman wrote:
> The code that cleans up the IAMR/AMOR before kexec'ing failed to
> remember that when we're running as a guest AMOR is not writable, it's
> hypervisor privileged.
> 
> They symptom is that the kexec stops before entering purgatory and
> nothing else is seen on the console. If you examine the state of the
> system all threads will be in the 0x700 program check handler.
> 
> Fix it by making the write to AMOR dependent on HV mode.
> 
> Fixes: 1e2a516e89fc ("powerpc/kexec: Fix radix to hash kexec due to 
> IAMR/AMOR")
> Cc: sta...@vger.kernel.org # v4.10+
> Reported-by: Yilin Zhang 
> Debugged-by: David Gibson 
> Signed-off-by: Michael Ellerman 
> Acked-by: Balbir Singh 
> Reviewed-by: David Gibson 
> Tested-by: David Gibson 

Applied to powerpc fixes.

https://git.kernel.org/powerpc/c/2621e945fbf1d6df5f3f0ba7be5bae

cheers


Re: [v3] cxl: Check if vphb exists before iterating over AFU devices

2017-11-24 Thread Michael Ellerman
On Thu, 2017-11-23 at 03:38:57 UTC, Vaibhav Jain wrote:
> During an eeh a kernel-oops is reported if no vPHB is allocated to the
> AFU. This happens as during AFU init, an error in creation of vPHB is
> a non-fatal error. Hence afu->phb should always be checked for NULL
> before iterating over it for the virtual AFU pci devices.
> 
> This patch fixes the kenel-oops by adding a NULL pointer check for
> afu->phb before it is dereferenced.
> 
> Fixes: 9e8df8a2196("cxl: EEH support")
> Cc: sta...@vger.kernel.org
> Signed-off-by: Vaibhav Jain 
> Acked-by: Andrew Donnellan 
> Acked-by: Frederic Barrat 

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/12841f87b7a8ceb3d54f171660f72a

cheers


Re: powernv: Avoid calling trace tlbie in kexec path.

2017-11-24 Thread Michael Ellerman
On Wed, 2017-11-22 at 17:32:07 UTC, Mahesh J Salgaonkar wrote:
> From: Mahesh Salgaonkar 
> 
> Rebooting into a new kernel with kexec fails in trace_tlbie() which is
> called from native_hpte_clear(). This happens if the running kernel has
> CONFIG_LOCKDEP enabled. With lockdep enabled, the tracepoints always
> execute few RCU checks regardless of whether tracing is on or off.
> We are already in the last phase of kexec sequence in real mode with
> HILE_BE set. At this point the RCU check ends up in RCU_LOCKDEP_WARN and
> causes kexec to fail.
> 
> Fix this by not calling trace_tlbie() from native_hpte_clear().
> 
> Signed-off-by: Mahesh Salgaonkar 
> Reported-by: Aneesh Kumar K.V 
> Suggested-by: Michael Ellerman 
> Acked-by: Naveen N. Rao 

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/a3961f824cdbe7eb431254dc7d8f6f

cheers


Re: powerpc/64s: Fix Power9 DD2.1 logic in DT CPU features

2017-11-24 Thread Michael Ellerman
On Wed, 2017-11-22 at 12:28:52 UTC, Michael Ellerman wrote:
> I got the logic wrong in the DT CPU features code when I added the
> Power9 DD2.1 feature. We should be setting the bit if we detect a
> DD2.1, not clearing it if we detect a DD2.0.
> 
> This code isn't actually exercised at the moment so nothing is
> actually broken.
> 
> Fixes: 3ffa9d9e2a7c ("powerpc/64s: Fix Power9 DD2.0 workarounds by adding 
> DD2.1 feature")
> Signed-off-by: Michael Ellerman 

Applied to powerpc fixes.

https://git.kernel.org/powerpc/c/4d6c51b107cc73b15a377224549aa5

cheers


Re: [v2,2/2] powerpc/perf: Fix IMC_MAX_PMU macro

2017-11-24 Thread Michael Ellerman
On Wed, 2017-11-22 at 05:15:39 UTC, Madhavan Srinivasan wrote:
> IMC_MAX_PMU is used for static storage (per_nest_pmu_arr) which holds
> nest pmu information. Current value for the macro is 32 based on
> the initial number of nest pmu units supported by the nest microcode.
> But going forward, microcode could support more nest units. Instead
> of static storage, patch to fix the code to dynamically allocate an
> array based on the number of nest imc units found in the device tree.
> 
> Fixes:8f95faaac56c1 ('powerpc/powernv: Detect and create IMC device')
> Signed-off-by: Madhavan Srinivasan 

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/73ce9aec65b17433e18163d07eb5cb

cheers


Re: [1/2] powerpc/perf: Fix pmu_count to count only nest imc pmus

2017-11-24 Thread Michael Ellerman
On Wed, 2017-11-22 at 05:15:38 UTC, Madhavan Srinivasan wrote:
> "pmu_count" in opal_imc_counters_probe() is intended to hold
> the number of successful nest imc pmu registerations. But
> current code also counts other imc units like core_imc and
> thread_imc. Patch add a check to count only nest imc pmus.
> 
> Signed-off-by: Madhavan Srinivasan 

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/de34787f1096cce38e2590be0013b4

cheers


Re: [v2] powerpc: fix boot on BOOK3S_32 with CONFIG_STRICT_KERNEL_RWX

2017-11-24 Thread Michael Ellerman
On Tue, 2017-11-21 at 14:28:20 UTC, Christophe Leroy wrote:
> On powerpc32, patch_instruction() is called by apply_feature_fixups()
> which is called from early_init()
> 
> There is the following note in front of early_init():
>  * Note that the kernel may be running at an address which is different
>  * from the address that it was linked at, so we must use RELOC/PTRRELOC
>  * to access static data (including strings).  -- paulus
> 
> Therefore, slab_is_available() cannot be called yet, and
> text_poke_area must be addressed with PTRRELOC()
> 
> Fixes: 37bc3e5fd764f ("powerpc/lib/code-patching: Use alternate map
> for patch_instruction()")
> Reported-by: Meelis Roos 
> Cc: Balbir Singh 
> Signed-off-by: Christophe Leroy 

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/252eb55816a6f69ef9464cad303cdb

cheers


Re: powerpc/vas, export chip_to_vas_id()

2017-11-24 Thread Michael Ellerman
On Mon, 2017-11-20 at 19:12:48 UTC, Sukadev Bhattiprolu wrote:
> >From 958f8db089f4b89407fc4b89bccd3eaef585aa96 Mon Sep 17 00:00:00 2001
> From: Sukadev Bhattiprolu 
> Date: Mon, 20 Nov 2017 12:53:15 -0600
> Subject: [PATCH 1/1] powerpc/vas, export chip_to_vas_id()
> 
> Export the symbol chip_to_vas_id() to fix a build failure when
> CONFIG_CRYPTO_DEV_NX_COMPRESS_POWERNV=m.
> 
> Reported-by: Haren Myneni 
> Reported-by: Josh Boyer 
> Signed-off-by: Sukadev Bhattiprolu 

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/62b49c42107efd973edffc75f4f874

cheers


Re: powerpc/64s/slice: Use addr limit when computing slice mask

2017-11-24 Thread Michael Ellerman
On Fri, 2017-11-10 at 04:55:07 UTC, "Aneesh Kumar K.V" wrote:
> While computing slice mask for the free area we need make sure we only search
> in the addr limit applicable for this mmap. We update the slb_addr_limit
> after we request for a mmap above 128TB. But the following mmap request
> with hint addr below 128TB should still limit its search to below 128TB. ie.
> we should not use slb_addr_limit to compute slice mask in this case. Instead,
> we should derive high addr limit based on the mmap hint addr value.
> 
> Signed-off-by: Aneesh Kumar K.V 

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/7a06c66835f75fe2be4f154a93cc30

cheers


Re: [1/2] powerpc/perf/imc: use cpu_to_node instead topology_physical_package_id

2017-11-24 Thread Michael Ellerman
On Sun, 2017-10-15 at 18:43:41 UTC, Madhavan Srinivasan wrote:
> ...
> [1069001518.00] [c03f95b3f770] [c00b2574] 
> init_imc_pmu+0x1f4/0xc40
> [1069005374.00] [c03f95b3f850] [c008fec8] 
> opal_imc_counters_probe+0x2e8/0x3e0
> [1069009426.00] [c03f95b3f950] [c06153a4] 
> platform_drv_probe+0x44/0x90
> [1069012818.00] [c03f95b3f9c0] [c06124c0] 
> really_probe+0x290/0x370
> [1069016302.00] [c03f95b3fa50] [c06126c8] 
> __driver_attach+0x128/0x130
> [1069019564.00] [c03f95b3fa90] [c060f38c] 
> bus_for_each_dev+0x9c/0x110
> [1069022838.00] [c03f95b3fae0] [c0611dfc] 
> driver_attach+0x3c/0x60
> [1069026104.00] [c03f95b3fb10] [c06118d8] 
> bus_add_driver+0x298/0x320
> [1069029428.00] [c03f95b3fb90] [c06135b8] 
> driver_register+0xb8/0x1a0
> [1069033016.00] [c03f95b3fc00] [c061533c] 
> __platform_driver_register+0x8c/0xb0
> [1069036362.00] [c03f95b3fc30] [c0cbb0fc] 
> opal_imc_driver_init+0x24/0x38
> [1069039756.00] [c03f95b3fc50] [c000cc70] 
> do_one_initcall+0xd0/0x250
> [1069043094.00] [c03f95b3fd20] [c0ca44d0] 
> kernel_init_freeable+0x244/0x324
> [1069046490.00] [c03f95b3fdc0] [c000d600] 
> kernel_init+0x30/0x1b0
> [1069050348.00] [c03f95b3fe30] [c000b268] 
> ret_from_kernel_thread+0x5c/0x74
> 
> init_imc_pmu() use topology_physical_package_id() to detect the phy_id
> of the processor it is on to get local memory. But this cause crashes
> when node_id are not same as physicaly id. As a fix use cpu_to_node().
> 
> Reported-By: Rob Lippert 
> Tested-By: Madhavan Srinivasan 
> Signed-off-by: Madhavan Srinivasan 

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/f3f1dfd600ff82b18b7ea73d80eb27

cheers


[PATCH v2 1/2] powerpc: Avoid signed to unsigned conversion in set_thread_tidr()

2017-11-24 Thread Vaibhav Jain
There is an unsafe signed to unsigned conversion in set_thread_tidr()
that may cause an error value to be assigned to SPRN_TIDR register and
used as thread-id.

The issue happens as assign_thread_tidr() returns an int and
thread.tidr is an unsigned-long. So a negative error code returned
from assign_thread_tidr() will fail the error check and gets assigned
as tidr as a large positive value.

To fix this the patch assigns the return value of assign_thread_tidr()
to a temporary int and assigns it to thread.tidr iff its '> 0'.

The patch shouldn't impact the calling convention of set_thread_tidr()
i.e all -ve return-values are error codes, +ve return values are
assigned Thread-ids. The way function is implemented it should never
return a '0'.

Fixes: ec233ede4c86("powerpc: Add support for setting SPRN_TIDR")
Signed-off-by: Vaibhav Jain 

---
Changelog:

v2  ->  * Update the patch description to document the calling
convention of set_thread_tidr(). [Mpe]
* Fix a tidr allocation leak.
---
 arch/powerpc/kernel/process.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index bfdd783e3916..5d8176c7c2d8 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1569,19 +1569,21 @@ void arch_release_task_struct(struct task_struct *t)
  */
 int set_thread_tidr(struct task_struct *t)
 {
+   int rc;
+
if (!cpu_has_feature(CPU_FTR_ARCH_300))
return -EINVAL;
 
if (t != current)
return -EINVAL;
 
-   t->thread.tidr = assign_thread_tidr();
-   if (t->thread.tidr < 0)
-   return t->thread.tidr;
-
-   mtspr(SPRN_TIDR, t->thread.tidr);
+   rc = assign_thread_tidr();
+   if (rc > 0) {
+   t->thread.tidr = rc;
+   mtspr(SPRN_TIDR, t->thread.tidr);
+   }
 
-   return 0;
+   return rc;
 }
 
 #endif /* CONFIG_PPC64 */
-- 
2.14.3



[PATCH v2 2/2] powerpc: Do not assign thread.tidr if already assigned

2017-11-24 Thread Vaibhav Jain
If set_thread_tidr() is called twice for same task_struct then it will
allocate a new tidr value to it leaving the previous value still
dangling in the vas_thread_ida table.

To fix this the patch changes set_thread_tidr() to check if a tidr
value is already assigned to the task_struct and if yes then returns
the existing value from function instead of allocating a new one.

Fixes: ec233ede4c86("powerpc: Add support for setting SPRN_TIDR")
Signed-off-by: Vaibhav Jain 
---
v2 ->   Fix minor spell errors in patch description
---
 arch/powerpc/kernel/process.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 5d8176c7c2d8..9a72282b022d 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1577,6 +1577,9 @@ int set_thread_tidr(struct task_struct *t)
if (t != current)
return -EINVAL;
 
+   if (t->thread.tidr)
+   return t->thread.tidr;
+
rc = assign_thread_tidr();
if (rc > 0) {
t->thread.tidr = rc;
-- 
2.14.3