hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/scsi/libsas/sas_port.c
....@@ -1,25 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Serial Attached SCSI (SAS) Port class
34 *
45 * Copyright (C) 2005 Adaptec, Inc. All rights reserved.
56 * 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
- *
237 */
248
259 #include "sas_internal.h"
....@@ -70,7 +54,7 @@
7054 continue;
7155 }
7256
73
- if (dev->dev_type == SAS_EDGE_EXPANDER_DEVICE || dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE) {
57
+ if (dev_is_expander(dev->dev_type)) {
7458 dev->ex_dev.ex_change_count = -1;
7559 for (i = 0; i < dev->ex_dev.num_phys; i++) {
7660 struct ex_phy *phy = &dev->ex_dev.ex_phy[i];
....@@ -95,6 +79,7 @@
9579 int i;
9680 struct sas_ha_struct *sas_ha = phy->ha;
9781 struct asd_sas_port *port = phy->port;
82
+ struct domain_device *port_dev;
9883 struct sas_internal *si =
9984 to_sas_internal(sas_ha->core.shost->transportt);
10085 unsigned long flags;
....@@ -110,9 +95,9 @@
11095 wake_up(&sas_ha->eh_wait_q);
11196 return;
11297 } 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);
116101 return;
117102 }
118103 }
....@@ -125,8 +110,8 @@
125110 if (*(u64 *) port->sas_addr &&
126111 phy_is_wideport_member(port, phy) && port->num_phys > 0) {
127112 /* 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);
130115 break;
131116 }
132117 spin_unlock(&port->phy_list_lock);
....@@ -147,15 +132,15 @@
147132 }
148133
149134 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__);
152136 spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags);
153137 return;
154138 }
155139
156140 /* add the phy to the port */
141
+ port_dev = port->port_dev;
157142 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);
159144 phy->port = port;
160145 port->num_phys++;
161146 port->phy_mask |= (1U << phy->id);
....@@ -180,19 +165,26 @@
180165 }
181166 sas_port_add_phy(port->port, phy->phy);
182167
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));
187172
188
- if (port->port_dev)
189
- port->port_dev->pathways = port->num_phys;
173
+ if (port_dev)
174
+ port_dev->pathways = port->num_phys;
190175
191176 /* Tell the LLDD about this port formation. */
192177 if (si->dft->lldd_port_formed)
193178 si->dft->lldd_port_formed(phy);
194179
195180 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
+ }
196188 flush_workqueue(sas_ha->disco_q);
197189 }
198190
....@@ -255,6 +247,15 @@
255247 spin_unlock(&port->phy_list_lock);
256248 spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags);
257249
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
+
258259 return;
259260 }
260261
....@@ -279,7 +280,7 @@
279280 prim = phy->sas_prim;
280281 spin_unlock_irqrestore(&phy->sas_prim_lock, flags);
281282
282
- SAS_DPRINTK("broadcast received: %d\n", prim);
283
+ pr_debug("broadcast received: %d\n", prim);
283284 sas_discover_event(phy->port, DISCE_REVALIDATE_DOMAIN);
284285
285286 if (phy->port)