fw-sbp2.c 33 KB

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