diff options
author | Michel Dänzer <[email protected]> | 2020-07-14 17:08:10 +0200 |
---|---|---|
committer | Michel Dänzer <[email protected]> | 2020-07-14 17:08:10 +0200 |
commit | 89caa485f15927ebc1f666b57732b55516288c1b (patch) | |
tree | 20961aac079caccd483c70e20da206c91323f834 /src/gallium | |
parent | 460300ed5927d1956d1258ba796ef642db86e540 (diff) |
Revert https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4580
It broke the CI pipeline on master:
https://gitlab.freedesktop.org/mesa/mesa/-/jobs/3604314
https://gitlab.freedesktop.org/mesa/mesa/-/jobs/3604315
Revert for now, to allow other MRs to be merged.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5905>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/util/u_screen.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nouveau_buffer.c | 81 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nouveau_buffer.h | 8 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nouveau_screen.c | 70 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nouveau_screen.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 14 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 3 | ||||
-rw-r--r-- | src/gallium/frontends/clover/core/device.cpp | 9 | ||||
-rw-r--r-- | src/gallium/frontends/clover/core/device.hpp | 1 | ||||
-rw-r--r-- | src/gallium/frontends/clover/core/resource.cpp | 4 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_defines.h | 1 |
11 files changed, 10 insertions, 185 deletions
diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index 59ff5dc84d5..69e44ab0dce 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -214,7 +214,6 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen, case PIPE_CAP_POLYGON_OFFSET_CLAMP: case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: case PIPE_CAP_RESOURCE_FROM_USER_MEMORY: - case PIPE_CAP_RESOURCE_FROM_USER_MEMORY_COMPUTE_ONLY: case PIPE_CAP_DEVICE_RESET_STATUS_QUERY: case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS: case PIPE_CAP_TEXTURE_FLOAT_LINEAR: diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c index acc0e8c8d29..abb4105099a 100644 --- a/src/gallium/drivers/nouveau/nouveau_buffer.c +++ b/src/gallium/drivers/nouveau/nouveau_buffer.c @@ -78,8 +78,6 @@ release_allocation(struct nouveau_mm_allocation **mm, inline void nouveau_buffer_release_gpu_storage(struct nv04_resource *buf) { - assert(!(buf->status & NOUVEAU_BUFFER_STATUS_USER_PTR)); - if (buf->fence && buf->fence->state < NOUVEAU_FENCE_STATE_FLUSHED) { nouveau_fence_work(buf->fence, nouveau_fence_unref_bo, buf->bo); buf->bo = NULL; @@ -568,9 +566,6 @@ nouveau_copy_buffer(struct nouveau_context *nv, { assert(dst->base.target == PIPE_BUFFER && src->base.target == PIPE_BUFFER); - assert(!(dst->status & NOUVEAU_BUFFER_STATUS_USER_PTR)); - assert(!(src->status & NOUVEAU_BUFFER_STATUS_USER_PTR)); - if (likely(dst->domain) && likely(src->domain)) { nv->copy_data(nv, dst->bo, dst->offset + dstx, dst->domain, @@ -604,8 +599,7 @@ nouveau_resource_map_offset(struct nouveau_context *nv, struct nv04_resource *res, uint32_t offset, uint32_t flags) { - if (unlikely(res->status & NOUVEAU_BUFFER_STATUS_USER_MEMORY) || - unlikely(res->status & NOUVEAU_BUFFER_STATUS_USER_PTR)) + if (unlikely(res->status & NOUVEAU_BUFFER_STATUS_USER_MEMORY)) return res->data + offset; if (res->domain == NOUVEAU_BO_VRAM) { @@ -628,6 +622,7 @@ nouveau_resource_map_offset(struct nouveau_context *nv, return (uint8_t *)res->bo->map + res->offset + offset; } + const struct u_resource_vtbl nouveau_buffer_vtbl = { u_default_resource_get_handle, /* get_handle */ @@ -637,46 +632,6 @@ const struct u_resource_vtbl nouveau_buffer_vtbl = nouveau_buffer_transfer_unmap, /* transfer_unmap */ }; -static void -nouveau_user_ptr_destroy(struct pipe_screen *pscreen, - struct pipe_resource *presource) -{ - struct nv04_resource *res = nv04_resource(presource); - FREE(res); -} - -static void * -nouveau_user_ptr_transfer_map(struct pipe_context *pipe, - struct pipe_resource *resource, - unsigned level, unsigned usage, - const struct pipe_box *box, - struct pipe_transfer **ptransfer) -{ - struct nouveau_transfer *tx = MALLOC_STRUCT(nouveau_transfer); - if (!tx) - return NULL; - nouveau_buffer_transfer_init(tx, resource, box, usage); - *ptransfer = &tx->base; - return nv04_resource(resource)->data; -} - -static void -nouveau_user_ptr_transfer_unmap(struct pipe_context *pipe, - struct pipe_transfer *transfer) -{ - struct nouveau_transfer *tx = nouveau_transfer(transfer); - FREE(tx); -} - -const struct u_resource_vtbl nouveau_user_ptr_buffer_vtbl = -{ - u_default_resource_get_handle, /* get_handle */ - nouveau_user_ptr_destroy, /* resource_destroy */ - nouveau_user_ptr_transfer_map, /* transfer_map */ - u_default_transfer_flush_region, /* transfer_flush_region */ - nouveau_user_ptr_transfer_unmap, /* transfer_unmap */ -}; - struct pipe_resource * nouveau_buffer_create(struct pipe_screen *pscreen, const struct pipe_resource *templ) @@ -745,32 +700,6 @@ fail: return NULL; } -struct pipe_resource * -nouveau_buffer_create_from_user(struct pipe_screen *pscreen, - const struct pipe_resource *templ, - void *user_ptr) -{ - struct nv04_resource *buffer; - - buffer = CALLOC_STRUCT(nv04_resource); - if (!buffer) - return NULL; - - buffer->base = *templ; - buffer->vtbl = &nouveau_user_ptr_buffer_vtbl; - /* set address and data to the same thing for higher compatibility with - * existing code. It's correct nonetheless as the same pointer is equally - * valid on the CPU and the GPU. - */ - buffer->address = (uint64_t)user_ptr; - buffer->data = user_ptr; - buffer->status = NOUVEAU_BUFFER_STATUS_USER_PTR; - buffer->base.screen = pscreen; - - pipe_reference_init(&buffer->base.reference, 1); - - return &buffer->base; -} struct pipe_resource * nouveau_user_buffer_create(struct pipe_screen *pscreen, void *ptr, @@ -818,8 +747,6 @@ bool nouveau_buffer_migrate(struct nouveau_context *nv, struct nv04_resource *buf, const unsigned new_domain) { - assert(!(buf->status & NOUVEAU_BUFFER_STATUS_USER_PTR)); - struct nouveau_screen *screen = nv->screen; struct nouveau_bo *bo; const unsigned old_domain = buf->domain; @@ -891,8 +818,6 @@ nouveau_user_buffer_upload(struct nouveau_context *nv, struct nv04_resource *buf, unsigned base, unsigned size) { - assert(!(buf->status & NOUVEAU_BUFFER_STATUS_USER_PTR)); - struct nouveau_screen *screen = nouveau_screen(buf->base.screen); int ret; @@ -921,8 +846,6 @@ nouveau_buffer_invalidate(struct pipe_context *pipe, struct nv04_resource *buf = nv04_resource(resource); int ref = buf->base.reference.count - 1; - assert(!(buf->status & NOUVEAU_BUFFER_STATUS_USER_PTR)); - /* Shared buffers shouldn't get reallocated */ if (unlikely(buf->base.bind & PIPE_BIND_SHARED)) return; diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.h b/src/gallium/drivers/nouveau/nouveau_buffer.h index b43db81d298..3a33fae9ce2 100644 --- a/src/gallium/drivers/nouveau/nouveau_buffer.h +++ b/src/gallium/drivers/nouveau/nouveau_buffer.h @@ -14,13 +14,10 @@ struct nouveau_bo; * * USER_MEMORY: resource->data is a pointer to client memory and may change * between GL calls - * - * USER_PTR: bo is backed by user memory mapped into the GPUs VM */ #define NOUVEAU_BUFFER_STATUS_GPU_READING (1 << 0) #define NOUVEAU_BUFFER_STATUS_GPU_WRITING (1 << 1) #define NOUVEAU_BUFFER_STATUS_DIRTY (1 << 2) -#define NOUVEAU_BUFFER_STATUS_USER_PTR (1 << 6) #define NOUVEAU_BUFFER_STATUS_USER_MEMORY (1 << 7) #define NOUVEAU_BUFFER_STATUS_REALLOC_MASK NOUVEAU_BUFFER_STATUS_USER_MEMORY @@ -95,11 +92,6 @@ nouveau_buffer_create(struct pipe_screen *pscreen, const struct pipe_resource *templ); struct pipe_resource * -nouveau_buffer_create_from_user(struct pipe_screen *pscreen, - const struct pipe_resource *templ, - void *user_ptr); - -struct pipe_resource * nouveau_user_buffer_create(struct pipe_screen *screen, void *ptr, unsigned bytes, unsigned usage); diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index e725f37f0e2..702d88b6c93 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -8,7 +8,6 @@ #include "util/format/u_format_s3tc.h" #include "util/u_string.h" -#include "os/os_mman.h" #include "util/os_time.h" #include <stdio.h> @@ -16,7 +15,6 @@ #include <stdlib.h> #include <nouveau_drm.h> -#include <xf86drm.h> #include "nouveau_winsys.h" #include "nouveau_screen.h" @@ -30,11 +28,6 @@ /* XXX this should go away */ #include "frontend/drm_driver.h" -/* Even though GPUs might allow addresses with more bits, some engines do not. - * Stick with 40 for compatibility. - */ -#define NV_GENERIC_VM_LIMIT_SHIFT 39 - int nouveau_mesa_debug = 0; static const char * @@ -180,16 +173,6 @@ nouveau_disk_cache_create(struct nouveau_screen *screen) cache_id, driver_flags); } -static void* -reserve_vma(uintptr_t start, uint64_t reserved_size) -{ - void *reserved = os_mmap((void*)start, reserved_size, PROT_NONE, - MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); - if (reserved == MAP_FAILED) - return NULL; - return reserved; -} - int nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) { @@ -234,46 +217,6 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) size = sizeof(nvc0_data); } - screen->has_svm = false; - /* we only care about HMM with OpenCL enabled */ - if (dev->chipset > 0x130 && screen->force_enable_cl) { - /* Before being able to enable SVM we need to carve out some memory for - * driver bo allocations. Let's just base the size on the available VRAM. - * - * 40 bit is the biggest we care about and for 32 bit systems we don't - * want to allocate all of the available memory either. - * - * Also we align the size we want to reserve to the next POT to make use - * of hugepages. - */ - const int vram_shift = util_logbase2_ceil64(dev->vram_size); - const int limit_bit = - MIN2(sizeof(void*) * 8 - 1, NV_GENERIC_VM_LIMIT_SHIFT); - screen->svm_cutout_size = - BITFIELD64_BIT(MIN2(sizeof(void*) == 4 ? 26 : NV_GENERIC_VM_LIMIT_SHIFT, vram_shift)); - - size_t start = screen->svm_cutout_size; - do { - screen->svm_cutout = reserve_vma(start, screen->svm_cutout_size); - if (!screen->svm_cutout) { - start += screen->svm_cutout_size; - continue; - } - - struct drm_nouveau_svm_init svm_args = { - .unmanaged_addr = (uint64_t)screen->svm_cutout, - .unmanaged_size = screen->svm_cutout_size, - }; - - ret = drmCommandWrite(screen->drm->fd, DRM_NOUVEAU_SVM_INIT, - &svm_args, sizeof(svm_args)); - screen->has_svm = !ret; - if (!screen->has_svm) - os_munmap(screen->svm_cutout, screen->svm_cutout_size); - break; - } while ((start + screen->svm_cutout_size) < BITFIELD64_MASK(limit_bit)); - } - /* * Set default VRAM domain if not overridden */ @@ -287,16 +230,16 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) ret = nouveau_object_new(&dev->object, 0, NOUVEAU_FIFO_CHANNEL_CLASS, data, size, &screen->channel); if (ret) - goto err; + return ret; ret = nouveau_client_new(screen->device, &screen->client); if (ret) - goto err; + return ret; ret = nouveau_pushbuf_new(screen->client, screen->channel, 4, 512 * 1024, 1, &screen->pushbuf); if (ret) - goto err; + return ret; /* getting CPU time first appears to be more accurate */ screen->cpu_gpu_time_delta = os_time_get(); @@ -338,11 +281,6 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) &mm_config); screen->mm_VRAM = nouveau_mm_create(dev, NOUVEAU_BO_VRAM, &mm_config); return 0; - -err: - if (screen->svm_cutout) - os_munmap(screen->svm_cutout, screen->svm_cutout_size); - return ret; } void @@ -352,8 +290,6 @@ nouveau_screen_fini(struct nouveau_screen *screen) if (screen->force_enable_cl) glsl_type_singleton_decref(); - if (screen->has_svm) - os_munmap(screen->svm_cutout, screen->svm_cutout_size); nouveau_mm_destroy(screen->mm_GART); nouveau_mm_destroy(screen->mm_VRAM); diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h index 2eb6320b2ec..40464225c75 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.h +++ b/src/gallium/drivers/nouveau/nouveau_screen.h @@ -70,9 +70,6 @@ struct nouveau_screen { bool prefer_nir; bool force_enable_cl; - bool has_svm; - void *svm_cutout; - size_t svm_cutout_size; #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS union { diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c index 622cfd4b9e1..d73ecf71624 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c @@ -98,19 +98,6 @@ nvc0_surface_create(struct pipe_context *pipe, return nvc0_miptree_surface_new(pipe, pres, templ); } -static struct pipe_resource * -nvc0_resource_from_user_memory(struct pipe_screen *pipe, - const struct pipe_resource *templ, - void *user_memory) -{ - struct nouveau_screen *screen = nouveau_screen(pipe); - - assert(screen->has_svm); - assert(templ->target == PIPE_BUFFER); - - return nouveau_buffer_create_from_user(pipe, templ, user_memory); -} - void nvc0_init_resource_functions(struct pipe_context *pcontext) { @@ -133,5 +120,4 @@ nvc0_screen_init_resource_functions(struct pipe_screen *pscreen) pscreen->resource_from_handle = nvc0_resource_from_handle; pscreen->resource_get_handle = u_resource_get_handle_vtbl; pscreen->resource_destroy = u_resource_destroy_vtbl; - pscreen->resource_from_user_memory = nvc0_resource_from_user_memory; } diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c index 2f0e92e6c29..c7a3354103a 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c @@ -323,9 +323,6 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) return class_3d >= GM200_3D_CLASS; case PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_TRIANGLES: return class_3d >= GP100_3D_CLASS; - case PIPE_CAP_RESOURCE_FROM_USER_MEMORY_COMPUTE_ONLY: - case PIPE_CAP_SYSTEM_SVM: - return screen->has_svm ? 1 : 0; /* caps has to be turned on with nir */ case PIPE_CAP_GL_SPIRV: diff --git a/src/gallium/frontends/clover/core/device.cpp b/src/gallium/frontends/clover/core/device.cpp index 7f3d970ea5f..ca2d951c767 100644 --- a/src/gallium/frontends/clover/core/device.cpp +++ b/src/gallium/frontends/clover/core/device.cpp @@ -238,7 +238,8 @@ device::svm_support() const { // // Another unsolvable scenario is a cl_mem object passed by cl_mem reference // and SVM pointer into the same kernel at the same time. - if (allows_user_pointers() && pipe->get_param(pipe, PIPE_CAP_SYSTEM_SVM)) + if (pipe->get_param(pipe, PIPE_CAP_RESOURCE_FROM_USER_MEMORY) && + pipe->get_param(pipe, PIPE_CAP_SYSTEM_SVM)) // we can emulate all lower levels if we support fine grain system return CL_DEVICE_SVM_FINE_GRAIN_SYSTEM | CL_DEVICE_SVM_COARSE_GRAIN_BUFFER | @@ -246,12 +247,6 @@ device::svm_support() const { return 0; } -bool -device::allows_user_pointers() const { - return pipe->get_param(pipe, PIPE_CAP_RESOURCE_FROM_USER_MEMORY) || - pipe->get_param(pipe, PIPE_CAP_RESOURCE_FROM_USER_MEMORY_COMPUTE_ONLY); -} - std::vector<size_t> device::max_block_size() const { auto v = get_compute_param<uint64_t>(pipe, ir_format(), diff --git a/src/gallium/frontends/clover/core/device.hpp b/src/gallium/frontends/clover/core/device.hpp index 2cd3a54762e..7c8cf13ccf7 100644 --- a/src/gallium/frontends/clover/core/device.hpp +++ b/src/gallium/frontends/clover/core/device.hpp @@ -72,7 +72,6 @@ namespace clover { bool has_unified_memory() const; size_t mem_base_addr_align() const; cl_device_svm_capabilities svm_support() const; - bool allows_user_pointers() const; std::vector<size_t> max_block_size() const; cl_uint subgroup_size() const; diff --git a/src/gallium/frontends/clover/core/resource.cpp b/src/gallium/frontends/clover/core/resource.cpp index c3c6cce5f3b..b8e257db6dc 100644 --- a/src/gallium/frontends/clover/core/resource.cpp +++ b/src/gallium/frontends/clover/core/resource.cpp @@ -127,6 +127,8 @@ root_resource::root_resource(clover::device &dev, memory_obj &obj, command_queue &q, const std::string &data) : resource(dev, obj) { pipe_resource info {}; + const bool user_ptr_support = dev.pipe->get_param(dev.pipe, + PIPE_CAP_RESOURCE_FROM_USER_MEMORY); if (image *img = dynamic_cast<image *>(&obj)) { info.format = translate_format(img->format()); @@ -145,7 +147,7 @@ root_resource::root_resource(clover::device &dev, memory_obj &obj, PIPE_BIND_COMPUTE_RESOURCE | PIPE_BIND_GLOBAL); - if (obj.flags() & CL_MEM_USE_HOST_PTR && dev.allows_user_pointers()) { + if (obj.flags() & CL_MEM_USE_HOST_PTR && user_ptr_support) { // Page alignment is normally required for this, just try, hope for the // best and fall back if it fails. pipe = dev.pipe->resource_from_user_memory(dev.pipe, &info, obj.host_ptr()); diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index ccb5fa11208..c6a2f0f4f14 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -811,7 +811,6 @@ enum pipe_cap PIPE_CAP_POLYGON_OFFSET_CLAMP, PIPE_CAP_MULTISAMPLE_Z_RESOLVE, PIPE_CAP_RESOURCE_FROM_USER_MEMORY, - PIPE_CAP_RESOURCE_FROM_USER_MEMORY_COMPUTE_ONLY, PIPE_CAP_DEVICE_RESET_STATUS_QUERY, PIPE_CAP_MAX_SHADER_PATCH_VARYINGS, PIPE_CAP_TEXTURE_FLOAT_LINEAR, |