Commit 4b634098 authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: B1 DMA drivers: Replace cli() by proper spin_lock.

parent 698b2ca3
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#ifndef _AVMCARD_H_ #ifndef _AVMCARD_H_
#define _AVMCARD_H_ #define _AVMCARD_H_
#include <linux/spinlock.h>
#define AVMB1_PORTLEN 0x1f #define AVMB1_PORTLEN 0x1f
#define AVM_MAXVERSION 8 #define AVM_MAXVERSION 8
#define AVM_NCCI_PER_CHANNEL 4 #define AVM_NCCI_PER_CHANNEL 4
...@@ -57,6 +59,8 @@ typedef struct avmcard_dmainfo { ...@@ -57,6 +59,8 @@ typedef struct avmcard_dmainfo {
typedef struct avmcard { typedef struct avmcard {
char name[32]; char name[32];
spinlock_t lock;
unsigned int port; unsigned int port;
unsigned irq; unsigned irq;
unsigned long membase; unsigned long membase;
......
...@@ -214,10 +214,6 @@ static inline u32 _get_slice(void **pp, unsigned char *dp) ...@@ -214,10 +214,6 @@ static inline u32 _get_slice(void **pp, unsigned char *dp)
void b1dma_reset(avmcard *card) void b1dma_reset(avmcard *card)
{ {
unsigned long flags;
save_flags(flags);
cli();
card->csr = 0x0; card->csr = 0x0;
b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr); b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr);
b1dmaoutmeml(card->mbase+AMCC_MCSR, 0); b1dmaoutmeml(card->mbase+AMCC_MCSR, 0);
...@@ -227,8 +223,6 @@ void b1dma_reset(avmcard *card) ...@@ -227,8 +223,6 @@ void b1dma_reset(avmcard *card)
t1outp(card->port, 0x10, 0x00); t1outp(card->port, 0x10, 0x00);
t1outp(card->port, 0x07, 0x00); t1outp(card->port, 0x07, 0x00);
restore_flags(flags);
b1dmaoutmeml(card->mbase+AMCC_MCSR, 0); b1dmaoutmeml(card->mbase+AMCC_MCSR, 0);
mdelay(10); mdelay(10);
b1dmaoutmeml(card->mbase+AMCC_MCSR, 0x0f000000); /* reset all */ b1dmaoutmeml(card->mbase+AMCC_MCSR, 0x0f000000); /* reset all */
...@@ -354,16 +348,16 @@ static void b1dma_queue_tx(avmcard *card, struct sk_buff *skb) ...@@ -354,16 +348,16 @@ static void b1dma_queue_tx(avmcard *card, struct sk_buff *skb)
{ {
unsigned long flags; unsigned long flags;
skb_queue_tail(&card->dma->send_queue, skb); spin_lock_irqsave(&card->lock, flags);
spin_lock_irq_save(&card->lock, flags); skb_queue_tail(&card->dma->send_queue, skb);
if (!(card->csr & EN_TX_TC_INT)) { if (!(card->csr & EN_TX_TC_INT)) {
b1dma_dispatch_tx(card); b1dma_dispatch_tx(card);
b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr); b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr);
} }
spin_unlock_irq_restore(&card->lock, flags); spin_unlock_irqrestore(&card->lock, flags);
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
...@@ -371,7 +365,6 @@ static void b1dma_queue_tx(avmcard *card, struct sk_buff *skb) ...@@ -371,7 +365,6 @@ static void b1dma_queue_tx(avmcard *card, struct sk_buff *skb)
static void b1dma_dispatch_tx(avmcard *card) static void b1dma_dispatch_tx(avmcard *card)
{ {
avmcard_dmainfo *dma = card->dma; avmcard_dmainfo *dma = card->dma;
unsigned long flags;
struct sk_buff *skb; struct sk_buff *skb;
u8 cmd, subcmd; u8 cmd, subcmd;
u16 len; u16 len;
...@@ -382,13 +375,6 @@ static void b1dma_dispatch_tx(avmcard *card) ...@@ -382,13 +375,6 @@ static void b1dma_dispatch_tx(avmcard *card)
inint = card->interrupt; inint = card->interrupt;
skb = skb_dequeue(&dma->send_queue); skb = skb_dequeue(&dma->send_queue);
if (!skb) {
#ifdef CONFIG_B1DMA_DEBUG
printk(KERN_DEBUG "tx(%d): underrun\n", inint);
#endif
restore_flags(flags);
return;
}
len = CAPIMSG_LEN(skb->data); len = CAPIMSG_LEN(skb->data);
...@@ -617,16 +603,17 @@ static void b1dma_handle_interrupt(avmcard *card) ...@@ -617,16 +603,17 @@ static void b1dma_handle_interrupt(avmcard *card)
} }
} }
if ((status & TX_TC_INT) != 0) { spin_lock(&card->lock);
spin_lock_irq_save(&card->lock, flags);
if ((status & TX_TC_INT) != 0) {
if (skb_queue_empty(&card->dma->send_queue))
card->csr &= ~EN_TX_TC_INT; card->csr &= ~EN_TX_TC_INT;
else
b1dma_dispatch_tx(card); b1dma_dispatch_tx(card);
spin_unlock_irq_restore(&card->lock, flags);
} }
b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr); b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr);
spin_unlock(&card->lock);
} }
void b1dma_interrupt(int interrupt, void *devptr, struct pt_regs *regs) void b1dma_interrupt(int interrupt, void *devptr, struct pt_regs *regs)
...@@ -712,7 +699,6 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) ...@@ -712,7 +699,6 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data)
{ {
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
avmcard *card = cinfo->card; avmcard *card = cinfo->card;
unsigned long flags;
int retval; int retval;
b1dma_reset(card); b1dma_reset(card);
...@@ -739,9 +725,6 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) ...@@ -739,9 +725,6 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data)
return -EIO; return -EIO;
} }
save_flags(flags);
cli();
card->csr = AVM_FLAG; card->csr = AVM_FLAG;
b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr); b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr);
b1dmaoutmeml(card->mbase+AMCC_MCSR, b1dmaoutmeml(card->mbase+AMCC_MCSR,
...@@ -756,7 +739,6 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) ...@@ -756,7 +739,6 @@ int b1dma_load_firmware(struct capi_ctr *ctrl, capiloaddata *data)
b1dmaoutmeml(card->mbase+AMCC_RXLEN, 4); b1dmaoutmeml(card->mbase+AMCC_RXLEN, 4);
card->csr |= EN_RX_TC_INT; card->csr |= EN_RX_TC_INT;
b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr); b1dmaoutmeml(card->mbase+AMCC_INTCSR, card->csr);
restore_flags(flags);
b1dma_send_init(card); b1dma_send_init(card);
...@@ -858,7 +840,6 @@ int b1dmactl_read_proc(char *page, char **start, off_t off, ...@@ -858,7 +840,6 @@ int b1dmactl_read_proc(char *page, char **start, off_t off,
{ {
avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata); avmctrl_info *cinfo = (avmctrl_info *)(ctrl->driverdata);
avmcard *card = cinfo->card; avmcard *card = cinfo->card;
unsigned long flags;
u8 flag; u8 flag;
int len = 0; int len = 0;
char *s; char *s;
...@@ -915,9 +896,6 @@ int b1dmactl_read_proc(char *page, char **start, off_t off, ...@@ -915,9 +896,6 @@ int b1dmactl_read_proc(char *page, char **start, off_t off,
} }
len += sprintf(page+len, "%-16s %s\n", "cardname", cinfo->cardname); len += sprintf(page+len, "%-16s %s\n", "cardname", cinfo->cardname);
save_flags(flags);
cli();
txoff = (dma_addr_t)b1dmainmeml(card->mbase+0x2c)-card->dma->sendbuf.dmaaddr; txoff = (dma_addr_t)b1dmainmeml(card->mbase+0x2c)-card->dma->sendbuf.dmaaddr;
txlen = b1dmainmeml(card->mbase+0x30); txlen = b1dmainmeml(card->mbase+0x30);
...@@ -926,8 +904,6 @@ int b1dmactl_read_proc(char *page, char **start, off_t off, ...@@ -926,8 +904,6 @@ int b1dmactl_read_proc(char *page, char **start, off_t off,
csr = b1dmainmeml(card->mbase+AMCC_INTCSR); csr = b1dmainmeml(card->mbase+AMCC_INTCSR);
restore_flags(flags);
len += sprintf(page+len, "%-16s 0x%lx\n", len += sprintf(page+len, "%-16s 0x%lx\n",
"csr (cached)", (unsigned long)card->csr); "csr (cached)", (unsigned long)card->csr);
len += sprintf(page+len, "%-16s 0x%lx\n", len += sprintf(page+len, "%-16s 0x%lx\n",
......
...@@ -258,6 +258,7 @@ static int b1pciv4_add_card(struct capi_driver *driver, ...@@ -258,6 +258,7 @@ static int b1pciv4_add_card(struct capi_driver *driver,
goto err; goto err;
} }
memset(card, 0, sizeof(avmcard)); memset(card, 0, sizeof(avmcard));
spin_lock_init(&card->lock);
card->dma = avmcard_dma_alloc(driver->name, dev, 2048+128, 2048+128); card->dma = avmcard_dma_alloc(driver->name, dev, 2048+128, 2048+128);
if (!card->dma) { if (!card->dma) {
......
...@@ -66,6 +66,8 @@ static int t1pci_add_card(struct capi_driver *driver, ...@@ -66,6 +66,8 @@ static int t1pci_add_card(struct capi_driver *driver,
goto err; goto err;
} }
memset(card, 0, sizeof(avmcard)); memset(card, 0, sizeof(avmcard));
spin_lock_init(&card->lock);
card->dma = avmcard_dma_alloc(driver->name, dev, 2048+128, 2048+128); card->dma = avmcard_dma_alloc(driver->name, dev, 2048+128, 2048+128);
if (!card->dma) { if (!card->dma) {
printk(KERN_WARNING "%s: no memory.\n", driver->name); printk(KERN_WARNING "%s: no memory.\n", driver->name);
......
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