| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Serial Attached SCSI (SAS) Port class |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2005 Adaptec, Inc. All rights reserved. |
|---|
| 5 | 6 | * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com> |
|---|
| 6 | | - * |
|---|
| 7 | | - * 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 | 7 | */ |
|---|
| 24 | 8 | |
|---|
| 25 | 9 | #include "sas_internal.h" |
|---|
| .. | .. |
|---|
| 70 | 54 | continue; |
|---|
| 71 | 55 | } |
|---|
| 72 | 56 | |
|---|
| 73 | | - if (dev->dev_type == SAS_EDGE_EXPANDER_DEVICE || dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE) { |
|---|
| 57 | + if (dev_is_expander(dev->dev_type)) { |
|---|
| 74 | 58 | dev->ex_dev.ex_change_count = -1; |
|---|
| 75 | 59 | for (i = 0; i < dev->ex_dev.num_phys; i++) { |
|---|
| 76 | 60 | struct ex_phy *phy = &dev->ex_dev.ex_phy[i]; |
|---|
| .. | .. |
|---|
| 95 | 79 | int i; |
|---|
| 96 | 80 | struct sas_ha_struct *sas_ha = phy->ha; |
|---|
| 97 | 81 | struct asd_sas_port *port = phy->port; |
|---|
| 82 | + struct domain_device *port_dev; |
|---|
| 98 | 83 | struct sas_internal *si = |
|---|
| 99 | 84 | to_sas_internal(sas_ha->core.shost->transportt); |
|---|
| 100 | 85 | unsigned long flags; |
|---|
| .. | .. |
|---|
| 110 | 95 | wake_up(&sas_ha->eh_wait_q); |
|---|
| 111 | 96 | return; |
|---|
| 112 | 97 | } else { |
|---|
| 113 | | - SAS_DPRINTK("%s: phy%d belongs to port%d already(%d)!\n", |
|---|
| 114 | | - __func__, phy->id, phy->port->id, |
|---|
| 115 | | - phy->port->num_phys); |
|---|
| 98 | + pr_info("%s: phy%d belongs to port%d already(%d)!\n", |
|---|
| 99 | + __func__, phy->id, phy->port->id, |
|---|
| 100 | + phy->port->num_phys); |
|---|
| 116 | 101 | return; |
|---|
| 117 | 102 | } |
|---|
| 118 | 103 | } |
|---|
| .. | .. |
|---|
| 125 | 110 | if (*(u64 *) port->sas_addr && |
|---|
| 126 | 111 | phy_is_wideport_member(port, phy) && port->num_phys > 0) { |
|---|
| 127 | 112 | /* wide port */ |
|---|
| 128 | | - SAS_DPRINTK("phy%d matched wide port%d\n", phy->id, |
|---|
| 129 | | - port->id); |
|---|
| 113 | + pr_debug("phy%d matched wide port%d\n", phy->id, |
|---|
| 114 | + port->id); |
|---|
| 130 | 115 | break; |
|---|
| 131 | 116 | } |
|---|
| 132 | 117 | spin_unlock(&port->phy_list_lock); |
|---|
| .. | .. |
|---|
| 147 | 132 | } |
|---|
| 148 | 133 | |
|---|
| 149 | 134 | if (i >= sas_ha->num_phys) { |
|---|
| 150 | | - printk(KERN_NOTICE "%s: couldn't find a free port, bug?\n", |
|---|
| 151 | | - __func__); |
|---|
| 135 | + pr_err("%s: couldn't find a free port, bug?\n", __func__); |
|---|
| 152 | 136 | spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags); |
|---|
| 153 | 137 | return; |
|---|
| 154 | 138 | } |
|---|
| 155 | 139 | |
|---|
| 156 | 140 | /* add the phy to the port */ |
|---|
| 141 | + port_dev = port->port_dev; |
|---|
| 157 | 142 | list_add_tail(&phy->port_phy_el, &port->phy_list); |
|---|
| 158 | | - sas_phy_set_target(phy, port->port_dev); |
|---|
| 143 | + sas_phy_set_target(phy, port_dev); |
|---|
| 159 | 144 | phy->port = port; |
|---|
| 160 | 145 | port->num_phys++; |
|---|
| 161 | 146 | port->phy_mask |= (1U << phy->id); |
|---|
| .. | .. |
|---|
| 180 | 165 | } |
|---|
| 181 | 166 | sas_port_add_phy(port->port, phy->phy); |
|---|
| 182 | 167 | |
|---|
| 183 | | - SAS_DPRINTK("%s added to %s, phy_mask:0x%x (%16llx)\n", |
|---|
| 184 | | - dev_name(&phy->phy->dev), dev_name(&port->port->dev), |
|---|
| 185 | | - port->phy_mask, |
|---|
| 186 | | - SAS_ADDR(port->attached_sas_addr)); |
|---|
| 168 | + pr_debug("%s added to %s, phy_mask:0x%x (%016llx)\n", |
|---|
| 169 | + dev_name(&phy->phy->dev), dev_name(&port->port->dev), |
|---|
| 170 | + port->phy_mask, |
|---|
| 171 | + SAS_ADDR(port->attached_sas_addr)); |
|---|
| 187 | 172 | |
|---|
| 188 | | - if (port->port_dev) |
|---|
| 189 | | - port->port_dev->pathways = port->num_phys; |
|---|
| 173 | + if (port_dev) |
|---|
| 174 | + port_dev->pathways = port->num_phys; |
|---|
| 190 | 175 | |
|---|
| 191 | 176 | /* Tell the LLDD about this port formation. */ |
|---|
| 192 | 177 | if (si->dft->lldd_port_formed) |
|---|
| 193 | 178 | si->dft->lldd_port_formed(phy); |
|---|
| 194 | 179 | |
|---|
| 195 | 180 | sas_discover_event(phy->port, DISCE_DISCOVER_DOMAIN); |
|---|
| 181 | + /* Only insert a revalidate event after initial discovery */ |
|---|
| 182 | + if (port_dev && dev_is_expander(port_dev->dev_type)) { |
|---|
| 183 | + struct expander_device *ex_dev = &port_dev->ex_dev; |
|---|
| 184 | + |
|---|
| 185 | + ex_dev->ex_change_count = -1; |
|---|
| 186 | + sas_discover_event(port, DISCE_REVALIDATE_DOMAIN); |
|---|
| 187 | + } |
|---|
| 196 | 188 | flush_workqueue(sas_ha->disco_q); |
|---|
| 197 | 189 | } |
|---|
| 198 | 190 | |
|---|
| .. | .. |
|---|
| 255 | 247 | spin_unlock(&port->phy_list_lock); |
|---|
| 256 | 248 | spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags); |
|---|
| 257 | 249 | |
|---|
| 250 | + /* Only insert revalidate event if the port still has members */ |
|---|
| 251 | + if (port->port && dev && dev_is_expander(dev->dev_type)) { |
|---|
| 252 | + struct expander_device *ex_dev = &dev->ex_dev; |
|---|
| 253 | + |
|---|
| 254 | + ex_dev->ex_change_count = -1; |
|---|
| 255 | + sas_discover_event(port, DISCE_REVALIDATE_DOMAIN); |
|---|
| 256 | + } |
|---|
| 257 | + flush_workqueue(sas_ha->disco_q); |
|---|
| 258 | + |
|---|
| 258 | 259 | return; |
|---|
| 259 | 260 | } |
|---|
| 260 | 261 | |
|---|
| .. | .. |
|---|
| 279 | 280 | prim = phy->sas_prim; |
|---|
| 280 | 281 | spin_unlock_irqrestore(&phy->sas_prim_lock, flags); |
|---|
| 281 | 282 | |
|---|
| 282 | | - SAS_DPRINTK("broadcast received: %d\n", prim); |
|---|
| 283 | + pr_debug("broadcast received: %d\n", prim); |
|---|
| 283 | 284 | sas_discover_event(phy->port, DISCE_REVALIDATE_DOMAIN); |
|---|
| 284 | 285 | |
|---|
| 285 | 286 | if (phy->port) |
|---|