Commit b279a4f5 authored by Cornelia Huck's avatar Cornelia Huck Committed by Martin Schwidefsky

[S390] cio: I/O subchannel specific fields.

Some fields may be !0 only for I/O subchannels. Add some checks
where required. Also adapt cio_enable_subchannel() to make the
caller specify the intparm, which makes it more generic.
Signed-off-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 4e8e56c6
...@@ -89,7 +89,8 @@ int chsc_get_ssd_info(struct subchannel_id schid, struct chsc_ssd_info *ssd) ...@@ -89,7 +89,8 @@ int chsc_get_ssd_info(struct subchannel_id schid, struct chsc_ssd_info *ssd)
/* Copy data */ /* Copy data */
ret = 0; ret = 0;
memset(ssd, 0, sizeof(struct chsc_ssd_info)); memset(ssd, 0, sizeof(struct chsc_ssd_info));
if ((ssd_area->st != 0) && (ssd_area->st != 2)) if ((ssd_area->st != SUBCHANNEL_TYPE_IO) &&
(ssd_area->st != SUBCHANNEL_TYPE_MSG))
goto out_free; goto out_free;
ssd->path_mask = ssd_area->path_mask; ssd->path_mask = ssd_area->path_mask;
ssd->fla_valid_mask = ssd_area->fla_valid_mask; ssd->fla_valid_mask = ssd_area->fla_valid_mask;
...@@ -158,7 +159,7 @@ s390_subchannel_remove_chpid(struct device *dev, void *data) ...@@ -158,7 +159,7 @@ s390_subchannel_remove_chpid(struct device *dev, void *data)
spin_lock_irq(sch->lock); spin_lock_irq(sch->lock);
stsch(sch->schid, &schib); stsch(sch->schid, &schib);
if (!schib.pmcw.dnv) if (!css_sch_is_valid(&schib))
goto out_unreg; goto out_unreg;
memcpy(&sch->schib, &schib, sizeof(struct schib)); memcpy(&sch->schib, &schib, sizeof(struct schib));
/* Check for single path devices. */ /* Check for single path devices. */
......
...@@ -406,8 +406,8 @@ cio_modify (struct subchannel *sch) ...@@ -406,8 +406,8 @@ cio_modify (struct subchannel *sch)
/* /*
* Enable subchannel. * Enable subchannel.
*/ */
int int cio_enable_subchannel(struct subchannel *sch, unsigned int isc,
cio_enable_subchannel (struct subchannel *sch, unsigned int isc) u32 intparm)
{ {
char dbf_txt[15]; char dbf_txt[15];
int ccode; int ccode;
...@@ -426,7 +426,7 @@ cio_enable_subchannel (struct subchannel *sch, unsigned int isc) ...@@ -426,7 +426,7 @@ cio_enable_subchannel (struct subchannel *sch, unsigned int isc)
for (retry = 5, ret = 0; retry > 0; retry--) { for (retry = 5, ret = 0; retry > 0; retry--) {
sch->schib.pmcw.ena = 1; sch->schib.pmcw.ena = 1;
sch->schib.pmcw.isc = isc; sch->schib.pmcw.isc = isc;
sch->schib.pmcw.intparm = (u32)(addr_t)sch; sch->schib.pmcw.intparm = intparm;
ret = cio_modify(sch); ret = cio_modify(sch);
if (ret == -ENODEV) if (ret == -ENODEV)
break; break;
...@@ -577,11 +577,8 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid) ...@@ -577,11 +577,8 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
} }
/* Initialization for io subchannels. */ /* Initialization for io subchannels. */
if (!sch->schib.pmcw.dnv) { if (!css_sch_is_valid(&sch->schib))
/* io subchannel but device number is invalid. */ return -ENODEV;
err = -ENODEV;
goto out;
}
/* Devno is valid. */ /* Devno is valid. */
if (is_blacklisted (sch->schid.ssid, sch->schib.pmcw.dev)) { if (is_blacklisted (sch->schid.ssid, sch->schib.pmcw.dev)) {
/* /*
...@@ -745,9 +742,9 @@ cio_test_for_console(struct subchannel_id schid, void *data) ...@@ -745,9 +742,9 @@ cio_test_for_console(struct subchannel_id schid, void *data)
{ {
if (stsch_err(schid, &console_subchannel.schib) != 0) if (stsch_err(schid, &console_subchannel.schib) != 0)
return -ENXIO; return -ENXIO;
if (console_subchannel.schib.pmcw.dnv && if ((console_subchannel.schib.pmcw.st == SUBCHANNEL_TYPE_IO) &&
console_subchannel.schib.pmcw.dev == console_subchannel.schib.pmcw.dnv &&
console_devno) { (console_subchannel.schib.pmcw.dev == console_devno)) {
console_irq = schid.sch_no; console_irq = schid.sch_no;
return 1; /* found */ return 1; /* found */
} }
...@@ -765,6 +762,7 @@ cio_get_console_sch_no(void) ...@@ -765,6 +762,7 @@ cio_get_console_sch_no(void)
/* VM provided us with the irq number of the console. */ /* VM provided us with the irq number of the console. */
schid.sch_no = console_irq; schid.sch_no = console_irq;
if (stsch(schid, &console_subchannel.schib) != 0 || if (stsch(schid, &console_subchannel.schib) != 0 ||
(console_subchannel.schib.pmcw.st != SUBCHANNEL_TYPE_IO) ||
!console_subchannel.schib.pmcw.dnv) !console_subchannel.schib.pmcw.dnv)
return -1; return -1;
console_devno = console_subchannel.schib.pmcw.dev; console_devno = console_subchannel.schib.pmcw.dev;
...@@ -1029,7 +1027,7 @@ static int __reipl_subchannel_match(struct subchannel_id schid, void *data) ...@@ -1029,7 +1027,7 @@ static int __reipl_subchannel_match(struct subchannel_id schid, void *data)
if (stsch_reset(schid, &schib)) if (stsch_reset(schid, &schib))
return -ENXIO; return -ENXIO;
if (schib.pmcw.dnv && if ((schib.pmcw.st == SUBCHANNEL_TYPE_IO) && schib.pmcw.dnv &&
(schib.pmcw.dev == match_id->devid.devno) && (schib.pmcw.dev == match_id->devid.devno) &&
(schid.ssid == match_id->devid.ssid)) { (schid.ssid == match_id->devid.ssid)) {
match_id->schid = schid; match_id->schid = schid;
...@@ -1075,6 +1073,8 @@ int __init cio_get_iplinfo(struct cio_iplinfo *iplinfo) ...@@ -1075,6 +1073,8 @@ int __init cio_get_iplinfo(struct cio_iplinfo *iplinfo)
return -ENODEV; return -ENODEV;
if (stsch(schid, &schib)) if (stsch(schid, &schib))
return -ENODEV; return -ENODEV;
if (schib.pmcw.st != SUBCHANNEL_TYPE_IO)
return -ENODEV;
if (!schib.pmcw.dnv) if (!schib.pmcw.dnv)
return -ENODEV; return -ENODEV;
iplinfo->devno = schib.pmcw.dev; iplinfo->devno = schib.pmcw.dev;
......
...@@ -60,7 +60,7 @@ struct subchannel { ...@@ -60,7 +60,7 @@ struct subchannel {
enum { enum {
SUBCHANNEL_TYPE_IO = 0, SUBCHANNEL_TYPE_IO = 0,
SUBCHANNEL_TYPE_CHSC = 1, SUBCHANNEL_TYPE_CHSC = 1,
SUBCHANNEL_TYPE_MESSAGE = 2, SUBCHANNEL_TYPE_MSG = 2,
SUBCHANNEL_TYPE_ADM = 3, SUBCHANNEL_TYPE_ADM = 3,
} st; /* subchannel type */ } st; /* subchannel type */
...@@ -85,7 +85,7 @@ struct subchannel { ...@@ -85,7 +85,7 @@ struct subchannel {
#define to_subchannel(n) container_of(n, struct subchannel, dev) #define to_subchannel(n) container_of(n, struct subchannel, dev)
extern int cio_validate_subchannel (struct subchannel *, struct subchannel_id); extern int cio_validate_subchannel (struct subchannel *, struct subchannel_id);
extern int cio_enable_subchannel (struct subchannel *, unsigned int); extern int cio_enable_subchannel(struct subchannel *, unsigned int, u32);
extern int cio_disable_subchannel (struct subchannel *); extern int cio_disable_subchannel (struct subchannel *);
extern int cio_cancel (struct subchannel *); extern int cio_cancel (struct subchannel *);
extern int cio_clear (struct subchannel *); extern int cio_clear (struct subchannel *);
......
...@@ -237,11 +237,25 @@ get_subchannel_by_schid(struct subchannel_id schid) ...@@ -237,11 +237,25 @@ get_subchannel_by_schid(struct subchannel_id schid)
return dev ? to_subchannel(dev) : NULL; return dev ? to_subchannel(dev) : NULL;
} }
/**
* css_sch_is_valid() - check if a subchannel is valid
* @schib: subchannel information block for the subchannel
*/
int css_sch_is_valid(struct schib *schib)
{
if ((schib->pmcw.st == SUBCHANNEL_TYPE_IO) && !schib->pmcw.dnv)
return 0;
return 1;
}
EXPORT_SYMBOL_GPL(css_sch_is_valid);
static int css_get_subchannel_status(struct subchannel *sch) static int css_get_subchannel_status(struct subchannel *sch)
{ {
struct schib schib; struct schib schib;
if (stsch(sch->schid, &schib) || !schib.pmcw.dnv) if (stsch(sch->schid, &schib))
return CIO_GONE;
if (!css_sch_is_valid(&schib))
return CIO_GONE; return CIO_GONE;
if (sch->schib.pmcw.dnv && (schib.pmcw.dev != sch->schib.pmcw.dev)) if (sch->schib.pmcw.dnv && (schib.pmcw.dev != sch->schib.pmcw.dev))
return CIO_REVALIDATE; return CIO_REVALIDATE;
...@@ -349,7 +363,7 @@ static int css_evaluate_new_subchannel(struct subchannel_id schid, int slow) ...@@ -349,7 +363,7 @@ static int css_evaluate_new_subchannel(struct subchannel_id schid, int slow)
/* Will be done on the slow path. */ /* Will be done on the slow path. */
return -EAGAIN; return -EAGAIN;
} }
if (stsch_err(schid, &schib) || !schib.pmcw.dnv) { if (stsch_err(schid, &schib) || !css_sch_is_valid(&schib)) {
/* Unusable - ignore. */ /* Unusable - ignore. */
return 0; return 0;
} }
......
...@@ -136,6 +136,8 @@ void css_schedule_eval(struct subchannel_id schid); ...@@ -136,6 +136,8 @@ void css_schedule_eval(struct subchannel_id schid);
void css_schedule_eval_all(void); void css_schedule_eval_all(void);
int sch_is_pseudo_sch(struct subchannel *); int sch_is_pseudo_sch(struct subchannel *);
struct schib;
int css_sch_is_valid(struct schib *);
extern struct workqueue_struct *slow_path_wq; extern struct workqueue_struct *slow_path_wq;
......
...@@ -553,7 +553,8 @@ ccw_device_recognition(struct ccw_device *cdev) ...@@ -553,7 +553,8 @@ ccw_device_recognition(struct ccw_device *cdev)
(cdev->private->state != DEV_STATE_BOXED)) (cdev->private->state != DEV_STATE_BOXED))
return -EINVAL; return -EINVAL;
sch = to_subchannel(cdev->dev.parent); sch = to_subchannel(cdev->dev.parent);
ret = cio_enable_subchannel(sch, sch->schib.pmcw.isc); ret = cio_enable_subchannel(sch, sch->schib.pmcw.isc,
(u32)(addr_t)sch);
if (ret != 0) if (ret != 0)
/* Couldn't enable the subchannel for i/o. Sick device. */ /* Couldn't enable the subchannel for i/o. Sick device. */
return ret; return ret;
...@@ -663,7 +664,8 @@ ccw_device_online(struct ccw_device *cdev) ...@@ -663,7 +664,8 @@ ccw_device_online(struct ccw_device *cdev)
sch = to_subchannel(cdev->dev.parent); sch = to_subchannel(cdev->dev.parent);
if (css_init_done && !get_device(&cdev->dev)) if (css_init_done && !get_device(&cdev->dev))
return -ENODEV; return -ENODEV;
ret = cio_enable_subchannel(sch, sch->schib.pmcw.isc); ret = cio_enable_subchannel(sch, sch->schib.pmcw.isc,
(u32)(addr_t)sch);
if (ret != 0) { if (ret != 0) {
/* Couldn't enable the subchannel for i/o. Sick device. */ /* Couldn't enable the subchannel for i/o. Sick device. */
if (ret == -ENODEV) if (ret == -ENODEV)
...@@ -1043,7 +1045,8 @@ ccw_device_start_id(struct ccw_device *cdev, enum dev_event dev_event) ...@@ -1043,7 +1045,8 @@ ccw_device_start_id(struct ccw_device *cdev, enum dev_event dev_event)
struct subchannel *sch; struct subchannel *sch;
sch = to_subchannel(cdev->dev.parent); sch = to_subchannel(cdev->dev.parent);
if (cio_enable_subchannel(sch, sch->schib.pmcw.isc) != 0) if (cio_enable_subchannel(sch, sch->schib.pmcw.isc,
(u32)(addr_t)sch) != 0)
/* Couldn't enable the subchannel for i/o. Sick device. */ /* Couldn't enable the subchannel for i/o. Sick device. */
return; return;
......
...@@ -501,7 +501,7 @@ ccw_device_stlck(struct ccw_device *cdev) ...@@ -501,7 +501,7 @@ ccw_device_stlck(struct ccw_device *cdev)
return -ENOMEM; return -ENOMEM;
} }
spin_lock_irqsave(sch->lock, flags); spin_lock_irqsave(sch->lock, flags);
ret = cio_enable_subchannel(sch, 3); ret = cio_enable_subchannel(sch, 3, (u32)(addr_t)sch);
if (ret) if (ret)
goto out_unlock; goto out_unlock;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment