Subject: Re: [PATCH v3 2/3] powerpc/eeh: fix pseries_eeh_configure_bridge()

From: Nathan Lynch <[email-masked]>
Date: Fri, 24 Apr 2020 11:17:17 -0500

Sam Bobroff <[email-masked]> writes:
> If a device is hot unplgged during EEH recovery, it's possible for the
> RTAS call to ibm,configure-pe in pseries_eeh_configure() to return
> parameter error (-3), however negative return values are not checked
> for and this leads to an infinite loop.
>
> Fix this by correctly bailing out on negative values.
>
> Signed-off-by: Sam Bobroff <[email-masked]>
> ---
>  arch/powerpc/platforms/pseries/eeh_pseries.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/platforms/pseries/eeh_pseries.c b/arch/powerpc/platforms/pseries/eeh_pseries.c
> index 893ba3f562c4..9ea1c06a78cd 100644
> --- a/arch/powerpc/platforms/pseries/eeh_pseries.c
> +++ b/arch/powerpc/platforms/pseries/eeh_pseries.c
> @@ -607,6 +607,8 @@ static int pseries_eeh_configure_bridge(struct eeh_pe *pe)
>  
>  		if (!ret)
>  			return ret;
> +		if (ret < 0)
> +			break;
>  
>  		/*
>  		 * If RTAS returns a delay value that's above 100ms, cut it
> @@ -627,7 +629,7 @@ static int pseries_eeh_configure_bridge(struct eeh_pe *pe)
>  
>  	pr_warn("%s: Unable to configure bridge PHB#%x-PE#%x (%d)\n",
>  		__func__, pe->phb->global_number, pe->addr, ret);
> -	return ret;
> +	return rtas_error_rc(ret);

See my response to patch #1. I think the best you can do here right now
is return -EINVAL for -3, -EIO for any other (unarchitected) negative
value.