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

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

Merge "soc: qcom: smp2p: keeping inbound entry on freeze"

parents fe45e480 104fcf97
Loading
Loading
Loading
Loading
+53 −27
Original line number Diff line number Diff line
@@ -604,31 +604,6 @@ static int qcom_smp2p_alloc_item(struct platform_device *pdev,
	return ret;
}

static void qcom_smp2p_release_item(struct device *dev,
					struct qcom_smp2p *smp2p)
{
	struct smp2p_entry *entry;
	struct smp2p_entry *next_entry;

	/* Walk through the out bound list and release state and entry */
	list_for_each_entry_safe(entry, next_entry, &smp2p->outbound, node) {
		qcom_smem_state_unregister(entry->state);
		list_del(&entry->node);
		devm_kfree(smp2p->dev, entry);
	}
	INIT_LIST_HEAD(&smp2p->outbound);

	/* Walk through the inbound list and release domain and entry */
	list_for_each_entry_safe(entry, next_entry, &smp2p->inbound, node) {
		irq_domain_remove(entry->domain);
		list_del(&entry->node);
		devm_kfree(smp2p->dev, entry);
	}
	INIT_LIST_HEAD(&smp2p->inbound);
	/* remove wakeup source */
	wakeup_source_trash(&smp2p->ws);
}

static int qcom_smp2p_probe(struct platform_device *pdev)
{
	struct smp2p_entry *entry;
@@ -749,10 +724,43 @@ static int qcom_smp2p_resume(struct device *dev)
{
	int ret = 0;
	struct qcom_smp2p *smp2p = dev_get_drvdata(dev);
	struct smp2p_entry *entry;
	struct device_node *node;
	struct platform_device *pdev = container_of(dev, struct
						platform_device, dev);

	ret = qcom_smp2p_alloc_item(pdev, smp2p);
	ret = qcom_smp2p_alloc_outbound_item(smp2p);
	if (ret < 0)
		goto print_err;

	for_each_available_child_of_node(pdev->dev.of_node, node) {
		entry = devm_kzalloc(&pdev->dev, sizeof(*entry), GFP_KERNEL);
		if (!entry) {
			ret = -ENOMEM;
			goto print_err;
		}

		entry->smp2p = smp2p;
		spin_lock_init(&entry->lock);
		ret = of_property_read_string(node, "qcom,entry-name",
								&entry->name);
		if (ret < 0)
			goto print_err;

		if (!of_property_read_bool(node, "interrupt-controller")) {
			ret = qcom_smp2p_outbound_entry(smp2p, entry, node);
			if (ret < 0)
				goto print_err;

			list_add(&entry->node, &smp2p->outbound);
		}
	}
	wakeup_source_init(&smp2p->ws, "smp2p");

	/* Kick the outgoing edge after allocating entries */
	qcom_smp2p_kick(smp2p);

print_err:
	if (ret < 0 && ret != -EEXIST)
		dev_err(dev, "failed to alloc items ret = %d\n", ret);

@@ -762,8 +770,26 @@ static int qcom_smp2p_resume(struct device *dev)
static int qcom_smp2p_suspend(struct device *dev)
{
	struct qcom_smp2p *smp2p = dev_get_drvdata(dev);
	struct smp2p_entry *entry;
	struct smp2p_entry *next_entry;

	/* Walk through the out bound list and release state and entry */
	list_for_each_entry_safe(entry, next_entry, &smp2p->outbound, node) {
		qcom_smem_state_unregister(entry->state);
		list_del(&entry->node);
		devm_kfree(smp2p->dev, entry);
	}
	INIT_LIST_HEAD(&smp2p->outbound);

	qcom_smp2p_release_item(dev, smp2p);
	/* Walk through the in bound list and reset last value */
	list_for_each_entry_safe(entry, next_entry, &smp2p->inbound, node) {
		entry->last_value = 0;
	}
	/* make null to point it to valid smem item during first interrupt */
	smp2p->in = NULL;
	smp2p->valid_entries = 0;
	/* remove wakeup source */
	wakeup_source_trash(&smp2p->ws);
	return 0;
}