2002-12-29 01:03:35

by Frank Davis

[permalink] [raw]
Subject: [PATCH] 2.5.53 : drivers/net/wan/x25_asy.c

Hello all,
The attached patch swaps the save_flags/cli/restore_flags combo with a
spinlock. Please review.

Regards,
Frank

--- linux/drivers/net/wan/x25_asy.c.old Sat Dec 28 18:49:00 2002
+++ linux/drivers/net/wan/x25_asy.c Sat Dec 28 18:54:51 2002
@@ -33,6 +33,7 @@
#include <linux/lapb.h>
#include <linux/init.h>
#include "x25_asy.h"
+#include <linux/spinlock.h>

typedef struct x25_ctrl {
struct x25_asy ctrl; /* X.25 things */
@@ -40,6 +41,7 @@
} x25_asy_ctrl_t;

static x25_asy_ctrl_t **x25_asy_ctrls = NULL;
+static spinlock_t x25_asy_slock = SPIN_LOCK_UNLOCKED;

int x25_asy_maxdev = SL_NRUNIT; /* Can be overridden with insmod! */

@@ -164,8 +166,7 @@
return;
}

- save_flags(flags);
- cli();
+ spin_lock_irqsave(&x25_asy_slock, flags);

oxbuff = sl->xbuff;
sl->xbuff = xbuff;
@@ -195,7 +196,7 @@

sl->buffsize = len;

- restore_flags(flags);
+ spin_unlock_irqrestore(&x25_asy_slock, flags);

if (oxbuff != NULL)
kfree(oxbuff);


2002-12-30 00:27:43

by Alan

[permalink] [raw]
Subject: Re: [PATCH] 2.5.53 : drivers/net/wan/x25_asy.c

On Sun, 2002-12-29 at 01:04, Frank Davis wrote:
> Hello all,
> The attached patch swaps the save_flags/cli/restore_flags combo with a
> spinlock. Please review.

You need to take the lock on the irq path as well