Commit fe2a70ee authored by Somnath Kotur's avatar Somnath Kotur Committed by David S. Miller

be2net: Fixed a bug in be_cmd_get_regs().

Same WRB entry was being reused over different iterations of a
loop while issuing non-embedded IOCTL requests.Fixed couple of minor bugs
in this path as well.
Re-factored code to alloc/free memory for DMA outside of loop
Signed-off-by: default avatarSomnath Kotur <somnath.kotur@emulex.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3aba891d
...@@ -1214,8 +1214,8 @@ int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size) ...@@ -1214,8 +1214,8 @@ int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size)
if (!status) { if (!status) {
struct be_cmd_resp_get_fat *resp = embedded_payload(wrb); struct be_cmd_resp_get_fat *resp = embedded_payload(wrb);
if (log_size && resp->log_size) if (log_size && resp->log_size)
*log_size = le32_to_cpu(resp->log_size - *log_size = le32_to_cpu(resp->log_size) -
sizeof(u32)); sizeof(u32);
} }
err: err:
spin_unlock_bh(&adapter->mcc_lock); spin_unlock_bh(&adapter->mcc_lock);
...@@ -1228,7 +1228,8 @@ void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf) ...@@ -1228,7 +1228,8 @@ void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf)
struct be_mcc_wrb *wrb; struct be_mcc_wrb *wrb;
struct be_cmd_req_get_fat *req; struct be_cmd_req_get_fat *req;
struct be_sge *sge; struct be_sge *sge;
u32 offset = 0, total_size, buf_size, log_offset = sizeof(u32); u32 offset = 0, total_size, buf_size,
log_offset = sizeof(u32), payload_len;
int status; int status;
if (buf_len == 0) if (buf_len == 0)
...@@ -1236,18 +1237,7 @@ void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf) ...@@ -1236,18 +1237,7 @@ void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf)
total_size = buf_len; total_size = buf_len;
spin_lock_bh(&adapter->mcc_lock); get_fat_cmd.size = sizeof(struct be_cmd_req_get_fat) + 60*1024;
wrb = wrb_from_mccq(adapter);
if (!wrb) {
status = -EBUSY;
goto err;
}
while (total_size) {
buf_size = min(total_size, (u32)60*1024);
total_size -= buf_size;
get_fat_cmd.size = sizeof(struct be_cmd_req_get_fat) + buf_size;
get_fat_cmd.va = pci_alloc_consistent(adapter->pdev, get_fat_cmd.va = pci_alloc_consistent(adapter->pdev,
get_fat_cmd.size, get_fat_cmd.size,
&get_fat_cmd.dma); &get_fat_cmd.dma);
...@@ -1255,18 +1245,31 @@ void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf) ...@@ -1255,18 +1245,31 @@ void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf)
status = -ENOMEM; status = -ENOMEM;
dev_err(&adapter->pdev->dev, dev_err(&adapter->pdev->dev,
"Memory allocation failure while retrieving FAT data\n"); "Memory allocation failure while retrieving FAT data\n");
return;
}
spin_lock_bh(&adapter->mcc_lock);
while (total_size) {
buf_size = min(total_size, (u32)60*1024);
total_size -= buf_size;
wrb = wrb_from_mccq(adapter);
if (!wrb) {
status = -EBUSY;
goto err; goto err;
} }
req = get_fat_cmd.va; req = get_fat_cmd.va;
sge = nonembedded_sgl(wrb); sge = nonembedded_sgl(wrb);
be_wrb_hdr_prepare(wrb, get_fat_cmd.size, false, 1, payload_len = sizeof(struct be_cmd_req_get_fat) + buf_size;
be_wrb_hdr_prepare(wrb, payload_len, false, 1,
OPCODE_COMMON_MANAGE_FAT); OPCODE_COMMON_MANAGE_FAT);
be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
OPCODE_COMMON_MANAGE_FAT, get_fat_cmd.size); OPCODE_COMMON_MANAGE_FAT, payload_len);
sge->pa_hi = cpu_to_le32(upper_32_bits(get_fat_cmd.size)); sge->pa_hi = cpu_to_le32(upper_32_bits(get_fat_cmd.dma));
sge->pa_lo = cpu_to_le32(get_fat_cmd.dma & 0xFFFFFFFF); sge->pa_lo = cpu_to_le32(get_fat_cmd.dma & 0xFFFFFFFF);
sge->len = cpu_to_le32(get_fat_cmd.size); sge->len = cpu_to_le32(get_fat_cmd.size);
...@@ -1281,17 +1284,17 @@ void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf) ...@@ -1281,17 +1284,17 @@ void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf)
memcpy(buf + offset, memcpy(buf + offset,
resp->data_buffer, resp->data_buffer,
resp->read_log_length); resp->read_log_length);
} } else {
pci_free_consistent(adapter->pdev, get_fat_cmd.size,
get_fat_cmd.va,
get_fat_cmd.dma);
if (status)
dev_err(&adapter->pdev->dev, "FAT Table Retrieve error\n"); dev_err(&adapter->pdev->dev, "FAT Table Retrieve error\n");
goto err;
}
offset += buf_size; offset += buf_size;
log_offset += buf_size; log_offset += buf_size;
} }
err: err:
pci_free_consistent(adapter->pdev, get_fat_cmd.size,
get_fat_cmd.va,
get_fat_cmd.dma);
spin_unlock_bh(&adapter->mcc_lock); spin_unlock_bh(&adapter->mcc_lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment