summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-02-08 08:12:15 -0500
committerTakashi Iwai <tiwai@suse.de>2019-02-08 08:12:15 -0500
commit36e4617c01153757cde9e5fcd375a75a8f8425c3 (patch)
tree3c95a8e5efc6cd1616bd3eadda68cb27101688b3
parent0b2338a9bf36b5ac6ed43425e2f1357fb3d3841b (diff)
parent62e94da3e9d8b991a467f376441a805c5d14c9c7 (diff)
Merge branch 'topic/memory-device-fixes-2' into for-next
Pull further device memory allocation cleanups (but no API change yet). Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--drivers/media/pci/solo6x10/solo6x10-g723.c4
-rw-r--r--drivers/media/pci/tw686x/tw686x-audio.c3
-rw-r--r--sound/atmel/ac97c.c4
-rw-r--r--sound/parisc/harmony.c10
-rw-r--r--sound/pci/ad1889.c7
-rw-r--r--sound/pci/aw2/aw2-alsa.c40
-rw-r--r--sound/pci/bt87x.c10
-rw-r--r--sound/pci/ca0106/ca0106_main.c16
-rw-r--r--sound/pci/echoaudio/echoaudio.c16
-rw-r--r--sound/pci/emu10k1/emupcm.c22
-rw-r--r--sound/pci/emu10k1/p16v.c17
-rw-r--r--sound/pci/lx6464es/lx6464es.c8
-rw-r--r--sound/pci/rme9652/hdspm.c20
-rw-r--r--sound/pci/via82xx_modem.c8
-rw-r--r--sound/ppc/snd_ps3.c6
-rw-r--r--sound/sh/aica.c14
-rw-r--r--sound/soc/amd/acp-pcm-dma.c26
-rw-r--r--sound/soc/amd/raven/acp3x-pcm-dma.c9
-rw-r--r--sound/soc/dwc/dwc-pcm.c3
-rw-r--r--sound/soc/intel/atom/sst-mfld-platform-pcm.c9
-rw-r--r--sound/soc/intel/baytrail/sst-baytrail-pcm.c15
-rw-r--r--sound/soc/intel/haswell/sst-haswell-pcm.c10
-rw-r--r--sound/soc/intel/skylake/skl-pcm.c9
-rw-r--r--sound/soc/mediatek/common/mtk-afe-platform-driver.c6
-rw-r--r--sound/soc/meson/axg-fifo.c7
-rw-r--r--sound/soc/sh/fsi.c3
-rw-r--r--sound/soc/sh/rcar/core.c5
-rw-r--r--sound/soc/sh/siu_pcm.c13
-rw-r--r--sound/soc/soc-generic-dmaengine-pcm.c5
-rw-r--r--sound/soc/stm/stm32_adfsdm.c5
-rw-r--r--sound/soc/txx9/txx9aclc.c4
-rw-r--r--sound/soc/uniphier/aio-dma.c3
-rw-r--r--sound/soc/xtensa/xtfpga-i2s.c6
-rw-r--r--sound/sparc/dbri.c9
-rw-r--r--sound/spi/at73c213.c2
-rw-r--r--sound/usb/usx2y/usbusx2yaudio.c21
-rw-r--r--sound/usb/usx2y/usx2yhwdeppcm.c19
37 files changed, 148 insertions, 246 deletions
diff --git a/drivers/media/pci/solo6x10/solo6x10-g723.c b/drivers/media/pci/solo6x10/solo6x10-g723.c
index 2cc05a9d57ac..a16242a9206f 100644
--- a/drivers/media/pci/solo6x10/solo6x10-g723.c
+++ b/drivers/media/pci/solo6x10/solo6x10-g723.c
@@ -360,13 +360,11 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
360 ss; ss = ss->next, i++) 360 ss; ss = ss->next, i++)
361 sprintf(ss->name, "Camera #%d Audio", i); 361 sprintf(ss->name, "Camera #%d Audio", i);
362 362
363 ret = snd_pcm_lib_preallocate_pages_for_all(pcm, 363 snd_pcm_lib_preallocate_pages_for_all(pcm,
364 SNDRV_DMA_TYPE_CONTINUOUS, 364 SNDRV_DMA_TYPE_CONTINUOUS,
365 snd_dma_continuous_data(GFP_KERNEL), 365 snd_dma_continuous_data(GFP_KERNEL),
366 G723_PERIOD_BYTES * PERIODS, 366 G723_PERIOD_BYTES * PERIODS,
367 G723_PERIOD_BYTES * PERIODS); 367 G723_PERIOD_BYTES * PERIODS);
368 if (ret < 0)
369 return ret;
370 368
371 solo_dev->snd_pcm = pcm; 369 solo_dev->snd_pcm = pcm;
372 370
diff --git a/drivers/media/pci/tw686x/tw686x-audio.c b/drivers/media/pci/tw686x/tw686x-audio.c
index a28329698e20..fb0e7573b5ae 100644
--- a/drivers/media/pci/tw686x/tw686x-audio.c
+++ b/drivers/media/pci/tw686x/tw686x-audio.c
@@ -301,11 +301,12 @@ static int tw686x_snd_pcm_init(struct tw686x_dev *dev)
301 ss; ss = ss->next, i++) 301 ss; ss = ss->next, i++)
302 snprintf(ss->name, sizeof(ss->name), "vch%u audio", i); 302 snprintf(ss->name, sizeof(ss->name), "vch%u audio", i);
303 303
304 return snd_pcm_lib_preallocate_pages_for_all(pcm, 304 snd_pcm_lib_preallocate_pages_for_all(pcm,
305 SNDRV_DMA_TYPE_DEV, 305 SNDRV_DMA_TYPE_DEV,
306 snd_dma_pci_data(dev->pci_dev), 306 snd_dma_pci_data(dev->pci_dev),
307 TW686X_AUDIO_PAGE_MAX * AUDIO_DMA_SIZE_MAX, 307 TW686X_AUDIO_PAGE_MAX * AUDIO_DMA_SIZE_MAX,
308 TW686X_AUDIO_PAGE_MAX * AUDIO_DMA_SIZE_MAX); 308 TW686X_AUDIO_PAGE_MAX * AUDIO_DMA_SIZE_MAX);
309 return 0;
309} 310}
310 311
311static void tw686x_audio_dma_free(struct tw686x_dev *dev, 312static void tw686x_audio_dma_free(struct tw686x_dev *dev,
diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c
index 380025887aef..33c87a0547a9 100644
--- a/sound/atmel/ac97c.c
+++ b/sound/atmel/ac97c.c
@@ -603,11 +603,9 @@ static int atmel_ac97c_pcm_new(struct atmel_ac97c *chip)
603 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &atmel_ac97_capture_ops); 603 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &atmel_ac97_capture_ops);
604 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &atmel_ac97_playback_ops); 604 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &atmel_ac97_playback_ops);
605 605
606 retval = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 606 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
607 &chip->pdev->dev, hw.periods_min * hw.period_bytes_min, 607 &chip->pdev->dev, hw.periods_min * hw.period_bytes_min,
608 hw.buffer_bytes_max); 608 hw.buffer_bytes_max);
609 if (retval)
610 return retval;
611 609
612 pcm->private_data = chip; 610 pcm->private_data = chip;
613 pcm->info_flags = 0; 611 pcm->info_flags = 0;
diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c
index f36e7006e00c..a4264b8943f0 100644
--- a/sound/parisc/harmony.c
+++ b/sound/parisc/harmony.c
@@ -669,14 +669,8 @@ snd_harmony_pcm_init(struct snd_harmony *h)
669 } 669 }
670 670
671 /* pre-allocate space for DMA */ 671 /* pre-allocate space for DMA */
672 err = snd_pcm_lib_preallocate_pages_for_all(pcm, h->dma.type, 672 snd_pcm_lib_preallocate_pages_for_all(pcm, h->dma.type, h->dma.dev,
673 h->dma.dev, 673 MAX_BUF_SIZE, MAX_BUF_SIZE);
674 MAX_BUF_SIZE,
675 MAX_BUF_SIZE);
676 if (err < 0) {
677 printk(KERN_ERR PFX "buffer allocation error: %d\n", err);
678 return err;
679 }
680 674
681 h->st.format = snd_harmony_set_data_format(h, 675 h->st.format = snd_harmony_set_data_format(h,
682 SNDRV_PCM_FORMAT_S16_BE, 1); 676 SNDRV_PCM_FORMAT_S16_BE, 1);
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index f333bbf41870..fef07ae648e6 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -644,16 +644,11 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device)
644 chip->psubs = NULL; 644 chip->psubs = NULL;
645 chip->csubs = NULL; 645 chip->csubs = NULL;
646 646
647 err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 647 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
648 snd_dma_pci_data(chip->pci), 648 snd_dma_pci_data(chip->pci),
649 BUFFER_BYTES_MAX / 2, 649 BUFFER_BYTES_MAX / 2,
650 BUFFER_BYTES_MAX); 650 BUFFER_BYTES_MAX);
651 651
652 if (err < 0) {
653 dev_err(chip->card->dev, "buffer allocation error: %d\n", err);
654 return err;
655 }
656
657 return 0; 652 return 0;
658} 653}
659 654
diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c
index 9a49e4243a9c..b07c5fc1da56 100644
--- a/sound/pci/aw2/aw2-alsa.c
+++ b/sound/pci/aw2/aw2-alsa.c
@@ -624,15 +624,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
624 624
625 /* pre-allocation of buffers */ 625 /* pre-allocation of buffers */
626 /* Preallocate continuous pages. */ 626 /* Preallocate continuous pages. */
627 err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana, 627 snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana,
628 SNDRV_DMA_TYPE_DEV, 628 SNDRV_DMA_TYPE_DEV,
629 snd_dma_pci_data 629 snd_dma_pci_data(chip->pci),
630 (chip->pci), 630 64 * 1024, 64 * 1024);
631 64 * 1024, 64 * 1024);
632 if (err)
633 dev_err(chip->card->dev,
634 "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
635 err);
636 631
637 err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0, 632 err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0,
638 &pcm_playback_num); 633 &pcm_playback_num);
@@ -661,15 +656,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
661 656
662 /* pre-allocation of buffers */ 657 /* pre-allocation of buffers */
663 /* Preallocate continuous pages. */ 658 /* Preallocate continuous pages. */
664 err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num, 659 snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num,
665 SNDRV_DMA_TYPE_DEV, 660 SNDRV_DMA_TYPE_DEV,
666 snd_dma_pci_data 661 snd_dma_pci_data(chip->pci),
667 (chip->pci), 662 64 * 1024, 64 * 1024);
668 64 * 1024, 64 * 1024);
669 if (err)
670 dev_err(chip->card->dev,
671 "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
672 err);
673 663
674 err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1, 664 err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1,
675 &pcm_capture); 665 &pcm_capture);
@@ -699,16 +689,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
699 689
700 /* pre-allocation of buffers */ 690 /* pre-allocation of buffers */
701 /* Preallocate continuous pages. */ 691 /* Preallocate continuous pages. */
702 err = snd_pcm_lib_preallocate_pages_for_all(pcm_capture, 692 snd_pcm_lib_preallocate_pages_for_all(pcm_capture,
703 SNDRV_DMA_TYPE_DEV, 693 SNDRV_DMA_TYPE_DEV,
704 snd_dma_pci_data 694 snd_dma_pci_data(chip->pci),
705 (chip->pci), 695 64 * 1024, 64 * 1024);
706 64 * 1024, 64 * 1024);
707 if (err)
708 dev_err(chip->card->dev,
709 "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
710 err);
711
712 696
713 /* Create control */ 697 /* Create control */
714 err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip)); 698 err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip));
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index ba971042f871..0adcba10c067 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -714,11 +714,11 @@ static int snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *name)
714 pcm->private_data = chip; 714 pcm->private_data = chip;
715 strcpy(pcm->name, name); 715 strcpy(pcm->name, name);
716 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_bt87x_pcm_ops); 716 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_bt87x_pcm_ops);
717 return snd_pcm_lib_preallocate_pages_for_all(pcm, 717 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
718 SNDRV_DMA_TYPE_DEV_SG, 718 snd_dma_pci_data(chip->pci),
719 snd_dma_pci_data(chip->pci), 719 128 * 1024,
720 128 * 1024, 720 ALIGN(255 * 4092, 1024));
721 ALIGN(255 * 4092, 1024)); 721 return 0;
722} 722}
723 723
724static int snd_bt87x_create(struct snd_card *card, 724static int snd_bt87x_create(struct snd_card *card,
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 3d1b0bbff33b..11ef0d636405 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -1402,21 +1402,17 @@ static int snd_ca0106_pcm(struct snd_ca0106 *emu, int device)
1402 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; 1402 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
1403 substream; 1403 substream;
1404 substream = substream->next) { 1404 substream = substream->next) {
1405 if ((err = snd_pcm_lib_preallocate_pages(substream, 1405 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
1406 SNDRV_DMA_TYPE_DEV, 1406 snd_dma_pci_data(emu->pci),
1407 snd_dma_pci_data(emu->pci), 1407 64*1024, 64*1024);
1408 64*1024, 64*1024)) < 0) /* FIXME: 32*1024 for sound buffer, between 32and64 for Periods table. */
1409 return err;
1410 } 1408 }
1411 1409
1412 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; 1410 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
1413 substream; 1411 substream;
1414 substream = substream->next) { 1412 substream = substream->next) {
1415 if ((err = snd_pcm_lib_preallocate_pages(substream, 1413 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
1416 SNDRV_DMA_TYPE_DEV, 1414 snd_dma_pci_data(emu->pci),
1417 snd_dma_pci_data(emu->pci), 1415 64*1024, 64*1024);
1418 64*1024, 64*1024)) < 0)
1419 return err;
1420 } 1416 }
1421 1417
1422 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2, 1418 err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2,
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 18d30d479b6b..ea876b0b02b9 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -884,17 +884,15 @@ static const struct snd_pcm_ops digital_capture_ops = {
884static int snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev) 884static int snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev)
885{ 885{
886 struct snd_pcm_substream *ss; 886 struct snd_pcm_substream *ss;
887 int stream, err; 887 int stream;
888 888
889 for (stream = 0; stream < 2; stream++) 889 for (stream = 0; stream < 2; stream++)
890 for (ss = pcm->streams[stream].substream; ss; ss = ss->next) { 890 for (ss = pcm->streams[stream].substream; ss; ss = ss->next)
891 err = snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG, 891 snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG,
892 dev, 892 dev,
893 ss->number ? 0 : 128<<10, 893 ss->number ? 0 : 128<<10,
894 256<<10); 894 256<<10);
895 if (err < 0) 895
896 return err;
897 }
898 return 0; 896 return 0;
899} 897}
900 898
diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
index 30b3472d0b75..f6b4cb9ac75c 100644
--- a/sound/pci/emu10k1/emupcm.c
+++ b/sound/pci/emu10k1/emupcm.c
@@ -1427,11 +1427,14 @@ int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device)
1427 emu->pcm = pcm; 1427 emu->pcm = pcm;
1428 1428
1429 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) 1429 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
1430 if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) 1430 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG,
1431 return err; 1431 snd_dma_pci_data(emu->pci),
1432 64*1024, 64*1024);
1432 1433
1433 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) 1434 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next)
1434 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1435 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
1436 snd_dma_pci_data(emu->pci),
1437 64*1024, 64*1024);
1435 1438
1436 return 0; 1439 return 0;
1437} 1440}
@@ -1455,8 +1458,9 @@ int snd_emu10k1_pcm_multi(struct snd_emu10k1 *emu, int device)
1455 emu->pcm_multi = pcm; 1458 emu->pcm_multi = pcm;
1456 1459
1457 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) 1460 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
1458 if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) 1461 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG,
1459 return err; 1462 snd_dma_pci_data(emu->pci),
1463 64*1024, 64*1024);
1460 1464
1461 return 0; 1465 return 0;
1462} 1466}
@@ -1489,7 +1493,9 @@ int snd_emu10k1_pcm_mic(struct snd_emu10k1 *emu, int device)
1489 strcpy(pcm->name, "Mic Capture"); 1493 strcpy(pcm->name, "Mic Capture");
1490 emu->pcm_mic = pcm; 1494 emu->pcm_mic = pcm;
1491 1495
1492 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1496 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1497 snd_dma_pci_data(emu->pci),
1498 64*1024, 64*1024);
1493 1499
1494 return 0; 1500 return 0;
1495} 1501}
@@ -1862,7 +1868,9 @@ int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device)
1862 if (err < 0) 1868 if (err < 0)
1863 return err; 1869 return err;
1864 1870
1865 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); 1871 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
1872 snd_dma_pci_data(emu->pci),
1873 64*1024, 64*1024);
1866 1874
1867 return 0; 1875 return 0;
1868} 1876}
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index 4948b95f6665..672017cac4c7 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -656,11 +656,10 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device)
656 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; 656 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
657 substream; 657 substream;
658 substream = substream->next) { 658 substream = substream->next) {
659 if ((err = snd_pcm_lib_preallocate_pages(substream, 659 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
660 SNDRV_DMA_TYPE_DEV, 660 snd_dma_pci_data(emu->pci),
661 snd_dma_pci_data(emu->pci), 661 (65536 - 64) * 8,
662 ((65536 - 64) * 8), ((65536 - 64) * 8))) < 0) 662 (65536 - 64) * 8);
663 return err;
664 /* 663 /*
665 dev_dbg(emu->card->dev, 664 dev_dbg(emu->card->dev,
666 "preallocate playback substream: err=%d\n", err); 665 "preallocate playback substream: err=%d\n", err);
@@ -670,11 +669,9 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device)
670 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; 669 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
671 substream; 670 substream;
672 substream = substream->next) { 671 substream = substream->next) {
673 if ((err = snd_pcm_lib_preallocate_pages(substream, 672 snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
674 SNDRV_DMA_TYPE_DEV, 673 snd_dma_pci_data(emu->pci),
675 snd_dma_pci_data(emu->pci), 674 65536 - 64, 65536 - 64);
676 65536 - 64, 65536 - 64)) < 0)
677 return err;
678 /* 675 /*
679 dev_dbg(emu->card->dev, 676 dev_dbg(emu->card->dev,
680 "preallocate capture substream: err=%d\n", err); 677 "preallocate capture substream: err=%d\n", err);
diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index 198ccf9b5eb3..ae23a2dfbdea 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -854,11 +854,9 @@ static int lx_pcm_create(struct lx6464es *chip)
854 pcm->nonatomic = true; 854 pcm->nonatomic = true;
855 strcpy(pcm->name, card_name); 855 strcpy(pcm->name, card_name);
856 856
857 err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 857 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
858 snd_dma_pci_data(chip->pci), 858 snd_dma_pci_data(chip->pci),
859 size, size); 859 size, size);
860 if (err < 0)
861 return err;
862 860
863 chip->pcm = pcm; 861 chip->pcm = pcm;
864 chip->capture_stream.is_capture = 1; 862 chip->capture_stream.is_capture = 1;
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index d485dd8a7b72..1209cf0b05e0 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -6402,7 +6402,6 @@ static int snd_hdspm_create_hwdep(struct snd_card *card,
6402 ------------------------------------------------------------*/ 6402 ------------------------------------------------------------*/
6403static int snd_hdspm_preallocate_memory(struct hdspm *hdspm) 6403static int snd_hdspm_preallocate_memory(struct hdspm *hdspm)
6404{ 6404{
6405 int err;
6406 struct snd_pcm *pcm; 6405 struct snd_pcm *pcm;
6407 size_t wanted; 6406 size_t wanted;
6408 6407
@@ -6410,21 +6409,10 @@ static int snd_hdspm_preallocate_memory(struct hdspm *hdspm)
6410 6409
6411 wanted = HDSPM_DMA_AREA_BYTES; 6410 wanted = HDSPM_DMA_AREA_BYTES;
6412 6411
6413 err = 6412 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
6414 snd_pcm_lib_preallocate_pages_for_all(pcm, 6413 snd_dma_pci_data(hdspm->pci),
6415 SNDRV_DMA_TYPE_DEV_SG, 6414 wanted, wanted);
6416 snd_dma_pci_data(hdspm->pci), 6415 dev_dbg(hdspm->card->dev, " Preallocated %zd Bytes\n", wanted);
6417 wanted,
6418 wanted);
6419 if (err < 0) {
6420 dev_dbg(hdspm->card->dev,
6421 "Could not preallocate %zd Bytes\n", wanted);
6422
6423 return err;
6424 } else
6425 dev_dbg(hdspm->card->dev,
6426 " Preallocated %zd Bytes\n", wanted);
6427
6428 return 0; 6416 return 0;
6429} 6417}
6430 6418
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index 848bf9dbf8cd..7e0bebce7b77 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -865,11 +865,9 @@ static int snd_via686_pcm_new(struct via82xx_modem *chip)
865 init_viadev(chip, 0, VIA_REG_MO_STATUS, 0); 865 init_viadev(chip, 0, VIA_REG_MO_STATUS, 0);
866 init_viadev(chip, 1, VIA_REG_MI_STATUS, 1); 866 init_viadev(chip, 1, VIA_REG_MI_STATUS, 1);
867 867
868 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, 868 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
869 snd_dma_pci_data(chip->pci), 869 snd_dma_pci_data(chip->pci),
870 64*1024, 128*1024)) < 0) 870 64*1024, 128*1024);
871 return err;
872
873 return 0; 871 return 0;
874} 872}
875 873
diff --git a/sound/ppc/snd_ps3.c b/sound/ppc/snd_ps3.c
index abe031c9d592..521236efcc4d 100644
--- a/sound/ppc/snd_ps3.c
+++ b/sound/ppc/snd_ps3.c
@@ -1024,15 +1024,11 @@ static int snd_ps3_driver_probe(struct ps3_system_bus_device *dev)
1024 1024
1025 the_card.pcm->info_flags = SNDRV_PCM_INFO_NONINTERLEAVED; 1025 the_card.pcm->info_flags = SNDRV_PCM_INFO_NONINTERLEAVED;
1026 /* pre-alloc PCM DMA buffer*/ 1026 /* pre-alloc PCM DMA buffer*/
1027 ret = snd_pcm_lib_preallocate_pages_for_all(the_card.pcm, 1027 snd_pcm_lib_preallocate_pages_for_all(the_card.pcm,
1028 SNDRV_DMA_TYPE_DEV, 1028 SNDRV_DMA_TYPE_DEV,
1029 &dev->core, 1029 &dev->core,
1030 SND_PS3_PCM_PREALLOC_SIZE, 1030 SND_PS3_PCM_PREALLOC_SIZE,
1031 SND_PS3_PCM_PREALLOC_SIZE); 1031 SND_PS3_PCM_PREALLOC_SIZE);
1032 if (ret < 0) {
1033 pr_info("%s: prealloc failed\n", __func__);
1034 goto clean_card;
1035 }
1036 1032
1037 /* 1033 /*
1038 * allocate null buffer 1034 * allocate null buffer
diff --git a/sound/sh/aica.c b/sound/sh/aica.c
index 2b26311405a4..e7fef3fce44a 100644
--- a/sound/sh/aica.c
+++ b/sound/sh/aica.c
@@ -464,14 +464,12 @@ static int __init snd_aicapcmchip(struct snd_card_aica
464 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, 464 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
465 &snd_aicapcm_playback_ops); 465 &snd_aicapcm_playback_ops);
466 /* Allocate the DMA buffers */ 466 /* Allocate the DMA buffers */
467 err = 467 snd_pcm_lib_preallocate_pages_for_all(pcm,
468 snd_pcm_lib_preallocate_pages_for_all(pcm, 468 SNDRV_DMA_TYPE_CONTINUOUS,
469 SNDRV_DMA_TYPE_CONTINUOUS, 469 snd_dma_continuous_data(GFP_KERNEL),
470 snd_dma_continuous_data 470 AICA_BUFFER_SIZE,
471 (GFP_KERNEL), 471 AICA_BUFFER_SIZE);
472 AICA_BUFFER_SIZE, 472 return 0;
473 AICA_BUFFER_SIZE);
474 return err;
475} 473}
476 474
477/* Mixer controls */ 475/* Mixer controls */
diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c
index f4011bebc7ec..2391c7f1dd2d 100644
--- a/sound/soc/amd/acp-pcm-dma.c
+++ b/sound/soc/amd/acp-pcm-dma.c
@@ -1142,7 +1142,6 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd)
1142 1142
1143static int acp_dma_new(struct snd_soc_pcm_runtime *rtd) 1143static int acp_dma_new(struct snd_soc_pcm_runtime *rtd)
1144{ 1144{
1145 int ret;
1146 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, 1145 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd,
1147 DRV_NAME); 1146 DRV_NAME);
1148 struct audio_drv_data *adata = dev_get_drvdata(component->dev); 1147 struct audio_drv_data *adata = dev_get_drvdata(component->dev);
@@ -1150,24 +1149,21 @@ static int acp_dma_new(struct snd_soc_pcm_runtime *rtd)
1150 1149
1151 switch (adata->asic_type) { 1150 switch (adata->asic_type) {
1152 case CHIP_STONEY: 1151 case CHIP_STONEY:
1153 ret = snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, 1152 snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
1154 SNDRV_DMA_TYPE_DEV, 1153 SNDRV_DMA_TYPE_DEV,
1155 parent, 1154 parent,
1156 ST_MIN_BUFFER, 1155 ST_MIN_BUFFER,
1157 ST_MAX_BUFFER); 1156 ST_MAX_BUFFER);
1158 break; 1157 break;
1159 default: 1158 default:
1160 ret = snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, 1159 snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
1161 SNDRV_DMA_TYPE_DEV, 1160 SNDRV_DMA_TYPE_DEV,
1162 parent, 1161 parent,
1163 MIN_BUFFER, 1162 MIN_BUFFER,
1164 MAX_BUFFER); 1163 MAX_BUFFER);
1165 break; 1164 break;
1166 } 1165 }
1167 if (ret < 0) 1166 return 0;
1168 dev_err(component->dev,
1169 "buffer preallocation failure error:%d\n", ret);
1170 return ret;
1171} 1167}
1172 1168
1173static int acp_dma_close(struct snd_pcm_substream *substream) 1169static int acp_dma_close(struct snd_pcm_substream *substream)
diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c
index 3e7d4099364c..1a2e15ff1456 100644
--- a/sound/soc/amd/raven/acp3x-pcm-dma.c
+++ b/sound/soc/amd/raven/acp3x-pcm-dma.c
@@ -367,11 +367,10 @@ static snd_pcm_uframes_t acp3x_dma_pointer(struct snd_pcm_substream *substream)
367 367
368static int acp3x_dma_new(struct snd_soc_pcm_runtime *rtd) 368static int acp3x_dma_new(struct snd_soc_pcm_runtime *rtd)
369{ 369{
370 return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, 370 snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_DEV,
371 SNDRV_DMA_TYPE_DEV, 371 rtd->pcm->card->dev,
372 rtd->pcm->card->dev, 372 MIN_BUFFER, MAX_BUFFER);
373 MIN_BUFFER, 373 return 0;
374 MAX_BUFFER);
375} 374}
376 375
377static int acp3x_dma_hw_free(struct snd_pcm_substream *substream) 376static int acp3x_dma_hw_free(struct snd_pcm_substream *substream)
diff --git a/sound/soc/dwc/dwc-pcm.c b/sound/soc/dwc/dwc-pcm.c
index 2cc9632024fc..a9ae91c4597f 100644
--- a/sound/soc/dwc/dwc-pcm.c
+++ b/sound/soc/dwc/dwc-pcm.c
@@ -249,9 +249,10 @@ static int dw_pcm_new(struct snd_soc_pcm_runtime *rtd)
249{ 249{
250 size_t size = dw_pcm_hardware.buffer_bytes_max; 250 size_t size = dw_pcm_hardware.buffer_bytes_max;
251 251
252 return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, 252 snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
253 SNDRV_DMA_TYPE_CONTINUOUS, 253 SNDRV_DMA_TYPE_CONTINUOUS,
254 snd_dma_continuous_data(GFP_KERNEL), size, size); 254 snd_dma_continuous_data(GFP_KERNEL), size, size);
255 return 0;
255} 256}
256 257
257static void dw_pcm_free(struct snd_pcm *pcm) 258static void dw_pcm_free(struct snd_pcm *pcm)
diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
index 91a2436ce952..985abda3bfbb 100644
--- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c
+++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
@@ -687,20 +687,15 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd)
687{ 687{
688 struct snd_soc_dai *dai = rtd->cpu_dai; 688 struct snd_soc_dai *dai = rtd->cpu_dai;
689 struct snd_pcm *pcm = rtd->pcm; 689 struct snd_pcm *pcm = rtd->pcm;
690 int retval = 0;
691 690
692 if (dai->driver->playback.channels_min || 691 if (dai->driver->playback.channels_min ||
693 dai->driver->capture.channels_min) { 692 dai->driver->capture.channels_min) {
694 retval = snd_pcm_lib_preallocate_pages_for_all(pcm, 693 snd_pcm_lib_preallocate_pages_for_all(pcm,
695 SNDRV_DMA_TYPE_CONTINUOUS, 694 SNDRV_DMA_TYPE_CONTINUOUS,
696 snd_dma_continuous_data(GFP_DMA), 695 snd_dma_continuous_data(GFP_DMA),
697 SST_MIN_BUFFER, SST_MAX_BUFFER); 696 SST_MIN_BUFFER, SST_MAX_BUFFER);
698 if (retval) {
699 dev_err(rtd->dev, "dma buffer allocation failure\n");
700 return retval;
701 }
702 } 697 }
703 return retval; 698 return 0;
704} 699}
705 700
706static int sst_soc_probe(struct snd_soc_component *component) 701static int sst_soc_probe(struct snd_soc_component *component)
diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c
index aabb35bf6b96..aa358073ac0f 100644
--- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c
+++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c
@@ -327,23 +327,16 @@ static int sst_byt_pcm_new(struct snd_soc_pcm_runtime *rtd)
327 size_t size; 327 size_t size;
328 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); 328 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
329 struct sst_pdata *pdata = dev_get_platdata(component->dev); 329 struct sst_pdata *pdata = dev_get_platdata(component->dev);
330 int ret = 0;
331 330
332 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || 331 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream ||
333 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { 332 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
334 size = sst_byt_pcm_hardware.buffer_bytes_max; 333 size = sst_byt_pcm_hardware.buffer_bytes_max;
335 ret = snd_pcm_lib_preallocate_pages_for_all(pcm, 334 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
336 SNDRV_DMA_TYPE_DEV, 335 pdata->dma_dev,
337 pdata->dma_dev, 336 size, size);
338 size, size);
339 if (ret) {
340 dev_err(rtd->dev, "dma buffer allocation failed %d\n",
341 ret);
342 return ret;
343 }
344 } 337 }
345 338
346 return ret; 339 return 0;
347} 340}
348 341
349static struct snd_soc_dai_driver byt_dais[] = { 342static struct snd_soc_dai_driver byt_dais[] = {
diff --git a/sound/soc/intel/haswell/sst-haswell-pcm.c b/sound/soc/intel/haswell/sst-haswell-pcm.c
index fe2c826e710c..f21a7f2c11c2 100644
--- a/sound/soc/intel/haswell/sst-haswell-pcm.c
+++ b/sound/soc/intel/haswell/sst-haswell-pcm.c
@@ -946,27 +946,21 @@ static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd)
946 struct sst_pdata *pdata = dev_get_platdata(component->dev); 946 struct sst_pdata *pdata = dev_get_platdata(component->dev);
947 struct hsw_priv_data *priv_data = dev_get_drvdata(component->dev); 947 struct hsw_priv_data *priv_data = dev_get_drvdata(component->dev);
948 struct device *dev = pdata->dma_dev; 948 struct device *dev = pdata->dma_dev;
949 int ret = 0;
950 949
951 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || 950 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream ||
952 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { 951 pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
953 ret = snd_pcm_lib_preallocate_pages_for_all(pcm, 952 snd_pcm_lib_preallocate_pages_for_all(pcm,
954 SNDRV_DMA_TYPE_DEV_SG, 953 SNDRV_DMA_TYPE_DEV_SG,
955 dev, 954 dev,
956 hsw_pcm_hardware.buffer_bytes_max, 955 hsw_pcm_hardware.buffer_bytes_max,
957 hsw_pcm_hardware.buffer_bytes_max); 956 hsw_pcm_hardware.buffer_bytes_max);
958 if (ret) {
959 dev_err(rtd->dev, "dma buffer allocation failed %d\n",
960 ret);
961 return ret;
962 }
963 } 957 }
964 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) 958 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream)
965 priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_PLAYBACK].hsw_pcm = pcm; 959 priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_PLAYBACK].hsw_pcm = pcm;
966 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) 960 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream)
967 priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_CAPTURE].hsw_pcm = pcm; 961 priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_CAPTURE].hsw_pcm = pcm;
968 962
969 return ret; 963 return 0;
970} 964}
971 965
972#define HSW_FORMATS \ 966#define HSW_FORMATS \
diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 557f80c0bfe5..20c88c677473 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -1289,7 +1289,6 @@ static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd)
1289 struct hdac_bus *bus = dev_get_drvdata(dai->dev); 1289 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
1290 struct snd_pcm *pcm = rtd->pcm; 1290 struct snd_pcm *pcm = rtd->pcm;
1291 unsigned int size; 1291 unsigned int size;
1292 int retval = 0;
1293 struct skl *skl = bus_to_skl(bus); 1292 struct skl *skl = bus_to_skl(bus);
1294 1293
1295 if (dai->driver->playback.channels_min || 1294 if (dai->driver->playback.channels_min ||
@@ -1298,17 +1297,13 @@ static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd)
1298 size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024; 1297 size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
1299 if (size > MAX_PREALLOC_SIZE) 1298 if (size > MAX_PREALLOC_SIZE)
1300 size = MAX_PREALLOC_SIZE; 1299 size = MAX_PREALLOC_SIZE;
1301 retval = snd_pcm_lib_preallocate_pages_for_all(pcm, 1300 snd_pcm_lib_preallocate_pages_for_all(pcm,
1302 SNDRV_DMA_TYPE_DEV_SG, 1301 SNDRV_DMA_TYPE_DEV_SG,
1303 snd_dma_pci_data(skl->pci), 1302 snd_dma_pci_data(skl->pci),
1304 size, MAX_PREALLOC_SIZE); 1303 size, MAX_PREALLOC_SIZE);
1305 if (retval) {
1306 dev_err(dai->dev, "dma buffer allocation fail\n");
1307 return retval;
1308 }
1309 } 1304 }
1310 1305
1311 return retval; 1306 return 0;
1312} 1307}
1313 1308
1314static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig) 1309static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig)
diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
index 697aa50aff9a..3ce527ce30ce 100644
--- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c
+++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
@@ -126,9 +126,9 @@ int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd)
126 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); 126 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
127 127
128 size = afe->mtk_afe_hardware->buffer_bytes_max; 128 size = afe->mtk_afe_hardware->buffer_bytes_max;
129 return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 129 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
130 afe->dev, 130 afe->dev, size, size);
131 size, size); 131 return 0;
132} 132}
133EXPORT_SYMBOL_GPL(mtk_afe_pcm_new); 133EXPORT_SYMBOL_GPL(mtk_afe_pcm_new);
134 134
diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c
index 0e4f65e654c4..75e5e480fda2 100644
--- a/sound/soc/meson/axg-fifo.c
+++ b/sound/soc/meson/axg-fifo.c
@@ -267,9 +267,10 @@ int axg_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd, unsigned int type)
267 struct snd_card *card = rtd->card->snd_card; 267 struct snd_card *card = rtd->card->snd_card;
268 size_t size = axg_fifo_hw.buffer_bytes_max; 268 size_t size = axg_fifo_hw.buffer_bytes_max;
269 269
270 return snd_pcm_lib_preallocate_pages(rtd->pcm->streams[type].substream, 270 snd_pcm_lib_preallocate_pages(rtd->pcm->streams[type].substream,
271 SNDRV_DMA_TYPE_DEV, card->dev, 271 SNDRV_DMA_TYPE_DEV, card->dev,
272 size, size); 272 size, size);
273 return 0;
273} 274}
274EXPORT_SYMBOL_GPL(axg_fifo_pcm_new); 275EXPORT_SYMBOL_GPL(axg_fifo_pcm_new);
275 276
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index aa7e902f0c02..285afbafa662 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -1768,11 +1768,12 @@ static const struct snd_pcm_ops fsi_pcm_ops = {
1768 1768
1769static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd) 1769static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd)
1770{ 1770{
1771 return snd_pcm_lib_preallocate_pages_for_all( 1771 snd_pcm_lib_preallocate_pages_for_all(
1772 rtd->pcm, 1772 rtd->pcm,
1773 SNDRV_DMA_TYPE_DEV, 1773 SNDRV_DMA_TYPE_DEV,
1774 rtd->card->snd_card->dev, 1774 rtd->card->snd_card->dev,
1775 PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); 1775 PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
1776 return 0;
1776} 1777}
1777 1778
1778/* 1779/*
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 59e250cc2e9d..29213b90755f 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -1575,7 +1575,6 @@ static int rsnd_preallocate_pages(struct snd_soc_pcm_runtime *rtd,
1575 struct rsnd_priv *priv = rsnd_io_to_priv(io); 1575 struct rsnd_priv *priv = rsnd_io_to_priv(io);
1576 struct device *dev = rsnd_priv_to_dev(priv); 1576 struct device *dev = rsnd_priv_to_dev(priv);
1577 struct snd_pcm_substream *substream; 1577 struct snd_pcm_substream *substream;
1578 int err;
1579 1578
1580 /* 1579 /*
1581 * use Audio-DMAC dev if we can use IPMMU 1580 * use Audio-DMAC dev if we can use IPMMU
@@ -1588,12 +1587,10 @@ static int rsnd_preallocate_pages(struct snd_soc_pcm_runtime *rtd,
1588 for (substream = rtd->pcm->streams[stream].substream; 1587 for (substream = rtd->pcm->streams[stream].substream;
1589 substream; 1588 substream;
1590 substream = substream->next) { 1589 substream = substream->next) {
1591 err = snd_pcm_lib_preallocate_pages(substream, 1590 snd_pcm_lib_preallocate_pages(substream,
1592 SNDRV_DMA_TYPE_DEV, 1591 SNDRV_DMA_TYPE_DEV,
1593 dev, 1592 dev,
1594 PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); 1593 PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
1595 if (err < 0)
1596 return err;
1597 } 1594 }
1598 1595
1599 return 0; 1596 return 0;
diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c
index 23384c477740..78c3145b4109 100644
--- a/sound/soc/sh/siu_pcm.c
+++ b/sound/soc/sh/siu_pcm.c
@@ -541,15 +541,9 @@ static int siu_pcm_new(struct snd_soc_pcm_runtime *rtd)
541 if (ret < 0) 541 if (ret < 0)
542 return ret; 542 return ret;
543 543
544 ret = snd_pcm_lib_preallocate_pages_for_all(pcm, 544 snd_pcm_lib_preallocate_pages_for_all(pcm,
545 SNDRV_DMA_TYPE_DEV, card->dev, 545 SNDRV_DMA_TYPE_DEV, card->dev,
546 SIU_BUFFER_BYTES_MAX, SIU_BUFFER_BYTES_MAX); 546 SIU_BUFFER_BYTES_MAX, SIU_BUFFER_BYTES_MAX);
547 if (ret < 0) {
548 dev_err(card->dev,
549 "snd_pcm_lib_preallocate_pages_for_all() err=%d",
550 ret);
551 goto fail;
552 }
553 547
554 (*port_info)->pcm = pcm; 548 (*port_info)->pcm = pcm;
555 549
@@ -562,11 +556,6 @@ static int siu_pcm_new(struct snd_soc_pcm_runtime *rtd)
562 556
563 dev_info(card->dev, "SuperH SIU driver initialized.\n"); 557 dev_info(card->dev, "SuperH SIU driver initialized.\n");
564 return 0; 558 return 0;
565
566fail:
567 siu_free_port(siu_ports[pdev->id]);
568 dev_err(card->dev, "SIU: failed to initialize.\n");
569 return ret;
570} 559}
571 560
572static void siu_pcm_free(struct snd_pcm *pcm) 561static void siu_pcm_free(struct snd_pcm *pcm)
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
index 30e791a53352..46252b13d3b3 100644
--- a/sound/soc/soc-generic-dmaengine-pcm.c
+++ b/sound/soc/soc-generic-dmaengine-pcm.c
@@ -270,7 +270,6 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
270 size_t prealloc_buffer_size; 270 size_t prealloc_buffer_size;
271 size_t max_buffer_size; 271 size_t max_buffer_size;
272 unsigned int i; 272 unsigned int i;
273 int ret;
274 273
275 if (config && config->prealloc_buffer_size) { 274 if (config && config->prealloc_buffer_size) {
276 prealloc_buffer_size = config->prealloc_buffer_size; 275 prealloc_buffer_size = config->prealloc_buffer_size;
@@ -303,13 +302,11 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
303 return -EINVAL; 302 return -EINVAL;
304 } 303 }
305 304
306 ret = snd_pcm_lib_preallocate_pages(substream, 305 snd_pcm_lib_preallocate_pages(substream,
307 SNDRV_DMA_TYPE_DEV_IRAM, 306 SNDRV_DMA_TYPE_DEV_IRAM,
308 dmaengine_dma_dev(pcm, substream), 307 dmaengine_dma_dev(pcm, substream),
309 prealloc_buffer_size, 308 prealloc_buffer_size,
310 max_buffer_size); 309 max_buffer_size);
311 if (ret)
312 return ret;
313 310
314 if (!dmaengine_pcm_can_report_residue(dev, pcm->chan[i])) 311 if (!dmaengine_pcm_can_report_residue(dev, pcm->chan[i]))
315 pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE; 312 pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE;
diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c
index 706ff005234f..47901983a6ff 100644
--- a/sound/soc/stm/stm32_adfsdm.c
+++ b/sound/soc/stm/stm32_adfsdm.c
@@ -262,8 +262,9 @@ static int stm32_adfsdm_pcm_new(struct snd_soc_pcm_runtime *rtd)
262 snd_soc_dai_get_drvdata(rtd->cpu_dai); 262 snd_soc_dai_get_drvdata(rtd->cpu_dai);
263 unsigned int size = DFSDM_MAX_PERIODS * DFSDM_MAX_PERIOD_SIZE; 263 unsigned int size = DFSDM_MAX_PERIODS * DFSDM_MAX_PERIOD_SIZE;
264 264
265 return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 265 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
266 priv->dev, size, size); 266 priv->dev, size, size);
267 return 0;
267} 268}
268 269
269static void stm32_adfsdm_pcm_free(struct snd_pcm *pcm) 270static void stm32_adfsdm_pcm_free(struct snd_pcm *pcm)
diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c
index 8d31fe628e2f..089bd7518606 100644
--- a/sound/soc/txx9/txx9aclc.c
+++ b/sound/soc/txx9/txx9aclc.c
@@ -313,8 +313,10 @@ static int txx9aclc_pcm_new(struct snd_soc_pcm_runtime *rtd)
313 if (ret) 313 if (ret)
314 goto exit; 314 goto exit;
315 } 315 }
316 return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 316
317 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
317 card->dev, 64 * 1024, 4 * 1024 * 1024); 318 card->dev, 64 * 1024, 4 * 1024 * 1024);
319 return 0;
318 320
319exit: 321exit:
320 for (i = 0; i < 2; i++) { 322 for (i = 0; i < 2; i++) {
diff --git a/sound/soc/uniphier/aio-dma.c b/sound/soc/uniphier/aio-dma.c
index 4ec6b65bfb44..fa001d3c1a88 100644
--- a/sound/soc/uniphier/aio-dma.c
+++ b/sound/soc/uniphier/aio-dma.c
@@ -235,10 +235,11 @@ static int uniphier_aiodma_new(struct snd_soc_pcm_runtime *rtd)
235 if (ret) 235 if (ret)
236 return ret; 236 return ret;
237 237
238 return snd_pcm_lib_preallocate_pages_for_all(pcm, 238 snd_pcm_lib_preallocate_pages_for_all(pcm,
239 SNDRV_DMA_TYPE_DEV, dev, 239 SNDRV_DMA_TYPE_DEV, dev,
240 uniphier_aiodma_hw.buffer_bytes_max, 240 uniphier_aiodma_hw.buffer_bytes_max,
241 uniphier_aiodma_hw.buffer_bytes_max); 241 uniphier_aiodma_hw.buffer_bytes_max);
242 return 0;
242} 243}
243 244
244static void uniphier_aiodma_free(struct snd_pcm *pcm) 245static void uniphier_aiodma_free(struct snd_pcm *pcm)
diff --git a/sound/soc/xtensa/xtfpga-i2s.c b/sound/soc/xtensa/xtfpga-i2s.c
index 503560916620..2f20a02c8d46 100644
--- a/sound/soc/xtensa/xtfpga-i2s.c
+++ b/sound/soc/xtensa/xtfpga-i2s.c
@@ -469,9 +469,9 @@ static int xtfpga_pcm_new(struct snd_soc_pcm_runtime *rtd)
469 struct snd_card *card = rtd->card->snd_card; 469 struct snd_card *card = rtd->card->snd_card;
470 size_t size = xtfpga_pcm_hardware.buffer_bytes_max; 470 size_t size = xtfpga_pcm_hardware.buffer_bytes_max;
471 471
472 return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, 472 snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_DEV,
473 SNDRV_DMA_TYPE_DEV, 473 card->dev, size, size);
474 card->dev, size, size); 474 return 0;
475} 475}
476 476
477static const struct snd_pcm_ops xtfpga_pcm_ops = { 477static const struct snd_pcm_ops xtfpga_pcm_ops = {
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c
index 682166202098..5e36d9bc971d 100644
--- a/sound/sparc/dbri.c
+++ b/sound/sparc/dbri.c
@@ -2243,12 +2243,9 @@ static int snd_dbri_pcm(struct snd_card *card)
2243 pcm->info_flags = 0; 2243 pcm->info_flags = 0;
2244 strcpy(pcm->name, card->shortname); 2244 strcpy(pcm->name, card->shortname);
2245 2245
2246 if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, 2246 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
2247 SNDRV_DMA_TYPE_CONTINUOUS, 2247 snd_dma_continuous_data(GFP_KERNEL),
2248 snd_dma_continuous_data(GFP_KERNEL), 2248 64 * 1024, 64 * 1024);
2249 64 * 1024, 64 * 1024)) < 0)
2250 return err;
2251
2252 return 0; 2249 return 0;
2253} 2250}
2254 2251
diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c
index 1ef52edeb538..8707e0108471 100644
--- a/sound/spi/at73c213.c
+++ b/sound/spi/at73c213.c
@@ -350,7 +350,7 @@ static int snd_at73c213_pcm_new(struct snd_at73c213 *chip, int device)
350 350
351 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &at73c213_playback_ops); 351 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &at73c213_playback_ops);
352 352
353 retval = snd_pcm_lib_preallocate_pages_for_all(chip->pcm, 353 snd_pcm_lib_preallocate_pages_for_all(chip->pcm,
354 SNDRV_DMA_TYPE_DEV, &chip->ssc->pdev->dev, 354 SNDRV_DMA_TYPE_DEV, &chip->ssc->pdev->dev,
355 64 * 1024, 64 * 1024); 355 64 * 1024, 64 * 1024);
356out: 356out:
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
index 2b833054e3b0..58974d094b27 100644
--- a/sound/usb/usx2y/usbusx2yaudio.c
+++ b/sound/usb/usx2y/usbusx2yaudio.c
@@ -981,18 +981,17 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint,
981 981
982 sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->pcm_devs); 982 sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->pcm_devs);
983 983
984 if ((playback_endpoint && 984 if (playback_endpoint) {
985 0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, 985 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
986 SNDRV_DMA_TYPE_CONTINUOUS, 986 SNDRV_DMA_TYPE_CONTINUOUS,
987 snd_dma_continuous_data(GFP_KERNEL), 987 snd_dma_continuous_data(GFP_KERNEL),
988 64*1024, 128*1024))) || 988 64*1024, 128*1024);
989 0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
990 SNDRV_DMA_TYPE_CONTINUOUS,
991 snd_dma_continuous_data(GFP_KERNEL),
992 64*1024, 128*1024))) {
993 snd_usX2Y_pcm_private_free(pcm);
994 return err;
995 } 989 }
990
991 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
992 SNDRV_DMA_TYPE_CONTINUOUS,
993 snd_dma_continuous_data(GFP_KERNEL),
994 64*1024, 128*1024);
996 usX2Y(card)->pcm_devs++; 995 usX2Y(card)->pcm_devs++;
997 996
998 return 0; 997 return 0;
diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c
index 4fd9276b8e50..714cf50d4a4c 100644
--- a/sound/usb/usx2y/usx2yhwdeppcm.c
+++ b/sound/usb/usx2y/usx2yhwdeppcm.c
@@ -736,17 +736,14 @@ int usX2Y_hwdep_pcm_new(struct snd_card *card)
736 pcm->info_flags = 0; 736 pcm->info_flags = 0;
737 737
738 sprintf(pcm->name, NAME_ALLCAPS" hwdep Audio"); 738 sprintf(pcm->name, NAME_ALLCAPS" hwdep Audio");
739 if (0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, 739 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
740 SNDRV_DMA_TYPE_CONTINUOUS, 740 SNDRV_DMA_TYPE_CONTINUOUS,
741 snd_dma_continuous_data(GFP_KERNEL), 741 snd_dma_continuous_data(GFP_KERNEL),
742 64*1024, 128*1024)) || 742 64*1024, 128*1024);
743 0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, 743 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
744 SNDRV_DMA_TYPE_CONTINUOUS, 744 SNDRV_DMA_TYPE_CONTINUOUS,
745 snd_dma_continuous_data(GFP_KERNEL), 745 snd_dma_continuous_data(GFP_KERNEL),
746 64*1024, 128*1024))) { 746 64*1024, 128*1024);
747 return err;
748 }
749
750 747
751 return 0; 748 return 0;
752} 749}