From 45e6cdf41437c72ed79cee64dc69e7f740511e50 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Tue, 19 Feb 2008 10:49:40 -0800 Subject: [SCSI] libsas: Provide a transport-level facility to request SAS addrs Provide a facility to use the request_firmware() interface to get a SAS address from userspace. This can be used by SAS LLDDs that cannot obtain the address from the host adapter. Signed-off-by: Darrick J. Wong Signed-off-by: James Bottomley --- include/scsi/libsas.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 39e1cac24bb..98724ba65a7 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -677,4 +677,6 @@ extern void sas_ssp_task_response(struct device *dev, struct sas_task *task, struct ssp_response_iu *iu); struct sas_phy *sas_find_local_phy(struct domain_device *dev); +int sas_request_addr(struct Scsi_Host *shost, u8 *addr); + #endif /* _SASLIB_H_ */ -- cgit v1.2.3 From 40f6b36c6243462fb95d0343237331c423494b03 Mon Sep 17 00:00:00 2001 From: Kai Makisara Date: Sun, 24 Feb 2008 22:23:24 +0200 Subject: [SCSI] st: add option to use SILI in variable block reads Add new option MT_ST_SILI to enable setting the SILI bit in reads in variable block mode. If SILI is set, reading a block shorter than the byte count does not result in CHECK CONDITION. The length of the block is determined using the residual count from the HBA. Avoiding the REQUEST SENSE command for every block speeds up some real applications considerably. Signed-off-by: Kai Makisara Signed-off-by: James Bottomley --- include/linux/mtio.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/mtio.h b/include/linux/mtio.h index 6f8d2d45a8f..ef01d6aa593 100644 --- a/include/linux/mtio.h +++ b/include/linux/mtio.h @@ -192,6 +192,7 @@ struct mtpos { #define MT_ST_SCSI2LOGICAL 0x800 #define MT_ST_SYSV 0x1000 #define MT_ST_NOWAIT 0x2000 +#define MT_ST_SILI 0x4000 /* The mode parameters to be controlled. Parameter chosen with bits 20-28 */ #define MT_ST_CLEAR_DEFAULT 0xfffff -- cgit v1.2.3 From 30bd7df8ced23eefec87a5cda96dc99b002ed9da Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Fri, 29 Feb 2008 18:25:19 -0600 Subject: [SCSI] scsi_error: add target reset handler The problem is that serveral drivers are sending a target reset from the device reset handler, and if we have multiple devices a target reset gets sent for each device when only one would be sufficient. And if we do a target reset it affects all the commands on the target so the device reset handler code only cleaning up one devices's commands makes programming the driver a little more difficult than it should be. This patch adds a target reset handler, which drivers can use to send a target reset. If successful it cleans up the commands for a devices accessed through that starget. Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- include/scsi/scsi_eh.h | 1 + include/scsi/scsi_host.h | 1 + 2 files changed, 2 insertions(+) (limited to 'include') diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h index 25071d5d9bf..37a7614f62f 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h @@ -64,6 +64,7 @@ extern int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len, #define SCSI_TRY_RESET_DEVICE 1 #define SCSI_TRY_RESET_BUS 2 #define SCSI_TRY_RESET_HOST 3 +#define SCSI_TRY_RESET_TARGET 4 extern int scsi_reset_provider(struct scsi_device *, int); diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 530ff4c553f..49132862bfa 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -172,6 +172,7 @@ struct scsi_host_template { */ int (* eh_abort_handler)(struct scsi_cmnd *); int (* eh_device_reset_handler)(struct scsi_cmnd *); + int (* eh_target_reset_handler)(struct scsi_cmnd *); int (* eh_bus_reset_handler)(struct scsi_cmnd *); int (* eh_host_reset_handler)(struct scsi_cmnd *); -- cgit v1.2.3 From b1adaf65ba0398c9a1adc8f3a274533165a4df61 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 18 Mar 2008 00:15:03 +0900 Subject: [SCSI] block: add sg buffer copy helper functions This patch adds new three helper functions to copy data between an SG list and a linear buffer. - sg_copy_from_buffer copies data from linear buffer to an SG list - sg_copy_to_buffer copies data from an SG list to a linear buffer When the APIs copy data from a linear buffer to an SG list, flush_kernel_dcache_page is called. It's not necessary for everyone but it's a no-op on most architectures and in general the API is not used in performance critical path. Signed-off-by: FUJITA Tomonori Acked-by: Jens Axboe Signed-off-by: James Bottomley --- include/linux/scatterlist.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index a3d567a974e..71fc8136004 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -213,6 +213,11 @@ int __sg_alloc_table(struct sg_table *, unsigned int, unsigned int, gfp_t, sg_alloc_fn *); int sg_alloc_table(struct sg_table *, unsigned int, gfp_t); +size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents, + void *buf, size_t buflen); +size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents, + void *buf, size_t buflen); + /* * Maximum number of entries that will be allocated in one piece, if * a list larger than this is required then chaining will be utilized. -- cgit v1.2.3 From 9ac16b616ab117dab3fce9790368d3b58ca441ef Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sun, 9 Mar 2008 13:44:29 +0900 Subject: [SCSI] scsi: add wrapper functions for sg buffer copy helper functions LLDs need to copies data between the SG table in struct scsi_cmnd and liner buffer. So they use the helper functions like sg_copy_from_buffer(scsi_sglist(sc), scsi_sg_count(sc), buf, buflen) sg_copy_to_buffer(scsi_sglist(sc), scsi_sg_count(sc), buf, buflen) This patch just adds wrapper functions: scsi_sg_copy_from_buffer(sc, buf, buflen) scsi_sg_copy_to_buffer(sc, buf, buflen) Signed-off-by: FUJITA Tomonori Signed-off-by: James Bottomley --- include/scsi/scsi_cmnd.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index de28aab820b..b260be6d0d7 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -175,4 +175,18 @@ static inline struct scsi_data_buffer *scsi_out(struct scsi_cmnd *cmd) return &cmd->sdb; } +static inline int scsi_sg_copy_from_buffer(struct scsi_cmnd *cmd, + void *buf, int buflen) +{ + return sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), + buf, buflen); +} + +static inline int scsi_sg_copy_to_buffer(struct scsi_cmnd *cmd, + void *buf, int buflen) +{ + return sg_copy_to_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), + buf, buflen); +} + #endif /* _SCSI_SCSI_CMND_H */ -- cgit v1.2.3 From 1c353f7d616a4ef04b5e73fe7a2184baa039f06f Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Thu, 13 Mar 2008 11:19:36 -0500 Subject: [SCSI] export command allocation and freeing functions independently of the host This is needed by things like USB storage that want to set up static commands for later use at start of day. Signed-off-by: James Bottomley --- include/scsi/scsi_cmnd.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index b260be6d0d7..8d20e60a94b 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -130,6 +130,9 @@ extern void scsi_release_buffers(struct scsi_cmnd *cmd); extern int scsi_dma_map(struct scsi_cmnd *cmd); extern void scsi_dma_unmap(struct scsi_cmnd *cmd); +struct scsi_cmnd *scsi_allocate_command(gfp_t gfp_mask); +void scsi_free_command(gfp_t gfp_mask, struct scsi_cmnd *cmd); + static inline unsigned scsi_sg_count(struct scsi_cmnd *cmd) { return cmd->sdb.table.nents; -- cgit v1.2.3 From 3bc6a26192d2548397a3e721d786cf8345ee54e1 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Tue, 25 Mar 2008 09:26:49 +0900 Subject: [SCSI] add scsi_build_sense_buffer helper function This adds scsi_build_sense_buffer, a simple helper function to build sense data in a buffer. Signed-off-by: FUJITA Tomonori Signed-off-by: James Bottomley --- include/scsi/scsi_eh.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h index 37a7614f62f..d3a133b4a07 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h @@ -57,7 +57,9 @@ extern const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len, extern int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len, u64 * info_out); - + +extern void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq); + /* * Reset request from external source */ -- cgit v1.2.3 From 2f3edc6936e3f6be3f1df1e89c141ae028fa605e Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Wed, 2 Apr 2008 10:05:48 -0500 Subject: [SCSI] transport_class: BUG if we can't release the attribute container Every current transport class calls transport_container_release but ignores the return value. This is catastrophic if it returns an error because the containers are part of a global list and the next action of almost every transport class is to free the memory used by the container. Fix this by making transport_container_release a void, but making it BUG if attribute_container_release returns an error ... this catches the root cause of a system panic much earlier. If we don't do this, we get an eventual BUG when the attribute container list notices the corruption caused by the freed memory it's still referencing. Also made attribute_container_release __must_check as a reminder. Cc: Greg KH Signed-off-by: James Bottomley --- include/linux/attribute_container.h | 2 +- include/linux/transport_class.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/linux/attribute_container.h b/include/linux/attribute_container.h index f5582332af0..574b201b99d 100644 --- a/include/linux/attribute_container.h +++ b/include/linux/attribute_container.h @@ -37,7 +37,7 @@ attribute_container_set_no_classdevs(struct attribute_container *atc) } int attribute_container_register(struct attribute_container *cont); -int attribute_container_unregister(struct attribute_container *cont); +int __must_check attribute_container_unregister(struct attribute_container *cont); void attribute_container_create_device(struct device *dev, int (*fn)(struct attribute_container *, struct device *, diff --git a/include/linux/transport_class.h b/include/linux/transport_class.h index 1d6cc22e5f4..6696cf79c4f 100644 --- a/include/linux/transport_class.h +++ b/include/linux/transport_class.h @@ -86,9 +86,10 @@ static inline int transport_container_register(struct transport_container *tc) return attribute_container_register(&tc->ac); } -static inline int transport_container_unregister(struct transport_container *tc) +static inline void transport_container_unregister(struct transport_container *tc) { - return attribute_container_unregister(&tc->ac); + if (unlikely(attribute_container_unregister(&tc->ac))) + BUG(); } int transport_class_register(struct transport_class *); -- cgit v1.2.3 From 79bc14813cd7e1b75d2e4cbbc17043261cf4bcdc Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Thu, 3 Apr 2008 09:04:31 -0500 Subject: [SCSI] libsas: fix missing inlines in header file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two functions in include/scsi/sas_ata.h don't have static inlines leading to problems if they're built in: On Thu, 2008-04-03 at 14:06 +0200, Toralf Förster wrote: > drivers/scsi/mvsas.o: In function `sas_ata_init_host_and_port': > mvsas.c:(.text+0x0): multiple definition of `sas_ata_init_host_and_port' > drivers/scsi/libsas/built-in.o:(.text+0x37f4): first defined here > drivers/scsi/mvsas.o: In function `sas_ata_task_abort': > mvsas.c:(.text+0x7): multiple definition of `sas_ata_task_abort' > drivers/scsi/libsas/built-in.o:(.text+0x37fb): first defined here > make[2]: *** [drivers/scsi/built-in.o] Error 1 > make[1]: *** [drivers/scsi] Error 2 > make: *** [drivers] Error 2 Add the correct static inline modifiers. Tested-by: Toralf Förster Signed-off-by: James Bottomley --- include/scsi/sas_ata.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h index dd5edc91541..c583193ae92 100644 --- a/include/scsi/sas_ata.h +++ b/include/scsi/sas_ata.h @@ -47,12 +47,12 @@ static inline int dev_is_sata(struct domain_device *dev) { return 0; } -int sas_ata_init_host_and_port(struct domain_device *found_dev, +static inline int sas_ata_init_host_and_port(struct domain_device *found_dev, struct scsi_target *starget) { return 0; } -void sas_ata_task_abort(struct sas_task *task) +static inline void sas_ata_task_abort(struct sas_task *task) { } #endif -- cgit v1.2.3 From 38d1c069db8c87eb6cb10ca1ede9d9b673531ddd Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Fri, 18 Apr 2008 10:11:51 -0500 Subject: [SCSI] iscsi: extended cdb support Support for extended CDBs in iscsi. All we need is to check if command spills over 16 bytes then allocate an iscsi-extended-header for the leftovers. Signed-off-by: Boaz Harrosh Reviewed-by: Pete Wyckoff Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- include/scsi/iscsi_proto.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h index 5ffec8ad696..e0593bfae62 100644 --- a/include/scsi/iscsi_proto.h +++ b/include/scsi/iscsi_proto.h @@ -112,6 +112,7 @@ struct iscsi_ahs_hdr { #define ISCSI_AHSTYPE_CDB 1 #define ISCSI_AHSTYPE_RLENGTH 2 +#define ISCSI_CDB_SIZE 16 /* iSCSI PDU Header */ struct iscsi_cmd { @@ -125,7 +126,7 @@ struct iscsi_cmd { __be32 data_length; __be32 cmdsn; __be32 exp_statsn; - uint8_t cdb[16]; /* SCSI Command Block */ + uint8_t cdb[ISCSI_CDB_SIZE]; /* SCSI Command Block */ /* Additional Data (Command Dependent) */ }; @@ -154,7 +155,8 @@ struct iscsi_ecdb_ahdr { __be16 ahslength; /* CDB length - 15, including reserved byte */ uint8_t ahstype; uint8_t reserved; - uint8_t ecdb[260 - 16]; /* 4-byte aligned extended CDB spillover */ + /* 4-byte aligned extended CDB spillover */ + uint8_t ecdb[260 - ISCSI_CDB_SIZE]; }; /* SCSI Response Header */ -- cgit v1.2.3