@@ -163,8 +163,8 @@ static void ibmvfc_npiv_logout(struct ibmvfc_host *);
163
163
static void ibmvfc_tgt_implicit_logout_and_del (struct ibmvfc_target * );
164
164
static void ibmvfc_tgt_move_login (struct ibmvfc_target * );
165
165
166
- static void ibmvfc_dereg_sub_crqs (struct ibmvfc_host * );
167
- static void ibmvfc_reg_sub_crqs (struct ibmvfc_host * );
166
+ static void ibmvfc_dereg_sub_crqs (struct ibmvfc_host * , struct ibmvfc_channels * );
167
+ static void ibmvfc_reg_sub_crqs (struct ibmvfc_host * , struct ibmvfc_channels * );
168
168
169
169
static const char * unknown_error = "unknown error" ;
170
170
@@ -925,7 +925,7 @@ static int ibmvfc_reenable_crq_queue(struct ibmvfc_host *vhost)
925
925
struct vio_dev * vdev = to_vio_dev (vhost -> dev );
926
926
unsigned long flags ;
927
927
928
- ibmvfc_dereg_sub_crqs (vhost );
928
+ ibmvfc_dereg_sub_crqs (vhost , & vhost -> scsi_scrqs );
929
929
930
930
/* Re-enable the CRQ */
931
931
do {
@@ -944,7 +944,7 @@ static int ibmvfc_reenable_crq_queue(struct ibmvfc_host *vhost)
944
944
spin_unlock (vhost -> crq .q_lock );
945
945
spin_unlock_irqrestore (vhost -> host -> host_lock , flags );
946
946
947
- ibmvfc_reg_sub_crqs (vhost );
947
+ ibmvfc_reg_sub_crqs (vhost , & vhost -> scsi_scrqs );
948
948
949
949
return rc ;
950
950
}
@@ -963,7 +963,7 @@ static int ibmvfc_reset_crq(struct ibmvfc_host *vhost)
963
963
struct vio_dev * vdev = to_vio_dev (vhost -> dev );
964
964
struct ibmvfc_queue * crq = & vhost -> crq ;
965
965
966
- ibmvfc_dereg_sub_crqs (vhost );
966
+ ibmvfc_dereg_sub_crqs (vhost , & vhost -> scsi_scrqs );
967
967
968
968
/* Close the CRQ */
969
969
do {
@@ -996,7 +996,7 @@ static int ibmvfc_reset_crq(struct ibmvfc_host *vhost)
996
996
spin_unlock (vhost -> crq .q_lock );
997
997
spin_unlock_irqrestore (vhost -> host -> host_lock , flags );
998
998
999
- ibmvfc_reg_sub_crqs (vhost );
999
+ ibmvfc_reg_sub_crqs (vhost , & vhost -> scsi_scrqs );
1000
1000
1001
1001
return rc ;
1002
1002
}
@@ -5906,12 +5906,13 @@ static int ibmvfc_init_crq(struct ibmvfc_host *vhost)
5906
5906
return retrc ;
5907
5907
}
5908
5908
5909
- static int ibmvfc_register_scsi_channel (struct ibmvfc_host * vhost ,
5910
- int index )
5909
+ static int ibmvfc_register_channel (struct ibmvfc_host * vhost ,
5910
+ struct ibmvfc_channels * channels ,
5911
+ int index )
5911
5912
{
5912
5913
struct device * dev = vhost -> dev ;
5913
5914
struct vio_dev * vdev = to_vio_dev (dev );
5914
- struct ibmvfc_queue * scrq = & vhost -> scsi_scrqs . scrqs [index ];
5915
+ struct ibmvfc_queue * scrq = & channels -> scrqs [index ];
5915
5916
int rc = - ENOMEM ;
5916
5917
5917
5918
ENTER ;
@@ -5959,11 +5960,13 @@ static int ibmvfc_register_scsi_channel(struct ibmvfc_host *vhost,
5959
5960
return rc ;
5960
5961
}
5961
5962
5962
- static void ibmvfc_deregister_scsi_channel (struct ibmvfc_host * vhost , int index )
5963
+ static void ibmvfc_deregister_channel (struct ibmvfc_host * vhost ,
5964
+ struct ibmvfc_channels * channels ,
5965
+ int index )
5963
5966
{
5964
5967
struct device * dev = vhost -> dev ;
5965
5968
struct vio_dev * vdev = to_vio_dev (dev );
5966
- struct ibmvfc_queue * scrq = & vhost -> scsi_scrqs . scrqs [index ];
5969
+ struct ibmvfc_queue * scrq = & channels -> scrqs [index ];
5967
5970
long rc ;
5968
5971
5969
5972
ENTER ;
@@ -5987,18 +5990,19 @@ static void ibmvfc_deregister_scsi_channel(struct ibmvfc_host *vhost, int index)
5987
5990
LEAVE ;
5988
5991
}
5989
5992
5990
- static void ibmvfc_reg_sub_crqs (struct ibmvfc_host * vhost )
5993
+ static void ibmvfc_reg_sub_crqs (struct ibmvfc_host * vhost ,
5994
+ struct ibmvfc_channels * channels )
5991
5995
{
5992
5996
int i , j ;
5993
5997
5994
5998
ENTER ;
5995
- if (!vhost -> mq_enabled || !vhost -> scsi_scrqs . scrqs )
5999
+ if (!vhost -> mq_enabled || !channels -> scrqs )
5996
6000
return ;
5997
6001
5998
- for (i = 0 ; i < nr_scsi_hw_queues ; i ++ ) {
5999
- if (ibmvfc_register_scsi_channel (vhost , i )) {
6002
+ for (i = 0 ; i < channels -> max_queues ; i ++ ) {
6003
+ if (ibmvfc_register_channel (vhost , channels , i )) {
6000
6004
for (j = i ; j > 0 ; j -- )
6001
- ibmvfc_deregister_scsi_channel (vhost , j - 1 );
6005
+ ibmvfc_deregister_channel (vhost , channels , j - 1 );
6002
6006
vhost -> do_enquiry = 0 ;
6003
6007
return ;
6004
6008
}
@@ -6007,77 +6011,96 @@ static void ibmvfc_reg_sub_crqs(struct ibmvfc_host *vhost)
6007
6011
LEAVE ;
6008
6012
}
6009
6013
6010
- static void ibmvfc_dereg_sub_crqs (struct ibmvfc_host * vhost )
6014
+ static void ibmvfc_dereg_sub_crqs (struct ibmvfc_host * vhost ,
6015
+ struct ibmvfc_channels * channels )
6011
6016
{
6012
6017
int i ;
6013
6018
6014
6019
ENTER ;
6015
- if (!vhost -> mq_enabled || !vhost -> scsi_scrqs . scrqs )
6020
+ if (!vhost -> mq_enabled || !channels -> scrqs )
6016
6021
return ;
6017
6022
6018
- for (i = 0 ; i < nr_scsi_hw_queues ; i ++ )
6019
- ibmvfc_deregister_scsi_channel (vhost , i );
6023
+ for (i = 0 ; i < channels -> max_queues ; i ++ )
6024
+ ibmvfc_deregister_channel (vhost , channels , i );
6020
6025
6021
6026
LEAVE ;
6022
6027
}
6023
6028
6024
- static void ibmvfc_init_sub_crqs (struct ibmvfc_host * vhost )
6029
+ static int ibmvfc_alloc_channels (struct ibmvfc_host * vhost ,
6030
+ struct ibmvfc_channels * channels )
6025
6031
{
6026
6032
struct ibmvfc_queue * scrq ;
6027
6033
int i , j ;
6034
+ int rc = 0 ;
6028
6035
6036
+ channels -> scrqs = kcalloc (channels -> max_queues ,
6037
+ sizeof (* channels -> scrqs ),
6038
+ GFP_KERNEL );
6039
+ if (!channels -> scrqs )
6040
+ return - ENOMEM ;
6041
+
6042
+ for (i = 0 ; i < channels -> max_queues ; i ++ ) {
6043
+ scrq = & channels -> scrqs [i ];
6044
+ rc = ibmvfc_alloc_queue (vhost , scrq , IBMVFC_SUB_CRQ_FMT );
6045
+ if (rc ) {
6046
+ for (j = i ; j > 0 ; j -- ) {
6047
+ scrq = & channels -> scrqs [j - 1 ];
6048
+ ibmvfc_free_queue (vhost , scrq );
6049
+ }
6050
+ kfree (channels -> scrqs );
6051
+ channels -> scrqs = NULL ;
6052
+ channels -> active_queues = 0 ;
6053
+ return rc ;
6054
+ }
6055
+ }
6056
+
6057
+ return rc ;
6058
+ }
6059
+
6060
+ static void ibmvfc_init_sub_crqs (struct ibmvfc_host * vhost )
6061
+ {
6029
6062
ENTER ;
6030
6063
if (!vhost -> mq_enabled )
6031
6064
return ;
6032
6065
6033
- vhost -> scsi_scrqs .scrqs = kcalloc (nr_scsi_hw_queues ,
6034
- sizeof (* vhost -> scsi_scrqs .scrqs ),
6035
- GFP_KERNEL );
6036
- if (!vhost -> scsi_scrqs .scrqs ) {
6066
+ if (ibmvfc_alloc_channels (vhost , & vhost -> scsi_scrqs )) {
6037
6067
vhost -> do_enquiry = 0 ;
6068
+ vhost -> mq_enabled = 0 ;
6038
6069
return ;
6039
6070
}
6040
6071
6041
- for (i = 0 ; i < nr_scsi_hw_queues ; i ++ ) {
6042
- scrq = & vhost -> scsi_scrqs .scrqs [i ];
6043
- if (ibmvfc_alloc_queue (vhost , scrq , IBMVFC_SUB_CRQ_FMT )) {
6044
- for (j = i ; j > 0 ; j -- ) {
6045
- scrq = & vhost -> scsi_scrqs .scrqs [j - 1 ];
6046
- ibmvfc_free_queue (vhost , scrq );
6047
- }
6048
- kfree (vhost -> scsi_scrqs .scrqs );
6049
- vhost -> scsi_scrqs .scrqs = NULL ;
6050
- vhost -> scsi_scrqs .active_queues = 0 ;
6051
- vhost -> do_enquiry = 0 ;
6052
- vhost -> mq_enabled = 0 ;
6053
- return ;
6054
- }
6055
- }
6056
-
6057
- ibmvfc_reg_sub_crqs (vhost );
6072
+ ibmvfc_reg_sub_crqs (vhost , & vhost -> scsi_scrqs );
6058
6073
6059
6074
LEAVE ;
6060
6075
}
6061
6076
6062
- static void ibmvfc_release_sub_crqs (struct ibmvfc_host * vhost )
6077
+ static void ibmvfc_release_channels (struct ibmvfc_host * vhost ,
6078
+ struct ibmvfc_channels * channels )
6063
6079
{
6064
6080
struct ibmvfc_queue * scrq ;
6065
6081
int i ;
6066
6082
6083
+ if (channels -> scrqs ) {
6084
+ for (i = 0 ; i < channels -> max_queues ; i ++ ) {
6085
+ scrq = & channels -> scrqs [i ];
6086
+ ibmvfc_free_queue (vhost , scrq );
6087
+ }
6088
+
6089
+ kfree (channels -> scrqs );
6090
+ channels -> scrqs = NULL ;
6091
+ channels -> active_queues = 0 ;
6092
+ }
6093
+ }
6094
+
6095
+ static void ibmvfc_release_sub_crqs (struct ibmvfc_host * vhost )
6096
+ {
6067
6097
ENTER ;
6068
6098
if (!vhost -> scsi_scrqs .scrqs )
6069
6099
return ;
6070
6100
6071
- ibmvfc_dereg_sub_crqs (vhost );
6072
-
6073
- for (i = 0 ; i < nr_scsi_hw_queues ; i ++ ) {
6074
- scrq = & vhost -> scsi_scrqs .scrqs [i ];
6075
- ibmvfc_free_queue (vhost , scrq );
6076
- }
6101
+ ibmvfc_dereg_sub_crqs (vhost , & vhost -> scsi_scrqs );
6077
6102
6078
- kfree (vhost -> scsi_scrqs .scrqs );
6079
- vhost -> scsi_scrqs .scrqs = NULL ;
6080
- vhost -> scsi_scrqs .active_queues = 0 ;
6103
+ ibmvfc_release_channels (vhost , & vhost -> scsi_scrqs );
6081
6104
LEAVE ;
6082
6105
}
6083
6106
0 commit comments