All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cedric Le Goater <clg@fr.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: Stewart Smith <stewart@linux.vnet.ibm.com>,
	skiboot@lists.ozlabs.org, benh@au1.ibm.com,
	linuxppc-dev@lists.ozlabs.org,
	Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Subject: Re: [PATCH v3 1/3] powerpc/powernv: convert codes returned by OPAL calls
Date: Mon, 30 Mar 2015 08:37:10 +0200	[thread overview]
Message-ID: <5518EF16.9070502@fr.ibm.com> (raw)
In-Reply-To: <1427681112.4218.6.camel@ellerman.id.au>

On 03/30/2015 04:05 AM, Michael Ellerman wrote:
> On Fri, 2015-03-27 at 17:39 +0100, Cédric Le Goater wrote:
>> OPAL has its own list of return codes. The patch provides a translation
>> of such codes in errnos for the opal_sensor_read call, and possibly 
>> others if needed.
>>
>> Index: linux.git/arch/powerpc/platforms/powernv/opal.c
>> ===================================================================
>> --- linux.git.orig/arch/powerpc/platforms/powernv/opal.c
>> +++ linux.git/arch/powerpc/platforms/powernv/opal.c
>> @@ -894,6 +894,23 @@ void opal_free_sg_list(struct opal_sg_li
>>  	}
>>  }
>>  
>> +int opal_error_code(int rc)
>> +{
>> +	switch (rc) {
>> +	case OPAL_SUCCESS:		return 0;
> 
> Obviously correct.

He. Initially, I didn't put a case for SUCCESS, but we have code doing :

	ret = be64_to_cpu(msg.params[1]);


>> +	case OPAL_PARAMETER:		return -EINVAL;
> 
> Yep.
> 
>> +	case OPAL_UNSUPPORTED:		return -ENOSYS;
> 
> You shouldn't use ENOSYS here, that should only ever mean "no such syscall",
> otherwise you get very confusing results like read() returning ENOSYS.

Indeed. How about ENODEV then ? 

>> +	case OPAL_ASYNC_COMPLETION:	return -EAGAIN;
> 
> EAGAIN means "try what you did again", I don't think that's what
> ASYNC_COMPLETION means, is it? It looks like it means, "don't try again, but
> you need to wait for the result to be ready".
> 
> I'm not sure it maps well to any of the Linux codes, maybe EINPROGRESS ?

Yes. This is better.

>> +	case OPAL_BUSY_EVENT:		return -EBUSY;
> 
> Yep.
> 
>> +	case OPAL_NO_MEM:		return -ENOMEM;
> 
> Yep.
> 
>> +	case OPAL_HARDWARE:		return -ENOENT;
> 
> This is another one which I think you shouldn't use as it can lead to confusing
> results at user level. eg:
> 
>   $ cat /sysfs/some/file
>   Error: No such file or directory
> 
> Huh?
> 
> Looking at the skiboot code this looks like EIO is a good match.

ok. 

>> +	case OPAL_INTERNAL_ERROR:	return -EIO;
> 
> Yeah as good as anything I guess.
> 
>> +	default:
>> +		pr_err("%s: unexpected OPAL error %d\n", __func__, rc);
>> +		return -ERANGE;
> 
> I'm not sure about this one honestly, it means "Math result not representable".
> 
> I suspect the reason RTAS chose it was just that it's not EINVAL.
> 
> This should probably also just be EIO.

ok. I will change it. 

Thanks,

C.

  reply	other threads:[~2015-03-30  6:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-25 17:50 [PATCH] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read Cédric Le Goater
2015-03-25 23:07 ` Stewart Smith
2015-03-26  9:44   ` Cedric Le Goater
2015-03-26 12:58     ` Cedric Le Goater
2015-03-26 16:04       ` [PATCH v2 1/3] powerpc/powernv: convert codes returned by OPAL calls Cédric Le Goater
2015-03-26 16:04         ` [PATCH v2 2/3] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read Cédric Le Goater
2015-03-26 16:04         ` [PATCH v2 3/3] powerpc/powernv: remove opal_sensor_mutex Cédric Le Goater
2015-03-27  9:59         ` [v2,1/3] powerpc/powernv: convert codes returned by OPAL calls Michael Ellerman
2015-03-27 10:36           ` [Skiboot] [v2, 1/3] " Benjamin Herrenschmidt
2015-03-27 10:39             ` Cedric Le Goater
2015-03-27 10:45           ` [v2,1/3] " Cedric Le Goater
2015-03-27 16:39           ` [PATCH v3 1/3] " Cédric Le Goater
2015-03-30  2:05             ` Michael Ellerman
2015-03-30  6:37               ` Cedric Le Goater [this message]
2015-03-30  6:54                 ` Michael Ellerman
2015-03-30  6:56                   ` Cedric Le Goater
2015-03-30 10:06                   ` [PATCH v4 1/2] " Cédric Le Goater
2015-03-30 10:06                   ` [PATCH v4 2/2] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read Cédric Le Goater
2015-03-27 16:39           ` [PATCH v3 2/3] " Cédric Le Goater
2015-03-27 16:39           ` [PATCH v3 3/3] powerpc/powernv: remove opal_sensor_mutex Cédric Le Goater
2015-03-30  2:09             ` Michael Ellerman
2015-03-30  6:51               ` Cedric Le Goater
2015-03-30  6:59                 ` Michael Ellerman
2015-03-30 10:05                   ` Cedric Le Goater
2015-03-27  6:05     ` [PATCH] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read Stewart Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5518EF16.9070502@fr.ibm.com \
    --to=clg@fr.ibm.com \
    --cc=benh@au1.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=neelegup@linux.vnet.ibm.com \
    --cc=skiboot@lists.ozlabs.org \
    --cc=stewart@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.