Commit ab3a3b51 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Remove cli()/.. from hisax/hscx driver

We use a per-card spinlock to protect interrupt and normal tx
path from each other.
parent 79d00d1d
...@@ -942,6 +942,7 @@ static int __devinit checkcard(int cardnr, char *id, int *busy_flag) ...@@ -942,6 +942,7 @@ static int __devinit checkcard(int cardnr, char *id, int *busy_flag)
cs->status_write = cs->status_buf; cs->status_write = cs->status_buf;
cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1; cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;
cs->typ = card->typ; cs->typ = card->typ;
spin_lock_init(&cs->lock);
SET_MODULE_OWNER(&cs->iif); SET_MODULE_OWNER(&cs->iif);
strcpy(cs->iif.id, id); strcpy(cs->iif.id, id);
cs->iif.channels = 2; cs->iif.channels = 2;
......
...@@ -881,6 +881,7 @@ struct icc_chip { ...@@ -881,6 +881,7 @@ struct icc_chip {
struct IsdnCardState { struct IsdnCardState {
unsigned char typ; unsigned char typ;
unsigned char subtyp; unsigned char subtyp;
spinlock_t lock;
int protocol; int protocol;
unsigned int irq; unsigned int irq;
unsigned long irq_flags; unsigned long irq_flags;
......
...@@ -102,32 +102,33 @@ void ...@@ -102,32 +102,33 @@ void
hscx_l2l1(struct PStack *st, int pr, void *arg) hscx_l2l1(struct PStack *st, int pr, void *arg)
{ {
struct sk_buff *skb = arg; struct sk_buff *skb = arg;
long flags; struct IsdnCardState *cs = st->l1.bcs->cs;
unsigned long flags;
switch (pr) { switch (pr) {
case (PH_DATA | REQUEST): case (PH_DATA | REQUEST):
save_flags(flags); spin_lock_irqsave(&cs->lock, flags);
cli();
if (st->l1.bcs->tx_skb) { if (st->l1.bcs->tx_skb) {
skb_queue_tail(&st->l1.bcs->squeue, skb); skb_queue_tail(&st->l1.bcs->squeue, skb);
restore_flags(flags);
} else { } else {
st->l1.bcs->tx_skb = skb; st->l1.bcs->tx_skb = skb;
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag); test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->hw.hscx.count = 0; st->l1.bcs->hw.hscx.count = 0;
restore_flags(flags);
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs); st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
} }
spin_unlock_irqrestore(&cs->lock, flags);
break; break;
case (PH_PULL | INDICATION): case (PH_PULL | INDICATION):
spin_lock_irqsave(&cs->lock, flags);
if (st->l1.bcs->tx_skb) { if (st->l1.bcs->tx_skb) {
printk(KERN_WARNING "hscx_l2l1: this shouldn't happen\n"); printk(KERN_WARNING "hscx_l2l1: this shouldn't happen\n");
break; } else {
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->hw.hscx.count = 0;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
} }
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag); spin_unlock_irqrestore(&cs->lock, flags);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->hw.hscx.count = 0;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
break; break;
case (PH_PULL | REQUEST): case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) { if (!st->l1.bcs->tx_skb) {
......
...@@ -43,23 +43,16 @@ waitforXFW(struct IsdnCardState *cs, int hscx) ...@@ -43,23 +43,16 @@ waitforXFW(struct IsdnCardState *cs, int hscx)
static inline void static inline void
WriteHSCXCMDR(struct IsdnCardState *cs, int hscx, u_char data) WriteHSCXCMDR(struct IsdnCardState *cs, int hscx, u_char data)
{ {
long flags;
save_flags(flags);
cli();
waitforCEC(cs, hscx); waitforCEC(cs, hscx);
WRITEHSCX(cs, hscx, HSCX_CMDR, data); WRITEHSCX(cs, hscx, HSCX_CMDR, data);
restore_flags(flags);
} }
static void static void
hscx_empty_fifo(struct BCState *bcs, int count) hscx_empty_fifo(struct BCState *bcs, int count)
{ {
u_char *ptr; u_char *ptr;
struct IsdnCardState *cs = bcs->cs; struct IsdnCardState *cs = bcs->cs;
long flags;
if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO)) if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
debugl1(cs, "hscx_empty_fifo"); debugl1(cs, "hscx_empty_fifo");
...@@ -73,11 +66,8 @@ hscx_empty_fifo(struct BCState *bcs, int count) ...@@ -73,11 +66,8 @@ hscx_empty_fifo(struct BCState *bcs, int count)
} }
ptr = bcs->hw.hscx.rcvbuf + bcs->hw.hscx.rcvidx; ptr = bcs->hw.hscx.rcvbuf + bcs->hw.hscx.rcvidx;
bcs->hw.hscx.rcvidx += count; bcs->hw.hscx.rcvidx += count;
save_flags(flags);
cli();
READHSCXFIFO(cs, bcs->hw.hscx.hscx, ptr, count); READHSCXFIFO(cs, bcs->hw.hscx.hscx, ptr, count);
WriteHSCXCMDR(cs, bcs->hw.hscx.hscx, 0x80); WriteHSCXCMDR(cs, bcs->hw.hscx.hscx, 0x80);
restore_flags(flags);
if (cs->debug & L1_DEB_HSCX_FIFO) { if (cs->debug & L1_DEB_HSCX_FIFO) {
char *t = bcs->blog; char *t = bcs->blog;
...@@ -89,14 +79,12 @@ hscx_empty_fifo(struct BCState *bcs, int count) ...@@ -89,14 +79,12 @@ hscx_empty_fifo(struct BCState *bcs, int count)
} }
static void static void
hscx_fill_fifo(struct BCState *bcs) __hscx_fill_fifo(struct BCState *bcs)
{ {
struct IsdnCardState *cs = bcs->cs; struct IsdnCardState *cs = bcs->cs;
int more, count; int more, count;
int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags)? 64: 32; int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags)? 64: 32;
u_char *ptr; u_char *ptr;
long flags;
if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO)) if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
debugl1(cs, "hscx_fill_fifo"); debugl1(cs, "hscx_fill_fifo");
...@@ -114,15 +102,12 @@ hscx_fill_fifo(struct BCState *bcs) ...@@ -114,15 +102,12 @@ hscx_fill_fifo(struct BCState *bcs)
count = bcs->tx_skb->len; count = bcs->tx_skb->len;
waitforXFW(cs, bcs->hw.hscx.hscx); waitforXFW(cs, bcs->hw.hscx.hscx);
save_flags(flags);
cli();
ptr = bcs->tx_skb->data; ptr = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, count); skb_pull(bcs->tx_skb, count);
bcs->tx_cnt -= count; bcs->tx_cnt -= count;
bcs->hw.hscx.count += count; bcs->hw.hscx.count += count;
WRITEHSCXFIFO(cs, bcs->hw.hscx.hscx, ptr, count); WRITEHSCXFIFO(cs, bcs->hw.hscx.hscx, ptr, count);
WriteHSCXCMDR(cs, bcs->hw.hscx.hscx, more ? 0x8 : 0xa); WriteHSCXCMDR(cs, bcs->hw.hscx.hscx, more ? 0x8 : 0xa);
restore_flags(flags);
if (cs->debug & L1_DEB_HSCX_FIFO) { if (cs->debug & L1_DEB_HSCX_FIFO) {
char *t = bcs->blog; char *t = bcs->blog;
...@@ -133,6 +118,17 @@ hscx_fill_fifo(struct BCState *bcs) ...@@ -133,6 +118,17 @@ hscx_fill_fifo(struct BCState *bcs)
} }
} }
static void
hscx_fill_fifo(struct BCState *bcs)
{
struct IsdnCardState *cs = bcs->cs;
unsigned long flags;
spin_lock_irqsave(&cs->lock, flags);
__hscx_fill_fifo(bcs);
spin_unlock_irqrestore(&cs->lock, flags);
}
static inline void static inline void
hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx) hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx)
{ {
...@@ -208,7 +204,7 @@ hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx) ...@@ -208,7 +204,7 @@ hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx)
if (val & 0x10) { /* XPR */ if (val & 0x10) { /* XPR */
if (bcs->tx_skb) { if (bcs->tx_skb) {
if (bcs->tx_skb->len) { if (bcs->tx_skb->len) {
hscx_fill_fifo(bcs); __hscx_fill_fifo(bcs);
return; return;
} else { } else {
if (bcs->st->lli.l1writewakeup && if (bcs->st->lli.l1writewakeup &&
...@@ -222,7 +218,7 @@ hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx) ...@@ -222,7 +218,7 @@ hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx)
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) { if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
bcs->hw.hscx.count = 0; bcs->hw.hscx.count = 0;
test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
hscx_fill_fifo(bcs); __hscx_fill_fifo(bcs);
} else { } else {
test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
hscx_sched_event(bcs, B_XMTBUFREADY); hscx_sched_event(bcs, B_XMTBUFREADY);
...@@ -237,12 +233,13 @@ hscx_int_main(struct IsdnCardState *cs, u_char val) ...@@ -237,12 +233,13 @@ hscx_int_main(struct IsdnCardState *cs, u_char val)
u_char exval; u_char exval;
struct BCState *bcs; struct BCState *bcs;
spin_lock(&cs->lock);
if (val & 0x01) { if (val & 0x01) {
bcs = cs->bcs + 1; bcs = cs->bcs + 1;
exval = READHSCX(cs, 1, HSCX_EXIR); exval = READHSCX(cs, 1, HSCX_EXIR);
if (exval & 0x40) { if (exval & 0x40) {
if (bcs->mode == 1) if (bcs->mode == 1)
hscx_fill_fifo(bcs); __hscx_fill_fifo(bcs);
else { else {
#ifdef ERROR_STATISTIC #ifdef ERROR_STATISTIC
bcs->err_tx++; bcs->err_tx++;
...@@ -272,7 +269,7 @@ hscx_int_main(struct IsdnCardState *cs, u_char val) ...@@ -272,7 +269,7 @@ hscx_int_main(struct IsdnCardState *cs, u_char val)
exval = READHSCX(cs, 0, HSCX_EXIR); exval = READHSCX(cs, 0, HSCX_EXIR);
if (exval & 0x40) { if (exval & 0x40) {
if (bcs->mode == L1_MODE_TRANS) if (bcs->mode == L1_MODE_TRANS)
hscx_fill_fifo(bcs); __hscx_fill_fifo(bcs);
else { else {
/* Here we lost an TX interrupt, so /* Here we lost an TX interrupt, so
* restart transmitting the whole frame. * restart transmitting the whole frame.
...@@ -298,4 +295,5 @@ hscx_int_main(struct IsdnCardState *cs, u_char val) ...@@ -298,4 +295,5 @@ hscx_int_main(struct IsdnCardState *cs, u_char val)
debugl1(cs, "HSCX A interrupt %x", exval); debugl1(cs, "HSCX A interrupt %x", exval);
hscx_interrupt(cs, exval, 0); hscx_interrupt(cs, exval, 0);
} }
spin_unlock(&cs->lock);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment