fw-sbp2.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195
  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/blkdev.h>
  36. #include <linux/timer.h>
  37. #include <scsi/scsi.h>
  38. #include <scsi/scsi_cmnd.h>
  39. #include <scsi/scsi_dbg.h>
  40. #include <scsi/scsi_device.h>
  41. #include <scsi/scsi_host.h>
  42. #include "fw-transaction.h"
  43. #include "fw-topology.h"
  44. #include "fw-device.h"
  45. /* I don't know why the SCSI stack doesn't define something like this... */
  46. typedef void (*scsi_done_fn_t)(struct scsi_cmnd *);
  47. static const char sbp2_driver_name[] = "sbp2";
  48. struct sbp2_device {
  49. struct kref kref;
  50. struct fw_unit *unit;
  51. struct fw_address_handler address_handler;
  52. struct list_head orb_list;
  53. u64 management_agent_address;
  54. u64 command_block_agent_address;
  55. u32 workarounds;
  56. int login_id;
  57. /*
  58. * We cache these addresses and only update them once we've
  59. * logged in or reconnected to the sbp2 device. That way, any
  60. * IO to the device will automatically fail and get retried if
  61. * it happens in a window where the device is not ready to
  62. * handle it (e.g. after a bus reset but before we reconnect).
  63. */
  64. int node_id;
  65. int address_high;
  66. int generation;
  67. int retries;
  68. struct delayed_work work;
  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. };
  184. /*
  185. * List of devices with known bugs.
  186. *
  187. * The firmware_revision field, masked with 0xffff00, is the best
  188. * indicator for the type of bridge chip of a device. It yields a few
  189. * false positives but this did not break correctly behaving devices
  190. * so far. We use ~0 as a wildcard, since the 24 bit values we get
  191. * from the config rom can never match that.
  192. */
  193. static const struct {
  194. u32 firmware_revision;
  195. u32 model;
  196. unsigned workarounds;
  197. } sbp2_workarounds_table[] = {
  198. /* DViCO Momobay CX-1 with TSB42AA9 bridge */ {
  199. .firmware_revision = 0x002800,
  200. .model = 0x001010,
  201. .workarounds = SBP2_WORKAROUND_INQUIRY_36 |
  202. SBP2_WORKAROUND_MODE_SENSE_8,
  203. },
  204. /* Initio bridges, actually only needed for some older ones */ {
  205. .firmware_revision = 0x000200,
  206. .model = ~0,
  207. .workarounds = SBP2_WORKAROUND_INQUIRY_36,
  208. },
  209. /* Symbios bridge */ {
  210. .firmware_revision = 0xa0b800,
  211. .model = ~0,
  212. .workarounds = SBP2_WORKAROUND_128K_MAX_TRANS,
  213. },
  214. /*
  215. * There are iPods (2nd gen, 3rd gen) with model_id == 0, but
  216. * these iPods do not feature the read_capacity bug according
  217. * to one report. Read_capacity behaviour as well as model_id
  218. * could change due to Apple-supplied firmware updates though.
  219. */
  220. /* iPod 4th generation. */ {
  221. .firmware_revision = 0x0a2700,
  222. .model = 0x000021,
  223. .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
  224. },
  225. /* iPod mini */ {
  226. .firmware_revision = 0x0a2700,
  227. .model = 0x000023,
  228. .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
  229. },
  230. /* iPod Photo */ {
  231. .firmware_revision = 0x0a2700,
  232. .model = 0x00007e,
  233. .workarounds = SBP2_WORKAROUND_FIX_CAPACITY,
  234. }
  235. };
  236. static void
  237. sbp2_status_write(struct fw_card *card, struct fw_request *request,
  238. int tcode, int destination, int source,
  239. int generation, int speed,
  240. unsigned long long offset,
  241. void *payload, size_t length, void *callback_data)
  242. {
  243. struct sbp2_device *sd = callback_data;
  244. struct sbp2_orb *orb;
  245. struct sbp2_status status;
  246. size_t header_size;
  247. unsigned long flags;
  248. if (tcode != TCODE_WRITE_BLOCK_REQUEST ||
  249. length == 0 || length > sizeof(status)) {
  250. fw_send_response(card, request, RCODE_TYPE_ERROR);
  251. return;
  252. }
  253. header_size = min(length, 2 * sizeof(u32));
  254. fw_memcpy_from_be32(&status, payload, header_size);
  255. if (length > header_size)
  256. memcpy(status.data, payload + 8, length - header_size);
  257. if (STATUS_GET_SOURCE(status) == 2 || STATUS_GET_SOURCE(status) == 3) {
  258. fw_notify("non-orb related status write, not handled\n");
  259. fw_send_response(card, request, RCODE_COMPLETE);
  260. return;
  261. }
  262. /* Lookup the orb corresponding to this status write. */
  263. spin_lock_irqsave(&card->lock, flags);
  264. list_for_each_entry(orb, &sd->orb_list, link) {
  265. if (STATUS_GET_ORB_HIGH(status) == 0 &&
  266. STATUS_GET_ORB_LOW(status) == orb->request_bus &&
  267. orb->rcode == RCODE_COMPLETE) {
  268. list_del(&orb->link);
  269. break;
  270. }
  271. }
  272. spin_unlock_irqrestore(&card->lock, flags);
  273. if (&orb->link != &sd->orb_list)
  274. orb->callback(orb, &status);
  275. else
  276. fw_error("status write for unknown orb\n");
  277. fw_send_response(card, request, RCODE_COMPLETE);
  278. }
  279. static void
  280. complete_transaction(struct fw_card *card, int rcode,
  281. void *payload, size_t length, void *data)
  282. {
  283. struct sbp2_orb *orb = data;
  284. unsigned long flags;
  285. orb->rcode = rcode;
  286. if (rcode != RCODE_COMPLETE) {
  287. spin_lock_irqsave(&card->lock, flags);
  288. list_del(&orb->link);
  289. spin_unlock_irqrestore(&card->lock, flags);
  290. orb->callback(orb, NULL);
  291. }
  292. }
  293. static void
  294. sbp2_send_orb(struct sbp2_orb *orb, struct fw_unit *unit,
  295. int node_id, int generation, u64 offset)
  296. {
  297. struct fw_device *device = fw_device(unit->device.parent);
  298. struct sbp2_device *sd = unit->device.driver_data;
  299. unsigned long flags;
  300. orb->pointer.high = 0;
  301. orb->pointer.low = orb->request_bus;
  302. fw_memcpy_to_be32(&orb->pointer, &orb->pointer, sizeof(orb->pointer));
  303. spin_lock_irqsave(&device->card->lock, flags);
  304. list_add_tail(&orb->link, &sd->orb_list);
  305. spin_unlock_irqrestore(&device->card->lock, flags);
  306. fw_send_request(device->card, &orb->t, TCODE_WRITE_BLOCK_REQUEST,
  307. node_id, generation, device->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->max_speed + 7) |
  877. COMMAND_ORB_SPEED(device->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. if (sd->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
  926. blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512);
  927. return 0;
  928. }
  929. /*
  930. * Called by scsi stack when something has really gone wrong. Usually
  931. * called when a command has timed-out for some reason.
  932. */
  933. static int sbp2_scsi_abort(struct scsi_cmnd *cmd)
  934. {
  935. struct sbp2_device *sd =
  936. (struct sbp2_device *)cmd->device->host->hostdata;
  937. struct fw_unit *unit = sd->unit;
  938. fw_notify("sbp2_scsi_abort\n");
  939. sbp2_agent_reset(unit);
  940. sbp2_cancel_orbs(unit);
  941. return SUCCESS;
  942. }
  943. /*
  944. * Format of /sys/bus/scsi/devices/.../ieee1394_id:
  945. * u64 EUI-64 : u24 directory_ID : u16 LUN (all printed in hexadecimal)
  946. *
  947. * This is the concatenation of target port identifier and logical unit
  948. * identifier as per SAM-2...SAM-4 annex A.
  949. */
  950. static ssize_t
  951. sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr,
  952. char *buf)
  953. {
  954. struct scsi_device *sdev = to_scsi_device(dev);
  955. struct sbp2_device *sd;
  956. struct fw_unit *unit;
  957. struct fw_device *device;
  958. u32 directory_id;
  959. struct fw_csr_iterator ci;
  960. int key, value, lun;
  961. if (!sdev)
  962. return 0;
  963. sd = (struct sbp2_device *)sdev->host->hostdata;
  964. unit = sd->unit;
  965. device = fw_device(unit->device.parent);
  966. /* implicit directory ID */
  967. directory_id = ((unit->directory - device->config_rom) * 4
  968. + CSR_CONFIG_ROM) & 0xffffff;
  969. /* explicit directory ID, overrides implicit ID if present */
  970. fw_csr_iterator_init(&ci, unit->directory);
  971. while (fw_csr_iterator_next(&ci, &key, &value))
  972. if (key == CSR_DIRECTORY_ID) {
  973. directory_id = value;
  974. break;
  975. }
  976. /* FIXME: Make this work for multi-lun devices. */
  977. lun = 0;
  978. return sprintf(buf, "%08x%08x:%06x:%04x\n",
  979. device->config_rom[3], device->config_rom[4],
  980. directory_id, lun);
  981. }
  982. static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL);
  983. static struct device_attribute *sbp2_scsi_sysfs_attrs[] = {
  984. &dev_attr_ieee1394_id,
  985. NULL
  986. };
  987. static struct scsi_host_template scsi_driver_template = {
  988. .module = THIS_MODULE,
  989. .name = "SBP-2 IEEE-1394",
  990. .proc_name = (char *)sbp2_driver_name,
  991. .queuecommand = sbp2_scsi_queuecommand,
  992. .slave_alloc = sbp2_scsi_slave_alloc,
  993. .slave_configure = sbp2_scsi_slave_configure,
  994. .eh_abort_handler = sbp2_scsi_abort,
  995. .this_id = -1,
  996. .sg_tablesize = SG_ALL,
  997. .use_clustering = ENABLE_CLUSTERING,
  998. .cmd_per_lun = 1,
  999. .can_queue = 1,
  1000. .sdev_attrs = sbp2_scsi_sysfs_attrs,
  1001. };
  1002. MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>");
  1003. MODULE_DESCRIPTION("SCSI over IEEE1394");
  1004. MODULE_LICENSE("GPL");
  1005. MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
  1006. /* Provide a module alias so root-on-sbp2 initrds don't break. */
  1007. #ifndef CONFIG_IEEE1394_SBP2_MODULE
  1008. MODULE_ALIAS("sbp2");
  1009. #endif
  1010. static int __init sbp2_init(void)
  1011. {
  1012. return driver_register(&sbp2_driver.driver);
  1013. }
  1014. static void __exit sbp2_cleanup(void)
  1015. {
  1016. driver_unregister(&sbp2_driver.driver);
  1017. }
  1018. module_init(sbp2_init);
  1019. module_exit(sbp2_cleanup);