Commit 6d284840 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

Merge branch 'for-linus' into for-next



Back-merge 5.7-devel branch for further development.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parents e0b2db35 630e3612
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ struct snd_rawmidi_runtime {
	size_t avail_min;	/* min avail for wakeup */
	size_t avail;		/* max used buffer for wakeup */
	size_t xruns;		/* over/underruns counter */
	int buffer_ref;		/* buffer reference count */
	/* misc */
	spinlock_t lock;
	wait_queue_head_t sleep;
+2 −2
Original line number Diff line number Diff line
@@ -216,12 +216,12 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw,
	if (info.index >= 32)
		return -EINVAL;
	/* check whether the dsp was already loaded */
	if (hw->dsp_loaded & (1 << info.index))
	if (hw->dsp_loaded & (1u << info.index))
		return -EBUSY;
	err = hw->ops.dsp_load(hw, &info);
	if (err < 0)
		return err;
	hw->dsp_loaded |= (1 << info.index);
	hw->dsp_loaded |= (1u << info.index);
	return 0;
}

+6 −4
Original line number Diff line number Diff line
@@ -205,13 +205,14 @@ static snd_pcm_sframes_t calc_dst_frames(struct snd_pcm_substream *plug,
	plugin = snd_pcm_plug_first(plug);
	while (plugin && frames > 0) {
		plugin_next = plugin->next;
		if (check_size && plugin->buf_frames &&
		    frames > plugin->buf_frames)
			frames = plugin->buf_frames;
		if (plugin->dst_frames) {
			frames = plugin->dst_frames(plugin, frames);
			if (frames < 0)
				return frames;
		}
		if (check_size && frames > plugin->buf_frames)
			frames = plugin->buf_frames;
		plugin = plugin_next;
	}
	return frames;
@@ -225,14 +226,15 @@ static snd_pcm_sframes_t calc_src_frames(struct snd_pcm_substream *plug,

	plugin = snd_pcm_plug_last(plug);
	while (plugin && frames > 0) {
		if (check_size && frames > plugin->buf_frames)
			frames = plugin->buf_frames;
		plugin_prev = plugin->prev;
		if (plugin->src_frames) {
			frames = plugin->src_frames(plugin, frames);
			if (frames < 0)
				return frames;
		}
		if (check_size && plugin->buf_frames &&
		    frames > plugin->buf_frames)
			frames = plugin->buf_frames;
		plugin = plugin_prev;
	}
	return frames;
+1 −0
Original line number Diff line number Diff line
@@ -433,6 +433,7 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,

 no_delta_check:
	if (runtime->status->hw_ptr == new_hw_ptr) {
		runtime->hw_ptr_jiffies = curr_jiffies;
		update_audio_tstamp(substream, &curr_tstamp, &audio_tstamp);
		return 0;
	}
+27 −4
Original line number Diff line number Diff line
@@ -120,6 +120,17 @@ static void snd_rawmidi_input_event_work(struct work_struct *work)
		runtime->event(runtime->substream);
}

/* buffer refcount management: call with runtime->lock held */
static inline void snd_rawmidi_buffer_ref(struct snd_rawmidi_runtime *runtime)
{
	runtime->buffer_ref++;
}

static inline void snd_rawmidi_buffer_unref(struct snd_rawmidi_runtime *runtime)
{
	runtime->buffer_ref--;
}

static int snd_rawmidi_runtime_create(struct snd_rawmidi_substream *substream)
{
	struct snd_rawmidi_runtime *runtime;
@@ -669,6 +680,11 @@ static int resize_runtime_buffer(struct snd_rawmidi_runtime *runtime,
		if (!newbuf)
			return -ENOMEM;
		spin_lock_irq(&runtime->lock);
		if (runtime->buffer_ref) {
			spin_unlock_irq(&runtime->lock);
			kvfree(newbuf);
			return -EBUSY;
		}
		oldbuf = runtime->buffer;
		runtime->buffer = newbuf;
		runtime->buffer_size = params->buffer_size;
@@ -1019,8 +1035,10 @@ static long snd_rawmidi_kernel_read1(struct snd_rawmidi_substream *substream,
	long result = 0, count1;
	struct snd_rawmidi_runtime *runtime = substream->runtime;
	unsigned long appl_ptr;
	int err = 0;

	spin_lock_irqsave(&runtime->lock, flags);
	snd_rawmidi_buffer_ref(runtime);
	while (count > 0 && runtime->avail) {
		count1 = runtime->buffer_size - runtime->appl_ptr;
		if (count1 > count)
@@ -1039,16 +1057,19 @@ static long snd_rawmidi_kernel_read1(struct snd_rawmidi_substream *substream,
		if (userbuf) {
			spin_unlock_irqrestore(&runtime->lock, flags);
			if (copy_to_user(userbuf + result,
					 runtime->buffer + appl_ptr, count1)) {
				return result > 0 ? result : -EFAULT;
			}
					 runtime->buffer + appl_ptr, count1))
				err = -EFAULT;
			spin_lock_irqsave(&runtime->lock, flags);
			if (err)
				goto out;
		}
		result += count1;
		count -= count1;
	}
 out:
	snd_rawmidi_buffer_unref(runtime);
	spin_unlock_irqrestore(&runtime->lock, flags);
	return result;
	return result > 0 ? result : err;
}

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,
			return -EAGAIN;
		}
	}
	snd_rawmidi_buffer_ref(runtime);
	while (count > 0 && runtime->avail > 0) {
		count1 = runtime->buffer_size - runtime->appl_ptr;
		if (count1 > count)
@@ -1373,6 +1395,7 @@ static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream,
	}
      __end:
	count1 = runtime->avail < runtime->buffer_size;
	snd_rawmidi_buffer_unref(runtime);
	spin_unlock_irqrestore(&runtime->lock, flags);
	if (count1)
		snd_rawmidi_output_trigger(substream, 1);
Loading