@@ -46,118 +46,6 @@ static const char * const supported_hypervisors[] = {
4646 [INTEL_GVT_HYPERVISOR_KVM ] = "KVM" ,
4747};
4848
49- static struct intel_vgpu_type *
50- intel_gvt_find_vgpu_type (struct intel_gvt * gvt , unsigned int type_group_id )
51- {
52- if (WARN_ON (type_group_id >= gvt -> num_types ))
53- return NULL ;
54- return & gvt -> types [type_group_id ];
55- }
56-
57- static ssize_t available_instances_show (struct mdev_type * mtype ,
58- struct mdev_type_attribute * attr ,
59- char * buf )
60- {
61- struct intel_vgpu_type * type ;
62- unsigned int num = 0 ;
63- void * gvt = kdev_to_i915 (mtype_get_parent_dev (mtype ))-> gvt ;
64-
65- type = intel_gvt_find_vgpu_type (gvt , mtype_get_type_group_id (mtype ));
66- if (!type )
67- num = 0 ;
68- else
69- num = type -> avail_instance ;
70-
71- return sprintf (buf , "%u\n" , num );
72- }
73-
74- static ssize_t device_api_show (struct mdev_type * mtype ,
75- struct mdev_type_attribute * attr , char * buf )
76- {
77- return sprintf (buf , "%s\n" , VFIO_DEVICE_API_PCI_STRING );
78- }
79-
80- static ssize_t description_show (struct mdev_type * mtype ,
81- struct mdev_type_attribute * attr , char * buf )
82- {
83- struct intel_vgpu_type * type ;
84- void * gvt = kdev_to_i915 (mtype_get_parent_dev (mtype ))-> gvt ;
85-
86- type = intel_gvt_find_vgpu_type (gvt , mtype_get_type_group_id (mtype ));
87- if (!type )
88- return 0 ;
89-
90- return sprintf (buf , "low_gm_size: %dMB\nhigh_gm_size: %dMB\n"
91- "fence: %d\nresolution: %s\n"
92- "weight: %d\n" ,
93- BYTES_TO_MB (type -> low_gm_size ),
94- BYTES_TO_MB (type -> high_gm_size ),
95- type -> fence , vgpu_edid_str (type -> resolution ),
96- type -> weight );
97- }
98-
99- static MDEV_TYPE_ATTR_RO (available_instances );
100- static MDEV_TYPE_ATTR_RO (device_api );
101- static MDEV_TYPE_ATTR_RO (description );
102-
103- static struct attribute * gvt_type_attrs [] = {
104- & mdev_type_attr_available_instances .attr ,
105- & mdev_type_attr_device_api .attr ,
106- & mdev_type_attr_description .attr ,
107- NULL ,
108- };
109-
110- static struct attribute_group * gvt_vgpu_type_groups [] = {
111- [0 ... NR_MAX_INTEL_VGPU_TYPES - 1 ] = NULL ,
112- };
113-
114- static bool intel_get_gvt_attrs (struct attribute_group * * * intel_vgpu_type_groups )
115- {
116- * intel_vgpu_type_groups = gvt_vgpu_type_groups ;
117- return true;
118- }
119-
120- static int intel_gvt_init_vgpu_type_groups (struct intel_gvt * gvt )
121- {
122- int i , j ;
123- struct intel_vgpu_type * type ;
124- struct attribute_group * group ;
125-
126- for (i = 0 ; i < gvt -> num_types ; i ++ ) {
127- type = & gvt -> types [i ];
128-
129- group = kzalloc (sizeof (struct attribute_group ), GFP_KERNEL );
130- if (WARN_ON (!group ))
131- goto unwind ;
132-
133- group -> name = type -> name ;
134- group -> attrs = gvt_type_attrs ;
135- gvt_vgpu_type_groups [i ] = group ;
136- }
137-
138- return 0 ;
139-
140- unwind :
141- for (j = 0 ; j < i ; j ++ ) {
142- group = gvt_vgpu_type_groups [j ];
143- kfree (group );
144- }
145-
146- return - ENOMEM ;
147- }
148-
149- static void intel_gvt_cleanup_vgpu_type_groups (struct intel_gvt * gvt )
150- {
151- int i ;
152- struct attribute_group * group ;
153-
154- for (i = 0 ; i < gvt -> num_types ; i ++ ) {
155- group = gvt_vgpu_type_groups [i ];
156- gvt_vgpu_type_groups [i ] = NULL ;
157- kfree (group );
158- }
159- }
160-
16149static const struct intel_gvt_ops intel_gvt_ops = {
16250 .emulate_cfg_read = intel_vgpu_emulate_cfg_read ,
16351 .emulate_cfg_write = intel_vgpu_emulate_cfg_write ,
@@ -169,8 +57,6 @@ static const struct intel_gvt_ops intel_gvt_ops = {
16957 .vgpu_reset = intel_gvt_reset_vgpu ,
17058 .vgpu_activate = intel_gvt_activate_vgpu ,
17159 .vgpu_deactivate = intel_gvt_deactivate_vgpu ,
172- .gvt_find_vgpu_type = intel_gvt_find_vgpu_type ,
173- .get_gvt_attrs = intel_get_gvt_attrs ,
17460 .vgpu_query_plane = intel_vgpu_query_plane ,
17561 .vgpu_get_dmabuf = intel_vgpu_get_dmabuf ,
17662 .write_protect_handler = intel_vgpu_page_track_handler ,
@@ -274,7 +160,6 @@ void intel_gvt_clean_device(struct drm_i915_private *i915)
274160 return ;
275161
276162 intel_gvt_destroy_idle_vgpu (gvt -> idle_vgpu );
277- intel_gvt_cleanup_vgpu_type_groups (gvt );
278163 intel_gvt_clean_vgpu_types (gvt );
279164
280165 intel_gvt_debugfs_clean (gvt );
@@ -363,12 +248,6 @@ int intel_gvt_init_device(struct drm_i915_private *i915)
363248 if (ret )
364249 goto out_clean_thread ;
365250
366- ret = intel_gvt_init_vgpu_type_groups (gvt );
367- if (ret ) {
368- gvt_err ("failed to init vgpu type groups: %d\n" , ret );
369- goto out_clean_types ;
370- }
371-
372251 vgpu = intel_gvt_create_idle_vgpu (gvt );
373252 if (IS_ERR (vgpu )) {
374253 ret = PTR_ERR (vgpu );
@@ -454,7 +333,8 @@ EXPORT_SYMBOL_GPL(intel_gvt_register_hypervisor);
454333void
455334intel_gvt_unregister_hypervisor (void )
456335{
457- intel_gvt_hypervisor_host_exit (intel_gvt_host .dev );
336+ void * gvt = (void * )kdev_to_i915 (intel_gvt_host .dev )-> gvt ;
337+ intel_gvt_hypervisor_host_exit (intel_gvt_host .dev , gvt );
458338 module_put (THIS_MODULE );
459339}
460340EXPORT_SYMBOL_GPL (intel_gvt_unregister_hypervisor );
0 commit comments