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>
This commit is contained in:
Takashi Iwai 2019-02-08 14:12:15 +01:00
Родитель 0b2338a9bf 62e94da3e9
Коммит 36e4617c01
37 изменённых файлов: 148 добавлений и 246 удалений

Просмотреть файл

@ -360,13 +360,11 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
ss; ss = ss->next, i++) ss; ss = ss->next, i++)
sprintf(ss->name, "Camera #%d Audio", i); sprintf(ss->name, "Camera #%d Audio", i);
ret = snd_pcm_lib_preallocate_pages_for_all(pcm, snd_pcm_lib_preallocate_pages_for_all(pcm,
SNDRV_DMA_TYPE_CONTINUOUS, SNDRV_DMA_TYPE_CONTINUOUS,
snd_dma_continuous_data(GFP_KERNEL), snd_dma_continuous_data(GFP_KERNEL),
G723_PERIOD_BYTES * PERIODS, G723_PERIOD_BYTES * PERIODS,
G723_PERIOD_BYTES * PERIODS); G723_PERIOD_BYTES * PERIODS);
if (ret < 0)
return ret;
solo_dev->snd_pcm = pcm; solo_dev->snd_pcm = pcm;

Просмотреть файл

@ -301,11 +301,12 @@ static int tw686x_snd_pcm_init(struct tw686x_dev *dev)
ss; ss = ss->next, i++) ss; ss = ss->next, i++)
snprintf(ss->name, sizeof(ss->name), "vch%u audio", i); snprintf(ss->name, sizeof(ss->name), "vch%u audio", i);
return snd_pcm_lib_preallocate_pages_for_all(pcm, snd_pcm_lib_preallocate_pages_for_all(pcm,
SNDRV_DMA_TYPE_DEV, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(dev->pci_dev), snd_dma_pci_data(dev->pci_dev),
TW686X_AUDIO_PAGE_MAX * AUDIO_DMA_SIZE_MAX, TW686X_AUDIO_PAGE_MAX * AUDIO_DMA_SIZE_MAX,
TW686X_AUDIO_PAGE_MAX * AUDIO_DMA_SIZE_MAX); TW686X_AUDIO_PAGE_MAX * AUDIO_DMA_SIZE_MAX);
return 0;
} }
static void tw686x_audio_dma_free(struct tw686x_dev *dev, static void tw686x_audio_dma_free(struct tw686x_dev *dev,

Просмотреть файл

@ -603,11 +603,9 @@ static int atmel_ac97c_pcm_new(struct atmel_ac97c *chip)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &atmel_ac97_capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &atmel_ac97_capture_ops);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &atmel_ac97_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &atmel_ac97_playback_ops);
retval = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
&chip->pdev->dev, hw.periods_min * hw.period_bytes_min, &chip->pdev->dev, hw.periods_min * hw.period_bytes_min,
hw.buffer_bytes_max); hw.buffer_bytes_max);
if (retval)
return retval;
pcm->private_data = chip; pcm->private_data = chip;
pcm->info_flags = 0; pcm->info_flags = 0;

Просмотреть файл

@ -669,14 +669,8 @@ snd_harmony_pcm_init(struct snd_harmony *h)
} }
/* pre-allocate space for DMA */ /* pre-allocate space for DMA */
err = snd_pcm_lib_preallocate_pages_for_all(pcm, h->dma.type, snd_pcm_lib_preallocate_pages_for_all(pcm, h->dma.type, h->dma.dev,
h->dma.dev, MAX_BUF_SIZE, MAX_BUF_SIZE);
MAX_BUF_SIZE,
MAX_BUF_SIZE);
if (err < 0) {
printk(KERN_ERR PFX "buffer allocation error: %d\n", err);
return err;
}
h->st.format = snd_harmony_set_data_format(h, h->st.format = snd_harmony_set_data_format(h,
SNDRV_PCM_FORMAT_S16_BE, 1); SNDRV_PCM_FORMAT_S16_BE, 1);

Просмотреть файл

@ -644,16 +644,11 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device)
chip->psubs = NULL; chip->psubs = NULL;
chip->csubs = NULL; chip->csubs = NULL;
err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(chip->pci), snd_dma_pci_data(chip->pci),
BUFFER_BYTES_MAX / 2, BUFFER_BYTES_MAX / 2,
BUFFER_BYTES_MAX); BUFFER_BYTES_MAX);
if (err < 0) {
dev_err(chip->card->dev, "buffer allocation error: %d\n", err);
return err;
}
return 0; return 0;
} }

