Skip to content

Commit a3f4f2d

Browse files
committed
ALSA: firewire: Convert to the common vmalloc memalloc
The recent change (*) in the ALSA memalloc core allows us to drop the special vmalloc-specific allocation and page handling. This patch coverts to the common code. (*) 1fe7f39: ALSA: memalloc: Add vmalloc buffer allocation support 7e8edae: ALSA: pcm: Handle special page mapping in the default mmap handler Link: https://lore.kernel.org/r/20191105151856.10785-11-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent b29e5ef commit a3f4f2d

9 files changed

Lines changed: 40 additions & 47 deletions

File tree

‎sound/firewire/bebob/bebob_pcm.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
214214
struct snd_bebob *bebob = substream->private_data;
215215
int err;
216216

217-
err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
218-
params_buffer_bytes(hw_params));
217+
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
219218
if (err < 0)
220219
return err;
221220

@@ -248,7 +247,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
248247

249248
mutex_unlock(&bebob->mutex);
250249

251-
return snd_pcm_lib_free_vmalloc_buffer(substream);
250+
return snd_pcm_lib_free_pages(substream);
252251
}
253252

254253
static int
@@ -354,7 +353,6 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob)
354353
.trigger = pcm_capture_trigger,
355354
.pointer = pcm_capture_pointer,
356355
.ack = pcm_capture_ack,
357-
.page = snd_pcm_lib_get_vmalloc_page,
358356
};
359357
static const struct snd_pcm_ops playback_ops = {
360358
.open = pcm_open,
@@ -366,7 +364,6 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob)
366364
.trigger = pcm_playback_trigger,
367365
.pointer = pcm_playback_pointer,
368366
.ack = pcm_playback_ack,
369-
.page = snd_pcm_lib_get_vmalloc_page,
370367
};
371368
struct snd_pcm *pcm;
372369
int err;
@@ -380,6 +377,8 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob)
380377
"%s PCM", bebob->card->shortname);
381378
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
382379
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
380+
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
381+
NULL, 0, 0);
383382
end:
384383
return err;
385384
}

‎sound/firewire/dice/dice-pcm.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
266266
struct snd_dice *dice = substream->private_data;
267267
int err;
268268

269-
err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
270-
params_buffer_bytes(hw_params));
269+
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
271270
if (err < 0)
272271
return err;
273272

@@ -305,7 +304,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
305304

306305
mutex_unlock(&dice->mutex);
307306

308-
return snd_pcm_lib_free_vmalloc_buffer(substream);
307+
return snd_pcm_lib_free_pages(substream);
309308
}
310309

311310
static int capture_prepare(struct snd_pcm_substream *substream)
@@ -417,7 +416,6 @@ int snd_dice_create_pcm(struct snd_dice *dice)
417416
.trigger = capture_trigger,
418417
.pointer = capture_pointer,
419418
.ack = capture_ack,
420-
.page = snd_pcm_lib_get_vmalloc_page,
421419
};
422420
static const struct snd_pcm_ops playback_ops = {
423421
.open = pcm_open,
@@ -429,7 +427,6 @@ int snd_dice_create_pcm(struct snd_dice *dice)
429427
.trigger = playback_trigger,
430428
.pointer = playback_pointer,
431429
.ack = playback_ack,
432-
.page = snd_pcm_lib_get_vmalloc_page,
433430
};
434431
struct snd_pcm *pcm;
435432
unsigned int capture, playback;
@@ -459,6 +456,10 @@ int snd_dice_create_pcm(struct snd_dice *dice)
459456
if (playback > 0)
460457
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
461458
&playback_ops);
459+
460+
snd_pcm_lib_preallocate_pages_for_all(pcm,
461+
SNDRV_DMA_TYPE_VMALLOC,
462+
NULL, 0, 0);
462463
}
463464

464465
return 0;

‎sound/firewire/digi00x/digi00x-pcm.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
190190
struct snd_dg00x *dg00x = substream->private_data;
191191
int err;
192192

193-
err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
194-
params_buffer_bytes(hw_params));
193+
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
195194
if (err < 0)
196195
return err;
197196

@@ -224,7 +223,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
224223

225224
mutex_unlock(&dg00x->mutex);
226225

227-
return snd_pcm_lib_free_vmalloc_buffer(substream);
226+
return snd_pcm_lib_free_pages(substream);
228227
}
229228

230229
static int pcm_capture_prepare(struct snd_pcm_substream *substream)
@@ -337,7 +336,6 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x)
337336
.trigger = pcm_capture_trigger,
338337
.pointer = pcm_capture_pointer,
339338
.ack = pcm_capture_ack,
340-
.page = snd_pcm_lib_get_vmalloc_page,
341339
};
342340
static const struct snd_pcm_ops playback_ops = {
343341
.open = pcm_open,
@@ -349,7 +347,6 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x)
349347
.trigger = pcm_playback_trigger,
350348
.pointer = pcm_playback_pointer,
351349
.ack = pcm_playback_ack,
352-
.page = snd_pcm_lib_get_vmalloc_page,
353350
};
354351
struct snd_pcm *pcm;
355352
int err;
@@ -363,6 +360,8 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x)
363360
"%s PCM", dg00x->card->shortname);
364361
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
365362
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
363+
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
364+
NULL, 0, 0);
366365

367366
return 0;
368367
}

‎sound/firewire/fireface/ff-pcm.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
230230
struct snd_ff *ff = substream->private_data;
231231
int err;
232232

233-
err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
234-
params_buffer_bytes(hw_params));
233+
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
235234
if (err < 0)
236235
return err;
237236

@@ -264,7 +263,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
264263

265264
mutex_unlock(&ff->mutex);
266265

267-
return snd_pcm_lib_free_vmalloc_buffer(substream);
266+
return snd_pcm_lib_free_pages(substream);
268267
}
269268

270269
static int pcm_capture_prepare(struct snd_pcm_substream *substream)
@@ -377,7 +376,6 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff)
377376
.trigger = pcm_capture_trigger,
378377
.pointer = pcm_capture_pointer,
379378
.ack = pcm_capture_ack,
380-
.page = snd_pcm_lib_get_vmalloc_page,
381379
};
382380
static const struct snd_pcm_ops pcm_playback_ops = {
383381
.open = pcm_open,
@@ -389,7 +387,6 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff)
389387
.trigger = pcm_playback_trigger,
390388
.pointer = pcm_playback_pointer,
391389
.ack = pcm_playback_ack,
392-
.page = snd_pcm_lib_get_vmalloc_page,
393390
};
394391
struct snd_pcm *pcm;
395392
int err;
@@ -403,6 +400,8 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff)
403400
"%s PCM", ff->card->shortname);
404401
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_playback_ops);
405402
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_capture_ops);
403+
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
404+
NULL, 0, 0);
406405

407406
return 0;
408407
}

‎sound/firewire/fireworks/fireworks_pcm.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
250250
struct snd_efw *efw = substream->private_data;
251251
int err;
252252

253-
err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
254-
params_buffer_bytes(hw_params));
253+
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
255254
if (err < 0)
256255
return err;
257256

@@ -284,7 +283,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
284283

285284
mutex_unlock(&efw->mutex);
286285

287-
return snd_pcm_lib_free_vmalloc_buffer(substream);
286+
return snd_pcm_lib_free_pages(substream);
288287
}
289288

290289
static int pcm_capture_prepare(struct snd_pcm_substream *substream)
@@ -384,7 +383,6 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw)
384383
.trigger = pcm_capture_trigger,
385384
.pointer = pcm_capture_pointer,
386385
.ack = pcm_capture_ack,
387-
.page = snd_pcm_lib_get_vmalloc_page,
388386
};
389387
static const struct snd_pcm_ops playback_ops = {
390388
.open = pcm_open,
@@ -396,7 +394,6 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw)
396394
.trigger = pcm_playback_trigger,
397395
.pointer = pcm_playback_pointer,
398396
.ack = pcm_playback_ack,
399-
.page = snd_pcm_lib_get_vmalloc_page,
400397
};
401398
struct snd_pcm *pcm;
402399
int err;
@@ -409,6 +406,8 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw)
409406
snprintf(pcm->name, sizeof(pcm->name), "%s PCM", efw->card->shortname);
410407
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
411408
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
409+
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
410+
NULL, 0, 0);
412411
end:
413412
return err;
414413
}

‎sound/firewire/isight.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
288288
struct isight *isight = substream->private_data;
289289
int err;
290290

291-
err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
292-
params_buffer_bytes(hw_params));
291+
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
293292
if (err < 0)
294293
return err;
295294

@@ -337,7 +336,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
337336
isight_stop_streaming(isight);
338337
mutex_unlock(&isight->mutex);
339338

340-
return snd_pcm_lib_free_vmalloc_buffer(substream);
339+
return snd_pcm_lib_free_pages(substream);
341340
}
342341

343342
static int isight_start_streaming(struct isight *isight)
@@ -453,7 +452,6 @@ static int isight_create_pcm(struct isight *isight)
453452
.prepare = isight_prepare,
454453
.trigger = isight_trigger,
455454
.pointer = isight_pointer,
456-
.page = snd_pcm_lib_get_vmalloc_page,
457455
};
458456
struct snd_pcm *pcm;
459457
int err;
@@ -465,6 +463,8 @@ static int isight_create_pcm(struct isight *isight)
465463
strcpy(pcm->name, "iSight");
466464
isight->pcm = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
467465
isight->pcm->ops = &ops;
466+
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
467+
NULL, 0, 0);
468468

469469
return 0;
470470
}

‎sound/firewire/motu/motu-pcm.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
218218
struct snd_motu *motu = substream->private_data;
219219
int err;
220220

221-
err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
222-
params_buffer_bytes(hw_params));
221+
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
223222
if (err < 0)
224223
return err;
225224

@@ -252,7 +251,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
252251

253252
mutex_unlock(&motu->mutex);
254253

255-
return snd_pcm_lib_free_vmalloc_buffer(substream);
254+
return snd_pcm_lib_free_pages(substream);
256255
}
257256

258257
static int capture_prepare(struct snd_pcm_substream *substream)
@@ -356,7 +355,6 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu)
356355
.trigger = capture_trigger,
357356
.pointer = capture_pointer,
358357
.ack = capture_ack,
359-
.page = snd_pcm_lib_get_vmalloc_page,
360358
};
361359
static const struct snd_pcm_ops playback_ops = {
362360
.open = pcm_open,
@@ -368,7 +366,6 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu)
368366
.trigger = playback_trigger,
369367
.pointer = playback_pointer,
370368
.ack = playback_ack,
371-
.page = snd_pcm_lib_get_vmalloc_page,
372369
};
373370
struct snd_pcm *pcm;
374371
int err;
@@ -381,6 +378,8 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu)
381378

382379
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
383380
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
381+
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
382+
NULL, 0, 0);
384383

385384
return 0;
386385
}

‎sound/firewire/oxfw/oxfw-pcm.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ static int pcm_capture_hw_params(struct snd_pcm_substream *substream,
239239
struct snd_oxfw *oxfw = substream->private_data;
240240
int err;
241241

242-
err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
243-
params_buffer_bytes(hw_params));
242+
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
244243
if (err < 0)
245244
return err;
246245

@@ -267,8 +266,7 @@ static int pcm_playback_hw_params(struct snd_pcm_substream *substream,
267266
struct snd_oxfw *oxfw = substream->private_data;
268267
int err;
269268

270-
err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
271-
params_buffer_bytes(hw_params));
269+
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
272270
if (err < 0)
273271
return err;
274272

@@ -303,7 +301,7 @@ static int pcm_capture_hw_free(struct snd_pcm_substream *substream)
303301

304302
mutex_unlock(&oxfw->mutex);
305303

306-
return snd_pcm_lib_free_vmalloc_buffer(substream);
304+
return snd_pcm_lib_free_pages(substream);
307305
}
308306
static int pcm_playback_hw_free(struct snd_pcm_substream *substream)
309307
{
@@ -318,7 +316,7 @@ static int pcm_playback_hw_free(struct snd_pcm_substream *substream)
318316

319317
mutex_unlock(&oxfw->mutex);
320318

321-
return snd_pcm_lib_free_vmalloc_buffer(substream);
319+
return snd_pcm_lib_free_pages(substream);
322320
}
323321

324322
static int pcm_capture_prepare(struct snd_pcm_substream *substream)
@@ -428,7 +426,6 @@ int snd_oxfw_create_pcm(struct snd_oxfw *oxfw)
428426
.trigger = pcm_capture_trigger,
429427
.pointer = pcm_capture_pointer,
430428
.ack = pcm_capture_ack,
431-
.page = snd_pcm_lib_get_vmalloc_page,
432429
};
433430
static const struct snd_pcm_ops playback_ops = {
434431
.open = pcm_open,
@@ -440,7 +437,6 @@ int snd_oxfw_create_pcm(struct snd_oxfw *oxfw)
440437
.trigger = pcm_playback_trigger,
441438
.pointer = pcm_playback_pointer,
442439
.ack = pcm_playback_ack,
443-
.page = snd_pcm_lib_get_vmalloc_page,
444440
};
445441
struct snd_pcm *pcm;
446442
unsigned int cap = 0;
@@ -458,6 +454,8 @@ int snd_oxfw_create_pcm(struct snd_oxfw *oxfw)
458454
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
459455
if (cap > 0)
460456
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
457+
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
458+
NULL, 0, 0);
461459

462460
return 0;
463461
}

0 commit comments

Comments
 (0)