Skip to content

Commit 50fe1a3

Browse files
tyreldmartinkpetersen
authored andcommitted
scsi: ibmvfc: Make discovery buffer per protocol channel group
The target discovery buffer that the VIOS populates with targets is currently a host adapter field. To facilitate the discovery of NVMe targets as well as SCSI another discovery buffer is required. Move the discovery buffer out of the host struct and into the ibmvfc_channels struct so that each channels instance for a given protocol has its own discovery buffer. Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com> Link: https://lore.kernel.org/r/20230921225435.3537728-11-tyreld@linux.ibm.com Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent eb85f1d commit 50fe1a3

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

drivers/scsi/ibmvscsi/ibmvfc.c

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4935,7 +4935,7 @@ static int ibmvfc_alloc_targets(struct ibmvfc_host *vhost)
49354935
int i, rc;
49364936

49374937
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]);
49394939

49404940
return rc;
49414941
}
@@ -4999,9 +4999,9 @@ static void ibmvfc_discover_targets(struct ibmvfc_host *vhost)
49994999
mad->common.version = cpu_to_be32(1);
50005000
mad->common.opcode = cpu_to_be32(IBMVFC_DISC_TARGETS);
50015001
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);
50055005
mad->flags = cpu_to_be32(IBMVFC_DISC_TGT_PORT_ID_WWPN_LIST);
50065006
ibmvfc_set_host_action(vhost, IBMVFC_HOST_ACTION_INIT_WAIT);
50075007

@@ -6119,6 +6119,12 @@ static void ibmvfc_release_sub_crqs(struct ibmvfc_host *vhost)
61196119
LEAVE;
61206120
}
61216121

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+
61226128
/**
61236129
* ibmvfc_free_mem - Free memory for vhost
61246130
* @vhost: ibmvfc host struct
@@ -6133,8 +6139,7 @@ static void ibmvfc_free_mem(struct ibmvfc_host *vhost)
61336139
ENTER;
61346140
mempool_destroy(vhost->tgt_pool);
61356141
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);
61386143
dma_free_coherent(vhost->dev, sizeof(*vhost->login_buf),
61396144
vhost->login_buf, vhost->login_buf_dma);
61406145
dma_free_coherent(vhost->dev, sizeof(*vhost->channel_setup_buf),
@@ -6144,6 +6149,21 @@ static void ibmvfc_free_mem(struct ibmvfc_host *vhost)
61446149
LEAVE;
61456150
}
61466151

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+
61476167
/**
61486168
* ibmvfc_alloc_mem - Allocate memory for vhost
61496169
* @vhost: ibmvfc host struct
@@ -6179,21 +6199,15 @@ static int ibmvfc_alloc_mem(struct ibmvfc_host *vhost)
61796199
goto free_sg_pool;
61806200
}
61816201

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))
61886203
goto free_login_buffer;
6189-
}
61906204

61916205
vhost->trace = kcalloc(IBMVFC_NUM_TRACE_ENTRIES,
61926206
sizeof(struct ibmvfc_trace_entry), GFP_KERNEL);
61936207
atomic_set(&vhost->trace_index, -1);
61946208

61956209
if (!vhost->trace)
6196-
goto free_disc_buffer;
6210+
goto free_scsi_disc_buffer;
61976211

61986212
vhost->tgt_pool = mempool_create_kmalloc_pool(IBMVFC_TGT_MEMPOOL_SZ,
61996213
sizeof(struct ibmvfc_target));
@@ -6219,9 +6233,8 @@ static int ibmvfc_alloc_mem(struct ibmvfc_host *vhost)
62196233
mempool_destroy(vhost->tgt_pool);
62206234
free_trace:
62216235
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);
62256238
free_login_buffer:
62266239
dma_free_coherent(dev, sizeof(*vhost->login_buf),
62276240
vhost->login_buf, vhost->login_buf_dma);

drivers/scsi/ibmvscsi/ibmvfc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,9 @@ struct ibmvfc_channels {
827827
unsigned int active_queues;
828828
unsigned int desired_queues;
829829
unsigned int max_queues;
830+
int disc_buf_sz;
831+
struct ibmvfc_discover_targets_entry *disc_buf;
832+
dma_addr_t disc_buf_dma;
830833
};
831834

832835
enum ibmvfc_host_action {
@@ -881,9 +884,7 @@ struct ibmvfc_host {
881884
dma_addr_t login_buf_dma;
882885
struct ibmvfc_channel_setup *channel_setup_buf;
883886
dma_addr_t channel_setup_dma;
884-
int disc_buf_sz;
885887
int log_level;
886-
struct ibmvfc_discover_targets_entry *disc_buf;
887888
struct mutex passthru_mutex;
888889
unsigned int max_vios_scsi_channels;
889890
int task_set;
@@ -904,7 +905,6 @@ struct ibmvfc_host {
904905
#define IBMVFC_AE_LINKUP 0x0001
905906
#define IBMVFC_AE_LINKDOWN 0x0002
906907
#define IBMVFC_AE_RSCN 0x0004
907-
dma_addr_t disc_buf_dma;
908908
unsigned int partition_number;
909909
char partition_name[97];
910910
void (*job_step) (struct ibmvfc_host *);

0 commit comments

Comments
 (0)