[PATCH v2] target_core_alua: silence GCC warning

2014-02-20 Thread Paul Bolle
Building target_core_alua.o triggers a GCC warning:
drivers/target/target_core_alua.c: In function ‘target_alua_state_check’:
drivers/target/target_core_alua.c:773:18: warning: ‘alua_ascq’ may be used 
uninitialized in this function [-Wmaybe-uninitialized]
   cmd->scsi_ascq = alua_ascq;
  ^

This is a false positive. A little trial and error shows it is
apparently caused by core_alua_state_lba_dependent(). It must be hard
for GCC to track the branches of a switch statement, inside a
list_for_each_entry loop, inside a while loop.

But if we add a small (inline) helper function we can reorganize the
code a bit. That also allows to drop alua_ascq which, obviously, gets
rid of this warning.

Signed-off-by: Paul Bolle 
---
v2: Make core_alua_state_nonoptimized() return void, as Geert
suggested. 

Also keep core_alua_state_lba_dependent() inline. Setting that function
noinline was just a leftover from the trial and error fase, and isn't
needed to make the warning go away. Ie, I was sloppy in v1!

Still compile tested only.

 drivers/target/target_core_alua.c | 95 ++-
 1 file changed, 44 insertions(+), 51 deletions(-)

diff --git a/drivers/target/target_core_alua.c 
b/drivers/target/target_core_alua.c
index c3d9df6..fcbe612 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -455,11 +455,26 @@ out:
return rc;
 }
 
-static inline int core_alua_state_nonoptimized(
+static inline void set_ascq(struct se_cmd *cmd, u8 alua_ascq)
+{
+   /*
+* Set SCSI additional sense code (ASC) to 'LUN Not Accessible';
+* The ALUA additional sense code qualifier (ASCQ) is determined
+* by the ALUA primary or secondary access state..
+*/
+   pr_debug("[%s]: ALUA TG Port not available, "
+   "SenseKey: NOT_READY, ASC/ASCQ: "
+   "0x04/0x%02x\n",
+   cmd->se_tfo->get_fabric_name(), alua_ascq);
+
+   cmd->scsi_asc = 0x04;
+   cmd->scsi_ascq = alua_ascq;
+}
+
+static inline void core_alua_state_nonoptimized(
struct se_cmd *cmd,
unsigned char *cdb,
-   int nonop_delay_msecs,
-   u8 *alua_ascq)
+   int nonop_delay_msecs)
 {
/*
 * Set SCF_ALUA_NON_OPTIMIZED here, this value will be checked
@@ -468,13 +483,11 @@ static inline int core_alua_state_nonoptimized(
 */
cmd->se_cmd_flags |= SCF_ALUA_NON_OPTIMIZED;
cmd->alua_nonop_delay = nonop_delay_msecs;
-   return 0;
 }
 
 static inline int core_alua_state_lba_dependent(
struct se_cmd *cmd,
-   struct t10_alua_tg_pt_gp *tg_pt_gp,
-   u8 *alua_ascq)
+   struct t10_alua_tg_pt_gp *tg_pt_gp)
 {
struct se_device *dev = cmd->se_dev;
u64 segment_size, segment_mult, sectors, lba;
@@ -520,7 +533,7 @@ static inline int core_alua_state_lba_dependent(
}
if (!cur_map) {
spin_unlock(&dev->t10_alua.lba_map_lock);
-   *alua_ascq = ASCQ_04H_ALUA_TG_PT_UNAVAILABLE;
+   set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_UNAVAILABLE);
return 1;
}
list_for_each_entry(map_mem, &cur_map->lba_map_mem_list,
@@ -531,11 +544,11 @@ static inline int core_alua_state_lba_dependent(
switch(map_mem->lba_map_mem_alua_state) {
case ALUA_ACCESS_STATE_STANDBY:
spin_unlock(&dev->t10_alua.lba_map_lock);
-   *alua_ascq = ASCQ_04H_ALUA_TG_PT_STANDBY;
+   set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_STANDBY);
return 1;
case ALUA_ACCESS_STATE_UNAVAILABLE:
spin_unlock(&dev->t10_alua.lba_map_lock);
-   *alua_ascq = ASCQ_04H_ALUA_TG_PT_UNAVAILABLE;
+   set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_UNAVAILABLE);
return 1;
default:
break;
@@ -548,8 +561,7 @@ static inline int core_alua_state_lba_dependent(
 
 static inline int core_alua_state_standby(
struct se_cmd *cmd,
-   unsigned char *cdb,
-   u8 *alua_ascq)
+   unsigned char *cdb)
 {
/*
 * Allowed CDBs for ALUA_ACCESS_STATE_STANDBY as defined by
@@ -570,7 +582,7 @@ static inline int core_alua_state_standby(
case MI_REPORT_TARGET_PGS:
return 0;
default:
-   *alua_ascq = ASCQ_04H_ALUA_TG_PT_STANDBY;
+   set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_STANDBY);
return 1;
}
case MAINTENANCE_OUT:
@@ -578,7 +590,7 @@ static inline int core_alua_state_standby(
case MO_SET_TARGET_PGS:
return 0;
default:
-  

[PATCH 2/2] MAINTAINERS: mark Advansys Orphan

2014-02-20 Thread Paul Bolle
Matthew Wilcox hasn't touched the Advansys driver since v2.6.29. I have
not been able to get Matthew to respond to a trivial patch I'd like to
see go in. Mark this driver Orphan and add this driver to Matthew's
CREDITS entry.

Signed-off-by: Paul Bolle 
---
 CREDITS | 2 +-
 MAINTAINERS | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/CREDITS b/CREDITS
index e371c55..4adbf38 100644
--- a/CREDITS
+++ b/CREDITS
@@ -3805,7 +3805,7 @@ N: Matthew Wilcox
 E: matt...@wil.cx
 W: ftp://ftp.uk.linux.org/pub/linux/people/willy/
 D: Linux/PARISC hacker.  Filesystem hacker.  Random other hacking.  Custom
-D: PPC port hacking.
+D: PPC port hacking.  Advansys SCSI driver.
 
 N: G\"unter Windau
 E: gun...@mbfys.kun.nl
diff --git a/MAINTAINERS b/MAINTAINERS
index fb08dce..c45d72e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -426,9 +426,8 @@ S:  Supported
 F: drivers/input/misc/adxl34x.c
 
 ADVANSYS SCSI DRIVER
-M: Matthew Wilcox 
 L: linux-scsi@vger.kernel.org
-S: Maintained
+S: Orphan
 F: Documentation/scsi/advansys.txt
 F: drivers/scsi/advansys.c
 
-- 
1.8.5.3

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


[PATCH 1/2] advansys: change buildtime warning into runtime error

2014-02-20 Thread Paul Bolle
Building advansys.o triggers this warning:
drivers/scsi/advansys.c:71:2: warning: #warning this driver is still not 
properly converted to the DMA API [-Wcpp]

This warning can be traced back to a patch called "advansys: add warning
and convert #includes" which was included in v2.6.10. That patch also
marked the driver as BROKEN.

Commit 4661e3eace2c7b8433476b5bf0ee437ab3c7dfd4 ("[SCSI] advansys
driver: limp along on x86") enabled this driver for x86-32. And commit
9d511a4b29de6764931343d03e493f2e04df0271 ("[SCSI] advansys: Changes to
work on parisc") enabled this driver for all architectures. But the
commit explanation stated:
I haven't removed the #warning yet because virt_to_bus/bus_to_virt are
only eliminated for narrow boards.  Wide boards need more work.

Six years have passed and, apparently, those wide boards still need
more work. So let's change the buildtime warning into a runtime error,
only printed for those wide boards. Perhaps that might push the people
using those wide boards to convert this driver. And for all others
there's now one less buildtime warning to ignore.

Signed-off-by: Paul Bolle 
---
Compile tested only. I don't have any Advansys SCSI boards (neither
narrow nor wide).

 drivers/scsi/advansys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index d814588..5999c60 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -68,7 +68,6 @@
  *  7. advansys_info is not safe against multiple simultaneous callers
  *  8. Add module_param to override ISA/VLB ioport array
  */
-#warning this driver is still not properly converted to the DMA API
 
 /* Enable driver /proc statistics. */
 #define ADVANSYS_STATS
@@ -12260,6 +12259,7 @@ static int advansys_pci_probe(struct pci_dev *pdev,
pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
pdev->device == PCI_DEVICE_ID_38C1600_REV1) {
board->flags |= ASC_IS_WIDE_BOARD;
+   pr_err("This driver is still not properly converted to the DMA 
API");
}
 
err = advansys_board_found(shost, ioport, ASC_IS_PCI);
-- 
1.8.5.3

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


[PATCH 0/2] advansys: remove warning and mark Orphan

2014-02-20 Thread Paul Bolle
0) I've tried to get a trivial patch to the Advansys SCSI driver merged.
It silences a build time warning. See:
- November 2012: https://lkml.org/lkml/2012/11/5/164 ;
- January 2013: https://lkml.org/lkml/2013/1/29/144 ; and
- January 2014: https://lkml.org/lkml/2014/1/8/569 .

That patch seems to be going nowhere. So a kernel build still generates
a warning when this driver is included. After seven years that is
getting pointless.

1) It seems that advansys is unmaintained. The last time its maintainer
touched it - by acking a patch - was in 2008, with commit 25729a7fb88e
("[SCSI] advansys, arcmsr, ipr, nsp32, qla1280, stex: use
pci_ioremap_bar()"). 

2) Fedora kernel people suggested to send this trivial patch to Andrew
Morton directly (see
https://lists.fedoraproject.org/pipermail/kernel/2014-January/004832.html ). 
They also suggested I'd mark this driver Orphan.

This small series does both.

Paul Bolle (2):
  advansys: change buildtime warning into runtime error
  MAINTAINERS: mark Advansys Orphan

 CREDITS | 2 +-
 MAINTAINERS | 3 +--
 drivers/scsi/advansys.c | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

-- 
1.8.5.3

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


re

2014-02-20 Thread mrs eva
Hi, I have a transaction for you, contact me on (
mrs@safe-mail.net ) for more details
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1.3 1/11] arcmsr: Revise interrupt service routine to fix command timeout

2014-02-20 Thread Dan Carpenter
On Thu, Feb 20, 2014 at 08:05:05PM +0800, 黃清隆 wrote:
> From: Ching 
> 
> Rewrite interrupt service routine to fix command timeout on controller too
> heavy loading.
> 
> Singed-off-by: Ching 

Your email client screwed up the whitespace completely.  Read
Documentation/email-clients.txt or use `git send-email`
http://www.freedesktop.org/wiki/Software/PulseAudio/HowToUseGitSendEmail/

There are also many unrelated white space changes in this patch.

regards,
dan carpenter

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


Re: loading scsi_debug with data integrity hits BUG_ON

2014-02-20 Thread Akinobu Mita
Thanks for the patch.  I have just one nitpicking.

> diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c
> index 0bad24d..47ed160 100644
> --- a/fs/bio-integrity.c
> +++ b/fs/bio-integrity.c
> @@ -476,7 +476,6 @@ static int bio_integrity_verify(struct bio *bio)
> sector += sectors;
> prot_buf += sectors * bi->tuple_size;
> total += sectors * bi->tuple_size;
> -   BUG_ON(total > bio->bi_integrity->bip_iter.bi_size);

The variable 'total' is only used for the BUG_ON.  So it can be removed.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/8] lpfc 8.3.45: Update lpfc to revision 8.3.45

2014-02-20 Thread James Smart
This patch set updates the lpfc driver to revision 8.3.45

The patches for 8.3.45 contain:

- Added dport mailbox pass through support.
- Incorporated support of a low-latency io path
- Incorporate changes to use reason in change_queue_depth function.
- Fix sysfs buffer overrun in read of lpfc_fcp_cpu_map for 128 CPUs.
- Fixed missing initialization for task management IOCBs
- Fixed driver error messages after firmware download
- Fixed crash during driver unload.
- Update lpfc version to driver version 8.3.45


The patches were cut against scsi.git, branch "misc" with the
prior lpfc 8.3.44 patchset applied.

-- james s


Signed-off-by: James Smart 





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


[PATCH 1/8] lpfc 8.3.45: Added dport mailbox pass through support.

2014-02-20 Thread James Smart
Added dport mailbox pass through support.


Signed-off-by: James Smart 

 ---

 lpfc_bsg.c |3 +++
 lpfc_bsg.h |2 ++
 2 files changed, 5 insertions(+)


diff -upNr a/drivers/scsi/lpfc/lpfc_bsg.c b/drivers/scsi/lpfc/lpfc_bsg.c
--- a/drivers/scsi/lpfc/lpfc_bsg.c  2014-02-12 10:40:47.0 -0500
+++ b/drivers/scsi/lpfc/lpfc_bsg.c  2014-02-19 15:29:25.278023648 -0500
@@ -4153,6 +4153,7 @@ lpfc_bsg_handle_sli_cfg_mbox(struct lpfc
if (subsys == SLI_CONFIG_SUBSYS_FCOE) {
switch (opcode) {
case FCOE_OPCODE_READ_FCF:
+   case FCOE_OPCODE_GET_DPORT_RESULTS:
lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
"2957 Handled SLI_CONFIG "
"subsys_fcoe, opcode:x%x\n",
@@ -4161,6 +4162,8 @@ lpfc_bsg_handle_sli_cfg_mbox(struct lpfc
nemb_mse, dmabuf);
break;
case FCOE_OPCODE_ADD_FCF:
+   case FCOE_OPCODE_SET_DPORT_MODE:
+   case LPFC_MBOX_OPCODE_FCOE_LINK_DIAG_STATE:
lpfc_printf_log(phba, KERN_INFO, LOG_LIBDFC,
"2958 Handled SLI_CONFIG "
"subsys_fcoe, opcode:x%x\n",
diff -upNr a/drivers/scsi/lpfc/lpfc_bsg.h b/drivers/scsi/lpfc/lpfc_bsg.h
--- a/drivers/scsi/lpfc/lpfc_bsg.h  2014-02-11 16:07:17.0 -0500
+++ b/drivers/scsi/lpfc/lpfc_bsg.h  2014-02-19 15:29:25.282023648 -0500
@@ -231,6 +231,8 @@ struct lpfc_sli_config_emb0_subsys {
 #define SLI_CONFIG_SUBSYS_FCOE 0x0C
 #define FCOE_OPCODE_READ_FCF   0x08
 #define FCOE_OPCODE_ADD_FCF0x09
+#define FCOE_OPCODE_SET_DPORT_MODE 0x27
+#define FCOE_OPCODE_GET_DPORT_RESULTS  0x28
 };
 
 struct lpfc_sli_config_emb1_subsys {



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


[PATCH 4/8] lpfc 8.3.45: Fix sysfs buffer overrun in read of lpfc_fcp_cpu_map for 128 CPUs.

2014-02-20 Thread James Smart
Fix sysfs buffer overrun in read of lpfc_fcp_cpu_map for 128 CPUs.


Signed-off-by: James Smart 

 ---

 lpfc_attr.c |   28 ++--
 lpfc_init.c |2 ++
 lpfc_sli4.h |1 +
 3 files changed, 25 insertions(+), 6 deletions(-)


diff -upNr a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
--- a/drivers/scsi/lpfc/lpfc_attr.c 2014-02-19 15:29:28.602023725 -0500
+++ b/drivers/scsi/lpfc/lpfc_attr.c 2014-02-19 15:29:33.856023845 -0500
@@ -4288,7 +4288,7 @@ lpfc_fcp_cpu_map_show(struct device *dev
struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
struct lpfc_hba   *phba = vport->phba;
struct lpfc_vector_map_info *cpup;
-   int  idx, len = 0;
+   int  len = 0;
 
if ((phba->sli_rev != LPFC_SLI_REV4) ||
(phba->intr_type != MSIX))
@@ -4316,23 +4316,39 @@ lpfc_fcp_cpu_map_show(struct device *dev
break;
}
 
-   cpup = phba->sli4_hba.cpu_map;
-   for (idx = 0; idx < phba->sli4_hba.num_present_cpu; idx++) {
+   while (phba->sli4_hba.curr_disp_cpu < phba->sli4_hba.num_present_cpu) {
+   cpup = &phba->sli4_hba.cpu_map[phba->sli4_hba.curr_disp_cpu];
+
+   /* margin should fit in this and the truncated message */
if (cpup->irq == LPFC_VECTOR_MAP_EMPTY)
len += snprintf(buf + len, PAGE_SIZE-len,
"CPU %02d io_chan %02d "
"physid %d coreid %d\n",
-   idx, cpup->channel_id, cpup->phys_id,
+   phba->sli4_hba.curr_disp_cpu,
+   cpup->channel_id, cpup->phys_id,
cpup->core_id);
else
len += snprintf(buf + len, PAGE_SIZE-len,
"CPU %02d io_chan %02d "
"physid %d coreid %d IRQ %d\n",
-   idx, cpup->channel_id, cpup->phys_id,
+   phba->sli4_hba.curr_disp_cpu,
+   cpup->channel_id, cpup->phys_id,
cpup->core_id, cpup->irq);
 
-   cpup++;
+   phba->sli4_hba.curr_disp_cpu++;
+
+   /* display max number of CPUs keeping some margin */
+   if (phba->sli4_hba.curr_disp_cpu <
+   phba->sli4_hba.num_present_cpu &&
+   (len >= (PAGE_SIZE - 64))) {
+   len += snprintf(buf + len, PAGE_SIZE-len, "more...\n");
+   break;
+   }
}
+
+   if (phba->sli4_hba.curr_disp_cpu == phba->sli4_hba.num_present_cpu)
+   phba->sli4_hba.curr_disp_cpu = 0;
+
return len;
 }
 
diff -upNr a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
--- a/drivers/scsi/lpfc/lpfc_init.c 2014-02-19 15:29:28.636023725 -0500
+++ b/drivers/scsi/lpfc/lpfc_init.c 2014-02-19 15:29:33.869023845 -0500
@@ -5280,6 +5280,7 @@ lpfc_sli4_driver_resource_unset(struct l
kfree(phba->sli4_hba.cpu_map);
phba->sli4_hba.num_present_cpu = 0;
phba->sli4_hba.num_online_cpu = 0;
+   phba->sli4_hba.curr_disp_cpu = 0;
 
/* Free memory allocated for msi-x interrupt vector entries */
kfree(phba->sli4_hba.msix_entries);
@@ -6850,6 +6851,7 @@ lpfc_sli4_queue_verify(struct lpfc_hba *
}
phba->sli4_hba.num_online_cpu = i;
phba->sli4_hba.num_present_cpu = lpfc_present_cpu;
+   phba->sli4_hba.curr_disp_cpu = 0;
 
if (i < cfg_fcp_io_channel) {
lpfc_printf_log(phba,
diff -upNr a/drivers/scsi/lpfc/lpfc_sli4.h b/drivers/scsi/lpfc/lpfc_sli4.h
--- a/drivers/scsi/lpfc/lpfc_sli4.h 2014-02-19 15:29:28.693023727 -0500
+++ b/drivers/scsi/lpfc/lpfc_sli4.h 2014-02-19 15:29:33.871023845 -0500
@@ -607,6 +607,7 @@ struct lpfc_sli4_hba {
struct lpfc_vector_map_info *cpu_map;
uint16_t num_online_cpu;
uint16_t num_present_cpu;
+   uint16_t curr_disp_cpu;
 };
 
 enum lpfc_sge_type {



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


[PATCH 5/8] lpfc 8.3.45: Fixed missing initialization for task management IOCBs

2014-02-20 Thread James Smart
Fixed missing initialization for task management IOCBs


Signed-off-by: James Smart 

 ---

 lpfc_scsi.c |2 ++
 1 file changed, 2 insertions(+)


diff -upNr a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
--- a/drivers/scsi/lpfc/lpfc_scsi.c 2014-02-19 15:29:32.386023811 -0500
+++ b/drivers/scsi/lpfc/lpfc_scsi.c 2014-02-19 15:29:36.097023895 -0500
@@ -4423,6 +4423,8 @@ lpfc_scsi_prep_task_mgmt_cmd(struct lpfc
}
piocb->ulpFCP2Rcvy = (ndlp->nlp_fcp_info & NLP_FCP_2_DEVICE) ? 1 : 0;
piocb->ulpClass = (ndlp->nlp_fcp_info & 0x0f);
+   piocb->ulpPU = 0;
+   piocb->un.fcpi.fcpi_parm = 0;
 
/* ulpTimeout is only one byte */
if (lpfc_cmd->timeout > 0xff) {



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


[PATCH 3/8] lpfc 8.3.45: Incorporate changes to use reason in change_queue_depth function.

2014-02-20 Thread James Smart
Incorporate changes to use reason in change_queue_depth function.


Signed-off-by: James Smart 

 ---

 lpfc.h |3 -
 lpfc_crtn.h|1 
 lpfc_hbadisc.c |2 
 lpfc_scsi.c|  126 -
 4 files changed, 19 insertions(+), 113 deletions(-)


diff -upNr a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
--- a/drivers/scsi/lpfc/lpfc_crtn.h 2014-02-19 15:29:28.607023725 -0500
+++ b/drivers/scsi/lpfc/lpfc_crtn.h 2014-02-19 15:29:32.341023676 -0500
@@ -405,7 +405,6 @@ void lpfc_fabric_block_timeout(unsigned
 void lpfc_unblock_fabric_iocbs(struct lpfc_hba *);
 void lpfc_rampdown_queue_depth(struct lpfc_hba *);
 void lpfc_ramp_down_queue_handler(struct lpfc_hba *);
-void lpfc_ramp_up_queue_handler(struct lpfc_hba *);
 void lpfc_scsi_dev_block(struct lpfc_hba *);
 
 void
diff -upNr a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
--- a/drivers/scsi/lpfc/lpfc.h  2014-02-19 15:29:28.612023725 -0500
+++ b/drivers/scsi/lpfc/lpfc.h  2014-02-19 15:29:32.343023711 -0500
@@ -73,8 +73,6 @@ struct lpfc_sli2_slim;
  */
 /* 1 Second */
 #define QUEUE_RAMP_DOWN_INTERVAL   (msecs_to_jiffies(1000 * 1))
-/* 5 minutes */
-#define QUEUE_RAMP_UP_INTERVAL (msecs_to_jiffies(1000 * 300))
 
 /* Number of exchanges reserved for discovery to complete */
 #define LPFC_DISC_IOCB_BUFF_COUNT 20
@@ -885,7 +883,6 @@ struct lpfc_hba {
atomic_t num_cmd_success;
unsigned long last_rsrc_error_time;
unsigned long last_ramp_down_time;
-   unsigned long last_ramp_up_time;
 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
struct dentry *hba_debugfs_root;
atomic_t debugfs_vport_count;
diff -upNr a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c  2014-02-12 11:38:01.316067309 -0500
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c  2014-02-19 15:29:32.381023811 -0500
@@ -674,8 +674,6 @@ lpfc_work_done(struct lpfc_hba *phba)
lpfc_fdmi_timeout_handler(vport);
if (work_port_events & WORKER_RAMP_DOWN_QUEUE)
lpfc_ramp_down_queue_handler(phba);
-   if (work_port_events & WORKER_RAMP_UP_QUEUE)
-   lpfc_ramp_up_queue_handler(phba);
if (work_port_events & WORKER_DELAYED_DISC_TMO)
lpfc_delayed_disc_timeout_handler(vport);
}
diff -upNr a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
--- a/drivers/scsi/lpfc/lpfc_scsi.c 2014-02-19 15:29:28.688023727 -0500
+++ b/drivers/scsi/lpfc/lpfc_scsi.c 2014-02-19 15:29:32.386023811 -0500
@@ -315,7 +315,25 @@ lpfc_change_queue_depth(struct scsi_devi
unsigned long new_queue_depth, old_queue_depth;
 
old_queue_depth = sdev->queue_depth;
-   scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
+
+   switch (reason) {
+   case SCSI_QDEPTH_DEFAULT:
+   /* change request from sysfs, fall through */
+   case SCSI_QDEPTH_RAMP_UP:
+   scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
+   break;
+   case SCSI_QDEPTH_QFULL:
+   if (scsi_track_queue_full(sdev, qdepth) == 0)
+   return sdev->queue_depth;
+
+   lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
+"0711 detected queue full - lun queue "
+"depth adjusted to %d.\n", sdev->queue_depth);
+   break;
+   default:
+   return -EOPNOTSUPP;
+   }
+
new_queue_depth = sdev->queue_depth;
rdata = lpfc_rport_data_from_scsi_device(sdev);
if (rdata)
@@ -388,50 +406,6 @@ lpfc_rampdown_queue_depth(struct lpfc_hb
 }
 
 /**
- * lpfc_rampup_queue_depth - Post RAMP_UP_QUEUE event for worker thread
- * @phba: The Hba for which this call is being executed.
- *
- * This routine post WORKER_RAMP_UP_QUEUE event for @phba vport. This routine
- * post at most 1 event every 5 minute after last_ramp_up_time or
- * last_rsrc_error_time.  This routine wakes up worker thread of @phba
- * to process WORKER_RAM_DOWN_EVENT event.
- *
- * This routine should be called with no lock held.
- **/
-static inline void
-lpfc_rampup_queue_depth(struct lpfc_vport  *vport,
-   uint32_t queue_depth)
-{
-   unsigned long flags;
-   struct lpfc_hba *phba = vport->phba;
-   uint32_t evt_posted;
-   atomic_inc(&phba->num_cmd_success);
-
-   if (vport->cfg_lun_queue_depth <= queue_depth)
-   return;
-   spin_lock_irqsave(&phba->hbalock, flags);
-   if (time_before(jiffies,
-   phba->last_ramp_up_time + QUEUE_RAMP_UP_INTERVAL) ||
-   time_before(jiffies,
-   phba->last_rsrc_error_time + QUEUE_RAMP_UP_INTERVAL)) {
-   spin_unlock_irqrestore(&phba->hbalock, 

[PATCH 6/8] lpfc 8.3.45: Fixed driver error messages after firmware download

2014-02-20 Thread James Smart
Fixed driver error messages after firmware download


Signed-off-by: James Smart 

 ---

 lpfc_init.c |   22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)


diff -upNr a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
--- a/drivers/scsi/lpfc/lpfc_init.c 2014-02-19 15:29:33.869023845 -0500
+++ b/drivers/scsi/lpfc/lpfc_init.c 2014-02-19 15:29:37.302023923 -0500
@@ -1469,7 +1469,8 @@ lpfc_handle_eratt_s3(struct lpfc_hba *ph
  * for handling possible port resource change.
  **/
 static int
-lpfc_sli4_port_sta_fn_reset(struct lpfc_hba *phba, int mbx_action)
+lpfc_sli4_port_sta_fn_reset(struct lpfc_hba *phba, int mbx_action,
+   bool en_rn_msg)
 {
int rc;
uint32_t intr_mode;
@@ -1481,9 +1482,10 @@ lpfc_sli4_port_sta_fn_reset(struct lpfc_
rc = lpfc_sli4_pdev_status_reg_wait(phba);
if (!rc) {
/* need reset: attempt for port recovery */
-   lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-   "2887 Reset Needed: Attempting Port "
-   "Recovery...\n");
+   if (en_rn_msg)
+   lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
+   "2887 Reset Needed: Attempting Port "
+   "Recovery...\n");
lpfc_offline_prep(phba, mbx_action);
lpfc_offline(phba);
/* release interrupt for possible resource change */
@@ -1523,6 +1525,7 @@ lpfc_handle_eratt_s4(struct lpfc_hba *ph
uint32_t reg_err1, reg_err2;
uint32_t uerrlo_reg, uemasklo_reg;
uint32_t pci_rd_rc1, pci_rd_rc2;
+   bool en_rn_msg = true;
int rc;
 
/* If the pci channel is offline, ignore possible errors, since
@@ -1573,10 +1576,12 @@ lpfc_handle_eratt_s4(struct lpfc_hba *ph
break;
}
if (reg_err1 == SLIPORT_ERR1_REG_ERR_CODE_2 &&
-   reg_err2 == SLIPORT_ERR2_REG_FW_RESTART)
+   reg_err2 == SLIPORT_ERR2_REG_FW_RESTART) {
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-   "3143 Port Down: Firmware Restarted\n");
-   else if (reg_err1 == SLIPORT_ERR1_REG_ERR_CODE_2 &&
+   "3143 Port Down: Firmware Update "
+   "Detected\n");
+   en_rn_msg = false;
+   } else if (reg_err1 == SLIPORT_ERR1_REG_ERR_CODE_2 &&
 reg_err2 == SLIPORT_ERR2_REG_FORCED_DUMP)
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"3144 Port Down: Debug Dump\n");
@@ -1586,7 +1591,8 @@ lpfc_handle_eratt_s4(struct lpfc_hba *ph
"3145 Port Down: Provisioning\n");
 
/* Check port status register for function reset */
-   rc = lpfc_sli4_port_sta_fn_reset(phba, LPFC_MBX_NO_WAIT);
+   rc = lpfc_sli4_port_sta_fn_reset(phba, LPFC_MBX_NO_WAIT,
+   en_rn_msg);
if (rc == 0) {
/* don't report event on forced debug dump */
if (reg_err1 == SLIPORT_ERR1_REG_ERR_CODE_2 &&



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


[PATCH 7/8] lpfc 8.3.45: Fixed crash during driver unload.

2014-02-20 Thread James Smart
Fixed crash during driver unload.


Signed-off-by: James Smart 

 ---

 lpfc_els.c  |   18 ++
 lpfc_init.c |9 +++--
 lpfc_sli.c  |   10 +++---
 3 files changed, 28 insertions(+), 9 deletions(-)


diff -upNr a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
--- a/drivers/scsi/lpfc/lpfc_els.c  2014-02-12 11:38:01.389067311 -0500
+++ b/drivers/scsi/lpfc/lpfc_els.c  2014-02-19 15:29:38.234023944 -0500
@@ -6223,11 +6223,11 @@ lpfc_els_timeout(unsigned long ptr)
 
spin_lock_irqsave(&vport->work_port_lock, iflag);
tmo_posted = vport->work_port_events & WORKER_ELS_TMO;
-   if (!tmo_posted)
+   if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING)))
vport->work_port_events |= WORKER_ELS_TMO;
spin_unlock_irqrestore(&vport->work_port_lock, iflag);
 
-   if (!tmo_posted)
+   if ((!tmo_posted) && (!(vport->load_flag & FC_UNLOADING)))
lpfc_worker_wake_up(phba);
return;
 }
@@ -6259,10 +6259,19 @@ lpfc_els_timeout_handler(struct lpfc_vpo
timeout = (uint32_t)(phba->fc_ratov << 1);
 
pring = &phba->sli.ring[LPFC_ELS_RING];
+   if ((phba->pport->load_flag & FC_UNLOADING))
+   return;
spin_lock_irq(&phba->hbalock);
if (phba->sli_rev == LPFC_SLI_REV4)
spin_lock(&pring->ring_lock);
 
+   if ((phba->pport->load_flag & FC_UNLOADING)) {
+   if (phba->sli_rev == LPFC_SLI_REV4)
+   spin_unlock(&pring->ring_lock);
+   spin_unlock_irq(&phba->hbalock);
+   return;
+   }
+
list_for_each_entry_safe(piocb, tmp_iocb, &pring->txcmplq, list) {
cmd = &piocb->iocb;
 
@@ -6319,8 +6328,9 @@ lpfc_els_timeout_handler(struct lpfc_vpo
}
 
if (!list_empty(&phba->sli.ring[LPFC_ELS_RING].txcmplq))
-   mod_timer(&vport->els_tmofunc,
- jiffies + msecs_to_jiffies(1000 * timeout));
+   if (!(phba->pport->load_flag & FC_UNLOADING))
+   mod_timer(&vport->els_tmofunc,
+ jiffies + msecs_to_jiffies(1000 * timeout));
 }
 
 /**
diff -upNr a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
--- a/drivers/scsi/lpfc/lpfc_init.c 2014-02-19 15:29:37.302023923 -0500
+++ b/drivers/scsi/lpfc/lpfc_init.c 2014-02-19 15:29:38.242023944 -0500
@@ -1006,9 +1006,14 @@ lpfc_rrq_timeout(unsigned long ptr)
 
phba = (struct lpfc_hba *)ptr;
spin_lock_irqsave(&phba->pport->work_port_lock, iflag);
-   phba->hba_flag |= HBA_RRQ_ACTIVE;
+   if (!(phba->pport->load_flag & FC_UNLOADING))
+   phba->hba_flag |= HBA_RRQ_ACTIVE;
+   else
+   phba->hba_flag &= ~HBA_RRQ_ACTIVE;
spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag);
-   lpfc_worker_wake_up(phba);
+
+   if (!(phba->pport->load_flag & FC_UNLOADING))
+   lpfc_worker_wake_up(phba);
 }
 
 /**
diff -upNr a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
--- a/drivers/scsi/lpfc/lpfc_sli.c  2014-02-19 15:29:28.714023727 -0500
+++ b/drivers/scsi/lpfc/lpfc_sli.c  2014-02-19 15:29:38.260023944 -0500
@@ -678,7 +678,8 @@ lpfc_handle_rrq_active(struct lpfc_hba *
next_time = rrq->rrq_stop_time;
}
spin_unlock_irqrestore(&phba->hbalock, iflags);
-   if (!list_empty(&phba->active_rrq_list))
+   if ((!list_empty(&phba->active_rrq_list)) &&
+   (!(phba->pport->load_flag & FC_UNLOADING)))
mod_timer(&phba->rrq_tmr, next_time);
list_for_each_entry_safe(rrq, nextrrq, &send_rrq, list) {
list_del(&rrq->list);
@@ -792,7 +793,9 @@ lpfc_cleanup_wt_rrqs(struct lpfc_hba *ph
list_del(&rrq->list);
lpfc_clr_rrq_active(phba, rrq->xritag, rrq);
}
-   if (!list_empty(&phba->active_rrq_list))
+   if ((!list_empty(&phba->active_rrq_list)) &&
+   (!(phba->pport->load_flag & FC_UNLOADING)))
+
mod_timer(&phba->rrq_tmr, next_time);
 }
 
@@ -1323,7 +1326,8 @@ lpfc_sli_ringtxcmpl_put(struct lpfc_hba
 
if ((unlikely(pring->ringno == LPFC_ELS_RING)) &&
   (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) &&
-  (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN)) {
+  (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN) &&
+(!(piocb->vport->load_flag & FC_UNLOADING))) {
if (!piocb->vport)
BUG();
else



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


[PATCH 8/8] lpfc 8.3.45: Update lpfc version to driver version 8.3.45

2014-02-20 Thread James Smart
Update lpfc version to driver version 8.3.45


Signed-off-by: James Smart 

 ---

 lpfc_version.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff -upNr a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
--- a/drivers/scsi/lpfc/lpfc_version.h  2014-02-12 11:38:01.410067311 -0500
+++ b/drivers/scsi/lpfc/lpfc_version.h  2014-02-19 15:29:39.834023942 -0500
@@ -18,7 +18,7 @@
  * included with this package. *
  ***/
 
-#define LPFC_DRIVER_VERSION "8.3.44"
+#define LPFC_DRIVER_VERSION "8.3.45"
 #define LPFC_DRIVER_NAME   "lpfc"
 
 /* Used for SLI 2/3 */



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


Re: [PATCH 11/22] lpfc: Remove superfluous call to pci_disable_msix()

2014-02-20 Thread James Smart

Hi Alexander,

The change is fine - but not really necessary.  The pci_disable_msix() 
call explicitly checks for enablement so it's safe.


It really is a superfluous change - but if James wants to take it:
Acked-by: James Smart  


-- james  s



On 2/4/2014 6:16 AM, Alexander Gordeev wrote:

Signed-off-by: Alexander Gordeev 
Cc: James Smart 
Cc: linux-scsi@vger.kernel.org
Cc: linux-...@vger.kernel.org
---
  drivers/scsi/lpfc/lpfc_init.c |9 ++---
  1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 68c94cc..a9df97a 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -8078,7 +8078,7 @@ lpfc_sli_enable_msix(struct lpfc_hba *phba)
if (rc) {
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
"0420 PCI enable MSI-X failed (%d)\n", rc);
-   goto msi_fail_out;
+   goto vec_fail_out;
}
for (i = 0; i < LPFC_MSIX_VECTORS; i++)
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
@@ -8156,6 +8156,8 @@ irq_fail_out:
  msi_fail_out:
/* Unconfigure MSI-X capability structure */
pci_disable_msix(phba->pcidev);
+
+vec_fail_out:
return rc;
  }
  
@@ -8644,7 +8646,7 @@ enable_msix_vectors:

} else if (rc) {
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
"0484 PCI enable MSI-X failed (%d)\n", rc);
-   goto msi_fail_out;
+   goto vec_fail_out;
}
  
  	/* Log MSI-X vector assignment */

@@ -8696,9 +8698,10 @@ cfg_fail_out:
 &phba->sli4_hba.fcp_eq_hdl[index]);
}
  
-msi_fail_out:

/* Unconfigure MSI-X capability structure */
pci_disable_msix(phba->pcidev);
+
+vec_fail_out:
return rc;
  }
  


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


Re: [PATCH 12/22] lpfc: Use pci_enable_msix_range()

2014-02-20 Thread James Smart
Alexander,

I've reworked this patch to layer on top of our rev 8.3.45 patches
that were just posted to linux-scsi. There were some conflicts due to
new additions.  Additionally, there were two other uses of pci_enable_msiXXX
that needed to be addressed.  The changes in this patch also address the
change requested by:
"[PATCH 11/22] lpfc: Remove superfluous call to pci_disable_msix()"

To avoid creating merge conflicts - either by your patches going in then
scsi git tree trying to merge or by scsi git tree going in and your patches
trying to merge - I recommend that you eliminate your lpfc patches from the
kernel and apply the patch below once scsi git with the updated lpfc driver
has actually merged.

-- james s


Revised patch:



As result of deprecation of MSI-X/MSI enablement functions
pci_enable_msix() and pci_enable_msi_block() all drivers
using these two interfaces need to be updated to use the
new pci_enable_msi_range() and pci_enable_msix_range()
interfaces.

CC: Alexander Gordeev 
Cc: linux-scsi@vger.kernel.org
Cc: linux-...@vger.kernel.org



Signed-off-by: James Smart 

 ---

 lpfc_init.c |   43 ++-
 1 file changed, 22 insertions(+), 21 deletions(-)


diff -upNr a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
--- a/drivers/scsi/lpfc/lpfc_init.c 2014-02-19 16:23:07.260097013 -0500
+++ b/drivers/scsi/lpfc/lpfc_init.c 2014-02-20 11:39:20.348203354 -0500
@@ -8100,8 +8100,8 @@ lpfc_sli4_pci_mem_unset(struct lpfc_hba
  * @phba: pointer to lpfc hba data structure.
  *
  * This routine is invoked to enable the MSI-X interrupt vectors to device
- * with SLI-3 interface specs. The kernel function pci_enable_msix() is
- * called to enable the MSI-X vectors. Note that pci_enable_msix(), once
+ * with SLI-3 interface specs. The kernel function pci_enable_msix_range() is
+ * called to enable the MSI-X vectors. Note that pci_enable_msix_range(), once
  * invoked, enables either all or nothing, depending on the current
  * availability of PCI vector resources. The device driver is responsible
  * for calling the individual request_irq() to register each MSI-X vector
@@ -8126,12 +8126,12 @@ lpfc_sli_enable_msix(struct lpfc_hba *ph
phba->msix_entries[i].entry = i;
 
/* Configure MSI-X capability structure */
-   rc = pci_enable_msix(phba->pcidev, phba->msix_entries,
-   ARRAY_SIZE(phba->msix_entries));
-   if (rc) {
+   rc = pci_enable_msix_range(phba->pcidev, phba->msix_entries,
+  LPFC_MSIX_VECTORS, LPFC_MSIX_VECTORS);
+   if (rc < 0) {
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
"0420 PCI enable MSI-X failed (%d)\n", rc);
-   goto msi_fail_out;
+   goto vec_fail_out;
}
for (i = 0; i < LPFC_MSIX_VECTORS; i++)
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
@@ -8209,6 +8209,8 @@ irq_fail_out:
 msi_fail_out:
/* Unconfigure MSI-X capability structure */
pci_disable_msix(phba->pcidev);
+
+vec_fail_out:
return rc;
 }
 
@@ -8238,8 +8240,8 @@ lpfc_sli_disable_msix(struct lpfc_hba *p
  * @phba: pointer to lpfc hba data structure.
  *
  * This routine is invoked to enable the MSI interrupt mode to device with
- * SLI-3 interface spec. The kernel function pci_enable_msi() is called to
- * enable the MSI vector. The device driver is responsible for calling the
+ * SLI-3 interface spec. The kernel function pci_enable_msi_range() is called
+ * to enable the MSI vector. The device driver is responsible for calling the
  * request_irq() to register MSI vector with a interrupt the handler, which
  * is done in this function.
  *
@@ -8252,8 +8254,8 @@ lpfc_sli_enable_msi(struct lpfc_hba *phb
 {
int rc;
 
-   rc = pci_enable_msi(phba->pcidev);
-   if (!rc)
+   rc = pci_enable_msi_range(phba->pcidev, 1, 1);
+   if (rc > 0)
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
"0462 PCI enable MSI mode success.\n");
else {
@@ -8692,17 +8694,15 @@ lpfc_sli4_enable_msix(struct lpfc_hba *p
phba->sli4_hba.msix_entries[index].entry = index;
vectors++;
}
-enable_msix_vectors:
-   rc = pci_enable_msix(phba->pcidev, phba->sli4_hba.msix_entries,
-vectors);
-   if (rc > 1) {
-   vectors = rc;
-   goto enable_msix_vectors;
-   } else if (rc) {
+
+   rc = pci_enable_msix_range(phba->pcidev, phba->sli4_hba.msix_entries,
+  2, vectors);
+   if (rc < 0) {
lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
"0484 PCI enable MSI-X failed (%d)\n", rc);
goto msi_fail_out;
}
+   vectors = rc;
 
/* Log MSI-X vector assignment */
for (index = 0; index < vectors; index++)
@@ -8764

Re: [PATCH v2] target_core_alua: silence GCC warning

2014-02-20 Thread Nicholas A. Bellinger
On Thu, 2014-02-20 at 09:07 +0100, Paul Bolle wrote:
> Building target_core_alua.o triggers a GCC warning:
> drivers/target/target_core_alua.c: In function ‘target_alua_state_check’:
> drivers/target/target_core_alua.c:773:18: warning: ‘alua_ascq’ may be 
> used uninitialized in this function [-Wmaybe-uninitialized]
>cmd->scsi_ascq = alua_ascq;
>   ^
> 
> This is a false positive. A little trial and error shows it is
> apparently caused by core_alua_state_lba_dependent(). It must be hard
> for GCC to track the branches of a switch statement, inside a
> list_for_each_entry loop, inside a while loop.
> 
> But if we add a small (inline) helper function we can reorganize the
> code a bit. That also allows to drop alua_ascq which, obviously, gets
> rid of this warning.
> 
> Signed-off-by: Paul Bolle 
> ---
> v2: Make core_alua_state_nonoptimized() return void, as Geert
> suggested. 
> 
> Also keep core_alua_state_lba_dependent() inline. Setting that function
> noinline was just a leftover from the trial and error fase, and isn't
> needed to make the warning go away. Ie, I was sloppy in v1!
> 
> Still compile tested only.
> 
>  drivers/target/target_core_alua.c | 95 
> ++-
>  1 file changed, 44 insertions(+), 51 deletions(-)
> 

Applied to target-pending/for-next.

Thanks Paul!

--nab

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


Re: loading scsi_debug with data integrity hits BUG_ON

2014-02-20 Thread Nicholas A. Bellinger
On Thu, 2014-02-20 at 22:44 +0900, Akinobu Mita wrote:
> Thanks for the patch.  I have just one nitpicking.
> 
> > diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c
> > index 0bad24d..47ed160 100644
> > --- a/fs/bio-integrity.c
> > +++ b/fs/bio-integrity.c
> > @@ -476,7 +476,6 @@ static int bio_integrity_verify(struct bio *bio)
> > sector += sectors;
> > prot_buf += sectors * bi->tuple_size;
> > total += sectors * bi->tuple_size;
> > -   BUG_ON(total > bio->bi_integrity->bip_iter.bi_size);
> 
> The variable 'total' is only used for the BUG_ON.  So it can be removed.

Duh, yes of course..

MKP + Jens, any concerns wrt dropping this BUG_ON for v3.14-rc code..?

--nab

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


Re: loading scsi_debug with data integrity hits BUG_ON

2014-02-20 Thread Martin K. Petersen
> "nab" == Nicholas A Bellinger  writes:

nab> Given that there is no (easy) way to ascertain what the original
nab> value of bio_integrity->bip_iter.bi_size was post
nab> bio_integrity_advance(), dropping this BUG_ON() probably makes the
nab> most sense.

nab> MKP + Jens, care to ACK + pickup..?

Please remove total as suggested by Akinobu.

Acked-by: Martin K. Petersen 

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


Re: suspicious self-assignment in lpfc

2014-02-20 Thread James Smart

yeah - this is pretty silly.  I'll cut a patch to remove the lines.

-- james s


On 2/18/2014 12:42 PM, Dave Jones wrote:

Looking through coverity reports, and it flagged lpfc_read_fcf_conn_tbl()
due to the following patch..

commit df0d085fdd2e7c39d1249c2d4ad6b3e176efb60c
Author: James Smart 
Date:   Fri May 31 17:05:08 2013 -0400

 [SCSI] lpfc 8.3.40: Fixed FCoE connection list vlan identifier and add FCF 
list debug
 
 Signed-off-by: James Smart 

 Signed-off-by: James Bottomley 

diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 0f6e2548f35d..0309cc15aad6 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -6158,12 +6158,44 @@ lpfc_read_fcf_conn_tbl(struct lpfc_hba *phba,
 memcpy(&conn_entry->conn_rec, &conn_rec[i],
 sizeof(struct lpfc_fcf_conn_rec));
 conn_entry->conn_rec.vlan_tag =
-   le16_to_cpu(conn_entry->conn_rec.vlan_tag) & 0xFFF;
+   conn_entry->conn_rec.vlan_tag;
 conn_entry->conn_rec.flags =
-   le16_to_cpu(conn_entry->conn_rec.flags);
+   conn_entry->conn_rec.flags;
 list_add_tail(&conn_entry->list,
 &phba->fcf_conn_rec_list);


Now that we're not caring about endianness, those two assignments are redundant.
I gather this has passed testing, because surely someone would have complained 
by now,
but can they be removed, or should they be doing something else entirely ?

Dave





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


[PATCH] lpfc: remove self-assignments

2014-02-20 Thread James Smart
As spotted by coverty/Dave Jones, removing unnecessary self assignments.

-- james s




Signed-off-by: James Smart 

 ---

 lpfc_hbadisc.c |4 
 1 file changed, 4 deletions(-)


diff -upNr a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c  2014-02-19 15:16:18.664005738 -0500
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c  2014-02-20 14:17:21.208419233 -0500
@@ -6189,10 +6189,6 @@ lpfc_read_fcf_conn_tbl(struct lpfc_hba *
 
memcpy(&conn_entry->conn_rec, &conn_rec[i],
sizeof(struct lpfc_fcf_conn_rec));
-   conn_entry->conn_rec.vlan_tag =
-   conn_entry->conn_rec.vlan_tag;
-   conn_entry->conn_rec.flags =
-   conn_entry->conn_rec.flags;
list_add_tail(&conn_entry->list,
&phba->fcf_conn_rec_list);
}


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


Re: loading scsi_debug with data integrity hits BUG_ON

2014-02-20 Thread Nicholas A. Bellinger
On Thu, 2014-02-20 at 14:16 -0500, Martin K. Petersen wrote:
> > "nab" == Nicholas A Bellinger  writes:
> 
> nab> Given that there is no (easy) way to ascertain what the original
> nab> value of bio_integrity->bip_iter.bi_size was post
> nab> bio_integrity_advance(), dropping this BUG_ON() probably makes the
> nab> most sense.
> 
> nab> MKP + Jens, care to ACK + pickup..?
> 
> Please remove total as suggested by Akinobu.
> 
> Acked-by: Martin K. Petersen 
> 

Thanks.  Here's an updated patch for Jen's to pickup.

--nab

>From 6bd5636cd46fe8e11de9bdecc26acac14a494f18 Mon Sep 17 00:00:00 2001
From: Nicholas Bellinger 
Date: Thu, 20 Feb 2014 00:52:01 +
Subject: [PATCH] bio-integrity: Drop bio_integrity_verify BUG_ON in post
 bip->bip_iter world

Given that bip->bip_iter.bi_size is decremented after bio_advance() ->
bio_integrity_advance() is called, the BUG_ON() in bio_integrity_verify()
ends up tripping in v3.14-rc1 code with the advent of immutable biovecs
in:

commit d57a5f7c6605f15f3b5134837e68b448a7cea88e
Author: Kent Overstreet 
Date:   Sat Nov 23 17:20:16 2013 -0800

bio-integrity: Convert to bvec_iter

Given that there is no easy way to ascertain the original bi_size
value, go ahead and drop this BUG_ON().

Reported-by: Sagi Grimberg 
Reported-by: Akinobu Mita 
Acked-by: Martin K. Petersen 
Cc: Jens Axboe 
Cc: Kent Overstreet 
Signed-off-by: Nicholas Bellinger 
---
 fs/bio-integrity.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c
index 0bad24d..76e0116 100644
--- a/fs/bio-integrity.c
+++ b/fs/bio-integrity.c
@@ -449,11 +449,10 @@ static int bio_integrity_verify(struct bio *bio)
struct blk_integrity_exchg bix;
struct bio_vec *bv;
sector_t sector = bio->bi_integrity->bip_iter.bi_sector;
-   unsigned int sectors, total, ret;
+   unsigned int sectors, ret = 0;
void *prot_buf = bio->bi_integrity->bip_buf;
int i;
 
-   ret = total = 0;
bix.disk_name = bio->bi_bdev->bd_disk->disk_name;
bix.sector_size = bi->sector_size;
 
@@ -475,8 +474,6 @@ static int bio_integrity_verify(struct bio *bio)
sectors = bv->bv_len / bi->sector_size;
sector += sectors;
prot_buf += sectors * bi->tuple_size;
-   total += sectors * bi->tuple_size;
-   BUG_ON(total > bio->bi_integrity->bip_iter.bi_size);
 
kunmap_atomic(kaddr);
}
-- 
1.7.10.4

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


Re: [PATCH] st: use dev_printk() to avoid linebreaks in kernel messages.

2014-02-20 Thread Martin K. Petersen
> "Hannes" == Hannes Reinecke  writes:

Hannes,

>> If you have a more complete and up-to-date patchset in your queue it
>> would be interesting to have a look at it.
>> 
Hannes> You can find the current development branch at

Hannes> git.kernel.org:/pub/scm/linux/kernel/git/hare/scsi-devel branch
Hannes> scsi-logging.v3

I like the printk cleanups and the more sensible sense printing. But why
perpetuate the crufty old SCSI logging stuff when we have SCSI tracing?

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


[PATCH 4/9] firewire: don't use PREPARE_DELAYED_WORK

2014-02-20 Thread Tejun Heo
PREPARE_[DELAYED_]WORK() are being phased out.  They have few users
and a nasty surprise in terms of reentrancy guarantee as workqueue
considers work items to be different if they don't have the same work
function.

firewire core-device and sbp2 have been been multiplexing work items
with multiple work functions.  Introduce fw_device_workfn() and
sbp2_lu_workfn() which invoke fw_device->workfn and
sbp2_logical_unit->workfn respectively and always use the two
functions as the work functions and update the users to set the
->workfn fields instead of overriding work functions using
PREPARE_DELAYED_WORK().

It would probably be best to route this with other related updates
through the workqueue tree.

Compile tested.

Signed-off-by: Tejun Heo 
Cc: Stefan Richter 
Cc: linux1394-de...@lists.sourceforge.net
Cc: Chris Boot 
Cc: linux-scsi@vger.kernel.org
Cc: target-de...@vger.kernel.org
---
 drivers/firewire/core-device.c | 22 +++---
 drivers/firewire/sbp2.c| 17 +
 include/linux/firewire.h   |  1 +
 3 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index de4aa40..2c6d5e1 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -916,7 +916,7 @@ static int lookup_existing_device(struct device *dev, void 
*data)
old->config_rom_retries = 0;
fw_notice(card, "rediscovered device %s\n", dev_name(dev));
 
-   PREPARE_DELAYED_WORK(&old->work, fw_device_update);
+   old->workfn = fw_device_update;
fw_schedule_device_work(old, 0);
 
if (current_node == card->root_node)
@@ -1075,7 +1075,7 @@ static void fw_device_init(struct work_struct *work)
if (atomic_cmpxchg(&device->state,
   FW_DEVICE_INITIALIZING,
   FW_DEVICE_RUNNING) == FW_DEVICE_GONE) {
-   PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
+   device->workfn = fw_device_shutdown;
fw_schedule_device_work(device, SHUTDOWN_DELAY);
} else {
fw_notice(card, "created device %s: GUID %08x%08x, S%d00\n",
@@ -1196,13 +1196,20 @@ static void fw_device_refresh(struct work_struct *work)
  dev_name(&device->device), fw_rcode_string(ret));
  gone:
atomic_set(&device->state, FW_DEVICE_GONE);
-   PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
+   device->workfn = fw_device_shutdown;
fw_schedule_device_work(device, SHUTDOWN_DELAY);
  out:
if (node_id == card->root_node->node_id)
fw_schedule_bm_work(card, 0);
 }
 
+static void fw_device_workfn(struct work_struct *work)
+{
+   struct fw_device *device = container_of(to_delayed_work(work),
+   struct fw_device, work);
+   device->workfn(work);
+}
+
 void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
 {
struct fw_device *device;
@@ -1252,7 +1259,8 @@ void fw_node_event(struct fw_card *card, struct fw_node 
*node, int event)
 * power-up after getting plugged in.  We schedule the
 * first config rom scan half a second after bus reset.
 */
-   INIT_DELAYED_WORK(&device->work, fw_device_init);
+   device->workfn = fw_device_init;
+   INIT_DELAYED_WORK(&device->work, fw_device_workfn);
fw_schedule_device_work(device, INITIAL_DELAY);
break;
 
@@ -1268,7 +1276,7 @@ void fw_node_event(struct fw_card *card, struct fw_node 
*node, int event)
if (atomic_cmpxchg(&device->state,
FW_DEVICE_RUNNING,
FW_DEVICE_INITIALIZING) == FW_DEVICE_RUNNING) {
-   PREPARE_DELAYED_WORK(&device->work, fw_device_refresh);
+   device->workfn = fw_device_refresh;
fw_schedule_device_work(device,
device->is_local ? 0 : INITIAL_DELAY);
}
@@ -1283,7 +1291,7 @@ void fw_node_event(struct fw_card *card, struct fw_node 
*node, int event)
smp_wmb();  /* update node_id before generation */
device->generation = card->generation;
if (atomic_read(&device->state) == FW_DEVICE_RUNNING) {
-   PREPARE_DELAYED_WORK(&device->work, fw_device_update);
+   device->workfn = fw_device_update;
fw_schedule_device_work(device, 0);
}
break;
@@ -1308,7 +1316,7 @@ void fw_node_event(struct fw_card *card, struct fw_node 
*node, int event)
device = node->data;
if (atomic_xchg(&device->state,
FW_DEVICE_GONE) == FW_DEVICE_RUNNING) {
-   PREPARE_DELAYED_WORK(&device->work, 

[PATCH 0/5] qla2xxx: NPIV target mode fixes for v3.14-rc

2014-02-20 Thread Nicholas A. Bellinger
From: Nicholas Bellinger 

Hi Sawan, Quinn, & Co.

The following series addresses a number of NPIV related bugs specific
to v3.14-rc code, mostly involving the underlying configfs dependency
of base_vha / base_tpg to not be removed while there are active NPIV
ports.

Patch #1 fixes a race between the qlt_lport_register() callback and
subsequent shutdown operations.

Patch #2 ensures that shutdown of a base_vha port fails when there
are active npiv_ports_inuse.

Patch #3 adds seperate enable/disable attribute logic that is specific
to NPIV operation, and patch #4 adds the configfs_[un]depend_item()
calls in ensure that base_vha / base_tpg cannot be removed from the
configfs hierarchy until all associated NPIV ports have been shutdown.

And patch #5 fixes a seperate issue with NAA formatting of EVPD=0x83
device identifier for NPIV WWPNs.

Please review.

Thanks!

--nab

Nicholas Bellinger (5):
  qla2xxx: Fix qlt_lport_register base_vha callback race
  qla2xxx: Check + fail when npiv_vports_inuse exists in shutdown
  tcm_qla2xxx: Add NPIV specific enable/disable attribute logic
  tcm_qla2xxx: Perform configfs depend/undepend for base_tpg
  tcm_qla2xxx: Fix NAA formatted name for NPIV WWPNs

 drivers/scsi/qla2xxx/qla_target.c  |   39 +++--
 drivers/scsi/qla2xxx/qla_target.h  |2 +-
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |  158 ++--
 drivers/scsi/qla2xxx/tcm_qla2xxx.h |7 +-
 4 files changed, 153 insertions(+), 53 deletions(-)

-- 
1.7.10.4

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


[PATCH 3/5] tcm_qla2xxx: Add NPIV specific enable/disable attribute logic

2014-02-20 Thread Nicholas A. Bellinger
From: Nicholas Bellinger 

This patch adds seperate logic for NPIV specific enable/disable
attribute logic, as NPIV vs. non-NPIV enable/disable ends up being
different enough to warrent seperate logic for setting configfs
tpg_group dependencies in the non-NPIV case.

Cc: Sawan Chandak 
Cc: Quinn Tran 
Cc: Saurav Kashyap 
Cc: Giridhar Malavali 
Signed-off-by: Nicholas Bellinger 
---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |   59 ++--
 1 file changed, 56 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 75a141b..db43b289 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -1053,11 +1053,64 @@ static void tcm_qla2xxx_drop_tpg(struct se_portal_group 
*se_tpg)
/*
 * Clear local TPG=1 pointer for non NPIV mode.
 */
-   lport->tpg_1 = NULL;
-
+   lport->tpg_1 = NULL;
kfree(tpg);
 }
 
+static ssize_t tcm_qla2xxx_npiv_tpg_show_enable(
+   struct se_portal_group *se_tpg,
+   char *page)
+{
+   return tcm_qla2xxx_tpg_show_enable(se_tpg, page);
+}
+
+static ssize_t tcm_qla2xxx_npiv_tpg_store_enable(
+   struct se_portal_group *se_tpg,
+   const char *page,
+   size_t count)
+{
+   struct se_wwn *se_wwn = se_tpg->se_tpg_wwn;
+   struct tcm_qla2xxx_lport *lport = container_of(se_wwn,
+   struct tcm_qla2xxx_lport, lport_wwn);
+   struct scsi_qla_host *vha = lport->qla_vha;
+   struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
+   struct tcm_qla2xxx_tpg, se_tpg);
+   unsigned long op;
+   int rc;
+
+   rc = kstrtoul(page, 0, &op);
+   if (rc < 0) {
+   pr_err("kstrtoul() returned %d\n", rc);
+   return -EINVAL;
+   }
+   if ((op != 1) && (op != 0)) {
+   pr_err("Illegal value for tpg_enable: %lu\n", op);
+   return -EINVAL;
+   }
+   if (op) {
+   if (atomic_read(&tpg->lport_tpg_enabled))
+   return -EEXIST;
+
+   atomic_set(&tpg->lport_tpg_enabled, 1);
+   qlt_enable_vha(vha);
+   } else {
+   if (!atomic_read(&tpg->lport_tpg_enabled))
+   return count;
+
+   atomic_set(&tpg->lport_tpg_enabled, 0);
+   qlt_stop_phase1(vha->vha_tgt.qla_tgt);
+   }
+
+   return count;
+}
+
+TF_TPG_BASE_ATTR(tcm_qla2xxx_npiv, enable, S_IRUGO | S_IWUSR);
+
+static struct configfs_attribute *tcm_qla2xxx_npiv_tpg_attrs[] = {
+&tcm_qla2xxx_npiv_tpg_enable.attr,
+NULL,
+};
+
 static struct se_portal_group *tcm_qla2xxx_npiv_make_tpg(
struct se_wwn *wwn,
struct config_group *group,
@@ -1935,7 +1988,7 @@ static int tcm_qla2xxx_register_configfs(void)
 */
npiv_fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs;
npiv_fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs =
-   tcm_qla2xxx_tpg_attrs;
+   tcm_qla2xxx_npiv_tpg_attrs;
npiv_fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL;
npiv_fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL;
npiv_fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL;
-- 
1.7.10.4

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


[PATCH 1/5] qla2xxx: Fix qlt_lport_register base_vha callback race

2014-02-20 Thread Nicholas A. Bellinger
From: Nicholas Bellinger 

This patch closes a race between qlt_lport_register() and
tcm_qla2xxx callback logic by holding qla_tgt_mutex before
making the callback.

In order for this to work, the qlt_add_target() and
qlt_remove_target() code has been changed to avoid the
accessing qla_tgt_mutex + list_[add,del] for NPIV enabled
ports.

This bug introduced in v3.14-rc1 code with commit 49a47f2.

Cc: Sawan Chandak 
Cc: Quinn Tran 
Cc: Saurav Kashyap 
Cc: Giridhar Malavali 
Signed-off-by: Nicholas Bellinger 
---
 drivers/scsi/qla2xxx/qla_target.c |   16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 2eb97d7..ea3eaef 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -4181,6 +4181,9 @@ int qlt_add_target(struct qla_hw_data *ha, struct 
scsi_qla_host *base_vha)
tgt->datasegs_per_cmd = QLA_TGT_DATASEGS_PER_CMD_24XX;
tgt->datasegs_per_cont = QLA_TGT_DATASEGS_PER_CONT_24XX;
 
+   if (base_vha->fc_vport)
+   return 0;
+
mutex_lock(&qla_tgt_mutex);
list_add_tail(&tgt->tgt_list_entry, &qla_tgt_glist);
mutex_unlock(&qla_tgt_mutex);
@@ -4194,6 +4197,10 @@ int qlt_remove_target(struct qla_hw_data *ha, struct 
scsi_qla_host *vha)
if (!vha->vha_tgt.qla_tgt)
return 0;
 
+   if (vha->fc_vport) {
+   qlt_release(vha->vha_tgt.qla_tgt);
+   return 0;
+   }
mutex_lock(&qla_tgt_mutex);
list_del(&vha->vha_tgt.qla_tgt->tgt_list_entry);
mutex_unlock(&qla_tgt_mutex);
@@ -4265,6 +4272,12 @@ int qlt_lport_register(void *target_lport_ptr, u64 
phys_wwpn,
spin_unlock_irqrestore(&ha->hardware_lock, flags);
continue;
}
+   if (tgt->tgt_stop) {
+   pr_debug("MODE_TARGET in shutdown on qla2xxx(%d)\n",
+host->host_no);
+   spin_unlock_irqrestore(&ha->hardware_lock, flags);
+   continue;
+   }
spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
if (!scsi_host_get(host)) {
@@ -4279,12 +4292,11 @@ int qlt_lport_register(void *target_lport_ptr, u64 
phys_wwpn,
scsi_host_put(host);
continue;
}
-   mutex_unlock(&qla_tgt_mutex);
-
rc = (*callback)(vha, target_lport_ptr, npiv_wwpn, npiv_wwnn);
if (rc != 0)
scsi_host_put(host);
 
+   mutex_unlock(&qla_tgt_mutex);
return rc;
}
mutex_unlock(&qla_tgt_mutex);
-- 
1.7.10.4

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


[PATCH 4/5] tcm_qla2xxx: Perform configfs depend/undepend for base_tpg

2014-02-20 Thread Nicholas A. Bellinger
From: Nicholas Bellinger 

This patch performs configfs_depend_item() during TPG enable for
base_tpg (eg: non-NPIV) ports, and configfs_undepend_item() during
TPG disable for base_tpg.

This is done to ensure that any attempt to configfs rmdir a base_tpg
with active NPIV ports will fail with -EBUSY, until all associated
NPIV ports have been explicitly shutdown and base_tpg disabled.

Note that the actual configfs_[un]depend_item() is done from seperate
process context, as these are not intended to be called directly
from configfs callbacks.

Cc: Sawan Chandak 
Cc: Quinn Tran 
Cc: Saurav Kashyap 
Cc: Giridhar Malavali 
Signed-off-by: Nicholas Bellinger 
---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |   72 +---
 drivers/scsi/qla2xxx/tcm_qla2xxx.h |3 ++
 2 files changed, 61 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index db43b289..5bdc440 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -941,15 +941,41 @@ static ssize_t tcm_qla2xxx_tpg_show_enable(
atomic_read(&tpg->lport_tpg_enabled));
 }
 
+static void tcm_qla2xxx_depend_tpg(struct work_struct *work)
+{
+   struct tcm_qla2xxx_tpg *base_tpg = container_of(work,
+   struct tcm_qla2xxx_tpg, tpg_base_work);
+   struct se_portal_group *se_tpg = &base_tpg->se_tpg;
+   struct scsi_qla_host *base_vha = base_tpg->lport->qla_vha;
+
+   if (!configfs_depend_item(se_tpg->se_tpg_tfo->tf_subsys,
+ &se_tpg->tpg_group.cg_item)) {
+   atomic_set(&base_tpg->lport_tpg_enabled, 1);
+   qlt_enable_vha(base_vha);
+   }
+   complete(&base_tpg->tpg_base_comp);
+}
+
+static void tcm_qla2xxx_undepend_tpg(struct work_struct *work)
+{
+   struct tcm_qla2xxx_tpg *base_tpg = container_of(work,
+   struct tcm_qla2xxx_tpg, tpg_base_work);
+   struct se_portal_group *se_tpg = &base_tpg->se_tpg;
+   struct scsi_qla_host *base_vha = base_tpg->lport->qla_vha;
+
+   if (!qlt_stop_phase1(base_vha->vha_tgt.qla_tgt)) {
+   atomic_set(&base_tpg->lport_tpg_enabled, 0);
+   configfs_undepend_item(se_tpg->se_tpg_tfo->tf_subsys,
+  &se_tpg->tpg_group.cg_item);
+   }
+   complete(&base_tpg->tpg_base_comp);
+}
+
 static ssize_t tcm_qla2xxx_tpg_store_enable(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
 {
-   struct se_wwn *se_wwn = se_tpg->se_tpg_wwn;
-   struct tcm_qla2xxx_lport *lport = container_of(se_wwn,
-   struct tcm_qla2xxx_lport, lport_wwn);
-   struct scsi_qla_host *vha = lport->qla_vha;
struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
struct tcm_qla2xxx_tpg, se_tpg);
unsigned long op;
@@ -964,19 +990,28 @@ static ssize_t tcm_qla2xxx_tpg_store_enable(
pr_err("Illegal value for tpg_enable: %lu\n", op);
return -EINVAL;
}
-
if (op) {
-   atomic_set(&tpg->lport_tpg_enabled, 1);
-   qlt_enable_vha(vha);
+   if (atomic_read(&tpg->lport_tpg_enabled))
+   return -EEXIST;
+
+   INIT_WORK(&tpg->tpg_base_work, tcm_qla2xxx_depend_tpg);
} else {
-   if (!vha->vha_tgt.qla_tgt) {
-   pr_err("struct qla_hw_data *vha->vha_tgt.qla_tgt is 
NULL\n");
-   return -ENODEV;
-   }
-   atomic_set(&tpg->lport_tpg_enabled, 0);
-   qlt_stop_phase1(vha->vha_tgt.qla_tgt);
+   if (!atomic_read(&tpg->lport_tpg_enabled))
+   return count;
+
+   INIT_WORK(&tpg->tpg_base_work, tcm_qla2xxx_undepend_tpg);
}
+   init_completion(&tpg->tpg_base_comp);
+   schedule_work(&tpg->tpg_base_work);
+   wait_for_completion(&tpg->tpg_base_comp);
 
+   if (op) {
+   if (!atomic_read(&tpg->lport_tpg_enabled))
+   return -ENODEV;
+   } else {
+   if (atomic_read(&tpg->lport_tpg_enabled))
+   return -EPERM;
+   }
return count;
 }
 
@@ -1703,6 +1738,9 @@ static int tcm_qla2xxx_lport_register_npiv_cb(struct 
scsi_qla_host *base_vha,
struct scsi_qla_host *npiv_vha;
struct tcm_qla2xxx_lport *lport =
(struct tcm_qla2xxx_lport *)target_lport_ptr;
+   struct tcm_qla2xxx_lport *base_lport =
+   (struct tcm_qla2xxx_lport 
*)base_vha->vha_tgt.target_lport_ptr;
+   struct tcm_qla2xxx_tpg *base_tpg;
struct fc_vport_identifiers vport_id;
 
if (!qla_tgt_mode_enabled(base_vha)) {
@@ -1710,6 +1748,13 @@ static int tcm_qla2xxx_lport_register_npiv_cb(struct 
scsi_qla_host *base_vha,
return -EPERM;
}
 
+   

[PATCH 5/5] tcm_qla2xxx: Fix NAA formatted name for NPIV WWPNs

2014-02-20 Thread Nicholas A. Bellinger
From: Nicholas Bellinger 

This patch fixes the NAA formatted name used by EVPD=0x83
device identifer to reflect the proper NPIV enabled WWPN.

Cc: Sawan Chandak 
Cc: Quinn Tran 
Cc: Saurav Kashyap 
Cc: Giridhar Malavali 
Signed-off-by: Nicholas Bellinger 
---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |   27 +--
 drivers/scsi/qla2xxx/tcm_qla2xxx.h |4 
 2 files changed, 1 insertion(+), 30 deletions(-)

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 5bdc440..788c4fe 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -182,20 +182,6 @@ static int tcm_qla2xxx_npiv_parse_wwn(
return 0;
 }
 
-static ssize_t tcm_qla2xxx_npiv_format_wwn(char *buf, size_t len,
-   u64 wwpn, u64 wwnn)
-{
-   u8 b[8], b2[8];
-
-   put_unaligned_be64(wwpn, b);
-   put_unaligned_be64(wwnn, b2);
-   return snprintf(buf, len,
-   "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x,"
-   "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
-   b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7],
-   b2[0], b2[1], b2[2], b2[3], b2[4], b2[5], b2[6], b2[7]);
-}
-
 static char *tcm_qla2xxx_npiv_get_fabric_name(void)
 {
return "qla2xxx_npiv";
@@ -227,15 +213,6 @@ static char *tcm_qla2xxx_get_fabric_wwn(struct 
se_portal_group *se_tpg)
return lport->lport_naa_name;
 }
 
-static char *tcm_qla2xxx_npiv_get_fabric_wwn(struct se_portal_group *se_tpg)
-{
-   struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
-   struct tcm_qla2xxx_tpg, se_tpg);
-   struct tcm_qla2xxx_lport *lport = tpg->lport;
-
-   return &lport->lport_npiv_name[0];
-}
-
 static u16 tcm_qla2xxx_get_tag(struct se_portal_group *se_tpg)
 {
struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
@@ -1811,8 +1788,6 @@ static struct se_wwn *tcm_qla2xxx_npiv_make_lport(
}
lport->lport_npiv_wwpn = npiv_wwpn;
lport->lport_npiv_wwnn = npiv_wwnn;
-   tcm_qla2xxx_npiv_format_wwn(&lport->lport_npiv_name[0],
-   TCM_QLA2XXX_NAMELEN, npiv_wwpn, npiv_wwnn);
sprintf(lport->lport_naa_name, "naa.%016llx", (unsigned long long) 
npiv_wwpn);
 
ret = tcm_qla2xxx_init_lport(lport);
@@ -1921,7 +1896,7 @@ static struct target_core_fabric_ops tcm_qla2xxx_ops = {
 static struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
.get_fabric_name= tcm_qla2xxx_npiv_get_fabric_name,
.get_fabric_proto_ident = tcm_qla2xxx_get_fabric_proto_ident,
-   .tpg_get_wwn= tcm_qla2xxx_npiv_get_fabric_wwn,
+   .tpg_get_wwn= tcm_qla2xxx_get_fabric_wwn,
.tpg_get_tag= tcm_qla2xxx_get_tag,
.tpg_get_default_depth  = tcm_qla2xxx_get_default_depth,
.tpg_get_pr_transport_id= tcm_qla2xxx_get_pr_transport_id,
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.h 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
index a90966d..33aaac8 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.h
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
@@ -4,8 +4,6 @@
 #define TCM_QLA2XXX_VERSION"v0.1"
 /* length of ASCII WWPNs including pad */
 #define TCM_QLA2XXX_NAMELEN32
-/* lenth of ASCII NPIV 'WWPN+WWNN' including pad */
-#define TCM_QLA2XXX_NPIV_NAMELEN 66
 
 #include "qla_target.h"
 
@@ -65,8 +63,6 @@ struct tcm_qla2xxx_lport {
char lport_name[TCM_QLA2XXX_NAMELEN];
/* ASCII formatted naa WWPN for VPD page 83 etc */
char lport_naa_name[TCM_QLA2XXX_NAMELEN];
-   /* ASCII formatted WWPN+WWNN for NPIV FC Target Lport */
-   char lport_npiv_name[TCM_QLA2XXX_NPIV_NAMELEN];
/* map for fc_port pointers in 24-bit FC Port ID space */
struct btree_head32 lport_fcport_map;
/* vmalloc-ed memory for fc_port pointers for 16-bit FC loop ID */
-- 
1.7.10.4

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


[PATCH 2/5] qla2xxx: Check + fail when npiv_vports_inuse exists in shutdown

2014-02-20 Thread Nicholas A. Bellinger
From: Nicholas Bellinger 

This patch adds an check to qlt_stop_phase1() to avoid shutdown
when the base_vha contains a non-zero fc_host->npiv_vports_inuse
count.

This includes holding qla_tgt_mutex in qlt_stop_phase1() between
the fc_host->npiv_vports_inuse check + setting of tgt->tgt_stop to
avoid a possible race between qlt_lport_register() -> tcm_qla2xxx
-> tcm_qla2xxx_lport_register_npiv_cb() calling fc_vport_create().

Cc: Sawan Chandak 
Cc: Quinn Tran 
Cc: Saurav Kashyap 
Cc: Giridhar Malavali 
Signed-off-by: Nicholas Bellinger 
---
 drivers/scsi/qla2xxx/qla_target.c |   23 ---
 drivers/scsi/qla2xxx/qla_target.h |2 +-
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index ea3eaef..f2e1c5a 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -790,17 +790,32 @@ static inline int test_tgt_sess_count(struct qla_tgt *tgt)
 }
 
 /* Called by tcm_qla2xxx configfs code */
-void qlt_stop_phase1(struct qla_tgt *tgt)
+int qlt_stop_phase1(struct qla_tgt *tgt)
 {
struct scsi_qla_host *vha = tgt->vha;
struct qla_hw_data *ha = tgt->ha;
unsigned long flags;
 
+   mutex_lock(&qla_tgt_mutex);
+   if (!vha->fc_vport) {
+   struct Scsi_Host *sh = vha->host;
+   struct fc_host_attrs *fc_host = shost_to_fc_host(sh);
+   bool npiv_vports;
+
+   spin_lock_irqsave(sh->host_lock, flags);
+   npiv_vports = (fc_host->npiv_vports_inuse);
+   spin_unlock_irqrestore(sh->host_lock, flags);
+
+   if (npiv_vports) {
+   mutex_unlock(&qla_tgt_mutex);
+   return -EPERM;
+   }
+   }
if (tgt->tgt_stop || tgt->tgt_stopped) {
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf04e,
"Already in tgt->tgt_stop or tgt_stopped state\n");
-   dump_stack();
-   return;
+   mutex_unlock(&qla_tgt_mutex);
+   return -EPERM;
}
 
ql_dbg(ql_dbg_tgt, vha, 0xe003, "Stopping target for host %ld(%p)\n",
@@ -815,6 +830,7 @@ void qlt_stop_phase1(struct qla_tgt *tgt)
qlt_clear_tgt_db(tgt, true);
spin_unlock_irqrestore(&ha->hardware_lock, flags);
mutex_unlock(&vha->vha_tgt.tgt_mutex);
+   mutex_unlock(&qla_tgt_mutex);
 
flush_delayed_work(&tgt->sess_del_work);
 
@@ -841,6 +857,7 @@ void qlt_stop_phase1(struct qla_tgt *tgt)
 
/* Wait for sessions to clear out (just in case) */
wait_event(tgt->waitQ, test_tgt_sess_count(tgt));
+   return 0;
 }
 EXPORT_SYMBOL(qlt_stop_phase1);
 
diff --git a/drivers/scsi/qla2xxx/qla_target.h 
b/drivers/scsi/qla2xxx/qla_target.h
index 66e755c..ce33d8c 100644
--- a/drivers/scsi/qla2xxx/qla_target.h
+++ b/drivers/scsi/qla2xxx/qla_target.h
@@ -1001,7 +1001,7 @@ extern void qlt_modify_vp_config(struct scsi_qla_host *,
 extern void qlt_probe_one_stage1(struct scsi_qla_host *, struct qla_hw_data *);
 extern int qlt_mem_alloc(struct qla_hw_data *);
 extern void qlt_mem_free(struct qla_hw_data *);
-extern void qlt_stop_phase1(struct qla_tgt *);
+extern int qlt_stop_phase1(struct qla_tgt *);
 extern void qlt_stop_phase2(struct qla_tgt *);
 extern irqreturn_t qla83xx_msix_atio_q(int, void *);
 extern void qlt_83xx_iospace_config(struct qla_hw_data *);
-- 
1.7.10.4

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


Mein Vorschlag

2014-02-20 Thread Peter Wong
ACHTUNG 

Ich habe ein Investment-Portfolio, die Geld in der Bank in China hinterlegt, 
die ich leicht auf Sie übertragen als Begünstigter bringt. Die Transaktion ist 
ohne Risiko, da es strategisch geplant abgeschlossen 
erfolgreich. 

Kontaktieren Sie mich auf meiner E-Mail-Adresse unten für weitere Details. 

Mit freundlichen Grüßen, 

Peter Wong 
E-Mail: ppwon...@aol.jp
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/9] I/O path micro-optimizations and per-command private data support

2014-02-20 Thread Christoph Hellwig
This is a resend of the easily acceptable subset of the previously sent
patches. The first two patches avoid taking the host_lock needlessly for
fast path operations, patches 3 to 5 avoid useless manipulations of the
device reference count, and the remaining ones allow a driver specifying
an extra command size so drivers don't have to allocate memory for driver
specific data additionally, as well as converting virtio-scsi to use this
feature.

Changes from the first version are limited to reordering the patch series,
fixing patch subjects and attribution and adding some boilerplate commands
back.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/9] scsi: do not manipulate device reference counts in scsi_get/put_command

2014-02-20 Thread Christoph Hellwig
Many callers won't need this and we can optimize them away.  In addition
the handling in the __-prefixed variants was inconsistant to start with.

Based on an earlier patch from Bart Van Assche.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/scsi.c |   36 
 drivers/scsi/scsi_error.c   |6 ++
 drivers/scsi/scsi_lib.c |   12 +++-
 drivers/scsi/scsi_tgt_lib.c |3 ++-
 include/scsi/scsi_cmnd.h|3 +--
 5 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index fb86479..843b4f1 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -284,27 +284,19 @@ EXPORT_SYMBOL_GPL(__scsi_get_command);
  */
 struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, gfp_t gfp_mask)
 {
-   struct scsi_cmnd *cmd;
+   struct scsi_cmnd *cmd = __scsi_get_command(dev->host, gfp_mask);
+   unsigned long flags;
 
-   /* Bail if we can't get a reference to the device */
-   if (!get_device(&dev->sdev_gendev))
+   if (unlikely(cmd == NULL))
return NULL;
 
-   cmd = __scsi_get_command(dev->host, gfp_mask);
-
-   if (likely(cmd != NULL)) {
-   unsigned long flags;
-
-   cmd->device = dev;
-   INIT_LIST_HEAD(&cmd->list);
-   INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler);
-   spin_lock_irqsave(&dev->list_lock, flags);
-   list_add_tail(&cmd->list, &dev->cmd_list);
-   spin_unlock_irqrestore(&dev->list_lock, flags);
-   cmd->jiffies_at_alloc = jiffies;
-   } else
-   put_device(&dev->sdev_gendev);
-
+   cmd->device = dev;
+   INIT_LIST_HEAD(&cmd->list);
+   INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler);
+   spin_lock_irqsave(&dev->list_lock, flags);
+   list_add_tail(&cmd->list, &dev->cmd_list);
+   spin_unlock_irqrestore(&dev->list_lock, flags);
+   cmd->jiffies_at_alloc = jiffies;
return cmd;
 }
 EXPORT_SYMBOL(scsi_get_command);
@@ -315,8 +307,7 @@ EXPORT_SYMBOL(scsi_get_command);
  * @cmd: Command to free
  * @dev: parent scsi device
  */
-void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd,
-   struct device *dev)
+void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
 {
unsigned long flags;
 
@@ -331,8 +322,6 @@ void __scsi_put_command(struct Scsi_Host *shost, struct 
scsi_cmnd *cmd,
 
if (likely(cmd != NULL))
scsi_pool_free_command(shost->cmd_pool, cmd);
-
-   put_device(dev);
 }
 EXPORT_SYMBOL(__scsi_put_command);
 
@@ -346,7 +335,6 @@ EXPORT_SYMBOL(__scsi_put_command);
  */
 void scsi_put_command(struct scsi_cmnd *cmd)
 {
-   struct scsi_device *sdev = cmd->device;
unsigned long flags;
 
/* serious error if the command hasn't come from a device list */
@@ -357,7 +345,7 @@ void scsi_put_command(struct scsi_cmnd *cmd)
 
cancel_delayed_work(&cmd->abort_work);
 
-   __scsi_put_command(cmd->device->host, cmd, &sdev->sdev_gendev);
+   __scsi_put_command(cmd->device->host, cmd);
 }
 EXPORT_SYMBOL(scsi_put_command);
 
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 78b004d..771c16b 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -2288,6 +2288,11 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
if (scsi_autopm_get_host(shost) < 0)
return FAILED;
 
+   if (!get_device(&dev->sdev_gendev)) {
+   rtn = FAILED;
+   goto out_put_autopm_host;
+   }
+
scmd = scsi_get_command(dev, GFP_KERNEL);
blk_rq_init(NULL, &req);
scmd->request = &req;
@@ -2345,6 +2350,7 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
scsi_run_host_queues(shost);
 
scsi_next_command(scmd);
+out_put_autopm_host:
scsi_autopm_put_host(shost);
return rtn;
 }
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ad516c0..500178c 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -95,6 +95,7 @@ static void scsi_unprep_request(struct request *req)
req->special = NULL;
 
scsi_put_command(cmd);
+   put_device(&cmd->device->sdev_gendev);
 }
 
 /**
@@ -529,6 +530,7 @@ void scsi_next_command(struct scsi_cmnd *cmd)
get_device(&sdev->sdev_gendev);
 
scsi_put_command(cmd);
+   put_device(&sdev->sdev_gendev);
scsi_run_queue(q);
 
/* ok to remove device now */
@@ -1116,6 +1118,7 @@ err_exit:
scsi_release_buffers(cmd);
cmd->request->special = NULL;
scsi_put_command(cmd);
+   put_device(&cmd->device->sdev_gendev);
return error;
 }
 EXPORT_SYMBOL(scsi_init_io);
@@ -1126,9 +1129,15 @@ static struct scsi_cmnd *scsi_get_cmd_from_req(struct 
scsi_device *sdev,
struct scsi_cmnd *cmd;
 
if (!req->special)

fyi>

2014-02-20 Thread LEWIS BAACH
My name is Lewis Baach, Attorney at law. Sequel to your non response to my 
previous email, I am re-sending this to you again thus; A deceased client of 
mine, that shares the same last name as yours,who died as the result of a 
heart-related condition on January 28th 2009. I have contacted you to assist in 
distributing the money left behind by my client which is lodged in the bank.

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


[PATCH 4/9] scsi: remove a useless get/put_device pair in scsi_request_fn

2014-02-20 Thread Christoph Hellwig
From: Bart Van Assche 

SCSI devices may only be removed by calling scsi_remove_device().
That function must invoke blk_cleanup_queue() before the final put
of sdev->sdev_gendev. Since blk_cleanup_queue() waits for the
block queue to drain and then tears it down, scsi_request_fn cannot
be active anymore after blk_cleanup_queue() has returned and hence
the get_device()/put_device() pair in scsi_request_fn is unnecessary.

Signed-off-by: Bart Van Assche 
Acked-by: Tejun Heo 
Acked-by: Hannes Reinecke 
Reviewed-by: Mike Christie 
---
 drivers/scsi/scsi_lib.c |   14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 500178c..7d35678 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1558,16 +1558,14 @@ static void scsi_softirq_done(struct request *rq)
  * Lock status: IO request lock assumed to be held when called.
  */
 static void scsi_request_fn(struct request_queue *q)
+   __releases(q->queue_lock)
+   __acquires(q->queue_lock)
 {
struct scsi_device *sdev = q->queuedata;
struct Scsi_Host *shost;
struct scsi_cmnd *cmd;
struct request *req;
 
-   if(!get_device(&sdev->sdev_gendev))
-   /* We must be tearing the block queue down already */
-   return;
-
/*
 * To start with, we keep looping until the queue is empty, or until
 * the host is no longer able to accept any more requests.
@@ -1656,7 +1654,7 @@ static void scsi_request_fn(struct request_queue *q)
goto out_delay;
}
 
-   goto out;
+   return;
 
  not_ready:
spin_unlock_irq(shost->host_lock);
@@ -1675,12 +1673,6 @@ static void scsi_request_fn(struct request_queue *q)
 out_delay:
if (sdev->device_busy == 0)
blk_delay_queue(q, SCSI_QUEUE_DELAY);
-out:
-   /* must be careful here...if we trigger the ->remove() function
-* we cannot be holding the q lock */
-   spin_unlock_irq(q->queue_lock);
-   put_device(&sdev->sdev_gendev);
-   spin_lock_irq(q->queue_lock);
 }
 
 u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)
-- 
1.7.10.4


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


[PATCH 2/9] scsi: avoid taking host_lock in scsi_run_queue unless nessecary

2014-02-20 Thread Christoph Hellwig
If we don't have starved devices we don't need to take the host lock
to iterate over them.  Also split the function up to be more clear.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/scsi_lib.c |   43 ---
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 7bd7f0d..ad516c0 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -385,29 +385,12 @@ static inline int scsi_host_is_busy(struct Scsi_Host 
*shost)
return 0;
 }
 
-/*
- * Function:   scsi_run_queue()
- *
- * Purpose:Select a proper request queue to serve next
- *
- * Arguments:  q   - last request's queue
- *
- * Returns: Nothing
- *
- * Notes:  The previous command was completely finished, start
- * a new one if possible.
- */
-static void scsi_run_queue(struct request_queue *q)
+static void scsi_starved_list_run(struct Scsi_Host *shost)
 {
-   struct scsi_device *sdev = q->queuedata;
-   struct Scsi_Host *shost;
LIST_HEAD(starved_list);
+   struct scsi_device *sdev;
unsigned long flags;
 
-   shost = sdev->host;
-   if (scsi_target(sdev)->single_lun)
-   scsi_single_lun_run(sdev);
-
spin_lock_irqsave(shost->host_lock, flags);
list_splice_init(&shost->starved_list, &starved_list);
 
@@ -459,6 +442,28 @@ static void scsi_run_queue(struct request_queue *q)
/* put any unprocessed entries back */
list_splice(&starved_list, &shost->starved_list);
spin_unlock_irqrestore(shost->host_lock, flags);
+}
+
+/*
+ * Function:   scsi_run_queue()
+ *
+ * Purpose:Select a proper request queue to serve next
+ *
+ * Arguments:  q   - last request's queue
+ *
+ * Returns: Nothing
+ *
+ * Notes:  The previous command was completely finished, start
+ * a new one if possible.
+ */
+static void scsi_run_queue(struct request_queue *q)
+{
+   struct scsi_device *sdev = q->queuedata;
+
+   if (scsi_target(sdev)->single_lun)
+   scsi_single_lun_run(sdev);
+   if (!list_empty(&sdev->host->starved_list))
+   scsi_starved_list_run(sdev->host);
 
blk_run_queue(q);
 }
-- 
1.7.10.4


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


[PATCH 7/9] megaraid: simplify internal command handling

2014-02-20 Thread Christoph Hellwig
We don't use the passed in scsi command for anything, so just add a adapter-
wide internal status to go along with the internal scb that is used unter
int_mtx to pass back the return value and get rid of all the complexities
and abuse of the scsi_cmnd structure.

This gets rid of the only user of scsi_allocate_command/scsi_free_command,
which can now be removed.

Signed-off-by: Christoph Hellwig 
Cc: sumit.sax...@lsi.com
Cc: kashyap.de...@lsi.com
Cc: megaraidli...@lsi.com
---
 drivers/scsi/megaraid.c  |  120 --
 drivers/scsi/megaraid.h  |3 +-
 drivers/scsi/scsi.c  |   56 --
 include/scsi/scsi_cmnd.h |3 --
 4 files changed, 32 insertions(+), 150 deletions(-)

diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 816db12..8bca30f 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -531,13 +531,6 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int 
*busy)
int target = 0;
int ldrv_num = 0;   /* logical drive number */
 
-
-   /*
-* filter the internal and ioctl commands
-*/
-   if((cmd->cmnd[0] == MEGA_INTERNAL_CMD))
-   return (scb_t *)cmd->host_scribble;
-
/*
 * We know what channels our logical drives are on - mega_find_card()
 */
@@ -1439,19 +1432,22 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int 
nstatus, int status)
 
cmdid = completed[i];
 
-   if( cmdid == CMDID_INT_CMDS ) { /* internal command */
+   /*
+* Only free SCBs for the commands coming down from the
+* mid-layer, not for which were issued internally
+*
+* For internal command, restore the status returned by the
+* firmware so that user can interpret it.
+*/
+   if (cmdid == CMDID_INT_CMDS) {
scb = &adapter->int_scb;
-   cmd = scb->cmd;
-   mbox = (mbox_t *)scb->raw_mbox;
 
-   /*
-* Internal command interface do not fire the extended
-* passthru or 64-bit passthru
-*/
-   pthru = scb->pthru;
+   list_del_init(&scb->list);
+   scb->state = SCB_FREE;
 
-   }
-   else {
+   adapter->int_status = status;
+   complete(&adapter->int_waitq);
+   } else {
scb = &adapter->scb_list[cmdid];
 
/*
@@ -1640,25 +1636,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int 
nstatus, int status)
cmd->result |= (DID_BAD_TARGET << 16)|status;
}
 
-   /*
-* Only free SCBs for the commands coming down from the
-* mid-layer, not for which were issued internally
-*
-* For internal command, restore the status returned by the
-* firmware so that user can interpret it.
-*/
-   if( cmdid == CMDID_INT_CMDS ) { /* internal command */
-   cmd->result = status;
-
-   /*
-* Remove the internal command from the pending list
-*/
-   list_del_init(&scb->list);
-   scb->state = SCB_FREE;
-   }
-   else {
-   mega_free_scb(adapter, scb);
-   }
+   mega_free_scb(adapter, scb);
 
/* Add Scsi_Command to end of completed queue */
list_add_tail(SCSI_LIST(cmd), &adapter->completed_list);
@@ -4133,23 +4111,15 @@ mega_internal_dev_inquiry(adapter_t *adapter, u8 ch, u8 
tgt,
  * The last argument is the address of the passthru structure if the command
  * to be fired is a passthru command
  *
- * lockscope specifies whether the caller has already acquired the lock. Of
- * course, the caller must know which lock we are talking about.
- *
  * Note: parameter 'pthru' is null for non-passthru commands.
  */
 static int
 mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
 {
-   Scsi_Cmnd   *scmd;
-   struct  scsi_device *sdev;
+   unsigned long flags;
scb_t   *scb;
int rval;
 
-   scmd = scsi_allocate_command(GFP_KERNEL);
-   if (!scmd)
-   return -ENOMEM;
-
/*
 * The internal commands share one command id and hence are
 * serialized. This is so because we want to reserve maximum number of
@@ -4160,73 +4130,45 @@ mega_internal_command(adapter_t *adapter, megacmd_t 
*mc, mega_passthru *pthru)
scb = &adapter->int_scb;
memset(scb, 0, sizeof(scb_t));
 
-   sdev = kzalloc(sizeof(struct scsi_device

[PATCH 1/9] scsi: avoid useless free_list lock roundtrips

2014-02-20 Thread Christoph Hellwig
Avoid hitting the host-wide free_list lock unless we need to put a command
back onto the freelist.

Signed-off-by: Christoph Hellwig 
Acked-by: Hannes Reinecke 
---
 drivers/scsi/scsi.c |   11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index d8afec8..fb86479 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -320,13 +320,14 @@ void __scsi_put_command(struct Scsi_Host *shost, struct 
scsi_cmnd *cmd,
 {
unsigned long flags;
 
-   /* changing locks here, don't need to restore the irq state */
-   spin_lock_irqsave(&shost->free_list_lock, flags);
if (unlikely(list_empty(&shost->free_list))) {
-   list_add(&cmd->list, &shost->free_list);
-   cmd = NULL;
+   spin_lock_irqsave(&shost->free_list_lock, flags);
+   if (list_empty(&shost->free_list)) {
+   list_add(&cmd->list, &shost->free_list);
+   cmd = NULL;
+   }
+   spin_unlock_irqrestore(&shost->free_list_lock, flags);
}
-   spin_unlock_irqrestore(&shost->free_list_lock, flags);
 
if (likely(cmd != NULL))
scsi_pool_free_command(shost->cmd_pool, cmd);
-- 
1.7.10.4


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


[PATCH 6/9] scsi: remove a useless get/put_device pair in scsi_requeue_command

2014-02-20 Thread Christoph Hellwig
Avoid a spurious device get/put pair by cleaning up scsi_requeue_command
and folding scsi_unprep_request into it.

Signed-off-by: Christoph Hellwig 
Acked-by: Hannes Reinecke 
---
 drivers/scsi/scsi_lib.c |   35 +++
 1 file changed, 3 insertions(+), 32 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 91ca414..9350691 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -75,29 +75,6 @@ struct kmem_cache *scsi_sdb_cache;
  */
 #define SCSI_QUEUE_DELAY   3
 
-/*
- * Function:   scsi_unprep_request()
- *
- * Purpose:Remove all preparation done for a request, including its
- * associated scsi_cmnd, so that it can be requeued.
- *
- * Arguments:  req - request to unprepare
- *
- * Lock status:Assumed that no locks are held upon entry.
- *
- * Returns:Nothing.
- */
-static void scsi_unprep_request(struct request *req)
-{
-   struct scsi_cmnd *cmd = req->special;
-
-   blk_unprep_request(req);
-   req->special = NULL;
-
-   scsi_put_command(cmd);
-   put_device(&cmd->device->sdev_gendev);
-}
-
 /**
  * __scsi_queue_insert - private queue insertion
  * @cmd: The SCSI command being requeued
@@ -503,16 +480,10 @@ static void scsi_requeue_command(struct request_queue *q, 
struct scsi_cmnd *cmd)
struct request *req = cmd->request;
unsigned long flags;
 
-   /*
-* We need to hold a reference on the device to avoid the queue being
-* killed after the unlock and before scsi_run_queue is invoked which
-* may happen because scsi_unprep_request() puts the command which
-* releases its reference on the device.
-*/
-   get_device(&sdev->sdev_gendev);
-
spin_lock_irqsave(q->queue_lock, flags);
-   scsi_unprep_request(req);
+   blk_unprep_request(req);
+   req->special = NULL;
+   scsi_put_command(cmd);
blk_requeue_request(q, req);
spin_unlock_irqrestore(q->queue_lock, flags);
 
-- 
1.7.10.4


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


[PATCH 8/9] scsi: simplify command allocation and freeing a bit

2014-02-20 Thread Christoph Hellwig
Just have one level of alloc/free functions that take a host instead
of two levels for the allocation and different calling conventions
for the free.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Paolo Bonzini 
---
 drivers/scsi/scsi.c |   67 +++
 1 file changed, 25 insertions(+), 42 deletions(-)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index a1ac75d..a94a486 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -161,47 +161,20 @@ static struct scsi_host_cmd_pool scsi_cmd_dma_pool = {
 static DEFINE_MUTEX(host_cmd_pool_mutex);
 
 /**
- * scsi_pool_alloc_command - internal function to get a fully allocated command
- * @pool:  slab pool to allocate the command from
- * @gfp_mask:  mask for the allocation
- *
- * Returns a fully allocated command (with the allied sense buffer) or
- * NULL on failure
- */
-static struct scsi_cmnd *
-scsi_pool_alloc_command(struct scsi_host_cmd_pool *pool, gfp_t gfp_mask)
-{
-   struct scsi_cmnd *cmd;
-
-   cmd = kmem_cache_zalloc(pool->cmd_slab, gfp_mask | pool->gfp_mask);
-   if (!cmd)
-   return NULL;
-
-   cmd->sense_buffer = kmem_cache_alloc(pool->sense_slab,
-gfp_mask | pool->gfp_mask);
-   if (!cmd->sense_buffer) {
-   kmem_cache_free(pool->cmd_slab, cmd);
-   return NULL;
-   }
-
-   return cmd;
-}
-
-/**
- * scsi_pool_free_command - internal function to release a command
- * @pool:  slab pool to allocate the command from
+ * scsi_host_free_command - internal function to release a command
+ * @host:  host to free the command for
  * @cmd:   command to release
  *
  * the command must previously have been allocated by
- * scsi_pool_alloc_command.
+ * scsi_host_alloc_command.
  */
 static void
-scsi_pool_free_command(struct scsi_host_cmd_pool *pool,
-struct scsi_cmnd *cmd)
+scsi_host_free_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
 {
+   struct scsi_host_cmd_pool *pool = shost->cmd_pool;
+
if (cmd->prot_sdb)
kmem_cache_free(scsi_sdb_cache, cmd->prot_sdb);
-
kmem_cache_free(pool->sense_slab, cmd->sense_buffer);
kmem_cache_free(pool->cmd_slab, cmd);
 }
@@ -217,22 +190,32 @@ scsi_pool_free_command(struct scsi_host_cmd_pool *pool,
 static struct scsi_cmnd *
 scsi_host_alloc_command(struct Scsi_Host *shost, gfp_t gfp_mask)
 {
+   struct scsi_host_cmd_pool *pool = shost->cmd_pool;
struct scsi_cmnd *cmd;
 
-   cmd = scsi_pool_alloc_command(shost->cmd_pool, gfp_mask);
+   cmd = kmem_cache_zalloc(pool->cmd_slab, gfp_mask | pool->gfp_mask);
if (!cmd)
-   return NULL;
+   goto fail;
+
+   cmd->sense_buffer = kmem_cache_alloc(pool->sense_slab,
+gfp_mask | pool->gfp_mask);
+   if (!cmd->sense_buffer)
+   goto fail_free_cmd;
 
if (scsi_host_get_prot(shost) >= SHOST_DIX_TYPE0_PROTECTION) {
cmd->prot_sdb = kmem_cache_zalloc(scsi_sdb_cache, gfp_mask);
-
-   if (!cmd->prot_sdb) {
-   scsi_pool_free_command(shost->cmd_pool, cmd);
-   return NULL;
-   }
+   if (!cmd->prot_sdb)
+   goto fail_free_sense;
}
 
return cmd;
+
+fail_free_sense:
+   kmem_cache_free(pool->sense_slab, cmd->sense_buffer);
+fail_free_cmd:
+   kmem_cache_free(pool->cmd_slab, cmd);
+fail:
+   return NULL;
 }
 
 /**
@@ -321,7 +304,7 @@ void __scsi_put_command(struct Scsi_Host *shost, struct 
scsi_cmnd *cmd)
}
 
if (likely(cmd != NULL))
-   scsi_pool_free_command(shost->cmd_pool, cmd);
+   scsi_host_free_command(shost, cmd);
 }
 EXPORT_SYMBOL(__scsi_put_command);
 
@@ -457,7 +440,7 @@ void scsi_destroy_command_freelist(struct Scsi_Host *shost)
 
cmd = list_entry(shost->free_list.next, struct scsi_cmnd, list);
list_del_init(&cmd->list);
-   scsi_pool_free_command(shost->cmd_pool, cmd);
+   scsi_host_free_command(shost, cmd);
}
shost->cmd_pool = NULL;
scsi_put_host_cmd_pool(shost->unchecked_isa_dma ? GFP_DMA : GFP_KERNEL);
-- 
1.7.10.4


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


[PATCH 5/9] scsi: remove a useless get/put_device pair in scsi_next_command

2014-02-20 Thread Christoph Hellwig
From: Bart Van Assche 

Eliminate a get_device() / put_device() pair from scsi_next_command().
Both are atomic operations hence removing these slightly improves
performance.

[hch: slight changes due to different context]

Signed-off-by: Bart Van Assche 
Acked-by: Hannes Reinecke 
Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/scsi_lib.c |5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 7d35678..91ca414 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -526,14 +526,9 @@ void scsi_next_command(struct scsi_cmnd *cmd)
struct scsi_device *sdev = cmd->device;
struct request_queue *q = sdev->request_queue;
 
-   /* need to hold a reference on the device before we let go of the cmd */
-   get_device(&sdev->sdev_gendev);
-
scsi_put_command(cmd);
-   put_device(&sdev->sdev_gendev);
scsi_run_queue(q);
 
-   /* ok to remove device now */
put_device(&sdev->sdev_gendev);
 }
 
-- 
1.7.10.4


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


[PATCH 9/9] scsi: add support for per-host cmd pools

2014-02-20 Thread Christoph Hellwig
This allows drivers to specify the size of their per-command private
data in the host template and then get extra memory allocated for
each command instead of needing another allocation in ->queuecommand.

With the current SCSI code that already does multiple allocations for
each command this probably doesn't make a big performance impact, but
it allows to clean up the drivers, and prepare them for using the
blk-mq infrastructure where the common allocation will make a difference.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Paolo Bonzini 
---
 drivers/scsi/scsi.c  |   96 +-
 include/scsi/scsi_host.h |7 
 2 files changed, 84 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index a94a486..a45f01c 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -332,46 +332,103 @@ void scsi_put_command(struct scsi_cmnd *cmd)
 }
 EXPORT_SYMBOL(scsi_put_command);
 
-static struct scsi_host_cmd_pool *scsi_get_host_cmd_pool(gfp_t gfp_mask)
+static struct scsi_host_cmd_pool *
+scsi_find_host_cmd_pool(struct Scsi_Host *shost)
 {
+   if (shost->hostt->cmd_size)
+   return shost->hostt->cmd_pool;
+   if (shost->unchecked_isa_dma)
+   return &scsi_cmd_dma_pool;
+   return &scsi_cmd_pool;
+}
+
+static void
+scsi_free_host_cmd_pool(struct scsi_host_cmd_pool *pool)
+{
+   kfree(pool->sense_name);
+   kfree(pool->cmd_name);
+   kfree(pool);
+}
+
+static struct scsi_host_cmd_pool *
+scsi_alloc_host_cmd_pool(struct Scsi_Host *shost)
+{
+   struct scsi_host_template *hostt = shost->hostt;
+   struct scsi_host_cmd_pool *pool;
+
+   pool = kzalloc(sizeof(*pool), GFP_KERNEL);
+   if (!pool)
+   return NULL;
+
+   pool->cmd_name = kasprintf(GFP_KERNEL, "%s_cmd", hostt->name);
+   pool->sense_name = kasprintf(GFP_KERNEL, "%s_sense", hostt->name);
+   if (!pool->cmd_name || !pool->sense_name) {
+   scsi_free_host_cmd_pool(pool);
+   return NULL;
+   }
+
+   pool->slab_flags = SLAB_HWCACHE_ALIGN;
+   if (shost->unchecked_isa_dma) {
+   pool->slab_flags |= SLAB_CACHE_DMA;
+   pool->gfp_mask = __GFP_DMA;
+   }
+   return pool;
+}
+
+static struct scsi_host_cmd_pool *
+scsi_get_host_cmd_pool(struct Scsi_Host *shost)
+{
+   struct scsi_host_template *hostt = shost->hostt;
struct scsi_host_cmd_pool *retval = NULL, *pool;
+   size_t cmd_size = sizeof(struct scsi_cmnd) + hostt->cmd_size;
+
/*
 * Select a command slab for this host and create it if not
 * yet existent.
 */
mutex_lock(&host_cmd_pool_mutex);
-   pool = (gfp_mask & __GFP_DMA) ? &scsi_cmd_dma_pool :
-   &scsi_cmd_pool;
+   pool = scsi_find_host_cmd_pool(shost);
+   if (!pool) {
+   pool = scsi_alloc_host_cmd_pool(shost);
+   if (!pool)
+   goto out;
+   }
+
if (!pool->users) {
-   pool->cmd_slab = kmem_cache_create(pool->cmd_name,
-  sizeof(struct scsi_cmnd), 0,
+   pool->cmd_slab = kmem_cache_create(pool->cmd_name, cmd_size, 0,
   pool->slab_flags, NULL);
if (!pool->cmd_slab)
-   goto fail;
+   goto out_free_pool;
 
pool->sense_slab = kmem_cache_create(pool->sense_name,
 SCSI_SENSE_BUFFERSIZE, 0,
 pool->slab_flags, NULL);
-   if (!pool->sense_slab) {
-   kmem_cache_destroy(pool->cmd_slab);
-   goto fail;
-   }
+   if (!pool->sense_slab)
+   goto out_free_slab;
}
 
pool->users++;
retval = pool;
- fail:
+out:
mutex_unlock(&host_cmd_pool_mutex);
return retval;
+
+out_free_slab:
+   kmem_cache_destroy(pool->cmd_slab);
+out_free_pool:
+   if (hostt->cmd_size)
+   scsi_free_host_cmd_pool(pool);
+   goto out;
 }
 
-static void scsi_put_host_cmd_pool(gfp_t gfp_mask)
+static void scsi_put_host_cmd_pool(struct Scsi_Host *shost)
 {
+   struct scsi_host_template *hostt = shost->hostt;
struct scsi_host_cmd_pool *pool;
 
mutex_lock(&host_cmd_pool_mutex);
-   pool = (gfp_mask & __GFP_DMA) ? &scsi_cmd_dma_pool :
-   &scsi_cmd_pool;
+   pool = scsi_find_host_cmd_pool(shost);
+
/*
 * This may happen if a driver has a mismatched get and put
 * of the command pool; the driver should be implicated in
@@ -382,6 +439,8 @@ static void scsi_put_host_cmd_pool(gfp_t gfp_mask)
if (!--pool->users) {
kmem_cache_destroy(pool->cmd_slab);
kmem_cache_destroy(pool->sense_slab);
+  

[PATCH 0/3] next round of blk-mq updates

2014-02-20 Thread Christoph Hellwig
A couple more blkmq updates: a trivial cleanup, a consolidation of two very
similar functions into one, and support for partial request completions,
a feature needed by the work in progress scsi blk-mq support.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] blk-mq: support partial I/O completions

2014-02-20 Thread Christoph Hellwig
Add a new blk_mq_end_io_partial function to partially complete requests
as needed by the SCSI layer.  We do this by reusing blk_update_request
to advance the bio instead of having a simplified version of it in
the blk-mq code.

Signed-off-by: Christoph Hellwig 
---
 block/blk-mq.c |   37 +
 include/linux/blk-mq.h |8 +++-
 2 files changed, 12 insertions(+), 33 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 2af8405..1b8b50d 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -283,38 +283,10 @@ void blk_mq_free_request(struct request *rq)
__blk_mq_free_request(hctx, ctx, rq);
 }
 
-static void blk_mq_bio_endio(struct request *rq, struct bio *bio, int error)
+bool blk_mq_end_io_partial(struct request *rq, int error, unsigned int 
nr_bytes)
 {
-   if (error)
-   clear_bit(BIO_UPTODATE, &bio->bi_flags);
-   else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
-   error = -EIO;
-
-   if (unlikely(rq->cmd_flags & REQ_QUIET))
-   set_bit(BIO_QUIET, &bio->bi_flags);
-
-   /* don't actually finish bio if it's part of flush sequence */
-   if (!(rq->cmd_flags & REQ_FLUSH_SEQ))
-   bio_endio(bio, error);
-}
-
-void blk_mq_end_io(struct request *rq, int error)
-{
-   struct bio *bio = rq->bio;
-   unsigned int bytes = 0;
-
-   trace_block_rq_complete(rq->q, rq);
-
-   while (bio) {
-   struct bio *next = bio->bi_next;
-
-   bio->bi_next = NULL;
-   bytes += bio->bi_iter.bi_size;
-   blk_mq_bio_endio(rq, bio, error);
-   bio = next;
-   }
-
-   blk_account_io_completion(rq, bytes);
+   if (blk_update_request(rq, error, blk_rq_bytes(rq)))
+   return true;
 
blk_account_io_done(rq);
 
@@ -322,8 +294,9 @@ void blk_mq_end_io(struct request *rq, int error)
rq->end_io(rq, error);
else
blk_mq_free_request(rq);
+   return false;
 }
-EXPORT_SYMBOL(blk_mq_end_io);
+EXPORT_SYMBOL(blk_mq_end_io_partial);
 
 static void __blk_mq_complete_request_remote(void *data)
 {
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index ff28fe3..2ff2e8d 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -133,7 +133,13 @@ struct blk_mq_hw_ctx *blk_mq_map_queue(struct 
request_queue *, const int ctx_ind
 struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_reg *, 
unsigned int);
 void blk_mq_free_single_hw_queue(struct blk_mq_hw_ctx *, unsigned int);
 
-void blk_mq_end_io(struct request *rq, int error);
+bool blk_mq_end_io_partial(struct request *rq, int error,
+   unsigned int nr_bytes);
+static inline void blk_mq_end_io(struct request *rq, int error)
+{
+   bool done = !blk_mq_end_io_partial(rq, error, blk_rq_bytes(rq));
+   BUG_ON(!done);
+}
 
 void blk_mq_complete_request(struct request *rq);
 
-- 
1.7.10.4


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


[PATCH 2/3] blk-mq: merge blk_mq_insert_request and blk_mq_run_request

2014-02-20 Thread Christoph Hellwig
It's almost identical to blk_mq_insert_request, so fold the two into one
slightly more generic function by making the flush special case a bit
smarted.

Signed-off-by: Christoph Hellwig 
---
 block/blk-exec.c   |2 +-
 block/blk-flush.c  |4 ++--
 block/blk-mq.c |   53 +---
 block/blk-mq.h |1 -
 include/linux/blk-mq.h |3 +--
 5 files changed, 14 insertions(+), 49 deletions(-)

diff --git a/block/blk-exec.c b/block/blk-exec.c
index c68613b..dbf4502 100644
--- a/block/blk-exec.c
+++ b/block/blk-exec.c
@@ -65,7 +65,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct 
gendisk *bd_disk,
 * be resued after dying flag is set
 */
if (q->mq_ops) {
-   blk_mq_insert_request(q, rq, at_head, true);
+   blk_mq_insert_request(rq, at_head, true, false);
return;
}
 
diff --git a/block/blk-flush.c b/block/blk-flush.c
index 66e2b69..f598f79 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -137,7 +137,7 @@ static void mq_flush_run(struct work_struct *work)
rq = container_of(work, struct request, mq_flush_work);
 
memset(&rq->csd, 0, sizeof(rq->csd));
-   blk_mq_run_request(rq, true, false);
+   blk_mq_insert_request(rq, false, true, false);
 }
 
 static bool blk_flush_queue_rq(struct request *rq)
@@ -411,7 +411,7 @@ void blk_insert_flush(struct request *rq)
if ((policy & REQ_FSEQ_DATA) &&
!(policy & (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH))) {
if (q->mq_ops) {
-   blk_mq_run_request(rq, false, true);
+   blk_mq_insert_request(rq, false, false, true);
} else
list_add_tail(&rq->queuelist, &q->queue_head);
return;
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 1e585e3..2af8405 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -724,61 +724,28 @@ static void __blk_mq_insert_request(struct blk_mq_hw_ctx 
*hctx,
blk_mq_add_timer(rq);
 }
 
-void blk_mq_insert_request(struct request_queue *q, struct request *rq,
-  bool at_head, bool run_queue)
+void blk_mq_insert_request(struct request *rq, bool at_head, bool run_queue,
+   bool async)
 {
+   struct request_queue *q = rq->q;
struct blk_mq_hw_ctx *hctx;
-   struct blk_mq_ctx *ctx, *current_ctx;
+   struct blk_mq_ctx *ctx = rq->mq_ctx, *current_ctx;
+
+   current_ctx = blk_mq_get_ctx(q);
+   if (!cpu_online(ctx->cpu))
+   rq->mq_ctx = ctx = current_ctx;
 
-   ctx = rq->mq_ctx;
hctx = q->mq_ops->map_queue(q, ctx->cpu);
 
-   if (rq->cmd_flags & (REQ_FLUSH | REQ_FUA)) {
+   if (rq->cmd_flags & (REQ_FLUSH | REQ_FUA) &&
+   !(rq->cmd_flags & (REQ_FLUSH_SEQ))) {
blk_insert_flush(rq);
} else {
-   current_ctx = blk_mq_get_ctx(q);
-
-   if (!cpu_online(ctx->cpu)) {
-   ctx = current_ctx;
-   hctx = q->mq_ops->map_queue(q, ctx->cpu);
-   rq->mq_ctx = ctx;
-   }
spin_lock(&ctx->lock);
__blk_mq_insert_request(hctx, rq, at_head);
spin_unlock(&ctx->lock);
-
-   blk_mq_put_ctx(current_ctx);
}
 
-   if (run_queue)
-   __blk_mq_run_hw_queue(hctx);
-}
-EXPORT_SYMBOL(blk_mq_insert_request);
-
-/*
- * This is a special version of blk_mq_insert_request to bypass FLUSH request
- * check. Should only be used internally.
- */
-void blk_mq_run_request(struct request *rq, bool run_queue, bool async)
-{
-   struct request_queue *q = rq->q;
-   struct blk_mq_hw_ctx *hctx;
-   struct blk_mq_ctx *ctx, *current_ctx;
-
-   current_ctx = blk_mq_get_ctx(q);
-
-   ctx = rq->mq_ctx;
-   if (!cpu_online(ctx->cpu)) {
-   ctx = current_ctx;
-   rq->mq_ctx = ctx;
-   }
-   hctx = q->mq_ops->map_queue(q, ctx->cpu);
-
-   /* ctx->cpu might be offline */
-   spin_lock(&ctx->lock);
-   __blk_mq_insert_request(hctx, rq, false);
-   spin_unlock(&ctx->lock);
-
blk_mq_put_ctx(current_ctx);
 
if (run_queue)
diff --git a/block/blk-mq.h b/block/blk-mq.h
index ed0035c..72beba1 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -23,7 +23,6 @@ struct blk_mq_ctx {
 };
 
 void __blk_mq_complete_request(struct request *rq);
-void blk_mq_run_request(struct request *rq, bool run_queue, bool async);
 void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async);
 void blk_mq_init_flush(struct request_queue *q);
 void blk_mq_drain_queue(struct request_queue *q);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 18ba8a6..ff28fe3 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -121,8 +121,7 @@ void blk_mq_init_commands(struct request_queue *, void 
(*init)(void *data, struc
 
 

[PATCH 1/3] blk-mq: remove blk_mq_alloc_rq

2014-02-20 Thread Christoph Hellwig
There's only one caller, which is a straight wrapper and fits the naming
scheme of the related functions a lot better.

Signed-off-by: Christoph Hellwig 
---
 block/blk-mq.c |   10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 1fa9dd1..1e585e3 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -73,8 +73,8 @@ static void blk_mq_hctx_mark_pending(struct blk_mq_hw_ctx 
*hctx,
set_bit(ctx->index_hw, hctx->ctx_map);
 }
 
-static struct request *blk_mq_alloc_rq(struct blk_mq_hw_ctx *hctx, gfp_t gfp,
-  bool reserved)
+static struct request *__blk_mq_alloc_request(struct blk_mq_hw_ctx *hctx,
+ gfp_t gfp, bool reserved)
 {
struct request *rq;
unsigned int tag;
@@ -193,12 +193,6 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, 
struct blk_mq_ctx *ctx,
ctx->rq_dispatched[rw_is_sync(rw_flags)]++;
 }
 
-static struct request *__blk_mq_alloc_request(struct blk_mq_hw_ctx *hctx,
- gfp_t gfp, bool reserved)
-{
-   return blk_mq_alloc_rq(hctx, gfp, reserved);
-}
-
 static struct request *blk_mq_alloc_request_pinned(struct request_queue *q,
   int rw, gfp_t gfp,
   bool reserved)
-- 
1.7.10.4


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


[PATCH] scsi/sd.c: fix spun up and not ready messages to mention which disk

2014-02-20 Thread Stewart Smith
Previously, many years ago, this was done in series which was fine,
but things moved to be done in parallel and with many disks in a system
it can be hard to see which disk spun up and which one didn't as the
printk messages were all mixed together.

Signed-off-by: Stewart Smith 
---
 drivers/scsi/sd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 470954a..1436c85 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1838,7 +1838,6 @@ sd_spinup_disk(struct scsi_disk *sdkp)
}
/* Wait 1 second for next try */
msleep(1000);
-   printk(".");
 
/*
 * Wait for USB flash devices with slow firmware.
@@ -1868,9 +1867,9 @@ sd_spinup_disk(struct scsi_disk *sdkp)
 
if (spintime) {
if (scsi_status_is_good(the_result))
-   printk("ready\n");
+   sd_printk(KERN_NOTICE, sdkp, "ready\n");
else
-   printk("not responding...\n");
+   sd_printk(KERN_NOTICE, sdkp, "not responding...\n");
}
 }
 
-- 
1.8.5.3

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


[PATCH] [SCSI] lpfc 8.3.43: use NULL instead of 0 for pointer

2014-02-20 Thread Daeseok Youn
>From 9e7478f6e953fac5b2bef0f5abe76fe8dc9e59d1 Mon Sep 17 00:00:00 2001
From: Daeseok Youn 
Date: Fri, 21 Feb 2014 09:03:32 +0900
Subject: [PATCH] [SCSI] lpfc 8.3.43: use NULL instead of 0 for pointer

sparse says:
drivers/scsi/lpfc/lpfc_sli.c:16547:37: warning:
 Using plain integer as NULL pointer

Signed-off-by: Daeseok Youn 
---
 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 8f580fd..a218ecd 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -16544,7 +16544,7 @@ lpfc_drain_txq(struct lpfc_hba *phba)
 {
LIST_HEAD(completions);
struct lpfc_sli_ring *pring = &phba->sli.ring[LPFC_ELS_RING];
-   struct lpfc_iocbq *piocbq = 0;
+   struct lpfc_iocbq *piocbq = NULL;
unsigned long iflags = 0;
char *fail_msg = NULL;
struct lpfc_sglq *sglq;
-- 
1.7.9.5

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


[PATCH] [SCSI] be2iscsi: make beiscsi_process_mcc() as static

2014-02-20 Thread Daeseok Youn
>From 137a2f619f1fa93fc497d891954d83c6cb307d11 Mon Sep 17 00:00:00 2001
From: Daeseok Youn 
Date: Fri, 21 Feb 2014 08:43:56 +0900
Subject: [PATCH] [SCSI] be2iscsi: make beiscsi_process_mcc() as static

beiscsi_process_mcc() is only referenced in this file.

Signed-off-by: Daeseok Youn 
---
 drivers/scsi/be2iscsi/be_cmds.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 1ec9793..d4fff8a 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -398,7 +398,7 @@ static void beiscsi_cq_notify(struct beiscsi_hba *phba, u16 
qid, bool arm,
 }
 
 
-int beiscsi_process_mcc(struct beiscsi_hba *phba)
+static int beiscsi_process_mcc(struct beiscsi_hba *phba)
 {
struct be_mcc_compl *compl;
int num = 0, status = 0;
-- 
1.7.9.5


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


[PATCH] [SCSI] be2iscsi: use NULL instead of 0 for pointer

2014-02-20 Thread Daeseok Youn
>From b483ef302f7d77c586949ae170754d589e8a4935 Mon Sep 17 00:00:00 2001
From: Daeseok Youn 
Date: Fri, 21 Feb 2014 08:39:08 +0900
Subject: [PATCH] [SCSI] be2iscsi: use NULL instead of 0 for pointer

sparse says:

drivers/scsi/be2iscsi/be_cmds.c:27:32: warning:
 Using plain integer as NULL pointer
drivers/scsi/be2iscsi/be_cmds.c:28:34: warning:
 Using plain integer as NULL pointer
drivers/scsi/be2iscsi/be_cmds.c:29:34: warning:
 Using plain integer as NULL pointer

Signed-off-by: Daeseok Youn 
---
 drivers/scsi/be2iscsi/be_cmds.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_cmds.c b/drivers/scsi/be2iscsi/be_cmds.c
index 3338391..1ec9793 100644
--- a/drivers/scsi/be2iscsi/be_cmds.c
+++ b/drivers/scsi/be2iscsi/be_cmds.c
@@ -24,9 +24,9 @@
 int beiscsi_pci_soft_reset(struct beiscsi_hba *phba)
 {
u32 sreset;
-   u8 *pci_reset_offset = 0;
-   u8 *pci_online0_offset = 0;
-   u8 *pci_online1_offset = 0;
+   u8 *pci_reset_offset = NULL;
+   u8 *pci_online0_offset = NULL;
+   u8 *pci_online1_offset = NULL;
u32 pconline0 = 0;
u32 pconline1 = 0;
u32 i;
-- 
1.7.9.5


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


Re: [PATCH 0/5] qla2xxx: NPIV target mode fixes for v3.14-rc

2014-02-20 Thread Quinn Tran
Nicholas,

Will do. Thanks.


Regards,
Quinn Tran




On 2/20/14 1:03 PM, "Nicholas A. Bellinger"  wrote:

>From: Nicholas Bellinger 
>
>Hi Sawan, Quinn, & Co.
>
>The following series addresses a number of NPIV related bugs specific
>to v3.14-rc code, mostly involving the underlying configfs dependency
>of base_vha / base_tpg to not be removed while there are active NPIV
>ports.
>
>Patch #1 fixes a race between the qlt_lport_register() callback and
>subsequent shutdown operations.
>
>Patch #2 ensures that shutdown of a base_vha port fails when there
>are active npiv_ports_inuse.
>
>Patch #3 adds seperate enable/disable attribute logic that is specific
>to NPIV operation, and patch #4 adds the configfs_[un]depend_item()
>calls in ensure that base_vha / base_tpg cannot be removed from the
>configfs hierarchy until all associated NPIV ports have been shutdown.
>
>And patch #5 fixes a seperate issue with NAA formatting of EVPD=0x83
>device identifier for NPIV WWPNs.
>
>Please review.
>
>Thanks!
>
>--nab
>
>Nicholas Bellinger (5):
>  qla2xxx: Fix qlt_lport_register base_vha callback race
>  qla2xxx: Check + fail when npiv_vports_inuse exists in shutdown
>  tcm_qla2xxx: Add NPIV specific enable/disable attribute logic
>  tcm_qla2xxx: Perform configfs depend/undepend for base_tpg
>  tcm_qla2xxx: Fix NAA formatted name for NPIV WWPNs
>
> drivers/scsi/qla2xxx/qla_target.c  |   39 +++--
> drivers/scsi/qla2xxx/qla_target.h  |2 +-
> drivers/scsi/qla2xxx/tcm_qla2xxx.c |  158
>++--
> drivers/scsi/qla2xxx/tcm_qla2xxx.h |7 +-
> 4 files changed, 153 insertions(+), 53 deletions(-)
>
>--
>1.7.10.4
>




This message and any attached documents contain information from QLogic 
Corporation or its wholly-owned subsidiaries that may be confidential. If you 
are not the intended recipient, you may not read, copy, distribute, or use this 
information. If you have received this transmission in error, please notify the 
sender immediately by reply e-mail and then delete this message.
<>

Re: [PATCH v1.3 1/11] arcmsr: Revise interrupt service routine to fix command timeout

2014-02-20 Thread James Bottomley
On Thu, 2014-02-20 at 15:14 +0300, Dan Carpenter wrote:
> On Thu, Feb 20, 2014 at 08:05:05PM +0800, 黃清隆 wrote:
> > From: Ching 
> > 
> > Rewrite interrupt service routine to fix command timeout on controller too
> > heavy loading.
> > 
> > Singed-off-by: Ching 
> 
> Your email client screwed up the whitespace completely.  Read
> Documentation/email-clients.txt or use `git send-email`
> http://www.freedesktop.org/wiki/Software/PulseAudio/HowToUseGitSendEmail/
> 
> There are also many unrelated white space changes in this patch.

Actually, none of these patches even made it to the SCSI list, because
they had html parts, which vger destroys.  Please make the changes Dan
suggests and then resubmit as plain text only.

James



Re: [PATCH 4/9] firewire: don't use PREPARE_DELAYED_WORK

2014-02-20 Thread Tejun Heo
Hello,

On Thu, Feb 20, 2014 at 08:44:46PM -0500, Peter Hurley wrote:
> >+static void fw_device_workfn(struct work_struct *work)
> >+{
> >+struct fw_device *device = container_of(to_delayed_work(work),
> >+struct fw_device, work);
> 
> I think this needs an smp_rmb() here.

The patch is equivalent transformation and the whole thing is
guaranteed to have gone through pool->lock.  No explicit rmb
necessary.

> IOW, the beginning of the work function should act like a barrier in
> the same way that queue_work_on() (et. al.) already does.

workqueue already has enough barriers; otherwise, the whole kernel
would have crumbled long time ago.

Thanks.

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


Re: [PATCH 4/9] firewire: don't use PREPARE_DELAYED_WORK

2014-02-20 Thread Peter Hurley

On 02/20/2014 08:59 PM, Tejun Heo wrote:

Hello,

On Thu, Feb 20, 2014 at 08:44:46PM -0500, Peter Hurley wrote:

+static void fw_device_workfn(struct work_struct *work)
+{
+   struct fw_device *device = container_of(to_delayed_work(work),
+   struct fw_device, work);


I think this needs an smp_rmb() here.


The patch is equivalent transformation and the whole thing is
guaranteed to have gone through pool->lock.  No explicit rmb
necessary.


The spin_unlock_irq(&pool->lock) only guarantees completion of
memory operations _before_ the unlock; memory operations which occur
_after_ the unlock may be speculated before the unlock.

IOW, unlock is not a memory barrier for operations that occur after.


IOW, the beginning of the work function should act like a barrier in
the same way that queue_work_on() (et. al.) already does.


workqueue already has enough barriers; otherwise, the whole kernel
would have crumbled long time ago.


See above.

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


Re: [PATCH 4/9] firewire: don't use PREPARE_DELAYED_WORK

2014-02-20 Thread Tejun Heo
On Thu, Feb 20, 2014 at 09:07:27PM -0500, Peter Hurley wrote:
> On 02/20/2014 08:59 PM, Tejun Heo wrote:
> >Hello,
> >
> >On Thu, Feb 20, 2014 at 08:44:46PM -0500, Peter Hurley wrote:
> >>>+static void fw_device_workfn(struct work_struct *work)
> >>>+{
> >>>+  struct fw_device *device = container_of(to_delayed_work(work),
> >>>+  struct fw_device, work);
> >>
> >>I think this needs an smp_rmb() here.
> >
> >The patch is equivalent transformation and the whole thing is
> >guaranteed to have gone through pool->lock.  No explicit rmb
> >necessary.
> 
> The spin_unlock_irq(&pool->lock) only guarantees completion of
> memory operations _before_ the unlock; memory operations which occur
> _after_ the unlock may be speculated before the unlock.
> 
> IOW, unlock is not a memory barrier for operations that occur after.

It's not just unlock.  It's lock / unlock pair on the same lock from
both sides.  Nothing can sip through that.

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


Re: [PATCH 4/9] firewire: don't use PREPARE_DELAYED_WORK

2014-02-20 Thread Peter Hurley

On 02/20/2014 03:44 PM, Tejun Heo wrote:

PREPARE_[DELAYED_]WORK() are being phased out.  They have few users
and a nasty surprise in terms of reentrancy guarantee as workqueue
considers work items to be different if they don't have the same work
function.

firewire core-device and sbp2 have been been multiplexing work items
with multiple work functions.  Introduce fw_device_workfn() and
sbp2_lu_workfn() which invoke fw_device->workfn and
sbp2_logical_unit->workfn respectively and always use the two
functions as the work functions and update the users to set the
->workfn fields instead of overriding work functions using
PREPARE_DELAYED_WORK().

It would probably be best to route this with other related updates
through the workqueue tree.

Compile tested.

Signed-off-by: Tejun Heo 
Cc: Stefan Richter 
Cc: linux1394-de...@lists.sourceforge.net
Cc: Chris Boot 
Cc: linux-scsi@vger.kernel.org
Cc: target-de...@vger.kernel.org
---
  drivers/firewire/core-device.c | 22 +++---
  drivers/firewire/sbp2.c| 17 +
  include/linux/firewire.h   |  1 +
  3 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index de4aa40..2c6d5e1 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -916,7 +916,7 @@ static int lookup_existing_device(struct device *dev, void 
*data)
old->config_rom_retries = 0;
fw_notice(card, "rediscovered device %s\n", dev_name(dev));

-   PREPARE_DELAYED_WORK(&old->work, fw_device_update);
+   old->workfn = fw_device_update;
fw_schedule_device_work(old, 0);

if (current_node == card->root_node)
@@ -1075,7 +1075,7 @@ static void fw_device_init(struct work_struct *work)
if (atomic_cmpxchg(&device->state,
   FW_DEVICE_INITIALIZING,
   FW_DEVICE_RUNNING) == FW_DEVICE_GONE) {
-   PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
+   device->workfn = fw_device_shutdown;
fw_schedule_device_work(device, SHUTDOWN_DELAY);


Implied mb of test_and_set_bit() in queue_work_on() ensures that the
newly assigned work function is visible on all cpus before evaluating
whether or not the work can be queued.

Ok.


} else {
fw_notice(card, "created device %s: GUID %08x%08x, S%d00\n",
@@ -1196,13 +1196,20 @@ static void fw_device_refresh(struct work_struct *work)
  dev_name(&device->device), fw_rcode_string(ret));
   gone:
atomic_set(&device->state, FW_DEVICE_GONE);
-   PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);
+   device->workfn = fw_device_shutdown;
fw_schedule_device_work(device, SHUTDOWN_DELAY);
   out:
if (node_id == card->root_node->node_id)
fw_schedule_bm_work(card, 0);
  }

+static void fw_device_workfn(struct work_struct *work)
+{
+   struct fw_device *device = container_of(to_delayed_work(work),
+   struct fw_device, work);


I think this needs an smp_rmb() here.


+   device->workfn(work);
+}
+


Otherwise this cpu could speculatively load workfn before
set_work_pool_and_clear_pending(), which means that the old workfn
could have been loaded but PENDING was still set and caused queue_work_on()
to reject the work as already pending.

Result: the new work function never runs.

But this exposes a more general problem that I believe workqueue should
prevent; speculated loads and stores in the work item function should be
prevented from occurring before clearing PENDING in
set_work_pool_and_clear_pending().

IOW, the beginning of the work function should act like a barrier in
the same way that queue_work_on() (et. al.) already does.

Regards,
Peter Hurley

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


Re: [PATCH] st: use dev_printk() to avoid linebreaks in kernel messages.

2014-02-20 Thread Yoshihiro YUNOMAE
Hi Hannes,

We want to handle the error message in userland for HA clusters, so the
error messages should be output in single(atomic) line. However, current
upstream kernel outputs SCSI error messages in multiple lines, so
current implementation is inconvenient. Even if human reads the error
messages, the split messages are difficult to read. Therefore, the
split error messages should be fixed.

In order to solve this problem, recently I submitted the patch fixing
SCSI error message split[1] to LKML. However, when I read the
discussion of you and Maurizio, I noticed that you already have fixed
in your branch.

When will you send your branch to linux-kernel ML or linux-scsi ML?

[1] https://lkml.org/lkml/2014/1/15/926
[2] http://marc.info/?t=13928007191&r=1&w=2

Thank you,
Yoshihiro YUNOMAE

-- 
Yoshihiro YUNOMAE
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: yoshihiro.yunomae...@hitachi.com

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


[PATCH v1.3 1/11] arcmsr: Revise interrupt service routine to fix command timeout

2014-02-20 Thread 黃清隆
From: Ching 

Rewrite interrupt service routine to fix command timeout on controller
too heavy loading.

Singed-off-by: Ching 
---

diff -uprN a/drivers/scsi/arcmsr/arcmsr_attr.c
b/drivers/scsi/arcmsr/arcmsr_attr.c
--- a/drivers/scsi/arcmsr/arcmsr_attr.c 2014-02-07 01:47:24.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_attr.c 2014-01-10 20:28:48.0 +0800
@@ -400,3 +400,4 @@ struct device_attribute *arcmsr_host_att
&dev_attr_host_fw_hd_channels,
NULL,
 };
+
diff -uprN a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
--- a/drivers/scsi/arcmsr/arcmsr.h  2014-02-07 01:47:44.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr.h  2014-01-11 02:53:22.0 +0800
@@ -45,28 +45,28 @@
 #include 
 struct device_attribute;
 /*The limit of outstanding scsi command that firmware can handle*/
-#define ARCMSR_MAX_OUTSTANDING_CMD
 256
+#define ARCMSR_MAX_OUTSTANDING_CMD 255
 #ifdef CONFIG_XEN
#define ARCMSR_MAX_FREECCB_NUM  160
 #else
#define ARCMSR_MAX_FREECCB_NUM  320
 #endif
-#define ARCMSR_DRIVER_VERSION   "Driver Version
1.20.00.15 2010/08/05"
-#define ARCMSR_SCSI_INITIATOR_ID
 255
-#define ARCMSR_MAX_XFER_SECTORS
 512
-#define ARCMSR_MAX_XFER_SECTORS_B
 4096
-#define ARCMSR_MAX_XFER_SECTORS_C
 304
-#define ARCMSR_MAX_TARGETID
 17
-#define ARCMSR_MAX_TARGETLUN
 8
-#define ARCMSR_MAX_CMD_PERLUN
ARCMSR_MAX_OUTSTANDING_CMD
-#define ARCMSR_MAX_QBUFFER
 4096
-#define ARCMSR_DEFAULT_SG_ENTRIES
 38
-#define ARCMSR_MAX_HBB_POSTQUEUE
 264
-#define ARCMSR_MAX_XFER_LEN
 0x26000 /* 152K */
-#define ARCMSR_CDB_SG_PAGE_LENGTH
 256
+#define ARCMSR_DRIVER_VERSION  "v1.30.00.04-20131204"
+#define ARCMSR_SCSI_INITIATOR_ID   255
+#define ARCMSR_MAX_XFER_SECTORS512
+#define ARCMSR_MAX_XFER_SECTORS_B  4096
+#define ARCMSR_MAX_XFER_SECTORS_C  304
+#define ARCMSR_MAX_TARGETID17
+#define ARCMSR_MAX_TARGETLUN   8
+#define ARCMSR_MAX_CMD_PERLUN  ARCMSR_MAX_OUTSTANDING_CMD
+#define ARCMSR_MAX_QBUFFER 4096
+#define ARCMSR_DEFAULT_SG_ENTRIES  38
+#define ARCMSR_MAX_HBB_POSTQUEUE   264
+#define ARCMSR_MAX_XFER_LEN0x26000 /* 152K */
+#define ARCMSR_CDB_SG_PAGE_LENGTH  256
 #ifndef PCI_DEVICE_ID_ARECA_1880
-#define PCI_DEVICE_ID_ARECA_1880 0x1880
- #endif
+#define PCI_DEVICE_ID_ARECA_1880   0x1880
+#endif
 /*
 
**
 **
@@ -690,3 +690,4 @@ extern struct QBUFFER __iomem *arcmsr_ge
 extern struct device_attribute *arcmsr_host_attrs[];
 extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *);
 void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb);
+
diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-07 01:47:00.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 01:59:18.0 +0800
@@ -104,7 +104,7 @@ static void arcmsr_request_hbc_device_ma
 static void arcmsr_message_isr_bh_fn(struct work_struct *work);
 static bool arcmsr_get_firmware_spec(struct AdapterControlBlock *acb);
 static void arcmsr_start_adapter_bgrb(struct AdapterControlBlock *acb);
-static void arcmsr_hbc_message_isr(struct AdapterControlBlock *pACB);
+static void arcmsr_hbaC_message_isr(struct AdapterControlBlock *pACB);
 static void arcmsr_hardware_reset(struct AdapterControlBlock *acb);
 static const char *arcmsr_info(struct Scsi_Host *);
 static irqreturn_t arcmsr_interrupt(struct AdapterControlBlock *acb);
@@ -1436,45 +1436,46 @@ static void arcmsr_iop2drv_data_read_han
}
 }

-static void arcmsr_hba_doorbell_isr(struct AdapterControlBlock *acb)
+static void
+arcmsr_hbaA_doorbell_isr(struct AdapterControlBlock *acb)
 {
uint32_t outbound_doorbell;
struct MessageUnit_A __iomem *reg = acb->pmuA;
outbound_doorbell = readl(®->outbound_doorbell);
-   writel(outbound_doorbell, ®->outbound_doorbell);
-   if (outbound_doorbell & ARCMSR_OUTBOUND_IOP331_DATA_WRITE_OK) {
-   arcmsr_iop2drv_data_wrote_handle(acb);
-   }
-
-   if (outbound_doorbell & ARCMSR_OUTBOUND_IOP331_DATA_READ_OK) {
-   arcmsr_iop2drv_data_read_handle(acb);
-   }
+   do {
+   writel(outbound_doorbell, ®->outbound_doorbell);
+   if (outbound_doorbell & ARCMSR_OUTBOUND_IOP331_DATA_WRITE_OK)
+   arcmsr_iop2drv_data_wrote_handle(acb);
+   if (outbound_doorbell & ARCMSR_OUTBOUND_IOP331_DATA_READ_OK)
+   arcmsr_iop2drv_data_read_handle(acb);
+   outbound_doorbell = readl(®->outbound_doorbell);
+   } while (outbound_doorbell & (ARCMSR_OUTBOUND_IOP331_DATA_WRITE_OK
+   | ARCMSR_OUTBOUND_IOP331_DATA_READ_OK));
 }
-static void arcmsr_hbc_doorbell_isr(struct AdapterControlBlock *pACB

[PATCH v1.3 2/11] arcmsr: Support MSI and MSI-X interrupt service

2014-02-20 Thread 黃清隆
From: Ching 

Supporting MSI and MSI-X interrupt service.

Singed-off-by: Ching 
---

diff -uprN a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
--- a/drivers/scsi/arcmsr/arcmsr.h  2014-01-11 02:53:22.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr.h  2014-01-11 03:14:14.0 +0800
@@ -64,6 +64,7 @@ struct device_attribute;
 #define ARCMSR_MAX_HBB_POSTQUEUE   264
 #define ARCMSR_MAX_XFER_LEN0x26000 /* 152K */
 #define ARCMSR_CDB_SG_PAGE_LENGTH  256
+#define ARCMST_NUM_MSIX_VECTORS4
 #ifndef PCI_DEVICE_ID_ARECA_1880
 #define PCI_DEVICE_ID_ARECA_1880   0x1880
 #endif
@@ -508,6 +509,7 @@ struct AdapterControlBlock
struct pci_dev *pdev;
struct Scsi_Host *  host;
unsigned long   vir2phy_offset;
+   struct msix_entry   entries[ARCMST_NUM_MSIX_VECTORS];
/* Offset is used in making arc cdb physical to virtual calculations */
uint32_toutbound_int_enable;
uint32_tcdb_phyaddr_hi32;
@@ -542,8 +544,10 @@ struct AdapterControlBlock

#define ACB_F_IOP_INITED0x0100
/* iop init */
-   #define ACB_F_ABORT 0x0200
-   #define ACB_F_FIRMWARE_TRAP 0x0400
+   #define ACB_F_ABORT 0x0200
+   #define ACB_F_FIRMWARE_TRAP 0x0400
+   #define ACB_F_MSI_ENABLED   0x1000
+   #define ACB_F_MSIX_ENABLED  0x2000
struct CommandControlBlock *
pccb_pool[ARCMSR_MAX_FREECCB_NUM];
/* used for memory free */
struct list_headccb_free_list;
diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 01:59:18.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 01:59:56.0 +0800
@@ -607,20 +607,19 @@ static int arcmsr_probe(struct pci_dev *
 {
struct Scsi_Host *host;
struct AdapterControlBlock *acb;
-   uint8_t bus,dev_fun;
-   int error;
+   uint8_t bus, dev_fun;
+   struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS];
+   int error, i, j;
error = pci_enable_device(pdev);
-   if(error){
+   if (error)
return -ENODEV;
-   }
host = scsi_host_alloc(&arcmsr_scsi_host_template,
sizeof(struct AdapterControlBlock));
-   if(!host){
+   if (!host)
goto pci_disable_dev;
-   }
error = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
-   if(error){
+   if (error) {
error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
-   if(error){
+   if (error) {
printk(KERN_WARNING
   "scsi%d: No suitable DMA mask available\n",
   host->host_no);
@@ -644,9 +643,8 @@ static int arcmsr_probe(struct pci_dev *
pci_set_drvdata(pdev, host);
pci_set_master(pdev);
error = pci_request_regions(pdev, "arcmsr");
-   if(error){
+   if (error)
goto scsi_host_release;
-   }
spin_lock_init(&acb->eh_lock);
spin_lock_init(&acb->ccblist_lock);
acb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED |
@@ -656,28 +654,58 @@ static int arcmsr_probe(struct pci_dev *
INIT_LIST_HEAD(&acb->ccb_free_list);
arcmsr_define_adapter_type(acb);
error = arcmsr_remap_pciregion(acb);
-   if(!error){
+   if (!error)
goto pci_release_regs;
-   }
error = arcmsr_get_firmware_spec(acb);
-   if(!error){
+   if (!error)
goto unmap_pci_region;
-   }
error = arcmsr_alloc_ccb_pool(acb);
-   if(error){
-   goto free_hbb_mu;
-   }
-   arcmsr_iop_init(acb);
+   if (error)
+   goto free_mu;
error = scsi_add_host(host, &pdev->dev);
-   if(error){
+   if (error)
goto RAID_controller_stop;
-   }
-   error = request_irq(pdev->irq, arcmsr_do_interrupt,
IRQF_SHARED, "arcmsr", acb);
-   if(error){
-   goto scsi_host_remove;
+   if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) {
+   if (!pci_enable_msix(pdev, entries, ARCMST_NUM_MSIX_VECTORS)) {
+   for (i = 0; i < ARCMST_NUM_MSIX_VECTORS; i++) {
+   entries[i].entry = i;
+   if (request_irq(entries[i].vector,
+   arcmsr_do_interrupt, 0,
"arcmsr", acb)) {
+   for (j = 0 ; j < i ; j++)
+
free_irq(entries[i].vector, acb);
+   goto scsi_host_remove;
+   }
+   acb->entries[i] = entries[i];
+   }
+   acb->acb_fla

[PATCH v1.3 3/11] arcmsr: Support hibernation

2014-02-20 Thread 黃清隆
From: Ching 

Supporting hibernation.

Singed-off-by: Ching 
---

diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 01:59:56.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 02:00:16.0 +0800
@@ -87,13 +87,16 @@ static int arcmsr_bus_reset(struct scsi_
 static int arcmsr_bios_param(struct scsi_device *sdev,
struct block_device *bdev, sector_t capacity, int *info);
 static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
-static int arcmsr_probe(struct pci_dev *pdev,
-   const struct pci_device_id *id);
+static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id);
+static int arcmsr_suspend(struct pci_dev *pdev, pm_message_t state);
+static int arcmsr_resume(struct pci_dev *pdev);
 static void arcmsr_remove(struct pci_dev *pdev);
 static void arcmsr_shutdown(struct pci_dev *pdev);
 static void arcmsr_iop_init(struct AdapterControlBlock *acb);
 static void arcmsr_free_ccb_pool(struct AdapterControlBlock *acb);
 static u32 arcmsr_disable_outbound_ints(struct AdapterControlBlock *acb);
+static void arcmsr_enable_outbound_ints(struct AdapterControlBlock *acb,
+   u32 intmask_org);
 static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb);
 static void arcmsr_flush_hba_cache(struct AdapterControlBlock *acb);
 static void arcmsr_flush_hbb_cache(struct AdapterControlBlock *acb);
@@ -164,9 +167,11 @@ static struct pci_device_id arcmsr_devic
 MODULE_DEVICE_TABLE(pci, arcmsr_device_id_table);
 static struct pci_driver arcmsr_pci_driver = {
.name   = "arcmsr",
-   .id_table   = arcmsr_device_id_table,
+   .id_table   = arcmsr_device_id_table,
.probe  = arcmsr_probe,
.remove = arcmsr_remove,
+   .suspend= arcmsr_suspend,
+   .resume = arcmsr_resume,
.shutdown   = arcmsr_shutdown,
 };
 /*
@@ -603,6 +608,121 @@ static void arcmsr_message_isr_bh_fn(str
}
 }

+static int
+arcmsr_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+   int i;
+   uint32_t intmask_org;
+   struct Scsi_Host *host = pci_get_drvdata(pdev);
+   struct AdapterControlBlock *acb =
+   (struct AdapterControlBlock *)host->hostdata;
+
+   intmask_org = arcmsr_disable_outbound_ints(acb);
+   if (acb->acb_flags & ACB_F_MSI_ENABLED) {
+   free_irq(pdev->irq, acb);
+   pci_disable_msi(pdev);
+   } else if (acb->acb_flags & ACB_F_MSIX_ENABLED) {
+   for (i = 0; i < ARCMST_NUM_MSIX_VECTORS; i++)
+   free_irq(acb->entries[i].vector, acb);
+   pci_disable_msix(pdev);
+   } else
+   free_irq(pdev->irq, acb);
+   del_timer_sync(&acb->eternal_timer);
+   flush_scheduled_work();
+   arcmsr_stop_adapter_bgrb(acb);
+   arcmsr_flush_adapter_cache(acb);
+   arcmsr_enable_outbound_ints(acb, intmask_org);
+   pci_set_drvdata(pdev, host);
+   pci_save_state(pdev);
+   pci_disable_device(pdev);
+   pci_set_power_state(pdev, pci_choose_state(pdev, state));
+   return 0;
+}
+
+static int
+arcmsr_resume(struct pci_dev *pdev)
+{
+   int error, i, j;
+   struct Scsi_Host *host = pci_get_drvdata(pdev);
+   struct AdapterControlBlock *acb =
+   (struct AdapterControlBlock *)host->hostdata;
+   struct msix_entry entries[ARCMST_NUM_MSIX_VECTORS];
+   pci_set_power_state(pdev, PCI_D0);
+   pci_enable_wake(pdev, PCI_D0, 0);
+   pci_restore_state(pdev);
+   if (pci_enable_device(pdev)) {
+   pr_warn("%s: pci_enable_device error\n", __func__);
+   return -ENODEV;
+   }
+   error = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
+   if (error) {
+   error = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+   if (error) {
+   pr_warn("scsi%d: No suitable DMA mask available\n",
+  host->host_no);
+   goto controller_unregister;
+   }
+   }
+   pci_set_master(pdev);
+   if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) {
+   if (!pci_enable_msix(pdev, entries,
+   ARCMST_NUM_MSIX_VECTORS)) {
+   for (i = 0; i < ARCMST_NUM_MSIX_VECTORS;
+   i++) {
+   entries[i].entry = i;
+   if (request_irq(entries[i].vector,
+   arcmsr_do_interrupt, 0,
+   "arcmsr", acb)) {
+   for (j = 0 ; j < i ; j++)
+
free_irq(entries[i].vector, acb);
+   goto controller_stop;
+   }
+  

[PATCH v1.3 4/11] arcmsr: Revise xxx_get_config functions

2014-02-20 Thread 黃清隆
From: Ching 

Revise xxx_get_config functions.

Singed-off-by: Ching 
---

diff -uprN a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
--- a/drivers/scsi/arcmsr/arcmsr.h  2014-01-11 03:14:14.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr.h  2014-01-13 23:21:56.0 +0800
@@ -598,6 +598,7 @@ struct AdapterControlBlock
#define FW_DEADLOCK 0x0010
atomic_trq_map_token;
atomic_tante_token_value;
+   uint32_tmaxOutstanding;
 };/* HW_DEVICE_EXTENSION */
 /*
 ***
diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 02:00:16.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 02:01:56.0 +0800
@@ -2241,8 +2241,7 @@ static int arcmsr_queue_command_lck(stru
arcmsr_handle_virtual_command(acb, cmd);
return 0;
}
-   if (atomic_read(&acb->ccboutstandingcount) >=
-   ARCMSR_MAX_OUTSTANDING_CMD)
+   if (atomic_read(&acb->ccboutstandingcount) >= acb->maxOutstanding)
return SCSI_MLQUEUE_HOST_BUSY;
ccb = arcmsr_get_freeccb(acb);
if (!ccb)
@@ -2258,24 +2257,28 @@ static int arcmsr_queue_command_lck(stru

 static DEF_SCSI_QCMD(arcmsr_queue_command)

-static bool arcmsr_get_hba_config(struct AdapterControlBlock *acb)
+static bool
+arcmsr_hbaA_get_config(struct AdapterControlBlock *acb)
 {
struct MessageUnit_A __iomem *reg = acb->pmuA;
char *acb_firm_model = acb->firm_model;
char *acb_firm_version = acb->firm_version;
char *acb_device_map = acb->device_map;
-   char __iomem *iop_firm_model = (char __iomem
*)(®->message_rwbuffer[15]);
-   char __iomem *iop_firm_version = (char __iomem
*)(®->message_rwbuffer[17]);
-   char __iomem *iop_device_map = (char __iomem
*)(®->message_rwbuffer[21]);
+   char __iomem *iop_firm_model =
+   (char __iomem *)(®->message_rwbuffer[15]);
+   char __iomem *iop_firm_version =
+   (char __iomem *)(®->message_rwbuffer[17]);
+   char __iomem *iop_device_map =
+   (char __iomem *)(®->message_rwbuffer[21]);
int count;
writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0);
if (!arcmsr_hba_wait_msgint_ready(acb)) {
-   printk(KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \
-   miscellaneous data' timeout \n", acb->host->host_no);
+   pr_notice("arcmsr%d: wait 'get adapter firmware "
+   "miscellaneous data' timeout\n", acb->host->host_no);
return false;
}
count = 8;
-   while (count){
+   while (count) {
*acb_firm_model = readb(iop_firm_model);
acb_firm_model++;
iop_firm_model++;
@@ -2283,7 +2286,7 @@ static bool arcmsr_get_hba_config(struct
}

count = 16;
-   while (count){
+   while (count) {
*acb_firm_version = readb(iop_firm_version);
acb_firm_version++;
iop_firm_version++;
@@ -2291,27 +2294,29 @@ static bool arcmsr_get_hba_config(struct
}

count=16;
-   while(count){
+   while (count) {
*acb_device_map = readb(iop_device_map);
acb_device_map++;
iop_device_map++;
count--;
}
-   printk(KERN_NOTICE "Areca RAID Controller%d: F/W %s & Model %s\n",
+   pr_notice("Areca RAID Controller%d: Model %s, F/W %s\n",
acb->host->host_no,
-   acb->firm_version,
-   acb->firm_model);
+   acb->firm_model,
+   acb->firm_version);
acb->signature = readl(®->message_rwbuffer[0]);
acb->firm_request_len = readl(®->message_rwbuffer[1]);
acb->firm_numbers_queue = readl(®->message_rwbuffer[2]);
acb->firm_sdram_size = readl(®->message_rwbuffer[3]);
acb->firm_hd_channels = readl(®->message_rwbuffer[4]);
-   acb->firm_cfg_version = readl(®->message_rwbuffer[25]);
/*firm_cfg_version,25,100-103*/
+   acb->firm_cfg_version = readl(®->message_rwbuffer[25]);
return true;
 }
-static bool arcmsr_get_hbb_config(struct AdapterControlBlock *acb)
+
+static bool
+arcmsr_hbaB_get_config(struct AdapterControlBlock *acb)
 {
-   struct MessageUnit_B *reg = acb->pmuB;
+   struct MessageUnit_B *reg;
struct pci_dev *pdev = acb->pdev;
void *dma_coherent;
dma_addr_t dma_coherent_handle;
@@ -2325,40 +2330,50 @@ static bool arcmsr_get_hbb_config(struct
char __iomem *iop_device_map;
/*firm_version,21,84-99*/
int count;
-   dma_coherent = dma_alloc_coherent(&pdev->dev, sizeof(struct
MessageUnit_B), &dma_coherent_handle, GFP_K

[PATCH v1.3 5/11] arcmsr: Rename function name and variables for readability

2014-02-20 Thread 黃清隆
From: Ching 

Rename function name and variables for readability.

Singed-off-by: Ching 
---

diff -uprN a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
--- a/drivers/scsi/arcmsr/arcmsr.h  2014-01-13 23:21:56.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr.h  2014-01-14 23:27:40.0 +0800
@@ -358,7 +358,7 @@ struct ARCMSR_CDB
 #define ARCMSR_CDB_FLAG_ORDEREDQ   0x10

uint8_t msgPages;
-   uint32_tContext;
+   uint32_tmsgContext;
uint32_tDataLength;
uint8_t Cdb[16];
uint8_t DeviceStatus;
@@ -561,8 +561,8 @@ struct AdapterControlBlock
/* dma_coherent used for memory free */
dma_addr_t  dma_coherent_handle;
/* dma_coherent_handle used for memory free */
-   dma_addr_t  dma_coherent_handle_hbb_mu;
-   unsigned intuncache_size;
+   dma_addr_t  dma_coherent_handle2;
+   unsigned intuncache_size;
uint8_t rqbuffer[ARCMSR_MAX_QBUFFER];
/* data collection buffer for read from 80331 */
int32_t rqbuf_firstindex;
@@ -611,7 +611,7 @@ struct CommandControlBlock{
struct list_headlist;
 /*x32: 8byte, x64: 16byte*/
struct scsi_cmnd*pcmd;
 /*8 bytes pointer of linux scsi command */
struct AdapterControlBlock  *acb;
 /*x32: 4byte, x64: 8byte*/
-   uint32_tcdb_phyaddr_pattern;
 /*x32: 4byte, x64: 4byte*/
+   uint32_tcdb_phyaddr;
 /*x32: 4byte, x64: 4byte*/
uint32_tarc_cdb_size;
 /*x32:4byte,x64:4byte*/
uint16_tccb_flags;
 /*x32: 2byte, x64: 2byte*/
#define CCB_FLAG_READ   0x
diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 02:01:56.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 02:02:34.0 +0800
@@ -98,12 +98,12 @@ static u32 arcmsr_disable_outbound_ints(
 static void arcmsr_enable_outbound_ints(struct AdapterControlBlock *acb,
u32 intmask_org);
 static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb);
-static void arcmsr_flush_hba_cache(struct AdapterControlBlock *acb);
-static void arcmsr_flush_hbb_cache(struct AdapterControlBlock *acb);
+static void arcmsr_hbaA_flush_cache(struct AdapterControlBlock *acb);
+static void arcmsr_hbaB_flush_cache(struct AdapterControlBlock *acb);
 static void arcmsr_request_device_map(unsigned long pacb);
-static void arcmsr_request_hba_device_map(struct AdapterControlBlock *acb);
-static void arcmsr_request_hbb_device_map(struct AdapterControlBlock *acb);
-static void arcmsr_request_hbc_device_map(struct AdapterControlBlock *acb);
+static void arcmsr_hbaA_request_device_map(struct AdapterControlBlock *acb);
+static void arcmsr_hbaB_request_device_map(struct AdapterControlBlock *acb);
+static void arcmsr_hbaC_request_device_map(struct AdapterControlBlock *acb);
 static void arcmsr_message_isr_bh_fn(struct work_struct *work);
 static bool arcmsr_get_firmware_spec(struct AdapterControlBlock *acb);
 static void arcmsr_start_adapter_bgrb(struct AdapterControlBlock *acb);
@@ -179,17 +179,17 @@ static struct pci_driver arcmsr_pci_driv
 
 */

-static void arcmsr_free_hbb_mu(struct AdapterControlBlock *acb)
+static void arcmsr_free_mu(struct AdapterControlBlock *acb)
 {
switch (acb->adapter_type) {
case ACB_ADAPTER_TYPE_A:
case ACB_ADAPTER_TYPE_C:
break;
-   case ACB_ADAPTER_TYPE_B:{
+   case ACB_ADAPTER_TYPE_B: {
dma_free_coherent(&acb->pdev->dev,
sizeof(struct MessageUnit_B),
-   acb->pmuB, acb->dma_coherent_handle_hbb_mu);
-   }
+   acb->pmuB, acb->dma_coherent_handle2);
+   }
}
 }

@@ -314,7 +314,7 @@ static void arcmsr_define_adapter_type(s
}
 }

-static uint8_t arcmsr_hba_wait_msgint_ready(struct AdapterControlBlock *acb)
+static uint8_t arcmsr_hbaA_wait_msgint_ready(struct AdapterControlBlock *acb)
 {
struct MessageUnit_A __iomem *reg = acb->pmuA;
int i;
@@ -332,7 +332,7 @@ static uint8_t arcmsr_hba_wait_msgint_re
return false;
 }

-static uint8_t arcmsr_hbb_wait_msgint_ready(struct AdapterControlBlock *acb)
+static uint8_t arcmsr_hbaB_wait_msgint_ready(struct AdapterControlBlock *acb)
 {
struct Messag

[PATCH v1.3 6/11] arcmsr: Rewrite arcmsr_message_isr_bh_fn function

2014-02-20 Thread 黃清隆
From: Ching 

Rewrite arcmsr_message_isr_bh_fn function

Singed-off-by: Ching 
---


diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 02:02:34.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 02:03:28.0 +0800
@@ -489,121 +489,68 @@ static int arcmsr_alloc_ccb_pool(struct
return 0;
 }

-static void arcmsr_message_isr_bh_fn(struct work_struct *work)
+static void
+arcmsr_message_isr_bh_fn(struct work_struct *work)
 {
-   struct AdapterControlBlock *acb = container_of(work,struct
AdapterControlBlock, arcmsr_do_message_isr_bh);
-   switch (acb->adapter_type) {
-   case ACB_ADAPTER_TYPE_A: {
-
-   struct MessageUnit_A __iomem *reg  = acb->pmuA;
-   char *acb_dev_map = (char *)acb->device_map;
-   uint32_t __iomem *signature = (uint32_t
__iomem*) (®->message_rwbuffer[0]);
-   char __iomem *devicemap = (char __iomem*)
(®->message_rwbuffer[21]);
-   int target, lun;
-   struct scsi_device *psdev;
-   char diff;
+   struct AdapterControlBlock *acb = container_of(work,
+   struct AdapterControlBlock, arcmsr_do_message_isr_bh);
+   char *acb_dev_map = (char *)acb->device_map;
+   uint32_t __iomem *signature = NULL;
+   char __iomem *devicemap = NULL;
+   int target, lun;
+   struct scsi_device *psdev;
+   char diff, temp;

-   atomic_inc(&acb->rq_map_token);
-   if (readl(signature) == ARCMSR_SIGNATURE_GET_CONFIG) {
-   for(target = 0; target <
ARCMSR_MAX_TARGETID -1; target++) {
-   diff = (*acb_dev_map)^readb(devicemap);
-   if (diff != 0) {
-   char temp;
-   *acb_dev_map = readb(devicemap);
-   temp =*acb_dev_map;
-   for(lun = 0; lun <
ARCMSR_MAX_TARGETLUN; lun++) {
-   if((temp &
0x01)==1 && (diff & 0x01) == 1) {
-
scsi_add_device(acb->host, 0, target, lun);
-   }else if((temp
& 0x01) == 0 && (diff & 0x01) == 1) {
-   psdev
= scsi_device_lookup(acb->host, 0, target, lun);
-   if
(psdev != NULL ) {
-
 scsi_remove_device(psdev);
-
 scsi_device_put(psdev);
-   }
-   }
-   temp >>= 1;
-   diff >>= 1;
-   }
-   }
-   devicemap++;
-   acb_dev_map++;
-   }
-   }
-   break;
+   switch (acb->adapter_type) {
+   case ACB_ADAPTER_TYPE_A: {
+   struct MessageUnit_A __iomem *reg  = acb->pmuA;
+   signature = (uint32_t __iomem *)(®->message_rwbuffer[0]);
+   devicemap = (char __iomem *)(®->message_rwbuffer[21]);
+   break;
}
-
-   case ACB_ADAPTER_TYPE_B: {
-   struct MessageUnit_B *reg  = acb->pmuB;
-   char *acb_dev_map = (char *)acb->device_map;
-   uint32_t __iomem *signature = (uint32_t
__iomem*)(®->message_rwbuffer[0]);
-   char __iomem *devicemap = (char
__iomem*)(®->message_rwbuffer[21]);
-   int target, lun;
-   struct scsi_device *psdev;
-   char diff;
-
-   atomic_inc(&acb->rq_map_token);
-   if (readl(signature) == ARCMSR_SIGNATURE_GET_CONFIG) {
-   for(target = 0; target <
ARCMSR_MAX_TARGETID -1; target++) {
-   diff = (*acb_dev_map)^readb(devicemap);
-   if (diff != 0) {
-   char temp;
-   *acb_dev_map = readb(devicemap);
-   temp =*acb_dev_map;
-   for(lun = 0; lun <
ARCMSR_MAX_TARGETLUN; lun++) {
-   if((temp &
0x01)==1 && (diff & 0x01) == 1) {
-
scsi_add_device(acb->host, 0, target, lun);
-   }else if((temp
& 

[PATCH v1.3 7/11] arcmsr: Notify sense data report

2014-02-20 Thread 黃清隆
From: Ching 

Notify sense data report

Singed-off-by: Ching 
---

diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 02:03:28.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 02:04:10.0 +0800
@@ -906,7 +906,7 @@ static void arcmsr_report_sense_info(str

struct scsi_cmnd *pcmd = ccb->pcmd;
struct SENSE_DATA *sensebuffer = (struct SENSE_DATA
*)pcmd->sense_buffer;
-   pcmd->result = DID_OK << 16;
+   pcmd->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
if (sensebuffer) {
int sense_data_length =
sizeof(struct SENSE_DATA) < SCSI_SENSE_BUFFERSIZE
@@ -915,6 +915,7 @@ static void arcmsr_report_sense_info(str
memcpy(sensebuffer, ccb->arcmsr_cdb.SenseData,
sense_data_length);
sensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS;
sensebuffer->Valid = 1;
+   pcmd->result |= (DRIVER_SENSE << 24);
}
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1.3 8/11] arcmsr: Modify ioctl relate functions to fix update firmware error

2014-02-20 Thread 黃清隆
From: Ching 

Modify ioctl relate functions to fix update firmware error.

Singed-off-by: Ching 
---

diff -uprN a/drivers/scsi/arcmsr/arcmsr_attr.c
b/drivers/scsi/arcmsr/arcmsr_attr.c
--- a/drivers/scsi/arcmsr/arcmsr_attr.c 2014-01-10 20:28:48.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_attr.c 2014-01-15 23:41:36.0 +0800
@@ -59,64 +59,104 @@

 struct device_attribute *arcmsr_host_attrs[];

-static ssize_t arcmsr_sysfs_iop_message_read(struct file *filp,
-struct kobject *kobj,
-struct bin_attribute *bin,
-char *buf, loff_t off,
-size_t count)
+static ssize_t
+arcmsr_sysfs_iop_message_read(struct file *filp,
+   struct kobject *kobj,
+   struct bin_attribute *bin,
+   char *buf, loff_t off,
+   size_t count)
 {
-   struct device *dev = container_of(kobj,struct device,kobj);
+   struct device *dev = container_of(kobj, struct device, kobj);
struct Scsi_Host *host = class_to_shost(dev);
-   struct AdapterControlBlock *acb = (struct AdapterControlBlock
*) host->hostdata;
+   struct AdapterControlBlock *acb =
+   (struct AdapterControlBlock *)host->hostdata;
uint8_t *pQbuffer,*ptmpQbuffer;
int32_t allxfer_len = 0;
+   unsigned long flags;

if (!capable(CAP_SYS_ADMIN))
return -EACCES;

/* do message unit read. */
ptmpQbuffer = (uint8_t *)buf;
-   while ((acb->rqbuf_firstindex != acb->rqbuf_lastindex)
-   && (allxfer_len < 1031)) {
+   spin_lock_irqsave(&acb->rqbuffer_lock, flags);
+   if (acb->rqbuf_firstindex != acb->rqbuf_lastindex) {
pQbuffer = &acb->rqbuffer[acb->rqbuf_firstindex];
-   memcpy(ptmpQbuffer, pQbuffer, 1);
-   acb->rqbuf_firstindex++;
-   acb->rqbuf_firstindex %= ARCMSR_MAX_QBUFFER;
-   ptmpQbuffer++;
-   allxfer_len++;
+   if (acb->rqbuf_firstindex > acb->rqbuf_lastindex) {
+   if ((ARCMSR_MAX_QBUFFER -
acb->rqbuf_firstindex) >= 1032) {
+   memcpy(ptmpQbuffer, pQbuffer, 1032);
+   acb->rqbuf_firstindex += 1032;
+   acb->rqbuf_firstindex %= ARCMSR_MAX_QBUFFER;
+   allxfer_len = 1032;
+   } else {
+   if (((ARCMSR_MAX_QBUFFER -
acb->rqbuf_firstindex)
+   + acb->rqbuf_lastindex) > 1032) {
+   memcpy(ptmpQbuffer, pQbuffer,
+   ARCMSR_MAX_QBUFFER
+   - acb->rqbuf_firstindex);
+   ptmpQbuffer += ARCMSR_MAX_QBUFFER
+   - acb->rqbuf_firstindex;
+   memcpy(ptmpQbuffer, acb->rqbuffer, 1032
+   - (ARCMSR_MAX_QBUFFER -
+   acb->rqbuf_firstindex));
+   acb->rqbuf_firstindex = 1032 -
+   (ARCMSR_MAX_QBUFFER -
+   acb->rqbuf_firstindex);
+   allxfer_len = 1032;
+   } else {
+   memcpy(ptmpQbuffer, pQbuffer,
+   ARCMSR_MAX_QBUFFER -
+   acb->rqbuf_firstindex);
+   ptmpQbuffer += ARCMSR_MAX_QBUFFER -
+   acb->rqbuf_firstindex;
+   memcpy(ptmpQbuffer, acb->rqbuffer,
+   acb->rqbuf_lastindex);
+   allxfer_len = ARCMSR_MAX_QBUFFER -
+   acb->rqbuf_firstindex +
+   acb->rqbuf_lastindex;
+   acb->rqbuf_firstindex =
+   acb->rqbuf_lastindex;
+   }
+   }
+   } else {
+   if ((acb->rqbuf_lastindex -
acb->rqbuf_firstindex) > 1032) {
+   memcpy(ptmpQbuffer, pQbuffer, 1032);
+   acb->rqbuf_firstindex += 1032;
+   allxfer_len = 1032;
+   } else {
+   memcpy(ptmpQbuffer, pQbuffer,
acb->rqbuf_lastindex
+   

[PATCH v1.3 9/11] arcmsr: Fixed sparse warning or errors

2014-02-20 Thread 黃清隆
From: Ching 

Fixed sparse warning or errors.

Singed-off-by: Ching 
---

diff -uprN a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
--- a/drivers/scsi/arcmsr/arcmsr.h  2014-02-18 01:30:16.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr.h  2014-02-20 23:23:30.0 +0800
@@ -408,9 +408,9 @@ struct MessageUnit_A
 struct MessageUnit_B
 {
uint32_tpost_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE];
-   uint32_tdone_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE];
+   volatile uint32_t done_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE];
uint32_tpostq_index;
-   uint32_tdoneq_index;
+   volatile uint32_t doneq_index;
uint32_t__iomem *drv2iop_doorbell;
uint32_t__iomem *drv2iop_doorbell_mask;
uint32_t__iomem *iop2drv_doorbell;
@@ -506,6 +506,7 @@ struct AdapterControlBlock
#define ACB_ADAPTER_TYPE_B0x0002/* hbb M IOP */
#define ACB_ADAPTER_TYPE_C0x0004/* hbc P IOP */
#define ACB_ADAPTER_TYPE_D0x0008/* hbd A IOP */
+   u32 roundup_ccbsize;
struct pci_dev *pdev;
struct Scsi_Host *  host;
unsigned long   vir2phy_offset;
@@ -564,6 +565,7 @@ struct AdapterControlBlock
dma_addr_t  dma_coherent_handle;
/* dma_coherent_handle used for memory free */
dma_addr_t  dma_coherent_handle2;
+   void*dma_coherent2;
unsigned intuncache_size;
uint8_t rqbuffer[ARCMSR_MAX_QBUFFER];
/* data collection buffer for read from 80331 */
diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-21 02:04:50.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c  2014-02-20 19:10:08.0 +0800
@@ -78,7 +78,7 @@ MODULE_VERSION(ARCMSR_DRIVER_VERSION);
 #defineARCMSR_SLEEPTIME10
 #defineARCMSR_RETRYCOUNT   12

-wait_queue_head_t wait_q;
+static wait_queue_head_t wait_q;
 static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb,
struct scsi_cmnd *cmd);
 static int arcmsr_iop_confirm(struct AdapterControlBlock *acb);
@@ -182,13 +182,10 @@ static struct pci_driver arcmsr_pci_driv
 static void arcmsr_free_mu(struct AdapterControlBlock *acb)
 {
switch (acb->adapter_type) {
-   case ACB_ADAPTER_TYPE_A:
-   case ACB_ADAPTER_TYPE_C:
-   break;
case ACB_ADAPTER_TYPE_B: {
-   dma_free_coherent(&acb->pdev->dev,
-   sizeof(struct MessageUnit_B),
-   acb->pmuB, acb->dma_coherent_handle2);
+   dma_free_coherent(&acb->pdev->dev, acb->roundup_ccbsize,
+   acb->dma_coherent2, acb->dma_coherent_handle2);
+   break;
}
}
 }
@@ -374,7 +371,7 @@ static uint8_t arcmsr_hbaB_wait_msgint_r

 static uint8_t arcmsr_hbaC_wait_msgint_ready(struct AdapterControlBlock *pACB)
 {
-   struct MessageUnit_C *phbcmu = (struct MessageUnit_C *)pACB->pmuC;
+   struct MessageUnit_C __iomem *phbcmu = pACB->pmuC;
int i;

for (i = 0; i < 2000; i++) {
@@ -424,7 +421,7 @@ static void arcmsr_hbaB_flush_cache(stru

 static void arcmsr_hbaC_flush_cache(struct AdapterControlBlock *pACB)
 {
-   struct MessageUnit_C *reg = (struct MessageUnit_C *)pACB->pmuC;
+   struct MessageUnit_C __iomem *reg = pACB->pmuC;
int retry_count = 30;/* enlarge wait flush adapter cache time:
10 minute */
writel(ARCMSR_INBOUND_MESG0_FLUSH_CACHE, ®->inbound_msgaddr0);
writel(ARCMSR_HBCMU_DRV2IOP_MESSAGE_CMD_DONE, ®->inbound_doorbell);
@@ -861,7 +858,7 @@ static uint8_t arcmsr_hbaB_abort_allcmd(
 }
 static uint8_t arcmsr_hbaC_abort_allcmd(struct AdapterControlBlock *pACB)
 {
-   struct MessageUnit_C *reg = (struct MessageUnit_C *)pACB->pmuC;
+   struct MessageUnit_C __iomem *reg = pACB->pmuC;
writel(ARCMSR_INBOUND_MESG0_ABORT_CMD, ®->inbound_msgaddr0);
writel(ARCMSR_HBCMU_DRV2IOP_MESSAGE_CMD_DONE, ®->inbound_doorbell);
if (!arcmsr_hbaC_wait_msgint_ready(pACB)) {
@@ -961,7 +958,7 @@ static u32 arcmsr_disable_outbound_ints(
}
break;
case ACB_ADAPTER_TYPE_C:{
-   struct MessageUnit_C *reg = (struct MessageUnit_C *)acb->pmuC;
+   struct MessageUnit_C __iomem *reg = acb->pmuC;
/* disable all outbound interrupt */
orig_mask = readl(®->host_int_mask); /* disable
outbound message0 int */
writel(orig_mask|ARCMSR_HBCMU_ALL_INTMASKENABLE,
®->host_int_mask);
@@ -1085,8 +1082,9 @@ static void arcmsr_done4abort_postqueue(
/*clear all outbound posted Q*/
   

[PATCH v1.3 11/11] arcmsr: Adding support Areca ARC1214/1224/1264/1284 SATA 6Gb raid controllers

2014-02-20 Thread 黃清隆
From: Ching 

Adding support Areca ARC1214/1224/1264/1284 SATA 6Gb raid controllers.

Singed-off-by: Ching 
---

diff -uprN a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
--- a/drivers/scsi/arcmsr/arcmsr.h  2014-02-20 20:14:42.0 +0800
+++ b/drivers/scsi/arcmsr/arcmsr.h  2014-02-20 20:01:46.0 +0800
@@ -62,12 +62,17 @@ struct device_attribute;
 #define ARCMSR_MAX_QBUFFER 4096
 #define ARCMSR_DEFAULT_SG_ENTRIES  38
 #define ARCMSR_MAX_HBB_POSTQUEUE   264
+#define ARCMSR_MAX_ARC1214_POSTQUEUE   256
+#define ARCMSR_MAX_ARC1214_DONEQUEUE   257
 #define ARCMSR_MAX_XFER_LEN0x26000
 #define ARCMSR_CDB_SG_PAGE_LENGTH  256
 #define ARCMST_NUM_MSIX_VECTORS4
 #ifndef PCI_DEVICE_ID_ARECA_1880
#define PCI_DEVICE_ID_ARECA_18800x1880
 #endif
+#ifndef PCI_DEVICE_ID_ARECA_1214
+   #define PCI_DEVICE_ID_ARECA_12140x1214
+#endif
 /*
 
**
 **
@@ -341,6 +346,56 @@ struct FIRMWARE_INFO
 #define ARCMSR_HBCMU_MESSAGE_FIRMWARE_OK   0x8000
 /*
 ***
+**SPEC. for Areca Type D adapter
+***
+*/
+#define ARCMSR_ARC1214_CHIP_ID 0x4
+#define ARCMSR_ARC1214_CPU_MEMORY_CONFIGURATION0x8
+#define ARCMSR_ARC1214_I2_HOST_INTERRUPT_MASK  0x00034
+#define ARCMSR_ARC1214_SAMPLE_RESET0x00100
+#define ARCMSR_ARC1214_RESET_REQUEST   0x00108
+#define ARCMSR_ARC1214_MAIN_INTERRUPT_STATUS   0x00200
+#define ARCMSR_ARC1214_PCIE_F0_INTERRUPT_ENABLE0x0020C
+#define ARCMSR_ARC1214_INBOUND_MESSAGE00x00400
+#define ARCMSR_ARC1214_INBOUND_MESSAGE10x00404
+#define ARCMSR_ARC1214_OUTBOUND_MESSAGE0   0x00420
+#define ARCMSR_ARC1214_OUTBOUND_MESSAGE1   0x00424
+#define ARCMSR_ARC1214_INBOUND_DOORBELL0x00460
+#define ARCMSR_ARC1214_OUTBOUND_DOORBELL   0x00480
+#define ARCMSR_ARC1214_OUTBOUND_DOORBELL_ENABLE0x00484
+#define ARCMSR_ARC1214_INBOUND_LIST_BASE_LOW   0x01000
+#define ARCMSR_ARC1214_INBOUND_LIST_BASE_HIGH  0x01004
+#define ARCMSR_ARC1214_INBOUND_LIST_WRITE_POINTER  0x01018
+#define ARCMSR_ARC1214_OUTBOUND_LIST_BASE_LOW  0x01060
+#define ARCMSR_ARC1214_OUTBOUND_LIST_BASE_HIGH 0x01064
+#define ARCMSR_ARC1214_OUTBOUND_LIST_COPY_POINTER  0x0106C
+#define ARCMSR_ARC1214_OUTBOUND_LIST_READ_POINTER  0x01070
+#define ARCMSR_ARC1214_OUTBOUND_INTERRUPT_CAUSE0x01088
+#define ARCMSR_ARC1214_OUTBOUND_INTERRUPT_ENABLE   0x0108C
+#define ARCMSR_ARC1214_MESSAGE_WBUFFER 0x02000
+#define ARCMSR_ARC1214_MESSAGE_RBUFFER 0x02100
+#define ARCMSR_ARC1214_MESSAGE_RWBUFFER0x02200
+/* Host Interrupt Mask */
+#define ARCMSR_ARC1214_ALL_INT_ENABLE  0x1010
+#define ARCMSR_ARC1214_ALL_INT_DISABLE 0x
+/* Host Interrupt Status */
+#define ARCMSR_ARC1214_OUTBOUND_DOORBELL_ISR   0x1000
+#define ARCMSR_ARC1214_OUTBOUND_POSTQUEUE_ISR  0x0010
+/* DoorBell*/
+#define ARCMSR_ARC1214_DRV2IOP_DATA_IN_READY   0x0001
+#define ARCMSR_ARC1214_DRV2IOP_DATA_OUT_READ   0x0002
+/*inbound message 0 ready*/
+#define ARCMSR_ARC1214_IOP2DRV_DATA_WRITE_OK   0x0001
+/*outbound DATA WRITE isr door bell clear*/
+#define ARCMSR_ARC1214_IOP2DRV_DATA_READ_OK0x0002
+/*outbound message 0 ready*/
+#define ARCMSR_ARC1214_IOP2DRV_MESSAGE_CMD_DONE0x0200
+/*outbound message cmd isr door bell clear*/
+/*ARCMSR_HBAMU_MESSAGE_FIRMWARE_OK*/
+#define ARCMSR_ARC1214_MESSAGE_FIRMWARE_OK 0x8000
+#define ARCMSR_ARC1214_OUTBOUND_LIST_INTERRUPT_CLEAR   0x0001
+/*
+***
 **ARECA SCSI COMMAND DESCRIPTOR BLOCK size 0x1F8 (504)
 ***
 */
@@ -501,6 +556,55 @@ struct MessageUnit_C {
uint32_t msgcode_rwbuffer[256]; /*2200 23FF*/
 };
 /*
+*
+** Messaging Unit (MU) of Type D processor
+*
+*/
+struct InBound_SRB {
+   uint32_t addressLow; /* pointer to SRB block */
+   uint32_t addressHigh;
+   uint32_t length; /* in DWORDs */
+   uint32_t reserved0;
+};
+
+struct OutBound_SRB {
+   uint32_t addressLow; /* pointer to SRB block */
+   uint32_t addressHigh;
+};
+
+struct MessageUnit_D {
+   struct InBound_SRB  post_q

Re: [PATCH 4/9] firewire: don't use PREPARE_DELAYED_WORK

2014-02-20 Thread Peter Hurley

On 02/20/2014 09:13 PM, Tejun Heo wrote:

On Thu, Feb 20, 2014 at 09:07:27PM -0500, Peter Hurley wrote:

On 02/20/2014 08:59 PM, Tejun Heo wrote:

Hello,

On Thu, Feb 20, 2014 at 08:44:46PM -0500, Peter Hurley wrote:

+static void fw_device_workfn(struct work_struct *work)
+{
+   struct fw_device *device = container_of(to_delayed_work(work),
+   struct fw_device, work);


I think this needs an smp_rmb() here.


The patch is equivalent transformation and the whole thing is
guaranteed to have gone through pool->lock.  No explicit rmb
necessary.


The spin_unlock_irq(&pool->lock) only guarantees completion of
memory operations _before_ the unlock; memory operations which occur
_after_ the unlock may be speculated before the unlock.

IOW, unlock is not a memory barrier for operations that occur after.


It's not just unlock.  It's lock / unlock pair on the same lock from
both sides.  Nothing can sip through that.


CPU 0| CPU 1
 |
 INIT_WORK(fw_device_workfn) |
 |
 workfn = funcA  |
 queue_work_on() |
 .   | process_one_work()
 .   |   ..
 .   |   worker->current_func = work->func
 .   |
 .   |   speculative load of workfn = funcA
 .   |   .
 workfn = funcB  |   .
 queue_work_on() |   .
   local_irq_save()  |   .
   test_and_set_bit() == 1   |   .
 |   set_work_pool_and_clear_pending()
   work is not queued| smp_wmb
funcB never runs | set_work_data()
 |   atomic_set()
 |   spin_unlock_irq()
 |
 |   worker->current_func(work)  @ 
fw_device_workfn
 |  workfn()  @ funcA


The speculative load of workfn on CPU 1 is valid because no rmb will occur
between the load and the execution of workfn() on CPU 1.

Thus funcB will never execute because, in this circumstance, a second
worker is not queued (because PENDING had not yet been cleared).

Regards,
Peter Hurley


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


[Bug 60758] module scsi_wait_scan not found kernel panic on boot

2014-02-20 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=60758

Thorsten Kohfeldt  changed:

   What|Removed |Added

 CC||thorsten.kohfe...@gmx.de

--- Comment #57 from Thorsten Kohfeldt  ---
I have filed a bug against dracut:

https://bugzilla.redhat.com/show_bug.cgi?id=1067669

which gives an explanation at least for kernel 3.13.


That kernel version introduces multi queue block i/o for virtio_blk, which in
turn does not any more call blk_init_queue() but blk_mq_init_queue() instead.

Dracut matches against symbol blk_init_queue but not yet against symbol
blk_mq_init_queue.

This should be fixed for Fedora and also for all RHEL derivatives ...


In the mean time there is this WORKAROUND:

1) check if virtio_blk is in intrd:
# for i in /boot/initramfs-* ; do echo $i: ; lsinitrd $i | grep virt ; done

2) if virtio_blk is missing in the relevant initrd, then

# echo 'add_drivers+="virtio_blk"'
>/etc/dracut.conf.d/force-vitio_blk-to-ensure-boot.conf
   (NOTE that the .conf extension is mandatory !)

3) then rebuild the initrd

-- 
You are receiving this mail because:
You are the assignee for the bug.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Bug 60758] module scsi_wait_scan not found kernel panic on boot

2014-02-20 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=60758

--- Comment #58 from Thorsten Kohfeldt  ---
Please verify/confirm (add comments to) that redhat/dracut bug/solution, so it
gets dracut maintainers' attention.

https://bugzilla.redhat.com/show_bug.cgi?id=1067669

-- 
You are receiving this mail because:
You are the assignee for the bug.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Bug 60758] module scsi_wait_scan not found kernel panic on boot

2014-02-20 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=60758

--- Comment #59 from Lin Feng  ---
(In reply to Thorsten Kohfeldt from comment #57)
> I have filed a bug against dracut:
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1067669
> 
> which gives an explanation at least for kernel 3.13.
> 
> 
> That kernel version introduces multi queue block i/o for virtio_blk, which
> in turn does not any more call blk_init_queue() but blk_mq_init_queue()
> instead.
> 
> Dracut matches against symbol blk_init_queue but not yet against symbol
> blk_mq_init_queue.
> 
Good, based on the bisect it seems that it's the root cause, thanks :)

-- 
You are receiving this mail because:
You are the assignee for the bug.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] st: use dev_printk() to avoid linebreaks in kernel messages.

2014-02-20 Thread Hannes Reinecke
On 02/20/2014 08:25 PM, Martin K. Petersen wrote:
>> "Hannes" == Hannes Reinecke  writes:
> 
> Hannes,
> 
>>> If you have a more complete and up-to-date patchset in your queue it
>>> would be interesting to have a look at it.
>>>
> Hannes> You can find the current development branch at
> 
> Hannes> git.kernel.org:/pub/scm/linux/kernel/git/hare/scsi-devel branch
> Hannes> scsi-logging.v3
> 
> I like the printk cleanups and the more sensible sense printing. But why
> perpetuate the crufty old SCSI logging stuff when we have SCSI tracing?
> 

I'm all for removing it, and move over to SCSI tracing.
But not without general (read: the maintainers) consent.

James?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1.3 1/11] arcmsr: Revise interrupt service routine to fix command timeout

2014-02-20 Thread Dan Carpenter
On Fri, Feb 21, 2014 at 10:56:34AM +0800, 黃清隆 wrote:
> From: Ching 
> 
> Rewrite interrupt service routine to fix command timeout on controller
> too heavy loading.
> 
> Singed-off-by: Ching 

This email is still line wrapped I'm afraid.  It doesn't apply.

> ---
> 
> diff -uprN a/drivers/scsi/arcmsr/arcmsr_attr.c
> b/drivers/scsi/arcmsr/arcmsr_attr.c
> --- a/drivers/scsi/arcmsr/arcmsr_attr.c 2014-02-07 01:47:24.0 +0800
> +++ b/drivers/scsi/arcmsr/arcmsr_attr.c 2014-01-10 20:28:48.0 +0800
> -#define ARCMSR_SCSI_INITIATOR_ID
>  255
> +#define ARCMSR_SCSI_INITIATOR_ID   255

Please do white space changes in a separate change set so that the logic
changes are easier to review.

Use "git citool".  Highlight the lines with white space changes and then
right click and select "Stage lines for commit".  It is a very useful
tool.

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