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=1796030490; b=vGXHC5C0C+OWuAcHHMb4oo/tr/LNFdvUM3bwEFio60P6vwQW/BoHR7gCU8INpTghHp8I 0wS6AiSfes88/TPUGsCjGg2q+e82hjqRDwTr8FtOcWyRLI+XVWj9U7a/166Gia1qfeh7b sA5j3JuZSYFXJSd/Sg/hNPJK+tmmNCQ7eXNYD9LSKUvAXe/A65jGHdOiZeXVHnOUsd4i9 /Z29kpdF6oBQM+g4SYbuYz4l15DlM8ZQGtMeCbOWLz/Asp3xOiMNO3Y4m6RElIpf+90l9 y25j0rTHdKeMsK1BjclfrJNxXn7I1SLJW6m9nwvMPPVErZWxtG8+j8If4/L9M6CdGqQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796030490; 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-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Info:X-Authority-Analysis: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=PIL2BT/MQ2zhbdWocdZ8/fa4YasptX4VTZVlOio8juA=; b=r59ZqrQl8etPx5iiDHImNACH1JHu+E9nGMAD1bSET24kZ5kUbTNUtvuHmYXEgub2rAWE 1OaJXyDakoQDQ1+BtRQ+J1XtNoRrSgWm6SHau6/V3NVBL4mV6Qa0Vvj6YJuLB82dWHA+Z 7GNN3vsth7e7Bjm9hxmtxj59vpZ3HBF7giJ2U6jav+N145w6bR+bTLQD3RvYtxee2N8UT et9VHSJzf7BSpamrHD752mAPn96mt4d0a4H2t1bm2Q9nK2bNHArcF2Mkk04BYUW+ApFyn ReoSAO5Za4dGFnDIfgv/VKP6XIHjBvl4g6h8S7N94QCvOOH4WROg5w/5OC0lybBaJ8w== 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 66622606A325 for ; Mon, 30 Nov 2026 09:21:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 66622606A325 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 (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AU5GimH787225 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-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j7r89dftd-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-f197.google.com with SMTP id d2e1a72fcca58-8b97460a133so7875600b3a.3 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=zrURzyJag2nzJXmI64mkpS64sp5sxRjKciLtlEzpxvijBjJJECWnm51CyRMsZykBL8 Cjte8MVY4xhzJZSWpySHIXgw4MNViBmCnTmCZrNNbxLYOv9eoHbhScg6Wl9z9l+xrZMD Thy9pJthdRQgAiUm05ebyx0RabRIn3gyI5zwPy1YtZR9qIoehq22SLhBeHurKcniupJL JLt0tNYMqE4apT9KZvHXiYnvxmu+kXmySLZWrKgXYhk4qPto8HlnlHhdRoVKaScLud7e +ytcYhMKtTnU9LLZ4VZ/CyN/M5RTlb4utivToXyG/bvlb3i18INWaP5NsCvWIaLdqoRD ai9g== X-Forwarded-Encrypted: i=1; AL+hErHa2SdAWVasYWU3pPXeh5b/M6zRMxv0mbitaldysIVKi7lZhgwWewgaMq5i8orvlgeFeAGL53cktyA=@vger.kernel.org X-Gm-Message-State: APuU4Z/IvbPGXy8/2jvWUMvPH3FurH4/xV5eNmhsvQIsF4feonnsJKXw 8ZfBYwySlXK6olWAtaDj8FIDJtLQiSm4OJ5ZXZ+yKKMdFzf7sgoHJurjfLUQisAKZJrSH6i4YI/ iqqzL7arUfh4/LtvbQbKRnnAE8j/JVJViu37neFU/b4rw/WW/dZWURDJY7CY+BK0= X-Gm-Gg: AZFdTZc464iVIogbibVScGU+xvpYvL9htYG7JbO2tuBps6xMdVSNMmi6IxFdQ5FFQ6U LQ/fzQiPWc1W04e8D4Z8F9btBWpelMfMvM/cazEbfmQGs9apR2UtLWQtGw7V4WLzxtKHAlM+ZMW R6WHhV84mstIrYQ+1Ri9hliJt8z1mzmhkc/ieV86ibm3oa+htumlVTsnXxKICi852qNCFjMwUNE wXYdYtDuZpBpdlbBDiYzgwVB1rrb0Y/Ol9T8p/IRyjnBufSiQExdMLNhkss3oLDnNx6uqDx7HLi GQFmv+Ff1iLwL8xzcpdHGG0bpMCmZiJDUnq9uxSRsAGbRuG7gubRR1OQrt8u68XnJtbKW5EtMcd kOTdObDTFPHEnndzuUk8wlMtbvqAF7Ry1IxRCKojAlJVfG6UIDfa0H0ex7pFaaOWAsibF+yFe/q GBQw== X-Received: by 2002:a05:6a00:14d6:b0:89e:71df:d6d5 with SMTP id d2e1a72fcca58-8c87bcbdc8emr30676738b3a.10.1796030487609; 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-doc@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-Proofpoint-ORIG-GUID: FWj66OajdYdVtTpJpVqVCKzZrFsHyEdl X-Proofpoint-Spam-Info: AW1haW4tMjYxMTMwMDAzNyBTYWx0ZWRfX0E9vC4flOqzS uq/nkh+2McvUaMgZ4mShB45axXOaaIUM1BA0nRp8CJ9yUfP6k0BwoLBStIKGmUDqnRnAf3hRi2T dTFdlMQHDJ8FEXyeoL0ymBqKUEkByUM= X-Authority-Analysis: v=2.4 cv=Eedd0/mC c=1 sm=1 tr=0 ts=6b0d4018 cx=c_pps a=rEQLjTOiSrHUhVqRoksmgQ==:117 a=j4ogTh8yFefVWWEFDRgCtg==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=ilmPHFpW7W4Gngwq7DcA:9 a=QEXdDO2ut3YA:10 a=2VI0MkxyNR6bbpdq8BZq:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDAzNyBTYWx0ZWRfX78oEqksbPuD+ WAPSKFPcuo82QanvEqE2glhDvLSPmmuZWzpJLnZzdNx4P7o8SnQLgAeRzw1PtXAHDQ9AhmRA4Yt O+Q5zpr+7gS060sAiffqLmVAQIriSIqAf93BETw2CCB7SwPqXKs9llSMUS+ggcfb2x3+1qlLXpU 1iSB8k5e3R1QgiHfyziC1UsAoVkiQcPa72c7cwJjAaiGeRS0TWQFAeVOxtIlVuKenvBECHb9D9w KltPPTrwfH3Ypmhf1DT390qysPpiESDLMYJNKK7cCEtjxXCpax1M4hZD4jMDqQYJNEZZtDhN48X Hc343nPYdyG9tmh7hujJZuXX5if12sRvectP0irvasXy+Z4e+VfED8Nmrw9vTMk/3dhMeGr8DmP 4fUr258YSUBDBfYLlJFdy0uaJZeqbdwE8Vmo2JIVuXdOlpU5hOvaB6XM8kxEKk2s3bK2JTrpZ89 yZAjqV7gI8GbQvJ8KnQ== X-Proofpoint-GUID: FWj66OajdYdVtTpJpVqVCKzZrFsHyEdl 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 priorityscore=1501 impostorscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 spamscore=0 suspectscore=0 malwarescore=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 >