[Skiboot] [PATCH 01/16] [PATCH 01/16] opencapi5: move opal api

Frederic Barrat fbarrat at linux.ibm.com
Wed Sep 8 22:16:35 AEST 2021



On 20/08/2021 11:45, Christophe Lombard wrote:
> Move the OPAL entry points for npu2 opencapi to the common opal NPU
> file. This prepares us to add same entries for PAU opencapi in this common
> file.
> 
> No functional change.
> 
> Signed-off-by: Christophe Lombard <clombard at linux.vnet.ibm.com>
> ---
>   hw/npu-opal.c      | 67 ++++++++++++++++++++++++++++++++++++++++++++++
>   hw/npu2-opencapi.c | 35 ++++--------------------
>   include/npu2.h     |  7 +++++
>   3 files changed, 79 insertions(+), 30 deletions(-)
> 
> diff --git a/hw/npu-opal.c b/hw/npu-opal.c
> index 412ea460..64e36852 100644
> --- a/hw/npu-opal.c
> +++ b/hw/npu-opal.c
> @@ -174,3 +174,70 @@ static int64_t opal_npu_get_relaxed_order(uint64_t phb_id,
>   	return phb4->ro_state;
>   }
>   opal_call(OPAL_NPU_GET_RELAXED_ORDER, opal_npu_get_relaxed_order, 2);
> +
> +#define MAX_PE_HANDLE	((1 << 15) - 1)
> +
> +static int64_t opal_npu_spa_setup(uint64_t phb_id, uint32_t bdfn,
> +				  uint64_t addr, uint64_t PE_mask)
> +{
> +	struct phb *phb = pci_get_phb(phb_id);
> +	int64_t rc = OPAL_SUCCESS;
> +
> +	if (!phb)
> +		return OPAL_PARAMETER;
> +
> +	/* 4k aligned */
> +	if (addr & 0xFFF)
> +		return OPAL_PARAMETER;
> +
> +	if (PE_mask > 15)
> +		return OPAL_PARAMETER;
> +
> +	if (phb->phb_type == phb_type_npu_v2_opencapi)
> +		rc = npu2_opencapi_spa_setup(phb, bdfn, addr, PE_mask);
> +	else
> +		return OPAL_PARAMETER;
> +
> +	return rc;


That seems a bit convoluted, that last line is useless.  That pattern 
will be repeated, with a few twists, in later patches. We should just 
use the same pattern on all the opal calls. See more on patch "Add 
support for OpenCAPI Persistent Memory devices."




> diff --git a/hw/npu2-opencapi.c b/hw/npu2-opencapi.c
> index 035c6cdc..686f2e22 100644
> --- a/hw/npu2-opencapi.c
> +++ b/hw/npu2-opencapi.c

> -static int64_t opal_npu_tl_set(uint64_t phb_id, uint32_t __unused bdfn,
> -			long capabilities, uint64_t rate_phys, int rate_sz)
> +int64_t npu2_opencapi_tl_set(struct phb *phb, uint32_t __unused bdfn,
> +		    long capabilities, uint64_t rate_phys, int rate_sz)
>   {
> -	struct phb *phb = pci_get_phb(phb_id);
>   	struct npu2_dev *dev;
>   	uint64_t stack, block, reg, templ_rate;
>   	int i, rate_pos;
>   	char *rate = (char *) rate_phys;
> 
> -	if (!phb || phb->phb_type != phb_type_npu_v2_opencapi)
> -		return OPAL_PARAMETER;
>   	if (!opal_addr_valid(rate) || rate_sz != TL_RATE_BUF_SIZE)
>   		return OPAL_PARAMETER;

For all the other opal calls, the argument verification is done in the 
front-end (npu-opal.c), except here for rate and rate_sz. No big deal, 
but it looks a bit odd.

   Fred


> 
> @@ -2157,7 +2133,6 @@ static int64_t opal_npu_tl_set(uint64_t phb_id, uint32_t __unused bdfn,
>   	OCAPIDBG(dev, "OTL configuration 1 register set to %llx\n", reg);
>   	return OPAL_SUCCESS;
>   }
> -opal_call(OPAL_NPU_TL_SET, opal_npu_tl_set, 5);
> 
>   static void set_mem_bar(struct npu2_dev *dev, uint64_t base, uint64_t size)
>   {
> diff --git a/include/npu2.h b/include/npu2.h
> index eb7c4558..f48a68b6 100644
> --- a/include/npu2.h
> +++ b/include/npu2.h
> @@ -271,4 +271,11 @@ static inline int npu2_get_phb_index(unsigned int brick_index)
>   	return NPU2_PHB_INDEX_BASE + brick_index;
>   }
> 
> +int64_t npu2_opencapi_spa_setup(struct phb *phb, uint32_t __unused bdfn,
> +				uint64_t addr, uint64_t PE_mask);
> +int64_t npu2_opencapi_spa_clear_cache(struct phb *phb, uint32_t __unused bdfn,
> +				      uint64_t PE_handle);
> +int64_t npu2_opencapi_tl_set(struct phb *phb, uint32_t __unused bdfn,
> +		    long capabilities, uint64_t rate_phys, int rate_sz);
> +
>   #endif /* __NPU2_H */
> 


More information about the Skiboot mailing list