Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

au1100fb: fix DMA API abuse

Virtual addresses return from dma(m)_alloc_coherent are opaque in what
backs then, and drivers must not poke into them. Switch the driver
to use the generic DMA API mmap helper to avoid these games.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>

+5 -20
+4 -20
drivers/video/fbdev/au1100fb.c
··· 340 340 */ 341 341 int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma) 342 342 { 343 - struct au1100fb_device *fbdev; 343 + struct au1100fb_device *fbdev = to_au1100fb_device(fbi); 344 344 345 - fbdev = to_au1100fb_device(fbi); 346 - 347 - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 348 345 pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6 349 346 350 - return vm_iomap_memory(vma, fbdev->fb_phys, fbdev->fb_len); 347 + return dma_mmap_coherent(fbdev->dev, vma, fbdev->fb_mem, fbdev->fb_phys, 348 + fbdev->fb_len); 351 349 } 352 350 353 351 static struct fb_ops au1100fb_ops = ··· 410 412 { 411 413 struct au1100fb_device *fbdev; 412 414 struct resource *regs_res; 413 - unsigned long page; 414 415 struct clk *c; 415 416 416 417 /* Allocate new device private */ ··· 421 424 goto failed; 422 425 423 426 platform_set_drvdata(dev, (void *)fbdev); 427 + fbdev->dev = &dev->dev; 424 428 425 429 /* Allocate region for our registers and map them */ 426 430 regs_res = platform_get_resource(dev, IORESOURCE_MEM, 0); ··· 469 471 470 472 au1100fb_fix.smem_start = fbdev->fb_phys; 471 473 au1100fb_fix.smem_len = fbdev->fb_len; 472 - 473 - /* 474 - * Set page reserved so that mmap will work. This is necessary 475 - * since we'll be remapping normal memory. 476 - */ 477 - for (page = (unsigned long)fbdev->fb_mem; 478 - page < PAGE_ALIGN((unsigned long)fbdev->fb_mem + fbdev->fb_len); 479 - page += PAGE_SIZE) { 480 - #ifdef CONFIG_DMA_NONCOHERENT 481 - SetPageReserved(virt_to_page(CAC_ADDR((void *)page))); 482 - #else 483 - SetPageReserved(virt_to_page(page)); 484 - #endif 485 - } 486 474 487 475 print_dbg("Framebuffer memory map at %p", fbdev->fb_mem); 488 476 print_dbg("phys=0x%08x, size=%dK", fbdev->fb_phys, fbdev->fb_len / 1024);
+1
drivers/video/fbdev/au1100fb.h
··· 110 110 dma_addr_t fb_phys; 111 111 int panel_idx; 112 112 struct clk *lcdclk; 113 + struct device *dev; 113 114 }; 114 115 115 116 /********************************************************************/