mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-19 00:36:44 +07:00
drm/etnaviv: populate GEM objects on cpu_prep
CPU prep is the point where we can reasonably return an error to userspace when something goes wrong while populating the object. If we leave the object unpopulated at this point, the allocation will happen in the fault handler when userspace accesses the object through the mmap space, where we don't have any other option than to OOM the system. Signed-off-by: Lucas Stach <dev@lynxeye.de>
This commit is contained in:
parent
f91ac470a8
commit
8cc47b3ea0
@ -413,6 +413,16 @@ int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op,
|
||||
bool write = !!(op & ETNA_PREP_WRITE);
|
||||
int ret;
|
||||
|
||||
if (!etnaviv_obj->sgt) {
|
||||
void *ret;
|
||||
|
||||
mutex_lock(&etnaviv_obj->lock);
|
||||
ret = etnaviv_gem_get_pages(etnaviv_obj);
|
||||
mutex_unlock(&etnaviv_obj->lock);
|
||||
if (IS_ERR(ret))
|
||||
return PTR_ERR(ret);
|
||||
}
|
||||
|
||||
if (op & ETNA_PREP_NOSYNC) {
|
||||
if (!reservation_object_test_signaled_rcu(etnaviv_obj->resv,
|
||||
write))
|
||||
@ -427,16 +437,6 @@ int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op,
|
||||
}
|
||||
|
||||
if (etnaviv_obj->flags & ETNA_BO_CACHED) {
|
||||
if (!etnaviv_obj->sgt) {
|
||||
void *ret;
|
||||
|
||||
mutex_lock(&etnaviv_obj->lock);
|
||||
ret = etnaviv_gem_get_pages(etnaviv_obj);
|
||||
mutex_unlock(&etnaviv_obj->lock);
|
||||
if (IS_ERR(ret))
|
||||
return PTR_ERR(ret);
|
||||
}
|
||||
|
||||
dma_sync_sg_for_cpu(dev->dev, etnaviv_obj->sgt->sgl,
|
||||
etnaviv_obj->sgt->nents,
|
||||
etnaviv_op_to_dma_dir(op));
|
||||
|
Loading…
Reference in New Issue
Block a user