Re: patches sound driver locking issue

2001-06-06 Thread Jeff Garzik

Frank Davis wrote:
> 
> Hello all,
> I have attached patches against the following sound drivers to fix the locking 
>issues mentioned in Alan's release notes for 2.4.5-ac9 . Please CC me on your 
>comments to the code (I can address the issues quicker). Thanks.

Do these patches have the same problems that your es1371 patch did?

Let's make sure that is fixed first, and is solid.

-- 
Jeff Garzik  | Andre the Giant has a posse.
Building 1024|
MandrakeSoft |
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



patches sound driver locking issue

2001-06-06 Thread Frank Davis

Hello all,
I have attached patches against the following sound drivers to fix the locking 
issues mentioned in Alan's release notes for 2.4.5-ac9 . Please CC me on your comments 
to the code (I can address the issues quicker). Thanks.
drivers/sound/esssolo1.c
drivers/sound/maestro.c
drivers/sound/maestro3.c
drivers/sound/cmpci.c

Regards,
Frank



--- drivers/sound/cmpci.c.old   Tue Jun  5 21:21:39 2001
+++ drivers/sound/cmpci.c   Tue Jun  5 23:20:41 2001
@@ -312,6 +312,7 @@

/* spdif frame counter */
int spdif_counter;
+   struct semaphore sem;
 };
 
 /* flags used for capability */
@@ -1653,7 +1654,7 @@
 static ssize_t cm_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
 {
struct cm_state *s = (struct cm_state *)file->private_data;
-   ssize_t ret;
+   ssize_t ret = 0;
unsigned long flags;
unsigned swptr;
int cnt;
@@ -1663,11 +1664,11 @@
return -ESPIPE;
if (s->dma_adc.mapped)
return -ENXIO;
-   if (!s->dma_adc.ready && (ret = prog_dmabuf(s, 1)))
-   return ret;
if (!access_ok(VERIFY_WRITE, buffer, count))
return -EFAULT;
-   ret = 0;
+   down(>sem);
+   if (!s->dma_adc.ready && (ret = prog_dmabuf(s, 1)))
+   goto out;
 #if 0
spin_lock_irqsave(>lock, flags);
cm_update_ptr(s);
@@ -1684,8 +1685,12 @@
cnt = count;
if (cnt <= 0) {
start_adc(s);
-   if (file->f_flags & O_NONBLOCK)
-   return ret ? ret : -EAGAIN;
+   if (file->f_flags & O_NONBLOCK)a
+   {
+   if(!ret) ret = -EAGAIN;
+   goto out;
+   }
+   up(>sem);
if (!interruptible_sleep_on_timeout(>dma_adc.wait, HZ)) {
printk(KERN_DEBUG "cm: read: chip lockup? dmasz %u 
fragsz %u count %i hwptr %u swptr %u\n",
   s->dma_adc.dmasize, s->dma_adc.fragsize, 
s->dma_adc.count,
@@ -1698,12 +1703,24 @@
s->dma_adc.count = s->dma_adc.hwptr = s->dma_adc.swptr 
= 0;
spin_unlock_irqrestore(>lock, flags);
}
-   if (signal_pending(current))
-   return ret ? ret : -ERESTARTSYS;
+   if (signal_pending(current)) 
+   {
+   if(!ret) ret = -ERESTARTSYS;
+   goto out;
+   }
+   down(>sem);
+   if (s->dma_adc.mapped)
+   {
+   ret = -ENXIO;
+   goto out;
+   }
continue;
}
if (copy_to_user(buffer, s->dma_adc.rawbuf + swptr, cnt))
-   return ret ? ret : -EFAULT;
+   {
+   if(!ret) ret = -EFAULT;
+   goto out;
+   }
swptr = (swptr + cnt) % s->dma_adc.dmasize;
spin_lock_irqsave(>lock, flags);
s->dma_adc.swptr = swptr;
@@ -1714,6 +1731,8 @@
start_adc_unlocked(s);
spin_unlock_irqrestore(>lock, flags);
}
+out:
+   up(>sem);
return ret;
 }
 
@@ -1730,18 +1749,20 @@
return -ESPIPE;
if (s->dma_dac.mapped)
return -ENXIO;
-   if (!s->dma_dac.ready && (ret = prog_dmabuf(s, 0)))
-   return ret;
if (!access_ok(VERIFY_READ, buffer, count))
return -EFAULT;
if (s->status & DO_DUAL_DAC) {
if (s->dma_adc.mapped)
return -ENXIO;
-   if (!s->dma_adc.ready && (ret = prog_dmabuf(s, 1)))
-   return ret;
if (!access_ok(VERIFY_READ, buffer, count))
return -EFAULT;
+   down(>sem);
+   if (!s->dma_adc.ready && (ret = prog_dmabuf(s, 1)))
+   goto out;
}
+   down(>sem);
+   if (!s->dma_dac.ready && (ret = prog_dmabuf(s, 0)))
+   goto out;
ret = 0;
 #if 0
