Re: [4.10, panic, regression] iscsi: null pointer deref at iscsi_tcp_segment_done+0x20d/0x2e0

2016-12-22 Thread Johannes Weiner
On Thu, Dec 22, 2016 at 12:22:27PM -0800, Hugh Dickins wrote:
> On Wed, 21 Dec 2016, Linus Torvalds wrote:
> > On Wed, Dec 21, 2016 at 9:13 PM, Dave Chinner  wrote:
> > > I unmounted the fs, mkfs'd it again, ran the
> > > workload again and about a minute in this fired:
> > >
> > > [628867.607417] [ cut here ]
> > > [628867.608603] WARNING: CPU: 2 PID: 16925 at mm/workingset.c:461 
> > > shadow_lru_isolate+0x171/0x220
> > 
> > Well, part of the changes during the merge window were the shadow
> > entry tracking changes that came in through Andrew's tree. Adding
> > Johannes Weiner to the participants.
> > 
> > > Now, this workload does not touch the page cache at all - it's
> > > entirely an XFS metadata workload, so it should not really be
> > > affecting the working set code.
> > 
> > Well, I suspect that anything that creates memory pressure will end up
> > triggering the working set code, so ..
> > 
> > That said, obviously memory corruption could be involved and result in
> > random issues too, but I wouldn't really expect that in this code.
> > 
> > It would probably be really useful to get more data points - is the
> > problem reliably in this area, or is it going to be random and all
> > over the place.
> 
> Data point: kswapd got WARNING on mm/workingset.c:457 in shadow_lru_isolate,
> soon followed by NULL pointer deref in list_lru_isolate, one time when
> I tried out Sunday's git tree.  Not seen since, I haven't had time to
> investigate, just set it aside as something to worry about if it happens
> again.  But it looks like shadow_lru_isolate() has issues beyond Dave's
> case (I've no XFS and no iscsi), suspect unrelated to his other problems.

This seems consistent with what Dave observed: we encounter regular
pages in radix tree nodes on the shadow LRU that should only contain
nodes full of exceptional shadow entries. It could be an issue in the
new slot replacement code and the node tracking callback.

Looking...
--
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 V6 04/11] megaraid_sas: SAS3.5 Generic Megaraid Controllers Stream Detection and IO Coalescing

2016-12-22 Thread kbuild test robot
Hi Sasikumar,

[auto build test WARNING on scsi/for-next]
[also build test WARNING on next-20161223]
[cannot apply to v4.9]
[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/Sasikumar-Chandrasekaran/megaraid_sas-Updates-for-scsi-next/20161223-103256
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: x86_64-randconfig-ne0-12231250 (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=x86_64 

All warnings (new ones prefixed by >>):

   In file included from include/linux/linkage.h:4:0,
from include/linux/kernel.h:6,
from drivers/scsi/megaraid/megaraid_sas_fusion.c:34:
   drivers/scsi/megaraid/megaraid_sas_fusion.c: In function 
'megasas_stream_detect':
   include/linux/compiler.h:149:2: warning: this 'if' clause does not guard... 
[-Wmisleading-indentation]
 if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
 ^
   include/linux/compiler.h:147:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
  ^~
>> drivers/scsi/megaraid/megaraid_sas_fusion.c:1744:3: note: in expansion of 
>> macro 'if'
  if ((io_info->ldStartBlock != current_sd->next_seq_lba)
  ^~
   drivers/scsi/megaraid/megaraid_sas_fusion.c:1751:4: note: ...this statement, 
but the latter is misleadingly indented as if it is guarded by the 'if'
   cmd->io_request->RaidContext.raid_context_g35.stream_detected = true;
   ^~~

vim +/if +1744 drivers/scsi/megaraid/megaraid_sas_fusion.c

  1728  struct STREAM_DETECT *current_sd;
  1729  /* find possible stream */
  1730  for (i = 0; i < MAX_STREAMS_TRACKED; ++i) {
  1731  stream_num =
  1732  (*track_stream >> (i * BITS_PER_INDEX_STREAM)) &
  1733  STREAM_MASK;
  1734  current_sd = ¤t_ld_sd->stream_track[stream_num];
  1735  /* if we found a stream, update the raid
  1736  *  context and also update the mruBitMap
  1737  */
  1738  /*  boundary condition */
  1739  if ((current_sd->next_seq_lba) &&
  1740  (io_info->ldStartBlock >= current_sd->next_seq_lba) &&
  1741  (io_info->ldStartBlock <= 
(current_sd->next_seq_lba+32)) &&
  1742  (current_sd->is_read == io_info->isRead)) {
  1743  
> 1744  if ((io_info->ldStartBlock != current_sd->next_seq_lba)
  1745  && ((!io_info->isRead) || (!is_read_ahead)))
  1746  /*
  1747  * Once the API availible we need to change this.
  1748  * At this point we are not allowing any gap
  1749  */
  1750  continue;
  1751  
cmd->io_request->RaidContext.raid_context_g35.stream_detected = true;
  1752  current_sd->next_seq_lba =

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


.config.gz
Description: application/gzip


Re: JMS56x not working reliably with uas driver

2016-12-22 Thread George Cherian

Hi Alan,


On Friday 23 December 2016 04:14 AM, Alan Stern wrote:

On Wed, 21 Dec 2016, George Cherian wrote:


Hi Oliver,

I was working with this JMicron device and using the uas driver.
I am seeing the following 2 issues.

1) On connect I see the following messages.
xhci_hcd :00:11.0: ERROR Transfer event for disabled endpoint or
incorrect stream ring
   This was eliminated using the following scissor patch.

-8<
[PATCH] usb: storage: unusual_uas: Add JMicron JMS56x to unusual device

This device gives the following error on detection.
xhci_hcd :00:11.0: ERROR Transfer event for disabled endpoint or
incorrect stream ring

The same error is not seen when it is added to unusual_device
list with US_FL_NO_REPORT_OPCODES passed.

Signed-off-by: George Cherian 
---
   drivers/usb/storage/unusual_uas.h | 7 +++
   1 file changed, 7 insertions(+)

diff --git a/drivers/usb/storage/unusual_uas.h
b/drivers/usb/storage/unusual_uas.h
index cbea9f3..d292299 100644
--- a/drivers/usb/storage/unusual_uas.h
+++ b/drivers/usb/storage/unusual_uas.h
@@ -142,6 +142,13 @@ UNUSUAL_DEV(0x152d, 0x0567, 0x, 0x,
USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_BROKEN_FUA | US_FL_NO_REPORT_OPCODES),

+/* Reported-by George Cherian  */
+UNUSUAL_DEV(0x152d, 0x9561, 0x, 0x,
+"JMicron",
+"JMS56x",
+USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+US_FL_NO_REPORT_OPCODES),
+
   /* Reported-by: Hans de Goede  */
   UNUSUAL_DEV(0x2109, 0x0711, 0x, 0x,
"VIA",
->8

I don't see how this patch fixes anything.  Unless I'm mistaken, it
just avoids the problem by preventing the system from issuing the
command that provokes the error, rather than really fixing the
underlying error.


2) On disconnect I am seeing the following issue

   scsi host4: uas_post_reset: alloc streams error -19 after reset
   sd 4:0:0:0: [sdb] Synchronizing SCSI cache

This is more fatal because after these messages the USB port becomes
unusable. Even an lsusb invocation hangs for ever.

This problem looks pretty simple.  uas doesn't check properly to see if
the device was disconnected following a reset.

Try changing the line in uas_post_reset() that says:

if (devinfo->shutdown)

to:

if (devinfo->shutdown ||
devinfo->udev->state == USB_STATE_NOTATTACHED)
Yes this works for me but with a little bit change as follows, But am 
not sure whether we should goto reset_scsi in case of shutdown.

Please advice.

diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 5ef014b..24db3fd 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -1072,8 +1072,8 @@ static int uas_post_reset(struct usb_interface *intf)
unsigned long flags;
int err;

-   if (devinfo->shutdown)
-   return 0;
+   if (devinfo->shutdown || devinfo->udev->state == 
USB_STATE_NOTATTACHED)

+   goto reset_scsi;

err = uas_configure_endpoints(devinfo);
if (err) {
@@ -1083,6 +1083,7 @@ static int uas_post_reset(struct usb_interface *intf)
return 1;
}

+reset_scsi:
spin_lock_irqsave(shost->host_lock, flags);
scsi_report_bus_reset(shost, 0);
spin_unlock_irqrestore(shost->host_lock, flags);


Alan Stern



--
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 08/12] scsi: ufs: add capability to keep auto bkops always enabled

2016-12-22 Thread Subhash Jadavani
UFS device requires to perform bkops (back ground operations) periodically
but host can control (via auto-bkops parameter of device) when device can
perform bkops based on its performance requirements. In general, host
would like to enable the device's auto-bkops only when it's not doing any
regular data transfer but sometimes device may not behave properly if host
keeps the auto-bkops disabled. This change adds the capability to let the
device auto-bkops always enabled except suspend.

Reviewed-by: Sahitya Tummala 
Signed-off-by: Subhash Jadavani 
---
 drivers/scsi/ufs/ufshcd.c | 33 ++---
 drivers/scsi/ufs/ufshcd.h | 13 +
 2 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 12a2250..a647bcf 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -4134,18 +4134,25 @@ static int ufshcd_disable_auto_bkops(struct ufs_hba 
*hba)
 }
 
 /**
- * ufshcd_force_reset_auto_bkops - force enable of auto bkops
+ * ufshcd_force_reset_auto_bkops - force reset auto bkops state
  * @hba: per adapter instance
  *
  * After a device reset the device may toggle the BKOPS_EN flag
  * to default value. The s/w tracking variables should be updated
- * as well. Do this by forcing enable of auto bkops.
+ * as well. This function would change the auto-bkops state based on
+ * UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND.
  */
-static void  ufshcd_force_reset_auto_bkops(struct ufs_hba *hba)
+static void ufshcd_force_reset_auto_bkops(struct ufs_hba *hba)
 {
-   hba->auto_bkops_enabled = false;
-   hba->ee_ctrl_mask |= MASK_EE_URGENT_BKOPS;
-   ufshcd_enable_auto_bkops(hba);
+   if (ufshcd_keep_autobkops_enabled_except_suspend(hba)) {
+   hba->auto_bkops_enabled = false;
+   hba->ee_ctrl_mask |= MASK_EE_URGENT_BKOPS;
+   ufshcd_enable_auto_bkops(hba);
+   } else {
+   hba->auto_bkops_enabled = true;
+   hba->ee_ctrl_mask &= ~MASK_EE_URGENT_BKOPS;
+   ufshcd_disable_auto_bkops(hba);
+   }
 }
 
 static inline int ufshcd_get_bkops_status(struct ufs_hba *hba, u32 *status)
@@ -6564,11 +6571,15 @@ static int ufshcd_resume(struct ufs_hba *hba, enum 
ufs_pm_op pm_op)
goto set_old_link_state;
}
 
-   /*
-* If BKOPs operations are urgently needed at this moment then
-* keep auto-bkops enabled or else disable it.
-*/
-   ufshcd_urgent_bkops(hba);
+   if (ufshcd_keep_autobkops_enabled_except_suspend(hba))
+   ufshcd_enable_auto_bkops(hba);
+   else
+   /*
+* If BKOPs operations are urgently needed at this moment then
+* keep auto-bkops enabled or else disable it.
+*/
+   ufshcd_urgent_bkops(hba);
+
hba->clk_gating.is_suspended = false;
 
if (hba->clk_scaling.is_allowed)
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 787323b..f25d468 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -566,6 +566,14 @@ struct ufs_hba {
 * CAUTION: Enabling this might reduce overall UFS throughput.
 */
 #define UFSHCD_CAP_INTR_AGGR (1 << 4)
+   /*
+* This capability allows the device auto-bkops to be always enabled
+* except during suspend (both runtime and suspend).
+* Enabling this capability means that device will always be allowed
+* to do background operation when it's active but it might degrade
+* the performance of ongoing read/write operations.
+*/
+#define UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND (1 << 5)
 
struct devfreq *devfreq;
struct ufs_clk_scaling clk_scaling;
@@ -663,6 +671,11 @@ static inline void *ufshcd_get_variant(struct ufs_hba *hba)
BUG_ON(!hba);
return hba->priv;
 }
+static inline bool ufshcd_keep_autobkops_enabled_except_suspend(
+   struct ufs_hba *hba)
+{
+   return hba->caps & UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND;
+}
 
 extern int ufshcd_runtime_suspend(struct ufs_hba *hba);
 extern int ufshcd_runtime_resume(struct ufs_hba *hba);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
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 11/12] scsi: ufs: add trace event for ufs commands

2016-12-22 Thread Subhash Jadavani
From: Lee Susman 

Use the ftrace infrastructure to conditionally trace ufs command events.
New trace event is created, which samples the following ufs command data:
- device name
- optional identification string
- task tag
- doorbell register
- number of transfer bytes
- interrupt status register
- request start LBA
- command opcode

Currently we only fully trace read(10) and write(10) commands.
All other commands which pass through ufshcd_send_command() will be
printed with "-1" in the lba and transfer_len fields.

Usage:
echo 1 > /sys/kernel/debug/tracing/events/ufs/enable
cat /sys/kernel/debug/tracing/trace_pipe

Signed-off-by: Lee Susman 
Signed-off-by: Subhash Jadavani 
---
Changes from v2 -> v3:
 - Removed conditional compilation based on CONFIG_TRACEPOINTS and
   used trace_*_enabled() to skip unnecessary code path execution.
---
 drivers/scsi/ufs/ufshcd.c  | 42 +-
 include/trace/events/ufs.h | 38 ++
 2 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 36d239d..918c597 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -293,6 +293,41 @@ static inline void ufshcd_remove_non_printable(char *val)
*val = ' ';
 }
 
+static void ufshcd_add_command_trace(struct ufs_hba *hba,
+   unsigned int tag, const char *str)
+{
+   sector_t lba = -1;
+   u8 opcode = 0;
+   u32 intr, doorbell;
+   struct ufshcd_lrb *lrbp;
+   int transfer_len = -1;
+
+   if (!trace_ufshcd_command_enabled())
+   return;
+
+   lrbp = &hba->lrb[tag];
+
+   if (lrbp->cmd) { /* data phase exists */
+   opcode = (u8)(*lrbp->cmd->cmnd);
+   if ((opcode == READ_10) || (opcode == WRITE_10)) {
+   /*
+* Currently we only fully trace read(10) and write(10)
+* commands
+*/
+   if (lrbp->cmd->request && lrbp->cmd->request->bio)
+   lba =
+ lrbp->cmd->request->bio->bi_iter.bi_sector;
+   transfer_len = be32_to_cpu(
+   lrbp->ucd_req_ptr->sc.exp_data_transfer_len);
+   }
+   }
+
+   intr = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
+   doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
+   trace_ufshcd_command(dev_name(hba->dev), str, tag,
+   doorbell, transfer_len, intr, lba, opcode);
+}
+
 static void ufshcd_print_host_regs(struct ufs_hba *hba)
 {
/*
@@ -1166,6 +1201,7 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned 
int task_tag)
ufshcd_writel(hba, 1 << task_tag, REG_UTP_TRANSFER_REQ_DOOR_BELL);
/* Make sure that doorbell is committed immediately */
wmb();
+   ufshcd_add_command_trace(hba, task_tag, "send");
 }
 
 /**
@@ -3955,6 +3991,7 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba 
*hba,
lrbp = &hba->lrb[index];
cmd = lrbp->cmd;
if (cmd) {
+   ufshcd_add_command_trace(hba, index, "complete");
result = ufshcd_transfer_rsp_status(hba, lrbp);
scsi_dma_unmap(cmd);
cmd->result = result;
@@ -3966,8 +4003,11 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba 
*hba,
__ufshcd_release(hba);
} else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE ||
lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) {
-   if (hba->dev_cmd.complete)
+   if (hba->dev_cmd.complete) {
+   ufshcd_add_command_trace(hba, index,
+   "dev_complete");
complete(hba->dev_cmd.complete);
+   }
}
}
 
diff --git a/include/trace/events/ufs.h b/include/trace/events/ufs.h
index e9634df..bf6f826 100644
--- a/include/trace/events/ufs.h
+++ b/include/trace/events/ufs.h
@@ -219,6 +219,44 @@
 TP_PROTO(const char *dev_name, int err, s64 usecs,
  int dev_state, int link_state),
 TP_ARGS(dev_name, err, usecs, dev_state, link_state));
+
+TRACE_EVENT(ufshcd_command,
+   TP_PROTO(const char *dev_name, const char *str, unsigned int tag,
+   u32 doorbell, int transfer_len, u32 intr, u64 lba,
+   u8 opcode),
+
+   TP_ARGS(dev_name, str, tag, doorbell, transfer_len, intr, lba, opcode),
+
+   TP_STRUCT__entry(
+   __string(dev_name, dev_name)
+   __string(str, str)
+   __field(unsigned int, tag)
+   __field(u32, doorbell)
+   __field(int, transfer_len

[PATCH v3 04/12] scsi: ufs: Add sysfs node to dynamically control clock gating

2016-12-22 Thread Subhash Jadavani
From: Sahitya Tummala 

Provide an option to enable/disable clock gating during runtime.
Write 1 or 0 to "clkgate_enable" sysfs node to enable/disable
clock gating.

Signed-off-by: Sahitya Tummala 
Signed-off-by: Subhash Jadavani 
---
 drivers/scsi/ufs/ufshcd.c | 48 ++-
 drivers/scsi/ufs/ufshcd.h |  4 
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 2e7c172..2ed82c2 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -970,6 +970,41 @@ static ssize_t ufshcd_clkgate_delay_store(struct device 
*dev,
return count;
 }
 
+static ssize_t ufshcd_clkgate_enable_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct ufs_hba *hba = dev_get_drvdata(dev);
+
+   return snprintf(buf, PAGE_SIZE, "%d\n", hba->clk_gating.is_enabled);
+}
+
+static ssize_t ufshcd_clkgate_enable_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count)
+{
+   struct ufs_hba *hba = dev_get_drvdata(dev);
+   unsigned long flags;
+   u32 value;
+
+   if (kstrtou32(buf, 0, &value))
+   return -EINVAL;
+
+   value = !!value;
+   if (value == hba->clk_gating.is_enabled)
+   goto out;
+
+   if (value) {
+   ufshcd_release(hba);
+   } else {
+   spin_lock_irqsave(hba->host->host_lock, flags);
+   hba->clk_gating.active_reqs++;
+   spin_unlock_irqrestore(hba->host->host_lock, flags);
+   }
+
+   hba->clk_gating.is_enabled = value;
+out:
+   return count;
+}
+
 static void ufshcd_init_clk_gating(struct ufs_hba *hba)
 {
if (!ufshcd_is_clkgating_allowed(hba))
@@ -979,13 +1014,23 @@ static void ufshcd_init_clk_gating(struct ufs_hba *hba)
INIT_DELAYED_WORK(&hba->clk_gating.gate_work, ufshcd_gate_work);
INIT_WORK(&hba->clk_gating.ungate_work, ufshcd_ungate_work);
 
+   hba->clk_gating.is_enabled = true;
+
hba->clk_gating.delay_attr.show = ufshcd_clkgate_delay_show;
hba->clk_gating.delay_attr.store = ufshcd_clkgate_delay_store;
sysfs_attr_init(&hba->clk_gating.delay_attr.attr);
hba->clk_gating.delay_attr.attr.name = "clkgate_delay_ms";
-   hba->clk_gating.delay_attr.attr.mode = S_IRUGO | S_IWUSR;
+   hba->clk_gating.delay_attr.attr.mode = 0644;
if (device_create_file(hba->dev, &hba->clk_gating.delay_attr))
dev_err(hba->dev, "Failed to create sysfs for clkgate_delay\n");
+
+   hba->clk_gating.enable_attr.show = ufshcd_clkgate_enable_show;
+   hba->clk_gating.enable_attr.store = ufshcd_clkgate_enable_store;
+   sysfs_attr_init(&hba->clk_gating.enable_attr.attr);
+   hba->clk_gating.enable_attr.attr.name = "clkgate_enable";
+   hba->clk_gating.enable_attr.attr.mode = 0644;
+   if (device_create_file(hba->dev, &hba->clk_gating.enable_attr))
+   dev_err(hba->dev, "Failed to create sysfs for 
clkgate_enable\n");
 }
 
 static void ufshcd_exit_clk_gating(struct ufs_hba *hba)
@@ -993,6 +1038,7 @@ static void ufshcd_exit_clk_gating(struct ufs_hba *hba)
if (!ufshcd_is_clkgating_allowed(hba))
return;
device_remove_file(hba->dev, &hba->clk_gating.delay_attr);
+   device_remove_file(hba->dev, &hba->clk_gating.enable_attr);
cancel_work_sync(&hba->clk_gating.ungate_work);
cancel_delayed_work_sync(&hba->clk_gating.gate_work);
 }
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 08cd26e..0882ba6 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -320,6 +320,8 @@ enum clk_gating_state {
  * @is_suspended: clk gating is suspended when set to 1 which can be used
  * during suspend/resume
  * @delay_attr: sysfs attribute to control delay_attr
+ * @enable_attr: sysfs attribute to enable/disable clock gating
+ * @is_enabled: Indicates the current status of clock gating
  * @active_reqs: number of requests that are pending and should be waited for
  * completion before gating clocks.
  */
