Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp89826lqo; Tue, 7 May 2024 13:07:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWNyL3MryUF9uUydx+MjpDxbpca5lIM6YiWmjGUfmqeJFG6Q8x1/ulb7O8NM4x2KTe/5p3vG1X8uJKM17gXNtcJLervi/XB+loX+Yh8ow== X-Google-Smtp-Source: AGHT+IHVv+YnCGqn52j8YcybamlNMj64G29xaYAlfY3ASxwHRGPvioruhibCiMv1iSFnY8malhIw X-Received: by 2002:a17:906:f0ce:b0:a59:ab0a:a170 with SMTP id a640c23a62f3a-a59fa863f68mr69312066b.1.1715112457918; Tue, 07 May 2024 13:07:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715112457; cv=pass; d=google.com; s=arc-20160816; b=fk6UewjET+DGcuINnWtSWDTt6sM40UDvZrOFhooAVfy0Jhs5BkAgunrDR738fgvmuX H/u/IpoVauydUckXr5lrlyeiGujOcwjIhz3mpUKL0jME8kGfb8ysNDg2IDw+GpcA6gvD 0UMkQtZ7PiWejgctQEbFqM8Qsl2QK+homE/6SBOOCklCRTLbcHPV2u/ECMBo1BXvHIOT 7SvSvvtSqzRuMkSt3MzmEv239LpLBKdwns2tfCthYxn39EwSw9632wumr18vavZ/m+lw kMQba9+N62ouL3ivo96dwXWULzUmzmCy/UlHru2ShCLMoUr//0eN3X2bL6LZq+dXzFnZ 7Qsg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=9u4+z96HwXR809ZF1PkEWCwnBjus+4ZFL2JjXWvh/IY=; fh=b/qpWQCm5Se1DtCnvFWgtBvlkK1tBhQbIrv67/Aa2TU=; b=fPgVwsFgaF3FDSBtYa8x5Zf/JVrfKUBvfGeFqgNhUfp519hAFn99M4Rgd03lb/8ObX cZWELF6PVQDD7rZjQxmijQbi6h3Fgpsi8o6XBuKuZ4rv++sWFa7vyhwhgEo3Nd4UA4U3 pGR4K7x+nCCHkPO0OK+/uS3LGl9rM9nzdys59YT7k3zr1jwdi0ry56E14rASuk8eEa8U LVUEGIXHlQ6EGzxyxE6ZwpPukDTRP0DVA4nn8E7WS4zAfHHRwZUVlVpNN7rZupr5NRHm YSweWAN+96pJxpFE2ndFgkomT9xZhHGAoOndP0fIbj2zmBdqrvQSAsudo+AEuCvonCmk S6Rw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XmcZxY1Z; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-172117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172117-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ds7-20020a170907724700b00a59e417b379si1473060ejc.851.2024.05.07.13.07.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 13:07:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XmcZxY1Z; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-172117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172117-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 am.mirrors.kernel.org (Postfix) with ESMTPS id E1B801F22879 for ; Tue, 7 May 2024 20:07:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 884F716F851; Tue, 7 May 2024 19:59:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="XmcZxY1Z" Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16A9E16E89D for ; Tue, 7 May 2024 19:59:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715111995; cv=none; b=qYASoHBJ6rx9nQ2iLzfzVrOriWDH3TPUMXxXlGLrLMNUTB5aiGYfJNBIp5Q20us8fBAe0yKwvU8F7cUFwsR2dfq1Klx3AMq6rBv8X0fxwcSA0X5gNsWH1ICMO9F/uB5DqeyuOvatDYkZ0mWWbQ+V1tphFyFuzL8BWyv3UGJWPc4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715111995; c=relaxed/simple; bh=i96+goKGZdI8wImUoBjARaHLkBInrQRdMejjNFZXHzw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IH6w5hm4h112eqFO+ktQD1D8TLjYqD4iTGzmKsrD3Z3zA0oJPM0FkJc1fUiul+d5PsTazMhAYvgjQFoaarbAL3bMOwQ635thknmIEQud4TtL5Kv15/Fh/VrgoPHBRxdor9pZIq8Vaetz0//Y+ZGyxa83ZOgwgZRm39xmcDaI15k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=XmcZxY1Z; arc=none smtp.client-ip=209.85.219.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-deb654482bcso3631860276.1 for ; Tue, 07 May 2024 12:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715111993; x=1715716793; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=9u4+z96HwXR809ZF1PkEWCwnBjus+4ZFL2JjXWvh/IY=; b=XmcZxY1ZgEkDXw/DzhDQvc5uElkUX6GOVrhwWzoXkytPq8zHWUpViRFjZY4v7TlXLn iQgZRBo0IT6nczarnCP4M1JHMGENvHKDZUreFSfSzzPqLIIGCTPozXdxLx+Hc7ubhgmO PCSaRbywb+q0I5AAeC2pQLbkXA3nJJ2dyavcbE3V2jstY1EXKzxMl9KJXBk6Wnx9yecv RIDOAYyuUQHCWhg9yfoXXOz3mu8PwzWIyFXg/zdFrCDdfIagTYj6JuMVhxAAsDCvwKtx ElOstvG4nuBa8PSZy48RYAOGmN5iPE7JcfArX89MEGYV5iOgEzGEFP2bCJzfxyXm5TxW GXOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715111993; x=1715716793; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9u4+z96HwXR809ZF1PkEWCwnBjus+4ZFL2JjXWvh/IY=; b=S1b6GbevEBjnx4bNDLp1EEG22UiJ626nVkMTHgL7C/6u1dbHEO4aSQMEa4nrn4othx szjYfl8CtSqWg9WS5lbng3BhOQ6ihXN4zuaD1DH9daux6LNhzl3PnqvJRerY70Z4U5ut UNACKZbdJZH6aV2GPm2BxjqQRWiXcmYjLO0QFjOAG3jMmq3NRP0fV/Cld0QavGr0lw63 SQNbF2E5+DzeRZMoCRhvP1SGm/njG7wsmfymSKBdnN+rhzhYEZnUlN7tNkLrM2Cv6UCd 9SW7+Xol9CEKAvPSAYf0D1E0sYpiNMHXItnOPKvzdLSCMMw5UhK7Q0VJ2+zlkQOYO6Fg vqMg== X-Forwarded-Encrypted: i=1; AJvYcCWbTYhpaDHtB5Beo/XHDODQH+2ZfVdLK1weowGmgdML+qTtLLreS3V84n+8QjGG3ODlAHlg7Gl+7NERu8EX7kxkq8KuIP4EWPRElFvB X-Gm-Message-State: AOJu0YwG7MavrLuxjZUhVoqkCRSUAKCr+f6n0CcaUd1jmcrP9+wKqzh+ fijiVyckkl2rpq4q7oofV+LSkYTgQjJ0OAg604Q/PC2jLLzsS0THfsv8xQOAHILAg7nsb1tcCFx 1e453N9/P5UBlV53X8h8FVz5snzayKWnn64Nlkw== X-Received: by 2002:a5b:881:0:b0:deb:b3da:b1ad with SMTP id 3f1490d57ef6-debb9cf9739mr749935276.12.1715111993047; Tue, 07 May 2024 12:59:53 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <3c0c7e7e-1530-411b-b7a4-9f13e0ff1f9e@redhat.com> <20240507184049.GC20390@pendragon.ideasonboard.com> In-Reply-To: <20240507184049.GC20390@pendragon.ideasonboard.com> From: Dmitry Baryshkov Date: Tue, 7 May 2024 22:59:42 +0300 Message-ID: Subject: Re: Safety of opening up /dev/dma_heap/* to physically present users (udev uaccess tag) ? To: Laurent Pinchart Cc: "Bryan O'Donoghue" , Hans de Goede , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , =?UTF-8?Q?Christian_K=C3=B6nig?= , 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 Content-Type: text/plain; charset="UTF-8" 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. > > > 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 -- With best wishes Dmitry