linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] powerpc/powernv: Add OPAL check token call
@ 2014-08-19  4:47 Michael Neuling
  2014-08-19  4:48 ` [PATCH 2/4] powerpc/powernv: Check OPAL RTC calls exists before using Michael Neuling
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Michael Neuling @ 2014-08-19  4:47 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Michael Ellerman; +Cc: Stewart Smith, linuxppc-dev

Currently there is no way to generically check if an OPAL call exists or not
from the host kernel.

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

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

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

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

* [PATCH 2/4] powerpc/powernv: Check OPAL RTC calls exists before using
  2014-08-19  4:47 [PATCH 1/4] powerpc/powernv: Add OPAL check token call Michael Neuling
@ 2014-08-19  4:48 ` Michael Neuling
  2014-08-19  4:48 ` [PATCH 3/4] powerpc/powernv: Check OPAL elog calls exist " Michael Neuling
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Michael Neuling @ 2014-08-19  4:48 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Michael Ellerman; +Cc: Stewart Smith, linuxppc-dev

Check that the OPAL_RTC_READ token exists before we use the OPAL RTC.

Refactors the code a little to merge error paths.

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

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

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

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

* [PATCH 3/4] powerpc/powernv: Check OPAL elog calls exist before using
  2014-08-19  4:47 [PATCH 1/4] powerpc/powernv: Add OPAL check token call Michael Neuling
  2014-08-19  4:48 ` [PATCH 2/4] powerpc/powernv: Check OPAL RTC calls exists before using Michael Neuling
@ 2014-08-19  4:48 ` Michael Neuling
  2014-09-15  3:13   ` Michael Ellerman
  2014-08-19  4:48 ` [PATCH 4/4] powerpc/powernv: Check OPAL dump " Michael Neuling
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Michael Neuling @ 2014-08-19  4:48 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Michael Ellerman; +Cc: Stewart Smith, linuxppc-dev

Check that the OPAL_ELOG_READ token exists before initalising the elog
infrastructure.

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

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

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

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

* [PATCH 4/4] powerpc/powernv: Check OPAL dump calls exist before using
  2014-08-19  4:47 [PATCH 1/4] powerpc/powernv: Add OPAL check token call Michael Neuling
  2014-08-19  4:48 ` [PATCH 2/4] powerpc/powernv: Check OPAL RTC calls exists before using Michael Neuling
  2014-08-19  4:48 ` [PATCH 3/4] powerpc/powernv: Check OPAL elog calls exist " Michael Neuling
@ 2014-08-19  4:48 ` Michael Neuling
  2014-09-15  3:10 ` [PATCH 1/4] powerpc/powernv: Add OPAL check token call Michael Ellerman
  2014-10-07  4:36 ` Stewart Smith
  4 siblings, 0 replies; 9+ messages in thread
From: Michael Neuling @ 2014-08-19  4:48 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Michael Ellerman; +Cc: Stewart Smith, linuxppc-dev

Check that the OPAL_DUMP_READ token exists before initalising the elog
infrastructure.

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

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

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

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

* Re: [PATCH 1/4] powerpc/powernv: Add OPAL check token call
  2014-08-19  4:47 [PATCH 1/4] powerpc/powernv: Add OPAL check token call Michael Neuling
                   ` (2 preceding siblings ...)
  2014-08-19  4:48 ` [PATCH 4/4] powerpc/powernv: Check OPAL dump " Michael Neuling
@ 2014-09-15  3:10 ` Michael Ellerman
  2014-09-15  3:19   ` Michael Neuling
  2014-09-15 12:24   ` Benjamin Herrenschmidt
  2014-10-07  4:36 ` Stewart Smith
  4 siblings, 2 replies; 9+ messages in thread
From: Michael Ellerman @ 2014-09-15  3:10 UTC (permalink / raw)
  To: Michael Neuling; +Cc: Stewart Smith, linuxppc-dev

