Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2938784yba; Tue, 16 Apr 2019 00:54:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqza+1qm+tRs8llMJshdGqhrAvrVWbHJpUs04s2o0ykPso2xp1jp1q+yDN0mLBw8v3JV6PnD X-Received: by 2002:a17:902:106:: with SMTP id 6mr37455895plb.98.1555401250034; Tue, 16 Apr 2019 00:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555401250; cv=none; d=google.com; s=arc-20160816; b=kz9NIiOBc7Q4/69Cb7kCvyM9PxIVGmTDWPE3GILA1W0SLmwr3heKaBGOMIB+MfYWYg xXHoyAqPUdJK9egar3sIdHcjc8j3hA6t1ZKfhv4pwJvo5ugl3CzIv7yIl5gJ0pHXQRY1 3H/8lC+o87WdFB/b7ZCep5WlAJxAw7YZJtM464TgGya9VQ9Ei5HEkJRW/9cMGKWqoJz2 8pHUEOf2+U5/9eYQuehfbsWdARffMOavt5yH6DZsD4/Qbr7HUlGnwWsTxuMq+MpQyPkQ 8s7KwOEZDWm6C8RIfEk9etZiBnvw7pB+G6narV7XpJHHssrhrIJ38ub5w5GbS+PjLcjU NA/g== 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:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=7jNtxv9e+QWoL+nxsHxcU+XebVLgfgg8ZHSaQ6Ck++w=; b=sLzr+UU6SHg9YWdBWfL8qzJ+oeDqjbMou06xxPen22bGaaar7ySUdi7tlW71hb6a7K TCnm0oSdbHIcnjVD32aiCrHVQZYiZiMF3Bm7hzptw6kunTVvDMAjysZD81VoHu5210sy DZ+3IljRk1NAikSXAftPYmAmukG+SK4N8lBl7NWV+b+Xq9LiHHQ236oZOizRqdEA79kT mTx2BuWDxEMghNk6YWdZ8yzVzVksj47XPSKw4JHhJsdyRUkch6zeE1s0vgt/BjKd3KH/ bJ+Bo/x1sYKgiQOtp1CcZU8lQRfhGjmoPTEaOi+AS3gAmvgUpffskL7PZEIvw9mKtYg8 tVfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=UhzC1yDY; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14si17741615pfa.102.2019.04.16.00.53.52; Tue, 16 Apr 2019 00:54:10 -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=fail header.i=@ffwll.ch header.s=google header.b=UhzC1yDY; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728445AbfDPHv4 (ORCPT + 99 others); Tue, 16 Apr 2019 03:51:56 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:34515 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726895AbfDPHv4 (ORCPT ); Tue, 16 Apr 2019 03:51:56 -0400 Received: by mail-ed1-f65.google.com with SMTP id a6so5784193edv.1 for ; Tue, 16 Apr 2019 00:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=7jNtxv9e+QWoL+nxsHxcU+XebVLgfgg8ZHSaQ6Ck++w=; b=UhzC1yDYtTlCTl7bwfr1Tz54WT4eoHBS/L0B1C+TRgkAHxGlqANxQ7YAh+fH5hXT2Q YL9tZTVnXzC6a+5X2oxpwDXT1fhrwVJebqBswSFv44+ehMkF7TJWO7lXM01GZiztW7j1 a5JcnO3sCQh6yXLDLZmPHbumdioRC6hsGzRsQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=7jNtxv9e+QWoL+nxsHxcU+XebVLgfgg8ZHSaQ6Ck++w=; b=PwpfGHeYI+Hw9RJqzGAUVGBBZqqzbxJG7MS/9rYwvn6tIwS8kGBt0HRWkq3b1aWXGy 4NZixtMJab5pTuCV+ToqHPfjKi7X5KfbPQMBDBaF0mz9qWtxjLL5Abab+SVcQ/FnsSWK VEcSpJY0bHAVM2Z3vbdYfQZTjNuAHVVWMfKEREY/pdDYpwJT5pBxehPJRjcNBVYwM61g GawxqV4HDNk4xfesJfCdu5V53lkae2CP+366+OG2lIgjFYtBtPVC4goZLIeJy/iY+IT6 91Rv2/oTNDv0f+/Z62ZRG7ZH9qTVwBjGR9D5ZeVzTpIGNGyU9BgKG3kQuMupzs0q4LyE uOBg== X-Gm-Message-State: APjAAAURSZ2vNiDyLKavwT8H4GUgfBnyIjmHXqfvx22hoo34Wa/G7AS9 rh5l5JalnYrJc/VPb+QOJi35sw== X-Received: by 2002:a17:906:d1d9:: with SMTP id bs25mr18325308ejb.213.1555401113741; Tue, 16 Apr 2019 00:51:53 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:569e:0:3106:d637:d723:e855]) by smtp.gmail.com with ESMTPSA id ga13sm9500506ejb.9.2019.04.16.00.51.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Apr 2019 00:51:52 -0700 (PDT) Date: Tue, 16 Apr 2019 09:51:50 +0200 From: Daniel Vetter To: Steven Price Cc: Alyssa Rosenzweig , Tomeu Vizoso , Neil Armstrong , Maxime Ripard , Sean Paul , Will Deacon , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, David Airlie , iommu@lists.linux-foundation.org, "Marty E . Plummer" , Robin Murphy , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 3/3] drm/panfrost: Add initial panfrost driver Message-ID: <20190416075150.GR2665@phenom.ffwll.local> Mail-Followup-To: Steven Price , Alyssa Rosenzweig , Tomeu Vizoso , Neil Armstrong , Maxime Ripard , Sean Paul , Will Deacon , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, David Airlie , iommu@lists.linux-foundation.org, "Marty E . Plummer" , Robin Murphy , linux-arm-kernel@lists.infradead.org References: <20190401074730.12241-1-robh@kernel.org> <20190401074730.12241-4-robh@kernel.org> <5efdc3cb-7367-65e1-d1bf-14051db5da10@arm.com> <20190405161632.GA9160@rosenzweig.io> <34a7038e-34f0-0cc4-4fc4-9b7dda356df6@arm.com> <20190415091837.GV2665@phenom.ffwll.local> <50682635-4134-f36b-dcb0-2a4d98eedb3c@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50682635-4134-f36b-dcb0-2a4d98eedb3c@arm.com> X-Operating-System: Linux phenom 4.19.0-1-amd64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 15, 2019 at 10:30:14AM +0100, Steven Price wrote: > On 15/04/2019 10:18, Daniel Vetter wrote: > > On Fri, Apr 05, 2019 at 05:42:33PM +0100, Steven Price wrote: > >> On 05/04/2019 17:16, Alyssa Rosenzweig wrote: > >>> acronym once ever and have it as a "??"), I'm not sure how to respond to > >>> that... We don't know how to allocate memory for the GPU-internal data > >>> structures (the tiler heap, for instance, but also a few others I've > >>> just named "misc_0" and "scratchpad" -- guessing one of those is for > >>> "TLS"). With kbase, I took the worst-case strategy of allocating > >>> gigantic chunks on startup with tiny commit counts and GROW_ON_GPF set. > >>> With the new driver, well, our memory consumption is scary since > >>> implementing GROW_ON_GPF in an upstream-friendly way is a bit more work > >>> and isn't expected to hit the 5.2 window. > >> > >> Yes GROW_ON_GPF is pretty much required for the tiler heap - it's not > >> (reasonably) possible to determine how big it should be. The Arm user > >> space driver does the same approach (tiny commit count, but allow it to > >> grow). > > > > Jumping in here with a drive through comment ... > > > > Growing gem bo and dma-buf is going to be endless amounts of fun, since we > > hard-coded that their size is invariant. > > > > I think the only reasonable way to implement this is if you allocate a > > really huge bo, map it, but only put the pages in on faulting. Or when > > really evil userspace tries to export it. Actually changing the underlying > > buffer size is not going to work I think. > > Yes the idea is that you allocate a large amount of virtual address > space, but only put a few physical pages in. If the GPU needs more you > fault them in as necessary. The "buffer size" (i.e. virtual address > region) never changes size. > > > Note: I didn't read kbase, so might be totally wrong in how GROW_ON_GPF > > works. > > For kbase we simply don't support exporting this type of memory, and are > fairly restrictive about mapping it into user space (user space > shouldn't normally need to read it). You can still disallow sharing with any other driver (in the dma-buf attach callback), and then enforce whatever mapping restrictions you want on the panfrost.ko ioctl interface. That should be roughly equivalent to the restrictions kbase imposes. > > Since Panfrost is using GEM BO it will have to deal with malicious user > space. But it would be sufficient to simply fully back the region in > that case. > > Recent version of kbase also support what is termed JIT (Just In Time > memory allocation). Basically this involves the kernel driver > allocating/freeing memory regions just before the job is loaded onto the > GPU. These regions might also be GROW_ON_GPF. The intention is that when > there isn't memory pressure these regions can be kept between jobs, but > under memory pressure they can be discarded and recreated if they turn > out to be needed again. > > Given the differences between the Panfrost and the proprietary user > space I'm not sure exactly what form this will need to be for Panfrost, > but Vulkan makes memory management "more interesting"! Allocating > upfront for the worst case can become prohibitively expensive. The usual way to do that is with a WONTNEED/WILLNEED madvise ioctl on the gem bo. I guess that could also be set at create time to essentially only require the bo to exist during an execbuf call. Should fit pretty well into what other drivers are doing with gem shmem already I think. ofc needs a shrinker to be able to reap these bo. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch