Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp184948lqo; Thu, 16 May 2024 03:18:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVBvpfrAGjczpE2wOh9LMNQdplv7rahn9IOF3OyLFimiERo6lfVkO/9QPbBm1N3EBmTaZDq1KuxxF4FrKRovl77AUNKTTberk23zKpjkw== X-Google-Smtp-Source: AGHT+IFcf3pAZPgrK+F6dMPI+ZFeMgnlaeJwr6yAMN5lVDT8kgs/GuV2/TF035T8VGxR5n7Y4wuG X-Received: by 2002:a05:6512:2806:b0:513:d3cb:249f with SMTP id 2adb3069b0e04-5220fe794bbmr13637503e87.52.1715854716153; Thu, 16 May 2024 03:18:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715854716; cv=pass; d=google.com; s=arc-20160816; b=dh0rq9dxCqoxvpAH+6d5EiC4+z+3gU2KAamNUSKko0myIDVU1bJ+YPCU1DSRH+fzAx gTSdWMqtze3qGfpCl8Wr+vAlNUBjVTuPC8f0ZW0xPiX7xsWsoILv+fvmoUb2OAOfJQTA 9KJBPx6/JU+VrsTp8prcUPH9fkRet5Ph6BvWOLRAMKgf7CJ9U84sORmeLFLJaIRnuL2f CLjqZROaFZzWyx/mfTDB7ZnfMF8efOUSbVASUQz91laUKB1/j/MDbFhIj1gaoIj/1rfj 9x/3TtfHNG468MIwaW7WNMCEC50TTRs4dwHg5hFTP0HQyFDrkVFBwkC+cB18xMngrKYT qKBA== 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:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=8TJDXJKaQUdW/2WF0Ge4iVoqYkhg+zWynHOclwI6BcY=; fh=l61/vIu2otNPQmGcwHwkL1k0oxsDT3K7XVo9trnDJEE=; b=RPqwHqFYcTqU8tULYkFxVy/Y3hJR0c0Le8GXJx8pQL2s+v+TDzkKs1S2RbDbtsL6B3 jumuM+VXd0YARD4ZTwZ3/cW+xrDcyOgC08cWAJvTIytikQGWcLjU3F7BLjQAm0uqmCVz MVGfWh0KZKDLj+0h4ysD8L29SBSZQo4YH8TjjU8XV3reBzloEUTW3pRw8IbIESiD+d6t h50JBVb7PAK/02GiigVISzLKR3mU/EUzVGo+GaL7aCaD4PCXHJy+Y6bZARK0Jd+zsMCu mV3wTtniRK/637BwtqvcJiQFT6GDNkpsADyBJ8HG50LoaFxQH6XryhxYUgQ+E12Mw8Dk Vh8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=T6gfGK9B; arc=pass (i=1 dkim=pass dkdomain=ffwll.ch); spf=pass (google.com: domain of linux-kernel+bounces-180895-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180895-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c2d530esi9036950a12.315.2024.05.16.03.18.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 03:18:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180895-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=T6gfGK9B; arc=pass (i=1 dkim=pass dkdomain=ffwll.ch); spf=pass (google.com: domain of linux-kernel+bounces-180895-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180895-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 am.mirrors.kernel.org (Postfix) with ESMTPS id B52D71F24947 for ; Thu, 16 May 2024 10:18:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CCA1143894; Thu, 16 May 2024 10:18:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="T6gfGK9B" Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 A64DF143874 for ; Thu, 16 May 2024 10:18:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715854698; cv=none; b=YGjVJWdxvV3/1bdicI8dUIRlbAJJYkk8oDEVEEqkXEehzYInik5b72hR7YD/yHfxZWfhCxw7ztvCBvnHsJCO4qwVYw/uAEw6NysLclm8f++rPVvaXw/T9B5ARDN5v8OEVquu/yVxs71T5735tRYT4kTq242tV0iR7HPhUZb0k+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715854698; c=relaxed/simple; bh=/g8E/M0prGmmgcgPZCaW0A7ShyGn2zDAARpOKjGFQyo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OuwYio+jcRM5gOWdOJJWeGkLvxTC7wtJuD808iDJI7oyd2GG7Vg4kwEP2Ly1JSPKJS1ASuhWp35uMeRXFhFg/psckWoq/4gJnf5uL7bzQ2YVt0JQVgUjRiHxK/wluThZMqHEottHADP3+Uq3vLMkie2zBIbBl5EyS8TJ3r6NlJI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch; spf=none smtp.mailfrom=ffwll.ch; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b=T6gfGK9B; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ffwll.ch Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4201033aeb4so7272235e9.3 for ; Thu, 16 May 2024 03:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; t=1715854695; x=1716459495; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=8TJDXJKaQUdW/2WF0Ge4iVoqYkhg+zWynHOclwI6BcY=; b=T6gfGK9Be9gQ/EHkLKIcki22nEipVxQQ0DqN+T5nK+nUqewlfZdePHmv7u49jAHs/h lo2GyiBUTr8Fr5DsvXyqM83dvPDJPYFf7CIrQ3clkj3TKveczfsw1/QIHuBJgihSiowk TZvYy/sM9ZBJw4cxSavlUSs2KfBcIV8S6R2qI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715854695; x=1716459495; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8TJDXJKaQUdW/2WF0Ge4iVoqYkhg+zWynHOclwI6BcY=; b=H7G01GffZIbYtqDzmCIjdTYC/n/MvTBZI+qXrvkczcDfyon3AdHGCNt7pEfVlwPK4S 5AP5hltaMVKQ7nY6cvlcvdk6hggIZylWTKWrZ+8RlSZZ7IF66XF/9/QakTpR2/Pm/+L9 jkMlQUDHZ65kE+Arw+xAgF9pbZiZCKiXRLPJwxgQNfIMxIj2APk1YkHHDy/vzJdZ/jgC +eCYmL2kNkSWlJo1IWGRVNPU1W0d8dUD9eTp2/gdg1+PLa+iMz27gZB97buVN4Ng8hbS PZwzqN9VAnjQ6BtCOBcvSX8mEmp8fPJXSnJC5+upQnj1t7TcV+12WaolkFg30tT93Qsp ctMw== X-Forwarded-Encrypted: i=1; AJvYcCX1W9mZcWgQwuttYJys4bKb/0IIU/BRiGT3Ycxx72Cqwla1igSiZKQT8wjMdlyY7j1qrw2LlYBaYpzeIrDcLOn/7glqv/qdqOwDwBli X-Gm-Message-State: AOJu0YwG7bOkUhEtOl+5auSg1ti3T/zdL3xLsYsgdXo5UH/BHPN4VHTx U7D/RKaSa7qDPLLQi00h3kXeZQyZO02TICR36IXYG1nT55gF0IlW9gY6GI4h8RA= X-Received: by 2002:a05:600c:5116:b0:418:ef65:4b11 with SMTP id 5b1f17b1804b1-41feac59e8amr154465585e9.2.1715854694962; Thu, 16 May 2024 03:18:14 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4201088fe8csm183349845e9.32.2024.05.16.03.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 03:18:14 -0700 (PDT) Date: Thu, 16 May 2024 12:18:12 +0200 From: Daniel Vetter To: Daniel Stone Cc: Hans de Goede , Maxime Ripard , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , Christian =?iso-8859-1?Q?K=F6nig?= , 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 , Bryan O'Donoghue , Milan Zamazal , Andrey Konovalov Subject: Re: Safety of opening up /dev/dma_heap/* to physically present users (udev uaccess tag) ? Message-ID: Mail-Followup-To: Daniel Stone , Hans de Goede , Maxime Ripard , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , Christian =?iso-8859-1?Q?K=F6nig?= , 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 , Bryan O'Donoghue , Milan Zamazal , Andrey Konovalov References: <20240506-dazzling-nippy-rhino-eabccd@houat> 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=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 6.6.15-amd64 On Thu, May 09, 2024 at 10:23:16AM +0100, Daniel Stone wrote: > Hi, > > On Wed, 8 May 2024 at 16:49, Daniel Vetter wrote: > > On Wed, May 08, 2024 at 09:38:33AM +0100, Daniel Stone wrote: > > > Right now, if your platform requires CMA for display, then the app > > > needs access to the GPU render node and the display node too, in order > > > to allocate buffers which the compositor can scan out directly. If it > > > only has access to the render nodes and not the display node, it won't > > > be able to allocate correctly, so its content will need a composition > > > pass, i.e. performance penalty for sandboxing. But if it can allocate > > > correctly, then hey, it can exhaust CMA just like heaps can. > > > > > > Personally I think we'd be better off just allowing access and > > > figuring out cgroups later. It's not like the OOM story is great > > > generally, and hey, you can get there with just render nodes ... > > > > Imo the right fix is to ask the compositor to allocate the buffers in this > > case, and then maybe have some kind of revoke/purge behaviour on these > > buffers. Compositor has an actual idea of who's a candidate for direct > > scanout after all, not the app. Or well at least force migrate the memory > > from cma to shmem. > > > > If you only whack cgroups on this issue you're still stuck in the world > > where either all apps together can ddos the display or no one can > > realistically direct scanout. > > Mmm, back to DRI2. I can't say I'm wildly enthused about that, not > least because a client using GPU/codec/etc for those buffers would > have to communicate its requirements (alignment etc) forward to the > compositor in order for the compositor to allocate for it. Obviously > passing the constraints etc around isn't a solved problem yet, but it > is at least contained down in clients rather than making it back and > forth between client and compositor. I don't think you need the compositor to allocate the buffer from the requirements, you only need a protocol that a) allocates a buffer of a given size from a given heap and b) has some kinda of revoke provisions so that the compositor can claw back the memory again when it needs it. > I'm extremely not-wild about the compositor migrating memory from CMA > to shmem behind the client's back, and tbh I'm not sure how that would > even work if the client has it pinned through whatever API it's > imported into. Other option is revoke on cma buffers that are allocated by clients, for the case the compositor needs it. > Anyway, like Laurent says, if we're deciding that heaps can't be used > by generic apps (unlike DRM/V4L2/etc), then we need gralloc. gralloc doesn't really fix this, it's just abstraction around how/where you allocate? Anyway the current plan is that we all pretend this issue of CMA allocated buffers don't exist and we let clients allocate without limits. Given that we don't even have cgroups to sort out the mess for anything else I wouldn't worry too much ... -Sima -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch