RE: [PATCH V1 3/8] scsi: ufs: wrap the i/o access operations

2013-05-13 Thread Dolev Raviv

 On Sunday, May 12, 2013, Dolev Raviv wrote:
 Author should be identified here. (From: author...)
 Except last patch of series(8/8), all of patches are not from you.

 Simplify operations with hiding mmio_base.

 Signed-off-by: Seungwon Jeon tgih@samsung.com
 Signed-off-by: Dolev Raviv dra...@codeaurora.org
 I'm not sure that your signed-off is proper here including (3/8 ~ 6/8)
 And maintainer, Santosh's ack is omitted.

Thanks for your comment I wasn't sure about the appropriate custom.
I will remove it later today if it is ok with you.

Dolev


 Tested-by: Maya Erez me...@codeaurora.org
 Thanks,
 Seungwon Jeon

 --
 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



-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


--
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 2/2] [SCSI] a3000: use module_platform_driver_probe()

2013-05-13 Thread Geert Uytterhoeven
On Thu, May 2, 2013 at 8:30 AM, Jingoo Han jg1@samsung.com wrote:
 This patch uses module_platform_driver_probe() macro which makes
 the code smaller and simpler.

 Acked-by: Geert Uytterhoeven ge...@linux-m68k.org
 Signed-off-by: Jingoo Han jg1@samsung.com

James, will you take this one? Or shall I queue it in the m68k tree?
Thx!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
-- Linus Torvalds
--
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 15/17] bfa: Support for chinook-quad port card

2013-05-13 Thread Vijaya Mohan Guvva
This patch enables support for chinook quad port 16G FC card (falcon)

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_defs.h | 5 -
 drivers/scsi/bfa/bfa_ioc.c  | 1 +
 drivers/scsi/bfa/bfad.c | 8 
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
index bef16d2..d40a79f 100644
--- a/drivers/scsi/bfa/bfa_defs.h
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -637,6 +637,7 @@ enum {
BFA_PCI_DEVICE_ID_CT= 0x14,
BFA_PCI_DEVICE_ID_CT_FC = 0x21,
BFA_PCI_DEVICE_ID_CT2   = 0x22,
+   BFA_PCI_DEVICE_ID_CT2_QUAD  = 0x23,
 };
 
 #define bfa_asic_id_cb(__d)\
