2 * Parallel SCSI (SPI) transport specific attributes exported to sysfs.
4 * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
5 * Copyright (c) 2004, 2005 James Bottomley <James.Bottomley@SteelEye.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <linux/ctype.h>
22 #include <linux/init.h>
23 #include <linux/module.h>
24 #include <linux/workqueue.h>
25 #include <linux/blkdev.h>
26 #include <linux/mutex.h>
27 #include <linux/sysfs.h>
28 #include <linux/slab.h>
29 #include <linux/suspend.h>
30 #include <scsi/scsi.h>
31 #include "scsi_priv.h"
32 #include <scsi/scsi_device.h>
33 #include <scsi/scsi_host.h>
34 #include <scsi/scsi_cmnd.h>
35 #include <scsi/scsi_eh.h>
36 #include <scsi/scsi_tcq.h>
37 #include <scsi/scsi_transport.h>
38 #include <scsi/scsi_transport_spi.h>
40 #define SPI_NUM_ATTRS 14 /* increase this if you add attributes */
41 #define SPI_OTHER_ATTRS 1 /* Increase this if you add "always
43 #define SPI_HOST_ATTRS 1
45 #define SPI_MAX_ECHO_BUFFER_SIZE 4096
48 #define DV_TIMEOUT (10*HZ)
49 #define DV_RETRIES 3 /* should only need at most
52 /* Our blacklist flags */
54 SPI_BLIST_NOIUS = (__force blist_flags_t)0x1,
57 /* blacklist table, modelled on scsi_devinfo.c */
62 } spi_static_device_list[] __initdata = {
63 {"HP", "Ultrium 3-SCSI", SPI_BLIST_NOIUS },
64 {"IBM", "ULTRIUM-TD3", SPI_BLIST_NOIUS },
68 /* Private data accessors (keep these out of the header file) */
69 #define spi_dv_in_progress(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_in_progress)
70 #define spi_dv_mutex(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_mutex)
73 struct scsi_transport_template t;
74 struct spi_function_template *f;
77 #define to_spi_internal(tmpl) container_of(tmpl, struct spi_internal, t)
79 static const int ppr_to_ps[] = {
80 /* The PPR values 0-6 are reserved, fill them in when
81 * the committee defines them */
96 /* The PPR values at which you calculate the period in ns by multiplying
98 #define SPI_STATIC_PPR 0x0c
100 static int sprint_frac(char *dest, int value, int denom)
102 int frac = value % denom;
103 int result = sprintf(dest, "%d", value / denom);
107 dest[result++] = '.';
111 sprintf(dest + result, "%d", frac / denom);
116 dest[result++] = '\0';
120 static int spi_execute(struct scsi_device *sdev, const void *cmd,
121 enum dma_data_direction dir,
122 void *buffer, unsigned bufflen,
123 struct scsi_sense_hdr *sshdr)
126 unsigned char sense[SCSI_SENSE_BUFFERSIZE];
127 struct scsi_sense_hdr sshdr_tmp;
132 for(i = 0; i < DV_RETRIES; i++) {
134 * The purpose of the RQF_PM flag below is to bypass the
135 * SDEV_QUIESCE state.
137 result = scsi_execute(sdev, cmd, dir, buffer, bufflen, sense,
138 sshdr, DV_TIMEOUT, /* retries */ 1,
140 REQ_FAILFAST_TRANSPORT |
143 if (driver_byte(result) != DRIVER_SENSE ||
144 sshdr->sense_key != UNIT_ATTENTION)
151 enum spi_signal_type value;
154 { SPI_SIGNAL_UNKNOWN, "unknown" },
155 { SPI_SIGNAL_SE, "SE" },
156 { SPI_SIGNAL_LVD, "LVD" },
157 { SPI_SIGNAL_HVD, "HVD" },
160 static inline const char *spi_signal_to_string(enum spi_signal_type type)
164 for (i = 0; i < ARRAY_SIZE(signal_types); i++) {
165 if (type == signal_types[i].value)
166 return signal_types[i].name;
170 static inline enum spi_signal_type spi_signal_to_value(const char *name)
174 for (i = 0; i < ARRAY_SIZE(signal_types); i++) {
175 len = strlen(signal_types[i].name);
176 if (strncmp(name, signal_types[i].name, len) == 0 &&
177 (name[len] == '\n' || name[len] == '\0'))
178 return signal_types[i].value;
180 return SPI_SIGNAL_UNKNOWN;
183 static int spi_host_setup(struct transport_container *tc, struct device *dev,
186 struct Scsi_Host *shost = dev_to_shost(dev);
188 spi_signalling(shost) = SPI_SIGNAL_UNKNOWN;
193 static int spi_host_configure(struct transport_container *tc,
195 struct device *cdev);
197 static DECLARE_TRANSPORT_CLASS(spi_host_class,
203 static int spi_host_match(struct attribute_container *cont,
206 struct Scsi_Host *shost;
208 if (!scsi_is_host_device(dev))
211 shost = dev_to_shost(dev);
212 if (!shost->transportt || shost->transportt->host_attrs.ac.class
213 != &spi_host_class.class)
216 return &shost->transportt->host_attrs.ac == cont;
219 static int spi_target_configure(struct transport_container *tc,
221 struct device *cdev);
223 static int spi_device_configure(struct transport_container *tc,
227 struct scsi_device *sdev = to_scsi_device(dev);
228 struct scsi_target *starget = sdev->sdev_target;
229 blist_flags_t bflags;
231 bflags = scsi_get_device_flags_keyed(sdev, &sdev->inquiry[8],
235 /* Populate the target capability fields with the values
236 * gleaned from the device inquiry */
238 spi_support_sync(starget) = scsi_device_sync(sdev);
239 spi_support_wide(starget) = scsi_device_wide(sdev);
240 spi_support_dt(starget) = scsi_device_dt(sdev);
241 spi_support_dt_only(starget) = scsi_device_dt_only(sdev);
242 spi_support_ius(starget) = scsi_device_ius(sdev);
243 if (bflags & SPI_BLIST_NOIUS) {
244 dev_info(dev, "Information Units disabled by blacklist\n");
245 spi_support_ius(starget) = 0;
247 spi_support_qas(starget) = scsi_device_qas(sdev);
252 static int spi_setup_transport_attrs(struct transport_container *tc,
256 struct scsi_target *starget = to_scsi_target(dev);
258 spi_period(starget) = -1; /* illegal value */
259 spi_min_period(starget) = 0;
260 spi_offset(starget) = 0; /* async */
261 spi_max_offset(starget) = 255;
262 spi_width(starget) = 0; /* narrow */
263 spi_max_width(starget) = 1;
264 spi_iu(starget) = 0; /* no IU */
265 spi_max_iu(starget) = 1;
266 spi_dt(starget) = 0; /* ST */
267 spi_qas(starget) = 0;
268 spi_max_qas(starget) = 1;
269 spi_wr_flow(starget) = 0;
270 spi_rd_strm(starget) = 0;
271 spi_rti(starget) = 0;
272 spi_pcomp_en(starget) = 0;
273 spi_hold_mcs(starget) = 0;
274 spi_dv_pending(starget) = 0;
275 spi_dv_in_progress(starget) = 0;
276 spi_initial_dv(starget) = 0;
277 mutex_init(&spi_dv_mutex(starget));
282 #define spi_transport_show_simple(field, format_string) \
285 show_spi_transport_##field(struct device *dev, \
286 struct device_attribute *attr, char *buf) \
288 struct scsi_target *starget = transport_class_to_starget(dev); \
289 struct spi_transport_attrs *tp; \
291 tp = (struct spi_transport_attrs *)&starget->starget_data; \
292 return snprintf(buf, 20, format_string, tp->field); \
295 #define spi_transport_store_simple(field, format_string) \
298 store_spi_transport_##field(struct device *dev, \
299 struct device_attribute *attr, \
300 const char *buf, size_t count) \
303 struct scsi_target *starget = transport_class_to_starget(dev); \
304 struct spi_transport_attrs *tp; \
306 tp = (struct spi_transport_attrs *)&starget->starget_data; \
307 val = simple_strtoul(buf, NULL, 0); \
312 #define spi_transport_show_function(field, format_string) \
315 show_spi_transport_##field(struct device *dev, \
316 struct device_attribute *attr, char *buf) \
318 struct scsi_target *starget = transport_class_to_starget(dev); \
319 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
320 struct spi_transport_attrs *tp; \
321 struct spi_internal *i = to_spi_internal(shost->transportt); \
322 tp = (struct spi_transport_attrs *)&starget->starget_data; \
323 if (i->f->get_##field) \
324 i->f->get_##field(starget); \
325 return snprintf(buf, 20, format_string, tp->field); \
328 #define spi_transport_store_function(field, format_string) \
330 store_spi_transport_##field(struct device *dev, \
331 struct device_attribute *attr, \
332 const char *buf, size_t count) \
335 struct scsi_target *starget = transport_class_to_starget(dev); \
336 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
337 struct spi_internal *i = to_spi_internal(shost->transportt); \
339 if (!i->f->set_##field) \
341 val = simple_strtoul(buf, NULL, 0); \
342 i->f->set_##field(starget, val); \
346 #define spi_transport_store_max(field, format_string) \
348 store_spi_transport_##field(struct device *dev, \
349 struct device_attribute *attr, \
350 const char *buf, size_t count) \
353 struct scsi_target *starget = transport_class_to_starget(dev); \
354 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
355 struct spi_internal *i = to_spi_internal(shost->transportt); \
356 struct spi_transport_attrs *tp \
357 = (struct spi_transport_attrs *)&starget->starget_data; \
359 if (!i->f->set_##field) \
361 val = simple_strtoul(buf, NULL, 0); \
362 if (val > tp->max_##field) \
363 val = tp->max_##field; \
364 i->f->set_##field(starget, val); \
368 #define spi_transport_rd_attr(field, format_string) \
369 spi_transport_show_function(field, format_string) \
370 spi_transport_store_function(field, format_string) \
371 static DEVICE_ATTR(field, S_IRUGO, \
372 show_spi_transport_##field, \
373 store_spi_transport_##field);
375 #define spi_transport_simple_attr(field, format_string) \
376 spi_transport_show_simple(field, format_string) \
377 spi_transport_store_simple(field, format_string) \
378 static DEVICE_ATTR(field, S_IRUGO, \
379 show_spi_transport_##field, \
380 store_spi_transport_##field);
382 #define spi_transport_max_attr(field, format_string) \
383 spi_transport_show_function(field, format_string) \
384 spi_transport_store_max(field, format_string) \
385 spi_transport_simple_attr(max_##field, format_string) \
386 static DEVICE_ATTR(field, S_IRUGO, \
387 show_spi_transport_##field, \
388 store_spi_transport_##field);
390 /* The Parallel SCSI Tranport Attributes: */
391 spi_transport_max_attr(offset, "%d\n");
392 spi_transport_max_attr(width, "%d\n");
393 spi_transport_max_attr(iu, "%d\n");
394 spi_transport_rd_attr(dt, "%d\n");
395 spi_transport_max_attr(qas, "%d\n");
396 spi_transport_rd_attr(wr_flow, "%d\n");
397 spi_transport_rd_attr(rd_strm, "%d\n");
398 spi_transport_rd_attr(rti, "%d\n");
399 spi_transport_rd_attr(pcomp_en, "%d\n");
400 spi_transport_rd_attr(hold_mcs, "%d\n");
402 /* we only care about the first child device that's a real SCSI device
403 * so we return 1 to terminate the iteration when we find it */
404 static int child_iter(struct device *dev, void *data)
406 if (!scsi_is_sdev_device(dev))
409 spi_dv_device(to_scsi_device(dev));
414 store_spi_revalidate(struct device *dev, struct device_attribute *attr,
415 const char *buf, size_t count)
417 struct scsi_target *starget = transport_class_to_starget(dev);
419 device_for_each_child(&starget->dev, NULL, child_iter);
422 static DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate);
424 /* Translate the period into ns according to the current spec
425 * for SDTR/PPR messages */
426 static int period_to_str(char *buf, int period)
430 if (period < 0 || period > 0xff) {
432 } else if (period <= SPI_STATIC_PPR) {
433 picosec = ppr_to_ps[period];
435 picosec = period * 4000;
439 len = sprintf(buf, "reserved");
441 len = sprint_frac(buf, picosec, 1000);
448 show_spi_transport_period_helper(char *buf, int period)
450 int len = period_to_str(buf, period);
457 store_spi_transport_period_helper(struct device *dev, const char *buf,
458 size_t count, int *periodp)
460 int j, picosec, period = -1;
463 picosec = simple_strtoul(buf, &endp, 10) * 1000;
470 picosec += (*endp - '0') * mult;
475 for (j = 0; j <= SPI_STATIC_PPR; j++) {
476 if (ppr_to_ps[j] < picosec)
483 period = picosec / 4000;
494 show_spi_transport_period(struct device *dev,
495 struct device_attribute *attr, char *buf)
497 struct scsi_target *starget = transport_class_to_starget(dev);
498 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
499 struct spi_internal *i = to_spi_internal(shost->transportt);
500 struct spi_transport_attrs *tp =
501 (struct spi_transport_attrs *)&starget->starget_data;
503 if (i->f->get_period)
504 i->f->get_period(starget);
506 return show_spi_transport_period_helper(buf, tp->period);
510 store_spi_transport_period(struct device *cdev, struct device_attribute *attr,
511 const char *buf, size_t count)
513 struct scsi_target *starget = transport_class_to_starget(cdev);
514 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
515 struct spi_internal *i = to_spi_internal(shost->transportt);
516 struct spi_transport_attrs *tp =
517 (struct spi_transport_attrs *)&starget->starget_data;
520 if (!i->f->set_period)
523 retval = store_spi_transport_period_helper(cdev, buf, count, &period);
525 if (period < tp->min_period)
526 period = tp->min_period;
528 i->f->set_period(starget, period);
533 static DEVICE_ATTR(period, S_IRUGO,
534 show_spi_transport_period,
535 store_spi_transport_period);
538 show_spi_transport_min_period(struct device *cdev,
539 struct device_attribute *attr, char *buf)
541 struct scsi_target *starget = transport_class_to_starget(cdev);
542 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
543 struct spi_internal *i = to_spi_internal(shost->transportt);
544 struct spi_transport_attrs *tp =
545 (struct spi_transport_attrs *)&starget->starget_data;
547 if (!i->f->set_period)
550 return show_spi_transport_period_helper(buf, tp->min_period);
554 store_spi_transport_min_period(struct device *cdev,
555 struct device_attribute *attr,
556 const char *buf, size_t count)
558 struct scsi_target *starget = transport_class_to_starget(cdev);
559 struct spi_transport_attrs *tp =
560 (struct spi_transport_attrs *)&starget->starget_data;
562 return store_spi_transport_period_helper(cdev, buf, count,
567 static DEVICE_ATTR(min_period, S_IRUGO,
568 show_spi_transport_min_period,
569 store_spi_transport_min_period);
572 static ssize_t show_spi_host_signalling(struct device *cdev,
573 struct device_attribute *attr,
576 struct Scsi_Host *shost = transport_class_to_shost(cdev);
577 struct spi_internal *i = to_spi_internal(shost->transportt);
579 if (i->f->get_signalling)
580 i->f->get_signalling(shost);
582 return sprintf(buf, "%s\n", spi_signal_to_string(spi_signalling(shost)));
584 static ssize_t store_spi_host_signalling(struct device *dev,
585 struct device_attribute *attr,
586 const char *buf, size_t count)
588 struct Scsi_Host *shost = transport_class_to_shost(dev);
589 struct spi_internal *i = to_spi_internal(shost->transportt);
590 enum spi_signal_type type = spi_signal_to_value(buf);
592 if (!i->f->set_signalling)
595 if (type != SPI_SIGNAL_UNKNOWN)
596 i->f->set_signalling(shost, type);
600 static DEVICE_ATTR(signalling, S_IRUGO,
601 show_spi_host_signalling,
602 store_spi_host_signalling);
604 static ssize_t show_spi_host_width(struct device *cdev,
605 struct device_attribute *attr,
608 struct Scsi_Host *shost = transport_class_to_shost(cdev);
610 return sprintf(buf, "%s\n", shost->max_id == 16 ? "wide" : "narrow");
612 static DEVICE_ATTR(host_width, S_IRUGO,
613 show_spi_host_width, NULL);
615 static ssize_t show_spi_host_hba_id(struct device *cdev,
616 struct device_attribute *attr,
619 struct Scsi_Host *shost = transport_class_to_shost(cdev);
621 return sprintf(buf, "%d\n", shost->this_id);
623 static DEVICE_ATTR(hba_id, S_IRUGO,
624 show_spi_host_hba_id, NULL);
626 #define DV_SET(x, y) \
628 i->f->set_##x(sdev->sdev_target, y)
630 enum spi_compare_returns {
633 SPI_COMPARE_SKIP_TEST,
637 /* This is for read/write Domain Validation: If the device supports
638 * an echo buffer, we do read/write tests to it */
639 static enum spi_compare_returns
640 spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer,
641 u8 *ptr, const int retries)
643 int len = ptr - buffer;
645 unsigned int pattern = 0x0000ffff;
646 struct scsi_sense_hdr sshdr;
648 const char spi_write_buffer[] = {
649 WRITE_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0
651 const char spi_read_buffer[] = {
652 READ_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0
655 /* set up the pattern buffer. Doesn't matter if we spill
656 * slightly beyond since that's where the read buffer is */
657 for (j = 0; j < len; ) {
659 /* fill the buffer with counting (test a) */
660 for ( ; j < min(len, 32); j++)
663 /* fill the buffer with alternating words of 0x0 and
665 for ( ; j < min(len, k + 32); j += 2) {
666 u16 *word = (u16 *)&buffer[j];
668 *word = (j & 0x02) ? 0x0000 : 0xffff;
671 /* fill with crosstalk (alternating 0x5555 0xaaa)
673 for ( ; j < min(len, k + 32); j += 2) {
674 u16 *word = (u16 *)&buffer[j];
676 *word = (j & 0x02) ? 0x5555 : 0xaaaa;
679 /* fill with shifting bits (test d) */
680 for ( ; j < min(len, k + 32); j += 4) {
681 u32 *word = (unsigned int *)&buffer[j];
682 u32 roll = (pattern & 0x80000000) ? 1 : 0;
685 pattern = (pattern << 1) | roll;
687 /* don't bother with random data (test e) */
690 for (r = 0; r < retries; r++) {
691 result = spi_execute(sdev, spi_write_buffer, DMA_TO_DEVICE,
692 buffer, len, &sshdr);
693 if(result || !scsi_device_online(sdev)) {
695 scsi_device_set_state(sdev, SDEV_QUIESCE);
696 if (scsi_sense_valid(&sshdr)
697 && sshdr.sense_key == ILLEGAL_REQUEST
698 /* INVALID FIELD IN CDB */
699 && sshdr.asc == 0x24 && sshdr.ascq == 0x00)
700 /* This would mean that the drive lied
701 * to us about supporting an echo
702 * buffer (unfortunately some Western
703 * Digital drives do precisely this)
705 return SPI_COMPARE_SKIP_TEST;
708 sdev_printk(KERN_ERR, sdev, "Write Buffer failure %x\n", result);
709 return SPI_COMPARE_FAILURE;
713 spi_execute(sdev, spi_read_buffer, DMA_FROM_DEVICE,
715 scsi_device_set_state(sdev, SDEV_QUIESCE);
717 if (memcmp(buffer, ptr, len) != 0)
718 return SPI_COMPARE_FAILURE;
720 return SPI_COMPARE_SUCCESS;
723 /* This is for the simplest form of Domain Validation: a read test
724 * on the inquiry data from the device */
725 static enum spi_compare_returns
726 spi_dv_device_compare_inquiry(struct scsi_device *sdev, u8 *buffer,
727 u8 *ptr, const int retries)
730 const int len = sdev->inquiry_len;
731 const char spi_inquiry[] = {
732 INQUIRY, 0, 0, 0, len, 0
735 for (r = 0; r < retries; r++) {
738 result = spi_execute(sdev, spi_inquiry, DMA_FROM_DEVICE,
741 if(result || !scsi_device_online(sdev)) {
742 scsi_device_set_state(sdev, SDEV_QUIESCE);
743 return SPI_COMPARE_FAILURE;
746 /* If we don't have the inquiry data already, the
747 * first read gets it */
754 if (memcmp(buffer, ptr, len) != 0)
756 return SPI_COMPARE_FAILURE;
758 return SPI_COMPARE_SUCCESS;
761 static enum spi_compare_returns
762 spi_dv_retrain(struct scsi_device *sdev, u8 *buffer, u8 *ptr,
763 enum spi_compare_returns
764 (*compare_fn)(struct scsi_device *, u8 *, u8 *, int))
766 struct spi_internal *i = to_spi_internal(sdev->host->transportt);
767 struct scsi_target *starget = sdev->sdev_target;
768 int period = 0, prevperiod = 0;
769 enum spi_compare_returns retval;
774 retval = compare_fn(sdev, buffer, ptr, DV_LOOPS);
776 if (retval == SPI_COMPARE_SUCCESS
777 || retval == SPI_COMPARE_SKIP_TEST)
780 /* OK, retrain, fallback */
782 i->f->get_iu(starget);
784 i->f->get_qas(starget);
785 if (i->f->get_period)
786 i->f->get_period(sdev->sdev_target);
788 /* Here's the fallback sequence; first try turning off
789 * IU, then QAS (if we can control them), then finally
790 * fall down the periods */
791 if (i->f->set_iu && spi_iu(starget)) {
792 starget_printk(KERN_ERR, starget, "Domain Validation Disabling Information Units\n");
794 } else if (i->f->set_qas && spi_qas(starget)) {
795 starget_printk(KERN_ERR, starget, "Domain Validation Disabling Quick Arbitration and Selection\n");
798 newperiod = spi_period(starget);
799 period = newperiod > period ? newperiod : period;
803 period += period >> 1;
805 if (unlikely(period > 0xff || period == prevperiod)) {
806 /* Total failure; set to async and return */
807 starget_printk(KERN_ERR, starget, "Domain Validation Failure, dropping back to Asynchronous\n");
809 return SPI_COMPARE_FAILURE;
811 starget_printk(KERN_ERR, starget, "Domain Validation detected failure, dropping back\n");
812 DV_SET(period, period);
820 spi_dv_device_get_echo_buffer(struct scsi_device *sdev, u8 *buffer)
824 /* first off do a test unit ready. This can error out
825 * because of reservations or some other reason. If it
826 * fails, the device won't let us write to the echo buffer
827 * so just return failure */
829 static const char spi_test_unit_ready[] = {
830 TEST_UNIT_READY, 0, 0, 0, 0, 0
833 static const char spi_read_buffer_descriptor[] = {
834 READ_BUFFER, 0x0b, 0, 0, 0, 0, 0, 0, 4, 0
838 /* We send a set of three TURs to clear any outstanding
839 * unit attention conditions if they exist (Otherwise the
840 * buffer tests won't be happy). If the TUR still fails
841 * (reservation conflict, device not ready, etc) just
842 * skip the write tests */
844 result = spi_execute(sdev, spi_test_unit_ready, DMA_NONE,
856 result = spi_execute(sdev, spi_read_buffer_descriptor,
857 DMA_FROM_DEVICE, buffer, 4, NULL);
860 /* Device has no echo buffer */
863 return buffer[3] + ((buffer[2] & 0x1f) << 8);
867 spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer)
869 struct spi_internal *i = to_spi_internal(sdev->host->transportt);
870 struct scsi_target *starget = sdev->sdev_target;
871 struct Scsi_Host *shost = sdev->host;
872 int len = sdev->inquiry_len;
873 int min_period = spi_min_period(starget);
874 int max_width = spi_max_width(starget);
875 /* first set us up for narrow async */
879 if (spi_dv_device_compare_inquiry(sdev, buffer, buffer, DV_LOOPS)
880 != SPI_COMPARE_SUCCESS) {
881 starget_printk(KERN_ERR, starget, "Domain Validation Initial Inquiry Failed\n");
882 /* FIXME: should probably offline the device here? */
886 if (!spi_support_wide(starget)) {
887 spi_max_width(starget) = 0;
892 if (i->f->set_width && max_width) {
893 i->f->set_width(starget, 1);
895 if (spi_dv_device_compare_inquiry(sdev, buffer,
898 != SPI_COMPARE_SUCCESS) {
899 starget_printk(KERN_ERR, starget, "Wide Transfers Fail\n");
900 i->f->set_width(starget, 0);
901 /* Make sure we don't force wide back on by asking
902 * for a transfer period that requires it */
909 if (!i->f->set_period)
912 /* device can't handle synchronous */
913 if (!spi_support_sync(starget) && !spi_support_dt(starget))
916 /* len == -1 is the signal that we need to ascertain the
917 * presence of an echo buffer before trying to use it. len ==
918 * 0 means we don't have an echo buffer */
923 /* now set up to the maximum */
924 DV_SET(offset, spi_max_offset(starget));
925 DV_SET(period, min_period);
927 /* try QAS requests; this should be harmless to set if the
928 * target supports it */
929 if (spi_support_qas(starget) && spi_max_qas(starget)) {
935 if (spi_support_ius(starget) && spi_max_iu(starget) &&
937 /* This u320 (or u640). Set IU transfers */
939 /* Then set the optional parameters */
949 /* now that we've done all this, actually check the bus
950 * signal type (if known). Some devices are stupid on
951 * a SE bus and still claim they can try LVD only settings */
952 if (i->f->get_signalling)
953 i->f->get_signalling(shost);
954 if (spi_signalling(shost) == SPI_SIGNAL_SE ||
955 spi_signalling(shost) == SPI_SIGNAL_HVD ||
956 !spi_support_dt(starget)) {
961 /* set width last because it will pull all the other
962 * parameters down to required values */
963 DV_SET(width, max_width);
965 /* Do the read only INQUIRY tests */
966 spi_dv_retrain(sdev, buffer, buffer + sdev->inquiry_len,
967 spi_dv_device_compare_inquiry);
968 /* See if we actually managed to negotiate and sustain DT */
970 i->f->get_dt(starget);
972 /* see if the device has an echo buffer. If it does we can do
973 * the SPI pattern write tests. Because of some broken
974 * devices, we *only* try this on a device that has actually
977 if (len == -1 && spi_dt(starget))
978 len = spi_dv_device_get_echo_buffer(sdev, buffer);
981 starget_printk(KERN_INFO, starget, "Domain Validation skipping write tests\n");
985 if (len > SPI_MAX_ECHO_BUFFER_SIZE) {
986 starget_printk(KERN_WARNING, starget, "Echo buffer size %d is too big, trimming to %d\n", len, SPI_MAX_ECHO_BUFFER_SIZE);
987 len = SPI_MAX_ECHO_BUFFER_SIZE;
990 if (spi_dv_retrain(sdev, buffer, buffer + len,
991 spi_dv_device_echo_buffer)
992 == SPI_COMPARE_SKIP_TEST) {
993 /* OK, the stupid drive can't do a write echo buffer
994 * test after all, fall back to the read tests */
1001 /** spi_dv_device - Do Domain Validation on the device
1002 * @sdev: scsi device to validate
1004 * Performs the domain validation on the given device in the
1005 * current execution thread. Since DV operations may sleep,
1006 * the current thread must have user context. Also no SCSI
1007 * related locks that would deadlock I/O issued by the DV may
1011 spi_dv_device(struct scsi_device *sdev)
1013 struct scsi_target *starget = sdev->sdev_target;
1015 const int len = SPI_MAX_ECHO_BUFFER_SIZE*2;
1018 * Because this function and the power management code both call
1019 * scsi_device_quiesce(), it is not safe to perform domain validation
1020 * while suspend or resume is in progress. Hence the
1021 * lock/unlock_system_sleep() calls.
1023 lock_system_sleep();
1025 if (scsi_autopm_get_device(sdev))
1026 goto unlock_system_sleep;
1028 if (unlikely(spi_dv_in_progress(starget)))
1031 if (unlikely(scsi_device_get(sdev)))
1034 spi_dv_in_progress(starget) = 1;
1036 buffer = kzalloc(len, GFP_KERNEL);
1038 if (unlikely(!buffer))
1041 /* We need to verify that the actual device will quiesce; the
1042 * later target quiesce is just a nice to have */
1043 if (unlikely(scsi_device_quiesce(sdev)))
1046 scsi_target_quiesce(starget);
1048 spi_dv_pending(starget) = 1;
1049 mutex_lock(&spi_dv_mutex(starget));
1051 starget_printk(KERN_INFO, starget, "Beginning Domain Validation\n");
1053 spi_dv_device_internal(sdev, buffer);
1055 starget_printk(KERN_INFO, starget, "Ending Domain Validation\n");
1057 mutex_unlock(&spi_dv_mutex(starget));
1058 spi_dv_pending(starget) = 0;
1060 scsi_target_resume(starget);
1062 spi_initial_dv(starget) = 1;
1068 spi_dv_in_progress(starget) = 0;
1069 scsi_device_put(sdev);
1071 scsi_autopm_put_device(sdev);
1073 unlock_system_sleep:
1074 unlock_system_sleep();
1076 EXPORT_SYMBOL(spi_dv_device);
1078 struct work_queue_wrapper {
1079 struct work_struct work;
1080 struct scsi_device *sdev;
1084 spi_dv_device_work_wrapper(struct work_struct *work)
1086 struct work_queue_wrapper *wqw =
1087 container_of(work, struct work_queue_wrapper, work);
1088 struct scsi_device *sdev = wqw->sdev;
1091 spi_dv_device(sdev);
1092 spi_dv_pending(sdev->sdev_target) = 0;
1093 scsi_device_put(sdev);
1098 * spi_schedule_dv_device - schedule domain validation to occur on the device
1099 * @sdev: The device to validate
1101 * Identical to spi_dv_device() above, except that the DV will be
1102 * scheduled to occur in a workqueue later. All memory allocations
1103 * are atomic, so may be called from any context including those holding
1107 spi_schedule_dv_device(struct scsi_device *sdev)
1109 struct work_queue_wrapper *wqw =
1110 kmalloc(sizeof(struct work_queue_wrapper), GFP_ATOMIC);
1115 if (unlikely(spi_dv_pending(sdev->sdev_target))) {
1119 /* Set pending early (dv_device doesn't check it, only sets it) */
1120 spi_dv_pending(sdev->sdev_target) = 1;
1121 if (unlikely(scsi_device_get(sdev))) {
1123 spi_dv_pending(sdev->sdev_target) = 0;
1127 INIT_WORK(&wqw->work, spi_dv_device_work_wrapper);
1130 schedule_work(&wqw->work);
1132 EXPORT_SYMBOL(spi_schedule_dv_device);
1135 * spi_display_xfer_agreement - Print the current target transfer agreement
1136 * @starget: The target for which to display the agreement
1138 * Each SPI port is required to maintain a transfer agreement for each
1139 * other port on the bus. This function prints a one-line summary of
1140 * the current agreement; more detailed information is available in sysfs.
1142 void spi_display_xfer_agreement(struct scsi_target *starget)
1144 struct spi_transport_attrs *tp;
1145 tp = (struct spi_transport_attrs *)&starget->starget_data;
1147 if (tp->offset > 0 && tp->period > 0) {
1148 unsigned int picosec, kb100;
1149 char *scsi = "FAST-?";
1152 if (tp->period <= SPI_STATIC_PPR) {
1153 picosec = ppr_to_ps[tp->period];
1154 switch (tp->period) {
1155 case 7: scsi = "FAST-320"; break;
1156 case 8: scsi = "FAST-160"; break;
1157 case 9: scsi = "FAST-80"; break;
1159 case 11: scsi = "FAST-40"; break;
1160 case 12: scsi = "FAST-20"; break;
1163 picosec = tp->period * 4000;
1164 if (tp->period < 25)
1166 else if (tp->period < 50)
1172 kb100 = (10000000 + picosec / 2) / picosec;
1175 sprint_frac(tmp, picosec, 1000);
1177 dev_info(&starget->dev,
1178 "%s %sSCSI %d.%d MB/s %s%s%s%s%s%s%s%s (%s ns, offset %d)\n",
1179 scsi, tp->width ? "WIDE " : "", kb100/10, kb100 % 10,
1180 tp->dt ? "DT" : "ST",
1181 tp->iu ? " IU" : "",
1182 tp->qas ? " QAS" : "",
1183 tp->rd_strm ? " RDSTRM" : "",
1184 tp->rti ? " RTI" : "",
1185 tp->wr_flow ? " WRFLOW" : "",
1186 tp->pcomp_en ? " PCOMP" : "",
1187 tp->hold_mcs ? " HMCS" : "",
1190 dev_info(&starget->dev, "%sasynchronous\n",
1191 tp->width ? "wide " : "");
1194 EXPORT_SYMBOL(spi_display_xfer_agreement);
1196 int spi_populate_width_msg(unsigned char *msg, int width)
1198 msg[0] = EXTENDED_MESSAGE;
1200 msg[2] = EXTENDED_WDTR;
1204 EXPORT_SYMBOL_GPL(spi_populate_width_msg);
1206 int spi_populate_sync_msg(unsigned char *msg, int period, int offset)
1208 msg[0] = EXTENDED_MESSAGE;
1210 msg[2] = EXTENDED_SDTR;
1215 EXPORT_SYMBOL_GPL(spi_populate_sync_msg);
1217 int spi_populate_ppr_msg(unsigned char *msg, int period, int offset,
1218 int width, int options)
1220 msg[0] = EXTENDED_MESSAGE;
1222 msg[2] = EXTENDED_PPR;
1230 EXPORT_SYMBOL_GPL(spi_populate_ppr_msg);
1233 * spi_populate_tag_msg - place a tag message in a buffer
1234 * @msg: pointer to the area to place the tag
1235 * @cmd: pointer to the scsi command for the tag
1238 * designed to create the correct type of tag message for the
1239 * particular request. Returns the size of the tag message.
1240 * May return 0 if TCQ is disabled for this device.
1242 int spi_populate_tag_msg(unsigned char *msg, struct scsi_cmnd *cmd)
1244 if (cmd->flags & SCMD_TAGGED) {
1245 *msg++ = SIMPLE_QUEUE_TAG;
1246 *msg++ = cmd->request->tag;
1252 EXPORT_SYMBOL_GPL(spi_populate_tag_msg);
1254 #ifdef CONFIG_SCSI_CONSTANTS
1255 static const char * const one_byte_msgs[] = {
1256 /* 0x00 */ "Task Complete", NULL /* Extended Message */, "Save Pointers",
1257 /* 0x03 */ "Restore Pointers", "Disconnect", "Initiator Error",
1258 /* 0x06 */ "Abort Task Set", "Message Reject", "Nop", "Message Parity Error",
1259 /* 0x0a */ "Linked Command Complete", "Linked Command Complete w/flag",
1260 /* 0x0c */ "Target Reset", "Abort Task", "Clear Task Set",
1261 /* 0x0f */ "Initiate Recovery", "Release Recovery",
1262 /* 0x11 */ "Terminate Process", "Continue Task", "Target Transfer Disable",
1263 /* 0x14 */ NULL, NULL, "Clear ACA", "LUN Reset"
1266 static const char * const two_byte_msgs[] = {
1267 /* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag",
1268 /* 0x23 */ "Ignore Wide Residue", "ACA"
1271 static const char * const extended_msgs[] = {
1272 /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request",
1273 /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request",
1274 /* 0x04 */ "Parallel Protocol Request", "Modify Bidirectional Data Pointer"
1277 static void print_nego(const unsigned char *msg, int per, int off, int width)
1281 period_to_str(buf, msg[per]);
1282 printk("period = %s ns ", buf);
1286 printk("offset = %d ", msg[off]);
1288 printk("width = %d ", 8 << msg[width]);
1291 static void print_ptr(const unsigned char *msg, int msb, const char *desc)
1293 int ptr = (msg[msb] << 24) | (msg[msb+1] << 16) | (msg[msb+2] << 8) |
1295 printk("%s = %d ", desc, ptr);
1298 int spi_print_msg(const unsigned char *msg)
1301 if (msg[0] == EXTENDED_MESSAGE) {
1305 if (msg[2] < ARRAY_SIZE(extended_msgs))
1306 printk ("%s ", extended_msgs[msg[2]]);
1308 printk ("Extended Message, reserved code (0x%02x) ",
1311 case EXTENDED_MODIFY_DATA_POINTER:
1312 print_ptr(msg, 3, "pointer");
1315 print_nego(msg, 3, 4, 0);
1318 print_nego(msg, 0, 0, 3);
1321 print_nego(msg, 3, 5, 6);
1323 case EXTENDED_MODIFY_BIDI_DATA_PTR:
1324 print_ptr(msg, 3, "out");
1325 print_ptr(msg, 7, "in");
1328 for (i = 2; i < len; ++i)
1329 printk("%02x ", msg[i]);
1332 } else if (msg[0] & 0x80) {
1333 printk("Identify disconnect %sallowed %s %d ",
1334 (msg[0] & 0x40) ? "" : "not ",
1335 (msg[0] & 0x20) ? "target routine" : "lun",
1337 /* Normal One byte */
1338 } else if (msg[0] < 0x1f) {
1339 if (msg[0] < ARRAY_SIZE(one_byte_msgs) && one_byte_msgs[msg[0]])
1340 printk("%s ", one_byte_msgs[msg[0]]);
1342 printk("reserved (%02x) ", msg[0]);
1343 } else if (msg[0] == 0x55) {
1344 printk("QAS Request ");
1346 } else if (msg[0] <= 0x2f) {
1347 if ((msg[0] - 0x20) < ARRAY_SIZE(two_byte_msgs))
1348 printk("%s %02x ", two_byte_msgs[msg[0] - 0x20],
1351 printk("reserved two byte (%02x %02x) ",
1355 printk("reserved ");
1358 EXPORT_SYMBOL(spi_print_msg);
1360 #else /* ifndef CONFIG_SCSI_CONSTANTS */
1362 int spi_print_msg(const unsigned char *msg)
1366 if (msg[0] == EXTENDED_MESSAGE) {
1370 for (i = 0; i < len; ++i)
1371 printk("%02x ", msg[i]);
1373 } else if (msg[0] & 0x80) {
1374 printk("%02x ", msg[0]);
1375 /* Normal One byte */
1376 } else if ((msg[0] < 0x1f) || (msg[0] == 0x55)) {
1377 printk("%02x ", msg[0]);
1379 } else if (msg[0] <= 0x2f) {
1380 printk("%02x %02x", msg[0], msg[1]);
1383 printk("%02x ", msg[0]);
1386 EXPORT_SYMBOL(spi_print_msg);
1387 #endif /* ! CONFIG_SCSI_CONSTANTS */
1389 static int spi_device_match(struct attribute_container *cont,
1392 struct scsi_device *sdev;
1393 struct Scsi_Host *shost;
1394 struct spi_internal *i;
1396 if (!scsi_is_sdev_device(dev))
1399 sdev = to_scsi_device(dev);
1401 if (!shost->transportt || shost->transportt->host_attrs.ac.class
1402 != &spi_host_class.class)
1404 /* Note: this class has no device attributes, so it has
1405 * no per-HBA allocation and thus we don't need to distinguish
1406 * the attribute containers for the device */
1407 i = to_spi_internal(shost->transportt);
1408 if (i->f->deny_binding && i->f->deny_binding(sdev->sdev_target))
1413 static int spi_target_match(struct attribute_container *cont,
1416 struct Scsi_Host *shost;
1417 struct scsi_target *starget;
1418 struct spi_internal *i;
1420 if (!scsi_is_target_device(dev))
1423 shost = dev_to_shost(dev->parent);
1424 if (!shost->transportt || shost->transportt->host_attrs.ac.class
1425 != &spi_host_class.class)
1428 i = to_spi_internal(shost->transportt);
1429 starget = to_scsi_target(dev);
1431 if (i->f->deny_binding && i->f->deny_binding(starget))
1434 return &i->t.target_attrs.ac == cont;
1437 static DECLARE_TRANSPORT_CLASS(spi_transport_class,
1439 spi_setup_transport_attrs,
1441 spi_target_configure);
1443 static DECLARE_ANON_TRANSPORT_CLASS(spi_device_class,
1445 spi_device_configure);
1447 static struct attribute *host_attributes[] = {
1448 &dev_attr_signalling.attr,
1449 &dev_attr_host_width.attr,
1450 &dev_attr_hba_id.attr,
1454 static struct attribute_group host_attribute_group = {
1455 .attrs = host_attributes,
1458 static int spi_host_configure(struct transport_container *tc,
1460 struct device *cdev)
1462 struct kobject *kobj = &cdev->kobj;
1463 struct Scsi_Host *shost = transport_class_to_shost(cdev);
1464 struct spi_internal *si = to_spi_internal(shost->transportt);
1465 struct attribute *attr = &dev_attr_signalling.attr;
1468 if (si->f->set_signalling)
1469 rc = sysfs_chmod_file(kobj, attr, attr->mode | S_IWUSR);
1474 /* returns true if we should be showing the variable. Also
1475 * overloads the return by setting 1<<1 if the attribute should
1477 #define TARGET_ATTRIBUTE_HELPER(name) \
1478 (si->f->show_##name ? S_IRUGO : 0) | \
1479 (si->f->set_##name ? S_IWUSR : 0)
1481 static umode_t target_attribute_is_visible(struct kobject *kobj,
1482 struct attribute *attr, int i)
1484 struct device *cdev = container_of(kobj, struct device, kobj);
1485 struct scsi_target *starget = transport_class_to_starget(cdev);
1486 struct Scsi_Host *shost = transport_class_to_shost(cdev);
1487 struct spi_internal *si = to_spi_internal(shost->transportt);
1489 if (attr == &dev_attr_period.attr &&
1490 spi_support_sync(starget))
1491 return TARGET_ATTRIBUTE_HELPER(period);
1492 else if (attr == &dev_attr_min_period.attr &&
1493 spi_support_sync(starget))
1494 return TARGET_ATTRIBUTE_HELPER(period);
1495 else if (attr == &dev_attr_offset.attr &&
1496 spi_support_sync(starget))
1497 return TARGET_ATTRIBUTE_HELPER(offset);
1498 else if (attr == &dev_attr_max_offset.attr &&
1499 spi_support_sync(starget))
1500 return TARGET_ATTRIBUTE_HELPER(offset);
1501 else if (attr == &dev_attr_width.attr &&
1502 spi_support_wide(starget))
1503 return TARGET_ATTRIBUTE_HELPER(width);
1504 else if (attr == &dev_attr_max_width.attr &&
1505 spi_support_wide(starget))
1506 return TARGET_ATTRIBUTE_HELPER(width);
1507 else if (attr == &dev_attr_iu.attr &&
1508 spi_support_ius(starget))
1509 return TARGET_ATTRIBUTE_HELPER(iu);
1510 else if (attr == &dev_attr_max_iu.attr &&
1511 spi_support_ius(starget))
1512 return TARGET_ATTRIBUTE_HELPER(iu);
1513 else if (attr == &dev_attr_dt.attr &&
1514 spi_support_dt(starget))
1515 return TARGET_ATTRIBUTE_HELPER(dt);
1516 else if (attr == &dev_attr_qas.attr &&
1517 spi_support_qas(starget))
1518 return TARGET_ATTRIBUTE_HELPER(qas);
1519 else if (attr == &dev_attr_max_qas.attr &&
1520 spi_support_qas(starget))
1521 return TARGET_ATTRIBUTE_HELPER(qas);
1522 else if (attr == &dev_attr_wr_flow.attr &&
1523 spi_support_ius(starget))
1524 return TARGET_ATTRIBUTE_HELPER(wr_flow);
1525 else if (attr == &dev_attr_rd_strm.attr &&
1526 spi_support_ius(starget))
1527 return TARGET_ATTRIBUTE_HELPER(rd_strm);
1528 else if (attr == &dev_attr_rti.attr &&
1529 spi_support_ius(starget))
1530 return TARGET_ATTRIBUTE_HELPER(rti);
1531 else if (attr == &dev_attr_pcomp_en.attr &&
1532 spi_support_ius(starget))
1533 return TARGET_ATTRIBUTE_HELPER(pcomp_en);
1534 else if (attr == &dev_attr_hold_mcs.attr &&
1535 spi_support_ius(starget))
1536 return TARGET_ATTRIBUTE_HELPER(hold_mcs);
1537 else if (attr == &dev_attr_revalidate.attr)
1543 static struct attribute *target_attributes[] = {
1544 &dev_attr_period.attr,
1545 &dev_attr_min_period.attr,
1546 &dev_attr_offset.attr,
1547 &dev_attr_max_offset.attr,
1548 &dev_attr_width.attr,
1549 &dev_attr_max_width.attr,
1551 &dev_attr_max_iu.attr,
1554 &dev_attr_max_qas.attr,
1555 &dev_attr_wr_flow.attr,
1556 &dev_attr_rd_strm.attr,
1558 &dev_attr_pcomp_en.attr,
1559 &dev_attr_hold_mcs.attr,
1560 &dev_attr_revalidate.attr,
1564 static struct attribute_group target_attribute_group = {
1565 .attrs = target_attributes,
1566 .is_visible = target_attribute_is_visible,
1569 static int spi_target_configure(struct transport_container *tc,
1571 struct device *cdev)
1573 struct kobject *kobj = &cdev->kobj;
1575 /* force an update based on parameters read from the device */
1576 sysfs_update_group(kobj, &target_attribute_group);
1581 struct scsi_transport_template *
1582 spi_attach_transport(struct spi_function_template *ft)
1584 struct spi_internal *i = kzalloc(sizeof(struct spi_internal),
1590 i->t.target_attrs.ac.class = &spi_transport_class.class;
1591 i->t.target_attrs.ac.grp = &target_attribute_group;
1592 i->t.target_attrs.ac.match = spi_target_match;
1593 transport_container_register(&i->t.target_attrs);
1594 i->t.target_size = sizeof(struct spi_transport_attrs);
1595 i->t.host_attrs.ac.class = &spi_host_class.class;
1596 i->t.host_attrs.ac.grp = &host_attribute_group;
1597 i->t.host_attrs.ac.match = spi_host_match;
1598 transport_container_register(&i->t.host_attrs);
1599 i->t.host_size = sizeof(struct spi_host_attrs);
1604 EXPORT_SYMBOL(spi_attach_transport);
1606 void spi_release_transport(struct scsi_transport_template *t)
1608 struct spi_internal *i = to_spi_internal(t);
1610 transport_container_unregister(&i->t.target_attrs);
1611 transport_container_unregister(&i->t.host_attrs);
1615 EXPORT_SYMBOL(spi_release_transport);
1617 static __init int spi_transport_init(void)
1619 int error = scsi_dev_info_add_list(SCSI_DEVINFO_SPI,
1620 "SCSI Parallel Transport Class");
1624 for (i = 0; spi_static_device_list[i].vendor; i++)
1625 scsi_dev_info_list_add_keyed(1, /* compatible */
1626 spi_static_device_list[i].vendor,
1627 spi_static_device_list[i].model,
1629 spi_static_device_list[i].flags,
1633 error = transport_class_register(&spi_transport_class);
1636 error = anon_transport_class_register(&spi_device_class);
1637 return transport_class_register(&spi_host_class);
1640 static void __exit spi_transport_exit(void)
1642 transport_class_unregister(&spi_transport_class);
1643 anon_transport_class_unregister(&spi_device_class);
1644 transport_class_unregister(&spi_host_class);
1645 scsi_dev_info_remove_list(SCSI_DEVINFO_SPI);
1648 MODULE_AUTHOR("Martin Hicks");
1649 MODULE_DESCRIPTION("SPI Transport Attributes");
1650 MODULE_LICENSE("GPL");
1652 module_init(spi_transport_init);
1653 module_exit(spi_transport_exit);