Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/atomic: add a drm_atomic_clean_old_fb helper.

This is useful for all the boilerplate code about cleaning old_fb.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1447237751-9663-4-git-send-email-maarten.lankhorst@ubuntu.com

authored by

Maarten Lankhorst and committed by
Jani Nikula
0f45c26f 45723728

+43 -18
+40 -18
drivers/gpu/drm/drm_atomic.c
··· 1432 1432 return ret; 1433 1433 } 1434 1434 1435 + /** 1436 + * drm_atomic_update_old_fb -- Unset old_fb pointers and set plane->fb pointers. 1437 + * 1438 + * @dev: drm device to check. 1439 + * @plane_mask: plane mask for planes that were updated. 1440 + * @ret: return value, can be -EDEADLK for a retry. 1441 + * 1442 + * Before doing an update plane->old_fb is set to plane->fb, 1443 + * but before dropping the locks old_fb needs to be set to NULL 1444 + * and plane->fb updated. This is a common operation for each 1445 + * atomic update, so this call is split off as a helper. 1446 + */ 1447 + void drm_atomic_clean_old_fb(struct drm_device *dev, 1448 + unsigned plane_mask, 1449 + int ret) 1450 + { 1451 + struct drm_plane *plane; 1452 + 1453 + /* if succeeded, fixup legacy plane crtc/fb ptrs before dropping 1454 + * locks (ie. while it is still safe to deref plane->state). We 1455 + * need to do this here because the driver entry points cannot 1456 + * distinguish between legacy and atomic ioctls. 1457 + */ 1458 + drm_for_each_plane_mask(plane, dev, plane_mask) { 1459 + if (ret == 0) { 1460 + struct drm_framebuffer *new_fb = plane->state->fb; 1461 + if (new_fb) 1462 + drm_framebuffer_reference(new_fb); 1463 + plane->fb = new_fb; 1464 + plane->crtc = plane->state->crtc; 1465 + 1466 + if (plane->old_fb) 1467 + drm_framebuffer_unreference(plane->old_fb); 1468 + } 1469 + plane->old_fb = NULL; 1470 + } 1471 + } 1472 + EXPORT_SYMBOL(drm_atomic_clean_old_fb); 1473 + 1435 1474 int drm_mode_atomic_ioctl(struct drm_device *dev, 1436 1475 void *data, struct drm_file *file_priv) 1437 1476 { ··· 1616 1577 } 1617 1578 1618 1579 out: 1619 - /* if succeeded, fixup legacy plane crtc/fb ptrs before dropping 1620 - * locks (ie. while it is still safe to deref plane->state). We 1621 - * need to do this here because the driver entry points cannot 1622 - * distinguish between legacy and atomic ioctls. 1623 - */ 1624 - drm_for_each_plane_mask(plane, dev, plane_mask) { 1625 - if (ret == 0) { 1626 - struct drm_framebuffer *new_fb = plane->state->fb; 1627 - if (new_fb) 1628 - drm_framebuffer_reference(new_fb); 1629 - plane->fb = new_fb; 1630 - plane->crtc = plane->state->crtc; 1631 - 1632 - if (plane->old_fb) 1633 - drm_framebuffer_unreference(plane->old_fb); 1634 - } 1635 - plane->old_fb = NULL; 1636 - } 1580 + drm_atomic_clean_old_fb(dev, plane_mask, ret); 1637 1581 1638 1582 if (ret && arg->flags & DRM_MODE_PAGE_FLIP_EVENT) { 1639 1583 /*
+3
include/drm/drm_atomic.h
··· 136 136 137 137 void drm_atomic_legacy_backoff(struct drm_atomic_state *state); 138 138 139 + void 140 + drm_atomic_clean_old_fb(struct drm_device *dev, unsigned plane_mask, int ret); 141 + 139 142 int __must_check drm_atomic_check_only(struct drm_atomic_state *state); 140 143 int __must_check drm_atomic_commit(struct drm_atomic_state *state); 141 144 int __must_check drm_atomic_async_commit(struct drm_atomic_state *state);