@@ -330,6 +332,8 @@ struct ufs_clk_gating {
unsigned long delay_ms;
bool is_suspended;
struct device_attribute delay_attr;
+   struct device_attribute enable_attr;
+   bool is_enabled;
int active_reqs;
 };
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
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 10/12] scsi: ufs: add time profiling support

2016-12-22 Thread Subhash Jadavani
This patch adds the profiling support for some of the time critical
operations like hibern8 enter/exit, clock gating & clock scaling.

Reviewed-by: Venkat Gopalakrishnan 
Signed-off-by: Subhash Jadavani 
---
 drivers/scsi/ufs/ufshcd.c  | 24 
 include/trace/events/ufs.h | 40 
 2 files changed, 64 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 2d3ca18..36d239d 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3021,11 +3021,14 @@ static int __ufshcd_uic_hibern8_enter(struct ufs_hba 
*hba)
 {
int ret;
struct uic_command uic_cmd = {0};
+   ktime_t start = ktime_get();
 
ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_ENTER, PRE_CHANGE);
 
uic_cmd.command = UIC_CMD_DME_HIBER_ENTER;
ret = ufshcd_uic_pwr_ctrl(hba, &uic_cmd);
+   trace_ufshcd_profile_hibern8(dev_name(hba->dev), "enter",
+ktime_to_us(ktime_sub(ktime_get(), start)), ret);
 
if (ret) {
dev_err(hba->dev, "%s: hibern8 enter failed. ret = %d\n",
@@ -3061,11 +3064,15 @@ static int ufshcd_uic_hibern8_exit(struct ufs_hba *hba)
 {
struct uic_command uic_cmd = {0};
int ret;
+   ktime_t start = ktime_get();
 
ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_EXIT, PRE_CHANGE);
 
uic_cmd.command = UIC_CMD_DME_HIBER_EXIT;
ret = ufshcd_uic_pwr_ctrl(hba, &uic_cmd);
+   trace_ufshcd_profile_hibern8(dev_name(hba->dev), "exit",
+ktime_to_us(ktime_sub(ktime_get(), start)), ret);
+
if (ret) {
dev_err(hba->dev, "%s: hibern8 exit failed. ret = %d\n",
__func__, ret);
@@ -5950,6 +5957,8 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, 
bool on,
struct ufs_clk_info *clki;
struct list_head *head = &hba->clk_list_head;
unsigned long flags;
+   ktime_t start = ktime_get();
+   bool clk_state_changed = false;
 
if (!head || list_empty(head))
goto out;
@@ -5963,6 +5972,7 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, 
bool on,
if (skip_ref_clk && !strcmp(clki->name, "ref_clk"))
continue;
 
+   clk_state_changed = on ^ clki->enabled;
if (on && !clki->enabled) {
ret = clk_prepare_enable(clki->clk);
if (ret) {
@@ -5997,6 +6007,10 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, 
bool on,
spin_unlock_irqrestore(hba->host->host_lock, flags);
}
 
+   if (clk_state_changed)
+   trace_ufshcd_profile_clk_gating(dev_name(hba->dev),
+   (on ? "on" : "off"),
+   ktime_to_us(ktime_sub(ktime_get(), start)), ret);
return ret;
 }
 
@@ -6996,6 +7010,8 @@ static int ufshcd_scale_clks(struct ufs_hba *hba, bool 
scale_up)
int ret = 0;
struct ufs_clk_info *clki;
struct list_head *head = &hba->clk_list_head;
+   ktime_t start = ktime_get();
+   bool clk_state_changed = false;
 
if (!head || list_empty(head))
goto out;
@@ -7009,6 +7025,8 @@ static int ufshcd_scale_clks(struct ufs_hba *hba, bool 
scale_up)
if (scale_up && clki->max_freq) {
if (clki->curr_freq == clki->max_freq)
continue;
+
+   clk_state_changed = true;
ret = clk_set_rate(clki->clk, clki->max_freq);
if (ret) {
dev_err(hba->dev, "%s: %s clk set 
rate(%dHz) failed, %d\n",
@@ -7026,6 +7044,8 @@ static int ufshcd_scale_clks(struct ufs_hba *hba, bool 
scale_up)
} else if (!scale_up && clki->min_freq) {
if (clki->curr_freq == clki->min_freq)
continue;
+
+   clk_state_changed = true;
ret = clk_set_rate(clki->clk, clki->min_freq);
if (ret) {
dev_err(hba->dev, "%s: %s clk set 
rate(%dHz) failed, %d\n",
@@ -7047,6 +7067,10 @@ static int ufshcd_scale_clks(struct ufs_hba *hba, bool 
scale_up)
ret = ufshcd_vops_clk_scale_notify(hba, scale_up, POST_CHANGE);
 
 out:
+   if (clk_state_changed)
+   trace_ufshcd_profile_clk_scaling(dev_name(hba->dev),
+   (scale_up ? "up" : "down"),
+   ktime_to_us(ktime_sub(ktime_get(), start)), ret);
return ret;
 }
 
diff --git a/include/trace/events/ufs.h b/include/trace/events/ufs.h
index 57743b6..e9634df 100644
--- a/include/trace/events/ufs.h
+++ b/include/trace/eve

[PATCH v3 09/12] scsi: ufs: fix setting init power mode

2016-12-22 Thread Subhash Jadavani
Immediately after successful UFS link startup, UFS link power mode would
be in PWM-G1, 1-lane, SLOW-AUTO mode. But currently we are doing few
of the DME local/peer attributes access before setting the "hba->pwr_info"
to default power mode. If we are doing link startup as part of error
recovery then old power mode might be set to FAST mode and doing DME peer
access (after link startup but before updating "hba->pwr_info" to default
power mode) unintentionally tries to switch from FAST to FAST_AUTO mode (if
UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE quirk is enabled).

Above issue is fixed by setting the default power mode immediately after
successful link startup.

Reviewed-by: Sahitya Tummala 
Signed-off-by: Subhash Jadavani 
---
 drivers/scsi/ufs/ufshcd.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index a647bcf..2d3ca18 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3512,6 +3512,10 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
goto link_startup;
}
 
+   /* Mark that link is up in PWM-G1, 1-lane, SLOW-AUTO mode */
+   ufshcd_init_pwr_info(hba);
+   ufshcd_print_pwr_info(hba);
+
if (hba->quirks & UFSHCD_QUIRK_BROKEN_LCC) {
ret = ufshcd_disable_device_tx_lcc(hba);
if (ret)
@@ -5547,9 +5551,6 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
if (ret)
goto out;
 
-   ufshcd_init_pwr_info(hba);
-   ufshcd_print_pwr_info(hba);
-
/* set the default level for urgent bkops */
hba->urgent_bkops_lvl = BKOPS_STATUS_PERF_IMPACT;
hba->is_urgent_bkops_lvl_checked = false;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
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 05/12] scsi: ufs: Add sysfs node to dynamically control clock scaling

2016-12-22 Thread Subhash Jadavani
From: Sahitya Tummala 

Provide an option to enable/disable clock scaling during runtime.
Write 1/0 to "clkscale_enable" sysfs node to enable/disable clock
scaling.

Signed-off-by: Sahitya Tummala 
Signed-off-by: Subhash Jadavani 
---
 drivers/scsi/ufs/ufshcd.c | 95 +++
 drivers/scsi/ufs/ufshcd.h |  4 +-
 2 files changed, 82 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 2ed82c2..5932936 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -230,6 +230,9 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, bool 
on,
 static int ufshcd_uic_hibern8_enter(struct ufs_hba *hba);
 static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba);
 static int ufshcd_host_reset_and_restore(struct ufs_hba *hba);
+static void ufshcd_resume_clkscaling(struct ufs_hba *hba);
+static void ufshcd_suspend_clkscaling(struct ufs_hba *hba);
+static int ufshcd_scale_clks(struct ufs_hba *hba, bool scale_up);
 static irqreturn_t ufshcd_intr(int irq, void *__hba);
 static int ufshcd_config_pwr_mode(struct ufs_hba *hba,
struct ufs_pa_layer_attr *desired_pwr_mode);
@@ -713,16 +716,58 @@ static bool ufshcd_is_unipro_pa_params_tuning_req(struct 
ufs_hba *hba)
 
 static void ufshcd_suspend_clkscaling(struct ufs_hba *hba)
 {
-   if (ufshcd_is_clkscaling_enabled(hba)) {
-   devfreq_suspend_device(hba->devfreq);
-   hba->clk_scaling.window_start_t = 0;
-   }
+   if (!ufshcd_is_clkscaling_supported(hba))
+   return;
+
+   devfreq_suspend_device(hba->devfreq);
+   hba->clk_scaling.window_start_t = 0;
 }
 
 static void ufshcd_resume_clkscaling(struct ufs_hba *hba)
 {
-   if (ufshcd_is_clkscaling_enabled(hba))
-   devfreq_resume_device(hba->devfreq);
+   devfreq_resume_device(hba->devfreq);
+}
+
+static ssize_t ufshcd_clkscale_enable_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct ufs_hba *hba = dev_get_drvdata(dev);
+
+   return snprintf(buf, PAGE_SIZE, "%d\n", hba->clk_scaling.is_allowed);
+}
+
+static ssize_t ufshcd_clkscale_enable_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count)
+{
+   struct ufs_hba *hba = dev_get_drvdata(dev);
+   u32 value;
+   int err;
+
+   if (kstrtou32(buf, 0, &value))
+   return -EINVAL;
+
+   value = !!value;
+   if (value == hba->clk_scaling.is_allowed)
+   goto out;
+
+   pm_runtime_get_sync(hba->dev);
+   ufshcd_hold(hba, false);
+
+   if (value) {
+   ufshcd_resume_clkscaling(hba);
+   } else {
+   ufshcd_suspend_clkscaling(hba);
+   err = ufshcd_scale_clks(hba, true);
+   if (err)
+   dev_err(hba->dev, "%s: failed to scale clocks up %d\n",
+   __func__, err);
+   }
+   hba->clk_scaling.is_allowed = value;
+
+   ufshcd_release(hba);
+   pm_runtime_put_sync(hba->dev);
+out:
+   return count;
 }
 
 static void ufshcd_ungate_work(struct work_struct *work)
@@ -758,7 +803,8 @@ static void ufshcd_ungate_work(struct work_struct *work)
hba->clk_gating.is_suspended = false;
}
 unblock_reqs:
-   ufshcd_resume_clkscaling(hba);
+   if (hba->clk_scaling.is_allowed)
+   ufshcd_resume_clkscaling(hba);
scsi_unblock_requests(hba->host);
 }
 
@@ -1046,7 +1092,7 @@ static void ufshcd_exit_clk_gating(struct ufs_hba *hba)
 /* Must be called with host lock acquired */
 static void ufshcd_clk_scaling_start_busy(struct ufs_hba *hba)
 {
-   if (!ufshcd_is_clkscaling_enabled(hba))
+   if (!ufshcd_is_clkscaling_supported(hba))
return;
 
if (!hba->clk_scaling.is_busy_started) {
@@ -1059,7 +1105,7 @@ static void ufshcd_clk_scaling_update_busy(struct ufs_hba 
*hba)
 {
struct ufs_clk_scaling *scaling = &hba->clk_scaling;
 
-   if (!ufshcd_is_clkscaling_enabled(hba))
+   if (!ufshcd_is_clkscaling_supported(hba))
return;
 
if (!hba->outstanding_reqs && scaling->is_busy_started) {
@@ -5526,12 +5572,15 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
pm_runtime_put_sync(hba->dev);
}
 
+   /* Resume devfreq after UFS device is detected */
+   if (ufshcd_is_clkscaling_supported(hba)) {
+   ufshcd_resume_clkscaling(hba);
+   hba->clk_scaling.is_allowed = true;
+   }
+
if (!hba->is_init_prefetch)
hba->is_init_prefetch = true;
 
-   /* Resume devfreq after UFS device is detected */
-   ufshcd_resume_clkscaling(hba);
-
 out:
/*
 * If we failed to initialize the device or the device is not
@@ -6484,7 +6533,8 @@ static int ufshcd_resume(struct ufs_hba *hba, enum 
ufs_pm_op pm_op)
ufshcd_urgent_bko

[PATCH v3 07/12] scsi: ufs: set default UFS power management level

2016-12-22 Thread Subhash Jadavani
UFS device and link can be put in multiple different low power modes hence
UFS driver supports multiple different low power modes.
This change sets the default UFS power management level which should put
the link hibernate state and device in sleep state. This default power
management level gives good  power savings with relatively less enter/exit
latencies.

Reviewed-by: Yaniv Gardi 
Signed-off-by: Subhash Jadavani 
---
Changes from v2 -> v3:
 - Simplified patch to just set the default power management level.
   Device tree capability to specify broken hardware will be taken up as
   separate patch in different patch series than current one.
---
 drivers/scsi/ufs/ufshcd.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 30ee04a..12a2250 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -191,6 +191,22 @@ enum {
return ufs_pm_lvl_states[lvl].link_state;
 }
 
+static inline enum ufs_pm_level
+ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state,
+   enum uic_link_state link_state)
+{
+   enum ufs_pm_level lvl;
+
+   for (lvl = UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++) {
+   if ((ufs_pm_lvl_states[lvl].dev_state == dev_state) &&
+   (ufs_pm_lvl_states[lvl].link_state == link_state))
+   return lvl;
+   }
+
+   /* if no match found, return the level 0 */
+   return UFS_PM_LVL_0;
+}
+
 static struct ufs_dev_fix ufs_fixups[] = {
/* UFS cards deviations table */
UFS_FIX(UFS_VENDOR_SAMSUNG, UFS_ANY_MODEL,
@@ -7264,6 +7280,18 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem 
*mmio_base, unsigned int irq)
ufshcd_clkscaling_init_sysfs(hba);
}
 
+   /*
+* Set the default power management level for runtime and system PM.
+* Default power saving mode is to keep UFS link in Hibern8 state
+* and UFS device in sleep state.
+*/
+   hba->rpm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
+   UFS_SLEEP_PWR_MODE,
+   UIC_LINK_HIBERN8_STATE);
+   hba->spm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
+   UFS_SLEEP_PWR_MODE,
+   UIC_LINK_HIBERN8_STATE);
+
/* Hold auto suspend until async scan completes */
pm_runtime_get_sync(dev);
 
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
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 12/12] scsi: ufs: Improve fatal error logs

2016-12-22 Thread Subhash Jadavani
From: Dolev Raviv 

Errors such as UIC error, illegal OCS values, and others may require
more information for debugging. Such information could be hibern8 events,
events sequences, recoverable errors, error history, and more.
This patch improves tracking of important errors and events in debug level
to be enabled when debugging a such issues. It includes:
* UIC error history
* Successful hibern8 events
* Successful command after hibern8 exit
* Clk-freq info
* Failed device command
* Infrastructure for dumping host controller debug information

Signed-off-by: Dolev Raviv 
Signed-off-by: Subhash Jadavani 
---
Changes from v1 -> v2:
 - Added explicit new line character at the end of the printk messages.
---
 drivers/scsi/ufs/ufshcd.c | 203 --
 drivers/scsi/ufs/ufshcd.h |  47 +++
 2 files changed, 208 insertions(+), 42 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 918c597..c2b15a2 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -328,6 +328,37 @@ static void ufshcd_add_command_trace(struct ufs_hba *hba,
doorbell, transfer_len, intr, lba, opcode);
 }
 
