Am Mittwoch 25 Februar 2009 10:36:24 schrieb Pauli Nieminen:
> Attached patch fixes freeze if r200 driver makes debug output to
> terminal. It also makes dri driver crash instead of silent exist when
> there is fatal error.
>
> Basic idea is to call special debug output function instead of
> fprintf. This debug function then checks if hardware lock is held. If
> lock is held output is queued to linked list. UNLOCK_HARDWARE then
> calls debug function that outputs all queued messages.
>
> Patch also changes all exit calls to UNLOCK_HARDWARE(); abort();
> combination so it is easier to get backtrace if facing bug in driver
> code.
>
> This code is nowhere near production quality but it is enough to test
> that idea works and I can do "R200_DEBUG=all glxgears" in terminal
> without freeze. Also I tested 3D Mark 2001 SE (without r200 debug) in
> wine so this shouldn't have caused regression.
>
> What should be still done?
> - Make this functionality shared between dri drivers
> - Thread safety? r200DebugPrintf is not safe if application uses
> opengl from multiple threads.

Actually, an OpenGL context must not be used from multiple threads at the same 
time. So as long as the output queue is per-context, there shouldn't be a 
problem.

> - Optimized memory handling. -- Calling twice malloc for each message
> can't be correct. :)

Actually, there are significantly worse problems in the code. Using vsprintf 
is absolutely incorrect and will cause additional bugs down the line. Also, 
the writen < 0 check is incorrect. Please read the manpage for vsnprintf for 
details on how to do this kind of code correctly.

> - Better error handling. -- There is still some error handling missing
> - Make assert also call unlock_hardware before abort

I'm wondering - shouldn't the DRM automatically release the lock if a client 
exits? I was under the impression that this was already done, but if not, it 
is definitely a kernel bug that needs fixing.

Sprinkling unlock_hardwares in the userspace code is the wrong approach, 
because it won't help e.g. in the case of segfaults.

cu,
Nicolai

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to