SCSI misc on 20190709
This is mostly update of the usual drivers: qla2xxx, hpsa, lpfc, ufs,
mpt3sas, ibmvscsi, megaraid_sas, bnx2fc and hisi_sas as well as the
removal of the osst driver (I heard from Willem privately that he
would like the driver removed because all his test hardware has
failed). Plus number of minor changes, spelling fixes and other
trivia.
Signed-off-by: James E.J. Bottomley <jejb@linux.ibm.com>
-----BEGIN PGP SIGNATURE-----
iJwEABMIAEQWIQTnYEDbdso9F2cI+arnQslM7pishQUCXSTl4yYcamFtZXMuYm90
dG9tbGV5QGhhbnNlbnBhcnRuZXJzaGlwLmNvbQAKCRDnQslM7pishdcxAQDCJVbd
fPUX76/V1ldupunF97+3DTharxxbst+VnkOnCwD8D4c0KFFFOI9+F36cnMGCPegE
fjy17dQLvsJ4GsidHy8=
=aS5B
-----END PGP SIGNATURE-----
Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI updates from James Bottomley:
"This is mostly update of the usual drivers: qla2xxx, hpsa, lpfc, ufs,
mpt3sas, ibmvscsi, megaraid_sas, bnx2fc and hisi_sas as well as the
removal of the osst driver (I heard from Willem privately that he
would like the driver removed because all his test hardware has
failed). Plus number of minor changes, spelling fixes and other
trivia.
The big merge conflict this time around is the SPDX licence tags.
Following discussion on linux-next, we believe our version to be more
accurate than the one in the tree, so the resolution is to take our
version for all the SPDX conflicts"
Note on the SPDX license tag conversion conflicts: the SCSI tree had
done its own SPDX conversion, which in some cases conflicted with the
treewide ones done by Thomas & co.
In almost all cases, the conflicts were purely syntactic: the SCSI tree
used the old-style SPDX tags ("GPL-2.0" and "GPL-2.0+") while the
treewide conversion had used the new-style ones ("GPL-2.0-only" and
"GPL-2.0-or-later").
In these cases I picked the new-style one.
In a few cases, the SPDX conversion was actually different, though. As
explained by James above, and in more detail in a pre-pull-request
thread:
"The other problem is actually substantive: In the libsas code Luben
Tuikov originally specified gpl 2.0 only by dint of stating:
* This file is licensed under GPLv2.
In all the libsas files, but then muddied the water by quoting GPLv2
verbatim (which includes the or later than language). So for these
files Christoph did the conversion to v2 only SPDX tags and Thomas
converted to v2 or later tags"
So in those cases, where the spdx tag substantially mattered, I took the
SCSI tree conversion of it, but then also took the opportunity to turn
the old-style "GPL-2.0" into a new-style "GPL-2.0-only" tag.
Similarly, when there were whitespace differences or other differences
to the comments around the copyright notices, I took the version from
the SCSI tree as being the more specific conversion.
Finally, in the spdx conversions that had no conflicts (because the
treewide ones hadn't been done for those files), I just took the SCSI
tree version as-is, even if it was old-style. The old-style conversions
are perfectly valid, even if the "-only" and "-or-later" versions are
perhaps more descriptive.
* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (185 commits)
scsi: qla2xxx: move IO flush to the front of NVME rport unregistration
scsi: qla2xxx: Fix NVME cmd and LS cmd timeout race condition
scsi: qla2xxx: on session delete, return nvme cmd
scsi: qla2xxx: Fix kernel crash after disconnecting NVMe devices
scsi: megaraid_sas: Update driver version to 07.710.06.00-rc1
scsi: megaraid_sas: Introduce various Aero performance modes
scsi: megaraid_sas: Use high IOPS queues based on IO workload
scsi: megaraid_sas: Set affinity for high IOPS reply queues
scsi: megaraid_sas: Enable coalescing for high IOPS queues
scsi: megaraid_sas: Add support for High IOPS queues
scsi: megaraid_sas: Add support for MPI toolbox commands
scsi: megaraid_sas: Offload Aero RAID5/6 division calculations to driver
scsi: megaraid_sas: RAID1 PCI bandwidth limit algorithm is applicable for only Ventura
scsi: megaraid_sas: megaraid_sas: Add check for count returned by HOST_DEVICE_LIST DCMD
scsi: megaraid_sas: Handle sequence JBOD map failure at driver level
scsi: megaraid_sas: Don't send FPIO to RL Bypass queue
scsi: megaraid_sas: In probe context, retry IOC INIT once if firmware is in fault
scsi: megaraid_sas: Release Mutex lock before OCR in case of DCMD timeout
scsi: megaraid_sas: Call disable_irq from process IRQ poll
scsi: megaraid_sas: Remove few debug counters from IO path
...
2019-07-12 06:14:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2006-08-29 22:22:51 +08:00
|
|
|
/*
|
|
|
|
* Serial Attached SCSI (SAS) class SCSI Host glue.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Adaptec, Inc. All rights reserved.
|
|
|
|
* Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
|
|
|
|
*/
|
|
|
|
|
2007-04-26 21:38:01 +08:00
|
|
|
#include <linux/kthread.h>
|
2008-02-20 02:49:40 +08:00
|
|
|
#include <linux/firmware.h>
|
2011-05-27 21:37:25 +08:00
|
|
|
#include <linux/export.h>
|
2008-02-20 02:49:40 +08:00
|
|
|
#include <linux/ctype.h>
|
2017-12-20 01:37:27 +08:00
|
|
|
#include <linux/kernel.h>
|
2007-04-26 21:38:01 +08:00
|
|
|
|
2006-08-29 22:22:51 +08:00
|
|
|
#include "sas_internal.h"
|
|
|
|
|
|
|
|
#include <scsi/scsi_host.h>
|
|
|
|
#include <scsi/scsi_device.h>
|
|
|
|
#include <scsi/scsi_tcq.h>
|
|
|
|
#include <scsi/scsi.h>
|
2006-10-31 07:18:39 +08:00
|
|
|
#include <scsi/scsi_eh.h>
|
2006-08-29 22:22:51 +08:00
|
|
|
#include <scsi/scsi_transport.h>
|
|
|
|
#include <scsi/scsi_transport_sas.h>
|
2006-10-19 05:43:37 +08:00
|
|
|
#include <scsi/sas_ata.h>
|
2006-08-29 22:22:51 +08:00
|
|
|
#include "../scsi_sas_internal.h"
|
2006-10-31 07:18:50 +08:00
|
|
|
#include "../scsi_transport_api.h"
|
2007-01-27 06:08:52 +08:00
|
|
|
#include "../scsi_priv.h"
|
2006-08-29 22:22:51 +08:00
|
|
|
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/blkdev.h>
|
2007-07-17 19:03:35 +08:00
|
|
|
#include <linux/freezer.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/gfp.h>
|
2006-08-29 22:22:51 +08:00
|
|
|
#include <linux/scatterlist.h>
|
2006-08-11 10:19:47 +08:00
|
|
|
#include <linux/libata.h>
|
2006-08-29 22:22:51 +08:00
|
|
|
|
2011-12-07 15:24:42 +08:00
|
|
|
/* record final status and free the task */
|
|
|
|
static void sas_end_task(struct scsi_cmnd *sc, struct sas_task *task)
|
2006-08-29 22:22:51 +08:00
|
|
|
{
|
|
|
|
struct task_status_struct *ts = &task->task_status;
|
|
|
|
int hs = 0, stat = 0;
|
|
|
|
|
|
|
|
if (ts->resp == SAS_TASK_UNDELIVERED) {
|
|
|
|
/* transport error */
|
|
|
|
hs = DID_NO_CONNECT;
|
|
|
|
} else { /* ts->resp == SAS_TASK_COMPLETE */
|
|
|
|
/* task delivered, what happened afterwards? */
|
|
|
|
switch (ts->stat) {
|
|
|
|
case SAS_DEV_NO_RESPONSE:
|
|
|
|
case SAS_INTERRUPTED:
|
|
|
|
case SAS_PHY_DOWN:
|
|
|
|
case SAS_NAK_R_ERR:
|
|
|
|
case SAS_OPEN_TO:
|
|
|
|
hs = DID_NO_CONNECT;
|
|
|
|
break;
|
|
|
|
case SAS_DATA_UNDERRUN:
|
2007-05-26 01:46:37 +08:00
|
|
|
scsi_set_resid(sc, ts->residual);
|
|
|
|
if (scsi_bufflen(sc) - scsi_get_resid(sc) < sc->underflow)
|
2006-08-29 22:22:51 +08:00
|
|
|
hs = DID_ERROR;
|
|
|
|
break;
|
|
|
|
case SAS_DATA_OVERRUN:
|
|
|
|
hs = DID_ERROR;
|
|
|
|
break;
|
|
|
|
case SAS_QUEUE_FULL:
|
|
|
|
hs = DID_SOFT_ERROR; /* retry */
|
|
|
|
break;
|
|
|
|
case SAS_DEVICE_UNKNOWN:
|
|
|
|
hs = DID_BAD_TARGET;
|
|
|
|
break;
|
|
|
|
case SAS_SG_ERR:
|
|
|
|
hs = DID_PARITY;
|
|
|
|
break;
|
|
|
|
case SAS_OPEN_REJECT:
|
|
|
|
if (ts->open_rej_reason == SAS_OREJ_RSVD_RETRY)
|
|
|
|
hs = DID_SOFT_ERROR; /* retry */
|
|
|
|
else
|
|
|
|
hs = DID_ERROR;
|
|
|
|
break;
|
|
|
|
case SAS_PROTO_RESPONSE:
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("LLDD:%s sent SAS_PROTO_RESP for an SSP task; please report this\n",
|
|
|
|
task->dev->port->ha->sas_ha_name);
|
2006-08-29 22:22:51 +08:00
|
|
|
break;
|
|
|
|
case SAS_ABORTED_TASK:
|
|
|
|
hs = DID_ABORT;
|
|
|
|
break;
|
2010-07-28 04:51:13 +08:00
|
|
|
case SAM_STAT_CHECK_CONDITION:
|
2006-08-29 22:22:51 +08:00
|
|
|
memcpy(sc->sense_buffer, ts->buf,
|
2008-01-13 01:20:18 +08:00
|
|
|
min(SCSI_SENSE_BUFFERSIZE, ts->buf_valid_size));
|
2010-07-28 04:51:13 +08:00
|
|
|
stat = SAM_STAT_CHECK_CONDITION;
|
2006-08-29 22:22:51 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
stat = ts->stat;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-12-07 15:24:42 +08:00
|
|
|
|
2006-08-29 22:22:51 +08:00
|
|
|
sc->result = (hs << 16) | stat;
|
2011-12-07 15:24:42 +08:00
|
|
|
ASSIGN_SAS_TASK(sc, NULL);
|
2006-08-29 22:22:51 +08:00
|
|
|
sas_free_task(task);
|
2011-12-07 15:24:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sas_scsi_task_done(struct sas_task *task)
|
|
|
|
{
|
|
|
|
struct scsi_cmnd *sc = task->uldd_task;
|
2011-11-29 03:29:20 +08:00
|
|
|
struct domain_device *dev = task->dev;
|
|
|
|
struct sas_ha_struct *ha = dev->port->ha;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dev->done_lock, flags);
|
|
|
|
if (test_bit(SAS_HA_FROZEN, &ha->state))
|
|
|
|
task = NULL;
|
|
|
|
else
|
|
|
|
ASSIGN_SAS_TASK(sc, NULL);
|
|
|
|
spin_unlock_irqrestore(&dev->done_lock, flags);
|
2011-12-07 15:24:42 +08:00
|
|
|
|
2011-11-29 03:29:20 +08:00
|
|
|
if (unlikely(!task)) {
|
|
|
|
/* task will be completed by the error handler */
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_debug("task done but aborted\n");
|
2011-12-07 15:24:42 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unlikely(!sc)) {
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_debug("task_done called with non existing SCSI cmnd!\n");
|
2011-12-07 15:24:42 +08:00
|
|
|
sas_free_task(task);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sas_end_task(sc, task);
|
2008-02-20 11:48:42 +08:00
|
|
|
sc->scsi_done(sc);
|
2006-08-29 22:22:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct sas_task *sas_create_task(struct scsi_cmnd *cmd,
|
|
|
|
struct domain_device *dev,
|
2006-09-25 09:55:40 +08:00
|
|
|
gfp_t gfp_flags)
|
2006-08-29 22:22:51 +08:00
|
|
|
{
|
|
|
|
struct sas_task *task = sas_alloc_task(gfp_flags);
|
|
|
|
struct scsi_lun lun;
|
|
|
|
|
|
|
|
if (!task)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
task->uldd_task = cmd;
|
|
|
|
ASSIGN_SAS_TASK(cmd, task);
|
|
|
|
|
|
|
|
task->dev = dev;
|
|
|
|
task->task_proto = task->dev->tproto; /* BUG_ON(!SSP) */
|
|
|
|
|
|
|
|
task->ssp_task.retry_count = 1;
|
|
|
|
int_to_scsilun(cmd->device->lun, &lun);
|
|
|
|
memcpy(task->ssp_task.LUN, &lun.scsi_lun, 8);
|
2010-09-03 17:56:16 +08:00
|
|
|
task->ssp_task.task_attr = TASK_ATTR_SIMPLE;
|
2013-05-08 06:38:18 +08:00
|
|
|
task->ssp_task.cmd = cmd;
|
2006-08-29 22:22:51 +08:00
|
|
|
|
2007-05-26 01:46:37 +08:00
|
|
|
task->scatter = scsi_sglist(cmd);
|
|
|
|
task->num_scatter = scsi_sg_count(cmd);
|
|
|
|
task->total_xfer_len = scsi_bufflen(cmd);
|
2006-08-29 22:22:51 +08:00
|
|
|
task->data_dir = cmd->sc_data_direction;
|
|
|
|
|
|
|
|
task->task_done = sas_scsi_task_done;
|
|
|
|
|
|
|
|
return task;
|
|
|
|
}
|
|
|
|
|
2011-07-12 02:49:23 +08:00
|
|
|
int sas_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
|
2006-08-29 22:22:51 +08:00
|
|
|
{
|
|
|
|
struct sas_internal *i = to_sas_internal(host->transportt);
|
2011-07-12 02:49:24 +08:00
|
|
|
struct domain_device *dev = cmd_to_domain_dev(cmd);
|
|
|
|
struct sas_task *task;
|
|
|
|
int res = 0;
|
2006-08-29 22:22:51 +08:00
|
|
|
|
2011-07-12 02:49:24 +08:00
|
|
|
/* If the device fell off, no sense in issuing commands */
|
2012-01-07 16:52:39 +08:00
|
|
|
if (test_bit(SAS_DEV_GONE, &dev->state)) {
|
2011-07-12 02:49:24 +08:00
|
|
|
cmd->result = DID_BAD_TARGET << 16;
|
|
|
|
goto out_done;
|
|
|
|
}
|
2006-08-29 22:22:51 +08:00
|
|
|
|
2011-07-12 02:49:24 +08:00
|
|
|
if (dev_is_sata(dev)) {
|
2011-11-18 09:59:50 +08:00
|
|
|
spin_lock_irq(dev->sata_dev.ap->lock);
|
2011-07-12 02:49:24 +08:00
|
|
|
res = ata_sas_queuecmd(cmd, dev->sata_dev.ap);
|
2011-11-18 09:59:50 +08:00
|
|
|
spin_unlock_irq(dev->sata_dev.ap->lock);
|
2011-07-12 02:49:24 +08:00
|
|
|
return res;
|
|
|
|
}
|
2007-01-30 17:18:35 +08:00
|
|
|
|
2011-07-12 02:49:24 +08:00
|
|
|
task = sas_create_task(cmd, dev, GFP_ATOMIC);
|
|
|
|
if (!task)
|
2011-07-17 03:00:35 +08:00
|
|
|
return SCSI_MLQUEUE_HOST_BUSY;
|
2006-08-11 10:19:47 +08:00
|
|
|
|
2014-11-05 17:36:28 +08:00
|
|
|
res = i->dft->lldd_execute_task(task, GFP_ATOMIC);
|
2011-07-12 02:49:24 +08:00
|
|
|
if (res)
|
|
|
|
goto out_free_task;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_free_task:
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_debug("lldd_execute_task returned: %d\n", res);
|
2011-07-12 02:49:24 +08:00
|
|
|
ASSIGN_SAS_TASK(cmd, NULL);
|
|
|
|
sas_free_task(task);
|
2011-07-17 03:00:35 +08:00
|
|
|
if (res == -SAS_QUEUE_FULL)
|
|
|
|
cmd->result = DID_SOFT_ERROR << 16; /* retry */
|
|
|
|
else
|
|
|
|
cmd->result = DID_ERROR << 16;
|
2011-07-12 02:49:24 +08:00
|
|
|
out_done:
|
|
|
|
cmd->scsi_done(cmd);
|
|
|
|
return 0;
|
2006-08-29 22:22:51 +08:00
|
|
|
}
|
|
|
|
|
2008-02-20 11:48:42 +08:00
|
|
|
static void sas_eh_finish_cmd(struct scsi_cmnd *cmd)
|
|
|
|
{
|
|
|
|
struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(cmd->device->host);
|
2018-03-08 10:34:53 +08:00
|
|
|
struct domain_device *dev = cmd_to_domain_dev(cmd);
|
2012-01-10 02:12:52 +08:00
|
|
|
struct sas_task *task = TO_SAS_TASK(cmd);
|
2008-02-20 11:48:42 +08:00
|
|
|
|
2011-12-07 15:24:42 +08:00
|
|
|
/* At this point, we only get called following an actual abort
|
|
|
|
* of the task, so we should be guaranteed not to be racing with
|
|
|
|
* any completions from the LLD. Task is freed after this.
|
|
|
|
*/
|
|
|
|
sas_end_task(cmd, task);
|
|
|
|
|
2018-03-08 10:34:53 +08:00
|
|
|
if (dev_is_sata(dev)) {
|
|
|
|
/* defer commands to libata so that libata EH can
|
|
|
|
* handle ata qcs correctly
|
|
|
|
*/
|
|
|
|
list_move_tail(&cmd->eh_entry, &sas_ha->eh_ata_q);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-20 11:48:42 +08:00
|
|
|
/* now finish the command and move it on to the error
|
|
|
|
* handler done list, this also takes it off the
|
2011-12-07 15:24:42 +08:00
|
|
|
* error handler pending list.
|
|
|
|
*/
|
2008-02-20 11:48:42 +08:00
|
|
|
scsi_eh_finish_cmd(cmd, &sas_ha->eh_done_q);
|
|
|
|
}
|
|
|
|
|
2006-08-29 22:22:51 +08:00
|
|
|
static void sas_scsi_clear_queue_lu(struct list_head *error_q, struct scsi_cmnd *my_cmd)
|
|
|
|
{
|
|
|
|
struct scsi_cmnd *cmd, *n;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(cmd, n, error_q, eh_entry) {
|
2008-02-23 07:07:52 +08:00
|
|
|
if (cmd->device->sdev_target == my_cmd->device->sdev_target &&
|
|
|
|
cmd->device->lun == my_cmd->device->lun)
|
2018-03-08 10:34:53 +08:00
|
|
|
sas_eh_finish_cmd(cmd);
|
2006-08-29 22:22:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sas_scsi_clear_queue_I_T(struct list_head *error_q,
|
|
|
|
struct domain_device *dev)
|
|
|
|
{
|
|
|
|
struct scsi_cmnd *cmd, *n;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(cmd, n, error_q, eh_entry) {
|
|
|
|
struct domain_device *x = cmd_to_domain_dev(cmd);
|
|
|
|
|
|
|
|
if (x == dev)
|
2008-02-20 11:48:42 +08:00
|
|
|
sas_eh_finish_cmd(cmd);
|
2006-08-29 22:22:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sas_scsi_clear_queue_port(struct list_head *error_q,
|
|
|
|
struct asd_sas_port *port)
|
|
|
|
{
|
|
|
|
struct scsi_cmnd *cmd, *n;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(cmd, n, error_q, eh_entry) {
|
|
|
|
struct domain_device *dev = cmd_to_domain_dev(cmd);
|
|
|
|
struct asd_sas_port *x = dev->port;
|
|
|
|
|
|
|
|
if (x == port)
|
2008-02-20 11:48:42 +08:00
|
|
|
sas_eh_finish_cmd(cmd);
|
2006-08-29 22:22:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum task_disposition {
|
|
|
|
TASK_IS_DONE,
|
|
|
|
TASK_IS_ABORTED,
|
|
|
|
TASK_IS_AT_LU,
|
|
|
|
TASK_IS_NOT_AT_LU,
|
2007-01-12 06:15:46 +08:00
|
|
|
TASK_ABORT_FAILED,
|
2006-08-29 22:22:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static enum task_disposition sas_scsi_find_task(struct sas_task *task)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int i, res;
|
|
|
|
struct sas_internal *si =
|
|
|
|
to_sas_internal(task->dev->port->ha->core.shost->transportt);
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++) {
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("%s: aborting task 0x%p\n", __func__, task);
|
2006-08-29 22:22:51 +08:00
|
|
|
res = si->dft->lldd_abort_task(task);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&task->task_state_lock, flags);
|
|
|
|
if (task->task_state_flags & SAS_TASK_STATE_DONE) {
|
|
|
|
spin_unlock_irqrestore(&task->task_state_lock, flags);
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_debug("%s: task 0x%p is done\n", __func__, task);
|
2006-08-29 22:22:51 +08:00
|
|
|
return TASK_IS_DONE;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&task->task_state_lock, flags);
|
|
|
|
|
|
|
|
if (res == TMF_RESP_FUNC_COMPLETE) {
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("%s: task 0x%p is aborted\n",
|
|
|
|
__func__, task);
|
2006-08-29 22:22:51 +08:00
|
|
|
return TASK_IS_ABORTED;
|
|
|
|
} else if (si->dft->lldd_query_task) {
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("%s: querying task 0x%p\n", __func__, task);
|
2006-08-29 22:22:51 +08:00
|
|
|
res = si->dft->lldd_query_task(task);
|
2007-01-12 06:15:46 +08:00
|
|
|
switch (res) {
|
|
|
|
case TMF_RESP_FUNC_SUCC:
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("%s: task 0x%p at LU\n", __func__,
|
|
|
|
task);
|
2006-08-29 22:22:51 +08:00
|
|
|
return TASK_IS_AT_LU;
|
2007-01-12 06:15:46 +08:00
|
|
|
case TMF_RESP_FUNC_COMPLETE:
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("%s: task 0x%p not at LU\n",
|
|
|
|
__func__, task);
|
2006-08-29 22:22:51 +08:00
|
|
|
return TASK_IS_NOT_AT_LU;
|
2007-01-12 06:15:46 +08:00
|
|
|
case TMF_RESP_FUNC_FAILED:
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("%s: task 0x%p failed to abort\n",
|
|
|
|
__func__, task);
|
|
|
|
return TASK_ABORT_FAILED;
|
|
|
|
}
|
2007-01-12 06:15:46 +08:00
|
|
|
|
2006-08-29 22:22:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sas_recover_lu(struct domain_device *dev, struct scsi_cmnd *cmd)
|
|
|
|
{
|
|
|
|
int res = TMF_RESP_FUNC_FAILED;
|
|
|
|
struct scsi_lun lun;
|
|
|
|
struct sas_internal *i =
|
|
|
|
to_sas_internal(dev->port->ha->core.shost->transportt);
|
|
|
|
|
|
|
|
int_to_scsilun(cmd->device->lun, &lun);
|
|
|
|
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("eh: device %llx LUN %llx has the task\n",
|
|
|
|
SAS_ADDR(dev->sas_addr),
|
|
|
|
cmd->device->lun);
|
2006-08-29 22:22:51 +08:00
|
|
|
|
|
|
|
if (i->dft->lldd_abort_task_set)
|
|
|
|
res = i->dft->lldd_abort_task_set(dev, lun.scsi_lun);
|
|
|
|
|
|
|
|
if (res == TMF_RESP_FUNC_FAILED) {
|
|
|
|
if (i->dft->lldd_clear_task_set)
|
|
|
|
res = i->dft->lldd_clear_task_set(dev, lun.scsi_lun);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res == TMF_RESP_FUNC_FAILED) {
|
|
|
|
if (i->dft->lldd_lu_reset)
|
|
|
|
res = i->dft->lldd_lu_reset(dev, lun.scsi_lun);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sas_recover_I_T(struct domain_device *dev)
|
|
|
|
{
|
|
|
|
int res = TMF_RESP_FUNC_FAILED;
|
|
|
|
struct sas_internal *i =
|
|
|
|
to_sas_internal(dev->port->ha->core.shost->transportt);
|
|
|
|
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("I_T nexus reset for dev %016llx\n",
|
|
|
|
SAS_ADDR(dev->sas_addr));
|
2006-08-29 22:22:51 +08:00
|
|
|
|
|
|
|
if (i->dft->lldd_I_T_nexus_reset)
|
|
|
|
res = i->dft->lldd_I_T_nexus_reset(dev);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2011-12-22 13:33:17 +08:00
|
|
|
/* take a reference on the last known good phy for this device */
|
|
|
|
struct sas_phy *sas_get_local_phy(struct domain_device *dev)
|
2007-01-12 06:15:17 +08:00
|
|
|
{
|
2011-12-22 13:33:17 +08:00
|
|
|
struct sas_ha_struct *ha = dev->port->ha;
|
|
|
|
struct sas_phy *phy;
|
|
|
|
unsigned long flags;
|
2007-01-12 06:15:17 +08:00
|
|
|
|
2011-12-22 13:33:17 +08:00
|
|
|
/* a published domain device always has a valid phy, it may be
|
|
|
|
* stale, but it is never NULL
|
|
|
|
*/
|
|
|
|
BUG_ON(!dev->phy);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ha->phy_port_lock, flags);
|
|
|
|
phy = dev->phy;
|
|
|
|
get_device(&phy->dev);
|
|
|
|
spin_unlock_irqrestore(&ha->phy_port_lock, flags);
|
|
|
|
|
|
|
|
return phy;
|
2007-01-12 06:15:17 +08:00
|
|
|
}
|
2011-12-22 13:33:17 +08:00
|
|
|
EXPORT_SYMBOL_GPL(sas_get_local_phy);
|
2007-01-12 06:15:17 +08:00
|
|
|
|
2012-06-22 14:30:48 +08:00
|
|
|
static void sas_wait_eh(struct domain_device *dev)
|
|
|
|
{
|
|
|
|
struct sas_ha_struct *ha = dev->port->ha;
|
|
|
|
DEFINE_WAIT(wait);
|
|
|
|
|
|
|
|
if (dev_is_sata(dev)) {
|
|
|
|
ata_port_wait_eh(dev->sata_dev.ap);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
retry:
|
|
|
|
spin_lock_irq(&ha->lock);
|
|
|
|
|
|
|
|
while (test_bit(SAS_DEV_EH_PENDING, &dev->state)) {
|
|
|
|
prepare_to_wait(&ha->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE);
|
|
|
|
spin_unlock_irq(&ha->lock);
|
|
|
|
schedule();
|
|
|
|
spin_lock_irq(&ha->lock);
|
|
|
|
}
|
|
|
|
finish_wait(&ha->eh_wait_q, &wait);
|
|
|
|
|
|
|
|
spin_unlock_irq(&ha->lock);
|
|
|
|
|
|
|
|
/* make sure SCSI EH is complete */
|
|
|
|
if (scsi_host_in_recovery(ha->core.shost)) {
|
|
|
|
msleep(10);
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-25 21:27:36 +08:00
|
|
|
static int sas_queue_reset(struct domain_device *dev, int reset_type,
|
|
|
|
u64 lun, int wait)
|
2012-06-22 14:30:48 +08:00
|
|
|
{
|
|
|
|
struct sas_ha_struct *ha = dev->port->ha;
|
|
|
|
int scheduled = 0, tries = 100;
|
|
|
|
|
|
|
|
/* ata: promote lun reset to bus reset */
|
|
|
|
if (dev_is_sata(dev)) {
|
|
|
|
sas_ata_schedule_reset(dev);
|
|
|
|
if (wait)
|
|
|
|
sas_ata_wait_eh(dev);
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!scheduled && tries--) {
|
|
|
|
spin_lock_irq(&ha->lock);
|
|
|
|
if (!test_bit(SAS_DEV_EH_PENDING, &dev->state) &&
|
|
|
|
!test_bit(reset_type, &dev->state)) {
|
|
|
|
scheduled = 1;
|
|
|
|
ha->eh_active++;
|
|
|
|
list_add_tail(&dev->ssp_dev.eh_list_node, &ha->eh_dev_q);
|
|
|
|
set_bit(SAS_DEV_EH_PENDING, &dev->state);
|
|
|
|
set_bit(reset_type, &dev->state);
|
|
|
|
int_to_scsilun(lun, &dev->ssp_dev.reset_lun);
|
|
|
|
scsi_schedule_eh(ha->core.shost);
|
|
|
|
}
|
|
|
|
spin_unlock_irq(&ha->lock);
|
|
|
|
|
|
|
|
if (wait)
|
|
|
|
sas_wait_eh(dev);
|
|
|
|
|
|
|
|
if (scheduled)
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_warn("%s reset of %s failed\n",
|
|
|
|
reset_type == SAS_DEV_LU_RESET ? "LUN" : "Bus",
|
|
|
|
dev_name(&dev->rphy->dev));
|
2012-06-22 14:30:48 +08:00
|
|
|
|
|
|
|
return FAILED;
|
|
|
|
}
|
|
|
|
|
2012-06-22 14:30:53 +08:00
|
|
|
int sas_eh_abort_handler(struct scsi_cmnd *cmd)
|
|
|
|
{
|
2018-01-10 16:34:02 +08:00
|
|
|
int res = TMF_RESP_FUNC_FAILED;
|
2012-06-22 14:30:53 +08:00
|
|
|
struct sas_task *task = TO_SAS_TASK(cmd);
|
|
|
|
struct Scsi_Host *host = cmd->device->host;
|
2018-01-10 16:34:02 +08:00
|
|
|
struct domain_device *dev = cmd_to_domain_dev(cmd);
|
2012-06-22 14:30:53 +08:00
|
|
|
struct sas_internal *i = to_sas_internal(host->transportt);
|
2018-01-10 16:34:02 +08:00
|
|
|
unsigned long flags;
|
2012-06-22 14:30:53 +08:00
|
|
|
|
|
|
|
if (!i->dft->lldd_abort_task)
|
|
|
|
return FAILED;
|
|
|
|
|
2018-01-10 16:34:02 +08:00
|
|
|
spin_lock_irqsave(host->host_lock, flags);
|
|
|
|
/* We cannot do async aborts for SATA devices */
|
|
|
|
if (dev_is_sata(dev) && !host->host_eh_scheduled) {
|
|
|
|
spin_unlock_irqrestore(host->host_lock, flags);
|
|
|
|
return FAILED;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(host->host_lock, flags);
|
|
|
|
|
|
|
|
if (task)
|
|
|
|
res = i->dft->lldd_abort_task(task);
|
|
|
|
else
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("no task to abort\n");
|
2012-06-22 14:30:53 +08:00
|
|
|
if (res == TMF_RESP_FUNC_SUCC || res == TMF_RESP_FUNC_COMPLETE)
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
return FAILED;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(sas_eh_abort_handler);
|
|
|
|
|
2007-01-30 15:48:19 +08:00
|
|
|
/* Attempt to send a LUN reset message to a device */
|
2007-01-27 06:08:52 +08:00
|
|
|
int sas_eh_device_reset_handler(struct scsi_cmnd *cmd)
|
2007-01-30 15:48:19 +08:00
|
|
|
{
|
|
|
|
int res;
|
2012-06-22 14:30:48 +08:00
|
|
|
struct scsi_lun lun;
|
|
|
|
struct Scsi_Host *host = cmd->device->host;
|
|
|
|
struct domain_device *dev = cmd_to_domain_dev(cmd);
|
|
|
|
struct sas_internal *i = to_sas_internal(host->transportt);
|
|
|
|
|
|
|
|
if (current != host->ehandler)
|
|
|
|
return sas_queue_reset(dev, SAS_DEV_LU_RESET, cmd->device->lun, 0);
|
2007-01-30 15:48:19 +08:00
|
|
|
|
|
|
|
int_to_scsilun(cmd->device->lun, &lun);
|
|
|
|
|
|
|
|
if (!i->dft->lldd_lu_reset)
|
|
|
|
return FAILED;
|
|
|
|
|
|
|
|
res = i->dft->lldd_lu_reset(dev, lun.scsi_lun);
|
|
|
|
if (res == TMF_RESP_FUNC_SUCC || res == TMF_RESP_FUNC_COMPLETE)
|
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
return FAILED;
|
|
|
|
}
|
|
|
|
|
2017-08-25 19:57:02 +08:00
|
|
|
int sas_eh_target_reset_handler(struct scsi_cmnd *cmd)
|
2007-01-27 06:08:52 +08:00
|
|
|
{
|
|
|
|
int res;
|
2012-06-22 14:30:58 +08:00
|
|
|
struct Scsi_Host *host = cmd->device->host;
|
|
|
|
struct domain_device *dev = cmd_to_domain_dev(cmd);
|
|
|
|
struct sas_internal *i = to_sas_internal(host->transportt);
|
2007-01-27 06:08:52 +08:00
|
|
|
|
2012-06-22 14:30:48 +08:00
|
|
|
if (current != host->ehandler)
|
|
|
|
return sas_queue_reset(dev, SAS_DEV_RESET, 0, 0);
|
|
|
|
|
2012-06-22 14:30:58 +08:00
|
|
|
if (!i->dft->lldd_I_T_nexus_reset)
|
|
|
|
return FAILED;
|
2011-12-22 13:33:17 +08:00
|
|
|
|
2012-06-22 14:30:58 +08:00
|
|
|
res = i->dft->lldd_I_T_nexus_reset(dev);
|
|
|
|
if (res == TMF_RESP_FUNC_SUCC || res == TMF_RESP_FUNC_COMPLETE ||
|
|
|
|
res == -ENODEV)
|
2007-01-27 06:08:52 +08:00
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
return FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try to reset a device */
|
2008-02-24 13:39:59 +08:00
|
|
|
static int try_to_reset_cmd_device(struct scsi_cmnd *cmd)
|
2007-01-27 06:08:52 +08:00
|
|
|
{
|
2007-01-30 15:48:19 +08:00
|
|
|
int res;
|
2008-02-24 13:39:59 +08:00
|
|
|
struct Scsi_Host *shost = cmd->device->host;
|
2007-01-30 15:48:19 +08:00
|
|
|
|
2007-01-27 06:08:52 +08:00
|
|
|
if (!shost->hostt->eh_device_reset_handler)
|
2017-08-25 19:57:02 +08:00
|
|
|
goto try_target_reset;
|
2007-01-30 15:48:19 +08:00
|
|
|
|
|
|
|
res = shost->hostt->eh_device_reset_handler(cmd);
|
|
|
|
if (res == SUCCESS)
|
|
|
|
return res;
|
2007-01-27 06:08:52 +08:00
|
|
|
|
2017-08-25 19:57:02 +08:00
|
|
|
try_target_reset:
|
|
|
|
if (shost->hostt->eh_target_reset_handler)
|
|
|
|
return shost->hostt->eh_target_reset_handler(cmd);
|
2007-01-30 15:48:19 +08:00
|
|
|
|
|
|
|
return FAILED;
|
2007-01-27 06:08:52 +08:00
|
|
|
}
|
|
|
|
|
2012-01-21 07:23:07 +08:00
|
|
|
static void sas_eh_handle_sas_errors(struct Scsi_Host *shost, struct list_head *work_q)
|
2006-08-29 22:22:51 +08:00
|
|
|
{
|
|
|
|
struct scsi_cmnd *cmd, *n;
|
|
|
|
enum task_disposition res = TASK_IS_DONE;
|
2007-01-12 06:15:17 +08:00
|
|
|
int tmf_resp, need_reset;
|
2006-08-29 22:22:51 +08:00
|
|
|
struct sas_internal *i = to_sas_internal(shost->transportt);
|
2007-01-27 06:08:52 +08:00
|
|
|
unsigned long flags;
|
|
|
|
struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost);
|
2012-01-10 02:12:52 +08:00
|
|
|
LIST_HEAD(done);
|
2006-08-29 22:22:51 +08:00
|
|
|
|
2012-01-10 02:12:52 +08:00
|
|
|
/* clean out any commands that won the completion vs eh race */
|
2007-01-27 06:08:52 +08:00
|
|
|
list_for_each_entry_safe(cmd, n, work_q, eh_entry) {
|
2011-11-29 03:29:20 +08:00
|
|
|
struct domain_device *dev = cmd_to_domain_dev(cmd);
|
|
|
|
struct sas_task *task;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dev->done_lock, flags);
|
|
|
|
/* by this point the lldd has either observed
|
|
|
|
* SAS_HA_FROZEN and is leaving the task alone, or has
|
|
|
|
* won the race with eh and decided to complete it
|
|
|
|
*/
|
|
|
|
task = TO_SAS_TASK(cmd);
|
|
|
|
spin_unlock_irqrestore(&dev->done_lock, flags);
|
2006-08-29 22:22:51 +08:00
|
|
|
|
2007-01-27 06:08:52 +08:00
|
|
|
if (!task)
|
2012-01-10 02:12:52 +08:00
|
|
|
list_move_tail(&cmd->eh_entry, &done);
|
|
|
|
}
|
|
|
|
|
|
|
|
Again:
|
|
|
|
list_for_each_entry_safe(cmd, n, work_q, eh_entry) {
|
|
|
|
struct sas_task *task = TO_SAS_TASK(cmd);
|
2007-01-27 06:08:52 +08:00
|
|
|
|
|
|
|
list_del_init(&cmd->eh_entry);
|
2007-01-12 06:15:17 +08:00
|
|
|
|
|
|
|
spin_lock_irqsave(&task->task_state_lock, flags);
|
|
|
|
need_reset = task->task_state_flags & SAS_TASK_NEED_DEV_RESET;
|
|
|
|
spin_unlock_irqrestore(&task->task_state_lock, flags);
|
|
|
|
|
2008-02-24 13:39:59 +08:00
|
|
|
if (need_reset) {
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("%s: task 0x%p requests reset\n",
|
|
|
|
__func__, task);
|
2008-02-24 13:39:59 +08:00
|
|
|
goto reset;
|
|
|
|
}
|
|
|
|
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_debug("trying to find task 0x%p\n", task);
|
2006-08-29 22:22:51 +08:00
|
|
|
res = sas_scsi_find_task(task);
|
|
|
|
|
|
|
|
switch (res) {
|
|
|
|
case TASK_IS_DONE:
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("%s: task 0x%p is done\n", __func__,
|
2006-08-29 22:22:51 +08:00
|
|
|
task);
|
2018-03-08 10:34:53 +08:00
|
|
|
sas_eh_finish_cmd(cmd);
|
2006-08-29 22:22:51 +08:00
|
|
|
continue;
|
|
|
|
case TASK_IS_ABORTED:
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("%s: task 0x%p is aborted\n",
|
|
|
|
__func__, task);
|
2018-03-08 10:34:53 +08:00
|
|
|
sas_eh_finish_cmd(cmd);
|
2006-08-29 22:22:51 +08:00
|
|
|
continue;
|
|
|
|
case TASK_IS_AT_LU:
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_info("task 0x%p is at LU: lu recover\n", task);
|
2008-02-24 13:39:59 +08:00
|
|
|
reset:
|
2006-08-29 22:22:51 +08:00
|
|
|
tmf_resp = sas_recover_lu(task->dev, cmd);
|
|
|
|
if (tmf_resp == TMF_RESP_FUNC_COMPLETE) {
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("dev %016llx LU %llx is recovered\n",
|
|
|
|
SAS_ADDR(task->dev),
|
|
|
|
cmd->device->lun);
|
2018-03-08 10:34:53 +08:00
|
|
|
sas_eh_finish_cmd(cmd);
|
2007-01-27 06:08:52 +08:00
|
|
|
sas_scsi_clear_queue_lu(work_q, cmd);
|
2006-08-29 22:22:51 +08:00
|
|
|
goto Again;
|
|
|
|
}
|
|
|
|
/* fallthrough */
|
|
|
|
case TASK_IS_NOT_AT_LU:
|
2007-01-12 06:15:46 +08:00
|
|
|
case TASK_ABORT_FAILED:
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("task 0x%p is not at LU: I_T recover\n",
|
|
|
|
task);
|
2006-08-29 22:22:51 +08:00
|
|
|
tmf_resp = sas_recover_I_T(task->dev);
|
2012-01-31 13:40:45 +08:00
|
|
|
if (tmf_resp == TMF_RESP_FUNC_COMPLETE ||
|
|
|
|
tmf_resp == -ENODEV) {
|
2008-02-24 13:39:59 +08:00
|
|
|
struct domain_device *dev = task->dev;
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("I_T %016llx recovered\n",
|
|
|
|
SAS_ADDR(task->dev->sas_addr));
|
2008-02-20 11:48:42 +08:00
|
|
|
sas_eh_finish_cmd(cmd);
|
2008-02-24 13:39:59 +08:00
|
|
|
sas_scsi_clear_queue_I_T(work_q, dev);
|
2006-08-29 22:22:51 +08:00
|
|
|
goto Again;
|
|
|
|
}
|
|
|
|
/* Hammer time :-) */
|
2008-02-24 13:39:59 +08:00
|
|
|
try_to_reset_cmd_device(cmd);
|
2006-08-29 22:22:51 +08:00
|
|
|
if (i->dft->lldd_clear_nexus_port) {
|
|
|
|
struct asd_sas_port *port = task->dev->port;
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_debug("clearing nexus for port:%d\n",
|
|
|
|
port->id);
|
2006-08-29 22:22:51 +08:00
|
|
|
res = i->dft->lldd_clear_nexus_port(port);
|
|
|
|
if (res == TMF_RESP_FUNC_COMPLETE) {
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("clear nexus port:%d succeeded\n",
|
|
|
|
port->id);
|
2008-02-20 11:48:42 +08:00
|
|
|
sas_eh_finish_cmd(cmd);
|
2007-01-27 06:08:52 +08:00
|
|
|
sas_scsi_clear_queue_port(work_q,
|
2006-08-29 22:22:51 +08:00
|
|
|
port);
|
|
|
|
goto Again;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i->dft->lldd_clear_nexus_ha) {
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_debug("clear nexus ha\n");
|
2006-08-29 22:22:51 +08:00
|
|
|
res = i->dft->lldd_clear_nexus_ha(ha);
|
|
|
|
if (res == TMF_RESP_FUNC_COMPLETE) {
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("clear nexus ha succeeded\n");
|
2008-02-20 11:48:42 +08:00
|
|
|
sas_eh_finish_cmd(cmd);
|
|
|
|
goto clear_q;
|
2006-08-29 22:22:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* If we are here -- this means that no amount
|
|
|
|
* of effort could recover from errors. Quite
|
|
|
|
* possibly the HA just disappeared.
|
|
|
|
*/
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_err("error from device %llx, LUN %llx couldn't be recovered in any way\n",
|
|
|
|
SAS_ADDR(task->dev->sas_addr),
|
|
|
|
cmd->device->lun);
|
2006-08-29 22:22:51 +08:00
|
|
|
|
2008-02-20 11:48:42 +08:00
|
|
|
sas_eh_finish_cmd(cmd);
|
2006-08-29 22:22:51 +08:00
|
|
|
goto clear_q;
|
|
|
|
}
|
|
|
|
}
|
2012-01-10 02:12:52 +08:00
|
|
|
out:
|
|
|
|
list_splice_tail(&done, work_q);
|
2011-11-30 04:08:50 +08:00
|
|
|
list_splice_tail_init(&ha->eh_ata_q, work_q);
|
2012-01-21 07:23:07 +08:00
|
|
|
return;
|
2012-01-10 02:12:52 +08:00
|
|
|
|
|
|
|
clear_q:
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_debug("--- Exit %s -- clear_q\n", __func__);
|
2008-02-20 11:48:42 +08:00
|
|
|
list_for_each_entry_safe(cmd, n, work_q, eh_entry)
|
|
|
|
sas_eh_finish_cmd(cmd);
|
2012-01-10 02:12:52 +08:00
|
|
|
goto out;
|
2007-01-27 06:08:52 +08:00
|
|
|
}
|
|
|
|
|
2012-06-22 14:30:48 +08:00
|
|
|
static void sas_eh_handle_resets(struct Scsi_Host *shost)
|
|
|
|
{
|
|
|
|
struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct sas_internal *i = to_sas_internal(shost->transportt);
|
|
|
|
|
|
|
|
/* handle directed resets to sas devices */
|
|
|
|
spin_lock_irq(&ha->lock);
|
|
|
|
while (!list_empty(&ha->eh_dev_q)) {
|
|
|
|
struct domain_device *dev;
|
|
|
|
struct ssp_device *ssp;
|
|
|
|
|
|
|
|
ssp = list_entry(ha->eh_dev_q.next, typeof(*ssp), eh_list_node);
|
|
|
|
list_del_init(&ssp->eh_list_node);
|
|
|
|
dev = container_of(ssp, typeof(*dev), ssp_dev);
|
|
|
|
kref_get(&dev->kref);
|
|
|
|
WARN_ONCE(dev_is_sata(dev), "ssp reset to ata device?\n");
|
|
|
|
|
|
|
|
spin_unlock_irq(&ha->lock);
|
|
|
|
|
|
|
|
if (test_and_clear_bit(SAS_DEV_LU_RESET, &dev->state))
|
|
|
|
i->dft->lldd_lu_reset(dev, ssp->reset_lun.scsi_lun);
|
|
|
|
|
|
|
|
if (test_and_clear_bit(SAS_DEV_RESET, &dev->state))
|
|
|
|
i->dft->lldd_I_T_nexus_reset(dev);
|
|
|
|
|
|
|
|
sas_put_device(dev);
|
|
|
|
spin_lock_irq(&ha->lock);
|
|
|
|
clear_bit(SAS_DEV_EH_PENDING, &dev->state);
|
|
|
|
ha->eh_active--;
|
|
|
|
}
|
|
|
|
spin_unlock_irq(&ha->lock);
|
|
|
|
}
|
|
|
|
|
2012-06-22 14:25:27 +08:00
|
|
|
|
2007-01-27 06:08:52 +08:00
|
|
|
void sas_scsi_recover_host(struct Scsi_Host *shost)
|
|
|
|
{
|
|
|
|
struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost);
|
|
|
|
LIST_HEAD(eh_work_q);
|
2012-06-22 14:25:27 +08:00
|
|
|
int tries = 0;
|
|
|
|
bool retry;
|
2007-01-27 06:08:52 +08:00
|
|
|
|
2012-06-22 14:25:27 +08:00
|
|
|
retry:
|
|
|
|
tries++;
|
|
|
|
retry = true;
|
|
|
|
spin_lock_irq(shost->host_lock);
|
2007-01-27 06:08:52 +08:00
|
|
|
list_splice_init(&shost->eh_cmd_q, &eh_work_q);
|
2012-06-22 14:25:27 +08:00
|
|
|
spin_unlock_irq(shost->host_lock);
|
2007-01-27 06:08:52 +08:00
|
|
|
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("Enter %s busy: %d failed: %d\n",
|
|
|
|
__func__, scsi_host_busy(shost), shost->host_failed);
|
2007-01-27 06:08:52 +08:00
|
|
|
/*
|
|
|
|
* Deal with commands that still have SAS tasks (i.e. they didn't
|
2012-01-21 07:23:07 +08:00
|
|
|
* complete via the normal sas_task completion mechanism),
|
|
|
|
* SAS_HA_FROZEN gives eh dominion over all sas_task completion.
|
2007-01-27 06:08:52 +08:00
|
|
|
*/
|
2011-11-29 03:29:20 +08:00
|
|
|
set_bit(SAS_HA_FROZEN, &ha->state);
|
2012-01-21 07:23:07 +08:00
|
|
|
sas_eh_handle_sas_errors(shost, &eh_work_q);
|
|
|
|
clear_bit(SAS_HA_FROZEN, &ha->state);
|
|
|
|
if (list_empty(&eh_work_q))
|
2007-01-27 06:08:52 +08:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now deal with SCSI commands that completed ok but have a an error
|
|
|
|
* code (and hopefully sense data) attached. This is roughly what
|
|
|
|
* scsi_unjam_host does, but we skip scsi_eh_abort_cmds because any
|
|
|
|
* command we see here has no sas_task and is thus unknown to the HA.
|
|
|
|
*/
|
2012-01-12 04:08:36 +08:00
|
|
|
sas_ata_eh(shost, &eh_work_q, &ha->eh_done_q);
|
|
|
|
if (!scsi_eh_get_sense(&eh_work_q, &ha->eh_done_q))
|
|
|
|
scsi_eh_ready_devs(shost, &eh_work_q, &ha->eh_done_q);
|
2007-01-27 06:08:52 +08:00
|
|
|
|
|
|
|
out:
|
2012-06-22 14:30:48 +08:00
|
|
|
sas_eh_handle_resets(shost);
|
|
|
|
|
2011-01-23 23:44:12 +08:00
|
|
|
/* now link into libata eh --- if we have any ata devices */
|
|
|
|
sas_ata_strategy_handler(shost);
|
|
|
|
|
2007-01-27 06:08:52 +08:00
|
|
|
scsi_eh_flush_done_q(&ha->eh_done_q);
|
2011-01-23 23:44:12 +08:00
|
|
|
|
2012-06-22 14:25:27 +08:00
|
|
|
/* check if any new eh work was scheduled during the last run */
|
|
|
|
spin_lock_irq(&ha->lock);
|
|
|
|
if (ha->eh_active == 0) {
|
|
|
|
shost->host_eh_scheduled = 0;
|
|
|
|
retry = false;
|
|
|
|
}
|
|
|
|
spin_unlock_irq(&ha->lock);
|
|
|
|
|
|
|
|
if (retry)
|
|
|
|
goto retry;
|
|
|
|
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("--- Exit %s: busy: %d failed: %d tries: %d\n",
|
|
|
|
__func__, scsi_host_busy(shost),
|
|
|
|
shost->host_failed, tries);
|
2006-08-29 22:22:51 +08:00
|
|
|
}
|
|
|
|
|
2019-02-08 00:07:20 +08:00
|
|
|
int sas_ioctl(struct scsi_device *sdev, unsigned int cmd, void __user *arg)
|
2006-08-11 10:19:47 +08:00
|
|
|
{
|
|
|
|
struct domain_device *dev = sdev_to_domain_dev(sdev);
|
|
|
|
|
|
|
|
if (dev_is_sata(dev))
|
2009-01-16 23:17:09 +08:00
|
|
|
return ata_sas_scsi_ioctl(dev->sata_dev.ap, sdev, cmd, arg);
|
2006-08-11 10:19:47 +08:00
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2006-08-29 22:22:51 +08:00
|
|
|
struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy)
|
|
|
|
{
|
|
|
|
struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent);
|
|
|
|
struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost);
|
|
|
|
struct domain_device *found_dev = NULL;
|
|
|
|
int i;
|
2007-01-12 06:15:40 +08:00
|
|
|
unsigned long flags;
|
2006-08-29 22:22:51 +08:00
|
|
|
|
2007-01-12 06:15:40 +08:00
|
|
|
spin_lock_irqsave(&ha->phy_port_lock, flags);
|
2006-08-29 22:22:51 +08:00
|
|
|
for (i = 0; i < ha->num_phys; i++) {
|
|
|
|
struct asd_sas_port *port = ha->sas_port[i];
|
|
|
|
struct domain_device *dev;
|
|
|
|
|
|
|
|
spin_lock(&port->dev_list_lock);
|
|
|
|
list_for_each_entry(dev, &port->dev_list, dev_list_node) {
|
|
|
|
if (rphy == dev->rphy) {
|
|
|
|
found_dev = dev;
|
|
|
|
spin_unlock(&port->dev_list_lock);
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_unlock(&port->dev_list_lock);
|
|
|
|
}
|
|
|
|
found:
|
2007-01-12 06:15:40 +08:00
|
|
|
spin_unlock_irqrestore(&ha->phy_port_lock, flags);
|
2006-08-29 22:22:51 +08:00
|
|
|
|
|
|
|
return found_dev;
|
|
|
|
}
|
|
|
|
|
|
|
|
int sas_target_alloc(struct scsi_target *starget)
|
|
|
|
{
|
2011-11-18 09:59:47 +08:00
|
|
|
struct sas_rphy *rphy = dev_to_rphy(starget->dev.parent);
|
|
|
|
struct domain_device *found_dev = sas_find_dev_by_rphy(rphy);
|
2006-08-29 22:22:51 +08:00
|
|
|
|
|
|
|
if (!found_dev)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2011-11-18 09:59:47 +08:00
|
|
|
kref_get(&found_dev->kref);
|
2006-08-29 22:22:51 +08:00
|
|
|
starget->hostdata = found_dev;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-09-21 06:10:46 +08:00
|
|
|
#define SAS_DEF_QD 256
|
2006-08-29 22:22:51 +08:00
|
|
|
|
|
|
|
int sas_slave_configure(struct scsi_device *scsi_dev)
|
|
|
|
{
|
|
|
|
struct domain_device *dev = sdev_to_domain_dev(scsi_dev);
|
|
|
|
|
|
|
|
BUG_ON(dev->rphy->identify.device_type != SAS_END_DEVICE);
|
|
|
|
|
2006-08-11 10:19:47 +08:00
|
|
|
if (dev_is_sata(dev)) {
|
|
|
|
ata_sas_slave_configure(scsi_dev, dev->sata_dev.ap);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-08-29 22:22:51 +08:00
|
|
|
sas_read_port_mode_page(scsi_dev);
|
|
|
|
|
|
|
|
if (scsi_dev->tagged_supported) {
|
2014-11-13 22:08:42 +08:00
|
|
|
scsi_change_queue_depth(scsi_dev, SAS_DEF_QD);
|
2006-08-29 22:22:51 +08:00
|
|
|
} else {
|
2018-11-15 18:20:31 +08:00
|
|
|
pr_notice("device %llx, LUN %llx doesn't support TCQ\n",
|
|
|
|
SAS_ADDR(dev->sas_addr), scsi_dev->lun);
|
2014-11-13 22:08:42 +08:00
|
|
|
scsi_change_queue_depth(scsi_dev, 1);
|
2006-08-29 22:22:51 +08:00
|
|
|
}
|
|
|
|
|
2007-01-27 06:08:58 +08:00
|
|
|
scsi_dev->allow_restart = 1;
|
|
|
|
|
2006-08-29 22:22:51 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-13 22:08:42 +08:00
|
|
|
int sas_change_queue_depth(struct scsi_device *sdev, int depth)
|
2006-08-29 22:22:51 +08:00
|
|
|
{
|
2011-09-21 06:10:46 +08:00
|
|
|
struct domain_device *dev = sdev_to_domain_dev(sdev);
|
2006-08-29 22:22:51 +08:00
|
|
|
|
2011-09-21 06:10:33 +08:00
|
|
|
if (dev_is_sata(dev))
|
2014-11-13 22:08:42 +08:00
|
|
|
return __ata_change_queue_depth(dev->sata_dev.ap, sdev, depth);
|
2011-09-21 06:10:46 +08:00
|
|
|
|
2014-11-13 21:25:11 +08:00
|
|
|
if (!sdev->tagged_supported)
|
|
|
|
depth = 1;
|
2014-11-13 22:08:42 +08:00
|
|
|
return scsi_change_queue_depth(sdev, depth);
|
2006-08-29 22:22:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int sas_bios_param(struct scsi_device *scsi_dev,
|
|
|
|
struct block_device *bdev,
|
|
|
|
sector_t capacity, int *hsc)
|
|
|
|
{
|
|
|
|
hsc[0] = 255;
|
|
|
|
hsc[1] = 63;
|
|
|
|
sector_div(capacity, 255*63);
|
|
|
|
hsc[2] = capacity;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-12 06:15:20 +08:00
|
|
|
/*
|
|
|
|
* Tell an upper layer that it needs to initiate an abort for a given task.
|
|
|
|
* This should only ever be called by an LLDD.
|
|
|
|
*/
|
|
|
|
void sas_task_abort(struct sas_task *task)
|
2006-10-31 07:18:50 +08:00
|
|
|
{
|
2007-01-12 06:15:20 +08:00
|
|
|
struct scsi_cmnd *sc = task->uldd_task;
|
2006-10-31 07:18:50 +08:00
|
|
|
|
2007-01-12 06:15:20 +08:00
|
|
|
/* Escape for libsas internal commands */
|
|
|
|
if (!sc) {
|
2012-06-22 14:36:30 +08:00
|
|
|
struct sas_task_slow *slow = task->slow_task;
|
|
|
|
|
|
|
|
if (!slow)
|
|
|
|
return;
|
|
|
|
if (!del_timer(&slow->timer))
|
2006-10-31 07:18:50 +08:00
|
|
|
return;
|
2017-10-23 15:40:42 +08:00
|
|
|
slow->timer.function(&slow->timer);
|
2007-01-12 06:15:20 +08:00
|
|
|
return;
|
|
|
|
}
|
2006-10-31 07:18:50 +08:00
|
|
|
|
2018-11-15 00:02:06 +08:00
|
|
|
if (dev_is_sata(task->dev))
|
2007-01-30 17:18:58 +08:00
|
|
|
sas_ata_task_abort(task);
|
2018-11-15 00:02:06 +08:00
|
|
|
else
|
2010-05-13 22:31:54 +08:00
|
|
|
blk_abort_request(sc->request);
|
2006-10-31 07:18:50 +08:00
|
|
|
}
|
|
|
|
|
2024-06-12 13:13:20 +08:00
|
|
|
int sas_slave_alloc(struct scsi_device *sdev)
|
|
|
|
{
|
|
|
|
if (dev_is_sata(sdev_to_domain_dev(sdev)) && sdev->lun)
|
|
|
|
return -ENXIO;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-08-11 10:19:47 +08:00
|
|
|
void sas_target_destroy(struct scsi_target *starget)
|
|
|
|
{
|
2011-11-18 09:59:47 +08:00
|
|
|
struct domain_device *found_dev = starget->hostdata;
|
2006-08-11 10:19:47 +08:00
|
|
|
|
|
|
|
if (!found_dev)
|
|
|
|
return;
|
|
|
|
|
2011-11-18 09:59:47 +08:00
|
|
|
starget->hostdata = NULL;
|
|
|
|
sas_put_device(found_dev);
|
2006-08-11 10:19:47 +08:00
|
|
|
}
|
|
|
|
|
2008-02-20 02:49:40 +08:00
|
|
|
#define SAS_STRING_ADDR_SIZE 16
|
|
|
|
|
|
|
|
int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
const struct firmware *fw;
|
|
|
|
|
|
|
|
res = request_firmware(&fw, "sas_addr", &shost->shost_gendev);
|
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
if (fw->size < SAS_STRING_ADDR_SIZE) {
|
|
|
|
res = -ENODEV;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-12-20 01:37:27 +08:00
|
|
|
res = hex2bin(addr, fw->data, strnlen(fw->data, SAS_ADDR_SIZE * 2) / 2);
|
|
|
|
if (res)
|
|
|
|
goto out;
|
2008-02-20 02:49:40 +08:00
|
|
|
|
|
|
|
out:
|
|
|
|
release_firmware(fw);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(sas_request_addr);
|
|
|
|
|
2006-08-29 22:22:51 +08:00
|
|
|
EXPORT_SYMBOL_GPL(sas_queuecommand);
|
|
|
|
EXPORT_SYMBOL_GPL(sas_target_alloc);
|
|
|
|
EXPORT_SYMBOL_GPL(sas_slave_configure);
|
|
|
|
EXPORT_SYMBOL_GPL(sas_change_queue_depth);
|
|
|
|
EXPORT_SYMBOL_GPL(sas_bios_param);
|
2006-10-31 07:18:50 +08:00
|
|
|
EXPORT_SYMBOL_GPL(sas_task_abort);
|
2006-11-08 09:28:55 +08:00
|
|
|
EXPORT_SYMBOL_GPL(sas_phy_reset);
|
2007-01-27 06:08:52 +08:00
|
|
|
EXPORT_SYMBOL_GPL(sas_eh_device_reset_handler);
|
2017-08-25 19:57:02 +08:00
|
|
|
EXPORT_SYMBOL_GPL(sas_eh_target_reset_handler);
|
2024-06-12 13:13:20 +08:00
|
|
|
EXPORT_SYMBOL_GPL(sas_slave_alloc);
|
2006-08-11 10:19:47 +08:00
|
|
|
EXPORT_SYMBOL_GPL(sas_target_destroy);
|
|
|
|
EXPORT_SYMBOL_GPL(sas_ioctl);
|