[PATCH v1 1/1] cciss: replace custom function to hexdump

2016-05-06 Thread Andy Shevchenko
For small buffers we may use %*ph[N] specifier, for the bigger blocks
print_hex_dump() call.

Cc: Christoph Hellwig 
Signed-off-by: Andy Shevchenko 
---
 drivers/block/cciss_scsi.c | 72 +++---
 1 file changed, 10 insertions(+), 62 deletions(-)

diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index 1537302..8988131 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -260,43 +260,6 @@ scsi_cmd_stack_free(ctlr_info_t *h)
 }
 
 #if 0
-static int xmargin=8;
-static int amargin=60;
-
-static void
-print_bytes (unsigned char *c, int len, int hex, int ascii)
-{
-
-   int i;
-   unsigned char *x;
-
-   if (hex)
-   {
-   x = c;
-   for (i=0;i0) printk("\n");
-   if ((i % xmargin) == 0) printk("0x%04x:", i);
-   printk(" %02x", *x);
-   x++;
-   }
-   printk("\n");
-   }
-   if (ascii)
-   {
-   x = c;
-   for (i=0;i0) printk("\n");
-   if ((i % amargin) == 0) printk("0x%04x:", i);
-   if (*x > 26 && *x < 128) printk("%c", *x);
-   else printk(".");
-   x++;
-   }
-   printk("\n");
-   }
-}
-
 static void
 print_cmd(CommandList_struct *cp)
 {
@@ -305,30 +268,13 @@ print_cmd(CommandList_struct *cp)
printk("sgtot:%d\n", cp->Header.SGTotal);
printk("Tag:0x%08x/0x%08x\n", cp->Header.Tag.upper, 
cp->Header.Tag.lower);
-   printk("LUN:0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
-   cp->Header.LUN.LunAddrBytes[0],
-   cp->Header.LUN.LunAddrBytes[1],
-   cp->Header.LUN.LunAddrBytes[2],
-   cp->Header.LUN.LunAddrBytes[3],
-   cp->Header.LUN.LunAddrBytes[4],
-   cp->Header.LUN.LunAddrBytes[5],
-   cp->Header.LUN.LunAddrBytes[6],
-   cp->Header.LUN.LunAddrBytes[7]);
+   printk("LUN:0x%8phN\n", cp->Header.LUN.LunAddrBytes);
printk("CDBLen:%d\n", cp->Request.CDBLen);
printk("Type:%d\n",cp->Request.Type.Type);
printk("Attr:%d\n",cp->Request.Type.Attribute);
printk(" Dir:%d\n",cp->Request.Type.Direction);
printk("Timeout:%d\n",cp->Request.Timeout);
-   printk( "CDB: %02x %02x %02x %02x %02x %02x %02x %02x"
-   " %02x %02x %02x %02x %02x %02x %02x %02x\n",
-   cp->Request.CDB[0], cp->Request.CDB[1],
-   cp->Request.CDB[2], cp->Request.CDB[3],
-   cp->Request.CDB[4], cp->Request.CDB[5],
-   cp->Request.CDB[6], cp->Request.CDB[7],
-   cp->Request.CDB[8], cp->Request.CDB[9],
-   cp->Request.CDB[10], cp->Request.CDB[11],
-   cp->Request.CDB[12], cp->Request.CDB[13],
-   cp->Request.CDB[14], cp->Request.CDB[15]),
+   printk( "CDB: %16ph\n", cp->Request.CDB);
printk("edesc.Addr: 0x%08x/0%08x, Len  = %d\n", 
cp->ErrDesc.Addr.upper, cp->ErrDesc.Addr.lower, 
cp->ErrDesc.Len);
@@ -340,9 +286,7 @@ print_cmd(CommandList_struct *cp)
printk("offense size:%d\n", 
cp->err_info->MoreErrInfo.Invalid_Cmd.offense_size);
printk("offense byte:%d\n", 
cp->err_info->MoreErrInfo.Invalid_Cmd.offense_num);
printk("offense value:%d\n", 
cp->err_info->MoreErrInfo.Invalid_Cmd.offense_value);
-   
 }
-
 #endif
 
 static int 
@@ -782,8 +726,10 @@ static void complete_scsi_command(CommandList_struct *c, 
int timeout,
"reported\n", c);
break;
case CMD_INVALID: {
-   /* print_bytes(c, sizeof(*c), 1, 0);
-   print_cmd(c); */
+   /*
+   print_hex_dump(KERN_INFO, "", 
DUMP_PREFIX_OFFSET, 16, 1, c, sizeof(*c), false);
+   print_cmd(c);
+*/
  /* We get CMD_INVALID if you address a non-existent tape drive instead
of a selection timeout (no response).  You will see this if you yank 
out a tape drive, then try to access it. This is kind of a shame
@@ -985,8 +931,10 @@ cciss_scsi_interpret_error(ctlr_info_t *h, 
CommandList_struct *c)
dev_warn(>pdev->dev,
"%p is reported invalid (probably means "
"target device no longer present)\n", c);
-   /* print_bytes((unsigned char *) c, sizeof(*c), 1, 0);
-   print_cmd(c);  */
+   /*

[PATCH v1 1/1] scsi: replace custom approach to hexdump small buffers

2016-05-06 Thread Andy Shevchenko
In kernel we have defined specifier (%*ph[C]) to dump small buffers in a hex
format. Replace custom approach by a generic one.

Signed-off-by: Andy Shevchenko 
---
 drivers/scsi/scsi_transport_srp.c | 11 +--
 drivers/scsi/sd.c |  4 +---
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/scsi_transport_srp.c 
b/drivers/scsi/scsi_transport_srp.c
index e3cd3ec..02cfc6b 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -115,21 +115,12 @@ static DECLARE_TRANSPORT_CLASS(srp_host_class, 
"srp_host", srp_host_setup,
 static DECLARE_TRANSPORT_CLASS(srp_rport_class, "srp_remote_ports",
   NULL, NULL, NULL);
 
-#define SRP_PID(p) \
-   (p)->port_id[0], (p)->port_id[1], (p)->port_id[2], (p)->port_id[3], \
-   (p)->port_id[4], (p)->port_id[5], (p)->port_id[6], (p)->port_id[7], \
-   (p)->port_id[8], (p)->port_id[9], (p)->port_id[10], (p)->port_id[11], \
-   (p)->port_id[12], (p)->port_id[13], (p)->port_id[14], (p)->port_id[15]
-
-#define SRP_PID_FMT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:" \
-   "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
-
 static ssize_t
 show_srp_rport_id(struct device *dev, struct device_attribute *attr,
  char *buf)
 {
struct srp_rport *rport = transport_class_to_srp_rport(dev);
-   return sprintf(buf, SRP_PID_FMT "\n", SRP_PID(rport));
+   return sprintf(buf, "%16phC\n", rport->port_id);
 }
 
 static DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 428c03e..c1b6b45 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2408,9 +2408,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, 
unsigned char *buffer)
if (sdkp->first_scan || old_wp != sdkp->write_prot) {
sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n",
  sdkp->write_prot ? "on" : "off");
-   sd_printk(KERN_DEBUG, sdkp,
- "Mode Sense: %02x %02x %02x %02x\n",
- buffer[0], buffer[1], buffer[2], buffer[3]);
+   sd_printk(KERN_DEBUG, sdkp, "Mode Sense: %4ph\n", 
buffer);
}
}
 }
-- 
2.8.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 v1 0/4] scsi: some (very) old clean ups

2016-05-06 Thread Andy Shevchenko
This is a set of independent clean ups that didn't land upstream for ages (some
are dated 2010!).  As agreed with Martin at some point I resend
them.

I have more, but the rest is not yet ready for submission.

Andy Shevchenko (3):
  libsas: remove private hex2bin() implementation
  scsi: fnic: use kernel's '%pM' format option to print MAC
  fusion: print lan address via %pMR

Oleksandr Khoshaba (1):
  scsi: qla4xxx: print MAC and SID via %p[mM][R]

 drivers/message/fusion/mptbase.c| 14 --
 drivers/scsi/fnic/vnic_dev.c| 10 ++
 drivers/scsi/libsas/sas_scsi_host.c | 22 ++
 drivers/scsi/qla4xxx/ql4_mbx.c  |  5 +
 drivers/scsi/qla4xxx/ql4_nx.c   |  8 ++--
 drivers/scsi/qla4xxx/ql4_os.c   | 15 ---
 6 files changed, 19 insertions(+), 55 deletions(-)

-- 
2.8.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 v1 4/4] scsi: qla4xxx: print MAC and SID via %p[mM][R]

2016-05-06 Thread Andy Shevchenko
From: Oleksandr Khoshaba 

In the kernel we have nice specifier to print MAC by given pointer to the
address in a binary form.

Signed-off-by: Oleksandr Khoshaba 
Acked-by: Vikas Chaudhary 
Cc: qlogic-storage-upstr...@qlogic.com
Signed-off-by: Andy Shevchenko 
---
 drivers/scsi/qla4xxx/ql4_mbx.c |  5 +
 drivers/scsi/qla4xxx/ql4_nx.c  |  8 ++--
 drivers/scsi/qla4xxx/ql4_os.c  | 15 ---
 3 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index c291fdf..1da04f3 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -2032,10 +2032,7 @@ int qla4xxx_set_param_ddbentry(struct scsi_qla_host *ha,
ptid = (uint16_t *)_ddb_entry->isid[1];
*ptid = cpu_to_le16((uint16_t)ddb_entry->sess->target_id);
 
-   DEBUG2(ql4_printk(KERN_INFO, ha, "ISID [%02x%02x%02x%02x%02x%02x]\n",
- fw_ddb_entry->isid[5], fw_ddb_entry->isid[4],
- fw_ddb_entry->isid[3], fw_ddb_entry->isid[2],
- fw_ddb_entry->isid[1], fw_ddb_entry->isid[0]));
+   DEBUG2(ql4_printk(KERN_INFO, ha, "ISID [%pmR]\n", fw_ddb_entry->isid));
 
iscsi_opts = le16_to_cpu(fw_ddb_entry->iscsi_options);
memset(fw_ddb_entry->iscsi_alias, 0, sizeof(fw_ddb_entry->iscsi_alias));
diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c
index ae87d6c..157938e 100644
--- a/drivers/scsi/qla4xxx/ql4_nx.c
+++ b/drivers/scsi/qla4xxx/ql4_nx.c
@@ -4094,12 +4094,8 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host *ha)
ha->phy_port_num = sys_info->port_num;
ha->iscsi_pci_func_cnt = sys_info->iscsi_pci_func_cnt;
 
-   DEBUG2(printk("scsi%ld: %s: "
-   "mac %02x:%02x:%02x:%02x:%02x:%02x "
-   "serial %s\n", ha->host_no, __func__,
-   ha->my_mac[0], ha->my_mac[1], ha->my_mac[2],
-   ha->my_mac[3], ha->my_mac[4], ha->my_mac[5],
-   ha->serial_number));
+   DEBUG2(printk("scsi%ld: %s: mac %pM serial %s\n",
+   ha->host_no, __func__, ha->my_mac, ha->serial_number));
 
status = QLA_SUCCESS;
 
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 01c3610..9fbb33f 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -6304,13 +6304,9 @@ static int qla4xxx_compare_tuple_ddb(struct 
scsi_qla_host *ha,
 * ISID would not match firmware generated ISID.
 */
if (is_isid_compare) {
-   DEBUG2(ql4_printk(KERN_INFO, ha, "%s: old ISID [%02x%02x%02x"
-   "%02x%02x%02x] New ISID [%02x%02x%02x%02x%02x%02x]\n",
-   __func__, old_tddb->isid[5], old_tddb->isid[4],
-   old_tddb->isid[3], old_tddb->isid[2], old_tddb->isid[1],
-   old_tddb->isid[0], new_tddb->isid[5], new_tddb->isid[4],
-   new_tddb->isid[3], new_tddb->isid[2], new_tddb->isid[1],
-   new_tddb->isid[0]));
+   DEBUG2(ql4_printk(KERN_INFO, ha,
+   "%s: old ISID [%pmR] New ISID [%pmR]\n",
+   __func__, old_tddb->isid, new_tddb->isid));
 
if (memcmp(_tddb->isid[0], _tddb->isid[0],
   sizeof(old_tddb->isid)))
@@ -7925,10 +7921,7 @@ qla4xxx_sysfs_ddb_get_param(struct 
iscsi_bus_flash_session *fnode_sess,
rc = sprintf(buf, "%u\n", fnode_conn->keepalive_timeout);
break;
case ISCSI_FLASHNODE_ISID:
-   rc = sprintf(buf, "%02x%02x%02x%02x%02x%02x\n",
-fnode_sess->isid[0], fnode_sess->isid[1],
-fnode_sess->isid[2], fnode_sess->isid[3],
-fnode_sess->isid[4], fnode_sess->isid[5]);
+   rc = sprintf(buf, "%pm\n", fnode_sess->isid);
break;
case ISCSI_FLASHNODE_TSID:
rc = sprintf(buf, "%u\n", fnode_sess->tsid);
-- 
2.8.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 v1 3/4] fusion: print lan address via %pMR

2016-05-06 Thread Andy Shevchenko
LAN MAC addresses can be printed directly using %pMR specifier.

Cc: Sathya Prakash 
Cc: mpt-fusionlinux@broadcom.com
Signed-off-by: Andy Shevchenko 
---
 drivers/message/fusion/mptbase.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 5537f8d..3af67e6 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -2584,10 +2584,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int 
sleepFlag)
(void) GetLanConfigPages(ioc);
a = 
(u8*)>lan_cnfg_page1.HardwareAddressLow;
dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
-   "LanAddr = %02X:%02X:%02X"
-   ":%02X:%02X:%02X\n",
-   ioc->name, a[5], a[4],
-   a[3], a[2], a[1], a[0]));
+   "LanAddr = %pMR\n", ioc->name, a));
}
break;
 
@@ -6782,8 +6779,7 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void 
*v)
if (ioc->bus_type == FC) {
if (ioc->pfacts[p].ProtocolFlags & 
MPI_PORTFACTS_PROTOCOL_LAN) {
u8 *a = 
(u8*)>lan_cnfg_page1.HardwareAddressLow;
-   seq_printf(m, "LanAddr = 
%02X:%02X:%02X:%02X:%02X:%02X\n",
-   a[5], a[4], a[3], a[2], a[1], 
a[0]);
+   seq_printf(m, "LanAddr = %pMR\n", a);
}
seq_printf(m, "WWN = %08X%08X:%08X%08X\n",
ioc->fc_port_page0[p].WWNN.High,
@@ -6860,8 +6856,7 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int 
*size, int len, int sh
 
if (showlan && (ioc->pfacts[0].ProtocolFlags & 
MPI_PORTFACTS_PROTOCOL_LAN)) {
u8 *a = (u8*)>lan_cnfg_page1.HardwareAddressLow;
-   y += sprintf(buffer+len+y, ", 
LanAddr=%02X:%02X:%02X:%02X:%02X:%02X",
-   a[5], a[4], a[3], a[2], a[1], a[0]);
+   y += sprintf(buffer+len+y, ", LanAddr=%pMR", a);
}
 
y += sprintf(buffer+len+y, ", IRQ=%d", ioc->pci_irq);
@@ -6895,8 +6890,7 @@ static void seq_mpt_print_ioc_summary(MPT_ADAPTER *ioc, 
struct seq_file *m, int
 
if (showlan && (ioc->pfacts[0].ProtocolFlags & 
MPI_PORTFACTS_PROTOCOL_LAN)) {
u8 *a = (u8*)>lan_cnfg_page1.HardwareAddressLow;
-   seq_printf(m, ", LanAddr=%02X:%02X:%02X:%02X:%02X:%02X",
-   a[5], a[4], a[3], a[2], a[1], a[0]);
+   seq_printf(m, ", LanAddr=%pMR", a);
}
 
seq_printf(m, ", IRQ=%d", ioc->pci_irq);
-- 
2.8.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 v1 2/4] scsi: fnic: use kernel's '%pM' format option to print MAC

2016-05-06 Thread Andy Shevchenko
Instead of supplying each byte through stack let's use %pM specifier.

Cc: Hiral Patel 
Cc: Suma Ramars 
Cc: Brian Uchino 
Signed-off-by: Andy Shevchenko 
---
 drivers/scsi/fnic/vnic_dev.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/fnic/vnic_dev.c b/drivers/scsi/fnic/vnic_dev.c
index 9795d6f..ba69d61 100644
--- a/drivers/scsi/fnic/vnic_dev.c
+++ b/drivers/scsi/fnic/vnic_dev.c
@@ -499,10 +499,7 @@ void vnic_dev_add_addr(struct vnic_dev *vdev, u8 *addr)
 
err = vnic_dev_cmd(vdev, CMD_ADDR_ADD, , , wait);
if (err)
-   printk(KERN_ERR
-   "Can't add addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
-   addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
-   err);
+   pr_err("Can't add addr [%pM], %d\n", addr, err);
 }
 
 void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
@@ -517,10 +514,7 @@ void vnic_dev_del_addr(struct vnic_dev *vdev, u8 *addr)
 
err = vnic_dev_cmd(vdev, CMD_ADDR_DEL, , , wait);
if (err)
-   printk(KERN_ERR
-   "Can't del addr [%02x:%02x:%02x:%02x:%02x:%02x], %d\n",
-   addr[0], addr[1], addr[2], addr[3], addr[4], addr[5],
-   err);
+   pr_err("Can't del addr [%pM], %d\n", addr, err);
 }
 
 int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
-- 
2.8.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 v1 1/4] libsas: remove private hex2bin() implementation

2016-05-06 Thread Andy Shevchenko
The function sas_parse_addr() could be easily substituted by hex2bin() which is
in kernel library code.

