From patchwork Wed Mar 11 01:28:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 5981461 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BFA329F318 for ; Wed, 11 Mar 2015 01:29:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D46B420383 for ; Wed, 11 Mar 2015 01:29:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 182AF20394 for ; Wed, 11 Mar 2015 01:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752685AbbCKB3V (ORCPT ); Tue, 10 Mar 2015 21:29:21 -0400 Received: from mail-we0-f176.google.com ([74.125.82.176]:38554 "EHLO mail-we0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751532AbbCKB3R (ORCPT ); Tue, 10 Mar 2015 21:29:17 -0400 Received: by wevk48 with SMTP id k48so5758216wev.5; Tue, 10 Mar 2015 18:29:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FmMooWbCQex22hCv9iBbFpraOBYLGscj+VERTVjwFZ4=; b=nyqDDNZm3J4xxi+uh/UDRZpUyI7ykljR233HwUp62IkHAX2enbNj1TvJXRCVqPSM13 FdAQrMjmDEz8y8axC5PmMV/OD+RZbk/S78qQw7XfQ39IqolwyS811Qy8hsE/Ai/Y9IQp aR5Luuy+Z+PBLIgHceKjPcTlrPKQR1+QYIbqYf/5GdbFZq0xQbaAj4zrVLH35gi1eQhC pGHVvhNgd3Oc6Fdir5Eqobn50at8h97uxfDvgY4fVK3z6nqHZivgANuuDElMsMToFnYh C5cIMyXsN7NDo4BaoFLqVbRlDyOTT2CvJBi7pHzLf+RGIe4Xa7PGRr/KCMOiSGEOShVO O/2A== X-Received: by 10.180.198.162 with SMTP id jd2mr114421045wic.21.1426037355866; Tue, 10 Mar 2015 18:29:15 -0700 (PDT) Received: from localhost (cpc71925-newt30-2-0-cust4.19-3.cable.virginm.net. [82.35.188.5]) by mx.google.com with ESMTPSA id p1sm3870616wib.23.2015.03.10.18.29.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Mar 2015 18:29:14 -0700 (PDT) From: Lorenzo Stoakes To: sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, gregkh@linuxfoundation.org Cc: linux-fbdev@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Lorenzo Stoakes Subject: [PATCH 6/6] staging: sm750fb: Spinlock and unlock in the same block Date: Wed, 11 Mar 2015 01:28:45 +0000 Message-Id: <1426037325-8392-6-git-send-email-lstoakes@gmail.com> X-Mailer: git-send-email 2.3.2 In-Reply-To: <1426037325-8392-1-git-send-email-lstoakes@gmail.com> References: <1426037325-8392-1-git-send-email-lstoakes@gmail.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch combines spinlock locks and unlocks together in the same block rather than occurring in separate blocks preventing a possible deadlock. This fixes the following sparse warnings:- drivers/staging/sm750fb/sm750.c:218:22: warning: context imbalance in 'lynxfb_ops_fillrect' - different lock contexts for basic block drivers/staging/sm750fb/sm750.c:241:22: warning: context imbalance in 'lynxfb_ops_copyarea' - different lock contexts for basic block drivers/staging/sm750fb/sm750.c:282:22: warning: context imbalance in 'lynxfb_ops_imageblit' - different lock contexts for basic block Unfortunately this change involves code (and comment) duplication. Signed-off-by: Lorenzo Stoakes --- drivers/staging/sm750fb/sm750.c | 76 +++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index 3e36b6a..58c7518 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -56,23 +56,6 @@ static char * g_settings = NULL; static int g_dualview = 0; static char * g_option = NULL; -/* if not use spin_lock,system will die if user load driver - * and immediatly unload driver frequently (dual)*/ -static inline void myspin_lock(spinlock_t * sl){ - struct lynx_share * share; - share = container_of(sl,struct lynx_share,slock); - if(share->dual){ - spin_lock(sl); - } -} - -static inline void myspin_unlock(spinlock_t * sl){ - struct lynx_share * share; - share = container_of(sl,struct lynx_share,slock); - if(share->dual){ - spin_unlock(sl); - } -} static const struct fb_videomode lynx750_ext[] = { /* 1024x600-60 VESA [1.71:1] */ {NULL, 60, 1024, 600, 20423, 144, 40, 18, 1, 104, 3, @@ -209,13 +192,22 @@ static void lynxfb_ops_fillrect(struct fb_info* info,const struct fb_fillrect* r color = (Bpp == 1)?region->color:((u32*)info->pseudo_palette)[region->color]; rop = ( region->rop != ROP_COPY ) ? HW_ROP2_XOR:HW_ROP2_COPY; - myspin_lock(&share->slock); - share->accel.de_fillrect(&share->accel, - base,pitch,Bpp, - region->dx,region->dy, - region->width,region->height, - color,rop); - myspin_unlock(&share->slock); + /* if not use spin_lock,system will die if user load driver + * and immediatly unload driver frequently (dual)*/ + if (share->dual) { + spin_lock(&share->slock); + share->accel.de_fillrect(&share->accel, + base,pitch,Bpp, + region->dx,region->dy, + region->width,region->height, + color,rop); + spin_unlock(&share->slock); + } else + share->accel.de_fillrect(&share->accel, + base,pitch,Bpp, + region->dx,region->dy, + region->width,region->height, + color,rop); } static void lynxfb_ops_copyarea(struct fb_info * info,const struct fb_copyarea * region) @@ -233,12 +225,20 @@ static void lynxfb_ops_copyarea(struct fb_info * info,const struct fb_copyarea * pitch = info->fix.line_length; Bpp = info->var.bits_per_pixel >> 3; - myspin_lock(&share->slock); - share->accel.de_copyarea(&share->accel, - base,pitch,region->sx,region->sy, - base,pitch,Bpp,region->dx,region->dy, - region->width,region->height,HW_ROP2_COPY); - myspin_unlock(&share->slock); + /* if not use spin_lock,system will die if user load driver + * and immediatly unload driver frequently (dual)*/ + if (share->dual) { + spin_lock(&share->slock); + share->accel.de_copyarea(&share->accel, + base,pitch,region->sx,region->sy, + base,pitch,Bpp,region->dx,region->dy, + region->width,region->height,HW_ROP2_COPY); + spin_unlock(&share->slock); + } else + share->accel.de_copyarea(&share->accel, + base,pitch,region->sx,region->sy, + base,pitch,Bpp,region->dx,region->dy, + region->width,region->height,HW_ROP2_COPY); } static void lynxfb_ops_imageblit(struct fb_info*info,const struct fb_image* image) @@ -272,14 +272,24 @@ static void lynxfb_ops_imageblit(struct fb_info*info,const struct fb_image* imag } return; _do_work: - myspin_lock(&share->slock); - share->accel.de_imageblit(&share->accel, + /* if not use spin_lock,system will die if user load driver + * and immediatly unload driver frequently (dual)*/ + if (share->dual) { + spin_lock(&share->slock); + share->accel.de_imageblit(&share->accel, + image->data,image->width>>3,0, + base,pitch,Bpp, + image->dx,image->dy, + image->width,image->height, + fgcol,bgcol,HW_ROP2_COPY); + spin_unlock(&share->slock); + } else + share->accel.de_imageblit(&share->accel, image->data,image->width>>3,0, base,pitch,Bpp, image->dx,image->dy, image->width,image->height, fgcol,bgcol,HW_ROP2_COPY); - myspin_unlock(&share->slock); } static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,