Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1 | /* |
Dhaval Patel | 14d46ce | 2017-01-17 16:28:12 -0800 | [diff] [blame] | 2 | * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 3 | * Copyright (C) 2013 Red Hat |
| 4 | * Author: Rob Clark <robdclark@gmail.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as published by |
| 8 | * the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along with |
| 16 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
Dhaval Patel | 3949f03 | 2016-06-20 16:24:33 -0700 | [diff] [blame] | 19 | #include <linux/of_address.h> |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 20 | #include <linux/kthread.h> |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 21 | #include "msm_drv.h" |
Rob Clark | edcd60c | 2016-03-16 12:56:12 -0400 | [diff] [blame] | 22 | #include "msm_debugfs.h" |
Rob Clark | fde5de6 | 2016-03-15 15:35:08 -0400 | [diff] [blame] | 23 | #include "msm_fence.h" |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 24 | #include "msm_gpu.h" |
Rob Clark | dd2da6e | 2013-11-30 16:12:10 -0500 | [diff] [blame] | 25 | #include "msm_kms.h" |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 26 | #include "sde_wb.h" |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 27 | |
Rob Clark | a8d854c | 2016-06-01 14:02:02 -0400 | [diff] [blame] | 28 | /* |
| 29 | * MSM driver version: |
| 30 | * - 1.0.0 - initial interface |
| 31 | * - 1.1.0 - adds madvise, and support for submits with > 4 cmd buffers |
Rob Clark | 7a3bcc0 | 2016-09-16 18:37:44 -0400 | [diff] [blame] | 32 | * - 1.2.0 - adds explicit fence support for submit ioctl |
Rob Clark | a8d854c | 2016-06-01 14:02:02 -0400 | [diff] [blame] | 33 | */ |
| 34 | #define MSM_VERSION_MAJOR 1 |
Rob Clark | 7a3bcc0 | 2016-09-16 18:37:44 -0400 | [diff] [blame] | 35 | #define MSM_VERSION_MINOR 2 |
Rob Clark | a8d854c | 2016-06-01 14:02:02 -0400 | [diff] [blame] | 36 | #define MSM_VERSION_PATCHLEVEL 0 |
| 37 | |
Lloyd Atkinson | 5217336c | 2016-09-15 18:21:18 -0400 | [diff] [blame] | 38 | #define TEARDOWN_DEADLOCK_RETRY_MAX 5 |
| 39 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 40 | static void msm_fb_output_poll_changed(struct drm_device *dev) |
| 41 | { |
| 42 | struct msm_drm_private *priv = dev->dev_private; |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 43 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 44 | if (priv->fbdev) |
| 45 | drm_fb_helper_hotplug_event(priv->fbdev); |
| 46 | } |
| 47 | |
Clarence Ip | a65cba5 | 2017-03-17 15:18:29 -0400 | [diff] [blame] | 48 | int msm_atomic_check(struct drm_device *dev, |
| 49 | struct drm_atomic_state *state) |
| 50 | { |
| 51 | if (msm_is_suspend_blocked(dev)) { |
| 52 | DRM_DEBUG("rejecting commit during suspend\n"); |
| 53 | return -EBUSY; |
| 54 | } |
| 55 | return drm_atomic_helper_check(dev, state); |
| 56 | } |
| 57 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 58 | static const struct drm_mode_config_funcs mode_config_funcs = { |
| 59 | .fb_create = msm_framebuffer_create, |
| 60 | .output_poll_changed = msm_fb_output_poll_changed, |
Clarence Ip | a65cba5 | 2017-03-17 15:18:29 -0400 | [diff] [blame] | 61 | .atomic_check = msm_atomic_check, |
Rob Clark | cf3a7e4 | 2014-11-08 13:21:06 -0500 | [diff] [blame] | 62 | .atomic_commit = msm_atomic_commit, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 63 | }; |
| 64 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 65 | int msm_register_mmu(struct drm_device *dev, struct msm_mmu *mmu) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 66 | { |
| 67 | struct msm_drm_private *priv = dev->dev_private; |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 68 | int idx = priv->num_mmus++; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 69 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 70 | if (WARN_ON(idx >= ARRAY_SIZE(priv->mmus))) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 71 | return -EINVAL; |
| 72 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 73 | priv->mmus[idx] = mmu; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 74 | |
| 75 | return idx; |
| 76 | } |
| 77 | |
Lloyd Atkinson | 1e2497e | 2016-09-26 17:55:48 -0400 | [diff] [blame] | 78 | void msm_unregister_mmu(struct drm_device *dev, struct msm_mmu *mmu) |
| 79 | { |
| 80 | struct msm_drm_private *priv = dev->dev_private; |
| 81 | int idx; |
| 82 | |
| 83 | if (priv->num_mmus <= 0) { |
| 84 | dev_err(dev->dev, "invalid num mmus %d\n", priv->num_mmus); |
| 85 | return; |
| 86 | } |
| 87 | |
| 88 | idx = priv->num_mmus - 1; |
| 89 | |
| 90 | /* only support reverse-order deallocation */ |
| 91 | if (priv->mmus[idx] != mmu) { |
| 92 | dev_err(dev->dev, "unexpected mmu at idx %d\n", idx); |
| 93 | return; |
| 94 | } |
| 95 | |
| 96 | --priv->num_mmus; |
| 97 | priv->mmus[idx] = 0; |
| 98 | } |
| 99 | |
| 100 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 101 | #ifdef CONFIG_DRM_MSM_REGISTER_LOGGING |
| 102 | static bool reglog = false; |
| 103 | MODULE_PARM_DESC(reglog, "Enable register read/write logging"); |
| 104 | module_param(reglog, bool, 0600); |
| 105 | #else |
| 106 | #define reglog 0 |
| 107 | #endif |
| 108 | |
Archit Taneja | a9ee34b | 2015-07-13 12:12:07 +0530 | [diff] [blame] | 109 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Rob Clark | e90dfec | 2015-01-30 17:05:41 -0500 | [diff] [blame] | 110 | static bool fbdev = true; |
| 111 | MODULE_PARM_DESC(fbdev, "Enable fbdev compat layer"); |
| 112 | module_param(fbdev, bool, 0600); |
| 113 | #endif |
| 114 | |
Rob Clark | 3a10ba8 | 2014-09-08 14:24:57 -0400 | [diff] [blame] | 115 | static char *vram = "16m"; |
Rob Clark | 4313c74 | 2016-02-03 14:02:04 -0500 | [diff] [blame] | 116 | MODULE_PARM_DESC(vram, "Configure VRAM size (for devices without IOMMU/GPUMMU)"); |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 117 | module_param(vram, charp, 0); |
| 118 | |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 119 | /* |
| 120 | * Util/helpers: |
| 121 | */ |
| 122 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 123 | void __iomem *msm_ioremap(struct platform_device *pdev, const char *name, |
| 124 | const char *dbgname) |
| 125 | { |
| 126 | struct resource *res; |
| 127 | unsigned long size; |
| 128 | void __iomem *ptr; |
| 129 | |
| 130 | if (name) |
| 131 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); |
| 132 | else |
| 133 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 134 | |
| 135 | if (!res) { |
| 136 | dev_err(&pdev->dev, "failed to get memory resource: %s\n", name); |
| 137 | return ERR_PTR(-EINVAL); |
| 138 | } |
| 139 | |
| 140 | size = resource_size(res); |
| 141 | |
| 142 | ptr = devm_ioremap_nocache(&pdev->dev, res->start, size); |
| 143 | if (!ptr) { |
| 144 | dev_err(&pdev->dev, "failed to ioremap: %s\n", name); |
| 145 | return ERR_PTR(-ENOMEM); |
| 146 | } |
| 147 | |
| 148 | if (reglog) |
Thierry Reding | fc99f97 | 2015-04-09 16:39:51 +0200 | [diff] [blame] | 149 | printk(KERN_DEBUG "IO:region %s %p %08lx\n", dbgname, ptr, size); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 150 | |
| 151 | return ptr; |
| 152 | } |
| 153 | |
Lloyd Atkinson | 1a0c917 | 2016-10-04 10:01:24 -0400 | [diff] [blame] | 154 | void msm_iounmap(struct platform_device *pdev, void __iomem *addr) |
| 155 | { |
| 156 | devm_iounmap(&pdev->dev, addr); |
| 157 | } |
| 158 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 159 | void msm_writel(u32 data, void __iomem *addr) |
| 160 | { |
| 161 | if (reglog) |
Thierry Reding | fc99f97 | 2015-04-09 16:39:51 +0200 | [diff] [blame] | 162 | printk(KERN_DEBUG "IO:W %p %08x\n", addr, data); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 163 | writel(data, addr); |
| 164 | } |
| 165 | |
| 166 | u32 msm_readl(const void __iomem *addr) |
| 167 | { |
| 168 | u32 val = readl(addr); |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 169 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 170 | if (reglog) |
Thierry Reding | fc99f97 | 2015-04-09 16:39:51 +0200 | [diff] [blame] | 171 | printk(KERN_ERR "IO:R %p %08x\n", addr, val); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 172 | return val; |
| 173 | } |
| 174 | |
Hai Li | 78b1d47 | 2015-07-27 13:49:45 -0400 | [diff] [blame] | 175 | struct vblank_event { |
| 176 | struct list_head node; |
| 177 | int crtc_id; |
| 178 | bool enable; |
| 179 | }; |
| 180 | |
Sandeep Panda | f48c46a | 2016-10-24 09:48:50 +0530 | [diff] [blame] | 181 | static void vblank_ctrl_worker(struct kthread_work *work) |
Hai Li | 78b1d47 | 2015-07-27 13:49:45 -0400 | [diff] [blame] | 182 | { |
| 183 | struct msm_vblank_ctrl *vbl_ctrl = container_of(work, |
| 184 | struct msm_vblank_ctrl, work); |
| 185 | struct msm_drm_private *priv = container_of(vbl_ctrl, |
| 186 | struct msm_drm_private, vblank_ctrl); |
| 187 | struct msm_kms *kms = priv->kms; |
| 188 | struct vblank_event *vbl_ev, *tmp; |
| 189 | unsigned long flags; |
| 190 | |
| 191 | spin_lock_irqsave(&vbl_ctrl->lock, flags); |
| 192 | list_for_each_entry_safe(vbl_ev, tmp, &vbl_ctrl->event_list, node) { |
| 193 | list_del(&vbl_ev->node); |
| 194 | spin_unlock_irqrestore(&vbl_ctrl->lock, flags); |
| 195 | |
| 196 | if (vbl_ev->enable) |
| 197 | kms->funcs->enable_vblank(kms, |
| 198 | priv->crtcs[vbl_ev->crtc_id]); |
| 199 | else |
| 200 | kms->funcs->disable_vblank(kms, |
| 201 | priv->crtcs[vbl_ev->crtc_id]); |
| 202 | |
| 203 | kfree(vbl_ev); |
| 204 | |
| 205 | spin_lock_irqsave(&vbl_ctrl->lock, flags); |
| 206 | } |
| 207 | |
| 208 | spin_unlock_irqrestore(&vbl_ctrl->lock, flags); |
| 209 | } |
| 210 | |
| 211 | static int vblank_ctrl_queue_work(struct msm_drm_private *priv, |
| 212 | int crtc_id, bool enable) |
| 213 | { |
| 214 | struct msm_vblank_ctrl *vbl_ctrl = &priv->vblank_ctrl; |
| 215 | struct vblank_event *vbl_ev; |
| 216 | unsigned long flags; |
| 217 | |
| 218 | vbl_ev = kzalloc(sizeof(*vbl_ev), GFP_ATOMIC); |
| 219 | if (!vbl_ev) |
| 220 | return -ENOMEM; |
| 221 | |
| 222 | vbl_ev->crtc_id = crtc_id; |
| 223 | vbl_ev->enable = enable; |
| 224 | |
| 225 | spin_lock_irqsave(&vbl_ctrl->lock, flags); |
| 226 | list_add_tail(&vbl_ev->node, &vbl_ctrl->event_list); |
| 227 | spin_unlock_irqrestore(&vbl_ctrl->lock, flags); |
| 228 | |
Sandeep Panda | f48c46a | 2016-10-24 09:48:50 +0530 | [diff] [blame] | 229 | kthread_queue_work(&priv->disp_thread[crtc_id].worker, &vbl_ctrl->work); |
Hai Li | 78b1d47 | 2015-07-27 13:49:45 -0400 | [diff] [blame] | 230 | |
| 231 | return 0; |
| 232 | } |
| 233 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 234 | static int msm_drm_uninit(struct device *dev) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 235 | { |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 236 | struct platform_device *pdev = to_platform_device(dev); |
| 237 | struct drm_device *ddev = platform_get_drvdata(pdev); |
| 238 | struct msm_drm_private *priv = ddev->dev_private; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 239 | struct msm_kms *kms = priv->kms; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 240 | struct msm_gpu *gpu = priv->gpu; |
Hai Li | 78b1d47 | 2015-07-27 13:49:45 -0400 | [diff] [blame] | 241 | struct msm_vblank_ctrl *vbl_ctrl = &priv->vblank_ctrl; |
| 242 | struct vblank_event *vbl_ev, *tmp; |
Sandeep Panda | f48c46a | 2016-10-24 09:48:50 +0530 | [diff] [blame] | 243 | int i; |
Hai Li | 78b1d47 | 2015-07-27 13:49:45 -0400 | [diff] [blame] | 244 | |
| 245 | /* We must cancel and cleanup any pending vblank enable/disable |
| 246 | * work before drm_irq_uninstall() to avoid work re-enabling an |
| 247 | * irq after uninstall has disabled it. |
| 248 | */ |
Sandeep Panda | f48c46a | 2016-10-24 09:48:50 +0530 | [diff] [blame] | 249 | kthread_flush_work(&vbl_ctrl->work); |
Hai Li | 78b1d47 | 2015-07-27 13:49:45 -0400 | [diff] [blame] | 250 | list_for_each_entry_safe(vbl_ev, tmp, &vbl_ctrl->event_list, node) { |
| 251 | list_del(&vbl_ev->node); |
| 252 | kfree(vbl_ev); |
| 253 | } |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 254 | |
Sandeep Panda | f48c46a | 2016-10-24 09:48:50 +0530 | [diff] [blame] | 255 | /* clean up display commit worker threads */ |
| 256 | for (i = 0; i < priv->num_crtcs; i++) { |
| 257 | if (priv->disp_thread[i].thread) { |
| 258 | kthread_flush_worker(&priv->disp_thread[i].worker); |
| 259 | kthread_stop(priv->disp_thread[i].thread); |
| 260 | priv->disp_thread[i].thread = NULL; |
| 261 | } |
| 262 | } |
| 263 | |
Rob Clark | 6820939 | 2016-05-17 16:19:32 -0400 | [diff] [blame] | 264 | msm_gem_shrinker_cleanup(ddev); |
| 265 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 266 | drm_kms_helper_poll_fini(ddev); |
Archit Taneja | 1aaa57f | 2016-02-25 11:19:45 +0530 | [diff] [blame] | 267 | |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 268 | drm_mode_config_cleanup(ddev); |
| 269 | drm_vblank_cleanup(ddev); |
| 270 | |
Lloyd Atkinson | ab3dd30 | 2017-02-13 10:44:55 -0800 | [diff] [blame] | 271 | if (priv->registered) { |
| 272 | drm_dev_unregister(ddev); |
| 273 | priv->registered = false; |
| 274 | } |
Archit Taneja | 8208ed9 | 2016-05-02 11:05:53 +0530 | [diff] [blame] | 275 | |
Archit Taneja | 1aaa57f | 2016-02-25 11:19:45 +0530 | [diff] [blame] | 276 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
| 277 | if (fbdev && priv->fbdev) |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 278 | msm_fbdev_free(ddev); |
Archit Taneja | 1aaa57f | 2016-02-25 11:19:45 +0530 | [diff] [blame] | 279 | #endif |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 280 | drm_mode_config_cleanup(ddev); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 281 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 282 | pm_runtime_get_sync(dev); |
| 283 | drm_irq_uninstall(ddev); |
| 284 | pm_runtime_put_sync(dev); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 285 | |
| 286 | flush_workqueue(priv->wq); |
| 287 | destroy_workqueue(priv->wq); |
| 288 | |
Archit Taneja | 1697608 | 2016-11-03 17:36:18 +0530 | [diff] [blame] | 289 | if (kms && kms->funcs) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 290 | kms->funcs->destroy(kms); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 291 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 292 | if (gpu) { |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 293 | mutex_lock(&ddev->struct_mutex); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 294 | gpu->funcs->pm_suspend(gpu); |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 295 | mutex_unlock(&ddev->struct_mutex); |
Rob Clark | 774449e | 2015-05-15 09:19:36 -0400 | [diff] [blame] | 296 | gpu->funcs->destroy(gpu); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 297 | } |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 298 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 299 | if (priv->vram.paddr) { |
Krzysztof Kozlowski | 00085f1 | 2016-08-03 13:46:00 -0700 | [diff] [blame] | 300 | unsigned long attrs = DMA_ATTR_NO_KERNEL_MAPPING; |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 301 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 302 | drm_mm_takedown(&priv->vram.mm); |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 303 | dma_free_attrs(dev, priv->vram.size, NULL, |
Krzysztof Kozlowski | 00085f1 | 2016-08-03 13:46:00 -0700 | [diff] [blame] | 304 | priv->vram.paddr, attrs); |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 305 | } |
| 306 | |
Lloyd Atkinson | 113aefd | 2016-10-23 13:15:18 -0400 | [diff] [blame] | 307 | sde_dbg_destroy(); |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 308 | debugfs_remove_recursive(priv->debug_root); |
Lloyd Atkinson | 5d40d31 | 2016-09-06 08:34:13 -0400 | [diff] [blame] | 309 | |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 310 | component_unbind_all(dev, ddev); |
Dhaval Patel | 5398f60 | 2017-03-25 18:25:18 -0700 | [diff] [blame] | 311 | sde_power_client_destroy(&priv->phandle, priv->pclient); |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 312 | sde_power_resource_deinit(pdev, &priv->phandle); |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 313 | |
Archit Taneja | 0a6030d | 2016-05-08 21:36:28 +0530 | [diff] [blame] | 314 | msm_mdss_destroy(ddev); |
| 315 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 316 | ddev->dev_private = NULL; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 317 | kfree(priv); |
| 318 | |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 319 | drm_dev_unref(ddev); |
| 320 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 321 | return 0; |
| 322 | } |
| 323 | |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 324 | #define KMS_MDP4 4 |
| 325 | #define KMS_MDP5 5 |
| 326 | #define KMS_SDE 3 |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 327 | |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 328 | static int get_mdp_ver(struct platform_device *pdev) |
| 329 | { |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 330 | #ifdef CONFIG_OF |
| 331 | static const struct of_device_id match_types[] = { { |
| 332 | .compatible = "qcom,mdss_mdp", |
| 333 | .data = (void *)KMS_MDP5, |
| 334 | }, |
| 335 | { |
| 336 | .compatible = "qcom,sde-kms", |
| 337 | .data = (void *)KMS_SDE, |
| 338 | /* end node */ |
| 339 | } }; |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 340 | struct device *dev = &pdev->dev; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 341 | const struct of_device_id *match; |
Archit Taneja | e9fbdaf | 2015-11-18 12:15:14 +0530 | [diff] [blame] | 342 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 343 | match = of_match_node(match_types, dev->of_node); |
| 344 | if (match) |
| 345 | return (int)(unsigned long)match->data; |
| 346 | #endif |
| 347 | return KMS_MDP4; |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 348 | } |
| 349 | |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 350 | static int msm_init_vram(struct drm_device *dev) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 351 | { |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 352 | struct msm_drm_private *priv = dev->dev_private; |
Archit Taneja | e9fbdaf | 2015-11-18 12:15:14 +0530 | [diff] [blame] | 353 | struct device_node *node; |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 354 | unsigned long size = 0; |
| 355 | int ret = 0; |
| 356 | |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 357 | /* In the device-tree world, we could have a 'memory-region' |
| 358 | * phandle, which gives us a link to our "vram". Allocating |
| 359 | * is all nicely abstracted behind the dma api, but we need |
| 360 | * to know the entire size to allocate it all in one go. There |
| 361 | * are two cases: |
| 362 | * 1) device with no IOMMU, in which case we need exclusive |
| 363 | * access to a VRAM carveout big enough for all gpu |
| 364 | * buffers |
| 365 | * 2) device with IOMMU, but where the bootloader puts up |
| 366 | * a splash screen. In this case, the VRAM carveout |
| 367 | * need only be large enough for fbdev fb. But we need |
| 368 | * exclusive access to the buffer to avoid the kernel |
| 369 | * using those pages for other purposes (which appears |
| 370 | * as corruption on screen before we have a chance to |
| 371 | * load and do initial modeset) |
| 372 | */ |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 373 | |
| 374 | node = of_parse_phandle(dev->dev->of_node, "memory-region", 0); |
| 375 | if (node) { |
| 376 | struct resource r; |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 377 | |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 378 | ret = of_address_to_resource(node, 0, &r); |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 379 | |
Peter Chen | 2ca41c17 | 2016-07-04 16:49:50 +0800 | [diff] [blame] | 380 | of_node_put(node); |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 381 | if (ret) |
| 382 | return ret; |
| 383 | size = r.end - r.start; |
Thierry Reding | fc99f97 | 2015-04-09 16:39:51 +0200 | [diff] [blame] | 384 | DRM_INFO("using VRAM carveout: %lx@%pa\n", size, &r.start); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 385 | |
Archit Taneja | e9fbdaf | 2015-11-18 12:15:14 +0530 | [diff] [blame] | 386 | /* if we have no IOMMU, then we need to use carveout allocator. |
| 387 | * Grab the entire CMA chunk carved out in early startup in |
| 388 | * mach-msm: |
| 389 | */ |
| 390 | } else if (!iommu_present(&platform_bus_type)) { |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 391 | DRM_INFO("using %s VRAM carveout\n", vram); |
| 392 | size = memparse(vram, NULL); |
| 393 | } |
| 394 | |
| 395 | if (size) { |
Krzysztof Kozlowski | 00085f1 | 2016-08-03 13:46:00 -0700 | [diff] [blame] | 396 | unsigned long attrs = 0; |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 397 | void *p; |
| 398 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 399 | priv->vram.size = size; |
| 400 | |
| 401 | drm_mm_init(&priv->vram.mm, 0, (size >> PAGE_SHIFT) - 1); |
| 402 | |
Krzysztof Kozlowski | 00085f1 | 2016-08-03 13:46:00 -0700 | [diff] [blame] | 403 | attrs |= DMA_ATTR_NO_KERNEL_MAPPING; |
| 404 | attrs |= DMA_ATTR_WRITE_COMBINE; |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 405 | |
| 406 | /* note that for no-kernel-mapping, the vaddr returned |
| 407 | * is bogus, but non-null if allocation succeeded: |
| 408 | */ |
| 409 | p = dma_alloc_attrs(dev->dev, size, |
Krzysztof Kozlowski | 00085f1 | 2016-08-03 13:46:00 -0700 | [diff] [blame] | 410 | &priv->vram.paddr, GFP_KERNEL, attrs); |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 411 | if (!p) { |
| 412 | dev_err(dev->dev, "failed to allocate VRAM\n"); |
| 413 | priv->vram.paddr = 0; |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 414 | return -ENOMEM; |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | dev_info(dev->dev, "VRAM: %08x->%08x\n", |
| 418 | (uint32_t)priv->vram.paddr, |
| 419 | (uint32_t)(priv->vram.paddr + size)); |
| 420 | } |
| 421 | |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 422 | return ret; |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 423 | } |
| 424 | |
Dhaval Patel | 3949f03 | 2016-06-20 16:24:33 -0700 | [diff] [blame] | 425 | #ifdef CONFIG_OF |
| 426 | static int msm_component_bind_all(struct device *dev, |
| 427 | struct drm_device *drm_dev) |
| 428 | { |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 429 | int ret; |
| 430 | |
| 431 | ret = component_bind_all(dev, drm_dev); |
| 432 | if (ret) |
| 433 | DRM_ERROR("component_bind_all failed: %d\n", ret); |
| 434 | |
| 435 | return ret; |
Dhaval Patel | 3949f03 | 2016-06-20 16:24:33 -0700 | [diff] [blame] | 436 | } |
| 437 | #else |
| 438 | static int msm_component_bind_all(struct device *dev, |
| 439 | struct drm_device *drm_dev) |
| 440 | { |
| 441 | return 0; |
| 442 | } |
| 443 | #endif |
| 444 | |
Lloyd Atkinson | 113aefd | 2016-10-23 13:15:18 -0400 | [diff] [blame] | 445 | static int msm_power_enable_wrapper(void *handle, void *client, bool enable) |
| 446 | { |
| 447 | return sde_power_resource_enable(handle, client, enable); |
| 448 | } |
| 449 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 450 | static int msm_drm_init(struct device *dev, struct drm_driver *drv) |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 451 | { |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 452 | struct platform_device *pdev = to_platform_device(dev); |
| 453 | struct drm_device *ddev; |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 454 | struct msm_drm_private *priv; |
| 455 | struct msm_kms *kms; |
Lloyd Atkinson | 113aefd | 2016-10-23 13:15:18 -0400 | [diff] [blame] | 456 | struct sde_dbg_power_ctrl dbg_power_ctrl = { 0 }; |
Sandeep Panda | f48c46a | 2016-10-24 09:48:50 +0530 | [diff] [blame] | 457 | int ret, i; |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 458 | |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 459 | ddev = drm_dev_alloc(drv, dev); |
| 460 | if (!ddev) { |
| 461 | dev_err(dev, "failed to allocate drm_device\n"); |
| 462 | return -ENOMEM; |
| 463 | } |
| 464 | |
| 465 | drm_mode_config_init(ddev); |
| 466 | platform_set_drvdata(pdev, ddev); |
| 467 | ddev->platformdev = pdev; |
| 468 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 469 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
| 470 | if (!priv) { |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 471 | ret = -ENOMEM; |
| 472 | goto priv_alloc_fail; |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | ddev->dev_private = priv; |
Rob Clark | 6820939 | 2016-05-17 16:19:32 -0400 | [diff] [blame] | 476 | priv->dev = ddev; |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 477 | |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 478 | ret = msm_mdss_init(ddev); |
| 479 | if (ret) |
| 480 | goto mdss_init_fail; |
| 481 | |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 482 | priv->wq = alloc_ordered_workqueue("msm_drm", 0); |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 483 | init_waitqueue_head(&priv->pending_crtcs_event); |
| 484 | |
| 485 | INIT_LIST_HEAD(&priv->client_event_list); |
| 486 | INIT_LIST_HEAD(&priv->inactive_list); |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 487 | INIT_LIST_HEAD(&priv->vblank_ctrl.event_list); |
Sandeep Panda | f48c46a | 2016-10-24 09:48:50 +0530 | [diff] [blame] | 488 | kthread_init_work(&priv->vblank_ctrl.work, vblank_ctrl_worker); |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 489 | spin_lock_init(&priv->vblank_ctrl.lock); |
| 490 | |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 491 | ret = sde_power_resource_init(pdev, &priv->phandle); |
| 492 | if (ret) { |
| 493 | pr_err("sde power resource init failed\n"); |
Dhaval Patel | 5398f60 | 2017-03-25 18:25:18 -0700 | [diff] [blame] | 494 | goto power_init_fail; |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 495 | } |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 496 | |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 497 | priv->pclient = sde_power_client_create(&priv->phandle, "sde"); |
| 498 | if (IS_ERR_OR_NULL(priv->pclient)) { |
| 499 | pr_err("sde power client create failed\n"); |
| 500 | ret = -EINVAL; |
Dhaval Patel | 5398f60 | 2017-03-25 18:25:18 -0700 | [diff] [blame] | 501 | goto power_client_fail; |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 502 | } |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 503 | |
| 504 | /* Bind all our sub-components: */ |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 505 | ret = msm_component_bind_all(dev, ddev); |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 506 | if (ret) |
Dhaval Patel | 5398f60 | 2017-03-25 18:25:18 -0700 | [diff] [blame] | 507 | goto bind_fail; |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 508 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 509 | ret = msm_init_vram(ddev); |
Rob Clark | 13f1556 | 2015-05-07 15:20:13 -0400 | [diff] [blame] | 510 | if (ret) |
| 511 | goto fail; |
| 512 | |
Lloyd Atkinson | 113aefd | 2016-10-23 13:15:18 -0400 | [diff] [blame] | 513 | dbg_power_ctrl.handle = &priv->phandle; |
| 514 | dbg_power_ctrl.client = priv->pclient; |
| 515 | dbg_power_ctrl.enable_fn = msm_power_enable_wrapper; |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 516 | ret = sde_dbg_init(&pdev->dev, &dbg_power_ctrl); |
Lloyd Atkinson | 5d40d31 | 2016-09-06 08:34:13 -0400 | [diff] [blame] | 517 | if (ret) { |
Lloyd Atkinson | 113aefd | 2016-10-23 13:15:18 -0400 | [diff] [blame] | 518 | dev_err(dev, "failed to init sde dbg: %d\n", ret); |
Lloyd Atkinson | 5d40d31 | 2016-09-06 08:34:13 -0400 | [diff] [blame] | 519 | goto fail; |
| 520 | } |
Rob Clark | 6820939 | 2016-05-17 16:19:32 -0400 | [diff] [blame] | 521 | |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 522 | switch (get_mdp_ver(pdev)) { |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 523 | case KMS_MDP4: |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 524 | kms = mdp4_kms_init(ddev); |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 525 | break; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 526 | case KMS_MDP5: |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 527 | kms = mdp5_kms_init(ddev); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 528 | break; |
| 529 | case KMS_SDE: |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 530 | kms = sde_kms_init(ddev); |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 531 | break; |
| 532 | default: |
| 533 | kms = ERR_PTR(-ENODEV); |
| 534 | break; |
| 535 | } |
| 536 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 537 | if (IS_ERR(kms)) { |
| 538 | /* |
| 539 | * NOTE: once we have GPU support, having no kms should not |
| 540 | * be considered fatal.. ideally we would still support gpu |
| 541 | * and (for example) use dmabuf/prime to share buffers with |
| 542 | * imx drm driver on iMX5 |
| 543 | */ |
Lloyd Atkinson | 1e2497e | 2016-09-26 17:55:48 -0400 | [diff] [blame] | 544 | priv->kms = NULL; |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 545 | dev_err(dev, "failed to load kms\n"); |
Thomas Meyer | e4826a9 | 2013-09-16 23:19:54 +0200 | [diff] [blame] | 546 | ret = PTR_ERR(kms); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 547 | goto fail; |
| 548 | } |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 549 | priv->kms = kms; |
| 550 | pm_runtime_enable(dev); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 551 | |
Alan Kwong | 2994628 | 2017-02-01 21:55:56 -0800 | [diff] [blame] | 552 | if (kms) { |
| 553 | ret = kms->funcs->hw_init(kms); |
| 554 | if (ret) { |
| 555 | dev_err(dev, "kms hw init failed: %d\n", ret); |
| 556 | goto fail; |
| 557 | } |
| 558 | } |
| 559 | ddev->mode_config.funcs = &mode_config_funcs; |
| 560 | |
Sandeep Panda | f48c46a | 2016-10-24 09:48:50 +0530 | [diff] [blame] | 561 | for (i = 0; i < priv->num_crtcs; i++) { |
| 562 | priv->disp_thread[i].crtc_id = priv->crtcs[i]->base.id; |
| 563 | kthread_init_worker(&priv->disp_thread[i].worker); |
| 564 | priv->disp_thread[i].dev = ddev; |
| 565 | priv->disp_thread[i].thread = |
| 566 | kthread_run(kthread_worker_fn, |
| 567 | &priv->disp_thread[i].worker, |
| 568 | "crtc_commit:%d", |
| 569 | priv->disp_thread[i].crtc_id); |
| 570 | |
| 571 | if (IS_ERR(priv->disp_thread[i].thread)) { |
| 572 | dev_err(dev, "failed to create kthread\n"); |
| 573 | priv->disp_thread[i].thread = NULL; |
| 574 | /* clean up previously created threads if any */ |
| 575 | for (i -= 1; i >= 0; i--) { |
| 576 | kthread_stop(priv->disp_thread[i].thread); |
| 577 | priv->disp_thread[i].thread = NULL; |
| 578 | } |
| 579 | goto fail; |
| 580 | } |
| 581 | } |
| 582 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 583 | ret = drm_vblank_init(ddev, priv->num_crtcs); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 584 | if (ret < 0) { |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 585 | dev_err(dev, "failed to initialize vblank\n"); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 586 | goto fail; |
| 587 | } |
| 588 | |
Archit Taneja | a2b3a55 | 2016-05-18 15:06:03 +0530 | [diff] [blame] | 589 | if (kms) { |
| 590 | pm_runtime_get_sync(dev); |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 591 | ret = drm_irq_install(ddev, platform_get_irq(pdev, 0)); |
Archit Taneja | a2b3a55 | 2016-05-18 15:06:03 +0530 | [diff] [blame] | 592 | pm_runtime_put_sync(dev); |
| 593 | if (ret < 0) { |
| 594 | dev_err(dev, "failed to install IRQ handler\n"); |
| 595 | goto fail; |
| 596 | } |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 597 | } |
| 598 | |
Lloyd Atkinson | ab3dd30 | 2017-02-13 10:44:55 -0800 | [diff] [blame] | 599 | ret = drm_dev_register(ddev, 0); |
| 600 | if (ret) |
| 601 | goto fail; |
| 602 | priv->registered = true; |
Rob Clark | a7d3c95 | 2014-05-30 14:47:38 -0400 | [diff] [blame] | 603 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 604 | drm_mode_config_reset(ddev); |
| 605 | |
| 606 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
| 607 | if (fbdev) |
| 608 | priv->fbdev = msm_fbdev_init(ddev); |
| 609 | #endif |
| 610 | |
| 611 | ret = msm_debugfs_late_init(ddev); |
| 612 | if (ret) |
| 613 | goto fail; |
| 614 | |
Dhaval Patel | 6c66662 | 2017-03-21 23:02:59 -0700 | [diff] [blame] | 615 | priv->debug_root = debugfs_create_dir("debug", |
| 616 | ddev->primary->debugfs_root); |
| 617 | if (IS_ERR_OR_NULL(priv->debug_root)) { |
| 618 | pr_err("debugfs_root create_dir fail, error %ld\n", |
| 619 | PTR_ERR(priv->debug_root)); |
| 620 | priv->debug_root = NULL; |
| 621 | goto fail; |
| 622 | } |
| 623 | |
| 624 | ret = sde_dbg_debugfs_register(priv->debug_root); |
Lloyd Atkinson | b020e0f | 2017-03-14 08:05:18 -0700 | [diff] [blame] | 625 | if (ret) { |
| 626 | dev_err(dev, "failed to reg sde dbg debugfs: %d\n", ret); |
| 627 | goto fail; |
| 628 | } |
| 629 | |
Alan Kwong | 5a3ac75 | 2016-10-16 01:02:35 -0400 | [diff] [blame] | 630 | /* perform subdriver post initialization */ |
| 631 | if (kms && kms->funcs && kms->funcs->postinit) { |
| 632 | ret = kms->funcs->postinit(kms); |
| 633 | if (ret) { |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 634 | pr_err("kms post init failed: %d\n", ret); |
Alan Kwong | 5a3ac75 | 2016-10-16 01:02:35 -0400 | [diff] [blame] | 635 | goto fail; |
| 636 | } |
| 637 | } |
| 638 | |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 639 | drm_kms_helper_poll_init(ddev); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 640 | |
| 641 | return 0; |
| 642 | |
| 643 | fail: |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 644 | msm_drm_uninit(dev); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 645 | return ret; |
Dhaval Patel | 5398f60 | 2017-03-25 18:25:18 -0700 | [diff] [blame] | 646 | bind_fail: |
| 647 | sde_power_client_destroy(&priv->phandle, priv->pclient); |
| 648 | power_client_fail: |
| 649 | sde_power_resource_deinit(pdev, &priv->phandle); |
| 650 | power_init_fail: |
| 651 | msm_mdss_destroy(ddev); |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 652 | mdss_init_fail: |
| 653 | kfree(priv); |
| 654 | priv_alloc_fail: |
| 655 | drm_dev_unref(ddev); |
| 656 | return ret; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 657 | } |
| 658 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 659 | /* |
| 660 | * DRM operations: |
| 661 | */ |
| 662 | |
Stephane Viau | 32f13f6 | 2015-04-29 15:57:29 -0400 | [diff] [blame] | 663 | #ifdef CONFIG_QCOM_KGSL |
| 664 | static void load_gpu(struct drm_device *dev) |
| 665 | { |
| 666 | } |
| 667 | #else |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 668 | static void load_gpu(struct drm_device *dev) |
| 669 | { |
Rob Clark | a1ad352 | 2014-07-11 11:59:22 -0400 | [diff] [blame] | 670 | static DEFINE_MUTEX(init_lock); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 671 | struct msm_drm_private *priv = dev->dev_private; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 672 | |
Rob Clark | a1ad352 | 2014-07-11 11:59:22 -0400 | [diff] [blame] | 673 | mutex_lock(&init_lock); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 674 | |
Rob Clark | e2550b7 | 2014-09-05 13:30:27 -0400 | [diff] [blame] | 675 | if (!priv->gpu) |
| 676 | priv->gpu = adreno_load_gpu(dev); |
Rob Clark | a1ad352 | 2014-07-11 11:59:22 -0400 | [diff] [blame] | 677 | |
Rob Clark | a1ad352 | 2014-07-11 11:59:22 -0400 | [diff] [blame] | 678 | mutex_unlock(&init_lock); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 679 | } |
Stephane Viau | 32f13f6 | 2015-04-29 15:57:29 -0400 | [diff] [blame] | 680 | #endif |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 681 | |
| 682 | static int msm_open(struct drm_device *dev, struct drm_file *file) |
| 683 | { |
| 684 | struct msm_file_private *ctx; |
| 685 | |
| 686 | /* For now, load gpu on open.. to avoid the requirement of having |
| 687 | * firmware in the initrd. |
| 688 | */ |
| 689 | load_gpu(dev); |
| 690 | |
| 691 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); |
| 692 | if (!ctx) |
| 693 | return -ENOMEM; |
| 694 | |
| 695 | file->driver_priv = ctx; |
| 696 | |
Clarence Ip | 0e19a5d | 2016-08-10 16:36:50 -0400 | [diff] [blame] | 697 | if (dev && dev->dev_private) { |
| 698 | struct msm_drm_private *priv = dev->dev_private; |
| 699 | struct msm_kms *kms; |
| 700 | |
| 701 | kms = priv->kms; |
| 702 | if (kms && kms->funcs && kms->funcs->postopen) |
| 703 | kms->funcs->postopen(kms, file); |
| 704 | } |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 705 | return 0; |
| 706 | } |
| 707 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 708 | static void msm_preclose(struct drm_device *dev, struct drm_file *file) |
| 709 | { |
| 710 | struct msm_drm_private *priv = dev->dev_private; |
Lloyd Atkinson | 5217336c | 2016-09-15 18:21:18 -0400 | [diff] [blame] | 711 | struct msm_kms *kms = priv->kms; |
| 712 | |
| 713 | if (kms && kms->funcs && kms->funcs->preclose) |
| 714 | kms->funcs->preclose(kms, file); |
| 715 | } |
| 716 | |
| 717 | static void msm_postclose(struct drm_device *dev, struct drm_file *file) |
| 718 | { |
| 719 | struct msm_drm_private *priv = dev->dev_private; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 720 | struct msm_file_private *ctx = file->driver_priv; |
Lloyd Atkinson | 5217336c | 2016-09-15 18:21:18 -0400 | [diff] [blame] | 721 | struct msm_kms *kms = priv->kms; |
| 722 | |
| 723 | if (kms && kms->funcs && kms->funcs->postclose) |
| 724 | kms->funcs->postclose(kms, file); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 725 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 726 | mutex_lock(&dev->struct_mutex); |
| 727 | if (ctx == priv->lastctx) |
| 728 | priv->lastctx = NULL; |
| 729 | mutex_unlock(&dev->struct_mutex); |
| 730 | |
| 731 | kfree(ctx); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 732 | } |
| 733 | |
Lloyd Atkinson | 5217336c | 2016-09-15 18:21:18 -0400 | [diff] [blame] | 734 | static int msm_disable_all_modes_commit( |
| 735 | struct drm_device *dev, |
| 736 | struct drm_atomic_state *state) |
| 737 | { |
| 738 | struct drm_plane *plane; |
| 739 | struct drm_crtc *crtc; |
| 740 | unsigned int plane_mask; |
| 741 | int ret; |
| 742 | |
| 743 | plane_mask = 0; |
| 744 | drm_for_each_plane(plane, dev) { |
| 745 | struct drm_plane_state *plane_state; |
| 746 | |
| 747 | plane_state = drm_atomic_get_plane_state(state, plane); |
| 748 | if (IS_ERR(plane_state)) { |
| 749 | ret = PTR_ERR(plane_state); |
| 750 | goto fail; |
| 751 | } |
| 752 | |
Alan Kwong | 76c9d18 | 2016-12-14 14:39:17 -0800 | [diff] [blame] | 753 | plane_state->rotation = 0; |
Lloyd Atkinson | 5217336c | 2016-09-15 18:21:18 -0400 | [diff] [blame] | 754 | |
| 755 | plane->old_fb = plane->fb; |
| 756 | plane_mask |= 1 << drm_plane_index(plane); |
| 757 | |
| 758 | /* disable non-primary: */ |
| 759 | if (plane->type == DRM_PLANE_TYPE_PRIMARY) |
| 760 | continue; |
| 761 | |
| 762 | DRM_DEBUG("disabling plane %d\n", plane->base.id); |
| 763 | |
| 764 | ret = __drm_atomic_helper_disable_plane(plane, plane_state); |
| 765 | if (ret != 0) |
| 766 | DRM_ERROR("error %d disabling plane %d\n", ret, |
| 767 | plane->base.id); |
| 768 | } |
| 769 | |
| 770 | drm_for_each_crtc(crtc, dev) { |
| 771 | struct drm_mode_set mode_set; |
| 772 | |
| 773 | memset(&mode_set, 0, sizeof(struct drm_mode_set)); |
| 774 | mode_set.crtc = crtc; |
| 775 | |
| 776 | DRM_DEBUG("disabling crtc %d\n", crtc->base.id); |
| 777 | |
| 778 | ret = __drm_atomic_helper_set_config(&mode_set, state); |
| 779 | if (ret != 0) |
| 780 | DRM_ERROR("error %d disabling crtc %d\n", ret, |
| 781 | crtc->base.id); |
| 782 | } |
| 783 | |
| 784 | DRM_DEBUG("committing disables\n"); |
| 785 | ret = drm_atomic_commit(state); |
| 786 | |
| 787 | fail: |
| 788 | drm_atomic_clean_old_fb(dev, plane_mask, ret); |
| 789 | DRM_DEBUG("disables result %d\n", ret); |
| 790 | return ret; |
| 791 | } |
| 792 | |
| 793 | /** |
| 794 | * msm_clear_all_modes - disables all planes and crtcs via an atomic commit |
| 795 | * based on restore_fbdev_mode_atomic in drm_fb_helper.c |
| 796 | * @dev: device pointer |
| 797 | * @Return: 0 on success, otherwise -error |
| 798 | */ |
| 799 | static int msm_disable_all_modes(struct drm_device *dev) |
| 800 | { |
| 801 | struct drm_atomic_state *state; |
| 802 | int ret, i; |
| 803 | |
| 804 | state = drm_atomic_state_alloc(dev); |
| 805 | if (!state) |
| 806 | return -ENOMEM; |
| 807 | |
| 808 | state->acquire_ctx = dev->mode_config.acquire_ctx; |
| 809 | |
| 810 | for (i = 0; i < TEARDOWN_DEADLOCK_RETRY_MAX; i++) { |
| 811 | ret = msm_disable_all_modes_commit(dev, state); |
| 812 | if (ret != -EDEADLK) |
| 813 | break; |
| 814 | drm_atomic_state_clear(state); |
| 815 | drm_atomic_legacy_backoff(state); |
| 816 | } |
| 817 | |
| 818 | /* on successful atomic commit state ownership transfers to framework */ |
| 819 | if (ret != 0) |
| 820 | drm_atomic_state_free(state); |
| 821 | |
| 822 | return ret; |
| 823 | } |
| 824 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 825 | static void msm_lastclose(struct drm_device *dev) |
| 826 | { |
| 827 | struct msm_drm_private *priv = dev->dev_private; |
Lloyd Atkinson | 5217336c | 2016-09-15 18:21:18 -0400 | [diff] [blame] | 828 | struct msm_kms *kms = priv->kms; |
Alan Kwong | 5a3ac75 | 2016-10-16 01:02:35 -0400 | [diff] [blame] | 829 | int i; |
| 830 | |
| 831 | /* |
| 832 | * clean up vblank disable immediately as this is the last close. |
| 833 | */ |
| 834 | for (i = 0; i < dev->num_crtcs; i++) { |
| 835 | struct drm_vblank_crtc *vblank = &dev->vblank[i]; |
| 836 | struct timer_list *disable_timer = &vblank->disable_timer; |
| 837 | |
| 838 | if (del_timer_sync(disable_timer)) |
| 839 | disable_timer->function(disable_timer->data); |
| 840 | } |
| 841 | |
| 842 | /* wait for pending vblank requests to be executed by worker thread */ |
| 843 | flush_workqueue(priv->wq); |
Lloyd Atkinson | 5217336c | 2016-09-15 18:21:18 -0400 | [diff] [blame] | 844 | |
| 845 | if (priv->fbdev) { |
Rob Clark | 5ea1f75 | 2014-05-30 12:29:48 -0400 | [diff] [blame] | 846 | drm_fb_helper_restore_fbdev_mode_unlocked(priv->fbdev); |
Lloyd Atkinson | 5217336c | 2016-09-15 18:21:18 -0400 | [diff] [blame] | 847 | } else { |
| 848 | drm_modeset_lock_all(dev); |
| 849 | msm_disable_all_modes(dev); |
| 850 | drm_modeset_unlock_all(dev); |
| 851 | if (kms && kms->funcs && kms->funcs->lastclose) |
| 852 | kms->funcs->lastclose(kms); |
| 853 | } |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 854 | } |
| 855 | |
Daniel Vetter | e9f0d76 | 2013-12-11 11:34:42 +0100 | [diff] [blame] | 856 | static irqreturn_t msm_irq(int irq, void *arg) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 857 | { |
| 858 | struct drm_device *dev = arg; |
| 859 | struct msm_drm_private *priv = dev->dev_private; |
| 860 | struct msm_kms *kms = priv->kms; |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 861 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 862 | BUG_ON(!kms); |
| 863 | return kms->funcs->irq(kms); |
| 864 | } |
| 865 | |
| 866 | static void msm_irq_preinstall(struct drm_device *dev) |
| 867 | { |
| 868 | struct msm_drm_private *priv = dev->dev_private; |
| 869 | struct msm_kms *kms = priv->kms; |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 870 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 871 | BUG_ON(!kms); |
| 872 | kms->funcs->irq_preinstall(kms); |
| 873 | } |
| 874 | |
| 875 | static int msm_irq_postinstall(struct drm_device *dev) |
| 876 | { |
| 877 | struct msm_drm_private *priv = dev->dev_private; |
| 878 | struct msm_kms *kms = priv->kms; |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 879 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 880 | BUG_ON(!kms); |
| 881 | return kms->funcs->irq_postinstall(kms); |
| 882 | } |
| 883 | |
| 884 | static void msm_irq_uninstall(struct drm_device *dev) |
| 885 | { |
| 886 | struct msm_drm_private *priv = dev->dev_private; |
| 887 | struct msm_kms *kms = priv->kms; |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 888 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 889 | BUG_ON(!kms); |
| 890 | kms->funcs->irq_uninstall(kms); |
| 891 | } |
| 892 | |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 893 | static int msm_enable_vblank(struct drm_device *dev, unsigned int pipe) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 894 | { |
| 895 | struct msm_drm_private *priv = dev->dev_private; |
| 896 | struct msm_kms *kms = priv->kms; |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 897 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 898 | if (!kms) |
| 899 | return -ENXIO; |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 900 | DBG("dev=%p, crtc=%u", dev, pipe); |
| 901 | return vblank_ctrl_queue_work(priv, pipe, true); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 902 | } |
| 903 | |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 904 | static void msm_disable_vblank(struct drm_device *dev, unsigned int pipe) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 905 | { |
| 906 | struct msm_drm_private *priv = dev->dev_private; |
| 907 | struct msm_kms *kms = priv->kms; |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 908 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 909 | if (!kms) |
| 910 | return; |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 911 | DBG("dev=%p, crtc=%u", dev, pipe); |
| 912 | vblank_ctrl_queue_work(priv, pipe, false); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 913 | } |
| 914 | |
| 915 | /* |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 916 | * DRM ioctls: |
| 917 | */ |
| 918 | |
| 919 | static int msm_ioctl_get_param(struct drm_device *dev, void *data, |
| 920 | struct drm_file *file) |
| 921 | { |
| 922 | struct msm_drm_private *priv = dev->dev_private; |
| 923 | struct drm_msm_param *args = data; |
| 924 | struct msm_gpu *gpu; |
| 925 | |
| 926 | /* for now, we just have 3d pipe.. eventually this would need to |
| 927 | * be more clever to dispatch to appropriate gpu module: |
| 928 | */ |
| 929 | if (args->pipe != MSM_PIPE_3D0) |
| 930 | return -EINVAL; |
| 931 | |
| 932 | gpu = priv->gpu; |
| 933 | |
| 934 | if (!gpu) |
| 935 | return -ENXIO; |
| 936 | |
| 937 | return gpu->funcs->get_param(gpu, args->param, &args->value); |
| 938 | } |
| 939 | |
| 940 | static int msm_ioctl_gem_new(struct drm_device *dev, void *data, |
| 941 | struct drm_file *file) |
| 942 | { |
| 943 | struct drm_msm_gem_new *args = data; |
Rob Clark | 93ddb0d | 2014-03-03 09:42:33 -0500 | [diff] [blame] | 944 | |
| 945 | if (args->flags & ~MSM_BO_FLAGS) { |
| 946 | DRM_ERROR("invalid flags: %08x\n", args->flags); |
| 947 | return -EINVAL; |
| 948 | } |
| 949 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 950 | return msm_gem_new_handle(dev, file, args->size, |
| 951 | args->flags, &args->handle); |
| 952 | } |
| 953 | |
Rob Clark | 56c2da8 | 2015-05-11 11:50:03 -0400 | [diff] [blame] | 954 | static inline ktime_t to_ktime(struct drm_msm_timespec timeout) |
| 955 | { |
| 956 | return ktime_set(timeout.tv_sec, timeout.tv_nsec); |
| 957 | } |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 958 | |
| 959 | static int msm_ioctl_gem_cpu_prep(struct drm_device *dev, void *data, |
| 960 | struct drm_file *file) |
| 961 | { |
| 962 | struct drm_msm_gem_cpu_prep *args = data; |
| 963 | struct drm_gem_object *obj; |
Rob Clark | 56c2da8 | 2015-05-11 11:50:03 -0400 | [diff] [blame] | 964 | ktime_t timeout = to_ktime(args->timeout); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 965 | int ret; |
| 966 | |
Rob Clark | 93ddb0d | 2014-03-03 09:42:33 -0500 | [diff] [blame] | 967 | if (args->op & ~MSM_PREP_FLAGS) { |
| 968 | DRM_ERROR("invalid op: %08x\n", args->op); |
| 969 | return -EINVAL; |
| 970 | } |
| 971 | |
Chris Wilson | a8ad0bd | 2016-05-09 11:04:54 +0100 | [diff] [blame] | 972 | obj = drm_gem_object_lookup(file, args->handle); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 973 | if (!obj) |
| 974 | return -ENOENT; |
| 975 | |
Rob Clark | 56c2da8 | 2015-05-11 11:50:03 -0400 | [diff] [blame] | 976 | ret = msm_gem_cpu_prep(obj, args->op, &timeout); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 977 | |
| 978 | drm_gem_object_unreference_unlocked(obj); |
| 979 | |
| 980 | return ret; |
| 981 | } |
| 982 | |
| 983 | static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data, |
| 984 | struct drm_file *file) |
| 985 | { |
| 986 | struct drm_msm_gem_cpu_fini *args = data; |
| 987 | struct drm_gem_object *obj; |
| 988 | int ret; |
| 989 | |
Chris Wilson | a8ad0bd | 2016-05-09 11:04:54 +0100 | [diff] [blame] | 990 | obj = drm_gem_object_lookup(file, args->handle); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 991 | if (!obj) |
| 992 | return -ENOENT; |
| 993 | |
| 994 | ret = msm_gem_cpu_fini(obj); |
| 995 | |
| 996 | drm_gem_object_unreference_unlocked(obj); |
| 997 | |
| 998 | return ret; |
| 999 | } |
| 1000 | |
| 1001 | static int msm_ioctl_gem_info(struct drm_device *dev, void *data, |
| 1002 | struct drm_file *file) |
| 1003 | { |
| 1004 | struct drm_msm_gem_info *args = data; |
| 1005 | struct drm_gem_object *obj; |
| 1006 | int ret = 0; |
| 1007 | |
| 1008 | if (args->pad) |
| 1009 | return -EINVAL; |
| 1010 | |
Chris Wilson | a8ad0bd | 2016-05-09 11:04:54 +0100 | [diff] [blame] | 1011 | obj = drm_gem_object_lookup(file, args->handle); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 1012 | if (!obj) |
| 1013 | return -ENOENT; |
| 1014 | |
| 1015 | args->offset = msm_gem_mmap_offset(obj); |
| 1016 | |
| 1017 | drm_gem_object_unreference_unlocked(obj); |
| 1018 | |
| 1019 | return ret; |
| 1020 | } |
| 1021 | |
| 1022 | static int msm_ioctl_wait_fence(struct drm_device *dev, void *data, |
| 1023 | struct drm_file *file) |
| 1024 | { |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame] | 1025 | struct msm_drm_private *priv = dev->dev_private; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 1026 | struct drm_msm_wait_fence *args = data; |
Rob Clark | 56c2da8 | 2015-05-11 11:50:03 -0400 | [diff] [blame] | 1027 | ktime_t timeout = to_ktime(args->timeout); |
Rob Clark | 93ddb0d | 2014-03-03 09:42:33 -0500 | [diff] [blame] | 1028 | |
| 1029 | if (args->pad) { |
| 1030 | DRM_ERROR("invalid pad: %08x\n", args->pad); |
| 1031 | return -EINVAL; |
| 1032 | } |
| 1033 | |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame] | 1034 | if (!priv->gpu) |
| 1035 | return 0; |
| 1036 | |
| 1037 | return msm_wait_fence(priv->gpu->fctx, args->fence, &timeout, true); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 1038 | } |
| 1039 | |
Rob Clark | 4cd33c4 | 2016-05-17 15:44:49 -0400 | [diff] [blame] | 1040 | static int msm_ioctl_gem_madvise(struct drm_device *dev, void *data, |
| 1041 | struct drm_file *file) |
| 1042 | { |
| 1043 | struct drm_msm_gem_madvise *args = data; |
| 1044 | struct drm_gem_object *obj; |
| 1045 | int ret; |
| 1046 | |
| 1047 | switch (args->madv) { |
| 1048 | case MSM_MADV_DONTNEED: |
| 1049 | case MSM_MADV_WILLNEED: |
| 1050 | break; |
| 1051 | default: |
| 1052 | return -EINVAL; |
| 1053 | } |
| 1054 | |
| 1055 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 1056 | if (ret) |
| 1057 | return ret; |
| 1058 | |
| 1059 | obj = drm_gem_object_lookup(file, args->handle); |
| 1060 | if (!obj) { |
| 1061 | ret = -ENOENT; |
| 1062 | goto unlock; |
| 1063 | } |
| 1064 | |
| 1065 | ret = msm_gem_madvise(obj, args->madv); |
| 1066 | if (ret >= 0) { |
| 1067 | args->retained = ret; |
| 1068 | ret = 0; |
| 1069 | } |
| 1070 | |
| 1071 | drm_gem_object_unreference(obj); |
| 1072 | |
| 1073 | unlock: |
| 1074 | mutex_unlock(&dev->struct_mutex); |
| 1075 | return ret; |
| 1076 | } |
| 1077 | |
Gopikrishnaiah Anandan | de2c81b | 2017-03-15 12:41:29 -0700 | [diff] [blame] | 1078 | static int msm_drm_object_supports_event(struct drm_device *dev, |
| 1079 | struct drm_msm_event_req *req) |
| 1080 | { |
| 1081 | int ret = -EINVAL; |
| 1082 | struct drm_mode_object *arg_obj; |
| 1083 | |
| 1084 | arg_obj = drm_mode_object_find(dev, req->object_id, req->object_type); |
| 1085 | if (!arg_obj) |
| 1086 | return -ENOENT; |
| 1087 | |
| 1088 | switch (arg_obj->type) { |
| 1089 | case DRM_MODE_OBJECT_CRTC: |
| 1090 | case DRM_MODE_OBJECT_CONNECTOR: |
| 1091 | ret = 0; |
| 1092 | break; |
| 1093 | default: |
| 1094 | ret = -EOPNOTSUPP; |
| 1095 | break; |
| 1096 | } |
| 1097 | |
| 1098 | return ret; |
| 1099 | } |
| 1100 | |
| 1101 | static int msm_register_event(struct drm_device *dev, |
| 1102 | struct drm_msm_event_req *req, struct drm_file *file, bool en) |
| 1103 | { |
| 1104 | int ret = -EINVAL; |
| 1105 | struct msm_drm_private *priv = dev->dev_private; |
| 1106 | struct msm_kms *kms = priv->kms; |
| 1107 | struct drm_mode_object *arg_obj; |
| 1108 | |
| 1109 | arg_obj = drm_mode_object_find(dev, req->object_id, req->object_type); |
| 1110 | if (!arg_obj) |
| 1111 | return -ENOENT; |
| 1112 | |
| 1113 | ret = kms->funcs->register_events(kms, arg_obj, req->event, en); |
| 1114 | return ret; |
| 1115 | } |
| 1116 | |
| 1117 | static int msm_event_client_count(struct drm_device *dev, |
| 1118 | struct drm_msm_event_req *req_event, bool locked) |
| 1119 | { |
| 1120 | struct msm_drm_private *priv = dev->dev_private; |
| 1121 | unsigned long flag = 0; |
| 1122 | struct msm_drm_event *node; |
| 1123 | int count = 0; |
| 1124 | |
| 1125 | if (!locked) |
| 1126 | spin_lock_irqsave(&dev->event_lock, flag); |
| 1127 | list_for_each_entry(node, &priv->client_event_list, base.link) { |
| 1128 | if (node->event.type == req_event->event && |
| 1129 | node->info.object_id == req_event->object_id) |
| 1130 | count++; |
| 1131 | } |
| 1132 | if (!locked) |
| 1133 | spin_unlock_irqrestore(&dev->event_lock, flag); |
| 1134 | |
| 1135 | return count; |
| 1136 | } |
| 1137 | |
| 1138 | static int msm_ioctl_register_event(struct drm_device *dev, void *data, |
| 1139 | struct drm_file *file) |
| 1140 | { |
| 1141 | struct msm_drm_private *priv = dev->dev_private; |
| 1142 | struct drm_msm_event_req *req_event = data; |
| 1143 | struct msm_drm_event *client, *node; |
| 1144 | unsigned long flag = 0; |
| 1145 | bool dup_request = false; |
| 1146 | int ret = 0, count = 0; |
| 1147 | |
| 1148 | ret = msm_drm_object_supports_event(dev, req_event); |
| 1149 | if (ret) { |
| 1150 | DRM_ERROR("unsupported event %x object %x object id %d\n", |
| 1151 | req_event->event, req_event->object_type, |
| 1152 | req_event->object_id); |
| 1153 | return ret; |
| 1154 | } |
| 1155 | |
| 1156 | spin_lock_irqsave(&dev->event_lock, flag); |
| 1157 | list_for_each_entry(node, &priv->client_event_list, base.link) { |
| 1158 | if (node->base.file_priv != file) |
| 1159 | continue; |
| 1160 | if (node->event.type == req_event->event && |
| 1161 | node->info.object_id == req_event->object_id) { |
| 1162 | DRM_DEBUG("duplicate request for event %x obj id %d\n", |
| 1163 | node->event.type, node->info.object_id); |
| 1164 | dup_request = true; |
| 1165 | break; |
| 1166 | } |
| 1167 | } |
| 1168 | spin_unlock_irqrestore(&dev->event_lock, flag); |
| 1169 | |
| 1170 | if (dup_request) |
| 1171 | return -EALREADY; |
| 1172 | |
| 1173 | client = kzalloc(sizeof(*client), GFP_KERNEL); |
| 1174 | if (!client) |
| 1175 | return -ENOMEM; |
| 1176 | |
| 1177 | client->base.file_priv = file; |
| 1178 | client->base.pid = current->pid; |
| 1179 | client->base.event = &client->event; |
| 1180 | client->event.type = req_event->event; |
| 1181 | memcpy(&client->info, req_event, sizeof(client->info)); |
| 1182 | |
| 1183 | /* Get the count of clients that have registered for event. |
| 1184 | * Event should be enabled for first client, for subsequent enable |
| 1185 | * calls add to client list and return. |
| 1186 | */ |
| 1187 | count = msm_event_client_count(dev, req_event, false); |
| 1188 | /* Add current client to list */ |
| 1189 | spin_lock_irqsave(&dev->event_lock, flag); |
| 1190 | list_add_tail(&client->base.link, &priv->client_event_list); |
| 1191 | spin_unlock_irqrestore(&dev->event_lock, flag); |
| 1192 | |
| 1193 | if (count) |
| 1194 | return 0; |
| 1195 | |
| 1196 | ret = msm_register_event(dev, req_event, file, true); |
| 1197 | if (ret) { |
| 1198 | DRM_ERROR("failed to enable event %x object %x object id %d\n", |
| 1199 | req_event->event, req_event->object_type, |
| 1200 | req_event->object_id); |
| 1201 | spin_lock_irqsave(&dev->event_lock, flag); |
| 1202 | list_del(&client->base.link); |
| 1203 | spin_unlock_irqrestore(&dev->event_lock, flag); |
| 1204 | kfree(client); |
| 1205 | } |
| 1206 | return ret; |
| 1207 | } |
| 1208 | |
| 1209 | static int msm_ioctl_deregister_event(struct drm_device *dev, void *data, |
| 1210 | struct drm_file *file) |
| 1211 | { |
| 1212 | struct msm_drm_private *priv = dev->dev_private; |
| 1213 | struct drm_msm_event_req *req_event = data; |
| 1214 | struct msm_drm_event *client = NULL, *node, *temp; |
| 1215 | unsigned long flag = 0; |
| 1216 | int count = 0; |
| 1217 | bool found = false; |
| 1218 | int ret = 0; |
| 1219 | |
| 1220 | ret = msm_drm_object_supports_event(dev, req_event); |
| 1221 | if (ret) { |
| 1222 | DRM_ERROR("unsupported event %x object %x object id %d\n", |
| 1223 | req_event->event, req_event->object_type, |
| 1224 | req_event->object_id); |
| 1225 | return ret; |
| 1226 | } |
| 1227 | |
| 1228 | spin_lock_irqsave(&dev->event_lock, flag); |
| 1229 | list_for_each_entry_safe(node, temp, &priv->client_event_list, |
| 1230 | base.link) { |
| 1231 | if (node->event.type == req_event->event && |
| 1232 | node->info.object_id == req_event->object_id && |
| 1233 | node->base.file_priv == file) { |
| 1234 | client = node; |
| 1235 | list_del(&client->base.link); |
| 1236 | found = true; |
| 1237 | kfree(client); |
| 1238 | break; |
| 1239 | } |
| 1240 | } |
| 1241 | spin_unlock_irqrestore(&dev->event_lock, flag); |
| 1242 | |
| 1243 | if (!found) |
| 1244 | return -ENOENT; |
| 1245 | |
| 1246 | count = msm_event_client_count(dev, req_event, false); |
| 1247 | if (!count) |
| 1248 | ret = msm_register_event(dev, req_event, file, false); |
| 1249 | |
| 1250 | return ret; |
| 1251 | } |
| 1252 | |
| 1253 | void msm_send_crtc_notification(struct drm_crtc *crtc, |
| 1254 | struct drm_event *event, u8 *payload) |
| 1255 | { |
| 1256 | struct drm_device *dev = NULL; |
| 1257 | struct msm_drm_private *priv = NULL; |
| 1258 | unsigned long flags; |
| 1259 | struct msm_drm_event *notify, *node; |
| 1260 | int len = 0, ret; |
| 1261 | |
| 1262 | if (!crtc || !event || !event->length || !payload) { |
| 1263 | DRM_ERROR("err param crtc %pK event %pK len %d payload %pK\n", |
| 1264 | crtc, event, ((event) ? (event->length) : -1), |
| 1265 | payload); |
| 1266 | return; |
| 1267 | } |
| 1268 | dev = crtc->dev; |
| 1269 | priv = (dev) ? dev->dev_private : NULL; |
| 1270 | if (!dev || !priv) { |
| 1271 | DRM_ERROR("invalid dev %pK priv %pK\n", dev, priv); |
| 1272 | return; |
| 1273 | } |
| 1274 | |
| 1275 | spin_lock_irqsave(&dev->event_lock, flags); |
| 1276 | list_for_each_entry(node, &priv->client_event_list, base.link) { |
| 1277 | if (node->event.type != event->type || |
| 1278 | crtc->base.id != node->info.object_id) |
| 1279 | continue; |
| 1280 | len = event->length + sizeof(struct drm_msm_event_resp); |
| 1281 | if (node->base.file_priv->event_space < len) { |
| 1282 | DRM_ERROR("Insufficient space to notify\n"); |
| 1283 | continue; |
| 1284 | } |
| 1285 | notify = kzalloc(len, GFP_ATOMIC); |
| 1286 | if (!notify) |
| 1287 | continue; |
| 1288 | notify->base.file_priv = node->base.file_priv; |
| 1289 | notify->base.event = ¬ify->event; |
| 1290 | notify->base.pid = node->base.pid; |
| 1291 | notify->event.type = node->event.type; |
| 1292 | notify->event.length = len; |
| 1293 | memcpy(¬ify->info, &node->info, sizeof(notify->info)); |
| 1294 | memcpy(notify->data, payload, event->length); |
| 1295 | ret = drm_event_reserve_init_locked(dev, node->base.file_priv, |
| 1296 | ¬ify->base, ¬ify->event); |
| 1297 | if (ret) { |
| 1298 | kfree(notify); |
| 1299 | continue; |
| 1300 | } |
| 1301 | drm_send_event_locked(dev, ¬ify->base); |
| 1302 | } |
| 1303 | spin_unlock_irqrestore(&dev->event_lock, flags); |
| 1304 | } |
| 1305 | |
| 1306 | static int msm_release(struct inode *inode, struct file *filp) |
| 1307 | { |
| 1308 | struct drm_file *file_priv = filp->private_data; |
| 1309 | struct drm_minor *minor = file_priv->minor; |
| 1310 | struct drm_device *dev = minor->dev; |
| 1311 | struct msm_drm_private *priv = dev->dev_private; |
| 1312 | struct msm_drm_event *node, *temp; |
| 1313 | u32 count; |
| 1314 | unsigned long flags; |
| 1315 | |
| 1316 | spin_lock_irqsave(&dev->event_lock, flags); |
| 1317 | list_for_each_entry_safe(node, temp, &priv->client_event_list, |
| 1318 | base.link) { |
| 1319 | if (node->base.file_priv != file_priv) |
| 1320 | continue; |
| 1321 | list_del(&node->base.link); |
| 1322 | spin_unlock_irqrestore(&dev->event_lock, flags); |
| 1323 | count = msm_event_client_count(dev, &node->info, true); |
| 1324 | if (!count) |
| 1325 | msm_register_event(dev, &node->info, file_priv, false); |
| 1326 | kfree(node); |
| 1327 | spin_lock_irqsave(&dev->event_lock, flags); |
| 1328 | } |
| 1329 | spin_unlock_irqrestore(&dev->event_lock, flags); |
| 1330 | |
| 1331 | return drm_release(inode, filp); |
| 1332 | } |
| 1333 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 1334 | static const struct drm_ioctl_desc msm_ioctls[] = { |
Daniel Vetter | f8c4714 | 2015-09-08 13:56:30 +0200 | [diff] [blame] | 1335 | DRM_IOCTL_DEF_DRV(MSM_GET_PARAM, msm_ioctl_get_param, DRM_AUTH|DRM_RENDER_ALLOW), |
| 1336 | DRM_IOCTL_DEF_DRV(MSM_GEM_NEW, msm_ioctl_gem_new, DRM_AUTH|DRM_RENDER_ALLOW), |
| 1337 | DRM_IOCTL_DEF_DRV(MSM_GEM_INFO, msm_ioctl_gem_info, DRM_AUTH|DRM_RENDER_ALLOW), |
| 1338 | DRM_IOCTL_DEF_DRV(MSM_GEM_CPU_PREP, msm_ioctl_gem_cpu_prep, DRM_AUTH|DRM_RENDER_ALLOW), |
| 1339 | DRM_IOCTL_DEF_DRV(MSM_GEM_CPU_FINI, msm_ioctl_gem_cpu_fini, DRM_AUTH|DRM_RENDER_ALLOW), |
| 1340 | DRM_IOCTL_DEF_DRV(MSM_GEM_SUBMIT, msm_ioctl_gem_submit, DRM_AUTH|DRM_RENDER_ALLOW), |
| 1341 | DRM_IOCTL_DEF_DRV(MSM_WAIT_FENCE, msm_ioctl_wait_fence, DRM_AUTH|DRM_RENDER_ALLOW), |
Rob Clark | 4cd33c4 | 2016-05-17 15:44:49 -0400 | [diff] [blame] | 1342 | DRM_IOCTL_DEF_DRV(MSM_GEM_MADVISE, msm_ioctl_gem_madvise, DRM_AUTH|DRM_RENDER_ALLOW), |
Alan Kwong | bb27c09 | 2016-07-20 16:41:25 -0400 | [diff] [blame] | 1343 | DRM_IOCTL_DEF_DRV(SDE_WB_CONFIG, sde_wb_config, DRM_UNLOCKED|DRM_AUTH), |
Gopikrishnaiah Anandan | de2c81b | 2017-03-15 12:41:29 -0700 | [diff] [blame] | 1344 | DRM_IOCTL_DEF_DRV(MSM_REGISTER_EVENT, msm_ioctl_register_event, |
| 1345 | DRM_UNLOCKED|DRM_CONTROL_ALLOW), |
| 1346 | DRM_IOCTL_DEF_DRV(MSM_DEREGISTER_EVENT, msm_ioctl_deregister_event, |
| 1347 | DRM_UNLOCKED|DRM_CONTROL_ALLOW), |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 1348 | }; |
| 1349 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1350 | static const struct vm_operations_struct vm_ops = { |
| 1351 | .fault = msm_gem_fault, |
| 1352 | .open = drm_gem_vm_open, |
| 1353 | .close = drm_gem_vm_close, |
| 1354 | }; |
| 1355 | |
| 1356 | static const struct file_operations fops = { |
| 1357 | .owner = THIS_MODULE, |
| 1358 | .open = drm_open, |
Gopikrishnaiah Anandan | de2c81b | 2017-03-15 12:41:29 -0700 | [diff] [blame] | 1359 | .release = msm_release, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1360 | .unlocked_ioctl = drm_ioctl, |
| 1361 | #ifdef CONFIG_COMPAT |
| 1362 | .compat_ioctl = drm_compat_ioctl, |
| 1363 | #endif |
| 1364 | .poll = drm_poll, |
| 1365 | .read = drm_read, |
| 1366 | .llseek = no_llseek, |
| 1367 | .mmap = msm_gem_mmap, |
| 1368 | }; |
| 1369 | |
| 1370 | static struct drm_driver msm_driver = { |
Rob Clark | 05b8491 | 2013-09-28 11:28:35 -0400 | [diff] [blame] | 1371 | .driver_features = DRIVER_HAVE_IRQ | |
| 1372 | DRIVER_GEM | |
| 1373 | DRIVER_PRIME | |
Rob Clark | b4b15c8 | 2013-09-28 12:01:25 -0400 | [diff] [blame] | 1374 | DRIVER_RENDER | |
Rob Clark | a5436e1 | 2015-06-04 10:12:22 -0400 | [diff] [blame] | 1375 | DRIVER_ATOMIC | |
Rob Clark | 05b8491 | 2013-09-28 11:28:35 -0400 | [diff] [blame] | 1376 | DRIVER_MODESET, |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 1377 | .open = msm_open, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1378 | .preclose = msm_preclose, |
Lloyd Atkinson | 5217336c | 2016-09-15 18:21:18 -0400 | [diff] [blame] | 1379 | .postclose = msm_postclose, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1380 | .lastclose = msm_lastclose, |
| 1381 | .irq_handler = msm_irq, |
| 1382 | .irq_preinstall = msm_irq_preinstall, |
| 1383 | .irq_postinstall = msm_irq_postinstall, |
| 1384 | .irq_uninstall = msm_irq_uninstall, |
Ville Syrjälä | b44f840 | 2015-09-30 16:46:48 +0300 | [diff] [blame] | 1385 | .get_vblank_counter = drm_vblank_no_hw_counter, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1386 | .enable_vblank = msm_enable_vblank, |
| 1387 | .disable_vblank = msm_disable_vblank, |
| 1388 | .gem_free_object = msm_gem_free_object, |
| 1389 | .gem_vm_ops = &vm_ops, |
| 1390 | .dumb_create = msm_gem_dumb_create, |
| 1391 | .dumb_map_offset = msm_gem_dumb_map_offset, |
Rob Clark | 30600a909 | 2013-09-28 10:13:04 -0400 | [diff] [blame] | 1392 | .dumb_destroy = drm_gem_dumb_destroy, |
Rob Clark | 05b8491 | 2013-09-28 11:28:35 -0400 | [diff] [blame] | 1393 | .prime_handle_to_fd = drm_gem_prime_handle_to_fd, |
| 1394 | .prime_fd_to_handle = drm_gem_prime_fd_to_handle, |
| 1395 | .gem_prime_export = drm_gem_prime_export, |
| 1396 | .gem_prime_import = drm_gem_prime_import, |
| 1397 | .gem_prime_pin = msm_gem_prime_pin, |
| 1398 | .gem_prime_unpin = msm_gem_prime_unpin, |
| 1399 | .gem_prime_get_sg_table = msm_gem_prime_get_sg_table, |
| 1400 | .gem_prime_import_sg_table = msm_gem_prime_import_sg_table, |
| 1401 | .gem_prime_vmap = msm_gem_prime_vmap, |
| 1402 | .gem_prime_vunmap = msm_gem_prime_vunmap, |
Daniel Thompson | 77a147e | 2014-11-12 11:38:14 +0000 | [diff] [blame] | 1403 | .gem_prime_mmap = msm_gem_prime_mmap, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1404 | #ifdef CONFIG_DEBUG_FS |
| 1405 | .debugfs_init = msm_debugfs_init, |
| 1406 | .debugfs_cleanup = msm_debugfs_cleanup, |
| 1407 | #endif |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 1408 | .ioctls = msm_ioctls, |
Jordan Crouse | 1023e9b | 2017-03-07 11:14:04 -0700 | [diff] [blame] | 1409 | .num_ioctls = ARRAY_SIZE(msm_ioctls), |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1410 | .fops = &fops, |
Stephane Viau | aa6ed8b | 2016-07-19 12:59:42 -0400 | [diff] [blame] | 1411 | .name = "msm_drm", |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1412 | .desc = "MSM Snapdragon DRM", |
| 1413 | .date = "20130625", |
Rob Clark | a8d854c | 2016-06-01 14:02:02 -0400 | [diff] [blame] | 1414 | .major = MSM_VERSION_MAJOR, |
| 1415 | .minor = MSM_VERSION_MINOR, |
| 1416 | .patchlevel = MSM_VERSION_PATCHLEVEL, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1417 | }; |
| 1418 | |
| 1419 | #ifdef CONFIG_PM_SLEEP |
| 1420 | static int msm_pm_suspend(struct device *dev) |
| 1421 | { |
Clarence Ip | e5f1f4c | 2016-11-19 18:02:23 -0500 | [diff] [blame] | 1422 | struct drm_device *ddev; |
| 1423 | struct drm_modeset_acquire_ctx ctx; |
| 1424 | struct drm_connector *conn; |
| 1425 | struct drm_atomic_state *state; |
| 1426 | struct drm_crtc_state *crtc_state; |
| 1427 | struct msm_drm_private *priv; |
| 1428 | int ret = 0; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1429 | |
Clarence Ip | e5f1f4c | 2016-11-19 18:02:23 -0500 | [diff] [blame] | 1430 | if (!dev) |
| 1431 | return -EINVAL; |
| 1432 | |
| 1433 | ddev = dev_get_drvdata(dev); |
| 1434 | if (!ddev || !ddev->dev_private) |
| 1435 | return -EINVAL; |
| 1436 | |
| 1437 | priv = ddev->dev_private; |
| 1438 | SDE_EVT32(0); |
| 1439 | |
| 1440 | /* acquire modeset lock(s) */ |
| 1441 | drm_modeset_acquire_init(&ctx, 0); |
| 1442 | |
| 1443 | retry: |
| 1444 | ret = drm_modeset_lock_all_ctx(ddev, &ctx); |
| 1445 | if (ret) |
| 1446 | goto unlock; |
| 1447 | |
| 1448 | /* save current state for resume */ |
| 1449 | if (priv->suspend_state) |
| 1450 | drm_atomic_state_free(priv->suspend_state); |
| 1451 | priv->suspend_state = drm_atomic_helper_duplicate_state(ddev, &ctx); |
| 1452 | if (IS_ERR_OR_NULL(priv->suspend_state)) { |
| 1453 | DRM_ERROR("failed to back up suspend state\n"); |
| 1454 | priv->suspend_state = NULL; |
| 1455 | goto unlock; |
| 1456 | } |
| 1457 | |
| 1458 | /* create atomic state to disable all CRTCs */ |
| 1459 | state = drm_atomic_state_alloc(ddev); |
| 1460 | if (IS_ERR_OR_NULL(state)) { |
| 1461 | DRM_ERROR("failed to allocate crtc disable state\n"); |
| 1462 | goto unlock; |
| 1463 | } |
| 1464 | |
| 1465 | state->acquire_ctx = &ctx; |
| 1466 | drm_for_each_connector(conn, ddev) { |
| 1467 | |
| 1468 | if (!conn->state || !conn->state->crtc || |
| 1469 | conn->dpms != DRM_MODE_DPMS_ON) |
| 1470 | continue; |
| 1471 | |
| 1472 | /* force CRTC to be inactive */ |
| 1473 | crtc_state = drm_atomic_get_crtc_state(state, |
| 1474 | conn->state->crtc); |
| 1475 | if (IS_ERR_OR_NULL(crtc_state)) { |
| 1476 | DRM_ERROR("failed to get crtc %d state\n", |
| 1477 | conn->state->crtc->base.id); |
| 1478 | drm_atomic_state_free(state); |
| 1479 | goto unlock; |
| 1480 | } |
| 1481 | crtc_state->active = false; |
| 1482 | } |
| 1483 | |
| 1484 | /* commit the "disable all" state */ |
| 1485 | ret = drm_atomic_commit(state); |
| 1486 | if (ret < 0) { |
| 1487 | DRM_ERROR("failed to disable crtcs, %d\n", ret); |
| 1488 | drm_atomic_state_free(state); |
Clarence Ip | a65cba5 | 2017-03-17 15:18:29 -0400 | [diff] [blame] | 1489 | } else { |
| 1490 | priv->suspend_block = true; |
Clarence Ip | e5f1f4c | 2016-11-19 18:02:23 -0500 | [diff] [blame] | 1491 | } |
| 1492 | |
| 1493 | unlock: |
| 1494 | if (ret == -EDEADLK) { |
| 1495 | drm_modeset_backoff(&ctx); |
| 1496 | goto retry; |
| 1497 | } |
| 1498 | drm_modeset_drop_locks(&ctx); |
| 1499 | drm_modeset_acquire_fini(&ctx); |
| 1500 | |
| 1501 | /* disable hot-plug polling */ |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1502 | drm_kms_helper_poll_disable(ddev); |
| 1503 | |
| 1504 | return 0; |
| 1505 | } |
| 1506 | |
| 1507 | static int msm_pm_resume(struct device *dev) |
| 1508 | { |
Clarence Ip | e5f1f4c | 2016-11-19 18:02:23 -0500 | [diff] [blame] | 1509 | struct drm_device *ddev; |
| 1510 | struct msm_drm_private *priv; |
| 1511 | int ret; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1512 | |
Clarence Ip | e5f1f4c | 2016-11-19 18:02:23 -0500 | [diff] [blame] | 1513 | if (!dev) |
| 1514 | return -EINVAL; |
| 1515 | |
| 1516 | ddev = dev_get_drvdata(dev); |
| 1517 | if (!ddev || !ddev->dev_private) |
| 1518 | return -EINVAL; |
| 1519 | |
| 1520 | priv = ddev->dev_private; |
| 1521 | |
| 1522 | SDE_EVT32(priv->suspend_state != NULL); |
| 1523 | |
| 1524 | drm_mode_config_reset(ddev); |
| 1525 | |
| 1526 | drm_modeset_lock_all(ddev); |
| 1527 | |
Clarence Ip | a65cba5 | 2017-03-17 15:18:29 -0400 | [diff] [blame] | 1528 | priv->suspend_block = false; |
| 1529 | |
Clarence Ip | e5f1f4c | 2016-11-19 18:02:23 -0500 | [diff] [blame] | 1530 | if (priv->suspend_state) { |
| 1531 | priv->suspend_state->acquire_ctx = |
| 1532 | ddev->mode_config.acquire_ctx; |
| 1533 | ret = drm_atomic_commit(priv->suspend_state); |
| 1534 | if (ret < 0) { |
| 1535 | DRM_ERROR("failed to restore state, %d\n", ret); |
| 1536 | drm_atomic_state_free(priv->suspend_state); |
| 1537 | } |
| 1538 | priv->suspend_state = NULL; |
| 1539 | } |
| 1540 | drm_modeset_unlock_all(ddev); |
| 1541 | |
| 1542 | /* enable hot-plug polling */ |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1543 | drm_kms_helper_poll_enable(ddev); |
| 1544 | |
| 1545 | return 0; |
| 1546 | } |
| 1547 | #endif |
| 1548 | |
| 1549 | static const struct dev_pm_ops msm_pm_ops = { |
| 1550 | SET_SYSTEM_SLEEP_PM_OPS(msm_pm_suspend, msm_pm_resume) |
| 1551 | }; |
| 1552 | |
| 1553 | /* |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 1554 | * Componentized driver support: |
| 1555 | */ |
| 1556 | |
Archit Taneja | e9fbdaf | 2015-11-18 12:15:14 +0530 | [diff] [blame] | 1557 | /* |
| 1558 | * NOTE: duplication of the same code as exynos or imx (or probably any other). |
| 1559 | * so probably some room for some helpers |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 1560 | */ |
| 1561 | static int compare_of(struct device *dev, void *data) |
| 1562 | { |
| 1563 | return dev->of_node == data; |
| 1564 | } |
Rob Clark | 41e6977 | 2013-12-15 16:23:05 -0500 | [diff] [blame] | 1565 | |
Archit Taneja | 812070e | 2016-05-19 10:38:39 +0530 | [diff] [blame] | 1566 | /* |
| 1567 | * Identify what components need to be added by parsing what remote-endpoints |
| 1568 | * our MDP output ports are connected to. In the case of LVDS on MDP4, there |
| 1569 | * is no external component that we need to add since LVDS is within MDP4 |
| 1570 | * itself. |
| 1571 | */ |
| 1572 | static int add_components_mdp(struct device *mdp_dev, |
| 1573 | struct component_match **matchptr) |
| 1574 | { |
| 1575 | struct device_node *np = mdp_dev->of_node; |
| 1576 | struct device_node *ep_node; |
Archit Taneja | 54011e2 | 2016-06-06 13:45:34 +0530 | [diff] [blame] | 1577 | struct device *master_dev; |
| 1578 | |
| 1579 | /* |
| 1580 | * on MDP4 based platforms, the MDP platform device is the component |
| 1581 | * master that adds other display interface components to itself. |
| 1582 | * |
| 1583 | * on MDP5 based platforms, the MDSS platform device is the component |
| 1584 | * master that adds MDP5 and other display interface components to |
| 1585 | * itself. |
| 1586 | */ |
| 1587 | if (of_device_is_compatible(np, "qcom,mdp4")) |
| 1588 | master_dev = mdp_dev; |
| 1589 | else |
| 1590 | master_dev = mdp_dev->parent; |
Archit Taneja | 812070e | 2016-05-19 10:38:39 +0530 | [diff] [blame] | 1591 | |
| 1592 | for_each_endpoint_of_node(np, ep_node) { |
| 1593 | struct device_node *intf; |
| 1594 | struct of_endpoint ep; |
| 1595 | int ret; |
| 1596 | |
| 1597 | ret = of_graph_parse_endpoint(ep_node, &ep); |
| 1598 | if (ret) { |
| 1599 | dev_err(mdp_dev, "unable to parse port endpoint\n"); |
| 1600 | of_node_put(ep_node); |
| 1601 | return ret; |
| 1602 | } |
| 1603 | |
| 1604 | /* |
| 1605 | * The LCDC/LVDS port on MDP4 is a speacial case where the |
| 1606 | * remote-endpoint isn't a component that we need to add |
| 1607 | */ |
| 1608 | if (of_device_is_compatible(np, "qcom,mdp4") && |
| 1609 | ep.port == 0) { |
| 1610 | of_node_put(ep_node); |
| 1611 | continue; |
| 1612 | } |
| 1613 | |
| 1614 | /* |
| 1615 | * It's okay if some of the ports don't have a remote endpoint |
| 1616 | * specified. It just means that the port isn't connected to |
| 1617 | * any external interface. |
| 1618 | */ |
| 1619 | intf = of_graph_get_remote_port_parent(ep_node); |
| 1620 | if (!intf) { |
| 1621 | of_node_put(ep_node); |
| 1622 | continue; |
| 1623 | } |
| 1624 | |
Archit Taneja | 54011e2 | 2016-06-06 13:45:34 +0530 | [diff] [blame] | 1625 | component_match_add(master_dev, matchptr, compare_of, intf); |
Archit Taneja | 812070e | 2016-05-19 10:38:39 +0530 | [diff] [blame] | 1626 | |
| 1627 | of_node_put(intf); |
| 1628 | of_node_put(ep_node); |
| 1629 | } |
| 1630 | |
| 1631 | return 0; |
| 1632 | } |
| 1633 | |
Archit Taneja | 54011e2 | 2016-06-06 13:45:34 +0530 | [diff] [blame] | 1634 | static int compare_name_mdp(struct device *dev, void *data) |
| 1635 | { |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 1636 | return (strnstr(dev_name(dev), "mdp", strlen("mdp")) != NULL); |
| 1637 | } |
| 1638 | |
| 1639 | static int add_display_components(struct device *dev, |
| 1640 | struct component_match **matchptr) |
| 1641 | { |
| 1642 | struct device *mdp_dev = NULL; |
Archit Taneja | 54011e2 | 2016-06-06 13:45:34 +0530 | [diff] [blame] | 1643 | int ret; |
| 1644 | |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 1645 | if (of_device_is_compatible(dev->of_node, "qcom,sde-kms")) { |
| 1646 | struct device_node *np = dev->of_node; |
| 1647 | unsigned int i; |
| 1648 | |
| 1649 | for (i = 0; ; i++) { |
| 1650 | struct device_node *node; |
| 1651 | |
| 1652 | node = of_parse_phandle(np, "connectors", i); |
| 1653 | if (!node) |
| 1654 | break; |
| 1655 | |
| 1656 | component_match_add(dev, matchptr, compare_of, node); |
| 1657 | } |
| 1658 | return 0; |
| 1659 | } |
| 1660 | |
| 1661 | /* |
| 1662 | * MDP5 based devices don't have a flat hierarchy. There is a top level |
| 1663 | * parent: MDSS, and children: MDP5, DSI, HDMI, eDP etc. Populate the |
| 1664 | * children devices, find the MDP5 node, and then add the interfaces |
| 1665 | * to our components list. |
| 1666 | */ |
| 1667 | if (of_device_is_compatible(dev->of_node, "qcom,mdss")) { |
| 1668 | ret = of_platform_populate(dev->of_node, NULL, NULL, dev); |
| 1669 | if (ret) { |
| 1670 | dev_err(dev, "failed to populate children devices\n"); |
| 1671 | return ret; |
| 1672 | } |
| 1673 | |
| 1674 | mdp_dev = device_find_child(dev, NULL, compare_name_mdp); |
| 1675 | if (!mdp_dev) { |
| 1676 | dev_err(dev, "failed to find MDSS MDP node\n"); |
| 1677 | of_platform_depopulate(dev); |
| 1678 | return -ENODEV; |
| 1679 | } |
| 1680 | |
| 1681 | put_device(mdp_dev); |
| 1682 | |
| 1683 | /* add the MDP component itself */ |
| 1684 | component_match_add(dev, matchptr, compare_of, |
| 1685 | mdp_dev->of_node); |
| 1686 | } else { |
| 1687 | /* MDP4 */ |
| 1688 | mdp_dev = dev; |
| 1689 | } |
| 1690 | |
| 1691 | ret = add_components_mdp(mdp_dev, matchptr); |
Archit Taneja | 54011e2 | 2016-06-06 13:45:34 +0530 | [diff] [blame] | 1692 | if (ret) |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 1693 | of_platform_depopulate(dev); |
Archit Taneja | 54011e2 | 2016-06-06 13:45:34 +0530 | [diff] [blame] | 1694 | |
| 1695 | return ret; |
Archit Taneja | 7d526fc | 2016-05-19 10:33:57 +0530 | [diff] [blame] | 1696 | } |
| 1697 | |
Archit Taneja | dc3ea26 | 2016-05-19 13:33:52 +0530 | [diff] [blame] | 1698 | /* |
| 1699 | * We don't know what's the best binding to link the gpu with the drm device. |
| 1700 | * Fow now, we just hunt for all the possible gpus that we support, and add them |
| 1701 | * as components. |
| 1702 | */ |
| 1703 | static const struct of_device_id msm_gpu_match[] = { |
| 1704 | { .compatible = "qcom,adreno-3xx" }, |
| 1705 | { .compatible = "qcom,kgsl-3d0" }, |
| 1706 | { }, |
| 1707 | }; |
| 1708 | |
Dhaval Patel | 169bf3a | 2017-04-11 11:00:57 -0700 | [diff] [blame] | 1709 | #ifdef CONFIG_QCOM_KGSL |
| 1710 | static int add_gpu_components(struct device *dev, |
| 1711 | struct component_match **matchptr) |
| 1712 | { |
| 1713 | return 0; |
| 1714 | } |
| 1715 | #else |
Archit Taneja | 7d526fc | 2016-05-19 10:33:57 +0530 | [diff] [blame] | 1716 | static int add_gpu_components(struct device *dev, |
| 1717 | struct component_match **matchptr) |
| 1718 | { |
Archit Taneja | dc3ea26 | 2016-05-19 13:33:52 +0530 | [diff] [blame] | 1719 | struct device_node *np; |
| 1720 | |
| 1721 | np = of_find_matching_node(NULL, msm_gpu_match); |
| 1722 | if (!np) |
| 1723 | return 0; |
| 1724 | |
| 1725 | component_match_add(dev, matchptr, compare_of, np); |
| 1726 | |
| 1727 | of_node_put(np); |
| 1728 | |
| 1729 | return 0; |
Archit Taneja | 7d526fc | 2016-05-19 10:33:57 +0530 | [diff] [blame] | 1730 | } |
Dhaval Patel | 169bf3a | 2017-04-11 11:00:57 -0700 | [diff] [blame] | 1731 | #endif |
Archit Taneja | 7d526fc | 2016-05-19 10:33:57 +0530 | [diff] [blame] | 1732 | |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 1733 | static int msm_drm_bind(struct device *dev) |
Russell King | 8444828 | 2014-04-19 11:20:42 +0100 | [diff] [blame] | 1734 | { |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 1735 | return msm_drm_init(dev, &msm_driver); |
Russell King | 8444828 | 2014-04-19 11:20:42 +0100 | [diff] [blame] | 1736 | } |
| 1737 | |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 1738 | static void msm_drm_unbind(struct device *dev) |
Russell King | 8444828 | 2014-04-19 11:20:42 +0100 | [diff] [blame] | 1739 | { |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 1740 | msm_drm_uninit(dev); |
Russell King | 8444828 | 2014-04-19 11:20:42 +0100 | [diff] [blame] | 1741 | } |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 1742 | |
| 1743 | static const struct component_master_ops msm_drm_ops = { |
| 1744 | .bind = msm_drm_bind, |
| 1745 | .unbind = msm_drm_unbind, |
| 1746 | }; |
Russell King | 8444828 | 2014-04-19 11:20:42 +0100 | [diff] [blame] | 1747 | |
| 1748 | /* |
| 1749 | * Platform driver: |
| 1750 | */ |
| 1751 | |
| 1752 | static int msm_pdev_probe(struct platform_device *pdev) |
| 1753 | { |
Dhaval Patel | 3949f03 | 2016-06-20 16:24:33 -0700 | [diff] [blame] | 1754 | int ret; |
Russell King | 8444828 | 2014-04-19 11:20:42 +0100 | [diff] [blame] | 1755 | struct component_match *match = NULL; |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 1756 | |
Archit Taneja | 7d526fc | 2016-05-19 10:33:57 +0530 | [diff] [blame] | 1757 | ret = add_display_components(&pdev->dev, &match); |
| 1758 | if (ret) |
| 1759 | return ret; |
| 1760 | |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 1761 | ret = add_gpu_components(&pdev->dev, &match); |
| 1762 | if (ret) |
| 1763 | return ret; |
Dhaval Patel | 3949f03 | 2016-06-20 16:24:33 -0700 | [diff] [blame] | 1764 | |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 1765 | pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); |
| 1766 | return component_master_add_with_match(&pdev->dev, &msm_drm_ops, match); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1767 | } |
| 1768 | |
| 1769 | static int msm_pdev_remove(struct platform_device *pdev) |
| 1770 | { |
Lloyd Atkinson | 6f74f40 | 2016-10-04 10:07:36 -0400 | [diff] [blame] | 1771 | component_master_del(&pdev->dev, &msm_drm_ops); |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 1772 | of_platform_depopulate(&pdev->dev); |
| 1773 | |
| 1774 | msm_drm_unbind(&pdev->dev); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1775 | return 0; |
| 1776 | } |
| 1777 | |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 1778 | static const struct of_device_id dt_match[] = { |
Dhaval Patel | 5200c60 | 2017-01-17 15:53:37 -0800 | [diff] [blame] | 1779 | { .compatible = "qcom,mdp4", .data = (void *)4 }, /* MDP4 */ |
| 1780 | { .compatible = "qcom,mdss", .data = (void *)5 }, /* MDP5 MDSS */ |
| 1781 | { .compatible = "qcom,sde-kms", .data = (void *)3 }, /* sde */ |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 1782 | {} |
| 1783 | }; |
| 1784 | MODULE_DEVICE_TABLE(of, dt_match); |
| 1785 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1786 | static struct platform_driver msm_platform_driver = { |
| 1787 | .probe = msm_pdev_probe, |
| 1788 | .remove = msm_pdev_remove, |
| 1789 | .driver = { |
Stephane Viau | aa6ed8b | 2016-07-19 12:59:42 -0400 | [diff] [blame] | 1790 | .name = "msm_drm", |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 1791 | .of_match_table = dt_match, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1792 | .pm = &msm_pm_ops, |
| 1793 | }, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1794 | }; |
| 1795 | |
Stephane Viau | 32f13f6 | 2015-04-29 15:57:29 -0400 | [diff] [blame] | 1796 | #ifdef CONFIG_QCOM_KGSL |
| 1797 | void __init adreno_register(void) |
| 1798 | { |
| 1799 | } |
| 1800 | |
| 1801 | void __exit adreno_unregister(void) |
| 1802 | { |
| 1803 | } |
| 1804 | #endif |
| 1805 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1806 | static int __init msm_drm_register(void) |
| 1807 | { |
| 1808 | DBG("init"); |
Hai Li | d5af49c | 2015-03-26 19:25:17 -0400 | [diff] [blame] | 1809 | msm_dsi_register(); |
Hai Li | 0045398 | 2014-12-12 14:41:17 -0500 | [diff] [blame] | 1810 | msm_edp_register(); |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 1811 | msm_hdmi_register(); |
Rob Clark | bfd28b1 | 2014-09-05 13:06:37 -0400 | [diff] [blame] | 1812 | adreno_register(); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1813 | return platform_driver_register(&msm_platform_driver); |
| 1814 | } |
| 1815 | |
| 1816 | static void __exit msm_drm_unregister(void) |
| 1817 | { |
| 1818 | DBG("fini"); |
| 1819 | platform_driver_unregister(&msm_platform_driver); |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 1820 | msm_hdmi_unregister(); |
Rob Clark | bfd28b1 | 2014-09-05 13:06:37 -0400 | [diff] [blame] | 1821 | adreno_unregister(); |
Hai Li | 0045398 | 2014-12-12 14:41:17 -0500 | [diff] [blame] | 1822 | msm_edp_unregister(); |
Hai Li | d5af49c | 2015-03-26 19:25:17 -0400 | [diff] [blame] | 1823 | msm_dsi_unregister(); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1824 | } |
| 1825 | |
| 1826 | module_init(msm_drm_register); |
| 1827 | module_exit(msm_drm_unregister); |
| 1828 | |
| 1829 | MODULE_AUTHOR("Rob Clark <robdclark@gmail.com"); |
| 1830 | MODULE_DESCRIPTION("MSM DRM Driver"); |
| 1831 | MODULE_LICENSE("GPL"); |