From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91FBD368291 for ; Fri, 30 Jan 2026 11:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769773933; cv=none; b=H2pduhr6umS7GISNnGfMQF/ItzWZx+Y8kI33WsuVkMFfLWA5eEfEJQW1Q6k6g24pRrZEFf+f/pGNjndSea2ViHgdDQHWVIut7lgz69ZEX4a4P4gopLCSb6cS1L2YoeODa5p8Rf+xAApsubmIm4bgayLtkywOifbzBH6b46l5mkU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769773933; c=relaxed/simple; bh=dLKlbBdNdZT0825AM0f0kn6sHa7tW2Pakir9yuwrrvY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=T0Nb5iruyfm2ABeueOPIjvIOFzC+YF+XSzSLBJnk8kaJw0Tl3gXBNWfr6VBZ9EWbSMzpAt52WxcVpJwB0rx9ToyHmUNepdVnWmlW1DhJzpY+JKf/I4FzI99rRmLg7baITl9xyl4u9f4+SFKpAIjiDYa3h6/xZgpbmEE8tVhisXU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=XIQZxfxT; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=AVIDUhAV; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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.b="XIQZxfxT"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="AVIDUhAV" 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 60UBKnrh1485253 for ; Fri, 30 Jan 2026 11:52:12 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= NACypJ423bQETWp3QTda+kmcF4j0ws7q8gc9h2VRpCY=; b=XIQZxfxT6C/JJcZW 34qNv+mGZ4x+e2AgkQamMa3zP1LAyrOVCG3S0V1pLLellukjLRdnO3ymsjfNDIxW Bx2pw/xL1nJkPGNU0cbSn2uXnuy35FuuUPxfNUVVuVQ5Oi2WQXFeCzmB0GahHvey pkUSzx2G8MFScesjH18Ek5QKL9SL5MFGuXJFOcq5ly+TW+0uDzJIBW7Ab0dDq4Do mxyDpvrThFNHRP/8bZTmcAz1C+CQh2QKYibqEAPYATQ4DWCiODvBOMDRXR3aQxSg SERUaXT/RE6au6bozzanLx/KpRjVEpBURc1pmiv0jXYWFQTfaP7RI3AxkgBT/MF8 Jxc0hQ== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4c0nsf97d3-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 30 Jan 2026 11:52:11 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-34ab8693a2cso4236958a91.0 for ; Fri, 30 Jan 2026 03:52:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1769773931; x=1770378731; darn=vger.kernel.org; h=content-transfer-encoding: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; bh=NACypJ423bQETWp3QTda+kmcF4j0ws7q8gc9h2VRpCY=; b=AVIDUhAVjBwROKFjNTL1yWxEqptCVMl4psC55gDCTRjIgEByttIUSF1djpyggi2hjL wjpHcN7Re4FW3eSTVvTHprUZqkrI9kPKfOfo9FbY3c1+iQgsGfAKVVuO//dBJ1E3fT6E zglQZyFNhxdm65kt6pqMvlhNeEMyIvkl2uxHle/uoX3I6ekXTigKRCTNzon5KnVWlF2E YkMvqXC3ASQYyyvtzEdiozOYQqXqdvJrH+r1UR00znyL0IoKJ754My2/UeLEirI26z7F mW41e20JXituHSYGmHNvfmYmPcFebhyH3NNWB2Qm3qfATfpwXfRljqDoUz7PZ8stIDZe 3eLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769773931; x=1770378731; h=content-transfer-encoding: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; bh=NACypJ423bQETWp3QTda+kmcF4j0ws7q8gc9h2VRpCY=; b=uwp9Guip64c8OlSgrfRWtk+MM/32WJBNilT1YFNfkc3RB4xTKzbB8f5Bq18mVz+Vwx LcU8KBE9OtEiIUzK39fq0ze7qL/yHlWi/yBvcihAaXxJqd4AEnyD6gdBtpg75cHC6zD3 FavVie1W2UrMiu6sn/ToJt1arToSGJZdMOWABJNCGgf5Zpkzecgq6SGZI/QVZ9o36Rlh nMSxeaqm4Z0N44e8530Pc1oGu2r/Hkz4PC7ukZx597d4HS9QQpweDG3A4DPwUL+YBGDZ hYb6OTlmi/FSiOL+YXY4LE+5E2GMPE0t+4YeVJBOJCM0/xpg3SYVM7y1WwYFpa74hyls GTiA== X-Forwarded-Encrypted: i=1; AJvYcCVpn+u/YNy22v9I//yH+BcCU7wCFdDmpD8lzeRlW/KjtBKmiW6Kf7FshTctmKvQXExebXV/TDs5Sz0o0Zk=@vger.kernel.org X-Gm-Message-State: AOJu0YwoopmEKp6lQ6j8ZIU2M3dcSVmgNeWOvEaqhsKQcbgriMfbUoCv znMZAxYtbBbNz7Xg8xUzC2knqUA/7RPJxIReQb+x9lWaIm9ZxJPK8StYYYfHby09bBOKevAhmeN 2GgWdMtGufUWmip0y5/vuQW73Yw58aIdym7tKVA35kM115naqwImjl3y4Y62jN5RSLWM= X-Gm-Gg: AZuq6aJ7M1svkdvJqtYcPNCk6j+Aql3TwUYvmn4q1YyaQYpDnZ/abKCbakq5sgaqNw9 RR2cL6icZ5xImCpmvwIEFUgADoRjCrl+VvKofhIlmTRDxR0EUjL5Z8p9JhyfVuhj3BbB1lyjtpS XU0vDeCxvICMCoSEDPEXZoQORRmVHqzJ3wPZbpPmmyG9g+NuBVPDaErH7BDMvJcMy2Sl4OwPbjq Ea/Nexv3hDLwQvZeBFZv4JqYRnSAwxBYVGOowZACYUKY1mnefOfQrd1CpCZDOJFnKudqddpj8Y6 wB8Mh9oo2sQqMrfhEvVzdf0/hDQsFDI9vF4/cgp9oc441FZglDMK8BF6Iyq21nPoT5DIDYc95/T E+EYSiRzI+c2vV/QryKme+ju6poFxR2tIzD824w== X-Received: by 2002:a17:90b:6c3:b0:341:8601:d77a with SMTP id 98e67ed59e1d1-3543b3b54b3mr2883674a91.29.1769773931072; Fri, 30 Jan 2026 03:52:11 -0800 (PST) X-Received: by 2002:a17:90b:6c3:b0:341:8601:d77a with SMTP id 98e67ed59e1d1-3543b3b54b3mr2883650a91.29.1769773930565; Fri, 30 Jan 2026 03:52:10 -0800 (PST) Received: from [10.206.99.28] ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3540f2cb5adsm8083054a91.3.2026.01.30.03.52.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 30 Jan 2026 03:52:10 -0800 (PST) Message-ID: <7e52f1d4-c05c-45ea-878c-cea2e6354c3f@oss.qualcomm.com> Date: Fri, 30 Jan 2026 17:22:05 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 3/3] misc: fastrpc: Support mapping userspace-allocated buffers To: rob.clark@oss.qualcomm.com Cc: Dmitry Baryshkov , srini@kernel.org, linux-arm-msm@vger.kernel.org, gregkh@linuxfoundation.org, quic_bkumar@quicinc.com, linux-kernel@vger.kernel.org, quic_chennak@quicinc.com, dri-devel@lists.freedesktop.org, arnd@arndb.de References: <20251230110225.3655707-1-ekansh.gupta@oss.qualcomm.com> <20251230110225.3655707-4-ekansh.gupta@oss.qualcomm.com> <69cb2d42-6672-4c42-935f-e3fff9bf38f8@oss.qualcomm.com> Content-Language: en-US From: Ekansh Gupta In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Proofpoint-ORIG-GUID: 8jYyDschzPQ3MJl4LLMAUdgs1e-go7tO X-Authority-Analysis: v=2.4 cv=EvjfbCcA c=1 sm=1 tr=0 ts=697c9b6b cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=hcJ8E8GYhuT13GVzWLAA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-GUID: 8jYyDschzPQ3MJl4LLMAUdgs1e-go7tO X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTMwMDA5NiBTYWx0ZWRfXyF9EeXz22eP7 NAXW2nceXr/qp9gsZPODM8SiqmxtxDCSFTrN64Lt0JPjXCxnUKyLmBEEuVoi3e8mls6ts69/bWU BumMcxx2IZBf5LEbmJ/+cTdmnILtJMEH0f1ngCZKC6OnT2S3t1tvJ2LniWsOy6IMLSJoC0G1U3C 4hc8v7HC/G2Rc1yCNbnXSJ23C3ZTW/1qJbGZ9cqld26zNyA33+08kpOvfkWbe3PLMvw9dDWpjP2 F1WuzhTFmEmiwGzQb+v/pI7ECaYo8i9WoIwKn3iwTV/S/nuu0MC4pUCo0a2T6HgozoD56MvQdAx S4XomLhKx04bDUQ3eUkmIsqcqgfQMCyGjXbiCmpETGcR9sNf55yfoBLwEnLkMX42usfA/Ut2N18 paGpiqbV8f1o8uqR+pm7gYxZAK81RyGvqyLWrq+MuWBZQHGiNEqFzllpsqZCSsVf5BGkb+aTLYj KwsRWIo2MXLhcrEMTEw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-01-30_01,2026-01-29_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 adultscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2601300096 On 1/30/2026 3:41 AM, Rob Clark wrote: > On Thu, Jan 29, 2026 at 2:39 AM Ekansh Gupta > wrote: >> >> >> On 1/6/2026 8:21 AM, Dmitry Baryshkov wrote: >>> On Tue, Dec 30, 2025 at 04:32:25PM +0530, Ekansh Gupta wrote: >>>> Currently, FastRPC only supports mapping buffers allocated by the >>>> kernel. This limits flexibility for applications that allocate memory >>>> in userspace using rpcmem or DMABUF and need to share it with the DSP. >>> Hmm, for DMABUF we need _import_ support rather than support for mapping >>> of userspace-allocated buffers. >>> >>>> Add support for mapping and unmapping userspace-allocated buffers to >>>> the DSP through SMMU. This includes handling map requests for rpcmem >>>> and DMABUF-backed memory and providing corresponding unmap >>>> functionality. >>> For me this definitely looks like a step back. For drm/accel we are >>> going to have GEM-managed buffers only. Why do we need to handle >>> userspace-allocated buffers here? >> That's correct, GEM-PRIME will handle it properly. Here, the reason to add this >> change is to enable routing of DSP logs to HLOS which is done by using a shared >> buffer between userspace process and DSP PD. The buffer can be allocated from >> both fastrpc driver's DMA-BUF or DMABUF heap(eg. system heap). >> >> So this shared buffer is getting mapped to both process's IOMMU device and DSP PD >> with this change. > So, a mmap'd dma-buf is not necessarily pinned. Or even backed with > pages. So you wouldn't want to try to map a userspace vaddr from a > dma-buf to the device. > > But looking at the patch, this looks more like mapping an imported > dmabuf? Presumably going thru dma_buf_map_attachment() somewhere in > the existing fastrpc code? yes, when the fd is passed to this call, first fastrpc_map_create is called which is calling dma_buf_map_attachment[1]. After this the buffer is mapped onto DSP. [1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/misc/fastrpc.c#n781 > > BR, > -R > >>>> Signed-off-by: Ekansh Gupta >>>> --- >>>> drivers/misc/fastrpc.c | 97 +++++++++++++++++++++++++++++++++++++----- >>>> 1 file changed, 86 insertions(+), 11 deletions(-) >>>> >>>> @@ -1989,25 +2020,69 @@ static int fastrpc_req_buf_alloc(struct fastrpc_user *fl, >>>> return err; >>>> } >>>> >>>> -static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) >>>> +static int fastrpc_req_map_create(struct fastrpc_user *fl, >>>> + struct fastrpc_req_mmap req, >>>> + char __user *argp) >>>> { >>>> - struct fastrpc_req_mmap req; >>>> + struct fastrpc_map *map = NULL; >>>> + struct device *dev = fl->sctx->dev; >>>> + u64 raddr = 0; >>>> int err; >>>> >>>> - if (copy_from_user(&req, argp, sizeof(req))) >>>> - return -EFAULT; >>>> + err = fastrpc_map_create(fl, req.fd, req.size, 0, &map); >>>> + if (err) { >>>> + dev_err(dev, "failed to map buffer, fd = %d\n", req.fd); >>>> + return err; >>>> + } >>>> + >>>> + err = fastrpc_req_map_dsp(fl, map->phys, map->size, req.flags, >>>> + req.vaddrin, &raddr); >>>> + if (err) >>>> + goto err_invoke; >>>> >>>> - if (req.flags != ADSP_MMAP_ADD_PAGES && req.flags != ADSP_MMAP_REMOTE_HEAP_ADDR) { >>>> - dev_err(fl->sctx->dev, "flag not supported 0x%x\n", req.flags); >>>> + /* update the buffer to be able to deallocate the memory on the DSP */ >>>> + map->raddr = (u64)raddr; >>> Which type are you converting? And why? >> I'll drop this. >>>> - return -EINVAL; >>>> + /* let the client know the address to use */ >>>> + req.vaddrout = raddr; >>>> + dev_dbg(dev, "mmap OK: raddr=%p [len=0x%08llx]\n", >>>> + (void *)(unsigned long)map->raddr, map->size); >>>> + >>>> + if (copy_to_user(argp, &req, sizeof(req))) { >>>> + err = -EFAULT; >>>> + goto err_copy; >>>> } >>>> >>>> - err = fastrpc_req_buf_alloc(fl, req, argp); >>>> + return 0; >>>> +err_copy: >>>> + fastrpc_req_munmap_dsp(fl, map->raddr, map->size); >>>> +err_invoke: >>>> + fastrpc_map_put(map); >>>> >>>> return err; >>>> } >>>> >>>> +static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp) >>>> +{ >>>> + struct fastrpc_req_mmap req; >>>> + int err; >>>> + >>>> + if (copy_from_user(&req, argp, sizeof(req))) >>>> + return -EFAULT; >>>> + >>>> + if ((req.flags == ADSP_MMAP_ADD_PAGES || >>>> + req.flags == ADSP_MMAP_REMOTE_HEAP_ADDR)) { >>> Side note: why are these flags not defined in the uABI header? >> Ack. These should be part of uABI. I'll create a separate patch for this. >>>> + err = fastrpc_req_buf_alloc(fl, req, argp); >>>> + if (err) >>>> + return err;