Skip to content

Commit dfbab3f

Browse files
committed
Merge tag 'sound-4.16-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound fixes from Takashi Iwai: "Two type of fixes: - The usual stuff, a handful HD-audio quirks for various machines - Further hardening against ALSA sequencer ioctl/write races that are triggered by fuzzer" * tag 'sound-4.16-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: ALSA: hda: add dock and led support for HP ProBook 640 G2 ALSA: hda: add dock and led support for HP EliteBook 820 G3 ALSA: hda/realtek - Make dock sound work on ThinkPad L570 ALSA: seq: Remove superfluous snd_seq_queue_client_leave_cells() call ALSA: seq: More protection for concurrent write and ioctl races ALSA: seq: Don't allow resizing pool in use ALSA: hda/realtek - Fix dock line-out volume on Dell Precision 7520 ALSA: hda/realtek: Limit mic boost on T480 ALSA: hda/realtek - Add headset mode support for Dell laptop ALSA: hda/realtek - Add support headset mode for DELL WYSE ALSA: hda - Fix a wrong FIXUP for alc289 on Dell machines
2 parents 719ea86 + 099fd6c commit dfbab3f

File tree

6 files changed

+73
-15
lines changed

6 files changed

+73
-15
lines changed

sound/core/seq/seq_clientmgr.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,8 @@ int snd_seq_dispatch_event(struct snd_seq_event_cell *cell, int atomic, int hop)
910910
static int snd_seq_client_enqueue_event(struct snd_seq_client *client,
911911
struct snd_seq_event *event,
912912
struct file *file, int blocking,
913-
int atomic, int hop)
913+
int atomic, int hop,
914+
struct mutex *mutexp)
914915
{
915916
struct snd_seq_event_cell *cell;
916917
int err;
@@ -948,7 +949,8 @@ static int snd_seq_client_enqueue_event(struct snd_seq_client *client,
948949
return -ENXIO; /* queue is not allocated */
949950

950951
/* allocate an event cell */
951-
err = snd_seq_event_dup(client->pool, event, &cell, !blocking || atomic, file);
952+
err = snd_seq_event_dup(client->pool, event, &cell, !blocking || atomic,
953+
file, mutexp);
952954
if (err < 0)
953955
return err;
954956

@@ -1017,12 +1019,11 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf,
10171019
return -ENXIO;
10181020

10191021
/* allocate the pool now if the pool is not allocated yet */
1022+
mutex_lock(&client->ioctl_mutex);
10201023
if (client->pool->size > 0 && !snd_seq_write_pool_allocated(client)) {
1021-
mutex_lock(&client->ioctl_mutex);
10221024
err = snd_seq_pool_init(client->pool);
1023-
mutex_unlock(&client->ioctl_mutex);
10241025
if (err < 0)
1025-
return -ENOMEM;
1026+
goto out;
10261027
}
10271028

10281029
/* only process whole events */
@@ -1073,7 +1074,7 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf,
10731074
/* ok, enqueue it */
10741075
err = snd_seq_client_enqueue_event(client, &event, file,
10751076
!(file->f_flags & O_NONBLOCK),
1076-
0, 0);
1077+
0, 0, &client->ioctl_mutex);
10771078
if (err < 0)
10781079
break;
10791080

@@ -1084,6 +1085,8 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf,
10841085
written += len;
10851086
}
10861087

1088+
out:
1089+
mutex_unlock(&client->ioctl_mutex);
10871090
return written ? written : err;
10881091
}
10891092

