aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2012-11-09 08:52:20 -0500
committerTomi Valkeinen <tomi.valkeinen@ti.com>2012-11-13 02:52:24 -0500
commit0049fb2603b7afb1080776ee691dfa5a3d282357 (patch)
tree87a13be03223d34213fc9f213e0a480b365a4dd0 /drivers/video
parent3f5ba55e8f3698432c65b0ef77e83d22d5f64a79 (diff)
OMAPFB: use dma_alloc_attrs to allocate memory
Use dma_alloc_attrs to allocate memory instead of omap specific vram allocator. After this we can remove the omap vram allocator. There are some downsides to this change: 1) dma_alloc_attrs doesn't let us allocate at certain physical address. However, this should not be a problem as this feature of vram allocator is only used when reserving the framebuffer that was initialized by the bootloader, and we don't currently support "passing" a framebuffer from the bootloader to the kernel anyway. 2) dma_alloc_attrs, as of now, always ioremaps the allocated area, and we don't need the ioremap when using VRFB. This patch uses DMA_ATTR_NO_KERNEL_MAPPING for the allocation, but the flag is currently not operational. 3) OMAPFB_GET_VRAM_INFO ioctl cannot return real values anymore. I changed the ioctl to return 64M for all the values, which, I hope, the applications will interpret as "there's enough vram". 4) "vram" kernel parameter to define how much ram to reserve for video use no longer works. The user needs to enable CMA and use "cma" parameter. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/omap2/omapfb/Kconfig1
-rw-r--r--drivers/video/omap2/omapfb/omapfb-ioctl.c14
-rw-r--r--drivers/video/omap2/omapfb/omapfb-main.c69
-rw-r--r--drivers/video/omap2/omapfb/omapfb.h5
4 files changed, 48 insertions, 41 deletions
diff --git a/drivers/video/omap2/omapfb/Kconfig b/drivers/video/omap2/omapfb/Kconfig
index 4ea17dc3258c..4cb12ce68855 100644
--- a/drivers/video/omap2/omapfb/Kconfig
+++ b/drivers/video/omap2/omapfb/Kconfig
@@ -2,7 +2,6 @@ menuconfig FB_OMAP2
2 tristate "OMAP2+ frame buffer support" 2 tristate "OMAP2+ frame buffer support"
3 depends on FB && OMAP2_DSS && !DRM_OMAP 3 depends on FB && OMAP2_DSS && !DRM_OMAP
4 4
5 select OMAP2_VRAM
6 select OMAP2_VRFB if ARCH_OMAP2 || ARCH_OMAP3 5 select OMAP2_VRFB if ARCH_OMAP2 || ARCH_OMAP3
7 select FB_CFB_FILLRECT 6 select FB_CFB_FILLRECT
8 select FB_CFB_COPYAREA 7 select FB_CFB_COPYAREA
diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c
index 606b89f12351..574c1708f749 100644
--- a/drivers/video/omap2/omapfb/omapfb-ioctl.c
+++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c
@@ -31,7 +31,6 @@
31 31
32#include <video/omapdss.h> 32#include <video/omapdss.h>
33#include <plat/vrfb.h> 33#include <plat/vrfb.h>
34#include <plat/vram.h>
35 34
36#include "omapfb.h" 35#include "omapfb.h"
37 36
@@ -853,14 +852,15 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
853 break; 852 break;
854 853
855 case OMAPFB_GET_VRAM_INFO: { 854 case OMAPFB_GET_VRAM_INFO: {
856 unsigned long vram, free, largest;
857
858 DBG("ioctl GET_VRAM_INFO\n"); 855 DBG("ioctl GET_VRAM_INFO\n");
859 856
860 omap_vram_get_info(&vram, &free, &largest); 857 /*
861 p.vram_info.total = vram; 858 * We don't have the ability to get this vram info anymore.
862 p.vram_info.free = free; 859 * Fill in something that should keep the applications working.
863 p.vram_info.largest_free_block = largest; 860 */
861 p.vram_info.total = SZ_1M * 64;
862 p.vram_info.free = SZ_1M * 64;
863 p.vram_info.largest_free_block = SZ_1M * 64;
864 864
865 if (copy_to_user((void __user *)arg, &p.vram_info, 865 if (copy_to_user((void __user *)arg, &p.vram_info,
866 sizeof(p.vram_info))) 866 sizeof(p.vram_info)))
diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c
index 16db1589bd91..84c10121de48 100644
--- a/drivers/video/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/omap2/omapfb/omapfb-main.c
@@ -32,7 +32,6 @@
32 32
33#include <video/omapdss.h> 33#include <video/omapdss.h>
34#include <plat/cpu.h> 34#include <plat/cpu.h>
35#include <plat/vram.h>
36#include <plat/vrfb.h> 35#include <plat/vrfb.h>
37 36
38#include "omapfb.h" 37#include "omapfb.h"
@@ -1336,24 +1335,25 @@ static void omapfb_free_fbmem(struct fb_info *fbi)
1336 1335
1337 rg = ofbi->region; 1336 rg = ofbi->region;
1338 1337
1339 WARN_ON(atomic_read(&rg->map_count)); 1338 if (rg->token == NULL)
1340 1339 return;
1341 if (rg->paddr)
1342 if (omap_vram_free(rg->paddr, rg->size))
1343 dev_err(fbdev->dev, "VRAM FREE failed\n");
1344 1340
1345 if (rg->vaddr) 1341 WARN_ON(atomic_read(&rg->map_count));
1346 iounmap(rg->vaddr);
1347 1342
1348 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) { 1343 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
1349 /* unmap the 0 angle rotation */ 1344 /* unmap the 0 angle rotation */
1350 if (rg->vrfb.vaddr[0]) { 1345 if (rg->vrfb.vaddr[0]) {
1351 iounmap(rg->vrfb.vaddr[0]); 1346 iounmap(rg->vrfb.vaddr[0]);
1352 omap_vrfb_release_ctx(&rg->vrfb);
1353 rg->vrfb.vaddr[0] = NULL; 1347 rg->vrfb.vaddr[0] = NULL;
1354 } 1348 }
1349
1350 omap_vrfb_release_ctx(&rg->vrfb);
1355 } 1351 }
1356 1352
1353 dma_free_attrs(fbdev->dev, rg->size, rg->token, rg->dma_handle,
1354 &rg->attrs);
1355
1356 rg->token = NULL;
1357 rg->vaddr = NULL; 1357 rg->vaddr = NULL;
1358 rg->paddr = 0; 1358 rg->paddr = 0;
1359 rg->alloc = 0; 1359 rg->alloc = 0;
@@ -1388,7 +1388,9 @@ static int omapfb_alloc_fbmem(struct fb_info *fbi, unsigned long size,
1388 struct omapfb_info *ofbi = FB2OFB(fbi); 1388 struct omapfb_info *ofbi = FB2OFB(fbi);
1389 struct omapfb2_device *fbdev = ofbi->fbdev; 1389 struct omapfb2_device *fbdev = ofbi->fbdev;
1390 struct omapfb2_mem_region *rg; 1390 struct omapfb2_mem_region *rg;
1391 void __iomem *vaddr; 1391 void *token;
1392 DEFINE_DMA_ATTRS(attrs);
1393 dma_addr_t dma_handle;
1392 int r; 1394 int r;
1393 1395
1394 rg = ofbi->region; 1396 rg = ofbi->region;
@@ -1403,42 +1405,43 @@ static int omapfb_alloc_fbmem(struct fb_info *fbi, unsigned long size,
1403 1405
1404 size = PAGE_ALIGN(size); 1406 size = PAGE_ALIGN(size);
1405 1407
1406 if (!paddr) { 1408 WARN_ONCE(paddr,
1407 DBG("allocating %lu bytes for fb %d\n", size, ofbi->id); 1409 "reserving memory at predefined address not supported\n");
1408 r = omap_vram_alloc(size, &paddr);
1409 } else {
1410 DBG("reserving %lu bytes at %lx for fb %d\n", size, paddr,
1411 ofbi->id);
1412 r = omap_vram_reserve(paddr, size);
1413 }
1414 1410
1415 if (r) { 1411 dma_set_attr(DMA_ATTR_WRITE_COMBINE, &attrs);
1412
1413 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB)
1414 dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &attrs);
1415
1416 DBG("allocating %lu bytes for fb %d\n", size, ofbi->id);
1417
1418 token = dma_alloc_attrs(fbdev->dev, size, &dma_handle,
1419 GFP_KERNEL, &attrs);
1420
1421 if (token == NULL) {
1416 dev_err(fbdev->dev, "failed to allocate framebuffer\n"); 1422 dev_err(fbdev->dev, "failed to allocate framebuffer\n");
1417 return -ENOMEM; 1423 return -ENOMEM;
1418 } 1424 }
1419 1425
1420 if (ofbi->rotation_type != OMAP_DSS_ROT_VRFB) { 1426 DBG("allocated VRAM paddr %lx, vaddr %p\n",
1421 vaddr = ioremap_wc(paddr, size); 1427 (unsigned long)dma_handle, token);
1422
1423 if (!vaddr) {
1424 dev_err(fbdev->dev, "failed to ioremap framebuffer\n");
1425 omap_vram_free(paddr, size);
1426 return -ENOMEM;
1427 }
1428 1428
1429 DBG("allocated VRAM paddr %lx, vaddr %p\n", paddr, vaddr); 1429 if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
1430 } else {
1431 r = omap_vrfb_request_ctx(&rg->vrfb); 1430 r = omap_vrfb_request_ctx(&rg->vrfb);
1432 if (r) { 1431 if (r) {
1432 dma_free_attrs(fbdev->dev, size, token, dma_handle,
1433 &attrs);
1433 dev_err(fbdev->dev, "vrfb create ctx failed\n"); 1434 dev_err(fbdev->dev, "vrfb create ctx failed\n");
1434 return r; 1435 return r;
1435 } 1436 }
1436
1437 vaddr = NULL;
1438 } 1437 }
1439 1438
1440 rg->paddr = paddr; 1439 rg->attrs = attrs;
1441 rg->vaddr = vaddr; 1440 rg->token = token;
1441 rg->dma_handle = dma_handle;
1442
1443 rg->paddr = (unsigned long)dma_handle;
1444 rg->vaddr = (void __iomem *)token;
1442 rg->size = size; 1445 rg->size = size;
1443 rg->alloc = 1; 1446 rg->alloc = 1;
1444 1447
diff --git a/drivers/video/omap2/omapfb/omapfb.h b/drivers/video/omap2/omapfb/omapfb.h
index 5ced9b334d35..5f72bf9017fc 100644
--- a/drivers/video/omap2/omapfb/omapfb.h
+++ b/drivers/video/omap2/omapfb/omapfb.h
@@ -28,6 +28,8 @@
28#endif 28#endif
29 29
30#include <linux/rwsem.h> 30#include <linux/rwsem.h>
31#include <linux/dma-attrs.h>
32#include <linux/dma-mapping.h>
31 33
32#include <video/omapdss.h> 34#include <video/omapdss.h>
33 35
@@ -49,6 +51,9 @@ extern bool omapfb_debug;
49 51
50struct omapfb2_mem_region { 52struct omapfb2_mem_region {
51 int id; 53 int id;
54 struct dma_attrs attrs;
55 void *token;
56 dma_addr_t dma_handle;
52 u32 paddr; 57 u32 paddr;
53 void __iomem *vaddr; 58 void __iomem *vaddr;
54 struct vrfb vrfb; 59 struct vrfb vrfb;