port.c 72 KB

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