Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp94014lqo; Tue, 7 May 2024 13:15:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXnRqJR+HT9GJbplnnRxuO+kSd3Bmd3xtNgBrPfuU5ont/xyHanqfTk59coK34DrTXU/VW3+ddu7w5M+WbsNzuVRCbgu8xt7s251wYZTQ== X-Google-Smtp-Source: AGHT+IF9bKsaW5fn1otiS0Laa/8HlZ+BAWa3KDAG9kXeTtesnFUvbxFtiVJaIkTuBKW3b+Cuj2R4 X-Received: by 2002:a05:6a20:3219:b0:1a7:5334:fbf3 with SMTP id adf61e73a8af0-1afc8e05067mr815591637.55.1715112951161; Tue, 07 May 2024 13:15:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715112951; cv=pass; d=google.com; s=arc-20160816; b=aSPFTr4ia8d2UlyOp4qHtHQnj98GMgH2H3I5lJfQ8yKtWOBbU45z5F4+EfJ++WL6lL Thbt8Px1hzFdbzXOkS1MCp/7HdSr6lcKE0fsf2fdJWYmFMLg0D/WwpDUHvwZ7abheyof Q5kzRDoCZBGhkgsEhUmfxT6bIVAOJzh0d7Rf28xsTGafFhMDM0rky7nbeKRQAVvHREaG 4xUl/q4C2Y+uRw5cZsTQYcY8KSdQ/cEjJrhRyedoFgBzLWQv+iANe6ywiROJEm7kBMFq 15RLddaQzVz4bnZwAG/n1/doZhfaN4CHfATdbRAtVWWf7LcU2Vse4obqv1/8X1oX/NEh yQbg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GuUgvMqx+83CyA8R7P6sCI54JQAgIP9v62ohjVIkKdc=; fh=ZQIxunv0YZrgaSQVO1XZUBv4Kxxhb3cD8DoV7TeL50o=; b=spAzsQQ729gnTYvpwttUM4rtp8QfZYx6ASpYXd3WtWNzjjG883Vmrp5eB3XG95loQ4 F7LVlkNUARkczj5GPV/BxunvaXLajsbfZ7rDO3F1AIL7NpOjmNPYF6zyQX/c/Rnnwucq Pca13QKgmbk1MQSHWew/VqUE3kmgE1NSKHV725D0Ck51lwVrF1CZF2I1oEaF4mE9zzjX S/iAiP4+PJBg7T9pPh2EOy7s8KHFthXmRZbhP5o4aNCImlTXWtJLoWdB6e8d5t7dKDha nqekKOJc2EFgvl8RBcV4hCOizPn4unyEuYVPzHFYTBI13GQrjlYY++UOmWLvVEr4Gpld Njhw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=ZjPGeIOJ; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-172133-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172133-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id le17-20020a056a004fd100b006f4743cf2cbsi5714327pfb.304.2024.05.07.13.15.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 13:15:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172133-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=ZjPGeIOJ; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-172133-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172133-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4CADE289730 for ; Tue, 7 May 2024 20:15:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BA5418733C; Tue, 7 May 2024 20:15:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ZjPGeIOJ" Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (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 0B613187324; Tue, 7 May 2024 20:15:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715112919; cv=none; b=qcvvrkuUcczn8DITWEkyJsyQ/dzosYciZay2AXCrDIluXjrxgaEh5OnxDGiAk3KFKLcp5KuX9FivlzS7vo+LxZtKjGLd/MU5JGztp29gUIDPZKvudpKY0RDm/99tOWIaElvS426RT+IUQk1wd26cXQKWlCMtrPLpF9+Q9uk5Ick= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715112919; c=relaxed/simple; bh=gpzcY4y3i2KBXNv1yb0z2rP0d1+GAgC9/AU3xoG+moM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LGlGybk7ZU21R2sMV2gGIz8JiC1HdWMZpPA5LHpHRazjmLrRPtZoDxm6zKeb1dS5WesXk/LaEMfgDXWtKeOV2g/s12M9eE0bHThaTOw7tqJ5DFRbVM+NWOOrrW2a58UFvsLQFwRTadWHur42Qnggfm0PHAejuHhANUGHVF5FUB4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=ZjPGeIOJ; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C2E26DFB; Tue, 7 May 2024 22:15:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1715112909; bh=gpzcY4y3i2KBXNv1yb0z2rP0d1+GAgC9/AU3xoG+moM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZjPGeIOJTDi4STMtKK6eRAtKTpi5o3A1Luo604bMWViu+xRjvML3zbzSvIkJw3ocP UHz4M9uRyXtZjvHW0U6OIGFZVGYQ/cLL8yS5QF7s4z9C72gXFpE34klgqi+laBoxJH ASfjttCYYcd0K9T9QjIQ7QeK0dGXZAV20oUxCgg8= Date: Tue, 7 May 2024 23:15:02 +0300 From: Laurent Pinchart To: Dmitry Baryshkov Cc: Bryan O'Donoghue , Hans de Goede , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , Christian =?utf-8?B?S8O2bmln?= , Lennart Poettering , Robert Mader , Sebastien Bacher , Linux Media Mailing List , "dri-devel@lists.freedesktop.org" , linaro-mm-sig@lists.linaro.org, Linux Kernel Mailing List , Milan Zamazal , Maxime Ripard , Andrey Konovalov Subject: Re: Safety of opening up /dev/dma_heap/* to physically present users (udev uaccess tag) ? Message-ID: <20240507201502.GC2012@pendragon.ideasonboard.com> References: <3c0c7e7e-1530-411b-b7a4-9f13e0ff1f9e@redhat.com> <20240507184049.GC20390@pendragon.ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Tue, May 07, 2024 at 10:59:42PM +0300, Dmitry Baryshkov wrote: > On Tue, 7 May 2024 at 21:40, Laurent Pinchart wrote: > > On Tue, May 07, 2024 at 06:19:18PM +0300, Dmitry Baryshkov wrote: > > > On Tue, 7 May 2024 at 18:15, Bryan O'Donoghue wrote: > > > > On 07/05/2024 16:09, Dmitry Baryshkov wrote: > > > > > Ah, I see. Then why do you require the DMA-ble buffer at all? If you are > > > > > providing data to VPU or DRM, then you should be able to get the buffer > > > > > from the data-consuming device. > > > > > > > > Because we don't necessarily know what the consuming device is, if any. > > > > > > > > Could be VPU, could be Zoom/Hangouts via pipewire, could for argument > > > > sake be GPU or DSP. > > > > > > > > Also if we introduce a dependency on another device to allocate the > > > > output buffers - say always taking the output buffer from the GPU, then > > > > we've added another dependency which is more difficult to guarantee > > > > across different arches. > > > > > > Yes. And it should be expected. It's a consumer who knows the > > > restrictions on the buffer. As I wrote, Zoom/Hangouts should not > > > require a DMA buffer at all. > > > > Why not ? If you want to capture to a buffer that you then compose on > > the screen without copying data, dma-buf is the way to go. That's the > > Linux solution for buffer sharing. > > Yes. But it should be allocated by the DRM driver. As Sima wrote, > there is no guarantee that the buffer allocated from dma-heaps is > accessible to the GPU. No disagreement there. From a libcamera point of view, we want to import buffers allocated externally. It's for use cases where applications can't provide dma buf instances easily that we need to allocate them through the libcamera buffer allocator helper. That helper has to a) provide dma buf fds, and b) make a best effort to allocate buffers that will have a decent chance of being usable by other devices. We're open to exploring other solutions than dma heaps, although I wonder what the dma heaps are for if nobody enables them :-) > > > Applications should be able to allocate > > > the buffer out of the generic memory. > > > > If applications really want to copy data and degrade performance, they > > are free to shoot themselves in the foot of course. Applications (or > > compositors) need to support copying as a fallback in the worst case, > > but all components should at least aim for the zero-copy case. > > I'd say that they should aim for the optimal case. It might include > both zero-copying access from another DMA master or simple software > processing of some kind. > > > > GPUs might also have different > > > requirements. Consider GPUs with VRAM. It might be beneficial to > > > allocate a buffer out of VRAM rather than generic DMA mem. > > > > Absolutely. For that we need a centralized device memory allocator in > > userspace. An effort was started by James Jones in 2016, see [1]. It has > > unfortunately stalled. If I didn't have a camera framework to develop, I > > would try to tackle that issue :-) > > I'll review the talk. However the fact that the effort has stalled > most likely means that 'one fits them all' approach didn't really fly > well. We have too many usecases. > > > [1] https://www.x.org/wiki/Events/XDC2016/Program/Unix_Device_Memory_Allocation.pdf -- Regards, Laurent Pinchart