From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, David Dillow <dave@thedillows.org>,
Takashi Iwai <tiwai@suse.de>
Subject: [01/53] ALSA: sis7019 - give slow codecs more time to reset
Date: Fri, 16 Dec 2011 11:44:58 -0800 [thread overview]
Message-ID: <20111216194554.112799656@clark.kroah.org> (raw)
In-Reply-To: <20111216194613.GA18395@kroah.com>
3.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Dillow <dave@thedillows.org>
commit fc084e0b930d546872ab23667052499f7daf0fed upstream.
There are some AC97 codec and board combinations that have been observed
to take a very long time to respond after the cold reset has completed.
In one case, more than 350 ms was required. To allow users to have sound
on those platforms, we'll wait up to 500ms for the codec to become
ready.
As a board may have multiple codecs, with some faster than others to
reset, we add a module parameter to inform the driver which codecs
should be present.
Reported-by: KotCzarny <tjosko@yahoo.com>
Signed-off-by: David Dillow <dave@thedillows.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
sound/pci/sis7019.c | 64 +++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 53 insertions(+), 11 deletions(-)
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -41,6 +41,7 @@ MODULE_SUPPORTED_DEVICE("{{SiS,SiS7019 A
static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
static int enable = 1;
+static int codecs = 1;
module_param(index, int, 0444);
MODULE_PARM_DESC(index, "Index value for SiS7019 Audio Accelerator.");
@@ -48,6 +49,8 @@ module_param(id, charp, 0444);
MODULE_PARM_DESC(id, "ID string for SiS7019 Audio Accelerator.");
module_param(enable, bool, 0444);
MODULE_PARM_DESC(enable, "Enable SiS7019 Audio Accelerator.");
+module_param(codecs, int, 0444);
+MODULE_PARM_DESC(codecs, "Set bit to indicate that codec number is expected to be present (default 1)");
static DEFINE_PCI_DEVICE_TABLE(snd_sis7019_ids) = {
{ PCI_DEVICE(PCI_VENDOR_ID_SI, 0x7019) },
@@ -140,6 +143,9 @@ struct sis7019 {
dma_addr_t silence_dma_addr;
};
+/* These values are also used by the module param 'codecs' to indicate
+ * which codecs should be present.
+ */
#define SIS_PRIMARY_CODEC_PRESENT 0x0001
#define SIS_SECONDARY_CODEC_PRESENT 0x0002
#define SIS_TERTIARY_CODEC_PRESENT 0x0004
@@ -1078,6 +1084,7 @@ static int sis_chip_init(struct sis7019
{
unsigned long io = sis->ioport;
void __iomem *ioaddr = sis->ioaddr;
+ unsigned long timeout;
u16 status;
int count;
int i;
@@ -1104,21 +1111,45 @@ static int sis_chip_init(struct sis7019
while ((inw(io + SIS_AC97_STATUS) & SIS_AC97_STATUS_BUSY) && --count)
udelay(1);
- /* Now that we've finished the reset, find out what's attached.
+ /* Command complete, we can let go of the semaphore now.
*/
- status = inl(io + SIS_AC97_STATUS);
- if (status & SIS_AC97_STATUS_CODEC_READY)
- sis->codecs_present |= SIS_PRIMARY_CODEC_PRESENT;
- if (status & SIS_AC97_STATUS_CODEC2_READY)
- sis->codecs_present |= SIS_SECONDARY_CODEC_PRESENT;
- if (status & SIS_AC97_STATUS_CODEC3_READY)
- sis->codecs_present |= SIS_TERTIARY_CODEC_PRESENT;
+ outl(SIS_AC97_SEMA_RELEASE, io + SIS_AC97_SEMA);
+ if (!count)
+ return -EIO;
+
+ /* Now that we've finished the reset, find out what's attached.
+ * There are some codec/board combinations that take an extremely
+ * long time to come up. 350+ ms has been observed in the field,
+ * so we'll give them up to 500ms.
+ */
+ sis->codecs_present = 0;
+ timeout = msecs_to_jiffies(500) + jiffies;
+ while (time_before_eq(jiffies, timeout)) {
+ status = inl(io + SIS_AC97_STATUS);
+ if (status & SIS_AC97_STATUS_CODEC_READY)
+ sis->codecs_present |= SIS_PRIMARY_CODEC_PRESENT;
+ if (status & SIS_AC97_STATUS_CODEC2_READY)
+ sis->codecs_present |= SIS_SECONDARY_CODEC_PRESENT;
+ if (status & SIS_AC97_STATUS_CODEC3_READY)
+ sis->codecs_present |= SIS_TERTIARY_CODEC_PRESENT;
+
+ if (sis->codecs_present == codecs)
+ break;
- /* All done, let go of the semaphore, and check for errors
+ msleep(1);
+ }
+
+ /* All done, check for errors.
*/
- outl(SIS_AC97_SEMA_RELEASE, io + SIS_AC97_SEMA);
- if (!sis->codecs_present || !count)
+ if (!sis->codecs_present) {
+ printk(KERN_ERR "sis7019: could not find any codecs\n");
return -EIO;
+ }
+
+ if (sis->codecs_present != codecs) {
+ printk(KERN_WARNING "sis7019: missing codecs, found %0x, expected %0x\n",
+ sis->codecs_present, codecs);
+ }
/* Let the hardware know that the audio driver is alive,
* and enable PCM slots on the AC-link for L/R playback (3 & 4) and
@@ -1390,6 +1421,17 @@ static int __devinit snd_sis7019_probe(s
if (!enable)
goto error_out;
+ /* The user can specify which codecs should be present so that we
+ * can wait for them to show up if they are slow to recover from
+ * the AC97 cold reset. We default to a single codec, the primary.
+ *
+ * We assume that SIS_PRIMARY_*_PRESENT matches bits 0-2.
+ */
+ codecs &= SIS_PRIMARY_CODEC_PRESENT | SIS_SECONDARY_CODEC_PRESENT |
+ SIS_TERTIARY_CODEC_PRESENT;
+ if (!codecs)
+ codecs = SIS_PRIMARY_CODEC_PRESENT;
+
rc = snd_card_create(index, id, THIS_MODULE, sizeof(*sis), &card);
if (rc < 0)
goto error_out;
next prev parent reply other threads:[~2011-12-16 19:50 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-16 19:46 [00/53] 3.1.6-stable review Greg KH
2011-12-16 19:44 ` Greg KH [this message]
2011-12-16 19:44 ` [02/53] ALSA: hda/realtek - Fix Oops in alc_mux_select() Greg KH
2011-12-16 19:45 ` [03/53] ALSA: hda - Fix GPIO LED setup for IDT 92HD75 codecs Greg KH
2011-12-16 19:45 ` [04/53] alarmtimers: Fix time comparison Greg KH
2011-12-16 19:45 ` [05/53] ARM: davinci: da850 evm: change audio edma event queue to EVENTQ_0 Greg KH
2011-12-16 19:45 ` [06/53] arm: mx23: recognise stmp378x as mx23 Greg KH
2011-12-16 19:45 ` [07/53] ARM: at91: fix clock conid for atmel_tcb.1 on 9260/9g20 Greg KH
2011-12-16 19:45 ` [08/53] ARM: at91: Fix USB AT91 gadget registration Greg KH
2011-12-16 19:45 ` [09/53] ARM: davinci: dm646x evm: wrong register used in setup_vpif_input_channel_mode Greg KH
2011-12-16 19:45 ` [10/53] ASoC: Provide a more complete DMA driver stub Greg KH
2011-12-16 19:45 ` [11/53] drivers/rtc/rtc-s3c.c: fix driver clock enable/disable balance issues Greg KH
2011-12-16 19:45 ` [12/53] fs/proc/meminfo.c: fix compilation error Greg KH
2011-12-16 19:45 ` [13/53] thp: add compound tail page _mapcount when mapped Greg KH
2011-12-16 19:45 ` [14/53] thp: set compound tail page _count to zero Greg KH
2011-12-16 19:45 ` [15/53] lockdep, kmemcheck: Annotate ->lock in lockdep_init_map() Greg KH
2011-12-16 19:45 ` [16/53] ptp: Fix clock_getres() implementation Greg KH
2011-12-16 19:45 ` [17/53] mm: Ensure that pfn_valid() is called once per pageblock when reserving pageblocks Greg KH
2011-12-16 19:45 ` [18/53] mm: vmalloc: check for page allocation failure before vmlist insertion Greg KH
2011-12-16 19:45 ` [19/53] fix apparmor dereferencing potentially freed dentry, sanitize __d_path() API Greg KH
2011-12-16 19:45 ` [20/53] TOMOYO: Fix pathname handling of disconnected paths Greg KH
2011-12-16 19:45 ` [21/53] target: Reject SCSI data overflow for fabrics using transport_generic_map_mem_to_cmd Greg KH
2011-12-16 19:45 ` [22/53] iscsi-target: Fix residual count hanlding + remove iscsi_cmd->residual_count Greg KH
2011-12-16 19:45 ` [23/53] target: Handle 0 correctly in transport_get_sectors_6() Greg KH
2011-12-16 19:45 ` [24/53] target: Fix page length in emulated INQUIRY VPD page 86h Greg KH
2011-12-16 19:45 ` [25/53] iscsi-target: Add missing F_BIT for iscsi_tm_rsp Greg KH
2011-12-16 19:45 ` [26/53] target/file: walk properly over sg list Greg KH
2011-12-16 19:45 ` [27/53] percpu: fix chunk range calculation Greg KH
2011-12-16 19:45 ` [28/53] cifs: check for NULL last_entry before calling cifs_save_resume_key Greg KH
2011-12-16 19:45 ` [29/53] linux/log2.h: Fix rounddown_pow_of_two(1) Greg KH
2011-12-16 19:45 ` [30/53] hwmon: (jz4740) fix signedness bug Greg KH
2011-12-16 19:45 ` [31/53] ARM: 7204/1: arch/arm/kernel/setup.c: initialize arm_dma_zone_size earlier Greg KH
2011-12-16 19:45 ` [32/53] mmc: mxcmmc: fix falling back to PIO Greg KH
2011-12-16 19:45 ` [33/53] xen/pm_idle: Make pm_idle be default_idle under Xen Greg KH
2011-12-16 19:45 ` [34/53] x86, hpet: Immediately disable HPET timer 1 if rtc irq is masked Greg KH
2011-12-16 19:45 ` [35/53] jbd/jbd2: validate sb->s_first in journal_get_superblock() Greg KH
2011-12-16 19:45 ` [36/53] hfs: fix hfs_find_init() sb->ext_tree NULL ptr oops Greg KH
2011-12-16 19:45 ` [37/53] drm/radeon/kms: cleanup atombios_adjust_pll() Greg KH
2011-12-16 19:45 ` [38/53] drm/radeon/kms: rework DP bridge checks Greg KH
2011-12-16 19:45 ` [39/53] drm/radeon/kms: fix DP setup on TRAVIS bridges Greg KH
2011-12-16 19:45 ` [40/53] xen: only limit memory map to maximum reservation for domain 0 Greg KH
2011-12-16 19:45 ` [41/53] ext4: fix ext4_end_io_dio() racing against fsync() Greg KH
2011-12-16 19:45 ` [42/53] ext4: display the correct mount option in /proc/mounts for [no]init_itable Greg KH
2011-12-16 19:45 ` [43/53] ext4: avoid hangs in ext4_da_should_update_i_disksize() Greg KH
2011-12-16 19:45 ` [44/53] ext4: avoid potential hang in mpage_submit_io() when blocksize < pagesize Greg KH
2011-12-16 19:45 ` [45/53] ext4: handle EOF correctly in ext4_bio_write_page() Greg KH
2011-12-16 19:45 ` [46/53] fuse: fix fuse_retrieve Greg KH
2011-12-16 19:45 ` [47/53] fuse: fix llseek bug Greg KH
2011-12-16 19:45 ` [48/53] staging: r8712u: Add new USB ID Greg KH
2011-12-16 19:45 ` [49/53] drm/radeon/kms: add some new pci ids Greg KH
2011-12-16 19:45 ` [50/53] ibft: Fix finding IBFT ACPI table on UEFI Greg KH
2011-12-16 19:45 ` [51/53] USB: cdc-acm: add IDs for Motorola H24 HSPA USB module Greg KH
2011-12-16 19:45 ` [52/53] usb: option: Add Huawei E398 controlling interfaces Greg KH
2011-12-16 19:45 ` [53/53] USB: option: Removing one bogus and adding some new Huawei combinations Greg KH
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=20111216194554.112799656@clark.kroah.org \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=dave@thedillows.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.de \
--cc=torvalds@linux-foundation.org \
/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
Powered by JetHome