From patchwork Sat Jan 27 14:42:38 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: 10187505 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 1A2AC602C8 for ; Sat, 27 Jan 2018 14:43:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE69B28B9B for ; Sat, 27 Jan 2018 14:43:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E233A28BA1; Sat, 27 Jan 2018 14:43:00 +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 33B1F28B9B for ; Sat, 27 Jan 2018 14:43:00 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 56C7F266FE1; Sat, 27 Jan 2018 15:42:46 +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 B0A47266FD8; Sat, 27 Jan 2018 15:42:45 +0100 (CET) Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by alsa0.perex.cz (Postfix) with ESMTP id 077A4266FE1 for ; Sat, 27 Jan 2018 15:42:39 +0100 (CET) Received: by vps-vb.mhejs.net with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) (envelope-from ) id 1efRgl-0006H3-20; Sat, 27 Jan 2018 15:42:39 +0100 From: "Maciej S. Szmigiero" To: Jaroslav Kysela , Takashi Iwai Message-ID: <829d7527-9684-3a3c-1890-e13be1c9a4a3@maciej.szmigiero.name> Date: Sat, 27 Jan 2018 15:42:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 Content-Language: en-US Cc: alsa-devel@alsa-project.org, linux-kernel Subject: [alsa-devel] [PATCH v2 3/5] ALSA: emu10k1: add optional debug printouts with DMA addresses 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 When we get a IOMMU page fault for a emu10k1 device it is very hard to discover which of chip many DMA allocations triggered it (since on a IOMMU system the DMA address space is often very different from the CPU one). Let's add optional debug printouts providing this information. These debug printouts are only enabled on an explicit request via the kernel dynamic debug mechanism. Signed-off-by: Maciej S. Szmigiero --- Changes from v1: Fix a sparse warning by changing a variable type in __{get,set}_ptb_entry from u32 to __le32, don't open code EMUPAGESIZE. sound/pci/emu10k1/emu10k1_main.c | 8 ++++++++ sound/pci/emu10k1/memory.c | 15 +++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 11e868f569d6..8decd2a7a404 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -1898,6 +1898,9 @@ int snd_emu10k1_create(struct snd_card *card, err = -ENOMEM; goto error; } + dev_dbg(card->dev, "page table address range is %.8lx:%.8lx\n", + (unsigned long)emu->ptb_pages.addr, + (unsigned long)(emu->ptb_pages.addr + emu->ptb_pages.bytes)); emu->page_ptr_table = vmalloc(emu->max_cache_pages * sizeof(void *)); emu->page_addr_table = vmalloc(emu->max_cache_pages * @@ -1912,6 +1915,11 @@ int snd_emu10k1_create(struct snd_card *card, err = -ENOMEM; goto error; } + dev_dbg(card->dev, "silent page range is %.8lx:%.8lx\n", + (unsigned long)emu->silent_page.addr, + (unsigned long)(emu->silent_page.addr + + emu->silent_page.bytes)); + emu->memhdr = snd_util_memhdr_new(emu->max_cache_pages * PAGE_SIZE); if (emu->memhdr == NULL) { err = -ENOMEM; diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c index eaa61024ac7f..fcb04cbbc9ab 100644 --- a/sound/pci/emu10k1/memory.c +++ b/sound/pci/emu10k1/memory.c @@ -34,7 +34,10 @@ * aligned pages in others */ #define __set_ptb_entry(emu,page,addr) \ - (((u32 *)(emu)->ptb_pages.area)[page] = cpu_to_le32(((addr) << (emu->address_mode)) | (page))) + (((__le32 *)(emu)->ptb_pages.area)[page] = \ + cpu_to_le32(((addr) << (emu->address_mode)) | (page))) +#define __get_ptb_entry(emu, page) \ + (le32_to_cpu(((__le32 *)(emu)->ptb_pages.area)[page])) #define UNIT_PAGES (PAGE_SIZE / EMUPAGESIZE) #define MAX_ALIGN_PAGES0 (MAXPAGES0 / UNIT_PAGES) @@ -44,8 +47,7 @@ /* get offset address from aligned page */ #define aligned_page_offset(page) ((page) << PAGE_SHIFT) -#if PAGE_SIZE == 4096 -/* page size == EMUPAGESIZE */ +#if PAGE_SIZE == EMUPAGESIZE && !IS_ENABLED(CONFIG_DYNAMIC_DEBUG) /* fill PTB entrie(s) corresponding to page with addr */ #define set_ptb_entry(emu,page,addr) __set_ptb_entry(emu,page,addr) /* fill PTB entrie(s) corresponding to page with silence pointer */ @@ -58,6 +60,8 @@ static inline void set_ptb_entry(struct snd_emu10k1 *emu, int page, dma_addr_t a page *= UNIT_PAGES; for (i = 0; i < UNIT_PAGES; i++, page++) { __set_ptb_entry(emu, page, addr); + dev_dbg(emu->card->dev, "mapped page %d to entry %.8x\n", page, + (unsigned int)__get_ptb_entry(emu, page)); addr += EMUPAGESIZE; } } @@ -65,9 +69,12 @@ static inline void set_silent_ptb(struct snd_emu10k1 *emu, int page) { int i; page *= UNIT_PAGES; - for (i = 0; i < UNIT_PAGES; i++, page++) + for (i = 0; i < UNIT_PAGES; i++, page++) { /* do not increment ptr */ __set_ptb_entry(emu, page, emu->silent_page.addr); + dev_dbg(emu->card->dev, "mapped silent page %d to entry %.8x\n", + page, (unsigned int)__get_ptb_entry(emu, page)); + } } #endif /* PAGE_SIZE */