diff options
author | Cornelia Huck <cornelia.huck@de.ibm.com> | 2006-07-12 10:39:50 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2006-07-12 10:39:50 -0400 |
commit | 6ab4879a0d074c938fd17dba141dce042fc17bee (patch) | |
tree | 62e413692d4c55ae322c3201c36ded4808806cb5 | |
parent | 63f4f9e1281ea9b9a2304bd13d657ba9d401c9a7 (diff) |
[S390] subchannel register/unregister mutex.
Add a reg_mutex to prevent unregistering a subchannel before it has been
registered. Since 2.6.17, we've seen oopses in kslowcrw when a device is
found to be not operational during sense id when doing initial device
recognition; it is not clear yet why that particular problem was not (yet)
observed with earlier kernels...
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r-- | drivers/s390/cio/cio.c | 1 | ||||
-rw-r--r-- | drivers/s390/cio/cio.h | 3 | ||||
-rw-r--r-- | drivers/s390/cio/css.c | 24 | ||||
-rw-r--r-- | drivers/s390/cio/css.h | 2 | ||||
-rw-r--r-- | drivers/s390/cio/device.c | 6 |
5 files changed, 29 insertions, 7 deletions
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c index 6fec90eab00e..f27b2b866f5a 100644 --- a/drivers/s390/cio/cio.c +++ b/drivers/s390/cio/cio.c | |||
@@ -519,6 +519,7 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid) | |||
519 | memset(sch, 0, sizeof(struct subchannel)); | 519 | memset(sch, 0, sizeof(struct subchannel)); |
520 | 520 | ||
521 | spin_lock_init(&sch->lock); | 521 | spin_lock_init(&sch->lock); |
522 | mutex_init(&sch->reg_mutex); | ||
522 | 523 | ||
523 | /* Set a name for the subchannel */ | 524 | /* Set a name for the subchannel */ |
524 | snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x", schid.ssid, | 525 | snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x", schid.ssid, |
diff --git a/drivers/s390/cio/cio.h b/drivers/s390/cio/cio.h index 0ca987344e07..4541c1af4b66 100644 --- a/drivers/s390/cio/cio.h +++ b/drivers/s390/cio/cio.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define S390_CIO_H | 2 | #define S390_CIO_H |
3 | 3 | ||
4 | #include "schid.h" | 4 | #include "schid.h" |
5 | #include <linux/mutex.h> | ||
5 | 6 | ||
6 | /* | 7 | /* |
7 | * where we put the ssd info | 8 | * where we put the ssd info |
@@ -87,7 +88,7 @@ struct orb { | |||
87 | struct subchannel { | 88 | struct subchannel { |
88 | struct subchannel_id schid; | 89 | struct subchannel_id schid; |
89 | spinlock_t lock; /* subchannel lock */ | 90 | spinlock_t lock; /* subchannel lock */ |
90 | 91 | struct mutex reg_mutex; | |
91 | enum { | 92 | enum { |
92 | SUBCHANNEL_TYPE_IO = 0, | 93 | SUBCHANNEL_TYPE_IO = 0, |
93 | SUBCHANNEL_TYPE_CHSC = 1, | 94 | SUBCHANNEL_TYPE_CHSC = 1, |
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 1d3be80797f8..a09deea5d687 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c | |||
@@ -108,6 +108,24 @@ css_subchannel_release(struct device *dev) | |||
108 | 108 | ||
109 | extern int css_get_ssd_info(struct subchannel *sch); | 109 | extern int css_get_ssd_info(struct subchannel *sch); |
110 | 110 | ||
111 | |||
112 | int css_sch_device_register(struct subchannel *sch) | ||
113 | { | ||
114 | int ret; | ||
115 | |||
116 | mutex_lock(&sch->reg_mutex); | ||
117 | ret = device_register(&sch->dev); | ||
118 | mutex_unlock(&sch->reg_mutex); | ||
119 | return ret; | ||
120 | } | ||
121 | |||
122 | void css_sch_device_unregister(struct subchannel *sch) | ||
123 | { | ||
124 | mutex_lock(&sch->reg_mutex); | ||
125 | device_unregister(&sch->dev); | ||
126 | mutex_unlock(&sch->reg_mutex); | ||
127 | } | ||
128 | |||
111 | static int | 129 | static int |
112 | css_register_subchannel(struct subchannel *sch) | 130 | css_register_subchannel(struct subchannel *sch) |
113 | { | 131 | { |
@@ -119,7 +137,7 @@ css_register_subchannel(struct subchannel *sch) | |||
119 | sch->dev.release = &css_subchannel_release; | 137 | sch->dev.release = &css_subchannel_release; |
120 | 138 | ||
121 | /* make it known to the system */ | 139 | /* make it known to the system */ |
122 | ret = device_register(&sch->dev); | 140 | ret = css_sch_device_register(sch); |
123 | if (ret) | 141 | if (ret) |
124 | printk (KERN_WARNING "%s: could not register %s\n", | 142 | printk (KERN_WARNING "%s: could not register %s\n", |
125 | __func__, sch->dev.bus_id); | 143 | __func__, sch->dev.bus_id); |
@@ -250,7 +268,7 @@ css_evaluate_subchannel(struct subchannel_id schid, int slow) | |||
250 | * The device will be killed automatically. | 268 | * The device will be killed automatically. |
251 | */ | 269 | */ |
252 | cio_disable_subchannel(sch); | 270 | cio_disable_subchannel(sch); |
253 | device_unregister(&sch->dev); | 271 | css_sch_device_unregister(sch); |
254 | /* Reset intparm to zeroes. */ | 272 | /* Reset intparm to zeroes. */ |
255 | sch->schib.pmcw.intparm = 0; | 273 | sch->schib.pmcw.intparm = 0; |
256 | cio_modify(sch); | 274 | cio_modify(sch); |
@@ -264,7 +282,7 @@ css_evaluate_subchannel(struct subchannel_id schid, int slow) | |||
264 | * away in any case. | 282 | * away in any case. |
265 | */ | 283 | */ |
266 | if (!disc) { | 284 | if (!disc) { |
267 | device_unregister(&sch->dev); | 285 | css_sch_device_unregister(sch); |
268 | /* Reset intparm to zeroes. */ | 286 | /* Reset intparm to zeroes. */ |
269 | sch->schib.pmcw.intparm = 0; | 287 | sch->schib.pmcw.intparm = 0; |
270 | cio_modify(sch); | 288 | cio_modify(sch); |
diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h index e210f89a2449..15f7f7cb0ec2 100644 --- a/drivers/s390/cio/css.h +++ b/drivers/s390/cio/css.h | |||
@@ -136,6 +136,8 @@ extern struct bus_type css_bus_type; | |||
136 | extern struct css_driver io_subchannel_driver; | 136 | extern struct css_driver io_subchannel_driver; |
137 | 137 | ||
138 | extern int css_probe_device(struct subchannel_id); | 138 | extern int css_probe_device(struct subchannel_id); |
139 | extern int css_sch_device_register(struct subchannel *); | ||
140 | extern void css_sch_device_unregister(struct subchannel *); | ||
139 | extern struct subchannel * get_subchannel_by_schid(struct subchannel_id); | 141 | extern struct subchannel * get_subchannel_by_schid(struct subchannel_id); |
140 | extern int css_init_done; | 142 | extern int css_init_done; |
141 | extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *); | 143 | extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *); |
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index 67f0de6aed33..9db09870b2ae 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c | |||
@@ -280,7 +280,7 @@ ccw_device_remove_disconnected(struct ccw_device *cdev) | |||
280 | * 'throw away device'. | 280 | * 'throw away device'. |
281 | */ | 281 | */ |
282 | sch = to_subchannel(cdev->dev.parent); | 282 | sch = to_subchannel(cdev->dev.parent); |
283 | device_unregister(&sch->dev); | 283 | css_sch_device_unregister(sch); |
284 | /* Reset intparm to zeroes. */ | 284 | /* Reset intparm to zeroes. */ |
285 | sch->schib.pmcw.intparm = 0; | 285 | sch->schib.pmcw.intparm = 0; |
286 | cio_modify(sch); | 286 | cio_modify(sch); |
@@ -625,7 +625,7 @@ ccw_device_do_unreg_rereg(void *data) | |||
625 | other_sch->schib.pmcw.intparm = 0; | 625 | other_sch->schib.pmcw.intparm = 0; |
626 | cio_modify(other_sch); | 626 | cio_modify(other_sch); |
627 | } | 627 | } |
628 | device_unregister(&other_sch->dev); | 628 | css_sch_device_unregister(other_sch); |
629 | } | 629 | } |
630 | } | 630 | } |
631 | /* Update ssd info here. */ | 631 | /* Update ssd info here. */ |
@@ -709,7 +709,7 @@ ccw_device_call_sch_unregister(void *data) | |||
709 | struct subchannel *sch; | 709 | struct subchannel *sch; |
710 | 710 | ||
711 | sch = to_subchannel(cdev->dev.parent); | 711 | sch = to_subchannel(cdev->dev.parent); |
712 | device_unregister(&sch->dev); | 712 | css_sch_device_unregister(sch); |
713 | /* Reset intparm to zeroes. */ | 713 | /* Reset intparm to zeroes. */ |
714 | sch->schib.pmcw.intparm = 0; | 714 | sch->schib.pmcw.intparm = 0; |
715 | cio_modify(sch); | 715 | cio_modify(sch); |