Received: by 10.223.185.116 with SMTP id b49csp4222437wrg; Tue, 13 Feb 2018 15:09:20 -0800 (PST) X-Google-Smtp-Source: AH8x227Xe4PwQjq+ER3EkChld/vQdopmiuIrOwd5l1AXXVersoBQ3p+E1IYHmp1OU86nyFGtW9GO X-Received: by 2002:a17:902:8607:: with SMTP id f7-v6mr2548302plo.273.1518563360213; Tue, 13 Feb 2018 15:09:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518563360; cv=none; d=google.com; s=arc-20160816; b=j1J7a4GCnW18AGskh5GV3f9Ucp8Wl8mN+iAKbOlXAH0RO7n8ktIa17Ii0MC6pGtWwM EjQgQ43OhiDqgLZjZ7A5JSkCrhhXJVB5xqWIYXCJZjAhufH/fvNLDaQt9WttXCu3OCTZ UfSi/+IvM347JelBycOOzDb667VbvbPHeD/jmJvohTnX/K+wJf78Nk4EOG1eWN01tfXu MykZ2uw8+Y8WuxN1F+JPLpilPK8GicIO49r11bfP88A+QKZ9uQwX4Kmg03izDYVYZANW S+be6IYJI7dNilXVZlTM1ti/66VGqlD1qpq4SZGZYPWNYPa9LkzbPJCgDC53v9bGgGq3 5GYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:mime-version:user-agent:date:message-id:cc:to :subject:from:arc-authentication-results; bh=3j3QVwQ7Dy9n9/MnBxrpwfcMLi2XIsrZCzCKx1zADV8=; b=X3xo9eYuGuDpPDDcMxICwecwqHpGgVzHqk3rD5JPvUNtvM+3DeRgqsSqurPu4h2Nod jUgQEj7fckqgyVM3wUwHI1IGgTsecIYtn0AmxLB5i8nSKEeqaLkE40HvgyVt48WaoJBh 7zMkACoSNEeeffnENd/SS89MSNS4xnJ1dAxD2D8TrG1KkaPxSCGUH3kO1snAWgQ7cksT Jzqarq6kPgJZYzP5taNOE8jVc32fUWb+OAXFDRgVinIGsen7PZNNIODf0Cjn5rBqwIl5 v8TLJzxkT694DMy9PcK4NWJIcpcu46L20RmPh6fw6SaHG0IZYqFqVuvgixGzgYJh3LNc jt+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bj8-v6si588029plb.238.2018.02.13.15.08.42; Tue, 13 Feb 2018 15:09:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966120AbeBMXGV (ORCPT + 99 others); Tue, 13 Feb 2018 18:06:21 -0500 Received: from vps-vb.mhejs.net ([37.28.154.113]:54116 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966002AbeBMXGU (ORCPT ); Tue, 13 Feb 2018 18:06:20 -0500 Received: by vps-vb.mhejs.net with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) (envelope-from ) id 1eljeU-0002i7-C7; Wed, 14 Feb 2018 00:06:18 +0100 From: "Maciej S. Szmigiero" Subject: [PATCH v3 3/5] ALSA: emu10k1: add optional debug printouts with DMA addresses To: Jaroslav Kysela , Takashi Iwai Cc: linux-kernel , alsa-devel@alsa-project.org Message-ID: Date: Wed, 14 Feb 2018 00:06:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Changes from v2: None in this patch. 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 */