Cc: Christoph Hellwig 
Signed-off-by: Andy Shevchenko 
---
 drivers/scsi/libsas/sas_scsi_host.c | 22 ++
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/libsas/sas_scsi_host.c 
b/drivers/scsi/libsas/sas_scsi_host.c
index 519dac4..30a5970 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "sas_internal.h"
 
@@ -961,21 +962,6 @@ void sas_target_destroy(struct scsi_target *starget)
sas_put_device(found_dev);
 }
 
-static void sas_parse_addr(u8 *sas_addr, const char *p)
-{
-   int i;
-   for (i = 0; i < SAS_ADDR_SIZE; i++) {
-   u8 h, l;
-   if (!*p)
-   break;
-   h = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
-   p++;
-   l = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
-   p++;
-   sas_addr[i] = (h<<4) | l;
-   }
-}
-
 #define SAS_STRING_ADDR_SIZE   16
 
 int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
@@ -992,7 +978,11 @@ int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
goto out;
}
 
-   sas_parse_addr(addr, fw->data);
+   res = hex2bin(addr, fw->data, strnlen(fw->data, SAS_ADDR_SIZE * 2) / 2);
+   if (res) {
+   res = -EINVAL;
+   goto out;
+   }
 
 out:
release_firmware(fw);
-- 
2.8.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


Re: [PATCHv3 00/14] libata: ZAC support

2016-05-06 Thread Hannes Reinecke
On 04/25/2016 10:16 PM, Tejun Heo wrote:
> Hello,
> 
> On Mon, Apr 25, 2016 at 12:45:42PM +0200, Hannes Reinecke wrote:
>> here's a patchset implementing ZAC support for libata.
>>
>> This is the second part of a larger patchset for ZAC/ZBC support;
>> it requires the scsi trace fixes queued for in mkp/4.7/scsi-queue and
>> the patchset 'libata: SATL update' queued in tj/for-4.7-zac.
> 
> The patches look good from libata side.  If others are okay with it, I
> can pull mkp/4.7/scsi-queue into tj/for-4.7-zac and apply this series
> on top of it.
> 
Ping?

I can easily split off the libsas bits into a different patchset if
this turns out to be an issue.
But it would be really good if this could make it 4.7, it will help
further integration a _lot_.

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
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] scsi: Make scsi_vpd_lun_id() able to use T10 vendor ID based designators

2016-05-06 Thread Hannes Reinecke
On 05/05/2016 02:41 PM, Paul Mackerras wrote:
> On Thu, May 05, 2016 at 10:01:13AM +0200, Hannes Reinecke wrote:
>> On 05/05/2016 05:50 AM, Paul Mackerras wrote:
>>> On Wed, May 04, 2016 at 12:04:16PM +0200, Hannes Reinecke wrote:
> ...
 Nearly.
 The thing is, a T-10 vendor specific ID is _supposed_ to be an ASCII
 string. So I'd rather have it decoded as such.
>>>
>>> Do we need to defend against non-printing characters in the string?
>>>
>> I really would like to stick to ASCII output here, as most vendors put a
>> meaningful string in here.
>> Those who don't we should be going with the '.' normal method and print
>> a dot '.' instead.
>> (Can't we fix up snprintf do do it for us? Would be soo cool ...)
>>
 And we're missing decoding for 'vendor-specific' ID, too.
>>>
>>> There's no guarantee that this would be ASCII, right?  So would you
>>> print it in hex?
>>>
>> Yes, that's the plan here.
>>
>>> Also, is there a preference between these types?  For example, is an
>>> 8-byte EUI-64 preferable to a vendor-specific ID of any length?
>>>
>> Yes. I'd treat T10 vendor ID descriptors with the lowest preference
>> (irrespective of the length), eclipsed (sic) only by the truly vendor
>> specific ones.
> 
> Well, the disks on my system all have the same vendor-specific ID,
> unfortunately -- a '0' followed by 19 spaces.  Here are the
> designators for all the disks on my system:
> 
> scsi 0:2:0:0: 02 01 00 20 'IBM IPR-0   5EC4AB20'
> scsi 0:2:0:0: 02 00 00 14 '0   '
> scsi 0:2:1:0: 02 01 00 20 'IBM IPR-0   5EC28C80'
> scsi 0:2:1:0: 02 00 00 14 '0   '
> scsi 0:2:2:0: 02 01 00 20 'IBM IPR-0   5EC28C60'
> scsi 0:2:2:0: 02 00 00 14 '0   '
> scsi 0:2:3:0: 02 01 00 20 'IBM IPR-0   5EC28C40'
> scsi 0:2:3:0: 02 00 00 14 '0   '
> scsi 0:2:4:0: 02 01 00 20 'IBM IPR-0   5EC28C20'
> scsi 0:2:4:0: 02 00 00 14 '0   '
> scsi 0:2:5:0: 02 01 00 20 'IBM IPR-0   5EC28CC0'
> scsi 0:2:5:0: 02 00 00 14 '0   '
> scsi 0:2:6:0: 02 01 00 20 'IBM IPR-0   5EC28CA0'
> scsi 0:2:6:0: 02 00 00 14 '0   '
> 
My all time favourite here is HP SmartArray, which has this id:

01 03 00 10 600508b1001cc041769dcf27a752f8c2
01 00 00 04 

Hence the logic to select the 'best' ID; any of the NAA or EUI
variants are (more-or-less) guaranteed to give you a valid result.
T-10 and Vendor-specific variants, OTOH, do not have a guarantee to
be even parseable; I've seen a very wide interpretation area of them
meaning of 'ASCII'...

>> And actually I would make the vendor-specific decoding the default
>> entry, too, as we might come across some other descriptors which we
>> cannot decode (yet). And by having a default method for decoding we
>> ensure to always be able to come up with an ALUA identification.
>> Otherwise we might end up in the same situation as we're in now.
> 
> What would happen if we pick a designator which is not unique across
> different disks?  Would we think that they were all the same disk?
> 
This is why I've implemented the selection mechanism.
Any of the NAA or EUI variants are guaranteed to the unique; I've
yet to see a vendor to get this wrong.
T-10 and vendor-specific variants, however, have a habit to be _not_
unique, without us being able to tell if they are.
(Which was the reason why I've omitted decoding for these).

Meanwhile I've posted two patches, one for not failing ALUA when no
VPD identifaction could be retrieved, and another one for properly
decoding T-10 vendor identifications.

Can you please test them and see if you issue is resolved?

Thanks.

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
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/6] mpt3sas: Updating mpt3sas driver version to 13.100.00.00

2016-05-06 Thread Chaitra P B
Bump mpt3sas driver version from 12.100.00.00 to 13.100.00.00

Signed-off-by: Chaitra P B 
---
 drivers/scsi/mpt3sas/mpt3sas_base.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 32580b5..aa918aa 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -73,8 +73,8 @@
 #define MPT3SAS_DRIVER_NAME"mpt3sas"
 #define MPT3SAS_AUTHOR "Avago Technologies "
 #define MPT3SAS_DESCRIPTION"LSI MPT Fusion SAS 3.0 Device Driver"
-#define MPT3SAS_DRIVER_VERSION "12.100.00.00"
-#define MPT3SAS_MAJOR_VERSION  12
+#define MPT3SAS_DRIVER_VERSION "13.100.00.00"
+#define MPT3SAS_MAJOR_VERSION  13
 #define MPT3SAS_MINOR_VERSION  100
 #define MPT3SAS_BUILD_VERSION  0
 #define MPT3SAS_RELEASE_VERSION00
-- 
1.8.3.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/6] mpt3sas: Update MPI header to 2.00.42

