drm/amdgpu: Check BO's requested pinning domains against its preferred_domains
authorLeo Li <sunpeng.li@amd.com>
Tue, 12 Jul 2022 16:30:29 +0000 (12:30 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 14 Jul 2022 00:56:44 +0000 (20:56 -0400)
commitf5ba14043621f4afdf3ad5f92ee2d8dbebbe4340
tree7ddb8a54aba1533d90af77ea8535a3782d848701
parenta0d10c437c1c9859d24a16b90abf85120603b4ff
drm/amdgpu: Check BO's requested pinning domains against its preferred_domains

When pinning a buffer, we should check to see if there are any
additional restrictions imposed by bo->preferred_domains. This will
prevent the BO from being moved to an invalid domain when pinning.

For example, this can happen if the user requests to create a BO in GTT
domain for display scanout. amdgpu_dm will allow pinning to either VRAM
or GTT domains, since DCN can scanout from either or. However, in
amdgpu_bo_pin_restricted(), pinning to VRAM is preferred if there is
adequate carveout. This can lead to pinning to VRAM despite the user
requesting GTT placement for the BO.

v2: Allow the kernel to override the domain, which can happen when
    exporting a BO to a V4L camera (for example).

Signed-off-by: Leo Li <sunpeng.li@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c