From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.151 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796031531; b=cm1CwOCGdH+kzI2ud7AaJidAgticye05lYgi1OLCXb9Kt4YS8H0/cleH075oUMWQ5jEd 8ZR06wiBJ2wYOKXIk1krmgwbOrpTZpcSbvSxbrMxPyd/6/+6JuKAG/Po4KR1SyhfrdN18 A+WOMDkQB1bECAFX81dBczqyEhI0FaQ4mxXniugfbUtz4FGrWPZmT7axYRP5ntVwG34yu lYpusTQKx47oTtPxHdWSx/T//gd7nU8F6LcfN6aM6XCh7mxW5GRWz5y+ZafzUounIcH1q +37nbOCOYbv/ENQiwL0jPK5Qw4JLAdaJnlbuSLhMRKikk6aHz0ii9LNhIezcZiMXpTw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796031531; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:X-Mailer: MIME-Version:X-ThreadId:Date:From:To:Cc:Message-Id:In-Reply-To: References:Subject:Content-Type:Content-Transfer-Encoding; bh=X5QQgo8U8cOi/cxS3HDb/CNasj3mOzO7k2rMXURVvs4=; b=GwN+71doJzXpeb7GOwaaJ8mtR6Lm/2esVxuZkq+BCGzZbxD3RaBrgZFLBzbSjlnLHQKT SCB9vtyNR9V5E6ayNHTTBO/H96uDttKcUYmVnktl4u3gCvD6PcPZSumZYkcXRskb+WbkE 81XiskBHwE3+R+GqDgTVbGasXw7OkKqHyKPHZ0MISB63YC/Bnm8QQZebaRuw7qGDSghWf snTkqOrUk38Zt42tfcrOHg4Enj+APTUo9tmNE/Wmr+7ZUPWyoW5Y1/ag+uXUVzPKVJPA9 Ko6PKbrVUcpYNpFbH6rQxqbsN6L4dfNsE+eMbjHIkXYnIi9jDlaFUUYSFITsw4ZGiHA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass header.d=arndb.de header.i=@arndb.de header.a=rsa-sha256 header.s=fm3 header.b=etZx+FbH; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=mgXzMPEH; arc=none smtp.remote-ip=103.168.172.151 Received: from fout-a8-smtp.messagingengine.com (fout-a8-smtp.messagingengine.com [103.168.172.151]) (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 E3B2D606A33C for ; Mon, 30 Nov 2026 09:38:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E3B2D606A33C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=arndb.de header.i=@arndb.de header.a=rsa-sha256 header.s=fm3 header.b=etZx+FbH; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=mgXzMPEH Received: from ams-compute-02.internal (ams-compute-02.internal [10.64.2.62]) by mailfout.phl.internal (Postfix) with ESMTP id DB0A4EC0C59 for ; Mon, 30 Nov 2026 04:38:49 -0500 (EST) Received: from ams-imap-03 ([10.64.2.23]) by ams-compute-02.internal (MEProxy); Mon, 30 Nov 2026 04:38:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1796031525; x=1796117925; bh=X5QQgo8U8cOi/cxS3HDb/CNasj3mOzO7k2rMXURVvs4=; b= etZx+FbHqmvjCY2wcCf8SQNHgciURben/PfZlfwbndJ4kl2ohGaeC/t9Jf8Uq5a5 a5AfDwTG5BVk8yeFOpetgSeCTkFLCWRQ/ucntcdyiF27Ge1Wp0p7uGpX/RF/2YUR JCuM0cG6y5insnqCT5VsZl+yDWEoaPDUw7yfz5F2XONlzEy4gF5KsD4glNDWTHek og/GTDAxYc+4TN2vufiBg5P57H5EcePGZv5W5KfDf9wbQcQhfmcC7+FTr8l3GvA1 wBw3tekxBrQvJtcrU7DdrAR9Xv4toOQ4yjKqqMpf+kd3oAal0M8lumpgF0FRgV4k ZQysS3eLYguNBgfOHeNEVg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1796031525; x= 1796117925; bh=X5QQgo8U8cOi/cxS3HDb/CNasj3mOzO7k2rMXURVvs4=; b=m gXzMPEHcSEB/CxlFEiRskGQyr9ghzv9J50EhkHVjYuw/FCTGlj9PpBas/bDRYEtU E1dptlcGx47TC3Rl7n3ERebp+7qNwxLUsIOwDgs4FXf/jB0aqSBtFI0K+Zs0V/WV Xffx1ulz7McQmqZRHgr2yTHp4pYP8J/rGJjCvi0TkDsFROpoMcP8v2Eo6yvmy2tx HytuavIZTD/WZsTxp6In+RwG1+TiPjRyNHBi4KLkNhnu42sonchsdsBhV1pPmsLB yzXjmjhhjMZS8zadfe31M84uf2i/jBXM5VgEAvDJL3xIwE7X09UwT5Fkyd9MV+mN eae2Q4w7gYsvcZNQKGx0A== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=arndb.de a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796031525; d=arndb.de; mf=PGFybmRAYXJuZGIuZGU+; rt=PGxpbnV4LWtlcm5lbEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:JOcPN5tiiS4d4OFVTCITb74OH6fbxh7cHTsoWlzj5NSfknW vBap+7V2A03qAocEbQ/LPoBibyMW7ti7Hd4ifE48daFh5Z1gPS/LWiTXOZTwRWza 7Wtk9sSuoBWKa1eFNJgfnQbFW6vq35QS83Z1aFU3svBFkYdLNkqKPTAVlYJLDEuz ClWlmwc0weBoGhKBvAFCBtJ42J95OOG/w/9xl1y/gViQPRoXk4k3rtm0mzueOANm JZwX8yZPp5CWbbC24aVA03DY0bWdxW+CZ3bb/9knwSZZTymOq12qdj/MlfsssC3/ OhFZaGn8QYbSeIG+Ggiv2SypNhrzwpYTi/uZt3w==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-transfer-encoding,content-type,date,feedback-id, from,in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:8VRqSDxpZhqJuuP8zbI3Ptevud+GS9p5arauy+aeWM8=:KZeZ78usV7ckKeobQx4vWigitdtbhd6+vnKecekUtRY=; X-ME-Sender: X-ME-Proxy-Cause: dmFkZTEEXd4GX/Td+H76RuGOIUvGcKnyV8QqQGper0GUQzsYcTEOlDlvfBsjrP7NC19Ded /mch9Csoc5Bhn4Z5Ik8NmGwkCSI3CVEQK6e91fLmW8uWEYsdQ3mYv35iA3EHicG2yIMJID Q5K9t+mvtWg8+zaao0iGTHDm4DqTUNhsDk4AfkOJ3XfoXzSuwYnQrR87oegnaC7UdY95P5 qC1LSvsQuD4FxmcfsqwnHqlQ72iURQkMyddYH6ODHI7/O1U6uDbY8Ut3LnQY0Zv+xzQ6mx HtlOWktm5hYIAc1GCgqBYMxjHMNuSPMV+X9D9l+UkvsK5qLXNRB6GjcFYpCO1efOeFADhq mD+k8iivxxMpZ0AGsU/zbnkJh6hn+MSRbPlGfrcH5NhR0fAJRBOgln2lcNFxVEg3jjS6zG 9MOozxvR13gZIwdlqdEzWFpHHW3+9uzWzhshtdvdEBCpGQD7YDMMJjYujG5FPk8uxx5aFy eWt9eycyBgDX2TrVQsvV6AMLxUFqzgY8SON5ooI6ZwFoQktMewbaKjBpx7gTrSy7WyS5By 7Gcii2kZdxGcDPxezJawIHK5CrLCEBn+bffcm8lAi1mJT+lF2nRmdNklMtNag3QG3pNUOM 4m6/Hm3QpmcwxGdZAD5xUt0Uv2BLnhoqkr4URkD9YtkZnktTSwkyL8oN5Z4w X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.ams.internal (Postfix, from userid 501) id D221132A0099; Mon, 30 Nov 2026 04:38:40 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface 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 X-ThreadId: AthCWVl4bt_o Date: Mon, 30 Nov 2026 10:38:20 +0100 From: "Arnd Bergmann" To: "Abhinav Parihar" , "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 Message-Id: <87f09bc1-d064-49c5-8821-a7e01efa01d9@app.fastmail.com> In-Reply-To: <2c58c159-3062-4afd-8b28-0c7afc996345@oss.qualcomm.com> References: <20261124120604.2640046-1-abhinav.parihar@oss.qualcomm.com> <6db57a38-ddf9-4345-996b-82db8a790b7a@app.fastmail.com> <2c58c159-3062-4afd-8b28-0c7afc996345@oss.qualcomm.com> Subject: Re: [PATCH v3] misc: fastrpc: Add cache maintenance for non-coherent platforms Content-Type: text/plain Content-Transfer-Encoding: 7bit On Mon, Nov 30, 2026, at 10:11, Abhinav Parihar wrote: > 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 >>> 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. I don't know what HLOS is, but the dma-mapping interface generally does handle this through the ownership model if you use it correctly. I would generally recommend to have one of the devices that share the buffer allocate it instead of using the system heap that makes things a bit more complicated here. Aside from FastRPC, what are the other devices that you expect to access the dma-buf? Is FastRPC the only one that may not be coherent, or are there others as well? >>> + 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? > > > 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. Right, my point was that this is not a portable way to do this because you rely on implementation details of the interface in order to do the exact thing that the interface was designed to do for you. > 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? Documentation/core-api/dma-api.rst explains the concept of the ownership model, the idea being that a buffer is at any point owned by either the device or the CPU, and you use dma_sync_single_for_{cpu,device}() to switch between the kernel. dmabuf extends this to allow multiple devices using dma_buf_begin_cpu_access() and dma_buf_end_cpu_access(), but the concept remains the same. You can generally choose between having the mapping normally be on the device side and enclosing the CPU access in a dma_buf_begin_cpu_access()/dma_buf_end_cpu_access() pair, or conceptually tying it to the CPU and enclosing the device access in the reverse dma_buf_end_cpu_access()/dma_buf_begin_cpu_access() pair. Since you seem to be dealing with multiple devices, you probably want the latter so the buffer is only ever owned by one of the devices. If the buffer is also mapped into userspace, you have the added complication of preventing userspace access while the buffer is owned by a device. You have the choice between risking data corruption for misbehaving userspace (which can be acceptable for certain types of data but not others), removing the user mapping during device access, or using a coherent mapping which requires expensive uncached user access if the device itself is not cache-coherent but avoids the explicit ownership management. Arnd