[Mesa-dev] [PATCH 3/3] vc4: Enable Neon on arm builds
Signed-off-by: Rob Herring --- src/gallium/drivers/vc4/Android.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/vc4/Android.mk b/src/gallium/drivers/vc4/Android.mk index de9d5e3f5b3c..fdc06744e5ab 100644 --- a/src/gallium/drivers/vc4/Android.mk +++ b/src/gallium/drivers/vc4/Android.mk @@ -25,6 +25,8 @@ include $(LOCAL_PATH)/Makefile.sources include $(CLEAR_VARS) +LOCAL_CFLAGS_arm := -DVC4_BUILD_NEON + LOCAL_SRC_FILES := \ $(C_SOURCES) -- 2.10.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] vc4: Make Neon inline assembly clang compatible
clang throws an error on "%r2" and similar. I couldn't find any documentation on what "%r?" is supposed to mean and I've never seen any use like that as far as I remember. The parameter is supposed to be cpu_stride and just %2/%3 should be sufficient. There's no need for trailing ";" either, so remove those, too. Signed-off-by: Rob Herring --- Eric, I *think* this is correct, but completely untested other than compiled on Android. Rob src/gallium/drivers/vc4/vc4_tiling_lt.c | 70 - 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/gallium/drivers/vc4/vc4_tiling_lt.c b/src/gallium/drivers/vc4/vc4_tiling_lt.c index 237396b1eaec..c9cbc65e2dbc 100644 --- a/src/gallium/drivers/vc4/vc4_tiling_lt.c +++ b/src/gallium/drivers/vc4/vc4_tiling_lt.c @@ -67,18 +67,18 @@ vc4_load_utile(void *cpu, void *gpu, uint32_t cpu_stride, uint32_t cpp) /* Load from the GPU in one shot, no interleave, to * d0-d7. */ -"vldm %0, {q0, q1, q2, q3};\n" +"vldm %0, {q0, q1, q2, q3}\n" /* Store each 8-byte line to cpu-side destination, * incrementing it by the stride each time. */ -"vst1.8 d0, [%1], %r2;\n" -"vst1.8 d1, [%1], %r2;\n" -"vst1.8 d2, [%1], %r2;\n" -"vst1.8 d3, [%1], %r2;\n" -"vst1.8 d4, [%1], %r2;\n" -"vst1.8 d5, [%1], %r2;\n" -"vst1.8 d6, [%1], %r2;\n" -"vst1.8 d7, [%1];\n" +"vst1.8 d0, [%1], %2\n" +"vst1.8 d1, [%1], %2\n" +"vst1.8 d2, [%1], %2\n" +"vst1.8 d3, [%1], %2\n" +"vst1.8 d4, [%1], %2\n" +"vst1.8 d5, [%1], %2\n" +"vst1.8 d6, [%1], %2\n" +"vst1.8 d7, [%1]\n" : : "r"(gpu), "r"(cpu), "r"(cpu_stride) : "q0", "q1", "q2", "q3"); @@ -93,14 +93,14 @@ vc4_load_utile(void *cpu, void *gpu, uint32_t cpu_stride, uint32_t cpp) * destination. (vld1 can only store one d-register * at a time). */ -"vst1.8 d0, [%1], %r3;\n" -"vst1.8 d1, [%2], %r3;\n" -"vst1.8 d2, [%1], %r3;\n" -"vst1.8 d3, [%2], %r3;\n" -"vst1.8 d4, [%1], %r3;\n" -"vst1.8 d5, [%2], %r3;\n" -"vst1.8 d6, [%1];\n" -"vst1.8 d7, [%2];\n" +"vst1.8 d0, [%1], %3\n" +"vst1.8 d1, [%2], %3\n" +"vst1.8 d2, [%1], %3\n" +"vst1.8 d3, [%2], %3\n" +"vst1.8 d4, [%1], %3\n" +"vst1.8 d5, [%2], %3\n" +"vst1.8 d6, [%1]\n" +"vst1.8 d7, [%2]\n" : : "r"(gpu), "r"(cpu), "r"(cpu + 8), "r"(cpu_stride) : "q0", "q1", "q2", "q3"); @@ -124,18 +124,18 @@ vc4_store_utile(void *gpu, void *cpu, uint32_t cpu_stride, uint32_t cpp) /* Load each 8-byte line from cpu-side source, * incrementing it by the stride each time. */ -"vld1.8 d0, [%1], %r2;\n" -"vld1.8 d1, [%1], %r2;\n" -"vld1.8 d2, [%1], %r2;\n" -"vld1.8 d3, [%1], %r2;\n" -"vld1.8 d4, [%1], %r2;\n" -"vld1.8 d5, [%1], %r2;\n" -"vld1.8 d6, [%1], %r2;\n" -"vld1.8 d7, [%1];\n" +"vld1.8 d0, [%1], %2\n" +"vld1.8 d1, [%1], %2\n" +"vld1.8 d2, [%1], %2\n" +"vld1.8 d3, [%1], %2\n" +
[Mesa-dev] [PATCH 2/3] vc4: fix arm64 build with Neon
The addition of Neon assembly breaks on arm64 builds because the assembly syntax is different. For now, restrict Neon to ARMv7 builds. Signed-off-by: Rob Herring --- src/gallium/drivers/vc4/vc4_tiling.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/vc4/vc4_tiling.h b/src/gallium/drivers/vc4/vc4_tiling.h index 218130b2007c..ba1ad6fb3f7d 100644 --- a/src/gallium/drivers/vc4/vc4_tiling.h +++ b/src/gallium/drivers/vc4/vc4_tiling.h @@ -87,7 +87,7 @@ void vc4_store_tiled_image(void *dst, uint32_t dst_stride, * should extend this to have some runtime detection of being built for ARMv6 * on a Pi 2+. */ -#if defined(__ARM_ARCH) && __ARM_ARCH >= 7 +#if defined(__ARM_ARCH) && __ARM_ARCH == 7 #define NEON_SUFFIX(x) x ## _neon #else #define NEON_SUFFIX(x) x ## _base -- 2.10.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Mesa 12.1.0 release plan (Was Re: Next Mesa release, anyone?)
On Tue, Oct 4, 2016 at 5:26 AM, Emil Velikov wrote: > On 4 October 2016 at 02:05, Rob Clark wrote: >> On Thu, Sep 29, 2016 at 10:56 AM, Emil Velikov >> wrote: >>> On 28 September 2016 at 19:53, Marek Olšák wrote: Hi, It's been almost 4 months since the 12.0 branch was created, and soon it will have been 3 months since Mesa 12.0 was released. Is there any reason we haven't created the stable branch yet? Ideally, we would time the release so that it's 1-2 months before fall distribution releases. >>> >>> Thanks Marek ! >>> >>> In all honesty I was secretly hoping that we'll get Dave/Bas RADV for >>> 12.1. With the topic of which would be 'the default' Vulkan driver for >>> ATI/AMD hardware to be considered at a later stage. >> >> btw, I pushed libdrm release that I think etnaviv was waiting for.. >> not sure what else is needed before merging etnaviv gallium driver, >> but if at all possible, it would be nice to land that before the >> branch point too. >> > Thanks for the libdrm bits Rob. IIRC on the mesa side Christian > reworked the render-only parts noticeably, yet as long as there isn't > a crazy amount of changes outside of the etnaviv driver I think we're > fine with getting it in. I've been doing some work to get etnaviv working on Android. The render-only approach is a bit broken IMO. It may work okay for X11 which expects to work on a card node, but it doesn't for Android which already uses the render node for GL and gralloc and the KMS node for HWC. Having the render-only driver also open the KMS node gets us into all of the permissions issues. It seems to me we want gralloc to be able to open both nodes (that still has some ioctl permission issues) and allocate scanout buffers from the control node (thru GBM). Then the etnaviv driver has to know to blit to the linear buffer when it has an imported scanout buffer. IOW, I don't think the render-only driver should internally allocate dumb buffers, but keep that allocation external and the etnaviv driver needs to be able to deal with external buffers. Maybe we just wait for the grand central allocator to solve all this. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] Fwd: errors for mesa master Android build 440
New Android build error for gen6_xml.h... -- Forwarded message -- From: Date: Sat, Oct 8, 2016 at 3:56 AM Subject: errors for mesa master Android build 440 To: rob.herr...@linaro.org Build URL: https://ci.linaro.org/jenkins/job/robher-aosp/440/ Full log: https://ci.linaro.org/jenkins/job/robher-aosp/440/consoleText Parsed warnings/errors: https://ci.linaro.org/jenkins/job/robher-aosp/440/parsed_console ERRORS: W: GPG error: http://ppa.launchpad.net utopic Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F1FCBACA7BE1F97B + sudo apt-get install -y gcc-4.9-multilib bison git gperf libxml2-utils python-mako zip time python-pycurl genisoimage patch mtools libfdt-dev python-mako gettext openjdk-8-jdk Reading package lists... ninja: error: 'out/target/product/linaro_arm64/gen/STATIC_LIBRARIES/libmesa_genxml_intermediates/genxml/gen6_xml.h', needed by 'out/target/product/linaro_arm64/obj/STATIC_LIBRARIES/libmesa_genxml_intermediates/genxml/gen6_xml.h', missing and no known rule to make it make: *** [ninja_wrapper] Error 1 make: Target `gallium_dri' not remade because of errors. ninja: error: 'out/target/product/linaro_x86_64/gen/STATIC_LIBRARIES/libmesa_genxml_intermediates/genxml/gen6_xml.h', needed by 'out/target/product/linaro_x86_64/obj/STATIC_LIBRARIES/libmesa_genxml_intermediates/genxml/gen6_xml.h', missing and no known rule to make it make: *** [ninja_wrapper] Error 1 make: Target `gallium_dri' not remade because of errors. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 6/7] egl/android: Add support for YV12 pixel format (v2)
On Mon, Aug 8, 2016 at 1:39 PM, Chad Versace wrote: > On 08/02/2016 04:07 AM, Tomasz Figa wrote: >> >> This patch adds support for YV12 pixel format to the Android platform >> backend. Only creating EGL images is supported, it is not added to the >> list of available visuals. >> >> v2: Use const array defined just for YV12 instead of trying to be overly >> generic. >> >> Signed-off-by: Tomasz Figa >> Signed-off-by: Kalyan Kondapally >> --- >> src/egl/drivers/dri2/platform_android.c | 56 >> + >> 1 file changed, 50 insertions(+), 6 deletions(-) > > > > >> @@ -512,22 +518,60 @@ static _EGLImage * >> droid_create_image_from_prime_fd(_EGLDisplay *disp, _EGLContext *ctx, >> struct ANativeWindowBuffer *buf, int fd) >> { >> + unsigned int offsets[3] = { 0, 0, 0 }; >> + unsigned int pitches[3] = { 0, 0, 0 }; >> + >> const int fourcc = get_fourcc(buf->format); >> - const int pitch = buf->stride * get_format_bpp(buf->format); >> + if (fourcc == -1) { >> + _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR"); >> + return NULL; >> + } >> >> - const EGLint attr_list[14] = { >> + pitches[0] = buf->stride * get_format_bpp(buf->format); >> + if (pitches[0] == 0) { >> + _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR"); >> + return NULL; >> + } >> + >> + switch (buf->format) { >> + case HAL_PIXEL_FORMAT_YV12: >> + /* Y plane is assumed to be at offset 0. */ >> + /* Cr plane is located after Y plane */ >> + offsets[1] = offsets[0] + pitches[0] * buf->height; >> + pitches[1] = ALIGN(pitches[0] / 2, 16); >> + /* Cb plane is located after Cr plane */ >> + offsets[2] = offsets[1] + pitches[1] * buf->height / 2; > > > I believe the above should be >offsets[2] = offsets[1] + pitches[1] * ALIGN(buf->height, 2) / 2; > to accommodate buffers with odd height. Android defines this format is even height and width with a stride multiple of 16 pixels: /* * Android YUV format: * * This format is exposed outside of the HAL to software decoders and * applications. EGLImageKHR must support it in conjunction with the * OES_EGL_image_external extension. * * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed * by (W/2) x (H/2) Cr and Cb planes. * * This format assumes * - an even width * - an even height * - a horizontal stride multiple of 16 pixels * - a vertical stride equal to the height * * y_size = stride * height * c_stride = ALIGN(stride/2, 16) * c_size = c_stride * height/2 * size = y_size + c_size * 2 * cr_offset = y_size * cb_offset = y_size + c_size * * When used with ANativeWindow, the dataSpace field describes the color * space of the buffer. */ Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/8] intel: Add a new "common" library for more code sharing
On Wed, Aug 31, 2016 at 3:56 PM, Jason Ekstrand wrote: > The first thing to go in this new library is brw_device_info. > > Signed-off-by: Jason Ekstrand > Cc: Rob Herring > --- > > The android build files I just copied-and-pasted from blorp but I don't > have an android build setup so I can't test them. Tested-by: Rob Herring Took longer than I expected because there's an unrelated breakage in glsl. Patch coming for that one. A couple of nits though... [...] > + > +include $(CLEAR_VARS) > + > +LOCAL_MODULE := libintel_common For consistency: libmesa_intel_common > + > +LOCAL_MODULE_CLASS := STATIC_LIBRARIES > + > +LOCAL_SRC_FILES := $(COMMON_FILES) > + > +LOCAL_C_INCLUDES := This line is not needed. > + > +include $(MESA_COMMON_MK) > +include $(BUILD_STATIC_LIBRARY) Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/8] intel: Add a new "common" library for more code sharing
On Thu, Sep 1, 2016 at 12:37 PM, Mauro Rossi wrote: > Thanks > > Doing a first attempt in building, there is currently some generated > code missing in android build for recent gsls changes, > due to commit ee3cdac7857a5c0f30108e1b1963d042f2a5e8e6 "glsl: Use the > generated constant expression code" > > I'll send a patch for that problem soon and I'll check and report I'm about to send one already. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] Android: glsl: add rules to generate ir_expression*.h header files
Recent changes to generate ir_expression*.h header files broke Android builds. This adds the generation rules. This change is complicated due to creating a circular dependency between libmesa_glsl, libmesa_nir, and libmesa_compiler. Normally, we add static libraries so that include paths are added even if there's no linking dependency. That is the case here. Instead, we explicitly add the include path using $(MESA_GEN_GLSL_H) to libmesa_compiler. This in turn requires shuffling the order of make includes. It also uncovered missing dependency tracking of glsl_parser.h. Signed-off-by: Rob Herring --- src/compiler/Android.glsl.gen.mk| 25 + src/compiler/Android.glsl.mk| 1 - src/compiler/Android.mk | 12 src/mesa/Android.libmesa_dricore.mk | 6 +- src/mesa/Android.libmesa_st_mesa.mk | 4 +++- src/mesa/program/Android.mk | 6 -- 6 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/compiler/Android.glsl.gen.mk b/src/compiler/Android.glsl.gen.mk index 157aa27..d7623e5 100644 --- a/src/compiler/Android.glsl.gen.mk +++ b/src/compiler/Android.glsl.gen.mk @@ -41,6 +41,15 @@ LOCAL_GENERATED_SOURCES += $(addprefix $(intermediates)/, \ $(LIBGLCPP_GENERATED_FILES) \ $(LIBGLSL_GENERATED_FILES)) +LOCAL_EXPORT_C_INCLUDE_DIRS += \ + $(intermediates)/glsl \ + +# Modules using libmesa_nir must set LOCAL_GENERATED_SOURCES to this +MESA_GEN_GLSL_H := $(addprefix $(call local-generated-sources-dir)/, \ + glsl/ir_expression_operation.h \ + glsl/ir_expression_operation_constant.h \ + glsl/ir_expression_operation_strings.h) + define local-l-or-ll-to-c-or-cpp @mkdir -p $(dir $@) @echo "Mesa Lex: $(PRIVATE_MODULE) <= $<" @@ -73,8 +82,24 @@ $(intermediates)/glsl/glsl_lexer.cpp: $(LOCAL_PATH)/glsl/glsl_lexer.ll $(intermediates)/glsl/glsl_parser.cpp: $(LOCAL_PATH)/glsl/glsl_parser.yy $(call local-yy-to-cpp-and-h,.cpp) +$(intermediates)/glsl/glsl_parser.h: $(intermediates)/glsl/glsl_parser.cpp + $(intermediates)/glsl/glcpp/glcpp-lex.c: $(LOCAL_PATH)/glsl/glcpp/glcpp-lex.l $(call local-l-or-ll-to-c-or-cpp) $(intermediates)/glsl/glcpp/glcpp-parse.c: $(LOCAL_PATH)/glsl/glcpp/glcpp-parse.y $(call glsl_local-y-to-c-and-h) + +$(LOCAL_PATH)/glsl/ir.h: $(intermediates)/glsl/ir_expression_operation.h + +$(intermediates)/glsl/ir_expression_operation.h: $(LOCAL_PATH)/glsl/ir_expression_operation.py + @mkdir -p $(dir $@) + $(hide) $(MESA_PYTHON2) $< enum > $@ + +$(intermediates)/glsl/ir_expression_operation_constant.h: $(LOCAL_PATH)/glsl/ir_expression_operation.py + @mkdir -p $(dir $@) + $(hide) $(MESA_PYTHON2) $< constant > $@ + +$(intermediates)/glsl/ir_expression_operation_strings.h: $(LOCAL_PATH)/glsl/ir_expression_operation.py + @mkdir -p $(dir $@) + $(hide) $(MESA_PYTHON2) $< strings > $@ diff --git a/src/compiler/Android.glsl.mk b/src/compiler/Android.glsl.mk index 21c1065..dcc356f 100644 --- a/src/compiler/Android.glsl.mk +++ b/src/compiler/Android.glsl.mk @@ -44,7 +44,6 @@ LOCAL_C_INCLUDES := \ $(MESA_TOP)/src/gallium/auxiliary LOCAL_STATIC_LIBRARIES := \ - libmesa_compiler \ libmesa_nir LOCAL_MODULE := libmesa_glsl diff --git a/src/compiler/Android.mk b/src/compiler/Android.mk index ac0ced5..1e81ca5 100644 --- a/src/compiler/Android.mk +++ b/src/compiler/Android.mk @@ -22,7 +22,8 @@ LOCAL_PATH := $(call my-dir) -include $(LOCAL_PATH)/Makefile.sources +include $(LOCAL_PATH)/Android.glsl.mk +include $(LOCAL_PATH)/Android.nir.mk # --- # Build libmesa_compiler @@ -30,19 +31,22 @@ include $(LOCAL_PATH)/Makefile.sources include $(CLEAR_VARS) +include $(LOCAL_PATH)/Makefile.sources LOCAL_SRC_FILES := $(LIBCOMPILER_FILES) LOCAL_C_INCLUDES := \ $(MESA_TOP)/src/mapi \ $(MESA_TOP)/src/mesa \ $(MESA_TOP)/src/gallium/include \ - $(MESA_TOP)/src/gallium/auxiliary + $(MESA_TOP)/src/gallium/auxiliary \ + $(dir $(MESA_GEN_GLSL_H)) + +LOCAL_GENERATED_SOURCES += \ + $(MESA_GEN_GLSL_H) LOCAL_MODULE := libmesa_compiler include $(MESA_COMMON_MK) include $(BUILD_STATIC_LIBRARY) -include $(LOCAL_PATH)/Android.glsl.mk -include $(LOCAL_PATH)/Android.nir.mk diff --git a/src/mesa/Android.libmesa_dricore.mk b/src/mesa/Android.libmesa_dricore.mk index d7647a7..86196ce 100644 --- a/src/mesa/Android.libmesa_dricore.mk +++ b/src/mesa/Android.libmesa_dricore.mk @@ -60,7 +60,11 @@ LOCAL_C_INCLUDES := \ $(MESA_TOP)/src/mesa/main \ $(MESA_TOP)/src/compiler/nir \ $(MESA_TOP)/src/gallium/include \ - $(MESA_TOP)/src/gallium/auxiliary + $(MESA_TOP)/src/gallium/auxiliary \ + $(dir $(MESA_GEN_GLSL_H)) + +LOCAL_GENERATED_SOURCES += \ + $(MESA_GEN_GLSL_H) LOCAL_WHOLE_STATIC_LIBRARIES += \ libmesa_program diff --git a/src
[Mesa-dev] [PATCH] amd/addrlib: limit fastcall/regparm to i386
The use of regparm causes an error on arm/arm64 builds with clang. fastcall is allowed, but still throws a warning. As both options only have effect on 32-bit x86 builds, limit them to that case. Signed-off-by: Rob Herring --- src/amd/addrlib/addrtypes.h | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/amd/addrlib/addrtypes.h b/src/amd/addrlib/addrtypes.h index 4c68ac544b88..183b5a751c3a 100644 --- a/src/amd/addrlib/addrtypes.h +++ b/src/amd/addrlib/addrtypes.h @@ -87,10 +87,14 @@ typedef intINT; #endif #ifndef ADDR_FASTCALL -#if defined(__GNUC__) -#define ADDR_FASTCALL __attribute__((regparm(0))) +#if defined(__i386__) + #if defined(__GNUC__) +#define ADDR_FASTCALL __attribute__((regparm(0))) +#else +#define ADDR_FASTCALL __fastcall +#endif #else -#define ADDR_FASTCALL __fastcall + #define ADDR_FASTCALL #endif #endif -- 2.10.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] egl/android: implement minimal swap_buffers_with_damage
Since commit 0a606a400fe3 ("egl: add eglSwapBuffersWithDamageKHR"), Android has been broken because the function eglSwapBuffersWithDamageKHR is provided regardless of the extension being present. Also, the Android meta-EGL always advertises the extension regardless of the underlying EGL implementation. As there doesn't seem to be a simple way conditionally make the EGL function ptr NULL, just implement a brain dead version for Android EGL. Cc: Rob Clark Cc: Eric Engestrom Cc: Emil Velikov Signed-off-by: Rob Herring --- src/egl/drivers/dri2/platform_android.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index 142ef05bd1ea..2a6527a34407 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -483,6 +483,14 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) return EGL_TRUE; } +static EGLBoolean +droid_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *disp, + _EGLSurface *draw, const EGLint *rects, + EGLint n_rects) +{ + return droid_swap_buffers(drv, disp, draw); +} + static _EGLImage * droid_create_image_from_prime_fd(_EGLDisplay *disp, _EGLContext *ctx, struct ANativeWindowBuffer *buf, int fd) @@ -876,7 +884,7 @@ static struct dri2_egl_display_vtbl droid_display_vtbl = { .create_image = droid_create_image_khr, .swap_interval = dri2_fallback_swap_interval, .swap_buffers = droid_swap_buffers, - .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage, + .swap_buffers_with_damage = droid_swap_buffers_with_damage, .swap_buffers_region = dri2_fallback_swap_buffers_region, .post_sub_buffer = dri2_fallback_post_sub_buffer, .copy_buffers = dri2_fallback_copy_buffers, -- 2.10.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] egl/android: implement minimal swap_buffers_with_damage
On Mon, Oct 24, 2016 at 3:34 AM, Eric Engestrom wrote: > On Friday, 2016-10-21 16:07:07 -0500, Rob Herring wrote: >> Since commit 0a606a400fe3 ("egl: add eglSwapBuffersWithDamageKHR"), >> Android has been broken because the function eglSwapBuffersWithDamageKHR >> is provided regardless of the extension being present. Also, the Android >> meta-EGL always advertises the extension regardless of the underlying >> EGL implementation. > > Where is that? I'd like to have a look when I find some time. frameworks/native/opengl/libs/EGL/eglApi.cpp:86 > >> As there doesn't seem to be a simple way >> conditionally make the EGL function ptr NULL, just implement a brain >> dead version for Android EGL. > > Ignoring the rectangles and doing a full swap regardless is indeed > allowed by the spec, so this is: > Reviewed-by: Eric Engestrom Thanks. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] amd/addrlib: limit fastcall/regparm to i386
On Sat, Oct 22, 2016 at 1:08 AM, Jason Ekstrand wrote: > On Fri, Oct 21, 2016 at 10:58 PM, Dave Airlie wrote: >> >> On 22 Oct. 2016 15:51, "Jason Ekstrand" wrote: >> > >> > Wait... Why are we building the AMD driver on ARM? I know AMD has been >> > talking about ARM-based servers, but are they actually strapping GPUs to >> > them? >> >> PCIE on ARM somewhere. > > I suppose so. I don't usually think of ARM devices as having PCIE, but I > guess it's possible... You learn something every day. Pretty much all the server and networking chips have PCIe. Even the mobile chips have PCIe now for WiFi. I'm just build testing ATM, but I have heard that folks are plugging in graphics cards on ARM dev boards. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH mesa] egl/dri2: swap_buffers_with_damage falls back to swap_buffers
On Mon, Oct 24, 2016 at 5:41 PM, Eric Engestrom wrote: > CC: Rob Herring > CC: Rob Clark > Suggested-by: Emil Velikov > Signed-off-by: Eric Engestrom Good, you beat me to it. Reviewed-by: Rob Herring > --- > src/egl/drivers/dri2/egl_dri2_fallbacks.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/src/egl/drivers/dri2/egl_dri2_fallbacks.h > b/src/egl/drivers/dri2/egl_dri2_fallbacks.h > index e769af3..8dad271 100644 > --- a/src/egl/drivers/dri2/egl_dri2_fallbacks.h > +++ b/src/egl/drivers/dri2/egl_dri2_fallbacks.h > @@ -66,7 +66,8 @@ dri2_fallback_swap_buffers_with_damage(_EGLDriver *drv, > _EGLDisplay *dpy, >_EGLSurface *surf, >const EGLint *rects, EGLint n_rects) > { > - return EGL_FALSE; > + struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy); > + return dri2_dpy->vtbl->swap_buffers(drv, dpy, surf); > } > > static inline EGLBoolean > -- > Cheers, > Eric > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC] mesa: drop current draw/read buffer when ctx is released
+Mauro, Chih-Wei On Fri, Oct 28, 2016 at 7:22 AM, Rob Clark wrote: > On Fri, Oct 28, 2016 at 1:24 AM, Tapani Pälli wrote: >> On 10/27/2016 01:48 PM, Rob Clark wrote: >>> >>> On Thu, Oct 27, 2016 at 2:59 AM, Tapani Pälli >>> wrote: On 10/27/2016 12:16 AM, Rob Clark wrote: > > So, not quite sure if this is the *correct* solution, but it is at least > *a* solution to a problem with android wallpaper vs mesa that I've been > debugging. Basically, what happens is: Could you tell more how to trigger this, is this with some particular live wallpaper and has this been working before (regression)? For me at least these default wallpapers have been working ok. >>> >>> Actually, it is the default static wallpaper that is problematic. And >>> IIRC, it has never worked, at least not with any of the gallium >>> drivers (freedreno, virgl, vc4, etc). Live-wallpaper did work, but >>> does not appear to exist in AOSP builds anymore. >>> >>> If this works with i965 on android, I'd be curious how. Or if you're >>> android build had some mesa patches that are not upstream? >> >> >> I can confirm that default wallpaper is working on i965. Our Mesa tree >> currently looks like this: >> >> https://github.com/android-ia/external-mesa >> >> It's now quite a bit behind though because we were dealing with some >> non-graphics issues and are planning to rebase soon. > > I suppose it is possible that it is triggered by something different > that mesa/st does vs dri/i965? Although I find it odd that > dri2_make_current() would drop the reference to the EGLSurface when > unbinding ctx, but _mesa_make_current() would not drop the reference > to the corresponding gl_framebuffer. > > Maybe the classic driver is holding an extra reference to the > EGLSurface so the _eglPutSurface() call in dri2_make_current() does > not actually drop the last refcnt? Which would ensure when the window > surface is created it ends up with a different address.. > > but, I wonder if you could try w/ Rob Herring's tree.. this is what we > are using for the upstream kernel + AOSP builds[1]: > > https://github.com/robherring/mesa/commits/android-m > > I guess in theory we should both need the same patches on top of > mesa.. although also I guess we should also just try to get to the > point where we can both use upstream mesa tree directly. Looks like we have some similar patches for gralloc headers and using render node (since I picked up Tomasz's patches). > [1] see: > https://github.com/robherring/generic_device/wiki/KConfig-based-Multi-platform-Android-Device-(and-Mesa-graphics) > > Btw, I guess in theory the qemu/x86 build from rob's generic_device > stuff should also work on real hw, so I think we should be able to > test exact same build that is failing with gallium/virgl with i965. > But I don't have any real hw for that. Mauro or Chih-Wei should be able to answer this (being do static wallpapers work in i965?). Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC] mesa: drop current draw/read buffer when ctx is released
On Fri, Oct 28, 2016 at 9:14 AM, Emil Velikov wrote: > On 28 October 2016 at 13:22, Rob Clark wrote: >> On Fri, Oct 28, 2016 at 1:24 AM, Tapani Pälli wrote: >>> On 10/27/2016 01:48 PM, Rob Clark wrote: On Thu, Oct 27, 2016 at 2:59 AM, Tapani Pälli wrote: > > On 10/27/2016 12:16 AM, Rob Clark wrote: >> >> So, not quite sure if this is the *correct* solution, but it is at least >> *a* solution to a problem with android wallpaper vs mesa that I've been >> debugging. Basically, what happens is: > > > Could you tell more how to trigger this, is this with some particular > live > wallpaper and has this been working before (regression)? For me at least > these default wallpapers have been working ok. Actually, it is the default static wallpaper that is problematic. And IIRC, it has never worked, at least not with any of the gallium drivers (freedreno, virgl, vc4, etc). Live-wallpaper did work, but does not appear to exist in AOSP builds anymore. If this works with i965 on android, I'd be curious how. Or if you're android build had some mesa patches that are not upstream? >>> >>> >>> I can confirm that default wallpaper is working on i965. Our Mesa tree >>> currently looks like this: >>> >>> https://github.com/android-ia/external-mesa >>> >>> It's now quite a bit behind though because we were dealing with some >>> non-graphics issues and are planning to rebase soon. >> >> I suppose it is possible that it is triggered by something different >> that mesa/st does vs dri/i965? Although I find it odd that >> dri2_make_current() would drop the reference to the EGLSurface when >> unbinding ctx, but _mesa_make_current() would not drop the reference >> to the corresponding gl_framebuffer. >> > Precisely my line of thinking as well. Both egl and glx drop the > reference to the objects on !newCtx. > > From a quick look the only place where we unref. > WinSysDrawBuffer/WinSysReadBuffer is in _mesa_free_context_data which > happens on ctx teardown. Which sounds incomplete - so I'm a bit > curious why/how that i965 works fine. > >> Maybe the classic driver is holding an extra reference to the >> EGLSurface so the _eglPutSurface() call in dri2_make_current() does >> not actually drop the last refcnt? Which would ensure when the window >> surface is created it ends up with a different address.. >> >> but, I wonder if you could try w/ Rob Herring's tree.. this is what we >> are using for the upstream kernel + AOSP builds[1]: >> >> https://github.com/robherring/mesa/commits/android-m >> >> I guess in theory we should both need the same patches on top of >> mesa.. although also I guess we should also just try to get to the >> point where we can both use upstream mesa tree directly. >> > Indeed. Skimming through the android-ia log - can borrow > ENABLE_FLINK_SUPPORT and let drm/gbm gralloc have a static inline > helpers gralloc_drm_get_gem_handle/gralloc_drm_get_prime_fd. > Thus everyone can polish their gralloc (if interested?) while still > having something that works across the board. With similar direction > on the GRALLOC_MODULE_PERFORM_GET_DRM_FD front ? It's all related. If we use dma-buf fds, then we use the render node instead of card node and don't need private gralloc access. We just assume if the buffer handle has an fd that the 1st fd is the dma-buf. I've been assuming that Tomasz would respin these patches. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] amd/addrlib: limit fastcall/regparm to GCC i386
On Wed, Nov 2, 2016 at 10:32 AM, Emil Velikov wrote: > From: Emil Velikov > > The use of regparm causes an error on arm/arm64 builds with clang. > fastcall is allowed, but still throws a warning. As both options only > have effect on 32-bit x86 builds, limit them to that case. > > v2: keep the __i386__ within GCC (Nicolai) > > Cc: 13.0 > Cc: Rob Herring > Cc: Nicolai Hähnle > Signed-off-by: Emil Velikov Thanks for respinning this for me. Reviewed-by: Rob Herring Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] amd/addrlib: limit fastcall/regparm to GCC i386
On Wed, Nov 2, 2016 at 10:42 PM, Rob Herring wrote: > On Wed, Nov 2, 2016 at 10:32 AM, Emil Velikov > wrote: >> From: Emil Velikov >> >> The use of regparm causes an error on arm/arm64 builds with clang. >> fastcall is allowed, but still throws a warning. As both options only >> have effect on 32-bit x86 builds, limit them to that case. >> >> v2: keep the __i386__ within GCC (Nicolai) >> >> Cc: 13.0 >> Cc: Rob Herring >> Cc: Nicolai Hähnle >> Signed-off-by: Emil Velikov > > Thanks for respinning this for me. > > Reviewed-by: Rob Herring Any reason this hasn't been applied yet? My Android CI job is still failing on this. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] Fwd: errors for mesa master Android build 554
This commit breaks the build for Android. Looks like a prototype is missing and LLVM is stricter. Rob commit 1a21d21580965eff751414d140b3c1762eb3 Author: Christian Gmeiner Date: Thu Nov 3 15:25:21 2016 +0100 dri: make use of dri_get_extensions_name(..) helper Signed-off-by: Christian Gmeiner Reviewed-by: Emil Velikov -- Forwarded message -- From: Date: Tue, Nov 15, 2016 at 11:02 AM Subject: errors for mesa master Android build 554 To: rob.herr...@linaro.org Build URL: https://ci.linaro.org/jenkins/job/robher-aosp/554/ Full log: https://ci.linaro.org/jenkins/job/robher-aosp/554/consoleText Parsed warnings/errors: https://ci.linaro.org/jenkins/job/robher-aosp/554/parsed_console ERRORS: W: GPG error: http://ppa.launchpad.net utopic Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F1FCBACA7BE1F97B + sudo apt-get install -y gcc-4.9-multilib bison git gperf libxml2-utils python-mako zip time python-pycurl genisoimage patch mtools libfdt-dev python-mako gettext openjdk-8-jdk Reading package lists... external/mesa3d/src/gbm/backends/dri/gbm_dri.c:366:24: error: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Werror,-Wint-conversion] get_extensions_name = dri_get_extensions_name(dri->base.driver_name); ^ ~~ external/mesa3d/src/egl/drivers/dri2/egl_dri2.c:517:24: error: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Werror,-Wint-conversion] get_extensions_name = dri_get_extensions_name(dri2_dpy->driver_name); ^ ~~ external/mesa3d/src/egl/drivers/dri2/egl_dri2.c:517:26: error: implicit declaration of function 'dri_get_extensions_name' is invalid in C99 [-Werror,-Wimplicit-function-declaration] get_extensions_name = dri_get_extensions_name(dri2_dpy->driver_name); ^ external/mesa3d/src/egl/drivers/dri2/egl_dri2.c:517:24: error: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Werror,-Wint-conversion] get_extensions_name = dri_get_extensions_name(dri2_dpy->driver_name); ^ ~~ external/mesa3d/src/gbm/backends/dri/gbm_dri.c:366:26: error: implicit declaration of function 'dri_get_extensions_name' is invalid in C99 [-Werror,-Wimplicit-function-declaration] get_extensions_name = dri_get_extensions_name(dri->base.driver_name); ^ external/mesa3d/src/gbm/backends/dri/gbm_dri.c:366:24: error: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Werror,-Wint-conversion] get_extensions_name = dri_get_extensions_name(dri->base.driver_name); ^ ~~ external/mesa3d/src/egl/drivers/dri2/egl_dri2.c:517:24: error: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Werror,-Wint-conversion] get_extensions_name = dri_get_extensions_name(dri2_dpy->driver_name); ^ ~~ external/mesa3d/src/gbm/backends/dri/gbm_dri.c:366:24: error: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Werror,-Wint-conversion] get_extensions_name = dri_get_extensions_name(dri->base.driver_name); ^ ~~ external/mesa3d/src/egl/drivers/dri2/egl_dri2.c:517:26: error: implicit declaration of function 'dri_get_extensions_name' is invalid in C99 [-Werror,-Wimplicit-function-declaration] get_extensions_name = dri_get_extensions_name(dri2_dpy->driver_name); ^ external/mesa3d/src/egl/drivers/dri2/egl_dri2.c:517:24: error: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Werror,-Wint-conversion] get_extensions_name = dri_get_extensions_name(dri2_dpy->driver_name); ^ ~~ external/mesa3d/src/gbm/backends/dri/gbm_dri.c:366:26: error: implicit declaration of function 'dri_get_extensions_name' is invalid in C99 [-Werror,-Wimplicit-function-declaration] get_extensions_name = dri_get_extensions_name(dri->base.driver_name); ^ external/mesa3d/src/gbm/backends/dri/gbm_dri.c:366:24: error: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Werror,-Wint-conversion] get_extensions_name = dri_get_extensions_name(dri->base.driver_name); ^ ~~ ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] EGL/android: pbuffer implementation.
On Mon, Nov 21, 2016 at 8:15 AM, Emil Velikov wrote: > On 21 November 2016 at 07:23, Tomasz Figa wrote: >> Hi, >> >> On Wed, Nov 16, 2016 at 11:11 AM, Liu Zhiquan wrote: >>> mesa android path didn't support pbuffer, so add pbuffer support to >>> fix most deqp and cts pbuffer test cases fail; >>> add single buffer config to support pbuffer, and create image for >>> pbuffer when pbuffer type is front surface. >>> The EGL 1.5 spec states that pbuffers have a back buffer but no front >>> buffer, single-buffered surfaces with no front buffer confuse Mesa; >>> so we deviate from the spec, following the precedent of Mesa's >>> EGL X11 platform. >>> >>> Test status: android CTS EGL pbuffer test can run without native crash. >>> test:[DEQP,EGL]all deqp pbuffer case passed. >>> >>> V3: update commit message and code review changes. >>> >>> Signed-off-by: Liu Zhiquan >>> Signed-off-by: Kalyan Kondapally >>> --- >>> src/egl/drivers/dri2/egl_dri2.h | 3 +- >>> src/egl/drivers/dri2/platform_android.c | 98 >>> + >>> 2 files changed, 78 insertions(+), 23 deletions(-) >>> >> >> Looks like this patch has already landed, but please let me try to >> confirm some things here anyway. Would you mind keeping me on CC for >> any future patches for the EGL/Android module? ( > > >> I believe >> scripts/get_reviewer.pl should already include me on the list of >> suggested reviewers, similarly for Rob Herring, who did a great job >> before helping us with testing on platforms other than i915.) >> > I'll add you and update the documentation to reference the script. > > Rob H let me know if you'd like to be in there as well which files > (platform_egl.c, Android build and/or other) and which email you'd > prefer. Yes, please. Use my kernel.org address. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 07/10] egl/android: Make drm_gralloc headers optional
On Fri, Jul 15, 2016 at 2:53 AM, Tomasz Figa wrote: > We can support render nodes alone without any private headers, so let's > make support for control nodes depend on presence of private drm_gralloc > headers. This is a complicated change for what amounts to just needing the flink name out of the gralloc handle. You don't have the dependency for prime fds because I assumed it is the first fd in the gralloc handle (as I was trying to avoid the header dependency). We could do the same for flink names. Whether we want to make support from control nodes ifdef'ed should be its own option not implied from having headers or not. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 08/10] egl/android: Make get_fourcc() accept HAL formats
On Fri, Jul 15, 2016 at 2:53 AM, Tomasz Figa wrote: > There are DRI_IMAGE_FOURCC macros, for which there are no corresponding > DRI_IMAGE_FORMAT macros. To support such formats we need to make the > lookup function take the native format directly. As a side effect, it > simplifies all existing calls to this function, because they all called > get_format() first to convert from native to DRI_IMAGE_FORMAT. > > Signed-off-by: Tomasz Figa > --- > src/egl/drivers/dri2/platform_android.c | 22 +- > 1 file changed, 13 insertions(+), 9 deletions(-) > > diff --git a/src/egl/drivers/dri2/platform_android.c > b/src/egl/drivers/dri2/platform_android.c > index 4473400..26d7b35 100644 > --- a/src/egl/drivers/dri2/platform_android.c > +++ b/src/egl/drivers/dri2/platform_android.c > @@ -69,18 +69,20 @@ get_format_bpp(int native) > } > > /* createImageFromFds requires fourcc format */ > -static int get_fourcc(int format) > +static int get_fourcc(int native) > { > - switch(format) { > - case __DRI_IMAGE_FORMAT_RGB565: return __DRI_IMAGE_FOURCC_RGB565; > - case __DRI_IMAGE_FORMAT_ARGB: return __DRI_IMAGE_FOURCC_ARGB; > - case __DRI_IMAGE_FORMAT_XRGB: return __DRI_IMAGE_FOURCC_XRGB; > - case __DRI_IMAGE_FORMAT_ABGR: return __DRI_IMAGE_FOURCC_ABGR; > - case __DRI_IMAGE_FORMAT_XBGR: return __DRI_IMAGE_FOURCC_XBGR; > + switch (native) { > + case HAL_PIXEL_FORMAT_RGB_565: return __DRI_IMAGE_FOURCC_RGB565; > + case HAL_PIXEL_FORMAT_BGRA_: return __DRI_IMAGE_FOURCC_ARGB; > + case HAL_PIXEL_FORMAT_RGBA_: return __DRI_IMAGE_FOURCC_ABGR; > + case HAL_PIXEL_FORMAT_RGBX_: return __DRI_IMAGE_FOURCC_XBGR; > + default: > + _eglLog(_EGL_WARNING, "unsupported native buffer format 0x%x", native); > } > return -1; > } > > +#ifdef HAS_GRALLOC_DRM_HEADERS No need to ifdef this. The compiler will drop it. > static int get_format(int format) > { > switch (format) { > @@ -95,6 +97,8 @@ static int get_format(int format) > } > return -1; > } > +#endif > + > static int > get_native_buffer_fd(struct ANativeWindowBuffer *buf) > { > @@ -435,7 +439,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) >return -1; > } > > - fourcc = get_fourcc(get_format(dri2_surf->buffer->format)); > + fourcc = get_fourcc(dri2_surf->buffer->format); > > pitch = dri2_surf->buffer->stride * >get_format_bpp(dri2_surf->buffer->format); > @@ -525,7 +529,7 @@ droid_create_image_from_prime_fd(_EGLDisplay *disp, > _EGLContext *ctx, > if (fd < 0) >return NULL; > > - const int fourcc = get_fourcc(get_format(buf->format)); > + const int fourcc = get_fourcc(buf->format); > const int pitch = buf->stride * get_format_bpp(buf->format); > > const EGLint attr_list[14] = { > -- > 2.8.0.rc3.226.g39d4020 > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] virgl: add exported dmabuf to BO hash table
On Fri, Jun 17, 2016 at 5:25 PM, Rob Herring wrote: > Exported dmabufs can get imported by the same process, but the handle was > not getting added to the hash table on export. Add the handle to the hash > table on export. Ping. Dave, can you please apply. Rob > > Cc: Dave Airlie > Signed-off-by: Rob Herring > --- > src/gallium/winsys/virgl/drm/virgl_drm_winsys.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c > b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c > index cbd416c..8336a33 100644 > --- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c > +++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c > @@ -486,6 +486,9 @@ static boolean > virgl_drm_winsys_resource_get_handle(struct virgl_winsys *qws, > } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { >if (drmPrimeHandleToFD(qdws->fd, res->bo_handle, DRM_CLOEXEC, > (int*)&whandle->handle)) > return FALSE; > + pipe_mutex_lock(qdws->bo_handles_mutex); > + util_hash_table_set(qdws->bo_handles, (void > *)(uintptr_t)res->bo_handle, res); > + pipe_mutex_unlock(qdws->bo_handles_mutex); > } > whandle->stride = stride; > return TRUE; > -- > 2.7.4 > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 00/10] egl/android: Improve the Android EGL backend
On Fri, Jul 15, 2016 at 2:53 AM, Tomasz Figa wrote: > Hi, > > This series is a collection of various fixes and extensions we came up > with during our attempt to use Mesa for Android. > > Fixes included in this series: > - added mandatory EGL_MAX_PBUFFER_WIDTH and _HEIGHT attributes to EGL >configs, > - fixed multiple issues with handling pbuffers in the backend, > - found and fixed a DRI image leak, > - made the implementation of DRI image loader .getBuffers callback >conform better to the extension semantics. > > New features added by this series: > - possibility to build the Android EGL platform without drm_gralloc >headers, > - support for creating EGL images from Android native buffers with >YV12 pixel format (prime-only), > - fallback to kms_swrast driver when no hardware driver can be loaded >but there is still some usable DRI node present in the system. > - more logging in case of errors to help diagnosing problems. > > Testing was done using classic i965 (gen 8) and gallium softpipe drivers > on an internal build of Android, based on gralloc backed by a DRM render > node and sharing buffers by PRIME FDs. I've tested out patches 1-6 with virgl and I don't get anything displayed. I get this message: EGL-DRI2: Front buffer is not supported for window surfaces That's as far as I investigated. I'll look into it some more tomorrow. Patches 7-10 wouldn't apply. Do you have a git tree with the series? Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 10/10] egl/android: Add fallback to kms_swrast driver
On Fri, Jul 15, 2016 at 2:53 AM, Tomasz Figa wrote: > If no hardware driver is present, it is possible to fall back to > the kms_swrast driver with any DRI node that supports dumb GEM create > and mmap IOCTLs with softpipe/llvmpipe drivers. This patch makes the > Android EGL platform code retry probe with kms_swrast if hardware-only > probe fails. Presumably, you need a gralloc that supports this too? It would be nice to have access to it to reproduce this setup. [...] > #define DRM_RENDER_DEV_NAME "%s/renderD%d" > > static int > -droid_open_device(_EGLDisplay *dpy) > +droid_open_device(_EGLDisplay *dpy, int swrast) > { > struct dri2_egl_display *dri2_dpy = dpy->DriverData; > const int limit = 64; > @@ -933,7 +936,7 @@ droid_open_device(_EGLDisplay *dpy) >if (fd < 0) > continue; > > - if (!droid_probe_device(dpy, fd)) > + if (!droid_probe_device(dpy, fd, swrast)) This only gets here if a render node is present and successfully opened. I would think in the sw rendering case, we want this to work when there's only a card node present. Furthermore, you can't do dumb allocs on a render node, so I don't see how this can work at all. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 10/10] egl/android: Add fallback to kms_swrast driver
On Wed, Jul 20, 2016 at 12:53 AM, Tomasz Figa wrote: > On Wed, Jul 20, 2016 at 7:40 AM, Rob Herring wrote: >> On Fri, Jul 15, 2016 at 2:53 AM, Tomasz Figa wrote: >>> If no hardware driver is present, it is possible to fall back to >>> the kms_swrast driver with any DRI node that supports dumb GEM create >>> and mmap IOCTLs with softpipe/llvmpipe drivers. This patch makes the >>> Android EGL platform code retry probe with kms_swrast if hardware-only >>> probe fails. >> >> Presumably, you need a gralloc that supports this too? It would be >> nice to have access to it to reproduce this setup. > > Our use case is running the system in Qemu with vgem driver, so our > gralloc has a backend for vgem. However it should work with any > available card or render node (more about render nodes below), no > special support in gralloc really needed. It's just using kms_swrast > instead of the native driver. Okay, interesting. I've not really looked at vgem. GBM also has a path for allocating dumb buffers which I was intending to try and get working with s/w rendering. Sadly, I've found s/w rendering harder to get working than h/w rendering. >> [...] >> >>> #define DRM_RENDER_DEV_NAME "%s/renderD%d" >>> >>> static int >>> -droid_open_device(_EGLDisplay *dpy) >>> +droid_open_device(_EGLDisplay *dpy, int swrast) >>> { >>> struct dri2_egl_display *dri2_dpy = dpy->DriverData; >>> const int limit = 64; >>> @@ -933,7 +936,7 @@ droid_open_device(_EGLDisplay *dpy) >>>if (fd < 0) >>> continue; >>> >>> - if (!droid_probe_device(dpy, fd)) >>> + if (!droid_probe_device(dpy, fd, swrast)) >> >> This only gets here if a render node is present and successfully >> opened. > > This is the case when HAS_GRALLOC_HEADERS is not defined, which means > only render nodes are supported. If you look at the other case, it > will use whatever FD was provided by gralloc using that private > perform call. > >> I would think in the sw rendering case, we want this to work >> when there's only a card node present. Furthermore, you can't do dumb >> allocs on a render node, so I don't see how this can work at all. > > This is only because the dumb alloc ioctl is not allowed, but that's > the only thing preventing it from working. We had similar restriction > put on mmap, but now everyone can just mmap the PRIME FD directly. We > actually have a patch allowing dumb alloc and mmap ioctls for render > nodes in our tree, because it makes things like swrast fallback much, > much easier and doesn't seem to be harmful at all. It might be worth > discussing this again on dri-devel mailing list. Yes, bypassing permissions is an easy hack, but I believe what's in place is by design and you are unlikely to change that. The answer always seems to be don't use dumb buffers... Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 00/10] egl/android: Improve the Android EGL backend
On Mon, Jul 18, 2016 at 11:29 PM, Tomasz Figa wrote: > On Tue, Jul 19, 2016 at 12:35 PM, Rob Herring wrote: >> On Fri, Jul 15, 2016 at 2:53 AM, Tomasz Figa wrote: >>> Hi, >>> >>> This series is a collection of various fixes and extensions we came up >>> with during our attempt to use Mesa for Android. >>> >>> Fixes included in this series: >>> - added mandatory EGL_MAX_PBUFFER_WIDTH and _HEIGHT attributes to EGL >>>configs, >>> - fixed multiple issues with handling pbuffers in the backend, >>> - found and fixed a DRI image leak, >>> - made the implementation of DRI image loader .getBuffers callback >>>conform better to the extension semantics. >>> >>> New features added by this series: >>> - possibility to build the Android EGL platform without drm_gralloc >>>headers, >>> - support for creating EGL images from Android native buffers with >>>YV12 pixel format (prime-only), >>> - fallback to kms_swrast driver when no hardware driver can be loaded >>>but there is still some usable DRI node present in the system. >>> - more logging in case of errors to help diagnosing problems. >>> >>> Testing was done using classic i965 (gen 8) and gallium softpipe drivers >>> on an internal build of Android, based on gralloc backed by a DRM render >>> node and sharing buffers by PRIME FDs. >> >> I've tested out patches 1-6 with virgl and I don't get anything >> displayed. I get this message: >> >> EGL-DRI2: Front buffer is not supported for window surfaces >> >> That's as far as I investigated. I'll look into it some more tomorrow. > > Thanks a lot for testing! > > It looks like somehow your driver (or gallium) is triggering a call to > DRI image loader getBuffers() callback with front buffer bit set in > the image mask, but window surfaces on Android provide only back > buffers. I've debugged this a bit more, but still am not sure what's going on. Reverting #6 fixes things though. I don't see how a specific driver would cause the issue here. Here's the call stack for where the warning is printed: 07-19 21:30:37.750 2153 2153 F DEBUG : #00 pc fc8d /system/lib64/egl/libGLES_mesa.so (droid_image_get_buffers+77) 07-19 21:30:37.750 2153 2153 F DEBUG : #01 pc 00319554 /system/lib64/dri/gallium_dri.so (dri2_allocate_textures+660) 07-19 21:30:37.750 2153 2153 F DEBUG : #02 pc 003157c6 /system/lib64/dri/gallium_dri.so (dri_st_framebuffer_validate+566) 07-19 21:30:37.750 2153 2153 F DEBUG : #03 pc 004eadf3 /system/lib64/dri/gallium_dri.so (st_framebuffer_validate+115) 07-19 21:30:37.750 2153 2153 F DEBUG : #04 pc 004ead4e /system/lib64/dri/gallium_dri.so (st_manager_validate_framebuffers+78) 07-19 21:30:37.750 2153 2153 F DEBUG : #05 pc 004c7450 /system/lib64/dri/gallium_dri.so (st_validate_state+352) 07-19 21:30:37.750 2153 2153 F DEBUG : #06 pc 004e6d5c /system/lib64/dri/gallium_dri.so (st_draw_vbo+172) 07-19 21:30:37.750 2153 2153 F DEBUG : #07 pc 004acc31 /system/lib64/dri/gallium_dri.so (vbo_draw_arrays+289) 07-19 21:30:37.750 2153 2153 F DEBUG : #08 pc 00044dce /system/lib64/libsurfaceflinger.so (android::GLES20RenderEngine::drawMesh(android::Mesh const&)+254) 07-19 21:30:37.750 2153 2153 F DEBUG : #09 pc 00025af9 /system/lib64/libsurfaceflinger.so (android::Layer::drawWithOpenGL(android::sp const&, android::Region const&, bool) const+329) > My understanding of the semantics was that the callback should deny > such requests, so that's how I implemented it. However it isn't really > well documented, so potentially it should only provide buffers that > are available and ignore the rest without bailing out. Could someone > more familiar with this extension comment on this? > >> >> Patches 7-10 wouldn't apply. Do you have a git tree with the series? > > Hmm, I rebased them on Mesa master just before sending. Let me try to > create a sandbox branch in our chromium tree. Turns out to be something in my tree... Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 06/10] egl/android: Fix support for pbuffers
On Fri, Jul 15, 2016 at 2:53 AM, Tomasz Figa wrote: > From: Nicolas Boichat > > Existing image loader code supports creating images only for window > surfaces. Moreover droid_create_surface() passes wrong surface type to > dri2_get_dri_config(), resulting in incorrect configs being returned for > pbuffers. This patch fixes these issues. > > In addition, the config generation code is fixed to include single > buffered contexts required for pbuffers and make sure that generated > configs support only surfaces which can handle their supported buffering > modes. > > Signed-off-by: Nicolas Boichat > Signed-off-by: Tomasz Figa > --- > src/egl/drivers/dri2/egl_dri2.h | 1 + > src/egl/drivers/dri2/platform_android.c | 61 > +++-- > 2 files changed, 51 insertions(+), 11 deletions(-) > > diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h > index 317de06..3ffc177 100644 > --- a/src/egl/drivers/dri2/egl_dri2.h > +++ b/src/egl/drivers/dri2/egl_dri2.h > @@ -287,6 +287,7 @@ struct dri2_egl_surface > struct ANativeWindow *window; > struct ANativeWindowBuffer *buffer; > __DRIimage *dri_image; > + __DRIimage *dri_front_image; > > /* EGL-owned buffers */ > __DRIbuffer *local_buffers[__DRI_BUFFER_COUNT]; > diff --git a/src/egl/drivers/dri2/platform_android.c > b/src/egl/drivers/dri2/platform_android.c > index 7495445..0f707dd 100644 > --- a/src/egl/drivers/dri2/platform_android.c > +++ b/src/egl/drivers/dri2/platform_android.c > @@ -286,7 +286,7 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, > EGLint type, >window->query(window, NATIVE_WINDOW_HEIGHT, &dri2_surf->base.Height); > } > > - config = dri2_get_dri_config(dri2_conf, EGL_WINDOW_BIT, > + config = dri2_get_dri_config(dri2_conf, type, > dri2_surf->base.GLColorspace); > if (!config) >goto cleanup_surface; > @@ -347,6 +347,9 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, > _EGLSurface *surf) >dri2_surf->window->common.decRef(&dri2_surf->window->common); > } > > + if (dri2_surf->dri_front_image) > + dri2_dpy->image->destroyImage(dri2_surf->dri_front_image); > + > (*dri2_dpy->core->destroyDrawable)(dri2_surf->dri_drawable); > > free(dri2_surf); > @@ -378,6 +381,29 @@ update_buffers(struct dri2_egl_surface *dri2_surf) > } > > static int > +get_front_bo(struct dri2_egl_surface *dri2_surf, unsigned int format) > +{ > + struct dri2_egl_display *dri2_dpy = > + dri2_egl_display(dri2_surf->base.Resource.Display); > + > + if (dri2_surf->base.Type == EGL_WINDOW_BIT) { > + _eglLog(_EGL_WARNING, "Front buffer is not supported for window > surfaces"); > + return -1; > + } > + > + if (dri2_surf->dri_front_image) > + return 0; > + > + dri2_surf->dri_front_image = > + dri2_dpy->image->createImage(dri2_dpy->dri_screen, > + dri2_surf->base.Width, > + dri2_surf->base.Height, > + format, 0, dri2_surf); > + > + return dri2_surf->dri_front_image ? 0 : -1; > +} > + > +static int > get_back_bo(struct dri2_egl_surface *dri2_surf) > { > struct dri2_egl_display *dri2_dpy = > @@ -385,6 +411,11 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) > int fourcc, pitch; > int offset = 0, fd; > > + if (dri2_surf->base.Type != EGL_WINDOW_BIT) { > + _eglLog(_EGL_WARNING, "Back buffer is not supported for pbuffer > surfaces"); > + return -1; > + } > + > if (dri2_surf->dri_image) >return 0; > > @@ -440,8 +471,11 @@ droid_image_get_buffers(__DRIdrawable *driDrawable, >return 0; > > if (buffer_mask & __DRI_IMAGE_BUFFER_FRONT) { > - _eglLog(_EGL_WARNING, "Front buffer is not supported for window > surfaces"); > - return 0; > + if (get_front_bo(dri2_surf, format) < 0) > + return 0; > + > + images->front = dri2_surf->dri_front_image; > + images->image_mask |= __DRI_IMAGE_BUFFER_FRONT; > } > > if (buffer_mask & __DRI_IMAGE_BUFFER_BACK) { > @@ -698,14 +732,6 @@ droid_add_configs_for_visuals(_EGLDriver *drv, > _EGLDisplay *dpy) >for (j = 0; dri2_dpy->driver_configs[j]; j++) { > const EGLint surface_type = EGL_WINDOW_BIT | EGL_PBUFFER_BIT; > struct dri2_egl_config *dri2_conf; > - unsigned int double_buffered = 0; > - > - dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[j], > -__DRI_ATTRIB_DOUBLE_BUFFER, &double_buffered); > - > - /* support only double buffered configs */ > - if (!double_buffered) > -continue; > > dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[j], > count + 1, surface_type, config_attrs, visuals[i].rgba_masks); > @@ -728,6 +754,19 @@ droid_add_configs_for_visuals(_EGLDriver *drv, > _EGLDisplay *dpy) >/* there is no
[Mesa-dev] [PATCH 00/11] *** S
*** BLURB HERE *** Rob Herring (11): gallium: move pipe_screen destroy into pipe-loader pipe-loader-drm: protect create_screen() calls with a mutex gallium: add common pipe_screen reference counting functions pipe-loader-drm: use pipe_screen_unreference to destroy screen nouveau: use common screen ref counting freedreno: use common screen ref counting amdgpu: use common screen ref counting radeon: use common screen ref counting vmwgfx: use common screen ref counting vc4: use common screen ref counting virgl: use common screen ref counting src/gallium/auxiliary/Makefile.sources | 2 + src/gallium/auxiliary/pipe-loader/pipe_loader.h| 1 + .../auxiliary/pipe-loader/pipe_loader_drm.c| 15 ++- src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 6 ++ src/gallium/auxiliary/util/u_screen.c | 114 + src/gallium/auxiliary/util/u_screen.h | 32 ++ src/gallium/auxiliary/vl/vl_winsys_dri.c | 1 - src/gallium/auxiliary/vl/vl_winsys_dri3.c | 1 - src/gallium/auxiliary/vl/vl_winsys_drm.c | 1 - src/gallium/drivers/freedreno/freedreno_screen.c | 1 - src/gallium/drivers/freedreno/freedreno_screen.h | 10 -- src/gallium/drivers/nouveau/nouveau_screen.c | 6 -- src/gallium/drivers/nouveau/nouveau_screen.h | 4 - src/gallium/drivers/nouveau/nv30/nv30_screen.c | 3 - src/gallium/drivers/nouveau/nv50/nv50_screen.c | 3 - src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 3 - src/gallium/drivers/r300/r300_screen.c | 3 - src/gallium/drivers/r600/r600_pipe.c | 6 -- src/gallium/drivers/radeon/radeon_winsys.h | 8 -- src/gallium/drivers/radeonsi/si_pipe.c | 6 -- src/gallium/include/pipe/p_screen.h| 3 + src/gallium/state_trackers/clover/core/device.cpp | 4 +- src/gallium/state_trackers/dri/dri_screen.c| 3 - src/gallium/state_trackers/xa/xa_tracker.c | 2 - src/gallium/tests/trivial/compute.c| 1 - src/gallium/tests/trivial/quad-tex.c | 1 - src/gallium/tests/trivial/tri.c| 1 - src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 45 ++-- src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h | 1 - .../winsys/freedreno/drm/freedreno_drm_winsys.c| 94 ++--- .../winsys/nouveau/drm/nouveau_drm_winsys.c| 89 ++-- src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 84 ++- src/gallium/winsys/svga/drm/vmw_screen.c | 51 ++--- src/gallium/winsys/svga/drm/vmw_screen.h | 6 -- src/gallium/winsys/vc4/drm/vc4_drm_winsys.c| 9 +- src/gallium/winsys/virgl/drm/virgl_drm_winsys.c| 86 ++-- 36 files changed, 221 insertions(+), 485 deletions(-) create mode 100644 src/gallium/auxiliary/util/u_screen.c create mode 100644 src/gallium/auxiliary/util/u_screen.h -- 2.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 01/11] gallium: move pipe_screen destroy into pipe-loader
In preparation to add reference counting of pipe_screen in the pipe-loader, pipe_loader_release needs to destroy the pipe_screen instead of state trackers. Signed-off-by: Rob Herring Cc: Emil Velikov --- src/gallium/auxiliary/pipe-loader/pipe_loader.h | 1 + src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 9 - src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 6 ++ src/gallium/auxiliary/vl/vl_winsys_dri.c| 1 - src/gallium/auxiliary/vl/vl_winsys_dri3.c | 1 - src/gallium/auxiliary/vl/vl_winsys_drm.c| 1 - src/gallium/state_trackers/clover/core/device.cpp | 4 +--- src/gallium/state_trackers/dri/dri_screen.c | 3 --- src/gallium/state_trackers/xa/xa_tracker.c | 2 -- src/gallium/tests/trivial/compute.c | 1 - src/gallium/tests/trivial/quad-tex.c| 1 - src/gallium/tests/trivial/tri.c | 1 - 12 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h b/src/gallium/auxiliary/pipe-loader/pipe_loader.h index 690d088..25cd4d1 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h @@ -65,6 +65,7 @@ struct pipe_loader_device { char *driver_name; const struct pipe_loader_ops *ops; + struct pipe_screen *pscreen; }; /** diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c index 994a284..7bdd2ec 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c @@ -39,6 +39,7 @@ #include "target-helpers/drm_helper_public.h" #include "state_tracker/drm_driver.h" #include "pipe_loader_priv.h" +#include "pipe/p_screen.h" #include "util/u_memory.h" #include "util/u_dl.h" @@ -269,6 +270,9 @@ static void pipe_loader_drm_release(struct pipe_loader_device **dev) { struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(*dev); + struct pipe_screen *pscreen = ddev->base.pscreen; + + pscreen->destroy(pscreen); #ifndef GALLIUM_STATIC_TARGETS if (ddev->lib) @@ -297,8 +301,11 @@ static struct pipe_screen * pipe_loader_drm_create_screen(struct pipe_loader_device *dev) { struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev); + struct pipe_screen *pscreen; - return ddev->dd->create_screen(ddev->fd); + pscreen = ddev->dd->create_screen(ddev->fd); + ddev->base.pscreen = pscreen; + return pscreen; } static const struct pipe_loader_ops pipe_loader_drm_ops = { diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c index e7fa974..ce5c2b3 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c @@ -27,6 +27,7 @@ #include "pipe_loader_priv.h" +#include "pipe/p_screen.h" #include "util/u_memory.h" #include "util/u_dl.h" #include "sw/dri/dri_sw_winsys.h" @@ -271,6 +272,9 @@ static void pipe_loader_sw_release(struct pipe_loader_device **dev) { struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(*dev); + struct pipe_screen *pscreen = sdev->base.pscreen; + + pscreen->destroy(pscreen); #ifndef GALLIUM_STATIC_TARGETS if (sdev->lib) @@ -301,6 +305,8 @@ pipe_loader_sw_create_screen(struct pipe_loader_device *dev) if (!screen) sdev->ws->destroy(sdev->ws); + sdev->base.pscreen = screen; + return screen; } diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c index 9ecc216..db90c54 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_dri.c +++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c @@ -461,7 +461,6 @@ vl_dri2_screen_destroy(struct vl_screen *vscreen) } vl_dri2_destroy_drawable(scrn); - scrn->base.pscreen->destroy(scrn->base.pscreen); pipe_loader_release(&scrn->base.dev, 1); FREE(scrn); } diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c index 493e645..c8c0198 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c +++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c @@ -611,7 +611,6 @@ vl_dri3_screen_destroy(struct vl_screen *vscreen) if (scrn->special_event) xcb_unregister_for_special_event(scrn->conn, scrn->special_event); - scrn->base.pscreen->destroy(scrn->base.pscreen); pipe_loader_release(&scrn->base.dev, 1); FREE(scrn); diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c b/src/gallium/auxiliary/vl/vl_winsys_drm.c index 6a759ae..aa690a2 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_drm.c +++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c @@ -80,7 +80,6 @@ vl_drm_screen_destroy(struct vl_screen
[Mesa-dev] [PATCH 03/11] gallium: add common pipe_screen reference counting functions
In order to prevent multiple pipe_screens being created in the same process, lookup of the DRM FD and reference counting of the pipe_screen are needed. Several implementations of this exist in various gallium drivers/winsys already. This creates a common version which is opt-in for winsys implementations. Signed-off-by: Rob Herring --- src/gallium/auxiliary/Makefile.sources | 2 + src/gallium/auxiliary/util/u_screen.c | 114 + src/gallium/auxiliary/util/u_screen.h | 32 + src/gallium/include/pipe/p_screen.h| 3 + 4 files changed, 151 insertions(+) create mode 100644 src/gallium/auxiliary/util/u_screen.c create mode 100644 src/gallium/auxiliary/util/u_screen.h diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index e0311bf..197ed36 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -284,6 +284,8 @@ C_SOURCES := \ util/u_ringbuffer.h \ util/u_sampler.c \ util/u_sampler.h \ + util/u_screen.c \ + util/u_screen.h \ util/u_simple_shaders.c \ util/u_simple_shaders.h \ util/u_slab.c \ diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c new file mode 100644 index 000..14be569 --- /dev/null +++ b/src/gallium/auxiliary/util/u_screen.c @@ -0,0 +1,114 @@ +/* + * Copyright 2016 Linaro, Ltd., Rob Herring + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * Functions for managing pipe_screen's + */ + +#include + +#include "os/os_thread.h" + +#include "pipe/p_screen.h" +#include "util/u_hash_table.h" +#include "util/u_inlines.h" +#include "util/u_pointer.h" +#include "util/u_screen.h" + +static struct util_hash_table *fd_tab = NULL; +pipe_static_mutex(fd_tab_mutex); + +static unsigned hash_fd(void *key) +{ + int fd = pointer_to_intptr(key); + struct stat stat; + fstat(fd, &stat); + + return stat.st_dev ^ stat.st_ino ^ stat.st_rdev; +} + +static int compare_fd(void *key1, void *key2) +{ + int fd1 = pointer_to_intptr(key1); + int fd2 = pointer_to_intptr(key2); + struct stat stat1, stat2; + fstat(fd1, &stat1); + fstat(fd2, &stat2); + + return stat1.st_dev != stat2.st_dev || + stat1.st_ino != stat2.st_ino || + stat1.st_rdev != stat2.st_rdev; +} + +struct pipe_screen * +pipe_screen_reference(int fd) +{ + struct pipe_screen *pscreen; + + if (!fd_tab) { + fd_tab = util_hash_table_create(hash_fd, compare_fd); + return NULL; + } + + pipe_mutex_lock(fd_tab_mutex); + pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd)); + if (pscreen) + pipe_reference(NULL, &pscreen->reference); + pipe_mutex_unlock(fd_tab_mutex); + + return pscreen; +} + +boolean +pipe_screen_unreference(struct pipe_screen *pscreen) +{ + boolean destroy; + + if (!pscreen) + return FALSE; + + /* Work-around until all pipe_screens have ref counting */ + if (!pipe_is_referenced(&pscreen->reference)) { + pscreen->destroy(pscreen); + return TRUE; + } + + pipe_mutex_lock(fd_tab_mutex); + destroy = pipe_reference(&pscreen->reference, NULL); + if (destroy) { + pscreen->destroy(pscreen); + util_hash_table_remove(fd_tab, intptr_to_pointer(pscreen->fd)); + close(pscreen->fd); + } + pipe_mutex_unlock(fd_tab_mutex); + return destroy; +} + + +void pipe_screen_reference_init(struct pipe_screen *pscreen, int fd) +{ + pscreen->fd = dup(fd); + pipe_reference_init(&pscreen->reference, 1); + util_hash_table_set(fd_tab, intptr_to_pointer(pscreen->fd), pscreen); +} diff --git a/src/gallium/auxiliary/util/u_screen.h b/src/gallium/auxiliary/util/u_screen.h new file mode 100644 ind
[Mesa-dev] [PATCH 02/11] pipe-loader-drm: protect create_screen() calls with a mutex
Creating a screen needs to be serialized in order to support reusing existing screen. With this, driver private mutexes in create_screen() functions can be removed. Signed-off-by: Rob Herring Cc: Emil Velikov --- src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 5 + 1 file changed, 5 insertions(+) diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c index 7bdd2ec..554e59a 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c @@ -41,6 +41,7 @@ #include "pipe_loader_priv.h" #include "pipe/p_screen.h" +#include "os/os_thread.h" #include "util/u_memory.h" #include "util/u_dl.h" #include "util/u_debug.h" @@ -63,6 +64,8 @@ struct pipe_loader_drm_device { static const struct pipe_loader_ops pipe_loader_drm_ops; +pipe_static_mutex(loader_mutex); + #ifdef GALLIUM_STATIC_TARGETS static const struct drm_conf_ret throttle_ret = { DRM_CONF_INT, @@ -303,8 +306,10 @@ pipe_loader_drm_create_screen(struct pipe_loader_device *dev) struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev); struct pipe_screen *pscreen; + pipe_mutex_lock(loader_mutex); pscreen = ddev->dd->create_screen(ddev->fd); ddev->base.pscreen = pscreen; + pipe_mutex_unlock(loader_mutex); return pscreen; } -- 2.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 00/11] Common pipe screen ref counting
Another version of common pipe_screen reference counting. Changes in v3: - dup() fd and store in pipe_screen as the lifetime of the pipe_loader_drm_device and pipe_screen are different. - Fix leaking of pipe_loader_drm_device. Only the last one closed was getting freed. - Move mutex for fd hash table into u_screen.c Rob Rob Herring (11): gallium: move pipe_screen destroy into pipe-loader pipe-loader-drm: protect create_screen() calls with a mutex gallium: add common pipe_screen reference counting functions pipe-loader-drm: use pipe_screen_unreference to destroy screen nouveau: use common screen ref counting freedreno: use common screen ref counting amdgpu: use common screen ref counting radeon: use common screen ref counting vmwgfx: use common screen ref counting vc4: use common screen ref counting virgl: use common screen ref counting src/gallium/auxiliary/Makefile.sources | 2 + src/gallium/auxiliary/pipe-loader/pipe_loader.h| 1 + .../auxiliary/pipe-loader/pipe_loader_drm.c| 15 ++- src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 6 ++ src/gallium/auxiliary/util/u_screen.c | 114 + src/gallium/auxiliary/util/u_screen.h | 32 ++ src/gallium/auxiliary/vl/vl_winsys_dri.c | 1 - src/gallium/auxiliary/vl/vl_winsys_dri3.c | 1 - src/gallium/auxiliary/vl/vl_winsys_drm.c | 1 - src/gallium/drivers/freedreno/freedreno_screen.c | 1 - src/gallium/drivers/freedreno/freedreno_screen.h | 10 -- src/gallium/drivers/nouveau/nouveau_screen.c | 6 -- src/gallium/drivers/nouveau/nouveau_screen.h | 4 - src/gallium/drivers/nouveau/nv30/nv30_screen.c | 3 - src/gallium/drivers/nouveau/nv50/nv50_screen.c | 3 - src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 3 - src/gallium/drivers/r300/r300_screen.c | 3 - src/gallium/drivers/r600/r600_pipe.c | 6 -- src/gallium/drivers/radeon/radeon_winsys.h | 8 -- src/gallium/drivers/radeonsi/si_pipe.c | 6 -- src/gallium/include/pipe/p_screen.h| 3 + src/gallium/state_trackers/clover/core/device.cpp | 4 +- src/gallium/state_trackers/dri/dri_screen.c| 3 - src/gallium/state_trackers/xa/xa_tracker.c | 2 - src/gallium/tests/trivial/compute.c| 1 - src/gallium/tests/trivial/quad-tex.c | 1 - src/gallium/tests/trivial/tri.c| 1 - src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 45 ++-- src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h | 1 - .../winsys/freedreno/drm/freedreno_drm_winsys.c| 94 ++--- .../winsys/nouveau/drm/nouveau_drm_winsys.c| 89 ++-- src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 84 ++- src/gallium/winsys/svga/drm/vmw_screen.c | 51 ++--- src/gallium/winsys/svga/drm/vmw_screen.h | 6 -- src/gallium/winsys/vc4/drm/vc4_drm_winsys.c| 9 +- src/gallium/winsys/virgl/drm/virgl_drm_winsys.c| 86 ++-- 36 files changed, 221 insertions(+), 485 deletions(-) create mode 100644 src/gallium/auxiliary/util/u_screen.c create mode 100644 src/gallium/auxiliary/util/u_screen.h -- 2.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 08/11] radeon: use common screen ref counting
Use the common pipe_screen ref counting and fd hashing functions. The mutex can be dropped as the pipe loader protects the create_screen() calls. Signed-off-by: Rob Herring Cc: "Marek Olšák" Cc: Ilia Mirkin --- src/gallium/drivers/r300/r300_screen.c| 3 - src/gallium/drivers/r600/r600_pipe.c | 6 -- src/gallium/drivers/radeon/radeon_winsys.h| 8 --- src/gallium/drivers/radeonsi/si_pipe.c| 6 -- src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 84 ++- 5 files changed, 7 insertions(+), 100 deletions(-) diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index d47b70d..1340009 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -676,9 +676,6 @@ static void r300_destroy_screen(struct pipe_screen* pscreen) struct r300_screen* r300screen = r300_screen(pscreen); struct radeon_winsys *rws = radeon_winsys(pscreen); -if (rws && !rws->unref(rws)) - return; - pipe_mutex_destroy(r300screen->cmask_mutex); if (rws) diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index f23daf9..c645295 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -570,12 +570,6 @@ static void r600_destroy_screen(struct pipe_screen* pscreen) { struct r600_screen *rscreen = (struct r600_screen *)pscreen; - if (!rscreen) - return; - - if (!rscreen->b.ws->unref(rscreen->b.ws)) - return; - if (rscreen->global_pool) { compute_memory_pool_delete(rscreen->global_pool); } diff --git a/src/gallium/drivers/radeon/radeon_winsys.h b/src/gallium/drivers/radeon/radeon_winsys.h index a9c9b9e..2ca19f4 100644 --- a/src/gallium/drivers/radeon/radeon_winsys.h +++ b/src/gallium/drivers/radeon/radeon_winsys.h @@ -426,14 +426,6 @@ struct radeon_winsys { struct pipe_screen *screen; /** - * Decrement the winsys reference count. - * - * \param ws The winsys this function is called for. - * \returnTrue if the winsys and screen should be destroyed. - */ -bool (*unref)(struct radeon_winsys *ws); - -/** * Destroy this winsys. * * \param wsThe winsys this function is called from. diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index ee97bcf..1c6920c 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -657,12 +657,6 @@ static void si_destroy_screen(struct pipe_screen* pscreen) }; unsigned i; - if (!sscreen) - return; - - if (!sscreen->b.ws->unref(sscreen->b.ws)) - return; - if (util_queue_is_initialized(&sscreen->shader_compiler_queue)) util_queue_destroy(&sscreen->shader_compiler_queue); diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c index 1b32c37..7c2c3fc 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c @@ -38,11 +38,11 @@ #include "pipebuffer/pb_bufmgr.h" #include "util/u_memory.h" #include "util/u_hash_table.h" +#include "util/u_screen.h" #include #include #include -#include #include #include @@ -63,9 +63,6 @@ #define RADEON_INFO_GPU_RESET_COUNTER 0x26 #endif -static struct util_hash_table *fd_tab = NULL; -pipe_static_mutex(fd_tab_mutex); - /* Enable/disable feature access for one command stream. * If enable == true, return true on success. * Otherwise, return false. @@ -558,9 +555,6 @@ static void radeon_winsys_destroy(struct radeon_winsys *rws) pipe_mutex_destroy(ws->bo_handles_mutex); pipe_mutex_destroy(ws->bo_va_mutex); -if (ws->fd >= 0) -close(ws->fd); - FREE(rws); } @@ -665,49 +659,8 @@ static bool radeon_read_registers(struct radeon_winsys *rws, return true; } -static unsigned hash_fd(void *key) -{ -int fd = pointer_to_intptr(key); -struct stat stat; -fstat(fd, &stat); - -return stat.st_dev ^ stat.st_ino ^ stat.st_rdev; -} - -static int compare_fd(void *key1, void *key2) -{ -int fd1 = pointer_to_intptr(key1); -int fd2 = pointer_to_intptr(key2); -struct stat stat1, stat2; -fstat(fd1, &stat1); -fstat(fd2, &stat2); - -return stat1.st_dev != stat2.st_dev || - stat1.st_ino != stat2.st_ino || - stat1.st_rdev != stat2.st_rdev; -} - DEBUG_GET_ONCE_BOOL_OPTION(thread, "RADEON_THREAD", true) -static bool radeon_winsys_unref(struct radeon_winsys *ws) -{ -struct radeon_drm_winsys *rws = (struct radeon_drm_winsys*)ws; -bool destroy; -
[Mesa-dev] [PATCH v3 06/11] freedreno: use common screen ref counting
Use the common pipe_screen ref counting and fd hashing functions. The mutex can be dropped as the pipe loader protects the create_screen() calls. Signed-off-by: Rob Herring Cc: Rob Clark --- src/gallium/drivers/freedreno/freedreno_screen.c | 1 - src/gallium/drivers/freedreno/freedreno_screen.h | 10 --- .../winsys/freedreno/drm/freedreno_drm_winsys.c| 94 ++ 3 files changed, 6 insertions(+), 99 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 5255c10..324f712 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -565,7 +565,6 @@ fd_screen_create(struct fd_device *dev) pscreen = &screen->base; screen->dev = dev; - screen->refcnt = 1; // maybe this should be in context? screen->pipe = fd_pipe_new(screen->dev, FD_PIPE_3D); diff --git a/src/gallium/drivers/freedreno/freedreno_screen.h b/src/gallium/drivers/freedreno/freedreno_screen.h index a81c778..8dcacca 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.h +++ b/src/gallium/drivers/freedreno/freedreno_screen.h @@ -42,16 +42,6 @@ struct fd_bo; struct fd_screen { struct pipe_screen base; - /* it would be tempting to use pipe_reference here, but that -* really doesn't work well if it isn't the first member of -* the struct, so not quite so awesome to be adding refcnting -* further down the inheritance hierarchy: -*/ - int refcnt; - - /* place for winsys to stash it's own stuff: */ - void *winsys_priv; - uint32_t gmemsize_bytes; uint32_t device_id; uint32_t gpu_id; /* 220, 305, etc */ diff --git a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c index e4785f8..56c021d 100644 --- a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c +++ b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c @@ -26,102 +26,20 @@ *Rob Clark */ -#include - -#include "pipe/p_context.h" -#include "pipe/p_state.h" -#include "util/u_format.h" -#include "util/u_memory.h" -#include "util/u_inlines.h" -#include "util/u_hash_table.h" -#include "os/os_thread.h" +#include "util/u_screen.h" #include "freedreno_drm_public.h" #include "freedreno/freedreno_screen.h" -static struct util_hash_table *fd_tab = NULL; - -pipe_static_mutex(fd_screen_mutex); - -static void -fd_drm_screen_destroy(struct pipe_screen *pscreen) -{ - struct fd_screen *screen = fd_screen(pscreen); - boolean destroy; - - pipe_mutex_lock(fd_screen_mutex); - destroy = --screen->refcnt == 0; - if (destroy) { - int fd = fd_device_fd(screen->dev); - util_hash_table_remove(fd_tab, intptr_to_pointer(fd)); - } - pipe_mutex_unlock(fd_screen_mutex); - - if (destroy) { - pscreen->destroy = screen->winsys_priv; - pscreen->destroy(pscreen); - } -} - -static unsigned hash_fd(void *key) -{ - int fd = pointer_to_intptr(key); - struct stat stat; - fstat(fd, &stat); - - return stat.st_dev ^ stat.st_ino ^ stat.st_rdev; -} - -static int compare_fd(void *key1, void *key2) -{ - int fd1 = pointer_to_intptr(key1); - int fd2 = pointer_to_intptr(key2); - struct stat stat1, stat2; - fstat(fd1, &stat1); - fstat(fd2, &stat2); - - return stat1.st_dev != stat2.st_dev || - stat1.st_ino != stat2.st_ino || - stat1.st_rdev != stat2.st_rdev; -} - struct pipe_screen * fd_drm_screen_create(int fd) { - struct pipe_screen *pscreen = NULL; - - pipe_mutex_lock(fd_screen_mutex); - if (!fd_tab) { - fd_tab = util_hash_table_create(hash_fd, compare_fd); - if (!fd_tab) - goto unlock; - } - - pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd)); - if (pscreen) { - fd_screen(pscreen)->refcnt++; - } else { - struct fd_device *dev = fd_device_new_dup(fd); - if (!dev) - goto unlock; - - pscreen = fd_screen_create(dev); - if (pscreen) { - int fd = fd_device_fd(dev); - - util_hash_table_set(fd_tab, intptr_to_pointer(fd), pscreen); - - /* Bit of a hack, to avoid circular linkage dependency, -* ie. pipe driver having to call in to winsys, we -* override the pipe drivers screen->destroy(): -*/ - fd_screen(pscreen)->winsys_priv = pscre
[Mesa-dev] [PATCH v3 05/11] nouveau: use common screen ref counting
Use the common pipe_screen ref counting and fd hashing functions. The mutex can be dropped as the pipe loader protects the create_screen() calls. Signed-off-by: Rob Herring Cc: Alexandre Courbot --- src/gallium/drivers/nouveau/nouveau_screen.c | 6 -- src/gallium/drivers/nouveau/nouveau_screen.h | 4 - src/gallium/drivers/nouveau/nv30/nv30_screen.c | 3 - src/gallium/drivers/nouveau/nv50/nv50_screen.c | 3 - src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 3 - .../winsys/nouveau/drm/nouveau_drm_winsys.c| 89 ++ 6 files changed, 7 insertions(+), 101 deletions(-) diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 2c421cc..41d4bef 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -159,12 +159,6 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) screen->drm = nouveau_drm(&dev->object); screen->device = dev; - /* -* this is initialized to 1 in nouveau_drm_screen_create after screen -* is fully constructed and added to the global screen list. -*/ - screen->refcount = -1; - if (dev->chipset < 0xc0) { data = &nv04_data; size = sizeof(nv04_data); diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h index 28c4760..55156c3 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.h +++ b/src/gallium/drivers/nouveau/nouveau_screen.h @@ -23,8 +23,6 @@ struct nouveau_screen { struct nouveau_client *client; struct nouveau_pushbuf *pushbuf; - int refcount; - unsigned vidmem_bindings; /* PIPE_BIND_* where VRAM placement is desired */ unsigned sysmem_bindings; /* PIPE_BIND_* where GART placement is desired */ unsigned lowmem_bindings; /* PIPE_BIND_* that require an address < 4 GiB */ @@ -119,8 +117,6 @@ nouveau_screen(struct pipe_screen *pscreen) return (struct nouveau_screen *)pscreen; } -bool nouveau_drm_screen_unref(struct nouveau_screen *screen); - bool nouveau_screen_bo_get_handle(struct pipe_screen *pscreen, struct nouveau_bo *bo, diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c index 68d8317..591cf92 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c @@ -408,9 +408,6 @@ nv30_screen_destroy(struct pipe_screen *pscreen) { struct nv30_screen *screen = nv30_screen(pscreen); - if (!nouveau_drm_screen_unref(&screen->base)) - return; - if (screen->base.fence.current) { struct nouveau_fence *current = NULL; diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c index 303ecf1..7dbf66f 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c @@ -428,9 +428,6 @@ nv50_screen_destroy(struct pipe_screen *pscreen) { struct nv50_screen *screen = nv50_screen(pscreen); - if (!nouveau_drm_screen_unref(&screen->base)) - return; - if (screen->base.fence.current) { struct nouveau_fence *current = NULL; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c index f681631..f789de4 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c @@ -485,9 +485,6 @@ nvc0_screen_destroy(struct pipe_screen *pscreen) { struct nvc0_screen *screen = nvc0_screen(pscreen); - if (!nouveau_drm_screen_unref(&screen->base)) - return; - if (screen->base.fence.current) { struct nouveau_fence *current = NULL; diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c index f90572f..9ad3c57 100644 --- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c +++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c @@ -1,12 +1,9 @@ -#include #include #include "pipe/p_context.h" #include "pipe/p_state.h" #include "util/u_format.h" #include "util/u_memory.h" -#include "util/u_inlines.h" -#include "util/u_hash_table.h" -#include "os/os_thread.h" +#include "util/u_screen.h" #include "nouveau_drm_public.h" @@ -16,47 +13,6 @@ #include #include -static struct util_hash_table *fd_tab = NULL; - -pipe_static_mutex(nouveau_screen_mutex); - -bool nouveau_drm_screen_unref(struct nouveau_screen *screen) -{ - int ret; - if (screen->refcount == -1) - return true; - - pipe_mutex_lock(nouveau_screen_mutex); - ret = --screen->refcount; - assert(ret >= 0); - if (ret == 0) - util_hash_table_remove(f
[Mesa-dev] [PATCH v3 07/11] amdgpu: use common screen ref counting
Use the common pipe_screen ref count. amdgpu is unique in its hashing the dev pointer rather than the fd, so the common fd hashing cannot be used. However, the same reference count can be used instead of the private one. The mutex can be dropped as the pipe loader protects the create_screen() calls. Signed-off-by: Rob Herring Cc: "Marek Olšák" Cc: Ilia Mirkin --- src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 45 --- src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h | 1 - 2 files changed, 6 insertions(+), 40 deletions(-) diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c index 9a04cbe..56a9672 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c @@ -60,8 +60,6 @@ #define CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_16X16 17 static struct util_hash_table *dev_tab = NULL; -pipe_static_mutex(dev_tab_mutex); - static unsigned cik_get_num_tile_pipes(struct amdgpu_gpu_info *info) { unsigned mode2d = info->gb_tile_mode[CIK_TILE_MODE_COLOR_2D]; @@ -329,6 +327,7 @@ static void amdgpu_winsys_destroy(struct radeon_winsys *rws) pipe_mutex_destroy(ws->global_bo_list_lock); AddrDestroy(ws->addrlib); amdgpu_device_deinitialize(ws->dev); + util_hash_table_remove(dev_tab, ws->dev); FREE(rws); } @@ -410,26 +409,6 @@ static int compare_dev(void *key1, void *key2) DEBUG_GET_ONCE_BOOL_OPTION(thread, "RADEON_THREAD", true) -static bool amdgpu_winsys_unref(struct radeon_winsys *rws) -{ - struct amdgpu_winsys *ws = (struct amdgpu_winsys*)rws; - bool destroy; - - /* When the reference counter drops to zero, remove the device pointer -* from the table. -* This must happen while the mutex is locked, so that -* amdgpu_winsys_create in another thread doesn't get the winsys -* from the table when the counter drops to 0. */ - pipe_mutex_lock(dev_tab_mutex); - - destroy = pipe_reference(&ws->reference, NULL); - if (destroy && dev_tab) - util_hash_table_remove(dev_tab, ws->dev); - - pipe_mutex_unlock(dev_tab_mutex); - return destroy; -} - PUBLIC struct radeon_winsys * amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create) { @@ -446,7 +425,6 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create) drmFreeVersion(version); /* Look up the winsys from the dev table. */ - pipe_mutex_lock(dev_tab_mutex); if (!dev_tab) dev_tab = util_hash_table_create(hash_dev, compare_dev); @@ -454,7 +432,6 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create) * for the same fd. */ r = amdgpu_device_initialize(fd, &drm_major, &drm_minor, &dev); if (r) { - pipe_mutex_unlock(dev_tab_mutex); fprintf(stderr, "amdgpu: amdgpu_device_initialize failed.\n"); return NULL; } @@ -462,17 +439,14 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create) /* Lookup a winsys if we have already created one for this device. */ ws = util_hash_table_get(dev_tab, dev); if (ws) { - pipe_reference(NULL, &ws->reference); - pipe_mutex_unlock(dev_tab_mutex); + pipe_reference(NULL, &ws->base.screen->reference); return &ws->base; } /* Create a new winsys. */ ws = CALLOC_STRUCT(amdgpu_winsys); - if (!ws) { - pipe_mutex_unlock(dev_tab_mutex); + if (!ws) return NULL; - } ws->dev = dev; ws->info.drm_major = drm_major; @@ -486,11 +460,7 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create) (ws->info.vram_size + ws->info.gart_size) / 8, amdgpu_bo_destroy, amdgpu_bo_can_reclaim); - /* init reference */ - pipe_reference_init(&ws->reference, 1); - /* Set functions. */ - ws->base.unref = amdgpu_winsys_unref; ws->base.destroy = amdgpu_winsys_destroy; ws->base.query_info = amdgpu_winsys_query_info; ws->base.cs_request_feature = amdgpu_cs_request_feature; @@ -516,21 +486,18 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create) ws->base.screen = screen_create(&ws->base); if (!ws->base.screen) { amdgpu_winsys_destroy(&ws->base); - pipe_mutex_unlock(dev_tab_mutex); return NULL; } util_hash_table_set(dev_tab, dev, ws); - /* We must unlock the mutex once the winsys is fully initialized, so that -* other threads attempting to create the winsys from the same fd will -* get a fully initialized winsys and not just half-way initialized. */ - pipe_mutex_unlock(dev_tab_mutex); + /* init reference */ + pipe_reference_init(&ws->base.screen->reference, 1); + return &ws->base; fail: - pipe_mutex_unlock(dev_tab_mutex); pb_cache_deinit(&ws->bo_cache); FREE(ws); return
[Mesa-dev] [PATCH v3 02/11] pipe-loader-drm: protect create_screen() calls with a mutex
Creating a screen needs to be serialized in order to support reusing existing screen. With this, driver private mutexes in create_screen() functions can be removed. Signed-off-by: Rob Herring Cc: Emil Velikov --- src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 5 + 1 file changed, 5 insertions(+) diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c index 7bdd2ec..554e59a 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c @@ -41,6 +41,7 @@ #include "pipe_loader_priv.h" #include "pipe/p_screen.h" +#include "os/os_thread.h" #include "util/u_memory.h" #include "util/u_dl.h" #include "util/u_debug.h" @@ -63,6 +64,8 @@ struct pipe_loader_drm_device { static const struct pipe_loader_ops pipe_loader_drm_ops; +pipe_static_mutex(loader_mutex); + #ifdef GALLIUM_STATIC_TARGETS static const struct drm_conf_ret throttle_ret = { DRM_CONF_INT, @@ -303,8 +306,10 @@ pipe_loader_drm_create_screen(struct pipe_loader_device *dev) struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev); struct pipe_screen *pscreen; + pipe_mutex_lock(loader_mutex); pscreen = ddev->dd->create_screen(ddev->fd); ddev->base.pscreen = pscreen; + pipe_mutex_unlock(loader_mutex); return pscreen; } -- 2.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 09/11] vmwgfx: use common screen ref counting
Use the common pipe_screen ref counting and fd hashing functions. The mutex can be dropped as the pipe loader protects the create_screen() calls. Signed-off-by: Rob Herring --- src/gallium/winsys/svga/drm/vmw_screen.c | 51 src/gallium/winsys/svga/drm/vmw_screen.h | 6 2 files changed, 6 insertions(+), 51 deletions(-) diff --git a/src/gallium/winsys/svga/drm/vmw_screen.c b/src/gallium/winsys/svga/drm/vmw_screen.c index 7fcb6d2..2b05012 100644 --- a/src/gallium/winsys/svga/drm/vmw_screen.c +++ b/src/gallium/winsys/svga/drm/vmw_screen.c @@ -30,24 +30,9 @@ #include "util/u_memory.h" #include "pipe/p_compiler.h" -#include "util/u_hash_table.h" #include -#include #include -static struct util_hash_table *dev_hash = NULL; - -static int vmw_dev_compare(void *key1, void *key2) -{ - return (major(*(dev_t *)key1) == major(*(dev_t *)key2) && - minor(*(dev_t *)key1) == minor(*(dev_t *)key2)) ? 0 : 1; -} - -static unsigned vmw_dev_hash(void *key) -{ - return (major(*(dev_t *) key) << 16) | minor(*(dev_t *) key); -} - /* Called from vmw_drm_create_screen(), creates and initializes the * vmw_winsys_screen structure, which is the main entity in this * module. @@ -60,29 +45,11 @@ struct vmw_winsys_screen * vmw_winsys_create( int fd ) { struct vmw_winsys_screen *vws; - struct stat stat_buf; - - if (dev_hash == NULL) { - dev_hash = util_hash_table_create(vmw_dev_hash, vmw_dev_compare); - if (dev_hash == NULL) - return NULL; - } - - if (fstat(fd, &stat_buf)) - return NULL; - - vws = util_hash_table_get(dev_hash, &stat_buf.st_rdev); - if (vws) { - vws->open_count++; - return vws; - } vws = CALLOC_STRUCT(vmw_winsys_screen); if (!vws) goto out_no_vws; - vws->device = stat_buf.st_rdev; - vws->open_count = 1; vws->ioctl.drm_fd = dup(fd); vws->base.have_gb_dma = TRUE; vws->base.need_to_rebind_resources = FALSE; @@ -100,11 +67,8 @@ vmw_winsys_create( int fd ) if (!vmw_winsys_screen_init_svga(vws)) goto out_no_svga; - if (util_hash_table_set(dev_hash, &vws->device, vws) != PIPE_OK) - goto out_no_hash_insert; - return vws; -out_no_hash_insert: + out_no_svga: vmw_pools_cleanup(vws); out_no_pools: @@ -121,12 +85,9 @@ out_no_vws: void vmw_winsys_destroy(struct vmw_winsys_screen *vws) { - if (--vws->open_count == 0) { - util_hash_table_remove(dev_hash, &vws->device); - vmw_pools_cleanup(vws); - vws->fence_ops->destroy(vws->fence_ops); - vmw_ioctl_cleanup(vws); - close(vws->ioctl.drm_fd); - FREE(vws); - } + vmw_pools_cleanup(vws); + vws->fence_ops->destroy(vws->fence_ops); + vmw_ioctl_cleanup(vws); + close(vws->ioctl.drm_fd); + FREE(vws); } diff --git a/src/gallium/winsys/svga/drm/vmw_screen.h b/src/gallium/winsys/svga/drm/vmw_screen.h index 79d0949..cfde6bb 100644 --- a/src/gallium/winsys/svga/drm/vmw_screen.h +++ b/src/gallium/winsys/svga/drm/vmw_screen.h @@ -93,12 +93,6 @@ struct vmw_winsys_screen } pools; struct pb_fence_ops *fence_ops; - - /* -* Screen instances -*/ - dev_t device; - int open_count; }; -- 2.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 01/11] gallium: move pipe_screen destroy into pipe-loader
In preparation to add reference counting of pipe_screen in the pipe-loader, pipe_loader_release needs to destroy the pipe_screen instead of state trackers. Signed-off-by: Rob Herring Cc: Emil Velikov --- src/gallium/auxiliary/pipe-loader/pipe_loader.h | 1 + src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 9 - src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 6 ++ src/gallium/auxiliary/vl/vl_winsys_dri.c| 1 - src/gallium/auxiliary/vl/vl_winsys_dri3.c | 1 - src/gallium/auxiliary/vl/vl_winsys_drm.c| 1 - src/gallium/state_trackers/clover/core/device.cpp | 4 +--- src/gallium/state_trackers/dri/dri_screen.c | 3 --- src/gallium/state_trackers/xa/xa_tracker.c | 2 -- src/gallium/tests/trivial/compute.c | 1 - src/gallium/tests/trivial/quad-tex.c| 1 - src/gallium/tests/trivial/tri.c | 1 - 12 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h b/src/gallium/auxiliary/pipe-loader/pipe_loader.h index 690d088..25cd4d1 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h @@ -65,6 +65,7 @@ struct pipe_loader_device { char *driver_name; const struct pipe_loader_ops *ops; + struct pipe_screen *pscreen; }; /** diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c index 994a284..7bdd2ec 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c @@ -39,6 +39,7 @@ #include "target-helpers/drm_helper_public.h" #include "state_tracker/drm_driver.h" #include "pipe_loader_priv.h" +#include "pipe/p_screen.h" #include "util/u_memory.h" #include "util/u_dl.h" @@ -269,6 +270,9 @@ static void pipe_loader_drm_release(struct pipe_loader_device **dev) { struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(*dev); + struct pipe_screen *pscreen = ddev->base.pscreen; + + pscreen->destroy(pscreen); #ifndef GALLIUM_STATIC_TARGETS if (ddev->lib) @@ -297,8 +301,11 @@ static struct pipe_screen * pipe_loader_drm_create_screen(struct pipe_loader_device *dev) { struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev); + struct pipe_screen *pscreen; - return ddev->dd->create_screen(ddev->fd); + pscreen = ddev->dd->create_screen(ddev->fd); + ddev->base.pscreen = pscreen; + return pscreen; } static const struct pipe_loader_ops pipe_loader_drm_ops = { diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c index e7fa974..ce5c2b3 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c @@ -27,6 +27,7 @@ #include "pipe_loader_priv.h" +#include "pipe/p_screen.h" #include "util/u_memory.h" #include "util/u_dl.h" #include "sw/dri/dri_sw_winsys.h" @@ -271,6 +272,9 @@ static void pipe_loader_sw_release(struct pipe_loader_device **dev) { struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(*dev); + struct pipe_screen *pscreen = sdev->base.pscreen; + + pscreen->destroy(pscreen); #ifndef GALLIUM_STATIC_TARGETS if (sdev->lib) @@ -301,6 +305,8 @@ pipe_loader_sw_create_screen(struct pipe_loader_device *dev) if (!screen) sdev->ws->destroy(sdev->ws); + sdev->base.pscreen = screen; + return screen; } diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c index 9ecc216..db90c54 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_dri.c +++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c @@ -461,7 +461,6 @@ vl_dri2_screen_destroy(struct vl_screen *vscreen) } vl_dri2_destroy_drawable(scrn); - scrn->base.pscreen->destroy(scrn->base.pscreen); pipe_loader_release(&scrn->base.dev, 1); FREE(scrn); } diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c index 493e645..c8c0198 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c +++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c @@ -611,7 +611,6 @@ vl_dri3_screen_destroy(struct vl_screen *vscreen) if (scrn->special_event) xcb_unregister_for_special_event(scrn->conn, scrn->special_event); - scrn->base.pscreen->destroy(scrn->base.pscreen); pipe_loader_release(&scrn->base.dev, 1); FREE(scrn); diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c b/src/gallium/auxiliary/vl/vl_winsys_drm.c index 6a759ae..aa690a2 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_drm.c +++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c @@ -80,7 +80,6 @@ vl_drm_screen_destroy(struct vl_screen
[Mesa-dev] [PATCH v3 04/11] pipe-loader-drm: use pipe_screen_unreference to destroy screen
Use pipe_screen_unreference as it will call pipe_screen->destroy() when the pipe_screen is no longer referenced. The pipe_screen referencing is done within create_screen() functions as drivers (like amdgpu) may have special needs for ref counting. Signed-off-by: Rob Herring Cc: Emil Velikov --- src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c index 554e59a..2edb291 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c @@ -45,6 +45,7 @@ #include "util/u_memory.h" #include "util/u_dl.h" #include "util/u_debug.h" +#include "util/u_screen.h" #define DRM_RENDER_NODE_DEV_NAME_FORMAT "%s/renderD%d" #define DRM_RENDER_NODE_MAX_NODES 63 @@ -275,7 +276,7 @@ pipe_loader_drm_release(struct pipe_loader_device **dev) struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(*dev); struct pipe_screen *pscreen = ddev->base.pscreen; - pscreen->destroy(pscreen); + pipe_screen_unreference(pscreen); #ifndef GALLIUM_STATIC_TARGETS if (ddev->lib) -- 2.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 03/11] gallium: add common pipe_screen reference counting functions
In order to prevent multiple pipe_screens being created in the same process, lookup of the DRM FD and reference counting of the pipe_screen are needed. Several implementations of this exist in various gallium drivers/winsys already. This creates a common version which is opt-in for winsys implementations. Signed-off-by: Rob Herring --- src/gallium/auxiliary/Makefile.sources | 2 + src/gallium/auxiliary/util/u_screen.c | 114 + src/gallium/auxiliary/util/u_screen.h | 32 + src/gallium/include/pipe/p_screen.h| 3 + 4 files changed, 151 insertions(+) create mode 100644 src/gallium/auxiliary/util/u_screen.c create mode 100644 src/gallium/auxiliary/util/u_screen.h diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index e0311bf..197ed36 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -284,6 +284,8 @@ C_SOURCES := \ util/u_ringbuffer.h \ util/u_sampler.c \ util/u_sampler.h \ + util/u_screen.c \ + util/u_screen.h \ util/u_simple_shaders.c \ util/u_simple_shaders.h \ util/u_slab.c \ diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c new file mode 100644 index 000..14be569 --- /dev/null +++ b/src/gallium/auxiliary/util/u_screen.c @@ -0,0 +1,114 @@ +/* + * Copyright 2016 Linaro, Ltd., Rob Herring + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * Functions for managing pipe_screen's + */ + +#include + +#include "os/os_thread.h" + +#include "pipe/p_screen.h" +#include "util/u_hash_table.h" +#include "util/u_inlines.h" +#include "util/u_pointer.h" +#include "util/u_screen.h" + +static struct util_hash_table *fd_tab = NULL; +pipe_static_mutex(fd_tab_mutex); + +static unsigned hash_fd(void *key) +{ + int fd = pointer_to_intptr(key); + struct stat stat; + fstat(fd, &stat); + + return stat.st_dev ^ stat.st_ino ^ stat.st_rdev; +} + +static int compare_fd(void *key1, void *key2) +{ + int fd1 = pointer_to_intptr(key1); + int fd2 = pointer_to_intptr(key2); + struct stat stat1, stat2; + fstat(fd1, &stat1); + fstat(fd2, &stat2); + + return stat1.st_dev != stat2.st_dev || + stat1.st_ino != stat2.st_ino || + stat1.st_rdev != stat2.st_rdev; +} + +struct pipe_screen * +pipe_screen_reference(int fd) +{ + struct pipe_screen *pscreen; + + if (!fd_tab) { + fd_tab = util_hash_table_create(hash_fd, compare_fd); + return NULL; + } + + pipe_mutex_lock(fd_tab_mutex); + pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd)); + if (pscreen) + pipe_reference(NULL, &pscreen->reference); + pipe_mutex_unlock(fd_tab_mutex); + + return pscreen; +} + +boolean +pipe_screen_unreference(struct pipe_screen *pscreen) +{ + boolean destroy; + + if (!pscreen) + return FALSE; + + /* Work-around until all pipe_screens have ref counting */ + if (!pipe_is_referenced(&pscreen->reference)) { + pscreen->destroy(pscreen); + return TRUE; + } + + pipe_mutex_lock(fd_tab_mutex); + destroy = pipe_reference(&pscreen->reference, NULL); + if (destroy) { + pscreen->destroy(pscreen); + util_hash_table_remove(fd_tab, intptr_to_pointer(pscreen->fd)); + close(pscreen->fd); + } + pipe_mutex_unlock(fd_tab_mutex); + return destroy; +} + + +void pipe_screen_reference_init(struct pipe_screen *pscreen, int fd) +{ + pscreen->fd = dup(fd); + pipe_reference_init(&pscreen->reference, 1); + util_hash_table_set(fd_tab, intptr_to_pointer(pscreen->fd), pscreen); +} diff --git a/src/gallium/auxiliary/util/u_screen.h b/src/gallium/auxiliary/util/u_screen.h new file mode 100644 ind
[Mesa-dev] [PATCH v3 10/11] vc4: use common screen ref counting
Use the common pipe_screen ref counting and fd hashing functions. The mutex can be dropped as the pipe loader protects the create_screen() calls. Cc: Eric Anholt Signed-off-by: Rob Herring --- src/gallium/winsys/vc4/drm/vc4_drm_winsys.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c b/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c index c5434ad..acda743 100644 --- a/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c +++ b/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c @@ -22,6 +22,7 @@ */ #include +#include "util/u_screen.h" #include "vc4_drm_public.h" @@ -30,5 +31,11 @@ struct pipe_screen * vc4_drm_screen_create(int fd) { - return vc4_screen_create(dup(fd)); +struct pipe_screen *pscreen = pipe_screen_reference(fd); +if (pscreen) +return pscreen; + + pscreen = vc4_screen_create(dup(fd)); + pipe_screen_reference_init(pscreen, fd); + return pscreen; } -- 2.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 11/11] virgl: use common screen ref counting
Use the common pipe_screen ref counting and fd hashing functions. The mutex can be dropped as the pipe loader protects the create_screen() calls. The fd does not need to be dup'ed as the caller has already done that. Signed-off-by: Rob Herring Cc: Dave Airlie --- src/gallium/winsys/virgl/drm/virgl_drm_winsys.c | 86 +++-- 1 file changed, 8 insertions(+), 78 deletions(-) diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c index 81afa84..0f35dd0 100644 --- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c +++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c @@ -25,7 +25,6 @@ #include #include #include -#include #include "os/os_mman.h" #include "os/os_time.h" @@ -33,6 +32,7 @@ #include "util/u_format.h" #include "util/u_hash_table.h" #include "util/u_inlines.h" +#include "util/u_screen.h" #include "state_tracker/drm_driver.h" #include "virgl/virgl_screen.h" #include "virgl/virgl_public.h" @@ -802,86 +802,16 @@ virgl_drm_winsys_create(int drmFD) } -static struct util_hash_table *fd_tab = NULL; -pipe_static_mutex(virgl_screen_mutex); - -static void -virgl_drm_screen_destroy(struct pipe_screen *pscreen) -{ - struct virgl_screen *screen = virgl_screen(pscreen); - boolean destroy; - - pipe_mutex_lock(virgl_screen_mutex); - destroy = --screen->refcnt == 0; - if (destroy) { - int fd = virgl_drm_winsys(screen->vws)->fd; - util_hash_table_remove(fd_tab, intptr_to_pointer(fd)); - } - pipe_mutex_unlock(virgl_screen_mutex); - - if (destroy) { - pscreen->destroy = screen->winsys_priv; - pscreen->destroy(pscreen); - } -} - -static unsigned hash_fd(void *key) -{ - int fd = pointer_to_intptr(key); - struct stat stat; - fstat(fd, &stat); - - return stat.st_dev ^ stat.st_ino ^ stat.st_rdev; -} - -static int compare_fd(void *key1, void *key2) -{ - int fd1 = pointer_to_intptr(key1); - int fd2 = pointer_to_intptr(key2); - struct stat stat1, stat2; - fstat(fd1, &stat1); - fstat(fd2, &stat2); - - return stat1.st_dev != stat2.st_dev || - stat1.st_ino != stat2.st_ino || - stat1.st_rdev != stat2.st_rdev; -} - struct pipe_screen * virgl_drm_screen_create(int fd) { - struct pipe_screen *pscreen = NULL; - - pipe_mutex_lock(virgl_screen_mutex); - if (!fd_tab) { - fd_tab = util_hash_table_create(hash_fd, compare_fd); - if (!fd_tab) - goto unlock; - } - - pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd)); - if (pscreen) { - virgl_screen(pscreen)->refcnt++; - } else { - struct virgl_winsys *vws; - int dup_fd = dup(fd); - - vws = virgl_drm_winsys_create(dup_fd); - - pscreen = virgl_create_screen(vws); - if (pscreen) { - util_hash_table_set(fd_tab, intptr_to_pointer(dup_fd), pscreen); - - /* Bit of a hack, to avoid circular linkage dependency, - * ie. pipe driver having to call in to winsys, we - * override the pipe drivers screen->destroy(): - */ - virgl_screen(pscreen)->winsys_priv = pscreen->destroy; - pscreen->destroy = virgl_drm_screen_destroy; - } - } + struct virgl_winsys *vws; + struct pipe_screen *pscreen = pipe_screen_reference(fd); + if (pscreen) + return pscreen; -unlock: - pipe_mutex_unlock(virgl_screen_mutex); + vws = virgl_drm_winsys_create(fd); + pscreen = virgl_create_screen(vws); + pipe_screen_reference_init(pscreen, fd); return pscreen; } -- 2.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v3 05/11] nouveau: use common screen ref counting
On Wed, Jul 20, 2016 at 5:32 PM, Ilia Mirkin wrote: > On Wed, Jul 20, 2016 at 6:29 PM, Ilia Mirkin wrote: >> On Wed, Jul 20, 2016 at 6:25 PM, Rob Herring wrote: >>> Use the common pipe_screen ref counting and fd hashing functions. The >>> mutex can be dropped as the pipe loader protects the create_screen() >>> calls. >>> >>> Signed-off-by: Rob Herring >>> Cc: Alexandre Courbot >>> --- >>> src/gallium/drivers/nouveau/nouveau_screen.c | 6 -- >>> src/gallium/drivers/nouveau/nouveau_screen.h | 4 - >>> src/gallium/drivers/nouveau/nv30/nv30_screen.c | 3 - >>> src/gallium/drivers/nouveau/nv50/nv50_screen.c | 3 - >>> src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 3 - >>> .../winsys/nouveau/drm/nouveau_drm_winsys.c| 89 >>> ++ >>> 6 files changed, 7 insertions(+), 101 deletions(-) >>> >>> diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c >>> b/src/gallium/drivers/nouveau/nouveau_screen.c >>> index 2c421cc..41d4bef 100644 >>> --- a/src/gallium/drivers/nouveau/nouveau_screen.c >>> +++ b/src/gallium/drivers/nouveau/nouveau_screen.c >>> @@ -159,12 +159,6 @@ nouveau_screen_init(struct nouveau_screen *screen, >>> struct nouveau_device *dev) >>> screen->drm = nouveau_drm(&dev->object); >>> screen->device = dev; >>> >>> - /* >>> -* this is initialized to 1 in nouveau_drm_screen_create after screen >>> -* is fully constructed and added to the global screen list. >>> -*/ >>> - screen->refcount = -1; >>> - >>> if (dev->chipset < 0xc0) { >>>data = &nv04_data; >>>size = sizeof(nv04_data); >>> diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h >>> b/src/gallium/drivers/nouveau/nouveau_screen.h >>> index 28c4760..55156c3 100644 >>> --- a/src/gallium/drivers/nouveau/nouveau_screen.h >>> +++ b/src/gallium/drivers/nouveau/nouveau_screen.h >>> @@ -23,8 +23,6 @@ struct nouveau_screen { >>> struct nouveau_client *client; >>> struct nouveau_pushbuf *pushbuf; >>> >>> - int refcount; >>> - >>> unsigned vidmem_bindings; /* PIPE_BIND_* where VRAM placement is >>> desired */ >>> unsigned sysmem_bindings; /* PIPE_BIND_* where GART placement is >>> desired */ >>> unsigned lowmem_bindings; /* PIPE_BIND_* that require an address < 4 >>> GiB */ >>> @@ -119,8 +117,6 @@ nouveau_screen(struct pipe_screen *pscreen) >>> return (struct nouveau_screen *)pscreen; >>> } >>> >>> -bool nouveau_drm_screen_unref(struct nouveau_screen *screen); >>> - >>> bool >>> nouveau_screen_bo_get_handle(struct pipe_screen *pscreen, >>> struct nouveau_bo *bo, >>> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c >>> b/src/gallium/drivers/nouveau/nv30/nv30_screen.c >>> index 68d8317..591cf92 100644 >>> --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c >>> +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c >>> @@ -408,9 +408,6 @@ nv30_screen_destroy(struct pipe_screen *pscreen) >>> { >>> struct nv30_screen *screen = nv30_screen(pscreen); >>> >>> - if (!nouveau_drm_screen_unref(&screen->base)) >>> - return; >>> - >>> if (screen->base.fence.current) { >>>struct nouveau_fence *current = NULL; >>> >>> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c >>> b/src/gallium/drivers/nouveau/nv50/nv50_screen.c >>> index 303ecf1..7dbf66f 100644 >>> --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c >>> +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c >>> @@ -428,9 +428,6 @@ nv50_screen_destroy(struct pipe_screen *pscreen) >>> { >>> struct nv50_screen *screen = nv50_screen(pscreen); >>> >>> - if (!nouveau_drm_screen_unref(&screen->base)) >>> - return; >>> - >>> if (screen->base.fence.current) { >>>struct nouveau_fence *current = NULL; >>> >>> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c >>> b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c >>> index f681631..f789de4 100644 >>> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c >>> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c >>&
Re: [Mesa-dev] [PATCH 06/10] egl/android: Fix support for pbuffers
On Thu, Jul 21, 2016 at 12:35 AM, Tomasz Figa wrote: > On Thu, Jul 21, 2016 at 6:19 AM, Rob Herring wrote: >> On Fri, Jul 15, 2016 at 2:53 AM, Tomasz Figa wrote: >>> From: Nicolas Boichat >>> >>> Existing image loader code supports creating images only for window >>> surfaces. Moreover droid_create_surface() passes wrong surface type to >>> dri2_get_dri_config(), resulting in incorrect configs being returned for >>> pbuffers. This patch fixes these issues. >>> >>> In addition, the config generation code is fixed to include single >>> buffered contexts required for pbuffers and make sure that generated >>> configs support only surfaces which can handle their supported buffering >>> modes. >>> >>> Signed-off-by: Nicolas Boichat >>> Signed-off-by: Tomasz Figa >>> --- [...] >>> @@ -728,6 +754,19 @@ droid_add_configs_for_visuals(_EGLDriver *drv, >>> _EGLDisplay *dpy) >>>/* there is no front buffer so no OpenGL */ >>>dri2_conf->base.RenderableType &= ~EGL_OPENGL_BIT; >>>dri2_conf->base.Conformant &= ~EGL_OPENGL_BIT; >>> + >>> + for (j = 0; j < 2; j++) { >>> + /* Unsupported color space variants should not affect surface >>> type. */ >>> + if (!dri2_conf->dri_single_config[j] && >>> !dri2_conf->dri_double_config[j]) >>> +continue; >>> + >>> + /* Pbuffers support only single buffering. */ >>> + if (!dri2_conf->dri_single_config[j]) >>> +dri2_conf->base.SurfaceType &= ~EGL_PBUFFER_BIT; >>> + /* Windows support only double buffering. */ >>> + else if (!dri2_conf->dri_double_config[j]) >>> +dri2_conf->base.SurfaceType &= ~EGL_WINDOW_BIT; >>> + } >> >> I still don't know why this patch causes problems, but I don't think >> this hunk is needed. The core DRI2 EGL code takes care of this. It's >> not so obvious though. EGL_PBUFFER_BIT is cleared in dri2_add_config, >> and dri2_get_dri_config returns single or double config based on the >> surface type. > > Well, it just doesn't work correctly without this. > > If DRI driver exposes certain double buffered configs that don't have > their equivalent single buffered configs then it will leave double > buffered configs with EGL_PBUFFER_BIT set and dri2_get_dri_config() > will return NULL at the time of eglCreateSurface(), which doesn't > conform to the spec and will cause failures, because it is expected > that if eglChooseConfig() is given EGL_PBUFFER_BIT then resulting > config must support pbuffers. Similarly for EGL_WINDOW_BIT and > single-buffered configs without double-buffered equivalents. > > Also I don't see where dri2_add_config() clears EGL_PBUFFER_BIT. I can > see only EGL_PIXMAP_BIT. Oh yes, you are correct. Sorry for the noise. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 00/11] Common pipe screen ref counting
Another version of common pipe_screen reference counting. Please help test on AMD and Nouveau as those are the more complicated ones and I don't have h/w to test. Changes in v4: - Move fd dup() back into driver winsys create screen functions which sometimes need the dup'ed fd before the pipe_screen is created. - Update vmwgfx driver which I missed updating in v3 - Update vc4 commit msg to reflect this is a new feature. Changes in v3: - dup() fd and store in pipe_screen as the lifetime of the pipe_loader_drm_device and pipe_screen are different. - Fix leaking of pipe_loader_drm_device. Only the last one closed was getting freed. - Move mutex for fd hash table into u_screen.c Rob Rob Herring (11): gallium: move pipe_screen destroy into pipe-loader pipe-loader-drm: protect create_screen() calls with a mutex gallium: add common pipe_screen reference counting functions pipe-loader-drm: use pipe_screen_unreference to destroy screen nouveau: use common screen ref counting freedreno: use common screen ref counting amdgpu: use common screen ref counting radeon: use common screen ref counting vmwgfx: use common screen ref counting virgl: use common screen ref counting vc4: use common screen ref counting src/gallium/auxiliary/Makefile.sources | 2 + src/gallium/auxiliary/pipe-loader/pipe_loader.h| 1 + .../auxiliary/pipe-loader/pipe_loader_drm.c| 15 ++- src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 6 ++ src/gallium/auxiliary/target-helpers/drm_helper.h | 2 +- src/gallium/auxiliary/util/u_screen.c | 114 + src/gallium/auxiliary/util/u_screen.h | 32 ++ src/gallium/auxiliary/vl/vl_winsys_dri.c | 1 - src/gallium/auxiliary/vl/vl_winsys_dri3.c | 1 - src/gallium/auxiliary/vl/vl_winsys_drm.c | 1 - src/gallium/drivers/freedreno/freedreno_screen.c | 1 - src/gallium/drivers/freedreno/freedreno_screen.h | 10 -- src/gallium/drivers/nouveau/nouveau_screen.c | 6 -- src/gallium/drivers/nouveau/nouveau_screen.h | 4 - src/gallium/drivers/nouveau/nv30/nv30_screen.c | 3 - src/gallium/drivers/nouveau/nv50/nv50_screen.c | 3 - src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 3 - src/gallium/drivers/r300/r300_screen.c | 3 - src/gallium/drivers/r600/r600_pipe.c | 6 -- src/gallium/drivers/radeon/radeon_winsys.h | 8 -- src/gallium/drivers/radeonsi/si_pipe.c | 6 -- src/gallium/drivers/svga/svga_public.h | 2 +- src/gallium/drivers/svga/svga_screen.c | 5 +- src/gallium/include/pipe/p_screen.h| 3 + src/gallium/state_trackers/clover/core/device.cpp | 4 +- src/gallium/state_trackers/dri/dri_screen.c| 3 - src/gallium/state_trackers/xa/xa_tracker.c | 2 - src/gallium/targets/pipe-loader/pipe_vmwgfx.c | 2 +- src/gallium/tests/trivial/compute.c| 1 - src/gallium/tests/trivial/quad-tex.c | 1 - src/gallium/tests/trivial/tri.c| 1 - src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 45 ++-- src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h | 1 - .../winsys/freedreno/drm/freedreno_drm_winsys.c| 98 ++ .../winsys/nouveau/drm/nouveau_drm_winsys.c| 69 + src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 80 ++- src/gallium/winsys/svga/drm/vmw_screen.c | 54 ++ src/gallium/winsys/svga/drm/vmw_screen.h | 6 -- src/gallium/winsys/vc4/drm/vc4_drm_winsys.c| 11 +- src/gallium/winsys/virgl/drm/virgl_drm_winsys.c| 88 ++-- 40 files changed, 236 insertions(+), 468 deletions(-) create mode 100644 src/gallium/auxiliary/util/u_screen.c create mode 100644 src/gallium/auxiliary/util/u_screen.h -- 2.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 09/11] vmwgfx: use common screen ref counting
Use the common pipe_screen ref counting and fd hashing functions. The mutex can be dropped as the pipe loader protects the create_screen() calls. Signed-off-by: Rob Herring --- src/gallium/auxiliary/target-helpers/drm_helper.h | 2 +- src/gallium/drivers/svga/svga_public.h| 2 +- src/gallium/drivers/svga/svga_screen.c| 5 ++- src/gallium/targets/pipe-loader/pipe_vmwgfx.c | 2 +- src/gallium/winsys/svga/drm/vmw_screen.c | 54 +-- src/gallium/winsys/svga/drm/vmw_screen.h | 6 --- 6 files changed, 17 insertions(+), 54 deletions(-) diff --git a/src/gallium/auxiliary/target-helpers/drm_helper.h b/src/gallium/auxiliary/target-helpers/drm_helper.h index 90820d3..a042162 100644 --- a/src/gallium/auxiliary/target-helpers/drm_helper.h +++ b/src/gallium/auxiliary/target-helpers/drm_helper.h @@ -181,7 +181,7 @@ pipe_vmwgfx_create_screen(int fd) if (!sws) return NULL; - screen = svga_screen_create(sws); + screen = svga_screen_create(sws, fd); return screen ? debug_screen_wrap(screen) : NULL; } diff --git a/src/gallium/drivers/svga/svga_public.h b/src/gallium/drivers/svga/svga_public.h index ded2e24..5a95660 100644 --- a/src/gallium/drivers/svga/svga_public.h +++ b/src/gallium/drivers/svga/svga_public.h @@ -37,6 +37,6 @@ struct pipe_screen; struct svga_winsys_screen; struct pipe_screen * -svga_screen_create(struct svga_winsys_screen *sws); +svga_screen_create(struct svga_winsys_screen *sws, int fd); #endif /* SVGA_PUBLIC_H_ */ diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 5b4ac74..b353b92 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -26,6 +26,7 @@ #include "util/u_format.h" #include "util/u_memory.h" #include "util/u_inlines.h" +#include "util/u_screen.h" #include "util/u_string.h" #include "util/u_math.h" @@ -906,7 +907,7 @@ svga_destroy_screen( struct pipe_screen *screen ) * Create a new svga_screen object */ struct pipe_screen * -svga_screen_create(struct svga_winsys_screen *sws) +svga_screen_create(struct svga_winsys_screen *sws, int fd) { struct svga_screen *svgascreen; struct pipe_screen *screen; @@ -1081,6 +1082,8 @@ svga_screen_create(struct svga_winsys_screen *sws) svga_screen_cache_init(svgascreen); + pipe_screen_reference_init(screen, dup(fd)); + return screen; error2: FREE(svgascreen); diff --git a/src/gallium/targets/pipe-loader/pipe_vmwgfx.c b/src/gallium/targets/pipe-loader/pipe_vmwgfx.c index 71015df..d246022 100644 --- a/src/gallium/targets/pipe-loader/pipe_vmwgfx.c +++ b/src/gallium/targets/pipe-loader/pipe_vmwgfx.c @@ -14,7 +14,7 @@ create_screen(int fd) if (!sws) return NULL; - screen = svga_screen_create(sws); + screen = svga_screen_create(sws, fd); if (!screen) return NULL; diff --git a/src/gallium/winsys/svga/drm/vmw_screen.c b/src/gallium/winsys/svga/drm/vmw_screen.c index 7fcb6d2..e0fa763 100644 --- a/src/gallium/winsys/svga/drm/vmw_screen.c +++ b/src/gallium/winsys/svga/drm/vmw_screen.c @@ -29,25 +29,11 @@ #include "vmw_context.h" #include "util/u_memory.h" +#include "util/u_screen.h" #include "pipe/p_compiler.h" -#include "util/u_hash_table.h" #include -#include #include -static struct util_hash_table *dev_hash = NULL; - -static int vmw_dev_compare(void *key1, void *key2) -{ - return (major(*(dev_t *)key1) == major(*(dev_t *)key2) && - minor(*(dev_t *)key1) == minor(*(dev_t *)key2)) ? 0 : 1; -} - -static unsigned vmw_dev_hash(void *key) -{ - return (major(*(dev_t *) key) << 16) | minor(*(dev_t *) key); -} - /* Called from vmw_drm_create_screen(), creates and initializes the * vmw_winsys_screen structure, which is the main entity in this * module. @@ -60,29 +46,15 @@ struct vmw_winsys_screen * vmw_winsys_create( int fd ) { struct vmw_winsys_screen *vws; - struct stat stat_buf; - - if (dev_hash == NULL) { - dev_hash = util_hash_table_create(vmw_dev_hash, vmw_dev_compare); - if (dev_hash == NULL) - return NULL; - } + struct pipe_screen *pscreen = pipe_screen_reference(fd); - if (fstat(fd, &stat_buf)) - return NULL; - - vws = util_hash_table_get(dev_hash, &stat_buf.st_rdev); - if (vws) { - vws->open_count++; - return vws; - } + if (pscreen) + return vmw_winsys_screen(svga_winsys_screen(pscreen)); vws = CALLOC_STRUCT(vmw_winsys_screen); if (!vws) goto out_no_vws; - vws->device = stat_buf.st_rdev; - vws->open_count = 1; vws->ioctl.drm_fd = dup(fd); vws->base.have_gb_dma = TRUE; vws->base.need_to_rebind_resources = FALSE; @@ -100,11 +72,8 @@ vmw_winsys_create( int fd ) if (!vmw_winsys_screen_init_svga(vws)) goto out
[Mesa-dev] [PATCH v4 02/11] pipe-loader-drm: protect create_screen() calls with a mutex
Creating a screen needs to be serialized in order to support reusing existing screen. With this, driver private mutexes in create_screen() functions can be removed. Signed-off-by: Rob Herring Cc: Emil Velikov --- src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 5 + 1 file changed, 5 insertions(+) diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c index 7bdd2ec..554e59a 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c @@ -41,6 +41,7 @@ #include "pipe_loader_priv.h" #include "pipe/p_screen.h" +#include "os/os_thread.h" #include "util/u_memory.h" #include "util/u_dl.h" #include "util/u_debug.h" @@ -63,6 +64,8 @@ struct pipe_loader_drm_device { static const struct pipe_loader_ops pipe_loader_drm_ops; +pipe_static_mutex(loader_mutex); + #ifdef GALLIUM_STATIC_TARGETS static const struct drm_conf_ret throttle_ret = { DRM_CONF_INT, @@ -303,8 +306,10 @@ pipe_loader_drm_create_screen(struct pipe_loader_device *dev) struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev); struct pipe_screen *pscreen; + pipe_mutex_lock(loader_mutex); pscreen = ddev->dd->create_screen(ddev->fd); ddev->base.pscreen = pscreen; + pipe_mutex_unlock(loader_mutex); return pscreen; } -- 2.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 07/11] amdgpu: use common screen ref counting
Use the common pipe_screen ref count. amdgpu is unique in its hashing the dev pointer rather than the fd, so the common fd hashing cannot be used. However, the same reference count can be used instead of the private one. The mutex can be dropped as the pipe loader protects the create_screen() calls. Signed-off-by: Rob Herring Cc: "Marek Olšák" Cc: Ilia Mirkin --- src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 45 --- src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h | 1 - 2 files changed, 6 insertions(+), 40 deletions(-) diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c index 9a04cbe..27293ac 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c @@ -60,8 +60,6 @@ #define CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_16X16 17 static struct util_hash_table *dev_tab = NULL; -pipe_static_mutex(dev_tab_mutex); - static unsigned cik_get_num_tile_pipes(struct amdgpu_gpu_info *info) { unsigned mode2d = info->gb_tile_mode[CIK_TILE_MODE_COLOR_2D]; @@ -329,6 +327,7 @@ static void amdgpu_winsys_destroy(struct radeon_winsys *rws) pipe_mutex_destroy(ws->global_bo_list_lock); AddrDestroy(ws->addrlib); amdgpu_device_deinitialize(ws->dev); + util_hash_table_remove(dev_tab, ws->dev); FREE(rws); } @@ -410,26 +409,6 @@ static int compare_dev(void *key1, void *key2) DEBUG_GET_ONCE_BOOL_OPTION(thread, "RADEON_THREAD", true) -static bool amdgpu_winsys_unref(struct radeon_winsys *rws) -{ - struct amdgpu_winsys *ws = (struct amdgpu_winsys*)rws; - bool destroy; - - /* When the reference counter drops to zero, remove the device pointer -* from the table. -* This must happen while the mutex is locked, so that -* amdgpu_winsys_create in another thread doesn't get the winsys -* from the table when the counter drops to 0. */ - pipe_mutex_lock(dev_tab_mutex); - - destroy = pipe_reference(&ws->reference, NULL); - if (destroy && dev_tab) - util_hash_table_remove(dev_tab, ws->dev); - - pipe_mutex_unlock(dev_tab_mutex); - return destroy; -} - PUBLIC struct radeon_winsys * amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create) { @@ -446,7 +425,6 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create) drmFreeVersion(version); /* Look up the winsys from the dev table. */ - pipe_mutex_lock(dev_tab_mutex); if (!dev_tab) dev_tab = util_hash_table_create(hash_dev, compare_dev); @@ -454,7 +432,6 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create) * for the same fd. */ r = amdgpu_device_initialize(fd, &drm_major, &drm_minor, &dev); if (r) { - pipe_mutex_unlock(dev_tab_mutex); fprintf(stderr, "amdgpu: amdgpu_device_initialize failed.\n"); return NULL; } @@ -462,17 +439,14 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create) /* Lookup a winsys if we have already created one for this device. */ ws = util_hash_table_get(dev_tab, dev); if (ws) { - pipe_reference(NULL, &ws->reference); - pipe_mutex_unlock(dev_tab_mutex); + pipe_reference(NULL, &ws->base.screen->reference); return &ws->base; } /* Create a new winsys. */ ws = CALLOC_STRUCT(amdgpu_winsys); - if (!ws) { - pipe_mutex_unlock(dev_tab_mutex); + if (!ws) return NULL; - } ws->dev = dev; ws->info.drm_major = drm_major; @@ -486,11 +460,7 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create) (ws->info.vram_size + ws->info.gart_size) / 8, amdgpu_bo_destroy, amdgpu_bo_can_reclaim); - /* init reference */ - pipe_reference_init(&ws->reference, 1); - /* Set functions. */ - ws->base.unref = amdgpu_winsys_unref; ws->base.destroy = amdgpu_winsys_destroy; ws->base.query_info = amdgpu_winsys_query_info; ws->base.cs_request_feature = amdgpu_cs_request_feature; @@ -516,21 +486,18 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create) ws->base.screen = screen_create(&ws->base); if (!ws->base.screen) { amdgpu_winsys_destroy(&ws->base); - pipe_mutex_unlock(dev_tab_mutex); return NULL; } util_hash_table_set(dev_tab, dev, ws); - /* We must unlock the mutex once the winsys is fully initialized, so that -* other threads attempting to create the winsys from the same fd will -* get a fully initialized winsys and not just half-way initialized. */ - pipe_mutex_unlock(dev_tab_mutex); + /* init reference */ + pipe_reference_init(&ws->base.screen->reference, 1); + ws->base.screen->fd = -1; return &ws->base; fail: - pipe_mutex_unlock(dev_tab_mutex); pb_cache_deinit(&ws->bo_c
[Mesa-dev] [PATCH v4 01/11] gallium: move pipe_screen destroy into pipe-loader
In preparation to add reference counting of pipe_screen in the pipe-loader, pipe_loader_release needs to destroy the pipe_screen instead of state trackers. Signed-off-by: Rob Herring Cc: Emil Velikov --- src/gallium/auxiliary/pipe-loader/pipe_loader.h | 1 + src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 9 - src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 6 ++ src/gallium/auxiliary/vl/vl_winsys_dri.c| 1 - src/gallium/auxiliary/vl/vl_winsys_dri3.c | 1 - src/gallium/auxiliary/vl/vl_winsys_drm.c| 1 - src/gallium/state_trackers/clover/core/device.cpp | 4 +--- src/gallium/state_trackers/dri/dri_screen.c | 3 --- src/gallium/state_trackers/xa/xa_tracker.c | 2 -- src/gallium/tests/trivial/compute.c | 1 - src/gallium/tests/trivial/quad-tex.c| 1 - src/gallium/tests/trivial/tri.c | 1 - 12 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h b/src/gallium/auxiliary/pipe-loader/pipe_loader.h index 690d088..25cd4d1 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h @@ -65,6 +65,7 @@ struct pipe_loader_device { char *driver_name; const struct pipe_loader_ops *ops; + struct pipe_screen *pscreen; }; /** diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c index 994a284..7bdd2ec 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c @@ -39,6 +39,7 @@ #include "target-helpers/drm_helper_public.h" #include "state_tracker/drm_driver.h" #include "pipe_loader_priv.h" +#include "pipe/p_screen.h" #include "util/u_memory.h" #include "util/u_dl.h" @@ -269,6 +270,9 @@ static void pipe_loader_drm_release(struct pipe_loader_device **dev) { struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(*dev); + struct pipe_screen *pscreen = ddev->base.pscreen; + + pscreen->destroy(pscreen); #ifndef GALLIUM_STATIC_TARGETS if (ddev->lib) @@ -297,8 +301,11 @@ static struct pipe_screen * pipe_loader_drm_create_screen(struct pipe_loader_device *dev) { struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev); + struct pipe_screen *pscreen; - return ddev->dd->create_screen(ddev->fd); + pscreen = ddev->dd->create_screen(ddev->fd); + ddev->base.pscreen = pscreen; + return pscreen; } static const struct pipe_loader_ops pipe_loader_drm_ops = { diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c index e7fa974..ce5c2b3 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c @@ -27,6 +27,7 @@ #include "pipe_loader_priv.h" +#include "pipe/p_screen.h" #include "util/u_memory.h" #include "util/u_dl.h" #include "sw/dri/dri_sw_winsys.h" @@ -271,6 +272,9 @@ static void pipe_loader_sw_release(struct pipe_loader_device **dev) { struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(*dev); + struct pipe_screen *pscreen = sdev->base.pscreen; + + pscreen->destroy(pscreen); #ifndef GALLIUM_STATIC_TARGETS if (sdev->lib) @@ -301,6 +305,8 @@ pipe_loader_sw_create_screen(struct pipe_loader_device *dev) if (!screen) sdev->ws->destroy(sdev->ws); + sdev->base.pscreen = screen; + return screen; } diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c index 9ecc216..db90c54 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_dri.c +++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c @@ -461,7 +461,6 @@ vl_dri2_screen_destroy(struct vl_screen *vscreen) } vl_dri2_destroy_drawable(scrn); - scrn->base.pscreen->destroy(scrn->base.pscreen); pipe_loader_release(&scrn->base.dev, 1); FREE(scrn); } diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c index 493e645..c8c0198 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c +++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c @@ -611,7 +611,6 @@ vl_dri3_screen_destroy(struct vl_screen *vscreen) if (scrn->special_event) xcb_unregister_for_special_event(scrn->conn, scrn->special_event); - scrn->base.pscreen->destroy(scrn->base.pscreen); pipe_loader_release(&scrn->base.dev, 1); FREE(scrn); diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c b/src/gallium/auxiliary/vl/vl_winsys_drm.c index 6a759ae..aa690a2 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_drm.c +++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c @@ -80,7 +80,6 @@ vl_drm_screen_destroy(struct vl_screen
[Mesa-dev] [PATCH v4 06/11] freedreno: use common screen ref counting
Use the common pipe_screen ref counting and fd hashing functions. The mutex can be dropped as the pipe loader protects the create_screen() calls. Signed-off-by: Rob Herring Cc: Rob Clark --- src/gallium/drivers/freedreno/freedreno_screen.c | 1 - src/gallium/drivers/freedreno/freedreno_screen.h | 10 --- .../winsys/freedreno/drm/freedreno_drm_winsys.c| 98 ++ 3 files changed, 9 insertions(+), 100 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 5255c10..324f712 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -565,7 +565,6 @@ fd_screen_create(struct fd_device *dev) pscreen = &screen->base; screen->dev = dev; - screen->refcnt = 1; // maybe this should be in context? screen->pipe = fd_pipe_new(screen->dev, FD_PIPE_3D); diff --git a/src/gallium/drivers/freedreno/freedreno_screen.h b/src/gallium/drivers/freedreno/freedreno_screen.h index a81c778..8dcacca 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.h +++ b/src/gallium/drivers/freedreno/freedreno_screen.h @@ -42,16 +42,6 @@ struct fd_bo; struct fd_screen { struct pipe_screen base; - /* it would be tempting to use pipe_reference here, but that -* really doesn't work well if it isn't the first member of -* the struct, so not quite so awesome to be adding refcnting -* further down the inheritance hierarchy: -*/ - int refcnt; - - /* place for winsys to stash it's own stuff: */ - void *winsys_priv; - uint32_t gmemsize_bytes; uint32_t device_id; uint32_t gpu_id; /* 220, 305, etc */ diff --git a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c index e4785f8..7d61ec9 100644 --- a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c +++ b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c @@ -26,102 +26,22 @@ *Rob Clark */ -#include - -#include "pipe/p_context.h" -#include "pipe/p_state.h" -#include "util/u_format.h" -#include "util/u_memory.h" -#include "util/u_inlines.h" -#include "util/u_hash_table.h" -#include "os/os_thread.h" +#include "util/u_screen.h" #include "freedreno_drm_public.h" #include "freedreno/freedreno_screen.h" -static struct util_hash_table *fd_tab = NULL; - -pipe_static_mutex(fd_screen_mutex); - -static void -fd_drm_screen_destroy(struct pipe_screen *pscreen) -{ - struct fd_screen *screen = fd_screen(pscreen); - boolean destroy; - - pipe_mutex_lock(fd_screen_mutex); - destroy = --screen->refcnt == 0; - if (destroy) { - int fd = fd_device_fd(screen->dev); - util_hash_table_remove(fd_tab, intptr_to_pointer(fd)); - } - pipe_mutex_unlock(fd_screen_mutex); - - if (destroy) { - pscreen->destroy = screen->winsys_priv; - pscreen->destroy(pscreen); - } -} - -static unsigned hash_fd(void *key) -{ - int fd = pointer_to_intptr(key); - struct stat stat; - fstat(fd, &stat); - - return stat.st_dev ^ stat.st_ino ^ stat.st_rdev; -} - -static int compare_fd(void *key1, void *key2) -{ - int fd1 = pointer_to_intptr(key1); - int fd2 = pointer_to_intptr(key2); - struct stat stat1, stat2; - fstat(fd1, &stat1); - fstat(fd2, &stat2); - - return stat1.st_dev != stat2.st_dev || - stat1.st_ino != stat2.st_ino || - stat1.st_rdev != stat2.st_rdev; -} - struct pipe_screen * fd_drm_screen_create(int fd) { - struct pipe_screen *pscreen = NULL; - - pipe_mutex_lock(fd_screen_mutex); - if (!fd_tab) { - fd_tab = util_hash_table_create(hash_fd, compare_fd); - if (!fd_tab) - goto unlock; - } - - pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd)); - if (pscreen) { - fd_screen(pscreen)->refcnt++; - } else { - struct fd_device *dev = fd_device_new_dup(fd); - if (!dev) - goto unlock; - - pscreen = fd_screen_create(dev); - if (pscreen) { - int fd = fd_device_fd(dev); - - util_hash_table_set(fd_tab, intptr_to_pointer(fd), pscreen); - - /* Bit of a hack, to avoid circular linkage dependency, -* ie. pipe driver having to call in to winsys, we -* override the pipe drivers screen->destroy(): -*/ - fd_screen(pscreen)->winsys_p
[Mesa-dev] [PATCH v4 03/11] gallium: add common pipe_screen reference counting functions
In order to prevent multiple pipe_screens being created in the same process, lookup of the DRM FD and reference counting of the pipe_screen are needed. Several implementations of this exist in various gallium drivers/winsys already. This creates a common version which is opt-in for winsys implementations. Signed-off-by: Rob Herring --- src/gallium/auxiliary/Makefile.sources | 2 + src/gallium/auxiliary/util/u_screen.c | 114 + src/gallium/auxiliary/util/u_screen.h | 32 + src/gallium/include/pipe/p_screen.h| 3 + 4 files changed, 151 insertions(+) create mode 100644 src/gallium/auxiliary/util/u_screen.c create mode 100644 src/gallium/auxiliary/util/u_screen.h diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index e0311bf..197ed36 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -284,6 +284,8 @@ C_SOURCES := \ util/u_ringbuffer.h \ util/u_sampler.c \ util/u_sampler.h \ + util/u_screen.c \ + util/u_screen.h \ util/u_simple_shaders.c \ util/u_simple_shaders.h \ util/u_slab.c \ diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c new file mode 100644 index 000..47bad11 --- /dev/null +++ b/src/gallium/auxiliary/util/u_screen.c @@ -0,0 +1,114 @@ +/* + * Copyright 2016 Linaro, Ltd., Rob Herring + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * Functions for managing pipe_screen's + */ + +#include + +#include "os/os_thread.h" + +#include "pipe/p_screen.h" +#include "util/u_hash_table.h" +#include "util/u_inlines.h" +#include "util/u_pointer.h" +#include "util/u_screen.h" + +static struct util_hash_table *fd_tab = NULL; +pipe_static_mutex(fd_tab_mutex); + +static unsigned hash_fd(void *key) +{ + int fd = pointer_to_intptr(key); + struct stat stat; + fstat(fd, &stat); + + return stat.st_dev ^ stat.st_ino ^ stat.st_rdev; +} + +static int compare_fd(void *key1, void *key2) +{ + int fd1 = pointer_to_intptr(key1); + int fd2 = pointer_to_intptr(key2); + struct stat stat1, stat2; + fstat(fd1, &stat1); + fstat(fd2, &stat2); + + return stat1.st_dev != stat2.st_dev || + stat1.st_ino != stat2.st_ino || + stat1.st_rdev != stat2.st_rdev; +} + +struct pipe_screen * +pipe_screen_reference(int fd) +{ + struct pipe_screen *pscreen; + + if (!fd_tab) { + fd_tab = util_hash_table_create(hash_fd, compare_fd); + return NULL; + } + + pipe_mutex_lock(fd_tab_mutex); + pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd)); + if (pscreen) + pipe_reference(NULL, &pscreen->reference); + pipe_mutex_unlock(fd_tab_mutex); + + return pscreen; +} + +boolean +pipe_screen_unreference(struct pipe_screen *pscreen) +{ + boolean destroy; + + if (!pscreen) + return FALSE; + + /* Work-around until all pipe_screens have ref counting */ + if (!pipe_is_referenced(&pscreen->reference)) { + pscreen->destroy(pscreen); + return TRUE; + } + + pipe_mutex_lock(fd_tab_mutex); + destroy = pipe_reference(&pscreen->reference, NULL); + if (destroy) { + pscreen->destroy(pscreen); + util_hash_table_remove(fd_tab, intptr_to_pointer(pscreen->fd)); + close(pscreen->fd); + } + pipe_mutex_unlock(fd_tab_mutex); + return destroy; +} + + +void pipe_screen_reference_init(struct pipe_screen *pscreen, int fd) +{ + pscreen->fd = fd; + pipe_reference_init(&pscreen->reference, 1); + util_hash_table_set(fd_tab, intptr_to_pointer(pscreen->fd), pscreen); +} diff --git a/src/gallium/auxiliary/util/u_screen.h b/src/gallium/auxiliary/util/u_screen.h new file mode 100644 index 000..fc91782
[Mesa-dev] [PATCH v4 10/11] virgl: use common screen ref counting
Use the common pipe_screen ref counting and fd hashing functions. The mutex can be dropped as the pipe loader protects the create_screen() calls. Signed-off-by: Rob Herring Cc: Dave Airlie --- src/gallium/winsys/virgl/drm/virgl_drm_winsys.c | 88 +++-- 1 file changed, 10 insertions(+), 78 deletions(-) diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c index 81afa84..61b041a 100644 --- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c +++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c @@ -25,7 +25,6 @@ #include #include #include -#include #include "os/os_mman.h" #include "os/os_time.h" @@ -33,6 +32,7 @@ #include "util/u_format.h" #include "util/u_hash_table.h" #include "util/u_inlines.h" +#include "util/u_screen.h" #include "state_tracker/drm_driver.h" #include "virgl/virgl_screen.h" #include "virgl/virgl_public.h" @@ -802,86 +802,18 @@ virgl_drm_winsys_create(int drmFD) } -static struct util_hash_table *fd_tab = NULL; -pipe_static_mutex(virgl_screen_mutex); - -static void -virgl_drm_screen_destroy(struct pipe_screen *pscreen) -{ - struct virgl_screen *screen = virgl_screen(pscreen); - boolean destroy; - - pipe_mutex_lock(virgl_screen_mutex); - destroy = --screen->refcnt == 0; - if (destroy) { - int fd = virgl_drm_winsys(screen->vws)->fd; - util_hash_table_remove(fd_tab, intptr_to_pointer(fd)); - } - pipe_mutex_unlock(virgl_screen_mutex); - - if (destroy) { - pscreen->destroy = screen->winsys_priv; - pscreen->destroy(pscreen); - } -} - -static unsigned hash_fd(void *key) -{ - int fd = pointer_to_intptr(key); - struct stat stat; - fstat(fd, &stat); - - return stat.st_dev ^ stat.st_ino ^ stat.st_rdev; -} - -static int compare_fd(void *key1, void *key2) -{ - int fd1 = pointer_to_intptr(key1); - int fd2 = pointer_to_intptr(key2); - struct stat stat1, stat2; - fstat(fd1, &stat1); - fstat(fd2, &stat2); - - return stat1.st_dev != stat2.st_dev || - stat1.st_ino != stat2.st_ino || - stat1.st_rdev != stat2.st_rdev; -} - struct pipe_screen * virgl_drm_screen_create(int fd) { - struct pipe_screen *pscreen = NULL; - - pipe_mutex_lock(virgl_screen_mutex); - if (!fd_tab) { - fd_tab = util_hash_table_create(hash_fd, compare_fd); - if (!fd_tab) - goto unlock; - } - - pscreen = util_hash_table_get(fd_tab, intptr_to_pointer(fd)); - if (pscreen) { - virgl_screen(pscreen)->refcnt++; - } else { - struct virgl_winsys *vws; - int dup_fd = dup(fd); - - vws = virgl_drm_winsys_create(dup_fd); - - pscreen = virgl_create_screen(vws); - if (pscreen) { - util_hash_table_set(fd_tab, intptr_to_pointer(dup_fd), pscreen); - - /* Bit of a hack, to avoid circular linkage dependency, - * ie. pipe driver having to call in to winsys, we - * override the pipe drivers screen->destroy(): - */ - virgl_screen(pscreen)->winsys_priv = pscreen->destroy; - pscreen->destroy = virgl_drm_screen_destroy; - } - } + int dupfd; + struct virgl_winsys *vws; + struct pipe_screen *pscreen = pipe_screen_reference(fd); + if (pscreen) + return pscreen; -unlock: - pipe_mutex_unlock(virgl_screen_mutex); + dupfd = dup(fd); + vws = virgl_drm_winsys_create(dupfd); + pscreen = virgl_create_screen(vws); + pipe_screen_reference_init(pscreen, dupfd); return pscreen; } -- 2.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 04/11] pipe-loader-drm: use pipe_screen_unreference to destroy screen
Use pipe_screen_unreference as it will call pipe_screen->destroy() when the pipe_screen is no longer referenced. The pipe_screen referencing is done within create_screen() functions as drivers (like amdgpu) may have special needs for ref counting. Signed-off-by: Rob Herring Cc: Emil Velikov --- src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c index 554e59a..2edb291 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c @@ -45,6 +45,7 @@ #include "util/u_memory.h" #include "util/u_dl.h" #include "util/u_debug.h" +#include "util/u_screen.h" #define DRM_RENDER_NODE_DEV_NAME_FORMAT "%s/renderD%d" #define DRM_RENDER_NODE_MAX_NODES 63 @@ -275,7 +276,7 @@ pipe_loader_drm_release(struct pipe_loader_device **dev) struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(*dev); struct pipe_screen *pscreen = ddev->base.pscreen; - pscreen->destroy(pscreen); + pipe_screen_unreference(pscreen); #ifndef GALLIUM_STATIC_TARGETS if (ddev->lib) -- 2.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 11/11] vc4: use common screen ref counting
Use the common pipe_screen ref counting and fd hashing functions for vc4. This is necessary to only create a single pipe_screen for a process and avoid multiple imports of same prime fd among other things (probably). Cc: Eric Anholt Signed-off-by: Rob Herring --- src/gallium/winsys/vc4/drm/vc4_drm_winsys.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c b/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c index c5434ad..e0d9cc2 100644 --- a/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c +++ b/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c @@ -22,6 +22,7 @@ */ #include +#include "util/u_screen.h" #include "vc4_drm_public.h" @@ -30,5 +31,13 @@ struct pipe_screen * vc4_drm_screen_create(int fd) { - return vc4_screen_create(dup(fd)); + int dupfd; + struct pipe_screen *pscreen = pipe_screen_reference(fd); + if (pscreen) + return pscreen; + + dupfd = dup(fd); + pscreen = vc4_screen_create(dupfd); + pipe_screen_reference_init(pscreen, dupfd); + return pscreen; } -- 2.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v4 08/11] radeon: use common screen ref counting
Use the common pipe_screen ref counting and fd hashing functions. The mutex can be dropped as the pipe loader protects the create_screen() calls. Signed-off-by: Rob Herring Cc: "Marek Olšák" Cc: Ilia Mirkin --- src/gallium/drivers/r300/r300_screen.c| 3 - src/gallium/drivers/r600/r600_pipe.c | 6 -- src/gallium/drivers/radeon/radeon_winsys.h| 8 --- src/gallium/drivers/radeonsi/si_pipe.c| 6 -- src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 80 ++- 5 files changed, 6 insertions(+), 97 deletions(-) diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index d47b70d..1340009 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -676,9 +676,6 @@ static void r300_destroy_screen(struct pipe_screen* pscreen) struct r300_screen* r300screen = r300_screen(pscreen); struct radeon_winsys *rws = radeon_winsys(pscreen); -if (rws && !rws->unref(rws)) - return; - pipe_mutex_destroy(r300screen->cmask_mutex); if (rws) diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index f23daf9..c645295 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -570,12 +570,6 @@ static void r600_destroy_screen(struct pipe_screen* pscreen) { struct r600_screen *rscreen = (struct r600_screen *)pscreen; - if (!rscreen) - return; - - if (!rscreen->b.ws->unref(rscreen->b.ws)) - return; - if (rscreen->global_pool) { compute_memory_pool_delete(rscreen->global_pool); } diff --git a/src/gallium/drivers/radeon/radeon_winsys.h b/src/gallium/drivers/radeon/radeon_winsys.h index a9c9b9e..2ca19f4 100644 --- a/src/gallium/drivers/radeon/radeon_winsys.h +++ b/src/gallium/drivers/radeon/radeon_winsys.h @@ -426,14 +426,6 @@ struct radeon_winsys { struct pipe_screen *screen; /** - * Decrement the winsys reference count. - * - * \param ws The winsys this function is called for. - * \returnTrue if the winsys and screen should be destroyed. - */ -bool (*unref)(struct radeon_winsys *ws); - -/** * Destroy this winsys. * * \param wsThe winsys this function is called from. diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index ee97bcf..1c6920c 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -657,12 +657,6 @@ static void si_destroy_screen(struct pipe_screen* pscreen) }; unsigned i; - if (!sscreen) - return; - - if (!sscreen->b.ws->unref(sscreen->b.ws)) - return; - if (util_queue_is_initialized(&sscreen->shader_compiler_queue)) util_queue_destroy(&sscreen->shader_compiler_queue); diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c index 1b32c37..355197c 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c @@ -38,11 +38,11 @@ #include "pipebuffer/pb_bufmgr.h" #include "util/u_memory.h" #include "util/u_hash_table.h" +#include "util/u_screen.h" #include #include #include -#include #include #include @@ -63,9 +63,6 @@ #define RADEON_INFO_GPU_RESET_COUNTER 0x26 #endif -static struct util_hash_table *fd_tab = NULL; -pipe_static_mutex(fd_tab_mutex); - /* Enable/disable feature access for one command stream. * If enable == true, return true on success. * Otherwise, return false. @@ -558,9 +555,6 @@ static void radeon_winsys_destroy(struct radeon_winsys *rws) pipe_mutex_destroy(ws->bo_handles_mutex); pipe_mutex_destroy(ws->bo_va_mutex); -if (ws->fd >= 0) -close(ws->fd); - FREE(rws); } @@ -665,49 +659,8 @@ static bool radeon_read_registers(struct radeon_winsys *rws, return true; } -static unsigned hash_fd(void *key) -{ -int fd = pointer_to_intptr(key); -struct stat stat; -fstat(fd, &stat); - -return stat.st_dev ^ stat.st_ino ^ stat.st_rdev; -} - -static int compare_fd(void *key1, void *key2) -{ -int fd1 = pointer_to_intptr(key1); -int fd2 = pointer_to_intptr(key2); -struct stat stat1, stat2; -fstat(fd1, &stat1); -fstat(fd2, &stat2); - -return stat1.st_dev != stat2.st_dev || - stat1.st_ino != stat2.st_ino || - stat1.st_rdev != stat2.st_rdev; -} - DEBUG_GET_ONCE_BOOL_OPTION(thread, "RADEON_THREAD", true) -static bool radeon_winsys_unref(struct radeon_winsys *ws) -{ -struct radeon_drm_winsys *rws = (struct radeon_drm_winsys*)ws; -bool destroy; -
[Mesa-dev] [PATCH v4 05/11] nouveau: use common screen ref counting
Use the common pipe_screen ref counting and fd hashing functions. The mutex can be dropped as the pipe loader protects the create_screen() calls. Signed-off-by: Rob Herring Cc: Alexandre Courbot --- src/gallium/drivers/nouveau/nouveau_screen.c | 6 -- src/gallium/drivers/nouveau/nouveau_screen.h | 4 -- src/gallium/drivers/nouveau/nv30/nv30_screen.c | 3 - src/gallium/drivers/nouveau/nv50/nv50_screen.c | 3 - src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 3 - .../winsys/nouveau/drm/nouveau_drm_winsys.c| 69 ++ 6 files changed, 5 insertions(+), 83 deletions(-) diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 2c421cc..41d4bef 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -159,12 +159,6 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) screen->drm = nouveau_drm(&dev->object); screen->device = dev; - /* -* this is initialized to 1 in nouveau_drm_screen_create after screen -* is fully constructed and added to the global screen list. -*/ - screen->refcount = -1; - if (dev->chipset < 0xc0) { data = &nv04_data; size = sizeof(nv04_data); diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h index 28c4760..55156c3 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.h +++ b/src/gallium/drivers/nouveau/nouveau_screen.h @@ -23,8 +23,6 @@ struct nouveau_screen { struct nouveau_client *client; struct nouveau_pushbuf *pushbuf; - int refcount; - unsigned vidmem_bindings; /* PIPE_BIND_* where VRAM placement is desired */ unsigned sysmem_bindings; /* PIPE_BIND_* where GART placement is desired */ unsigned lowmem_bindings; /* PIPE_BIND_* that require an address < 4 GiB */ @@ -119,8 +117,6 @@ nouveau_screen(struct pipe_screen *pscreen) return (struct nouveau_screen *)pscreen; } -bool nouveau_drm_screen_unref(struct nouveau_screen *screen); - bool nouveau_screen_bo_get_handle(struct pipe_screen *pscreen, struct nouveau_bo *bo, diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c b/src/gallium/drivers/nouveau/nv30/nv30_screen.c index 68d8317..591cf92 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c @@ -408,9 +408,6 @@ nv30_screen_destroy(struct pipe_screen *pscreen) { struct nv30_screen *screen = nv30_screen(pscreen); - if (!nouveau_drm_screen_unref(&screen->base)) - return; - if (screen->base.fence.current) { struct nouveau_fence *current = NULL; diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c b/src/gallium/drivers/nouveau/nv50/nv50_screen.c index 303ecf1..7dbf66f 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c @@ -428,9 +428,6 @@ nv50_screen_destroy(struct pipe_screen *pscreen) { struct nv50_screen *screen = nv50_screen(pscreen); - if (!nouveau_drm_screen_unref(&screen->base)) - return; - if (screen->base.fence.current) { struct nouveau_fence *current = NULL; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c index f681631..f789de4 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c @@ -485,9 +485,6 @@ nvc0_screen_destroy(struct pipe_screen *pscreen) { struct nvc0_screen *screen = nvc0_screen(pscreen); - if (!nouveau_drm_screen_unref(&screen->base)) - return; - if (screen->base.fence.current) { struct nouveau_fence *current = NULL; diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c index f90572f..d208d9c 100644 --- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c +++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c @@ -1,12 +1,9 @@ -#include #include #include "pipe/p_context.h" #include "pipe/p_state.h" #include "util/u_format.h" #include "util/u_memory.h" -#include "util/u_inlines.h" -#include "util/u_hash_table.h" -#include "os/os_thread.h" +#include "util/u_screen.h" #include "nouveau_drm_public.h" @@ -16,47 +13,6 @@ #include #include -static struct util_hash_table *fd_tab = NULL; - -pipe_static_mutex(nouveau_screen_mutex); - -bool nouveau_drm_screen_unref(struct nouveau_screen *screen) -{ - int ret; - if (screen->refcount == -1) - return true; - - pipe_mutex_lock(nouveau_screen_mutex); - ret = --screen->refcount; - assert(ret >= 0); - if (ret == 0) - util_hash_table_remove(f
Re: [Mesa-dev] [PATCH v4 03/11] gallium: add common pipe_screen reference counting functions
On Fri, Jul 22, 2016 at 11:46 AM, Ilia Mirkin wrote: > On Fri, Jul 22, 2016 at 12:22 PM, Rob Herring wrote: >> In order to prevent multiple pipe_screens being created in the same >> process, lookup of the DRM FD and reference counting of the pipe_screen >> are needed. Several implementations of this exist in various gallium >> drivers/winsys already. This creates a common version which is opt-in >> for winsys implementations. >> >> Signed-off-by: Rob Herring >> --- >> src/gallium/auxiliary/Makefile.sources | 2 + >> src/gallium/auxiliary/util/u_screen.c | 114 >> + >> src/gallium/auxiliary/util/u_screen.h | 32 + >> src/gallium/include/pipe/p_screen.h| 3 + >> 4 files changed, 151 insertions(+) >> create mode 100644 src/gallium/auxiliary/util/u_screen.c >> create mode 100644 src/gallium/auxiliary/util/u_screen.h >> >> diff --git a/src/gallium/auxiliary/Makefile.sources >> b/src/gallium/auxiliary/Makefile.sources >> index e0311bf..197ed36 100644 >> --- a/src/gallium/auxiliary/Makefile.sources >> +++ b/src/gallium/auxiliary/Makefile.sources >> @@ -284,6 +284,8 @@ C_SOURCES := \ >> util/u_ringbuffer.h \ >> util/u_sampler.c \ >> util/u_sampler.h \ >> + util/u_screen.c \ >> + util/u_screen.h \ >> util/u_simple_shaders.c \ >> util/u_simple_shaders.h \ >> util/u_slab.c \ >> diff --git a/src/gallium/auxiliary/util/u_screen.c >> b/src/gallium/auxiliary/util/u_screen.c >> new file mode 100644 >> index 000..47bad11 >> --- /dev/null >> +++ b/src/gallium/auxiliary/util/u_screen.c >> @@ -0,0 +1,114 @@ >> +/* >> + * Copyright 2016 Linaro, Ltd., Rob Herring >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining a >> + * copy of this software and associated documentation files (the >> + * "Software"), to deal in the Software without restriction, including >> + * without limitation the rights to use, copy, modify, merge, publish, >> + * distribute, sub license, and/or sell copies of the Software, and to >> + * permit persons to whom the Software is furnished to do so, subject to >> + * the following conditions: >> + * >> + * The above copyright notice and this permission notice (including the >> + * next paragraph) shall be included in all copies or substantial portions >> + * of the Software. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS >> + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >> + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. >> + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR >> + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, >> + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE >> + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. >> + */ >> + >> +/** >> + * Functions for managing pipe_screen's >> + */ >> + >> +#include >> + >> +#include "os/os_thread.h" >> + >> +#include "pipe/p_screen.h" >> +#include "util/u_hash_table.h" >> +#include "util/u_inlines.h" >> +#include "util/u_pointer.h" >> +#include "util/u_screen.h" >> + >> +static struct util_hash_table *fd_tab = NULL; >> +pipe_static_mutex(fd_tab_mutex); >> + >> +static unsigned hash_fd(void *key) >> +{ >> + int fd = pointer_to_intptr(key); >> + struct stat stat; >> + fstat(fd, &stat); >> + >> + return stat.st_dev ^ stat.st_ino ^ stat.st_rdev; >> +} >> + >> +static int compare_fd(void *key1, void *key2) >> +{ >> + int fd1 = pointer_to_intptr(key1); >> + int fd2 = pointer_to_intptr(key2); >> + struct stat stat1, stat2; >> + fstat(fd1, &stat1); >> + fstat(fd2, &stat2); >> + >> + return stat1.st_dev != stat2.st_dev || >> + stat1.st_ino != stat2.st_ino || >> + stat1.st_rdev != stat2.st_rdev; >> +} >> + >> +struct pipe_screen * >> +pipe_screen_reference(int fd) >> +{ >> + struct pipe_screen *pscreen; >> + >> + if (!fd_tab) { >> + fd_tab = util_hash_table_create(hash_fd, compare_fd); > > Do you need to grab the fd_tab_mutex around this? What if two > pipe_screen_reference() calls race to be the first ones? No, but only because the loa
[Mesa-dev] [PATCH v2] vc4: add hash table look-up for exported dmabufs
It is necessary to reuse existing BOs when dmabufs are imported. There are 2 cases that need to be handled. dmabufs can be created/exported and imported by the same process and can be imported multiple times. Copying other drivers, add a hash table to track exported BOs so the BOs get reused. Cc: Eric Anholt Signed-off-by: Rob Herring --- v2: - Avoid taking mutex on unreference if private - Fix use after free with util_hash_table_remove src/gallium/drivers/vc4/vc4_bufmgr.c | 20 +++- src/gallium/drivers/vc4/vc4_bufmgr.h | 19 ++- src/gallium/drivers/vc4/vc4_screen.c | 15 +++ src/gallium/drivers/vc4/vc4_screen.h | 3 +++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.c b/src/gallium/drivers/vc4/vc4_bufmgr.c index 21e3bde..f6bacfd 100644 --- a/src/gallium/drivers/vc4/vc4_bufmgr.c +++ b/src/gallium/drivers/vc4/vc4_bufmgr.c @@ -28,6 +28,7 @@ #include #include +#include "util/u_hash_table.h" #include "util/u_memory.h" #include "util/ralloc.h" @@ -329,10 +330,19 @@ vc4_bo_open_handle(struct vc4_screen *screen, uint32_t winsys_stride, uint32_t handle, uint32_t size) { -struct vc4_bo *bo = CALLOC_STRUCT(vc4_bo); +struct vc4_bo *bo; assert(size); +pipe_mutex_lock(screen->bo_handles_mutex); + +bo = util_hash_table_get(screen->bo_handles, (void*)(uintptr_t)handle); +if (bo) { +pipe_reference(NULL, &bo->reference); +goto done; +} + +bo = CALLOC_STRUCT(vc4_bo); pipe_reference_init(&bo->reference, 1); bo->screen = screen; bo->handle = handle; @@ -347,6 +357,10 @@ vc4_bo_open_handle(struct vc4_screen *screen, bo->map = malloc(bo->size); #endif +util_hash_table_set(screen->bo_handles, (void *)(uintptr_t)handle, bo); + +done: +pipe_mutex_unlock(screen->bo_handles_mutex); return bo; } @@ -399,7 +413,11 @@ vc4_bo_get_dmabuf(struct vc4_bo *bo) bo->handle); return -1; } + +pipe_mutex_lock(bo->screen->bo_handles_mutex); bo->private = false; +util_hash_table_set(bo->screen->bo_handles, (void *)(uintptr_t)bo->handle, bo); +pipe_mutex_unlock(bo->screen->bo_handles_mutex); return fd; } diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.h b/src/gallium/drivers/vc4/vc4_bufmgr.h index b77506e..c84b850 100644 --- a/src/gallium/drivers/vc4/vc4_bufmgr.h +++ b/src/gallium/drivers/vc4/vc4_bufmgr.h @@ -25,6 +25,7 @@ #define VC4_BUFMGR_H #include +#include "util/u_hash_table.h" #include "util/u_inlines.h" #include "vc4_qir.h" @@ -87,11 +88,27 @@ vc4_bo_reference(struct vc4_bo *bo) static inline void vc4_bo_unreference(struct vc4_bo **bo) { +struct vc4_screen *screen; if (!*bo) return; -if (pipe_reference(&(*bo)->reference, NULL)) +if ((*bo)->private) { +/* Avoid the mutex for private BOs */ +if (pipe_reference(&(*bo)->reference, NULL)) vc4_bo_last_unreference(*bo); +} else { +screen = (*bo)->screen; +pipe_mutex_lock(screen->bo_handles_mutex); + +if (pipe_reference(&(*bo)->reference, NULL)) { +util_hash_table_remove(screen->bo_handles, + (void *)(uintptr_t)(*bo)->handle); +vc4_bo_last_unreference(*bo); +} + +pipe_mutex_unlock(screen->bo_handles_mutex); +} + *bo = NULL; } diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c index 29c0f94..82544e0 100644 --- a/src/gallium/drivers/vc4/vc4_screen.c +++ b/src/gallium/drivers/vc4/vc4_screen.c @@ -30,6 +30,7 @@ #include "util/u_debug.h" #include "util/u_memory.h" #include "util/u_format.h" +#include "util/u_hash_table.h" #include "util/ralloc.h" #include "vc4_screen.h" @@ -496,6 +497,18 @@ vc4_screen_is_format_supported(struct pipe_screen *pscreen, return retval == usage; } +#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x))) + +static unsigned handle_hash(void *key) +{ +return PTR_TO_UINT(key); +} + +static int handle_compare(void *key1, void *key2) +{ +return PTR_TO_UINT(key1) != PTR_TO_UINT(key2); +} + static bool vc4_supports_branches(struct vc4_screen *screen) { @@ -523,6 +536,8 @@ vc4_screen_create(int fd) screen->fd = fd; list_inithead(&screen->bo_cache.time_list); +pipe_mutex_init(screen->bo_handles_mutex); +screen->bo_handles = util_hash_table_create(handle_hash, handle_com
Re: [Mesa-dev] [PATCH v4 01/11] gallium: move pipe_screen destroy into pipe-loader
On Tue, Jul 26, 2016 at 4:15 AM, Emil Velikov wrote: > On 22 July 2016 at 17:22, Rob Herring wrote: >> In preparation to add reference counting of pipe_screen in the pipe-loader, >> pipe_loader_release needs to destroy the pipe_screen instead of state >> trackers. >> >> Signed-off-by: Rob Herring >> Cc: Emil Velikov > >> --- a/src/gallium/state_trackers/clover/core/device.cpp >> +++ b/src/gallium/state_trackers/clover/core/device.cpp >> @@ -45,14 +45,12 @@ device::device(clover::platform &platform, >> pipe_loader_device *ldev) : >> pipe = pipe_loader_create_screen(ldev); >> if (!pipe || !pipe->get_param(pipe, PIPE_CAP_COMPUTE)) { >>if (pipe) >> - pipe->destroy(pipe); >> + pipe_loader_release(&ldev, 1); > My C++ is a bit rusty - are we going to end up using device::ldev here > or the one provided by the user ? I believe this->ldev would be device::ldev and this is the parameter ldev. Probably would be best to rename one of them. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/3] freedreno/a2xx: Fix sign compare warnings
On Thu, Jun 30, 2016 at 12:16 PM, Francesco Ansanelli wrote: > --- > src/gallium/drivers/freedreno/a2xx/fd2_screen.c |8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_screen.c > b/src/gallium/drivers/freedreno/a2xx/fd2_screen.c > index c2baa6f..fe4849b 100644 > --- a/src/gallium/drivers/freedreno/a2xx/fd2_screen.c > +++ b/src/gallium/drivers/freedreno/a2xx/fd2_screen.c > @@ -61,7 +61,7 @@ fd2_screen_is_format_supported(struct pipe_screen *pscreen, > > if ((usage & (PIPE_BIND_SAMPLER_VIEW | > PIPE_BIND_VERTEX_BUFFER)) && > - (fd2_pipe2surface(format) != ~0)) { > + (fd2_pipe2surface(format) != ~0u)) { FYI, all these still warn with LLVM, but now the warning is about being out of range: external/mesa3d/src/gallium/drivers/freedreno/a2xx/fd2_screen.c:64:30: warning: comparison of constant 4294967295 with expression of type 'enum a2xx_sq_surfaceformat' is always true [-Wtautological-constant-out-of-range-compare] (fd2_pipe2surface(format) != ~0u)) { ^ ~~~ Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/4] freedreno/ir3: Add missing braces in initializer
On Thu, Jul 28, 2016 at 1:07 PM, Rob Clark wrote: > tbh, I haven't used anything as ancient as 4.6 in a while.. these days > I'm using 6.1 and even with 5.x I don't remember seeing that warning. FWIW, clang 3.8 throws the warning too. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/3] freedreno/a2xx: Fix sign compare warnings
On Thu, Jul 28, 2016 at 6:55 PM, Rob Clark wrote: > On Thu, Jul 28, 2016 at 6:36 PM, Rob Herring wrote: >> On Thu, Jun 30, 2016 at 12:16 PM, Francesco Ansanelli >> wrote: >>> --- >>> src/gallium/drivers/freedreno/a2xx/fd2_screen.c |8 >>> 1 file changed, 4 insertions(+), 4 deletions(-) >>> >>> diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_screen.c >>> b/src/gallium/drivers/freedreno/a2xx/fd2_screen.c >>> index c2baa6f..fe4849b 100644 >>> --- a/src/gallium/drivers/freedreno/a2xx/fd2_screen.c >>> +++ b/src/gallium/drivers/freedreno/a2xx/fd2_screen.c >>> @@ -61,7 +61,7 @@ fd2_screen_is_format_supported(struct pipe_screen >>> *pscreen, >>> >>> if ((usage & (PIPE_BIND_SAMPLER_VIEW | >>> PIPE_BIND_VERTEX_BUFFER)) && >>> - (fd2_pipe2surface(format) != ~0)) { >>> + (fd2_pipe2surface(format) != ~0u)) { >> >> FYI, all these still warn with LLVM, but now the warning is about >> being out of range: >> >> external/mesa3d/src/gallium/drivers/freedreno/a2xx/fd2_screen.c:64:30: >> warning: comparison of constant 4294967295 with expression of type >> 'enum a2xx_sq_surfaceformat' is always true >> [-Wtautological-constant-out-of-range-compare] >> (fd2_pipe2surface(format) != ~0u)) { >> ^ ~~~ > > bleh.. I guess it depends on whether enums are signed or unsigned? > > maybe (enum a2xx_sq_surfaceformat)~0 then? Or add the error value to the enums. Rob P.S. This is why I hate enums. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v4 07/11] amdgpu: use common screen ref counting
On Fri, Jul 29, 2016 at 12:51 PM, Marek Olšák wrote: > The fd table and reference counting in the winsys is required by the > GL-VDPAU interop. > > radeon_drm_winsys_create and amdgpu_winsys_create are publicly > exported by both *_dri.so and libvdpau_*.so, and whichever is loaded > first will effectively provide the gallium driver implementation for > both of them. The second loaded lib can't create its own winsys & > screen & contexts because of the public *_winsys_create functions > always invoking the first loaded lib. Yes, I'm aware of this as it was discussed in the RFC version, and it was my intent to maintain that. I believe this version should support this case as the ref counting is done within radeon_drm_winsys_create/amdgpu_winsys_create. Where specifically do you think it is broken? Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 3/7] egl/android: Fix support for pbuffers (v2)
On Tue, Aug 2, 2016 at 6:07 AM, Tomasz Figa wrote: > From: Nicolas Boichat > > Existing image loader code supports creating images only for window > surfaces. Moreover droid_create_surface() passes wrong surface type to > dri2_get_dri_config(), resulting in incorrect configs being returned for > pbuffers. This patch fixes these issues. > > In addition, the config generation code is fixed to include single > buffered contexts required for pbuffers and make sure that generated > configs support only surfaces which can handle their supported buffering > modes. > > v2: Return error only in case of real error condition and ignore requests > of unavailable buffers. > Improve coding style. This still breaks Android for me. Just adding the hunks below is enough to break things. It results in get_buffers() being called with type == EGL_WINDOW_BIT and buffer_mask == __DRI_IMAGE_BUFFER_FRONT. I don't see any requests for the front buffer without this change. I've looked through the tree, but don't really see what would cause buffer_mask to change. > diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h > index 4577875..3da6bef 100644 > --- a/src/egl/drivers/dri2/egl_dri2.h > +++ b/src/egl/drivers/dri2/egl_dri2.h > @@ -291,6 +291,7 @@ struct dri2_egl_surface > struct ANativeWindow *window; > struct ANativeWindowBuffer *buffer; > __DRIimage *dri_image; > + __DRIimage *dri_front_image; > > /* EGL-owned buffers */ > __DRIbuffer *local_buffers[__DRI_BUFFER_COUNT]; > diff --git a/src/egl/drivers/dri2/platform_android.c > b/src/egl/drivers/dri2/platform_android.c > index d78c06d..420436c 100644 > --- a/src/egl/drivers/dri2/platform_android.c > +++ b/src/egl/drivers/dri2/platform_android.c > @@ -286,7 +286,7 @@ droid_create_surface(_EGLDriver *drv, _EGLDisplay *disp, > EGLint type, >window->query(window, NATIVE_WINDOW_HEIGHT, &dri2_surf->base.Height); > } > > - config = dri2_get_dri_config(dri2_conf, EGL_WINDOW_BIT, > + config = dri2_get_dri_config(dri2_conf, type, > dri2_surf->base.GLColorspace); > if (!config) >goto cleanup_surface; > @@ -347,6 +347,9 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, > _EGLSurface *surf) >dri2_surf->window->common.decRef(&dri2_surf->window->common); > } > > + if (dri2_surf->dri_front_image) > + dri2_dpy->image->destroyImage(dri2_surf->dri_front_image); > + > (*dri2_dpy->core->destroyDrawable)(dri2_surf->dri_drawable); > > free(dri2_surf); > @@ -696,14 +725,6 @@ droid_add_configs_for_visuals(_EGLDriver *drv, > _EGLDisplay *dpy) >for (j = 0; dri2_dpy->driver_configs[j]; j++) { > const EGLint surface_type = EGL_WINDOW_BIT | EGL_PBUFFER_BIT; > struct dri2_egl_config *dri2_conf; > - unsigned int double_buffered = 0; > - > - dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[j], > -__DRI_ATTRIB_DOUBLE_BUFFER, &double_buffered); > - > - /* support only double buffered configs */ > - if (!double_buffered) > -continue; > > dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[j], > count + 1, surface_type, config_attrs, visuals[i].rgba_masks); > @@ -726,6 +747,19 @@ droid_add_configs_for_visuals(_EGLDriver *drv, > _EGLDisplay *dpy) >/* there is no front buffer so no OpenGL */ >dri2_conf->base.RenderableType &= ~EGL_OPENGL_BIT; >dri2_conf->base.Conformant &= ~EGL_OPENGL_BIT; > + > + for (j = 0; j < 2; j++) { > + /* Unsupported color space variants should not affect surface type. > */ > + if (!dri2_conf->dri_single_config[j] && > !dri2_conf->dri_double_config[j]) > +continue; > + > + /* Pbuffers support only single buffering. */ > + if (!dri2_conf->dri_single_config[j]) > +dri2_conf->base.SurfaceType &= ~EGL_PBUFFER_BIT; > + /* Windows support only double buffering. */ > + if (!dri2_conf->dri_double_config[j]) > +dri2_conf->base.SurfaceType &= ~EGL_WINDOW_BIT; > + } > } > > return (count != 0); > -- > 2.8.0.rc3.226.g39d4020 > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 2/7] egl/android: Respect buffer mask in droid_image_get_buffers (v2)
On Tue, Aug 2, 2016 at 6:07 AM, Tomasz Figa wrote: > Drivers can request different set of buffers depending on the buffer > mask they pass to the get_buffers callback. This patch makes > droid_image_get_buffers() respect this mask. > > v2: Return error only in case of real error condition and ignore requests > of unavailable buffers. > > Signed-off-by: Tomasz Figa Tested-by: Rob Herring ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 1/7] egl/android: Remove unused variables in droid_get_buffers_with_format()
On Tue, Aug 2, 2016 at 6:07 AM, Tomasz Figa wrote: > Fix compilation warnings due to unused variables left after some earlier > code changes. > > Signed-off-by: Tomasz Figa Tested-by: Rob Herring ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 5/7] egl/android: Make get_fourcc() accept HAL formats
On Tue, Aug 2, 2016 at 6:07 AM, Tomasz Figa wrote: > There are DRI_IMAGE_FOURCC macros, for which there are no corresponding > DRI_IMAGE_FORMAT macros. To support such formats we need to make the > lookup function take the native format directly. As a side effect, it > simplifies all existing calls to this function, because they all called > get_format() first to convert from native to DRI_IMAGE_FORMAT. > > Signed-off-by: Tomasz Figa Tested-by: Rob Herring ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 4/7] egl/android: Refactor image creation to separate flink and prime paths (v2)
On Tue, Aug 2, 2016 at 6:07 AM, Tomasz Figa wrote: > This patch splits current dri2_create_image_android_native_buffer() into > main entry point and two additional functions, one for creating an image > from flink name and one for handling prime FDs using the generic DMA-buf > path. This makes the code cleaner and also prepares for disabling flink > path more easily in the future. > > v2: Split into separate patch. > Add error messages. > > Signed-off-by: Tomasz Figa Tested-by: Rob Herring ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 6/7] egl/android: Add support for YV12 pixel format (v2)
On Tue, Aug 2, 2016 at 6:07 AM, Tomasz Figa wrote: > This patch adds support for YV12 pixel format to the Android platform > backend. Only creating EGL images is supported, it is not added to the > list of available visuals. > > v2: Use const array defined just for YV12 instead of trying to be overly > generic. > > Signed-off-by: Tomasz Figa > Signed-off-by: Kalyan Kondapally I didn't exercise this path, but it didn't break anything, so: Tested-by: Rob Herring ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 7/7] egl/android: Make drm_gralloc headers optional (v2)
On Tue, Aug 2, 2016 at 6:07 AM, Tomasz Figa wrote: > Make the code at least compile when being built without drm_gralloc > headers. > > v2: Replaced #ifdefs with stubs for gralloc_drm_get_gem_handle() > and GRALLOC_MODULE_PERFORM_GET_DRM_FD. > Removed explicit render node probing code. > > Signed-off-by: Tomasz Figa > --- > src/egl/Android.mk | 1 + > src/egl/Makefile.am| 4 ++- > src/egl/drivers/dri2/egl_dri2.h| 2 +- > src/egl/drivers/dri2/platform_android.c| 2 +- > .../drivers/dri2/platform_android_gralloc_drm.h| 41 > ++ > 5 files changed, 47 insertions(+), 3 deletions(-) > create mode 100644 src/egl/drivers/dri2/platform_android_gralloc_drm.h > > diff --git a/src/egl/Android.mk b/src/egl/Android.mk > index bfd56a7..72ec02a 100644 > --- a/src/egl/Android.mk > +++ b/src/egl/Android.mk > @@ -41,6 +41,7 @@ LOCAL_SRC_FILES := \ > LOCAL_CFLAGS := \ > -D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_ANDROID \ > -D_EGL_BUILT_IN_DRIVER_DRI2 \ > + -DHAS_GRALLOC_DRM_HEADERS \ > -DHAVE_ANDROID_PLATFORM > > LOCAL_C_INCLUDES := \ > diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am > index 95ee6cc..e6ed8e6 100644 > --- a/src/egl/Makefile.am > +++ b/src/egl/Makefile.am > @@ -86,7 +86,9 @@ endif > > if HAVE_EGL_PLATFORM_ANDROID > AM_CFLAGS += -DHAVE_ANDROID_PLATFORM > -dri2_backend_FILES += drivers/dri2/platform_android.c > +dri2_backend_FILES += \ > + drivers/dri2/platform_android.c \ > + drivers/dri2/egl_dri2_drm_gralloc.h > endif > > if HAVE_EGL_DRIVER_DRI2 > diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h > index 3da6bef..14c1e05 100644 > --- a/src/egl/drivers/dri2/egl_dri2.h > +++ b/src/egl/drivers/dri2/egl_dri2.h > @@ -64,8 +64,8 @@ > # include > #endif > > +#include "platform_android_gralloc_drm.h" This isn't needed here. > #include This should probably just be included by platform_android.c, but that's a separate clean-up. > -#include > #include Maybe this too? > > #endif /* HAVE_ANDROID_PLATFORM */ > diff --git a/src/egl/drivers/dri2/platform_android.c > b/src/egl/drivers/dri2/platform_android.c > index 1768724..49a9eb0 100644 > --- a/src/egl/drivers/dri2/platform_android.c > +++ b/src/egl/drivers/dri2/platform_android.c > @@ -38,7 +38,7 @@ > #include "loader.h" > #include "egl_dri2.h" > #include "egl_dri2_fallbacks.h" > -#include "gralloc_drm.h" > +#include "platform_android_gralloc_drm.h" > > #define ALIGN(val, align) (((val) + (align) - 1) & ~((align) - 1)) > > diff --git a/src/egl/drivers/dri2/platform_android_gralloc_drm.h > b/src/egl/drivers/dri2/platform_android_gralloc_drm.h > new file mode 100644 > index 000..6757d1b > --- /dev/null > +++ b/src/egl/drivers/dri2/platform_android_gralloc_drm.h > @@ -0,0 +1,41 @@ > +/* > + * Copyright 2016 Google Inc. All Rights Reserved. > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > + * copy of this software and associated documentation files (the "Software"), > + * to deal in the Software without restriction, including without limitation > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, > + * and/or sell copies of the Software, and to permit persons to whom the > + * Software is furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice (including the next > + * paragraph) shall be included in all copies or substantial portions of the > + * Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND > + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT > + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, > + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER > + * DEALINGS IN THE SOFTWARE. > + */ > + > +#pragma once > + > +#ifdef HAS_GRALLOC_DRM_HEADERS > + > +#include > +#include > + > +#else > + > +#define GRALLOC_MODULE_PERFORM_GET_DRM_FD 0x0FD4DEAD This leaves things a bit broken as droid_open_device can never work with HAS_GRALLOC_DRM_HEADERS undefined. As we're both aligned in using the render nodes, I'd like to be able to use the same fix. Since with render nodes, it doesn't have to be the same fd now, the following works for me: droid_open_device(void) { #ifdef HAS_GRALLOC_DRM_HEADERS // existing code #else return loader_open_device("/dev/dri/renderD128"); #endif } I can provide that patch, but just want to throw it out there for context. We probably want to get the device path from a property or something rather than hardcoding. > + > +static inline int gralloc_drm_get_gem_handle(buffer_handle_t handle) > +{ > + r
Re: [Mesa-dev] [PATCH v2 3/7] egl/android: Fix support for pbuffers (v2)
On Tue, Aug 2, 2016 at 9:27 PM, Tomasz Figa wrote: > Hi Rob, > > On Wed, Aug 3, 2016 at 2:32 AM, Rob Herring wrote: >> On Tue, Aug 2, 2016 at 6:07 AM, Tomasz Figa wrote: >>> From: Nicolas Boichat >>> >>> Existing image loader code supports creating images only for window >>> surfaces. Moreover droid_create_surface() passes wrong surface type to >>> dri2_get_dri_config(), resulting in incorrect configs being returned for >>> pbuffers. This patch fixes these issues. >>> >>> In addition, the config generation code is fixed to include single >>> buffered contexts required for pbuffers and make sure that generated >>> configs support only surfaces which can handle their supported buffering >>> modes. >>> >>> v2: Return error only in case of real error condition and ignore requests >>> of unavailable buffers. >>> Improve coding style. >> >> This still breaks Android for me. Just adding the hunks below is >> enough to break things. It results in get_buffers() being called with >> type == EGL_WINDOW_BIT and buffer_mask == __DRI_IMAGE_BUFFER_FRONT. I >> don't see any requests for the front buffer without this change. I've >> looked through the tree, but don't really see what would cause >> buffer_mask to change. > > Thanks for testing again and sorry to hear that it still doesn't work > correctly. > > It looks like somehow a single buffered config ends up being used for > a window surface with your driver. > > Could you give me some instructions how to set up some environment for > testing to reproduce the issue? https://github.com/robherring/generic_device/wiki/KConfig-based-Multi-platform-Android-Device-(and-Mesa-graphics) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] pl111: Rename the pl111 driver to "kmsro".
On Thu, Oct 25, 2018 at 11:39 AM Eric Anholt wrote: > > The vc4 driver can do prime sharing to many different KMS-only devices, > such as the various tinydrm drivers for SPI-attached displays. Rename the > driver away from "pl111" to represent what it will actually support: > various sorts of KMS displays with the renderonly layer used to attach a > GPU. I was about to start writing this same patch... I've started looking at the lima and panfrost drivers. The many combinations of Mali GPUs and DC isn't going to scale. The lima and panfrost trees can't even co-exist as both define a rockchip winsys which load different GPU drivers. The same will be true for meson, hisilicon, allwinner, etc. i.MX is about to be in the same boat needing to support both etnaviv and freedreno. What do we need to do to merge this? There was some discussion on patch 2, but I think dealing with the loader is a separate issue. With this patch, we're left with only some very simple boilerplate to add new kms drivers. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] pl111: Rename the pl111 driver to "kmsro".
On Thu, Jan 24, 2019 at 9:14 AM Emil Velikov wrote: > > Hi all, > > Fwiw I'm ok with the idea, as pointed out in 2/2 as-is this is a > partial solution. > Never the less is some solution for the problem we have. > > With that said the series is: > Acked-by: Emil Velikov > > On Wed, 23 Jan 2019 at 23:42, Alyssa Rosenzweig wrote: > > > > > I've started looking at the lima and panfrost drivers. The many > > > combinations of Mali GPUs and DC isn't going to scale. The lima and > > > panfrost trees can't even co-exist as both define a rockchip winsys > > > which load different GPU drivers. The same will be true for meson, > > > hisilicon, allwinner, etc. i.MX is about to be in the same boat > > > needing to support both etnaviv and freedreno. > > > > As Rob stated, Mali being used by basically everyone at one point or > > another has led to a nightmare in the winsys. I agree that dealing with > > the loader can happen later, but honestly, just having the centralised > > kmsro winsys (that all of pl111/rockchip/meson/sunxi/etc point to) that > > tries all of vc4/v3d/panfrost/lima/etc would be a marked improvement on > > the present situation. > > > > There are a lot of DRM drivers out there, sure, and it _is_ better to > > handle something generically in the loader. But for the much more > > immediate goal of letting both Lima and Panfrost coexist on > > Rockchip/Meson, this is a good start. > > AFAICT for a comprehensive solution, that handles the above usescases, > we would need: > > - a form or drm driver name to kms_ro mapping > Personally I'm leaning towards a drirc style file. Thus no patching or > rebuilding of mesa is needed and no more symlinks. That would be nice. Based on the discussion on patch 2, I'm not really clear on where all the support for this needs to go. That's just my lack of X11 details. > - a form of KMSRO to GPU device mapping > Thus we can use that instead of the hardcoded vc4 in the proposed KMSRO. > Ideally they would live alongside the previous mappings, to avoid > patching/rebuilding. The one other thing besides which gpu we have is whether we alloc scanout buffers in the gpu or dc, but that could be a flag. For now, I was working on a patch to just try each gpu with a series of drmOpenwithType calls like this: #if defined(GALLIUM_ETNAVIV) ro.gpu_fd = drmOpenWithType("etnaviv", NULL, DRM_NODE_RENDER); if (ro.gpu_fd >= 0) { ro.create_for_resource = renderonly_create_kms_dumb_buffer_for_resource, screen = etna_drm_screen_create_renderonly(&ro); if (!screen) close(ro.gpu_fd); return screen; } #endif I don't think we have any cases of 2 different embedded GPUs in one system (but SoC vendors have done crazier things) and the number of GPUs is not a huge set. Also, if we require some config file to tell us what GPU, then we still have to update that config file for each and every new system. I'd rather see things work by default and we only need a config file for the special cases. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/4] Switch imx to kmsro and remove the imx winsys
The kmsro winsys is equivalent to the imx winsys, so we can switch to it and remove the imx one. Signed-off-by: Rob Herring --- Android.mk| 5 +- Makefile.am | 2 +- configure.ac | 14 +- meson.build | 6 +-- meson_options.txt | 2 +- src/gallium/Android.mk| 1 - src/gallium/Makefile.am | 4 -- .../auxiliary/pipe-loader/pipe_loader_drm.c | 5 -- .../auxiliary/target-helpers/drm_helper.h | 23 - src/gallium/drivers/imx/Automake.inc | 9 src/gallium/drivers/imx/Makefile.am | 8 --- src/gallium/meson.build | 5 -- src/gallium/targets/dri/Makefile.am | 1 - src/gallium/targets/dri/meson.build | 4 +- src/gallium/winsys/imx/drm/Android.mk | 40 --- src/gallium/winsys/imx/drm/Makefile.am| 35 - src/gallium/winsys/imx/drm/Makefile.sources | 3 -- src/gallium/winsys/imx/drm/imx_drm_public.h | 34 - src/gallium/winsys/imx/drm/imx_drm_winsys.c | 50 --- src/gallium/winsys/imx/drm/meson.build| 33 20 files changed, 9 insertions(+), 275 deletions(-) delete mode 100644 src/gallium/drivers/imx/Automake.inc delete mode 100644 src/gallium/drivers/imx/Makefile.am delete mode 100644 src/gallium/winsys/imx/drm/Android.mk delete mode 100644 src/gallium/winsys/imx/drm/Makefile.am delete mode 100644 src/gallium/winsys/imx/drm/Makefile.sources delete mode 100644 src/gallium/winsys/imx/drm/imx_drm_public.h delete mode 100644 src/gallium/winsys/imx/drm/imx_drm_winsys.c delete mode 100644 src/gallium/winsys/imx/drm/meson.build diff --git a/Android.mk b/Android.mk index 1a0bdd1736cf..9d999835ebb4 100644 --- a/Android.mk +++ b/Android.mk @@ -24,7 +24,7 @@ # BOARD_GPU_DRIVERS should be defined. The valid values are # # classic drivers: i915 i965 -# gallium drivers: swrast freedreno i915g nouveau kmsro r300g r600g radeonsi vc4 virgl vmwgfx etnaviv imx +# gallium drivers: swrast freedreno i915g nouveau kmsro r300g r600g radeonsi vc4 virgl vmwgfx etnaviv # # The main target is libGLES_mesa. For each classic driver enabled, a DRI # module will also be built. DRI modules will be loaded by libGLES_mesa. @@ -59,8 +59,7 @@ gallium_drivers := \ vmwgfx.HAVE_GALLIUM_VMWGFX \ vc4.HAVE_GALLIUM_VC4 \ virgl.HAVE_GALLIUM_VIRGL \ - etnaviv.HAVE_GALLIUM_ETNAVIV \ - imx.HAVE_GALLIUM_IMX + etnaviv.HAVE_GALLIUM_ETNAVIV ifeq ($(BOARD_GPU_DRIVERS),all) MESA_BUILD_CLASSIC := $(filter HAVE_%, $(subst ., , $(classic_drivers))) diff --git a/Makefile.am b/Makefile.am index 62c755aeca7f..e7e14f5b3cdd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,7 +45,7 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \ --enable-libunwind \ --with-platforms=x11,wayland,drm,surfaceless \ --with-dri-drivers=i915,i965,nouveau,radeon,r200,swrast \ - --with-gallium-drivers=i915,nouveau,r300,kmsro,r600,radeonsi,freedreno,svga,swrast,vc4,tegra,virgl,swr,etnaviv,imx \ + --with-gallium-drivers=i915,nouveau,r300,kmsro,r600,radeonsi,freedreno,svga,swrast,vc4,tegra,virgl,swr,etnaviv \ --with-vulkan-drivers=intel,radeon ACLOCAL_AMFLAGS = -I m4 diff --git a/configure.ac b/configure.ac index 8f668fb10ad1..858da79f4d0a 100644 --- a/configure.ac +++ b/configure.ac @@ -1408,7 +1408,7 @@ GALLIUM_DRIVERS_DEFAULT="r300,r600,svga,swrast" AC_ARG_WITH([gallium-drivers], [AS_HELP_STRING([--with-gallium-drivers@<:@=DIRS...@:>@], [comma delimited Gallium drivers list, e.g. - "i915,nouveau,r300,r600,radeonsi,freedreno,kmsro,svga,swrast,swr,tegra,v3d,vc4,virgl,etnaviv,imx" + "i915,nouveau,r300,r600,radeonsi,freedreno,kmsro,svga,swrast,swr,tegra,v3d,vc4,virgl,etnaviv" @<:@default=r300,r600,svga,swrast@:>@])], [with_gallium_drivers="$withval"], [with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"]) @@ -2741,9 +2741,6 @@ if test -n "$with_gallium_drivers"; then PKG_CHECK_MODULES([ETNAVIV], [libdrm >= $LIBDRM_ETNAVIV_REQUIRED libdrm_etnaviv >= $LIBDRM_ETNAVIV_REQUIRED]) require_libdrm "etnaviv" ;; - ximx) -HAVE_GALLIUM_IMX=yes -;; xtegra) HAVE_GALLIUM_TEGRA=yes require_libdrm "tegra" @@ -2864,10 +2861,6 @@ AM_CONDITIONAL(HAVE_SWR_BUILTIN, test "x$HAVE_SWR_BUILTIN" = xyes) dnl We need to validate some needed dependencies for renderonly drivers. -if test "x$HAVE_GALLIUM_ETNAVIV" != xyes -a "x$HAVE_GALLIUM_IMX" = xyes ; then -AC_MSG_ERROR([Building with imx requires etnaviv]) -fi - if test "x$HAVE_GALLIUM_VC4"
[Mesa-dev] [PATCH 1/4] pl111: Rename the pl111 driver to "kmsro".
From: Eric Anholt The vc4 driver can do prime sharing to many different KMS-only devices, such as the various tinydrm drivers for SPI-attached displays. Rename the driver away from "pl111" to represent what it will actually support: various sorts of KMS displays with the renderonly layer used to attach a GPU. Acked-by: Emil Velikov Signed-off-by: Rob Herring --- .travis.yml | 2 +- Android.mk | 4 ++-- Makefile.am | 2 +- configure.ac | 16 meson.build | 8 meson_options.txt| 2 +- src/gallium/Android.mk | 2 +- src/gallium/Makefile.am | 4 ++-- .../auxiliary/pipe-loader/pipe_loader_drm.c | 2 +- .../auxiliary/target-helpers/drm_helper.h| 12 ++-- .../auxiliary/target-helpers/drm_helper_public.h | 2 +- src/gallium/drivers/{pl111 => kmsro}/Android.mk | 6 +++--- src/gallium/drivers/kmsro/Automake.inc | 9 + src/gallium/drivers/{pl111 => kmsro}/Makefile.am | 4 ++-- .../drivers/{pl111 => kmsro}/Makefile.sources| 0 src/gallium/drivers/pl111/Automake.inc | 9 - src/gallium/meson.build | 6 +++--- src/gallium/targets/dri/Makefile.am | 2 +- src/gallium/targets/dri/meson.build | 4 ++-- src/gallium/targets/dri/target.c | 2 +- .../winsys/{pl111 => kmsro}/drm/Android.mk | 2 +- .../winsys/{pl111 => kmsro}/drm/Makefile.am | 4 ++-- src/gallium/winsys/kmsro/drm/Makefile.sources| 3 +++ .../drm/kmsro_drm_public.h} | 8 .../drm/kmsro_drm_winsys.c} | 6 +++--- .../winsys/{pl111 => kmsro}/drm/meson.build | 12 ++-- src/gallium/winsys/pl111/drm/Makefile.sources| 3 --- 27 files changed, 68 insertions(+), 68 deletions(-) rename src/gallium/drivers/{pl111 => kmsro}/Android.mk (91%) create mode 100644 src/gallium/drivers/kmsro/Automake.inc rename src/gallium/drivers/{pl111 => kmsro}/Makefile.am (55%) rename src/gallium/drivers/{pl111 => kmsro}/Makefile.sources (100%) delete mode 100644 src/gallium/drivers/pl111/Automake.inc rename src/gallium/winsys/{pl111 => kmsro}/drm/Android.mk (97%) rename src/gallium/winsys/{pl111 => kmsro}/drm/Makefile.am (94%) create mode 100644 src/gallium/winsys/kmsro/drm/Makefile.sources rename src/gallium/winsys/{pl111/drm/pl111_drm_public.h => kmsro/drm/kmsro_drm_public.h} (89%) rename src/gallium/winsys/{pl111/drm/pl111_drm_winsys.c => kmsro/drm/kmsro_drm_winsys.c} (92%) rename src/gallium/winsys/{pl111 => kmsro}/drm/meson.build (87%) delete mode 100644 src/gallium/winsys/pl111/drm/Makefile.sources diff --git a/.travis.yml b/.travis.yml index 67bbf592a901..6936699cfac3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -352,7 +352,7 @@ matrix: - DRI_LOADERS="--disable-glx --disable-gbm --disable-egl" - DRI_DRIVERS="" - GALLIUM_ST="--enable-dri --disable-opencl --disable-xa --disable-nine --disable-xvmc --disable-vdpau --disable-va --disable-omx-bellagio --disable-gallium-osmesa" -- GALLIUM_DRIVERS="i915,nouveau,pl111,r300,r600,freedreno,svga,swrast,v3d,vc4,virgl,etnaviv,imx" +- GALLIUM_DRIVERS="i915,nouveau,kmsro,r300,r600,freedreno,svga,swrast,v3d,vc4,virgl,etnaviv,imx" - VULKAN_DRIVERS="" - LIBUNWIND_FLAGS="--enable-libunwind" addons: diff --git a/Android.mk b/Android.mk index 914854c27d63..1a0bdd1736cf 100644 --- a/Android.mk +++ b/Android.mk @@ -24,7 +24,7 @@ # BOARD_GPU_DRIVERS should be defined. The valid values are # # classic drivers: i915 i965 -# gallium drivers: swrast freedreno i915g nouveau pl111 r300g r600g radeonsi vc4 virgl vmwgfx etnaviv imx +# gallium drivers: swrast freedreno i915g nouveau kmsro r300g r600g radeonsi vc4 virgl vmwgfx etnaviv imx # # The main target is libGLES_mesa. For each classic driver enabled, a DRI # module will also be built. DRI modules will be loaded by libGLES_mesa. @@ -52,7 +52,7 @@ gallium_drivers := \ freedreno.HAVE_GALLIUM_FREEDRENO \ i915g.HAVE_GALLIUM_I915 \ nouveau.HAVE_GALLIUM_NOUVEAU \ - pl111.HAVE_GALLIUM_PL111 \ + kmsro.HAVE_GALLIUM_KMSRO \ r300g.HAVE_GALLIUM_R300 \ r600g.HAVE_GALLIUM_R600 \ radeonsi.HAVE_GALLIUM_RADEONSI \ diff --git a/Makefile.am b/Makefile.am index 9e27db046e52..62c755aeca7f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,7 +45,7 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \ --enable-libunwind \ --with-platforms=x11,wayland,drm,surfaceless \ --with-dri-drivers=i915,i965,nouveau,radeon,r200,swrast \ -
[Mesa-dev] [PATCH 0/4] Common KMS renderonly support
This series aims to make supporting new platforms containing renderonly GPUs easier with less copy-n-paste. This hasn't been a big issue so far as the current renderonly drivers (vc4 and etnaviv) only exists on a few platforms. This is changing with i.MX+freedreno, armada+etnaviv and a slew of platforms using Mali lima and panfrost drivers. I've taken the kmsro winsys from Eric, extended the pipe-loader to fall back to kmsro, added etnaviv support, and switched imx to use kmsro. I've tested this with the panfrost tree. Help testing on i.MX would be nice. A git branch is here[1]. Rob [1] https://github.com/robherring/mesa winsys-renderonly Eric Anholt (1): pl111: Rename the pl111 driver to "kmsro". Rob Herring (3): pipe-loader: Fallback to kmsro driver when no matching driver name found kmsro: Add etnaviv renderonly support Switch imx to kmsro and remove the imx winsys .travis.yml | 2 +- Android.mk| 7 ++- Makefile.am | 2 +- configure.ac | 28 --- meson.build | 12 ++--- meson_options.txt | 4 +- src/gallium/Android.mk| 3 +- src/gallium/Makefile.am | 8 +-- .../auxiliary/pipe-loader/pipe_loader_drm.c | 18 +++ .../auxiliary/target-helpers/drm_helper.h | 35 +++-- .../target-helpers/drm_helper_public.h| 2 +- src/gallium/drivers/imx/Automake.inc | 9 .../drivers/{pl111 => kmsro}/Android.mk | 6 +-- src/gallium/drivers/kmsro/Automake.inc| 9 .../drivers/{imx => kmsro}/Makefile.am| 4 +- .../drivers/{pl111 => kmsro}/Makefile.sources | 0 src/gallium/drivers/pl111/Automake.inc| 9 src/gallium/drivers/pl111/Makefile.am | 8 --- src/gallium/meson.build | 23 - src/gallium/targets/dri/Makefile.am | 3 +- src/gallium/targets/dri/meson.build | 8 +-- src/gallium/targets/dri/target.c | 2 +- src/gallium/winsys/imx/drm/Android.mk | 40 --- src/gallium/winsys/imx/drm/Makefile.am| 35 - src/gallium/winsys/imx/drm/Makefile.sources | 3 -- src/gallium/winsys/imx/drm/imx_drm_public.h | 34 - src/gallium/winsys/imx/drm/imx_drm_winsys.c | 50 --- src/gallium/winsys/imx/drm/meson.build| 33 .../winsys/{pl111 => kmsro}/drm/Android.mk| 2 +- .../winsys/{pl111 => kmsro}/drm/Makefile.am | 12 - src/gallium/winsys/kmsro/drm/Makefile.sources | 3 ++ .../drm/kmsro_drm_public.h} | 8 +-- .../drm/kmsro_drm_winsys.c} | 42 +++- .../winsys/{pl111 => kmsro}/drm/meson.build | 23 ++--- src/gallium/winsys/pl111/drm/Makefile.sources | 3 -- 35 files changed, 130 insertions(+), 360 deletions(-) delete mode 100644 src/gallium/drivers/imx/Automake.inc rename src/gallium/drivers/{pl111 => kmsro}/Android.mk (91%) create mode 100644 src/gallium/drivers/kmsro/Automake.inc rename src/gallium/drivers/{imx => kmsro}/Makefile.am (55%) rename src/gallium/drivers/{pl111 => kmsro}/Makefile.sources (100%) delete mode 100644 src/gallium/drivers/pl111/Automake.inc delete mode 100644 src/gallium/drivers/pl111/Makefile.am delete mode 100644 src/gallium/winsys/imx/drm/Android.mk delete mode 100644 src/gallium/winsys/imx/drm/Makefile.am delete mode 100644 src/gallium/winsys/imx/drm/Makefile.sources delete mode 100644 src/gallium/winsys/imx/drm/imx_drm_public.h delete mode 100644 src/gallium/winsys/imx/drm/imx_drm_winsys.c delete mode 100644 src/gallium/winsys/imx/drm/meson.build rename src/gallium/winsys/{pl111 => kmsro}/drm/Android.mk (97%) rename src/gallium/winsys/{pl111 => kmsro}/drm/Makefile.am (87%) create mode 100644 src/gallium/winsys/kmsro/drm/Makefile.sources rename src/gallium/winsys/{pl111/drm/pl111_drm_public.h => kmsro/drm/kmsro_drm_public.h} (89%) rename src/gallium/winsys/{pl111/drm/pl111_drm_winsys.c => kmsro/drm/kmsro_drm_winsys.c} (63%) rename src/gallium/winsys/{pl111 => kmsro}/drm/meson.build (76%) delete mode 100644 src/gallium/winsys/pl111/drm/Makefile.sources -- 2.19.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/4] kmsro: Add etnaviv renderonly support
Enable using etnaviv for KMS renderonly. This still needs KMS driver name mapping to kmsro to be used automatically. Signed-off-by: Rob Herring --- meson.build | 4 +-- src/gallium/meson.build | 12 +++ src/gallium/winsys/kmsro/drm/Makefile.am | 8 + .../winsys/kmsro/drm/kmsro_drm_winsys.c | 36 ++- src/gallium/winsys/kmsro/drm/meson.build | 11 -- 5 files changed, 52 insertions(+), 19 deletions(-) diff --git a/meson.build b/meson.build index a7082f1057cf..5d2ae2a446df 100644 --- a/meson.build +++ b/meson.build @@ -205,8 +205,8 @@ endif if with_gallium_imx and not with_gallium_etnaviv error('IMX driver requires etnaviv driver') endif -if with_gallium_kmsro and not with_gallium_vc4 - error('kmsro driver requires vc4 driver') +if with_gallium_kmsro and not (with_gallium_vc4 or with_gallium_etnaviv) + error('kmsro driver requires one or more renderonly drivers (vc4, etnaviv)') endif if with_gallium_tegra and not with_gallium_nouveau error('tegra driver requires nouveau driver') diff --git a/src/gallium/meson.build b/src/gallium/meson.build index a3679e5ef629..5b0ce81d1e47 100644 --- a/src/gallium/meson.build +++ b/src/gallium/meson.build @@ -89,6 +89,12 @@ if with_gallium_vc4 else driver_vc4 = declare_dependency() endif +if with_gallium_etnaviv + subdir('winsys/etnaviv/drm') + subdir('drivers/etnaviv') +else + driver_etnaviv = declare_dependency() +endif if with_gallium_kmsro subdir('winsys/kmsro/drm') else @@ -100,12 +106,6 @@ if with_gallium_v3d else driver_v3d = declare_dependency() endif -if with_gallium_etnaviv - subdir('winsys/etnaviv/drm') - subdir('drivers/etnaviv') -else - driver_etnaviv = declare_dependency() -endif if with_gallium_imx subdir('winsys/imx/drm') else diff --git a/src/gallium/winsys/kmsro/drm/Makefile.am b/src/gallium/winsys/kmsro/drm/Makefile.am index ad471d31d4fa..0092206539c3 100644 --- a/src/gallium/winsys/kmsro/drm/Makefile.am +++ b/src/gallium/winsys/kmsro/drm/Makefile.am @@ -29,6 +29,14 @@ AM_CFLAGS = \ $(GALLIUM_WINSYS_CFLAGS) \ $(LIBDRM_CFLAGS) +if HAVE_GALLIUM_ETNAVIV +AM_CFLAGS += -DGALLIUM_ETNAVIV +endif + +if HAVE_GALLIUM_VC4 +AM_CFLAGS += -DGALLIUM_VC4 +endif + noinst_LTLIBRARIES = libkmsrodrm.la libkmsrodrm_la_SOURCES = $(C_SOURCES) diff --git a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c index 4448150cc0c6..e086c0858f05 100644 --- a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c +++ b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c @@ -27,6 +27,7 @@ #include "kmsro_drm_public.h" #include "vc4/drm/vc4_drm_public.h" +#include "etnaviv/drm/etnaviv_drm_public.h" #include "xf86drm.h" #include "pipe/p_screen.h" @@ -34,22 +35,39 @@ struct pipe_screen *kmsro_drm_screen_create(int fd) { + struct pipe_screen *screen = NULL; struct renderonly ro = { + .kms_fd = fd, + .gpu_fd = -1, + }; + +#if defined(GALLIUM_VC4) + ro.gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER); + if (ro.gpu_fd >= 0) { /* Passes the vc4-allocated BO through to the KMS-only DRM device using * PRIME buffer sharing. The VC4 BO must be linear, which the SCANOUT * flag on allocation will have ensured. */ - .create_for_resource = renderonly_create_gpu_import_for_resource, - .kms_fd = fd, - .gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER), - }; + ro.create_for_resource = renderonly_create_gpu_import_for_resource, + screen = vc4_drm_screen_create_renderonly(&ro); + if (!screen) + close(ro.gpu_fd); + + return screen; + } +#endif - if (ro.gpu_fd < 0) - return NULL; +#if defined(GALLIUM_ETNAVIV) + ro.gpu_fd = drmOpenWithType("etnaviv", NULL, DRM_NODE_RENDER); + if (ro.gpu_fd >= 0) { + ro.create_for_resource = renderonly_create_kms_dumb_buffer_for_resource, + screen = etna_drm_screen_create_renderonly(&ro); + if (!screen) + close(ro.gpu_fd); - struct pipe_screen *screen = vc4_drm_screen_create_renderonly(&ro); - if (!screen) - close(ro.gpu_fd); + return screen; + } +#endif return screen; } diff --git a/src/gallium/winsys/kmsro/drm/meson.build b/src/gallium/winsys/kmsro/drm/meson.build index f157982d7288..e8c350e081bc 100644 --- a/src/gallium/winsys/kmsro/drm/meson.build +++ b/src/gallium/winsys/kmsro/drm/meson.build @@ -18,6 +18,14 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +kmsro_c_args = [] +if with_gallium_etnaviv + kmsro_c_args += '-DGALLIUM_ETNAVIV' +endif +if with_gallium_vc4 + kmsro_c_args += '-DGALLIUM_VC4' +endif + libkmsrowi
[Mesa-dev] [PATCH 2/4] pipe-loader: Fallback to kmsro driver when no matching driver name found
If we can't find a driver matching by name, then use the kmsro driver. This removes the need for needing a driver descriptor for every possible KMS driver. Signed-off-by: Rob Herring --- src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c index 230bafe5e159..c1323ac65906 100644 --- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c @@ -106,11 +106,6 @@ static const struct drm_driver_descriptor driver_descriptors[] = { .create_screen = pipe_freedreno_create_screen, .configuration = pipe_default_configuration_query, }, -{ - .driver_name = "pl111", -.create_screen = pipe_kmsro_create_screen, -.configuration = pipe_default_configuration_query, -}, { .driver_name = "virtio_gpu", .create_screen = pipe_virgl_create_screen, @@ -142,6 +137,13 @@ static const struct drm_driver_descriptor driver_descriptors[] = { .configuration = pipe_default_configuration_query, }, }; + +static const struct drm_driver_descriptor default_driver_descriptor = { +.driver_name = "kmsro", +.create_screen = pipe_kmsro_create_screen, +.configuration = pipe_default_configuration_query, +}; + #endif static const struct drm_driver_descriptor * @@ -152,6 +154,7 @@ get_driver_descriptor(const char *driver_name, struct util_dl_library **plib) if (strcmp(driver_descriptors[i].driver_name, driver_name) == 0) return &driver_descriptors[i]; } + return &default_driver_descriptor; #else *plib = pipe_loader_find_module(driver_name, PIPE_SEARCH_DIR); if (!*plib) -- 2.19.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/4] kmsro: Add etnaviv renderonly support
On Thu, Jan 24, 2019 at 7:21 PM Eric Anholt wrote: > > Rob Herring writes: > > > Enable using etnaviv for KMS renderonly. This still needs KMS driver > > name mapping to kmsro to be used automatically. > > > > Signed-off-by: Rob Herring > > > diff --git a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c > > b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c > > index 4448150cc0c6..e086c0858f05 100644 > > --- a/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c > > +++ b/src/gallium/winsys/kmsro/drm/kmsro_drm_winsys.c > > @@ -27,6 +27,7 @@ > > > > #include "kmsro_drm_public.h" > > #include "vc4/drm/vc4_drm_public.h" > > +#include "etnaviv/drm/etnaviv_drm_public.h" > > #include "xf86drm.h" > > > > #include "pipe/p_screen.h" > > @@ -34,22 +35,39 @@ > > > > struct pipe_screen *kmsro_drm_screen_create(int fd) > > { > > + struct pipe_screen *screen = NULL; > > struct renderonly ro = { > > + .kms_fd = fd, > > + .gpu_fd = -1, > > + }; > > + > > +#if defined(GALLIUM_VC4) > > + ro.gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER); > > + if (ro.gpu_fd >= 0) { > >/* Passes the vc4-allocated BO through to the KMS-only DRM device > > using > > * PRIME buffer sharing. The VC4 BO must be linear, which the > > SCANOUT > > * flag on allocation will have ensured. > > */ > > - .create_for_resource = renderonly_create_gpu_import_for_resource, > > - .kms_fd = fd, > > - .gpu_fd = drmOpenWithType("vc4", NULL, DRM_NODE_RENDER), > > - }; > > + ro.create_for_resource = renderonly_create_gpu_import_for_resource, > > + screen = vc4_drm_screen_create_renderonly(&ro); > > + if (!screen) > > + close(ro.gpu_fd); > > + > > + return screen; > > + } > > +#endif > > > > - if (ro.gpu_fd < 0) > > - return NULL; > > +#if defined(GALLIUM_ETNAVIV) > > + ro.gpu_fd = drmOpenWithType("etnaviv", NULL, DRM_NODE_RENDER); > > + if (ro.gpu_fd >= 0) { > > + ro.create_for_resource = > > renderonly_create_kms_dumb_buffer_for_resource, > > + screen = etna_drm_screen_create_renderonly(&ro); > > + if (!screen) > > + close(ro.gpu_fd); > > > > - struct pipe_screen *screen = vc4_drm_screen_create_renderonly(&ro); > > - if (!screen) > > - close(ro.gpu_fd); > > + return screen; > > + } > > +#endif > > Would it make more sense to open the first render node once, then check > if its name matches any of the drivers we support and calling their > setup function? That would be more efficient. The downside is if you did have more than one render node, then which device you get is less predictable as it would be depending on probe order. As-is, we can handle at least simple prioritization of drivers to use. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 0/4] Common KMS renderonly support
On Fri, Jan 25, 2019 at 9:00 PM Qiang Yu wrote: > > Thanks Rob, I'm OK with this kmsro approach. > > But I have to point out that this will break XServer AIGLX: > 1. modesetting DDX will report the display drm driver name like meson > as DRI2 driver name > 2. libglx.so used by xserver will look after meson_dri.so for dlopen > 3. then dlsym __driDriverGetExtensions_meson for init 2 and 3 are now the only things you have to add to add a platform. Now it is a 2 line patch to add a platform. Specifically what you have to add are shown in the lima branch I sent you. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] panfrost: Initial stub for Panfrost driver
On Sun, Feb 3, 2019 at 9:33 PM Alyssa Rosenzweig wrote: > > > You should just land it and start doing in-tree development! > > I don't have push access, you know :P I can push it if you don't want to go the MR route. That goes for subsequent changes too. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/8] panfrost: Detect GPU version at runtime
On Mon, Mar 4, 2019 at 1:35 PM Alyssa Rosenzweig wrote: > > > /* If set, we'll require the use of single render-target framebuffer > > * descriptors (SFBD), for older hardware -- specifically, > If > > This require_sfbd field should also be set at the same time. In > particular, we'll want a (kernel-agnostic) routine to determine whether > a given chip version supports MFBD, so we know to use it or not. > > In kernel-space, this corresponds to the "FEATURE_MRT" flag. We'll want > to import this to userspace, but tl;dr "T760+ is MFBD, T6XX/T720 is > SFBD". +1 "is_t6xx" is not going to scale. We need to do feature and issues. Doesn't have to be in this series though. > > +ctx->is_t6xx = pscreen->driver->query_gpu_version(pscreen) == > > 0x0750; > > Where did this magic number come from? Is that for T760 or actually T600 > or something else or...? For Midgard only, I suppose <= 0x0750 is > probably what you want but we'll see. Most of midgard has a number in hex matching the marketing number, but there's some oddballs. This one is T760 which doesn't match is_t6xx. The other oddball is T604 which has 0x6???. Then Bifrost has a different scheme. > > + unsigned (*query_gpu_version) (struct panfrost_screen *screen); > > I'll implement this in the non-DRM module as well (tonight, if I get > time for it), but that's needed for merging to avoid regressing. Just > making a mental note to self -- nothing for you to worry about here :) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 8/8] panfrost: Add backend targeting the DRM driver
On Mon, Mar 4, 2019 at 10:12 AM Tomeu Vizoso wrote: > > This backend interacts with the new DRM driver for Midgard GPUs which is > currently in development. > > When using this backend, Panfrost has roughly on-par functionality as > when using the non-DRM driver from Arm. > > Signed-off-by: Tomeu Vizoso > --- > include/drm-uapi/panfrost_drm.h| 128 + > src/gallium/drivers/panfrost/pan_drm.c | 362 + > 2 files changed, 490 insertions(+) > create mode 100644 include/drm-uapi/panfrost_drm.h > > diff --git a/include/drm-uapi/panfrost_drm.h b/include/drm-uapi/panfrost_drm.h > new file mode 100644 > index ..d4d271e37206 > --- /dev/null > +++ b/include/drm-uapi/panfrost_drm.h > @@ -0,0 +1,128 @@ > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ > +/* Copyright 2018, Linaro, Ltd., Rob Herring */ > + > +#ifndef __PANFROST_DRM_H__ > +#define __PANFROST_DRM_H__ > + > +#include "drm.h" > + > +#if defined(__cplusplus) > +extern "C" { > +#endif > + > +/* timeouts are specified in clock-monotonic absolute times (to simplify > + * restarting interrupted ioctls). The following struct is logically the > + * same as 'struct timespec' but 32/64b ABI safe. > + */ > +struct drm_panfrost_timespec { > + __s64 tv_sec; /* seconds */ > + __s64 tv_nsec; /* nanoseconds */ > +}; > + > +#define PANFROST_PARAM_GPU_ID 0x01 > + > +struct drm_panfrost_get_param { > + __u32 param;/* in */ > + __u32 pad; > + __u64 value;/* out */ > +}; > + > +struct drm_panfrost_gem_new { > + __u64 size; /* in */ > + __u32 flags; /* in, mask of ETNA_BO_x */ > + __u32 handle; /* out */ > + /** > +* Returned offset for the BO in the GPU address space. This offset > +* is private to the DRM fd and is valid for the lifetime of the GEM > +* handle. > +* > +* This offset value will always be nonzero, since various HW > +* units treat 0 specially. > +*/ > + __u64 offset; > +}; > +struct drm_panfrost_gem_info { > + __u32 handle; /* in */ > + __u32 pad; > + __u64 offset; /* out, offset to pass to mmap() */ > +}; > + > +/** > + * Returns the offset for the BO in the GPU address space for this DRM fd. > + * This is the same value returned by drm_panfrost_gem_new, if that was > called > + * from this DRM fd. > + */ > +struct drm_panfrost_get_bo_offset { > + __u32 handle; > + __u32 pad; > + __u64 offset; > +}; > + > + > +#define ETNA_PREP_READ0x01 > +#define ETNA_PREP_WRITE 0x02 > +#define ETNA_PREP_NOSYNC 0x04 Guess we need to rename or delete these and a few other spots with 'ETNA'. I'd hoped to keep some alignment with other drivers, but I don't think that's going to happen. > + > +struct drm_panfrost_gem_cpu_prep { > + __u32 handle; /* in */ > + __u32 op; /* in, mask of ETNA_PREP_x */ > + struct drm_panfrost_timespec timeout; /* in */ > +}; > + > +struct drm_panfrost_gem_cpu_fini { > + __u32 handle; /* in */ > + __u32 flags; /* in, placeholder for now, no defined values */ > +}; > + > +/* > + * Cmdstream Submission: > + */ > + > +#define PANFROST_JD_REQ_FS (1 << 0) > + > +#define PANFROST_DEP_TYPE_ORDER0x01 > +#define PANFROST_DEP_TYPE_DATA 0x02 > + > +struct drm_panfrost_gem_submit_atom_dep { > + __u32 atom_nr; /* job ID of dependency */ > + __u32 type; /* one of PANFROST_DEP_TYPE_* */ > +}; > + > +struct drm_panfrost_gem_submit_atom { > + __u64 jc; /* in, address to GPU mapping of job descriptor */ > + __u32 atom_nr; /* in, job ID */ > + __u32 requirements; /* in, a combination of PANFROST_JD_REQ_* */ > + __u64 bo_handles; > + __u32 bo_handle_count; > + struct drm_panfrost_gem_submit_atom_dep deps[2]; > +}; > + > +struct drm_panfrost_gem_submit { > + __u32 nr_atoms; /* in, number of submit_atom */ > + __u32 pad; > + __u64 atoms;/* in, ptr to array of submit_atom */ > +}; > + > + > + > +#define DRM_PANFROST_GET_PARAM 0x00 > +#define DRM_PANFROST_GEM_NEW 0x01 > +#define DRM_PANFROST_GEM_INFO 0x02 > +#define DRM_PANFROST_GEM_CPU_PREP 0x03 > +#define DRM_PANFROST_GEM_CPU_FINI 0x04 > +#define DRM_PANFROST_GEM_SUBMIT0x05 > +#define DRM_PANFROST_GET_BO_OFFSET
Re: [Mesa-dev] [PATCH 6/8] panfrost: Free context BOs
On Mon, Mar 4, 2019 at 1:38 PM Alyssa Rosenzweig wrote: > > > unsigned transient_count = > > ctx->transient_pools[ctx->cmdstream_i].entry_index*ctx->transient_pools[0].entry_size > > + ctx->transient_pools[ctx->cmdstream_i].entry_offset; > > - printf("Uploaded transient %d bytes\n", transient_count); > > + //printf("Uploaded transient %d bytes\n", transient_count); > > This will raised an unused variable warning for transient_count, better > comment both or neither. Better yet, use a debug print so it can be enabled via an env var. Or if it's not that useful, just remove it. > > Other than that, Reviewed-by: Alyssa Rosenzweig > > I wonder if this will fix some of the memory leaks on non-DRM as well. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 8/8] panfrost: Add backend targeting the DRM driver
On Mon, Mar 4, 2019 at 6:43 PM Alyssa Rosenzweig wrote: > > Wooo!!! > > Seeing this patch in my inbox has been some of the best news all day! > > Without further ado, my (solicited?) comments: > > > +/* Copyright 2018, Linaro, Ltd., Rob Herring */ > > Please triple check upstream that this license is okay; the other files > in include/drm-uapi are BSDish. There's a mixture of MIT and 'GPL-2.0 WITH Linux-syscall-note'. These are the ones with GPL: include/uapi/drm/armada_drm.h:/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ include/uapi/drm/etnaviv_drm.h:/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ include/uapi/drm/exynos_drm.h:/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ include/uapi/drm/i810_drm.h:/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ include/uapi/drm/omap_drm.h:/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ I don't think it matters, but imagine all corporate entities would prefer MIT. > > > +/* timeouts are specified in clock-monotonic absolute times (to simplify > > + * restarting interrupted ioctls). The following struct is logically the > > + * same as 'struct timespec' but 32/64b ABI safe. > > + */ > > +struct drm_panfrost_timespec { > > + __s64 tv_sec; /* seconds */ > > + __s64 tv_nsec; /* nanoseconds */ > > +}; > > What's this for -- is there not a shared struct for this if it's > necessary? (I'm assuming this was copied from etna..?) I couldn't find any common struct. > > > + __u32 flags; /* in, mask of ETNA_BO_x */ > > As Rob said, s/ETNA/PAN/g > > > + struct drm_panfrost_timespec timeout; /* in */ > > (Presumably we just want a timeout in one of nanoseconds / milliseconds > / second, not the full timespec... 64-bit time gives a pretty wide range > even for high-precision timeouts, which I don't know that we need. Also, > it's signed for some reason...?) Yes, but I was keeping it aligned with etnaviv. Changing to just u64 ns should be fine as I think rollover in 500 years is acceptable. Arnd confirmed with me that a plain u64 nanoseconds is preferred. > > + struct drm_panfrost_gem_submit_atom_dep deps[2]; > > I'm concerned about hardcoding deps to 2 here. I know the Arm driver > does it, but I'm super uncomfortable by them doing it too. Keep in mind, > when they have complex dependencies they insert dummy "dependency-only" > jobs into the graph, though I concede I haven't seen this yet. > > I'm not at all sure what the right number is, especially since the new > kernel interface seems to support waiting on BOs? Or am I > misinterpreting this? > > Regardless, this will start to matter when we implement support for more > complex FBOs (where various FBOs samples from various other FBOs), which > I think can have arbitrarily complicated dependency graphs. So > hardcoding to [2] is inappropriate if we want to use deps for waiting on > FBOs. On the other hand, if we use a kernel-side BO wait or fences or > something to resolve dependencies, do we even need two deps, or just > one? > > > + // TODO cache allocations > > + // TODO properly handle errors > > + // TODO take into account extra_flags > > Not a blocker at all for merge, but these should be taken care of before > we drop support for the non-DRM stuff (since at least the > lack of GROWABLE support represents a regression compared to the Arm > driver). Need to research how other drivers deal with this. Presumably other drivers should need some heap as well? I found one case that has a specific ioctl call to do allocate it (don't remember which one offhand). > > > + // TODO map and unmap on demand? > > I don't know if this matters too much...? Usually if we're allocating a > slab, that means we want it mapped immediately, unless we set the > INVISIBLE flag which means we odn't want it mapped at all. Map to what? The GPU or CPU? > Maybe we'll have fancier scenarios in the future, but at the moment I > think we can safely cross off at least the first half of the TODO. > > As you know I'm not a believer in unmapping/freeing resources ever, so I > don't get an opinion there ;) > > > + gem_info.handle = gem_new.handle; > > + ret = drmIoctl(drm->fd, DRM_IOCTL_PANFROST_GEM_INFO, &gem_info); > > + if (ret) { > > +fprintf(stderr, "DRM_IOCTL_PANFROST_GEM_INFO failed: > > %d\n", ret); > > + assert(0); > > + } > > Maybe a question for Rob, but why isn't this info
Re: [Mesa-dev] [PATCH v2 2/8] panfrost: Detect GPU version at runtime
On Fri, Mar 8, 2019 at 3:27 AM Tomeu Vizoso wrote: > > Also use the raw GPU ID value to decide whether to use SFD or MFD. > > Signed-off-by: Tomeu Vizoso > --- > src/gallium/drivers/panfrost/pan_context.c | 66 ++ > src/gallium/drivers/panfrost/pan_context.h | 10 > src/gallium/drivers/panfrost/pan_screen.h | 1 + > 3 files changed, 41 insertions(+), 36 deletions(-) > @@ -2724,8 +2712,14 @@ struct pipe_context * > panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned > flags) > { > struct panfrost_context *ctx = CALLOC_STRUCT(panfrost_context); > +struct panfrost_screen *pscreen = pan_screen(screen); > memset(ctx, 0, sizeof(*ctx)); > struct pipe_context *gallium = (struct pipe_context *) ctx; > +unsigned gpu_id; > + > +gpu_id = pscreen->driver->query_gpu_version(pscreen); > +ctx->is_t6xx = gpu_id <= 0x0750; /* For now, this flag means t76x or > less */ This doesn't work for t604 which has a special version of 0x6???. That helpfully also collides with bifrost versions. We could fix this up in the kernel to expose it as 0x0600. Then an 'is_bifrost' would be an easy (gpu_id & 0xf000). Why isn't this 'is_t8xx' instead as you are touching it everywhere or this needs to be t8xx and bifrost? If not you could just do ((gpu_id & 0xff00) == 0x0800). Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 8/8] panfrost: Add backend targeting the DRM driver
On Fri, Mar 8, 2019 at 3:59 PM Alyssa Rosenzweig wrote: > > > +/** > > + * struct drm_panfrost_wait_bo - ioctl argument for waiting for > > + * completion of the last DRM_PANFROST_SUBMIT_CL on a BO. > > Nit: Should be plain DRM_PANFROST_SUBMIT, there is no CL for us. > > > + __s64 timeout_ns; /* absolute */ > > Erm, why is this signed? Semantically, what does a negative timestamp > mean? Seems suspect. The comment /* absolute */ seems to underscore that > we really do want an unsigned value, perhaps ascribing a special meaning > to 0/~0 for "nonblocking" and "block indefinitely" if needed. Of course, > "(2^64)-1 ns" is essentially indefinite, so the latter need not be a > special case. Signed is convention and used internally in the kernel (ktime_t). I checked that signed is correct with Arnd Bergmann who is leading the 2038 work. > * It's 585 years, according to a back of the envelope calculation. > Panfrost will be obsolete many times over by the time that timeout > elapses ;) I'm pretty sure it will be obsolete in only 240 years too. :) Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] android: enable building static version of libdrm
From: Sumit Semwal Android needs libdrm built statically for recovery; enable that as well. Signed-off-by: Sumit Semwal Signed-off-by: Rob Herring Cc: Chih-Wei Huang Cc: Emil Velikov --- Android.mk | 19 +++ 1 file changed, 19 insertions(+) diff --git a/Android.mk b/Android.mk index 90cdcb3..1d8cd65 100644 --- a/Android.mk +++ b/Android.mk @@ -27,6 +27,8 @@ include $(CLEAR_VARS) # Import variables LIBDRM_{,H_,INCLUDE_H_,INCLUDE_VMWGFX_H_}FILES include $(LOCAL_PATH)/Makefile.sources +#static library for the device (recovery) +include $(CLEAR_VARS) LOCAL_MODULE := libdrm LOCAL_MODULE_TAGS := optional @@ -41,7 +43,24 @@ LOCAL_C_INCLUDES := \ LOCAL_CFLAGS := \ -DHAVE_VISIBILITY=1 \ -DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 +include $(BUILD_STATIC_LIBRARY) + +# Shared library for the device +include $(CLEAR_VARS) +LOCAL_MODULE := libdrm +LOCAL_MODULE_TAGS := optional +LOCAL_SRC_FILES := $(LIBDRM_FILES) +LOCAL_EXPORT_C_INCLUDE_DIRS := \ +$(LOCAL_PATH) \ +$(LOCAL_PATH)/include/drm + +LOCAL_C_INCLUDES := \ +$(LOCAL_PATH)/include/drm + +LOCAL_CFLAGS := \ +-DHAVE_VISIBILITY=1 \ +-DHAVE_LIBDRM_ATOMIC_PRIMITIVES=1 include $(BUILD_SHARED_LIBRARY) include $(call all-makefiles-under,$(LOCAL_PATH)) -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [android-x86-devel] Re: need-help: how to change to newest mesa in android-x86?
On Wed, Jan 13, 2016 at 12:17 PM, Rob Clark wrote: > On Wed, Jan 13, 2016 at 12:54 PM, Rob Herring wrote: >> On Tue, Jan 12, 2016 at 8:06 PM, Chih-Wei Huang >> wrote: >>> 2016-01-13 6:29 GMT+08:00 Rob Herring : >>>> On Tue, Jan 12, 2016 at 7:05 AM, Chih-Wei Huang >>>> wrote: >>>>> 2016-01-12 19:55 GMT+08:00 陈渝 : >>>>>> hi, Rob, Dave, Zhiwei: >>>>>> Thank you all! >>>>>> >>>>>> Next I need to update other parts should be in the user level. >>>>>> >>>>>> I need to update drm_gralloc? Do I need to update drm_hwcomposer or >>>>>> libdrm? >>>>>> Are there any other things I need notice? >>>>> >>>>> libdrm in marshmallow-x86 is 2.4.66 which is newer enough >>>>> to support it, I think. >>>>> >>>>> drm_hwcomposer is not been used in marshmallow-x86 yet. >>>>> So don't worry about it. >>>>> >>>>> The keypoint is to implement the gralloc_drm_virgil3d.c. >>>>> You may look at other gralloc_drm_*.c as examples. >>>> >>>> Nope, virgl is a pipe driver and support is already there for the most >>>> part. >>> >>> Rob, thank you very much for the input. >>> It's the first time I heard the usage of >>> AOSP's drm_gralloc & drm_hwcomposer from others. >>> Great! >>> >>> Indeed we have tried to enable AOSP's drm_gralloc & drm_hwcomposer >>> in the beginning of marshmallow-x86 porting but failed. >> >> How far did you get? >> >>> So we keep to use our implementation. >>> (AOSP's drm_gralloc was forked from our lollipop-x86 branch >>> since about Jan 2015) >>> >>> I'm excited to know you have succeeded to use them. >>> Could you please guide us how to enable them correctly? >> >> Well, things are not completely working. I've got 1 device config >> which can build for x86 or arm64 (any arch in theory) and runs on x86 >> KVM, Dragonboard 410c or arm64 QEMU. x86 KVM seems to work the best. I >> can boot and navigate around a bit until it dies. There's at least 2 >> problems. >> >> After a little bit of navigating around I get errors like this from >> virglrenderer: >> vrend_set_single_sampler_view: context error reported 6 >> "ndroid.contacts" Illegal handle 112 >> vrend_set_single_sampler_view: context error reported 6 >> "ndroid.contacts" Illegal handle 113 >> vrend_set_single_sampler_view: context error reported 6 >> "ndroid.contacts" Illegal handle 114 >> vrend_set_single_sampler_view: context error reported 6 >> "ndroid.contacts" Illegal handle 115 >> vrend_set_single_sampler_view: context error reported 6 >> "ndroid.contacts" Illegal handle 116 >> vrend_set_single_sampler_view: context error reported 6 >> "ndroid.contacts" Illegal handle 117 >> vrend_set_single_sampler_view: context error reported 6 >> "ndroid.contacts" Illegal handle 118 >> vrend_set_framebuffer_state: context error reported 5 >> "ndroid.systemui" Illegal surface 63 >> >> Usually the screen get flipped and drawn in about 1/4 of the original >> screen size after these errors. I can capture a screenshot if >> interested. > > I wonder a bit if refcnt'ing imbalance or something like that.. > accidentally free'ing the last reference to buffer, and then numeric > handle getting re-used on a different unrelated buffer (for example) > can cause all sorts of fun. I've got freedreno mostly working now. I had missed one of the fixes in your tree allowing prime_fd=0 to be valid. The good news is I don't see this problem on freedreno, so it seems likely this problem is specific to virtio-gpu. The question then is ref counting where? I started with the host side as that is where the error messages come from. I've added some debug to virglrenderer vrend_object_insert/remove to try to trace the handles. Here's a snippet around the error messages. create surface obj 1735 destroy sampler view obj 1727 destroy surface obj 1735 create sampler view obj 1736 create surface obj 158 unknown obj 154 vrend_set_framebuffer_state: context error reported 5 "ndroid.systemui" Illegal surface 155 vrend_set_single_sampler_view: context error reported 5 "ndroid.systemui" Illegal handle 156 vrend_set_single_sampler_view: context error reported 5 "ndroid.systemui" Illegal handle 157 create surfa
Re: [Mesa-dev] [android-x86-devel] Re: need-help: how to change to newest mesa in android-x86?
On Fri, Jan 15, 2016 at 3:10 PM, Dave Airlie wrote: >> >> well, nothing specific, but for example early on we had some confusion >> in drm_gralloc (when adding dmabuf fd support) about who close()d the >> fd's. Resulting in same fd getting closed twice (although some >> completely unrelated file handle might have snuck into that slot >> between the two close()s). >> >> Or you could end up w/ the same sort of thing for gem handles (which >> are unique to the drm device fd, so if you open() the device multiple >> times..). I did initially have some confusion about this, w/ multiple >> fd_bo's (or pipe_resource's) being created for a given gem handle, and >> first one that gets deleted takes away the backing store that both >> userspace references where using. >> >> You might want to look at freedreno_drm_winsys.c and the crazy things >> it does.. I suspect virgl might need similar hacks. That is really >> one part of two, that ensures that we share the same pipe_screen, and >> therefore (from libdrm) fd_device, for a given drm device fd. The >> other part is that fd_device has hashtables to deal w/ double import >> of gem buffers. > > I think Rob Clark might be on the right track here. > > it sounds like the host is sending double deletes for some objects, which > sounds like a possible reference counting bug in the host. > > So possibly something drm_gralloc, but it could be a bug in mesa, though > I haven't triggered anything like this yet. Okay, I'll start digging there. > > I'd be more willing to look at this if/when there is an easy to > produce android-x86 > image that I could just drop newer mesa/drm_gralloc into, I suppose I could > look > at ARM images, but I'm not really setup for cross dev, and I've a few > other things to > be doing. I've got a minimal build that is recent mesa and 4.4 kernel (only a couple of patches on top of each) and runs in a VM (or arm64). It is as easy as it gets with Android and rebuilding the world, but that's not saying too much. Instructions are here[1]. Rob [1] https://github.com/robherring/generic_device/wiki/Android-with-DRM-mesa-graphics ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [android-x86-devel] Re: need-help: how to change to newest mesa in android-x86?
On Fri, Jan 15, 2016 at 11:45 PM, 陈渝 wrote: > hi, Rob Herring: > I have downloaded the AOSP repos finally(spend 36+ hours). and followed your > Instructions try to know your current progress on x86_64. > > I finished virglrenderer, qemu, kernel, BUT... (BTW, I have tried AOSP-6, > android-x86 sucessfully in the last) > When I build aosp, I got below error info, > ... > build/core/tasks/boot_jars_package_check.mk:34: update target > 'out/target/common/obj/PACKAGING/boot-jars-package-check_intermediates/stamp' > due to: > out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/classes.jar > echo "Check package name for > out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/apache-xml_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/org.apache.http.legacy.boot_intermediates/classes.jar" > Check package name for > out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/apache-xml_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/org.apache.http.legacy.boot_intermediates/classes.jar > build/core/tasks/check_boot_jars/check_boot_jars.py > build/core/tasks/check_boot_jars/package_whitelist.txt > out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/apache-xml_intermediates/classes.jar > out/target/common/obj/JAVA_LIBRARIES/org.apache.http.legacy.boot_intermediates/classes.jar > mkdir -p > out/target/common/obj/PACKAGING/boot-jars-package-check_intermediates/ && > touch > out/target/common/obj/PACKAGING/boot-jars-package-check_intermediates/stamp > make: *** No rule to make target > 'out/target/product/linaro_x86_64/obj/STATIC_LIBRARIES/libdrm_intermediates/export_includes', > needed by > 'out/target/product/linaro_x86_64/obj/STATIC_LIBRARIES/libminui_intermediates/import_includes'. > Stop. Sync the repos (or just libdrm) again. The problem is the recovery image needs a static libdrm built. I've added that patch to libdrm and added libdrm to my github repos (repo sync will throw an error with the repository location changing). There's a couple of changes to the device repo I have checked in the last couple of days, too. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [android-x86-devel] Re: need-help: how to change to newest mesa in android-x86?
On Fri, Jan 15, 2016 at 3:10 PM, Dave Airlie wrote: >> >> well, nothing specific, but for example early on we had some confusion >> in drm_gralloc (when adding dmabuf fd support) about who close()d the >> fd's. Resulting in same fd getting closed twice (although some >> completely unrelated file handle might have snuck into that slot >> between the two close()s). >> >> Or you could end up w/ the same sort of thing for gem handles (which >> are unique to the drm device fd, so if you open() the device multiple >> times..). I did initially have some confusion about this, w/ multiple >> fd_bo's (or pipe_resource's) being created for a given gem handle, and >> first one that gets deleted takes away the backing store that both >> userspace references where using. >> >> You might want to look at freedreno_drm_winsys.c and the crazy things >> it does.. I suspect virgl might need similar hacks. That is really >> one part of two, that ensures that we share the same pipe_screen, and >> therefore (from libdrm) fd_device, for a given drm device fd. The >> other part is that fd_device has hashtables to deal w/ double import >> of gem buffers. > > I think Rob Clark might be on the right track here. > > it sounds like the host is sending double deletes for some objects, which > sounds like a possible reference counting bug in the host. > > So possibly something drm_gralloc, but it could be a bug in mesa, though > I haven't triggered anything like this yet. Some more details. If I comment out the freeing of imported buffers in gralloc_drm_handle_unregister, things work a lot better. I think there is a missing reference taken on an alloc with an existing dmabuf FD. I've been comparing freedreno vs. pipe alloc/free implementations for gralloc. The freedreno alloc function will call drmPrimeFDToHandle and increment the BO ref count (in lookup_bo). The equivalent for virgl is in virgl_drm_winsys_resource_create_handle. It calls drmPrimeFDToHandle, but there is no reference taken. The shared handle case in that function does take a reference with a virgl_drm_resource_reference call. I may be off as my attempted fix doesn't work... Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [android-x86-devel] Re: need-help: how to change to newest mesa in android-x86?
On Mon, Jan 18, 2016 at 4:46 PM, Rob Clark wrote: > On Mon, Jan 18, 2016 at 5:18 PM, Rob Herring wrote: >> On Fri, Jan 15, 2016 at 3:10 PM, Dave Airlie wrote: >>>> >>>> well, nothing specific, but for example early on we had some confusion >>>> in drm_gralloc (when adding dmabuf fd support) about who close()d the >>>> fd's. Resulting in same fd getting closed twice (although some >>>> completely unrelated file handle might have snuck into that slot >>>> between the two close()s). >>>> >>>> Or you could end up w/ the same sort of thing for gem handles (which >>>> are unique to the drm device fd, so if you open() the device multiple >>>> times..). I did initially have some confusion about this, w/ multiple >>>> fd_bo's (or pipe_resource's) being created for a given gem handle, and >>>> first one that gets deleted takes away the backing store that both >>>> userspace references where using. >>>> >>>> You might want to look at freedreno_drm_winsys.c and the crazy things >>>> it does.. I suspect virgl might need similar hacks. That is really >>>> one part of two, that ensures that we share the same pipe_screen, and >>>> therefore (from libdrm) fd_device, for a given drm device fd. The >>>> other part is that fd_device has hashtables to deal w/ double import >>>> of gem buffers. >>> >>> I think Rob Clark might be on the right track here. >>> >>> it sounds like the host is sending double deletes for some objects, which >>> sounds like a possible reference counting bug in the host. >>> >>> So possibly something drm_gralloc, but it could be a bug in mesa, though >>> I haven't triggered anything like this yet. >> >> Some more details. If I comment out the freeing of imported buffers in >> gralloc_drm_handle_unregister, things work a lot better. I think there >> is a missing reference taken on an alloc with an existing dmabuf FD. >> I've been comparing freedreno vs. pipe alloc/free implementations for >> gralloc. The freedreno alloc function will call drmPrimeFDToHandle and >> increment the BO ref count (in lookup_bo). The equivalent for virgl is >> in virgl_drm_winsys_resource_create_handle. It calls >> drmPrimeFDToHandle, but there is no reference taken. The shared handle >> case in that function does take a reference with a >> virgl_drm_resource_reference call. I may be off as my attempted fix >> doesn't work... > > Hmm, so I guess I should have removed gralloc_drm_freedreno, but by > the time I actually got things working properly on ifc6410 I was using > gralloc_drm_pipe.c.. sorry if you had been looking at the wrong code. I was and should have realized that. Still, it got me looking at the right area. The virgl driver is missing a BO handle hash table for prime fd handles. It is only doing handle lookups for shared handles. I've fixed that, but have broken the shared handle hashing in the process. Looking at other drivers, it appears I need to have 2 hash tables. I'm guessing shared handles and prime handles are from different number spaces? > I originally abandoned gralloc_drm_freedreno once I realized that for > the refcnt'ing to work out I needed gralloc to share the same > fd_device ptr as mesa/gl. And by using gralloc_drm_pipe (plus that > freedreno winsys code I pointed to earlier) both gralloc and the gl > context share the same pipe_screen (and fd_device). Looks like this was the main problem. With screen ref counting and prime handle lookups, virgl seems to be working now. The radeon driver also does the same ref counting. Shouldn't this be common code rather than duplicated in each driver? Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] virgl: enable building on Android
On Fri, Dec 18, 2015 at 11:01 AM, Emil Velikov wrote: > Thank you Rob ! > > On 17 December 2015 at 15:45, Rob Herring wrote: >> This is just a copy-n-paste and rename of vc4 Android makefiles. >> > Looks great. > > Rob, I take it that you've at least compile tested this patch ? > > Cc: "11.1" > Reviewed-by: Emil Velikov > > I'll apply this some time next week. It looks like these 2 patches never got applied. Rob ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 6/6] virgl: also build vtest for Android
Enabling swrast on Android causes a link error because vtest is missing. Signed-off-by: Rob Herring --- src/gallium/Android.mk| 2 +- src/gallium/targets/dri/Android.mk| 2 +- src/gallium/winsys/virgl/vtest/Android.mk | 33 +++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/gallium/winsys/virgl/vtest/Android.mk diff --git a/src/gallium/Android.mk b/src/gallium/Android.mk index 749be7d..2b469b6 100644 --- a/src/gallium/Android.mk +++ b/src/gallium/Android.mk @@ -85,7 +85,7 @@ endif # virgl ifneq ($(filter virgl, $(MESA_GPU_DRIVERS)),) -SUBDIRS += winsys/virgl/drm drivers/virgl +SUBDIRS += winsys/virgl/drm winsys/virgl/vtest drivers/virgl endif # vmwgfx diff --git a/src/gallium/targets/dri/Android.mk b/src/gallium/targets/dri/Android.mk index 96292a0..4acd093 100644 --- a/src/gallium/targets/dri/Android.mk +++ b/src/gallium/targets/dri/Android.mk @@ -94,7 +94,7 @@ gallium_DRIVERS += libmesa_winsys_vc4 libmesa_pipe_vc4 endif ifneq ($(filter virgl,$(MESA_GPU_DRIVERS)),) LOCAL_CFLAGS += -DGALLIUM_VIRGL -gallium_DRIVERS += libmesa_winsys_virgl libmesa_pipe_virgl +gallium_DRIVERS += libmesa_winsys_virgl libmesa_winsys_virgl_vtest libmesa_pipe_virgl endif ifneq ($(filter vmwgfx,$(MESA_GPU_DRIVERS)),) gallium_DRIVERS += libmesa_winsys_svga libmesa_pipe_svga diff --git a/src/gallium/winsys/virgl/vtest/Android.mk b/src/gallium/winsys/virgl/vtest/Android.mk new file mode 100644 index 000..3e084e4 --- /dev/null +++ b/src/gallium/winsys/virgl/vtest/Android.mk @@ -0,0 +1,33 @@ +# Copyright (C) 2014 Emil Velikov +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. + +LOCAL_PATH := $(call my-dir) + +# get C_SOURCES +include $(LOCAL_PATH)/Makefile.sources + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(C_SOURCES) + +LOCAL_MODULE := libmesa_winsys_virgl_vtest + +include $(GALLIUM_COMMON_MK) +include $(BUILD_STATIC_LIBRARY) -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/6] Android: Fix building secondary arch in mixed 32/64-bit builds
At least in Android M, using LOCAL_CC does not work for secondary arch when doing dual arch builds. Use LOCAL_CLFAGS and LOCAL_CONLYFLAGS instead. Cc: Emil Velikov Cc: Chih-Wei Huang Signed-off-by: Rob Herring --- Android.common.mk | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Android.common.mk b/Android.common.mk index 948561c..c882209 100644 --- a/Android.common.mk +++ b/Android.common.mk @@ -22,12 +22,8 @@ # DEALINGS IN THE SOFTWARE. # use c99 compiler by default -ifeq ($(LOCAL_CC),) ifeq ($(LOCAL_IS_HOST_MODULE),true) -LOCAL_CC := $(HOST_CC) -std=c99 -D_GNU_SOURCE -else -LOCAL_CC := $(TARGET_CC) -std=c99 -endif +LOCAL_CFLAGS += -D_GNU_SOURCE endif LOCAL_C_INCLUDES += \ @@ -60,6 +56,9 @@ LOCAL_CFLAGS += \ -fvisibility=hidden \ -Wno-sign-compare +LOCAL_CONLYFLAGS += \ + -std=c99 + ifeq ($(strip $(MESA_ENABLE_ASM)),true) ifeq ($(TARGET_ARCH),x86) LOCAL_CFLAGS += \ -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/6] Android: enable building on arm64
Define the DEFAULT_DRIVER_DIR for arm64 builds. Cc: Emil Velikov Cc: Chih-Wei Huang Signed-off-by: Rob Herring --- src/egl/Android.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/src/egl/Android.mk b/src/egl/Android.mk index ebd67af..ad902a0 100644 --- a/src/egl/Android.mk +++ b/src/egl/Android.mk @@ -44,6 +44,7 @@ LOCAL_CFLAGS := \ -DHAVE_ANDROID_PLATFORM ifeq ($(MESA_LOLLIPOP_BUILD),true) +LOCAL_CFLAGS_arm64 := -DDEFAULT_DRIVER_DIR=\"/system/lib64/dri\" LOCAL_CFLAGS_arm := -DDEFAULT_DRIVER_DIR=\"/system/lib/dri\" LOCAL_CFLAGS_x86 := -DDEFAULT_DRIVER_DIR=\"/system/lib/dri\" LOCAL_CFLAGS_x86_64 := -DDEFAULT_DRIVER_DIR=\"/system/lib64/dri\" -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/6] Android: fix build break from nir/glsl move to compiler/
Commits a39a8fbbaa12 ("nir: move to compiler/") and eb63640c1d38 ("glsl: move to compiler/") broke Android builds. Fix them. Built with i915, i965, freedreno, r300g, r600g, and virgl enabled. Cc: Emil Velikov Signed-off-by: Rob Herring --- Android.mk | 2 +- src/compiler/glsl/Android.gen.mk | 2 +- src/compiler/glsl/Android.mk | 3 +-- src/gallium/auxiliary/Android.mk | 2 +- src/gallium/drivers/freedreno/Android.mk | 2 +- src/gallium/targets/dri/Android.mk | 2 ++ src/mesa/drivers/dri/Android.mk | 2 ++ src/mesa/program/Android.mk | 2 +- 8 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Android.mk b/Android.mk index 908078a..2c56b73 100644 --- a/Android.mk +++ b/Android.mk @@ -87,7 +87,7 @@ SUBDIRS := \ src/loader \ src/mapi \ src/compiler \ - src/glsl \ + src/compiler/glsl \ src/mesa \ src/util \ src/egl \ diff --git a/src/compiler/glsl/Android.gen.mk b/src/compiler/glsl/Android.gen.mk index c5741b4..c0902b2 100644 --- a/src/compiler/glsl/Android.gen.mk +++ b/src/compiler/glsl/Android.gen.mk @@ -33,7 +33,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) LOCAL_C_INCLUDES += \ $(intermediates)/glcpp \ - $(MESA_TOP)/src/glsl/glcpp \ + $(LOCAL_PATH)/glcpp \ LOCAL_GENERATED_SOURCES += $(addprefix $(intermediates)/, \ $(LIBGLCPP_GENERATED_FILES) \ diff --git a/src/compiler/glsl/Android.mk b/src/compiler/glsl/Android.mk index 9cbb9a3..f5d96b3 100644 --- a/src/compiler/glsl/Android.mk +++ b/src/compiler/glsl/Android.mk @@ -36,7 +36,6 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := \ $(LIBGLCPP_FILES) \ $(LIBGLSL_FILES) \ - $(NIR_FILES) LOCAL_C_INCLUDES := \ $(MESA_TOP)/src/mapi \ @@ -67,7 +66,7 @@ LOCAL_C_INCLUDES := \ $(MESA_TOP)/src/gallium/include \ $(MESA_TOP)/src/gallium/auxiliary -LOCAL_STATIC_LIBRARIES := libmesa_glsl libmesa_glsl_utils libmesa_util +LOCAL_STATIC_LIBRARIES := libmesa_glsl libmesa_glsl_utils libmesa_util libmesa_compiler LOCAL_MODULE_TAGS := eng LOCAL_MODULE := glsl_compiler diff --git a/src/gallium/auxiliary/Android.mk b/src/gallium/auxiliary/Android.mk index 86430eb..31ceadc 100644 --- a/src/gallium/auxiliary/Android.mk +++ b/src/gallium/auxiliary/Android.mk @@ -46,7 +46,7 @@ endif # We need libmesa_glsl to get NIR's generated include directories. LOCAL_MODULE := libmesa_gallium -LOCAL_STATIC_LIBRARIES += libmesa_glsl +LOCAL_STATIC_LIBRARIES += libmesa_glsl libmesa_nir # generate sources LOCAL_MODULE_CLASS := STATIC_LIBRARIES diff --git a/src/gallium/drivers/freedreno/Android.mk b/src/gallium/drivers/freedreno/Android.mk index ed51835..3eb412f 100644 --- a/src/gallium/drivers/freedreno/Android.mk +++ b/src/gallium/drivers/freedreno/Android.mk @@ -39,7 +39,7 @@ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/ir3 LOCAL_SHARED_LIBRARIES := libdrm libdrm_freedreno -LOCAL_STATIC_LIBRARIES := libmesa_glsl +LOCAL_STATIC_LIBRARIES := libmesa_glsl libmesa_nir LOCAL_MODULE := libmesa_pipe_freedreno include $(GALLIUM_COMMON_MK) diff --git a/src/gallium/targets/dri/Android.mk b/src/gallium/targets/dri/Android.mk index d403085..96292a0 100644 --- a/src/gallium/targets/dri/Android.mk +++ b/src/gallium/targets/dri/Android.mk @@ -109,6 +109,8 @@ LOCAL_WHOLE_STATIC_LIBRARIES := \ libmesa_st_dri \ libmesa_st_mesa \ libmesa_glsl \ + libmesa_compiler \ + libmesa_nir \ libmesa_dri_common \ libmesa_megadriver_stub \ libmesa_gallium \ diff --git a/src/mesa/drivers/dri/Android.mk b/src/mesa/drivers/dri/Android.mk index 42bfd77..1789762 100644 --- a/src/mesa/drivers/dri/Android.mk +++ b/src/mesa/drivers/dri/Android.mk @@ -42,6 +42,8 @@ MESA_DRI_C_INCLUDES := \ MESA_DRI_WHOLE_STATIC_LIBRARIES := \ libmesa_glsl \ + libmesa_compiler \ + libmesa_nir \ libmesa_megadriver_stub \ libmesa_dri_common \ libmesa_dricore \ diff --git a/src/mesa/program/Android.mk b/src/mesa/program/Android.mk index 0bc97a6..79780cf 100644 --- a/src/mesa/program/Android.mk +++ b/src/mesa/program/Android.mk @@ -44,7 +44,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := libmesa_program LOCAL_MODULE_CLASS := STATIC_LIBRARIES -LOCAL_STATIC_LIBRARIES := libmesa_glsl +LOCAL_STATIC_LIBRARIES := libmesa_glsl libmesa_nir intermediates := $(call local-generated-sources-dir) -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev