From: Thomas Hellström <thellstrom(a)vmware.com>
Graphics APIs like OpenGL 4.4 and Vulkan require the graphics driver
to provide coherent graphics memory, meaning that the GPU sees any
content written to the coherent memory on the next GPU operation that
touches that memory, and the CPU sees any content written by the GPU
to that memory immediately after any fence object trailing the GPU
operation has signaled.
Paravirtual drivers that otherwise require explicit synchronization
needs to …
[View More]do this by hooking up dirty tracking to pagefault handlers
and buffer object validation.
The mm patch page walk interface has been reworked to be similar to the
reworked page-walk code (mm/pagewalk.c). There have been two other solutions
to consider:
1) Using the page-walk code. That is currently not possible since it requires
the mmap-sem to be held for the struct vm_area_struct vm_flags and for huge
page splitting. The pagewalk code in this patchset can't hold the mmap sems
since it will lead to locking inversion. We have an established locking order
mmap_sem -> dma_reservation -> i_mmap_lock, whereas holding the mmap_sem in
this case would require dma_reservation -> i_mmap_lock -> mmap_sem.
Instead it uses an operation mode similar to unmap_mapping_range() where the
i_mmap_lock is held.
2) Using apply_to_page_range(). The primary use of this code is to fill
page tables. The operation modes are IMO sufficiently different to motivate
re-implementing the page-walk.
The code has been tested and exercised by a tailored version of mesa
where we disable all explicit synchronization and assume graphics memory
is coherent. The performance loss varies of course; a typical number is
around 5%.
I would like to merge this code through the DRM tree, so an ack to include
the new mm helpers in that merge would be greatly appreciated.
Changes since RFC:
- Merge conflict changes moved to the correct patch. Fixes intra-patchset
compile errors.
- Be more aggressive when turning ttm vm code into helpers. This makes sure
we can use a const qualifier on the vmwgfx vm_ops.
- Reinstate a lost comment an fix an error path that was broken when turning
the ttm vm code into helpers.
- Remove explicit type-casts of struct vm_area_struct::vm_private_data
- Clarify the locking inversion that makes us not being able to use the mm
pagewalk code.
Changes since v1:
- Removed the vmwgfx maintainer entry for as_dirty_helpers.c, updated
commit message accordingly
- Removed the TTM patches from the series as they are merged separately
through DRM.
Cc: Andrew Morton <akpm(a)linux-foundation.org>
Cc: Matthew Wilcox <willy(a)infradead.org>
Cc: Will Deacon <will.deacon(a)arm.com>
Cc: Peter Zijlstra <peterz(a)infradead.org>
Cc: Rik van Riel <riel(a)surriel.com>
Cc: Minchan Kim <minchan(a)kernel.org>
Cc: Michal Hocko <mhocko(a)suse.com>
Cc: Huang Ying <ying.huang(a)intel.com>
Cc: Souptick Joarder <jrdr.linux(a)gmail.com>
Cc: Jérôme Glisse <jglisse(a)redhat.com>
Cc: Christian König <christian.koenig(a)amd.com>
Cc: Christoph Hellwig <hch(a)infradead.org>
[View Less]
(was: drm/ast/mgag200: Place cursor BOs at VRAM high-end)
This patchset cleans up the memory management of HW cursors in ast. It
further moves the allocated cursor BOs to the of the video RAM to reduce
memory fragmentation.
The ast driver manages cursor memory in a dedicated GEM VRAM buffer
object. It uses a double-buffering scheme of alternating between offsets
within the GEM BO. The code is convoluted and can lead to memory
fragmentation if the BO is stored the middle of VRAM. This is …
[View More]especially
a problem as ast devices only have a small amount of video memory (e.g.,
8 MiB).
With this patchset, the cursor handling in ast is first split up into
separate functions for copying cursor images, managing buffer objects,
setting scanout addresses, and moving and hiding the cursor. Furthermore,
the driver dedicates a few KiB at the high end of the device's video
memory to storing the cursor's buffer objects. This prevents memory
fragmentation.
The patchset has been tested on ast hardware.
v3:
* split-off ast patches into separate series
* move around ast_{show,hide}_cursor in a separate patch
* fix space-before-tab error near AST_HWC_SIGNATURE_CHECKSUM
v2:
* remove VRAM buffers in favor of GEM BOs
* manage BO placement with pin flag
Thomas Zimmermann (5):
drm/ast: Don't call ast_show_cursor() from ast_cursor_move()
drm/ast: Move ast_{show,hide}_cursor() within source file
drm/ast: Move cursor update code to ast_show_cursor()
drm/ast: Move cursor offset swapping into ast_show_cursor()
drm/ast: Allocate cursor BOs at high end of video memory
drivers/gpu/drm/ast/ast_drv.h | 43 +++---
drivers/gpu/drm/ast/ast_mode.c | 235 +++++++++++++++++++--------------
2 files changed, 158 insertions(+), 120 deletions(-)
--
2.23.0
[View Less]
(was: drm/ast/mgag200: Place cursor BOs at VRAM high-end)
This patchset cleans up the memory management of HW cursors in mgag200. It
further moves the allocated cursor BOs to the of the video RAM to reduce
memory fragmentation.
The mgag200 driver manages cursor memory in dedicated GEM VRAM buffer
objects. It uses a double-buffering scheme of alternating between two GEM
BOs The code is convoluted and can lead to memory fragmentation if a BO
is stored the middle of VRAM. This is especially a …
[View More]problem as mgag200
devices only contain a small amount of video memory (e.g., 16 MiB).
With this patchset, the cursor handling in mgag200 is first split up into
separate functions for copying cursor images, managing buffer objects,
setting scanout addresses, and moving and hiding the cursor. Furthermore,
the driver dedicates a few KiB at the high end of a device's video memory
to storing the cursor's buffer objects. This prevents memory fragmentation.
The patchset has been tested on mgag200 hardware.
v3:
* split-off mgag200 patches into separate series
v2:
* remove VRAM buffers in favor of GEM BOs
* manage BO placement with pin flag
Thomas Zimmermann (7):
drm/mgag200: Rename cursor functions to use mgag200_ prefix
drm/mgag200: Add init and fini functions for cursor handling
drm/mgag200: Add separate move-cursor function
drm/mgag200: Move cursor-image update to mgag200_show_cursor()
drm/mgag200: Move cursor BO swapping into mgag200_show_cursor()
drm/mgag200: Reserve video memory for cursor plane
drm/mgag200: Allocate cursor BOs at high end of video memory
drivers/gpu/drm/mgag200/mgag200_cursor.c | 313 ++++++++++++++---------
drivers/gpu/drm/mgag200/mgag200_drv.h | 22 +-
drivers/gpu/drm/mgag200/mgag200_main.c | 20 +-
drivers/gpu/drm/mgag200/mgag200_mode.c | 6 +-
drivers/gpu/drm/mgag200/mgag200_ttm.c | 4 +
5 files changed, 216 insertions(+), 149 deletions(-)
--
2.23.0
[View Less]
In acp_hw_init there are some allocations that needs to be released in
case of failure:
1- adev->acp.acp_genpd should be released if any allocation attemp for
adev->acp.acp_cell, adev->acp.acp_res or i2s_pdata fails.
2- all of those allocations should be released if pm_genpd_add_device
fails.
Signed-off-by: Navid Emamdoost <navid.emamdoost(a)gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/…
[View More]drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
index eba42c752bca..dd3fa85b11c5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
@@ -231,17 +231,21 @@ static int acp_hw_init(void *handle)
adev->acp.acp_cell = kcalloc(ACP_DEVS, sizeof(struct mfd_cell),
GFP_KERNEL);
- if (adev->acp.acp_cell == NULL)
+ if (adev->acp.acp_cell == NULL) {
+ kfree(adev->acp.acp_genpd);
return -ENOMEM;
+ }
adev->acp.acp_res = kcalloc(5, sizeof(struct resource), GFP_KERNEL);
if (adev->acp.acp_res == NULL) {
+ kfree(adev->acp.acp_genpd);
kfree(adev->acp.acp_cell);
return -ENOMEM;
}
i2s_pdata = kcalloc(3, sizeof(struct i2s_platform_data), GFP_KERNEL);
if (i2s_pdata == NULL) {
+ kfree(adev->acp.acp_genpd);
kfree(adev->acp.acp_res);
kfree(adev->acp.acp_cell);
return -ENOMEM;
@@ -348,6 +352,10 @@ static int acp_hw_init(void *handle)
r = pm_genpd_add_device(&adev->acp.acp_genpd->gpd, dev);
if (r) {
dev_err(dev, "Failed to add dev to genpd\n");
+ kfree(adev->acp.acp_genpd);
+ kfree(adev->acp.acp_res);
+ kfree(adev->acp.acp_cell);
+ kfree(i2s_pdata);
return r;
}
}
--
2.17.1
[View Less]