From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51265C10F13 for ; Tue, 16 Apr 2019 07:52:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 204AD2073F for ; Tue, 16 Apr 2019 07:52:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qulBkaEB"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="UhzC1yDY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 204AD2073F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KwObvzKhMI/3JFPG9JnGo2LmtkGQLI/kGjlUO0+tZao=; b=qulBkaEBZCfPIp +lFmRghFzTp0LFPwzrZcqAE2F79QJVbz8JGL5lBbP/pdG7yjj1vbH1FXYbYaWJ58URN7DJAyjn4kt DpZEn+A9DIhxMWiTJPL+ngK5hh42Xk9JCVKr8lURXYViE1yCQBOpic+lXvI94nIyE1CMUAudNkTGz 6bGZgjjQVT4esr+BtSZa1a5H/LPvPGfy9Fq08kENiOGnaV5oipwI3kfRqkXHlvFmWsIbdwKvdlK7R 0PP8doeWTRMUjq8MRY7FiXossy3+WJyTxxmkgwYxXCIrdTxPqCNX01IQGjFbxXSm4EDCUQcdjCRnQ SczNg5cM4G1l3ejgToiA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGIso-0001xK-US; Tue, 16 Apr 2019 07:51:58 +0000 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGIsl-0001wz-IQ for linux-arm-kernel@lists.infradead.org; Tue, 16 Apr 2019 07:51:57 +0000 Received: by mail-ed1-x542.google.com with SMTP id j20so6817697edq.10 for ; Tue, 16 Apr 2019 00:51:55 -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=fwcMJBtUAGFkT7pNJNe5R7Z6E/D4MYot712OuhMecOLTfGsZgdvWXKWFgKvjt2gWOI 5jUggSyAkCKM/idOyJ7en89Iv9X/CusjNkFYvyDexxSutEFG1fa3mEvrIt8JnjLOy8yc OW9J5Qm8OPa3/mZ4Xcn/HfcMsRQUWyxKjpynhIN+Zp8r3wx5oXBgV/TImOhH18XjYQ5U ljoKHznkrYAcds4HK3HJJEbGQTBwPJc8v9KVT1wBCxAh2Of9POdmkP9u4b6KFA6QcKjY Ku+EESI3A4XSPAr5kSOVHDWvOpG2q5L+YzesoTPaLGSUR34eAgoZy1PNs2CcjKAzbaC6 BF2A== X-Gm-Message-State: APjAAAUKP8m2T9J+SYOVRcpAH8MlyN4uYGdd/gotdvGb/+rvZzVFj5+m PEJ5GLLiaBpD3Mi9uMdx1gK9Mw== X-Google-Smtp-Source: APXvYqzoSwwi6rPH/PPCvDSqoisNzF/DHHX2I6RV70LEoyCtIw8qyy8v7xd+Cq1ZmB0cbJ+Y9PeCCw== 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 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-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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190416_005155_616058_2B852B8A X-CRM114-Status: GOOD ( 25.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomeu Vizoso , Neil Armstrong , Maxime Ripard , Robin Murphy , Will Deacon , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, David Airlie , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, "Marty E . Plummer" , Sean Paul , Alyssa Rosenzweig Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel