]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/powernv/npu: Add lock to prevent race in concurrent context init/destroy
authorAlistair Popple <alistair@popple.id.au>
Wed, 11 Apr 2018 06:38:54 +0000 (16:38 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 23 Apr 2018 23:46:56 +0000 (09:46 +1000)
commit4cda2ce49a2d250b9ec5edb6e1d34e2ecdde0d96
tree60f2fc855fef3941a2ca52dd5968d971fd4ada80
parent1e9787386e749050823cf92c9e8412dae04d1fd9
powerpc/powernv/npu: Add lock to prevent race in concurrent context init/destroy

The pnv_npu2_init_context() and pnv_npu2_destroy_context() functions
are used to allocate/free contexts to allow address translation and
shootdown by the NPU on a particular GPU. Context initialisation is
implicitly safe as it is protected by the requirement mmap_sem be held
in write mode, however pnv_npu2_destroy_context() does not require
mmap_sem to be held and it is not safe to call with a concurrent
initialisation for a different GPU.

It was assumed the driver would ensure destruction was not called
concurrently with initialisation. However the driver may be simplified
by allowing concurrent initialisation and destruction for different
GPUs. As npu context creation/destruction is not a performance
critical path and the critical section is not large a single spinlock
is used for simplicity.

Fixes: 775d3584b1e7 ("powerpc/powernv: Introduce address translation services for Nvlink2")
Cc: stable@vger.kernel.org # v4.12+
Signed-off-by: Alistair Popple <alistair@popple.id.au>
Reviewed-by: Mark Hairgrove <mhairgrove@nvidia.com>
Tested-by: Mark Hairgrove <mhairgrove@nvidia.com>
Reviewed-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/powernv/npu-dma.c