Commit 60fa88f6 authored by Takashi Iwai's avatar Takashi Iwai Committed by Greg Kroah-Hartman

ALSA: hda: Check the non-cached stream buffers more explicitly

[ Upstream commit 78c9be61 ]

Introduce a new flag, uc_buffer, to indicate that the controller
requires the non-cached pages for stream buffers, either as a
chip-specific requirement or specified via snoop=0 option.
This improves the code-readability.

Also, this patch fixes the incorrect behavior for C-Media chip where
the stream buffers were never handled as non-cached due to the check
of driver_type even if you pass snoop=0 option.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9dd0fafb
...@@ -160,6 +160,7 @@ struct azx { ...@@ -160,6 +160,7 @@ struct azx {
unsigned int msi:1; unsigned int msi:1;
unsigned int probing:1; /* codec probing phase */ unsigned int probing:1; /* codec probing phase */
unsigned int snoop:1; unsigned int snoop:1;
unsigned int uc_buffer:1; /* non-cached pages for stream buffers */
unsigned int align_buffer_size:1; unsigned int align_buffer_size:1;
unsigned int region_requested:1; unsigned int region_requested:1;
unsigned int disabled:1; /* disabled by vga_switcheroo */ unsigned int disabled:1; /* disabled by vga_switcheroo */
......
...@@ -412,7 +412,7 @@ static void __mark_pages_wc(struct azx *chip, struct snd_dma_buffer *dmab, bool ...@@ -412,7 +412,7 @@ static void __mark_pages_wc(struct azx *chip, struct snd_dma_buffer *dmab, bool
#ifdef CONFIG_SND_DMA_SGBUF #ifdef CONFIG_SND_DMA_SGBUF
if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_SG) { if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_SG) {
struct snd_sg_buf *sgbuf = dmab->private_data; struct snd_sg_buf *sgbuf = dmab->private_data;
if (chip->driver_type == AZX_DRIVER_CMEDIA) if (!chip->uc_buffer)
return; /* deal with only CORB/RIRB buffers */ return; /* deal with only CORB/RIRB buffers */
if (on) if (on)
set_pages_array_wc(sgbuf->page_table, sgbuf->pages); set_pages_array_wc(sgbuf->page_table, sgbuf->pages);
...@@ -1678,6 +1678,7 @@ static void azx_check_snoop_available(struct azx *chip) ...@@ -1678,6 +1678,7 @@ static void azx_check_snoop_available(struct azx *chip)
dev_info(chip->card->dev, "Force to %s mode by module option\n", dev_info(chip->card->dev, "Force to %s mode by module option\n",
snoop ? "snoop" : "non-snoop"); snoop ? "snoop" : "non-snoop");
chip->snoop = snoop; chip->snoop = snoop;
chip->uc_buffer = !snoop;
return; return;
} }
...@@ -1698,8 +1699,12 @@ static void azx_check_snoop_available(struct azx *chip) ...@@ -1698,8 +1699,12 @@ static void azx_check_snoop_available(struct azx *chip)
snoop = false; snoop = false;
chip->snoop = snoop; chip->snoop = snoop;
if (!snoop) if (!snoop) {
dev_info(chip->card->dev, "Force to non-snoop mode\n"); dev_info(chip->card->dev, "Force to non-snoop mode\n");
/* C-Media requires non-cached pages only for CORB/RIRB */
if (chip->driver_type != AZX_DRIVER_CMEDIA)
chip->uc_buffer = true;
}
} }
static void azx_probe_work(struct work_struct *work) static void azx_probe_work(struct work_struct *work)
...@@ -2138,7 +2143,7 @@ static void pcm_mmap_prepare(struct snd_pcm_substream *substream, ...@@ -2138,7 +2143,7 @@ static void pcm_mmap_prepare(struct snd_pcm_substream *substream,
#ifdef CONFIG_X86 #ifdef CONFIG_X86
struct azx_pcm *apcm = snd_pcm_substream_chip(substream); struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
struct azx *chip = apcm->chip; struct azx *chip = apcm->chip;
if (!azx_snoop(chip) && chip->driver_type != AZX_DRIVER_CMEDIA) if (chip->uc_buffer)
area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment