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

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

Merge "soc: qcom: spcom: release ion buffer on rpmsg channel remove"

parents efe390ac e049bee5
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -1935,17 +1935,27 @@ static int spcom_rpdev_probe(struct rpmsg_device *rpdev)
static void spcom_rpdev_remove(struct rpmsg_device *rpdev)
{
	struct spcom_channel *ch;
	int i;

	if (!rpdev) {
		pr_err("rpdev is NULL\n");
		return;
	}

	dev_info(&rpdev->dev, "rpmsg device %s removed\n", rpdev->id.name);
	ch = dev_get_drvdata(&rpdev->dev);
	if (!ch) {
		pr_err("channel %s not found\n", rpdev->id.name);
		return;
	}
	/* release all ion buffers locked by the channel */
	for (i = 0 ; i < ARRAY_SIZE(ch->dmabuf_handle_table) ; i++) {
		if (ch->dmabuf_handle_table[i]) {
			dma_buf_put(ch->dmabuf_handle_table[i]);
			ch->dmabuf_handle_table[i] = NULL;
			dev_info(&rpdev->dev, "dma_buf_put(%d)\n", i);
		}
	}
	mutex_lock(&ch->lock);
	ch->rpdev = NULL;
	ch->rpmsg_abort = true;
@@ -1956,7 +1966,6 @@ static void spcom_rpdev_remove(struct rpmsg_device *rpdev)
	if (atomic_dec_and_test(&spcom_dev->rpmsg_dev_count))
		complete_all(&spcom_dev->rpmsg_state_change);

	dev_info(&rpdev->dev, "rpmsg device %s removed\n", rpdev->id.name);
}

/* register rpmsg driver to match with channel ch_name */