[Bug 101891] mvsas prep failed, NULL pointer dereference in mvs_slot_task_free+0x5/0x1f0 [mvsas]

2015-08-20 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=101891

Turbo Fredriksson tu...@bayour.com changed:

   What|Removed |Added

 CC||tu...@bayour.com

--- Comment #6 from Turbo Fredriksson tu...@bayour.com ---
Forgive an ignoramus, but those last lines doesn't look to good

kernel: ata11.00: device reported invalid CHS sector 0

I have a problem that is very much like yours, but my stack traces are
different so I'm unsure if we have the same problem. I'm going to rebuild my
kernel as well with your fix and see if it helps me as well.

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


[PATCH] SCSI: mvsas: Fix NULL pointer dereference in mvs_slot_task_free

2015-08-20 Thread Dāvis Mosāns
When pci_pool_alloc fails in mvs_task_prep then task-lldd_task stays
NULL but it's later used in mvs_abort_task as slot which is passed
to mvs_slot_task_free causing NULL pointer dereference.

Just return from mvs_slot_task_free when passed with NULL slot.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=101891
Signed-off-by: Dāvis Mosāns davis...@gmail.com
---
 drivers/scsi/mvsas/mv_sas.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
index 454536c..9c78074 100644
--- a/drivers/scsi/mvsas/mv_sas.c
+++ b/drivers/scsi/mvsas/mv_sas.c
@@ -887,6 +887,8 @@ static void mvs_slot_free(struct mvs_info *mvi, u32 rx_desc)
 static void mvs_slot_task_free(struct mvs_info *mvi, struct sas_task *task,
  struct mvs_slot_info *slot, u32 slot_idx)
 {
+   if (!slot)
+   return;
if (!slot-task)
return;
if (!sas_protocol_ata(task-task_proto))
-- 
2.5.0

--
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] fix: lpfc_send_rscn_event sends bigger buffer size

2015-08-20 Thread Ales Novak
lpfc_send_rscn_event() allocates data for sizeof(struct
lpfc_rscn_event_header) + payload_len, but claims that the data has size
of sizeof(struct lpfc_els_event_header) + payload_len. That leads to
buffer overruns.

Signed-off-by: Ales Novak alno...@suse.cz
---
 drivers/scsi/lpfc/lpfc_els.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 36bf58b..136928e 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -5444,7 +5444,7 @@ lpfc_send_rscn_event(struct lpfc_vport *vport,
 
fc_host_post_vendor_event(shost,
fc_get_event_number(),
-   sizeof(struct lpfc_els_event_header) + payload_len,
+   sizeof(struct lpfc_rscn_event_header) + payload_len,
(char *)rscn_event_data,
LPFC_NL_VENDOR_ID);
 
-- 
2.4.1.168.g1ea28e1

--
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 6/8] scsi: ufs: make the UFS variant a platform device

2015-08-20 Thread Akinobu Mita
2015-08-20 22:59 GMT+09:00 Yaniv Gardi yga...@codeaurora.org:
 @@ -1036,7 +1037,7 @@ void ufs_qcom_clk_scale_notify(struct ufs_hba *hba)
   * The variant operations configure the necessary controller and PHY
   * handshake during initialization.
   */
 -static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
 +static struct ufs_hba_variant_ops ufs_hba_qcom_vops = {

It's better to keep const.  In order to do this, we also need to put
const to 'vops' member in struct ufs_hba and the second argument of
ufshcd_pltfrm_init().

 +static void ufs_qcom_shutdown(struct platform_device *pdev)
 +{
 +   ufshcd_shutdown((struct ufs_hba *)platform_get_drvdata(pdev));
 +}

We don't need this function anymore since we have
ufshcd_pltfrm_shutdown() now.

 -static void ufshcd_pltfrm_shutdown(struct platform_device *pdev)
 +void ufshcd_pltfrm_shutdown(struct platform_device *pdev)
  {
 -   ufshcd_shutdown((struct ufs_hba *)platform_get_drvdata(pdev));
 +   ufshcd_shutdown((struct ufs_hba *)platform_get_drvdata(pdev));

Whitespace is used as code indent.  There are same issues in
this patch series, so I recommend running checkpatch.pl before
sending patches.
--
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] target/qla2xxx: Honor max_data_sg_nents I/O transfer limit

2015-08-20 Thread Nicholas A. Bellinger
On Wed, 2015-08-19 at 17:48 -0700, Arun Easi wrote:
 Hi nab,
 
 On Thu, 13 Aug 2015, 1:45am -0700, Nicholas A. Bellinger wrote:
 
  From: Nicholas Bellinger n...@linux-iscsi.org
 
  Hi Arun, Roland  Co,
 
  Based upon the feedback from last week, here is a proper
  patch for target-core to honor a fabric provided SGL limit
  using residual count plus underflow response bit.
 
  Everything appears to be working as expected with tcm-loop
  LUNs with basic I/O and sg_raw to test CDB underflow, but
  still needs to be verified on real qla2xxx hardware over
  the next days for v4.2.0 code.
 
  Please review + test.
 
 Changes look good. I could not test the changes, though. I have requested 
 internally to test this patch. Himanshu (copied) will get back with the 
 test results (Thanks Himanshu).
 

Thanks for the update.  Btw, this patch has been pushed to
refs/heads/queue, atop the other recent v4.2-rc fixes here:

https://git.kernel.org/cgit/linux/kernel/git/nab/target-pending.git/commit/?h=queue

Just an FYI for Himanshu, for testing against Linux hosts that do honor
EVPD block-limits, you'll want to include the following small hack to
report a larger block-limits value so the new residual handling can
actually get invoked.

diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 01421e9..f02767b 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -523,6 +523,7 @@ spc_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
if (cmd-se_tfo-max_data_sg_nents) {
mtl = (cmd-se_tfo-max_data_sg_nents * PAGE_SIZE) /
   dev-dev_attrib.block_size;
+   mtl *= 2;
}
put_unaligned_be32(min_not_zero(mtl, dev-dev_attrib.hw_max_sectors), 
buf[8]);

Also for testing, I'd recommend lowering tcm_qla2xxx's max_data_sg_nents
to something arbitrarily small to exercise the new code.

Craig, have you had a chance to test the new logic on your setup with
hosts that don't honor EVPD block-limits..?

--nab 




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


Re: [PATCH v2 7/8] scsi: ufs-qcom: add debug prints for test bus

2015-08-20 Thread Akinobu Mita
2015-08-20 22:59 GMT+09:00 Yaniv Gardi yga...@codeaurora.org:
 @@ -30,6 +48,14 @@ static void ufs_qcom_get_speed_mode(struct 
 ufs_pa_layer_attr *p, char *result);
  static int ufs_qcom_get_bus_vote(struct ufs_qcom_host *host,
 const char *speed_mode);
  static int ufs_qcom_set_bus_vote(struct ufs_qcom_host *host, int vote);
 +static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host);
 +static void ufs_qcom_dump_regs(struct ufs_hba *hba, int offset, int len,
 +   char *prefix)
 +{
 +   print_hex_dump(KERN_ERR, prefix,
 +   len  4 ? DUMP_PREFIX_OFFSET : DUMP_PREFIX_NONE,
 +   16, 4, hba-mmio_base + offset, len * 4, false);
 +}

This causes a sparse warning as __iomem pointer is passed to
print_hex_dump().
--
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: Persistent Reservation API V2

2015-08-20 Thread Keith Busch

On Tue, 11 Aug 2015, Christoph Hellwig wrote:

This series adds support for a simplified Persistent Reservation API
to the block layer.  The intent is that both in-kernel and userspace
consumers can use the API instead of having to hand craft SCSI or NVMe
command through the various pass through interfaces.  It also adds
DM support as getting reservations through dm-multipath is a major
pain with the current scheme.

NVMe support currently isn't included as I don't have a multihost
NVMe setup to test on, but Keith offered to test it and I'll have
a patch for it shortly.


Hi Christoph,

I wrote an nvme implementation and it seems to work as expected with your
pr-tests (minor modification to open an nvme target). While API appears to
work as designed, there are a few features of NVMe that are unreachable
with it. For example, NVMe can ignore existing keys when acquiring a
reservation in addition to registering a new key. NVMe can also specify
if whether or not a reservation should persist through power-loss.

Anyway, I don't think SCSI has these same options. Should this new IOCTL
API accommodate the common subset to maintain its simplicity, or make
it more expressive for all features? The more important question might
be if there are any users requiring these features, and I honestly don't
know that right now.
--
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 1/3] cxlflash: Base error recovery support

2015-08-20 Thread Manoj Kumar


James:

Wondering whether there is anything else you were expecting from us
before pulling this patch series in.

Regards,
- Manoj Kumar


On 8/13/2015 9:47 PM, Matthew R. Ochs wrote:

Introduce support for enhanced I/O error handling.

A device state is added to track 3 possible states of the device:

Normal - the device is operating normally and is fully operational

Limbo - the device is in a reset/recovery scenario and its operational
 status is paused

Failed/terminating - the device has either failed to be reset/recovered
  or is being terminated (removed); it is no longer
  operational

All operations are allowed when the device is operating normally. When the
device transitions to limbo state, I/O must be paused. To help accomplish
this, a wait queue is introduced where existing and new threads can wait
until the device is no longer in limbo. When coming out of limbo, threads
need to check the state and error out gracefully when encountering the
failed state. When the device transitions to the failed/terminating state,
normal operations are no longer allowed. Only specially designated
operations related to graceful cleanup are permitted.

Signed-off-by: Matthew R. Ochs mro...@linux.vnet.ibm.com
Signed-off-by: Manoj N. Kumar ma...@linux.vnet.ibm.com
Reviewed-by: Daniel Axtens d...@axtens.net
Reviewed-by: Michael Neuling mi...@neuling.org
Reviewed-by: Wen Xiong wenxi...@linux.vnet.ibm.com
---
  drivers/scsi/cxlflash/Kconfig   |   2 +-
  drivers/scsi/cxlflash/common.h  |  11 ++-
  drivers/scsi/cxlflash/main.c| 174 +---
  drivers/scsi/cxlflash/main.h|   6 +-
  drivers/scsi/cxlflash/sislite.h |   0
  5 files changed, 177 insertions(+), 16 deletions(-)
  mode change 100755 = 100644 drivers/scsi/cxlflash/sislite.h

diff --git a/drivers/scsi/cxlflash/Kconfig b/drivers/scsi/cxlflash/Kconfig
index c707508..c052104 100644
--- a/drivers/scsi/cxlflash/Kconfig
+++ b/drivers/scsi/cxlflash/Kconfig
@@ -4,7 +4,7 @@

  config CXLFLASH
tristate Support for IBM CAPI Flash
-   depends on PCI  SCSI  CXL
+   depends on PCI  SCSI  CXL  EEH
default m
help
  Allows CAPI Accelerated IO to Flash
diff --git a/drivers/scsi/cxlflash/common.h b/drivers/scsi/cxlflash/common.h
index fe86bfe..ffdbc57 100644
--- a/drivers/scsi/cxlflash/common.h
+++ b/drivers/scsi/cxlflash/common.h
@@ -76,6 +76,12 @@ enum cxlflash_init_state {
INIT_STATE_SCSI
  };

