Staging: xgifb: Remove CRIT[FLAGS | BEGIN | END] defines nd conditional spinlock compilation logic
Subsystems (2)
cover Staging: xgifb: Remove CRIT[FLAGS | BEGIN | END] defines nd conditional spinlock compilation logic
xgifb staging driver uses a set of defines that hides the synchronization mechanism used to access critical sections. Also, the use of spinlocks can be disabled in compile time.
Since the spinlocks ABI only are used in contexts were critical section exists (UP with preemption enabled and SMP machines), I think we should always have the spinlocks enabled and let the spinlock ABI choose to include the spinlocks or not. In the other hand if the driver doesn't need locking at all, then maybe we should just delete the spinlock logic.
This patchset first replaces all the defines used with explicit definitions, then removes all the defines and the spinlocks optional compilation logic.
The patchset is composed of the following patches:
[PATCH 1/2] Staging: xgifb: Remove CRIT[FLAGS | BEGIN | END] defines usage
[PATCH 2/2] Staging: xgifb: Removes CRIT[FLAGS | BEGIN | END] defines and conditional spinlock compilation logic
PATCH 1/2 Staging: xgifb: Remove CRIT[FLAGS | BEGIN | END] defines usage
--- drivers/staging/xgifb/XGI_accel.c | 43 ++++++++++++++++++++---------------- 1 files changed, 24 insertions(+), 19 deletions(-)
drivers/staging/xgifb/XGI_accel.c +24 -19
@@ -216,19 +216,21 @@ void XGIfb_syncaccel(void)int fbcon_XGI_sync (struct fb_info *info) { -if (!XGIfb_accel)return 0 ; -CRITFLAGS +unsigned long critflags =0 ; -XGI310Sync (); +if (!XGIfb_accel) +return 0 ; + +XGI310Sync (); -CRITEND - return 0; +spin_unlock_irqrestore (&xgi_video_info.lockaccel, critflags); +return 0 ; }void fbcon_XGI_fillrect (struct fb_info *info,const struct fb_fillrect *rect) { -int col=0 ; - CRITFLAGS +int col =0 ; +unsigned long critflags;if (!rect->width || !rect->height)
@@ -249,19 +251,20 @@ void fbcon_XGI_fillrect(struct fb_info *info, const struct fb_fillrect *rect) } -CRITBEGIN - XGI310SetupForSolidFill(col, myrops[rect->rop], 0); -XGI310SubsequentSolidFillRect (rect->dx, rect->dy, rect->width, rect->height); -CRITEND -XGI310Sync (); +spin_lock_irqsave (&xgi_video_info.lockaccel, critflags); +XGI310SetupForSolidFill (col, myrops[rect->rop],0 ); +XGI310SubsequentSolidFillRect (rect->dx, rect->dy, rect->width, + rect->height); +spin_unlock_irqrestore (&xgi_video_info.lockaccel, critflags); +XGI310Sync (); }void fbcon_XGI_copyarea (struct fb_info *info,const struct fb_copyarea *area) { -int xdir, ydir; -CRITFLAGS +int xdir, ydir; +unsigned long critflags;if (!XGIfb_accel) {
@@ -277,11 +280,13 @@ void fbcon_XGI_copyarea(struct fb_info *info, const struct fb_copyarea *area)if (area->sy < area->dy) ydir =0 ;else ydir =1 ; - CRITBEGIN - XGI310SetupForScreenToScreenCopy(xdir, ydir, 3, 0, -1); - XGI310SubsequentScreenToScreenCopy(area->sx, area->sy, area->dx, area->dy, area->width, area->height); - CRITEND - XGI310Sync(); +spin_lock_irqsave (&xgi_video_info.lockaccel, critflags); +XGI310SetupForScreenToScreenCopy (xdir, ydir,3 ,0 ,-1 ); +XGI310SubsequentScreenToScreenCopy (area->sx, area->sy, area->dx, + area->dy, area->width, + area->height); +spin_unlock_irqrestore (&xgi_video_info.lockaccel, critflags); +XGI310Sync (); }
Signature · 1 line
1.7.2.3
PATCH 2/2 Staging: xgifb: Removes CRIT[FLAGS | BEGIN | END] defines and conditional spinlock compilation logic
In reply to Javier Martinez Canillas--- drivers/staging/xgifb/XGI_accel.h | 11 ----------- 1 files changed, 0 insertions(+), 11 deletions(-)
drivers/staging/xgifb/XGI_accel.h +0 -11
@@ -18,19 +18,8 @@#ifndef _XGIFB_ACCEL_H#define _XGIFB_ACCEL_H -/* Guard accelerator accesses with spin_lock_irqsave? Works well without. */ -#undef XGIFB_USE_SPINLOCKS -#ifdef XGIFB_USE_SPINLOCKS #include <linux/spinlock.h> -#define CRITBEGIN spin_lock_irqsave(&xgi_video_info.lockaccel), critflags); -#define CRITEND spin_unlock_irqrestore(&xgi_video_info.lockaccel), critflags); -#define CRITFLAGS unsigned long critflags; -#else -#define CRITBEGIN -#define CRITEND -#define CRITFLAGS -#endif /* Definitions for the XGI engine communication. */
Signature · 1 line
1.7.2.3
Re: [PATCH 1/2] Staging: xgifb: Remove CRIT[FLAGS | BEGIN | END] defines usage
In reply to Javier Martinez CanillasHi Javier,
Your idea was good but there are a couple problems with this patch. I'm afraid you're going to need to fix it and resend.
You put the patch description in the 0/2 patch. It was a pretty decent patch description. Unfortunately the 0/2 descriptions get thrown away, and do not get included in the final git log. So they should go with the individual patches.
drivers/staging/xgifb/XGI_accel.c void XGIfb_syncaccel(void) · line 219
Quoted 5 lines · Javier Martinez Canillas
int
fbcon_XGI_sync(struct fb_info *info)
{drivers/staging/xgifb/XGI_accel.c +1
-2-if (!XGIfb_accel)return 0 ; -CRITFLAGS +unsigned long critflags =0 ;
It's better to just call it "flags" instead of "critflags" so that it's consistent with the rest of the kernel.
It's also not a good idea to initialize it to zero. I know that gcc prints a warning, but you can't just set it to zero to silence the warning. Also this change should have been mentioned in the patch description. Every behavior change should be described in the change log.
drivers/staging/xgifb/XGI_accel.c void XGIfb_syncaccel(void) · line 226
Quoted 10 lines
drivers/staging/xgifb/XGI_accel.c +5
-3-XGI310Sync (); +if (!XGIfb_accel) +return 0 ; + +XGI310Sync (); -CRITEND - return 0; +spin_unlock_irqrestore (&xgi_video_info.lockaccel, critflags);
I know you didn't introduce it, but this makes no sense at all. It's a random unlock, and in the original code critflags was uninitialized.
The only reason this works is because XGIfb_accel is always 0. So you can remove this function, and remove all the code that depends on XGIfb_accel. (In a separate patch of course).
regards,
dan carpenter
Hi,
From: Javier Martinez Canillas [[email protected]]:
Quoted 9 lines
xgifb staging driver uses a set of defines that hides the synchronization mechanism used to access critical sections. Also, the use of spinlocks can be disabled in compile time.
Since the spinlocks ABI only are used in contexts were critical section exists (UP with preemption enabled and SMP machines), I think we should always have the spinlocks enabled and let the spinlock ABI choose to include the spinlocks or not. In the other hand if the driver doesn't need locking at all, then maybe we should just delete the spinlock logic.
I think these should be just deleted. The acceleration functions are used by the framebuffer layer which should take care of concurrent access. Or can you point out some real scenario where the spinlocks are needed?
A.