linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: sm750fb: fix sparse warning for lock
@ 2015-08-05 13:26 Peng Fan
  2015-08-05 19:01 ` Greg KH
  2015-08-05 22:34 ` Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Peng Fan @ 2015-08-05 13:26 UTC (permalink / raw)
  To: sudipm.mukherjee, teddy.wang, gregkh
  Cc: linux-fbdev, devel, linux-kernel, van.freenix

Use __acquire() and __release() in the right place to silence the sparse
lock checking warning.

drivers/staging/sm750fb/sm750.c:177:13: warning: context imbalance in 'lynxfb_ops_fillrect' - different lock contexts for basic block
drivers/staging/sm750fb/sm750.c:243:9: warning: context imbalance in 'lynxfb_ops_copyarea' - different lock contexts for basic block
drivers/staging/sm750fb/sm750.c:247:13: warning: context imbalance in 'lynxfb_ops_imageblit' - different lock contexts for basic block

Signed-off-by: Peng Fan <van.freenix@gmail.com>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Teddy Wang <teddy.wang@siliconmotion.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/staging/sm750fb/sm750.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 8e201f1..5ba1c06 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -203,6 +203,8 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
 	 */
 	if (share->dual)
 		spin_lock(&share->slock);
+	else
+		__acquire(&share->slock);
 
 	share->accel.de_fillrect(&share->accel,
 				 base, pitch, Bpp,
@@ -211,6 +213,8 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
 				 color, rop);
 	if (share->dual)
 		spin_unlock(&share->slock);
+	else
+		__release(&share->slock);
 }
 
 static void lynxfb_ops_copyarea(struct fb_info *info,
@@ -235,6 +239,8 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
 	 */
 	if (share->dual)
 		spin_lock(&share->slock);
+	else
+		__acquire(&share->slock);
 
 	share->accel.de_copyarea(&share->accel,
 				 base, pitch, region->sx, region->sy,
@@ -242,6 +248,8 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
 				 region->width, region->height, HW_ROP2_COPY);
 	if (share->dual)
 		spin_unlock(&share->slock);
+	else
+		__release(&share->slock);
 }
 
 static void lynxfb_ops_imageblit(struct fb_info *info,
@@ -282,6 +290,8 @@ _do_work:
 	 */
 	if (share->dual)
 		spin_lock(&share->slock);
+	else
+		__acquire(&share->slock);
 
 	share->accel.de_imageblit(&share->accel,
 				  image->data, image->width>>3, 0,
@@ -291,6 +301,8 @@ _do_work:
 				  fgcol, bgcol, HW_ROP2_COPY);
 	if (share->dual)
 		spin_unlock(&share->slock);
+	else
+		__release(&share->slock);
 }
 
 static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
-- 
1.8.4


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

* Re: [PATCH] staging: sm750fb: fix sparse warning for lock
  2015-08-05 13:26 [PATCH] staging: sm750fb: fix sparse warning for lock Peng Fan
@ 2015-08-05 19:01 ` Greg KH
  2015-08-05 22:34 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2015-08-05 19:01 UTC (permalink / raw)
  To: Peng Fan; +Cc: sudipm.mukherjee, teddy.wang, devel, linux-fbdev, linux-kernel

On Wed, Aug 05, 2015 at 09:26:44PM +0800, Peng Fan wrote:
> Use __acquire() and __release() in the right place to silence the sparse
> lock checking warning.
> 
> drivers/staging/sm750fb/sm750.c:177:13: warning: context imbalance in 'lynxfb_ops_fillrect' - different lock contexts for basic block
> drivers/staging/sm750fb/sm750.c:243:9: warning: context imbalance in 'lynxfb_ops_copyarea' - different lock contexts for basic block
> drivers/staging/sm750fb/sm750.c:247:13: warning: context imbalance in 'lynxfb_ops_imageblit' - different lock contexts for basic block
> 
> Signed-off-by: Peng Fan <van.freenix@gmail.com>
> Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> Cc: Teddy Wang <teddy.wang@siliconmotion.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/staging/sm750fb/sm750.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
> index 8e201f1..5ba1c06 100644
> --- a/drivers/staging/sm750fb/sm750.c
> +++ b/drivers/staging/sm750fb/sm750.c
> @@ -203,6 +203,8 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
>  	 */
>  	if (share->dual)
>  		spin_lock(&share->slock);
> +	else
> +		__acquire(&share->slock);

That's horrid, please don't do stuff like this just to make a static
checker "quiet".

greg k-h

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

* Re: [PATCH] staging: sm750fb: fix sparse warning for lock
  2015-08-05 13:26 [PATCH] staging: sm750fb: fix sparse warning for lock Peng Fan
  2015-08-05 19:01 ` Greg KH
@ 2015-08-05 22:34 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2015-08-05 22:34 UTC (permalink / raw)
  To: Peng Fan
  Cc: sudipm.mukherjee, teddy.wang, gregkh, devel, linux-fbdev,
	linux-kernel

On Wed, Aug 05, 2015 at 09:26:44PM +0800, Peng Fan wrote:
> Use __acquire() and __release() in the right place to silence the sparse
> lock checking warning.
> 
> drivers/staging/sm750fb/sm750.c:177:13: warning: context imbalance in 'lynxfb_ops_fillrect' - different lock contexts for basic block
> drivers/staging/sm750fb/sm750.c:243:9: warning: context imbalance in 'lynxfb_ops_copyarea' - different lock contexts for basic block
> drivers/staging/sm750fb/sm750.c:247:13: warning: context imbalance in 'lynxfb_ops_imageblit' - different lock contexts for basic block
> 

Sparse is really bad at locking stuff.  Smatch is also really bad for
locking and I have been promising to re-write that check for years, but
I take comfort always in the fact that at least it's not as bad as
Sparse.

You should pretty much ignore Sparse locking warnings.

regards,
dan carpenter


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

end of thread, other threads:[~2015-08-05 22:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-05 13:26 [PATCH] staging: sm750fb: fix sparse warning for lock Peng Fan
2015-08-05 19:01 ` Greg KH
2015-08-05 22:34 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).