Skip to content

Commit 6d28484

Browse files
committed
Merge branch 'for-linus' into for-next
Back-merge 5.7-devel branch for further development. Signed-off-by: Takashi Iwai <[email protected]>
2 parents e0b2db3 + 630e361 commit 6d28484

File tree

16 files changed

+231
-55
lines changed

16 files changed

+231
-55
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/hwdep.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw,
216216
if (info.index >= 32)
217217
return -EINVAL;
218218
/* check whether the dsp was already loaded */
219-
if (hw->dsp_loaded & (1 << info.index))
219+
if (hw->dsp_loaded & (1u << info.index))
220220
return -EBUSY;
221221
err = hw->ops.dsp_load(hw, &info);
222222
if (err < 0)
223223
return err;
224-
hw->dsp_loaded |= (1 << info.index);
224+
hw->dsp_loaded |= (1u << info.index);
225225
return 0;
226226
}
227227

sound/core/oss/pcm_plugin.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,14 @@ static snd_pcm_sframes_t calc_dst_frames(struct snd_pcm_substream *plug,
205205
plugin = snd_pcm_plug_first(plug);
206206
while (plugin && frames > 0) {
207207
plugin_next = plugin->next;
208+
if (check_size && plugin->buf_frames &&
209+
frames > plugin->buf_frames)
210+
frames = plugin->buf_frames;
208211
if (plugin->dst_frames) {
209212
frames = plugin->dst_frames(plugin, frames);
210213
if (frames < 0)
211214
return frames;
212215
}
213-
if (check_size && frames > plugin->buf_frames)
214-
frames = plugin->buf_frames;
215216
plugin = plugin_next;
216217
}
217218
return frames;
@@ -225,14 +226,15 @@ static snd_pcm_sframes_t calc_src_frames(struct snd_pcm_substream *plug,
225226

226227
plugin = snd_pcm_plug_last(plug);
227228
while (plugin && frames > 0) {
228-
if (check_size && frames > plugin->buf_frames)
229-
frames = plugin->buf_frames;
230229
plugin_prev = plugin->prev;
231230
if (plugin->src_frames) {
232231
frames = plugin->src_frames(plugin, frames);
233232
if (frames < 0)
234233
return frames;
235234
}
235+
if (check_size && plugin->buf_frames &&
236+
frames > plugin->buf_frames)
237+
frames = plugin->buf_frames;
236238
plugin = plugin_prev;
237239
}
238240
return frames;

sound/core/pcm_lib.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
433433

434434
no_delta_check:
435435
if (runtime->status->hw_ptr == new_hw_ptr) {
436+
runtime->hw_ptr_jiffies = curr_jiffies;
436437
update_audio_tstamp(substream, &curr_tstamp, &audio_tstamp);
437438
return 0;
438439
}

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/isa/opti9xx/miro.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -867,10 +867,13 @@ static void snd_miro_write(struct snd_miro *chip, unsigned char reg,
867867
spin_unlock_irqrestore(&chip->lock, flags);
868868
}
869869

870+
static inline void snd_miro_write_mask(struct snd_miro *chip,
871+
unsigned char reg, unsigned char value, unsigned char mask)
872+
{
873+
unsigned char oldval = snd_miro_read(chip, reg);
870874

871-
#define snd_miro_write_mask(chip, reg, value, mask) \
872-
snd_miro_write(chip, reg, \
873-
(snd_miro_read(chip, reg) & ~(mask)) | ((value) & (mask)))
875+
snd_miro_write(chip, reg, (oldval & ~mask) | (value & mask));
876+
}
874877

875878
/*
876879
* Proc Interface

sound/isa/opti9xx/opti92x-ad1848.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,13 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg,
317317
}
318318

319319

320-
#define snd_opti9xx_write_mask(chip, reg, value, mask) \
321-
snd_opti9xx_write(chip, reg, \
322-
(snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask)))
320+
static inline void snd_opti9xx_write_mask(struct snd_opti9xx *chip,
321+
unsigned char reg, unsigned char value, unsigned char mask)
322+
{
323+
unsigned char oldval = snd_opti9xx_read(chip, reg);
323324

325+
snd_opti9xx_write(chip, reg, (oldval & ~mask) | (value & mask));
326+
}
324327

325328
static int snd_opti9xx_configure(struct snd_opti9xx *chip,
326329
long port,

sound/pci/hda/patch_hdmi.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,8 +1848,10 @@ static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid)
18481848
/* Add sanity check to pass klockwork check.
18491849
* This should never happen.
18501850
*/
1851-
if (WARN_ON(spdif == NULL))
1851+
if (WARN_ON(spdif == NULL)) {
1852+
mutex_unlock(&codec->spdif_mutex);
18521853
return true;
1854+
}
18531855
non_pcm = !!(spdif->status & IEC958_AES0_NONAUDIO);
18541856
mutex_unlock(&codec->spdif_mutex);
18551857
return non_pcm;
@@ -2198,7 +2200,9 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
21982200

21992201
for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
22002202
struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
2203+
struct hdmi_eld *pin_eld = &per_pin->sink_eld;
22012204

2205+
pin_eld->eld_valid = false;
22022206
hdmi_present_sense(per_pin, 0);
22032207
}
22042208

0 commit comments

Comments
 (0)