fw-sbp2.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  1. /*
  2. * SBP2 driver (SCSI over IEEE1394)
  3. *
  4. * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. /*
  21. * The basic structure of this driver is based on the old storage driver,
  22. * drivers/ieee1394/sbp2.c, originally written by
  23. * James Goodwin <jamesg@filanet.com>
  24. * with later contributions and ongoing maintenance from
  25. * Ben Collins <bcollins@debian.org>,
  26. * Stefan Richter <stefanr@s5r6.in-berlin.de>
  27. * and many others.
  28. */
  29. #include <linux/kernel.h>
  30. #include <linux/module.h>
  31. #include <linux/mod_devicetable.h>
  32. #include <linux/device.h>
  33. #include <linux/scatterlist.h>
  34. #include <linux/dma-mapping.h>
  35. #include <linux/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 release_sbp2_device(struct kref *kref)
  448. {
  449. struct sbp2_device *sd = container_of(kref, struct sbp2_device, kref);
  450. struct Scsi_Host *host =
  451. container_of((void *)sd, struct Scsi_Host, hostdata[0]);
  452. scsi_remove_host(host);
  453. sbp2_send_management_orb(sd->unit, sd->node_id, sd->generation,
  454. SBP2_LOGOUT_REQUEST, sd->login_id, NULL);
  455. fw_core_remove_address_handler(&sd->address_handler);
  456. fw_notify("removed sbp2 unit %s\n", sd->unit->device.bus_id);
  457. put_device(&sd->unit->device);
  458. scsi_host_put(host);
  459. }
  460. static void sbp2_login(struct work_struct *work)
  461. {
  462. struct sbp2_device *sd =
  463. container_of(work, struct sbp2_device, work.work);
  464. struct Scsi_Host *host =
  465. container_of((void *)sd, struct Scsi_Host, hostdata[0]);
  466. struct fw_unit *unit = sd->unit;
  467. struct fw_device *device = fw_device(unit->device.parent);
  468. struct sbp2_login_response response;
  469. int generation, node_id, local_node_id, lun, retval;
  470. /* FIXME: Make this work for multi-lun devices. */
  471. lun = 0;
  472. generation = device->card->generation;
  473. node_id = device->node->node_id;
  474. local_node_id = device->card->local_node->node_id;
  475. if (sbp2_send_management_orb(unit, node_id, generation,
  476. SBP2_LOGIN_REQUEST, lun, &response) < 0) {
  477. if (sd->retries++ < 5) {
  478. schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5));
  479. } else {
  480. fw_error("failed to login to %s\n",
  481. unit->device.bus_id);
  482. kref_put(&sd->kref, release_sbp2_device);
  483. }
  484. return;
  485. }
  486. sd->generation = generation;
  487. sd->node_id = node_id;
  488. sd->address_high = local_node_id << 16;
  489. /* Get command block agent offset and login id. */
  490. sd->command_block_agent_address =
  491. ((u64) (response.command_block_agent.high & 0xffff) << 32) |
  492. response.command_block_agent.low;
  493. sd->login_id = LOGIN_RESPONSE_GET_LOGIN_ID(response);
  494. fw_notify("logged in to sbp2 unit %s (%d retries)\n",
  495. unit->device.bus_id, sd->retries);
  496. fw_notify(" - management_agent_address: 0x%012llx\n",
  497. (unsigned long long) sd->management_agent_address);
  498. fw_notify(" - command_block_agent_address: 0x%012llx\n",
  499. (unsigned long long) sd->command_block_agent_address);
  500. fw_notify(" - status write address: 0x%012llx\n",
  501. (unsigned long long) sd->address_handler.offset);
  502. #if 0
  503. /* FIXME: The linux1394 sbp2 does this last step. */
  504. sbp2_set_busy_timeout(scsi_id);
  505. #endif
  506. PREPARE_DELAYED_WORK(&sd->work, sbp2_reconnect);
  507. sbp2_agent_reset(unit);
  508. /* FIXME: Loop over luns here. */
  509. lun = 0;
  510. retval = scsi_add_device(host, 0, 0, lun);
  511. if (retval < 0) {
  512. sbp2_send_management_orb(unit, sd->node_id, sd->generation,
  513. SBP2_LOGOUT_REQUEST, sd->login_id,
  514. NULL);
  515. /*
  516. * Set this back to sbp2_login so we fall back and
  517. * retry login on bus reset.
  518. */
  519. PREPARE_DELAYED_WORK(&sd->work, sbp2_login);
  520. }
  521. kref_put(&sd->kref, release_sbp2_device);
  522. }
  523. static int sbp2_probe(struct device *dev)
  524. {
  525. struct fw_unit *unit = fw_unit(dev);
  526. struct fw_device *device = fw_device(unit->device.parent);
  527. struct sbp2_device *sd;
  528. struct fw_csr_iterator ci;
  529. struct Scsi_Host *host;
  530. int i, key, value, err;
  531. u32 model, firmware_revision;
  532. err = -ENOMEM;
  533. host = scsi_host_alloc(&scsi_driver_template, sizeof(*sd));
  534. if (host == NULL)
  535. goto fail;
  536. sd = (struct sbp2_device *) host->hostdata;
  537. unit->device.driver_data = sd;
  538. sd->unit = unit;
  539. INIT_LIST_HEAD(&sd->orb_list);
  540. kref_init(&sd->kref);
  541. sd->address_handler.length = 0x100;
  542. sd->address_handler.address_callback = sbp2_status_write;
  543. sd->address_handler.callback_data = sd;
  544. err = fw_core_add_address_handler(&sd->address_handler,
  545. &fw_high_memory_region);
  546. if (err < 0)
  547. goto fail_host;
  548. err = fw_device_enable_phys_dma(device);
  549. if (err < 0)
  550. goto fail_address_handler;
  551. err = scsi_add_host(host, &unit->device);
  552. if (err < 0)
  553. goto fail_address_handler;
  554. /*
  555. * Scan unit directory to get management agent address,
  556. * firmware revison and model. Initialize firmware_revision
  557. * and model to values that wont match anything in our table.
  558. */
  559. firmware_revision = 0xff000000;
  560. model = 0xff000000;
  561. fw_csr_iterator_init(&ci, unit->directory);
  562. while (fw_csr_iterator_next(&ci, &key, &value)) {
  563. switch (key) {
  564. case CSR_DEPENDENT_INFO | CSR_OFFSET:
  565. sd->management_agent_address =
  566. 0xfffff0000000ULL + 4 * value;
  567. break;
  568. case SBP2_FIRMWARE_REVISION:
  569. firmware_revision = value;
  570. break;
  571. case CSR_MODEL:
  572. model = value;
  573. break;
  574. }
  575. }
  576. for (i = 0; i < ARRAY_SIZE(sbp2_workarounds_table); i++) {
  577. if (sbp2_workarounds_table[i].firmware_revision !=
  578. (firmware_revision & 0xffffff00))
  579. continue;
  580. if (sbp2_workarounds_table[i].model != model &&
  581. sbp2_workarounds_table[i].model != ~0)
  582. continue;
  583. sd->workarounds |= sbp2_workarounds_table[i].workarounds;
  584. break;
  585. }
  586. if (sd->workarounds)
  587. fw_notify("Workarounds for node %s: 0x%x "
  588. "(firmware_revision 0x%06x, model_id 0x%06x)\n",
  589. unit->device.bus_id,
  590. sd->workarounds, firmware_revision, model);
  591. get_device(&unit->device);
  592. /*
  593. * We schedule work to do the login so we can easily
  594. * reschedule retries. Always get the ref before scheduling
  595. * work.
  596. */
  597. INIT_DELAYED_WORK(&sd->work, sbp2_login);
  598. if (schedule_delayed_work(&sd->work, 0))
  599. kref_get(&sd->kref);
  600. return 0;
  601. fail_address_handler:
  602. fw_core_remove_address_handler(&sd->address_handler);
  603. fail_host:
  604. scsi_host_put(host);
  605. fail:
  606. return err;
  607. }
  608. static int sbp2_remove(struct device *dev)
  609. {
  610. struct fw_unit *unit = fw_unit(dev);
  611. struct sbp2_device *sd = unit->device.driver_data;
  612. kref_put(&sd->kref, release_sbp2_device);
  613. return 0;
  614. }
  615. static void sbp2_reconnect(struct work_struct *work)
  616. {
  617. struct sbp2_device *sd =
  618. container_of(work, struct sbp2_device, work.work);
  619. struct fw_unit *unit = sd->unit;
  620. struct fw_device *device = fw_device(unit->device.parent);
  621. int generation, node_id, local_node_id;
  622. generation = device->card->generation;
  623. node_id = device->node->node_id;
  624. local_node_id = device->card->local_node->node_id;
  625. if (sbp2_send_management_orb(unit, node_id, generation,
  626. SBP2_RECONNECT_REQUEST,
  627. sd->login_id, NULL) < 0) {
  628. if (sd->retries++ >= 5) {
  629. fw_error("failed to reconnect to %s\n",
  630. unit->device.bus_id);
  631. /* Fall back and try to log in again. */
  632. sd->retries = 0;
  633. PREPARE_DELAYED_WORK(&sd->work, sbp2_login);
  634. }
  635. schedule_delayed_work(&sd->work, DIV_ROUND_UP(HZ, 5));
  636. return;
  637. }
  638. sd->generation = generation;
  639. sd->node_id = node_id;
  640. sd->address_high = local_node_id << 16;
  641. fw_notify("reconnected to unit %s (%d retries)\n",
  642. unit->device.bus_id, sd->retries);
  643. sbp2_agent_reset(unit);
  644. sbp2_cancel_orbs(unit);
  645. kref_put(&sd->kref, release_sbp2_device);
  646. }
  647. static void sbp2_update(struct fw_unit *unit)
  648. {
  649. struct fw_device *device = fw_device(unit->device.parent);
  650. struct sbp2_device *sd = unit->device.driver_data;
  651. sd->retries = 0;
  652. fw_device_enable_phys_dma(device);
  653. if (schedule_delayed_work(&sd->work, 0))
  654. kref_get(&sd->kref);
  655. }
  656. #define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e
  657. #define SBP2_SW_VERSION_ENTRY 0x00010483
  658. static const struct fw_device_id sbp2_id_table[] = {
  659. {
  660. .match_flags = FW_MATCH_SPECIFIER_ID | FW_MATCH_VERSION,
  661. .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY,
  662. .version = SBP2_SW_VERSION_ENTRY,
  663. },
  664. { }
  665. };
  666. static struct fw_driver sbp2_driver = {
  667. .driver = {
  668. .owner = THIS_MODULE,
  669. .name = sbp2_driver_name,
  670. .bus = &fw_bus_type,
  671. .probe = sbp2_probe,
  672. .remove = sbp2_remove,
  673. },
  674. .update = sbp2_update,
  675. .id_table = sbp2_id_table,
  676. };
  677. static unsigned int
  678. sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
  679. {
  680. int sam_status;
  681. sense_data[0] = 0x70;
  682. sense_data[1] = 0x0;
  683. sense_data[2] = sbp2_status[1];
  684. sense_data[3] = sbp2_status[4];
  685. sense_data[4] = sbp2_status[5];
  686. sense_data[5] = sbp2_status[6];
  687. sense_data[6] = sbp2_status[7];
  688. sense_data[7] = 10;
  689. sense_data[8] = sbp2_status[8];
  690. sense_data[9] = sbp2_status[9];
  691. sense_data[10] = sbp2_status[10];
  692. sense_data[11] = sbp2_status[11];
  693. sense_data[12] = sbp2_status[2];
  694. sense_data[13] = sbp2_status[3];
  695. sense_data[14] = sbp2_status[12];
  696. sense_data[15] = sbp2_status[13];
  697. sam_status = sbp2_status[0] & 0x3f;
  698. switch (sam_status) {
  699. case SAM_STAT_GOOD:
  700. case SAM_STAT_CHECK_CONDITION:
  701. case SAM_STAT_CONDITION_MET:
  702. case SAM_STAT_BUSY:
  703. case SAM_STAT_RESERVATION_CONFLICT:
  704. case SAM_STAT_COMMAND_TERMINATED:
  705. return DID_OK << 16 | sam_status;
  706. default:
  707. return DID_ERROR << 16;
  708. }
  709. }
  710. static void
  711. complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
  712. {
  713. struct sbp2_command_orb *orb = (struct sbp2_command_orb *)base_orb;
  714. struct fw_unit *unit = orb->unit;
  715. struct fw_device *device = fw_device(unit->device.parent);
  716. struct scatterlist *sg;
  717. int result;
  718. if (status != NULL) {
  719. if (STATUS_GET_DEAD(*status))
  720. sbp2_agent_reset(unit);
  721. switch (STATUS_GET_RESPONSE(*status)) {
  722. case SBP2_STATUS_REQUEST_COMPLETE:
  723. result = DID_OK << 16;
  724. break;
  725. case SBP2_STATUS_TRANSPORT_FAILURE:
  726. result = DID_BUS_BUSY << 16;
  727. break;
  728. case SBP2_STATUS_ILLEGAL_REQUEST:
  729. case SBP2_STATUS_VENDOR_DEPENDENT:
  730. default:
  731. result = DID_ERROR << 16;
  732. break;
  733. }
  734. if (result == DID_OK << 16 && STATUS_GET_LEN(*status) > 1)
  735. result = sbp2_status_to_sense_data(STATUS_GET_DATA(*status),
  736. orb->cmd->sense_buffer);
  737. } else {
  738. /*
  739. * If the orb completes with status == NULL, something
  740. * went wrong, typically a bus reset happened mid-orb
  741. * or when sending the write (less likely).
  742. */
  743. result = DID_BUS_BUSY << 16;
  744. }
  745. dma_unmap_single(device->card->device, orb->base.request_bus,
  746. sizeof(orb->request), DMA_TO_DEVICE);
  747. if (orb->cmd->use_sg > 0) {
  748. sg = (struct scatterlist *)orb->cmd->request_buffer;
  749. dma_unmap_sg(device->card->device, sg, orb->cmd->use_sg,
  750. orb->cmd->sc_data_direction);
  751. }
  752. if (orb->page_table_bus != 0)
  753. dma_unmap_single(device->card->device, orb->page_table_bus,
  754. sizeof(orb->page_table_bus), DMA_TO_DEVICE);
  755. orb->cmd->result = result;
  756. orb->done(orb->cmd);
  757. kfree(orb);
  758. }
  759. static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb)
  760. {
  761. struct sbp2_device *sd =
  762. (struct sbp2_device *)orb->cmd->device->host->hostdata;
  763. struct fw_unit *unit = sd->unit;
  764. struct fw_device *device = fw_device(unit->device.parent);
  765. struct scatterlist *sg;
  766. int sg_len, l, i, j, count;
  767. size_t size;
  768. dma_addr_t sg_addr;
  769. sg = (struct scatterlist *)orb->cmd->request_buffer;
  770. count = dma_map_sg(device->card->device, sg, orb->cmd->use_sg,
  771. orb->cmd->sc_data_direction);
  772. if (count == 0)
  773. goto fail;
  774. /*
  775. * Handle the special case where there is only one element in
  776. * the scatter list by converting it to an immediate block
  777. * request. This is also a workaround for broken devices such
  778. * as the second generation iPod which doesn't support page
  779. * tables.
  780. */
  781. if (count == 1 && sg_dma_len(sg) < SBP2_MAX_SG_ELEMENT_LENGTH) {
  782. orb->request.data_descriptor.high = sd->address_high;
  783. orb->request.data_descriptor.low = sg_dma_address(sg);
  784. orb->request.misc |=
  785. COMMAND_ORB_DATA_SIZE(sg_dma_len(sg));
  786. return 0;
  787. }
  788. /*
  789. * Convert the scatterlist to an sbp2 page table. If any
  790. * scatterlist entries are too big for sbp2, we split them as we
  791. * go. Even if we ask the block I/O layer to not give us sg
  792. * elements larger than 65535 bytes, some IOMMUs may merge sg elements
  793. * during DMA mapping, and Linux currently doesn't prevent this.
  794. */
  795. for (i = 0, j = 0; i < count; i++) {
  796. sg_len = sg_dma_len(sg + i);
  797. sg_addr = sg_dma_address(sg + i);
  798. while (sg_len) {
  799. l = min(sg_len, SBP2_MAX_SG_ELEMENT_LENGTH);
  800. orb->page_table[j].low = sg_addr;
  801. orb->page_table[j].high = (l << 16);
  802. sg_addr += l;
  803. sg_len -= l;
  804. j++;
  805. }
  806. }
  807. size = sizeof(orb->page_table[0]) * j;
  808. /*
  809. * The data_descriptor pointer is the one case where we need
  810. * to fill in the node ID part of the address. All other
  811. * pointers assume that the data referenced reside on the
  812. * initiator (i.e. us), but data_descriptor can refer to data
  813. * on other nodes so we need to put our ID in descriptor.high.
  814. */
  815. orb->page_table_bus =
  816. dma_map_single(device->card->device, orb->page_table,
  817. size, DMA_TO_DEVICE);
  818. if (dma_mapping_error(orb->page_table_bus))
  819. goto fail_page_table;
  820. orb->request.data_descriptor.high = sd->address_high;
  821. orb->request.data_descriptor.low = orb->page_table_bus;
  822. orb->request.misc |=
  823. COMMAND_ORB_PAGE_TABLE_PRESENT |
  824. COMMAND_ORB_DATA_SIZE(j);
  825. fw_memcpy_to_be32(orb->page_table, orb->page_table, size);
  826. return 0;
  827. fail_page_table:
  828. dma_unmap_sg(device->card->device, sg, orb->cmd->use_sg,
  829. orb->cmd->sc_data_direction);
  830. fail:
  831. return -ENOMEM;
  832. }
  833. /* SCSI stack integration */
  834. static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
  835. {
  836. struct sbp2_device *sd =
  837. (struct sbp2_device *)cmd->device->host->hostdata;
  838. struct fw_unit *unit = sd->unit;
  839. struct fw_device *device = fw_device(unit->device.parent);
  840. struct sbp2_command_orb *orb;
  841. /*
  842. * Bidirectional commands are not yet implemented, and unknown
  843. * transfer direction not handled.
  844. */
  845. if (cmd->sc_data_direction == DMA_BIDIRECTIONAL) {
  846. fw_error("Can't handle DMA_BIDIRECTIONAL, rejecting command\n");
  847. cmd->result = DID_ERROR << 16;
  848. done(cmd);
  849. return 0;
  850. }
  851. orb = kzalloc(sizeof(*orb), GFP_ATOMIC);
  852. if (orb == NULL) {
  853. fw_notify("failed to alloc orb\n");
  854. goto fail_alloc;
  855. }
  856. /* Initialize rcode to something not RCODE_COMPLETE. */
  857. orb->base.rcode = -1;
  858. orb->base.request_bus =
  859. dma_map_single(device->card->device, &orb->request,
  860. sizeof(orb->request), DMA_TO_DEVICE);
  861. if (dma_mapping_error(orb->base.request_bus))
  862. goto fail_mapping;
  863. orb->unit = unit;
  864. orb->done = done;
  865. orb->cmd = cmd;
  866. orb->request.next.high = SBP2_ORB_NULL;
  867. orb->request.next.low = 0x0;
  868. /*
  869. * At speed 100 we can do 512 bytes per packet, at speed 200,
  870. * 1024 bytes per packet etc. The SBP-2 max_payload field
  871. * specifies the max payload size as 2 ^ (max_payload + 2), so
  872. * if we set this to max_speed + 7, we get the right value.
  873. */
  874. orb->request.misc =
  875. COMMAND_ORB_MAX_PAYLOAD(device->max_speed + 7) |
  876. COMMAND_ORB_SPEED(device->max_speed) |
  877. COMMAND_ORB_NOTIFY;
  878. if (cmd->sc_data_direction == DMA_FROM_DEVICE)
  879. orb->request.misc |=
  880. COMMAND_ORB_DIRECTION(SBP2_DIRECTION_FROM_MEDIA);
  881. else if (cmd->sc_data_direction == DMA_TO_DEVICE)
  882. orb->request.misc |=
  883. COMMAND_ORB_DIRECTION(SBP2_DIRECTION_TO_MEDIA);
  884. if (cmd->use_sg && sbp2_command_orb_map_scatterlist(orb) < 0)
  885. goto fail_map_payload;
  886. fw_memcpy_to_be32(&orb->request, &orb->request, sizeof(orb->request));
  887. memset(orb->request.command_block,
  888. 0, sizeof(orb->request.command_block));
  889. memcpy(orb->request.command_block, cmd->cmnd, COMMAND_SIZE(*cmd->cmnd));
  890. orb->base.callback = complete_command_orb;
  891. sbp2_send_orb(&orb->base, unit, sd->node_id, sd->generation,
  892. sd->command_block_agent_address + SBP2_ORB_POINTER);
  893. return 0;
  894. fail_map_payload:
  895. dma_unmap_single(device->card->device, orb->base.request_bus,
  896. sizeof(orb->request), DMA_TO_DEVICE);
  897. fail_mapping:
  898. kfree(orb);
  899. fail_alloc:
  900. return SCSI_MLQUEUE_HOST_BUSY;
  901. }
  902. static int sbp2_scsi_slave_alloc(struct scsi_device *sdev)
  903. {
  904. struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata;
  905. sdev->allow_restart = 1;
  906. if (sd->workarounds & SBP2_WORKAROUND_INQUIRY_36)
  907. sdev->inquiry_len = 36;
  908. return 0;
  909. }
  910. static int sbp2_scsi_slave_configure(struct scsi_device *sdev)
  911. {
  912. struct sbp2_device *sd = (struct sbp2_device *)sdev->host->hostdata;
  913. struct fw_unit *unit = sd->unit;
  914. sdev->use_10_for_rw = 1;
  915. if (sdev->type == TYPE_ROM)
  916. sdev->use_10_for_ms = 1;
  917. if (sdev->type == TYPE_DISK &&
  918. sd->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
  919. sdev->skip_ms_page_8 = 1;
  920. if (sd->workarounds & SBP2_WORKAROUND_FIX_CAPACITY) {
  921. fw_notify("setting fix_capacity for %s\n", unit->device.bus_id);
  922. sdev->fix_capacity = 1;
  923. }
  924. if (sd->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
  925. blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512);
  926. return 0;
  927. }
  928. /*
  929. * Called by scsi stack when something has really gone wrong. Usually
  930. * called when a command has timed-out for some reason.
  931. */
  932. static int sbp2_scsi_abort(struct scsi_cmnd *cmd)
  933. {
  934. struct sbp2_device *sd =
  935. (struct sbp2_device *)cmd->device->host->hostdata;
  936. struct fw_unit *unit = sd->unit;
  937. fw_notify("sbp2_scsi_abort\n");
  938. sbp2_agent_reset(unit);
  939. sbp2_cancel_orbs(unit);
  940. return SUCCESS;
  941. }
  942. /*
  943. * Format of /sys/bus/scsi/devices/.../ieee1394_id:
  944. * u64 EUI-64 : u24 directory_ID : u16 LUN (all printed in hexadecimal)
  945. *
  946. * This is the concatenation of target port identifier and logical unit
  947. * identifier as per SAM-2...SAM-4 annex A.
  948. */
  949. static ssize_t
  950. sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr,
  951. char *buf)
  952. {
  953. struct scsi_device *sdev = to_scsi_device(dev);
  954. struct sbp2_device *sd;
  955. struct fw_unit *unit;
  956. struct fw_device *device;
  957. u32 directory_id;
  958. struct fw_csr_iterator ci;
  959. int key, value, lun;
  960. if (!sdev)
  961. return 0;
  962. sd = (struct sbp2_device *)sdev->host->hostdata;
  963. unit = sd->unit;
  964. device = fw_device(unit->device.parent);
  965. /* implicit directory ID */
  966. directory_id = ((unit->directory - device->config_rom) * 4
  967. + CSR_CONFIG_ROM) & 0xffffff;
  968. /* explicit directory ID, overrides implicit ID if present */
  969. fw_csr_iterator_init(&ci, unit->directory);
  970. while (fw_csr_iterator_next(&ci, &key, &value))
  971. if (key == CSR_DIRECTORY_ID) {
  972. directory_id = value;
  973. break;
  974. }
  975. /* FIXME: Make this work for multi-lun devices. */
  976. lun = 0;
  977. return sprintf(buf, "%08x%08x:%06x:%04x\n",
  978. device->config_rom[3], device->config_rom[4],
  979. directory_id, lun);
  980. }
  981. static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL);
  982. static struct device_attribute *sbp2_scsi_sysfs_attrs[] = {
  983. &dev_attr_ieee1394_id,
  984. NULL
  985. };
  986. static struct scsi_host_template scsi_driver_template = {
  987. .module = THIS_MODULE,
  988. .name = "SBP-2 IEEE-1394",
  989. .proc_name = (char *)sbp2_driver_name,
  990. .queuecommand = sbp2_scsi_queuecommand,
  991. .slave_alloc = sbp2_scsi_slave_alloc,
  992. .slave_configure = sbp2_scsi_slave_configure,
  993. .eh_abort_handler = sbp2_scsi_abort,
  994. .this_id = -1,
  995. .sg_tablesize = SG_ALL,
  996. .use_clustering = ENABLE_CLUSTERING,
  997. .cmd_per_lun = 1,
  998. .can_queue = 1,
  999. .sdev_attrs = sbp2_scsi_sysfs_attrs,
  1000. };
  1001. MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>");
  1002. MODULE_DESCRIPTION("SCSI over IEEE1394");
  1003. MODULE_LICENSE("GPL");
  1004. MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
  1005. /* Provide a module alias so root-on-sbp2 initrds don't break. */
  1006. #ifndef CONFIG_IEEE1394_SBP2_MODULE
  1007. MODULE_ALIAS("sbp2");
  1008. #endif
  1009. static int __init sbp2_init(void)
  1010. {
  1011. return driver_register(&sbp2_driver.driver);
  1012. }
  1013. static void __exit sbp2_cleanup(void)
  1014. {
  1015. driver_unregister(&sbp2_driver.driver);
  1016. }
  1017. module_init(sbp2_init);
  1018. module_exit(sbp2_cleanup);