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