88 * Author: Tom Lyon, pugs@cisco.com
99 */
1010
11+ #define pr_fmt (fmt ) KBUILD_MODNAME ": " fmt
12+
1113#include <linux/device.h>
1214#include <linux/eventfd.h>
1315#include <linux/file.h>
2527#include <linux/nospec.h>
2628#include <linux/sched/mm.h>
2729
28- #include "vfio_pci_core.h"
30+ #include <linux/vfio_pci_core.h>
31+
32+ #define DRIVER_AUTHOR "Alex Williamson <alex.williamson@redhat.com>"
33+ #define DRIVER_DESC "core driver for VFIO based PCI devices"
2934
3035static bool nointxmask ;
3136static bool disable_vga ;
@@ -306,6 +311,7 @@ int vfio_pci_core_enable(struct vfio_pci_core_device *vdev)
306311
307312 return 0 ;
308313}
314+ EXPORT_SYMBOL_GPL (vfio_pci_core_enable );
309315
310316void vfio_pci_core_disable (struct vfio_pci_core_device * vdev )
311317{
@@ -403,6 +409,7 @@ void vfio_pci_core_disable(struct vfio_pci_core_device *vdev)
403409 if (!vfio_pci_dev_set_try_reset (vdev -> vdev .dev_set ) && !disable_idle_d3 )
404410 vfio_pci_set_power_state (vdev , PCI_D3hot );
405411}
412+ EXPORT_SYMBOL_GPL (vfio_pci_core_disable );
406413
407414static struct vfio_pci_core_device * get_pf_vdev (struct vfio_pci_core_device * vdev )
408415{
@@ -459,13 +466,15 @@ void vfio_pci_core_close_device(struct vfio_device *core_vdev)
459466 }
460467 mutex_unlock (& vdev -> igate );
461468}
469+ EXPORT_SYMBOL_GPL (vfio_pci_core_close_device );
462470
463471void vfio_pci_core_finish_enable (struct vfio_pci_core_device * vdev )
464472{
465473 vfio_pci_probe_mmaps (vdev );
466474 vfio_spapr_pci_eeh_open (vdev -> pdev );
467475 vfio_pci_vf_token_user_add (vdev , 1 );
468476}
477+ EXPORT_SYMBOL_GPL (vfio_pci_core_finish_enable );
469478
470479static int vfio_pci_get_irq_count (struct vfio_pci_core_device * vdev , int irq_type )
471480{
@@ -624,6 +633,7 @@ int vfio_pci_register_dev_region(struct vfio_pci_core_device *vdev,
624633
625634 return 0 ;
626635}
636+ EXPORT_SYMBOL_GPL (vfio_pci_register_dev_region );
627637
628638long vfio_pci_core_ioctl (struct vfio_device * core_vdev , unsigned int cmd ,
629639 unsigned long arg )
@@ -1168,6 +1178,7 @@ long vfio_pci_core_ioctl(struct vfio_device *core_vdev, unsigned int cmd,
11681178
11691179 return - ENOTTY ;
11701180}
1181+ EXPORT_SYMBOL_GPL (vfio_pci_core_ioctl );
11711182
11721183static ssize_t vfio_pci_rw (struct vfio_pci_core_device * vdev , char __user * buf ,
11731184 size_t count , loff_t * ppos , bool iswrite )
@@ -1211,6 +1222,7 @@ ssize_t vfio_pci_core_read(struct vfio_device *core_vdev, char __user *buf,
12111222
12121223 return vfio_pci_rw (vdev , buf , count , ppos , false);
12131224}
1225+ EXPORT_SYMBOL_GPL (vfio_pci_core_read );
12141226
12151227ssize_t vfio_pci_core_write (struct vfio_device * core_vdev , const char __user * buf ,
12161228 size_t count , loff_t * ppos )
@@ -1223,6 +1235,7 @@ ssize_t vfio_pci_core_write(struct vfio_device *core_vdev, const char __user *bu
12231235
12241236 return vfio_pci_rw (vdev , (char __user * )buf , count , ppos , true);
12251237}
1238+ EXPORT_SYMBOL_GPL (vfio_pci_core_write );
12261239
12271240/* Return 1 on zap and vma_lock acquired, 0 on contention (only with @try) */
12281241static int vfio_pci_zap_and_vma_lock (struct vfio_pci_core_device * vdev , bool try )
@@ -1501,6 +1514,7 @@ int vfio_pci_core_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma
15011514
15021515 return 0 ;
15031516}
1517+ EXPORT_SYMBOL_GPL (vfio_pci_core_mmap );
15041518
15051519void vfio_pci_core_request (struct vfio_device * core_vdev , unsigned int count )
15061520{
@@ -1523,6 +1537,7 @@ void vfio_pci_core_request(struct vfio_device *core_vdev, unsigned int count)
15231537
15241538 mutex_unlock (& vdev -> igate );
15251539}
1540+ EXPORT_SYMBOL_GPL (vfio_pci_core_request );
15261541
15271542static int vfio_pci_validate_vf_token (struct vfio_pci_core_device * vdev ,
15281543 bool vf_token , uuid_t * uuid )
@@ -1667,6 +1682,7 @@ int vfio_pci_core_match(struct vfio_device *core_vdev, char *buf)
16671682
16681683 return 1 ; /* Match */
16691684}
1685+ EXPORT_SYMBOL_GPL (vfio_pci_core_match );
16701686
16711687static int vfio_pci_bus_notifier (struct notifier_block * nb ,
16721688 unsigned long action , void * data )
@@ -1775,6 +1791,7 @@ void vfio_pci_core_init_device(struct vfio_pci_core_device *vdev,
17751791 INIT_LIST_HEAD (& vdev -> vma_list );
17761792 init_rwsem (& vdev -> memory_lock );
17771793}
1794+ EXPORT_SYMBOL_GPL (vfio_pci_core_init_device );
17781795
17791796void vfio_pci_core_uninit_device (struct vfio_pci_core_device * vdev )
17801797{
@@ -1785,6 +1802,7 @@ void vfio_pci_core_uninit_device(struct vfio_pci_core_device *vdev)
17851802 kfree (vdev -> region );
17861803 kfree (vdev -> pm_save );
17871804}
1805+ EXPORT_SYMBOL_GPL (vfio_pci_core_uninit_device );
17881806
17891807int vfio_pci_core_register_device (struct vfio_pci_core_device * vdev )
17901808{
@@ -1852,7 +1870,6 @@ int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev)
18521870 ret = vfio_register_group_dev (& vdev -> vdev );
18531871 if (ret )
18541872 goto out_power ;
1855- dev_set_drvdata (& pdev -> dev , vdev );
18561873 return 0 ;
18571874
18581875out_power :
@@ -1864,6 +1881,7 @@ int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev)
18641881 vfio_iommu_group_put (group , & pdev -> dev );
18651882 return ret ;
18661883}
1884+ EXPORT_SYMBOL_GPL (vfio_pci_core_register_device );
18671885
18681886void vfio_pci_core_unregister_device (struct vfio_pci_core_device * vdev )
18691887{
@@ -1881,6 +1899,7 @@ void vfio_pci_core_unregister_device(struct vfio_pci_core_device *vdev)
18811899 if (!disable_idle_d3 )
18821900 vfio_pci_set_power_state (vdev , PCI_D0 );
18831901}
1902+ EXPORT_SYMBOL_GPL (vfio_pci_core_unregister_device );
18841903
18851904static pci_ers_result_t vfio_pci_aer_err_detected (struct pci_dev * pdev ,
18861905 pci_channel_state_t state )
@@ -1924,10 +1943,12 @@ int vfio_pci_core_sriov_configure(struct pci_dev *pdev, int nr_virtfn)
19241943
19251944 return ret < 0 ? ret : nr_virtfn ;
19261945}
1946+ EXPORT_SYMBOL_GPL (vfio_pci_core_sriov_configure );
19271947
19281948const struct pci_error_handlers vfio_pci_core_err_handlers = {
19291949 .error_detected = vfio_pci_aer_err_detected ,
19301950};
1951+ EXPORT_SYMBOL_GPL (vfio_pci_core_err_handlers );
19311952
19321953static bool vfio_dev_in_groups (struct vfio_pci_core_device * vdev ,
19331954 struct vfio_pci_group_info * groups )
@@ -2116,16 +2137,22 @@ void vfio_pci_core_set_params(bool is_nointxmask, bool is_disable_vga,
21162137 disable_vga = is_disable_vga ;
21172138 disable_idle_d3 = is_disable_idle_d3 ;
21182139}
2140+ EXPORT_SYMBOL_GPL (vfio_pci_core_set_params );
21192141
2120- /* This will become the __exit function of vfio_pci_core.ko */
2121- void vfio_pci_core_cleanup (void )
2142+ static void vfio_pci_core_cleanup (void )
21222143{
21232144 vfio_pci_uninit_perm_bits ();
21242145}
21252146
2126- /* This will become the __init function of vfio_pci_core.ko */
2127- int __init vfio_pci_core_init (void )
2147+ static int __init vfio_pci_core_init (void )
21282148{
21292149 /* Allocate shared config space permission data used by all devices */
21302150 return vfio_pci_init_perm_bits ();
21312151}
2152+
2153+ module_init (vfio_pci_core_init );
2154+ module_exit (vfio_pci_core_cleanup );
2155+
2156+ MODULE_LICENSE ("GPL v2" );
2157+ MODULE_AUTHOR (DRIVER_AUTHOR );
2158+ MODULE_DESCRIPTION (DRIVER_DESC );
0 commit comments