[PATCH 2/2] ufs: don't stop controller before scsi_remove_host()

2013-07-08 Thread Akinobu Mita
scsi_remove_host() sends SYNCHRONIZE CACHE commands for write cache
enabled scsi disk devices.  So stopping controller working shouldn't
be done before scsi_remove_host().

Signed-off-by: Akinobu Mita m...@fixstars.com
Cc: Vinayak Holikatti vinholika...@gmail.com
Cc: Santosh Y santos...@gmail.com
Cc: James E.J. Bottomley jbottom...@parallels.com
Cc: linux-scsi@vger.kernel.org
---
 drivers/scsi/ufs/ufshcd-pci.c| 1 -
 drivers/scsi/ufs/ufshcd-pltfrm.c | 1 -
 drivers/scsi/ufs/ufshcd.c| 3 ++-
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
index c34efb9..91a2e79 100644
--- a/drivers/scsi/ufs/ufshcd-pci.c
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -91,7 +91,6 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
 {
struct ufs_hba *hba = pci_get_drvdata(pdev);
 
-   disable_irq(pdev-irq);
ufshcd_remove(hba);
pci_set_drvdata(pdev, NULL);
 }
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index c42db40..94ba40c 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -144,7 +144,6 @@ static int ufshcd_pltfrm_remove(struct platform_device 
*pdev)
 {
struct ufs_hba *hba =  platform_get_drvdata(pdev);
 
-   disable_irq(hba-irq);
ufshcd_remove(hba);
return 0;
 }
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index cfa9633..f2832b8 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1657,11 +1657,12 @@ EXPORT_SYMBOL_GPL(ufshcd_resume);
  */
 void ufshcd_remove(struct ufs_hba *hba)
 {
+   scsi_remove_host(hba-host);
/* disable interrupts */
+   disable_irq(hba-irq);
ufshcd_disable_intr(hba, hba-intr_mask);
ufshcd_hba_stop(hba);
 
-   scsi_remove_host(hba-host);
scsi_host_put(hba-host);
 }
 EXPORT_SYMBOL_GPL(ufshcd_remove);
-- 
1.8.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] ufshcd-pci: release ioremapped region during removing driver

2013-07-08 Thread Akinobu Mita
Before commit 2953f850c3b80bdca004967c83733365d8aa0aa2 ([SCSI] ufs:
use devres functions for ufshcd), UFSHCI register was ioremapped by
each glue-driver (ufshcd-pltfrm and ufshcd-pci) during probing and it
was iounmapped by core-driver during removing driver.  The commit
converted ufshcd-pltfrm to use devres functions, but it didn't convert
ufshcd-pci.

Therefore, the change causes ufshcd-pci driver not to iounmap UFSHCI
register region during removing driver.  This fixes it by converting
ufshcd-pci to use devres functions.

Signed-off-by: Akinobu Mita m...@fixstars.com
Cc: Seungwon Jeon tgih@samsung.com
Cc: Vinayak Holikatti vinholika...@gmail.com
Cc: Santosh Y santos...@gmail.com
Cc: James E.J. Bottomley jbottom...@parallels.com
Cc: linux-scsi@vger.kernel.org
---
 drivers/scsi/ufs/ufshcd-pci.c | 35 ---
 1 file changed, 8 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
index 64d36eb..c34efb9 100644
--- a/drivers/scsi/ufs/ufshcd-pci.c
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -93,10 +93,7 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
 
