mptsas crash on expander hot-remove

2017-06-16 Thread Will Simoneau
I've got a disk box with a SAS expander connected to a card based on the 
LSI SAS1068E chip. I recently upgraded the machine from 4.5.7 to 4.11.5, 
and now disconnecting (i.e. hot removing) the SAS expander from the HBA 
results in fireworks like this:


[ 4738.044119]  end_device-6:0:0: mptsas: ioc2: removing sata device: 
fw_channel 0, fw_id 8, phy 0,sas_addr 0x500194752200
[ 4738.044126]  phy-6:0:8: mptsas: ioc2: delete phy 0, phy-obj 
(0x883f21a80c00)
[ 4738.044143]  port-6:0:0: mptsas: ioc2: delete port 0, sas_addr 
(0x500194752200)
[ 4738.051435]  end_device-6:0:3: mptsas: ioc2: removing ssp device: fw_channel 
0, fw_id 13, phy 5,sas_addr 0x5000c5000184240d
[ 4738.051442]  phy-6:0:13: mptsas: ioc2: delete phy 5, phy-obj 
(0x883f21a86c00)
[ 4738.051456]  port-6:0:3: mptsas: ioc2: delete port 3, sas_addr 
(0x5000c5000184240d)
[ 4738.054796]  end_device-6:0:2: mptsas: ioc2: removing sata device: 
fw_channel 0, fw_id 12, phy 4,sas_addr 0x500194752204
[ 4738.054801]  phy-6:0:12: mptsas: ioc2: delete phy 4, phy-obj 
(0x883f21a85400)
[ 4738.054814]  port-6:0:2: mptsas: ioc2: delete port 2, sas_addr 
(0x500194752204)
[ 4738.062425]  end_device-6:0:1: mptsas: ioc2: removing ssp device: fw_channel 
0, fw_id 9, phy 1,sas_addr 0x5000c5000182d58d
[ 4738.062432]  phy-6:0:9: mptsas: ioc2: delete phy 1, phy-obj 
(0x883f21a82400)
[ 4738.062446]  port-6:0:1: mptsas: ioc2: delete port 1, sas_addr 
(0x5000c5000182d58d)
[ 4738.062558]  end_device-6:0:0: mptsas: ioc2: removing sata device: 
fw_channel 0, fw_id 8, phy 0,sas_addr 0x500194752200
[ 4738.062560]  phy-6:0:8: mptsas: ioc2: delete phy 0, phy-obj 
(0x883f21a80c00)
[ 4738.062564]  port-6:0:0: mptsas: ioc2: delete port 0, sas_addr 
(0x500194752200)
[ 4738.062937]  end_device-6:0:7: mptsas: ioc2: removing ssp device: fw_channel 
0, fw_id 32, phy 24,sas_addr 0x50019475223e
[ 4738.062939]  phy-6:0:32: mptsas: ioc2: delete phy 24, phy-obj 
(0x883f21a78800)
[ 4738.062946]  port-6:0:7: mptsas: ioc2: delete port 7, sas_addr 
(0x50019475223e)
[ 4738.065679]  end_device-6:0:5: mptsas: ioc2: removing sata device: 
fw_channel 0, fw_id 20, phy 12,sas_addr 0x50019475220c
[ 4738.065683]  phy-6:0:20: mptsas: ioc2: delete phy 12, phy-obj 
(0x883f21a9a000)
[ 4738.065698]  port-6:0:5: mptsas: ioc2: delete port 5, sas_addr 
(0x50019475220c)
[ 4738.074843]  end_device-6:0:4: mptsas: ioc2: removing sata device: 
fw_channel 0, fw_id 16, phy 8,sas_addr 0x500194752208
[ 4738.074856]  phy-6:0:16: mptsas: ioc2: delete phy 8, phy-obj 
(0x883f21a82000)
[ 4738.074883]  port-6:0:4: mptsas: ioc2: delete port 4, sas_addr 
(0x500194752208)
[ 4738.136115] sd 6:0:3:0: [sdl] Synchronizing SCSI cache
[ 4738.136192] sd 6:0:3:0: [sdl] Synchronize Cache(10) failed: Result: 
hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
[ 4738.225172] [ cut here ]
[ 4738.225188] WARNING: CPU: 0 PID: 19546 at fs/sysfs/group.c:237 
sysfs_remove_group+0x89/0x90
[ 4738.225189] sysfs group 'power' not found for kobject 'target6:0:0'
[ 4738.225191] Modules linked in: iscsi_tcp libiscsi_tcp libiscsi 
scsi_transport_iscsi serpent_sse2_x86_64 serpent_generic ablk_helper 
algif_skcipher af_alg vmnet(O) vmblock(O) vmmon(O) vmw_vsock_vmci_transport 
vsock vmw_vmci nfsd rpcsec_gss_krb5 auth_rpcgss oid_registry nfsv4 nfs lockd 
grace sunrpc bonding cachefiles fscache binfmt_misc usb_storage ipmi_ssif 
pl2303 amdgpu usbserial snd_oxygen dcdbas i2c_algo_bit snd_oxygen_lib 
drm_kms_helper snd_hda_codec_hdmi coretemp snd_mpu401_uart cfbfillrect 
syscopyarea snd_rawmidi cfbimgblt sr_mod sysfillrect snd_seq_device sysimgblt 
cdrom snd_hda_intel fb_sys_fops mptsas cfbcopyarea snd_hda_codec ttm 
snd_hda_core drm snd_hwdep snd_pcm snd_timer snd soundcore i7300_edac bnx2 
edac_core mptspi mptscsih ipmi_si mptbase ipmi_devintf xhci_pci ipmi_msghandler 
xhci_hcd
[ 4738.225270] CPU: 0 PID: 19546 Comm: kworker/0:9 Tainted: G   O
4.11.5+ #8
[ 4738.225272] Hardware name: Dell Inc. PowerEdge R900/0TT975, BIOS 1.2.0 
11/11/2010
[ 4738.225283] Workqueue: mpt/2 mptsas_firmware_event_work [mptsas]
[ 4738.225285] Call Trace:
[ 4738.225297]  dump_stack+0x4d/0x65
[ 4738.225303]  __warn+0xc7/0xf0
[ 4738.225304]  warn_slowpath_fmt+0x46/0x50
[ 4738.225306]  sysfs_remove_group+0x89/0x90
[ 4738.225310]  dpm_sysfs_remove+0x52/0x60
[ 4738.225313]  device_del+0x119/0x320
[ 4738.225315]  ? kobject_release+0x4c/0x80
[ 4738.225319]  scsi_target_reap_ref_release+0x28/0x40
[ 4738.225320]  scsi_target_reap+0x29/0x30
[ 4738.225322]  scsi_remove_target+0x189/0x1a0
[ 4738.225325]  sas_rphy_remove+0x5b/0x70
[ 4738.225328]  sas_port_delete+0x28/0x160
[ 4738.225331]  ? sysfs_remove_link+0x14/0x30
[ 4738.225334]  mptsas_del_end_device+0x16c/0x1a0 [mptsas]
[ 4738.225336]  mptsas_expander_delete+0x129/0x310 [mptsas]
[ 4738.225338]  mptsas_firmware_event_work+0x69f/0xcda [mptsas]
[ 4738.225340]  ? mptsas_firmware_event_work+0x69f/0xcda [mptsas]
[ 4738.225346]  ? 

[PATCH 5/6] qla2xxx: Use FC-NMVe FC4 type for FDMI registration

2017-06-16 Thread Himanshu Madhani
From: Duane Grigsby 

Signed-off-by: Duane Grigsby 
Signed-off-by: Darren Trapp 
Signed-off-by: Anil Gurumurthy 
Signed-off-by: Giridhar Malavali 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_gs.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index c91478529b51..b323a7c71eda 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -2166,6 +2166,13 @@ qla2x00_fdmiv2_rpa(scsi_qla_host_t *vha)
eiter->a.fc4_types[2],
eiter->a.fc4_types[1]);
 
+   if (vha->flags.nvme_enabled) {
+   eiter->a.fc4_types[6] = 1;  /* NVMe type 28h */
+   ql_dbg(ql_dbg_disc, vha, 0x211f,
+   "NVME FC4 Type = %02x 0x0 0x0 0x0 0x0 0x0.\n",
+   eiter->a.fc4_types[6]);
+   }
+
/* Supported speed. */
eiter = entries + size;
eiter->type = cpu_to_be16(FDMI_PORT_SUPPORT_SPEED);
@@ -2363,6 +2370,15 @@ qla2x00_fdmiv2_rpa(scsi_qla_host_t *vha)
"Port Active FC4 Type = %02x %02x.\n",
eiter->a.port_fc4_type[2], eiter->a.port_fc4_type[1]);
 
+   if (vha->flags.nvme_enabled) {
+   eiter->a.port_fc4_type[4] = 0;
+   eiter->a.port_fc4_type[5] = 0;
+   eiter->a.port_fc4_type[6] = 1;  /* NVMe type 28h */
+   ql_dbg(ql_dbg_disc, vha, 0x2120,
+   "NVME Port Active FC4 Type = %02x 0x0 0x0 0x0 0x0 0x0.\n",
+   eiter->a.port_fc4_type[6]);
+   }
+
/* Port State */
eiter = entries + size;
eiter->type = cpu_to_be16(FDMI_PORT_STATE);
-- 
2.12.0



[PATCH 6/6] qla2xxx: Update Driver version to 10.00.00.00-k

2017-06-16 Thread Himanshu Madhani
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_version.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_version.h 
b/drivers/scsi/qla2xxx/qla_version.h
index dcbb9bb05e99..005a378f7fab 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,9 +7,9 @@
 /*
  * Driver version
  */
-#define QLA2XXX_VERSION  "9.01.00.00-k"
+#define QLA2XXX_VERSION  "10.00.00.00-k"
 
-#define QLA_DRIVER_MAJOR_VER   9
-#define QLA_DRIVER_MINOR_VER   1
+#define QLA_DRIVER_MAJOR_VER   10
+#define QLA_DRIVER_MINOR_VER   0
 #define QLA_DRIVER_PATCH_VER   0
 #define QLA_DRIVER_BETA_VER0
-- 
2.12.0



[PATCH 3/6] qla2xxx: Add FC-NVMe F/W initialization and transport registration

2017-06-16 Thread Himanshu Madhani
From: Duane Grigsby 

This code provides the interfaces to register remote and local ports
of FC4 type 0x28 with the FC-NVMe transport and transports the
requests (FC-NVMe FC link services and FC-NVMe commands IUs) to the
fabric. It also provides the support for allocating h/w queues and
aborting FC-NVMe FC requests.

Signed-off-by: Darren Trapp 
Signed-off-by: Duane Grigsby 
Signed-off-by: Anil Gurumurthy 
Signed-off-by: Giridhar Malavali 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/Makefile   |   2 +-
 drivers/scsi/qla2xxx/qla_dbg.c  |   2 +-
 drivers/scsi/qla2xxx/qla_def.h  |   3 +
 drivers/scsi/qla2xxx/qla_gbl.h  |  27 ++
 drivers/scsi/qla2xxx/qla_init.c |   8 +
 drivers/scsi/qla2xxx/qla_iocb.c |  36 ++
 drivers/scsi/qla2xxx/qla_isr.c  |  19 +
 drivers/scsi/qla2xxx/qla_mbx.c  |  22 ++
 drivers/scsi/qla2xxx/qla_nvme.c | 797 
 drivers/scsi/qla2xxx/qla_nvme.h | 132 +++
 drivers/scsi/qla2xxx/qla_os.c   |  40 +-
 11 files changed, 1079 insertions(+), 9 deletions(-)
 create mode 100644 drivers/scsi/qla2xxx/qla_nvme.c
 create mode 100644 drivers/scsi/qla2xxx/qla_nvme.h

diff --git a/drivers/scsi/qla2xxx/Makefile b/drivers/scsi/qla2xxx/Makefile
index 44def6bb4bb0..0b767a0bb308 100644
--- a/drivers/scsi/qla2xxx/Makefile
+++ b/drivers/scsi/qla2xxx/Makefile
@@ -1,6 +1,6 @@
 qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \
qla_dbg.o qla_sup.o qla_attr.o qla_mid.o qla_dfs.o qla_bsg.o \
-   qla_nx.o qla_mr.o qla_nx2.o qla_target.o qla_tmpl.o
+   qla_nx.o qla_mr.o qla_nx2.o qla_target.o qla_tmpl.o qla_nvme.o
 
 obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx.o
 obj-$(CONFIG_TCM_QLA2XXX) += tcm_qla2xxx.o
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index cf4f47603a91..d840529fc023 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -15,7 +15,7 @@
  * |  || 0x015b-0x0160 |
  * |  || 0x016e
|
  * | Mailbox commands |   0x1199   | 0x1193
|
- * | Device Discovery |   0x2131   | 0x210e-0x2116  |
+ * | Device Discovery |   0x2134   | 0x210e-0x2116  |
  * | || 0x211a |
  * |  || 0x211c-0x2128  |
  * |  || 0x212a-0x2130  |
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 693c42392886..c1edfa55b071 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -37,6 +37,7 @@
 #include "qla_bsg.h"
 #include "qla_nx.h"
 #include "qla_nx2.h"
+#include "qla_nvme.h"
 #define QLA2XXX_DRIVER_NAME"qla2xxx"
 #define QLA2XXX_APIDEV "ql2xapidev"
 #define QLA2XXX_MANUFACTURER   "QLogic Corporation"
