From patchwork Tue Feb 13 23:04:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej S. Szmigiero" X-Patchwork-Id: 10217679 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 792A260329 for ; Tue, 13 Feb 2018 23:05:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FDD31FF41 for ; Tue, 13 Feb 2018 23:05:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 643BC28D0E; Tue, 13 Feb 2018 23:05:13 +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=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=unavailable 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 944621FF41 for ; Tue, 13 Feb 2018 23:05:12 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id D07242679F4; Wed, 14 Feb 2018 00:05:10 +0100 (CET) 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 DE311267A0D; Wed, 14 Feb 2018 00:05:08 +0100 (CET) Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by alsa0.perex.cz (Postfix) with ESMTP id C2DC4267A20 for ; Wed, 14 Feb 2018 00:05:00 +0100 (CET) Received: by vps-vb.mhejs.net with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) (envelope-from ) id 1eljdD-0002hb-6b; Wed, 14 Feb 2018 00:04:59 +0100 From: "Maciej S. Szmigiero" To: Jaroslav Kysela , Takashi Iwai Message-ID: <87e066a9-99ec-31a4-111a-1d848b7d98ec@maciej.szmigiero.name> Date: Wed, 14 Feb 2018 00:04:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Language: en-US Cc: alsa-devel@alsa-project.org, linux-kernel Subject: [alsa-devel] [PATCH v3 1/5] ALSA: emu10k1: remove reserved_page 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 The emu10k1-family chips need the first page (index 0) reserved in their page tables for some reason (every emu10k1 driver I've checked does this without much of an explanation). Using the first page for normal samples results in a broken playback. However, we already have a dummy page allocated - so called "silent page" and, in fact, had always been setting it as the first page in the chip page table because an initialization of every entry of the page table to point to a silent page happens after and overwrites the reserved_page allocation. So the only thing remaining to remove the reserved_page allocation is a trivial change to the page allocation logic to ignore the first page entry and start its allocations from the second entry (index 1). Signed-off-by: Maciej S. Szmigiero --- Changes from v1, v2: None in this patch. include/sound/emu10k1.h | 1 - sound/pci/emu10k1/emu10k1_main.c | 11 ----------- sound/pci/emu10k1/memory.c | 8 ++++++-- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 4f42affe777c..db32b7de52e0 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -1718,7 +1718,6 @@ struct snd_emu10k1 { struct snd_dma_buffer p16v_buffer; struct snd_util_memhdr *memhdr; /* page allocation list */ - struct snd_emu10k1_memblk *reserved_page; /* reserved page */ struct list_head mapped_link_head; struct list_head mapped_order_link_head; diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index ccf4415a1c7b..a0a4d31ded53 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -1272,12 +1272,6 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu) release_firmware(emu->dock_fw); if (emu->irq >= 0) free_irq(emu->irq, emu); - /* remove reserved page */ - if (emu->reserved_page) { - snd_emu10k1_synth_free(emu, - (struct snd_util_memblk *)emu->reserved_page); - emu->reserved_page = NULL; - } snd_util_memhdr_free(emu->memhdr); if (emu->silent_page.area) snd_dma_free_pages(&emu->silent_page); @@ -1993,11 +1987,6 @@ int snd_emu10k1_create(struct snd_card *card, SPCS_GENERATIONSTATUS | 0x00001200 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT; - emu->reserved_page = (struct snd_emu10k1_memblk *) - snd_emu10k1_synth_alloc(emu, 4096); - if (emu->reserved_page) - emu->reserved_page->map_locked = 1; - /* Clear silent pages and set up pointers */ memset(emu->silent_page.area, 0, PAGE_SIZE); silent_page = emu->silent_page.addr << emu->address_mode; diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c index 4f1f69be1865..eaa61024ac7f 100644 --- a/sound/pci/emu10k1/memory.c +++ b/sound/pci/emu10k1/memory.c @@ -102,7 +102,7 @@ static void emu10k1_memblk_init(struct snd_emu10k1_memblk *blk) */ static int search_empty_map_area(struct snd_emu10k1 *emu, int npages, struct list_head **nextp) { - int page = 0, found_page = -ENOMEM; + int page = 1, found_page = -ENOMEM; int max_size = npages; int size; struct list_head *candidate = &emu->mapped_link_head; @@ -147,6 +147,10 @@ static int map_memblk(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) page = search_empty_map_area(emu, blk->pages, &next); if (page < 0) /* not found */ return page; + if (page == 0) { + dev_err(emu->card->dev, "trying to map zero (reserved) page\n"); + return -EINVAL; + } /* insert this block in the proper position of mapped list */ list_add_tail(&blk->mapped_link, next); /* append this as a newest block in order list */ @@ -177,7 +181,7 @@ static int unmap_memblk(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) q = get_emu10k1_memblk(p, mapped_link); start_page = q->mapped_page + q->pages; } else - start_page = 0; + start_page = 1; if ((p = blk->mapped_link.next) != &emu->mapped_link_head) { q = get_emu10k1_memblk(p, mapped_link); end_page = q->mapped_page;