On Tue, 2014-08-19 at 14:47 +1000, Michael Neuling wrote:
> Currently there is no way to generically check if an OPAL call exists or not
> from the host kernel.
> 
> This adds an OPAL call opal_check_token() which tells you if the given token is
> present in OPAL or not.
> 
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> ---
>  arch/powerpc/include/asm/opal.h                | 7 +++++++
>  arch/powerpc/platforms/powernv/opal-wrappers.S | 1 +
>  2 files changed, 8 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
> index 86055e5..4593a93 100644
> --- a/arch/powerpc/include/asm/opal.h
> +++ b/arch/powerpc/include/asm/opal.h
> @@ -135,6 +135,7 @@ struct opal_sg_list {
>  #define OPAL_FLASH_MANAGE			77
>  #define OPAL_FLASH_UPDATE			78
>  #define OPAL_RESYNC_TIMEBASE			79
> +#define OPAL_CHECK_TOKEN			80
>  #define OPAL_DUMP_INIT				81
>  #define OPAL_DUMP_INFO				82
>  #define OPAL_DUMP_READ				83
> @@ -417,6 +418,11 @@ struct opal_msg {
>  	__be64 params[8];
>  };
>  
> +enum OpalCheckTokenStatus {
> +       OPAL_TOKEN_ABSENT = 0,
> +       OPAL_TOKEN_PRESENT = 1
> +};

I don't see this used anywhere?

And NoCamelCase !

Yes I know there's lots in that file, but I didn't merge that :)

cheers

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

* Re: [PATCH 3/4] powerpc/powernv: Check OPAL elog calls exist before using
  2014-08-19  4:48 ` [PATCH 3/4] powerpc/powernv: Check OPAL elog calls exist " Michael Neuling
@ 2014-09-15  3:13   ` Michael Ellerman
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Ellerman @ 2014-09-15  3:13 UTC (permalink / raw)
  To: Michael Neuling; +Cc: Stewart Smith, linuxppc-dev

On Tue, 2014-08-19 at 14:48 +1000, Michael Neuling wrote:
> Check that the OPAL_ELOG_READ token exists before initalising the elog
> infrastructure.
> 
> This avoids littering the OPAL console with:
>   "OPAL: Called with bad token 74"
> 
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> ---
>  arch/powerpc/platforms/powernv/opal-elog.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c
> index bbdb3ff..518fe95 100644
> --- a/arch/powerpc/platforms/powernv/opal-elog.c
> +++ b/arch/powerpc/platforms/powernv/opal-elog.c
> @@ -295,6 +295,10 @@ int __init opal_elog_init(void)
>  {
>  	int rc = 0;
>  
> +	/* ELOG not supported by firmware */
> +	if (!opal_check_token(OPAL_ELOG_READ))
> +		return -1;
> +

The only caller does:

			/* Setup error log interface */
			rc = opal_elog_init();
			/* Setup code update interface */
			opal_flash_init();
			/* Setup platform dump extract interface */
			opal_platform_dump_init();
			/* Setup system parameters interface */
			opal_sys_param_init();
			/* Setup message log interface. */
			opal_msglog_init();
		}
	
		return 0;
	}


So we may as well have it return void. Wanna send a follow-up patch for that.

cheers

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

* Re: [PATCH 1/4] powerpc/powernv: Add OPAL check token call
  2014-09-15  3:10 ` [PATCH 1/4] powerpc/powernv: Add OPAL check token call Michael Ellerman
@ 2014-09-15  3:19   ` Michael Neuling
  2014-09-15 12:24   ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 9+ messages in thread
From: Michael Neuling @ 2014-09-15  3:19 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Stewart Smith, linuxppc-dev

On Mon, 2014-09-15 at 13:10 +1000, Michael Ellerman wrote:
> On Tue, 2014-08-19 at 14:47 +1000, Michael Neuling wrote:
> > Currently there is no way to generically check if an OPAL call exists o=
r not
> > from the host kernel.
> >=20
> > This adds an OPAL call opal_check_token() which tells you if the given =
token is
> > present in OPAL or not.
> >=20
> > Signed-off-by: Michael Neuling <mikey@neuling.org>
> > ---
> >  arch/powerpc/include/asm/opal.h                | 7 +++++++
> >  arch/powerpc/platforms/powernv/opal-wrappers.S | 1 +
> >  2 files changed, 8 insertions(+)
> >=20
> > diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm=
/opal.h
> > index 86055e5..4593a93 100644
> > --- a/arch/powerpc/include/asm/opal.h
> > +++ b/arch/powerpc/include/asm/opal.h
> > @@ -135,6 +135,7 @@ struct opal_sg_list {
> >  #define OPAL_FLASH_MANAGE			77
> >  #define OPAL_FLASH_UPDATE			78
> >  #define OPAL_RESYNC_TIMEBASE			79
> > +#define OPAL_CHECK_TOKEN			80
> >  #define OPAL_DUMP_INIT				81
> >  #define OPAL_DUMP_INFO				82
> >  #define OPAL_DUMP_READ				83
> > @@ -417,6 +418,11 @@ struct opal_msg {
> >  	__be64 params[8];
> >  };
> > =20
> > +enum OpalCheckTokenStatus {
> > +       OPAL_TOKEN_ABSENT =3D 0,
> > +       OPAL_TOKEN_PRESENT =3D 1
> > +};
>=20
> I don't see this used anywhere?
>=20
> And NoCamelCase !

We can probably just delete the enum since we are just doing this in
code anyway:

       if (!opal_check_token(OPAL_RTC_READ))
               goto out;

OK?  Or would you prefer the usage to read:

       if (opal_check_token(OPAL_RTC_READ) =3D=3D OPAL_TOKEN_ABSENT)
               goto out;


> Yes I know there's lots in that file, but I didn't merge that :)

