Skip to content

Commit 4c8ab06

Browse files
committed
Merge tag 'sound-fix-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound fixes from Takashi Iwai: "A collection of small fixes that have been gathered recently: - Two code-typo fixes in the new UMP core - A fix in jack reporting to avoid the usage of mutex - A potential data race fix in HD-audio core regmap code - A potential data race fix in PCM allocation helper code - HD-audio quirks for ASUS, Clevo and Unis machines - Constifications in FireWire drivers" * tag 'sound-fix-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: ALSA: hda/realtek: Add quirk for ASUS ROG GZ301V ALSA: jack: Fix mutex call in snd_jack_report() ALSA: seq: ump: fix typo in system_2p_ev_to_ump_midi1() ALSA: hda/realtek: Whitespace fix ALSA: hda/realtek: Add quirk for ASUS ROG G614Jx ALSA: hda/realtek: Amend G634 quirk to enable rear speakers ALSA: hda/realtek: Add quirk for ASUS ROG GA402X ALSA: hda/realtek: Add quirk for ASUS ROG GX650P ALSA: pcm: Fix potential data race at PCM memory allocation helpers ALSA: hda: fix a possible null-pointer dereference due to data race in snd_hdac_regmap_sync() ALSA: hda/realtek: Add quirks for Unis H3C Desktop B760 & Q760 ALSA: hda/realtek: Add quirk for Clevo NPx0SNx ALSA: ump: Correct wrong byte size at converting a UMP System message ALSA: fireface: make read-only const array for model names static ALSA: oxfw: make read-only const array models static
2 parents 3290bad + 5251605 commit 4c8ab06

File tree

8 files changed

+94
-26
lines changed

8 files changed

+94
-26
lines changed

sound/core/jack.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ void snd_jack_report(struct snd_jack *jack, int status)
654654
struct snd_jack_kctl *jack_kctl;
655655
unsigned int mask_bits = 0;
656656
#ifdef CONFIG_SND_JACK_INPUT_DEV
657+
struct input_dev *idev;
657658
int i;
658659
#endif
659660

@@ -670,31 +671,29 @@ void snd_jack_report(struct snd_jack *jack, int status)
670671
status & jack_kctl->mask_bits);
671672

672673
#ifdef CONFIG_SND_JACK_INPUT_DEV
673-
mutex_lock(&jack->input_dev_lock);
674-
if (!jack->input_dev) {
675-
mutex_unlock(&jack->input_dev_lock);
674+
idev = input_get_device(jack->input_dev);
675+
if (!idev)
676676
return;
677-
}
678677

