Subject: Re: [PATCH] powerpc/eeh: Validate arch in eeh_add_device_early()

From: Benjamin Herrenschmidt <[email-masked]>
Date: Wed, 13 Jan 2016 17:04:40 +1100

On Sun, 2016-01-10 at 01:08 -0200, Guilherme G. Piccoli wrote:weust changes the way the arch checking is done in function
> 
> This patch jeeh_add_device_early(): we use no more eeh_enabled(), but instead we check therunning architecture by using the macro machine_is(). If we are running on
> pSeries or PowerNV, the EEH mechanism can be enabled; otherwise, we bail out
> the function. This way, we don't enable EEH on Cell and we don't hit the oops
> on DLPAR either.

Can't we just check for eeh_ops being NULL ?

Cheers,
Ben.

> Fixes: 89a51df5ab1d ("powerpc/eeh: Fix crash in eeh_add_device_early() on Cell")
> Signed-off-by: Guilherme G. Piccoli <[email-masked]>
> ---
>  arch/powerpc/kernel/eeh.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
> index 40e4d4a..81e2d3e 100644
> --- a/arch/powerpc/kernel/eeh.c
> +++ b/arch/powerpc/kernel/eeh.c
> @@ -1072,7 +1072,13 @@ void eeh_add_device_early(struct pci_dn *pdn)
>  	struct pci_controller *phb;
>  	struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
>  
> -	if (!edev || !eeh_enabled())
> +	if (!edev)
> +		return;
> +
> +	/* Some platforms (like Cell) don't have EEH capabilities, so we
> +	 * need to abort here. In case of pseries or powernv, we have EEH
> +	 * so we can continue. */
> +	if (!machine_is(pseries) && !machine_is(powernv))
>  		return;
>  
>  	if (!eeh_has_flag(EEH_PROBE_MODE_DEVTREE))