Re: [PATCH 3/3] scsi:stex.c Add S3/S4 support

2015-09-03 Thread Johannes Thumshirn
Charles Chiou  writes:

> From f442518879f8f41d103b684046d912eca13844e7 Mon Sep 17 00:00:00 2001
> From: Charles 
> Date: Wed, 2 Sep 2015 20:54:45 +0800
> Subject: [PATCH 3/3] scsi:stex.c Add S3/S4 support
>
> Add S3/S4 support, add .suspend and .resume function in pci_driver.
> In .suspend handler, driver send S3/S4 signal to the device.
>
> V2: Remove blank lines
>
> Signed-off-by: Charles Chiou 
> ---
>  drivers/scsi/stex.c | 59 
> ++---
>  1 file changed, 56 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
> index 4ef0c80..c96a86d 100644
> --- a/drivers/scsi/stex.c
> +++ b/drivers/scsi/stex.c
> @@ -166,6 +166,13 @@ enum {
>
>   ST_ADDITIONAL_MEM   = 0x20,
>   ST_ADDITIONAL_MEM_MIN   = 0x8,
> + PMIC_SHUTDOWN   = 0x0D,
> + PMIC_REUMSE = 0x10,
> + ST_IGNORED  = -1,
> + ST_S3   = 3,
> + ST_S4   = 4,
> + ST_S5   = 5,
> + ST_S6   = 6,
>  };
>
>  struct st_sgitem {
> @@ -1733,7 +1740,7 @@ out_disable:
>   return err;
>  }
>
> -static void stex_hba_stop(struct st_hba *hba)
> +static void stex_hba_stop(struct st_hba *hba, int st_sleep_mic)
>  {
>   struct req_msg *req;
>   struct st_msg_header *msg_h;
> @@ -1749,11 +1756,18 @@ static void stex_hba_stop(struct st_hba *hba)
>   } else
>   memset(req, 0, hba->rq_size);
>
> - if (hba->cardtype == st_yosemite || hba->cardtype == st_yel) {
> + if ((hba->cardtype == st_yosemite || hba->cardtype == st_yel)
> + && st_sleep_mic == ST_IGNORED) {
>   req->cdb[0] = MGT_CMD;
>   req->cdb[1] = MGT_CMD_SIGNATURE;
>   req->cdb[2] = CTLR_CONFIG_CMD;
>   req->cdb[3] = CTLR_SHUTDOWN;
> + } else if (hba->cardtype == st_yel && st_sleep_mic != ST_IGNORED) {
> + req->cdb[0] = MGT_CMD;
> + req->cdb[1] = MGT_CMD_SIGNATURE;
> + req->cdb[2] = CTLR_CONFIG_CMD;
> + req->cdb[3] = PMIC_SHUTDOWN;
> + req->cdb[4] = st_sleep_mic;
>   } else {
>   req->cdb[0] = CONTROLLER_CMD;
>   req->cdb[1] = CTLR_POWER_STATE_CHANGE;
> @@ -1773,10 +1787,12 @@ static void stex_hba_stop(struct st_hba *hba)
>   while (hba->ccb[tag].req_type & PASSTHRU_REQ_TYPE) {
>   if (time_after(jiffies, before + ST_INTERNAL_TIMEOUT * HZ)) {
>   hba->ccb[tag].req_type = 0;
> + hba->mu_status = MU_STATE_STOP;
>   return;
>   }
>   msleep(1);
>   }
> + hba->mu_status = MU_STATE_STOP;
>  }
>
>  static void stex_hba_free(struct st_hba *hba)
> @@ -1816,9 +1832,44 @@ static void stex_shutdown(struct pci_dev *pdev)
>  {
>   struct st_hba *hba = pci_get_drvdata(pdev);
>
> - stex_hba_stop(hba);
> + if (hba->supports_pm == 0)
> + stex_hba_stop(hba, ST_IGNORED);
> + else
> + stex_hba_stop(hba, ST_S5);
> +}
> +
> +static int stex_choice_sleep_mic(pm_message_t state)
> +{
> + switch (state.event) {
> + case PM_EVENT_SUSPEND:
> + return ST_S3;
> + case PM_EVENT_FREEZE:
> + case PM_EVENT_HIBERNATE:
> + return ST_S4;
> + default:
> + return ST_S4;
> + }
> +}
> +
> +static int stex_suspend(struct pci_dev *pdev, pm_message_t state)
> +{
> + struct st_hba *hba = pci_get_drvdata(pdev);
> +
> + if (hba->cardtype == st_yel && hba->supports_pm == 1)
> + stex_hba_stop(hba, stex_choice_sleep_mic(state));
> + else
> + stex_hba_stop(hba, ST_IGNORED);
> + return 0;
>  }
>
> +static int stex_resume(struct pci_dev *pdev)
> +{
> + struct st_hba *hba = pci_get_drvdata(pdev);
> +
> + hba->mu_status = MU_STATE_STARTING;
> + stex_handshake(hba);
> + return 0;
> +}
>  MODULE_DEVICE_TABLE(pci, stex_pci_tbl);
>
>  static struct pci_driver stex_pci_driver = {
> @@ -1827,6 +1878,8 @@ static struct pci_driver stex_pci_driver = {
>   .probe  = stex_probe,
>   .remove = stex_remove,
>   .shutdown   = stex_shutdown,
> + .suspend= stex_suspend,
> + .resume = stex_resume,
>  };
>
>  static int __init stex_init(void)

Looks OK from my side
Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 

Re: [v2 PATCH 2/3] scsi:stex.c Add hotplug support

2015-09-03 Thread Johannes Thumshirn
Charles Chiou  writes:

> From 60e14c245c18cbe0300cfa244334e2850a52a381 Mon Sep 17 00:00:00 2001
> From: Charles 
> Date: Wed, 2 Sep 2015 20:48:55 +0800
> Subject: [PATCH 2/3] scsi:stex.c Add hotplug support
>
> 1. Add hotplug support. Pegasus support surprise removal. To this end, I
>use return_abnormal_state function to return DID_NO_CONNECT for all
>   commands which sent to driver.
>
> 2. Remove stex_hba_stop in stex_remove because we cannot send command to
>device after hotplug.
>
> 3. Add new device status:  MU_STATE_STOP, MU_STATE_NOCONNECT,
>MU_STATE_STOP. MU_STATE_STOP is currently not referenced.
>MU_STATE_NOCONNECT represent that device is plugged out from the host.
>
> 4. Use return_abnormal_function() to substitute part of code in stex_do_reset.
>
> V2: N/A
>
> Signed-off-by: Charles Chiou 
> ---
>  drivers/scsi/stex.c | 53 
> ++---
>  1 file changed, 34 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
> index 0c93f1f..4ef0c80 100644
> --- a/drivers/scsi/stex.c
> +++ b/drivers/scsi/stex.c
> @@ -83,6 +83,8 @@ enum {
>   MU_STATE_STARTED= 2,
>   MU_STATE_RESETTING  = 3,
>   MU_STATE_FAILED = 4,
> + MU_STATE_STOP   = 5,
> + MU_STATE_NOCONNECT  = 6,
>
>   MU_MAX_DELAY= 120,
>   MU_HANDSHAKE_SIGNATURE  = 0x5555,
> @@ -544,6 +546,27 @@ stex_ss_send_cmd(struct st_hba *hba, struct req_msg *req,
> u16 tag)
>   readl(hba->mmio_base + YH2I_REQ); /* flush */
>  }
>
> +static void return_abnormal_state(struct st_hba *hba, int status)
> +{
> + struct st_ccb *ccb;
> + unsigned long flags;
> + u16 tag;
> +
> + spin_lock_irqsave(hba->host->host_lock, flags);
> + for (tag = 0; tag < hba->host->can_queue; tag++) {
> + ccb = >ccb[tag];
> + if (ccb->req == NULL)
> + continue;
> + ccb->req = NULL;
> + if (ccb->cmd) {
> + scsi_dma_unmap(ccb->cmd);
> + ccb->cmd->result = status << 16;
> + ccb->cmd->scsi_done(ccb->cmd);
> + ccb->cmd = NULL;
> + }
> + }
> + spin_unlock_irqrestore(hba->host->host_lock, flags);
> +}
>  static int
>  stex_slave_config(struct scsi_device *sdev)
>  {
> @@ -567,8 +590,12 @@ stex_queuecommand_lck(struct scsi_cmnd *cmd, void
> (*done)(struct scsi_cmnd *))
>   id = cmd->device->id;
>   lun = cmd->device->lun;
>   hba = (struct st_hba *) >hostdata[0];
> -
> - if (unlikely(hba->mu_status == MU_STATE_RESETTING))
> + if (hba->mu_status == MU_STATE_NOCONNECT) {
> + cmd->result = DID_NO_CONNECT;
> + done(cmd);
> + return 0;
> + }
> + if (unlikely(hba->mu_status != MU_STATE_STARTED))
>   return SCSI_MLQUEUE_HOST_BUSY;
>
>   switch (cmd->cmnd[0]) {
> @@ -1267,10 +1294,8 @@ static void stex_ss_reset(struct st_hba *hba)
>
>  static int stex_do_reset(struct st_hba *hba)
>  {
> - struct st_ccb *ccb;
>   unsigned long flags;
>   unsigned int mu_status = MU_STATE_RESETTING;
> - u16 tag;
>
>   spin_lock_irqsave(hba->host->host_lock, flags);
>   if (hba->mu_status == MU_STATE_STARTING) {
> @@ -1304,20 +1329,8 @@ static int stex_do_reset(struct st_hba *hba)
>   else if (hba->cardtype == st_yel)
>   stex_ss_reset(hba);
>
> - spin_lock_irqsave(hba->host->host_lock, flags);
> - for (tag = 0; tag < hba->host->can_queue; tag++) {
> - ccb = >ccb[tag];
> - if (ccb->req == NULL)
> - continue;
> - ccb->req = NULL;
> - if (ccb->cmd) {
> - scsi_dma_unmap(ccb->cmd);
> - ccb->cmd->result = DID_RESET << 16;
> - ccb->cmd->scsi_done(ccb->cmd);
> - ccb->cmd = NULL;
> - }
> - }
> - spin_unlock_irqrestore(hba->host->host_lock, flags);
> +
> + return_abnormal_state(hba, DID_RESET);
>
>   if (stex_handshake(hba) == 0)
>   return 0;
> @@ -1786,9 +1799,11 @@ static void stex_remove(struct pci_dev *pdev)
>  {
>   struct st_hba *hba = pci_get_drvdata(pdev);
>
> + hba->mu_status = MU_STATE_NOCONNECT;
> + return_abnormal_state(hba, DID_NO_CONNECT);
>   scsi_remove_host(hba->host);
>
> - stex_hba_stop(hba);
> + scsi_block_requests(hba->host);
>
>   stex_hba_free(hba);

Looks OK to me, so
Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix 

Re: [v2 PATCH 1/3] scsi:stex.c Support to Pegasus series.

2015-09-03 Thread Johannes Thumshirn
Charles Chiou  writes:

> From 9d7973dfa05a7785d0eb1e9bcfb0fb6d2c493209 Mon Sep 17 00:00:00 2001
> From: Charles 
> Date: Wed, 2 Sep 2015 20:41:56 +0800
> Subject: [PATCH 1/3] scsi:stex.c Support to Pegasus series.
>
> Pegasus is a high performace hardware RAID solution designed to unleash
> the raw power of Thunderbolt technology.
>
> 1. Add code to distinct SuperTrack and Pegasus series by sub device ID.
>It should support backward compatibility.
>
> 2. Change the driver version.
>
> V2: Remove blank lines
>
> Signed-off-by: Charles Chiou 
> ---
>  drivers/scsi/stex.c | 32 ++--
>  1 file changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
> index 98a62bc..0c93f1f 100644
> --- a/drivers/scsi/stex.c
> +++ b/drivers/scsi/stex.c
> @@ -1,7 +1,7 @@
>  /*
>   * SuperTrak EX Series Storage Controller driver for Linux
>   *
> - *   Copyright (C) 2005-2009 Promise Technology Inc.
> + *   Copyright (C) 2005-2015 Promise Technology Inc.
>   *
>   *   This program is free software; you can redistribute it and/or
>   *   modify it under the terms of the GNU General Public License
> @@ -37,11 +37,11 @@
>  #include 
>
>  #define DRV_NAME "stex"
> -#define ST_DRIVER_VERSION "4.6..4"
> -#define ST_VER_MAJOR 4
> -#define ST_VER_MINOR 6
> -#define ST_OEM   0
> -#define ST_BUILD_VER 4
> +#define ST_DRIVER_VERSION"5.00..01"
> +#define ST_VER_MAJOR 5
> +#define ST_VER_MINOR 00
> +#define ST_OEM   
> +#define ST_BUILD_VER 01
>
>  enum {
>   /* MU register offset */
> @@ -327,6 +327,7 @@ struct st_hba {
>   u16 rq_count;
>   u16 rq_size;
>   u16 sts_count;
> + u8  supports_pm;
>  };
>
>  struct st_card_info {
> @@ -1568,6 +1569,25 @@ static int stex_probe(struct pci_dev *pdev, const 
> struct
> pci_device_id *id)
>
>   hba->cardtype = (unsigned int) id->driver_data;
>   ci = _card_info[hba->cardtype];
> + switch (id->subdevice) {
> + case 0x4221:
> + case 0x4222:
> + case 0x4223:
> + case 0x4224:
> + case 0x4225:
> + case 0x4226:
> + case 0x4227:
> + case 0x4261:
> + case 0x4262:
> + case 0x4263:
> + case 0x4264:
> + case 0x4265:
> + break;
> + default:
> + if (hba->cardtype == st_yel)
> + hba->supports_pm = 1;
> + }
> +
>   sts_offset = scratch_offset = (ci->rq_count+1) * ci->rq_size;
>   if (hba->cardtype == st_yel)
>   sts_offset += (ci->sts_count+1) * sizeof(u32);

I somehow find that switch() above awkward to read, but if no-one else
objects, who am I to do.

Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
--
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] bfa: Fix incorrect de-reference of pointer

2015-09-03 Thread Ewan Milne
On Thu, 2015-08-13 at 06:41 -0400, anil.gurumur...@qlogic.com wrote:
> From: Anil Gurumurthy 
> 
> Signed-off-by: Anil Gurumurthy 
> Tested-by: Sudarsana Kalluru 
> ---
>  drivers/scsi/bfa/bfa_ioc.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
> index 4e71044..98f7e8c 100644
> --- a/drivers/scsi/bfa/bfa_ioc.c
> +++ b/drivers/scsi/bfa/bfa_ioc.c
> @@ -3878,7 +3878,7 @@ bfa_sfp_show_comp(struct bfa_sfp_s *sfp, struct 
> bfi_mbmsg_s *msg)
>   bfa_trc(sfp, sfp->data_valid);
>   if (sfp->data_valid) {
>   u32 size = sizeof(struct sfp_mem_s);
> - u8 *des = (u8 *) &(sfp->sfpmem);
> + u8 *des = (u8 *)(sfp->sfpmem);
>   memcpy(des, sfp->dbuf_kva, size);
>   }
>   /*

Reviewed-by: Ewan D. Milne 


--
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] bfa: Fix indentation

2015-09-03 Thread Ewan Milne
On Thu, 2015-08-13 at 06:41 -0400, anil.gurumur...@qlogic.com wrote:
> From: Anil Gurumurthy 
> 
> Signed-off-by: Anil Gurumurthy 
> Tested-by : Sudarasana Kalluru 
> ---
>  drivers/scsi/bfa/bfa_ioc.c |   22 +++---
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
> index 315d6d6..4e71044 100644
> --- a/drivers/scsi/bfa/bfa_ioc.c
> +++ b/drivers/scsi/bfa/bfa_ioc.c
> @@ -3665,19 +3665,19 @@ bfa_cb_sfp_state_query(struct bfa_sfp_s *sfp)
>   if (sfp->state_query_cbfn)
>   sfp->state_query_cbfn(sfp->state_query_cbarg,
>   sfp->status);
> - sfp->media = NULL;
> - }
> + sfp->media = NULL;
> + }
>  
> - if (sfp->portspeed) {
> - sfp->status = bfa_sfp_speed_valid(sfp, sfp->portspeed);
> - if (sfp->state_query_cbfn)
> - sfp->state_query_cbfn(sfp->state_query_cbarg,
> - sfp->status);
> - sfp->portspeed = BFA_PORT_SPEED_UNKNOWN;
> - }
> + if (sfp->portspeed) {
> + sfp->status = bfa_sfp_speed_valid(sfp, sfp->portspeed);
> + if (sfp->state_query_cbfn)
> + sfp->state_query_cbfn(sfp->state_query_cbarg,
> + sfp->status);
> + sfp->portspeed = BFA_PORT_SPEED_UNKNOWN;
> + }
>  
> - sfp->state_query_lock = 0;
> - sfp->state_query_cbfn = NULL;
> + sfp->state_query_lock = 0;
> + sfp->state_query_cbfn = NULL;
>  }
>  
>  /*

Reviewed-by: Ewan D. Milne 


--
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: introduce short_inquiry flag for broken host adapters

2015-09-03 Thread Vitaly Kuznetsov
Some host adapters (e.g. Hyper-V storvsc) are known for not respecting the
SPC-2/3/4 requirement for 'INQUIRY data (see table ...) shall contain at
least 36 bytes'. As a result we get tons on 'scsi 0:7:1:1: scsi scan:
INQUIRY result too short (5), using 36' messages on console. This can be
problematic for slow consoles. Introduce short_inquiry host template flag
to avoid printing error messages for such adapters.

Signed-off-by: Vitaly Kuznetsov 
---
Changes since v1:
- This is a successor of previously sent "scsi_scan: move 'INQUIRY result
  too short' message to debug level" patch. Instead of moving the message
  to debug level for all adapters introduce a special 'short_inquiry' flag
  for host template [inspired by James Bottomley].
---
 drivers/scsi/scsi_scan.c   | 7 ---
 drivers/scsi/storvsc_drv.c | 1 +
 include/scsi/scsi_host.h   | 6 ++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index f9f3f82..f1d00a0 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -701,9 +701,10 @@ static int scsi_probe_lun(struct scsi_device *sdev, 
unsigned char *inq_result,
 * strings.
 */
if (sdev->inquiry_len < 36) {
-   sdev_printk(KERN_INFO, sdev,
-   "scsi scan: INQUIRY result too short (%d),"
-   " using 36\n", sdev->inquiry_len);
+   if (!sdev->host->hostt->short_inquiry)
+   sdev_printk(KERN_INFO, sdev,
+   "scsi scan: INQUIRY result too short (%d),"
+   " using 36\n", sdev->inquiry_len);
sdev->inquiry_len = 36;
}
 
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 3c6584f..f3b4d0f 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1711,6 +1711,7 @@ static struct scsi_host_template scsi_driver = {
/* Make sure we dont get a sg segment crosses a page boundary */
.dma_boundary = PAGE_SIZE-1,
.no_write_same =1,
+   .short_inquiry =1,
 };
 
 enum {
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index e113c75..7b022af 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -454,6 +454,12 @@ struct scsi_host_template {
unsigned no_async_abort:1;
 
/*
+* True if this host adapter returns short (<36 bytes) responses to
+* some INQUIRY requests.
+*/
+   unsigned short_inquiry:1;
+
+   /*
 * Countdown for host blocking with no commands outstanding.
 */
unsigned int max_host_blocked;
-- 
2.4.3

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


[PATCH RESEND] libiscsi: Fix iscsi_check_transport_timeouts possible infinite loop

2015-09-03 Thread Sagi Grimberg
From: Ariel Nahum 

Connection last_ping is not being updated when iscsi_send_nopout fails.
Not updating the last_ping will cause firing a timer to a past time
(last_ping + ping_tmo < current_time) which triggers an infinite loop of
iscsi_check_transport_timeouts() and hogs the cpu.

Fix this issue by checking the return value of iscsi_send_nopout.
If it fails set the next_timeout to one second later.

Signed-off-by: Ariel Nahum 
Signed-off-by: Sagi Grimberg 
Reviewed-by: Mike Christie 
---
 drivers/scsi/libiscsi.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 8053f24..29c02b8 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -979,13 +979,13 @@ static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr)
wake_up(>ehwait);
 }
 
-static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin 
*rhdr)
+static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
 {
 struct iscsi_nopout hdr;
struct iscsi_task *task;
 
if (!rhdr && conn->ping_task)
-   return;
+   return -EINVAL;
 
memset(, 0, sizeof(struct iscsi_nopout));
hdr.opcode = ISCSI_OP_NOOP_OUT | ISCSI_OP_IMMEDIATE;
@@ -999,13 +999,16 @@ static void iscsi_send_nopout(struct iscsi_conn *conn, 
struct iscsi_nopin *rhdr)
hdr.ttt = RESERVED_ITT;
 
task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *), NULL, 0);
-   if (!task)
+   if (!task) {
iscsi_conn_printk(KERN_ERR, conn, "Could not send nopout\n");
-   else if (!rhdr) {
+   return -EIO;
+   } else if (!rhdr) {
/* only track our nops */
conn->ping_task = task;
conn->last_ping = jiffies;
}
+
+   return 0;
 }
 
 static int iscsi_nop_out_rsp(struct iscsi_task *task,
@@ -2095,8 +2098,10 @@ static void iscsi_check_transport_timeouts(unsigned long 
data)
if (time_before_eq(last_recv + recv_timeout, jiffies)) {
/* send a ping to try to provoke some traffic */
ISCSI_DBG_CONN(conn, "Sending nopout as ping\n");
-   iscsi_send_nopout(conn, NULL);
-   next_timeout = conn->last_ping + (conn->ping_timeout * HZ);
+   if (iscsi_send_nopout(conn, NULL))
+   next_timeout = jiffies + (1 * HZ);
+   else
+   next_timeout = conn->last_ping + (conn->ping_timeout * 
HZ);
} else
next_timeout = last_recv + recv_timeout;
 
-- 
1.8.4.3

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


Re: [PATCHv3] Update scsi host to use ida for host number

2015-09-03 Thread Lee Duncan
On 09/01/2015 11:48 PM, Christoph Hellwig wrote:
> On Tue, Sep 01, 2015 at 05:03:28PM -0700, Lee Duncan wrote:
>> +static int host_get_index(int *index)
>> +{
>> +int error = -ENOMEM;
>> +
>> +do {
>> +if (!ida_pre_get(_index_ida, GFP_KERNEL))
>> +break;
>> +spin_lock(_index_lock);
>> +error = ida_get_new(_index_ida, index);
>> +spin_unlock(_index_lock);
>> +} while (error == -EAGAIN);
>> +
>> +return error;
>> +}
>> +
>> +static inline void host_put_index(int index)
>> +{
>> +spin_lock(_index_lock);
>> +ida_remove(_index_ida, index);
>> +spin_unlock(_index_lock);
>> +}
> 
> I really hate how this pattern (and the equivalent for IDA) are
> spread all over.  Any chance to have some simple_ida/simple_idr helpers
> instead of duplicating it again an again.
> 
> Besides that why aren't we using and idr here and use it for host lookup
> as well?
> .
> 

Good question. My original goal was just to fix the host_no wrap-around
problem, but I agree, the hosts.c module could benefit from using idr,
making scsi_host_lookup(hostnum) much simpler, and possible faster.

I will submit another patch.

This means I won't need the sequence any longer that you wanted made
into helper functions, though I'd still be glad to create the helper
functions and convert some of the ida users, if you wish.
-- 
Lee Duncan

--
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_ioctl: support persistent reserve commands through ioctl for non-root user.

2015-09-03 Thread Lee Duncan
On 08/01/2015 02:51 AM, jiang.bi...@zte.com.cn wrote:
> scsi_ioctl: support persistent reserve commands through ioctl for
> non-root user.
> 
> Scsi persistent reserve commands need to be used for non-root user in
> many scenarios.
> EPERM error will be returned by sg_io() when PERSISTENT_RESERVE_OUT
> or PERSISTENT_RESERVE_IN command is sent through ioctl() for
> non-root user.
> Add PERSISTENT_RESERVE_OUT and PERSISTENT_RESERVE_IN into
> blk_default_cmd_filter in blk_set_cmd_filter_defaults() to support 
> persistent reserve commands for non-root user.
> 
> Signed-off-by: Jiang Biao 
> Signed-off-by: Li Ping 
> Reviewed-by: Liu Jianjun 
> 
> diff -urpN block/scsi_ioctl.c block_new/scsi_ioctl.c
> --- block/scsi_ioctl.c  2015-08-01 17:07:47.0 +0800
> +++ block_new/scsi_ioctl.c  2015-08-01 17:09:56.0 +0800
> @@ -202,6 +202,9 @@ static void blk_set_cmd_filter_defaults(
> __set_bit(GPCMD_LOAD_UNLOAD, filter->write_ok);
> __set_bit(GPCMD_SET_STREAMING, filter->write_ok);
> __set_bit(GPCMD_SET_READ_AHEAD, filter->write_ok);
> +   /* Persistent reserve command*/
> +   __set_bit(PERSISTENT_RESERVE_IN, filter->read_ok);
> +   __set_bit(PERSISTENT_RESERVE_OUT, filter->write_ok);
>  }
> 
>  int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm)
> N�r��y���b�X��ǧv�^�)޺{.n�+{���"�{ay�ʇڙ�,j��f���h���z��w���
> ���j:+v���w�j�mzZ+�ݢj"��!tml=
> 

I disagree that it is a good idea to give non-root users permanent
access to the reservation commands. This can be used to coopt a disc,
including the root disc.

-- 
Lee Duncan

--
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 RESEND] scsi: Fix sense information setting in fixed sized format

2015-09-03 Thread Ewan Milne
On Thu, 2015-09-03 at 19:49 +0300, Sagi Grimberg wrote:
> In fixed size sense format the information field is a four byte
> field.
> 
> Signed-off-by: Sagi Grimberg 
> Reviewed-by: Martin K. Petersen 
> Reviewed-by: Bart Van Assche 
> Reviewed-by: Christoph Hellwig 
> ---
>  drivers/scsi/scsi_common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_common.c b/drivers/scsi/scsi_common.c
> index 41432c10dda2..8cfb7eeb5bbc 100644
> --- a/drivers/scsi/scsi_common.c
> +++ b/drivers/scsi/scsi_common.c
> @@ -270,7 +270,7 @@ void scsi_set_sense_information(u8 *buf, u64 info)
>   put_unaligned_be64(info, [4]);
>   } else if ((buf[0] & 0x7f) == 0x70) {
>   buf[0] |= 0x80;
> - put_unaligned_be64(info, [3]);
> + put_unaligned_be32(info, [3]);
>   }
>  }
>  EXPORT_SYMBOL(scsi_set_sense_information);

Looks correct per SPC-4 4.5.3

And you did post a patch to target for the case where the sector
did not fit in 32 bits, which requires descriptor format sense, so...

Reviewed-by: Ewan D. Milne 

--
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 RESEND] scsi: Fix sense information setting in fixed sized format

2015-09-03 Thread Sagi Grimberg
In fixed size sense format the information field is a four byte
field.

Signed-off-by: Sagi Grimberg 
Reviewed-by: Martin K. Petersen 
Reviewed-by: Bart Van Assche 
Reviewed-by: Christoph Hellwig 
---
 drivers/scsi/scsi_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_common.c b/drivers/scsi/scsi_common.c
index 41432c10dda2..8cfb7eeb5bbc 100644
--- a/drivers/scsi/scsi_common.c
+++ b/drivers/scsi/scsi_common.c
@@ -270,7 +270,7 @@ void scsi_set_sense_information(u8 *buf, u64 info)
put_unaligned_be64(info, [4]);
} else if ((buf[0] & 0x7f) == 0x70) {
buf[0] |= 0x80;
-   put_unaligned_be64(info, [3]);
+   put_unaligned_be32(info, [3]);
}
 }
 EXPORT_SYMBOL(scsi_set_sense_information);
-- 
1.8.4.3

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


Re: [PATCH 1/3] scsi:stex.c Support to Pegasus series.

2015-09-03 Thread Johannes Thumshirn
Charles Chiou  writes:

> From 63f806abc43237285a918f559ce6e5e410d90d85 Mon Sep 17 00:00:00 2001
> From: Charles 
> Date: Wed, 2 Sep 2015 20:41:56 +0800
> Subject: [PATCH 1/3] scsi:stex.c Support to Pegasus series.
>
> Pegasus is a high performace hardware RAID solution designed to unleash
> the raw power of Thunderbolt technology.
>
> 1. Add code to distinct SuperTrack and Pegasus series by sub device ID.
>It should support backward compatibility.
>
> 2. Change the driver version.
>
> Signed-off-by: Charles Chiou 
> ---
>  drivers/scsi/stex.c | 35 +--
>  1 file changed, 29 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
> index 98a62bc..657e3ae 100644
> --- a/drivers/scsi/stex.c
> +++ b/drivers/scsi/stex.c
> @@ -1,7 +1,7 @@
>  /*
>   * SuperTrak EX Series Storage Controller driver for Linux
>   *
> - *   Copyright (C) 2005-2009 Promise Technology Inc.
> + *   Copyright (C) 2005-2015 Promise Technology Inc.
>   *
>   *   This program is free software; you can redistribute it and/or
>   *   modify it under the terms of the GNU General Public License
> @@ -37,11 +37,11 @@
>  #include 
>
>  #define DRV_NAME "stex"
> -#define ST_DRIVER_VERSION "4.6..4"
> -#define ST_VER_MAJOR 4
> -#define ST_VER_MINOR 6
> -#define ST_OEM   0
> -#define ST_BUILD_VER 4
> +#define ST_DRIVER_VERSION"5.00..01"
> +#define ST_VER_MAJOR 5
> +#define ST_VER_MINOR 00
> +#define ST_OEM   
> +#define ST_BUILD_VER 01
>
>  enum {
>   /* MU register offset */
> @@ -327,6 +327,7 @@ struct st_hba {
>   u16 rq_count;
>   u16 rq_size;
>   u16 sts_count;
> + u8  supports_pm;
>  };
>
>  struct st_card_info {
> @@ -1566,8 +1567,30 @@ static int stex_probe(struct pci_dev *pdev, const 
> struct
> pci_device_id *id)
>   goto out_iounmap;
>   }
>
> +
> +
> +

Please no quad blank lines, one's enough :-(

>   hba->cardtype = (unsigned int) id->driver_data;
>   ci = _card_info[hba->cardtype];
> + switch (id->subdevice) {
> + case 0x4221:
> + case 0x4222:
> + case 0x4223:
> + case 0x4224:
> + case 0x4225:
> + case 0x4226:
> + case 0x4227:
> + case 0x4261:
> + case 0x4262:
> + case 0x4263:
> + case 0x4264:
> + case 0x4265:
> + break;
> + default:
> + if (hba->cardtype == st_yel)
> + hba->supports_pm = 1;
> + }
> +
>   sts_offset = scratch_offset = (ci->rq_count+1) * ci->rq_size;
>   if (hba->cardtype == st_yel)
>   sts_offset += (ci->sts_count+1) * sizeof(u32);

-- 
Johannes Thumshirn   Storage
jthumsh...@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
--
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 3/3] scsi:stex.c Add S3/S4 support

2015-09-03 Thread Johannes Thumshirn
Charles Chiou  writes:

> From 7d98f8c500de452277e2700a950b23bf4685ed64 Mon Sep 17 00:00:00 2001
> From: Charles 
> Date: Wed, 2 Sep 2015 20:54:45 +0800
> Subject: [PATCH 3/3] scsi:stex.c Add S3/S4 support
>
> Add S3/S4 support, add .suspend and .resume function in pci_driver.
> In .suspend handler, driver send S3/S4 signal to the device.
>
> Signed-off-by: Charles Chiou 
> ---
>  drivers/scsi/stex.c | 65 
> ++---
>  1 file changed, 62 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
> index 6578f3d..45482d5 100644
> --- a/drivers/scsi/stex.c
> +++ b/drivers/scsi/stex.c
> @@ -166,6 +166,13 @@ enum {
>
>   ST_ADDITIONAL_MEM   = 0x20,
>   ST_ADDITIONAL_MEM_MIN   = 0x8,
> + PMIC_SHUTDOWN   = 0x0D,
> + PMIC_REUMSE = 0x10,
> + ST_IGNORED  = -1,
> + ST_S3   = 3,
> + ST_S4   = 4,
> + ST_S5   = 5,
> + ST_S6   = 6,
>  };
>
>  struct st_sgitem {
> @@ -360,6 +367,8 @@ static const char console_inq_page[] =
>   0x0C,0x20,0x20,0x20,0x20,0x20,0x20,0x20
>  };
>
> +
> +

