Merge branch '5.3/scsi-sg' into scsi-next
Цей коміт міститься в:
@@ -149,12 +149,10 @@ static inline void initialize_SCp(struct scsi_cmnd *cmd)
|
||||
|
||||
if (scsi_bufflen(cmd)) {
|
||||
cmd->SCp.buffer = scsi_sglist(cmd);
|
||||
cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
|
||||
cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
|
||||
cmd->SCp.this_residual = cmd->SCp.buffer->length;
|
||||
} else {
|
||||
cmd->SCp.buffer = NULL;
|
||||
cmd->SCp.buffers_residual = 0;
|
||||
cmd->SCp.ptr = NULL;
|
||||
cmd->SCp.this_residual = 0;
|
||||
}
|
||||
@@ -163,6 +161,17 @@ static inline void initialize_SCp(struct scsi_cmnd *cmd)
|
||||
cmd->SCp.Message = 0;
|
||||
}
|
||||
|
||||
static inline void advance_sg_buffer(struct scsi_cmnd *cmd)
|
||||
{
|
||||
struct scatterlist *s = cmd->SCp.buffer;
|
||||
|
||||
if (!cmd->SCp.this_residual && s && !sg_is_last(s)) {
|
||||
cmd->SCp.buffer = sg_next(s);
|
||||
cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
|
||||
cmd->SCp.this_residual = cmd->SCp.buffer->length;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NCR5380_poll_politely2 - wait for two chip register values
|
||||
* @hostdata: host private data
|
||||
@@ -1670,12 +1679,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
|
||||
sun3_dma_setup_done != cmd) {
|
||||
int count;
|
||||
|
||||
if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
|
||||
++cmd->SCp.buffer;
|
||||
--cmd->SCp.buffers_residual;
|
||||
cmd->SCp.this_residual = cmd->SCp.buffer->length;
|
||||
cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
|
||||
}
|
||||
advance_sg_buffer(cmd);
|
||||
|
||||
count = sun3scsi_dma_xfer_len(hostdata, cmd);
|
||||
|
||||
@@ -1725,15 +1729,11 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
|
||||
* scatter-gather list, move onto the next one.
|
||||
*/
|
||||
|
||||
if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
|
||||
++cmd->SCp.buffer;
|
||||
--cmd->SCp.buffers_residual;
|
||||
cmd->SCp.this_residual = cmd->SCp.buffer->length;
|
||||
cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
|
||||
dsprintk(NDEBUG_INFORMATION, instance, "%d bytes and %d buffers left\n",
|
||||
cmd->SCp.this_residual,
|
||||
cmd->SCp.buffers_residual);
|
||||
}
|
||||
advance_sg_buffer(cmd);
|
||||
dsprintk(NDEBUG_INFORMATION, instance,
|
||||
"this residual %d, sg ents %d\n",
|
||||
cmd->SCp.this_residual,
|
||||
sg_nents(cmd->SCp.buffer));
|
||||
|
||||
/*
|
||||
* The preferred transfer method is going to be
|
||||
@@ -2126,12 +2126,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance)
|
||||
if (sun3_dma_setup_done != tmp) {
|
||||
int count;
|
||||
|
||||
if (!tmp->SCp.this_residual && tmp->SCp.buffers_residual) {
|
||||
++tmp->SCp.buffer;
|
||||
--tmp->SCp.buffers_residual;
|
||||
tmp->SCp.this_residual = tmp->SCp.buffer->length;
|
||||
tmp->SCp.ptr = sg_virt(tmp->SCp.buffer);
|
||||
}
|
||||
advance_sg_buffer(tmp);
|
||||
|
||||
count = sun3scsi_dma_xfer_len(hostdata, tmp);
|
||||
|
||||
|
@@ -7714,7 +7714,7 @@ adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp,
|
||||
sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
|
||||
return ADV_SUCCESS;
|
||||
}
|
||||
slp++;
|
||||
slp = sg_next(slp);
|
||||
}
|
||||
sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
|
||||
prev_sg_block = sg_block;
|
||||
|
@@ -948,7 +948,6 @@ static int aha152x_internal_queue(struct scsi_cmnd *SCpnt,
|
||||
SCp.ptr : buffer pointer
|
||||
SCp.this_residual : buffer length
|
||||
SCp.buffer : next buffer
|
||||
SCp.buffers_residual : left buffers in list
|
||||
SCp.phase : current state of the command */
|
||||
|
||||
if ((phase & resetting) || !scsi_sglist(SCpnt)) {
|
||||
@@ -956,13 +955,11 @@ static int aha152x_internal_queue(struct scsi_cmnd *SCpnt,
|
||||
SCpnt->SCp.this_residual = 0;
|
||||
scsi_set_resid(SCpnt, 0);
|
||||
SCpnt->SCp.buffer = NULL;
|
||||
SCpnt->SCp.buffers_residual = 0;
|
||||
} else {
|
||||
scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
|
||||
SCpnt->SCp.buffer = scsi_sglist(SCpnt);
|
||||
SCpnt->SCp.ptr = SG_ADDRESS(SCpnt->SCp.buffer);
|
||||
SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
|
||||
SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
|
||||
}
|
||||
|
||||
DO_LOCK(flags);
|
||||
@@ -2030,10 +2027,9 @@ static void datai_run(struct Scsi_Host *shpnt)
|
||||
}
|
||||
|
||||
if (CURRENT_SC->SCp.this_residual == 0 &&
|
||||
CURRENT_SC->SCp.buffers_residual > 0) {
|
||||
!sg_is_last(CURRENT_SC->SCp.buffer)) {
|
||||
/* advance to next buffer */
|
||||
CURRENT_SC->SCp.buffers_residual--;
|
||||
CURRENT_SC->SCp.buffer++;
|
||||
CURRENT_SC->SCp.buffer = sg_next(CURRENT_SC->SCp.buffer);
|
||||
CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer);
|
||||
CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length;
|
||||
}
|
||||
@@ -2136,10 +2132,10 @@ static void datao_run(struct Scsi_Host *shpnt)
|
||||
CMD_INC_RESID(CURRENT_SC, -2 * data_count);
|
||||
}
|
||||
|
||||
if(CURRENT_SC->SCp.this_residual==0 && CURRENT_SC->SCp.buffers_residual>0) {
|
||||
if (CURRENT_SC->SCp.this_residual == 0 &&
|
||||
!sg_is_last(CURRENT_SC->SCp.buffer)) {
|
||||
/* advance to next buffer */
|
||||
CURRENT_SC->SCp.buffers_residual--;
|
||||
CURRENT_SC->SCp.buffer++;
|
||||
CURRENT_SC->SCp.buffer = sg_next(CURRENT_SC->SCp.buffer);
|
||||
CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer);
|
||||
CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length;
|
||||
}
|
||||
@@ -2158,22 +2154,26 @@ static void datao_run(struct Scsi_Host *shpnt)
|
||||
static void datao_end(struct Scsi_Host *shpnt)
|
||||
{
|
||||
if(TESTLO(DMASTAT, DFIFOEMP)) {
|
||||
int data_count = (DATA_LEN - scsi_get_resid(CURRENT_SC)) -
|
||||
GETSTCNT();
|
||||
u32 datao_cnt = GETSTCNT();
|
||||
int datao_out = DATA_LEN - scsi_get_resid(CURRENT_SC);
|
||||
int done;
|
||||
struct scatterlist *sg = scsi_sglist(CURRENT_SC);
|
||||
|
||||
CMD_INC_RESID(CURRENT_SC, data_count);
|
||||
CMD_INC_RESID(CURRENT_SC, datao_out - datao_cnt);
|
||||
|
||||
data_count -= CURRENT_SC->SCp.ptr -
|
||||
SG_ADDRESS(CURRENT_SC->SCp.buffer);
|
||||
while(data_count>0) {
|
||||
CURRENT_SC->SCp.buffer--;
|
||||
CURRENT_SC->SCp.buffers_residual++;
|
||||
data_count -= CURRENT_SC->SCp.buffer->length;
|
||||
done = scsi_bufflen(CURRENT_SC) - scsi_get_resid(CURRENT_SC);
|
||||
/* Locate the first SG entry not yet sent */
|
||||
while (done > 0 && !sg_is_last(sg)) {
|
||||
if (done < sg->length)
|
||||
break;
|
||||
done -= sg->length;
|
||||
sg = sg_next(sg);
|
||||
}
|
||||
CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) -
|
||||
data_count;
|
||||
CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length +
|
||||
data_count;
|
||||
|
||||
CURRENT_SC->SCp.buffer = sg;
|
||||
CURRENT_SC->SCp.ptr = SG_ADDRESS(CURRENT_SC->SCp.buffer) + done;
|
||||
CURRENT_SC->SCp.this_residual = CURRENT_SC->SCp.buffer->length -
|
||||
done;
|
||||
}
|
||||
|
||||
SETPORT(SXFRCTL0, CH1|CLRCH1|CLRSTCNT);
|
||||
@@ -2501,7 +2501,7 @@ static void get_command(struct seq_file *m, struct scsi_cmnd * ptr)
|
||||
|
||||
seq_printf(m, "); resid=%d; residual=%d; buffers=%d; phase |",
|
||||
scsi_get_resid(ptr), ptr->SCp.this_residual,
|
||||
ptr->SCp.buffers_residual);
|
||||
sg_nents(ptr->SCp.buffer) - 1);
|
||||
|
||||
if (ptr->SCp.phase & not_issued)
|
||||
seq_puts(m, "not issued|");
|
||||
|
@@ -370,6 +370,7 @@ static void esp_map_dma(struct esp *esp, struct scsi_cmnd *cmd)
|
||||
struct esp_cmd_priv *spriv = ESP_CMD_PRIV(cmd);
|
||||
struct scatterlist *sg = scsi_sglist(cmd);
|
||||
int total = 0, i;
|
||||
struct scatterlist *s;
|
||||
|
||||
if (cmd->sc_data_direction == DMA_NONE)
|
||||
return;
|
||||
@@ -380,16 +381,18 @@ static void esp_map_dma(struct esp *esp, struct scsi_cmnd *cmd)
|
||||
* a dma address, so perform an identity mapping.
|
||||
*/
|
||||
spriv->num_sg = scsi_sg_count(cmd);
|
||||
for (i = 0; i < spriv->num_sg; i++) {
|
||||
sg[i].dma_address = (uintptr_t)sg_virt(&sg[i]);
|
||||
total += sg_dma_len(&sg[i]);
|
||||
|
||||
scsi_for_each_sg(cmd, s, spriv->num_sg, i) {
|
||||
s->dma_address = (uintptr_t)sg_virt(s);
|
||||
total += sg_dma_len(s);
|
||||
}
|
||||
} else {
|
||||
spriv->num_sg = scsi_dma_map(cmd);
|
||||
for (i = 0; i < spriv->num_sg; i++)
|
||||
total += sg_dma_len(&sg[i]);
|
||||
scsi_for_each_sg(cmd, s, spriv->num_sg, i)
|
||||
total += sg_dma_len(s);
|
||||
}
|
||||
spriv->cur_residue = sg_dma_len(sg);
|
||||
spriv->prv_sg = NULL;
|
||||
spriv->cur_sg = sg;
|
||||
spriv->tot_residue = total;
|
||||
}
|
||||
@@ -443,7 +446,8 @@ static void esp_advance_dma(struct esp *esp, struct esp_cmd_entry *ent,
|
||||
p->tot_residue = 0;
|
||||
}
|
||||
if (!p->cur_residue && p->tot_residue) {
|
||||
p->cur_sg++;
|
||||
p->prv_sg = p->cur_sg;
|
||||
p->cur_sg = sg_next(p->cur_sg);
|
||||
p->cur_residue = sg_dma_len(p->cur_sg);
|
||||
}
|
||||
}
|
||||
@@ -464,6 +468,7 @@ static void esp_save_pointers(struct esp *esp, struct esp_cmd_entry *ent)
|
||||
return;
|
||||
}
|
||||
ent->saved_cur_residue = spriv->cur_residue;
|
||||
ent->saved_prv_sg = spriv->prv_sg;
|
||||
ent->saved_cur_sg = spriv->cur_sg;
|
||||
ent->saved_tot_residue = spriv->tot_residue;
|
||||
}
|
||||
@@ -478,6 +483,7 @@ static void esp_restore_pointers(struct esp *esp, struct esp_cmd_entry *ent)
|
||||
return;
|
||||
}
|
||||
spriv->cur_residue = ent->saved_cur_residue;
|
||||
spriv->prv_sg = ent->saved_prv_sg;
|
||||
spriv->cur_sg = ent->saved_cur_sg;
|
||||
spriv->tot_residue = ent->saved_tot_residue;
|
||||
}
|
||||
@@ -1646,7 +1652,7 @@ static int esp_msgin_process(struct esp *esp)
|
||||
spriv = ESP_CMD_PRIV(ent->cmd);
|
||||
|
||||
if (spriv->cur_residue == sg_dma_len(spriv->cur_sg)) {
|
||||
spriv->cur_sg--;
|
||||
spriv->cur_sg = spriv->prv_sg;
|
||||
spriv->cur_residue = 1;
|
||||
} else
|
||||
spriv->cur_residue++;
|
||||
|
@@ -251,6 +251,7 @@
|
||||
struct esp_cmd_priv {
|
||||
int num_sg;
|
||||
int cur_residue;
|
||||
struct scatterlist *prv_sg;
|
||||
struct scatterlist *cur_sg;
|
||||
int tot_residue;
|
||||
};
|
||||
@@ -273,6 +274,7 @@ struct esp_cmd_entry {
|
||||
struct scsi_cmnd *cmd;
|
||||
|
||||
unsigned int saved_cur_residue;
|
||||
struct scatterlist *saved_prv_sg;
|
||||
struct scatterlist *saved_cur_sg;
|
||||
unsigned int saved_tot_residue;
|
||||
|
||||
|
@@ -686,7 +686,7 @@ static int imm_completion(struct scsi_cmnd *cmd)
|
||||
if (cmd->SCp.buffer && !cmd->SCp.this_residual) {
|
||||
/* if scatter/gather, advance to the next segment */
|
||||
if (cmd->SCp.buffers_residual--) {
|
||||
cmd->SCp.buffer++;
|
||||
cmd->SCp.buffer = sg_next(cmd->SCp.buffer);
|
||||
cmd->SCp.this_residual =
|
||||
cmd->SCp.buffer->length;
|
||||
cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
|
||||
|
@@ -3915,22 +3915,23 @@ static int ipr_copy_ucode_buffer(struct ipr_sglist *sglist,
|
||||
u8 *buffer, u32 len)
|
||||
{
|
||||
int bsize_elem, i, result = 0;
|
||||
struct scatterlist *scatterlist;
|
||||
struct scatterlist *sg;
|
||||
void *kaddr;
|
||||
|
||||
/* Determine the actual number of bytes per element */
|
||||
bsize_elem = PAGE_SIZE * (1 << sglist->order);
|
||||
|
||||
scatterlist = sglist->scatterlist;
|
||||
sg = sglist->scatterlist;
|
||||
|
||||
for (i = 0; i < (len / bsize_elem); i++, buffer += bsize_elem) {
|
||||
struct page *page = sg_page(&scatterlist[i]);
|
||||
for (i = 0; i < (len / bsize_elem); i++, sg = sg_next(sg),
|
||||
buffer += bsize_elem) {
|
||||
struct page *page = sg_page(sg);
|
||||
|
||||
kaddr = kmap(page);
|
||||
memcpy(kaddr, buffer, bsize_elem);
|
||||
kunmap(page);
|
||||
|
||||
scatterlist[i].length = bsize_elem;
|
||||
sg->length = bsize_elem;
|
||||
|
||||
if (result != 0) {
|
||||
ipr_trace;
|
||||
@@ -3939,13 +3940,13 @@ static int ipr_copy_ucode_buffer(struct ipr_sglist *sglist,
|
||||
}
|
||||
|
||||
if (len % bsize_elem) {
|
||||
struct page *page = sg_page(&scatterlist[i]);
|
||||
struct page *page = sg_page(sg);
|
||||
|
||||
kaddr = kmap(page);
|
||||
memcpy(kaddr, buffer, len % bsize_elem);
|
||||
kunmap(page);
|
||||
|
||||
scatterlist[i].length = len % bsize_elem;
|
||||
sg->length = len % bsize_elem;
|
||||
}
|
||||
|
||||
sglist->buffer_len = len;
|
||||
@@ -3966,6 +3967,7 @@ static void ipr_build_ucode_ioadl64(struct ipr_cmnd *ipr_cmd,
|
||||
struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb;
|
||||
struct ipr_ioadl64_desc *ioadl64 = ipr_cmd->i.ioadl64;
|
||||
struct scatterlist *scatterlist = sglist->scatterlist;
|
||||
struct scatterlist *sg;
|
||||
int i;
|
||||
|
||||
ipr_cmd->dma_use_sg = sglist->num_dma_sg;
|
||||
@@ -3974,10 +3976,10 @@ static void ipr_build_ucode_ioadl64(struct ipr_cmnd *ipr_cmd,
|
||||
|
||||
ioarcb->ioadl_len =
|
||||
cpu_to_be32(sizeof(struct ipr_ioadl64_desc) * ipr_cmd->dma_use_sg);
|
||||
for (i = 0; i < ipr_cmd->dma_use_sg; i++) {
|
||||
for_each_sg(scatterlist, sg, ipr_cmd->dma_use_sg, i) {
|
||||
ioadl64[i].flags = cpu_to_be32(IPR_IOADL_FLAGS_WRITE);
|
||||
ioadl64[i].data_len = cpu_to_be32(sg_dma_len(&scatterlist[i]));
|
||||
ioadl64[i].address = cpu_to_be64(sg_dma_address(&scatterlist[i]));
|
||||
ioadl64[i].data_len = cpu_to_be32(sg_dma_len(sg));
|
||||
ioadl64[i].address = cpu_to_be64(sg_dma_address(sg));
|
||||
}
|
||||
|
||||
ioadl64[i-1].flags |= cpu_to_be32(IPR_IOADL_FLAGS_LAST);
|
||||
@@ -3997,6 +3999,7 @@ static void ipr_build_ucode_ioadl(struct ipr_cmnd *ipr_cmd,
|
||||
struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb;
|
||||
struct ipr_ioadl_desc *ioadl = ipr_cmd->i.ioadl;
|
||||
struct scatterlist *scatterlist = sglist->scatterlist;
|
||||
struct scatterlist *sg;
|
||||
int i;
|
||||
|
||||
ipr_cmd->dma_use_sg = sglist->num_dma_sg;
|
||||
@@ -4006,11 +4009,11 @@ static void ipr_build_ucode_ioadl(struct ipr_cmnd *ipr_cmd,
|
||||
ioarcb->ioadl_len =
|
||||
cpu_to_be32(sizeof(struct ipr_ioadl_desc) * ipr_cmd->dma_use_sg);
|
||||
|
||||
for (i = 0; i < ipr_cmd->dma_use_sg; i++) {
|
||||
for_each_sg(scatterlist, sg, ipr_cmd->dma_use_sg, i) {
|
||||
ioadl[i].flags_and_data_len =
|
||||
cpu_to_be32(IPR_IOADL_FLAGS_WRITE | sg_dma_len(&scatterlist[i]));
|
||||
cpu_to_be32(IPR_IOADL_FLAGS_WRITE | sg_dma_len(sg));
|
||||
ioadl[i].address =
|
||||
cpu_to_be32(sg_dma_address(&scatterlist[i]));
|
||||
cpu_to_be32(sg_dma_address(sg));
|
||||
}
|
||||
|
||||
ioadl[i-1].flags_and_data_len |=
|
||||
|
@@ -2887,8 +2887,7 @@ lpfc_nvmet_prep_fcp_wqe(struct lpfc_hba *phba,
|
||||
nvmewqe->drvrTimeout = (phba->fc_ratov * 3) + LPFC_DRVR_TIMEOUT;
|
||||
nvmewqe->context1 = ndlp;
|
||||
|
||||
for (i = 0; i < rsp->sg_cnt; i++) {
|
||||
sgel = &rsp->sg[i];
|
||||
for_each_sg(rsp->sg, sgel, rsp->sg_cnt, i) {
|
||||
physaddr = sg_dma_address(sgel);
|
||||
cnt = sg_dma_len(sgel);
|
||||
sgl->addr_hi = putPaddrHigh(physaddr);
|
||||
|
@@ -211,23 +211,22 @@ static int mvumi_make_sgl(struct mvumi_hba *mhba, struct scsi_cmnd *scmd,
|
||||
unsigned int sgnum = scsi_sg_count(scmd);
|
||||
dma_addr_t busaddr;
|
||||
|
||||
sg = scsi_sglist(scmd);
|
||||
*sg_count = dma_map_sg(&mhba->pdev->dev, sg, sgnum,
|
||||
*sg_count = dma_map_sg(&mhba->pdev->dev, scsi_sglist(scmd), sgnum,
|
||||
scmd->sc_data_direction);
|
||||
if (*sg_count > mhba->max_sge) {
|
||||
dev_err(&mhba->pdev->dev,
|
||||
"sg count[0x%x] is bigger than max sg[0x%x].\n",
|
||||
*sg_count, mhba->max_sge);
|
||||
dma_unmap_sg(&mhba->pdev->dev, sg, sgnum,
|
||||
dma_unmap_sg(&mhba->pdev->dev, scsi_sglist(scmd), sgnum,
|
||||
scmd->sc_data_direction);
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < *sg_count; i++) {
|
||||
busaddr = sg_dma_address(&sg[i]);
|
||||
scsi_for_each_sg(scmd, sg, *sg_count, i) {
|
||||
busaddr = sg_dma_address(sg);
|
||||
m_sg->baseaddr_l = cpu_to_le32(lower_32_bits(busaddr));
|
||||
m_sg->baseaddr_h = cpu_to_le32(upper_32_bits(busaddr));
|
||||
m_sg->flags = 0;
|
||||
sgd_setsz(mhba, m_sg, cpu_to_le32(sg_dma_len(&sg[i])));
|
||||
sgd_setsz(mhba, m_sg, cpu_to_le32(sg_dma_len(sg)));
|
||||
if ((i + 1) == *sg_count)
|
||||
m_sg->flags |= 1U << mhba->eot_flag;
|
||||
|
||||
|
@@ -789,7 +789,7 @@ static void nsp_pio_read(struct scsi_cmnd *SCpnt)
|
||||
SCpnt->SCp.buffers_residual != 0 ) {
|
||||
//nsp_dbg(NSP_DEBUG_DATA_IO, "scatterlist next timeout=%d", time_out);
|
||||
SCpnt->SCp.buffers_residual--;
|
||||
SCpnt->SCp.buffer++;
|
||||
SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer);
|
||||
SCpnt->SCp.ptr = BUFFER_ADDR;
|
||||
SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
|
||||
time_out = 1000;
|
||||
@@ -887,7 +887,7 @@ static void nsp_pio_write(struct scsi_cmnd *SCpnt)
|
||||
SCpnt->SCp.buffers_residual != 0 ) {
|
||||
//nsp_dbg(NSP_DEBUG_DATA_IO, "scatterlist next");
|
||||
SCpnt->SCp.buffers_residual--;
|
||||
SCpnt->SCp.buffer++;
|
||||
SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer);
|
||||
SCpnt->SCp.ptr = BUFFER_ADDR;
|
||||
SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
|
||||
time_out = 1000;
|
||||
|
@@ -3270,7 +3270,7 @@ static int pmcraid_copy_sglist(
|
||||
int direction
|
||||
)
|
||||
{
|
||||
struct scatterlist *scatterlist;
|
||||
struct scatterlist *sg;
|
||||
void *kaddr;
|
||||
int bsize_elem;
|
||||
int i;
|
||||
@@ -3279,10 +3279,10 @@ static int pmcraid_copy_sglist(
|
||||
/* Determine the actual number of bytes per element */
|
||||
bsize_elem = PAGE_SIZE * (1 << sglist->order);
|
||||
|
||||
scatterlist = sglist->scatterlist;
|
||||
sg = sglist->scatterlist;
|
||||
|
||||
for (i = 0; i < (len / bsize_elem); i++, buffer += bsize_elem) {
|
||||
struct page *page = sg_page(&scatterlist[i]);
|
||||
for (i = 0; i < (len / bsize_elem); i++, sg = sg_next(sg), buffer += bsize_elem) {
|
||||
struct page *page = sg_page(sg);
|
||||
|
||||
kaddr = kmap(page);
|
||||
if (direction == DMA_TO_DEVICE)
|
||||
@@ -3297,11 +3297,11 @@ static int pmcraid_copy_sglist(
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
scatterlist[i].length = bsize_elem;
|
||||
sg->length = bsize_elem;
|
||||
}
|
||||
|
||||
if (len % bsize_elem) {
|
||||
struct page *page = sg_page(&scatterlist[i]);
|
||||
struct page *page = sg_page(sg);
|
||||
|
||||
kaddr = kmap(page);
|
||||
|
||||
@@ -3312,7 +3312,7 @@ static int pmcraid_copy_sglist(
|
||||
|
||||
kunmap(page);
|
||||
|
||||
scatterlist[i].length = len % bsize_elem;
|
||||
sg->length = len % bsize_elem;
|
||||
}
|
||||
|
||||
if (rc) {
|
||||
|
@@ -590,7 +590,7 @@ static int ppa_completion(struct scsi_cmnd *cmd)
|
||||
if (cmd->SCp.buffer && !cmd->SCp.this_residual) {
|
||||
/* if scatter/gather, advance to the next segment */
|
||||
if (cmd->SCp.buffers_residual--) {
|
||||
cmd->SCp.buffer++;
|
||||
cmd->SCp.buffer = sg_next(cmd->SCp.buffer);
|
||||
cmd->SCp.this_residual =
|
||||
cmd->SCp.buffer->length;
|
||||
cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
|
||||
|
@@ -40,6 +40,18 @@
|
||||
#include "scsi_priv.h"
|
||||
#include "scsi_logging.h"
|
||||
|
||||
/*
|
||||
* Size of integrity metadata is usually small, 1 inline sg should
|
||||
* cover normal cases.
|
||||
*/
|
||||
#ifdef CONFIG_ARCH_NO_SG_CHAIN
|
||||
#define SCSI_INLINE_PROT_SG_CNT 0
|
||||
#define SCSI_INLINE_SG_CNT 0
|
||||
#else
|
||||
#define SCSI_INLINE_PROT_SG_CNT 1
|
||||
#define SCSI_INLINE_SG_CNT 2
|
||||
#endif
|
||||
|
||||
static struct kmem_cache *scsi_sdb_cache;
|
||||
static struct kmem_cache *scsi_sense_cache;
|
||||
static struct kmem_cache *scsi_sense_isadma_cache;
|
||||
@@ -542,9 +554,11 @@ static void scsi_uninit_cmd(struct scsi_cmnd *cmd)
|
||||
static void scsi_mq_free_sgtables(struct scsi_cmnd *cmd)
|
||||
{
|
||||
if (cmd->sdb.table.nents)
|
||||
sg_free_table_chained(&cmd->sdb.table, true);
|
||||
sg_free_table_chained(&cmd->sdb.table,
|
||||
SCSI_INLINE_SG_CNT);
|
||||
if (scsi_prot_sg_count(cmd))
|
||||
sg_free_table_chained(&cmd->prot_sdb->table, true);
|
||||
sg_free_table_chained(&cmd->prot_sdb->table,
|
||||
SCSI_INLINE_PROT_SG_CNT);
|
||||
}
|
||||
|
||||
static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
|
||||
@@ -977,7 +991,8 @@ static blk_status_t scsi_init_sgtable(struct request *req,
|
||||
* If sg table allocation fails, requeue request later.
|
||||
*/
|
||||
if (unlikely(sg_alloc_table_chained(&sdb->table,
|
||||
blk_rq_nr_phys_segments(req), sdb->table.sgl)))
|
||||
blk_rq_nr_phys_segments(req), sdb->table.sgl,
|
||||
SCSI_INLINE_SG_CNT)))
|
||||
return BLK_STS_RESOURCE;
|
||||
|
||||
/*
|
||||
@@ -1031,7 +1046,8 @@ blk_status_t scsi_init_io(struct scsi_cmnd *cmd)
|
||||
ivecs = blk_rq_count_integrity_sg(rq->q, rq->bio);
|
||||
|
||||
if (sg_alloc_table_chained(&prot_sdb->table, ivecs,
|
||||
prot_sdb->table.sgl)) {
|
||||
prot_sdb->table.sgl,
|
||||
SCSI_INLINE_PROT_SG_CNT)) {
|
||||
ret = BLK_STS_RESOURCE;
|
||||
goto out_free_sgtables;
|
||||
}
|
||||
@@ -1542,9 +1558,9 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
|
||||
}
|
||||
|
||||
/* Size in bytes of the sg-list stored in the scsi-mq command-private data. */
|
||||
static unsigned int scsi_mq_sgl_size(struct Scsi_Host *shost)
|
||||
static unsigned int scsi_mq_inline_sgl_size(struct Scsi_Host *shost)
|
||||
{
|
||||
return min_t(unsigned int, shost->sg_tablesize, SG_CHUNK_SIZE) *
|
||||
return min_t(unsigned int, shost->sg_tablesize, SCSI_INLINE_SG_CNT) *
|
||||
sizeof(struct scatterlist);
|
||||
}
|
||||
|
||||
@@ -1726,7 +1742,7 @@ static int scsi_mq_init_request(struct blk_mq_tag_set *set, struct request *rq,
|
||||
if (scsi_host_get_prot(shost)) {
|
||||
sg = (void *)cmd + sizeof(struct scsi_cmnd) +
|
||||
shost->hostt->cmd_size;
|
||||
cmd->prot_sdb = (void *)sg + scsi_mq_sgl_size(shost);
|
||||
cmd->prot_sdb = (void *)sg + scsi_mq_inline_sgl_size(shost);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1820,10 +1836,11 @@ int scsi_mq_setup_tags(struct Scsi_Host *shost)
|
||||
{
|
||||
unsigned int cmd_size, sgl_size;
|
||||
|
||||
sgl_size = scsi_mq_sgl_size(shost);
|
||||
sgl_size = scsi_mq_inline_sgl_size(shost);
|
||||
cmd_size = sizeof(struct scsi_cmnd) + shost->hostt->cmd_size + sgl_size;
|
||||
if (scsi_host_get_prot(shost))
|
||||
cmd_size += sizeof(struct scsi_data_buffer) + sgl_size;
|
||||
cmd_size += sizeof(struct scsi_data_buffer) +
|
||||
sizeof(struct scatterlist) * SCSI_INLINE_PROT_SG_CNT;
|
||||
|
||||
memset(&shost->tag_set, 0, sizeof(shost->tag_set));
|
||||
shost->tag_set.ops = &scsi_mq_ops;
|
||||
|
@@ -335,7 +335,7 @@ static void pvscsi_create_sg(struct pvscsi_ctx *ctx,
|
||||
BUG_ON(count > PVSCSI_MAX_NUM_SG_ENTRIES_PER_SEGMENT);
|
||||
|
||||
sge = &ctx->sgl->sge[0];
|
||||
for (i = 0; i < count; i++, sg++) {
|
||||
for (i = 0; i < count; i++, sg = sg_next(sg)) {
|
||||
sge[i].addr = sg_dma_address(sg);
|
||||
sge[i].length = sg_dma_len(sg);
|
||||
sge[i].flags = 0;
|
||||
|
@@ -744,7 +744,7 @@ transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd,
|
||||
* source or destination for THIS transfer.
|
||||
*/
|
||||
if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
|
||||
++cmd->SCp.buffer;
|
||||
cmd->SCp.buffer = sg_next(cmd->SCp.buffer);
|
||||
--cmd->SCp.buffers_residual;
|
||||
cmd->SCp.this_residual = cmd->SCp.buffer->length;
|
||||
cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
|
||||
|
Посилання в новій задачі
Заблокувати користувача