679678
for (i = 0; i < ARRAY_SIZE(jack->key); i++) {
680679
int testbit = ((SND_JACK_BTN_0 >> i) & ~mask_bits);
681680

682681
if (jack->type & testbit)
683-
input_report_key(jack->input_dev, jack->key[i],
682+
input_report_key(idev, jack->key[i],
684683
status & testbit);
685684
}
686685

687686
for (i = 0; i < ARRAY_SIZE(jack_switch_types); i++) {
688687
int testbit = ((1 << i) & ~mask_bits);
689688

690689
if (jack->type & testbit)
691-
input_report_switch(jack->input_dev,
690+
input_report_switch(idev,
692691
jack_switch_types[i],
693692
status & testbit);
694693
}
695694

696-
input_sync(jack->input_dev);
697-
mutex_unlock(&jack->input_dev_lock);
695+
input_sync(idev);
696+
input_put_device(idev);
698697
#endif /* CONFIG_SND_JACK_INPUT_DEV */
699698
}
700699
EXPORT_SYMBOL(snd_jack_report);

sound/core/pcm_memory.c

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,56 @@ static unsigned long max_alloc_per_card = 32UL * 1024UL * 1024UL;
3131
module_param(max_alloc_per_card, ulong, 0644);
3232
MODULE_PARM_DESC(max_alloc_per_card, "Max total allocation bytes per card.");
3333

34+
static void __update_allocated_size(struct snd_card *card, ssize_t bytes)
35+
{
36+
card->total_pcm_alloc_bytes += bytes;
37+
}
38+
39+
static void update_allocated_size(struct snd_card *card, ssize_t bytes)
40+
{
41+
mutex_lock(&card->memory_mutex);
42+
__update_allocated_size(card, bytes);
43+
mutex_unlock(&card->memory_mutex);
44+
}
45+
46+
static void decrease_allocated_size(struct snd_card *card, size_t bytes)
47+
{
48+
mutex_lock(&card->memory_mutex);
49+
WARN_ON(card->total_pcm_alloc_bytes < bytes);
50+
__update_allocated_size(card, -(ssize_t)bytes);
51+
mutex_unlock(&card->memory_mutex);
52+
}
53+
3454
static int do_alloc_pages(struct snd_card *card, int type, struct device *dev,
3555
int str, size_t size, struct snd_dma_buffer *dmab)
3656
{
3757
enum dma_data_direction dir;
3858
int err;
3959

60+
/* check and reserve the requested size */
61+
mutex_lock(&card->memory_mutex);
4062
if (max_alloc_per_card &&
41-
card->total_pcm_alloc_bytes + size > max_alloc_per_card)
63+
card->total_pcm_alloc_bytes + size > max_alloc_per_card) {
64+
mutex_unlock(&card->memory_mutex);
4265
return -ENOMEM;
66+
}
67+
__update_allocated_size(card, size);
68+
mutex_unlock(&card->memory_mutex);
4369

4470
if (str == SNDRV_PCM_STREAM_PLAYBACK)
4571
dir = DMA_TO_DEVICE;
4672
else
4773
dir = DMA_FROM_DEVICE;
4874
err = snd_dma_alloc_dir_pages(type, dev, dir, size, dmab);
4975
if (!err) {
50-
mutex_lock(&card->memory_mutex);
51-
card->total_pcm_alloc_bytes += dmab->bytes;
52-
mutex_unlock(&card->memory_mutex);
76+
/* the actual allocation size might be bigger than requested,
77+
* and we need to correct the account
78+
*/
79+
if (dmab->bytes != size)
80+
update_allocated_size(card, dmab->bytes - size);
81+
} else {
82+
/* take back on allocation failure */
83+
decrease_allocated_size(card, size);
5384
}
5485
return err;
5586
}
@@ -58,10 +89,7 @@ static void do_free_pages(struct snd_card *card, struct snd_dma_buffer *dmab)
5889
{
5990
if (!dmab->area)
6091
return;
61-
mutex_lock(&card->memory_mutex);
62-
WARN_ON(card->total_pcm_alloc_bytes < dmab->bytes);
63-
card->total_pcm_alloc_bytes -= dmab->bytes;
64-
mutex_unlock(&card->memory_mutex);
92+
decrease_allocated_size(card, dmab->bytes);
6593
snd_dma_free_pages(dmab);
6694
dmab->area = NULL;
6795
}