+static void ufshcd_print_clk_freqs(struct ufs_hba *hba)
+{
+   struct ufs_clk_info *clki;
+   struct list_head *head = &hba->clk_list_head;
+
+   if (!head || list_empty(head))
+   return;
+
+   list_for_each_entry(clki, head, list) {
+   if (!IS_ERR_OR_NULL(clki->clk) && clki->min_freq &&
+   clki->max_freq)
+   dev_err(hba->dev, "clk: %s, rate: %u\n",
+   clki->name, clki->curr_freq);
+   }
+}
+
+static void ufshcd_print_uic_err_hist(struct ufs_hba *hba,
+   struct ufs_uic_err_reg_hist *err_hist, char *err_name)
+{
+   int i;
+
+   for (i = 0; i < UIC_ERR_REG_HIST_LENGTH; i++) {
+   int p = (i + err_hist->pos - 1) % UIC_ERR_REG_HIST_LENGTH;
+
+   if (err_hist->reg[p] == 0)
+   continue;
+   dev_err(hba->dev, "%s[%d] = 0x%x at %lld us\n", err_name, i,
+   err_hist->reg[p], ktime_to_us(err_hist->tstamp[p]));
+   }
+}
+
 static void ufshcd_print_host_regs(struct ufs_hba *hba)
 {
/*
@@ -344,6 +375,21 @@ static void ufshcd_print_host_regs(struct ufs_hba *hba)
dev_err(hba->dev,
"hba->outstanding_reqs = 0x%x, hba->outstanding_tasks = 0x%x\n",
(u32)hba->outstanding_reqs, (u32)hba->outstanding_tasks);
+   dev_err(hba->dev,
+   "last_hibern8_exit_tstamp at %lld us, hibern8_exit_cnt = %d\n",
+   ktime_to_us(hba->ufs_stats.last_hibern8_exit_tstamp),
+   hba->ufs_stats.hibern8_exit_cnt);
+
+   ufshcd_print_uic_err_hist(hba, &hba->ufs_stats.pa_err, "pa_err");
+   ufshcd_print_uic_err_hist(hba, &hba->ufs_stats.dl_err, "dl_err");
+   ufshcd_print_uic_err_hist(hba, &hba->ufs_stats.nl_err, "nl_err");
+   ufshcd_print_uic_err_hist(hba, &hba->ufs_stats.tl_err, "tl_err");
+   ufshcd_print_uic_err_hist(hba, &hba->ufs_stats.dme_err, "dme_err");
+
+   ufshcd_print_clk_freqs(hba);
+
+   if (hba->vops && hba->vops->dbg_register_dump)
+   hba->vops->dbg_register_dump(hba);
 }
 
 static
@@ -355,22 +401,30 @@ void ufshcd_print_trs(struct ufs_hba *hba, unsigned long 
bitmap, bool pr_prdt)
for_each_set_bit(tag, &bitmap, hba->nutrs) {
lrbp = &hba->lrb[tag];
 
-   dev_err(hba->dev, "UPIU[%d] - Transfer Request Descriptor\n",
-   tag);
+   dev_err(hba->dev, "UPIU[%d] - issue time %lld us\n",
+   tag, ktime_to_us(lrbp->issue_time_stamp));
+   dev_err(hba->dev,
+   "UPIU[%d] - Transfer Request Descriptor phys@0x%llx\n",
+   tag, (u64)lrbp->utrd_dma_addr);
+
ufshcd_hex_dump("UPIU TRD: ", lrbp->utr_descriptor_ptr,
sizeof(struct utp_transfer_req_desc));
-   dev_err(hba->dev, "UPIU[%d] - Request UPIU\n", tag);
+   dev_err(hba->dev, "UPIU[%d] - Request UPIU phys@0x%llx\n", tag,
+   (u64)lrbp->ucd_req_dma_addr);
ufshcd_hex_dump("UPIU REQ: ", lrbp->ucd_req_ptr,
sizeof(struct utp_upiu_req));
-   dev_err(hba->dev, "UPIU[%d] - Response UPIU\n", tag);
+   dev_err(hba->dev, "UPIU[%d] - Response UPIU phys@0x%llx\n", tag,
+   (u64)lrbp->ucd_rsp_dma_addr);
ufshcd_hex_dump("UPIU RSP: ", lrbp->ucd_rsp_ptr,
sizeof(struct utp_upiu_rsp));
if (pr_prdt) {
int prdt_length = le16_to_cpu(
lrbp->utr_descriptor_ptr->prd_table_length);
 
-   dev_err(hba->d

[PATCH v3 06/12] scsi: ufs: provide sysfs attribute to select the PM level

2016-12-22 Thread Subhash Jadavani
This patch provides the sysfs attribute to choose the power management
level for UFS runtime and system suspend.

Reviewed-by: Sujit Reddy Thumma 
Signed-off-by: Subhash Jadavani 
---
 drivers/scsi/ufs/ufshcd.c | 144 ++
 drivers/scsi/ufs/ufshcd.h |   2 +
 2 files changed, 146 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 5932936..30ee04a 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -686,6 +686,28 @@ static inline int ufshcd_is_hba_active(struct ufs_hba *hba)
return (ufshcd_readl(hba, REG_CONTROLLER_ENABLE) & 0x1) ? 0 : 1;
 }
 
+static const char *ufschd_uic_link_state_to_string(
+   enum uic_link_state state)
+{
+   switch (state) {
+   case UIC_LINK_OFF_STATE:return "OFF";
+   case UIC_LINK_ACTIVE_STATE: return "ACTIVE";
+   case UIC_LINK_HIBERN8_STATE:return "HIBERN8";
+   default:return "UNKNOWN";
+   }
+}
+
+static const char *ufschd_ufs_dev_pwr_mode_to_string(
+   enum ufs_dev_pwr_mode state)
+{
+   switch (state) {
+   case UFS_ACTIVE_PWR_MODE:   return "ACTIVE";
+   case UFS_SLEEP_PWR_MODE:return "SLEEP";
+   case UFS_POWERDOWN_PWR_MODE:return "POWERDOWN";
+   default:return "UNKNOWN";
+   }
+}
+
 u32 ufshcd_get_local_unipro_ver(struct ufs_hba *hba)
 {
/* HCI version 1.0 and 1.1 supports UniPro 1.41 */
@@ -6709,6 +6731,127 @@ int ufshcd_runtime_idle(struct ufs_hba *hba)
 }
 EXPORT_SYMBOL(ufshcd_runtime_idle);
 
+static inline ssize_t ufshcd_pm_lvl_store(struct device *dev,
+  struct device_attribute *attr,
+  const char *buf, size_t count,
+  bool rpm)
+{
+   struct ufs_hba *hba = dev_get_drvdata(dev);
+   unsigned long flags, value;
+
+   if (kstrtoul(buf, 0, &value))
+   return -EINVAL;
+
+   if ((value < UFS_PM_LVL_0) || (value >= UFS_PM_LVL_MAX))
+   return -EINVAL;
+
+   spin_lock_irqsave(hba->host->host_lock, flags);
+   if (rpm)
+   hba->rpm_lvl = value;
+   else
+   hba->spm_lvl = value;
+   spin_unlock_irqrestore(hba->host->host_lock, flags);
+   return count;
+}
+
+static ssize_t ufshcd_rpm_lvl_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct ufs_hba *hba = dev_get_drvdata(dev);
+   int curr_len;
+   u8 lvl;
+
+   curr_len = snprintf(buf, PAGE_SIZE,
+   "\nCurrent Runtime PM level [%d] => dev_state [%s] 
link_state [%s]\n",
+   hba->rpm_lvl,
+   ufschd_ufs_dev_pwr_mode_to_string(
+   ufs_pm_lvl_states[hba->rpm_lvl].dev_state),
+   ufschd_uic_link_state_to_string(
+   ufs_pm_lvl_states[hba->rpm_lvl].link_state));
+
+   curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len),
+"\nAll available Runtime PM levels info:\n");
+   for (lvl = UFS_PM_LVL_0; lvl < UFS_PM_LVL_MAX; lvl++)
+   curr_len += snprintf((buf + curr_len), (PAGE_SIZE - curr_len),
+"\tRuntime PM level [%d] => dev_state [%s] 
link_state [%s]\n",
+   lvl,
+   ufschd_ufs_dev_pwr_mode_to_string(
+   ufs_pm_lvl_states[lvl].dev_state),
+   ufschd_uic_link_state_to_string(
+   ufs_pm_lvl_states[lvl].link_state));
+
+   return curr_len;
+}
+
+static ssize_t ufshcd_rpm_lvl_store(struct device *dev,
+   struct device_attribute *attr, const char *buf, size_t count)
+{
+   return ufshcd_pm_lvl_store(dev, attr, buf, count, true);
+}
+
+static void ufshcd_add_rpm_lvl_sysfs_nodes(struct ufs_hba *hba)
+{
+   hba->rpm_lvl_attr.show = ufshcd_rpm_lvl_show;
+   hba->rpm_lvl_attr.store = ufshcd_rpm_lvl_store;
+   sysfs_attr_init(&hba->rpm_lvl_attr.attr);
+   hba->rpm_lvl_attr.attr.name = "rpm_lvl";
+   hba->rpm_lvl_attr.attr.mode = 0644;
+   if (device_create_file(hba->dev, &hba->rpm_lvl_attr))
+   dev_err(hba->dev, "Failed to create sysfs for rpm_lvl\n");
+}
+
+static ssize_t ufshcd_spm_lvl_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct ufs_hba *hba = dev_get_drvdata(dev);
+   int curr_len;
+   u8 lvl;
+
+   curr_len = snprintf(buf, PAGE_SIZE,
+   "\nCurrent System PM level [%d] => dev_state [%s] 
link_state [%s]\n",
+   hba->spm_lvl,
+   ufschd_ufs_dev_pwr_mode_to_string(
+ 

[PATCH v3 03/12] scsi: ufs: fix multiple ufs spec violation

2016-12-22 Thread Subhash Jadavani
From: Dolev Raviv 

When a command to a W-LU is timed out via scsi, error handling
will treat it as any other LU and send commands such as
START_STOP with wrong format or task abort. Those commands are
illegal for W-LU according to the UFS spec.
To solve it, when an error is recognized those steps are skipped
and the last step, reset and restore process, is initiated.

Signed-off-by: Dolev Raviv 
Signed-off-by: Subhash Jadavani 
---
 drivers/scsi/ufs/ufshcd.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index d718cb6..2e7c172 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -218,6 +218,7 @@ enum {
 static void ufshcd_tmc_handler(struct ufs_hba *hba);
 static void ufshcd_async_scan(void *data, async_cookie_t cookie);
 static int ufshcd_reset_and_restore(struct ufs_hba *hba);
+static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd);
 static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag);
 static void ufshcd_hba_exit(struct ufs_hba *hba);
 static int ufshcd_probe_hba(struct ufs_hba *hba);
@@ -4730,6 +4731,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
host = cmd->device->host;
hba = shost_priv(host);
tag = cmd->request->tag;
+   lrbp = &hba->lrb[tag];
if (!ufshcd_valid_tag(hba, tag)) {
dev_err(hba->dev,
"%s: invalid command tag %d: cmd=0x%p, 
cmd->request=0x%p",
@@ -4737,6 +4739,16 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
BUG();
}
 
+   /*
+* Task abort to the device W-LUN is illegal. When this command
+* will fail, due to spec violation, scsi err handling next step
+* will be to send LU reset which, again, is a spec violation.
+* To avoid these unnecessary/illegal step we skip to the last error
+* handling stage: reset and restore.
+*/
+   if (lrbp->lun == UFS_UPIU_UFS_DEVICE_WLUN)
+   return ufshcd_eh_host_reset_handler(cmd);
+
ufshcd_hold(hba, false);
reg = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
/* If command is already aborted/completed, return SUCCESS */
@@ -4760,7 +4772,6 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
ufshcd_print_pwr_info(hba);
ufshcd_print_trs(hba, 1 << tag, true);
 
-   lrbp = &hba->lrb[tag];
for (poll_cnt = 100; poll_cnt; poll_cnt--) {
err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrbp->task_tag,
UFS_QUERY_TASK, &resp);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
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 02/12] scsi: ufs: add tracing support

2016-12-22 Thread Subhash Jadavani
This change adds the ftrace support for following:
1. UFS initialization time
2. Clock gating states
3. Clock scaling states
4. Power management APIs latency
5. BKOPs enable/disable

Usage:
echo 1 > /sys/kernel/debug/tracing/events/ufs/enable
cat /sys/kernel/debug/tracing/trace_pipe

Reviewed-by: Sahitya Tummala 
Signed-off-by: Subhash Jadavani 
---
Changes from v2 -> v3:
 - Used TRACE_DEFINE_ENUM to print out enums
---
 drivers/scsi/ufs/ufshcd.c  |  85 ++---
 include/trace/events/ufs.h | 185 +
 2 files changed, 258 insertions(+), 12 deletions(-)
 create mode 100644 include/trace/events/ufs.h

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index fe516b2..d718cb6 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -45,6 +45,9 @@
 #include "ufs_quirks.h"
 #include "unipro.h"
 
+#define CREATE_TRACE_POINTS
+#include 
+
 #define UFSHCD_REQ_SENSE_SIZE  18
 
 #define UFSHCD_ENABLE_INTRS(UTP_TRANSFER_REQ_COMPL |\
@@ -801,6 +804,8 @@ int ufshcd_hold(struct ufs_hba *hba, bool async)
case REQ_CLKS_OFF:
if (cancel_delayed_work(&hba->clk_gating.gate_work)) {
hba->clk_gating.state = CLKS_ON;
+   trace_ufshcd_clk_gating(dev_name(hba->dev),
+   hba->clk_gating.state);
break;
}
/*
@@ -811,6 +816,8 @@ int ufshcd_hold(struct ufs_hba *hba, bool async)
case CLKS_OFF:
scsi_block_requests(hba->host);
hba->clk_gating.state = REQ_CLKS_ON;
+   trace_ufshcd_clk_gating(dev_name(hba->dev),
+   hba->clk_gating.state);
schedule_work(&hba->clk_gating.ungate_work);
/*
 * fall through to check if we should wait for this
@@ -855,6 +862,8 @@ static void ufshcd_gate_work(struct work_struct *work)
if (hba->clk_gating.is_suspended ||
(hba->clk_gating.state == REQ_CLKS_ON)) {
hba->clk_gating.state = CLKS_ON;
+   trace_ufshcd_clk_gating(dev_name(hba->dev),
+   hba->clk_gating.state);
goto rel_lock;
}
 
@@ -870,6 +879,8 @@ static void ufshcd_gate_work(struct work_struct *work)
if (ufshcd_can_hibern8_during_gating(hba)) {
if (ufshcd_uic_hibern8_enter(hba)) {
hba->clk_gating.state = CLKS_ON;
+   trace_ufshcd_clk_gating(dev_name(hba->dev),
+   hba->clk_gating.state);
goto out;
}
ufshcd_set_link_hibern8(hba);
@@ -893,9 +904,11 @@ static void ufshcd_gate_work(struct work_struct *work)
 * new requests arriving before the current cancel work is done.
 */
spin_lock_irqsave(hba->host->host_lock, flags);
-   if (hba->clk_gating.state == REQ_CLKS_OFF)
+   if (hba->clk_gating.state == REQ_CLKS_OFF) {
hba->clk_gating.state = CLKS_OFF;
-
+   trace_ufshcd_clk_gating(dev_name(hba->dev),
+   hba->clk_gating.state);
+   }
 rel_lock:
spin_unlock_irqrestore(hba->host->host_lock, flags);
 out:
@@ -918,6 +931,7 @@ static void __ufshcd_release(struct ufs_hba *hba)
return;
 
hba->clk_gating.state = REQ_CLKS_OFF;
+   trace_ufshcd_clk_gating(dev_name(hba->dev), hba->clk_gating.state);
schedule_delayed_work(&hba->clk_gating.gate_work,
msecs_to_jiffies(hba->clk_gating.delay_ms));
 }
@@ -3932,6 +3946,7 @@ static int ufshcd_enable_auto_bkops(struct ufs_hba *hba)
}
 
hba->auto_bkops_enabled = true;
+   trace_ufshcd_auto_bkops_state(dev_name(hba->dev), "Enabled");
 
/* No need of URGENT_BKOPS exception from the device */
err = ufshcd_disable_ee(hba, MASK_EE_URGENT_BKOPS);
@@ -3982,6 +3997,7 @@ static int ufshcd_disable_auto_bkops(struct ufs_hba *hba)
}
 
hba->auto_bkops_enabled = false;
+   trace_ufshcd_auto_bkops_state(dev_name(hba->dev), "Disabled");
 out:
return err;
 }
@@ -5377,6 +5393,7 @@ static void ufshcd_tune_unipro_params(struct ufs_hba *hba)
 static int ufshcd_probe_hba(struct ufs_hba *hba)
 {
int ret;
+   ktime_t start = ktime_get();
 
ret = ufshcd_link_startup(hba);
if (ret)
@@ -5468,6 +5485,9 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
ufshcd_hba_exit(hba);
}
 
+   trace_ufshcd_init(dev_name(hba->dev), ret,
+   ktime_to_us(ktime_sub(ktime_get(), start)),
+   hba->uic_link_state, hba->curr_dev_pwr_mode);
return ret;
 }
 
@@ -5817,11 +5837,14 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, 
bool on,
if (!IS_ERR_OR_NULL(

[PATCH v3 01/12] scsi: ufs: dump debug info during failures

2016-12-22 Thread Subhash Jadavani
From: Dolev Raviv 

Inserts driver dumps for UFS Host Controller registers, Transfer Requests
and Task Management Requests.
The dumps will occur on driver initialization failure, ufshcd_abort() and
on error handling path.

Signed-off-by: Dolev Raviv 
Signed-off-by: Subhash Jadavani 
---
Changes from v1 -> v2:
 - Added explicit new line character at the end of the printk messages.
 - Fixed couple of checkpatch warnings.
---
 drivers/scsi/ufs/ufshcd.c | 129 ++
 drivers/scsi/ufs/ufshci.h |   3 ++
 2 files changed, 132 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index af7e028..fe516b2 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -94,6 +94,9 @@
_ret;   \
})
 
+#define ufshcd_hex_dump(prefix_str, buf, len) \
+print_hex_dump(KERN_ERR, prefix_str, DUMP_PREFIX_OFFSET, 16, 4, buf, len, 
false)
+
 static u32 ufs_query_desc_max_size[] = {
QUERY_DESC_DEVICE_MAX_SIZE,
QUERY_DESC_CONFIGURAION_MAX_SIZE,
@@ -267,6 +270,77 @@ static inline void ufshcd_remove_non_printable(char *val)
*val = ' ';
 }
 