@@ -645,7 +646,9 @@ enum {
 #define bfa_asic_id_ct(__d)\
((__d) == BFA_PCI_DEVICE_ID_CT ||   \
 (__d) == BFA_PCI_DEVICE_ID_CT_FC)
-#define bfa_asic_id_ct2(__d)   ((__d) == BFA_PCI_DEVICE_ID_CT2)
+#define bfa_asic_id_ct2(__d)   \
+   ((__d) == BFA_PCI_DEVICE_ID_CT2 ||  \
+   (__d) == BFA_PCI_DEVICE_ID_CT2_QUAD)
 #define bfa_asic_id_ctc(__d)   \
(bfa_asic_id_ct(__d) || bfa_asic_id_ct2(__d))
 
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index a4f3741..f78bcb6 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -2196,6 +2196,7 @@ bfa_ioc_pci_init(struct bfa_ioc_s *ioc, struct 
bfa_pcidev_s *pcidev,
break;
 
case BFA_PCI_DEVICE_ID_CT2:
+   case BFA_PCI_DEVICE_ID_CT2_QUAD:
ioc-asic_gen = BFI_ASIC_GEN_CT2;
if (clscode == BFI_PCIFN_CLASS_FC 
pcidev-ssid == BFA_PCI_CT2_SSID_FC) {
diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index a5f7690..bf5c5d3 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -1720,6 +1720,14 @@ struct pci_device_id bfad_id_table[] = {
.class_mask = ~0,
},
 
+   {
+   .vendor = BFA_PCI_VENDOR_ID_BROCADE,
+   .device = BFA_PCI_DEVICE_ID_CT2_QUAD,
+   .subvendor = PCI_ANY_ID,
+   .subdevice = PCI_ANY_ID,
+   .class = (PCI_CLASS_SERIAL_FIBER  8),
+   .class_mask = ~0,
+   },
{0, 0},
 };
 
-- 
1.7.12

--
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 13/17] bfa: Fix bug_on condition in RPSC rsp handling

2013-05-13 Thread Vijaya Mohan Guvva
Fix bug_on condition check in RPSC (Report Port Speed Capabilities)
response processing.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_fcs_rport.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_fcs_rport.c b/drivers/scsi/bfa/bfa_fcs_rport.c
index 807622b..891aab6 100644
--- a/drivers/scsi/bfa/bfa_fcs_rport.c
+++ b/drivers/scsi/bfa/bfa_fcs_rport.c
@@ -3430,9 +3430,10 @@ bfa_fcs_rpf_rpsc2_response(void *fcsarg, struct 
bfa_fcxp_s *fcxp, void *cbarg,
num_ents = be16_to_cpu(rpsc2_acc-num_pids);
bfa_trc(rport-fcs, num_ents);
if (num_ents  0) {
-   WARN_ON(rpsc2_acc-port_info[0].pid == rport-pid);
+   WARN_ON(be32_to_cpu(rpsc2_acc-port_info[0].pid) !=
+   bfa_ntoh3b(rport-pid));
bfa_trc(rport-fcs,
-   be16_to_cpu(rpsc2_acc-port_info[0].pid));
+   be32_to_cpu(rpsc2_acc-port_info[0].pid));
bfa_trc(rport-fcs,
be16_to_cpu(rpsc2_acc-port_info[0].speed));
bfa_trc(rport-fcs,
-- 
1.7.12

--
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 05/17] bfa: FDMI enhancements

2013-05-13 Thread Vijaya Mohan Guvva
Update addl. fields in FDMI to confirm to FC-GS6 standard for RPA and
RHBA commands.

Signed-off-by: Anil Gurumurthy aguru...@brocade.com
Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_fc.h|  15 
 drivers/scsi/bfa/bfa_fcs.h   |  21 -
 drivers/scsi/bfa/bfa_fcs_lport.c | 190 +++
 3 files changed, 224 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_fc.h b/drivers/scsi/bfa/bfa_fc.h
index bea821b..562ef73 100644
--- a/drivers/scsi/bfa/bfa_fc.h
+++ b/drivers/scsi/bfa/bfa_fc.h
@@ -1531,6 +1531,12 @@ enum fdmi_hba_attribute_type {
FDMI_HBA_ATTRIB_FW_VERSION, /* 0x0009 */
FDMI_HBA_ATTRIB_OS_NAME,/* 0x000A */
FDMI_HBA_ATTRIB_MAX_CT, /* 0x000B */
+   FDMI_HBA_ATTRIB_NODE_SYM_NAME,  /* 0x000C */
+   FDMI_HBA_ATTRIB_VENDOR_INFO,/* 0x000D */
+   FDMI_HBA_ATTRIB_NUM_PORTS,  /* 0x000E */
+   FDMI_HBA_ATTRIB_FABRIC_NAME,/* 0x000F */
+   FDMI_HBA_ATTRIB_BIOS_VER,   /* 0x0010 */
+   FDMI_HBA_ATTRIB_VENDOR_ID = 0x00E0,
 
FDMI_HBA_ATTRIB_MAX_TYPE
 };
@@ -1545,6 +1551,15 @@ enum fdmi_port_attribute_type {
FDMI_PORT_ATTRIB_FRAME_SIZE,/* 0x0004 */
FDMI_PORT_ATTRIB_DEV_NAME,  /* 0x0005 */
FDMI_PORT_ATTRIB_HOST_NAME, /* 0x0006 */
+   FDMI_PORT_ATTRIB_NODE_NAME, /* 0x0007 */
+   FDMI_PORT_ATTRIB_PORT_NAME, /* 0x0008 */
+   FDMI_PORT_ATTRIB_PORT_SYM_NAME, /* 0x0009 */
+   FDMI_PORT_ATTRIB_PORT_TYPE, /* 0x000A */
+   FDMI_PORT_ATTRIB_SUPP_COS,  /* 0x000B */
+   FDMI_PORT_ATTRIB_PORT_FAB_NAME, /* 0x000C */
+   FDMI_PORT_ATTRIB_PORT_FC4_TYPE, /* 0x000D */
+   FDMI_PORT_ATTRIB_PORT_STATE = 0x101,/* 0x0101 */
+   FDMI_PORT_ATTRIB_PORT_NUM_RPRT = 0x102, /* 0x0102 */
 
FDMI_PORT_ATTR_MAX_TYPE
 };
diff --git a/drivers/scsi/bfa/bfa_fcs.h b/drivers/scsi/bfa/bfa_fcs.h
index 1369682..4f1e650 100644
--- a/drivers/scsi/bfa/bfa_fcs.h
+++ b/drivers/scsi/bfa/bfa_fcs.h
@@ -627,6 +627,9 @@ void bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim,
 
 #define BFA_FCS_FDMI_SUPP_SPEEDS_10G   FDMI_TRANS_SPEED_10G
 
+#define BFA_FCS_FDMI_VENDOR_INFO_LEN8
+#define BFA_FCS_FDMI_FC4_TYPE_LEN   32
+
 /*
  * HBA Attribute Block : BFA internal representation. Note : Some variable
  * sizes have been trimmed to suit BFA For Ex : Model will be Brocade. Based
@@ -637,25 +640,39 @@ struct bfa_fcs_fdmi_hba_attr_s {
u8 manufacturer[64];
u8 serial_num[64];
u8 model[16];
-   u8 model_desc[256];
+   u8 model_desc[128];
u8 hw_version[8];
u8 driver_version[BFA_VERSION_LEN];
u8 option_rom_ver[BFA_VERSION_LEN];
u8 fw_version[BFA_VERSION_LEN];
u8 os_name[256];
__be32max_ct_pyld;
+   struct  bfa_lport_symname_s node_sym_name;
+   u8 vendor_info[BFA_FCS_FDMI_VENDOR_INFO_LEN];
+   __be32num_ports;
+   wwn_t   fabric_name;
+   u8 bios_ver[BFA_VERSION_LEN];
 };
 
 /*
  * Port Attribute Block
  */
 struct bfa_fcs_fdmi_port_attr_s {
-   u8 supp_fc4_types[32];  /* supported FC4 types */
+   u8 supp_fc4_types[BFA_FCS_FDMI_FC4_TYPE_LEN];
__be32supp_speed;   /* supported speed */
__be32curr_speed;   /* current Speed */
__be32max_frm_size; /* max frame size */
u8 os_device_name[256]; /* OS device Name */
u8 host_name[256];  /* host name */
+   wwn_t   port_name;
+   wwn_t   node_name;
+   struct  bfa_lport_symname_s port_sym_name;
+   __be32port_type;
+   enum fc_cosscos;
+   wwn_t   port_fabric_name;
+   u8 port_act_fc4_type[BFA_FCS_FDMI_FC4_TYPE_LEN];
+   __be32port_state;
+   __be32num_ports;
 };
 
 struct bfa_fcs_stats_s {
diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
index 1224d04..8773d5e 100644
--- a/drivers/scsi/bfa/bfa_fcs_lport.c
+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
@@ -2048,10 +2048,71 @@ bfa_fcs_lport_fdmi_build_rhba_pyld(struct 
bfa_fcs_lport_fdmi_s *fdmi, u8 *pyld)
attr-type = cpu_to_be16(FDMI_HBA_ATTRIB_MAX_CT);
templen = sizeof(fcs_hba_attr-max_ct_pyld);
memcpy(attr-value, fcs_hba_attr-max_ct_pyld, templen);
+   templen = fc_roundup(templen, sizeof(u32));
+   curr_ptr += sizeof(attr-type) + sizeof(templen) + templen;
len += templen;
count++;
attr-len = cpu_to_be16(templen + sizeof(attr-type) +
 sizeof(templen));
+   /*
+* Send extended attributes ( FOS 7.1 support )
+*/
+   if (fdmi-retry_cnt == 0) {
+   attr = (struct fdmi_attr_s *) curr_ptr;
+   attr-type = cpu_to_be16(FDMI_HBA_ATTRIB_NODE_SYM_NAME);
+   

[PATCH V1] bfa: fix faulty handling of events in lps sm

2013-05-13 Thread Vijay Mohan Guvva
Resending the patch as it didn't make the link-scsi list.

When a switch disable/enable or a reboot is done, the HBA port gets an
offline and a subsequent online notification. When the port comes up a
link up notification is sent to bfa from the firmware. The bfa then send
an FLOGI to the firmware which is sent out on the wire.
The switch port meanwhile goes offline (presumably for diagnostics)
which causes the switch not to respond to the FLOGI.
The link down notification is sent to the HBA driver. However owing to a
bug in the lps state machine handling the lps state machine does not
move to sm_init state (it remains in sm_login state and send a login
complete message to fcs). This results in a zero PID assignment as the
login is not really complete.

This fix is to correctly handle the events in lps state machine.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_svc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c
index 299c1c8..7ed2c57 100644
--- a/drivers/scsi/bfa/bfa_svc.c
+++ b/drivers/scsi/bfa/bfa_svc.c
@@ -1276,7 +1276,6 @@ bfa_lps_sm_login(struct bfa_lps_s *lps, enum 
bfa_lps_event event)
 
switch (event) {
case BFA_LPS_SM_FWRSP:
-   case BFA_LPS_SM_OFFLINE:
if (lps-status == BFA_STATUS_OK) {
bfa_sm_set_state(lps, bfa_lps_sm_online);
if (lps-fdisc)
@@ -1305,6 +1304,7 @@ bfa_lps_sm_login(struct bfa_lps_s *lps, enum 
bfa_lps_event event)
bfa_lps_login_comp(lps);
break;
 
+   case BFA_LPS_SM_OFFLINE:
case BFA_LPS_SM_DELETE:
bfa_sm_set_state(lps, bfa_lps_sm_init);
break;
-- 
1.8.2.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 02/17] bfa: Forward Error Correction status query

2013-05-13 Thread Vijaya Mohan Guvva
This patch includes changes to get FC HBA feature Forward Error
Correction (FEC) (enabled at 16Gig speed) status from firmware and to
return to brocade HBA management utility.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_defs_svc.h | 15 +--
 drivers/scsi/bfa/bfa_svc.c  |  8 
 drivers/scsi/bfa/bfa_svc.h  |  1 +
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index efbf0a9..8522475 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -882,6 +882,15 @@ enum bfa_lunmask_state_s {
BFA_LUNMASK_UNINITIALIZED = 0xff,
 };
 
+/**
+ * FEC states
+ */
+enum bfa_fec_state_s {
+   BFA_FEC_ONLINE = 1, /*! FEC is online */
+   BFA_FEC_OFFLINE = 2,/*! FEC is offline */
+   BFA_FEC_OFFLINE_NOT_16G = 3,/*! FEC is offline (speed not 16Gig) */
+};
+
 #pragma pack(1)
 /*
  * LUN mask configuration
@@ -978,6 +987,7 @@ struct bfa_port_attr_s {
bfa_boolean_t   link_e2e_beacon; /* link beacon is on */
bfa_boolean_t   bbsc_op_status; /* fc credit recovery oper
 * state */
+   enum bfa_fec_state_sfec_state;  /*! current FEC state */
 
/*
 * Dynamic field - info from FCS
@@ -989,7 +999,7 @@ struct bfa_port_attr_s {
 
/* FCoE specific  */
u16 fcoe_vlan;
-   u8  rsvd1[6];
+   u8  rsvd1[2];
 };
 
 /*
@@ -1076,7 +1086,8 @@ struct bfa_port_link_s {
u8   speed; /*  Link speed (1/2/4/8 G) */
u32  linkstate_opt; /*  Linkstate optional data (debug) */
u8   trunked;   /*  Trunked or not (1 or 0) */
-   u8   resvd[7];
+   u8   fec_state; /*! State of FEC */
+   u8   resvd[6];
struct bfa_qos_attr_s  qos_attr;   /* QoS Attributes */
union {
struct bfa_fcport_loop_info_s loop_info;
diff --git a/drivers/scsi/bfa/bfa_svc.c b/drivers/scsi/bfa/bfa_svc.c
index 0fff5ec..60ebcc9 100644
--- a/drivers/scsi/bfa/bfa_svc.c
+++ b/drivers/scsi/bfa/bfa_svc.c
@@ -3079,6 +3079,8 @@ bfa_fcport_attach(struct bfa_s *bfa, void *bfad, struct 
bfa_iocfc_cfg_s *cfg,
port_cfg-qos_bw.med = BFA_QOS_BW_MED;
port_cfg-qos_bw.low = BFA_QOS_BW_LOW;
 
+   fcport-fec_state = BFA_FEC_OFFLINE;
+
INIT_LIST_HEAD(fcport-stats_pending_q);
INIT_LIST_HEAD(fcport-statsclr_pending_q);
 
@@ -3157,6 +3159,9 @@ bfa_fcport_update_linkinfo(struct bfa_fcport_s *fcport)
 
if (fcport-cfg.bb_cr_enabled)
fcport-bbcr_attr = pevent-link_state.attr.bbcr_attr;
+
+   fcport-fec_state = pevent-link_state.fec_state;
+
/*
 * update trunk state if applicable
 */
@@ -3176,6 +3181,7 @@ bfa_fcport_reset_linkinfo(struct bfa_fcport_s *fcport)
 {
fcport-speed = BFA_PORT_SPEED_UNKNOWN;
fcport-topology = BFA_PORT_TOPOLOGY_NONE;
+   fcport-fec_state = BFA_FEC_OFFLINE;
 }
 
 /*
@@ -4027,6 +4033,8 @@ bfa_fcport_get_attr(struct bfa_s *bfa, struct 
bfa_port_attr_s *attr)
attr-pport_cfg.q_depth  = bfa_fcpim_qdepth_get(bfa);
attr-port_state = bfa_sm_to_state(hal_port_sm_table, fcport-sm);
 
+   attr-fec_state = fcport-fec_state;
+
/* PBC Disabled State */
if (bfa_fcport_is_pbcdisabled(bfa))
attr-port_state = BFA_PORT_ST_PREBOOT_DISABLED;
diff --git a/drivers/scsi/bfa/bfa_svc.h b/drivers/scsi/bfa/bfa_svc.h
index c2fb834..810bd9c 100644
--- a/drivers/scsi/bfa/bfa_svc.h
+++ b/drivers/scsi/bfa/bfa_svc.h
@@ -513,6 +513,7 @@ struct bfa_fcport_s {
struct bfa_mem_dma_sfcport_dma;
bfa_boolean_t   stats_dma_ready;
struct bfa_bbcr_attr_s  bbcr_attr;
+   enum bfa_fec_state_sfec_state;
 };
 
 #define BFA_FCPORT_MOD(__bfa)  ((__bfa)-modules.fcport)
-- 
1.7.12

--
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 09/17] bfa: driver compatibility with 32bit libs

2013-05-13 Thread Vijaya Mohan Guvva
Replaced usage of void * with u64 in data structure shared between
brocade user space libraries and the bfa driver to address pointer
size changes across 32-bit vs 64-bit to have the compatibility between
32bit library and 64bit driver and vice versa.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfad_bsg.c | 7 ---
 drivers/scsi/bfa/bfad_bsg.h | 4 +++-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index f31acfa..9863b1c 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -3371,7 +3371,8 @@ bfad_im_bsg_els_ct_request(struct fc_bsg_job *job)
goto out;
}
 
-   if (copy_from_user((uint8_t *)bsg_fcpt, bsg_data-payload,
+   if (copy_from_user((uint8_t *)bsg_fcpt,
+   (void *)(unsigned long)bsg_data-payload,
bsg_data-payload_len)) {
kfree(bsg_fcpt);
rc = -EIO;
@@ -3525,8 +3526,8 @@ out_free_mem:
kfree(rsp_kbuf);
 
/* Need a copy to user op */
-   if (copy_to_user(bsg_data-payload, (void *) bsg_fcpt,
-bsg_data-payload_len))
+   if (copy_to_user((void *)(unsigned long)bsg_data-payload,
+   (void *)bsg_fcpt, bsg_data-payload_len))
rc = -EIO;
 
kfree(bsg_fcpt);
diff --git a/drivers/scsi/bfa/bfad_bsg.h b/drivers/scsi/bfa/bfad_bsg.h
index 3ef321c..b0b5ac7 100644
--- a/drivers/scsi/bfa/bfad_bsg.h
+++ b/drivers/scsi/bfa/bfad_bsg.h
@@ -819,10 +819,12 @@ struct bfa_bsg_fcpt_s {
 };
 #define bfa_bsg_fcpt_t struct bfa_bsg_fcpt_s
 
+#pragma pack(1)
 struct bfa_bsg_data {
int payload_len;
-   void *payload;
+   u64 payload;
 };
+#pragma pack()
 
 #define bfad_chk_iocmd_sz(__payload_len, __hdrsz, __bufsz) \
(((__payload_len) != ((__hdrsz) + (__bufsz))) ? \
-- 
1.7.12

--
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 08/17] bfa: kdump fix on 815 and 825 adapters

2013-05-13 Thread Vijaya Mohan Guvva
Root cause: When kernel crashes, On brocade 815/825 adapters,
 bfa IOC state machine and FW doesn't get a notification and
hence are not cleanly shutdown. So registers holding driver/IOC
state information are not reset back to valid disabled/parking
values. This causes subsequent driver initialization to fail
during kdump kernel boot.

Fix description: during the initialization of first PCI function, reset
corresponding register when unclean shutown is detect by reading chip
registers. This will make sure that ioc/fw gets clean re-initialization.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_ioc.c| 42 -
 drivers/scsi/bfa/bfa_ioc.h|  6 +++
 drivers/scsi/bfa/bfa_ioc_cb.c | 86 +++
 drivers/scsi/bfa/bfa_ioc_ct.c | 36 ++
 drivers/scsi/bfa/bfi.h|  4 ++
 5 files changed, 150 insertions(+), 24 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index 0116c10..8928b68 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -67,6 +67,14 @@ BFA_TRC_FILE(CNA, IOC);
((__ioc)-ioc_hwif-ioc_sync_ack(__ioc))
 #define bfa_ioc_sync_complete(__ioc)\
((__ioc)-ioc_hwif-ioc_sync_complete(__ioc))
+#define bfa_ioc_set_cur_ioc_fwstate(__ioc, __fwstate)  \
+   ((__ioc)-ioc_hwif-ioc_set_fwstate(__ioc, __fwstate))
+#define bfa_ioc_get_cur_ioc_fwstate(__ioc) \
+   ((__ioc)-ioc_hwif-ioc_get_fwstate(__ioc))
+#define bfa_ioc_set_alt_ioc_fwstate(__ioc, __fwstate)  \
+   ((__ioc)-ioc_hwif-ioc_set_alt_fwstate(__ioc, __fwstate))
+#define bfa_ioc_get_alt_ioc_fwstate(__ioc) \
+   ((__ioc)-ioc_hwif-ioc_get_alt_fwstate(__ioc))
 
 #define bfa_ioc_mbox_cmd_pending(__ioc)\
(!list_empty(((__ioc)-mbox_mod.cmd_q)) || \
@@ -698,7 +706,7 @@ bfa_iocpf_sm_fwcheck_entry(struct bfa_iocpf_s *iocpf)
}
 
/* h/w sem init */
-   fwstate = readl(iocpf-ioc-ioc_regs.ioc_fwstate);
+   fwstate = bfa_ioc_get_cur_ioc_fwstate(iocpf-ioc);
if (fwstate == BFI_IOC_UNINIT) {
writel(1, iocpf-ioc-ioc_regs.ioc_init_sem_reg);
goto sem_get;
@@ -725,8 +733,8 @@ bfa_iocpf_sm_fwcheck_entry(struct bfa_iocpf_s *iocpf)
 
bfa_trc(iocpf-ioc, fwstate);
bfa_trc(iocpf-ioc, swab32(fwhdr.exec));
-   writel(BFI_IOC_UNINIT, iocpf-ioc-ioc_regs.ioc_fwstate);
-   writel(BFI_IOC_UNINIT, iocpf-ioc-ioc_regs.alt_ioc_fwstate);
+   bfa_ioc_set_cur_ioc_fwstate(iocpf-ioc, BFI_IOC_UNINIT);
+   bfa_ioc_set_alt_ioc_fwstate(iocpf-ioc, BFI_IOC_UNINIT);
 
/*
 * Unlock the hw semaphore. Should be here only once per boot.
@@ -1037,7 +1045,7 @@ bfa_iocpf_sm_disabling(struct bfa_iocpf_s *iocpf, enum 
iocpf_event event)
 */
 
case IOCPF_E_TIMEOUT:
-   writel(BFI_IOC_FAIL, ioc-ioc_regs.ioc_fwstate);
+   bfa_ioc_set_cur_ioc_fwstate(ioc, BFI_IOC_FAIL);
bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling_sync);
break;
 
@@ -1138,7 +1146,7 @@ bfa_iocpf_sm_initfail_sync(struct bfa_iocpf_s *iocpf, 
enum iocpf_event event)
case IOCPF_E_SEMLOCKED:
bfa_ioc_notify_fail(ioc);
bfa_ioc_sync_leave(ioc);
-   writel(BFI_IOC_FAIL, ioc-ioc_regs.ioc_fwstate);
+   bfa_ioc_set_cur_ioc_fwstate(ioc, BFI_IOC_FAIL);
writel(1, ioc-ioc_regs.ioc_sem_reg);
bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail);
break;
@@ -1227,7 +1235,7 @@ bfa_iocpf_sm_fail_sync(struct bfa_iocpf_s *iocpf, enum 
iocpf_event event)
bfa_ioc_notify_fail(ioc);
if (!iocpf-auto_recover) {
bfa_ioc_sync_leave(ioc);
-   writel(BFI_IOC_FAIL, ioc-ioc_regs.ioc_fwstate);
+   bfa_ioc_set_cur_ioc_fwstate(ioc, BFI_IOC_FAIL);
writel(1, ioc-ioc_regs.ioc_sem_reg);
bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail);
} else {
@@ -1519,7 +1527,7 @@ bfa_ioc_hwinit(struct bfa_ioc_s *ioc, bfa_boolean_t force)
u32 boot_type;
u32 boot_env;
 
-   ioc_fwstate = readl(ioc-ioc_regs.ioc_fwstate);
+   ioc_fwstate = bfa_ioc_get_cur_ioc_fwstate(ioc);
 
if (force)
ioc_fwstate = BFI_IOC_UNINIT;
@@ -2006,11 +2014,11 @@ bfa_ioc_boot(struct bfa_ioc_s *ioc, u32 boot_type, u32 
boot_env)
 * Initialize IOC state of all functions on a chip reset.
 */
if (boot_type == BFI_FWBOOT_TYPE_MEMTEST) {
-   writel(BFI_IOC_MEMTEST, ioc-ioc_regs.ioc_fwstate);
-   writel(BFI_IOC_MEMTEST, ioc-ioc_regs.alt_ioc_fwstate);
+   bfa_ioc_set_cur_ioc_fwstate(ioc, BFI_IOC_MEMTEST);
+   

[PATCH V1 12/17] bfa: Allow rsp queue process during ioc disable

2013-05-13 Thread Vijaya Mohan Guvva
Allow processing completions from firmware during IOC_DISABLE request is
being processed by the firmware, by setting the queue_process flag
appropriately.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_core.c b/drivers/scsi/bfa/bfa_core.c
index 342d7d9..520540a 100644
--- a/drivers/scsi/bfa/bfa_core.c
+++ b/drivers/scsi/bfa/bfa_core.c
@@ -1432,6 +1432,7 @@ bfa_iocfc_disable_cbfn(void *bfa_arg)
 {
struct bfa_s*bfa = bfa_arg;
 
+   bfa-queue_process = BFA_FALSE;
bfa_fsm_send_event(bfa-iocfc, IOCFC_E_IOC_DISABLED);
 }
 
@@ -1567,7 +1568,6 @@ bfa_iocfc_start(struct bfa_s *bfa)
 void
 bfa_iocfc_stop(struct bfa_s *bfa)
 {
-   bfa-queue_process = BFA_FALSE;
bfa_fsm_send_event(bfa-iocfc, IOCFC_E_STOP);
 }
 
@@ -1674,7 +1674,6 @@ bfa_iocfc_disable(struct bfa_s *bfa)
bfa_plog_str(bfa-plog, BFA_PL_MID_HAL, BFA_PL_EID_MISC, 0,
 IOC Disable);
 
-   bfa-queue_process = BFA_FALSE;
bfa_fsm_send_event(bfa-iocfc, IOCFC_E_DISABLE);
 }
 
-- 
1.7.12

--
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 06/17] bfa: Fix 1860 port initialize when ATC is enabled

2013-05-13 Thread Vijaya Mohan Guvva
On Xen kernels, if ATC (address translation cache) is enabled, the
first PCIe DMA read from the adapter fails with an error. This is due to
a bug ASIC, which leads to a failure of 1860 ports to be initialised.

This patch includes the fix to disable Invalidated Tag Match Enable
capability by setting the bit 26 of CHIP_MISC_PRG to 0, by default it is
set to 1.

Signed-off-by: Anil Gurumurthy aguru...@brocade.com
Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_ioc_ct.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/scsi/bfa/bfa_ioc_ct.c b/drivers/scsi/bfa/bfa_ioc_ct.c
index de4e726..a8e52a1 100644
--- a/drivers/scsi/bfa/bfa_ioc_ct.c
+++ b/drivers/scsi/bfa/bfa_ioc_ct.c
@@ -918,6 +918,16 @@ bfa_ioc_ct2_pll_init(void __iomem *rb, enum bfi_asic_mode 
mode)
 
}
}
+   /*
+   * The very first PCIe DMA Read done by LPU fails with a fatal error,
+   * when Address Translation Cache (ATC) has been enabled by system BIOS.
+   *
+   * Workaround:
+   * Disable Invalidated Tag Match Enable capability by setting the bit 26
+   * of CHIP_MISC_PRG to 0, by default it is set to 1.
+   */
+   r32 = readl(rb + CT2_CHIP_MISC_PRG);
+   writel((r32  0xfbff), (rb + CT2_CHIP_MISC_PRG));
 
/*
 * Mask the interrupts and clear any
-- 
1.7.12

--
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 04/17] bfa: Fix WARN_ON condition check

2013-05-13 Thread Vijaya Mohan Guvva
The WARN_ON condition check in IO completion path is wrong. IOtags
returned by the firmware is compared with driver/bfa iotag after masking
the retry count bits.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_fcpim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bfa/bfa_fcpim.c b/drivers/scsi/bfa/bfa_fcpim.c
index 27b5609..d7385d1 100644
--- a/drivers/scsi/bfa/bfa_fcpim.c
+++ b/drivers/scsi/bfa/bfa_fcpim.c
@@ -2882,7 +2882,7 @@ bfa_ioim_good_comp_isr(struct bfa_s *bfa, struct 
bfi_msg_s *m)
iotag = be16_to_cpu(rsp-io_tag);
 
ioim = BFA_IOIM_FROM_TAG(fcpim, iotag);
-   WARN_ON(BFA_IOIM_TAG_2_ID(ioim-iotag) != iotag);
+   WARN_ON(ioim-iotag != iotag);
 
bfa_ioim_cb_profile_comp(fcpim, ioim);
 
-- 
1.7.12

--
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 17/17] bfa: Update the driver version to 3.2.21.1

2013-05-13 Thread Vijaya Mohan Guvva
Update bfa driver version to 3.2.21.1
Update bfa to use firmware image versions 3.2.1.0

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfad.c | 6 +++---
 drivers/scsi/bfa/bfad_drv.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index bf5c5d3..9611195 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -63,9 +63,9 @@ int   max_rport_logins = BFA_FCS_MAX_RPORT_LOGINS;
 u32bfi_image_cb_size, bfi_image_ct_size, bfi_image_ct2_size;
 u32*bfi_image_cb, *bfi_image_ct, *bfi_image_ct2;
 
-#define BFAD_FW_FILE_CBcbfw-3.1.0.0.bin
-#define BFAD_FW_FILE_CTctfw-3.1.0.0.bin
-#define BFAD_FW_FILE_CT2   ct2fw-3.1.0.0.bin
+#define BFAD_FW_FILE_CBcbfw-3.2.1.0.bin
+#define BFAD_FW_FILE_CTctfw-3.2.1.0.bin
+#define BFAD_FW_FILE_CT2   ct2fw-3.2.1.0.bin
 
 static u32 *bfad_load_fwimg(struct pci_dev *pdev);
 static void bfad_free_fwimg(void);
diff --git a/drivers/scsi/bfa/bfad_drv.h b/drivers/scsi/bfa/bfad_drv.h
index 0c64a04..78d3401 100644
--- a/drivers/scsi/bfa/bfad_drv.h
+++ b/drivers/scsi/bfa/bfad_drv.h
@@ -57,7 +57,7 @@
 #ifdef BFA_DRIVER_VERSION
 #define BFAD_DRIVER_VERSIONBFA_DRIVER_VERSION
 #else
-#define BFAD_DRIVER_VERSION3.1.2.1
+#define BFAD_DRIVER_VERSION3.2.21.1
 #endif
 
 #define BFAD_PROTO_NAME FCPI_NAME
-- 
1.7.12

--
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 11/17] bfa: firmware statistics update

2013-05-13 Thread Vijaya Mohan Guvva
Get RDS drop interrupts and REC (Read Exchange Concise) related stats
from firmware.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_defs_svc.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index 3e8e224..d151e2b 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -105,6 +105,9 @@ struct bfa_fw_ioim_stats_s {
 *  an error condition*/
u32 wait_for_si;/*  FW wait for SI */
u32 rec_rsp_inval;  /*  REC rsp invalid */
+   u32 rec_rsp_xchg_comp;  /*  REC rsp xchg complete */
+   u32 rec_rsp_rd_si_ownd; /*  REC rsp read si owned */
+
u32 seqr_io_abort;  /*  target does not know cmd so abort */
u32 seqr_io_retry;  /*  SEQR failed so retry IO */
 
@@ -483,6 +486,14 @@ struct bfa_fw_ct_mod_stats_s {
 };
 
 /*
+ * RDS mod stats
+ */
+struct bfa_fw_rds_stats_s {
+   u32 no_fid_drop_err; /* RDS no fid drop error */
+   u32 rsvd;/* 64bit align */
+};
+
+/*
  * IOC firmware stats
  */
 struct bfa_fw_stats_s {
@@ -497,6 +508,7 @@ struct bfa_fw_stats_s {
struct bfa_fw_mac_mod_stats_s   macmod_stats;
struct bfa_fw_ct_mod_stats_sctmod_stats;
struct bfa_fw_eth_sndrcv_stats_sethsndrcv_stats;
+   struct bfa_fw_rds_stats_s   rds_stats;
 };
 
 #define BFA_IOCFC_PATHTOV_MAX  60
-- 
1.7.12

--
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 16/17] bfa: dis-associate bfa path_tov with dev_loss_tmo

2013-05-13 Thread Vijaya Mohan Guvva
Disassoicate path_tov in the driver with the dev_loss_tmo set by the
application.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfad_attr.c | 33 +++--
 1 file changed, 7 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_attr.c b/drivers/scsi/bfa/bfad_attr.c
index 72f5dc3..e9a681d 100644
--- a/drivers/scsi/bfa/bfad_attr.c
+++ b/drivers/scsi/bfa/bfad_attr.c
@@ -335,23 +335,10 @@ bfad_im_reset_stats(struct Scsi_Host *shost)
 }
 
 /*
- * FC transport template entry, get rport loss timeout.
- */
-static void
-bfad_im_get_rport_loss_tmo(struct fc_rport *rport)
-{
-   struct bfad_itnim_data_s *itnim_data = rport-dd_data;
-   struct bfad_itnim_s   *itnim = itnim_data-itnim;
-   struct bfad_s *bfad = itnim-im-bfad;
-   unsigned long   flags;
-
-   spin_lock_irqsave(bfad-bfad_lock, flags);
-   rport-dev_loss_tmo = bfa_fcpim_path_tov_get(bfad-bfa);
-   spin_unlock_irqrestore(bfad-bfad_lock, flags);
-}
-
-/*
  * FC transport template entry, set rport loss timeout.
+ * Update dev_loss_tmo based on the value pushed down by the stack
+ * In case it is lesser than path_tov of driver, set it to path_tov + 1
+ * to ensure that the driver times out before the application
  */
 static void
 bfad_im_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout)
@@ -359,15 +346,11 @@ bfad_im_set_rport_loss_tmo(struct fc_rport *rport, u32 
timeout)
struct bfad_itnim_data_s *itnim_data = rport-dd_data;
struct bfad_itnim_s   *itnim = itnim_data-itnim;
struct bfad_s *bfad = itnim-im-bfad;
-   unsigned long   flags;
-
-   if (timeout  0) {
-   spin_lock_irqsave(bfad-bfad_lock, flags);
-   bfa_fcpim_path_tov_set(bfad-bfa, timeout);
-   rport-dev_loss_tmo = bfa_fcpim_path_tov_get(bfad-bfa);
-   spin_unlock_irqrestore(bfad-bfad_lock, flags);
-   }
+   uint16_t path_tov = bfa_fcpim_path_tov_get(bfad-bfa);
 
+   rport-dev_loss_tmo = timeout;
+   if (timeout  path_tov)
+   rport-dev_loss_tmo = path_tov + 1;
 }
 
 static int
