[Skiboot] [PATCH 5/7] npu2: Add checks to npu2-only codepaths

Alexey Kardashevskiy aik at ozlabs.ru
Tue Jun 18 17:12:50 AEST 2019



On 13/06/2019 07:08, Reza Arbab wrote:
> To prepare for npu3, add a few checks in codepaths that are only for
> npu2. Compare against PVR_TYPE_P9, as npu3 will be in systems of
> PVR_TYPE_P9P (or greater). Alternatively, check for dt compatibility
> with "ibm,power9-npu" because npu3 will use "ibm,power9-npu3".
> 
> Signed-off-by: Reza Arbab <arbab at linux.ibm.com>
> ---
>  core/hmi.c       | 4 ++++
>  hdata/spira.c    | 6 +++---
>  hw/npu2-common.c | 4 ++++
>  3 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/core/hmi.c b/core/hmi.c
> index 5cde67138109..2202bfba9ca2 100644
> --- a/core/hmi.c
> +++ b/core/hmi.c
> @@ -636,6 +636,10 @@ static void find_npu2_checkstop_reason(int flat_chip_id,
>  	int total_errors = 0;
>  	const char *loc;
>  
> +	/* NPU2 only */
> +	if (PVR_TYPE(mfspr(SPR_PVR)) != PVR_TYPE_P9)
> +		return;
> +
>  	/* Find the NPU on the chip associated with the HMI. */
>  	for_each_phb(phb) {
>  		/* NOTE: if a chip ever has >1 NPU this will need adjusting */
> diff --git a/hdata/spira.c b/hdata/spira.c
> index 6891a9c71bdf..804d90da34a1 100644
> --- a/hdata/spira.c
> +++ b/hdata/spira.c
> @@ -1506,7 +1506,8 @@ static void add_npus(void)
>  	int phb_index = 7; /* Start counting from 7, for no reason */
>  	int npu_index = 0;
>  
> -	if (proc_gen < proc_gen_p9)
> +	/* Only consult HDAT for npu2 */
> +	if (cpu_type != PVR_TYPE_P9)
>  		return;
>  
>  	dt_for_each_compatible(dt_root, xscom, "ibm,xscom") {
> @@ -1633,8 +1634,7 @@ int parse_hdat(bool is_opal)
>  	io_parse();
>  
>  	/* Add NPU nodes */
> -	if (proc_gen >= proc_gen_p9)
> -		add_npus();
> +	add_npus();
>  
>  	/* Parse VPD */
>  	vpd_parse();
> diff --git a/hw/npu2-common.c b/hw/npu2-common.c
> index f3f2f45a10d4..776030759693 100644
> --- a/hw/npu2-common.c
> +++ b/hw/npu2-common.c
> @@ -654,6 +654,10 @@ void probe_npu2(void)



probe_npu2() will probe npu3 and probe_npu3() will probe npu3? Quite
confusing. And thers is also probe_npu() - is that guy expected to probe
npu1, npu2, npu3?

I'd rather suggest factoring out common chunks, give them descriptive
names and call them from probe_npu[23]().


>  	struct dt_node *np;
>  	const char *zcal;
>  
> +	/* npu2 only */
> +	if (!dt_find_compatible_node(dt_root, NULL, "ibm,power9-npu"))
> +		return;
> +
>  	/* Abort if we're running on POWER9C DD1 (P9N DD1 is not supported) */
>  	if (chip &&
>  	    chip->type == PROC_CHIP_P9_CUMULUS &&
> 

-- 
Alexey


More information about the Skiboot mailing list