Merge branch 'fix/hda' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6

* 'fix/hda' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6:
ALSA: hda - Read buffer overflow
ALSA: hda: Correct EAPD for Dell Inspiron 1525
ALSA: hda: warn on spurious response
ALSA: hda: remember last command for each codec
ALSA: hda: read CORBWP inside reg_lock
ALSA: hda: take reg_lock in azx_init_cmd_io/azx_free_cmd_io
ALSA: hda: take cmd_mutex in probe_codec()
ALSA: hda: track CIRB/CORB command/response states for each codec
ALSA: hda - Fix quirk for Toshiba Satellite A135-S4527

+86 -34
+1 -1
sound/pci/hda/hda_codec.c
··· 174 174 mutex_lock(&bus->cmd_mutex); 175 175 err = bus->ops.command(bus, cmd); 176 176 if (!err && res) 177 - *res = bus->ops.get_response(bus); 177 + *res = bus->ops.get_response(bus, codec->addr); 178 178 mutex_unlock(&bus->cmd_mutex); 179 179 snd_hda_power_down(codec); 180 180 if (res && *res == -1 && bus->rirb_error) {
+1 -1
sound/pci/hda/hda_codec.h
··· 568 568 /* send a single command */ 569 569 int (*command)(struct hda_bus *bus, unsigned int cmd); 570 570 /* get a response from the last command */ 571 - unsigned int (*get_response)(struct hda_bus *bus); 571 + unsigned int (*get_response)(struct hda_bus *bus, unsigned int addr); 572 572 /* free the private data */ 573 573 void (*private_free)(struct hda_bus *); 574 574 /* attach a PCM stream */
+74 -29
sound/pci/hda/hda_intel.c
··· 253 253 254 254 /* STATESTS int mask: S3,SD2,SD1,SD0 */ 255 255 #define AZX_MAX_CODECS 4 256 - #define STATESTS_INT_MASK 0x0f 256 + #define STATESTS_INT_MASK ((1 << AZX_MAX_CODECS) - 1) 257 257 258 258 /* SD_CTL bits */ 259 259 #define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */ ··· 361 361 dma_addr_t addr; /* physical address of CORB/RIRB buffer */ 362 362 /* for RIRB */ 363 363 unsigned short rp, wp; /* read/write pointers */ 364 - int cmds; /* number of pending requests */ 365 - u32 res; /* last read value */ 364 + int cmds[AZX_MAX_CODECS]; /* number of pending requests */ 365 + u32 res[AZX_MAX_CODECS]; /* last read value */ 366 366 }; 367 367 368 368 struct azx { ··· 418 418 unsigned int probing :1; /* codec probing phase */ 419 419 420 420 /* for debugging */ 421 - unsigned int last_cmd; /* last issued command (to sync) */ 421 + unsigned int last_cmd[AZX_MAX_CODECS]; 422 422 423 423 /* for pending irqs */ 424 424 struct work_struct irq_pending_work; ··· 513 513 514 514 static void azx_init_cmd_io(struct azx *chip) 515 515 { 516 + spin_lock_irq(&chip->reg_lock); 516 517 /* CORB set up */ 517 518 chip->corb.addr = chip->rb.addr; 518 519 chip->corb.buf = (u32 *)chip->rb.area; ··· 532 531 /* RIRB set up */ 533 532 chip->rirb.addr = chip->rb.addr + 2048; 534 533 chip->rirb.buf = (u32 *)(chip->rb.area + 2048); 535 - chip->rirb.wp = chip->rirb.rp = chip->rirb.cmds = 0; 534 + chip->rirb.wp = chip->rirb.rp = 0; 535 + memset(chip->rirb.cmds, 0, sizeof(chip->rirb.cmds)); 536 536 azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr); 537 537 azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr)); 538 538 ··· 545 543 azx_writew(chip, RINTCNT, 1); 546 544 /* enable rirb dma and response irq */ 547 545 azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN); 546 + spin_unlock_irq(&chip->reg_lock); 548 547 } 549 548 550 549 static void azx_free_cmd_io(struct azx *chip) 551 550 { 551 + spin_lock_irq(&chip->reg_lock); 552 552 /* disable ringbuffer DMAs */ 553 553 azx_writeb(chip, RIRBCTL, 0); 554 554 azx_writeb(chip, CORBCTL, 0); 555 + spin_unlock_irq(&chip->reg_lock); 556 + } 557 + 558 + static unsigned int azx_command_addr(u32 cmd) 559 + { 560 + unsigned int addr = cmd >> 28; 561 + 562 + if (addr >= AZX_MAX_CODECS) { 563 + snd_BUG(); 564 + addr = 0; 565 + } 566 + 567 + return addr; 568 + } 569 + 570 + static unsigned int azx_response_addr(u32 res) 571 + { 572 + unsigned int addr = res & 0xf; 573 + 574 + if (addr >= AZX_MAX_CODECS) { 575 + snd_BUG(); 576 + addr = 0; 577 + } 578 + 579 + return addr; 555 580 } 556 581 557 582 /* send a command */ 558 583 static int azx_corb_send_cmd(struct hda_bus *bus, u32 val) 559 584 { 560 585 struct azx *chip = bus->private_data; 586 + unsigned int addr = azx_command_addr(val); 561 587 unsigned int wp; 588 + 589 + spin_lock_irq(&chip->reg_lock); 562 590 563 591 /* add command to corb */ 564 592 wp = azx_readb(chip, CORBWP); 565 593 wp++; 566 594 wp %= ICH6_MAX_CORB_ENTRIES; 567 595 568 - spin_lock_irq(&chip->reg_lock); 569 - chip->rirb.cmds++; 596 + chip->rirb.cmds[addr]++; 570 597 chip->corb.buf[wp] = cpu_to_le32(val); 571 598 azx_writel(chip, CORBWP, wp); 599 + 572 600 spin_unlock_irq(&chip->reg_lock); 573 601 574 602 return 0; ··· 610 578 static void azx_update_rirb(struct azx *chip) 611 579 { 612 580 unsigned int rp, wp; 581 + unsigned int addr; 613 582 u32 res, res_ex; 614 583 615 584 wp = azx_readb(chip, RIRBWP); 616 585 if (wp == chip->rirb.wp) 617 586 return; 618 587 chip->rirb.wp = wp; 619 - 588 + 620 589 while (chip->rirb.rp != wp) { 621 590 chip->rirb.rp++; 622 591 chip->rirb.rp %= ICH6_MAX_RIRB_ENTRIES; ··· 625 592 rp = chip->rirb.rp << 1; /* an RIRB entry is 8-bytes */ 626 593 res_ex = le32_to_cpu(chip->rirb.buf[rp + 1]); 627 594 res = le32_to_cpu(chip->rirb.buf[rp]); 595 + addr = azx_response_addr(res_ex); 628 596 if (res_ex & ICH6_RIRB_EX_UNSOL_EV) 629 597 snd_hda_queue_unsol_event(chip->bus, res, res_ex); 630 - else if (chip->rirb.cmds) { 631 - chip->rirb.res = res; 598 + else if (chip->rirb.cmds[addr]) { 599 + chip->rirb.res[addr] = res; 632 600 smp_wmb(); 633 - chip->rirb.cmds--; 634 - } 601 + chip->rirb.cmds[addr]--; 602 + } else 603 + snd_printk(KERN_ERR SFX "spurious response %#x:%#x, " 604 + "last cmd=%#08x\n", 605 + res, res_ex, 606 + chip->last_cmd[addr]); 635 607 } 636 608 } 637 609 638 610 /* receive a response */ 639 - static unsigned int azx_rirb_get_response(struct hda_bus *bus) 611 + static unsigned int azx_rirb_get_response(struct hda_bus *bus, 612 + unsigned int addr) 640 613 { 641 614 struct azx *chip = bus->private_data; 642 615 unsigned long timeout; ··· 655 616 azx_update_rirb(chip); 656 617 spin_unlock_irq(&chip->reg_lock); 657 618 } 658 - if (!chip->rirb.cmds) { 619 + if (!chip->rirb.cmds[addr]) { 659 620 smp_rmb(); 660 621 bus->rirb_error = 0; 661 - return chip->rirb.res; /* the last value */ 622 + return chip->rirb.res[addr]; /* the last value */ 662 623 } 663 624 if (time_after(jiffies, timeout)) 664 625 break; ··· 672 633 673 634 if (chip->msi) { 674 635 snd_printk(KERN_WARNING SFX "No response from codec, " 675 - "disabling MSI: last cmd=0x%08x\n", chip->last_cmd); 636 + "disabling MSI: last cmd=0x%08x\n", 637 + chip->last_cmd[addr]); 676 638 free_irq(chip->irq, chip); 677 639 chip->irq = -1; 678 640 pci_disable_msi(chip->pci); ··· 688 648 if (!chip->polling_mode) { 689 649 snd_printk(KERN_WARNING SFX "azx_get_response timeout, " 690 650 "switching to polling mode: last cmd=0x%08x\n", 691 - chip->last_cmd); 651 + chip->last_cmd[addr]); 692 652 chip->polling_mode = 1; 693 653 goto again; 694 654 } ··· 712 672 713 673 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, " 714 674 "switching to single_cmd mode: last cmd=0x%08x\n", 715 - chip->last_cmd); 675 + chip->last_cmd[addr]); 716 676 chip->single_cmd = 1; 717 677 bus->response_reset = 0; 718 678 /* re-initialize CORB/RIRB */ ··· 732 692 */ 733 693 734 694 /* receive a response */ 735 - static int azx_single_wait_for_response(struct azx *chip) 695 + static int azx_single_wait_for_response(struct azx *chip, unsigned int addr) 736 696 { 737 697 int timeout = 50; 738 698 ··· 740 700 /* check IRV busy bit */ 741 701 if (azx_readw(chip, IRS) & ICH6_IRS_VALID) { 742 702 /* reuse rirb.res as the response return value */ 743 - chip->rirb.res = azx_readl(chip, IR); 703 + chip->rirb.res[addr] = azx_readl(chip, IR); 744 704 return 0; 745 705 } 746 706 udelay(1); ··· 748 708 if (printk_ratelimit()) 749 709 snd_printd(SFX "get_response timeout: IRS=0x%x\n", 750 710 azx_readw(chip, IRS)); 751 - chip->rirb.res = -1; 711 + chip->rirb.res[addr] = -1; 752 712 return -EIO; 753 713 } 754 714 ··· 756 716 static int azx_single_send_cmd(struct hda_bus *bus, u32 val) 757 717 { 758 718 struct azx *chip = bus->private_data; 719 + unsigned int addr = azx_command_addr(val); 759 720 int timeout = 50; 760 721 761 722 bus->rirb_error = 0; ··· 769 728 azx_writel(chip, IC, val); 770 729 azx_writew(chip, IRS, azx_readw(chip, IRS) | 771 730 ICH6_IRS_BUSY); 772 - return azx_single_wait_for_response(chip); 731 + return azx_single_wait_for_response(chip, addr); 773 732 } 774 733 udelay(1); 775 734 } ··· 780 739 } 781 740 782 741 /* receive a response */ 783 - static unsigned int azx_single_get_response(struct hda_bus *bus) 742 + static unsigned int azx_single_get_response(struct hda_bus *bus, 743 + unsigned int addr) 784 744 { 785 745 struct azx *chip = bus->private_data; 786 - return chip->rirb.res; 746 + return chip->rirb.res[addr]; 787 747 } 788 748 789 749 /* ··· 799 757 { 800 758 struct azx *chip = bus->private_data; 801 759 802 - chip->last_cmd = val; 760 + chip->last_cmd[azx_command_addr(val)] = val; 803 761 if (chip->single_cmd) 804 762 return azx_single_send_cmd(bus, val); 805 763 else ··· 807 765 } 808 766 809 767 /* get a response */ 810 - static unsigned int azx_get_response(struct hda_bus *bus) 768 + static unsigned int azx_get_response(struct hda_bus *bus, 769 + unsigned int addr) 811 770 { 812 771 struct azx *chip = bus->private_data; 813 772 if (chip->single_cmd) 814 - return azx_single_get_response(bus); 773 + return azx_single_get_response(bus, addr); 815 774 else 816 - return azx_rirb_get_response(bus); 775 + return azx_rirb_get_response(bus, addr); 817 776 } 818 777 819 778 #ifdef CONFIG_SND_HDA_POWER_SAVE ··· 1286 1243 (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID; 1287 1244 unsigned int res; 1288 1245 1246 + mutex_lock(&chip->bus->cmd_mutex); 1289 1247 chip->probing = 1; 1290 1248 azx_send_cmd(chip->bus, cmd); 1291 - res = azx_get_response(chip->bus); 1249 + res = azx_get_response(chip->bus, addr); 1292 1250 chip->probing = 0; 1251 + mutex_unlock(&chip->bus->cmd_mutex); 1293 1252 if (res == -1) 1294 1253 return -EIO; 1295 1254 snd_printdd(SFX "codec #%d probed OK\n", addr);
+2 -2
sound/pci/hda/patch_realtek.c
··· 559 559 560 560 /* Find enumerated value for current pinctl setting */ 561 561 i = alc_pin_mode_min(dir); 562 - while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) 562 + while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl) 563 563 i++; 564 564 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); 565 565 return 0; ··· 15157 15157 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), 15158 15158 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), 15159 15159 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ 15160 - SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), 15160 + SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO), 15161 15161 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), 15162 15162 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), 15163 15163 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
+8 -1
sound/pci/hda/patch_sigmatel.c
··· 2266 2266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), 2267 2267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS), 2268 2268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), 2269 - SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST), 2269 + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS), 2270 2270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), 2271 2271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), 2272 2272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), ··· 5645 5645 /* GPIO2 High = Enable EAPD */ 5646 5646 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; 5647 5647 spec->gpio_data = 0x04; 5648 + switch (codec->subsystem_id) { 5649 + case 0x1028022f: 5650 + /* correct EAPD to be GPIO0 */ 5651 + spec->eapd_mask = spec->gpio_mask = 0x01; 5652 + spec->gpio_dir = spec->gpio_data = 0x01; 5653 + break; 5654 + }; 5648 5655 spec->dmic_nids = stac927x_dmic_nids; 5649 5656 spec->num_dmics = STAC927X_NUM_DMICS; 5650 5657