From: Christoph Hellwig <hch@lst.de>
To: Ralf Baechle <ralf@linux-mips.org>,
Paul Burton <paul.burton@mips.com>,
James Hogan <jhogan@kernel.org>, Ley Foon Tan <lftan@altera.com>,
Michal Simek <monstr@monstr.eu>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: linux-mips@vger.kernel.org, iommu@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org
Subject: [PATCH 2/7] au1100fb: fix DMA API abuse
Date: Tue, 30 Apr 2019 11:00:27 +0000 [thread overview]
Message-ID: <20190430110032.25301-3-hch@lst.de> (raw)
In-Reply-To: <20190430110032.25301-1-hch@lst.de>
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>
---
drivers/video/fbdev/au1100fb.c | 24 ++++--------------------
drivers/video/fbdev/au1100fb.h | 1 +
2 files changed, 5 insertions(+), 20 deletions(-)
diff --git a/drivers/video/fbdev/au1100fb.c b/drivers/video/fbdev/au1100fb.c
index 0adf0683cf08..99941ae1f3a1 100644
--- a/drivers/video/fbdev/au1100fb.c
+++ b/drivers/video/fbdev/au1100fb.c
@@ -340,14 +340,12 @@ int au1100fb_fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *fbi)
*/
int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)
{
- struct au1100fb_device *fbdev;
-
- fbdev = to_au1100fb_device(fbi);
+ struct au1100fb_device *fbdev = to_au1100fb_device(fbi);
- vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6
- return vm_iomap_memory(vma, fbdev->fb_phys, fbdev->fb_len);
+ return dma_mmap_coherent(fbdev->dev, vma, fbdev->fb_mem, fbdev->fb_phys,
+ fbdev->fb_len);
}
static struct fb_ops au1100fb_ops @@ -412,7 +410,6 @@ static int au1100fb_drv_probe(struct platform_device *dev)
{
struct au1100fb_device *fbdev;
struct resource *regs_res;
- unsigned long page;
struct clk *c;
/* Allocate new device private */
@@ -424,6 +421,7 @@ static int au1100fb_drv_probe(struct platform_device *dev)
goto failed;
platform_set_drvdata(dev, (void *)fbdev);
+ fbdev->dev = &dev->dev;
/* Allocate region for our registers and map them */
regs_res = platform_get_resource(dev, IORESOURCE_MEM, 0);
@@ -472,20 +470,6 @@ static int au1100fb_drv_probe(struct platform_device *dev)
au1100fb_fix.smem_start = fbdev->fb_phys;
au1100fb_fix.smem_len = fbdev->fb_len;
- /*
- * Set page reserved so that mmap will work. This is necessary
- * since we'll be remapping normal memory.
- */
- for (page = (unsigned long)fbdev->fb_mem;
- page < PAGE_ALIGN((unsigned long)fbdev->fb_mem + fbdev->fb_len);
- page += PAGE_SIZE) {
-#ifdef CONFIG_DMA_NONCOHERENT
- SetPageReserved(virt_to_page(CAC_ADDR((void *)page)));
-#else
- SetPageReserved(virt_to_page(page));
-#endif
- }
-
print_dbg("Framebuffer memory map at %p", fbdev->fb_mem);
print_dbg("phys=0x%08x, size=%dK", fbdev->fb_phys, fbdev->fb_len / 1024);
diff --git a/drivers/video/fbdev/au1100fb.h b/drivers/video/fbdev/au1100fb.h
index 9af19939a9c6..e7239bceefd3 100644
--- a/drivers/video/fbdev/au1100fb.h
+++ b/drivers/video/fbdev/au1100fb.h
@@ -110,6 +110,7 @@ struct au1100fb_device {
dma_addr_t fb_phys;
int panel_idx;
struct clk *lcdclk;
+ struct device *dev;
};
/********************************************************************/
--
2.20.1
next prev parent reply other threads:[~2019-04-30 11:00 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-30 11:00 provide generic support for uncached segements in dma-direct Christoph Hellwig
2019-04-30 11:00 ` [PATCH 1/7] MIPS: remove the _dma_cache_wback_inv export Christoph Hellwig
2019-04-30 11:00 ` Christoph Hellwig [this message]
2019-05-06 13:49 ` [PATCH 2/7] au1100fb: fix DMA API abuse Bartlomiej Zolnierkiewicz
2019-05-07 6:36 ` Christoph Hellwig
2019-06-03 6:49 ` Christoph Hellwig
2019-04-30 11:00 ` [PATCH 3/7] dma-mapping: add a Kconfig symbol to indicate arch_dma_prep_coherent presence Christoph Hellwig
2019-04-30 11:00 ` [PATCH 4/7] dma-direct: provide generic support for uncached kernel segments Christoph Hellwig
2019-05-01 17:18 ` Paul Burton
2019-05-01 17:29 ` Christoph Hellwig
2019-05-01 17:40 ` Paul Burton
2019-05-01 17:49 ` Christoph Hellwig
2019-05-02 0:08 ` Paul Burton
2019-05-02 13:11 ` Christoph Hellwig
2019-04-30 11:00 ` [PATCH 5/7] MIPS: use the generic uncached segment support in dma-direct Christoph Hellwig
2019-04-30 20:10 ` Paul Burton
2019-04-30 20:29 ` Christoph Hellwig
2019-04-30 21:11 ` Paul Burton
2019-04-30 21:15 ` Christoph Hellwig
2019-05-01 13:13 ` [PATCH 5/7 v2] " Christoph Hellwig
2019-05-01 17:13 ` Paul Burton
2019-06-03 6:48 ` Christoph Hellwig
2019-07-03 8:54 ` Arnd Bergmann
2019-07-03 12:13 ` Christoph Hellwig
2019-04-30 11:00 ` [PATCH 6/7] nios2: " Christoph Hellwig
2019-04-30 11:00 ` [PATCH 7/7] microblaze: " Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190430110032.25301-3-hch@lst.de \
--to=hch@lst.de \
--cc=b.zolnierkie@samsung.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jhogan@kernel.org \
--cc=lftan@altera.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=monstr@monstr.eu \
--cc=paul.burton@mips.com \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).