Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp704476imm; Fri, 3 Aug 2018 10:05:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdXA9FtB3/HlQwkazRM1AljilcMd3Cp/EwdhvCPOaxL8QcXN4d2HAPDsnt74q82DaaL/0jO X-Received: by 2002:a63:8e41:: with SMTP id k62-v6mr4500982pge.187.1533315906795; Fri, 03 Aug 2018 10:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533315906; cv=none; d=google.com; s=arc-20160816; b=Dfi8FtEp0+fBQBbr8bRIIVqnB/PdyMYBObK/EAnS/77r+F37y3deuq11wWMkAZBtKD dxaHQtDHeJz9OkCqaLf+9DKE1Hc3egS9dZax1bCCa56X/+bEWKQCNPN0GXbYoGUy4jqS tEt82CM/s4AN04zSNologcJFy23y39awcmRxEOXlPZIP6YO5tcr4xXDhbyx370W0B6/R lA3T3U5JbXRupSX2zosRy7A3P4ihVqnBc0k9bGdLGInatviCR2dg0HvAs/Ubn7X8SLn4 J2veFLJitd/xgfTxGf2HqSSHBGKZlauQ+1OMs8hqJrM/8r7vaoZM0Z92igkjkXe6P6/G CMNQ== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=34oHgtuMXg+nXOkIyKByaSY+iRDDxhenRKBQzKu2ooo=; b=mKhGjg79dOkSll3T6p4TGVcZRqPoBkNvVNymc2673arg/LTRO6BED4J2gLvIvCkrsd eJ9rDTfcbF5mvRZtG+ipld/DiW00qd+wQiAQeh6Y6m/6ENFXWjJRZpjBsB2rdBLcQsM4 6jtSYIswX1F0Xcqrk3uE8BQLXi8VhT2Q5M4ZmNH5A5muFnH7MCdpSbEiDuwla3821W+D 9GK5h4BQtd3R46g9uLCZKTOqrwzqwPvB6Q2QULWcTETm5SfLUKelMDLEzR0nPdWtp06C QYnrKHDBj9rImjVGtVpmmYXeuGDD93ZKs72dIRkGkmTqS2NK1nxitoQWz3woL0MTjJYx dN/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Segw7ZRT; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b76-v6si5544958pfl.223.2018.08.03.10.04.51; Fri, 03 Aug 2018 10:05:06 -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=@gmail.com header.s=20161025 header.b=Segw7ZRT; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728023AbeHCTBB (ORCPT + 99 others); Fri, 3 Aug 2018 15:01:01 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39942 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727171AbeHCTBB (ORCPT ); Fri, 3 Aug 2018 15:01:01 -0400 Received: by mail-wr1-f68.google.com with SMTP id h15-v6so6026852wrs.7 for ; Fri, 03 Aug 2018 10:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=34oHgtuMXg+nXOkIyKByaSY+iRDDxhenRKBQzKu2ooo=; b=Segw7ZRTvKDlhOaUWBkvOxCXYXBd5CVlK+Ux73DCmw9X250WEjoJcKbBlJ9eNzeZcF 1pzP/RXtVbPQ5kemu5hX0boKPPc3pOPqS0amtyHQbzk/58uTW+uxn1a1OTvufOfzd6sC 8EPRpuKipMov0SMK/OWgShET7Bg/UUNLQnuIqbIwBE3pH5evI3dmt2nvaIg9HA8IYpbO n6KDohzpgoYdATttwdJg/d2Rbmzu3tCvzXM17Lr6nzDc7f0Zdpgub5IfkXnE9Q9M/fUM R+hz6KHa6pA1OIKX3BxCI+xHllQeQDjQ10ckxEIKbcK95vWc2g1C5ZrGc1qgKNjAZWjX jQNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=34oHgtuMXg+nXOkIyKByaSY+iRDDxhenRKBQzKu2ooo=; b=A66582JgwGqJAbXF9X8EfhFJZV6CX85jOs/PtfwQXhnWlPCXspzG5sm3xUgHIMLZE/ FrxNVJYddpwHqb4LJvkqWziZxlxV5ldeu0u/gS74vx9FHqmLrI1nLT5ZyZzUNPH3GWFL z34SN0kIYWLsCgqVly1fgEJjwTd4Qo9+w/WIPPM5cqEdvM9jXASq/YFFIC6Atyhvdqhn qaZrxeERsaOqqsZWaJHUtHobhcV4vWapOsZWgASlHiaAdXlXt/vv0HxdAQg2EB8YWj9v dqZZXC4EGju9CZfmbfraeiquYMsi1g/1OrEgpdm+IdFvDv1KBX7Vl9qTDTJBfVbqaWwy oF5Q== X-Gm-Message-State: AOUpUlEtmTasWZzQ9vwb8tNhPKagbUZrXr+2UznhBMVcM+m7R+lRK0G8 GgoV1FkTxXlZ6hBUlCwMpw6YzZaaTa2IwyRrGfs= X-Received: by 2002:adf:ffc7:: with SMTP id x7-v6mr3234798wrs.137.1533315831117; Fri, 03 Aug 2018 10:03:51 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:178a:0:0:0:0:0 with HTTP; Fri, 3 Aug 2018 10:03:50 -0700 (PDT) In-Reply-To: References: <20180724082213.25677-1-robert.foss@collabora.com> From: Emil Velikov Date: Fri, 3 Aug 2018 18:03:50 +0100 Message-ID: Subject: Re: [RFC] drm: Allow DRM_IOCTL_MODE_MAP_DUMB for render nodes To: Martin Fuzzey Cc: 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 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 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 ;-) Thanks Emil