Skip to content

Commit c8a6552

Browse files
committed
Merge tag 'sound-5.7-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound fixes from Takashi Iwai: "One significant regression fix is for HD-audio buffer preallocation. In 5.6 it was set to non-prompt for x86 and forced to 0, but this turned out to be problematic for some applications, hence it gets reverted. Distros would need to restore CONFIG_SND_HDA_PREALLOC_SIZE value to the earlier values they've used in the past. Other than that, we've received quite a few small fixes for HD-audio and USB-audio. Most of them are for dealing with the broken TRX40 mobos and the runtime PM without HD-audio codecs" * tag 'sound-5.7-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: ALSA: hda: call runtime_allow() for all hda controllers ALSA: hda: Allow setting preallocation again for x86 ALSA: hda: Explicitly permit using autosuspend if runtime PM is supported ALSA: hda: Skip controller resume if not needed ALSA: hda: Keep the controller initialization even if no codecs found ALSA: hda: Release resources at error in delayed probe ALSA: hda: Honor PM disablement in PM freeze and thaw_noirq ops ALSA: hda: Don't release card at firmware loading error ALSA: usb-audio: Check mapping at creating connector controls, too ALSA: usb-audio: Don't create jack controls for PCM terminals ALSA: usb-audio: Don't override ignore_ctl_error value from the map ALSA: usb-audio: Filter error from connector kctl ops, too ALSA: hda/realtek - Enable the headset mic on Asus FX505DT ALSA: ctxfi: Remove unnecessary cast in kfree
2 parents 7a56db0 + 9a64184 commit c8a6552

File tree

9 files changed

+104
-68
lines changed

9 files changed

+104
-68
lines changed

include/sound/hda_codec.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,11 @@ void snd_hda_update_power_acct(struct hda_codec *codec);
494494
static inline void snd_hda_set_power_save(struct hda_bus *bus, int delay) {}
495495
#endif
496496

497+
static inline bool hda_codec_need_resume(struct hda_codec *codec)
498+
{
499+
return !codec->relaxed_resume && codec->jacktbl.used;
500+
}
501+
497502
#ifdef CONFIG_SND_HDA_PATCH_LOADER
498503
/*
499504
* patch firmware

sound/hda/Kconfig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@ config SND_HDA_EXT_CORE
2121
select SND_HDA_CORE
2222

2323
config SND_HDA_PREALLOC_SIZE
24-
int "Pre-allocated buffer size for HD-audio driver" if !SND_DMA_SGBUF
24+
int "Pre-allocated buffer size for HD-audio driver"
2525
range 0 32768
26-
default 0 if SND_DMA_SGBUF
26+
default 2048 if SND_DMA_SGBUF
2727
default 64 if !SND_DMA_SGBUF
2828
help
2929
Specifies the default pre-allocated buffer-size in kB for the
3030
HD-audio driver. A larger buffer (e.g. 2048) is preferred
3131
for systems using PulseAudio. The default 64 is chosen just
3232
for compatibility reasons.
33-
On x86 systems, the default is zero as we need no preallocation.
33+
On x86 systems, the default is 2048 as a reasonable value for
34+
most of modern systems.
3435

3536
Note that the pre-allocation size can be changed dynamically
3637
via a proc file (/proc/asound/card*/pcm*/sub*/prealloc), too.

sound/pci/ctxfi/cthw20k1.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static int src_get_rsc_ctrl_blk(void **rblk)
168168

169169
static int src_put_rsc_ctrl_blk(void *blk)
170170
{
171-
kfree((struct src_rsc_ctrl_blk *)blk);
171+
kfree(blk);
172172

173173
return 0;
174174
}
@@ -494,7 +494,7 @@ static int src_mgr_get_ctrl_blk(void **rblk)
494494

495495
static int src_mgr_put_ctrl_blk(void *blk)
496496
{
497-
kfree((struct src_mgr_ctrl_blk *)blk);
497+
kfree(blk);
498498

499499
return 0;
500500
}
@@ -515,7 +515,7 @@ static int srcimp_mgr_get_ctrl_blk(void **rblk)
515515

516516
static int srcimp_mgr_put_ctrl_blk(void *blk)
517517
{
518-
kfree((struct srcimp_mgr_ctrl_blk *)blk);
518+
kfree(blk);
519519

520520
return 0;
521521
}
@@ -702,7 +702,7 @@ static int amixer_rsc_get_ctrl_blk(void **rblk)
702702

703703
static int amixer_rsc_put_ctrl_blk(void *blk)
704704
{
705-
kfree((struct amixer_rsc_ctrl_blk *)blk);
705+
kfree(blk);
706706

707707
return 0;
708708
}
@@ -909,7 +909,7 @@ static int dai_get_ctrl_blk(void **rblk)
909909

910910
static int dai_put_ctrl_blk(void *blk)
911911
{
912-
kfree((struct dai_ctrl_blk *)blk);
912+
kfree(blk);
913913

914914
return 0;
915915
}
@@ -958,7 +958,7 @@ static int dao_get_ctrl_blk(void **rblk)
958958

959959
static int dao_put_ctrl_blk(void *blk)
960960
{
961-
kfree((struct dao_ctrl_blk *)blk);
961+
kfree(blk);
962962

963963
return 0;
964964
}
@@ -1156,7 +1156,7 @@ static int daio_mgr_get_ctrl_blk(struct hw *hw, void **rblk)
11561156

11571157
static int daio_mgr_put_ctrl_blk(void *blk)
11581158
{
1159-
kfree((struct daio_mgr_ctrl_blk *)blk);
1159+
kfree(blk);
11601160

11611161
return 0;
11621162
}

sound/pci/hda/hda_codec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2951,7 +2951,7 @@ static int hda_codec_runtime_resume(struct device *dev)
29512951
static int hda_codec_force_resume(struct device *dev)
29522952
{
29532953
struct hda_codec *codec = dev_to_hda_codec(dev);
2954-
bool forced_resume = !codec->relaxed_resume && codec->jacktbl.used;
2954+
bool forced_resume = hda_codec_need_resume(codec);
29552955
int ret;
29562956

29572957
/* The get/put pair below enforces the runtime resume even if the

sound/pci/hda/hda_intel.c

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ static int azx_suspend(struct device *dev)
10271027
chip = card->private_data;
10281028
bus = azx_bus(chip);
10291029
snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1030-
__azx_runtime_suspend(chip);
1030+
pm_runtime_force_suspend(dev);
10311031
if (bus->irq >= 0) {
10321032
free_irq(bus->irq, chip);
10331033
bus->irq = -1;
@@ -1044,7 +1044,9 @@ static int azx_suspend(struct device *dev)
10441044
static int azx_resume(struct device *dev)
10451045
{
10461046
struct snd_card *card = dev_get_drvdata(dev);
1047+
struct hda_codec *codec;
10471048
struct azx *chip;
1049+
bool forced_resume = false;
10481050

10491051
if (!azx_is_pm_ready(card))
10501052
return 0;
@@ -1055,7 +1057,20 @@ static int azx_resume(struct device *dev)
10551057
chip->msi = 0;
10561058
if (azx_acquire_irq(chip, 1) < 0)
10571059
return -EIO;
1058-
__azx_runtime_resume(chip, false);
1060+
1061+
/* check for the forced resume */
1062+
list_for_each_codec(codec, &chip->bus) {
1063+
if (hda_codec_need_resume(codec)) {
1064+
forced_resume = true;
1065+
break;
1066+
}
1067+
}
1068+
1069+
if (forced_resume)
1070+
pm_runtime_get_noresume(dev);
1071+
pm_runtime_force_resume(dev);
1072+
if (forced_resume)
1073+
pm_runtime_put(dev);
10591074
snd_power_change_state(card, SNDRV_CTL_POWER_D0);
10601075

10611076
trace_azx_resume(chip);
@@ -1071,6 +1086,8 @@ static int azx_freeze_noirq(struct device *dev)
10711086
struct azx *chip = card->private_data;
10721087
struct pci_dev *pci = to_pci_dev(dev);
10731088

1089+
if (!azx_is_pm_ready(card))
1090+
return 0;
10741091
if (chip->driver_type == AZX_DRIVER_SKL)
10751092
pci_set_power_state(pci, PCI_D3hot);
10761093

@@ -1083,6 +1100,8 @@ static int azx_thaw_noirq(struct device *dev)
10831100
struct azx *chip = card->private_data;
10841101
struct pci_dev *pci = to_pci_dev(dev);
10851102

1103+
if (!azx_is_pm_ready(card))
1104+
return 0;
10861105
if (chip->driver_type == AZX_DRIVER_SKL)
10871106
pci_set_power_state(pci, PCI_D0);
10881107

@@ -1098,12 +1117,12 @@ static int azx_runtime_suspend(struct device *dev)
10981117
if (!azx_is_pm_ready(card))
10991118
return 0;
11001119
chip = card->private_data;
1101-
if (!azx_has_pm_runtime(chip))
1102-
return 0;
11031120

11041121
/* enable controller wake up event */
1105-
azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) |
1106-
STATESTS_INT_MASK);
1122+
if (snd_power_get_state(card) == SNDRV_CTL_POWER_D0) {
1123+
azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) |
1124+
STATESTS_INT_MASK);
1125+
}
11071126

11081127
__azx_runtime_suspend(chip);
11091128
trace_azx_runtime_suspend(chip);
@@ -1114,17 +1133,18 @@ static int azx_runtime_resume(struct device *dev)
11141133
{
11151134
struct snd_card *card = dev_get_drvdata(dev);
11161135
struct azx *chip;
1136+
bool from_rt = snd_power_get_state(card) == SNDRV_CTL_POWER_D0;
11171137

11181138
if (!azx_is_pm_ready(card))
11191139
return 0;
11201140
chip = card->private_data;
1121-
if (!azx_has_pm_runtime(chip))
1122-
return 0;
1123-
__azx_runtime_resume(chip, true);
1141+
__azx_runtime_resume(chip, from_rt);
11241142

11251143
/* disable controller Wake Up event*/
1126-
azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) &
1127-
~STATESTS_INT_MASK);
1144+
if (from_rt) {
1145+
azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) &
1146+
~STATESTS_INT_MASK);
1147+
}
11281148

11291149
trace_azx_runtime_resume(chip);
11301150
return 0;
@@ -1199,10 +1219,8 @@ static void azx_vs_set_state(struct pci_dev *pci,
11991219
if (!disabled) {
12001220
dev_info(chip->card->dev,
12011221
"Start delayed initialization\n");
1202-
if (azx_probe_continue(chip) < 0) {
1222+
if (azx_probe_continue(chip) < 0)
12031223
dev_err(chip->card->dev, "initialization error\n");
1204-
hda->init_failed = true;
1205-
}
12061224
}
12071225
} else {
12081226
dev_info(chip->card->dev, "%s via vga_switcheroo\n",
@@ -1335,12 +1353,15 @@ static int register_vga_switcheroo(struct azx *chip)
13351353
/*
13361354
* destructor
13371355
*/
1338-
static int azx_free(struct azx *chip)
1356+
static void azx_free(struct azx *chip)
13391357
{
13401358
struct pci_dev *pci = chip->pci;
13411359
struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
13421360
struct hdac_bus *bus = azx_bus(chip);
13431361

1362+
if (hda->freed)
1363+
return;
1364+
13441365
if (azx_has_pm_runtime(chip) && chip->running)
13451366
pm_runtime_get_noresume(&pci->dev);
13461367
chip->running = 0;
@@ -1384,9 +1405,8 @@ static int azx_free(struct azx *chip)
13841405

13851406
if (chip->driver_caps & AZX_DCAPS_I915_COMPONENT)
13861407
snd_hdac_i915_exit(bus);
1387-
kfree(hda);
13881408

1389-
return 0;
1409+
hda->freed = 1;
13901410
}
13911411

13921412
static int azx_dev_disconnect(struct snd_device *device)
@@ -1402,7 +1422,8 @@ static int azx_dev_disconnect(struct snd_device *device)
14021422

14031423
static int azx_dev_free(struct snd_device *device)
14041424
{
1405-
return azx_free(device->device_data);
1425+
azx_free(device->device_data);
1426+
return 0;
14061427
}
14071428

14081429
#ifdef SUPPORT_VGA_SWITCHEROO
@@ -1769,7 +1790,7 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
17691790
if (err < 0)
17701791
return err;
17711792

1772-
hda = kzalloc(sizeof(*hda), GFP_KERNEL);
1793+
hda = devm_kzalloc(&pci->dev, sizeof(*hda), GFP_KERNEL);
17731794
if (!hda) {
17741795
pci_disable_device(pci);
17751796
return -ENOMEM;
@@ -1810,7 +1831,6 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
18101831

18111832
err = azx_bus_init(chip, model[dev]);
18121833
if (err < 0) {
1813-
kfree(hda);
18141834
pci_disable_device(pci);
18151835
return err;
18161836
}
@@ -2005,7 +2025,7 @@ static int azx_first_init(struct azx *chip)
20052025
/* codec detection */
20062026
if (!azx_bus(chip)->codec_mask) {
20072027
dev_err(card->dev, "no codecs found!\n");
2008-
return -ENODEV;
2028+
/* keep running the rest for the runtime PM */
20092029
}
20102030

20112031
if (azx_acquire_irq(chip, 0) < 0)
@@ -2027,24 +2047,15 @@ static void azx_firmware_cb(const struct firmware *fw, void *context)
20272047
{
20282048
struct snd_card *card = context;
20292049
struct azx *chip = card->private_data;
2030-
struct pci_dev *pci = chip->pci;
2031-
2032-
if (!fw) {
2033-
dev_err(card->dev, "Cannot load firmware, aborting\n");
2034-
goto error;
2035-
}
20362050

2037-
chip->fw = fw;
2051+
if (fw)
2052+
chip->fw = fw;
2053+
else
2054+
dev_err(card->dev, "Cannot load firmware, continue without patching\n");
20382055
if (!chip->disabled) {
20392056
/* continue probing */
2040-
if (azx_probe_continue(chip))
2041-
goto error;
2057+
azx_probe_continue(chip);
20422058
}
2043-
return; /* OK */
2044-
2045-
error:
2046-
snd_card_free(card);
2047-
pci_set_drvdata(pci, NULL);
20482059
}
20492060
#endif
20502061

@@ -2308,9 +2319,11 @@ static int azx_probe_continue(struct azx *chip)
23082319
#endif
23092320

23102321
/* create codec instances */
2311-
err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]);
2312-
if (err < 0)
2313-
goto out_free;
2322+
if (bus->codec_mask) {
2323+
err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]);
2324+
if (err < 0)
2325+
goto out_free;
2326+
}
23142327

23152328
#ifdef CONFIG_SND_HDA_PATCH_LOADER
23162329
if (chip->fw) {
@@ -2324,7 +2337,7 @@ static int azx_probe_continue(struct azx *chip)
23242337
#endif
23252338
}
23262339
#endif
2327-
if ((probe_only[dev] & 1) == 0) {
2340+
if (bus->codec_mask && !(probe_only[dev] & 1)) {
23282341
err = azx_codec_configure(chip);
23292342
if (err < 0)
23302343
goto out_free;
@@ -2341,17 +2354,23 @@ static int azx_probe_continue(struct azx *chip)
23412354

23422355
set_default_power_save(chip);
23432356

2344-
if (azx_has_pm_runtime(chip))
2357+
if (azx_has_pm_runtime(chip)) {
2358+
pm_runtime_use_autosuspend(&pci->dev);
2359+
pm_runtime_allow(&pci->dev);
23452360
pm_runtime_put_autosuspend(&pci->dev);
2361+
}
23462362

23472363
out_free:
2348-
if (err < 0 || !hda->need_i915_power)
2364+
if (err < 0) {
2365+
azx_free(chip);
2366+
return err;
2367+
}
2368+
2369+
if (!hda->need_i915_power)
23492370
display_power(chip, false);
2350-
if (err < 0)
2351-
hda->init_failed = 1;
23522371
complete_all(&hda->probe_wait);
23532372
to_hda_bus(bus)->bus_probing = 0;
2354-
return err;
2373+
return 0;
23552374
}
23562375

23572376
static void azx_remove(struct pci_dev *pci)

sound/pci/hda/hda_intel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct hda_intel {
2727
unsigned int use_vga_switcheroo:1;
2828
unsigned int vga_switcheroo_registered:1;
2929
unsigned int init_failed:1; /* delayed init failed */
30+
unsigned int freed:1; /* resources already released */
3031

3132
bool need_i915_power:1; /* the hda controller needs i915 power */
3233
};

sound/pci/hda/patch_realtek.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7378,6 +7378,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
73787378
SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
73797379
SND_PCI_QUIRK(0x1043, 0x17d1, "ASUS UX431FL", ALC294_FIXUP_ASUS_DUAL_SPK),
73807380
SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC),
7381+
SND_PCI_QUIRK(0x1043, 0x18f1, "Asus FX505DT", ALC256_FIXUP_ASUS_HEADSET_MIC),
73817382
SND_PCI_QUIRK(0x1043, 0x19ce, "ASUS B9450FA", ALC294_FIXUP_ASUS_HPE),
73827383
SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
73837384
SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),

0 commit comments

Comments
 (0)