@@ -1838,9 +1841,11 @@ static int snd_seq_ioctl_set_client_pool(struct snd_seq_client *client,
18381841
(! snd_seq_write_pool_allocated(client) ||
18391842
info->output_pool != client->pool->size)) {
18401843
if (snd_seq_write_pool_allocated(client)) {
1844+
/* is the pool in use? */
1845+
if (atomic_read(&client->pool->counter))
1846+
return -EBUSY;
18411847
/* remove all existing cells */
18421848
snd_seq_pool_mark_closing(client->pool);
1843-
snd_seq_queue_client_leave_cells(client->number);
18441849
snd_seq_pool_done(client->pool);
18451850
}
18461851
client->pool->size = info->output_pool;
@@ -2260,7 +2265,8 @@ static int kernel_client_enqueue(int client, struct snd_seq_event *ev,
22602265
if (! cptr->accept_output)
22612266
result = -EPERM;
22622267
else /* send it */
2263-
result = snd_seq_client_enqueue_event(cptr, ev, file, blocking, atomic, hop);
2268+
result = snd_seq_client_enqueue_event(cptr, ev, file, blocking,
2269+
atomic, hop, NULL);
22642270

22652271
snd_seq_client_unlock(cptr);
22662272
return result;

sound/core/seq/seq_fifo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ int snd_seq_fifo_event_in(struct snd_seq_fifo *f,
125125
return -EINVAL;
126126

127127
snd_use_lock_use(&f->use_lock);
128-
err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL); /* always non-blocking */
128+
err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL, NULL); /* always non-blocking */
129129
if (err < 0) {
130130
if ((err == -ENOMEM) || (err == -EAGAIN))
131131
atomic_inc(&f->overflow);

sound/core/seq/seq_memory.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ void snd_seq_cell_free(struct snd_seq_event_cell * cell)
220220
*/
221221
static int snd_seq_cell_alloc(struct snd_seq_pool *pool,
222222
struct snd_seq_event_cell **cellp,
223-
int nonblock, struct file *file)
223+
int nonblock, struct file *file,
224+
struct mutex *mutexp)
224225
{
225226
struct snd_seq_event_cell *cell;
226227
unsigned long flags;
@@ -244,7 +245,11 @@ static int snd_seq_cell_alloc(struct snd_seq_pool *pool,
244245
set_current_state(TASK_INTERRUPTIBLE);
245246
add_wait_queue(&pool->output_sleep, &wait);
246247
spin_unlock_irq(&pool->lock);
248+
if (mutexp)
249+
mutex_unlock(mutexp);
247250
schedule();
251+
if (mutexp)
252+
mutex_lock(mutexp);
248253
spin_lock_irq(&pool->lock);
249254
remove_wait_queue(&pool->output_sleep, &wait);
250255
/* interrupted? */
@@ -287,7 +292,7 @@ static int snd_seq_cell_alloc(struct snd_seq_pool *pool,
287292
*/
288293
int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event,
289294
struct snd_seq_event_cell **cellp, int nonblock,
290-
struct file *file)
295+
struct file *file, struct mutex *mutexp)
291296
{
292297
int ncells, err;
293298
unsigned int extlen;
@@ -304,7 +309,7 @@ int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event,
304309
if (ncells >= pool->total_elements)
305310
return -ENOMEM;
306311

307-
err = snd_seq_cell_alloc(pool, &cell, nonblock, file);
312+
err = snd_seq_cell_alloc(pool, &cell, nonblock, file, mutexp);
308313
if (err < 0)
309314
return err;
310315

@@ -330,7 +335,8 @@ int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event,
330335
int size = sizeof(struct snd_seq_event);
331336
if (len < size)
332337
size = len;
333-
err = snd_seq_cell_alloc(pool, &tmp, nonblock, file);
338+
err = snd_seq_cell_alloc(pool, &tmp, nonblock, file,
339+
mutexp);
334340
if (err < 0)
335341
goto __error;
336342
if (cell->event.data.ext.ptr == NULL)

sound/core/seq/seq_memory.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ struct snd_seq_pool {
6666
void snd_seq_cell_free(struct snd_seq_event_cell *cell);
6767

6868
int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event,
69-
struct snd_seq_event_cell **cellp, int nonblock, struct file *file);
69+
struct snd_seq_event_cell **cellp, int nonblock,
70+
struct file *file, struct mutex *mutexp);
7071

7172
/* return number of unused (free) cells */
7273
static inline int snd_seq_unused_cells(struct snd_seq_pool *pool)

sound/pci/hda/patch_conexant.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,8 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
957957
SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_ASPIRE_DMIC),
958958
SND_PCI_QUIRK(0x1025, 0x054f, "Acer Aspire 4830T", CXT_FIXUP_ASPIRE_DMIC),
959959
SND_PCI_QUIRK(0x103c, 0x8079, "HP EliteBook 840 G3", CXT_FIXUP_HP_DOCK),
960+
SND_PCI_QUIRK(0x103c, 0x807C, "HP EliteBook 820 G3", CXT_FIXUP_HP_DOCK),
961+
SND_PCI_QUIRK(0x103c, 0x80FD, "HP ProBook 640 G2", CXT_FIXUP_HP_DOCK),
960962
SND_PCI_QUIRK(0x103c, 0x8174, "HP Spectre x360", CXT_FIXUP_HP_SPECTRE),
961963
SND_PCI_QUIRK(0x103c, 0x8115, "HP Z1 Gen3", CXT_FIXUP_HP_GATE_MIC),
962964
SND_PCI_QUIRK(0x103c, 0x814f, "HP ZBook 15u G3", CXT_FIXUP_MUTE_LED_GPIO),

sound/pci/hda/patch_realtek.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5274,6 +5274,16 @@ static void alc298_fixup_speaker_volume(struct hda_codec *codec,
52745274
}
52755275
}
52765276

