public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: muli@il.ibm.com
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, Muli Ben-Yehuda <muli@il.ibm.com>,
	tammy000@gmail.com, bunk@stusta.de
Subject: [PATCH 2/3] OSS trident: fix locking around write_voice_regs
Date: Sun, 13 May 2007 22:15:27 +0300	[thread overview]
Message-ID: <1179083728411-git-send-email-muli@il.ibm.com> (raw)
In-Reply-To: <11790837282758-git-send-email-muli@il.ibm.com>

From: Muli Ben-Yehuda <muli@il.ibm.com>

trident_write_voice_regs() was getting called with the card spinlock
held in only some cases. Fix it.

Explanation: we allocate a new virtual channel in open, and then we
frob some hardware registers (in write_voice_regs) for that
channel. But the hardware registers are shared with other channels,
which may be trying to frob the some registers (albeit for another
channel) via ioctl(SNDCTL_DSP_SPEED).

Fixed bugzilla.kernel.org bug #8172 (http://bugme.osdl.org/show_bug.cgi?id=8172)

Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
Cc: tammy000@gmail.com
Cc: bunk@stusta.de
---
 sound/oss/trident.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/sound/oss/trident.c b/sound/oss/trident.c
index 3e408f4..2e3e78e 100644
--- a/sound/oss/trident.c
+++ b/sound/oss/trident.c
@@ -2702,6 +2702,7 @@ trident_open(struct inode *inode, struct
 	struct trident_card *card = devs;
 	struct trident_state *state = NULL;
 	struct dmabuf *dmabuf = NULL;
+	unsigned long flags;
 
 	/* Added by Matt Wu 01-05-2001 */
 	/* TODO: there's some redundacy here wrt the check below */
@@ -2779,7 +2780,9 @@ trident_open(struct inode *inode, struct
 			/* set default channel attribute to normal playback */
 			dmabuf->channel->attribute = CHANNEL_PB;
 		}
+		spin_lock_irqsave(&card->lock, flags);
 		trident_set_dac_rate(state, 8000);
+		spin_unlock_irqrestore(&card->lock, flags);
 	}
 
 	if (file->f_mode & FMODE_READ) {
@@ -2797,7 +2800,9 @@ trident_open(struct inode *inode, struct
 			dmabuf->channel->attribute = (CHANNEL_REC | PCM_LR |
 						      MONO_MIX);
 		}
+		spin_lock_irqsave(&card->lock, flags);
 		trident_set_adc_rate(state, 8000);
+		spin_unlock_irqrestore(&card->lock, flags);
 
 		/* Added by Matt Wu 01-05-2001 */
 		if (card->pci_id == PCI_DEVICE_ID_ALI_5451)
-- 
1.4.4


  reply	other threads:[~2007-05-13 19:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-13 19:15 OSS trident updates muli
2007-05-13 19:15 ` [PATCH 1/3] OSS trident: massive whitespace removal muli
2007-05-13 19:15   ` muli [this message]
2007-05-13 19:15     ` [PATCH 3/3] OSS trident: replace deprecated pci_find_device with pci_get_device muli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1179083728411-git-send-email-muli@il.ibm.com \
    --to=muli@il.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=bunk@stusta.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tammy000@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox