8 #define KMSG_COMPONENT "dasd-eckd"
10 #include <linux/list.h>
11 #include <linux/slab.h>
19 #define PRINTK_HEADER "dasd(eckd):"
43 static void summary_unit_check_handling_work(
struct work_struct *);
80 __u8 search_unit_addr;
97 if (pos->
uid.base_unit_addr == search_unit_addr &&
108 server = kzalloc(
sizeof(*server),
GFP_KERNEL);
113 INIT_LIST_HEAD(&server->
server);
114 INIT_LIST_HEAD(&server->
lculist);
136 lcu->
rsu_cqr->cpaddr = kzalloc(
sizeof(
struct ccw1),
149 INIT_LIST_HEAD(&lcu->
lcu);
170 static void _free_lcu(
struct alias_lcu *lcu)
198 server = _find_server(&uid);
200 spin_unlock_irqrestore(&aliastree.
lock, flags);
201 newserver = _allocate_server(&uid);
202 if (IS_ERR(newserver))
203 return PTR_ERR(newserver);
205 server = _find_server(&uid);
211 _free_server(newserver);
215 lcu = _find_lcu(server, &uid);
217 spin_unlock_irqrestore(&aliastree.
lock, flags);
218 newlcu = _allocate_lcu(&uid);
220 return PTR_ERR(newlcu);
222 lcu = _find_lcu(server, &uid);
231 spin_lock(&lcu->
lock);
234 spin_unlock(&lcu->
lock);
235 spin_unlock_irqrestore(&aliastree.
lock, flags);
263 if (device == lcu->
suc_data.device) {
264 spin_unlock_irqrestore(&lcu->
lock, flags);
272 spin_unlock_irqrestore(&lcu->
lock, flags);
280 spin_unlock_irqrestore(&lcu->
lock, flags);
283 spin_lock(&lcu->
lock);
288 spin_unlock(&lcu->
lock);
293 _schedule_lcu_update(lcu,
NULL);
294 spin_unlock(&lcu->
lock);
296 server = _find_server(&uid);
297 if (server && list_empty(&server->
lculist)) {
299 _free_server(server);
301 spin_unlock_irqrestore(&aliastree.
lock, flags);
310 static int _add_device_to_lcu(
struct alias_lcu *lcu,
326 private->uid.type = lcu->
uac->unit[
private->uid.real_unit_addr].ua_type;
327 private->uid.base_unit_addr =
328 lcu->
uac->unit[
private->uid.real_unit_addr].base_ua;
340 group = _find_group(lcu, &uid);
353 INIT_LIST_HEAD(&group->
group);
362 private->pavgroup =
group;
366 static void _remove_device_from_lcu(
struct alias_lcu *lcu,
374 group =
private->pavgroup;
377 private->pavgroup =
NULL;
383 if (group->
next == device)
400 msg_format = (sense[7] & 0xF0);
401 msg_no = (sense[7] & 0x0F);
404 if ((reason == 0x80) && (msg_format == 0x00) && (msg_no == 0x04))
410 static int read_unit_address_configuration(
struct dasd_device *device,
457 spin_unlock_irqrestore(&lcu->
lock, flags);
461 if (rc && suborder_not_supported(cqr))
463 }
while (rc && (cqr->
retries > 0));
467 spin_unlock_irqrestore(&lcu->
lock, flags);
487 private->pavgroup =
NULL;
493 private->pavgroup =
NULL;
498 spin_unlock_irqrestore(&lcu->
lock, flags);
500 rc = read_unit_address_configuration(refdev, lcu);
507 spin_lock(&lcu->
lock);
510 switch (lcu->
uac->unit[i].ua_type) {
524 _add_device_to_lcu(lcu, device, refdev);
526 spin_unlock(&lcu->
lock);
541 device = ruac_data->
device;
542 rc = _lcu_update(device, lcu);
551 " alias data in lcu (rc = %d), retry later", rc);
557 spin_unlock_irqrestore(&lcu->
lock, flags);
560 static int _schedule_lcu_update(
struct alias_lcu *lcu,
571 if (device && !list_empty(&device->
alias_list))
574 if (!usedev && !list_empty(&lcu->
grouplist)) {
614 spin_lock(&lcu->
lock);
616 rc = _add_device_to_lcu(lcu, device, device);
622 _schedule_lcu_update(lcu, device);
624 spin_unlock(&lcu->
lock);
649 _remove_device_from_lcu(lcu, device);
650 spin_unlock_irqrestore(&lcu->
lock, flags);
664 group = private->pavgroup;
671 if (
unlikely(!(private->features.feature[8] & 0x01))) {
678 "Prefix not enabled with PAV enabled\n");
683 alias_device = group->
next;
686 spin_unlock_irqrestore(&lcu->
lock, flags);
700 spin_unlock_irqrestore(&lcu->
lock, flags);
702 if ((alias_priv->
count < private->count) && !alias_device->
stopped)
712 static int reset_summary_unit_check(
struct alias_lcu *lcu,
743 static void _restart_all_base_devices_on_lcu(
struct alias_lcu *lcu)
783 static void flush_all_alias_devices_on_lcu(
struct alias_lcu *lcu)
815 while (!list_empty(&
active)) {
818 spin_unlock_irqrestore(&lcu->
lock, flags);
829 spin_unlock_irqrestore(&lcu->
lock, flags);
832 static void __stop_device_on_lcu(
struct dasd_device *device,
849 static void _stop_all_devices_on_lcu(
struct alias_lcu *lcu,
856 __stop_device_on_lcu(device, pos);
858 __stop_device_on_lcu(device, pos);
861 __stop_device_on_lcu(device, pos);
863 __stop_device_on_lcu(device, pos);
901 static void summary_unit_check_handling_work(
struct work_struct *work)
911 device = suc_data->
device;
914 flush_all_alias_devices_on_lcu(lcu);
921 reset_summary_unit_check(lcu, device, suc_data->
reason);
924 _unstop_all_devices_on_lcu(lcu);
925 _restart_all_base_devices_on_lcu(lcu);
927 _schedule_lcu_update(lcu, device);
929 spin_unlock_irqrestore(&lcu->
lock, flags);
949 "eckd handle summary unit check: reason", reason);
952 "eckd handle summary unit check:"
953 " no reason code available");
960 "device not ready to handle summary"
961 " unit check (no lcu structure)");
964 spin_lock(&lcu->
lock);
965 _stop_all_devices_on_lcu(lcu, device);
973 "device is in offline processing,"
974 " don't do summary unit check handling");
975 spin_unlock(&lcu->
lock);
981 "previous instance of summary unit check worker"
983 spin_unlock(&lcu->
lock);
988 spin_unlock(&lcu->
lock);