drm/ttm/pool: Fix ttm_pool_alloc error path
authorThomas Hellström <thomas.hellstrom@linux.intel.com>
Tue, 4 Apr 2023 20:06:48 +0000 (22:06 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:03:13 +0000 (23:03 +0900)
commitd2151c5d9dbe3f8fec4cae5f4784edce3ced3a7e
tree04cfd66cf2ed5af3af93985a8b1637e5c75fb391
parent5e5a4185c66f9478a8cb2f74eed1a5b5a5000b13
drm/ttm/pool: Fix ttm_pool_alloc error path

[ Upstream commit 379989e7cbdc7aa7496a00ee286ec146c7599cf0 ]

When hitting an error, the error path forgot to unmap dma mappings and
could call set_pages_wb() on already uncached pages.

Fix this by introducing a common ttm_pool_free_range() function that
does the right thing.

v2:
- Simplify that common function (Christian König)
v3:
- Rename that common function to ttm_pool_free_range() (Christian König)

Fixes: d099fc8f540a ("drm/ttm: new TT backend allocation pool v3")
Cc: Christian König <christian.koenig@amd.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Christian Koenig <christian.koenig@amd.com>
Cc: Huang Rui <ray.huang@amd.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230404200650.11043-2-thomas.hellstrom@linux.intel.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/ttm/ttm_pool.c