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

Commit 97a1c935 authored by Shrenuj Bansal's avatar Shrenuj Bansal
Browse files

msm: kgsl: Add adreno_setproperty_compat to adreno_compat.c



With the addition of the power constraints interface, we now have
need of a compat version of adreno_setproperty due to the contents
of struct kgsl_device_constraint.

Change-Id: I2d4a5b8f26acc3433a11a390b0472acae383140d
Signed-off-by: default avatarShrenuj Bansal <shrenujb@codeaurora.org>
parent 5830ea78
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2614,7 +2614,7 @@ static int adreno_getproperty(struct kgsl_device *device,
	return status;
}

static int adreno_set_constraint(struct kgsl_device *device,
int adreno_set_constraint(struct kgsl_device *device,
				struct kgsl_context *context,
				struct kgsl_device_constraint *constraint)
{
@@ -3244,6 +3244,7 @@ static const struct kgsl_functable adreno_functable = {
	.drawctxt_detach = adreno_drawctxt_detach,
	.drawctxt_destroy = adreno_drawctxt_destroy,
	.setproperty = adreno_setproperty,
	.setproperty_compat = adreno_setproperty_compat,
	.drawctxt_sched = adreno_drawctxt_sched,
	.resume = adreno_dispatcher_start,
};
+4 −0
Original line number Diff line number Diff line
@@ -595,6 +595,10 @@ int adreno_perfcounter_query_group(struct adreno_device *adreno_dev,
int adreno_perfcounter_read_group(struct adreno_device *adreno_dev,
	struct kgsl_perfcounter_read_group __user *reads, unsigned int count);

int adreno_set_constraint(struct kgsl_device *device,
				struct kgsl_context *context,
				struct kgsl_device_constraint *constraint);

void adreno_shadermem_regread(struct kgsl_device *device,
						unsigned int offsetwords,
						unsigned int *value);
+50 −0
Original line number Diff line number Diff line
@@ -95,6 +95,56 @@ int adreno_getproperty_compat(struct kgsl_device *device,
	return status;
}

int adreno_setproperty_compat(struct kgsl_device_private *dev_priv,
				enum kgsl_property_type type,
				void __user *value,
				unsigned int sizebytes)
{
	int status = -EINVAL;
	struct kgsl_device *device = dev_priv->device;

	switch (type) {
	case KGSL_PROP_PWR_CONSTRAINT: {
			struct kgsl_device_constraint_compat constraint32;
			struct kgsl_device_constraint constraint;
			struct kgsl_context *context;

			if (sizebytes != sizeof(constraint32))
				break;

			if (copy_from_user(&constraint32, value,
				sizeof(constraint32))) {
				status = -EFAULT;
				break;
			}

			/* Populate the real constraint type from the compat */
			constraint.type = constraint32.type;
			constraint.context_id = constraint32.context_id;
			constraint.data = compat_ptr(constraint32.data);
			constraint.size = (size_t)constraint32.size;

			context = kgsl_context_get_owner(dev_priv,
							constraint.context_id);
			if (context == NULL)
				break;
			status = adreno_set_constraint(device, context,
								&constraint);
			kgsl_context_put(context);
		}
		break;
	default:
		/*
		 * Call adreno_setproperty in case the property type was
		 * KGSL_PROP_PWRCTRL
		 */
		status = device->ftbl->setproperty(dev_priv, type, value,
						sizebytes);
	}

	return status;
}

long adreno_compat_ioctl(struct kgsl_device_private *dev_priv,
			      unsigned int cmd, void *data)
{
+6 −1
Original line number Diff line number Diff line
@@ -1340,7 +1340,12 @@ long kgsl_ioctl_device_setproperty(struct kgsl_device_private *dev_priv,
	/* The getproperty struct is reused for setproperty too */
	struct kgsl_device_getproperty *param = data;

	if (dev_priv->device->ftbl->setproperty)
	/* Reroute to compat version if coming from compat_ioctl */
	if (is_compat_task())
		result = dev_priv->device->ftbl->setproperty_compat(
			dev_priv, param->type, param->value,
			param->sizebytes);
	else if (dev_priv->device->ftbl->setproperty)
		result = dev_priv->device->ftbl->setproperty(
			dev_priv, param->type, param->value,
			param->sizebytes);
+21 −0
Original line number Diff line number Diff line
@@ -46,6 +46,13 @@ struct kgsl_shadowprop_compat {
	unsigned int flags;
};

struct kgsl_device_constraint_compat {
	unsigned int type;
	unsigned int context_id;
	compat_uptr_t data;
	compat_size_t size;
};

struct kgsl_device_getproperty_compat {
	unsigned int type;
	compat_uptr_t value;
@@ -252,6 +259,11 @@ int adreno_getproperty_compat(struct kgsl_device *device,
			void __user *value,
			size_t sizebytes);

int adreno_setproperty_compat(struct kgsl_device_private *dev_priv,
				enum kgsl_property_type type,
				void __user *value,
				unsigned int sizebytes);

long adreno_compat_ioctl(struct kgsl_device_private *dev_priv,
			unsigned int cmd, void *data);

@@ -269,12 +281,21 @@ static inline long kgsl_compat_ioctl(struct file *filep, unsigned int cmd,
{
	BUG();
}

static inline int adreno_getproperty_compat(struct kgsl_device *device,
				enum kgsl_property_type type,
				void __user *value, size_t sizebytes)
{
	BUG();
}

static inline int adreno_setproperty_compat(struct kgsl_device_private
				*dev_priv, enum kgsl_property_type type,
				void __user *value, unsigned int sizebytes)
{
	BUG();
}

static inline long adreno_compat_ioctl(struct kgsl_device_private *dev_priv,
				unsigned int cmd, void *data)
{
Loading