drm/msm: Add fault-injection support
Intended as a way to trigger error paths in mesa. Signed-off-by: Rob Clark <robdclark@chromium.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Patchwork: https://patchwork.freedesktop.org/patch/496710/ Link: https://lore.kernel.org/r/20220807172848.2432845-1-robdclark@gmail.com
This commit is contained in:
parent
d95c196ddb
commit
6d29709de8
@ -7,6 +7,7 @@
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/fault-inject.h>
|
||||
|
||||
#include <drm/drm_debugfs.h>
|
||||
#include <drm/drm_file.h>
|
||||
@ -326,6 +327,13 @@ void msm_debugfs_init(struct drm_minor *minor)
|
||||
|
||||
if (priv->kms && priv->kms->funcs->debugfs_init)
|
||||
priv->kms->funcs->debugfs_init(priv->kms, minor);
|
||||
|
||||
#ifdef CONFIG_FAULT_INJECTION
|
||||
fault_create_debugfs_attr("fail_gem_alloc", minor->debugfs_root,
|
||||
&fail_gem_alloc);
|
||||
fault_create_debugfs_attr("fail_gem_iova", minor->debugfs_root,
|
||||
&fail_gem_iova);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/fault-inject.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/sched/mm.h>
|
||||
#include <linux/uaccess.h>
|
||||
@ -78,6 +79,11 @@ static bool modeset = true;
|
||||
MODULE_PARM_DESC(modeset, "Use kernel modesetting [KMS] (1=on (default), 0=disable)");
|
||||
module_param(modeset, bool, 0600);
|
||||
|
||||
#ifdef CONFIG_FAULT_INJECTION
|
||||
DECLARE_FAULT_ATTR(fail_gem_alloc);
|
||||
DECLARE_FAULT_ATTR(fail_gem_iova);
|
||||
#endif
|
||||
|
||||
static irqreturn_t msm_irq(int irq, void *arg)
|
||||
{
|
||||
struct drm_device *dev = arg;
|
||||
@ -701,6 +707,9 @@ static int msm_ioctl_gem_new(struct drm_device *dev, void *data,
|
||||
flags |= MSM_BO_WC;
|
||||
}
|
||||
|
||||
if (should_fail(&fail_gem_alloc, args->size))
|
||||
return -ENOMEM;
|
||||
|
||||
return msm_gem_new_handle(dev, file, args->size,
|
||||
args->flags, &args->handle, NULL);
|
||||
}
|
||||
@ -762,6 +771,9 @@ static int msm_ioctl_gem_info_iova(struct drm_device *dev,
|
||||
if (!priv->gpu)
|
||||
return -EINVAL;
|
||||
|
||||
if (should_fail(&fail_gem_iova, obj->size))
|
||||
return -ENOMEM;
|
||||
|
||||
/*
|
||||
* Don't pin the memory here - just get an address so that userspace can
|
||||
* be productive
|
||||
@ -783,6 +795,9 @@ static int msm_ioctl_gem_info_set_iova(struct drm_device *dev,
|
||||
if (priv->gpu->aspace == ctx->aspace)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (should_fail(&fail_gem_iova, obj->size))
|
||||
return -ENOMEM;
|
||||
|
||||
return msm_gem_set_iova(obj, ctx->aspace, iova);
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,13 @@
|
||||
#include <drm/msm_drm.h>
|
||||
#include <drm/drm_gem.h>
|
||||
|
||||
#ifdef CONFIG_FAULT_INJECTION
|
||||
extern struct fault_attr fail_gem_alloc;
|
||||
extern struct fault_attr fail_gem_iova;
|
||||
#else
|
||||
# define should_fail(attr, size) 0
|
||||
#endif
|
||||
|
||||
struct msm_kms;
|
||||
struct msm_gpu;
|
||||
struct msm_mmu;
|
||||
|
Loading…
x
Reference in New Issue
Block a user