@@ -665,7 +648,6 @@ struct fc_function_template bfad_im_fc_function_template = {
.show_rport_maxframe_size = 1,
.show_rport_supported_classes = 1,
.show_rport_dev_loss_tmo = 1,
-   .get_rport_dev_loss_tmo = bfad_im_get_rport_loss_tmo,
.set_rport_dev_loss_tmo = bfad_im_set_rport_loss_tmo,
.issue_fc_host_lip = bfad_im_issue_fc_host_lip,
.vport_create = bfad_im_vport_create,
@@ -723,7 +705,6 @@ struct fc_function_template 
bfad_im_vport_fc_function_template = {
.show_rport_maxframe_size = 1,
.show_rport_supported_classes = 1,
.show_rport_dev_loss_tmo = 1,
-   .get_rport_dev_loss_tmo = bfad_im_get_rport_loss_tmo,
.set_rport_dev_loss_tmo = bfad_im_set_rport_loss_tmo,
 };
 
-- 
1.7.12

--
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 01/17] bfa: Support for FC BB credit recovery

2013-05-13 Thread Vijaya Mohan Guvva
This patch includes changes to  1) Enable/disable fc credit recovery on
Brocade FC adapter port operating at max supported speed. 2) Get credit
recovery status and stats related to credit loss and recovered credits

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_defs.h  | 10 +
 drivers/scsi/bfa/bfa_defs_svc.h  | 49 +
 drivers/scsi/bfa/bfa_fcs.c   | 62 +++---
 drivers/scsi/bfa/bfa_fcs.h   |  5 ---
 drivers/scsi/bfa/bfa_fcs_rport.c |  2 +-
 drivers/scsi/bfa/bfa_svc.c   | 95 +++-
 drivers/scsi/bfa/bfa_svc.h   | 12 ++---
 drivers/scsi/bfa/bfad_bsg.c  | 47 ++--
 drivers/scsi/bfa/bfad_bsg.h  | 19 +++-
 drivers/scsi/bfa/bfi_ms.h|  5 +--
 10 files changed, 202 insertions(+), 104 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
