From: Daniel Vetter Date: Sun, 26 Feb 2017 20:34:42 +0000 (+0100) Subject: Merge airlied/drm-next into drm-misc-next X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8e22e1b3499a446df48c2b26667ca36c55bf864c;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git Merge airlied/drm-next into drm-misc-next Backmerge the main pull request to sync up with all the newly landed drivers. Otherwise we'll have chaos even before 4.12 started in earnest. Signed-off-by: Daniel Vetter --- 8e22e1b3499a446df48c2b26667ca36c55bf864c diff --cc Documentation/gpu/index.rst index c9b08b02f57c,f81278a7c2cc..70a91b372b21 --- a/Documentation/gpu/index.rst +++ b/Documentation/gpu/index.rst @@@ -11,9 -11,9 +11,10 @@@ Linux GPU Driver Developer's Guid drm-kms-helpers drm-uapi i915 + tinydrm vga-switcheroo vgaarbiter + todo .. only:: subproject and html diff --cc drivers/gpu/drm/drm_atomic.c index 5a0c7082c8f8,a5673107db26..afec53832145 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@@ -1950,8 -1938,8 +1950,8 @@@ static int prepare_crtc_signaling(struc if (arg->flags & DRM_MODE_ATOMIC_TEST_ONLY) return 0; - for_each_crtc_in_state(state, crtc, crtc_state, i) { + for_each_new_crtc_in_state(state, crtc, crtc_state, i) { - u64 __user *fence_ptr; + s32 __user *fence_ptr; fence_ptr = get_out_fence_for_crtc(crtc_state->state, crtc); @@@ -2030,14 -2018,17 +2030,17 @@@ static void complete_crtc_signaling(str return; } - for_each_crtc_in_state(state, crtc, crtc_state, i) { + for_each_new_crtc_in_state(state, crtc, crtc_state, i) { + struct drm_pending_vblank_event *event = crtc_state->event; /* - * TEST_ONLY and PAGE_FLIP_EVENT are mutually - * exclusive, if they weren't, this code should be - * called on success for TEST_ONLY too. + * Free the allocated event. drm_atomic_helper_setup_commit + * can allocate an event too, so only free it if it's ours + * to prevent a double free in drm_atomic_state_clear. */ - if (crtc_state->event) - drm_event_cancel_free(dev, &crtc_state->event->base); + if (event && (event->base.fence || event->base.file_priv)) { + drm_event_cancel_free(dev, &event->base); + crtc_state->event = NULL; + } } if (!fence_state) diff --cc drivers/gpu/drm/drm_fb_helper.c index c91240598471,f6d4d9700734..0dd5da8c55e5 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@@ -837,27 -833,36 +837,30 @@@ void drm_fb_helper_unregister_fbi(struc EXPORT_SYMBOL(drm_fb_helper_unregister_fbi); /** - * drm_fb_helper_release_fbi - dealloc fb_info and its members + * drm_fb_helper_fini - finialize a &struct drm_fb_helper * @fb_helper: driver-allocated fbdev helper * - * A helper to free memory taken by fb_info and the members cmap and - * apertures + * This cleans up all remaining resources associated with @fb_helper. Must be + * called after drm_fb_helper_unlink_fbi() was called. */ -void drm_fb_helper_release_fbi(struct drm_fb_helper *fb_helper) +void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) { - if (fb_helper) { - struct fb_info *info = fb_helper->fbdev; + struct fb_info *info; - if (info) { - if (info->cmap.len) - fb_dealloc_cmap(&info->cmap); - framebuffer_release(info); - } + if (!drm_fbdev_emulation || !fb_helper) + return; - fb_helper->fbdev = NULL; + info = fb_helper->fbdev; + if (info) { + if (info->cmap.len) + fb_dealloc_cmap(&info->cmap); + framebuffer_release(info); } -} -EXPORT_SYMBOL(drm_fb_helper_release_fbi); - -void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) -{ - if (!drm_fbdev_emulation) - return; + fb_helper->fbdev = NULL; + cancel_work_sync(&fb_helper->resume_work); + cancel_work_sync(&fb_helper->dirty_work); + mutex_lock(&kernel_fb_helper_lock); if (!list_empty(&fb_helper->kernel_fb_list)) { list_del(&fb_helper->kernel_fb_list); diff --cc drivers/gpu/drm/nouveau/nv50_display.c index 413b178c86b2,0b4440ffbeae..2517adbe7089 --- a/drivers/gpu/drm/nouveau/nv50_display.c +++ b/drivers/gpu/drm/nouveau/nv50_display.c @@@ -847,12 -846,9 +847,12 @@@ nv50_wndw_atomic_check_acquire(struct n asyw->image.w = fb->base.width; asyw->image.h = fb->base.height; asyw->image.kind = (fb->nvbo->tile_flags & 0x0000ff00) >> 8; + + asyw->interval = pflip_flags & DRM_MODE_PAGE_FLIP_ASYNC ? 0 : 1; + if (asyw->image.kind) { asyw->image.layout = 0; - if (drm->device.info.chipset >= 0xc0) + if (drm->client.device.info.chipset >= 0xc0) asyw->image.block = fb->nvbo->tile_mode >> 4; else asyw->image.block = fb->nvbo->tile_mode; diff --cc drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 7719b9cd5b74,b360e6251836..ccf456938792 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@@ -71,7 -74,92 +74,43 @@@ void rockchip_drm_dma_detach_device(str if (!is_support_iommu) return; - arm_iommu_detach_device(dev); + iommu_detach_device(domain, dev); + } + -int rockchip_register_crtc_funcs(struct drm_crtc *crtc, - const struct rockchip_crtc_funcs *crtc_funcs) -{ - int pipe = drm_crtc_index(crtc); - struct rockchip_drm_private *priv = crtc->dev->dev_private; - - if (pipe >= ROCKCHIP_MAX_CRTC) - return -EINVAL; - - priv->crtc_funcs[pipe] = crtc_funcs; - - return 0; -} - -void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc) -{ - int pipe = drm_crtc_index(crtc); - struct rockchip_drm_private *priv = crtc->dev->dev_private; - - if (pipe >= ROCKCHIP_MAX_CRTC) - return; - - priv->crtc_funcs[pipe] = NULL; -} - -static int rockchip_drm_crtc_enable_vblank(struct drm_device *dev, - unsigned int pipe) -{ - struct rockchip_drm_private *priv = dev->dev_private; - struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe); - - if (crtc && priv->crtc_funcs[pipe] && - priv->crtc_funcs[pipe]->enable_vblank) - return priv->crtc_funcs[pipe]->enable_vblank(crtc); - - return 0; -} - -static void rockchip_drm_crtc_disable_vblank(struct drm_device *dev, - unsigned int pipe) -{ - struct rockchip_drm_private *priv = dev->dev_private; - struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe); - - if (crtc && priv->crtc_funcs[pipe] && - priv->crtc_funcs[pipe]->enable_vblank) - priv->crtc_funcs[pipe]->disable_vblank(crtc); -} - + static int rockchip_drm_init_iommu(struct drm_device *drm_dev) + { + struct rockchip_drm_private *private = drm_dev->dev_private; + struct iommu_domain_geometry *geometry; + u64 start, end; + + if (!is_support_iommu) + return 0; + + private->domain = iommu_domain_alloc(&platform_bus_type); + if (!private->domain) + return -ENOMEM; + + geometry = &private->domain->geometry; + start = geometry->aperture_start; + end = geometry->aperture_end; + + DRM_DEBUG("IOMMU context initialized (aperture: %#llx-%#llx)\n", + start, end); + drm_mm_init(&private->mm, start, end - start + 1); + mutex_init(&private->mm_lock); + + return 0; + } + + static void rockchip_iommu_cleanup(struct drm_device *drm_dev) + { + struct rockchip_drm_private *private = drm_dev->dev_private; + + if (!is_support_iommu) + return; + + drm_mm_takedown(&private->mm); + iommu_domain_free(private->domain); } static int rockchip_drm_bind(struct device *dev) diff --cc drivers/gpu/drm/rockchip/rockchip_drm_drv.h index 9f9bc959b108,adc39302bec5..8aca219ec4c8 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@@ -30,7 -30,18 +30,8 @@@ struct drm_device; struct drm_connector; + struct iommu_domain; -/* - * Rockchip drm private crtc funcs. - * @enable_vblank: enable crtc vblank irq. - * @disable_vblank: disable crtc vblank irq. - */ -struct rockchip_crtc_funcs { - int (*enable_vblank)(struct drm_crtc *crtc); - void (*disable_vblank)(struct drm_crtc *crtc); -}; - struct rockchip_crtc_state { struct drm_crtc_state base; int output_type; @@@ -48,8 -59,12 +49,11 @@@ struct rockchip_drm_private { struct drm_fb_helper fbdev_helper; struct drm_gem_object *fbdev_bo; - const struct rockchip_crtc_funcs *crtc_funcs[ROCKCHIP_MAX_CRTC]; struct drm_atomic_state *state; - + struct iommu_domain *domain; + /* protect drm_mm on multi-threads */ + struct mutex mm_lock; + struct drm_mm mm; struct list_head psr_list; spinlock_t psr_list_lock; }; diff --cc include/drm/drm_atomic.h index 3fa6e8dcb9d8,052ab161b239..c6f355a970d2 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h @@@ -143,9 -143,9 +143,9 @@@ struct __drm_planes_state struct __drm_crtcs_state { struct drm_crtc *ptr; - struct drm_crtc_state *state; + struct drm_crtc_state *state, *old_state, *new_state; struct drm_crtc_commit *commit; - s64 __user *out_fence_ptr; + s32 __user *out_fence_ptr; unsigned last_vblank_count; };