server gpus: fix race between buffer evict and fbdev updates
Subsystems (4)
Dave Airlie
maintainerThis stores up dirty updates to the fbdev until the next update after the buffer has finished moving, otherwise you'd see a lot of failed to reserve bo during bootup with plymouth was starting.
Dave.
Dave Airlie
maintainerPATCH 1/3 drm/mgag200: deal with bo reserve fail in dirty update path
From: Dave Airlie <[email protected]>
On F19 testing, it was noticed we get a lot of errors in dmesg about being unable to reserve the buffer when plymouth starts, this is due to the buffer being in the process of migrating, so it makes sense we can't reserve it.
In order to deal with it, this adds delayed updates for the dirty updates, when the bo is unreservable, in the normal console case this shouldn't ever happen, its just when plymouth or X is pushing the console bo to system memory.
--- drivers/gpu/drm/mgag200/mgag200_drv.h | 2 ++ drivers/gpu/drm/mgag200/mgag200_fb.c | 43 ++++++++++++++++++++++++++++++++--- drivers/gpu/drm/mgag200/mgag200_ttm.c | 4 ++-- 3 files changed, 44 insertions(+), 5 deletions(-)
drivers/gpu/drm/mgag200/mgag200_drv.h +2 -0
@@ -115,6 +115,8 @@ struct mga_fbdev {void *sysram;int size;struct ttm_bo_kmap_obj mapping; +int x1, y1, x2, y2;/* dirty rect */ +spinlock_t dirty_lock; };struct mga_crtc {
drivers/gpu/drm/mgag200/mgag200_fb.c +40 -3
72 lines not on this page · raw message
drivers/gpu/drm/mgag200/mgag200_ttm.c +2 -2
@@ -315,8 +315,8 @@ int mgag200_bo_reserve(struct mgag200_bo *bo, bool no_wait) ret =ttm_bo_reserve (&bo->bo, true, no_wait, false,0 );if (ret) { -if (ret != -ERESTARTSYS ) -DRM_ERROR ("reserve failed %p\n" , bo); +if (ret != -ERESTARTSYS && ret != -EBUSY ) +DRM_ERROR ("reserve failed %p %d\n" , bo, ret);return ret; }return 0 ;
Signature · 1 line
1.8.1.2
Dave Airlie
maintainerPATCH 2/3 drm/ast: deal with bo reserve fail in dirty update path
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
Port over the mgag200 fix to ast as it suffers the same issue.
On F19 testing, it was noticed we get a lot of errors in dmesg about being unable to reserve the buffer when plymouth starts, this is due to the buffer being in the process of migrating, so it makes sense we can't reserve it.
In order to deal with it, this adds delayed updates for the dirty updates, when the bo is unreservable, in the normal console case this shouldn't ever happen, its just when plymouth or X is pushing the console bo to system memory.
--- drivers/gpu/drm/ast/ast_drv.h | 2 ++ drivers/gpu/drm/ast/ast_fb.c | 43 ++++++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/ast/ast_ttm.c | 2 +- 3 files changed, 43 insertions(+), 4 deletions(-)
drivers/gpu/drm/ast/ast_drv.h +2 -0
@@ -241,6 +241,8 @@ struct ast_fbdev {void *sysram;int size;struct ttm_bo_kmap_obj mapping; +int x1, y1, x2, y2;/* dirty rect */ +spinlock_t dirty_lock; };#define to_ast_crtc (x) container_of(x, struct ast_crtc, base)
drivers/gpu/drm/ast/ast_fb.c +40 -3
72 lines not on this page · raw message
drivers/gpu/drm/ast/ast_ttm.c +1 -1
@@ -316,7 +316,7 @@ int ast_bo_reserve(struct ast_bo *bo, bool no_wait) ret =ttm_bo_reserve (&bo->bo, true, no_wait, false,0 );if (ret) { -if (ret != -ERESTARTSYS ) +if (ret != -ERESTARTSYS && ret != -EBUSY )DRM_ERROR ("reserve failed %p\n" , bo);return ret; }
Signature · 1 line
1.8.1.2
Dave Airlie
maintainerPATCH 3/3 drm/cirrus: deal with bo reserve fail in dirty update path
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
Port over the mgag200 fix to cirrus as it suffers the same issue.
On F19 testing, it was noticed we get a lot of errors in dmesg about being unable to reserve the buffer when plymouth starts, this is due to the buffer being in the process of migrating, so it makes sense we can't reserve it.
In order to deal with it, this adds delayed updates for the dirty updates, when the bo is unreservable, in the normal console case this shouldn't ever happen, its just when plymouth or X is pushing the console bo to system memory.
--- drivers/gpu/drm/cirrus/cirrus_drv.h | 2 ++ drivers/gpu/drm/cirrus/cirrus_fbdev.c | 38 ++++++++++++++++++++++++++++++++++- drivers/gpu/drm/cirrus/cirrus_ttm.c | 2 +- 3 files changed, 40 insertions(+), 2 deletions(-)
drivers/gpu/drm/cirrus/cirrus_drv.h +2 -0
@@ -154,6 +154,8 @@ struct cirrus_fbdev {struct list_head fbdev_list;void *sysram;int size; +int x1, y1, x2, y2;/* dirty rect */ +spinlock_t dirty_lock; };struct cirrus_bo {
drivers/gpu/drm/cirrus/cirrus_fbdev.c +37 -1
@@ -27,16 +27,51 @@ static void cirrus_dirty_update(struct cirrus_fbdev *afbdev,int bpp = (afbdev->gfb.base.bits_per_pixel +7 )/8 ;int ret;bool unmap = false; +bool store_for_later = false; +int x2, y2; +unsigned long flags; obj = afbdev->gfb.obj; bo =gem_to_cirrus_bo (obj); +/* +* try and reserve the BO, if we fail with busy +* then the BO is being moved and we should +* store up the damage until later. +*/ ret =cirrus_bo_reserve (bo, true);if (ret) { -DRM_ERROR ("failed to reserve fb bo\n" ); +if (ret != -EBUSY ) +return ; + store_for_later = true; + } + + x2 = x + width -1 ; + y2 = y + height -1 ; +spin_lock_irqsave (&afbdev->dirty_lock, flags); + +if (afbdev->y1 < y) + y = afbdev->y1; +if (afbdev->y2 > y2) + y2 = afbdev->y2; +if (afbdev->x1 < x) + x = afbdev->x1; +if (afbdev->x2 > x2) + x2 = afbdev->x2; + +if (store_for_later) { + afbdev->x1 = x; + afbdev->x2 = x2; + afbdev->y1 = y; + afbdev->y2 = y2; +spin_unlock_irqrestore (&afbdev->dirty_lock, flags);return ; } + afbdev->x1 = afbdev->y1 =INT_MAX ; + afbdev->x2 = afbdev->y2 =0 ; +spin_unlock_irqrestore (&afbdev->dirty_lock, flags); +if (!bo->kmap.virtual) { ret =ttm_bo_kmap (&bo->bo,0 , bo->bo.num_pages, &bo->kmap);if (ret) {
@@ -268,6 +303,7 @@ int cirrus_fbdev_init(struct cirrus_device *cdev) cdev->mode_info.gfbdev = gfbdev; gfbdev->helper.funcs = &cirrus_fb_helper_funcs; +spin_lock_init (&gfbdev->dirty_lock); ret =drm_fb_helper_init (cdev->dev, &gfbdev->helper, cdev->num_crtc,CIRRUSFB_CONN_LIMIT );
drivers/gpu/drm/cirrus/cirrus_ttm.c +1 -1
@@ -321,7 +321,7 @@ int cirrus_bo_reserve(struct cirrus_bo *bo, bool no_wait) ret =ttm_bo_reserve (&bo->bo, true, no_wait, false,0 );if (ret) { -if (ret != -ERESTARTSYS ) +if (ret != -ERESTARTSYS && ret != -EBUSY )DRM_ERROR ("reserve failed %p\n" , bo);return ret; }
Signature · 1 line
1.8.1.2