Skip to contentSkip to conversation

vmwgfx: add missing mutex_unlocks

PATCH NAK Devendra Naga 2 participants 3 messages Aug 4, 2012 – Aug 6, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vmwgfx: add missing mutex_unlocks

we have done a proper mutex_unlock in the error cases of the vmw_fifo_reserve, but there are missing mutex unlocks where we return a valid pointer in vmw_fifo_reserve.

---
 drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c +5 -2
index a0c2f12..e3abd7a 100644
@@ -355,6 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
 				if (reserveable)
 					iowrite32(bytes, fifo_mem +
 						  SVGA_FIFO_RESERVED);
+				mutex_unlock(&fifo_state->fifo_mutex);
 				return fifo_mem + (next_cmd >> 2);
 			} else {
 				need_bounce = true;
@@ -363,10 +364,12 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
 
 		if (need_bounce) {
 			fifo_state->using_bounce_buffer = true;
-			if (bytes < fifo_state->static_buffer_size)
+			if (bytes < fifo_state->static_buffer_size) {
+				mutex_unlock(&fifo_state->fifo_mutex);
 				return fifo_state->static_buffer;
-			else {
+			} else {
 				fifo_state->dynamic_buffer = vmalloc(bytes);
+				mutex_unlock(&fifo_state->fifo_mutex);
 				return fifo_state->dynamic_buffer;
 			}
 		}
Signature · 1 line
1.7.9.5
#1 lore raw

NAK,

The mutex unlock is done in vmw_fifo_commit. The mutex is protecting the fifo memory against multiple simultaneous reservers.

/Thomas

Quoted 35 lines · Devendra Naga

we have done a proper mutex_unlock in the error cases of the vmw_fifo_reserve, but there are missing mutex unlocks where we return a valid pointer in vmw_fifo_reserve.

---
  drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c |    7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c +5 -2
index a0c2f12..e3abd7a 100644
@@ -355,6 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
  				if (reserveable)
  					iowrite32(bytes, fifo_mem +
  						  SVGA_FIFO_RESERVED);
+				mutex_unlock(&fifo_state->fifo_mutex);
  				return fifo_mem + (next_cmd >> 2);
  			} else {
  				need_bounce = true;
@@ -363,10 +364,12 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
 
  		if (need_bounce) {
  			fifo_state->using_bounce_buffer = true;
-			if (bytes < fifo_state->static_buffer_size)
+			if (bytes < fifo_state->static_buffer_size) {
+				mutex_unlock(&fifo_state->fifo_mutex);
  				return fifo_state->static_buffer;
-			else {
+			} else {
  				fifo_state->dynamic_buffer = vmalloc(bytes);
+				mutex_unlock(&fifo_state->fifo_mutex);
  				return fifo_state->dynamic_buffer;
  			}
  		}
#2 lore raw

Hi Thomas,

Quoted 5 lines · Thomas Hellstrom

NAK,

The mutex unlock is done in vmw_fifo_commit. The mutex is protecting the fifo memory against multiple simultaneous reservers.

Thanks for the answer :-). sorry for your time... i will definitely try more reading and analyse the code and then send patch if it needs really.

Quoted 49 lines

/Thomas

Quoted 41 lines · Devendra Naga

we have done a proper mutex_unlock in the error cases of the vmw_fifo_reserve, but
there are missing mutex unlocks where we return a valid pointer in vmw_fifo_reserve.

---
  drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c |    7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c +1 -0
index a0c2f12..e3abd7a 100644
@@ -355,6 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv,
 uint32_t bytes)
                                if (reserveable)
                                        iowrite32(bytes, fifo_mem +
                                                  SVGA_FIFO_RESERVED);
+                               mutex_unlock(&fifo_state->fifo_mutex);
                                return fifo_mem + (next_cmd >> 2);
                        } else {
                                need_bounce = true;
drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c +4 -2
@@ -363,10 +364,12 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv,
 uint32_t bytes)
                if (need_bounce) {
                        fifo_state->using_bounce_buffer = true;
-                       if (bytes < fifo_state->static_buffer_size)
+                       if (bytes < fifo_state->static_buffer_size) {
+                               mutex_unlock(&fifo_state->fifo_mutex);
                                return fifo_state->static_buffer;
-                       else {
+                       } else {
                                fifo_state->dynamic_buffer =
 vmalloc(bytes);
+                               mutex_unlock(&fifo_state->fifo_mutex);
                                return fifo_state->dynamic_buffer;
                        }
                }