fw-sbp2.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194
  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,
  307. device->node->max_speed, offset,
  308. &orb->pointer, sizeof(orb->pointer),
  309. complete_transaction, orb);
  310. }
  311. static int sbp2_cancel_orbs(struct fw_unit *unit)
  312. {
  313. struct fw_device *device = fw_device(unit->device.parent);
  314. struct sbp2_device *sd = unit->device.driver_data;
  315. struct sbp2_orb *orb, *next;
  316. struct list_head list;
  317. unsigned long flags;
  318. int retval = -ENOENT;
  319. INIT_LIST_HEAD(&list);
  320. spin_lock_irqsave(&device->card->lock, flags);
  321. list_splice_init(&sd->orb_list, &list);
  322. spin_unlock_irqrestore(&device->card->lock, flags);
  323. list_for_each_entry_safe(orb, next, &list, link) {
  324. retval = 0;
  325. if (fw_cancel_transaction(device->card, &orb->t) == 0)
  326. continue;
  327. orb->rcode = RCODE_CANCELLED;
  328. orb->callback(orb, NULL);
  329. }
  330. return retval;
  331. }
  332. static void
  333. complete_management_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
  334. {
  335. struct sbp2_management_orb *orb =
  336. (struct sbp2_management_orb *)base_orb;
  337. if (status)
  338. memcpy(&orb->status, status, sizeof(*status));
  339. complete(&orb->done);
  340. }
  341. static int
  342. sbp2_send_management_orb(struct fw_unit *unit, int node_id, int generation,
  343. int function, int lun, void *response)
  344. {
  345. struct fw_device *device = fw_device(unit->device.parent);
  346. struct sbp2_device *sd = unit->device.driver_data;
  347. struct sbp2_management_orb *orb;
  348. int retval = -ENOMEM;
  349. orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
  350. if (orb == NULL)
  351. return -ENOMEM;
  352. /*
  353. * The sbp2 device is going to send a block read request to
  354. * read out the request from host memory, so map it for dma.
  355. */
  356. orb->base.request_bus =
  357. dma_map_single(device->card->device, &orb->request,
  358. sizeof(orb->request), DMA_TO_DEVICE);
  359. if (dma_mapping_error(orb->base.request_bus))
  360. goto out;
  361. orb->response_bus =
  362. dma_map_single(device->card->device, &orb->response,
  363. sizeof(orb->response), DMA_FROM_DEVICE);
  364. if (dma_mapping_error(orb->response_bus))
  365. goto out;
  366. orb->request.response.high = 0;
  367. orb->request.response.low = orb->response_bus;
  368. orb->request.misc =
  369. MANAGEMENT_ORB_NOTIFY |
  370. MANAGEMENT_ORB_FUNCTION(function) |
  371. MANAGEMENT_ORB_LUN(lun);
  372. orb->request.length =
  373. MANAGEMENT_ORB_RESPONSE_LENGTH(sizeof(orb->response));
  374. orb->request.status_fifo.high = sd->address_handler.offset >> 32;
  375. orb->request.status_fifo.low = sd->address_handler.offset;
  376. /*
  377. * FIXME: Yeah, ok this isn't elegant, we hardwire exclusive
  378. * login and 1 second reconnect time. The reconnect setting
  379. * is probably fine, but the exclusive login should be an option.
  380. */
  381. if (function == SBP2_LOGIN_REQUEST) {
  382. orb->request.misc |=
  383. MANAGEMENT_ORB_EXCLUSIVE |
  384. MANAGEMENT_ORB_RECONNECT(0);
  385. }
  386. fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request));
  387. init_completion(&orb->done);
  388. orb->base.callback = complete_management_orb;
  389. sbp2_send_orb(&orb->base, unit,
  390. node_id, generation, sd->management_agent_address);
  391. wait_for_completion_timeout(&orb->done,
  392. msecs_to_jiffies(SBP2_ORB_TIMEOUT));
  393. retval = -EIO;
  394. if (sbp2_cancel_orbs(unit) == 0) {
  395. fw_error("orb reply timed out, rcode=0x%02x\n",
  396. orb->base.rcode);
  397. goto out;
  398. }
  399. if (orb->base.rcode != RCODE_COMPLETE) {
  400. fw_error("management write failed, rcode 0x%02x\n",
  401. orb->base.rcode);
  402. goto out;
  403. }
  404. if (STATUS_GET_RESPONSE(orb->status) != 0 ||
  405. STATUS_GET_SBP_STATUS(orb->status) != 0) {
  406. fw_error("error status: %d:%d\n",
  407. STATUS_GET_RESPONSE(orb->status),
  408. STATUS_GET_SBP_STATUS(orb->status));
  409. goto out;
  410. }
  411. retval = 0;
  412. out:
  413. dma_unmap_single(device->card->device, orb->base.request_bus,
  414. sizeof(orb->request), DMA_TO_DEVICE);
  415. dma_unmap_single(device->card->device, orb->response_bus,
  416. sizeof(orb->response), DMA_FROM_DEVICE);
  417. if (response)
  418. fw_memcpy_from_be32(response,
  419. orb->response, sizeof(orb->response));
  420. kfree(orb);
  421. return retval;
  422. }
  423. static void
  424. complete_agent_reset_write(struct fw_card *card, int rcode,
  425. void *payload, size_t length, void *data)
  426. {
  427. struct fw_transaction *t = data;
  428. kfree(t);
  429. }
  430. static int sbp2_agent_reset(struct fw_unit *unit)
  431. {
  432. struct fw_device *device = fw_device(unit->device.parent);
  433. struct sbp2_device *sd = unit->device.driver_data;
  434. struct fw_transaction *t;
  435. static u32 zero;
  436. t = kzalloc(sizeof(*t), GFP_ATOMIC);
  437. if (t == NULL)
  438. return -ENOMEM;
  439. fw_send_request(device->card, t, TCODE_WRITE_QUADLET_REQUEST,
  440. sd->node_id, sd->generation, SCODE_400,
  441. sd->command_block_agent_address + SBP2_AGENT_RESET,
  442. &zero, sizeof(zero), complete_agent_reset_write, t);
  443. return 0;
  444. }
  445. static void sbp2_reconnect(struct work_struct *work);
  446. static struct scsi_host_template scsi_driver_template;
  447. static void
  448. release_sbp2_device(struct kref *kref)
  449. {
  450. struct sbp2_device *sd = container_of(kref, struct sbp2_device, kref);
  451. struct Scsi_Host *host =
  452. container_of((void *)sd, struct Scsi_Host, hostdata[0]);
  453. sbp2_send_management_orb(sd->unit, sd->node_id, sd->generation,
  454. SBP2_LOGOUT_REQUEST, sd->login_id, NULL);
  455. scsi_remove_host(host);
  456. fw_core_remove_address_handler(&sd->address_handler);
  457. fw_notify("removed sbp2 unit %s\n", sd->unit->device.bus_id);
  458. put_device(&sd->unit->device);
  459. scsi_host_put(host);
  460. }
  461. static void sbp2_login(struct work_struct *work)
  462. {
  463. struct sbp2_device *sd =
  464. container_of(work, struct sbp2_device, work.work);
  465. struct Scsi_Host *host =
  466. container_of((void *)sd, struct Scsi_Host, hostdata[0]);
  467. struct fw_unit *unit = sd->unit;
  468. struct fw_device *device = fw_device(unit->device.parent);
  469. struct sbp2_login_response response;
  470. int generation, node_id, local_node_id, lun, retval;
  471. /* FIXME: Make this work for multi-lun devices. */
  472. lun = 0;
  473. generation = device->card->generation;
  474. node_id = device->node->node_id;
  475. local_node_id = device->card->local_node->node_id;
  476. if (sbp2_send_management_orb(unit, node_id, generation,
  477. SBP2_LOGIN_REQUEST, lun, &response) < 0) {
  478. if (sd->retries++ < 5) {
  479. schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5));
  480. } else {
  481. fw_error("failed to login to %s\n",
  482. unit->device.bus_id);
  483. kref_put(&sd->kref, release_sbp2_device);
  484. }
  485. return;
  486. }
  487. sd->generation = generation;
  488. sd->node_id = node_id;
  489. sd->address_high = local_node_id << 16;
  490. /* Get command block agent offset and login id. */
  491. sd->command_block_agent_address =
  492. ((u64) (response.command_block_agent.high & 0xffff) << 32) |
  493. response.command_block_agent.low;
  494. sd->login_id = LOGIN_RESPONSE_GET_LOGIN_ID(response);
  495. fw_notify("logged in to sbp2 unit %s (%d retries)\n",
  496. unit->device.bus_id, sd->retries);
  497. fw_notify(" - management_agent_address: 0x%012llx\n",
  498. (unsigned long long) sd->management_agent_address);
  499. fw_notify(" - command_block_agent_address: 0x%012llx\n",
  500. (unsigned long long) sd->command_block_agent_address);
  501. fw_notify(" - status write address: 0x%012llx\n",
  502. (unsigned long long) sd->address_handler.offset);
  503. #if 0
  504. /* FIXME: The linux1394 sbp2 does this last step. */
  505. sbp2_set_busy_timeout(scsi_id);
  506. #endif
  507. PREPARE_DELAYED_WORK(&sd->work, sbp2_reconnect);
  508. sbp2_agent_reset(unit);
  509. /* FIXME: Loop over luns here. */
  510. lun = 0;
  511. retval = scsi_add_device(host, 0, 0, lun);
  512. if (retval < 0) {
  513. sbp2_send_management_orb(unit, sd->node_id, sd->generation,
  514. SBP2_LOGOUT_REQUEST, sd->login_id,
  515. NULL);
  516. /*
  517. * Set this back to sbp2_login so we fall back and
  518. * retry login on bus reset.
  519. */
  520. PREPARE_DELAYED_WORK(&sd->work, sbp2_login);
  521. }
  522. kref_put(&sd->kref, release_sbp2_device);
  523. }
  524. static int sbp2_probe(struct device *dev)
  525. {
  526. struct fw_unit *unit = fw_unit(dev);
  527. struct fw_device *device = fw_device(unit->device.parent);
  528. struct sbp2_device *sd;
  529. struct fw_csr_iterator ci;
  530. struct Scsi_Host *host;
  531. int i, key, value, err;
  532. u32 model, firmware_revision;
  533. err = -ENOMEM;
  534. host = scsi_host_alloc(&scsi_driver_template, sizeof(*sd));
  535. if (host == NULL)
  536. goto fail;
  537. sd = (struct sbp2_device *) host->hostdata;
  538. unit->device.driver_data = sd;
  539. sd->unit = unit;
  540. INIT_LIST_HEAD(&sd->orb_list);
  541. kref_init(&sd->kref);
  542. sd->address_handler.length = 0x100;
  543. sd->address_handler.address_callback = sbp2_status_write;
  544. sd->address_handler.callback_data = sd;
  545. err = fw_core_add_address_handler(&sd->address_handler,
  546. &fw_high_memory_region);
  547. if (err < 0)
  548. goto fail_host;
  549. err = fw_device_enable_phys_dma(device);
  550. if (err < 0)
  551. goto fail_address_handler;
  552. err = scsi_add_host(host, &unit->device);
  553. if (err < 0)
  554. goto fail_address_handler;
  555. /*
  556. * Scan unit directory to get management agent address,
  557. * firmware revison and model. Initialize firmware_revision
  558. * and model to values that wont match anything in our table.
  559. */
  560. firmware_revision = 0xff000000;
  561. model = 0xff000000;
  562. fw_csr_iterator_init(&ci, unit->directory);
  563. while (fw_csr_iterator_next(&ci, &key, &value)) {
  564. switch (key) {
  565. case CSR_DEPENDENT_INFO | CSR_OFFSET:
  566. sd->management_agent_address =
  567. 0xfffff0000000ULL + 4 * value;
  568. break;
  569. case SBP2_FIRMWARE_REVISION:
  570. firmware_revision = value;
  571. break;
  572. case CSR_MODEL:
  573. model = value;
  574. break;
  575. }
  576. }
  577. for (i = 0; i < ARRAY_SIZE(sbp2_workarounds_table); i++) {
  578. if (sbp2_workarounds_table[i].firmware_revision !=
  579. (firmware_revision & 0xffffff00))
  580. continue;
  581. if (sbp2_workarounds_table[i].model != model &&
  582. sbp2_workarounds_table[i].model != ~0)
  583. continue;
  584. sd->workarounds |= sbp2_workarounds_table[i].workarounds;
  585. break;
  586. }
  587. if (sd->workarounds)
  588. fw_notify("Workarounds for node %s: 0x%x "
  589. "(firmware_revision 0x%06x, model_id 0x%06x)\n",
  590. unit->device.bus_id,
  591. sd->workarounds, firmware_revision, model);
  592. get_device(&unit->device);
  593. /*
  594. * We schedule work to do the login so we can easily
  595. * reschedule retries. Always get the ref before scheduling
  596. * work.
  597. */
  598. INIT_DELAYED_WORK(&sd->work, sbp2_login);
  599. if (schedule_delayed_work(&sd->work, 0))
  600. kref_get(&sd->kref);
  601. return 0;
  602. fail_address_handler:
  603. fw_core_remove_address_handler(&sd->address_handler);
  604. fail_host:
  605. scsi_host_put(host);
  606. fail:
  607. return err;
  608. }
  609. static int sbp2_remove(struct device *dev)
  610. {
  611. struct fw_unit *unit = fw_unit(dev);
  612. struct sbp2_device *sd = unit->device.driver_data;
  613. kref_put(&sd->kref, release_sbp2_device);
  614. return 0;
  615. }
  616. static void sbp2_reconnect(struct work_struct *work)
  617. {
  618. struct sbp2_device *sd =
  619. container_of(work, struct sbp2_device, work.work);
  620. struct fw_unit *unit = sd->unit;
  621. struct fw_device *device = fw_device(unit->device.parent);
  622. int generation, node_id, local_node_id;
  623. generation = device->card->generation;
  624. node_id = device->node->node_id;
  625. local_node_id = device->card->local_node->node_id;
  626. if (sbp2_send_management_orb(unit, node_id, generation,
  627. SBP2_RECONNECT_REQUEST,
  628. sd->login_id, NULL) < 0) {
  629. if (sd->retries++ >= 5) {
  630. fw_error("failed to reconnect to %s\n",
  631. unit->device.bus_id);
  632. /* Fall back and try to log in again. */
  633. sd->retries = 0;
  634. PREPARE_DELAYED_WORK(&sd->work, sbp2_login);
  635. }
  636. schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5));
  637. return;
  638. }
  639. sd->generation = generation;
  640. sd->node_id = node_id;
  641. sd->address_high = local_node_id << 16;
  642. fw_notify("reconnected to unit %s (%d retries)\n",
  643. unit->device.bus_id, sd->retries);
  644. sbp2_agent_reset(unit);
  645. sbp2_cancel_orbs(unit);
  646. kref_put(&sd->kref, release_sbp2_device);
  647. }
  648. static void sbp2_update(struct fw_unit *unit)
  649. {
  650. struct fw_device *device = fw_device(unit->device.parent);
  651. struct sbp2_device *sd = unit->device.driver_data;
  652. sd->retries = 0;
  653. fw_device_enable_phys_dma(device);
  654. if (schedule_delayed_work(&sd->work, 0))
  655. kref_get(&sd->kref);
  656. }
  657. #define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e
  658. #define SBP2_SW_VERSION_ENTRY 0x00010483
  659. static const struct fw_device_id sbp2_id_table[] = {
  660. {
  661. .match_flags = FW_MATCH_SPECIFIER_ID | FW_MATCH_VERSION,
  662. .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY,
  663. .version = SBP2_SW_VERSION_ENTRY,
  664. },
  665. { }
  666. };
  667. static struct fw_driver sbp2_driver = {
  668. .driver = {
  669. .owner = THIS_MODULE,
  670. .name = sbp2_driver_name,
  671. .bus = &fw_bus_type,
  672. .probe = sbp2_probe,
  673. .remove = sbp2_remove,
  674. },
  675. .update = sbp2_update,
  676. .id_table = sbp2_id_table,
  677. };
  678. static unsigned int
  679. sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
  680. {
  681. int sam_status;
  682. sense_data[0] = 0x70;
  683. sense_data[1] = 0x0;
  684. sense_data[2] = sbp2_status[1];
  685. sense_data[3] = sbp2_status[4];
  686. sense_data[4] = sbp2_status[5];
  687. sense_data[5] = sbp2_status[6];
  688. sense_data[6] = sbp2_status[7];
  689. sense_data[7] = 10;
  690. sense_data[8] = sbp2_status[8];
  691. sense_data[9] = sbp2_status[9];
  692. sense_data[10] = sbp2_status[10];
  693. sense_data[11] = sbp2_status[11];
  694. sense_data[12] = sbp2_status[2];
  695. sense_data[13] = sbp2_status[3];
  696. sense_data[14] = sbp2_status[12];
  697. sense_data[15] = sbp2_status[13];
  698. sam_status = sbp2_status[0] & 0x3f;
  699. switch (sam_status) {
  700. case SAM_STAT_GOOD:
  701. case SAM_STAT_CHECK_CONDITION:
  702. case SAM_STAT_CONDITION_MET:
  703. case SAM_STAT_BUSY:
  704. case SAM_STAT_RESERVATION_CONFLICT:
  705. case SAM_STAT_COMMAND_TERMINATED:
  706. return DID_OK << 16 | sam_status;
  707. default:
  708. return DID_ERROR << 16;
  709. }
  710. }
  711. static void
  712. complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
  713. {
  714. struct sbp2_command_orb *orb = (struct sbp2_command_orb *)base_orb;
  715. struct fw_unit *unit = orb->unit;
  716. struct fw_device *device = fw_device(unit->device.parent);
  717. struct scatterlist *sg;
  718. int result;
  719. if (status != NULL) {
  720. if (STATUS_GET_DEAD(*status))
  721. sbp2_agent_reset(unit);
  722. switch (STATUS_GET_RESPONSE(*status)) {
  723. case SBP2_STATUS_REQUEST_COMPLETE:
  724. result = DID_OK << 16;
  725. break;
  726. case SBP2_STATUS_TRANSPORT_FAILURE:
  727. result = DID_BUS_BUSY << 16;
  728. break;
  729. case SBP2_STATUS_ILLEGAL_REQUEST:
  730. case SBP2_STATUS_VENDOR_DEPENDENT:
  731. default:
  732. result = DID_ERROR << 16;
  733. break;
  734. }
  735. if (result == DID_OK << 16 && STATUS_GET_LEN(*status) > 1)
  736. result = sbp2_status_to_sense_data(STATUS_GET_DATA(*status),
  737. orb->cmd->sense_buffer);
  738. } else {
  739. /*
  740. * If the orb completes with status == NULL, something
  741. * went wrong, typically a bus reset happened mid-orb
  742. * or when sending the write (less likely).
  743. */
  744. result = DID_BUS_BUSY << 16;
  745. }
  746. dma_unmap_single(device->card->device, orb->base.request_bus,
  747. sizeof(orb->request), DMA_TO_DEVICE);
  748. if (orb->cmd->use_sg > 0) {
  749. sg = (struct scatterlist *)orb->cmd->request_buffer;
  750. dma_unmap_sg(device->card->device, sg, orb->cmd->use_sg,
  751. orb->cmd->sc_data_direction);
  752. }
  753. if (orb->page_table_bus != 0)
  754. dma_unmap_single(device->card->device, orb->page_table_bus,
  755. sizeof(orb->page_table_bus), DMA_TO_DEVICE);
  756. orb->cmd->result = result;
  757. orb->done(orb->cmd);
  758. kfree(orb);
  759. }
  760. static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb)
  761. {
  762. struct sbp2_device *sd =
  763. (struct sbp2_device *)orb->cmd->device->host->hostdata;
  764. struct fw_unit *unit = sd->unit;
  765. struct fw_device *device = fw_device(unit->device.parent);
  766. struct scatterlist *sg;
  767. int sg_len, l, i, j, count;
  768. size_t size;
  769. dma_addr_t sg_addr;
  770. sg = (struct scatterlist *)orb->cmd->request_buffer;
  771. count = dma_map_sg(device->card->device, sg, orb->cmd->use_sg,
  772. orb->cmd->sc_data_direction);
  773. if (count == 0)
  774. goto fail;
  775. /*
  776. * Handle the special case where there is only one element in
  777. * the scatter list by converting it to an immediate block
  778. * request. This is also a workaround for broken devices such
  779. * as the second generation iPod which doesn't support page
  780. * tables.
  781. */
  782. if (count == 1 && sg_dma_len(sg) < SBP2_MAX_SG_ELEMENT_LENGTH) {
  783. orb->request.data_descriptor.high = sd->address_high;
  784. orb->request.data_descriptor.low = sg_dma_address(sg);
  785. orb->request.misc |=
  786. COMMAND_ORB_DATA_SIZE(sg_dma_len(sg));
  787. return 0;
  788. }
  789. /*
  790. * Convert the scatterlist to an sbp2 page table. If any
  791. * scatterlist entries are too big for sbp2, we split them as we
  792. * go. Even if we ask the block I/O layer to not give us sg
  793. * elements larger than 65535 bytes, some IOMMUs may merge sg elements
  794. * during DMA mapping, and Linux currently doesn't prevent this.
  795. */
  796. for (i = 0, j = 0; i < count; i++) {
  797. sg_len = sg_dma_len(sg + i);
  798. sg_addr = sg_dma_address(sg + i);
  799. while (sg_len) {
  800. l = min(sg_len, SBP2_MAX_SG_ELEMENT_LENGTH);
  801. orb->page_table[j].low = sg_addr;
  802. orb->page_table[j].high = (l << 16);
  803. sg_addr += l;
  804. sg_len -= l;
  805. j++;
  806. }
  807. }
  808. size = sizeof(orb->page_table[0]) * j;
  809. /*
  810. * The data_descriptor pointer is the one case where we need
  811. * to fill in the node ID part of the address. All other
  812. * pointers assume that the data referenced reside on the
  813. * initiator (i.e. us), but data_descriptor can refer to data
  814. * on other nodes so we need to put our ID in descriptor.high.
  815. */
  816. orb->page_table_bus =
  817. dma_map_single(device->card->device, orb->page_table,
  818. size, DMA_TO_DEVICE);
  819. if (dma_mapping_error(orb->page_table_bus))
  820. goto fail_page_table;
  821. orb->request.data_descriptor.high = sd->address_high;
  822. orb->request.data_descriptor.low = orb->page_table_bus;
  823. orb->request.misc |=
  824. COMMAND_ORB_PAGE_TABLE_PRESENT |
  825. COMMAND_ORB_DATA_SIZE(j);
  826. fw_memcpy_to_be32(orb->page_table, orb->page_table, size);
  827. return 0;
  828. fail_page_table:
  829. dma_unmap_sg(device->card->device, sg, orb->cmd->use_sg,
  830. orb->cmd->sc_data_direction);
  831. fail:
  832. return -ENOMEM;
  833. }
  834. /* SCSI stack integration */
  835. static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
  836. {
  837. struct sbp2_device *sd =
  838. (struct sbp2_device *)cmd->device->host->hostdata;
  839. struct fw_unit *unit = sd->unit;
  840. struct fw_device *device = fw_device(unit->device.parent);
  841. struct sbp2_command_orb *orb;
  842. /*
  843. * Bidirectional commands are not yet implemented, and unknown
  844. * transfer direction not handled.
  845. */
  846. if (cmd->sc_data_direction == DMA_BIDIRECTIONAL) {
  847. fw_error("Can't handle DMA_BIDIRECTIONAL, rejecting command\n");
  848. cmd->result = DID_ERROR << 16;
  849. done(cmd);
  850. return 0;
  851. }
  852. orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
  853. if (orb == NULL) {
  854. fw_notify("failed to alloc orb\n");
  855. goto fail_alloc;
  856. }
  857. /* Initialize rcode to something not RCODE_COMPLETE. */
  858. orb->base.rcode = -1;
  859. orb->base.request_bus =
  860. dma_map_single(device->card->device, &orb->request,
  861. sizeof(orb->request), DMA_TO_DEVICE);
  862. if (dma_mapping_error(orb->base.request_bus))
  863. goto fail_mapping;
  864. orb->unit = unit;
  865. orb->done = done;
  866. orb->cmd = cmd;
  867. orb->request.next.high = SBP2_ORB_NULL;
  868. orb->request.next.low = 0x0;
  869. /*
  870. * At speed 100 we can do 512 bytes per packet, at speed 200,
  871. * 1024 bytes per packet etc. The SBP-2 max_payload field
  872. * specifies the max payload size as 2 ^ (max_payload + 2), so
  873. * if we set this to max_speed + 7, we get the right value.
  874. */
  875. orb->request.misc =
  876. COMMAND_ORB_MAX_PAYLOAD(device->node->max_speed + 7) |
  877. COMMAND_ORB_SPEED(device->node->max_speed) |
  878. COMMAND_ORB_NOTIFY;
  879. if (cmd->sc_data_direction == DMA_FROM_DEVICE)
  880. orb->request.misc |=
  881. COMMAND_ORB_DIRECTION(SBP2_DIRECTION_FROM_MEDIA);
  882. else if (cmd->sc_data_direction == DMA_TO_DEVICE)
  883. orb->request.misc |=
  884. COMMAND_ORB_DIRECTION(SBP2_DIRECTION_TO_MEDIA);
  885. if (cmd->use_sg && sbp2_command_orb_map_scatterlist(orb) < 0)
  886. goto fail_map_payload;
  887. fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request));
  888. memset(orb->request.command_block,
  889. 0, sizeof(orb->request.command_block));
  890. memcpy(orb->request.command_block, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd));
  891. orb->base.callback = complete_command_orb;
  892. sbp2_send_orb(&orb->base, unit, sd->node_id, sd->generation,
  893. sd->command_block_agent_address + SBP2_ORB_POINTER);
  894. return 0;
  895. fail_map_payload:
  896. dma_unmap_single(device->card->device, orb->base.request_bus,
  897. sizeof(orb->request), DMA_TO_DEVICE);
  898. fail_mapping:
  899. kfree(orb);
  900. fail_alloc:
  901. return SCSI_MLQUEUE_HOST_BUSY;
  902. }
  903. static int sbp2_scsi_slave_alloc(struct scsi_device *sdev)
  904. {
  905. struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata;
  906. sdev->allow_restart = 1;
  907. if (sd->workarounds & SBP2_WORKAROUND_INQUIRY_36)
  908. sdev->inquiry_len = 36;
  909. return 0;
  910. }
  911. static int sbp2_scsi_slave_configure(struct scsi_device *sdev)
  912. {
  913. struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata;
  914. struct fw_unit *unit = sd->unit;
  915. sdev->use_10_for_rw = 1;
  916. if (sdev->type == TYPE_ROM)
  917. sdev->use_10_for_ms = 1;
  918. if (sdev->type == TYPE_DISK &&
  919. sd->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
  920. sdev->skip_ms_page_8 = 1;
  921. if (sd->workarounds & SBP2_WORKAROUND_FIX_CAPACITY) {
  922. fw_notify("setting fix_capacity for %s\n", unit->device.bus_id);
  923. sdev->fix_capacity = 1;
  924. }
  925. return 0;
  926. }
  927. /*
  928. * Called by scsi stack when something has really gone wrong. Usually
  929. * called when a command has timed-out for some reason.
  930. */
  931. static int sbp2_scsi_abort(struct scsi_cmnd *cmd)
  932. {
  933. struct sbp2_device *sd =
  934. (struct sbp2_device *)cmd->device->host->hostdata;
  935. struct fw_unit *unit = sd->unit;
  936. fw_notify("sbp2_scsi_abort\n");
  937. sbp2_agent_reset(unit);
  938. sbp2_cancel_orbs(unit);
  939. return SUCCESS;
  940. }
  941. /*
  942. * Format of /sys/bus/scsi/devices/.../ieee1394_id:
  943. * u64 EUI-64 : u24 directory_ID : u16 LUN (all printed in hexadecimal)
  944. *
  945. * This is the concatenation of target port identifier and logical unit
  946. * identifier as per SAM-2...SAM-4 annex A.
  947. */
  948. static ssize_t
  949. sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr,
  950. char *buf)
  951. {
  952. struct scsi_device *sdev = to_scsi_device(dev);
  953. struct sbp2_device *sd;
  954. struct fw_unit *unit;
  955. struct fw_device *device;
  956. u32 directory_id;
  957. struct fw_csr_iterator ci;
  958. int key, value, lun;
  959. if (!sdev)
  960. return 0;
  961. sd = (struct sbp2_device *)sdev->host->hostdata;
  962. unit = sd->unit;
  963. device = fw_device(unit->device.parent);
  964. /* implicit directory ID */
  965. directory_id = ((unit->directory - device->config_rom) * 4
  966. + CSR_CONFIG_ROM) & 0xffffff;
  967. /* explicit directory ID, overrides implicit ID if present */
  968. fw_csr_iterator_init(&ci, unit->directory);
  969. while (fw_csr_iterator_next(&ci, &key, &value))
  970. if (key == CSR_DIRECTORY_ID) {
  971. directory_id = value;
  972. break;
  973. }
  974. /* FIXME: Make this work for multi-lun devices. */
  975. lun = 0;
  976. return sprintf(buf, "%08x%08x:%06x:%04x\n",
  977. device->config_rom[3], device->config_rom[4],
  978. directory_id, lun);
  979. }
  980. static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL);
  981. static struct device_attribute *sbp2_scsi_sysfs_attrs[] = {
  982. &dev_attr_ieee1394_id,
  983. NULL
  984. };
  985. static struct scsi_host_template scsi_driver_template = {
  986. .module = THIS_MODULE,
  987. .name = "SBP-2 IEEE-1394",
  988. .proc_name = (char *)sbp2_driver_name,
  989. .queuecommand = sbp2_scsi_queuecommand,
  990. .slave_alloc = sbp2_scsi_slave_alloc,
  991. .slave_configure = sbp2_scsi_slave_configure,
  992. .eh_abort_handler = sbp2_scsi_abort,
  993. .this_id = -1,
  994. .sg_tablesize = SG_ALL,
  995. .use_clustering = ENABLE_CLUSTERING,
  996. .cmd_per_lun = 1,
  997. .can_queue = 1,
  998. .sdev_attrs = sbp2_scsi_sysfs_attrs,
  999. };
  1000. MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>");
  1001. MODULE_DESCRIPTION("SCSI over IEEE1394");
  1002. MODULE_LICENSE("GPL");
  1003. MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
  1004. /* Provide a module alias so root-on-sbp2 initrds don't break. */
  1005. #ifndef CONFIG_IEEE1394_SBP2_MODULE
  1006. MODULE_ALIAS("sbp2");
  1007. #endif
  1008. static int __init sbp2_init(void)
  1009. {
  1010. return driver_register(&sbp2_driver.driver);
  1011. }
  1012. static void __exit sbp2_cleanup(void)
  1013. {
  1014. driver_unregister(&sbp2_driver.driver);
  1015. }
  1016. module_init(sbp2_init);
  1017. module_exit(sbp2_cleanup);