disable_irq(pdev-irq);
ufshcd_remove(hba);
-   pci_release_regions(pdev);
pci_set_drvdata(pdev, NULL);
-   pci_clear_master(pdev);
-   pci_disable_device(pdev);
 }
 
 /**
@@ -113,47 +110,31 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
void __iomem *mmio_base;
int err;
 
-   err = pci_enable_device(pdev);
+   err = pcim_enable_device(pdev);
if (err) {
-   dev_err(pdev-dev, pci_enable_device failed\n);
-   goto out_error;
+   dev_err(pdev-dev, pcim_enable_device failed\n);
+   return err;
}
 
pci_set_master(pdev);
 
-
-   err = pci_request_regions(pdev, UFSHCD);
+   err = pcim_iomap_regions(pdev, 1  0, UFSHCD);
if (err  0) {
-   dev_err(pdev-dev, request regions failed\n);
-   goto out_disable;
+   dev_err(pdev-dev, request and iomap failed\n);
+   return err;
}
 
-   mmio_base = pci_ioremap_bar(pdev, 0);
-   if (!mmio_base) {
-   dev_err(pdev-dev, memory map failed\n);
-   err = -ENOMEM;
-   goto out_release_regions;
-   }
+   mmio_base = pcim_iomap_table(pdev)[0];
 
err = ufshcd_init(pdev-dev, hba, mmio_base, pdev-irq);
if (err) {
dev_err(pdev-dev, Initialization failed\n);
-   goto out_iounmap;
+   return err;
}
 
pci_set_drvdata(pdev, hba);
 
return 0;
-
-out_iounmap:
-   iounmap(mmio_base);
-out_release_regions:
-   pci_release_regions(pdev);
-out_disable:
-   pci_clear_master(pdev);
-   pci_disable_device(pdev);
-out_error:
-   return err;
 }
 
 static DEFINE_PCI_DEVICE_TABLE(ufshcd_pci_tbl) = {
-- 
1.8.1.4

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/7] qla4xxx: Export more firmware info in sysfs

2013-07-08 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/qla4xxx/ql4_attr.c |   86 ++-
 drivers/scsi/qla4xxx/ql4_def.h  |9 +---
 drivers/scsi/qla4xxx/ql4_fw.h   |2 +-
 drivers/scsi/qla4xxx/ql4_mbx.c  |   33 ++-
 drivers/scsi/qla4xxx/ql4_os.c   |4 +-
 5 files changed, 105 insertions(+), 29 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_attr.c b/drivers/scsi/qla4xxx/ql4_attr.c
index 19ee55a..687c07f 100644
--- a/drivers/scsi/qla4xxx/ql4_attr.c
+++ b/drivers/scsi/qla4xxx/ql4_attr.c
@@ -158,14 +158,12 @@ qla4xxx_fw_version_show(struct device *dev,
 
if (is_qla80XX(ha))
return snprintf(buf, PAGE_SIZE, %d.%02d.%02d (%x)\n,
-   ha-firmware_version[0],
-   ha-firmware_version[1],
-   ha-patch_number, ha-build_number);
+   ha-fw_info.fw_major, ha-fw_info.fw_minor,
+   ha-fw_info.fw_patch, ha-fw_info.fw_build);
else
return snprintf(buf, PAGE_SIZE, %d.%02d.%02d.%02d\n,
-   ha-firmware_version[0],
-   ha-firmware_version[1],
-   ha-patch_number, ha-build_number);
+   ha-fw_info.fw_major, ha-fw_info.fw_minor,
+   ha-fw_info.fw_patch, ha-fw_info.fw_build);
 }
 
 static ssize_t
@@ -181,8 +179,8 @@ qla4xxx_iscsi_version_show(struct device *dev, struct 
device_attribute *attr,
   char *buf)
 {
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
-   return snprintf(buf, PAGE_SIZE, %d.%02d\n, ha-iscsi_major,
-   ha-iscsi_minor);
+   return snprintf(buf, PAGE_SIZE, %d.%02d\n, ha-fw_info.iscsi_major,
+   ha-fw_info.iscsi_minor);
 }
 
 static ssize_t
@@ -191,8 +189,8 @@ qla4xxx_optrom_version_show(struct device *dev, struct 
device_attribute *attr,
 {
struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
return snprintf(buf, PAGE_SIZE, %d.%02d.%02d.%02d\n,
-   ha-bootload_major, ha-bootload_minor,
-   ha-bootload_patch, ha-bootload_build);
+   ha-fw_info.bootload_major, ha-fw_info.bootload_minor,
+   ha-fw_info.bootload_patch, ha-fw_info.bootload_build);
 }
 
 static ssize_t
@@ -259,6 +257,63 @@ qla4xxx_hba_model_show(struct device *dev, struct 
device_attribute *attr,
return snprintf(buf, PAGE_SIZE, %s\n, ha-model_name);
 }
 
+static ssize_t
+qla4xxx_fw_timestamp_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+   struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
+   return snprintf(buf, PAGE_SIZE, %s %s\n, ha-fw_info.fw_build_date,
+   ha-fw_info.fw_build_time);
+}
+
+static ssize_t
+qla4xxx_fw_build_user_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
+   return snprintf(buf, PAGE_SIZE, %s\n, ha-fw_info.fw_build_user);
+}
+
+static ssize_t
+qla4xxx_fw_ext_timestamp_show(struct device *dev, struct device_attribute 
*attr,
+ char *buf)
+{
+   struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
+   return snprintf(buf, PAGE_SIZE, %s\n, ha-fw_info.extended_timestamp);
+}
+
+static ssize_t
+qla4xxx_fw_load_src_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
+   char *load_src = NULL;
+
+   switch (ha-fw_info.fw_load_source) {
+   case 1:
+   load_src = Flash Primary;
+   break;
+   case 2:
+   load_src = Flash Secondary;
+   break;
+   case 3:
+   load_src = Host Download;
+   break;
+   }
+
+   return snprintf(buf, PAGE_SIZE, %s\n, load_src);
+}
+
+static ssize_t
+qla4xxx_fw_uptime_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
+   qla4xxx_about_firmware(ha);
+   return snprintf(buf, PAGE_SIZE, %u.%u secs\n, ha-fw_uptime_secs,
+   ha-fw_uptime_msecs);
+}
+
 static DEVICE_ATTR(fw_version, S_IRUGO, qla4xxx_fw_version_show, NULL);
 static DEVICE_ATTR(serial_num, S_IRUGO, qla4xxx_serial_num_show, NULL);
 static DEVICE_ATTR(iscsi_version, S_IRUGO, qla4xxx_iscsi_version_show, NULL);
@@ -269,6 +324,12 @@ static DEVICE_ATTR(phy_port_cnt, S_IRUGO, 
qla4xxx_phy_port_cnt_show, NULL);
 static 

[PATCH 2/7] qla4xxx: Use discovery_parent_idx instead of discovery_parent_type

2013-07-08 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

While setting the values for DDB, discovery_parent_idx needs to be used
instead of discovery_parent_type.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/qla4xxx/ql4_os.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index ee2f903..9b25b8c 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -2262,7 +2262,7 @@ static int qla4xxx_copy_to_fwddb_param(struct 
iscsi_bus_flash_session *sess,
fw_ddb_entry-lcl_port = cpu_to_le16(conn-local_port);
fw_ddb_entry-stat_sn = cpu_to_le32(conn-statsn);
fw_ddb_entry-exp_stat_sn = cpu_to_le32(conn-exp_statsn);
-   fw_ddb_entry-ddb_link = cpu_to_le16(sess-discovery_parent_type);
+   fw_ddb_entry-ddb_link = cpu_to_le16(sess-discovery_parent_idx);
fw_ddb_entry-chap_tbl_idx = cpu_to_le16(sess-chap_out_idx);
fw_ddb_entry-tsid = cpu_to_le16(sess-tsid);
fw_ddb_entry-port = cpu_to_le16(conn-port);
@@ -6654,8 +6654,8 @@ qla4xxx_sysfs_ddb_set_param(struct 
iscsi_bus_flash_session *fnode_sess,
memcpy(fnode_conn-link_local_ipv6_addr,
   fnode_param-value, IPv6_ADDR_LEN);
break;
-   case ISCSI_FLASHNODE_DISCOVERY_PARENT_TYPE:
-   fnode_sess-discovery_parent_type =
+   case ISCSI_FLASHNODE_DISCOVERY_PARENT_IDX:
+   fnode_sess-discovery_parent_idx =
*(uint16_t *)fnode_param-value;
break;
case ISCSI_FLASHNODE_TCP_XMIT_WSF:
-- 
1.7.1


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/7] qla4xxx: Update driver version to 5.03.00-k11

2013-07-08 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/qla4xxx/ql4_version.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_version.h 
b/drivers/scsi/qla4xxx/ql4_version.h
index c5edd0d..c085c9a 100644
--- a/drivers/scsi/qla4xxx/ql4_version.h
+++ b/drivers/scsi/qla4xxx/ql4_version.h
@@ -5,4 +5,4 @@
  * See LICENSE.qla4xxx for copyright and licensing details.
  */
 
