8a4259bf89
Replace a spinlock with a mutex protecting the vm block list at mmap / munmap calls, which caused Oops like below: BUG: sleeping function called from invalid context at mm/slub.c:1599 in_atomic(): 0, irqs_disabled(): 1, pid: 32065, name: xine Pid: 32065, comm: xine Tainted: P 2.6.29.4-75.fc10.x86_64 #1 Call Trace: [<ffffffff81040685>] __might_sleep+0x105/0x10a [<ffffffff810c9fae>] kmem_cache_alloc+0x32/0xe2 [<ffffffffa08e3110>] ct_vm_map+0xfa/0x19e [snd_ctxfi] [<ffffffffa08e1a07>] ct_map_audio_buffer+0x4c/0x76 [snd_ctxfi] [<ffffffffa08e2aa5>] atc_pcm_playback_prepare+0x1d7/0x2a8 [snd_ctxfi] [<ffffffff8105ef3f>] ? up_read+0x9/0xb [<ffffffff81186b61>] ? __up_read+0x7c/0x87 [<ffffffffa08e36a6>] ct_pcm_playback_prepare+0x39/0x60 [snd_ctxfi] [<ffffffffa0886bcb>] snd_pcm_do_prepare+0x16/0x28 [snd_pcm] [<ffffffffa08867c7>] snd_pcm_action_single+0x2d/0x5b [snd_pcm] [<ffffffffa08881f3>] snd_pcm_action_nonatomic+0x52/0x6a [snd_pcm] [<ffffffffa088a723>] snd_pcm_common_ioctl1+0x404/0xc79 [snd_pcm] [<ffffffff810c52c8>] ? alloc_pages_current+0xb9/0xc2 [<ffffffff810c9402>] ? new_slab+0x1a5/0x1cb [<ffffffff810ab9ea>] ? vma_prio_tree_insert+0x23/0xc1 [<ffffffffa088b411>] snd_pcm_playback_ioctl1+0x213/0x230 [snd_pcm] [<ffffffff810b6c20>] ? mmap_region+0x397/0x4c9 [<ffffffffa088bd9b>] snd_pcm_playback_ioctl+0x2e/0x36 [snd_pcm] [<ffffffff810ddc64>] vfs_ioctl+0x2a/0x78 [<ffffffff810de130>] do_vfs_ioctl+0x462/0x4a2 [<ffffffff81029cef>] ? default_spin_lock_flags+0x9/0xe [<ffffffff81374647>] ? trace_hardirqs_off_thunk+0x3a/0x6c [<ffffffff810de1c5>] sys_ioctl+0x55/0x77 [<ffffffff8101133a>] system_call_fastpath+0x16/0x1b Signed-off-by: Takashi Iwai <tiwai@suse.de>
154 lines
4.9 KiB
C
154 lines
4.9 KiB
C
/**
|
|
* Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
|
|
*
|
|
* This source file is released under GPL v2 license (no other versions).
|
|
* See the COPYING file included in the main directory of this source
|
|
* distribution for the license terms and conditions.
|
|
*
|
|
* @File ctatc.h
|
|
*
|
|
* @Brief
|
|
* This file contains the definition of the device resource management object.
|
|
*
|
|
* @Author Liu Chun
|
|
* @Date Mar 28 2008
|
|
*
|
|
*/
|
|
|
|
#ifndef CTATC_H
|
|
#define CTATC_H
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/spinlock_types.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/timer.h>
|
|
#include <sound/core.h>
|
|
|
|
#include "ctvmem.h"
|
|
#include "ctresource.h"
|
|
|
|
enum CTALSADEVS { /* Types of alsa devices */
|
|
FRONT,
|
|
REAR,
|
|
CLFE,
|
|
SURROUND,
|
|
IEC958,
|
|
MIXER,
|
|
NUM_CTALSADEVS /* This should always be the last */
|
|
};
|
|
|
|
enum CTCARDS {
|
|
CTSB0760,
|
|
CTHENDRIX,
|
|
CTSB08801,
|
|
CTSB08802,
|
|
CTSB08803,
|
|
NUM_CTCARDS /* This should always be the last */
|
|
};
|
|
|
|
struct ct_atc_chip_sub_details {
|
|
u16 subsys;
|
|
const char *nm_model;
|
|
};
|
|
|
|
struct ct_atc_chip_details {
|
|
u16 vendor;
|
|
u16 device;
|
|
const struct ct_atc_chip_sub_details *sub_details;
|
|
const char *nm_card;
|
|
};
|
|
|
|
struct ct_atc;
|
|
|
|
/* alsa pcm stream descriptor */
|
|
struct ct_atc_pcm {
|
|
struct snd_pcm_substream *substream;
|
|
void (*interrupt)(struct ct_atc_pcm *apcm);
|
|
unsigned int started:1;
|
|
unsigned int stop_timer:1;
|
|
struct timer_list timer;
|
|
spinlock_t timer_lock;
|
|
unsigned int position;
|
|
|
|
/* Only mono and interleaved modes are supported now. */
|
|
struct ct_vm_block *vm_block;
|
|
void *src; /* SRC for interacting with host memory */
|
|
void **srccs; /* SRCs for sample rate conversion */
|
|
void **srcimps; /* SRC Input Mappers */
|
|
void **amixers; /* AMIXERs for routing converted data */
|
|
void *mono; /* A SUM resource for mixing chs to one */
|
|
unsigned char n_srcc; /* Number of converting SRCs */
|
|
unsigned char n_srcimp; /* Number of SRC Input Mappers */
|
|
unsigned char n_amixer; /* Number of AMIXERs */
|
|
};
|
|
|
|
/* Chip resource management object */
|
|
struct ct_atc {
|
|
struct pci_dev *pci;
|
|
struct snd_card *card;
|
|
unsigned int rsr; /* reference sample rate in Hz */
|
|
unsigned int msr; /* master sample rate in rsr */
|
|
unsigned int pll_rate; /* current rate of Phase Lock Loop */
|
|
|
|
const struct ct_atc_chip_details *chip_details;
|
|
enum CTCARDS model;
|
|
/* Create all alsa devices */
|
|
int (*create_alsa_devs)(struct ct_atc *atc);
|
|
|
|
struct ct_vm *vm; /* device virtual memory manager for this card */
|
|
int (*map_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
|
|
void (*unmap_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
|
|
unsigned long (*get_ptp_phys)(struct ct_atc *atc, int index);
|
|
|
|
spinlock_t atc_lock;
|
|
|
|
int (*pcm_playback_prepare)(struct ct_atc *atc,
|
|
struct ct_atc_pcm *apcm);
|
|
int (*pcm_playback_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
|
|
int (*pcm_playback_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
|
|
int (*pcm_playback_position)(struct ct_atc *atc,
|
|
struct ct_atc_pcm *apcm);
|
|
int (*spdif_passthru_playback_prepare)(struct ct_atc *atc,
|
|
struct ct_atc_pcm *apcm);
|
|
int (*pcm_capture_prepare)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
|
|
int (*pcm_capture_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
|
|
int (*pcm_capture_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
|
|
int (*pcm_capture_position)(struct ct_atc *atc,
|
|
struct ct_atc_pcm *apcm);
|
|
int (*pcm_release_resources)(struct ct_atc *atc,
|
|
struct ct_atc_pcm *apcm);
|
|
int (*select_line_in)(struct ct_atc *atc);
|
|
int (*select_mic_in)(struct ct_atc *atc);
|
|
int (*select_digit_io)(struct ct_atc *atc);
|
|
int (*line_front_unmute)(struct ct_atc *atc, unsigned char state);
|
|
int (*line_surround_unmute)(struct ct_atc *atc, unsigned char state);
|
|
int (*line_clfe_unmute)(struct ct_atc *atc, unsigned char state);
|
|
int (*line_rear_unmute)(struct ct_atc *atc, unsigned char state);
|
|
int (*line_in_unmute)(struct ct_atc *atc, unsigned char state);
|
|
int (*spdif_out_unmute)(struct ct_atc *atc, unsigned char state);
|
|
int (*spdif_in_unmute)(struct ct_atc *atc, unsigned char state);
|
|
int (*spdif_out_get_status)(struct ct_atc *atc, unsigned int *status);
|
|
int (*spdif_out_set_status)(struct ct_atc *atc, unsigned int status);
|
|
int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state);
|
|
int (*have_digit_io_switch)(struct ct_atc *atc);
|
|
|
|
/* Don't touch! Used for internal object. */
|
|
void *rsc_mgrs[NUM_RSCTYP]; /* chip resource managers */
|
|
void *mixer; /* internal mixer object */
|
|
void *hw; /* chip specific hardware access object */
|
|
void **daios; /* digital audio io resources */
|
|
void **pcm; /* SUMs for collecting all pcm stream */
|
|
void **srcs; /* Sample Rate Converters for input signal */
|
|
void **srcimps; /* input mappers for SRCs */
|
|
unsigned char n_daio;
|
|
unsigned char n_src;
|
|
unsigned char n_srcimp;
|
|
unsigned char n_pcm;
|
|
};
|
|
|
|
|
|
int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci,
|
|
unsigned int rsr, unsigned int msr,
|
|
struct ct_atc **ratc);
|
|
|
|
#endif /* CTATC_H */
|