2016-05-06 Thread Chaitra P B
Updated MPI version and MPI header files.

ChangeList:
* Added SATADeviceWaitTime to SAS IO Unit Page 4
* Added EEDPObservedValue added to SCSI IO Reply message
* Added MPI2_EVENT_ACTIVE_CABLE_EXCEPTION and
  MPI26_EVENT_DATA_ACTIVE_CABLE_EXCEPT

Signed-off-by: Chaitra P B 
---
 drivers/scsi/mpt3sas/mpi/mpi2.h  |  7 +--
 drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h | 18 +++-
 drivers/scsi/mpt3sas/mpi/mpi2_init.h | 15 +++---
 drivers/scsi/mpt3sas/mpi/mpi2_ioc.h  | 40 +++-
 4 files changed, 65 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpi/mpi2.h b/drivers/scsi/mpt3sas/mpi/mpi2.h
index dfad5b8..a9a659f 100644
--- a/drivers/scsi/mpt3sas/mpi/mpi2.h
+++ b/drivers/scsi/mpt3sas/mpi/mpi2.h
@@ -8,7 +8,7 @@
  * scatter/gather formats.
  * Creation Date:  June 21, 2006
  *
- * mpi2.h Version:  02.00.39
+ * mpi2.h Version:  02.00.42
  *
  * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
  *   prefix are for use only on MPI v2.5 products, and must not be used
@@ -100,6 +100,9 @@
  * Added MPI2_DIAG_SBR_RELOAD.
  * 03-19-15  02.00.38  Bumped MPI2_HEADER_VERSION_UNIT.
  * 05-25-15  02.00.39  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 08-25-15  02.00.40  Bumped MPI2_HEADER_VERSION_UNIT.
+ * 12-15-15  02.00.41  Bumped MPI_HEADER_VERSION_UNIT
+ * 01-01-16  02.00.42  Bumped MPI_HEADER_VERSION_UNIT
  * --
  */
 
@@ -139,7 +142,7 @@
 #define MPI2_VERSION_02_06 (0x0206)
 
 /*Unit and Dev versioning for this MPI header set */
-#define MPI2_HEADER_VERSION_UNIT(0x27)
+#define MPI2_HEADER_VERSION_UNIT(0x2A)
 #define MPI2_HEADER_VERSION_DEV (0x00)
 #define MPI2_HEADER_VERSION_UNIT_MASK   (0xFF00)
 #define MPI2_HEADER_VERSION_UNIT_SHIFT  (8)
diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h 
b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
index 9cf09bf..95356a8 100644
--- a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
+++ b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h
@@ -6,7 +6,7 @@
  * Title:  MPI Configuration messages and pages
  * Creation Date:  November 10, 2006
  *
- *   mpi2_cnfg.h Version:  02.00.33
+ *   mpi2_cnfg.h Version:  02.00.35
  *
  * NOTE: Names (typedefs, defines, etc.) beginning with an MPI25 or Mpi25
  *   prefix are for use only on MPI v2.5 products, and must not be used
@@ -183,9 +183,12 @@
  * Added MPI2_BIOSPAGE1_OPTIONS_ADVANCED_CONFIG.
  * Added AdapterOrderAux fields to BIOS Page 3.
  * 03-16-15  02.00.31  Updated for MPI v2.6.
+ * Added Flags field to IO Unit Page 7.
  * Added new SAS Phy Event codes
  * 05-25-15  02.00.33  Added more defines for the BiosOptions field of
  * MPI2_CONFIG_PAGE_BIOS_1.
+ * 08-25-15  02.00.34  Bumped Header Version.
+ * 12-18-15  02.00.35  Added SATADeviceWaitTime to SAS IO Unit Page 4.
  * --
  */
 
@@ -958,13 +961,16 @@ typedef struct _MPI2_CONFIG_PAGE_IO_UNIT_7 {
U8  Reserved3;  /*0x17 */
U32 BoardPowerRequirement;  /*0x18 */
U32 PCISlotPowerAllocation; /*0x1C */
-   U32 Reserved6;  /* 0x20 */
-   U32 Reserved7;  /* 0x24 */
+/* reserved prior to MPI v2.6 */
+   U8  Flags;  /* 0x20 */
+   U8  Reserved6;  /* 0x21 */
+   U16 Reserved7;  /* 0x22 */
+   U32 Reserved8;  /* 0x24 */
 } MPI2_CONFIG_PAGE_IO_UNIT_7,
*PTR_MPI2_CONFIG_PAGE_IO_UNIT_7,
Mpi2IOUnitPage7_t, *pMpi2IOUnitPage7_t;
 
-#define MPI2_IOUNITPAGE7_PAGEVERSION   (0x04)
+#define MPI2_IOUNITPAGE7_PAGEVERSION   (0x05)
 
 /*defines for IO Unit Page 7 CurrentPowerMode and PreviousPowerMode fields */
 #define MPI25_IOUNITPAGE7_PM_INIT_MASK  (0xC0)
@@ -1045,6 +1051,8 @@ typedef struct _MPI2_CONFIG_PAGE_IO_UNIT_7 {
 #define MPI2_IOUNITPAGE7_BOARD_TEMP_FAHRENHEIT  (0x01)
 #define MPI2_IOUNITPAGE7_BOARD_TEMP_CELSIUS (0x02)
 
+/* defines for IO Unit Page 7 Flags field */
+#define MPI2_IOUNITPAGE7_FLAG_CABLE_POWER_EXC   (0x01)
 
 /*IO Unit Page 8 */
 
@@ -2271,7 +2279,7 @@ typedef struct _MPI2_CONFIG_PAGE_SASIOUNIT_4 {
U8
BootDeviceWaitTime; /*0x24 */
U8
-   Reserved4;  /*0x25 */
+   SATADeviceWaitTime; /*0x25 */
U16
Reserved5;  /*0x26 */
U8
diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_init.h 
b/drivers/scsi/mpt3sas/mpi/mpi2_init.h
index c38f624..bba56b6 

[PATCH 0/6] mpt3sas: driver update to Phase12.

2016-05-06 Thread Chaitra P B
Here is the change list:
* Updated MPI version and MPI header files.
* Handle active cable exception event for Intruder/Cutlass HBAs.
* Use scsi_prot_ref_tag()API to fill reference tag field in the CDB.
* Updated mpt3sas driver version to Ph12 13.100.00.00
* Set maximum transfer length per IO on RAID volumes to 4MB.
* Use "synchronize_irq()"API to handle Asynchronous TM's completion.

Chaitra P B (6):
  mpt3sas: Update MPI header to 2.00.42
  mpt3sas: Handle active cable exception event
  mpt3sas: Fix initial Reference tag field for 4K PI drives.
  mpt3sas: Updating mpt3sas driver version to 13.100.00.00
  mpt3sas: Set maximum transfer length per IO to 4MB for VDs
  mpt3sas: Used "synchronize_irq()"API to synchronize timed-out IO
& TMs

 drivers/scsi/mpt3sas/mpi/mpi2.h  |  7 +--
 drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h | 18 +++-
 drivers/scsi/mpt3sas/mpi/mpi2_init.h | 15 +++---
 drivers/scsi/mpt3sas/mpi/mpi2_ioc.h  | 40 +++-
 drivers/scsi/mpt3sas/mpt3sas_base.c  | 20 ++
 drivers/scsi/mpt3sas/mpt3sas_base.h  |  9 +---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 27 ++--
 7 files changed, 108 insertions(+), 28 deletions(-)

-- 
1.8.3.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/6] mpt3sas: Set maximum transfer length per IO to 4MB for VDs

2016-05-06 Thread Chaitra P B
Set maximum transfer length per IO on RAID volumes
to 4MB by setting VD's queue's max_sector to 8192.

Signed-off-by: Chaitra P B 
---
 drivers/scsi/mpt3sas/mpt3sas_base.h  | 2 ++
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 8 
 2 files changed, 10 insertions(+)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index aa918aa..e1befba 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -112,6 +112,8 @@
 #define MPT3SAS_SAS_QUEUE_DEPTH254
 #define MPT3SAS_RAID_QUEUE_DEPTH   128
 
+#define MPT3SAS_RAID_MAX_SECTORS   8192
+
 #define MPT_NAME_LENGTH32  /* generic length of 
strings */
 #define MPT_STRING_LENGTH  64
 
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 0fea937..abd8717 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -1911,6 +1911,14 @@ scsih_slave_configure(struct scsi_device *sdev)
(unsigned long long)raid_device->wwid,
raid_device->num_pds, ds);
 
+   if (shost->max_sectors > MPT3SAS_RAID_MAX_SECTORS) {
+   blk_queue_max_hw_sectors(sdev->request_queue,
+   MPT3SAS_RAID_MAX_SECTORS);
+   sdev_printk(KERN_INFO, sdev,
+   "Set queue's max_sector to: %u\n",
+   MPT3SAS_RAID_MAX_SECTORS);
+   }
+
scsih_change_queue_depth(sdev, qdepth);
 
/* raid transport support */
-- 
1.8.3.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 3/6] mpt3sas: Fix initial Reference tag field for 4K PI drives.

2016-05-06 Thread Chaitra P B
Modified driver code to use scsi_prot_ref_tag() API instead of
scsi_get_lba(), while initializing reference tag field in the CDB.

Signed-off-by: Chaitra P B 
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 221f8bf..0fea937 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -3961,7 +3961,7 @@ _scsih_setup_eedp(struct MPT3SAS_ADAPTER *ioc, struct 
scsi_cmnd *scmd,
MPI2_SCSIIO_EEDPFLAGS_CHECK_REFTAG |
MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD;
mpi_request->CDB.EEDP32.PrimaryReferenceTag =
-   cpu_to_be32(scsi_get_lba(scmd));
+   cpu_to_be32(scsi_prot_ref_tag(scmd));
break;
 
case SCSI_PROT_DIF_TYPE3:
-- 
1.8.3.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 6/6] mpt3sas: Used "synchronize_irq()"API to synchronize timed-out IO & TMs

2016-05-06 Thread Chaitra P B
Replaced mpt3sas_base_flush_reply_queues()with
mpt3sas_base_sync_reply_irqs(),as mpt3sas_base_flush_reply_queues()
skips over reply queues that are currently busy (i.e. being handled
by interrupt processing in another core). If a reply queue is busy,
then call to synchronize_irq()in mpt3sas_base_sync_reply_irqs()make
sures the other core has finished flushing the queue and completed
any calls to the mid-layer scsi_done() routine.