+static void ufshcd_print_host_regs(struct ufs_hba *hba)
+{
+   /*
+* hex_dump reads its data without the readl macro. This might
+* cause inconsistency issues on some platform, as the printed
+* values may be from cache and not the most recent value.
+* To know whether you are looking at an un-cached version verify
+* that IORESOURCE_MEM flag is on when xxx_get_resource() is invoked
+* during platform/pci probe function.
+*/
+   ufshcd_hex_dump("host regs: ", hba->mmio_base, UFSHCI_REG_SPACE_SIZE);
+   dev_err(hba->dev, "hba->ufs_version = 0x%x, hba->capabilities = 0x%x\n",
+   hba->ufs_version, hba->capabilities);
+   dev_err(hba->dev,
+   "hba->outstanding_reqs = 0x%x, hba->outstanding_tasks = 0x%x\n",
+   (u32)hba->outstanding_reqs, (u32)hba->outstanding_tasks);
+}
+
+static
+void ufshcd_print_trs(struct ufs_hba *hba, unsigned long bitmap, bool pr_prdt)
+{
+   struct ufshcd_lrb *lrbp;
+   int tag;
+
+   for_each_set_bit(tag, &bitmap, hba->nutrs) {
+   lrbp = &hba->lrb[tag];
+
+   dev_err(hba->dev, "UPIU[%d] - Transfer Request Descriptor\n",
+   tag);
+   ufshcd_hex_dump("UPIU TRD: ", lrbp->utr_descriptor_ptr,
+   sizeof(struct utp_transfer_req_desc));
+   dev_err(hba->dev, "UPIU[%d] - Request UPIU\n", tag);
+   ufshcd_hex_dump("UPIU REQ: ", lrbp->ucd_req_ptr,
+   sizeof(struct utp_upiu_req));
+   dev_err(hba->dev, "UPIU[%d] - Response UPIU\n", tag);
+   ufshcd_hex_dump("UPIU RSP: ", lrbp->ucd_rsp_ptr,
+   sizeof(struct utp_upiu_rsp));
+   if (pr_prdt) {
+   int prdt_length = le16_to_cpu(
+   lrbp->utr_descriptor_ptr->prd_table_length);
+
+   dev_err(hba->dev, "UPIU[%d] - PRDT - %d entries\n", tag,
+   prdt_length);
+   ufshcd_hex_dump("UPIU PRDT: ", lrbp->ucd_prdt_ptr,
+   sizeof(struct ufshcd_sg_entry) *
+   prdt_length);
+   }
+   }
+}
+
+static void ufshcd_print_tmrs(struct ufs_hba *hba, unsigned long bitmap)
+{
+   struct utp_task_req_desc *tmrdp;
+   int tag;
+
+   for_each_set_bit(tag, &bitmap, hba->nutmrs) {
+   tmrdp = &hba->utmrdl_base_addr[tag];
+   dev_err(hba->dev, "TM[%d] - Task Management Header\n", tag);
+   ufshcd_hex_dump("TM TRD: ", &tmrdp->header,
+   sizeof(struct request_desc_header));
+   dev_err(hba->dev, "TM[%d] - Task Management Request UPIU\n",
+   tag);
+   ufshcd_hex_dump("TM REQ: ", tmrdp->task_req_upiu,
+   sizeof(struct utp_upiu_req));
+   dev_err(hba->dev, "TM[%d] - Task Management Response UPIU\n",
+   tag);
+   ufshcd_hex_dump("TM RSP: ", tmrdp->task_rsp_upiu,
+   sizeof(struct utp_task_req_desc));
+   }
+}
+
 /*
  * ufshcd_wait_for_register - wait for register value to change
  * @hba - per-adapter interface
@@ -2392,6 +2466,32 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba)
 }
 
 /**
+ * ufshcd_print_pwr_info - print power params as saved in hba
+ * power info
+ * @hba: per-adapter instance
+ */
+static void ufshcd_print_pwr_info(struct ufs_hba *hba)
+{
+   static const char * const names[] = {
+   "INVALID MODE",
+   "FAST MODE",
+   "SLOW_MODE",
+   "INV

[PATCH v3 00/12] scsi: ufs: add trace/debug support, sysfs controls and few fixes

2016-12-22 Thread Subhash Jadavani
This patch series adds following things:
 - ftrace support to trace important events in UFS driver.
 - debug dumps following failures to ease the debugging
 - sysfs node to control clock gating, clock scaling and PM
 - few fixes

---
Changes from v2 -> v3:

1. Patch #2: Used TRACE_DEFINE_ENUM to print out enums

2. Patch #11: Removed conditional compilation based on CONFIG_TRACEPOINTS
   and used trace_*_enabled() to skip unnecessary code path execution.

3. Patch #7: Simplified patch to just set the default power management
   level. Device tree capability to specify broken hardware will be taken
   up as separate patch in different patch series than current one.

1 & 2 should address Steven Rostedt's comments.

3 should address Rob Herring's comments.

Changes from v1 -> v2:
 - Added explicit new line character at the end of the printk messages
   for patch #1 & #12
 - Fixed couple of checkpatch warnings for patch #1
---

Dolev Raviv (3):
  scsi: ufs: dump debug info during failures
  scsi: ufs: fix multiple ufs spec violation
  scsi: ufs: Improve fatal error logs

Lee Susman (1):
  scsi: ufs: add trace event for ufs commands

Sahitya Tummala (2):
  scsi: ufs: Add sysfs node to dynamically control clock gating
  scsi: ufs: Add sysfs node to dynamically control clock scaling

Subhash Jadavani (6):
  scsi: ufs: add tracing support
  scsi: ufs: provide sysfs attribute to select the PM level
  scsi: ufs: set default UFS power management level
  scsi: ufs: add capability to keep auto bkops always enabled
  scsi: ufs: fix setting init power mode
  scsi: ufs: add time profiling support

 drivers/scsi/ufs/ufshcd.c  | 785 +
 drivers/scsi/ufs/ufshcd.h  |  70 +++-
 drivers/scsi/ufs/ufshci.h  |   3 +
 include/trace/events/ufs.h | 263 +++
 4 files changed, 1066 insertions(+), 55 deletions(-)
 create mode 100644 include/trace/events/ufs.h

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

--
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 V6 03/11] megaraid_sas: EEDP Escape Mode Support for SAS3.5 Generic Megaraid Controllers

2016-12-22 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 and same as V5

Signed-off-by: Sasikumar Chandrasekaran 
Reviewed-by: Tomas Henzl 
---
 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 413e2030..fe69c4a 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 V6 02/11] megaraid_sas: 128 MSIX Support

2016-12-22 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 and same as V5

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

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index cb82195..36aac88 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2148,6 +2148,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 ea04fce..5a1a53b 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -5072,13 +5072,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) &
@@ -5098,6 +5092,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;
@@ -5131,6 +5128,20 @@ 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);
+   }
+
i = pci_alloc_irq_vectors(instance->pdev, 1, 1, PCI_IRQ_LEGACY);
if (i < 0)
goto fail_setup_irqs;
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 8d7a397..413e2030 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 V6 01/11] megaraid_sas: Add new pci device Ids for SAS3.5 Generic Megaraid Controllers

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

This Pacth is Same as V5

Signed-off-by: Sasikumar Chandrasekaran 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas.h| 12 +---
 drivers/scsi/megaraid/megaraid_sas_base.c   | 14 +-
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 30 ++---
 3 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index fdd519c..cb82195 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -56,6 +56,11 @@
 #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_VENTURA  0x0014
+#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
 
 /*
  * Intel HBA SSDIDs
@@ -100,7 +105,7 @@
  */
 
 /*
- * MFI stands for  MegaRAID SAS FW Interface. This is just a moniker for 
+ * MFI stands for  MegaRAID SAS FW Interface. This is just a moniker for
  * protocol between the software and firmware. Commands are issued using
  * "message frames"
  */
@@ -1435,7 +1440,7 @@ enum FW_BOOT_CONTEXT {
 * register set for both 1068 and 1078 controllers
 * structure extended for 1078 registers
 */
- 
+
 struct megasas_register_set {
u32 doorbell;   /*h*/
u32 fusion_seq_offset;  /*0004h*/
@@ -1478,7 +1483,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;
@@ -2142,6 +2147,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 6484c38..ea04fce 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -155,6 +155,12 @@ 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_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)},
{}
 };
 
@@ -5714,6 +5720,12 @@ 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_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:
@@ -5738,7 +5750,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..8d7a397 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_lo

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

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

This patch is depending on patch 6 and same as V5

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

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 403bbef..9f0253f 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -5042,34 +5042,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 = &megasas_instance_template_fusion;
-   break;
-   case PCI_DEVICE_ID_LSI_SAS1078R:
-   case PCI_DEVICE_ID_LSI_SAS1078DE:
-   instance->instancet = &megasas_instance_template_ppc;
-   break;
-   case PCI_DEVICE_ID_LSI_SAS1078GEN2:
-   case PCI_DEVICE_ID_LSI_SAS0079GEN2:
-   instance->instancet = &megasas_instance_template_gen2;
-   break;
-   case PCI_DEVICE_ID_LSI_SAS0073SKINNY:
-   case PCI_DEVICE_ID_LSI_SAS0071SKINNY:
-   instance->instancet = &megasas_instance_template_skinny;
-   break;
-   case PCI_DEVICE_ID_LSI_SAS1064R:
-   case PCI_DEVICE_ID_DELL_PERC5:
-   default:
-   instance->instancet = &megasas_instance_template_xscale;
-   break;
+   else {
+   switch (instance->pdev->device) {
+   case PCI_DEVICE_ID_LSI_SAS1078R:
+   case PCI_DEVICE_ID_LSI_SAS1078DE:
+   instance->instancet = &megasas_instance_template_ppc;
+   break;
+   case PCI_DEVICE_ID_LSI_SAS1078GEN2:
+   case PCI_DEVICE_ID_LSI_SAS0079GEN2:
+   instance->instancet = &megasas_instance_template_gen2;
+   break;
+   case PCI_DEVICE_ID_LSI_SAS0073SKINNY:
+   case PCI_DEVICE_ID_LSI_SAS0071SKINNY:
+   instance->instancet = &megasas_instance_template_skinny;
+   break;
+   case PCI_DEVICE_ID_LSI_SAS1064R:
+   case PCI_DEVICE_ID_DELL_PERC5:
+   default:
+   instance->instancet = &megasas_instance_template_xscale;
+   instance->pd_list_not_supported = 1;
+   break;
+   }
}
 
if (megasas_transition_to_ready(instance, 0)) {
@@ -5819,7 +5814,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 46f7e16..97a0008 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -244,7 +244,10 @@ inline void megasas_return_cmd_fusion(struct 
megasas_instance *instance,
 
reg_set = instance->reg_set;
 
-   cur_max_fw_cmds = readl(&instance->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(&instance->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;
@@ -837,7 +840,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 */
  

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

2016-12-22 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 and same as V5

Signed-off-by: Sasikumar Chandrasekaran 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas.h|   1 +
 drivers/scsi/megaraid/megaraid_sas_fp.c |  31 ++-
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 335 
 drivers/scsi/megaraid/megaraid_sas_fusion.h |  15 +-
 4 files changed, 329 insertions(+), 53 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 3d86bc6..a96889c 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2056,6 +2056,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 a4e213b..eb9ff44 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,16 @@ 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 +826,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 +874,17 @@ 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)
+   if (pd != MR_PD_INVALID) {
/* Get dev handle from Pd. */
*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 {
/* set dev handle as invalid. */
*pDevHandle = cpu_to_le16(MR_PD_INVALID);
if ((raid->level >= 5) &&
@@ -1126,6 +1140,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->is_raid_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 804b164..b5bb430 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c

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

2016-12-22 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

80 chars per line limit is taken care around VD_EXT_DEBUG macro.
NULL pointer check for desc_table has been removed.
Few code indentation issues fixed.

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas.h|   7 +
 drivers/scsi/megaraid/megaraid_sas_base.c   |  60 --
 drivers/scsi/megaraid/megaraid_sas_fp.c | 301 
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 226 -
 drivers/scsi/megaraid/megaraid_sas_fusion.h | 240 ++
 5 files changed, 696 insertions(+), 138 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index a96889c..6ddf994 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1434,6 +1434,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
 
 /*
@@ -2151,6 +2157,7 @@ struct megasas_instance {
bool fw_sync_cache_support;
bool is_ventura;
bool msix_combined;
+   u16 max_raid_mapsize;
 };
 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 acdafc7..403bbef 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4424,8 +4424,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 */
@@ -4455,21 +4454,38 @@ 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->max_raid_mapsize) {
+   ventura_map_sz = instance->max_raid_mapsize *
+   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(&instance->pdev->dev, "instance->max_raid_mapsize 0x%x\n ",
+   instance->max_raid_mapsize);
+   dev_info(&instance->pdev->dev, "new_map_sz = 0x%x, old_map_sz = 0x%x\n",
+   fusion->new_map_sz, fusion->old_map_sz);
+   dev_info(&instance->pdev->dev, "ventura_map_sz = 0x%x, current_map_sz = 
0x%x\n",
+   ventura_map_sz, fusion->current_map_sz);
+   dev_info(&instance->pdev->dev, "fusion->drv_map_sz =0x%x, size of 
driver raid map 0x%lx\n",
+   fusion->drv_map_sz, sizeof(struct MR_DRV_RAID_MAP_ALL));
+#endif
 }
 
 /**
@@ -4996,7 +5012,7 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
 {
u32 max_sectors_1;
u32 max_sectors_2;
-   u32 tmp_sectors, msi

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

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

This patch is depending on patch 3

Few code indentation issues fixed

Signed-off-by: Sasikumar Chandrasekaran 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas.h|   1 +
 drivers/scsi/megaraid/megaraid_sas_base.c   |  43 +++-
 drivers/scsi/megaraid/megaraid_sas_fp.c |   2 +
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 164 +++-
 drivers/scsi/megaraid/megaraid_sas_fusion.h | 117 +++-
 5 files changed, 296 insertions(+), 31 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 36aac88..3d86bc6 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2070,6 +2070,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 5a1a53b..acdafc7 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -5001,7 +5001,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;
 
@@ -5194,6 +5194,36 @@ 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->stream_detect_by_ld =
+   kzalloc(sizeof(struct LD_STREAM_DETECT *)
+   * MAX_LOGICAL_DRIVES_EXT,
+   GFP_KERNEL);
+   if (!fusion->stream_detect_by_ld) {
+   dev_err(&instance->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->stream_detect_by_ld[i] =
+   kmalloc(sizeof(struct LD_STREAM_DETECT),
+   GFP_KERNEL);
+   if (!fusion->stream_detect_by_ld[i]) {
+   dev_err(&instance->pdev->dev,
+   "unable to allocate stream detect by 
LD\n ");
+   for (j = 0; j < i; ++j)
+   kfree(fusion->stream_detect_by_ld[j]);
+   kfree(fusion->stream_detect_by_ld);
+   fusion->stream_detect_by_ld = NULL;
+   goto fail_get_ld_pd_list;
+   }
+   fusion->stream_detect_by_ld[i]->mru_bit_map
+   = MR_STREAM_BITMAP;
+   }
+   }
+
if (megasas_ld_list_query(instance,
  MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
megasas_get_ld_list(instance);
@@ -5313,6 +5343,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);
 fail_init_adapter:
@@ -5846,6 +5878,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
 
spin_lock_init(&instance->mfi_pool_lock);
spin_lock_init(&instance->hba_lock);
+   spin_lock_init(&instance->stream_lock);
spin_lock_init(&instance->completion_lock);
 
mutex_init(&instance->reset_mutex);
@@ -6353,6 +6386,14 @@ static void megasas_detach_one(struct pci_dev *pdev)
if (instance->msix_vectors)
pci_free_irq_vectors(instance->pdev);
 
+   if (instance->is_ventura) {
+   for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i)
+   kfree(fusion->stream_detect_by_ld[i]);
+   kfree(fusion->stream_detect_by_ld);
+   fusion->stream_detect_by_ld = 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..a4e213b 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 mega

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

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

This patch is depending on patch 7

80 chars per line limit is taken care around VD_EXT_DEBUG macro.

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas.h|  8 +
 drivers/scsi/megaraid/megaraid_sas_base.c   | 48 +
 drivers/scsi/megaraid/megaraid_sas_fp.c |  7 +
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 20 +++-
 drivers/scsi/megaraid/megaraid_sas_fusion.h |  2 +-
 5 files changed, 76 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 6ddf994..0696903 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1429,6 +1429,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
@@ -2101,6 +2103,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;
@@ -2142,6 +2148,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;
@@ -2158,6 +2165,7 @@ struct megasas_instance {
bool is_ventura;
bool msix_combined;
u16 max_raid_mapsize;
+   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 9f0253f..fd3bc6d 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1940,6 +1940,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(&instance->r1_fp_hold_timer);
+
 }
 
  /**
@@ -2438,6 +2441,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(&instance->bytes_wrote) >=
+   instance->pci_threshold_bandwidth) {
+
+   atomic64_set(&instance->bytes_wrote, 0);
+   atomic_set(&instance->r1_write_fp_capable, 0);
+   } else {
+   atomic64_set(&instance->bytes_wrote, 0);
+   atomic_set(&instance->r1_write_fp_capable, 1);
+   }
+   mod_timer(&instance->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
@@ -5362,6 +5383,17 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
instance->skip_heartbeat_timer_del = 1;
}
 
+   if (instance->is_ventura) {
+   atomic64_set(&instance->bytes_wrote, 0);
+   atomic_set(&instance->r1_write_fp_capable, 1);
+   megasas_start_timer(instance,
+   &instance->r1_fp_hold_timer,
+   megasas_change_r1_fp_status,
+   MEGASAS_RAID1_FAST_PATH_STATUS_CHECK_INTERVAL);
+   dev_info(&instance->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:
@@ -6152,6 +6184,9 @@ static void megasas_shutdown_controller(struct 
megasas_instance *instance,
if (instance->requestorId && !instance->skip_heartbeat_timer_del)
del_timer_sync(&instance->sriov_heartbeat_timer);
 
+   if (instance->is_ventura)
+   del_timer_sync(&instance->r1_fp_hold_timer);
+
megasas_flush_cache(instance);
megasas_shutdown_controller(instance, MR_DCMD_HIBERNATE_SHUTDOWN);
 
@@ -6278,6 +6313,16 @@ static void megasas_shutdown_controller(struct 
megasas_instance *instance,
megasas_setu

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

2016-12-22 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 and same as V5

Signed-off-by: Sasikumar Chandrasekaran 
Reviewed-by: Tomas Henzl 
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index aa508b3..a3382cf 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -2579,7 +2579,6 @@ void megasas_prepare_secondRaid1_IO(struct 
megasas_instance *instance,
 
if (atomic_inc_return(&instance->fw_outstanding) >
instance->host->can_queue) {
-   dev_err(&instance->pdev->dev, "Throttle IOs beyond Controller 
queue depth\n");
atomic_dec(&instance->fw_outstanding);
return SCSI_MLQUEUE_HOST_BUSY;
}
@@ -2811,6 +2810,9 @@ 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.ex_status 
= 0;
+   if (instance->ldio_threshold
+   && megasas_cmd_type(scmd_local) == 
READ_WRITE_LDIO)
+   atomic_dec(&instance->ldio_outstanding);
megasas_return_cmd_fusion(instance, cmd_fusion);
scsi_dma_unmap(scmd_local);
scmd_local->scsi_done(scmd_local);
@@ -3959,7 +3961,8 @@ 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(&instance->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 V6 11/11] megaraid_sas: driver version upgrade

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

This patch is depending on patch 10 and same as V5

Signed-off-by: Sasikumar Chandrasekaran 
Reviewed-by: Tomas Henzl 
---
 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 d2dc340..5412759 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 V6 10/11] megaraid_sas: Implement the PD Map support for SAS3.5 Generic Megaraid Controllers

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

This patch is depending on patch 9 and same as V5

Signed-off-by: Sasikumar Chandrasekaran 
---
 drivers/scsi/megaraid/megaraid_sas.h| 105 +---
 drivers/scsi/megaraid/megaraid_sas_base.c   |   3 +
 drivers/scsi/megaraid/megaraid_sas_fusion.c |   6 ++
 drivers/scsi/megaraid/megaraid_sas_fusion.h |   3 +-
 4 files changed, 89 insertions(+), 28 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 0696903..d2dc340 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1317,7 +1317,55 @@ 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 cpld_in_flash:1;
+#else
+   u8 cpld_in_flash:1;
+   u8 reserved:7;
+#endif
+   u8 reserved1[3];
+   /* Null terminated string. Has the version
+   *  information if cpld_in_flash = FALSE
+   */
+   u8 userCodeDefinition[12];
+   } cpld;  /* Valid only if upgradableCPLD is TRUE */
+
+   struct {
+   #if defined(__BIG_ENDIAN_BITFIELD)
+   u16 reserved:8;
+   u16 fw_swaps_bbu_vpd_info:1;
+   u16 support_pd_map_target_id:1;
+   u16 support_ses_ctrl_in_multipathcfg:1;
+   u16 image_upload_supported:1;
+   u16 support_encrypted_mfc:1;
+   u16 supported_enc_algo:1;
+   u16 support_ibutton_less:1;
+   u16 ctrl_info_ext_supported:1;
+   #else
+
+   u16 ctrl_info_ext_supported:1;
+   u16 support_ibutton_less:1;
+   u16 supported_enc_algo:1;
+   u16 support_encrypted_mfc:1;
+   u16 image_upload_supported:1;
+   /* FW supports LUN based association and target port based */
+   u16 support_ses_ctrl_in_multipathcfg:1;
+   /* association for the SES device connected in multipath mode */
+/* FW defines Jbod target Id within MR_PD_CFG_SEQ */
+   u16 support_pd_map_target_id:1;
+   /* FW swaps relevant fields in MR_BBU_VPD_INFO_FIXED to
+   *  provide the data in little endian order
+   */
+   u16 fw_swaps_bbu_vpd_info:1;
+   u16 reserved:8;
+   #endif
+   } adapter_operations4;
+   u8 pad[0x800-0x7FE]; /* 0x7FE pad to 2K for expansion */
 } __packed;
 
 /*
@@ -1557,33 +1605,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 support_pd_map_target_id: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 support_core_affinity:1;
+   u32 security_protocol_cmds_fw:1;
+   u3

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

2016-12-22 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   | 240 +++--
 drivers/scsi/megaraid/megaraid_sas_fp.c | 341 +++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 750 +++-
 drivers/scsi/megaraid/megaraid_sas_fusion.h | 364 --
 5 files changed, 1557 insertions(+), 277 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


Re: [4.10, panic, regression] iscsi: null pointer deref at iscsi_tcp_segment_done+0x20d/0x2e0

2016-12-22 Thread Chris Leech
On Fri, Dec 23, 2016 at 07:53:50AM +0800, Ming Lei wrote:
> On Fri, Dec 23, 2016 at 2:50 AM, Chris Leech  wrote:
> > I'm not reproducing any problems with xfstests running over iscsi_tcp
> > right now.  Two 10G luns exported from an LIO target, attached directly
> > to a test VM as sda/sdb and xfstests configured to use sda1/sdb1 as
> > TEST_DEV and SCRATCH_DEV.
> >
> > The virtio scatterlist issue that popped right away for me is triggered
> > by an hdparm ioctl, which is being run by tuned on Fedora.  And that
> > actually seems to happen back on 4.9 as well :(
> 
> Could you share us what the specific hdparm cmd line is? I tried several
> random cmds over virtio-blk/virito-scsi, looks not see this problem.

Of course, looks like I've screwed up my bisect run on this so I'm still
taking a look.  It triggers for me with 'hdparm -B /dev/vda' but may
also depend on kernel configuration.

I started with the fedora rawhide config with a lot of debug on and
trimed it down with a localmodconfig run in the VM to speed up rebuilds.

Chris
--
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: [4.10, panic, regression] iscsi: null pointer deref at iscsi_tcp_segment_done+0x20d/0x2e0

2016-12-22 Thread Ming Lei
On Fri, Dec 23, 2016 at 2:50 AM, Chris Leech  wrote:
> On Thu, Dec 22, 2016 at 05:50:12PM +1100, Dave Chinner wrote:
>> On Wed, Dec 21, 2016 at 09:46:37PM -0800, Linus Torvalds wrote:
>> > On Wed, Dec 21, 2016 at 9:13 PM, Dave Chinner  wrote:
>> > >
>> > > There may be deeper issues. I just started running scalability tests
>> > > (e.g. 16-way fsmark create tests) and about a minute in I got a
>> > > directory corruption reported - something I hadn't seen in the dev
>> > > cycle at all.
>> >
>> > By "in the dev cycle", do you mean your XFS changes, or have you been
>> > tracking the merge cycle at least for some testing?
>>
>> I mean the three months leading up to the 4.10 merge, when all the
>> XFS changes were being tested against 4.9-rc kernels.
>>
>> The iscsi problem showed up when I updated the base kernel from
>> 4.9 to 4.10-current last week to test the pullreq I was going to
>> send you. I've been bust with other stuff until now, so I didn't
>> upgrade my working trees again until today in the hope the iscsi
>> problem had already been found and fixed.
>>
>> > > I unmounted the fs, mkfs'd it again, ran the
>> > > workload again and about a minute in this fired:
>> > >
>> > > [628867.607417] [ cut here ]
>> > > [628867.608603] WARNING: CPU: 2 PID: 16925 at mm/workingset.c:461 
>> > > shadow_lru_isolate+0x171/0x220
>> >
>> > Well, part of the changes during the merge window were the shadow
>> > entry tracking changes that came in through Andrew's tree. Adding
>> > Johannes Weiner to the participants.
>> >
>> > > Now, this workload does not touch the page cache at all - it's
>> > > entirely an XFS metadata workload, so it should not really be
>> > > affecting the working set code.
>> >
>> > Well, I suspect that anything that creates memory pressure will end up
>> > triggering the working set code, so ..
>> >
>> > That said, obviously memory corruption could be involved and result in
>> > random issues too, but I wouldn't really expect that in this code.
>> >
>> > It would probably be really useful to get more data points - is the
>> > problem reliably in this area, or is it going to be random and all
>> > over the place.
>>
>> The iscsi problem is 100% reproducable. create a pair of iscsi luns,
>> mkfs, run xfstests on them. iscsi fails a second after xfstests mounts
>> the filesystems.
>>
>> The test machine I'm having all these other problems on? stable and
>> steady as a rock using PMEM devices. Moment I go to use /dev/vdc
>> (i.e. run load/perf benchmarks) it starts falling over left, right
>> and center.
>
> I'm not reproducing any problems with xfstests running over iscsi_tcp
> right now.  Two 10G luns exported from an LIO target, attached directly
> to a test VM as sda/sdb and xfstests configured to use sda1/sdb1 as
> TEST_DEV and SCRATCH_DEV.
>
> The virtio scatterlist issue that popped right away for me is triggered
> by an hdparm ioctl, which is being run by tuned on Fedora.  And that
> actually seems to happen back on 4.9 as well :(

Could you share us what the specific hdparm cmd line is? I tried several
random cmds over virtio-blk/virito-scsi, looks not see this problem.


Thanks,
Ming Lei
--
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: JMS56x not working reliably with uas driver

2016-12-22 Thread Alan Stern
On Wed, 21 Dec 2016, George Cherian wrote:

> Hi Oliver,
> 
> I was working with this JMicron device and using the uas driver.
> I am seeing the following 2 issues.
> 
> 1) On connect I see the following messages.
> xhci_hcd :00:11.0: ERROR Transfer event for disabled endpoint or 
> incorrect stream ring
>   This was eliminated using the following scissor patch.
> 
> -8<
> [PATCH] usb: storage: unusual_uas: Add JMicron JMS56x to unusual device
> 
> This device gives the following error on detection.
> xhci_hcd :00:11.0: ERROR Transfer event for disabled endpoint or 
> incorrect stream ring
> 
> The same error is not seen when it is added to unusual_device
> list with US_FL_NO_REPORT_OPCODES passed.
> 
> Signed-off-by: George Cherian 
> ---
>   drivers/usb/storage/unusual_uas.h | 7 +++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/usb/storage/unusual_uas.h 
> b/drivers/usb/storage/unusual_uas.h
> index cbea9f3..d292299 100644
> --- a/drivers/usb/storage/unusual_uas.h
> +++ b/drivers/usb/storage/unusual_uas.h
> @@ -142,6 +142,13 @@ UNUSUAL_DEV(0x152d, 0x0567, 0x, 0x,
>   USB_SC_DEVICE, USB_PR_DEVICE, NULL,
>   US_FL_BROKEN_FUA | US_FL_NO_REPORT_OPCODES),
> 
> +/* Reported-by George Cherian  */
> +UNUSUAL_DEV(0x152d, 0x9561, 0x, 0x,
> +"JMicron",
> +"JMS56x",
> +USB_SC_DEVICE, USB_PR_DEVICE, NULL,
> +US_FL_NO_REPORT_OPCODES),
> +
>   /* Reported-by: Hans de Goede  */
>   UNUSUAL_DEV(0x2109, 0x0711, 0x, 0x,
>   "VIA",
> ->8

I don't see how this patch fixes anything.  Unless I'm mistaken, it
just avoids the problem by preventing the system from issuing the
command that provokes the error, rather than really fixing the
underlying error.

> 2) On disconnect I am seeing the following issue
> 
>   scsi host4: uas_post_reset: alloc streams error -19 after reset
>   sd 4:0:0:0: [sdb] Synchronizing SCSI cache
> 
> This is more fatal because after these messages the USB port becomes 
> unusable. Even an lsusb invocation hangs for ever.

This problem looks pretty simple.  uas doesn't check properly to see if 
the device was disconnected following a reset.

Try changing the line in uas_post_reset() that says:

if (devinfo->shutdown)

to:

if (devinfo->shutdown ||
devinfo->udev->state == USB_STATE_NOTATTACHED)

Alan Stern

--
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 03/11] lpfc: Deprecate lpfc_soft_wwn parameter

2016-12-22 Thread Sebastian Herbszt
James Smart wrote:
> Deprecate lpfc_soft_wwn parameter.
> No longer allow override of hw-assigned wwns
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 

Any reason to remove this functionality?
I was actually using it.

Sebastian
--
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 ] tcm_qla2xxx - Enhancements to the tcm_debug jammer code to jam only data movement commands

2016-12-22 Thread Laurence Oberman


- Original Message -
> From: "Bart Van Assche" 
> To: "himanshu madhani" , lober...@redhat.com, 
> n...@daterainc.com
> Cc: linux-scsi@vger.kernel.org
> Sent: Thursday, December 22, 2016 4:54:30 PM
> Subject: Re: [PATCH ] tcm_qla2xxx - Enhancements to the tcm_debug jammer code 
> to jam only data movement commands
> 
> On Thu, 2016-12-22 at 16:46 -0500, Laurence Oberman wrote:
> > Added the possibility of blocking only specific SCSI data movement commands
> > but allowing TUR'S to pass.
> > This has been helpful for debugging many driver/array interoperabilty
> > issues.
> 
> Hello Laurence,
> 
> Your work is appreciated and also that you are posting this patch for
> inclusion
> in the kernel. However, since this is functionality of which I think that it
> is
> useful for all target drivers, shouldn't this kind of functionality be added
> to
> the target core instead of one specific target driver?
> 
> Bart.

Hello Bart

Thank you for this.

Indeed, That's on my plate for next year to try rework this into the target 
core.
Its used a lot here at Red Hat for testing the F/C drivers and multipath via 
the LIO target server.
The first version of this is already in that allows jamming of all commands.
I wanted to share the enhancement which is very useful and has been working 
well here but indeed if we have this in the core its better.

I may have some questions for you as I work on that next year.
Many Thanks Bart for all your help this year.

Regards
Laurence
--
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 ] tcm_qla2xxx - Enhancements to the tcm_debug jammer code to jam only data movement commands

2016-12-22 Thread Bart Van Assche
On Thu, 2016-12-22 at 16:46 -0500, Laurence Oberman wrote:
> Added the possibility of blocking only specific SCSI data movement commands
> but allowing TUR'S to pass.
> This has been helpful for debugging many driver/array interoperabilty
> issues.

Hello Laurence,

Your work is appreciated and also that you are posting this patch for inclusion
in the kernel. However, since this is functionality of which I think that it is
useful for all target drivers, shouldn't this kind of functionality be added to
the target core instead of one specific target driver?

Bart.

[PATCH ] tcm_qla2xxx - Enhancements to the tcm_debug jammer code to jam only data movement commands

2016-12-22 Thread Laurence Oberman
Hello Himanshu and Nicholas,

Was going over my patches and remembered this one got lost.

Himanshu, you acked this already at some point.
Nicholas can we get this on next submission maybe.

Thanks
Laurence

Added the possibility of blocking only specific SCSI data movement commands
but allowing TUR'S to pass.
This has been helpful for debugging many driver/array interoperabilty
issues.

Folded documentation and code into single patch now

Tested by: Laurence Oberman 
Signed-off-by: Laurence Oberman 

 Documentation/scsi/tcm_qla2xxx.txt | 16 
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |  7 +++
 drivers/scsi/qla2xxx/tcm_qla2xxx.h |  1 +
 3 files changed, 24 insertions(+)

diff --git a/Documentation/scsi/tcm_qla2xxx.txt 
b/Documentation/scsi/tcm_qla2xxx.txt
index c3a670a..8d26d29 100644
--- a/Documentation/scsi/tcm_qla2xxx.txt
+++ b/Documentation/scsi/tcm_qla2xxx.txt
@@ -20,3 +20,19 @@ echo 1 > 
/sys/kernel/config/target/qla2xxx/21:00:00:24:ff:27:8f:ae/tpgt_1/attrib
 
 Disable jamming on host 4
 echo 0 > 
/sys/kernel/config/target/qla2xxx/21:00:00:24:ff:27:8f:ae/tpgt_1/attrib/jam_host
+
+New feature added with a new attribute called jam_data.
+
+Setting a boolean of 1 for jam_data will allow the allow the dropping of 
data-only SCSI 
+ commands but allow TUR commands to pass.
+Note that for this to work jam_host needs to be set to 0
+
+This has proven very useful for testing Low Level driver response.
+
+Enable host 4 for only data commands to be jammed
+echo 0 > 
/sys/kernel/config/target/qla2xxx/21:00:00:24:ff:27:8f:ae/tpgt_1/attrib/jam_host
+echo 1 > 
/sys/kernel/config/target/qla2xxx/21:00:00:24:ff:27:8f:ae/tpgt_1/attrib/jam_data
+
+Disable jamming on host 4
+echo 0 > 
/sys/kernel/config/target/qla2xxx/21:00:00:24:ff:27:8f:ae/tpgt_1/attrib/jam_host
+echo 0 > 
/sys/kernel/config/target/qla2xxx/21:00:00:24:ff:27:8f:ae/tpgt_1/attrib/jam_data

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 6643f6f..1cb3f02 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -473,6 +473,10 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, 
struct qla_tgt_cmd *cmd,
/* return, and dont run target_submit_cmd,discarding command */
return 0;
}
+   if (unlikely(tpg->tpg_attrib.jam_data && (cdb[0]==0x08 || cdb[0]==0x0A 
|| cdb[0]==0x28 || cdb[0]==0x2A))) {
+/* return, and dont run target_submit_cmd,discarding command 
if not TUR*/
+return 0;
+}
 #endif
 
cmd->vha->tgt_counters.qla_core_sbt_cmd++;
@@ -827,6 +831,7 @@ DEF_QLA_TPG_ATTRIB(prod_mode_write_protect);
 DEF_QLA_TPG_ATTRIB(demo_mode_login_only);
 #ifdef CONFIG_TCM_QLA2XXX_DEBUG
 DEF_QLA_TPG_ATTRIB(jam_host);
