blob: 90757af9bc73ce578831b620d414dba17cf05caf [file] [log] [blame]
Ben Skeggs94580292012-07-06 12:14:00 +10001/*
2 * Copyright 2012 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24
Ben Skeggs77145f12012-07-31 16:16:21 +100025#include <linux/console.h>
Lukas Wunnerc5fd9362015-04-19 17:18:01 +020026#include <linux/delay.h>
Ben Skeggs94580292012-07-06 12:14:00 +100027#include <linux/module.h>
28#include <linux/pci.h>
Dave Airlie5addcf02012-09-10 14:20:51 +100029#include <linux/pm_runtime.h>
30#include <linux/vga_switcheroo.h>
Ben Skeggsfdb751e2014-08-10 04:10:23 +100031
Masahiro Yamadaae956212017-04-24 13:50:29 +090032#include <drm/drmP.h>
33#include <drm/drm_crtc_helper.h>
Ben Skeggsfdb751e2014-08-10 04:10:23 +100034
Ben Skeggsebb945a2012-07-20 08:17:34 +100035#include <core/gpuobj.h>
Ilia Mirkinc33e05a2014-02-13 21:35:14 -050036#include <core/option.h>
Ben Skeggs7974dd12015-08-20 14:54:17 +100037#include <core/pci.h>
38#include <core/tegra.h>
Ben Skeggs94580292012-07-06 12:14:00 +100039
Ben Skeggs04b88672016-05-22 20:35:16 +100040#include <nvif/driver.h>
41
Ben Skeggs923bc412015-11-08 12:23:16 +100042#include <nvif/class.h>
Ben Skeggs845f2722015-11-08 12:16:40 +100043#include <nvif/cl0002.h>
Ben Skeggs8ed17302015-11-08 11:28:26 +100044#include <nvif/cla06f.h>
Ben Skeggs538b2692015-11-08 10:34:50 +100045#include <nvif/if0004.h>
46
Ben Skeggs4dc28132016-05-20 09:22:55 +100047#include "nouveau_drv.h"
Ben Skeggsebb945a2012-07-20 08:17:34 +100048#include "nouveau_dma.h"
Ben Skeggs77145f12012-07-31 16:16:21 +100049#include "nouveau_ttm.h"
50#include "nouveau_gem.h"
Ben Skeggs77145f12012-07-31 16:16:21 +100051#include "nouveau_vga.h"
Martin Peres8d021d72016-08-25 03:57:07 +030052#include "nouveau_led.h"
Ben Skeggsb9ed9192013-10-15 09:44:02 +100053#include "nouveau_hwmon.h"
Ben Skeggs77145f12012-07-31 16:16:21 +100054#include "nouveau_acpi.h"
55#include "nouveau_bios.h"
56#include "nouveau_ioctl.h"
Ben Skeggsebb945a2012-07-20 08:17:34 +100057#include "nouveau_abi16.h"
58#include "nouveau_fbcon.h"
59#include "nouveau_fence.h"
Marcin Slusarz33b903e2013-02-08 21:42:13 +010060#include "nouveau_debugfs.h"
Ben Skeggs27111a22014-08-10 04:10:31 +100061#include "nouveau_usif.h"
Pierre Moreau703fa262014-08-18 22:43:24 +020062#include "nouveau_connector.h"
Alexandre Courbot055a65d2015-01-15 15:29:56 +090063#include "nouveau_platform.h"
Ben Skeggsebb945a2012-07-20 08:17:34 +100064
Ben Skeggs94580292012-07-06 12:14:00 +100065MODULE_PARM_DESC(config, "option string to pass to driver core");
66static char *nouveau_config;
67module_param_named(config, nouveau_config, charp, 0400);
68
69MODULE_PARM_DESC(debug, "debug string to pass to driver core");
70static char *nouveau_debug;
71module_param_named(debug, nouveau_debug, charp, 0400);
72
Ben Skeggsebb945a2012-07-20 08:17:34 +100073MODULE_PARM_DESC(noaccel, "disable kernel/abi16 acceleration");
74static int nouveau_noaccel = 0;
75module_param_named(noaccel, nouveau_noaccel, int, 0400);
76
Ben Skeggs94307382012-10-31 12:11:15 +100077MODULE_PARM_DESC(modeset, "enable driver (default: auto, "
78 "0 = disabled, 1 = enabled, 2 = headless)");
79int nouveau_modeset = -1;
Ben Skeggs77145f12012-07-31 16:16:21 +100080module_param_named(modeset, nouveau_modeset, int, 0400);
81
Dave Airlie5addcf02012-09-10 14:20:51 +100082MODULE_PARM_DESC(runpm, "disable (0), force enable (1), optimus only default (-1)");
Ben Skeggs321f5c52017-06-02 14:38:07 +100083static int nouveau_runtime_pm = -1;
Dave Airlie5addcf02012-09-10 14:20:51 +100084module_param_named(runpm, nouveau_runtime_pm, int, 0400);
85
David Herrmann915b4d12014-08-29 12:12:43 +020086static struct drm_driver driver_stub;
87static struct drm_driver driver_pci;
88static struct drm_driver driver_platform;
Ben Skeggs77145f12012-07-31 16:16:21 +100089
Ben Skeggs94580292012-07-06 12:14:00 +100090static u64
Alexandre Courbot420b9462014-02-17 15:17:26 +090091nouveau_pci_name(struct pci_dev *pdev)
Ben Skeggs94580292012-07-06 12:14:00 +100092{
93 u64 name = (u64)pci_domain_nr(pdev->bus) << 32;
94 name |= pdev->bus->number << 16;
95 name |= PCI_SLOT(pdev->devfn) << 8;
96 return name | PCI_FUNC(pdev->devfn);
97}
98
Alexandre Courbot420b9462014-02-17 15:17:26 +090099static u64
100nouveau_platform_name(struct platform_device *platformdev)
101{
102 return platformdev->id;
103}
104
105static u64
106nouveau_name(struct drm_device *dev)
107{
108 if (dev->pdev)
109 return nouveau_pci_name(dev->pdev);
110 else
Laurent Pinchart76adb462016-12-18 00:01:19 +0200111 return nouveau_platform_name(to_platform_device(dev->dev));
Alexandre Courbot420b9462014-02-17 15:17:26 +0900112}
113
Ben Skeggs94580292012-07-06 12:14:00 +1000114static void
Ben Skeggs20d8a882016-05-18 13:36:34 +1000115nouveau_cli_fini(struct nouveau_cli *cli)
Ben Skeggs94580292012-07-06 12:14:00 +1000116{
Ben Skeggsbe83cd42015-01-14 15:36:34 +1000117 nvkm_vm_ref(NULL, &nvxx_client(&cli->base)->vm, NULL);
Ben Skeggs27111a22014-08-10 04:10:31 +1000118 usif_client_fini(cli);
Ben Skeggs1167c6b2016-05-18 13:57:42 +1000119 nvif_device_fini(&cli->device);
Ben Skeggs20d8a882016-05-18 13:36:34 +1000120 nvif_client_fini(&cli->base);
121}
122
123static int
124nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
125 struct nouveau_cli *cli)
126{
127 u64 device = nouveau_name(drm->dev);
128 int ret;
129
130 snprintf(cli->name, sizeof(cli->name), "%s", sname);
131 cli->dev = drm->dev;
132 mutex_init(&cli->mutex);
133 usif_client_init(cli);
134
Ben Skeggs80e60972016-05-23 11:25:17 +1000135 if (cli == &drm->client) {
136 ret = nvif_driver_init(NULL, nouveau_config, nouveau_debug,
137 cli->name, device, &cli->base);
138 } else {
139 ret = nvif_client_init(&drm->client.base, cli->name, device,
140 &cli->base);
141 }
Ben Skeggs20d8a882016-05-18 13:36:34 +1000142 if (ret) {
143 NV_ERROR(drm, "Client allocation failed: %d\n", ret);
144 goto done;
145 }
146
Ben Skeggs1167c6b2016-05-18 13:57:42 +1000147 ret = nvif_device_init(&cli->base.object, 0, NV_DEVICE,
148 &(struct nv_device_v0) {
149 .device = ~0,
150 }, sizeof(struct nv_device_v0),
151 &cli->device);
152 if (ret) {
153 NV_ERROR(drm, "Device allocation failed: %d\n", ret);
154 goto done;
155 }
156
Ben Skeggs20d8a882016-05-18 13:36:34 +1000157done:
158 if (ret)
159 nouveau_cli_fini(cli);
160 return ret;
Ben Skeggs94580292012-07-06 12:14:00 +1000161}
162
Ben Skeggsebb945a2012-07-20 08:17:34 +1000163static void
164nouveau_accel_fini(struct nouveau_drm *drm)
165{
Ben Skeggsfbd58eb2015-08-20 14:54:22 +1000166 nouveau_channel_idle(drm->channel);
Ben Skeggs0ad72862014-08-10 04:10:22 +1000167 nvif_object_fini(&drm->ntfy);
Ben Skeggsf027f492015-08-20 14:54:17 +1000168 nvkm_gpuobj_del(&drm->notify);
Ben Skeggsfbd58eb2015-08-20 14:54:22 +1000169 nvif_notify_fini(&drm->flip);
Ben Skeggs0ad72862014-08-10 04:10:22 +1000170 nvif_object_fini(&drm->nvsw);
Ben Skeggsfbd58eb2015-08-20 14:54:22 +1000171 nouveau_channel_del(&drm->channel);
172
173 nouveau_channel_idle(drm->cechan);
Ben Skeggs0ad72862014-08-10 04:10:22 +1000174 nvif_object_fini(&drm->ttm.copy);
Ben Skeggsfbd58eb2015-08-20 14:54:22 +1000175 nouveau_channel_del(&drm->cechan);
176
Ben Skeggsebb945a2012-07-20 08:17:34 +1000177 if (drm->fence)
178 nouveau_fence(drm)->dtor(drm);
179}
180
181static void
182nouveau_accel_init(struct nouveau_drm *drm)
183{
Ben Skeggs1167c6b2016-05-18 13:57:42 +1000184 struct nvif_device *device = &drm->client.device;
Ben Skeggs41a63402015-08-20 14:54:16 +1000185 struct nvif_sclass *sclass;
Ben Skeggs49981042012-08-06 19:38:25 +1000186 u32 arg0, arg1;
Ben Skeggs41a63402015-08-20 14:54:16 +1000187 int ret, i, n;
Ben Skeggsebb945a2012-07-20 08:17:34 +1000188
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000189 if (nouveau_noaccel)
Ben Skeggsebb945a2012-07-20 08:17:34 +1000190 return;
191
192 /* initialise synchronisation routines */
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000193 /*XXX: this is crap, but the fence/channel stuff is a little
194 * backwards in some places. this will be fixed.
195 */
Ben Skeggs41a63402015-08-20 14:54:16 +1000196 ret = n = nvif_object_sclass_get(&device->object, &sclass);
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000197 if (ret < 0)
198 return;
199
Ben Skeggs41a63402015-08-20 14:54:16 +1000200 for (ret = -ENOSYS, i = 0; i < n; i++) {
201 switch (sclass[i].oclass) {
Ben Skeggsbbf89062014-08-10 04:10:25 +1000202 case NV03_CHANNEL_DMA:
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000203 ret = nv04_fence_create(drm);
204 break;
Ben Skeggsbbf89062014-08-10 04:10:25 +1000205 case NV10_CHANNEL_DMA:
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000206 ret = nv10_fence_create(drm);
207 break;
Ben Skeggsbbf89062014-08-10 04:10:25 +1000208 case NV17_CHANNEL_DMA:
209 case NV40_CHANNEL_DMA:
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000210 ret = nv17_fence_create(drm);
211 break;
Ben Skeggsbbf89062014-08-10 04:10:25 +1000212 case NV50_CHANNEL_GPFIFO:
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000213 ret = nv50_fence_create(drm);
214 break;
Ben Skeggsbbf89062014-08-10 04:10:25 +1000215 case G82_CHANNEL_GPFIFO:
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000216 ret = nv84_fence_create(drm);
217 break;
Ben Skeggsbbf89062014-08-10 04:10:25 +1000218 case FERMI_CHANNEL_GPFIFO:
219 case KEPLER_CHANNEL_GPFIFO_A:
Ben Skeggs63f8c9b2016-03-11 13:09:28 +1000220 case KEPLER_CHANNEL_GPFIFO_B:
Ben Skeggsa1020af2015-04-14 11:47:24 +1000221 case MAXWELL_CHANNEL_GPFIFO_A:
Ben Skeggse8ff9792016-07-09 10:41:01 +1000222 case PASCAL_CHANNEL_GPFIFO_A:
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000223 ret = nvc0_fence_create(drm);
224 break;
225 default:
226 break;
227 }
228 }
229
Ben Skeggs41a63402015-08-20 14:54:16 +1000230 nvif_object_sclass_put(&sclass);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000231 if (ret) {
232 NV_ERROR(drm, "failed to initialise sync subsystem, %d\n", ret);
233 nouveau_accel_fini(drm);
234 return;
235 }
236
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000237 if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
Ben Skeggs1167c6b2016-05-18 13:57:42 +1000238 ret = nouveau_channel_new(drm, &drm->client.device,
Ben Skeggs1f5ff7f2016-03-11 13:09:28 +1000239 NVA06F_V0_ENGINE_CE0 |
240 NVA06F_V0_ENGINE_CE1,
Ben Skeggsbbf89062014-08-10 04:10:25 +1000241 0, &drm->cechan);
Ben Skeggs49981042012-08-06 19:38:25 +1000242 if (ret)
243 NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
244
Ben Skeggs1f5ff7f2016-03-11 13:09:28 +1000245 arg0 = NVA06F_V0_ENGINE_GR;
Ben Skeggs49469802012-11-22 13:43:55 +1000246 arg1 = 1;
Ben Skeggs00fc6f62013-07-09 14:20:15 +1000247 } else
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000248 if (device->info.chipset >= 0xa3 &&
249 device->info.chipset != 0xaa &&
250 device->info.chipset != 0xac) {
Ben Skeggs1167c6b2016-05-18 13:57:42 +1000251 ret = nouveau_channel_new(drm, &drm->client.device,
Ben Skeggs0ad72862014-08-10 04:10:22 +1000252 NvDmaFB, NvDmaTT, &drm->cechan);
Ben Skeggs00fc6f62013-07-09 14:20:15 +1000253 if (ret)
254 NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
255
256 arg0 = NvDmaFB;
257 arg1 = NvDmaTT;
Ben Skeggs49981042012-08-06 19:38:25 +1000258 } else {
259 arg0 = NvDmaFB;
260 arg1 = NvDmaTT;
261 }
262
Ben Skeggs1167c6b2016-05-18 13:57:42 +1000263 ret = nouveau_channel_new(drm, &drm->client.device,
264 arg0, arg1, &drm->channel);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000265 if (ret) {
266 NV_ERROR(drm, "failed to create kernel channel, %d\n", ret);
267 nouveau_accel_fini(drm);
268 return;
269 }
270
Ben Skeggsa01ca782015-08-20 14:54:15 +1000271 ret = nvif_object_init(&drm->channel->user, NVDRM_NVSW,
Ben Skeggs0ad72862014-08-10 04:10:22 +1000272 nouveau_abi16_swclass(drm), NULL, 0, &drm->nvsw);
Ben Skeggs69a61462013-11-13 10:58:51 +1000273 if (ret == 0) {
Ben Skeggs69a61462013-11-13 10:58:51 +1000274 ret = RING_SPACE(drm->channel, 2);
275 if (ret == 0) {
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000276 if (device->info.family < NV_DEVICE_INFO_V0_FERMI) {
Ben Skeggs69a61462013-11-13 10:58:51 +1000277 BEGIN_NV04(drm->channel, NvSubSw, 0, 1);
278 OUT_RING (drm->channel, NVDRM_NVSW);
279 } else
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000280 if (device->info.family < NV_DEVICE_INFO_V0_KEPLER) {
Ben Skeggs69a61462013-11-13 10:58:51 +1000281 BEGIN_NVC0(drm->channel, FermiSw, 0, 1);
282 OUT_RING (drm->channel, 0x001f0000);
283 }
284 }
Ben Skeggs898a2b32015-08-20 14:54:18 +1000285
286 ret = nvif_notify_init(&drm->nvsw, nouveau_flip_complete,
Ben Skeggs538b2692015-11-08 10:34:50 +1000287 false, NV04_NVSW_NTFY_UEVENT,
288 NULL, 0, 0, &drm->flip);
Ben Skeggs898a2b32015-08-20 14:54:18 +1000289 if (ret == 0)
290 ret = nvif_notify_get(&drm->flip);
291 if (ret) {
292 nouveau_accel_fini(drm);
293 return;
294 }
Ben Skeggs69a61462013-11-13 10:58:51 +1000295 }
296
297 if (ret) {
298 NV_ERROR(drm, "failed to allocate software object, %d\n", ret);
299 nouveau_accel_fini(drm);
300 return;
301 }
302
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000303 if (device->info.family < NV_DEVICE_INFO_V0_FERMI) {
Ben Skeggs1167c6b2016-05-18 13:57:42 +1000304 ret = nvkm_gpuobj_new(nvxx_device(&drm->client.device), 32, 0,
305 false, NULL, &drm->notify);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000306 if (ret) {
307 NV_ERROR(drm, "failed to allocate notifier, %d\n", ret);
308 nouveau_accel_fini(drm);
309 return;
310 }
311
Ben Skeggsa01ca782015-08-20 14:54:15 +1000312 ret = nvif_object_init(&drm->channel->user, NvNotify0,
Ben Skeggs4acfd702014-08-10 04:10:24 +1000313 NV_DMA_IN_MEMORY,
314 &(struct nv_dma_v0) {
315 .target = NV_DMA_V0_TARGET_VRAM,
316 .access = NV_DMA_V0_ACCESS_RDWR,
Ben Skeggsebb945a2012-07-20 08:17:34 +1000317 .start = drm->notify->addr,
318 .limit = drm->notify->addr + 31
Ben Skeggs4acfd702014-08-10 04:10:24 +1000319 }, sizeof(struct nv_dma_v0),
Ben Skeggs0ad72862014-08-10 04:10:22 +1000320 &drm->ntfy);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000321 if (ret) {
322 nouveau_accel_fini(drm);
323 return;
324 }
325 }
326
327
Ben Skeggs49981042012-08-06 19:38:25 +1000328 nouveau_bo_move_init(drm);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000329}
330
Greg Kroah-Hartman56550d92012-12-21 15:09:25 -0800331static int nouveau_drm_probe(struct pci_dev *pdev,
332 const struct pci_device_id *pent)
Ben Skeggs94580292012-07-06 12:14:00 +1000333{
Ben Skeggsbe83cd42015-01-14 15:36:34 +1000334 struct nvkm_device *device;
Ben Skeggsebb945a2012-07-20 08:17:34 +1000335 struct apertures_struct *aper;
336 bool boot = false;
Ben Skeggs94580292012-07-06 12:14:00 +1000337 int ret;
338
Lukas Wunnerb00e5332016-05-31 11:13:27 +0200339 if (vga_switcheroo_client_probe_defer(pdev))
Lukas Wunner98b3a342016-01-11 20:09:20 +0100340 return -EPROBE_DEFER;
341
Ben Skeggs0e67bed2016-07-12 11:57:07 +1000342 /* We need to check that the chipset is supported before booting
343 * fbdev off the hardware, as there's no way to put it back.
344 */
345 ret = nvkm_device_pci_new(pdev, NULL, "error", true, false, 0, &device);
346 if (ret)
347 return ret;
348
349 nvkm_device_del(&device);
350
351 /* Remove conflicting drivers (vesafb, efifb etc). */
Ben Skeggsebb945a2012-07-20 08:17:34 +1000352 aper = alloc_apertures(3);
353 if (!aper)
354 return -ENOMEM;
355
356 aper->ranges[0].base = pci_resource_start(pdev, 1);
357 aper->ranges[0].size = pci_resource_len(pdev, 1);
358 aper->count = 1;
359
360 if (pci_resource_len(pdev, 2)) {
361 aper->ranges[aper->count].base = pci_resource_start(pdev, 2);
362 aper->ranges[aper->count].size = pci_resource_len(pdev, 2);
363 aper->count++;
364 }
365
366 if (pci_resource_len(pdev, 3)) {
367 aper->ranges[aper->count].base = pci_resource_start(pdev, 3);
368 aper->ranges[aper->count].size = pci_resource_len(pdev, 3);
369 aper->count++;
370 }
371
372#ifdef CONFIG_X86
373 boot = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
374#endif
Ben Skeggs771fa0e2014-08-10 04:10:31 +1000375 if (nouveau_modeset != 2)
Daniel Vetter44adece2016-08-10 18:52:34 +0200376 drm_fb_helper_remove_conflicting_framebuffers(aper, "nouveaufb", boot);
Tommi Rantala83ef7772012-11-09 09:19:40 +0000377 kfree(aper);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000378
Ben Skeggs7974dd12015-08-20 14:54:17 +1000379 ret = nvkm_device_pci_new(pdev, nouveau_config, nouveau_debug,
380 true, true, ~0ULL, &device);
Ben Skeggs94580292012-07-06 12:14:00 +1000381 if (ret)
382 return ret;
383
384 pci_set_master(pdev);
385
David Herrmann915b4d12014-08-29 12:12:43 +0200386 ret = drm_get_pci_dev(pdev, pent, &driver_pci);
Ben Skeggs94580292012-07-06 12:14:00 +1000387 if (ret) {
Ben Skeggse781dc82015-08-20 14:54:15 +1000388 nvkm_device_del(&device);
Ben Skeggs94580292012-07-06 12:14:00 +1000389 return ret;
390 }
391
392 return 0;
393}
394
Dave Airlie5addcf02012-09-10 14:20:51 +1000395#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403
396
397static void
Ilia Mirkin46941b02014-02-13 03:39:50 -0500398nouveau_get_hdmi_dev(struct nouveau_drm *drm)
Dave Airlie5addcf02012-09-10 14:20:51 +1000399{
Ilia Mirkin46941b02014-02-13 03:39:50 -0500400 struct pci_dev *pdev = drm->dev->pdev;
Dave Airlie5addcf02012-09-10 14:20:51 +1000401
Alexandre Courbot420b9462014-02-17 15:17:26 +0900402 if (!pdev) {
Alexandre Courbotf2a0ada2016-03-02 19:13:03 +0900403 NV_DEBUG(drm, "not a PCI device; no HDMI\n");
Alexandre Courbot420b9462014-02-17 15:17:26 +0900404 drm->hdmi_device = NULL;
405 return;
406 }
407
Dave Airlie5addcf02012-09-10 14:20:51 +1000408 /* subfunction one is a hdmi audio device? */
409 drm->hdmi_device = pci_get_bus_and_slot((unsigned int)pdev->bus->number,
410 PCI_DEVFN(PCI_SLOT(pdev->devfn), 1));
411
412 if (!drm->hdmi_device) {
Ilia Mirkin46941b02014-02-13 03:39:50 -0500413 NV_DEBUG(drm, "hdmi device not found %d %d %d\n", pdev->bus->number, PCI_SLOT(pdev->devfn), 1);
Dave Airlie5addcf02012-09-10 14:20:51 +1000414 return;
415 }
416
417 if ((drm->hdmi_device->class >> 8) != PCI_CLASS_MULTIMEDIA_HD_AUDIO) {
Ilia Mirkin46941b02014-02-13 03:39:50 -0500418 NV_DEBUG(drm, "possible hdmi device not audio %d\n", drm->hdmi_device->class);
Dave Airlie5addcf02012-09-10 14:20:51 +1000419 pci_dev_put(drm->hdmi_device);
420 drm->hdmi_device = NULL;
421 return;
422 }
423}
424
Marcin Slusarz5b8a43a2012-08-19 23:00:00 +0200425static int
Ben Skeggs94580292012-07-06 12:14:00 +1000426nouveau_drm_load(struct drm_device *dev, unsigned long flags)
427{
Ben Skeggs94580292012-07-06 12:14:00 +1000428 struct nouveau_drm *drm;
429 int ret;
430
Ben Skeggs20d8a882016-05-18 13:36:34 +1000431 if (!(drm = kzalloc(sizeof(*drm), GFP_KERNEL)))
432 return -ENOMEM;
433 dev->dev_private = drm;
434 drm->dev = dev;
435
436 ret = nouveau_cli_init(drm, "DRM", &drm->client);
Ben Skeggs94580292012-07-06 12:14:00 +1000437 if (ret)
438 return ret;
439
Ben Skeggs1167c6b2016-05-18 13:57:42 +1000440 dev->irq_enabled = true;
441
Ben Skeggs989aa5b2015-01-12 12:33:37 +1000442 nvxx_client(&drm->client.base)->debug =
Ben Skeggsbe83cd42015-01-14 15:36:34 +1000443 nvkm_dbgopt(nouveau_debug, "DRM");
Ben Skeggs77145f12012-07-31 16:16:21 +1000444
Ben Skeggs94580292012-07-06 12:14:00 +1000445 INIT_LIST_HEAD(&drm->clients);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000446 spin_lock_init(&drm->tile.lock);
Ben Skeggs94580292012-07-06 12:14:00 +1000447
Ilia Mirkin46941b02014-02-13 03:39:50 -0500448 nouveau_get_hdmi_dev(drm);
Dave Airlie5addcf02012-09-10 14:20:51 +1000449
Ben Skeggs77145f12012-07-31 16:16:21 +1000450 /* workaround an odd issue on nvc1 by disabling the device's
451 * nosnoop capability. hopefully won't cause issues until a
452 * better fix is found - assuming there is one...
453 */
Ben Skeggs1167c6b2016-05-18 13:57:42 +1000454 if (drm->client.device.info.chipset == 0xc1)
455 nvif_mask(&drm->client.device.object, 0x00088080, 0x00000800, 0x00000000);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000456
Ben Skeggs77145f12012-07-31 16:16:21 +1000457 nouveau_vga_init(drm);
Ben Skeggscb75d972012-07-11 10:44:20 +1000458
Ben Skeggs1167c6b2016-05-18 13:57:42 +1000459 if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
460 if (!nvxx_device(&drm->client.device)->mmu) {
Ben Skeggs21002922016-07-09 10:41:01 +1000461 ret = -ENOSYS;
462 goto fail_device;
463 }
464
Ben Skeggs1167c6b2016-05-18 13:57:42 +1000465 ret = nvkm_vm_new(nvxx_device(&drm->client.device),
466 0, (1ULL << 40), 0x1000, NULL,
467 &drm->client.vm);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000468 if (ret)
469 goto fail_device;
Ben Skeggs3ee6f5b2014-08-10 04:10:20 +1000470
Ben Skeggs989aa5b2015-01-12 12:33:37 +1000471 nvxx_client(&drm->client.base)->vm = drm->client.vm;
Ben Skeggsebb945a2012-07-20 08:17:34 +1000472 }
473
474 ret = nouveau_ttm_init(drm);
Ben Skeggs94580292012-07-06 12:14:00 +1000475 if (ret)
Ben Skeggs77145f12012-07-31 16:16:21 +1000476 goto fail_ttm;
Ben Skeggs94580292012-07-06 12:14:00 +1000477
Ben Skeggs77145f12012-07-31 16:16:21 +1000478 ret = nouveau_bios_init(dev);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000479 if (ret)
Ben Skeggs77145f12012-07-31 16:16:21 +1000480 goto fail_bios;
481
Ben Skeggs77145f12012-07-31 16:16:21 +1000482 ret = nouveau_display_create(dev);
483 if (ret)
484 goto fail_dispctor;
485
486 if (dev->mode_config.num_crtc) {
487 ret = nouveau_display_init(dev);
488 if (ret)
489 goto fail_dispinit;
490 }
491
Karol Herbstb126a202015-07-30 11:52:23 +0200492 nouveau_debugfs_init(drm);
Ben Skeggsb9ed9192013-10-15 09:44:02 +1000493 nouveau_hwmon_init(dev);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000494 nouveau_accel_init(drm);
495 nouveau_fbcon_init(dev);
Martin Peres8d021d72016-08-25 03:57:07 +0300496 nouveau_led_init(dev);
Dave Airlie5addcf02012-09-10 14:20:51 +1000497
Ben Skeggs8fa43382017-06-02 14:49:45 +1000498 if (nouveau_pmops_runtime()) {
Dave Airlie5addcf02012-09-10 14:20:51 +1000499 pm_runtime_use_autosuspend(dev->dev);
500 pm_runtime_set_autosuspend_delay(dev->dev, 5000);
501 pm_runtime_set_active(dev->dev);
502 pm_runtime_allow(dev->dev);
503 pm_runtime_mark_last_busy(dev->dev);
504 pm_runtime_put(dev->dev);
Peter Ujfalusi9a2eba32017-05-15 12:04:31 +0300505 } else {
506 /* enable polling for external displays */
507 drm_kms_helper_poll_enable(dev);
Dave Airlie5addcf02012-09-10 14:20:51 +1000508 }
Ben Skeggs94580292012-07-06 12:14:00 +1000509 return 0;
510
Ben Skeggs77145f12012-07-31 16:16:21 +1000511fail_dispinit:
512 nouveau_display_destroy(dev);
513fail_dispctor:
Ben Skeggs77145f12012-07-31 16:16:21 +1000514 nouveau_bios_takedown(dev);
515fail_bios:
Ben Skeggsebb945a2012-07-20 08:17:34 +1000516 nouveau_ttm_fini(drm);
Ben Skeggs77145f12012-07-31 16:16:21 +1000517fail_ttm:
Ben Skeggs77145f12012-07-31 16:16:21 +1000518 nouveau_vga_fini(drm);
Ben Skeggs94580292012-07-06 12:14:00 +1000519fail_device:
Ben Skeggs20d8a882016-05-18 13:36:34 +1000520 nouveau_cli_fini(&drm->client);
521 kfree(drm);
Ben Skeggs94580292012-07-06 12:14:00 +1000522 return ret;
523}
524
Gabriel Krisman Bertazi11b3c202017-01-06 15:57:31 -0200525static void
Ben Skeggs94580292012-07-06 12:14:00 +1000526nouveau_drm_unload(struct drm_device *dev)
527{
Ben Skeggs77145f12012-07-31 16:16:21 +1000528 struct nouveau_drm *drm = nouveau_drm(dev);
Ben Skeggs94580292012-07-06 12:14:00 +1000529
Ben Skeggs8fa43382017-06-02 14:49:45 +1000530 if (nouveau_pmops_runtime()) {
Lukas Wunnerc1b16b42016-06-08 18:47:27 +0200531 pm_runtime_get_sync(dev->dev);
Lukas Wunner55c868a2016-06-08 18:47:27 +0200532 pm_runtime_forbid(dev->dev);
Lukas Wunnerc1b16b42016-06-08 18:47:27 +0200533 }
534
Martin Peres8d021d72016-08-25 03:57:07 +0300535 nouveau_led_fini(dev);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000536 nouveau_fbcon_fini(dev);
537 nouveau_accel_fini(drm);
Ben Skeggsb9ed9192013-10-15 09:44:02 +1000538 nouveau_hwmon_fini(dev);
Karol Herbstb126a202015-07-30 11:52:23 +0200539 nouveau_debugfs_fini(drm);
Ben Skeggs77145f12012-07-31 16:16:21 +1000540
Ben Skeggs94307382012-10-31 12:11:15 +1000541 if (dev->mode_config.num_crtc)
Ben Skeggs3b4c0ab2016-11-04 17:20:35 +1000542 nouveau_display_fini(dev, false);
Ben Skeggs77145f12012-07-31 16:16:21 +1000543 nouveau_display_destroy(dev);
544
Ben Skeggs77145f12012-07-31 16:16:21 +1000545 nouveau_bios_takedown(dev);
Ben Skeggs94580292012-07-06 12:14:00 +1000546
Ben Skeggsebb945a2012-07-20 08:17:34 +1000547 nouveau_ttm_fini(drm);
Ben Skeggs77145f12012-07-31 16:16:21 +1000548 nouveau_vga_fini(drm);
Ben Skeggscb75d972012-07-11 10:44:20 +1000549
Dave Airlie5addcf02012-09-10 14:20:51 +1000550 if (drm->hdmi_device)
551 pci_dev_put(drm->hdmi_device);
Ben Skeggs20d8a882016-05-18 13:36:34 +1000552 nouveau_cli_fini(&drm->client);
553 kfree(drm);
Ben Skeggs94580292012-07-06 12:14:00 +1000554}
555
Alexandre Courbot8ba9ff12014-06-26 14:33:32 +0900556void
557nouveau_drm_device_remove(struct drm_device *dev)
Ben Skeggs94580292012-07-06 12:14:00 +1000558{
Ben Skeggs77145f12012-07-31 16:16:21 +1000559 struct nouveau_drm *drm = nouveau_drm(dev);
Ben Skeggsbe83cd42015-01-14 15:36:34 +1000560 struct nvkm_client *client;
Ben Skeggs76ecea52015-08-20 14:54:15 +1000561 struct nvkm_device *device;
Ben Skeggs77145f12012-07-31 16:16:21 +1000562
Ilia Mirkin7d3428c2014-01-29 19:53:00 -0500563 dev->irq_enabled = false;
Ben Skeggs989aa5b2015-01-12 12:33:37 +1000564 client = nvxx_client(&drm->client.base);
Ben Skeggs4e7e62d2015-08-20 14:54:15 +1000565 device = nvkm_device_find(client->device);
Ben Skeggs77145f12012-07-31 16:16:21 +1000566 drm_put_dev(dev);
567
Ben Skeggse781dc82015-08-20 14:54:15 +1000568 nvkm_device_del(&device);
Ben Skeggs94580292012-07-06 12:14:00 +1000569}
Alexandre Courbot8ba9ff12014-06-26 14:33:32 +0900570
571static void
572nouveau_drm_remove(struct pci_dev *pdev)
573{
574 struct drm_device *dev = pci_get_drvdata(pdev);
575
576 nouveau_drm_device_remove(dev);
577}
Ben Skeggs94580292012-07-06 12:14:00 +1000578
Marcin Slusarzcd897832013-01-27 15:01:55 +0100579static int
Dave Airlie05c63c22014-03-26 14:10:06 +1000580nouveau_do_suspend(struct drm_device *dev, bool runtime)
Ben Skeggs94580292012-07-06 12:14:00 +1000581{
Ben Skeggs77145f12012-07-31 16:16:21 +1000582 struct nouveau_drm *drm = nouveau_drm(dev);
Ben Skeggs94580292012-07-06 12:14:00 +1000583 int ret;
584
Martin Peres8d021d72016-08-25 03:57:07 +0300585 nouveau_led_suspend(dev);
586
Ben Skeggs6fbb7022014-10-02 13:22:27 +1000587 if (dev->mode_config.num_crtc) {
588 NV_INFO(drm, "suspending console...\n");
589 nouveau_fbcon_set_suspend(dev, 1);
Ben Skeggsc52f4fa2013-11-08 14:38:40 +1000590 NV_INFO(drm, "suspending display...\n");
Ben Skeggs6fbb7022014-10-02 13:22:27 +1000591 ret = nouveau_display_suspend(dev, runtime);
Ben Skeggs94307382012-10-31 12:11:15 +1000592 if (ret)
593 return ret;
594 }
Ben Skeggs94580292012-07-06 12:14:00 +1000595
Ben Skeggsc52f4fa2013-11-08 14:38:40 +1000596 NV_INFO(drm, "evicting buffers...\n");
Ben Skeggsebb945a2012-07-20 08:17:34 +1000597 ttm_bo_evict_mm(&drm->ttm.bdev, TTM_PL_VRAM);
598
Ben Skeggsc52f4fa2013-11-08 14:38:40 +1000599 NV_INFO(drm, "waiting for kernel channels to go idle...\n");
Ben Skeggs81dff212013-05-07 08:33:10 +1000600 if (drm->cechan) {
601 ret = nouveau_channel_idle(drm->cechan);
602 if (ret)
Ilia Mirkinf3980dc2014-01-23 02:45:02 -0500603 goto fail_display;
Ben Skeggs81dff212013-05-07 08:33:10 +1000604 }
605
606 if (drm->channel) {
607 ret = nouveau_channel_idle(drm->channel);
608 if (ret)
Ilia Mirkinf3980dc2014-01-23 02:45:02 -0500609 goto fail_display;
Ben Skeggs81dff212013-05-07 08:33:10 +1000610 }
611
Ben Skeggs80e60972016-05-23 11:25:17 +1000612 NV_INFO(drm, "suspending fence...\n");
Ben Skeggsebb945a2012-07-20 08:17:34 +1000613 if (drm->fence && nouveau_fence(drm)->suspend) {
Ilia Mirkinf3980dc2014-01-23 02:45:02 -0500614 if (!nouveau_fence(drm)->suspend(drm)) {
615 ret = -ENOMEM;
616 goto fail_display;
617 }
Ben Skeggsebb945a2012-07-20 08:17:34 +1000618 }
619
Ben Skeggs80e60972016-05-23 11:25:17 +1000620 NV_INFO(drm, "suspending object tree...\n");
Ben Skeggs0ad72862014-08-10 04:10:22 +1000621 ret = nvif_client_suspend(&drm->client.base);
Ben Skeggs94580292012-07-06 12:14:00 +1000622 if (ret)
623 goto fail_client;
624
Ben Skeggs94580292012-07-06 12:14:00 +1000625 return 0;
626
627fail_client:
Ilia Mirkinf3980dc2014-01-23 02:45:02 -0500628 if (drm->fence && nouveau_fence(drm)->resume)
629 nouveau_fence(drm)->resume(drm);
630
631fail_display:
Ben Skeggs94307382012-10-31 12:11:15 +1000632 if (dev->mode_config.num_crtc) {
Ben Skeggsc52f4fa2013-11-08 14:38:40 +1000633 NV_INFO(drm, "resuming display...\n");
Ben Skeggs6fbb7022014-10-02 13:22:27 +1000634 nouveau_display_resume(dev, runtime);
Ben Skeggs94307382012-10-31 12:11:15 +1000635 }
Ben Skeggs94580292012-07-06 12:14:00 +1000636 return ret;
637}
638
Marcin Slusarzcd897832013-01-27 15:01:55 +0100639static int
Ben Skeggs6fbb7022014-10-02 13:22:27 +1000640nouveau_do_resume(struct drm_device *dev, bool runtime)
Dave Airlie2d8b9cc2012-11-02 11:04:28 +1000641{
642 struct nouveau_drm *drm = nouveau_drm(dev);
Dave Airlie2d8b9cc2012-11-02 11:04:28 +1000643
Ben Skeggs80e60972016-05-23 11:25:17 +1000644 NV_INFO(drm, "resuming object tree...\n");
Ben Skeggs0ad72862014-08-10 04:10:22 +1000645 nvif_client_resume(&drm->client.base);
Ben Skeggs94580292012-07-06 12:14:00 +1000646
Ben Skeggs80e60972016-05-23 11:25:17 +1000647 NV_INFO(drm, "resuming fence...\n");
Ben Skeggs81dff212013-05-07 08:33:10 +1000648 if (drm->fence && nouveau_fence(drm)->resume)
649 nouveau_fence(drm)->resume(drm);
650
Ben Skeggs77145f12012-07-31 16:16:21 +1000651 nouveau_run_vbios_init(dev);
Ben Skeggs77145f12012-07-31 16:16:21 +1000652
Ben Skeggs94307382012-10-31 12:11:15 +1000653 if (dev->mode_config.num_crtc) {
Ben Skeggsc52f4fa2013-11-08 14:38:40 +1000654 NV_INFO(drm, "resuming display...\n");
Ben Skeggs6fbb7022014-10-02 13:22:27 +1000655 nouveau_display_resume(dev, runtime);
656 NV_INFO(drm, "resuming console...\n");
657 nouveau_fbcon_set_suspend(dev, 0);
Ben Skeggs94307382012-10-31 12:11:15 +1000658 }
Dave Airlie5addcf02012-09-10 14:20:51 +1000659
Martin Peres8d021d72016-08-25 03:57:07 +0300660 nouveau_led_resume(dev);
661
Ben Skeggs77145f12012-07-31 16:16:21 +1000662 return 0;
Ben Skeggs94580292012-07-06 12:14:00 +1000663}
664
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000665int
666nouveau_pmops_suspend(struct device *dev)
667{
668 struct pci_dev *pdev = to_pci_dev(dev);
669 struct drm_device *drm_dev = pci_get_drvdata(pdev);
670 int ret;
671
672 if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
673 drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
674 return 0;
675
676 ret = nouveau_do_suspend(drm_dev, false);
677 if (ret)
678 return ret;
679
680 pci_save_state(pdev);
681 pci_disable_device(pdev);
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000682 pci_set_power_state(pdev, PCI_D3hot);
Lukas Wunnerc5fd9362015-04-19 17:18:01 +0200683 udelay(200);
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000684 return 0;
685}
686
687int
688nouveau_pmops_resume(struct device *dev)
Dave Airlie2d8b9cc2012-11-02 11:04:28 +1000689{
690 struct pci_dev *pdev = to_pci_dev(dev);
691 struct drm_device *drm_dev = pci_get_drvdata(pdev);
692 int ret;
693
Dave Airlie5addcf02012-09-10 14:20:51 +1000694 if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
695 drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
Dave Airlie2d8b9cc2012-11-02 11:04:28 +1000696 return 0;
697
698 pci_set_power_state(pdev, PCI_D0);
699 pci_restore_state(pdev);
700 ret = pci_enable_device(pdev);
701 if (ret)
702 return ret;
703 pci_set_master(pdev);
704
Hans de Goede0b2fe652016-11-21 17:50:55 +0100705 ret = nouveau_do_resume(drm_dev, false);
706
707 /* Monitors may have been connected / disconnected during suspend */
708 schedule_work(&nouveau_drm(drm_dev)->hpd_work);
709
710 return ret;
Dave Airlie2d8b9cc2012-11-02 11:04:28 +1000711}
712
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000713static int
714nouveau_pmops_freeze(struct device *dev)
Dave Airlie2d8b9cc2012-11-02 11:04:28 +1000715{
716 struct pci_dev *pdev = to_pci_dev(dev);
717 struct drm_device *drm_dev = pci_get_drvdata(pdev);
Ben Skeggs6fbb7022014-10-02 13:22:27 +1000718 return nouveau_do_suspend(drm_dev, false);
Dave Airlie2d8b9cc2012-11-02 11:04:28 +1000719}
720
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000721static int
722nouveau_pmops_thaw(struct device *dev)
Dave Airlie2d8b9cc2012-11-02 11:04:28 +1000723{
724 struct pci_dev *pdev = to_pci_dev(dev);
725 struct drm_device *drm_dev = pci_get_drvdata(pdev);
Ben Skeggs6fbb7022014-10-02 13:22:27 +1000726 return nouveau_do_resume(drm_dev, false);
Dave Airlie2d8b9cc2012-11-02 11:04:28 +1000727}
728
Ben Skeggs321f5c52017-06-02 14:38:07 +1000729bool
Arnd Bergmann54994732017-06-09 12:38:33 +0200730nouveau_pmops_runtime(void)
Ben Skeggs321f5c52017-06-02 14:38:07 +1000731{
732 if (nouveau_runtime_pm == -1)
733 return nouveau_is_optimus() || nouveau_is_v1_dsm();
734 return nouveau_runtime_pm == 1;
735}
736
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000737static int
738nouveau_pmops_runtime_suspend(struct device *dev)
739{
740 struct pci_dev *pdev = to_pci_dev(dev);
741 struct drm_device *drm_dev = pci_get_drvdata(pdev);
742 int ret;
743
Ben Skeggs321f5c52017-06-02 14:38:07 +1000744 if (!nouveau_pmops_runtime()) {
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000745 pm_runtime_forbid(dev);
746 return -EBUSY;
747 }
748
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000749 drm_kms_helper_poll_disable(drm_dev);
750 vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_OFF);
751 nouveau_switcheroo_optimus_dsm();
752 ret = nouveau_do_suspend(drm_dev, true);
753 pci_save_state(pdev);
754 pci_disable_device(pdev);
Dave Airlie8c863942014-12-08 10:33:52 +1000755 pci_ignore_hotplug(pdev);
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000756 pci_set_power_state(pdev, PCI_D3cold);
757 drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
758 return ret;
759}
760
761static int
762nouveau_pmops_runtime_resume(struct device *dev)
763{
764 struct pci_dev *pdev = to_pci_dev(dev);
765 struct drm_device *drm_dev = pci_get_drvdata(pdev);
Ben Skeggs1167c6b2016-05-18 13:57:42 +1000766 struct nvif_device *device = &nouveau_drm(drm_dev)->client.device;
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000767 int ret;
768
Ben Skeggs321f5c52017-06-02 14:38:07 +1000769 if (!nouveau_pmops_runtime()) {
770 pm_runtime_forbid(dev);
771 return -EBUSY;
772 }
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000773
774 pci_set_power_state(pdev, PCI_D0);
775 pci_restore_state(pdev);
776 ret = pci_enable_device(pdev);
777 if (ret)
778 return ret;
779 pci_set_master(pdev);
780
781 ret = nouveau_do_resume(drm_dev, true);
Lyude Paulcae9ff02017-01-11 21:25:23 -0500782
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000783 /* do magic */
Ben Skeggsa01ca782015-08-20 14:54:15 +1000784 nvif_mask(&device->object, 0x088488, (1 << 25), (1 << 25));
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000785 vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON);
786 drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
Hans de Goede0b2fe652016-11-21 17:50:55 +0100787
788 /* Monitors may have been connected / disconnected during suspend */
789 schedule_work(&nouveau_drm(drm_dev)->hpd_work);
790
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000791 return ret;
792}
793
794static int
795nouveau_pmops_runtime_idle(struct device *dev)
796{
797 struct pci_dev *pdev = to_pci_dev(dev);
798 struct drm_device *drm_dev = pci_get_drvdata(pdev);
799 struct nouveau_drm *drm = nouveau_drm(drm_dev);
800 struct drm_crtc *crtc;
801
Ben Skeggs321f5c52017-06-02 14:38:07 +1000802 if (!nouveau_pmops_runtime()) {
Ben Skeggs7bb6d442014-10-02 13:31:00 +1000803 pm_runtime_forbid(dev);
804 return -EBUSY;
805 }
806
807 /* if we have a hdmi audio device - make sure it has a driver loaded */
808 if (drm->hdmi_device) {
809 if (!drm->hdmi_device->driver) {
810 DRM_DEBUG_DRIVER("failing to power off - no HDMI audio driver loaded\n");
811 pm_runtime_mark_last_busy(dev);
812 return -EBUSY;
813 }
814 }
815
816 list_for_each_entry(crtc, &drm->dev->mode_config.crtc_list, head) {
817 if (crtc->enabled) {
818 DRM_DEBUG_DRIVER("failing to power off - crtc active\n");
819 return -EBUSY;
820 }
821 }
822 pm_runtime_mark_last_busy(dev);
823 pm_runtime_autosuspend(dev);
824 /* we don't want the main rpm_idle to call suspend - we want to autosuspend */
825 return 1;
826}
Dave Airlie2d8b9cc2012-11-02 11:04:28 +1000827
Marcin Slusarz5b8a43a2012-08-19 23:00:00 +0200828static int
Ben Skeggsebb945a2012-07-20 08:17:34 +1000829nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
830{
Ben Skeggsebb945a2012-07-20 08:17:34 +1000831 struct nouveau_drm *drm = nouveau_drm(dev);
832 struct nouveau_cli *cli;
Marcin Slusarza2896ce2012-12-09 15:45:21 +0100833 char name[32], tmpname[TASK_COMM_LEN];
Ben Skeggsebb945a2012-07-20 08:17:34 +1000834 int ret;
835
Dave Airlie5addcf02012-09-10 14:20:51 +1000836 /* need to bring up power immediately if opening device */
837 ret = pm_runtime_get_sync(dev->dev);
Alexandre Courbotb6c42852014-02-12 14:00:59 +0900838 if (ret < 0 && ret != -EACCES)
Dave Airlie5addcf02012-09-10 14:20:51 +1000839 return ret;
840
Marcin Slusarza2896ce2012-12-09 15:45:21 +0100841 get_task_comm(tmpname, current);
842 snprintf(name, sizeof(name), "%s[%d]", tmpname, pid_nr(fpriv->pid));
Ben Skeggsfa6df8c2012-09-12 13:09:23 +1000843
Ben Skeggs20d8a882016-05-18 13:36:34 +1000844 if (!(cli = kzalloc(sizeof(*cli), GFP_KERNEL)))
845 return ret;
Alexandre Courbot420b9462014-02-17 15:17:26 +0900846
Ben Skeggs20d8a882016-05-18 13:36:34 +1000847 ret = nouveau_cli_init(drm, name, cli);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000848 if (ret)
Ben Skeggs20d8a882016-05-18 13:36:34 +1000849 goto done;
Ben Skeggsebb945a2012-07-20 08:17:34 +1000850
Ben Skeggs0ad72862014-08-10 04:10:22 +1000851 cli->base.super = false;
852
Ben Skeggs1167c6b2016-05-18 13:57:42 +1000853 if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) {
854 ret = nvkm_vm_new(nvxx_device(&drm->client.device), 0,
855 (1ULL << 40), 0x1000, NULL, &cli->vm);
Ben Skeggs20d8a882016-05-18 13:36:34 +1000856 if (ret)
857 goto done;
Ben Skeggs3ee6f5b2014-08-10 04:10:20 +1000858
Ben Skeggs989aa5b2015-01-12 12:33:37 +1000859 nvxx_client(&cli->base)->vm = cli->vm;
Ben Skeggsebb945a2012-07-20 08:17:34 +1000860 }
861
862 fpriv->driver_priv = cli;
863
864 mutex_lock(&drm->client.mutex);
865 list_add(&cli->head, &drm->clients);
866 mutex_unlock(&drm->client.mutex);
Dave Airlie5addcf02012-09-10 14:20:51 +1000867
Ben Skeggs20d8a882016-05-18 13:36:34 +1000868done:
869 if (ret && cli) {
870 nouveau_cli_fini(cli);
871 kfree(cli);
872 }
873
Dave Airlie5addcf02012-09-10 14:20:51 +1000874 pm_runtime_mark_last_busy(dev->dev);
875 pm_runtime_put_autosuspend(dev->dev);
Dave Airlie5addcf02012-09-10 14:20:51 +1000876 return ret;
Ben Skeggsebb945a2012-07-20 08:17:34 +1000877}
878
Marcin Slusarz5b8a43a2012-08-19 23:00:00 +0200879static void
Daniel Vetterf0e73ff2017-05-08 10:26:30 +0200880nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv)
Ben Skeggsebb945a2012-07-20 08:17:34 +1000881{
882 struct nouveau_cli *cli = nouveau_cli(fpriv);
883 struct nouveau_drm *drm = nouveau_drm(dev);
884
Dave Airlie5addcf02012-09-10 14:20:51 +1000885 pm_runtime_get_sync(dev->dev);
886
Kamil Dudkaac8c7932015-07-15 17:18:15 +0200887 mutex_lock(&cli->mutex);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000888 if (cli->abi16)
889 nouveau_abi16_fini(cli->abi16);
Kamil Dudkaac8c7932015-07-15 17:18:15 +0200890 mutex_unlock(&cli->mutex);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000891
892 mutex_lock(&drm->client.mutex);
893 list_del(&cli->head);
894 mutex_unlock(&drm->client.mutex);
Dave Airlie5addcf02012-09-10 14:20:51 +1000895
Ben Skeggs20d8a882016-05-18 13:36:34 +1000896 nouveau_cli_fini(cli);
897 kfree(cli);
Dave Airlie5addcf02012-09-10 14:20:51 +1000898 pm_runtime_mark_last_busy(dev->dev);
899 pm_runtime_put_autosuspend(dev->dev);
Ben Skeggsebb945a2012-07-20 08:17:34 +1000900}
901
Rob Clarkbaa70942013-08-02 13:27:49 -0400902static const struct drm_ioctl_desc
Ben Skeggs77145f12012-07-31 16:16:21 +1000903nouveau_ioctls[] = {
Daniel Vetterf8c47142015-09-08 13:56:30 +0200904 DRM_IOCTL_DEF_DRV(NOUVEAU_GETPARAM, nouveau_abi16_ioctl_getparam, DRM_AUTH|DRM_RENDER_ALLOW),
905 DRM_IOCTL_DEF_DRV(NOUVEAU_SETPARAM, nouveau_abi16_ioctl_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
906 DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_ALLOC, nouveau_abi16_ioctl_channel_alloc, DRM_AUTH|DRM_RENDER_ALLOW),
907 DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_FREE, nouveau_abi16_ioctl_channel_free, DRM_AUTH|DRM_RENDER_ALLOW),
908 DRM_IOCTL_DEF_DRV(NOUVEAU_GROBJ_ALLOC, nouveau_abi16_ioctl_grobj_alloc, DRM_AUTH|DRM_RENDER_ALLOW),
909 DRM_IOCTL_DEF_DRV(NOUVEAU_NOTIFIEROBJ_ALLOC, nouveau_abi16_ioctl_notifierobj_alloc, DRM_AUTH|DRM_RENDER_ALLOW),
910 DRM_IOCTL_DEF_DRV(NOUVEAU_GPUOBJ_FREE, nouveau_abi16_ioctl_gpuobj_free, DRM_AUTH|DRM_RENDER_ALLOW),
911 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_NEW, nouveau_gem_ioctl_new, DRM_AUTH|DRM_RENDER_ALLOW),
912 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_PUSHBUF, nouveau_gem_ioctl_pushbuf, DRM_AUTH|DRM_RENDER_ALLOW),
913 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_PREP, nouveau_gem_ioctl_cpu_prep, DRM_AUTH|DRM_RENDER_ALLOW),
914 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_FINI, nouveau_gem_ioctl_cpu_fini, DRM_AUTH|DRM_RENDER_ALLOW),
915 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_INFO, nouveau_gem_ioctl_info, DRM_AUTH|DRM_RENDER_ALLOW),
Ben Skeggs77145f12012-07-31 16:16:21 +1000916};
917
Ben Skeggs27111a22014-08-10 04:10:31 +1000918long
919nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
Dave Airlie5addcf02012-09-10 14:20:51 +1000920{
Ben Skeggs27111a22014-08-10 04:10:31 +1000921 struct drm_file *filp = file->private_data;
922 struct drm_device *dev = filp->minor->dev;
Dave Airlie5addcf02012-09-10 14:20:51 +1000923 long ret;
Dave Airlie5addcf02012-09-10 14:20:51 +1000924
925 ret = pm_runtime_get_sync(dev->dev);
Alexandre Courbotb6c42852014-02-12 14:00:59 +0900926 if (ret < 0 && ret != -EACCES)
Dave Airlie5addcf02012-09-10 14:20:51 +1000927 return ret;
928
Ben Skeggs27111a22014-08-10 04:10:31 +1000929 switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) {
930 case DRM_NOUVEAU_NVIF:
931 ret = usif_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
932 break;
933 default:
934 ret = drm_ioctl(file, cmd, arg);
935 break;
936 }
Dave Airlie5addcf02012-09-10 14:20:51 +1000937
938 pm_runtime_mark_last_busy(dev->dev);
939 pm_runtime_put_autosuspend(dev->dev);
940 return ret;
941}
Ben Skeggs27111a22014-08-10 04:10:31 +1000942
Ben Skeggs77145f12012-07-31 16:16:21 +1000943static const struct file_operations
944nouveau_driver_fops = {
945 .owner = THIS_MODULE,
946 .open = drm_open,
947 .release = drm_release,
Dave Airlie5addcf02012-09-10 14:20:51 +1000948 .unlocked_ioctl = nouveau_drm_ioctl,
Ben Skeggs77145f12012-07-31 16:16:21 +1000949 .mmap = nouveau_ttm_mmap,
950 .poll = drm_poll,
Ben Skeggs77145f12012-07-31 16:16:21 +1000951 .read = drm_read,
952#if defined(CONFIG_COMPAT)
953 .compat_ioctl = nouveau_compat_ioctl,
954#endif
955 .llseek = noop_llseek,
956};
957
958static struct drm_driver
David Herrmann915b4d12014-08-29 12:12:43 +0200959driver_stub = {
Ben Skeggs77145f12012-07-31 16:16:21 +1000960 .driver_features =
Peter Antoine0e975982015-06-23 08:18:49 +0100961 DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER |
962 DRIVER_KMS_LEGACY_CONTEXT,
Ben Skeggs77145f12012-07-31 16:16:21 +1000963
964 .load = nouveau_drm_load,
965 .unload = nouveau_drm_unload,
966 .open = nouveau_drm_open,
Ben Skeggs77145f12012-07-31 16:16:21 +1000967 .postclose = nouveau_drm_postclose,
968 .lastclose = nouveau_vga_lastclose,
969
Marcin Slusarz33b903e2013-02-08 21:42:13 +0100970#if defined(CONFIG_DEBUG_FS)
Karol Herbst56c101a2015-07-31 00:35:42 +0200971 .debugfs_init = nouveau_drm_debugfs_init,
Marcin Slusarz33b903e2013-02-08 21:42:13 +0100972#endif
973
Ben Skeggs51cb4b32013-10-03 07:02:29 +1000974 .enable_vblank = nouveau_display_vblank_enable,
975 .disable_vblank = nouveau_display_vblank_disable,
Ben Skeggsd83ef852013-11-14 13:37:49 +1000976 .get_scanout_position = nouveau_display_scanoutpos,
Daniel Vetter1bf6ad62017-05-09 16:03:28 +0200977 .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
Ben Skeggs77145f12012-07-31 16:16:21 +1000978
979 .ioctls = nouveau_ioctls,
Rob Clarkbaa70942013-08-02 13:27:49 -0400980 .num_ioctls = ARRAY_SIZE(nouveau_ioctls),
Ben Skeggs77145f12012-07-31 16:16:21 +1000981 .fops = &nouveau_driver_fops,
982
983 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
984 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
Aaron Plattnerab9ccb92013-01-15 20:47:43 +0000985 .gem_prime_export = drm_gem_prime_export,
986 .gem_prime_import = drm_gem_prime_import,
987 .gem_prime_pin = nouveau_gem_prime_pin,
Maarten Lankhorst3aac4502014-07-01 12:57:26 +0200988 .gem_prime_res_obj = nouveau_gem_prime_res_obj,
Maarten Lankhorst1af7c7d2013-06-27 13:38:19 +0200989 .gem_prime_unpin = nouveau_gem_prime_unpin,
Aaron Plattnerab9ccb92013-01-15 20:47:43 +0000990 .gem_prime_get_sg_table = nouveau_gem_prime_get_sg_table,
991 .gem_prime_import_sg_table = nouveau_gem_prime_import_sg_table,
992 .gem_prime_vmap = nouveau_gem_prime_vmap,
993 .gem_prime_vunmap = nouveau_gem_prime_vunmap,
Ben Skeggs77145f12012-07-31 16:16:21 +1000994
Daniel Vettera51e6ac2016-05-30 19:53:00 +0200995 .gem_free_object_unlocked = nouveau_gem_object_del,
Ben Skeggs77145f12012-07-31 16:16:21 +1000996 .gem_open_object = nouveau_gem_object_open,
997 .gem_close_object = nouveau_gem_object_close,
998
999 .dumb_create = nouveau_display_dumb_create,
1000 .dumb_map_offset = nouveau_display_dumb_map_offset,
Daniel Vetter43387b32013-07-16 09:12:04 +02001001 .dumb_destroy = drm_gem_dumb_destroy,
Ben Skeggs77145f12012-07-31 16:16:21 +10001002
1003 .name = DRIVER_NAME,
1004 .desc = DRIVER_DESC,
1005#ifdef GIT_REVISION
1006 .date = GIT_REVISION,
1007#else
1008 .date = DRIVER_DATE,
1009#endif
1010 .major = DRIVER_MAJOR,
1011 .minor = DRIVER_MINOR,
1012 .patchlevel = DRIVER_PATCHLEVEL,
1013};
1014
Ben Skeggs94580292012-07-06 12:14:00 +10001015static struct pci_device_id
1016nouveau_drm_pci_table[] = {
1017 {
1018 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID),
1019 .class = PCI_BASE_CLASS_DISPLAY << 16,
1020 .class_mask = 0xff << 16,
1021 },
1022 {
1023 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA_SGS, PCI_ANY_ID),
1024 .class = PCI_BASE_CLASS_DISPLAY << 16,
1025 .class_mask = 0xff << 16,
1026 },
1027 {}
1028};
1029
Pierre Moreau703fa262014-08-18 22:43:24 +02001030static void nouveau_display_options(void)
1031{
1032 DRM_DEBUG_DRIVER("Loading Nouveau with parameters:\n");
1033
1034 DRM_DEBUG_DRIVER("... tv_disable : %d\n", nouveau_tv_disable);
1035 DRM_DEBUG_DRIVER("... ignorelid : %d\n", nouveau_ignorelid);
1036 DRM_DEBUG_DRIVER("... duallink : %d\n", nouveau_duallink);
1037 DRM_DEBUG_DRIVER("... nofbaccel : %d\n", nouveau_nofbaccel);
1038 DRM_DEBUG_DRIVER("... config : %s\n", nouveau_config);
1039 DRM_DEBUG_DRIVER("... debug : %s\n", nouveau_debug);
1040 DRM_DEBUG_DRIVER("... noaccel : %d\n", nouveau_noaccel);
1041 DRM_DEBUG_DRIVER("... modeset : %d\n", nouveau_modeset);
1042 DRM_DEBUG_DRIVER("... runpm : %d\n", nouveau_runtime_pm);
1043 DRM_DEBUG_DRIVER("... vram_pushbuf : %d\n", nouveau_vram_pushbuf);
Ben Skeggsf3a8b662016-11-04 11:44:21 +10001044 DRM_DEBUG_DRIVER("... hdmimhz : %d\n", nouveau_hdmimhz);
Pierre Moreau703fa262014-08-18 22:43:24 +02001045}
1046
Dave Airlie2d8b9cc2012-11-02 11:04:28 +10001047static const struct dev_pm_ops nouveau_pm_ops = {
1048 .suspend = nouveau_pmops_suspend,
1049 .resume = nouveau_pmops_resume,
1050 .freeze = nouveau_pmops_freeze,
1051 .thaw = nouveau_pmops_thaw,
1052 .poweroff = nouveau_pmops_freeze,
1053 .restore = nouveau_pmops_resume,
Dave Airlie5addcf02012-09-10 14:20:51 +10001054 .runtime_suspend = nouveau_pmops_runtime_suspend,
1055 .runtime_resume = nouveau_pmops_runtime_resume,
1056 .runtime_idle = nouveau_pmops_runtime_idle,
Dave Airlie2d8b9cc2012-11-02 11:04:28 +10001057};
1058
Ben Skeggs94580292012-07-06 12:14:00 +10001059static struct pci_driver
1060nouveau_drm_pci_driver = {
1061 .name = "nouveau",
1062 .id_table = nouveau_drm_pci_table,
1063 .probe = nouveau_drm_probe,
1064 .remove = nouveau_drm_remove,
Dave Airlie2d8b9cc2012-11-02 11:04:28 +10001065 .driver.pm = &nouveau_pm_ops,
Ben Skeggs94580292012-07-06 12:14:00 +10001066};
1067
Alexandre Courbot8ba9ff12014-06-26 14:33:32 +09001068struct drm_device *
Alexandre Courbote396ecd2015-09-04 19:59:31 +09001069nouveau_platform_device_create(const struct nvkm_device_tegra_func *func,
1070 struct platform_device *pdev,
Ben Skeggs47b25052015-08-20 14:54:15 +10001071 struct nvkm_device **pdevice)
Alexandre Courbot420b9462014-02-17 15:17:26 +09001072{
Alexandre Courbot8ba9ff12014-06-26 14:33:32 +09001073 struct drm_device *drm;
1074 int err;
Alexandre Courbot420b9462014-02-17 15:17:26 +09001075
Alexandre Courbote396ecd2015-09-04 19:59:31 +09001076 err = nvkm_device_tegra_new(func, pdev, nouveau_config, nouveau_debug,
Ben Skeggs7974dd12015-08-20 14:54:17 +10001077 true, true, ~0ULL, pdevice);
Alexandre Courbot8ba9ff12014-06-26 14:33:32 +09001078 if (err)
Ben Skeggse781dc82015-08-20 14:54:15 +10001079 goto err_free;
Alexandre Courbot420b9462014-02-17 15:17:26 +09001080
David Herrmann915b4d12014-08-29 12:12:43 +02001081 drm = drm_dev_alloc(&driver_platform, &pdev->dev);
Tom Gundersen0f288602016-09-21 16:59:19 +02001082 if (IS_ERR(drm)) {
1083 err = PTR_ERR(drm);
Alexandre Courbot8ba9ff12014-06-26 14:33:32 +09001084 goto err_free;
Alexandre Courbot420b9462014-02-17 15:17:26 +09001085 }
1086
Alexandre Courbot8ba9ff12014-06-26 14:33:32 +09001087 platform_set_drvdata(pdev, drm);
1088
1089 return drm;
1090
1091err_free:
Ben Skeggse781dc82015-08-20 14:54:15 +10001092 nvkm_device_del(pdevice);
Alexandre Courbot8ba9ff12014-06-26 14:33:32 +09001093
1094 return ERR_PTR(err);
Alexandre Courbot420b9462014-02-17 15:17:26 +09001095}
1096
Ben Skeggs94580292012-07-06 12:14:00 +10001097static int __init
1098nouveau_drm_init(void)
1099{
David Herrmann915b4d12014-08-29 12:12:43 +02001100 driver_pci = driver_stub;
1101 driver_pci.set_busid = drm_pci_set_busid;
1102 driver_platform = driver_stub;
David Herrmann915b4d12014-08-29 12:12:43 +02001103
Pierre Moreau703fa262014-08-18 22:43:24 +02001104 nouveau_display_options();
1105
Ben Skeggs77145f12012-07-31 16:16:21 +10001106 if (nouveau_modeset == -1) {
Ben Skeggs77145f12012-07-31 16:16:21 +10001107 if (vgacon_text_force())
1108 nouveau_modeset = 0;
Ben Skeggs77145f12012-07-31 16:16:21 +10001109 }
1110
1111 if (!nouveau_modeset)
1112 return 0;
1113
Alexandre Courbot055a65d2015-01-15 15:29:56 +09001114#ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER
1115 platform_driver_register(&nouveau_platform_driver);
1116#endif
1117
Ben Skeggs77145f12012-07-31 16:16:21 +10001118 nouveau_register_dsm_handler();
Pierre Moreaudb1a0ae22016-12-08 00:57:08 +01001119 nouveau_backlight_ctor();
David Herrmann915b4d12014-08-29 12:12:43 +02001120 return drm_pci_init(&driver_pci, &nouveau_drm_pci_driver);
Ben Skeggs94580292012-07-06 12:14:00 +10001121}
1122
1123static void __exit
1124nouveau_drm_exit(void)
1125{
Ben Skeggs77145f12012-07-31 16:16:21 +10001126 if (!nouveau_modeset)
1127 return;
1128
David Herrmann915b4d12014-08-29 12:12:43 +02001129 drm_pci_exit(&driver_pci, &nouveau_drm_pci_driver);
Pierre Moreaudb1a0ae22016-12-08 00:57:08 +01001130 nouveau_backlight_dtor();
Ben Skeggs77145f12012-07-31 16:16:21 +10001131 nouveau_unregister_dsm_handler();
Alexandre Courbot055a65d2015-01-15 15:29:56 +09001132
1133#ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER
1134 platform_driver_unregister(&nouveau_platform_driver);
1135#endif
Ben Skeggs94580292012-07-06 12:14:00 +10001136}
1137
1138module_init(nouveau_drm_init);
1139module_exit(nouveau_drm_exit);
1140
1141MODULE_DEVICE_TABLE(pci, nouveau_drm_pci_table);
Ben Skeggs77145f12012-07-31 16:16:21 +10001142MODULE_AUTHOR(DRIVER_AUTHOR);
1143MODULE_DESCRIPTION(DRIVER_DESC);
Ben Skeggs94580292012-07-06 12:14:00 +10001144MODULE_LICENSE("GPL and additional rights");