+enum cxlflash_state {
+   STATE_NORMAL,   /* Normal running state, everything good */
+   STATE_LIMBO,/* Limbo running state, trying to reset/recover */
+   STATE_FAILTERM  /* Failed/terminating state, error out users/threads */
+};
+
  /*
   * Each context has its own set of resource handles that is visible
   * only from that context.
@@ -91,8 +97,6 @@ struct cxlflash_cfg {

ulong cxlflash_regs_pci;

-   wait_queue_head_t eeh_waitq;
-
struct work_struct work_q;
enum cxlflash_init_state init_state;
enum cxlflash_lr_state lr_state;
@@ -105,7 +109,8 @@ struct cxlflash_cfg {

wait_queue_head_t tmf_waitq;
bool tmf_active;
-   u8 err_recovery_active:1;
+   wait_queue_head_t limbo_waitq;
+   enum cxlflash_state state;
  };

  struct afu_cmd {
diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 76a7286..4df1ff6 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -353,6 +353,7 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, 
struct scsi_cmnd *scp)
struct cxlflash_cfg *cfg = (struct cxlflash_cfg *)host-hostdata;
struct afu *afu = cfg-afu;
struct pci_dev *pdev = cfg-dev;
+   struct device *dev = cfg-dev-dev;
struct afu_cmd *cmd;
u32 port_sel = scp-device-channel + 1;
int nseg, i, ncount;
@@ -380,6 +381,21 @@ static int cxlflash_queuecommand(struct Scsi_Host *host, 
struct scsi_cmnd *scp)
}
spin_unlock_irqrestore(cfg-tmf_waitq.lock, lock_flags);

+   switch (cfg-state) {
+   case STATE_LIMBO:
+   dev_dbg_ratelimited(dev, %s: device in limbo!\n, __func__);
+   rc = SCSI_MLQUEUE_HOST_BUSY;
+   goto out;
+   case STATE_FAILTERM:
+   dev_dbg_ratelimited(dev, %s: device has failed!\n, __func__);
+   scp-result = (DID_NO_CONNECT  16);
+   scp-scsi_done(scp);
+   rc = 0;
+   goto out;
+   default:
+   break;
+   }
+
cmd = cxlflash_cmd_checkout(afu);
if (unlikely(!cmd)) {
pr_err(%s: could not get a free command\n, __func__);
@@ -455,9 +471,21 @@ static int cxlflash_eh_device_reset_handler(struct 
scsi_cmnd *scp)
 get_unaligned_be32(((u32 *)scp-cmnd)[2]),
 get_unaligned_be32(((u32 *)scp-cmnd)[3]));

-   rcr = send_tmf(afu, scp, TMF_LUN_RESET);
-   if 

[PATCH v2 4/8] add ufshcd_get_variant ufshcd_set_variant

2015-08-20 Thread Yaniv Gardi
Signed-off-by: Yaniv Gardi yga...@codeaurora.org

---
 drivers/scsi/ufs/ufs-qcom.c | 34 +-
 drivers/scsi/ufs/ufshcd.h   | 21 +
 2 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 6c23bbf..64c54b7 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -155,7 +155,7 @@ out:
 
 static int ufs_qcom_link_startup_post_change(struct ufs_hba *hba)
 {
-   struct ufs_qcom_host *host = hba-priv;
+   struct ufs_qcom_host *host = ufshcd_get_variant(hba);
struct phy *phy = host-generic_phy;
u32 tx_lanes;
int err = 0;
@@ -211,7 +211,7 @@ static int ufs_qcom_check_hibern8(struct ufs_hba *hba)
 
 static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
 {
-   struct ufs_qcom_host *host = hba-priv;
+   struct ufs_qcom_host *host = ufshcd_get_variant(hba);
struct phy *phy = host-generic_phy;
int ret = 0;
bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B)
@@ -273,7 +273,7 @@ static void ufs_qcom_enable_hw_clk_gating(struct ufs_hba 
*hba)
 
 static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba, bool status)
 {
-   struct ufs_qcom_host *host = hba-priv;
+   struct ufs_qcom_host *host = ufshcd_get_variant(hba);
int err = 0;
 
switch (status) {
@@ -307,7 +307,7 @@ static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba, 
bool status)
 static unsigned long
 ufs_qcom_cfg_timers(struct ufs_hba *hba, u32 gear, u32 hs, u32 rate)
 {
-   struct ufs_qcom_host *host = hba-priv;
+   struct ufs_qcom_host *host = ufshcd_get_variant(hba);
struct ufs_clk_info *clki;
u32 core_clk_period_in_ns;
u32 tx_clk_cycles_per_us = 0;
@@ -448,7 +448,7 @@ static int ufs_qcom_link_startup_notify(struct ufs_hba 
*hba, bool status)
 
 static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 {
-   struct ufs_qcom_host *host = hba-priv;
+   struct ufs_qcom_host *host = ufshcd_get_variant(hba);
struct phy *phy = host-generic_phy;
int ret = 0;
 
@@ -479,7 +479,7 @@ out:
 
 static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 {
-   struct ufs_qcom_host *host = hba-priv;
+   struct ufs_qcom_host *host = ufshcd_get_variant(hba);
struct phy *phy = host-generic_phy;
int err;
 
@@ -621,7 +621,7 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
struct ufs_pa_layer_attr *dev_req_params)
 {
u32 val;
-   struct ufs_qcom_host *host = hba-priv;
+   struct ufs_qcom_host *host = ufshcd_get_variant(hba);
struct phy *phy = host-generic_phy;
struct ufs_qcom_dev_params ufs_qcom_cap;
int ret = 0;
@@ -696,7 +696,7 @@ out:
 
 static u32 ufs_qcom_get_ufs_hci_version(struct ufs_hba *hba)
 {
-   struct ufs_qcom_host *host = hba-priv;
+   struct ufs_qcom_host *host = ufshcd_get_variant(hba);
 
if (host-hw_ver.major == 0x1)
return UFSHCI_VERSION_11;
@@ -715,7 +715,7 @@ static u32 ufs_qcom_get_ufs_hci_version(struct ufs_hba *hba)
  */
 static void ufs_qcom_advertise_quirks(struct ufs_hba *hba)
 {
-   struct ufs_qcom_host *host = hba-priv;
+   struct ufs_qcom_host *host = ufshcd_get_variant(hba);
 
if (host-hw_ver.major == 0x01) {
hba-quirks |= UFSHCD_QUIRK_DELAY_BEFORE_DME_CMDS
@@ -740,7 +740,7 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba)
 
 static void ufs_qcom_set_caps(struct ufs_hba *hba)
 {
-   struct ufs_qcom_host *host = hba-priv;
+   struct ufs_qcom_host *host = ufshcd_get_variant(hba);
 
if (host-hw_ver.major = 0x2)
host-caps = UFS_QCOM_CAP_QUNIPRO;
@@ -811,7 +811,7 @@ static void ufs_qcom_get_speed_mode(struct 
ufs_pa_layer_attr *p, char *result)
 
 static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on)
 {
-   struct ufs_qcom_host *host = hba-priv;
+   struct ufs_qcom_host *host = ufshcd_get_variant(hba);
int err = 0;
int vote = 0;
 
@@ -866,7 +866,7 @@ show_ufs_to_mem_max_bus_bw(struct device *dev, struct 
device_attribute *attr,
char *buf)
 {
struct ufs_hba *hba = dev_get_drvdata(dev);
-   struct ufs_qcom_host *host = hba-priv;
+   struct ufs_qcom_host *host = ufshcd_get_variant(hba);
 
return snprintf(buf, PAGE_SIZE, %u\n,
host-bus_vote.is_max_bw_needed);
@@ -877,7 +877,7 @@ store_ufs_to_mem_max_bus_bw(struct device *dev, struct 
device_attribute *attr,
const char *buf, size_t count)
 {
struct ufs_hba *hba = dev_get_drvdata(dev);
-   struct ufs_qcom_host *host = hba-priv;
+   struct ufs_qcom_host *host = ufshcd_get_variant(hba);
uint32_t value;
 
if (!kstrtou32(buf, 0, value)) {
@@ -954,7 +954,7 @@ static int ufs_qcom_init(struct ufs_hba *hba)
}
 
host-hba 

[PATCH v2 5/8] scsi: ufs: creates wrapper functions for vops

2015-08-20 Thread Yaniv Gardi
In order to simplify the code a set of wrapper functions is created
to test and call each of the variant operations.

Signed-off-by: Yaniv Gardi yga...@codeaurora.org

---
 drivers/scsi/ufs/ufs-qcom.c |   1 -
 drivers/scsi/ufs/ufshcd.c   | 104 +---
 drivers/scsi/ufs/ufshcd.h   |  98 +
 3 files changed, 137 insertions(+), 66 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 64c54b7..329ac84 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -1049,6 +1049,5 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops 
= {
.suspend= ufs_qcom_suspend,
.resume = ufs_qcom_resume,
 };
-EXPORT_SYMBOL(ufs_hba_qcom_vops);
 
 MODULE_LICENSE(GPL v2);
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index b0ade73..9e79c33 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -271,10 +271,8 @@ static inline u32 ufshcd_get_intr_mask(struct ufs_hba *hba)
  */
 static inline u32 ufshcd_get_ufs_version(struct ufs_hba *hba)
 {
-   if (hba-quirks  UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION) {
-   if (hba-vops  hba-vops-get_ufs_hci_version)
-   return hba-vops-get_ufs_hci_version(hba);
-   }
+   if (hba-quirks  UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION)
+   return ufshcd_vops_get_ufs_hci_version(hba);
 
return ufshcd_readl(hba, REG_UFS_VERSION);
 }
@@ -2473,9 +2471,8 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba,
dev_err(hba-dev,
%s: power mode change failed %d\n, __func__, ret);
} else {
-   if (hba-vops  hba-vops-pwr_change_notify)
-   hba-vops-pwr_change_notify(hba,
-   POST_CHANGE, NULL, pwr_mode);
+   ufshcd_vops_pwr_change_notify(hba, POST_CHANGE, NULL,
+   pwr_mode);
 
memcpy(hba-pwr_info, pwr_mode,
sizeof(struct ufs_pa_layer_attr));
@@ -2495,10 +2492,10 @@ static int ufshcd_config_pwr_mode(struct ufs_hba *hba,
struct ufs_pa_layer_attr final_params = { 0 };
int ret;
 
-   if (hba-vops  hba-vops-pwr_change_notify)
-   hba-vops-pwr_change_notify(hba,
-PRE_CHANGE, desired_pwr_mode, final_params);
-   else
+   ret = ufshcd_vops_pwr_change_notify(hba, PRE_CHANGE,
+   desired_pwr_mode, final_params);
+
+   if (ret)
memcpy(final_params, desired_pwr_mode, sizeof(final_params));
 
ret = ufshcd_change_power_mode(hba, final_params);
@@ -2647,8 +2644,7 @@ static int ufshcd_hba_enable(struct ufs_hba *hba)
/* UniPro link is disabled at this point */
ufshcd_set_link_off(hba);
 
-   if (hba-vops  hba-vops-hce_enable_notify)
-   hba-vops-hce_enable_notify(hba, PRE_CHANGE);
+   ufshcd_vops_hce_enable_notify(hba, PRE_CHANGE);
 
/* start controller initialization sequence */
ufshcd_hba_start(hba);
@@ -2681,8 +2677,7 @@ static int ufshcd_hba_enable(struct ufs_hba *hba)
/* enable UIC related interrupts */
ufshcd_enable_intr(hba, UFSHCD_UIC_MASK);
 
-   if (hba-vops  hba-vops-hce_enable_notify)
-   hba-vops-hce_enable_notify(hba, POST_CHANGE);
+   ufshcd_vops_hce_enable_notify(hba, POST_CHANGE);
 
return 0;
 }
@@ -2735,8 +2730,7 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
int retries = DME_LINKSTARTUP_RETRIES;
 
do {
-   if (hba-vops  hba-vops-link_startup_notify)
-   hba-vops-link_startup_notify(hba, PRE_CHANGE);
+   ufshcd_vops_link_startup_notify(hba, PRE_CHANGE);
 
ret = ufshcd_dme_link_startup(hba);
 
@@ -2767,11 +2761,9 @@ static int ufshcd_link_startup(struct ufs_hba *hba)
}
 
/* Include any host controller configuration via UIC commands */
-   if (hba-vops  hba-vops-link_startup_notify) {
-   ret = hba-vops-link_startup_notify(hba, POST_CHANGE);
-   if (ret)
-   goto out;
-   }
+   ret = ufshcd_vops_link_startup_notify(hba, POST_CHANGE);
+   if (ret)
+   goto out;
 
ret = ufshcd_make_hba_operational(hba);
 out:
@@ -4578,8 +4570,7 @@ static int __ufshcd_setup_clocks(struct ufs_hba *hba, 
bool on,
}
}
 
-   if (hba-vops  hba-vops-setup_clocks)
-   ret = hba-vops-setup_clocks(hba, on);
+   ret = ufshcd_vops_setup_clocks(hba, on);
 out:
if (ret) {
list_for_each_entry(clki, head, list) {
@@ -4645,27 +4636,22 @@ static int ufshcd_variant_hba_init(struct ufs_hba *hba)
if (!hba-vops)
goto out;
 
-   if (hba-vops-init) {
-   err = 

[PATCH v2 8/8] scsi: ufs-qcom: add QUniPro hardware support and power optimizations

2015-08-20 Thread Yaniv Gardi
New revisions of UFS host controller supports the new UniPro
hardware controller (referred as QUniPro). This patch adds
the support to enable this new UniPro controller hardware.

This change also adds power optimization for bus scaling feature, as well
as support for HS-G3 power mode.

Signed-off-by: Yaniv Gardi yga...@codeaurora.org

---
 drivers/scsi/ufs/ufs-qcom.c | 632 
 drivers/scsi/ufs/ufs-qcom.h |  31 ++-
 drivers/scsi/ufs/ufshcd.c   |   8 +-
 drivers/scsi/ufs/ufshcd.h   |  31 ++-
 4 files changed, 522 insertions(+), 180 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index adfd3f3..42a281c 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -44,11 +44,11 @@ enum {
 
 static struct ufs_qcom_host *ufs_qcom_hosts[MAX_UFS_QCOM_HOSTS];
 
-static void ufs_qcom_get_speed_mode(struct ufs_pa_layer_attr *p, char *result);
-static int ufs_qcom_get_bus_vote(struct ufs_qcom_host *host,
-   const char *speed_mode);
 static int ufs_qcom_set_bus_vote(struct ufs_qcom_host *host, int vote);
 static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host);
+static int ufs_qcom_set_dme_vs_core_clk_ctrl_clear_div(struct ufs_hba *hba,
+  u32 clk_cycles);
+
 static void ufs_qcom_dump_regs(struct ufs_hba *hba, int offset, int len,
char *prefix)
 {
@@ -176,6 +176,7 @@ static int ufs_qcom_init_lane_clks(struct ufs_qcom_host 
*host)
 
err = ufs_qcom_host_clk_get(dev, tx_lane1_sync_clk,
host-tx_l1_sync_clk);
+
 out:
return err;
 }
@@ -208,7 +209,9 @@ static int ufs_qcom_check_hibern8(struct ufs_hba *hba)
 
do {
err = ufshcd_dme_get(hba,
-   UIC_ARG_MIB(MPHY_TX_FSM_STATE), tx_fsm_val);
+   UIC_ARG_MIB_SEL(MPHY_TX_FSM_STATE,
+   UIC_ARG_MPHY_TX_GEN_SEL_INDEX(0)),
+   tx_fsm_val);
if (err || tx_fsm_val == TX_FSM_HIBERN8)
break;
 
@@ -222,7 +225,9 @@ static int ufs_qcom_check_hibern8(struct ufs_hba *hba)
 */
if (time_after(jiffies, timeout))
err = ufshcd_dme_get(hba,
-   UIC_ARG_MIB(MPHY_TX_FSM_STATE), tx_fsm_val);
+   UIC_ARG_MIB_SEL(MPHY_TX_FSM_STATE,
+   UIC_ARG_MPHY_TX_GEN_SEL_INDEX(0)),
+   tx_fsm_val);
 
if (err) {
dev_err(hba-dev, %s: unable to get TX_FSM_STATE, err %d\n,
@@ -236,6 +241,15 @@ static int ufs_qcom_check_hibern8(struct ufs_hba *hba)
return err;
 }
 
+static void ufs_qcom_select_unipro_mode(struct ufs_qcom_host *host)
+{
+   ufshcd_rmwl(host-hba, QUNIPRO_SEL,
+  ufs_qcom_cap_qunipro(host) ? QUNIPRO_SEL : 0,
+  REG_UFS_CFG1);
+   /* make sure above configuration is applied before we return */
+   mb();
+}
+
 static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
 {
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
@@ -250,6 +264,7 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
usleep_range(1000, 1100);
 
ret = ufs_qcom_phy_calibrate_phy(phy, is_rate_B);
+
if (ret) {
dev_err(hba-dev, %s: ufs_qcom_phy_calibrate_phy() failed, ret 
= %d\n,
__func__, ret);
@@ -276,6 +291,8 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
dev_err(hba-dev, %s: is_physical_coding_sublayer_ready() 
failed, ret = %d\n,
__func__, ret);
 
+   ufs_qcom_select_unipro_mode(host);
+
 out:
return ret;
 }
@@ -298,7 +315,8 @@ static void ufs_qcom_enable_hw_clk_gating(struct ufs_hba 
*hba)
mb();
 }
 
-static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba, bool status)
+static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba,
+ enum ufs_notify_change_status status)
 {
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
int err = 0;
@@ -328,12 +346,12 @@ static int ufs_qcom_hce_enable_notify(struct ufs_hba 
*hba, bool status)
 }
 
 /**
- * Returns non-zero for success (which rate of core_clk) and 0
- * in case of a failure
+ * Returns zero for success and non-zero in case of a failure
  */
-static unsigned long
-ufs_qcom_cfg_timers(struct ufs_hba *hba, u32 gear, u32 hs, u32 rate)
+static int ufs_qcom_cfg_timers(struct ufs_hba *hba, u32 gear,
+  u32 hs, u32 rate, bool update_link_startup_timer)
 {
+   int ret = 0;
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
struct ufs_clk_info *clki;
u32 core_clk_period_in_ns;
@@ -351,11 +369,13 @@ ufs_qcom_cfg_timers(struct ufs_hba *hba, u32 gear, u32 
hs, u32 rate)
static u32 hs_fr_table_rA[][2] = 

[PATCH v2 3/8] scsi: ufs-qcom: update configuration option of SCSI_UFS_QCOM component

2015-08-20 Thread Yaniv Gardi
This change is required in order to be able to build the component
as a module.

Signed-off-by: Yaniv Gardi yga...@codeaurora.org

---
 drivers/scsi/ufs/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index e945383..5f45307 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -72,7 +72,7 @@ config SCSI_UFSHCD_PLATFORM
  If unsure, say N.
 
 config SCSI_UFS_QCOM
-   bool QCOM specific hooks to UFS controller platform driver
+   tristate QCOM specific hooks to UFS controller platform driver
depends on SCSI_UFSHCD_PLATFORM  ARCH_QCOM
select PHY_QCOM_UFS
help
-- 
1.8.5.2

-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 7/8] scsi: ufs-qcom: add debug prints for test bus

2015-08-20 Thread Yaniv Gardi
Adds support for configuring and reading the test bus and debug
registers. This change also adds another vops in order to print the
debug registers.

Signed-off-by: Yaniv Gardi yga...@codeaurora.org

---
 drivers/scsi/ufs/ufs-qcom.c | 164 +++-
 drivers/scsi/ufs/ufs-qcom.h |  37 +-
 drivers/scsi/ufs/ufshcd.c   |   2 +
 drivers/scsi/ufs/ufshcd.h   |   8 +++
 4 files changed, 207 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 725cd49..adfd3f3 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -23,6 +23,24 @@
 #include unipro.h
 #include ufs-qcom.h
 #include ufshci.h
+#define UFS_QCOM_DEFAULT_DBG_PRINT_EN  \
+   (UFS_QCOM_DBG_PRINT_REGS_EN | UFS_QCOM_DBG_PRINT_TEST_BUS_EN)
+
+enum {
+   TSTBUS_UAWM,
+   TSTBUS_UARM,
+   TSTBUS_TXUC,
+   TSTBUS_RXUC,
+   TSTBUS_DFC,
+   TSTBUS_TRLUT,
+   TSTBUS_TMRLUT,
+   TSTBUS_OCSC,
+   TSTBUS_UTP_HCI,
+   TSTBUS_COMBINED,
+   TSTBUS_WRAPPER,
+   TSTBUS_UNIPRO,
+   TSTBUS_MAX,
+};
 
 static struct ufs_qcom_host *ufs_qcom_hosts[MAX_UFS_QCOM_HOSTS];
 
@@ -30,6 +48,14 @@ static void ufs_qcom_get_speed_mode(struct ufs_pa_layer_attr 
*p, char *result);
 static int ufs_qcom_get_bus_vote(struct ufs_qcom_host *host,
const char *speed_mode);
 static int ufs_qcom_set_bus_vote(struct ufs_qcom_host *host, int vote);
+static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host);
+static void ufs_qcom_dump_regs(struct ufs_hba *hba, int offset, int len,
+   char *prefix)
+{
+   print_hex_dump(KERN_ERR, prefix,
+   len  4 ? DUMP_PREFIX_OFFSET : DUMP_PREFIX_NONE,
+   16, 4, hba-mmio_base + offset, len * 4, false);
+}
 
 static int ufs_qcom_get_connected_tx_lanes(struct ufs_hba *hba, u32 *tx_lanes)
 {
@@ -996,6 +1022,15 @@ static int ufs_qcom_init(struct ufs_hba *hba)
if (hba-dev-id  MAX_UFS_QCOM_HOSTS)
ufs_qcom_hosts[hba-dev-id] = host;
 
+   host-dbg_print_en |= UFS_QCOM_DEFAULT_DBG_PRINT_EN;
+   ufs_qcom_get_default_testbus_cfg(host);
+   err = ufs_qcom_testbus_config(host);
+   if (err) {
+   dev_warn(dev, %s: failed to configure the testbus %d\n,
+   __func__, err);
+   err = 0;
+   }
+
goto out;
 
 out_disable_phy:
@@ -1025,12 +1060,134 @@ void ufs_qcom_clk_scale_notify(struct ufs_hba *hba)
 
if (!dev_req_params)
return;
+}
+
+static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host)
+{
+   /* provide a legal default configuration */
+   host-testbus.select_major = TSTBUS_UAWM;
+   host-testbus.select_minor = 1;
+}
+
+static bool ufs_qcom_testbus_cfg_is_ok(struct ufs_qcom_host *host)
+{
+   if (host-testbus.select_major = TSTBUS_MAX) {
+   dev_err(host-hba-dev,
+   %s: UFS_CFG1[TEST_BUS_SEL} may not equal 0x%05X\n,
+   __func__, host-testbus.select_major);
+   return false;
+   }
+
+   /*
+* Not performing check for each individual select_major
+* mappings of select_minor, since there is no harm in
+* configuring a non-existent select_minor
+*/
+   if (host-testbus.select_major  0x1F) {
+   dev_err(host-hba-dev,
+   %s: 0x%05X is not a legal testbus option\n,
+   __func__, host-testbus.select_minor);
+   return false;
+   }
+
+   return true;
+}
+
+int ufs_qcom_testbus_config(struct ufs_qcom_host *host)
+{
+   int reg;
+   int offset;
+   u32 mask = TEST_BUS_SUB_SEL_MASK;
+
+   if (!host)
+   return -EINVAL;
 
-   ufs_qcom_cfg_timers(hba, dev_req_params-gear_rx,
-   dev_req_params-pwr_rx,
-   dev_req_params-hs_rate);
+   if (!ufs_qcom_testbus_cfg_is_ok(host))
+   return -EPERM;
+
+   switch (host-testbus.select_major) {
+   case TSTBUS_UAWM:
+   reg = UFS_TEST_BUS_CTRL_0;
+   offset = 24;
+   break;
+   case TSTBUS_UARM:
+   reg = UFS_TEST_BUS_CTRL_0;
+   offset = 16;
+   break;
+   case TSTBUS_TXUC:
+   reg = UFS_TEST_BUS_CTRL_0;
+   offset = 8;
+   break;
+   case TSTBUS_RXUC:
+   reg = UFS_TEST_BUS_CTRL_0;
+   offset = 0;
+   break;
+   case TSTBUS_DFC:
+   reg = UFS_TEST_BUS_CTRL_1;
+   offset = 24;
+   break;
+   case TSTBUS_TRLUT:
+   reg = UFS_TEST_BUS_CTRL_1;
+   offset = 16;
+   break;
+   case TSTBUS_TMRLUT:
+   reg = UFS_TEST_BUS_CTRL_1;
+   offset = 8;
+   break;
+   case TSTBUS_OCSC:
+ 

[PATCH v2 6/8] scsi: ufs: make the UFS variant a platform device

2015-08-20 Thread Yaniv Gardi
This change turns the UFS variant (SCSI_UFS_QCOM) into a UFS
a platform device.
In order to do so a few additional changes are required:
1. The ufshcd-pltfrm is no longer serves as a platform device.
   Now it only serves as a group of platform APIs such as PM APIs
   (runtime suspend/resume, system suspend/resume etc), parsers of
   clocks, regulators and pm_levels from DT.
2. What used to be the old platform probe is now only a pltfrm_init()
   routine, that does exactly the same, but only being called by the
   new probe function of the UFS variant.

Signed-off-by: Yaniv Gardi yga...@codeaurora.org

---
 drivers/scsi/ufs/ufs-qcom.c  | 83 +++-
 drivers/scsi/ufs/ufshcd-pltfrm.c | 92 ++--
 drivers/scsi/ufs/ufshcd-pltfrm.h | 41 ++
 drivers/scsi/ufs/ufshcd.c| 10 +
 drivers/scsi/ufs/ufshcd.h|  1 +
 5 files changed, 156 insertions(+), 71 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.h

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 329ac84..725cd49 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -19,6 +19,7 @@
 
 #include linux/phy/phy-qcom-ufs.h
 #include ufshcd.h
+#include ufshcd-pltfrm.h
 #include unipro.h
 #include ufs-qcom.h
 #include ufshci.h
@@ -1036,7 +1037,7 @@ void ufs_qcom_clk_scale_notify(struct ufs_hba *hba)
  * The variant operations configure the necessary controller and PHY
  * handshake during initialization.
  */
-static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
+static struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
.name   = qcom,
.init   = ufs_qcom_init,
.exit   = ufs_qcom_exit,
@@ -1050,4 +1051,84 @@ static const struct ufs_hba_variant_ops 
ufs_hba_qcom_vops = {
.resume = ufs_qcom_resume,
 };
 
+/**
+ * ufs_qcom_probe - probe routine of the driver
+ * @pdev: pointer to Platform device handle
+ *
+ * Always return 0
+ */
+static int ufs_qcom_probe(struct platform_device *pdev)
+{
+   int err;
+   struct device *dev = pdev-dev;
+   struct ufs_hba *hba;
+
+   /* Perform generic probe */
+   err = ufshcd_pltfrm_init(pdev, ufs_hba_qcom_vops);
+   if (err) {
+   dev_err(dev, ufshcd_pltfrm_init() failed %d\n, err);
+   goto out;
+   }
+
+   hba = platform_get_drvdata(pdev);
+   if (unlikely(!hba)) {
+   dev_err(dev, no hba structure after successful probing\n);
+   goto dealloc_host;
+   }
+
+   return 0;
+
+dealloc_host:
+   /* disconnect the bind between the qcom host and the hba */
+   ufshcd_set_variant(hba, NULL);
+   ufshcd_dealloc_host(hba);
+out:
+   return err;
+}
+
+/**
+ * ufs_qcom_remove - set driver_data of the device to NULL
+ * @pdev: pointer to platform device handle
+ *
+ * Always return 0
+ */
+static int ufs_qcom_remove(struct platform_device *pdev)
+{
+   struct ufs_hba *hba =  platform_get_drvdata(pdev);
+
+   pm_runtime_get_sync((pdev)-dev);
+   ufshcd_remove(hba);
+   return 0;
+}
+
+static void ufs_qcom_shutdown(struct platform_device *pdev)
+{
+   ufshcd_shutdown((struct ufs_hba *)platform_get_drvdata(pdev));
+}
+
+static const struct of_device_id ufs_qcom_of_match[] = {
+   { .compatible = qcom,ufshc},
+   {},
+};
+
+static const struct dev_pm_ops ufs_qcom_pm_ops = {
+   .suspend= ufshcd_pltfrm_suspend,
+   .resume = ufshcd_pltfrm_resume,
+   .runtime_suspend = ufshcd_pltfrm_runtime_suspend,
+   .runtime_resume  = ufshcd_pltfrm_runtime_resume,
+   .runtime_idle= ufshcd_pltfrm_runtime_idle,
+};
+
+static struct platform_driver ufs_qcom_pltform = {
+   .probe  = ufs_qcom_probe,
+   .remove = ufs_qcom_remove,
+   .shutdown = ufs_qcom_shutdown,
+   .driver = {
+   .name   = ufshcd-qcom,
+   .pm = ufs_qcom_pm_ops,
+   .of_match_table = of_match_ptr(ufs_qcom_of_match),
+   },
+};
+module_platform_driver(ufs_qcom_pltform);
+
 MODULE_LICENSE(GPL v2);
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 7db9564..91c73934 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -38,20 +38,7 @@
 #include linux/of.h
 
 #include ufshcd.h
-
-static const struct of_device_id ufs_of_match[];
-static struct ufs_hba_variant_ops *get_variant_ops(struct device *dev)
-{
-   if (dev-of_node) {
-   const struct of_device_id *match;
-
-   match = of_match_node(ufs_of_match, dev-of_node);
-   if (match)
-   return (struct ufs_hba_variant_ops *)match-data;
-   }
-
-   return NULL;
-}
+#include ufshcd-pltfrm.h
 
 static int ufshcd_parse_clock_info(struct ufs_hba *hba)
 {
@@ -245,10 +232,11 @@ out:
  * Returns 0 if successful
  * Returns 

[PATCH v2 0/8] Fix error message and present UFS variant

2015-08-20 Thread Yaniv Gardi
V2 fixes a few issues of unnecessary EXPORT_SYMBOL,
types of parameters in routine definition, 
build errors in case CONFIG_PM is not defined and some
other minor fixes.

Yaniv Gardi (8):
  phy: qcom-ufs: fix build error when the component is built as a module
  scsi: ufs-qcom: fix compilation warning if compiled as a module
  scsi: ufs-qcom: update configuration option of SCSI_UFS_QCOM component
  add ufshcd_get_variant ufshcd_set_variant
  scsi: ufs: creates wrapper functions for vops
  scsi: ufs: make the UFS variant a platform device
  scsi: ufs-qcom: add debug prints for test bus
  scsi: ufs-qcom: add QUniPro hardware support and power optimizations

 drivers/phy/phy-qcom-ufs.c   |  11 +
 drivers/scsi/ufs/Kconfig |   2 +-
 drivers/scsi/ufs/ufs-qcom.c  | 917 +++
 drivers/scsi/ufs/ufs-qcom.h  |  68 ++-
 drivers/scsi/ufs/ufshcd-pltfrm.c |  92 +---
 drivers/scsi/ufs/ufshcd-pltfrm.h |  41 ++
 drivers/scsi/ufs/ufshcd.c| 122 +++---
 drivers/scsi/ufs/ufshcd.h| 149 ++-
 8 files changed, 1070 insertions(+), 332 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.h

-- 
1.8.5.2

-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/8] phy: qcom-ufs: fix build error when the component is built as a module

2015-08-20 Thread Yaniv Gardi
Export the following functions in order to avoid build errors
when the component PHY_QCOM_UFS is compiled as a module:

ERROR: ufs_qcom_phy_disable_ref_clk [drivers/scsi/ufs/ufs-qcom.ko] undefined!
ERROR: ufs_qcom_phy_enable_ref_clk [drivers/scsi/ufs/ufs-qcom.ko] undefined!
ERROR: ufs_qcom_phy_is_pcs_ready [drivers/scsi/ufs/ufs-qcom.ko] undefined!
ERROR: ufs_qcom_phy_disable_iface_clk [drivers/scsi/ufs/ufs-qcom.ko] 
undefined!
ERROR: ufs_qcom_phy_start_serdes [drivers/scsi/ufs/ufs-qcom.ko] undefined!
ERROR: ufs_qcom_phy_calibrate_phy [drivers/scsi/ufs/ufs-qcom.ko] undefined!
ERROR: ufs_qcom_phy_enable_dev_ref_clk [drivers/scsi/ufs/ufs-qcom.ko] 
undefined!
ERROR: ufs_qcom_phy_set_tx_lane_enable [drivers/scsi/ufs/ufs-qcom.ko] 
undefined!
ERROR: ufs_qcom_phy_disable_dev_ref_clk [drivers/scsi/ufs/ufs-qcom.ko] 
undefined!
ERROR: ufs_qcom_phy_save_controller_version [drivers/scsi/ufs/ufs-qcom.ko] 
undefined!
ERROR: ufs_qcom_phy_enable_iface_clk [drivers/scsi/ufs/ufs-qcom.ko] undefined!
make[1]: *** [__modpost] Error 1

Signed-off-by: Yaniv Gardi yga...@codeaurora.org

---
 drivers/phy/phy-qcom-ufs.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/drivers/phy/phy-qcom-ufs.c b/drivers/phy/phy-qcom-ufs.c
index f9c618f..6140a8b 100644
--- a/drivers/phy/phy-qcom-ufs.c
+++ b/drivers/phy/phy-qcom-ufs.c
@@ -432,6 +432,7 @@ out_disable_src:
 out:
return ret;
 }
+EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_ref_clk);
 
 static
 int ufs_qcom_phy_disable_vreg(struct phy *phy,
@@ -474,6 +475,7 @@ void ufs_qcom_phy_disable_ref_clk(struct phy *generic_phy)
phy-is_ref_clk_enabled = false;
}
 }
+EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_ref_clk);
 
 #define UFS_REF_CLK_EN (1  5)
 
