Skip to content

Commit 1742bcd

Browse files
committed
Merge tag 'sound-5.7-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound fixes from Takashi Iwai: "Things look good and calming down; the only change to ALSA core is the fix for racy rawmidi buffer accesses spotted by syzkaller, and the rest are all small device-specific quirks for HD-audio and USB-audio devices" * tag 'sound-5.7-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: ALSA: hda/realtek - Limit int mic boost for Thinkpad T530 ALSA: hda/realtek - Add COEF workaround for ASUS ZenBook UX431DA ALSA: hda/realtek: Enable headset mic of ASUS UX581LV with ALC295 ALSA: hda/realtek - Enable headset mic of ASUS UX550GE with ALC295 ALSA: hda/realtek - Enable headset mic of ASUS GL503VM with ALC295 ALSA: hda/realtek: Add quirk for Samsung Notebook ALSA: rawmidi: Fix racy buffer resize under concurrent accesses ALSA: usb-audio: add mapping for ASRock TRX40 Creator ALSA: hda/realtek - Fix S3 pop noise on Dell Wyse Revert "ALSA: hda/realtek: Fix pop noise on ALC225" ALSA: firewire-lib: fix 'function sizeof not defined' error of tracepoints format ALSA: usb-audio: Add control message quirk delay for Kingston HyperX headset
2 parents e7cea79 + b590b38 commit 1742bcd

File tree

7 files changed

+111
-13
lines changed

7 files changed

+111
-13
lines changed

include/sound/rawmidi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ struct snd_rawmidi_runtime {
6161
size_t avail_min; /* min avail for wakeup */
6262
size_t avail; /* max used buffer for wakeup */
6363
size_t xruns; /* over/underruns counter */
64+
int buffer_ref; /* buffer reference count */
6465
/* misc */
6566
spinlock_t lock;
6667
wait_queue_head_t sleep;

sound/core/rawmidi.c

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ static void snd_rawmidi_input_event_work(struct work_struct *work)
120120
runtime->event(runtime->substream);
121121
}
122122

123+
/* buffer refcount management: call with runtime->lock held */
124+
static inline void snd_rawmidi_buffer_ref(struct snd_rawmidi_runtime *runtime)
125+
{
126+
runtime->buffer_ref++;
127+
}
128+
129+
static inline void snd_rawmidi_buffer_unref(struct snd_rawmidi_runtime *runtime)
130+
{
131+
runtime->buffer_ref--;
132+
}
133+
123134
static int snd_rawmidi_runtime_create(struct snd_rawmidi_substream *substream)
124135
{
125136
struct snd_rawmidi_runtime *runtime;
@@ -669,6 +680,11 @@ static int resize_runtime_buffer(struct snd_rawmidi_runtime *runtime,
669680
if (!newbuf)
670681
return -ENOMEM;
671682
spin_lock_irq(&runtime->lock);
683+
if (runtime->buffer_ref) {
684+
spin_unlock_irq(&runtime->lock);
685+
kvfree(newbuf);
686+
return -EBUSY;
687+
}
672688
oldbuf = runtime->buffer;
673689
runtime->buffer = newbuf;
674690
runtime->buffer_size = params->buffer_size;
@@ -1019,8 +1035,10 @@ static long snd_rawmidi_kernel_read1(struct snd_rawmidi_substream *substream,
10191035
long result = 0, count1;
10201036
struct snd_rawmidi_runtime *runtime = substream->runtime;
10211037
unsigned long appl_ptr;
1038+
int err = 0;
10221039

10231040
spin_lock_irqsave(&runtime->lock, flags);
1041+
snd_rawmidi_buffer_ref(runtime);
10241042
while (count > 0 && runtime->avail) {
10251043
count1 = runtime->buffer_size - runtime->appl_ptr;
10261044
if (count1 > count)
@@ -1039,16 +1057,19 @@ static long snd_rawmidi_kernel_read1(struct snd_rawmidi_substream *substream,
10391057
if (userbuf) {
10401058
spin_unlock_irqrestore(&runtime->lock, flags);
10411059
if (copy_to_user(userbuf + result,
1042-
runtime->buffer + appl_ptr, count1)) {
1043-
return result > 0 ? result : -EFAULT;
1044-
}
1060+
runtime->buffer + appl_ptr, count1))
1061+
err = -EFAULT;
10451062
spin_lock_irqsave(&runtime->lock, flags);
1063+
if (err)
1064+
goto out;
10461065
}
10471066
result += count1;
10481067
count -= count1;
10491068
}
1069+
out:
1070+
snd_rawmidi_buffer_unref(runtime);
10501071
spin_unlock_irqrestore(&runtime->lock, flags);
1051-
return result;
1072+
return result > 0 ? result : err;
10521073
}
10531074

10541075
long snd_rawmidi_kernel_read(struct snd_rawmidi_substream *substream,
@@ -1342,6 +1363,7 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
13421363
return -EAGAIN;
13431364
}
13441365
}
1366+
snd_rawmidi_buffer_ref(runtime);
13451367
while (count > 0 && runtime->avail > 0) {
13461368
count1 = runtime->buffer_size - runtime->appl_ptr;
13471369
if (count1 > count)
@@ -1373,6 +1395,7 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
13731395
}
13741396
__end:
13751397
count1 = runtime->avail < runtime->buffer_size;
1398+
snd_rawmidi_buffer_unref(runtime);
13761399
spin_unlock_irqrestore(&runtime->lock, flags);
13771400
if (count1)
13781401
snd_rawmidi_output_trigger(substream, 1);

sound/firewire/amdtp-stream-trace.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ TRACE_EVENT(amdtp_packet,
6666
__entry->irq,
6767
__entry->index,
6868
__print_array(__get_dynamic_array(cip_header),
69-
__get_dynamic_array_len(cip_header),
70-
sizeof(u8)))
69+
__get_dynamic_array_len(cip_header), 1))
7170
);
7271

7372
#endif

sound/pci/hda/patch_realtek.c

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5856,6 +5856,15 @@ static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
58565856
}
58575857
}
58585858

5859+
static void alc225_fixup_s3_pop_noise(struct hda_codec *codec,
5860+
const struct hda_fixup *fix, int action)
5861+
{
5862+
if (action != HDA_FIXUP_ACT_PRE_PROBE)
5863+
return;
5864+
5865+
codec->power_save_node = 1;
5866+
}
5867+
58595868
/* Forcibly assign NID 0x03 to HP/LO while NID 0x02 to SPK for EQ */
58605869
static void alc274_fixup_bind_dacs(struct hda_codec *codec,
58615870
const struct hda_fixup *fix, int action)
@@ -5960,6 +5969,7 @@ enum {
59605969
ALC269_FIXUP_HP_LINE1_MIC1_LED,
59615970
ALC269_FIXUP_INV_DMIC,
59625971
ALC269_FIXUP_LENOVO_DOCK,
5972+
ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST,
59635973
ALC269_FIXUP_NO_SHUTUP,
59645974
ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
59655975
ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
@@ -6045,6 +6055,7 @@ enum {
60456055
ALC233_FIXUP_ACER_HEADSET_MIC,
60466056
ALC294_FIXUP_LENOVO_MIC_LOCATION,
60476057
ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE,
6058+
ALC225_FIXUP_S3_POP_NOISE,
60486059
ALC700_FIXUP_INTEL_REFERENCE,
60496060
ALC274_FIXUP_DELL_BIND_DACS,
60506061
ALC274_FIXUP_DELL_AIO_LINEOUT_VERB,
@@ -6080,9 +6091,12 @@ enum {
60806091
ALC294_FIXUP_ASUS_DUAL_SPK,
60816092
ALC285_FIXUP_THINKPAD_HEADSET_JACK,
60826093
ALC294_FIXUP_ASUS_HPE,
6094+
ALC294_FIXUP_ASUS_COEF_1B,
60836095
ALC285_FIXUP_HP_GPIO_LED,
60846096
ALC285_FIXUP_HP_MUTE_LED,
60856097
ALC236_FIXUP_HP_MUTE_LED,
6098+
ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET,
6099+
ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
60866100
};
60876101

60886102
static const struct hda_fixup alc269_fixups[] = {
@@ -6280,6 +6294,12 @@ static const struct hda_fixup alc269_fixups[] = {
62806294
.chained = true,
62816295
.chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
62826296
},
6297+
[ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST] = {
6298+
.type = HDA_FIXUP_FUNC,
6299+
.v.func = alc269_fixup_limit_int_mic_boost,
6300+
.chained = true,
6301+
.chain_id = ALC269_FIXUP_LENOVO_DOCK,
6302+
},
62836303
[ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
62846304
.type = HDA_FIXUP_FUNC,
62856305
.v.func = alc269_fixup_pincfg_no_hp_to_lineout,
@@ -6932,6 +6952,12 @@ static const struct hda_fixup alc269_fixups[] = {
69326952
{ }
69336953
},
69346954
.chained = true,
6955+
.chain_id = ALC225_FIXUP_S3_POP_NOISE
6956+
},
6957+
[ALC225_FIXUP_S3_POP_NOISE] = {
6958+
.type = HDA_FIXUP_FUNC,
6959+
.v.func = alc225_fixup_s3_pop_noise,
6960+
.chained = true,
69356961
.chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
69366962
},
69376963
[ALC700_FIXUP_INTEL_REFERENCE] = {
@@ -7204,6 +7230,17 @@ static const struct hda_fixup alc269_fixups[] = {
72047230
.chained = true,
72057231
.chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
72067232
},
7233+
[ALC294_FIXUP_ASUS_COEF_1B] = {
7234+
.type = HDA_FIXUP_VERBS,
7235+
.v.verbs = (const struct hda_verb[]) {
7236+
/* Set bit 10 to correct noisy output after reboot from
7237+
* Windows 10 (due to pop noise reduction?)
7238+
*/
7239+
{ 0x20, AC_VERB_SET_COEF_INDEX, 0x1b },
7240+
{ 0x20, AC_VERB_SET_PROC_COEF, 0x4e4b },
7241+
{ }
7242+
},
7243+
},
72077244
[ALC285_FIXUP_HP_GPIO_LED] = {
72087245
.type = HDA_FIXUP_FUNC,
72097246
.v.func = alc285_fixup_hp_gpio_led,
@@ -7216,6 +7253,22 @@ static const struct hda_fixup alc269_fixups[] = {
72167253
.type = HDA_FIXUP_FUNC,
72177254
.v.func = alc236_fixup_hp_mute_led,
72187255
},
7256+
[ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET] = {
7257+
.type = HDA_FIXUP_VERBS,
7258+
.v.verbs = (const struct hda_verb[]) {
7259+
{ 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc5 },
7260+
{ }
7261+
},
7262+
},
7263+
[ALC295_FIXUP_ASUS_MIC_NO_PRESENCE] = {
7264+
.type = HDA_FIXUP_PINS,
7265+
.v.pins = (const struct hda_pintbl[]) {
7266+
{ 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
7267+
{ }
7268+
},
7269+
.chained = true,
7270+
.chain_id = ALC269_FIXUP_HEADSET_MODE
7271+
},
72197272
};
72207273

72217274
static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -7383,8 +7436,10 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
73837436
SND_PCI_QUIRK(0x1043, 0x18b1, "Asus MJ401TA", ALC256_FIXUP_ASUS_HEADSET_MIC),
73847437
SND_PCI_QUIRK(0x1043, 0x18f1, "Asus FX505DT", ALC256_FIXUP_ASUS_HEADSET_MIC),
73857438
SND_PCI_QUIRK(0x1043, 0x19ce, "ASUS B9450FA", ALC294_FIXUP_ASUS_HPE),
7439+
SND_PCI_QUIRK(0x1043, 0x19e1, "ASUS UX581LV", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE),
73867440
SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
73877441
SND_PCI_QUIRK(0x1043, 0x1a30, "ASUS X705UD", ALC256_FIXUP_ASUS_MIC),
7442+
SND_PCI_QUIRK(0x1043, 0x1b11, "ASUS UX431DA", ALC294_FIXUP_ASUS_COEF_1B),
73887443
SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
73897444
SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
73907445
SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
@@ -7410,6 +7465,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
74107465
SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
74117466
SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
74127467
SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
7468+
SND_PCI_QUIRK(0x144d, 0xc169, "Samsung Notebook 9 Pen (NP930SBE-K01US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
7469+
SND_PCI_QUIRK(0x144d, 0xc176, "Samsung Notebook 9 Pro (NP930MBE-K04US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
74137470
SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
74147471
SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
74157472
SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
@@ -7426,7 +7483,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
74267483
SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
74277484
SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
74287485
SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
7429-
SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
7486+
SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST),
74307487
SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
74317488
SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
74327489
SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
@@ -7565,6 +7622,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
75657622
{.id = ALC269_FIXUP_HEADSET_MODE, .name = "headset-mode"},
75667623
{.id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC, .name = "headset-mode-no-hp-mic"},
75677624
{.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
7625+
{.id = ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST, .name = "lenovo-dock-limit-boost"},
75687626
{.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
75697627
{.id = ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED, .name = "hp-dock-gpio-mic1-led"},
75707628
{.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
@@ -7993,6 +8051,18 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
79938051
{0x12, 0x90a60130},
79948052
{0x17, 0x90170110},
79958053
{0x21, 0x03211020}),
8054+
SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
8055+
{0x12, 0x90a60120},
8056+
{0x17, 0x90170110},
8057+
{0x21, 0x04211030}),
8058+
SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
8059+
{0x12, 0x90a60130},
8060+
{0x17, 0x90170110},
8061+
{0x21, 0x03211020}),
8062+
SND_HDA_PIN_QUIRK(0x10ec0295, 0x1043, "ASUS", ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
8063+
{0x12, 0x90a60130},
8064+
{0x17, 0x90170110},
8065+
{0x21, 0x03211020}),
79968066
SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
79978067
{0x14, 0x90170110},
79988068
{0x21, 0x04211020}),
@@ -8209,8 +8279,6 @@ static int patch_alc269(struct hda_codec *codec)
82098279
spec->gen.mixer_nid = 0;
82108280
break;
82118281
case 0x10ec0225:
8212-
codec->power_save_node = 1;
8213-
/* fall through */
82148282
case 0x10ec0295:
82158283
case 0x10ec0299:
82168284
spec->codec_variant = ALC269_TYPE_ALC225;

sound/usb/mixer_maps.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,11 @@ static const struct usbmix_ctl_map usbmix_ctl_maps[] = {
549549
.map = trx40_mobo_map,
550550
.connector_map = trx40_mobo_connector_map,
551551
},
552+
{ /* Asrock TRX40 Creator */
553+
.id = USB_ID(0x26ce, 0x0a01),
554+
.map = trx40_mobo_map,
555+
.connector_map = trx40_mobo_connector_map,
556+
},
552557
{ 0 } /* terminator */
553558
};
554559

sound/usb/quirks-table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3563,6 +3563,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
35633563
ALC1220_VB_DESKTOP(0x0414, 0xa002), /* Gigabyte TRX40 Aorus Pro WiFi */
35643564
ALC1220_VB_DESKTOP(0x0db0, 0x0d64), /* MSI TRX40 Creator */
35653565
ALC1220_VB_DESKTOP(0x0db0, 0x543d), /* MSI TRX40 */
3566+
ALC1220_VB_DESKTOP(0x26ce, 0x0a01), /* Asrock TRX40 Creator */
35663567
#undef ALC1220_VB_DESKTOP
35673568

35683569
#undef USB_DEVICE_VENDOR_SPEC

sound/usb/quirks.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,13 +1636,14 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
16361636
&& (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
16371637
msleep(20);
16381638

1639-
/* Zoom R16/24, Logitech H650e, Jabra 550a needs a tiny delay here,
1640-
* otherwise requests like get/set frequency return as failed despite
1641-
* actually succeeding.
1639+
/* Zoom R16/24, Logitech H650e, Jabra 550a, Kingston HyperX needs a tiny
1640+
* delay here, otherwise requests like get/set frequency return as
1641+
* failed despite actually succeeding.
16421642
*/
16431643
if ((chip->usb_id == USB_ID(0x1686, 0x00dd) ||
16441644
chip->usb_id == USB_ID(0x046d, 0x0a46) ||
1645-
chip->usb_id == USB_ID(0x0b0e, 0x0349)) &&
1645+
chip->usb_id == USB_ID(0x0b0e, 0x0349) ||
1646+
chip->usb_id == USB_ID(0x0951, 0x16ad)) &&
16461647
(requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
16471648
usleep_range(1000, 2000);
16481649
}

0 commit comments

Comments
 (0)