Merge tag 'sound-fix-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound

Pull sound fixes from Takashi Iwai:
"Here are a few remaining patches for 6.1-rc1.

The major changes are the hibernation fixes for HD-audio CS35L41 codec
and the USB-audio small fixes against the last change. In addition, a
couple of HD-audio regression fixes and a couple of potential
mutex-deadlock fixes with OSS emulation in ALSA core side are seen"

* tag 'sound-fix-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
ALSA: hda: cs35l41: Support System Suspend
ALSA: hda: cs35l41: Remove suspend/resume hda hooks
ALSA: hda/cs_dsp_ctl: Fix mutex inversion when creating controls
ALSA: hda: hda_cs_dsp_ctl: Ensure pwr_lock is held before reading/writing controls
ALSA: hda: hda_cs_dsp_ctl: Minor clean and redundant code removal
ALSA: oss: Fix potential deadlock at unregistration
ALSA: rawmidi: Drop register_mutex in snd_rawmidi_free()
ALSA: hda/realtek: Add Intel Reference SSID to support headset keys
ALSA: hda/realtek: Add quirk for ASUS GV601R laptop
ALSA: hda/realtek: Correct pin configs for ASUS G533Z
ALSA: usb-audio: Avoid superfluous endpoint setup
ALSA: usb-audio: Correct the return code from snd_usb_endpoint_set_params()
ALSA: usb-audio: Apply mutex around snd_usb_endpoint_set_params()
ALSA: usb-audio: Avoid unnecessary interface change at EP close
ALSA: hda: Update register polling macros
ALSA: hda/realtek: remove ALC289_FIXUP_DUAL_SPK for Dell 5530