Просмотреть файл

@ -624,15 +624,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
/* pre-allocation of buffers */ /* pre-allocation of buffers */
/* Preallocate continuous pages. */ /* Preallocate continuous pages. */
err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana, snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana,
SNDRV_DMA_TYPE_DEV, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data snd_dma_pci_data(chip->pci),
(chip->pci), 64 * 1024, 64 * 1024);
64 * 1024, 64 * 1024);
if (err)
dev_err(chip->card->dev,
"snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
err);
err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0, err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0,
&pcm_playback_num); &pcm_playback_num);
@ -661,15 +656,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
/* pre-allocation of buffers */ /* pre-allocation of buffers */
/* Preallocate continuous pages. */ /* Preallocate continuous pages. */
err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num, snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num,
SNDRV_DMA_TYPE_DEV, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data snd_dma_pci_data(chip->pci),
(chip->pci), 64 * 1024, 64 * 1024);
64 * 1024, 64 * 1024);
if (err)
dev_err(chip->card->dev,
"snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
err);
err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1, err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1,
&pcm_capture); &pcm_capture);
@ -699,16 +689,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
/* pre-allocation of buffers */ /* pre-allocation of buffers */
/* Preallocate continuous pages. */ /* Preallocate continuous pages. */
err = snd_pcm_lib_preallocate_pages_for_all(pcm_capture, snd_pcm_lib_preallocate_pages_for_all(pcm_capture,
SNDRV_DMA_TYPE_DEV, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data snd_dma_pci_data(chip->pci),
(chip->pci), 64 * 1024, 64 * 1024);
64 * 1024, 64 * 1024);
if (err)
dev_err(chip->card->dev,
"snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
err);
/* Create control */ /* Create control */
err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip)); err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip));

Просмотреть файл

@ -714,11 +714,11 @@ static int snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *name)
pcm->private_data = chip; pcm->private_data = chip;
strcpy(pcm->name, name); strcpy(pcm->name, name);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_bt87x_pcm_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_bt87x_pcm_ops);
return snd_pcm_lib_preallocate_pages_for_all(pcm, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(chip->pci),
snd_dma_pci_data(chip->pci), 128 * 1024,
128 * 1024, ALIGN(255 * 4092, 1024));
ALIGN(255 * 4092, 1024)); return 0;
} }
static int snd_bt87x_create(struct snd_card *card, static int snd_bt87x_create(struct snd_card *card,

Просмотреть файл

@ -1402,21 +1402,17 @@ static int snd_ca0106_pcm(struct snd_ca0106 *emu, int device)
for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
substream; substream;
substream = substream->next) { substream = substream->next) {
if ((err = snd_pcm_lib_preallocate_pages(substream, snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci),
snd_dma_pci_data(emu->pci), 64*1024, 64*1024);
64*1024, 64*1024)) < 0) /* FIXME: 32*1024 for sound buffer, between 32and64 for Periods table. */
return err;
} }
for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
substream; substream;
substream = substream->next) { substream = substream->next) {
if ((err = snd_pcm_lib_preallocate_pages(substream, snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci),
snd_dma_pci_data(emu->pci), 64*1024, 64*1024);
64*1024, 64*1024)) < 0)
return err;
} }
err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2, err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2,

Просмотреть файл

@ -884,17 +884,15 @@ static const struct snd_pcm_ops digital_capture_ops = {
static int snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev) static int snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev)
{ {
struct snd_pcm_substream *ss; struct snd_pcm_substream *ss;
int stream, err; int stream;
for (stream = 0; stream < 2; stream++) for (stream = 0; stream < 2; stream++)
for (ss = pcm->streams[stream].substream; ss; ss = ss->next) { for (ss = pcm->streams[stream].substream; ss; ss = ss->next)
err = snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG, snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG,
dev, dev,
ss->number ? 0 : 128<<10, ss->number ? 0 : 128<<10,
256<<10); 256<<10);
if (err < 0)
return err;
}
return 0; return 0;
} }

Просмотреть файл

@ -1427,11 +1427,14 @@ int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device)
emu->pcm = pcm; emu->pcm = pcm;
for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG,
return err; snd_dma_pci_data(emu->pci),
64*1024, 64*1024);
for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next) for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next)
snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(emu->pci),
64*1024, 64*1024);
return 0; return 0;
} }
@ -1455,8 +1458,9 @@ int snd_emu10k1_pcm_multi(struct snd_emu10k1 *emu, int device)
emu->pcm_multi = pcm; emu->pcm_multi = pcm;
for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG,
return err; snd_dma_pci_data(emu->pci),
64*1024, 64*1024);
return 0; return 0;
} }
@ -1489,7 +1493,9 @@ int snd_emu10k1_pcm_mic(struct snd_emu10k1 *emu, int device)
strcpy(pcm->name, "Mic Capture"); strcpy(pcm->name, "Mic Capture");
emu->pcm_mic = pcm; emu->pcm_mic = pcm;
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(emu->pci),
64*1024, 64*1024);
return 0; return 0;
} }
@ -1862,7 +1868,9 @@ int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device)
if (err < 0) if (err < 0)
return err; return err;
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024); snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(emu->pci),
64*1024, 64*1024);
return 0; return 0;
} }

Просмотреть файл

@ -656,11 +656,10 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device)
for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
substream; substream;
substream = substream->next) { substream = substream->next) {
if ((err = snd_pcm_lib_preallocate_pages(substream, snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci),
snd_dma_pci_data(emu->pci), (65536 - 64) * 8,
((65536 - 64) * 8), ((65536 - 64) * 8))) < 0) (65536 - 64) * 8);
return err;
/* /*
dev_dbg(emu->card->dev, dev_dbg(emu->card->dev,
"preallocate playback substream: err=%d\n", err); "preallocate playback substream: err=%d\n", err);
@ -670,11 +669,9 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device)
for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
substream; substream;
substream = substream->next) { substream = substream->next) {
if ((err = snd_pcm_lib_preallocate_pages(substream, snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci),
snd_dma_pci_data(emu->pci), 65536 - 64, 65536 - 64);
65536 - 64, 65536 - 64)) < 0)
return err;
/* /*
dev_dbg(emu->card->dev, dev_dbg(emu->card->dev,
"preallocate capture substream: err=%d\n", err); "preallocate capture substream: err=%d\n", err);

Просмотреть файл

@ -854,11 +854,9 @@ static int lx_pcm_create(struct lx6464es *chip)
pcm->nonatomic = true; pcm->nonatomic = true;
strcpy(pcm->name, card_name); strcpy(pcm->name, card_name);
err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(chip->pci), snd_dma_pci_data(chip->pci),
size, size); size, size);
if (err < 0)
return err;
chip->pcm = pcm; chip->pcm = pcm;
chip->capture_stream.is_capture = 1; chip->capture_stream.is_capture = 1;

Просмотреть файл

@ -6402,7 +6402,6 @@ static int snd_hdspm_create_hwdep(struct snd_card *card,
------------------------------------------------------------*/ ------------------------------------------------------------*/
static int snd_hdspm_preallocate_memory(struct hdspm *hdspm) static int snd_hdspm_preallocate_memory(struct hdspm *hdspm)
{ {
int err;
struct snd_pcm *pcm; struct snd_pcm *pcm;
size_t wanted; size_t wanted;
@ -6410,21 +6409,10 @@ static int snd_hdspm_preallocate_memory(struct hdspm *hdspm)
wanted = HDSPM_DMA_AREA_BYTES; wanted = HDSPM_DMA_AREA_BYTES;
err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
snd_pcm_lib_preallocate_pages_for_all(pcm, snd_dma_pci_data(hdspm->pci),
SNDRV_DMA_TYPE_DEV_SG, wanted, wanted);
snd_dma_pci_data(hdspm->pci), dev_dbg(hdspm->card->dev, " Preallocated %zd Bytes\n", wanted);
wanted,
wanted);
if (err < 0) {
dev_dbg(hdspm->card->dev,
"Could not preallocate %zd Bytes\n", wanted);
return err;
} else
dev_dbg(hdspm->card->dev,
" Preallocated %zd Bytes\n", wanted);
return 0; return 0;
} }

Просмотреть файл

@ -865,11 +865,9 @@ static int snd_via686_pcm_new(struct via82xx_modem *chip)
init_viadev(chip, 0, VIA_REG_MO_STATUS, 0); init_viadev(chip, 0, VIA_REG_MO_STATUS, 0);
init_viadev(chip, 1, VIA_REG_MI_STATUS, 1); init_viadev(chip, 1, VIA_REG_MI_STATUS, 1);
if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
snd_dma_pci_data(chip->pci), snd_dma_pci_data(chip->pci),
64*1024, 128*1024)) < 0) 64*1024, 128*1024);
return err;
return 0; return 0;
} }

Просмотреть файл

@ -1024,15 +1024,11 @@ static int snd_ps3_driver_probe(struct ps3_system_bus_device *dev)
the_card.pcm->info_flags = SNDRV_PCM_INFO_NONINTERLEAVED; the_card.pcm->info_flags = SNDRV_PCM_INFO_NONINTERLEAVED;
/* pre-alloc PCM DMA buffer*/ /* pre-alloc PCM DMA buffer*/
ret = snd_pcm_lib_preallocate_pages_for_all(the_card.pcm, snd_pcm_lib_preallocate_pages_for_all(the_card.pcm,
SNDRV_DMA_TYPE_DEV, SNDRV_DMA_TYPE_DEV,
&dev->core, &dev->core,
SND_PS3_PCM_PREALLOC_SIZE, SND_PS3_PCM_PREALLOC_SIZE,
SND_PS3_PCM_PREALLOC_SIZE); SND_PS3_PCM_PREALLOC_SIZE);
if (ret < 0) {
pr_info("%s: prealloc failed\n", __func__);
goto clean_card;
}
/* /*
* allocate null buffer * allocate null buffer

Просмотреть файл

@ -464,14 +464,12 @@ static int __init snd_aicapcmchip(struct snd_card_aica
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
&snd_aicapcm_playback_ops); &snd_aicapcm_playback_ops);
/* Allocate the DMA buffers */ /* Allocate the DMA buffers */
err = snd_pcm_lib_preallocate_pages_for_all(pcm,
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
SNDRV_DMA_TYPE_CONTINUOUS, snd_dma_continuous_data(GFP_KERNEL),
snd_dma_continuous_data AICA_BUFFER_SIZE,
(GFP_KERNEL), AICA_BUFFER_SIZE);
AICA_BUFFER_SIZE, return 0;
AICA_BUFFER_SIZE);
return err;
} }
/* Mixer controls */ /* Mixer controls */

Просмотреть файл

@ -1142,7 +1142,6 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd)
static int acp_dma_new(struct snd_soc_pcm_runtime *rtd) static int acp_dma_new(struct snd_soc_pcm_runtime *rtd)
{ {
int ret;
struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd,
DRV_NAME); DRV_NAME);
struct audio_drv_data *adata = dev_get_drvdata(component->dev); 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)
switch (adata->asic_type) { switch (adata->asic_type) {
case CHIP_STONEY: case CHIP_STONEY:
ret = snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
SNDRV_DMA_TYPE_DEV, SNDRV_DMA_TYPE_DEV,
parent, parent,
ST_MIN_BUFFER, ST_MIN_BUFFER,
ST_MAX_BUFFER); ST_MAX_BUFFER);
break; break;
default: default:
ret = snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
SNDRV_DMA_TYPE_DEV, SNDRV_DMA_TYPE_DEV,
parent, parent,
MIN_BUFFER, MIN_BUFFER,
MAX_BUFFER); MAX_BUFFER);
break; break;
} }
if (ret < 0) return 0;
dev_err(component->dev,
"buffer preallocation failure error:%d\n", ret);
return ret;
} }
static int acp_dma_close(struct snd_pcm_substream *substream) static int acp_dma_close(struct snd_pcm_substream *substream)

Просмотреть файл

@ -367,11 +367,10 @@ static snd_pcm_uframes_t acp3x_dma_pointer(struct snd_pcm_substream *substream)
static int acp3x_dma_new(struct snd_soc_pcm_runtime *rtd) static int acp3x_dma_new(struct snd_soc_pcm_runtime *rtd)
{ {
return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_DEV,
SNDRV_DMA_TYPE_DEV, rtd->pcm->card->dev,
rtd->pcm->card->dev, MIN_BUFFER, MAX_BUFFER);
MIN_BUFFER, return 0;
MAX_BUFFER);
} }
static int acp3x_dma_hw_free(struct snd_pcm_substream *substream) static int acp3x_dma_hw_free(struct snd_pcm_substream *substream)

Просмотреть файл

@ -249,9 +249,10 @@ static int dw_pcm_new(struct snd_soc_pcm_runtime *rtd)
{ {
size_t size = dw_pcm_hardware.buffer_bytes_max; size_t size = dw_pcm_hardware.buffer_bytes_max;
return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
SNDRV_DMA_TYPE_CONTINUOUS, SNDRV_DMA_TYPE_CONTINUOUS,
snd_dma_continuous_data(GFP_KERNEL), size, size); snd_dma_continuous_data(GFP_KERNEL), size, size);
return 0;
} }
static void dw_pcm_free(struct snd_pcm *pcm) static void dw_pcm_free(struct snd_pcm *pcm)

Просмотреть файл

@ -687,20 +687,15 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_dai *dai = rtd->cpu_dai; struct snd_soc_dai *dai = rtd->cpu_dai;
struct snd_pcm *pcm = rtd->pcm; struct snd_pcm *pcm = rtd->pcm;
int retval = 0;
if (dai->driver->playback.channels_min || if (dai->driver->playback.channels_min ||
dai->driver->capture.channels_min) { dai->driver->capture.channels_min) {
retval = snd_pcm_lib_preallocate_pages_for_all(pcm, snd_pcm_lib_preallocate_pages_for_all(pcm,
SNDRV_DMA_TYPE_CONTINUOUS, SNDRV_DMA_TYPE_CONTINUOUS,
snd_dma_continuous_data(GFP_DMA), snd_dma_continuous_data(GFP_DMA),
SST_MIN_BUFFER, SST_MAX_BUFFER); SST_MIN_BUFFER, SST_MAX_BUFFER);
if (retval) {
dev_err(rtd->dev, "dma buffer allocation failure\n");
return retval;
}
} }
return retval; return 0;
} }
static int sst_soc_probe(struct snd_soc_component *component) static int sst_soc_probe(struct snd_soc_component *component)

Просмотреть файл

@ -327,23 +327,16 @@ static int sst_byt_pcm_new(struct snd_soc_pcm_runtime *rtd)
size_t size; size_t size;
struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_pdata *pdata = dev_get_platdata(component->dev);
int ret = 0;
if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream ||
pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
size = sst_byt_pcm_hardware.buffer_bytes_max; size = sst_byt_pcm_hardware.buffer_bytes_max;
ret = snd_pcm_lib_preallocate_pages_for_all(pcm, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
SNDRV_DMA_TYPE_DEV, pdata->dma_dev,
pdata->dma_dev, size, size);
size, size);
if (ret) {
dev_err(rtd->dev, "dma buffer allocation failed %d\n",
ret);
return ret;
}
} }
return ret; return 0;
} }
static struct snd_soc_dai_driver byt_dais[] = { static struct snd_soc_dai_driver byt_dais[] = {

Просмотреть файл

@ -946,27 +946,21 @@ static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd)
struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_pdata *pdata = dev_get_platdata(component->dev);
struct hsw_priv_data *priv_data = dev_get_drvdata(component->dev); struct hsw_priv_data *priv_data = dev_get_drvdata(component->dev);
struct device *dev = pdata->dma_dev; struct device *dev = pdata->dma_dev;
int ret = 0;
if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream ||
pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
ret = snd_pcm_lib_preallocate_pages_for_all(pcm, snd_pcm_lib_preallocate_pages_for_all(pcm,
SNDRV_DMA_TYPE_DEV_SG, SNDRV_DMA_TYPE_DEV_SG,
dev, dev,
hsw_pcm_hardware.buffer_bytes_max, hsw_pcm_hardware.buffer_bytes_max,
hsw_pcm_hardware.buffer_bytes_max); hsw_pcm_hardware.buffer_bytes_max);
if (ret) {
dev_err(rtd->dev, "dma buffer allocation failed %d\n",
ret);
return ret;
}
} }
if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream)
priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_PLAYBACK].hsw_pcm = pcm; priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_PLAYBACK].hsw_pcm = pcm;
if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream)
priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_CAPTURE].hsw_pcm = pcm; priv_data->pcm[rtd->cpu_dai->id][SNDRV_PCM_STREAM_CAPTURE].hsw_pcm = pcm;
return ret; return 0;
} }
#define HSW_FORMATS \ #define HSW_FORMATS \

