Эх сурвалжийг харах

disp: msm: sde: reserve resources on trusted vm usecase start

The MEM & IRQ lend handlers signals the resources
are lent from the primary VM. Reserve the SDE HW
resources in trusted VM using the cont-splash path
and setup the SDE & DRM software states. Set the
DSI connector status to active for the handoff
display during the start and disable it at the end
of the session.

Change-Id: I75b6df735eb5609cc521808aca0ddfb0b3993e84
Signed-off-by: Veera Sundaram Sankaran <[email protected]>
Veera Sundaram Sankaran 5 жил өмнө
parent
commit
96438460c6

+ 78 - 0
msm/sde/sde_kms.c

@@ -1222,6 +1222,8 @@ int sde_kms_vm_trusted_post_commit(struct sde_kms *sde_kms,
 
 	sde_hw_set_lutdma_sid(sde_kms->hw_sid, 0);
 
+	sde_kms_vm_trusted_resource_deinit(sde_kms);
+
 	if (vm_ops->vm_release)
 		rc = vm_ops->vm_release(sde_kms);
 
@@ -4130,6 +4132,82 @@ struct msm_kms *sde_kms_init(struct drm_device *dev)
 	return &sde_kms->base;
 }
 
+void sde_kms_vm_trusted_resource_deinit(struct sde_kms *sde_kms)
+{
+	struct dsi_display *display;
+	struct sde_splash_display *handoff_display;
+	int i;
+
+	for (i = 0; i < sde_kms->dsi_display_count; i++) {
+		handoff_display = &sde_kms->splash_data.splash_display[i];
+		display = (struct dsi_display *)sde_kms->dsi_displays[i];
+
+		if (handoff_display->cont_splash_enabled)
+			_sde_kms_free_splash_display_data(sde_kms,
+						handoff_display);
+		dsi_display_set_active_state(display, false);
+	}
+
+	memset(&sde_kms->splash_data, 0, sizeof(struct sde_splash_data));
+}
+
+int sde_kms_vm_trusted_resource_init(struct sde_kms *sde_kms)
+{
+	struct drm_device *dev;
+	struct msm_drm_private *priv;
+	struct sde_splash_display *handoff_display;
+	struct dsi_display *display;
+	int ret, i;
+
+	if (!sde_kms || !sde_kms->dev || !sde_kms->dev->dev_private) {
+		SDE_ERROR("invalid params\n");
+		return -EINVAL;
+	}
+
+	if (!sde_kms->vm->vm_ops.vm_owns_hw(sde_kms)) {
+		SDE_DEBUG(
+		   "skipping sde res init as device assign is not completed\n");
+		return 0;
+	}
+
+	if (sde_kms->dsi_display_count != 1) {
+		SDE_ERROR("no. of displays not supported:%d\n",
+				sde_kms->dsi_display_count);
+		return -EINVAL;
+	}
+
+	dev = sde_kms->dev;
+	priv = dev->dev_private;
+	sde_kms->splash_data.type = SDE_VM_HANDOFF;
+	sde_kms->splash_data.num_splash_displays = sde_kms->dsi_display_count;
+
+	ret = sde_rm_cont_splash_res_init(priv, &sde_kms->rm,
+				&sde_kms->splash_data, sde_kms->catalog);
+
+	for (i = 0; i < sde_kms->dsi_display_count; i++) {
+		handoff_display = &sde_kms->splash_data.splash_display[i];
+		display = (struct dsi_display *)sde_kms->dsi_displays[i];
+		if (!handoff_display->cont_splash_enabled || ret)
+			_sde_kms_free_splash_display_data(sde_kms,
+							handoff_display);
+		else
+			dsi_display_set_active_state(display, true);
+	}
+
+	ret = sde_kms_cont_splash_config(&sde_kms->base);
+	if (ret) {
+		SDE_ERROR("error in setting handoff configs\n");
+		goto error;
+	}
+
+	return 0;
+
+error:
+	sde_kms_vm_trusted_resource_deinit(sde_kms);
+
+	return ret;
+}
+
 static int _sde_kms_register_events(struct msm_kms *kms,
 		struct drm_mode_object *obj, u32 event, bool en)
 {

+ 14 - 1
msm/sde/sde_kms.h

@@ -701,6 +701,19 @@ void sde_kms_irq_enable_notify(struct sde_kms *sde_kms, bool enable);
  */
 int sde_kms_get_io_resources(struct sde_kms *kms, struct msm_io_res *io_res);
 
+/**
+ * sde_kms_vm_trusted_resource_init - reserve/initialize the HW/SW resources
+ * @sde_kms: poiner to sde_kms structure
+ * return: 0 on success; error code otherwise
+ */
+int sde_kms_vm_trusted_resource_init(struct sde_kms *sde_kms);
+
+/**
+ * sde_kms_vm_trusted_resource_deinit - release the HW/SW resources
+ * @sde_kms: poiner to sde_kms structure
+ */
+void sde_kms_vm_trusted_resource_deinit(struct sde_kms *sde_kms);
+
 /**
  * sde_kms_vm_trusted_post_commit - function to prepare the VM after the
  *				    last commit before releasing the HW
@@ -710,6 +723,7 @@ int sde_kms_get_io_resources(struct sde_kms *kms, struct msm_io_res *io_res);
  */
 int sde_kms_vm_trusted_post_commit(struct sde_kms *sde_kms,
 	struct drm_atomic_state *state);
+
 /**
  * sde_kms_vm_primary_post_commit - function to prepare the VM after the
  *				    last commit before assign the HW
@@ -738,5 +752,4 @@ int sde_kms_vm_trusted_prepare_commit(struct sde_kms *sde_kms,
  */
 int sde_kms_vm_primary_prepare_commit(struct sde_kms *sde_kms,
 					   struct drm_atomic_state *state);
-
 #endif /* __sde_kms_H__ */

+ 9 - 0
msm/sde/sde_vm_trusted.c

@@ -69,6 +69,7 @@ void sde_vm_irq_lend_notification_handler(void *req, enum hh_irq_label label)
 	struct sde_vm_irq_entry irq_temp, *found = NULL;
 	struct irq_data *exp_irq_data, *acc_irq_data;
 	int accepted_irq, expected_irq;
+	int rc;
 
 	if (!req) {
 		SDE_ERROR("invalid data on lend notification\n");
@@ -121,6 +122,10 @@ void sde_vm_irq_lend_notification_handler(void *req, enum hh_irq_label label)
 			exp_irq_data->hwirq);
 
 	atomic_inc(&sde_vm->base.n_irq_lent);
+
+	rc = sde_kms_vm_trusted_resource_init(sde_kms);
+	if (rc)
+		SDE_ERROR("vm resource init failed\n");
 end:
 	mutex_unlock(&sde_vm->base.vm_res_lock);
 }
@@ -186,6 +191,10 @@ static void sde_vm_mem_lend_notification_handler(enum hh_mem_notifier_tag tag,
 	SDE_INFO("mem accept succeeded for tag: %d label: %d\n", tag,
 				payload->label);
 
+	rc = sde_kms_vm_trusted_resource_init(sde_kms);
+	if (rc)
+		SDE_ERROR("vm resource init failed\n");
+
 accept_fail:
 	kfree(acl_desc);
 acl_fail: