From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: =?utf-8?b?562U5aSNOiAgQSBidWcgYWJvdXQgY2FjaGUgaW5j?= =?utf-8?q?onsistency_report?= Date: Tue, 07 Aug 2018 14:00:27 +0200 Message-ID: References: Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id A9D8C267692 for ; Tue, 7 Aug 2018 14:00:28 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: "Hans Hu(SH-RD)" Cc: "Tony W. Wang(BJ-RD)" , "'alsa-devel@alsa-project.org'" , "Tim Guo(BJ-RD)" , "Annie Liu(BJ-RD)" List-Id: alsa-devel@alsa-project.org On Tue, 07 Aug 2018 12:59:04 +0200, Hans Hu(SH-RD) wrote: > > > >Then the next step would be to fake sg-buffer from this straight > > >buffer. Revert the above, and modify sgbuf.c to the following: > > >- Allocate a large continuous buffer > > >- Assign each page in this large buffer > > > > >If this still works, it's not about vmap, but it just means that the > > >physically ordered pages do matter -- implicitly showing that the > > >snooping behavior isn't properly turned on / off on the controller. > > > > To fake SG-buffer, I did this test: restore all the codes to the original, then added some codes in snd_malloc_sgbuf_pages() like below, the result is badly niose. > > >Not really what I meant. Rather something like below (totally untested). > > [Hans :] I know what you mean now and complete code like below, but the result is still noise. OK, so indeed the vmapped address does seem matter. Interesting. What kind of user access does produce the noise? Does it via aplay mmap mode, too? In anyway, if the vmap is a problem, it might be worked around a patch like below (again totally untested and not sure whether it's correct). Takashi --- diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -410,12 +410,23 @@ static void __mark_pages_wc(struct azx *chip, struct snd_dma_buffer *dmab, bool #ifdef CONFIG_SND_DMA_SGBUF if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_SG) { struct snd_sg_buf *sgbuf = dmab->private_data; + pgprot_t prot; + void *new_area; + if (chip->driver_type == AZX_DRIVER_CMEDIA) return; /* deal with only CORB/RIRB buffers */ - if (on) + if (on) { set_pages_array_wc(sgbuf->page_table, sgbuf->pages); - else + prot = pgprot_noncached(PAGE_KERNEL); + } else { set_pages_array_wb(sgbuf->page_table, sgbuf->pages); + prot = PAGE_KERNEL; + } + new_area = vmap(sgbuf->page_table, sgbuf->pages, VM_MAP, prot); + if (WARN_ON(!new_area)) + return; + vunmap(dmab->area); + dmab->area = new_area; return; } #endif