[alsa-devel] [PATCH 3/5] ALSA: emu10k1: add optional debug printouts with DMA addresses
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 mail@maciej.szmigiero.name --- sound/pci/emu10k1/emu10k1_main.c | 8 ++++++++ sound/pci/emu10k1/memory.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 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..39afe199e1c7 100644 --- a/sound/pci/emu10k1/memory.c +++ b/sound/pci/emu10k1/memory.c @@ -35,6 +35,8 @@ */ #define __set_ptb_entry(emu,page,addr) \ (((u32 *)(emu)->ptb_pages.area)[page] = cpu_to_le32(((addr) << (emu->address_mode)) | (page))) +#define __get_ptb_entry(emu, page) \ + (le32_to_cpu(((u32 *)(emu)->ptb_pages.area)[page]))
#define UNIT_PAGES (PAGE_SIZE / EMUPAGESIZE) #define MAX_ALIGN_PAGES0 (MAXPAGES0 / UNIT_PAGES) @@ -44,7 +46,7 @@ /* get offset address from aligned page */ #define aligned_page_offset(page) ((page) << PAGE_SHIFT)
-#if PAGE_SIZE == 4096 +#if PAGE_SIZE == 4096 && !IS_ENABLED(CONFIG_DYNAMIC_DEBUG) /* page size == EMUPAGESIZE */ /* fill PTB entrie(s) corresponding to page with addr */ #define set_ptb_entry(emu,page,addr) __set_ptb_entry(emu,page,addr) @@ -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 */
Hi Maciej,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on sound/for-next] [also build test WARNING on v4.15-rc8 next-20180119] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Maciej-S-Szmigiero/ALSA-emu10k1-rem... base: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
sound/pci/emu10k1/memory.c:62:17: sparse: incorrect type in assignment (different base types) @@ expected unsigned int <noident> @@ got ed int <noident> @@ sound/pci/emu10k1/memory.c:62:17: expected unsigned int <noident> sound/pci/emu10k1/memory.c:62:17: got restricted __le32 <noident>
sound/pci/emu10k1/memory.c:63:17: sparse: cast to restricted __le32
sound/pci/emu10k1/memory.c:74:17: sparse: incorrect type in assignment (different base types) @@ expected unsigned int <noident> @@ got ed int <noident> @@ sound/pci/emu10k1/memory.c:74:17: expected unsigned int <noident> sound/pci/emu10k1/memory.c:74:17: got restricted __le32 <noident> sound/pci/emu10k1/memory.c:75:17: sparse: cast to restricted __le32
vim +63 sound/pci/emu10k1/memory.c
48 49 #if PAGE_SIZE == 4096 && !IS_ENABLED(CONFIG_DYNAMIC_DEBUG) 50 /* page size == EMUPAGESIZE */ 51 /* fill PTB entrie(s) corresponding to page with addr */ 52 #define set_ptb_entry(emu,page,addr) __set_ptb_entry(emu,page,addr) 53 /* fill PTB entrie(s) corresponding to page with silence pointer */ 54 #define set_silent_ptb(emu,page) __set_ptb_entry(emu,page,emu->silent_page.addr) 55 #else 56 /* fill PTB entries -- we need to fill UNIT_PAGES entries */ 57 static inline void set_ptb_entry(struct snd_emu10k1 *emu, int page, dma_addr_t addr) 58 { 59 int i; 60 page *= UNIT_PAGES; 61 for (i = 0; i < UNIT_PAGES; i++, page++) {
62 __set_ptb_entry(emu, page, addr); 63 dev_dbg(emu->card->dev, "mapped page %d to entry %.8x\n", page,
64 (unsigned int)__get_ptb_entry(emu, page)); 65 addr += EMUPAGESIZE; 66 } 67 } 68 static inline void set_silent_ptb(struct snd_emu10k1 *emu, int page) 69 { 70 int i; 71 page *= UNIT_PAGES; 72 for (i = 0; i < UNIT_PAGES; i++, page++) { 73 /* do not increment ptr */ 74 __set_ptb_entry(emu, page, emu->silent_page.addr); 75 dev_dbg(emu->card->dev, "mapped silent page %d to entry %.8x\n", 76 page, (unsigned int)__get_ptb_entry(emu, page)); 77 } 78 } 79 #endif /* PAGE_SIZE */ 80 81
--- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
participants (2)
-
kbuild test robot
-
Maciej S. Szmigiero