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 Oct 27, 2022
2 parents 031a4e2 + 7029e21 commit c8d0d0a
Show file tree
Hide file tree
Showing 37 changed files with 509 additions and 211 deletions.
7 changes: 5 additions & 2 deletions Documentation/scsi/scsi_eh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,17 @@ The timeout handler is scsi_timeout(). When a timeout occurs, this function
1. invokes optional hostt->eh_timed_out() callback. Return value can
be one of

- BLK_EH_RESET_TIMER
- SCSI_EH_RESET_TIMER
This indicates that more time is required to finish the
command. Timer is restarted.

- BLK_EH_DONE
- SCSI_EH_NOT_HANDLED
eh_timed_out() callback did not handle the command.
Step #2 is taken.

- SCSI_EH_DONE
eh_timed_out() completed the command.

2. scsi_abort_command() is invoked to schedule an asynchronous abort which may
issue a retry scmd->allowed + 1 times. Asynchronous aborts are not invoked
for commands for which the SCSI_EH_ABORT_SCHEDULED flag is set (this
Expand Down
8 changes: 4 additions & 4 deletions drivers/message/fusion/mptsas.c
Original file line number Diff line number Diff line change
Expand Up @@ -1952,12 +1952,12 @@ mptsas_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *SCpnt)
* @sc: scsi command that the midlayer is about to time out
*
**/
static enum blk_eh_timer_return mptsas_eh_timed_out(struct scsi_cmnd *sc)
static enum scsi_timeout_action mptsas_eh_timed_out(struct scsi_cmnd *sc)
{
MPT_SCSI_HOST *hd;
MPT_ADAPTER *ioc;
VirtDevice *vdevice;
enum blk_eh_timer_return rc = BLK_EH_DONE;
enum scsi_timeout_action rc = SCSI_EH_NOT_HANDLED;

hd = shost_priv(sc->device->host);
if (hd == NULL) {
Expand All @@ -1980,15 +1980,15 @@ static enum blk_eh_timer_return mptsas_eh_timed_out(struct scsi_cmnd *sc)
dtmprintk(ioc, printk(MYIOC_s_WARN_FMT ": %s: ioc is in reset,"
"SML need to reset the timer (sc=%p)\n",
ioc->name, __func__, sc));
rc = BLK_EH_RESET_TIMER;
rc = SCSI_EH_RESET_TIMER;
}
vdevice = sc->device->hostdata;
if (vdevice && vdevice->vtarget && (vdevice->vtarget->inDMD
|| vdevice->vtarget->deleted)) {
dtmprintk(ioc, printk(MYIOC_s_WARN_FMT ": %s: target removed "
"or in device removal delay (sc=%p)\n",
ioc->name, __func__, sc));
rc = BLK_EH_RESET_TIMER;
rc = SCSI_EH_RESET_TIMER;
goto done;
}

Expand Down
38 changes: 14 additions & 24 deletions drivers/scsi/hisi_sas/hisi_sas_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,22 @@ static void hisi_sas_slot_index_set(struct hisi_hba *hisi_hba, int slot_idx)
}

