Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796029887; b=GUx//Qbm81XZDpMub8MdUqo+kwlM21CYDLSZ2Hyf8a/WvLM91H9W4RfR8gXofqyOyO3x la98y7QZevCA4I4EyKUSUUUmajkJPl3mLJsvQha6218fIRKrcSNrZbO9r/TXk4i9xKYoT CGPJQy41rEEm2QPXLnpASlCtAw4KMcCnZScTNuOfGLYrGnFnKqVww+mLVBeSfczwjnTQ+ LWF/f9L3NwhsTbqcAJd0YA3tjziDXdtJqH22Lev2bTd95AF6AtTZ3+bYujJoTXCFkPDHX gmjzVYxvH561348RyvgzsHlXKT1/RVo2EOryRikpzs+AZIszcclTwl+5j8MrP11EFSQ== 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-ORIG-GUID: X-Proofpoint-GUID:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-Spam-Info:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=KOkqHc7EN6pLogLULj8r3WyNmBg4hki7Ohj1ceeDpkI=; b=DiIHTkSdj7pmBZVMdOX631+QRXS7yPvVHEF3UvUJs4hlbGFikNXUoq3njZpQpbS/FJeJ Fatqrv1VekpoqCULUNcgijnwJaeVmRrD3mfQaD6cYeJMAwWvB6GGh4t7WntljhEpcfR3X D13mKe+F0ABHdNLxBP4J66QDu+dwlLCI9zeJPEYhefMkh/wH2yrFL6OkmKu6JM7kFuubC Y7IQ5pVUaBWt+i5+DB78kkoOOmHa8vhEiPTifv9sbdmct22CcsmdqjGnwKVLv62t6pKqv ubWfVZOL65P3e6OFxm3ibr4/oIRJ8oNsqwYXc9mVIFsccIVFduX+SyV9qXoXrXaO5vg== 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.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 4EFE1606A320 for ; Mon, 30 Nov 2026 09:11:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4EFE1606A320 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=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 (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AU5GHBK3991667 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-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j90c1saa8-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 30 Nov 2026 09:11:25 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2f09a37f41dso72402365ad.3 for ; Mon, 30 Nov 2026 01:11:25 -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=jSNSAPpex+UlB1kA5J8cR56LJdrPUGxDVuLC0S27RWV3K43XjCNcKY+WbGlTaWYnCv SV/w+JT0iPda0gk7Vw+YZqCHDgpltyk1XmqAIw6tadPIo+Ct8rspZHsFeEwn7PeV/1ac bLI75WxcehwMiHQ+DRj7ZqlT/v9dRe1dAErQUg+v5Z0eygyRMuh4sC+SgsINQoCNUXRR qzAGdPBEyYY2N+73bTQIWwHIT1lrhDZLHCoJstJenH0cgFi6gHZ28HpQzx1vW0pOVskq f3Pndp5DBFbQq/aF36rHCfbc0qYG12MXRd+PjLlLOqBQ6X8OnL6KBuzwGHcyqSgLcNsa JUMQ== X-Forwarded-Encrypted: i=1; AL+hErHL7ejvbCkvZYP2MDV5bvH7KSBr7bqfNuB91waVc55SF8do76MjdF3ZPUN8Q/R6+3/vRW7y/V7N/IAh3ulV@vger.kernel.org X-Gm-Message-State: APuU4Z8afpMMEcK5T8VtvZV6tembEXgkfc44iZ5W2jc6Fp/WheezN9fJ pcfpD+w++T4oYjreF953akzVYg7osr1RWTRIiSG5k3a+X7EHUZoSLTYSytcKE7bwtZKxtygai4s Za8ppwu73IXazjuBRQ65Ye6xdbvrDsGRLhp1hiiIWA2lceMfFLUFUTACU/OqVht97K0c5 X-Gm-Gg: AZFdTZc2SS9/KtUZcJU23hqpXExv/QjqQupH6SvJVAiJzhmxJj6AeGp/bi0rChM8Vx+ l3426v33nDikGHmgvjN2bj8QbNhZz3ZrBoKqNwikDmcB8P3ibFP+AUUVXRwoPlBrynEbY8aEsda bX9AYX4U7Tn1BKkvmIxWbRoUJhUvr8/nDMW8X0hVUgBHlUaqGqawAKcGC30PYwTHS2nHih607nV PT0HIyumsmq71kXjF4Tw00cHp0RWsPpPTA7v0Up6hJwgTu49+o9coKEACSakkutrU9ZwJX4+CQ1 tdPLmmaMN+fItzkoTip04kEMB8TbjfN1zgL052+SbzkvK/HTPT+caLz1aAiIgyv3iwKI9IxtoVs hrkXmKDerVlB/wD5fsoPMN2l44vYJZYJ46mYSNCDbNoJuT9l8EVlLJhcHrCKUCKHqp0po+s29vu Po7coSyw== X-Received: by 2002:a05:6a21:6812:b0:3f9:9975:4287 with SMTP id adf61e73a8af0-4014db58a21mr35257814637.45.1796029884782; 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-arm-msm@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=R7+WitRX c=1 sm=1 tr=0 ts=6b0d3dbe cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=j4ogTh8yFefVWWEFDRgCtg==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=Cm05He8fsTNdmMj0co4A:9 a=QEXdDO2ut3YA:10 a=1OuFwYUASf3TG4hYMiVC:22 X-Proofpoint-ORIG-GUID: bTNEK6EHiMOtcAQl6vl06H3bFgGy0jef X-Proofpoint-GUID: bTNEK6EHiMOtcAQl6vl06H3bFgGy0jef X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDAzNiBTYWx0ZWRfX6BRq2WZ+5bn3 BHHj19a0k2liQ0tgcKCbaDhOgqi+07efn6gMrXZ0WOw/ciJGW9rwriFKvG3X3RG2z1Ilvj6dA1B a+32y4TlTuC6EtAnnaod6JSEabtqDXEaLuz+tc8/EGuP1RdcwZ8lmKk6KR2QmmSjVhDt9BD6mLb PUVLV7tXEQEHBULGYJJLZygmf/y7uHocwwoJ7lPlIhBgGRmLrxygJbetesoDvd1psavq2WDgP1u JsnLark+WHgFofaWddUjmcqBcEJXOPOoE8+LYpSCUsjQ4f+vnuv/JG5osz7qSARdQX6Eu3kZZvt IX5fzSMo5IEVZsPfldC3mVvg/ru8kdifb1syyZny2bFkT0bYEQrPv2OgGmjUsTYa89AUGeFYIb/ xpFXJ1Rlmfd/TFOReOy0yc6ltCrGcYLTBnaB437zwlSQ73VdD3WBVaaXyycxR5/jqhUoLcZFZhl V+YQ9c/BpbiBJ6s52EQ== X-Proofpoint-Spam-Info: AW1haW4tMjYxMTMwMDAzNiBTYWx0ZWRfX82EbIPlwhlzP rAhZ6sjz/4kUV6ESI1tdNkrb5zk853A9CZcJFqXGs8WtJ0gY9V+HbBBq4lmyApfbtDnaEudYPTm LDp0B69W5KJQJnaKSOuHwJ8JmIeK1jA= 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 adultscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 bulkscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 suspectscore=0 phishscore=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?