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