Fickle bloody maintainers.  I thought I never say this but... I want our
crazy Frenchman back! :-P

Mikey

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

* Re: [PATCH 1/4] powerpc/powernv: Add OPAL check token call
  2014-09-15  3:10 ` [PATCH 1/4] powerpc/powernv: Add OPAL check token call Michael Ellerman
  2014-09-15  3:19   ` Michael Neuling
@ 2014-09-15 12:24   ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 9+ messages in thread
From: Benjamin Herrenschmidt @ 2014-09-15 12:24 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Stewart Smith, Michael Neuling, linuxppc-dev

On Mon, 2014-09-15 at 13:10 +1000, Michael Ellerman wrote:
> > +enum OpalCheckTokenStatus {
> > +       OPAL_TOKEN_ABSENT = 0,
> > +       OPAL_TOKEN_PRESENT = 1
> > +};
> 
> I don't see this used anywhere?
> 
> And NoCamelCase !
> 
> Yes I know there's lots in that file, but I didn't merge that :)

The original OPAL APIs were like that and I chose to not "fix" them
because I've been aiming at reconciling the Linux and the FW versions
of the file, which I haven't had a chance to do yet (Cyril & Sam have
some WIP in that area afaik).

We could de-camelify them both but I'd rather do the reunification
first.

Cheers,
Ben.

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

* Re: [PATCH 1/4] powerpc/powernv: Add OPAL check token call
  2014-08-19  4:47 [PATCH 1/4] powerpc/powernv: Add OPAL check token call Michael Neuling
                   ` (3 preceding siblings ...)
  2014-09-15  3:10 ` [PATCH 1/4] powerpc/powernv: Add OPAL check token call Michael Ellerman
@ 2014-10-07  4:36 ` Stewart Smith
  4 siblings, 0 replies; 9+ messages in thread
From: Stewart Smith @ 2014-10-07  4:36 UTC (permalink / raw)
  To: Michael Neuling, Benjamin Herrenschmidt, Michael Ellerman; +Cc: linuxppc-dev

Michael Neuling <mikey@neuling.org> writes:
> Currently there is no way to generically check if an OPAL call exists or not
> from the host kernel.
>
> This adds an OPAL call opal_check_token() which tells you if the given token is
> present in OPAL or not.
>
> Signed-off-by: Michael Neuling <mikey@neuling.org>

(checked the firmware code)

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

(although should we be checking if the call returns OPAL_PARAMETER?
The opal call will return that if booting on firmware without
OPAL_CHECK_TOKEN.. which granted, is pretty old firmware that I don't
*think* we had leave the lab... or at least not to too many places)

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

end of thread, other threads:[~2014-10-07  4:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-19  4:47 [PATCH 1/4] powerpc/powernv: Add OPAL check token call Michael Neuling
2014-08-19  4:48 ` [PATCH 2/4] powerpc/powernv: Check OPAL RTC calls exists before using Michael Neuling
2014-08-19  4:48 ` [PATCH 3/4] powerpc/powernv: Check OPAL elog calls exist " Michael Neuling
2014-09-15  3:13   ` Michael Ellerman
2014-08-19  4:48 ` [PATCH 4/4] powerpc/powernv: Check OPAL dump " Michael Neuling
2014-09-15  3:10 ` [PATCH 1/4] powerpc/powernv: Add OPAL check token call Michael Ellerman
2014-09-15  3:19   ` Michael Neuling
2014-09-15 12:24   ` Benjamin Herrenschmidt
2014-10-07  4:36 ` Stewart Smith

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).