Re: [PATCH] mpt3sas: switch to pci_alloc_irq_vectors

2016-12-02 Thread kbuild test robot
Hi Hannes,

[auto build test ERROR on scsi/for-next]
[also build test ERROR on next-20161202]
[cannot apply to v4.9-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Hannes-Reinecke/mpt3sas-switch-to-pci_alloc_irq_vectors/20161203-074559
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/scsi/mpt3sas/mpt3sas_base.c: In function '_base_get_msix_index':
>> drivers/scsi/mpt3sas/mpt3sas_base.c:2198:9: error: implicit declaration of 
>> function 'pci_irq_get_affinity_vector' 
>> [-Werror=implicit-function-declaration]
 return pci_irq_get_affinity_vector(ioc->pdev, raw_smp_processor_id());
^~~
   cc1: some warnings being treated as errors
--
   drivers/scsi/mpt3sas/mpt3sas_scsih.c: In function 'scsih_map_queues':
>> drivers/scsi/mpt3sas/mpt3sas_scsih.c:8564:9: error: too many arguments to 
>> function 'blk_mq_pci_map_queues'
 return blk_mq_pci_map_queues(>tag_set, ioc->pdev, 0);
^
   In file included from drivers/scsi/mpt3sas/mpt3sas_scsih.c:57:0:
   include/linux/blk-mq-pci.h:7:5: note: declared here
int blk_mq_pci_map_queues(struct blk_mq_tag_set *set, struct pci_dev *pdev);
^

vim +/pci_irq_get_affinity_vector +2198 drivers/scsi/mpt3sas/mpt3sas_base.c

  2192  return ioc->reply + (phys_addr - (u32)ioc->reply_dma);
  2193  }
  2194  
  2195  static inline u16
  2196  _base_get_msix_index(struct MPT3SAS_ADAPTER *ioc)
  2197  {
> 2198  return pci_irq_get_affinity_vector(ioc->pdev, 
> raw_smp_processor_id());
  2199  }
  2200  
  2201  /**

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH 5/6] g_NCR5380: Autoprobe IRQ by default

2016-12-02 Thread Finn Thain

Hi Ondrej,

On Wed, 2 Nov 2016, I wrote:

> 
> I think this patch is incomplete and you should add these changes:
> 
> diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
> index 7299ad9..0bf0322 100644
> --- a/drivers/scsi/g_NCR5380.c
> +++ b/drivers/scsi/g_NCR5380.c
> @@ -44,7 +44,7 @@ static int ncr_53c400;
>  static int ncr_53c400a;
>  static int dtc_3181e;
>  static int hp_c2502;
> -module_param(ncr_irq, int, 0);
> +module_param(ncr_irq, int, IRQ_AUTO);

Oops, this doesn't even compile! Sorry about that.

What I was trying to achieve was,

-static int ncr_irq;
+static int ncr_irq = IRQ_AUTO;

I will update my patch queue, compile test it, and ask you to review.

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


RE: [PATCHv3] hpsa: fallback to use legacy REPORT PHYS command

2016-12-02 Thread Don Brace
> -Original Message-
> From: Hannes Reinecke [mailto:h...@suse.de]
> Sent: Friday, December 02, 2016 4:36 AM
> To: Martin K. Petersen
> Cc: Christoph Hellwig; James Bottomley; Don Brace; linux-
> s...@vger.kernel.org; Hannes Reinecke; Hannes Reinecke
> Subject: [PATCHv3] hpsa: fallback to use legacy REPORT PHYS command
> 
> EXTERNAL EMAIL
> 
> 
> Older SmartArray controllers (eg SmartArray 64xx) do
> not support the extended REPORT PHYS command, so
> fallback to use the legacy version here.
> 
> Signed-off-by: Hannes Reinecke 
> ---
>  drivers/scsi/hpsa.c | 28 ++--
>  1 file changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 216c137..3783ef6 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -3640,8 +3640,32 @@ static int hpsa_scsi_do_report_luns(struct
> ctlr_info *h, int logical,
>  static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
> struct ReportExtendedLUNdata *buf, int bufsize)
>  {
> -   return hpsa_scsi_do_report_luns(h, 0, buf, bufsize,
> -   HPSA_REPORT_PHYS_EXTENDED);
> +   int rc;
> +   struct ReportLUNdata *lbuf;
> +
> +   rc = hpsa_scsi_do_report_luns(h, 0, buf, bufsize,
> + HPSA_REPORT_PHYS_EXTENDED);
> +   if (!rc || !hpsa_allow_any)
> +   return rc;
> +
> +   /* REPORT PHYS EXTENDED is not supported */
> +   lbuf = kzalloc(sizeof(*lbuf), GFP_KERNEL);
> +   if (!lbuf)
> +   return -ENOMEM;
> +
> +   rc = hpsa_scsi_do_report_luns(h, 0, lbuf, sizeof(*lbuf), 0);
> +   if (!rc) {
> +   int i;
> +   u32 nphys;
> +
> +   /* Copy ReportLUNdata header */
> +   memcpy(buf, lbuf, 8);
> +   nphys = be32_to_cpu(*((__be32 *)lbuf->LUNListLength)) / 8;
> +   for (i = 0; i < nphys; i++)
> +   memcpy(buf->LUN[i].lunid, lbuf->LUN[i], 8);
> +   }
> +   kfree(lbuf);
> +   return rc;
>  }
> 
>  static inline int hpsa_scsi_do_report_log_luns(struct ctlr_info *h,
> --
> 1.8.5.6

Acked-by: Don Brace 

Note: there has been zero testing on our end of these ancient controllers with 
the hpsa driver.
While it might work there is no official support from either us or HPE on this 
configuration.

Thanks,
Don Brace
ESC - Smart Storage
Microsemi Corporation



--
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 v3 3/6] qla2xxx: Utilize pci_alloc_irq_vectors/pci_free_irq_vectors calls.

2016-12-02 Thread Himanshu Madhani
From: Michael Hernandez 

Replaces the old pci_enable_msi[x]* and pci_disable_msi[x] calls.

Signed-off-by: Michael Hernandez 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h |  1 +
 drivers/scsi/qla2xxx/qla_isr.c | 81 +++---
 2 files changed, 30 insertions(+), 52 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 9a6ddcb..53021b5 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2748,6 +2748,7 @@ struct qla_msix_entry {
uint32_t vector;
uint16_t entry;
struct rsp_que *rsp;
+   void *handle;
struct irq_affinity_notify irq_notify;
int cpuid;
 };
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 19f1848..16e7601 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -3025,52 +3025,17 @@ struct qla_init_msix_entry {
{ "qla2xxx (atio_q)", qla83xx_msix_atio_q },
 };
 
