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

Commit e049bee5 authored by Konstantin Dorfman's avatar Konstantin Dorfman
Browse files

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



This change decreases reference count on shared memory buffers locked
by hlos application, because rpmsg channel device removed when secure
processor communication endpoint disconnected.  The reason for such is
ssr event.

Change-Id: Ifd3167101a7c20160d0e8bae98f79ab424db2390
Signed-off-by: default avatarKonstantin Dorfman <kdorfman@codeaurora.org>
parent fa0b07e3
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 */