Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp3915045rwe; Mon, 17 Apr 2023 05:36:34 -0700 (PDT) X-Google-Smtp-Source: AKy350b0ERKncpBywuH2x05Hsm24zTIhTpanon2svAJSFKoLrEd8S/70InvMr6bo8Sm/qOtj2WXg X-Received: by 2002:a05:6a20:699b:b0:f0:219e:f114 with SMTP id t27-20020a056a20699b00b000f0219ef114mr1756373pzk.35.1681734993837; Mon, 17 Apr 2023 05:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681734993; cv=none; d=google.com; s=arc-20160816; b=hxDzxu7dhOyAH/R9gNMSxb04wqt73GYzJWvZj+SOaAk4I87PYB3gY23eMfH/uzc+Rj SrXABDKeBKigbjKE2dHgr0XFvu4Af5y4RYCAOkr/rdHN/UtWHyDNI05vzbCOgZ6RVcVw tqVitbuOLd94cwColqzFwp7VSCSWfCQBwPTrSgkOCHZSOFiGc/0dRyFFY5tOc85yZV0D yvembqtk/KOCQnnDxgf0Cl6t53dmsczilj1LymMSygb3oTfUlqI3YTwcO4F7RK7kJ9pO 41qfwWrihmP3yQmMKufHxcN5Qkbi8BJ6nAOotAegR/B33Xh5Ks7LR5C2appVF2+ScrvI N1tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=ra8yNCbawCcIf6dzsG//FIG3sSDS2uALTiSWM4rrdu4=; b=Lwc4kQ7VTpvhNjr68SyMsYcyGG2Te7XYAYeZgZpvHw/LeF0QwD52UaBaa3xty+SVwG S0p/7gt1Mpf8wDzgktpdK8Tkx88quwctDyLYPBUjH64SZARyFt8/2G7sw1NDmFJOHplo tQfR/A54aRvkqkuXQq7Rs6v6qmSUjSSDbg9VS6pamC8UT8T1jlFYW9dPX/J7BTb1dky9 R4Kov0pU07XVr98YyGwvLFYp/qN4lt9NsPh9O9FNW5MgHppG+emfOQjfhAzp82LVCBzy pXNPt5I0nbaEYcpGBKR09L7u4tfjzAMttwd9mGyr2OoVkyUZd74uAENodX1j5oocHd2B IpbQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020a630315000000b004fbcff506c5si12137062pgd.346.2023.04.17.05.36.21; Mon, 17 Apr 2023 05:36:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230109AbjDQM2D (ORCPT + 99 others); Mon, 17 Apr 2023 08:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229898AbjDQM2C (ORCPT ); Mon, 17 Apr 2023 08:28:02 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4D8B044B4 for ; Mon, 17 Apr 2023 05:27:42 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BF6BE1E5E; Mon, 17 Apr 2023 05:28:25 -0700 (PDT) Received: from [10.57.80.202] (unknown [10.57.80.202]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 47D633F5A1; Mon, 17 Apr 2023 05:27:41 -0700 (PDT) Message-ID: <42d401e9-57d2-1178-eb94-68f975be73e8@arm.com> Date: Mon, 17 Apr 2023 13:27:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [RFC PATCH] dma: coherent: respect to device 'dma-coherent' property Content-Language: en-GB To: "Z.Q. Hou" , Christoph Hellwig Cc: "iommu@lists.linux.dev" , "linux-kernel@vger.kernel.org" , "m.szyprowski@samsung.com" References: <20230414080307.35114-1-Zhiqiang.Hou@nxp.com> <20230416063028.GA6276@lst.de> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023-04-17 03:06, Z.Q. Hou wrote: > Hi Christoph, > >> -----Original Message----- >> From: Christoph Hellwig >> Sent: Sunday, April 16, 2023 2:30 PM >> To: Z.Q. Hou >> Cc: iommu@lists.linux.dev; linux-kernel@vger.kernel.org; hch@lst.de; >> m.szyprowski@samsung.com; robin.murphy@arm.com >> Subject: Re: [RFC PATCH] dma: coherent: respect to device 'dma-coherent' >> property >> >> On Fri, Apr 14, 2023 at 04:03:07PM +0800, Zhiqiang Hou wrote: >>> From: Hou Zhiqiang >>> >>> Currently, the coherent DMA memory is always mapped as writecombine >>> and uncached, ignored the 'dma-coherent' property in device node, this >>> patch is to map the memory as writeback and cached when the device has >>> 'dma-coherent' property. >> >> What is the use case here? The somewhat misnamed per-device coherent >> memory is intended for small per-device pools of sram or such used for >> staging memory. > > In my case, there are multiple Cortex-A cores within the cluster, in which it is > cache coherent, they are split into 2 island for running Linux and RTOS respectively. > I created a virtual device for Linux and RTOS communication using shared memory. > In Linux side, I created a per-device dma memory pool and added 'dma-coherent' > for the virtual device, but the data in shared memory can't be sync up, finally found > the per-device dma pool is always mapped as uncached, so submitted this fix patch. Yes, in principle this should apply similarly to restricted DMA or confidential compute VMs where DMA buffers are to be allocated from a predetermined shared memory area, and a DT reserved-memory region is used as a coherent pool to achieve that. Quite likely that so far this has only been done with non-coherent hardware or in software models where a mismatch in nominal cacheability wasn't noticeable. It's a bit niche, but not entirely unreasonable. Thanks, Robin.