[Skiboot] [PATCH v3 05/10] npu2: Use read-modify-write in npu2_assign_gmb()

Alistair Popple alistair at popple.id.au
Fri Aug 4 14:16:17 AEST 2017


Much cleaner. Thanks!

Acked-by: Alistair Popple <alistair at popple.id.au>

On Mon, 31 Jul 2017 09:37:01 PM Reza Arbab wrote:
> We currently set each half of the GPU memory BAR by OR'ing our half
> into what is already there. This allows a possible conflict if Hostboot
> or other system boot software has already written to the BAR.
> 
> Set each half of the BAR value directly instead of using OR.
> 
> Signed-off-by: Reza Arbab <arbab at linux.vnet.ibm.com>
> Cc: Alistair Popple <alistair at popple.id.au>
> Cc: Andrew Donnellan <andrew.donnellan at au1.ibm.com>
> Cc: Frederic Barrat <fbarrat at linux.vnet.ibm.com>
> ---
>  hw/npu2.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/npu2.c b/hw/npu2.c
> index c7e636f..e495728 100644
> --- a/hw/npu2.c
> +++ b/hw/npu2.c
> @@ -630,14 +630,16 @@ static int npu2_assign_gmb(struct npu2_dev *ndev)
>  
>  	mode += ndev->bdfn & 0x7;
>  	val = SETFIELD(NPU2_MEM_BAR_MODE, val, mode);
> -	if (NPU2DEV_BRICK(ndev))
> -		val >>= 32;
> +
>  	reg = NPU2_REG_OFFSET(NPU2_STACK_STCK_0 + NPU2DEV_STACK(ndev),
>  			      NPU2_BLOCK_SM_0,
>  			      NPU2_GPU0_MEM_BAR);
>  
>  	old_val = npu2_read(p, reg);
> -	val |= old_val;
> +	if (NPU2DEV_BRICK(ndev))
> +		val = SETFIELD(PPC_BITMASK(32, 63), old_val, val >> 32);
> +	else
> +		val = SETFIELD(PPC_BITMASK(0, 31), old_val, val >> 32);
>  
>  	npu2_write(p, reg, val);
>  	reg = NPU2_REG_OFFSET(NPU2_STACK_STCK_0 + NPU2DEV_STACK(ndev),
> 



More information about the Skiboot mailing list