Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7bd05939 authored by Hareesh Gundu's avatar Hareesh Gundu
Browse files

msm: kgsl: Add facility to BUG_ON for a gpu fault



Few gpu faults need system level information like voltages,
interface clock etc. This information can't be extracted
through the snapshot dump. Add a facility to force panic
on gpu fault, which will help to extract additional
information from the ramdumps.

To trigger BUG_ON for a gpu fault:
echo 1  > /sys/class/kgsl/kgsl-3d0/snapshot/force_panic

Change-Id: I020b5518fcaedd4fecc572b580a989bf117f6ceb
Signed-off-by: default avatarHareesh Gundu <hareeshg@codeaurora.org>
parent 3fb740b2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -263,6 +263,7 @@ struct kgsl_device {
	struct kgsl_snapshot *snapshot;

	u32 snapshot_faultcount;	/* Total number of faults since boot */
	bool force_panic;		/* Force panic after snapshot dump */
	struct kobject snapshot_kobj;

	struct kobject ppd_kobj;
+37 −3
Original line number Diff line number Diff line
@@ -803,6 +803,29 @@ static ssize_t faultcount_store(struct kgsl_device *device, const char *buf,
	return count;
}

/* Show the force_panic request status */
static ssize_t force_panic_show(struct kgsl_device *device, char *buf)
{
	return snprintf(buf, PAGE_SIZE, "%d\n", device->force_panic);
}

/* Store the panic request value to force_panic */
static ssize_t force_panic_store(struct kgsl_device *device, const char *buf,
	size_t count)
{
	unsigned int val = 0;
	int ret;

	if (device && count > 0)
		device->force_panic = 0;

	ret = kgsl_sysfs_store(buf, &val);

	if (!ret && device)
		device->force_panic = (bool)val;

	return (ssize_t) ret < 0 ? ret : count;
}
/* Show the timestamp of the last collected snapshot */
static ssize_t timestamp_show(struct kgsl_device *device, char *buf)
{
@@ -828,6 +851,7 @@ struct kgsl_snapshot_attribute attr_##_name = { \

static SNAPSHOT_ATTR(timestamp, 0444, timestamp_show, NULL);
static SNAPSHOT_ATTR(faultcount, 0644, faultcount_show, faultcount_store);
static SNAPSHOT_ATTR(force_panic, 0644, force_panic_show, force_panic_store);

static ssize_t snapshot_sysfs_show(struct kobject *kobj,
	struct attribute *attr, char *buf)
@@ -907,6 +931,7 @@ int kgsl_device_snapshot_init(struct kgsl_device *device)

	device->snapshot = NULL;
	device->snapshot_faultcount = 0;
	device->force_panic = 0;

	ret = kobject_init_and_add(&device->snapshot_kobj, &ktype_snapshot,
		&device->dev->kobj, "snapshot");
@@ -922,7 +947,11 @@ int kgsl_device_snapshot_init(struct kgsl_device *device)
		goto done;

	ret  = sysfs_create_file(&device->snapshot_kobj, &attr_faultcount.attr);
	if (ret)
		goto done;

	ret  = sysfs_create_file(&device->snapshot_kobj,
			&attr_force_panic.attr);
done:
	return ret;
}
@@ -947,6 +976,7 @@ void kgsl_device_snapshot_close(struct kgsl_device *device)
	device->snapshot_memory.ptr = NULL;
	device->snapshot_memory.size = 0;
	device->snapshot_faultcount = 0;
	device->force_panic = 0;
}
EXPORT_SYMBOL(kgsl_device_snapshot_close);

@@ -1025,6 +1055,7 @@ void kgsl_snapshot_save_frozen_objs(struct work_struct *work)
{
	struct kgsl_snapshot *snapshot = container_of(work,
				struct kgsl_snapshot, work);
	struct kgsl_device *device = kgsl_get_device(KGSL_DEVICE_3D0);
	struct kgsl_snapshot_object *obj, *tmp;
	size_t size = 0;
	void *ptr;
@@ -1044,7 +1075,7 @@ void kgsl_snapshot_save_frozen_objs(struct work_struct *work)

	snapshot->mempool = vmalloc(size);
	if (snapshot->mempool != NULL)
		KGSL_CORE_ERR("snapshot: mempool address %p, size %zx\n",
		KGSL_DRV_ERR(device, "snapshot: mempool address %p, size %zx\n",
				snapshot->mempool, size);

	ptr = snapshot->mempool;
@@ -1069,12 +1100,15 @@ done:
	snapshot->process = NULL;

	if (snapshot->ib1base && !snapshot->ib1dumped)
		pr_warn("kgsl: snapshot: Active IB1:%016llx not dumped\n",
		KGSL_DRV_ERR(device,
				"snapshot: Active IB1:%016llx not dumped\n",
				snapshot->ib1base);
	else if (snapshot->ib2base && !snapshot->ib2dumped)
		pr_warn("kgsl: snapshot: Active IB2:%016llx not dumped\n",
		KGSL_DRV_ERR(device,
			       "snapshot: Active IB2:%016llx not dumped\n",
				snapshot->ib2base);

	complete_all(&snapshot->dump_gate);
	BUG_ON(device->force_panic);
	return;
}