@@ -423,6 +424,7 @@ struct srb_iocb {
int rsp_len;
dma_addr_t cmd_dma;
dma_addr_t rsp_dma;
+   enum nvmefc_fcp_datadir dir;
uint32_t dl;
uint32_t timeout_sec;
} nvme;
@@ -452,6 +454,7 @@ struct srb_iocb {
 #define SRB_NACK_PRLI  17
 #define SRB_NACK_LOGO  18
 #define SRB_NVME_CMD   19
+#define SRB_NVME_LS20
 #define SRB_PRLI_CMD   21
 
 enum {
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 6fbee11c1a18..fc2c03bda731 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -10,6 +10,32 @@
 #include 
 
 /*
+ * Global functions prototype in qla_nvme.c source file.
+ */
+extern void qla_nvme_register_hba(scsi_qla_host_t *);
+extern int  qla_nvme_register_remote(scsi_qla_host_t *, fc_port_t *);
+extern void qla_nvme_delete(scsi_qla_host_t *);
+extern void qla_nvme_abort(struct qla_hw_data *, srb_t *sp);
+extern void qla_nvme_unregister_remote_port(struct work_struct *);
+extern int qla_nvme_wait_on_rport_del(fc_port_t *);
+extern void qla_nvme_abort_all(fc_port_t *);
+extern int qla_nvme_post_cmd(struct nvme_fc_local_port *,
+struct nvme_fc_remote_port *, void *, struct nvmefc_fcp_req *);
+extern int qla_nvme_alloc_queue(struct nvme_fc_local_port *, unsigned int,
+u16, void **);
+extern int qla_nvme_hba_scan(scsi_qla_host_t *);
+extern void qla_nvme_ls_abort(struct nvme_fc_local_port *,
+struct nvme_fc_remote_port *, struct nvmefc_ls_req *);
+extern int qla_nvme_ls_req(struct nvme_fc_local_port *,
+struct nvme_fc_remote_port *, struct nvmefc_ls_req *);
+extern void qla_nvme_poll(struct nvme_fc_local_port *, void *);
+extern int qla2x00_start_nvme_mq(srb_t *);
+extern void 

[PATCH 4/6] qla2xxx: Send FC4 type NVMe to the management server

2017-06-16 Thread Himanshu Madhani
From: Duane Grigsby 

This patch adds switch command support for FC-4 type of FC-NVMe (0x28)
for resgistering HBA port to the management server. RFT_ID command is
used to register FC-4 type of 0x28 and RFF_ID is used to register
FC-4 features bits for FC-NVMe port.

Signed-off-by: Darren Trapp 
Signed-off-by: Duane Grigsby 
Signed-off-by: Anil Gurumurthy 
Signed-off-by: Giridhar Malavali 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h  |   1 +
 drivers/scsi/qla2xxx/qla_gbl.h  |   6 +-
 drivers/scsi/qla2xxx/qla_gs.c   | 118 +++-
 drivers/scsi/qla2xxx/qla_init.c |  11 +++-
 4 files changed, 131 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index c1edfa55b071..c68c1cb1aadf 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2866,6 +2866,7 @@ struct ct_sns_rsp {
} gpsc;
 
 #define GFF_FCP_SCSI_OFFSET7
+#define GFF_NVME_OFFSET23 /* type = 28h */
struct {
uint8_t fc4_features[128];
} gff_id;
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index fc2c03bda731..1a2b5b791e22 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -34,6 +34,7 @@ extern void qla_nvme_fcp_abort(struct nvme_fc_local_port *,
 struct nvme_fc_remote_port *, void *, struct nvmefc_fcp_req *);
 extern void qla24xx_nvme_ls4_iocb(scsi_qla_host_t *, struct pt_ls4_request *,
 struct req_que *);
+extern void qla24xx_async_gffid_sp_done(void *, int);
 
 /*
  * Global Function Prototypes in qla_init.c source file.
@@ -634,7 +635,7 @@ extern int qla2x00_gpn_id(scsi_qla_host_t *, sw_info_t *);
 extern int qla2x00_gnn_id(scsi_qla_host_t *, sw_info_t *);
 extern void qla2x00_gff_id(scsi_qla_host_t *, sw_info_t *);
 extern int qla2x00_rft_id(scsi_qla_host_t *);
-extern int qla2x00_rff_id(scsi_qla_host_t *);
+extern int qla2x00_rff_id(scsi_qla_host_t *, u8);
 extern int qla2x00_rnn_id(scsi_qla_host_t *);
 extern int qla2x00_rsnn_nn(scsi_qla_host_t *);
 extern void *qla2x00_prep_ms_fdmi_iocb(scsi_qla_host_t *, uint32_t, uint32_t);
@@ -660,7 +661,8 @@ void qla24xx_handle_gpnid_event(scsi_qla_host_t *, struct 
event_arg *);
 int qla24xx_post_gpsc_work(struct scsi_qla_host *, fc_port_t *);
 int qla24xx_async_gpsc(scsi_qla_host_t *, fc_port_t *);
 int qla2x00_mgmt_svr_login(scsi_qla_host_t *);
-
+void qla24xx_handle_gffid_event(scsi_qla_host_t *vha, struct event_arg *ea);
+int qla24xx_async_gffid(scsi_qla_host_t *vha, fc_port_t *fcport);
 /*
  * Global Function Prototypes in qla_attr.c source file.
  */
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index 540fec524ccb..c91478529b51 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -550,6 +550,8 @@ qla2x00_rft_id(scsi_qla_host_t *vha)
 
ct_req->req.rft_id.fc4_types[2] = 0x01; /* FCP-3 */
 
+   if (vha->flags.nvme_enabled)
+   ct_req->req.rft_id.fc4_types[6] = 1;/* NVMe type 28h */
/* Execute MS IOCB */
rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
sizeof(ms_iocb_entry_t));
@@ -575,7 +577,7 @@ qla2x00_rft_id(scsi_qla_host_t *vha)
  * Returns 0 on success.
  */
 int
-qla2x00_rff_id(scsi_qla_host_t *vha)
+qla2x00_rff_id(scsi_qla_host_t *vha, u8 type)
 {
int rval;
struct qla_hw_data *ha = vha->hw;
@@ -613,7 +615,7 @@ qla2x00_rff_id(scsi_qla_host_t *vha)
 
qlt_rff_id(vha, ct_req);
 
-   ct_req->req.rff_id.fc4_type = 0x08; /* SCSI - FCP */
+   ct_req->req.rff_id.fc4_type = type; /* SCSI - FCP */
 
/* Execute MS IOCB */
rval = qla2x00_issue_iocb(vha, ha->ms_iocb, ha->ms_iocb_dma,
@@ -2754,6 +2756,10 @@ qla2x00_gff_id(scsi_qla_host_t *vha, sw_info_t *list)
list[i].fc4_type = FC4_TYPE_FCP_SCSI;
else
list[i].fc4_type = FC4_TYPE_OTHER;
+
+   list[i].fc4f_nvme =
+   ct_rsp->rsp.gff_id.fc4_features[GFF_NVME_OFFSET];
+   list[i].fc4f_nvme &= 0xf;
}
 
/* Last device exit. */
@@ -3305,3 +3311,111 @@ int qla24xx_async_gpnid(scsi_qla_host_t *vha, port_id_t 
*id)
 done:
return rval;
 }
+
+void qla24xx_handle_gffid_event(scsi_qla_host_t *vha, struct event_arg *ea)
+{
+   fc_port_t *fcport = ea->fcport;
+
+   qla24xx_post_gnl_work(vha, fcport);
+}
+
+void qla24xx_async_gffid_sp_done(void *s, int res)
+{
+   struct srb *sp = s;
+   struct scsi_qla_host *vha = sp->vha;
+   fc_port_t *fcport = sp->fcport;
+   struct ct_sns_rsp *ct_rsp;
+  

[PATCH 1/6] qla2xxx: Add FC-NVMe port discovery and PRLI handling

2017-06-16 Thread Himanshu Madhani
From: Duane Grigsby 

Signed-off-by: Darren Trapp 
Signed-off-by: Duane Grigsby 
Signed-off-by: Anil Gurumurthy 
Signed-off-by: Giridhar Malavali 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_dbg.c|   9 +-
 drivers/scsi/qla2xxx/qla_def.h|  31 ++-
 drivers/scsi/qla2xxx/qla_fw.h |  13 ++-
 drivers/scsi/qla2xxx/qla_gbl.h|   1 +
 drivers/scsi/qla2xxx/qla_init.c   | 168 --
 drivers/scsi/qla2xxx/qla_iocb.c   |  21 +
 drivers/scsi/qla2xxx/qla_mbx.c|  33 +---
 drivers/scsi/qla2xxx/qla_os.c |   4 +
 drivers/scsi/qla2xxx/qla_target.c |   4 +-
 9 files changed, 257 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index c0c90dcc7c7b..cf4f47603a91 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -15,9 +15,10 @@
  * |  || 0x015b-0x0160 |
  * |  || 0x016e
|
  * | Mailbox commands |   0x1199   | 0x1193
|
- * | Device Discovery |   0x2004   | 0x2016
|
- * |  || 0x2011-0x2012, |
- * |  || 0x2099-0x20a4  |
+ * | Device Discovery |   0x2131   | 0x210e-0x2116  |
+ * | || 0x211a |
+ * |  || 0x211c-0x2128  |
+ * |  || 0x212a-0x2130  |
  * | Queue Command and IO tracing |   0x3074   | 0x300b |
  * |  || 0x3027-0x3028  |
  * |  || 0x303d-0x3041  |
@@ -59,7 +60,7 @@
  * |  || 0xb13c-0xb140  |
  * |  || 0xb149
|
  * | MultiQ   |   0xc010   |   |
- * | Misc |   0xd301   | 0xd031-0xd0ff |
+ * | Misc |   0xd302   | 0xd031-0xd0ff |
  * |  || 0xd101-0xd1fe |
  * |  || 0xd214-0xd2fe |
  * | Target Mode |   0xe081   ||
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index e1af9db3691d..bd1b3fef95a4 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -343,6 +343,7 @@ struct srb_iocb {
 #define SRB_LOGIN_RETRIED  BIT_0
 #define SRB_LOGIN_COND_PLOGI   BIT_1
 #define SRB_LOGIN_SKIP_PRLIBIT_2
+#define SRB_LOGIN_NVME_PRLIBIT_3
uint16_t data[2];
u32 iop[2];
} logio;
@@ -436,6 +437,7 @@ struct srb_iocb {
 #define SRB_NACK_PLOGI 16
 #define SRB_NACK_PRLI  17
 #define SRB_NACK_LOGO  18
+#define SRB_PRLI_CMD   21
 
 enum {
TYPE_SRB,
@@ -1088,6 +1090,7 @@ struct mbx_cmd_32 {
 #defineMBX_1   BIT_1
 #defineMBX_0   BIT_0
 
+#define RNID_TYPE_PORT_LOGIN   0x7
 #define RNID_TYPE_SET_VERSION  0x9
 #define RNID_TYPE_ASIC_TEMP0xC
 
@@ -2152,10 +2155,12 @@ typedef struct {
uint8_t fabric_port_name[WWN_SIZE];
uint16_t fp_speed;
uint8_t fc4_type;
+   uint8_t fc4f_nvme;  /* nvme fc4 feature bits */
 } sw_info_t;
 
 /* FCP-4 types */
 #define FC4_TYPE_FCP_SCSI  0x08
+#define FC4_TYPE_NVME  0x28
 #define FC4_TYPE_OTHER 0x0
 #define FC4_TYPE_UNKNOWN   0xff
 
@@ -2180,7 +2185,8 @@ typedef enum {
FCT_SWITCH,
FCT_BROADCAST,
FCT_INITIATOR,
-   FCT_TARGET
+   FCT_TARGET,
+   FCT_NVME
 } fc_port_type_t;
 
 enum qla_sess_deletion {
@@ -2237,10 +2243,12 @@ enum fcport_mgt_event {
FCME_RSCN,
FCME_GIDPN_DONE,
FCME_PLOGI_DONE,/* Initiator side sent LLIOCB */
+   FCME_PRLI_DONE,
FCME_GNL_DONE,
FCME_GPSC_DONE,
FCME_GPDB_DONE,
FCME_GPNID_DONE,
+   FCME_GFFID_DONE,
FCME_DELETE_DONE,
 };
 
@@ -2274,6 +2282,16 @@ typedef struct fc_port {
unsigned int login_pause:1;
unsigned int login_succ:1;
 
+   struct work_struct nvme_del_work;
+   atomic_t nvme_ref_count;
+   uint32_t nvme_prli_service_param;
+#define NVME_PRLI_SP_CONF   BIT_7
+#define NVME_PRLI_SP_INITIATOR  BIT_5
+#define NVME_PRLI_SP_TARGET BIT_4
+#define NVME_PRLI_SP_DISCOVERY  BIT_3
+   uint8_t nvme_flag;
+#define NVME_FLAG_REGISTERED 4
+
struct fc_port *conflict;
unsigned char 

[PATCH 2/6] qla2xxx: Add FC-NVMe command handling

2017-06-16 Thread Himanshu Madhani
From: Duane Grigsby 

Signed-off-by: Darren Trapp 
Signed-off-by: Duane Grigsby 
Signed-off-by: Anil Gurumurthy 
Signed-off-by: Giridhar Malavali 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h | 17 +
 drivers/scsi/qla2xxx/qla_fw.h  | 28 --
 drivers/scsi/qla2xxx/qla_isr.c | 86 ++
 drivers/scsi/qla2xxx/qla_os.c  | 18 -
 4 files changed, 144 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index bd1b3fef95a4..693c42392886 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -412,6 +412,20 @@ struct srb_iocb {
struct {
struct imm_ntfy_from_isp *ntfy;
} nack;
+   struct {
+   __le16 comp_status;
+   uint16_t rsp_pyld_len;
+   uint8_t aen_op;
+   void *desc;
+
+   /* These are only used with ls4 requests */
+   int cmd_len;
+   int rsp_len;
+   dma_addr_t cmd_dma;
+   dma_addr_t rsp_dma;
+   uint32_t dl;
+   uint32_t timeout_sec;
+   } nvme;
} u;
 
struct timer_list timer;
@@ -437,6 +451,7 @@ struct srb_iocb {
 #define SRB_NACK_PLOGI 16
 #define SRB_NACK_PRLI  17
 #define SRB_NACK_LOGO  18
+#define SRB_NVME_CMD   19
 #define SRB_PRLI_CMD   21
 
 enum {
@@ -4111,6 +4126,8 @@ typedef struct scsi_qla_host {
struct  nvme_fc_local_port *nvme_local_port;
atomic_tnvme_ref_count;
struct list_head nvme_rport_list;
+   atomic_tnvme_active_aen_cnt;
+   uint16_tnvme_last_rptd_aen;
 
uint16_tfcoe_vlan_id;
uint16_tfcoe_fcf_idx;
diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h
index dcae62d4cbeb..7d9a076c4667 100644
--- a/drivers/scsi/qla2xxx/qla_fw.h
+++ b/drivers/scsi/qla2xxx/qla_fw.h
@@ -603,9 +603,14 @@ struct sts_entry_24xx {
 
uint32_t residual_len;  /* FW calc residual transfer length. */
 
-   uint16_t reserved_1;
+   union {
+   uint16_t reserved_1;
+   uint16_t nvme_rsp_pyld_len;
+   };
+
uint16_t state_flags;   /* State flags. */
 #define SF_TRANSFERRED_DATABIT_11
+#define SF_NVME_ERSPBIT_6
 #define SF_FCP_RSP_DMA BIT_0
 
uint16_t retry_delay;
@@ -615,8 +620,25 @@ struct sts_entry_24xx {
uint32_t rsp_residual_count;/* FCP RSP residual count. */
 
uint32_t sense_len; /* FCP SENSE length. */
-   uint32_t rsp_data_len;  /* FCP response data length. */
-   uint8_t data[28];   /* FCP response/sense information. */
+
+   union {
+   struct {
+   uint32_t rsp_data_len;  /* FCP response data length  */
+   uint8_t data[28];   /* FCP rsp/sense information */
+   };
+   struct {
+   /* nvme ersp hdr */
+   __u8status_code;
+   __u8rsvd0;
+   __be16  iu_len;
+   __be32  rsn;
+   __be32  xfrd_len;
+   __be32  rsvd12;
+   uint8_t cqe[16];
+   };
+   uint8_t nvme_ersp_data[32];
+   };
+
/*
 * If DIF Error is set in comp_status, these additional fields are
 * defined:
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 40385bc1d1fa..0d60fd0da604 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1799,6 +1799,86 @@ qla24xx_tm_iocb_entry(scsi_qla_host_t *vha, struct 
req_que *req, void *tsk)
sp->done(sp, 0);
 }
 
+static void
+qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk)
+{
+   const char func[] = "NVME-IOCB";
+   fc_port_t *fcport;
+   srb_t *sp;
+   struct srb_iocb *iocb;
+   struct sts_entry_24xx *sts = (struct sts_entry_24xx *)tsk;
+   uint16_tstate_flags;
+   struct nvmefc_fcp_req *fd;
+   struct srb_iocb *nvme;
+
+   sp = qla2x00_get_sp_from_handle(vha, func, req, tsk);
+   if (!sp)
+   return;
+
+   iocb = >u.iocb_cmd;
+   fcport = sp->fcport;
+   iocb->u.nvme.comp_status = le16_to_cpu(sts->comp_status);
+   state_flags  = le16_to_cpu(sts->state_flags);
+   fd = iocb->u.nvme.desc;
+   nvme = >u.iocb_cmd;
+
+   if (unlikely(nvme->u.nvme.aen_op)) {
+   atomic_dec(>vha->nvme_active_aen_cnt);
+   

[PATCH 0/6] qla2xxx: Add NVMe FC Fabric support in driver

2017-06-16 Thread Himanshu Madhani
Hi Martin,

This patch series adds NVMe FC fabric support for qla2xxx initiator mode driver.

This series depends on the target multiqueue series that was sent out on June 
13,207. 
(https://www.spinics.net/lists/linux-scsi/msg109827.html)

There are couple of new files qla_nvme.c and qla_nvme.h created to add the 
changes needed
for registration to NVMe FC transport template as well as error handling logic.

Patch 1 adds NVMe bits to various driver resources to help with NVMe remote 
port discovery
and PRLI handling in the driver.

Patch 2 adds NVMe command handling in driver. 

Patch 3 has bulk of NVMe changes which handles NVMe support based on module 
paramter which
is used for firmware initialization and NVMe transport registration. All the 
logic to handle
NVMe command and error handling is also included in qla_nvme.c file.

Patch 4 and 5 are trivial changes for FDMI registration to send NVMe FC-4 type 
to switch
management server.

Please apply this series to for-next for inclusion in 4.13 merge window.

Note: Patch 2 does not compile due to change which are part of patch 3. 
  Please apply patch 1-6 to be able to get compilable driver. 

Thanks,
Himanshu 

Duane Grigsby (5):
  qla2xxx: Add FC-NVMe port discovery and PRLI handling
  qla2xxx: Add FC-NVMe command handling
  qla2xxx: Add FC-NVMe F/W initialization and transport registration
  qla2xxx: Send FC4 type NVMe to the management server
  qla2xxx: Use FC-NMVe FC4 type for FDMI registration

Himanshu Madhani (1):
  qla2xxx: Update Driver version to 10.00.00.00-k

 drivers/scsi/qla2xxx/Makefile  |   2 +-
 drivers/scsi/qla2xxx/qla_dbg.c |   9 +-
 drivers/scsi/qla2xxx/qla_def.h |  52 ++-
 drivers/scsi/qla2xxx/qla_fw.h  |  41 +-
 drivers/scsi/qla2xxx/qla_gbl.h |  34 +-
 drivers/scsi/qla2xxx/qla_gs.c  | 134 ++-
 drivers/scsi/qla2xxx/qla_init.c| 187 -
 drivers/scsi/qla2xxx/qla_iocb.c|  57 +++
 drivers/scsi/qla2xxx/qla_isr.c | 105 +
 drivers/scsi/qla2xxx/qla_mbx.c |  55 ++-
 drivers/scsi/qla2xxx/qla_nvme.c| 797 +
 drivers/scsi/qla2xxx/qla_nvme.h| 132 ++
 drivers/scsi/qla2xxx/qla_os.c  |  60 ++-
 drivers/scsi/qla2xxx/qla_target.c  |   4 +-
 drivers/scsi/qla2xxx/qla_version.h |   6 +-
 15 files changed, 1628 insertions(+), 47 deletions(-)
 create mode 100644 drivers/scsi/qla2xxx/qla_nvme.c
 create mode 100644 drivers/scsi/qla2xxx/qla_nvme.h

-- 
2.12.0



Re: [PATCH v2 2/5] dt-bindings: scsi: ufs: add document for hi3660-ufs

2017-06-16 Thread Arnd Bergmann
On Fri, Jun 16, 2017 at 8:51 AM, Bu Tao  wrote:
> add ufs node document for hi3660
>
> Signed-off-by: Bu Tao 
> ---
>  .../devicetree/bindings/ufs/hi3660-ufs.txt | 58 
> ++
>  1 file changed, 58 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/ufs/hi3660-ufs.txt
>
> diff --git a/Documentation/devicetree/bindings/ufs/hi3660-ufs.txt 
> b/Documentation/devicetree/bindings/ufs/hi3660-ufs.txt
> new file mode 100644
> index ..461afc8ef017
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/ufs/hi3660-ufs.txt
> @@ -0,0 +1,58 @@
> +* Hisilicon Universal Flash Storage (UFS) Host Controller
> +
> +UFS nodes are defined to describe on-chip UFS hardware macro.
> +Each UFS Host Controller should have its own node.
> +
> +Required properties:
> +- compatible: compatible list, contains one of the following -
> +   "hisilicon,hi3660-ufs" for hisi ufs host controller
> +present on Hi3660 chipset.
> +- reg   : should contain UFS register address space & UFS SYS 
> CTRL register address,
> +- interrupt-parent  : interrupt device
> +- interrupts: interrupt number
> +- clocks   : List of phandle and clock specifier pairs
> +- clock-names   : List of clock input name strings sorted in the same
> + order as the clocks property. "clk_ref", "clk_phy" is 
> optional
> +- resets: reset node register, one reset the clk and the other 
> reset the controller
> +- reset-names   : describe reset node register
> +
> +Optional properties for board device:
> +- ufs-hi3660-use-rate-B: specifies UFS rate-B
> +- ufs-hi3660-broken-fastauto   : specifies no fastauto
> +- ufs-hi3660-use-HS-GEAR3  : specifies UFS HS-GEAR3
> +- ufs-hi3660-use-HS-GEAR2  : specifies UFS HS-GEAR2
> +- ufs-hi3660-use-HS-GEAR1  : specifies UFS HS-GEAR1
> +- ufs-hi3660-broken-clk-gate-bypass: specifies no clk-gate
> +- ufs-hi3660-use-one-line  : specifies UFS use one line work
> +- reset-gpio   : specifies to reset devices

Some of these sound rather generic and might apply to UFS implementations
other than hi3660, so I'd suggest adding them to the base ufs binding with
a generic name instead.

Any DT properties that might be useful across multiple implementations
should be parsed in generic code that gets called by the individual drivers,
and then the properties that are specific to the integration work done by
hisilicon should be prefixed with "hisilicon,", but not normally with the
SoC name: it is quite possible that another SoC will be derived from this
chip and it should reuse the properties.

(note: this is different from the value of the "compatible" property that
is meant to be as specific as possible".

Also, please clarify how your binding relates to the ufshcd binding
in Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt: does
hi3660 implement any registers that are shared with ufshcd, or does
it use the same physical interface with a different register set?

   Arnd


Re: [PATCH 2/2] qedi: Remove WARN_ON from clear task context.

2017-06-16 Thread Lee Duncan
On 06/15/2017 12:10 AM, Manish Rangankar wrote:
> Signed-off-by: Manish Rangankar 
> ---
>  drivers/scsi/qedi/qedi_main.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
> index 09a2946..879d3b7 100644
> --- a/drivers/scsi/qedi/qedi_main.c
> +++ b/drivers/scsi/qedi/qedi_main.c
> @@ -1499,11 +1499,9 @@ int qedi_get_task_idx(struct qedi_ctx *qedi)
>  
>  void qedi_clear_task_idx(struct qedi_ctx *qedi, int idx)
>  {
> - if (!test_and_clear_bit(idx, qedi->task_idx_map)) {
> + if (!test_and_clear_bit(idx, qedi->task_idx_map))
>   QEDI_ERR(>dbg_ctx,
>"FW task context, already cleared, tid=0x%x\n", idx);
> - WARN_ON(1);
> - }
>  }
>  
>  void qedi_update_itt_map(struct qedi_ctx *qedi, u32 tid, u32 proto_itt,
> 

Reviewed-by: Lee Duncan 


Re: [PATCH 1/2] qedi: Remove WARN_ON for untracked cleanup.

2017-06-16 Thread Lee Duncan
On 06/15/2017 12:10 AM, Manish Rangankar wrote:
> Signed-off-by: Manish Rangankar 
> ---
>  drivers/scsi/qedi/qedi_fw.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c
> index 8bc7ee1..507512c 100644
> --- a/drivers/scsi/qedi/qedi_fw.c
> +++ b/drivers/scsi/qedi/qedi_fw.c
> @@ -870,7 +870,6 @@ static void qedi_process_cmd_cleanup_resp(struct qedi_ctx 
> *qedi,
>   QEDI_ERR(>dbg_ctx,
>"Delayed or untracked cleanup response, itt=0x%x, 
> tid=0x%x, cid=0x%x, task=%p\n",
>protoitt, cqe->itid, qedi_conn->iscsi_conn_id, task);
> - WARN_ON(1);
>   }
>  }
>  
> 

Reviewed-by: Lee Duncan 


Hello!

2017-06-16 Thread raymond.mabe...@ono.com
Hello!
MY Name Is Mrs  Raymond.Mabel
,I am contacting you  to help me And  My Daughter to  relocate  to your country 
My  husband was a serving director of the Gold exporting 
board until his death
He Was  planed and poisoned  By his  Family Members  He  made a deposit of 
($6,500,000.00) here in Ouagadougou Burkina Faso in one of the 
Security Finance Company  ,I 

Discovered The Certificate Of Deposit  About One Week Ago. Which  is with me 
now! i don’t want My husband Relatives To knows About This 
Fund.  That is the Reason I 

contacted You To Help Me To Claim This Fund  Out From The Security Company.
Reply To me I will Give you More Details
Thanks and best regards 
 Mrs Raymond.Mabel
--



Re: enclosure: fix sysfs symlinks creation when using multipath

2017-06-16 Thread Douglas Miller

On 06/16/2017 10:41 AM, Douglas Miller wrote:

On 03/16/2017 01:49 PM, James Bottomley wrote:

On Wed, 2017-03-15 at 19:39 -0400, Martin K. Petersen wrote:

Maurizio Lombardi  writes:


With multipath, it may happen that the same device is passed to
enclosure_add_device() multiple times and that the
enclosure_add_links() function fails to create the symlinks because
the device's sysfs directory entry is still NULL.  In this case,
the
links will never be created because all the subsequent calls to
enclosure_add_device() will immediately fail with EEXIST.

James?

Well I don't think the patch is the correct way to do this.  The
problem is that if we encounter an error creating the links, we
shouldn't add the device to the enclosure.  There's no need of a
links_created variable (see below).

However, more interesting is why the link creation failed in the first
place.  The device clearly seems to exist because it was added to sysfs
at time index 19.2 and the enclosure didn't try to use it until 60.0.
  Can you debug this a bit more, please?  I can't see anything specific
to multipath in the trace, so whatever this is looks like it could
happen in the single path case as well.

James

diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 65fed71..ae89082 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -375,6 +375,7 @@ int enclosure_add_device(struct enclosure_device 
*edev, int component,

   struct device *dev)
  {
  struct enclosure_component *cdev;
+int err;
if (!edev || component >= edev->components)
  return -EINVAL;
@@ -384,12 +385,15 @@ int enclosure_add_device(struct 
enclosure_device *edev, int component,

  if (cdev->dev == dev)
  return -EEXIST;
  -if (cdev->dev)
+if (cdev->dev) {
  enclosure_remove_links(cdev);
-
-put_device(cdev->dev);
-cdev->dev = get_device(dev);
-return enclosure_add_links(cdev);
+put_device(cdev->dev);
+cdev->dev = NULL;
+}
+err = enclosure_add_links(cdev);
+if (!err)
+cdev->dev = get_device(dev);
+return err;
  }
  EXPORT_SYMBOL_GPL(enclosure_add_device);
After stumbling across the NULL pointer panic, I was able to use 
Maurizio's second patch below:


diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 65fed71..6ac07ea 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -375,6 +375,7 @@ int enclosure_add_device(struct enclosure_device 
*edev, int component,

 struct device *dev)
 {
struct enclosure_component *cdev;
+   int err;

if (!edev || component >= edev->components)
return -EINVAL;
@@ -384,12 +385,17 @@ int enclosure_add_device(struct enclosure_device 
*edev, int component,

if (cdev->dev == dev)
return -EEXIST;

-   if (cdev->dev)
+   if (cdev->dev) {
enclosure_remove_links(cdev);
-
-   put_device(cdev->dev);
+   put_device(cdev->dev);
+   }
cdev->dev = get_device(dev);
-   return enclosure_add_links(cdev);
+   err = enclosure_add_links(cdev);
+   if (err) {
+   cdev->dev = NULL;
+   put_device(cdev->dev);
+   }
+   return err;
 }
 EXPORT_SYMBOL_GPL(enclosure_add_device);


I am able to pass my testing with this patch. I don't see an official 
submit of this patch, but will respond to it when I see one. Again, I 
am seeing the problem even without multipath.


Just to respond to James' question on the cause. What I observed was a 
race condition between udevd (ses_init()) and a worker thread 
(do_scan_async()), where the worker thread is creating the directories 
that are the target of the symlinks being created by udevd. Something 
was happening when udevd caught up with the worker thread (so the target 
directory did not exist) and it seemed the worker thread either got 
preempted or else just could not stay ahead of udevd. This means that 
udevd started failing to create symlinks even though the worker thread 
eventually got them all created. I did observe what appeared to be 
preemption, as the creation of directories stopped until udevd finished 
failing all the (rest of the) symlinks. Although there may have been 
other explanations for what I saw.




Re: enclosure: fix sysfs symlinks creation when using multipath

2017-06-16 Thread Douglas Miller

On 03/16/2017 01:49 PM, James Bottomley wrote:

On Wed, 2017-03-15 at 19:39 -0400, Martin K. Petersen wrote:

Maurizio Lombardi  writes:


With multipath, it may happen that the same device is passed to
enclosure_add_device() multiple times and that the
enclosure_add_links() function fails to create the symlinks because
the device's sysfs directory entry is still NULL.  In this case,
the
links will never be created because all the subsequent calls to
enclosure_add_device() will immediately fail with EEXIST.

James?

Well I don't think the patch is the correct way to do this.  The
problem is that if we encounter an error creating the links, we
shouldn't add the device to the enclosure.  There's no need of a
links_created variable (see below).

However, more interesting is why the link creation failed in the first
place.  The device clearly seems to exist because it was added to sysfs
at time index 19.2 and the enclosure didn't try to use it until 60.0.
  Can you debug this a bit more, please?  I can't see anything specific
to multipath in the trace, so whatever this is looks like it could
happen in the single path case as well.

James

diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 65fed71..ae89082 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -375,6 +375,7 @@ int enclosure_add_device(struct enclosure_device *edev, int 
component,
 struct device *dev)
  {
struct enclosure_component *cdev;
+   int err;
  
  	if (!edev || component >= edev->components)

return -EINVAL;
@@ -384,12 +385,15 @@ int enclosure_add_device(struct enclosure_device *edev, 
int component,
if (cdev->dev == dev)
return -EEXIST;
  
-	if (cdev->dev)

+   if (cdev->dev) {
enclosure_remove_links(cdev);
-
-   put_device(cdev->dev);
-   cdev->dev = get_device(dev);
-   return enclosure_add_links(cdev);
+   put_device(cdev->dev);
+   cdev->dev = NULL;
+   }
+   err = enclosure_add_links(cdev);
+   if (!err)
+   cdev->dev = get_device(dev);
+   return err;
  }
  EXPORT_SYMBOL_GPL(enclosure_add_device);
  
After stumbling across the NULL pointer panic, I was able to use 
Maurizio's second patch below:


diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 65fed71..6ac07ea 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -375,6 +375,7 @@ int enclosure_add_device(struct enclosure_device 
*edev, int component,

 struct device *dev)
 {
struct enclosure_component *cdev;
+   int err;

if (!edev || component >= edev->components)
return -EINVAL;
@@ -384,12 +385,17 @@ int enclosure_add_device(struct enclosure_device 
*edev, int component,

if (cdev->dev == dev)
return -EEXIST;

-   if (cdev->dev)
+   if (cdev->dev) {
enclosure_remove_links(cdev);
-
-   put_device(cdev->dev);
+   put_device(cdev->dev);
+   }
cdev->dev = get_device(dev);
-   return enclosure_add_links(cdev);
+   err = enclosure_add_links(cdev);
+   if (err) {
+   cdev->dev = NULL;
+   put_device(cdev->dev);
+   }
+   return err;
 }
 EXPORT_SYMBOL_GPL(enclosure_add_device);


I am able to pass my testing with this patch. I don't see an official 
submit of this patch, but will respond to it when I see one. Again, I am 
seeing the problem even without multipath.




Re: [PATCH] scsi_proto.h: ATA_32 added for ata pass-thru(32).

2017-06-16 Thread Bart Van Assche
On Thu, 2017-06-15 at 20:29 +0900, Minwoo Im wrote:
> SAT-4(SCSI/ATA Translation Standard) supports a ATA PASS-THROUGH(32)
> SCSI command. It uses 7Fh as a operation code which means
> variable-length CDB.
> It would be great if kernel supports an ata pass-thru(32) command.
> Prior to development of ata pass-through in libata level,
> the definition of it should be added first.
> 
> Signed-off-by: Minwoo Im 
> ---
>  include/scsi/scsi_proto.h |1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h
> index ce78ec8..1eb4efd 100644
> --- a/include/scsi/scsi_proto.h
> +++ b/include/scsi/scsi_proto.h
> @@ -164,6 +164,7 @@
>  #define WRITE_SAME_32  0x0d
>  
>  /* Values for T10/04-262r7 */
> +#define  ATA_320x7F  /* 32-byte pass-thru */
>  #define  ATA_160x85  /* 16-byte pass-thru */
>  #define  ATA_120xa1  /* 12-byte pass-thru */

Hello Minwoo,

In the Linux kernel we do not add such definitions separately but we
only add such definitions together with the code that uses the newly
introduced symbolic name.

Regarding the above patch, to keep the definitions consistent, please
use VARIABLE_LENGTH_CMD as a symbolic name for 0x7F and also add the
following definition below "/* values for variable length command */":

#define ATA_32 0x1ff0

Thanks,

Bart. 


[RFC] ubsan: signed integer overflow in scsi_partsize

2017-06-16 Thread Alice Ferrazzi
A Gentoo user reported a USBAN signed integer overflow in scsicam.c
Shall we change something?


kernel: UBSAN: Undefined behaviour in drivers/scsi/scsicam.c:173:29
kernel: signed integer overflow:
kernel: 62015235 * 63 cannot be represented in type 'int'
kernel: CPU: 0 PID: 14131 Comm: fdisk Tainted: P   O
4.9.25-gentoo #4
...
kernel: d6629cec d1f444f2 0007 d6629d1c 003f d6629cfc d1fc8ffe
d6629cfc
kernel: d3037320 d6629d80 d1fc934b d28b15c0 d6629d20 002a d6629d48
d3037320
kernel: 002a 3202 31303236 35333235 ecd1f900 ecd1f9a8 d6629d5c
d189d121
kernel: Call Trace:
kernel: [] dump_stack+0x59/0x87
kernel: [] ubsan_epilogue+0xe/0x40
kernel: [] handle_overflow+0xbb/0xf0
kernel: [] ? do_read_cache_page+0x71/0x570
kernel: [] ? blkdev_readpages+0x20/0x20
kernel: [] ? read_cache_page+0x26/0x50
kernel: [] __ubsan_handle_mul_overflow+0x12/0x20
kernel: [] scsi_partsize+0x217/0x2e0
kernel: [] scsicam_bios_param+0x46/0x380
kernel: [] sd_getgeo+0x174/0x2d0
kernel: [] blkdev_ioctl+0x251/0x12c0
kernel: [] block_ioctl+0x4c/0xb0
kernel: [] do_vfs_ioctl+0xc0/0xdf0
kernel: [] ? mntput+0x23/0x60
kernel: [] ? __fput+0x1e9/0x4e0
kernel: [] ? fput+0x8/0x10
kernel: [] ? task_work_run+0x60/0xd0
kernel: [] SyS_ioctl+0x2e/0x60
kernel: [] do_fast_syscall_32+0x11d/0x550
kernel: [] ? do_vfs_ioctl+0xdf0/0xdf0
kernel: [] sysenter_past_esp+0x47/0x75
kernel:


Thanks,
Alice


signature.asc
Description: PGP signature


Re: [RFC] enclosure: fix sysfs symlinks creation when using multipath

2017-06-16 Thread Douglas Miller

On 06/16/2017 07:48 AM, Maurizio Lombardi wrote:


Dne 16.6.2017 v 14:40 Douglas Miller napsal(a):

I'd like to add that we are seeing this problem with singlepath installations 
and need to get this fixed upstream as soon as possible. RHEL new product 
contains this fix and is working for us, but we need to be able to offer other 
distros as well. I am currently running this patch on a custom-built Ubuntu 
16.04.2 kernel and it is fixing the problem there.

What needs to be done to get this patch accepted?


Note that James proposed a different patch to fix this bug.

diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 65fed71..ae89082 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -375,6 +375,7 @@ int enclosure_add_device(struct enclosure_device *edev, int 
component,
 struct device *dev)
  {
struct enclosure_component *cdev;
+   int err;

if (!edev || component >= edev->components)
return -EINVAL;
@@ -384,12 +385,15 @@ int enclosure_add_device(struct enclosure_device *edev, 
int component,
if (cdev->dev == dev)
return -EEXIST;

-   if (cdev->dev)
+   if (cdev->dev) {
enclosure_remove_links(cdev);
-
-   put_device(cdev->dev);
-   cdev->dev = get_device(dev);
-   return enclosure_add_links(cdev);
+   put_device(cdev->dev);
+   cdev->dev = NULL;
+   }
+   err = enclosure_add_links(cdev);
+   if (!err)
+   cdev->dev = get_device(dev);
+   return err;
  }
  EXPORT_SYMBOL_GPL(enclosure_add_device);



I will test this out. Thanks.



Re: [RFC] enclosure: fix sysfs symlinks creation when using multipath

2017-06-16 Thread Maurizio Lombardi


Dne 16.6.2017 v 14:40 Douglas Miller napsal(a):
> 
> I'd like to add that we are seeing this problem with singlepath installations 
> and need to get this fixed upstream as soon as possible. RHEL new product 
> contains this fix and is working for us, but we need to be able to offer 
> other distros as well. I am currently running this patch on a custom-built 
> Ubuntu 16.04.2 kernel and it is fixing the problem there.
> 
> What needs to be done to get this patch accepted?
> 

Note that James proposed a different patch to fix this bug.

diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 65fed71..ae89082 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -375,6 +375,7 @@ int enclosure_add_device(struct enclosure_device *edev, int 
component,
 struct device *dev)
 {
struct enclosure_component *cdev;
+   int err;
 
if (!edev || component >= edev->components)
return -EINVAL;
@@ -384,12 +385,15 @@ int enclosure_add_device(struct enclosure_device *edev, 
int component,
if (cdev->dev == dev)
return -EEXIST;
 
-   if (cdev->dev)
+   if (cdev->dev) {
enclosure_remove_links(cdev);
-
-   put_device(cdev->dev);
-   cdev->dev = get_device(dev);
-   return enclosure_add_links(cdev);
+   put_device(cdev->dev);
+   cdev->dev = NULL;
+   }
+   err = enclosure_add_links(cdev);
+   if (!err)
+   cdev->dev = get_device(dev);
+   return err;
 }
 EXPORT_SYMBOL_GPL(enclosure_add_device);
 



Re: [RFC] enclosure: fix sysfs symlinks creation when using multipath

2017-06-16 Thread Douglas Miller

On 02/07/2017 08:08 AM, Maurizio Lombardi wrote:

With multipath, it may happen that the same device is passed
to enclosure_add_device() multiple times and that the enclosure_add_links()
function fails to create the symlinks because the device's sysfs
directory entry is still NULL.
In this case, the links will never be created because all the subsequent
calls to enclosure_add_device() will immediately fail with EEXIST.

This patch modifies the code so the driver will detect this condition
and will retry to create the symlinks when enclosure_add_device() is called.

Signed-off-by: Maurizio Lombardi 
---
  drivers/misc/enclosure.c  | 16 ++--
  include/linux/enclosure.h |  1 +
  2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 65fed71..a856c98 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -375,21 +375,33 @@ int enclosure_add_device(struct enclosure_device *edev, 
int component,
 struct device *dev)
  {
struct enclosure_component *cdev;
+   int error;
  
  	if (!edev || component >= edev->components)

return -EINVAL;
  
  	cdev = >component[component];
  
-	if (cdev->dev == dev)

+   if (cdev->dev == dev) {
+   if (!cdev->links_created) {
+   error = enclosure_add_links(cdev);
+   if (!error)
+   cdev->links_created = 1;
+   }
return -EEXIST;
+   }
  
  	if (cdev->dev)

enclosure_remove_links(cdev);
  
  	put_device(cdev->dev);

cdev->dev = get_device(dev);
-   return enclosure_add_links(cdev);
+   error = enclosure_add_links(cdev);
+   if (!error)
+   cdev->links_created = 1;
+   else
+   cdev->links_created = 0;
+   return error;
  }
  EXPORT_SYMBOL_GPL(enclosure_add_device);
  
diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h

index a4cf57c..c3bdc4c 100644
--- a/include/linux/enclosure.h
+++ b/include/linux/enclosure.h
@@ -97,6 +97,7 @@ struct enclosure_component {
struct device cdev;
struct device *dev;
enum enclosure_component_type type;
+   int links_created;
int number;
int fault;
int active;


Tested-by: Douglas Miller 

I'd like to add that we are seeing this problem with singlepath 
installations and need to get this fixed upstream as soon as possible. 
RHEL new product contains this fix and is working for us, but we need to 
be able to offer other distros as well. I am currently running this 
patch on a custom-built Ubuntu 16.04.2 kernel and it is fixing the 
problem there.


What needs to be done to get this patch accepted?

Thanks,
Doug



Re: [alsa-devel] [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs

2017-06-16 Thread Takashi Iwai
On Fri, 16 Jun 2017 10:51:47 +0200,
Christoph Hellwig wrote:
> 
> On Fri, Jun 16, 2017 at 10:49:56AM +0200, Takashi Iwai wrote:
> > On Fri, 16 Jun 2017 09:17:09 +0200,
> > Christoph Hellwig wrote:
> > > 
> > > Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.
> > > 
> > > Signed-off-by: Christoph Hellwig 
> > 
> > Should I take this one through sound git tree, or would you prefer
> > taking all through another?
> 
> Feel free to take it through the sound tree.

OK, applied now.  Thanks!


Takashi


Re: [alsa-devel] [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs

2017-06-16 Thread Christoph Hellwig
On Fri, Jun 16, 2017 at 10:49:56AM +0200, Takashi Iwai wrote:
> On Fri, 16 Jun 2017 09:17:09 +0200,
> Christoph Hellwig wrote:
> > 
> > Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.
> > 
> > Signed-off-by: Christoph Hellwig 
> 
> Should I take this one through sound git tree, or would you prefer
> taking all through another?

Feel free to take it through the sound tree.


Re: [alsa-devel] [PATCH 04/11] sound/hal2: switch to dma_alloc_attrs

2017-06-16 Thread Takashi Iwai
On Fri, 16 Jun 2017 09:17:09 +0200,
Christoph Hellwig wrote:
> 
> Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.
> 
> Signed-off-by: Christoph Hellwig 

Should I take this one through sound git tree, or would you prefer
taking all through another?

In the latter case,
  Reviewed-by: Takashi Iwai 


thanks,

Takashi

> ---
>  sound/mips/hal2.c | 20 ++--
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c
> index 00fc9241d266..17a78a93e885 100644
> --- a/sound/mips/hal2.c
> +++ b/sound/mips/hal2.c
> @@ -461,15 +461,15 @@ static int hal2_alloc_dmabuf(struct hal2_codec *codec)
>   int count = H2_BUF_SIZE / H2_BLOCK_SIZE;
>   int i;
>  
> - codec->buffer = dma_alloc_noncoherent(NULL, H2_BUF_SIZE,
> -   _dma, GFP_KERNEL);
> + codec->buffer = dma_alloc_attrs(NULL, H2_BUF_SIZE, _dma,
> + GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
>   if (!codec->buffer)
>   return -ENOMEM;
> - desc = dma_alloc_noncoherent(NULL, count * sizeof(struct hal2_desc),
> -  _dma, GFP_KERNEL);
> + desc = dma_alloc_attrs(NULL, count * sizeof(struct hal2_desc),
> +_dma, GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
>   if (!desc) {
> - dma_free_noncoherent(NULL, H2_BUF_SIZE,
> -  codec->buffer, buffer_dma);
> + dma_free_attrs(NULL, H2_BUF_SIZE, codec->buffer, buffer_dma,
> +DMA_ATTR_NON_CONSISTENT);
>   return -ENOMEM;
>   }
>   codec->buffer_dma = buffer_dma;
> @@ -490,10 +490,10 @@ static int hal2_alloc_dmabuf(struct hal2_codec *codec)
>  
>  static void hal2_free_dmabuf(struct hal2_codec *codec)
>  {
> - dma_free_noncoherent(NULL, codec->desc_count * sizeof(struct hal2_desc),
> -  codec->desc, codec->desc_dma);
> - dma_free_noncoherent(NULL, H2_BUF_SIZE, codec->buffer,
> -  codec->buffer_dma);
> + dma_free_attrs(NULL, codec->desc_count * sizeof(struct hal2_desc),
> +codec->desc, codec->desc_dma, DMA_ATTR_NON_CONSISTENT);
> + dma_free_attrs(NULL, H2_BUF_SIZE, codec->buffer, codec->buffer_dma,
> +DMA_ATTR_NON_CONSISTENT);
>  }
>  
>  static struct snd_pcm_hardware hal2_pcm_hw = {
> -- 
> 2.11.0
> 
> ___
> Alsa-devel mailing list
> alsa-de...@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 


[PATCH] scsi: default to scsi-mq

2017-06-16 Thread Christoph Hellwig
Remove the SCSI_MQ_DEFAULT config option and default to the blk-mq I/O
path now that we had plenty of testing, and have I/O schedulers for
blk-mq.  The module option to disable the blk-mq path is kept around
for now.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/Kconfig | 11 ---
 drivers/scsi/scsi.c  |  4 
 2 files changed, 15 deletions(-)

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 3c52867dfe28..d384f4f86c26 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -47,17 +47,6 @@ config SCSI_NETLINK
default n
depends on NET
 
-config SCSI_MQ_DEFAULT
-   bool "SCSI: use blk-mq I/O path by default"
-   depends on SCSI
-   ---help---
- This option enables the new blk-mq based I/O path for SCSI
- devices by default.  With the option the scsi_mod.use_blk_mq
- module/boot option defaults to Y, without it to N, but it can
- still be overridden either way.
-
- If unsure say N.
-
 config SCSI_PROC_FS
bool "legacy /proc/scsi/ support"
depends on SCSI && PROC_FS
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 1bf274e3b2b6..3d38c6d463b8 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -800,11 +800,7 @@ MODULE_LICENSE("GPL");
 module_param(scsi_logging_level, int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(scsi_logging_level, "a bit mask of logging levels");
 
-#ifdef CONFIG_SCSI_MQ_DEFAULT
 bool scsi_use_blk_mq = true;
-#else
-bool scsi_use_blk_mq = false;
-#endif
 module_param_named(use_blk_mq, scsi_use_blk_mq, bool, S_IWUSR | S_IRUGO);
 
 static int __init init_scsi(void)
-- 
2.11.0



Re: [PATCH 11/11] lpfc: update to revision to 11.4.0.1

2017-06-16 Thread Hannes Reinecke
On 06/16/2017 07:56 AM, James Smart wrote:
> Set lpfc driver revision to 11.4.0.1
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_version.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_version.h 
> b/drivers/scsi/lpfc/lpfc_version.h
> index 067c9e8a4b2d..c6a24c3e2d5e 100644
> --- a/drivers/scsi/lpfc/lpfc_version.h
> +++ b/drivers/scsi/lpfc/lpfc_version.h
> @@ -20,7 +20,7 @@
>   * included with this package. *
>   ***/
>  
> -#define LPFC_DRIVER_VERSION "11.4.0.0"
> +#define LPFC_DRIVER_VERSION "11.4.0.1"
>  #define LPFC_DRIVER_NAME "lpfc"
>  
>  /* Used for SLI 2/3 */
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 10/11] Driver responds LS_RJT to Beacon Off ELS - Linux

2017-06-16 Thread Hannes Reinecke
On 06/16/2017 07:56 AM, James Smart wrote:
> Beacon OFF from switch is rejected by driver.
> 
> Driver fails Beacon OFF if frequency is set to 0. As per fc-ls
> spec, status, capability, frequency and duration fields are only
> applicable for Beacon ON.
> 
> Remove frequency and type checks. Reject Beacon ON if duration
> is non zero.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_els.c | 22 --
>  1 file changed, 4 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
> index 54de984d695f..6d1d6f691df4 100644
> --- a/drivers/scsi/lpfc/lpfc_els.c
> +++ b/drivers/scsi/lpfc/lpfc_els.c
> @@ -5703,27 +5703,13 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct 
> lpfc_iocbq *cmdiocb,
>   rjt_err = LSRJT_CMD_UNSUPPORTED;
>   goto rjt;
>   }
> - if (beacon->lcb_frequency == 0) {
> + if (beacon->lcb_sub_command != LPFC_LCB_ON &&
> + beacon->lcb_sub_command != LPFC_LCB_OFF) {
>   rjt_err = LSRJT_CMD_UNSUPPORTED;
>   goto rjt;
>   }
> - if ((beacon->lcb_type != LPFC_LCB_GREEN) &&
> - (beacon->lcb_type != LPFC_LCB_AMBER)) {
> - rjt_err = LSRJT_CMD_UNSUPPORTED;
> - goto rjt;
> - }
> - if ((beacon->lcb_sub_command != LPFC_LCB_ON) &&
> - (beacon->lcb_sub_command != LPFC_LCB_OFF)) {
> - rjt_err = LSRJT_CMD_UNSUPPORTED;
> - goto rjt;
> - }
> - if ((beacon->lcb_sub_command == LPFC_LCB_ON) &&
> - (beacon->lcb_type != LPFC_LCB_GREEN) &&
> - (beacon->lcb_type != LPFC_LCB_AMBER)) {
> - rjt_err = LSRJT_CMD_UNSUPPORTED;
> - goto rjt;
> - }
> - if (be16_to_cpu(beacon->lcb_duration) != 0) {
> + if (beacon->lcb_sub_command == LPFC_LCB_ON &&
> + be16_to_cpu(beacon->lcb_duration) != 0) {
>   rjt_err = LSRJT_CMD_UNSUPPORTED;
>   goto rjt;
>   }
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 08/11] Fix crash doing IO with resets

2017-06-16 Thread Hannes Reinecke
On 06/16/2017 07:56 AM, James Smart wrote:
> During every reset, IOCBs are allocated. So, at one point, number of
> allocated IOCBs reaches maximum limit and lpfc_sli_next_iotag fails.
> 
> Allocate IOCBs only during initialization. Reuse them after every reset
> instead of allocating new set of IOCBs.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_sli.c | 22 --
>  1 file changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
> index 8de70b9d79dd..e948ea05fd33 100644
> --- a/drivers/scsi/lpfc/lpfc_sli.c
> +++ b/drivers/scsi/lpfc/lpfc_sli.c
> @@ -6927,18 +6927,6 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
>   cnt = phba->cfg_iocb_cnt * 1024;
>   /* We need 1 iocbq for every SGL, for IO processing */
>   cnt += phba->sli4_hba.nvmet_xri_cnt;
> - /* Initialize and populate the iocb list per host */
> - lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
> - "2821 initialize iocb list %d total %d\n",
> - phba->cfg_iocb_cnt, cnt);
> - rc = lpfc_init_iocb_list(phba, cnt);
> - if (rc) {
> - lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
> - "1413 Failed to init iocb list.\n");
> - goto out_destroy_queue;
> - }
> -
> - lpfc_nvmet_create_targetport(phba);
>   } else {
>   /* update host scsi xri-sgl sizes and mappings */
>   rc = lpfc_sli4_scsi_sgl_update(phba);
> @@ -6959,18 +6947,24 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
>   }
>  
>   cnt = phba->cfg_iocb_cnt * 1024;
> + }
> +
> + if (!phba->sli.iocbq_lookup) {
>   /* Initialize and populate the iocb list per host */
>   lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
> - "2820 initialize iocb list %d total %d\n",
> + "2821 initialize iocb list %d total %d\n",
>   phba->cfg_iocb_cnt, cnt);
>   rc = lpfc_init_iocb_list(phba, cnt);
>   if (rc) {
>   lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
> - "6301 Failed to init iocb list.\n");
> + "1413 Failed to init iocb list.\n");
>   goto out_destroy_queue;
>   }
>   }
>  
> + if (phba->nvmet_support)
> + lpfc_nvmet_create_targetport(phba);
> +
>   if (phba->nvmet_support && phba->cfg_nvmet_mrq) {
>   /* Post initial buffers to all RQs created */
>   for (i = 0; i < phba->cfg_nvmet_mrq; i++) {
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 09/11] Fix crash in lpfc_sli_ringtxcmpl_put when nvmet gets an abort request.

2017-06-16 Thread Hannes Reinecke
On 06/16/2017 07:56 AM, James Smart wrote:
> When running nvme detach-ns /dev/nvme0n1 -n 1 command,
> the nvmet lpfc driver crashes with this stack dump:
> 
> kernel BUG at /root/NVME/lpfc_8.4/lpfc_sli.c:1393!
> invalid opcode:  [#1] SMP
> Workqueue: nvmet-fc-cpu0 nvmet_fc_do_work_on_cpu [nvmet_fc]
>  lpfc_sli4_issue_wqe+0x357/0x440 [lpfc]
>  lpfc_nvmet_xmt_fcp_abort+0x36b/0x5c0 [lpfc]
>  nvmet_fc_abort_op+0x30/0x50 [nvmet_fc]
>  nvmet_fc_do_work_on_cpu+0xd9/0x130 [nvmet_fc]
>  process_one_work+0x14e/0x410
>  worker_thread+0x116/0x490
>  kthread+0xc7/0xe0
>  ret_from_fork+0x3f/0x70
> 
> Crash is due to an uninitialized iocbq->vport pointer.
> 
> Explicitly set the iocbq->vport field to phba->pport in
> lpfc_nvmet_sol_fcp_issue_abort as it does all abort iocbq
> initialization in the routine.  Using phba->pport is ok because
> target does not support NPIV instances.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_nvmet.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
> index 5fb29735e236..7dc061a14f95 100644
> --- a/drivers/scsi/lpfc/lpfc_nvmet.c
> +++ b/drivers/scsi/lpfc/lpfc_nvmet.c
> @@ -2523,6 +2523,7 @@ lpfc_nvmet_sol_fcp_issue_abort(struct lpfc_hba *phba,
>   abts_wqeq->iocb_cmpl = 0;
>   abts_wqeq->iocb_flag |= LPFC_IO_NVME;
>   abts_wqeq->context2 = ctxp;
> + abts_wqeq->vport = phba->pport;
>   rc = lpfc_sli4_issue_wqe(phba, LPFC_FCP_RING, abts_wqeq);
>   spin_unlock_irqrestore(>hbalock, flags);
>   if (rc == WQE_SUCCESS) {
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 07/11] Fix crash after firmware flash when IO is running.

2017-06-16 Thread Hannes Reinecke
On 06/16/2017 07:56 AM, James Smart wrote:
> OS crashes after the completion of firmware download.
> 
> Failure in posting SCSI SGL buffers because number of SGL buffers
> is less than total count. Some of the pending IOs are not completed
> by driver. SGL buffers for these IOs are not added back to the list.
> Pending IOs are not completed because lpfc_wq_list list is
> initialized before completion of pending IOs.
> 
> Postpone lpfc_wq_list reinitialization by moving
> lpfc_sli4_queue_destroy() after lpfc_hba_down_post().
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_sli.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
> index 4f2cc395597e..8de70b9d79dd 100644
> --- a/drivers/scsi/lpfc/lpfc_sli.c
> +++ b/drivers/scsi/lpfc/lpfc_sli.c
> @@ -4303,7 +4303,6 @@ lpfc_sli4_brdreset(struct lpfc_hba *phba)
>  
>   /* Perform FCoE PCI function reset before freeing queue memory */
>   rc = lpfc_pci_function_reset(phba);
> - lpfc_sli4_queue_destroy(phba);
>  
>   /* Restore PCI cmd register */
>   pci_write_config_word(phba->pcidev, PCI_COMMAND, cfg_value);
> @@ -4428,6 +4427,7 @@ lpfc_sli_brdrestart_s4(struct lpfc_hba *phba)
>   pci_disable_pcie_error_reporting(phba->pcidev);
>  
>   lpfc_hba_down_post(phba);
> + lpfc_sli4_queue_destroy(phba);
>  
>   return rc;
>  }
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 06/11] Fix SLI3 drivers attempting NVME ELS commands.

2017-06-16 Thread Hannes Reinecke
On 06/16/2017 07:56 AM, James Smart wrote:
> In a server with an 8G adapter and a 32G adapter, running NVME
> and FCP, the server would crash with the following stack.
> 
> RIP: 0010: ... lpfc_nvme_register_port+0x38/0x420 [lpfc]
>  lpfc_nlp_state_cleanup+0x154/0x4f0 [lpfc]
>  lpfc_nlp_set_state+0x9d/0x1a0 [lpfc]
>  lpfc_cmpl_prli_prli_issue+0x35f/0x440 [lpfc]
>  lpfc_disc_state_machine+0x78/0x1c0 [lpfc]
>  lpfc_cmpl_els_prli+0x17c/0x1f0 [lpfc]
>  lpfc_sli_sp_handle_rspiocb+0x39b/0x6b0 [lpfc]
>  lpfc_sli_handle_slow_ring_event_s3+0x134/0x2d0 [lpfc]
>  lpfc_work_done+0x8ac/0x13b0 [lpfc]
>  lpfc_do_work+0xf1/0x1b0 [lpfc]
> 
> Crash, on the 8G adapter, is due to a vport which does not have
> a nvme local port structure. It's not supposed to have one. NVME is
> not supported on the 8G adapter, so the NVME PRLI, which started
> this flow shouldn't have been sent in the first place.
> 
> Correct discovery engine to recognize when on an SLI3 rport, which
> doesn't support SLI3, if the rport supports only NVME, don't send
> a NVME PRLI. Instead, as no FC4 will be used, a LOGO is sent.
> If rport is FCP and NVME, only execute the SCSI PRLI.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_els.c | 16 +++-
>  drivers/scsi/lpfc/lpfc_hbadisc.c |  3 ++-
>  2 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
> index a140318d6159..54de984d695f 100644
> --- a/drivers/scsi/lpfc/lpfc_els.c
> +++ b/drivers/scsi/lpfc/lpfc_els.c
> @@ -2168,6 +2168,19 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct 
> lpfc_nodelist *ndlp,
>ndlp->nlp_fc4_type, ndlp->nlp_DID);
>   return 1;
>   }
> +
> + /* SLI3 ports don't support NVME.  If this rport is a strict NVME
> +  * FC4 type, implicitly LOGO.
> +  */
> + if (phba->sli_rev == LPFC_SLI_REV3 &&
> + ndlp->nlp_fc4_type == NLP_FC4_NVME) {
> + lpfc_printf_vlog(vport, KERN_INFO, LOG_DISCOVERY,
> +  "3088 Rport fc4 type 0x%x not supported by 
> SLI3 adapter\n",
> +  ndlp->nlp_type);
> + lpfc_disc_state_machine(vport, ndlp, NULL, NLP_EVT_DEVICE_RM);
> + return 1;
> + }
> +
>   elsiocb = lpfc_prep_els_iocb(vport, 1, cmdsize, retry, ndlp,
>ndlp->nlp_DID, elscmd);
>   if (!elsiocb)
> @@ -2268,7 +2281,8 @@ lpfc_issue_els_prli(struct lpfc_vport *vport, struct 
> lpfc_nodelist *ndlp,
>   /* The driver supports 2 FC4 types.  Make sure
>* a PRLI is issued for all types before exiting.
>*/
> - if (local_nlp_type & (NLP_FC4_FCP | NLP_FC4_NVME))
> + if (phba->sli_rev == LPFC_SLI_REV4 &&
> + local_nlp_type & (NLP_FC4_FCP | NLP_FC4_NVME))
>   goto send_next_prli;
>  
>   return 0;
> diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c 
> b/drivers/scsi/lpfc/lpfc_hbadisc.c
> index db2d0e692ddf..aa5e5ff56dfb 100644
> --- a/drivers/scsi/lpfc/lpfc_hbadisc.c
> +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
> @@ -4194,7 +4194,8 @@ lpfc_nlp_state_cleanup(struct lpfc_vport *vport, struct 
> lpfc_nodelist *ndlp,
>   lpfc_register_remote_port(vport, ndlp);
>   }
>   /* Notify the NVME transport of this new rport. */
> - if (ndlp->nlp_fc4_type & NLP_FC4_NVME) {
> + if (vport->phba->sli_rev >= LPFC_SLI_REV4 &&
> + ndlp->nlp_fc4_type & NLP_FC4_NVME) {
>   if (vport->phba->nvmet_support == 0) {
>   /* Register this rport with the transport.
>* Initiators take the NDLP ref count in
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 05/11] Break up IO ctx list into a separate get and put list

2017-06-16 Thread Hannes Reinecke
On 06/16/2017 07:56 AM, James Smart wrote:
> Since unsol rcv ISR and command cmpl ISR both access/lock
> this list, a separate get/put lists will reduce contention.
> 
> Replaced
> struct list_head lpfc_nvmet_ctx_list;
> with
> struct list_head lpfc_nvmet_ctx_get_list;
> struct list_head lpfc_nvmet_ctx_put_list;
> and all correpsonding locks and counters.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_attr.c| 11 --
>  drivers/scsi/lpfc/lpfc_debugfs.c | 11 --
>  drivers/scsi/lpfc/lpfc_init.c| 16 +---
>  drivers/scsi/lpfc/lpfc_nvmet.c   | 82 
> +---
>  drivers/scsi/lpfc/lpfc_sli4.h|  9 +++--
>  5 files changed, 89 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
> index af22602b1058..4ed48ed38e79 100644
> --- a/drivers/scsi/lpfc/lpfc_attr.c
> +++ b/drivers/scsi/lpfc/lpfc_attr.c
> @@ -245,15 +245,18 @@ lpfc_nvme_info_show(struct device *dev, struct 
> device_attribute *attr,
>   atomic_read(>xmt_abort_rsp),
>   atomic_read(>xmt_abort_rsp_error));
>  
> - spin_lock(>sli4_hba.nvmet_io_lock);
> + spin_lock(>sli4_hba.nvmet_ctx_get_lock);
> + spin_lock(>sli4_hba.nvmet_ctx_put_lock);
>   tot = phba->sli4_hba.nvmet_xri_cnt -
> - phba->sli4_hba.nvmet_ctx_cnt;
> - spin_unlock(>sli4_hba.nvmet_io_lock);
> + (phba->sli4_hba.nvmet_ctx_get_cnt +
> + phba->sli4_hba.nvmet_ctx_put_cnt);
> + spin_unlock(>sli4_hba.nvmet_ctx_put_lock);
> + spin_unlock(>sli4_hba.nvmet_ctx_get_lock);
>  
>   len += snprintf(buf + len, PAGE_SIZE - len,
>   "IO_CTX: %08x  WAIT: cur %08x tot %08x\n"
>   "CTX Outstanding %08llx\n",
> - phba->sli4_hba.nvmet_ctx_cnt,
> + phba->sli4_hba.nvmet_xri_cnt,
>   phba->sli4_hba.nvmet_io_wait_cnt,
>   phba->sli4_hba.nvmet_io_wait_total,
>   tot);
Question is if you need the lock here; after all, we could just store
the values in local variables and drop the lock altogether ...

> diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c 
> b/drivers/scsi/lpfc/lpfc_debugfs.c
> index cc49850e18a9..ed2850645e70 100644
> --- a/drivers/scsi/lpfc/lpfc_debugfs.c
> +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
> @@ -848,15 +848,18 @@ lpfc_debugfs_nvmestat_data(struct lpfc_vport *vport, 
> char *buf, int size)
>   spin_unlock(>sli4_hba.abts_nvme_buf_list_lock);
>   }
>  
> - spin_lock(>sli4_hba.nvmet_io_lock);
> + spin_lock(>sli4_hba.nvmet_ctx_get_lock);
> + spin_lock(>sli4_hba.nvmet_ctx_put_lock);
>   tot = phba->sli4_hba.nvmet_xri_cnt -
> - phba->sli4_hba.nvmet_ctx_cnt;
> - spin_unlock(>sli4_hba.nvmet_io_lock);
> + (phba->sli4_hba.nvmet_ctx_get_cnt +
> + phba->sli4_hba.nvmet_ctx_put_cnt);
> + spin_unlock(>sli4_hba.nvmet_ctx_put_lock);
> + spin_unlock(>sli4_hba.nvmet_ctx_get_lock);
>  
>   len += snprintf(buf + len, size - len,
>   "IO_CTX: %08x  WAIT: cur %08x tot %08x\n"
>   "CTX Outstanding %08llx\n",
> - phba->sli4_hba.nvmet_ctx_cnt,
> + phba->sli4_hba.nvmet_xri_cnt,
>   phba->sli4_hba.nvmet_io_wait_cnt,
>   phba->sli4_hba.nvmet_io_wait_total,
>   tot);
Same here.

> diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
> index 77283705eb8d..7e73fdc154f7 100644
> --- a/drivers/scsi/lpfc/lpfc_init.c
> +++ b/drivers/scsi/lpfc/lpfc_init.c
> @@ -1281,10 +1281,13 @@ lpfc_hb_timeout_handler(struct lpfc_hba *phba)
>   /* Check outstanding IO count */
>   if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) {
>   if (phba->nvmet_support) {
> - spin_lock(>sli4_hba.nvmet_io_lock);
> + spin_lock(>sli4_hba.nvmet_ctx_get_lock);
> + spin_lock(>sli4_hba.nvmet_ctx_put_lock);
>   tot = phba->sli4_hba.nvmet_xri_cnt -
> - phba->sli4_hba.nvmet_ctx_cnt;
> - spin_unlock(>sli4_hba.nvmet_io_lock);
> + (phba->sli4_hba.nvmet_ctx_get_cnt +
> + phba->sli4_hba.nvmet_ctx_put_cnt);
> + spin_unlock(>sli4_hba.nvmet_ctx_put_lock);
> +   

Re: [PATCH 03/11] Vport creation is failing with "Link Down" error

2017-06-16 Thread Hannes Reinecke
On 06/16/2017 07:56 AM, James Smart wrote:
> Vport creation fails for SLI-3 adapters.
> 
> Mailbox submission fails because mailbox interrupt is disabled. Mailbox
> interrupt is disabled during port reset.
> 
> Do reset only for physical port.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_init.c | 21 -
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
> index 9d3a12636455..77283705eb8d 100644
> --- a/drivers/scsi/lpfc/lpfc_init.c
> +++ b/drivers/scsi/lpfc/lpfc_init.c
> @@ -3691,14 +3691,6 @@ lpfc_get_wwpn(struct lpfc_hba *phba)
>   LPFC_MBOXQ_t *mboxq;
>   MAILBOX_t *mb;
>  
> - if (phba->sli_rev < LPFC_SLI_REV4) {
> - /* Reset the port first */
> - lpfc_sli_brdrestart(phba);
> - rc = lpfc_sli_chipset_init(phba);
> - if (rc)
> - return (uint64_t)-1;
> - }
> -
>   mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool,
>   GFP_KERNEL);
>   if (!mboxq)
> @@ -3852,8 +3844,19 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, 
> struct device *dev)
>   int i;
>   uint64_t wwn;
>   bool use_no_reset_hba = false;
> + int rc;
>  
> - wwn = lpfc_get_wwpn(phba);
> + if (lpfc_no_hba_reset_cnt) {
> + if (phba->sli_rev < LPFC_SLI_REV4 &&
> + dev == >pcidev->dev) {
> + /* Reset the port first */
> + lpfc_sli_brdrestart(phba);
> + rc = lpfc_sli_chipset_init(phba);
> + if (rc)
> + return NULL;
> + }
> + wwn = lpfc_get_wwpn(phba);
> + }
>  
>   for (i = 0; i < lpfc_no_hba_reset_cnt; i++) {
>   if (wwn == lpfc_no_hba_reset[i]) {
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 04/11] Reduce time spent in IRQ for received NVME commands

2017-06-16 Thread Hannes Reinecke
On 06/16/2017 07:56 AM, James Smart wrote:
> Removed unnecessary bzero of context area. Due to size of sg list,
> added a substantial delay and played havoc on cpu caches.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_nvmet.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
> index dba1bd216be3..431faa0a4f3e 100644
> --- a/drivers/scsi/lpfc/lpfc_nvmet.c
> +++ b/drivers/scsi/lpfc/lpfc_nvmet.c
> @@ -205,7 +205,6 @@ lpfc_nvmet_ctxbuf_post(struct lpfc_hba *phba, struct 
> lpfc_nvmet_ctxbuf *ctx_buf)
>   sid = sli4_sid_from_fc_hdr(fc_hdr);
>  
>   ctxp = (struct lpfc_nvmet_rcv_ctx *)ctx_buf->context;
> - memset(ctxp, 0, sizeof(ctxp->ctx));
>   ctxp->wqeq = NULL;
>   ctxp->txrdy = NULL;
>   ctxp->offset = 0;
> @@ -1422,7 +1421,6 @@ lpfc_nvmet_unsol_fcp_buffer(struct lpfc_hba *phba,
>   "6414 NVMET Context corrupt %d %d oxid x%x\n",
>   ctxp->state, ctxp->entry_cnt, ctxp->oxid);
>   }
> - memset(ctxp, 0, sizeof(ctxp->ctx));
>   ctxp->wqeq = NULL;
>   ctxp->txrdy = NULL;
>   ctxp->offset = 0;
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 02/11] Fix nvme_info sysfs output to be consistent

2017-06-16 Thread Hannes Reinecke
On 06/16/2017 07:56 AM, James Smart wrote:
> First line of nvme_info output is not consistent
> 
> There is an Extra colon in the format.
> 
> First line of output will contain one of the following strings:
> NVME Initiator Enabled
> NVME Target Enabled
> NVME Disabled
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_attr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
> index 66269e342c7e..af22602b1058 100644
> --- a/drivers/scsi/lpfc/lpfc_attr.c
> +++ b/drivers/scsi/lpfc/lpfc_attr.c
> @@ -171,7 +171,7 @@ lpfc_nvme_info_show(struct device *dev, struct 
> device_attribute *attr,
>   else
>   statep = "INIT";
>   len += snprintf(buf + len, PAGE_SIZE - len,
> - "NVME Target: Enabled  State %s\n",
> + "NVME Target Enabled  State %s\n",
>   statep);
>   len += snprintf(buf + len, PAGE_SIZE - len,
>   "%s%d WWPN x%llx WWNN x%llx DID x%06x\n",
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCH 01/11] Fix system panic when express lane enabled.

2017-06-16 Thread Hannes Reinecke
On 06/16/2017 07:56 AM, James Smart wrote:
> There is a null pointer dereference that can happen in the FOF interrupt
> handler.
> 
> The driver was not setting up cq->assoc_qp_for sli4_hba->oas_cq.
> 
> Initialize cq->assoc_qp before accessing it.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_sli.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
> index 040575adf9c6..4f2cc395597e 100644
> --- a/drivers/scsi/lpfc/lpfc_sli.c
> +++ b/drivers/scsi/lpfc/lpfc_sli.c
> @@ -13560,6 +13560,9 @@ lpfc_sli4_fof_handle_eqe(struct lpfc_hba *phba, 
> struct lpfc_eqe *eqe)
>   return;
>   }
>  
> + /* Save EQ associated with this CQ */
> + cq->assoc_qp = phba->sli4_hba.fof_eq;
> +
>   /* Process all the entries to the OAS CQ */
>   while ((cqe = lpfc_sli4_cq_get(cq))) {
>   workposted |= lpfc_sli4_fp_handle_cqe(phba, cq, cqe);
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


[PATCH 04/11] sound/hal2: switch to dma_alloc_attrs

2017-06-16 Thread Christoph Hellwig
Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.

Signed-off-by: Christoph Hellwig 
---
 sound/mips/hal2.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c
index 00fc9241d266..17a78a93e885 100644
--- a/sound/mips/hal2.c
+++ b/sound/mips/hal2.c
@@ -461,15 +461,15 @@ static int hal2_alloc_dmabuf(struct hal2_codec *codec)
int count = H2_BUF_SIZE / H2_BLOCK_SIZE;
int i;
 
-   codec->buffer = dma_alloc_noncoherent(NULL, H2_BUF_SIZE,
- _dma, GFP_KERNEL);
+   codec->buffer = dma_alloc_attrs(NULL, H2_BUF_SIZE, _dma,
+   GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
if (!codec->buffer)
return -ENOMEM;
-   desc = dma_alloc_noncoherent(NULL, count * sizeof(struct hal2_desc),
-_dma, GFP_KERNEL);
+   desc = dma_alloc_attrs(NULL, count * sizeof(struct hal2_desc),
+  _dma, GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
if (!desc) {
-   dma_free_noncoherent(NULL, H2_BUF_SIZE,
-codec->buffer, buffer_dma);
+   dma_free_attrs(NULL, H2_BUF_SIZE, codec->buffer, buffer_dma,
+  DMA_ATTR_NON_CONSISTENT);
return -ENOMEM;
}
codec->buffer_dma = buffer_dma;
@@ -490,10 +490,10 @@ static int hal2_alloc_dmabuf(struct hal2_codec *codec)
 
 static void hal2_free_dmabuf(struct hal2_codec *codec)
 {
-   dma_free_noncoherent(NULL, codec->desc_count * sizeof(struct hal2_desc),
-codec->desc, codec->desc_dma);
-   dma_free_noncoherent(NULL, H2_BUF_SIZE, codec->buffer,
-codec->buffer_dma);
+   dma_free_attrs(NULL, codec->desc_count * sizeof(struct hal2_desc),
+  codec->desc, codec->desc_dma, DMA_ATTR_NON_CONSISTENT);
+   dma_free_attrs(NULL, H2_BUF_SIZE, codec->buffer, codec->buffer_dma,
+  DMA_ATTR_NON_CONSISTENT);
 }
 
 static struct snd_pcm_hardware hal2_pcm_hw = {
-- 
2.11.0



[PATCH 01/11] dma-mapping: remove dmam_free_noncoherent

2017-06-16 Thread Christoph Hellwig
This function was never used since it was added.

Signed-off-by: Christoph Hellwig 
---
 Documentation/driver-model/devres.txt |  1 -
 drivers/base/dma-mapping.c| 20 
 include/linux/dma-mapping.h   |  2 --
 3 files changed, 23 deletions(-)

diff --git a/Documentation/driver-model/devres.txt 
b/Documentation/driver-model/devres.txt
index e72587fe477d..9070ff06b558 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -243,7 +243,6 @@ DMA
   dmam_alloc_noncoherent()
   dmam_declare_coherent_memory()
   dmam_free_coherent()
-  dmam_free_noncoherent()
   dmam_pool_create()
   dmam_pool_destroy()
 
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index f3deb6af42ad..5940c9dace36 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -148,26 +148,6 @@ void *dmam_alloc_noncoherent(struct device *dev, size_t 
size,
 }
 EXPORT_SYMBOL(dmam_alloc_noncoherent);
 
-/**
- * dmam_free_coherent - Managed dma_free_noncoherent()
- * @dev: Device to free noncoherent memory for
- * @size: Size of allocation
- * @vaddr: Virtual address of the memory to free
- * @dma_handle: DMA handle of the memory to free
- *
- * Managed dma_free_noncoherent().
- */
-void dmam_free_noncoherent(struct device *dev, size_t size, void *vaddr,
-  dma_addr_t dma_handle)
-{
-   struct dma_devres match_data = { size, vaddr, dma_handle };
-
-   dma_free_noncoherent(dev, size, vaddr, dma_handle);
-   WARN_ON(!devres_destroy(dev, dmam_noncoherent_release, dmam_match,
-   _data));
-}
-EXPORT_SYMBOL(dmam_free_noncoherent);
-
 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
 
 static void dmam_coherent_decl_release(struct device *dev, void *res)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 4f3eecedca2d..830ec5f06a4f 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -749,8 +749,6 @@ extern void dmam_free_coherent(struct device *dev, size_t 
size, void *vaddr,
   dma_addr_t dma_handle);
 extern void *dmam_alloc_noncoherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp);
-extern void dmam_free_noncoherent(struct device *dev, size_t size, void *vaddr,
- dma_addr_t dma_handle);
 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
 extern int dmam_declare_coherent_memory(struct device *dev,
phys_addr_t phys_addr,
-- 
2.11.0



[PATCH 02/11] dma-mapping: replace dmam_alloc_noncoherent with dmam_alloc_attrs

2017-06-16 Thread Christoph Hellwig
dmam_alloc_noncoherent is a trivial wrapper around dmam_alloc_attrs,
that hardcodes one particular flag.  Make the devres code more
flexible by allowing the callers to pass arbitrary flags.

Signed-off-by: Christoph Hellwig 
---
 Documentation/driver-model/devres.txt |  2 +-
 drivers/base/dma-mapping.c| 36 ---
 drivers/video/fbdev/au1200fb.c|  5 +++--
 include/linux/dma-mapping.h   |  5 +++--
 4 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/Documentation/driver-model/devres.txt 
b/Documentation/driver-model/devres.txt
index 9070ff06b558..7e08c02b5393 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -240,7 +240,7 @@ CLOCK
 
 DMA
   dmam_alloc_coherent()
-  dmam_alloc_noncoherent()
+  dmam_alloc_attrs()
   dmam_declare_coherent_memory()
   dmam_free_coherent()
   dmam_pool_create()
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index 5940c9dace36..10e7c022e8cf 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -22,20 +22,15 @@ struct dma_devres {
size_t  size;
void*vaddr;
dma_addr_t  dma_handle;
+   unsigned long   attrs;
 };
 
-static void dmam_coherent_release(struct device *dev, void *res)
+static void dmam_release(struct device *dev, void *res)
 {
struct dma_devres *this = res;
 
-   dma_free_coherent(dev, this->size, this->vaddr, this->dma_handle);
-}
-
-static void dmam_noncoherent_release(struct device *dev, void *res)
-{
-   struct dma_devres *this = res;
-
-   dma_free_noncoherent(dev, this->size, this->vaddr, this->dma_handle);
+   dma_free_attrs(dev, this->size, this->vaddr, this->dma_handle,
+   this->attrs);
 }
 
 static int dmam_match(struct device *dev, void *res, void *match_data)
@@ -69,7 +64,7 @@ void *dmam_alloc_coherent(struct device *dev, size_t size,
struct dma_devres *dr;
void *vaddr;
 
-   dr = devres_alloc(dmam_coherent_release, sizeof(*dr), gfp);
+   dr = devres_alloc(dmam_release, sizeof(*dr), gfp);
if (!dr)
return NULL;
 
@@ -104,35 +99,35 @@ void dmam_free_coherent(struct device *dev, size_t size, 
void *vaddr,
struct dma_devres match_data = { size, vaddr, dma_handle };
 
dma_free_coherent(dev, size, vaddr, dma_handle);
-   WARN_ON(devres_destroy(dev, dmam_coherent_release, dmam_match,
-  _data));
+   WARN_ON(devres_destroy(dev, dmam_release, dmam_match, _data));
 }
 EXPORT_SYMBOL(dmam_free_coherent);
 
 /**
- * dmam_alloc_non_coherent - Managed dma_alloc_noncoherent()
+ * dmam_alloc_attrs - Managed dma_alloc_attrs()
  * @dev: Device to allocate non_coherent memory for
  * @size: Size of allocation
  * @dma_handle: Out argument for allocated DMA handle
  * @gfp: Allocation flags
+ * @attrs: Flags in the DMA_ATTR_* namespace.
  *
- * Managed dma_alloc_noncoherent().  Memory allocated using this
- * function will be automatically released on driver detach.
+ * Managed dma_alloc_attrs().  Memory allocated using this function will be
+ * automatically released on driver detach.
  *
  * RETURNS:
  * Pointer to allocated memory on success, NULL on failure.
  */
-void *dmam_alloc_noncoherent(struct device *dev, size_t size,
-dma_addr_t *dma_handle, gfp_t gfp)
+void *dmam_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
+   gfp_t gfp, unsigned long attrs)
 {
struct dma_devres *dr;
void *vaddr;
 
-   dr = devres_alloc(dmam_noncoherent_release, sizeof(*dr), gfp);
+   dr = devres_alloc(dmam_release, sizeof(*dr), gfp);
if (!dr)
return NULL;
 
-   vaddr = dma_alloc_noncoherent(dev, size, dma_handle, gfp);
+   vaddr = dma_alloc_attrs(dev, size, dma_handle, gfp, attrs);
if (!vaddr) {
devres_free(dr);
return NULL;
@@ -141,12 +136,13 @@ void *dmam_alloc_noncoherent(struct device *dev, size_t 
size,
dr->vaddr = vaddr;
dr->dma_handle = *dma_handle;
dr->size = size;
+   dr->attrs = attrs;
 
devres_add(dev, dr);
 
return vaddr;
 }
-EXPORT_SYMBOL(dmam_alloc_noncoherent);
+EXPORT_SYMBOL(dmam_alloc_attrs);
 
 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
 
diff --git a/drivers/video/fbdev/au1200fb.c b/drivers/video/fbdev/au1200fb.c
index 6c2b2ca4a909..5f04b4096c42 100644
--- a/drivers/video/fbdev/au1200fb.c
+++ b/drivers/video/fbdev/au1200fb.c
@@ -1694,9 +1694,10 @@ static int au1200fb_drv_probe(struct platform_device 
*dev)
/* Allocate the framebuffer to the maximum screen size */
fbdev->fb_len = (win->w[plane].xres * win->w[plane].yres * bpp) 
/ 8;
 
-   fbdev->fb_mem = dmam_alloc_noncoherent(>dev,
+   fbdev->fb_mem = dmam_alloc_attrs(>dev,

[PATCH 03/11] au1100fb: remove a bogus dma_free_nonconsistent call

2017-06-16 Thread Christoph Hellwig
au1100fb is using managed dma allocations, so it doesn't need to
explicitly free the dma memory in the error path (and if it did
it would have to use the managed version).

Signed-off-by: Christoph Hellwig 
---
 drivers/video/fbdev/au1100fb.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/video/fbdev/au1100fb.c b/drivers/video/fbdev/au1100fb.c
index 35df2c1a8a63..8de42f617d16 100644
--- a/drivers/video/fbdev/au1100fb.c
+++ b/drivers/video/fbdev/au1100fb.c
@@ -532,10 +532,6 @@ static int au1100fb_drv_probe(struct platform_device *dev)
clk_disable_unprepare(fbdev->lcdclk);
clk_put(fbdev->lcdclk);
}
-   if (fbdev->fb_mem) {
-   dma_free_noncoherent(>dev, fbdev->fb_len, fbdev->fb_mem,
-fbdev->fb_phys);
-   }
if (fbdev->info.cmap.len != 0) {
fb_dealloc_cmap(>info.cmap);
}
-- 
2.11.0



[PATCH 06/11] sigwd93: switch to dma_alloc_attrs

2017-06-16 Thread Christoph Hellwig
Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/sgiwd93.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/sgiwd93.c b/drivers/scsi/sgiwd93.c
index 71b4b91d2215..80cfa93e407c 100644
--- a/drivers/scsi/sgiwd93.c
+++ b/drivers/scsi/sgiwd93.c
@@ -249,8 +249,8 @@ static int sgiwd93_probe(struct platform_device *pdev)
 
hdata = host_to_hostdata(host);
hdata->dev = >dev;
-   hdata->cpu = dma_alloc_noncoherent(>dev, HPC_DMA_SIZE,
-  >dma, GFP_KERNEL);
+   hdata->cpu = dma_alloc_attrs(>dev, HPC_DMA_SIZE, >dma,
+GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
if (!hdata->cpu) {
printk(KERN_WARNING "sgiwd93: Could not allocate memory for "
   "host %d buffer.\n", unit);
@@ -289,7 +289,8 @@ static int sgiwd93_probe(struct platform_device *pdev)
 out_irq:
free_irq(irq, host);
 out_free:
-   dma_free_noncoherent(>dev, HPC_DMA_SIZE, hdata->cpu, hdata->dma);
+   dma_free_attrs(>dev, HPC_DMA_SIZE, hdata->cpu, hdata->dma,
+  DMA_ATTR_NON_CONSISTENT);
 out_put:
scsi_host_put(host);
 out:
@@ -305,7 +306,8 @@ static int sgiwd93_remove(struct platform_device *pdev)
 
scsi_remove_host(host);
free_irq(pd->irq, host);
-   dma_free_noncoherent(>dev, HPC_DMA_SIZE, hdata->cpu, hdata->dma);
+   dma_free_attrs(>dev, HPC_DMA_SIZE, hdata->cpu, hdata->dma,
+  DMA_ATTR_NON_CONSISTENT);
scsi_host_put(host);
return 0;
 }
-- 
2.11.0



[PATCH 05/11] serial/mpsc: switch to dma_alloc_attrs

2017-06-16 Thread Christoph Hellwig
Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.

Signed-off-by: Christoph Hellwig 
---
 drivers/tty/serial/mpsc.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/mpsc.c b/drivers/tty/serial/mpsc.c
index 1a60a2063e75..67ffecc50e42 100644
--- a/drivers/tty/serial/mpsc.c
+++ b/drivers/tty/serial/mpsc.c
@@ -754,9 +754,10 @@ static int mpsc_alloc_ring_mem(struct mpsc_port_info *pi)
if (!dma_set_mask(pi->port.dev, 0x)) {
printk(KERN_ERR "MPSC: Inadequate DMA support\n");
rc = -ENXIO;
-   } else if ((pi->dma_region = dma_alloc_noncoherent(pi->port.dev,
+   } else if ((pi->dma_region = dma_alloc_attrs(pi->port.dev,
MPSC_DMA_ALLOC_SIZE,
-   >dma_region_p, GFP_KERNEL))
+   >dma_region_p, GFP_KERNEL,
+   DMA_ATTR_NON_CONSISTENT))
== NULL) {
printk(KERN_ERR "MPSC: Can't alloc Desc region\n");
rc = -ENOMEM;
@@ -771,8 +772,9 @@ static void mpsc_free_ring_mem(struct mpsc_port_info *pi)
pr_debug("mpsc_free_ring_mem[%d]: Freeing ring mem\n", pi->port.line);
 
if (pi->dma_region) {
-   dma_free_noncoherent(pi->port.dev, MPSC_DMA_ALLOC_SIZE,
-   pi->dma_region, pi->dma_region_p);
+   dma_free_attrs(pi->port.dev, MPSC_DMA_ALLOC_SIZE,
+   pi->dma_region, pi->dma_region_p,
+   DMA_ATTR_NON_CONSISTENT);
pi->dma_region = NULL;
pi->dma_region_p = (dma_addr_t)NULL;
}
-- 
2.11.0



[PATCH 09/11] au1000_eth: switch to dma_alloc_attrs

2017-06-16 Thread Christoph Hellwig
Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.

Signed-off-by: Christoph Hellwig 
---
 drivers/net/ethernet/amd/au1000_eth.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/amd/au1000_eth.c 
b/drivers/net/ethernet/amd/au1000_eth.c
index a3c90fe5de00..73ca8879ada7 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -1180,9 +1180,10 @@ static int au1000_probe(struct platform_device *pdev)
/* Allocate the data buffers
 * Snooping works fine with eth on all au1xxx
 */
-   aup->vaddr = (u32)dma_alloc_noncoherent(NULL, MAX_BUF_SIZE *
-   (NUM_TX_BUFFS + NUM_RX_BUFFS),
-   >dma_addr, 0);
+   aup->vaddr = (u32)dma_alloc_attrs(NULL, MAX_BUF_SIZE *
+ (NUM_TX_BUFFS + NUM_RX_BUFFS),
+ >dma_addr, 0,
+ DMA_ATTR_NON_CONSISTENT);
if (!aup->vaddr) {
dev_err(>dev, "failed to allocate data buffers\n");
err = -ENOMEM;
@@ -1361,8 +1362,9 @@ static int au1000_probe(struct platform_device *pdev)
 err_remap2:
iounmap(aup->mac);
 err_remap1:
-   dma_free_noncoherent(NULL, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
-(void *)aup->vaddr, aup->dma_addr);
+   dma_free_attrs(NULL, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
+   (void *)aup->vaddr, aup->dma_addr,
+   DMA_ATTR_NON_CONSISTENT);
 err_vaddr:
free_netdev(dev);
 err_alloc:
@@ -1394,9 +1396,9 @@ static int au1000_remove(struct platform_device *pdev)
if (aup->tx_db_inuse[i])
au1000_ReleaseDB(aup, aup->tx_db_inuse[i]);
 
-   dma_free_noncoherent(NULL, MAX_BUF_SIZE *
-   (NUM_TX_BUFFS + NUM_RX_BUFFS),
-   (void *)aup->vaddr, aup->dma_addr);
+   dma_free_attrs(NULL, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS),
+   (void *)aup->vaddr, aup->dma_addr,
+   DMA_ATTR_NON_CONSISTENT);
 
iounmap(aup->macdma);
iounmap(aup->mac);
-- 
2.11.0



[PATCH 08/11] sgiseeq: switch to dma_alloc_attrs

2017-06-16 Thread Christoph Hellwig
Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.

Signed-off-by: Christoph Hellwig 
---
 drivers/net/ethernet/seeq/sgiseeq.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/seeq/sgiseeq.c 
b/drivers/net/ethernet/seeq/sgiseeq.c
index 70347720fdf9..573691bc3b71 100644
--- a/drivers/net/ethernet/seeq/sgiseeq.c
+++ b/drivers/net/ethernet/seeq/sgiseeq.c
@@ -737,8 +737,8 @@ static int sgiseeq_probe(struct platform_device *pdev)
sp = netdev_priv(dev);
 
/* Make private data page aligned */
-   sr = dma_alloc_noncoherent(>dev, sizeof(*sp->srings),
-   >srings_dma, GFP_KERNEL);
+   sr = dma_alloc_attrs(>dev, sizeof(*sp->srings), >srings_dma,
+GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
if (!sr) {
printk(KERN_ERR "Sgiseeq: Page alloc failed, aborting.\n");
err = -ENOMEM;
@@ -813,8 +813,8 @@ static int sgiseeq_remove(struct platform_device *pdev)
struct sgiseeq_private *sp = netdev_priv(dev);
 
unregister_netdev(dev);
-   dma_free_noncoherent(>dev, sizeof(*sp->srings), sp->srings,
-sp->srings_dma);
+   dma_free_attrs(>dev, sizeof(*sp->srings), sp->srings,
+  sp->srings_dma, DMA_ATTR_NON_CONSISTENT);
free_netdev(dev);
 
return 0;
-- 
2.11.0



[PATCH 07/11] 53c700: switch to dma_alloc_attrs

2017-06-16 Thread Christoph Hellwig
Use dma_alloc_attrs directly instead of the dma_alloc_noncoherent wrapper.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/53c700.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index 95e32a47face..4b3b08025ef6 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -296,8 +296,8 @@ NCR_700_detect(struct scsi_host_template *tpnt,
if(tpnt->sdev_attrs == NULL)
tpnt->sdev_attrs = NCR_700_dev_attrs;
 
-   memory = dma_alloc_noncoherent(hostdata->dev, TOTAL_MEM_SIZE,
-  , GFP_KERNEL);
+   memory = dma_alloc_attrs(hostdata->dev, TOTAL_MEM_SIZE, ,
+GFP_KERNEL, DMA_ATTR_NON_CONSISTENT);
if(memory == NULL) {
printk(KERN_ERR "53c700: Failed to allocate memory for driver, 
detaching\n");
return NULL;
@@ -410,8 +410,8 @@ NCR_700_release(struct Scsi_Host *host)
struct NCR_700_Host_Parameters *hostdata = 
(struct NCR_700_Host_Parameters *)host->hostdata[0];
 
-   dma_free_noncoherent(hostdata->dev, TOTAL_MEM_SIZE,
-  hostdata->script, hostdata->pScript);
+   dma_free_attrs(hostdata->dev, TOTAL_MEM_SIZE, hostdata->script,
+  hostdata->pScript, DMA_ATTR_NON_CONSISTENT);
return 1;
 }
 
-- 
2.11.0



[PATCH 10/11] i825xx: switch to switch to dma_alloc_attrs

2017-06-16 Thread Christoph Hellwig
This way we can always pass DMA_ATTR_NON_CONSISTENT, the SNI mips version
will simply ignore the flag.

Signed-off-by: Christoph Hellwig 
---
 drivers/net/ethernet/i825xx/lasi_82596.c | 6 ++
 drivers/net/ethernet/i825xx/lib82596.c   | 9 +
 drivers/net/ethernet/i825xx/sni_82596.c  | 6 ++
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/i825xx/lasi_82596.c 
b/drivers/net/ethernet/i825xx/lasi_82596.c
index d787fdd5db7b..d5b5021aa759 100644
--- a/drivers/net/ethernet/i825xx/lasi_82596.c
+++ b/drivers/net/ethernet/i825xx/lasi_82596.c
@@ -96,8 +96,6 @@
 
 #define OPT_SWAP_PORT  0x0001  /* Need to wordswp on the MPU port */
 
-#define DMA_ALLOCdma_alloc_noncoherent
-#define DMA_FREE dma_free_noncoherent
 #define DMA_WBACK(ndev, addr, len) \
do { dma_cache_sync((ndev)->dev.parent, (void *)addr, len, 
DMA_TO_DEVICE); } while (0)
 
@@ -200,8 +198,8 @@ static int lan_remove_chip(struct parisc_device *pdev)
struct i596_private *lp = netdev_priv(dev);
 
unregister_netdev (dev);
-   DMA_FREE(>dev, sizeof(struct i596_private),
-(void *)lp->dma, lp->dma_addr);
+   dma_free_attrs(>dev, sizeof(struct i596_private), lp->dma,
+  lp->dma_addr, DMA_ATTR_NON_CONSISTENT);
free_netdev (dev);
return 0;
 }
diff --git a/drivers/net/ethernet/i825xx/lib82596.c 
b/drivers/net/ethernet/i825xx/lib82596.c
index e86773325cbe..31e879fbec07 100644
--- a/drivers/net/ethernet/i825xx/lib82596.c
+++ b/drivers/net/ethernet/i825xx/lib82596.c
@@ -1062,8 +1062,9 @@ static int i82596_probe(struct net_device *dev)
if (!dev->base_addr || !dev->irq)
return -ENODEV;
 
-   dma = (struct i596_dma *) DMA_ALLOC(dev->dev.parent,
-   sizeof(struct i596_dma), >dma_addr, GFP_KERNEL);
+   dma = dma_alloc_attrs(dev->dev.parent, sizeof(struct i596_dma),
+ >dma_addr, GFP_KERNEL,
+ DMA_ATTR_NON_CONSISTENT);
if (!dma) {
printk(KERN_ERR "%s: Couldn't get shared memory\n", __FILE__);
return -ENOMEM;
@@ -1084,8 +1085,8 @@ static int i82596_probe(struct net_device *dev)
 
i = register_netdev(dev);
if (i) {
-   DMA_FREE(dev->dev.parent, sizeof(struct i596_dma),
-   (void *)dma, lp->dma_addr);
+   dma_free_attrs(dev->dev.parent, sizeof(struct i596_dma),
+  dma, lp->dma_addr, DMA_ATTR_NON_CONSISTENT);
return i;
}
 
diff --git a/drivers/net/ethernet/i825xx/sni_82596.c 
b/drivers/net/ethernet/i825xx/sni_82596.c
index 2af7f77345fb..b2c04a789744 100644
--- a/drivers/net/ethernet/i825xx/sni_82596.c
+++ b/drivers/net/ethernet/i825xx/sni_82596.c
@@ -23,8 +23,6 @@
 
 static const char sni_82596_string[] = "snirm_82596";
 
-#define DMA_ALLOC  dma_alloc_coherent
-#define DMA_FREE   dma_free_coherent
 #define DMA_WBACK(priv, addr, len) do { } while (0)
 #define DMA_INV(priv, addr, len)   do { } while (0)
 #define DMA_WBACK_INV(priv, addr, len) do { } while (0)
@@ -152,8 +150,8 @@ static int sni_82596_driver_remove(struct platform_device 
*pdev)
struct i596_private *lp = netdev_priv(dev);
 
unregister_netdev(dev);
-   DMA_FREE(dev->dev.parent, sizeof(struct i596_private),
-lp->dma, lp->dma_addr);
+   dma_free_attrs(dev->dev.parent, sizeof(struct i596_private), lp->dma,
+  lp->dma_addr, DMA_ATTR_NON_CONSISTENT);
iounmap(lp->ca);
iounmap(lp->mpu_port);
free_netdev (dev);
-- 
2.11.0



[PATCH 11/11] dma-mapping: remove dma_alloc_noncoherent and dma_free_noncoherent

2017-06-16 Thread Christoph Hellwig
No users left, everyone switched to the _attrs versions.

Signed-off-by: Christoph Hellwig 
---
 Documentation/DMA-API.txt| 30 --
 arch/metag/include/asm/dma-mapping.h |  2 +-
 arch/nios2/include/asm/dma-mapping.h |  2 +-
 arch/tile/include/asm/dma-mapping.h  |  4 ++--
 include/linux/dma-mapping.h  | 14 --
 5 files changed, 20 insertions(+), 32 deletions(-)

diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index 6b20128fab8a..c55782f68348 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -451,14 +451,15 @@ processor and an I/O device, you should not be using this 
part of the
 API at all.
 
 void *
-dma_alloc_noncoherent(struct device *dev, size_t size,
-  dma_addr_t *dma_handle, gfp_t flag)
+dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle,
+   gfp_t flag, unsigned long attrs)
 
-Identical to dma_alloc_coherent() except that the platform will
-choose to return either consistent or non-consistent memory as it sees
-fit.  By using this API, you are guaranteeing to the platform that you
-have all the correct and necessary sync points for this memory in the
-driver should it choose to return non-consistent memory.
+Identical to dma_alloc_coherent() except that when the
+DMA_ATTR_NON_CONSISTENT flags is passed in the attrs argument, the
+platform will choose to return either consistent or non-consistent memory
+as it sees fit.  By using this API, you are guaranteeing to the platform
+that you have all the correct and necessary sync points for this memory
+in the driver should it choose to return non-consistent memory.
 
 Note: where the platform can return consistent memory, it will
 guarantee that the sync points become nops.
@@ -469,12 +470,13 @@ required to work on one of the rare (usually non-PCI) 
architectures
 that simply cannot make consistent memory.
 
 void
-dma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr,
- dma_addr_t dma_handle)
+dma_free_attrs(struct device *dev, size_t size, void *cpu_addr,
+  dma_addr_t dma_handle, unsigned long attrs)
 
-Free memory allocated by the nonconsistent API.  All parameters must
-be identical to those passed in (and returned by
-dma_alloc_noncoherent()).
+Free memory allocated by the dma_alloc_attrs().  All parameters common
+parameters must identical to those otherwise passed to dma_fre_coherent,
+and the attrs argument must be identical to the attrs passed to
+dma_alloc_attrs().
 
 int
 dma_get_cache_alignment(void)
@@ -492,8 +494,8 @@ void
 dma_cache_sync(struct device *dev, void *vaddr, size_t size,
   enum dma_data_direction direction)
 
-Do a partial sync of memory that was allocated by
-dma_alloc_noncoherent(), starting at virtual address vaddr and
+Do a partial sync of memory that was allocated by dma_alloc_attrs() with
+the DMA_ATTR_NON_CONSISTENT flag starting at virtual address vaddr and
 continuing on for size.  Again, you *must* observe the cache line
 boundaries when doing this.
 
diff --git a/arch/metag/include/asm/dma-mapping.h 
b/arch/metag/include/asm/dma-mapping.h
index fad3dc3cb210..ea573be2b6d0 100644
--- a/arch/metag/include/asm/dma-mapping.h
+++ b/arch/metag/include/asm/dma-mapping.h
@@ -9,7 +9,7 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct 
bus_type *bus)
 }
 
 /*
- * dma_alloc_noncoherent() returns non-cacheable memory, so there's no need to
+ * dma_alloc_attrs() always returns non-cacheable memory, so there's no need to
  * do any flushing here.
  */
 static inline void
diff --git a/arch/nios2/include/asm/dma-mapping.h 
b/arch/nios2/include/asm/dma-mapping.h
index 7b3c6f280293..f8dc6741 100644
--- a/arch/nios2/include/asm/dma-mapping.h
+++ b/arch/nios2/include/asm/dma-mapping.h
@@ -18,7 +18,7 @@ static inline const struct dma_map_ops 
*get_arch_dma_ops(struct bus_type *bus)
 }
 
 /*
- * dma_alloc_noncoherent() returns non-cacheable memory, so there's no need to
+ * dma_alloc_attrs() always returns non-cacheable memory, so there's no need to
  * do any flushing here.
  */
 static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
diff --git a/arch/tile/include/asm/dma-mapping.h 
b/arch/tile/include/asm/dma-mapping.h
index bbc71a29b2c6..7061dc8af43a 100644
--- a/arch/tile/include/asm/dma-mapping.h
+++ b/arch/tile/include/asm/dma-mapping.h
@@ -68,8 +68,8 @@ static inline bool dma_capable(struct device *dev, dma_addr_t 
addr, size_t size)
 int dma_set_mask(struct device *dev, u64 mask);
 
 /*
- * dma_alloc_noncoherent() is #defined to return coherent memory,
- * so there's no need to do any flushing here.
+ * dma_alloc_attrs() always returns non-cacheable memory, so there's no need to
+ * do any flushing here.
  */
 static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
  enum dma_data_direction 

remove dma_alloc_noncoherent

2017-06-16 Thread Christoph Hellwig
For many years we've had the dma_alloc_attrs API that is more flexible
than dma_alloc_noncoherent.  This series moves the remaining users over
to the attrs API.


[PATCH v2 1/5] scsi: ufs: add hi3660 ufs driver code

2017-06-16 Thread Bu Tao
add hi3660 ufs driver code

Signed-off-by: Geng Jianfeng 
Signed-off-by: Bu Tao 
Signed-off-by: Zang Leigang 
Signed-off-by: Yu Jianfeng 
---
 drivers/scsi/ufs/Kconfig  |   8 +
 drivers/scsi/ufs/Makefile |   1 +
 drivers/scsi/ufs/ufs-hi3660.c | 727 ++
 drivers/scsi/ufs/ufs-hi3660.h | 173 ++
 4 files changed, 909 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufs-hi3660.c
 create mode 100644 drivers/scsi/ufs/ufs-hi3660.h

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index e27b4d4e6ae2..119604ea0aae 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -80,6 +80,14 @@ config SCSI_UFSHCD_PLATFORM
 
  If unsure, say N.
 
+config SCSI_UFS_HI3660
+   tristate "Hisilicon Hi3660 UFS controller platform driver"
+   depends on (ARCH_HISI || COMPILE_TEST) && SCSI_UFSHCD_PLATFORM
+   help
+ This selects the Hisilicon HI3660 additions to UFSHCD platform driver.
+
+ If unsure, say N.
+
 config SCSI_UFS_DWC_TC_PLATFORM
tristate "DesignWare platform support using a G210 Test Chip"
depends on SCSI_UFSHCD_PLATFORM
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 6e77cb0bfee9..ae880189f018 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -2,6 +2,7 @@
 obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o 
tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o 
tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
+obj-$(CONFIG_SCSI_UFS_HI3660) += ufs-hi3660.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
 obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
diff --git a/drivers/scsi/ufs/ufs-hi3660.c b/drivers/scsi/ufs/ufs-hi3660.c
new file mode 100644
index ..9356e828e107
--- /dev/null
+++ b/drivers/scsi/ufs/ufs-hi3660.c
@@ -0,0 +1,727 @@
+/*
+ *
+ * HiSilicon Hi3660 UFS Driver
+ *
+ * Copyright (c) 2016-2017 Linaro Ltd.
+ * Copyright (c) 2016-2017 HiSilicon Technologies Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ufshcd.h"
+#include "ufshcd-pltfrm.h"
+#include "unipro.h"
+#include "ufs-hi3660.h"
+#include "ufshci.h"
+
+static int ufs_hi3660_check_hibern8(struct ufs_hba *hba)
+{
+   int err;
+   u32 tx_fsm_val_0;
+   u32 tx_fsm_val_1;
+   unsigned long timeout = jiffies + msecs_to_jiffies(HBRN8_POLL_TOUT_MS);
+
+   do {
+   err = ufshcd_dme_get(hba, UIC_ARG_MIB_SEL(MPHY_TX_FSM_STATE, 0),
+ _fsm_val_0);
+   err |= ufshcd_dme_get(hba,
+   UIC_ARG_MIB_SEL(MPHY_TX_FSM_STATE, 1), _fsm_val_1);
+   if (err || (tx_fsm_val_0 == TX_FSM_HIBERN8 &&
+   tx_fsm_val_1 == TX_FSM_HIBERN8))
+   break;
+
+   /* sleep for max. 200us */
+   usleep_range(100, 200);
+   } while (time_before(jiffies, timeout));
+
+   /*
+* we might have scheduled out for long during polling so
+* check the state again.
+*/
+   if (time_after(jiffies, timeout)) {
+   err = ufshcd_dme_get(hba, UIC_ARG_MIB_SEL(MPHY_TX_FSM_STATE, 0),
+_fsm_val_0);
+   err |= ufshcd_dme_get(hba,
+UIC_ARG_MIB_SEL(MPHY_TX_FSM_STATE, 1), _fsm_val_1);
+   }
+
+   if (err) {
+   dev_err(hba->dev, "%s: unable to get TX_FSM_STATE, err %d\n",
+   __func__, err);
+   } else if (tx_fsm_val_0 != TX_FSM_HIBERN8 ||
+tx_fsm_val_1 != TX_FSM_HIBERN8) {
+   err = -1;
+   dev_err(hba->dev, "%s: invalid TX_FSM_STATE, lane0 = %d, lane1 
= %d\n",
+   __func__, tx_fsm_val_0, tx_fsm_val_1);
+   }
+
+   return err;
+}
+
+static void ufs_hi3660_clk_init(struct ufs_hba *hba)
+{
+   struct ufs_hi3660_host *host = ufshcd_get_variant(hba);
+
+   ufs_sys_ctrl_clr_bits(host, BIT_SYSCTRL_REF_CLOCK_EN, PHY_CLK_CTRL);
+   if (ufs_sys_ctrl_readl(host, PHY_CLK_CTRL) & BIT_SYSCTRL_REF_CLOCK_EN)
+   mdelay(1);
+   /* use abb clk */
+   ufs_sys_ctrl_clr_bits(host, BIT_UFS_REFCLK_SRC_SEl, UFS_SYSCTRL);
+   ufs_sys_ctrl_clr_bits(host, BIT_UFS_REFCLK_ISO_EN, PHY_ISO_EN);
+   /* open mphy ref clk */
+   ufs_sys_ctrl_set_bits(host, BIT_SYSCTRL_REF_CLOCK_EN, PHY_CLK_CTRL);
+}
+
+static void ufs_hi3660_soc_init(struct ufs_hba *hba)
+{
+   struct 

[PATCH v2 4/5] arm64: defconfig: enable configs for hi3660 ufs

2017-06-16 Thread Bu Tao
This enable configs for Hi3660 UFS driver.

Reviewed-by: Chen Feng 
Signed-off-by: Zhangfei Gao 
Signed-off-by: Chen Jun 
Signed-off-by: Guodong Xu 
---
 arch/arm64/configs/defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 65cdd878cfbd..379c942fe114 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -158,6 +158,9 @@ CONFIG_EEPROM_AT25=m
 CONFIG_BLK_DEV_SD=y
 CONFIG_SCSI_SAS_ATA=y
 CONFIG_SCSI_HISI_SAS=y
+CONFIG_SCSI_UFSHCD=y
+CONFIG_SCSI_UFSHCD_PLATFORM=y
+CONFIG_SCSI_UFS_HI3660=y
 CONFIG_ATA=y
 CONFIG_SATA_AHCI=y
 CONFIG_SATA_AHCI_PLATFORM=y
-- 
2.11.GIT



[PATCH v2 2/5] dt-bindings: scsi: ufs: add document for hi3660-ufs

2017-06-16 Thread Bu Tao
add ufs node document for hi3660

Signed-off-by: Bu Tao 
---
 .../devicetree/bindings/ufs/hi3660-ufs.txt | 58 ++
 1 file changed, 58 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/hi3660-ufs.txt

diff --git a/Documentation/devicetree/bindings/ufs/hi3660-ufs.txt 
b/Documentation/devicetree/bindings/ufs/hi3660-ufs.txt
new file mode 100644
index ..461afc8ef017
--- /dev/null
+++ b/Documentation/devicetree/bindings/ufs/hi3660-ufs.txt
@@ -0,0 +1,58 @@
+* Hisilicon Universal Flash Storage (UFS) Host Controller
+
+UFS nodes are defined to describe on-chip UFS hardware macro.
+Each UFS Host Controller should have its own node.
+
+Required properties:
+- compatible: compatible list, contains one of the following -
+   "hisilicon,hi3660-ufs" for hisi ufs host controller
+present on Hi3660 chipset.
+- reg   : should contain UFS register address space & UFS SYS CTRL 
register address,
+- interrupt-parent  : interrupt device
+- interrupts: interrupt number
+- clocks   : List of phandle and clock specifier pairs
+- clock-names   : List of clock input name strings sorted in the same
+ order as the clocks property. "clk_ref", "clk_phy" is 
optional
+- resets: reset node register, one reset the clk and the other 
reset the controller
+- reset-names   : describe reset node register
+
+Optional properties for board device:
+- ufs-hi3660-use-rate-B: specifies UFS rate-B
+- ufs-hi3660-broken-fastauto   : specifies no fastauto
+- ufs-hi3660-use-HS-GEAR3  : specifies UFS HS-GEAR3
+- ufs-hi3660-use-HS-GEAR2  : specifies UFS HS-GEAR2
+- ufs-hi3660-use-HS-GEAR1  : specifies UFS HS-GEAR1
+- ufs-hi3660-broken-clk-gate-bypass: specifies no clk-gate
+- ufs-hi3660-use-one-line  : specifies UFS use one line work
+- reset-gpio   : specifies to reset devices
+
+Example:
+
+   ufs: ufs@ff3b {
+   compatible = "jedec,ufs-1.1", "hisilicon,hi3660-ufs";
+   /* 0: HCI standard */
+   /* 1: UFS SYS CTRL */
+   reg = <0x0 0xff3b 0x0 0x1000>,
+   <0x0 0xff3b1000 0x0 0x1000>;
+   interrupt-parent = <>;
+   interrupts = ;
+   clocks = <_ctrl HI3660_CLK_GATE_UFSIO_REF>,
+   <_ctrl HI3660_CLK_GATE_UFSPHY_CFG>;
+   clock-names = "clk_ref", "clk_phy";
+   freq-table-hz = <0 0>, <0 0>;
+   /* offset: 0x84; bit: 12 */
+   /* offset: 0x84; bit: 7  */
+   resets = <_rst 0x84 12>,
+   <_rst 0x84 7>;
+   reset-names = "rst", "assert";
+   }
+
+{
+   ufs-hi3660-use-rate-B;
+   ufs-hi3660-broken-fastauto;
+   ufs-hi3660-use-HS-GEAR3;
+   ufs-hi3660-broken-clk-gate-bypass;
+   reset-gpio = < 1 0>;
+   status = "okay";
+   }
+
-- 
2.11.GIT



[PATCH v2 0/5] scsi: ufs: add ufs driver code for Hi3660 SoC

2017-06-16 Thread Bu Tao
This patchset adds driver support for UFS for Hi3660 SoC. It is verified on 
HiKey960 board

In v2
The dts ufs node patch, 
v2-0003-arm64-dts-Add-ufs-dts-node-for-Hisilicon-Hi3660-S.patch,
is dependent on the patch below:

>From Guodong Xu 
https://www.spinics.net/lists/arm-kernel/msg588232.html

Bu Tao (3):
  scsi: ufs: add hi3660 ufs driver code
  scsi: ufs: add ufs node document for hi3660
  arm64: dts: Add ufs dts node for Hisilicon Hi3660 SoC

Zhangfei Gao(2):
  rm64: defconfig: enable configs for hi3660 ufs
  arm64: defconfig: enable f2fs and squashfs

 .../devicetree/bindings/ufs/hi3660-ufs.txt |  58 ++
 arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts  |   9 +
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi  |  19 +
 arch/arm64/configs/defconfig   |  11 +
 drivers/scsi/ufs/Kconfig   |   8 +
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/ufs-hi3660.c  | 727 +
 drivers/scsi/ufs/ufs-hi3660.h  | 173 +
 8 files changed, 1006 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/hi3660-ufs.txt
 create mode 100644 drivers/scsi/ufs/ufs-hi3660.c
 create mode 100644 drivers/scsi/ufs/ufs-hi3660.h

-- 
2.11.GIT



[PATCH v2 5/5] arm64: defconfig: enable f2fs and squashfs

2017-06-16 Thread Bu Tao
Partitions in HiKey960 are formatted as f2fs and squashfs.
f2fs is for userdata; squashfs is for system. Both partitions are required
by Android.

Signed-off-by: Zhangfei Gao 
Signed-off-by: Chen Jun 
Signed-off-by: Guodong Xu 
---
 arch/arm64/configs/defconfig | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 379c942fe114..d73351fa0c9a 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -494,6 +494,7 @@ CONFIG_RASPBERRYPI_FIRMWARE=y
 CONFIG_ACPI=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
+CONFIG_F2FS_FS=y
 CONFIG_EXT4_FS_POSIX_ACL=y
 CONFIG_BTRFS_FS=m
 CONFIG_BTRFS_FS_POSIX_ACL=y
@@ -509,6 +510,13 @@ CONFIG_HUGETLBFS=y
 CONFIG_CONFIGFS_FS=y
 CONFIG_EFIVAR_FS=y
 CONFIG_SQUASHFS=y
+CONFIG_SQUASHFS_FILE_DIRECT=y
+CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU=y
+CONFIG_SQUASHFS_XATTR=y
+CONFIG_SQUASHFS_LZ4=y
+CONFIG_SQUASHFS_LZO=y
+CONFIG_SQUASHFS_XZ=y
+CONFIG_SQUASHFS_4K_DEVBLK_SIZE=y
 CONFIG_NFS_FS=y
 CONFIG_NFS_V4=y
 CONFIG_NFS_V4_1=y
-- 
2.11.GIT



[PATCH v2 3/5] arm64: dts: Add ufs dts node

2017-06-16 Thread Bu Tao
arm64: dts: add ufs node for hi3660

Signed-off-by: Bu Tao 
---
 arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts |  9 +
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 19 +++
 2 files changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts 
b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
index 186251ffc6b2..5dbe642f3c66 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
+++ b/arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts
@@ -32,3 +32,12 @@
  {
status = "okay";
 };
+
+ {
+   ufs-hi3660-use-rate-B;
+   ufs-hi3660-broken-fastauto;
+   ufs-hi3660-use-HS-GEAR3;
+   ufs-hi3660-broken-clk-gate-bypass;
+   reset-gpio = < 1 0>;
+   status = "okay";
+}
diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi 
b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index 3983086bd67b..e688fdb0a939 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -141,6 +141,25 @@
#size-cells = <2>;
ranges;
 
+   ufs: ufs@ff3b {
+   compatible = "jedec,ufs-1.1", "hisilicon,hi3660-ufs";
+   /* 0: HCI standard */
+   /* 1: UFS SYS CTRL */
+   reg = <0x0 0xff3b 0x0 0x1000>,
+   <0x0 0xff3b1000 0x0 0x1000>;
+   interrupt-parent = <>;
+   interrupts = ;
+   clocks = <_ctrl HI3660_CLK_GATE_UFSIO_REF>,
+   <_ctrl HI3660_CLK_GATE_UFSPHY_CFG>;
+   clock-names = "clk_ref", "clk_phy";
+   freq-table-hz = <0 0>, <0 0>;
+   /* offset: 0x84; bit: 12 */
+   /* offset: 0x84; bit: 7  */
+   resets = <_rst 0x84 12>,
+   <_rst 0x84 7>;
+   reset-names = "rst", "assert";
+   };
+
fixed_uart5: fixed_19_2M {
compatible = "fixed-clock";
#clock-cells = <0>;
-- 
2.11.GIT



Re: [ANNOUNCE]: Broadcom (Emulex) FC Target driver - efct

2017-06-16 Thread Hannes Reinecke
On 06/14/2017 10:02 PM, Sebastian Herbszt wrote:
> Hannes Reinecke wrote:
>> On 06/13/2017 01:08 AM, James Smart wrote:
> 
> [snip]
> 
>>> Questions:
>>> a) How best to deal with overlapping pci id's ?  E.g. if we do (1)
>>> and we have an initiator and target driver, there is a lot of
>>> adapters that are fully functional for target operation, but were
>>> sold as primarily an initiator adapter. How could we manage target
>>> mode enablement without code mod or hard pci id partitioning ?   I
>>> know individual pci unbind/bind could work, but its been frowned
>>> upon as a long term option. Same thing goes for module parameters
>>> to select which ports do what role. 
>> That indeed is a problem.
>>
>> Ideally we should be able to set the required mode on a per-port base;
>> having it per PCI device might be too coarse. Unless you represent
>> each port as a PCI function; not sure if that's the case, though.
> 
> It seems to be the case.
> At least a dual port FC HBA (SLI-3) has two PCI functions.
> 
>> If we were to allow to set the mode on a per-port base we could easily
>> implement kernel parameters like fctarget=WWPN and/or
>> fcinitiator=WWPN; NVMe could be treated similarly.
>> And have a config option specifying if the default FC mode should be
>> initiator or target.
> 
> The old lpfc+lpfc_scst combination and also qla2xxx+tcm_qla2xxx allow
> simultaneous initiator and target mode on the same port. I guess this
> won't be possible with a split driver.
> 
Which was kinda the point of this entire conversation ...

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.com  +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)