2019-05-19 13:51:48 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-05-01 21:49:59 +00:00
|
|
|
/*
|
|
|
|
* Basic HP/COMPAQ MSA 1000 support. This is only needed if your HW cannot be
|
|
|
|
* upgraded.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Red Hat, Inc. All rights reserved.
|
|
|
|
* Copyright (C) 2006 Mike Christie
|
2008-07-17 23:53:09 +00:00
|
|
|
* Copyright (C) 2008 Hannes Reinecke <hare@suse.de>
|
2008-05-01 21:49:59 +00:00
|
|
|
*/
|
|
|
|
|
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 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2011-05-27 13:47:43 +00:00
|
|
|
#include <linux/module.h>
|
2008-05-01 21:49:59 +00:00
|
|
|
#include <scsi/scsi.h>
|
|
|
|
#include <scsi/scsi_dbg.h>
|
|
|
|
#include <scsi/scsi_eh.h>
|
|
|
|
#include <scsi/scsi_dh.h>
|
|
|
|
|
2008-07-17 23:53:09 +00:00
|
|
|
#define HP_SW_NAME "hp_sw"
|
2008-05-01 21:49:59 +00:00
|
|
|
|
2008-07-17 23:53:09 +00:00
|
|
|
#define HP_SW_TIMEOUT (60 * HZ)
|
|
|
|
#define HP_SW_RETRIES 3
|
|
|
|
|
|
|
|
#define HP_SW_PATH_UNINITIALIZED -1
|
|
|
|
#define HP_SW_PATH_ACTIVE 0
|
|
|
|
#define HP_SW_PATH_PASSIVE 1
|
2008-05-01 21:49:59 +00:00
|
|
|
|
|
|
|
struct hp_sw_dh_data {
|
2008-07-17 23:53:09 +00:00
|
|
|
int path_state;
|
2008-05-01 21:49:59 +00:00
|
|
|
int retries;
|
2009-10-21 16:22:58 +00:00
|
|
|
int retry_cnt;
|
|
|
|
struct scsi_device *sdev;
|
2008-05-01 21:49:59 +00:00
|
|
|
};
|
|
|
|
|
2009-10-21 16:22:58 +00:00
|
|
|
static int hp_sw_start_stop(struct hp_sw_dh_data *);
|
|
|
|
|
2008-07-17 23:53:09 +00:00
|
|
|
/*
|
|
|
|
* tur_done - Handle TEST UNIT READY return status
|
|
|
|
* @sdev: sdev the command has been sent to
|
|
|
|
* @errors: blk error code
|
|
|
|
*
|
|
|
|
* Returns SCSI_DH_DEV_OFFLINED if the sdev is on the passive path
|
|
|
|
*/
|
2016-11-03 13:20:23 +00:00
|
|
|
static int tur_done(struct scsi_device *sdev, struct hp_sw_dh_data *h,
|
|
|
|
struct scsi_sense_hdr *sshdr)
|
2008-05-01 21:49:59 +00:00
|
|
|
{
|
2016-11-03 13:20:23 +00:00
|
|
|
int ret = SCSI_DH_IO;
|
2008-05-01 21:49:59 +00:00
|
|
|
|
2016-11-03 13:20:23 +00:00
|
|
|
switch (sshdr->sense_key) {
|
2008-07-17 23:53:09 +00:00
|
|
|
case UNIT_ATTENTION:
|
|
|
|
ret = SCSI_DH_IMM_RETRY;
|
|
|
|
break;
|
2008-05-01 21:49:59 +00:00
|
|
|
case NOT_READY:
|
2016-11-03 13:20:23 +00:00
|
|
|
if (sshdr->asc == 0x04 && sshdr->ascq == 2) {
|
2008-07-17 23:53:09 +00:00
|
|
|
/*
|
|
|
|
* LUN not ready - Initialization command required
|
|
|
|
*
|
|
|
|
* This is the passive path
|
|
|
|
*/
|
2016-11-03 13:20:23 +00:00
|
|
|
h->path_state = HP_SW_PATH_PASSIVE;
|
|
|
|
ret = SCSI_DH_OK;
|
2008-05-01 21:49:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-08-23 22:36:59 +00:00
|
|
|
fallthrough;
|
2008-05-01 21:49:59 +00:00
|
|
|
default:
|
2008-07-17 23:53:09 +00:00
|
|
|
sdev_printk(KERN_WARNING, sdev,
|
|
|
|
"%s: sending tur failed, sense %x/%x/%x\n",
|
2016-11-03 13:20:23 +00:00
|
|
|
HP_SW_NAME, sshdr->sense_key, sshdr->asc,
|
|
|
|
sshdr->ascq);
|
2008-07-17 23:53:09 +00:00
|
|
|
break;
|
2008-05-01 21:49:59 +00:00
|
|
|
}
|
2008-07-17 23:53:09 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* hp_sw_tur - Send TEST UNIT READY
|
|
|
|
* @sdev: sdev command should be sent to
|
|
|
|
*
|
|
|
|
* Use the TEST UNIT READY command to determine
|
|
|
|
* the path state.
|
|
|
|
*/
|
|
|
|
static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
|
|
|
|
{
|
2016-11-03 13:20:23 +00:00
|
|
|
unsigned char cmd[6] = { TEST_UNIT_READY };
|
|
|
|
struct scsi_sense_hdr sshdr;
|
|
|
|
int ret = SCSI_DH_OK, res;
|
2022-07-14 18:07:08 +00:00
|
|
|
blk_opf_t req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
|
2016-11-03 13:20:23 +00:00
|
|
|
REQ_FAILFAST_DRIVER;
|
2008-07-17 23:53:09 +00:00
|
|
|
|
2008-12-09 14:52:15 +00:00
|
|
|
retry:
|
2017-02-23 15:02:37 +00:00
|
|
|
res = scsi_execute(sdev, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
|
|
|
|
HP_SW_TIMEOUT, HP_SW_RETRIES, req_flags, 0, NULL);
|
2016-11-03 13:20:23 +00:00
|
|
|
if (res) {
|
|
|
|
if (scsi_sense_valid(&sshdr))
|
|
|
|
ret = tur_done(sdev, h, &sshdr);
|
|
|
|
else {
|
2008-07-17 23:53:09 +00:00
|
|
|
sdev_printk(KERN_WARNING, sdev,
|
|
|
|
"%s: sending tur failed with %x\n",
|
2016-11-03 13:20:23 +00:00
|
|
|
HP_SW_NAME, res);
|
2008-07-17 23:53:09 +00:00
|
|
|
ret = SCSI_DH_IO;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
h->path_state = HP_SW_PATH_ACTIVE;
|
|
|
|
ret = SCSI_DH_OK;
|
|
|
|
}
|
2016-11-03 13:20:23 +00:00
|
|
|
if (ret == SCSI_DH_IMM_RETRY)
|
2008-07-17 23:53:09 +00:00
|
|
|
goto retry;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* hp_sw_start_stop - Send START STOP UNIT command
|
|
|
|
* @sdev: sdev command should be sent to
|
|
|
|
*
|
|
|
|
* Sending START STOP UNIT activates the SP.
|
|
|
|
*/
|
2009-10-21 16:22:58 +00:00
|
|
|
static int hp_sw_start_stop(struct hp_sw_dh_data *h)
|
2008-05-01 21:49:59 +00:00
|
|
|
{
|
2016-11-03 13:20:23 +00:00
|
|
|
unsigned char cmd[6] = { START_STOP, 0, 0, 0, 1, 0 };
|
|
|
|
struct scsi_sense_hdr sshdr;
|
|
|
|
struct scsi_device *sdev = h->sdev;
|
|
|
|
int res, rc = SCSI_DH_OK;
|
|
|
|
int retry_cnt = HP_SW_RETRIES;
|
2022-07-14 18:07:08 +00:00
|
|
|
blk_opf_t req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
|
2016-11-03 13:20:23 +00:00
|
|
|
REQ_FAILFAST_DRIVER;
|
2008-07-17 23:53:09 +00:00
|
|
|
|
2016-11-03 13:20:23 +00:00
|
|
|
retry:
|
2017-02-23 15:02:37 +00:00
|
|
|
res = scsi_execute(sdev, cmd, DMA_NONE, NULL, 0, NULL, &sshdr,
|
|
|
|
HP_SW_TIMEOUT, HP_SW_RETRIES, req_flags, 0, NULL);
|
2016-11-03 13:20:23 +00:00
|
|
|
if (res) {
|
|
|
|
if (!scsi_sense_valid(&sshdr)) {
|
|
|
|
sdev_printk(KERN_WARNING, sdev,
|
|
|
|
"%s: sending start_stop_unit failed, "
|
|
|
|
"no sense available\n", HP_SW_NAME);
|
|
|
|
return SCSI_DH_IO;
|
|
|
|
}
|
|
|
|
switch (sshdr.sense_key) {
|
|
|
|
case NOT_READY:
|
|
|
|
if (sshdr.asc == 0x04 && sshdr.ascq == 3) {
|
|
|
|
/*
|
|
|
|
* LUN not ready - manual intervention required
|
|
|
|
*
|
|
|
|
* Switch-over in progress, retry.
|
|
|
|
*/
|
|
|
|
if (--retry_cnt)
|
|
|
|
goto retry;
|
|
|
|
rc = SCSI_DH_RETRY;
|
|
|
|
break;
|
|
|
|
}
|
2020-08-23 22:36:59 +00:00
|
|
|
fallthrough;
|
2016-11-03 13:20:23 +00:00
|
|
|
default:
|
|
|
|
sdev_printk(KERN_WARNING, sdev,
|
|
|
|
"%s: sending start_stop_unit failed, "
|
|
|
|
"sense %x/%x/%x\n", HP_SW_NAME,
|
|
|
|
sshdr.sense_key, sshdr.asc, sshdr.ascq);
|
|
|
|
rc = SCSI_DH_IO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rc;
|
2008-07-17 23:53:09 +00:00
|
|
|
}
|
|
|
|
|
2018-11-09 13:42:40 +00:00
|
|
|
static blk_status_t hp_sw_prep_fn(struct scsi_device *sdev, struct request *req)
|
2008-07-17 23:53:09 +00:00
|
|
|
{
|
2015-08-27 12:16:59 +00:00
|
|
|
struct hp_sw_dh_data *h = sdev->handler_data;
|
2008-07-17 23:53:09 +00:00
|
|
|
|
|
|
|
if (h->path_state != HP_SW_PATH_ACTIVE) {
|
2016-10-20 13:12:13 +00:00
|
|
|
req->rq_flags |= RQF_QUIET;
|
2018-11-09 13:42:40 +00:00
|
|
|
return BLK_STS_IOERR;
|
2008-07-17 23:53:09 +00:00
|
|
|
}
|
|
|
|
|
2018-11-09 13:42:40 +00:00
|
|
|
return BLK_STS_OK;
|
2008-07-17 23:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* hp_sw_activate - Activate a path
|
|
|
|
* @sdev: sdev on the path to be activated
|
|
|
|
*
|
|
|
|
* The HP Active/Passive firmware is pretty simple;
|
|
|
|
* the passive path reports NOT READY with sense codes
|
|
|
|
* 0x04/0x02; a START STOP UNIT command will then
|
|
|
|
* activate the passive path (and deactivate the
|
|
|
|
* previously active one).
|
|
|
|
*/
|
2009-10-21 16:22:46 +00:00
|
|
|
static int hp_sw_activate(struct scsi_device *sdev,
|
|
|
|
activate_complete fn, void *data)
|
2008-07-17 23:53:09 +00:00
|
|
|
{
|
|
|
|
int ret = SCSI_DH_OK;
|
2015-08-27 12:16:59 +00:00
|
|
|
struct hp_sw_dh_data *h = sdev->handler_data;
|
2008-07-17 23:53:09 +00:00
|
|
|
|
|
|
|
ret = hp_sw_tur(sdev, h);
|
|
|
|
|
2016-11-03 13:20:23 +00:00
|
|
|
if (ret == SCSI_DH_OK && h->path_state == HP_SW_PATH_PASSIVE)
|
2009-10-21 16:22:58 +00:00
|
|
|
ret = hp_sw_start_stop(h);
|
2008-07-17 23:53:09 +00:00
|
|
|
|
2009-10-21 16:22:46 +00:00
|
|
|
if (fn)
|
|
|
|
fn(data, ret);
|
|
|
|
return 0;
|
2008-05-01 21:49:59 +00:00
|
|
|
}
|
|
|
|
|
2015-08-27 12:16:59 +00:00
|
|
|
static int hp_sw_bus_attach(struct scsi_device *sdev)
|
2008-05-01 21:49:59 +00:00
|
|
|
{
|
2008-07-17 23:53:09 +00:00
|
|
|
struct hp_sw_dh_data *h;
|
|
|
|
int ret;
|
2008-05-01 21:49:59 +00:00
|
|
|
|
2014-09-14 02:59:51 +00:00
|
|
|
h = kzalloc(sizeof(*h), GFP_KERNEL);
|
2014-09-14 18:08:21 +00:00
|
|
|
if (!h)
|
2017-09-20 07:18:51 +00:00
|
|
|
return SCSI_DH_NOMEM;
|
2008-07-17 23:53:09 +00:00
|
|
|
h->path_state = HP_SW_PATH_UNINITIALIZED;
|
|
|
|
h->retries = HP_SW_RETRIES;
|
2009-10-21 16:22:58 +00:00
|
|
|
h->sdev = sdev;
|
2008-07-17 23:53:09 +00:00
|
|
|
|
|
|
|
ret = hp_sw_tur(sdev, h);
|
2017-09-20 07:18:51 +00:00
|
|
|
if (ret != SCSI_DH_OK)
|
2008-07-17 23:53:09 +00:00
|
|
|
goto failed;
|
2017-09-20 07:18:51 +00:00
|
|
|
if (h->path_state == HP_SW_PATH_UNINITIALIZED) {
|
|
|
|
ret = SCSI_DH_NOSYS;
|
|
|
|
goto failed;
|
|
|
|
}
|
2008-07-17 23:53:09 +00:00
|
|
|
|
|
|
|
sdev_printk(KERN_INFO, sdev, "%s: attached to %s path\n",
|
|
|
|
HP_SW_NAME, h->path_state == HP_SW_PATH_ACTIVE?
|
|
|
|
"active":"passive");
|
2015-08-27 12:16:59 +00:00
|
|
|
|
|
|
|
sdev->handler_data = h;
|
2017-09-20 07:18:51 +00:00
|
|
|
return SCSI_DH_OK;
|
2008-07-17 23:53:09 +00:00
|
|
|
failed:
|
2014-09-14 02:59:51 +00:00
|
|
|
kfree(h);
|
2017-09-20 07:18:51 +00:00
|
|
|
return ret;
|
2008-07-17 23:52:51 +00:00
|
|
|
}
|
2008-05-01 21:49:59 +00:00
|
|
|
|
2008-07-17 23:52:51 +00:00
|
|
|
static void hp_sw_bus_detach( struct scsi_device *sdev )
|
|
|
|
{
|
2015-08-27 12:16:59 +00:00
|
|
|
kfree(sdev->handler_data);
|
|
|
|
sdev->handler_data = NULL;
|
2008-05-01 21:49:59 +00:00
|
|
|
}
|
|
|
|
|
2014-09-14 18:08:21 +00:00
|
|
|
static struct scsi_device_handler hp_sw_dh = {
|
|
|
|
.name = HP_SW_NAME,
|
|
|
|
.module = THIS_MODULE,
|
|
|
|
.attach = hp_sw_bus_attach,
|
|
|
|
.detach = hp_sw_bus_detach,
|
|
|
|
.activate = hp_sw_activate,
|
|
|
|
.prep_fn = hp_sw_prep_fn,
|
|
|
|
};
|
|
|
|
|
2008-05-01 21:49:59 +00:00
|
|
|
static int __init hp_sw_init(void)
|
|
|
|
{
|
|
|
|
return scsi_register_device_handler(&hp_sw_dh);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit hp_sw_exit(void)
|
|
|
|
{
|
|
|
|
scsi_unregister_device_handler(&hp_sw_dh);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(hp_sw_init);
|
|
|
|
module_exit(hp_sw_exit);
|
|
|
|
|
2008-07-17 23:53:09 +00:00
|
|
|
MODULE_DESCRIPTION("HP Active/Passive driver");
|
2008-05-01 21:49:59 +00:00
|
|
|
MODULE_AUTHOR("Mike Christie <michaelc@cs.wisc.edu");
|
|
|
|
MODULE_LICENSE("GPL");
|