2007-04-27 21:01:28 +07:00
|
|
|
/*
|
2012-07-20 16:15:04 +07:00
|
|
|
* Copyright IBM Corp. 1999, 2010
|
2007-04-27 21:01:28 +07:00
|
|
|
* Author(s): Cornelia Huck (cornelia.huck@de.ibm.com)
|
|
|
|
* Arnd Bergmann (arndb@de.ibm.com)
|
|
|
|
* Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/bug.h>
|
|
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <linux/spinlock.h>
|
2011-07-30 14:25:15 +07:00
|
|
|
#include <linux/export.h>
|
|
|
|
#include <linux/sched.h>
|
2007-04-27 21:01:31 +07:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/jiffies.h>
|
|
|
|
#include <linux/wait.h>
|
|
|
|
#include <linux/mutex.h>
|
2007-10-12 21:11:19 +07:00
|
|
|
#include <linux/errno.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 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2007-04-27 21:01:31 +07:00
|
|
|
#include <asm/chpid.h>
|
|
|
|
#include <asm/sclp.h>
|
2009-03-26 21:24:01 +07:00
|
|
|
#include <asm/crw.h>
|
2007-04-27 21:01:28 +07:00
|
|
|
|
|
|
|
#include "cio.h"
|
|
|
|
#include "css.h"
|
|
|
|
#include "ioasm.h"
|
|
|
|
#include "cio_debug.h"
|
|
|
|
#include "chp.h"
|
|
|
|
|
|
|
|
#define to_channelpath(device) container_of(device, struct channel_path, dev)
|
2007-04-27 21:01:31 +07:00
|
|
|
#define CHP_INFO_UPDATE_INTERVAL 1*HZ
|
|
|
|
|
|
|
|
enum cfg_task_t {
|
|
|
|
cfg_none,
|
|
|
|
cfg_configure,
|
|
|
|
cfg_deconfigure
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Map for pending configure tasks. */
|
|
|
|
static enum cfg_task_t chp_cfg_task[__MAX_CSSID + 1][__MAX_CHPID + 1];
|
|
|
|
static DEFINE_MUTEX(cfg_lock);
|
|
|
|
static int cfg_busy;
|
|
|
|
|
|
|
|
/* Map for channel-path status. */
|
|
|
|
static struct sclp_chp_info chp_info;
|
|
|
|
static DEFINE_MUTEX(info_lock);
|
|
|
|
|
|
|
|
/* Time after which channel-path status may be outdated. */
|
|
|
|
static unsigned long chp_info_expires;
|
|
|
|
|
|
|
|
/* Workqueue to perform pending configure tasks. */
|
|
|
|
static struct workqueue_struct *chp_wq;
|
|
|
|
static struct work_struct cfg_work;
|
|
|
|
|
|
|
|
/* Wait queue for configure completion events. */
|
|
|
|
static wait_queue_head_t cfg_wait_queue;
|
2007-04-27 21:01:28 +07:00
|
|
|
|
|
|
|
/* Set vary state for given chpid. */
|
|
|
|
static void set_chp_logically_online(struct chp_id chpid, int onoff)
|
|
|
|
{
|
|
|
|
chpid_to_chp(chpid)->state = onoff;
|
|
|
|
}
|
|
|
|
|
tree-wide: fix assorted typos all over the place
That is "success", "unknown", "through", "performance", "[re|un]mapping"
, "access", "default", "reasonable", "[con]currently", "temperature"
, "channel", "[un]used", "application", "example","hierarchy", "therefore"
, "[over|under]flow", "contiguous", "threshold", "enough" and others.
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-11-14 22:09:05 +07:00
|
|
|
/* On success return 0 if channel-path is varied offline, 1 if it is varied
|
2007-04-27 21:01:28 +07:00
|
|
|
* online. Return -ENODEV if channel-path is not registered. */
|
|
|
|
int chp_get_status(struct chp_id chpid)
|
|
|
|
{
|
|
|
|
return (chpid_to_chp(chpid) ? chpid_to_chp(chpid)->state : -ENODEV);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* chp_get_sch_opm - return opm for subchannel
|
|
|
|
* @sch: subchannel
|
|
|
|
*
|
|
|
|
* Calculate and return the operational path mask (opm) based on the chpids
|
|
|
|
* used by the subchannel and the status of the associated channel-paths.
|
|
|
|
*/
|
|
|
|
u8 chp_get_sch_opm(struct subchannel *sch)
|
|
|
|
{
|
|
|
|
struct chp_id chpid;
|
|
|
|
int opm;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
opm = 0;
|
|
|
|
chp_id_init(&chpid);
|
2007-10-12 21:11:19 +07:00
|
|
|
for (i = 0; i < 8; i++) {
|
2007-04-27 21:01:28 +07:00
|
|
|
opm <<= 1;
|
|
|
|
chpid.id = sch->schib.pmcw.chpid[i];
|
|
|
|
if (chp_get_status(chpid) != 0)
|
|
|
|
opm |= 1;
|
|
|
|
}
|
|
|
|
return opm;
|
|
|
|
}
|
2008-07-14 14:58:47 +07:00
|
|
|
EXPORT_SYMBOL_GPL(chp_get_sch_opm);
|
2007-04-27 21:01:28 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* chp_is_registered - check if a channel-path is registered
|
|
|
|
* @chpid: channel-path ID
|
|
|
|
*
|
|
|
|
* Return non-zero if a channel-path with the given chpid is registered,
|
|
|
|
* zero otherwise.
|
|
|
|
*/
|
|
|
|
int chp_is_registered(struct chp_id chpid)
|
|
|
|
{
|
|
|
|
return chpid_to_chp(chpid) != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function: s390_vary_chpid
|
|
|
|
* Varies the specified chpid online or offline
|
|
|
|
*/
|
|
|
|
static int s390_vary_chpid(struct chp_id chpid, int on)
|
|
|
|
{
|
|
|
|
char dbf_text[15];
|
|
|
|
int status;
|
|
|
|
|
|
|
|
sprintf(dbf_text, on?"varyon%x.%02x":"varyoff%x.%02x", chpid.cssid,
|
|
|
|
chpid.id);
|
2007-10-12 21:11:19 +07:00
|
|
|
CIO_TRACE_EVENT(2, dbf_text);
|
2007-04-27 21:01:28 +07:00
|
|
|
|
|
|
|
status = chp_get_status(chpid);
|
2008-07-14 14:59:22 +07:00
|
|
|
if (!on && !status)
|
|
|
|
return 0;
|
2007-04-27 21:01:28 +07:00
|
|
|
|
|
|
|
set_chp_logically_online(chpid, on);
|
|
|
|
chsc_chp_vary(chpid, on);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Channel measurement related functions
|
|
|
|
*/
|
2010-05-13 08:28:57 +07:00
|
|
|
static ssize_t chp_measurement_chars_read(struct file *filp,
|
|
|
|
struct kobject *kobj,
|
2007-06-09 12:57:22 +07:00
|
|
|
struct bin_attribute *bin_attr,
|
|
|
|
char *buf, loff_t off, size_t count)
|
2007-04-27 21:01:28 +07:00
|
|
|
{
|
|
|
|
struct channel_path *chp;
|
2007-10-12 21:11:35 +07:00
|
|
|
struct device *device;
|
2007-04-27 21:01:28 +07:00
|
|
|
|
2007-10-12 21:11:35 +07:00
|
|
|
device = container_of(kobj, struct device, kobj);
|
|
|
|
chp = to_channelpath(device);
|
2007-04-27 21:01:28 +07:00
|
|
|
if (!chp->cmg_chars)
|
|
|
|
return 0;
|
|
|
|
|
2008-07-14 14:59:15 +07:00
|
|
|
return memory_read_from_buffer(buf, count, &off,
|
|
|
|
chp->cmg_chars, sizeof(struct cmg_chars));
|
2007-04-27 21:01:28 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct bin_attribute chp_measurement_chars_attr = {
|
|
|
|
.attr = {
|
|
|
|
.name = "measurement_chars",
|
|
|
|
.mode = S_IRUSR,
|
|
|
|
},
|
|
|
|
.size = sizeof(struct cmg_chars),
|
|
|
|
.read = chp_measurement_chars_read,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void chp_measurement_copy_block(struct cmg_entry *buf,
|
|
|
|
struct channel_subsystem *css,
|
|
|
|
struct chp_id chpid)
|
|
|
|
{
|
|
|
|
void *area;
|
|
|
|
struct cmg_entry *entry, reference_buf;
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
if (chpid.id < 128) {
|
|
|
|
area = css->cub_addr1;
|
|
|
|
idx = chpid.id;
|
|
|
|
} else {
|
|
|
|
area = css->cub_addr2;
|
|
|
|
idx = chpid.id - 128;
|
|
|
|
}
|
|
|
|
entry = area + (idx * sizeof(struct cmg_entry));
|
|
|
|
do {
|
|
|
|
memcpy(buf, entry, sizeof(*entry));
|
|
|
|
memcpy(&reference_buf, entry, sizeof(*entry));
|
|
|
|
} while (reference_buf.values[0] != buf->values[0]);
|
|
|
|
}
|
|
|
|
|
2010-05-13 08:28:57 +07:00
|
|
|
static ssize_t chp_measurement_read(struct file *filp, struct kobject *kobj,
|
2007-06-09 12:57:22 +07:00
|
|
|
struct bin_attribute *bin_attr,
|
|
|
|
char *buf, loff_t off, size_t count)
|
2007-04-27 21:01:28 +07:00
|
|
|
{
|
|
|
|
struct channel_path *chp;
|
|
|
|
struct channel_subsystem *css;
|
2007-10-12 21:11:35 +07:00
|
|
|
struct device *device;
|
2007-04-27 21:01:28 +07:00
|
|
|
unsigned int size;
|
|
|
|
|
2007-10-12 21:11:35 +07:00
|
|
|
device = container_of(kobj, struct device, kobj);
|
|
|
|
chp = to_channelpath(device);
|
2007-04-27 21:01:28 +07:00
|
|
|
css = to_css(chp->dev.parent);
|
|
|
|
|
|
|
|
size = sizeof(struct cmg_entry);
|
|
|
|
|
|
|
|
/* Only allow single reads. */
|
|
|
|
if (off || count < size)
|
|
|
|
return 0;
|
|
|
|
chp_measurement_copy_block((struct cmg_entry *)buf, css, chp->chpid);
|
|
|
|
count = size;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct bin_attribute chp_measurement_attr = {
|
|
|
|
.attr = {
|
|
|
|
.name = "measurement",
|
|
|
|
.mode = S_IRUSR,
|
|
|
|
},
|
|
|
|
.size = sizeof(struct cmg_entry),
|
|
|
|
.read = chp_measurement_read,
|
|
|
|
};
|
|
|
|
|
|
|
|
void chp_remove_cmg_attr(struct channel_path *chp)
|
|
|
|
{
|
|
|
|
device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
|
|
|
|
device_remove_bin_file(&chp->dev, &chp_measurement_attr);
|
|
|
|
}
|
|
|
|
|
|
|
|
int chp_add_cmg_attr(struct channel_path *chp)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = device_create_bin_file(&chp->dev, &chp_measurement_chars_attr);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
ret = device_create_bin_file(&chp->dev, &chp_measurement_attr);
|
|
|
|
if (ret)
|
|
|
|
device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Files for the channel path entries.
|
|
|
|
*/
|
|
|
|
static ssize_t chp_status_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
2007-10-22 17:52:40 +07:00
|
|
|
struct channel_path *chp = to_channelpath(dev);
|
2010-10-25 21:10:27 +07:00
|
|
|
int status;
|
2007-04-27 21:01:28 +07:00
|
|
|
|
2010-10-25 21:10:27 +07:00
|
|
|
mutex_lock(&chp->lock);
|
|
|
|
status = chp->state;
|
|
|
|
mutex_unlock(&chp->lock);
|
|
|
|
|
|
|
|
return status ? sprintf(buf, "online\n") : sprintf(buf, "offline\n");
|
2007-04-27 21:01:28 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t chp_status_write(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
2007-10-22 17:52:40 +07:00
|
|
|
struct channel_path *cp = to_channelpath(dev);
|
2007-04-27 21:01:28 +07:00
|
|
|
char cmd[10];
|
|
|
|
int num_args;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
num_args = sscanf(buf, "%5s", cmd);
|
|
|
|
if (!num_args)
|
|
|
|
return count;
|
|
|
|
|
2010-10-25 21:10:27 +07:00
|
|
|
if (!strnicmp(cmd, "on", 2) || !strcmp(cmd, "1")) {
|
|
|
|
mutex_lock(&cp->lock);
|
2007-04-27 21:01:28 +07:00
|
|
|
error = s390_vary_chpid(cp->chpid, 1);
|
2010-10-25 21:10:27 +07:00
|
|
|
mutex_unlock(&cp->lock);
|
|
|
|
} else if (!strnicmp(cmd, "off", 3) || !strcmp(cmd, "0")) {
|
|
|
|
mutex_lock(&cp->lock);
|
2007-04-27 21:01:28 +07:00
|
|
|
error = s390_vary_chpid(cp->chpid, 0);
|
2010-10-25 21:10:27 +07:00
|
|
|
mutex_unlock(&cp->lock);
|
|
|
|
} else
|
2007-04-27 21:01:28 +07:00
|
|
|
error = -EINVAL;
|
|
|
|
|
|
|
|
return error < 0 ? error : count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(status, 0644, chp_status_show, chp_status_write);
|
|
|
|
|
2007-04-27 21:01:31 +07:00
|
|
|
static ssize_t chp_configure_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct channel_path *cp;
|
|
|
|
int status;
|
|
|
|
|
2007-10-22 17:52:40 +07:00
|
|
|
cp = to_channelpath(dev);
|
2007-04-27 21:01:31 +07:00
|
|
|
status = chp_info_get_status(cp->chpid);
|
|
|
|
if (status < 0)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%d\n", status);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cfg_wait_idle(void);
|
|
|
|
|
|
|
|
static ssize_t chp_configure_write(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct channel_path *cp;
|
|
|
|
int val;
|
|
|
|
char delim;
|
|
|
|
|
|
|
|
if (sscanf(buf, "%d %c", &val, &delim) != 1)
|
|
|
|
return -EINVAL;
|
|
|
|
if (val != 0 && val != 1)
|
|
|
|
return -EINVAL;
|
2007-10-22 17:52:40 +07:00
|
|
|
cp = to_channelpath(dev);
|
2007-04-27 21:01:31 +07:00
|
|
|
chp_cfg_schedule(cp->chpid, val);
|
|
|
|
cfg_wait_idle();
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(configure, 0644, chp_configure_show, chp_configure_write);
|
|
|
|
|
2007-04-27 21:01:28 +07:00
|
|
|
static ssize_t chp_type_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
2007-10-22 17:52:40 +07:00
|
|
|
struct channel_path *chp = to_channelpath(dev);
|
2010-10-25 21:10:27 +07:00
|
|
|
u8 type;
|
2007-04-27 21:01:28 +07:00
|
|
|
|
2010-10-25 21:10:27 +07:00
|
|
|
mutex_lock(&chp->lock);
|
|
|
|
type = chp->desc.desc;
|
|
|
|
mutex_unlock(&chp->lock);
|
|
|
|
return sprintf(buf, "%x\n", type);
|
2007-04-27 21:01:28 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(type, 0444, chp_type_show, NULL);
|
|
|
|
|
|
|
|
static ssize_t chp_cmg_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct channel_path *chp = to_channelpath(dev);
|
|
|
|
|
|
|
|
if (!chp)
|
|
|
|
return 0;
|
|
|
|
if (chp->cmg == -1) /* channel measurements not available */
|
|
|
|
return sprintf(buf, "unknown\n");
|
|
|
|
return sprintf(buf, "%x\n", chp->cmg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(cmg, 0444, chp_cmg_show, NULL);
|
|
|
|
|
|
|
|
static ssize_t chp_shared_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct channel_path *chp = to_channelpath(dev);
|
|
|
|
|
|
|
|
if (!chp)
|
|
|
|
return 0;
|
|
|
|
if (chp->shared == -1) /* channel measurements not available */
|
|
|
|
return sprintf(buf, "unknown\n");
|
|
|
|
return sprintf(buf, "%x\n", chp->shared);
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(shared, 0444, chp_shared_show, NULL);
|
|
|
|
|
2013-05-15 18:43:29 +07:00
|
|
|
static ssize_t chp_chid_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct channel_path *chp = to_channelpath(dev);
|
|
|
|
ssize_t rc;
|
|
|
|
|
|
|
|
mutex_lock(&chp->lock);
|
|
|
|
if (chp->desc_fmt1.flags & 0x10)
|
|
|
|
rc = sprintf(buf, "%04x\n", chp->desc_fmt1.chid);
|
|
|
|
else
|
|
|
|
rc = 0;
|
|
|
|
mutex_unlock(&chp->lock);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR(chid, 0444, chp_chid_show, NULL);
|
|
|
|
|
|
|
|
static ssize_t chp_chid_external_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
struct channel_path *chp = to_channelpath(dev);
|
|
|
|
ssize_t rc;
|
|
|
|
|
|
|
|
mutex_lock(&chp->lock);
|
|
|
|
if (chp->desc_fmt1.flags & 0x10)
|
|
|
|
rc = sprintf(buf, "%x\n", chp->desc_fmt1.flags & 0x8 ? 1 : 0);
|
|
|
|
else
|
|
|
|
rc = 0;
|
|
|
|
mutex_unlock(&chp->lock);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR(chid_external, 0444, chp_chid_external_show, NULL);
|
|
|
|
|
2007-10-12 21:11:19 +07:00
|
|
|
static struct attribute *chp_attrs[] = {
|
2007-04-27 21:01:28 +07:00
|
|
|
&dev_attr_status.attr,
|
2007-04-27 21:01:31 +07:00
|
|
|
&dev_attr_configure.attr,
|
2007-04-27 21:01:28 +07:00
|
|
|
&dev_attr_type.attr,
|
|
|
|
&dev_attr_cmg.attr,
|
|
|
|
&dev_attr_shared.attr,
|
2013-05-15 18:43:29 +07:00
|
|
|
&dev_attr_chid.attr,
|
|
|
|
&dev_attr_chid_external.attr,
|
2007-04-27 21:01:28 +07:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
static struct attribute_group chp_attr_group = {
|
|
|
|
.attrs = chp_attrs,
|
|
|
|
};
|
2012-06-05 00:29:41 +07:00
|
|
|
static const struct attribute_group *chp_attr_groups[] = {
|
|
|
|
&chp_attr_group,
|
|
|
|
NULL,
|
|
|
|
};
|
2007-04-27 21:01:28 +07:00
|
|
|
|
|
|
|
static void chp_release(struct device *dev)
|
|
|
|
{
|
|
|
|
struct channel_path *cp;
|
|
|
|
|
2007-10-22 17:52:40 +07:00
|
|
|
cp = to_channelpath(dev);
|
2007-04-27 21:01:28 +07:00
|
|
|
kfree(cp);
|
|
|
|
}
|
|
|
|
|
2013-03-11 18:58:18 +07:00
|
|
|
/**
|
|
|
|
* chp_update_desc - update channel-path description
|
|
|
|
* @chp - channel-path
|
|
|
|
*
|
|
|
|
* Update the channel-path description of the specified channel-path.
|
|
|
|
* Return zero on success, non-zero otherwise.
|
|
|
|
*/
|
|
|
|
int chp_update_desc(struct channel_path *chp)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = chsc_determine_base_channel_path_desc(chp->chpid, &chp->desc);
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
rc = chsc_determine_fmt1_channel_path_desc(chp->chpid, &chp->desc_fmt1);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-04-27 21:01:28 +07:00
|
|
|
/**
|
|
|
|
* chp_new - register a new channel-path
|
|
|
|
* @chpid - channel-path ID
|
|
|
|
*
|
|
|
|
* Create and register data structure representing new channel-path. Return
|
|
|
|
* zero on success, non-zero otherwise.
|
|
|
|
*/
|
|
|
|
int chp_new(struct chp_id chpid)
|
|
|
|
{
|
|
|
|
struct channel_path *chp;
|
|
|
|
int ret;
|
|
|
|
|
2007-04-27 21:01:31 +07:00
|
|
|
if (chp_is_registered(chpid))
|
|
|
|
return 0;
|
2007-04-27 21:01:28 +07:00
|
|
|
chp = kzalloc(sizeof(struct channel_path), GFP_KERNEL);
|
|
|
|
if (!chp)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
/* fill in status, etc. */
|
|
|
|
chp->chpid = chpid;
|
|
|
|
chp->state = 1;
|
2007-10-12 21:11:13 +07:00
|
|
|
chp->dev.parent = &channel_subsystems[chpid.cssid]->device;
|
2012-06-05 00:29:41 +07:00
|
|
|
chp->dev.groups = chp_attr_groups;
|
2007-04-27 21:01:28 +07:00
|
|
|
chp->dev.release = chp_release;
|
2010-10-25 21:10:27 +07:00
|
|
|
mutex_init(&chp->lock);
|
2007-04-27 21:01:28 +07:00
|
|
|
|
|
|
|
/* Obtain channel path description and fill it in. */
|
2013-03-11 18:58:18 +07:00
|
|
|
ret = chp_update_desc(chp);
|
2007-04-27 21:01:28 +07:00
|
|
|
if (ret)
|
|
|
|
goto out_free;
|
2007-04-27 21:01:29 +07:00
|
|
|
if ((chp->desc.flags & 0x80) == 0) {
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto out_free;
|
|
|
|
}
|
2007-04-27 21:01:28 +07:00
|
|
|
/* Get channel-measurement characteristics. */
|
2008-07-14 14:58:57 +07:00
|
|
|
if (css_chsc_characteristics.scmc && css_chsc_characteristics.secm) {
|
2007-04-27 21:01:28 +07:00
|
|
|
ret = chsc_get_channel_measurement_chars(chp);
|
|
|
|
if (ret)
|
|
|
|
goto out_free;
|
|
|
|
} else {
|
|
|
|
chp->cmg = -1;
|
|
|
|
}
|
2009-10-06 15:33:59 +07:00
|
|
|
dev_set_name(&chp->dev, "chp%x.%02x", chpid.cssid, chpid.id);
|
2007-04-27 21:01:28 +07:00
|
|
|
|
|
|
|
/* make it known to the system */
|
|
|
|
ret = device_register(&chp->dev);
|
|
|
|
if (ret) {
|
2007-07-27 17:29:19 +07:00
|
|
|
CIO_MSG_EVENT(0, "Could not register chp%x.%02x: %d\n",
|
|
|
|
chpid.cssid, chpid.id, ret);
|
2009-09-11 15:28:38 +07:00
|
|
|
put_device(&chp->dev);
|
|
|
|
goto out;
|
2007-04-27 21:01:28 +07:00
|
|
|
}
|
2007-10-12 21:11:13 +07:00
|
|
|
mutex_lock(&channel_subsystems[chpid.cssid]->mutex);
|
|
|
|
if (channel_subsystems[chpid.cssid]->cm_enabled) {
|
2007-04-27 21:01:28 +07:00
|
|
|
ret = chp_add_cmg_attr(chp);
|
|
|
|
if (ret) {
|
|
|
|
device_unregister(&chp->dev);
|
2007-10-12 21:11:13 +07:00
|
|
|
mutex_unlock(&channel_subsystems[chpid.cssid]->mutex);
|
2008-09-09 17:38:57 +07:00
|
|
|
goto out;
|
2007-04-27 21:01:28 +07:00
|
|
|
}
|
|
|
|
}
|
2007-10-12 21:11:13 +07:00
|
|
|
channel_subsystems[chpid.cssid]->chps[chpid.id] = chp;
|
|
|
|
mutex_unlock(&channel_subsystems[chpid.cssid]->mutex);
|
2008-09-09 17:38:57 +07:00
|
|
|
goto out;
|
2007-04-27 21:01:28 +07:00
|
|
|
out_free:
|
|
|
|
kfree(chp);
|
2008-09-09 17:38:57 +07:00
|
|
|
out:
|
2007-04-27 21:01:28 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* chp_get_chp_desc - return newly allocated channel-path description
|
|
|
|
* @chpid: channel-path ID
|
|
|
|
*
|
|
|
|
* On success return a newly allocated copy of the channel-path description
|
|
|
|
* data associated with the given channel-path ID. Return %NULL on error.
|
|
|
|
*/
|
|
|
|
void *chp_get_chp_desc(struct chp_id chpid)
|
|
|
|
{
|
|
|
|
struct channel_path *chp;
|
|
|
|
struct channel_path_desc *desc;
|
|
|
|
|
|
|
|
chp = chpid_to_chp(chpid);
|
|
|
|
if (!chp)
|
|
|
|
return NULL;
|
|
|
|
desc = kmalloc(sizeof(struct channel_path_desc), GFP_KERNEL);
|
|
|
|
if (!desc)
|
|
|
|
return NULL;
|
2010-10-25 21:10:27 +07:00
|
|
|
|
|
|
|
mutex_lock(&chp->lock);
|
2007-04-27 21:01:28 +07:00
|
|
|
memcpy(desc, &chp->desc, sizeof(struct channel_path_desc));
|
2010-10-25 21:10:27 +07:00
|
|
|
mutex_unlock(&chp->lock);
|
2007-04-27 21:01:28 +07:00
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* chp_process_crw - process channel-path status change
|
2008-07-14 14:58:46 +07:00
|
|
|
* @crw0: channel report-word to handler
|
|
|
|
* @crw1: second channel-report word (always NULL)
|
|
|
|
* @overflow: crw overflow indication
|
2007-04-27 21:01:28 +07:00
|
|
|
*
|
|
|
|
* Handle channel-report-words indicating that the status of a channel-path
|
|
|
|
* has changed.
|
|
|
|
*/
|
2008-07-14 14:58:46 +07:00
|
|
|
static void chp_process_crw(struct crw *crw0, struct crw *crw1,
|
|
|
|
int overflow)
|
2007-04-27 21:01:28 +07:00
|
|
|
{
|
|
|
|
struct chp_id chpid;
|
|
|
|
|
2008-07-14 14:58:46 +07:00
|
|
|
if (overflow) {
|
|
|
|
css_schedule_eval_all();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
CIO_CRW_EVENT(2, "CRW reports slct=%d, oflw=%d, "
|
|
|
|
"chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n",
|
|
|
|
crw0->slct, crw0->oflw, crw0->chn, crw0->rsc, crw0->anc,
|
|
|
|
crw0->erc, crw0->rsid);
|
|
|
|
/*
|
|
|
|
* Check for solicited machine checks. These are
|
|
|
|
* created by reset channel path and need not be
|
|
|
|
* handled here.
|
|
|
|
*/
|
|
|
|
if (crw0->slct) {
|
|
|
|
CIO_CRW_EVENT(2, "solicited machine check for "
|
|
|
|
"channel path %02X\n", crw0->rsid);
|
|
|
|
return;
|
|
|
|
}
|
2007-04-27 21:01:28 +07:00
|
|
|
chp_id_init(&chpid);
|
2008-07-14 14:58:46 +07:00
|
|
|
chpid.id = crw0->rsid;
|
|
|
|
switch (crw0->erc) {
|
|
|
|
case CRW_ERC_IPARM: /* Path has come. */
|
2007-04-27 21:01:28 +07:00
|
|
|
if (!chp_is_registered(chpid))
|
|
|
|
chp_new(chpid);
|
2007-04-27 21:01:34 +07:00
|
|
|
chsc_chp_online(chpid);
|
2008-07-14 14:58:46 +07:00
|
|
|
break;
|
|
|
|
case CRW_ERC_PERRI: /* Path has gone. */
|
|
|
|
case CRW_ERC_PERRN:
|
2007-04-27 21:01:28 +07:00
|
|
|
chsc_chp_offline(chpid);
|
2008-07-14 14:58:46 +07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CIO_CRW_EVENT(2, "Don't know how to handle erc=%x\n",
|
|
|
|
crw0->erc);
|
|
|
|
}
|
2007-04-27 21:01:28 +07:00
|
|
|
}
|
2007-04-27 21:01:31 +07:00
|
|
|
|
2008-07-14 14:59:02 +07:00
|
|
|
int chp_ssd_get_mask(struct chsc_ssd_info *ssd, struct chp_link *link)
|
2008-07-14 14:58:45 +07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int mask;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
mask = 0x80 >> i;
|
|
|
|
if (!(ssd->path_mask & mask))
|
|
|
|
continue;
|
2008-07-14 14:59:02 +07:00
|
|
|
if (!chp_id_is_equal(&ssd->chpid[i], &link->chpid))
|
2008-07-14 14:58:45 +07:00
|
|
|
continue;
|
|
|
|
if ((ssd->fla_valid_mask & mask) &&
|
2008-07-14 14:59:02 +07:00
|
|
|
((ssd->fla[i] & link->fla_mask) != link->fla))
|
2008-07-14 14:58:45 +07:00
|
|
|
continue;
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(chp_ssd_get_mask);
|
|
|
|
|
2007-04-27 21:01:31 +07:00
|
|
|
static inline int info_bit_num(struct chp_id id)
|
|
|
|
{
|
|
|
|
return id.id + id.cssid * (__MAX_CHPID + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Force chp_info refresh on next call to info_validate(). */
|
|
|
|
static void info_expire(void)
|
|
|
|
{
|
|
|
|
mutex_lock(&info_lock);
|
|
|
|
chp_info_expires = jiffies - 1;
|
|
|
|
mutex_unlock(&info_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure that chp_info is up-to-date. */
|
|
|
|
static int info_update(void)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
mutex_lock(&info_lock);
|
|
|
|
rc = 0;
|
|
|
|
if (time_after(jiffies, chp_info_expires)) {
|
|
|
|
/* Data is too old, update. */
|
|
|
|
rc = sclp_chp_read_info(&chp_info);
|
|
|
|
chp_info_expires = jiffies + CHP_INFO_UPDATE_INTERVAL ;
|
|
|
|
}
|
|
|
|
mutex_unlock(&info_lock);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* chp_info_get_status - retrieve configure status of a channel-path
|
|
|
|
* @chpid: channel-path ID
|
|
|
|
*
|
|
|
|
* On success, return 0 for standby, 1 for configured, 2 for reserved,
|
|
|
|
* 3 for not recognized. Return negative error code on error.
|
|
|
|
*/
|
|
|
|
int chp_info_get_status(struct chp_id chpid)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
int bit;
|
|
|
|
|
|
|
|
rc = info_update();
|
|
|
|
if (rc)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
bit = info_bit_num(chpid);
|
|
|
|
mutex_lock(&info_lock);
|
|
|
|
if (!chp_test_bit(chp_info.recognized, bit))
|
|
|
|
rc = CHP_STATUS_NOT_RECOGNIZED;
|
|
|
|
else if (chp_test_bit(chp_info.configured, bit))
|
|
|
|
rc = CHP_STATUS_CONFIGURED;
|
|
|
|
else if (chp_test_bit(chp_info.standby, bit))
|
|
|
|
rc = CHP_STATUS_STANDBY;
|
|
|
|
else
|
|
|
|
rc = CHP_STATUS_RESERVED;
|
|
|
|
mutex_unlock(&info_lock);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return configure task for chpid. */
|
|
|
|
static enum cfg_task_t cfg_get_task(struct chp_id chpid)
|
|
|
|
{
|
|
|
|
return chp_cfg_task[chpid.cssid][chpid.id];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set configure task for chpid. */
|
|
|
|
static void cfg_set_task(struct chp_id chpid, enum cfg_task_t cfg)
|
|
|
|
{
|
|
|
|
chp_cfg_task[chpid.cssid][chpid.id] = cfg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Perform one configure/deconfigure request. Reschedule work function until
|
|
|
|
* last request. */
|
|
|
|
static void cfg_func(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct chp_id chpid;
|
|
|
|
enum cfg_task_t t;
|
2008-07-14 14:59:04 +07:00
|
|
|
int rc;
|
2007-04-27 21:01:31 +07:00
|
|
|
|
|
|
|
mutex_lock(&cfg_lock);
|
|
|
|
t = cfg_none;
|
|
|
|
chp_id_for_each(&chpid) {
|
|
|
|
t = cfg_get_task(chpid);
|
|
|
|
if (t != cfg_none) {
|
|
|
|
cfg_set_task(chpid, cfg_none);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mutex_unlock(&cfg_lock);
|
|
|
|
|
|
|
|
switch (t) {
|
|
|
|
case cfg_configure:
|
2008-07-14 14:59:04 +07:00
|
|
|
rc = sclp_chp_configure(chpid);
|
|
|
|
if (rc)
|
|
|
|
CIO_MSG_EVENT(2, "chp: sclp_chp_configure(%x.%02x)="
|
|
|
|
"%d\n", chpid.cssid, chpid.id, rc);
|
|
|
|
else {
|
|
|
|
info_expire();
|
|
|
|
chsc_chp_online(chpid);
|
|
|
|
}
|
2007-04-27 21:01:31 +07:00
|
|
|
break;
|
|
|
|
case cfg_deconfigure:
|
2008-07-14 14:59:04 +07:00
|
|
|
rc = sclp_chp_deconfigure(chpid);
|
|
|
|
if (rc)
|
|
|
|
CIO_MSG_EVENT(2, "chp: sclp_chp_deconfigure(%x.%02x)="
|
|
|
|
"%d\n", chpid.cssid, chpid.id, rc);
|
|
|
|
else {
|
|
|
|
info_expire();
|
|
|
|
chsc_chp_offline(chpid);
|
|
|
|
}
|
2007-04-27 21:01:31 +07:00
|
|
|
break;
|
|
|
|
case cfg_none:
|
|
|
|
/* Get updated information after last change. */
|
|
|
|
info_update();
|
|
|
|
mutex_lock(&cfg_lock);
|
|
|
|
cfg_busy = 0;
|
|
|
|
mutex_unlock(&cfg_lock);
|
|
|
|
wake_up_interruptible(&cfg_wait_queue);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
queue_work(chp_wq, &cfg_work);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* chp_cfg_schedule - schedule chpid configuration request
|
|
|
|
* @chpid - channel-path ID
|
|
|
|
* @configure - Non-zero for configure, zero for deconfigure
|
|
|
|
*
|
|
|
|
* Schedule a channel-path configuration/deconfiguration request.
|
|
|
|
*/
|
|
|
|
void chp_cfg_schedule(struct chp_id chpid, int configure)
|
|
|
|
{
|
|
|
|
CIO_MSG_EVENT(2, "chp_cfg_sched%x.%02x=%d\n", chpid.cssid, chpid.id,
|
|
|
|
configure);
|
|
|
|
mutex_lock(&cfg_lock);
|
|
|
|
cfg_set_task(chpid, configure ? cfg_configure : cfg_deconfigure);
|
|
|
|
cfg_busy = 1;
|
|
|
|
mutex_unlock(&cfg_lock);
|
|
|
|
queue_work(chp_wq, &cfg_work);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* chp_cfg_cancel_deconfigure - cancel chpid deconfiguration request
|
|
|
|
* @chpid - channel-path ID
|
|
|
|
*
|
|
|
|
* Cancel an active channel-path deconfiguration request if it has not yet
|
|
|
|
* been performed.
|
|
|
|
*/
|
|
|
|
void chp_cfg_cancel_deconfigure(struct chp_id chpid)
|
|
|
|
{
|
|
|
|
CIO_MSG_EVENT(2, "chp_cfg_cancel:%x.%02x\n", chpid.cssid, chpid.id);
|
|
|
|
mutex_lock(&cfg_lock);
|
|
|
|
if (cfg_get_task(chpid) == cfg_deconfigure)
|
|
|
|
cfg_set_task(chpid, cfg_none);
|
|
|
|
mutex_unlock(&cfg_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cfg_wait_idle(void)
|
|
|
|
{
|
|
|
|
if (wait_event_interruptible(cfg_wait_queue, !cfg_busy))
|
|
|
|
return -ERESTARTSYS;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init chp_init(void)
|
|
|
|
{
|
|
|
|
struct chp_id chpid;
|
2008-07-14 14:58:46 +07:00
|
|
|
int ret;
|
2007-04-27 21:01:31 +07:00
|
|
|
|
2009-03-26 21:24:01 +07:00
|
|
|
ret = crw_register_handler(CRW_RSC_CPATH, chp_process_crw);
|
2008-07-14 14:58:46 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2007-04-27 21:01:31 +07:00
|
|
|
chp_wq = create_singlethread_workqueue("cio_chp");
|
2008-07-14 14:58:46 +07:00
|
|
|
if (!chp_wq) {
|
2009-03-26 21:24:01 +07:00
|
|
|
crw_unregister_handler(CRW_RSC_CPATH);
|
2007-04-27 21:01:31 +07:00
|
|
|
return -ENOMEM;
|
2008-07-14 14:58:46 +07:00
|
|
|
}
|
2007-04-27 21:01:31 +07:00
|
|
|
INIT_WORK(&cfg_work, cfg_func);
|
|
|
|
init_waitqueue_head(&cfg_wait_queue);
|
|
|
|
if (info_update())
|
|
|
|
return 0;
|
|
|
|
/* Register available channel-paths. */
|
|
|
|
chp_id_for_each(&chpid) {
|
|
|
|
if (chp_info_get_status(chpid) != CHP_STATUS_NOT_RECOGNIZED)
|
|
|
|
chp_new(chpid);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
subsys_initcall(chp_init);
|