spin_lock_irqsave(>lock, flags);
@@ -1776,7 +1797,11 @@
if (cnt <= 0) {
start_dac(s);
if (file->f_flags & O_NONBLOCK)
-   return ret ? ret : -EAGAIN;
+   {
+if(!ret) ret = -EAGAIN;
+goto out;
+   }
+   up(>sem);
if (!interruptible_sleep_on_timeout(>dma_dac.wait, HZ)) {

patches sound driver locking issue

2001-06-06 Thread Frank Davis

Hello all,
I have attached patches against the following sound drivers to fix the locking 
issues mentioned in Alan's release notes for 2.4.5-ac9 . Please CC me on your comments 
to the code (I can address the issues quicker). Thanks.
drivers/sound/esssolo1.c
drivers/sound/maestro.c
drivers/sound/maestro3.c
drivers/sound/cmpci.c

Regards,
Frank



--- drivers/sound/cmpci.c.old   Tue Jun  5 21:21:39 2001
+++ drivers/sound/cmpci.c   Tue Jun  5 23:20:41 2001
@@ -312,6 +312,7 @@

/* spdif frame counter */
int spdif_counter;
+   struct semaphore sem;
 };
 
 /* flags used for capability */
@@ -1653,7 +1654,7 @@
 static ssize_t cm_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
 {
struct cm_state *s = (struct cm_state *)file-private_data;
-   ssize_t ret;
+   ssize_t ret = 0;
unsigned long flags;
unsigned swptr;
int cnt;
@@ -1663,11 +1664,11 @@
return -ESPIPE;
if (s-dma_adc.mapped)
return -ENXIO;
-   if (!s-dma_adc.ready  (ret = prog_dmabuf(s, 1)))
-   return ret;
if (!access_ok(VERIFY_WRITE, buffer, count))
return -EFAULT;
-   ret = 0;
+   down(s-sem);
+   if (!s-dma_adc.ready  (ret = prog_dmabuf(s, 1)))
+   goto out;
 #if 0
spin_lock_irqsave(s-lock, flags);
cm_update_ptr(s);
@@ -1684,8 +1685,12 @@
cnt = count;
if (cnt = 0) {
start_adc(s);
-   if (file-f_flags  O_NONBLOCK)
-   return ret ? ret : -EAGAIN;
+   if (file-f_flags  O_NONBLOCK)a
+   {
+   if(!ret) ret = -EAGAIN;
+   goto out;
+   }
+   up(s-sem);
if (!interruptible_sleep_on_timeout(s-dma_adc.wait, HZ)) {
printk(KERN_DEBUG cm: read: chip lockup? dmasz %u 
fragsz %u count %i hwptr %u swptr %u\n,
   s-dma_adc.dmasize, s-dma_adc.fragsize, 
s-dma_adc.count,
@@ -1698,12 +1703,24 @@
s-dma_adc.count = s-dma_adc.hwptr = s-dma_adc.swptr 
= 0;
spin_unlock_irqrestore(s-lock, flags);
}
-   if (signal_pending(current))
-   return ret ? ret : -ERESTARTSYS;
+   if (signal_pending(current)) 
+   {
+   if(!ret) ret = -ERESTARTSYS;
+   goto out;
+   }
+   down(s-sem);
+   if (s-dma_adc.mapped)
+   {
+   ret = -ENXIO;
+   goto out;
+   }
continue;
}
if (copy_to_user(buffer, s-dma_adc.rawbuf + swptr, cnt))
-   return ret ? ret : -EFAULT;
+   {
+   if(!ret) ret = -EFAULT;
+   goto out;
+   }
swptr = (swptr + cnt) % s-dma_adc.dmasize;
spin_lock_irqsave(s-lock, flags);
s-dma_adc.swptr = swptr;
@@ -1714,6 +1731,8 @@
start_adc_unlocked(s);
spin_unlock_irqrestore(s-lock, flags);
}
+out:
+   up(s-sem);
return ret;
 }
 
@@ -1730,18 +1749,20 @@
return -ESPIPE;
if (s-dma_dac.mapped)
return -ENXIO;
-   if (!s-dma_dac.ready  (ret = prog_dmabuf(s, 0)))
-   return ret;
if (!access_ok(VERIFY_READ, buffer, count))
return -EFAULT;
if (s-status  DO_DUAL_DAC) {
if (s-dma_adc.mapped)
return -ENXIO;
-   if (!s-dma_adc.ready  (ret = prog_dmabuf(s, 1)))
-   return ret;
if (!access_ok(VERIFY_READ, buffer, count))
return -EFAULT;
+   down(s-sem);
+   if (!s-dma_adc.ready  (ret = prog_dmabuf(s, 1)))
+   goto out;
}
+   down(s-sem);
+   if (!s-dma_dac.ready  (ret = prog_dmabuf(s, 0)))
+   goto out;
ret = 0;
 #if 0
spin_lock_irqsave(s-lock, flags);
@@ -1776,7 +1797,11 @@
if (cnt = 0) {
start_dac(s);
if (file-f_flags  O_NONBLOCK)
-   return ret ? ret : -EAGAIN;
+   {
+if(!ret) ret = -EAGAIN;
+goto out;
+   }
+   up(s-sem);
if (!interruptible_sleep_on_timeout(s-dma_dac.wait, HZ)) {
printk(KERN_DEBUG cm: write: chip 

Re: patches sound driver locking issue

2001-06-06 Thread Jeff Garzik

Frank Davis wrote:
 
 Hello all,
 I have attached patches against the following sound drivers to fix the locking 
issues mentioned in Alan's release notes for 2.4.5-ac9 . Please CC me on your 
comments to the code (I can address the issues quicker). Thanks.

Do these patches have the same problems that your es1371 patch did?

Let's make sure that is fixed first, and is solid.

-- 
Jeff Garzik  | Andre the Giant has a posse.
Building 1024|
MandrakeSoft |
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/