port.c 53 KB

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