Same as with 1/1

>  MODULE_AUTHOR("Ed Lin");
>  MODULE_DESCRIPTION("Promise Technology SuperTrak EX Controllers");
>  MODULE_LICENSE("GPL");
> @@ -1359,6 +1368,9 @@ static void stex_reset_work(struct work_struct *work)
>   stex_do_reset(hba);
>  }
>
> +
> +
> +

Again

>  static int stex_biosparam(struct scsi_device *sdev,
>   struct block_device *bdev, sector_t capacity, int geom[])
>  {
> @@ -1736,7 +1748,7 @@ out_disable:
>   return err;
>  }
>
> -static void stex_hba_stop(struct st_hba *hba)
> +static void stex_hba_stop(struct st_hba *hba, int st_sleep_mic)
>  {
>   struct req_msg *req;
>   struct st_msg_header *msg_h;
> @@ -1752,11 +1764,18 @@ static void stex_hba_stop(struct st_hba *hba)
>   } else
>   memset(req, 0, hba->rq_size);
>
> - if (hba->cardtype == st_yosemite || hba->cardtype == st_yel) {
> + if ((hba->cardtype == st_yosemite || hba->cardtype == st_yel)
> + && st_sleep_mic == ST_IGNORED) {
>   req->cdb[0] = MGT_CMD;
>   req->cdb[1] = MGT_CMD_SIGNATURE;
>   req->cdb[2] = CTLR_CONFIG_CMD;
>   req->cdb[3] = CTLR_SHUTDOWN;
> + } else if (hba->cardtype == st_yel && st_sleep_mic != ST_IGNORED) {
> + req->cdb[0] = MGT_CMD;
> + req->cdb[1] = MGT_CMD_SIGNATURE;
> + req->cdb[2] = CTLR_CONFIG_CMD;
> + req->cdb[3] = PMIC_SHUTDOWN;
> + req->cdb[4] = st_sleep_mic;
>   } else {
>   req->cdb[0] = CONTROLLER_CMD;
>   req->cdb[1] = CTLR_POWER_STATE_CHANGE;
> @@ -1776,10 +1795,12 @@ static void stex_hba_stop(struct st_hba *hba)
>   while (hba->ccb[tag].req_type & PASSTHRU_REQ_TYPE) {
>   if (time_after(jiffies, before + ST_INTERNAL_TIMEOUT * HZ)) {
>   hba->ccb[tag].req_type = 0;
> + hba->mu_status = MU_STATE_STOP;
>   return;
>   }
>   msleep(1);
>   }
> + hba->mu_status = MU_STATE_STOP;
>  }
>
>  static void stex_hba_free(struct st_hba *hba)
> @@ -1819,9 +1840,45 @@ static void stex_shutdown(struct pci_dev *pdev)
>  {
>   struct st_hba *hba = pci_get_drvdata(pdev);
>
> - stex_hba_stop(hba);
> + if (hba->supports_pm == 0)
> + stex_hba_stop(hba, ST_IGNORED);
> + else
> + stex_hba_stop(hba, ST_S5);
> +}
> +
> +static int stex_choice_sleep_mic(pm_message_t state)
> +{
> + switch (state.event) {
> + case PM_EVENT_SUSPEND:
> + return ST_S3;
> + case PM_EVENT_FREEZE:
> + case PM_EVENT_HIBERNATE:
> + return ST_S4;
> + default:
> + return ST_S4;
> + }
> +}
> +
> +static int stex_suspend(struct pci_dev *pdev, pm_message_t state)
> +{
> + struct st_hba *hba = pci_get_drvdata(pdev);
> +
> + if (hba->cardtype == st_yel && hba->supports_pm == 1)
> + stex_hba_stop(hba, stex_choice_sleep_mic(state));
> + else
> + stex_hba_stop(hba, ST_IGNORED);
> + return 0;
>  }
>
> +
> +static int stex_resume(struct pci_dev *pdev)
> +{
> + struct st_hba *hba = pci_get_drvdata(pdev);
> +
> + hba->mu_status = MU_STATE_STARTING;
> + stex_handshake(hba);
> + return 0;
> +}
>  MODULE_DEVICE_TABLE(pci, stex_pci_tbl);
>
>  static struct pci_driver stex_pci_driver = {
> @@ -1830,6 +1887,8 @@ static struct pci_driver stex_pci_driver = {
>   .probe  = stex_probe,
>   .remove = stex_remove,
>   .shutdown   = 

[PATCH] target: Attach EXTENDED_COPY local I/O descriptors to xcopy_pt_sess

2015-09-03 Thread Nicholas A. Bellinger
From: Nicholas Bellinger 

This patch is a >= v4.1 regression bug-fix where control CDB
emulation logic in commit 38b57f82 now expects a se_cmd->se_sess
pointer to exist when determining T10-PI support is to be exposed
for initiator host ports.

To address this bug, go ahead and add locally generated se_cmd
descriptors for copy-offload block-copy to it's own stand-alone
se_session nexus, while the parent EXTENDED_COPY se_cmd descriptor
remains associated with it's originating se_cmd->se_sess nexus.

Note a valid se_cmd->se_sess is also required for future support
of WRITE_INSERT and READ_STRIP software emulation when submitting
backend I/O to se_device that exposes T10-PI suport.

Reported-by: Alex Gorbachev 
Cc: Alex Gorbachev 
Cc: "Martin K. Petersen" 
Cc: Hannes Reinecke 
Cc: Christoph Hellwig 
Cc: Doug Gilbert 
Cc:  # v4.1+
Signed-off-by: Nicholas Bellinger 
---
 drivers/target/target_core_xcopy.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_xcopy.c 
b/drivers/target/target_core_xcopy.c
index 4515f52..47fe94e 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -450,6 +450,8 @@ int target_xcopy_setup_pt(void)
memset(_pt_sess, 0, sizeof(struct se_session));
INIT_LIST_HEAD(_pt_sess.sess_list);
INIT_LIST_HEAD(_pt_sess.sess_acl_list);
+   INIT_LIST_HEAD(_pt_sess.sess_cmd_list);
+   spin_lock_init(_pt_sess.sess_cmd_lock);
 
xcopy_pt_nacl.se_tpg = _pt_tpg;
xcopy_pt_nacl.nacl_sess = _pt_sess;
@@ -644,7 +646,7 @@ static int target_xcopy_read_source(
pr_debug("XCOPY: Built READ_16: LBA: %llu Sectors: %u Length: %u\n",
(unsigned long long)src_lba, src_sectors, length);
 
-   transport_init_se_cmd(se_cmd, _pt_tfo, NULL, length,
+   transport_init_se_cmd(se_cmd, _pt_tfo, _pt_sess, length,
  DMA_FROM_DEVICE, 0, _cmd->sense_buffer[0]);
xop->src_pt_cmd = xpt_cmd;
 
@@ -704,7 +706,7 @@ static int target_xcopy_write_destination(
pr_debug("XCOPY: Built WRITE_16: LBA: %llu Sectors: %u Length: %u\n",
(unsigned long long)dst_lba, dst_sectors, length);
 
-   transport_init_se_cmd(se_cmd, _pt_tfo, NULL, length,
+   transport_init_se_cmd(se_cmd, _pt_tfo, _pt_sess, length,
  DMA_TO_DEVICE, 0, _cmd->sense_buffer[0]);
xop->dst_pt_cmd = xpt_cmd;
 
-- 
1.7.10.4

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


Re: [PATCH 06/23] scsi_dh_alua: fixup description of stpg_endio()

2015-09-03 Thread Martin K. Petersen
> "Hannes" == Hannes Reinecke  writes:

Hannes> Fixup copy-and-paste error in the description of stpg_endio().

Reviewed-by: Martin K. Petersen 

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


Re: [PATCH 07/23] scsi: remove scsi_show_sense_hdr()

2015-09-03 Thread Martin K. Petersen
> "Hannes" == Hannes Reinecke  writes:

Hannes> Last caller is gone, so remove it.

Reviewed-by: Martin K. Petersen 

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


Re: [PATCH 08/23] scsi_dh_alua: use flag for RTPG extended header

2015-09-03 Thread Martin K. Petersen
> "Hannes" == Hannes Reinecke  writes:

Hannes> We should be using a flag when RTPG extended header is not
Hannes> supported, that saves us sending RTPG twice for older arrays.

Reviewed-by: Martin K. Petersen 

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


Re: [PATCH 09/23] scsi_dh_alua: use unaligned access macros

2015-09-03 Thread Martin K. Petersen
> "Hannes" == Hannes Reinecke  writes:

Hannes> Use 'get_unaligned_XX' and 'put_unaligned_XX' instead of
Hannes> open-coding it.

Reviewed-by: Martin K. Petersen 

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


Re: [PATCH 10/23] scsi_dh_alua: Pass buffer as function argument

2015-09-03 Thread Martin K. Petersen
> "Hannes" == Hannes Reinecke  writes:

Hannes> Pass in the buffer as a function argument for submit_rtpg().

Reviewed-by: Martin K. Petersen 

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


Re: [PATCH v3 6/10] megaraid_sas : Chip reset if driver fail to bring ioc ready

2015-09-03 Thread Martin K. Petersen
> "Sumit" == sumit saxena  writes:

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

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

Reviewed-by: Martin K. Petersen 

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


[v2 PATCH 1/3] scsi:stex.c Support to Pegasus series.

2015-09-03 Thread Charles Chiou

From 9d7973dfa05a7785d0eb1e9bcfb0fb6d2c493209 Mon Sep 17 00:00:00 2001
From: Charles 
Date: Wed, 2 Sep 2015 20:41:56 +0800
Subject: [PATCH 1/3] scsi:stex.c Support to Pegasus series.

Pegasus is a high performace hardware RAID solution designed to unleash
the raw power of Thunderbolt technology.

1. Add code to distinct SuperTrack and Pegasus series by sub device ID.
   It should support backward compatibility.

2. Change the driver version.

V2: Remove blank lines

Signed-off-by: Charles Chiou 
---
 drivers/scsi/stex.c | 32 ++--
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 98a62bc..0c93f1f 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -1,7 +1,7 @@
 /*
  * SuperTrak EX Series Storage Controller driver for Linux
  *
- * Copyright (C) 2005-2009 Promise Technology Inc.
+ * Copyright (C) 2005-2015 Promise Technology Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -37,11 +37,11 @@
 #include 

 #define DRV_NAME "stex"
-#define ST_DRIVER_VERSION "4.6..4"
-#define ST_VER_MAJOR   4
-#define ST_VER_MINOR   6
-#define ST_OEM 0
-#define ST_BUILD_VER   4
+#define ST_DRIVER_VERSION  "5.00..01"
+#define ST_VER_MAJOR   5
+#define ST_VER_MINOR   00
+#define ST_OEM 
+#define ST_BUILD_VER   01

 enum {
/* MU register offset */
@@ -327,6 +327,7 @@ struct st_hba {
u16 rq_count;
u16 rq_size;
u16 sts_count;
+   u8  supports_pm;
 };

 struct st_card_info {
@@ -1568,6 +1569,25 @@ static int stex_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)


hba->cardtype = (unsigned int) id->driver_data;
ci = _card_info[hba->cardtype];
+   switch (id->subdevice) {
+   case 0x4221:
+   case 0x4222:
+   case 0x4223:
+   case 0x4224:
+   case 0x4225:
+   case 0x4226:
+   case 0x4227:
+   case 0x4261:
+   case 0x4262:
+   case 0x4263:
+   case 0x4264:
+   case 0x4265:
+   break;
+   default:
+   if (hba->cardtype == st_yel)
+   hba->supports_pm = 1;
+   }
+
sts_offset = scratch_offset = (ci->rq_count+1) * ci->rq_size;
if (hba->cardtype == st_yel)
sts_offset += (ci->sts_count+1) * sizeof(u32);
--
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


[v2 PATCH 2/3] scsi:stex.c Add hotplug support

2015-09-03 Thread Charles Chiou

From 60e14c245c18cbe0300cfa244334e2850a52a381 Mon Sep 17 00:00:00 2001
From: Charles 
Date: Wed, 2 Sep 2015 20:48:55 +0800
Subject: [PATCH 2/3] scsi:stex.c Add hotplug support

1. Add hotplug support. Pegasus support surprise removal. To this end, I
   use return_abnormal_state function to return DID_NO_CONNECT for all
  commands which sent to driver.

2. Remove stex_hba_stop in stex_remove because we cannot send command to
   device after hotplug.

3. Add new device status:  MU_STATE_STOP, MU_STATE_NOCONNECT,
   MU_STATE_STOP. MU_STATE_STOP is currently not referenced.
   MU_STATE_NOCONNECT represent that device is plugged out from the host.

4. Use return_abnormal_function() to substitute part of code in 
stex_do_reset.


V2: N/A

Signed-off-by: Charles Chiou 
---
 drivers/scsi/stex.c | 53 
++---

 1 file changed, 34 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 0c93f1f..4ef0c80 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -83,6 +83,8 @@ enum {
MU_STATE_STARTED= 2,
MU_STATE_RESETTING  = 3,
MU_STATE_FAILED = 4,
+   MU_STATE_STOP   = 5,
+   MU_STATE_NOCONNECT  = 6,

MU_MAX_DELAY= 120,
MU_HANDSHAKE_SIGNATURE  = 0x5555,
@@ -544,6 +546,27 @@ stex_ss_send_cmd(struct st_hba *hba, struct req_msg 
*req, u16 tag)

readl(hba->mmio_base + YH2I_REQ); /* flush */
 }

+static void return_abnormal_state(struct st_hba *hba, int status)
+{
+   struct st_ccb *ccb;
+   unsigned long flags;
+   u16 tag;
+
+   spin_lock_irqsave(hba->host->host_lock, flags);
+   for (tag = 0; tag < hba->host->can_queue; tag++) {
+   ccb = >ccb[tag];
+   if (ccb->req == NULL)
+   continue;
+   ccb->req = NULL;
+   if (ccb->cmd) {
+   scsi_dma_unmap(ccb->cmd);
+   ccb->cmd->result = status << 16;
+   ccb->cmd->scsi_done(ccb->cmd);
+   ccb->cmd = NULL;
+   }
+   }
+   spin_unlock_irqrestore(hba->host->host_lock, flags);
+}
 static int
 stex_slave_config(struct scsi_device *sdev)
 {
@@ -567,8 +590,12 @@ stex_queuecommand_lck(struct scsi_cmnd *cmd, void 
(*done)(struct scsi_cmnd *))

id = cmd->device->id;
lun = cmd->device->lun;
hba = (struct st_hba *) >hostdata[0];
-
-   if (unlikely(hba->mu_status == MU_STATE_RESETTING))
+   if (hba->mu_status == MU_STATE_NOCONNECT) {
+   cmd->result = DID_NO_CONNECT;
+   done(cmd);
+   return 0;
+   }
+   if (unlikely(hba->mu_status != MU_STATE_STARTED))
return SCSI_MLQUEUE_HOST_BUSY;

switch (cmd->cmnd[0]) {
@@ -1267,10 +1294,8 @@ static void stex_ss_reset(struct st_hba *hba)

 static int stex_do_reset(struct st_hba *hba)
 {
-   struct st_ccb *ccb;
unsigned long flags;
unsigned int mu_status = MU_STATE_RESETTING;
-   u16 tag;

spin_lock_irqsave(hba->host->host_lock, flags);
if (hba->mu_status == MU_STATE_STARTING) {
@@ -1304,20 +1329,8 @@ static int stex_do_reset(struct st_hba *hba)
else if (hba->cardtype == st_yel)
stex_ss_reset(hba);

-   spin_lock_irqsave(hba->host->host_lock, flags);
-   for (tag = 0; tag < hba->host->can_queue; tag++) {
-   ccb = >ccb[tag];
-   if (ccb->req == NULL)
-   continue;
-   ccb->req = NULL;
-   if (ccb->cmd) {
-   scsi_dma_unmap(ccb->cmd);
-   ccb->cmd->result = DID_RESET << 16;
-   ccb->cmd->scsi_done(ccb->cmd);
-   ccb->cmd = NULL;
-   }
-   }
-   spin_unlock_irqrestore(hba->host->host_lock, flags);
+
+   return_abnormal_state(hba, DID_RESET);

if (stex_handshake(hba) == 0)
return 0;
@@ -1786,9 +1799,11 @@ static void stex_remove(struct pci_dev *pdev)
 {
struct st_hba *hba = pci_get_drvdata(pdev);

+   hba->mu_status = MU_STATE_NOCONNECT;
+   return_abnormal_state(hba, DID_NO_CONNECT);
scsi_remove_host(hba->host);

-   stex_hba_stop(hba);
+   scsi_block_requests(hba->host);

stex_hba_free(hba);

--
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 v3 9/10] megaraid_sas : Code refactor for use of requestorId

2015-09-03 Thread Martin K. Petersen
> "Sumit" == sumit saxena  writes:

Sumit> Some of the code changes was proposed by David Binderman Removed
Sumit> redudant check of requestorId. Redundant condition:
Sumit> instance.requestorId.  Check for plasma firmware 1.11 or new
Sumit> restructured to support only for specific device id

Reviewed-by: Martin K. Petersen 

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


Re: [PATCH 01/23] scsi_dh_alua: Disable ALUA handling for non-disk devices

2015-09-03 Thread Martin K. Petersen
> "Hannes" == Hannes Reinecke  writes:

Hannes> Non-disk devices might support ALUA, but the firmware
Hannes> implementation is untested and frequently broken.  As we're
Hannes> don't actually need it disable ALUA support for non-disk device
Hannes> for now.

Reviewed-by: Martin K. Petersen 

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


Re: [PATCH v3 10/10] megaraid_sas : Version upgrade

2015-09-03 Thread Martin K. Petersen
> "Sumit" == sumit saxena  writes:

Reviewed-by: Martin K. Petersen 

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


Re: [PATCH v3 8/10] megaraid_sas : Fix validHandles check in io path

2015-09-03 Thread Martin K. Petersen
> "Sumit" == sumit saxena  writes:

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

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

Reviewed-by: Martin K. Petersen 

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


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

2015-09-03 Thread Martin K. Petersen
> "Sumit" == sumit saxena  writes:

Sumit> Print firmware event in readable format. This will help user to
Sumit> track any critical firmware event without any application
Sumit> support.

Reviewed-by: Martin K. Petersen 

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


Re: [PATCH 02/23] scsi_dh_alua: Use vpd_pg83 information

2015-09-03 Thread Martin K. Petersen
> "Hannes" == Hannes Reinecke  writes:

Hannes> The SCSI device now has the VPD page 0x83 information attached,
Hannes> so there is no need to query it again.

Reviewed-by: Martin K. Petersen 

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


Re: [PATCH 03/23] scsi_dh_alua: improved logging

2015-09-03 Thread Martin K. Petersen
> "Hannes" == Hannes Reinecke  writes:

Hannes> Issue different logging messages if ALUA is not supported or the
Hannes> TPGS setting is invalid.

Reviewed-by: Martin K. Petersen 

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