hw/scsi: Rename SCSIRequest::resid as 'residual'
The 'resid' field is slightly confusing and could be interpreted as some ID. Rename it as 'residual' which is clearer to review. No logical change. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: David Hildenbrand <david@redhat.com> Message-Id: <20220111184309.28637-8-f4bug@amsat.org> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
This commit is contained in:
parent
ce0a798285
commit
5f412602de
|
@ -1045,7 +1045,8 @@ static int megasas_pd_get_info_submit(SCSIDevice *sdev, int lun,
|
||||||
uint64_t pd_size;
|
uint64_t pd_size;
|
||||||
uint16_t pd_id = ((sdev->id & 0xFF) << 8) | (lun & 0xFF);
|
uint16_t pd_id = ((sdev->id & 0xFF) << 8) | (lun & 0xFF);
|
||||||
uint8_t cmdbuf[6];
|
uint8_t cmdbuf[6];
|
||||||
size_t len, resid;
|
size_t len;
|
||||||
|
size_t residual;
|
||||||
|
|
||||||
if (!cmd->iov_buf) {
|
if (!cmd->iov_buf) {
|
||||||
cmd->iov_buf = g_malloc0(dcmd_size);
|
cmd->iov_buf = g_malloc0(dcmd_size);
|
||||||
|
@ -1112,9 +1113,10 @@ static int megasas_pd_get_info_submit(SCSIDevice *sdev, int lun,
|
||||||
info->connected_port_bitmap = 0x1;
|
info->connected_port_bitmap = 0x1;
|
||||||
info->device_speed = 1;
|
info->device_speed = 1;
|
||||||
info->link_speed = 1;
|
info->link_speed = 1;
|
||||||
resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED);
|
residual = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg,
|
||||||
|
MEMTXATTRS_UNSPECIFIED);
|
||||||
g_free(cmd->iov_buf);
|
g_free(cmd->iov_buf);
|
||||||
cmd->iov_size = dcmd_size - resid;
|
cmd->iov_size = dcmd_size - residual;
|
||||||
cmd->iov_buf = NULL;
|
cmd->iov_buf = NULL;
|
||||||
return MFI_STAT_OK;
|
return MFI_STAT_OK;
|
||||||
}
|
}
|
||||||
|
@ -1149,7 +1151,8 @@ static int megasas_dcmd_pd_get_info(MegasasState *s, MegasasCmd *cmd)
|
||||||
static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd)
|
static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd)
|
||||||
{
|
{
|
||||||
struct mfi_ld_list info;
|
struct mfi_ld_list info;
|
||||||
size_t dcmd_size = sizeof(info), resid;
|
size_t dcmd_size = sizeof(info);
|
||||||
|
size_t residual;
|
||||||
uint32_t num_ld_disks = 0, max_ld_disks;
|
uint32_t num_ld_disks = 0, max_ld_disks;
|
||||||
uint64_t ld_size;
|
uint64_t ld_size;
|
||||||
BusChild *kid;
|
BusChild *kid;
|
||||||
|
@ -1184,8 +1187,9 @@ static int megasas_dcmd_ld_get_list(MegasasState *s, MegasasCmd *cmd)
|
||||||
info.ld_count = cpu_to_le32(num_ld_disks);
|
info.ld_count = cpu_to_le32(num_ld_disks);
|
||||||
trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks);
|
trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks);
|
||||||
|
|
||||||
resid = dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED);
|
residual = dma_buf_read(&info, dcmd_size, &cmd->qsg,
|
||||||
cmd->iov_size = dcmd_size - resid;
|
MEMTXATTRS_UNSPECIFIED);
|
||||||
|
cmd->iov_size = dcmd_size - residual;
|
||||||
return MFI_STAT_OK;
|
return MFI_STAT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1193,7 +1197,8 @@ static int megasas_dcmd_ld_list_query(MegasasState *s, MegasasCmd *cmd)
|
||||||
{
|
{
|
||||||
uint16_t flags;
|
uint16_t flags;
|
||||||
struct mfi_ld_targetid_list info;
|
struct mfi_ld_targetid_list info;
|
||||||
size_t dcmd_size = sizeof(info), resid;
|
size_t dcmd_size = sizeof(info);
|
||||||
|
size_t residual;
|
||||||
uint32_t num_ld_disks = 0, max_ld_disks = s->fw_luns;
|
uint32_t num_ld_disks = 0, max_ld_disks = s->fw_luns;
|
||||||
BusChild *kid;
|
BusChild *kid;
|
||||||
|
|
||||||
|
@ -1233,8 +1238,9 @@ static int megasas_dcmd_ld_list_query(MegasasState *s, MegasasCmd *cmd)
|
||||||
info.size = dcmd_size;
|
info.size = dcmd_size;
|
||||||
trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks);
|
trace_megasas_dcmd_ld_get_list(cmd->index, num_ld_disks, max_ld_disks);
|
||||||
|
|
||||||
resid = dma_buf_read(&info, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED);
|
residual = dma_buf_read(&info, dcmd_size, &cmd->qsg,
|
||||||
cmd->iov_size = dcmd_size - resid;
|
MEMTXATTRS_UNSPECIFIED);
|
||||||
|
cmd->iov_size = dcmd_size - residual;
|
||||||
return MFI_STAT_OK;
|
return MFI_STAT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1244,7 +1250,8 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun,
|
||||||
struct mfi_ld_info *info = cmd->iov_buf;
|
struct mfi_ld_info *info = cmd->iov_buf;
|
||||||
size_t dcmd_size = sizeof(struct mfi_ld_info);
|
size_t dcmd_size = sizeof(struct mfi_ld_info);
|
||||||
uint8_t cdb[6];
|
uint8_t cdb[6];
|
||||||
ssize_t len, resid;
|
ssize_t len;
|
||||||
|
size_t residual;
|
||||||
uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (lun & 0xFF);
|
uint16_t sdev_id = ((sdev->id & 0xFF) << 8) | (lun & 0xFF);
|
||||||
uint64_t ld_size;
|
uint64_t ld_size;
|
||||||
|
|
||||||
|
@ -1283,9 +1290,10 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev, int lun,
|
||||||
info->ld_config.span[0].num_blocks = info->size;
|
info->ld_config.span[0].num_blocks = info->size;
|
||||||
info->ld_config.span[0].array_ref = cpu_to_le16(sdev_id);
|
info->ld_config.span[0].array_ref = cpu_to_le16(sdev_id);
|
||||||
|
|
||||||
resid = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg, MEMTXATTRS_UNSPECIFIED);
|
residual = dma_buf_read(cmd->iov_buf, dcmd_size, &cmd->qsg,
|
||||||
|
MEMTXATTRS_UNSPECIFIED);
|
||||||
g_free(cmd->iov_buf);
|
g_free(cmd->iov_buf);
|
||||||
cmd->iov_size = dcmd_size - resid;
|
cmd->iov_size = dcmd_size - residual;
|
||||||
cmd->iov_buf = NULL;
|
cmd->iov_buf = NULL;
|
||||||
return MFI_STAT_OK;
|
return MFI_STAT_OK;
|
||||||
}
|
}
|
||||||
|
@ -1617,13 +1625,13 @@ static int megasas_handle_dcmd(MegasasState *s, MegasasCmd *cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int megasas_finish_internal_dcmd(MegasasCmd *cmd,
|
static int megasas_finish_internal_dcmd(MegasasCmd *cmd,
|
||||||
SCSIRequest *req, size_t resid)
|
SCSIRequest *req, size_t residual)
|
||||||
{
|
{
|
||||||
int retval = MFI_STAT_OK;
|
int retval = MFI_STAT_OK;
|
||||||
int lun = req->lun;
|
int lun = req->lun;
|
||||||
|
|
||||||
trace_megasas_dcmd_internal_finish(cmd->index, cmd->dcmd_opcode, lun);
|
trace_megasas_dcmd_internal_finish(cmd->index, cmd->dcmd_opcode, lun);
|
||||||
cmd->iov_size -= resid;
|
cmd->iov_size -= residual;
|
||||||
switch (cmd->dcmd_opcode) {
|
switch (cmd->dcmd_opcode) {
|
||||||
case MFI_DCMD_PD_GET_INFO:
|
case MFI_DCMD_PD_GET_INFO:
|
||||||
retval = megasas_pd_get_info_submit(req->dev, lun, cmd);
|
retval = megasas_pd_get_info_submit(req->dev, lun, cmd);
|
||||||
|
@ -1865,12 +1873,12 @@ static void megasas_xfer_complete(SCSIRequest *req, uint32_t len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void megasas_command_complete(SCSIRequest *req, size_t resid)
|
static void megasas_command_complete(SCSIRequest *req, size_t residual)
|
||||||
{
|
{
|
||||||
MegasasCmd *cmd = req->hba_private;
|
MegasasCmd *cmd = req->hba_private;
|
||||||
uint8_t cmd_status = MFI_STAT_OK;
|
uint8_t cmd_status = MFI_STAT_OK;
|
||||||
|
|
||||||
trace_megasas_command_complete(cmd->index, req->status, resid);
|
trace_megasas_command_complete(cmd->index, req->status, residual);
|
||||||
|
|
||||||
if (req->io_canceled) {
|
if (req->io_canceled) {
|
||||||
return;
|
return;
|
||||||
|
@ -1880,7 +1888,7 @@ static void megasas_command_complete(SCSIRequest *req, size_t resid)
|
||||||
/*
|
/*
|
||||||
* Internal command complete
|
* Internal command complete
|
||||||
*/
|
*/
|
||||||
cmd_status = megasas_finish_internal_dcmd(cmd, req, resid);
|
cmd_status = megasas_finish_internal_dcmd(cmd, req, residual);
|
||||||
if (cmd_status == MFI_STAT_INVALID_STATUS) {
|
if (cmd_status == MFI_STAT_INVALID_STATUS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -760,7 +760,7 @@ SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun,
|
||||||
}
|
}
|
||||||
|
|
||||||
req->cmd = cmd;
|
req->cmd = cmd;
|
||||||
req->resid = req->cmd.xfer;
|
req->residual = req->cmd.xfer;
|
||||||
|
|
||||||
switch (buf[0]) {
|
switch (buf[0]) {
|
||||||
case INQUIRY:
|
case INQUIRY:
|
||||||
|
@ -1408,7 +1408,7 @@ void scsi_req_data(SCSIRequest *req, int len)
|
||||||
trace_scsi_req_data(req->dev->id, req->lun, req->tag, len);
|
trace_scsi_req_data(req->dev->id, req->lun, req->tag, len);
|
||||||
assert(req->cmd.mode != SCSI_XFER_NONE);
|
assert(req->cmd.mode != SCSI_XFER_NONE);
|
||||||
if (!req->sg) {
|
if (!req->sg) {
|
||||||
req->resid -= len;
|
req->residual -= len;
|
||||||
req->bus->info->transfer_data(req, len);
|
req->bus->info->transfer_data(req, len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1421,9 +1421,9 @@ void scsi_req_data(SCSIRequest *req, int len)
|
||||||
|
|
||||||
buf = scsi_req_get_buf(req);
|
buf = scsi_req_get_buf(req);
|
||||||
if (req->cmd.mode == SCSI_XFER_FROM_DEV) {
|
if (req->cmd.mode == SCSI_XFER_FROM_DEV) {
|
||||||
req->resid = dma_buf_read(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED);
|
req->residual = dma_buf_read(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED);
|
||||||
} else {
|
} else {
|
||||||
req->resid = dma_buf_write(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED);
|
req->residual = dma_buf_write(buf, len, req->sg, MEMTXATTRS_UNSPECIFIED);
|
||||||
}
|
}
|
||||||
scsi_req_continue(req);
|
scsi_req_continue(req);
|
||||||
}
|
}
|
||||||
|
@ -1512,7 +1512,7 @@ void scsi_req_complete(SCSIRequest *req, int status)
|
||||||
|
|
||||||
scsi_req_ref(req);
|
scsi_req_ref(req);
|
||||||
scsi_req_dequeue(req);
|
scsi_req_dequeue(req);
|
||||||
req->bus->info->complete(req, req->resid);
|
req->bus->info->complete(req, req->residual);
|
||||||
|
|
||||||
/* Cancelled requests might end up being completed instead of cancelled */
|
/* Cancelled requests might end up being completed instead of cancelled */
|
||||||
notifier_list_notify(&req->cancel_notifiers, req);
|
notifier_list_notify(&req->cancel_notifiers, req);
|
||||||
|
|
|
@ -420,7 +420,7 @@ static void scsi_do_read(SCSIDiskReq *r, int ret)
|
||||||
|
|
||||||
if (r->req.sg) {
|
if (r->req.sg) {
|
||||||
dma_acct_start(s->qdev.conf.blk, &r->acct, r->req.sg, BLOCK_ACCT_READ);
|
dma_acct_start(s->qdev.conf.blk, &r->acct, r->req.sg, BLOCK_ACCT_READ);
|
||||||
r->req.resid -= r->req.sg->size;
|
r->req.residual -= r->req.sg->size;
|
||||||
r->req.aiocb = dma_blk_io(blk_get_aio_context(s->qdev.conf.blk),
|
r->req.aiocb = dma_blk_io(blk_get_aio_context(s->qdev.conf.blk),
|
||||||
r->req.sg, r->sector << BDRV_SECTOR_BITS,
|
r->req.sg, r->sector << BDRV_SECTOR_BITS,
|
||||||
BDRV_SECTOR_SIZE,
|
BDRV_SECTOR_SIZE,
|
||||||
|
@ -580,7 +580,7 @@ static void scsi_write_data(SCSIRequest *req)
|
||||||
|
|
||||||
if (r->req.sg) {
|
if (r->req.sg) {
|
||||||
dma_acct_start(s->qdev.conf.blk, &r->acct, r->req.sg, BLOCK_ACCT_WRITE);
|
dma_acct_start(s->qdev.conf.blk, &r->acct, r->req.sg, BLOCK_ACCT_WRITE);
|
||||||
r->req.resid -= r->req.sg->size;
|
r->req.residual -= r->req.sg->size;
|
||||||
r->req.aiocb = dma_blk_io(blk_get_aio_context(s->qdev.conf.blk),
|
r->req.aiocb = dma_blk_io(blk_get_aio_context(s->qdev.conf.blk),
|
||||||
r->req.sg, r->sector << BDRV_SECTOR_BITS,
|
r->req.sg, r->sector << BDRV_SECTOR_BITS,
|
||||||
BDRV_SECTOR_SIZE,
|
BDRV_SECTOR_SIZE,
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct SCSIRequest {
|
||||||
int16_t status;
|
int16_t status;
|
||||||
int16_t host_status;
|
int16_t host_status;
|
||||||
void *hba_private;
|
void *hba_private;
|
||||||
size_t resid;
|
size_t residual;
|
||||||
SCSICommand cmd;
|
SCSICommand cmd;
|
||||||
NotifierList cancel_notifiers;
|
NotifierList cancel_notifiers;
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ struct SCSIBusInfo {
|
||||||
void *hba_private);
|
void *hba_private);
|
||||||
void (*transfer_data)(SCSIRequest *req, uint32_t arg);
|
void (*transfer_data)(SCSIRequest *req, uint32_t arg);
|
||||||
void (*fail)(SCSIRequest *req);
|
void (*fail)(SCSIRequest *req);
|
||||||
void (*complete)(SCSIRequest *req, size_t resid);
|
void (*complete)(SCSIRequest *req, size_t residual);
|
||||||
void (*cancel)(SCSIRequest *req);
|
void (*cancel)(SCSIRequest *req);
|
||||||
void (*change)(SCSIBus *bus, SCSIDevice *dev, SCSISense sense);
|
void (*change)(SCSIBus *bus, SCSIDevice *dev, SCSISense sense);
|
||||||
QEMUSGList *(*get_sg_list)(SCSIRequest *req);
|
QEMUSGList *(*get_sg_list)(SCSIRequest *req);
|
||||||
|
|
|
@ -294,49 +294,49 @@ BlockAIOCB *dma_blk_write(BlockBackend *blk,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static MemTxResult dma_buf_rw(void *buf, int32_t len, uint64_t *residp,
|
static MemTxResult dma_buf_rw(void *buf, int32_t len, uint64_t *residual,
|
||||||
QEMUSGList *sg, DMADirection dir,
|
QEMUSGList *sg, DMADirection dir,
|
||||||
MemTxAttrs attrs)
|
MemTxAttrs attrs)
|
||||||
{
|
{
|
||||||
uint8_t *ptr = buf;
|
uint8_t *ptr = buf;
|
||||||
uint64_t resid;
|
uint64_t xresidual;
|
||||||
int sg_cur_index;
|
int sg_cur_index;
|
||||||
MemTxResult res = MEMTX_OK;
|
MemTxResult res = MEMTX_OK;
|
||||||
|
|
||||||
resid = sg->size;
|
xresidual = sg->size;
|
||||||
sg_cur_index = 0;
|
sg_cur_index = 0;
|
||||||
len = MIN(len, resid);
|
len = MIN(len, xresidual);
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
ScatterGatherEntry entry = sg->sg[sg_cur_index++];
|
ScatterGatherEntry entry = sg->sg[sg_cur_index++];
|
||||||
int32_t xfer = MIN(len, entry.len);
|
int32_t xfer = MIN(len, entry.len);
|
||||||
res |= dma_memory_rw(sg->as, entry.base, ptr, xfer, dir, attrs);
|
res |= dma_memory_rw(sg->as, entry.base, ptr, xfer, dir, attrs);
|
||||||
ptr += xfer;
|
ptr += xfer;
|
||||||
len -= xfer;
|
len -= xfer;
|
||||||
resid -= xfer;
|
xresidual -= xfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (residp) {
|
if (residual) {
|
||||||
*residp = resid;
|
*residual = xresidual;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs)
|
uint64_t dma_buf_read(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs)
|
||||||
{
|
{
|
||||||
uint64_t resid;
|
uint64_t residual;
|
||||||
|
|
||||||
dma_buf_rw(ptr, len, &resid, sg, DMA_DIRECTION_FROM_DEVICE, attrs);
|
dma_buf_rw(ptr, len, &residual, sg, DMA_DIRECTION_FROM_DEVICE, attrs);
|
||||||
|
|
||||||
return resid;
|
return residual;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs)
|
uint64_t dma_buf_write(void *ptr, int32_t len, QEMUSGList *sg, MemTxAttrs attrs)
|
||||||
{
|
{
|
||||||
uint64_t resid;
|
uint64_t residual;
|
||||||
|
|
||||||
dma_buf_rw(ptr, len, &resid, sg, DMA_DIRECTION_TO_DEVICE, attrs);
|
dma_buf_rw(ptr, len, &residual, sg, DMA_DIRECTION_TO_DEVICE, attrs);
|
||||||
|
|
||||||
return resid;
|
return residual;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie,
|
void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie,
|
||||||
|
|
Loading…
Reference in New Issue