Signed-off-by: Chaitra P B 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c  | 15 +++
 drivers/scsi/mpt3sas/mpt3sas_base.h  |  3 ++-
 drivers/scsi/mpt3sas/mpt3sas_scsih.c |  4 +++-
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 4e9142f..fd9002d 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -1103,18 +1103,16 @@ _base_is_controller_msix_enabled(struct MPT3SAS_ADAPTER 
*ioc)
 }
 
 /**
- * mpt3sas_base_flush_reply_queues - flushing the MSIX reply queues
+ * mpt3sas_base_sync_reply_irqs - flush pending MSIX interrupts
  * @ioc: per adapter object
- * Context: ISR conext
+ * Context: non ISR conext
  *
- * Called when a Task Management request has completed. We want
- * to flush the other reply queues so all the outstanding IO has been
- * completed back to OS before we process the TM completetion.
+ * Called when a Task Management request has completed.
  *
  * Return nothing.
  */
 void
-mpt3sas_base_flush_reply_queues(struct MPT3SAS_ADAPTER *ioc)
+mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *ioc)
 {
struct adapter_reply_queue *reply_q;
 
@@ -1125,12 +1123,13 @@ mpt3sas_base_flush_reply_queues(struct MPT3SAS_ADAPTER 
*ioc)
return;
 
list_for_each_entry(reply_q, >reply_queue_list, list) {
-   if (ioc->shost_recovery)
+   if (ioc->shost_recovery || ioc->remove_host ||
+   ioc->pci_error_recovery)
return;
/* TMs are on msix_index == 0 */
if (reply_q->msix_index == 0)
continue;
-   _base_interrupt(reply_q->vector, (void *)reply_q);
+   synchronize_irq(reply_q->vector);
}
 }
 
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index e1befba..1a614d7 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -1236,7 +1236,8 @@ void *mpt3sas_base_get_msg_frame(struct MPT3SAS_ADAPTER 
*ioc, u16 smid);
 void *mpt3sas_base_get_sense_buffer(struct MPT3SAS_ADAPTER *ioc, u16 smid);
 __le32 mpt3sas_base_get_sense_buffer_dma(struct MPT3SAS_ADAPTER *ioc,
u16 smid);
-void mpt3sas_base_flush_reply_queues(struct MPT3SAS_ADAPTER *ioc);
+
+void mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *ioc);
 
 /* hi-priority queue */
 u16 mpt3sas_base_get_smid_hpr(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx);
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index abd8717..928214f 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -2126,7 +2126,6 @@ _scsih_tm_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 
msix_index, u32 reply)
return 1;
if (ioc->tm_cmds.smid != smid)
return 1;
-   mpt3sas_base_flush_reply_queues(ioc);
ioc->tm_cmds.status |= MPT3_CMD_COMPLETE;
mpi_reply =  mpt3sas_base_get_reply_virt_addr(ioc, reply);
if (mpi_reply) {
@@ -2311,6 +2310,9 @@ mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 
handle, uint channel,
}
}
 
+   /* sync IRQs in case those were busy during flush. */
+   mpt3sas_base_sync_reply_irqs(ioc);
+
if (ioc->tm_cmds.status & MPT3_CMD_REPLY_VALID) {
mpt3sas_trigger_master(ioc, MASTER_TRIGGER_TASK_MANAGMENT);
mpi_reply = ioc->tm_cmds.reply;
-- 
1.8.3.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 2/6] mpt3sas: Handle active cable exception event

2016-05-06 Thread Chaitra P B
In-order to handle this 'MPI2_EVENT_ACTIVE_CABLE_EXCEPTION' event,
driver need to follow below steps,
1. Unmask the 'MPI2_EVENT_ACTIVE_CABLE_EXCEPTION' event,
so that FW can notify this event to host driver.
2. After receiving this event, add this event to AEN event queue,
for notifying this event to applications.
3. Then Print below message in kernel logs if the event data's reason
code is zero,
"Currently an active cable with ReceptacleID  cannot be powered
and devices connected to this active cable will not be seen. This active
cable requires  of power"

This event is only for Intruder/Cutlass HBAs.

Signed-off-by: Chaitra P B 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c  |  5 +
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 13 +
 2 files changed, 18 insertions(+)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 8c44b9c..4e9142f 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -654,6 +654,9 @@ _base_display_event_data(struct MPT3SAS_ADAPTER *ioc,
case MPI2_EVENT_TEMP_THRESHOLD:
desc = "Temperature Threshold";
break;
+   case MPI2_EVENT_ACTIVE_CABLE_EXCEPTION:
+   desc = "Active cable exception";
+   break;
}
 
if (!desc)
@@ -5424,6 +5427,8 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc)
_base_unmask_events(ioc, MPI2_EVENT_IR_OPERATION_STATUS);
_base_unmask_events(ioc, MPI2_EVENT_LOG_ENTRY_ADDED);
_base_unmask_events(ioc, MPI2_EVENT_TEMP_THRESHOLD);
+   if (ioc->hba_mpi_version_belonged == MPI26_VERSION)
+   _base_unmask_events(ioc, MPI2_EVENT_ACTIVE_CABLE_EXCEPTION);
 
r = _base_make_ioc_operational(ioc, CAN_SLEEP);
if (r)
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index e0e4920..221f8bf 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -7850,6 +7850,7 @@ mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, 
u8 msix_index,
Mpi2EventNotificationReply_t *mpi_reply;
u16 event;
u16 sz;
+   Mpi26EventDataActiveCableExcept_t *ActiveCableEventData;
 
