Commit 574466e8 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN/HiSax: Remove broken home-made lock primitives

The HFC subdrivers chose to use atomic ops to re-implement sth
like broken spinlocks. That's now gone. Basically all races should
be taken care of by the fact that we take cs->lock before going down
to the hardware, this locks protects from concurrent accesses from
IRQ context. Well, some rare paths (setting mode etc) don't take the
lock yet, so it's not quite done yet.
parent 9abd1799
......@@ -75,7 +75,6 @@
const char *enternow_pci_rev = "$Revision: 1.1.2.1 $";
static spinlock_t enternow_pci_lock = SPIN_LOCK_UNLOCKED;
/* *************************** I/O-Interface functions ************************************* */
......@@ -231,13 +230,8 @@ enpci_interrupt(int intno, void *dev_id, struct pt_regs *regs)
{
struct IsdnCardState *cs = dev_id;
BYTE sval, ir;
unsigned long flags;
if (!cs) {
printk(KERN_WARNING "enter:now PCI: Spurious interrupt!\n");
return;
}
spin_lock(&cs->lock);
sval = InByte(cs->hw.njet.base + NETJET_IRQSTAT1);
......@@ -251,7 +245,6 @@ enpci_interrupt(int intno, void *dev_id, struct pt_regs *regs)
/* DMA-Interrupt: B-channel-stuff */
/* set bits in sval to indicate which page is free */
spin_lock_irqsave(&enternow_pci_lock, flags);
/* set bits in sval to indicate which page is free */
if (inl(cs->hw.njet.base + NETJET_DMA_WRITE_ADR) <
inl(cs->hw.njet.base + NETJET_DMA_WRITE_IRQ))
......@@ -265,14 +258,8 @@ enpci_interrupt(int intno, void *dev_id, struct pt_regs *regs)
sval = sval | 0x02;
else /* the 1st read page is free */
sval = sval | 0x01;
if (sval != cs->hw.njet.last_is0) /* we have a DMA interrupt */
{
if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
spin_unlock_irqrestore(&enternow_pci_lock, flags);
return;
}
if (sval != cs->hw.njet.last_is0) { /* we have a DMA interrupt */
cs->hw.njet.irqstat0 = sval;
spin_unlock_irqrestore(&enternow_pci_lock, flags);
if ((cs->hw.njet.irqstat0 & NETJET_IRQM0_READ) !=
(cs->hw.njet.last_is0 & NETJET_IRQM0_READ))
/* we have a read dma int */
......@@ -281,9 +268,8 @@ enpci_interrupt(int intno, void *dev_id, struct pt_regs *regs)
(cs->hw.njet.last_is0 & NETJET_IRQM0_WRITE))
/* we have a write dma int */
write_tiger(cs);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
} else
spin_unlock_irqrestore(&enternow_pci_lock, flags);
}
spin_unlock(&cs->lock);
}
......@@ -296,7 +282,6 @@ setup_enternow_pci(struct IsdnCard *card)
int bytecnt;
struct IsdnCardState *cs = card->cs;
char tmp[64];
unsigned long flags;
#if CONFIG_PCI
#ifdef __BIG_ENDIAN
......@@ -306,7 +291,6 @@ setup_enternow_pci(struct IsdnCard *card)
printk(KERN_INFO "HiSax: Formula-n Europe AG enter:now ISDN PCI driver Rev. %s\n", HiSax_getrev(tmp));
if (cs->typ != ISDN_CTYPE_ENTERNOW)
return(0);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
for ( ;; )
{
......@@ -343,9 +327,6 @@ setup_enternow_pci(struct IsdnCard *card)
cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA;
cs->hw.njet.isac = cs->hw.njet.base + 0xC0; // Fenster zum AMD
save_flags(flags);
sti();
/* Reset an */
cs->hw.njet.ctrl_reg = 0x07; // gendert von 0xff
OutByte(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
......@@ -360,8 +341,6 @@ setup_enternow_pci(struct IsdnCard *card)
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout((10*HZ)/1000); /* Timeout 10ms */
restore_flags(flags);
cs->hw.njet.auxd = 0x00; // war 0xc0
cs->hw.njet.dmactrl = 0;
......
This diff is collapsed.
......@@ -21,18 +21,14 @@ static inline int
WaitForBusy(struct IsdnCardState *cs)
{
int to = 130;
long flags;
u_char val;
save_flags(flags);
cli();
while (!(cs->BC_Read_Reg(cs, HFC_STATUS, 0) & HFC_BUSY) && to) {
val = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2 |
(cs->hw.hfc.cip & 3));
udelay(1);
to--;
}
restore_flags(flags);
if (!to) {
printk(KERN_WARNING "HiSax: waitforBusy timeout\n");
return (0);
......@@ -86,15 +82,13 @@ static void
hfc_clear_fifo(struct BCState *bcs)
{
struct IsdnCardState *cs = bcs->cs;
long flags;
int idx, cnt;
int rcnt, z1, z2;
u_char cip, f1, f2;
if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
debugl1(cs, "hfc_clear_fifo");
save_flags(flags);
cli();
cip = HFC_CIP | HFC_F1 | HFC_REC | HFC_CHANNEL(bcs->channel);
if ((cip & 0xc3) != (cs->hw.hfc.cip & 0xc3)) {
cs->BC_Write_Reg(cs, HFC_STATUS, cip, cip);
......@@ -141,7 +135,6 @@ hfc_clear_fifo(struct BCState *bcs)
z1 = ReadZReg(bcs, HFC_Z1 | HFC_REC | HFC_CHANNEL(bcs->channel));
z2 = ReadZReg(bcs, HFC_Z2 | HFC_REC | HFC_CHANNEL(bcs->channel));
}
restore_flags(flags);
return;
}
......@@ -244,7 +237,6 @@ static void
hfc_fill_fifo(struct BCState *bcs)
{
struct IsdnCardState *cs = bcs->cs;
long flags;
int idx, fcnt;
int count;
int z1, z2;
......@@ -255,8 +247,6 @@ hfc_fill_fifo(struct BCState *bcs)
if (bcs->tx_skb->len <= 0)
return;
save_flags(flags);
cli();
cip = HFC_CIP | HFC_F1 | HFC_SEND | HFC_CHANNEL(bcs->channel);
if ((cip & 0xc3) != (cs->hw.hfc.cip & 0xc3)) {
cs->BC_Write_Reg(cs, HFC_STATUS, cip, cip);
......@@ -279,7 +269,6 @@ hfc_fill_fifo(struct BCState *bcs)
if (fcnt > 30) {
if (cs->debug & L1_DEB_HSCX)
debugl1(cs, "hfc_fill_fifo more as 30 frames");
restore_flags(flags);
return;
}
count = GetFreeFifoBytes(bcs);
......@@ -299,7 +288,6 @@ hfc_fill_fifo(struct BCState *bcs)
if (count < bcs->tx_skb->len) {
if (cs->debug & L1_DEB_HSCX)
debugl1(cs, "hfc_fill_fifo no fifo mem");
restore_flags(flags);
return;
}
cip = HFC_CIP | HFC_FIFO_IN | HFC_SEND | HFC_CHANNEL(bcs->channel);
......@@ -323,23 +311,19 @@ hfc_fill_fifo(struct BCState *bcs)
}
test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
}
restore_flags(flags);
return;
}
void
main_irq_hfc(struct BCState *bcs)
{
long flags;
struct IsdnCardState *cs = bcs->cs;
int z1, z2, rcnt;
u_char f1, f2, cip;
int receive, transmit, count = 5;
struct sk_buff *skb;
save_flags(flags);
Begin:
cli();
count--;
cip = HFC_CIP | HFC_F1 | HFC_REC | HFC_CHANNEL(bcs->channel);
if ((cip & 0xc3) != (cs->hw.hfc.cip & 0xc3)) {
......@@ -372,7 +356,6 @@ main_irq_hfc(struct BCState *bcs)
if (cs->debug & L1_DEB_HSCX)
debugl1(cs, "hfc rec %d z1(%x) z2(%x) cnt(%d)",
bcs->channel, z1, z2, rcnt);
/* sti(); */
if ((skb = hfc_empty_fifo(bcs, rcnt))) {
skb_queue_tail(&bcs->rqueue, skb);
sched_b_event(bcs, B_RCVBUFREADY);
......@@ -380,9 +363,7 @@ main_irq_hfc(struct BCState *bcs)
}
receive = 1;
}
restore_flags(flags);
udelay(1);
cli();
if (bcs->tx_skb) {
transmit = 1;
test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
......@@ -401,7 +382,6 @@ main_irq_hfc(struct BCState *bcs)
sched_b_event(bcs, B_XMTBUFREADY);
}
}
restore_flags(flags);
if ((receive || transmit) && count)
goto Begin;
return;
......
This diff is collapsed.
This diff is collapsed.
......@@ -866,7 +866,6 @@ struct icc_chip {
#define FLG_TWO_DCHAN 4
#define FLG_L1_DBUSY 5
#define FLG_DBUSY_TIMER 6
#define FLG_LOCK_ATOMIC 7
#define FLG_ARCOFI_TIMER 8
#define FLG_ARCOFI_ERROR 9
#define FLG_HW_L1_UINT 10
......
......@@ -60,10 +60,6 @@ netjet_s_interrupt(int intno, void *dev_id, struct pt_regs *regs)
sval = sval | 0x01;
if (sval != cs->hw.njet.last_is0) /* we have a DMA interrupt */
{
if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
goto unlock;
}
cs->hw.njet.irqstat0 = sval;
if ((cs->hw.njet.irqstat0 & NETJET_IRQM0_READ) !=
(cs->hw.njet.last_is0 & NETJET_IRQM0_READ))
......@@ -74,7 +70,6 @@ netjet_s_interrupt(int intno, void *dev_id, struct pt_regs *regs)
/* we have a write dma int */
write_tiger(cs);
/* end new code 13/07/00 GE */
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
}
/* if (!testcnt--) {
cs->hw.njet.dmactrl = 0;
......@@ -83,7 +78,6 @@ netjet_s_interrupt(int intno, void *dev_id, struct pt_regs *regs)
byteout(cs->hw.njet.base + NETJET_IRQMASK0, 0);
}
*/
unlock:
spin_unlock(&cs->lock);
}
......@@ -142,7 +136,6 @@ setup_netjet_s(struct IsdnCard *card)
printk(KERN_INFO "HiSax: Traverse Tech. NETjet-S driver Rev. %s\n", HiSax_getrev(tmp));
if (cs->typ != ISDN_CTYPE_NETJET_S)
return(0);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
#if CONFIG_PCI
......
......@@ -60,9 +60,6 @@ netjet_u_interrupt(int intno, void *dev_id, struct pt_regs *regs)
sval = sval | 0x01;
if (sval != cs->hw.njet.last_is0) /* we have a DMA interrupt */
{
if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
goto unlock;
}
cs->hw.njet.irqstat0 = sval;
if ((cs->hw.njet.irqstat0 & NETJET_IRQM0_READ) !=
(cs->hw.njet.last_is0 & NETJET_IRQM0_READ))
......@@ -73,7 +70,6 @@ netjet_u_interrupt(int intno, void *dev_id, struct pt_regs *regs)
/* we have a write dma int */
write_tiger(cs);
/* end new code 13/07/00 GE */
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
}
/* if (!testcnt--) {
cs->hw.njet.dmactrl = 0;
......@@ -82,7 +78,6 @@ netjet_u_interrupt(int intno, void *dev_id, struct pt_regs *regs)
byteout(cs->hw.njet.base + NETJET_IRQMASK0, 0);
}
*/
unlock:
spin_unlock(&cs->lock);
}
......@@ -146,7 +141,6 @@ setup_netjet_u(struct IsdnCard *card)
printk(KERN_INFO "HiSax: Traverse Tech. NETspider-U driver Rev. %s\n", HiSax_getrev(tmp));
if (cs->typ != ISDN_CTYPE_NETJET_U)
return(0);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
#if CONFIG_PCI
......
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