linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/powernv: Fallback to old HMI handling behavior for old firmware
@ 2014-10-06  9:34 Mahesh J Salgaonkar
  2014-10-07  4:53 ` Stewart Smith
  2014-10-10  6:23 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Mahesh J Salgaonkar @ 2014-10-06  9:34 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev, Benjamin Herrenschmidt; +Cc: Paul Mackerras

From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>

Recently we moved HMI handling into Linux kernel instead of taking
HMI directly in OPAL. This new change is dependent on new OPAL call
for HMI recovery which was introduced in newer firmware. While this new
change works fine with latest OPAL firmware, we broke the HMI handling
if we run newer kernel on old OPAL firmware that results in system hang.

This patch fixes this issue by falling back to old HMI behavior on older
OPAL firmware.

This patch introduces a check for opal token OPAL_HANDLE_HMI to see
if we are running on newer firmware or old firmware. On newer firmware
this check would return OPAL_TOKEN_PRESENT, otherwise we are running on
old firmware and fallback to old HMI behavior.

This patch depends on opal check token patch posted at ppc-devel
https://lists.ozlabs.org/pipermail/linuxppc-dev/2014-August/120224.html

Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/opal.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index b44eec3..2768cd3 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -194,6 +194,24 @@ static int __init opal_register_exception_handlers(void)
 	 * fwnmi area at 0x7000 to provide the glue space to OPAL
 	 */
 	glue = 0x7000;
+
+	/* Check if we are running on newer firmware that exports
+	 * OPAL_HANDLE_HMI token. If yes, then don't ask opal to patch
+	 * HMI interrupt and we catch it directly in Linux kernel.
+	 *
+	 * For older firmware we will fallback to old behavior and
+	 * let OPAL patch the HMI vector and handle it inside OPAL
+	 * firmware.
+	 */
+	if (opal_check_token(OPAL_HANDLE_HMI) != OPAL_TOKEN_PRESENT) {
+		/* We are on old firmware. fallback to old behavior. */
+		pr_info("%s: Falling back to old HMI handling behavior.\n",
+			__func__);
+		opal_register_exception_handler(
+				OPAL_HYPERVISOR_MAINTENANCE_HANDLER,
+				0, glue);
+		glue += 128;
+	}
 	opal_register_exception_handler(OPAL_SOFTPATCH_HANDLER, 0, glue);
 #endif
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/powernv: Fallback to old HMI handling behavior for old firmware
  2014-10-06  9:34 [PATCH] powerpc/powernv: Fallback to old HMI handling behavior for old firmware Mahesh J Salgaonkar
@ 2014-10-07  4:53 ` Stewart Smith
  2014-10-10  6:23 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Stewart Smith @ 2014-10-07  4:53 UTC (permalink / raw)
  To: Mahesh J Salgaonkar, Michael Ellerman, linuxppc-dev,
	Benjamin Herrenschmidt
  Cc: Paul Mackerras

Mahesh J Salgaonkar <mahesh@linux.vnet.ibm.com> writes:
> From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
>
> Recently we moved HMI handling into Linux kernel instead of taking
> HMI directly in OPAL. This new change is dependent on new OPAL call
> for HMI recovery which was introduced in newer firmware. While this new
> change works fine with latest OPAL firmware, we broke the HMI handling
> if we run newer kernel on old OPAL firmware that results in system hang.
>
> This patch fixes this issue by falling back to old HMI behavior on older
> OPAL firmware.
>
> This patch introduces a check for opal token OPAL_HANDLE_HMI to see
> if we are running on newer firmware or old firmware. On newer firmware
> this check would return OPAL_TOKEN_PRESENT, otherwise we are running on
> old firmware and fallback to old HMI behavior.
>
> This patch depends on opal check token patch posted at ppc-devel
> https://lists.ozlabs.org/pipermail/linuxppc-dev/2014-August/120224.html

(just reviewed that patch before this one...)

> diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
> index b44eec3..2768cd3 100644
> --- a/arch/powerpc/platforms/powernv/opal.c
> +++ b/arch/powerpc/platforms/powernv/opal.c
> @@ -194,6 +194,24 @@ static int __init opal_register_exception_handlers(void)
>  	 * fwnmi area at 0x7000 to provide the glue space to OPAL
>  	 */
>  	glue = 0x7000;
> +
> +	/* Check if we are running on newer firmware that exports
> +	 * OPAL_HANDLE_HMI token. If yes, then don't ask opal to patch
> +	 * HMI interrupt and we catch it directly in Linux kernel.
> +	 *
> +	 * For older firmware we will fallback to old behavior and
> +	 * let OPAL patch the HMI vector and handle it inside OPAL
> +	 * firmware.
> +	 */
> +	if (opal_check_token(OPAL_HANDLE_HMI) != OPAL_TOKEN_PRESENT) {
> +		/* We are on old firmware. fallback to old behavior. */
> +		pr_info("%s: Falling back to old HMI handling behavior.\n",
> +			__func__);
> +		opal_register_exception_handler(
> +				OPAL_HYPERVISOR_MAINTENANCE_HANDLER,
> +				0, glue);
> +		glue += 128;
> +	}
>  	opal_register_exception_handler(OPAL_SOFTPATCH_HANDLER, 0,
> glue);

So.. that all looks fine, but another note: why are we doing the
OPAL_SOFTPATCH_HANDLER and why is it all #if 0 out in skiboot?

for this patch:

Reviewed-by: Stewart Smith <stewart@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: powerpc/powernv: Fallback to old HMI handling behavior for old firmware
  2014-10-06  9:34 [PATCH] powerpc/powernv: Fallback to old HMI handling behavior for old firmware Mahesh J Salgaonkar
  2014-10-07  4:53 ` Stewart Smith
@ 2014-10-10  6:23 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2014-10-10  6:23 UTC (permalink / raw)
  To: Mahesh Salgaonkar, linuxppc-dev, Benjamin Herrenschmidt; +Cc: Paul Mackerras

On Mon, 2014-06-10 at 09:34:19 UTC, Mahesh Salgaonkar wrote:
> From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>

Hi Mahesh,

> Recently we moved HMI handling into Linux kernel instead of taking
> HMI directly in OPAL. This new change is dependent on new OPAL call
> for HMI recovery which was introduced in newer firmware. While this new
> change works fine with latest OPAL firmware, we broke the HMI handling
> if we run newer kernel on old OPAL firmware that results in system hang.
> 
> This patch fixes this issue by falling back to old HMI behavior on older
> OPAL firmware.

It sounds like "older" firmware is actually "the currently released firmware".
The "newer" firmware is still in development, is that right?

If so please update the comment and changelog to better reflect that.

> diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
> index b44eec3..2768cd3 100644
> --- a/arch/powerpc/platforms/powernv/opal.c
> +++ b/arch/powerpc/platforms/powernv/opal.c
> @@ -194,6 +194,24 @@ static int __init opal_register_exception_handlers(void)
>  	 * fwnmi area at 0x7000 to provide the glue space to OPAL
>  	 */
>  	glue = 0x7000;
> +
> +	/* Check if we are running on newer firmware that exports

Please format your long comments like:

/*
 * Check if we are ..
 */

I know some of our code uses the other style but this is the commonly accepted
style.

> +	 * OPAL_HANDLE_HMI token. If yes, then don't ask opal to patch
> +	 * HMI interrupt and we catch it directly in Linux kernel.
> +	 *
> +	 * For older firmware we will fallback to old behavior and
> +	 * let OPAL patch the HMI vector and handle it inside OPAL
> +	 * firmware.
> +	 */
> +	if (opal_check_token(OPAL_HANDLE_HMI) != OPAL_TOKEN_PRESENT) {

OPAL_TOKEN_PRESENT was dropped from the API. Just use:

	if (!opal_check_token(OPAL_HANDLE_HMI)) {

> +		/* We are on old firmware. fallback to old behavior. */
> +		pr_info("%s: Falling back to old HMI handling behavior.\n",
> +			__func__);

Please just use "opal: " rather than __func__.

And rather than the user having to know what the old vs new behaviour is, can
you make it explicit in the message, eg:

"opal: Old firmware detected, letting OPAL handle HMIs."

> +		opal_register_exception_handler(
> +				OPAL_HYPERVISOR_MAINTENANCE_HANDLER,
> +				0, glue);
> +		glue += 128;
> +	}

Newline here please.

>  	opal_register_exception_handler(OPAL_SOFTPATCH_HANDLER, 0, glue);
>  #endif


cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-10  6:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-06  9:34 [PATCH] powerpc/powernv: Fallback to old HMI handling behavior for old firmware Mahesh J Salgaonkar
2014-10-07  4:53 ` Stewart Smith
2014-10-10  6:23 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).