-static void
-qla24xx_disable_msix(struct qla_hw_data *ha)
-{
-   int i;
-   struct qla_msix_entry *qentry;
-   scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
-
-   for (i = 0; i < ha->msix_count; i++) {
-   qentry = >msix_entries[i];
-   if (qentry->have_irq) {
-   /* un-register irq cpu affinity notification */
-   irq_set_affinity_notifier(qentry->vector, NULL);
-   free_irq(qentry->vector, qentry->rsp);
-   }
-   }
-   pci_disable_msix(ha->pdev);
-   kfree(ha->msix_entries);
-   ha->msix_entries = NULL;
-   ha->flags.msix_enabled = 0;
-   ql_dbg(ql_dbg_init, vha, 0x0042,
-   "Disabled the MSI.\n");
-}
-
 static int
 qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
 {
 #define MIN_MSIX_COUNT 2
 #define ATIO_VECTOR2
int i, ret;
-   struct msix_entry *entries;
struct qla_msix_entry *qentry;
scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
 
-   entries = kzalloc(sizeof(struct msix_entry) * ha->msix_count,
-   GFP_KERNEL);
-   if (!entries) {
-   ql_log(ql_log_warn, vha, 0x00bc,
-   "Failed to allocate memory for msix_entry.\n");
-   return -ENOMEM;
-   }
-
-   for (i = 0; i < ha->msix_count; i++)
-   entries[i].entry = i;
-
-   ret = pci_enable_msix_range(ha->pdev,
-   entries, MIN_MSIX_COUNT, ha->msix_count);
+   ret = pci_alloc_irq_vectors(ha->pdev,
+   MIN_MSIX_COUNT, ha->msix_count, PCI_IRQ_MSIX|PCI_IRQ_AFFINITY);
if (ret < 0) {
ql_log(ql_log_fatal, vha, 0x00c7,
"MSI-X: Failed to enable support, "
@@ -3097,10 +3062,10 @@ struct qla_init_msix_entry {
 
for (i = 0; i < ha->msix_count; i++) {
qentry = >msix_entries[i];
-   qentry->vector = entries[i].vector;
-   qentry->entry = entries[i].entry;
+   qentry->vector = pci_irq_vector(ha->pdev, i);
+   qentry->entry = i;
qentry->have_irq = 0;
-   qentry->rsp = NULL;
+   qentry->handle = NULL;
qentry->irq_notify.notify  = qla_irq_affinity_notify;
qentry->irq_notify.release = qla_irq_affinity_release;
qentry->cpuid = -1;
@@ -3109,7 +3074,7 @@ struct qla_init_msix_entry {
/* Enable MSI-X vectors for the base queue */
for (i = 0; i < 2; i++) {
qentry = >msix_entries[i];
-   qentry->rsp = rsp;
+   qentry->handle = rsp;
rsp->msix = qentry;
if (IS_P3P_TYPE(ha))
ret = request_irq(qentry->vector,
@@ -3142,7 +3107,7 @@ struct qla_init_msix_entry {
 */
if (QLA_TGT_MODE_ENABLED() && IS_ATIO_MSIX_CAPABLE(ha)) {
qentry = >msix_entries[ATIO_VECTOR];
-   qentry->rsp = rsp;
+   qentry->handle = rsp;
rsp->msix = qentry;
ret = request_irq(qentry->vector,
qla83xx_msix_entries[ATIO_VECTOR].handler,
@@ -3155,7 +3120,7 @@ struct qla_init_msix_entry {
ql_log(ql_log_fatal, vha, 0x00cb,
"MSI-X: unable to register handler -- %x/%d.\n",
qentry->vector, ret);
-   qla24xx_disable_msix(ha);
+   qla2x00_free_irqs(vha);
ha->mqenable = 0;
goto msix_out;
}
@@ -3177,7 +3142,6 @@ struct qla_init_msix_entry {
ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues);
 
 msix_out:
-   kfree(entries);
return ret;
 }
 
@@ -3230,7 +3194,7 @@ struct qla_init_msix_entry {
!IS_QLA27XX(ha))
goto 

[PATCH v3 1/6] qla2xxx: Only allow operational MBX to proceed during RESET.

2016-12-02 Thread Himanshu Madhani
Reviewed-by: Hannes Reinecke 
Signed-off-by: Himanshu Madhani 
Signed-off-by: Giridhar Malavali 
---
 drivers/scsi/qla2xxx/qla_mbx.c | 52 ++
 1 file changed, 52 insertions(+)

diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 23698c9..b31c36b 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -10,6 +10,43 @@
 #include 
 #include 
 
+struct rom_cmd {
+   uint16_t cmd;
+} rom_cmds[] = {
+   { MBC_LOAD_RAM },
+   { MBC_EXECUTE_FIRMWARE },
+   { MBC_READ_RAM_WORD },
+   { MBC_MAILBOX_REGISTER_TEST },
+   { MBC_VERIFY_CHECKSUM },
+   { MBC_GET_FIRMWARE_VERSION },
+   { MBC_LOAD_RISC_RAM },
+   { MBC_DUMP_RISC_RAM },
+   { MBC_LOAD_RISC_RAM_EXTENDED },
+   { MBC_DUMP_RISC_RAM_EXTENDED },
+   { MBC_WRITE_RAM_WORD_EXTENDED },
+   { MBC_READ_RAM_EXTENDED },
+   { MBC_GET_RESOURCE_COUNTS },
+   { MBC_SET_FIRMWARE_OPTION },
+   { MBC_MID_INITIALIZE_FIRMWARE },
+   { MBC_GET_FIRMWARE_STATE },
+   { MBC_GET_MEM_OFFLOAD_CNTRL_STAT },
+   { MBC_GET_RETRY_COUNT },
+   { MBC_TRACE_CONTROL },
+};
+
+static int is_rom_cmd(uint16_t cmd)
+{
+   int i;
+   struct  rom_cmd *wc;
+
+   for (i = 0; i < ARRAY_SIZE(rom_cmds); i++) {
+   wc = rom_cmds + i;
+   if (wc->cmd == cmd)
+   return 1;
+   }
+
+   return 0;
+}
 
 /*
  * qla2x00_mailbox_command
@@ -92,6 +129,17 @@
return QLA_FUNCTION_TIMEOUT;
}
 
+   /* check if ISP abort is active and return cmd with timeout */
+   if ((test_bit(ABORT_ISP_ACTIVE, _vha->dpc_flags) ||
+   test_bit(ISP_ABORT_RETRY, _vha->dpc_flags) ||
+   test_bit(ISP_ABORT_NEEDED, _vha->dpc_flags)) &&
+   !is_rom_cmd(mcp->mb[0])) {
+   ql_log(ql_log_info, vha, 0x1005,
+   "Cmd 0x%x aborted with timeout since ISP Abort is 
pending\n",
+   mcp->mb[0]);
+   return QLA_FUNCTION_TIMEOUT;
+   }
+
/*
 * Wait for active mailbox commands to finish by waiting at most tov
 * seconds. This is to serialize actual issuing of mailbox cmds during
@@ -178,6 +226,7 @@
WRT_REG_WORD(>isp.hccr, HCCR_SET_HOST_INT);
spin_unlock_irqrestore(>hardware_lock, flags);
 
+   wait_time = jiffies;
if (!wait_for_completion_timeout(>mbx_intr_comp,
mcp->tov * HZ)) {
ql_dbg(ql_dbg_mbx, vha, 0x117a,
@@ -186,6 +235,9 @@
clear_bit(MBX_INTR_WAIT, >mbx_cmd_flags);
spin_unlock_irqrestore(>hardware_lock, flags);
}
+   if (time_after(jiffies, wait_time + 5 * HZ))
+   ql_log(ql_log_warn, vha, 0x1015, "cmd=0x%x, waited %d 
msecs\n",
+   command, jiffies_to_msecs(jiffies - wait_time));
} else {
ql_dbg(ql_dbg_mbx, vha, 0x1011,
"Cmd=%x Polling Mode.\n", command);
-- 
1.8.3.1

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


[PATCH v3 5/6] qla2xxx: Add Block Multi Queue functionality.

2016-12-02 Thread Himanshu Madhani
From: Michael Hernandez 

Tell the SCSI layer how many hardware queues we have based on the number
of max queue pairs created. The number of max queue pairs created will
depend on number of MSI-X vector count.

This feature can be turned on via CONFIG_SCSI_MQ_DEFAULT or passing
scsi_mod.use_blk_mq=Y as a parameter to the kernel

Queue pair creation depend on module parameter "ql2xmqsupport", which
need to be enabled to create queue pair.

Signed-off-by: Sawan Chandak 
Signed-off-by: Michael Hernandez 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_os.c | 37 -
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index b06722a..3371b3f 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -667,16 +667,26 @@ static void qla2x00_free_queues(struct qla_hw_data *ha)
struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
srb_t *sp;
int rval;
-   struct qla_qpair *qpair;
+   struct qla_qpair *qpair = NULL;
+   uint32_t tag;
+   uint16_t hwq;
 
if (unlikely(test_bit(UNLOADING, _vha->dpc_flags))) {
cmd->result = DID_NO_CONNECT << 16;
goto qc24_fail_command;
}
 
-   if (vha->vp_idx && vha->qpair) {
-   qpair = vha->qpair;
-   return qla2xxx_mqueuecommand(host, cmd, qpair);
+   if (ha->mqenable) {
+   if (shost_use_blk_mq(vha->host)) {
+   tag = blk_mq_unique_tag(cmd->request);
+   hwq = blk_mq_unique_tag_to_hwq(tag);
+   qpair = ha->queue_pair_map[hwq];
+   } else if (vha->vp_idx && vha->qpair) {
+   qpair = vha->qpair;
+   }
+
+   if (qpair)
+   return qla2xxx_mqueuecommand(host, cmd, qpair);
}
 
if (ha->flags.eeh_busy) {
@@ -2362,6 +2372,7 @@ static void qla2x00_destroy_mbx_wq(struct qla_hw_data *ha)
uint16_t req_length = 0, rsp_length = 0;
struct req_que *req = NULL;
struct rsp_que *rsp = NULL;
+   int i;
 
bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
sht = _driver_template;
@@ -2727,6 +2738,16 @@ static void qla2x00_destroy_mbx_wq(struct qla_hw_data 
*ha)
goto probe_init_failed;
}
 
+   if (ha->mqenable && shost_use_blk_mq(host)) {
+   /* number of hardware queues supported by blk/scsi-mq*/
+   host->nr_hw_queues = ha->max_qpairs;
+
+   ql_dbg(ql_dbg_init, base_vha, 0x0192,
+   "blk/scsi-mq enabled, HW queues = %d.\n", 
host->nr_hw_queues);
+   } else
+   ql_dbg(ql_dbg_init, base_vha, 0x0193,
+   "blk/scsi-mq disabled.\n");
+
qlt_probe_one_stage1(base_vha, ha);
 
pci_save_state(pdev);
@@ -2827,8 +2848,14 @@ static void qla2x00_destroy_mbx_wq(struct qla_hw_data 
*ha)
host->can_queue, base_vha->req,
base_vha->mgmt_svr_loop_id, host->sg_tablesize);
 
-   if (ha->mqenable)
+   if (ha->mqenable) {
ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1);
+   /* Create start of day qpairs for Block MQ */
+   if (shost_use_blk_mq(host)) {
+   for (i = 0; i < ha->max_qpairs; i++)
+   qla2xxx_create_qpair(base_vha, 5, 0);
+   }
+   }
 
if (ha->flags.running_gold_fw)
goto skip_dpc;
-- 
1.8.3.1

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


[PATCH v3 6/6] qla2xxx: Fix Target mode handling with Multiqueue changes.

2016-12-02 Thread Himanshu Madhani
From: Quinn Tran 

- Fix race condition between dpc_thread accessing Multiqueue resources
  and qla2x00_remove_one thread trying to free resource.
- Fix out of order free for Multiqueue resources. Also, Multiqueue
  interrupts needs a workqueue. Interrupt needed to stop before
  the wq can be destroyed.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h |  3 ++-
 drivers/scsi/qla2xxx/qla_isr.c | 20 +++--
 drivers/scsi/qla2xxx/qla_mq.c  |  2 +-
 drivers/scsi/qla2xxx/qla_os.c  | 51 +++---
 4 files changed, 49 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 607d539..e613535 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2734,7 +2734,8 @@ struct isp_operations {
 
 #define QLA_MSIX_DEFAULT   0x00
 #define QLA_MSIX_RSP_Q 0x01
-#define QLA_MSIX_QPAIR_MULTIQ_RSP_Q0x02
+#define QLA_ATIO_VECTOR0x02
+#define QLA_MSIX_QPAIR_MULTIQ_RSP_Q0x03
 
 #define QLA_MIDX_DEFAULT   0
 #define QLA_MIDX_RSP_Q 1
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 14f27a7..03384cf 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -2976,6 +2976,7 @@ struct qla_init_msix_entry {
 static struct qla_init_msix_entry msix_entries[] = {
{ "qla2xxx (default)", qla24xx_msix_default },
{ "qla2xxx (rsp_q)", qla24xx_msix_rsp_q },
+   { "qla2xxx (atio_q)", qla83xx_msix_atio_q },
{ "qla2xxx (qpair_multiq)", qla2xxx_msix_rsp_q },
 };
 
@@ -2984,17 +2985,10 @@ struct qla_init_msix_entry {
{ "qla2xxx (rsp_q)", qla82xx_msix_rsp_q },
 };
 
-static struct qla_init_msix_entry qla83xx_msix_entries[] = {
-   { "qla2xxx (default)", qla24xx_msix_default },
-   { "qla2xxx (rsp_q)", qla24xx_msix_rsp_q },
-   { "qla2xxx (atio_q)", qla83xx_msix_atio_q },
-};
-
 static int
 qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
 {
 #define MIN_MSIX_COUNT 2
-#define ATIO_VECTOR2
int i, ret;
struct qla_msix_entry *qentry;
scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
@@ -3051,7 +3045,7 @@ struct qla_init_msix_entry {
}
 
/* Enable MSI-X vectors for the base queue */
-   for (i = 0; i < 2; i++) {
+   for (i = 0; i < (QLA_MSIX_RSP_Q + 1); i++) {
qentry = >msix_entries[i];
qentry->handle = rsp;
rsp->msix = qentry;
@@ -3068,6 +3062,7 @@ struct qla_init_msix_entry {
if (ret)
goto msix_register_fail;
qentry->have_irq = 1;
+   qentry->in_use = 1;
 
/* Register for CPU affinity notification. */
irq_set_affinity_notifier(qentry->vector, >irq_notify);
@@ -3087,14 +3082,15 @@ struct qla_init_msix_entry {
 * queue.
 */
if (QLA_TGT_MODE_ENABLED() && IS_ATIO_MSIX_CAPABLE(ha)) {
-   qentry = >msix_entries[ATIO_VECTOR];
+   qentry = >msix_entries[QLA_ATIO_VECTOR];
rsp->msix = qentry;
qentry->handle = rsp;
scnprintf(qentry->name, sizeof(qentry->name),
-   qla83xx_msix_entries[ATIO_VECTOR].name);
+   msix_entries[QLA_ATIO_VECTOR].name);
+   qentry->in_use = 1;
ret = request_irq(qentry->vector,
-   qla83xx_msix_entries[ATIO_VECTOR].handler,
-   0, qla83xx_msix_entries[ATIO_VECTOR].name, rsp);
+   msix_entries[QLA_ATIO_VECTOR].handler,
+   0, msix_entries[QLA_ATIO_VECTOR].name, rsp);
qentry->have_irq = 1;
}
 
diff --git a/drivers/scsi/qla2xxx/qla_mq.c b/drivers/scsi/qla2xxx/qla_mq.c
index a64b7b0..5543b4c 100644
--- a/drivers/scsi/qla2xxx/qla_mq.c
+++ b/drivers/scsi/qla2xxx/qla_mq.c
@@ -118,7 +118,7 @@ struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host 
*vha, int qos, int v
qpair->vp_idx = vp_idx;
 
for (i = 0; i < ha->msix_count; i++) {
-   msix = >msix_entries[i + 2];
+   msix = >msix_entries[i];
if (msix->in_use)
continue;
qpair->msix = msix;
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 3371b3f..91d8e7a 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -434,24 +434,41 @@ static void qla2x00_free_queues(struct qla_hw_data *ha)
struct req_que *req;
struct rsp_que *rsp;
int cnt;
+   unsigned long flags;
 
+   spin_lock_irqsave(>hardware_lock, flags);
for (cnt = 0; cnt < ha->max_req_queues; cnt++) {
  

[PATCH v3 4/6] qla2xxx: Add multiple queue pair functionality.

2016-12-02 Thread Himanshu Madhani
From: Michael Hernandez 

Replaced existing multiple queue functionality with framework
that allows for the creation of pairs of request and response queues,
either at start of day or dynamically.

Signed-off-by: Sawan Chandak 
Signed-off-by: Michael Hernandez 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/Makefile |   3 +-
 drivers/scsi/qla2xxx/qla_attr.c   |  36 ++--
 drivers/scsi/qla2xxx/qla_bottom.c | 398 ++
 drivers/scsi/qla2xxx/qla_dbg.c|   4 +-
 drivers/scsi/qla2xxx/qla_def.h| 105 --
 drivers/scsi/qla2xxx/qla_gbl.h|  32 ++-
 drivers/scsi/qla2xxx/qla_init.c   |  14 +-
 drivers/scsi/qla2xxx/qla_inline.h |  30 +++
 drivers/scsi/qla2xxx/qla_iocb.c   |  56 ++
 drivers/scsi/qla2xxx/qla_isr.c| 101 +-
 drivers/scsi/qla2xxx/qla_mbx.c|  33 ++--
 drivers/scsi/qla2xxx/qla_mid.c| 116 +--
 drivers/scsi/qla2xxx/qla_mq.c | 236 ++
 drivers/scsi/qla2xxx/qla_os.c | 237 +++
 drivers/scsi/qla2xxx/qla_top.c|  95 +
 15 files changed, 1153 insertions(+), 343 deletions(-)
 create mode 100644 drivers/scsi/qla2xxx/qla_bottom.c
 create mode 100644 drivers/scsi/qla2xxx/qla_mq.c
 create mode 100644 drivers/scsi/qla2xxx/qla_top.c

diff --git a/drivers/scsi/qla2xxx/Makefile b/drivers/scsi/qla2xxx/Makefile
index 44def6b..ca04260 100644
--- a/drivers/scsi/qla2xxx/Makefile
+++ b/drivers/scsi/qla2xxx/Makefile
@@ -1,6 +1,7 @@
 qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \
qla_dbg.o qla_sup.o qla_attr.o qla_mid.o qla_dfs.o qla_bsg.o \
-   qla_nx.o qla_mr.o qla_nx2.o qla_target.o qla_tmpl.o
+   qla_nx.o qla_mr.o qla_nx2.o qla_target.o qla_tmpl.o qla_mq.o \
+   qla_top.o qla_bottom.o
 
 obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx.o
 obj-$(CONFIG_TCM_QLA2XXX) += tcm_qla2xxx.o
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index fe7469c..47eb4d5 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1988,9 +1988,9 @@ struct device_attribute *qla2x00_host_attrs[] = {
scsi_qla_host_t *base_vha = shost_priv(fc_vport->shost);
scsi_qla_host_t *vha = NULL;
struct qla_hw_data *ha = base_vha->hw;
-   uint16_t options = 0;
int cnt;
struct req_que *req = ha->req_q_map[0];
+   struct qla_qpair *qpair;
 
ret = qla24xx_vport_create_req_sanity_check(fc_vport);
if (ret) {
@@ -2075,15 +2075,9 @@ struct device_attribute *qla2x00_host_attrs[] = {
qlt_vport_create(vha, ha);
qla24xx_vport_disable(fc_vport, disable);
 
-   if (ha->flags.cpu_affinity_enabled) {
-   req = ha->req_q_map[1];
-   ql_dbg(ql_dbg_multiq, vha, 0xc000,
-   "Request queue %p attached with "
-   "VP[%d], cpu affinity =%d\n",
-   req, vha->vp_idx, ha->flags.cpu_affinity_enabled);
-   goto vport_queue;
-   } else if (ql2xmaxqueues == 1 || !ha->npiv_info)
+   if (!ql2xmqsupport || !ha->npiv_info)
goto vport_queue;
+
/* Create a request queue in QoS mode for the vport */
for (cnt = 0; cnt < ha->nvram_npiv_size; cnt++) {
if (memcmp(ha->npiv_info[cnt].port_name, vha->port_name, 8) == 0
@@ -2095,20 +2089,20 @@ struct device_attribute *qla2x00_host_attrs[] = {
}
 
if (qos) {
-   ret = qla25xx_create_req_que(ha, options, vha->vp_idx, 0, 0,
-   qos);
-   if (!ret)
+   qpair = qla2xxx_create_qpair(vha, qos, vha->vp_idx);
+   if (!qpair)
ql_log(ql_log_warn, vha, 0x7084,
-   "Can't create request queue for VP[%d]\n",
+   "Can't create qpair for VP[%d]\n",
vha->vp_idx);
else {
ql_dbg(ql_dbg_multiq, vha, 0xc001,
-   "Request Que:%d Q0s: %d) created for VP[%d]\n",
-   ret, qos, vha->vp_idx);
+   "Queue pair: %d Qos: %d) created for VP[%d]\n",
+   qpair->id, qos, vha->vp_idx);
ql_dbg(ql_dbg_user, vha, 0x7085,
-   "Request Que:%d Q0s: %d) created for VP[%d]\n",
-   ret, qos, vha->vp_idx);
-   req = ha->req_q_map[ret];
+   "Queue Pair: %d Qos: %d) created for VP[%d]\n",
+   qpair->id, qos, vha->vp_idx);
+   req = qpair->req;
+   vha->qpair = qpair;
}
}
 
@@ -2162,10 +2156,10 @@ struct device_attribute *qla2x00_host_attrs[] = {
clear_bit(vha->vp_idx, 

[PATCH v3 0/6] qla2xxx: Feture updates for driver.

2016-12-02 Thread Himanshu Madhani
Hi Martin,

Please consider this revised series for scsi-misc inclusion
at your earliest convenience.

Changes from v2 --> v3

o Added patch to utilize pci_{alloc|free}_irq_vectors call as per
  Christoph's suggestion.
o Clean up IRQ affinity and drop num_online_cpu() usage in driver
  as per review comments from Hannes & Christoph.
o Added patch description for mailbox starvation patch. Also added
  Reviewed-by signature from Hannes.

Changes from v1 --> v2

o Split up the patches for Multiqueue into infrastucture changes
  and support for adding multiqueue capablity in the driver as
  per Ewan's suggestion.
o Incorporate new pci_irq_alloc_vector call as per Christoph's suggestion.
o To address comments related to Mailbox patches by Ewan, I have
  reworked the patch to clean-up mailbox workqueue.

Thanks,
Himanshu

Himanshu Madhani (1):
  qla2xxx: Only allow operational MBX to proceed during RESET.

Michael Hernandez (3):
  qla2xxx: Utilize pci_alloc_irq_vectors/pci_free_irq_vectors calls.
  qla2xxx: Add multiple queue pair functionality.
  qla2xxx: Add Block Multi Queue functionality.

Quinn Tran (1):
  qla2xxx: Fix Target mode handling with Multiqueue changes.

Samy (1):
  qla2xxx: Fix mailbox command timeout due to starvation

 drivers/scsi/qla2xxx/Makefile |   3 +-
 drivers/scsi/qla2xxx/qla_attr.c   |  36 ++--
 drivers/scsi/qla2xxx/qla_bottom.c | 398 ++
 drivers/scsi/qla2xxx/qla_dbg.c|   4 +-
 drivers/scsi/qla2xxx/qla_def.h| 110 +--
 drivers/scsi/qla2xxx/qla_gbl.h|  32 ++-
 drivers/scsi/qla2xxx/qla_init.c   |  14 +-
 drivers/scsi/qla2xxx/qla_inline.h |  30 +++
 drivers/scsi/qla2xxx/qla_iocb.c   |  56 ++
 drivers/scsi/qla2xxx/qla_isr.c| 196 ---
 drivers/scsi/qla2xxx/qla_mbx.c| 165 +---
 drivers/scsi/qla2xxx/qla_mid.c| 116 +--
 drivers/scsi/qla2xxx/qla_mq.c | 236 ++
 drivers/scsi/qla2xxx/qla_os.c | 329 ++-
 drivers/scsi/qla2xxx/qla_top.c|  95 +
 15 files changed, 1388 insertions(+), 432 deletions(-)
 create mode 100644 drivers/scsi/qla2xxx/qla_bottom.c
 create mode 100644 drivers/scsi/qla2xxx/qla_mq.c
 create mode 100644 drivers/scsi/qla2xxx/qla_top.c

-- 
1.8.3.1

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


[PATCH v3 2/6] qla2xxx: Fix mailbox command timeout due to starvation

2016-12-02 Thread Himanshu Madhani
From: Samy 

This patch helps resolve some of the mailbox timeout issue discovered
during large SAN emulation testing where 1000+ initiators are trying
to log into target mode personality. Since current mailbox interface
handles submission and processing of commands in a sequential order,
command could timeout resulting in some initiator not being able to
log into target.

Reviewed-by: Hannes Reinecke 
Signed-off-by: Samy 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h |  3 ++
 drivers/scsi/qla2xxx/qla_mbx.c | 88 ++
 drivers/scsi/qla2xxx/qla_os.c  | 24 
 3 files changed, 91 insertions(+), 24 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 5236e3f..9a6ddcb 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -3553,6 +3553,9 @@ struct qla_hw_data {
uint32_tidc_audit_ts;
uint32_tidc_extend_tmo;
 
+   /* mail box work queue */
+   struct workqueue_struct *mbx_wq;
+
/* DPC low-priority workqueue */
struct workqueue_struct *dpc_lp_wq;
struct work_struct idc_aen;
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index b31c36b..14068fb 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -10,6 +10,14 @@
 #include 
 #include 
 
+struct mbx_cmd_info_t {
+   mbx_cmd_t   *mcp;
+   scsi_qla_host_t *vha;
+   struct work_struct  work;
+   struct completion   comp;
+   int status;
+};
+
 struct rom_cmd {
uint16_t cmd;
 } rom_cmds[] = {
@@ -68,7 +76,7 @@ static int is_rom_cmd(uint16_t cmd)
  * Kernel context.
  */
 static int
-qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
+__qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
 {
int rval, i;
unsigned longflags = 0;
@@ -140,19 +148,6 @@ static int is_rom_cmd(uint16_t cmd)
return QLA_FUNCTION_TIMEOUT;
}
 
-   /*
-* Wait for active mailbox commands to finish by waiting at most tov
-* seconds. This is to serialize actual issuing of mailbox cmds during
-* non ISP abort time.
-*/
-   if (!wait_for_completion_timeout(>mbx_cmd_comp, mcp->tov * HZ)) {
-   /* Timeout occurred. Return error. */
-   ql_log(ql_log_warn, vha, 0x1005,
-   "Cmd access timeout, cmd=0x%x, Exiting.\n",
-   mcp->mb[0]);
-   return QLA_FUNCTION_TIMEOUT;
-   }
-
ha->flags.mbox_busy = 1;
/* Save mailbox command for debug */
ha->mcp = mcp;
@@ -217,7 +212,7 @@ static int is_rom_cmd(uint16_t cmd)
ql_dbg(ql_dbg_mbx, vha, 0x1010,
"Pending mailbox timeout, exiting.\n");
rval = QLA_FUNCTION_TIMEOUT;
-   goto premature_exit;
+   goto mbx_done;
}
WRT_REG_DWORD(>isp82.hint, HINT_MBX_INT_PENDING);
} else if (IS_FWI2_CAPABLE(ha))
@@ -251,7 +246,7 @@ static int is_rom_cmd(uint16_t cmd)
ql_dbg(ql_dbg_mbx, vha, 0x1012,
"Pending mailbox timeout, exiting.\n");
rval = QLA_FUNCTION_TIMEOUT;
-   goto premature_exit;
+   goto mbx_done;
}
WRT_REG_DWORD(>isp82.hint, HINT_MBX_INT_PENDING);
} else if (IS_FWI2_CAPABLE(ha))
@@ -297,7 +292,7 @@ static int is_rom_cmd(uint16_t cmd)
rval = QLA_FUNCTION_FAILED;
ql_log(ql_log_warn, vha, 0x1015,
"FW hung = %d.\n", ha->flags.isp82xx_fw_hung);
-   goto premature_exit;
+   goto mbx_done;
}
 
if (ha->mailbox_out[0] != MBS_COMMAND_COMPLETE)
@@ -353,7 +348,7 @@ static int is_rom_cmd(uint16_t cmd)
set_bit(PCI_ERR, _vha->dpc_flags);
ha->flags.mbox_busy = 0;
rval = QLA_FUNCTION_TIMEOUT;
-   goto premature_exit;
+   goto mbx_done;
}
 
/* Attempt to capture firmware dump for further
@@ -431,8 +426,6 @@ static int is_rom_cmd(uint16_t cmd)
command, mcp->mb[0]);
set_bit(ABORT_ISP_ACTIVE, >dpc_flags);
clear_bit(ISP_ABORT_NEEDED, >dpc_flags);
-   /* Allow 

[Bug 176951] boot fails unless acpi=off Acer Travelmate X-349

2016-12-02 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=176951

mus@gmail.com changed:

   What|Removed |Added

 CC||mus@gmail.com

--- Comment #6 from mus@gmail.com ---
I can confirm this issue on my Acer Swift 3 Model SF314-51-59RF. Arch Linux x64
with kernel 4.8.11 and 4.9.rc7 hang with a black screen on boot.

However, I can also confirm some reports from this acer thread that this seems
to be a x64 specific issue:

https://community.acer.com/t5/Swift-Spin-S-and-R-Series/Ubuntu-on-Swift-3-SF314-51-74FW-black-screen-after-menu-on-Live/td-p/464481/highlight/true/page/3

I'm typing this from a perfectly fine working Fedora 25 32-Bit Live system with
kernel 4.8.6. The x64 version hangs on boot just like Arch Linux.

btw, there is no BIOS update available for the Swift 3 yet (BIOS version 1.05).

-- 
You are receiving this mail because:
You are watching the assignee of 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: SG does not ignore dxferp (direct io + mmap)

2016-12-02 Thread Ewan D. Milne
On Thu, 2016-12-01 at 08:40 -0500, Martin K. Petersen wrote:
> > "Ewan" == Ewan D Milne  writes:
...
> Specifically, the problem appears to be caused by the removal of
> the setting of bio->bi_bdev, which would previously be set to NULL.
> If I add:
> 
> diff --git a/block/bio.c b/block/bio.c
> index 0723d4c..ecac37b 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -1351,6 +1351,7 @@ struct bio *bio_map_user_iov(struct request_queue
> *q,
> if (iter->type & WRITE)
> bio->bi_rw |= REQ_WRITE;
>  
> +   bio->bi_bdev = NULL;
> bio->bi_flags |= (1 << BIO_USER_MAPPED);
>  
> /*
> 
> Ewan> The test passes (no zero byte corruption).
> 

Adding this seemed to work on top of the commit commit id mentioned
above (37f19e57a0de3c4a3417aa13ff4d04f1e0dee4b3)
but does not help on 4.7, because the test case now takes the
bio_copy_user_iov() code path rather than bio_map_user_iov().

-Ewan



--
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: SG does not ignore dxferp (direct io + mmap)

2016-12-02 Thread Ewan D. Milne
On Fri, 2016-12-02 at 15:10 +0100, Hannes Reinecke wrote:
> On 12/02/2016 02:29 PM, Ewan D. Milne wrote:
> > On Fri, 2016-12-02 at 04:21 -0800, Christoph Hellwig wrote:
> >> On Thu, Dec 01, 2016 at 08:40:31AM -0500, Martin K. Petersen wrote:
> >>> Specifically, the problem appears to be caused by the removal of
> >>> the setting of bio->bi_bdev, which would previously be set to NULL.
> >>> If I add:
> >>
> >> Very odd.  For one I would expect it to be NULL anyway, second
> >> I don't see why the behavior changed.  But given that this reverts
> >> to the original assignment and makes things work I'll happily hack it
> >> to get things working again:
> >>
> >> Acked-by: Christoph Hellwig 
> >
> > Yeah, I'm not sure I understand this either, apart from the change
> > adjusting the code to effectively do what it used to and making the
> > test case work.  I'm reluctant to cc: stable yet, let me look at this
> > a bit more and I'll post the actual patch soon.
> >
> Plus we found that this is basically a timing issue; we've found that 
> supposedly fixed bugs will crop up after ~4k iterations.
> (Johannes did a _lot_ of testing here :-)
> So just because the bug failed to materialize can also mean that you 
> simply didn't test long enough.
> 
Yes, and following the code paths it isn't completely clear how this
leads to the single zero-byte corruption, I am continuing to investigate.
There may very well be more than one problem.

On kernel versions I tested where I got a failure it was a solid
failure, it never worked no matter how many times I tried, but I
did not exhaustively test apparently successful kernel versions.
Not thousands, of times, anyway.

-Ewan


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


Re: [PATCH v2 4/5] qla2xxx: Add Block Multi Queue functionality.

2016-12-02 Thread Madhani, Himanshu
On 12/1/16, 2:25 AM, "Christoph Hellwig"  wrote:



>> -pci_disable_msix(ha->pdev);
>> +pci_free_irq_vectors(ha->pdev);
>
>Please make the switch to pci_alloc_irq_vectors / pci_free_irq_vectors
>a se[arate patch.

Ack. We’ll split up patch. 

>
>> +ret = pci_alloc_irq_vectors(ha->pdev,
>> +MIN_MSIX_COUNT, ha->msix_count, PCI_IRQ_MSIX);
>
>And for proper blk-mq support you must use PCI_IRQ_AFFINITY to get
>the affinity right.

Ack. 

>
>>  /* Recalculate queue values */
>> -if (ql2xmqsupport) {
>> +if (ha->mqiobase && ql2xmqsupport) {
>
>Where is that change coming from?

This change was introduced in previous patch. 
>
>>  cpus = num_online_cpus();
>>  ha->max_req_queues = (ha->msix_count - 1 > cpus) ?
>>  (cpus + 1) : (ha->msix_count - 1);
>> -ha->max_rsp_queues = ha->max_req_queues;
>>  
>>  /* ATIOQ needs 1 vector. That's 1 less QPair */
>>  if (QLA_TGT_MODE_ENABLED())
>>  ha->max_req_queues--;
>
>And don't do your own look at online cpus and queue spreading, that's
>what PCI_IRQ_AFFINITY and blk_mq_pci_map_queues are for.

We’ll update patch with the recommendation. 

>
>>  "MSI: Enabled.\n");
>> @@ -3273,11 +3261,10 @@ struct qla_init_msix_entry {
>>  
>>  if (ha->flags.msix_enabled)
>>  qla24xx_disable_msix(ha);
>> -else if (ha->flags.msi_enabled) {
>> -free_irq(ha->pdev->irq, rsp);
>> -pci_disable_msi(ha->pdev);
>> -} else
>> -free_irq(ha->pdev->irq, rsp);
>> +else {
>> +free_irq(pci_irq_vector(ha->pdev, 0), rsp);
>> +pci_free_irq_vectors(ha->pdev);
>> +}
>
>Please also kill off qla24xx_disable_msix, and have a single
>callsite that iterates over all vectors and finally calls
>pci_free_irq_vectors.

Ack. We’ll update in revised patch.

>
>> -if (ql2xmqsupport) {
>> +if (ql2xmqsupport && ha->max_qpairs) {
>
>Where does this come from?

This was introduced in earlier patch 

>


Re: [PATCH v3 0/3] Add QLogic FastLinQ iSCSI (qedi) driver.

2016-12-02 Thread David Miller
From: "Rangankar, Manish" 
Date: Fri, 2 Dec 2016 07:00:39 +

> Please consider applying the qed patches 1 & 2 to net-next.

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


Re: [PATCH v2 3/5] qla2xxx: Add multiple queue pair functionality.

2016-12-02 Thread Madhani, Himanshu
Hi Hannes, 




On 12/1/16, 12:39 AM, "Hannes Reinecke"  wrote:

>On 11/30/2016 09:24 PM, Himanshu Madhani wrote:
>> From: Michael Hernandez 
>> 
>> Replaced existing multiple queue functionality with framework
>> that allows for the creation of pairs of request and response queues,
>> either at start of day or dynamically.
>> 
>> Signed-off-by: Sawan Chandak 
>> Signed-off-by: Michael Hernandez 
>> Signed-off-by: Himanshu Madhani 
>> ---
>>  drivers/scsi/qla2xxx/Makefile |   3 +-
>>  drivers/scsi/qla2xxx/qla_attr.c   |  36 ++--
>>  drivers/scsi/qla2xxx/qla_bottom.c | 398 
>> ++
>>  drivers/scsi/qla2xxx/qla_dbg.c|   4 +-
>>  drivers/scsi/qla2xxx/qla_def.h| 114 +--
>>  drivers/scsi/qla2xxx/qla_gbl.h|  34 +++-
>>  drivers/scsi/qla2xxx/qla_init.c   |  14 +-
>>  drivers/scsi/qla2xxx/qla_inline.h |  30 +++
>>  drivers/scsi/qla2xxx/qla_iocb.c   |  56 ++
>>  drivers/scsi/qla2xxx/qla_isr.c| 109 +--
>>  drivers/scsi/qla2xxx/qla_mbx.c|  44 +++--
>>  drivers/scsi/qla2xxx/qla_mid.c| 116 +--
>>  drivers/scsi/qla2xxx/qla_mq.c | 279 ++
>>  drivers/scsi/qla2xxx/qla_os.c | 235 +++---
>>  drivers/scsi/qla2xxx/qla_target.c |   4 +
>>  drivers/scsi/qla2xxx/qla_top.c|  95 +
>>  16 files changed, 1230 insertions(+), 341 deletions(-)
>>  create mode 100644 drivers/scsi/qla2xxx/qla_bottom.c
>>  create mode 100644 drivers/scsi/qla2xxx/qla_mq.c
>>  create mode 100644 drivers/scsi/qla2xxx/qla_top.c
>> 
>[ .. ]
>> diff --git a/drivers/scsi/qla2xxx/qla_bottom.c 
>> b/drivers/scsi/qla2xxx/qla_bottom.c
>> new file mode 100644
>> index 000..8bf757e
>> --- /dev/null
>> +++ b/drivers/scsi/qla2xxx/qla_bottom.c
>> @@ -0,0 +1,398 @@
>> +/*
>> + * QLogic Fibre Channel HBA Driver
>> + * Copyright (c)  2016 QLogic Corporation
>> + *
>> + * See LICENSE.qla2xxx for copyright and licensing details.
>> + */
>> +#include "qla_def.h"
>> +
>> +/**
>> + * qla2xxx_start_scsi_mq() - Send a SCSI command to the ISP
>> + * @sp: command to send to the ISP
>> + *
>> + * Returns non-zero if a failure occurred, else zero.
>> + */
>> +
>> +static int
>> +qla2xxx_start_scsi_mq(srb_t *sp)
>> +{
>> +int nseg;
>> +unsigned long   flags;
>> +uint32_t*clr_ptr;
>> +uint32_tindex;
>> +uint32_thandle;
>> +struct cmd_type_7 *cmd_pkt;
>> +uint16_tcnt;
>> +uint16_treq_cnt;
>> +uint16_ttot_dsds;
>> +struct req_que *req = NULL;
>> +struct rsp_que *rsp = NULL;
>> +struct scsi_cmnd *cmd = GET_CMD_SP(sp);
>> +struct scsi_qla_host *vha = sp->fcport->vha;
>> +struct qla_hw_data *ha = vha->hw;
>> +struct qla_qpair *qpair = sp->qpair;
>> +
>> +/* Setup qpair pointers */
>> +rsp = qpair->rsp;
>> +req = qpair->req;
>> +
>> +/* So we know we haven't pci_map'ed anything yet */
>> +tot_dsds = 0;
>> +
>> +/* Send marker if required */
>> +if (vha->marker_needed != 0) {
>> +if (qla2x00_marker(vha, req, rsp, 0, 0, MK_SYNC_ALL) !=
>> +QLA_SUCCESS)
>> +return QLA_FUNCTION_FAILED;
>> +vha->marker_needed = 0;
>> +}
>> +
>> +/* Acquire qpair specific lock */
>> +spin_lock_irqsave(>qp_lock, flags);
>> +
>> +/* Check for room in outstanding command list. */
>> +handle = req->current_outstanding_cmd;
>> +for (index = 1; index < req->num_outstanding_cmds; index++) {
>> +handle++;
>> +if (handle == req->num_outstanding_cmds)
>> +handle = 1;
>> +if (!req->outstanding_cmds[handle])
>> +break;
>> +}
>> +if (index == req->num_outstanding_cmds)
>> +goto queuing_error;
>> +
>> +/* Map the sg table so we have an accurate count of sg entries needed */
>> +if (scsi_sg_count(cmd)) {
>> +nseg = dma_map_sg(>pdev->dev, scsi_sglist(cmd),
>> +scsi_sg_count(cmd), cmd->sc_data_direction);
>> +if (unlikely(!nseg))
>> +goto queuing_error;
>> +} else
>> +nseg = 0;
>> +
>> +tot_dsds = nseg;
>> +req_cnt = qla24xx_calc_iocbs(vha, tot_dsds);
>> +if (req->cnt < (req_cnt + 2)) {
>> +cnt = IS_SHADOW_REG_CAPABLE(ha) ? *req->out_ptr :
>> +RD_REG_DWORD_RELAXED(req->req_q_out);
>> +if (req->ring_index < cnt)
>> +req->cnt = cnt - req->ring_index;
>> +else
>> +req->cnt = req->length -
>> +(req->ring_index - cnt);
>> +if (req->cnt < (req_cnt + 2))
>> +goto queuing_error;
>> +}
>> +
>> +/* Build command packet. */
>> +req->current_outstanding_cmd = handle;
>> +

Re: scsi: use-after-free in bio_copy_from_iter

2016-12-02 Thread Dmitry Vyukov
On Fri, Nov 25, 2016 at 8:08 PM, Dmitry Vyukov  wrote:
> Hello,
>
> The following program triggers use-after-free in bio_copy_from_iter:
> https://gist.githubusercontent.com/dvyukov/80cd94b4e4c288f16ee4c787d404118b/raw/10536069562444da51b758bb39655b514ff93b45/gistfile1.txt
>
>
> ==
> BUG: KASAN: use-after-free in copy_from_iter+0xf30/0x15e0 at addr
> 880062c6e02a
> Read of size 4096 by task a.out/8529
> page:ea00018b1b80 count:2 mapcount:0 mapping:88006c80e9d0 index:0x1695
> flags: 0x5fffc000864(referenced|lru|active|private)
> page dumped because: kasan: bad access detected
> page->mem_cgroup:88003ebcea00
> CPU: 1 PID: 8529 Comm: a.out Not tainted 4.9.0-rc6+ #55
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
>  880039ca6770 834c3bb9 0001 110007394c81
>  ed0007394c79 41b58ab3 89575c30 834c38cb
>    0001 
> Call Trace:
>  [< inline >] __dump_stack lib/dump_stack.c:15
>  [] dump_stack+0x2ee/0x3f5 lib/dump_stack.c:51
>  [< inline >] print_address_description mm/kasan/report.c:211
>  [< inline >] kasan_report_error mm/kasan/report.c:285
>  [] kasan_report+0x418/0x440 mm/kasan/report.c:305
>  [< inline >] check_memory_region_inline mm/kasan/kasan.c:308
>  [] check_memory_region+0x139/0x190 mm/kasan/kasan.c:315
>  [] memcpy+0x23/0x50 mm/kasan/kasan.c:350
>  [] copy_from_iter+0xf30/0x15e0 lib/iov_iter.c:559
>  [] copy_page_from_iter+0x474/0x860 lib/iov_iter.c:614
>  [< inline >] bio_copy_from_iter block/bio.c:1025
>  [] bio_copy_user_iov+0xb50/0xf10 block/bio.c:1226
>  [< inline >] __blk_rq_map_user_iov block/blk-map.c:56
>  [] blk_rq_map_user_iov+0x295/0x930 block/blk-map.c:130
>  [] blk_rq_map_user+0x139/0x1e0 block/blk-map.c:159
>  [< inline >] sg_start_req drivers/scsi/sg.c:1757
>  [] sg_common_write.isra.20+0x12da/0x1b20
> drivers/scsi/sg.c:772
>  [] sg_write+0x78a/0xda0 drivers/scsi/sg.c:675
>  [] __vfs_write+0x65e/0x830 fs/read_write.c:510
>  [] __kernel_write+0xec/0x340 fs/read_write.c:532
>  [] write_pipe_buf+0x19c/0x260 fs/splice.c:814
>  [< inline >] splice_from_pipe_feed fs/splice.c:519
>  [] __splice_from_pipe+0x31f/0x750 fs/splice.c:643
>  [] splice_from_pipe+0x1dc/0x300 fs/splice.c:678
>  [] default_file_splice_write+0x45/0x90 fs/splice.c:826
>  [< inline >] do_splice_from fs/splice.c:868
>  [] direct_splice_actor+0x12a/0x190 fs/splice.c:1035
>  [] splice_direct_to_actor+0x2c6/0x840 fs/splice.c:990
>  [] do_splice_direct+0x2ce/0x470 fs/splice.c:1078
>  [] do_sendfile+0x73f/0x1060 fs/read_write.c:1401
>  [< inline >] SYSC_sendfile64 fs/read_write.c:1456
>  [] SyS_sendfile64+0xee/0x1a0 fs/read_write.c:1448
>  [] entry_SYSCALL_64_fastpath+0x23/0xc6
> arch/x86/entry/entry_64.S:209
> Memory state around the buggy address:
>  880062c6ef00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>  880062c6ef80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>>880062c6f000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>^
>  880062c6f080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>  880062c6f100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> ==
> Disabling lock debugging due to kernel taint
> BUG: unable to handle kernel paging request at 880062c6f000
> IP: [] __memcpy+0x12/0x20 arch/x86/lib/memcpy_64.S:37
> PGD c53d067 [  494.351750] PUD c540067
> PMD 7fdea067 [  494.351750] PTE 800062c6f060
>
> Oops:  [#1] SMP DEBUG_PAGEALLOC KASAN
> Modules linked in:
> CPU: 1 PID: 8529 Comm: a.out Tainted: GB   4.9.0-rc6+ #55
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> task: 88003c54e3c0 task.stack: 880039ca
> RIP: 0010:[]  []
> __memcpy+0x12/0x20 arch/x86/lib/memcpy_64.S:37
> RSP: 0018:880039ca6838  EFLAGS: 00010246
> RAX: 880031b99000 RBX: 1000 RCX: 0006
> RDX:  RSI: 880062c6effa RDI: 880031b99fd0
> RBP: 880039ca6858 R08:  R09: 
> R10: 0200 R11: ed00063733ff R12: 880031b99000
> R13: 880062c6e02a R14: 880039ca6f70 R15: 880039ca6d18
> FS:  7f7a78013700() GS:88003ed0() knlGS:
> CS:  0010 DS:  ES:  CR0: 80050033
> CR2: 880062c6f000 CR3: 6411f000 CR4: 06e0
> Stack:
>  819f0a65 880039ca71a0 1000 2000
>  880039ca6d40 83525d10 41b58ab3 89576240
>  0001  41b58ab3 894d07b0
> Call Trace:
>  [] copy_from_iter+0xf30/0x15e0 lib/iov_iter.c:559
>  [] copy_page_from_iter+0x474/0x860 lib/iov_iter.c:614
>  [< inline >] 

RE: [PATCH 0/2] hpsa: fix rmmod issues

2016-12-02 Thread Don Brace

From: Martin Wilck [mwi...@suse.de]
Sent: Friday, December 02, 2016 12:58 AM
To: Don Brace
Cc: dl-esc-Team ESD Storage Dev Support; iss_storage...@hp.com; 
linux-scsi@vger.kernel.org; James Bottomley; h...@lst.de; h...@suse.de; 
jthumsh...@suse.com
Subject: Re: [PATCH 0/2] hpsa: fix rmmod issues

EXTERNAL EMAIL


On Thu, 2016-12-01 at 23:22 +, Don Brace wrote:
> > -Original Message-
> > From: Martin Wilck [mailto:mwi...@suse.de]
> > Sent: Monday, November 21, 2016 8:04 AM
> > To: Don Brace
> > Cc: dl-esc-Team ESD Storage Dev Support; iss_storage...@hp.com;
> > linux-
> > s...@vger.kernel.org; jbottom...@odin.com; h...@lst.de; h...@suse.de
> > ;
> > Martin Wilck
> > Subject: [PATCH 0/2] hpsa: fix rmmod issues
> >
> > EXTERNAL EMAIL
> >
> >
> > This patch set fixes two issues I encountered when removing the
> > hpsa modules with rmmod.
> >
> > Comments and reviews are welcome.
> >
> > Martin Wilck (2):
> >   hpsa: cleanup sas_phy structures in sysfs when unloading
> >   hpsa: destroy sas transport properties before scsi_host
> >
> >  drivers/scsi/hpsa.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > --
> > 2.10.1
>
> I have both patches applied and I still get stack traces.

Hm,

there must be a difference between 4.9.0 and the SUSE kernel that I
tested with, then. To be certain, you did NOT see a stack trace at
rmmod before applying my patches?

I can see that your trace occurs in a different code path
(bsg_unregister_queue()) than the ones I observed
(sas_port_delete()/sas_phy_delete()). CC'ing Johannes who alluded to a
generic problem in the SCSI stack during our internal discussion.

Anyway, I'll have another look.

Regards
Martin

I do see a stack trace before your patches. You patches have made a difference.
I am not yet sure when they started,. Will have to start doing some more 
investigation also,

Appreciate the help.

Thanks,
Don

>
>
>
> [252338.604903] [ cut here ]
> [252338.627899] WARNING: CPU: 69 PID: 23977 at fs/sysfs/group.c:237
> sysfs_remove_group+0x8e/0x90
> [252338.668726] sysfs group 'power' not found for kobject '5:0:0:0'
> [252338.697526] Modules linked in: hpsa(OE-) scsi_transport_sas(OE)
> ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 nf_conntrack_ipv6
> nf_defrag_ipv6 ipt_REJECT nf_reject_ipv4 nf_conntrack_ipv4
> nf_defrag_ipv4 xt_conntrack nf_conntrack cfg80211 rfkill ebtable_nat
> ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_mangle
> ip6table_security ip6table_raw ip6table_filter ip6_tables
> iptable_mangle iptable_security iptable_raw iptable_filter ip_tables
> osst ch st sb_edac edac_core x86_pkg_temp_thermal coretemp
> crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel lrw
> iTCO_wdt gf128mul glue_helper iTCO_vendor_support ablk_helper cryptd
> pcspkr ioatdma lpc_ich hpwdt hpilo mfd_core dca ipmi_si wmi
> ipmi_msghandler pcc_cpufreq acpi_cpufreq acpi_power_meter uinput
> mgag200 i2c_algo_bit drm_kms_helper syscopyarea
> [252339.038528]  sysfillrect sysimgblt fb_sys_fops ttm drm
> crc32c_intel serio_raw tg3 ptp usb_storage i2c_core pps_core
> dm_mirror dm_region_hash dm_log dm_mod [last unloaded:
> scsi_transport_sas]
> [252339.113923] CPU: 69 PID: 23977 Comm: rmmod Tainted:
> GW  OE   4.9.0-rc71+ #24
> [252339.151296] Hardware name: HP ProLiant DL580 Gen8, BIOS P79
> 08/18/2016
> [252339.183354]  c9000ff1bbf0 815909bd c9000ff1bc40
> 
> [252339.219046]  c9000ff1bc30 81090901 00ed0246
> 
> [252339.255044]  81f71560 88204584dd38 882051e93670
> 00ae1090
> [252339.290927] Call Trace:
> [252339.303968]  [] dump_stack+0x85/0xc8
> [252339.329624]  [] __warn+0xd1/0xf0
> [252339.354037]  [] warn_slowpath_fmt+0x5f/0x80
> [252339.382084]  [] ? mutex_unlock+0xe/0x10
> [252339.408515]  [] ?
> kernfs_find_and_get_ns+0x4a/0x60
> [252339.439571]  [] sysfs_remove_group+0x8e/0x90
> [252339.468069]  [] dpm_sysfs_remove+0x57/0x60
> [252339.495701]  [] device_del+0x58/0x270
> [252339.521474]  [] device_unregister+0x1a/0x60
> [252339.549796]  [] bsg_unregister_queue+0x60/0xa0
> [252339.578999]  [] __scsi_remove_device+0xaa/0xd0
> [252339.608230]  [] scsi_forget_host+0x69/0x70
> [252339.635723]  [] scsi_remove_host+0x82/0x130
> [252339.663738]  [] hpsa_remove_one+0x93/0x190
> [hpsa]
> [252339.694960]  [] pci_device_remove+0x39/0xc0
> [252339.723128]  []
> __device_release_driver+0x9a/0x150
> [252339.753539]  [] driver_detach+0xc1/0xd0
> [252339.779784]  [] bus_remove_driver+0x58/0xd0
> [252339.807519]  [] driver_unregister+0x2c/0x50
> [252339.835948]  [] pci_unregister_driver+0x2a/0x80
> [252339.865660]  [] hpsa_cleanup+0x10/0x7a7 [hpsa]
> [252339.894682]  [] SyS_delete_module+0x1bc/0x220
> [252339.924020]  [] do_syscall_64+0x6c/0x200
> [252339.950862]  []
> entry_SYSCALL64_slow_path+0x25/0x25
> [252339.982292] ---[ end trace 03cf2c42f2f658e5 ]---

--
To unsubscribe from this 

Re: [PATCH] mpt3sas: switch to pci_alloc_irq_vectors

2016-12-02 Thread Hannes Reinecke

On 12/02/2016 03:30 PM, Christoph Hellwig wrote:

+static inline u16
 _base_get_msix_index(struct MPT3SAS_ADAPTER *ioc)
 {
+   return pci_irq_get_affinity_vector(ioc->pdev, raw_smp_processor_id());
 }


This looks extremely sketchy. Are we guaranteed to always have enough
MSI-X vectors that each CPU has it's own?  I'd much prefer to keep the
indirection array of the existing code.


Hmm. Okay. will be doing so.


+static int scsih_map_queues(struct Scsi_Host *shost)
+{
+   struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
+
+   return blk_mq_pci_map_queues(>tag_set, ioc->pdev, 0);
+}


Given that mpt3sas only supports a single hardware queue (and doesn't
set the nr_hw_queues field) this is pointless and won't have any effect.


Well, it does, actually.
But this is part of another patchset enabling 'real' mq support.
I'll be redoing the patch.

Cheers,

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


Re: [PATCH 00/11] Updates for scsi-next

2016-12-02 Thread Tomas Henzl
On 2.12.2016 15:07, Sasikumar Chandrasekaran wrote:
> Sasikumar Chandrasekaran (11):
>   megaraid_sas: Add new pci device Ids for SAS3.5 Generic Megaraid
> Controllers
>   megaraid_sas: 128 MSIX Support
>   megaraid_sas: EEDP Escape Mode Support for SAS3.5 Generic Megaraid
> Controllers
>   megaraid_sas: SAS3.5 Generic Megaraid Controllers Stream Detection and
> IO Coalescing
>   megaraid_sas: SAS3.5 Generic Megaraid Controllers Fast Path for RAID
> 1/10 Writes
>   megaraid_sas: Dynamic Raid Map Changes for SAS3.5 Generic Megaraid
> Controllers
>   megaraid_sas: Add the Support for SAS3.5 Generic Megaraid Controllers
> Capabilities
>   megaraid_sas: Enable or Disable Fast path based on the PCI Threshold
> Bandwidth
>   megaraid_sas: ldio_outstanding variable is not decremented in
> completion path
>   megaraid_sas: Implement the PD Map support for SAS3.5 Generic Megaraid
> Controllers
>   megaraid_sas: driver version upgrade
>
>  drivers/scsi/megaraid/megaraid_sas.h| 139 --
>  drivers/scsi/megaraid/megaraid_sas_base.c   | 242 +++---
>  drivers/scsi/megaraid/megaraid_sas_fp.c | 319 +++--
>  drivers/scsi/megaraid/megaraid_sas_fusion.c | 687 
> 
>  drivers/scsi/megaraid/megaraid_sas_fusion.h | 318 -
>  5 files changed, 1474 insertions(+), 231 deletions(-)
>
Hi Sasikumar,

pleas run the scripts/checkpatch.pl script on your patch before sending,
it shows errors like this one

ERROR: DOS line endings
#80: FILE: drivers/scsi/megaraid/megaraid_sas.h:59:
+#define PCI_DEVICE_ID_LSI_MECTOR^I^I0x00D4^M$

>From my point of view there are too many checkpatch issues and the series
should be fixed.

Also when you resend the series add a version counting string V2 , V3 ...
to the mail subject so -> "[PATCH V2 00/11] Updates for scsi-next"


Thanks,
Tomas

--
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] mpt3sas: switch to pci_alloc_irq_vectors

2016-12-02 Thread Christoph Hellwig
> +static inline u16
>  _base_get_msix_index(struct MPT3SAS_ADAPTER *ioc)
>  {
> + return pci_irq_get_affinity_vector(ioc->pdev, raw_smp_processor_id());
>  }

This looks extremely sketchy. Are we guaranteed to always have enough
MSI-X vectors that each CPU has it's own?  I'd much prefer to keep the
indirection array of the existing code.

> +static int scsih_map_queues(struct Scsi_Host *shost)
> +{
> + struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
> +
> + return blk_mq_pci_map_queues(>tag_set, ioc->pdev, 0);
> +}

Given that mpt3sas only supports a single hardware queue (and doesn't
set the nr_hw_queues field) this is pointless and won't have any effect.
--
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: SG does not ignore dxferp (direct io + mmap)

2016-12-02 Thread Laurence Oberman


- Original Message -
> From: "Hannes Reinecke" 
> To: emi...@redhat.com, "Christoph Hellwig" 
> Cc: "Martin K. Petersen" , "Johannes Thumshirn" 
> , "Laurence Oberman"
> , "Eyal Ben David" , 
> dgilb...@interlog.com, linux-scsi@vger.kernel.org
> Sent: Friday, December 2, 2016 9:10:01 AM
> Subject: Re: SG does not ignore dxferp (direct io + mmap)
> 
> On 12/02/2016 02:29 PM, Ewan D. Milne wrote:
> > On Fri, 2016-12-02 at 04:21 -0800, Christoph Hellwig wrote:
> >> On Thu, Dec 01, 2016 at 08:40:31AM -0500, Martin K. Petersen wrote:
> >>> Specifically, the problem appears to be caused by the removal of
> >>> the setting of bio->bi_bdev, which would previously be set to NULL.
> >>> If I add:
> >>
> >> Very odd.  For one I would expect it to be NULL anyway, second
> >> I don't see why the behavior changed.  But given that this reverts
> >> to the original assignment and makes things work I'll happily hack it
> >> to get things working again:
> >>
> >> Acked-by: Christoph Hellwig 
> >
> > Yeah, I'm not sure I understand this either, apart from the change
> > adjusting the code to effectively do what it used to and making the
> > test case work.  I'm reluctant to cc: stable yet, let me look at this
> > a bit more and I'll post the actual patch soon.
> >
> Plus we found that this is basically a timing issue; we've found that
> supposedly fixed bugs will crop up after ~4k iterations.
> (Johannes did a _lot_ of testing here :-)
> So just because the bug failed to materialize can also mean that you
> simply didn't test long enough.
> 
> Cheers,
> 
> Hannes
> --
> Dr. Hannes Reinecke  Teamlead Storage & Networking
> h...@suse.de +49 911 74053 688
> SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
> GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
> HRB 21284 (AG Nürnberg)
> 
Hannes, 
Just to clarify, my original test reverting  commit 
3fa6c507319c897598512da91c010a4ad2ed682c,
what Ewan originally bisected to and running > 10 iterations never failed.

--
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: SG does not ignore dxferp (direct io + mmap)

2016-12-02 Thread Hannes Reinecke

On 12/02/2016 02:29 PM, Ewan D. Milne wrote:

On Fri, 2016-12-02 at 04:21 -0800, Christoph Hellwig wrote:

On Thu, Dec 01, 2016 at 08:40:31AM -0500, Martin K. Petersen wrote:

Specifically, the problem appears to be caused by the removal of
the setting of bio->bi_bdev, which would previously be set to NULL.
If I add:


Very odd.  For one I would expect it to be NULL anyway, second
I don't see why the behavior changed.  But given that this reverts
to the original assignment and makes things work I'll happily hack it
to get things working again:

Acked-by: Christoph Hellwig 


Yeah, I'm not sure I understand this either, apart from the change
adjusting the code to effectively do what it used to and making the
test case work.  I'm reluctant to cc: stable yet, let me look at this
a bit more and I'll post the actual patch soon.

Plus we found that this is basically a timing issue; we've found that 
supposedly fixed bugs will crop up after ~4k iterations.

(Johannes did a _lot_ of testing here :-)
So just because the bug failed to materialize can also mean that you 
simply didn't test long enough.


Cheers,

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


[PATCH 10/11] megaraid_sas: Implement the PD Map support for SAS3.5 Generic Megaraid Controllers

2016-12-02 Thread Sasikumar Chandrasekaran
Update Linux driver to use new pdTargetId field for JBOD target ID

This patch is depending on patch 9

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas.h| 106 +---
 drivers/scsi/megaraid/megaraid_sas_base.c   |   5 +-
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  11 ++-
 drivers/scsi/megaraid/megaraid_sas_fusion.h |   3 +-
 4 files changed, 94 insertions(+), 31 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 40b8295..e4bb93d 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1320,7 +1320,56 @@ struct megasas_ctrl_info {
 #endif
} adapterOperations3;
 
-   u8  pad[0x800-0x7EC];
+   struct {
+#if defined(__BIG_ENDIAN_BITFIELD)
+   u8 reserved:7;
+   /* Indicates whether the CPLD image is part of
+   *  the package and stored in flash   
+   */
+   u8 cpldInFlash:1;
+#else
+   u8 cpldInFlash:1;
+   u8 reserved:7;
+#endif
+   u8 reserved1[3];
+   /* Null terminated string. Has the version
+   *  information if cpldInFlash = FALSE 
+   */
+   u8 userCodeDefinition[12];
+   } cpld;  /* Valid only if upgradableCPLD is TRUE */
+
+   struct {
+   #if defined(__BIG_ENDIAN_BITFIELD)
+   u16 reserved:8;
+   u16 FWSwapsBBUVPDInfo   :1;
+   u16 supportPdMapTargetId:1;
+   u16 supportSESCtrlInMultipathCfg:1;
+   u16 imageUploadSupported:1;
+   u16 supportEncryptedMfc :1;
+   u16 supportedEncAlgo:1;
+   u16 supportIbuttonLess  :1;
+   u16 ctrlInfoExtSupported:1;
+   #else
+
+   u16 ctrlInfoExtSupported:1;
+   u16 supportIbuttonLess  :1;
+   u16 supportedEncAlgo:1;
+   u16 supportEncryptedMfc :1;
+   u16 imageUploadSupported:1;
+   /* FW supports LUN based association and target port based */
+   u16 supportSESCtrlInMultipathCfg:1;
+   /* association for the SES device connected in multipath mode */
+/* FW defines Jbod target Id within MR_PD_CFG_SEQ */
+   u16 supportPdMapTargetId:1;
+   /* FW swaps relevant fields in MR_BBU_VPD_INFO_FIXED to
+   *  provide the data in little endian order 
+   */
+   u16 FWSwapsBBUVPDInfo   :1;
+   u16 reserved:8;
+   #endif
+   } adapterOperations4;
+
+u8  pad[0x800-0x7FE];  /* 0x7FE pad to 2K for 
expansion */
 } __packed;
 
 /*
@@ -1560,33 +1609,35 @@ struct megasas_header {
 typedef union _MFI_CAPABILITIES {
struct {
 #if   defined(__BIG_ENDIAN_BITFIELD)
-   u32 reserved:20;
-   u32 support_qd_throttling:1;
-   u32 support_fp_rlbypass:1;
-   u32 support_vfid_in_ioframe:1;
-   u32 support_ext_io_size:1;
-   u32 support_ext_queue_depth:1;
-   u32 security_protocol_cmds_fw:1;
-   u32 support_core_affinity:1;
-   u32 support_ndrive_r1_lb:1;
-   u32 support_max_255lds:1;
-   u32 support_fastpath_wb:1;
-   u32 support_additional_msix:1;
-   u32 support_fp_remote_lun:1;
+   u32 reserved:19;
+   u32 supportPdMapTargetId:1;
+   u32 support_qd_throttling:1;
+   u32 support_fp_rlbypass:1;
+   u32 support_vfid_in_ioframe:1;
+   u32 support_ext_io_size:1;
+   u32 support_ext_queue_depth:1;
+   u32 security_protocol_cmds_fw:1;
+   u32 support_core_affinity:1;
+   u32 support_ndrive_r1_lb:1;
+   u32 support_max_255lds:1;
+   u32 support_fastpath_wb:1;
+   u32 support_additional_msix:1;
+   u32 support_fp_remote_lun:1;
 #else
-   u32 support_fp_remote_lun:1;
-   u32 support_additional_msix:1;
-   u32 support_fastpath_wb:1;
-   u32 support_max_255lds:1;
-   u32 support_ndrive_r1_lb:1;
-   u32 support_core_affinity:1;
-   u32 security_protocol_cmds_fw:1;
-   u32 support_ext_queue_depth:1;
-   u32 support_ext_io_size:1;
-   u32 support_vfid_in_ioframe:1;
-   u32 support_fp_rlbypass:1;
-   u32 support_qd_throttling:1;
-   u32 reserved:20;
+   u32 support_fp_remote_lun:1;
+   u32 support_additional_msix:1;
+   u32 support_fastpath_wb:1;
+   u32 support_max_255lds:1;
+   u32 support_ndrive_r1_lb:1;
+   u32 

[PATCH 11/11] megaraid_sas: driver version upgrade

2016-12-02 Thread Sasikumar Chandrasekaran
Upgrade driver version.

This patch is depending on patch 10

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index e4bb93d..bc5e042 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -35,8 +35,8 @@
 /*
  * MegaRAID SAS Driver meta data
  */
-#define MEGASAS_VERSION"06.812.07.00-rc1"
-#define MEGASAS_RELDATE"August 22, 2016"
+#define MEGASAS_VERSION"07.700.00.00-rc1"
+#define MEGASAS_RELDATE"November 29, 2016"
 
 /*
  * Device IDs
-- 
1.8.3.1

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


[PATCH 00/11] Updates for scsi-next

2016-12-02 Thread Sasikumar Chandrasekaran

Sasikumar Chandrasekaran (11):
  megaraid_sas: Add new pci device Ids for SAS3.5 Generic Megaraid
Controllers
  megaraid_sas: 128 MSIX Support
  megaraid_sas: EEDP Escape Mode Support for SAS3.5 Generic Megaraid
Controllers
  megaraid_sas: SAS3.5 Generic Megaraid Controllers Stream Detection and
IO Coalescing
  megaraid_sas: SAS3.5 Generic Megaraid Controllers Fast Path for RAID
1/10 Writes
  megaraid_sas: Dynamic Raid Map Changes for SAS3.5 Generic Megaraid
Controllers
  megaraid_sas: Add the Support for SAS3.5 Generic Megaraid Controllers
Capabilities
  megaraid_sas: Enable or Disable Fast path based on the PCI Threshold
Bandwidth
  megaraid_sas: ldio_outstanding variable is not decremented in
completion path
  megaraid_sas: Implement the PD Map support for SAS3.5 Generic Megaraid
Controllers
  megaraid_sas: driver version upgrade

 drivers/scsi/megaraid/megaraid_sas.h| 139 --
 drivers/scsi/megaraid/megaraid_sas_base.c   | 242 +++---
 drivers/scsi/megaraid/megaraid_sas_fp.c | 319 +++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 687 
 drivers/scsi/megaraid/megaraid_sas_fusion.h | 318 -
 5 files changed, 1474 insertions(+), 231 deletions(-)

-- 
1.8.3.1

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


[PATCH 05/11] megaraid_sas: SAS3.5 Generic Megaraid Controllers Fast Path for RAID 1/10 Writes

2016-12-02 Thread Sasikumar Chandrasekaran
To improve RAID 1/10 Write performance, OS drivers need to issue the required 
Write
IOs as Fast Path IOs (after the appropriate checks allowing Fast Path to be 
used)
to the appropriate physical drives (translated from the OS logical IO) and wait 
for
all Write IOs to complete.  If any of the Write IOs fail or time out, the IO 
will be
re issued to FW as an LD IO so FW can perform the error handling.

This patch is depending on patch 4

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas.h|   1 +
 drivers/scsi/megaraid/megaraid_sas_fp.c |  32 ++-
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 325 
 drivers/scsi/megaraid/megaraid_sas_fusion.h |  15 +-
 4 files changed, 317 insertions(+), 56 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index ee6bd5c..9263ba3 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2059,6 +2059,7 @@ struct megasas_instance {
 
u16 max_num_sge;
u16 max_fw_cmds;
+   u16 max_mpt_cmds;
u16 max_mfi_cmds;
u16 max_scsi_cmds;
u16 ldio_threshold;
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c 
b/drivers/scsi/megaraid/megaraid_sas_fp.c
index d9483bc..5922d15 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -737,7 +737,7 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance 
*instance, u32 ld,
struct MR_DRV_RAID_MAP_ALL *map)
 {
struct MR_LD_RAID  *raid = MR_LdRaidGet(ld, map);
-   u32 pd, arRef;
+   u32 pd, arRef, r1_alt_pd;
u8  physArm, span;
u64 row;
u8  retval = TRUE;
@@ -772,9 +772,15 @@ static u8 mr_spanset_get_phy_params(struct 
megasas_instance *instance, u32 ld,
arRef   = MR_LdSpanArrayGet(ld, span, map);
pd  = MR_ArPdGet(arRef, physArm, map);
 
-   if (pd != MR_PD_INVALID)
+   if (pd != MR_PD_INVALID) {
*pDevHandle = MR_PdDevHandleGet(pd, map);
-   else {
+   /* get second pd also for raid 1/10 fast path writes*/
+   if (raid->level == 1) {
+   r1_alt_pd = MR_ArPdGet(arRef, physArm + 1, map);
+   if (r1_alt_pd != MR_PD_INVALID)
+   io_info->r1_alt_dev_handle = 
MR_PdDevHandleGet(r1_alt_pd, map);
+   }
+   } else {
*pDevHandle = cpu_to_le16(MR_PD_INVALID);
if ((raid->level >= 5) &&
((fusion->adapter_type == THUNDERBOLT_SERIES)  ||
@@ -819,7 +825,7 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 
ld, u64 stripRow,
struct MR_DRV_RAID_MAP_ALL *map)
 {
struct MR_LD_RAID  *raid = MR_LdRaidGet(ld, map);
-   u32 pd, arRef;
+   u32 pd, arRef, r1_alt_pd;
u8  physArm, span;
u64 row;
u8  retval = TRUE;
@@ -867,10 +873,15 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 
ld, u64 stripRow,
arRef   = MR_LdSpanArrayGet(ld, span, map);
pd  = MR_ArPdGet(arRef, physArm, map); /* Get the pd */
 
-   if (pd != MR_PD_INVALID)
-   /* Get dev handle from Pd. */
-   *pDevHandle = MR_PdDevHandleGet(pd, map);
-   else {
+   if (pd != MR_PD_INVALID) {
+   *pDevHandle = MR_PdDevHandleGet(pd, map); /* Get dev handle 
from Pd. */
+   /* get second pd also for raid 1/10 fast path writes*/
+   if (raid->level == 1) {
+   r1_alt_pd = MR_ArPdGet(arRef, physArm + 1, map);
+   if (r1_alt_pd != MR_PD_INVALID)
+   io_info->r1_alt_dev_handle = 
MR_PdDevHandleGet(r1_alt_pd, map);
+   }
+   } else {
/* set dev handle as invalid. */
*pDevHandle = cpu_to_le16(MR_PD_INVALID);
if ((raid->level >= 5) &&
@@ -1126,6 +1137,11 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, 
u32 ld, u64 stripRow,
/* If IO on an invalid Pd, then FP is not possible.*/
if (io_info->devHandle == cpu_to_le16(MR_PD_INVALID))
io_info->fpOkForIo = FALSE;
+   /* set raid 1/10 fast path write capable bit in io_info */
+   if (io_info->fpOkForIo &&
+   (io_info->r1_alt_dev_handle != MR_PD_INVALID) &&
+   (raid->level == 1) && !isRead)
+   io_info->isRaid_1_fp_write = 1;
return retval;
} else if (isRead) {
uint stripIdx;
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 3ad929b..116f300 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ 

[PATCH 08/11] megaraid_sas: Enable or Disable Fast path based on the PCI Threshold Bandwidth

2016-12-02 Thread Sasikumar Chandrasekaran
Large SEQ IO workload should sent as non fast path commands

This patch is depending on patch 7

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas.h|  8 +
 drivers/scsi/megaraid/megaraid_sas_base.c   | 49 +
 drivers/scsi/megaraid/megaraid_sas_fp.c | 21 -
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 20 +++-
 drivers/scsi/megaraid/megaraid_sas_fusion.h |  5 +--
 5 files changed, 86 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 2da47b9..40b8295 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1432,6 +1432,8 @@ enum FW_BOOT_CONTEXT {
 #define MFI_1068_FW_HANDSHAKE_OFFSET   0x64
 #define MFI_1068_FW_READY  0x
 
+#define MEGASAS_RAID1_FAST_PATH_STATUS_CHECK_INTERVAL HZ
+
 #define MR_MAX_REPLY_QUEUES_OFFSET  0X001F
 #define MR_MAX_REPLY_QUEUES_EXT_OFFSET  0X003FC000
 #define MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT14
@@ -2104,6 +2106,10 @@ struct megasas_instance {
atomic_t ldio_outstanding;
atomic_t fw_reset_no_pci_access;
 
+   atomic64_t bytes_wrote; /* used for raid1 fast path enable or disable */
+   atomic_t r1_write_fp_capable;
+
+
struct megasas_instance_template *instancet;
struct tasklet_struct isr_tasklet;
struct work_struct work_init;
@@ -2146,6 +2152,7 @@ struct megasas_instance {
long reset_flags;
struct mutex reset_mutex;
struct timer_list sriov_heartbeat_timer;
+   struct timer_list r1_fp_hold_timer;
char skip_heartbeat_timer_del;
u8 requestorId;
char PlasmaFW111;
@@ -2162,6 +2169,7 @@ struct megasas_instance {
bool is_ventura;
bool msix_combined;
u16 maxRaidMapSize;
+   u64  pci_threshold_bandwidth; /* used to control the fp writes */
 };
 struct MR_LD_VF_MAP {
u32 size;
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index cfd379a..be11e9d 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1943,6 +1943,9 @@ void megaraid_sas_kill_hba(struct megasas_instance 
*instance)
}
/* Complete outstanding ioctls when adapter is killed */
megasas_complete_outstanding_ioctls(instance);
+   if (instance->is_ventura)
+   del_timer_sync(>r1_fp_hold_timer);
+
 }
 
  /**
@@ -2441,6 +2444,24 @@ void megasas_sriov_heartbeat_handler(unsigned long 
instance_addr)
}
 }
 
+/*Handler for disabling/enabling raid 1 fast paths*/
+void megasas_change_r1_fp_status(unsigned long instance_addr)
+{
+   struct megasas_instance *instance =
+   (struct megasas_instance *)instance_addr;
+   if (atomic64_read(>bytes_wrote) >=
+   instance->pci_threshold_bandwidth) {
+
+   atomic64_set(>bytes_wrote, 0);
+   atomic_set(>r1_write_fp_capable, 0);
+   } else {
+   atomic64_set(>bytes_wrote, 0);
+   atomic_set(>r1_write_fp_capable, 1);
+   }
+   mod_timer(>r1_fp_hold_timer,
+   jiffies + 
MEGASAS_RAID1_FAST_PATH_STATUS_CHECK_INTERVAL);
+}
+
 /**
  * megasas_wait_for_outstanding -  Wait for all outstanding cmds
  * @instance:  Adapter soft state
@@ -5367,6 +5388,18 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
instance->skip_heartbeat_timer_del = 1;
}
 
+   if (instance->is_ventura) {
+   atomic64_set(>bytes_wrote, 0);
+   atomic_set(>r1_write_fp_capable, 1);
+   megasas_start_timer(instance,
+   >r1_fp_hold_timer,
+   megasas_change_r1_fp_status,
+   MEGASAS_RAID1_FAST_PATH_STATUS_CHECK_INTERVAL);
+   dev_info(>pdev->dev, "starting the raid 1 fp timer"
+   " with interval %d \n",
+   MEGASAS_RAID1_FAST_PATH_STATUS_CHECK_INTERVAL);
+   }
+
return 0;
 
 fail_get_ld_pd_list:
@@ -6160,6 +6193,9 @@ static void megasas_shutdown_controller(struct 
megasas_instance *instance,
if (instance->requestorId && !instance->skip_heartbeat_timer_del)
del_timer_sync(>sriov_heartbeat_timer);
 
+   if (instance->is_ventura)
+   del_timer_sync(>r1_fp_hold_timer);
+
megasas_flush_cache(instance);
megasas_shutdown_controller(instance, MR_DCMD_HIBERNATE_SHUTDOWN);
 
@@ -6279,6 +6315,16 @@ static void megasas_shutdown_controller(struct 
megasas_instance *instance,
megasas_setup_jbod_map(instance);
instance->unload = 0;
 
+   if (instance->is_ventura) {
+   atomic64_set(>bytes_wrote, 0);
+   

[PATCH 03/11] megaraid_sas: EEDP Escape Mode Support for SAS3.5 Generic Megaraid Controllers

2016-12-02 Thread Sasikumar Chandrasekaran
An UNMAP command on a PI formatted device will leave the Logical Block 
Application
Tag and Logical Block Reference Tag as all F's (for those LBAs that are 
unmapped).
To avoid IO errors if those LBAs are subsequently read before they are written 
with
valid tag fields, the MPI SCSI IO requests need to set the EEDPFlags element 
EEDP
Escape Mode field, Bits [7:6] appropriately.  A value of 2 should be set to 
disable
all PI checks if the Logical Block Application Tag is 0x for PI types 1 and 
2.
A value of 3 should be set to disable all PI checks if the Logical Block 
Application
Tag is 0x and the Logical Block Reference Tag is 0x for PI type 3.

This patch is depending on patch 2

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 +
 drivers/scsi/megaraid/megaraid_sas_fusion.h | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 9de9e66..7f26b14 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -1589,6 +1589,7 @@ static int megasas_create_sg_sense_fusion(struct 
megasas_instance *instance)
MPI2_SCSIIO_EEDPFLAGS_CHECK_REFTAG |
MPI2_SCSIIO_EEDPFLAGS_CHECK_REMOVE_OP |
MPI2_SCSIIO_EEDPFLAGS_CHECK_APPTAG |
+   MPI25_SCSIIO_EEDPFLAGS_DO_NOT_DISABLE_MODE |
MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD);
} else {
io_request->EEDPFlags = cpu_to_le16(
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h 
b/drivers/scsi/megaraid/megaraid_sas_fusion.h
index e3bee04..9d22ade 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
@@ -175,6 +175,8 @@ enum REGION_TYPE {
 #define MPI2_SCSIIO_EEDPFLAGS_CHECK_APPTAG  (0x0200)
 #define MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD   (0x0100)
 #define MPI2_SCSIIO_EEDPFLAGS_INSERT_OP (0x0004)
+/* EEDP escape mode */
+#define MPI25_SCSIIO_EEDPFLAGS_DO_NOT_DISABLE_MODE  (0x0040)
 #define MPI2_FUNCTION_SCSI_IO_REQUEST   (0x00) /* SCSI IO */
 #define MPI2_FUNCTION_SCSI_TASK_MGMT(0x01)
 #define MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY   (0x03)
-- 
1.8.3.1

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


[PATCH 09/11] megaraid_sas: ldio_outstanding variable is not decremented in completion path

2016-12-02 Thread Sasikumar Chandrasekaran
ldio outstanding variable needs to be decremented in io completion path for
iMR dual queue depth

This patch is depending on patch 8

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 3aab189..e8016bc 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -2558,8 +2558,6 @@ void megasas_prepare_secondRaid1_IO(struct 
megasas_instance *instance,
 
if (atomic_inc_return(>fw_outstanding) >
instance->host->can_queue) {
-   dev_err(>pdev->dev, "Throttle IOs beyond"
-   "Controller queue depth\n");
atomic_dec(>fw_outstanding);
return SCSI_MLQUEUE_HOST_BUSY;
}
@@ -2786,6 +2784,8 @@ void megasas_prepare_secondRaid1_IO(struct 
megasas_instance *instance,
extStatus, data_length, sense);
scsi_io_req->RaidContext.raid_context.status = 
0;
scsi_io_req->RaidContext.raid_context.exStatus 
= 0;
+   if (instance->ldio_threshold && 
megasas_cmd_type(scmd_local) == READ_WRITE_LDIO)
+   atomic_dec(>ldio_outstanding);
megasas_return_cmd_fusion(instance, cmd_fusion);
scsi_dma_unmap(scmd_local);
scmd_local->scsi_done(scmd_local);
@@ -3931,7 +3931,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int 
reason)
scmd_local->result =
megasas_check_mpio_paths(instance,
scmd_local);
-   if (megasas_cmd_type(scmd_local) == 
READ_WRITE_LDIO)
+   if (instance->ldio_threshold && 
megasas_cmd_type(scmd_local) == READ_WRITE_LDIO)
atomic_dec(>ldio_outstanding);
megasas_return_cmd_fusion(instance, cmd_fusion);
scsi_dma_unmap(scmd_local);
-- 
1.8.3.1

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


[PATCH 07/11] megaraid_sas: Add the Support for SAS3.5 Generic Megaraid Controllers Capabilities

2016-12-02 Thread Sasikumar Chandrasekaran
The Megaraid driver has to support the SAS3.5 Generic Megaraid Controllers 
Firmware functionality.

This patch is depending on patch 6

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas_base.c   | 53 ++---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 18 +-
 drivers/scsi/megaraid/megaraid_sas_fusion.h |  1 +
 3 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index b74609c..cfd379a 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -5058,34 +5058,29 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
 
reg_set = instance->reg_set;
 
-   switch (instance->pdev->device) {
-   case PCI_DEVICE_ID_LSI_FUSION:
-   case PCI_DEVICE_ID_LSI_PLASMA:
-   case PCI_DEVICE_ID_LSI_INVADER:
-   case PCI_DEVICE_ID_LSI_FURY:
-   case PCI_DEVICE_ID_LSI_INTRUDER:
-   case PCI_DEVICE_ID_LSI_INTRUDER_24:
-   case PCI_DEVICE_ID_LSI_CUTLASS_52:
-   case PCI_DEVICE_ID_LSI_CUTLASS_53:
+   if (fusion)
instance->instancet = _instance_template_fusion;
-   break;
-   case PCI_DEVICE_ID_LSI_SAS1078R:
-   case PCI_DEVICE_ID_LSI_SAS1078DE:
-   instance->instancet = _instance_template_ppc;
-   break;
-   case PCI_DEVICE_ID_LSI_SAS1078GEN2:
-   case PCI_DEVICE_ID_LSI_SAS0079GEN2:
-   instance->instancet = _instance_template_gen2;
-   break;
-   case PCI_DEVICE_ID_LSI_SAS0073SKINNY:
-   case PCI_DEVICE_ID_LSI_SAS0071SKINNY:
-   instance->instancet = _instance_template_skinny;
-   break;
-   case PCI_DEVICE_ID_LSI_SAS1064R:
-   case PCI_DEVICE_ID_DELL_PERC5:
-   default:
-   instance->instancet = _instance_template_xscale;
-   break;
+   else {
+   switch (instance->pdev->device) {
+   case PCI_DEVICE_ID_LSI_SAS1078R:
+   case PCI_DEVICE_ID_LSI_SAS1078DE:
+   instance->instancet = _instance_template_ppc;
+   break;
+   case PCI_DEVICE_ID_LSI_SAS1078GEN2:
+   case PCI_DEVICE_ID_LSI_SAS0079GEN2:
+   instance->instancet = _instance_template_gen2;
+   break;
+   case PCI_DEVICE_ID_LSI_SAS0073SKINNY:
+   case PCI_DEVICE_ID_LSI_SAS0071SKINNY:
+   instance->instancet = _instance_template_skinny;
+   break;
+   case PCI_DEVICE_ID_LSI_SAS1064R:
+   case PCI_DEVICE_ID_DELL_PERC5:
+   default:
+   instance->instancet = _instance_template_xscale;
+   instance->pd_list_not_supported = 1;
+   break;
+   }
}
 
if (megasas_transition_to_ready(instance, 0)) {
@@ -5827,7 +5822,9 @@ static int megasas_probe_one(struct pci_dev *pdev,
if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
(instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA))
fusion->adapter_type = THUNDERBOLT_SERIES;
-   else if (!instance->is_ventura)
+   else if (instance->is_ventura)
+   fusion->adapter_type = VENTURA_SERIES;
+   else
fusion->adapter_type = INVADER_SERIES;
}
break;
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index e0b188d..331cacd 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -244,7 +244,9 @@ inline void megasas_return_cmd_fusion(struct 
megasas_instance *instance,
 
reg_set = instance->reg_set;
 
-   cur_max_fw_cmds = readl(>reg_set->outbound_scratch_pad_3) & 
0x00;
+   /* ventura FW does not fill outbound_scratch_pad_3 with queue depth */
+   if (!instance->is_ventura)
+   cur_max_fw_cmds = 
readl(>reg_set->outbound_scratch_pad_3) & 0x00;
 
if (dual_qdepth_disable || !cur_max_fw_cmds)
cur_max_fw_cmds = 
instance->instancet->read_fw_status_reg(reg_set) & 0x00;
@@ -842,7 +844,7 @@ static int megasas_create_sg_sense_fusion(struct 
megasas_instance *instance)
drv_ops = (MFI_CAPABILITIES *) &(init_frame->driver_operations);
 
/* driver support Extended MSIX */
-   if (fusion->adapter_type == INVADER_SERIES)
+   if (fusion->adapter_type >= INVADER_SERIES)
drv_ops->mfi_capabilities.support_additional_msix = 1;
/* driver supports HA / Remote LUN over Fast Path interface */
drv_ops->mfi_capabilities.support_fp_remote_lun = 1;
@@ -1496,7 +1498,7 @@ static int 

[PATCH 04/11] megaraid_sas: SAS3.5 Generic Megaraid Controllers Stream Detection and IO Coalescing

2016-12-02 Thread Sasikumar Chandrasekaran
Detect sequential IO streams and pass those IOs directly to FW.

This patch is depending on patch 3

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas.h|   1 +
 drivers/scsi/megaraid/megaraid_sas_base.c   |  40 +++-
 drivers/scsi/megaraid/megaraid_sas_fp.c |   2 +
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 151 +++-
 drivers/scsi/megaraid/megaraid_sas_fusion.h | 123 +-
 5 files changed, 287 insertions(+), 30 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index af94f58..ee6bd5c 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2073,6 +2073,7 @@ struct megasas_instance {
/* used to sync fire the cmd to fw */
spinlock_t hba_lock;
/* used to synch producer, consumer ptrs in dpc */
+   spinlock_t stream_lock;
spinlock_t completion_lock;
struct dma_pool *frame_dma_pool;
struct dma_pool *sense_dma_pool;
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 7c8c313..86f25d5 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -5018,7 +5018,7 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
struct megasas_register_set __iomem *reg_set;
struct megasas_ctrl_info *ctrl_info = NULL;
unsigned long bar_list;
-   int i, loop, fw_msix_count = 0;
+   int i, j, loop, fw_msix_count = 0;
struct IOV_111 *iovPtr;
struct fusion_context *fusion;
 
@@ -5205,6 +5205,33 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
}
 
memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS);
+
+   /* stream detection initialization */
+   if (instance->is_ventura) {
+   fusion->streamDetectByLD =
+   kzalloc(sizeof(PTR_LD_STREAM_DETECT) * MAX_LOGICAL_DRIVES_EXT,
+   GFP_KERNEL);
+   if (!fusion->streamDetectByLD) {
+   dev_err(>pdev->dev,
+   "unable to allocate stream detection 
for pool of LDs\n");
+   goto fail_get_ld_pd_list;
+   }
+   for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i) {
+   fusion->streamDetectByLD[i] =
+   kmalloc(sizeof(LD_STREAM_DETECT), GFP_KERNEL);
+   if (!fusion->streamDetectByLD[i]) {
+   dev_err(>pdev->dev,
+   "unable to allocate stream detect by 
LD\n ");
+for (j = 0; j < i; ++j)
+   kfree(fusion->streamDetectByLD[j]);
+   kfree(fusion->streamDetectByLD);
+   fusion->streamDetectByLD = NULL;
+   goto fail_get_ld_pd_list;
+   }
+   fusion->streamDetectByLD[i]->mruBitMap = 
MR_STREAM_BITMAP;
+   }
+   }
+
if (megasas_ld_list_query(instance,
  MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
megasas_get_ld_list(instance);
@@ -5324,6 +5351,8 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
 
return 0;
 
+fail_get_ld_pd_list:
+   instance->instancet->disable_intr(instance);
 fail_get_pd_list:
instance->instancet->disable_intr(instance);
megasas_destroy_irqs(instance);
@@ -5860,6 +5889,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
 
spin_lock_init(>mfi_pool_lock);
spin_lock_init(>hba_lock);
+   spin_lock_init(>stream_lock);
spin_lock_init(>completion_lock);
 
mutex_init(>reset_mutex);
@@ -6360,6 +6390,14 @@ static void megasas_detach_one(struct pci_dev *pdev)
if (instance->msix_vectors)
pci_disable_msix(instance->pdev);
 
+   if (instance->is_ventura) {
+   for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i)
+   kfree(fusion->streamDetectByLD[i]);
+   kfree(fusion->streamDetectByLD);
+   fusion->streamDetectByLD = NULL;
+   }
+
+
if (instance->ctrl_context) {
megasas_release_fusion(instance);
pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c 
b/drivers/scsi/megaraid/megaraid_sas_fp.c
index f237d00..d9483bc 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -935,6 +935,8 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 
ld, u64 stripRow,
 
ld = MR_TargetIdToLdGet(ldTgtId, map);
raid = MR_LdRaidGet(ld, map);
+   /*check read ahead bit*/
+   io_info->raCapable 

[PATCH 06/11] megaraid_sas: Dynamic Raid Map Changes for SAS3.5 Generic Megaraid Controllers

2016-12-02 Thread Sasikumar Chandrasekaran
SAS3.5 Generic Megaraid Controllers FW will support new dynamic RaidMap to have 
different
sizes for different number of supported VDs.

This patch is depending on patch 5

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas.h|   7 +
 drivers/scsi/megaraid/megaraid_sas_base.c   |  57 --
 drivers/scsi/megaraid/megaraid_sas_fp.c | 278 +---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 148 ++-
 drivers/scsi/megaraid/megaraid_sas_fusion.h | 177 +-
 5 files changed, 602 insertions(+), 65 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 9263ba3..2da47b9 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1437,6 +1437,12 @@ enum FW_BOOT_CONTEXT {
 #define MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT14
 #define MR_MAX_MSIX_REG_ARRAY   16
 #define MR_RDPQ_MODE_OFFSET0X0080
+
+#define MR_MAX_RAID_MAP_SIZE_OFFSET_SHIFT  16
+#define MR_MAX_RAID_MAP_SIZE_MASK  0x1FF
+#define MR_MIN_MAP_SIZE0x1
+/* 64k */
+
 #define MR_CAN_HANDLE_SYNC_CACHE_OFFSET0X0100
 
 /*
@@ -2155,6 +2161,7 @@ struct megasas_instance {
bool fw_sync_cache_support;
bool is_ventura;
bool msix_combined;
+   u16 maxRaidMapSize;
 };
 struct MR_LD_VF_MAP {
u32 size;
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 86f25d5..b74609c 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4427,8 +4427,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance)
 static void megasas_update_ext_vd_details(struct megasas_instance *instance)
 {
struct fusion_context *fusion;
-   u32 old_map_sz;
-   u32 new_map_sz;
+   u32 ventura_map_sz = 0;
 
fusion = instance->ctrl_context;
/* For MFI based controllers return dummy success */
@@ -4458,21 +4457,37 @@ static void megasas_update_ext_vd_details(struct 
megasas_instance *instance)
instance->supportmax256vd ? "Extended VD(240 VD)firmware" :
"Legacy(64 VD) firmware");
 
-   old_map_sz = sizeof(struct MR_FW_RAID_MAP) +
-   (sizeof(struct MR_LD_SPAN_MAP) *
-   (instance->fw_supported_vd_count - 1));
-   new_map_sz = sizeof(struct MR_FW_RAID_MAP_EXT);
-   fusion->drv_map_sz = sizeof(struct MR_DRV_RAID_MAP) +
-   (sizeof(struct MR_LD_SPAN_MAP) *
-   (instance->drv_supported_vd_count - 1));
-
-   fusion->max_map_sz = max(old_map_sz, new_map_sz);
+   if (instance->maxRaidMapSize) {
+   ventura_map_sz = instance->maxRaidMapSize *
+   MR_MIN_MAP_SIZE; /* 64k */
+   fusion->current_map_sz = ventura_map_sz;
+   fusion->max_map_sz = ventura_map_sz;
+   } else {
+   fusion->old_map_sz =  sizeof(struct MR_FW_RAID_MAP) +
+   (sizeof(struct MR_LD_SPAN_MAP) *
+   (instance->fw_supported_vd_count - 1));
+   fusion->new_map_sz =  sizeof(struct MR_FW_RAID_MAP_EXT);
 
+   fusion->max_map_sz = max(fusion->old_map_sz, 
fusion->new_map_sz);
 
-   if (instance->supportmax256vd)
-   fusion->current_map_sz = new_map_sz;
-   else
-   fusion->current_map_sz = old_map_sz;
+   if (instance->supportmax256vd)
+   fusion->current_map_sz = fusion->new_map_sz;
+   else
+   fusion->current_map_sz = fusion->old_map_sz;
+   }
+   /* irrespective of FW raid maps, driver raid map is constant */
+   fusion->drv_map_sz = sizeof(struct MR_DRV_RAID_MAP_ALL);
+#if VD_EXT_DEBUG
+   dev_info(>pdev->dev, "instance->maxRaidMapSize 0x%x \n ",
+   instance->maxRaidMapSize);
+   dev_info(>pdev->dev,
+   "new_map_sz = 0x%x, old_map_sz = 0x%x, "
+   "ventura_map_sz = 0x%x, current_map_sz = 0x%x "
+   "fusion->drv_map_sz =0x%x, size of driver raid 
map 0x%lx\n",
+   fusion->new_map_sz, fusion->old_map_sz,
+   ventura_map_sz, fusion->current_map_sz,
+   fusion->drv_map_sz, sizeof(struct 
MR_DRV_RAID_MAP_ALL));
+#endif
 }
 
 /**
@@ -5013,7 +5028,7 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
 {
u32 max_sectors_1;
u32 max_sectors_2;
-   u32 tmp_sectors, msix_enable, scratch_pad_2;
+   u32 tmp_sectors, msix_enable, scratch_pad_2, scratch_pad_3;
resource_size_t 

[PATCH 02/11] megaraid_sas: 128 MSIX Support

2016-12-02 Thread Sasikumar Chandrasekaran
SAS3.5 Generic Megaraid based Controllers will have the support for 128 MSI-X 
vectors,
resulting in the need to support 128 reply queues

This patch is depending on patch 1

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas.h|  1 +
 drivers/scsi/megaraid/megaraid_sas_base.c   | 24 +---
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  4 ++--
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index f24ce88..af94f58 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2152,6 +2152,7 @@ struct megasas_instance {
bool dev_handle;
bool fw_sync_cache_support;
bool is_ventura;
+   bool msix_combined;
 };
 struct MR_LD_VF_MAP {
u32 size;
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index b7166b8..7c8c313 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -5089,13 +5089,7 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
goto fail_ready_state;
}
 
-   /*
-* MSI-X host index 0 is common for all adapter.
-* It is used for all MPT based Adapters.
-*/
-   instance->reply_post_host_index_addr[0] =
-   (u32 __iomem *)((u8 __iomem *)instance->reg_set +
-   MPI2_REPLY_POST_HOST_INDEX_OFFSET);
+
 
/* Check if MSI-X is supported while in ready state */
msix_enable = (instance->instancet->read_fw_status_reg(reg_set) &
@@ -5113,6 +5107,9 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
instance->msix_vectors = ((scratch_pad_2
& MR_MAX_REPLY_QUEUES_EXT_OFFSET)
>> 
MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT) + 1;
+   if (instance->msix_vectors > 16)
+   instance->msix_combined = true;
+
if (rdpq_enable)
instance->is_rdpq = (scratch_pad_2 & 
MR_RDPQ_MODE_OFFSET) ?
1 : 0;
@@ -5146,6 +5143,19 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
else
instance->msix_vectors = 0;
}
+   /*
+* MSI-X host index 0 is common for all adapter.
+* It is used for all MPT based Adapters.
+*/
+   if (instance->msix_combined) {
+   instance->reply_post_host_index_addr[0] =
+   (u32 *)((u8 *)instance->reg_set +
+   MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET);
+   } else {
+   instance->reply_post_host_index_addr[0] =
+   (u32 *)((u8 *)instance->reg_set +
+   MPI2_REPLY_POST_HOST_INDEX_OFFSET);
+   }
 
dev_info(>pdev->dev,
"firmware supports msix\t: (%d)", fw_msix_count);
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index e048423..9de9e66 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -2391,7 +2391,7 @@ static void megasas_build_ld_nonrw_fusion(struct 
megasas_instance *instance,
 * pending to be completed
 */
if (threshold_reply_count >= THRESHOLD_REPLY_COUNT) {
-   if (fusion->adapter_type == INVADER_SERIES)
+   if (instance->msix_combined)
writel(((MSIxIndex & 0x7) << 24) |
fusion->last_reply_idx[MSIxIndex],

instance->reply_post_host_index_addr[MSIxIndex/8]);
@@ -2407,7 +2407,7 @@ static void megasas_build_ld_nonrw_fusion(struct 
megasas_instance *instance,
return IRQ_NONE;
 
wmb();
-   if (fusion->adapter_type == INVADER_SERIES)
+   if (instance->msix_combined)
writel(((MSIxIndex & 0x7) << 24) |
fusion->last_reply_idx[MSIxIndex],
instance->reply_post_host_index_addr[MSIxIndex/8]);
-- 
1.8.3.1

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


[PATCH 01/11] megaraid_sas: Add new pci device Ids for SAS3.5 Generic Megaraid Controllers

2016-12-02 Thread Sasikumar Chandrasekaran
This patch contains new pci device ids for SAS3.5 Generic Megaraid Controllers

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas.h| 11 ++-
 drivers/scsi/megaraid/megaraid_sas_base.c   | 20 +++-
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 29 ++---
 3 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 0d2625b..f24ce88 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -56,6 +56,14 @@
 #define PCI_DEVICE_ID_LSI_INTRUDER_24  0x00cf
 #define PCI_DEVICE_ID_LSI_CUTLASS_52   0x0052
 #define PCI_DEVICE_ID_LSI_CUTLASS_53   0x0053
+#define PCI_DEVICE_ID_LSI_MECTOR   0x00D4
+#define PCI_DEVICE_ID_LSI_VENTURA  0x0014
+#define PCI_DEVICE_ID_LSI_CRUSADER 0x0015
+#define PCI_DEVICE_ID_LSI_HARPOON  0x0016
+#define PCI_DEVICE_ID_LSI_TOMCAT   0x0017
+#define PCI_DEVICE_ID_LSI_VENTURA_4PORT0x001B
+#define PCI_DEVICE_ID_LSI_CRUSADER_4PORT   0x001C
+#define PCI_DEVICE_ID_LSI_MARLIN   0x00D3
 
 /*
  * Intel HBA SSDIDs
@@ -1478,7 +1486,7 @@ struct megasas_register_set {
 
u32 inbound_high_queue_port ;   /*00C4h*/
 
-   u32 reserved_5; /*00C8h*/
+   u32 inbound_single_queue_port;  /*00C8h*/
u32 res_6[11];  /*CCh*/
u32 host_diag;
u32 seq_offset;
@@ -2143,6 +2151,7 @@ struct megasas_instance {
u8 is_rdpq;
bool dev_handle;
bool fw_sync_cache_support;
+   bool is_ventura;
 };
 struct MR_LD_VF_MAP {
u32 size;
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 5462676..b7166b8 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -155,6 +155,15 @@ static int megasas_register_aen(struct megasas_instance 
*instance,
/* Intruder 24 port*/
{PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_CUTLASS_52)},
{PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_CUTLASS_53)},
+   /* VENTURA */
+   {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_VENTURA)},
+   {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_MARLIN)},
+   {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_MECTOR)},
+   {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_CRUSADER)},
+   {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_HARPOON)},
+   {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_TOMCAT)},
+   {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_VENTURA_4PORT)},
+   {PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_CRUSADER_4PORT)},
{}
 };
 
@@ -5723,6 +5732,15 @@ static int megasas_probe_one(struct pci_dev *pdev,
instance->pdev = pdev;
 
switch (instance->pdev->device) {
+   case PCI_DEVICE_ID_LSI_VENTURA:
+   case PCI_DEVICE_ID_LSI_MARLIN:
+   case PCI_DEVICE_ID_LSI_MECTOR:
+   case PCI_DEVICE_ID_LSI_CRUSADER:
+   case PCI_DEVICE_ID_LSI_HARPOON:
+   case PCI_DEVICE_ID_LSI_TOMCAT:
+   case PCI_DEVICE_ID_LSI_VENTURA_4PORT:
+   case PCI_DEVICE_ID_LSI_CRUSADER_4PORT:
+instance->is_ventura = true;
case PCI_DEVICE_ID_LSI_FUSION:
case PCI_DEVICE_ID_LSI_PLASMA:
case PCI_DEVICE_ID_LSI_INVADER:
@@ -5747,7 +5765,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
(instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA))
fusion->adapter_type = THUNDERBOLT_SERIES;
-   else
+   else if (!instance->is_ventura)
fusion->adapter_type = INVADER_SERIES;
}
break;
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 24778ba..e048423 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -189,15 +189,29 @@ inline void megasas_return_cmd_fusion(struct 
megasas_instance *instance,
  */
 static void
 megasas_fire_cmd_fusion(struct megasas_instance *instance,
-   union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc)
+   union MEGASAS_REQUEST_DESCRIPTOR_UNION *req_desc, bool is_32bit)
 {
+   struct megasas_register_set __iomem *regs = instance->reg_set;
+   unsigned long flags;
+   
+   if (is_32bit)
+   writel(le32_to_cpu(req_desc->u.low),
+   &(regs)->inbound_single_queue_port);
+   else if (instance->is_ventura) {
+   spin_lock_irqsave(>hba_lock, flags);
+   

Re: [PATCH] scsi: hisi_sas: fix free'ing in probe and remove

2016-12-02 Thread Quentin Lambert



On 11/29/2016 04:45 PM, John Garry wrote:

From: Xiaofei Tan 

This patch addresses 4 problems in the module probe/remove:
- When hisi_sas_shost_alloc() fails after we alloc shost memory,
we should free shost memory before the function returns.
- When hisi_sas_probe() fails after we alloc the HBA memories,
we should also free the HBA memories.
- We should free shost memory at the end of hisi_sas_remove().
- sha->core.shost is set twice, so remove extra set.

Signed-off-by: Xiaofei Tan 
Signed-off-by: John Garry 

Reviewed-by: Quentin Lambert 


diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 6d6f150..d50e9cf 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1412,8 +1412,10 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct 
platform_device *pdev,
struct clk *refclk;
  
  	shost = scsi_host_alloc(_sas_sht, sizeof(*hisi_hba));

-   if (!shost)
-   goto err_out;
+   if (!shost) {
+   dev_err(dev, "scsi host alloc failed\n");
+   return NULL;
+   }
hisi_hba = shost_priv(shost);
  
  	hisi_hba->hw = hw;

@@ -1477,6 +1479,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct 
platform_device *pdev,
  
  	return shost;

  err_out:
+   kfree(shost);
dev_err(dev, "shost alloc failed\n");
return NULL;
  }
@@ -1503,10 +1506,8 @@ int hisi_sas_probe(struct platform_device *pdev,
int rc, phy_nr, port_nr, i;
  
  	shost = hisi_sas_shost_alloc(pdev, hw);

-   if (!shost) {
-   rc = -ENOMEM;
-   goto err_out_ha;
-   }
+   if (!shost)
+   return -ENOMEM;
  
  	sha = SHOST_TO_SAS_HA(shost);

hisi_hba = shost_priv(shost);
@@ -1516,12 +1517,13 @@ int hisi_sas_probe(struct platform_device *pdev,
  
  	arr_phy = devm_kcalloc(dev, phy_nr, sizeof(void *), GFP_KERNEL);

arr_port = devm_kcalloc(dev, port_nr, sizeof(void *), GFP_KERNEL);
-   if (!arr_phy || !arr_port)
-   return -ENOMEM;
+   if (!arr_phy || !arr_port) {
+   rc = -ENOMEM;
+   goto err_out_ha;
+   }
  
  	sha->sas_phy = arr_phy;

sha->sas_port = arr_port;
-   sha->core.shost = shost;
sha->lldd_ha = hisi_hba;
  
  	shost->transportt = hisi_sas_stt;

@@ -1566,6 +1568,7 @@ int hisi_sas_probe(struct platform_device *pdev,
  err_out_register_ha:
scsi_remove_host(shost);
  err_out_ha:
+   hisi_sas_free(hisi_hba);
kfree(shost);
return rc;
  }
@@ -1575,12 +1578,14 @@ int hisi_sas_remove(struct platform_device *pdev)
  {
struct sas_ha_struct *sha = platform_get_drvdata(pdev);
struct hisi_hba *hisi_hba = sha->lldd_ha;
+   struct Scsi_Host *shost = sha->core.shost;
  
  	scsi_remove_host(sha->core.shost);

sas_unregister_ha(sha);
sas_remove_host(sha->core.shost);
  
  	hisi_sas_free(hisi_hba);

+   kfree(shost);
return 0;
  }
  EXPORT_SYMBOL_GPL(hisi_sas_remove);


--
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: SG does not ignore dxferp (direct io + mmap)

2016-12-02 Thread Ewan D. Milne
On Fri, 2016-12-02 at 04:21 -0800, Christoph Hellwig wrote:
> On Thu, Dec 01, 2016 at 08:40:31AM -0500, Martin K. Petersen wrote:
> > Specifically, the problem appears to be caused by the removal of
> > the setting of bio->bi_bdev, which would previously be set to NULL.
> > If I add:
> 
> Very odd.  For one I would expect it to be NULL anyway, second
> I don't see why the behavior changed.  But given that this reverts
> to the original assignment and makes things work I'll happily hack it
> to get things working again:
> 
> Acked-by: Christoph Hellwig 

Yeah, I'm not sure I understand this either, apart from the change
adjusting the code to effectively do what it used to and making the
test case work.  I'm reluctant to cc: stable yet, let me look at this
a bit more and I'll post the actual patch soon.

-Ewan


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


Re: [PATCH] scsi_dh_alua: Fix RCU annotations

2016-12-02 Thread Christoph Hellwig
On Thu, Dec 01, 2016 at 11:30:50AM -0800, Bart Van Assche wrote:
> This patch avoids that sparse complains about RCU pointer dereferences.

Looks good,

Reviewed-by: Christoph Hellwig 
--
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: SG does not ignore dxferp (direct io + mmap)

2016-12-02 Thread Christoph Hellwig
On Thu, Dec 01, 2016 at 08:40:31AM -0500, Martin K. Petersen wrote:
> Specifically, the problem appears to be caused by the removal of
> the setting of bio->bi_bdev, which would previously be set to NULL.
> If I add:

Very odd.  For one I would expect it to be NULL anyway, second
I don't see why the behavior changed.  But given that this reverts
to the original assignment and makes things work I'll happily hack it
to get things working again:

Acked-by: Christoph Hellwig 
--
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] block: improve handling of the magic discard payload

2016-12-02 Thread Christoph Hellwig
Instead of allocating a single unused biovec for discard requests, send
them down without any payload.  Instead we allow the driver to add a
"special" payload using a biovec embedded into struct request (unioned
over other fields never used while in the driver), and overloading
the number of segments for this case.

This has a couple of advantages:

 - we don't have to allocate the bio_vec
 - the amount of special casing for discard requests in the block
   layer is significantly reduced
 - using this same scheme for other request types is trivial,
   which will be important for implementing the new WRITE_ZEROES
   op on devices where it actually requires a payload (e.g. SCSI)
 - we can get rid of playing games with the request length, as
   we'll never touch it and completions will work just fine
 - it will allow us to support ranged discard operations in the
   future by merging non-contiguous discard bios into a single
   request
 - last but not least it removes a lot of code

This patch is the common base for my WIP series for ranges discards and to
remove discard_zeroes_data in favor of always using REQ_OP_WRITE_ZEROES,
so it would be good to get it in quickly.

Signed-off-by: Christoph Hellwig 
---
 block/bio.c| 10 +
 block/blk-core.c   | 34 ++---
 block/blk-lib.c|  2 +-
 block/blk-merge.c  | 53 +++---
 drivers/nvme/host/core.c   | 17 ---
 drivers/nvme/host/nvme.h   |  6 --
 drivers/nvme/host/pci.c| 27 +++
 drivers/nvme/host/rdma.c   | 13 +---
 drivers/nvme/target/loop.c |  4 ++--
 drivers/scsi/scsi_lib.c|  6 +++---
 drivers/scsi/sd.c  | 24 -
 include/linux/bio.h|  3 ++-
 include/linux/blkdev.h | 15 ++---
 13 files changed, 76 insertions(+), 138 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 83db1f3..2b37502 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1840,15 +1840,7 @@ struct bio *bio_split(struct bio *bio, int sectors,
BUG_ON(sectors <= 0);
BUG_ON(sectors >= bio_sectors(bio));
 
-   /*
-* Discards need a mutable bio_vec to accommodate the payload
-* required by the DSM TRIM and UNMAP commands.
-*/
-   if (bio_op(bio) == REQ_OP_DISCARD || bio_op(bio) == REQ_OP_SECURE_ERASE)
-   split = bio_clone_bioset(bio, gfp, bs);
-   else
-   split = bio_clone_fast(bio, gfp, bs);
-
+   split = bio_clone_fast(bio, gfp, bs);
if (!split)
return NULL;
 
diff --git a/block/blk-core.c b/block/blk-core.c
index 3f2eb8d..bb9934a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1475,38 +1475,6 @@ void blk_put_request(struct request *req)
 }
 EXPORT_SYMBOL(blk_put_request);
 
-/**
- * blk_add_request_payload - add a payload to a request
- * @rq: request to update
- * @page: page backing the payload
- * @offset: offset in page
- * @len: length of the payload.
- *
- * This allows to later add a payload to an already submitted request by
- * a block driver.  The driver needs to take care of freeing the payload
- * itself.
- *
- * Note that this is a quite horrible hack and nothing but handling of
- * discard requests should ever use it.
- */
-void blk_add_request_payload(struct request *rq, struct page *page,
-   int offset, unsigned int len)
-{
-   struct bio *bio = rq->bio;
-
-   bio->bi_io_vec->bv_page = page;
-   bio->bi_io_vec->bv_offset = offset;
-   bio->bi_io_vec->bv_len = len;
-
-   bio->bi_iter.bi_size = len;
-   bio->bi_vcnt = 1;
-   bio->bi_phys_segments = 1;
-
-   rq->__data_len = rq->resid_len = len;
-   rq->nr_phys_segments = 1;
-}
-EXPORT_SYMBOL_GPL(blk_add_request_payload);
-
 bool bio_attempt_back_merge(struct request_queue *q, struct request *req,
struct bio *bio)
 {
@@ -2641,6 +2609,8 @@ bool blk_update_request(struct request *req, int error, 
unsigned int nr_bytes)
return false;
}
 
+   WARN_ON_ONCE(req->rq_flags & RQF_SPECIAL_PAYLOAD);
+
req->__data_len -= total_bytes;
 
/* update sector only for requests with clear definition of sector */
diff --git a/block/blk-lib.c b/block/blk-lib.c
index 510a6fb..ed89c8f 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -80,7 +80,7 @@ int __blkdev_issue_discard(struct block_device *bdev, 
sector_t sector,
req_sects = end_sect - sector;
}
 
-   bio = next_bio(bio, 1, gfp_mask);
+   bio = next_bio(bio, 0, gfp_mask);
bio->bi_iter.bi_sector = sector;
bio->bi_bdev = bdev;
bio_set_op_attrs(bio, op, 0);
diff --git a/block/blk-merge.c b/block/blk-merge.c
index cf2848c..5f719d3 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -241,18 +241,13 @@ static unsigned int 

[PATCH] block: improve handling of the magic discard payload

2016-12-02 Thread Christoph Hellwig
Instead of allocating a single unused biovec for discard requests, send
them down without any payload.  Instead we allow the driver to add a
"special" payload using a biovec embedded into struct request (unioned
over other fields never used while in the driver), and overloading
the number of segments for this case.

This has a couple of advantages:

 - we don't have to allocate the bio_vec
 - the amount of special casing for discard requests in the block
   layer is significantly reduced
 - using this same scheme for other request types is trivial,
   which will be important for implementing the new WRITE_ZEROES
   op on devices where it actually requires a payload (e.g. SCSI)
 - we can get rid of playing games with the request length, as
   we'll never touch it and completions will work just fine
 - it will allow us to support ranged discard operations in the
   future by merging non-contiguous discard bios into a single
   request
 - last but not least it removes a lot of code

This patch is the common base for my WIP series for ranges discards and to
remove discard_zeroes_data in favor of always using REQ_OP_WRITE_ZEROES,
so it would be good to get it in quickly.

Signed-off-by: Christoph Hellwig 
---
 block/bio.c| 10 +
 block/blk-core.c   | 34 ++---
 block/blk-lib.c|  2 +-
 block/blk-merge.c  | 53 +++---
 drivers/nvme/host/core.c   | 17 ---
 drivers/nvme/host/nvme.h   |  6 --
 drivers/nvme/host/pci.c| 27 +++
 drivers/nvme/host/rdma.c   | 13 +---
 drivers/nvme/target/loop.c |  4 ++--
 drivers/scsi/scsi_lib.c|  6 +++---
 drivers/scsi/sd.c  | 24 -
 include/linux/bio.h|  3 ++-
 include/linux/blkdev.h | 15 ++---
 13 files changed, 76 insertions(+), 138 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 83db1f3..2b37502 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1840,15 +1840,7 @@ struct bio *bio_split(struct bio *bio, int sectors,
BUG_ON(sectors <= 0);
BUG_ON(sectors >= bio_sectors(bio));
 
-   /*
-* Discards need a mutable bio_vec to accommodate the payload
-* required by the DSM TRIM and UNMAP commands.
-*/
-   if (bio_op(bio) == REQ_OP_DISCARD || bio_op(bio) == REQ_OP_SECURE_ERASE)
-   split = bio_clone_bioset(bio, gfp, bs);
-   else
-   split = bio_clone_fast(bio, gfp, bs);
-
+   split = bio_clone_fast(bio, gfp, bs);
if (!split)
return NULL;
 
diff --git a/block/blk-core.c b/block/blk-core.c
index 3f2eb8d..bb9934a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1475,38 +1475,6 @@ void blk_put_request(struct request *req)
 }
 EXPORT_SYMBOL(blk_put_request);
 
-/**
- * blk_add_request_payload - add a payload to a request
- * @rq: request to update
- * @page: page backing the payload
- * @offset: offset in page
- * @len: length of the payload.
- *
- * This allows to later add a payload to an already submitted request by
- * a block driver.  The driver needs to take care of freeing the payload
- * itself.
- *
- * Note that this is a quite horrible hack and nothing but handling of
- * discard requests should ever use it.
- */
-void blk_add_request_payload(struct request *rq, struct page *page,
-   int offset, unsigned int len)
-{
-   struct bio *bio = rq->bio;
-
-   bio->bi_io_vec->bv_page = page;
-   bio->bi_io_vec->bv_offset = offset;
-   bio->bi_io_vec->bv_len = len;
-
-   bio->bi_iter.bi_size = len;
-   bio->bi_vcnt = 1;
-   bio->bi_phys_segments = 1;
-
-   rq->__data_len = rq->resid_len = len;
-   rq->nr_phys_segments = 1;
-}
-EXPORT_SYMBOL_GPL(blk_add_request_payload);
-
 bool bio_attempt_back_merge(struct request_queue *q, struct request *req,
struct bio *bio)
 {
@@ -2641,6 +2609,8 @@ bool blk_update_request(struct request *req, int error, 
unsigned int nr_bytes)
return false;
}
 
+   WARN_ON_ONCE(req->rq_flags & RQF_SPECIAL_PAYLOAD);
+
req->__data_len -= total_bytes;
 
/* update sector only for requests with clear definition of sector */
diff --git a/block/blk-lib.c b/block/blk-lib.c
index 510a6fb..ed89c8f 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -80,7 +80,7 @@ int __blkdev_issue_discard(struct block_device *bdev, 
sector_t sector,
req_sects = end_sect - sector;
}
 
-   bio = next_bio(bio, 1, gfp_mask);
+   bio = next_bio(bio, 0, gfp_mask);
bio->bi_iter.bi_sector = sector;
bio->bi_bdev = bdev;
bio_set_op_attrs(bio, op, 0);
diff --git a/block/blk-merge.c b/block/blk-merge.c
index cf2848c..5f719d3 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -241,18 +241,13 @@ static unsigned int 

[PATCH] mpt3sas: switch to pci_alloc_irq_vectors

2016-12-02 Thread Hannes Reinecke
Cleanup the MSI-X handling allowing us to use
the PCI-layer provided vector allocation.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c  | 167 +++
 drivers/scsi/mpt3sas/mpt3sas_base.h  |   6 --
 drivers/scsi/mpt3sas/mpt3sas_scsih.c |   9 ++
 3 files changed, 42 insertions(+), 140 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index f00ef88..0d93cb0 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -1129,7 +1129,7 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
/* TMs are on msix_index == 0 */
if (reply_q->msix_index == 0)
continue;
-   synchronize_irq(reply_q->vector);
+   synchronize_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index));
}
 }
 
@@ -1818,11 +1818,7 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
 
list_for_each_entry_safe(reply_q, next, >reply_queue_list, list) {
list_del(_q->list);
-   if (smp_affinity_enable) {
-   irq_set_affinity_hint(reply_q->vector, NULL);
-   free_cpumask_var(reply_q->affinity_hint);
-   }
-   free_irq(reply_q->vector, reply_q);
+   free_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index), 
reply_q);
kfree(reply_q);
}
 }
@@ -1831,13 +1827,13 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
  * _base_request_irq - request irq
  * @ioc: per adapter object
  * @index: msix index into vector table
- * @vector: irq vector
  *
  * Inserting respective reply_queue into the list.
  */
 static int
-_base_request_irq(struct MPT3SAS_ADAPTER *ioc, u8 index, u32 vector)
+_base_request_irq(struct MPT3SAS_ADAPTER *ioc, u8 index)
 {
+   struct pci_dev *pdev = ioc->pdev;
struct adapter_reply_queue *reply_q;
int r;
 
@@ -1849,14 +1845,6 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
}
reply_q->ioc = ioc;
reply_q->msix_index = index;
-   reply_q->vector = vector;
-
-   if (smp_affinity_enable) {
-   if (!zalloc_cpumask_var(_q->affinity_hint, GFP_KERNEL)) {
-   kfree(reply_q);
-   return -ENOMEM;
-   }
-   }
 
atomic_set(_q->busy, 0);
if (ioc->msix_enable)
@@ -1865,12 +1853,11 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
else
snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d",
ioc->driver_name, ioc->id);
-   r = request_irq(vector, _base_interrupt, IRQF_SHARED, reply_q->name,
-   reply_q);
+   r = request_irq(pci_irq_vector(pdev, index), _base_interrupt,
+   IRQF_SHARED, reply_q->name, reply_q);
if (r) {
pr_err(MPT3SAS_FMT "unable to allocate interrupt %d!\n",
-   reply_q->name, vector);
-   free_cpumask_var(reply_q->affinity_hint);
+  reply_q->name, pci_irq_vector(pdev, index));
kfree(reply_q);
return -EBUSY;
}
@@ -1881,61 +1868,6 @@ static int mpt3sas_remove_dead_ioc_func(void *arg)
 }
 
 /**
- * _base_assign_reply_queues - assigning msix index for each cpu
- * @ioc: per adapter object
- *
- * The enduser would need to set the affinity via /proc/irq/#/smp_affinity
- *
- * It would nice if we could call irq_set_affinity, however it is not
- * an exported symbol
- */
-static void
-_base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc)
-{
-   unsigned int cpu, nr_cpus, nr_msix, index = 0;
-   struct adapter_reply_queue *reply_q;
-
-   if (!_base_is_controller_msix_enabled(ioc))
-   return;
-
-   memset(ioc->cpu_msix_table, 0, ioc->cpu_msix_table_sz);
-
-   nr_cpus = num_online_cpus();
-   nr_msix = ioc->reply_queue_count = min(ioc->reply_queue_count,
-  ioc->facts.MaxMSIxVectors);
-   if (!nr_msix)
-   return;
-
-   cpu = cpumask_first(cpu_online_mask);
-
-   list_for_each_entry(reply_q, >reply_queue_list, list) {
-
-   unsigned int i, group = nr_cpus / nr_msix;
-
-   if (cpu >= nr_cpus)
-   break;
-
-   if (index < nr_cpus % nr_msix)
-   group++;
-
-   for (i = 0 ; i < group ; i++) {
-   ioc->cpu_msix_table[cpu] = index;
-   if (smp_affinity_enable)
-   cpumask_or(reply_q->affinity_hint,
-  reply_q->affinity_hint, get_cpu_mask(cpu));
-   cpu = cpumask_next(cpu, cpu_online_mask);
-   }
-   if (smp_affinity_enable)
-   if (irq_set_affinity_hint(reply_q->vector,
-

[PATCH] megaraid_sas: switch to pci_alloc_irq_vectors

2016-12-02 Thread Hannes Reinecke
Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/megaraid/megaraid_sas.h  |  1 -
 drivers/scsi/megaraid/megaraid_sas_base.c | 78 +++
 2 files changed, 38 insertions(+), 41 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 74c7b44..757ddda 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2120,7 +2120,6 @@ struct megasas_instance {
u32 ctrl_context_pages;
struct megasas_ctrl_info *ctrl_info;
unsigned int msix_vectors;
-   struct msix_entry msixentry[MEGASAS_MAX_MSIX_QUEUES];
struct megasas_irq_context irq_context[MEGASAS_MAX_MSIX_QUEUES];
u64 map_id;
u64 pd_seq_map_id;
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 5462676..692f40a 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4837,7 +4837,7 @@ int megasas_set_crash_dump_params(struct megasas_instance 
*instance,
 }
 
 /*
- * megasas_setup_irqs_msix -   register legacy interrupts.
+ * megasas_setup_irqs_ioapic - register legacy interrupts.
  * @instance:  Adapter soft state
  *
  * Do not enable interrupt, only setup ISRs.
@@ -4852,8 +4852,9 @@ int megasas_set_crash_dump_params(struct megasas_instance 
*instance,
pdev = instance->pdev;
instance->irq_context[0].instance = instance;
instance->irq_context[0].MSIxIndex = 0;
-   if (request_irq(pdev->irq, instance->instancet->service_isr,
-   IRQF_SHARED, "megasas", >irq_context[0])) {
+   if (request_irq(pci_irq_vector(pdev, 0),
+   instance->instancet->service_isr, IRQF_SHARED,
+   "megasas", >irq_context[0])) {
dev_err(>pdev->dev,
"Failed to register IRQ from %s %d\n",
__func__, __LINE__);
@@ -4874,28 +4875,23 @@ int megasas_set_crash_dump_params(struct 
megasas_instance *instance,
 static int
 megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe)
 {
-   int i, j, cpu;
+   int i, j;
struct pci_dev *pdev;
 
pdev = instance->pdev;
 
/* Try MSI-x */
-   cpu = cpumask_first(cpu_online_mask);
for (i = 0; i < instance->msix_vectors; i++) {
instance->irq_context[i].instance = instance;
instance->irq_context[i].MSIxIndex = i;
-   if (request_irq(instance->msixentry[i].vector,
+   if (request_irq(pci_irq_vector(pdev, i),
instance->instancet->service_isr, 0, "megasas",
>irq_context[i])) {
dev_err(>pdev->dev,
"Failed to register IRQ for vector %d.\n", i);
-   for (j = 0; j < i; j++) {
-   if (smp_affinity_enable)
-   irq_set_affinity_hint(
-   instance->msixentry[j].vector, 
NULL);
-   free_irq(instance->msixentry[j].vector,
-   >irq_context[j]);
-   }
+   for (j = 0; j < i; j++)
+   free_irq(pci_irq_vector(pdev, j),
+>irq_context[j]);
/* Retry irq register for IO_APIC*/
instance->msix_vectors = 0;
if (is_probe)
@@ -4903,14 +4899,6 @@ int megasas_set_crash_dump_params(struct 
megasas_instance *instance,
else
return -1;
}
-   if (smp_affinity_enable) {
-   if (irq_set_affinity_hint(instance->msixentry[i].vector,
-   get_cpu_mask(cpu)))
-   dev_err(>pdev->dev,
-   "Failed to set affinity hint"
-   " for cpu %d\n", cpu);
-   cpu = cpumask_next(cpu, cpu_online_mask);
-   }
}
return 0;
 }
@@ -4927,14 +4915,12 @@ int megasas_set_crash_dump_params(struct 
megasas_instance *instance,
 
if (instance->msix_vectors)
for (i = 0; i < instance->msix_vectors; i++) {
-   if (smp_affinity_enable)
-   irq_set_affinity_hint(
-   instance->msixentry[i].vector, NULL);
-   free_irq(instance->msixentry[i].vector,
+   free_irq(pci_irq_vector(instance->pdev, i),
 >irq_context[i]);
}
else
-   free_irq(instance->pdev->irq, >irq_context[0]);
+   

Re: [PATCH] hpsa: expose enclosures

2016-12-02 Thread Hannes Reinecke

On 12/02/2016 12:39 PM, Christoph Hellwig wrote:

On Fri, Dec 02, 2016 at 11:36:33AM +0100, Hannes Reinecke wrote:

Some servers have a built-in enclosure which will show up on the
same bus as the internal physical devices. As the driver doesn't
differentiate here they'll be hidden from the OS.
This patch add a module parameter 'hpsa_expose_enclosure' which
will expose these enclosures.


Any reason for not doing this unconditionally?


Backwards compability.
hpsa never did, so it _might_ be by design.
You never know :-)

I surely can make this the default if Don agrees.

Cheers,

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


Re: [PATCH] hpsa: expose enclosures

2016-12-02 Thread Christoph Hellwig
On Fri, Dec 02, 2016 at 11:36:33AM +0100, Hannes Reinecke wrote:
> Some servers have a built-in enclosure which will show up on the
> same bus as the internal physical devices. As the driver doesn't
> differentiate here they'll be hidden from the OS.
> This patch add a module parameter 'hpsa_expose_enclosure' which
> will expose these enclosures.

Any reason for not doing this unconditionally?
--
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


[PATCHv3] hpsa: fallback to use legacy REPORT PHYS command

2016-12-02 Thread Hannes Reinecke
Older SmartArray controllers (eg SmartArray 64xx) do
not support the extended REPORT PHYS command, so
fallback to use the legacy version here.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/hpsa.c | 28 ++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 216c137..3783ef6 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3640,8 +3640,32 @@ static int hpsa_scsi_do_report_luns(struct ctlr_info *h, 
int logical,
 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
struct ReportExtendedLUNdata *buf, int bufsize)
 {
-   return hpsa_scsi_do_report_luns(h, 0, buf, bufsize,
-   HPSA_REPORT_PHYS_EXTENDED);
+   int rc;
+   struct ReportLUNdata *lbuf;
+
+   rc = hpsa_scsi_do_report_luns(h, 0, buf, bufsize,
+ HPSA_REPORT_PHYS_EXTENDED);
+   if (!rc || !hpsa_allow_any)
+   return rc;
+
+   /* REPORT PHYS EXTENDED is not supported */
+   lbuf = kzalloc(sizeof(*lbuf), GFP_KERNEL);
+   if (!lbuf)
+   return -ENOMEM;
+
+   rc = hpsa_scsi_do_report_luns(h, 0, lbuf, sizeof(*lbuf), 0);
+   if (!rc) {
+   int i;
+   u32 nphys;
+
+   /* Copy ReportLUNdata header */
+   memcpy(buf, lbuf, 8);
+   nphys = be32_to_cpu(*((__be32 *)lbuf->LUNListLength)) / 8;
+   for (i = 0; i < nphys; i++)
+   memcpy(buf->LUN[i].lunid, lbuf->LUN[i], 8);
+   }
+   kfree(lbuf);
+   return rc;
 }
 
 static inline int hpsa_scsi_do_report_log_luns(struct ctlr_info *h,
-- 
1.8.5.6

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


[PATCH] hpsa: expose enclosures

2016-12-02 Thread Hannes Reinecke
Some servers have a built-in enclosure which will show up on the
same bus as the internal physical devices. As the driver doesn't
differentiate here they'll be hidden from the OS.
This patch add a module parameter 'hpsa_expose_enclosure' which
will expose these enclosures.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/hpsa.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 3783ef6..b9e05b3 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -90,6 +90,10 @@
 module_param(hpsa_simple_mode, int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(hpsa_simple_mode,
"Use 'simple mode' rather than 'performant mode'");
+static int hpsa_expose_enclosure;
+module_param(hpsa_expose_enclosure, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(hpsa_expose_enclosure,
+"Expose enclosure devices to the OS");
 
 /* define the PCI info for the cards we can control */
 static const struct pci_device_id hpsa_pci_device_id[] = {
@@ -4417,7 +4421,11 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
 * Expose all devices except for physical devices that
 * are masked.
 */
-   if (MASKED_DEVICE(lunaddrbytes) && this_device->physical_device)
+   if (hpsa_expose_enclosure &&
+   this_device->devtype == TYPE_ENCLOSURE)
+   this_device->expose_device = 1;
+   else if (MASKED_DEVICE(lunaddrbytes) &&
+this_device->physical_device)
this_device->expose_device = 0;
else
this_device->expose_device = 1;
-- 
1.8.5.6

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


Re: [PATCH] hpsa: fallback to use legacy REPORT PHYS command

2016-12-02 Thread Hannes Reinecke

On 12/02/2016 11:32 AM, Hannes Reinecke wrote:

Older SmartArray controllers (eg SmartArray 64xx) do
not support the extended REPORT PHYS command, so
fallback to use the legacy version here.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/hpsa.c | 30 +++---
 1 file changed, 27 insertions(+), 3 deletions(-)


Oh fsck.

I messed up.

Please ignore this patch.

Cheers,

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


[PATCH] hpsa: fallback to use legacy REPORT PHYS command

2016-12-02 Thread Hannes Reinecke
Older SmartArray controllers (eg SmartArray 64xx) do
not support the extended REPORT PHYS command, so
fallback to use the legacy version here.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/hpsa.c | 30 +++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 216c137..0aed9d6 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3438,7 +3438,7 @@ static u64 
hpsa_get_sas_address_from_report_physical(struct ctlr_info *h,
kfree(physdev);
return 0;
}
-   nphysicals = get_unaligned_be32(physdev->LUNListLength) / 24;
+   nphysicals = get_unaligned_be32(physdev->LUNListLength) / 8;
 
for (i = 0; i < nphysicals; i++)
if (!memcmp(>LUN[i].lunid[0], scsi3addr, 8)) {
@@ -3640,8 +3640,32 @@ static int hpsa_scsi_do_report_luns(struct ctlr_info *h, 
int logical,
 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
struct ReportExtendedLUNdata *buf, int bufsize)
 {
-   return hpsa_scsi_do_report_luns(h, 0, buf, bufsize,
-   HPSA_REPORT_PHYS_EXTENDED);
+   int rc;
+   struct ReportLUNdata *lbuf;
+
+   rc = hpsa_scsi_do_report_luns(h, 0, buf, bufsize,
+ HPSA_REPORT_PHYS_EXTENDED);
+   if (!rc || !hpsa_allow_any)
+   return rc;
+
+   /* REPORT PHYS EXTENDED is not supported */
+   lbuf = kzalloc(sizeof(*lbuf), GFP_KERNEL);
+   if (!lbuf)
+   return -ENOMEM;
+
+   rc = hpsa_scsi_do_report_luns(h, 0, lbuf, sizeof(*lbuf), 0);
+   if (!rc) {
+   int i;
+   u32 nphys;
+
+   /* Copy ReportLUNdata header */
+   memcpy(buf, lbuf, 8);
+   nphys = be32_to_cpu(*((__be32 *)lbuf->LUNListLength)) / 24;
+   for (i = 0; i < nphys; i++)
+   memcpy(buf->LUN[i].lunid, lbuf->LUN[i], 8);
+   }
+   kfree(lbuf);
+   return rc;
 }
 
 static inline int hpsa_scsi_do_report_log_luns(struct ctlr_info *h,
-- 
1.8.5.6

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


Re: [PATCH 2/3] hpsa: fallback to use legacy REPORT PHYS command

2016-12-02 Thread Hannes Reinecke

On 12/01/2016 10:50 PM, Don Brace wrote:



-Original Message-
From: Hannes Reinecke [mailto:h...@suse.de]
Sent: Friday, November 18, 2016 1:33 AM
To: Martin K. Petersen
Cc: Christoph Hellwig; James Bottomley; Don Brace; Martin Wilck; linux-
s...@vger.kernel.org; Hannes Reinecke; Hannes Reinecke
Subject: [PATCH 2/3] hpsa: fallback to use legacy REPORT PHYS command

EXTERNAL EMAIL


Older SmartArray controller do not support the extended REPORT PHYS
command, so fallback to use the legacy version here.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/hpsa.c | 28 ++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 488e17c..3d89f74 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -3628,8 +3628,32 @@ static int hpsa_scsi_do_report_luns(struct
ctlr_info *h, int logical,
 static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
struct ReportExtendedLUNdata *buf, int bufsize)
 {
-   return hpsa_scsi_do_report_luns(h, 0, buf, bufsize,
-   HPSA_REPORT_PHYS_EXTENDED);
+   int rc;
+   struct ReportLUNdata *lbuf;
+
+   rc = hpsa_scsi_do_report_luns(h, 0, buf, bufsize,
+ HPSA_REPORT_PHYS_EXTENDED);
+   if (!rc || !hpsa_allow_any)
+   return rc;
+
+   /* REPORT PHYS EXTENDED is not supported */
+   lbuf = kzalloc(sizeof(*lbuf), GFP_KERNEL);
+   if (!lbuf)
+   return -ENOMEM;
+
+   rc = hpsa_scsi_do_report_luns(h, 0, lbuf, sizeof(*lbuf), 0);
+   if (!rc) {
+   int i;
+   u32 nphys;
+
+   /* Copy ReportLUNdata header */
+   memcpy(buf, lbuf, 8);
+   nphys = be32_to_cpu(*((__be32 *)lbuf->LUNListLength)) / 24;
+   for (i = 0; i < nphys; i++)
+   memcpy(buf->LUN[i].lunid, lbuf->LUN[i], 8);
+   }
+   kfree(lbuf);
+   return rc;
 }

 static inline int hpsa_scsi_do_report_log_luns(struct ctlr_info *h,
--
1.8.5.6


For a non-extended REPORT_PHYS, the buffer size is 8, so the divisor needs to 
be 8.
REPORT_PHYS_EXTENDED has been around a long time, which controller and fw are 
you testing this on so I can
Also run some tests.


That was seen on an Smart Array 64xx.
Yes, I know, horribly ancient.

But this was sort-of the idea, namely that we can use 'hpsa' as a 
complete replacement for cciss.


I'll be fixing up the patch and resubmit it.

Cheers,

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


Re: [PATCH 0/2] hpsa: fix rmmod issues

2016-12-02 Thread Martin Wilck
On Thu, 2016-12-01 at 23:22 +, Don Brace wrote:
> > -Original Message-
> > From: Martin Wilck [mailto:mwi...@suse.de]
> > Sent: Monday, November 21, 2016 8:04 AM
> > To: Don Brace
> > Cc: dl-esc-Team ESD Storage Dev Support; iss_storage...@hp.com;
> > linux-
> > s...@vger.kernel.org; jbottom...@odin.com; h...@lst.de; h...@suse.de
> > ;
> > Martin Wilck
> > Subject: [PATCH 0/2] hpsa: fix rmmod issues
> > 
> > EXTERNAL EMAIL
> > 
> > 
> > This patch set fixes two issues I encountered when removing the
> > hpsa modules with rmmod.
> > 
> > Comments and reviews are welcome.
> > 
> > Martin Wilck (2):
> >   hpsa: cleanup sas_phy structures in sysfs when unloading
> >   hpsa: destroy sas transport properties before scsi_host
> > 
> >  drivers/scsi/hpsa.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > --
> > 2.10.1
> 
> I have both patches applied and I still get stack traces.

Hm, 

there must be a difference between 4.9.0 and the SUSE kernel that I
tested with, then. To be certain, you did NOT see a stack trace at
rmmod before applying my patches?

I can see that your trace occurs in a different code path
(bsg_unregister_queue()) than the ones I observed
(sas_port_delete()/sas_phy_delete()). CC'ing Johannes who alluded to a
generic problem in the SCSI stack during our internal discussion.

Anyway, I'll have another look.

Regards
Martin


> 
> 
> 
> [252338.604903] [ cut here ]
> [252338.627899] WARNING: CPU: 69 PID: 23977 at fs/sysfs/group.c:237
> sysfs_remove_group+0x8e/0x90
> [252338.668726] sysfs group 'power' not found for kobject '5:0:0:0'
> [252338.697526] Modules linked in: hpsa(OE-) scsi_transport_sas(OE)
> ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 nf_conntrack_ipv6
> nf_defrag_ipv6 ipt_REJECT nf_reject_ipv4 nf_conntrack_ipv4
> nf_defrag_ipv4 xt_conntrack nf_conntrack cfg80211 rfkill ebtable_nat
> ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_mangle
> ip6table_security ip6table_raw ip6table_filter ip6_tables
> iptable_mangle iptable_security iptable_raw iptable_filter ip_tables
> osst ch st sb_edac edac_core x86_pkg_temp_thermal coretemp
> crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel lrw
> iTCO_wdt gf128mul glue_helper iTCO_vendor_support ablk_helper cryptd
> pcspkr ioatdma lpc_ich hpwdt hpilo mfd_core dca ipmi_si wmi
> ipmi_msghandler pcc_cpufreq acpi_cpufreq acpi_power_meter uinput
> mgag200 i2c_algo_bit drm_kms_helper syscopyarea
> [252339.038528]  sysfillrect sysimgblt fb_sys_fops ttm drm
> crc32c_intel serio_raw tg3 ptp usb_storage i2c_core pps_core
> dm_mirror dm_region_hash dm_log dm_mod [last unloaded:
> scsi_transport_sas]
> [252339.113923] CPU: 69 PID: 23977 Comm: rmmod Tainted:
> GW  OE   4.9.0-rc71+ #24
> [252339.151296] Hardware name: HP ProLiant DL580 Gen8, BIOS P79
> 08/18/2016
> [252339.183354]  c9000ff1bbf0 815909bd c9000ff1bc40
> 
> [252339.219046]  c9000ff1bc30 81090901 00ed0246
> 
> [252339.255044]  81f71560 88204584dd38 882051e93670
> 00ae1090
> [252339.290927] Call Trace:
> [252339.303968]  [] dump_stack+0x85/0xc8
> [252339.329624]  [] __warn+0xd1/0xf0
> [252339.354037]  [] warn_slowpath_fmt+0x5f/0x80
> [252339.382084]  [] ? mutex_unlock+0xe/0x10
> [252339.408515]  [] ?
> kernfs_find_and_get_ns+0x4a/0x60
> [252339.439571]  [] sysfs_remove_group+0x8e/0x90
> [252339.468069]  [] dpm_sysfs_remove+0x57/0x60
> [252339.495701]  [] device_del+0x58/0x270
> [252339.521474]  [] device_unregister+0x1a/0x60
> [252339.549796]  [] bsg_unregister_queue+0x60/0xa0
> [252339.578999]  [] __scsi_remove_device+0xaa/0xd0
> [252339.608230]  [] scsi_forget_host+0x69/0x70
> [252339.635723]  [] scsi_remove_host+0x82/0x130
> [252339.663738]  [] hpsa_remove_one+0x93/0x190
> [hpsa]
> [252339.694960]  [] pci_device_remove+0x39/0xc0
> [252339.723128]  []
> __device_release_driver+0x9a/0x150
> [252339.753539]  [] driver_detach+0xc1/0xd0
> [252339.779784]  [] bus_remove_driver+0x58/0xd0
> [252339.807519]  [] driver_unregister+0x2c/0x50
> [252339.835948]  [] pci_unregister_driver+0x2a/0x80
> [252339.865660]  [] hpsa_cleanup+0x10/0x7a7 [hpsa]
> [252339.894682]  [] SyS_delete_module+0x1bc/0x220
> [252339.924020]  [] do_syscall_64+0x6c/0x200
> [252339.950862]  []
> entry_SYSCALL64_slow_path+0x25/0x25
> [252339.982292] ---[ end trace 03cf2c42f2f658e5 ]---

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