Skip to content

Commit

Permalink
Merge branch 'misc' into for-next
Browse files Browse the repository at this point in the history
  • Loading branch information
James Bottomley authored and James Bottomley committed Feb 27, 2021
2 parents 89263de + f749d8b commit 586b0f0
Show file tree
Hide file tree
Showing 12 changed files with 185 additions and 107 deletions.
2 changes: 1 addition & 1 deletion drivers/scsi/aic7xxx/aic79xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ struct ahd_softc {
uint8_t tqinfifonext;

/*
* Cached verson of the hs_mailbox so we can avoid
* Cached version of the hs_mailbox so we can avoid
* pausing the sequencer during mailbox updates.
*/
uint8_t hs_mailbox;
Expand Down
2 changes: 0 additions & 2 deletions drivers/scsi/aic7xxx/aic7xxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,6 @@ union ahc_bus_softc {

typedef void (*ahc_bus_intr_t)(struct ahc_softc *);
typedef int (*ahc_bus_chip_init_t)(struct ahc_softc *);
typedef int (*ahc_bus_suspend_t)(struct ahc_softc *);
typedef int (*ahc_bus_resume_t)(struct ahc_softc *);
typedef void ahc_callback_t (void *);

struct ahc_softc {
Expand Down
1 change: 1 addition & 0 deletions drivers/scsi/bnx2fc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ config SCSI_BNX2X_FCOE
depends on (IPV6 || IPV6=n)
depends on LIBFC
depends on LIBFCOE
depends on MMU
select NETDEVICES
select ETHERNET
select NET_VENDOR_BROADCOM
Expand Down
51 changes: 44 additions & 7 deletions drivers/scsi/hpsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,10 @@ static void __enqueue_cmd_and_start_io(struct ctlr_info *h,
{
dial_down_lockup_detection_during_fw_flash(h, c);
atomic_inc(&h->commands_outstanding);
if (c->device)
/*
* Check to see if the command is being retried.
*/
if (c->device && !c->retry_pending)
atomic_inc(&c->device->commands_outstanding);

reply_queue = h->reply_map[raw_smp_processor_id()];
Expand Down Expand Up @@ -5567,7 +5570,8 @@ static inline void hpsa_cmd_partial_init(struct ctlr_info *h, int index,
}

static int hpsa_ioaccel_submit(struct ctlr_info *h,
struct CommandList *c, struct scsi_cmnd *cmd)
struct CommandList *c, struct scsi_cmnd *cmd,
bool retry)
{
struct hpsa_scsi_dev_t *dev = cmd->device->hostdata;
int rc = IO_ACCEL_INELIGIBLE;
Expand All @@ -5584,18 +5588,22 @@ static int hpsa_ioaccel_submit(struct ctlr_info *h,
cmd->host_scribble = (unsigned char *) c;

if (dev->offload_enabled) {
hpsa_cmd_init(h, c->cmdindex, c);
hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */
c->cmd_type = CMD_SCSI;
c->scsi_cmd = cmd;
c->device = dev;
if (retry) /* Resubmit but do not increment device->commands_outstanding. */
c->retry_pending = true;
rc = hpsa_scsi_ioaccel_raid_map(h, c);
if (rc < 0) /* scsi_dma_map failed. */
rc = SCSI_MLQUEUE_HOST_BUSY;
} else if (dev->hba_ioaccel_enabled) {
hpsa_cmd_init(h, c->cmdindex, c);
hpsa_cmd_init(h, c->cmdindex, c); /* Zeroes out all fields */
c->cmd_type = CMD_SCSI;
c->scsi_cmd = cmd;
c->device = dev;
if (retry) /* Resubmit but do not increment device->commands_outstanding. */
c->retry_pending = true;
rc = hpsa_scsi_ioaccel_direct_map(h, c);
if (rc < 0) /* scsi_dma_map failed. */
rc = SCSI_MLQUEUE_HOST_BUSY;
Expand Down Expand Up @@ -5628,7 +5636,8 @@ static void hpsa_command_resubmit_worker(struct work_struct *work)

if (c2->error_data.serv_response ==
IOACCEL2_STATUS_SR_TASK_COMP_SET_FULL) {
rc = hpsa_ioaccel_submit(h, c, cmd);
/* Resubmit with the retry_pending flag set. */
rc = hpsa_ioaccel_submit(h, c, cmd, true);
if (rc == 0)
return;
if (rc == SCSI_MLQUEUE_HOST_BUSY) {
Expand All @@ -5644,6 +5653,15 @@ static void hpsa_command_resubmit_worker(struct work_struct *work)
}
}
hpsa_cmd_partial_init(c->h, c->cmdindex, c);
/*
* Here we have not come in though queue_command, so we
* can set the retry_pending flag to true for a driver initiated
* retry attempt (I.E. not a SML retry).
* I.E. We are submitting a driver initiated retry.
* Note: hpsa_ciss_submit does not zero out the command fields like
* ioaccel submit does.
*/
c->retry_pending = true;
if (hpsa_ciss_submit(c->h, c, cmd, dev)) {
/*
* If we get here, it means dma mapping failed. Try
Expand Down Expand Up @@ -5706,11 +5724,16 @@ static int hpsa_scsi_queue_command(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
/*
* Call alternate submit routine for I/O accelerated commands.
* Retries always go down the normal I/O path.
* Note: If cmd->retries is non-zero, then this is a SML
* initiated retry and not a driver initiated retry.
* This command has been obtained from cmd_tagged_alloc
* and is therefore a brand-new command.
*/
if (likely(cmd->retries == 0 &&
!blk_rq_is_passthrough(cmd->request) &&
h->acciopath_status)) {
rc = hpsa_ioaccel_submit(h, c, cmd);
/* Submit with the retry_pending flag unset. */
rc = hpsa_ioaccel_submit(h, c, cmd, false);
if (rc == 0)
return 0;
if (rc == SCSI_MLQUEUE_HOST_BUSY) {
Expand Down Expand Up @@ -6105,6 +6128,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
* at init, and managed by cmd_tagged_alloc() and cmd_tagged_free() using the
* block request tag as an index into a table of entries. cmd_tagged_free() is
* the complement, although cmd_free() may be called instead.
* This function is only called for new requests from queue_command.
*/
static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h,
struct scsi_cmnd *scmd)
Expand Down Expand Up @@ -6139,8 +6163,14 @@ static struct CommandList *cmd_tagged_alloc(struct ctlr_info *h,
}

atomic_inc(&c->refcount);

hpsa_cmd_partial_init(h, idx, c);

/*
* This is a new command obtained from queue_command so
* there have not been any driver initiated retry attempts.
*/
c->retry_pending = false;

return c;
}

Expand Down Expand Up @@ -6208,6 +6238,13 @@ static struct CommandList *cmd_alloc(struct ctlr_info *h)
}
hpsa_cmd_partial_init(h, i, c);
c->device = NULL;

/*
* cmd_alloc is for "internal" commands and they are never
* retried.
*/
c->retry_pending = false;

return c;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/hpsa_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ struct CommandList {
*/
struct hpsa_scsi_dev_t *phys_disk;

int abort_pending;
bool retry_pending;
struct hpsa_scsi_dev_t *device;
atomic_t refcount; /* Must be last to avoid memset in hpsa_cmd_init() */
} __aligned(COMMANDLIST_ALIGNMENT);
Expand Down
6 changes: 3 additions & 3 deletions drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,9 @@ static int sd_sec_submit(void *data, u16 spsp, u8 secp, void *buffer,
put_unaligned_be16(spsp, &cdb[2]);
put_unaligned_be32(len, &cdb[6]);

ret = scsi_execute_req(sdev, cdb,
send ? DMA_TO_DEVICE : DMA_FROM_DEVICE,
buffer, len, NULL, SD_TIMEOUT, sdkp->max_retries, NULL);
ret = scsi_execute(sdev, cdb, send ? DMA_TO_DEVICE : DMA_FROM_DEVICE,
buffer, len, NULL, NULL, SD_TIMEOUT, sdkp->max_retries, 0,
RQF_PM, NULL);
return ret <= 0 ? ret : -EIO;
}
#endif /* CONFIG_BLK_SED_OPAL */
Expand Down
6 changes: 5 additions & 1 deletion drivers/scsi/sd_zbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
unsigned int nr_zones = sdkp->rev_nr_zones;
u32 max_append;
int ret = 0;
unsigned int flags;

/*
* For all zoned disks, initialize zone append emulation data if not
Expand Down Expand Up @@ -720,16 +721,19 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
disk->queue->nr_zones == nr_zones)
goto unlock;

flags = memalloc_noio_save();
sdkp->zone_blocks = zone_blocks;
sdkp->nr_zones = nr_zones;
sdkp->rev_wp_offset = kvcalloc(nr_zones, sizeof(u32), GFP_NOIO);
sdkp->rev_wp_offset = kvcalloc(nr_zones, sizeof(u32), GFP_KERNEL);
if (!sdkp->rev_wp_offset) {
ret = -ENOMEM;
memalloc_noio_restore(flags);
goto unlock;
}

ret = blk_revalidate_disk_zones(disk, sd_zbc_revalidate_zones_cb);

memalloc_noio_restore(flags);
kvfree(sdkp->rev_wp_offset);
sdkp->rev_wp_offset = NULL;

Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/ufs/ufshcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ enum ufshcd_quirks {
/*
* This quirk allows only sg entries aligned with page size.
*/
UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE = 1 << 13,
UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE = 1 << 14,
};

enum ufshcd_caps {
Expand Down
15 changes: 11 additions & 4 deletions drivers/target/target_core_pr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3739,6 +3739,7 @@ core_scsi3_pri_read_keys(struct se_cmd *cmd)
spin_unlock(&dev->t10_pr.registration_lock);

put_unaligned_be32(add_len, &buf[4]);
target_set_cmd_data_length(cmd, 8 + add_len);

transport_kunmap_data_sg(cmd);

Expand All @@ -3757,7 +3758,7 @@ core_scsi3_pri_read_reservation(struct se_cmd *cmd)
struct t10_pr_registration *pr_reg;
unsigned char *buf;
u64 pr_res_key;
u32 add_len = 16; /* Hardcoded to 16 when a reservation is held. */
u32 add_len = 0;

if (cmd->data_length < 8) {
pr_err("PRIN SA READ_RESERVATIONS SCSI Data Length: %u"
Expand All @@ -3775,8 +3776,9 @@ core_scsi3_pri_read_reservation(struct se_cmd *cmd)
pr_reg = dev->dev_pr_res_holder;
if (pr_reg) {
/*
* Set the hardcoded Additional Length
* Set the Additional Length to 16 when a reservation is held
*/
add_len = 16;
put_unaligned_be32(add_len, &buf[4]);

if (cmd->data_length < 22)
Expand Down Expand Up @@ -3812,6 +3814,8 @@ core_scsi3_pri_read_reservation(struct se_cmd *cmd)
(pr_reg->pr_res_type & 0x0f);
}

target_set_cmd_data_length(cmd, 8 + add_len);

err:
spin_unlock(&dev->dev_reservation_lock);
transport_kunmap_data_sg(cmd);
Expand All @@ -3830,7 +3834,7 @@ core_scsi3_pri_report_capabilities(struct se_cmd *cmd)
struct se_device *dev = cmd->se_dev;
struct t10_reservation *pr_tmpl = &dev->t10_pr;
unsigned char *buf;
u16 add_len = 8; /* Hardcoded to 8. */
u16 len = 8; /* Hardcoded to 8. */

if (cmd->data_length < 6) {
pr_err("PRIN SA REPORT_CAPABILITIES SCSI Data Length:"
Expand All @@ -3842,7 +3846,7 @@ core_scsi3_pri_report_capabilities(struct se_cmd *cmd)
if (!buf)
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;

put_unaligned_be16(add_len, &buf[0]);
put_unaligned_be16(len, &buf[0]);
buf[2] |= 0x10; /* CRH: Compatible Reservation Hanlding bit. */
buf[2] |= 0x08; /* SIP_C: Specify Initiator Ports Capable bit */
buf[2] |= 0x04; /* ATP_C: All Target Ports Capable bit */
Expand Down Expand Up @@ -3871,6 +3875,8 @@ core_scsi3_pri_report_capabilities(struct se_cmd *cmd)
buf[4] |= 0x02; /* PR_TYPE_WRITE_EXCLUSIVE */
buf[5] |= 0x01; /* PR_TYPE_EXCLUSIVE_ACCESS_ALLREG */

target_set_cmd_data_length(cmd, len);

transport_kunmap_data_sg(cmd);

return 0;
Expand Down Expand Up @@ -4031,6 +4037,7 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd)
* Set ADDITIONAL_LENGTH
*/
put_unaligned_be32(add_len, &buf[4]);
target_set_cmd_data_length(cmd, 8 + add_len);

transport_kunmap_data_sg(cmd);

Expand Down
15 changes: 11 additions & 4 deletions drivers/target/target_core_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,11 +879,9 @@ void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status)
}
EXPORT_SYMBOL(target_complete_cmd);

void target_complete_cmd_with_length(struct se_cmd *cmd, u8 scsi_status, int length)
void target_set_cmd_data_length(struct se_cmd *cmd, int length)
{
if ((scsi_status == SAM_STAT_GOOD ||
cmd->se_cmd_flags & SCF_TREAT_READ_AS_NORMAL) &&
length < cmd->data_length) {
if (length < cmd->data_length) {
if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) {
cmd->residual_count += cmd->data_length - length;
} else {
Expand All @@ -893,6 +891,15 @@ void target_complete_cmd_with_length(struct se_cmd *cmd, u8 scsi_status, int len

cmd->data_length = length;
}
}
EXPORT_SYMBOL(target_set_cmd_data_length);

void target_complete_cmd_with_length(struct se_cmd *cmd, u8 scsi_status, int length)
{
if (scsi_status == SAM_STAT_GOOD ||
cmd->se_cmd_flags & SCF_TREAT_READ_AS_NORMAL) {
target_set_cmd_data_length(cmd, length);
}

target_complete_cmd(cmd, scsi_status);
}
Expand Down
Loading

0 comments on commit 586b0f0

Please sign in to comment.