drm/amdgpu: Check BO's requested pinning domains against its preferred_domains
authorjsg <jsg@openbsd.org>
Thu, 18 Aug 2022 00:41:20 +0000 (00:41 +0000)
committerjsg <jsg@openbsd.org>
Thu, 18 Aug 2022 00:41:20 +0000 (00:41 +0000)
From Leo Li
eb3c69c7c777d9d3c016568cb062ef02197a5a4e in linux 5.15.y/5.15.61
f5ba14043621f4afdf3ad5f92ee2d8dbebbe4340 in mainline linux

sys/dev/pci/drm/amd/amdgpu/amdgpu_object.c

index b5c67fb..54b498d 100644 (file)
@@ -914,6 +914,10 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
        if (WARN_ON_ONCE(min_offset > max_offset))
                return -EINVAL;
 
+       /* Check domain to be pinned to against preferred domains */
+       if (bo->preferred_domains & domain)
+               domain = bo->preferred_domains & domain;
+
        /* A shared bo cannot be migrated to VRAM */
        if (bo->tbo.base.import_attach) {
                if (domain & AMDGPU_GEM_DOMAIN_GTT)