Commit 4c8ab068 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents 3290badd 5251605f
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -654,6 +654,7 @@ void snd_jack_report(struct snd_jack *jack, int status)
	struct snd_jack_kctl *jack_kctl;
	unsigned int mask_bits = 0;
#ifdef CONFIG_SND_JACK_INPUT_DEV
	struct input_dev *idev;
	int i;
#endif

@@ -670,17 +671,15 @@ void snd_jack_report(struct snd_jack *jack, int status)
					     status & jack_kctl->mask_bits);

#ifdef CONFIG_SND_JACK_INPUT_DEV
	mutex_lock(&jack->input_dev_lock);
	if (!jack->input_dev) {
		mutex_unlock(&jack->input_dev_lock);
	idev = input_get_device(jack->input_dev);
	if (!idev)
		return;
	}

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

		if (jack->type & testbit)
			input_report_key(jack->input_dev, jack->key[i],
			input_report_key(idev, jack->key[i],
					 status & testbit);
	}

@@ -688,13 +687,13 @@ void snd_jack_report(struct snd_jack *jack, int status)
		int testbit = ((1 << i) & ~mask_bits);

		if (jack->type & testbit)
			input_report_switch(jack->input_dev,
			input_report_switch(idev,
					    jack_switch_types[i],
					    status & testbit);
	}

	input_sync(jack->input_dev);
	mutex_unlock(&jack->input_dev_lock);
	input_sync(idev);
	input_put_device(idev);
#endif /* CONFIG_SND_JACK_INPUT_DEV */
}
EXPORT_SYMBOL(snd_jack_report);
+36 −8
Original line number Diff line number Diff line
@@ -31,15 +31,41 @@ static unsigned long max_alloc_per_card = 32UL * 1024UL * 1024UL;
module_param(max_alloc_per_card, ulong, 0644);
MODULE_PARM_DESC(max_alloc_per_card, "Max total allocation bytes per card.");

static void __update_allocated_size(struct snd_card *card, ssize_t bytes)
{
	card->total_pcm_alloc_bytes += bytes;
}

static void update_allocated_size(struct snd_card *card, ssize_t bytes)
{
	mutex_lock(&card->memory_mutex);
	__update_allocated_size(card, bytes);
	mutex_unlock(&card->memory_mutex);
}

static void decrease_allocated_size(struct snd_card *card, size_t bytes)
{
	mutex_lock(&card->memory_mutex);
	WARN_ON(card->total_pcm_alloc_bytes < bytes);
	__update_allocated_size(card, -(ssize_t)bytes);
	mutex_unlock(&card->memory_mutex);
}

static int do_alloc_pages(struct snd_card *card, int type, struct device *dev,
			  int str, size_t size, struct snd_dma_buffer *dmab)
{
	enum dma_data_direction dir;
	int err;

	/* check and reserve the requested size */
	mutex_lock(&card->memory_mutex);
	if (max_alloc_per_card &&
	    card->total_pcm_alloc_bytes + size > max_alloc_per_card)
	    card->total_pcm_alloc_bytes + size > max_alloc_per_card) {
		mutex_unlock(&card->memory_mutex);
		return -ENOMEM;
	}
	__update_allocated_size(card, size);
	mutex_unlock(&card->memory_mutex);

	if (str == SNDRV_PCM_STREAM_PLAYBACK)
		dir = DMA_TO_DEVICE;
@@ -47,9 +73,14 @@ static int do_alloc_pages(struct snd_card *card, int type, struct device *dev,
		dir = DMA_FROM_DEVICE;
	err = snd_dma_alloc_dir_pages(type, dev, dir, size, dmab);
	if (!err) {
		mutex_lock(&card->memory_mutex);
		card->total_pcm_alloc_bytes += dmab->bytes;
		mutex_unlock(&card->memory_mutex);
		/* the actual allocation size might be bigger than requested,
		 * and we need to correct the account
		 */
		if (dmab->bytes != size)
			update_allocated_size(card, dmab->bytes - size);
	} else {
		/* take back on allocation failure */
		decrease_allocated_size(card, size);
	}
	return err;
}
@@ -58,10 +89,7 @@ static void do_free_pages(struct snd_card *card, struct snd_dma_buffer *dmab)
{
	if (!dmab->area)
		return;
	mutex_lock(&card->memory_mutex);
	WARN_ON(card->total_pcm_alloc_bytes < dmab->bytes);
	card->total_pcm_alloc_bytes -= dmab->bytes;
	mutex_unlock(&card->memory_mutex);
	decrease_allocated_size(card, dmab->bytes);
	snd_dma_free_pages(dmab);
	dmab->area = NULL;
}
+1 −1
Original line number Diff line number Diff line
@@ -714,7 +714,7 @@ static int system_2p_ev_to_ump_midi1(const struct snd_seq_event *event,
{
	data->system.status = status;
	data->system.parm1 = (event->data.control.value >> 7) & 0x7f;
	data->system.parm1 = event->data.control.value & 0x7f;
	data->system.parm2 = event->data.control.value & 0x7f;
	return 1;
}

+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ static int cvt_ump_system_to_legacy(u32 data, unsigned char *buf)
	case UMP_SYSTEM_STATUS_MIDI_TIME_CODE:
	case UMP_SYSTEM_STATUS_SONG_SELECT:
		buf[1] = (data >> 8) & 0x7f;
		return 1;
		return 2;
	case UMP_SYSTEM_STATUS_SONG_POSITION:
		buf[1] = (data >> 8) & 0x7f;
		buf[2] = data & 0x7f;
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ MODULE_LICENSE("GPL");
static void name_card(struct snd_ff *ff)
{
	struct fw_device *fw_dev = fw_parent_device(ff->unit);
	const char *const names[] = {
	static const char *const names[] = {
		[SND_FF_UNIT_VERSION_FF800]	= "Fireface800",
		[SND_FF_UNIT_VERSION_FF400]	= "Fireface400",
		[SND_FF_UNIT_VERSION_UFX]	= "FirefaceUFX",
Loading