@@ -517,11 +519,13 @@ void ufs_qcom_phy_enable_dev_ref_clk(struct phy 
*generic_phy)
 {
ufs_qcom_phy_dev_ref_clk_ctrl(generic_phy, true);
 }
+EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_dev_ref_clk);
 
 void ufs_qcom_phy_disable_dev_ref_clk(struct phy *generic_phy)
 {
ufs_qcom_phy_dev_ref_clk_ctrl(generic_phy, false);
 }
+EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_dev_ref_clk);
 
 /* Turn ON M-PHY RMMI interface clocks */
 int ufs_qcom_phy_enable_iface_clk(struct phy *generic_phy)
@@ -550,6 +554,7 @@ int ufs_qcom_phy_enable_iface_clk(struct phy *generic_phy)
 out:
return ret;
 }
+EXPORT_SYMBOL_GPL(ufs_qcom_phy_enable_iface_clk);
 
 /* Turn OFF M-PHY RMMI interface clocks */
 void ufs_qcom_phy_disable_iface_clk(struct phy *generic_phy)
@@ -562,6 +567,7 @@ void ufs_qcom_phy_disable_iface_clk(struct phy *generic_phy)
phy-is_iface_clk_enabled = false;
}
 }
+EXPORT_SYMBOL_GPL(ufs_qcom_phy_disable_iface_clk);
 
 int ufs_qcom_phy_start_serdes(struct phy *generic_phy)
 {
@@ -578,6 +584,7 @@ int ufs_qcom_phy_start_serdes(struct phy *generic_phy)
 
return ret;
 }
+EXPORT_SYMBOL_GPL(ufs_qcom_phy_start_serdes);
 
 int ufs_qcom_phy_set_tx_lane_enable(struct phy *generic_phy, u32 tx_lanes)
 {
@@ -595,6 +602,7 @@ int ufs_qcom_phy_set_tx_lane_enable(struct phy 
*generic_phy, u32 tx_lanes)
 
return ret;
 }
+EXPORT_SYMBOL_GPL(ufs_qcom_phy_set_tx_lane_enable);
 
 void ufs_qcom_phy_save_controller_version(struct phy *generic_phy,
  u8 major, u16 minor, u16 step)
@@ -605,6 +613,7 @@ void ufs_qcom_phy_save_controller_version(struct phy 
*generic_phy,
ufs_qcom_phy-host_ctrl_rev_minor = minor;
ufs_qcom_phy-host_ctrl_rev_step = step;
 }
+EXPORT_SYMBOL_GPL(ufs_qcom_phy_save_controller_version);
 
 int ufs_qcom_phy_calibrate_phy(struct phy *generic_phy, bool is_rate_B)
 {
@@ -625,6 +634,7 @@ int ufs_qcom_phy_calibrate_phy(struct phy *generic_phy, 
bool is_rate_B)
 
return ret;
 }
