From patchwork Wed Feb 6 13:14:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Yu X-Patchwork-Id: 10799375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B37FA6C2 for ; Wed, 6 Feb 2019 13:16:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0EE62A86B for ; Wed, 6 Feb 2019 13:16:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 932782AA5C; Wed, 6 Feb 2019 13:16:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1340B2A86B for ; Wed, 6 Feb 2019 13:16:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 693E16E956; Wed, 6 Feb 2019 13:16:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id ED48D6E951; Wed, 6 Feb 2019 13:16:06 +0000 (UTC) Received: by mail-pg1-x542.google.com with SMTP id z11so2891378pgu.0; Wed, 06 Feb 2019 05:16:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LcGQpI4ZjzX5I8xT8/PpVkSGRE7dlG2wR9TX9yZDDHY=; b=M77gegdW+FYbq/+JrtNBJimHUC/6090pEy3Em3NznQcUvtlmA9NC1rhDLubN2bLz38 MfcmmUUc+nkJOLREqNjPQ+7PwlGBHs4UZH4qaiTtz4kviBHhMd9Spci0xb9doARsGvbO dg6lcb6G5nXcW8XGlweGQp9YRr1Bfj+n3xzxG8uSlw9jzCN9ryaBv4QOvun6YCiJpQbi lac/VTCj0c6mHQQGZVQWVemkTHmROEiVqhSvfQayb7plKmqswa3mMZTKvPM+MhvIRPbK U+1LfEBUcOObi+pDOE+tcFx2of+LBWH0njj0LpXYLEsBimsMEQ26fUxTz8oK6rJnEcbC NeMg== X-Gm-Message-State: AHQUAuY+qzf+Fm5tmgfpptundAhcFX1Yy150PQCsN0F2zSTRwrb1p46H etgbiZ8NuTRgiRKCSDZQ51E+o7dp1cw= X-Google-Smtp-Source: AHgI3IbrY1VjVeJ4oqxshD96YUjyLZAM9wuoqUIKhGBoVVwrZo6Q7FGKE5TF1dfeRqii8Ai8oRjJrQ== X-Received: by 2002:a62:8a57:: with SMTP id y84mr10393187pfd.197.1549458966282; Wed, 06 Feb 2019 05:16:06 -0800 (PST) Received: from localhost.localdomain ([150.109.119.235]) by smtp.gmail.com with ESMTPSA id 125sm10040838pfd.124.2019.02.06.05.16.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Feb 2019 05:16:05 -0800 (PST) From: Qiang Yu To: dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org Subject: [PATCH 0/2] Lima DRM driver Date: Wed, 6 Feb 2019 21:14:55 +0800 Message-Id: <20190206131457.1072-1-yuq825@gmail.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , Simon Shields , Andreas Baierl , Maxime Ripard , Neil Armstrong , Vasily Khoruzhick , David Airlie , Qiang Yu , Sean Paul , Erico Nunes MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Kernel DRM driver for ARM Mali 400/450 GPUs. Since last RFC, all feedback has been addressed. Most Mali DTS changes are already upstreamed by SoC maintainers. The kernel driver and user-kernel interface are quite stable for several months, so I think it's ready to be upstreamed. This implementation mainly take amdgpu DRM driver as reference. - Mali 4xx GPUs have two kinds of processors GP and PP. GP is for OpenGL vertex shader processing and PP is for fragment shader processing. Each processor has its own MMU so prcessors work in virtual address space. - There's only one GP but multiple PP (max 4 for mali 400 and 8 for mali 450) in the same mali 4xx GPU. All PPs are grouped togather to handle a single fragment shader task divided by FB output tiled pixels. Mali 400 user space driver is responsible for assign target tiled pixels to each PP, but mali 450 has a HW module called DLBU to dynamically balance each PP's load. - User space driver allocate buffer object and map into GPU virtual address space, upload command stream and draw data with CPU mmap of the buffer object, then submit task to GP/PP with a register frame indicating where is the command stream and misc settings. - There's no command stream validation/relocation due to each user process has its own GPU virtual address space. GP/PP's MMU switch virtual address space before running two tasks from different user process. Error or evil user space code just get MMU fault or GP/PP error IRQ, then the HW/SW will be recovered. - Use TTM as MM. TTM_PL_TT type memory is used as the content of lima buffer object which is allocated from TTM page pool. all lima buffer object gets pinned with TTM_PL_FLAG_NO_EVICT when allocation, so there's no buffer eviction and swap for now. - Use drm_sched for GPU task schedule. Each OpenGL context should have a lima context object in the kernel to distinguish tasks from different user. drm_sched gets task from each lima context in a fair way. This patch serial is based on 5.0-rc5 and squash all the commits. For whole history of this driver's development, see: https://gitlab.freedesktop.org/lima/linux/commits/lima-5.0-rc5 https://gitlab.freedesktop.org/lima/linux/commits/lima-4.17-rc4 Mesa driver is still in development and not ready for daily usage, but can run some simple tests like kmscube and glamrk2, and some single full screen application like kodi-gbm, see: https://gitlab.freedesktop.org/lima/mesa [rfc] https://lists.freedesktop.org/archives/dri-devel/2018-May/177314.html Lima Project Developers (1): drm/lima: driver for ARM Mali4xx GPUs Qiang Yu (1): drm/fourcc: add ARM tiled format modifier drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/lima/Kconfig | 10 + drivers/gpu/drm/lima/Makefile | 22 ++ drivers/gpu/drm/lima/lima_bcast.c | 46 +++ drivers/gpu/drm/lima/lima_bcast.h | 14 + drivers/gpu/drm/lima/lima_ctx.c | 124 +++++++ drivers/gpu/drm/lima/lima_ctx.h | 33 ++ drivers/gpu/drm/lima/lima_device.c | 384 ++++++++++++++++++++ drivers/gpu/drm/lima/lima_device.h | 116 ++++++ drivers/gpu/drm/lima/lima_dlbu.c | 56 +++ drivers/gpu/drm/lima/lima_dlbu.h | 18 + drivers/gpu/drm/lima/lima_drv.c | 459 ++++++++++++++++++++++++ drivers/gpu/drm/lima/lima_drv.h | 59 ++++ drivers/gpu/drm/lima/lima_gem.c | 485 +++++++++++++++++++++++++ drivers/gpu/drm/lima/lima_gem.h | 25 ++ drivers/gpu/drm/lima/lima_gem_prime.c | 144 ++++++++ drivers/gpu/drm/lima/lima_gem_prime.h | 18 + drivers/gpu/drm/lima/lima_gp.c | 280 +++++++++++++++ drivers/gpu/drm/lima/lima_gp.h | 16 + drivers/gpu/drm/lima/lima_l2_cache.c | 79 +++++ drivers/gpu/drm/lima/lima_l2_cache.h | 14 + drivers/gpu/drm/lima/lima_mmu.c | 135 +++++++ drivers/gpu/drm/lima/lima_mmu.h | 16 + drivers/gpu/drm/lima/lima_object.c | 103 ++++++ drivers/gpu/drm/lima/lima_object.h | 72 ++++ drivers/gpu/drm/lima/lima_pmu.c | 61 ++++ drivers/gpu/drm/lima/lima_pmu.h | 12 + drivers/gpu/drm/lima/lima_pp.c | 419 ++++++++++++++++++++++ drivers/gpu/drm/lima/lima_pp.h | 19 + drivers/gpu/drm/lima/lima_regs.h | 298 ++++++++++++++++ drivers/gpu/drm/lima/lima_sched.c | 486 ++++++++++++++++++++++++++ drivers/gpu/drm/lima/lima_sched.h | 108 ++++++ drivers/gpu/drm/lima/lima_ttm.c | 319 +++++++++++++++++ drivers/gpu/drm/lima/lima_ttm.h | 24 ++ drivers/gpu/drm/lima/lima_vm.c | 354 +++++++++++++++++++ drivers/gpu/drm/lima/lima_vm.h | 59 ++++ include/uapi/drm/drm_fourcc.h | 9 + include/uapi/drm/lima_drm.h | 193 ++++++++++ 39 files changed, 5092 insertions(+) create mode 100644 drivers/gpu/drm/lima/Kconfig create mode 100644 drivers/gpu/drm/lima/Makefile create mode 100644 drivers/gpu/drm/lima/lima_bcast.c create mode 100644 drivers/gpu/drm/lima/lima_bcast.h create mode 100644 drivers/gpu/drm/lima/lima_ctx.c create mode 100644 drivers/gpu/drm/lima/lima_ctx.h create mode 100644 drivers/gpu/drm/lima/lima_device.c create mode 100644 drivers/gpu/drm/lima/lima_device.h create mode 100644 drivers/gpu/drm/lima/lima_dlbu.c create mode 100644 drivers/gpu/drm/lima/lima_dlbu.h create mode 100644 drivers/gpu/drm/lima/lima_drv.c create mode 100644 drivers/gpu/drm/lima/lima_drv.h create mode 100644 drivers/gpu/drm/lima/lima_gem.c create mode 100644 drivers/gpu/drm/lima/lima_gem.h create mode 100644 drivers/gpu/drm/lima/lima_gem_prime.c create mode 100644 drivers/gpu/drm/lima/lima_gem_prime.h create mode 100644 drivers/gpu/drm/lima/lima_gp.c create mode 100644 drivers/gpu/drm/lima/lima_gp.h create mode 100644 drivers/gpu/drm/lima/lima_l2_cache.c create mode 100644 drivers/gpu/drm/lima/lima_l2_cache.h create mode 100644 drivers/gpu/drm/lima/lima_mmu.c create mode 100644 drivers/gpu/drm/lima/lima_mmu.h create mode 100644 drivers/gpu/drm/lima/lima_object.c create mode 100644 drivers/gpu/drm/lima/lima_object.h create mode 100644 drivers/gpu/drm/lima/lima_pmu.c create mode 100644 drivers/gpu/drm/lima/lima_pmu.h create mode 100644 drivers/gpu/drm/lima/lima_pp.c create mode 100644 drivers/gpu/drm/lima/lima_pp.h create mode 100644 drivers/gpu/drm/lima/lima_regs.h create mode 100644 drivers/gpu/drm/lima/lima_sched.c create mode 100644 drivers/gpu/drm/lima/lima_sched.h create mode 100644 drivers/gpu/drm/lima/lima_ttm.c create mode 100644 drivers/gpu/drm/lima/lima_ttm.h create mode 100644 drivers/gpu/drm/lima/lima_vm.c create mode 100644 drivers/gpu/drm/lima/lima_vm.h create mode 100644 include/uapi/drm/lima_drm.h