[Skiboot] [PATCH 6/6] platforms/astbmc/witherspoon: Implement OpenCAPI support

Alistair Popple alistair at popple.id.au
Tue Aug 21 16:59:59 AEST 2018


<snip>

> +	gpu0_present = occ_get_gpu_presence(chip, 0);
> +	if (gpu0_present) {
> +		prlog(PR_DEBUG, "PLAT: Chip %d GPU#0 slot present\n", chip->id);
> +	}
> +
> +	gpu1_present = occ_get_gpu_presence(chip, 1);
> +	if (gpu1_present) {
> +		prlog(PR_DEBUG, "PLAT: Chip %d GPU#1 slot present\n", chip->id);
> +	}
> +
> +	/* Set pins to input */
> +	state = 0xff;
> +	rc = i2c_request_send(i2c_port_id,
> +			      platform.ocapi->i2c_presence_addr, SMBUS_WRITE, 3,
> +			      1, &state, 1, 120);
> +	if (rc)
> +		goto i2c_failed;
> +
> +	/* Read the presence value */
> +	state = 0x00;
> +	rc = i2c_request_send(i2c_port_id,
> +			      platform.ocapi->i2c_presence_addr, SMBUS_READ, 0,
> +			      1, &state, 1, 120);
> +	if (rc)
> +		goto i2c_failed;
> +
> +	if (gpu0_present) {
> +		if (state & (1 << 0)) {
> +			prlog(PR_DEBUG, "PLAT: Chip %d GPU#0 is OpenCAPI\n",
> +			      chip->id);
> +			/*
> +			 * On witherspoon, bricks 2 and 3 are connected to
> +			 * the lanes matching links 1 and 0 in OpenCAPI mode.
> +			 */
> +			dev = find_link_index(npu, 0);
> +			if (dev) {
> +				dev->type = NPU2_DEV_TYPE_OPENCAPI;
> +				dev->brick_index = 3;
> +			}
> +
> +			dev = find_link_index(npu, 1);
> +			if (dev) {
> +				/* dev->type = NPU2_DEV_TYPE_OPENCAPI; */
> +				/* We current don't support using the second link */
> +				dev->type = NPU2_DEV_TYPE_UNKNOWN;
> +				dev->brick_index = 2;
> +			}
> +		} else {
> +			prlog(PR_DEBUG, "PLAT: Chip %d GPU#0 is NVLink\n",
> +			      chip->id);
> +			dev = find_link_index(npu, 0);
> +			if (dev)
> +				dev->type = NPU2_DEV_TYPE_NVLINK;
> +			dev = find_link_index(npu, 1);
> +			if (dev)
> +				dev->type = NPU2_DEV_TYPE_NVLINK;
> +			dev = find_link_index(npu, 2);
> +			if (dev)
> +				dev->type = NPU2_DEV_TYPE_NVLINK;
> +		}
> +	}
> +
> +	if (gpu1_present) {
> +		if (state & (1 << 1)) {
> +			prlog(PR_DEBUG, "PLAT: Chip %d GPU#1 is OpenCAPI\n",
> +			      chip->id);
> +			dev = find_link_index(npu, 4);
> +			if (dev)
> +				dev->type = NPU2_DEV_TYPE_OPENCAPI;
> +			dev = find_link_index(npu, 5);
> +			if (dev)
> +				/* dev->type = NPU2_DEV_TYPE_OPENCAPI; */
> +				/* We current don't support using the second link */
> +				dev->type = NPU2_DEV_TYPE_UNKNOWN;
> +		} else {
> +			prlog(PR_DEBUG, "PLAT: Chip %d GPU#1 is NVLink\n",
> +			      chip->id);
> +			dev = find_link_index(npu, 3);
> +			if (dev)
> +				dev->type = NPU2_DEV_TYPE_NVLINK;
> +			dev = find_link_index(npu, 4);
> +			if (dev)
> +				dev->type = NPU2_DEV_TYPE_NVLINK;
> +			dev = find_link_index(npu, 5);
> +			if (dev)
> +				dev->type = NPU2_DEV_TYPE_NVLINK;
> +		}
> +	}

There looks to be a reasonable amount of code duplication here which might
benefit from a little refactoring but it looks correct.

Reviewed-By: Alistair Popple <alistair at popple.id.au>




More information about the Skiboot mailing list