[Skiboot] [PATCH v4] hw/npu2-opencapi: Add initial support for allocating OpenCAPI LPC memory

Frederic Barrat fbarrat at linux.ibm.com
Tue May 14 01:19:38 AEST 2019


Arg! One silly mistake below...



> diff --git a/hw/npu2-opencapi.c b/hw/npu2-opencapi.c
> index 9df51b22eda5..d78b161eac27 100644
> --- a/hw/npu2-opencapi.c
> +++ b/hw/npu2-opencapi.c

...

> +static int64_t alloc_mem_bar(struct npu2_dev *dev, uint64_t size, uint64_t *bar)
> +{
> +	uint64_t phys_map_base, phys_map_size;
> +	int rc = OPAL_SUCCESS;
> +
> +	lock(&dev->npu->lock);
> +
> +	/*
> +	 * Right now, we support 1 allocation per chip, of up to 4TB.
> +	 *
> +	 * In future, we will use chip address extension to support
> +	 * >4TB ranges, and we will implement a more sophisticated
> +	 * allocator to allow an allocation for every link on a chip.
> +	 */
> +
> +	if (dev->npu->lpc_mem_allocated) {
> +		rc = OPAL_RESOURCE;
> +		goto out;
> +	}
> +
> +	phys_map_get(dev->npu->chip_id, OCAPI_MEM, 0, &phys_map_base, &phys_map_size);
> +
> +	if (size > phys_map_size) {
> +		/**
> +		 * @fwts-label OCAPIInvalidLPCMemoryBARSize
> +		 * @fwts-advice The operating system requested an unsupported
> +		 * amount of OpenCAPI LPC memory. This is possibly a kernel
> +		 * bug, or you may need to upgrade your firmware.
> +		 */
> +		OCAPIERR(dev, "Invalid LPC memory BAR allocation size requested: 0x%llx bytes (limit 0x%llx)\n",
> +			 size, phys_map_size);

		rc = OPAL_PARAMETER

> +		goto out;
> +	}



More information about the Skiboot mailing list