static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba,
struct scsi_cmnd *scsi_cmnd)
struct request *rq)
{
int index;
void *bitmap = hisi_hba->slot_index_tags;

if (scsi_cmnd)
return scsi_cmd_to_rq(scsi_cmnd)->tag;
if (rq)
return rq->tag + HISI_SAS_RESERVED_IPTT;

spin_lock(&hisi_hba->lock);
index = find_next_zero_bit(bitmap, hisi_hba->slot_index_count,
index = find_next_zero_bit(bitmap, HISI_SAS_RESERVED_IPTT,
hisi_hba->last_slot_index + 1);
if (index >= hisi_hba->slot_index_count) {
if (index >= HISI_SAS_RESERVED_IPTT) {
index = find_next_zero_bit(bitmap,
hisi_hba->slot_index_count,
HISI_SAS_UNRESERVED_IPTT);
if (index >= hisi_hba->slot_index_count) {
HISI_SAS_RESERVED_IPTT,
0);
if (index >= HISI_SAS_RESERVED_IPTT) {
spin_unlock(&hisi_hba->lock);
return -SAS_QUEUE_FULL;
}
Expand Down Expand Up @@ -461,11 +461,11 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
struct asd_sas_port *sas_port = device->port;
struct hisi_sas_device *sas_dev = device->lldd_dev;
bool internal_abort = sas_is_internal_abort(task);
struct scsi_cmnd *scmd = NULL;
struct hisi_sas_dq *dq = NULL;
struct hisi_sas_port *port;
struct hisi_hba *hisi_hba;
struct hisi_sas_slot *slot;
struct request *rq = NULL;
struct device *dev;
int rc;

Expand Down Expand Up @@ -520,22 +520,12 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
return -ECOMM;
}

if (task->uldd_task) {
struct ata_queued_cmd *qc;

if (dev_is_sata(device)) {
qc = task->uldd_task;
scmd = qc->scsicmd;
} else {
scmd = task->uldd_task;
}
}

if (scmd) {
rq = sas_task_find_rq(task);
if (rq) {
unsigned int dq_index;
u32 blk_tag;

blk_tag = blk_mq_unique_tag(scsi_cmd_to_rq(scmd));
blk_tag = blk_mq_unique_tag(rq);
dq_index = blk_mq_unique_tag_to_hwq(blk_tag);
dq = &hisi_hba->dq[dq_index];
} else {
Expand Down Expand Up @@ -580,7 +570,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
if (!internal_abort && hisi_hba->hw->slot_index_alloc)
rc = hisi_hba->hw->slot_index_alloc(hisi_hba, device);
else
rc = hisi_sas_slot_index_alloc(hisi_hba, scmd);
rc = hisi_sas_slot_index_alloc(hisi_hba, rq);

if (rc < 0)
goto err_out_dif_dma_unmap;
Expand Down Expand Up @@ -2226,7 +2216,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba)
if (!hisi_hba->sata_breakpoint)
goto err_out;

hisi_hba->last_slot_index = HISI_SAS_UNRESERVED_IPTT;
hisi_hba->last_slot_index = 0;

hisi_hba->wq = create_singlethread_workqueue(dev_name(dev));
if (!hisi_hba->wq) {
Expand Down
26 changes: 13 additions & 13 deletions drivers/scsi/libiscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2071,9 +2071,9 @@ static int iscsi_has_ping_timed_out(struct iscsi_conn *conn)
return 0;
}

enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
enum scsi_timeout_action iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
{
enum blk_eh_timer_return rc = BLK_EH_DONE;
enum scsi_timeout_action rc = SCSI_EH_NOT_HANDLED;
struct iscsi_task *task = NULL, *running_task;
struct iscsi_cls_session *cls_session;
struct iscsi_session *session;
Expand All @@ -2093,7 +2093,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
* Raced with completion. Blk layer has taken ownership
* so let timeout code complete it now.
*/
rc = BLK_EH_DONE;
rc = SCSI_EH_NOT_HANDLED;
spin_unlock(&session->back_lock);
goto done;
}
Expand All @@ -2102,7 +2102,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
* Racing with the completion path right now, so give it more
* time so that path can complete it like normal.
*/
rc = BLK_EH_RESET_TIMER;
rc = SCSI_EH_RESET_TIMER;
task = NULL;
spin_unlock(&session->back_lock);
goto done;
Expand All @@ -2120,21 +2120,21 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
if (unlikely(system_state != SYSTEM_RUNNING)) {
sc->result = DID_NO_CONNECT << 16;
ISCSI_DBG_EH(session, "sc on shutdown, handled\n");
rc = BLK_EH_DONE;
rc = SCSI_EH_NOT_HANDLED;
goto done;
}
/*
* We are probably in the middle of iscsi recovery so let
* that complete and handle the error.
*/
rc = BLK_EH_RESET_TIMER;
rc = SCSI_EH_RESET_TIMER;
goto done;
}

conn = session->leadconn;
if (!conn) {
/* In the middle of shuting down */
rc = BLK_EH_RESET_TIMER;
rc = SCSI_EH_RESET_TIMER;
goto done;
}

Expand All @@ -2151,7 +2151,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
"Last data xfer at %lu. Last timeout was at "
"%lu\n.", task->last_xfer, task->last_timeout);
task->have_checked_conn = false;
rc = BLK_EH_RESET_TIMER;
rc = SCSI_EH_RESET_TIMER;
goto done;
}

Expand All @@ -2162,7 +2162,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
* and can let the iscsi eh handle it
*/
if (iscsi_has_ping_timed_out(conn)) {
rc = BLK_EH_RESET_TIMER;
rc = SCSI_EH_RESET_TIMER;
goto done;
}

Expand Down Expand Up @@ -2200,7 +2200,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
task->last_xfer, running_task->last_xfer,
task->last_timeout);
spin_unlock(&session->back_lock);
rc = BLK_EH_RESET_TIMER;
rc = SCSI_EH_RESET_TIMER;
goto done;
}
}
Expand All @@ -2216,14 +2216,14 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
*/
if (READ_ONCE(conn->ping_task)) {
task->have_checked_conn = true;
rc = BLK_EH_RESET_TIMER;
rc = SCSI_EH_RESET_TIMER;
goto done;
}

/* Make sure there is a transport check done */
iscsi_send_nopout(conn, NULL);
task->have_checked_conn = true;
rc = BLK_EH_RESET_TIMER;
rc = SCSI_EH_RESET_TIMER;

done:
spin_unlock_bh(&session->frwd_lock);
Expand All @@ -2232,7 +2232,7 @@ enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
task->last_timeout = jiffies;
iscsi_put_task(task);
}
ISCSI_DBG_EH(session, "return %s\n", rc == BLK_EH_RESET_TIMER ?
ISCSI_DBG_EH(session, "return %s\n", rc == SCSI_EH_RESET_TIMER ?
"timer reset" : "shutdown or nh");
return rc;
}
Expand Down
118 changes: 118 additions & 0 deletions drivers/scsi/lpfc/lpfc_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1877,6 +1877,122 @@ lpfc_set_trunking(struct lpfc_hba *phba, char *buff_out)
return 0;
}

static ssize_t
lpfc_xcvr_data_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *shost = class_to_shost(dev);
struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
struct lpfc_hba *phba = vport->phba;
int rc;
int len = 0;
struct lpfc_rdp_context *rdp_context;
u16 temperature;
u16 rx_power;
u16 tx_bias;
u16 tx_power;
u16 vcc;
char chbuf[128];
u16 wavelength = 0;
struct sff_trasnceiver_codes_byte7 *trasn_code_byte7;

/* Get transceiver information */
rdp_context = kmalloc(sizeof(*rdp_context), GFP_KERNEL);

rc = lpfc_get_sfp_info_wait(phba, rdp_context);
if (rc) {
len = scnprintf(buf, PAGE_SIZE - len, "SFP info NA:\n");
goto out_free_rdp;
}

strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_NAME], 16);
chbuf[16] = 0;

len = scnprintf(buf, PAGE_SIZE - len, "VendorName:\t%s\n", chbuf);
len += scnprintf(buf + len, PAGE_SIZE - len,
"VendorOUI:\t%02x-%02x-%02x\n",
(uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI],
(uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI + 1],
(uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI + 2]);
strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_PN], 16);
chbuf[16] = 0;
len += scnprintf(buf + len, PAGE_SIZE - len, "VendorPN:\t%s\n", chbuf);
strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_SN], 16);
chbuf[16] = 0;
len += scnprintf(buf + len, PAGE_SIZE - len, "VendorSN:\t%s\n", chbuf);
strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_REV], 4);
chbuf[4] = 0;
len += scnprintf(buf + len, PAGE_SIZE - len, "VendorRev:\t%s\n", chbuf);
strncpy(chbuf, &rdp_context->page_a0[SSF_DATE_CODE], 8);
chbuf[8] = 0;
len += scnprintf(buf + len, PAGE_SIZE - len, "DateCode:\t%s\n", chbuf);
len += scnprintf(buf + len, PAGE_SIZE - len, "Identifier:\t%xh\n",
(uint8_t)rdp_context->page_a0[SSF_IDENTIFIER]);
len += scnprintf(buf + len, PAGE_SIZE - len, "ExtIdentifier:\t%xh\n",
(uint8_t)rdp_context->page_a0[SSF_EXT_IDENTIFIER]);
len += scnprintf(buf + len, PAGE_SIZE - len, "Connector:\t%xh\n",
(uint8_t)rdp_context->page_a0[SSF_CONNECTOR]);
wavelength = (rdp_context->page_a0[SSF_WAVELENGTH_B1] << 8) |
rdp_context->page_a0[SSF_WAVELENGTH_B0];

len += scnprintf(buf + len, PAGE_SIZE - len, "Wavelength:\t%d nm\n",
wavelength);
trasn_code_byte7 = (struct sff_trasnceiver_codes_byte7 *)
&rdp_context->page_a0[SSF_TRANSCEIVER_CODE_B7];