+DEF_QLA_TPG_ATTRIB(jam_data);
 #endif
 
 static struct configfs_attribute *tcm_qla2xxx_tpg_attrib_attrs[] = {
@@ -837,6 +842,7 @@ static struct configfs_attribute 
*tcm_qla2xxx_tpg_attrib_attrs[] = {
&tcm_qla2xxx_tpg_attrib_attr_demo_mode_login_only,
 #ifdef CONFIG_TCM_QLA2XXX_DEBUG
&tcm_qla2xxx_tpg_attrib_attr_jam_host,
+   &tcm_qla2xxx_tpg_attrib_attr_jam_data,
 #endif
NULL,
 };
@@ -1011,6 +1017,7 @@ static struct se_portal_group *tcm_qla2xxx_make_tpg(
tpg->tpg_attrib.cache_dynamic_acls = 1;
tpg->tpg_attrib.demo_mode_login_only = 1;
tpg->tpg_attrib.jam_host = 0;
+   tpg->tpg_attrib.jam_data = 0;
 
ret = core_tpg_register(wwn, &tpg->se_tpg, SCSI_PROTOCOL_FCP);
if (ret < 0) {
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.h 
b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
index 37e026a..789bdeb 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.h
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
@@ -35,6 +35,7 @@ struct tcm_qla2xxx_tpg_attrib {
int demo_mode_login_only;
int fabric_prot_type;
int jam_host;
+   int jam_data;
 };
 
 struct tcm_qla2xxx_tpg {
-- 
2.5.5
--
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[GIT PULL] final round of SCSI updates for the 4.9+ merge window

2016-12-22 Thread James Bottomley
This is mostly stuff which missed the initial pull.  There's a new
driver: qedi, some ufs, ibmvscsis and ncr5380 updates plus some
assorted driver fixes and also a fix for the bug where if a device goes
into a blocked state between configuration and sysfs device add (which
can be a long time under async probing) it would become permanently
blocked.

The patch is available here:

git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git scsi-for-linus

The short changelog is:

Adam Manzanares (1):
  scsi: mpt3sas: Recognize and act on iopriority info

Adam Radford (1):
  scsi: Update 3ware driver email addresses

Amit Kushwaha (1):
  scsi: hpsa: remove memory allocate failure message

Benjamin Block (1):
  scsi: zfcp: fix use-after-"free" in FC ingress path after TMF

Finn Thain (2):
  scsi: g_NCR5380: Autoprobe board IRQ by default
  scsi: g_NCR5380: Fix automatic IRQ on HP C2502 cards

Kevin Barnett (1):
  scsi: aacraid: remove wildcard for series 9 controllers

Manish Rangankar (1):
  scsi: qedi: Add QLogic FastLinQ offload iSCSI driver framework.

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

Ondrej Zary (2):
  scsi: g_NCR5380: Use probe_irq_*() for IRQ probing
  scsi: g_NCR5380: Check for chip presence before calling NCR5380_init()

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

Steffen Maier (2):
  scsi: zfcp: fix rport unblock race with LUN recovery
  scsi: zfcp: do not trace pure benign residual HBA responses at default 
level

Subhash Jadavani (2):
  scsi: ufs-qcom: fix bug with read/modify write of UFS_CFG1
  scsi: ufs: add quirk to increase host PA_SaveConfigTime

Tyrel Datwyler (3):
  scsi: ibmvscsi: add write memory barrier to CRQ processing
  scsi: ibmvscsi: log bad SRP response opcode in hex format
  scsi: ibmvscsi: add vscsi hosts to global list_head

Varun Prakash (5):
  scsi: libcxgbi: return error if interface is not up
  scsi: cxgb4i: libcxgbi: add missing module_put()
  scsi: cxgb4i: libcxgbi: cxgb4: add T6 iSCSI completion feature
  scsi: cxgb4i: libcxgbi: add active open cmd for T6 adapters
  scsi: cxgb4i: use cxgb4_tp_smt_idx() to get smt_idx

Wei Fang (1):
  scsi: avoid a permanent stop of the scsi device's request queue

Yaniv Gardi (2):
  scsi: ufs-qcom: add probe_defer in case phy driver not probed yet
  scsi: ufs: add support for UFS HCI 2.1

himanshu.madh...@cavium.com (1):
  scsi: qla2xxx: Only allow operational MBX to proceed during RESET.

and the diffstat:

 Documentation/scsi/g_NCR5380.txt|   46 +-
 MAINTAINERS |8 +-
 drivers/net/ethernet/chelsio/cxgb4/t4_msg.h |   13 +
 drivers/s390/scsi/zfcp_dbf.c|   17 +-
 drivers/s390/scsi/zfcp_dbf.h|   41 +-
 drivers/s390/scsi/zfcp_erp.c|   61 +-
 drivers/s390/scsi/zfcp_ext.h|4 +-
 drivers/s390/scsi/zfcp_fsf.h|3 +-
 drivers/s390/scsi/zfcp_reqlist.h|   30 +-
 drivers/s390/scsi/zfcp_scsi.c   |   61 +-
 drivers/scsi/3w-9xxx.c  |9 +-
 drivers/scsi/3w-9xxx.h  |9 +-
 drivers/scsi/3w-sas.c   |7 +-
 drivers/scsi/3w-sas.h   |7 +-
 drivers/scsi/3w-.c  |7 +-
 drivers/scsi/3w-.h  |5 +-
 drivers/scsi/Kconfig|1 +
 drivers/scsi/Makefile   |1 +
 drivers/scsi/NCR5380.c  |   77 +-
 drivers/scsi/NCR5380.h  |   11 -
 drivers/scsi/aacraid/linit.c|2 -
 drivers/scsi/cxgbi/cxgb4i/cxgb4i.c  |  320 +++-
 drivers/scsi/cxgbi/libcxgbi.c   |   40 +-
 drivers/scsi/cxgbi/libcxgbi.h   |2 +
 drivers/scsi/g_NCR5380.c|  153 +-
 drivers/scsi/g_NCR5380.h|2 +
 drivers/scsi/hpsa.c |   37 +-
 drivers/scsi/ibmvscsi/ibmvscsi.c|7 +-
 drivers/scsi/ibmvscsi/ibmvscsi.h|1 +
 drivers/scsi/mpt3sas/mpt3sas_base.h |6 +
 drivers/scsi/mpt3sas/mpt3sas_ctl.c  |   43 +-
 drivers/scsi/mpt3sas/mpt3sas_scsih.c|   34 +-
 drivers/scsi/qedi/Kconfig   |   10 +
 drivers/scsi/qedi/Makefile  |5 +
 drivers/scsi/qedi/qedi.h|  364 
 drivers/scsi/qedi/qedi_dbg.c|  143 ++
 drivers/scsi/qedi/qedi_dbg.h|  144 ++
 drivers/scsi/qedi/qedi_debugfs.c|  244 +++
 drivers/scsi/qedi/qedi_fw.c | 2378 +++
 drivers/scsi/qedi/qedi_gbl.h|   73 +
 drivers/scsi/qedi/qedi_hs

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

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

--- Comment #10 from mus@gmail.com ---
Created attachment 248381
  --> https://bugzilla.kernel.org/attachment.cgi?id=248381&action=edit
Kernel Panic Arch Linux x64 kernel 4.9

Attached is a kernel panic I get with Arch Linux x64 and kernel 4.9.
Unfortunately I can't get the whole stack trace. I tried to up the resolution
with the vga= parameter but then the screen stays black. I actually got it to
boot once, but had no other success after 10 other tries.

The stacktrace looks very similiar to Bug 58201 (comment 20 on this bug also
mentions the same problem with vga=).

Since Fedora and Ubuntu are fixed by the BIOS upgrade but Arch Linux still
doesn't boot, I guess this may be related to different kernel configs? Any
hints on which configs could affect this?

-- 
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: [4.10, panic, regression] iscsi: null pointer deref at iscsi_tcp_segment_done+0x20d/0x2e0

2016-12-22 Thread Hugh Dickins
On Wed, 21 Dec 2016, Linus Torvalds wrote:
> On Wed, Dec 21, 2016 at 9:13 PM, Dave Chinner  wrote:
> >
> > There may be deeper issues. I just started running scalability tests
> > (e.g. 16-way fsmark create tests) and about a minute in I got a
> > directory corruption reported - something I hadn't seen in the dev
> > cycle at all.
> 
> By "in the dev cycle", do you mean your XFS changes, or have you been
> tracking the merge cycle at least for some testing?
> 
> > I unmounted the fs, mkfs'd it again, ran the
> > workload again and about a minute in this fired:
> >
> > [628867.607417] [ cut here ]
> > [628867.608603] WARNING: CPU: 2 PID: 16925 at mm/workingset.c:461 
> > shadow_lru_isolate+0x171/0x220
> 
> Well, part of the changes during the merge window were the shadow
> entry tracking changes that came in through Andrew's tree. Adding
> Johannes Weiner to the participants.
> 
> > Now, this workload does not touch the page cache at all - it's
> > entirely an XFS metadata workload, so it should not really be
> > affecting the working set code.
> 
> Well, I suspect that anything that creates memory pressure will end up
> triggering the working set code, so ..
> 
> That said, obviously memory corruption could be involved and result in
> random issues too, but I wouldn't really expect that in this code.
> 
> It would probably be really useful to get more data points - is the
> problem reliably in this area, or is it going to be random and all
> over the place.

Data point: kswapd got WARNING on mm/workingset.c:457 in shadow_lru_isolate,
soon followed by NULL pointer deref in list_lru_isolate, one time when
I tried out Sunday's git tree.  Not seen since, I haven't had time to
investigate, just set it aside as something to worry about if it happens
again.  But it looks like shadow_lru_isolate() has issues beyond Dave's
case (I've no XFS and no iscsi), suspect unrelated to his other problems.

Hugh

> 
> That said:
> 
> > And worse, on that last error, the /host/ is now going into meltdown
> > (running 4.7.5) with 32 CPUs all burning down in ACPI code:
> 
> The obvious question here is how much you trust the environment if the
> host ends up also showing problems. Maybe you do end up having hw
> issues pop up too.
> 
> The primary suspect would presumably be the development kernel you're
> testing triggering something, but it has to be asked..
> 
>  Linus
--
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: block: add back plugging in __blkdev_direct_IO

2016-12-22 Thread kbuild test robot
Hi Christoph,

[auto build test ERROR on linus/master]
[also build test ERROR on next-20161222]
[cannot apply to v4.9]
[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/Christoph-Hellwig/block-add-back-plugging-in-__blkdev_direct_IO/20161223-002453
config: x86_64-lkp (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=x86_64 

All errors (new ones prefixed by >>):

   fs/iomap.c: In function 'iomap_dio_rw':
>> fs/iomap.c:897:18: error: 'plug' undeclared (first use in this function)
 blk_start_plug(&plug);
 ^~~~
   fs/iomap.c:897:18: note: each undeclared identifier is reported only once 
for each function it appears in

vim +/plug +897 fs/iomap.c

ff6a9292 Christoph Hellwig 2016-11-30  891  WARN_ON_ONCE(ret);
ff6a9292 Christoph Hellwig 2016-11-30  892  ret = 0;
ff6a9292 Christoph Hellwig 2016-11-30  893  }
ff6a9292 Christoph Hellwig 2016-11-30  894  
ff6a9292 Christoph Hellwig 2016-11-30  895  inode_dio_begin(inode);
ff6a9292 Christoph Hellwig 2016-11-30  896  
ff6a9292 Christoph Hellwig 2016-11-30 @897  blk_start_plug(&plug);
ff6a9292 Christoph Hellwig 2016-11-30  898  do {
ff6a9292 Christoph Hellwig 2016-11-30  899  ret = 
iomap_apply(inode, pos, count, flags, ops, dio,
ff6a9292 Christoph Hellwig 2016-11-30  900  
iomap_dio_actor);

:: The code at line 897 was first introduced by commit
:: ff6a9292e6f633d596826be5ba70d3ef90cc3300 iomap: implement direct I/O

:: TO: Christoph Hellwig 
:: CC: Dave Chinner 

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


.config.gz
Description: application/gzip


Re: block: add back plugging in __blkdev_direct_IO

2016-12-22 Thread kbuild test robot
Hi Christoph,

[auto build test ERROR on linus/master]
[also build test ERROR on next-20161222]
[cannot apply to v4.9]
[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/Christoph-Hellwig/block-add-back-plugging-in-__blkdev_direct_IO/20161223-002453
config: x86_64-rhel (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=x86_64 

All errors (new ones prefixed by >>):

   fs/iomap.c: In function 'iomap_dio_rw':
>> fs/iomap.c:897:18: error: 'plug' undeclared (first use in this function)
 blk_start_plug(&plug);
 ^~~~
   fs/iomap.c:897:18: note: each undeclared identifier is reported only once 
for each function it appears in

vim +/plug +897 fs/iomap.c

ff6a9292 Christoph Hellwig 2016-11-30  891  WARN_ON_ONCE(ret);
ff6a9292 Christoph Hellwig 2016-11-30  892  ret = 0;
ff6a9292 Christoph Hellwig 2016-11-30  893  }
ff6a9292 Christoph Hellwig 2016-11-30  894  
ff6a9292 Christoph Hellwig 2016-11-30  895  inode_dio_begin(inode);
ff6a9292 Christoph Hellwig 2016-11-30  896  
ff6a9292 Christoph Hellwig 2016-11-30 @897  blk_start_plug(&plug);
ff6a9292 Christoph Hellwig 2016-11-30  898  do {
ff6a9292 Christoph Hellwig 2016-11-30  899  ret = 
iomap_apply(inode, pos, count, flags, ops, dio,
ff6a9292 Christoph Hellwig 2016-11-30  900  
iomap_dio_actor);

:: The code at line 897 was first introduced by commit
:: ff6a9292e6f633d596826be5ba70d3ef90cc3300 iomap: implement direct I/O

:: TO: Christoph Hellwig 
:: CC: Dave Chinner 

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


.config.gz
Description: application/gzip


Hello

2016-12-22 Thread info
Hello,

Complement of the Season, I'M Anessa female 25 years old single, I am 
contacting you because I will be relocating to your country. I will send you my 
photos and also tell you much about my self. 
Thanks.

Sincerely yours
Anessa.
--
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: iscsi_trx going into D state

2016-12-22 Thread Doug Ledford
On 12/21/2016 6:39 PM, Robert LeBlanc wrote:
> I hit a new backtrace today, hopefully it adds something.
> 
> # cat /proc/19659/stack
> [] iscsit_stop_session+0x1b1/0x1c0
> [] iscsi_check_for_session_reinstatement+0x1e2/0x270
> [] iscsi_target_check_for_existing_instances+0x30/0x40
> [] iscsi_target_do_login+0x138/0x630
> [] iscsi_target_start_negotiation+0x4e/0xa0
> [] __iscsi_target_login_thread+0x83e/0xf20
> [] iscsi_target_login_thread+0x24/0x30
> [] kthread+0xd9/0xf0
> [] ret_from_fork+0x25/0x30
> [] 0x
> 
> # cat /proc/21342/stack
> [] __ib_drain_sq+0x190/0x1c0 [ib_core]
> [] ib_drain_sq+0x25/0x30 [ib_core]
> [] ib_drain_qp+0x12/0x30 [ib_core]
> [] isert_wait_conn+0x5f/0x2d0 [ib_isert]
> [] iscsit_close_connection+0x157/0x860
> [] iscsit_take_action_for_connection_exit+0x7b/0xf0
> [] iscsi_target_rx_thread+0x95/0xa0
> [] kthread+0xd9/0xf0
> [] ret_from_fork+0x25/0x30
> [] 0x
> 
> # ps aux | grep iscsi | grep D
> root 19659  0.0  0.0  0 0 ?D16:12   0:00 [iscsi_np]
> root 21342  0.0  0.0  0 0 ?D16:29   0:00 [iscsi_trx]
> 
> Robert LeBlanc
> PGP Fingerprint 79A2 9CA4 6CC4 45DD A904  C70E E654 3BB2 FA62 B9F1

That looks suspiciously like the __ib_drain_sq is stuck forever waiting
on a completion that never comes.

> 
> On Thu, Dec 15, 2016 at 1:38 PM, Robert LeBlanc  wrote:
>> Nicholas,
>>
>> I've found that the kernels I used were not able to be inspected using
>> crash and I could not build the debug info for them. So I built a new
>> 4.9 kernel and verified that I could inspect the crash. It is located
>> at [1].
>>
>> [1] http://mirrors.betterservers.com/trace/crash2.tar.xz
>> 
>> Robert LeBlanc
>> PGP Fingerprint 79A2 9CA4 6CC4 45DD A904  C70E E654 3BB2 FA62 B9F1
>>
>>
>> On Mon, Dec 12, 2016 at 4:57 PM, Robert LeBlanc  wrote:
>>> Nicholas,
>>>
>>> After lots of set backs and having to give up trying to get kernel
>>> dumps on our "production" systems, I've been able to work out the
>>> issues we had with kdump and replicate the issue on my dev boxes. I
>>> have dumps from 4.4.30 and 4.9-rc8 (makedumpfile would not dump, so it
>>> is a straight copy of /proc/vmcore from the crash kernel). In each
>>> crash directory, I put a details.txt file that has the process IDs
>>> that were having problems and a brief description of the set-up at the
>>> time. This was mostly replicated by starting fio and pulling the
>>> Infiniband cable until fio gave up. This hardware also has Mellanox
>>> ConnectX4-LX cards and I also replicated the issue over RoCE using 4.9
>>> since it has the drivers in-box. Please let me know if you need more
>>> info, I can test much faster now. The cores/kernels/modules are
>>> located at [1].
>>>
>>> [1] http://mirrors.betterservers.com/trace/crash.tar.xz
>>>
>>> Thanks,
>>> Robert
>>> 
>>> Robert LeBlanc
>>> PGP Fingerprint 79A2 9CA4 6CC4 45DD A904  C70E E654 3BB2 FA62 B9F1
>>>
>>>
>>> On Fri, Nov 4, 2016 at 3:57 PM, Robert LeBlanc  wrote:
 We hit this yesterday, this time it was on the tx thread (the other
 ones before seem to be on the rx thread). We weren't able to get a
 kernel dump on this. We'll try to get one next time.

 # ps axuw | grep "D.*iscs[i]"
 root 12383  0.0  0.0  0 0 ?DNov03   0:04 [iscsi_np]
 root 23016  0.0  0.0  0 0 ?DNov03   0:00 
 [iscsi_ttx]
 root 23018  0.0  0.0  0 0 ?DNov03   0:00 
 [iscsi_ttx]
 # cat /proc/12383/stack
 [] iscsit_stop_session+0x19f/0x1d0
 [] iscsi_check_for_session_reinstatement+0x1e6/0x270
 [] iscsi_target_check_for_existing_instances+0x30/0x40
 [] iscsi_target_do_login+0x140/0x640
 [] iscsi_target_start_negotiation+0x1c/0xb0
 [] iscsi_target_login_thread+0xa9b/0xfc0
 [] kthread+0xd8/0xf0
 [] ret_from_fork+0x3f/0x70
 [] 0x
 # cat /proc/23016/stack
 [] target_wait_for_sess_cmds+0x49/0x1a0
 [] isert_wait_conn+0x1ab/0x2f0 [ib_isert]
 [] iscsit_close_connection+0x162/0x870
 [] iscsit_take_action_for_connection_exit+0x7f/0x100
 [] iscsi_target_tx_thread+0x1aa/0x1d0
 [] kthread+0xd8/0xf0
 [] ret_from_fork+0x3f/0x70
 [] 0x
 # cat /proc/23018/stack
 [] target_wait_for_sess_cmds+0x49/0x1a0
 [] isert_wait_conn+0x1ab/0x2f0 [ib_isert]
 [] iscsit_close_connection+0x162/0x870
 [] iscsit_take_action_for_connection_exit+0x7f/0x100
 [] iscsi_target_tx_thread+0x1aa/0x1d0
 [] kthread+0xd8/0xf0
 [] ret_from_fork+0x3f/0x70
 [] 0x

 From dmesg:
 [  394.476332] INFO: rcu_sched self-detected stall on CPU
 [  394.476334]  20-...: (23976 ticks this GP)
 idle=edd/141/0 softirq=292/292 fqs=18788
 [  394.476336]   (t=24003 jiffies g=3146 c=3145 q=0)
 [  394.476337] Task dump for CPU 20:
 [  394.476338] kworker/u68:2   R  running ta

Re: [4.10, panic, regression] iscsi: null pointer deref at iscsi_tcp_segment_done+0x20d/0x2e0

2016-12-22 Thread Chris Leech
On Thu, Dec 22, 2016 at 05:50:12PM +1100, Dave Chinner wrote:
> On Wed, Dec 21, 2016 at 09:46:37PM -0800, Linus Torvalds wrote:
> > On Wed, Dec 21, 2016 at 9:13 PM, Dave Chinner  wrote:
> > >
> > > There may be deeper issues. I just started running scalability tests
> > > (e.g. 16-way fsmark create tests) and about a minute in I got a
> > > directory corruption reported - something I hadn't seen in the dev
> > > cycle at all.
> > 
> > By "in the dev cycle", do you mean your XFS changes, or have you been
> > tracking the merge cycle at least for some testing?
> 
> I mean the three months leading up to the 4.10 merge, when all the
> XFS changes were being tested against 4.9-rc kernels.
> 
> The iscsi problem showed up when I updated the base kernel from
> 4.9 to 4.10-current last week to test the pullreq I was going to
> send you. I've been bust with other stuff until now, so I didn't
> upgrade my working trees again until today in the hope the iscsi
> problem had already been found and fixed.
> 
> > > I unmounted the fs, mkfs'd it again, ran the
> > > workload again and about a minute in this fired:
> > >
> > > [628867.607417] [ cut here ]
> > > [628867.608603] WARNING: CPU: 2 PID: 16925 at mm/workingset.c:461 
> > > shadow_lru_isolate+0x171/0x220
> > 
> > Well, part of the changes during the merge window were the shadow
> > entry tracking changes that came in through Andrew's tree. Adding
> > Johannes Weiner to the participants.
> > 
> > > Now, this workload does not touch the page cache at all - it's
> > > entirely an XFS metadata workload, so it should not really be
> > > affecting the working set code.
> > 
> > Well, I suspect that anything that creates memory pressure will end up
> > triggering the working set code, so ..
> > 
> > That said, obviously memory corruption could be involved and result in
> > random issues too, but I wouldn't really expect that in this code.
> > 
> > It would probably be really useful to get more data points - is the
> > problem reliably in this area, or is it going to be random and all
> > over the place.
> 
> The iscsi problem is 100% reproducable. create a pair of iscsi luns,
> mkfs, run xfstests on them. iscsi fails a second after xfstests mounts
> the filesystems.
> 
> The test machine I'm having all these other problems on? stable and
> steady as a rock using PMEM devices. Moment I go to use /dev/vdc
> (i.e. run load/perf benchmarks) it starts falling over left, right
> and center.

I'm not reproducing any problems with xfstests running over iscsi_tcp
right now.  Two 10G luns exported from an LIO target, attached directly
to a test VM as sda/sdb and xfstests configured to use sda1/sdb1 as
TEST_DEV and SCRATCH_DEV.

The virtio scatterlist issue that popped right away for me is triggered
by an hdparm ioctl, which is being run by tuned on Fedora.  And that
actually seems to happen back on 4.9 as well :(

Chris

--
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: Testing latest linux-next 4.9 ib_srp and ib_srpt sees I/O capped at 1MB and no merging

2016-12-22 Thread Laurence Oberman

- Original Message -
> From: "Christoph Hellwig" 
> To: "Laurence Oberman" 
> Cc: "Christoph Hellwig" , "Bart Van Assche" 
> ,
> linux-r...@vger.kernel.org, linux-scsi@vger.kernel.org
> Sent: Thursday, December 22, 2016 10:40:49 AM
> Subject: Re: Testing latest linux-next 4.9 ib_srp and ib_srpt sees I/O capped 
> at 1MB and no merging
> 
> Hi Laurance,
> 
> please try the patch below:
> 
> ---
> From 69febe1cfb55844862f768447432249781001f9c Mon Sep 17 00:00:00 2001
> From: Christoph Hellwig 
> Date: Thu, 22 Dec 2016 16:38:29 +0100
> Subject: block: add back plugging in __blkdev_direct_IO
> 
> This allows sending larger than 1 MB requess to devices that support
> large I/O sizes.
> 
> Signed-off-by: Christoph Hellwig 
> Reported-by: Laurence Oberman 
> ---
>  fs/block_dev.c | 3 +++
>  fs/iomap.c | 1 -
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 7c45072..206a92a 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -328,6 +328,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter
> *iter, int nr_pages)
>   struct file *file = iocb->ki_filp;
>   struct inode *inode = bdev_file_inode(file);
>   struct block_device *bdev = I_BDEV(inode);
> + struct blk_plug plug;
>   struct blkdev_dio *dio;
>   struct bio *bio;
>   bool is_read = (iov_iter_rw(iter) == READ);
> @@ -353,6 +354,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter
> *iter, int nr_pages)
>   dio->multi_bio = false;
>   dio->should_dirty = is_read && (iter->type == ITER_IOVEC);
>  
> + blk_start_plug(&plug);
>   for (;;) {
>   bio->bi_bdev = bdev;
>   bio->bi_iter.bi_sector = pos >> 9;
> @@ -394,6 +396,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter
> *iter, int nr_pages)
>   submit_bio(bio);
>   bio = bio_alloc(GFP_KERNEL, nr_pages);
>   }
> + blk_finish_plug(&plug);
>  
>   if (!dio->is_sync)
>   return -EIOCBQUEUED;
> diff --git a/fs/iomap.c b/fs/iomap.c
> index 354a123..3adf1e1 100644
> --- a/fs/iomap.c
> +++ b/fs/iomap.c
> @@ -844,7 +844,6 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
> struct iomap_ops *ops,
>   size_t count = iov_iter_count(iter);
>   loff_t pos = iocb->ki_pos, end = iocb->ki_pos + count - 1, ret = 0;
>   unsigned int flags = IOMAP_DIRECT;
> - struct blk_plug plug;
>   struct iomap_dio *dio;
>  
>   lockdep_assert_held(&inode->i_rwsem);
> --
> 2.1.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

Hello Christoph

The patch works and I now see 4MB I/O

# DISK STATISTICS (/sec)
#   
<-reads-><-writes-> 
Pct
#Time Name   KBytes Merged  IOs Size  KBytes Merged  IOs Size  RWSize  
QLen  Wait SvcTim Util
11:53:58 sdah143360105   35 4096   0  0004096   
  128 28   99
11:53:59 sdah139264102   34 4096   0  0004096   
  129 29   99
11:54:00 sdah143360105   35 4096   0  0004096   
  128 28   99

I think you forgot to remove calls to blk_start_plug and blk_finish_plug in 
fs/iomap.c in your patch.
I took them out and built the test kernel that way.

Let me know if you will just remove those in the final or want a patch.


Thanks fo rthe super quick response

Regards
Laurence
--
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 00/10] qla2xxx: Bug fixes for driver.

2016-12-22 Thread Madhani, Himanshu
Hi Bart, 



On 12/22/16, 9:02 AM, "Bart Van Assche"  wrote:

>On Thu, 2016-12-22 at 16:44 +, Madhani, Himanshu wrote:
>> Do you want me to send series updating Reviewed-by Tag or would you be able 
>> to update 
>> while applying to target-pending tree? 
>
>Hello Himanshu,
>
>The past three days I have been busy with rewriting the blk-mq-sched code so I 
>have
>not yet had the time to review this patch series. I plan to do this tomorrow.
>
>BTW, it is a good idea to wait for feedback from everyone who is likely to post
>feedback before reposting a patch series such that all review comments can be
>addressed at once. Additionally, since v2 of this patch series was posted less 
>than
>24 hours ago it is too early anyway to repost this patch series.
>
>Bart.

Understood. I’ll hold off on sending update to this series. 

I am going to post series where we have done additional improvements and added 
new features.
I wanted to get review comments before most of the folks take some time off 
next week.

Thanks,
Himanshu



N�r��yb�X��ǧv�^�)޺{.n�+{���"�{ay�ʇڙ�,j��f���h���z��w���
���j:+v���w�j�mzZ+�ݢj"��!�i

Re: [PATCH v2 00/10] qla2xxx: Bug fixes for driver.

2016-12-22 Thread Bart Van Assche
On Thu, 2016-12-22 at 16:44 +, Madhani, Himanshu wrote:
> Do you want me to send series updating Reviewed-by Tag or would you be able 
> to update 
> while applying to target-pending tree? 

Hello Himanshu,

The past three days I have been busy with rewriting the blk-mq-sched code so I 
have
not yet had the time to review this patch series. I plan to do this tomorrow.

BTW, it is a good idea to wait for feedback from everyone who is likely to post
feedback before reposting a patch series such that all review comments can be
addressed at once. Additionally, since v2 of this patch series was posted less 
than
24 hours ago it is too early anyway to repost this patch series.

Bart.N�r��yb�X��ǧv�^�)޺{.n�+{���"�{ay�ʇڙ�,j��f���h���z��w���
���j:+v���w�j�mzZ+�ݢj"��!�i

Re: [PATCH v2 00/10] qla2xxx: Bug fixes for driver.

2016-12-22 Thread Madhani, Himanshu

On 12/22/16, 1:25 AM, "Christoph Hellwig"  wrote:

>The whole series looks fine:
>
>Reviewed-by: Christoph Hellwig 
>
>(not sure why you dropped my Reviewed-by: tags for all the previously
>reviewed patches, though)

Thanks for the review. Looks like oversight while sending updated series.

Bart, 

Do you want me to send series updating Reviewed-by Tag or would you be able to 
update 
while applying to target-pending tree? 

Thanks,
Himanshu
>


Re: Testing latest linux-next 4.9 ib_srp and ib_srpt sees I/O capped at 1MB and no merging

2016-12-22 Thread Christoph Hellwig
Hi Laurance,

please try the patch below:

---
>From 69febe1cfb55844862f768447432249781001f9c Mon Sep 17 00:00:00 2001
From: Christoph Hellwig 
Date: Thu, 22 Dec 2016 16:38:29 +0100
Subject: block: add back plugging in __blkdev_direct_IO

This allows sending larger than 1 MB requess to devices that support
large I/O sizes.

Signed-off-by: Christoph Hellwig 
Reported-by: Laurence Oberman 
---
 fs/block_dev.c | 3 +++
 fs/iomap.c | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 7c45072..206a92a 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -328,6 +328,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter 
*iter, int nr_pages)
struct file *file = iocb->ki_filp;
struct inode *inode = bdev_file_inode(file);
struct block_device *bdev = I_BDEV(inode);
+   struct blk_plug plug;
struct blkdev_dio *dio;
struct bio *bio;
bool is_read = (iov_iter_rw(iter) == READ);
@@ -353,6 +354,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter 
*iter, int nr_pages)
dio->multi_bio = false;
dio->should_dirty = is_read && (iter->type == ITER_IOVEC);
 
+   blk_start_plug(&plug);
for (;;) {
bio->bi_bdev = bdev;
bio->bi_iter.bi_sector = pos >> 9;
@@ -394,6 +396,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter 
*iter, int nr_pages)
submit_bio(bio);
bio = bio_alloc(GFP_KERNEL, nr_pages);
}
+   blk_finish_plug(&plug);
 
if (!dio->is_sync)
return -EIOCBQUEUED;
diff --git a/fs/iomap.c b/fs/iomap.c
index 354a123..3adf1e1 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -844,7 +844,6 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, 
struct iomap_ops *ops,
size_t count = iov_iter_count(iter);
loff_t pos = iocb->ki_pos, end = iocb->ki_pos + count - 1, ret = 0;
unsigned int flags = IOMAP_DIRECT;
-   struct blk_plug plug;
struct iomap_dio *dio;
 
lockdep_assert_held(&inode->i_rwsem);
-- 
2.1.4

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


Re: Testing latest linux-next 4.9 ib_srp and ib_srpt sees I/O capped at 1MB and no merging

2016-12-22 Thread Laurence Oberman

Hello Christoph, apologies, here is a clear summary of the issue.

During testing of the latest linux-next with rc-10 block layer changes I 
noticed that I/O was being capped at 1MB size and no merging was seen.

The issue was not apparent on 4.8.0-rc8 or earlier.

dd if=/dev/sdw bs=4096k of=/dev/null iflag=direct

### RECORD6 >>> ibclient <<< (1482266543.001) (Tue Dec 20 15:42:23 2016) ###
# DISK STATISTICS (/sec)
#   
<-reads---><-writes-->
 Pct
#Time Name   KBytes Merged  IOs Size  Wait  KBytes Merged  IOs Size  
Wait  RWSize  QLen  Wait SvcTim Util
15:42:23 sdw 278528201   68 4096 2   0  000 
04096 1 2  2   206

Then git checkout master and build final test kernel
4.9.0+

This one clearly shows the I.O at 1MB and no merging.

# DISK STATISTICS (/sec)
#   
<-reads---><-writes-->
 Pct
#Time Name   KBytes Merged  IOs Size  Wait  KBytes Merged  IOs Size  
Wait  RWSize  QLen  Wait SvcTim Util
22:12:48 sdw 1413120  0 1380 1024 2   0  000
 01024 3 2  0   99
22:12:49 sdw 1409024  0 1376 1024 2   0  000
 01024 3 2  0   98
22:12:50 sdw 1445888  0 1412 1024 2   0  000
 01024 3 2  0   98
22:12:51 sdw 1429504  0 1396 1024 2   0  000
 01024 3 2  0   98
22:12:52 sdw 1426432  0 1393 1024 2   0  000
 01024 3 2  0   98
22:12:53 sdw 1408000  0 1375 1024 2   0  000
 01024 3 2  0   98
***     
  

After multiple bisects (6000 revisions, 13 cycles), I got to this one.
Of course there are a huge amount of block layer changes as we know in rc10.

[loberman@ibclient linux-next.orig]$ git bisect bad
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[542ff7bf18c63cf403e36a4a1c71d86dc120d924] block: new direct I/O implementation

This commit is the one that seems to have changed the behavior.
Max I/O size restricted 1MB, even when 4MB I/O is requested, no merging seen.

This is not going to only affect SRP targets.

I will be happy to test any patches and the test bed is always in place.


commit 542ff7bf18c63cf403e36a4a1c71d86dc120d924
Author: Christoph Hellwig 
Date:   Wed Nov 16 23:14:22 2016 -0700

block: new direct I/O implementation

Similar to the simple fast path, but we now need a dio structure to
track multiple-bio completions.  It's basically a cut-down version
of the new iomap-based direct I/O code for filesystems, but without
all the logic to call into the filesystem for extent lookup or
allocation, and without the complex I/O completion workqueue handler
for AIO - instead we just use the FUA bit on the bios to ensure
data is flushed to stable storage.

Signed-off-by: Christoph Hellwig 
Signed-off-by: Jens Axboe 

Many Thanks
Laurence
--
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 12/13] be2iscsi: Add warning message for unsupported adapter

2016-12-22 Thread Hannes Reinecke

On 12/13/2016 11:26 AM, Jitendra Bhivare wrote:

From: Ketan Mukadam 

Add a warning message to indicate obsolete/unsupported
BE2 Adapter Family devices

Signed-off-by: Ketan Mukadam 
Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.c | 2 ++
 drivers/scsi/be2iscsi/be_mgmt.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)


Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 13/13] be2iscsi: Update driver version

2016-12-22 Thread Hannes Reinecke

On 12/13/2016 11:26 AM, Jitendra Bhivare wrote:

Version 11.2.1.0

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 02a9b2d..2188579 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -36,7 +36,7 @@
 #include 

 #define DRV_NAME   "be2iscsi"
-#define BUILD_STR  "11.2.0.0"
+#define BUILD_STR  "11.2.1.0"
 #define BE_NAME"Emulex OneConnect" \
"Open-iSCSI Driver version" BUILD_STR
 #define DRV_DESC   BE_NAME " " "Driver"


Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 11/13] be2iscsi: Reinit SGL handle, CID tables after TPE

2016-12-22 Thread Hannes Reinecke

On 12/13/2016 11:26 AM, Jitendra Bhivare wrote:

After TPE recovery, CID table needs to be repopulated as per CIDs in
WRBQ creation responses.

SGL handles table needs to be recreated for posting and its indices need
to be resetted.

This is achieved by calling beiscsi_cleanup_port when disabling and
beiscsi_init_port in enabling port.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.c | 61 ++---
 1 file changed, 20 insertions(+), 41 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 10/13] be2iscsi: Add checks to validate CID alloc/free

