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

Commit 0d4704a6 authored by Murali Nalajala's avatar Murali Nalajala Committed by Gerrit - the friendly Code Review server
Browse files

haven: irq_lend: add support for IRQ notifications



Currently IRQ APIs are combined with notifications to VMs for sharing the
handles. This limit the clients for managing the error handling from the
drivers. Hence separate the notifications from the actual APIs so that
clients manage the error handling better. Add support for notifications
like IRQ_LEND/ACCEPT/RELEASE from SVM to PVM when SVM accept the irq
handle shared by PVM.

Change-Id: I49999c2d9494c68b1542680e521c012a25e3f6a8
Signed-off-by: default avatarppadasal <quic_ppadasal@quicinc.com>
parent 28ca2b9d
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -296,7 +296,9 @@ static int fts_ts_vm_handle_vm_hardware(struct fts_ts_data *fts_data)
	return rc;
}

static void fts_ts_vm_irq_on_lend_callback(void *data, enum hh_irq_label label)
static void fts_ts_vm_irq_on_lend_callback(void *data,
					unsigned long notif_type,
					enum hh_irq_label label)
{
	struct fts_ts_data *fts_data = data;
	struct irq_data *irq_data;
@@ -472,6 +474,10 @@ static void fts_ts_trusted_touch_vm_mode_disable(struct fts_ts_data *fts_data)
			pr_err("Failed to release irq rc:%d\n", rc);
		else
			atomic_set(&fts_data->vm_info->tvm_owns_irq, 0);

		rc = hh_irq_release_notify(fts_data->vm_info->irq_label);
		if (rc)
			pr_err("Failed to notify release irq rc:%d\n", rc);
	}
	atomic_set(&fts_data->trusted_touch_enabled, 0);
	reinit_completion(&fts_data->resource_checkpoint);
@@ -600,6 +606,7 @@ static void fts_ts_trusted_touch_complete(struct fts_ts_data *fts_data)
}

static void fts_ts_vm_irq_on_release_callback(void *data,
					unsigned long notif_type,
					enum hh_irq_label label)
{
	struct fts_ts_data *fts_data = data;
@@ -730,7 +737,7 @@ static int fts_ts_trusted_touch_vm_mode_enable(struct fts_ts_data *fts_data)
	}
	atomic_set(&vm_info->pvm_owns_iomem, 0);

	rc = hh_irq_lend(vm_info->irq_label, vm_info->vm_name,
	rc = hh_irq_lend_v2(vm_info->irq_label, vm_info->vm_name,
		fts_data->irq, &fts_ts_vm_irq_on_release_callback, fts_data);
	if (rc) {
		pr_err("Failed to lend irq\n");
@@ -738,6 +745,12 @@ static int fts_ts_trusted_touch_vm_mode_enable(struct fts_ts_data *fts_data)
	}
	atomic_set(&vm_info->pvm_owns_irq, 0);

	rc = hh_irq_lend_notify(vm_info->irq_label);
	if (rc) {
		pr_err("Failed to notify irq\n");
		return -EINVAL;
	}

	reinit_completion(&fts_data->trusted_touch_powerdown);
	atomic_set(&fts_data->trusted_touch_enabled, 1);
	pr_debug("trusted touch enabled\n");
@@ -809,7 +822,7 @@ static int fts_ts_vm_init(struct fts_ts_data *fts_data)
		goto init_fail;
	}
	vm_info->mem_cookie = mem_cookie;
	rc = hh_irq_wait_for_lend(vm_info->irq_label, HH_PRIMARY_VM,
	rc = hh_irq_wait_for_lend_v2(vm_info->irq_label, HH_PRIMARY_VM,
			&fts_ts_vm_irq_on_lend_callback, fts_data);
	atomic_set(&vm_info->tvm_owns_irq, 0);
	atomic_set(&vm_info->tvm_owns_iomem, 0);
+18 −4
Original line number Diff line number Diff line
@@ -301,7 +301,9 @@ static int fts_vm_handle_vm_hardware(struct fts_ts_info *info)
	return rc;
}

static void fts_vm_irq_on_lend_callback(void *data, enum hh_irq_label label)
static void fts_vm_irq_on_lend_callback(void *data,
					unsigned long notif_type,
					enum hh_irq_label label)
{
	struct fts_ts_info *info = data;
	struct irq_data *irq_data;
@@ -477,6 +479,10 @@ static void fts_trusted_touch_vm_mode_disable(struct fts_ts_info *info)
			pr_err("Failed to release irq rc:%d\n", rc);
		else
			atomic_set(&info->vm_info->tvm_owns_irq, 0);

		rc = hh_irq_release_notify(info->vm_info->irq_label);
		if (rc)
			pr_err("Failed to notify release irq rc:%d\n", rc);
	}
	atomic_set(&info->trusted_touch_enabled, 0);
	reinit_completion(&info->resource_checkpoint);
@@ -604,7 +610,9 @@ static void fts_trusted_touch_complete(struct fts_ts_info *info)
	}
}

static void fts_vm_irq_on_release_callback(void *data, enum hh_irq_label label)
static void fts_vm_irq_on_release_callback(void *data,
					unsigned long notif_type,
					enum hh_irq_label label)
{
	struct fts_ts_info *info = data;
	int rc = 0;
@@ -735,7 +743,7 @@ static int fts_trusted_touch_vm_mode_enable(struct fts_ts_info *info)
	}
	atomic_set(&vm_info->pvm_owns_iomem, 0);

	rc = hh_irq_lend(vm_info->irq_label, vm_info->vm_name,
	rc = hh_irq_lend_v2(vm_info->irq_label, vm_info->vm_name,
		info->client->irq, &fts_vm_irq_on_release_callback, info);
	if (rc) {
		pr_err("Failed to lend irq\n");
@@ -743,6 +751,12 @@ static int fts_trusted_touch_vm_mode_enable(struct fts_ts_info *info)
	}
	atomic_set(&vm_info->pvm_owns_irq, 0);

	rc = hh_irq_lend_notify(vm_info->irq_label);
	if (rc) {
		pr_err("Failed to notify irq\n");
		return -EINVAL;
	}

	reinit_completion(&info->trusted_touch_powerdown);
	atomic_set(&info->trusted_touch_enabled, 1);
	pr_debug("trusted touch enabled\n");
@@ -813,7 +827,7 @@ static int fts_vm_init(struct fts_ts_info *info)
		goto init_fail;
	}
	vm_info->mem_cookie = mem_cookie;
	rc = hh_irq_wait_for_lend(vm_info->irq_label, HH_PRIMARY_VM,
	rc = hh_irq_wait_for_lend_v2(vm_info->irq_label, HH_PRIMARY_VM,
			&fts_vm_irq_on_lend_callback, info);
	atomic_set(&vm_info->tvm_owns_irq, 0);
	atomic_set(&vm_info->tvm_owns_iomem, 0);