@@ -4935,7 +4935,7 @@ static int ibmvfc_alloc_targets(struct ibmvfc_host *vhost)
4935
4935
int i , rc ;
4936
4936
4937
4937
for (i = 0 , rc = 0 ; !rc && i < vhost -> num_targets ; i ++ )
4938
- rc = ibmvfc_alloc_target (vhost , & vhost -> disc_buf [i ]);
4938
+ rc = ibmvfc_alloc_target (vhost , & vhost -> scsi_scrqs . disc_buf [i ]);
4939
4939
4940
4940
return rc ;
4941
4941
}
@@ -4999,9 +4999,9 @@ static void ibmvfc_discover_targets(struct ibmvfc_host *vhost)
4999
4999
mad -> common .version = cpu_to_be32 (1 );
5000
5000
mad -> common .opcode = cpu_to_be32 (IBMVFC_DISC_TARGETS );
5001
5001
mad -> common .length = cpu_to_be16 (sizeof (* mad ));
5002
- mad -> bufflen = cpu_to_be32 (vhost -> disc_buf_sz );
5003
- mad -> buffer .va = cpu_to_be64 (vhost -> disc_buf_dma );
5004
- mad -> buffer .len = cpu_to_be32 (vhost -> disc_buf_sz );
5002
+ mad -> bufflen = cpu_to_be32 (vhost -> scsi_scrqs . disc_buf_sz );
5003
+ mad -> buffer .va = cpu_to_be64 (vhost -> scsi_scrqs . disc_buf_dma );
5004
+ mad -> buffer .len = cpu_to_be32 (vhost -> scsi_scrqs . disc_buf_sz );
5005
5005
mad -> flags = cpu_to_be32 (IBMVFC_DISC_TGT_PORT_ID_WWPN_LIST );
5006
5006
ibmvfc_set_host_action (vhost , IBMVFC_HOST_ACTION_INIT_WAIT );
5007
5007
@@ -6119,6 +6119,12 @@ static void ibmvfc_release_sub_crqs(struct ibmvfc_host *vhost)
6119
6119
LEAVE ;
6120
6120
}
6121
6121
6122
+ static void ibmvfc_free_disc_buf (struct device * dev , struct ibmvfc_channels * channels )
6123
+ {
6124
+ dma_free_coherent (dev , channels -> disc_buf_sz , channels -> disc_buf ,
6125
+ channels -> disc_buf_dma );
6126
+ }
6127
+
6122
6128
/**
6123
6129
* ibmvfc_free_mem - Free memory for vhost
6124
6130
* @vhost: ibmvfc host struct
@@ -6133,8 +6139,7 @@ static void ibmvfc_free_mem(struct ibmvfc_host *vhost)
6133
6139
ENTER ;
6134
6140
mempool_destroy (vhost -> tgt_pool );
6135
6141
kfree (vhost -> trace );
6136
- dma_free_coherent (vhost -> dev , vhost -> disc_buf_sz , vhost -> disc_buf ,
6137
- vhost -> disc_buf_dma );
6142
+ ibmvfc_free_disc_buf (vhost -> dev , & vhost -> scsi_scrqs );
6138
6143
dma_free_coherent (vhost -> dev , sizeof (* vhost -> login_buf ),
6139
6144
vhost -> login_buf , vhost -> login_buf_dma );
6140
6145
dma_free_coherent (vhost -> dev , sizeof (* vhost -> channel_setup_buf ),
@@ -6144,6 +6149,21 @@ static void ibmvfc_free_mem(struct ibmvfc_host *vhost)
6144
6149
LEAVE ;
6145
6150
}
6146
6151
6152
+ static int ibmvfc_alloc_disc_buf (struct device * dev , struct ibmvfc_channels * channels )
6153
+ {
6154
+ channels -> disc_buf_sz = sizeof (* channels -> disc_buf ) * max_targets ;
6155
+ channels -> disc_buf = dma_alloc_coherent (dev , channels -> disc_buf_sz ,
6156
+ & channels -> disc_buf_dma , GFP_KERNEL );
6157
+
6158
+ if (!channels -> disc_buf ) {
6159
+ dev_err (dev , "Couldn't allocate %s Discover Targets buffer\n" ,
6160
+ (channels -> protocol == IBMVFC_PROTO_SCSI ) ? "SCSI" : "NVMe" );
6161
+ return - ENOMEM ;
6162
+ }
6163
+
6164
+ return 0 ;
6165
+ }
6166
+
6147
6167
/**
6148
6168
* ibmvfc_alloc_mem - Allocate memory for vhost
6149
6169
* @vhost: ibmvfc host struct
@@ -6179,21 +6199,15 @@ static int ibmvfc_alloc_mem(struct ibmvfc_host *vhost)
6179
6199
goto free_sg_pool ;
6180
6200
}
6181
6201
6182
- vhost -> disc_buf_sz = sizeof (* vhost -> disc_buf ) * max_targets ;
6183
- vhost -> disc_buf = dma_alloc_coherent (dev , vhost -> disc_buf_sz ,
6184
- & vhost -> disc_buf_dma , GFP_KERNEL );
6185
-
6186
- if (!vhost -> disc_buf ) {
6187
- dev_err (dev , "Couldn't allocate Discover Targets buffer\n" );
6202
+ if (ibmvfc_alloc_disc_buf (dev , & vhost -> scsi_scrqs ))
6188
6203
goto free_login_buffer ;
6189
- }
6190
6204
6191
6205
vhost -> trace = kcalloc (IBMVFC_NUM_TRACE_ENTRIES ,
6192
6206
sizeof (struct ibmvfc_trace_entry ), GFP_KERNEL );
6193
6207
atomic_set (& vhost -> trace_index , -1 );
6194
6208
6195
6209
if (!vhost -> trace )
6196
- goto free_disc_buffer ;
6210
+ goto free_scsi_disc_buffer ;
6197
6211
6198
6212
vhost -> tgt_pool = mempool_create_kmalloc_pool (IBMVFC_TGT_MEMPOOL_SZ ,
6199
6213
sizeof (struct ibmvfc_target ));
@@ -6219,9 +6233,8 @@ static int ibmvfc_alloc_mem(struct ibmvfc_host *vhost)
6219
6233
mempool_destroy (vhost -> tgt_pool );
6220
6234
free_trace :
6221
6235
kfree (vhost -> trace );
6222
- free_disc_buffer :
6223
- dma_free_coherent (dev , vhost -> disc_buf_sz , vhost -> disc_buf ,
6224
- vhost -> disc_buf_dma );
6236
+ free_scsi_disc_buffer :
6237
+ ibmvfc_free_disc_buf (dev , & vhost -> scsi_scrqs );
6225
6238
free_login_buffer :
6226
6239
dma_free_coherent (dev , sizeof (* vhost -> login_buf ),
6227
6240
vhost -> login_buf , vhost -> login_buf_dma );
0 commit comments