From patchwork Tue Aug 7 10:59:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Hans Hu(SH-RD)" X-Patchwork-Id: 10558547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 734891057 for ; Tue, 7 Aug 2018 10:59:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6272029418 for ; Tue, 7 Aug 2018 10:59:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 564392948E; Tue, 7 Aug 2018 10:59:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03E1829418 for ; Tue, 7 Aug 2018 10:59:28 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id F0ABC26786B; Tue, 7 Aug 2018 12:59:24 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3939526786D; Tue, 7 Aug 2018 12:59:22 +0200 (CEST) Received: from ZXSHCAS2.zhaoxin.com (unknown [203.148.12.82]) by alsa0.perex.cz (Postfix) with ESMTP id 48BEA267692 for ; Tue, 7 Aug 2018 12:59:18 +0200 (CEST) Received: from ZXSHMBX2.zhaoxin.com (10.28.252.164) by ZXSHCAS2.zhaoxin.com (10.28.252.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1261.35; Tue, 7 Aug 2018 18:59:13 +0800 Received: from ZXSHMBX1.zhaoxin.com (10.28.252.163) by ZXSHMBX2.zhaoxin.com (10.28.252.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1261.35; Tue, 7 Aug 2018 18:59:12 +0800 Received: from ZXSHMBX1.zhaoxin.com ([fe80::70f4:1ea6:cdb1:546b]) by ZXSHMBX1.zhaoxin.com ([fe80::70f4:1ea6:cdb1:546b%5]) with mapi id 15.01.1261.035; Tue, 7 Aug 2018 18:59:04 +0800 From: "Hans Hu(SH-RD)" To: 'Takashi Iwai' Thread-Topic: [alsa-devel] A bug about cache inconsistency report Thread-Index: AdQuAnCyRHAM8MwxSv+1LatSBEpp5v//1i0A//9h1cA= Date: Tue, 7 Aug 2018 10:59:04 +0000 Message-ID: References: In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.28.120.21] MIME-Version: 1.0 Cc: "Tony W. Wang\(BJ-RD\)" , "'alsa-devel@alsa-project.org'" , "Tim Guo\(BJ-RD\)" , "Annie Liu\(BJ-RD\)" Subject: [alsa-devel] =?utf-8?q?=E7=AD=94=E5=A4=8D=3A__A_bug_about_cache_inc?= =?utf-8?q?onsistency_report?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" 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 X-Virus-Scanned: ClamAV using ClamSMTP > >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. Thanks, Hans --- 保密声明: 本邮件含有保密或专有信息,仅供指定收件人使用。严禁对本邮件或其内容做任何未经授权的查阅、使用、复制或转发。 CONFIDENTIAL NOTE: This email contains confidential or legally privileged information and is for the sole use of its intended recipient. Any unauthorized review, use, copying or forwarding of this email or the content of this email is strictly prohibited. diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c index 84fffabdd129..643f6cb2048c 100644 --- a/sound/core/sgbuf.c +++ b/sound/core/sgbuf.c @@ -68,7 +68,7 @@ void *snd_malloc_sgbuf_pages(struct device *device, size_t *res_size) { struct snd_sg_buf *sgbuf; -unsigned int i, pages, chunk, maxpages; +unsigned int i, pages, chunk; struct snd_dma_buffer tmpb; struct snd_sg_page *table; struct page **pgtable; @@ -90,38 +90,18 @@ void *snd_malloc_sgbuf_pages(struct device *device, goto _failed; sgbuf->page_table = pgtable; -/* allocate pages */ -maxpages = MAX_ALLOC_PAGES; -while (pages > 0) { -chunk = pages; -/* don't be too eager to take a huge chunk */ -if (chunk > maxpages) -chunk = maxpages; -chunk <<= PAGE_SHIFT; -if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, device, - chunk, &tmpb) < 0) { -if (!sgbuf->pages) -goto _failed; -if (!res_size) -goto _failed; -size = sgbuf->pages * PAGE_SIZE; -break; -} -chunk = tmpb.bytes >> PAGE_SHIFT; -for (i = 0; i < chunk; i++) { -table->buf = tmpb.area; -table->addr = tmpb.addr; -if (!i) -table->addr |= chunk; /* mark head */ -table++; -*pgtable++ = virt_to_page(tmpb.area); -tmpb.area += PAGE_SIZE; -tmpb.addr += PAGE_SIZE; -} -sgbuf->pages += chunk; -pages -= chunk; -if (chunk < maxpages) -maxpages = chunk; +if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, device, size, &tmpb) < 0) +goto _failed; +chunk = tmpb.bytes >> PAGE_SHIFT; +for (i = 0; i < pages; i++) { +table->buf = tmpb.area; +table->addr = tmpb.addr; +if (!i) +table->addr |= pages; /* mark head */ +table++; +*pgtable++ = virt_to_page(tmpb.area); +tmpb.area += PAGE_SIZE; +tmpb.addr += PAGE_SIZE; +sgbuf->pages += chunk; } sgbuf->size = size;