diff -urNp linux-2.4.21/drivers/sound/msnd.c linux-2.4.21.SUSE/drivers/sound/msnd.c --- linux-2.4.21/drivers/sound/msnd.c 2001-09-30 21:26:08.000000000 +0200 +++ linux-2.4.21.SUSE/drivers/sound/msnd.c 2004-06-21 16:14:10.295270170 +0200 @@ -155,13 +155,10 @@ void msnd_fifo_make_empty(msnd_fifo *f) f->len = f->tail = f->head = 0; } -int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len, int user) +int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len) { int count = 0; - if (f->len == f->n) - return 0; - while ((count < len) && (f->len != f->n)) { int nwritten; @@ -177,11 +174,7 @@ int msnd_fifo_write(msnd_fifo *f, const nwritten = len - count; } - if (user) { - if (copy_from_user(f->data + f->tail, buf, nwritten)) - return -EFAULT; - } else - isa_memcpy_fromio(f->data + f->tail, (unsigned long) buf, nwritten); + isa_memcpy_fromio(f->data + f->tail, (unsigned long) buf, nwritten); count += nwritten; buf += nwritten; @@ -193,13 +186,10 @@ int msnd_fifo_write(msnd_fifo *f, const return count; } -int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len, int user) +int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len) { int count = 0; - if (f->len == 0) - return f->len; - while ((count < len) && (f->len > 0)) { int nread; @@ -215,11 +205,7 @@ int msnd_fifo_read(msnd_fifo *f, char *b nread = len - count; } - if (user) { - if (copy_to_user(buf, f->data + f->head, nread)) - return -EFAULT; - } else - isa_memcpy_toio((unsigned long) buf, f->data + f->head, nread); + isa_memcpy_toio((unsigned long) buf, f->data + f->head, nread); count += nread; buf += nread; diff -urNp linux-2.4.21/drivers/sound/msnd.h linux-2.4.21.SUSE/drivers/sound/msnd.h --- linux-2.4.21/drivers/sound/msnd.h 2000-07-13 06:58:43.000000000 +0200 +++ linux-2.4.21.SUSE/drivers/sound/msnd.h 2004-06-21 16:14:10.296270182 +0200 @@ -266,8 +266,8 @@ void msnd_fifo_init(msnd_fifo *f); void msnd_fifo_free(msnd_fifo *f); int msnd_fifo_alloc(msnd_fifo *f, size_t n); void msnd_fifo_make_empty(msnd_fifo *f); -int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len, int user); -int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len, int user); +int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len); +int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len); int msnd_wait_TXDE(multisound_dev_t *dev); int msnd_wait_HC0(multisound_dev_t *dev); diff -urNp linux-2.4.21/drivers/sound/msnd_pinnacle.c linux-2.4.21.SUSE/drivers/sound/msnd_pinnacle.c --- linux-2.4.21/drivers/sound/msnd_pinnacle.c 2002-08-03 02:39:44.000000000 +0200 +++ linux-2.4.21.SUSE/drivers/sound/msnd_pinnacle.c 2004-06-21 16:14:10.297270195 +0200 @@ -804,7 +804,7 @@ static int dev_release(struct inode *ino static __inline__ int pack_DARQ_to_DARF(register int bank) { - register int size, n, timeout = 3; + register int size, timeout = 3; register WORD wTmp; LPDAQD DAQD; @@ -825,13 +825,10 @@ static __inline__ int pack_DARQ_to_DARF( /* Read data from the head (unprotected bank 1 access okay since this is only called inside an interrupt) */ outb(HPBLKSEL_1, dev.io + HP_BLKS); - if ((n = msnd_fifo_write( + msnd_fifo_write( &dev.DARF, (char *)(dev.base + bank * DAR_BUFF_SIZE), - size, 0)) <= 0) { - outb(HPBLKSEL_0, dev.io + HP_BLKS); - return n; - } + size); outb(HPBLKSEL_0, dev.io + HP_BLKS); return 1; @@ -853,21 +850,16 @@ static __inline__ int pack_DAPF_to_DAPQ( if (protect) { /* Critical section: protect fifo in non-interrupt */ spin_lock_irqsave(&dev.lock, flags); - if ((n = msnd_fifo_read( + n = msnd_fifo_read( &dev.DAPF, (char *)(dev.base + bank_num * DAP_BUFF_SIZE), - DAP_BUFF_SIZE, 0)) < 0) { - spin_unlock_irqrestore(&dev.lock, flags); - return n; - } + DAP_BUFF_SIZE); spin_unlock_irqrestore(&dev.lock, flags); } else { - if ((n = msnd_fifo_read( + n = msnd_fifo_read( &dev.DAPF, (char *)(dev.base + bank_num * DAP_BUFF_SIZE), - DAP_BUFF_SIZE, 0)) < 0) { - return n; - } + DAP_BUFF_SIZE); } if (!n) break; @@ -894,30 +886,43 @@ static __inline__ int pack_DAPF_to_DAPQ( static int dsp_read(char *buf, size_t len) { int count = len; + char *page = (char *)__get_free_page(PAGE_SIZE); + + if (!page) + return -ENOMEM; while (count > 0) { - int n; + int n, k; unsigned long flags; + k = PAGE_SIZE; + if (k > count) + k = count; + /* Critical section: protect fifo in non-interrupt */ spin_lock_irqsave(&dev.lock, flags); - if ((n = msnd_fifo_read(&dev.DARF, buf, count, 1)) < 0) { - printk(KERN_WARNING LOGNAME ": FIFO read error\n"); - spin_unlock_irqrestore(&dev.lock, flags); - return n; - } + n = msnd_fifo_read(&dev.DARF, page, k); spin_unlock_irqrestore(&dev.lock, flags); + if (copy_to_user(buf, page, n)) { + free_page((unsigned long)page); + return -EFAULT; + } buf += n; count -= n; + if (n == k && count) + continue; + if (!test_bit(F_READING, &dev.flags) && dev.mode & FMODE_READ) { dev.last_recbank = -1; if (chk_send_dsp_cmd(&dev, HDEX_RECORD_START) == 0) set_bit(F_READING, &dev.flags); } - if (dev.rec_ndelay) + if (dev.rec_ndelay) { + free_page((unsigned long)page); return count == len ? -EAGAIN : len - count; + } if (count > 0) { set_bit(F_READBLOCK, &dev.flags); @@ -926,41 +931,57 @@ static int dsp_read(char *buf, size_t le get_rec_delay_jiffies(DAR_BUFF_SIZE))) clear_bit(F_READING, &dev.flags); clear_bit(F_READBLOCK, &dev.flags); - if (signal_pending(current)) + if (signal_pending(current)) { + free_page((unsigned long)page); return -EINTR; + } } } - + free_page((unsigned long)page); return len - count; } static int dsp_write(const char *buf, size_t len) { int count = len; + char *page = (char *)__get_free_page(GFP_KERNEL); + + if (!page) + return -ENOMEM; while (count > 0) { - int n; + int n, k; unsigned long flags; + k = PAGE_SIZE; + if (k > count) + k = count; + + if (copy_from_user(page, buf, k)) { + free_page((unsigned long)page); + return -EFAULT; + } + /* Critical section: protect fifo in non-interrupt */ spin_lock_irqsave(&dev.lock, flags); - if ((n = msnd_fifo_write(&dev.DAPF, buf, count, 1)) < 0) { - printk(KERN_WARNING LOGNAME ": FIFO write error\n"); - spin_unlock_irqrestore(&dev.lock, flags); - return n; - } + n = msnd_fifo_write(&dev.DAPF, page, k); spin_unlock_irqrestore(&dev.lock, flags); buf += n; count -= n; + if (count && n == k) + continue; + if (!test_bit(F_WRITING, &dev.flags) && (dev.mode & FMODE_WRITE)) { dev.last_playbank = -1; if (pack_DAPF_to_DAPQ(1) > 0) set_bit(F_WRITING, &dev.flags); } - if (dev.play_ndelay) + if (dev.play_ndelay) { + free_page((unsigned long)page); return count == len ? -EAGAIN : len - count; + } if (count > 0) { set_bit(F_WRITEBLOCK, &dev.flags); @@ -968,11 +989,14 @@ static int dsp_write(const char *buf, si &dev.writeblock, get_play_delay_jiffies(DAP_BUFF_SIZE)); clear_bit(F_WRITEBLOCK, &dev.flags); - if (signal_pending(current)) + if (signal_pending(current)) { + free_page((unsigned long)page); return -EINTR; + } } } + free_page((unsigned long)page); return len - count; }