2016-12-22 Thread Hannes Reinecke

On 12/13/2016 11:26 AM, Jitendra Bhivare wrote:

Set CID slot to 0x to indicate empty.
Check if connection already exists in conn_table before binding.
Check if endpoint already NULL before putting back CID.
Break ep->conn link in free_ep to ignore completions after freeing.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_iscsi.c | 163 ---
 drivers/scsi/be2iscsi/be_main.c  |   7 +-
 drivers/scsi/be2iscsi/be_main.h  |   1 +
 3 files changed, 87 insertions(+), 84 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 09/13] be2iscsi: Remove wq_name from beiscsi_hba

2016-12-22 Thread Hannes Reinecke

On 12/13/2016 11:26 AM, Jitendra Bhivare wrote:

wq_name is used only to set WQ name when its being allocated.
Remove it from beiscsi_hba structure and define locally.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.c | 9 +
 drivers/scsi/be2iscsi/be_main.h | 1 -
 2 files changed, 5 insertions(+), 5 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 08/13] be2iscsi: Remove unused struct members

2016-12-22 Thread Hannes Reinecke

On 12/13/2016 11:26 AM, Jitendra Bhivare wrote:

Fix errors reported in static analysis.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be.h   |  3 --
 drivers/scsi/be2iscsi/be_cmds.c  |  8 +++---
 drivers/scsi/be2iscsi/be_cmds.h  | 17 ++--
 drivers/scsi/be2iscsi/be_iscsi.c |  2 +-
 drivers/scsi/be2iscsi/be_main.c  | 24 +++-
 drivers/scsi/be2iscsi/be_main.h  | 22 ---
 drivers/scsi/be2iscsi/be_mgmt.c  |  9 ++
 drivers/scsi/be2iscsi/be_mgmt.h  | 60 
 8 files changed, 21 insertions(+), 124 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 07/13] be2iscsi: Remove redundant receive buffers posting

2016-12-22 Thread Hannes Reinecke

On 12/13/2016 11:26 AM, Jitendra Bhivare wrote:

This duplicate code got added during manual merging.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 1b5a07f..c6af6e5 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -3859,14 +3859,6 @@ static int hwi_init_port(struct beiscsi_hba *phba)
phwi_ctrlr->wrb_context[cri].cid] =
async_arr_idx++;
}
-   /**
-* Now that the default PDU rings have been created,
-* let EP know about it.
-*/
-   beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_HDR,
-ulp_num);
-   beiscsi_hdq_post_handles(phba, BEISCSI_DEFQ_DATA,
-ulp_num);
}
}



Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 06/13] be2iscsi: Fix iSCSI cmd cleanup IOCTL

