powerpc/powernv: Return for invalid IMC domain [Linux 4.14.129]

powerpc/powernv: Return for invalid IMC domain [Linux 4.14.129]

This Linux kernel change "powerpc/powernv: Return for invalid IMC domain" is included in the Linux 4.14.129 release. This change is authored by Anju T Sudhakar <anju [at] linux.vnet.ibm.com> on Mon May 20 14:27:53 2019 +0530. The commit for this change in Linux stable tree is 8a58d4a (patch) which is from upstream commit b59bd35. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream b59bd35.

powerpc/powernv: Return for invalid IMC domain

[ Upstream commit b59bd3527fe3c1939340df558d7f9d568fc9f882 ]

Currently init_imc_pmu() can fail either because we try to register an
IMC unit with an invalid domain (i.e an IMC node not supported by the
kernel) or something went wrong while registering a valid IMC unit. In
both the cases kernel provides a 'Register failed' error message.

For example when trace-imc node is not supported by the kernel, but
skiboot advertises a trace-imc node we print:

  IMC Unknown Device type
  IMC PMU (null) Register failed

To avoid confusion just print the unknown device type message, before
attempting PMU registration, so the second message isn't printed.

Fixes: 8f95faaac56c ("powerpc/powernv: Detect and create IMC device")
Reported-by: Pavaman Subramaniyam <[email protected]>
Signed-off-by: Anju T Sudhakar <[email protected]>
Reviewed-by: Madhavan Srinivasan <[email protected]>
[mpe: Reword change log a bit]
Signed-off-by: Michael Ellerman <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>

There are 4 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 arch/powerpc/platforms/powernv/opal-imc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/platforms/powernv/opal-imc.c b/arch/powerpc/platforms/powernv/opal-imc.c
index 6914b28..7b93191 100644
--- a/arch/powerpc/platforms/powernv/opal-imc.c
+++ b/arch/powerpc/platforms/powernv/opal-imc.c
@@ -87,6 +87,10 @@ static int imc_pmu_create(struct device_node *parent, int pmu_index, int domain)
    struct imc_pmu *pmu_ptr;
    u32 offset;

+   /* Return for unknown domain */
+   if (domain < 0)
+       return -EINVAL;
    /* memory for pmu */
    pmu_ptr = kzalloc(sizeof(struct imc_pmu), GFP_KERNEL);
    if (!pmu_ptr)

Leave a Reply

Your email address will not be published. Required fields are marked *