All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qiang Yu <yuq825@gmail.com>
To: "Christian König" <christian.koenig@amd.com>
Cc: Simon Shields <simon@lineageos.org>,
	devicetree@vger.kernel.org, Connor Abbott <cwabbott0@gmail.com>,
	Marek Vasut <marex@denx.de>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Andrei Paulau <7134956@gmail.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Vasily Khoruzhick <anarsoul@gmail.com>,
	Erico Nunes <nunes.erico@gmail.com>
Subject: Re: [PATCH RFC 00/24] Lima DRM driver
Date: Wed, 23 May 2018 22:13:13 +0800	[thread overview]
Message-ID: <CAKGbVbuSd2FkLCShYkk+nW8xeU=4rBM1NDxROi=HRhFWc929Zw@mail.gmail.com> (raw)
In-Reply-To: <ec001286-973f-d3ef-b41c-c634c93ede3e@amd.com>

On Wed, May 23, 2018 at 9:59 PM, Christian König
<christian.koenig@amd.com> wrote:
> Am 23.05.2018 um 15:52 schrieb Qiang Yu:
>>
>> On Wed, May 23, 2018 at 5:29 PM, Christian König
>> <ckoenig.leichtzumerken@gmail.com> wrote:
>>>
>>> Am 18.05.2018 um 11:27 schrieb Qiang Yu:
>>>>
>>>> Kernel DRM driver for ARM Mali 400/450 GPUs.
>>>>
>>>> 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. We
>>>>     need reverse engineering to see if and how GP/PP support MMU
>>>>     fault recovery (continue execution). Otherwise we have to
>>>>     pin/unpin each envolved buffer when task creation/deletion.
>>>
>>>
>>> Well pinning all memory is usually a no-go for upstreaming. But since you
>>> are already using the drm_sched for GPU task scheduling why are you
>>> actually
>>> needing this?
>>>
>>> The scheduler should take care of signaling all fences when the hardware
>>> is
>>> done with it's magic and that is enough for TTM to note that a buffer
>>> object
>>> is movable again (e.g. unpin them).
>>
>> Please correct me if I'm wrong.
>
>
> Well, you are wrong :)
>
>> One way to implement eviction/swap is like this:
>> call validation on each buffers involved in a task, but this won't
>> prevent it from
>> eviction/swap when executing, so a GPU MMU fault may happen and in the
>> handler we need to recover the buffer evicted/swapped.
>>
>> Another way is pin/unpin buffers evolved when task create/free.
>>
>> First way is better when memory load is low and second way is better when
>> memory load is high. First way also need less memory.
>>
>> So I'd prefer first way but due to the GPU MMU fault
>> HW op need reverse engineering, I have to pin all buffers now. After
>> the HW op is clear, I can choose one way to implement.
>
>
> The general approach is:
> 1.) Lock all BOs
> 2.) Validate all BOs
> 3.) Add the fence
> 4.) Unlock the BOs
This is the task prepare process, right?

>
> BOs can't be evicted while they are locked
During the task prepare stage, they're locked, but after task queued, they
get unlocked and be evictable?

> and since you already add the
> fence that should be perfectly sufficient to prevent it from being evicted
> until your operation is completed.
You mean I have to explicitly pin it with TTM_PL_FLAG_NO_EVICT
when task creation or TTM will check buffer's reservation object and
won't evict it if see a fence?

Regards,
Qiang

>
> Using the MMU is certainly be better in general, but usually only optional
> and a pain in the ass to get working. We have that in amdgpu for quite a
> while as well now and still don't use it because of that.
>
> Regards,
> Christian.
>
>
>>
>> Regards,
>> Qiang
>>
>>> Christian.
>>>
>>>
>>>> - 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.
>>>>
>>>> Not implemented:
>>>> - Dump buffer support
>>>> - Power management
>>>> - Performance counter
>>>>
>>>> This patch serial just pack a pair of .c/.h files in each patch.
>>>> For whole history of this driver's development, see:
>>>> https://github.com/yuq/linux-lima/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, see:
>>>> https://github.com/yuq/mesa-lima
>>>>
>>>> Andrei Paulau (1):
>>>>     arm64/dts: add switch-delay for meson mali
>>>>
>>>> Lima Project Developers (10):
>>>>     drm/lima: add mali 4xx GPU hardware regs
>>>>     drm/lima: add lima core driver
>>>>     drm/lima: add GPU device functions
>>>>     drm/lima: add PMU related functions
>>>>     drm/lima: add PP related functions
>>>>     drm/lima: add MMU related functions
>>>>     drm/lima: add GPU virtual memory space handing
>>>>     drm/lima: add GEM related functions
>>>>     drm/lima: add GEM Prime related functions
>>>>     drm/lima: add makefile and kconfig
>>>>
>>>> Qiang Yu (12):
>>>>     dt-bindings: add switch-delay property for mali-utgard
>>>>     arm64/dts: add switch-delay for meson mali
>>>>     Revert "drm: Nerf the preclose callback for modern drivers"
>>>>     drm/lima: add lima uapi header
>>>>     drm/lima: add L2 cache functions
>>>>     drm/lima: add GP related functions
>>>>     drm/lima: add BCAST related function
>>>>     drm/lima: add DLBU related functions
>>>>     drm/lima: add TTM subsystem functions
>>>>     drm/lima: add buffer object functions
>>>>     drm/lima: add GPU schedule using DRM_SCHED
>>>>     drm/lima: add context related functions
>>>>
>>>> Simon Shields (1):
>>>>     ARM: dts: add gpu node to exynos4
>>>>
>>>>    .../bindings/gpu/arm,mali-utgard.txt          |   4 +
>>>>    arch/arm/boot/dts/exynos4.dtsi                |  33 ++
>>>>    arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi   |   1 +
>>>>    .../boot/dts/amlogic/meson-gxl-mali.dtsi      |   1 +
>>>>    drivers/gpu/drm/Kconfig                       |   2 +
>>>>    drivers/gpu/drm/Makefile                      |   1 +
>>>>    drivers/gpu/drm/drm_file.c                    |   8 +-
>>>>    drivers/gpu/drm/lima/Kconfig                  |   9 +
>>>>    drivers/gpu/drm/lima/Makefile                 |  19 +
>>>>    drivers/gpu/drm/lima/lima_bcast.c             |  65 +++
>>>>    drivers/gpu/drm/lima/lima_bcast.h             |  34 ++
>>>>    drivers/gpu/drm/lima/lima_ctx.c               | 143 +++++
>>>>    drivers/gpu/drm/lima/lima_ctx.h               |  51 ++
>>>>    drivers/gpu/drm/lima/lima_device.c            | 407 ++++++++++++++
>>>>    drivers/gpu/drm/lima/lima_device.h            | 136 +++++
>>>>    drivers/gpu/drm/lima/lima_dlbu.c              |  75 +++
>>>>    drivers/gpu/drm/lima/lima_dlbu.h              |  37 ++
>>>>    drivers/gpu/drm/lima/lima_drv.c               | 466 ++++++++++++++++
>>>>    drivers/gpu/drm/lima/lima_drv.h               |  77 +++
>>>>    drivers/gpu/drm/lima/lima_gem.c               | 459 ++++++++++++++++
>>>>    drivers/gpu/drm/lima/lima_gem.h               |  41 ++
>>>>    drivers/gpu/drm/lima/lima_gem_prime.c         |  66 +++
>>>>    drivers/gpu/drm/lima/lima_gem_prime.h         |  31 ++
>>>>    drivers/gpu/drm/lima/lima_gp.c                | 293 +++++++++++
>>>>    drivers/gpu/drm/lima/lima_gp.h                |  34 ++
>>>>    drivers/gpu/drm/lima/lima_l2_cache.c          |  98 ++++
>>>>    drivers/gpu/drm/lima/lima_l2_cache.h          |  32 ++
>>>>    drivers/gpu/drm/lima/lima_mmu.c               | 154 ++++++
>>>>    drivers/gpu/drm/lima/lima_mmu.h               |  34 ++
>>>>    drivers/gpu/drm/lima/lima_object.c            | 120 +++++
>>>>    drivers/gpu/drm/lima/lima_object.h            |  87 +++
>>>>    drivers/gpu/drm/lima/lima_pmu.c               |  85 +++
>>>>    drivers/gpu/drm/lima/lima_pmu.h               |  30 ++
>>>>    drivers/gpu/drm/lima/lima_pp.c                | 418 +++++++++++++++
>>>>    drivers/gpu/drm/lima/lima_pp.h                |  37 ++
>>>>    drivers/gpu/drm/lima/lima_regs.h              | 304 +++++++++++
>>>>    drivers/gpu/drm/lima/lima_sched.c             | 497
>>>> ++++++++++++++++++
>>>>    drivers/gpu/drm/lima/lima_sched.h             | 126 +++++
>>>>    drivers/gpu/drm/lima/lima_ttm.c               | 409 ++++++++++++++
>>>>    drivers/gpu/drm/lima/lima_ttm.h               |  44 ++
>>>>    drivers/gpu/drm/lima/lima_vm.c                | 312 +++++++++++
>>>>    drivers/gpu/drm/lima/lima_vm.h                |  73 +++
>>>>    include/drm/drm_drv.h                         |  23 +-
>>>>    include/uapi/drm/lima_drm.h                   | 195 +++++++
>>>>    44 files changed, 5565 insertions(+), 6 deletions(-)
>>>>    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
>>>>
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-05-23 14:13 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-18  9:27 [PATCH RFC 00/24] Lima DRM driver Qiang Yu
2018-05-18  9:27 ` [PATCH RFC 01/24] ARM: dts: add gpu node to exynos4 Qiang Yu
2018-05-23 17:06   ` Rob Herring
2018-05-18  9:27 ` [PATCH RFC 02/24] dt-bindings: add switch-delay property for mali-utgard Qiang Yu
2018-05-23 17:04   ` Rob Herring
2018-05-24  1:52     ` Qiang Yu
2018-05-18  9:27 ` [PATCH RFC 03/24] arm64/dts: add switch-delay for meson mali Qiang Yu
2018-05-21 14:16   ` Neil Armstrong
2018-05-21 14:16     ` Neil Armstrong
2018-05-22  0:48     ` Qiang Yu
2018-05-22  0:48       ` Qiang Yu
2018-05-18  9:27 ` [PATCH RFC 04/24] " Qiang Yu
2018-05-21 14:16   ` Neil Armstrong
2018-05-21 14:16     ` Neil Armstrong
2018-05-18  9:27 ` [PATCH RFC 05/24] Revert "drm: Nerf the preclose callback for modern drivers" Qiang Yu
2018-05-23  9:35   ` Christian König
2018-05-23 13:13     ` Qiang Yu
2018-05-23 13:41       ` Christian König
2018-05-24  1:38         ` Qiang Yu
2018-05-24  6:46           ` Christian König
2018-05-24  9:24             ` Qiang Yu
2018-05-24  9:41               ` Christian König
2018-05-24 12:54                 ` Qiang Yu
2018-05-18  9:27 ` [PATCH RFC 06/24] drm/lima: add lima uapi header Qiang Yu
2018-05-18  9:33   ` Marek Vasut
2018-05-20  7:22     ` Qiang Yu
2018-05-20  9:52       ` Marek Vasut
2018-05-20  7:25     ` Qiang Yu
2018-05-18  9:27 ` [PATCH RFC 07/24] drm/lima: add mali 4xx GPU hardware regs Qiang Yu
2018-05-23 17:24   ` Rob Herring
2018-05-23 17:31     ` Vasily Khoruzhick
2018-05-24  0:58     ` Qiang Yu
2018-05-24 14:31       ` Rob Herring
2018-05-18  9:27 ` [PATCH RFC 08/24] drm/lima: add lima core driver Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 09/24] drm/lima: add GPU device functions Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 10/24] drm/lima: add PMU related functions Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 11/24] drm/lima: add L2 cache functions Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 12/24] drm/lima: add GP related functions Qiang Yu
2018-05-23 17:12   ` Marek Vasut
2018-05-24  0:38     ` Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 13/24] drm/lima: add PP " Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 14/24] drm/lima: add MMU " Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 15/24] drm/lima: add BCAST related function Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 16/24] drm/lima: add DLBU related functions Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 17/24] drm/lima: add GPU virtual memory space handing Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 18/24] drm/lima: add TTM subsystem functions Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 19/24] drm/lima: add buffer object functions Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 20/24] drm/lima: add GEM related functions Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 21/24] drm/lima: add GEM Prime " Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 22/24] drm/lima: add GPU schedule using DRM_SCHED Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 23/24] drm/lima: add context related functions Qiang Yu
2018-05-18  9:28 ` [PATCH RFC 24/24] drm/lima: add makefile and kconfig Qiang Yu
2018-05-23 17:16   ` Marek Vasut
2018-05-23 17:26     ` Rob Herring
2018-05-24  0:49       ` Qiang Yu
2018-06-15 17:23     ` Andre Przywara
2018-07-14  1:14       ` Qiang Yu
2018-07-14 12:06         ` André Przywara
2018-07-14 14:18           ` Qiang Yu
2018-07-14 19:15             ` André Przywara
2018-07-15  2:23               ` Qiang Yu
2018-05-23  9:02 ` [PATCH RFC 00/24] Lima DRM driver Daniel Vetter
2018-05-23 13:24   ` Qiang Yu
2018-05-23  9:29 ` Christian König
2018-05-23 13:52   ` Qiang Yu
2018-05-23 13:59     ` Christian König
2018-05-23 14:13       ` Qiang Yu [this message]
2018-05-23 14:19         ` Christian König
2018-05-23 14:27           ` Qiang Yu
2018-05-23 15:44     ` Daniel Vetter
2018-05-24  0:31       ` Qiang Yu
2018-05-24  6:27         ` Christian König
2018-05-24  7:25           ` Daniel Vetter
2018-05-24  9:53             ` Christian König
2018-05-19  6:52 Qiang Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKGbVbuSd2FkLCShYkk+nW8xeU=4rBM1NDxROi=HRhFWc929Zw@mail.gmail.com' \
    --to=yuq825@gmail.com \
    --cc=7134956@gmail.com \
    --cc=anarsoul@gmail.com \
    --cc=christian.koenig@amd.com \
    --cc=cwabbott0@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=marex@denx.de \
    --cc=narmstrong@baylibre.com \
    --cc=nunes.erico@gmail.com \
    --cc=simon@lineageos.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.