aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libsas
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/libsas')
-rw-r--r--drivers/scsi/libsas/Kconfig8
-rw-r--r--drivers/scsi/libsas/Makefile4
-rw-r--r--drivers/scsi/libsas/sas_ata.c80
-rw-r--r--drivers/scsi/libsas/sas_dump.c4
-rw-r--r--drivers/scsi/libsas/sas_dump.h12
-rw-r--r--drivers/scsi/libsas/sas_expander.c5
-rw-r--r--drivers/scsi/libsas/sas_internal.h6
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c3
8 files changed, 29 insertions, 93 deletions
diff --git a/drivers/scsi/libsas/Kconfig b/drivers/scsi/libsas/Kconfig
index 18f33cd54411..9dafe64e7c7a 100644
--- a/drivers/scsi/libsas/Kconfig
+++ b/drivers/scsi/libsas/Kconfig
@@ -46,11 +46,3 @@ config SCSI_SAS_HOST_SMP
46 Allows sas hosts to receive SMP frames. Selecting this 46 Allows sas hosts to receive SMP frames. Selecting this
47 option builds an SMP interpreter into libsas. Say 47 option builds an SMP interpreter into libsas. Say
48 N here if you want to save the few kb this consumes. 48 N here if you want to save the few kb this consumes.
49
50config SCSI_SAS_LIBSAS_DEBUG
51 bool "Compile the SAS Domain Transport Attributes in debug mode"
52 default y
53 depends on SCSI_SAS_LIBSAS
54 help
55 Compiles the SAS Layer in debug mode. In debug mode, the
56 SAS Layer prints diagnostic and debug messages.
diff --git a/drivers/scsi/libsas/Makefile b/drivers/scsi/libsas/Makefile
index 1ad1323c60fa..566a10024598 100644
--- a/drivers/scsi/libsas/Makefile
+++ b/drivers/scsi/libsas/Makefile
@@ -21,10 +21,6 @@
21# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 21# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22# USA 22# USA
23 23
24ifeq ($(CONFIG_SCSI_SAS_LIBSAS_DEBUG),y)
25 EXTRA_CFLAGS += -DSAS_DEBUG
26endif
27
28obj-$(CONFIG_SCSI_SAS_LIBSAS) += libsas.o 24obj-$(CONFIG_SCSI_SAS_LIBSAS) += libsas.o
29libsas-y += sas_init.o \ 25libsas-y += sas_init.o \
30 sas_phy.o \ 26 sas_phy.o \
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index 4d3b704ede1c..31fc21f4d831 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -71,13 +71,13 @@ static enum ata_completion_errors sas_to_ata_err(struct task_status_struct *ts)
71 case SAS_SG_ERR: 71 case SAS_SG_ERR:
72 return AC_ERR_INVALID; 72 return AC_ERR_INVALID;
73 73
74 case SAM_STAT_CHECK_CONDITION:
75 case SAS_OPEN_TO: 74 case SAS_OPEN_TO:
76 case SAS_OPEN_REJECT: 75 case SAS_OPEN_REJECT:
77 SAS_DPRINTK("%s: Saw error %d. What to do?\n", 76 SAS_DPRINTK("%s: Saw error %d. What to do?\n",
78 __func__, ts->stat); 77 __func__, ts->stat);
79 return AC_ERR_OTHER; 78 return AC_ERR_OTHER;
80 79
80 case SAM_STAT_CHECK_CONDITION:
81 case SAS_ABORTED_TASK: 81 case SAS_ABORTED_TASK:
82 return AC_ERR_DEV; 82 return AC_ERR_DEV;
83 83
@@ -107,13 +107,15 @@ static void sas_ata_task_done(struct sas_task *task)
107 sas_ha = dev->port->ha; 107 sas_ha = dev->port->ha;
108 108
109 spin_lock_irqsave(dev->sata_dev.ap->lock, flags); 109 spin_lock_irqsave(dev->sata_dev.ap->lock, flags);
110 if (stat->stat == SAS_PROTO_RESPONSE || stat->stat == SAM_STAT_GOOD) { 110 if (stat->stat == SAS_PROTO_RESPONSE || stat->stat == SAM_STAT_GOOD ||
111 ((stat->stat == SAM_STAT_CHECK_CONDITION &&
112 dev->sata_dev.command_set == ATAPI_COMMAND_SET))) {
111 ata_tf_from_fis(resp->ending_fis, &dev->sata_dev.tf); 113 ata_tf_from_fis(resp->ending_fis, &dev->sata_dev.tf);
112 qc->err_mask |= ac_err_mask(dev->sata_dev.tf.command); 114 qc->err_mask |= ac_err_mask(dev->sata_dev.tf.command);
113 dev->sata_dev.sstatus = resp->sstatus; 115 dev->sata_dev.sstatus = resp->sstatus;
114 dev->sata_dev.serror = resp->serror; 116 dev->sata_dev.serror = resp->serror;
115 dev->sata_dev.scontrol = resp->scontrol; 117 dev->sata_dev.scontrol = resp->scontrol;
116 } else if (stat->stat != SAM_STAT_GOOD) { 118 } else {
117 ac = sas_to_ata_err(stat); 119 ac = sas_to_ata_err(stat);
118 if (ac) { 120 if (ac) {
119 SAS_DPRINTK("%s: SAS error %x\n", __func__, 121 SAS_DPRINTK("%s: SAS error %x\n", __func__,
@@ -305,55 +307,6 @@ static void sas_ata_post_internal(struct ata_queued_cmd *qc)
305 } 307 }
306} 308}
307 309
308static int sas_ata_scr_write(struct ata_link *link, unsigned int sc_reg_in,
309 u32 val)
310{
311 struct domain_device *dev = link->ap->private_data;
312
313 SAS_DPRINTK("STUB %s\n", __func__);
314 switch (sc_reg_in) {
315 case SCR_STATUS:
316 dev->sata_dev.sstatus = val;
317 break;
318 case SCR_CONTROL:
319 dev->sata_dev.scontrol = val;
320 break;
321 case SCR_ERROR:
322 dev->sata_dev.serror = val;
323 break;
324 case SCR_ACTIVE:
325 dev->sata_dev.ap->link.sactive = val;
326 break;
327 default:
328 return -EINVAL;
329 }
330 return 0;
331}
332
333static int sas_ata_scr_read(struct ata_link *link, unsigned int sc_reg_in,
334 u32 *val)
335{
336 struct domain_device *dev = link->ap->private_data;
337
338 SAS_DPRINTK("STUB %s\n", __func__);
339 switch (sc_reg_in) {
340 case SCR_STATUS:
341 *val = dev->sata_dev.sstatus;
342 return 0;
343 case SCR_CONTROL:
344 *val = dev->sata_dev.scontrol;
345 return 0;
346 case SCR_ERROR:
347 *val = dev->sata_dev.serror;
348 return 0;
349 case SCR_ACTIVE:
350 *val = dev->sata_dev.ap->link.sactive;
351 return 0;
352 default:
353 return -EINVAL;
354 }
355}
356
357static struct ata_port_operations sas_sata_ops = { 310static struct ata_port_operations sas_sata_ops = {
358 .prereset = ata_std_prereset, 311 .prereset = ata_std_prereset,
359 .softreset = NULL, 312 .softreset = NULL,
@@ -367,8 +320,6 @@ static struct ata_port_operations sas_sata_ops = {
367 .qc_fill_rtf = sas_ata_qc_fill_rtf, 320 .qc_fill_rtf = sas_ata_qc_fill_rtf,
368 .port_start = ata_sas_port_start, 321 .port_start = ata_sas_port_start,
369 .port_stop = ata_sas_port_stop, 322 .port_stop = ata_sas_port_stop,
370 .scr_read = sas_ata_scr_read,
371 .scr_write = sas_ata_scr_write
372}; 323};
373 324
374static struct ata_port_info sata_port_info = { 325static struct ata_port_info sata_port_info = {
@@ -801,7 +752,7 @@ void sas_ata_strategy_handler(struct Scsi_Host *shost)
801 752
802 if (!dev_is_sata(ddev)) 753 if (!dev_is_sata(ddev))
803 continue; 754 continue;
804 755
805 ata_port_printk(ap, KERN_DEBUG, "sas eh calling libata port error handler"); 756 ata_port_printk(ap, KERN_DEBUG, "sas eh calling libata port error handler");
806 ata_scsi_port_error_handler(shost, ap); 757 ata_scsi_port_error_handler(shost, ap);
807 } 758 }
@@ -834,13 +785,13 @@ int sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q,
834 LIST_HEAD(sata_q); 785 LIST_HEAD(sata_q);
835 786
836 ap = NULL; 787 ap = NULL;
837 788
838 list_for_each_entry_safe(cmd, n, work_q, eh_entry) { 789 list_for_each_entry_safe(cmd, n, work_q, eh_entry) {
839 struct domain_device *ddev = cmd_to_domain_dev(cmd); 790 struct domain_device *ddev = cmd_to_domain_dev(cmd);
840 791
841 if (!dev_is_sata(ddev) || TO_SAS_TASK(cmd)) 792 if (!dev_is_sata(ddev) || TO_SAS_TASK(cmd))
842 continue; 793 continue;
843 if(ap && ap != ddev->sata_dev.ap) 794 if (ap && ap != ddev->sata_dev.ap)
844 continue; 795 continue;
845 ap = ddev->sata_dev.ap; 796 ap = ddev->sata_dev.ap;
846 rtn = 1; 797 rtn = 1;
@@ -848,8 +799,21 @@ int sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q,
848 } 799 }
849 800
850 if (!list_empty(&sata_q)) { 801 if (!list_empty(&sata_q)) {
851 ata_port_printk(ap, KERN_DEBUG,"sas eh calling libata cmd error handler\n"); 802 ata_port_printk(ap, KERN_DEBUG, "sas eh calling libata cmd error handler\n");
852 ata_scsi_cmd_error_handler(shost, ap, &sata_q); 803 ata_scsi_cmd_error_handler(shost, ap, &sata_q);
804 /*
805 * ata's error handler may leave the cmd on the list
806 * so make sure they don't remain on a stack list
807 * about to go out of scope.
808 *
809 * This looks strange, since the commands are
810 * now part of no list, but the next error
811 * action will be ata_port_error_handler()
812 * which takes no list and sweeps them up
813 * anyway from the ata tag array.
814 */
815 while (!list_empty(&sata_q))
816 list_del_init(sata_q.next);
853 } 817 }
854 } while (ap); 818 } while (ap);
855 819
diff --git a/drivers/scsi/libsas/sas_dump.c b/drivers/scsi/libsas/sas_dump.c
index c17c25030f1c..fc460933575c 100644
--- a/drivers/scsi/libsas/sas_dump.c
+++ b/drivers/scsi/libsas/sas_dump.c
@@ -24,8 +24,6 @@
24 24
25#include "sas_dump.h" 25#include "sas_dump.h"
26 26
27#ifdef SAS_DEBUG
28
29static const char *sas_hae_str[] = { 27static const char *sas_hae_str[] = {
30 [0] = "HAE_RESET", 28 [0] = "HAE_RESET",
31}; 29};
@@ -72,5 +70,3 @@ void sas_dump_port(struct asd_sas_port *port)
72 SAS_DPRINTK("port%d: oob_mode:0x%x\n", port->id, port->oob_mode); 70 SAS_DPRINTK("port%d: oob_mode:0x%x\n", port->id, port->oob_mode);
73 SAS_DPRINTK("port%d: num_phys:%d\n", port->id, port->num_phys); 71 SAS_DPRINTK("port%d: num_phys:%d\n", port->id, port->num_phys);
74} 72}
75
76#endif /* SAS_DEBUG */
diff --git a/drivers/scsi/libsas/sas_dump.h b/drivers/scsi/libsas/sas_dump.h
index 47b45d4f5258..800e4c69093f 100644
--- a/drivers/scsi/libsas/sas_dump.h
+++ b/drivers/scsi/libsas/sas_dump.h
@@ -24,19 +24,7 @@
24 24
25#include "sas_internal.h" 25#include "sas_internal.h"
26 26
27#ifdef SAS_DEBUG
28
29void sas_dprint_porte(int phyid, enum port_event pe); 27void sas_dprint_porte(int phyid, enum port_event pe);
30void sas_dprint_phye(int phyid, enum phy_event pe); 28void sas_dprint_phye(int phyid, enum phy_event pe);
31void sas_dprint_hae(struct sas_ha_struct *sas_ha, enum ha_event he); 29void sas_dprint_hae(struct sas_ha_struct *sas_ha, enum ha_event he);
32void sas_dump_port(struct asd_sas_port *port); 30void sas_dump_port(struct asd_sas_port *port);
33
34#else /* SAS_DEBUG */
35
36static inline void sas_dprint_porte(int phyid, enum port_event pe) { }
37static inline void sas_dprint_phye(int phyid, enum phy_event pe) { }
38static inline void sas_dprint_hae(struct sas_ha_struct *sas_ha,
39 enum ha_event he) { }
40static inline void sas_dump_port(struct asd_sas_port *port) { }
41
42#endif /* SAS_DEBUG */
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 505ffe358293..f3f693b772ac 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -244,6 +244,11 @@ static int sas_ex_phy_discover_helper(struct domain_device *dev, u8 *disc_req,
244 * dev to host FIS as described in section G.5 of 244 * dev to host FIS as described in section G.5 of
245 * sas-2 r 04b */ 245 * sas-2 r 04b */
246 dr = &((struct smp_resp *)disc_resp)->disc; 246 dr = &((struct smp_resp *)disc_resp)->disc;
247 if (memcmp(dev->sas_addr, dr->attached_sas_addr,
248 SAS_ADDR_SIZE) == 0) {
249 sas_printk("Found loopback topology, just ignore it!\n");
250 return 0;
251 }
247 if (!(dr->attached_dev_type == 0 && 252 if (!(dr->attached_dev_type == 0 &&
248 dr->attached_sata_dev)) 253 dr->attached_sata_dev))
249 break; 254 break;
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index 0001374bd6b2..8b538bd1ff2b 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -33,11 +33,7 @@
33 33
34#define sas_printk(fmt, ...) printk(KERN_NOTICE "sas: " fmt, ## __VA_ARGS__) 34#define sas_printk(fmt, ...) printk(KERN_NOTICE "sas: " fmt, ## __VA_ARGS__)
35 35
36#ifdef SAS_DEBUG 36#define SAS_DPRINTK(fmt, ...) printk(KERN_DEBUG "sas: " fmt, ## __VA_ARGS__)
37#define SAS_DPRINTK(fmt, ...) printk(KERN_NOTICE "sas: " fmt, ## __VA_ARGS__)
38#else
39#define SAS_DPRINTK(fmt, ...)
40#endif
41 37
42#define TO_SAS_TASK(_scsi_cmd) ((void *)(_scsi_cmd)->host_scribble) 38#define TO_SAS_TASK(_scsi_cmd) ((void *)(_scsi_cmd)->host_scribble)
43#define ASSIGN_SAS_TASK(_sc, _t) do { (_sc)->host_scribble = (void *) _t; } while (0) 39#define ASSIGN_SAS_TASK(_sc, _t) do { (_sc)->host_scribble = (void *) _t; } while (0)
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 67758ea8eb7f..f6e189f40917 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -681,11 +681,10 @@ enum blk_eh_timer_return sas_scsi_timed_out(struct scsi_cmnd *cmd)
681{ 681{
682 struct sas_task *task = TO_SAS_TASK(cmd); 682 struct sas_task *task = TO_SAS_TASK(cmd);
683 unsigned long flags; 683 unsigned long flags;
684 enum blk_eh_timer_return rtn; 684 enum blk_eh_timer_return rtn;
685 685
686 if (sas_ata_timed_out(cmd, task, &rtn)) 686 if (sas_ata_timed_out(cmd, task, &rtn))
687 return rtn; 687 return rtn;
688
689 688
690 if (!task) { 689 if (!task) {
691 cmd->request->timeout /= 2; 690 cmd->request->timeout /= 2;