88
88
89
89
static const char hisi_zip_name [] = "hisi_zip" ;
90
90
static struct dentry * hzip_debugfs_root ;
91
- static LIST_HEAD (hisi_zip_list );
92
- static DEFINE_MUTEX (hisi_zip_list_lock );
93
-
94
- struct hisi_zip_resource {
95
- struct hisi_zip * hzip ;
96
- int distance ;
97
- struct list_head list ;
98
- };
99
-
100
- static void free_list (struct list_head * head )
101
- {
102
- struct hisi_zip_resource * res , * tmp ;
103
-
104
- list_for_each_entry_safe (res , tmp , head , list ) {
105
- list_del (& res -> list );
106
- kfree (res );
107
- }
108
- }
109
-
110
- struct hisi_zip * find_zip_device (int node )
111
- {
112
- struct hisi_zip_resource * res , * tmp ;
113
- struct hisi_zip * ret = NULL ;
114
- struct hisi_zip * hisi_zip ;
115
- struct list_head * n ;
116
- struct device * dev ;
117
- LIST_HEAD (head );
118
-
119
- mutex_lock (& hisi_zip_list_lock );
120
-
121
- if (IS_ENABLED (CONFIG_NUMA )) {
122
- list_for_each_entry (hisi_zip , & hisi_zip_list , list ) {
123
- res = kzalloc (sizeof (* res ), GFP_KERNEL );
124
- if (!res )
125
- goto err ;
126
-
127
- dev = & hisi_zip -> qm .pdev -> dev ;
128
- res -> hzip = hisi_zip ;
129
- res -> distance = node_distance (dev_to_node (dev ), node );
130
-
131
- n = & head ;
132
- list_for_each_entry (tmp , & head , list ) {
133
- if (res -> distance < tmp -> distance ) {
134
- n = & tmp -> list ;
135
- break ;
136
- }
137
- }
138
- list_add_tail (& res -> list , n );
139
- }
140
-
141
- list_for_each_entry (tmp , & head , list ) {
142
- if (hisi_qm_get_free_qp_num (& tmp -> hzip -> qm )) {
143
- ret = tmp -> hzip ;
144
- break ;
145
- }
146
- }
147
-
148
- free_list (& head );
149
- } else {
150
- ret = list_first_entry (& hisi_zip_list , struct hisi_zip , list );
151
- }
152
-
153
- mutex_unlock (& hisi_zip_list_lock );
154
-
155
- return ret ;
156
-
157
- err :
158
- free_list (& head );
159
- mutex_unlock (& hisi_zip_list_lock );
160
- return NULL ;
161
- }
91
+ static struct hisi_qm_list zip_devices ;
162
92
163
93
struct hisi_zip_hw_error {
164
94
u32 int_msk ;
@@ -313,18 +243,11 @@ static const struct pci_device_id hisi_zip_dev_ids[] = {
313
243
};
314
244
MODULE_DEVICE_TABLE (pci , hisi_zip_dev_ids );
315
245
316
- static inline void hisi_zip_add_to_list (struct hisi_zip * hisi_zip )
246
+ int zip_create_qps (struct hisi_qp * * qps , int qp_num )
317
247
{
318
- mutex_lock (& hisi_zip_list_lock );
319
- list_add_tail (& hisi_zip -> list , & hisi_zip_list );
320
- mutex_unlock (& hisi_zip_list_lock );
321
- }
248
+ int node = cpu_to_node (smp_processor_id ());
322
249
323
- static inline void hisi_zip_remove_from_list (struct hisi_zip * hisi_zip )
324
- {
325
- mutex_lock (& hisi_zip_list_lock );
326
- list_del (& hisi_zip -> list );
327
- mutex_unlock (& hisi_zip_list_lock );
250
+ return hisi_qm_alloc_qps_node (& zip_devices , qp_num , 0 , node , qps );
328
251
}
329
252
330
253
static void hisi_zip_set_user_domain_and_cache (struct hisi_zip * hisi_zip )
@@ -891,7 +814,7 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id)
891
814
if (ret )
892
815
dev_err (& pdev -> dev , "Failed to init debugfs (%d)!\n" , ret );
893
816
894
- hisi_zip_add_to_list ( hisi_zip );
817
+ hisi_qm_add_to_list ( qm , & zip_devices );
895
818
896
819
if (qm -> uacce ) {
897
820
ret = uacce_register (qm -> uacce );
@@ -908,7 +831,7 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id)
908
831
return 0 ;
909
832
910
833
err_remove_from_list :
911
- hisi_zip_remove_from_list ( hisi_zip );
834
+ hisi_qm_del_from_list ( qm , & zip_devices );
912
835
hisi_zip_debugfs_exit (hisi_zip );
913
836
hisi_qm_stop (qm );
914
837
err_qm_uninit :
@@ -937,7 +860,7 @@ static void hisi_zip_remove(struct pci_dev *pdev)
937
860
938
861
hisi_qm_dev_err_uninit (qm );
939
862
hisi_qm_uninit (qm );
940
- hisi_zip_remove_from_list ( hisi_zip );
863
+ hisi_qm_del_from_list ( qm , & zip_devices );
941
864
}
942
865
943
866
static const struct pci_error_handlers hisi_zip_err_handler = {
@@ -971,6 +894,7 @@ static int __init hisi_zip_init(void)
971
894
{
972
895
int ret ;
973
896
897
+ hisi_qm_init_list (& zip_devices );
974
898
hisi_zip_register_debugfs ();
975
899
976
900
ret = pci_register_driver (& hisi_zip_pci_driver );
0 commit comments