sound/core/seq/seq_ump_convert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ static int system_2p_ev_to_ump_midi1(const struct snd_seq_event *event,
714714
{
715715
data->system.status = status;
716716
data->system.parm1 = (event->data.control.value >> 7) & 0x7f;
717-
data->system.parm1 = event->data.control.value & 0x7f;
717+
data->system.parm2 = event->data.control.value & 0x7f;
718718
return 1;
719719
}
720720

sound/core/ump_convert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static int cvt_ump_system_to_legacy(u32 data, unsigned char *buf)
7373
case UMP_SYSTEM_STATUS_MIDI_TIME_CODE:
7474
case UMP_SYSTEM_STATUS_SONG_SELECT:
7575
buf[1] = (data >> 8) & 0x7f;
76-
return 1;
76+
return 2;
7777
case UMP_SYSTEM_STATUS_SONG_POSITION:
7878
buf[1] = (data >> 8) & 0x7f;
7979
buf[2] = data & 0x7f;

sound/firewire/fireface/ff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ MODULE_LICENSE("GPL");
1616
static void name_card(struct snd_ff *ff)
1717
{
1818
struct fw_device *fw_dev = fw_parent_device(ff->unit);
19-
const char *const names[] = {
19+
static const char *const names[] = {
2020
[SND_FF_UNIT_VERSION_FF800] = "Fireface800",
2121
[SND_FF_UNIT_VERSION_FF400] = "Fireface400",
2222
[SND_FF_UNIT_VERSION_UFX] = "FirefaceUFX",

sound/firewire/oxfw/oxfw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct compat_info {
4444

4545
static bool detect_loud_models(struct fw_unit *unit)
4646
{
47-
const char *const models[] = {
47+
static const char *const models[] = {
4848
"Onyxi",
4949
"Onyx-i",
5050
"Onyx 1640i",

sound/hda/hdac_regmap.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,9 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw_once);
596596
*/
597597
void snd_hdac_regmap_sync(struct hdac_device *codec)
598598
{
599-
if (codec->regmap) {
600-
mutex_lock(&codec->regmap_lock);
599+
mutex_lock(&codec->regmap_lock);
600+
if (codec->regmap)
601601
regcache_sync(codec->regmap);
602-
mutex_unlock(&codec->regmap_lock);
603-
}
602+
mutex_unlock(&codec->regmap_lock);
604603
}
605604
EXPORT_SYMBOL_GPL(snd_hdac_regmap_sync);

sound/pci/hda/patch_realtek.c

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5883,7 +5883,7 @@ static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
58835883
struct alc_spec *spec = codec->spec;
58845884
spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
58855885
alc255_set_default_jack_type(codec);
5886-
}
5886+
}
58875887
else
58885888
alc_fixup_headset_mode(codec, fix, action);
58895889
}
@@ -7068,6 +7068,9 @@ enum {
70687068
ALC285_FIXUP_SPEAKER2_TO_DAC1,
70697069
ALC285_FIXUP_ASUS_SPEAKER2_TO_DAC1,
70707070
ALC285_FIXUP_ASUS_HEADSET_MIC,
7071+
ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS,
7072+
ALC285_FIXUP_ASUS_I2C_SPEAKER2_TO_DAC1,
7073+
ALC285_FIXUP_ASUS_I2C_HEADSET_MIC,
70717074
ALC280_FIXUP_HP_HEADSET_MIC,
70727075
ALC221_FIXUP_HP_FRONT_MIC,
70737076
ALC292_FIXUP_TPT460,
@@ -8058,6 +8061,31 @@ static const struct hda_fixup alc269_fixups[] = {
80588061
.chained = true,
80598062
.chain_id = ALC285_FIXUP_ASUS_SPEAKER2_TO_DAC1
80608063
},
8064+
[ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS] = {
8065+
.type = HDA_FIXUP_PINS,
8066+
.v.pins = (const struct hda_pintbl[]) {
8067+
{ 0x14, 0x90170120 },
8068+
{ }
8069+
},
8070+
.chained = true,
8071+
.chain_id = ALC285_FIXUP_ASUS_HEADSET_MIC
8072+
},
8073+
[ALC285_FIXUP_ASUS_I2C_SPEAKER2_TO_DAC1] = {
8074+
.type = HDA_FIXUP_FUNC,
8075+
.v.func = alc285_fixup_speaker2_to_dac1,
8076+
.chained = true,
8077+
.chain_id = ALC287_FIXUP_CS35L41_I2C_2
8078+
},
8079+
[ALC285_FIXUP_ASUS_I2C_HEADSET_MIC] = {
8080+
.type = HDA_FIXUP_PINS,
8081+
.v.pins = (const struct hda_pintbl[]) {
8082+
{ 0x19, 0x03a11050 },
8083+
{ 0x1b, 0x03a11c30 },
8084+
{ }
8085+
},
8086+
.chained = true,
8087+
.chain_id = ALC285_FIXUP_ASUS_I2C_SPEAKER2_TO_DAC1
8088+
},
80618089
[ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
80628090
.type = HDA_FIXUP_PINS,
80638091
.v.pins = (const struct hda_pintbl[]) {
@@ -9573,10 +9601,13 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
95739601
SND_PCI_QUIRK(0x1043, 0x1313, "Asus K42JZ", ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE),
95749602
SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC),
95759603
SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
9604+
SND_PCI_QUIRK(0x1043, 0x1433, "ASUS GX650P", ALC285_FIXUP_ASUS_I2C_HEADSET_MIC),
9605+
SND_PCI_QUIRK(0x1043, 0x1463, "Asus GA402X", ALC285_FIXUP_ASUS_I2C_HEADSET_MIC),
95769606
SND_PCI_QUIRK(0x1043, 0x1473, "ASUS GU604V", ALC285_FIXUP_ASUS_HEADSET_MIC),
95779607
SND_PCI_QUIRK(0x1043, 0x1483, "ASUS GU603V", ALC285_FIXUP_ASUS_HEADSET_MIC),
95789608
SND_PCI_QUIRK(0x1043, 0x1493, "ASUS GV601V", ALC285_FIXUP_ASUS_HEADSET_MIC),
95799609
SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
9610+
SND_PCI_QUIRK(0x1043, 0x1573, "ASUS GZ301V", ALC285_FIXUP_ASUS_HEADSET_MIC),
95809611
SND_PCI_QUIRK(0x1043, 0x1662, "ASUS GV301QH", ALC294_FIXUP_ASUS_DUAL_SPK),
95819612
SND_PCI_QUIRK(0x1043, 0x1683, "ASUS UM3402YAR", ALC287_FIXUP_CS35L41_I2C_2),
95829613
SND_PCI_QUIRK(0x1043, 0x16b2, "ASUS GU603", ALC289_FIXUP_ASUS_GA401),
@@ -9602,7 +9633,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
96029633
SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
96039634
SND_PCI_QUIRK(0x1043, 0x1c62, "ASUS GU603", ALC289_FIXUP_ASUS_GA401),
96049635
SND_PCI_QUIRK(0x1043, 0x1c92, "ASUS ROG Strix G15", ALC285_FIXUP_ASUS_G533Z_PINS),
9605-
SND_PCI_QUIRK(0x1043, 0x1caf, "ASUS G634JYR/JZR", ALC285_FIXUP_ASUS_HEADSET_MIC),
9636+
SND_PCI_QUIRK(0x1043, 0x1c9f, "ASUS G614JI", ALC285_FIXUP_ASUS_HEADSET_MIC),
9637+
SND_PCI_QUIRK(0x1043, 0x1caf, "ASUS G634JYR/JZR", ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS),
96069638
SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
96079639
SND_PCI_QUIRK(0x1043, 0x1d42, "ASUS Zephyrus G14 2022", ALC289_FIXUP_ASUS_GA401),
96089640
SND_PCI_QUIRK(0x1043, 0x1d4e, "ASUS TM420", ALC256_FIXUP_ASUS_HPE),
@@ -9731,6 +9763,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
97319763
SND_PCI_QUIRK(0x1558, 0x971d, "Clevo N970T[CDF]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
97329764
SND_PCI_QUIRK(0x1558, 0xa500, "Clevo NL5[03]RU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
97339765
SND_PCI_QUIRK(0x1558, 0xa600, "Clevo NL50NU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
9766+
SND_PCI_QUIRK(0x1558, 0xa650, "Clevo NP[567]0SN[CD]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
97349767
SND_PCI_QUIRK(0x1558, 0xa671, "Clevo NP70SN[CDE]", ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
97359768
SND_PCI_QUIRK(0x1558, 0xb018, "Clevo NP50D[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
97369769
SND_PCI_QUIRK(0x1558, 0xb019, "Clevo NH77D[BE]Q", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
@@ -11286,6 +11319,7 @@ enum {
1128611319
ALC897_FIXUP_HP_HSMIC_VERB,
1128711320
ALC897_FIXUP_LENOVO_HEADSET_MODE,
1128811321
ALC897_FIXUP_HEADSET_MIC_PIN2,
11322+
ALC897_FIXUP_UNIS_H3C_X500S,
1128911323
};
1129011324

1129111325
static const struct hda_fixup alc662_fixups[] = {
@@ -11725,6 +11759,13 @@ static const struct hda_fixup alc662_fixups[] = {
1172511759
.chained = true,
1172611760
.chain_id = ALC897_FIXUP_LENOVO_HEADSET_MODE
1172711761
},
11762+
[ALC897_FIXUP_UNIS_H3C_X500S] = {
11763+
.type = HDA_FIXUP_VERBS,
11764+
.v.verbs = (const struct hda_verb[]) {
11765+
{ 0x14, AC_VERB_SET_EAPD_BTLENABLE, 0 },
11766+
{}
11767+
},
11768+
},
1172811769
};
1172911770

1173011771
static const struct snd_pci_quirk alc662_fixup_tbl[] = {
@@ -11886,6 +11927,7 @@ static const struct hda_model_fixup alc662_fixup_models[] = {
1188611927
{.id = ALC662_FIXUP_USI_HEADSET_MODE, .name = "usi-headset"},
1188711928
{.id = ALC662_FIXUP_LENOVO_MULTI_CODECS, .name = "dual-codecs"},
1188811929
{.id = ALC669_FIXUP_ACER_ASPIRE_ETHOS, .name = "aspire-ethos"},
11930+
{.id = ALC897_FIXUP_UNIS_H3C_X500S, .name = "unis-h3c-x500s"},
1188911931
{}
1189011932
};
1189111933

0 commit comments

Comments
 (0)