Skip to content

Commit ab5a60c

Browse files
author
David Herrmann
committed
drm/omap: use __GFP_DMA32 for shmem-backed gem
OMAP requires bo-pages to be in the DMA32 zone. Explicitly request this by setting __GFP_DMA32 as mapping-gfp-mask during shmem initialization. This drops HIGHMEM from the gfp-mask and uses DMA32 instead. shmem-core takes care to relocate pages during swap-in in case they have been loaded into the wrong zone. It is _not_ possible to pass __GFP_DMA32 to shmem_read_mapping_page_gfp() as the page might have already been swapped-in at that time. The zone-mask must be set during initialization and be kept constant for now. Remove the now superfluous TODO in omap_gem.c. Reviewed-by: Rob Clark <robdclark@gmail.com> Tested-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
1 parent 4661270 commit ab5a60c

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

‎drivers/gpu/drm/omapdrm/omap_gem.c‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,6 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
233233

234234
WARN_ON(omap_obj->pages);
235235

236-
/* TODO: __GFP_DMA32 .. but somehow GFP_HIGHMEM is coming from the
237-
* mapping_gfp_mask(mapping) which conflicts w/ GFP_DMA32.. probably
238-
* we actually want CMA memory for it all anyways..
239-
*/
240236
pages = drm_gem_get_pages(obj, GFP_KERNEL);
241237
if (IS_ERR(pages)) {
242238
dev_err(obj->dev->dev, "could not get pages: %ld\n", PTR_ERR(pages));
@@ -1347,6 +1343,7 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev,
13471343
struct omap_drm_private *priv = dev->dev_private;
13481344
struct omap_gem_object *omap_obj;
13491345
struct drm_gem_object *obj = NULL;
1346+
struct address_space *mapping;
13501347
size_t size;
13511348
int ret;
13521349

@@ -1404,14 +1401,16 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev,
14041401
omap_obj->height = gsize.tiled.height;
14051402
}
14061403

1407-
ret = 0;
1408-
if (flags & (OMAP_BO_DMA|OMAP_BO_EXT_MEM))
1404+
if (flags & (OMAP_BO_DMA|OMAP_BO_EXT_MEM)) {
14091405
drm_gem_private_object_init(dev, obj, size);
1410-
else
1406+
} else {
14111407
ret = drm_gem_object_init(dev, obj, size);
1408+
if (ret)
1409+
goto fail;
14121410

1413-
if (ret)
1414-
goto fail;
1411+
mapping = file_inode(obj->filp)->i_mapping;
1412+
mapping_set_gfp_mask(mapping, GFP_USER | __GFP_DMA32);
1413+
}
14151414

14161415
return obj;
14171416

0 commit comments

Comments
 (0)