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

Commit 4fff827a authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "char: adsprpc: support pm restore for hibernation"

parents 3a94c5d2 fc72b995
Loading
Loading
Loading
Loading
+65 −0
Original line number Diff line number Diff line
@@ -4069,6 +4069,68 @@ static void fastrpc_deinit(void)
	}
}

#ifdef CONFIG_PM_SLEEP
static int fastrpc_restore(struct device *dev)
{
	int err = 0;
	struct fastrpc_apps *me = &gfa;
	struct smq_phy_page range;
	struct device_node *ion_node, *node;
	struct platform_device *ion_pdev;
	struct cma *cma;
	uint32_t val;

	pr_info("adsprpc: restore enter\n");
	if (of_device_is_compatible(dev->of_node,
					"qcom,msm-adsprpc-mem-region")) {
		me->dev = dev;
		range.addr = 0;
		ion_node = of_find_compatible_node(NULL, NULL, "qcom,msm-ion");
		if (ion_node) {
			for_each_available_child_of_node(ion_node, node) {
				if (of_property_read_u32(node, "reg", &val))
					continue;
				if (val != ION_ADSP_HEAP_ID)
					continue;
				ion_pdev = of_find_device_by_node(node);
				if (!ion_pdev)
					break;
				cma = dev_get_cma_area(&ion_pdev->dev);
				if (cma) {
					range.addr = cma_get_base(cma);
					range.size = (size_t)cma_get_size(cma);
				}
				break;
			}
		}
		if (range.addr && !of_property_read_bool(dev->of_node,
							 "restrict-access")) {
			int srcVM[1] = {VMID_HLOS};
			int destVM[4] = {VMID_HLOS, VMID_MSS_MSA, VMID_SSC_Q6,
						VMID_ADSP_Q6};
			int destVMperm[4] = {PERM_READ | PERM_WRITE | PERM_EXEC,
				PERM_READ | PERM_WRITE | PERM_EXEC,
				PERM_READ | PERM_WRITE | PERM_EXEC,
				PERM_READ | PERM_WRITE | PERM_EXEC,
				};

			VERIFY(err, !hyp_assign_phys(range.addr, range.size,
					srcVM, 1, destVM, destVMperm, 4));
			if (err)
				return err;
			me->range.addr = range.addr;
			me->range.size = range.size;
		}
	}
	pr_info("adsprpc: restore exit\n");
	return 0;
}

static const struct dev_pm_ops fastrpc_pm = {
	.restore = fastrpc_restore,
};
#endif

static struct platform_driver fastrpc_driver = {
	.probe = fastrpc_probe,
	.driver = {
@@ -4076,6 +4138,9 @@ static struct platform_driver fastrpc_driver = {
		.owner = THIS_MODULE,
		.of_match_table = fastrpc_match_table,
		.suppress_bind_attrs = true,
#ifdef CONFIG_PM_SLEEP
		.pm = &fastrpc_pm,
#endif
	},
};