All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Michael Ellerman <michael@ellerman.id.au>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH 3/4] Simplify rtas_change_msi() error semantics
Date: Tue, 02 Oct 2007 15:23:23 +1000	[thread overview]
Message-ID: <1191302603.6310.88.camel@pasglop> (raw)
In-Reply-To: <fbd88f287ba9d9ca41b5c8da734afd595ae25922.1190270165.git.michael@ellerman.id.au>


On Thu, 2007-09-20 at 16:36 +1000, Michael Ellerman wrote:
> Currently rtas_change_msi() returns either the error code from RTAS, or if
> the RTAS call succeeded the number of irqs that were configured by RTAS.
> This makes checking the return value more complicated than it needs to be.
> 
> Instead, have rtas_change_msi() check that the number of irqs configured by
> RTAS is equal to what we requested - and return an error otherwise. This makes
> the return semantics match the usual 0 for success, something else for error.
> 
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>

Looks allright, just a question tho... what do we do if it fails ? Do we
try to fallback to a lower number of MSIs ? Or what ? Dead device ?

Ben.

> ---
>  arch/powerpc/platforms/pseries/msi.c |   18 +++++++++++-------
>  1 files changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/msi.c b/arch/powerpc/platforms/pseries/msi.c
> index 9c3bcfe..2793a1b 100644
> --- a/arch/powerpc/platforms/pseries/msi.c
> +++ b/arch/powerpc/platforms/pseries/msi.c
> @@ -70,11 +70,15 @@ static int rtas_change_msi(struct pci_dn *pdn, u32 func, u32 num_irqs)
>  		seq_num = rtas_ret[1];
>  	} while (rtas_busy_delay(rc));
>  
> -	if (rc == 0) /* Success */
> -		rc = rtas_ret[0];
> +	/*
> +	 * If the RTAS call succeeded, check the number of irqs is actually
> +	 * what we asked for. If not, return an error.
> +	 */
> +	if (rc == 0 && rtas_ret[0] != num_irqs)
> +		rc = -ENOSPC;
>  
> -	pr_debug("rtas_msi: ibm,change_msi(func=%d,num=%d) = (%d)\n",
> -		 func, num_irqs, rc);
> +	pr_debug("rtas_msi: ibm,change_msi(func=%d,num=%d), got %d rc = %d\n",
> +		 func, num_irqs, rtas_ret[0], rc);
>  
>  	return rc;
>  }
> @@ -87,7 +91,7 @@ static void rtas_disable_msi(struct pci_dev *pdev)
>  	if (!pdn)
>  		return;
>  
> -	if (rtas_change_msi(pdn, RTAS_CHANGE_FN, 0) != 0)
> +	if (rtas_change_msi(pdn, RTAS_CHANGE_FN, 0))
>  		pr_debug("rtas_msi: Setting MSIs to 0 failed!\n");
>  }
>  
> @@ -180,14 +184,14 @@ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
>  	if (type == PCI_CAP_ID_MSI) {
>  		rc = rtas_change_msi(pdn, RTAS_CHANGE_MSI_FN, nvec);
>  
> -		if (rc != nvec) {
> +		if (rc) {
>  			pr_debug("rtas_msi: trying the old firmware call.\n");
>  			rc = rtas_change_msi(pdn, RTAS_CHANGE_FN, nvec);
>  		}
>  	} else
>  		rc = rtas_change_msi(pdn, RTAS_CHANGE_MSIX_FN, nvec);
>  
> -	if (rc != nvec) {
> +	if (rc) {
>  		pr_debug("rtas_msi: rtas_change_msi() failed\n");
>  		return rc;
>  	}

  reply	other threads:[~2007-10-02  5:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-20  6:36 [PATCH 1/4] Simplify error logic in u3msi_setup_msi_irqs() Michael Ellerman
2007-09-20  6:36 ` [PATCH 2/4] Simplify error logic in rtas_setup_msi_irqs() Michael Ellerman
2007-10-02  5:21   ` Benjamin Herrenschmidt
2007-09-20  6:36 ` [PATCH 3/4] Simplify rtas_change_msi() error semantics Michael Ellerman
2007-10-02  5:23   ` Benjamin Herrenschmidt [this message]
2007-10-02  5:58     ` Michael Ellerman
2007-10-02  6:24       ` Benjamin Herrenschmidt
2007-10-02  7:40         ` Michael Ellerman
2007-10-02  8:37           ` Benjamin Herrenschmidt
2007-09-20  6:36 ` [PATCH 4/4] Inline u3msi_compose_msi_msg() Michael Ellerman
2007-10-02  5:24   ` Benjamin Herrenschmidt
2007-10-02  5:21 ` [PATCH 1/4] Simplify error logic in u3msi_setup_msi_irqs() Benjamin Herrenschmidt

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=1191302603.6310.88.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=michael@ellerman.id.au \
    /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.