Commit 35d2ce0b authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Martin K. Petersen

scsi: aacraid: use scsi_host_busy_iter() in get_num_of_incomplete_fibs()

Use the SCSI midlayer helper to traverse the number of outstanding
commands. This also eliminates the last usage for the cmd_list
functionality so we can drop it.

Link: https://lore.kernel.org/r/20200228075318.91255-13-hare@suse.deReviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarBalsundar P <balsundar.p@microchip.com>
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent f4a0c9db
...@@ -622,54 +622,56 @@ static int aac_ioctl(struct scsi_device *sdev, unsigned int cmd, ...@@ -622,54 +622,56 @@ static int aac_ioctl(struct scsi_device *sdev, unsigned int cmd,
return aac_do_ioctl(dev, cmd, arg); return aac_do_ioctl(dev, cmd, arg);
} }
static int get_num_of_incomplete_fibs(struct aac_dev *aac) struct fib_count_data {
int mlcnt;
int llcnt;
int ehcnt;
int fwcnt;
int krlcnt;
};
static bool fib_count_iter(struct scsi_cmnd *scmnd, void *data, bool reserved)
{ {
struct fib_count_data *fib_count = data;
switch (scmnd->SCp.phase) {
case AAC_OWNER_FIRMWARE:
fib_count->fwcnt++;
break;
case AAC_OWNER_ERROR_HANDLER:
fib_count->ehcnt++;
break;
case AAC_OWNER_LOWLEVEL:
fib_count->llcnt++;
break;
case AAC_OWNER_MIDLEVEL:
fib_count->mlcnt++;
break;
default:
fib_count->krlcnt++;
break;
}
return true;
}
unsigned long flags; /* Called during SCSI EH, so we don't need to block requests */
struct scsi_device *sdev = NULL; static int get_num_of_incomplete_fibs(struct aac_dev *aac)
{
struct Scsi_Host *shost = aac->scsi_host_ptr; struct Scsi_Host *shost = aac->scsi_host_ptr;
struct scsi_cmnd *scmnd = NULL;
struct device *ctrl_dev; struct device *ctrl_dev;
struct fib_count_data fcnt = { };
int mlcnt = 0; scsi_host_busy_iter(shost, fib_count_iter, &fcnt);
int llcnt = 0;
int ehcnt = 0;
int fwcnt = 0;
int krlcnt = 0;
__shost_for_each_device(sdev, shost) {
spin_lock_irqsave(&sdev->list_lock, flags);
list_for_each_entry(scmnd, &sdev->cmd_list, list) {
switch (scmnd->SCp.phase) {
case AAC_OWNER_FIRMWARE:
fwcnt++;
break;
case AAC_OWNER_ERROR_HANDLER:
ehcnt++;
break;
case AAC_OWNER_LOWLEVEL:
llcnt++;
break;
case AAC_OWNER_MIDLEVEL:
mlcnt++;
break;
default:
krlcnt++;
break;
}
}
spin_unlock_irqrestore(&sdev->list_lock, flags);
}
ctrl_dev = &aac->pdev->dev; ctrl_dev = &aac->pdev->dev;
dev_info(ctrl_dev, "outstanding cmd: midlevel-%d\n", mlcnt); dev_info(ctrl_dev, "outstanding cmd: midlevel-%d\n", fcnt.mlcnt);
dev_info(ctrl_dev, "outstanding cmd: lowlevel-%d\n", llcnt); dev_info(ctrl_dev, "outstanding cmd: lowlevel-%d\n", fcnt.llcnt);
dev_info(ctrl_dev, "outstanding cmd: error handler-%d\n", ehcnt); dev_info(ctrl_dev, "outstanding cmd: error handler-%d\n", fcnt.ehcnt);
dev_info(ctrl_dev, "outstanding cmd: firmware-%d\n", fwcnt); dev_info(ctrl_dev, "outstanding cmd: firmware-%d\n", fcnt.fwcnt);
dev_info(ctrl_dev, "outstanding cmd: kernel-%d\n", krlcnt); dev_info(ctrl_dev, "outstanding cmd: kernel-%d\n", fcnt.krlcnt);
return mlcnt + llcnt + ehcnt + fwcnt; return fcnt.mlcnt + fcnt.llcnt + fcnt.ehcnt + fcnt.fwcnt;
} }
static int aac_eh_abort(struct scsi_cmnd* cmd) static int aac_eh_abort(struct scsi_cmnd* cmd)
...@@ -1675,7 +1677,6 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1675,7 +1677,6 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
shost->irq = pdev->irq; shost->irq = pdev->irq;
shost->unique_id = unique_id; shost->unique_id = unique_id;
shost->max_cmd_len = 16; shost->max_cmd_len = 16;
shost->use_cmd_list = 1;
if (aac_cfg_major == AAC_CHARDEV_NEEDS_REINIT) if (aac_cfg_major == AAC_CHARDEV_NEEDS_REINIT)
aac_init_char(); aac_init_char();
......
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