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=1796029887; b=xtww1UwBb0gMRWzXv7KbwM5oF/6wBC6fxNFdjpgNis5ytRhrOSlotPKfMPz+7Te6eVry g3uTNqqv3VIgA5NBXGR2bNq+DpDDo25bxPDIicPfV5sD8ItJQ2FmeVMgAQNilyKdboB77 E0JH2rVpfcFccj1tv9o4FuVCJ0B3KXGW5Ah+hC2DbTTXEzZHqlbdJDiFdjuVIwPONxUPI KgOLxjzpi+0NDtN9UpWSCqAePMvqcw7QZzDo0T5B/sl9Mpb13QFE5Yuk+0KXq2BUadWU2 dINMq9fPRHj3P0oIOjUdDNIQOlX3yeceACtWxCVhMW4b8rp6e7JTZ0Q3KwI3zFcSmOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796029887; 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=KOkqHc7EN6pLogLULj8r3WyNmBg4hki7Ohj1ceeDpkI=; b=NmN5USuIQIDUPBdm3dbEIo3tBmNCRqa8MOQCvtpigFXOTfxAjGXzk8SBjr5wMsSyoXCu l5FgdfZG+XyAzGrJPMFa1o1B/qlM4JMEzj607jfLj1uD/nx5NJH1Jc44suRHq7MDlpFhD np1IngChCy+dMlRX3NCIRiKjUYwuHlfivMGgo+gQVGUK4RWN58cFRhRihTSYyFE/GEwZ4 u1CWpgkKy0GP3Z3k6qRRXOUcf+AHS7l74m8dY/gbfwnbIYF4bCNY3U6vIQISoGA8opFc5 RUvE7YGKcDwVvNOzMTXGFRJgQ7nC/PtCD3ND81YL4WHeyoF65U6DWdD9ONhRz1U5/xQ== 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="HYAV4Lm/"; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=FWAlqByO; 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 4753F606A31C for ; Mon, 30 Nov 2026 09:11:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4753F606A31C 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, unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=HYAV4Lm/; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=FWAlqByO 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 6AU8RlT22138410 for ; Mon, 30 Nov 2026 09:11:26 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= KOkqHc7EN6pLogLULj8r3WyNmBg4hki7Ohj1ceeDpkI=; b=HYAV4Lm/vMn/OZUL a5WCLEEm2/SgQSul7AE+QO9q1uFmDenMngOe5eACDbE2p5MMlw8d03Vdl/YjE+Wy BEwQlZWctG5UaZTZUZLOfh/qZl7d6cusEjAti0BQXPGMhGIhr+Qa+jnkkq2bK/qW 8d3B3HeKSIjreBaspYLUnfOQhuevuUixTU//EV1NU5NktZZWdZ77S250c7XA1jyM PKHqKztvnDRXw50pmUmPZSyKv69cS4qx9s1N4uIrzzW06Z62brnG7/udVQZoBNcA 0hDX6lBvmpx9Q9IwJORL4fvb0Vdog4R36PvSrE79Tzn/CyRSjfnWXbxuWV7rv10t TgNOwg== Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j95ndr6nb-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 30 Nov 2026 09:11:26 +0000 (GMT) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-cd3b9e70f88so5108357a12.0 for ; Mon, 30 Nov 2026 01:11:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796029885; x=1796634685; 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=KOkqHc7EN6pLogLULj8r3WyNmBg4hki7Ohj1ceeDpkI=; b=FWAlqByOR8mk7VA9DTcNfq+7R9XC7quoGENS7vG07CTb4LZaKI2hx5o4gAm+pG8z3o Tb2qYOnNr8UU6SNOQNRUw1EuMCngVSu2JILqdEEgJlLjf9GmHZzb1r5B/cw1T/weLJyh CmmVx3AFCpJex45zrORPlMXSHF57gZbnkuUfbsE59vnymYgYZ6sC8dAtYkVrASVKC2UK BW+hTZbl810HEPU9K56o7QTPFhAVoicxyqc+xn111D0S7M95T0Hb/W4i8OqV5WMkGTHy akIeMnxVarUm4bI9mu0jSDnUfyD9DdwWOWj1APQMgsAokXdl15xuxXB4tZ5xsMGNpD8T lkiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796029885; x=1796634685; 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=KOkqHc7EN6pLogLULj8r3WyNmBg4hki7Ohj1ceeDpkI=; b=w700BuK3cbi4T/Qvk+8V8aNMuD40Z/nqwxQNdqT1PWorHcoAA5Ub2w4x66vNw/ukMV IkgepA/dCRntuQBtScdK/JURNprLVgxUF5XMU0w5OqTtoKf3ZGBrcl+kNbsGa28TP8Q8 TBB4oGGmOwE1SBW9E2UWym7dqkATOpmvaQAqBEz3ey2r1SYoixfWzEkpSJBt95GveepK xwH9kfcYKEOu9auBaG/tHGBfXC4HNYrC0D1oVFWaSsChFxG34vUndB3OeqrTTCV2yoWK nR/RCRQvSWAHkooSMnOY9MQ2TePCWrswMFY5JTC2Qu5vxXfZwpSzdidZ0NKTbdHLOv+K wc4Q== X-Forwarded-Encrypted: i=1; AL+hErHOmPhvIbO7+aqmicGgKzCmmEdLnvCQEs2d7fICjAJjT2UNxBlRsQ5KHdmNh+SjF6pwf6aifq9ygckOqQ8=@vger.kernel.org X-Gm-Message-State: APuU4Z/wmoEN0YtqGUaQ7/7m4Wp6I3g9dKPM0df0xcG5pZJ/SNCq1/Ga haS2wpHVQQcj60LAHq8KyOaixf09KE0c4XNuMS4LMbXJEBYzoUebB2RCnVsU5pyfev0SPFBURPY /Iy2If3T8echpFzr92rdEjIw1bIj9j0ggtkuNLkrWNalasVZC8kIzhgWZ3ftKVbuv1Ns= X-Gm-Gg: AZFdTZebWmyG1onBako/bout3V8bHWneVarjMUbs2VkN/it9DuGhGuM4OmLDg/x2sJZ SY/PSkLwPgh3/Gd7Aqmb4UH1OlYcu0Rd9z1w6RVUetmxXRhA4X8If6hqiuPW5Gc/NJDDrKmS9l9 33PYLMBDK+AI5RkfYn5Gynx1nSjMGPswD87x2wS2LEupVprthgnwB96pYXx5W7ckp27+fAR7hd3 zq/P6+7+X1JTLqKrIl+Q9I5bqjtazZIE+UvluuuCae9eno6NvLMbCUKeV/jhQwuHgws5Etoj9cB D2uuI/mWKxVslftGXcUjFhsRi2UgDBK27RzveBpTYVWwZZNULmna1YP0yy09b/nKTRc280EtVC1 15ewZwjLc4GG1stwfeoo3ReezLzDqUp1B4ZnJQOsn8Fcq0RPE14DKd+uQO16rpcXZipVRrGsw2d AEXeQLEQ== X-Received: by 2002:a05:6a21:6812:b0:3f9:9975:4287 with SMTP id adf61e73a8af0-4014db58a21mr35257815637.45.1796029884783; Mon, 30 Nov 2026 01:11:24 -0800 (PST) X-Received: by 2002:a05:6a21:6812:b0:3f9:9975:4287 with SMTP id adf61e73a8af0-4014db58a21mr35257787637.45.1796029884284; Mon, 30 Nov 2026 01:11:24 -0800 (PST) Received: from [10.219.56.91] ([202.46.23.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c87285c14fsm17271090b3a.15.2026.11.30.01.11.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Nov 2026 01:11:23 -0800 (PST) Message-ID: <2c58c159-3062-4afd-8b28-0c7afc996345@oss.qualcomm.com> Date: Mon, 30 Nov 2026 14:41:19 +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 v3] misc: fastrpc: Add cache maintenance for non-coherent platforms To: Arnd Bergmann , Srinivas Kandagatla , linux-arm-msm@vger.kernel.org Cc: Greg Kroah-Hartman , quic_bkumar@quicinc.com, Ekansh Gupta , linux-kernel@vger.kernel.org, quic_chennak@quicinc.com, dri-devel@lists.freedesktop.org References: <20261124120604.2640046-1-abhinav.parihar@oss.qualcomm.com> <6db57a38-ddf9-4345-996b-82db8a790b7a@app.fastmail.com> Content-Language: en-US From: Abhinav Parihar In-Reply-To: <6db57a38-ddf9-4345-996b-82db8a790b7a@app.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=BPgmP1QG c=1 sm=1 tr=0 ts=6b0d3dbe cx=c_pps a=rz3CxIlbcmazkYymdCej/Q==: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=Cm05He8fsTNdmMj0co4A:9 a=QEXdDO2ut3YA:10 a=bFCP_H2QrGi7Okbo017w:22 X-Proofpoint-GUID: xix9lIapIs9Kj9lyXYucgwgY_b2kUqO3 X-Proofpoint-ORIG-GUID: xix9lIapIs9Kj9lyXYucgwgY_b2kUqO3 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTMwMDAzNiBTYWx0ZWRfXxCS0F2o1ugVP P1GsJaSpFmFBAcjQCZtKYcqSbepwpLTHTjf0m3nyUBZq3eGhgsrwQh7lSw9BQ0TNH0DzEUeCtDn QikZgVcawZPDaLJVAUp3/WKQsBAeggw= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDAzNiBTYWx0ZWRfX5z+QreOVaS38 sEsoVJVzj22bQG+2wxb1sq2imbdDjN4SoTLwz9iiZnNeQUo7BcFaWrLzAK6CiyFgQM4aykgrHK/ j+tIn5Is6awkrku5vmCWleKneHagNeGwCzirAdAcQ6Bw+cPXT35PSiCu6LyDgnMskSStmC5nMnV DALYV5+w8+ViRkIwUn4fhWWz3GjttLJRaSwLArfhgSx6CDj/P54P6N+5piWVU1nDuSa49zSU8zn Of8/AsuogAnkMboAwR9bSZFEOkHjKVIHJRNgclU9ryP3qhzjgIB0nujXxatNr+y1KxlGR1XHx51 FjT9JwcB9xKJc/bBG4Ej8O9oyGp712EmFjO9RVS8Uav4Fo54r7d8c931TTm+mt2pCsi33iZB2Db 0dmbek2ykj/JfxVIVtxM1j2up68kVVOv7xdKsG4tq8vj1tkUgl7yxsTkcw6LRATCP/avbTpMKvz NkpYCSrgEC09hRtP2lA== 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-2611300036 On 11/24/2026 5:59 PM, Arnd Bergmann wrote: > On Tue, Nov 24, 2026, at 13:06, Abhinav Parihar wrote: >> Some platforms using fastrpc do not support DMA coherency on >> HLOS. On such systems, explicit cache maintenance is >> required to ensure data consistency for RPC argument buffers. >> >> Add cache maintenance for argument buffers when operating on >> non-coherent platforms: >> - Flush input buffers before invoking RPC to ensure CPU writes are >> visible to the DSP >> - Invalidate output buffers after RPC completion to ensure DSP >> writes are visible to the CPU >> >> Introduce helper functions fastrpc_flush_args() and >> fastrpc_inv_args() to perform the required dma-buf cache >> operations. These are invoked only when the device is not marked >> as DMA coherent. >> >> The coherency capability is determined using the "dma-coherent" >> device tree property and stored per session context. > The dma-mapping abstraction is meant to hide this from drivers, > why does this driver need to know? I added that check because I thought coherency varied across targets and wanted to avoid unnecessary operations for IO coherent targets. The data flow is that userspace allocates the dma-buf (system heap), FastRPC driver attaches and maps it for the HLOS SMMU, and the resulting IOVA is passed to the DSP, which maps and accesses the buffer in its own address space. Goal is that inbufs are updated in DDR before DSP reads them and outbufs cache lines are invalidated before HLOS reads the DSP results. >> @@ -1078,6 +1086,54 @@ static int fastrpc_create_maps(struct >> fastrpc_invoke_ctx *ctx) >> return 0; >> } >> >> +static void fastrpc_flush_args(struct fastrpc_invoke_ctx *ctx) >> +{ >> + union fastrpc_remote_arg *rpra = ctx->rpra; >> + int i, inbufs; >> + >> + inbufs = REMOTE_SCALARS_INBUFS(ctx->sc); >> + >> + for (i = 0; i < ctx->nbufs; ++i) { >> + int raix = ctx->olaps[i].raix; >> + struct fastrpc_map *map = ctx->maps[raix]; >> + >> + if (raix + 1 > inbufs) >> + continue; >> + if (!map || !map->buf) >> + continue; >> + >> + if (rpra[raix].buf.len && (ctx->olaps[i].mstart || >> ctx->olaps[i].do_cmo)) { >> + dma_buf_begin_cpu_access(map->buf, DMA_TO_DEVICE); >> + dma_buf_end_cpu_access(map->buf, DMA_TO_DEVICE); >> + } >> + } >> +} > This does not look like an appropriate interface: the driver > should not have to worry about platform specific details > of 'flush' or 'invalidate' and only access the data between > 'begin' and 'end' here. E.g. if there is an iommu or swiotlb, > the buffer may become inaccessible again after 'end'. > > Can you change this to have separate loops to manage > ownership before and after the access? > > Arnd I was calling dma_buf_begin_cpu_access() and dma_buf_end_cpu_access() back-to-back to trigger cache maintenance. Currently we are treating these calls as flush/invalidate primitives. Since FastRPC passes the mapping to the DSP rather than accessing the buffer contents in the kernel, could you advise which interface is appropriate for this case?