Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3935687imm; Mon, 6 Aug 2018 13:19:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcHEKpKU2yHAjXHmu6NSwmkK98JxubXx6bbPUC/ZPVA/84OJVZhPkK85hFwqJjZftWWVUvV X-Received: by 2002:a62:129a:: with SMTP id 26-v6mr18563917pfs.102.1533586772003; Mon, 06 Aug 2018 13:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533586771; cv=none; d=google.com; s=arc-20160816; b=PPJ0uffcOSvbWF1nXU3zqPwssabbEtR3b8ycdEzBsUP+h3SSClR6NE0cPBZ4SG0+8y m/J2mM2SIDgxMgJ0+f5gO6m/kiGF+5nsPkE17L9/asqMWhpzA2V6qruZHiqjylWhA+sB uQRmtbHgzCwaIr1jtEfviHRjTg3kykaPeluQp9GEKKP0dSJceh54hKwtOIvN8s+W9iYf EbMRJCG7hIEB7KaIDELgEMPUApXJU7YWE2Pb3/j8DbYahRBARIp5zos9qdJfSGiwdEIV B2ZjU43aVIfIaLIXw1/miaPCQzPHg/7LV9Xb5vtGlOZRiRhqnp38OqYmQPm1UXbFRNIe RI3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=iKXRsAWIGK3MoowsiZoKf6ktZOrW5MtqVu7LGBrLTiE=; b=b49YZLrgw/yHgDvcwLRN1Msl4UuYaaANqVr6w8K8tPmdZT61xgCUiFKc2VtHPUZ8MA 3UaEXXfbDdTu1grG0BVb0PE3JdpOWtVn0z6L48SAfRx6ifJTR5U6pGmhGkZvMFPnPooS 77LA1XeuGGhY5CQxA2qEGJWDm5yYDZ2orot6kpYw79BPhAnxd86xvvH+ZSqn7sbBWbLC E1xNfztxB5lN6Jj6KGscX9XKknU3UGA4jUhtRqLoukM718Qs1OsRNfTO0Om8JKee8VCB RRTqUrukumdB2TzWB/u9qGbeleh4tplLmPguYfIQWeq6HPXpZ+uAuoX2YQCAGHYLwjk7 b+Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=skapDPhE; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7-v6si11081656pgp.411.2018.08.06.13.19.16; Mon, 06 Aug 2018 13:19:31 -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=@kernel.org header.s=default header.b=skapDPhE; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732746AbeHFVPq (ORCPT + 99 others); Mon, 6 Aug 2018 17:15:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:54900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732394AbeHFVPq (ORCPT ); Mon, 6 Aug 2018 17:15:46 -0400 Received: from mail-qk0-f169.google.com (mail-qk0-f169.google.com [209.85.220.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9A1E121A5D for ; Mon, 6 Aug 2018 19:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533582317; bh=LSYwrDwf6K3+2HGSQ0Dc9tOBuAAWJEy4A5ViN/os+eQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=skapDPhEZxWKBykIGIgpjKZhFcQW0SYDtFZWUPSGAFgl+0bF3/0ZQeGrw7mdi9Lt4 O2y1M9Ze18OufdOau3atswlz2omDRQmhqWioSuhoI1+D+7HYf0WGUivn1aexACs5MZ YQc9gD7x/kHFybUFXmUFpqPhT7m4DpiB1SIV1MsM= Received: by mail-qk0-f169.google.com with SMTP id z74-v6so9692236qkb.10 for ; Mon, 06 Aug 2018 12:05:17 -0700 (PDT) X-Gm-Message-State: AOUpUlEYUO9JQ8Zshak/6ut7QU2bfB/vE9lWM3w58xC/b6T8SW1IN7ic ilF+MPtlLZEGh8ifK3SZdtPxC9ll0Jr7MaCvQQ== X-Received: by 2002:a37:ab14:: with SMTP id u20-v6mr14303409qke.120.1533582316717; Mon, 06 Aug 2018 12:05:16 -0700 (PDT) MIME-Version: 1.0 References: <20180724082213.25677-1-robert.foss@collabora.com> <20180803195025.GO20303@art_vandelay> In-Reply-To: <20180803195025.GO20303@art_vandelay> From: Rob Herring Date: Mon, 6 Aug 2018 13:05:05 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC] drm: Allow DRM_IOCTL_MODE_MAP_DUMB for render nodes To: Sean Paul Cc: Emil Velikov , martin.fuzzey@flowbird.group, Robert Foss , David Airlie , Brian Paul , dri-devel , eric.engestrom@intel.com, Gustavo Padovan , "linux-kernel@vger.kernel.org" , Maarten Lankhorst , norvez@chromium.org, Tomasz Figa , Tomeu Vizoso Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 3, 2018 at 1:50 PM Sean Paul wrote: > > 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. The problem with using render nodes is what if there isn't one? We require VGEM (and make VGEM allow dumb buffers) in that case? Rob