nouveau_drm.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  1. /*
  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. #include <linux/console.h>
  25. #include <linux/delay.h>
  26. #include <linux/module.h>
  27. #include <linux/pci.h>
  28. #include <linux/pm_runtime.h>
  29. #include <linux/vga_switcheroo.h>
  30. #include <drm/drmP.h>
  31. #include <drm/drm_crtc_helper.h>
  32. #include <core/gpuobj.h>
  33. #include <core/option.h>
  34. #include <core/pci.h>
  35. #include <core/tegra.h>
  36. #include <nvif/driver.h>
  37. #include <nvif/fifo.h>
  38. #include <nvif/user.h>
  39. #include <nvif/class.h>
  40. #include <nvif/cl0002.h>
  41. #include <nvif/cla06f.h>
  42. #include <nvif/if0004.h>
  43. #include "nouveau_drv.h"
  44. #include "nouveau_dma.h"
  45. #include "nouveau_ttm.h"
  46. #include "nouveau_gem.h"
  47. #include "nouveau_vga.h"
  48. #include "nouveau_led.h"
  49. #include "nouveau_hwmon.h"
  50. #include "nouveau_acpi.h"
  51. #include "nouveau_bios.h"
  52. #include "nouveau_ioctl.h"
  53. #include "nouveau_abi16.h"
  54. #include "nouveau_fbcon.h"
  55. #include "nouveau_fence.h"
  56. #include "nouveau_debugfs.h"
  57. #include "nouveau_usif.h"
  58. #include "nouveau_connector.h"
  59. #include "nouveau_platform.h"
  60. MODULE_PARM_DESC(config, "option string to pass to driver core");
  61. static char *nouveau_config;
  62. module_param_named(config, nouveau_config, charp, 0400);
  63. MODULE_PARM_DESC(debug, "debug string to pass to driver core");
  64. static char *nouveau_debug;
  65. module_param_named(debug, nouveau_debug, charp, 0400);
  66. MODULE_PARM_DESC(noaccel, "disable kernel/abi16 acceleration");
  67. static int nouveau_noaccel = 0;
  68. module_param_named(noaccel, nouveau_noaccel, int, 0400);
  69. MODULE_PARM_DESC(modeset, "enable driver (default: auto, "
  70. "0 = disabled, 1 = enabled, 2 = headless)");
  71. int nouveau_modeset = -1;
  72. module_param_named(modeset, nouveau_modeset, int, 0400);
  73. MODULE_PARM_DESC(atomic, "Expose atomic ioctl (default: disabled)");
  74. static int nouveau_atomic = 0;
  75. module_param_named(atomic, nouveau_atomic, int, 0400);
  76. MODULE_PARM_DESC(runpm, "disable (0), force enable (1), optimus only default (-1)");
  77. static int nouveau_runtime_pm = -1;
  78. module_param_named(runpm, nouveau_runtime_pm, int, 0400);
  79. static struct drm_driver driver_stub;
  80. static struct drm_driver driver_pci;
  81. static struct drm_driver driver_platform;
  82. static u64
  83. nouveau_pci_name(struct pci_dev *pdev)
  84. {
  85. u64 name = (u64)pci_domain_nr(pdev->bus) << 32;
  86. name |= pdev->bus->number << 16;
  87. name |= PCI_SLOT(pdev->devfn) << 8;
  88. return name | PCI_FUNC(pdev->devfn);
  89. }
  90. static u64
  91. nouveau_platform_name(struct platform_device *platformdev)
  92. {
  93. return platformdev->id;
  94. }
  95. static u64
  96. nouveau_name(struct drm_device *dev)
  97. {
  98. if (dev->pdev)
  99. return nouveau_pci_name(dev->pdev);
  100. else
  101. return nouveau_platform_name(to_platform_device(dev->dev));
  102. }
  103. static inline bool
  104. nouveau_cli_work_ready(struct dma_fence *fence)
  105. {
  106. if (!dma_fence_is_signaled(fence))
  107. return false;
  108. dma_fence_put(fence);
  109. return true;
  110. }
  111. static void
  112. nouveau_cli_work(struct work_struct *w)
  113. {
  114. struct nouveau_cli *cli = container_of(w, typeof(*cli), work);
  115. struct nouveau_cli_work *work, *wtmp;
  116. mutex_lock(&cli->lock);
  117. list_for_each_entry_safe(work, wtmp, &cli->worker, head) {
  118. if (!work->fence || nouveau_cli_work_ready(work->fence)) {
  119. list_del(&work->head);
  120. work->func(work);
  121. }
  122. }
  123. mutex_unlock(&cli->lock);
  124. }
  125. static void
  126. nouveau_cli_work_fence(struct dma_fence *fence, struct dma_fence_cb *cb)
  127. {
  128. struct nouveau_cli_work *work = container_of(cb, typeof(*work), cb);
  129. schedule_work(&work->cli->work);
  130. }
  131. void
  132. nouveau_cli_work_queue(struct nouveau_cli *cli, struct dma_fence *fence,
  133. struct nouveau_cli_work *work)
  134. {
  135. work->fence = dma_fence_get(fence);
  136. work->cli = cli;
  137. mutex_lock(&cli->lock);
  138. list_add_tail(&work->head, &cli->worker);
  139. if (dma_fence_add_callback(fence, &work->cb, nouveau_cli_work_fence))
  140. nouveau_cli_work_fence(fence, &work->cb);
  141. mutex_unlock(&cli->lock);
  142. }
  143. static void
  144. nouveau_cli_fini(struct nouveau_cli *cli)
  145. {
  146. /* All our channels are dead now, which means all the fences they
  147. * own are signalled, and all callback functions have been called.
  148. *
  149. * So, after flushing the workqueue, there should be nothing left.
  150. */
  151. flush_work(&cli->work);
  152. WARN_ON(!list_empty(&cli->worker));
  153. usif_client_fini(cli);
  154. nouveau_vmm_fini(&cli->vmm);
  155. nvif_mmu_fini(&cli->mmu);
  156. nvif_device_fini(&cli->device);
  157. mutex_lock(&cli->drm->master.lock);
  158. nvif_client_fini(&cli->base);
  159. mutex_unlock(&cli->drm->master.lock);
  160. }
  161. static int
  162. nouveau_cli_init(struct nouveau_drm *drm, const char *sname,
  163. struct nouveau_cli *cli)
  164. {
  165. static const struct nvif_mclass
  166. mems[] = {
  167. { NVIF_CLASS_MEM_GF100, -1 },
  168. { NVIF_CLASS_MEM_NV50 , -1 },
  169. { NVIF_CLASS_MEM_NV04 , -1 },
  170. {}
  171. };
  172. static const struct nvif_mclass
  173. mmus[] = {
  174. { NVIF_CLASS_MMU_GF100, -1 },
  175. { NVIF_CLASS_MMU_NV50 , -1 },
  176. { NVIF_CLASS_MMU_NV04 , -1 },
  177. {}
  178. };
  179. static const struct nvif_mclass
  180. vmms[] = {
  181. { NVIF_CLASS_VMM_GP100, -1 },
  182. { NVIF_CLASS_VMM_GM200, -1 },
  183. { NVIF_CLASS_VMM_GF100, -1 },
  184. { NVIF_CLASS_VMM_NV50 , -1 },
  185. { NVIF_CLASS_VMM_NV04 , -1 },
  186. {}
  187. };
  188. u64 device = nouveau_name(drm->dev);
  189. int ret;
  190. snprintf(cli->name, sizeof(cli->name), "%s", sname);
  191. cli->drm = drm;
  192. mutex_init(&cli->mutex);
  193. usif_client_init(cli);
  194. INIT_WORK(&cli->work, nouveau_cli_work);
  195. INIT_LIST_HEAD(&cli->worker);
  196. mutex_init(&cli->lock);
  197. if (cli == &drm->master) {
  198. ret = nvif_driver_init(NULL, nouveau_config, nouveau_debug,
  199. cli->name, device, &cli->base);
  200. } else {
  201. mutex_lock(&drm->master.lock);
  202. ret = nvif_client_init(&drm->master.base, cli->name, device,
  203. &cli->base);
  204. mutex_unlock(&drm->master.lock);
  205. }
  206. if (ret) {
  207. NV_PRINTK(err, cli, "Client allocation failed: %d\n", ret);
  208. goto done;
  209. }
  210. ret = nvif_device_init(&cli->base.object, 0, NV_DEVICE,
  211. &(struct nv_device_v0) {
  212. .device = ~0,
  213. }, sizeof(struct nv_device_v0),
  214. &cli->device);
  215. if (ret) {
  216. NV_PRINTK(err, cli, "Device allocation failed: %d\n", ret);
  217. goto done;
  218. }
  219. ret = nvif_mclass(&cli->device.object, mmus);
  220. if (ret < 0) {
  221. NV_PRINTK(err, cli, "No supported MMU class\n");
  222. goto done;
  223. }
  224. ret = nvif_mmu_init(&cli->device.object, mmus[ret].oclass, &cli->mmu);
  225. if (ret) {
  226. NV_PRINTK(err, cli, "MMU allocation failed: %d\n", ret);
  227. goto done;
  228. }
  229. ret = nvif_mclass(&cli->mmu.object, vmms);
  230. if (ret < 0) {
  231. NV_PRINTK(err, cli, "No supported VMM class\n");
  232. goto done;
  233. }
  234. ret = nouveau_vmm_init(cli, vmms[ret].oclass, &cli->vmm);
  235. if (ret) {
  236. NV_PRINTK(err, cli, "VMM allocation failed: %d\n", ret);
  237. goto done;
  238. }
  239. ret = nvif_mclass(&cli->mmu.object, mems);
  240. if (ret < 0) {
  241. NV_PRINTK(err, cli, "No supported MEM class\n");
  242. goto done;
  243. }
  244. cli->mem = &mems[ret];
  245. return 0;
  246. done:
  247. if (ret)
  248. nouveau_cli_fini(cli);
  249. return ret;
  250. }
  251. static void
  252. nouveau_accel_fini(struct nouveau_drm *drm)
  253. {
  254. nouveau_channel_idle(drm->channel);
  255. nvif_object_fini(&drm->ntfy);
  256. nvkm_gpuobj_del(&drm->notify);
  257. nvif_notify_fini(&drm->flip);
  258. nvif_object_fini(&drm->nvsw);
  259. nouveau_channel_del(&drm->channel);
  260. nouveau_channel_idle(drm->cechan);
  261. nvif_object_fini(&drm->ttm.copy);
  262. nouveau_channel_del(&drm->cechan);
  263. if (drm->fence)
  264. nouveau_fence(drm)->dtor(drm);
  265. }
  266. static void
  267. nouveau_accel_init(struct nouveau_drm *drm)
  268. {
  269. struct nvif_device *device = &drm->client.device;
  270. struct nvif_sclass *sclass;
  271. u32 arg0, arg1;
  272. int ret, i, n;
  273. if (nouveau_noaccel)
  274. return;
  275. ret = nouveau_channels_init(drm);
  276. if (ret)
  277. return;
  278. if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_VOLTA) {
  279. ret = nvif_user_init(device);
  280. if (ret)
  281. return;
  282. }
  283. /* initialise synchronisation routines */
  284. /*XXX: this is crap, but the fence/channel stuff is a little
  285. * backwards in some places. this will be fixed.
  286. */
  287. ret = n = nvif_object_sclass_get(&device->object, &sclass);
  288. if (ret < 0)
  289. return;
  290. for (ret = -ENOSYS, i = 0; i < n; i++) {
  291. switch (sclass[i].oclass) {
  292. case NV03_CHANNEL_DMA:
  293. ret = nv04_fence_create(drm);
  294. break;
  295. case NV10_CHANNEL_DMA:
  296. ret = nv10_fence_create(drm);
  297. break;
  298. case NV17_CHANNEL_DMA:
  299. case NV40_CHANNEL_DMA:
  300. ret = nv17_fence_create(drm);
  301. break;
  302. case NV50_CHANNEL_GPFIFO:
  303. ret = nv50_fence_create(drm);
  304. break;
  305. case G82_CHANNEL_GPFIFO:
  306. ret = nv84_fence_create(drm);
  307. break;
  308. case FERMI_CHANNEL_GPFIFO:
  309. case KEPLER_CHANNEL_GPFIFO_A:
  310. case KEPLER_CHANNEL_GPFIFO_B:
  311. case MAXWELL_CHANNEL_GPFIFO_A:
  312. case PASCAL_CHANNEL_GPFIFO_A:
  313. case VOLTA_CHANNEL_GPFIFO_A:
  314. ret = nvc0_fence_create(drm);
  315. break;
  316. default:
  317. break;
  318. }
  319. }
  320. nvif_object_sclass_put(&sclass);
  321. if (ret) {
  322. NV_ERROR(drm, "failed to initialise sync subsystem, %d\n", ret);
  323. nouveau_accel_fini(drm);
  324. return;
  325. }
  326. if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
  327. ret = nouveau_channel_new(drm, &drm->client.device,
  328. nvif_fifo_runlist_ce(device), 0,
  329. &drm->cechan);
  330. if (ret)
  331. NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
  332. arg0 = nvif_fifo_runlist(device, NV_DEVICE_INFO_ENGINE_GR);
  333. arg1 = 1;
  334. } else
  335. if (device->info.chipset >= 0xa3 &&
  336. device->info.chipset != 0xaa &&
  337. device->info.chipset != 0xac) {
  338. ret = nouveau_channel_new(drm, &drm->client.device,
  339. NvDmaFB, NvDmaTT, &drm->cechan);
  340. if (ret)
  341. NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
  342. arg0 = NvDmaFB;
  343. arg1 = NvDmaTT;
  344. } else {
  345. arg0 = NvDmaFB;
  346. arg1 = NvDmaTT;
  347. }
  348. ret = nouveau_channel_new(drm, &drm->client.device,
  349. arg0, arg1, &drm->channel);
  350. if (ret) {
  351. NV_ERROR(drm, "failed to create kernel channel, %d\n", ret);
  352. nouveau_accel_fini(drm);
  353. return;
  354. }
  355. if (device->info.family < NV_DEVICE_INFO_V0_TESLA) {
  356. ret = nvif_object_init(&drm->channel->user, NVDRM_NVSW,
  357. nouveau_abi16_swclass(drm), NULL, 0,
  358. &drm->nvsw);
  359. if (ret == 0) {
  360. ret = RING_SPACE(drm->channel, 2);
  361. if (ret == 0) {
  362. BEGIN_NV04(drm->channel, NvSubSw, 0, 1);
  363. OUT_RING (drm->channel, drm->nvsw.handle);
  364. }
  365. ret = nvif_notify_init(&drm->nvsw,
  366. nouveau_flip_complete,
  367. false, NV04_NVSW_NTFY_UEVENT,
  368. NULL, 0, 0, &drm->flip);
  369. if (ret == 0)
  370. ret = nvif_notify_get(&drm->flip);
  371. if (ret) {
  372. nouveau_accel_fini(drm);
  373. return;
  374. }
  375. }
  376. if (ret) {
  377. NV_ERROR(drm, "failed to allocate sw class, %d\n", ret);
  378. nouveau_accel_fini(drm);
  379. return;
  380. }
  381. }
  382. if (device->info.family < NV_DEVICE_INFO_V0_FERMI) {
  383. ret = nvkm_gpuobj_new(nvxx_device(&drm->client.device), 32, 0,
  384. false, NULL, &drm->notify);
  385. if (ret) {
  386. NV_ERROR(drm, "failed to allocate notifier, %d\n", ret);
  387. nouveau_accel_fini(drm);
  388. return;
  389. }
  390. ret = nvif_object_init(&drm->channel->user, NvNotify0,
  391. NV_DMA_IN_MEMORY,
  392. &(struct nv_dma_v0) {
  393. .target = NV_DMA_V0_TARGET_VRAM,
  394. .access = NV_DMA_V0_ACCESS_RDWR,
  395. .start = drm->notify->addr,
  396. .limit = drm->notify->addr + 31
  397. }, sizeof(struct nv_dma_v0),
  398. &drm->ntfy);
  399. if (ret) {
  400. nouveau_accel_fini(drm);
  401. return;
  402. }
  403. }
  404. nouveau_bo_move_init(drm);
  405. }
  406. static int nouveau_drm_probe(struct pci_dev *pdev,
  407. const struct pci_device_id *pent)
  408. {
  409. struct nvkm_device *device;
  410. struct apertures_struct *aper;
  411. bool boot = false;
  412. int ret;
  413. if (vga_switcheroo_client_probe_defer(pdev))
  414. return -EPROBE_DEFER;
  415. /* We need to check that the chipset is supported before booting
  416. * fbdev off the hardware, as there's no way to put it back.
  417. */
  418. ret = nvkm_device_pci_new(pdev, NULL, "error", true, false, 0, &device);
  419. if (ret)
  420. return ret;
  421. nvkm_device_del(&device);
  422. /* Remove conflicting drivers (vesafb, efifb etc). */
  423. aper = alloc_apertures(3);
  424. if (!aper)
  425. return -ENOMEM;
  426. aper->ranges[0].base = pci_resource_start(pdev, 1);
  427. aper->ranges[0].size = pci_resource_len(pdev, 1);
  428. aper->count = 1;
  429. if (pci_resource_len(pdev, 2)) {
  430. aper->ranges[aper->count].base = pci_resource_start(pdev, 2);
  431. aper->ranges[aper->count].size = pci_resource_len(pdev, 2);
  432. aper->count++;
  433. }
  434. if (pci_resource_len(pdev, 3)) {
  435. aper->ranges[aper->count].base = pci_resource_start(pdev, 3);
  436. aper->ranges[aper->count].size = pci_resource_len(pdev, 3);
  437. aper->count++;
  438. }
  439. #ifdef CONFIG_X86
  440. boot = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
  441. #endif
  442. if (nouveau_modeset != 2)
  443. drm_fb_helper_remove_conflicting_framebuffers(aper, "nouveaufb", boot);
  444. kfree(aper);
  445. ret = nvkm_device_pci_new(pdev, nouveau_config, nouveau_debug,
  446. true, true, ~0ULL, &device);
  447. if (ret)
  448. return ret;
  449. pci_set_master(pdev);
  450. if (nouveau_atomic)
  451. driver_pci.driver_features |= DRIVER_ATOMIC;
  452. ret = drm_get_pci_dev(pdev, pent, &driver_pci);
  453. if (ret) {
  454. nvkm_device_del(&device);
  455. return ret;
  456. }
  457. return 0;
  458. }
  459. static int
  460. nouveau_drm_load(struct drm_device *dev, unsigned long flags)
  461. {
  462. struct nouveau_drm *drm;
  463. int ret;
  464. if (!(drm = kzalloc(sizeof(*drm), GFP_KERNEL)))
  465. return -ENOMEM;
  466. dev->dev_private = drm;
  467. drm->dev = dev;
  468. ret = nouveau_cli_init(drm, "DRM-master", &drm->master);
  469. if (ret)
  470. return ret;
  471. ret = nouveau_cli_init(drm, "DRM", &drm->client);
  472. if (ret)
  473. return ret;
  474. dev->irq_enabled = true;
  475. nvxx_client(&drm->client.base)->debug =
  476. nvkm_dbgopt(nouveau_debug, "DRM");
  477. INIT_LIST_HEAD(&drm->clients);
  478. spin_lock_init(&drm->tile.lock);
  479. /* workaround an odd issue on nvc1 by disabling the device's
  480. * nosnoop capability. hopefully won't cause issues until a
  481. * better fix is found - assuming there is one...
  482. */
  483. if (drm->client.device.info.chipset == 0xc1)
  484. nvif_mask(&drm->client.device.object, 0x00088080, 0x00000800, 0x00000000);
  485. nouveau_vga_init(drm);
  486. ret = nouveau_ttm_init(drm);
  487. if (ret)
  488. goto fail_ttm;
  489. ret = nouveau_bios_init(dev);
  490. if (ret)
  491. goto fail_bios;
  492. ret = nouveau_display_create(dev);
  493. if (ret)
  494. goto fail_dispctor;
  495. if (dev->mode_config.num_crtc) {
  496. ret = nouveau_display_init(dev);
  497. if (ret)
  498. goto fail_dispinit;
  499. }
  500. nouveau_debugfs_init(drm);
  501. nouveau_hwmon_init(dev);
  502. nouveau_accel_init(drm);
  503. nouveau_fbcon_init(dev);
  504. nouveau_led_init(dev);
  505. if (nouveau_pmops_runtime()) {
  506. pm_runtime_use_autosuspend(dev->dev);
  507. pm_runtime_set_autosuspend_delay(dev->dev, 5000);
  508. pm_runtime_set_active(dev->dev);
  509. pm_runtime_allow(dev->dev);
  510. pm_runtime_mark_last_busy(dev->dev);
  511. pm_runtime_put(dev->dev);
  512. }
  513. return 0;
  514. fail_dispinit:
  515. nouveau_display_destroy(dev);
  516. fail_dispctor:
  517. nouveau_bios_takedown(dev);
  518. fail_bios:
  519. nouveau_ttm_fini(drm);
  520. fail_ttm:
  521. nouveau_vga_fini(drm);
  522. nouveau_cli_fini(&drm->client);
  523. nouveau_cli_fini(&drm->master);
  524. kfree(drm);
  525. return ret;
  526. }
  527. static void
  528. nouveau_drm_unload(struct drm_device *dev)
  529. {
  530. struct nouveau_drm *drm = nouveau_drm(dev);
  531. if (nouveau_pmops_runtime()) {
  532. pm_runtime_get_sync(dev->dev);
  533. pm_runtime_forbid(dev->dev);
  534. }
  535. nouveau_led_fini(dev);
  536. nouveau_fbcon_fini(dev);
  537. nouveau_accel_fini(drm);
  538. nouveau_hwmon_fini(dev);
  539. nouveau_debugfs_fini(drm);
  540. if (dev->mode_config.num_crtc)
  541. nouveau_display_fini(dev, false, false);
  542. nouveau_display_destroy(dev);
  543. nouveau_bios_takedown(dev);
  544. nouveau_ttm_fini(drm);
  545. nouveau_vga_fini(drm);
  546. nouveau_cli_fini(&drm->client);
  547. nouveau_cli_fini(&drm->master);
  548. kfree(drm);
  549. }
  550. void
  551. nouveau_drm_device_remove(struct drm_device *dev)
  552. {
  553. struct nouveau_drm *drm = nouveau_drm(dev);
  554. struct nvkm_client *client;
  555. struct nvkm_device *device;
  556. dev->irq_enabled = false;
  557. client = nvxx_client(&drm->client.base);
  558. device = nvkm_device_find(client->device);
  559. drm_put_dev(dev);
  560. nvkm_device_del(&device);
  561. }
  562. static void
  563. nouveau_drm_remove(struct pci_dev *pdev)
  564. {
  565. struct drm_device *dev = pci_get_drvdata(pdev);
  566. nouveau_drm_device_remove(dev);
  567. }
  568. static int
  569. nouveau_do_suspend(struct drm_device *dev, bool runtime)
  570. {
  571. struct nouveau_drm *drm = nouveau_drm(dev);
  572. int ret;
  573. nouveau_led_suspend(dev);
  574. if (dev->mode_config.num_crtc) {
  575. NV_DEBUG(drm, "suspending console...\n");
  576. nouveau_fbcon_set_suspend(dev, 1);
  577. NV_DEBUG(drm, "suspending display...\n");
  578. ret = nouveau_display_suspend(dev, runtime);
  579. if (ret)
  580. return ret;
  581. }
  582. NV_DEBUG(drm, "evicting buffers...\n");
  583. ttm_bo_evict_mm(&drm->ttm.bdev, TTM_PL_VRAM);
  584. NV_DEBUG(drm, "waiting for kernel channels to go idle...\n");
  585. if (drm->cechan) {
  586. ret = nouveau_channel_idle(drm->cechan);
  587. if (ret)
  588. goto fail_display;
  589. }
  590. if (drm->channel) {
  591. ret = nouveau_channel_idle(drm->channel);
  592. if (ret)
  593. goto fail_display;
  594. }
  595. NV_DEBUG(drm, "suspending fence...\n");
  596. if (drm->fence && nouveau_fence(drm)->suspend) {
  597. if (!nouveau_fence(drm)->suspend(drm)) {
  598. ret = -ENOMEM;
  599. goto fail_display;
  600. }
  601. }
  602. NV_DEBUG(drm, "suspending object tree...\n");
  603. ret = nvif_client_suspend(&drm->master.base);
  604. if (ret)
  605. goto fail_client;
  606. return 0;
  607. fail_client:
  608. if (drm->fence && nouveau_fence(drm)->resume)
  609. nouveau_fence(drm)->resume(drm);
  610. fail_display:
  611. if (dev->mode_config.num_crtc) {
  612. NV_DEBUG(drm, "resuming display...\n");
  613. nouveau_display_resume(dev, runtime);
  614. }
  615. return ret;
  616. }
  617. static int
  618. nouveau_do_resume(struct drm_device *dev, bool runtime)
  619. {
  620. struct nouveau_drm *drm = nouveau_drm(dev);
  621. NV_DEBUG(drm, "resuming object tree...\n");
  622. nvif_client_resume(&drm->master.base);
  623. NV_DEBUG(drm, "resuming fence...\n");
  624. if (drm->fence && nouveau_fence(drm)->resume)
  625. nouveau_fence(drm)->resume(drm);
  626. nouveau_run_vbios_init(dev);
  627. if (dev->mode_config.num_crtc) {
  628. NV_DEBUG(drm, "resuming display...\n");
  629. nouveau_display_resume(dev, runtime);
  630. NV_DEBUG(drm, "resuming console...\n");
  631. nouveau_fbcon_set_suspend(dev, 0);
  632. }
  633. nouveau_led_resume(dev);
  634. return 0;
  635. }
  636. int
  637. nouveau_pmops_suspend(struct device *dev)
  638. {
  639. struct pci_dev *pdev = to_pci_dev(dev);
  640. struct drm_device *drm_dev = pci_get_drvdata(pdev);
  641. int ret;
  642. if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
  643. drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
  644. return 0;
  645. ret = nouveau_do_suspend(drm_dev, false);
  646. if (ret)
  647. return ret;
  648. pci_save_state(pdev);
  649. pci_disable_device(pdev);
  650. pci_set_power_state(pdev, PCI_D3hot);
  651. udelay(200);
  652. return 0;
  653. }
  654. int
  655. nouveau_pmops_resume(struct device *dev)
  656. {
  657. struct pci_dev *pdev = to_pci_dev(dev);
  658. struct drm_device *drm_dev = pci_get_drvdata(pdev);
  659. int ret;
  660. if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
  661. drm_dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
  662. return 0;
  663. pci_set_power_state(pdev, PCI_D0);
  664. pci_restore_state(pdev);
  665. ret = pci_enable_device(pdev);
  666. if (ret)
  667. return ret;
  668. pci_set_master(pdev);
  669. ret = nouveau_do_resume(drm_dev, false);
  670. /* Monitors may have been connected / disconnected during suspend */
  671. schedule_work(&nouveau_drm(drm_dev)->hpd_work);
  672. return ret;
  673. }
  674. static int
  675. nouveau_pmops_freeze(struct device *dev)
  676. {
  677. struct pci_dev *pdev = to_pci_dev(dev);
  678. struct drm_device *drm_dev = pci_get_drvdata(pdev);
  679. return nouveau_do_suspend(drm_dev, false);
  680. }
  681. static int
  682. nouveau_pmops_thaw(struct device *dev)
  683. {
  684. struct pci_dev *pdev = to_pci_dev(dev);
  685. struct drm_device *drm_dev = pci_get_drvdata(pdev);
  686. return nouveau_do_resume(drm_dev, false);
  687. }
  688. bool
  689. nouveau_pmops_runtime(void)
  690. {
  691. if (nouveau_runtime_pm == -1)
  692. return nouveau_is_optimus() || nouveau_is_v1_dsm();
  693. return nouveau_runtime_pm == 1;
  694. }
  695. static int
  696. nouveau_pmops_runtime_suspend(struct device *dev)
  697. {
  698. struct pci_dev *pdev = to_pci_dev(dev);
  699. struct drm_device *drm_dev = pci_get_drvdata(pdev);
  700. int ret;
  701. if (!nouveau_pmops_runtime()) {
  702. pm_runtime_forbid(dev);
  703. return -EBUSY;
  704. }
  705. nouveau_switcheroo_optimus_dsm();
  706. ret = nouveau_do_suspend(drm_dev, true);
  707. pci_save_state(pdev);
  708. pci_disable_device(pdev);
  709. pci_ignore_hotplug(pdev);
  710. pci_set_power_state(pdev, PCI_D3cold);
  711. drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
  712. return ret;
  713. }
  714. static int
  715. nouveau_pmops_runtime_resume(struct device *dev)
  716. {
  717. struct pci_dev *pdev = to_pci_dev(dev);
  718. struct drm_device *drm_dev = pci_get_drvdata(pdev);
  719. struct nvif_device *device = &nouveau_drm(drm_dev)->client.device;
  720. int ret;
  721. if (!nouveau_pmops_runtime()) {
  722. pm_runtime_forbid(dev);
  723. return -EBUSY;
  724. }
  725. pci_set_power_state(pdev, PCI_D0);
  726. pci_restore_state(pdev);
  727. ret = pci_enable_device(pdev);
  728. if (ret)
  729. return ret;
  730. pci_set_master(pdev);
  731. ret = nouveau_do_resume(drm_dev, true);
  732. /* do magic */
  733. nvif_mask(&device->object, 0x088488, (1 << 25), (1 << 25));
  734. drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
  735. /* Monitors may have been connected / disconnected during suspend */
  736. schedule_work(&nouveau_drm(drm_dev)->hpd_work);
  737. return ret;
  738. }
  739. static int
  740. nouveau_pmops_runtime_idle(struct device *dev)
  741. {
  742. if (!nouveau_pmops_runtime()) {
  743. pm_runtime_forbid(dev);
  744. return -EBUSY;
  745. }
  746. pm_runtime_mark_last_busy(dev);
  747. pm_runtime_autosuspend(dev);
  748. /* we don't want the main rpm_idle to call suspend - we want to autosuspend */
  749. return 1;
  750. }
  751. static int
  752. nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
  753. {
  754. struct nouveau_drm *drm = nouveau_drm(dev);
  755. struct nouveau_cli *cli;
  756. char name[32], tmpname[TASK_COMM_LEN];
  757. int ret;
  758. /* need to bring up power immediately if opening device */
  759. ret = pm_runtime_get_sync(dev->dev);
  760. if (ret < 0 && ret != -EACCES)
  761. return ret;
  762. get_task_comm(tmpname, current);
  763. snprintf(name, sizeof(name), "%s[%d]", tmpname, pid_nr(fpriv->pid));
  764. if (!(cli = kzalloc(sizeof(*cli), GFP_KERNEL))) {
  765. ret = -ENOMEM;
  766. goto done;
  767. }
  768. ret = nouveau_cli_init(drm, name, cli);
  769. if (ret)
  770. goto done;
  771. cli->base.super = false;
  772. fpriv->driver_priv = cli;
  773. mutex_lock(&drm->client.mutex);
  774. list_add(&cli->head, &drm->clients);
  775. mutex_unlock(&drm->client.mutex);
  776. done:
  777. if (ret && cli) {
  778. nouveau_cli_fini(cli);
  779. kfree(cli);
  780. }
  781. pm_runtime_mark_last_busy(dev->dev);
  782. pm_runtime_put_autosuspend(dev->dev);
  783. return ret;
  784. }
  785. static void
  786. nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv)
  787. {
  788. struct nouveau_cli *cli = nouveau_cli(fpriv);
  789. struct nouveau_drm *drm = nouveau_drm(dev);
  790. pm_runtime_get_sync(dev->dev);
  791. mutex_lock(&cli->mutex);
  792. if (cli->abi16)
  793. nouveau_abi16_fini(cli->abi16);
  794. mutex_unlock(&cli->mutex);
  795. mutex_lock(&drm->client.mutex);
  796. list_del(&cli->head);
  797. mutex_unlock(&drm->client.mutex);
  798. nouveau_cli_fini(cli);
  799. kfree(cli);
  800. pm_runtime_mark_last_busy(dev->dev);
  801. pm_runtime_put_autosuspend(dev->dev);
  802. }
  803. static const struct drm_ioctl_desc
  804. nouveau_ioctls[] = {
  805. DRM_IOCTL_DEF_DRV(NOUVEAU_GETPARAM, nouveau_abi16_ioctl_getparam, DRM_AUTH|DRM_RENDER_ALLOW),
  806. DRM_IOCTL_DEF_DRV(NOUVEAU_SETPARAM, nouveau_abi16_ioctl_setparam, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  807. DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_ALLOC, nouveau_abi16_ioctl_channel_alloc, DRM_AUTH|DRM_RENDER_ALLOW),
  808. DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_FREE, nouveau_abi16_ioctl_channel_free, DRM_AUTH|DRM_RENDER_ALLOW),
  809. DRM_IOCTL_DEF_DRV(NOUVEAU_GROBJ_ALLOC, nouveau_abi16_ioctl_grobj_alloc, DRM_AUTH|DRM_RENDER_ALLOW),
  810. DRM_IOCTL_DEF_DRV(NOUVEAU_NOTIFIEROBJ_ALLOC, nouveau_abi16_ioctl_notifierobj_alloc, DRM_AUTH|DRM_RENDER_ALLOW),
  811. DRM_IOCTL_DEF_DRV(NOUVEAU_GPUOBJ_FREE, nouveau_abi16_ioctl_gpuobj_free, DRM_AUTH|DRM_RENDER_ALLOW),
  812. DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_NEW, nouveau_gem_ioctl_new, DRM_AUTH|DRM_RENDER_ALLOW),
  813. DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_PUSHBUF, nouveau_gem_ioctl_pushbuf, DRM_AUTH|DRM_RENDER_ALLOW),
  814. DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_PREP, nouveau_gem_ioctl_cpu_prep, DRM_AUTH|DRM_RENDER_ALLOW),
  815. DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_FINI, nouveau_gem_ioctl_cpu_fini, DRM_AUTH|DRM_RENDER_ALLOW),
  816. DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_INFO, nouveau_gem_ioctl_info, DRM_AUTH|DRM_RENDER_ALLOW),
  817. };
  818. long
  819. nouveau_drm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  820. {
  821. struct drm_file *filp = file->private_data;
  822. struct drm_device *dev = filp->minor->dev;
  823. long ret;
  824. ret = pm_runtime_get_sync(dev->dev);
  825. if (ret < 0 && ret != -EACCES)
  826. return ret;
  827. switch (_IOC_NR(cmd) - DRM_COMMAND_BASE) {
  828. case DRM_NOUVEAU_NVIF:
  829. ret = usif_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
  830. break;
  831. default:
  832. ret = drm_ioctl(file, cmd, arg);
  833. break;
  834. }
  835. pm_runtime_mark_last_busy(dev->dev);
  836. pm_runtime_put_autosuspend(dev->dev);
  837. return ret;
  838. }
  839. static const struct file_operations
  840. nouveau_driver_fops = {
  841. .owner = THIS_MODULE,
  842. .open = drm_open,
  843. .release = drm_release,
  844. .unlocked_ioctl = nouveau_drm_ioctl,
  845. .mmap = nouveau_ttm_mmap,
  846. .poll = drm_poll,
  847. .read = drm_read,
  848. #if defined(CONFIG_COMPAT)
  849. .compat_ioctl = nouveau_compat_ioctl,
  850. #endif
  851. .llseek = noop_llseek,
  852. };
  853. static struct drm_driver
  854. driver_stub = {
  855. .driver_features =
  856. DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER |
  857. DRIVER_KMS_LEGACY_CONTEXT,
  858. .load = nouveau_drm_load,
  859. .unload = nouveau_drm_unload,
  860. .open = nouveau_drm_open,
  861. .postclose = nouveau_drm_postclose,
  862. .lastclose = nouveau_vga_lastclose,
  863. #if defined(CONFIG_DEBUG_FS)
  864. .debugfs_init = nouveau_drm_debugfs_init,
  865. #endif
  866. .enable_vblank = nouveau_display_vblank_enable,
  867. .disable_vblank = nouveau_display_vblank_disable,
  868. .get_scanout_position = nouveau_display_scanoutpos,
  869. .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos,
  870. .ioctls = nouveau_ioctls,
  871. .num_ioctls = ARRAY_SIZE(nouveau_ioctls),
  872. .fops = &nouveau_driver_fops,
  873. .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  874. .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  875. .gem_prime_export = drm_gem_prime_export,
  876. .gem_prime_import = drm_gem_prime_import,
  877. .gem_prime_pin = nouveau_gem_prime_pin,
  878. .gem_prime_res_obj = nouveau_gem_prime_res_obj,
  879. .gem_prime_unpin = nouveau_gem_prime_unpin,
  880. .gem_prime_get_sg_table = nouveau_gem_prime_get_sg_table,
  881. .gem_prime_import_sg_table = nouveau_gem_prime_import_sg_table,
  882. .gem_prime_vmap = nouveau_gem_prime_vmap,
  883. .gem_prime_vunmap = nouveau_gem_prime_vunmap,
  884. .gem_free_object_unlocked = nouveau_gem_object_del,
  885. .gem_open_object = nouveau_gem_object_open,
  886. .gem_close_object = nouveau_gem_object_close,
  887. .dumb_create = nouveau_display_dumb_create,
  888. .dumb_map_offset = nouveau_display_dumb_map_offset,
  889. .name = DRIVER_NAME,
  890. .desc = DRIVER_DESC,
  891. #ifdef GIT_REVISION
  892. .date = GIT_REVISION,
  893. #else
  894. .date = DRIVER_DATE,
  895. #endif
  896. .major = DRIVER_MAJOR,
  897. .minor = DRIVER_MINOR,
  898. .patchlevel = DRIVER_PATCHLEVEL,
  899. };
  900. static struct pci_device_id
  901. nouveau_drm_pci_table[] = {
  902. {
  903. PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID),
  904. .class = PCI_BASE_CLASS_DISPLAY << 16,
  905. .class_mask = 0xff << 16,
  906. },
  907. {
  908. PCI_DEVICE(PCI_VENDOR_ID_NVIDIA_SGS, PCI_ANY_ID),
  909. .class = PCI_BASE_CLASS_DISPLAY << 16,
  910. .class_mask = 0xff << 16,
  911. },
  912. {}
  913. };
  914. static void nouveau_display_options(void)
  915. {
  916. DRM_DEBUG_DRIVER("Loading Nouveau with parameters:\n");
  917. DRM_DEBUG_DRIVER("... tv_disable : %d\n", nouveau_tv_disable);
  918. DRM_DEBUG_DRIVER("... ignorelid : %d\n", nouveau_ignorelid);
  919. DRM_DEBUG_DRIVER("... duallink : %d\n", nouveau_duallink);
  920. DRM_DEBUG_DRIVER("... nofbaccel : %d\n", nouveau_nofbaccel);
  921. DRM_DEBUG_DRIVER("... config : %s\n", nouveau_config);
  922. DRM_DEBUG_DRIVER("... debug : %s\n", nouveau_debug);
  923. DRM_DEBUG_DRIVER("... noaccel : %d\n", nouveau_noaccel);
  924. DRM_DEBUG_DRIVER("... modeset : %d\n", nouveau_modeset);
  925. DRM_DEBUG_DRIVER("... runpm : %d\n", nouveau_runtime_pm);
  926. DRM_DEBUG_DRIVER("... vram_pushbuf : %d\n", nouveau_vram_pushbuf);
  927. DRM_DEBUG_DRIVER("... hdmimhz : %d\n", nouveau_hdmimhz);
  928. }
  929. static const struct dev_pm_ops nouveau_pm_ops = {
  930. .suspend = nouveau_pmops_suspend,
  931. .resume = nouveau_pmops_resume,
  932. .freeze = nouveau_pmops_freeze,
  933. .thaw = nouveau_pmops_thaw,
  934. .poweroff = nouveau_pmops_freeze,
  935. .restore = nouveau_pmops_resume,
  936. .runtime_suspend = nouveau_pmops_runtime_suspend,
  937. .runtime_resume = nouveau_pmops_runtime_resume,
  938. .runtime_idle = nouveau_pmops_runtime_idle,
  939. };
  940. static struct pci_driver
  941. nouveau_drm_pci_driver = {
  942. .name = "nouveau",
  943. .id_table = nouveau_drm_pci_table,
  944. .probe = nouveau_drm_probe,
  945. .remove = nouveau_drm_remove,
  946. .driver.pm = &nouveau_pm_ops,
  947. };
  948. struct drm_device *
  949. nouveau_platform_device_create(const struct nvkm_device_tegra_func *func,
  950. struct platform_device *pdev,
  951. struct nvkm_device **pdevice)
  952. {
  953. struct drm_device *drm;
  954. int err;
  955. err = nvkm_device_tegra_new(func, pdev, nouveau_config, nouveau_debug,
  956. true, true, ~0ULL, pdevice);
  957. if (err)
  958. goto err_free;
  959. drm = drm_dev_alloc(&driver_platform, &pdev->dev);
  960. if (IS_ERR(drm)) {
  961. err = PTR_ERR(drm);
  962. goto err_free;
  963. }
  964. platform_set_drvdata(pdev, drm);
  965. return drm;
  966. err_free:
  967. nvkm_device_del(pdevice);
  968. return ERR_PTR(err);
  969. }
  970. static int __init
  971. nouveau_drm_init(void)
  972. {
  973. driver_pci = driver_stub;
  974. driver_platform = driver_stub;
  975. nouveau_display_options();
  976. if (nouveau_modeset == -1) {
  977. if (vgacon_text_force())
  978. nouveau_modeset = 0;
  979. }
  980. if (!nouveau_modeset)
  981. return 0;
  982. #ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER
  983. platform_driver_register(&nouveau_platform_driver);
  984. #endif
  985. nouveau_register_dsm_handler();
  986. nouveau_backlight_ctor();
  987. #ifdef CONFIG_PCI
  988. return pci_register_driver(&nouveau_drm_pci_driver);
  989. #else
  990. return 0;
  991. #endif
  992. }
  993. static void __exit
  994. nouveau_drm_exit(void)
  995. {
  996. if (!nouveau_modeset)
  997. return;
  998. #ifdef CONFIG_PCI
  999. pci_unregister_driver(&nouveau_drm_pci_driver);
  1000. #endif
  1001. nouveau_backlight_dtor();
  1002. nouveau_unregister_dsm_handler();
  1003. #ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER
  1004. platform_driver_unregister(&nouveau_platform_driver);
  1005. #endif
  1006. }
  1007. module_init(nouveau_drm_init);
  1008. module_exit(nouveau_drm_exit);
  1009. MODULE_DEVICE_TABLE(pci, nouveau_drm_pci_table);
  1010. MODULE_AUTHOR(DRIVER_AUTHOR);
  1011. MODULE_DESCRIPTION(DRIVER_DESC);
  1012. MODULE_LICENSE("GPL and additional rights");