From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 552B3340295 for ; Thu, 29 Jan 2026 10:39:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769683190; cv=none; b=q+Px0njyl1G947mED7Kofp2mnGmk/nMBZ7ANvkoXc2qR0RwCsCWq2ryQqRLqvTLlfa0BI1wYbdz5xD+Y3Zip/F9Z08po4ckLIKiUBRFX+VdMqQTaRZR4dfAy2i6vsczzIh/6zjzdmbxPOpK5T2gvHZktbYMaQ3rQI9/TqxZBSIM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769683190; c=relaxed/simple; bh=LmLnoI92W6kcubHlziijB1nvk1Jvl69W7a0k46sP2i8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=QkIuyBraWViLRdvTD1pyCI9kuHc1r9AErHI6L7J0WAsHACGTclWn3g1oRsHvh5+o+Bx8bDpyy/rYoOARDNOlufbT7ugLAJxcKnDo0dksiinL0oaP60epuyVAzkNfWF/5xZDwGogvLIYisfMntDGrigCyyQc8dZS7W/LXf41Z/RY= 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=gYOIPuWv; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=gLyHnKZE; arc=none smtp.client-ip=205.220.180.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="gYOIPuWv"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="gLyHnKZE" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60TAPfhF3642239 for ; Thu, 29 Jan 2026 10:39:48 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= 8nFcWZSxon1A1m6tkx1GK8WmBFbfomcGS+iTKwPNJrg=; b=gYOIPuWvCXd5tQe9 DcwiewBtUph03uNBa/ps7tk4klnw4MDPd8SPThIHzMVINib6WvcriRRmmDB8dYbu Q/66SOT3zBHmqAbwXOoENObGbl/KUORbO3WscHCK+nM2HJofhINh+ZYLuRcyynSf nPiDIsFAV8ujS0+I6MgBnQZvnKWOkchZf7M+a2Wsqm1RC4mYERcYgKEeP7s8/B1o DyTatLn+3pJVCDcaelUZyVLxEgQ7PULLYLsy502ByHQ4nabos/2v7d9/8hxbeOr0 oFvKxePN3wQzzk0qVN9ZioeynP76byZoBmgr2BxMlJ0AbLfrQ7X/8/oZUbHhOT2m FRP/TA== Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4c05sr01a3-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 29 Jan 2026 10:39:48 +0000 (GMT) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-c6133262e4eso552092a12.2 for ; Thu, 29 Jan 2026 02:39:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1769683187; x=1770287987; 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=8nFcWZSxon1A1m6tkx1GK8WmBFbfomcGS+iTKwPNJrg=; b=gLyHnKZEGQ35f2TtDzMzpXnDWtK0WpGSR3DUZsinHn8rhIrF+hziDdh/cgyNeVEZfL 038SgMTN/OVwgODgLlBoMLw4TS7QBRy2aOe4M481Km5cvZkvp/LZ0FmLytpXg5NHrLEK z5akHieC7m5cUhCtK50Z8L9Nz2b893fcHd/mf0k4ToleVVZ2CA//TqVgtWPCmIh4yU9g EiQeQYy6icWPbgsEMjwPcPHbokElmVI/jTQc5SaKygHonPHl8tSYusGCjHYEVi0saCFg B8eOs/Z1oAJH0kkkO9ISA4lcKm6JjUdi1dsbwBlS5Ftycw8S3KIq83Q2if1D4r5NqMTK ibgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769683187; x=1770287987; 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=8nFcWZSxon1A1m6tkx1GK8WmBFbfomcGS+iTKwPNJrg=; b=vv8trGsiAgZsoHDRcG2oO8ub19pG1rTt81z3dXV78xxmgdChVqYwdd1kL9bIcxS3XE fAPKjhd7J8wAKgUaN9DfLb3QnP4b22wl1z7uWokRCmu7euvDJk3rww6HeN2FWDVyXjKB OBqZmgrMAPda7c6JjAB7qSZ+IIBBPnT0AHjZovpqJ/7NKpqQRGZGMpL9Phw76SFVEcRZ KUQ4anj2au/kennE/VFRCOX7zbDtOhPhQMfFI1pnJvDjpOLSI5cesMYJ4+i6B9ShCMLs N29+sGW/2YNXQgXXVucUseCErK8w8VGXCNM7JVLEe7DEP2K6aSLMjoZKs12X4LKLiuvt RKkg== X-Forwarded-Encrypted: i=1; AJvYcCXn2r0ZPTz7G17brJ37DXhw1XKfL5wy4xKlM4QZO5m1GN8mFBRdO8G6FJU2eisqM17+XyXrZBvNSOQPObc=@vger.kernel.org X-Gm-Message-State: AOJu0YwpKWRVMyT2errRV2Gc3fM1fZI50qiNvnCpyPT8HINcFTWqAeWw 1LlvP71rFE2yzhwbWUkYBPbbRToiOlRgSSyD1l91VPQ4ZQ/4ymhl8MLt2PifldosrHRGbjOQBYs 4GEis9xpp2omkrtvq4VEnjHegwVUq7iqnwr441Wk+gvqb8AgB7OqrYQfUEM8eVJhhZc4= X-Gm-Gg: AZuq6aKiZymOgK6FZ7IKjQqCpvWx/2W6oUvNE2qxRUCQ7joHjypKMH7sNoSMWFJazje hvddyD3SRnsK+gR0UvxsYGqSb2e/PplWUfx6opgnqN2upnwJDsWFEjVnpTy59Qz4qflJ0x3C623 EW+agZSkHauKtiuSMyQSFijZEJ2TbR0QSBU3UrM9DrnAh1atsFYLDzv5nLj7N6+ragEuWYsIKvw B3xupD4us/DtwGMb5Wvfll4OG5cBVi9JQsq25aciwcM4YxfEZViSozg8QRxEdODVA5jvMtAemxu W+eoa4ja8L9hKTFS7gvs/N32TE8ht420LntAmdfissvuLy6lLsY2hVamRPW5Dt5CmjrjzeU2KkP j5vphj8gMluZW7Rk38/tVBnrlI16cTxgUUD9euw== X-Received: by 2002:a05:6a20:7345:b0:38d:ebc4:b552 with SMTP id adf61e73a8af0-38ec62ddfc5mr7700204637.27.1769683187089; Thu, 29 Jan 2026 02:39:47 -0800 (PST) X-Received: by 2002:a05:6a20:7345:b0:38d:ebc4:b552 with SMTP id adf61e73a8af0-38ec62ddfc5mr7700176637.27.1769683186576; Thu, 29 Jan 2026 02:39:46 -0800 (PST) Received: from [10.206.99.28] ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c642b0b4c07sm4563659a12.36.2026.01.29.02.39.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Jan 2026 02:39:46 -0800 (PST) Message-ID: <69cb2d42-6672-4c42-935f-e3fff9bf38f8@oss.qualcomm.com> Date: Thu, 29 Jan 2026 16:09:41 +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: Dmitry Baryshkov Cc: 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> Content-Language: en-US From: Ekansh Gupta In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTI5MDA3MCBTYWx0ZWRfX1jRt75Gapz7g fbAVWaFeWLjUC8tzHPc/2lVKEwwcQv+8NdQeFOy0BUP/AfN/aIppyDyKxdS8cGbpdG5W5wXRrYU A7crRioNzDrGaXJFMr/qI7KIOThuSx2vVwFoFAcClogFw/JrwAZC8P4BZOwK3rpi3ZOWLygcqSV pv0qeJM8BhGBBcflCkJjLBI7KxPZiZnJ+wiII33pQ2UE4NLTuFOG1E10fYbW2AoYnwKzYN1L9co NJTMfsn3InxGrbJqz0/DNB0/35B/5UaSFJWhAQ0WYhiKIzr9xSjbizYPmLVF06PZQbDgbxPPCeF CK8Kmxf6xFlLIQEbw/rp9FbD+dnVVLomxKP1dPnvxCWQENO1gkCPNJm6cmalcr6PBqRZlJZ8UPG wkLHei8Jysb+sXa7GrXovWs3zAyCdm1QdRgj2mXygkYFZH1TM88Nh4s+LiN6F4FAT9y5zZk43+P Ef6lvy3NhGqFjC0u7Eg== X-Proofpoint-ORIG-GUID: JhXOb-5Omxga3OTAlsvLYhnCchcq_NSi X-Authority-Analysis: v=2.4 cv=UsJu9uwB c=1 sm=1 tr=0 ts=697b38f4 cx=c_pps a=oF/VQ+ItUULfLr/lQ2/icg==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=ZcInPQ15WBUuy6mFm-kA:9 a=QEXdDO2ut3YA:10 a=3WC7DwWrALyhR5TkjVHa:22 X-Proofpoint-GUID: JhXOb-5Omxga3OTAlsvLYhnCchcq_NSi 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-29_02,2026-01-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 clxscore=1015 spamscore=0 malwarescore=0 adultscore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2601290070 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. > >> 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;