fw-sbp2.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  1. /*
  2. * SBP2 driver (SCSI over IEEE1394)
  3. *
  4. * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. /*
  21. * The basic structure of this driver is based on the old storage driver,
  22. * drivers/ieee1394/sbp2.c, originally written by
  23. * James Goodwin <jamesg@filanet.com>
  24. * with later contributions and ongoing maintenance from
  25. * Ben Collins <bcollins@debian.org>,
  26. * Stefan Richter <stefanr@s5r6.in-berlin.de>
  27. * and many others.
  28. */
  29. #include <linux/kernel.h>
  30. #include <linux/module.h>
  31. #include <linux/mod_devicetable.h>
  32. #include <linux/device.h>
  33. #include <linux/scatterlist.h>
  34. #include <linux/dma-mapping.h>
  35. #include <linux/timer.h>
  36. #include <scsi/scsi.h>
  37. #include <scsi/scsi_cmnd.h>
  38. #include <scsi/scsi_dbg.h>
  39. #include <scsi/scsi_device.h>
  40. #include <scsi/scsi_host.h>
  41. #include "fw-transaction.h"
  42. #include "fw-topology.h"
  43. #include "fw-device.h"
  44. /* I don't know why the SCSI stack doesn't define something like this... */
  45. typedef void (*scsi_done_fn_t)(struct scsi_cmnd *);
  46. static const char sbp2_driver_name[] = "sbp2";
  47. struct sbp2_device {
  48. struct kref kref;
  49. struct fw_unit *unit;
  50. struct fw_address_handler address_handler;
  51. struct list_head orb_list;
  52. u64 management_agent_address;
  53. u64 command_block_agent_address;
  54. u32 workarounds;
  55. int login_id;
  56. /*
  57. * We cache these addresses and only update them once we've
  58. * logged in or reconnected to the sbp2 device. That way, any
  59. * IO to the device will automatically fail and get retried if
  60. * it happens in a window where the device is not ready to
  61. * handle it (e.g. after a bus reset but before we reconnect).
  62. */
  63. int node_id;
  64. int address_high;
  65. int generation;
  66. int retries;
  67. struct delayed_work work;
  68. };
  69. #define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000
  70. #define SBP2_MAX_SECTORS 255 /* Max sectors supported */
  71. #define SBP2_ORB_TIMEOUT 2000 /* Timeout in ms */
  72. #define SBP2_ORB_NULL 0x80000000
  73. #define SBP2_DIRECTION_TO_MEDIA 0x0
  74. #define SBP2_DIRECTION_FROM_MEDIA 0x1
  75. /* Unit directory keys */
  76. #define SBP2_COMMAND_SET_SPECIFIER 0x38
  77. #define SBP2_COMMAND_SET 0x39
  78. #define SBP2_COMMAND_SET_REVISION 0x3b
  79. #define SBP2_FIRMWARE_REVISION 0x3c
  80. /* Flags for detected oddities and brokeness */
  81. #define SBP2_WORKAROUND_128K_MAX_TRANS 0x1
  82. #define SBP2_WORKAROUND_INQUIRY_36 0x2
  83. #define SBP2_WORKAROUND_MODE_SENSE_8 0x4
  84. #define SBP2_WORKAROUND_FIX_CAPACITY 0x8
  85. #define SBP2_WORKAROUND_OVERRIDE 0x100
  86. /* Management orb opcodes */
  87. #define SBP2_LOGIN_REQUEST 0x0
  88. #define SBP2_QUERY_LOGINS_REQUEST 0x1
  89. #define SBP2_RECONNECT_REQUEST 0x3
  90. #define SBP2_SET_PASSWORD_REQUEST 0x4
  91. #define SBP2_LOGOUT_REQUEST 0x7
  92. #define SBP2_ABORT_TASK_REQUEST 0xb
  93. #define SBP2_ABORT_TASK_SET 0xc
  94. #define SBP2_LOGICAL_UNIT_RESET 0xe
  95. #define SBP2_TARGET_RESET_REQUEST 0xf
  96. /* Offsets for command block agent registers */
  97. #define SBP2_AGENT_STATE 0x00
  98. #define SBP2_AGENT_RESET 0x04
  99. #define SBP2_ORB_POINTER 0x08
  100. #define SBP2_DOORBELL 0x10
  101. #define SBP2_UNSOLICITED_STATUS_ENABLE 0x14
  102. /* Status write response codes */
  103. #define SBP2_STATUS_REQUEST_COMPLETE 0x0
  104. #define SBP2_STATUS_TRANSPORT_FAILURE 0x1
  105. #define SBP2_STATUS_ILLEGAL_REQUEST 0x2
  106. #define SBP2_STATUS_VENDOR_DEPENDENT 0x3
  107. #define STATUS_GET_ORB_HIGH(v) ((v).status & 0xffff)
  108. #define STATUS_GET_SBP_STATUS(v) (((v).status >> 16) & 0xff)
  109. #define STATUS_GET_LEN(v) (((v).status >> 24) & 0x07)
  110. #define STATUS_GET_DEAD(v) (((v).status >> 27) & 0x01)
  111. #define STATUS_GET_RESPONSE(v) (((v).status >> 28) & 0x03)
  112. #define STATUS_GET_SOURCE(v) (((v).status >> 30) & 0x03)
  113. #define STATUS_GET_ORB_LOW(v) ((v).orb_low)
  114. #define STATUS_GET_DATA(v) ((v).data)
  115. struct sbp2_status {
  116. u32 status;
  117. u32 orb_low;
  118. u8 data[24];
  119. };
  120. struct sbp2_pointer {
  121. u32 high;
  122. u32 low;
  123. };
  124. struct sbp2_orb {
  125. struct fw_transaction t;
  126. dma_addr_t request_bus;
  127. int rcode;
  128. struct sbp2_pointer pointer;
  129. void (*callback)(struct sbp2_orb * orb, struct sbp2_status * status);
  130. struct list_head link;
  131. };
  132. #define MANAGEMENT_ORB_LUN(v) ((v))
  133. #define MANAGEMENT_ORB_FUNCTION(v) ((v) << 16)
  134. #define MANAGEMENT_ORB_RECONNECT(v) ((v) << 20)
  135. #define MANAGEMENT_ORB_EXCLUSIVE ((1) << 28)
  136. #define MANAGEMENT_ORB_REQUEST_FORMAT(v) ((v) << 29)
  137. #define MANAGEMENT_ORB_NOTIFY ((1) << 31)
  138. #define MANAGEMENT_ORB_RESPONSE_LENGTH(v) ((v))
  139. #define MANAGEMENT_ORB_PASSWORD_LENGTH(v) ((v) << 16)
  140. struct sbp2_management_orb {
  141. struct sbp2_orb base;
  142. struct {
  143. struct sbp2_pointer password;
  144. struct sbp2_pointer response;
  145. u32 misc;
  146. u32 length;
  147. struct sbp2_pointer status_fifo;
  148. } request;
  149. __be32 response[4];
  150. dma_addr_t response_bus;
  151. struct completion done;
  152. struct sbp2_status status;
  153. };
  154. #define LOGIN_RESPONSE_GET_LOGIN_ID(v) ((v).misc & 0xffff)
  155. #define LOGIN_RESPONSE_GET_LENGTH(v) (((v).misc >> 16) & 0xffff)
  156. struct sbp2_login_response {
  157. u32 misc;
  158. struct sbp2_pointer command_block_agent;
  159. u32 reconnect_hold;
  160. };
  161. #define COMMAND_ORB_DATA_SIZE(v) ((v))
  162. #define COMMAND_ORB_PAGE_SIZE(v) ((v) << 16)
  163. #define COMMAND_ORB_PAGE_TABLE_PRESENT ((1) << 19)
  164. #define COMMAND_ORB_MAX_PAYLOAD(v) ((v) << 20)
  165. #define COMMAND_ORB_SPEED(v) ((v) << 24)
  166. #define COMMAND_ORB_DIRECTION(v) ((v) << 27)
  167. #define COMMAND_ORB_REQUEST_FORMAT(v) ((v) << 29)
  168. #define COMMAND_ORB_NOTIFY ((1) << 31)
  169. struct sbp2_command_orb {
  170. struct sbp2_orb base;
  171. struct {
  172. struct sbp2_pointer next;
  173. struct sbp2_pointer data_descriptor;
  174. u32 misc;
  175. u8 command_block[12];
  176. } request;
  177. struct scsi_cmnd *cmd;
  178. scsi_done_fn_t done;
  179. struct fw_unit *unit;
  180. struct sbp2_pointer page_table[SG_ALL];
  181. dma_addr_t page_table_bus;
  182. };
  183. /*
  184. * List of devices with known bugs.
  185. *
  186. * The firmware_revision field, masked with 0xffff00, is the best
  187. * indicator for the type of bridge chip of a device. It yields a few
  188. * false positives but this did not break correctly behaving devices
  189. * so far. We use ~0 as a wildcard, since the 24 bit values we get
  190. * from the config rom can never match that.
  191. */
  192. static const struct {
  193. u32 firmware_revision;
  194. u32 model;
  195. unsigned workarounds;
  196. } sbp2_workarounds_table[] = {
  197. /* DViCO Momobay CX-1 with TSB42AA9 bridge */ {
  198. .firmware_revision = 0x002800,
  199. .model = 0x001010,
  200. .workarounds = SBP2_WORKAROUND_INQUIRY_36 |
  201. SBP2_WORKAROUND_MODE_SENSE_8,
  202. },
  203. /* Initio bridges, actually only needed for some older ones */ {
  204. .firmware_revision = 0x000200,
  205. .model = ~0,
  206. .workarounds = SBP2_WORKAROUND_INQUIRY_36,
  207. },
  208. /* Symbios bridge */ {
  209. .firmware_revision = 0xa0b800,
  210. .model = ~0,
  211. .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
  212. },
  213. /*
  214. * There are iPods (2nd gen, 3rd gen) with model_id == 0, but
  215. * these iPods do not feature the read_capacity bug according
  216. * to one report. Read_capacity behaviour as well as model_id
  217. * could change due to Apple-supplied firmware updates though.
  218. */
  219. /* iPod 4th generation. */ {
  220. .firmware_revision = 0x0a2700,
  221. .model = 0x000021,
  222. .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
  223. },
  224. /* iPod mini */ {
  225. .firmware_revision = 0x0a2700,
  226. .model = 0x000023,
  227. .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
  228. },
  229. /* iPod Photo */ {
  230. .firmware_revision = 0x0a2700,
  231. .model = 0x00007e,
  232. .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
  233. }
  234. };
  235. static void
  236. sbp2_status_write(struct fw_card *card, struct fw_request *request,
  237. int tcode, int destination, int source,
  238. int generation, int speed,
  239. unsigned long long offset,
  240. void *payload, size_t length, void *callback_data)
  241. {
  242. struct sbp2_device *sd = callback_data;
  243. struct sbp2_orb *orb;
  244. struct sbp2_status status;
  245. size_t header_size;
  246. unsigned long flags;
  247. if (tcode != TCODE_WRITE_BLOCK_REQUEST ||
  248. length == 0 || length > sizeof(status)) {
  249. fw_send_response(card, request, RCODE_TYPE_ERROR);
  250. return;
  251. }
  252. header_size = min(length, 2 * sizeof(u32));
  253. fw_memcpy_from_be32(&status, payload, header_size);
  254. if (length > header_size)
  255. memcpy(status.data, payload + 8, length - header_size);
  256. if (STATUS_GET_SOURCE(status) == 2 || STATUS_GET_SOURCE(status) == 3) {
  257. fw_notify("non-orb related status write, not handled\n");
  258. fw_send_response(card, request, RCODE_COMPLETE);
  259. return;
  260. }
  261. /* Lookup the orb corresponding to this status write. */
  262. spin_lock_irqsave(&card->lock, flags);
  263. list_for_each_entry(orb, &sd->orb_list, link) {
  264. if (STATUS_GET_ORB_HIGH(status) == 0 &&
  265. STATUS_GET_ORB_LOW(status) == orb->request_bus &&
  266. orb->rcode == RCODE_COMPLETE) {
  267. list_del(&orb->link);
  268. break;
  269. }
  270. }
  271. spin_unlock_irqrestore(&card->lock, flags);
  272. if (&orb->link != &sd->orb_list)
  273. orb->callback(orb, &status);
  274. else
  275. fw_error("status write for unknown orb\n");
  276. fw_send_response(card, request, RCODE_COMPLETE);
  277. }
  278. static void
  279. complete_transaction(struct fw_card *card, int rcode,
  280. void *payload, size_t length, void *data)
  281. {
  282. struct sbp2_orb *orb = data;
  283. unsigned long flags;
  284. orb->rcode = rcode;
  285. if (rcode != RCODE_COMPLETE) {
  286. spin_lock_irqsave(&card->lock, flags);
  287. list_del(&orb->link);
  288. spin_unlock_irqrestore(&card->lock, flags);
  289. orb->callback(orb, NULL);
  290. }
  291. }
  292. static void
  293. sbp2_send_orb(struct sbp2_orb *orb, struct fw_unit *unit,
  294. int node_id, int generation, u64 offset)
  295. {
  296. struct fw_device *device = fw_device(unit->device.parent);
  297. struct sbp2_device *sd = unit->device.driver_data;
  298. unsigned long flags;
  299. orb->pointer.high = 0;
  300. orb->pointer.low = orb->request_bus;
  301. fw_memcpy_to_be32(&orb->pointer, &orb->pointer, sizeof(orb->pointer));
  302. spin_lock_irqsave(&device->card->lock, flags);
  303. list_add_tail(&orb->link, &sd->orb_list);
  304. spin_unlock_irqrestore(&device->card->lock, flags);
  305. fw_send_request(device->card, &orb->t, TCODE_WRITE_BLOCK_REQUEST,
  306. node_id, generation, device->max_speed, offset,
  307. &orb->pointer, sizeof(orb->pointer),
  308. complete_transaction, orb);
  309. }
  310. static int sbp2_cancel_orbs(struct fw_unit *unit)
  311. {
  312. struct fw_device *device = fw_device(unit->device.parent);
  313. struct sbp2_device *sd = unit->device.driver_data;
  314. struct sbp2_orb *orb, *next;
  315. struct list_head list;
  316. unsigned long flags;
  317. int retval = -ENOENT;
  318. INIT_LIST_HEAD(&list);
  319. spin_lock_irqsave(&device->card->lock, flags);
  320. list_splice_init(&sd->orb_list, &list);
  321. spin_unlock_irqrestore(&device->card->lock, flags);
  322. list_for_each_entry_safe(orb, next, &list, link) {
  323. retval = 0;
  324. if (fw_cancel_transaction(device->card, &orb->t) == 0)
  325. continue;
  326. orb->rcode = RCODE_CANCELLED;
  327. orb->callback(orb, NULL);
  328. }
  329. return retval;
  330. }
  331. static void
  332. complete_management_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
  333. {
  334. struct sbp2_management_orb *orb =
  335. (struct sbp2_management_orb *)base_orb;
  336. if (status)
  337. memcpy(&orb->status, status, sizeof(*status));
  338. complete(&orb->done);
  339. }
  340. static int
  341. sbp2_send_management_orb(struct fw_unit *unit, int node_id, int generation,
  342. int function, int lun, void *response)
  343. {
  344. struct fw_device *device = fw_device(unit->device.parent);
  345. struct sbp2_device *sd = unit->device.driver_data;
  346. struct sbp2_management_orb *orb;
  347. int retval = -ENOMEM;
  348. orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
  349. if (orb == NULL)
  350. return -ENOMEM;
  351. /*
  352. * The sbp2 device is going to send a block read request to
  353. * read out the request from host memory, so map it for dma.
  354. */
  355. orb->base.request_bus =
  356. dma_map_single(device->card->device, &orb->request,
  357. sizeof(orb->request), DMA_TO_DEVICE);
  358. if (dma_mapping_error(orb->base.request_bus))
  359. goto out;
  360. orb->response_bus =
  361. dma_map_single(device->card->device, &orb->response,
  362. sizeof(orb->response), DMA_FROM_DEVICE);
  363. if (dma_mapping_error(orb->response_bus))
  364. goto out;
  365. orb->request.response.high = 0;
  366. orb->request.response.low = orb->response_bus;
  367. orb->request.misc =
  368. MANAGEMENT_ORB_NOTIFY |
  369. MANAGEMENT_ORB_FUNCTION(function) |
  370. MANAGEMENT_ORB_LUN(lun);
  371. orb->request.length =
  372. MANAGEMENT_ORB_RESPONSE_LENGTH(sizeof(orb->response));
  373. orb->request.status_fifo.high = sd->address_handler.offset >> 32;
  374. orb->request.status_fifo.low = sd->address_handler.offset;
  375. /*
  376. * FIXME: Yeah, ok this isn't elegant, we hardwire exclusive
  377. * login and 1 second reconnect time. The reconnect setting
  378. * is probably fine, but the exclusive login should be an option.
  379. */
  380. if (function == SBP2_LOGIN_REQUEST) {
  381. orb->request.misc |=
  382. MANAGEMENT_ORB_EXCLUSIVE |
  383. MANAGEMENT_ORB_RECONNECT(0);
  384. }
  385. fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request));
  386. init_completion(&orb->done);
  387. orb->base.callback = complete_management_orb;
  388. sbp2_send_orb(&orb->base, unit,
  389. node_id, generation, sd->management_agent_address);
  390. wait_for_completion_timeout(&orb->done,
  391. msecs_to_jiffies(SBP2_ORB_TIMEOUT));
  392. retval = -EIO;
  393. if (sbp2_cancel_orbs(unit) == 0) {
  394. fw_error("orb reply timed out, rcode=0x%02x\n",
  395. orb->base.rcode);
  396. goto out;
  397. }
  398. if (orb->base.rcode != RCODE_COMPLETE) {
  399. fw_error("management write failed, rcode 0x%02x\n",
  400. orb->base.rcode);
  401. goto out;
  402. }
  403. if (STATUS_GET_RESPONSE(orb->status) != 0 ||
  404. STATUS_GET_SBP_STATUS(orb->status) != 0) {
  405. fw_error("error status: %d:%d\n",
  406. STATUS_GET_RESPONSE(orb->status),
  407. STATUS_GET_SBP_STATUS(orb->status));
  408. goto out;
  409. }
  410. retval = 0;
  411. out:
  412. dma_unmap_single(device->card->device, orb->base.request_bus,
  413. sizeof(orb->request), DMA_TO_DEVICE);
  414. dma_unmap_single(device->card->device, orb->response_bus,
  415. sizeof(orb->response), DMA_FROM_DEVICE);
  416. if (response)
  417. fw_memcpy_from_be32(response,
  418. orb->response, sizeof(orb->response));
  419. kfree(orb);
  420. return retval;
  421. }
  422. static void
  423. complete_agent_reset_write(struct fw_card *card, int rcode,
  424. void *payload, size_t length, void *data)
  425. {
  426. struct fw_transaction *t = data;
  427. kfree(t);
  428. }
  429. static int sbp2_agent_reset(struct fw_unit *unit)
  430. {
  431. struct fw_device *device = fw_device(unit->device.parent);
  432. struct sbp2_device *sd = unit->device.driver_data;
  433. struct fw_transaction *t;
  434. static u32 zero;
  435. t = kzalloc(sizeof(*t), GFP_ATOMIC);
  436. if (t == NULL)
  437. return -ENOMEM;
  438. fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST,
  439. sd->node_id, sd->generation, SCODE_400,
  440. sd->command_block_agent_address + SBP2_AGENT_RESET,
  441. &zero, sizeof(zero), complete_agent_reset_write, t);
  442. return 0;
  443. }
  444. static void sbp2_reconnect(struct work_struct *work);
  445. static struct scsi_host_template scsi_driver_template;
  446. static void
  447. release_sbp2_device(struct kref *kref)
  448. {
  449. struct sbp2_device *sd = container_of(kref, struct sbp2_device, kref);
  450. struct Scsi_Host *host =
  451. container_of((void *)sd, struct Scsi_Host, hostdata[0]);
  452. sbp2_send_management_orb(sd->unit, sd->node_id, sd->generation,
  453. SBP2_LOGOUT_REQUEST, sd->login_id, NULL);
  454. scsi_remove_host(host);
  455. fw_core_remove_address_handler(&sd->address_handler);
  456. fw_notify("removed sbp2 unit %s\n", sd->unit->device.bus_id);
  457. put_device(&sd->unit->device);
  458. scsi_host_put(host);
  459. }
  460. static void sbp2_login(struct work_struct *work)
  461. {
  462. struct sbp2_device *sd =
  463. container_of(work, struct sbp2_device, work.work);
  464. struct Scsi_Host *host =
  465. container_of((void *)sd, struct Scsi_Host, hostdata[0]);
  466. struct fw_unit *unit = sd->unit;
  467. struct fw_device *device = fw_device(unit->device.parent);
  468. struct sbp2_login_response response;
  469. int generation, node_id, local_node_id, lun, retval;
  470. /* FIXME: Make this work for multi-lun devices. */
  471. lun = 0;
  472. generation = device->card->generation;
  473. node_id = device->node->node_id;
  474. local_node_id = device->card->local_node->node_id;
  475. if (sbp2_send_management_orb(unit, node_id, generation,
  476. SBP2_LOGIN_REQUEST, lun, &response) < 0) {
  477. if (sd->retries++ < 5) {
  478. schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5));
  479. } else {
  480. fw_error("failed to login to %s\n",
  481. unit->device.bus_id);
  482. kref_put(&sd->kref, release_sbp2_device);
  483. }
  484. return;
  485. }
  486. sd->generation = generation;
  487. sd->node_id = node_id;
  488. sd->address_high = local_node_id << 16;
  489. /* Get command block agent offset and login id. */
  490. sd->command_block_agent_address =
  491. ((u64) (response.command_block_agent.high & 0xffff) << 32) |
  492. response.command_block_agent.low;
  493. sd->login_id = LOGIN_RESPONSE_GET_LOGIN_ID(response);
  494. fw_notify("logged in to sbp2 unit %s (%d retries)\n",
  495. unit->device.bus_id, sd->retries);
  496. fw_notify(" - management_agent_address: 0x%012llx\n",
  497. (unsigned long long) sd->management_agent_address);
  498. fw_notify(" - command_block_agent_address: 0x%012llx\n",
  499. (unsigned long long) sd->command_block_agent_address);
  500. fw_notify(" - status write address: 0x%012llx\n",
  501. (unsigned long long) sd->address_handler.offset);
  502. #if 0
  503. /* FIXME: The linux1394 sbp2 does this last step. */
  504. sbp2_set_busy_timeout(scsi_id);
  505. #endif
  506. PREPARE_DELAYED_WORK(&sd->work, sbp2_reconnect);
  507. sbp2_agent_reset(unit);
  508. /* FIXME: Loop over luns here. */
  509. lun = 0;
  510. retval = scsi_add_device(host, 0, 0, lun);
  511. if (retval < 0) {
  512. sbp2_send_management_orb(unit, sd->node_id, sd->generation,
  513. SBP2_LOGOUT_REQUEST, sd->login_id,
  514. NULL);
  515. /*
  516. * Set this back to sbp2_login so we fall back and
  517. * retry login on bus reset.
  518. */
  519. PREPARE_DELAYED_WORK(&sd->work, sbp2_login);
  520. }
  521. kref_put(&sd->kref, release_sbp2_device);
  522. }
  523. static int sbp2_probe(struct device *dev)
  524. {
  525. struct fw_unit *unit = fw_unit(dev);
  526. struct fw_device *device = fw_device(unit->device.parent);
  527. struct sbp2_device *sd;
  528. struct fw_csr_iterator ci;
  529. struct Scsi_Host *host;
  530. int i, key, value, err;
  531. u32 model, firmware_revision;
  532. err = -ENOMEM;
  533. host = scsi_host_alloc(&scsi_driver_template, sizeof(*sd));
  534. if (host == NULL)
  535. goto fail;
  536. sd = (struct sbp2_device *) host->hostdata;
  537. unit->device.driver_data = sd;
  538. sd->unit = unit;
  539. INIT_LIST_HEAD(&sd->orb_list);
  540. kref_init(&sd->kref);
  541. sd->address_handler.length = 0x100;
  542. sd->address_handler.address_callback = sbp2_status_write;
  543. sd->address_handler.callback_data = sd;
  544. err = fw_core_add_address_handler(&sd->address_handler,
  545. &fw_high_memory_region);
  546. if (err < 0)
  547. goto fail_host;
  548. err = fw_device_enable_phys_dma(device);
  549. if (err < 0)
  550. goto fail_address_handler;
  551. err = scsi_add_host(host, &unit->device);
  552. if (err < 0)
  553. goto fail_address_handler;
  554. /*
  555. * Scan unit directory to get management agent address,
  556. * firmware revison and model. Initialize firmware_revision
  557. * and model to values that wont match anything in our table.
  558. */
  559. firmware_revision = 0xff000000;
  560. model = 0xff000000;
  561. fw_csr_iterator_init(&ci, unit->directory);
  562. while (fw_csr_iterator_next(&ci, &key, &value)) {
  563. switch (key) {
  564. case CSR_DEPENDENT_INFO | CSR_OFFSET:
  565. sd->management_agent_address =
  566. 0xfffff0000000ULL + 4 * value;
  567. break;
  568. case SBP2_FIRMWARE_REVISION:
  569. firmware_revision = value;
  570. break;
  571. case CSR_MODEL:
  572. model = value;
  573. break;
  574. }
  575. }
  576. for (i = 0; i < ARRAY_SIZE(sbp2_workarounds_table); i++) {
  577. if (sbp2_workarounds_table[i].firmware_revision !=
  578. (firmware_revision & 0xffffff00))
  579. continue;
  580. if (sbp2_workarounds_table[i].model != model &&
  581. sbp2_workarounds_table[i].model != ~0)
  582. continue;
  583. sd->workarounds |= sbp2_workarounds_table[i].workarounds;
  584. break;
  585. }
  586. if (sd->workarounds)
  587. fw_notify("Workarounds for node %s: 0x%x "
  588. "(firmware_revision 0x%06x, model_id 0x%06x)\n",
  589. unit->device.bus_id,
  590. sd->workarounds, firmware_revision, model);
  591. get_device(&unit->device);
  592. /*
  593. * We schedule work to do the login so we can easily
  594. * reschedule retries. Always get the ref before scheduling
  595. * work.
  596. */
  597. INIT_DELAYED_WORK(&sd->work, sbp2_login);
  598. if (schedule_delayed_work(&sd->work, 0))
  599. kref_get(&sd->kref);
  600. return 0;
  601. fail_address_handler:
  602. fw_core_remove_address_handler(&sd->address_handler);
  603. fail_host:
  604. scsi_host_put(host);
  605. fail:
  606. return err;
  607. }
  608. static int sbp2_remove(struct device *dev)
  609. {
  610. struct fw_unit *unit = fw_unit(dev);
  611. struct sbp2_device *sd = unit->device.driver_data;
  612. kref_put(&sd->kref, release_sbp2_device);
  613. return 0;
  614. }
  615. static void sbp2_reconnect(struct work_struct *work)
  616. {
  617. struct sbp2_device *sd =
  618. container_of(work, struct sbp2_device, work.work);
  619. struct fw_unit *unit = sd->unit;
  620. struct fw_device *device = fw_device(unit->device.parent);
  621. int generation, node_id, local_node_id;
  622. generation = device->card->generation;
  623. node_id = device->node->node_id;
  624. local_node_id = device->card->local_node->node_id;
  625. if (sbp2_send_management_orb(unit, node_id, generation,
  626. SBP2_RECONNECT_REQUEST,
  627. sd->login_id, NULL) < 0) {
  628. if (sd->retries++ >= 5) {
  629. fw_error("failed to reconnect to %s\n",
  630. unit->device.bus_id);
  631. /* Fall back and try to log in again. */
  632. sd->retries = 0;
  633. PREPARE_DELAYED_WORK(&sd->work, sbp2_login);
  634. }
  635. schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5));
  636. return;
  637. }
  638. sd->generation = generation;
  639. sd->node_id = node_id;
  640. sd->address_high = local_node_id << 16;
  641. fw_notify("reconnected to unit %s (%d retries)\n",
  642. unit->device.bus_id, sd->retries);
  643. sbp2_agent_reset(unit);
  644. sbp2_cancel_orbs(unit);
  645. kref_put(&sd->kref, release_sbp2_device);
  646. }
  647. static void sbp2_update(struct fw_unit *unit)
  648. {
  649. struct fw_device *device = fw_device(unit->device.parent);
  650. struct sbp2_device *sd = unit->device.driver_data;
  651. sd->retries = 0;
  652. fw_device_enable_phys_dma(device);
  653. if (schedule_delayed_work(&sd->work, 0))
  654. kref_get(&sd->kref);
  655. }
  656. #define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e
  657. #define SBP2_SW_VERSION_ENTRY 0x00010483
  658. static const struct fw_device_id sbp2_id_table[] = {
  659. {
  660. .match_flags = FW_MATCH_SPECIFIER_ID | FW_MATCH_VERSION,
  661. .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY,
  662. .version = SBP2_SW_VERSION_ENTRY,
  663. },
  664. { }
  665. };
  666. static struct fw_driver sbp2_driver = {
  667. .driver = {
  668. .owner = THIS_MODULE,
  669. .name = sbp2_driver_name,
  670. .bus = &fw_bus_type,
  671. .probe = sbp2_probe,
  672. .remove = sbp2_remove,
  673. },
  674. .update = sbp2_update,
  675. .id_table = sbp2_id_table,
  676. };
  677. static unsigned int
  678. sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
  679. {
  680. int sam_status;
  681. sense_data[0] = 0x70;
  682. sense_data[1] = 0x0;
  683. sense_data[2] = sbp2_status[1];
  684. sense_data[3] = sbp2_status[4];
  685. sense_data[4] = sbp2_status[5];
  686. sense_data[5] = sbp2_status[6];
  687. sense_data[6] = sbp2_status[7];
  688. sense_data[7] = 10;
  689. sense_data[8] = sbp2_status[8];
  690. sense_data[9] = sbp2_status[9];
  691. sense_data[10] = sbp2_status[10];
  692. sense_data[11] = sbp2_status[11];
  693. sense_data[12] = sbp2_status[2];
  694. sense_data[13] = sbp2_status[3];
  695. sense_data[14] = sbp2_status[12];
  696. sense_data[15] = sbp2_status[13];
  697. sam_status = sbp2_status[0] & 0x3f;
  698. switch (sam_status) {
  699. case SAM_STAT_GOOD:
  700. case SAM_STAT_CHECK_CONDITION:
  701. case SAM_STAT_CONDITION_MET:
  702. case SAM_STAT_BUSY:
  703. case SAM_STAT_RESERVATION_CONFLICT:
  704. case SAM_STAT_COMMAND_TERMINATED:
  705. return DID_OK << 16 | sam_status;
  706. default:
  707. return DID_ERROR << 16;
  708. }
  709. }
  710. static void
  711. complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
  712. {
  713. struct sbp2_command_orb *orb = (struct sbp2_command_orb *)base_orb;
  714. struct fw_unit *unit = orb->unit;
  715. struct fw_device *device = fw_device(unit->device.parent);
  716. struct scatterlist *sg;
  717. int result;
  718. if (status != NULL) {
  719. if (STATUS_GET_DEAD(*status))
  720. sbp2_agent_reset(unit);
  721. switch (STATUS_GET_RESPONSE(*status)) {
  722. case SBP2_STATUS_REQUEST_COMPLETE:
  723. result = DID_OK << 16;
  724. break;
  725. case SBP2_STATUS_TRANSPORT_FAILURE:
  726. result = DID_BUS_BUSY << 16;
  727. break;
  728. case SBP2_STATUS_ILLEGAL_REQUEST:
  729. case SBP2_STATUS_VENDOR_DEPENDENT:
  730. default:
  731. result = DID_ERROR << 16;
  732. break;
  733. }
  734. if (result == DID_OK << 16 && STATUS_GET_LEN(*status) > 1)
  735. result = sbp2_status_to_sense_data(STATUS_GET_DATA(*status),
  736. orb->cmd->sense_buffer);
  737. } else {
  738. /*
  739. * If the orb completes with status == NULL, something
  740. * went wrong, typically a bus reset happened mid-orb
  741. * or when sending the write (less likely).
  742. */
  743. result = DID_BUS_BUSY << 16;
  744. }
  745. dma_unmap_single(device->card->device, orb->base.request_bus,
  746. sizeof(orb->request), DMA_TO_DEVICE);
  747. if (orb->cmd->use_sg > 0) {
  748. sg = (struct scatterlist *)orb->cmd->request_buffer;
  749. dma_unmap_sg(device->card->device, sg, orb->cmd->use_sg,
  750. orb->cmd->sc_data_direction);
  751. }
  752. if (orb->page_table_bus != 0)
  753. dma_unmap_single(device->card->device, orb->page_table_bus,
  754. sizeof(orb->page_table_bus), DMA_TO_DEVICE);
  755. orb->cmd->result = result;
  756. orb->done(orb->cmd);
  757. kfree(orb);
  758. }
  759. static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb)
  760. {
  761. struct sbp2_device *sd =
  762. (struct sbp2_device *)orb->cmd->device->host->hostdata;
  763. struct fw_unit *unit = sd->unit;
  764. struct fw_device *device = fw_device(unit->device.parent);
  765. struct scatterlist *sg;
  766. int sg_len, l, i, j, count;
  767. size_t size;
  768. dma_addr_t sg_addr;
  769. sg = (struct scatterlist *)orb->cmd->request_buffer;
  770. count = dma_map_sg(device->card->device, sg, orb->cmd->use_sg,
  771. orb->cmd->sc_data_direction);
  772. if (count == 0)
  773. goto fail;
  774. /*
  775. * Handle the special case where there is only one element in
  776. * the scatter list by converting it to an immediate block
  777. * request. This is also a workaround for broken devices such
  778. * as the second generation iPod which doesn't support page
  779. * tables.
  780. */
  781. if (count == 1 && sg_dma_len(sg) < SBP2_MAX_SG_ELEMENT_LENGTH) {
  782. orb->request.data_descriptor.high = sd->address_high;
  783. orb->request.data_descriptor.low = sg_dma_address(sg);
  784. orb->request.misc |=
  785. COMMAND_ORB_DATA_SIZE(sg_dma_len(sg));
  786. return 0;
  787. }
  788. /*
  789. * Convert the scatterlist to an sbp2 page table. If any
  790. * scatterlist entries are too big for sbp2, we split them as we
  791. * go. Even if we ask the block I/O layer to not give us sg
  792. * elements larger than 65535 bytes, some IOMMUs may merge sg elements
  793. * during DMA mapping, and Linux currently doesn't prevent this.
  794. */
  795. for (i = 0, j = 0; i < count; i++) {
  796. sg_len = sg_dma_len(sg + i);
  797. sg_addr = sg_dma_address(sg + i);
  798. while (sg_len) {
  799. l = min(sg_len, SBP2_MAX_SG_ELEMENT_LENGTH);
  800. orb->page_table[j].low = sg_addr;
  801. orb->page_table[j].high = (l << 16);
  802. sg_addr += l;
  803. sg_len -= l;
  804. j++;
  805. }
  806. }
  807. size = sizeof(orb->page_table[0]) * j;
  808. /*
  809. * The data_descriptor pointer is the one case where we need
  810. * to fill in the node ID part of the address. All other
  811. * pointers assume that the data referenced reside on the
  812. * initiator (i.e. us), but data_descriptor can refer to data
  813. * on other nodes so we need to put our ID in descriptor.high.
  814. */
  815. orb->page_table_bus =
  816. dma_map_single(device->card->device, orb->page_table,
  817. size, DMA_TO_DEVICE);
  818. if (dma_mapping_error(orb->page_table_bus))
  819. goto fail_page_table;
  820. orb->request.data_descriptor.high = sd->address_high;
  821. orb->request.data_descriptor.low = orb->page_table_bus;
  822. orb->request.misc |=
  823. COMMAND_ORB_PAGE_TABLE_PRESENT |
  824. COMMAND_ORB_DATA_SIZE(j);
  825. fw_memcpy_to_be32(orb->page_table, orb->page_table, size);
  826. return 0;
  827. fail_page_table:
  828. dma_unmap_sg(device->card->device, sg, orb->cmd->use_sg,
  829. orb->cmd->sc_data_direction);
  830. fail:
  831. return -ENOMEM;
  832. }
  833. /* SCSI stack integration */
  834. static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
  835. {
  836. struct sbp2_device *sd =
  837. (struct sbp2_device *)cmd->device->host->hostdata;
  838. struct fw_unit *unit = sd->unit;
  839. struct fw_device *device = fw_device(unit->device.parent);
  840. struct sbp2_command_orb *orb;
  841. /*
  842. * Bidirectional commands are not yet implemented, and unknown
  843. * transfer direction not handled.
  844. */
  845. if (cmd->sc_data_direction == DMA_BIDIRECTIONAL) {
  846. fw_error("Can't handle DMA_BIDIRECTIONAL, rejecting command\n");
  847. cmd->result = DID_ERROR << 16;
  848. done(cmd);
  849. return 0;
  850. }
  851. orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
  852. if (orb == NULL) {
  853. fw_notify("failed to alloc orb\n");
  854. goto fail_alloc;
  855. }
  856. /* Initialize rcode to something not RCODE_COMPLETE. */
  857. orb->base.rcode = -1;
  858. orb->base.request_bus =
  859. dma_map_single(device->card->device, &orb->request,
  860. sizeof(orb->request), DMA_TO_DEVICE);
  861. if (dma_mapping_error(orb->base.request_bus))
  862. goto fail_mapping;
  863. orb->unit = unit;
  864. orb->done = done;
  865. orb->cmd = cmd;
  866. orb->request.next.high = SBP2_ORB_NULL;
  867. orb->request.next.low = 0x0;
  868. /*
  869. * At speed 100 we can do 512 bytes per packet, at speed 200,
  870. * 1024 bytes per packet etc. The SBP-2 max_payload field
  871. * specifies the max payload size as 2 ^ (max_payload + 2), so
  872. * if we set this to max_speed + 7, we get the right value.
  873. */
  874. orb->request.misc =
  875. COMMAND_ORB_MAX_PAYLOAD(device->max_speed + 7) |
  876. COMMAND_ORB_SPEED(device->max_speed) |
  877. COMMAND_ORB_NOTIFY;
  878. if (cmd->sc_data_direction == DMA_FROM_DEVICE)
  879. orb->request.misc |=
  880. COMMAND_ORB_DIRECTION(SBP2_DIRECTION_FROM_MEDIA);
  881. else if (cmd->sc_data_direction == DMA_TO_DEVICE)
  882. orb->request.misc |=
  883. COMMAND_ORB_DIRECTION(SBP2_DIRECTION_TO_MEDIA);
  884. if (cmd->use_sg && sbp2_command_orb_map_scatterlist(orb) < 0)
  885. goto fail_map_payload;
  886. fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request));
  887. memset(orb->request.command_block,
  888. 0, sizeof(orb->request.command_block));
  889. memcpy(orb->request.command_block, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd));
  890. orb->base.callback = complete_command_orb;
  891. sbp2_send_orb(&orb->base, unit, sd->node_id, sd->generation,
  892. sd->command_block_agent_address + SBP2_ORB_POINTER);
  893. return 0;
  894. fail_map_payload:
  895. dma_unmap_single(device->card->device, orb->base.request_bus,
  896. sizeof(orb->request), DMA_TO_DEVICE);
  897. fail_mapping:
  898. kfree(orb);
  899. fail_alloc:
  900. return SCSI_MLQUEUE_HOST_BUSY;
  901. }
  902. static int sbp2_scsi_slave_alloc(struct scsi_device *sdev)
  903. {
  904. struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata;
  905. sdev->allow_restart = 1;
  906. if (sd->workarounds & SBP2_WORKAROUND_INQUIRY_36)
  907. sdev->inquiry_len = 36;
  908. return 0;
  909. }
  910. static int sbp2_scsi_slave_configure(struct scsi_device *sdev)
  911. {
  912. struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata;
  913. struct fw_unit *unit = sd->unit;
  914. sdev->use_10_for_rw = 1;
  915. if (sdev->type == TYPE_ROM)
  916. sdev->use_10_for_ms = 1;
  917. if (sdev->type == TYPE_DISK &&
  918. sd->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
  919. sdev->skip_ms_page_8 = 1;
  920. if (sd->workarounds & SBP2_WORKAROUND_FIX_CAPACITY) {
  921. fw_notify("setting fix_capacity for %s\n", unit->device.bus_id);
  922. sdev->fix_capacity = 1;
  923. }
  924. return 0;
  925. }
  926. /*
  927. * Called by scsi stack when something has really gone wrong. Usually
  928. * called when a command has timed-out for some reason.
  929. */
  930. static int sbp2_scsi_abort(struct scsi_cmnd *cmd)
  931. {
  932. struct sbp2_device *sd =
  933. (struct sbp2_device *)cmd->device->host->hostdata;
  934. struct fw_unit *unit = sd->unit;
  935. fw_notify("sbp2_scsi_abort\n");
  936. sbp2_agent_reset(unit);
  937. sbp2_cancel_orbs(unit);
  938. return SUCCESS;
  939. }
  940. /*
  941. * Format of /sys/bus/scsi/devices/.../ieee1394_id:
  942. * u64 EUI-64 : u24 directory_ID : u16 LUN (all printed in hexadecimal)
  943. *
  944. * This is the concatenation of target port identifier and logical unit
  945. * identifier as per SAM-2...SAM-4 annex A.
  946. */
  947. static ssize_t
  948. sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr,
  949. char *buf)
  950. {
  951. struct scsi_device *sdev = to_scsi_device(dev);
  952. struct sbp2_device *sd;
  953. struct fw_unit *unit;
  954. struct fw_device *device;
  955. u32 directory_id;
  956. struct fw_csr_iterator ci;
  957. int key, value, lun;
  958. if (!sdev)
  959. return 0;
  960. sd = (struct sbp2_device *)sdev->host->hostdata;
  961. unit = sd->unit;
  962. device = fw_device(unit->device.parent);
  963. /* implicit directory ID */
  964. directory_id = ((unit->directory - device->config_rom) * 4
  965. + CSR_CONFIG_ROM) & 0xffffff;
  966. /* explicit directory ID, overrides implicit ID if present */
  967. fw_csr_iterator_init(&ci, unit->directory);
  968. while (fw_csr_iterator_next(&ci, &key, &value))
  969. if (key == CSR_DIRECTORY_ID) {
  970. directory_id = value;
  971. break;
  972. }
  973. /* FIXME: Make this work for multi-lun devices. */
  974. lun = 0;
  975. return sprintf(buf, "%08x%08x:%06x:%04x\n",
  976. device->config_rom[3], device->config_rom[4],
  977. directory_id, lun);
  978. }
  979. static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL);
  980. static struct device_attribute *sbp2_scsi_sysfs_attrs[] = {
  981. &dev_attr_ieee1394_id,
  982. NULL
  983. };
  984. static struct scsi_host_template scsi_driver_template = {
  985. .module = THIS_MODULE,
  986. .name = "SBP-2 IEEE-1394",
  987. .proc_name = (char *)sbp2_driver_name,
  988. .queuecommand = sbp2_scsi_queuecommand,
  989. .slave_alloc = sbp2_scsi_slave_alloc,
  990. .slave_configure = sbp2_scsi_slave_configure,
  991. .eh_abort_handler = sbp2_scsi_abort,
  992. .this_id = -1,
  993. .sg_tablesize = SG_ALL,
  994. .use_clustering = ENABLE_CLUSTERING,
  995. .cmd_per_lun = 1,
  996. .can_queue = 1,
  997. .sdev_attrs = sbp2_scsi_sysfs_attrs,
  998. };
  999. MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>");
  1000. MODULE_DESCRIPTION("SCSI over IEEE1394");
  1001. MODULE_LICENSE("GPL");
  1002. MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
  1003. /* Provide a module alias so root-on-sbp2 initrds don't break. */
  1004. #ifndef CONFIG_IEEE1394_SBP2_MODULE
  1005. MODULE_ALIAS("sbp2");
  1006. #endif
  1007. static int __init sbp2_init(void)
  1008. {
  1009. return driver_register(&sbp2_driver.driver);
  1010. }
  1011. static void __exit sbp2_cleanup(void)
  1012. {
  1013. driver_unregister(&sbp2_driver.driver);
  1014. }
  1015. module_init(sbp2_init);
  1016. module_exit(sbp2_cleanup);