Skip to content

Commit

Permalink
Merge branch 'topic/memory-device-fixes-2' into for-next
Browse files Browse the repository at this point in the history
Pull further device memory allocation cleanups (but no API change yet).

Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Feb 8, 2019
2 parents 0b2338a + 62e94da commit 36e4617
Show file tree
Hide file tree
Showing 37 changed files with 148 additions and 246 deletions.
4 changes: 1 addition & 3 deletions drivers/media/pci/solo6x10/solo6x10-g723.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,11 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
ss; ss = ss->next, 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,
snd_dma_continuous_data(GFP_KERNEL),
G723_PERIOD_BYTES * PERIODS,
G723_PERIOD_BYTES * PERIODS);
if (ret < 0)
return ret;

solo_dev->snd_pcm = pcm;

Expand Down
3 changes: 2 additions & 1 deletion drivers/media/pci/tw686x/tw686x-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,12 @@ static int tw686x_snd_pcm_init(struct tw686x_dev *dev)
ss; ss = ss->next, 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,
snd_dma_pci_data(dev->pci_dev),
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,
Expand Down
4 changes: 1 addition & 3 deletions sound/atmel/ac97c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_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,
hw.buffer_bytes_max);
if (retval)
return retval;

pcm->private_data = chip;
pcm->info_flags = 0;
Expand Down
10 changes: 2 additions & 8 deletions sound/parisc/harmony.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,14 +669,8 @@ snd_harmony_pcm_init(struct snd_harmony *h)
}

/* pre-allocate space for DMA */
err = snd_pcm_lib_preallocate_pages_for_all(pcm, h->dma.type,
h->dma.dev,
MAX_BUF_SIZE,
MAX_BUF_SIZE);
if (err < 0) {
printk(KERN_ERR PFX "buffer allocation error: %d\n", err);
return err;
}
snd_pcm_lib_preallocate_pages_for_all(pcm, h->dma.type, h->dma.dev,
MAX_BUF_SIZE, MAX_BUF_SIZE);

h->st.format = snd_harmony_set_data_format(h,
SNDRV_PCM_FORMAT_S16_BE, 1);
Expand Down
7 changes: 1 addition & 6 deletions sound/pci/ad1889.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,16 +644,11 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device)
chip->psubs = 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),
BUFFER_BYTES_MAX / 2,
BUFFER_BYTES_MAX);

if (err < 0) {
dev_err(chip->card->dev, "buffer allocation error: %d\n", err);
return err;
}

return 0;
}

Expand Down
40 changes: 12 additions & 28 deletions sound/pci/aw2/aw2-alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,15 +624,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)

/* pre-allocation of buffers */
/* Preallocate continuous pages. */
err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana,
SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data
(chip->pci),
64 * 1024, 64 * 1024);
if (err)
dev_err(chip->card->dev,
"snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
err);
snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana,
SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(chip->pci),
64 * 1024, 64 * 1024);

err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0,
&pcm_playback_num);
Expand Down Expand Up @@ -661,15 +656,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)

/* pre-allocation of buffers */
/* Preallocate continuous pages. */
err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num,
SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data
(chip->pci),
64 * 1024, 64 * 1024);
if (err)
dev_err(chip->card->dev,
"snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
err);
snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num,
SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(chip->pci),
64 * 1024, 64 * 1024);

err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1,
&pcm_capture);
Expand Down Expand Up @@ -699,16 +689,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)

/* pre-allocation of buffers */
/* Preallocate continuous pages. */
err = snd_pcm_lib_preallocate_pages_for_all(pcm_capture,
SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data
(chip->pci),
64 * 1024, 64 * 1024);
if (err)
dev_err(chip->card->dev,
"snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
err);

snd_pcm_lib_preallocate_pages_for_all(pcm_capture,
SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(chip->pci),
64 * 1024, 64 * 1024);

/* Create control */
err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip));
Expand Down
10 changes: 5 additions & 5 deletions sound/pci/bt87x.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,11 +714,11 @@ static int snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *name)
pcm->private_data = chip;
strcpy(pcm->name, name);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_bt87x_pcm_ops);
return snd_pcm_lib_preallocate_pages_for_all(pcm,
SNDRV_DMA_TYPE_DEV_SG,
snd_dma_pci_data(chip->pci),
128 * 1024,
ALIGN(255 * 4092, 1024));
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
snd_dma_pci_data(chip->pci),
128 * 1024,
ALIGN(255 * 4092, 1024));
return 0;
}

static int snd_bt87x_create(struct snd_card *card,
Expand Down
16 changes: 6 additions & 10 deletions sound/pci/ca0106/ca0106_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1402,21 +1402,17 @@ static int snd_ca0106_pcm(struct snd_ca0106 *emu, int device)
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,
snd_dma_pci_data(emu->pci),
64*1024, 64*1024)) < 0) /* FIXME: 32*1024 for sound buffer, between 32and64 for Periods table. */
return err;
snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(emu->pci),
64*1024, 64*1024);
}

for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
substream;
substream = substream->next) {
if ((err = snd_pcm_lib_preallocate_pages(substream,
SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(emu->pci),
64*1024, 64*1024)) < 0)
return err;
snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(emu->pci),
64*1024, 64*1024);
}

err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2,
Expand Down
16 changes: 7 additions & 9 deletions sound/pci/echoaudio/echoaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
struct snd_pcm_substream *ss;
int stream, err;
int stream;

for (stream = 0; stream < 2; stream++)
for (ss = pcm->streams[stream].substream; ss; ss = ss->next) {
err = snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG,
dev,
ss->number ? 0 : 128<<10,
256<<10);
if (err < 0)
return err;
}
for (ss = pcm->streams[stream].substream; ss; ss = ss->next)
snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG,
dev,
ss->number ? 0 : 128<<10,
256<<10);

return 0;
}

Expand Down
22 changes: 15 additions & 7 deletions sound/pci/emu10k1/emupcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,11 +1427,14 @@ int snd_emu10k1_pcm(struct snd_emu10k1 *emu, int device)
emu->pcm = pcm;

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)
return err;
snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG,
snd_dma_pci_data(emu->pci),
64*1024, 64*1024);

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;
}
Expand All @@ -1455,8 +1458,9 @@ int snd_emu10k1_pcm_multi(struct snd_emu10k1 *emu, int device)
emu->pcm_multi = pcm;

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)
return err;
snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG,
snd_dma_pci_data(emu->pci),
64*1024, 64*1024);

return 0;
}
Expand Down Expand Up @@ -1489,7 +1493,9 @@ int snd_emu10k1_pcm_mic(struct snd_emu10k1 *emu, int device)
strcpy(pcm->name, "Mic Capture");
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;
}
Expand Down Expand Up @@ -1862,7 +1868,9 @@ int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device)
if (err < 0)
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;
}
17 changes: 7 additions & 10 deletions sound/pci/emu10k1/p16v.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,10 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device)
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,
snd_dma_pci_data(emu->pci),
((65536 - 64) * 8), ((65536 - 64) * 8))) < 0)
return err;
snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(emu->pci),
(65536 - 64) * 8,
(65536 - 64) * 8);
/*
dev_dbg(emu->card->dev,
"preallocate playback substream: err=%d\n", err);
Expand All @@ -670,11 +669,9 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device)
for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
substream;
substream = substream->next) {
if ((err = snd_pcm_lib_preallocate_pages(substream,
SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(emu->pci),
65536 - 64, 65536 - 64)) < 0)
return err;
snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(emu->pci),
65536 - 64, 65536 - 64);
/*
dev_dbg(emu->card->dev,
"preallocate capture substream: err=%d\n", err);
Expand Down
8 changes: 3 additions & 5 deletions sound/pci/lx6464es/lx6464es.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,11 +854,9 @@ static int lx_pcm_create(struct lx6464es *chip)
pcm->nonatomic = true;
strcpy(pcm->name, card_name);

err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(chip->pci),
size, size);
if (err < 0)
return err;
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(chip->pci),
size, size);

chip->pcm = pcm;
chip->capture_stream.is_capture = 1;
Expand Down
20 changes: 4 additions & 16 deletions sound/pci/rme9652/hdspm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6402,29 +6402,17 @@ static int snd_hdspm_create_hwdep(struct snd_card *card,
------------------------------------------------------------*/
static int snd_hdspm_preallocate_memory(struct hdspm *hdspm)
{
int err;
struct snd_pcm *pcm;
size_t wanted;

pcm = hdspm->pcm;

wanted = HDSPM_DMA_AREA_BYTES;

err =
snd_pcm_lib_preallocate_pages_for_all(pcm,
SNDRV_DMA_TYPE_DEV_SG,
snd_dma_pci_data(hdspm->pci),
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);

snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
snd_dma_pci_data(hdspm->pci),
wanted, wanted);
dev_dbg(hdspm->card->dev, " Preallocated %zd Bytes\n", wanted);
return 0;
}

Expand Down
8 changes: 3 additions & 5 deletions sound/pci/via82xx_modem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, 1, VIA_REG_MI_STATUS, 1);

if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
snd_dma_pci_data(chip->pci),
64*1024, 128*1024)) < 0)
return err;

snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
snd_dma_pci_data(chip->pci),
64*1024, 128*1024);
return 0;
}

Expand Down
6 changes: 1 addition & 5 deletions sound/ppc/snd_ps3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/* 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,
&dev->core,
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
Expand Down
14 changes: 6 additions & 8 deletions sound/sh/aica.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,12 @@ static int __init snd_aicapcmchip(struct snd_card_aica
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
&snd_aicapcm_playback_ops);
/* Allocate the DMA buffers */
err =
snd_pcm_lib_preallocate_pages_for_all(pcm,
SNDRV_DMA_TYPE_CONTINUOUS,
snd_dma_continuous_data
(GFP_KERNEL),
AICA_BUFFER_SIZE,
AICA_BUFFER_SIZE);
return err;
snd_pcm_lib_preallocate_pages_for_all(pcm,
SNDRV_DMA_TYPE_CONTINUOUS,
snd_dma_continuous_data(GFP_KERNEL),
AICA_BUFFER_SIZE,
AICA_BUFFER_SIZE);
return 0;
}

/* Mixer controls */
Expand Down
Loading

0 comments on commit 36e4617

Please sign in to comment.