+EXPORT_SYMBOL_GPL(ufs_qcom_phy_calibrate_phy);
 
 int ufs_qcom_phy_remove(struct phy *generic_phy,
struct ufs_qcom_phy *ufs_qcom_phy)
@@ -662,6 +672,7 @@ int ufs_qcom_phy_is_pcs_ready(struct phy *generic_phy)
return ufs_qcom_phy-phy_spec_ops-
is_physical_coding_sublayer_ready(ufs_qcom_phy);
 }
+EXPORT_SYMBOL_GPL(ufs_qcom_phy_is_pcs_ready);
 
 int ufs_qcom_phy_power_on(struct phy *generic_phy)
 {
-- 
1.8.5.2

-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/8] scsi: ufs-qcom: fix compilation warning if compiled as a module

2015-08-20 Thread Yaniv Gardi
This change fixes a compilation warning that happens if SCSI_UFS_QCOM
is compiled as a module.
Also this patch fixes an error happens when insmod the module:
ufs_qcom: module license 'unspecified' taints kernel.

Signed-off-by: Yaniv Gardi yga...@codeaurora.org

---
 drivers/scsi/ufs/ufs-qcom.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index 4cdffa4..6c23bbf 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -917,12 +917,15 @@ out:
 
 #defineANDROID_BOOT_DEV_MAX30
 static char android_boot_dev[ANDROID_BOOT_DEV_MAX];
-static int get_android_boot_dev(char *str)
+
+#ifndef MODULE
+static int __init get_android_boot_dev(char *str)
 {
strlcpy(android_boot_dev, str, ANDROID_BOOT_DEV_MAX);
return 1;
 }
 __setup(androidboot.bootdevice=, get_android_boot_dev);
+#endif
 
 /**
  * ufs_qcom_init - bind phy with controller
@@ -1047,3 +1050,5 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops 
= {
.resume = ufs_qcom_resume,
 };
 EXPORT_SYMBOL(ufs_hba_qcom_vops);
+
+MODULE_LICENSE(GPL v2);
-- 
1.8.5.2

-- 
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member of 
Code Aurora Forum, hosted by The Linux Foundation
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 7/10] megaraid_sas : Print critical fw event message

2015-08-20 Thread Sumit.Saxena
Print firmware event in readable format. This will help user to track any
critical firmware event without any application support.

sample syslogd output -

megaraid_sas :02:00.0: 8619 (491648347s/0x0020/WARN) - Controller 
temperature threshold exceeded. This may indicate inadequate system cooling. 
Switching to low performance mode

Format of print is - pci_dev_id: sequence_number 
(timestamp/locale/class) - description

Signed-off-by: Sumit Saxena sumit.sax...@avagotech.com
Signed-off-by: Kashyap Desai kashyap.de...@avagotech.com
---
 drivers/scsi/megaraid/megaraid_sas.h  |   10 +
 drivers/scsi/megaraid/megaraid_sas_base.c |   61 +
 2 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 5db31c6..ccda60d 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -273,6 +273,16 @@ enum MFI_STAT {
MFI_STAT_INVALID_STATUS = 0xFF
 };
 
+enum mfi_evt_class {
+   MFI_EVT_CLASS_DEBUG =   -2,
+   MFI_EVT_CLASS_PROGRESS =-1,
+   MFI_EVT_CLASS_INFO =0,
+   MFI_EVT_CLASS_WARNING = 1,
+   MFI_EVT_CLASS_CRITICAL =2,
+   MFI_EVT_CLASS_FATAL =   3,
+   MFI_EVT_CLASS_DEAD =4
+};
+
 /*
  * Crash dump related defines
  */
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index de31015..4fb4225 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -260,6 +260,66 @@ megasas_return_cmd(struct megasas_instance *instance, 
struct megasas_cmd *cmd)
 
 }
 