2016-12-22 Thread Hannes Reinecke

On 12/13/2016 11:25 AM, Jitendra Bhivare wrote:

Prepare the IOCTL with appropriate sizes of buffers of V0 and V1.
Set missing chute number in V1 IOCTL.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_cmds.c | 33 ++---
 drivers/scsi/be2iscsi/be_main.c |  3 +--
 2 files changed, 19 insertions(+), 17 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 05/13] be2iscsi: Add checks to validate completions

2016-12-22 Thread Hannes Reinecke

On 12/13/2016 11:25 AM, Jitendra Bhivare wrote:

Added check in beiscsi_process_cq for pio_handle.
pio_handle is cleared in beiscsi_put_wrb_handle.
This catches any case where task gets cleaned up just before completion.

Use back_lock before accessing pio_handle.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.c | 28 +---
 1 file changed, 21 insertions(+), 7 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 04/13] be2iscsi: Set WRB invalid bit for SkyHawk

2016-12-22 Thread Hannes Reinecke

On 12/13/2016 11:25 AM, Jitendra Bhivare wrote:

invalid bit in WRB indicates to FW that IO was invalidated before WRB
was fetched from host memory.

For SkyHawk, this invalid bit in WRB is at a different offset.
Use amap_iscsi_wrb_v2 to mark invalid bit for SkyHawk.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.c | 19 ++-
 drivers/scsi/be2iscsi/be_main.h |  2 +-
 2 files changed, 15 insertions(+), 6 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 03/13] be2iscsi: Take iscsi_task ref in abort handler

2016-12-22 Thread Hannes Reinecke

On 12/13/2016 11:25 AM, Jitendra Bhivare wrote:

Hold the reference of iscsi_task till invalidation completes.
This prevents use of ICD when invalidation of that ICD is being processed.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.c | 45 +
 1 file changed, 19 insertions(+), 26 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 02/13] be2iscsi: Fix for crash in beiscsi_eh_device_reset

2016-12-22 Thread Hannes Reinecke

On 12/13/2016 11:25 AM, Jitendra Bhivare wrote:

System crashes when sg_reset is executed in a loop.
CPU: 13 PID: 7073 Comm: sg_reset Tainted: GE   4.8.0-rc1+ #4
RIP: 0010:[]  []
beiscsi_eh_device_reset+0x160/0x520 [be2iscsi]
Call Trace:
[] ? scsi_host_alloc_command+0x47/0xc0
[] scsi_try_bus_device_reset+0x2a/0x50
[] scsi_ioctl_reset+0x13e/0x260
[] scsi_ioctl+0x137/0x3d0
[] sg_ioctl+0x572/0xc20 [sg]
[] do_vfs_ioctl+0xa7/0x5d0

The accesses to beiscsi_io_task is being protected in device reset handler
with frwd_lock but the freeing of task can happen under back_lock.

Hold the reference of iscsi_task till invalidation completes.
This prevents use of ICD when invalidation of that ICD is being processed.
Use frwd_lock for iscsi_tasks looping and back_lock to access
beiscsi_io_task structures.

Rewrite mgmt_invalidation_icds to handle allocation and freeing of IOCTL
buffer in one place.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.c | 121 +---
 drivers/scsi/be2iscsi/be_mgmt.c | 107 ---
 drivers/scsi/be2iscsi/be_mgmt.h |   8 +--
 3 files changed, 114 insertions(+), 122 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v2 01/13] be2iscsi: Fix use of invalidate command table req

2016-12-22 Thread Hannes Reinecke

On 12/13/2016 11:25 AM, Jitendra Bhivare wrote:

Remove shared structure inv_tbl in phba for all sessions to post
invalidation IOCTL.
Always allocate and then free the table after use in reset handler.
Abort handler needs just one instance so define it on stack.
Add checks for BE_INVLDT_CMD_TBL_SZ to not exceed invalidation
command table size in IOCTL.

Signed-off-by: Jitendra Bhivare 
---
 drivers/scsi/be2iscsi/be_main.c | 85 -
 drivers/scsi/be2iscsi/be_main.h | 16 
 drivers/scsi/be2iscsi/be_mgmt.c | 12 +++---
 drivers/scsi/be2iscsi/be_mgmt.h | 40 +--
 4 files changed, 83 insertions(+), 70 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

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


[PATCH v2] scsi: qla4xxx: Use dma_pool_zalloc

2016-12-22 Thread Souptick Joarder
We should use dma_pool_zalloc instead of dma_pool_alloc/memset

Signed-off-by: Souptick joarder 
---
v2 changes:
   - Address comment from Nilesh to make same change in
 all applicable places inside qla4xxx source

 drivers/scsi/qla4xxx/ql4_mbx.c | 6 ++
 drivers/scsi/qla4xxx/ql4_os.c  | 4 +---
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index c291fdf..8f97839 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -1587,12 +1587,11 @@ int qla4xxx_get_chap(struct scsi_qla_host *ha, char 
*username, char *password,
struct ql4_chap_table *chap_table;
dma_addr_t chap_dma;

-   chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
+   chap_table = dma_pool_zalloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
if (chap_table == NULL)
return -ENOMEM;

chap_size = sizeof(struct ql4_chap_table);
-   memset(chap_table, 0, chap_size);

if (is_qla40XX(ha))
offset = FLASH_CHAP_OFFSET | (idx * chap_size);
@@ -1651,13 +1650,12 @@ int qla4xxx_set_chap(struct scsi_qla_host *ha, char 
*username, char *password,
uint32_t chap_size = 0;
dma_addr_t chap_dma;

-   chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
+   chap_table = dma_pool_zalloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
if (chap_table == NULL) {
ret =  -ENOMEM;
goto exit_set_chap;
}

-   memset(chap_table, 0, sizeof(struct ql4_chap_table));
if (bidi)
chap_table->flags |= BIT_6; /* peer */
else
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 01c3610..0c91c89 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -825,12 +825,10 @@ static int qla4xxx_delete_chap(struct Scsi_Host *shost, 
uint16_t chap_tbl_idx)
uint32_t chap_size;
int ret = 0;

-   chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
+   chap_table = dma_pool_zalloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
if (chap_table == NULL)
return -ENOMEM;

-   memset(chap_table, 0, sizeof(struct ql4_chap_table));
-
if (is_qla80XX(ha))
max_chap_entries = (ha->hw.flt_chap_size / 2) /
   sizeof(struct ql4_chap_table);
--
1.9.1

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


Re: [PATCH] scsi/qla4: comments correction

2016-12-22 Thread Javali, Nilesh


On 19/12/16, 11:50 AM, "linux-scsi-ow...@vger.kernel.org on behalf of Cao
jin"  wrote:

>Signed-off-by: Cao jin 
>---
> drivers/scsi/qla4xxx/ql4_os.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
>index 01c3610a60cf..fc60e0a1043e 100644
>--- a/drivers/scsi/qla4xxx/ql4_os.c
>+++ b/drivers/scsi/qla4xxx/ql4_os.c
>@@ -9546,15 +9546,15 @@ static int qla4xxx_host_reset(struct Scsi_Host
>*shost, int reset_type)
>  * driver calls the following device driver's callbacks
>  *
>  * - Fatal Errors - link_reset
>- * - Non-Fatal Errors - driver's pci_error_detected() which
>+ * - Non-Fatal Errors - driver's error_detected() which
>  * returns CAN_RECOVER, NEED_RESET or DISCONNECT.
>  *
>  * PCI AER driver calls
>- * CAN_RECOVER - driver's pci_mmio_enabled(), mmio_enabled
>+ * CAN_RECOVER - driver's mmio_enabled(), mmio_enabled()
>  *   returns RECOVERED or NEED_RESET if fw_hung
>  * NEED_RESET - driver's slot_reset()
>  * DISCONNECT - device is dead & cannot recover
>- * RECOVERED - driver's pci_resume()
>+ * RECOVERED - driver's resume()
>  */
> static pci_ers_result_t
> qla4xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t
>state)
>-- 
>2.1.0

Acked-by: Nilesh Javali 

--
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: JMS56x not working reliably with uas driver

2016-12-22 Thread Oliver Neukum
On Thu, 2016-12-22 at 15:43 +0530, George Cherian wrote:
> dmesg with the patch applied

Hi,

did you apply both patches, yours and the one I posted?
And did you physically disconnect your device?

Regards
Oliver


--
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: JMS56x not working reliably with uas driver

2016-12-22 Thread George Cherian

dmesg with the patch applied

[root@localhost ~]# dmesg
[  108.575683] usb 4-1.3: new SuperSpeed USB device number 3 using xhci_hcd
[  108.596485] usb 4-1.3: New USB device found, idVendor=152d, 
idProduct=9561
[  108.603350] usb 4-1.3: New USB device strings: Mfr=1, Product=2, 
SerialNumber=5

[  108.610663] usb 4-1.3: Product: JMS56x Series
[  108.615009] usb 4-1.3: Manufacturer: JMicron
[  108.619277] usb 4-1.3: SerialNumber: 
[  109.790747] usbcore: registered new interface driver usb-storage
[  110.061769] scsi host4: scsi_eh_4: sleeping
[  110.062119] scsi host4: uas
[  110.062305] usbcore: registered new interface driver uas
[  110.062370] scsi 4:0:0:0: Send: scmd 0x801fddcc1500
[  110.062374] scsi 4:0:0:0: CDB: Inquiry 12 00 00 00 24 00
[  110.062551] scsi 4:0:0:0: Done: SUCCESS Result: hostbyte=DID_OK 
driverbyte=DRIVER_OK

[  110.062555] scsi 4:0:0:0: CDB: Inquiry 12 00 00 00 24 00
[  110.062559] scsi 4:0:0:0: 0 sectors total, 36 bytes done.
[  110.062615] scsi 4:0:0:0: Send: scmd 0x801fcc338880
[  110.062618] scsi 4:0:0:0: CDB: Inquiry 12 00 00 00 60 00
[  110.062790] scsi 4:0:0:0: Done: SUCCESS Result: hostbyte=DID_OK 
driverbyte=DRIVER_OK

[  110.062793] scsi 4:0:0:0: CDB: Inquiry 12 00 00 00 60 00
[  110.062797] scsi 4:0:0:0: 0 sectors total, 96 bytes done.
[  110.062829] scsi 4:0:0:0: Direct-Access ST4000NM 0033-9ZM170  
0001 PQ: 0 ANSI: 6

[  110.062844] scsi 4:0:0:0: Send: scmd 0x801fcc338880
[  110.062847] scsi 4:0:0:0: CDB: Inquiry 12 01 00 00 ff 00
[  110.063011] scsi 4:0:0:0: Done: SUCCESS Result: hostbyte=DID_OK 
driverbyte=DRIVER_OK

[  110.063014] scsi 4:0:0:0: CDB: Inquiry 12 01 00 00 ff 00
[  110.063018] scsi 4:0:0:0: 0 sectors total, 255 bytes done.
[  110.063045] scsi 4:0:0:0: Send: scmd 0x801fcc338880
[  110.063048] scsi 4:0:0:0: CDB: Inquiry 12 01 80 00 ff 00
[  110.063216] scsi 4:0:0:0: Done: SUCCESS Result: hostbyte=DID_OK 
driverbyte=DRIVER_OK

[  110.063219] scsi 4:0:0:0: CDB: Inquiry 12 01 80 00 ff 00
[  110.063222] scsi 4:0:0:0: 0 sectors total, 255 bytes done.
[  110.063248] scsi 4:0:0:0: Send: scmd 0x801fcc338880
[  110.063251] scsi 4:0:0:0: CDB: Inquiry 12 01 83 00 ff 00
[  110.063428] scsi 4:0:0:0: Done: SUCCESS Result: hostbyte=DID_OK 
driverbyte=DRIVER_OK

[  110.063431] scsi 4:0:0:0: CDB: Inquiry 12 01 83 00 ff 00
[  110.063435] scsi 4:0:0:0: 0 sectors total, 255 bytes done.
[  110.063463] scsi 4:0:0:0: Send: scmd 0x801fcc338880
[  110.063466] scsi 4:0:0:0: CDB: Report luns a0 00 00 00 00 00 00 00 10 
00 00 00
[  110.063626] scsi 4:0:0:0: Done: SUCCESS Result: hostbyte=DID_OK 
driverbyte=DRIVER_OK
[  110.063629] scsi 4:0:0:0: CDB: Report luns a0 00 00 00 00 00 00 00 10 
00 00 00

[  110.063633] scsi 4:0:0:0: 8 sectors total, 4096 bytes done.
[  110.063912] sd 4:0:0:0: Send: scmd 0x801fdd8e5880
[  110.063916] sd 4:0:0:0: CDB: Test Unit Ready 00 00 00 00 00 00
[  110.064018] sd 4:0:0:0: Done: SUCCESS Result: hostbyte=DID_OK 
driverbyte=DRIVER_OK

[  110.064021] sd 4:0:0:0: CDB: Test Unit Ready 00 00 00 00 00 00
[  110.064026] sd 4:0:0:0: 0 sectors total, 0 bytes done.
[  110.064050] sd 4:0:0:0: Send: scmd 0x801fdd8e5a00
[  110.064053] sd 4:0:0:0: CDB: Read capacity(16) 9e 10 00 00 00 00 00 
00 00 00 00 00 00 20 00 00

[  110.064064] sd 4:0:0:0: Attached scsi generic sg1 type 0
[  110.064209] sd 4:0:0:0: Done: SUCCESS Result: hostbyte=DID_OK 
driverbyte=DRIVER_OK
[  110.064213] sd 4:0:0:0: CDB: Read capacity(16) 9e 10 00 00 00 00 00 
00 00 00 00 00 00 20 00 00

[  110.064216] sd 4:0:0:0: 0 sectors total, 32 bytes done.
[  110.064240] sd 4:0:0:0: [sdb] 7814037168 512-byte logical blocks: 
(4.00 TB/3.63 TiB)

[  110.064253] sd 4:0:0:0: Send: scmd 0x801fcc338880
[  110.064256] sd 4:0:0:0: CDB: Inquiry 12 01 00 00 40 00
[  110.064421] sd 4:0:0:0: Done: SUCCESS Result: hostbyte=DID_OK 
driverbyte=DRIVER_OK

[  110.064424] sd 4:0:0:0: CDB: Inquiry 12 01 00 00 40 00
[  110.064427] sd 4:0:0:0: 0 sectors total, 64 bytes done.
[  110.064454] sd 4:0:0:0: Send: scmd 0x801fcc338880
[  110.064457] sd 4:0:0:0: CDB: Inquiry 12 01 b0 00 40 00
[  110.064625] sd 4:0:0:0: Done: SUCCESS Result: hostbyte=DID_OK 
driverbyte=DRIVER_OK

[  110.064628] sd 4:0:0:0: CDB: Inquiry 12 01 b0 00 40 00
[  110.064632] sd 4:0:0:0: 0 sectors total, 64 bytes done.
[  110.064658] sd 4:0:0:0: Send: scmd 0x801fcc338880
[  110.064661] sd 4:0:0:0: CDB: Inquiry 12 01 00 00 40 00
[  110.064829] sd 4:0:0:0: Done: SUCCESS Result: hostbyte=DID_OK 
driverbyte=DRIVER_OK

[  110.064832] sd 4:0:0:0: CDB: Inquiry 12 01 00 00 40 00
[  110.064836] sd 4:0:0:0: 0 sectors total, 64 bytes done.
[  110.064861] sd 4:0:0:0: Send: scmd 0x801fcc338880
[  110.064864] sd 4:0:0:0: CDB: Inquiry 12 01 b1 00 40 00
[  110.065030] sd 4:0:0:0: Done: SUCCESS Result: hostbyte=DID_OK 
driverbyte=DRIVER_OK

[  110.065033] sd 4:0:0:0: CDB: Inquiry 12 01 b1 00 40 00
[  110.065037] sd 4:0:0:0: 0 sectors total, 64 bytes done.
[  110.065064] sd 4:0:0:0: Send: scmd 0x8

Re: [PATCH v2 00/10] qla2xxx: Bug fixes for driver.

2016-12-22 Thread Christoph Hellwig
The whole series looks fine:

Reviewed-by: Christoph Hellwig 

(not sure why you dropped my Reviewed-by: tags for all the previously
reviewed patches, though)
--
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: qedi: return via va_end to match corresponding va_start

2016-12-22 Thread Rangankar, Manish


On 16/12/16 7:40 PM, "Colin King"  wrote:

>From: Colin Ian King 
>
>Although on most systems va_end is a no-op, it is good practice
>to use va_end on the function return path, especially since the
>va_start documenation states:
>
>  "Each invocation of va_start() must be matched by a corresponding
>   invocation of va_end() in the same function."
>
>Found with static analysis by CoverityScan, CIDs 1389477-1389479
>
>Signed-off-by: Colin Ian King 
>---
> drivers/scsi/qedi/qedi_dbg.c | 9 ++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/scsi/qedi/qedi_dbg.c b/drivers/scsi/qedi/qedi_dbg.c
>index 2bdedb9..8fd28b0 100644
>--- a/drivers/scsi/qedi/qedi_dbg.c
>+++ b/drivers/scsi/qedi/qedi_dbg.c
>@@ -52,7 +52,7 @@ qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char
>*func, u32 line,
>   vaf.va = &va;
> 
>   if (!(qedi_dbg_log & QEDI_LOG_WARN))
>-  return;
>+  goto ret;
> 
>   if (likely(qedi) && likely(qedi->pdev))
>   pr_warn("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
>@@ -60,6 +60,7 @@ qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char
>*func, u32 line,
>   else
>   pr_warn("[:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
> 
>+ret:
>   va_end(va);
> }
> 
>@@ -80,7 +81,7 @@ qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char
>*func, u32 line,
>   vaf.va = &va;
> 
>   if (!(qedi_dbg_log & QEDI_LOG_NOTICE))
>-  return;
>+  goto ret;
> 
>   if (likely(qedi) && likely(qedi->pdev))
>   pr_notice("[%s]:[%s:%d]:%d: %pV",
>@@ -89,6 +90,7 @@ qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char
>*func, u32 line,
>   else
>   pr_notice("[:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
> 
>+ret:
>   va_end(va);
> }
> 
>@@ -109,7 +111,7 @@ qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char
>*func, u32 line,
>   vaf.va = &va;
> 
>   if (!(qedi_dbg_log & level))
>-  return;
>+  goto ret;
> 
>   if (likely(qedi) && likely(qedi->pdev))
>   pr_info("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
>@@ -117,6 +119,7 @@ qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char
>*func, u32 line,
>   else
>   pr_info("[:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
> 
>+ret:
>   va_end(va);
> }
> 
>-- 
>2.10.2


Acked-by: Manish Rangankar 

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