All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vmwgfx: add missing mutex_unlocks
@ 2012-08-04  5:33 Devendra Naga
  2012-08-06  8:07 ` Thomas Hellstrom
  0 siblings, 1 reply; 3+ messages in thread
From: Devendra Naga @ 2012-08-04  5:33 UTC (permalink / raw)
  To: David Airlie, Jakob Bornecrantz, Thomas Hellstrom, Dave Airlie,
	dri-devel
  Cc: 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.

Signed-off-by: Devendra Naga <develkernel412222@gmail.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
index a0c2f12..e3abd7a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
@@ -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;
 			}
 		}
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] vmwgfx: add missing mutex_unlocks
  2012-08-04  5:33 [PATCH] vmwgfx: add missing mutex_unlocks Devendra Naga
@ 2012-08-06  8:07 ` Thomas Hellstrom
  2012-08-06  8:12   ` Devendra Naga
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Hellstrom @ 2012-08-06  8:07 UTC (permalink / raw)
  To: Devendra Naga; +Cc: Dave Airlie, linux-graphics-maintainer, dri-devel

NAK,

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

/Thomas



On 08/04/2012 07:33 AM, Devendra Naga wrote:
> 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.
>
> Signed-off-by: Devendra Naga <develkernel412222@gmail.com>
> ---
>   drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c |    7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
> index a0c2f12..e3abd7a 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
> @@ -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;
>   			}
>   		}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] vmwgfx: add missing mutex_unlocks
  2012-08-06  8:07 ` Thomas Hellstrom
@ 2012-08-06  8:12   ` Devendra Naga
  0 siblings, 0 replies; 3+ messages in thread
From: Devendra Naga @ 2012-08-06  8:12 UTC (permalink / raw)
  To: Thomas Hellstrom; +Cc: Dave Airlie, linux-graphics-maintainer, dri-devel

Hi Thomas,

On Mon, Aug 6, 2012 at 1:52 PM, Thomas Hellstrom <thellstrom@vmware.com> wrote:
> 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.
> /Thomas
>
>
>
>
> On 08/04/2012 07:33 AM, Devendra Naga wrote:
>>
>> 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.
>>
>> Signed-off-by: Devendra Naga <develkernel412222@gmail.com>
>> ---
>>   drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c |    7 +++++--
>>   1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
>> b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
>> index a0c2f12..e3abd7a 100644
>> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
>> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
>> @@ -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;
>>                         }
>>                 }
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-08-06  8:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-04  5:33 [PATCH] vmwgfx: add missing mutex_unlocks Devendra Naga
2012-08-06  8:07 ` Thomas Hellstrom
2012-08-06  8:12   ` Devendra Naga

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.