From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796030489; b=4VM6QJOsbkWWHWhyWH8x9OiU5N5UgRi1PwYqdwY4c1eINjwFi0IGr8wFMFtg3G7DxT03 a7HZR4iuZTWo9kFv8klm3x9h04YshxkVDoSZPFquirZkCip4wYXNWnbg26WdbbyavXOuH W1NiDhk/d4q7oP1LSApYOeEkQDTII8IcPOwAAiovWU5nfHysCl8JyFXJTp6QmKIQApQf6 LBtKz5Hnz/tFepCUKsEK7+aG3MXU3SgVHX43DBzYIeoFgDaY0k3KDl5GiGoH2ATHLMnkT o7xjlsYmn6fMRZ1EZNJWN+oimvHeWViFodMxZwC/fKlDt6qjnpJPJyhXG3r/wwb4djA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796030489; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-Authority-Analysis:X-Proofpoint-GUID: X-Proofpoint-ORIG-GUID:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=PIL2BT/MQ2zhbdWocdZ8/fa4YasptX4VTZVlOio8juA=; b=D75QLPxBT67pvtasVgI7KLTJv0gJ1FAEPh1cx8FFYGqXHKkdmzkF1VHoXTXAeoTFvEE1 dQHPQ0dqFO9rqEEtxqq5oKI+KJOptIqejO7u/iMaPLh0rFzlTtiZ2FC7Zq0lnzp4QKUvk jb05UUj9j0SaatjqcwxbLIfC0E6ZEpoGzSrZn053A3vN3190qqq9nMAxYZxXa3KFLkOz+ 6EXu4w9jKnjcfb/szpwFnnp9ufL9k3dbPQ0SSDzS6A+HtfNa7HYqdA+k9Q3Sh9rbqMjT9 OuFPiWIHSix21otb5Pk/Bk/BoyUyhKV9jArHM2ihkzBsHJEd5sbZdPjVu9XWinPL2Aw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=NKNGQ5S5; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=VGwjcB1r; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66562606A320 for ; Mon, 30 Nov 2026 09:21:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 66562606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=NKNGQ5S5; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=VGwjcB1r Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AU8RdNT2138316 for ; Mon, 30 Nov 2026 09:21:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= PIL2BT/MQ2zhbdWocdZ8/fa4YasptX4VTZVlOio8juA=; b=NKNGQ5S5egnSb1aa EifKBOqOHb1Oegv24ZVIqp3Xuc1WD+RUWIaY3gycZNT+gB2Q1kjddV+hZyoB/5GX cXC005LoiF/SyVi8xq4+5siD81RF9l6nyqkQR/nLwxgaXIk48LytlnOUVAa7xJb7 cl/MOoqc13UEigQ5j61S6iTQfWKbbQPvZYGq+ocFycE4GcybZYUMTWNPFWnqT6LI B0r0jnz+6X9QD9AA0q8TAEacnFvJyfhgvd372AraSDz0hYYWIaxWiNdmGTfyYTlZ IUFY/sKceW6l1p4GzPOgliCAbVeWkVDHCBG3yc0kgWfueZT7wb3/uqMuvTemRpFl dmwG7Q== Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j95ndr831-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 30 Nov 2026 09:21:28 +0000 (GMT) Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-8a05a4396d2so8131536b3a.0 for ; Mon, 30 Nov 2026 01:21:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796030488; x=1796635288; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=PIL2BT/MQ2zhbdWocdZ8/fa4YasptX4VTZVlOio8juA=; b=VGwjcB1ru0pDzmXokzmdHybqN0lVteg+JvQAsFNiw7fV4ruiFopSYKHh2EC84ZJKST 9KZZm+i6JXsh/wayCaLT4UHIomYR6EAR/OjGGH4xU+vhEXMTO8mdPccV/VU3Mz7I5kZj Dd8AhLgLk2nXVhld5aae0/Cz7e6GaX8LmP6ahI/Oi6OOpiSzKVXnOwtMmPyyUeKF7gFK 89m6vyHYgmoox/PqQg04IJfv0f2H+cmZiDZHMvtcbpYavqlTnOE/aN9aE56yVCDTUqjp Ci7SJ+z2lXS6x7/j7CDa/QdWSgaVlW61aIC+QN8Y+d6yVbCNZeSMadJF6udxe/HV2tw3 4JPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796030488; x=1796635288; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PIL2BT/MQ2zhbdWocdZ8/fa4YasptX4VTZVlOio8juA=; b=pPzHB7MbxAy7tpzuw4SCyIvZazuAbcyTuu5vvzYn7BXDVVQ31/t+okLUz25kn2dmVy H1AyahpZOJEoMRhQOC0ctC+f0YhiCAEfNOIeXDXiAmNrM3hG+jvAq2jtVe9rYlE8Wpx9 vmpyEgfDJL385FvTVA7S9DnzsY4YSHqgGLF2Z49hEF0ZP2aROdWlLkqFOvdV/Z5ZIStp fiirI7I6y9e2UzwbnynxAwZ2zKIBHhn8W8llBX50my4HX7HSUbCJ3jOr4C67DXmFqNym LazA0swv64SvGP0l3Cd6eonu8vMkzcDqLpd0+L1Vi/jdAqk+zsqFSjptEWbZ02PzkvNf Ruwg== X-Forwarded-Encrypted: i=1; AL+hErG92DJVnQacDfWy2Xr3glHbDe27jfgrQ+4Bo4w0ZmT5s+SA2kFOwei9h6cYKr2zZKQx/oUkaUlRJvF1GBE=@vger.kernel.org X-Gm-Message-State: APuU4Z+qY71SJQ4WLMUgATY8UVs/QfKVyyRYdxn3z8JVdWK7V6MHLFMU l9lF1d0/ScPszn8nXUPQjM4yP8ht1fvQEXZFuoIZFv1HbF8Xo31sDwHFZdIxEe+7bMUxz1UmMSI TbRQtViKzLPlDQS7NVVTBmmuFLmRRDMRvpUeLid1lPtKwPRwFHSeTWZQmoX1Fi4Xaomo= X-Gm-Gg: AZFdTZfGaf0O0niWU0wmvKV22jwUamnNxKz6R9Myc+SByue6bQYHNbtsaNHFR10ddL0 +xVRf8Vwbu9xJjyIyKTMotZUjT01vZKIGIpixEUChO8mT370F2Kp4di2Qd7RNyvMERZm/AzlQV/ I29EdJbfPXWpkllDcjjhMmUV32S/Et89IXw98E9wdgmEDUd9sg2BHk4GfLtAYaNyot1TLEIBxsz RVGDdDs5JF9j70qW+5j+S6gHN9aq94YJD5rZSehvdEnuHHNfnGgSoRCGXl9Mq3GWxFGywrWxx9Q fogk2W+9xGx9DWN+olDd7Eto9+Y9pzDlRI9c7K48nHEE8KavdYxLmTyAh+9P7/8sO5tthdh9it+ Ffnpl3nPCevqjRewxnA0rAUOUiGgFvLSp3XhMIFCzaA291/TwHsb8h4RYDbF/QTmnx8MnDlB2nh 25bA== X-Received: by 2002:a05:6a00:14d6:b0:89e:71df:d6d5 with SMTP id d2e1a72fcca58-8c87bcbdc8emr30676726b3a.10.1796030487585; Mon, 30 Nov 2026 01:21:27 -0800 (PST) X-Received: by 2002:a05:6a00:14d6:b0:89e:71df:d6d5 with SMTP id d2e1a72fcca58-8c87bcbdc8emr30676705b3a.10.1796030487061; Mon, 30 Nov 2026 01:21:27 -0800 (PST) Received: from [10.219.56.59] ([202.46.23.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c87285c228sm17192195b3a.10.2026.11.30.01.21.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Nov 2026 01:21:26 -0800 (PST) Message-ID: <99ca06cc-7f3c-4791-91c7-3ac6105864e4@oss.qualcomm.com> Date: Mon, 30 Nov 2026 14:51:16 +0530 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 13/25] accel/qda: Add the invocation ioctl and teardown on unplug To: Oded Gabbay , Jonathan Corbet , Shuah Khan , Randy Dunlap , Srinivas Kandagatla , Arnd Bergmann , Greg Kroah-Hartman , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Philipp Stanner , dmitry.baryshkov@oss.qualcomm.com, andersson@kernel.org, krzk@kernel.org, rob.clark@oss.qualcomm.com, jgg@ziepe.ca Cc: lingtong@qti.qualcomm.com, cacar@qti.qualcomm.com, sandheep@qti.qualcomm.com, Bharath Kumar , Chenna Kesava Raju , dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, Bharath Kumar , Chenna Kesava Raju , Ekansh Gupta References: <20261102-v4-v4-0-88f2f24a5f0b@qti.qualcomm.com> <20261102-v4-v4-13-88f2f24a5f0b@qti.qualcomm.com> Content-Language: en-US From: Ekansh Gupta In-Reply-To: <20261102-v4-v4-13-88f2f24a5f0b@qti.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=BPgmP1QG c=1 sm=1 tr=0 ts=6b0d4018 cx=c_pps a=m5Vt/hrsBiPMCU0y4gIsQw==:117 a=j4ogTh8yFefVWWEFDRgCtg==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=ilmPHFpW7W4Gngwq7DcA:9 a=QEXdDO2ut3YA:10 a=IoOABgeZipijB_acs4fv:22 X-Proofpoint-GUID: 8e2G-KHFDvLpXyTnGnpYykwOXW5HuIiW X-Proofpoint-ORIG-GUID: 8e2G-KHFDvLpXyTnGnpYykwOXW5HuIiW X-Proofpoint-Spam-Info: AW1haW4tMjYxMTMwMDAzNyBTYWx0ZWRfX1HftugXsSevv VUEgh9Rv1B9EwGTg/ENaGvl/8LFGVxdF+bS62UdliV8UsmmwQay2jA1zKmAlVC7LD+ir3aLKpoV qeJ8cx3vkjLVW78yiKM3utMMexDHKrA= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDAzNyBTYWx0ZWRfXyl9E9xi//76Z dx+yKUXOGlD/Xbh9u3MfWSGlo7A07qJwG03Th+jbtf4aUYcLVrmF0OdjntpgzfM1L2HOeha8WN2 9wlldE4pG6f3/Uunqd25V69Rope44nMQoib9q6EUB7yxkDp8d5iVr5I+CWXXEpZxu/ahJynSM8r mEZmbMfBwbYsjPkNM4Alsz3SGPNOSKLWPsxzYIzQej5Gk8cJD9JJRbpRvpckMJRRxDHBqYQ+xGJ sn8lxDMtNm37zhvjc4fzM68h+0vjH3MQGBN4muRPpn089CwvZcrIaAYE4RmFFZw4PHfQl8Y2CNf Hau15/SjmfBzwGu1kpBPkma0y9uoFzGfG9jSUGX3+NBI/178AlkXJhZ4J4oVJfcI3G3PBmC7x+P 7VGn23cegrPYjM4AVd0QjLwMv9oa0GmXDZjHXtnzPmja/h7/oDBzHrQYDG1zyCY+IreH8YnQUj2 IDrSDSVkRYc981+zkcQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-30_02,2026-11-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611300037 On 02-11-2026 03:51, Ekansh Gupta wrote: > Tie the invocation pieces together behind an ioctl: allocate an > invocation, take its arguments from user space, build the payload, send > it to the DSP, wait, and act on the answer. > > The wait is interruptible, so a DSP that never answers does not leave > the caller unkillable. An interrupted caller drops its own reference and > returns, but the invocation lives on, because the DSP still owns the > payload buffer and may write into it. It is freed once the DSP answers > or the transport goes away. > > When the remote processor goes away, invocations may be waiting for > answers that will never come. Those waiters are failed with -EPIPE > and woken so they can release the buffers they hold. The flush runs > after the device is unplugged, so the response handler is drained and > the flush is the only thing completing invocations. > > The flush drops the reference the send path took for the response. An > invocation that has not been sent yet, or whose response has already > been handled, does not hold that reference, so the flush can drop one > that is not its own. Both windows are narrow but open exactly when the > DSP crashes. > > Signed-off-by: Ekansh Gupta > --- > drivers/accel/qda/qda_drv.c | 1 + > drivers/accel/qda/qda_fastrpc.c | 67 +++++++++++++++++++++++++++++++++++++++++ > drivers/accel/qda/qda_fastrpc.h | 2 ++ > drivers/accel/qda/qda_ioctl.c | 36 ++++++++++++++++++++++ > drivers/accel/qda/qda_ioctl.h | 1 + > drivers/accel/qda/qda_rpmsg.c | 1 + > include/uapi/drm/qda_accel.h | 3 ++ > 7 files changed, 111 insertions(+) > > diff --git a/drivers/accel/qda/qda_drv.c b/drivers/accel/qda/qda_drv.c > index 99bd37fca438..7d44342d3f67 100644 > --- a/drivers/accel/qda/qda_drv.c > +++ b/drivers/accel/qda/qda_drv.c > @@ -110,6 +110,7 @@ static const struct drm_ioctl_desc qda_ioctls[] = { > DRM_IOCTL_DEF_DRV(QDA_QUERY, qda_ioctl_query, 0), > DRM_IOCTL_DEF_DRV(QDA_GEM_CREATE, qda_ioctl_gem_create, 0), > DRM_IOCTL_DEF_DRV(QDA_GEM_MMAP_OFFSET, qda_ioctl_gem_mmap_offset, 0), > + DRM_IOCTL_DEF_DRV(QDA_REMOTE_INVOKE, qda_ioctl_invoke, 0), > }; > > static const struct drm_driver qda_drm_driver = { > diff --git a/drivers/accel/qda/qda_fastrpc.c b/drivers/accel/qda/qda_fastrpc.c > index 2971f2f9461f..3a1959e2c53e 100644 > --- a/drivers/accel/qda/qda_fastrpc.c > +++ b/drivers/accel/qda/qda_fastrpc.c > @@ -10,6 +10,7 @@ > #include "qda_drv.h" > #include "qda_fastrpc.h" > #include "qda_gem.h" > +#include "qda_rpmsg.h" > > /* > * The caller owns the returned reference and must drop it with > @@ -484,6 +485,72 @@ int qda_fastrpc_invoke_pack(struct qda_fastrpc_invoke_ctx *ctx, struct qda_msg * > return 0; > } > > +/** > + * qda_fastrpc_flush_pending() - Fail every invocation still in flight > + * @qdev: Device whose invocations should be failed > + * > + * The DSP has gone away and will never answer, so stand in for the response > + * handler: wake each waiter with an error and drop the reference the send > + * path took for that handler. Each waiter then tears its invocation down, > + * releasing the buffers it holds. > + * > + * Must run after drm_dev_unplug() has drained the response handler, so this > + * is the only path completing an invocation. > + */ > +void qda_fastrpc_flush_pending(struct qda_dev *qdev) > +{ > + struct qda_fastrpc_invoke_ctx *ctx; > + unsigned long idx; > + > + xa_for_each(&qdev->ctx_xa, idx, ctx) { > + ctx->retval = -EPIPE; > + complete(&ctx->work); > + kref_put(&ctx->refcount, qda_fastrpc_context_free); > + } > +} Our internal security review flagged a lifetime problem with qda_fastrpc_flush_pending(). qda_fastrpc_context_alloc() inserts the ctx into ctx_xa with refcount 1, owned by the caller, before any message is sent. The extra reference for the response handler is only taken later in qda_rpmsg_send_msg(). qda_fastrpc_flush_pending() walks ctx_xa and does an unconditional kref_put() on every entry. If it runs while an invocation is still being prepared, after a failed send, or after qda_rpmsg_cb() has queued put_work, it drops a reference nobody took for it. That frees a ctx still in use by the ioctl (UAF) and underflows or double-puts later. xa_for_each() here, and xa_load() in qda_rpmsg_cb(), also use the ctx without a reference or lock, so a concurrent free is not excluded. The trigger is any rpmsg removal (DSP crash, SSR, remoteproc stop or unbind) racing an in-flight ioctl. I plan to fix this in v5. > + > +/** > + * qda_fastrpc_invoke_common() - Shared tail of a FastRPC invocation > + * @qdev: Device to invoke on > + * @ctx: Invocation whose arguments are already prepared > + * > + * Packs the invocation into a message, sends it, waits for the DSP, and acts > + * on the answer. Common to the accel UAPI and the legacy shim, once each has > + * prepared ctx->args and ctx->gem_objs by its own means. > + * > + * Return: 0 on success, negative error code on failure > + */ > +int qda_fastrpc_invoke_common(struct qda_dev *qdev, struct qda_fastrpc_invoke_ctx *ctx) > +{ > + struct qda_msg msg = {}; > + int err; > + > + err = qda_fastrpc_invoke_pack(ctx, &msg); > + if (err) > + return err; > + > + err = qda_rpmsg_send_msg(qdev, &msg); > + if (err) > + return err; > + > + err = qda_rpmsg_wait_for_rsp(ctx); > + if (err) > + return err; > + > + /* Ensure the results written by the DSP are visible before reading */ > + dma_rmb(); > + > + err = ctx->retval; > + if (err) { > + drm_dbg_driver(&qdev->drm_dev, "DSP returned status %d\n", ctx->retval); > + return err; > + } > + > + qda_fastrpc_cleanup_handlelist(ctx); > + > + return 0; > +} > + > /* > * INVOKE_DYNAMIC: the argument descriptors are supplied by user space, which > * is also responsible for having imported every buffer to a GEM handle. > diff --git a/drivers/accel/qda/qda_fastrpc.h b/drivers/accel/qda/qda_fastrpc.h > index 8440efc21b77..61f80c64e6d2 100644 > --- a/drivers/accel/qda/qda_fastrpc.h > +++ b/drivers/accel/qda/qda_fastrpc.h > @@ -205,5 +205,7 @@ void qda_session_msg_buf_pool_destroy(struct qda_session *session); > int qda_fastrpc_prepare_args(struct qda_fastrpc_invoke_ctx *ctx, > struct qda_session *session, void *argp); > int qda_fastrpc_invoke_pack(struct qda_fastrpc_invoke_ctx *ctx, struct qda_msg *msg); > +int qda_fastrpc_invoke_common(struct qda_dev *qdev, struct qda_fastrpc_invoke_ctx *ctx); > +void qda_fastrpc_flush_pending(struct qda_dev *qdev); > > #endif /* __QDA_FASTRPC_H__ */ > diff --git a/drivers/accel/qda/qda_ioctl.c b/drivers/accel/qda/qda_ioctl.c > index b11743ab791e..e9f4151e344a 100644 > --- a/drivers/accel/qda/qda_ioctl.c > +++ b/drivers/accel/qda/qda_ioctl.c > @@ -6,6 +6,7 @@ > #include > #include > #include "qda_drv.h" > +#include "qda_fastrpc.h" > #include "qda_gem.h" > #include "qda_ioctl.h" > > @@ -73,3 +74,38 @@ int qda_ioctl_gem_mmap_offset(struct drm_device *dev, void *data, struct drm_fil > > return drm_gem_dumb_map_offset(file_priv, dev, args->handle, &args->offset); > } > + > +static int qda_fastrpc_invoke(void *data, struct qda_session *session) > +{ > + struct qda_dev *qdev = session->qda_dev; > + struct qda_fastrpc_invoke_ctx *ctx; > + int err; > + > + ctx = qda_fastrpc_context_alloc(qdev); > + if (IS_ERR(ctx)) > + return PTR_ERR(ctx); > + > + err = qda_fastrpc_prepare_args(ctx, session, data); > + if (err) > + goto out_put; > + > + err = qda_fastrpc_invoke_common(qdev, ctx); > + > +out_put: > + kref_put(&ctx->refcount, qda_fastrpc_context_free); > + > + return err; > +} > + > +/** > + * qda_ioctl_invoke() - Run a method on the DSP > + * @dev: DRM device structure > + * @data: User-space data (struct drm_qda_invoke_args) > + * @file_priv: DRM file private data > + * > + * Return: 0 on success, negative error code on failure > + */ > +int qda_ioctl_invoke(struct drm_device *dev, void *data, struct drm_file *file_priv) > +{ > + return qda_fastrpc_invoke(data, file_priv->driver_priv); > +} > diff --git a/drivers/accel/qda/qda_ioctl.h b/drivers/accel/qda/qda_ioctl.h > index d1cbbfb6d965..3bb9cfd98370 100644 > --- a/drivers/accel/qda/qda_ioctl.h > +++ b/drivers/accel/qda/qda_ioctl.h > @@ -11,5 +11,6 @@ > int qda_ioctl_query(struct drm_device *dev, void *data, struct drm_file *file_priv); > int qda_ioctl_gem_create(struct drm_device *dev, void *data, struct drm_file *file_priv); > int qda_ioctl_gem_mmap_offset(struct drm_device *dev, void *data, struct drm_file *file_priv); > +int qda_ioctl_invoke(struct drm_device *dev, void *data, struct drm_file *file_priv); > > #endif /* __QDA_IOCTL_H__ */ > diff --git a/drivers/accel/qda/qda_rpmsg.c b/drivers/accel/qda/qda_rpmsg.c > index 43b56ab3f012..7e58df3eb2e1 100644 > --- a/drivers/accel/qda/qda_rpmsg.c > +++ b/drivers/accel/qda/qda_rpmsg.c > @@ -160,6 +160,7 @@ static void qda_rpmsg_remove(struct rpmsg_device *rpdev) > */ > drm_dev_unplug(&qdev->drm_dev); > qdev->rpdev = NULL; > + qda_fastrpc_flush_pending(qdev); > qda_cb_unpopulate(qdev); > qda_deinit_device(qdev); > } > diff --git a/include/uapi/drm/qda_accel.h b/include/uapi/drm/qda_accel.h > index 6d81f0ef47b6..c21bc5b2446c 100644 > --- a/include/uapi/drm/qda_accel.h > +++ b/include/uapi/drm/qda_accel.h > @@ -15,6 +15,7 @@ extern "C" { > #define DRM_QDA_QUERY 0x00 > #define DRM_QDA_GEM_CREATE 0x01 > #define DRM_QDA_GEM_MMAP_OFFSET 0x02 > +#define DRM_QDA_REMOTE_INVOKE 0x03 > > #define DRM_IOCTL_QDA_QUERY DRM_IOWR(DRM_COMMAND_BASE + DRM_QDA_QUERY, \ > struct drm_qda_query) > @@ -22,6 +23,8 @@ extern "C" { > struct drm_qda_gem_create) > #define DRM_IOCTL_QDA_GEM_MMAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_QDA_GEM_MMAP_OFFSET, \ > struct drm_qda_gem_mmap_offset) > +#define DRM_IOCTL_QDA_REMOTE_INVOKE DRM_IOWR(DRM_COMMAND_BASE + DRM_QDA_REMOTE_INVOKE, \ > + struct drm_qda_invoke_args) > > /* Query type definitions for drm_qda_query */ > #define QDA_QUERY_DSP_NAME 1 >