struct amdgpu_bo *bo;
struct drm_amdgpu_gem_userptr args;
union drm_amdgpu_gem_va va;
+ uintptr_t cpu0;
+ uint32_t ps, off;
memset(&args, 0, sizeof(args));
- args.addr = (uint64_t)cpu;
+ ps = getpagesize();
+
+ cpu0 = ROUND_DOWN((uintptr_t)cpu, ps);
+ off = (uintptr_t)cpu - cpu0;
+ size = ROUND_UP(size + off, ps);
+
+ args.addr = cpu0;
args.flags = AMDGPU_GEM_USERPTR_ANONONLY | AMDGPU_GEM_USERPTR_REGISTER;
args.size = size;
r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_GEM_USERPTR,
(void*)(uintptr_t)bo->virtual_mc_base_address, bo);
info->buf_handle = bo;
info->virtual_mc_base_address = bo->virtual_mc_base_address;
+ info->virtual_mc_base_address += off;
+
return r;
}
#include "util_double_list.h"
#define AMDGPU_CS_MAX_RINGS 8
+/* do not use below macro if b is not power of 2 aligned value */
+#define ROUND_DOWN(a,b) ((a) & (~((b)-1)))
+#define ROUND_UP(a,b) (((a)+((b)-1)) & (~((b)-1)))
struct amdgpu_bo_va_hole {
struct list_head list;