-#define QLA4XXX_DRIVER_VERSION 5.03.00-k10
+#define QLA4XXX_DRIVER_VERSION 5.03.00-k11
-- 
1.7.1


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/7] qla4xxx: Allow removal of failed session using logout.

2013-07-08 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

If logout is performed on a failed session entry then that session
should be gracefully removed.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/qla4xxx/ql4_def.h |1 +
 drivers/scsi/qla4xxx/ql4_os.c  |   48 +--
 2 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index ddf16a8..50dc0c7 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -335,6 +335,7 @@ struct ql4_tuple_ddb {
 #define DF_BOOT_TGT1   /* Boot target entry */
 #define DF_ISNS_DISCOVERED 2   /* Device was discovered via iSNS */
 #define DF_FO_MASKED   3
+#define DF_DISABLE_RELOGIN 4   /* Disable relogin to device */
 
 enum qla4_work_type {
QLA4_EVENT_AEN,
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 84d9361..ee2f903 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -3583,7 +3583,9 @@ static void qla4xxx_relogin_devices(struct 
iscsi_cls_session *cls_session)
} else {
/* Trigger relogin */
if (ddb_entry-ddb_type == FLASH_DDB) {
-   if (!test_bit(DF_RELOGIN, ddb_entry-flags))
+   if (!(test_bit(DF_RELOGIN, ddb_entry-flags) ||
+ test_bit(DF_DISABLE_RELOGIN,
+  ddb_entry-flags)))
qla4xxx_arm_relogin_timer(ddb_entry);
} else
iscsi_session_failure(cls_session-dd_data,
@@ -3686,6 +3688,9 @@ static void qla4xxx_dpc_relogin(struct iscsi_cls_session 
*cls_sess)
if (!(ddb_entry-ddb_type == FLASH_DDB))
return;
 
+   if (test_bit(DF_DISABLE_RELOGIN, ddb_entry-flags))
+   return;
+
if (test_and_clear_bit(DF_RELOGIN, ddb_entry-flags) 
!iscsi_is_session_online(cls_sess)) {
DEBUG2(ql4_printk(KERN_INFO, ha,
@@ -6014,13 +6019,6 @@ static int qla4xxx_sysfs_ddb_logout_sid(struct 
iscsi_cls_session *cls_sess)
goto exit_ddb_logout;
}
 
-   options = LOGOUT_OPTION_CLOSE_SESSION;
-   if (qla4xxx_session_logout_ddb(ha, ddb_entry, options) == QLA_ERROR) {
-   ql4_printk(KERN_ERR, ha, %s: Logout failed\n, __func__);
-   ret = -EIO;
-   goto exit_ddb_logout;
-   }
-
fw_ddb_entry = dma_alloc_coherent(ha-pdev-dev, sizeof(*fw_ddb_entry),
  fw_ddb_entry_dma, GFP_KERNEL);
if (!fw_ddb_entry) {
@@ -6030,6 +6028,38 @@ static int qla4xxx_sysfs_ddb_logout_sid(struct 
iscsi_cls_session *cls_sess)
goto exit_ddb_logout;
}
 
+   if (test_and_set_bit(DF_DISABLE_RELOGIN, ddb_entry-flags))
+   goto ddb_logout_init;
+
+   ret = qla4xxx_get_fwddb_entry(ha, ddb_entry-fw_ddb_index,
+ fw_ddb_entry, fw_ddb_entry_dma,
+ NULL, NULL, ddb_state, NULL,
+ NULL, NULL);
+   if (ret == QLA_ERROR)
+   goto ddb_logout_init;
+
+   if (ddb_state == DDB_DS_SESSION_ACTIVE)
+   goto ddb_logout_init;
+
+   /* wait until next relogin is triggered using DF_RELOGIN and
+* clear DF_RELOGIN to avoid invocation of further relogin
+*/
+   wtime = jiffies + (HZ * RELOGIN_TOV);
+   do {
+   if (test_and_clear_bit(DF_RELOGIN, ddb_entry-flags))
+   goto ddb_logout_init;
+
+   schedule_timeout_uninterruptible(HZ);
+   } while ((time_after(wtime, jiffies)));
+
+ddb_logout_init:
+   atomic_set(ddb_entry-retry_relogin_timer, INVALID_ENTRY);
+   atomic_set(ddb_entry-relogin_timer, 0);
+
+   options = LOGOUT_OPTION_CLOSE_SESSION;
+   qla4xxx_session_logout_ddb(ha, ddb_entry, options);
+
+   memset(fw_ddb_entry, 0, sizeof(*fw_ddb_entry));
wtime = jiffies + (HZ * LOGOUT_TOV);
do {
ret = qla4xxx_get_fwddb_entry(ha, ddb_entry-fw_ddb_index,
@@ -6059,10 +6089,12 @@ ddb_logout_clr_sess:
 
spin_lock_irqsave(ha-hardware_lock, flags);
qla4xxx_free_ddb(ha, ddb_entry);
+   clear_bit(ddb_entry-fw_ddb_index, ha-ddb_idx_map);
spin_unlock_irqrestore(ha-hardware_lock, flags);
 
iscsi_session_teardown(ddb_entry-sess);
 
+   clear_bit(DF_DISABLE_RELOGIN, ddb_entry-flags);
ret = QLA_SUCCESS;
 
 exit_ddb_logout:
-- 
1.7.1


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  

[PATCH 3/7] qla4xxx: Set IPv6 traffic class if device type is IPv6.

2013-07-08 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/qla4xxx/ql4_os.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 9b25b8c..85762f7 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -2256,7 +2256,6 @@ static int qla4xxx_copy_to_fwddb_param(struct 
iscsi_bus_flash_session *sess,
fw_ddb_entry-mss = cpu_to_le16(conn-max_segment_size);
fw_ddb_entry-tcp_xmt_wsf = (uint8_t) cpu_to_le32(conn-tcp_xmit_wsf);
fw_ddb_entry-tcp_rcv_wsf = (uint8_t) cpu_to_le32(conn-tcp_recv_wsf);
-   fw_ddb_entry-ipv4_tos = conn-ipv4_tos;
fw_ddb_entry-ipv6_flow_lbl = cpu_to_le16(conn-ipv6_flow_label);
fw_ddb_entry-ka_timeout = cpu_to_le16(conn-keepalive_timeout);
fw_ddb_entry-lcl_port = cpu_to_le16(conn-local_port);
@@ -2269,6 +2268,11 @@ static int qla4xxx_copy_to_fwddb_param(struct 
iscsi_bus_flash_session *sess,
fw_ddb_entry-def_timeout =
cpu_to_le16(sess-default_taskmgmt_timeout);
 
+   if (!strncmp(sess-portal_type, PORTAL_TYPE_IPV6, 4))
+   fw_ddb_entry-ipv4_tos = conn-ipv6_traffic_class;
+   else
+   fw_ddb_entry-ipv4_tos = conn-ipv4_tos;
+
if (conn-ipaddress)
memcpy(fw_ddb_entry-ip_addr, conn-ipaddress,
   sizeof(fw_ddb_entry-ip_addr));
-- 
1.7.1


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/7] qla4xxx: discovery_parent_idx can be shown without any check.

2013-07-08 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/qla4xxx/ql4_os.c |7 ++-
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 85762f7..a6e4d51 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -6235,7 +6235,7 @@ qla4xxx_sysfs_ddb_get_param(struct 
iscsi_bus_flash_session *fnode_sess,
struct iscsi_bus_flash_conn *fnode_conn;
struct ql4_chap_table chap_tbl;
struct device *dev;
-   int parent_type, parent_index = 0x;
+   int parent_type;
int rc = 0;
 
dev = iscsi_find_flashnode_conn(fnode_sess);
@@ -6401,10 +6401,7 @@ qla4xxx_sysfs_ddb_get_param(struct 
iscsi_bus_flash_session *fnode_sess,
rc = sprintf(buf, \n);
break;
case ISCSI_FLASHNODE_DISCOVERY_PARENT_IDX:
-   if (fnode_sess-discovery_parent_idx  MAX_DDB_ENTRIES)
-   parent_index = fnode_sess-discovery_parent_idx;
-
-   rc = sprintf(buf, %u\n, parent_index);
+   rc = sprintf(buf, %u\n, fnode_sess-discovery_parent_idx);
break;
case ISCSI_FLASHNODE_DISCOVERY_PARENT_TYPE:
if (fnode_sess-discovery_parent_type == DDB_ISNS)
-- 
1.7.1


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/7] qla4xxx: Only BIOS boot target entries should be at index 0 and 1.

2013-07-08 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

Flash target index 0 and 1 are reserved for boot target entries created
with BIOS utility.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/qla4xxx/ql4_os.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index a6e4d51..52d01ae 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -5707,7 +5707,8 @@ static int qla4xxx_sysfs_ddb_add(struct Scsi_Host *shost, 
const char *buf,
goto exit_ddb_add;
}
 
-   for (idx = 0; idx  max_ddbs; idx++) {
+   /* Index 0 and 1 are reserved for boot target entries */
+   for (idx = 2; idx  max_ddbs; idx++) {
if (qla4xxx_flashdb_by_index(ha, fw_ddb_entry,
 fw_ddb_entry_dma, idx))
break;
-- 
1.7.1


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/7] qla4xxx: Updates for scsi misc branch

2013-07-08 Thread adheer.chandravanshi
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

James,

Please apply the following patches to the scsi tree at your earliest
convenience.

Adheer Chandravanshi (7):
qla4xxx: Allow removal of failed session using logout.
qla4xxx: Use discovery_parent_idx instead of discovery_parent_type
qla4xxx: Set IPv6 traffic class if device type is IPv6.
qla4xxx: discovery_parent_idx can be shown without any check.
qla4xxx: Only BIOS boot target entries should be at index 0 and 1.
qla4xxx: Export more firmware info in sysfs
qla4xxx: Update driver version to 5.03.00-k11

Thanks,
Adheer

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 07/13] scsi_transport_srp: Add transport layer error handling

2013-07-08 Thread Vu Pham


  

Though, now that I've unpacked it -- I don't think it is OK for
dev_loss_tmo to be off, but fast IO to be on? That drops another
conditional.
  
The combination of dev_loss_tmo off and reconnect_delay  0 worked fine 
in my tests. An I/O failure was detected shortly after the cable to the 
target was pulled. I/O resumed shortly after the cable to the target was 
reinserted.



Perhaps I don't understand your answer -- I'm asking about dev_loss_tmo
 0, and fast_io_fail_tmo = 0. The other transports do not allow this
scenario, and I'm asking if it makes sense for SRP to allow it.

But now that you mention reconnect_delay, what is the meaning of that
when it is negative? That's not in the documentation. And should it be
considered in srp_tmo_valid() -- are there values of reconnect_delay
that cause problems?

I'm starting to get a bit concerned about this patch -- can you, Vu, and
Sebastian comment on the testing you have done?

  

Hello Bart,

After running cable pull test on two local IB links for several hrs, 
I/Os got stuck.

Further commands multipath -ll or fdisk -l got stuck and never return
Here are the stack dump for srp-x kernel threads.
I'll run with #DEBUG to get more debug info on scsi host  rport

-vu


srp_threads.txt.tgz
Description: application/compressed


Re: [PATCH v3 07/13] scsi_transport_srp: Add transport layer error handling

2013-07-08 Thread Bart Van Assche
On 07/08/13 19:26, Vu Pham wrote:
 After running cable pull test on two local IB links for several hrs, 
 I/Os got stuck.
 Further commands multipath -ll or fdisk -l got stuck and never return
 Here are the stack dump for srp-x kernel threads.
 I'll run with #DEBUG to get more debug info on scsi host  rport

Hello Vu,

I had a quick look at the stack dump that was attached to your e-mail.
It shows that scsi_execute_req() hangs in blk_execute_rq(). It would be
appreciated if you could continue your tests with the kernel patch below
applied on top of v3 of this patch series. This patch should avoid that
a transport layer error that occurs after device removal has started can
cause the SCSI device state to change into blocked. This patch also
causes such TL errors to fail I/O quickly (scsi_host_alloc() zero-
initializes the memory it allocates so no explicit initialization of the
deleted variable is necessary).

Thanks,

Bart.

diff --git a/drivers/scsi/scsi_transport_srp.c 
b/drivers/scsi/scsi_transport_srp.c
index 1b9ebd5..1bb7c63 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -522,6 +522,12 @@ void srp_start_tl_fail_timers(struct srp_rport *rport)
int fast_io_fail_tmo, dev_loss_tmo, delay;
 
mutex_lock(rport-mutex);
+   if (rport-deleted) {
+   srp_rport_set_state(rport, SRP_RPORT_FAIL_FAST);
+   scsi_target_unblock(shost-shost_gendev,
+   SDEV_TRANSPORT_OFFLINE);
+   goto unlock;
+   }
delay = rport-reconnect_delay;
fast_io_fail_tmo = rport-fast_io_fail_tmo;
dev_loss_tmo = rport-dev_loss_tmo;
@@ -542,6 +548,7 @@ void srp_start_tl_fail_timers(struct srp_rport *rport)
if (dev_loss_tmo = 0)
queue_delayed_work(system_long_wq, rport-dev_loss_work,
   1UL * dev_loss_tmo * HZ);
+unlock:
mutex_unlock(rport-mutex);
 }
 EXPORT_SYMBOL(srp_start_tl_fail_timers);
@@ -730,6 +737,7 @@ void srp_rport_del(struct srp_rport *rport)
mutex_lock(rport-mutex);
if (rport-state == SRP_RPORT_BLOCKED)
__rport_fast_io_fail_timedout(rport);
+   rport-deleted = true;
mutex_unlock(rport-mutex);
 
put_device(dev);
diff --git a/include/scsi/scsi_transport_srp.h 
b/include/scsi/scsi_transport_srp.h
index fbcc985..a4addcf 100644
--- a/include/scsi/scsi_transport_srp.h
+++ b/include/scsi/scsi_transport_srp.h
@@ -54,6 +54,7 @@ struct srp_rport {
int dev_loss_tmo;
struct delayed_work fast_io_fail_work;
struct delayed_work dev_loss_work;
+   booldeleted;
 };
 
 struct srp_function_template {

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 07/13] scsi_transport_srp: Add transport layer error handling

2013-07-08 Thread David Dillow
On Thu, 2013-07-04 at 10:01 +0200, Bart Van Assche wrote:
 On 07/03/13 20:57, David Dillow wrote:
  And I'm getting the strong sense that the answer to my question about
  fast_io_fail_tmo = 0 when dev_loss_tmo is that we should not allow that
  combination, even if it doesn't break the kernel. If it doesn't make
  sense, there is no reason to create an opportunity for user confusion.
 
 Let's take a step back. I think we agree that the only combinations of 
 timeout parameters that are useful are those combinations that guarantee 
 that SCSI commands will be finished in a reasonable time and also that 
 allow multipath to detect failed paths. The first requirement comes down 
 to limiting the value fast_io_fail_tmo can be set to. The second 
 requirement means that either reconnect_delay or fast_io_fail_tmo must 
 be set (please note that a reconnect failure changes the state of all 
 involved SCSI devices into SDEV_TRANSPORT_OFFLINE). So how about 
 modifying srp_tmo_valid() as follows:
 * Add an argument called reconnect_delay.
 * Add the following code in that function:
  if (reconnect_delay  0  fast_io_fail_tmo  0  dev_loss_tmo  0)
  return -EINVAL;

I think this sounds reasonable; I need to make sure I understand the new
behaviors of the code to be sure.

I'm also concerned about Vu's bug report at this late stage; I'll be
watching for its resolution -- hopefully in time for inclusion.

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Variety of small usb disks reporting media absent

2013-07-08 Thread peter grne
The linux OS is used in our product with a variety of small USB drives
for storing scratch information.

For a range of kernels, we have found that a number of drives from
various manufacturers have failed in our field product, though working
in our development environment, with identical equipment and kernel,
but different user space and kernel configuration.

Upon investigation, I found that although the device was present in
/sys/block/sdN/device, it was not present in /proc/partitions. No
error messages were found.

Using printk and comparing working and failing units, the problem
appears to be in sd_spinup_disk in drivers/scsi/sd.c
The failing scsi drives were initially reporting media-not-present
and the whole disk registration procedure was failing.

I fixed this by waiting up to 500 milliseconds before accepting a
media-not-present.

I do not know if this is proper scsi behavior by the disks or what. As
I am not sure this is a bug, I have not reported it to bugzilla. I
would not advise commiting my code to the linux kernel, as a better
solution is probable. Nevertheless, I enclose the patch below in order
to demonstrate the modification made to address this issue.

This problem did not result from any difference in configuration, but
more probably different timing in the development environment as
compared to our field product. Whether the development environment is
quicker or slower, I do not know.

I have plenty of samples and could easily post one or more failing
units to any person.

--- ../linux-3.9.2.orig/drivers/scsi/sd.c   2013-05-12 00:19:28.0 
+1000
+++ linux-3.9.2/drivers/scsi/sd.c   2013-07-05 15:21:17.0 +1000
@@ -1300,39 +1300,49 @@ static void set_media_not_present(struct
 {
if (sdkp-media_present)
sdkp-device-changed = 1;

if (sdkp-device-removable) {
sdkp-media_present = 0;
sdkp-capacity = 0;
}
 }

-static int media_not_present(struct scsi_disk *sdkp,
+static int check_media_not_present(struct scsi_disk *sdkp,
 struct scsi_sense_hdr *sshdr)
 {
if (!scsi_sense_valid(sshdr))
return 0;

/* not invoked for commands that could return deferred errors */
switch (sshdr-sense_key) {
case UNIT_ATTENTION:
case NOT_READY:
/* medium not present */
if (sshdr-asc == 0x3A) {
-   set_media_not_present(sdkp);
return 1;
}
}
return 0;
 }

+static int media_not_present(struct scsi_disk *sdkp,
+struct scsi_sense_hdr *sshdr)
+{
+   if(check_media_not_present(sdkp, sshdr))
+   {
+   set_media_not_present(sdkp);
+   return 1;
+   }
+   return 0;
+}
+
 /**
  * sd_check_events - check media events
  * @disk: kernel device descriptor
  * @clearing: disk events currently being cleared
  *
  * Returns mask of DISK_EVENT_*.
  *
  * Note: this function is invoked from the block subsystem.
  **/
 static unsigned int sd_check_events(struct gendisk *disk, unsigned
int clearing)
@@ -1736,27 +1746,35 @@ sd_spinup_disk(struct scsi_disk *sdkp)
int sense_valid = 0;

spintime = 0;

/* Spin up drives, as required.  Only do this at boot time */
/* Spinup needs to be done for module loads too. */
do {
retries = 0;

do {
-   cmd[0] = TEST_UNIT_READY;
-   memset((void *) cmd[1], 0, 9);
-
-   the_result = scsi_execute_req(sdkp-device, cmd,
- DMA_NONE, NULL, 0,
- sshdr, SD_TIMEOUT,
- SD_MAX_RETRIES, NULL);
+   /* Try for at least 500 milliseconds before reporting 
no media present. */
+   /* Logically, the_result would be expected to be true 
for media absent,
+* but try to minimally change the original logic, for 
consistency sake.
+*/
+   unsigned long jlimit = 
msecs_to_jiffies(jiffies_to_msecs(jiffies) + 500);
+   do {
+   cmd[0] = TEST_UNIT_READY;
+   memset((void *) cmd[1], 0, 9);
+
+   the_result = scsi_execute_req(sdkp-device, cmd,
+ DMA_NONE, NULL, 0,
+ sshdr, 
SD_TIMEOUT,
+ SD_MAX_RETRIES, 
NULL);
+   }
+   while(check_media_not_present(sdkp, sshdr) 
time_is_after_jiffies(jlimit));

/*
 * If the