+246 -124
+4 -4
include/sound/hdaudio.h
··· 592 592 #define snd_hdac_stream_readb(dev, reg) \ 593 593 snd_hdac_reg_readb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) 594 594 #define snd_hdac_stream_readb_poll(dev, reg, val, cond, delay_us, timeout_us) \ 595 - readb_poll_timeout((dev)->sd_addr + AZX_REG_ ## reg, val, cond, \ 596 - delay_us, timeout_us) 595 + read_poll_timeout_atomic(snd_hdac_reg_readb, val, cond, delay_us, timeout_us, \ 596 + false, (dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) 597 597 #define snd_hdac_stream_readl_poll(dev, reg, val, cond, delay_us, timeout_us) \ 598 - readl_poll_timeout((dev)->sd_addr + AZX_REG_ ## reg, val, cond, \ 599 - delay_us, timeout_us) 598 + read_poll_timeout_atomic(snd_hdac_reg_readl, val, cond, delay_us, timeout_us, \ 599 + false, (dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) 600 600 601 601 /* update a register, pass without AZX_REG_ prefix */ 602 602 #define snd_hdac_stream_updatel(dev, reg, mask, val) \
-2
sound/core/rawmidi.c
··· 1899 1899 1900 1900 snd_info_free_entry(rmidi->proc_entry); 1901 1901 rmidi->proc_entry = NULL; 1902 - mutex_lock(&register_mutex); 1903 1902 if (rmidi->ops && rmidi->ops->dev_unregister) 1904 1903 rmidi->ops->dev_unregister(rmidi); 1905 - mutex_unlock(&register_mutex); 1906 1904 1907 1905 snd_rawmidi_free_substreams(&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT]); 1908 1906 snd_rawmidi_free_substreams(&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]);
+9 -4
sound/core/sound_oss.c
··· 162 162 mutex_unlock(&sound_oss_mutex); 163 163 return -ENOENT; 164 164 } 165 - unregister_sound_special(minor); 166 165 switch (SNDRV_MINOR_OSS_DEVICE(minor)) { 167 166 case SNDRV_MINOR_OSS_PCM: 168 167 track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_AUDIO); ··· 173 174 track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1); 174 175 break; 175 176 } 176 - if (track2 >= 0) { 177 - unregister_sound_special(track2); 177 + if (track2 >= 0) 178 178 snd_oss_minors[track2] = NULL; 179 - } 180 179 snd_oss_minors[minor] = NULL; 181 180 mutex_unlock(&sound_oss_mutex); 181 + 182 + /* call unregister_sound_special() outside sound_oss_mutex; 183 + * otherwise may deadlock, as it can trigger the release of a card 184 + */ 185 + unregister_sound_special(minor); 186 + if (track2 >= 0) 187 + unregister_sound_special(track2); 188 + 182 189 kfree(mptr); 183 190 return 0; 184 191 }
+151 -46
sound/pci/hda/cs35l41_hda.c
··· 91 91 { CS35L41_AMP_DIG_VOL_CTRL, 0x0000A678 }, // AMP_VOL_PCM Mute 92 92 }; 93 93 94 - static int cs35l41_control_add(struct cs_dsp_coeff_ctl *cs_ctl) 94 + static void cs35l41_add_controls(struct cs35l41_hda *cs35l41) 95 95 { 96 - struct cs35l41_hda *cs35l41 = container_of(cs_ctl->dsp, struct cs35l41_hda, cs_dsp); 97 96 struct hda_cs_dsp_ctl_info info; 98 97 99 98 info.device_name = cs35l41->amp_name; 100 99 info.fw_type = cs35l41->firmware_type; 101 100 info.card = cs35l41->codec->card; 102 101 103 - return hda_cs_dsp_control_add(cs_ctl, &info); 102 + hda_cs_dsp_add_controls(&cs35l41->cs_dsp, &info); 104 103 } 105 104 106 105 static const struct cs_dsp_client_ops client_ops = { 107 - .control_add = cs35l41_control_add, 108 106 .control_remove = hda_cs_dsp_control_remove, 109 107 }; 110 108 ··· 433 435 if (ret) 434 436 goto err_release; 435 437 438 + cs35l41_add_controls(cs35l41); 439 + 436 440 ret = cs35l41_save_calibration(cs35l41); 437 441 438 442 err_release: ··· 461 461 struct cs_dsp *dsp = &cs35l41->cs_dsp; 462 462 463 463 cancel_work_sync(&cs35l41->fw_load_work); 464 + 465 + mutex_lock(&cs35l41->fw_mutex); 464 466 cs35l41_shutdown_dsp(cs35l41); 465 467 cs_dsp_remove(dsp); 466 468 cs35l41->halo_initialized = false; 469 + mutex_unlock(&cs35l41->fw_mutex); 467 470 } 468 471 469 472 /* Protection release cycle to get the speaker out of Safe-Mode */ ··· 490 487 struct regmap *reg = cs35l41->regmap; 491 488 int ret = 0; 492 489 493 - mutex_lock(&cs35l41->fw_mutex); 494 - 495 490 switch (action) { 496 491 case HDA_GEN_PCM_ACT_OPEN: 492 + pm_runtime_get_sync(dev); 493 + mutex_lock(&cs35l41->fw_mutex); 497 494 cs35l41->playback_started = true; 498 495 if (cs35l41->firmware_running) { 499 496 regmap_multi_reg_write(reg, cs35l41_hda_config_dsp, ··· 511 508 CS35L41_AMP_EN_MASK, 1 << CS35L41_AMP_EN_SHIFT); 512 509 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) 513 510 regmap_write(reg, CS35L41_GPIO1_CTRL1, 0x00008001); 511 + mutex_unlock(&cs35l41->fw_mutex); 514 512 break; 515 513 case HDA_GEN_PCM_ACT_PREPARE: 514 + mutex_lock(&cs35l41->fw_mutex); 516 515 ret = cs35l41_global_enable(reg, cs35l41->hw_cfg.bst_type, 1); 516 + mutex_unlock(&cs35l41->fw_mutex); 517 517 break; 518 518 case HDA_GEN_PCM_ACT_CLEANUP: 519 + mutex_lock(&cs35l41->fw_mutex); 519 520 regmap_multi_reg_write(reg, cs35l41_hda_mute, ARRAY_SIZE(cs35l41_hda_mute)); 520 521 ret = cs35l41_global_enable(reg, cs35l41->hw_cfg.bst_type, 0); 522 + mutex_unlock(&cs35l41->fw_mutex); 521 523 break; 522 524 case HDA_GEN_PCM_ACT_CLOSE: 525 + mutex_lock(&cs35l41->fw_mutex); 523 526 ret = regmap_update_bits(reg, CS35L41_PWR_CTRL2, 524 527 CS35L41_AMP_EN_MASK, 0 << CS35L41_AMP_EN_SHIFT); 525 528 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) ··· 539 530 } 540 531 cs35l41_irq_release(cs35l41); 541 532 cs35l41->playback_started = false; 533 + mutex_unlock(&cs35l41->fw_mutex); 534 + 535 + pm_runtime_mark_last_busy(dev); 536 + pm_runtime_put_autosuspend(dev); 542 537 break; 543 538 default: 544 539 dev_warn(cs35l41->dev, "Playback action not supported: %d\n", action); 545 540 break; 546 541 } 547 - 548 - mutex_unlock(&cs35l41->fw_mutex); 549 542 550 543 if (ret) 551 544 dev_err(cs35l41->dev, "Regmap access fail: %d\n", ret); ··· 573 562 rx_slot); 574 563 } 575 564 565 + static void cs35l41_ready_for_reset(struct cs35l41_hda *cs35l41) 566 + { 567 + mutex_lock(&cs35l41->fw_mutex); 568 + if (cs35l41->firmware_running) { 569 + 570 + regcache_cache_only(cs35l41->regmap, false); 571 + 572 + cs35l41_exit_hibernate(cs35l41->dev, cs35l41->regmap); 573 + cs35l41_shutdown_dsp(cs35l41); 574 + cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type); 575 + 576 + regcache_cache_only(cs35l41->regmap, true); 577 + regcache_mark_dirty(cs35l41->regmap); 578 + } 579 + mutex_unlock(&cs35l41->fw_mutex); 580 + } 581 + 582 + static int cs35l41_system_suspend(struct device *dev) 583 + { 584 + struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); 585 + int ret; 586 + 587 + dev_dbg(cs35l41->dev, "System Suspend\n"); 588 + 589 + if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { 590 + dev_err(cs35l41->dev, "System Suspend not supported\n"); 591 + return -EINVAL; 592 + } 593 + 594 + ret = pm_runtime_force_suspend(dev); 595 + if (ret) 596 + return ret; 597 + 598 + /* Shutdown DSP before system suspend */ 599 + cs35l41_ready_for_reset(cs35l41); 600 + 601 + /* 602 + * Reset GPIO may be shared, so cannot reset here. 603 + * However beyond this point, amps may be powered down. 604 + */ 605 + return 0; 606 + } 607 + 608 + static int cs35l41_system_resume(struct device *dev) 609 + { 610 + struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); 611 + int ret; 612 + 613 + dev_dbg(cs35l41->dev, "System Resume\n"); 614 + 615 + if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { 616 + dev_err(cs35l41->dev, "System Resume not supported\n"); 617 + return -EINVAL; 618 + } 619 + 620 + if (cs35l41->reset_gpio) { 621 + usleep_range(2000, 2100); 622 + gpiod_set_value_cansleep(cs35l41->reset_gpio, 1); 623 + } 624 + 625 + usleep_range(2000, 2100); 626 + 627 + ret = pm_runtime_force_resume(dev); 628 + 629 + mutex_lock(&cs35l41->fw_mutex); 630 + if (!ret && cs35l41->request_fw_load && !cs35l41->fw_request_ongoing) { 631 + cs35l41->fw_request_ongoing = true; 632 + schedule_work(&cs35l41->fw_load_work); 633 + } 634 + mutex_unlock(&cs35l41->fw_mutex); 635 + 636 + return ret; 637 + } 638 + 576 639 static int cs35l41_runtime_suspend(struct device *dev) 577 640 { 578 641 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); 642 + int ret = 0; 579 643 580 - dev_dbg(cs35l41->dev, "Suspend\n"); 644 + dev_dbg(cs35l41->dev, "Runtime Suspend\n"); 581 645 582 - if (!cs35l41->firmware_running) 646 + if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { 647 + dev_dbg(cs35l41->dev, "Runtime Suspend not supported\n"); 583 648 return 0; 649 + } 584 650 585 - if (cs35l41_enter_hibernate(cs35l41->dev, cs35l41->regmap, cs35l41->hw_cfg.bst_type) < 0) 586 - return 0; 651 + mutex_lock(&cs35l41->fw_mutex); 652 + 653 + if (cs35l41->playback_started) { 654 + regmap_multi_reg_write(cs35l41->regmap, cs35l41_hda_mute, 655 + ARRAY_SIZE(cs35l41_hda_mute)); 656 + cs35l41_global_enable(cs35l41->regmap, cs35l41->hw_cfg.bst_type, 0); 657 + regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2, 658 + CS35L41_AMP_EN_MASK, 0 << CS35L41_AMP_EN_SHIFT); 659 + if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) 660 + regmap_write(cs35l41->regmap, CS35L41_GPIO1_CTRL1, 0x00000001); 661 + regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2, 662 + CS35L41_VMON_EN_MASK | CS35L41_IMON_EN_MASK, 663 + 0 << CS35L41_VMON_EN_SHIFT | 0 << CS35L41_IMON_EN_SHIFT); 664 + cs35l41->playback_started = false; 665 + } 666 + 667 + if (cs35l41->firmware_running) { 668 + ret = cs35l41_enter_hibernate(cs35l41->dev, cs35l41->regmap, 669 + cs35l41->hw_cfg.bst_type); 670 + if (ret) 671 + goto err; 672 + } else { 673 + cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type); 674 + } 587 675 588 676 regcache_cache_only(cs35l41->regmap, true); 589 677 regcache_mark_dirty(cs35l41->regmap); 590 678 591 - return 0; 679 + err: 680 + mutex_unlock(&cs35l41->fw_mutex); 681 + 682 + return ret; 592 683 } 593 684 594 685 static int cs35l41_runtime_resume(struct device *dev) 595 686 { 596 687 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); 597 - int ret; 688 + int ret = 0; 598 689 599 - dev_dbg(cs35l41->dev, "Resume.\n"); 690 + dev_dbg(cs35l41->dev, "Runtime Resume\n"); 600 691 601 692 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { 602 - dev_dbg(cs35l41->dev, "System does not support Resume\n"); 693 + dev_dbg(cs35l41->dev, "Runtime Resume not supported\n"); 603 694 return 0; 604 695 } 605 696 606 - if (!cs35l41->firmware_running) 607 - return 0; 697 + mutex_lock(&cs35l41->fw_mutex); 608 698 609 699 regcache_cache_only(cs35l41->regmap, false); 610 700 611 - ret = cs35l41_exit_hibernate(cs35l41->dev, cs35l41->regmap); 612 - if (ret) { 613 - regcache_cache_only(cs35l41->regmap, true); 614 - return ret; 701 + if (cs35l41->firmware_running) { 702 + ret = cs35l41_exit_hibernate(cs35l41->dev, cs35l41->regmap); 703 + if (ret) { 704 + dev_warn(cs35l41->dev, "Unable to exit Hibernate."); 705 + goto err; 706 + } 615 707 } 616 708 617 709 /* Test key needs to be unlocked to allow the OTP settings to re-apply */ ··· 723 609 cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); 724 610 if (ret) { 725 611 dev_err(cs35l41->dev, "Failed to restore register cache: %d\n", ret); 726 - return ret; 612 + goto err; 727 613 } 728 614 729 615 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) 730 616 cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, &cs35l41->hw_cfg); 731 617 732 - return 0; 733 - } 618 + err: 619 + mutex_unlock(&cs35l41->fw_mutex); 734 620 735 - static int cs35l41_hda_suspend_hook(struct device *dev) 736 - { 737 - dev_dbg(dev, "Request Suspend\n"); 738 - pm_runtime_mark_last_busy(dev); 739 - return pm_runtime_put_autosuspend(dev); 740 - } 741 - 742 - static int cs35l41_hda_resume_hook(struct device *dev) 743 - { 744 - dev_dbg(dev, "Request Resume\n"); 745 - return pm_runtime_get_sync(dev); 621 + return ret; 746 622 } 747 623 748 624 static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41) ··· 782 678 783 679 static void cs35l41_load_firmware(struct cs35l41_hda *cs35l41, bool load) 784 680 { 785 - pm_runtime_get_sync(cs35l41->dev); 786 - 787 681 if (cs35l41->firmware_running && !load) { 788 682 dev_dbg(cs35l41->dev, "Unloading Firmware\n"); 789 683 cs35l41_shutdown_dsp(cs35l41); ··· 791 689 } else { 792 690 dev_dbg(cs35l41->dev, "Unable to Load firmware.\n"); 793 691 } 794 - 795 - pm_runtime_mark_last_busy(cs35l41->dev); 796 - pm_runtime_put_autosuspend(cs35l41->dev); 797 692 } 798 693 799 694 static int cs35l41_fw_load_ctl_get(struct snd_kcontrol *kcontrol, ··· 806 707 { 807 708 struct cs35l41_hda *cs35l41 = container_of(work, struct cs35l41_hda, fw_load_work); 808 709 710 + pm_runtime_get_sync(cs35l41->dev); 711 + 809 712 mutex_lock(&cs35l41->fw_mutex); 810 713 811 714 /* Recheck if playback is ongoing, mutex will block playback during firmware loading */ 812 715 if (cs35l41->playback_started) 813 - dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback\n"); 716 + dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback. Retrying...\n"); 814 717 else 815 718 cs35l41_load_firmware(cs35l41, cs35l41->request_fw_load); 816 719 817 720 cs35l41->fw_request_ongoing = false; 818 721 mutex_unlock(&cs35l41->fw_mutex); 722 + 723 + pm_runtime_mark_last_busy(cs35l41->dev); 724 + pm_runtime_put_autosuspend(cs35l41->dev); 819 725 } 820 726 821 727 static int cs35l41_fw_load_ctl_put(struct snd_kcontrol *kcontrol, ··· 944 840 945 841 pm_runtime_get_sync(dev); 946 842 843 + mutex_lock(&cs35l41->fw_mutex); 844 + 947 845 comps->dev = dev; 948 846 if (!cs35l41->acpi_subsystem_id) 949 847 cs35l41->acpi_subsystem_id = kasprintf(GFP_KERNEL, "%.8x", ··· 958 852 if (firmware_autostart) { 959 853 dev_dbg(cs35l41->dev, "Firmware Autostart.\n"); 960 854 cs35l41->request_fw_load = true; 961 - mutex_lock(&cs35l41->fw_mutex); 962 855 if (cs35l41_smart_amp(cs35l41) < 0) 963 856 dev_warn(cs35l41->dev, "Cannot Run Firmware, reverting to dsp bypass...\n"); 964 - mutex_unlock(&cs35l41->fw_mutex); 965 857 } else { 966 858 dev_dbg(cs35l41->dev, "Firmware Autostart is disabled.\n"); 967 859 } ··· 967 863 ret = cs35l41_create_controls(cs35l41); 968 864 969 865 comps->playback_hook = cs35l41_hda_playback_hook; 970 - comps->suspend_hook = cs35l41_hda_suspend_hook; 971 - comps->resume_hook = cs35l41_hda_resume_hook; 866 + 867 + mutex_unlock(&cs35l41->fw_mutex); 972 868 973 869 pm_runtime_mark_last_busy(dev); 974 870 pm_runtime_put_autosuspend(dev); ··· 1537 1433 1538 1434 const struct dev_pm_ops cs35l41_hda_pm_ops = { 1539 1435 RUNTIME_PM_OPS(cs35l41_runtime_suspend, cs35l41_runtime_resume, NULL) 1436 + SYSTEM_SLEEP_PM_OPS(cs35l41_system_suspend, cs35l41_system_resume) 1540 1437 }; 1541 1438 EXPORT_SYMBOL_NS_GPL(cs35l41_hda_pm_ops, SND_HDA_SCODEC_CS35L41); 1542 1439
-2
sound/pci/hda/hda_component.h
··· 16 16 char name[HDA_MAX_NAME_SIZE]; 17 17 struct hda_codec *codec; 18 18 void (*playback_hook)(struct device *dev, int action); 19 - int (*suspend_hook)(struct device *dev); 20 - int (*resume_hook)(struct device *dev); 21 19 };
+46 -35
sound/pci/hda/hda_cs_dsp_ctl.c
··· 97 97 return out; 98 98 } 99 99 100 - static int hda_cs_dsp_add_kcontrol(struct hda_cs_dsp_coeff_ctl *ctl, const char *name) 100 + static void hda_cs_dsp_add_kcontrol(struct hda_cs_dsp_coeff_ctl *ctl, const char *name) 101 101 { 102 102 struct cs_dsp_coeff_ctl *cs_ctl = ctl->cs_ctl; 103 103 struct snd_kcontrol_new kcontrol = {0}; ··· 107 107 if (cs_ctl->len > ADSP_MAX_STD_CTRL_SIZE) { 108 108 dev_err(cs_ctl->dsp->dev, "KControl %s: length %zu exceeds maximum %d\n", name, 109 109 cs_ctl->len, ADSP_MAX_STD_CTRL_SIZE); 110 - return -EINVAL; 110 + return; 111 111 } 112 112 113 113 kcontrol.name = name; ··· 120 120 /* Save ctl inside private_data, ctl is owned by cs_dsp, 121 121 * and will be freed when cs_dsp removes the control */ 122 122 kctl = snd_ctl_new1(&kcontrol, (void *)ctl); 123 - if (!kctl) { 124 - ret = -ENOMEM; 125 - return ret; 126 - } 123 + if (!kctl) 124 + return; 127 125 128 126 ret = snd_ctl_add(ctl->card, kctl); 129 127 if (ret) { 130 128 dev_err(cs_ctl->dsp->dev, "Failed to add KControl %s = %d\n", kcontrol.name, ret); 131 - return ret; 129 + return; 132 130 } 133 131 134 132 dev_dbg(cs_ctl->dsp->dev, "Added KControl: %s\n", kcontrol.name); 135 133 ctl->kctl = kctl; 136 - 137 - return 0; 138 134 } 139 135 140 - int hda_cs_dsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl, struct hda_cs_dsp_ctl_info *info) 136 + static void hda_cs_dsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl, 137 + const struct hda_cs_dsp_ctl_info *info) 141 138 { 142 139 struct cs_dsp *cs_dsp = cs_ctl->dsp; 143 140 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; ··· 142 145 const char *region_name; 143 146 int ret; 144 147 145 - if (cs_ctl->flags & WMFW_CTL_FLAG_SYS) 146 - return 0; 147 - 148 148 region_name = cs_dsp_mem_region_name(cs_ctl->alg_region.type); 149 149 if (!region_name) { 150 - dev_err(cs_dsp->dev, "Unknown region type: %d\n", cs_ctl->alg_region.type); 151 - return -EINVAL; 150 + dev_warn(cs_dsp->dev, "Unknown region type: %d\n", cs_ctl->alg_region.type); 151 + return; 152 152 } 153 153 154 154 ret = scnprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s %s %.12s %x", info->device_name, ··· 165 171 166 172 ctl = kzalloc(sizeof(*ctl), GFP_KERNEL); 167 173 if (!ctl) 168 - return -ENOMEM; 174 + return; 169 175 170 176 ctl->cs_ctl = cs_ctl; 171 177 ctl->card = info->card; 172 178 cs_ctl->priv = ctl; 173 179 174 - ret = hda_cs_dsp_add_kcontrol(ctl, name); 175 - if (ret) { 176 - dev_err(cs_dsp->dev, "Error (%d) adding control %s\n", ret, name); 177 - kfree(ctl); 178 - return ret; 179 - } 180 - 181 - return 0; 180 + hda_cs_dsp_add_kcontrol(ctl, name); 182 181 } 183 - EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_control_add, SND_HDA_CS_DSP_CONTROLS); 182 + 183 + void hda_cs_dsp_add_controls(struct cs_dsp *dsp, const struct hda_cs_dsp_ctl_info *info) 184 + { 185 + struct cs_dsp_coeff_ctl *cs_ctl; 186 + 187 + /* 188 + * pwr_lock would cause mutex inversion with ALSA control lock compared 189 + * to the get/put functions. 190 + * It is safe to walk the list without holding a mutex because entries 191 + * are persistent and only cs_dsp_power_up() or cs_dsp_remove() can 192 + * change the list. 193 + */ 194 + lockdep_assert_not_held(&dsp->pwr_lock); 195 + 196 + list_for_each_entry(cs_ctl, &dsp->ctl_list, list) { 197 + if (cs_ctl->flags & WMFW_CTL_FLAG_SYS) 198 + continue; 199 + 200 + if (cs_ctl->priv) 201 + continue; 202 + 203 + hda_cs_dsp_control_add(cs_ctl, info); 204 + } 205 + } 206 + EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_add_controls, SND_HDA_CS_DSP_CONTROLS); 184 207 185 208 void hda_cs_dsp_control_remove(struct cs_dsp_coeff_ctl *cs_ctl) 186 209 { ··· 214 203 struct hda_cs_dsp_coeff_ctl *ctl; 215 204 int ret; 216 205 206 + mutex_lock(&dsp->pwr_lock); 217 207 cs_ctl = cs_dsp_get_ctl(dsp, name, type, alg); 218 - if (!cs_ctl) 219 - return -EINVAL; 220 - 221 - ctl = cs_ctl->priv; 222 - 223 208 ret = cs_dsp_coeff_write_ctrl(cs_ctl, 0, buf, len); 209 + mutex_unlock(&dsp->pwr_lock); 224 210 if (ret) 225 211 return ret; 226 212 227 213 if (cs_ctl->flags & WMFW_CTL_FLAG_SYS) 228 214 return 0; 215 + 216 + ctl = cs_ctl->priv; 229 217 230 218 snd_ctl_notify(ctl->card, SNDRV_CTL_EVENT_MASK_VALUE, &ctl->kctl->id); 231 219 ··· 235 225 int hda_cs_dsp_read_ctl(struct cs_dsp *dsp, const char *name, int type, 236 226 unsigned int alg, void *buf, size_t len) 237 227 { 238 - struct cs_dsp_coeff_ctl *cs_ctl; 228 + int ret; 239 229 240 - cs_ctl = cs_dsp_get_ctl(dsp, name, type, alg); 241 - if (!cs_ctl) 242 - return -EINVAL; 230 + mutex_lock(&dsp->pwr_lock); 231 + ret = cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(dsp, name, type, alg), 0, buf, len); 232 + mutex_unlock(&dsp->pwr_lock); 243 233 244 - return cs_dsp_coeff_read_ctrl(cs_ctl, 0, buf, len); 234 + return ret; 235 + 245 236 } 246 237 EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_read_ctl, SND_HDA_CS_DSP_CONTROLS); 247 238
+1 -1
sound/pci/hda/hda_cs_dsp_ctl.h
··· 29 29 30 30 extern const char * const hda_cs_dsp_fw_ids[HDA_CS_DSP_NUM_FW]; 31 31 32 - int hda_cs_dsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl, struct hda_cs_dsp_ctl_info *info); 32 + void hda_cs_dsp_add_controls(struct cs_dsp *dsp, const struct hda_cs_dsp_ctl_info *info); 33 33 void hda_cs_dsp_control_remove(struct cs_dsp_coeff_ctl *cs_ctl); 34 34 int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type, 35 35 unsigned int alg, const void *buf, size_t len);
+8 -22
sound/pci/hda/patch_realtek.c
··· 4022 4022 static int alc269_suspend(struct hda_codec *codec) 4023 4023 { 4024 4024 struct alc_spec *spec = codec->spec; 4025 - int i; 4026 4025 4027 4026 if (spec->has_alc5505_dsp) 4028 4027 alc5505_dsp_suspend(codec); 4029 - 4030 - for (i = 0; i < HDA_MAX_COMPONENTS; i++) 4031 - if (spec->comps[i].suspend_hook) 4032 - spec->comps[i].suspend_hook(spec->comps[i].dev); 4033 4028 4034 4029 return alc_suspend(codec); 4035 4030 } ··· 4032 4037 static int alc269_resume(struct hda_codec *codec) 4033 4038 { 4034 4039 struct alc_spec *spec = codec->spec; 4035 - int i; 4036 4040 4037 4041 if (spec->codec_variant == ALC269_TYPE_ALC269VB) 4038 4042 alc269vb_toggle_power_output(codec, 0); ··· 4061 4067 4062 4068 if (spec->has_alc5505_dsp) 4063 4069 alc5505_dsp_resume(codec); 4064 - 4065 - for (i = 0; i < HDA_MAX_COMPONENTS; i++) 4066 - if (spec->comps[i].resume_hook) 4067 - spec->comps[i].resume_hook(spec->comps[i].dev); 4068 4070 4069 4071 return 0; 4070 4072 } ··· 6654 6664 { 6655 6665 struct hda_codec *cdc = dev_to_hda_codec(dev); 6656 6666 struct alc_spec *spec = cdc->spec; 6657 - int ret, i; 6667 + int ret; 6658 6668 6659 6669 ret = component_bind_all(dev, spec->comps); 6660 6670 if (ret) 6661 6671 return ret; 6662 - 6663 - if (snd_hdac_is_power_on(&cdc->core)) { 6664 - codec_dbg(cdc, "Resuming after bind.\n"); 6665 - for (i = 0; i < HDA_MAX_COMPONENTS; i++) 6666 - if (spec->comps[i].resume_hook) 6667 - spec->comps[i].resume_hook(spec->comps[i].dev); 6668 - } 6669 6672 6670 6673 return 0; 6671 6674 } ··· 8432 8449 [ALC285_FIXUP_ASUS_G533Z_PINS] = { 8433 8450 .type = HDA_FIXUP_PINS, 8434 8451 .v.pins = (const struct hda_pintbl[]) { 8435 - { 0x14, 0x90170120 }, 8452 + { 0x14, 0x90170152 }, /* Speaker Surround Playback Switch */ 8453 + { 0x19, 0x03a19020 }, /* Mic Boost Volume */ 8454 + { 0x1a, 0x03a11c30 }, /* Mic Boost Volume */ 8455 + { 0x1e, 0x90170151 }, /* Rear jack, IN OUT EAPD Detect */ 8456 + { 0x21, 0x03211420 }, 8436 8457 { } 8437 8458 }, 8438 - .chained = true, 8439 - .chain_id = ALC294_FIXUP_ASUS_G513_PINS, 8440 8459 }, 8441 8460 [ALC294_FIXUP_ASUS_COEF_1B] = { 8442 8461 .type = HDA_FIXUP_VERBS, ··· 9183 9198 SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC), 9184 9199 SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC), 9185 9200 SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB), 9186 - SND_PCI_QUIRK(0x1028, 0x087d, "Dell Precision 5530", ALC289_FIXUP_DUAL_SPK), 9187 9201 SND_PCI_QUIRK(0x1028, 0x08ad, "Dell WYSE AIO", ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE), 9188 9202 SND_PCI_QUIRK(0x1028, 0x08ae, "Dell WYSE NB", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE), 9189 9203 SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB), ··· 9406 9422 SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401), 9407 9423 SND_PCI_QUIRK(0x1043, 0x1c52, "ASUS Zephyrus G15 2022", ALC289_FIXUP_ASUS_GA401), 9408 9424 SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401), 9425 + SND_PCI_QUIRK(0x1043, 0x1f92, "ASUS ROG Flow X16", ALC289_FIXUP_ASUS_GA401), 9409 9426 SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2), 9410 9427 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), 9411 9428 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), ··· 9428 9443 SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE), 9429 9444 SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE), 9430 9445 SND_PCI_QUIRK(0x10ec, 0x1230, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK), 9446 + SND_PCI_QUIRK(0x10ec, 0x124c, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK), 9431 9447 SND_PCI_QUIRK(0x10ec, 0x1252, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK), 9432 9448 SND_PCI_QUIRK(0x10ec, 0x1254, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK), 9433 9449 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
+2 -1
sound/usb/card.h
··· 129 129 in a stream */ 130 130 bool implicit_fb_sync; /* syncs with implicit feedback */ 131 131 bool lowlatency_playback; /* low-latency playback mode */ 132 - bool need_setup; /* (re-)need for configure? */ 132 + bool need_setup; /* (re-)need for hw_params? */ 133 + bool need_prepare; /* (re-)need for prepare? */ 133 134 134 135 /* for hw constraints */ 135 136 const struct audioformat *cur_audiofmt;
+25 -7
sound/usb/endpoint.c
··· 32 32 unsigned char iface; 33 33 bool need_setup; 34 34 int opened; 35 + int altset; 35 36 struct list_head list; 36 37 }; 37 38 ··· 824 823 825 824 ep->implicit_fb_sync = fp->implicit_fb; 826 825 ep->need_setup = true; 826 + ep->need_prepare = true; 827 827 828 828 usb_audio_dbg(chip, " channels=%d, rate=%d, format=%s, period_bytes=%d, periods=%d, implicit_fb=%d\n", 829 829 ep->cur_channels, ep->cur_rate, ··· 901 899 int altset = set ? ep->altsetting : 0; 902 900 int err; 903 901 902 + if (ep->iface_ref->altset == altset) 903 + return 0; 904 + 904 905 usb_audio_dbg(chip, "Setting usb interface %d:%d for EP 0x%x\n", 905 906 ep->iface, altset, ep->ep_num); 906 907 err = usb_set_interface(chip->dev, ep->iface, altset); ··· 915 910 916 911 if (chip->quirk_flags & QUIRK_FLAG_IFACE_DELAY) 917 912 msleep(50); 913 + ep->iface_ref->altset = altset; 918 914 return 0; 919 915 } 920 916 ··· 953 947 /* Prepare for suspening EP, called from the main suspend handler */ 954 948 void snd_usb_endpoint_suspend(struct snd_usb_endpoint *ep) 955 949 { 956 - ep->need_setup = true; 950 + ep->need_prepare = true; 957 951 if (ep->iface_ref) 958 952 ep->iface_ref->need_setup = true; 959 953 if (ep->clock_ref) ··· 1336 1330 struct snd_usb_endpoint *ep) 1337 1331 { 1338 1332 const struct audioformat *fmt = ep->cur_audiofmt; 1339 - int err; 1333 + int err = 0; 1334 + 1335 + mutex_lock(&chip->mutex); 1336 + if (!ep->need_setup) 1337 + goto unlock; 1340 1338 1341 1339 /* release old buffers, if any */ 1342 1340 err = release_urbs(ep, false); 1343 1341 if (err < 0) 1344 - return err; 1342 + goto unlock; 1345 1343 1346 1344 ep->datainterval = fmt->datainterval; 1347 1345 ep->maxpacksize = fmt->maxpacksize; ··· 1383 1373 usb_audio_dbg(chip, "Set up %d URBS, ret=%d\n", ep->nurbs, err); 1384 1374 1385 1375 if (err < 0) 1386 - return err; 1376 + goto unlock; 1387 1377 1388 1378 /* some unit conversions in runtime */ 1389 1379 ep->maxframesize = ep->maxpacksize / ep->cur_frame_bytes; 1390 1380 ep->curframesize = ep->curpacksize / ep->cur_frame_bytes; 1391 1381 1392 - return update_clock_ref_rate(chip, ep); 1382 + err = update_clock_ref_rate(chip, ep); 1383 + if (err >= 0) { 1384 + ep->need_setup = false; 1385 + err = 0; 1386 + } 1387 + 1388 + unlock: 1389 + mutex_unlock(&chip->mutex); 1390 + return err; 1393 1391 } 1394 1392 1395 1393 static int init_sample_rate(struct snd_usb_audio *chip, ··· 1444 1426 mutex_lock(&chip->mutex); 1445 1427 if (WARN_ON(!ep->iface_ref)) 1446 1428 goto unlock; 1447 - if (!ep->need_setup) 1429 + if (!ep->need_prepare) 1448 1430 goto unlock; 1449 1431 1450 1432 /* If the interface has been already set up, just set EP parameters */ ··· 1498 1480 ep->iface_ref->need_setup = false; 1499 1481 1500 1482 done: 1501 - ep->need_setup = false; 1483 + ep->need_prepare = false; 1502 1484 err = 1; 1503 1485 1504 1486 unlock: