Skip to content

Commit

Permalink
ALSA: memalloc: Fix pgprot for WC mmap on x86
Browse files Browse the repository at this point in the history
We have a special handling of WC pages on x86, and it's currently
specific to HD-audio.  The last forgotten piece was the pgprot setup
for the mmap with WC pages.

This patch moves the pgprot setup for WC pages from HD-audio-specific
mmap callback to the common helper code.  It allows us to remove the
superfluous mmap callback in HD-audio and its prepare_mmap
redirection.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
tiwai authored and intel-lab-lkp committed Aug 4, 2021
1 parent d125459 commit 2221a30
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 25 deletions.
4 changes: 4 additions & 0 deletions sound/core/memalloc.c
Expand Up @@ -414,6 +414,10 @@ static void snd_dma_dev_free(struct snd_dma_buffer *dmab)
static int snd_dma_dev_mmap(struct snd_dma_buffer *dmab,
struct vm_area_struct *area)
{
#ifdef CONFIG_X86
if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC)
area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
#endif
return dma_mmap_coherent(dmab->dev.dev, area,
dmab->area, dmab->addr, dmab->bytes);
}
Expand Down
11 changes: 0 additions & 11 deletions sound/pci/hda/hda_controller.c
Expand Up @@ -669,16 +669,6 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
return err;
}

static int azx_pcm_mmap(struct snd_pcm_substream *substream,
struct vm_area_struct *area)
{
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
struct azx *chip = apcm->chip;
if (chip->ops->pcm_mmap_prepare)
chip->ops->pcm_mmap_prepare(substream, area);
return snd_pcm_lib_default_mmap(substream, area);
}

static const struct snd_pcm_ops azx_pcm_ops = {
.open = azx_pcm_open,
.close = azx_pcm_close,
Expand All @@ -688,7 +678,6 @@ static const struct snd_pcm_ops azx_pcm_ops = {
.trigger = azx_pcm_trigger,
.pointer = azx_pcm_pointer,
.get_time_info = azx_get_time_info,
.mmap = azx_pcm_mmap,
};

static void azx_pcm_free(struct snd_pcm *pcm)
Expand Down
2 changes: 0 additions & 2 deletions sound/pci/hda/hda_controller.h
Expand Up @@ -74,8 +74,6 @@ struct azx;
struct hda_controller_ops {
/* Disable msi if supported, PCI only */
int (*disable_msi_reset_irq)(struct azx *);
void (*pcm_mmap_prepare)(struct snd_pcm_substream *substream,
struct vm_area_struct *area);
/* Check if current position is acceptable */
int (*position_check)(struct azx *chip, struct azx_dev *azx_dev);
/* enable/disable the link power */
Expand Down
12 changes: 0 additions & 12 deletions sound/pci/hda/hda_intel.c
Expand Up @@ -2037,17 +2037,6 @@ static int disable_msi_reset_irq(struct azx *chip)
return 0;
}

static void pcm_mmap_prepare(struct snd_pcm_substream *substream,
struct vm_area_struct *area)
{
#ifdef CONFIG_X86
struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
struct azx *chip = apcm->chip;
if (chip->uc_buffer)
area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
#endif
}

/* Denylist for skipping the whole probe:
* some HD-audio PCI entries are exposed without any codecs, and such devices
* should be ignored from the beginning.
Expand All @@ -2061,7 +2050,6 @@ static const struct pci_device_id driver_denylist[] = {

static const struct hda_controller_ops pci_hda_ops = {
.disable_msi_reset_irq = disable_msi_reset_irq,
.pcm_mmap_prepare = pcm_mmap_prepare,
.position_check = azx_position_check,
};

Expand Down

0 comments on commit 2221a30

Please sign in to comment.