Skip to content

Commit 9882d63

Browse files
committed
ALSA: memalloc: Drop x86-specific hack for WC allocations
The recent report for a crash on Haswell machines implied that the x86-specific (rather hackish) implementation for write-cache memory buffer allocation in ALSA core is buggy with the recent kernel in some corner cases. This patch drops the x86-specific implementation and uses the standard dma_alloc_wc() & co generically for avoiding the bug and also for simplification. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=216112 Cc: <[email protected]> # v5.18+ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent d499512 commit 9882d63

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

sound/core/memalloc.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -431,33 +431,17 @@ static const struct snd_malloc_ops snd_dma_iram_ops = {
431431
*/
432432
static void *snd_dma_dev_alloc(struct snd_dma_buffer *dmab, size_t size)
433433
{
434-
void *p;
435-
436-
p = dma_alloc_coherent(dmab->dev.dev, size, &dmab->addr, DEFAULT_GFP);
437-
#ifdef CONFIG_X86
438-
if (p && dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC)
439-
set_memory_wc((unsigned long)p, PAGE_ALIGN(size) >> PAGE_SHIFT);
440-
#endif
441-
return p;
434+
return dma_alloc_coherent(dmab->dev.dev, size, &dmab->addr, DEFAULT_GFP);
442435
}
443436

444437
static void snd_dma_dev_free(struct snd_dma_buffer *dmab)
445438
{
446-
#ifdef CONFIG_X86
447-
if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC)
448-
set_memory_wb((unsigned long)dmab->area,
449-
PAGE_ALIGN(dmab->bytes) >> PAGE_SHIFT);
450-
#endif
451439
dma_free_coherent(dmab->dev.dev, dmab->bytes, dmab->area, dmab->addr);
452440
}
453441

454442
static int snd_dma_dev_mmap(struct snd_dma_buffer *dmab,
455443
struct vm_area_struct *area)
456444
{
457-
#ifdef CONFIG_X86
458-
if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC)
459-
area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
460-
#endif
461445
return dma_mmap_coherent(dmab->dev.dev, area,
462446
dmab->area, dmab->addr, dmab->bytes);
463447
}
@@ -471,10 +455,6 @@ static const struct snd_malloc_ops snd_dma_dev_ops = {
471455
/*
472456
* Write-combined pages
473457
*/
474-
#ifdef CONFIG_X86
475-
/* On x86, share the same ops as the standard dev ops */
476-
#define snd_dma_wc_ops snd_dma_dev_ops
477-
#else /* CONFIG_X86 */
478458
static void *snd_dma_wc_alloc(struct snd_dma_buffer *dmab, size_t size)
479459
{
480460
return dma_alloc_wc(dmab->dev.dev, size, &dmab->addr, DEFAULT_GFP);
@@ -497,7 +477,6 @@ static const struct snd_malloc_ops snd_dma_wc_ops = {
497477
.free = snd_dma_wc_free,
498478
.mmap = snd_dma_wc_mmap,
499479
};
500-
#endif /* CONFIG_X86 */
501480

502481
#ifdef CONFIG_SND_DMA_SGBUF
503482
static void *snd_dma_sg_fallback_alloc(struct snd_dma_buffer *dmab, size_t size);

0 commit comments

Comments
 (0)