.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
---|
1 | 2 | /* |
---|
2 | 3 | * Serial Attached SCSI (SAS) Expander discovery and configuration |
---|
3 | 4 | * |
---|
.. | .. |
---|
5 | 6 | * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com> |
---|
6 | 7 | * |
---|
7 | 8 | * This file is licensed under GPLv2. |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or |
---|
10 | | - * modify it under the terms of the GNU General Public License as |
---|
11 | | - * published by the Free Software Foundation; either version 2 of the |
---|
12 | | - * License, or (at your option) any later version. |
---|
13 | | - * |
---|
14 | | - * This program is distributed in the hope that it will be useful, but |
---|
15 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | | - * General Public License for more details. |
---|
18 | | - * |
---|
19 | | - * You should have received a copy of the GNU General Public License |
---|
20 | | - * along with this program; if not, write to the Free Software |
---|
21 | | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
22 | | - * |
---|
23 | 9 | */ |
---|
24 | 10 | |
---|
25 | 11 | #include <linux/scatterlist.h> |
---|
26 | 12 | #include <linux/blkdev.h> |
---|
27 | 13 | #include <linux/slab.h> |
---|
| 14 | +#include <asm/unaligned.h> |
---|
28 | 15 | |
---|
29 | 16 | #include "sas_internal.h" |
---|
30 | 17 | |
---|
.. | .. |
---|
98 | 85 | res = i->dft->lldd_execute_task(task, GFP_KERNEL); |
---|
99 | 86 | |
---|
100 | 87 | if (res) { |
---|
101 | | - del_timer(&task->slow_task->timer); |
---|
102 | | - SAS_DPRINTK("executing SMP task failed:%d\n", res); |
---|
| 88 | + del_timer_sync(&task->slow_task->timer); |
---|
| 89 | + pr_notice("executing SMP task failed:%d\n", res); |
---|
103 | 90 | break; |
---|
104 | 91 | } |
---|
105 | 92 | |
---|
106 | 93 | wait_for_completion(&task->slow_task->completion); |
---|
107 | 94 | res = -ECOMM; |
---|
108 | 95 | if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) { |
---|
109 | | - SAS_DPRINTK("smp task timed out or aborted\n"); |
---|
| 96 | + pr_notice("smp task timed out or aborted\n"); |
---|
110 | 97 | i->dft->lldd_abort_task(task); |
---|
111 | 98 | if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) { |
---|
112 | | - SAS_DPRINTK("SMP task aborted and not done\n"); |
---|
| 99 | + pr_notice("SMP task aborted and not done\n"); |
---|
113 | 100 | break; |
---|
114 | 101 | } |
---|
115 | 102 | } |
---|
116 | 103 | if (task->task_status.resp == SAS_TASK_COMPLETE && |
---|
117 | | - task->task_status.stat == SAM_STAT_GOOD) { |
---|
| 104 | + task->task_status.stat == SAS_SAM_STAT_GOOD) { |
---|
118 | 105 | res = 0; |
---|
119 | 106 | break; |
---|
120 | 107 | } |
---|
.. | .. |
---|
134 | 121 | task->task_status.stat == SAS_DEVICE_UNKNOWN) |
---|
135 | 122 | break; |
---|
136 | 123 | else { |
---|
137 | | - SAS_DPRINTK("%s: task to dev %016llx response: 0x%x " |
---|
138 | | - "status 0x%x\n", __func__, |
---|
139 | | - SAS_ADDR(dev->sas_addr), |
---|
140 | | - task->task_status.resp, |
---|
141 | | - task->task_status.stat); |
---|
| 124 | + pr_notice("%s: task to dev %016llx response: 0x%x status 0x%x\n", |
---|
| 125 | + __func__, |
---|
| 126 | + SAS_ADDR(dev->sas_addr), |
---|
| 127 | + task->task_status.resp, |
---|
| 128 | + task->task_status.stat); |
---|
142 | 129 | sas_free_task(task); |
---|
143 | 130 | task = NULL; |
---|
144 | 131 | } |
---|
.. | .. |
---|
347 | 334 | if (test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state)) |
---|
348 | 335 | set_bit(DISCE_REVALIDATE_DOMAIN, &dev->port->disc.pending); |
---|
349 | 336 | |
---|
350 | | - SAS_DPRINTK("%sex %016llx phy%02d:%c:%X attached: %016llx (%s)\n", |
---|
351 | | - test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state) ? "ata: " : "", |
---|
352 | | - SAS_ADDR(dev->sas_addr), phy->phy_id, |
---|
353 | | - sas_route_char(dev, phy), phy->linkrate, |
---|
354 | | - SAS_ADDR(phy->attached_sas_addr), type); |
---|
| 337 | + pr_debug("%sex %016llx phy%02d:%c:%X attached: %016llx (%s)\n", |
---|
| 338 | + test_bit(SAS_HA_ATA_EH_ACTIVE, &ha->state) ? "ata: " : "", |
---|
| 339 | + SAS_ADDR(dev->sas_addr), phy->phy_id, |
---|
| 340 | + sas_route_char(dev, phy), phy->linkrate, |
---|
| 341 | + SAS_ADDR(phy->attached_sas_addr), type); |
---|
355 | 342 | } |
---|
356 | 343 | |
---|
357 | 344 | /* check if we have an existing attached ata device on this expander phy */ |
---|
.. | .. |
---|
393 | 380 | return res; |
---|
394 | 381 | dr = &((struct smp_resp *)disc_resp)->disc; |
---|
395 | 382 | if (memcmp(dev->sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE) == 0) { |
---|
396 | | - sas_printk("Found loopback topology, just ignore it!\n"); |
---|
| 383 | + pr_notice("Found loopback topology, just ignore it!\n"); |
---|
397 | 384 | return 0; |
---|
398 | 385 | } |
---|
399 | 386 | sas_set_ex_phy(dev, single, disc_resp); |
---|
.. | .. |
---|
440 | 427 | static int sas_expander_discover(struct domain_device *dev) |
---|
441 | 428 | { |
---|
442 | 429 | struct expander_device *ex = &dev->ex_dev; |
---|
443 | | - int res = -ENOMEM; |
---|
| 430 | + int res; |
---|
444 | 431 | |
---|
445 | 432 | ex->ex_phy = kcalloc(ex->num_phys, sizeof(*ex->ex_phy), GFP_KERNEL); |
---|
446 | 433 | if (!ex->ex_phy) |
---|
.. | .. |
---|
500 | 487 | RG_RESP_SIZE); |
---|
501 | 488 | |
---|
502 | 489 | if (res) { |
---|
503 | | - SAS_DPRINTK("RG to ex %016llx failed:0x%x\n", |
---|
504 | | - SAS_ADDR(dev->sas_addr), res); |
---|
| 490 | + pr_notice("RG to ex %016llx failed:0x%x\n", |
---|
| 491 | + SAS_ADDR(dev->sas_addr), res); |
---|
505 | 492 | goto out; |
---|
506 | 493 | } else if (rg_resp->result != SMP_RESP_FUNC_ACC) { |
---|
507 | | - SAS_DPRINTK("RG:ex %016llx returned SMP result:0x%x\n", |
---|
508 | | - SAS_ADDR(dev->sas_addr), rg_resp->result); |
---|
| 494 | + pr_debug("RG:ex %016llx returned SMP result:0x%x\n", |
---|
| 495 | + SAS_ADDR(dev->sas_addr), rg_resp->result); |
---|
509 | 496 | res = rg_resp->result; |
---|
510 | 497 | goto out; |
---|
511 | 498 | } |
---|
.. | .. |
---|
513 | 500 | ex_assign_report_general(dev, rg_resp); |
---|
514 | 501 | |
---|
515 | 502 | if (dev->ex_dev.configuring) { |
---|
516 | | - SAS_DPRINTK("RG: ex %llx self-configuring...\n", |
---|
517 | | - SAS_ADDR(dev->sas_addr)); |
---|
| 503 | + pr_debug("RG: ex %016llx self-configuring...\n", |
---|
| 504 | + SAS_ADDR(dev->sas_addr)); |
---|
518 | 505 | schedule_timeout_interruptible(5*HZ); |
---|
519 | 506 | } else |
---|
520 | 507 | break; |
---|
.. | .. |
---|
568 | 555 | |
---|
569 | 556 | res = smp_execute_task(dev, mi_req, MI_REQ_SIZE, mi_resp,MI_RESP_SIZE); |
---|
570 | 557 | if (res) { |
---|
571 | | - SAS_DPRINTK("MI: ex %016llx failed:0x%x\n", |
---|
572 | | - SAS_ADDR(dev->sas_addr), res); |
---|
| 558 | + pr_notice("MI: ex %016llx failed:0x%x\n", |
---|
| 559 | + SAS_ADDR(dev->sas_addr), res); |
---|
573 | 560 | goto out; |
---|
574 | 561 | } else if (mi_resp[2] != SMP_RESP_FUNC_ACC) { |
---|
575 | | - SAS_DPRINTK("MI ex %016llx returned SMP result:0x%x\n", |
---|
576 | | - SAS_ADDR(dev->sas_addr), mi_resp[2]); |
---|
| 562 | + pr_debug("MI ex %016llx returned SMP result:0x%x\n", |
---|
| 563 | + SAS_ADDR(dev->sas_addr), mi_resp[2]); |
---|
577 | 564 | goto out; |
---|
578 | 565 | } |
---|
579 | 566 | |
---|
.. | .. |
---|
696 | 683 | if (res) |
---|
697 | 684 | goto out; |
---|
698 | 685 | |
---|
699 | | - phy->invalid_dword_count = scsi_to_u32(&resp[12]); |
---|
700 | | - phy->running_disparity_error_count = scsi_to_u32(&resp[16]); |
---|
701 | | - phy->loss_of_dword_sync_count = scsi_to_u32(&resp[20]); |
---|
702 | | - phy->phy_reset_problem_count = scsi_to_u32(&resp[24]); |
---|
| 686 | + phy->invalid_dword_count = get_unaligned_be32(&resp[12]); |
---|
| 687 | + phy->running_disparity_error_count = get_unaligned_be32(&resp[16]); |
---|
| 688 | + phy->loss_of_dword_sync_count = get_unaligned_be32(&resp[20]); |
---|
| 689 | + phy->phy_reset_problem_count = get_unaligned_be32(&resp[24]); |
---|
703 | 690 | |
---|
704 | 691 | out: |
---|
705 | 692 | kfree(req); |
---|
.. | .. |
---|
825 | 812 | #ifdef CONFIG_SCSI_SAS_ATA |
---|
826 | 813 | if ((phy->attached_tproto & SAS_PROTOCOL_STP) || phy->attached_sata_dev) { |
---|
827 | 814 | if (child->linkrate > parent->min_linkrate) { |
---|
| 815 | + struct sas_phy *cphy = child->phy; |
---|
| 816 | + enum sas_linkrate min_prate = cphy->minimum_linkrate, |
---|
| 817 | + parent_min_lrate = parent->min_linkrate, |
---|
| 818 | + min_linkrate = (min_prate > parent_min_lrate) ? |
---|
| 819 | + parent_min_lrate : 0; |
---|
828 | 820 | struct sas_phy_linkrates rates = { |
---|
829 | 821 | .maximum_linkrate = parent->min_linkrate, |
---|
830 | | - .minimum_linkrate = parent->min_linkrate, |
---|
| 822 | + .minimum_linkrate = min_linkrate, |
---|
831 | 823 | }; |
---|
832 | 824 | int ret; |
---|
833 | 825 | |
---|
.. | .. |
---|
864 | 856 | |
---|
865 | 857 | res = sas_discover_sata(child); |
---|
866 | 858 | if (res) { |
---|
867 | | - SAS_DPRINTK("sas_discover_sata() for device %16llx at " |
---|
868 | | - "%016llx:0x%x returned 0x%x\n", |
---|
869 | | - SAS_ADDR(child->sas_addr), |
---|
870 | | - SAS_ADDR(parent->sas_addr), phy_id, res); |
---|
| 859 | + pr_notice("sas_discover_sata() for device %16llx at %016llx:%02d returned 0x%x\n", |
---|
| 860 | + SAS_ADDR(child->sas_addr), |
---|
| 861 | + SAS_ADDR(parent->sas_addr), phy_id, res); |
---|
871 | 862 | goto out_list_del; |
---|
872 | 863 | } |
---|
873 | 864 | } else |
---|
.. | .. |
---|
890 | 881 | |
---|
891 | 882 | res = sas_discover_end_dev(child); |
---|
892 | 883 | if (res) { |
---|
893 | | - SAS_DPRINTK("sas_discover_end_dev() for device %16llx " |
---|
894 | | - "at %016llx:0x%x returned 0x%x\n", |
---|
895 | | - SAS_ADDR(child->sas_addr), |
---|
896 | | - SAS_ADDR(parent->sas_addr), phy_id, res); |
---|
| 884 | + pr_notice("sas_discover_end_dev() for device %016llx at %016llx:%02d returned 0x%x\n", |
---|
| 885 | + SAS_ADDR(child->sas_addr), |
---|
| 886 | + SAS_ADDR(parent->sas_addr), phy_id, res); |
---|
897 | 887 | goto out_list_del; |
---|
898 | 888 | } |
---|
899 | 889 | } else { |
---|
900 | | - SAS_DPRINTK("target proto 0x%x at %016llx:0x%x not handled\n", |
---|
901 | | - phy->attached_tproto, SAS_ADDR(parent->sas_addr), |
---|
902 | | - phy_id); |
---|
| 890 | + pr_notice("target proto 0x%x at %016llx:0x%x not handled\n", |
---|
| 891 | + phy->attached_tproto, SAS_ADDR(parent->sas_addr), |
---|
| 892 | + phy_id); |
---|
903 | 893 | goto out_free; |
---|
904 | 894 | } |
---|
905 | 895 | |
---|
.. | .. |
---|
956 | 946 | int res; |
---|
957 | 947 | |
---|
958 | 948 | if (phy->routing_attr == DIRECT_ROUTING) { |
---|
959 | | - SAS_DPRINTK("ex %016llx:0x%x:D <--> ex %016llx:0x%x is not " |
---|
960 | | - "allowed\n", |
---|
961 | | - SAS_ADDR(parent->sas_addr), phy_id, |
---|
962 | | - SAS_ADDR(phy->attached_sas_addr), |
---|
963 | | - phy->attached_phy_id); |
---|
| 949 | + pr_warn("ex %016llx:%02d:D <--> ex %016llx:0x%x is not allowed\n", |
---|
| 950 | + SAS_ADDR(parent->sas_addr), phy_id, |
---|
| 951 | + SAS_ADDR(phy->attached_sas_addr), |
---|
| 952 | + phy->attached_phy_id); |
---|
964 | 953 | return NULL; |
---|
965 | 954 | } |
---|
966 | 955 | child = sas_alloc_device(); |
---|
.. | .. |
---|
1069 | 1058 | ex_phy->attached_dev_type != SAS_FANOUT_EXPANDER_DEVICE && |
---|
1070 | 1059 | ex_phy->attached_dev_type != SAS_EDGE_EXPANDER_DEVICE && |
---|
1071 | 1060 | ex_phy->attached_dev_type != SAS_SATA_PENDING) { |
---|
1072 | | - SAS_DPRINTK("unknown device type(0x%x) attached to ex %016llx " |
---|
1073 | | - "phy 0x%x\n", ex_phy->attached_dev_type, |
---|
1074 | | - SAS_ADDR(dev->sas_addr), |
---|
1075 | | - phy_id); |
---|
| 1061 | + pr_warn("unknown device type(0x%x) attached to ex %016llx phy%02d\n", |
---|
| 1062 | + ex_phy->attached_dev_type, |
---|
| 1063 | + SAS_ADDR(dev->sas_addr), |
---|
| 1064 | + phy_id); |
---|
1076 | 1065 | return 0; |
---|
1077 | 1066 | } |
---|
1078 | 1067 | |
---|
1079 | 1068 | res = sas_configure_routing(dev, ex_phy->attached_sas_addr); |
---|
1080 | 1069 | if (res) { |
---|
1081 | | - SAS_DPRINTK("configure routing for dev %016llx " |
---|
1082 | | - "reported 0x%x. Forgotten\n", |
---|
1083 | | - SAS_ADDR(ex_phy->attached_sas_addr), res); |
---|
| 1070 | + pr_notice("configure routing for dev %016llx reported 0x%x. Forgotten\n", |
---|
| 1071 | + SAS_ADDR(ex_phy->attached_sas_addr), res); |
---|
1084 | 1072 | sas_disable_routing(dev, ex_phy->attached_sas_addr); |
---|
1085 | 1073 | return res; |
---|
1086 | 1074 | } |
---|
1087 | 1075 | |
---|
1088 | 1076 | if (sas_ex_join_wide_port(dev, phy_id)) { |
---|
1089 | | - SAS_DPRINTK("Attaching ex phy%d to wide port %016llx\n", |
---|
1090 | | - phy_id, SAS_ADDR(ex_phy->attached_sas_addr)); |
---|
| 1077 | + pr_debug("Attaching ex phy%02d to wide port %016llx\n", |
---|
| 1078 | + phy_id, SAS_ADDR(ex_phy->attached_sas_addr)); |
---|
1091 | 1079 | return res; |
---|
1092 | 1080 | } |
---|
1093 | 1081 | |
---|
.. | .. |
---|
1098 | 1086 | break; |
---|
1099 | 1087 | case SAS_FANOUT_EXPANDER_DEVICE: |
---|
1100 | 1088 | if (SAS_ADDR(dev->port->disc.fanout_sas_addr)) { |
---|
1101 | | - SAS_DPRINTK("second fanout expander %016llx phy 0x%x " |
---|
1102 | | - "attached to ex %016llx phy 0x%x\n", |
---|
1103 | | - SAS_ADDR(ex_phy->attached_sas_addr), |
---|
1104 | | - ex_phy->attached_phy_id, |
---|
1105 | | - SAS_ADDR(dev->sas_addr), |
---|
1106 | | - phy_id); |
---|
| 1089 | + pr_debug("second fanout expander %016llx phy%02d attached to ex %016llx phy%02d\n", |
---|
| 1090 | + SAS_ADDR(ex_phy->attached_sas_addr), |
---|
| 1091 | + ex_phy->attached_phy_id, |
---|
| 1092 | + SAS_ADDR(dev->sas_addr), |
---|
| 1093 | + phy_id); |
---|
1107 | 1094 | sas_ex_disable_phy(dev, phy_id); |
---|
1108 | | - break; |
---|
| 1095 | + return res; |
---|
1109 | 1096 | } else |
---|
1110 | 1097 | memcpy(dev->port->disc.fanout_sas_addr, |
---|
1111 | 1098 | ex_phy->attached_sas_addr, SAS_ADDR_SIZE); |
---|
1112 | | - /* fallthrough */ |
---|
| 1099 | + fallthrough; |
---|
1113 | 1100 | case SAS_EDGE_EXPANDER_DEVICE: |
---|
1114 | 1101 | child = sas_ex_discover_expander(dev, phy_id); |
---|
1115 | 1102 | break; |
---|
.. | .. |
---|
1117 | 1104 | break; |
---|
1118 | 1105 | } |
---|
1119 | 1106 | |
---|
1120 | | - if (child) { |
---|
1121 | | - int i; |
---|
1122 | | - |
---|
1123 | | - for (i = 0; i < ex->num_phys; i++) { |
---|
1124 | | - if (ex->ex_phy[i].phy_state == PHY_VACANT || |
---|
1125 | | - ex->ex_phy[i].phy_state == PHY_NOT_PRESENT) |
---|
1126 | | - continue; |
---|
1127 | | - /* |
---|
1128 | | - * Due to races, the phy might not get added to the |
---|
1129 | | - * wide port, so we add the phy to the wide port here. |
---|
1130 | | - */ |
---|
1131 | | - if (SAS_ADDR(ex->ex_phy[i].attached_sas_addr) == |
---|
1132 | | - SAS_ADDR(child->sas_addr)) { |
---|
1133 | | - ex->ex_phy[i].phy_state= PHY_DEVICE_DISCOVERED; |
---|
1134 | | - if (sas_ex_join_wide_port(dev, i)) |
---|
1135 | | - SAS_DPRINTK("Attaching ex phy%d to wide port %016llx\n", |
---|
1136 | | - i, SAS_ADDR(ex->ex_phy[i].attached_sas_addr)); |
---|
1137 | | - |
---|
1138 | | - } |
---|
1139 | | - } |
---|
1140 | | - } |
---|
1141 | | - |
---|
| 1107 | + if (!child) |
---|
| 1108 | + pr_notice("ex %016llx phy%02d failed to discover\n", |
---|
| 1109 | + SAS_ADDR(dev->sas_addr), phy_id); |
---|
1142 | 1110 | return res; |
---|
1143 | 1111 | } |
---|
1144 | 1112 | |
---|
.. | .. |
---|
1154 | 1122 | phy->phy_state == PHY_NOT_PRESENT) |
---|
1155 | 1123 | continue; |
---|
1156 | 1124 | |
---|
1157 | | - if ((phy->attached_dev_type == SAS_EDGE_EXPANDER_DEVICE || |
---|
1158 | | - phy->attached_dev_type == SAS_FANOUT_EXPANDER_DEVICE) && |
---|
| 1125 | + if (dev_is_expander(phy->attached_dev_type) && |
---|
1159 | 1126 | phy->routing_attr == SUBTRACTIVE_ROUTING) { |
---|
1160 | 1127 | |
---|
1161 | | - memcpy(sub_addr, phy->attached_sas_addr,SAS_ADDR_SIZE); |
---|
| 1128 | + memcpy(sub_addr, phy->attached_sas_addr, SAS_ADDR_SIZE); |
---|
1162 | 1129 | |
---|
1163 | 1130 | return 1; |
---|
1164 | 1131 | } |
---|
.. | .. |
---|
1170 | 1137 | { |
---|
1171 | 1138 | struct expander_device *ex = &dev->ex_dev; |
---|
1172 | 1139 | struct domain_device *child; |
---|
1173 | | - u8 sub_addr[8] = {0, }; |
---|
| 1140 | + u8 sub_addr[SAS_ADDR_SIZE] = {0, }; |
---|
1174 | 1141 | |
---|
1175 | 1142 | list_for_each_entry(child, &ex->children, siblings) { |
---|
1176 | | - if (child->dev_type != SAS_EDGE_EXPANDER_DEVICE && |
---|
1177 | | - child->dev_type != SAS_FANOUT_EXPANDER_DEVICE) |
---|
| 1143 | + if (!dev_is_expander(child->dev_type)) |
---|
1178 | 1144 | continue; |
---|
1179 | 1145 | if (sub_addr[0] == 0) { |
---|
1180 | 1146 | sas_find_sub_addr(child, sub_addr); |
---|
1181 | 1147 | continue; |
---|
1182 | 1148 | } else { |
---|
1183 | | - u8 s2[8]; |
---|
| 1149 | + u8 s2[SAS_ADDR_SIZE]; |
---|
1184 | 1150 | |
---|
1185 | 1151 | if (sas_find_sub_addr(child, s2) && |
---|
1186 | 1152 | (SAS_ADDR(sub_addr) != SAS_ADDR(s2))) { |
---|
1187 | 1153 | |
---|
1188 | | - SAS_DPRINTK("ex %016llx->%016llx-?->%016llx " |
---|
1189 | | - "diverges from subtractive " |
---|
1190 | | - "boundary %016llx\n", |
---|
1191 | | - SAS_ADDR(dev->sas_addr), |
---|
1192 | | - SAS_ADDR(child->sas_addr), |
---|
1193 | | - SAS_ADDR(s2), |
---|
1194 | | - SAS_ADDR(sub_addr)); |
---|
| 1154 | + pr_notice("ex %016llx->%016llx-?->%016llx diverges from subtractive boundary %016llx\n", |
---|
| 1155 | + SAS_ADDR(dev->sas_addr), |
---|
| 1156 | + SAS_ADDR(child->sas_addr), |
---|
| 1157 | + SAS_ADDR(s2), |
---|
| 1158 | + SAS_ADDR(sub_addr)); |
---|
1195 | 1159 | |
---|
1196 | 1160 | sas_ex_disable_port(child, s2); |
---|
1197 | 1161 | } |
---|
.. | .. |
---|
1261 | 1225 | phy->phy_state == PHY_NOT_PRESENT) |
---|
1262 | 1226 | continue; |
---|
1263 | 1227 | |
---|
1264 | | - if ((phy->attached_dev_type == SAS_FANOUT_EXPANDER_DEVICE || |
---|
1265 | | - phy->attached_dev_type == SAS_EDGE_EXPANDER_DEVICE) && |
---|
| 1228 | + if (dev_is_expander(phy->attached_dev_type) && |
---|
1266 | 1229 | phy->routing_attr == SUBTRACTIVE_ROUTING) { |
---|
1267 | 1230 | |
---|
1268 | 1231 | if (!sub_sas_addr) |
---|
.. | .. |
---|
1270 | 1233 | else if (SAS_ADDR(sub_sas_addr) != |
---|
1271 | 1234 | SAS_ADDR(phy->attached_sas_addr)) { |
---|
1272 | 1235 | |
---|
1273 | | - SAS_DPRINTK("ex %016llx phy 0x%x " |
---|
1274 | | - "diverges(%016llx) on subtractive " |
---|
1275 | | - "boundary(%016llx). Disabled\n", |
---|
1276 | | - SAS_ADDR(dev->sas_addr), i, |
---|
1277 | | - SAS_ADDR(phy->attached_sas_addr), |
---|
1278 | | - SAS_ADDR(sub_sas_addr)); |
---|
| 1236 | + pr_notice("ex %016llx phy%02d diverges(%016llx) on subtractive boundary(%016llx). Disabled\n", |
---|
| 1237 | + SAS_ADDR(dev->sas_addr), i, |
---|
| 1238 | + SAS_ADDR(phy->attached_sas_addr), |
---|
| 1239 | + SAS_ADDR(sub_sas_addr)); |
---|
1279 | 1240 | sas_ex_disable_phy(dev, i); |
---|
1280 | 1241 | } |
---|
1281 | 1242 | } |
---|
.. | .. |
---|
1293 | 1254 | }; |
---|
1294 | 1255 | struct domain_device *parent = child->parent; |
---|
1295 | 1256 | |
---|
1296 | | - sas_printk("%s ex %016llx phy 0x%x <--> %s ex %016llx " |
---|
1297 | | - "phy 0x%x has %c:%c routing link!\n", |
---|
| 1257 | + pr_notice("%s ex %016llx phy%02d <--> %s ex %016llx phy%02d has %c:%c routing link!\n", |
---|
| 1258 | + ex_type[parent->dev_type], |
---|
| 1259 | + SAS_ADDR(parent->sas_addr), |
---|
| 1260 | + parent_phy->phy_id, |
---|
1298 | 1261 | |
---|
1299 | | - ex_type[parent->dev_type], |
---|
1300 | | - SAS_ADDR(parent->sas_addr), |
---|
1301 | | - parent_phy->phy_id, |
---|
| 1262 | + ex_type[child->dev_type], |
---|
| 1263 | + SAS_ADDR(child->sas_addr), |
---|
| 1264 | + child_phy->phy_id, |
---|
1302 | 1265 | |
---|
1303 | | - ex_type[child->dev_type], |
---|
1304 | | - SAS_ADDR(child->sas_addr), |
---|
1305 | | - child_phy->phy_id, |
---|
1306 | | - |
---|
1307 | | - sas_route_char(parent, parent_phy), |
---|
1308 | | - sas_route_char(child, child_phy)); |
---|
| 1266 | + sas_route_char(parent, parent_phy), |
---|
| 1267 | + sas_route_char(child, child_phy)); |
---|
1309 | 1268 | } |
---|
1310 | 1269 | |
---|
1311 | 1270 | static int sas_check_eeds(struct domain_device *child, |
---|
.. | .. |
---|
1317 | 1276 | |
---|
1318 | 1277 | if (SAS_ADDR(parent->port->disc.fanout_sas_addr) != 0) { |
---|
1319 | 1278 | res = -ENODEV; |
---|
1320 | | - SAS_DPRINTK("edge ex %016llx phy S:0x%x <--> edge ex %016llx " |
---|
1321 | | - "phy S:0x%x, while there is a fanout ex %016llx\n", |
---|
1322 | | - SAS_ADDR(parent->sas_addr), |
---|
1323 | | - parent_phy->phy_id, |
---|
1324 | | - SAS_ADDR(child->sas_addr), |
---|
1325 | | - child_phy->phy_id, |
---|
1326 | | - SAS_ADDR(parent->port->disc.fanout_sas_addr)); |
---|
| 1279 | + pr_warn("edge ex %016llx phy S:%02d <--> edge ex %016llx phy S:%02d, while there is a fanout ex %016llx\n", |
---|
| 1280 | + SAS_ADDR(parent->sas_addr), |
---|
| 1281 | + parent_phy->phy_id, |
---|
| 1282 | + SAS_ADDR(child->sas_addr), |
---|
| 1283 | + child_phy->phy_id, |
---|
| 1284 | + SAS_ADDR(parent->port->disc.fanout_sas_addr)); |
---|
1327 | 1285 | } else if (SAS_ADDR(parent->port->disc.eeds_a) == 0) { |
---|
1328 | 1286 | memcpy(parent->port->disc.eeds_a, parent->sas_addr, |
---|
1329 | 1287 | SAS_ADDR_SIZE); |
---|
.. | .. |
---|
1341 | 1299 | ; |
---|
1342 | 1300 | else { |
---|
1343 | 1301 | res = -ENODEV; |
---|
1344 | | - SAS_DPRINTK("edge ex %016llx phy 0x%x <--> edge ex %016llx " |
---|
1345 | | - "phy 0x%x link forms a third EEDS!\n", |
---|
1346 | | - SAS_ADDR(parent->sas_addr), |
---|
1347 | | - parent_phy->phy_id, |
---|
1348 | | - SAS_ADDR(child->sas_addr), |
---|
1349 | | - child_phy->phy_id); |
---|
| 1302 | + pr_warn("edge ex %016llx phy%02d <--> edge ex %016llx phy%02d link forms a third EEDS!\n", |
---|
| 1303 | + SAS_ADDR(parent->sas_addr), |
---|
| 1304 | + parent_phy->phy_id, |
---|
| 1305 | + SAS_ADDR(child->sas_addr), |
---|
| 1306 | + child_phy->phy_id); |
---|
1350 | 1307 | } |
---|
1351 | 1308 | |
---|
1352 | 1309 | return res; |
---|
.. | .. |
---|
1364 | 1321 | if (!child->parent) |
---|
1365 | 1322 | return 0; |
---|
1366 | 1323 | |
---|
1367 | | - if (child->parent->dev_type != SAS_EDGE_EXPANDER_DEVICE && |
---|
1368 | | - child->parent->dev_type != SAS_FANOUT_EXPANDER_DEVICE) |
---|
| 1324 | + if (!dev_is_expander(child->parent->dev_type)) |
---|
1369 | 1325 | return 0; |
---|
1370 | 1326 | |
---|
1371 | 1327 | parent_ex = &child->parent->ex_dev; |
---|
.. | .. |
---|
1460 | 1416 | goto out; |
---|
1461 | 1417 | res = rri_resp[2]; |
---|
1462 | 1418 | if (res == SMP_RESP_NO_INDEX) { |
---|
1463 | | - SAS_DPRINTK("overflow of indexes: dev %016llx " |
---|
1464 | | - "phy 0x%x index 0x%x\n", |
---|
1465 | | - SAS_ADDR(dev->sas_addr), phy_id, i); |
---|
| 1419 | + pr_warn("overflow of indexes: dev %016llx phy%02d index 0x%x\n", |
---|
| 1420 | + SAS_ADDR(dev->sas_addr), phy_id, i); |
---|
1466 | 1421 | goto out; |
---|
1467 | 1422 | } else if (res != SMP_RESP_FUNC_ACC) { |
---|
1468 | | - SAS_DPRINTK("%s: dev %016llx phy 0x%x index 0x%x " |
---|
1469 | | - "result 0x%x\n", __func__, |
---|
1470 | | - SAS_ADDR(dev->sas_addr), phy_id, i, res); |
---|
| 1423 | + pr_notice("%s: dev %016llx phy%02d index 0x%x result 0x%x\n", |
---|
| 1424 | + __func__, SAS_ADDR(dev->sas_addr), phy_id, |
---|
| 1425 | + i, res); |
---|
1471 | 1426 | goto out; |
---|
1472 | 1427 | } |
---|
1473 | 1428 | if (SAS_ADDR(sas_addr) != 0) { |
---|
.. | .. |
---|
1531 | 1486 | goto out; |
---|
1532 | 1487 | res = cri_resp[2]; |
---|
1533 | 1488 | if (res == SMP_RESP_NO_INDEX) { |
---|
1534 | | - SAS_DPRINTK("overflow of indexes: dev %016llx phy 0x%x " |
---|
1535 | | - "index 0x%x\n", |
---|
1536 | | - SAS_ADDR(dev->sas_addr), phy_id, index); |
---|
| 1489 | + pr_warn("overflow of indexes: dev %016llx phy%02d index 0x%x\n", |
---|
| 1490 | + SAS_ADDR(dev->sas_addr), phy_id, index); |
---|
1537 | 1491 | } |
---|
1538 | 1492 | out: |
---|
1539 | 1493 | kfree(cri_req); |
---|
.. | .. |
---|
1580 | 1534 | } |
---|
1581 | 1535 | |
---|
1582 | 1536 | if (ex_parent->conf_route_table == 0) { |
---|
1583 | | - SAS_DPRINTK("ex %016llx has self-configuring routing table\n", |
---|
1584 | | - SAS_ADDR(parent->sas_addr)); |
---|
| 1537 | + pr_debug("ex %016llx has self-configuring routing table\n", |
---|
| 1538 | + SAS_ADDR(parent->sas_addr)); |
---|
1585 | 1539 | return 0; |
---|
1586 | 1540 | } |
---|
1587 | 1541 | |
---|
.. | .. |
---|
1642 | 1596 | |
---|
1643 | 1597 | res = sas_expander_discover(dev); |
---|
1644 | 1598 | if (res) { |
---|
1645 | | - SAS_DPRINTK("expander %016llx discovery failed(0x%x)\n", |
---|
1646 | | - SAS_ADDR(dev->sas_addr), res); |
---|
| 1599 | + pr_warn("expander %016llx discovery failed(0x%x)\n", |
---|
| 1600 | + SAS_ADDR(dev->sas_addr), res); |
---|
1647 | 1601 | goto out_err; |
---|
1648 | 1602 | } |
---|
1649 | 1603 | |
---|
.. | .. |
---|
1663 | 1617 | struct domain_device *dev; |
---|
1664 | 1618 | |
---|
1665 | 1619 | list_for_each_entry(dev, &port->dev_list, dev_list_node) { |
---|
1666 | | - if (dev->dev_type == SAS_EDGE_EXPANDER_DEVICE || |
---|
1667 | | - dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE) { |
---|
| 1620 | + if (dev_is_expander(dev->dev_type)) { |
---|
1668 | 1621 | struct sas_expander_device *ex = |
---|
1669 | 1622 | rphy_to_expander_device(dev->rphy); |
---|
1670 | 1623 | |
---|
.. | .. |
---|
1777 | 1730 | |
---|
1778 | 1731 | res = sas_get_phy_discover(dev, phy_id, disc_resp); |
---|
1779 | 1732 | if (res == 0) { |
---|
1780 | | - memcpy(sas_addr, disc_resp->disc.attached_sas_addr, 8); |
---|
| 1733 | + memcpy(sas_addr, disc_resp->disc.attached_sas_addr, |
---|
| 1734 | + SAS_ADDR_SIZE); |
---|
1781 | 1735 | *type = to_dev_type(dr); |
---|
1782 | 1736 | if (*type == 0) |
---|
1783 | | - memset(sas_addr, 0, 8); |
---|
| 1737 | + memset(sas_addr, 0, SAS_ADDR_SIZE); |
---|
1784 | 1738 | } |
---|
1785 | 1739 | kfree(disc_resp); |
---|
1786 | 1740 | return res; |
---|
.. | .. |
---|
1887 | 1841 | if (phy_id != -1) { |
---|
1888 | 1842 | *src_dev = dev; |
---|
1889 | 1843 | ex->ex_change_count = ex_change_count; |
---|
1890 | | - SAS_DPRINTK("Expander phy change count has changed\n"); |
---|
| 1844 | + pr_info("ex %016llx phy%02d change count has changed\n", |
---|
| 1845 | + SAS_ADDR(dev->sas_addr), phy_id); |
---|
1891 | 1846 | return res; |
---|
1892 | 1847 | } else |
---|
1893 | | - SAS_DPRINTK("Expander phys DID NOT change\n"); |
---|
| 1848 | + pr_info("ex %016llx phys DID NOT change\n", |
---|
| 1849 | + SAS_ADDR(dev->sas_addr)); |
---|
1894 | 1850 | } |
---|
1895 | 1851 | list_for_each_entry(ch, &ex->children, siblings) { |
---|
1896 | | - if (ch->dev_type == SAS_EDGE_EXPANDER_DEVICE || ch->dev_type == SAS_FANOUT_EXPANDER_DEVICE) { |
---|
| 1852 | + if (dev_is_expander(ch->dev_type)) { |
---|
1897 | 1853 | res = sas_find_bcast_dev(ch, src_dev); |
---|
1898 | 1854 | if (*src_dev) |
---|
1899 | 1855 | return res; |
---|
.. | .. |
---|
1910 | 1866 | |
---|
1911 | 1867 | list_for_each_entry_safe(child, n, &ex->children, siblings) { |
---|
1912 | 1868 | set_bit(SAS_DEV_GONE, &child->state); |
---|
1913 | | - if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE || |
---|
1914 | | - child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) |
---|
| 1869 | + if (dev_is_expander(child->dev_type)) |
---|
1915 | 1870 | sas_unregister_ex_tree(port, child); |
---|
1916 | 1871 | else |
---|
1917 | 1872 | sas_unregister_dev(port, child); |
---|
.. | .. |
---|
1931 | 1886 | if (SAS_ADDR(child->sas_addr) == |
---|
1932 | 1887 | SAS_ADDR(phy->attached_sas_addr)) { |
---|
1933 | 1888 | set_bit(SAS_DEV_GONE, &child->state); |
---|
1934 | | - if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE || |
---|
1935 | | - child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) |
---|
| 1889 | + if (dev_is_expander(child->dev_type)) |
---|
1936 | 1890 | sas_unregister_ex_tree(parent->port, child); |
---|
1937 | 1891 | else |
---|
1938 | 1892 | sas_unregister_dev(parent->port, child); |
---|
.. | .. |
---|
1961 | 1915 | int res = 0; |
---|
1962 | 1916 | |
---|
1963 | 1917 | list_for_each_entry(child, &ex_root->children, siblings) { |
---|
1964 | | - if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE || |
---|
1965 | | - child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) { |
---|
| 1918 | + if (dev_is_expander(child->dev_type)) { |
---|
1966 | 1919 | struct sas_expander_device *ex = |
---|
1967 | 1920 | rphy_to_expander_device(child->rphy); |
---|
1968 | 1921 | |
---|
.. | .. |
---|
2000 | 1953 | struct domain_device *child; |
---|
2001 | 1954 | int res; |
---|
2002 | 1955 | |
---|
2003 | | - SAS_DPRINTK("ex %016llx phy%d new device attached\n", |
---|
2004 | | - SAS_ADDR(dev->sas_addr), phy_id); |
---|
| 1956 | + pr_debug("ex %016llx phy%02d new device attached\n", |
---|
| 1957 | + SAS_ADDR(dev->sas_addr), phy_id); |
---|
2005 | 1958 | res = sas_ex_phy_discover(dev, phy_id); |
---|
2006 | 1959 | if (res) |
---|
2007 | 1960 | return res; |
---|
.. | .. |
---|
2015 | 1968 | list_for_each_entry(child, &dev->ex_dev.children, siblings) { |
---|
2016 | 1969 | if (SAS_ADDR(child->sas_addr) == |
---|
2017 | 1970 | SAS_ADDR(ex_phy->attached_sas_addr)) { |
---|
2018 | | - if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE || |
---|
2019 | | - child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) |
---|
| 1971 | + if (dev_is_expander(child->dev_type)) |
---|
2020 | 1972 | res = sas_discover_bfs_by_root(child); |
---|
2021 | 1973 | break; |
---|
2022 | 1974 | } |
---|
.. | .. |
---|
2039 | 1991 | return false; |
---|
2040 | 1992 | } |
---|
2041 | 1993 | |
---|
2042 | | -static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last) |
---|
| 1994 | +static int sas_rediscover_dev(struct domain_device *dev, int phy_id, |
---|
| 1995 | + bool last, int sibling) |
---|
2043 | 1996 | { |
---|
2044 | 1997 | struct expander_device *ex = &dev->ex_dev; |
---|
2045 | 1998 | struct ex_phy *phy = &ex->ex_phy[phy_id]; |
---|
2046 | 1999 | enum sas_device_type type = SAS_PHY_UNUSED; |
---|
2047 | | - u8 sas_addr[8]; |
---|
| 2000 | + u8 sas_addr[SAS_ADDR_SIZE]; |
---|
| 2001 | + char msg[80] = ""; |
---|
2048 | 2002 | int res; |
---|
2049 | 2003 | |
---|
2050 | | - memset(sas_addr, 0, 8); |
---|
| 2004 | + if (!last) |
---|
| 2005 | + sprintf(msg, ", part of a wide port with phy%02d", sibling); |
---|
| 2006 | + |
---|
| 2007 | + pr_debug("ex %016llx rediscovering phy%02d%s\n", |
---|
| 2008 | + SAS_ADDR(dev->sas_addr), phy_id, msg); |
---|
| 2009 | + |
---|
| 2010 | + memset(sas_addr, 0, SAS_ADDR_SIZE); |
---|
2051 | 2011 | res = sas_get_phy_attached_dev(dev, phy_id, sas_addr, &type); |
---|
2052 | 2012 | switch (res) { |
---|
2053 | 2013 | case SMP_RESP_NO_PHY: |
---|
.. | .. |
---|
2084 | 2044 | |
---|
2085 | 2045 | if (ata_dev && phy->attached_dev_type == SAS_SATA_PENDING) |
---|
2086 | 2046 | action = ", needs recovery"; |
---|
2087 | | - SAS_DPRINTK("ex %016llx phy 0x%x broadcast flutter%s\n", |
---|
2088 | | - SAS_ADDR(dev->sas_addr), phy_id, action); |
---|
| 2047 | + pr_debug("ex %016llx phy%02d broadcast flutter%s\n", |
---|
| 2048 | + SAS_ADDR(dev->sas_addr), phy_id, action); |
---|
2089 | 2049 | return res; |
---|
2090 | 2050 | } |
---|
2091 | 2051 | |
---|
2092 | 2052 | /* we always have to delete the old device when we went here */ |
---|
2093 | | - SAS_DPRINTK("ex %016llx phy 0x%x replace %016llx\n", |
---|
2094 | | - SAS_ADDR(dev->sas_addr), phy_id, |
---|
2095 | | - SAS_ADDR(phy->attached_sas_addr)); |
---|
| 2053 | + pr_info("ex %016llx phy%02d replace %016llx\n", |
---|
| 2054 | + SAS_ADDR(dev->sas_addr), phy_id, |
---|
| 2055 | + SAS_ADDR(phy->attached_sas_addr)); |
---|
2096 | 2056 | sas_unregister_devs_sas_addr(dev, phy_id, last); |
---|
2097 | 2057 | |
---|
2098 | 2058 | return sas_discover_new(dev, phy_id); |
---|
.. | .. |
---|
2120 | 2080 | int i; |
---|
2121 | 2081 | bool last = true; /* is this the last phy of the port */ |
---|
2122 | 2082 | |
---|
2123 | | - SAS_DPRINTK("ex %016llx phy%d originated BROADCAST(CHANGE)\n", |
---|
2124 | | - SAS_ADDR(dev->sas_addr), phy_id); |
---|
| 2083 | + pr_debug("ex %016llx phy%02d originated BROADCAST(CHANGE)\n", |
---|
| 2084 | + SAS_ADDR(dev->sas_addr), phy_id); |
---|
2125 | 2085 | |
---|
2126 | 2086 | if (SAS_ADDR(changed_phy->attached_sas_addr) != 0) { |
---|
2127 | 2087 | for (i = 0; i < ex->num_phys; i++) { |
---|
.. | .. |
---|
2131 | 2091 | continue; |
---|
2132 | 2092 | if (SAS_ADDR(phy->attached_sas_addr) == |
---|
2133 | 2093 | SAS_ADDR(changed_phy->attached_sas_addr)) { |
---|
2134 | | - SAS_DPRINTK("phy%d part of wide port with " |
---|
2135 | | - "phy%d\n", phy_id, i); |
---|
2136 | 2094 | last = false; |
---|
2137 | 2095 | break; |
---|
2138 | 2096 | } |
---|
2139 | 2097 | } |
---|
2140 | | - res = sas_rediscover_dev(dev, phy_id, last); |
---|
| 2098 | + res = sas_rediscover_dev(dev, phy_id, last, i); |
---|
2141 | 2099 | } else |
---|
2142 | 2100 | res = sas_discover_new(dev, phy_id); |
---|
2143 | 2101 | return res; |
---|
.. | .. |
---|
2190 | 2148 | case SAS_FANOUT_EXPANDER_DEVICE: |
---|
2191 | 2149 | break; |
---|
2192 | 2150 | default: |
---|
2193 | | - printk("%s: can we send a smp request to a device?\n", |
---|
| 2151 | + pr_err("%s: can we send a smp request to a device?\n", |
---|
2194 | 2152 | __func__); |
---|
2195 | 2153 | goto out; |
---|
2196 | 2154 | } |
---|
2197 | 2155 | |
---|
2198 | 2156 | dev = sas_find_dev_by_rphy(rphy); |
---|
2199 | 2157 | if (!dev) { |
---|
2200 | | - printk("%s: fail to find a domain_device?\n", __func__); |
---|
| 2158 | + pr_err("%s: fail to find a domain_device?\n", __func__); |
---|
2201 | 2159 | goto out; |
---|
2202 | 2160 | } |
---|
2203 | 2161 | |
---|
2204 | 2162 | /* do we need to support multiple segments? */ |
---|
2205 | 2163 | if (job->request_payload.sg_cnt > 1 || |
---|
2206 | 2164 | job->reply_payload.sg_cnt > 1) { |
---|
2207 | | - printk("%s: multiple segments req %u, rsp %u\n", |
---|
2208 | | - __func__, job->request_payload.payload_len, |
---|
2209 | | - job->reply_payload.payload_len); |
---|
| 2165 | + pr_info("%s: multiple segments req %u, rsp %u\n", |
---|
| 2166 | + __func__, job->request_payload.payload_len, |
---|
| 2167 | + job->reply_payload.payload_len); |
---|
2210 | 2168 | goto out; |
---|
2211 | 2169 | } |
---|
2212 | 2170 | |
---|