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)
cs->status_write = cs->status_buf;
cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;
cs->typ = card->typ;
spin_lock_init(&cs->lock);
SET_MODULE_OWNER(&cs->iif);
strcpy(cs->iif.id, id);
cs->iif.channels = 2;
......
......@@ -881,6 +881,7 @@ struct icc_chip {
struct IsdnCardState {
unsigned char typ;
unsigned char subtyp;
spinlock_t lock;
int protocol;
unsigned int irq;
unsigned long irq_flags;
......
......@@ -102,32 +102,33 @@ void
hscx_l2l1(struct PStack *st, int pr, void *arg)
{
struct sk_buff *skb = arg;
long flags;
struct IsdnCardState *cs = st->l1.bcs->cs;
unsigned long flags;
switch (pr) {
case (PH_DATA | REQUEST):
save_flags(flags);
cli();
spin_lock_irqsave(&cs->lock, flags);
if (st->l1.bcs->tx_skb) {
skb_queue_tail(&st->l1.bcs->squeue, skb);
restore_flags(flags);
} else {
st->l1.bcs->tx_skb = skb;
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->hw.hscx.count = 0;
restore_flags(flags);
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
}
spin_unlock_irqrestore(&cs->lock, flags);
break;
case (PH_PULL | INDICATION):
spin_lock_irqsave(&cs->lock, flags);
if (st->l1.bcs->tx_skb) {
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);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->hw.hscx.count = 0;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
spin_unlock_irqrestore(&cs->lock, flags);
break;
case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) {
......
......@@ -43,23 +43,16 @@ waitforXFW(struct IsdnCardState *cs, int hscx)
static inline void
WriteHSCXCMDR(struct IsdnCardState *cs, int hscx, u_char data)
{
long flags;
save_flags(flags);
cli();
waitforCEC(cs, hscx);
WRITEHSCX(cs, hscx, HSCX_CMDR, data);
restore_flags(flags);
}
static void
hscx_empty_fifo(struct BCState *bcs, int count)
{
u_char *ptr;
struct IsdnCardState *cs = bcs->cs;
long flags;
if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
debugl1(cs, "hscx_empty_fifo");
......@@ -73,11 +66,8 @@ hscx_empty_fifo(struct BCState *bcs, int count)
}
ptr = bcs->hw.hscx.rcvbuf + bcs->hw.hscx.rcvidx;
bcs->hw.hscx.rcvidx += count;
save_flags(flags);
cli();
READHSCXFIFO(cs, bcs->hw.hscx.hscx, ptr, count);
WriteHSCXCMDR(cs, bcs->hw.hscx.hscx, 0x80);
restore_flags(flags);
if (cs->debug & L1_DEB_HSCX_FIFO) {
char *t = bcs->blog;
......@@ -89,14 +79,12 @@ hscx_empty_fifo(struct BCState *bcs, int count)
}
static void
hscx_fill_fifo(struct BCState *bcs)
__hscx_fill_fifo(struct BCState *bcs)
{
struct IsdnCardState *cs = bcs->cs;
int more, count;
int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags)? 64: 32;
u_char *ptr;
long flags;
if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
debugl1(cs, "hscx_fill_fifo");
......@@ -114,15 +102,12 @@ hscx_fill_fifo(struct BCState *bcs)
count = bcs->tx_skb->len;
waitforXFW(cs, bcs->hw.hscx.hscx);
save_flags(flags);
cli();
ptr = bcs->tx_skb->data;
skb_pull(bcs->tx_skb, count);
bcs->tx_cnt -= count;
bcs->hw.hscx.count += count;
WRITEHSCXFIFO(cs, bcs->hw.hscx.hscx, ptr, count);
WriteHSCXCMDR(cs, bcs->hw.hscx.hscx, more ? 0x8 : 0xa);
restore_flags(flags);
if (cs->debug & L1_DEB_HSCX_FIFO) {
char *t = bcs->blog;
......@@ -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
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 (bcs->tx_skb) {
if (bcs->tx_skb->len) {
hscx_fill_fifo(bcs);
__hscx_fill_fifo(bcs);
return;
} else {
if (bcs->st->lli.l1writewakeup &&
......@@ -222,7 +218,7 @@ hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx)
if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
bcs->hw.hscx.count = 0;
test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
hscx_fill_fifo(bcs);
__hscx_fill_fifo(bcs);
} else {
test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
hscx_sched_event(bcs, B_XMTBUFREADY);
......@@ -237,12 +233,13 @@ hscx_int_main(struct IsdnCardState *cs, u_char val)
u_char exval;
struct BCState *bcs;
spin_lock(&cs->lock);
if (val & 0x01) {
bcs = cs->bcs + 1;
exval = READHSCX(cs, 1, HSCX_EXIR);
if (exval & 0x40) {
if (bcs->mode == 1)
hscx_fill_fifo(bcs);
__hscx_fill_fifo(bcs);
else {
#ifdef ERROR_STATISTIC
bcs->err_tx++;
......@@ -272,7 +269,7 @@ hscx_int_main(struct IsdnCardState *cs, u_char val)
exval = READHSCX(cs, 0, HSCX_EXIR);
if (exval & 0x40) {
if (bcs->mode == L1_MODE_TRANS)
hscx_fill_fifo(bcs);
__hscx_fill_fifo(bcs);
else {
/* Here we lost an TX interrupt, so
* restart transmitting the whole frame.
......@@ -298,4 +295,5 @@ hscx_int_main(struct IsdnCardState *cs, u_char val)
debugl1(cs, "HSCX A interrupt %x", exval);
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