Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp858076imm; Fri, 3 Aug 2018 12:51:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeW2f6Tgh5fnIikxr0YuR2iF8Q42UGoflcjddj6GjljwqVyo7s8Vj+Qj/2xbZ9ihEA56ZF1 X-Received: by 2002:a63:5d09:: with SMTP id r9-v6mr5027806pgb.303.1533325890720; Fri, 03 Aug 2018 12:51:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533325890; cv=none; d=google.com; s=arc-20160816; b=l7ovC6gYsfyWmikBGoIV538RPHI63UqKULAzLYUlJn7T9CkTQFrLu45P6W7RGlo3fN hMyvgGconxxTXVoEOKVMfkJLUagP5N/hcZXPSPrLHf9eYW8ZWsIY26PZCpVXOfEGXp/a GmeIMasJ24X+J37H+db4Pj4Zr3eFfp5H4DBiTFuhXGOmISXuC0gfHRzN3W7Vkc0ETDo7 CfC21v/YPQ9QUCsXsaz8SJV192BUoTAF1nZfi7QaMUCMNCyvmMyqs3p3Q+zX19Ujoluy TFiCujVcBXsmsVAKKGZqaCV1Y/GGvpqHm/bJt4nwAu/DuOpmwd9jsw3dQsC4v07OPlSQ rp9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=/8eorP3SBVJgegrat/pBBkRyKnsxwNw2tVlTziNUwzA=; b=Tx5TG6O6T3YUx0h5WagSIXuVaydS5domJvplgT1ndtGVjwDb/xZcCK97R+uYWht8iO Fe+47Db45+s8F4ns7kZqIJTxMdgfqkIOJYRRX6Ueq3l6D4fKAN4VhuVHg9ZmeSogd6Pn eTSh2AyyPgsVBvTCcebA8yFapwJOHg5AcGkt4Bm9I+10AoI3MCkh2Ers3JaJLP/c1kBT R7k4Pp4eI/0YGD/Wjnfpik16/u7XfurXj2G090zeq5ZdE53IdQWZWAumHVMzpCbLS7Ja KKWuySTru0THP4UVeixQSQ4kJZ54Q0CtehEH3+mwQ0cihAwHzFGBb+LWpczQLeGXKJ/S yvPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mGzO3pMr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4-v6si6064152pgl.9.2018.08.03.12.51.15; Fri, 03 Aug 2018 12:51:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mGzO3pMr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731969AbeHCVsK (ORCPT + 99 others); Fri, 3 Aug 2018 17:48:10 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:39260 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728470AbeHCVsJ (ORCPT ); Fri, 3 Aug 2018 17:48:09 -0400 Received: by mail-yw1-f66.google.com with SMTP id r184-v6so1404335ywg.6 for ; Fri, 03 Aug 2018 12:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/8eorP3SBVJgegrat/pBBkRyKnsxwNw2tVlTziNUwzA=; b=mGzO3pMriJtX+H4GhrFGf9l6KbVr6v4UcbosbBele8EsBgNBb/TpYoE5iQlzM2wBde +CIUSZxCPyQ8yBhCrRgHDuwqrZlI+oUlQKf/3n0d15JcoWB8JjjbvKKgn6aXdomGt6+X 3H5kffqe4XBd8RUS/oRhKRwKOrMIfaljwqev4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/8eorP3SBVJgegrat/pBBkRyKnsxwNw2tVlTziNUwzA=; b=UwHoDzi+q/ejI5dFLg9eX6J18HZG5dtPBzLTJqtMTpcs5o0tFPR1uGi4a0g/0zaRM7 hlGpfqgNQWP1xXJxfU/1m1NB6VrOtwiT4JqyKT6tOKTAvyy1jYz0hYxkyGFgK/9TLcy7 4/4yB5MyYJSXw/JbD0EAkOJBSYqJOwSnY/9rbjdcPmJnBra+yrlShauKDbNohlFjr1g7 j2wmmrrkk79RCLHetVf1Dvaf71qLw9USouFXQrsyehoPK8GHKbb0vbWoYLlfNnGTWE82 Suuh9QzjlsITPTh6UO8qh5TsIV9ggdkuP/5wumXzn9ZKTX2uufjtx8rlFE4Ux50MKqgU Psdw== X-Gm-Message-State: AOUpUlHzKfYTrwIeY2X2M1z8lcwJsApLO4wA1aUmQ44yOHN0Z7zK0956 h6s9/pi5YJNYEf1VU14KZiW5xA== X-Received: by 2002:a0d:e044:: with SMTP id j65-v6mr841699ywe.202.1533325826432; Fri, 03 Aug 2018 12:50:26 -0700 (PDT) Received: from localhost ([2620:0:1013:11:ad55:b1db:adfe:3b9f]) by smtp.gmail.com with ESMTPSA id r3-v6sm3547016ywr.80.2018.08.03.12.50.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Aug 2018 12:50:25 -0700 (PDT) Date: Fri, 3 Aug 2018 15:50:25 -0400 From: Sean Paul To: Emil Velikov Cc: Martin Fuzzey , Robert Foss , David Airlie , Brian Paul , ML dri-devel , Eric Engestrom , Gustavo Padovan , "Linux-Kernel@Vger. Kernel. Org" , Maarten Lankhorst , Nicolas Norvez , Rob Herring , Sean Paul , Tomasz Figa , Tomeu Vizoso Subject: Re: [RFC] drm: Allow DRM_IOCTL_MODE_MAP_DUMB for render nodes Message-ID: <20180803195025.GO20303@art_vandelay> References: <20180724082213.25677-1-robert.foss@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 03, 2018 at 06:03:50PM +0100, Emil Velikov wrote: > On 3 August 2018 at 16:06, Martin Fuzzey wrote: > > Hi Emil, > > > > On 03/08/18 14:35, Emil Velikov wrote: > >> > >> Hi Martin, > >> > >> On 1 August 2018 at 15:24, Martin Fuzzey > >> wrote: > >> > >> Let's start with the not-so obvious question: > >> Why does one open the imx as render node? > >> > >> Of the top of my head: > >> There is nothing in egl/android that should require an authenticated > >> device. > >> Hence, using a card node should be fine - the etnaviv code opens the > >> render node it needs. > > > > > > Yes, the problem is not in egl/android but in the scanout buffer allocation > > code. > > > > etnaviv opens the render node on the *GPU* (for submitting GPU commands), > > that part is fine. > > > > But scanout buffers need to be allocated from imx-drm not etnaviv. > > > > This done by renderonly_create_kms_dumb_buffer_for_resource() > > [src/gallium/auxiliary/renderonly/renderonly.c] > > Which uses DRM_IOCTL_MODE_CREATE_DUMB followed by > > DRM_IOCTL_PRIME_FD_TO_HANDLE > > on the "kms_fd" (probably poorly named because it's not actually used for > > modesetting) > > see imx_drm_screen_create()[ src/gallium/winsys/imx/drm/imx_drm_winsys.c] > > > > > > If the card node is used DRM_IOCTL_MODE_CREATE_DUMB works but > > DRM_IOCTL_PRIME_FD_TO_HANDLE fails, because the permissions are > > DRM_AUTH|DRM_UNLOCKED|DRM_RENDER_ALLOW > > > Right I missed the DRM_AUTH, in the fd <> handle IOCTLs. > So in order for things to work, we'd need to either: > - allow dumb buffers for render nodes, or > - drop the DRM_AUTH for fd <> handle imports > > Pointing an alternative solution, for kernel developers to analyse and > make a decision. > > > > > In android 8.1 the hardware composer runs in a seperate process and it has > > to use the card node and be drm master (to use the KMS API), > > therefore, when the surface flinger calls > > renderonly_create_kms_dumb_buffer_for_resource() it is not authenticated. > > > > Making surface flinger use a render node fixes the problem for > > DRM_IOCTL_PRIME_FD_TO_HANDLE (because that already has DRM_RENDER_ALLOW), > > but DRM_IOCTL_MODE_CREATE_DUMB now fails without the patch. > > > > > > This probably worked in previous versions of Android where surface flinger > > and hwc were all in the same process. > > > There has been varying hacks for Android through the years. Bringing > details into the discussion will result in a significant diversion. > Something we could avoid, for the time being ;-) Did someone say diversion?!? The way this was handled prior to using render/control nodes in drm_hwc/[drm/gbm]_gralloc is that all modesetting was done via gralloc which was master. The hwc implementation was basically a proxy backchanneling all of the work to gralloc. Anyways, we probably don't want to go back there. Fwiw, I'd lean towards allowing DUMB allocation from the render nodes. I understand it limits use cases that are undesirable, but it is also limiting usecases that are desirable. So, given that people are going to get "creative" regardless of how many safety railings we put up, we shouldn't make things unnecessarily hard on other trying to Get Work Done. Sean [Disclaimer: I'm totally and completely biased on this issue] > > Thanks > Emil -- Sean Paul, Software Engineer, Google / Chromium OS