+static const char *
+format_timestamp(uint32_t timestamp)
+{
+   static char buffer[32];
+
+   if ((timestamp  0xff00) == 0xff00)
+   snprintf(buffer, sizeof(buffer), boot + %us, timestamp 
+   0x00ff);
+   else
+   snprintf(buffer, sizeof(buffer), %us, timestamp);
+   return buffer;
+}
+
+static const char *
+format_class(int8_t class)
+{
+   static char buffer[6];
+
+   switch (class) {
+   case MFI_EVT_CLASS_DEBUG:
+   return debug;
+   case MFI_EVT_CLASS_PROGRESS:
+   return progress;
+   case MFI_EVT_CLASS_INFO:
+   return info;
+   case MFI_EVT_CLASS_WARNING:
+   return WARN;
+   case MFI_EVT_CLASS_CRITICAL:
+   return CRIT;
+   case MFI_EVT_CLASS_FATAL:
+   return FATAL;
+   case MFI_EVT_CLASS_DEAD:
+   return DEAD;
+   default:
+   snprintf(buffer, sizeof(buffer), %d, class);
+   return buffer;
+   }
+}
+
+/**
+  * megasas_decode_evt: Decode FW AEN event and print critical event
+  * for information.
+  * @instance: Adapter soft state
+  */
+static void
+megasas_decode_evt(struct megasas_instance *instance)
+{
+   struct megasas_evt_detail *evt_detail = instance-evt_detail;
+   union megasas_evt_class_locale class_locale;
+   class_locale.word = le32_to_cpu(evt_detail-cl.word);
+
+   if (class_locale.members.class = MFI_EVT_CLASS_CRITICAL)
+   dev_info(instance-pdev-dev, %d (%s/0x%04x/%s) - %s\n,
+   le32_to_cpu(evt_detail-seq_num),
+   format_timestamp(le32_to_cpu(evt_detail-time_stamp)),
+   (class_locale.members.locale),
+   format_class(class_locale.members.class),
+   evt_detail-description);
+}
+
 /**
 *  The following functions are defined for xscale
 *  (deviceid : 1064R, PERC5) controllers
@@ -6610,6 +6670,7 @@ megasas_aen_polling(struct work_struct *work)
instance-ev = NULL;
host = instance-host;
if (instance-evt_detail) {
+   megasas_decode_evt(instance);
 
switch (le32_to_cpu(instance-evt_detail-code)) {
case MR_EVT_PD_INSERTED:
-- 
1.7.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 v2 10/10] megaraid_sas : Version upgrade

2015-08-20 Thread Sumit.Saxena
Signed-off-by: Sumit Saxena sumit.sax...@avagotech.com
Signed-off-by: Kashyap Desai kashyap.de...@avagotech.com
---
 drivers/scsi/megaraid/megaraid_sas.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index ccda60d..fc58ba3 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_VERSION06.807.10.00-rc1
-#define MEGASAS_RELDATEMarch 6, 2015
+#define MEGASAS_VERSION06.808.14.00-rc1
+#define MEGASAS_RELDATEJul 31, 2015
 
 /*
  * Device IDs
-- 
1.7.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 v2 9/10] megaraid_sas : Code refactor for use of requestorId

2015-08-20 Thread Sumit.Saxena
Some of the code changes was proposed by David Binderman

Removed redudant check of requestorId. Redundant condition: 
instance.requestorId. 
Check for plasma firmware 1.11 or new restructured to support only for specific 
device id

Signed-off-by: Sumit Saxena sumit.sax...@avagotech.com
Signed-off-by: Kashyap Desai kashyap.de...@avagotech.com
---
 drivers/scsi/megaraid/megaraid_sas_base.c |   35 +++--
 1 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 4fb4225..e6fe5e6 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4844,18 +4844,22 @@ static int megasas_init_fw(struct megasas_instance 
*instance)
 
}
if (ctrl_info-host_interface.SRIOV) {
-   if (!ctrl_info-adapterOperations2.activePassive)
-   instance-PlasmaFW111 = 1;
-
-   if (!instance-PlasmaFW111)
-   instance-requestorId =
-   ctrl_info-iov.requestorId;
-   else {
-   iovPtr = (struct IOV_111 *)((unsigned char *)ctrl_info 
+ IOV_111_OFFSET);
-   instance-requestorId = iovPtr-requestorId;
+   instance-requestorId = ctrl_info-iov.requestorId;
+   if (instance-pdev-device == PCI_DEVICE_ID_LSI_PLASMA) {
+   if (!ctrl_info-adapterOperations2.activePassive)
+   instance-PlasmaFW111 = 1;
+
+   dev_info(instance-pdev-dev, SR-IOV: firmware type: 
%s\n,
+   instance-PlasmaFW111 ? 1.11 : new);
+
+   if (instance-PlasmaFW111) {
+   iovPtr = (struct IOV_111 *)
+   ((unsigned char *)ctrl_info + IOV_111_OFFSET);
+   instance-requestorId = iovPtr-requestorId;
+   }
}
-   dev_warn(instance-pdev-dev, I am VF 
-  requestorId %d\n, instance-requestorId);
+   dev_info(instance-pdev-dev, SRIOV: VF requestorId %d\n,
+   instance-requestorId);
}
 
instance-crash_dump_fw_support =
@@ -6735,8 +6739,7 @@ megasas_aen_polling(struct work_struct *work)
case MR_EVT_CFG_CLEARED:
case MR_EVT_LD_DELETED:
if (!instance-requestorId ||
-   (instance-requestorId 
-megasas_get_ld_vf_affiliation(instance, 0))) {
+   megasas_get_ld_vf_affiliation(instance, 0)) {
if (megasas_ld_list_query(instance,
  
MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
megasas_get_ld_list(instance);
@@ -6767,8 +6770,7 @@ megasas_aen_polling(struct work_struct *work)
break;
case MR_EVT_LD_CREATED:
if (!instance-requestorId ||
-   (instance-requestorId 
-megasas_get_ld_vf_affiliation(instance, 0))) {
+   megasas_get_ld_vf_affiliation(instance, 0)) {
if (megasas_ld_list_query(instance,
  
MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
megasas_get_ld_list(instance);
@@ -6834,8 +6836,7 @@ megasas_aen_polling(struct work_struct *work)
}
 
if (!instance-requestorId ||
-   (instance-requestorId 
-megasas_get_ld_vf_affiliation(instance, 0))) {
+   megasas_get_ld_vf_affiliation(instance, 0)) {
if (megasas_ld_list_query(instance,
  
MR_LD_QUERY_TYPE_EXPOSED_TO_HOST))
megasas_get_ld_list(instance);
-- 
1.7.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 v2 8/10] megaraid_sas : Fix validHandles check in io path

2015-08-20 Thread Sumit.Saxena
Syncro firmware supports round robin IO switch on dual path. For this driver 
use validHandles as a check for dual path. This check suppose to be  1 (not  
2)

Without this patch, earlier driver code does not use dual path functionality.

Signed-off-by: Sumit Saxena sumit.sax...@avagotech.com
Signed-off-by: Kashyap Desai kashyap.de...@avagotech.com
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 9f39859..64e27e6 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -1686,7 +1686,7 @@ megasas_build_ldio_fusion(struct megasas_instance 
*instance,
scp-SCp.Status = ~MEGASAS_LOAD_BALANCE_FLAG;
 
if ((raidLUN[0] == 1) 
-   
(local_map_ptr-raidMap.devHndlInfo[io_info.pd_after_lb].validHandles  2)) {
+   
(local_map_ptr-raidMap.devHndlInfo[io_info.pd_after_lb].validHandles  1)) {
instance-dev_handle = !(instance-dev_handle);
io_info.devHandle =

local_map_ptr-raidMap.devHndlInfo[io_info.pd_after_lb].devHandle[instance-dev_handle];
-- 
1.7.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 v1 8/8] scsi: ufs-qcom: add QUniPro hardware support and power optimizations

2015-08-20 Thread ygardi
Thank you Mita for the review.
Your comments were correct and helpful.
I appreciate your time and effort.

please see inline.

 2015-08-16 19:14 GMT+09:00 Yaniv Gardi yga...@codeaurora.org:
 @@ -1208,6 +1510,7 @@ static struct ufs_hba_variant_ops
 ufs_hba_qcom_vops = {
 .resume = ufs_qcom_resume,
 .dbg_register_dump  = ufs_qcom_dump_dbg_regs,
  };
 +EXPORT_SYMBOL(ufs_hba_qcom_vops);

 As I said in the view comment for the patch 5, this shouldn't be exported
 again.

I removed this export at all. it is not needed anymore.


 @@ -775,6 +781,12 @@ static inline int ufshcd_vops_resume(struct ufs_hba
 *hba, enum ufs_pm_op op)
 return 0;
  }

 +static inline void ufshcd_vops_dbg_register_dump(struct ufs_hba *hba)
 +{
 +   if (hba-vops  hba-vops-dbg_register_dump)
 +   hba-vops-dbg_register_dump(hba);
 +}
 +

 This change should be done in the patch 7?

you are correct.

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



--
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 3/10] megaraid_sas : Jbod sequence number support

2015-08-20 Thread Sumit.Saxena
Implemented JBOD map which will provide quick access for JBOD path and also 
provide sequence number.
This will help hardware to fail command to the FW in case of any sequence 
mismatch.

Fast Path IO for JBOD will refer JBOD map (which has sequence number per JBOD 
devices) 
instead of Raid map.  Earlier, driver use Raid map to get device handle for 
fast path IO,
which does not have sequence number information. Now, driver will use JBOD map 
for the same purpose.
As part of error handling, if JBOD map is failed/not supported by firmware; 
driver will continue legacy behavior.

Now there will be three IO path for JBOD (syspd)

JBOD map with sequence number (Fast Path)
Raid map without sequence number (Fast Path)
FW path via h/w exceptional queue deliberately setup devhandle 0x (FW path).


Relevant data structures:
-Driver send new DCMD MR_DCMD_SYSTEM_PD_MAP_GET_INFO for this purpose.
-struct MR_PD_CFG_SEQ- This structure represent map of single physical device.
-struct MR_PD_CFG_SEQ_NUM_SYNC- This structure represent whole JBOD map in 
general(size, count of sysPDs configured,
 struct MR_PD_CFG_SEQ of syspD with 0 index).

-JBOD sequnce map size is: sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) + 
(sizeof(struct MR_PD_CFG_SEQ) * (MAX_PHYSICAL_DEVICES - 1))
 which is allocated while setting up JBOD map at driver load time.

Signed-off-by: Sumit Saxena sumit.sax...@avagotech.com
Signed-off-by: Kashyap Desai kashyap.de...@avagotech.com
Reviewed-by: Martin Petersen martin.peter...@oracle.com
---
 drivers/scsi/megaraid/megaraid_sas.h|   13 +++-
 drivers/scsi/megaraid/megaraid_sas_base.c   |  100 +-
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  126 ---
 drivers/scsi/megaraid/megaraid_sas_fusion.h |   19 
 4 files changed, 242 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index b0d373d..811fc4a 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -973,7 +973,8 @@ struct megasas_ctrl_info {
 
struct {
 #if defined(__BIG_ENDIAN_BITFIELD)
-   u32 reserved:8;
+   u32 reserved:7;
+   u32 useSeqNumJbodFP:1;
u32 supportExtendedSSCSize:1;
u32 supportDiskCacheSettingForSysPDs:1;
u32 supportCPLDUpdate:1;
@@ -1021,7 +1022,8 @@ struct megasas_ctrl_info {
u32 supportCPLDUpdate:1;
u32 supportDiskCacheSettingForSysPDs:1;
u32 supportExtendedSSCSize:1;
-   u32 reserved:8;
+   u32 useSeqNumJbodFP:1;
+   u32 reserved:7;
 #endif
} adapterOperations3;
 
@@ -1700,6 +1702,7 @@ struct megasas_instance {
u32 crash_dump_drv_support;
u32 crash_dump_app_support;
u32 secure_jbod_support;
+   bool use_seqnum_jbod_fp;   /* Added for PD sequence */
spinlock_t crashdump_lock;
 
struct megasas_register_set __iomem *reg_set;
@@ -1779,7 +1782,9 @@ struct megasas_instance {
struct msix_entry msixentry[MEGASAS_MAX_MSIX_QUEUES];
struct megasas_irq_context irq_context[MEGASAS_MAX_MSIX_QUEUES];
u64 map_id;
+   u64 pd_seq_map_id;
struct megasas_cmd *map_update_cmd;
+   struct megasas_cmd *jbod_seq_cmd;
unsigned long bar;
long reset_flags;
struct mutex reset_mutex;
@@ -1995,6 +2000,9 @@ __le16 get_updated_dev_handle(struct megasas_instance 
*instance,
 void mr_update_load_balance_params(struct MR_DRV_RAID_MAP_ALL *map,
struct LD_LOAD_BALANCE_INFO *lbInfo);
 int megasas_get_ctrl_info(struct megasas_instance *instance);
+/* PD sequence */
+int
+megasas_sync_pd_seq_num(struct megasas_instance *instance, bool pend);
 int megasas_set_crash_dump_params(struct megasas_instance *instance,
u8 crash_buf_state);
 void megasas_free_host_crash_buffer(struct megasas_instance *instance);
@@ -2010,5 +2018,6 @@ void __megasas_return_cmd(struct megasas_instance 
*instance,
 void megasas_return_mfi_mpt_pthr(struct megasas_instance *instance,
struct megasas_cmd *cmd_mfi, struct megasas_cmd_fusion *cmd_fusion);
 int megasas_cmd_type(struct scsi_cmnd *cmd);
+void megasas_setup_jbod_map(struct megasas_instance *instance);
 
 #endif /*LSI_MEGARAID_SAS_H */
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 10c292c..de31015 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -2833,7 +2833,7 @@ megasas_complete_cmd(struct megasas_instance *instance, 
struct megasas_cmd *cmd,
struct megasas_header *hdr = cmd-frame-hdr;
unsigned long flags;
struct fusion_context *fusion = instance-ctrl_context;
-   u32 opcode;
+   u32 opcode, status;
 
/* flag for the retry reset */

[PATCH v2 02/10] megaraid_sas : Increase timeout to 60 secs for abort frames during shutdown

2015-08-20 Thread Sumit.Saxena
Signed-off-by: Sumit Saxena sumit.sax...@avagotech.com
Signed-off-by: Kashyap Desai kashyap.de...@avagotech.com
Reviewed-by: Martin Petersen martin.peter...@oracle.com
---
 drivers/scsi/megaraid/megaraid_sas_base.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 71b884d..10c292c 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -5510,10 +5510,10 @@ static void megasas_shutdown_controller(struct 
megasas_instance *instance,
 
if (instance-aen_cmd)
megasas_issue_blocked_abort_cmd(instance,
-   instance-aen_cmd, 30);
+   instance-aen_cmd, MEGASAS_BLOCKED_CMD_TIMEOUT);
if (instance-map_update_cmd)
megasas_issue_blocked_abort_cmd(instance,
-   instance-map_update_cmd, 30);
+   instance-map_update_cmd, MEGASAS_BLOCKED_CMD_TIMEOUT);
dcmd = cmd-frame-dcmd;
 
memset(dcmd-mbox.b, 0, MFI_MBOX_SIZE);
-- 
1.7.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 v2 6/10] megaraid_sas : Chip reset if driver fail to bring ioc ready

2015-08-20 Thread Sumit.Saxena
Patch which fix the issue reported as below.

http://marc.info/?l=linux-scsim=143694494104544w=2

This patch will try to do chip reset from driver load time.
Driver load time, if firmware is not comming to ready state, driver try chip 
reset calling
adp_reset() callback. For fusion adapter, that call back was void, so it will 
not do any chip reset.

Now, using this patch megasas_adp_reset_fusion() will have chip reset logic for 
Fusion adapter.

Signed-off-by: Sumit Saxena sumit.sax...@avagotech.com
Signed-off-by: Kashyap Desai kashyap.de...@avagotech.com
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c |  143 +--
 1 files changed, 68 insertions(+), 75 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index d1ff580..9f39859 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -2511,6 +2511,70 @@ static int
 megasas_adp_reset_fusion(struct megasas_instance *instance,
 struct megasas_register_set __iomem *regs)
 {
+   u32 host_diag, abs_state, retry;
+
+   /* Now try to reset the chip */
+   writel(MPI2_WRSEQ_FLUSH_KEY_VALUE, 
instance-reg_set-fusion_seq_offset);
+   writel(MPI2_WRSEQ_1ST_KEY_VALUE, instance-reg_set-fusion_seq_offset);
+   writel(MPI2_WRSEQ_2ND_KEY_VALUE, instance-reg_set-fusion_seq_offset);
+   writel(MPI2_WRSEQ_3RD_KEY_VALUE, instance-reg_set-fusion_seq_offset);
+   writel(MPI2_WRSEQ_4TH_KEY_VALUE, instance-reg_set-fusion_seq_offset);
+   writel(MPI2_WRSEQ_5TH_KEY_VALUE, instance-reg_set-fusion_seq_offset);
+   writel(MPI2_WRSEQ_6TH_KEY_VALUE, instance-reg_set-fusion_seq_offset);
+
+   /* Check that the diag write enable (DRWE) bit is on */
+   host_diag = readl(instance-reg_set-fusion_host_diag);
+   retry = 0;
+   while (!(host_diag  HOST_DIAG_WRITE_ENABLE)) {
+   msleep(100);
+   host_diag = readl(instance-reg_set-fusion_host_diag);
+   if (retry++ == 100) {
+   dev_warn(instance-pdev-dev,
+   Host diag unlock failed from %s %d\n,
+   __func__, __LINE__);
+   break;
+   }
+   }
+   if (!(host_diag  HOST_DIAG_WRITE_ENABLE))
+   return -1;
+
+   /* Send chip reset command */
+   writel(host_diag | HOST_DIAG_RESET_ADAPTER,
+   instance-reg_set-fusion_host_diag);
+   msleep(3000);
+
+   /* Make sure reset adapter bit is cleared */
+   host_diag = readl(instance-reg_set-fusion_host_diag);
+   retry = 0;
+   while (host_diag  HOST_DIAG_RESET_ADAPTER) {
+   msleep(100);
+   host_diag = readl(instance-reg_set-fusion_host_diag);
+   if (retry++ == 1000) {
+   dev_warn(instance-pdev-dev,
+   Diag reset adapter never cleared %s %d\n,
+   __func__, __LINE__);
+   break;
+   }
+   }
+   if (host_diag  HOST_DIAG_RESET_ADAPTER)
+   return -1;
+
+   abs_state = instance-instancet-read_fw_status_reg(instance-reg_set)
+MFI_STATE_MASK;
+   retry = 0;
+
+   while ((abs_state = MFI_STATE_FW_INIT)  (retry++  1000)) {
+   msleep(100);
+   abs_state = instance-instancet-
+   read_fw_status_reg(instance-reg_set)  MFI_STATE_MASK;
+   }
+   if (abs_state = MFI_STATE_FW_INIT) {
+   dev_warn(instance-pdev-dev,
+   fw state  MFI_STATE_FW_INIT, state = 0x%x %s %d\n,
+   abs_state, __func__, __LINE__);
+   return -1;
+   }
+
return 0;
 }
 
@@ -2676,11 +2740,11 @@ out:
 /* Core fusion reset function */
 int megasas_reset_fusion(struct Scsi_Host *shost, int iotimeout)
 {
-   int retval = SUCCESS, i, retry = 0, convert = 0;
+   int retval = SUCCESS, i, convert = 0;
struct megasas_instance *instance;
struct megasas_cmd_fusion *cmd_fusion;
struct fusion_context *fusion;
-   u32 host_diag, abs_state, status_reg, reset_adapter;
+   u32 abs_state, status_reg, reset_adapter;
u32 io_timeout_in_crash_mode = 0;
struct scsi_cmnd *scmd_local = NULL;
 
@@ -2834,81 +2898,10 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int 
iotimeout)
 
/* Now try to reset the chip */
for (i = 0; i  MEGASAS_FUSION_MAX_RESET_TRIES; i++) {
-   writel(MPI2_WRSEQ_FLUSH_KEY_VALUE,
-  instance-reg_set-fusion_seq_offset);
-   writel(MPI2_WRSEQ_1ST_KEY_VALUE,
-  instance-reg_set-fusion_seq_offset);
-   writel(MPI2_WRSEQ_2ND_KEY_VALUE,
-  instance-reg_set-fusion_seq_offset);
- 

[PATCH v2 5/10] megaraid_sas : Support for max_io_size 1MB

2015-08-20 Thread Sumit.Saxena
Driver will expose max sge = 256 (earlier it was 64), if firmware support 
extended IO size upto 1M. 

Signed-off-by: Sumit Saxena sumit.sax...@avagotech.com
Signed-off-by: Kashyap Desai kashyap.de...@avagotech.com
Reviewed-by: Martin Petersen martin.peter...@oracle.com
---
 drivers/scsi/megaraid/megaraid_sas.h|7 ++-
 drivers/scsi/megaraid/megaraid_sas_fusion.c |   64 +++
 drivers/scsi/megaraid/megaraid_sas_fusion.h |   10 +++-
 3 files changed, 59 insertions(+), 22 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 811fc4a..5db31c6 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -1239,7 +1239,8 @@ union megasas_sgl_frame {
 typedef union _MFI_CAPABILITIES {
struct {
 #if   defined(__BIG_ENDIAN_BITFIELD)
-   u32 reserved:24;
+   u32 reserved:23;
+   u32 support_ext_io_size:1;
u32 support_ext_queue_depth:1;
u32 security_protocol_cmds_fw:1;
u32 support_core_affinity:1;
@@ -1257,7 +1258,8 @@ typedef union _MFI_CAPABILITIES {
u32 support_core_affinity:1;
u32 security_protocol_cmds_fw:1;
u32 support_ext_queue_depth:1;
-   u32 reserved:24;
+   u32 support_ext_io_size:1;
+   u32 reserved:23;
 #endif
} mfi_capabilities;
__le32  reg;
@@ -1795,6 +1797,7 @@ struct megasas_instance {
char mpio;
u16 throttlequeuedepth;
u8 mask_interrupts;
+   u16 max_chain_frame_sz;
u8 is_imr;
bool dev_handle;
 };
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c 
b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index f82085a..d1ff580 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -316,27 +316,24 @@ static int megasas_create_frame_pool_fusion(struct 
megasas_instance *instance)
u32 max_cmd;
struct fusion_context *fusion;
struct megasas_cmd_fusion *cmd;
-   u32 total_sz_chain_frame;
 
fusion = instance-ctrl_context;
max_cmd = instance-max_fw_cmds;
 
-   total_sz_chain_frame = MEGASAS_MAX_SZ_CHAIN_FRAME;
-
/*
 * Use DMA pool facility provided by PCI layer
 */
 
-   fusion-sg_dma_pool = pci_pool_create(megasas sg pool fusion,
- instance-pdev,
- total_sz_chain_frame, 4,
- 0);
+   fusion-sg_dma_pool = pci_pool_create(sg_pool_fusion, instance-pdev,
+   instance-max_chain_frame_sz,
+   4, 0);
+
if (!fusion-sg_dma_pool) {
printk(KERN_DEBUG megasas: failed to setup request pool 
   fusion\n);
return -ENOMEM;
}
-   fusion-sense_dma_pool = pci_pool_create(megasas sense pool fusion,
+   fusion-sense_dma_pool = pci_pool_create(sense_pool_fusion,
 instance-pdev,
 SCSI_SENSE_BUFFERSIZE, 64, 0);
 
@@ -667,7 +664,9 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
drv_ops-mfi_capabilities.support_max_255lds = 1;
drv_ops-mfi_capabilities.support_ndrive_r1_lb = 1;
drv_ops-mfi_capabilities.security_protocol_cmds_fw = 1;
-   
+   if (instance-max_chain_frame_sz  MEGASAS_CHAIN_FRAME_SZ_MIN)
+   drv_ops-mfi_capabilities.support_ext_io_size = 1;
+
/* Convert capability to LE32 */
cpu_to_le32s((u32 *)init_frame-driver_operations.mfi_capabilities);
 
@@ -1057,7 +1056,7 @@ megasas_init_adapter_fusion(struct megasas_instance 
*instance)
 {
struct megasas_register_set __iomem *reg_set;
struct fusion_context *fusion;
-   u32 max_cmd;
+   u32 max_cmd, scratch_pad_2;
int i = 0, count;
 
fusion = instance-ctrl_context;
@@ -1096,15 +1095,40 @@ megasas_init_adapter_fusion(struct megasas_instance 
*instance)
(MEGA_MPI2_RAID_DEFAULT_IO_FRAME_SIZE *
 (max_cmd + 1)); /* Extra 1 for SMID 0 */
 
+   scratch_pad_2 = readl(instance-reg_set-outbound_scratch_pad_2);
+   /* If scratch_pad_2  MEGASAS_MAX_CHAIN_SIZE_UNITS_MASK is set,
+* Firmware support extended IO chain frame which is 4 times more than
+* legacy Firmware.
+* Legacy Firmware - Frame size is (8 * 128) = 1K
+* 1M IO Firmware  - Frame size is (8 * 128 * 4)  = 4K
+*/
+   if (scratch_pad_2  MEGASAS_MAX_CHAIN_SIZE_UNITS_MASK)
+   instance-max_chain_frame_sz =
+   ((scratch_pad_2  MEGASAS_MAX_CHAIN_SIZE_MASK) 
+   

[PATCH v2 0/10] megaraid_sas : Updates for scsi for-next

2015-08-20 Thread Sumit.Saxena
MegaRaid driver changes. This patch set is resent based on feedback received by 
Martin Petersen.
Please consider this patch set for next kernel release.

Signed-off-by: Sumit Saxena sumit.sax...@avagotech.com
Signed-off-by: Kashyap Desai kashyap.de...@avagotech.com
---
[PATCH v2 00/10] megaraid_sas : Updates for scsi for-next.
[PATCH v2 01/10] megaraid_sas : Synchronize driver headers with firmware APIs.
[PATCH v2 02/10] megaraid_sas : Increase timeout to 60 secs for abort frames 
during shutdown.
[PATCH v2 03/10] megaraid_sas : Jbod sequence number support.
[PATCH v2 04/10] megaraid_sas : Code cleanup-use local variable drv_ops inside 
megasas_ioc_init_fusion.
[PATCH v2 05/10] megaraid_sas : Support for max_io_size 1MB.
[PATCH v2 06/10] megaraid_sas : Chip reset if driver fail to bring ioc ready.
[PATCH v2 07/10] megaraid_sas : Print critical fw event message.
[PATCH v2 08/10] megaraid_sas : Fix validHandles check in io path.
[PATCH v2 09/10] megaraid_sas : Code refactor for use of requestorId.
[PATCH v2 10/10] megaraid_sas : Version upgrade.


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


[Bug 101891] mvsas prep failed, NULL pointer dereference in mvs_slot_task_free+0x5/0x1f0 [mvsas]

2015-08-20 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=101891

--- Comment #7 from Dāvis davis...@gmail.com ---
(In reply to Turbo Fredriksson from comment #6)
 Forgive an ignoramus, but those last lines doesn't look to good
 
 kernel: ata11.00: device reported invalid CHS sector 0
 
 I have a problem that is very much like yours, but my stack traces are
 different so I'm unsure if we have the same problem. I'm going to rebuild my
 kernel as well with your fix and see if it helps me as well.

My fix is only for NULL pointer dereference in mvs_slot_task_free in mvsas
driver. If you use hardware with different driver then this fix won't change
anything for you. And even if you've such hardware and use this driver then you
might have hit different bug, you really should have posted stack trace, logs,
etc...

As for those other messages, I've no clue what they actually mean. But as I
understand under heavy I/O load pci_pool_alloc fails, so those tasks are
aborted and that probably prevents kernel from accessing disks and disk reset
is issued. Then it can access all disks again and everything keeps working.

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


[PATCH v2 01/10] megaraid_sas : Synchronize driver headers with firmware APIs

2015-08-20 Thread Sumit.Saxena
Signed-off-by: Sumit Saxena sumit.sax...@avagotech.com
Signed-off-by: Kashyap Desai kashyap.de...@avagotech.com
Reviewed-by: Martin Petersen martin.peter...@oracle.com
---
 drivers/scsi/megaraid/megaraid_sas.h|   18 ++
 drivers/scsi/megaraid/megaraid_sas_fusion.h |3 ++-
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h 
b/drivers/scsi/megaraid/megaraid_sas.h
index 20c3754..b0d373d 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -973,7 +973,11 @@ struct megasas_ctrl_info {
 
struct {
 #if defined(__BIG_ENDIAN_BITFIELD)
-   u32 reserved:12;
+   u32 reserved:8;
+   u32 supportExtendedSSCSize:1;
+   u32 supportDiskCacheSettingForSysPDs:1;
+   u32 supportCPLDUpdate:1;
+   u32 supportTTYLogCompression:1;
u32 discardCacheDuringLDDelete:1;
u32 supportSecurityonJBOD:1;
u32 supportCacheBypassModes:1;
@@ -1013,7 +1017,11 @@ struct megasas_ctrl_info {
u32 supportCacheBypassModes:1;
u32 supportSecurityonJBOD:1;
u32 discardCacheDuringLDDelete:1;
-   u32 reserved:12;
+   u32 supportTTYLogCompression:1;
+   u32 supportCPLDUpdate:1;
+   u32 supportDiskCacheSettingForSysPDs:1;
+   u32 supportExtendedSSCSize:1;
+   u32 reserved:8;
 #endif
} adapterOperations3;
 
@@ -1229,7 +1237,8 @@ union megasas_sgl_frame {
 typedef union _MFI_CAPABILITIES {
struct {
 #if   defined(__BIG_ENDIAN_BITFIELD)
-   u32 reserved:25;
+   u32 reserved:24;
+   u32 support_ext_queue_depth:1;
u32 security_protocol_cmds_fw:1;
u32 support_core_affinity:1;
u32 support_ndrive_r1_lb:1;
@@ -1245,7 +1254,8 @@ typedef union _MFI_CAPABILITIES {
u32 support_ndrive_r1_lb:1;
u32 support_core_affinity:1;
u32 security_protocol_cmds_fw:1;
-   u32 reserved:25;
+   u32 support_ext_queue_depth:1;
+   u32 reserved:24;
 #endif
} mfi_capabilities;
__le32  reg;
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h 
b/drivers/scsi/megaraid/megaraid_sas_fusion.h
index ced6dc0..be1be8e 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
@@ -117,7 +117,8 @@ struct RAID_CONTEXT {
u8  numSGE;
__le16  configSeqNum;
u8  spanArm;
-   u8  resvd2[3];
+   u8  priority;
+   u8  resvd2[2];
 };
 
 #define RAID_CTX_SPANARM_ARM_SHIFT (0)
-- 
1.7.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 V2 2/8] pm80xx: Corrected device state changes in I_T_Nexus_Reset.

2015-08-20 Thread Tomas Henzl
On 11.8.2015 11:36, viswa...@pmcs.com wrote:
 From: Viswas G viswa...@pmcs.com
 
 In Nexus reset the device state request are not needed.
 
 Changes from V1:
 Device state change request has been removed as the firmware
 will handle it during internal cleanup. Also updated the
 proper return value in case of failures.
 
 Signed-off-by: Viswas G viswa...@pmcs.com
 
 Reviewed-by: Suresh Thiagarajan suresh.thiagara...@pmcs.com
Reviewed-by: Tomas Henzl the...@redhat.com

Tomas

 ---
  drivers/scsi/pm8001/pm8001_sas.c |   18 +-
  drivers/scsi/pm8001/pm8001_sas.h |8 
  2 files changed, 21 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/scsi/pm8001/pm8001_sas.c 
 b/drivers/scsi/pm8001/pm8001_sas.c
 index b93f289..48f4627 100644
 --- a/drivers/scsi/pm8001/pm8001_sas.c
 +++ b/drivers/scsi/pm8001/pm8001_sas.c
 @@ -975,19 +975,27 @@ int pm8001_I_T_nexus_reset(struct domain_device *dev)
   phy = sas_get_local_phy(dev);
  
   if (dev_is_sata(dev)) {
 - DECLARE_COMPLETION_ONSTACK(completion_setstate);
   if (scsi_is_sas_phy_local(phy)) {
   rc = 0;
   goto out;
   }
   rc = sas_phy_reset(phy, 1);
 + if (rc) {
 + PM8001_EH_DBG(pm8001_ha,
 + pm8001_printk(phy reset failed for device %x\n
 + with rc %d\n, pm8001_dev-device_id, rc));
 + rc = TMF_RESP_FUNC_FAILED;
 + goto out;
 + }
   msleep(2000);
   rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev ,
   dev, 1, 0);
 - pm8001_dev-setds_completion = completion_setstate;
 - rc = PM8001_CHIP_DISP-set_dev_state_req(pm8001_ha,
 - pm8001_dev, 0x01);
 - wait_for_completion(completion_setstate);
 + if (rc) {
 + PM8001_EH_DBG(pm8001_ha,
 + pm8001_printk(task abort failed %x\n
 + with rc %d\n, pm8001_dev-device_id, rc));
 + rc = TMF_RESP_FUNC_FAILED;
 + }
   } else {
   rc = sas_phy_reset(phy, 1);
   msleep(2000);
 diff --git a/drivers/scsi/pm8001/pm8001_sas.h 
 b/drivers/scsi/pm8001/pm8001_sas.h
 index 8dd8b78..c9736cc 100644
 --- a/drivers/scsi/pm8001/pm8001_sas.h
 +++ b/drivers/scsi/pm8001/pm8001_sas.h
 @@ -569,6 +569,14 @@ struct pm8001_fw_image_header {
  #define  NCQ_READ_LOG_FLAG   0x8000
  #define  NCQ_ABORT_ALL_FLAG  0x4000
  #define  NCQ_2ND_RLE_FLAG0x2000
 +
 +/* Device states */
 +#define DS_OPERATIONAL   0x01
 +#define DS_PORT_IN_RESET 0x02
 +#define DS_IN_RECOVERY   0x03
 +#define DS_IN_ERROR  0x04
 +#define DS_NON_OPERATIONAL   0x07
 +
  /**
   * brief param structure for firmware flash update.
   */
 

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


Re: [PATCH 2/2] ipr: Enable SIS pipe commands for SIS-32 devices.

2015-08-20 Thread Brian King
On 08/19/2015 09:47 AM, Gabriel Krisman Bertazi wrote:
 Remove unnecessary check that disabled SIS pipe commands for SIS-32
 devices.  This change was sufficient to enable raw mode and send SIS
 pipe commands for a 57B3 device.
 
 Fixes: f8ee25d7d239 (ipr: AF DASD raw mode implementation in ipr driver)
 Signed-off-by: Gabriel Krisman Bertazi kris...@linux.vnet.ibm.com
 ---

Thanks!

Acked-by: Brian King brk...@linux.vnet.ibm.com

-- 
Brian King
Power Linux I/O
IBM Linux Technology Center


--
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 1/2] ipr: Inhibit underlength data check for AFDASD in raw mode.

2015-08-20 Thread Brian King
On 08/19/2015 09:47 AM, Gabriel Krisman Bertazi wrote:
 Disable underlength error verification based on count of bytes actually
 transferred for AF DASD devices when SIS pipe mode is enabled.
 
 This avoids unexpected underlength errors when issuing some commands in
 raw mode.
 
 Signed-off-by: Gabriel Krisman Bertazi kris...@linux.vnet.ibm.com
 ---

Looks good. Thanks!

Acked-by: Brian King brk...@linux.vnet.ibm.com

-- 
Brian King
Power Linux I/O
IBM Linux Technology Center


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


SCSI scanning behavior

2015-08-20 Thread Brian King
In one of our SAN test labs where there is some storage controller error 
injection going on,
I'm seeing some interesting behavior. We are getting into a scenario, when the 
target is coming
back where we are going through SCSI scan for it and the Report LUNs we are 
issuing to it times
out, so we fall back to a sequential LUN scan. When performing the sequential 
LUN scan, we 
end up adding a bunch of LUNs than we didn't previously see, 512 in fact. The 
target is reporting
PQ=1, PDT=0 for every LUN that doesn't exist. When Report LUNs *does work*, it 
doesn't report
these LUNs. 

In net, we end up with a different result if we do a sequential LUN scan 
compared to a report LUNs
scan.

Now, one could argue this is a defect in the SCSI target, since SPC says:

The REPORT LUNS parameter data should be returned even though the device server 
is not ready for other
commands. The report of the logical unit inventory should be available without 
incurring any media access
delays. If the device server is not ready with the logical unit inventory or if 
the inventory list is null for the
requesting I_T nexus and the SELECT REPORT field set to 02h, then the device 
server shall provide a default
logical unit inventory that contains at least LUN 0 or the REPORT LUNS well 
known logical unit (see 8.2). A
non-empty peripheral device logical unit inventory that does not contain either 
LUN 0 or the REPORT LUNS
well known logical unit is valid.

However, I'm still left wondering why we are adding PQ=1, PDT=0 devices in the 
sequential LUN scan at all.
Are there media changer devices out there that we've seen respond like this? 
Even so, does it make sense
to add PQ=1, PDT=0 LUNs for LUN  0?

Thanks,

Brian

-- 
Brian King
Power Linux I/O
IBM Linux Technology Center


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