/* events turned off due to host reset or driver unloading */
if (ioc->remove_host || ioc->pci_error_recovery)
@@ -7962,6 +7963,18 @@ mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER 
*ioc, u8 msix_index,
(Mpi2EventDataTemperature_t *)
mpi_reply->EventData);
break;
+   case MPI2_EVENT_ACTIVE_CABLE_EXCEPTION:
+   ActiveCableEventData =
+   (Mpi26EventDataActiveCableExcept_t *) mpi_reply->EventData;
+   if (ActiveCableEventData->ReasonCode ==
+   MPI26_EVENT_ACTIVE_CABLE_INSUFFICIENT_POWER)
+   pr_info(MPT3SAS_FMT "Currently an active cable with 
ReceptacleID %d",
+   ioc->name, ActiveCableEventData->ReceptacleID);
+   pr_info("cannot be powered and devices connected to 
this active cable");
+   pr_info("will not be seen. This active cable");
+   pr_info("requires %d mW of power",
+   ActiveCableEventData->ActiveCablePowerRequirement);
+   break;
 
default: /* ignore the rest */
return 1;
-- 
1.8.3.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] scsi_dh_alua: do not fail for unknown VPD identification

2016-05-06 Thread Hannes Reinecke
Not every device will return a useable VPD identification, but
still might support ALUA. Rather then disable ALUA support we
should be allowing the device identification to be empty and
attach individual ALUA device handler to each devices.

Reported-by: Paul Mackerras 
Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index ab666a1..eddc200 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -195,10 +195,13 @@ static struct alua_port_group *alua_find_get_pg(char 
*id_str, size_t id_size,
 {
struct alua_port_group *pg;
 
+   if (!id_str || !id_size || !strlen(id_str))
+   return NULL;
+
list_for_each_entry(pg, _group_list, node) {
if (pg->group_id != group_id)
continue;
-   if (pg->device_id_len != id_size)
+   if (!pg->device_id_len || pg->device_id_len != id_size)
continue;
if (strncmp(pg->device_id_str, id_str, id_size))
continue;
@@ -232,14 +235,14 @@ static struct alua_port_group *alua_alloc_pg(struct 
scsi_device *sdev,
sizeof(pg->device_id_str));
if (pg->device_id_len <= 0) {
/*
-* Internal error: TPGS supported but no device
-* identifcation found. Disable ALUA support.
+* TPGS supported but no device identifcation found.
+* Generate private device identification.
 */
-   kfree(pg);
sdev_printk(KERN_INFO, sdev,
"%s: No device descriptors found\n",
ALUA_DH_NAME);
-   return ERR_PTR(-ENXIO);
+   pg->device_id_str[0] = '\0';
+   pg->device_id_len = 0;
}
pg->group_id = group_id;
pg->tpgs = tpgs;
@@ -354,9 +357,15 @@ static int alua_check_vpd(struct scsi_device *sdev, struct 
alua_dh_data *h,
return SCSI_DH_NOMEM;
return SCSI_DH_DEV_UNSUPP;
}
-   sdev_printk(KERN_INFO, sdev,
-   "%s: device %s port group %x rel port %x\n",
-   ALUA_DH_NAME, pg->device_id_str, group_id, rel_port);
+   if (pg->device_id_len)
+   sdev_printk(KERN_INFO, sdev,
+   "%s: device %s port group %x rel port %x\n",
+   ALUA_DH_NAME, pg->device_id_str,
+   group_id, rel_port);
+   else
+   sdev_printk(KERN_INFO, sdev,
+   "%s: port group %x rel port %x\n",
+   ALUA_DH_NAME, group_id, rel_port);
 
/* Check for existing port group references */
spin_lock(>pg_lock);
-- 
1.8.5.6

--
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] scsi_lib: Decode T-10 vendor IDs

2016-05-06 Thread Hannes Reinecke
Some arrays / HBAs will only present T-10 vendor IDs, so we
should be decoding them, too.

Suggested-by: Paul Mackerras 
Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/scsi_lib.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index b920c5d..a6158f8 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -3064,6 +3064,7 @@ int scsi_vpd_lun_id(struct scsi_device *sdev, char *id, 
size_t id_len)
 * - EUI-64 based 12-byte
 * - NAA IEEE Registered
 * - NAA IEEE Extended
+* - T10 Vendor ID
 * as longer descriptors reduce the likelyhood
 * of identification clashes.
 */
@@ -3082,6 +3083,21 @@ int scsi_vpd_lun_id(struct scsi_device *sdev, char *id, 
size_t id_len)
goto next_desig;
 
switch (d[1] & 0xf) {
+   case 0x1:
+   /* T-10 Vendor ID */
+   if (cur_id_size > d[3])
+   break;
+   /* Prefer anything */
+   if (cur_id_type > 0x01)
+   break;
+   cur_id_size = d[3];
+   if (cur_id_size + 4 > id_len)
+   cur_id_size = id_len - 4;
+   cur_id_str = d + 4;
+   cur_id_type = d[1] & 0xf;
+   id_size = snprintf(id, id_len, "t10.%*pE",
+  cur_id_size, cur_id_str);
+   break;
case 0x2:
/* EUI-64 */
if (cur_id_size > d[3])
-- 
1.8.5.6

--
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 resend v2] [SCSI] bfa: fix bfa_fcb_itnim_alloc() error handling

2016-05-06 Thread Anil Gurumurthy
Apologies for the delay. Patch looks good.

Acked by: Anil Gurumurthy 


-Original Message-
From: Martin K. Petersen [mailto:martin.peter...@oracle.com] 
Sent: 06 May 2016 06:54
To: Dan Carpenter 
Cc: Anil Gurumurthy ; Sudarsana Kalluru 
; James E.J. Bottomley ; 
Martin K. Petersen ; linux-scsi 
; kernel-janit...@vger.kernel.org
Subject: Re: [PATCH resend v2] [SCSI] bfa: fix bfa_fcb_itnim_alloc() error 
handling

> "Dan" == Dan Carpenter  writes:

Dan> The caller assumes that "itnim" is NULL on error and non-NULL on 
Dan> success but really "itnim" is uninitialized on error.  This 
Dan> function should just use normal error handling where it returns 
Dan> zero on success and negative on failure.

Anil, please review:

https://patchwork.kernel.org/patch/8820751/

-- 
Martin K. Petersen  Oracle Linux Engineering
--
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