len += scnprintf(buf + len, PAGE_SIZE - len, "Speeds: \t");
if (*(uint8_t *)trasn_code_byte7 == 0) {
len += scnprintf(buf + len, PAGE_SIZE - len,
"Unknown\n");
} else {
if (trasn_code_byte7->fc_sp_100MB)
len += scnprintf(buf + len, PAGE_SIZE - len,
"1 ");
if (trasn_code_byte7->fc_sp_200mb)
len += scnprintf(buf + len, PAGE_SIZE - len,
"2 ");
if (trasn_code_byte7->fc_sp_400MB)
len += scnprintf(buf + len, PAGE_SIZE - len,
"4 ");
if (trasn_code_byte7->fc_sp_800MB)
len += scnprintf(buf + len, PAGE_SIZE - len,
"8 ");
if (trasn_code_byte7->fc_sp_1600MB)
len += scnprintf(buf + len, PAGE_SIZE - len,
"16 ");
if (trasn_code_byte7->fc_sp_3200MB)
len += scnprintf(buf + len, PAGE_SIZE - len,
"32 ");
if (trasn_code_byte7->speed_chk_ecc)
len += scnprintf(buf + len, PAGE_SIZE - len,
"64 ");
len += scnprintf(buf + len, PAGE_SIZE - len, "GB\n");
}
temperature = (rdp_context->page_a2[SFF_TEMPERATURE_B1] << 8 |
rdp_context->page_a2[SFF_TEMPERATURE_B0]);
vcc = (rdp_context->page_a2[SFF_VCC_B1] << 8 |
rdp_context->page_a2[SFF_VCC_B0]);
tx_power = (rdp_context->page_a2[SFF_TXPOWER_B1] << 8 |
rdp_context->page_a2[SFF_TXPOWER_B0]);
tx_bias = (rdp_context->page_a2[SFF_TX_BIAS_CURRENT_B1] << 8 |
rdp_context->page_a2[SFF_TX_BIAS_CURRENT_B0]);
rx_power = (rdp_context->page_a2[SFF_RXPOWER_B1] << 8 |
rdp_context->page_a2[SFF_RXPOWER_B0]);

len += scnprintf(buf + len, PAGE_SIZE - len,
"Temperature:\tx%04x C\n", temperature);
len += scnprintf(buf + len, PAGE_SIZE - len, "Vcc:\t\tx%04x V\n", vcc);
len += scnprintf(buf + len, PAGE_SIZE - len,
"TxBiasCurrent:\tx%04x mA\n", tx_bias);
len += scnprintf(buf + len, PAGE_SIZE - len, "TxPower:\tx%04x mW\n",
tx_power);
len += scnprintf(buf + len, PAGE_SIZE - len, "RxPower:\tx%04x mW\n",
rx_power);
out_free_rdp:
kfree(rdp_context);
return len;
}

/**
* lpfc_board_mode_show - Return the state of the board
* @dev: class device that is converted into a Scsi_host.
Expand Down Expand Up @@ -2810,6 +2926,7 @@ static DEVICE_ATTR_RO(lpfc_drvr_version);
static DEVICE_ATTR_RO(lpfc_enable_fip);
static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
lpfc_board_mode_show, lpfc_board_mode_store);
static DEVICE_ATTR_RO(lpfc_xcvr_data);
static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
static DEVICE_ATTR(max_vpi, S_IRUGO, lpfc_max_vpi_show, NULL);
static DEVICE_ATTR(used_vpi, S_IRUGO, lpfc_used_vpi_show, NULL);
Expand Down Expand Up @@ -5906,6 +6023,7 @@ static struct attribute *lpfc_hba_attrs[] = {
&dev_attr_lpfc_fcp_wait_abts_rsp.attr,
&dev_attr_nport_evt_cnt.attr,
&dev_attr_board_mode.attr,
&dev_attr_lpfc_xcvr_data.attr,
&dev_attr_max_vpi.attr,
&dev_attr_used_vpi.attr,
&dev_attr_max_rpi.attr,
Expand Down
3 changes: 3 additions & 0 deletions drivers/scsi/lpfc/lpfc_crtn.h
Original file line number Diff line number Diff line change
Expand Up @@ -687,3 +687,6 @@ int lpfc_issue_els_qfpa(struct lpfc_vport *vport);

void lpfc_sli_rpi_release(struct lpfc_vport *vport,
struct lpfc_nodelist *ndlp);

int lpfc_get_sfp_info_wait(struct lpfc_hba *phba,
struct lpfc_rdp_context *rdp_context);
Loading

0 comments on commit c8d0d0a

Please sign in to comment.