Skip to contentSkip to conversation

Char: istallion, init+locking fixes

PATCH In review Ingo Korb 3 participants 4 messages Jun 18, 2007 – Jun 19, 2007 Char and misc drivers

lore
Share & tools
lore

Ingo Korb

author
#0 lore raw

PATCH 1/1 Char: istallion, init+locking fixes

Move brdp->iosize assignment in stli_initecp up a few lines to stop the driver from requesting an I/O region of length 0.

Remove spin_lock_irqsave/spin_unlock_irqrestore from __stli_sendcmd as all users of that function take the lock already.

---
One thing I dislike about this driver: It polls its cards every jiffy to look for new data. The cards are able to use interrupts (some of the drivers for other OSes use them), but as far as I know there is no open documentation. Unfortunately the DOS driver (probably easiest to analyze) also uses polling. =(

drivers/char/istallion.c +2 -5
index 7b279d1..0bc1c37 100644
@@ -2168,8 +2168,6 @@ static void __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigne
 	unsigned char __iomem *bits;
 	unsigned long flags;
 
-	spin_lock_irqsave(&brd_lock, flags);
-
 	if (test_bit(ST_CMDING, &portp->state)) {
 		printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n",
 				(int) cmd);
@@ -2194,7 +2192,6 @@ static void __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigne
 	writeb(readb(bits) | portp->portbit, bits);
 	set_bit(ST_CMDING, &portp->state);
 	EBRDDISABLE(brdp);
-	spin_unlock_irqrestore(&brd_lock, flags);
 }
 
 static void stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback)
@@ -3218,13 +3215,13 @@ static int stli_initecp(struct stlibrd *brdp)
 		goto err;
 	}
 
+	brdp->iosize = ECP_IOSIZE;
+
 	if (!request_region(brdp->iobase, brdp->iosize, "istallion")) {
 		retval = -EIO;
 		goto err;
 	}
 
-	brdp->iosize = ECP_IOSIZE;
-
 /*
  *	Based on the specific board type setup the common vars to access
  *	and enable shared memory. Set all board specific information now
#1 lore raw

Ingo Korb napsal(a):

Quoted 20 lines

Move brdp->iosize assignment in stli_initecp up a few lines to stop the driver from requesting an I/O region of length 0.

Remove spin_lock_irqsave/spin_unlock_irqrestore from __stli_sendcmd as all users of that function take the lock already.

---
One thing I dislike about this driver: It polls its cards every jiffy to look for new data. The cards are able to use interrupts (some of the drivers for other OSes use them), but as far as I know there is no open documentation. Unfortunately the DOS driver (probably easiest to analyze) also uses polling. =(

drivers/char/istallion.c +0 -0
index 7b279d1..0bc1c37 100644

drivers/char/istallion.c static void __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigne · line 2169

Quoted 2 lines
drivers/char/istallion.c +0 -0
@@ -2168,8 +2168,6 @@ static void __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigne
 	unsigned char __iomem *bits;
 	unsigned long flags;

Remove the flags and you will see the bug, you introduced ;).

drivers/char/istallion.c static void __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigne · line 2195

Quoted 11 lines
drivers/char/istallion.c +0 -3
-	spin_lock_irqsave(&brd_lock, flags);
-
 	if (test_bit(ST_CMDING, &portp->state)) {
 		printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n",
 				(int) cmd);
@@ -2194,7 +2192,6 @@ static void __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigne
 	writeb(readb(bits) | portp->portbit, bits);
 	set_bit(ST_CMDING, &portp->state);
 	EBRDDISABLE(brdp);
-	spin_unlock_irqrestore(&brd_lock, flags);
 }

regards,

Signature · 4 lines
http://www.fi.muni.cz/~xslaby/            Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8  22A0 32CC 55C3 39D4 7A7E
#2 lore raw
Quoted 4 lines · Jiri Slaby

drivers/char/istallion.c static void __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigne · line 2169

Quoted 2 lines
drivers/char/istallion.c +0 -0
 	unsigned char __iomem *bits;
 	unsigned long flags;

Remove the flags and you will see the bug, you introduced ;).

Oops. I guess I shouldn't try to work on kernel stuff while tired. Fixed patch follows.

-ik

author
#3 lore raw

PATCH 1/1 Char: istallion, init+locking fixes (try 2)

In reply to Jiri Slaby

Move brdp->iosize assignment in stli_initecp up a few lines to stop the driver from requesting an I/O region of length 0.

Remove spin_lock_irqsave/spin_unlock_irqrestore from __stli_sendcmd as all users of that function take the lock already.

---

drivers/char/istallion.c +2 -7
index 7b279d1..becba24 100644
@@ -2166,14 +2166,10 @@ static void __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigne
 	cdkhdr_t __iomem *hdrp;
 	cdkctrl_t __iomem *cp;
 	unsigned char __iomem *bits;
-	unsigned long flags;
-
-	spin_lock_irqsave(&brd_lock, flags);
 
 	if (test_bit(ST_CMDING, &portp->state)) {
 		printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n",
 				(int) cmd);
-		spin_unlock_irqrestore(&brd_lock, flags);
 		return;
 	}
 
@@ -2194,7 +2190,6 @@ static void __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigne
 	writeb(readb(bits) | portp->portbit, bits);
 	set_bit(ST_CMDING, &portp->state);
 	EBRDDISABLE(brdp);
-	spin_unlock_irqrestore(&brd_lock, flags);
 }
 
 static void stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback)
@@ -3218,13 +3213,13 @@ static int stli_initecp(struct stlibrd *brdp)
 		goto err;
 	}
 
+	brdp->iosize = ECP_IOSIZE;
+
 	if (!request_region(brdp->iobase, brdp->iosize, "istallion")) {
 		retval = -EIO;
 		goto err;
 	}
 
-	brdp->iosize = ECP_IOSIZE;
-
 /*
  *	Based on the specific board type setup the common vars to access
  *	and enable shared memory. Set all board specific information now