5277+
/* disable DAC3 (0x06) selection on NID 0x17 as it has no volume amp control */
5278+
static void alc295_fixup_disable_dac3(struct hda_codec *codec,
5279+
const struct hda_fixup *fix, int action)
5280+
{
5281+
if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5282+
hda_nid_t conn[2] = { 0x02, 0x03 };
5283+
snd_hda_override_conn_list(codec, 0x17, 2, conn);
5284+
}
5285+
}
5286+
52775287
/* Hook to update amp GPIO4 for automute */
52785288
static void alc280_hp_gpio4_automute_hook(struct hda_codec *codec,
52795289
struct hda_jack_callback *jack)
@@ -5466,6 +5476,7 @@ enum {
54665476
ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
54675477
ALC255_FIXUP_DELL_SPK_NOISE,
54685478
ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
5479+
ALC295_FIXUP_DISABLE_DAC3,
54695480
ALC280_FIXUP_HP_HEADSET_MIC,
54705481
ALC221_FIXUP_HP_FRONT_MIC,
54715482
ALC292_FIXUP_TPT460,
@@ -5480,10 +5491,12 @@ enum {
54805491
ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE,
54815492
ALC233_FIXUP_LENOVO_MULTI_CODECS,
54825493
ALC294_FIXUP_LENOVO_MIC_LOCATION,
5494+
ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
54835495
ALC700_FIXUP_INTEL_REFERENCE,
54845496
ALC274_FIXUP_DELL_BIND_DACS,
54855497
ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
54865498
ALC298_FIXUP_TPT470_DOCK,
5499+
ALC255_FIXUP_DUMMY_LINEOUT_VERB,
54875500
};
54885501

54895502
static const struct hda_fixup alc269_fixups[] = {
@@ -6198,6 +6211,10 @@ static const struct hda_fixup alc269_fixups[] = {
61986211
.chained = true,
61996212
.chain_id = ALC298_FIXUP_DELL_AIO_MIC_NO_PRESENCE,
62006213
},
6214+
[ALC295_FIXUP_DISABLE_DAC3] = {
6215+
.type = HDA_FIXUP_FUNC,
6216+
.v.func = alc295_fixup_disable_dac3,
6217+
},
62016218
[ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER] = {
62026219
.type = HDA_FIXUP_PINS,
62036220
.v.pins = (const struct hda_pintbl[]) {
@@ -6283,6 +6300,18 @@ static const struct hda_fixup alc269_fixups[] = {
62836300
{ }
62846301
},
62856302
},
6303+
[ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE] = {
6304+
.type = HDA_FIXUP_PINS,
6305+
.v.pins = (const struct hda_pintbl[]) {
6306+
{ 0x16, 0x0101102f }, /* Rear Headset HP */
6307+
{ 0x19, 0x02a1913c }, /* use as Front headset mic, without its own jack detect */
6308+
{ 0x1a, 0x01a19030 }, /* Rear Headset MIC */
6309+
{ 0x1b, 0x02011020 },
6310+
{ }
6311+
},
6312+
.chained = true,
6313+
.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
6314+
},
62866315
[ALC700_FIXUP_INTEL_REFERENCE] = {
62876316
.type = HDA_FIXUP_VERBS,
62886317
.v.verbs = (const struct hda_verb[]) {
@@ -6319,6 +6348,15 @@ static const struct hda_fixup alc269_fixups[] = {
63196348
.chained = true,
63206349
.chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE
63216350
},
6351+
[ALC255_FIXUP_DUMMY_LINEOUT_VERB] = {
6352+
.type = HDA_FIXUP_PINS,
6353+
.v.pins = (const struct hda_pintbl[]) {
6354+
{ 0x14, 0x0201101f },
6355+
{ }
6356+
},
6357+
.chained = true,
6358+
.chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
6359+
},
63226360
};
63236361

63246362
static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -6367,10 +6405,13 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
63676405
SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
63686406
SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
63696407
SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
6408+
SND_PCI_QUIRK(0x1028, 0x07b0, "Dell Precision 7520", ALC295_FIXUP_DISABLE_DAC3),
63706409
SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
6410+
SND_PCI_QUIRK(0x1028, 0x080c, "Dell WYSE", ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE),
63716411
SND_PCI_QUIRK(0x1028, 0x082a, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
63726412
SND_PCI_QUIRK(0x1028, 0x084b, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
63736413
SND_PCI_QUIRK(0x1028, 0x084e, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB),
6414+
SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB),
63746415
SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
63756416
SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
63766417
SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
@@ -6508,9 +6549,11 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
65086549
SND_PCI_QUIRK(0x17aa, 0x2245, "Thinkpad T470", ALC298_FIXUP_TPT470_DOCK),
65096550
SND_PCI_QUIRK(0x17aa, 0x2246, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
65106551
SND_PCI_QUIRK(0x17aa, 0x2247, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6552+
SND_PCI_QUIRK(0x17aa, 0x2249, "Thinkpad", ALC292_FIXUP_TPT460),
65116553
SND_PCI_QUIRK(0x17aa, 0x224b, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
65126554
SND_PCI_QUIRK(0x17aa, 0x224c, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
65136555
SND_PCI_QUIRK(0x17aa, 0x224d, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
6556+
SND_PCI_QUIRK(0x17aa, 0x225d, "Thinkpad T480", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
65146557
SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
65156558
SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
65166559
SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
@@ -6872,7 +6915,7 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
68726915
{0x12, 0x90a60120},
68736916
{0x14, 0x90170110},
68746917
{0x21, 0x0321101f}),
6875-
SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
6918+
SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
68766919
{0x12, 0xb7a60130},
68776920
{0x14, 0x90170110},
68786921
{0x21, 0x04211020}),

0 commit comments

Comments
 (0)