From mboxrd@z Thu Jan 1 00:00:00 1970 From: catalin.marinas@arm.com (Catalin Marinas) Date: Wed, 18 Jan 2017 11:25:07 +0000 Subject: [PATCH] arm64: Fix swiotlb fallback allocation In-Reply-To: <1484567193-71258-1-git-send-email-agraf@suse.de> References: <1484567193-71258-1-git-send-email-agraf@suse.de> Message-ID: <20170118112506.GC7566@e104818-lin.cambridge.arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Mon, Jan 16, 2017 at 12:46:33PM +0100, Alexander Graf wrote: > Commit b67a8b29df introduced logic to skip swiotlb allocation when all memory > is DMA accessible anyway. > > While this is a great idea, __dma_alloc still calls swiotlb code unconditionally > to allocate memory when there is no CMA memory available. The swiotlb code is > called to ensure that we at least try get_free_pages(). > > Without initialization, swiotlb allocation code tries to access io_tlb_list > which is NULL. That results in a stack trace like this: > > Unable to handle kernel NULL pointer dereference at virtual address 00000000 > [...] > [] swiotlb_tbl_map_single+0xd0/0x2b0 > [] swiotlb_alloc_coherent+0x10c/0x198 > [] __dma_alloc+0x68/0x1a8 > [] drm_gem_cma_create+0x98/0x108 [drm] > [] drm_fbdev_cma_create_with_funcs+0xbc/0x368 [drm_kms_helper] > [] drm_fbdev_cma_create+0x2c/0x40 [drm_kms_helper] > [] drm_fb_helper_initial_config+0x238/0x410 [drm_kms_helper] > [] drm_fbdev_cma_init_with_funcs+0x98/0x160 [drm_kms_helper] > [] drm_fbdev_cma_init+0x40/0x58 [drm_kms_helper] > [] vc4_kms_load+0x90/0xf0 [vc4] > [] vc4_drm_bind+0xec/0x168 [vc4] > [...] > > Thankfully swiotlb code just learned how to not do allocations with the FORCE_NO > option. This patch configures the swiotlb code to use that if we decide not to > initialize the swiotlb framework. > > Fixes: b67a8b29df ("arm64: mm: only initialize swiotlb when necessary") > Signed-off-by: Alexander Graf > CC: Catalin Marinas > CC: Jisheng Zhang > CC: Geert Uytterhoeven > CC: Konrad Rzeszutek Wilk Queued for 4.10. Thanks. -- Catalin