Guest User

patch: nitrogen6x firewire traces

a guest
Jun 25th, 2015
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.25 KB | None | 0 0
  1. From 6a6a9745a020c90596fc5e6ffbb1676891f3ce8d Mon Sep 17 00:00:00 2001
  2. From: Eric <[email protected]>
  3. Date: Thu, 26 Mar 2015 15:38:48 -0600
  4. Subject: [PATCH] add firewire traces
  5.  
  6. ---
  7. drivers/firewire/ohci.c | 1 +
  8. drivers/firewire/sbp2.c | 54 ++++++++++++++++++++++++++++++++++--------------
  9. drivers/scsi/scsi_scan.c | 13 +++++++++---
  10. 3 files changed, 50 insertions(+), 18 deletions(-)
  11.  
  12. diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
  13. index 2ff8f2a..41a1cb38 100644
  14. --- a/drivers/firewire/ohci.c
  15. +++ b/drivers/firewire/ohci.c
  16. @@ -2037,6 +2037,7 @@ static void bus_reset_work(struct work_struct *work)
  17. spin_lock_irq(&ohci->lock);
  18.  
  19. ohci->generation = generation;
  20. + printk("firewire_ohci: bus_reset_work: clearing OHCI1394_busReset");
  21. reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset);
  22.  
  23. if (ohci->quirks & QUIRK_RESET_PACKET)
  24. diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c
  25. index 47674b9..cfb4b92 100644
  26. --- a/drivers/firewire/sbp2.c
  27. +++ b/drivers/firewire/sbp2.c
  28. @@ -486,7 +486,7 @@ static void complete_transaction(struct fw_card *card, int rcode,
  29. if (orb->rcode != RCODE_COMPLETE) {
  30. list_del(&orb->link);
  31. spin_unlock_irqrestore(&card->lock, flags);
  32. -
  33. + printk("sbp2-complete_transaction: complete_transaction() sending NULL status due to rcode != RCODE_COMPLETE\n");
  34. orb->callback(orb, NULL);
  35. kref_put(&orb->kref, free_orb); /* orb callback reference */
  36. } else {
  37. @@ -536,6 +536,7 @@ static int sbp2_cancel_orbs(struct sbp2_logical_unit *lu)
  38. if (fw_cancel_transaction(device->card, &orb->t) == 0)
  39. continue;
  40.  
  41. + printk("sbp2_cancel_orbs: setting rcode = RCODE_CANCELLED\n");
  42. orb->rcode = RCODE_CANCELLED;
  43. orb->callback(orb, NULL);
  44. kref_put(&orb->kref, free_orb); /* orb callback reference */
  45. @@ -653,15 +654,19 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
  46. return retval;
  47. }
  48.  
  49. -static void sbp2_agent_reset(struct sbp2_logical_unit *lu)
  50. +static int sbp2_agent_reset(struct sbp2_logical_unit *lu)
  51. {
  52. struct fw_device *device = target_parent_device(lu->tgt);
  53. __be32 d = 0;
  54. + int code;
  55. + printk("sbp2_agent_reset: command_block_agent_address is %lld, generation is %d\n", lu->command_block_agent_address, lu->generation);
  56.  
  57. - fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST,
  58. + code = fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST,
  59. lu->tgt->node_id, lu->generation, device->max_speed,
  60. lu->command_block_agent_address + SBP2_AGENT_RESET,
  61. &d, 4);
  62. + printk("sbp2_agent_reset returned rcode 0x%X (%s)\n", code, fw_rcode_string(code));
  63. + return code;
  64. }
  65.  
  66. static void complete_agent_reset_write_no_wait(struct fw_card *card,
  67. @@ -804,9 +809,11 @@ static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu)
  68. struct fw_device *device = target_parent_device(lu->tgt);
  69. __be32 d = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT);
  70.  
  71. - fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST,
  72. + int code;
  73. + code = fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST,
  74. lu->tgt->node_id, lu->generation, device->max_speed,
  75. CSR_REGISTER_BASE + CSR_BUSY_TIMEOUT, &d, 4);
  76. + printk("sbp2_set_busy_timeout returned rcode 0x%X (%s)\n", code, fw_rcode_string(code));
  77. }
  78.  
  79. static void sbp2_reconnect(struct work_struct *work);
  80. @@ -831,10 +838,12 @@ static void sbp2_login(struct work_struct *work)
  81. local_node_id = device->card->node_id;
  82.  
  83. /* If this is a re-login attempt, log out, or we might be rejected. */
  84. - if (lu->has_sdev)
  85. - sbp2_send_management_orb(lu, device->node_id, generation,
  86. - SBP2_LOGOUT_REQUEST, lu->login_id, NULL);
  87. -
  88. + if (lu->has_sdev){
  89. + if(sbp2_send_management_orb(lu, device->node_id, generation,
  90. + SBP2_LOGOUT_REQUEST, lu->login_id, NULL) < 0){
  91. + printk("sbp2_login: re-login attempt failed to logout of LUN %04x\n", lu->lun);
  92. + }
  93. + }
  94. if (sbp2_send_management_orb(lu, node_id, generation,
  95. SBP2_LOGIN_REQUEST, lu->lun, &response) < 0) {
  96. if (lu->retries++ < 5) {
  97. @@ -862,16 +871,21 @@ static void sbp2_login(struct work_struct *work)
  98. lu->lun, lu->retries);
  99.  
  100. /* set appropriate retry limit(s) in BUSY_TIMEOUT register */
  101. + printk("sbp2_login: command_block_agent_address is %lld, generation is %d\n", lu->command_block_agent_address, lu->generation);
  102. sbp2_set_busy_timeout(lu);
  103.  
  104. +
  105. PREPARE_DELAYED_WORK(&lu->work, sbp2_reconnect);
  106. - sbp2_agent_reset(lu);
  107. +
  108. + if(sbp2_agent_reset(lu)){
  109. + /*goto out_logout_login;*/
  110. + }
  111.  
  112. /* This was a re-login. */
  113. if (lu->has_sdev) {
  114. sbp2_cancel_orbs(lu);
  115. sbp2_conditionally_unblock(lu);
  116. -
  117. + printk("sbp2_login: lu->has_sdev is true... returning\n");
  118. return;
  119. }
  120.  
  121. @@ -880,6 +894,7 @@ static void sbp2_login(struct work_struct *work)
  122.  
  123. shost = container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
  124. sdev = __scsi_add_device(shost, 0, 0, sbp2_lun2int(lu->lun), lu);
  125. + printk("sbp2_login: scsi sdev = %d(0x%X)\n", (int)sdev, (int)sdev);
  126. /*
  127. * FIXME: We are unable to perform reconnects while in sbp2_login().
  128. * Therefore __scsi_add_device() will get into trouble if a bus reset
  129. @@ -889,9 +904,10 @@ static void sbp2_login(struct work_struct *work)
  130. */
  131.  
  132. /* Reported error during __scsi_add_device() */
  133. - if (IS_ERR(sdev))
  134. + if (IS_ERR(sdev)){
  135. + printk("sbp2_login: IS_ERR(sdev) is true... attempt logout_login\n");
  136. goto out_logout_login;
  137. -
  138. + }
  139. /* Unreported error during __scsi_add_device() */
  140. smp_rmb(); /* get current card generation */
  141. if (generation != device->card->generation) {
  142. @@ -911,13 +927,14 @@ static void sbp2_login(struct work_struct *work)
  143. smp_rmb(); /* generation may have changed */
  144. generation = device->generation;
  145. smp_rmb(); /* node_id must not be older than generation */
  146. -
  147. + printk("sbp2_login: out_logout_login: sending SBP2_LOGOUT_REQUEST.\n");
  148. sbp2_send_management_orb(lu, device->node_id, generation,
  149. SBP2_LOGOUT_REQUEST, lu->login_id, NULL);
  150. /*
  151. * If a bus reset happened, sbp2_update will have requeued
  152. * lu->work already. Reset the work from reconnect to login.
  153. */
  154. + printk("sbp2_login: out_logout_login: rescheduling login.\n");
  155. PREPARE_DELAYED_WORK(&lu->work, sbp2_login);
  156. }
  157.  
  158. @@ -928,9 +945,12 @@ static void sbp2_reconnect(struct work_struct *work)
  159. struct sbp2_target *tgt = lu->tgt;
  160. struct fw_device *device = target_parent_device(tgt);
  161. int generation, node_id, local_node_id;
  162. -
  163. + printk("sbp2_reconnect: sbp2_reconnect start..\n");
  164. if (fw_device_is_shutdown(device))
  165. + {
  166. + printk("sbp2_reconnect: returning because device is shut down.\n");
  167. return;
  168. + }
  169.  
  170. generation = device->generation;
  171. smp_rmb(); /* node IDs must not be older than generation */
  172. @@ -940,6 +960,7 @@ static void sbp2_reconnect(struct work_struct *work)
  173. if (sbp2_send_management_orb(lu, node_id, generation,
  174. SBP2_RECONNECT_REQUEST,
  175. lu->login_id, NULL) < 0) {
  176. + printk("sbp2_reconnect: sbp2_send_management_orb SBP2_RECONNECT_REQUEST returned non 0.\n");
  177. /*
  178. * If reconnect was impossible even though we are in the
  179. * current generation, fall back and try to log in again.
  180. @@ -952,10 +973,11 @@ static void sbp2_reconnect(struct work_struct *work)
  181. lu->retries++ >= 5) {
  182. dev_err(tgt_dev(tgt), "failed to reconnect\n");
  183. lu->retries = 0;
  184. + printk("sbp2_reconnect: failed to reconnect, rescheduling sbp2_login.\n");
  185. PREPARE_DELAYED_WORK(&lu->work, sbp2_login);
  186. }
  187. sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5));
  188. -
  189. + printk("sbp2_reconnect: exit after sbp2_queue_work..\n");
  190. return;
  191. }
  192.  
  193. @@ -1365,6 +1387,7 @@ static void complete_command_orb(struct sbp2_orb *base_orb,
  194. result = DID_OK << 16;
  195. break;
  196. case SBP2_STATUS_TRANSPORT_FAILURE:
  197. + printk("sbp2-complete_command_orb: Setting DID_BUS_BUSY due to SBP2_STATUS_TRANSPORT_FAILURE\n");
  198. result = DID_BUS_BUSY << 16;
  199. break;
  200. case SBP2_STATUS_ILLEGAL_REQUEST:
  201. @@ -1383,6 +1406,7 @@ static void complete_command_orb(struct sbp2_orb *base_orb,
  202. * went wrong, typically a bus reset happened mid-orb
  203. * or when sending the write (less likely).
  204. */
  205. + printk("sbp2-complete_command_orb: Setting DID_BUS_BUSY due to status == NULL\n");
  206. result = DID_BUS_BUSY << 16;
  207. sbp2_conditionally_block(orb->lu);
  208. }
  209. diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
  210. index 3e58b22..e351f8f 100644
  211. --- a/drivers/scsi/scsi_scan.c
  212. +++ b/drivers/scsi/scsi_scan.c
  213. @@ -1014,6 +1014,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
  214. * host adapter calls into here with rescan == 0.
  215. */
  216. sdev = scsi_device_lookup_by_target(starget, lun);
  217. + printk("scsi_probe_and_add_lun: scsi_device_lookup_by_target(0x%X, 0x%X) returned sdev of 0x%X\n", (int)starget, lun, (int)sdev);
  218. if (sdev) {
  219. if (rescan || !scsi_device_created(sdev)) {
  220. SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO
  221. @@ -1041,8 +1042,10 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
  222. if (!result)
  223. goto out_free_sdev;
  224.  
  225. - if (scsi_probe_lun(sdev, result, result_len, &bflags))
  226. + if (scsi_probe_lun(sdev, result, result_len, &bflags)){
  227. + printk("scsi_probe_and_add_lun: scsi_probe_lun returned non 0!\n");
  228. goto out_free_result;
  229. + }
  230.  
  231. if (bflagsp)
  232. *bflagsp = bflags;
  233. @@ -1508,9 +1511,12 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
  234. struct scsi_device *sdev = ERR_PTR(-ENODEV);
  235. struct device *parent = &shost->shost_gendev;
  236. struct scsi_target *starget;
  237. + int val;
  238.  
  239. - if (strncmp(scsi_scan_type, "none", 4) == 0)
  240. + if (strncmp(scsi_scan_type, "none", 4) == 0){
  241. + printk("__scsi_add_device: scsi_scan_type is none!\n");
  242. return ERR_PTR(-ENODEV);
  243. + }
  244.  
  245. starget = scsi_alloc_target(parent, channel, id);
  246. if (!starget)
  247. @@ -1522,7 +1528,8 @@ struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
  248. scsi_complete_async_scans();
  249.  
  250. if (scsi_host_scan_allowed(shost) && scsi_autopm_get_host(shost) == 0) {
  251. - scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata);
  252. + val = scsi_probe_and_add_lun(starget, lun, NULL, &sdev, 1, hostdata);
  253. + printk("__scsi_add_device: scsi_probe_add_lun returned %d(0x%X): sdev = %d (0x%X)\n", val, val, (int)sdev, (int)sdev);
  254. scsi_autopm_put_host(shost);
  255. }
  256. mutex_unlock(&shost->scan_mutex);
  257. --
  258. 1.8.3.1
Advertisement
Add Comment
Please, Sign In to add comment