File drivers/gpu/alga/amd/si/drv.c changed (mode: 100644) (index 592cb32..93f009f) |
11 |
11 |
#include <linux/module.h> |
#include <linux/module.h> |
12 |
12 |
#include <linux/cdev.h> |
#include <linux/cdev.h> |
13 |
13 |
#include <linux/fs.h> |
#include <linux/fs.h> |
|
14 |
|
#include <linux/idr.h> |
14 |
15 |
|
|
15 |
16 |
#include <alga/rng_mng.h> |
#include <alga/rng_mng.h> |
16 |
17 |
#include <alga/pixel_fmts.h> |
#include <alga/pixel_fmts.h> |
|
33 |
34 |
#include "bus/hdp.h" |
#include "bus/hdp.h" |
34 |
35 |
#include "bus/bif.h" |
#include "bus/bif.h" |
35 |
36 |
|
|
|
37 |
|
#define GPUS_MAX 256 |
|
38 |
|
static DEFINE_IDA(ida); |
|
39 |
|
|
36 |
40 |
static struct class *class; |
static struct class *class; |
37 |
41 |
|
|
38 |
42 |
static struct atb_dev adev; |
static struct atb_dev adev; |
|
... |
... |
static void extern_wr32(struct device *dev, u32 val, unsigned of) |
90 |
94 |
wr32(pdev, val, of); |
wr32(pdev, val, of); |
91 |
95 |
} |
} |
92 |
96 |
|
|
93 |
|
static void * __init rom_copy_get(struct pci_dev *dev) |
|
|
97 |
|
static void *rom_copy_get(struct pci_dev *dev) |
94 |
98 |
{ |
{ |
95 |
99 |
void __iomem *rom; |
void __iomem *rom; |
96 |
100 |
void *rom_copy; |
void *rom_copy; |
|
... |
... |
static void bif_mc_mem_reqs_ena(struct pci_dev *dev) |
129 |
133 |
bif_hdp_ena(dev); |
bif_hdp_ena(dev); |
130 |
134 |
} |
} |
131 |
135 |
|
|
132 |
|
static int __init bars_map(struct pci_dev *dev) |
|
|
136 |
|
static int bars_map(struct pci_dev *dev) |
133 |
137 |
{ |
{ |
134 |
138 |
struct dev_drv_data *dd; |
struct dev_drv_data *dd; |
135 |
139 |
dd = pci_get_drvdata(dev); |
dd = pci_get_drvdata(dev); |
|
... |
... |
static void cfg_init(struct pci_dev *dev) |
188 |
192 |
gpu_cfg_init(dev); |
gpu_cfg_init(dev); |
189 |
193 |
} |
} |
190 |
194 |
|
|
191 |
|
static int __init probe(struct pci_dev *dev, const struct pci_device_id *id) |
|
|
195 |
|
static int probe(struct pci_dev *dev, const struct pci_device_id *id) |
192 |
196 |
{ |
{ |
193 |
197 |
int r; |
int r; |
194 |
198 |
struct dev_drv_data *dd; |
struct dev_drv_data *dd; |
|
... |
... |
static int __init probe(struct pci_dev *dev, const struct pci_device_id *id) |
413 |
417 |
/*--------------------------------------------------------------------*/ |
/*--------------------------------------------------------------------*/ |
414 |
418 |
/* userland interface setup */ |
/* userland interface setup */ |
415 |
419 |
cdev_init(&dd->si_cdev, &fops); |
cdev_init(&dd->si_cdev, &fops); |
416 |
|
r = cdev_add(&dd->si_cdev, devt, 1); |
|
|
420 |
|
|
|
421 |
|
r = ida_simple_get(&ida, 0, GPUS_MAX, GFP_KERNEL); |
|
422 |
|
if (r < 0) { |
|
423 |
|
if (r == -ENOMEM) { |
|
424 |
|
dev_err(&dev->dev, "no memory for minor\n"); |
|
425 |
|
} else if (r == -ENOSPC) { |
|
426 |
|
dev_err(&dev->dev, "no more room for new minor\n"); |
|
427 |
|
} else { |
|
428 |
|
dev_err(&dev->dev, "minor allocation failed\n"); |
|
429 |
|
} |
|
430 |
|
goto err_shutdown_dce6; |
|
431 |
|
} |
|
432 |
|
dd->minor=(unsigned int)r; |
|
433 |
|
|
|
434 |
|
r = cdev_add(&dd->si_cdev, MKDEV(MAJOR(devt_region), dd->minor), 1); |
417 |
435 |
if (r) { |
if (r) { |
418 |
436 |
dev_err(&dev->dev, "cannot add register char device\n"); |
dev_err(&dev->dev, "cannot add register char device\n"); |
419 |
|
goto err_shutdown_dce6; |
|
|
437 |
|
goto err_free_minor; |
420 |
438 |
} |
} |
421 |
439 |
|
|
422 |
440 |
dd->si_dev = device_create(class, &dev->dev, dd->si_cdev.dev, NULL, |
dd->si_dev = device_create(class, &dev->dev, dd->si_cdev.dev, NULL, |
423 |
|
"si0"); |
|
|
441 |
|
"si%u", dd->minor); |
424 |
442 |
if (IS_ERR(dd->si_dev)) { |
if (IS_ERR(dd->si_dev)) { |
425 |
443 |
dev_err(&dev->dev, "cannot create userspace char device\n"); |
dev_err(&dev->dev, "cannot create userspace char device\n"); |
426 |
444 |
goto err_cdev_del; |
goto err_cdev_del; |
|
... |
... |
static int __init probe(struct pci_dev *dev, const struct pci_device_id *id) |
433 |
451 |
err_cdev_del: |
err_cdev_del: |
434 |
452 |
cdev_del(&dd->si_cdev); |
cdev_del(&dd->si_cdev); |
435 |
453 |
|
|
|
454 |
|
err_free_minor: |
|
455 |
|
ida_simple_remove(&ida, dd->minor); |
|
456 |
|
|
436 |
457 |
err_shutdown_dce6: |
err_shutdown_dce6: |
437 |
458 |
dce6_shutdown(dd->dce); |
dce6_shutdown(dd->dce); |
438 |
459 |
pci_clear_master(dev); |
pci_clear_master(dev); |
|
... |
... |
static void __exit remove(struct pci_dev *dev) |
504 |
525 |
/* remove userland interface */ |
/* remove userland interface */ |
505 |
526 |
device_destroy(class, dd->si_cdev.dev); |
device_destroy(class, dd->si_cdev.dev); |
506 |
527 |
cdev_del(&dd->si_cdev); |
cdev_del(&dd->si_cdev); |
|
528 |
|
ida_simple_remove(&ida, dd->minor); |
507 |
529 |
|
|
508 |
530 |
dce6_shutdown(dd->dce); |
dce6_shutdown(dd->dce); |
509 |
531 |
pci_clear_master(dev); |
pci_clear_master(dev); |
|
... |
... |
static int __init init(void) |
606 |
628 |
{ |
{ |
607 |
629 |
int r; |
int r; |
608 |
630 |
|
|
|
631 |
|
ida_init(&ida); |
|
632 |
|
|
609 |
633 |
class = class_create(THIS_MODULE, "si"); |
class = class_create(THIS_MODULE, "si"); |
610 |
634 |
if (IS_ERR(class)) |
if (IS_ERR(class)) |
611 |
635 |
return PTR_ERR(class); |
return PTR_ERR(class); |
612 |
636 |
|
|
613 |
|
r = alloc_chrdev_region(&devt, 0, 1, pci_driver.name); |
|
|
637 |
|
r = alloc_chrdev_region(&devt_region, 0, GPUS_MAX, pci_driver.name); |
614 |
638 |
if (r < 0) { |
if (r < 0) { |
615 |
639 |
printk(KERN_ERR "%s:cannot allocate major/minor range\n", |
printk(KERN_ERR "%s:cannot allocate major/minor range\n", |
616 |
640 |
pci_driver.name); |
pci_driver.name); |
|
... |
... |
static int __init init(void) |
626 |
650 |
return 0; |
return 0; |
627 |
651 |
|
|
628 |
652 |
chrdev_region_unregister: |
chrdev_region_unregister: |
629 |
|
unregister_chrdev_region(devt, 1); |
|
|
653 |
|
unregister_chrdev_region(devt_region, GPUS_MAX); |
630 |
654 |
|
|
631 |
655 |
class_destroy: |
class_destroy: |
632 |
656 |
class_destroy(class); |
class_destroy(class); |
|
... |
... |
class_destroy: |
636 |
660 |
static void __exit cleanup(void) |
static void __exit cleanup(void) |
637 |
661 |
{ |
{ |
638 |
662 |
pci_unregister_driver(&pci_driver); |
pci_unregister_driver(&pci_driver); |
639 |
|
unregister_chrdev_region(devt, 1); |
|
|
663 |
|
unregister_chrdev_region(devt_region, GPUS_MAX); |
640 |
664 |
class_destroy(class); |
class_destroy(class); |
|
665 |
|
ida_destroy(&ida); |
641 |
666 |
} |
} |
642 |
667 |
|
|
643 |
668 |
module_init(init); |
module_init(init); |