From 4fcf812ca392303aa79dd50e96e83a29faa13bd0 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 29 Jul 2011 17:26:39 -0700 Subject: [SCSI] libsas: export sas_alloc_task() Now that isci has added a 3rd open coded user of this functionality just share the libsas version. Acked-by: Jack Wang Signed-off-by: Dan Williams Signed-off-by: James Bottomley --- include/scsi/libsas.h | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'include/scsi/libsas.h') diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index ee866060f8a..2517254b840 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -555,36 +555,14 @@ struct sas_task { struct work_struct abort_work; }; -extern struct kmem_cache *sas_task_cache; - #define SAS_TASK_STATE_PENDING 1 #define SAS_TASK_STATE_DONE 2 #define SAS_TASK_STATE_ABORTED 4 #define SAS_TASK_NEED_DEV_RESET 8 #define SAS_TASK_AT_INITIATOR 16 -static inline struct sas_task *sas_alloc_task(gfp_t flags) -{ - struct sas_task *task = kmem_cache_zalloc(sas_task_cache, flags); - - if (task) { - INIT_LIST_HEAD(&task->list); - spin_lock_init(&task->task_state_lock); - task->task_state_flags = SAS_TASK_STATE_PENDING; - init_timer(&task->timer); - init_completion(&task->completion); - } - - return task; -} - -static inline void sas_free_task(struct sas_task *task) -{ - if (task) { - BUG_ON(!list_empty(&task->list)); - kmem_cache_free(sas_task_cache, task); - } -} +extern struct sas_task *sas_alloc_task(gfp_t flags); +extern void sas_free_task(struct sas_task *task); struct sas_domain_function_template { /* The class calls these to notify the LLDD of an event. */ -- cgit v1.2.3 From 8ec6552f4a77d15f446b00aed364e3c12d38aa6c Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 1 Sep 2011 21:18:20 -0700 Subject: [SCSI] libsas: sgpio write support Add SFF-8485 v0.7 / SAS-1 smp-write-gpio register support to libsas. Defer SAS-2 support unless/until it defines an sgpio interface. Minimum implementation needed to get the lights blinking. try_test_sas_gpio_gp_bit() provides a common method to parse the incoming write data (raw bitstream), and the to_sas_gpio_gp_bit() helper routine can be used as a basis for the set/clear operations for the 'read' implementation. Host implementations parse as many bits (ODx.[012]) as are locally supported and report the number of registers successfully written. If the submitted data overruns the internal number of registers available report the write as a success with the number of bytes remaining reported in ->resid_len. Example (assuming an active backplane) set the "identify" pattern for the first 21 devices: smp_write_gpio --count=2 --data=92,49,24,92,24,92,49,24 -t 4 --index=1 /dev/bsg/sas_hostX Signed-off-by: Dan Williams Signed-off-by: James Bottomley --- include/scsi/libsas.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/scsi/libsas.h') diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 2517254b840..af0a1deac93 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -405,6 +405,13 @@ static inline void sas_phy_disconnected(struct asd_sas_phy *phy) phy->linkrate = SAS_LINK_RATE_UNKNOWN; } +static inline unsigned int to_sas_gpio_od(int device, int bit) +{ + return 3 * device + bit; +} + +int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count); + /* ---------- Tasks ---------- */ /* service_response | SAS_TASK_COMPLETE | SAS_TASK_UNDELIVERED | @@ -592,6 +599,10 @@ struct sas_domain_function_template { /* Phy management */ int (*lldd_control_phy)(struct asd_sas_phy *, enum phy_func, void *); + + /* GPIO support */ + int (*lldd_write_gpio)(struct sas_ha_struct *, u8 reg_type, + u8 reg_index, u8 reg_count, u8 *write_data); }; extern int sas_register_ha(struct sas_ha_struct *); -- cgit v1.2.3 From ffaac8f45bfb2dffb78179baa5740de34058eef8 Mon Sep 17 00:00:00 2001 From: Luben Tuikov Date: Thu, 22 Sep 2011 09:41:36 -0700 Subject: [SCSI] libsas: Allow expander T-T attachments Allow expander table-to-table attachments for expanders that support it. Signed-off-by: Luben Tuikov Signed-off-by: James Bottomley --- include/scsi/libsas.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/scsi/libsas.h') diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index af0a1deac93..ac9d80c93c6 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -142,8 +142,11 @@ struct expander_device { u16 ex_change_count; u16 max_route_indexes; u8 num_phys; + + u8 t2t_supp:1; u8 configuring:1; u8 conf_route_table:1; + u8 enclosure_logical_id[8]; struct ex_phy *ex_phy; -- cgit v1.2.3 From d962480e9a061505637bb16543d49e247349e25d Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 23 Sep 2011 16:43:45 -0700 Subject: [SCSI] libsas: fix try_test_sas_gpio_gp_bit() build error If the user has disabled CONFIG_SCSI_SAS_HOST_SMP then libsas drivers will not be receiving smp-gpio frames and do not need this lookup code. Reported-by: Randy Dunlap Tested-by: Randy Dunlap Signed-off-by: Dan Williams Signed-off-by: James Bottomley --- include/scsi/libsas.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/scsi/libsas.h') diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index ac9d80c93c6..d455fa96dc8 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -413,7 +413,14 @@ static inline unsigned int to_sas_gpio_od(int device, int bit) return 3 * device + bit; } +#ifdef CONFIG_SCSI_SAS_HOST_SMP int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count); +#else +static inline int try_test_sas_gpio_gp_bit(unsigned int od, u8 *data, u8 index, u8 count) +{ + return -1; +} +#endif /* ---------- Tasks ---------- */ /* -- cgit v1.2.3 From b50102d3e9a43a75379407c2080f696f61cb286b Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 30 Sep 2011 18:52:19 -0700 Subject: [SCSI] isci: atapi support Based on original implementation from Jiangbi Liu and Maciej Trela. ATAPI transfers happen in two-to-three stages. The two stage atapi commands are those that include a dma data transfer. The data transfer portion of these operations is handled by the hardware packet-dma acceleration. The three-stage commands do not have a data transfer and are handled without hardware assistance in raw frame mode. stage1: transmit host-to-device fis to notify the device of an incoming atapi cdb. Upon reception of the pio-setup-fis repost the task_context to perform the dma transfer of the cdb+data (go to stage3), or repost the task_context to transmit the cdb as a raw frame (go to stage 2). stage2: wait for hardware notification of the cdb transmission and then go to stage 3. stage3: wait for the arrival of the terminating device-to-host fis and terminate the command. To keep the implementation simple we only support ATAPI packet-dma protocol (for commands with data) to avoid needing to handle the data transfer manually (like we do for SATA-PIO). This may affect compatibility for a small number of devices (see ATA_HORKAGE_ATAPI_MOD16_DMA). If the data-transfer underruns, or encounters an error the device-to-host fis is expected to arrive in the unsolicited frame queue to pass to libata for disposition. However, in the DONE_UNEXP_FIS (data underrun) case it appears we need to craft a response. In the DONE_REG_ERR case we do receive the UF and propagate it to libsas. Signed-off-by: Maciej Trela Signed-off-by: Dan Williams Signed-off-by: James Bottomley --- include/scsi/libsas.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/scsi/libsas.h') diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index d455fa96dc8..c4b7cd0b85e 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -389,6 +389,11 @@ sdev_to_domain_dev(struct scsi_device *sdev) { return starget_to_domain_dev(sdev->sdev_target); } +static inline struct ata_device *sas_to_ata_dev(struct domain_device *dev) +{ + return &dev->sata_dev.ap->link.device[0]; +} + static inline struct domain_device * cmd_to_domain_dev(struct scsi_cmnd *cmd) { -- cgit v1.2.3 From 1a34c0640137eed8dabdac3a68a7a84116ac9e0d Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 21 Sep 2011 22:05:34 -0700 Subject: [SCSI] libsas: fix port->dev_list locking port->dev_list maintains a list of devices attached to a given sas root port. It needs to be mutated under a lock as contexts outside of the single-threaded-libsas-workqueue access the list via sas_find_dev_by_rphy(). Fixup locations where the list was being mutated without a lock. This is a follow-up to commit 5911e963 "[SCSI] libsas: remove expander from dev list on error", where Luben noted [1]: > 2/ We have unlocked list manipulations in sas_ex_discover_end_dev(), > sas_unregister_common_dev(), and sas_ex_discover_end_dev() Yes, I can see that and that is very unfortunate. [1]: http://marc.info/?l=linux-scsi&m=131480962006471&w=2 Signed-off-by: Dan Williams Signed-off-by: James Bottomley --- include/scsi/libsas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/scsi/libsas.h') diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index c4b7cd0b85e..6a308d42d98 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -656,7 +656,7 @@ int sas_discover_event(struct asd_sas_port *, enum discover_event ev); int sas_discover_sata(struct domain_device *); int sas_discover_end_dev(struct domain_device *); -void sas_unregister_dev(struct domain_device *); +void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *); void sas_init_dev(struct domain_device *); -- cgit v1.2.3