Просмотреть файл

@ -1289,7 +1289,6 @@ static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd)
struct hdac_bus *bus = dev_get_drvdata(dai->dev); struct hdac_bus *bus = dev_get_drvdata(dai->dev);
struct snd_pcm *pcm = rtd->pcm; struct snd_pcm *pcm = rtd->pcm;
unsigned int size; unsigned int size;
int retval = 0;
struct skl *skl = bus_to_skl(bus); struct skl *skl = bus_to_skl(bus);
if (dai->driver->playback.channels_min || if (dai->driver->playback.channels_min ||
@ -1298,17 +1297,13 @@ static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd)
size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024; size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
if (size > MAX_PREALLOC_SIZE) if (size > MAX_PREALLOC_SIZE)
size = MAX_PREALLOC_SIZE; size = MAX_PREALLOC_SIZE;
retval = snd_pcm_lib_preallocate_pages_for_all(pcm, snd_pcm_lib_preallocate_pages_for_all(pcm,
SNDRV_DMA_TYPE_DEV_SG, SNDRV_DMA_TYPE_DEV_SG,
snd_dma_pci_data(skl->pci), snd_dma_pci_data(skl->pci),
size, MAX_PREALLOC_SIZE); size, MAX_PREALLOC_SIZE);
if (retval) {
dev_err(dai->dev, "dma buffer allocation fail\n");
return retval;
}
} }
return retval; return 0;
} }
static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig) static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig)

Просмотреть файл

@ -126,9 +126,9 @@ int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd)
struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
size = afe->mtk_afe_hardware->buffer_bytes_max; size = afe->mtk_afe_hardware->buffer_bytes_max;
return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
afe->dev, afe->dev, size, size);
size, size); return 0;
} }
EXPORT_SYMBOL_GPL(mtk_afe_pcm_new); EXPORT_SYMBOL_GPL(mtk_afe_pcm_new);

Просмотреть файл

@ -267,9 +267,10 @@ int axg_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd, unsigned int type)
struct snd_card *card = rtd->card->snd_card; struct snd_card *card = rtd->card->snd_card;
size_t size = axg_fifo_hw.buffer_bytes_max; size_t size = axg_fifo_hw.buffer_bytes_max;
return snd_pcm_lib_preallocate_pages(rtd->pcm->streams[type].substream, snd_pcm_lib_preallocate_pages(rtd->pcm->streams[type].substream,
SNDRV_DMA_TYPE_DEV, card->dev, SNDRV_DMA_TYPE_DEV, card->dev,
size, size); size, size);
return 0;
} }
EXPORT_SYMBOL_GPL(axg_fifo_pcm_new); EXPORT_SYMBOL_GPL(axg_fifo_pcm_new);

Просмотреть файл

@ -1768,11 +1768,12 @@ static const struct snd_pcm_ops fsi_pcm_ops = {
static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd) static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd)
{ {
return snd_pcm_lib_preallocate_pages_for_all( snd_pcm_lib_preallocate_pages_for_all(
rtd->pcm, rtd->pcm,
SNDRV_DMA_TYPE_DEV, SNDRV_DMA_TYPE_DEV,
rtd->card->snd_card->dev, rtd->card->snd_card->dev,
PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
return 0;
} }
/* /*

Просмотреть файл

@ -1575,7 +1575,6 @@ static int rsnd_preallocate_pages(struct snd_soc_pcm_runtime *rtd,
struct rsnd_priv *priv = rsnd_io_to_priv(io); struct rsnd_priv *priv = rsnd_io_to_priv(io);
struct device *dev = rsnd_priv_to_dev(priv); struct device *dev = rsnd_priv_to_dev(priv);
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
int err;
/* /*
* use Audio-DMAC dev if we can use IPMMU * use Audio-DMAC dev if we can use IPMMU
@ -1588,12 +1587,10 @@ static int rsnd_preallocate_pages(struct snd_soc_pcm_runtime *rtd,
for (substream = rtd->pcm->streams[stream].substream; for (substream = rtd->pcm->streams[stream].substream;
substream; substream;
substream = substream->next) { substream = substream->next) {
err = snd_pcm_lib_preallocate_pages(substream, snd_pcm_lib_preallocate_pages(substream,
SNDRV_DMA_TYPE_DEV, SNDRV_DMA_TYPE_DEV,
dev, dev,
PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
if (err < 0)
return err;
} }
return 0; return 0;

Просмотреть файл

@ -541,15 +541,9 @@ static int siu_pcm_new(struct snd_soc_pcm_runtime *rtd)
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = snd_pcm_lib_preallocate_pages_for_all(pcm, snd_pcm_lib_preallocate_pages_for_all(pcm,
SNDRV_DMA_TYPE_DEV, card->dev, SNDRV_DMA_TYPE_DEV, card->dev,
SIU_BUFFER_BYTES_MAX, SIU_BUFFER_BYTES_MAX); SIU_BUFFER_BYTES_MAX, SIU_BUFFER_BYTES_MAX);
if (ret < 0) {
dev_err(card->dev,
"snd_pcm_lib_preallocate_pages_for_all() err=%d",
ret);
goto fail;
}
(*port_info)->pcm = pcm; (*port_info)->pcm = pcm;
@ -562,11 +556,6 @@ static int siu_pcm_new(struct snd_soc_pcm_runtime *rtd)
dev_info(card->dev, "SuperH SIU driver initialized.\n"); dev_info(card->dev, "SuperH SIU driver initialized.\n");
return 0; return 0;
fail:
siu_free_port(siu_ports[pdev->id]);
dev_err(card->dev, "SIU: failed to initialize.\n");
return ret;
} }
static void siu_pcm_free(struct snd_pcm *pcm) static void siu_pcm_free(struct snd_pcm *pcm)

Просмотреть файл

@ -270,7 +270,6 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
size_t prealloc_buffer_size; size_t prealloc_buffer_size;
size_t max_buffer_size; size_t max_buffer_size;
unsigned int i; unsigned int i;
int ret;
if (config && config->prealloc_buffer_size) { if (config && config->prealloc_buffer_size) {
prealloc_buffer_size = config->prealloc_buffer_size; prealloc_buffer_size = config->prealloc_buffer_size;
@ -303,13 +302,11 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
return -EINVAL; return -EINVAL;
} }
ret = snd_pcm_lib_preallocate_pages(substream, snd_pcm_lib_preallocate_pages(substream,
SNDRV_DMA_TYPE_DEV_IRAM, SNDRV_DMA_TYPE_DEV_IRAM,
dmaengine_dma_dev(pcm, substream), dmaengine_dma_dev(pcm, substream),
prealloc_buffer_size, prealloc_buffer_size,
max_buffer_size); max_buffer_size);
if (ret)
return ret;
if (!dmaengine_pcm_can_report_residue(dev, pcm->chan[i])) if (!dmaengine_pcm_can_report_residue(dev, pcm->chan[i]))
pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE; pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE;

Просмотреть файл

@ -262,8 +262,9 @@ static int stm32_adfsdm_pcm_new(struct snd_soc_pcm_runtime *rtd)
snd_soc_dai_get_drvdata(rtd->cpu_dai); snd_soc_dai_get_drvdata(rtd->cpu_dai);
unsigned int size = DFSDM_MAX_PERIODS * DFSDM_MAX_PERIOD_SIZE; unsigned int size = DFSDM_MAX_PERIODS * DFSDM_MAX_PERIOD_SIZE;
return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
priv->dev, size, size); priv->dev, size, size);
return 0;
} }
static void stm32_adfsdm_pcm_free(struct snd_pcm *pcm) static void stm32_adfsdm_pcm_free(struct snd_pcm *pcm)

Просмотреть файл

@ -313,8 +313,10 @@ static int txx9aclc_pcm_new(struct snd_soc_pcm_runtime *rtd)
if (ret) if (ret)
goto exit; goto exit;
} }
return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
card->dev, 64 * 1024, 4 * 1024 * 1024); card->dev, 64 * 1024, 4 * 1024 * 1024);
return 0;
exit: exit:
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {

Просмотреть файл

@ -235,10 +235,11 @@ static int uniphier_aiodma_new(struct snd_soc_pcm_runtime *rtd)
if (ret) if (ret)
return ret; return ret;
return snd_pcm_lib_preallocate_pages_for_all(pcm, snd_pcm_lib_preallocate_pages_for_all(pcm,
SNDRV_DMA_TYPE_DEV, dev, SNDRV_DMA_TYPE_DEV, dev,
uniphier_aiodma_hw.buffer_bytes_max, uniphier_aiodma_hw.buffer_bytes_max,
uniphier_aiodma_hw.buffer_bytes_max); uniphier_aiodma_hw.buffer_bytes_max);
return 0;
} }
static void uniphier_aiodma_free(struct snd_pcm *pcm) static void uniphier_aiodma_free(struct snd_pcm *pcm)

Просмотреть файл

@ -469,9 +469,9 @@ static int xtfpga_pcm_new(struct snd_soc_pcm_runtime *rtd)
struct snd_card *card = rtd->card->snd_card; struct snd_card *card = rtd->card->snd_card;
size_t size = xtfpga_pcm_hardware.buffer_bytes_max; size_t size = xtfpga_pcm_hardware.buffer_bytes_max;
return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, SNDRV_DMA_TYPE_DEV,
SNDRV_DMA_TYPE_DEV, card->dev, size, size);
card->dev, size, size); return 0;
} }
static const struct snd_pcm_ops xtfpga_pcm_ops = { static const struct snd_pcm_ops xtfpga_pcm_ops = {

Просмотреть файл

@ -2243,12 +2243,9 @@ static int snd_dbri_pcm(struct snd_card *card)
pcm->info_flags = 0; pcm->info_flags = 0;
strcpy(pcm->name, card->shortname); strcpy(pcm->name, card->shortname);
if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
SNDRV_DMA_TYPE_CONTINUOUS, snd_dma_continuous_data(GFP_KERNEL),
snd_dma_continuous_data(GFP_KERNEL), 64 * 1024, 64 * 1024);
64 * 1024, 64 * 1024)) < 0)
return err;
return 0; return 0;
} }

Просмотреть файл

@ -350,7 +350,7 @@ static int snd_at73c213_pcm_new(struct snd_at73c213 *chip, int device)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &at73c213_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &at73c213_playback_ops);
retval = snd_pcm_lib_preallocate_pages_for_all(chip->pcm, snd_pcm_lib_preallocate_pages_for_all(chip->pcm,
SNDRV_DMA_TYPE_DEV, &chip->ssc->pdev->dev, SNDRV_DMA_TYPE_DEV, &chip->ssc->pdev->dev,
64 * 1024, 64 * 1024); 64 * 1024, 64 * 1024);
out: out:

Просмотреть файл

@ -981,18 +981,17 @@ static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint,
sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->pcm_devs); sprintf(pcm->name, NAME_ALLCAPS" Audio #%d", usX2Y(card)->pcm_devs);
if ((playback_endpoint && if (playback_endpoint) {
0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
SNDRV_DMA_TYPE_CONTINUOUS, SNDRV_DMA_TYPE_CONTINUOUS,
snd_dma_continuous_data(GFP_KERNEL), snd_dma_continuous_data(GFP_KERNEL),
64*1024, 128*1024))) || 64*1024, 128*1024);
0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
SNDRV_DMA_TYPE_CONTINUOUS,
snd_dma_continuous_data(GFP_KERNEL),
64*1024, 128*1024))) {
snd_usX2Y_pcm_private_free(pcm);
return err;
} }
snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
SNDRV_DMA_TYPE_CONTINUOUS,
snd_dma_continuous_data(GFP_KERNEL),
64*1024, 128*1024);
usX2Y(card)->pcm_devs++; usX2Y(card)->pcm_devs++;
return 0; return 0;

Просмотреть файл

@ -736,17 +736,14 @@ int usX2Y_hwdep_pcm_new(struct snd_card *card)
pcm->info_flags = 0; pcm->info_flags = 0;
sprintf(pcm->name, NAME_ALLCAPS" hwdep Audio"); sprintf(pcm->name, NAME_ALLCAPS" hwdep Audio");
if (0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
SNDRV_DMA_TYPE_CONTINUOUS, SNDRV_DMA_TYPE_CONTINUOUS,
snd_dma_continuous_data(GFP_KERNEL), snd_dma_continuous_data(GFP_KERNEL),
64*1024, 128*1024)) || 64*1024, 128*1024);
0 > (err = snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
SNDRV_DMA_TYPE_CONTINUOUS, SNDRV_DMA_TYPE_CONTINUOUS,
snd_dma_continuous_data(GFP_KERNEL), snd_dma_continuous_data(GFP_KERNEL),
64*1024, 128*1024))) { 64*1024, 128*1024);
return err;
}
return 0; return 0;
} }