GIT f70cfa9bef432d7aeb4e35c093ac27fd6f071d7e git+ssh://master.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git commit Author: Mike Christie Date: Sat Sep 30 20:42:31 2006 -0400 [SCSI] scsi_devinfo: scsi2 HP and Hitachi entries When SCSI-2 they can support luns past 7 and sparse luns. Signed-off-by: Mike Christie Signed-off-by: James Bottomley commit 12427d99489966185dc12a0b6f725d682a3277ca Author: Mike Christie Date: Sat Sep 30 20:42:30 2006 -0400 [SCSI] scsi_devinfo: add nec iStorage support the report luns opcode . Signed-off-by: Mike Christie Signed-off-by: James Bottomley commit 5f619c5ba509994c9203bfd18f5246b4457e2c22 Author: Mike Christie Date: Sat Sep 30 20:42:29 2006 -0400 [SCSI] scsi_devinfo: add Tornado This is from RHEL4. I do not have any info from our bugzilla. All I could find was something like this thread http://lkml.org/lkml/2005/1/7/346 Report lun for linux does not work. It may be our lun format code or it may be the device. It is probably not worth it to add anything special for this device, so the patch just adds BLIST_NOREPORTLUN. Signed-off-by: Mike Christie Signed-off-by: James Bottomley commit 3441afc672bc9bfc137ae7717ac1db4b9c28cc8b Author: Mike Christie Date: Sat Sep 30 20:42:28 2006 -0400 [SCSI] scsi_devinfo: add EMC Invista This is from RHEL4. This box can support scsi2 and can also support BLIST_SPARSELUN | BLIST_LARGELUN. Signed-off-by: Mike Christie Signed-off-by: James Bottomley commit 6470f2ba641cf93d357854cdc63a65350352bb97 Author: Arne Redlich Date: Sat Sep 30 15:49:40 2006 +0200 [SCSI] trivial scsi_execute_async fix In scsi_execute_async()'s error path, a struct scsi_io_context allocated with kmem_cache_alloc() is kfree()'d. Obviously kmem_cache_free() should be used instead. Signed-off-by: Arne Redlich Signed-off-by: James Bottomley commit fb4f66be59f3dcc66fda2e681f1fc77b5cc4508d Author: Ed Lin Date: Wed Sep 27 19:23:41 2006 +0800 [SCSI] stex: add new device (id 0x8650) support A new device (id 0x8650, nickname 'yosemite') support is added. It's basically the same, except for following items: - mapping of id and lun by firmware - special handling for some commands in interrupt routine - change of internal copy function for these special commands - different reset handling code - different shutdown notification command Signed-off-by: Ed Lin Signed-off-by: James Bottomley commit f903d7b7a80b7c3103335d506533790a322da87b Author: Ed Lin Date: Wed Sep 27 19:23:33 2006 +0800 [SCSI] stex: cancel unused field in struct req_msg The payload_sz field in struct req_msg is not big enough to indicate the size of req_msg, as its type is u8. It is confirmed that this field is not used by firmware, so cancel it here. Signed-off-by: Ed Lin Signed-off-by: James Bottomley commit 80c6e3c0b5eb855b69270658318f5ccf04d7b1ff Author: Eric Sesterhenn Date: Tue Sep 26 13:22:13 2006 +0200 [SCSI] fix scsi_device_types overrun in scsi.c this overrun was spotted by coverity (cid #1403). If type == ARRAY_SIZE(scsi_device_types), we are off by one. Signed-off-by: Eric Sesterhenn Signed-off-by: James Bottomley commit 7b75b990e3cb33fd529640d589e77950e72a607c Author: Denis Vlasenko Date: Mon Sep 25 16:57:42 2006 -0700 [SCSI] aic7xxx: fix byte I/O order in ahd_inw Comment says "Read high byte first as some registers increment..." but code doesn't guarantee that, I think: return ((ahd_inb(ahd, port+1) << 8) | ahd_inb(ahd, port)); Compiler can reorder it. Make the order explicit. Signed-off-by: Denis Vlasenko Signed-off-by: Andrew Morton Fixed rejections and added aic7xxx code Signed-off-by: James Bottomley commit 02a0fa676cd453ce4254c2eee838307ffc5c37f4 Author: Alan Cox Date: Mon Sep 25 23:45:51 2006 +0100 [SCSI] Switch ips to pci_register from pci_module Signed-off-by: Alan Cox Signed-off-by: James Bottomley commit 8350a348e97c2f8aa3e91c025c0e040c90146414 Author: Andrew Morton Date: Mon Sep 25 16:59:15 2006 -0700 [SCSI] scsi: device_reprobe() can fail device_reprobe() should return an error code. When it does so, scsi_device_reprobe() should propagate it back. Signed-off-by: Andrew Morton Signed-off-by: James Bottomley commit a2a65a3ecb54ecd1a8f0409f11cb82ae083c6964 Author: Eric Sesterhenn Date: Mon Sep 25 16:59:07 2006 -0700 [SCSI] Signedness issue in drivers/scsi/ipr.c gcc 4.1 with some extra warnings show the following: drivers/scsi/ipr.c:6361: warning: comparison of unsigned expression < 0 is always false drivers/scsi/ipr.c:6385: warning: comparison of unsigned expression < 0 is always false drivers/scsi/ipr.c:6415: warning: comparison of unsigned expression < 0 is always false The problem is that rc is of the type u32, which can never be smaller than zero, therefore all three error handling checks get useless. This patch changes it to a normal int, because all usages / all functions it get used with expect an int. Signed-off-by: Eric Sesterhenn Acked-by: Brian King Signed-off-by: Andrew Morton Signed-off-by: James Bottomley commit dcbccbde00b85b4d4a1c206b419e7a3d2ab2b1cd Author: Henrik Kretzschmar Date: Mon Sep 25 16:58:58 2006 -0700 [SCSI] pci_module_init conversion in scsi subsystem Converts pci_module_init() to pci_register_driver() in the scsi subsys on 23 drivers which only return the value of pci_module_init(). Signed-off-by: Henrik Kretzschmar Signed-off-by: Andrew Morton Signed-off-by: James Bottomley commit 45223fd77c2b39d05dd7f1aaabf614abb1770bbe Author: Eric Sesterhenn Date: Mon Sep 25 16:59:08 2006 -0700 [SCSI] Signdness issue in drivers/scsi/osst.c another signdness warning from gcc 4.1 drivers/scsi/osst.c:5154: warning: comparison of unsigned expression < 0 is always false The problem is that blk is defined as unsigned, but all usages of it are normal int cases. osst_get_frame_position() and osst_get_sector() return ints and can return negative values. If blk stays an unsigned int, the error check is useless. Signed-off-by: Eric Sesterhenn Signed-off-by: Andrew Morton Signed-off-by: James Bottomley commit 53aefd3fc31f08487f6941282ef6611413e02e43 Author: Henrik Kretzschmar Date: Mon Sep 25 16:59:12 2006 -0700 [SCSI] scsi: included header cleanup Free seagate.h from obsolete drivers/scsi.h, remove a double inclusion od linux/delay.h and remove the unneeded scsi/scsi_ioctl.h Signed-off-by: Henrik Kretzschmar Signed-off-by: Andrew Morton Signed-off-by: James Bottomley commit 20a2460b4dd07fe7dc74b281fcbe18bac03830aa Author: Michal Piotrowski Date: Mon Sep 25 16:59:06 2006 -0700 [SCSI] drivers/message/fusion/linux_compat.h Removal of old code Signed-off-by: Michal Piotrowski Acked-by: "Moore, Eric Dean" Signed-off-by: Andrew Morton Signed-off-by: James Bottomley commit c03d10ab6aafe6706520e1595d6e91d0e50ac5ad Author: Michal Piotrowski Date: Mon Sep 25 16:59:03 2006 -0700 [SCSI] drivers/scsi/gdth.h: removal of old scsi code Signed-off-by: Michal Piotrowski Signed-off-by: Andrew Morton Signed-off-by: James Bottomley commit 288777f89a63ca0bece7b5e082ce9beebacfb8fd Author: Michal Piotrowski Date: Mon Sep 25 16:59:02 2006 -0700 [SCSI] drivers/scsi/dpt/dpti_i2o.h: removal of old scsi code Signed-off-by: Michal Piotrowski Signed-off-by: Andrew Morton Signed-off-by: James Bottomley commit f5ebbeb57e4b57ac44f29ff9ec2ebde1401999d1 Author: Eric W. Biederman Date: Mon Sep 25 16:59:01 2006 -0700 [SCSI] megaraid: Use the proper type to hold the irq number. When testing on a Unisys machine it was discovered that the megaraid driver would not initialize as it was requesting irq 162 instead of irq 1442 it was assigned. The problem was the irq number had been truncated by being stored in an unsigned char. This patches fixes that problem and the driver now appears to work. The ioctl interface appears fundamentally broken as it exports the irq number to user space in an unsigned char. Signed-off-by: Eric W. Biederman Signed-off-by: Andrew Morton Signed-off-by: James Bottomley commit d41ba22a6d330ab1e8d3adde7d2ce9349d4e4dc7 Author: Alexey Dobriyan Date: Mon Sep 25 16:59:11 2006 -0700 [SCSI] 3w-xxxx: fix "ATA UDMA upgrade" message number sparse "defined twice" warning Signed-off-by: Alexey Dobriyan Signed-off-by: Andrew Morton Signed-off-by: James Bottomley commit 16c8729a46b599bca647839556a33d0b59522e94 Author: Michal Piotrowski Date: Mon Sep 25 16:59:04 2006 -0700 [SCSI] drivers/scsi/nsp32.h: removal of old scsi code Signed-off-by: Michal Piotrowski Signed-off-by: Andrew Morton Signed-off-by: James Bottomley commit 76be12de87c4601cf35a88f83d199b940d995c62 Author: Randy Dunlap Date: Mon Sep 25 16:58:56 2006 -0700 [SCSI] dc395x: fix printk format warning drivers/scsi/dc395x.c:1224: warning: format '%i' expects type 'int', but argument 5 has type 'size_t' Signed-off-by: Randy Dunlap Signed-off-by: Andrew Morton Signed-off-by: James Bottomley commit 35a39691e4daa3c371c265e4cb8356c67ded45ec Author: Brian King Date: Mon Sep 25 12:39:20 2006 -0500 [SCSI] ipr: Support attaching SATA devices Adds support to attach SATA devices to ipr SAS adapters. Signed-off-by: Brian King Signed-off-by: James Bottomley commit d7694f8c0bb61829b1bd4d5543a51c66f04a6c3e Author: Henrik Kretzschmar Date: Fri Sep 15 18:50:34 2006 +0200 [SCSI] seagate: remove header and convert to struct scsi_cmnd Signed-off-by: Henrik Kretzschmar Signed-off-by: James Bottomley commit 15d1f53fc7654d62af7e9b23049ae3b71f5b161c Author: Jes Sorensen Date: Mon Sep 25 05:44:57 2006 -0400 [SCSI] qla1280 command timeout Original patch from Ian Dall in bugzilla. Set command timeout as specified by the SCSI layer rather than hardcode it to 30 seconds. I have received a couple of reports of people hitting this one with various tape configurations and the patch looks obviously correct. - Jes From http://bugzilla.kernel.org/show_bug.cgi?id=6275 ian@beware.dropbear.id.au (Ian Dall): The command sent to the card was using a 30second timeout regardless of the timeout requested in the scsi command passed down from higher levels. Signed-off-by: Jes Sorensen Signed-off-by: James Bottomley commit bc54ec6b0782979a440603beeed349b2eac39a59 Author: Muli Ben-Yehuda Date: Mon Sep 25 17:10:19 2006 +0300 [SCSI] aic94xx: require firmware loader aic94xx relies on external firmware and thus requires FW_LOADER. Signed-off-by: Muli Ben-Yehuda Signed-off-by: James Bottomley commit 6460e75a104d10458817d2f5b2fbff775bf0b43a Author: Douglas Gilbert Date: Wed Sep 20 18:20:49 2006 -0400 [SCSI] sg: fixes for large page_size This sg driver patch addresses the problem with larger page sizes reported by Brian King in this post: http://marc.theaimsgroup.com/?l=linux-scsi&m=115867718623631&w=2 Some other related matters are also addressed. Some of these prevent oopses when the SG_SCATTER_SZ or scatter_elem_sz are set to inappropriate values. The scatter_elem_sz has been tested up to 4 MB which should make the largest data transfer with one SCSI command, 32 MB less one block, achievable with a relatively small number of elements in the scatter gather list. ChangeLog: - add scatter_elem_sz boot time parameter and sysfs module parameter that is initialized to SG_SCATTER_SZ - the driver will then adjust scatter_elem_sz to be the max(given(scatter_elem_sz), PAGE_SIZE) It will also round it up, if necessary, to be a power of two - clean up sg.h header, correct bad urls and some statements that are no longer valid - make the def_reserved_size sysfs module attribute writable Signed-off-by: Douglas Gilbert Signed-off-by: James Bottomley commit 8aee918a1cff2a3722ce76fc6fa5abe09aa98d1b Author: James Smart Date: Thu Aug 31 12:27:57 2006 -0400 [SCSI] lpfc: don't free mempool if mailbox is busy Signed-off-by: James Bottomley drivers/message/fusion/linux_compat.h | 9 drivers/scsi/3w-9xxx.c | 2 drivers/scsi/3w-xxxx.c | 2 drivers/scsi/3w-xxxx.h | 2 drivers/scsi/Kconfig | 6 drivers/scsi/a100u2w.c | 2 drivers/scsi/aic7xxx/aic79xx_inline.h | 3 drivers/scsi/aic7xxx/aic79xx_osm_pci.c | 2 drivers/scsi/aic7xxx/aic7xxx_inline.h | 3 drivers/scsi/aic7xxx/aic7xxx_osm_pci.c | 3 drivers/scsi/aic94xx/Kconfig | 1 drivers/scsi/dc395x.c | 4 drivers/scsi/dmx3191d.c | 2 drivers/scsi/dpt/dpti_i2o.h | 10 drivers/scsi/gdth.h | 10 drivers/scsi/ipr.c | 687 +++++++++++++++++++++++++++++++- drivers/scsi/ipr.h | 18 + drivers/scsi/ips.c | 2 drivers/scsi/lpfc/lpfc_init.c | 6 drivers/scsi/megaraid/mega_common.h | 2 drivers/scsi/nsp32.c | 2 drivers/scsi/nsp32.h | 42 -- drivers/scsi/osst.c | 3 drivers/scsi/qla1280.c | 6 drivers/scsi/scsi.c | 2 drivers/scsi/scsi_devinfo.c | 16 + drivers/scsi/scsi_lib.c | 2 drivers/scsi/seagate.c | 24 + drivers/scsi/seagate.h | 19 - drivers/scsi/sg.c | 53 ++ drivers/scsi/stex.c | 197 ++++++++- include/scsi/sg.h | 61 +-- 32 files changed, 967 insertions(+), 236 deletions(-) diff --git a/drivers/message/fusion/linux_compat.h b/drivers/message/fusion/linux_compat.h index 048b5b8..bb2bf5a 100644 --- a/drivers/message/fusion/linux_compat.h +++ b/drivers/message/fusion/linux_compat.h @@ -6,13 +6,4 @@ #define FUSION_LINUX_COMPAT_H #include #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,6)) -static int inline scsi_device_online(struct scsi_device *sdev) -{ - return sdev->online; -} -#endif - - -/*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ #endif /* _LINUX_COMPAT_H */ diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 5a9475e..da17315 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c @@ -2211,7 +2211,7 @@ static int __init twa_init(void) { printk(KERN_WARNING "3ware 9000 Storage Controller device driver for Linux v%s.\n", TW_DRIVER_VERSION); - return pci_module_init(&twa_driver); + return pci_register_driver(&twa_driver); } /* End twa_init() */ /* This function is called on driver exit */ diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index f3a5f42..2d4cb67 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c @@ -2486,7 +2486,7 @@ static int __init tw_init(void) { printk(KERN_WARNING "3ware Storage Controller device driver for Linux v%s.\n", TW_DRIVER_VERSION); - return pci_module_init(&tw_driver); + return pci_register_driver(&tw_driver); } /* End tw_init() */ /* This function is called on driver exit */ diff --git a/drivers/scsi/3w-xxxx.h b/drivers/scsi/3w-xxxx.h index 31fe5ea..bbd654a 100644 --- a/drivers/scsi/3w-xxxx.h +++ b/drivers/scsi/3w-xxxx.h @@ -74,7 +74,7 @@ static char *tw_aen_string[] = { [0x00D] = "ERROR: Logical unit deleted: Unit #", [0x00F] = "WARNING: SMART threshold exceeded: Port #", [0x021] = "WARNING: ATA UDMA downgrade: Port #", - [0x021] = "WARNING: ATA UDMA upgrade: Port #", + [0x022] = "WARNING: ATA UDMA upgrade: Port #", [0x023] = "WARNING: Sector repair occurred: Port #", [0x024] = "ERROR: SBUF integrity check failure", [0x025] = "ERROR: Lost cached write: Port #", diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index dab0820..797a13c 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig @@ -1016,7 +1016,7 @@ config SCSI_SYM53C8XX_MMIO config SCSI_IPR tristate "IBM Power Linux RAID adapter support" - depends on PCI && SCSI + depends on PCI && SCSI && ATA select FW_LOADER ---help--- This driver supports the IBM Power Linux family RAID adapters. @@ -1262,8 +1262,8 @@ config SCSI_SEAGATE These are 8-bit SCSI controllers; the ST-01 is also supported by this driver. It is explained in section 3.9 of the SCSI-HOWTO, available from . If it - doesn't work out of the box, you may have to change some settings in - . + doesn't work out of the box, you may have to change some macros at + compiletime, which are described in . To compile this driver as a module, choose M here: the module will be called seagate. diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c index d7e9fab..2684150 100644 --- a/drivers/scsi/a100u2w.c +++ b/drivers/scsi/a100u2w.c @@ -1187,7 +1187,7 @@ static struct pci_driver inia100_pci_dri static int __init inia100_init(void) { - return pci_module_init(&inia100_pci_driver); + return pci_register_driver(&inia100_pci_driver); } static void __exit inia100_exit(void) diff --git a/drivers/scsi/aic7xxx/aic79xx_inline.h b/drivers/scsi/aic7xxx/aic79xx_inline.h index 8ad3ce9..a3266e0 100644 --- a/drivers/scsi/aic7xxx/aic79xx_inline.h +++ b/drivers/scsi/aic7xxx/aic79xx_inline.h @@ -527,7 +527,8 @@ ahd_inw(struct ahd_softc *ahd, u_int por * or have other side effects when the low byte is * read. */ - return ((ahd_inb(ahd, port+1) << 8) | ahd_inb(ahd, port)); + uint16_t r = ahd_inb(ahd, port+1) << 8; + return r | ahd_inb(ahd, port); } static __inline void diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c index 50a41ed..4b53542 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c @@ -198,7 +198,7 @@ ahd_linux_pci_dev_probe(struct pci_dev * int ahd_linux_pci_init(void) { - return (pci_module_init(&aic79xx_pci_driver)); + return pci_register_driver(&aic79xx_pci_driver); } void diff --git a/drivers/scsi/aic7xxx/aic7xxx_inline.h b/drivers/scsi/aic7xxx/aic7xxx_inline.h index 2cc8a17..8e1954c 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_inline.h +++ b/drivers/scsi/aic7xxx/aic7xxx_inline.h @@ -300,7 +300,8 @@ ahc_fetch_transinfo(struct ahc_softc *ah static __inline uint16_t ahc_inw(struct ahc_softc *ahc, u_int port) { - return ((ahc_inb(ahc, port+1) << 8) | ahc_inb(ahc, port)); + uint16_t r = ahc_inb(ahc, port+1) << 8; + return r | ahc_inb(ahc, port); } static __inline void diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c index 7e42f07..d20ca51 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c @@ -246,8 +246,7 @@ ahc_linux_pci_dev_probe(struct pci_dev * int ahc_linux_pci_init(void) { - /* Translate error or zero return into zero or one */ - return pci_module_init(&aic7xxx_pci_driver) ? 0 : 1; + return pci_register_driver(&aic7xxx_pci_driver); } void diff --git a/drivers/scsi/aic94xx/Kconfig b/drivers/scsi/aic94xx/Kconfig index 0ed391d..c83fe75 100644 --- a/drivers/scsi/aic94xx/Kconfig +++ b/drivers/scsi/aic94xx/Kconfig @@ -28,6 +28,7 @@ config SCSI_AIC94XX tristate "Adaptec AIC94xx SAS/SATA support" depends on PCI select SCSI_SAS_LIBSAS + select FW_LOADER help This driver supports Adaptec's SAS/SATA 3Gb/s 64 bit PCI-X AIC94xx chip based host adapters. diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c index ff2b179..c6118d9 100644 --- a/drivers/scsi/dc395x.c +++ b/drivers/scsi/dc395x.c @@ -1219,7 +1219,7 @@ static void dump_register_info(struct Ad srb, srb->cmd, srb->cmd->pid, srb->cmd->cmnd[0], srb->cmd->device->id, srb->cmd->device->lun); - printk(" sglist=%p cnt=%i idx=%i len=%i\n", + printk(" sglist=%p cnt=%i idx=%i len=%Zd\n", srb->segment_x, srb->sg_count, srb->sg_index, srb->total_xfer_length); printk(" state=0x%04x status=0x%02x phase=0x%02x (%sconn.)\n", @@ -4949,7 +4949,7 @@ static struct pci_driver dc395x_driver = **/ static int __init dc395x_module_init(void) { - return pci_module_init(&dc395x_driver); + return pci_register_driver(&dc395x_driver); } diff --git a/drivers/scsi/dmx3191d.c b/drivers/scsi/dmx3191d.c index 879a266..fa738ec 100644 --- a/drivers/scsi/dmx3191d.c +++ b/drivers/scsi/dmx3191d.c @@ -155,7 +155,7 @@ static struct pci_driver dmx3191d_pci_dr static int __init dmx3191d_init(void) { - return pci_module_init(&dmx3191d_pci_driver); + return pci_register_driver(&dmx3191d_pci_driver); } static void __exit dmx3191d_exit(void) diff --git a/drivers/scsi/dpt/dpti_i2o.h b/drivers/scsi/dpt/dpti_i2o.h index d84a281..b3fa7ed 100644 --- a/drivers/scsi/dpt/dpti_i2o.h +++ b/drivers/scsi/dpt/dpti_i2o.h @@ -47,21 +47,11 @@ #define I2O_MAX_MANAGERS 4 * I2O Interface Objects */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) - -#define DECLARE_MUTEX(name) struct semaphore name=MUTEX - -typedef struct wait_queue *adpt_wait_queue_head_t; -#define ADPT_DECLARE_WAIT_QUEUE_HEAD(wait) adpt_wait_queue_head_t wait = NULL -typedef struct wait_queue adpt_wait_queue_t; -#else - #include typedef wait_queue_head_t adpt_wait_queue_head_t; #define ADPT_DECLARE_WAIT_QUEUE_HEAD(wait) DECLARE_WAIT_QUEUE_HEAD(wait) typedef wait_queue_t adpt_wait_queue_t; -#endif /* * message structures */ diff --git a/drivers/scsi/gdth.h b/drivers/scsi/gdth.h index 47eae02..8c29eaf 100644 --- a/drivers/scsi/gdth.h +++ b/drivers/scsi/gdth.h @@ -936,18 +936,12 @@ #endif gdth_binfo_str binfo; /* controller info */ gdth_evt_data dvr; /* event structure */ spinlock_t smp_lock; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) struct pci_dev *pdev; -#endif char oem_name[8]; #ifdef GDTH_DMA_STATISTICS ulong dma32_cnt, dma64_cnt; /* statistics: DMA buffer */ #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) struct scsi_device *sdev; -#else - struct scsi_device sdev; -#endif } gdth_ha_str; /* structure for scsi_register(), SCSI bus != 0 */ @@ -1029,10 +1023,6 @@ typedef struct { /* function prototyping */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) int gdth_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int); -#else -int gdth_proc_info(char *,char **,off_t,int,int,int); -#endif #endif diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 7ed4eef..e1fe949 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -70,6 +70,7 @@ #include #include #include #include +#include #include #include #include @@ -78,6 +79,7 @@ #include #include #include #include +#include #include "ipr.h" /* @@ -199,6 +201,8 @@ struct ipr_error_table_t ipr_error_table "FFFA: Undefined device response recovered by the IOA"}, {0x014A0000, 1, 1, "FFF6: Device bus error, message or command phase"}, + {0x014A8000, 0, 1, + "FFFE: Task Management Function failed"}, {0x015D0000, 0, 1, "FFF6: Failure prediction threshold exceeded"}, {0x015D9200, 0, 1, @@ -261,6 +265,8 @@ struct ipr_error_table_t ipr_error_table "Device bus status error"}, {0x04448600, 0, 1, "8157: IOA error requiring IOA reset to recover"}, + {0x04448700, 0, 0, + "ATA device status error"}, {0x04490000, 0, 0, "Message reject received from the device"}, {0x04449200, 0, 1, @@ -273,6 +279,8 @@ struct ipr_error_table_t ipr_error_table "9082: IOA detected device error"}, {0x044A0000, 1, 1, "3110: Device bus error, message or command phase"}, + {0x044A8000, 1, 1, + "3110: SAS Command / Task Management Function failed"}, {0x04670400, 0, 1, "9091: Incorrect hardware configuration change has been detected"}, {0x04678000, 0, 1, @@ -453,7 +461,8 @@ static void ipr_trc_hook(struct ipr_cmnd trace_entry->time = jiffies; trace_entry->op_code = ipr_cmd->ioarcb.cmd_pkt.cdb[0]; trace_entry->type = type; - trace_entry->cmd_index = ipr_cmd->cmd_index; + trace_entry->ata_op_code = ipr_cmd->ioarcb.add_data.u.regs.command; + trace_entry->cmd_index = ipr_cmd->cmd_index & 0xff; trace_entry->res_handle = ipr_cmd->ioarcb.res_handle; trace_entry->u.add_data = add_data; } @@ -480,8 +489,10 @@ static void ipr_reinit_ipr_cmnd(struct i ioarcb->read_ioadl_len = 0; ioasa->ioasc = 0; ioasa->residual_data_len = 0; + ioasa->u.gata.status = 0; ipr_cmd->scsi_cmd = NULL; + ipr_cmd->qc = NULL; ipr_cmd->sense_buffer[0] = 0; ipr_cmd->dma_use_sg = 0; } @@ -626,6 +637,28 @@ static int ipr_set_pcix_cmd_reg(struct i } /** + * ipr_sata_eh_done - done function for aborted SATA commands + * @ipr_cmd: ipr command struct + * + * This function is invoked for ops generated to SATA + * devices which are being aborted. + * + * Return value: + * none + **/ +static void ipr_sata_eh_done(struct ipr_cmnd *ipr_cmd) +{ + struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; + struct ata_queued_cmd *qc = ipr_cmd->qc; + struct ipr_sata_port *sata_port = qc->ap->private_data; + + qc->err_mask |= AC_ERR_OTHER; + sata_port->ioasa.status |= ATA_BUSY; + list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q); + ata_qc_complete(qc); +} + +/** * ipr_scsi_eh_done - mid-layer done function for aborted ops * @ipr_cmd: ipr command struct * @@ -669,6 +702,8 @@ static void ipr_fail_all_ops(struct ipr_ if (ipr_cmd->scsi_cmd) ipr_cmd->done = ipr_scsi_eh_done; + else if (ipr_cmd->qc) + ipr_cmd->done = ipr_sata_eh_done; ipr_trc_hook(ipr_cmd, IPR_TRACE_FINISH, IPR_IOASC_IOA_WAS_RESET); del_timer(&ipr_cmd->timer); @@ -825,6 +860,7 @@ static void ipr_init_res_entry(struct ip res->del_from_ml = 0; res->resetting_device = 0; res->sdev = NULL; + res->sata_port = NULL; } /** @@ -1316,7 +1352,7 @@ static u32 ipr_get_error(u32 ioasc) int i; for (i = 0; i < ARRAY_SIZE(ipr_error_table); i++) - if (ipr_error_table[i].ioasc == ioasc) + if (ipr_error_table[i].ioasc == (ioasc & IPR_IOASC_IOASC_MASK)) return i; return 0; @@ -3051,6 +3087,17 @@ #endif **/ static int ipr_change_queue_depth(struct scsi_device *sdev, int qdepth) { + struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)sdev->host->hostdata; + struct ipr_resource_entry *res; + unsigned long lock_flags = 0; + + spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); + res = (struct ipr_resource_entry *)sdev->hostdata; + + if (res && ipr_is_gata(res) && qdepth > IPR_MAX_CMD_PER_ATA_LUN) + qdepth = IPR_MAX_CMD_PER_ATA_LUN; + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); + scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); return sdev->queue_depth; } @@ -3166,6 +3213,122 @@ static int ipr_biosparam(struct scsi_dev } /** + * ipr_find_starget - Find target based on bus/target. + * @starget: scsi target struct + * + * Return value: + * resource entry pointer if found / NULL if not found + **/ +static struct ipr_resource_entry *ipr_find_starget(struct scsi_target *starget) +{ + struct Scsi_Host *shost = dev_to_shost(&starget->dev); + struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *) shost->hostdata; + struct ipr_resource_entry *res; + + list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { + if ((res->cfgte.res_addr.bus == starget->channel) && + (res->cfgte.res_addr.target == starget->id) && + (res->cfgte.res_addr.lun == 0)) { + return res; + } + } + + return NULL; +} + +static struct ata_port_info sata_port_info; + +/** + * ipr_target_alloc - Prepare for commands to a SCSI target + * @starget: scsi target struct + * + * If the device is a SATA device, this function allocates an + * ATA port with libata, else it does nothing. + * + * Return value: + * 0 on success / non-0 on failure + **/ +static int ipr_target_alloc(struct scsi_target *starget) +{ + struct Scsi_Host *shost = dev_to_shost(&starget->dev); + struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *) shost->hostdata; + struct ipr_sata_port *sata_port; + struct ata_port *ap; + struct ipr_resource_entry *res; + unsigned long lock_flags; + + spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); + res = ipr_find_starget(starget); + starget->hostdata = NULL; + + if (res && ipr_is_gata(res)) { + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); + sata_port = kzalloc(sizeof(*sata_port), GFP_KERNEL); + if (!sata_port) + return -ENOMEM; + + ap = ata_sas_port_alloc(&ioa_cfg->ata_host, &sata_port_info, shost); + if (ap) { + spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); + sata_port->ioa_cfg = ioa_cfg; + sata_port->ap = ap; + sata_port->res = res; + + res->sata_port = sata_port; + ap->private_data = sata_port; + starget->hostdata = sata_port; + } else { + kfree(sata_port); + return -ENOMEM; + } + } + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); + + return 0; +} + +/** + * ipr_target_destroy - Destroy a SCSI target + * @starget: scsi target struct + * + * If the device was a SATA device, this function frees the libata + * ATA port, else it does nothing. + * + **/ +static void ipr_target_destroy(struct scsi_target *starget) +{ + struct ipr_sata_port *sata_port = starget->hostdata; + + if (sata_port) { + starget->hostdata = NULL; + ata_sas_port_destroy(sata_port->ap); + kfree(sata_port); + } +} + +/** + * ipr_find_sdev - Find device based on bus/target/lun. + * @sdev: scsi device struct + * + * Return value: + * resource entry pointer if found / NULL if not found + **/ +static struct ipr_resource_entry *ipr_find_sdev(struct scsi_device *sdev) +{ + struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *) sdev->host->hostdata; + struct ipr_resource_entry *res; + + list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { + if ((res->cfgte.res_addr.bus == sdev->channel) && + (res->cfgte.res_addr.target == sdev->id) && + (res->cfgte.res_addr.lun == sdev->lun)) + return res; + } + + return NULL; +} + +/** * ipr_slave_destroy - Unconfigure a SCSI device * @sdev: scsi device struct * @@ -3183,8 +3346,11 @@ static void ipr_slave_destroy(struct scs spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); res = (struct ipr_resource_entry *) sdev->hostdata; if (res) { + if (res->sata_port) + ata_port_disable(res->sata_port->ap); sdev->hostdata = NULL; res->sdev = NULL; + res->sata_port = NULL; } spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); } @@ -3219,13 +3385,45 @@ static int ipr_slave_configure(struct sc } if (ipr_is_vset_device(res) || ipr_is_scsi_disk(res)) sdev->allow_restart = 1; - scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); + if (ipr_is_gata(res) && res->sata_port) { + scsi_adjust_queue_depth(sdev, 0, IPR_MAX_CMD_PER_ATA_LUN); + ata_sas_slave_configure(sdev, res->sata_port->ap); + } else { + scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); + } } spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); return 0; } /** + * ipr_ata_slave_alloc - Prepare for commands to a SATA device + * @sdev: scsi device struct + * + * This function initializes an ATA port so that future commands + * sent through queuecommand will work. + * + * Return value: + * 0 on success + **/ +static int ipr_ata_slave_alloc(struct scsi_device *sdev) +{ + struct ipr_sata_port *sata_port = NULL; + int rc = -ENXIO; + + ENTER; + if (sdev->sdev_target) + sata_port = sdev->sdev_target->hostdata; + if (sata_port) + rc = ata_sas_port_init(sata_port->ap); + if (rc) + ipr_slave_destroy(sdev); + + LEAVE; + return rc; +} + +/** * ipr_slave_alloc - Prepare for commands to a device. * @sdev: scsi device struct * @@ -3248,18 +3446,18 @@ static int ipr_slave_alloc(struct scsi_d spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); - list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { - if ((res->cfgte.res_addr.bus == sdev->channel) && - (res->cfgte.res_addr.target == sdev->id) && - (res->cfgte.res_addr.lun == sdev->lun)) { - res->sdev = sdev; - res->add_to_ml = 0; - res->in_erp = 0; - sdev->hostdata = res; - if (!ipr_is_naca_model(res)) - res->needs_sync_complete = 1; - rc = 0; - break; + res = ipr_find_sdev(sdev); + if (res) { + res->sdev = sdev; + res->add_to_ml = 0; + res->in_erp = 0; + sdev->hostdata = res; + if (!ipr_is_naca_model(res)) + res->needs_sync_complete = 1; + rc = 0; + if (ipr_is_gata(res)) { + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); + return ipr_ata_slave_alloc(sdev); } } @@ -3314,7 +3512,8 @@ static int ipr_eh_host_reset(struct scsi * This function issues a device reset to the affected device. * If the device is a SCSI device, a LUN reset will be sent * to the device first. If that does not work, a target reset - * will be sent. + * will be sent. If the device is a SATA device, a PHY reset will + * be sent. * * Return value: * 0 on success / non-zero on failure @@ -3325,26 +3524,79 @@ static int ipr_device_reset(struct ipr_i struct ipr_cmnd *ipr_cmd; struct ipr_ioarcb *ioarcb; struct ipr_cmd_pkt *cmd_pkt; + struct ipr_ioarcb_ata_regs *regs; u32 ioasc; ENTER; ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg); ioarcb = &ipr_cmd->ioarcb; cmd_pkt = &ioarcb->cmd_pkt; + regs = &ioarcb->add_data.u.regs; ioarcb->res_handle = res->cfgte.res_handle; cmd_pkt->request_type = IPR_RQTYPE_IOACMD; cmd_pkt->cdb[0] = IPR_RESET_DEVICE; + if (ipr_is_gata(res)) { + cmd_pkt->cdb[2] = IPR_ATA_PHY_RESET; + ioarcb->add_cmd_parms_len = cpu_to_be32(sizeof(regs->flags)); + regs->flags |= IPR_ATA_FLAG_STATUS_ON_GOOD_COMPLETION; + } ipr_send_blocking_cmd(ipr_cmd, ipr_timeout, IPR_DEVICE_RESET_TIMEOUT); ioasc = be32_to_cpu(ipr_cmd->ioasa.ioasc); list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q); + if (ipr_is_gata(res) && res->sata_port && ioasc != IPR_IOASC_IOA_WAS_RESET) + memcpy(&res->sata_port->ioasa, &ipr_cmd->ioasa.u.gata, + sizeof(struct ipr_ioasa_gata)); LEAVE; return (IPR_IOASC_SENSE_KEY(ioasc) ? -EIO : 0); } /** + * ipr_sata_reset - Reset the SATA port + * @ap: SATA port to reset + * @classes: class of the attached device + * + * This function issues a SATA phy reset to the affected ATA port. + * + * Return value: + * 0 on success / non-zero on failure + **/ +static int ipr_sata_reset(struct ata_port *ap, unsigned int *classes) +{ + struct ipr_sata_port *sata_port = ap->private_data; + struct ipr_ioa_cfg *ioa_cfg = sata_port->ioa_cfg; + struct ipr_resource_entry *res; + unsigned long lock_flags = 0; + int rc = -ENXIO; + + ENTER; + spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); + res = sata_port->res; + if (res) { + rc = ipr_device_reset(ioa_cfg, res); + switch(res->cfgte.proto) { + case IPR_PROTO_SATA: + case IPR_PROTO_SAS_STP: + *classes = ATA_DEV_ATA; + break; + case IPR_PROTO_SATA_ATAPI: + case IPR_PROTO_SAS_STP_ATAPI: + *classes = ATA_DEV_ATAPI; + break; + default: + *classes = ATA_DEV_UNKNOWN; + break; + }; + } + + spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); + LEAVE; + return rc; +} + +/** * ipr_eh_dev_reset - Reset the device * @scsi_cmd: scsi command struct * @@ -3360,7 +3612,8 @@ static int __ipr_eh_dev_reset(struct scs struct ipr_cmnd *ipr_cmd; struct ipr_ioa_cfg *ioa_cfg; struct ipr_resource_entry *res; - int rc; + struct ata_port *ap; + int rc = 0; ENTER; ioa_cfg = (struct ipr_ioa_cfg *) scsi_cmd->device->host->hostdata; @@ -3388,7 +3641,14 @@ static int __ipr_eh_dev_reset(struct scs res->resetting_device = 1; scmd_printk(KERN_ERR, scsi_cmd, "Resetting device\n"); - rc = ipr_device_reset(ioa_cfg, res); + + if (ipr_is_gata(res) && res->sata_port) { + ap = res->sata_port->ap; + spin_unlock_irq(scsi_cmd->device->host->host_lock); + ata_do_eh(ap, NULL, NULL, ipr_sata_reset, NULL); + spin_lock_irq(scsi_cmd->device->host->host_lock); + } else + rc = ipr_device_reset(ioa_cfg, res); res->resetting_device = 0; LEAVE; @@ -4300,6 +4560,9 @@ static int ipr_queuecommand(struct scsi_ return 0; } + if (ipr_is_gata(res) && res->sata_port) + return ata_sas_queuecmd(scsi_cmd, done, res->sata_port->ap); + ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg); ioarcb = &ipr_cmd->ioarcb; list_add_tail(&ipr_cmd->queue, &ioa_cfg->pending_q); @@ -4345,6 +4608,26 @@ static int ipr_queuecommand(struct scsi_ } /** + * ipr_ioctl - IOCTL handler + * @sdev: scsi device struct + * @cmd: IOCTL cmd + * @arg: IOCTL arg + * + * Return value: + * 0 on success / other on failure + **/ +int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) +{ + struct ipr_resource_entry *res; + + res = (struct ipr_resource_entry *)sdev->hostdata; + if (res && ipr_is_gata(res)) + return ata_scsi_ioctl(sdev, cmd, arg); + + return -EINVAL; +} + +/** * ipr_info - Get information about the card/driver * @scsi_host: scsi host struct * @@ -4366,10 +4649,45 @@ static const char * ipr_ioa_info(struct return buffer; } +/** + * ipr_scsi_timed_out - Handle scsi command timeout + * @scsi_cmd: scsi command struct + * + * Return value: + * EH_NOT_HANDLED + **/ +enum scsi_eh_timer_return ipr_scsi_timed_out(struct scsi_cmnd *scsi_cmd) +{ + struct ipr_ioa_cfg *ioa_cfg; + struct ipr_cmnd *ipr_cmd; + unsigned long flags; + + ENTER; + spin_lock_irqsave(scsi_cmd->device->host->host_lock, flags); + ioa_cfg = (struct ipr_ioa_cfg *)scsi_cmd->device->host->hostdata; + + list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) { + if (ipr_cmd->qc && ipr_cmd->qc->scsicmd == scsi_cmd) { + ipr_cmd->qc->err_mask |= AC_ERR_TIMEOUT; + ipr_cmd->qc->flags |= ATA_QCFLAG_FAILED; + break; + } + } + + spin_unlock_irqrestore(scsi_cmd->device->host->host_lock, flags); + LEAVE; + return EH_NOT_HANDLED; +} + +static struct scsi_transport_template ipr_transport_template = { + .eh_timed_out = ipr_scsi_timed_out +}; + static struct scsi_host_template driver_template = { .module = THIS_MODULE, .name = "IPR", .info = ipr_ioa_info, + .ioctl = ipr_ioctl, .queuecommand = ipr_queuecommand, .eh_abort_handler = ipr_eh_abort, .eh_device_reset_handler = ipr_eh_dev_reset, @@ -4377,6 +4695,8 @@ static struct scsi_host_template driver_ .slave_alloc = ipr_slave_alloc, .slave_configure = ipr_slave_configure, .slave_destroy = ipr_slave_destroy, + .target_alloc = ipr_target_alloc, + .target_destroy = ipr_target_destroy, .change_queue_depth = ipr_change_queue_depth, .change_queue_type = ipr_change_queue_type, .bios_param = ipr_biosparam, @@ -4391,6 +4711,330 @@ static struct scsi_host_template driver_ .proc_name = IPR_NAME }; +/** + * ipr_ata_phy_reset - libata phy_reset handler + * @ap: ata port to reset + * + **/ +static void ipr_ata_phy_reset(struct ata_port *ap) +{ + unsigned long flags; + struct ipr_sata_port *sata_port = ap->private_data; + struct ipr_resource_entry *res = sata_port->res; + struct ipr_ioa_cfg *ioa_cfg = sata_port->ioa_cfg; + int rc; + + ENTER; + spin_lock_irqsave(ioa_cfg->host->host_lock, flags); + while(ioa_cfg->in_reset_reload) { + spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags); + wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload); + spin_lock_irqsave(ioa_cfg->host->host_lock, flags); + } + + if (!ioa_cfg->allow_cmds) + goto out_unlock; + + rc = ipr_device_reset(ioa_cfg, res); + + if (rc) { + ap->ops->port_disable(ap); + goto out_unlock; + } + + switch(res->cfgte.proto) { + case IPR_PROTO_SATA: + case IPR_PROTO_SAS_STP: + ap->device[0].class = ATA_DEV_ATA; + break; + case IPR_PROTO_SATA_ATAPI: + case IPR_PROTO_SAS_STP_ATAPI: + ap->device[0].class = ATA_DEV_ATAPI; + break; + default: + ap->device[0].class = ATA_DEV_UNKNOWN; + ap->ops->port_disable(ap); + break; + }; + +out_unlock: + spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags); + LEAVE; +} + +/** + * ipr_ata_post_internal - Cleanup after an internal command + * @qc: ATA queued command + * + * Return value: + * none + **/ +static void ipr_ata_post_internal(struct ata_queued_cmd *qc) +{ + struct ipr_sata_port *sata_port = qc->ap->private_data; + struct ipr_ioa_cfg *ioa_cfg = sata_port->ioa_cfg; + struct ipr_cmnd *ipr_cmd; + unsigned long flags; + + spin_lock_irqsave(ioa_cfg->host->host_lock, flags); + list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) { + if (ipr_cmd->qc == qc) { + ipr_device_reset(ioa_cfg, sata_port->res); + break; + } + } + spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags); +} + +/** + * ipr_tf_read - Read the current ATA taskfile for the ATA port + * @ap: ATA port + * @tf: destination ATA taskfile + * + * Return value: + * none + **/ +static void ipr_tf_read(struct ata_port *ap, struct ata_taskfile *tf) +{ + struct ipr_sata_port *sata_port = ap->private_data; + struct ipr_ioasa_gata *g = &sata_port->ioasa; + + tf->feature = g->error; + tf->nsect = g->nsect; + tf->lbal = g->lbal; + tf->lbam = g->lbam; + tf->lbah = g->lbah; + tf->device = g->device; + tf->command = g->status; + tf->hob_nsect = g->hob_nsect; + tf->hob_lbal = g->hob_lbal; + tf->hob_lbam = g->hob_lbam; + tf->hob_lbah = g->hob_lbah; + tf->ctl = g->alt_status; +} + +/** + * ipr_copy_sata_tf - Copy a SATA taskfile to an IOA data structure + * @regs: destination + * @tf: source ATA taskfile + * + * Return value: + * none + **/ +static void ipr_copy_sata_tf(struct ipr_ioarcb_ata_regs *regs, + struct ata_taskfile *tf) +{ + regs->feature = tf->feature; + regs->nsect = tf->nsect; + regs->lbal = tf->lbal; + regs->lbam = tf->lbam; + regs->lbah = tf->lbah; + regs->device = tf->device; + regs->command = tf->command; + regs->hob_feature = tf->hob_feature; + regs->hob_nsect = tf->hob_nsect; + regs->hob_lbal = tf->hob_lbal; + regs->hob_lbam = tf->hob_lbam; + regs->hob_lbah = tf->hob_lbah; + regs->ctl = tf->ctl; +} + +/** + * ipr_sata_done - done function for SATA commands + * @ipr_cmd: ipr command struct + * + * This function is invoked by the interrupt handler for + * ops generated by the SCSI mid-layer to SATA devices + * + * Return value: + * none + **/ +static void ipr_sata_done(struct ipr_cmnd *ipr_cmd) +{ + struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; + struct ata_queued_cmd *qc = ipr_cmd->qc; + struct ipr_sata_port *sata_port = qc->ap->private_data; + struct ipr_resource_entry *res = sata_port->res; + u32 ioasc = be32_to_cpu(ipr_cmd->ioasa.ioasc); + + memcpy(&sata_port->ioasa, &ipr_cmd->ioasa.u.gata, + sizeof(struct ipr_ioasa_gata)); + ipr_dump_ioasa(ioa_cfg, ipr_cmd, res); + + if (be32_to_cpu(ipr_cmd->ioasa.ioasc_specific) & IPR_ATA_DEVICE_WAS_RESET) + scsi_report_device_reset(ioa_cfg->host, res->cfgte.res_addr.bus, + res->cfgte.res_addr.target); + + if (IPR_IOASC_SENSE_KEY(ioasc) > RECOVERED_ERROR) + qc->err_mask |= __ac_err_mask(ipr_cmd->ioasa.u.gata.status); + else + qc->err_mask |= ac_err_mask(ipr_cmd->ioasa.u.gata.status); + list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q); + ata_qc_complete(qc); +} + +/** + * ipr_build_ata_ioadl - Build an ATA scatter/gather list + * @ipr_cmd: ipr command struct + * @qc: ATA queued command + * + **/ +static void ipr_build_ata_ioadl(struct ipr_cmnd *ipr_cmd, + struct ata_queued_cmd *qc) +{ + u32 ioadl_flags = 0; + struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; + struct ipr_ioadl_desc *ioadl = ipr_cmd->ioadl; + int len = qc->nbytes + qc->pad_len; + struct scatterlist *sg; + + if (len == 0) + return; + + if (qc->dma_dir == DMA_TO_DEVICE) { + ioadl_flags = IPR_IOADL_FLAGS_WRITE; + ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_WRITE_NOT_READ; + ioarcb->write_data_transfer_length = cpu_to_be32(len); + ioarcb->write_ioadl_len = + cpu_to_be32(sizeof(struct ipr_ioadl_desc) * ipr_cmd->dma_use_sg); + } else if (qc->dma_dir == DMA_FROM_DEVICE) { + ioadl_flags = IPR_IOADL_FLAGS_READ; + ioarcb->read_data_transfer_length = cpu_to_be32(len); + ioarcb->read_ioadl_len = + cpu_to_be32(sizeof(struct ipr_ioadl_desc) * ipr_cmd->dma_use_sg); + } + + ata_for_each_sg(sg, qc) { + ioadl->flags_and_data_len = cpu_to_be32(ioadl_flags | sg_dma_len(sg)); + ioadl->address = cpu_to_be32(sg_dma_address(sg)); + if (ata_sg_is_last(sg, qc)) + ioadl->flags_and_data_len |= cpu_to_be32(IPR_IOADL_FLAGS_LAST); + else + ioadl++; + } +} + +/** + * ipr_qc_issue - Issue a SATA qc to a device + * @qc: queued command + * + * Return value: + * 0 if success + **/ +static unsigned int ipr_qc_issue(struct ata_queued_cmd *qc) +{ + struct ata_port *ap = qc->ap; + struct ipr_sata_port *sata_port = ap->private_data; + struct ipr_resource_entry *res = sata_port->res; + struct ipr_ioa_cfg *ioa_cfg = sata_port->ioa_cfg; + struct ipr_cmnd *ipr_cmd; + struct ipr_ioarcb *ioarcb; + struct ipr_ioarcb_ata_regs *regs; + + if (unlikely(!ioa_cfg->allow_cmds || ioa_cfg->ioa_is_dead)) + return -EIO; + + ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg); + ioarcb = &ipr_cmd->ioarcb; + regs = &ioarcb->add_data.u.regs; + + memset(&ioarcb->add_data, 0, sizeof(ioarcb->add_data)); + ioarcb->add_cmd_parms_len = cpu_to_be32(sizeof(ioarcb->add_data.u.regs)); + + list_add_tail(&ipr_cmd->queue, &ioa_cfg->pending_q); + ipr_cmd->qc = qc; + ipr_cmd->done = ipr_sata_done; + ipr_cmd->ioarcb.res_handle = res->cfgte.res_handle; + ioarcb->cmd_pkt.request_type = IPR_RQTYPE_ATA_PASSTHRU; + ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_NO_LINK_DESC; + ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_NO_ULEN_CHK; + ipr_cmd->dma_use_sg = qc->pad_len ? qc->n_elem + 1 : qc->n_elem; + + ipr_build_ata_ioadl(ipr_cmd, qc); + regs->flags |= IPR_ATA_FLAG_STATUS_ON_GOOD_COMPLETION; + ipr_copy_sata_tf(regs, &qc->tf); + memcpy(ioarcb->cmd_pkt.cdb, qc->cdb, IPR_MAX_CDB_LEN); + ipr_trc_hook(ipr_cmd, IPR_TRACE_START, IPR_GET_PHYS_LOC(res->cfgte.res_addr)); + + switch (qc->tf.protocol) { + case ATA_PROT_NODATA: + case ATA_PROT_PIO: + break; + + case ATA_PROT_DMA: + regs->flags |= IPR_ATA_FLAG_XFER_TYPE_DMA; + break; + + case ATA_PROT_ATAPI: + case ATA_PROT_ATAPI_NODATA: + regs->flags |= IPR_ATA_FLAG_PACKET_CMD; + break; + + case ATA_PROT_ATAPI_DMA: + regs->flags |= IPR_ATA_FLAG_PACKET_CMD; + regs->flags |= IPR_ATA_FLAG_XFER_TYPE_DMA; + break; + + default: + WARN_ON(1); + return -1; + } + + mb(); + writel(be32_to_cpu(ioarcb->ioarcb_host_pci_addr), + ioa_cfg->regs.ioarrin_reg); + return 0; +} + +/** + * ipr_ata_check_status - Return last ATA status + * @ap: ATA port + * + * Return value: + * ATA status + **/ +static u8 ipr_ata_check_status(struct ata_port *ap) +{ + struct ipr_sata_port *sata_port = ap->private_data; + return sata_port->ioasa.status; +} + +/** + * ipr_ata_check_altstatus - Return last ATA altstatus + * @ap: ATA port + * + * Return value: + * Alt ATA status + **/ +static u8 ipr_ata_check_altstatus(struct ata_port *ap) +{ + struct ipr_sata_port *sata_port = ap->private_data; + return sata_port->ioasa.alt_status; +} + +static struct ata_port_operations ipr_sata_ops = { + .port_disable = ata_port_disable, + .check_status = ipr_ata_check_status, + .check_altstatus = ipr_ata_check_altstatus, + .dev_select = ata_noop_dev_select, + .phy_reset = ipr_ata_phy_reset, + .post_internal_cmd = ipr_ata_post_internal, + .tf_read = ipr_tf_read, + .qc_prep = ata_noop_qc_prep, + .qc_issue = ipr_qc_issue, + .port_start = ata_sas_port_start, + .port_stop = ata_sas_port_stop +}; + +static struct ata_port_info sata_port_info = { + .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | ATA_FLAG_SATA_RESET | + ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA, + .pio_mask = 0x10, /* pio4 */ + .mwdma_mask = 0x07, + .udma_mask = 0x7f, /* udma0-6 */ + .port_ops = &ipr_sata_ops +}; + #ifdef CONFIG_PPC_PSERIES static const u16 ipr_blocked_processors[] = { PV_NORTHSTAR, @@ -6352,7 +6996,7 @@ static int __devinit ipr_probe_ioa(struc struct Scsi_Host *host; unsigned long ipr_regs_pci; void __iomem *ipr_regs; - u32 rc = PCIBIOS_SUCCESSFUL; + int rc = PCIBIOS_SUCCESSFUL; volatile u32 mask, uproc; ENTER; @@ -6374,6 +7018,9 @@ static int __devinit ipr_probe_ioa(struc ioa_cfg = (struct ipr_ioa_cfg *)host->hostdata; memset(ioa_cfg, 0, sizeof(struct ipr_ioa_cfg)); + host->transportt = &ipr_transport_template; + ata_host_init(&ioa_cfg->ata_host, &pdev->dev, + sata_port_info.flags, &ipr_sata_ops); ioa_cfg->chip_cfg = ipr_get_chip_cfg(dev_id); @@ -6749,7 +7396,7 @@ static int __init ipr_init(void) ipr_info("IBM Power RAID SCSI Device Driver version: %s %s\n", IPR_DRIVER_VERSION, IPR_DRIVER_DATE); - return pci_module_init(&ipr_driver); + return pci_register_driver(&ipr_driver); } /** diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h index 11eaff5..6d03528 100644 --- a/drivers/scsi/ipr.h +++ b/drivers/scsi/ipr.h @@ -28,6 +28,7 @@ #define _IPR_H #include #include +#include #include #include #include @@ -36,8 +37,8 @@ #include /* * Literals */ -#define IPR_DRIVER_VERSION "2.1.4" -#define IPR_DRIVER_DATE "(August 2, 2006)" +#define IPR_DRIVER_VERSION "2.2.0" +#define IPR_DRIVER_DATE "(September 25, 2006)" /* * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding @@ -849,6 +850,13 @@ struct ipr_bus_attributes { u32 max_xfer_rate; }; +struct ipr_sata_port { + struct ipr_ioa_cfg *ioa_cfg; + struct ata_port *ap; + struct ipr_resource_entry *res; + struct ipr_ioasa_gata ioasa; +}; + struct ipr_resource_entry { struct ipr_config_table_entry cfgte; u8 needs_sync_complete:1; @@ -858,6 +866,7 @@ struct ipr_resource_entry { u8 resetting_device:1; struct scsi_device *sdev; + struct ipr_sata_port *sata_port; struct list_head queue; }; @@ -928,10 +937,11 @@ struct ipr_trace_entry { u32 time; u8 op_code; + u8 ata_op_code; u8 type; #define IPR_TRACE_START 0x00 #define IPR_TRACE_FINISH 0xff - u16 cmd_index; + u8 cmd_index; __be32 res_handle; union { @@ -1073,6 +1083,7 @@ #define IPR_HRRQ_REQ_RESP_HANDLE_SHIFT 2 struct ipr_cmnd *reset_cmd; + struct ata_host ata_host; char ipr_cmd_label[8]; #define IPR_CMD_LABEL "ipr_cmnd" struct ipr_cmnd *ipr_cmnd_list[IPR_NUM_CMD_BLKS]; @@ -1085,6 +1096,7 @@ struct ipr_cmnd { struct ipr_ioadl_desc ioadl[IPR_NUM_IOADL_ENTRIES]; struct list_head queue; struct scsi_cmnd *scsi_cmd; + struct ata_queued_cmd *qc; struct completion completion; struct timer_list timer; void (*done) (struct ipr_cmnd *); diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index 3c63928..58065ff 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -7078,7 +7078,7 @@ ips_remove_device(struct pci_dev *pci_de static int __init ips_module_init(void) { - if (pci_module_init(&ips_pci_driver) < 0) + if (pci_register_driver(&ips_pci_driver) < 0) return -ENODEV; ips_driver_template.module = THIS_MODULE; ips_order_controllers(); diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 4cdf346..a5723ad 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -389,7 +389,8 @@ lpfc_config_port_post(struct lpfc_hba * lpfc_init_link(phba, pmb, phba->cfg_topology, phba->cfg_link_speed); pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; - if (lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT) != MBX_SUCCESS) { + rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); + if (rc != MBX_SUCCESS) { lpfc_printf_log(phba, KERN_ERR, LOG_INIT, @@ -406,7 +407,8 @@ lpfc_config_port_post(struct lpfc_hba * readl(phba->HAregaddr); /* flush */ phba->hba_state = LPFC_HBA_ERROR; - mempool_free(pmb, phba->mbox_mem_pool); + if (rc != MBX_BUSY) + mempool_free(pmb, phba->mbox_mem_pool); return -EIO; } /* MBOX buffer will be freed in mbox compl */ diff --git a/drivers/scsi/megaraid/mega_common.h b/drivers/scsi/megaraid/mega_common.h index 8cd0bd1..b50e27e 100644 --- a/drivers/scsi/megaraid/mega_common.h +++ b/drivers/scsi/megaraid/mega_common.h @@ -175,7 +175,7 @@ typedef struct { uint8_t max_lun; uint32_t unique_id; - uint8_t irq; + int irq; uint8_t ito; caddr_t ibuf; dma_addr_t ibuf_dma_h; diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c index bfb4f49..1c624ce 100644 --- a/drivers/scsi/nsp32.c +++ b/drivers/scsi/nsp32.c @@ -3581,7 +3581,7 @@ #endif */ static int __init init_nsp32(void) { nsp32_msg(KERN_INFO, "loading..."); - return pci_module_init(&nsp32_driver); + return pci_register_driver(&nsp32_driver); } static void __exit exit_nsp32(void) { diff --git a/drivers/scsi/nsp32.h b/drivers/scsi/nsp32.h index 5addf9f..a976e81 100644 --- a/drivers/scsi/nsp32.h +++ b/drivers/scsi/nsp32.h @@ -619,47 +619,5 @@ #define ARBIT_TIMEOUT_TIME 100 /* 100us #define REQSACK_TIMEOUT_TIME 10000 /* max wait time for REQ/SACK assertion or negation, 10000us == 10ms */ -/************************************************************************** - * Compatibility functions - */ - -/* for Kernel 2.4 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) -# define scsi_register_host(template) scsi_register_module(MODULE_SCSI_HA, template) -# define scsi_unregister_host(template) scsi_unregister_module(MODULE_SCSI_HA, template) -# define scsi_host_put(host) scsi_unregister(host) -# define pci_name(pci_dev) ((pci_dev)->slot_name) - -typedef void irqreturn_t; -# define IRQ_NONE /* */ -# define IRQ_HANDLED /* */ -# define IRQ_RETVAL(x) /* */ - -/* This is ad-hoc version of scsi_host_get_next() */ -static inline struct Scsi_Host *scsi_host_get_next(struct Scsi_Host *host) -{ - if (host == NULL) { - return scsi_hostlist; - } else { - return host->next; - } -} - -/* This is ad-hoc version of scsi_host_hn_get() */ -static inline struct Scsi_Host *scsi_host_hn_get(unsigned short hostno) -{ - struct Scsi_Host *host; - - for (host = scsi_host_get_next(NULL); host != NULL; - host = scsi_host_get_next(host)) { - if (host->host_no == hostno) { - break; - } - } - - return host; -} -#endif - #endif /* _NSP32_H */ /* end */ diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 4a2fed3..9ecb323 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c @@ -4843,8 +4843,7 @@ static int os_scsi_tape_close(struct ino static int osst_ioctl(struct inode * inode,struct file * file, unsigned int cmd_in, unsigned long arg) { - int i, cmd_nr, cmd_type, retval = 0; - unsigned int blk; + int i, cmd_nr, cmd_type, blk, retval = 0; struct st_modedef * STm; struct st_partstat * STps; struct osst_request * SRpnt = NULL; diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 332151e..9f33e59 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -2862,7 +2862,7 @@ qla1280_64bit_start_scsi(struct scsi_qla memset(((char *)pkt + 8), 0, (REQUEST_ENTRY_SIZE - 8)); /* Set ISP command timeout. */ - pkt->timeout = cpu_to_le16(30); + pkt->timeout = cpu_to_le16(cmd->timeout_per_command/HZ); /* Set device target ID and LUN */ pkt->lun = SCSI_LUN_32(cmd); @@ -3161,7 +3161,7 @@ qla1280_32bit_start_scsi(struct scsi_qla memset(((char *)pkt + 8), 0, (REQUEST_ENTRY_SIZE - 8)); /* Set ISP command timeout. */ - pkt->timeout = cpu_to_le16(30); + pkt->timeout = cpu_to_le16(cmd->timeout_per_command/HZ); /* Set device target ID and LUN */ pkt->lun = SCSI_LUN_32(cmd); @@ -4484,7 +4484,7 @@ #ifdef MODULE qla1280_setup(qla1280); #endif - return pci_module_init(&qla1280_pci_driver); + return pci_register_driver(&qla1280_pci_driver); } static void __exit diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index da95bce..c59f315 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -128,7 +128,7 @@ const char * scsi_device_type(unsigned t return "Well-known LUN "; if (type == 0x1f) return "No Device "; - if (type > ARRAY_SIZE(scsi_device_types)) + if (type >= ARRAY_SIZE(scsi_device_types)) return "Unknown "; return scsi_device_types[type]; } diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index 3d0429b..ce63044 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -150,6 +150,7 @@ static struct { {"DELL", "PERCRAID", NULL, BLIST_FORCELUN}, {"DGC", "RAID", NULL, BLIST_SPARSELUN}, /* Dell PV 650F, storage on LUN 0 */ {"DGC", "DISK", NULL, BLIST_SPARSELUN}, /* Dell PV 650F, no storage on LUN 0 */ + {"EMC", "Invista", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, {"EMC", "SYMMETRIX", NULL, BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_FORCELUN}, {"EMULEX", "MD21/S2 ESDI", NULL, BLIST_SINGLELUN}, {"FSC", "CentricStor", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, @@ -161,6 +162,11 @@ static struct { {"HITACHI", "DF600", "*", BLIST_SPARSELUN}, {"HITACHI", "DISK-SUBSYSTEM", "*", BLIST_ATTACH_PQ3 | BLIST_SPARSELUN | BLIST_LARGELUN}, {"HITACHI", "OPEN-E", "*", BLIST_ATTACH_PQ3 | BLIST_SPARSELUN | BLIST_LARGELUN}, + {"HITACHI", "OP-C-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, + {"HITACHI", "3380-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, + {"HITACHI", "3390-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, + {"HITACHI", "6586-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, + {"HITACHI", "6588-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, {"HP", "A6189A", NULL, BLIST_SPARSELUN | BLIST_LARGELUN}, /* HP VA7400 */ {"HP", "OPEN-", "*", BLIST_REPORTLUN2}, /* HP XP Arrays */ {"HP", "NetRAID-4M", NULL, BLIST_FORCELUN}, @@ -168,6 +174,14 @@ static struct { {"HP", "C1557A", NULL, BLIST_FORCELUN}, {"HP", "C3323-300", "4269", BLIST_NOTQ}, {"HP", "C5713A", NULL, BLIST_NOREPORTLUN}, + {"HP", "DF400", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, + {"HP", "DF500", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, + {"HP", "DF600", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, + {"HP", "OP-C-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, + {"HP", "3380-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, + {"HP", "3390-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, + {"HP", "6586-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, + {"HP", "6588-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, {"IBM", "AuSaV1S2", NULL, BLIST_FORCELUN}, {"IBM", "ProFibre 4000R", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, {"IBM", "2105", NULL, BLIST_RETRY_HWERROR}, @@ -188,6 +202,7 @@ static struct { {"NAKAMICH", "MJ-4.8S", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, {"NAKAMICH", "MJ-5.16S", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, {"NEC", "PD-1 ODX654P", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, + {"NEC", "iStorage", NULL, BLIST_REPORTLUN2}, {"NRC", "MBR-7", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, {"NRC", "MBR-7.4", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, {"PIONEER", "CD-ROM DRM-600", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, @@ -210,6 +225,7 @@ static struct { {"SUN", "T300", "*", BLIST_SPARSELUN}, {"SUN", "T4", "*", BLIST_SPARSELUN}, {"TEXEL", "CD-ROM", "1.06", BLIST_BORKEN}, + {"Tornado-", "F4", "*", BLIST_NOREPORTLUN}, {"TOSHIBA", "CDROM", NULL, BLIST_ISROM}, {"TOSHIBA", "CD-ROM", NULL, BLIST_ISROM}, {"USB2.0", "SMARTMEDIA/XD", NULL, BLIST_FORCELUN | BLIST_INQUIRY_36}, diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 7108472..743f67e 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -426,7 +426,7 @@ int scsi_execute_async(struct scsi_devic free_req: blk_put_request(req); free_sense: - kfree(sioc); + kmem_cache_free(scsi_io_context_cache, sioc); return DRIVER_ERROR << 24; } EXPORT_SYMBOL_GPL(scsi_execute_async); diff --git a/drivers/scsi/seagate.c b/drivers/scsi/seagate.c index 2679ea8..4e6666c 100644 --- a/drivers/scsi/seagate.c +++ b/drivers/scsi/seagate.c @@ -94,7 +94,6 @@ #include #include #include #include -#include #include #include #include @@ -103,12 +102,13 @@ #include #include #include -#include "scsi.h" +#include +#include +#include + #include #include -#include "seagate.h" -#include #ifdef DEBUG #define DPRINTK( when, msg... ) do { if ( (DEBUG & (when)) == (when) ) printk( msg ); } while (0) @@ -322,6 +322,7 @@ #endif /* n OVERRIDE */ static int hostno = -1; static void seagate_reconnect_intr (int, void *, struct pt_regs *); static irqreturn_t do_seagate_reconnect_intr (int, void *, struct pt_regs *); +static int seagate_st0x_bus_reset(struct scsi_cmnd *); #ifdef FAST static int fast = 1; @@ -585,8 +586,8 @@ static int linked_connected = 0; static unsigned char linked_target, linked_lun; #endif -static void (*done_fn) (Scsi_Cmnd *) = NULL; -static Scsi_Cmnd *SCint = NULL; +static void (*done_fn) (struct scsi_cmnd *) = NULL; +static struct scsi_cmnd *SCint = NULL; /* * These control whether or not disconnect / reconnect will be attempted, @@ -633,7 +634,7 @@ static irqreturn_t do_seagate_reconnect_ static void seagate_reconnect_intr (int irq, void *dev_id, struct pt_regs *regs) { int temp; - Scsi_Cmnd *SCtmp; + struct scsi_cmnd *SCtmp; DPRINTK (PHASE_RESELECT, "scsi%d : seagate_reconnect_intr() called\n", hostno); @@ -675,10 +676,11 @@ static void seagate_reconnect_intr (int static int recursion_depth = 0; -static int seagate_st0x_queue_command (Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *)) +static int seagate_st0x_queue_command(struct scsi_cmnd * SCpnt, + void (*done) (struct scsi_cmnd *)) { int result, reconnect; - Scsi_Cmnd *SCtmp; + struct scsi_cmnd *SCtmp; DANY ("seagate: que_command"); done_fn = done; @@ -1609,7 +1611,7 @@ #endif /* LINKED */ return retcode (st0x_aborted); } /* end of internal_command */ -static int seagate_st0x_abort (Scsi_Cmnd * SCpnt) +static int seagate_st0x_abort(struct scsi_cmnd * SCpnt) { st0x_aborted = DID_ABORT; return SUCCESS; @@ -1624,7 +1626,7 @@ #undef TIMEOUT * May be called with SCpnt = NULL */ -static int seagate_st0x_bus_reset(Scsi_Cmnd * SCpnt) +static int seagate_st0x_bus_reset(struct scsi_cmnd * SCpnt) { /* No timeouts - this command is going to fail because it was reset. */ DANY ("scsi%d: Reseting bus... ", hostno); diff --git a/drivers/scsi/seagate.h b/drivers/scsi/seagate.h deleted file mode 100644 index fb5f380..0000000 --- a/drivers/scsi/seagate.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * seagate.h Copyright (C) 1992 Drew Eckhardt - * low level scsi driver header for ST01/ST02 by - * Drew Eckhardt - * - * - */ - -#ifndef _SEAGATE_H -#define SEAGATE_H - -static int seagate_st0x_detect(struct scsi_host_template *); -static int seagate_st0x_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); - -static int seagate_st0x_abort(Scsi_Cmnd *); -static const char *seagate_st0x_info(struct Scsi_Host *); -static int seagate_st0x_bus_reset(Scsi_Cmnd *); - -#endif /* _SEAGATE_H */ diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 34f9343..3f8b931 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -60,7 +60,7 @@ #include "scsi_logging.h" #ifdef CONFIG_SCSI_PROC_FS #include -static char *sg_version_date = "20060818"; +static char *sg_version_date = "20060920"; static int sg_proc_init(void); static void sg_proc_cleanup(void); @@ -94,6 +94,9 @@ int sg_big_buff = SG_DEF_RESERVED_SIZE; static int def_reserved_size = -1; /* picks up init parameter */ static int sg_allow_dio = SG_ALLOW_DIO_DEF; +static int scatter_elem_sz = SG_SCATTER_SZ; +static int scatter_elem_sz_prev = SG_SCATTER_SZ; + #define SG_SECTOR_SZ 512 #define SG_SECTOR_MSK (SG_SECTOR_SZ - 1) @@ -1537,11 +1540,9 @@ sg_remove(struct class_device *cl_dev, s msleep(10); /* dirty detach so delay device destruction */ } -/* Set 'perm' (4th argument) to 0 to disable module_param's definition - * of sysfs parameters (which module_param doesn't yet support). - * Sysfs parameters defined explicitly below. - */ -module_param_named(def_reserved_size, def_reserved_size, int, S_IRUGO); +module_param_named(scatter_elem_sz, scatter_elem_sz, int, S_IRUGO | S_IWUSR); +module_param_named(def_reserved_size, def_reserved_size, int, + S_IRUGO | S_IWUSR); module_param_named(allow_dio, sg_allow_dio, int, S_IRUGO | S_IWUSR); MODULE_AUTHOR("Douglas Gilbert"); @@ -1550,6 +1551,8 @@ MODULE_LICENSE("GPL"); MODULE_VERSION(SG_VERSION_STR); MODULE_ALIAS_CHARDEV_MAJOR(SCSI_GENERIC_MAJOR); +MODULE_PARM_DESC(scatter_elem_sz, "scatter gather element " + "size (default: max(SG_SCATTER_SZ, PAGE_SIZE))"); MODULE_PARM_DESC(def_reserved_size, "size of buffer reserved for each fd"); MODULE_PARM_DESC(allow_dio, "allow direct I/O (default: 0 (disallow))"); @@ -1558,8 +1561,14 @@ init_sg(void) { int rc; + if (scatter_elem_sz < PAGE_SIZE) { + scatter_elem_sz = PAGE_SIZE; + scatter_elem_sz_prev = scatter_elem_sz; + } if (def_reserved_size >= 0) sg_big_buff = def_reserved_size; + else + def_reserved_size = sg_big_buff; rc = register_chrdev_region(MKDEV(SCSI_GENERIC_MAJOR, 0), SG_MAX_DEVS, "sg"); @@ -1842,15 +1851,30 @@ sg_build_indirect(Sg_scatter_hold * schp if (mx_sc_elems < 0) return mx_sc_elems; /* most likely -ENOMEM */ + num = scatter_elem_sz; + if (unlikely(num != scatter_elem_sz_prev)) { + if (num < PAGE_SIZE) { + scatter_elem_sz = PAGE_SIZE; + scatter_elem_sz_prev = PAGE_SIZE; + } else + scatter_elem_sz_prev = num; + } for (k = 0, sg = schp->buffer, rem_sz = blk_size; (rem_sz > 0) && (k < mx_sc_elems); ++k, rem_sz -= ret_sz, ++sg) { - num = (rem_sz > SG_SCATTER_SZ) ? SG_SCATTER_SZ : rem_sz; + num = (rem_sz > scatter_elem_sz_prev) ? + scatter_elem_sz_prev : rem_sz; p = sg_page_malloc(num, sfp->low_dma, &ret_sz); if (!p) return -ENOMEM; + if (num == scatter_elem_sz_prev) { + if (unlikely(ret_sz > scatter_elem_sz_prev)) { + scatter_elem_sz = ret_sz; + scatter_elem_sz_prev = ret_sz; + } + } sg->page = p; sg->length = ret_sz; @@ -2341,6 +2365,9 @@ sg_add_sfp(Sg_device * sdp, int dev) } write_unlock_irqrestore(&sg_dev_arr_lock, iflags); SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: sfp=0x%p\n", sfp)); + if (unlikely(sg_big_buff != def_reserved_size)) + sg_big_buff = def_reserved_size; + sg_build_reserve(sfp, sg_big_buff); SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: bufflen=%d, k_use_sg=%d\n", sfp->reserve.bufflen, sfp->reserve.k_use_sg)); @@ -2437,16 +2464,16 @@ sg_res_in_use(Sg_fd * sfp) return srp ? 1 : 0; } -/* If retSzp==NULL want exact size or fail */ +/* The size fetched (value output via retSzp) set when non-NULL return */ static struct page * sg_page_malloc(int rqSz, int lowDma, int *retSzp) { struct page *resp = NULL; gfp_t page_mask; int order, a_size; - int resSz = rqSz; + int resSz; - if (rqSz <= 0) + if ((rqSz <= 0) || (NULL == retSzp)) return resp; if (lowDma) @@ -2456,8 +2483,9 @@ sg_page_malloc(int rqSz, int lowDma, int for (order = 0, a_size = PAGE_SIZE; a_size < rqSz; order++, a_size <<= 1) ; + resSz = a_size; /* rounded up if necessary */ resp = alloc_pages(page_mask, order); - while ((!resp) && order && retSzp) { + while ((!resp) && order) { --order; a_size >>= 1; /* divide by 2, until PAGE_SIZE */ resp = alloc_pages(page_mask, order); /* try half */ @@ -2466,8 +2494,7 @@ sg_page_malloc(int rqSz, int lowDma, int if (resp) { if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) memset(page_address(resp), 0, resSz); - if (retSzp) - *retSzp = resSz; + *retSzp = resSz; } return resp; } diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index 3cf3106..a54e6c1 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -11,7 +11,7 @@ * Written By: * Ed Lin * - * Version: 2.9.0.13 + * Version: 3.0.0.1 * */ @@ -37,11 +37,11 @@ #include #include #define DRV_NAME "stex" -#define ST_DRIVER_VERSION "2.9.0.13" -#define ST_VER_MAJOR 2 -#define ST_VER_MINOR 9 +#define ST_DRIVER_VERSION "3.0.0.1" +#define ST_VER_MAJOR 3 +#define ST_VER_MINOR 0 #define ST_OEM 0 -#define ST_BUILD_VER 13 +#define ST_BUILD_VER 1 enum { /* MU register offset */ @@ -120,12 +120,18 @@ enum { st_shasta = 0, st_vsc = 1, + st_yosemite = 2, PASSTHRU_REQ_TYPE = 0x00000001, PASSTHRU_REQ_NO_WAKEUP = 0x00000100, ST_INTERNAL_TIMEOUT = 30, + ST_TO_CMD = 0, + ST_FROM_CMD = 1, + /* vendor specific commands of Promise */ + MGT_CMD = 0xd8, + SINBAND_MGT_CMD = 0xd9, ARRAY_CMD = 0xe0, CONTROLLER_CMD = 0xe1, DEBUGGING_CMD = 0xe2, @@ -133,14 +139,48 @@ enum { PASSTHRU_GET_ADAPTER = 0x05, PASSTHRU_GET_DRVVER = 0x10, + + CTLR_CONFIG_CMD = 0x03, + CTLR_SHUTDOWN = 0x0d, + CTLR_POWER_STATE_CHANGE = 0x0e, CTLR_POWER_SAVING = 0x01, PASSTHRU_SIGNATURE = 0x4e415041, + MGT_CMD_SIGNATURE = 0xba, INQUIRY_EVPD = 0x01, }; +/* SCSI inquiry data */ +typedef struct st_inq { + u8 DeviceType :5; + u8 DeviceTypeQualifier :3; + u8 DeviceTypeModifier :7; + u8 RemovableMedia :1; + u8 Versions; + u8 ResponseDataFormat :4; + u8 HiSupport :1; + u8 NormACA :1; + u8 ReservedBit :1; + u8 AERC :1; + u8 AdditionalLength; + u8 Reserved[2]; + u8 SoftReset :1; + u8 CommandQueue :1; + u8 Reserved2 :1; + u8 LinkedCommands :1; + u8 Synchronous :1; + u8 Wide16Bit :1; + u8 Wide32Bit :1; + u8 RelativeAddressing :1; + u8 VendorId[8]; + u8 ProductId[16]; + u8 ProductRevisionLevel[4]; + u8 VendorSpecific[20]; + u8 Reserved3[40]; +} ST_INQ; + struct st_sgitem { u8 ctrl; /* SG_CF_xxx */ u8 reserved[3]; @@ -181,7 +221,7 @@ struct req_msg { u8 task_attr; u8 task_manage; u8 prd_entry; - u8 payload_sz; /* payload size in 4-byte */ + u8 payload_sz; /* payload size in 4-byte, not used */ u8 cdb[STEX_CDB_LENGTH]; u8 variable[REQ_VARIABLE_LEN]; }; @@ -242,7 +282,8 @@ struct st_drvver { #define MU_REQ_BUFFER_SIZE (MU_REQ_COUNT * sizeof(struct req_msg)) #define MU_STATUS_BUFFER_SIZE (MU_STATUS_COUNT * sizeof(struct status_msg)) #define MU_BUFFER_SIZE (MU_REQ_BUFFER_SIZE + MU_STATUS_BUFFER_SIZE) -#define STEX_BUFFER_SIZE (MU_BUFFER_SIZE + sizeof(struct st_frame)) +#define STEX_EXTRA_SIZE max(sizeof(struct st_frame), sizeof(ST_INQ)) +#define STEX_BUFFER_SIZE (MU_BUFFER_SIZE + STEX_EXTRA_SIZE) struct st_ccb { struct req_msg *req; @@ -403,7 +444,7 @@ static int stex_map_sg(struct st_hba *hb } static void stex_internal_copy(struct scsi_cmnd *cmd, - const void *src, size_t *count, int sg_count) + const void *src, size_t *count, int sg_count, int direction) { size_t lcount; size_t len; @@ -427,7 +468,10 @@ static void stex_internal_copy(struct sc } else d = cmd->request_buffer; - memcpy(d, s, len); + if (direction == ST_TO_CMD) + memcpy(d, s, len); + else + memcpy(s, d, len); lcount -= len; if (cmd->use_sg) @@ -449,7 +493,7 @@ static int stex_direct_copy(struct scsi_ return 0; } - stex_internal_copy(cmd, src, &cp_len, n_elem); + stex_internal_copy(cmd, src, &cp_len, n_elem, ST_TO_CMD); if (cmd->use_sg) pci_unmap_sg(hba->pdev, cmd->request_buffer, @@ -480,7 +524,7 @@ static void stex_controller_info(struct p->subid = hba->pdev->subsystem_vendor << 16 | hba->pdev->subsystem_device; - stex_internal_copy(ccb->cmd, p, &count, ccb->sg_count); + stex_internal_copy(ccb->cmd, p, &count, ccb->sg_count, ST_TO_CMD); } static void @@ -489,7 +533,6 @@ stex_send_cmd(struct st_hba *hba, struct req->tag = cpu_to_le16(tag); req->task_attr = TASK_ATTRIBUTE_SIMPLE; req->task_manage = 0; /* not supported yet */ - req->payload_sz = (u8)(sizeof(struct req_msg)/sizeof(u32)); hba->ccb[tag].req = req; hba->out_req_cnt++; @@ -595,8 +638,14 @@ stex_queuecommand(struct scsi_cmnd *cmd, return SCSI_MLQUEUE_HOST_BUSY; req = stex_alloc_req(hba); - req->lun = lun; - req->target = id; + + if (hba->cardtype == st_yosemite) { + req->lun = lun * (ST_MAX_TARGET_NUM - 1) + id; + req->target = 0; + } else { + req->lun = lun; + req->target = id; + } /* cdb */ memcpy(req->cdb, cmd->cmnd, STEX_CDB_LENGTH); @@ -680,7 +729,51 @@ static void stex_copy_data(struct st_ccb if (ccb->cmd == NULL) return; - stex_internal_copy(ccb->cmd, resp->variable, &count, ccb->sg_count); + stex_internal_copy(ccb->cmd, + resp->variable, &count, ccb->sg_count, ST_TO_CMD); +} + +static void stex_ys_commands(struct st_hba *hba, + struct st_ccb *ccb, struct status_msg *resp) +{ + size_t count; + + if (ccb->cmd->cmnd[0] == MGT_CMD && + resp->scsi_status != SAM_STAT_CHECK_CONDITION) { + ccb->cmd->request_bufflen = + le32_to_cpu(*(__le32 *)&resp->variable[0]); + return; + } + + if (resp->srb_status != 0) + return; + + /* determine inquiry command status by DeviceTypeQualifier */ + if (ccb->cmd->cmnd[0] == INQUIRY && + resp->scsi_status == SAM_STAT_GOOD) { + ST_INQ *inq_data; + + count = STEX_EXTRA_SIZE; + stex_internal_copy(ccb->cmd, hba->copy_buffer, + &count, ccb->sg_count, ST_FROM_CMD); + inq_data = (ST_INQ *)hba->copy_buffer; + if (inq_data->DeviceTypeQualifier != 0) + ccb->srb_status = SRB_STATUS_SELECTION_TIMEOUT; + else + ccb->srb_status = SRB_STATUS_SUCCESS; + } else if (ccb->cmd->cmnd[0] == REPORT_LUNS) { + u8 *report_lun_data = (u8 *)hba->copy_buffer; + + count = STEX_EXTRA_SIZE; + stex_internal_copy(ccb->cmd, report_lun_data, + &count, ccb->sg_count, ST_FROM_CMD); + if (report_lun_data[2] || report_lun_data[3]) { + report_lun_data[2] = 0x00; + report_lun_data[3] = 0x08; + stex_internal_copy(ccb->cmd, report_lun_data, + &count, ccb->sg_count, ST_TO_CMD); + } + } } static void stex_mu_intr(struct st_hba *hba, u32 doorbell) @@ -702,8 +795,17 @@ static void stex_mu_intr(struct st_hba * return; } - if (unlikely(hba->mu_status != MU_STATE_STARTED || - hba->out_req_cnt <= 0)) { + /* + * it's not a valid status payload if: + * 1. there are no pending requests(e.g. during init stage) + * 2. there are some pending requests, but the controller is in + * reset status, and its type is not st_yosemite + * firmware of st_yosemite in reset status will return pending requests + * to driver, so we allow it to pass + */ + if (unlikely(hba->out_req_cnt <= 0 || + (hba->mu_status == MU_STATE_RESETTING && + hba->cardtype != st_yosemite))) { hba->status_tail = hba->status_head; goto update_status; } @@ -723,6 +825,7 @@ static void stex_mu_intr(struct st_hba * if (unlikely(ccb->req == NULL)) { printk(KERN_WARNING DRV_NAME "(%s): lagging req\n", pci_name(hba->pdev)); + hba->out_req_cnt--; continue; } @@ -741,9 +844,13 @@ static void stex_mu_intr(struct st_hba * ccb->scsi_status = resp->scsi_status; if (likely(ccb->cmd != NULL)) { + if (hba->cardtype == st_yosemite) + stex_ys_commands(hba, ccb, resp); + if (unlikely(ccb->cmd->cmnd[0] == PASSTHRU_CMD && ccb->cmd->cmnd[1] == PASSTHRU_GET_ADAPTER)) stex_controller_info(hba, ccb); + stex_unmap_sg(hba, ccb->cmd); stex_scsi_done(ccb); hba->out_req_cnt--; @@ -948,6 +1055,7 @@ static int stex_reset(struct scsi_cmnd * { struct st_hba *hba; unsigned long flags; + unsigned long before; hba = (struct st_hba *) &cmd->device->host->hostdata[0]; hba->mu_status = MU_STATE_RESETTING; @@ -955,20 +1063,37 @@ static int stex_reset(struct scsi_cmnd * if (hba->cardtype == st_shasta) stex_hard_reset(hba); - if (stex_handshake(hba)) { - printk(KERN_WARNING DRV_NAME - "(%s): resetting: handshake failed\n", - pci_name(hba->pdev)); - return FAILED; + if (hba->cardtype != st_yosemite) { + if (stex_handshake(hba)) { + printk(KERN_WARNING DRV_NAME + "(%s): resetting: handshake failed\n", + pci_name(hba->pdev)); + return FAILED; + } + spin_lock_irqsave(hba->host->host_lock, flags); + hba->req_head = 0; + hba->req_tail = 0; + hba->status_head = 0; + hba->status_tail = 0; + hba->out_req_cnt = 0; + spin_unlock_irqrestore(hba->host->host_lock, flags); + return SUCCESS; + } + + /* st_yosemite */ + writel(MU_INBOUND_DOORBELL_RESET, hba->mmio_base + IDBL); + readl(hba->mmio_base + IDBL); /* flush */ + before = jiffies; + while (hba->out_req_cnt > 0) { + if (time_after(jiffies, before + ST_INTERNAL_TIMEOUT * HZ)) { + printk(KERN_WARNING DRV_NAME + "(%s): reset timeout\n", pci_name(hba->pdev)); + return FAILED; + } + msleep(1); } - spin_lock_irqsave(hba->host->host_lock, flags); - hba->req_head = 0; - hba->req_tail = 0; - hba->status_head = 0; - hba->status_tail = 0; - hba->out_req_cnt = 0; - spin_unlock_irqrestore(hba->host->host_lock, flags); + hba->mu_status = MU_STATE_STARTED; return SUCCESS; } @@ -1156,9 +1281,16 @@ static void stex_hba_stop(struct st_hba req = stex_alloc_req(hba); memset(req->cdb, 0, STEX_CDB_LENGTH); - req->cdb[0] = CONTROLLER_CMD; - req->cdb[1] = CTLR_POWER_STATE_CHANGE; - req->cdb[2] = CTLR_POWER_SAVING; + if (hba->cardtype == st_yosemite) { + req->cdb[0] = MGT_CMD; + req->cdb[1] = MGT_CMD_SIGNATURE; + req->cdb[2] = CTLR_CONFIG_CMD; + req->cdb[3] = CTLR_SHUTDOWN; + } else { + req->cdb[0] = CONTROLLER_CMD; + req->cdb[1] = CTLR_POWER_STATE_CHANGE; + req->cdb[2] = CTLR_POWER_SAVING; + } hba->ccb[tag].cmd = NULL; hba->ccb[tag].sg_count = 0; @@ -1222,6 +1354,7 @@ static struct pci_device_id stex_pci_tbl { 0x105a, 0x8301, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, { 0x105a, 0x8302, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, { 0x1725, 0x7250, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_vsc }, + { 0x105a, 0x8650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_yosemite }, { } /* terminate list */ }; MODULE_DEVICE_TABLE(pci, stex_pci_tbl); diff --git a/include/scsi/sg.h b/include/scsi/sg.h index 0a487fe..519c49a 100644 --- a/include/scsi/sg.h +++ b/include/scsi/sg.h @@ -11,26 +11,10 @@ #include Original driver (sg.h): * Copyright (C) 1992 Lawrence Foard Version 2 and 3 extensions to driver: -* Copyright (C) 1998 - 2003 Douglas Gilbert - - Version: 3.5.29 (20030529) - This version is for 2.5 series kernels. - - Changes since 3.5.28 (20030308) - - fix bug introduced in version 3.1.24 (last segment of sgat list) - Changes since 3.5.27 (20020812) - - remove procfs entries: hosts, host_hdr + host_strs (now in sysfs) - - add sysfs sg driver params: def_reserved_size, allow_dio, version - - new boot option: "sg_allow_dio" and module parameter: "allow_dio" - - multiple internal changes due to scsi subsystem rework - Changes since 3.5.26 (20020708) - - re-add direct IO using Kai Makisara's work - - re-tab to 8, start using C99-isms - - simplify memory management - Changes since 3.5.25 (20020504) - - driverfs additions - - copy_to/from_user() fixes [William Stinson] - - disable kiobufs support +* Copyright (C) 1998 - 2006 Douglas Gilbert + + Version: 3.5.34 (20060920) + This version is for 2.6 series kernels. For a full changelog see http://www.torque.net/sg @@ -40,7 +24,7 @@ Map of SG verions to the Linux kernels i 2.1.40 2.2.20 3.0.x optional version 3 sg driver for 2.2 series 3.1.17++ 2.4.0++ - 3.5.23++ 2.5.0++ + 3.5.30++ 2.6.0++ Major new features in SG 3.x driver (cf SG 2.x drivers) - SG_IO ioctl() combines function if write() and read() @@ -51,14 +35,15 @@ Major new features in SG 3.x driver (cf data into kernel buffers and then use the CPU to copy the data into the user space (vice versa for writes). That is called "indirect" IO due to the double handling of data. There are two methods offered to remove the - redundant copy: 1) direct IO which uses the kernel kiobuf mechanism and - 2) using the mmap() system call to map the reserve buffer (this driver has - one reserve buffer per fd) into the user space. Both have their advantages. + redundant copy: 1) direct IO and 2) using the mmap() system call to map + the reserve buffer (this driver has one reserve buffer per fd) into the + user space. Both have their advantages. In terms of absolute speed mmap() is faster. If speed is not a concern, indirect IO should be fine. Read the documentation for more information. - ** N.B. To use direct IO 'echo 1 > /proc/scsi/sg/allow_dio' may be - needed. That pseudo file's content is defaulted to 0. ** + ** N.B. To use direct IO 'echo 1 > /proc/scsi/sg/allow_dio' or + 'echo 1 > /sys/module/sg/parameters/allow_dio' is needed. + That attribute is 0 by default. ** Historical note: this SCSI pass-through driver has been known as "sg" for a decade. In broader kernel discussions "sg" is used to refer to scatter @@ -72,20 +57,17 @@ Major new features in SG 3.x driver (cf http://www.torque.net/sg/p/sg_v3_ho.html This is a rendering from DocBook source [change the extension to "sgml" or "xml"]. There are renderings in "ps", "pdf", "rtf" and "txt" (soon). + The SG_IO ioctl is now found in other parts kernel (e.g. the block layer). + For more information see http://www.torque.net/sg/sg_io.html The older, version 2 documents discuss the original sg interface in detail: http://www.torque.net/sg/p/scsi-generic.txt http://www.torque.net/sg/p/scsi-generic_long.txt - A version of this document (potentially out of date) may also be found in - the kernel source tree, probably at: - Documentation/scsi/scsi-generic.txt . + Also available: /Documentation/scsi/scsi-generic.txt Utility and test programs are available at the sg web site. They are - bundled as sg_utils (for the lk 2.2 series) and sg3_utils (for the - lk 2.4 series). - - There is a HOWTO on the Linux SCSI subsystem in the lk 2.4 series at: - http://www.linuxdoc.org/HOWTO/SCSI-2.4-HOWTO + packaged as sg3_utils (for the lk 2.4 and 2.6 series) and sg_utils + (for the lk 2.2 series). */ @@ -238,13 +220,12 @@ #define SG_GET_KEEP_ORPHAN 0x2288 #define SG_GET_ACCESS_COUNT 0x2289 -#define SG_SCATTER_SZ (8 * 4096) /* PAGE_SIZE not available to user */ +#define SG_SCATTER_SZ (8 * 4096) /* Largest size (in bytes) a single scatter-gather list element can have. - The value must be a power of 2 and <= (PAGE_SIZE * 32) [131072 bytes on - i386]. The minimum value is PAGE_SIZE. If scatter-gather not supported - by adapter then this value is the largest data block that can be - read/written by a single scsi command. The user can find the value of - PAGE_SIZE by calling getpagesize() defined in unistd.h . */ + The value used by the driver is 'max(SG_SCATTER_SZ, PAGE_SIZE)'. + This value should be a power of 2 (and may be rounded up internally). + If scatter-gather is not supported by adapter then this value is the + largest data block that can be read/written by a single scsi command. */ #define SG_DEFAULT_RETRIES 0