Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is provided under a dual BSD/GPLv2 license. When using or |
| 3 | * redistributing this file, you may do so under either license. |
| 4 | * |
| 5 | * GPL LICENSE SUMMARY |
| 6 | * |
| 7 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of version 2 of the GNU General Public License as |
| 11 | * published by the Free Software Foundation. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | * The full GNU General Public License is included in this distribution |
| 22 | * in the file called LICENSE.GPL. |
| 23 | * |
| 24 | * BSD LICENSE |
| 25 | * |
| 26 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. |
| 27 | * All rights reserved. |
| 28 | * |
| 29 | * Redistribution and use in source and binary forms, with or without |
| 30 | * modification, are permitted provided that the following conditions |
| 31 | * are met: |
| 32 | * |
| 33 | * * Redistributions of source code must retain the above copyright |
| 34 | * notice, this list of conditions and the following disclaimer. |
| 35 | * * Redistributions in binary form must reproduce the above copyright |
| 36 | * notice, this list of conditions and the following disclaimer in |
| 37 | * the documentation and/or other materials provided with the |
| 38 | * distribution. |
| 39 | * * Neither the name of Intel Corporation nor the names of its |
| 40 | * contributors may be used to endorse or promote products derived |
| 41 | * from this software without specific prior written permission. |
| 42 | * |
| 43 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 44 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 45 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 46 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 47 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 48 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 49 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 50 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 51 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 52 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 53 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 54 | */ |
| 55 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 56 | #include "isci.h" |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 57 | #include "port.h" |
| 58 | #include "request.h" |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 59 | |
| 60 | #define SCIC_SDS_PORT_HARD_RESET_TIMEOUT (1000) |
| 61 | #define SCU_DUMMY_INDEX (0xFFFF) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 62 | |
Dan Williams | e531381 | 2011-05-07 10:11:43 -0700 | [diff] [blame] | 63 | static void isci_port_change_state(struct isci_port *iport, enum isci_status status) |
| 64 | { |
| 65 | unsigned long flags; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 66 | |
Dan Williams | e531381 | 2011-05-07 10:11:43 -0700 | [diff] [blame] | 67 | dev_dbg(&iport->isci_host->pdev->dev, |
| 68 | "%s: iport = %p, state = 0x%x\n", |
| 69 | __func__, iport, status); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 70 | |
Dan Williams | e531381 | 2011-05-07 10:11:43 -0700 | [diff] [blame] | 71 | /* XXX pointless lock */ |
| 72 | spin_lock_irqsave(&iport->state_lock, flags); |
| 73 | iport->status = status; |
| 74 | spin_unlock_irqrestore(&iport->state_lock, flags); |
| 75 | } |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 76 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 77 | static void sci_port_get_protocols(struct isci_port *iport, struct sci_phy_proto *proto) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 78 | { |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 79 | u8 index; |
| 80 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 81 | proto->all = 0; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 82 | for (index = 0; index < SCI_MAX_PHYS; index++) { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 83 | struct isci_phy *iphy = iport->phy_table[index]; |
| 84 | |
| 85 | if (!iphy) |
| 86 | continue; |
| 87 | sci_phy_get_protocols(iphy, proto); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 88 | } |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 91 | static u32 sci_port_get_phys(struct isci_port *iport) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 92 | { |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 93 | u32 index; |
| 94 | u32 mask; |
| 95 | |
| 96 | mask = 0; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 97 | for (index = 0; index < SCI_MAX_PHYS; index++) |
| 98 | if (iport->phy_table[index]) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 99 | mask |= (1 << index); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 100 | |
| 101 | return mask; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 102 | } |
| 103 | |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 104 | /** |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 105 | * sci_port_get_properties() - This method simply returns the properties |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 106 | * regarding the port, such as: physical index, protocols, sas address, etc. |
| 107 | * @port: this parameter specifies the port for which to retrieve the physical |
| 108 | * index. |
| 109 | * @properties: This parameter specifies the properties structure into which to |
| 110 | * copy the requested information. |
| 111 | * |
| 112 | * Indicate if the user specified a valid port. SCI_SUCCESS This value is |
| 113 | * returned if the specified port was valid. SCI_FAILURE_INVALID_PORT This |
| 114 | * value is returned if the specified port is not valid. When this value is |
| 115 | * returned, no data is copied to the properties output parameter. |
| 116 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 117 | static enum sci_status sci_port_get_properties(struct isci_port *iport, |
| 118 | struct sci_port_properties *prop) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 119 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 120 | if (!iport || iport->logical_port_index == SCIC_SDS_DUMMY_PORT) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 121 | return SCI_FAILURE_INVALID_PORT; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 122 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 123 | prop->index = iport->logical_port_index; |
| 124 | prop->phy_mask = sci_port_get_phys(iport); |
| 125 | sci_port_get_sas_address(iport, &prop->local.sas_address); |
| 126 | sci_port_get_protocols(iport, &prop->local.protocols); |
| 127 | sci_port_get_attached_sas_address(iport, &prop->remote.sas_address); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 128 | |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 129 | return SCI_SUCCESS; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 130 | } |
| 131 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 132 | static void sci_port_bcn_enable(struct isci_port *iport) |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 133 | { |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 134 | struct isci_phy *iphy; |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 135 | u32 val; |
| 136 | int i; |
| 137 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 138 | for (i = 0; i < ARRAY_SIZE(iport->phy_table); i++) { |
| 139 | iphy = iport->phy_table[i]; |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 140 | if (!iphy) |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 141 | continue; |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 142 | val = readl(&iphy->link_layer_registers->link_layer_control); |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 143 | /* clear the bit by writing 1. */ |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 144 | writel(val, &iphy->link_layer_registers->link_layer_control); |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 145 | } |
| 146 | } |
| 147 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 148 | /* called under sci_lock to stabilize phy:port associations */ |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 149 | void isci_port_bcn_enable(struct isci_host *ihost, struct isci_port *iport) |
| 150 | { |
| 151 | int i; |
| 152 | |
| 153 | clear_bit(IPORT_BCN_BLOCKED, &iport->flags); |
| 154 | wake_up(&ihost->eventq); |
| 155 | |
| 156 | if (!test_and_clear_bit(IPORT_BCN_PENDING, &iport->flags)) |
| 157 | return; |
| 158 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 159 | for (i = 0; i < ARRAY_SIZE(iport->phy_table); i++) { |
| 160 | struct isci_phy *iphy = iport->phy_table[i]; |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 161 | |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 162 | if (!iphy) |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 163 | continue; |
| 164 | |
| 165 | ihost->sas_ha.notify_port_event(&iphy->sas_phy, |
| 166 | PORTE_BROADCAST_RCVD); |
| 167 | break; |
| 168 | } |
| 169 | } |
| 170 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 171 | static void isci_port_bc_change_received(struct isci_host *ihost, |
| 172 | struct isci_port *iport, |
| 173 | struct isci_phy *iphy) |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 174 | { |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 175 | if (iport && test_bit(IPORT_BCN_BLOCKED, &iport->flags)) { |
| 176 | dev_dbg(&ihost->pdev->dev, |
| 177 | "%s: disabled BCN; isci_phy = %p, sas_phy = %p\n", |
| 178 | __func__, iphy, &iphy->sas_phy); |
| 179 | set_bit(IPORT_BCN_PENDING, &iport->flags); |
| 180 | atomic_inc(&iport->event); |
| 181 | wake_up(&ihost->eventq); |
| 182 | } else { |
| 183 | dev_dbg(&ihost->pdev->dev, |
| 184 | "%s: isci_phy = %p, sas_phy = %p\n", |
| 185 | __func__, iphy, &iphy->sas_phy); |
| 186 | |
| 187 | ihost->sas_ha.notify_port_event(&iphy->sas_phy, |
| 188 | PORTE_BROADCAST_RCVD); |
| 189 | } |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 190 | sci_port_bcn_enable(iport); |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 191 | } |
| 192 | |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 193 | static void isci_port_link_up(struct isci_host *isci_host, |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 194 | struct isci_port *iport, |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 195 | struct isci_phy *iphy) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 196 | { |
| 197 | unsigned long flags; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 198 | struct sci_port_properties properties; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 199 | unsigned long success = true; |
| 200 | |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 201 | BUG_ON(iphy->isci_port != NULL); |
Bartosz Barcinski | 6cb4d6b | 2011-04-12 17:28:43 -0700 | [diff] [blame] | 202 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 203 | iphy->isci_port = iport; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 204 | |
| 205 | dev_dbg(&isci_host->pdev->dev, |
| 206 | "%s: isci_port = %p\n", |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 207 | __func__, iport); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 208 | |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 209 | spin_lock_irqsave(&iphy->sas_phy.frame_rcvd_lock, flags); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 210 | |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 211 | isci_port_change_state(iphy->isci_port, isci_starting); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 212 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 213 | sci_port_get_properties(iport, &properties); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 214 | |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 215 | if (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) { |
Dan Williams | 150fc6f | 2011-02-25 10:25:21 -0800 | [diff] [blame] | 216 | u64 attached_sas_address; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 217 | |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 218 | iphy->sas_phy.oob_mode = SATA_OOB_MODE; |
| 219 | iphy->sas_phy.frame_rcvd_size = sizeof(struct dev_to_host_fis); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 220 | |
| 221 | /* |
| 222 | * For direct-attached SATA devices, the SCI core will |
| 223 | * automagically assign a SAS address to the end device |
| 224 | * for the purpose of creating a port. This SAS address |
| 225 | * will not be the same as assigned to the PHY and needs |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 226 | * to be obtained from struct sci_port_properties properties. |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 227 | */ |
Dan Williams | 150fc6f | 2011-02-25 10:25:21 -0800 | [diff] [blame] | 228 | attached_sas_address = properties.remote.sas_address.high; |
| 229 | attached_sas_address <<= 32; |
| 230 | attached_sas_address |= properties.remote.sas_address.low; |
| 231 | swab64s(&attached_sas_address); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 232 | |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 233 | memcpy(&iphy->sas_phy.attached_sas_addr, |
Dan Williams | 150fc6f | 2011-02-25 10:25:21 -0800 | [diff] [blame] | 234 | &attached_sas_address, sizeof(attached_sas_address)); |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 235 | } else if (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) { |
| 236 | iphy->sas_phy.oob_mode = SAS_OOB_MODE; |
| 237 | iphy->sas_phy.frame_rcvd_size = sizeof(struct sas_identify_frame); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 238 | |
| 239 | /* Copy the attached SAS address from the IAF */ |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 240 | memcpy(iphy->sas_phy.attached_sas_addr, |
| 241 | iphy->frame_rcvd.iaf.sas_addr, SAS_ADDR_SIZE); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 242 | } else { |
| 243 | dev_err(&isci_host->pdev->dev, "%s: unkown target\n", __func__); |
| 244 | success = false; |
| 245 | } |
| 246 | |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 247 | iphy->sas_phy.phy->negotiated_linkrate = sci_phy_linkrate(iphy); |
Dan Williams | 83e5143 | 2011-02-18 09:25:13 -0800 | [diff] [blame] | 248 | |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 249 | spin_unlock_irqrestore(&iphy->sas_phy.frame_rcvd_lock, flags); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 250 | |
| 251 | /* Notify libsas that we have an address frame, if indeed |
| 252 | * we've found an SSP, SMP, or STP target */ |
| 253 | if (success) |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 254 | isci_host->sas_ha.notify_port_event(&iphy->sas_phy, |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 255 | PORTE_BYTES_DMAED); |
| 256 | } |
| 257 | |
| 258 | |
| 259 | /** |
| 260 | * isci_port_link_down() - This function is called by the sci core when a link |
| 261 | * becomes inactive. |
| 262 | * @isci_host: This parameter specifies the isci host object. |
| 263 | * @phy: This parameter specifies the isci phy with the active link. |
| 264 | * @port: This parameter specifies the isci port with the active link. |
| 265 | * |
| 266 | */ |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 267 | static void isci_port_link_down(struct isci_host *isci_host, |
| 268 | struct isci_phy *isci_phy, |
| 269 | struct isci_port *isci_port) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 270 | { |
| 271 | struct isci_remote_device *isci_device; |
| 272 | |
| 273 | dev_dbg(&isci_host->pdev->dev, |
| 274 | "%s: isci_port = %p\n", __func__, isci_port); |
| 275 | |
| 276 | if (isci_port) { |
| 277 | |
| 278 | /* check to see if this is the last phy on this port. */ |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 279 | if (isci_phy->sas_phy.port && |
| 280 | isci_phy->sas_phy.port->num_phys == 1) { |
| 281 | atomic_inc(&isci_port->event); |
| 282 | isci_port_bcn_enable(isci_host, isci_port); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 283 | |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 284 | /* change the state for all devices on this port. The |
| 285 | * next task sent to this device will be returned as |
| 286 | * SAS_TASK_UNDELIVERED, and the scsi mid layer will |
| 287 | * remove the target |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 288 | */ |
| 289 | list_for_each_entry(isci_device, |
| 290 | &isci_port->remote_dev_list, |
| 291 | node) { |
| 292 | dev_dbg(&isci_host->pdev->dev, |
| 293 | "%s: isci_device = %p\n", |
| 294 | __func__, isci_device); |
Dan Williams | 209fae1 | 2011-06-13 17:39:44 -0700 | [diff] [blame] | 295 | set_bit(IDEV_GONE, &isci_device->flags); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | isci_port_change_state(isci_port, isci_stopping); |
| 299 | } |
| 300 | |
| 301 | /* Notify libsas of the borken link, this will trigger calls to our |
| 302 | * isci_port_deformed and isci_dev_gone functions. |
| 303 | */ |
| 304 | sas_phy_disconnected(&isci_phy->sas_phy); |
| 305 | isci_host->sas_ha.notify_phy_event(&isci_phy->sas_phy, |
| 306 | PHYE_LOSS_OF_SIGNAL); |
| 307 | |
| 308 | isci_phy->isci_port = NULL; |
| 309 | |
| 310 | dev_dbg(&isci_host->pdev->dev, |
| 311 | "%s: isci_port = %p - Done\n", __func__, isci_port); |
| 312 | } |
| 313 | |
| 314 | |
| 315 | /** |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 316 | * isci_port_ready() - This function is called by the sci core when a link |
| 317 | * becomes ready. |
| 318 | * @isci_host: This parameter specifies the isci host object. |
| 319 | * @port: This parameter specifies the sci port with the active link. |
| 320 | * |
| 321 | */ |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 322 | static void isci_port_ready(struct isci_host *isci_host, struct isci_port *isci_port) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 323 | { |
| 324 | dev_dbg(&isci_host->pdev->dev, |
| 325 | "%s: isci_port = %p\n", __func__, isci_port); |
| 326 | |
| 327 | complete_all(&isci_port->start_complete); |
| 328 | isci_port_change_state(isci_port, isci_ready); |
| 329 | return; |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * isci_port_not_ready() - This function is called by the sci core when a link |
| 334 | * is not ready. All remote devices on this link will be removed if they are |
| 335 | * in the stopping state. |
| 336 | * @isci_host: This parameter specifies the isci host object. |
| 337 | * @port: This parameter specifies the sci port with the active link. |
| 338 | * |
| 339 | */ |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 340 | static void isci_port_not_ready(struct isci_host *isci_host, struct isci_port *isci_port) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 341 | { |
| 342 | dev_dbg(&isci_host->pdev->dev, |
| 343 | "%s: isci_port = %p\n", __func__, isci_port); |
| 344 | } |
| 345 | |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 346 | static void isci_port_stop_complete(struct isci_host *ihost, |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 347 | struct isci_port *iport, |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 348 | enum sci_status completion_status) |
| 349 | { |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 350 | dev_dbg(&ihost->pdev->dev, "Port stop complete\n"); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 351 | } |
| 352 | |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 353 | /** |
| 354 | * isci_port_hard_reset_complete() - This function is called by the sci core |
| 355 | * when the hard reset complete notification has been received. |
| 356 | * @port: This parameter specifies the sci port with the active link. |
| 357 | * @completion_status: This parameter specifies the core status for the reset |
| 358 | * process. |
| 359 | * |
| 360 | */ |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 361 | static void isci_port_hard_reset_complete(struct isci_port *isci_port, |
| 362 | enum sci_status completion_status) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 363 | { |
| 364 | dev_dbg(&isci_port->isci_host->pdev->dev, |
| 365 | "%s: isci_port = %p, completion_status=%x\n", |
| 366 | __func__, isci_port, completion_status); |
| 367 | |
| 368 | /* Save the status of the hard reset from the port. */ |
| 369 | isci_port->hard_reset_status = completion_status; |
| 370 | |
| 371 | complete_all(&isci_port->hard_reset_complete); |
| 372 | } |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 373 | |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 374 | /* This method will return a true value if the specified phy can be assigned to |
| 375 | * this port The following is a list of phys for each port that are allowed: - |
| 376 | * Port 0 - 3 2 1 0 - Port 1 - 1 - Port 2 - 3 2 - Port 3 - 3 This method |
| 377 | * doesn't preclude all configurations. It merely ensures that a phy is part |
| 378 | * of the allowable set of phy identifiers for that port. For example, one |
| 379 | * could assign phy 3 to port 0 and no other phys. Please refer to |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 380 | * sci_port_is_phy_mask_valid() for information regarding whether the |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 381 | * phy_mask for a port can be supported. bool true if this is a valid phy |
| 382 | * assignment for the port false if this is not a valid phy assignment for the |
| 383 | * port |
| 384 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 385 | bool sci_port_is_valid_phy_assignment(struct isci_port *iport, u32 phy_index) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 386 | { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 387 | struct isci_host *ihost = iport->owning_controller; |
| 388 | struct sci_user_parameters *user = &ihost->user_parameters; |
| 389 | |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 390 | /* Initialize to invalid value. */ |
| 391 | u32 existing_phy_index = SCI_MAX_PHYS; |
| 392 | u32 index; |
| 393 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 394 | if ((iport->physical_port_index == 1) && (phy_index != 1)) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 395 | return false; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 396 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 397 | if (iport->physical_port_index == 3 && phy_index != 3) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 398 | return false; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 399 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 400 | if (iport->physical_port_index == 2 && |
| 401 | (phy_index == 0 || phy_index == 1)) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 402 | return false; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 403 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 404 | for (index = 0; index < SCI_MAX_PHYS; index++) |
| 405 | if (iport->phy_table[index] && index != phy_index) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 406 | existing_phy_index = index; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 407 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 408 | /* Ensure that all of the phys in the port are capable of |
| 409 | * operating at the same maximum link rate. |
| 410 | */ |
| 411 | if (existing_phy_index < SCI_MAX_PHYS && |
| 412 | user->phys[phy_index].max_speed_generation != |
| 413 | user->phys[existing_phy_index].max_speed_generation) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 414 | return false; |
| 415 | |
| 416 | return true; |
| 417 | } |
| 418 | |
| 419 | /** |
| 420 | * |
| 421 | * @sci_port: This is the port object for which to determine if the phy mask |
| 422 | * can be supported. |
| 423 | * |
| 424 | * This method will return a true value if the port's phy mask can be supported |
| 425 | * by the SCU. The following is a list of valid PHY mask configurations for |
| 426 | * each port: - Port 0 - [[3 2] 1] 0 - Port 1 - [1] - Port 2 - [[3] 2] |
| 427 | * - Port 3 - [3] This method returns a boolean indication specifying if the |
| 428 | * phy mask can be supported. true if this is a valid phy assignment for the |
| 429 | * port false if this is not a valid phy assignment for the port |
| 430 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 431 | static bool sci_port_is_phy_mask_valid( |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 432 | struct isci_port *iport, |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 433 | u32 phy_mask) |
| 434 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 435 | if (iport->physical_port_index == 0) { |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 436 | if (((phy_mask & 0x0F) == 0x0F) |
| 437 | || ((phy_mask & 0x03) == 0x03) |
| 438 | || ((phy_mask & 0x01) == 0x01) |
| 439 | || (phy_mask == 0)) |
| 440 | return true; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 441 | } else if (iport->physical_port_index == 1) { |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 442 | if (((phy_mask & 0x02) == 0x02) |
| 443 | || (phy_mask == 0)) |
| 444 | return true; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 445 | } else if (iport->physical_port_index == 2) { |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 446 | if (((phy_mask & 0x0C) == 0x0C) |
| 447 | || ((phy_mask & 0x04) == 0x04) |
| 448 | || (phy_mask == 0)) |
| 449 | return true; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 450 | } else if (iport->physical_port_index == 3) { |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 451 | if (((phy_mask & 0x08) == 0x08) |
| 452 | || (phy_mask == 0)) |
| 453 | return true; |
| 454 | } |
| 455 | |
| 456 | return false; |
| 457 | } |
| 458 | |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 459 | /* |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 460 | * This method retrieves a currently active (i.e. connected) phy contained in |
| 461 | * the port. Currently, the lowest order phy that is connected is returned. |
| 462 | * This method returns a pointer to a SCIS_SDS_PHY object. NULL This value is |
| 463 | * returned if there are no currently active (i.e. connected to a remote end |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 464 | * point) phys contained in the port. All other values specify a struct sci_phy |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 465 | * object that is active in the port. |
| 466 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 467 | static struct isci_phy *sci_port_get_a_connected_phy(struct isci_port *iport) |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 468 | { |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 469 | u32 index; |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 470 | struct isci_phy *iphy; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 471 | |
| 472 | for (index = 0; index < SCI_MAX_PHYS; index++) { |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 473 | /* Ensure that the phy is both part of the port and currently |
| 474 | * connected to the remote end-point. |
| 475 | */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 476 | iphy = iport->phy_table[index]; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 477 | if (iphy && sci_port_active_phy(iport, iphy)) |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 478 | return iphy; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | return NULL; |
| 482 | } |
| 483 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 484 | static enum sci_status sci_port_set_phy(struct isci_port *iport, struct isci_phy *iphy) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 485 | { |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 486 | /* Check to see if we can add this phy to a port |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 487 | * that means that the phy is not part of a port and that the port does |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 488 | * not already have a phy assinged to the phy index. |
| 489 | */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 490 | if (!iport->phy_table[iphy->phy_index] && |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 491 | !phy_get_non_dummy_port(iphy) && |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 492 | sci_port_is_valid_phy_assignment(iport, iphy->phy_index)) { |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 493 | /* Phy is being added in the stopped state so we are in MPC mode |
| 494 | * make logical port index = physical port index |
| 495 | */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 496 | iport->logical_port_index = iport->physical_port_index; |
| 497 | iport->phy_table[iphy->phy_index] = iphy; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 498 | sci_phy_set_port(iphy, iport); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 499 | |
| 500 | return SCI_SUCCESS; |
| 501 | } |
| 502 | |
| 503 | return SCI_FAILURE; |
| 504 | } |
| 505 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 506 | static enum sci_status sci_port_clear_phy(struct isci_port *iport, struct isci_phy *iphy) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 507 | { |
| 508 | /* Make sure that this phy is part of this port */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 509 | if (iport->phy_table[iphy->phy_index] == iphy && |
| 510 | phy_get_non_dummy_port(iphy) == iport) { |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 511 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 512 | |
| 513 | /* Yep it is assigned to this port so remove it */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 514 | sci_phy_set_port(iphy, &ihost->ports[SCI_MAX_PORTS]); |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 515 | iport->phy_table[iphy->phy_index] = NULL; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 516 | return SCI_SUCCESS; |
| 517 | } |
| 518 | |
| 519 | return SCI_FAILURE; |
| 520 | } |
| 521 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 522 | void sci_port_get_sas_address(struct isci_port *iport, struct sci_sas_address *sas) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 523 | { |
| 524 | u32 index; |
| 525 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 526 | sas->high = 0; |
| 527 | sas->low = 0; |
| 528 | for (index = 0; index < SCI_MAX_PHYS; index++) |
| 529 | if (iport->phy_table[index]) |
| 530 | sci_phy_get_sas_address(iport->phy_table[index], sas); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 531 | } |
| 532 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 533 | void sci_port_get_attached_sas_address(struct isci_port *iport, struct sci_sas_address *sas) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 534 | { |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 535 | struct isci_phy *iphy; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 536 | |
| 537 | /* |
| 538 | * Ensure that the phy is both part of the port and currently |
| 539 | * connected to the remote end-point. |
| 540 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 541 | iphy = sci_port_get_a_connected_phy(iport); |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 542 | if (iphy) { |
| 543 | if (iphy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA) { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 544 | sci_phy_get_attached_sas_address(iphy, sas); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 545 | } else { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 546 | sci_phy_get_sas_address(iphy, sas); |
| 547 | sas->low += iphy->phy_index; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 548 | } |
| 549 | } else { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 550 | sas->high = 0; |
| 551 | sas->low = 0; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 552 | } |
| 553 | } |
| 554 | |
| 555 | /** |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 556 | * sci_port_construct_dummy_rnc() - create dummy rnc for si workaround |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 557 | * |
| 558 | * @sci_port: logical port on which we need to create the remote node context |
| 559 | * @rni: remote node index for this remote node context. |
| 560 | * |
| 561 | * This routine will construct a dummy remote node context data structure |
| 562 | * This structure will be posted to the hardware to work around a scheduler |
| 563 | * error in the hardware. |
| 564 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 565 | static void sci_port_construct_dummy_rnc(struct isci_port *iport, u16 rni) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 566 | { |
| 567 | union scu_remote_node_context *rnc; |
| 568 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 569 | rnc = &iport->owning_controller->remote_node_context_table[rni]; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 570 | |
| 571 | memset(rnc, 0, sizeof(union scu_remote_node_context)); |
| 572 | |
| 573 | rnc->ssp.remote_sas_address_hi = 0; |
| 574 | rnc->ssp.remote_sas_address_lo = 0; |
| 575 | |
| 576 | rnc->ssp.remote_node_index = rni; |
| 577 | rnc->ssp.remote_node_port_width = 1; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 578 | rnc->ssp.logical_port_index = iport->physical_port_index; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 579 | |
| 580 | rnc->ssp.nexus_loss_timer_enable = false; |
| 581 | rnc->ssp.check_bit = false; |
| 582 | rnc->ssp.is_valid = true; |
| 583 | rnc->ssp.is_remote_node_context = true; |
| 584 | rnc->ssp.function_number = 0; |
| 585 | rnc->ssp.arbitration_wait_time = 0; |
| 586 | } |
| 587 | |
Dan Williams | dd047c8 | 2011-06-09 11:06:58 -0700 | [diff] [blame] | 588 | /* |
| 589 | * construct a dummy task context data structure. This |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 590 | * structure will be posted to the hardwre to work around a scheduler error |
| 591 | * in the hardware. |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 592 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 593 | static void sci_port_construct_dummy_task(struct isci_port *iport, u16 tag) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 594 | { |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 595 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 596 | struct scu_task_context *task_context; |
| 597 | |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 598 | task_context = &ihost->task_context_table[ISCI_TAG_TCI(tag)]; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 599 | memset(task_context, 0, sizeof(struct scu_task_context)); |
| 600 | |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 601 | task_context->initiator_request = 1; |
| 602 | task_context->connection_rate = 1; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 603 | task_context->logical_port_index = iport->physical_port_index; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 604 | task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP; |
Dan Williams | dd047c8 | 2011-06-09 11:06:58 -0700 | [diff] [blame] | 605 | task_context->task_index = ISCI_TAG_TCI(tag); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 606 | task_context->valid = SCU_TASK_CONTEXT_VALID; |
| 607 | task_context->context_type = SCU_TASK_CONTEXT_TYPE; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 608 | task_context->remote_node_index = iport->reserved_rni; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 609 | task_context->do_not_dma_ssp_good_response = 1; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 610 | task_context->task_phase = 0x01; |
| 611 | } |
| 612 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 613 | static void sci_port_destroy_dummy_resources(struct isci_port *iport) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 614 | { |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 615 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 616 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 617 | if (iport->reserved_tag != SCI_CONTROLLER_INVALID_IO_TAG) |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 618 | isci_free_tag(ihost, iport->reserved_tag); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 619 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 620 | if (iport->reserved_rni != SCU_DUMMY_INDEX) |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 621 | sci_remote_node_table_release_remote_node_index(&ihost->available_remote_nodes, |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 622 | 1, iport->reserved_rni); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 623 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 624 | iport->reserved_rni = SCU_DUMMY_INDEX; |
| 625 | iport->reserved_tag = SCI_CONTROLLER_INVALID_IO_TAG; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 626 | } |
| 627 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 628 | void sci_port_setup_transports(struct isci_port *iport, u32 device_id) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 629 | { |
| 630 | u8 index; |
| 631 | |
| 632 | for (index = 0; index < SCI_MAX_PHYS; index++) { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 633 | if (iport->active_phy_mask & (1 << index)) |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 634 | sci_phy_setup_transport(iport->phy_table[index], device_id); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 635 | } |
| 636 | } |
| 637 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 638 | static void sci_port_activate_phy(struct isci_port *iport, struct isci_phy *iphy, |
| 639 | bool do_notify_user) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 640 | { |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 641 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 642 | |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 643 | if (iphy->protocol != SCIC_SDS_PHY_PROTOCOL_SATA) |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 644 | sci_phy_resume(iphy); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 645 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 646 | iport->active_phy_mask |= 1 << iphy->phy_index; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 647 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 648 | sci_controller_clear_invalid_phy(ihost, iphy); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 649 | |
| 650 | if (do_notify_user == true) |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 651 | isci_port_link_up(ihost, iport, iphy); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 652 | } |
| 653 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 654 | void sci_port_deactivate_phy(struct isci_port *iport, struct isci_phy *iphy, |
| 655 | bool do_notify_user) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 656 | { |
Dan Williams | 34a9915 | 2011-07-01 02:25:15 -0700 | [diff] [blame^] | 657 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 658 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 659 | iport->active_phy_mask &= ~(1 << iphy->phy_index); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 660 | |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 661 | iphy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 662 | |
| 663 | /* Re-assign the phy back to the LP as if it were a narrow port */ |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 664 | writel(iphy->phy_index, |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 665 | &iport->port_pe_configuration_register[iphy->phy_index]); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 666 | |
| 667 | if (do_notify_user == true) |
| 668 | isci_port_link_down(ihost, iphy, iport); |
| 669 | } |
| 670 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 671 | static void sci_port_invalid_link_up(struct isci_port *iport, struct isci_phy *iphy) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 672 | { |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 673 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 674 | |
| 675 | /* |
| 676 | * Check to see if we have alreay reported this link as bad and if |
| 677 | * not go ahead and tell the SCI_USER that we have discovered an |
| 678 | * invalid link. |
| 679 | */ |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 680 | if ((ihost->invalid_phy_mask & (1 << iphy->phy_index)) == 0) { |
Dan Williams | 34a9915 | 2011-07-01 02:25:15 -0700 | [diff] [blame^] | 681 | ihost->invalid_phy_mask |= 1 << iphy->phy_index; |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 682 | dev_warn(&ihost->pdev->dev, "Invalid link up!\n"); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 683 | } |
| 684 | } |
| 685 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 686 | static bool is_port_ready_state(enum sci_port_states state) |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 687 | { |
| 688 | switch (state) { |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 689 | case SCI_PORT_READY: |
| 690 | case SCI_PORT_SUB_WAITING: |
| 691 | case SCI_PORT_SUB_OPERATIONAL: |
| 692 | case SCI_PORT_SUB_CONFIGURING: |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 693 | return true; |
| 694 | default: |
| 695 | return false; |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | /* flag dummy rnc hanling when exiting a ready state */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 700 | static void port_state_machine_change(struct isci_port *iport, |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 701 | enum sci_port_states state) |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 702 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 703 | struct sci_base_state_machine *sm = &iport->sm; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 704 | enum sci_port_states old_state = sm->current_state_id; |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 705 | |
| 706 | if (is_port_ready_state(old_state) && !is_port_ready_state(state)) |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 707 | iport->ready_exit = true; |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 708 | |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 709 | sci_change_state(sm, state); |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 710 | iport->ready_exit = false; |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 711 | } |
| 712 | |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 713 | /** |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 714 | * sci_port_general_link_up_handler - phy can be assigned to port? |
| 715 | * @sci_port: sci_port object for which has a phy that has gone link up. |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 716 | * @sci_phy: This is the struct isci_phy object that has gone link up. |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 717 | * @do_notify_user: This parameter specifies whether to inform the user (via |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 718 | * sci_port_link_up()) as to the fact that a new phy as become ready. |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 719 | * |
| 720 | * Determine if this phy can be assigned to this |
| 721 | * port . If the phy is not a valid PHY for |
| 722 | * this port then the function will notify the user. A PHY can only be |
| 723 | * part of a port if it's attached SAS ADDRESS is the same as all other PHYs in |
| 724 | * the same port. none |
| 725 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 726 | static void sci_port_general_link_up_handler(struct isci_port *iport, |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 727 | struct isci_phy *iphy, |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 728 | bool do_notify_user) |
| 729 | { |
| 730 | struct sci_sas_address port_sas_address; |
| 731 | struct sci_sas_address phy_sas_address; |
| 732 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 733 | sci_port_get_attached_sas_address(iport, &port_sas_address); |
| 734 | sci_phy_get_attached_sas_address(iphy, &phy_sas_address); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 735 | |
| 736 | /* If the SAS address of the new phy matches the SAS address of |
| 737 | * other phys in the port OR this is the first phy in the port, |
| 738 | * then activate the phy and allow it to be used for operations |
| 739 | * in this port. |
| 740 | */ |
| 741 | if ((phy_sas_address.high == port_sas_address.high && |
| 742 | phy_sas_address.low == port_sas_address.low) || |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 743 | iport->active_phy_mask == 0) { |
| 744 | struct sci_base_state_machine *sm = &iport->sm; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 745 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 746 | sci_port_activate_phy(iport, iphy, do_notify_user); |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 747 | if (sm->current_state_id == SCI_PORT_RESETTING) |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 748 | port_state_machine_change(iport, SCI_PORT_READY); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 749 | } else |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 750 | sci_port_invalid_link_up(iport, iphy); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 751 | } |
| 752 | |
| 753 | |
| 754 | |
| 755 | /** |
| 756 | * This method returns false if the port only has a single phy object assigned. |
| 757 | * If there are no phys or more than one phy then the method will return |
| 758 | * true. |
| 759 | * @sci_port: The port for which the wide port condition is to be checked. |
| 760 | * |
| 761 | * bool true Is returned if this is a wide ported port. false Is returned if |
| 762 | * this is a narrow port. |
| 763 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 764 | static bool sci_port_is_wide(struct isci_port *iport) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 765 | { |
| 766 | u32 index; |
| 767 | u32 phy_count = 0; |
| 768 | |
| 769 | for (index = 0; index < SCI_MAX_PHYS; index++) { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 770 | if (iport->phy_table[index] != NULL) { |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 771 | phy_count++; |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | return phy_count != 1; |
| 776 | } |
| 777 | |
| 778 | /** |
| 779 | * This method is called by the PHY object when the link is detected. if the |
| 780 | * port wants the PHY to continue on to the link up state then the port |
| 781 | * layer must return true. If the port object returns false the phy object |
| 782 | * must halt its attempt to go link up. |
| 783 | * @sci_port: The port associated with the phy object. |
| 784 | * @sci_phy: The phy object that is trying to go link up. |
| 785 | * |
| 786 | * true if the phy object can continue to the link up condition. true Is |
| 787 | * returned if this phy can continue to the ready state. false Is returned if |
| 788 | * can not continue on to the ready state. This notification is in place for |
| 789 | * wide ports and direct attached phys. Since there are no wide ported SATA |
| 790 | * devices this could become an invalid port configuration. |
| 791 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 792 | bool sci_port_link_detected( |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 793 | struct isci_port *iport, |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 794 | struct isci_phy *iphy) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 795 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 796 | if ((iport->logical_port_index != SCIC_SDS_DUMMY_PORT) && |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 797 | (iphy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) && |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 798 | sci_port_is_wide(iport)) { |
| 799 | sci_port_invalid_link_up(iport, iphy); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 800 | |
| 801 | return false; |
| 802 | } |
| 803 | |
| 804 | return true; |
| 805 | } |
| 806 | |
Edmund Nadolski | 5553ba2 | 2011-05-19 11:59:10 +0000 | [diff] [blame] | 807 | static void port_timeout(unsigned long data) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 808 | { |
Edmund Nadolski | 5553ba2 | 2011-05-19 11:59:10 +0000 | [diff] [blame] | 809 | struct sci_timer *tmr = (struct sci_timer *)data; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 810 | struct isci_port *iport = container_of(tmr, typeof(*iport), timer); |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 811 | struct isci_host *ihost = iport->owning_controller; |
Edmund Nadolski | 5553ba2 | 2011-05-19 11:59:10 +0000 | [diff] [blame] | 812 | unsigned long flags; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 813 | u32 current_state; |
| 814 | |
Edmund Nadolski | 5553ba2 | 2011-05-19 11:59:10 +0000 | [diff] [blame] | 815 | spin_lock_irqsave(&ihost->scic_lock, flags); |
| 816 | |
| 817 | if (tmr->cancel) |
| 818 | goto done; |
| 819 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 820 | current_state = iport->sm.current_state_id; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 821 | |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 822 | if (current_state == SCI_PORT_RESETTING) { |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 823 | /* if the port is still in the resetting state then the timeout |
| 824 | * fired before the reset completed. |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 825 | */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 826 | port_state_machine_change(iport, SCI_PORT_FAILED); |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 827 | } else if (current_state == SCI_PORT_STOPPED) { |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 828 | /* if the port is stopped then the start request failed In this |
| 829 | * case stay in the stopped state. |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 830 | */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 831 | dev_err(sciport_to_dev(iport), |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 832 | "%s: SCIC Port 0x%p failed to stop before tiemout.\n", |
| 833 | __func__, |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 834 | iport); |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 835 | } else if (current_state == SCI_PORT_STOPPING) { |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 836 | /* if the port is still stopping then the stop has not completed */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 837 | isci_port_stop_complete(iport->owning_controller, |
| 838 | iport, |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 839 | SCI_FAILURE_TIMEOUT); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 840 | } else { |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 841 | /* The port is in the ready state and we have a timer |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 842 | * reporting a timeout this should not happen. |
| 843 | */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 844 | dev_err(sciport_to_dev(iport), |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 845 | "%s: SCIC Port 0x%p is processing a timeout operation " |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 846 | "in state %d.\n", __func__, iport, current_state); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 847 | } |
Edmund Nadolski | 5553ba2 | 2011-05-19 11:59:10 +0000 | [diff] [blame] | 848 | |
| 849 | done: |
| 850 | spin_unlock_irqrestore(&ihost->scic_lock, flags); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 851 | } |
| 852 | |
| 853 | /* --------------------------------------------------------------------------- */ |
| 854 | |
| 855 | /** |
| 856 | * This function updates the hardwares VIIT entry for this port. |
| 857 | * |
| 858 | * |
| 859 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 860 | static void sci_port_update_viit_entry(struct isci_port *iport) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 861 | { |
| 862 | struct sci_sas_address sas_address; |
| 863 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 864 | sci_port_get_sas_address(iport, &sas_address); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 865 | |
| 866 | writel(sas_address.high, |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 867 | &iport->viit_registers->initiator_sas_address_hi); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 868 | writel(sas_address.low, |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 869 | &iport->viit_registers->initiator_sas_address_lo); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 870 | |
| 871 | /* This value get cleared just in case its not already cleared */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 872 | writel(0, &iport->viit_registers->reserved); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 873 | |
| 874 | /* We are required to update the status register last */ |
| 875 | writel(SCU_VIIT_ENTRY_ID_VIIT | |
| 876 | SCU_VIIT_IPPT_INITIATOR | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 877 | ((1 << iport->physical_port_index) << SCU_VIIT_ENTRY_LPVIE_SHIFT) | |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 878 | SCU_VIIT_STATUS_ALL_VALID, |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 879 | &iport->viit_registers->status); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 880 | } |
| 881 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 882 | enum sas_linkrate sci_port_get_max_allowed_speed(struct isci_port *iport) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 883 | { |
| 884 | u16 index; |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 885 | struct isci_phy *iphy; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 886 | enum sas_linkrate max_allowed_speed = SAS_LINK_RATE_6_0_GBPS; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 887 | |
| 888 | /* |
| 889 | * Loop through all of the phys in this port and find the phy with the |
| 890 | * lowest maximum link rate. */ |
| 891 | for (index = 0; index < SCI_MAX_PHYS; index++) { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 892 | iphy = iport->phy_table[index]; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 893 | if (iphy && sci_port_active_phy(iport, iphy) && |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 894 | iphy->max_negotiated_speed < max_allowed_speed) |
| 895 | max_allowed_speed = iphy->max_negotiated_speed; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 896 | } |
| 897 | |
| 898 | return max_allowed_speed; |
| 899 | } |
| 900 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 901 | static void sci_port_suspend_port_task_scheduler(struct isci_port *iport) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 902 | { |
| 903 | u32 pts_control_value; |
| 904 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 905 | pts_control_value = readl(&iport->port_task_scheduler_registers->control); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 906 | pts_control_value |= SCU_PTSxCR_GEN_BIT(SUSPEND); |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 907 | writel(pts_control_value, &iport->port_task_scheduler_registers->control); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | /** |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 911 | * sci_port_post_dummy_request() - post dummy/workaround request |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 912 | * @sci_port: port to post task |
| 913 | * |
| 914 | * Prevent the hardware scheduler from posting new requests to the front |
| 915 | * of the scheduler queue causing a starvation problem for currently |
| 916 | * ongoing requests. |
| 917 | * |
| 918 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 919 | static void sci_port_post_dummy_request(struct isci_port *iport) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 920 | { |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 921 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 922 | u16 tag = iport->reserved_tag; |
Dan Williams | 312e0c2 | 2011-06-28 13:47:09 -0700 | [diff] [blame] | 923 | struct scu_task_context *tc; |
| 924 | u32 command; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 925 | |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 926 | tc = &ihost->task_context_table[ISCI_TAG_TCI(tag)]; |
Dan Williams | 312e0c2 | 2011-06-28 13:47:09 -0700 | [diff] [blame] | 927 | tc->abort = 0; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 928 | |
| 929 | command = SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 930 | iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | |
Dan Williams | 312e0c2 | 2011-06-28 13:47:09 -0700 | [diff] [blame] | 931 | ISCI_TAG_TCI(tag); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 932 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 933 | sci_controller_post_request(ihost, command); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 934 | } |
| 935 | |
| 936 | /** |
| 937 | * This routine will abort the dummy request. This will alow the hardware to |
| 938 | * power down parts of the silicon to save power. |
| 939 | * |
| 940 | * @sci_port: The port on which the task must be aborted. |
| 941 | * |
| 942 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 943 | static void sci_port_abort_dummy_request(struct isci_port *iport) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 944 | { |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 945 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 946 | u16 tag = iport->reserved_tag; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 947 | struct scu_task_context *tc; |
| 948 | u32 command; |
| 949 | |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 950 | tc = &ihost->task_context_table[ISCI_TAG_TCI(tag)]; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 951 | tc->abort = 1; |
| 952 | |
| 953 | command = SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 954 | iport->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | |
Dan Williams | 312e0c2 | 2011-06-28 13:47:09 -0700 | [diff] [blame] | 955 | ISCI_TAG_TCI(tag); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 956 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 957 | sci_controller_post_request(ihost, command); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 958 | } |
| 959 | |
| 960 | /** |
| 961 | * |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 962 | * @sci_port: This is the struct isci_port object to resume. |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 963 | * |
| 964 | * This method will resume the port task scheduler for this port object. none |
| 965 | */ |
| 966 | static void |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 967 | sci_port_resume_port_task_scheduler(struct isci_port *iport) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 968 | { |
| 969 | u32 pts_control_value; |
| 970 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 971 | pts_control_value = readl(&iport->port_task_scheduler_registers->control); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 972 | pts_control_value &= ~SCU_PTSxCR_GEN_BIT(SUSPEND); |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 973 | writel(pts_control_value, &iport->port_task_scheduler_registers->control); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 974 | } |
| 975 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 976 | static void sci_port_ready_substate_waiting_enter(struct sci_base_state_machine *sm) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 977 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 978 | struct isci_port *iport = container_of(sm, typeof(*iport), sm); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 979 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 980 | sci_port_suspend_port_task_scheduler(iport); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 981 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 982 | iport->not_ready_reason = SCIC_PORT_NOT_READY_NO_ACTIVE_PHYS; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 983 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 984 | if (iport->active_phy_mask != 0) { |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 985 | /* At least one of the phys on the port is ready */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 986 | port_state_machine_change(iport, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 987 | SCI_PORT_SUB_OPERATIONAL); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 988 | } |
| 989 | } |
| 990 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 991 | static void sci_port_ready_substate_operational_enter(struct sci_base_state_machine *sm) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 992 | { |
| 993 | u32 index; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 994 | struct isci_port *iport = container_of(sm, typeof(*iport), sm); |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 995 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 996 | |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 997 | isci_port_ready(ihost, iport); |
| 998 | |
| 999 | for (index = 0; index < SCI_MAX_PHYS; index++) { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1000 | if (iport->phy_table[index]) { |
| 1001 | writel(iport->physical_port_index, |
| 1002 | &iport->port_pe_configuration_register[ |
| 1003 | iport->phy_table[index]->phy_index]); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1004 | } |
| 1005 | } |
| 1006 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1007 | sci_port_update_viit_entry(iport); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1008 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1009 | sci_port_resume_port_task_scheduler(iport); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1010 | |
| 1011 | /* |
| 1012 | * Post the dummy task for the port so the hardware can schedule |
| 1013 | * io correctly |
| 1014 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1015 | sci_port_post_dummy_request(iport); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1016 | } |
| 1017 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1018 | static void sci_port_invalidate_dummy_remote_node(struct isci_port *iport) |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 1019 | { |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1020 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1021 | u8 phys_index = iport->physical_port_index; |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 1022 | union scu_remote_node_context *rnc; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1023 | u16 rni = iport->reserved_rni; |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 1024 | u32 command; |
| 1025 | |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1026 | rnc = &ihost->remote_node_context_table[rni]; |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 1027 | |
| 1028 | rnc->ssp.is_valid = false; |
| 1029 | |
| 1030 | /* ensure the preceding tc abort request has reached the |
| 1031 | * controller and give it ample time to act before posting the rnc |
| 1032 | * invalidate |
| 1033 | */ |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1034 | readl(&ihost->smu_registers->interrupt_status); /* flush */ |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 1035 | udelay(10); |
| 1036 | |
| 1037 | command = SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE | |
| 1038 | phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni; |
| 1039 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1040 | sci_controller_post_request(ihost, command); |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 1041 | } |
| 1042 | |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1043 | /** |
| 1044 | * |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1045 | * @object: This is the object which is cast to a struct isci_port object. |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1046 | * |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1047 | * This method will perform the actions required by the struct isci_port on |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1048 | * exiting the SCI_PORT_SUB_OPERATIONAL. This function reports |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1049 | * the port not ready and suspends the port task scheduler. none |
| 1050 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1051 | static void sci_port_ready_substate_operational_exit(struct sci_base_state_machine *sm) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1052 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1053 | struct isci_port *iport = container_of(sm, typeof(*iport), sm); |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1054 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1055 | |
| 1056 | /* |
| 1057 | * Kill the dummy task for this port if it has not yet posted |
| 1058 | * the hardware will treat this as a NOP and just return abort |
| 1059 | * complete. |
| 1060 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1061 | sci_port_abort_dummy_request(iport); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1062 | |
| 1063 | isci_port_not_ready(ihost, iport); |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 1064 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1065 | if (iport->ready_exit) |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1066 | sci_port_invalidate_dummy_remote_node(iport); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1067 | } |
| 1068 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1069 | static void sci_port_ready_substate_configuring_enter(struct sci_base_state_machine *sm) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1070 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1071 | struct isci_port *iport = container_of(sm, typeof(*iport), sm); |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1072 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1073 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1074 | if (iport->active_phy_mask == 0) { |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1075 | isci_port_not_ready(ihost, iport); |
| 1076 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1077 | port_state_machine_change(iport, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1078 | SCI_PORT_SUB_WAITING); |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1079 | } else if (iport->started_request_count == 0) |
| 1080 | port_state_machine_change(iport, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1081 | SCI_PORT_SUB_OPERATIONAL); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1082 | } |
| 1083 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1084 | static void sci_port_ready_substate_configuring_exit(struct sci_base_state_machine *sm) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1085 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1086 | struct isci_port *iport = container_of(sm, typeof(*iport), sm); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1087 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1088 | sci_port_suspend_port_task_scheduler(iport); |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1089 | if (iport->ready_exit) |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1090 | sci_port_invalidate_dummy_remote_node(iport); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1091 | } |
| 1092 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1093 | enum sci_status sci_port_start(struct isci_port *iport) |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1094 | { |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1095 | struct isci_host *ihost = iport->owning_controller; |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1096 | enum sci_status status = SCI_SUCCESS; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1097 | enum sci_port_states state; |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1098 | u32 phy_mask; |
| 1099 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1100 | state = iport->sm.current_state_id; |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1101 | if (state != SCI_PORT_STOPPED) { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1102 | dev_warn(sciport_to_dev(iport), |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1103 | "%s: in wrong state: %d\n", __func__, state); |
| 1104 | return SCI_FAILURE_INVALID_STATE; |
| 1105 | } |
| 1106 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1107 | if (iport->assigned_device_count > 0) { |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1108 | /* TODO This is a start failure operation because |
| 1109 | * there are still devices assigned to this port. |
| 1110 | * There must be no devices assigned to a port on a |
| 1111 | * start operation. |
| 1112 | */ |
| 1113 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; |
| 1114 | } |
| 1115 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1116 | if (iport->reserved_rni == SCU_DUMMY_INDEX) { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1117 | u16 rni = sci_remote_node_table_allocate_remote_node( |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1118 | &ihost->available_remote_nodes, 1); |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1119 | |
| 1120 | if (rni != SCU_DUMMY_INDEX) |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1121 | sci_port_construct_dummy_rnc(iport, rni); |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1122 | else |
| 1123 | status = SCI_FAILURE_INSUFFICIENT_RESOURCES; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1124 | iport->reserved_rni = rni; |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1125 | } |
| 1126 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1127 | if (iport->reserved_tag == SCI_CONTROLLER_INVALID_IO_TAG) { |
Dan Williams | 312e0c2 | 2011-06-28 13:47:09 -0700 | [diff] [blame] | 1128 | u16 tag; |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1129 | |
Dan Williams | 312e0c2 | 2011-06-28 13:47:09 -0700 | [diff] [blame] | 1130 | tag = isci_alloc_tag(ihost); |
| 1131 | if (tag == SCI_CONTROLLER_INVALID_IO_TAG) |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1132 | status = SCI_FAILURE_INSUFFICIENT_RESOURCES; |
Dan Williams | 312e0c2 | 2011-06-28 13:47:09 -0700 | [diff] [blame] | 1133 | else |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1134 | sci_port_construct_dummy_task(iport, tag); |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1135 | iport->reserved_tag = tag; |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1136 | } |
| 1137 | |
| 1138 | if (status == SCI_SUCCESS) { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1139 | phy_mask = sci_port_get_phys(iport); |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1140 | |
| 1141 | /* |
| 1142 | * There are one or more phys assigned to this port. Make sure |
| 1143 | * the port's phy mask is in fact legal and supported by the |
| 1144 | * silicon. |
| 1145 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1146 | if (sci_port_is_phy_mask_valid(iport, phy_mask) == true) { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1147 | port_state_machine_change(iport, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1148 | SCI_PORT_READY); |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1149 | |
| 1150 | return SCI_SUCCESS; |
| 1151 | } |
| 1152 | status = SCI_FAILURE; |
| 1153 | } |
| 1154 | |
| 1155 | if (status != SCI_SUCCESS) |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1156 | sci_port_destroy_dummy_resources(iport); |
Piotr Sawicki | d76f71d | 2011-05-11 23:52:26 +0000 | [diff] [blame] | 1157 | |
| 1158 | return status; |
| 1159 | } |
| 1160 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1161 | enum sci_status sci_port_stop(struct isci_port *iport) |
Piotr Sawicki | 8bc80d3 | 2011-05-11 23:52:31 +0000 | [diff] [blame] | 1162 | { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1163 | enum sci_port_states state; |
Piotr Sawicki | 8bc80d3 | 2011-05-11 23:52:31 +0000 | [diff] [blame] | 1164 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1165 | state = iport->sm.current_state_id; |
Piotr Sawicki | 8bc80d3 | 2011-05-11 23:52:31 +0000 | [diff] [blame] | 1166 | switch (state) { |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1167 | case SCI_PORT_STOPPED: |
Piotr Sawicki | 8bc80d3 | 2011-05-11 23:52:31 +0000 | [diff] [blame] | 1168 | return SCI_SUCCESS; |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1169 | case SCI_PORT_SUB_WAITING: |
| 1170 | case SCI_PORT_SUB_OPERATIONAL: |
| 1171 | case SCI_PORT_SUB_CONFIGURING: |
| 1172 | case SCI_PORT_RESETTING: |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1173 | port_state_machine_change(iport, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1174 | SCI_PORT_STOPPING); |
Piotr Sawicki | 8bc80d3 | 2011-05-11 23:52:31 +0000 | [diff] [blame] | 1175 | return SCI_SUCCESS; |
| 1176 | default: |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1177 | dev_warn(sciport_to_dev(iport), |
Piotr Sawicki | 8bc80d3 | 2011-05-11 23:52:31 +0000 | [diff] [blame] | 1178 | "%s: in wrong state: %d\n", __func__, state); |
| 1179 | return SCI_FAILURE_INVALID_STATE; |
| 1180 | } |
| 1181 | } |
| 1182 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1183 | static enum sci_status sci_port_hard_reset(struct isci_port *iport, u32 timeout) |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1184 | { |
| 1185 | enum sci_status status = SCI_FAILURE_INVALID_PHY; |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 1186 | struct isci_phy *iphy = NULL; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1187 | enum sci_port_states state; |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1188 | u32 phy_index; |
| 1189 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1190 | state = iport->sm.current_state_id; |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1191 | if (state != SCI_PORT_SUB_OPERATIONAL) { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1192 | dev_warn(sciport_to_dev(iport), |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1193 | "%s: in wrong state: %d\n", __func__, state); |
| 1194 | return SCI_FAILURE_INVALID_STATE; |
| 1195 | } |
| 1196 | |
| 1197 | /* Select a phy on which we can send the hard reset request. */ |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 1198 | for (phy_index = 0; phy_index < SCI_MAX_PHYS && !iphy; phy_index++) { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1199 | iphy = iport->phy_table[phy_index]; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1200 | if (iphy && !sci_port_active_phy(iport, iphy)) { |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1201 | /* |
| 1202 | * We found a phy but it is not ready select |
| 1203 | * different phy |
| 1204 | */ |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 1205 | iphy = NULL; |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1206 | } |
| 1207 | } |
| 1208 | |
| 1209 | /* If we have a phy then go ahead and start the reset procedure */ |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 1210 | if (!iphy) |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1211 | return status; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1212 | status = sci_phy_reset(iphy); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1213 | |
| 1214 | if (status != SCI_SUCCESS) |
| 1215 | return status; |
| 1216 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1217 | sci_mod_timer(&iport->timer, timeout); |
| 1218 | iport->not_ready_reason = SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED; |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1219 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1220 | port_state_machine_change(iport, SCI_PORT_RESETTING); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1221 | return SCI_SUCCESS; |
| 1222 | } |
| 1223 | |
| 1224 | /** |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1225 | * sci_port_add_phy() - |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1226 | * @sci_port: This parameter specifies the port in which the phy will be added. |
| 1227 | * @sci_phy: This parameter is the phy which is to be added to the port. |
| 1228 | * |
| 1229 | * This method will add a PHY to the selected port. This method returns an |
| 1230 | * enum sci_status. SCI_SUCCESS the phy has been added to the port. Any other |
| 1231 | * status is a failure to add the phy to the port. |
| 1232 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1233 | enum sci_status sci_port_add_phy(struct isci_port *iport, |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 1234 | struct isci_phy *iphy) |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1235 | { |
| 1236 | enum sci_status status; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1237 | enum sci_port_states state; |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1238 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1239 | state = iport->sm.current_state_id; |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1240 | switch (state) { |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1241 | case SCI_PORT_STOPPED: { |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1242 | struct sci_sas_address port_sas_address; |
| 1243 | |
| 1244 | /* Read the port assigned SAS Address if there is one */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1245 | sci_port_get_sas_address(iport, &port_sas_address); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1246 | |
| 1247 | if (port_sas_address.high != 0 && port_sas_address.low != 0) { |
| 1248 | struct sci_sas_address phy_sas_address; |
| 1249 | |
| 1250 | /* Make sure that the PHY SAS Address matches the SAS Address |
| 1251 | * for this port |
| 1252 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1253 | sci_phy_get_sas_address(iphy, &phy_sas_address); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1254 | |
| 1255 | if (port_sas_address.high != phy_sas_address.high || |
| 1256 | port_sas_address.low != phy_sas_address.low) |
| 1257 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; |
| 1258 | } |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1259 | return sci_port_set_phy(iport, iphy); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1260 | } |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1261 | case SCI_PORT_SUB_WAITING: |
| 1262 | case SCI_PORT_SUB_OPERATIONAL: |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1263 | status = sci_port_set_phy(iport, iphy); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1264 | |
| 1265 | if (status != SCI_SUCCESS) |
| 1266 | return status; |
| 1267 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1268 | sci_port_general_link_up_handler(iport, iphy, true); |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1269 | iport->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; |
| 1270 | port_state_machine_change(iport, SCI_PORT_SUB_CONFIGURING); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1271 | |
| 1272 | return status; |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1273 | case SCI_PORT_SUB_CONFIGURING: |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1274 | status = sci_port_set_phy(iport, iphy); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1275 | |
| 1276 | if (status != SCI_SUCCESS) |
| 1277 | return status; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1278 | sci_port_general_link_up_handler(iport, iphy, true); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1279 | |
| 1280 | /* Re-enter the configuring state since this may be the last phy in |
| 1281 | * the port. |
| 1282 | */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1283 | port_state_machine_change(iport, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1284 | SCI_PORT_SUB_CONFIGURING); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1285 | return SCI_SUCCESS; |
| 1286 | default: |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1287 | dev_warn(sciport_to_dev(iport), |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1288 | "%s: in wrong state: %d\n", __func__, state); |
| 1289 | return SCI_FAILURE_INVALID_STATE; |
| 1290 | } |
| 1291 | } |
| 1292 | |
| 1293 | /** |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1294 | * sci_port_remove_phy() - |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1295 | * @sci_port: This parameter specifies the port in which the phy will be added. |
| 1296 | * @sci_phy: This parameter is the phy which is to be added to the port. |
| 1297 | * |
| 1298 | * This method will remove the PHY from the selected PORT. This method returns |
| 1299 | * an enum sci_status. SCI_SUCCESS the phy has been removed from the port. Any |
| 1300 | * other status is a failure to add the phy to the port. |
| 1301 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1302 | enum sci_status sci_port_remove_phy(struct isci_port *iport, |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 1303 | struct isci_phy *iphy) |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1304 | { |
| 1305 | enum sci_status status; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1306 | enum sci_port_states state; |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1307 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1308 | state = iport->sm.current_state_id; |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1309 | |
| 1310 | switch (state) { |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1311 | case SCI_PORT_STOPPED: |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1312 | return sci_port_clear_phy(iport, iphy); |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1313 | case SCI_PORT_SUB_OPERATIONAL: |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1314 | status = sci_port_clear_phy(iport, iphy); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1315 | if (status != SCI_SUCCESS) |
| 1316 | return status; |
| 1317 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1318 | sci_port_deactivate_phy(iport, iphy, true); |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1319 | iport->not_ready_reason = SCIC_PORT_NOT_READY_RECONFIGURING; |
| 1320 | port_state_machine_change(iport, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1321 | SCI_PORT_SUB_CONFIGURING); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1322 | return SCI_SUCCESS; |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1323 | case SCI_PORT_SUB_CONFIGURING: |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1324 | status = sci_port_clear_phy(iport, iphy); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1325 | |
| 1326 | if (status != SCI_SUCCESS) |
| 1327 | return status; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1328 | sci_port_deactivate_phy(iport, iphy, true); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1329 | |
| 1330 | /* Re-enter the configuring state since this may be the last phy in |
| 1331 | * the port |
| 1332 | */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1333 | port_state_machine_change(iport, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1334 | SCI_PORT_SUB_CONFIGURING); |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1335 | return SCI_SUCCESS; |
| 1336 | default: |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1337 | dev_warn(sciport_to_dev(iport), |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1338 | "%s: in wrong state: %d\n", __func__, state); |
| 1339 | return SCI_FAILURE_INVALID_STATE; |
| 1340 | } |
| 1341 | } |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1342 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1343 | enum sci_status sci_port_link_up(struct isci_port *iport, |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 1344 | struct isci_phy *iphy) |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1345 | { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1346 | enum sci_port_states state; |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1347 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1348 | state = iport->sm.current_state_id; |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1349 | switch (state) { |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1350 | case SCI_PORT_SUB_WAITING: |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1351 | /* Since this is the first phy going link up for the port we |
| 1352 | * can just enable it and continue |
| 1353 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1354 | sci_port_activate_phy(iport, iphy, true); |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1355 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1356 | port_state_machine_change(iport, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1357 | SCI_PORT_SUB_OPERATIONAL); |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1358 | return SCI_SUCCESS; |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1359 | case SCI_PORT_SUB_OPERATIONAL: |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1360 | sci_port_general_link_up_handler(iport, iphy, true); |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1361 | return SCI_SUCCESS; |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1362 | case SCI_PORT_RESETTING: |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1363 | /* TODO We should make sure that the phy that has gone |
| 1364 | * link up is the same one on which we sent the reset. It is |
| 1365 | * possible that the phy on which we sent the reset is not the |
| 1366 | * one that has gone link up and we want to make sure that |
| 1367 | * phy being reset comes back. Consider the case where a |
| 1368 | * reset is sent but before the hardware processes the reset it |
| 1369 | * get a link up on the port because of a hot plug event. |
| 1370 | * because of the reset request this phy will go link down |
| 1371 | * almost immediately. |
| 1372 | */ |
| 1373 | |
| 1374 | /* In the resetting state we don't notify the user regarding |
| 1375 | * link up and link down notifications. |
| 1376 | */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1377 | sci_port_general_link_up_handler(iport, iphy, false); |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1378 | return SCI_SUCCESS; |
| 1379 | default: |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1380 | dev_warn(sciport_to_dev(iport), |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1381 | "%s: in wrong state: %d\n", __func__, state); |
| 1382 | return SCI_FAILURE_INVALID_STATE; |
| 1383 | } |
| 1384 | } |
| 1385 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1386 | enum sci_status sci_port_link_down(struct isci_port *iport, |
Dan Williams | 8528095 | 2011-06-28 15:05:53 -0700 | [diff] [blame] | 1387 | struct isci_phy *iphy) |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1388 | { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1389 | enum sci_port_states state; |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1390 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1391 | state = iport->sm.current_state_id; |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1392 | switch (state) { |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1393 | case SCI_PORT_SUB_OPERATIONAL: |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1394 | sci_port_deactivate_phy(iport, iphy, true); |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1395 | |
| 1396 | /* If there are no active phys left in the port, then |
| 1397 | * transition the port to the WAITING state until such time |
| 1398 | * as a phy goes link up |
| 1399 | */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1400 | if (iport->active_phy_mask == 0) |
| 1401 | port_state_machine_change(iport, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1402 | SCI_PORT_SUB_WAITING); |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1403 | return SCI_SUCCESS; |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1404 | case SCI_PORT_RESETTING: |
Piotr Sawicki | 051266c | 2011-05-12 19:10:14 +0000 | [diff] [blame] | 1405 | /* In the resetting state we don't notify the user regarding |
| 1406 | * link up and link down notifications. */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1407 | sci_port_deactivate_phy(iport, iphy, false); |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1408 | return SCI_SUCCESS; |
| 1409 | default: |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1410 | dev_warn(sciport_to_dev(iport), |
Piotr Sawicki | bd6713b | 2011-05-12 19:10:03 +0000 | [diff] [blame] | 1411 | "%s: in wrong state: %d\n", __func__, state); |
| 1412 | return SCI_FAILURE_INVALID_STATE; |
| 1413 | } |
| 1414 | } |
| 1415 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1416 | enum sci_status sci_port_start_io(struct isci_port *iport, |
| 1417 | struct isci_remote_device *idev, |
| 1418 | struct isci_request *ireq) |
Dan Williams | 6813820 | 2011-05-12 07:16:06 -0700 | [diff] [blame] | 1419 | { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1420 | enum sci_port_states state; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1421 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1422 | state = iport->sm.current_state_id; |
Dan Williams | 6813820 | 2011-05-12 07:16:06 -0700 | [diff] [blame] | 1423 | switch (state) { |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1424 | case SCI_PORT_SUB_WAITING: |
Dan Williams | 6813820 | 2011-05-12 07:16:06 -0700 | [diff] [blame] | 1425 | return SCI_FAILURE_INVALID_STATE; |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1426 | case SCI_PORT_SUB_OPERATIONAL: |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1427 | iport->started_request_count++; |
Dan Williams | 6813820 | 2011-05-12 07:16:06 -0700 | [diff] [blame] | 1428 | return SCI_SUCCESS; |
| 1429 | default: |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1430 | dev_warn(sciport_to_dev(iport), |
Dan Williams | 6813820 | 2011-05-12 07:16:06 -0700 | [diff] [blame] | 1431 | "%s: in wrong state: %d\n", __func__, state); |
| 1432 | return SCI_FAILURE_INVALID_STATE; |
| 1433 | } |
| 1434 | } |
| 1435 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1436 | enum sci_status sci_port_complete_io(struct isci_port *iport, |
| 1437 | struct isci_remote_device *idev, |
| 1438 | struct isci_request *ireq) |
Dan Williams | 6813820 | 2011-05-12 07:16:06 -0700 | [diff] [blame] | 1439 | { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1440 | enum sci_port_states state; |
Dan Williams | 6813820 | 2011-05-12 07:16:06 -0700 | [diff] [blame] | 1441 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1442 | state = iport->sm.current_state_id; |
Dan Williams | 6813820 | 2011-05-12 07:16:06 -0700 | [diff] [blame] | 1443 | switch (state) { |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1444 | case SCI_PORT_STOPPED: |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1445 | dev_warn(sciport_to_dev(iport), |
Dan Williams | 6813820 | 2011-05-12 07:16:06 -0700 | [diff] [blame] | 1446 | "%s: in wrong state: %d\n", __func__, state); |
| 1447 | return SCI_FAILURE_INVALID_STATE; |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1448 | case SCI_PORT_STOPPING: |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1449 | sci_port_decrement_request_count(iport); |
Dan Williams | 6813820 | 2011-05-12 07:16:06 -0700 | [diff] [blame] | 1450 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1451 | if (iport->started_request_count == 0) |
| 1452 | port_state_machine_change(iport, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1453 | SCI_PORT_STOPPED); |
Dan Williams | 6813820 | 2011-05-12 07:16:06 -0700 | [diff] [blame] | 1454 | break; |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1455 | case SCI_PORT_READY: |
| 1456 | case SCI_PORT_RESETTING: |
| 1457 | case SCI_PORT_FAILED: |
| 1458 | case SCI_PORT_SUB_WAITING: |
| 1459 | case SCI_PORT_SUB_OPERATIONAL: |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1460 | sci_port_decrement_request_count(iport); |
Dan Williams | 6813820 | 2011-05-12 07:16:06 -0700 | [diff] [blame] | 1461 | break; |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1462 | case SCI_PORT_SUB_CONFIGURING: |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1463 | sci_port_decrement_request_count(iport); |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1464 | if (iport->started_request_count == 0) { |
| 1465 | port_state_machine_change(iport, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1466 | SCI_PORT_SUB_OPERATIONAL); |
Dan Williams | 6813820 | 2011-05-12 07:16:06 -0700 | [diff] [blame] | 1467 | } |
| 1468 | break; |
| 1469 | } |
| 1470 | return SCI_SUCCESS; |
| 1471 | } |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1472 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1473 | static void sci_port_enable_port_task_scheduler(struct isci_port *iport) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1474 | { |
| 1475 | u32 pts_control_value; |
| 1476 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1477 | /* enable the port task scheduler in a suspended state */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1478 | pts_control_value = readl(&iport->port_task_scheduler_registers->control); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1479 | pts_control_value |= SCU_PTSxCR_GEN_BIT(ENABLE) | SCU_PTSxCR_GEN_BIT(SUSPEND); |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1480 | writel(pts_control_value, &iport->port_task_scheduler_registers->control); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1481 | } |
| 1482 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1483 | static void sci_port_disable_port_task_scheduler(struct isci_port *iport) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1484 | { |
| 1485 | u32 pts_control_value; |
| 1486 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1487 | pts_control_value = readl(&iport->port_task_scheduler_registers->control); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1488 | pts_control_value &= |
| 1489 | ~(SCU_PTSxCR_GEN_BIT(ENABLE) | SCU_PTSxCR_GEN_BIT(SUSPEND)); |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1490 | writel(pts_control_value, &iport->port_task_scheduler_registers->control); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1491 | } |
| 1492 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1493 | static void sci_port_post_dummy_remote_node(struct isci_port *iport) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1494 | { |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1495 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1496 | u8 phys_index = iport->physical_port_index; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1497 | union scu_remote_node_context *rnc; |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1498 | u16 rni = iport->reserved_rni; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1499 | u32 command; |
| 1500 | |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1501 | rnc = &ihost->remote_node_context_table[rni]; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1502 | rnc->ssp.is_valid = true; |
| 1503 | |
| 1504 | command = SCU_CONTEXT_COMMAND_POST_RNC_32 | |
| 1505 | phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni; |
| 1506 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1507 | sci_controller_post_request(ihost, command); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1508 | |
| 1509 | /* ensure hardware has seen the post rnc command and give it |
| 1510 | * ample time to act before sending the suspend |
| 1511 | */ |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1512 | readl(&ihost->smu_registers->interrupt_status); /* flush */ |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1513 | udelay(10); |
| 1514 | |
| 1515 | command = SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX_RX | |
| 1516 | phys_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT | rni; |
| 1517 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1518 | sci_controller_post_request(ihost, command); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1519 | } |
| 1520 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1521 | static void sci_port_stopped_state_enter(struct sci_base_state_machine *sm) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1522 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1523 | struct isci_port *iport = container_of(sm, typeof(*iport), sm); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1524 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1525 | if (iport->sm.previous_state_id == SCI_PORT_STOPPING) { |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1526 | /* |
| 1527 | * If we enter this state becasuse of a request to stop |
| 1528 | * the port then we want to disable the hardwares port |
| 1529 | * task scheduler. */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1530 | sci_port_disable_port_task_scheduler(iport); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1531 | } |
| 1532 | } |
| 1533 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1534 | static void sci_port_stopped_state_exit(struct sci_base_state_machine *sm) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1535 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1536 | struct isci_port *iport = container_of(sm, typeof(*iport), sm); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1537 | |
| 1538 | /* Enable and suspend the port task scheduler */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1539 | sci_port_enable_port_task_scheduler(iport); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1540 | } |
| 1541 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1542 | static void sci_port_ready_state_enter(struct sci_base_state_machine *sm) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1543 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1544 | struct isci_port *iport = container_of(sm, typeof(*iport), sm); |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1545 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1546 | u32 prev_state; |
| 1547 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1548 | prev_state = iport->sm.previous_state_id; |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1549 | if (prev_state == SCI_PORT_RESETTING) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1550 | isci_port_hard_reset_complete(iport, SCI_SUCCESS); |
| 1551 | else |
| 1552 | isci_port_not_ready(ihost, iport); |
| 1553 | |
| 1554 | /* Post and suspend the dummy remote node context for this port. */ |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1555 | sci_port_post_dummy_remote_node(iport); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1556 | |
| 1557 | /* Start the ready substate machine */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1558 | port_state_machine_change(iport, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1559 | SCI_PORT_SUB_WAITING); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1560 | } |
| 1561 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1562 | static void sci_port_resetting_state_exit(struct sci_base_state_machine *sm) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1563 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1564 | struct isci_port *iport = container_of(sm, typeof(*iport), sm); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1565 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1566 | sci_del_timer(&iport->timer); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1567 | } |
| 1568 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1569 | static void sci_port_stopping_state_exit(struct sci_base_state_machine *sm) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1570 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1571 | struct isci_port *iport = container_of(sm, typeof(*iport), sm); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1572 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1573 | sci_del_timer(&iport->timer); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1574 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1575 | sci_port_destroy_dummy_resources(iport); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1576 | } |
| 1577 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1578 | static void sci_port_failed_state_enter(struct sci_base_state_machine *sm) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1579 | { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1580 | struct isci_port *iport = container_of(sm, typeof(*iport), sm); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1581 | |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1582 | isci_port_hard_reset_complete(iport, SCI_FAILURE_TIMEOUT); |
| 1583 | } |
| 1584 | |
| 1585 | /* --------------------------------------------------------------------------- */ |
| 1586 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1587 | static const struct sci_base_state sci_port_state_table[] = { |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1588 | [SCI_PORT_STOPPED] = { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1589 | .enter_state = sci_port_stopped_state_enter, |
| 1590 | .exit_state = sci_port_stopped_state_exit |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1591 | }, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1592 | [SCI_PORT_STOPPING] = { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1593 | .exit_state = sci_port_stopping_state_exit |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1594 | }, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1595 | [SCI_PORT_READY] = { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1596 | .enter_state = sci_port_ready_state_enter, |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 1597 | }, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1598 | [SCI_PORT_SUB_WAITING] = { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1599 | .enter_state = sci_port_ready_substate_waiting_enter, |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 1600 | }, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1601 | [SCI_PORT_SUB_OPERATIONAL] = { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1602 | .enter_state = sci_port_ready_substate_operational_enter, |
| 1603 | .exit_state = sci_port_ready_substate_operational_exit |
Piotr Sawicki | e91f41e | 2011-05-11 23:52:21 +0000 | [diff] [blame] | 1604 | }, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1605 | [SCI_PORT_SUB_CONFIGURING] = { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1606 | .enter_state = sci_port_ready_substate_configuring_enter, |
| 1607 | .exit_state = sci_port_ready_substate_configuring_exit |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1608 | }, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1609 | [SCI_PORT_RESETTING] = { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1610 | .exit_state = sci_port_resetting_state_exit |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1611 | }, |
Edmund Nadolski | e301370 | 2011-06-02 00:10:43 +0000 | [diff] [blame] | 1612 | [SCI_PORT_FAILED] = { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1613 | .enter_state = sci_port_failed_state_enter, |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1614 | } |
| 1615 | }; |
| 1616 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1617 | void sci_port_construct(struct isci_port *iport, u8 index, |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1618 | struct isci_host *ihost) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1619 | { |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1620 | sci_init_sm(&iport->sm, sci_port_state_table, SCI_PORT_STOPPED); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1621 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1622 | iport->logical_port_index = SCIC_SDS_DUMMY_PORT; |
| 1623 | iport->physical_port_index = index; |
| 1624 | iport->active_phy_mask = 0; |
| 1625 | iport->ready_exit = false; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1626 | |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1627 | iport->owning_controller = ihost; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1628 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1629 | iport->started_request_count = 0; |
| 1630 | iport->assigned_device_count = 0; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1631 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1632 | iport->reserved_rni = SCU_DUMMY_INDEX; |
| 1633 | iport->reserved_tag = SCI_CONTROLLER_INVALID_IO_TAG; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1634 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1635 | sci_init_timer(&iport->timer, port_timeout); |
Edmund Nadolski | 5553ba2 | 2011-05-19 11:59:10 +0000 | [diff] [blame] | 1636 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1637 | iport->port_task_scheduler_registers = NULL; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1638 | |
| 1639 | for (index = 0; index < SCI_MAX_PHYS; index++) |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1640 | iport->phy_table[index] = NULL; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1641 | } |
| 1642 | |
| 1643 | void isci_port_init(struct isci_port *iport, struct isci_host *ihost, int index) |
| 1644 | { |
| 1645 | INIT_LIST_HEAD(&iport->remote_dev_list); |
| 1646 | INIT_LIST_HEAD(&iport->domain_dev_list); |
| 1647 | spin_lock_init(&iport->state_lock); |
| 1648 | init_completion(&iport->start_complete); |
| 1649 | iport->isci_host = ihost; |
| 1650 | isci_port_change_state(iport, isci_freed); |
Jeff Skirvin | 61aaff4 | 2011-06-21 12:16:33 -0700 | [diff] [blame] | 1651 | atomic_set(&iport->event, 0); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1652 | } |
| 1653 | |
| 1654 | /** |
| 1655 | * isci_port_get_state() - This function gets the status of the port object. |
| 1656 | * @isci_port: This parameter points to the isci_port object |
| 1657 | * |
| 1658 | * status of the object as a isci_status enum. |
| 1659 | */ |
| 1660 | enum isci_status isci_port_get_state( |
| 1661 | struct isci_port *isci_port) |
| 1662 | { |
| 1663 | return isci_port->status; |
| 1664 | } |
| 1665 | |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1666 | void sci_port_broadcast_change_received(struct isci_port *iport, struct isci_phy *iphy) |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1667 | { |
Dan Williams | d9dcb4b | 2011-06-30 17:38:32 -0700 | [diff] [blame] | 1668 | struct isci_host *ihost = iport->owning_controller; |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1669 | |
| 1670 | /* notify the user. */ |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1671 | isci_port_bc_change_received(ihost, iport, iphy); |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1672 | } |
| 1673 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1674 | int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *iport, |
| 1675 | struct isci_phy *iphy) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1676 | { |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1677 | unsigned long flags; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1678 | enum sci_status status; |
Jeff Skirvin | fd0527a | 2011-06-20 14:09:26 -0700 | [diff] [blame] | 1679 | int idx, ret = TMF_RESP_FUNC_COMPLETE; |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1680 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1681 | dev_dbg(&ihost->pdev->dev, "%s: iport = %p\n", |
| 1682 | __func__, iport); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1683 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1684 | init_completion(&iport->hard_reset_complete); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1685 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1686 | spin_lock_irqsave(&ihost->scic_lock, flags); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1687 | |
| 1688 | #define ISCI_PORT_RESET_TIMEOUT SCIC_SDS_SIGNATURE_FIS_TIMEOUT |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1689 | status = sci_port_hard_reset(iport, ISCI_PORT_RESET_TIMEOUT); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1690 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1691 | spin_unlock_irqrestore(&ihost->scic_lock, flags); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1692 | |
| 1693 | if (status == SCI_SUCCESS) { |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1694 | wait_for_completion(&iport->hard_reset_complete); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1695 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1696 | dev_dbg(&ihost->pdev->dev, |
| 1697 | "%s: iport = %p; hard reset completion\n", |
| 1698 | __func__, iport); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1699 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1700 | if (iport->hard_reset_status != SCI_SUCCESS) |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1701 | ret = TMF_RESP_FUNC_FAILED; |
| 1702 | } else { |
| 1703 | ret = TMF_RESP_FUNC_FAILED; |
| 1704 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1705 | dev_err(&ihost->pdev->dev, |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1706 | "%s: iport = %p; sci_port_hard_reset call" |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1707 | " failed 0x%x\n", |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1708 | __func__, iport, status); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1709 | |
| 1710 | } |
| 1711 | |
| 1712 | /* If the hard reset for the port has failed, consider this |
| 1713 | * the same as link failures on all phys in the port. |
| 1714 | */ |
| 1715 | if (ret != TMF_RESP_FUNC_COMPLETE) { |
Jeff Skirvin | fd0527a | 2011-06-20 14:09:26 -0700 | [diff] [blame] | 1716 | |
Dan Williams | 4393aa4 | 2011-03-31 13:10:44 -0700 | [diff] [blame] | 1717 | dev_err(&ihost->pdev->dev, |
| 1718 | "%s: iport = %p; hard reset failed " |
Jeff Skirvin | fd0527a | 2011-06-20 14:09:26 -0700 | [diff] [blame] | 1719 | "(0x%x) - driving explicit link fail for all phys\n", |
| 1720 | __func__, iport, iport->hard_reset_status); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1721 | |
Jeff Skirvin | fd0527a | 2011-06-20 14:09:26 -0700 | [diff] [blame] | 1722 | /* Down all phys in the port. */ |
| 1723 | spin_lock_irqsave(&ihost->scic_lock, flags); |
| 1724 | for (idx = 0; idx < SCI_MAX_PHYS; ++idx) { |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1725 | struct isci_phy *iphy = iport->phy_table[idx]; |
Jeff Skirvin | fd0527a | 2011-06-20 14:09:26 -0700 | [diff] [blame] | 1726 | |
Dan Williams | ffe191c | 2011-06-29 13:09:25 -0700 | [diff] [blame] | 1727 | if (!iphy) |
| 1728 | continue; |
Dan Williams | 89a7301 | 2011-06-30 19:14:33 -0700 | [diff] [blame] | 1729 | sci_phy_stop(iphy); |
| 1730 | sci_phy_start(iphy); |
Jeff Skirvin | fd0527a | 2011-06-20 14:09:26 -0700 | [diff] [blame] | 1731 | } |
| 1732 | spin_unlock_irqrestore(&ihost->scic_lock, flags); |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1733 | } |
Dan Williams | 6f231dd | 2011-07-02 22:56:22 -0700 | [diff] [blame] | 1734 | return ret; |
| 1735 | } |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 1736 | |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1737 | /** |
| 1738 | * isci_port_deformed() - This function is called by libsas when a port becomes |
| 1739 | * inactive. |
| 1740 | * @phy: This parameter specifies the libsas phy with the inactive port. |
| 1741 | * |
| 1742 | */ |
| 1743 | void isci_port_deformed(struct asd_sas_phy *phy) |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 1744 | { |
Dan Williams | e2f8db50 | 2011-05-10 02:28:46 -0700 | [diff] [blame] | 1745 | pr_debug("%s: sas_phy = %p\n", __func__, phy); |
| 1746 | } |
| 1747 | |
| 1748 | /** |
| 1749 | * isci_port_formed() - This function is called by libsas when a port becomes |
| 1750 | * active. |
| 1751 | * @phy: This parameter specifies the libsas phy with the active port. |
| 1752 | * |
| 1753 | */ |
| 1754 | void isci_port_formed(struct asd_sas_phy *phy) |
| 1755 | { |
| 1756 | pr_debug("%s: sas_phy = %p, sas_port = %p\n", __func__, phy, phy->port); |
Dave Jiang | 09d7da1 | 2011-03-26 16:11:51 -0700 | [diff] [blame] | 1757 | } |