Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

Pull sound fixes from Takashi Iwai:
"The amount of the changes isn't as quite small as wished, nevertheless
they are straight fixes that deserve merging to 4.14 final.

Most of fixes are about ALSA core bugs spotted by fuzzer: a follow-up
fix for the previous nested rwsem patch, a fix to avoid the resource
hogs due to too many concurrent ALSA timer invocations, and a fix for
a crash with SYSEX MIDI transfer over OSS sequencer emulation that is
used by none but fuzzer.

The rest are usual HD-audio and USB-audio device-specific quirks,
which are safe to apply"

* tag 'sound-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
ALSA: hda - fix headset mic problem for Dell machines with alc274
ALSA: seq: Fix OSS sysex delivery in OSS emulation
ALSA: seq: Avoid invalid lockdep class warning
ALSA: timer: Limit max instances per timer
ALSA: usb-audio: support new Amanero Combo384 firmware version

+97 -17
+2 -1
include/sound/seq_kernel.h
··· 49 49 #define SNDRV_SEQ_DEFAULT_CLIENT_EVENTS 200 50 50 51 51 /* max delivery path length */ 52 - #define SNDRV_SEQ_MAX_HOPS 10 52 + /* NOTE: this shouldn't be greater than MAX_LOCKDEP_SUBCLASSES */ 53 + #define SNDRV_SEQ_MAX_HOPS 8 53 54 54 55 /* max size of event size */ 55 56 #define SNDRV_SEQ_MAX_EVENT_LEN 0x3fffffff
+2
include/sound/timer.h
··· 90 90 struct list_head ack_list_head; 91 91 struct list_head sack_list_head; /* slow ack list head */ 92 92 struct tasklet_struct task_queue; 93 + int max_instances; /* upper limit of timer instances */ 94 + int num_instances; /* current number of timer instances */ 93 95 }; 94 96 95 97 struct snd_timer_instance {
+1
sound/core/hrtimer.c
··· 159 159 timer->hw = hrtimer_hw; 160 160 timer->hw.resolution = resolution; 161 161 timer->hw.ticks = NANO_SEC / resolution; 162 + timer->max_instances = 100; /* lower the limit */ 162 163 163 164 err = snd_timer_global_register(timer); 164 165 if (err < 0) {
+1 -3
sound/core/seq/oss/seq_oss_midi.c
··· 612 612 if (!dp->timer->running) 613 613 len = snd_seq_oss_timer_start(dp->timer); 614 614 if (ev->type == SNDRV_SEQ_EVENT_SYSEX) { 615 - if ((ev->flags & SNDRV_SEQ_EVENT_LENGTH_MASK) == SNDRV_SEQ_EVENT_LENGTH_VARIABLE) 616 - snd_seq_oss_readq_puts(dp->readq, mdev->seq_device, 617 - ev->data.ext.ptr, ev->data.ext.len); 615 + snd_seq_oss_readq_sysex(dp->readq, mdev->seq_device, ev); 618 616 } else { 619 617 len = snd_midi_event_decode(mdev->coder, msg, sizeof(msg), ev); 620 618 if (len > 0)
+29
sound/core/seq/oss/seq_oss_readq.c
··· 118 118 } 119 119 120 120 /* 121 + * put MIDI sysex bytes; the event buffer may be chained, thus it has 122 + * to be expanded via snd_seq_dump_var_event(). 123 + */ 124 + struct readq_sysex_ctx { 125 + struct seq_oss_readq *readq; 126 + int dev; 127 + }; 128 + 129 + static int readq_dump_sysex(void *ptr, void *buf, int count) 130 + { 131 + struct readq_sysex_ctx *ctx = ptr; 132 + 133 + return snd_seq_oss_readq_puts(ctx->readq, ctx->dev, buf, count); 134 + } 135 + 136 + int snd_seq_oss_readq_sysex(struct seq_oss_readq *q, int dev, 137 + struct snd_seq_event *ev) 138 + { 139 + struct readq_sysex_ctx ctx = { 140 + .readq = q, 141 + .dev = dev 142 + }; 143 + 144 + if ((ev->flags & SNDRV_SEQ_EVENT_LENGTH_MASK) != SNDRV_SEQ_EVENT_LENGTH_VARIABLE) 145 + return 0; 146 + return snd_seq_dump_var_event(ev, readq_dump_sysex, &ctx); 147 + } 148 + 149 + /* 121 150 * copy an event to input queue: 122 151 * return zero if enqueued 123 152 */
+2
sound/core/seq/oss/seq_oss_readq.h
··· 44 44 void snd_seq_oss_readq_clear(struct seq_oss_readq *readq); 45 45 unsigned int snd_seq_oss_readq_poll(struct seq_oss_readq *readq, struct file *file, poll_table *wait); 46 46 int snd_seq_oss_readq_puts(struct seq_oss_readq *readq, int dev, unsigned char *data, int len); 47 + int snd_seq_oss_readq_sysex(struct seq_oss_readq *q, int dev, 48 + struct snd_seq_event *ev); 47 49 int snd_seq_oss_readq_put_event(struct seq_oss_readq *readq, union evrec *ev); 48 50 int snd_seq_oss_readq_put_timestamp(struct seq_oss_readq *readq, unsigned long curt, int seq_mode); 49 51 int snd_seq_oss_readq_pick(struct seq_oss_readq *q, union evrec *rec);
+54 -13
sound/core/timer.c
··· 180 180 * 181 181 * call this with register_mutex down. 182 182 */ 183 - static void snd_timer_check_slave(struct snd_timer_instance *slave) 183 + static int snd_timer_check_slave(struct snd_timer_instance *slave) 184 184 { 185 185 struct snd_timer *timer; 186 186 struct snd_timer_instance *master; ··· 190 190 list_for_each_entry(master, &timer->open_list_head, open_list) { 191 191 if (slave->slave_class == master->slave_class && 192 192 slave->slave_id == master->slave_id) { 193 + if (master->timer->num_instances >= 194 + master->timer->max_instances) 195 + return -EBUSY; 193 196 list_move_tail(&slave->open_list, 194 197 &master->slave_list_head); 198 + master->timer->num_instances++; 195 199 spin_lock_irq(&slave_active_lock); 196 200 slave->master = master; 197 201 slave->timer = master->timer; 198 202 spin_unlock_irq(&slave_active_lock); 199 - return; 203 + return 0; 200 204 } 201 205 } 202 206 } 207 + return 0; 203 208 } 204 209 205 210 /* ··· 213 208 * 214 209 * call this with register_mutex down. 215 210 */ 216 - static void snd_timer_check_master(struct snd_timer_instance *master) 211 + static int snd_timer_check_master(struct snd_timer_instance *master) 217 212 { 218 213 struct snd_timer_instance *slave, *tmp; 219 214 ··· 221 216 list_for_each_entry_safe(slave, tmp, &snd_timer_slave_list, open_list) { 222 217 if (slave->slave_class == master->slave_class && 223 218 slave->slave_id == master->slave_id) { 219 + if (master->timer->num_instances >= 220 + master->timer->max_instances) 221 + return -EBUSY; 224 222 list_move_tail(&slave->open_list, &master->slave_list_head); 223 + master->timer->num_instances++; 225 224 spin_lock_irq(&slave_active_lock); 226 225 spin_lock(&master->timer->lock); 227 226 slave->master = master; ··· 237 228 spin_unlock_irq(&slave_active_lock); 238 229 } 239 230 } 231 + return 0; 240 232 } 233 + 234 + static int snd_timer_close_locked(struct snd_timer_instance *timeri); 241 235 242 236 /* 243 237 * open a timer instance ··· 252 240 { 253 241 struct snd_timer *timer; 254 242 struct snd_timer_instance *timeri = NULL; 243 + int err; 255 244 256 245 if (tid->dev_class == SNDRV_TIMER_CLASS_SLAVE) { 257 246 /* open a slave instance */ ··· 272 259 timeri->slave_id = tid->device; 273 260 timeri->flags |= SNDRV_TIMER_IFLG_SLAVE; 274 261 list_add_tail(&timeri->open_list, &snd_timer_slave_list); 275 - snd_timer_check_slave(timeri); 262 + err = snd_timer_check_slave(timeri); 263 + if (err < 0) { 264 + snd_timer_close_locked(timeri); 265 + timeri = NULL; 266 + } 276 267 mutex_unlock(&register_mutex); 277 268 *ti = timeri; 278 - return 0; 269 + return err; 279 270 } 280 271 281 272 /* open a master instance */ ··· 304 287 mutex_unlock(&register_mutex); 305 288 return -EBUSY; 306 289 } 290 + } 291 + if (timer->num_instances >= timer->max_instances) { 292 + mutex_unlock(&register_mutex); 293 + return -EBUSY; 307 294 } 308 295 timeri = snd_timer_instance_new(owner, timer); 309 296 if (!timeri) { ··· 335 314 } 336 315 337 316 list_add_tail(&timeri->open_list, &timer->open_list_head); 338 - snd_timer_check_master(timeri); 317 + timer->num_instances++; 318 + err = snd_timer_check_master(timeri); 319 + if (err < 0) { 320 + snd_timer_close_locked(timeri); 321 + timeri = NULL; 322 + } 339 323 mutex_unlock(&register_mutex); 340 324 *ti = timeri; 341 - return 0; 325 + return err; 342 326 } 343 327 EXPORT_SYMBOL(snd_timer_open); 344 328 345 329 /* 346 330 * close a timer instance 331 + * call this with register_mutex down. 347 332 */ 348 - int snd_timer_close(struct snd_timer_instance *timeri) 333 + static int snd_timer_close_locked(struct snd_timer_instance *timeri) 349 334 { 350 335 struct snd_timer *timer = NULL; 351 336 struct snd_timer_instance *slave, *tmp; 352 337 353 - if (snd_BUG_ON(!timeri)) 354 - return -ENXIO; 355 - 356 - mutex_lock(&register_mutex); 357 338 list_del(&timeri->open_list); 358 339 359 340 /* force to stop the timer */ ··· 363 340 364 341 timer = timeri->timer; 365 342 if (timer) { 343 + timer->num_instances--; 366 344 /* wait, until the active callback is finished */ 367 345 spin_lock_irq(&timer->lock); 368 346 while (timeri->flags & SNDRV_TIMER_IFLG_CALLBACK) { ··· 379 355 list_for_each_entry_safe(slave, tmp, &timeri->slave_list_head, 380 356 open_list) { 381 357 list_move_tail(&slave->open_list, &snd_timer_slave_list); 358 + timer->num_instances--; 382 359 slave->master = NULL; 383 360 slave->timer = NULL; 384 361 list_del_init(&slave->ack_list); ··· 407 382 module_put(timer->module); 408 383 } 409 384 410 - mutex_unlock(&register_mutex); 411 385 return 0; 386 + } 387 + 388 + /* 389 + * close a timer instance 390 + */ 391 + int snd_timer_close(struct snd_timer_instance *timeri) 392 + { 393 + int err; 394 + 395 + if (snd_BUG_ON(!timeri)) 396 + return -ENXIO; 397 + 398 + mutex_lock(&register_mutex); 399 + err = snd_timer_close_locked(timeri); 400 + mutex_unlock(&register_mutex); 401 + return err; 412 402 } 413 403 EXPORT_SYMBOL(snd_timer_close); 414 404 ··· 896 856 spin_lock_init(&timer->lock); 897 857 tasklet_init(&timer->task_queue, snd_timer_tasklet, 898 858 (unsigned long)timer); 859 + timer->max_instances = 1000; /* default limit per timer */ 899 860 if (card != NULL) { 900 861 timer->module = card->module; 901 862 err = snd_device_new(card, SNDRV_DEV_TIMER, timer, &ops);
+5
sound/pci/hda/patch_realtek.c
··· 6544 6544 {0x14, 0x90170110}, 6545 6545 {0x1b, 0x90a70130}, 6546 6546 {0x21, 0x03211020}), 6547 + SND_HDA_PIN_QUIRK(0x10ec0274, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, 6548 + {0x12, 0xb7a60130}, 6549 + {0x13, 0xb8a61140}, 6550 + {0x16, 0x90170110}, 6551 + {0x21, 0x04211020}), 6547 6552 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4, 6548 6553 {0x12, 0x90a60130}, 6549 6554 {0x14, 0x90170110},
+1
sound/usb/quirks.c
··· 1375 1375 case 0x199: 1376 1376 return SNDRV_PCM_FMTBIT_DSD_U32_LE; 1377 1377 case 0x19b: 1378 + case 0x203: 1378 1379 return SNDRV_PCM_FMTBIT_DSD_U32_BE; 1379 1380 default: 1380 1381 break;