From d3301874083874f8a0ac88aa1bb7da6b62df34d2 Mon Sep 17 00:00:00 2001 From: Mike Anderson Date: Thu, 16 Jun 2005 11:12:38 -0700 Subject: [SCSI] host state model update: replace old host bitmap state Migrate the current SCSI host state model to a model like SCSI device is using. Signed-off-by: Mike Anderson Rejections fixed up and Signed-off-by: James Bottomley --- include/scsi/scsi_host.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'include/scsi') diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 81d5234f677..0b1e275b269 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -429,12 +429,15 @@ struct scsi_host_template { }; /* - * shost states + * shost state: If you alter this, you also need to alter scsi_sysfs.c + * (for the ascii descriptions) and the state model enforcer: + * scsi_host_set_state() */ -enum { - SHOST_ADD, - SHOST_DEL, +enum scsi_host_state { + SHOST_CREATED = 1, + SHOST_RUNNING, SHOST_CANCEL, + SHOST_DEL, SHOST_RECOVERY, }; @@ -575,7 +578,7 @@ struct Scsi_Host { unsigned int irq; - unsigned long shost_state; + enum scsi_host_state shost_state; /* ldm bits */ struct device shost_gendev; @@ -633,6 +636,7 @@ extern void scsi_remove_host(struct Scsi_Host *); extern struct Scsi_Host *scsi_host_get(struct Scsi_Host *); extern void scsi_host_put(struct Scsi_Host *t); extern struct Scsi_Host *scsi_host_lookup(unsigned short); +extern const char *scsi_host_state_name(enum scsi_host_state); extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *); -- cgit v1.2.3 From 82f29467a025f6a2192d281e97fca0be46e905cc Mon Sep 17 00:00:00 2001 From: Mike Anderson Date: Thu, 16 Jun 2005 11:14:33 -0700 Subject: [SCSI] host state model update: mediate host add/remove race Add support to not allow additions to a host when it is being removed. Signed-off-by: Mike Anderson Signed-off-by: James Bottomley --- include/scsi/scsi_host.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/scsi') diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 0b1e275b269..1ea5b51d174 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -650,6 +650,15 @@ static inline struct device *scsi_get_device(struct Scsi_Host *shost) return shost->shost_gendev.parent; } +/** + * scsi_host_scan_allowed - Is scanning of this host allowed + * @shost: Pointer to Scsi_Host. + **/ +static inline int scsi_host_scan_allowed(struct Scsi_Host *shost) +{ + return shost->shost_state == SHOST_RUNNING; +} + extern void scsi_unblock_requests(struct Scsi_Host *); extern void scsi_block_requests(struct Scsi_Host *); -- cgit v1.2.3 From 47ba39eead9f4495cd6a3eca39d7c73d0f0d61c9 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sat, 30 Jul 2005 11:39:53 -0500 Subject: [SCSI] add template for scsi_host_set_state() Fixes up some warnings in the tree. Signed-off-by: James Bottomley --- include/scsi/scsi_host.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/scsi') diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 1ea5b51d174..ac1b6125e3a 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -676,5 +676,6 @@ extern struct scsi_device *scsi_get_host_dev(struct Scsi_Host *); /* legacy interfaces */ extern struct Scsi_Host *scsi_register(struct scsi_host_template *, int); extern void scsi_unregister(struct Scsi_Host *); +extern int scsi_host_set_state(struct Scsi_Host *, enum scsi_host_state); #endif /* _SCSI_SCSI_HOST_H */ -- cgit v1.2.3 From d872ebe4549576e7aab60ed7c746193196381dd0 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Wed, 3 Aug 2005 15:43:52 -0500 Subject: [SCSI] add missing hold_mcs parameter to the spi transport class This parameter is important only to people who take the time to tune the margin control settings, otherwise it's completely irrelevant. However, just in case anyone should want to do this, it's appropriate to include the parameter. I don't do anything with it in DV by design, so the parameter will come up as off by default, so if anyone actually wants to play with the margin control settings they'll have to enable it under the spi_transport class first. I also updated the transfer settings display to report all of the PPR settings instead of only DT, IU and QAS Signed-off-by: James Bottomley --- include/scsi/scsi_transport_spi.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/scsi') diff --git a/include/scsi/scsi_transport_spi.h b/include/scsi/scsi_transport_spi.h index a30d6cd4c0e..d8ef86006e0 100644 --- a/include/scsi/scsi_transport_spi.h +++ b/include/scsi/scsi_transport_spi.h @@ -39,6 +39,7 @@ struct spi_transport_attrs { unsigned int rd_strm:1; /* Read streaming enabled */ unsigned int rti:1; /* Retain Training Information */ unsigned int pcomp_en:1;/* Precompensation enabled */ + unsigned int hold_mcs:1;/* Hold Margin Control Settings */ unsigned int initial_dv:1; /* DV done to this target yet */ unsigned long flags; /* flags field for drivers to use */ /* Device Properties fields */ @@ -78,6 +79,7 @@ struct spi_host_attrs { #define spi_rd_strm(x) (((struct spi_transport_attrs *)&(x)->starget_data)->rd_strm) #define spi_rti(x) (((struct spi_transport_attrs *)&(x)->starget_data)->rti) #define spi_pcomp_en(x) (((struct spi_transport_attrs *)&(x)->starget_data)->pcomp_en) +#define spi_hold_mcs(x) (((struct spi_transport_attrs *)&(x)->starget_data)->hold_mcs) #define spi_initial_dv(x) (((struct spi_transport_attrs *)&(x)->starget_data)->initial_dv) #define spi_support_sync(x) (((struct spi_transport_attrs *)&(x)->starget_data)->support_sync) @@ -114,6 +116,8 @@ struct spi_function_template { void (*set_rti)(struct scsi_target *, int); void (*get_pcomp_en)(struct scsi_target *); void (*set_pcomp_en)(struct scsi_target *, int); + void (*get_hold_mcs)(struct scsi_target *); + void (*set_hold_mcs)(struct scsi_target *, int); void (*get_signalling)(struct Scsi_Host *); void (*set_signalling)(struct Scsi_Host *, enum spi_signal_type); /* The driver sets these to tell the transport class it @@ -130,6 +134,7 @@ struct spi_function_template { unsigned long show_rd_strm:1; unsigned long show_rti:1; unsigned long show_pcomp_en:1; + unsigned long show_hold_mcs:1; }; struct scsi_transport_template *spi_attach_transport(struct spi_function_template *); -- cgit v1.2.3 From b21a41385118f9a6af3cd96ce71090c5ada52eb5 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Fri, 5 Aug 2005 21:45:40 -0500 Subject: [SCSI] add global timeout to the scsi mid-layer There are certain rogue devices (and the aic7xxx driver) that return BUSY or QUEUE_FULL forever. This code will apply a global timeout (of the total number of retries times the per command timer) to a given command. If it is exceeded, the command is completed regardless of its state. The patch also removes the unused field in the command: timeout and timeout_total. This solves the problem of detecting an endless loop in the mid-layer because of BUSY/QUEUE_FULL bouncing, but will not recover the device. In the aic7xxx case, the driver can be recovered by sending a bus reset, so possibly this should be tied into the error handler? Signed-off-by: James Bottomley --- include/scsi/scsi_cmnd.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include/scsi') diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 9957f16dcc5..bed4b7c9be9 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -51,12 +51,16 @@ struct scsi_cmnd { * printk's to use ->pid, so that we can kill this field. */ unsigned long serial_number; + /* + * This is set to jiffies as it was when the command was first + * allocated. It is used to time how long the command has + * been outstanding + */ + unsigned long jiffies_at_alloc; int retries; int allowed; int timeout_per_command; - int timeout_total; - int timeout; unsigned char cmd_len; unsigned char old_cmd_len; -- cgit v1.2.3 From 10c1b88987d618f4f89c10e11e574c76de73b5e7 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 14 Aug 2005 14:34:06 -0500 Subject: [SCSI] add ability to deny binding to SPI transport class This patch is necessary if we begin exposing underlying physical disks (which can attach to the SPI transport class) of the hardware RAID cards, since we don't want any SPI parameters binding to the RAID devices. Signed-off-by: James Bottomley --- include/scsi/scsi_transport_spi.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/scsi') diff --git a/include/scsi/scsi_transport_spi.h b/include/scsi/scsi_transport_spi.h index d8ef86006e0..6bdc4afb248 100644 --- a/include/scsi/scsi_transport_spi.h +++ b/include/scsi/scsi_transport_spi.h @@ -120,6 +120,7 @@ struct spi_function_template { void (*set_hold_mcs)(struct scsi_target *, int); void (*get_signalling)(struct Scsi_Host *); void (*set_signalling)(struct Scsi_Host *, enum spi_signal_type); + int (*deny_binding)(struct scsi_target *); /* The driver sets these to tell the transport class it * wants the attributes displayed in sysfs. If the show_ flag * is not set, the attribute will be private to the transport -- cgit v1.2.3 From 392160335c798bbe94ab3aae6ea0c85d32b81bbc Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Wed, 15 Jun 2005 18:48:29 -0500 Subject: [SCSI] use scatter lists for all block pc requests and simplify hw handlers Original From: Mike Christie Add scsi_execute_req() as a replacement for scsi_wait_req() Fixed up various pieces (added REQ_SPECIAL and caught req use after free) Signed-off-by: James Bottomley --- include/scsi/scsi_request.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/scsi') diff --git a/include/scsi/scsi_request.h b/include/scsi/scsi_request.h index 98719407d55..d64903a617c 100644 --- a/include/scsi/scsi_request.h +++ b/include/scsi/scsi_request.h @@ -54,6 +54,9 @@ extern void scsi_do_req(struct scsi_request *, const void *cmnd, void *buffer, unsigned bufflen, void (*done) (struct scsi_cmnd *), int timeout, int retries); +extern int scsi_execute_req(struct scsi_device *sdev, unsigned char *cmd, + int data_direction, void *buffer, unsigned bufflen, + unsigned char *sense, int timeout, int retries); struct scsi_mode_data { __u32 length; -- cgit v1.2.3 From 1cf72699c1530c3e4ac3d58344f6a6a40a2f46d3 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 28 Aug 2005 11:27:01 -0500 Subject: [SCSI] convert the remaining mid-layer pieces to scsi_execute_req After this, we just have some drivers, all the ULDs and the SPI transport class using scsi_wait_req(). Signed-off-by: James Bottomley --- include/scsi/scsi_device.h | 13 +++++++++++-- include/scsi/scsi_request.h | 15 --------------- 2 files changed, 11 insertions(+), 17 deletions(-) (limited to 'include/scsi') diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 835af8ecbb7..9181068883c 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -8,9 +8,17 @@ struct request_queue; struct scsi_cmnd; -struct scsi_mode_data; struct scsi_lun; +struct scsi_mode_data { + __u32 length; + __u16 block_descriptor_length; + __u8 medium_type; + __u8 device_specific; + __u8 header_length; + __u8 longlba:1; +}; + /* * sdev state: If you alter this, you also need to alter scsi_sysfs.c * (for the ascii descriptions) and the state model enforcer: @@ -228,7 +236,8 @@ extern int scsi_set_medium_removal(struct scsi_device *, char); extern int scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, unsigned char *buffer, int len, int timeout, - int retries, struct scsi_mode_data *data); + int retries, struct scsi_mode_data *data, + char *sense); extern int scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries); extern int scsi_device_set_state(struct scsi_device *sdev, diff --git a/include/scsi/scsi_request.h b/include/scsi/scsi_request.h index d64903a617c..f5dfdfec9fe 100644 --- a/include/scsi/scsi_request.h +++ b/include/scsi/scsi_request.h @@ -58,19 +58,4 @@ extern int scsi_execute_req(struct scsi_device *sdev, unsigned char *cmd, int data_direction, void *buffer, unsigned bufflen, unsigned char *sense, int timeout, int retries); -struct scsi_mode_data { - __u32 length; - __u16 block_descriptor_length; - __u8 medium_type; - __u8 device_specific; - __u8 header_length; - __u8 longlba:1; -}; - -extern int __scsi_mode_sense(struct scsi_request *SRpnt, int dbd, - int modepage, unsigned char *buffer, int len, - int timeout, int retries, - struct scsi_mode_data *data); - - #endif /* _SCSI_SCSI_REQUEST_H */ -- cgit v1.2.3 From 33aa687db90dd8541bd5e9a762eebf880eaee767 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 28 Aug 2005 11:31:14 -0500 Subject: [SCSI] convert SPI transport class to scsi_execute This one's slightly more difficult. The transport class uses REQ_FAILFAST, so another interface (scsi_execute) had to be invented to take the extra flag. Also, the sense functions are shifted around to allow spi_execute to place data directly into a struct scsi_sense_hdr. With this change, there's probably a lot of unnecessary sense buffer allocation going on which we can fix later. Signed-off-by: James Bottomley --- include/scsi/scsi_device.h | 13 +++++++++++++ include/scsi/scsi_eh.h | 8 ++++++++ include/scsi/scsi_request.h | 4 ---- 3 files changed, 21 insertions(+), 4 deletions(-) (limited to 'include/scsi') diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 9181068883c..5ad08b70763 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -256,6 +256,19 @@ extern void int_to_scsilun(unsigned int, struct scsi_lun *); extern const char *scsi_device_state_name(enum scsi_device_state); extern int scsi_is_sdev_device(const struct device *); extern int scsi_is_target_device(const struct device *); +extern int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, + int data_direction, void *buffer, unsigned bufflen, + unsigned char *sense, int timeout, int retries, + int flag); + +static inline int +scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, + int data_direction, void *buffer, unsigned bufflen, + unsigned char *sense, int timeout, int retries) +{ + return scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, + timeout, retries, 0); +} static inline int scsi_device_online(struct scsi_device *sdev) { return sdev->sdev_state != SDEV_OFFLINE; diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h index 80557f879e3..b24d224281b 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h @@ -26,6 +26,14 @@ struct scsi_sense_hdr { /* See SPC-3 section 4.5 */ u8 additional_length; /* always 0 for fixed sense format */ }; +static inline int scsi_sense_valid(struct scsi_sense_hdr *sshdr) +{ + if (!sshdr) + return 0; + + return (sshdr->response_code & 0x70) == 0x70; +} + extern void scsi_add_timer(struct scsi_cmnd *, int, void (*)(struct scsi_cmnd *)); diff --git a/include/scsi/scsi_request.h b/include/scsi/scsi_request.h index f5dfdfec9fe..6a140020d7c 100644 --- a/include/scsi/scsi_request.h +++ b/include/scsi/scsi_request.h @@ -54,8 +54,4 @@ extern void scsi_do_req(struct scsi_request *, const void *cmnd, void *buffer, unsigned bufflen, void (*done) (struct scsi_cmnd *), int timeout, int retries); -extern int scsi_execute_req(struct scsi_device *sdev, unsigned char *cmd, - int data_direction, void *buffer, unsigned bufflen, - unsigned char *sense, int timeout, int retries); - #endif /* _SCSI_SCSI_REQUEST_H */ -- cgit v1.2.3 From ea73a9f23906c374b697cd5b0d64f6dceced63de Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 28 Aug 2005 11:33:52 -0500 Subject: [SCSI] convert sd to scsi_execute_req (and update the scsi_execute_req API) This one removes struct scsi_request entirely from sd. In the process, I noticed we have no callers of scsi_wait_req who don't immediately normalise the sense, so I updated the API to make it take a struct scsi_sense_hdr instead of simply a big sense buffer. Signed-off-by: James Bottomley --- include/scsi/scsi_dbg.h | 2 ++ include/scsi/scsi_device.h | 14 +++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'include/scsi') diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h index 12e90934a7a..b090a11d7e1 100644 --- a/include/scsi/scsi_dbg.h +++ b/include/scsi/scsi_dbg.h @@ -3,8 +3,10 @@ struct scsi_cmnd; struct scsi_request; +struct scsi_sense_hdr; extern void scsi_print_command(struct scsi_cmnd *); +extern void scsi_print_sense_hdr(const char *, struct scsi_sense_hdr *); extern void __scsi_print_command(unsigned char *); extern void scsi_print_sense(const char *, struct scsi_cmnd *); extern void scsi_print_req_sense(const char *, struct scsi_request *); diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 5ad08b70763..da63722c012 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -9,6 +9,7 @@ struct request_queue; struct scsi_cmnd; struct scsi_lun; +struct scsi_sense_hdr; struct scsi_mode_data { __u32 length; @@ -237,7 +238,7 @@ extern int scsi_set_medium_removal(struct scsi_device *, char); extern int scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, unsigned char *buffer, int len, int timeout, int retries, struct scsi_mode_data *data, - char *sense); + struct scsi_sense_hdr *); extern int scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries); extern int scsi_device_set_state(struct scsi_device *sdev, @@ -260,15 +261,10 @@ extern int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, int data_direction, void *buffer, unsigned bufflen, unsigned char *sense, int timeout, int retries, int flag); +extern int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, + int data_direction, void *buffer, unsigned bufflen, + struct scsi_sense_hdr *, int timeout, int retries); -static inline int -scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, - int data_direction, void *buffer, unsigned bufflen, - unsigned char *sense, int timeout, int retries) -{ - return scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, - timeout, retries, 0); -} static inline int scsi_device_online(struct scsi_device *sdev) { return sdev->sdev_state != SDEV_OFFLINE; -- cgit v1.2.3 From c5478def7a3a2dba9ceda452c2aa3539514d30a9 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 6 Sep 2005 14:04:26 +0200 Subject: [SCSI] switch EH thread startup to the kthread API Signed-off-by: James Bottomley --- include/scsi/scsi_host.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include/scsi') diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index ac1b6125e3a..916144be208 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -467,12 +467,10 @@ struct Scsi_Host { struct task_struct * ehandler; /* Error recovery thread. */ struct semaphore * eh_wait; /* The error recovery thread waits on this. */ - struct completion * eh_notify; /* wait for eh to begin or end */ struct semaphore * eh_action; /* Wait for specific actions on the host. */ unsigned int eh_active:1; /* Indicates the eh thread is awake and active if this is true. */ - unsigned int eh_kill:1; /* set when killing the eh thread */ wait_queue_head_t host_wait; struct scsi_host_template *hostt; struct scsi_transport_template *transportt; -- cgit v1.2.3 From fe1b2d544d71300f8e2d151c3c77a130d13a58be Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 6 Sep 2005 14:15:37 +0200 Subject: [SCSI] unexport scsi_add_timer/scsi_delete_timer Signed-off-by: James Bottomley --- include/scsi/scsi_eh.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include/scsi') diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h index 80557f879e3..4b71095be68 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h @@ -27,9 +27,6 @@ struct scsi_sense_hdr { /* See SPC-3 section 4.5 */ }; -extern void scsi_add_timer(struct scsi_cmnd *, int, - void (*)(struct scsi_cmnd *)); -extern int scsi_delete_timer(struct scsi_cmnd *); extern void scsi_report_bus_reset(struct Scsi_Host *, int); extern void scsi_report_device_reset(struct Scsi_Host *, int, int); extern int scsi_block_when_processing_errors(struct scsi_device *); -- cgit v1.2.3