index 0efdf31..bdd1bae 100644
--- a/drivers/scsi/bfa/bfa_defs.h
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -185,6 +185,8 @@ enum bfa_status {
BFA_STATUS_FAA_DISABLED = 198,  /* FAA is already disabled */
BFA_STATUS_FAA_ACQUIRED = 199,  /* FAA is already acquired */
BFA_STATUS_FAA_ACQ_ADDR = 200,  /* Acquiring addr */
+   BFA_STATUS_BBCR_FC_ONLY = 201, /*! BBCredit Recovery is supported for *
+   * FC mode only */
BFA_STATUS_ERROR_TRUNK_ENABLED = 203,   /* Trunk enabled on adapter */
BFA_STATUS_MAX_ENTRY_REACHED = 212, /* MAX entry reached */
BFA_STATUS_TOPOLOGY_LOOP = 230, /* Topology is set to Loop */
@@ -198,6 +200,14 @@ enum bfa_status {
BFA_STATUS_CMD_NOTSUPP_MEZZ = 239, /* Cmd not supported for MEZZ card */
BFA_STATUS_FRU_NOT_PRESENT = 240, /* fru module not present */
BFA_STATUS_DPORT_ERR = 245, /* D-port mode is enabled */
+   BFA_STATUS_ERR_BBCR_SPEED_UNSUPPORT = 258, /*! BB credit recovery is
+   * supported at max port speed alone */
+   BFA_STATUS_ERROR_BBCR_ENABLED  = 259, /*! BB credit recovery
+   * is enabled */
+   BFA_STATUS_INVALID_BBSCN = 260, /*! Invalid BBSCN value.
+* Valid range is [1-15] */
+   BFA_STATUS_BBCR_CFG_NO_CHANGE = 265, /*! BBCR is operational.
+   * Disable BBCR and try this operation again. */
BFA_STATUS_MAX_VAL  /* Unknown error code */
 };
 #define bfa_status_t enum bfa_status
diff --git a/drivers/scsi/bfa/bfa_defs_svc.h b/drivers/scsi/bfa/bfa_defs_svc.h
index ec03c8c..efbf0a9 100644
--- a/drivers/scsi/bfa/bfa_defs_svc.h
+++ b/drivers/scsi/bfa/bfa_defs_svc.h
@@ -257,8 +257,6 @@ struct bfa_fw_port_lksm_stats_s {
u32nos_tx; /*  No. of times NOS tx started */
u32hwsm_lrr_rx;/*  No. of times LRR rx-ed by HWSM  */
u32hwsm_lr_rx; /*  No. of times LR rx-ed by HWSM   */
-   u32bbsc_lr;/* LKSM LR tx for credit recovery   */
-   u32 rsvd;
 };
 
 struct bfa_fw_port_snsm_stats_s {
@@ -409,7 +407,7 @@ struct bfa_fw_trunk_stats_s {
u32 rsvd;   /*  padding for 64 bit alignment */
 };
 
-struct bfa_fw_advsm_stats_s {
+struct bfa_fw_aport_stats_s {
u32 flogi_sent; /*  Flogi sent  */
u32 flogi_acc_recvd;/*  Flogi Acc received  */
u32 flogi_rjt_recvd;/*  Flogi rejects received  */
@@ -419,6 +417,12 @@ struct bfa_fw_advsm_stats_s {
u32 elp_accepted;   /*  ELP Accepted*/
u32 elp_rejected;   /*  ELP rejected*/
u32 elp_dropped;/*  ELP dropped */
+
+   u32 bbcr_lr_count;  /*! BBCR Link Resets   */
+   u32 frame_lost_intrs;   /*! BBCR Frame loss intrs  */
+   u32 rrdy_lost_intrs;/*! BBCR Rrdy loss intrs   */
+
+   u32 rsvd;
 };
 
 /*
@@ -489,7 +493,7 @@ struct bfa_fw_stats_s {
struct bfa_fw_fcxchg_stats_sfcxchg_stats;
struct bfa_fw_lps_stats_s   lps_stats;
struct bfa_fw_trunk_stats_s trunk_stats;
-   struct bfa_fw_advsm_stats_s advsm_stats;
+   struct bfa_fw_aport_stats_s aport_stats;
struct bfa_fw_mac_mod_stats_s   macmod_stats;
struct bfa_fw_ct_mod_stats_sctmod_stats;
struct bfa_fw_eth_sndrcv_stats_sethsndrcv_stats;
@@ -545,6 +549,27 @@ struct bfa_qos_attr_s {
struct bfa_qos_bw_s qos_bw_op;  /* QOS bw operational */
 };
 
+enum bfa_bbcr_state {
+   BFA_BBCR_DISABLED,  /*! BBCR is disable */
+   BFA_BBCR_ONLINE,/*! BBCR is online  */
+   BFA_BBCR_OFFLINE,   /*! BBCR is offline */
+};
+
+enum bfa_bbcr_err_reason {
+   BFA_BBCR_ERR_REASON_NONE, /*! Unknown */
+   BFA_BBCR_ERR_REASON_SPEED_UNSUP, /*! Port speed  max sup_speed */
+   

[PATCH] bfa: fix for FC Direct Attach LUN discovery failure

2013-05-13 Thread Vijay Mohan Guvva
Resending the patch as it didn't make the linux-scsi list.

This patch fixes fcs rport state machine to address ocassional Brocade
FC Direct Attach LUN discovery failure due to not sending PLOGI accept
to the target.

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_fcs_rport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_fcs_rport.c b/drivers/scsi/bfa/bfa_fcs_rport.c
index 58ac643..610ca95 100644
--- a/drivers/scsi/bfa/bfa_fcs_rport.c
+++ b/drivers/scsi/bfa/bfa_fcs_rport.c
@@ -189,8 +189,8 @@ bfa_fcs_rport_sm_uninit(struct bfa_fcs_rport_s *rport, enum 
rport_event event)
break;
 
case RPSM_EVENT_PLOGI_RCVD:
-   bfa_sm_set_state(rport, bfa_fcs_rport_sm_fc4_fcs_online);
-   bfa_fcs_rport_fcs_online_action(rport);
+   bfa_sm_set_state(rport, bfa_fcs_rport_sm_plogiacc_sending);
+   bfa_fcs_rport_send_plogiacc(rport, NULL);
break;
 
case RPSM_EVENT_PLOGI_COMP:
-- 
1.8.2.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 00/17] Update the driver version to 3.2.21.1

2013-05-13 Thread Vijaya Mohan Guvva
Hi James,
Re-submitting the patch sets, Update the driver version to 3.2.21.0 and
Update the driver version to 3.2.21.1.
It includes bug-fixes, changes to use firmware version 3.2.1.0, adds new
features such as Forward Error Correction, FC BB credit recovery, dynamic
diagnostic Port (D-port), enabled support for new hardware - chinook quad
and updates the Brocade BFA driver to v3.2.21.1.

Thanks,
Vijaya Mohan Guvva

Vijaya Mohan Guvva (17):
  bfa: Support for FC BB credit recovery
  bfa: Forward Error Correction status query
  bfa: Add dynamic diagnostic port support
  bfa: Fix WARN_ON condition check
  bfa: FDMI enhancements
  bfa: Fix 1860 port initialize when ATC is enabled
  bfa: Fix FDISC timeout handling
  bfa: kdump fix on 815 and 825 adapters
  bfa: driver compatibility with 32bit libs
  bfa: fru vpd date update changes
  bfa: firmware statistics update
  bfa: Allow rsp queue process during ioc disable
  bfa: Fix bug_on condition in RPSC rsp handling
  bfa: fix endianess issue for firmware stats
  bfa: Support for chinook-quad port card
  bfa: dis-associate bfa path_tov with dev_loss_tmo
  bfa: Update the driver version to 3.2.21.1

 drivers/scsi/bfa/bfa_core.c  |   3 +-
 drivers/scsi/bfa/bfa_defs.h  | 103 +-
 drivers/scsi/bfa/bfa_defs_svc.h  |  77 -
 drivers/scsi/bfa/bfa_fc.h|  15 +
 drivers/scsi/bfa/bfa_fcpim.c |   2 +-
 drivers/scsi/bfa/bfa_fcs.c   |  62 +---
 drivers/scsi/bfa/bfa_fcs.h   |  34 +-
 drivers/scsi/bfa/bfa_fcs_lport.c | 209 +++-
 drivers/scsi/bfa/bfa_fcs_rport.c |   7 +-
 drivers/scsi/bfa/bfa_ioc.c   |  74 +++--
 drivers/scsi/bfa/bfa_ioc.h   |   9 +-
 drivers/scsi/bfa/bfa_ioc_cb.c|  86 -
 drivers/scsi/bfa/bfa_ioc_ct.c|  46 +++
 drivers/scsi/bfa/bfa_svc.c   | 698 ---
 drivers/scsi/bfa/bfa_svc.h   |  34 +-
 drivers/scsi/bfa/bfad.c  |  14 +-
 drivers/scsi/bfa/bfad_attr.c |  33 +-
 drivers/scsi/bfa/bfad_bsg.c  | 137 +---
 drivers/scsi/bfa/bfad_bsg.h  |  52 ++-
 drivers/scsi/bfa/bfad_drv.h  |   2 +-
 drivers/scsi/bfa/bfi.h   |  78 -
 drivers/scsi/bfa/bfi_ms.h|   5 +-
 22 files changed, 1498 insertions(+), 282 deletions(-)

-- 
1.7.12

--
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 03/17] bfa: Add dynamic diagnostic port support

2013-05-13 Thread Vijaya Mohan Guvva
D-Port is a new port type created with the intention of running link
level diagnostic tests like loopback, traffic test. In static D-port
mode, user configures the port to D-port mode and starts the test, but
in dynamic D-port, once the Brocade switch port is configured to
D-port, it will reject the regular FLOGI from HBA with reason that it is
in D-port mode. So based on the reason code HBA port will turn itself into
D-port and start diagnostic test.

Signed-off-by: Sudarsana Reddy Kalluru skall...@brocade.com
Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_defs.h |  79 +-
 drivers/scsi/bfa/bfa_defs_svc.h |   1 +
 drivers/scsi/bfa/bfa_svc.c  | 595 +---
 drivers/scsi/bfa/bfa_svc.h  |  21 +-
 drivers/scsi/bfa/bfad_bsg.c |  81 --
 drivers/scsi/bfa/bfad_bsg.h |  25 +-
 drivers/scsi/bfa/bfi.h  |  68 -
 7 files changed, 781 insertions(+), 89 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_defs.h b/drivers/scsi/bfa/bfa_defs.h
index bdd1bae..d65a9b4 100644
--- a/drivers/scsi/bfa/bfa_defs.h
+++ b/drivers/scsi/bfa/bfa_defs.h
@@ -199,15 +199,34 @@ enum bfa_status {
BFA_STATUS_DPORT_DISABLED = 236, /* D-port mode is already disabled */
BFA_STATUS_CMD_NOTSUPP_MEZZ = 239, /* Cmd not supported for MEZZ card */
BFA_STATUS_FRU_NOT_PRESENT = 240, /* fru module not present */
+   BFA_STATUS_DPORT_NO_SFP = 243, /* SFP is not present.\n D-port will be
+   * enabled but it will be operational
+   * only after inserting a valid SFP. */
BFA_STATUS_DPORT_ERR = 245, /* D-port mode is enabled */
+   BFA_STATUS_DPORT_ENOSYS = 254, /* Switch has no D_Port functionality */
+   BFA_STATUS_DPORT_CANT_PERF = 255, /* Switch port is not D_Port capable
+   * or D_Port is disabled */
+   BFA_STATUS_DPORT_LOGICALERR = 256, /* Switch D_Port fail */
+   BFA_STATUS_DPORT_SWBUSY = 257, /* Switch port busy */
BFA_STATUS_ERR_BBCR_SPEED_UNSUPPORT = 258, /*! BB credit recovery is
* supported at max port speed alone */
BFA_STATUS_ERROR_BBCR_ENABLED  = 259, /*! BB credit recovery
* is enabled */
BFA_STATUS_INVALID_BBSCN = 260, /*! Invalid BBSCN value.
 * Valid range is [1-15] */
+   BFA_STATUS_DDPORT_ERR = 261, /* Dynamic D_Port mode is active.\n To
+   * exit dynamic mode, disable D_Port on
+   * the remote port */
+   BFA_STATUS_DPORT_SFPWRAP_ERR = 262, /* Clear e/o_wrap fail, check or
+   * replace SFP */
BFA_STATUS_BBCR_CFG_NO_CHANGE = 265, /*! BBCR is operational.
* Disable BBCR and try this operation again. */
+   BFA_STATUS_DPORT_SW_NOTREADY = 268, /* Remote port is not ready to
+   * start dport test. Check remote
+   * port status. */
+   BFA_STATUS_DPORT_INV_SFP = 271, /* Invalid SFP for D-PORT mode. */
+   BFA_STATUS_DPORT_CMD_NOTSUPP= 273, /* Dport is not supported by
+   * remote port */
BFA_STATUS_MAX_VAL  /* Unknown error code */
 };
 #define bfa_status_t enum bfa_status
@@ -527,17 +546,6 @@ struct bfa_ioc_aen_data_s {
 };
 
 /*
- * D-port states
- *
-*/
-enum bfa_dport_state {
-   BFA_DPORT_ST_DISABLED   = 0,/* D-port is Disabled */
-   BFA_DPORT_ST_DISABLING  = 1,/* D-port is Disabling */
-   BFA_DPORT_ST_ENABLING   = 2,/* D-port is Enabling */
-   BFA_DPORT_ST_ENABLED= 3,/* D-port is Enabled */
-};
-
-/*
  * -- mfg definitions 
  */
 
@@ -1136,6 +1144,7 @@ struct bfa_flash_attr_s {
 #define LB_PATTERN_DEFAULT 0xB5B5B5B5
 #define QTEST_CNT_DEFAULT  10
 #define QTEST_PAT_DEFAULT  LB_PATTERN_DEFAULT
+#define DPORT_ENABLE_LOOPCNT_DEFAULT (1024 * 1024)
 
 struct bfa_diag_memtest_s {
u8  algo;
@@ -1164,6 +1173,54 @@ struct bfa_diag_loopback_result_s {
u8  rsvd[3];
 };
 
+enum bfa_diag_dport_test_status {
+   DPORT_TEST_ST_IDLE  = 0,/* the test has not started yet. */
+   DPORT_TEST_ST_FINAL = 1,/* the test done successfully */
+   DPORT_TEST_ST_SKIP  = 2,/* the test skipped */
+   DPORT_TEST_ST_FAIL  = 3,/* the test failed */
+   DPORT_TEST_ST_INPRG = 4,/* the testing is in progress */
+   DPORT_TEST_ST_RESPONDER = 5,/* test triggered from remote port */
+   DPORT_TEST_ST_STOPPED   = 6,/* the test stopped by user. */
+   DPORT_TEST_ST_MAX
+};
+
+enum bfa_diag_dport_test_type {
+   DPORT_TEST_ELOOP= 0,
+   DPORT_TEST_OLOOP= 1,
+

[PATCH V1 14/17] bfa: fix endianess issue for firmware stats

2013-05-13 Thread Vijaya Mohan Guvva
Fix endianess issue on Big-endian architecture for firmware statistics

Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_ioc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index c31cb3c..a4f3741 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -1858,7 +1858,7 @@ bfa_ioc_smem_read(struct bfa_ioc_s *ioc, void *tbuf, u32 
soff, u32 sz)
bfa_trc(ioc, len);
for (i = 0; i  len; i++) {
r32 = bfa_mem_read(ioc-ioc_regs.smem_page_start, loff);
-   buf[i] = be32_to_cpu(r32);
+   buf[i] = swab32(r32);
loff += sizeof(u32);
 
/*
-- 
1.7.12

--
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/8] ufs patch siries

2013-05-13 Thread Dolev Raviv
This patch series clusters the latest version of all the UFS patches in the
SCSI mailing list. It gives a stable functional base line for the UFS driver.

It includes the following versions:
 [PATCH 1/2] Documentation: devicetree: Add DT bindings for UFS host
 controller
 [PATCH 2/2] scsi: ufs: Fix the response UPIU length setting
 [PATCH v4 1/6] scsi: ufs: wrap the i/o access operations
 [PATCH v4 2/6] scsi: ufs: amend interrupt configuration
 [PATCH v4 3/6] scsi: ufs: fix interrupt status clears
 [PATCH v4 4/6] scsi: ufs: rework link start-up process
 [PATCH V5 1/1] scsi: ufs: Add support for sending NOP OUT UPIU
 [PATCH V4] scsi: ufs: Set fDeviceInit flag to initiate device
 initialization

But does not include:
 [PATCH v4 5/6] scsi: ufs: add dme configuration primit
 [PATCH v4 6/6] scsi: ufs: add dme control primitives


Dolev Raviv (8):
  Documentation: devicetree: Add DT bindings for UFS host controller
  scsi: ufs: Fix the response UPIU length setting
  scsi: ufs: wrap the i/o access operations
  scsi: ufs: amend interrupt configuration
  scsi: ufs: fix interrupt status clears
  scsi: ufs: rework link start-up process
  scsi: ufs: Add support for sending NOP OUT UPIU
  scsi: ufs: Set fDeviceInit flag to initiate device initialization

 .../devicetree/bindings/ufs/ufshcd-pltfrm.txt  |   16 +
 drivers/scsi/ufs/ufs.h |   10 +-
 drivers/scsi/ufs/ufshcd.c  |  839 
 drivers/scsi/ufs/ufshcd.h  |   25 +-
 drivers/scsi/ufs/ufshci.h  |5 +-
 5 files changed, 721 insertions(+), 174 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt

-- 
1.7.6

-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
--
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/8] Documentation: devicetree: Add DT bindings for UFS host controller

2013-05-13 Thread Dolev Raviv
Compatible list is used in commit 03b1781 but is not documented.
Add necessary device tree bindings to describe on-chip UFS host
controllers.

Signed-off-by: Sujit Reddy Thumma sthu...@codeaurora.org

diff --git a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt 
b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
new file mode 100644
index 000..20468b2
--- /dev/null
+++ b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
@@ -0,0 +1,16 @@
+* Universal Flash Storage (UFS) Host Controller
+
+UFSHC nodes are defined to describe on-chip UFS host controllers.
+Each UFS controller instance should have its own node.
+
+Required properties:
+- compatible: compatible list, contains jedec,ufs-1.1
+- interrupts: interrupt mapping for UFS host controller IRQ
+- reg   : registers mapping
+
+Example:
+   ufshc@0xfc598000 {
+   compatible = jedec,ufs-1.1;
+   reg = 0xfc598000 0x800;
+   interrupts = 0 28 0;
+   };
-- 
1.7.6

-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
--
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 5/8] scsi: ufs: fix interrupt status clears

2013-05-13 Thread Dolev Raviv
There is no need to check the version to clear
the interrupt status. And the order is changed
prior to actual handling.

Signed-off-by: Seungwon Jeon tgih@samsung.com
Tested-by: Maya Erez me...@codeaurora.org
Acked-by: Santosh Y santos...@gmail.com

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index c342a38..f4293d1 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1478,11 +1478,8 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
 
if (intr_status) {
+   ufshcd_writel(hba, intr_status, REG_INTERRUPT_STATUS);
ufshcd_sl_intr(hba, intr_status);
-
-   /* If UFSHCI 1.0 then clear interrupt status register */
-   if (hba-ufs_version == UFSHCI_VERSION_10)
-   ufshcd_writel(hba, intr_status, REG_INTERRUPT_STATUS);
retval = IRQ_HANDLED;
}
spin_unlock(hba-host-host_lock);
-- 
1.7.6

-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
--
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 7/8] scsi: ufs: Add support for sending NOP OUT UPIU

2013-05-13 Thread Dolev Raviv
As part of device initialization sequence, sending NOP OUT UPIU and
waiting for NOP IN UPIU response is mandatory. This confirms that the
device UFS Transport (UTP) layer is functional and the host can configure
the device with further commands. Add support for sending NOP OUT UPIU to
check the device connection path and test whether the UTP layer on the
device side is functional during initialization.

Signed-off-by: Sujit Reddy Thumma sthu...@codeaurora.org
Signed-off-by: Dolev Raviv dra...@codeaurora.org
Acked-by: Santosh Y santos...@gmail.com

---
v5:
  - rebase on top of Seungwon Jeon's UFS V4 patchset
v4:
   - Removed readl_poll_timeout and replaced with wait logic
   - additional checks for completion
v3:
   - minor bug fix in error path
v2:
   - fixed INTERNAL_CMD_TAG check in readl_poll_timeout
   - minor cleanup from v1
   - rebased on Seungwon Jeon's UFS V3 patchset

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 333812f..2db550b 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -43,6 +43,13 @@
 /* UIC command timeout, unit: ms */
 #define UIC_CMD_TIMEOUT500
 
+/* NOP OUT retries waiting for NOP IN response */
+#define NOP_OUT_RETRIES10
+/* Timeout after 30 msecs if NOP OUT hangs without response */
+#define NOP_OUT_TIMEOUT30 /* msecs */
+/* Reserved tag for internal commands */
+#define INTERNAL_CMD_TAG   0
+
 enum {
UFSHCD_MAX_CHANNEL  = 0,
UFSHCD_MAX_ID   = 1,
@@ -71,6 +78,39 @@ enum {
INT_AGGR_CONFIG,
 };
 
+/*
+ * ufshcd_wait_for_register - wait for register value to change
+ * @hba - per-adapter interface
+ * @reg - mmio register offset
+ * @mask - mask to apply to read register value
+ * @val - wait condition
+ * @interval_us - polling interval in microsecs
+ * @timeout_ms - timeout in millisecs
+ *
+ * Returns final register value after iteration
+ */
+static u32 ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
+   u32 val, unsigned long interval_us, unsigned long timeout_ms)
+{
+   u32 tmp;
+   ktime_t start;
+   unsigned long diff;
+
+   tmp = ufshcd_readl(hba, reg);
+
+   start = ktime_get();
+   while ((tmp  mask) == val) {
+   /* wakeup within 50us of expiry */
+   usleep_range(interval_us, interval_us + 50);
+   tmp = ufshcd_readl(hba, reg);
+   diff = ktime_to_ms(ktime_sub(ktime_get(), start));
+   if (diff  timeout_ms)
+   break;
+   }
+
+   return tmp;
+}
+
 /**
  * ufshcd_get_intr_mask - Get the interrupt bit mask
  * @hba - Pointer to adapter instance
@@ -612,7 +652,7 @@ static void ufshcd_prepare_req_desc(struct ufshcd_lrb 
*lrbp, u32 *upiu_flags)
 {
struct utp_transfer_req_desc *req_desc = lrbp-utr_descriptor_ptr;
enum dma_data_direction cmd_dir =
-   lrbp-cmd-sc_data_direction;
+   lrbp-cmd ? lrbp-cmd-sc_data_direction : DMA_NONE;
u32 data_direction;
u32 dword_0;
 
@@ -629,6 +669,8 @@ static void ufshcd_prepare_req_desc(struct ufshcd_lrb 
*lrbp, u32 *upiu_flags)
 
dword_0 = data_direction | (lrbp-command_type
 UPIU_COMMAND_TYPE_OFFSET);
+   if (lrbp-intr_cmd)
+   dword_0 |= UTP_REQ_DESC_INT_CMD;
 
/* Transfer request descriptor header fields */
req_desc-header.dword_0 = cpu_to_le32(dword_0);
@@ -717,6 +759,18 @@ static void ufshcd_prepare_utp_query_req_upiu(struct 
ufs_hba *hba,
 
 }
 
+static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp)
+{
+   struct utp_upiu_req *ucd_req_ptr = lrbp-ucd_req_ptr;
+
+   memset(ucd_req_ptr, 0, sizeof(struct utp_upiu_req));
+
+   /* command descriptor fields */
+   ucd_req_ptr-header.dword_0 =
+   UPIU_HEADER_DWORD(
+   UPIU_TRANSACTION_NOP_OUT, 0, 0, lrbp-task_tag);
+}
+
 /**
  * ufshcd_compose_upiu - form UFS Protocol Information Unit(UPIU)
  * @hba - UFS hba
@@ -731,11 +785,13 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, 
struct ufshcd_lrb *lrbp)
case UTP_CMD_TYPE_SCSI:
case UTP_CMD_TYPE_DEV_MANAGE:
ufshcd_prepare_req_desc(lrbp, upiu_flags);
-   if (lrbp-command_type == UTP_CMD_TYPE_SCSI)
+   if (lrbp-cmd  lrbp-command_type == UTP_CMD_TYPE_SCSI)
ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
-   else
+   else if (lrbp-cmd  ufshcd_is_query_req(lrbp))
ufshcd_prepare_utp_query_req_upiu(hba, lrbp,
upiu_flags);
+   else if (!lrbp-cmd)
+   ufshcd_prepare_utp_nop_upiu(lrbp);
break;
case UTP_CMD_TYPE_UFS:
/* For UFS native command implementation */
@@ -784,6 +840,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, 
struct scsi_cmnd 

[PATCH V1 6/8] scsi: ufs: rework link start-up process

2013-05-13 Thread Dolev Raviv
Link start-up requires long time with multiphase handshakes
between UFS host and device. This affects driver's probe time.
This patch let link start-up run asynchronously. Link start-up
will be executed at the end of prove separately.
Along with this change, the following is worked.

Defined completion time of uic command to avoid a permanent wait.
Added mutex to guarantee of uic command at a time.
Adapted some sequence of controller initialization after link statup
according to HCI standard.

Signed-off-by: Seungwon Jeon tgih@samsung.com
Signed-off-by: Sujit Reddy Thumma sthu...@codeaurora.org
Tested-by: Maya Erez me...@codeaurora.org
Acked-by: Santosh Y santos...@gmail.com
---
Change in v4:
- Addressed late interrupt case (Sujit).
- Move print message in link startup (Maya).

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index f4293d1..333812f 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -33,11 +33,15 @@
  * this program.
  */
 
+#include linux/async.h
+
 #include ufshcd.h
 
 #define UFSHCD_ENABLE_INTRS(UTP_TRANSFER_REQ_COMPL |\
 UTP_TASK_REQ_COMPL |\
 UFSHCD_ERROR_MASK)
+/* UIC command timeout, unit: ms */
+#define UIC_CMD_TIMEOUT500
 
 enum {
UFSHCD_MAX_CHANNEL  = 0,
@@ -401,24 +405,122 @@ static inline void ufshcd_hba_capabilities(struct 
ufs_hba *hba)
 }
 
 /**
- * ufshcd_send_uic_command - Send UIC commands to unipro layers
+ * ufshcd_ready_for_uic_cmd - Check if controller is ready
+ *to accept UIC commands
  * @hba: per adapter instance
- * @uic_command: UIC command
+ * Return true on success, else false
+ */
+static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba)
+{
+   if (ufshcd_readl(hba, REG_CONTROLLER_STATUS)  UIC_COMMAND_READY)
+   return true;
+   else
+   return false;
+}
+
+/**
+ * ufshcd_dispatch_uic_cmd - Dispatch UIC commands to unipro layers
+ * @hba: per adapter instance
+ * @uic_cmd: UIC command
+ *
+ * Mutex must be held.
  */
 static inline void
-ufshcd_send_uic_command(struct ufs_hba *hba, struct uic_command *uic_cmnd)
+ufshcd_dispatch_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
 {
+   WARN_ON(hba-active_uic_cmd);
+
+   hba-active_uic_cmd = uic_cmd;
+
/* Write Args */
-   ufshcd_writel(hba, uic_cmnd-argument1, REG_UIC_COMMAND_ARG_1);
-   ufshcd_writel(hba, uic_cmnd-argument2, REG_UIC_COMMAND_ARG_2);
-   ufshcd_writel(hba, uic_cmnd-argument3, REG_UIC_COMMAND_ARG_3);
+   ufshcd_writel(hba, uic_cmd-argument1, REG_UIC_COMMAND_ARG_1);
+   ufshcd_writel(hba, uic_cmd-argument2, REG_UIC_COMMAND_ARG_2);
+   ufshcd_writel(hba, uic_cmd-argument3, REG_UIC_COMMAND_ARG_3);
 
/* Write UIC Cmd */
-   ufshcd_writel(hba, uic_cmnd-command  COMMAND_OPCODE_MASK,
+   ufshcd_writel(hba, uic_cmd-command  COMMAND_OPCODE_MASK,
  REG_UIC_COMMAND);
 }
 
 /**
+ * ufshcd_wait_for_uic_cmd - Wait complectioin of UIC command
+ * @hba: per adapter instance
+ * @uic_command: UIC command
+ *
+ * Must be called with mutex held.
+ * Returns 0 only if success.
+ */
+static int
+ufshcd_wait_for_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
+{
+   int ret;
+   unsigned long flags;
+
+   if (wait_for_completion_timeout(uic_cmd-done,
+   msecs_to_jiffies(UIC_CMD_TIMEOUT)))
+   ret = uic_cmd-argument2  MASK_UIC_COMMAND_RESULT;
+   else
+   ret = -ETIMEDOUT;
+
+   spin_lock_irqsave(hba-host-host_lock, flags);
+   hba-active_uic_cmd = NULL;
+   spin_unlock_irqrestore(hba-host-host_lock, flags);
+
+   return ret;
+}
+
+/**
+ * __ufshcd_send_uic_cmd - Send UIC commands and retrieve the result
+ * @hba: per adapter instance
+ * @uic_cmd: UIC command
+ *
+ * Identical to ufshcd_send_uic_cmd() expect mutex. Must be called
+ * with mutex held.
+ * Returns 0 only if success.
+ */
+static int
+__ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
+{
+   int ret;
+   unsigned long flags;
+
+   if (!ufshcd_ready_for_uic_cmd(hba)) {
+   dev_err(hba-dev,
+   Controller not ready to accept UIC commands\n);
+   return -EIO;
+   }
+
+   init_completion(uic_cmd-done);
+
+   spin_lock_irqsave(hba-host-host_lock, flags);
+   ufshcd_dispatch_uic_cmd(hba, uic_cmd);
+   spin_unlock_irqrestore(hba-host-host_lock, flags);
+
+   ret = ufshcd_wait_for_uic_cmd(hba, uic_cmd);
+
+   return ret;
+}
+
+/**
+ * ufshcd_send_uic_cmd - Send UIC commands and retrieve the result
+ * @hba: per adapter instance
+ * @uic_cmd: UIC command
+ *
+ * Returns 0 only if success.
+ */
+static int
+ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
+{
+   int ret;
+
+   mutex_lock(hba-uic_cmd_mutex);
+   ret = __ufshcd_send_uic_cmd(hba, 

[PATCH V1 8/8] scsi: ufs: Set fDeviceInit flag to initiate device initialization

2013-05-13 Thread Dolev Raviv
Allow UFS device to complete its initialization and accept
SCSI commands by setting fDeviceInit flag. The device may take
time for this operation and hence the host should poll until
fDeviceInit flag is toggled to zero. This step is mandated by
UFS device specification for device initialization completion.

Signed-off-by: Dolev Raviv dra...@codeaurora.org
Signed-off-by: Sujit Reddy Thumma sthu...@codeaurora.org
Acked-by: Santosh Y santos...@gmail.com

--
Changes for V4:
- Add NULL pointer check
- Changed fix from v3 to bug on since hba can't be null
Changes for V3:
- Fix static checker error
Changes for V2:
- Add the query sending api via SCSI from the original query patch

diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index 086ff03..742363d 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -107,8 +107,13 @@ enum {
UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST = 0x81,
 };
 
+/* Flag idn for Query Requests*/
+enum flag_idn {
+   QUERY_FLAG_IDN_FDEVICEINIT = 0x01,
+};
+
 /* UTP QUERY Transaction Specific Fields OpCode */
-enum {
+enum query_opcode {
UPIU_QUERY_OPCODE_NOP   = 0x0,
UPIU_QUERY_OPCODE_READ_DESC = 0x1,
UPIU_QUERY_OPCODE_WRITE_DESC= 0x2,
@@ -208,6 +213,9 @@ struct utp_upiu_query {
u32 reserved[2];
 };
 
+/* Expose the flag value from utp_upiu_query.value */
+#define MASK_QUERY_UPIU_FLAG_LOC 0xFF
+
 /**
  * struct utp_upiu_req - general upiu request structure
  * @header:UPIU header structure DW-0 to DW-2
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 2db550b..e9dba33 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -50,6 +50,15 @@
 /* Reserved tag for internal commands */
 #define INTERNAL_CMD_TAG   0
 
+/* Query request standart retries */
+#define QUERY_REQ_RETRIES 10
+/* Query request standart timeout  in seconds */
+#define QUERY_REQ_TIMEOUT 5
+/* Send Query Requst with default parameters */
+#define send_query_request(ARG1, ARG2, ARG3, ARG4) \
+   ufshcd_query_request(ARG1, ARG2, ARG3, ARG4,\
+   QUERY_REQ_TIMEOUT, QUERY_REQ_RETRIES)
+
 enum {
UFSHCD_MAX_CHANNEL  = 0,
UFSHCD_MAX_ID   = 1,
@@ -862,6 +871,164 @@ out:
 }
 
 /**
+ *  ufshcd_query_request() - Entry point for issuing query request to a
+ *  ufs device.
+ *  @hba: ufs driver context
+ *  @query: params for query request
+ *  @descriptor: buffer for sending/receiving descriptor
+ *  @response: pointer to a buffer that will contain the response code and
+ *   response upiu
+ *  @timeout: time limit for the command in seconds
+ *  @retries: number of times to try executing the command
+ *
+ *  The query request is submitted to the same request queue as the rest of
+ *  the scsi commands passed to the UFS controller. In order to use this
+ *  queue, we need to receive a tag, same as all other commands. The tags
+ *  are issued from the block layer. To simulate a request from the block
+ *  layer, we use the same interface as the SCSI layer does when it issues
+ *  commands not generated by users. To distinguish a query request from
+ *  the SCSI commands, we use a vendor specific unused SCSI command
+ *  op-code. This op-code is not part of the SCSI command subset used in
+ *  UFS. In such way it is easy to check the command in the driver and
+ *  handle it appropriately.
+ *
+ *  All necessary fields for issuing a query and receiving its response are
+ *  stored in the UFS hba struct. We can use this method since we know
+ *  there is only one active query request at all times.
+ *
+ *  The request that will pass to the device is stored in query argument
+ *  passed to this function, while the response argument (which is output
+ *  field) will hold the query response from the device along with the
+ *  response code.
+ */
+int ufshcd_query_request(struct ufs_hba *hba,
+   struct ufs_query_req *query,
+   u8 *descriptor,
+   struct ufs_query_res *response,
+   int timeout,
+   int retries)
+{
+   struct scsi_device *sdev;
+   u8 cmd[UFS_QUERY_CMD_SIZE] = {0};
+   int result;
+   bool sdev_lookup = true;
+
+   BUG_ON(!hba);
+   if (!query || !response) {
+   dev_err(hba-dev,
+   %s: NULL pointer hba = %p, query = %p response = %p\n,
+   __func__, hba, query, response);
+   return -EINVAL;
+   }
+
+   /*
+* A SCSI command structure is composed from opcode at the
+* begining and 0 at the end.
+*/
+   cmd[0] = UFS_QUERY_RESERVED_SCSI_CMD;
+
+   /* extracting the SCSI Device */
+   sdev = scsi_device_lookup(hba-host, 0, 0, 0);
+   if (!sdev) {
+   /**
+* There are some Query Requests that are sent during device
+* initialization, this happens before the scsi device was
+  

[PATCH V1 3/8] scsi: ufs: wrap the i/o access operations

2013-05-13 Thread Dolev Raviv
Simplify operations with hiding mmio_base.

Signed-off-by: Seungwon Jeon tgih@samsung.com
Tested-by: Maya Erez me...@codeaurora.org
Acked-by: Santosh Y santos...@gmail.com

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 7ce40a5..3946b9d 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -71,7 +71,7 @@ enum {
  */
 static inline u32 ufshcd_get_ufs_version(struct ufs_hba *hba)
 {
-   return readl(hba-mmio_base + REG_UFS_VERSION);
+   return ufshcd_readl(hba, REG_UFS_VERSION);
 }
 
 /**
@@ -130,8 +130,7 @@ static inline int ufshcd_get_tm_free_slot(struct ufs_hba 
*hba)
  */
 static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos)
 {
-   writel(~(1  pos),
-   (hba-mmio_base + REG_UTP_TRANSFER_REQ_LIST_CLEAR));
+   ufshcd_writel(hba, ~(1  pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR);
 }
 
 /**
@@ -165,7 +164,7 @@ static inline int ufshcd_get_lists_status(u32 reg)
  */
 static inline int ufshcd_get_uic_cmd_result(struct ufs_hba *hba)
 {
-   return readl(hba-mmio_base + REG_UIC_COMMAND_ARG_2) 
+   return ufshcd_readl(hba, REG_UIC_COMMAND_ARG_2) 
   MASK_UIC_COMMAND_RESULT;
 }
 
@@ -238,18 +237,15 @@ ufshcd_config_int_aggr(struct ufs_hba *hba, int option)
 {
switch (option) {
case INT_AGGR_RESET:
-   writel((INT_AGGR_ENABLE |
-   INT_AGGR_COUNTER_AND_TIMER_RESET),
-   (hba-mmio_base +
-REG_UTP_TRANSFER_REQ_INT_AGG_CONTROL));
+   ufshcd_writel(hba, INT_AGGR_ENABLE |
+ INT_AGGR_COUNTER_AND_TIMER_RESET,
+ REG_UTP_TRANSFER_REQ_INT_AGG_CONTROL);
break;
case INT_AGGR_CONFIG:
-   writel((INT_AGGR_ENABLE |
-   INT_AGGR_PARAM_WRITE |
-   INT_AGGR_COUNTER_THRESHOLD_VALUE |
-   INT_AGGR_TIMEOUT_VALUE),
-   (hba-mmio_base +
-REG_UTP_TRANSFER_REQ_INT_AGG_CONTROL));
+   ufshcd_writel(hba, INT_AGGR_ENABLE | INT_AGGR_PARAM_WRITE |
+ INT_AGGR_COUNTER_THRESHOLD_VALUE |
+ INT_AGGR_TIMEOUT_VALUE,
+ REG_UTP_TRANSFER_REQ_INT_AGG_CONTROL);
break;
}
 }
@@ -262,12 +258,10 @@ ufshcd_config_int_aggr(struct ufs_hba *hba, int option)
  */
 static void ufshcd_enable_run_stop_reg(struct ufs_hba *hba)
 {
-   writel(UTP_TASK_REQ_LIST_RUN_STOP_BIT,
-  (hba-mmio_base +
-   REG_UTP_TASK_REQ_LIST_RUN_STOP));
-   writel(UTP_TRANSFER_REQ_LIST_RUN_STOP_BIT,
-  (hba-mmio_base +
-   REG_UTP_TRANSFER_REQ_LIST_RUN_STOP));
+   ufshcd_writel(hba, UTP_TASK_REQ_LIST_RUN_STOP_BIT,
+ REG_UTP_TASK_REQ_LIST_RUN_STOP);
+   ufshcd_writel(hba, UTP_TRANSFER_REQ_LIST_RUN_STOP_BIT,
+ REG_UTP_TRANSFER_REQ_LIST_RUN_STOP);
 }
 
 /**
@@ -276,7 +270,7 @@ static void ufshcd_enable_run_stop_reg(struct ufs_hba *hba)
  */
 static inline void ufshcd_hba_start(struct ufs_hba *hba)
 {
-   writel(CONTROLLER_ENABLE , (hba-mmio_base + REG_CONTROLLER_ENABLE));
+   ufshcd_writel(hba, CONTROLLER_ENABLE, REG_CONTROLLER_ENABLE);
 }
 
 /**
@@ -287,7 +281,7 @@ static inline void ufshcd_hba_start(struct ufs_hba *hba)
  */
 static inline int ufshcd_is_hba_active(struct ufs_hba *hba)
 {
-   return (readl(hba-mmio_base + REG_CONTROLLER_ENABLE)  0x1) ? 0 : 1;
+   return (ufshcd_readl(hba, REG_CONTROLLER_ENABLE)  0x1) ? 0 : 1;
 }
 
 /**
@@ -299,8 +293,7 @@ static inline
 void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag)
 {
__set_bit(task_tag, hba-outstanding_reqs);
-   writel((1  task_tag),
-  (hba-mmio_base + REG_UTP_TRANSFER_REQ_DOOR_BELL));
+   ufshcd_writel(hba, 1  task_tag, REG_UTP_TRANSFER_REQ_DOOR_BELL);
 }
 
 /**
@@ -381,8 +374,7 @@ void ufshcd_copy_query_response(struct ufs_hba *hba, struct 
ufshcd_lrb *lrbp)
  */
 static inline void ufshcd_hba_capabilities(struct ufs_hba *hba)
 {
-   hba-capabilities =
-   readl(hba-mmio_base + REG_CONTROLLER_CAPABILITIES);
+   hba-capabilities = ufshcd_readl(hba, REG_CONTROLLER_CAPABILITIES);
 
/* nutrs and nutmrs are 0 based values */
hba-nutrs = (hba-capabilities  MASK_TRANSFER_REQUESTS_SLOTS) + 1;
@@ -399,16 +391,13 @@ static inline void
 ufshcd_send_uic_command(struct ufs_hba *hba, struct uic_command *uic_cmnd)
 {
/* Write Args */
-   writel(uic_cmnd-argument1,
- (hba-mmio_base + REG_UIC_COMMAND_ARG_1));
-   writel(uic_cmnd-argument2,
- (hba-mmio_base + REG_UIC_COMMAND_ARG_2));
-   writel(uic_cmnd-argument3,
- (hba-mmio_base + REG_UIC_COMMAND_ARG_3));
+   ufshcd_writel(hba, uic_cmnd-argument1, REG_UIC_COMMAND_ARG_1);
+   ufshcd_writel(hba, uic_cmnd-argument2, 

[PATCH V1 4/8] scsi: ufs: amend interrupt configuration

2013-05-13 Thread Dolev Raviv
It makes interrupt setting more flexible especially
for disabling. And wrong bit mask is fixed for ver 1.0.
[17:16] is added for mask.

Signed-off-by: Seungwon Jeon tgih@samsung.com
Tested-by: Maya Erez me...@codeaurora.org
Acked-by: Santosh Y santos...@gmail.com

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 3946b9d..c342a38 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -35,6 +35,10 @@
 
 #include ufshcd.h
 
+#define UFSHCD_ENABLE_INTRS(UTP_TRANSFER_REQ_COMPL |\
+UTP_TASK_REQ_COMPL |\
+UFSHCD_ERROR_MASK)
+
 enum {
UFSHCD_MAX_CHANNEL  = 0,
UFSHCD_MAX_ID   = 1,
@@ -64,6 +68,20 @@ enum {
 };
 
 /**
+ * ufshcd_get_intr_mask - Get the interrupt bit mask
+ * @hba - Pointer to adapter instance
+ *
+ * Returns interrupt bit mask per version
+ */
+static inline u32 ufshcd_get_intr_mask(struct ufs_hba *hba)
+{
+   if (hba-ufs_version == UFSHCI_VERSION_10)
+   return INTERRUPT_MASK_ALL_VER_10;
+   else
+   return INTERRUPT_MASK_ALL_VER_11;
+}
+
+/**
  * ufshcd_get_ufs_version - Get the UFS version supported by the HBA
  * @hba - Pointer to adapter instance
  *
@@ -441,25 +459,45 @@ static int ufshcd_map_sg(struct ufshcd_lrb *lrbp)
 }
 
 /**
- * ufshcd_int_config - enable/disable interrupts
+ * ufshcd_enable_intr - enable interrupts
  * @hba: per adapter instance
- * @option: interrupt option
+ * @intrs: interrupt bits
  */
-static void ufshcd_int_config(struct ufs_hba *hba, u32 option)
+static void ufshcd_enable_intr(struct ufs_hba *hba, u32 intrs)
 {
-   switch (option) {
-   case UFSHCD_INT_ENABLE:
-   ufshcd_writel(hba, hba-int_enable_mask, REG_INTERRUPT_ENABLE);
-   break;
-   case UFSHCD_INT_DISABLE:
-   if (hba-ufs_version == UFSHCI_VERSION_10)
-   ufshcd_writel(hba, INTERRUPT_DISABLE_MASK_10,
- REG_INTERRUPT_ENABLE);
-   else
-   ufshcd_writel(hba, INTERRUPT_DISABLE_MASK_11,
- REG_INTERRUPT_ENABLE);
-   break;
+   u32 set = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+
+   if (hba-ufs_version == UFSHCI_VERSION_10) {
+   u32 rw;
+   rw = set  INTERRUPT_MASK_RW_VER_10;
+   set = rw | ((set ^ intrs)  intrs);
+   } else {
+   set |= intrs;
+   }
+
+   ufshcd_writel(hba, set, REG_INTERRUPT_ENABLE);
+}
+
+/**
+ * ufshcd_disable_intr - disable interrupts
+ * @hba: per adapter instance
+ * @intrs: interrupt bits
+ */
+static void ufshcd_disable_intr(struct ufs_hba *hba, u32 intrs)
+{
+   u32 set = ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
+
+   if (hba-ufs_version == UFSHCI_VERSION_10) {
+   u32 rw;
+   rw = (set  INTERRUPT_MASK_RW_VER_10) 
+   ~(intrs  INTERRUPT_MASK_RW_VER_10);
+   set = rw | ((set  intrs)  ~INTERRUPT_MASK_RW_VER_10);
+
+   } else {
+   set = ~intrs;
}
+
+   ufshcd_writel(hba, set, REG_INTERRUPT_ENABLE);
 }
 
 /**
@@ -842,8 +880,7 @@ static int ufshcd_dme_link_startup(struct ufs_hba *hba)
uic_cmd-argument3 = 0;
 
/* enable UIC related interrupts */
-   hba-int_enable_mask |= UIC_COMMAND_COMPL;
-   ufshcd_int_config(hba, UFSHCD_INT_ENABLE);
+   ufshcd_enable_intr(hba, UIC_COMMAND_COMPL);
 
/* sending UIC commands to controller */
ufshcd_send_uic_command(hba, uic_cmd);
@@ -890,13 +927,7 @@ static int ufshcd_make_hba_operational(struct ufs_hba *hba)
}
 
/* Enable required interrupts */
-   hba-int_enable_mask |= (UTP_TRANSFER_REQ_COMPL |
-UIC_ERROR |
-UTP_TASK_REQ_COMPL |
-DEVICE_FATAL_ERROR |
-CONTROLLER_FATAL_ERROR |
-SYSTEM_BUS_FATAL_ERROR);
-   ufshcd_int_config(hba, UFSHCD_INT_ENABLE);
+   ufshcd_enable_intr(hba, UFSHCD_ENABLE_INTRS);
 
/* Configure interrupt aggregation */
ufshcd_config_int_aggr(hba, INT_AGGR_CONFIG);
@@ -1724,7 +1755,7 @@ static void ufshcd_hba_free(struct ufs_hba *hba)
 void ufshcd_remove(struct ufs_hba *hba)
 {
/* disable interrupts */
-   ufshcd_int_config(hba, UFSHCD_INT_DISABLE);
+   ufshcd_disable_intr(hba, hba-intr_mask);
 
ufshcd_hba_stop(hba);
ufshcd_hba_free(hba);
@@ -1782,6 +1813,9 @@ int ufshcd_init(struct device *dev, struct ufs_hba 
**hba_handle,
/* Get UFS version supported by the controller */
hba-ufs_version = ufshcd_get_ufs_version(hba);
 
+   /* Get Interrupt bit mask per version */
+   hba-intr_mask = ufshcd_get_intr_mask(hba);
+
/* Allocate memory for host memory space */
err = ufshcd_memory_alloc(hba);
if (err) {

[PATCH V1 07/17] bfa: Fix FDISC timeout handling

2013-05-13 Thread Vijaya Mohan Guvva
Retry FDISC a max of 6 times. Introduce new events to handle vport
login fails due to max logins to fabric/switch.

Signed-off-by: Anil Gurumurthy aguru...@brocade.com
Signed-off-by: Vijaya Mohan Guvva vmo...@brocade.com
---
 drivers/scsi/bfa/bfa_fcs_lport.c | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
index 8773d5e..2f61a5a 100644
--- a/drivers/scsi/bfa/bfa_fcs_lport.c
+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
@@ -5988,6 +5988,7 @@ enum bfa_fcs_vport_event {
BFA_FCS_VPORT_SM_RSP_DUP_WWN = 12,  /*  Dup wnn error*/
BFA_FCS_VPORT_SM_RSP_FAILED = 13,   /*  non-retryable failure */
BFA_FCS_VPORT_SM_STOPCOMP = 14, /* vport delete completion */
+   BFA_FCS_VPORT_SM_FABRIC_MAX = 15, /* max vports on fabric */
 };
 
 static void bfa_fcs_vport_sm_uninit(struct bfa_fcs_vport_s *vport,
@@ -6173,6 +6174,7 @@ bfa_fcs_vport_sm_fdisc(struct bfa_fcs_vport_s *vport,
break;
 
case BFA_FCS_VPORT_SM_RSP_FAILED:
+   case BFA_FCS_VPORT_SM_FABRIC_MAX:
bfa_sm_set_state(vport, bfa_fcs_vport_sm_offline);
break;
 
@@ -6243,6 +6245,7 @@ bfa_fcs_vport_sm_fdisc_rsp_wait(struct bfa_fcs_vport_s 
*vport,
case BFA_FCS_VPORT_SM_OFFLINE:
case BFA_FCS_VPORT_SM_RSP_ERROR:
case BFA_FCS_VPORT_SM_RSP_FAILED:
+   case BFA_FCS_VPORT_SM_FABRIC_MAX:
case BFA_FCS_VPORT_SM_RSP_DUP_WWN:
bfa_sm_set_state(vport, bfa_fcs_vport_sm_cleanup);
bfa_sm_send_event(vport-lps, BFA_LPS_SM_OFFLINE);
@@ -6528,7 +6531,7 @@ bfa_fcs_vport_fdisc_rejected(struct bfa_fcs_vport_s 
*vport)
else {
bfa_fcs_vport_aen_post(vport-lport,
BFA_LPORT_AEN_NPIV_FABRIC_MAX);
-   bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_FAILED);
+   bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_FABRIC_MAX);
}
break;
 
@@ -6914,7 +6917,19 @@ bfa_cb_lps_fdisc_comp(void *bfad, void *uarg, 
bfa_status_t status)
break;
}
 
-   bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
+   if (vport-fdisc_retries  BFA_FCS_VPORT_MAX_RETRIES)
+   bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
+   else
+   bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_FAILED);
+
+   break;
+
+   case BFA_STATUS_ETIMER:
+   vport-vport_stats.fdisc_timeouts++;
+   if (vport-fdisc_retries  BFA_FCS_VPORT_MAX_RETRIES)
+   bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_ERROR);
+   else
+   bfa_sm_send_event(vport, BFA_FCS_VPORT_SM_RSP_FAILED);
break;
 
case BFA_STATUS_FABRIC_RJT:
-- 
1.7.12

--
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/8] scsi: ufs: Fix the response UPIU length setting

2013-05-13 Thread Dolev Raviv
The response UPIU length should be in DWORD and not in bytes.

Signed-off-by: Maya Erez me...@codeaurora.org
Signed-off-by: Sujit Reddy Thumma sthu...@codeaurora.org
Signed-off-by: Dolev Raviv dra...@codeaurora.org
Tested-by: Dolev Raviv dra...@codeaurora.org

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 4ddc8be..7ce40a5 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -807,7 +807,7 @@ static void ufshcd_host_memory_configure(struct ufs_hba 
*hba)
utrdlp[i].prd_table_offset =
cpu_to_le16((prdt_offset  2));
utrdlp[i].response_upiu_length =
-   cpu_to_le16(ALIGNED_UPIU_SIZE);
+   cpu_to_le16(ALIGNED_UPIU_SIZE  2);
 
hba-lrb[i].utr_descriptor_ptr = (utrdlp + i);
hba-lrb[i].ucd_req_ptr =
-- 
1.7.6

-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
--
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 V1 0/8] ufs patch siries

2013-05-13 Thread Seungwon Jeon
On Monday, May 13, 2013, Dolev Raviv wrote:
 This patch series clusters the latest version of all the UFS patches in the
 SCSI mailing list. It gives a stable functional base line for the UFS driver.
 
 It includes the following versions:
  [PATCH 1/2] Documentation: devicetree: Add DT bindings for UFS host
  controller
  [PATCH 2/2] scsi: ufs: Fix the response UPIU length setting
  [PATCH v4 1/6] scsi: ufs: wrap the i/o access operations
  [PATCH v4 2/6] scsi: ufs: amend interrupt configuration
  [PATCH v4 3/6] scsi: ufs: fix interrupt status clears
  [PATCH v4 4/6] scsi: ufs: rework link start-up process
  [PATCH V5 1/1] scsi: ufs: Add support for sending NOP OUT UPIU
  [PATCH V4] scsi: ufs: Set fDeviceInit flag to initiate device
  initialization
 
 But does not include:
  [PATCH v4 5/6] scsi: ufs: add dme configuration primit
  [PATCH v4 6/6] scsi: ufs: add dme control primitives
 
 
 Dolev Raviv (8):
   Documentation: devicetree: Add DT bindings for UFS host controller
   scsi: ufs: Fix the response UPIU length setting
   scsi: ufs: wrap the i/o access operations
   scsi: ufs: amend interrupt configuration
   scsi: ufs: fix interrupt status clears
   scsi: ufs: rework link start-up process
   scsi: ufs: Add support for sending NOP OUT UPIU
   scsi: ufs: Set fDeviceInit flag to initiate device initialization

It seems that you missed my first comment on previous mailing.

RE: [PATCH V1 3/8] scsi: ufs: wrap the i/o access operations
Could you check the e-mail?

If you intended to sort the patches instead of Santosh, 
you should have identify the author per patch e-mail expect 8/8 which is from 
you.
'From: Author name Author e-mail' is expected in the head of e-mail.
I feel that maintainer has this role, though.

And there is need to check the base of tree for ufshcd.
' scsi: ufs: add support for query requests' is not merged finally.
I think we can talk with Santosh for those.

Thanks,
Seungwon Jeon

--
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: Allow error handling timeout to be specified

2013-05-13 Thread Jeremy Linton
On 5/13/2013 12:46 AM, Hannes Reinecke wrote:

 True. But and the end of the day, we _do_ want to recover the failed LUN.
 If we were to disable that faulty LUN and continue running with the others
 we won't have a chance of _ever_ recovering that one LUN.

I don't buy this. Especially for FC devices, the vast majority of 
errors I see
are related to zoning, SFP and cabling problems. Once one of those happens you
tend to get a lot of shotgun debugging, which injects all kinds of
further errors. None of these errors are fixed by the linux error recovery 
paths.

That said, if the admin fixes something, for FC/SAS (and potentially 
others)
you _WILL_ get notification that the device is online again.


 SET when the link is down). So we basically _have_ to escalate it to the
 next level. Even though that will mean to stop I/O to other, hitherto
 unaffected instances.

And a single failure, turns into performance bubbles and further errors 
on
other devices. Particularly if the functional devices are stateful, and the
error recovery mechanism isn't sufficiently intelligent about that state (see
tape drives). Think about what happens when a marginal SFP on a target causes
a device to repeatably drop off and reappear at some random point in the future.


Anyway, It is possible to make a determination about the topology and 
make
decisions about the likely-hood of any given portion being at fault. For
example, if one lun on a target has failed and the remainder continue to work,
then its unlikely that if abort and lun reset fail that anything higher up in
the stack is going to succeed.

I feel pretty strongly, at that point your better off providing good
diagnostics about the failure and expecting user interaction rather than
muddying the waters by causing other device interruptions. If the user tries
everything and determines that a HBA reset is the right choice, provide that
option, don't do it for them.

If every device attached to the HBA fails then resetting the HBA is a 
valid
choice, not before. Same for I_T.



--
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: Allow error handling timeout to be specified

2013-05-13 Thread Hannes Reinecke
On 05/13/2013 04:40 PM, Jeremy Linton wrote:
 On 5/13/2013 12:46 AM, Hannes Reinecke wrote:
 
 True. But and the end of the day, we _do_ want to recover the failed LUN.
 If we were to disable that faulty LUN and continue running with the others
 we won't have a chance of _ever_ recovering that one LUN.
 
   I don't buy this. Especially for FC devices, the vast majority of 
 errors I see
 are related to zoning, SFP and cabling problems. Once one of those happens you
 tend to get a lot of shotgun debugging, which injects all kinds of
 further errors.   None of these errors are fixed by the linux error 
 recovery paths.
 
   That said, if the admin fixes something, for FC/SAS (and potentially 
 others)
 you _WILL_ get notification that the device is online again.
 

Well, yes, of course.
Sadly, these kind of errors tend to be very erratic and very hard to
diagnose. There simply is no way telling that the error you've had
is due to a bad cable or bad SFP.
Bad zoning is easy; then the device is simply not reachable anymore.

So for error recovery we first have to assume that the error is
fixable. And then we have a standard way of trying to fix this error.
The problem we have is that we lose all information about the error
once it's 'fixed' (ie after eh is done). Which is the main problem
with bad cabling: we're running the same sequence all over again,
without ever figuring out 'hey, I've done this already'.

sd.c has some _very_ limited support for this. But trying to
generalise things here will be _hard_.

So yeah, I see your point. In fact, I've been bitten by this, too.
But the error scenarios I've seen are far to complex to have them
modelled into something re-usable.

 SET when the link is down). So we basically _have_ to escalate it to the
 next level. Even though that will mean to stop I/O to other, hitherto
 unaffected instances.
 
   And a single failure, turns into performance bubbles and further errors 
 on
 other devices. Particularly if the functional devices are stateful, and the
 error recovery mechanism isn't sufficiently intelligent about that state (see
 tape drives). Think about what happens when a marginal SFP on a target causes
 a device to repeatably drop off and reappear at some random point in the 
 future.
 
 
   Anyway, It is possible to make a determination about the topology and 
 make
 decisions about the likely-hood of any given portion being at fault. For
 example, if one lun on a target has failed and the remainder continue to work,
 then its unlikely that if abort and lun reset fail that anything higher up in
 the stack is going to succeed.
 
Which is why I suggested 'ABORT TASK SET' instead of 'LUN reset'.
That will be restricted to the I_T_L nexus, and leave the rest of
the LUN alone (or so one hopes).

   I feel pretty strongly, at that point your better off providing good
 diagnostics about the failure and expecting user interaction rather than
 muddying the waters by causing other device interruptions. If the user tries
 everything and determines that a HBA reset is the right choice, provide that
 option, don't do it for them.
 
   If every device attached to the HBA fails then resetting the HBA is a 
 valid
 choice, not before. Same for I_T.
 
Hmm. Really not sure.

Take the 'target not responding' case. (which is what triggered this
whole issue anyway). Say a target port went out to lunch and don't
respond to FC commands anymore.

With our current EH it'll take _ages_, but eventually the big hammer
hits (or the device comes back) and everything is back to normal again.
So LUN reset (or ABORT TASK SET) fails.
The other LUNs haven't reported an error. But how do you know
whether they are still okay? The other LUNs might simply be idle,
and no commands have been send to them.
So the state's still good. Do we reset the I_T nexus or not?

If we do, we would find that the entire rport doesn't respond, so
the devloss_tmo mechanism would trigger, and eventually the rport
will disappear and we're back on normal operation.

If we don't the LUN will be stuck forever, until someone actually
issues I/O to the other LUNs for that rport. And only when I/O is
issued to the _last_ LUN we'll decide to reset the I_T nexus.
Not a very appealing scenario.

And 'reset I_T nexus' should be a rather fast operation; with a bit
of luck the other rports wouldn't even notice.
I've had a prototype running which would just kick off the
dev_loss_tmo mechanism; that worked like a charm.
(Agreed, as James Smart indicated 'only by luck', but nevertheless)

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (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  

RE: [PATCH] scsi: Allow error handling timeout to be specified

2013-05-13 Thread Elliott, Robert (Server Storage)


 -Original Message-
 From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
 ow...@vger.kernel.org] On Behalf Of Ewan Milne
 Sent: Friday, 10 May, 2013 11:59 AM
 To: Hannes Reinecke
 Cc: Baruch Even; Martin K. Petersen; linux-scsi; michaelc
 Subject: Re: [PATCH] scsi: Allow error handling timeout to be specified
 
 On Fri, 2013-05-10 at 16:24 +0200, Hannes Reinecke wrote:
  On 05/10/2013 04:01 PM, Ewan Milne wrote:
   On Fri, 2013-05-10 at 16:22 +0300, Baruch Even wrote:
   On Fri, May 10, 2013 at 3:43 PM, Ewan Milne emi...@redhat.com
 wrote:
  
  
   I would argue that waiting for the eh to timeout before you switch to
   another path is most likely to be wrong. If you did the first pass of
   error recovery (task abort) and that failed the
   path/hba/logical-device is doomed. If you will switch to another path
   it will either work (meaning the path/hba were bad) or not (logical
   device was the culprit).
  
   It is necessary to either know the disposition of a command or
   else wait for a defined amount of time before retrying the command on
   another path.  Otherwise you run the risk that the command will
   eventually complete on the first path.  So yes, we need to do the abort
   (and its timeout).
  
  Strictly speaking that's not true.
  Yes, we do need to wait for a certain amount of time for the command
  completion to come in.
 
  However, this time is only defined _on the initiator_.
  The specification does _NOT_ have any fixed timeout values for _any_
  command. As such it could in theory (and does, if you happen to run
  against certain arrays under certain conditions) take several
  minutes to return a completion.

The REPORT SUPPORTED OPERATION CODES command (see SPC-4) 
returns nominal and recommended timeout values for each supported
command.  Similarly, REPORT SUPPORTED TASK MANAGEMENT FUNCTIONS
returns timeouts for task management functions.

Those times are from the device server's perspective, so any fabric 
overhead needs to be added.

Those commands and the command timeout descriptors are optional.
They are proposed to be mandatory in the Base feature set, though.

 Granted.  (e.g. in the case of WRITE SAME, it could be a while before
 the command completes, and retrying it on another path too quickly,
 followed by other WRITE commands could be a disaster).  So the timeout
 used for the original command has to be appropriate for the command.
 Reducing that timeout and issuing an abort / lun reset / target reset
 to try to fail over to another path earlier won't work if the device
 never gets the abort / lun reset / target reset and the command is still
 executing.

One problem with the ABORT TASK and I_T NEXUS RESET task management
functions is they must be sent down the same I_T nexus as the command(s)
that ran into timeouts.  If that I_T nexus is the source of the problem,
then they are likely to timeout as well.

The REMOVE I_T NEXUS command (standardized in March 2012 in 
SPC-4 revision 35) is designed to be sent down a different I_T nexus - the 
failover path.  It ensures that commands on the original I_T nexus won't 
suddenly resume.  That command is optional and still very new in
standards time.




Re: [PATCH] scsi: Allow error handling timeout to be specified

2013-05-13 Thread Jeremy Linton
On 5/13/2013 10:03 AM, Hannes Reinecke wrote:
 The other LUNs haven't reported an error. But how do you know whether they
 are still okay? The other LUNs might simply be idle, and no commands have
 been send to them.

Well, how about generating std inquiry against them if they are idle 
and the
given HBA has a device in error state? Then you can make a rough approximation
of what has failed, and escalate the error handling if all the devices at a
particular level have failed.

The midlayer may not even need to send the inquiries. If the individual
device drivers (sd/st/etc) are responsible for monitoring and error recovery
then they can be tasked with determining device availability as well. I think
this solves other problems too. For example, the use of TUR in the midlayer,
is a problem because it doesn't have enough knowledge about the possible check
conditions being returned to act on them appropriately.







--
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 v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead

2013-05-13 Thread Jiang Liu
From: Gu Zheng guz.f...@cn.fujitsu.com

marker to prevent gmail from removing below From:
From: Gu Zheng guz.f...@cn.fujitsu.com

Use the new pci_alloc_dev(bus) to replace the existing using of
alloc_pci_dev(void).

v2:
  Follow Bjorn's correction to move pci_bus_put() to
  pci_release_dev() instead.

Signed-off-by: Gu Zheng guz.f...@cn.fujitsu.com
Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
Cc: Paul Mackerras pau...@samba.org
Cc: David S. Miller da...@davemloft.net
Cc: David Airlie airl...@linux.ie
Cc: Neela Syam Kolli megaraidli...@lsi.com
Cc: James E.J. Bottomley jbottom...@parallels.com
Cc: Yinghai Lu ying...@kernel.org
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: Andrew Morton a...@linux-foundation.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: linux-ker...@vger.kernel.org
Cc: sparcli...@vger.kernel.org
Cc: linux-...@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Jiang Liu jiang@huawei.com
---
 arch/powerpc/kernel/pci_of_scan.c | 3 +--
 arch/sparc/kernel/pci.c   | 3 +--
 drivers/char/agp/alpha-agp.c  | 2 +-
 drivers/char/agp/parisc-agp.c | 2 +-
 drivers/pci/iov.c | 8 +---
 drivers/pci/probe.c   | 4 ++--
 drivers/scsi/megaraid.c   | 2 +-
 7 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/kernel/pci_of_scan.c 
b/arch/powerpc/kernel/pci_of_scan.c
index 2a67e9b..24d01c4 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -128,7 +128,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
const char *type;
struct pci_slot *slot;
 
-   dev = alloc_pci_dev();
+   dev = pci_alloc_dev(bus);
if (!dev)
return NULL;
type = of_get_property(node, device_type, NULL);
@@ -137,7 +137,6 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
 
pr_debug(create device, devfn: %x, type: %s\n, devfn, type);
 
-   dev-bus = bus;
dev-dev.of_node = of_node_get(node);
dev-dev.parent = bus-bridge;
dev-dev.bus = pci_bus_type;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index baf4366..e5871fb 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -254,7 +254,7 @@ static struct pci_dev *of_create_pci_dev(struct 
pci_pbm_info *pbm,
const char *type;
u32 class;
 
-   dev = alloc_pci_dev();
+   dev = pci_alloc_dev(bus);
if (!dev)
return NULL;
 
@@ -281,7 +281,6 @@ static struct pci_dev *of_create_pci_dev(struct 
pci_pbm_info *pbm,
printk(create device, devfn: %x, type: %s\n,
   devfn, type);
 
-   dev-bus = bus;
dev-sysdata = node;
dev-dev.parent = bus-bridge;
dev-dev.bus = pci_bus_type;
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c
index dd84af4..199b8e9 100644
--- a/drivers/char/agp/alpha-agp.c
+++ b/drivers/char/agp/alpha-agp.c
@@ -174,7 +174,7 @@ alpha_core_agp_setup(void)
/*
 * Build a fake pci_dev struct
 */
-   pdev = alloc_pci_dev();
+   pdev = pci_alloc_dev(NULL);
if (!pdev)
return -ENOMEM;
pdev-vendor = 0x;
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index 94821ab..bf5d247 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -333,7 +333,7 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem 
*lba_hpa)
struct agp_bridge_data *bridge;
int error = 0;
 
-   fake_bridge_dev = alloc_pci_dev();
+   fake_bridge_dev = pci_alloc_dev(NULL);
if (!fake_bridge_dev) {
error = -ENOMEM;
goto fail;
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index ee599f2..24134cd 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -75,18 +75,20 @@ static int virtfn_add(struct pci_dev *dev, int id, int 
reset)
struct pci_dev *virtfn;
struct resource *res;
struct pci_sriov *iov = dev-sriov;
+   struct pci_bus *bus;
 
-   virtfn = alloc_pci_dev();
+   virtfn = pci_alloc_dev(NULL);
if (!virtfn)
return -ENOMEM;
 
mutex_lock(iov-dev-sriov-lock);
-   virtfn-bus = virtfn_add_bus(dev-bus, virtfn_bus(dev, id));
-   if (!virtfn-bus) {
+   bus = virtfn_add_bus(dev-bus, virtfn_bus(dev, id));
+   if (!bus) {
kfree(virtfn);
mutex_unlock(iov-dev-sriov-lock);
return -ENOMEM;
}
+   virtfn-bus = pci_bus_get(bus);
virtfn-devfn = virtfn_devfn(dev, id);
virtfn-vendor = dev-vendor;
pci_read_config_word(dev, iov-pos + PCI_SRIOV_VF_DID, virtfn-device);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 4f0bc0a..bc075a3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1131,6 +1131,7 @@ static void pci_release_dev(struct device *dev)
struct pci_dev 

Re: [PATCH] scsi: Allow error handling timeout to be specified

2013-05-13 Thread Baruch Even
On Mon, May 13, 2013 at 6:58 PM, Jeremy Linton jlin...@tributary.com wrote:
 On 5/13/2013 10:03 AM, Hannes Reinecke wrote:
 The other LUNs haven't reported an error. But how do you know whether they
 are still okay? The other LUNs might simply be idle, and no commands have
 been send to them.

 Well, how about generating std inquiry against them if they are idle 
 and the
 given HBA has a device in error state? Then you can make a rough approximation
 of what has failed, and escalate the error handling if all the devices at a
 particular level have failed.

 The midlayer may not even need to send the inquiries. If the 
 individual
 device drivers (sd/st/etc) are responsible for monitoring and error recovery
 then they can be tasked with determining device availability as well. I think
 this solves other problems too. For example, the use of TUR in the midlayer,
 is a problem because it doesn't have enough knowledge about the possible check
 conditions being returned to act on them appropriately.

Such an approach is preferable IMO than the big hammer, especially if
we are talking about a likely condition of using multipath and having
other links over the same host  that do have traffic flowing through
them. If there is traffic already on the same host there is no reason
to do a host reset, if there is no traffic and there are no other
luns, go for the big gun it will not matter to anything else, if there
are other inactive luns some mechanism to trigger some basic traffic
(inquiry/tur) on them is much preferable to just a plain big hammer
application.

It might be that the kernel is not the right place for all of this
diagnostics work but then some interface for an external daemon to do
this diagnostics is preferable to just wielding the big hammer and
killing all traffic.

In my experience if the device doesn't respond it usually just
disappeared from the network, if it is on the network and the task
abort or target reset do not return successfully it is either unlikely
that the host reset will help (the host is fine, device is gone) or
that the host reset is the only way since the host is dead but then a
simple check on all other luns would reveal that quite fast. In many
cases the host controller itself is mostly dead and the driver could
detect that on its own without waiting for the traffic to time out but
that's an issue for each driver to handle.

Baruch

Baruch
--
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 v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead

2013-05-13 Thread Yinghai Lu
On Mon, May 13, 2013 at 9:08 AM, Jiang Liu liu...@gmail.com wrote:
 From: Gu Zheng guz.f...@cn.fujitsu.com
 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
 index 4f0bc0a..bc075a3 100644
 --- a/drivers/pci/probe.c
 +++ b/drivers/pci/probe.c
 @@ -1131,6 +1131,7 @@ static void pci_release_dev(struct device *dev)
 struct pci_dev *pci_dev;

 pci_dev = to_pci_dev(dev);
 +   pci_bus_put(pci_dev-bus);
 pci_release_capabilities(pci_dev);
 pci_release_of_node(pci_dev);
 kfree(pci_dev);
 @@ -1269,11 +1270,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus 
 *bus, int devfn)
 if (!pci_bus_read_dev_vendor_id(bus, devfn, l, 60*1000))
 return NULL;

 -   dev = alloc_pci_dev();
 +   dev = pci_alloc_dev(bus);
 if (!dev)
 return NULL;

 -   dev-bus = bus;
 dev-devfn = devfn;
 dev-vendor = l  0x;
 dev-device = (l  16)  0x;

in pci_setup_device() fail path, it release the ref to that bus.

Yinghai
--
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: Allow error handling timeout to be specified

2013-05-13 Thread Martin K. Petersen
 Jeremy == Jeremy Linton jlin...@tributary.com writes:

Jeremy Well, how about generating std inquiry against them if they are
Jeremy idle and the given HBA has a device in error state? Then you can
Jeremy make a rough approximation of what has failed, and escalate the
Jeremy error handling if all the devices at a particular level have
Jeremy failed.

It's not that simple, unfortunately. Some HBAs keep more state than
others. We see cases fairly often where a misbehaving target has
confused the HBA enough that we can not bring the device back without
doing an HBA firmware reset. Despite I/O completing successfully on
other targets connected to the same HBA.

So at some point we do need to give up and escalate to a full HBA
reset. We would just like to defer that hammer until we have run out of
other options.

-- 
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


Re: [PATCH] scsi: Allow error handling timeout to be specified

2013-05-13 Thread Jeremy Linton
On 5/13/2013 3:29 PM, Martin K. Petersen wrote:

 others. We see cases fairly often where a misbehaving target has
 confused the HBA enough that we can not bring the device back without
 doing an HBA firmware reset. Despite I/O completing successfully on
 other targets connected to the same HBA.

This would seem to indicate a HBA/driver bug...

 So at some point we do need to give up and escalate to a full HBA
 reset. We would just like to defer that hammer until we have run out of
 other options.

Except that I've seen the linux error recovery cause more problems than 
it
solves on a fairly regular basis. I would rather have a solution designed to
isolate failures, than one that makes a lot of mistakes and causes further
problems (sometimes with other machines). I'm pretty convinced that attempting
everything possible to recover a device when the underlying problem is unknown
is a bad strategy.

I think maybe its a perspective difference. If the device that is 
failing is an
OS disk, then giving up is paramount to crashing the machine. On the other hand,
if the failing device is some shared tape drive in a SAN with a few hundred
alternatives then killing the OS in an attempt to recover that drive is a 
problem.

Maybe, the super aggressive recovery paths should be reserved for 
devices
marked critical to system operation.


--
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 0/4] Patchset to use PCLMULQDQ to accelerate CRC-T10DIF checksum computation

2013-05-13 Thread Herbert Xu
On Wed, May 01, 2013 at 12:52:47PM -0700, Tim Chen wrote:
 Currently the CRC-T10DIF checksum is computed using a generic table lookup
 algorithm.  By switching the checksum to PCLMULQDQ based computation,
 we can speedup the computation by 8x for checksumming 512 bytes and
 even more for larger buffer size.  This will improve performance of SCSI
 drivers turning on the CRC-T10IDF checksum.  In our SSD based experiments,
 we have seen increase disk throughput by 3.5x with T10DIF for 512 byte
 block size.
 
 This patch set provides the x86_64 routine using PCLMULQDQ instruction
 and switches the crc_t10dif library function to use the faster PCLMULQDQ
 based routine when available.
 
 Tim
 
 v3
 1. Update the crct10dif crypto transform used in the crct10dif library in a 
 safe way.
 2. Load the accelerated t10dif transform for the x86_64 cpus that support it.
 3. Added generic crct10dif crypto transform.

All applied.  Thanks Tim.
-- 
Email: Herbert Xu herb...@gondor.apana.org.au
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
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: SCSI testing/USB devices are amazing

2013-05-13 Thread ronnie sahlberg
Hi Martin,

Thanks for your input, and for the link to your nice writeup.

On Thu, May 9, 2013 at 7:43 PM, Martin K. Petersen
martin.peter...@oracle.com wrote:
 Ronnie == ronnie sahlberg ronniesahlb...@gmail.com writes:

 Ronnie * please have a look at the tests and the test results I linked
 Ronnie   to above. I currently have quite a few tests but am happy to
 Ronnie   add more.

 Aside from issuing commands with various bits set, I'd like to see some
 more sanity checking. Mainly to see whether it responds correctly to the
 features is claims to support.

I will start to add such. I think your document will provide ideas on
what to start writing tests for.


 I.e. do the values reported in the Block Limits VPD look sane given what
 we know about the device in general (SCSI level, capacity, PI supported,
 discard supported, etc.)?

I have added tests for the block limits VPD as SCSI.Inquiry.InquiryBlockLimits.
It checks that the pagelength is valid. 3C if SBC3 is claimed  and 0C
if prior to SBC3.
It then validates that the UNMAP counts are sane.
Sane being that if LBPU==0 then these must be 0, and if LBPU==1 then
these must be 1, must be than 2**LBPPBE and either 0x
or 1M. (1M is arbitrary for crazy large number of blocks)

The other fields I had a hard time to come up with good sanity tests
for. Any suggestions ?
Do you have examples of things that vendors get wrong here ?



 Right now you always expect RDPROTECT/WRPROTECT  0 to fail, but they
 should succeed if the device is formatted with PI.

I have added a check so that the tests are skipped if the device does not
support protection information or if it supports protection
information but but it is not enabled.

I will add tests for when protection information is enabled in the
future, I will need to find time to add it to tgt first.



 FWIW, my slightly outdated document is here:

 https://oss.oracle.com/~mkp/docs/linux-advanced-storage.pdf

Very nice document.
Section 1.3 could update though. READCAPACITY16 is only mandatory in
SBC-2 IF the device supports protection information, but optional if
it does not.
In SBC-3 it is always mandatory though. Thin provisioning and
different logical/physical block sizes were only added to this command
in SBC-3 not SBC-2.


I have thus updated my READCAPACITY16 tests so that IF SBC-3 is
claimed, or if IQN-PROTECT is set
then the device must support this opcode or the test will fail.
Otherwise, if it is not SBC-3  and if PROTECT is clear, then the test
will be skipped but not fail if the opcode is missing.


If you want to, have time and if you have specific opcodes/features
that vendors get wrong,  I am happy to add tests if you point me in
the right direction for what you want me to add tests for.

regards
ronnie sahlberg



 --
 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