Re: [PATCH v5 15/15] scsi: ufs-qcom: set PA_Local_TX_LCC_Enable before link startup

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> Some UFS devices (and may be host) have issues if LCC is
> enabled. So we are setting PA_Local_TX_LCC_Enable to 0
> before link startup which will make sure that both host
> and device TX LCC are disabled once link startup is
> completed.
> 
> This change also:
> - enables the device ref clock before changing to HS mode
>   and disables it if entered to PWM mode
> - adds printouts of testbus debug registers
> 
Please make that in two patches; these issues are unrelated and will
just confuse users if one ever need to dig through the git log.

Cheers,

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


Re: [PATCH v5 14/15] scsi: ufs: add device quirk delay before putting UFS rails in LPM

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> We put the UFS device in sleep state & UFS link in hibern8 state during
> runtime suspaned. After this we put all the UFS rails in low power
> modes immediately but it seems some devices may still draw more than
> sleep current from UFS rails (especially from VCCQ rail) atleast for
> 500us.
> To avoid this situation, this change adds 2ms delay before putting
> these UFS rails in LPM mode.
> 
> Reviewed-by: Gilad Broner 
> Signed-off-by: Subhash Jadavani 
> Signed-off-by: Yaniv Gardi 
> 
> ---
>  drivers/scsi/ufs/ufs_quirks.c |  4 
>  drivers/scsi/ufs/ufs_quirks.h | 11 ++-
>  drivers/scsi/ufs/ufshcd.c | 10 ++
>  3 files changed, 24 insertions(+), 1 deletion(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v5 13/15] scsi: ufs: fix leakage during link off state

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> Currently when we try to put the link in off/disabled state during
> suspend, it seems link is not being kept in low power mode.
> This patch fixes the issue by putting the link in hibern8 first
> (so device also puts the link in low power mode) and then stop the
> host controller.
> 
> Signed-off-by: Subhash Jadavani 
> Signed-off-by: Yaniv Gardi 
> 
> ---
>  drivers/scsi/ufs/ufshcd.c | 10 ++
>  1 file changed, 10 insertions(+)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v5 12/15] scsi: ufs: tune UniPro parameters to optimize hibern8 exit time

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> Optimal values of local UniPro parameters like PA_Hibern8Time &
> PA_TActivate can help reduce the hibern8 exit latency. If both host and
> device supports UniPro ver1.6 or later, these parameters will be
> automatically tuned during link startup itself. But if either host or
> device doesn't support UniPro ver 1.6 or later, we have to manually
> tune them. But to keep manual tuning logic simple, we will only do
> manual tuning if local unipro version doesn't support ver1.6 or later.
> 
> Signed-off-by: Subhash Jadavani 
> Signed-off-by: Yaniv Gardi 
> 
> ---
>  drivers/scsi/ufs/ufshcd.c | 118 
> ++
>  drivers/scsi/ufs/ufshcd.h |   1 +
>  drivers/scsi/ufs/ufshci.h |   2 +
>  drivers/scsi/ufs/unipro.h |  21 +
>  4 files changed, 142 insertions(+)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v5 11/15] scsi: ufs: handle non spec compliant bkops behaviour by device

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> We are seeing that some devices are raising the urgent bkops exception
> events even when BKOPS status doesn't indicate performace impacted or
> critical. Handle these device by determining their urgent bkops status
> at runtime.
> 
> Signed-off-by: Subhash Jadavani 
> Signed-off-by: Yaniv Gardi 
> 
> ---
>  drivers/scsi/ufs/ufshcd.c | 53 
> ---
>  drivers/scsi/ufs/ufshcd.h |  6 ++
>  2 files changed, 52 insertions(+), 7 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v5 10/15] scsi: ufs: add retry for query descriptors

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> Query commands have 100ms timeout and it may timeout if they are
> issued in parallel to ongoing read/write SCSI commands, this change
> adds the retry (max: 10) in case command timeouts.
> 
> Signed-off-by: Subhash Jadavani 
> Signed-off-by: Yaniv Gardi 
> 
> ---
>  drivers/scsi/ufs/ufshcd.c | 55 
> +++
>  1 file changed, 37 insertions(+), 18 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v5 09/15] scsi: ufs: add error recovery after DL NAC error

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> Some vendor's UFS device sends back to back NACs for the DL data frames
> causing the host controller to raise the DFES error status. Sometimes
> such UFS devices send back to back NAC without waiting for new
> retransmitted DL frame from the host and in such cases it might be
> possible the Host UniPro goes into bad state without raising the DFES
> error interrupt. If this happens then all the pending commands would
> timeout only after respective SW command (which is generally too
> large).
> 
> This change workarounds such device behaviour like this:
> - As soon as SW sees the DL NAC error, it would schedule the error
>   handler
> - Error handler would sleep for 50ms to see if there any fatal errors
>   raised by UFS controller.
>- If there are fatal errors then SW does normal error recovery.
>- If there are no fatal errors then SW sends the NOP command to
>  device to check if link is alive.
>- If NOP command times out, SW does normal error recovery
>- If NOP command succeed, skip the error handling.
> 
> If DL NAC error is seen multiple times with some vendor's UFS devices
> then enable this quirk to initiate quick error recovery and also
> silence related error logs to reduce spamming of kernel logs.
> 
> Signed-off-by: Subhash Jadavani 
> Signed-off-by: Yaniv Gardi 
> 
> ---
>  drivers/scsi/ufs/ufshcd.c | 93 
> +++
>  drivers/scsi/ufs/ufshci.h |  2 +
>  2 files changed, 95 insertions(+)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v5 08/15] scsi: ufs: make error handling bit faster

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> UFS driver's error handler forcefully tries to clear all the pending
> requests. For each pending request in the queue, it waits 1 sec for it
> to get cleared. If we have multiple requests in the queue then it's
> possible that we might end up waiting for those many seconds before
> resetting the host. But note that resetting host would any way clear
> all the pending requests from the hardware. Hence this change skips
> the forceful clear of the pending requests if we are anyway going to
> reset the host (for fatal errors).
> 
> Signed-off-by: Subhash Jadavani 
> Signed-off-by: Yaniv Gardi 
> 
> ---
>  drivers/scsi/ufs/ufshcd.c | 155 
> +-
>  1 file changed, 112 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 987cf27..dc096f1 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -133,9 +133,11 @@ enum {
>  /* UFSHCD UIC layer error flags */
>  enum {
>   UFSHCD_UIC_DL_PA_INIT_ERROR = (1 << 0), /* Data link layer error */
> - UFSHCD_UIC_NL_ERROR = (1 << 1), /* Network layer error */
> - UFSHCD_UIC_TL_ERROR = (1 << 2), /* Transport Layer error */
> - UFSHCD_UIC_DME_ERROR = (1 << 3), /* DME error */
> + UFSHCD_UIC_DL_NAC_RECEIVED_ERROR = (1 << 1), /* Data link layer error */
> + UFSHCD_UIC_DL_TCx_REPLAY_ERROR = (1 << 2), /* Data link layer error */
> + UFSHCD_UIC_NL_ERROR = (1 << 3), /* Network layer error */
> + UFSHCD_UIC_TL_ERROR = (1 << 4), /* Transport Layer error */
> + UFSHCD_UIC_DME_ERROR = (1 << 5), /* DME error */
>  };
>  
>  /* Interrupt configuration options */
> @@ -3465,31 +3467,18 @@ static void ufshcd_uic_cmd_compl(struct ufs_hba *hba, 
> u32 intr_status)
>  }
>  
>  /**
> - * ufshcd_transfer_req_compl - handle SCSI and query command completion
> + * __ufshcd_transfer_req_compl - handle SCSI and query command completion
>   * @hba: per adapter instance
> + * @completed_reqs: requests to complete
>   */
> -static void ufshcd_transfer_req_compl(struct ufs_hba *hba)
> +static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,
> + unsigned long completed_reqs)
>  {
>   struct ufshcd_lrb *lrbp;
>   struct scsi_cmnd *cmd;
> - unsigned long completed_reqs;
> - u32 tr_doorbell;
>   int result;
>   int index;
>  
> - /* Resetting interrupt aggregation counters first and reading the
> -  * DOOR_BELL afterward allows us to handle all the completed requests.
> -  * In order to prevent other interrupts starvation the DB is read once
> -  * after reset. The down side of this solution is the possibility of
> -  * false interrupt if device completes another request after resetting
> -  * aggregation and before reading the DB.
> -  */
> - if (ufshcd_is_intr_aggr_allowed(hba))
> - ufshcd_reset_intr_aggr(hba);
> -
> - tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
> - completed_reqs = tr_doorbell ^ hba->outstanding_reqs;
> -
>   for_each_set_bit(index, &completed_reqs, hba->nutrs) {
>   lrbp = &hba->lrb[index];
>   cmd = lrbp->cmd;
> @@ -3519,6 +3508,31 @@ static void ufshcd_transfer_req_compl(struct ufs_hba 
> *hba)
>  }
>  
>  /**
> + * ufshcd_transfer_req_compl - handle SCSI and query command completion
> + * @hba: per adapter instance
> + */
> +static void ufshcd_transfer_req_compl(struct ufs_hba *hba)
> +{
> + unsigned long completed_reqs;
> + u32 tr_doorbell;
> +
> + /* Resetting interrupt aggregation counters first and reading the
> +  * DOOR_BELL afterward allows us to handle all the completed requests.
> +  * In order to prevent other interrupts starvation the DB is read once
> +  * after reset. The down side of this solution is the possibility of
> +  * false interrupt if device completes another request after resetting
> +  * aggregation and before reading the DB.
> +  */
> + if (ufshcd_is_intr_aggr_allowed(hba))
> + ufshcd_reset_intr_aggr(hba);
> +
> + tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
> + completed_reqs = tr_doorbell ^ hba->outstanding_reqs;
> +
> + __ufshcd_transfer_req_compl(hba, completed_reqs);
> +}
> +
> +/**
>   * ufshcd_disable_ee - disable exception event
>   * @hba: per-adapter instance
>   * @mask: exception event to disable
> @@ -3773,6 +3787,13 @@ out:
>   return;
>  }
>  
> +/* Complete requests that have door-bell cleared */
> +static void ufshcd_complete_requests(struct ufs_hba *hba)
> +{
> + ufshcd_transfer_req_compl(hba);
> + ufshcd_tmc_handler(hba);
> +}
> +
>  /**
>   * ufshcd_err_handler - handle UFS errors that require s/w attention
>   * @work: pointer to work structure
> @@ -3785,6 +3806,7 @@ static void ufshcd_err_handler(struct work_struct *work)
>   u32 err_tm = 0;
>   int err = 0;
>   i

Re: [PATCH v5 06/15] scsi: ufs: separate device and host quirks

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> Currently we use the host quirks mechanism in order to
> handle both device and host controller quirks.
> In order to support various of UFS devices we should separate
> handling the device quirks from the host controller's.
> 
> Reviewed-by: Gilad Broner 
> Signed-off-by: Raviv Shvili 
> Signed-off-by: Yaniv Gardi 
> 
> ---
>  drivers/scsi/ufs/Makefile |   2 +-
>  drivers/scsi/ufs/ufs.h|  31 +++
>  drivers/scsi/ufs/ufs_quirks.c | 100 ++
>  drivers/scsi/ufs/ufs_quirks.h | 124 
> ++
>  drivers/scsi/ufs/ufshcd.c |   2 +
>  drivers/scsi/ufs/ufshcd.h |   3 +
>  6 files changed, 261 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/scsi/ufs/ufs_quirks.c
>  create mode 100644 drivers/scsi/ufs/ufs_quirks.h
> 
Sigh. _Of course_ there will be device quirks.
Probably too much to hope to have a new implementation where everyone
agrees on the details.

Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v5 07/15] scsi: ufs: disable vccq if it's not needed by UFS device

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> Some UFS devices don't require VCCQ rail for device operations hence
> this change adds support to recognize such devices and remove vote for
> the unused VCCQ rail.
> 
> Signed-off-by: Subhash Jadavani 
> Signed-off-by: Yaniv Gardi 
> 
> ---
>  drivers/scsi/ufs/ufs.h|  1 +
>  drivers/scsi/ufs/ufshcd.c | 60 
> +++
>  2 files changed, 57 insertions(+), 4 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v5 05/15] scsi: ufs: add support to read device and string descriptors

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> This change adds support to read device descriptor and string descriptor
> from a UFS device
> 
> Reviewed-by: Gilad Broner 
> Signed-off-by: Raviv Shvili 
> Signed-off-by: Yaniv Gardi 
> 
> ---
>  drivers/scsi/ufs/ufs.h|  1 +
>  drivers/scsi/ufs/ufshcd.c | 88 
> ++-
>  drivers/scsi/ufs/ufshcd.h |  7 
>  3 files changed, 95 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
> index 54a16ce..aacb235 100644
> --- a/drivers/scsi/ufs/ufs.h
> +++ b/drivers/scsi/ufs/ufs.h
> @@ -43,6 +43,7 @@
>  #define GENERAL_UPIU_REQUEST_SIZE 32
>  #define QUERY_DESC_MAX_SIZE   255
>  #define QUERY_DESC_MIN_SIZE   2
> +#define QUERY_DESC_HDR_SIZE   2
>  #define QUERY_OSF_SIZE(GENERAL_UPIU_REQUEST_SIZE - \
>   (sizeof(struct utp_upiu_header)))
>  
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 80031e6..e2ed415 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -39,7 +39,7 @@
>  
>  #include 
>  #include 
> -
> +#include 
>  #include 
>  #include "ufshcd.h"
>  #include "unipro.h"
> @@ -232,6 +232,16 @@ static inline void ufshcd_disable_irq(struct ufs_hba 
> *hba)
>   }
>  }
>  
> +/* replace non-printable or non-ASCII characters with spaces */
> +static inline void ufshcd_remove_non_printable(char *val)
> +{
> + if (!val)
> + return;
> +
> + if (*val < 0x20 || *val > 0x7e)
> + *val = ' ';
> +}
> +
>  /*
>   * ufshcd_wait_for_register - wait for register value to change
>   * @hba - per-adapter interface
> @@ -2021,6 +2031,82 @@ static inline int ufshcd_read_power_desc(struct 
> ufs_hba *hba,
>   return ufshcd_read_desc(hba, QUERY_DESC_IDN_POWER, 0, buf, size);
>  }
>  
> +int ufshcd_read_device_desc(struct ufs_hba *hba, u8 *buf, u32 size)
> +{
> + return ufshcd_read_desc(hba, QUERY_DESC_IDN_DEVICE, 0, buf, size);
> +}
> +EXPORT_SYMBOL(ufshcd_read_device_desc);
> +
> +/**
> + * ufshcd_read_string_desc - read string descriptor
> + * @hba: pointer to adapter instance
> + * @desc_index: descriptor index
> + * @buf: pointer to buffer where descriptor would be read
> + * @size: size of buf
> + * @ascii: if true convert from unicode to ascii characters
> + *
> + * Return 0 in case of success, non-zero otherwise
> + */
> +int ufshcd_read_string_desc(struct ufs_hba *hba, int desc_index, u8 *buf,
> + u32 size, bool ascii)
> +{
> + int err = 0;
> +
> + err = ufshcd_read_desc(hba,
> + QUERY_DESC_IDN_STRING, desc_index, buf, size);
> +
> + if (err) {
> + dev_err(hba->dev, "%s: reading String Desc failed after %d 
> retries. err = %d\n",
> + __func__, QUERY_REQ_RETRIES, err);
> + goto out;
> + }
> +
> + if (ascii) {
> + int desc_len;
> + int ascii_len;
> + int i;
> + char *buff_ascii;
> +
> + desc_len = buf[0];
> + /* remove header and divide by 2 to move from UTF16 to UTF8 */
> + ascii_len = (desc_len - QUERY_DESC_HDR_SIZE) / 2 + 1;
> + if (size < ascii_len + QUERY_DESC_HDR_SIZE) {
> + dev_err(hba->dev, "%s: buffer allocated size is too 
> small\n",
> + __func__);
> + err = -ENOMEM;
> + goto out;
> + }
> +
> + buff_ascii = kmalloc(ascii_len, GFP_KERNEL);
> + if (!buff_ascii) {
> + err = -ENOMEM;
> + goto out_free_buff;
> + }
> +
> + /*
> +  * the descriptor contains string in UTF16 format
> +  * we need to convert to utf-8 so it can be displayed
> +  */
> + utf16s_to_utf8s((wchar_t *)&buf[QUERY_DESC_HDR_SIZE],
> + desc_len - QUERY_DESC_HDR_SIZE,
> + UTF16_BIG_ENDIAN, buff_ascii, ascii_len);
> +
> + /* replace non-printable or non-ASCII characters with spaces */
> + for (i = 0; i < ascii_len; i++)
> + ufshcd_remove_non_printable(&buff_ascii[i]);
> +
> + memset(buf + QUERY_DESC_HDR_SIZE, 0,
> + size - QUERY_DESC_HDR_SIZE);
> + memcpy(buf + QUERY_DESC_HDR_SIZE, buff_ascii, ascii_len);
> + buf[QUERY_DESC_LENGTH_OFFSET] = ascii_len + QUERY_DESC_HDR_SIZE;
> +out_free_buff:
> + kfree(buff_ascii);
> + }
> +out:
> + return err;
> +}
> +EXPORT_SYMBOL(ufshcd_read_string_desc);
> +
>  /**
>   * ufshcd_read_unit_desc_param - read the specified unit descriptor parameter
>   * @hba: Pointer to adapter instance
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index a6d3572..54e13cc 100644
> --- a/drivers/s

Re: [PATCH v5 04/15] scsi: ufs: verify hba controller hce reg value

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> Sometimes due to hw issues it takes some time to the
> host controller register to update. In order to verify the register
> has updated, a polling is done until its value is set.
> 
> In addition the functions ufshcd_hba_stop() and
> ufshcd_wait_for_register() was updated with an additional input
> parameter, indicating the timeout between reads will
> be done by sleeping or spinning the cpu.
> 
> Signed-off-by: Raviv Shvili 
> Signed-off-by: Yaniv Gardi 
> 
> ---
>  drivers/scsi/ufs/ufshcd.c | 53 
> ---
>  drivers/scsi/ufs/ufshcd.h | 12 +++
>  2 files changed, 35 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 3400ceb..80031e6 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -240,11 +240,13 @@ static inline void ufshcd_disable_irq(struct ufs_hba 
> *hba)
>   * @val - wait condition
>   * @interval_us - polling interval in microsecs
>   * @timeout_ms - timeout in millisecs
> + * @can_sleep - perform sleep or just spin
>   *
>   * Returns -ETIMEDOUT on error, zero on success
>   */
> -static int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
> - u32 val, unsigned long interval_us, unsigned long timeout_ms)
> +int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
> + u32 val, unsigned long interval_us,
> + unsigned long timeout_ms, bool can_sleep)
>  {
>   int err = 0;
>   unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
> @@ -253,9 +255,10 @@ static int ufshcd_wait_for_register(struct ufs_hba *hba, 
> u32 reg, u32 mask,
>   val = val & mask;
>  
>   while ((ufshcd_readl(hba, reg) & mask) != val) {
> - /* wakeup within 50us of expiry */
> - usleep_range(interval_us, interval_us + 50);
> -
> + if (can_sleep)
> + usleep_range(interval_us, interval_us + 50);
> + else
> + udelay(interval_us);
>   if (time_after(jiffies, timeout)) {
>   if ((ufshcd_readl(hba, reg) & mask) != val)
>   err = -ETIMEDOUT;
> @@ -1459,7 +1462,7 @@ ufshcd_clear_cmd(struct ufs_hba *hba, int tag)
>*/
>   err = ufshcd_wait_for_register(hba,
>   REG_UTP_TRANSFER_REQ_DOOR_BELL,
> - mask, ~mask, 1000, 1000);
> + mask, ~mask, 1000, 1000, true);
>  
>   return err;
>  }
> @@ -2815,6 +2818,23 @@ out:
>  }
>  
>  /**
> + * ufshcd_hba_stop - Send controller to reset state
> + * @hba: per adapter instance
> + * @can_sleep: perform sleep or just spin
> + */
> +static inline void ufshcd_hba_stop(struct ufs_hba *hba, bool can_sleep)
> +{
> + int err;
> +
> + ufshcd_writel(hba, CONTROLLER_DISABLE,  REG_CONTROLLER_ENABLE);
> + err = ufshcd_wait_for_register(hba, REG_CONTROLLER_ENABLE,
> + CONTROLLER_ENABLE, CONTROLLER_DISABLE,
> + 10, 1, can_sleep);
> + if (err)
> + dev_err(hba->dev, "%s: Controller disable failed\n", __func__);
> +}
> +
Shouldn't you return an error here?
If the controller disable failed you probably need a hard reset or
something, otherwise I would assume that every other command from that
point on will not work as expected.

Cheers,

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


Re: [PATCH v5 03/15] scsi: ufs: implement scsi host timeout handler

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> A race condition exists between request requeueing and scsi layer
> error handling:
> When UFS driver queuecommand returns a busy status for a request,
> it will be requeued and its tag will be freed and set to -1.
> At the same time it is possible that the request will timeout and
> scsi layer will start error handling for it. The scsi layer reuses
> the request and its tag to send error related commands to the device,
> however its tag is no longer valid.
Hmm. How can the host return a 'busy' status for a request?
>From my understanding we have three possibilities:

1) queuecommand returns busy; however, that means that the command has
never been send and this issue shouldn't occur
2) The command returns with BUSY status. But in this case it has already
been returned, so there cannot be any timeout coming in.
3) The host receives a command with a tag which is already in-use.
However, that should have been prevented by the block-layer, which
really should ensure that this situation never happens.

So either way I look at it, it really looks like a bug and adding a
timeout handler will just paper over it.
(Not that a timeout handler is a bad idea, in fact I'm convinced that
you need one. Just not for this purpose.)

So can you elaborate how this 'busy' status comes about?
Is the command sent to the device?

Cheers,

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


Re: [PATCH] target/cxgbit: add INET dependency

2016-02-29 Thread Varun Prakash
On Tue, Mar 01, 2016 at 10:58:28AM +0530, Nicholas A. Bellinger wrote:
> Hi Arnd,
> 
> On Mon, 2016-02-29 at 12:14 +0100, Arnd Bergmann wrote:
> > The newly added cxgbit driver directly calls functions of the
> > IPv4 network stack, which fails if that is disabled:
> > 
> > ERROR: "ip_route_output_flow" [drivers/target/iscsi/cxgbit/cxgbit.ko] 
> > undefined!
> > ERROR: "__ip_dev_find" [drivers/target/iscsi/cxgbit/cxgbit.ko] undefined!
> > 
> > This adds a Kconfig dependency to ensure we can't enable this
> > driver without the complete network stack it needs.
> > 
> > Signed-off-by: Arnd Bergmann 
> > Fixes: b7ca3321e114 ("cxgbit: add Kconfig and Makefile")
> > ---
> >  drivers/target/iscsi/cxgbit/Kconfig | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/target/iscsi/cxgbit/Kconfig 
> > b/drivers/target/iscsi/cxgbit/Kconfig
> > index cf335b4dbb4e..ce6f5cca315d 100644
> > --- a/drivers/target/iscsi/cxgbit/Kconfig
> > +++ b/drivers/target/iscsi/cxgbit/Kconfig
> > @@ -1,6 +1,7 @@
> >  config ISCSI_TARGET_CXGB4
> > tristate "Chelsio iSCSI target offload driver"
> > depends on ISCSI_TARGET && CHELSIO_T4
> > +   depends on INET
> > select CHELSIO_T4_UWIRE
> > ---help---
> > To compile this driver as module, choose M here: the module
> 
> Odd, ISCSI_TARGET already depends on NET, but I guess that's not enough
> for cxgbit..  ;)
> 
> Varun, please pick this up and fold it into the original commit, with
> proper credit to Arnd for finding this in the commit log.

I will update the original commit in v2 series, thanks Arnd for
finding this.
--
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/6] scsi: Add 'access_state' and 'preferred_path' attribute

2016-02-29 Thread Seymour, Shane M
in https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt

it says:

- show() must not use snprintf() when formatting the value to be
  returned to user space. If you can guarantee that an overflow
  will never happen you can use sprintf() otherwise you must use
  scnprintf().

> -Original Message-
> From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
> ow...@vger.kernel.org] On Behalf Of Hannes Reinecke
> Sent: Tuesday, March 01, 2016 3:56 PM
> To: Martin K. Petersen
> Cc: Christoph Hellwig; Ewan Milne; Bart van Assche; James Bottomley; linux-
> s...@vger.kernel.org; Hannes Reinecke
> Subject: [PATCH 1/6] scsi: Add 'access_state' and 'preferred_path' attribute
> 
> Add an 'access_state' field to struct scsi_device and display them in sysfs as
> 'access_state' and 'preferred_path' attribute.
> 
> Signed-off-by: Hannes Reinecke 
> ---
>  drivers/scsi/scsi_sysfs.c  | 74
> ++
>  include/scsi/scsi_device.h |  1 +
>  include/scsi/scsi_proto.h  | 12 
>  3 files changed, 87 insertions(+)
> 
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index
> d8b275b..b6a1af8 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -81,6 +81,33 @@ const char *scsi_host_state_name(enum
> scsi_host_state state)
>   return name;
>  }
> 
> +static const struct {
> + unsigned char   value;
> + char*name;
> +} sdev_access_states[] = {
> + { SCSI_ACCESS_STATE_OPTIMAL, "active/optimized" },
> + { SCSI_ACCESS_STATE_ACTIVE, "active/non-optimized" },
> + { SCSI_ACCESS_STATE_STANDBY, "standby" },
> + { SCSI_ACCESS_STATE_UNAVAILABLE, "unavailable" },
> + { SCSI_ACCESS_STATE_LBA, "lba-dependent" },
> + { SCSI_ACCESS_STATE_OFFLINE, "offline" },
> + { SCSI_ACCESS_STATE_TRANSITIONING, "transitioning" }, };
> +
> +const char *scsi_access_state_name(unsigned char state) {
> + int i;
> + char *name = NULL;
> +
> + for (i = 0; i < ARRAY_SIZE(sdev_access_states); i++) {
> + if (sdev_access_states[i].value == state) {
> + name = sdev_access_states[i].name;
> + break;
> + }
> + }
> + return name;
> +}
> +
>  static int check_set(unsigned long long *val, char *src)  {
>   char *last;
> @@ -973,6 +1000,43 @@ sdev_store_dh_state(struct device *dev, struct
> device_attribute *attr,
> 
>  static DEVICE_ATTR(dh_state, S_IRUGO | S_IWUSR, sdev_show_dh_state,
>  sdev_store_dh_state);
> +
> +static ssize_t
> +sdev_show_access_state(struct device *dev,
> +struct device_attribute *attr,
> +char *buf)
> +{
> + struct scsi_device *sdev = to_scsi_device(dev);
> + unsigned char access_state;
> + const char *access_state_name;
> +
> + if (!sdev->handler)
> + return -EINVAL;
> +
> + access_state = (sdev->access_state & SCSI_ACCESS_STATE_MASK);
> + access_state_name = scsi_access_state_name(access_state);
> +
> + return snprintf(buf, 32, "%s\n",
> + access_state_name ? access_state_name :
> "unknown"); } static
> +DEVICE_ATTR(access_state, S_IRUGO, sdev_show_access_state, NULL);
> +
> +static ssize_t
> +sdev_show_preferred_path(struct device *dev,
> +  struct device_attribute *attr,
> +  char *buf)
> +{
> + struct scsi_device *sdev = to_scsi_device(dev);
> +
> + if (!sdev->handler)
> + return -EINVAL;
> +
> + if (sdev->access_state & SCSI_ACCESS_STATE_PREFERRED)
> + return snprintf(buf,2, "1\n");
> + else
> + return snprintf(buf, 2, "0\n");
> +}
> +static DEVICE_ATTR(preferred_path, S_IRUGO,
> sdev_show_preferred_path,
> +NULL);
>  #endif
> 
>  static ssize_t
> @@ -1020,6 +1084,14 @@ static umode_t scsi_sdev_attr_is_visible(struct
> kobject *kobj,
>   !sdev->host->hostt->change_queue_depth)
>   return 0;
> 
> +#ifdef CONFIG_SCSI_DH
> + if (attr == &dev_attr_access_state.attr &&
> + !sdev->handler)
> + return 0;
> + if (attr == &dev_attr_preferred_path.attr &&
> + !sdev->handler)
> + return 0;
> +#endif
>   return attr->mode;
>  }
> 
> @@ -1069,6 +1141,8 @@ static struct attribute *scsi_sdev_attrs[] = {
>   &dev_attr_wwid.attr,
>  #ifdef CONFIG_SCSI_DH
>   &dev_attr_dh_state.attr,
> + &dev_attr_access_state.attr,
> + &dev_attr_preferred_path.attr,
>  #endif
>   &dev_attr_queue_ramp_up_period.attr,
>   REF_EVT(media_change),
> diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index
> 4af2b24..c067019 100644
> --- a/include/scsi/scsi_device.h
> +++ b/include/scsi/scsi_device.h
> @@ -201,6 +201,7 @@ struct scsi_device {
>   struct scsi_device_handler *handler;
>   void*handler_data;
> 
> + unsigned char   access_state;
>   enum scsi_device_state sdev_state;
>

Re: [PATCH] eata: Convert eata driver as normal PCI and platform device drivers

2016-02-29 Thread Christoph Hellwig
Hi Jiang.

I'd love to see this patch in and abuse of the old PCI API gone.

Did you resolve the problems Arthur saw with the previous iteratons
of the patch?
--
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_sysfs: add 'is_bin_visible' callback

2016-02-29 Thread Seymour, Shane M

Reviewed-by: Shane Seymour 

--
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] qlogicpti: Return correct error code

2016-02-29 Thread Seymour, Shane M

Reviewed-by: Shane Seymour 

--
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] scsi_transport_fc: implement 'disable_target_scan' module parameter

2016-02-29 Thread Seymour, Shane M

Reviewed-by: Shane Seymour 

--
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] scsi_transport_fc: Implement 'async_user_scan' module parameter

2016-02-29 Thread Seymour, Shane M

Reviewed-by: Shane Seymour 

--
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] snic: correctly check for array overrun on overly long version number

2016-02-29 Thread Seymour, Shane M

Reviewed-by: Shane Seymour 

--
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/cxgbit: add INET dependency

2016-02-29 Thread Nicholas A. Bellinger
Hi Arnd,

On Mon, 2016-02-29 at 12:14 +0100, Arnd Bergmann wrote:
> The newly added cxgbit driver directly calls functions of the
> IPv4 network stack, which fails if that is disabled:
> 
> ERROR: "ip_route_output_flow" [drivers/target/iscsi/cxgbit/cxgbit.ko] 
> undefined!
> ERROR: "__ip_dev_find" [drivers/target/iscsi/cxgbit/cxgbit.ko] undefined!
> 
> This adds a Kconfig dependency to ensure we can't enable this
> driver without the complete network stack it needs.
> 
> Signed-off-by: Arnd Bergmann 
> Fixes: b7ca3321e114 ("cxgbit: add Kconfig and Makefile")
> ---
>  drivers/target/iscsi/cxgbit/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/target/iscsi/cxgbit/Kconfig 
> b/drivers/target/iscsi/cxgbit/Kconfig
> index cf335b4dbb4e..ce6f5cca315d 100644
> --- a/drivers/target/iscsi/cxgbit/Kconfig
> +++ b/drivers/target/iscsi/cxgbit/Kconfig
> @@ -1,6 +1,7 @@
>  config ISCSI_TARGET_CXGB4
>   tristate "Chelsio iSCSI target offload driver"
>   depends on ISCSI_TARGET && CHELSIO_T4
> + depends on INET
>   select CHELSIO_T4_UWIRE
>   ---help---
>   To compile this driver as module, choose M here: the module

Odd, ISCSI_TARGET already depends on NET, but I guess that's not enough
for cxgbit..  ;)

Varun, please pick this up and fold it into the original commit, with
proper credit to Arnd for finding this in the commit log.

--
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 112241] Under heavy load FC TARGET going to Oops

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

--- Comment #3 from nab  ---
Hi Anthony,

On Mon, 2016-02-29 at 02:26 +, bugzilla-dae...@bugzilla.kernel.org
wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=112241
> 
> Anthony  changed:
> 
>What|Removed |Added
> 
>  Kernel Version|4.3.3   |4.5.0
> 
> --- Comment #2 from Anthony  ---
> With kernel 4.5.0 on target, system hang after clients connects to target.
> 

So there are two things going on here.

First, the BUG_ON your ESX <-> LIO FC setup triggered has been addressed
recently in v4.5-rc4 and later kernels with the following series:

http://www.spinics.net/lists/target-devel/msg11822.html

Note these patches will be making it back to earlier stable kernels over
the next weeks.

However, this specific bug is a final consequence of larger ESX v5.5u2+
host side issue of AtomicTestandSet (ATS) heartbeat being enabled (by
default) for all VMFS5 mounts:

https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2113956

Other folks have been hitting this recently, here's some extra
background:

http://permalink.gmane.org/gmane.linux.scsi.target.devel/11574
http://www.spinics.net/lists/target-devel/msg12124.html

Note this effects all targets w/ VAAI ATS (including EMC, IBM, 3PAR,
SolidFire, etc) and the current solution for ESX v5.5u2+ is to either:

  - Explicitly disable ATS heartbeat usage on all VMFS5 mounts as 
described in the VMWare -kb article, or:
  - Explicitly disable all ATS logic completely from LIO using 
emulate_caw=0 on all backends connected to ESX v5.5u2+ hosts
with VMFS5.

You can google for 'esx ats heartbeat bug' to see the gory details.

Thanks for reporting!

--nab

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


Re: [Bug 112241] Under heavy load FC TARGET going to Oops

2016-02-29 Thread Nicholas A. Bellinger
Hi Anthony,

On Mon, 2016-02-29 at 02:26 +, bugzilla-dae...@bugzilla.kernel.org
wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=112241
> 
> Anthony  changed:
> 
>What|Removed |Added
> 
>  Kernel Version|4.3.3   |4.5.0
> 
> --- Comment #2 from Anthony  ---
> With kernel 4.5.0 on target, system hang after clients connects to target.
> 

So there are two things going on here.

First, the BUG_ON your ESX <-> LIO FC setup triggered has been addressed
recently in v4.5-rc4 and later kernels with the following series:

http://www.spinics.net/lists/target-devel/msg11822.html

Note these patches will be making it back to earlier stable kernels over
the next weeks.

However, this specific bug is a final consequence of larger ESX v5.5u2+
host side issue of AtomicTestandSet (ATS) heartbeat being enabled (by
default) for all VMFS5 mounts:

https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2113956

Other folks have been hitting this recently, here's some extra
background:

http://permalink.gmane.org/gmane.linux.scsi.target.devel/11574
http://www.spinics.net/lists/target-devel/msg12124.html

Note this effects all targets w/ VAAI ATS (including EMC, IBM, 3PAR,
SolidFire, etc) and the current solution for ESX v5.5u2+ is to either:

  - Explicitly disable ATS heartbeat usage on all VMFS5 mounts as 
described in the VMWare -kb article, or:
  - Explicitly disable all ATS logic completely from LIO using 
emulate_caw=0 on all backends connected to ESX v5.5u2+ hosts
with VMFS5.

You can google for 'esx ats heartbeat bug' to see the gory details.

Thanks for reporting!

--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 v5 02/15] scsi: ufs: avoid spurious UFS host controller interrupts

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> When control reaches to Linux UFS driver during UFS boot mode, UFS host
> controller interrupt status/enable registers may have left over
> settings.
> In order to avoid any spurious interrupts due to these left overs,
> it's important to clear these interrupt status/enable registers before
> enabling UFS interrupt handling.
> 
> Signed-off-by: Subhash Jadavani 
> Signed-off-by: Yaniv Gardi 
> 
> ---
>  drivers/scsi/ufs/ufshcd.c | 15 +++
>  1 file changed, 15 insertions(+)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH v5 01/15] scsi: ufs-qcom: add number of lanes per direction

2016-02-29 Thread Hannes Reinecke
On 02/28/2016 09:32 PM, Yaniv Gardi wrote:
> Different platform may have different number of lanes
> for the UFS link.
> Add parameter to device tree specifying how many lanes
> should be configured for the UFS link.
> 
> Signed-off-by: Gilad Broner 
> Signed-off-by: Yaniv Gardi 
> 
> ---
Reviewed-by: Hannes Reinecke 

Cheers,

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


Re: [PATCH 1/8] scsi_sysfs: add 'is_bin_visible' callback

2016-02-29 Thread Hannes Reinecke
On 03/01/2016 12:51 PM, Hannes Reinecke wrote:
> Add 'is_bin_visible' callback to blank out unsupported vpd pages.
> 
> Signed-off-by: Hannes Reinecke 
> ---
>  drivers/scsi/scsi_sysfs.c | 23 +++
>  1 file changed, 23 insertions(+)
> 
Sorry, this is actually a stand-alone patch.
I'll be resending it with the proper subject.

Cheers,

Hannes

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


[PATCH 1/6] scsi: Add 'access_state' and 'preferred_path' attribute

2016-02-29 Thread Hannes Reinecke
Add an 'access_state' field to struct scsi_device
and display them in sysfs as 'access_state' and
'preferred_path' attribute.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/scsi_sysfs.c  | 74 ++
 include/scsi/scsi_device.h |  1 +
 include/scsi/scsi_proto.h  | 12 
 3 files changed, 87 insertions(+)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index d8b275b..b6a1af8 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -81,6 +81,33 @@ const char *scsi_host_state_name(enum scsi_host_state state)
return name;
 }
 
+static const struct {
+   unsigned char   value;
+   char*name;
+} sdev_access_states[] = {
+   { SCSI_ACCESS_STATE_OPTIMAL, "active/optimized" },
+   { SCSI_ACCESS_STATE_ACTIVE, "active/non-optimized" },
+   { SCSI_ACCESS_STATE_STANDBY, "standby" },
+   { SCSI_ACCESS_STATE_UNAVAILABLE, "unavailable" },
+   { SCSI_ACCESS_STATE_LBA, "lba-dependent" },
+   { SCSI_ACCESS_STATE_OFFLINE, "offline" },
+   { SCSI_ACCESS_STATE_TRANSITIONING, "transitioning" },
+};
+
+const char *scsi_access_state_name(unsigned char state)
+{
+   int i;
+   char *name = NULL;
+
+   for (i = 0; i < ARRAY_SIZE(sdev_access_states); i++) {
+   if (sdev_access_states[i].value == state) {
+   name = sdev_access_states[i].name;
+   break;
+   }
+   }
+   return name;
+}
+
 static int check_set(unsigned long long *val, char *src)
 {
char *last;
@@ -973,6 +1000,43 @@ sdev_store_dh_state(struct device *dev, struct 
device_attribute *attr,
 
 static DEVICE_ATTR(dh_state, S_IRUGO | S_IWUSR, sdev_show_dh_state,
   sdev_store_dh_state);
+
+static ssize_t
+sdev_show_access_state(struct device *dev,
+  struct device_attribute *attr,
+  char *buf)
+{
+   struct scsi_device *sdev = to_scsi_device(dev);
+   unsigned char access_state;
+   const char *access_state_name;
+
+   if (!sdev->handler)
+   return -EINVAL;
+
+   access_state = (sdev->access_state & SCSI_ACCESS_STATE_MASK);
+   access_state_name = scsi_access_state_name(access_state);
+
+   return snprintf(buf, 32, "%s\n",
+   access_state_name ? access_state_name : "unknown");
+}
+static DEVICE_ATTR(access_state, S_IRUGO, sdev_show_access_state, NULL);
+
+static ssize_t
+sdev_show_preferred_path(struct device *dev,
+struct device_attribute *attr,
+char *buf)
+{
+   struct scsi_device *sdev = to_scsi_device(dev);
+
+   if (!sdev->handler)
+   return -EINVAL;
+
+   if (sdev->access_state & SCSI_ACCESS_STATE_PREFERRED)
+   return snprintf(buf,2, "1\n");
+   else
+   return snprintf(buf, 2, "0\n");
+}
+static DEVICE_ATTR(preferred_path, S_IRUGO, sdev_show_preferred_path, NULL);
 #endif
 
 static ssize_t
@@ -1020,6 +1084,14 @@ static umode_t scsi_sdev_attr_is_visible(struct kobject 
*kobj,
!sdev->host->hostt->change_queue_depth)
return 0;
 
+#ifdef CONFIG_SCSI_DH
+   if (attr == &dev_attr_access_state.attr &&
+   !sdev->handler)
+   return 0;
+   if (attr == &dev_attr_preferred_path.attr &&
+   !sdev->handler)
+   return 0;
+#endif
return attr->mode;
 }
 
@@ -1069,6 +1141,8 @@ static struct attribute *scsi_sdev_attrs[] = {
&dev_attr_wwid.attr,
 #ifdef CONFIG_SCSI_DH
&dev_attr_dh_state.attr,
+   &dev_attr_access_state.attr,
+   &dev_attr_preferred_path.attr,
 #endif
&dev_attr_queue_ramp_up_period.attr,
REF_EVT(media_change),
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 4af2b24..c067019 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -201,6 +201,7 @@ struct scsi_device {
struct scsi_device_handler *handler;
void*handler_data;
 
+   unsigned char   access_state;
enum scsi_device_state sdev_state;
unsigned long   sdev_data[0];
 } __attribute__((aligned(sizeof(unsigned long;
diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h
index a9fbf1b..c2ae21c 100644
--- a/include/scsi/scsi_proto.h
+++ b/include/scsi/scsi_proto.h
@@ -277,5 +277,17 @@ struct scsi_lun {
__u8 scsi_lun[8];
 };
 
+/* SPC asymmetric access states */
+#define SCSI_ACCESS_STATE_OPTIMAL 0x00
+#define SCSI_ACCESS_STATE_ACTIVE  0x01
+#define SCSI_ACCESS_STATE_STANDBY 0x02
+#define SCSI_ACCESS_STATE_UNAVAILABLE 0x03
+#define SCSI_ACCESS_STATE_LBA 0x04
+#define SCSI_ACCESS_STATE_OFFLINE 0x0e
+#define SCSI_ACCESS_STATE_TRANSITIONING 0x0f
+
+/* Values for REPORT TARGET GROUP STATES */
+#define SCSI_ACCESS_STATE_MASK0x0f
+#define SCSI_ACCESS_STATE_PREFERRED   0x80
 
 #endif /* _

[PATCH 3/6] scsi_dh_alua: update 'access_state' field

2016-02-29 Thread Hannes Reinecke
Track attached SCSI devices and update the 'access_state' field
whenever an ALUA state change has been detected.

Reviewed-by: Bart Van Assche 
Reviewed-by: Ewan Milne 
Reviewed-by: Christoph Hellwig 
Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 48 --
 1 file changed, 46 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index 19f6539..5bcdf8d 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -75,6 +76,7 @@ struct alua_port_group {
struct kref kref;
struct rcu_head rcu;
struct list_headnode;
+   struct list_headdh_list;
unsigned char   device_id_str[256];
int device_id_len;
int group_id;
@@ -92,6 +94,7 @@ struct alua_port_group {
 };
 
 struct alua_dh_data {
+   struct list_headnode;
struct alua_port_group  *pg;
int group_id;
spinlock_t  pg_lock;
@@ -247,6 +250,7 @@ struct alua_port_group *alua_alloc_pg(struct scsi_device 
*sdev,
INIT_DELAYED_WORK(&pg->rtpg_work, alua_rtpg_work);
INIT_LIST_HEAD(&pg->rtpg_list);
INIT_LIST_HEAD(&pg->node);
+   INIT_LIST_HEAD(&pg->dh_list);
spin_lock_init(&pg->lock);
 
spin_lock(&port_group_lock);
@@ -328,6 +332,8 @@ static int alua_check_vpd(struct scsi_device *sdev, struct 
alua_dh_data *h,
 {
int rel_port = -1, group_id;
struct alua_port_group *pg, *old_pg = NULL;
+   bool pg_updated;
+   unsigned long flags;
 
group_id = scsi_vpd_tpg_id(sdev, &rel_port);
if (group_id < 0) {
@@ -357,10 +363,22 @@ static int alua_check_vpd(struct scsi_device *sdev, 
struct alua_dh_data *h,
old_pg = h->pg;
if (old_pg != pg) {
/* port group has changed. Update to new port group */
+   if (h->pg) {
+   spin_lock_irqsave(&old_pg->lock, flags);
+   list_del_rcu(&h->node);
+   spin_unlock_irqrestore(&old_pg->lock, flags);
+   }
rcu_assign_pointer(h->pg, pg);
+   pg_updated = true;
}
+
+   spin_lock_irqsave(&pg->lock, flags);
if (sdev->synchronous_alua)
pg->flags |= ALUA_SYNC_STPG;
+   if (pg_updated)
+   list_add_rcu(&h->node, &pg->dh_list);
+   spin_unlock_irqrestore(&pg->lock, flags);
+
alua_rtpg_queue(h->pg, sdev, NULL, true);
spin_unlock(&h->pg_lock);
 
@@ -613,8 +631,18 @@ static int alua_rtpg(struct scsi_device *sdev, struct 
alua_port_group *pg)
if (spin_trylock_irqsave(&tmp_pg->lock, flags)) {
if ((tmp_pg == pg) ||
!(tmp_pg->flags & ALUA_PG_RUNNING)) {
+   struct alua_dh_data *h;
+
tmp_pg->state = desc[0] & 0x0f;
tmp_pg->pref = desc[0] >> 7;
+   rcu_read_lock();
+   list_for_each_entry_rcu(h,
+   &tmp_pg->dh_list, node) {
+   /* h->sdev should always be 
valid */
+   BUG_ON(!h->sdev);
+   h->sdev->access_state = desc[0];
+   }
+   rcu_read_unlock();
}
if (tmp_pg == pg)
valid_states = desc[1];
@@ -645,10 +673,22 @@ static int alua_rtpg(struct scsi_device *sdev, struct 
alua_port_group *pg)
pg->interval = 2;
err = SCSI_DH_RETRY;
} else {
+   struct alua_dh_data *h;
+
/* Transitioning time exceeded, set port to standby */
err = SCSI_DH_IO;
pg->state = SCSI_ACCESS_STATE_STANDBY;
pg->expiry = 0;
+   rcu_read_lock();
+   list_for_each_entry_rcu(h, &pg->dh_list, node) {
+   BUG_ON(!h->sdev);
+   h->sdev->access_state =
+   (pg->state & SCSI_ACCESS_STATE_MASK);
+   if (pg->pref)
+   h->sdev->access_state |=
+   SCSI_ACCESS_STATE_PREFERRED;
+   }
+  

[PATCH 2/6] scsi_dh_alua: use common definitions for ALUA state

2016-02-29 Thread Hannes Reinecke
scsi_proto.h now contains definitions for the ALUA state,
so we don't have to carry them in the device handler.

Reviewed-by: Christoph Hellwig 
Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 58 +-
 1 file changed, 25 insertions(+), 33 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c 
b/drivers/scsi/device_handler/scsi_dh_alua.c
index 9a7657e..19f6539 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -31,14 +31,6 @@
 #define ALUA_DH_NAME "alua"
 #define ALUA_DH_VER "2.0"
 
-#define TPGS_STATE_OPTIMIZED   0x0
-#define TPGS_STATE_NONOPTIMIZED0x1
-#define TPGS_STATE_STANDBY 0x2
-#define TPGS_STATE_UNAVAILABLE 0x3
-#define TPGS_STATE_LBA_DEPENDENT   0x4
-#define TPGS_STATE_OFFLINE 0xe
-#define TPGS_STATE_TRANSITIONING   0xf
-
 #define TPGS_SUPPORT_NONE  0x00
 #define TPGS_SUPPORT_OPTIMIZED 0x01
 #define TPGS_SUPPORT_NONOPTIMIZED  0x02
@@ -180,7 +172,7 @@ static int submit_stpg(struct scsi_device *sdev, int 
group_id,
 
/* Prepare the data buffer */
memset(stpg_data, 0, stpg_len);
-   stpg_data[4] = TPGS_STATE_OPTIMIZED & 0x0f;
+   stpg_data[4] = SCSI_ACCESS_STATE_OPTIMAL;
put_unaligned_be16(group_id, &stpg_data[6]);
 
/* Prepare the command. */
@@ -248,7 +240,7 @@ struct alua_port_group *alua_alloc_pg(struct scsi_device 
*sdev,
}
pg->group_id = group_id;
pg->tpgs = tpgs;
-   pg->state = TPGS_STATE_OPTIMIZED;
+   pg->state = SCSI_ACCESS_STATE_OPTIMAL;
if (optimize_stpg)
pg->flags |= ALUA_OPTIMIZE_STPG;
kref_init(&pg->kref);
@@ -378,22 +370,22 @@ static int alua_check_vpd(struct scsi_device *sdev, 
struct alua_dh_data *h,
return SCSI_DH_OK;
 }
 
-static char print_alua_state(int state)
+static char print_alua_state(unsigned char state)
 {
switch (state) {
-   case TPGS_STATE_OPTIMIZED:
+   case SCSI_ACCESS_STATE_OPTIMAL:
return 'A';
-   case TPGS_STATE_NONOPTIMIZED:
+   case SCSI_ACCESS_STATE_ACTIVE:
return 'N';
-   case TPGS_STATE_STANDBY:
+   case SCSI_ACCESS_STATE_STANDBY:
return 'S';
-   case TPGS_STATE_UNAVAILABLE:
+   case SCSI_ACCESS_STATE_UNAVAILABLE:
return 'U';
-   case TPGS_STATE_LBA_DEPENDENT:
+   case SCSI_ACCESS_STATE_LBA:
return 'L';
-   case TPGS_STATE_OFFLINE:
+   case SCSI_ACCESS_STATE_OFFLINE:
return 'O';
-   case TPGS_STATE_TRANSITIONING:
+   case SCSI_ACCESS_STATE_TRANSITIONING:
return 'T';
default:
return 'X';
@@ -647,7 +639,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct 
alua_port_group *pg)
valid_states&TPGS_SUPPORT_OPTIMIZED?'A':'a');
 
switch (pg->state) {
-   case TPGS_STATE_TRANSITIONING:
+   case SCSI_ACCESS_STATE_TRANSITIONING:
if (time_before(jiffies, pg->expiry)) {
/* State transition, retry */
pg->interval = 2;
@@ -655,11 +647,11 @@ static int alua_rtpg(struct scsi_device *sdev, struct 
alua_port_group *pg)
} else {
/* Transitioning time exceeded, set port to standby */
err = SCSI_DH_IO;
-   pg->state = TPGS_STATE_STANDBY;
+   pg->state = SCSI_ACCESS_STATE_STANDBY;
pg->expiry = 0;
}
break;
-   case TPGS_STATE_OFFLINE:
+   case SCSI_ACCESS_STATE_OFFLINE:
/* Path unusable */
err = SCSI_DH_DEV_OFFLINED;
pg->expiry = 0;
@@ -693,20 +685,20 @@ static unsigned alua_stpg(struct scsi_device *sdev, 
struct alua_port_group *pg)
return SCSI_DH_RETRY;
}
switch (pg->state) {
-   case TPGS_STATE_OPTIMIZED:
+   case SCSI_ACCESS_STATE_OPTIMAL:
return SCSI_DH_OK;
-   case TPGS_STATE_NONOPTIMIZED:
+   case SCSI_ACCESS_STATE_ACTIVE:
if ((pg->flags & ALUA_OPTIMIZE_STPG) &&
!pg->pref &&
(pg->tpgs & TPGS_MODE_IMPLICIT))
return SCSI_DH_OK;
break;
-   case TPGS_STATE_STANDBY:
-   case TPGS_STATE_UNAVAILABLE:
+   case SCSI_ACCESS_STATE_STANDBY:
+   case SCSI_ACCESS_STATE_UNAVAILABLE:
break;
-   case TPGS_STATE_OFFLINE:
+   case SCSI_ACCESS_STATE_OFFLINE:
return SCSI_DH_IO;
-   case TPGS_STATE_TRANSITIONING:
+   case SCSI_ACCESS_STATE_TRANSITIONING:
break;
default:
sdev_printk(KERN_INFO, sdev,
@@ -760,7 +752,7 @@ static void alua_rtpg_work(struct work_struct *work)
 
pg->flags &

[PATCH 6/6] scsi_sysfs: call 'device_add' after attaching device handler

2016-02-29 Thread Hannes Reinecke
'device_add' will be evaluating the 'is_visible' callback
when creating the sysfs attributes. As by this time the
device handler has not been attached the 'access_state'
attribute will never be visible.

This patch moves the code around so that the device handler
is present by the time 'is_visible' is evaluated to
correctly display the 'access_state' attribute.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/scsi_sysfs.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index b6a1af8..4e7f944 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1226,13 +1226,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
 
scsi_autopm_get_device(sdev);
 
-   error = device_add(&sdev->sdev_gendev);
-   if (error) {
-   sdev_printk(KERN_INFO, sdev,
-   "failed to add device: %d\n", error);
-   return error;
-   }
-
error = scsi_dh_add_device(sdev);
if (error)
/*
@@ -1241,6 +1234,13 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
sdev_printk(KERN_INFO, sdev,
"failed to add device handler: %d\n", error);
 
+   error = device_add(&sdev->sdev_gendev);
+   if (error) {
+   sdev_printk(KERN_INFO, sdev,
+   "failed to add device: %d\n", error);
+   return error;
+   }
+
device_enable_async_suspend(&sdev->sdev_dev);
error = device_add(&sdev->sdev_dev);
if (error) {
-- 
2.6.2

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


[PATCH 4/6] scsi_dh_rdac: update 'access_state' field

2016-02-29 Thread Hannes Reinecke
Track attached SCSI devices and update the 'access_state'
whenever the path state of the device changes.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/device_handler/scsi_dh_rdac.c | 38 --
 1 file changed, 31 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c 
b/drivers/scsi/device_handler/scsi_dh_rdac.c
index 93880ed..06fbd0b 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -165,6 +165,7 @@ struct rdac_controller {
struct work_struct  ms_work;
struct scsi_device  *ms_sdev;
struct list_headms_head;
+   struct list_headdh_list;
 };
 
 struct c2_inquiry {
@@ -181,7 +182,9 @@ struct c2_inquiry {
 };
 
 struct rdac_dh_data {
+   struct list_headnode;
struct rdac_controller  *ctlr;
+   struct scsi_device  *sdev;
 #define UNINITIALIZED_LUN  (1 << 8)
unsignedlun;
 
@@ -392,6 +395,7 @@ static struct rdac_controller *get_controller(int index, 
char *array_name,
INIT_WORK(&ctlr->ms_work, send_mode_select);
INIT_LIST_HEAD(&ctlr->ms_head);
list_add(&ctlr->node, &ctlr_list);
+   INIT_LIST_HEAD(&ctlr->dh_list);
 
return ctlr;
 }
@@ -455,7 +459,8 @@ static int get_lun_info(struct scsi_device *sdev, struct 
rdac_dh_data *h,
 
 static int check_ownership(struct scsi_device *sdev, struct rdac_dh_data *h)
 {
-   int err;
+   int err, access_state;
+   struct rdac_dh_data *tmp;
struct c9_inquiry *inqp;
 
h->state = RDAC_STATE_ACTIVE;
@@ -471,19 +476,31 @@ static int check_ownership(struct scsi_device *sdev, 
struct rdac_dh_data *h)
h->mode = RDAC_MODE; /* LUN in RDAC mode */
 
/* Update ownership */
-   if (inqp->avte_cvp & 0x1)
+   if (inqp->avte_cvp & 0x1) {
h->lun_state = RDAC_LUN_OWNED;
-   else {
+   access_state = SCSI_ACCESS_STATE_OPTIMAL;
+   } else {
h->lun_state = RDAC_LUN_UNOWNED;
-   if (h->mode == RDAC_MODE)
+   if (h->mode == RDAC_MODE) {
h->state = RDAC_STATE_PASSIVE;
+   access_state = SCSI_ACCESS_STATE_STANDBY;
+   } else
+   access_state = SCSI_ACCESS_STATE_ACTIVE;
}
 
/* Update path prio*/
-   if (inqp->path_prio & 0x1)
+   if (inqp->path_prio & 0x1) {
h->preferred = RDAC_PREFERRED;
-   else
+   access_state |= SCSI_ACCESS_STATE_PREFERRED;
+   } else
h->preferred = RDAC_NON_PREFERRED;
+   rcu_read_lock();
+   list_for_each_entry_rcu(tmp, &h->ctlr->dh_list, node) {
+   /* h->sdev should always be valid */
+   BUG_ON(!tmp->sdev);
+   tmp->sdev->access_state = access_state;
+   }
+   rcu_read_unlock();
}
 
return err;
@@ -508,6 +525,10 @@ static int initialize_controller(struct scsi_device *sdev,
h->ctlr = get_controller(index, array_name, array_id, sdev);
if (!h->ctlr)
err = SCSI_DH_RES_TEMP_UNAVAIL;
+   else {
+   list_add_rcu(&h->node, &h->ctlr->dh_list);
+   h->sdev = sdev;
+   }
spin_unlock(&list_lock);
}
return err;
@@ -829,8 +850,11 @@ static void rdac_bus_detach( struct scsi_device *sdev )
flush_workqueue(kmpath_rdacd);
 
spin_lock(&list_lock);
-   if (h->ctlr)
+   if (h->ctlr) {
+   list_del_rcu(&h->node);
+   h->sdev = NULL;
kref_put(&h->ctlr->kref, release_controller);
+   }
spin_unlock(&list_lock);
sdev->handler_data = NULL;
kfree(h);
-- 
2.6.2

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


[PATCH 5/6] scsi_dh_emc: update 'access_state' field

2016-02-29 Thread Hannes Reinecke
Update the 'access_state' field of the SCSI device whenever
the path state changes.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/device_handler/scsi_dh_emc.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c 
b/drivers/scsi/device_handler/scsi_dh_emc.c
index e6fb97c..375d818 100644
--- a/drivers/scsi/device_handler/scsi_dh_emc.c
+++ b/drivers/scsi/device_handler/scsi_dh_emc.c
@@ -199,7 +199,12 @@ static int parse_sp_info_reply(struct scsi_device *sdev,
csdev->lun_state = csdev->buffer[4];
csdev->current_sp = csdev->buffer[8];
csdev->port = csdev->buffer[7];
-
+   if (csdev->lun_state == CLARIION_LUN_OWNED)
+   sdev->access_state = SCSI_ACCESS_STATE_OPTIMAL;
+   else
+   sdev->access_state = SCSI_ACCESS_STATE_STANDBY;
+   if (csdev->default_sp == csdev->current_sp)
+   sdev->access_state |= SCSI_ACCESS_STATE_PREFERRED;
 out:
return err;
 }
-- 
2.6.2

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


[PATCH 0/6] SCSI 'access_state' attribute

2016-02-29 Thread Hannes Reinecke
Hi all,

here's the patchset to add an 'access_state' and 'preferred_path'
attribute. It will display the access state of a path if a
hardware handler is attached.
The access_state is given in terms of SCSI ALUA, and
the vendor-specific access state (eg for rdac or alua)
are mapped onto the ALUA values.
Additionally the 'is_visible' callback is updated to
only display the attributes if they are supported.

Hannes Reinecke (6):
  scsi: Add 'access_state' and 'preferred_path' attribute
  scsi_dh_alua: use common definitions for ALUA state
  scsi_dh_alua: update 'access_state' field
  scsi_dh_rdac: update 'access_state' field
  scsi_dh_emc: update 'access_state' field
  scsi_sysfs: call 'device_add' after attaching device handler

 drivers/scsi/device_handler/scsi_dh_alua.c | 106 +++--
 drivers/scsi/device_handler/scsi_dh_emc.c  |   7 +-
 drivers/scsi/device_handler/scsi_dh_rdac.c |  38 +--
 drivers/scsi/scsi_sysfs.c  |  88 ++--
 include/scsi/scsi_device.h |   1 +
 include/scsi/scsi_proto.h  |  12 
 6 files changed, 202 insertions(+), 50 deletions(-)

-- 
2.6.2

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


[PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback

2016-02-29 Thread Hannes Reinecke
Add 'is_bin_visible' callback to blank out unsupported vpd pages.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/scsi_sysfs.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 00bc721..d8b275b 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1023,6 +1023,28 @@ static umode_t scsi_sdev_attr_is_visible(struct kobject 
*kobj,
return attr->mode;
 }
 
+static umode_t scsi_sdev_bin_attr_is_visible(struct kobject *kobj,
+struct bin_attribute *attr, int i)
+{
+   struct device *dev = container_of(kobj, struct device, kobj);
+   struct scsi_device *sdev = to_scsi_device(dev);
+
+
+   rcu_read_lock();
+   if (attr == &dev_attr_vpd_pg80 &&
+   !rcu_dereference(sdev->vpd_pg80)) {
+   rcu_read_unlock();
+   return 0;
+   }
+   if (attr == &dev_attr_vpd_pg83 &&
+   !rcu_dereference(sdev->vpd_pg83)) {
+   rcu_read_unlock();
+   return 0;
+   }
+   rcu_read_unlock();
+   return S_IRUGO;
+}
+
 /* Default template for device attributes.  May NOT be modified */
 static struct attribute *scsi_sdev_attrs[] = {
&dev_attr_device_blocked.attr,
@@ -1068,6 +1090,7 @@ static struct attribute_group scsi_sdev_attr_group = {
.attrs =scsi_sdev_attrs,
.bin_attrs =scsi_sdev_bin_attrs,
.is_visible =   scsi_sdev_attr_is_visible,
+   .is_bin_visible = scsi_sdev_bin_attr_is_visible,
 };
 
 static const struct attribute_group *scsi_sdev_attr_groups[] = {
-- 
2.6.2

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


[PATCH 1/8] scsi_sysfs: add 'is_bin_visible' callback

2016-02-29 Thread Hannes Reinecke
Add 'is_bin_visible' callback to blank out unsupported vpd pages.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/scsi_sysfs.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 00bc721..d8b275b 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1023,6 +1023,28 @@ static umode_t scsi_sdev_attr_is_visible(struct kobject 
*kobj,
return attr->mode;
 }
 
+static umode_t scsi_sdev_bin_attr_is_visible(struct kobject *kobj,
+struct bin_attribute *attr, int i)
+{
+   struct device *dev = container_of(kobj, struct device, kobj);
+   struct scsi_device *sdev = to_scsi_device(dev);
+
+
+   rcu_read_lock();
+   if (attr == &dev_attr_vpd_pg80 &&
+   !rcu_dereference(sdev->vpd_pg80)) {
+   rcu_read_unlock();
+   return 0;
+   }
+   if (attr == &dev_attr_vpd_pg83 &&
+   !rcu_dereference(sdev->vpd_pg83)) {
+   rcu_read_unlock();
+   return 0;
+   }
+   rcu_read_unlock();
+   return S_IRUGO;
+}
+
 /* Default template for device attributes.  May NOT be modified */
 static struct attribute *scsi_sdev_attrs[] = {
&dev_attr_device_blocked.attr,
@@ -1068,6 +1090,7 @@ static struct attribute_group scsi_sdev_attr_group = {
.attrs =scsi_sdev_attrs,
.bin_attrs =scsi_sdev_bin_attrs,
.is_visible =   scsi_sdev_attr_is_visible,
+   .is_bin_visible = scsi_sdev_bin_attr_is_visible,
 };
 
 static const struct attribute_group *scsi_sdev_attr_groups[] = {
-- 
2.6.2

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


Re: [PATCH 0/6] ncr5380: Exception handling fixes for v4.5

2016-02-29 Thread Finn Thain

On Mon, 29 Feb 2016, Martin K. Petersen wrote:

> > "Finn" == Finn Thain  writes:
> 
> Finn> These patches fix some exception handling and autosense bugs that
> Finn> I accidentally introduced in v4.5-rc1.
> 
> Finn> drivers/scsi/NCR5380.c   |  133 
> +++
> Finn> drivers/scsi/atari_NCR5380.c |  133 
> +++
> Finn> 2 files changed, 118 insertions(+), 148 deletions(-)
> 
> This is a pretty big lump of changes for a 4.5 bug fix!

I'm sure this is a lot of rework when compared to the high standard set by 
well-funded corporate contributions.

However, I don't have anyone paying me to write and execute thorough test 
plans for error paths on a wide variety of different hardware platforms.

Nonetheless, these error paths have now been thoroughly tested on several 
platforms.

Please keep in mind that these fixes are all rework of the changes I made 
in -rc1. So this submission is
   2 files changed, 118 insertions(+), 148 deletions(-)
which is all rework of the previous submission, which was
   18 files changed, 2940 insertions(+), 3688 deletions(-)

Better than 5% rate of rework. Bugs-per-line-of-code should drop quite 
quickly at that rate, presuming fixes get merged.

> 
> Given the limited exposure based on the nature of the affected hardware 
> I have queued them for 4.6.
> 

The affected hardware doesn't matter (though it is likely outside of any 
commercial support contract). It's the affected users that interest me.

-- 
--
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] eata: Convert eata driver as normal PCI and platform device drivers

2016-02-29 Thread kbuild test robot
Hi Jiang,

[auto build test ERROR on scsi/for-next]
[also build test ERROR on v4.5-rc6 next-20160229]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improving the system]

url:
https://github.com/0day-ci/linux/commits/Jiang-Liu/eata-Convert-eata-driver-as-normal-PCI-and-platform-device-drivers/20160301-105821
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: alpha-allyesconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=alpha 

All errors (new ones prefixed by >>):

   drivers/scsi/eata.c:1531:1: warning: data definition has no type or storage 
class
MODULE_DEVICE_TABLE(pci, eata2x_tbl);
^
>> drivers/scsi/eata.c:1531:1: error: type defaults to 'int' in declaration of 
>> 'MODULE_DEVICE_TABLE' [-Werror=implicit-int]
   drivers/scsi/eata.c:1531:1: warning: parameter names (without types) in 
function declaration
   drivers/scsi/eata.c:2633:1: warning: data definition has no type or storage 
class
module_init(eata2x_init);
^
   drivers/scsi/eata.c:2633:1: error: type defaults to 'int' in declaration of 
'module_init' [-Werror=implicit-int]
   drivers/scsi/eata.c:2633:1: warning: parameter names (without types) in 
function declaration
   drivers/scsi/eata.c:2634:1: warning: data definition has no type or storage 
class
module_exit(eata2x_exit);
^
   drivers/scsi/eata.c:2634:1: error: type defaults to 'int' in declaration of 
'module_exit' [-Werror=implicit-int]
   drivers/scsi/eata.c:2634:1: warning: parameter names (without types) in 
function declaration
   drivers/scsi/eata.c:1655:19: warning: 'eata2x_init' defined but not used 
[-Wunused-function]
static int __init eata2x_init(void)
  ^
   cc1: some warnings being treated as errors

vim +1531 drivers/scsi/eata.c

  1525  }
  1526  
  1527  static struct pci_device_id eata2x_tbl[] = {
  1528  { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_SCSI << 8, PCI_ANY_ID) },
  1529  { },
  1530  };
> 1531  MODULE_DEVICE_TABLE(pci, eata2x_tbl);
  1532  
  1533  static struct pci_driver eata2x_pci_driver = {
  1534  .name   = "eata_pci",

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


.config.gz
Description: Binary data


Re: [PATCH] eata: Convert eata driver as normal PCI and platform device drivers

2016-02-29 Thread kbuild test robot
Hi Jiang,

[auto build test ERROR on scsi/for-next]
[also build test ERROR on v4.5-rc6 next-20160229]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improving the system]

url:
https://github.com/0day-ci/linux/commits/Jiang-Liu/eata-Convert-eata-driver-as-normal-PCI-and-platform-device-drivers/20160301-105821
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: mips-allyesconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mips 

All error/warnings (new ones prefixed by >>):

>> drivers/scsi/eata.c:2633:1: warning: data definition has no type or storage 
>> class
module_init(eata2x_init);
^
>> drivers/scsi/eata.c:2633:1: error: type defaults to 'int' in declaration of 
>> 'module_init' [-Werror=implicit-int]
>> drivers/scsi/eata.c:2633:1: warning: parameter names (without types) in 
>> function declaration
   drivers/scsi/eata.c:2634:1: warning: data definition has no type or storage 
class
module_exit(eata2x_exit);
^
>> drivers/scsi/eata.c:2634:1: error: type defaults to 'int' in declaration of 
>> 'module_exit' [-Werror=implicit-int]
   drivers/scsi/eata.c:2634:1: warning: parameter names (without types) in 
function declaration
   drivers/scsi/eata.c:1655:19: warning: 'eata2x_init' defined but not used 
[-Wunused-function]
static int __init eata2x_init(void)
  ^
   cc1: some warnings being treated as errors

vim +2633 drivers/scsi/eata.c

  2627  spin_lock_irqsave(shost->host_lock, spin_flags);
  2628  ret = ihdlr(shost);
  2629  spin_unlock_irqrestore(shost->host_lock, spin_flags);
  2630  return ret;
  2631  }
  2632  
> 2633  module_init(eata2x_init);
> 2634  module_exit(eata2x_exit);
  2635  
  2636  #ifndef MODULE
  2637  __setup("eata=", option_setup);

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


.config.gz
Description: Binary data


[PATCH] eata: Convert eata driver as normal PCI and platform device drivers

2016-02-29 Thread Jiang Liu
Previously the eata driver just grabs and accesses eata PCI devices
without implementing a PCI device driver, that causes troubles with
latest IRQ related

Commit 991de2e59090 ("PCI, x86: Implement pcibios_alloc_irq() and
pcibios_free_irq()") changes the way to allocate PCI legacy IRQ
for PCI devices on x86 platforms. Instead of allocating PCI legacy
IRQs when pcibios_enable_device() gets called, now pcibios_alloc_irq()
will be called by pci_device_probe() to allocate PCI legacy IRQs
when binding PCI drivers to PCI devices.

But the eata driver directly accesses PCI devices without implementing
corresponding PCI drivers, so pcibios_alloc_irq() won't be called for
those PCI devices and wrong IRQ number may be used to manage the PCI
device.

This patch implements a PCI device driver to manage eata PCI devices,
so eata driver could properly cooperate with the PCI core. It also
provides headroom for PCI hotplug with eata driver.

It also represents non-PCI eata devices as platform devices, so it could
be managed as normal devices.

Signed-off-by: Jiang Liu 
Cc: Hannes Reinecke 
Cc: Ballabio, Dario 
Cc: Christoph Hellwig 
---
 drivers/scsi/eata.c |  624 ---
 1 file changed, 342 insertions(+), 282 deletions(-)

diff --git a/drivers/scsi/eata.c b/drivers/scsi/eata.c
index 227dd2c2ec2f..a27a7201866d 100644
--- a/drivers/scsi/eata.c
+++ b/drivers/scsi/eata.c
@@ -486,6 +486,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -503,8 +504,6 @@
 #include 
 #include 
 
-static int eata2x_detect(struct scsi_host_template *);
-static int eata2x_release(struct Scsi_Host *);
 static int eata2x_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
 static int eata2x_eh_abort(struct scsi_cmnd *);
 static int eata2x_eh_host_reset(struct scsi_cmnd *);
@@ -513,9 +512,9 @@ static int eata2x_bios_param(struct scsi_device *, struct 
block_device *,
 static int eata2x_slave_configure(struct scsi_device *);
 
 static struct scsi_host_template driver_template = {
+   .module = THIS_MODULE,
+   .proc_name = "eata2x",
.name = "EATA/DMA 2.0x rev. 8.10.00 ",
-   .detect = eata2x_detect,
-   .release = eata2x_release,
.queuecommand = eata2x_queuecommand,
.eh_abort_handler = eata2x_eh_abort,
.eh_host_reset_handler = eata2x_eh_host_reset,
@@ -818,7 +817,6 @@ struct hostdata {
unsigned int cp_stat[MAX_MAILBOXES];/* FREE, IN_USE, LOCKED, 
IN_RESET */
unsigned int last_cp_used;  /* Index of last mailbox used */
unsigned int iocount;   /* Total i/o done for this board */
-   int board_number;   /* Number of this board */
char board_name[16];/* Name of this board */
int in_reset;   /* True if board is doing a reset */
int target_to[MAX_TARGET][MAX_CHANNEL]; /* N. of timeout errors on 
target */
@@ -834,12 +832,9 @@ struct hostdata {
struct mssp sp; /* Local copy of sp buffer */
 };
 
-static struct Scsi_Host *sh[MAX_BOARDS];
 static const char *driver_name = "EATA";
-static char sha[MAX_BOARDS];
-
-/* Initialize num_boards so that ihdlr can work while detect is in progress */
-static unsigned int num_boards = MAX_BOARDS;
+static struct platform_device *eata2x_platform_devs[MAX_BOARDS];
+static bool eata2x_platform_driver_registered;
 
 static unsigned long io_port[] = {
 
@@ -850,10 +845,6 @@ static unsigned long io_port[] = {
/* First ISA */
0x1f0,
 
-   /* Space for MAX_PCI ports possibly reported by PCI_BIOS */
-   SKIP, SKIP, SKIP, SKIP, SKIP, SKIP, SKIP, SKIP,
-   SKIP, SKIP, SKIP, SKIP, SKIP, SKIP, SKIP, SKIP,
-
/* MAX_EISA ports */
0x1c88, 0x2c88, 0x3c88, 0x4c88, 0x5c88, 0x6c88, 0x7c88, 0x8c88,
0x9c88, 0xac88, 0xbc88, 0xcc88, 0xdc88, 0xec88, 0xfc88,
@@ -871,6 +862,18 @@ static unsigned long io_port[] = {
 #define H2DEV16(x) cpu_to_be16(x)
 #define DEV2H16(x) be16_to_cpu(x)
 
+#define dev_warn_on(dev, cond, fmt, ...)   \
+do {   \
+   if (cond)   \
+   dev_warn(dev, fmt, ##__VA_ARGS__);  \
+} while(0)
+
+#define dev_info_on(dev, cond, fmt, ...)   \
+do {   \
+   if (cond)   \
+   dev_info(dev, fmt, ##__VA_ARGS__);  \
+} while(0)
+
 /* But transfer orientation from the 16 bit data register is Little Endian */
 #define REG2H(x)   le16_to_cpu(x)
 
@@ -1024,90 +1027,43 @@ static int read_pio(unsigned long iobase, ushort * 
start, ushort * end)
return 0;
 }
 
-static struct pci_dev *get_pci_dev(unsigned long port_base)
-{
-#if defined(CONFIG_PCI)
-   unsigned int addr;
-   struct pci_dev *dev = NULL;
-
- 

Reviews, please

2016-02-29 Thread Martin K. Petersen

Loose ends for 4.6:

aicasm: fix kbuild for separated build directories
https://patchwork.kernel.org/patch/8298331/
https://patchwork.kernel.org/patch/8343891/

qlogicpti: Return correct error code
https://patchwork.kernel.org/patch/8338931/

scsi_transport_fc: Implement 'async_user_scan' module parameter
https://patchwork.kernel.org/patch/8372621/

scsi_transport_fc: implement 'disable_target_scan' module parameter
https://patchwork.kernel.org/patch/8372631/

snic: correctly check for array overrun on overly long version number
https://patchwork.kernel.org/patch/8427331/

ufs:
https://patchwork.kernel.org/bundle/mkp/ufs/

-- 
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 0/6] ncr5380: Exception handling fixes for v4.5

2016-02-29 Thread Martin K. Petersen
> "Finn" == Finn Thain  writes:

Finn> These patches fix some exception handling and autosense bugs that
Finn> I accidentally introduced in v4.5-rc1.

Finn> drivers/scsi/NCR5380.c   |  133 
+++
Finn> drivers/scsi/atari_NCR5380.c |  133 
+++
Finn> 2 files changed, 118 insertions(+), 148 deletions(-)

This is a pretty big lump of changes for a 4.5 bug fix!

Given the limited exposure based on the nature of the affected hardware
I have queued them for 4.6.

-- 
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] be2iscsi:Add missing error check in beiscsi_eeh_resume

2016-02-29 Thread Martin K. Petersen
> "Nicholas" == Nicholas Krause  writes:

Nicholas> This adds the missing error check and path for if the call to
Nicholas> the function hwi_init_controller fails as this error path was
Nicholas> clearly missed when writing beiscsi_eeh_resume and thus we
Nicholas> must add it now in order to be able to handle this
Nicholas> nonrecoverable failing function call gracefully in
Nicholas> beiscsi_eeh_resume.

Applied to 4.6/scsi-queue.

-- 
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] fcoe: fix reset of fip selection time.

2016-02-29 Thread Martin K. Petersen
> "Usha" == Usha Ketineni  writes:

Usha> Do not reset fip selection time for every advertisement in
Usha> fcoe_ctlr_recv_adv() but set it only once for the first validated
Usha> FCF. Otherwise FCF selection won't happen when the advertisements
Usha> consistently arrive with sub FCOE_CTLR_START_DELAY periodicity.

Applied to 4.6/scsi-queue.

-- 
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 v2 0/6] hisi_sas: add abort and retry feature

2016-02-29 Thread Martin K. Petersen
> "John" == John Garry  writes:

John> This patchset introduces support to abort certain commands which
John> have failed and retry.  Certain errors require that the command be
John> retried, like TRANS_TX_CREDIT_TIMEOUT_ERR in v1 hw.  However, when
John> these errors occur the IO may still be in the device, so the IO
John> must first be aborted, and then retried. The HiSilicon SAS
John> controller has no FW to do this work, so it needs to be done
John> manually.

Applied to 4.6/scsi-queue.

-- 
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 v2 1/1] sd: add missing scenario for sd_config_write_same

2016-02-29 Thread Martin K. Petersen
> "Tom" == Tom Yan  writes:

Tom> Since you've mentioned it, why do we disable write same for all
Tom> devices with a ATA Information VPD?

Generally speaking, SAS controllers that properly translate SCSI WRITE
SAME to ATA ditto also support modern features such as the REPORT
SUPPORTED OPERATION CODES command.

For the SAS controllers that do not support RSOC we check for the ATA
Information VPD page to determine whether we are talking to a SAS or
SATA device. If it's a SATA device we skip WRITE SAME because in most
cases either the controller's SATL or the drive itself will fail
miserably.

-- 
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: [Lsf-pc] [LSF/MM ATTEND] Online Logical Head Depop and SMR disks chunked writepages

2016-02-29 Thread Damien Le Moal









From:  Jan Kara 
Date:  Monday, February 29, 2016 at 22:40
To:  Damien Le Moal 
Cc:  Jan Kara , "linux-bl...@vger.kernel.org" 
, Bart Van Assche , 
Matias Bjorling , "linux-scsi@vger.kernel.org" 
, "lsf...@lists.linuxfoundation.org" 

Subject:  Re: [Lsf-pc] [LSF/MM ATTEND] Online Logical Head Depop and SMR disks 
chunked writepages


>On Mon 29-02-16 02:02:16, Damien Le Moal wrote:
>> 
>> >On Wed 24-02-16 01:53:24, Damien Le Moal wrote:
>> >> 
>> >> >On Tue 23-02-16 05:31:13, Damien Le Moal wrote:
>> >> >> 
>> >> >> >On 02/22/16 18:56, Damien Le Moal wrote:
>> >> >> >> 2) Write back of dirty pages to SMR block devices:
>> >> >> >>
>> >> >> >> Dirty pages of a block device inode are currently processed using 
>> >> >> >> the
>> >> >> >> generic_writepages function, which can be executed simultaneously
>> >> >> >> by multiple contexts (e.g sync, fsync, msync, sync_file_range, etc).
>> >> >> >> Mutual exclusion of the dirty page processing being achieved only at
>> >> >> >> the page level (page lock & page writeback flag), multiple processes
>> >> >> >> executing a "sync" of overlapping block ranges over the same zone of
>> >> >> >> an SMR disk can cause an out-of-LBA-order sequence of write requests
>> >> >> >> being sent to the underlying device. On a host managed SMR disk, 
>> >> >> >> where
>> >> >> >> sequential write to disk zones is mandatory, this result in errors 
>> >> >> >> and
>> >> >> >> the impossibility for an application using raw sequential disk write
>> >> >> >> accesses to be guaranteed successful completion of its write or 
>> >> >> >> fsync
>> >> >> >> requests.
>> >> >> >>
>> >> >> >> Using the zone information attached to the SMR block device queue
>> >> >> >> (introduced by Hannes), calls to the generic_writepages function can
>> >> >> >> be made mutually exclusive on a per zone basis by locking the zones.
>> >> >> >> This guarantees sequential request generation for each zone and 
>> >> >> >> avoid
>> >> >> >> write errors without any modification to the generic code 
>> >> >> >> implementing
>> >> >> >> generic_writepages.
>> >> >> >>
>> >> >> >> This is but one possible solution for supporting SMR host-managed
>> >> >> >> devices without any major rewrite of page cache management and
>> >> >> >> write-back processing. The opinion of the audience regarding this
>> >> >> >> solution and discussing other potential solutions would be greatly
>> >> >> >> appreciated.
>> >> >> >
>> >> >> >Hello Damien,
>> >> >> >
>> >> >> >Is it sufficient to support filesystems like BTRFS on top of SMR 
>> >> >> >drives 
>> >> >> >or would you also like to see that filesystems like ext4 can use SMR 
>> >> >> >drives ? In the latter case: the behavior of SMR drives differs so 
>> >> >> >significantly from that of other block devices that I'm not sure that 
>> >> >> >we 
>> >> >> >should try to support these directly from infrastructure like the 
>> >> >> >page 
>> >> >> >cache. If we look e.g. at NAND SSDs then we see that the 
>> >> >> >characteristics 
>> >> >> >of NAND do not match what filesystems expect (e.g. large erase 
>> >> >> >blocks). 
>> >> >> >That is why every SSD vendor provides an FTL (Flash Translation 
>> >> >> >Layer), 
>> >> >> >either inside the SSD or as a separate software driver. An FTL 
>> >> >> >implements a so-called LFS (log-structured filesystem). With what I 
>> >> >> >know 
>> >> >> >about SMR this technology looks also suitable for implementation of a 
>> >> >> >LFS. Has it already been considered to implement an LFS driver for 
>> >> >> >SMR 
>> >> >> >drives ? That would make it possible for any filesystem to access an 
>> >> >> >SMR 
>> >> >> >drive as any other block device. I'm not sure of this but maybe it 
>> >> >> >will 
>> >> >> >be possible to share some infrastructure with the LightNVM driver 
>> >> >> >(directory drivers/lightnvm in the Linux kernel tree). This driver 
>> >> >> >namely implements an FTL.
>> >> >> 
>> >> >> I totally agree with you that trying to support SMR disks by only 
>> >> >> modifying
>> >> >> the page cache so that unmodified standard file systems like BTRFS or 
>> >> >> ext4
>> >> >> remain operational is not realistic at best, and more likely simply 
>> >> >> impossible.
>> >> >> For this kind of use case, as you said, an FTL or a device mapper 
>> >> >> driver are
>> >> >> much more suitable.
>> >> >> 
>> >> >> The case I am considering for this discussion is for raw block device 
>> >> >> accesses
>> >> >> by an application (writes from user space to /dev/sdxx). This is a 
>> >> >> very likely
>> >> >> use case scenario for high capacity SMR disks with applications like 
>> >> >> distributed
>> >> >> object stores / key value stores.
>> >> >> 
>> >> >> In this case, write-back of dirty pages in the block device file inode 
>> >> >> mapping
>> >> >> is handled in fs/block_dev.c using the generic helper function 
>> >> >> generic_writepages.
>> >> >> This does not guarantee the generation of the required sequential 
>> >> >> wr

Re: [PATCHv2] iscsi_ibft: Add prefix-len attr and display netmask

2016-02-29 Thread Lee Duncan
On 02/29/2016 01:04 PM, Konrad Rzeszutek Wilk wrote:
> On Mon, Feb 29, 2016 at 1:45 PM, Mike Christie  wrote:
>> On 02/25/2016 12:15 PM, Lee Duncan wrote:
>>> From: Hannes Reinecke 
>>>
>>> The iBFT table only specifies a prefix length, not a netmask.
>>> And the netmask is pretty much pointless for IPv6.
>>> So introduce a new attribute 'prefix-len' and display the
>>> netmask attribute only for IPv4 addresses.
>>
>> The code looks ok to me, but I think this ipv4 comment was left over
>> from the last posting since it conflicts with the comment below about
>> always displaying it. Maybe it can just be edited when the patch is
>> merged to avoid having to resend again. If so,
>>
>> Reviewed-by: Mike Christie 
>>
> 
> Cool. Let me roll it up and send the git pull to Linus.

I actually just resent it, but the only change was to truncate the last
line of first paragraph of the comment to:

So introduce a new attribute 'prefix-len'.


> 
> This does not seem be super-urgent so it can wait for the upcoming merge 
> window?
> 
>>
>>>
>>> Some older user-space code might rely on the netmask attribute
>>> being present, so we should always display it.
>>>
>>> Changes from v1:
>>>  - Combined two patches into one
>>>
>>> Signed-off-by: Hannes Reinecke 
>>> Signed-off-by: Lee Duncan 
> 

-- 
Lee Duncan
SUSE Labs
--
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: [PATCHv2] iscsi_ibft: Add prefix-len attr and display netmask

2016-02-29 Thread Lee Duncan
On 02/29/2016 10:45 AM, Mike Christie wrote:
> On 02/25/2016 12:15 PM, Lee Duncan wrote:
>> From: Hannes Reinecke 
>>
>> The iBFT table only specifies a prefix length, not a netmask.
>> And the netmask is pretty much pointless for IPv6.
>> So introduce a new attribute 'prefix-len' and display the
>> netmask attribute only for IPv4 addresses.
> 
> The code looks ok to me, but I think this ipv4 comment was left over
> from the last posting since it conflicts with the comment below about
> always displaying it. Maybe it can just be edited when the patch is
> merged to avoid having to resend again. If so,
> 
> Reviewed-by: Mike Christie 
> 
> ...

Since there are no other comments, I will resubmit it with the comment
fixed.
-- 
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: [LSF/MM TOPIC][LSF/MM ATTEND] LIO Target Synchronization with sysfs [resend]

2016-02-29 Thread Lee Duncan
On 02/27/2016 01:54 PM, Nicholas A. Bellinger wrote:
> On Sat, 2016-02-27 at 08:19 -0800, Lee Duncan wrote:
>> [Apologies for the resend.]
>>
>> I would like to attend LSF/MM this year. I would like to discuss
>> problems I've had dealing with LIO targets and their inherent
>> asynchronicity in sysfs. I believe that with judicious use of kernel
>> events we can help user space handle target changes more cleanly.
>>
> 
> I assume you mean configfs, and not sysfs.  ;)

Apologies. Yes.

> 
>> As for other topics:
>>
>> As one of the maintainers of LIO at SUSE, I'd dearly love to see our
>> iSCSI targets merged.
>>
> 
> You're talking about Mike's (CC'ed) original target_core_rbd.c driver,
> right..?
> 
> He's been working on porting the PR related changes to a generic
> interface that can be consumed by multiple backend using
> target_core_iblock.c.
> 

Actually, no. I'm aware of that work because one of the groups I'm in is
working in that area. And that is of interest to me to.

But I meant the scst/lio merge, one of the proposed LSF/MM topics.
-- 
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: [PATCHv2] iscsi_ibft: Add prefix-len attr and display netmask

2016-02-29 Thread Konrad Rzeszutek Wilk
On Mon, Feb 29, 2016 at 1:45 PM, Mike Christie  wrote:
> On 02/25/2016 12:15 PM, Lee Duncan wrote:
>> From: Hannes Reinecke 
>>
>> The iBFT table only specifies a prefix length, not a netmask.
>> And the netmask is pretty much pointless for IPv6.
>> So introduce a new attribute 'prefix-len' and display the
>> netmask attribute only for IPv4 addresses.
>
> The code looks ok to me, but I think this ipv4 comment was left over
> from the last posting since it conflicts with the comment below about
> always displaying it. Maybe it can just be edited when the patch is
> merged to avoid having to resend again. If so,
>
> Reviewed-by: Mike Christie 
>

Cool. Let me roll it up and send the git pull to Linus.

This does not seem be super-urgent so it can wait for the upcoming merge window?

>
>>
>> Some older user-space code might rely on the netmask attribute
>> being present, so we should always display it.
>>
>> Changes from v1:
>>  - Combined two patches into one
>>
>> Signed-off-by: Hannes Reinecke 
>> Signed-off-by: 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: [Open-FCoE] [PATCH] fcoe: fix reset of fip selection time.

2016-02-29 Thread Neil Horman
On Mon, Feb 29, 2016 at 03:36:52AM -0800, Usha Ketineni wrote:
> Do not reset fip selection time for every advertisement
> in fcoe_ctlr_recv_adv() but set it only once for the first
> validated FCF. Otherwise FCF selection won't happen when the
> advertisements consistently arrive with sub FCOE_CTLR_START_DELAY
> periodicity.
> 
> Tested-by: Narendra K 
> Acked-by: Neil Horman 
> Reviewed-by: Johannes Thumshirn 
> Acked-by: Vasu Dev 
> Signed-off-by: Usha Ketineni 
> ---
>  drivers/scsi/fcoe/fcoe_ctlr.c |3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
> index d68d572..0c85ef6 100644
> --- a/drivers/scsi/fcoe/fcoe_ctlr.c
> +++ b/drivers/scsi/fcoe/fcoe_ctlr.c
> @@ -1079,7 +1079,8 @@ static void fcoe_ctlr_recv_adv(struct fcoe_ctlr *fip, 
> struct sk_buff *skb)
>* If this is the first validated FCF, note the time and
>* set a timer to trigger selection.
>*/
> - if (mtu_valid && !fip->sel_fcf && fcoe_ctlr_fcf_usable(fcf)) {
> + if (mtu_valid && !fip->sel_fcf && !fip->sel_time &&
> + fcoe_ctlr_fcf_usable(fcf)) {
>   fip->sel_time = jiffies +
>   msecs_to_jiffies(FCOE_CTLR_START_DELAY);
>   if (!timer_pending(&fip->timer) ||
> 
> ___
> fcoe-devel mailing list
> fcoe-de...@open-fcoe.org
> http://lists.open-fcoe.org/mailman/listinfo/fcoe-devel
> 
Acked-by: Neil Horman 

--
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: [PATCHv2] iscsi_ibft: Add prefix-len attr and display netmask

2016-02-29 Thread Mike Christie
On 02/25/2016 12:15 PM, Lee Duncan wrote:
> From: Hannes Reinecke 
> 
> The iBFT table only specifies a prefix length, not a netmask.
> And the netmask is pretty much pointless for IPv6.
> So introduce a new attribute 'prefix-len' and display the
> netmask attribute only for IPv4 addresses.

The code looks ok to me, but I think this ipv4 comment was left over
from the last posting since it conflicts with the comment below about
always displaying it. Maybe it can just be edited when the patch is
merged to avoid having to resend again. If so,

Reviewed-by: Mike Christie 


> 
> Some older user-space code might rely on the netmask attribute
> being present, so we should always display it.
> 
> Changes from v1:
>  - Combined two patches into one
> 
> Signed-off-by: Hannes Reinecke 
> Signed-off-by: Lee Duncan 
> ---
>  drivers/firmware/iscsi_ibft.c| 4 
>  drivers/scsi/iscsi_boot_sysfs.c  | 5 +
>  include/linux/iscsi_boot_sysfs.h | 1 +
>  3 files changed, 10 insertions(+)
> 
> diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
> index 72791232e46b..81037e5fe301 100644
> --- a/drivers/firmware/iscsi_ibft.c
> +++ b/drivers/firmware/iscsi_ibft.c
> @@ -319,6 +319,9 @@ static ssize_t ibft_attr_show_nic(void *data, int type, 
> char *buf)
>   val = cpu_to_be32(~((1 << (32-nic->subnet_mask_prefix))-1));
>   str += sprintf(str, "%pI4", &val);
>   break;
> + case ISCSI_BOOT_ETH_PREFIX_LEN:
> + str += sprintf(str, "%d\n", nic->subnet_mask_prefix);
> + break;
>   case ISCSI_BOOT_ETH_ORIGIN:
>   str += sprintf(str, "%d\n", nic->origin);
>   break;
> @@ -460,6 +463,7 @@ static umode_t ibft_check_nic_for(void *data, int type)
>   if (address_not_null(nic->ip_addr))
>   rc = S_IRUGO;
>   break;
> + case ISCSI_BOOT_ETH_PREFIX_LEN:
>   case ISCSI_BOOT_ETH_SUBNET_MASK:
>   if (nic->subnet_mask_prefix)
>   rc = S_IRUGO;
> diff --git a/drivers/scsi/iscsi_boot_sysfs.c b/drivers/scsi/iscsi_boot_sysfs.c
> index 680bf6f0ce76..8f0ea97cf31f 100644
> --- a/drivers/scsi/iscsi_boot_sysfs.c
> +++ b/drivers/scsi/iscsi_boot_sysfs.c
> @@ -166,6 +166,7 @@ static struct attribute_group 
> iscsi_boot_target_attr_group = {
>  iscsi_boot_rd_attr(eth_index, index, ISCSI_BOOT_ETH_INDEX);
>  iscsi_boot_rd_attr(eth_flags, flags, ISCSI_BOOT_ETH_FLAGS);
>  iscsi_boot_rd_attr(eth_ip, ip-addr, ISCSI_BOOT_ETH_IP_ADDR);
> +iscsi_boot_rd_attr(eth_prefix, prefix-len, ISCSI_BOOT_ETH_PREFIX_LEN);
>  iscsi_boot_rd_attr(eth_subnet, subnet-mask, ISCSI_BOOT_ETH_SUBNET_MASK);
>  iscsi_boot_rd_attr(eth_origin, origin, ISCSI_BOOT_ETH_ORIGIN);
>  iscsi_boot_rd_attr(eth_gateway, gateway, ISCSI_BOOT_ETH_GATEWAY);
> @@ -181,6 +182,7 @@ static struct attribute *ethernet_attrs[] = {
>   &iscsi_boot_attr_eth_index.attr,
>   &iscsi_boot_attr_eth_flags.attr,
>   &iscsi_boot_attr_eth_ip.attr,
> + &iscsi_boot_attr_eth_prefix.attr,
>   &iscsi_boot_attr_eth_subnet.attr,
>   &iscsi_boot_attr_eth_origin.attr,
>   &iscsi_boot_attr_eth_gateway.attr,
> @@ -208,6 +210,9 @@ static umode_t iscsi_boot_eth_attr_is_visible(struct 
> kobject *kobj,
>   else if (attr ==  &iscsi_boot_attr_eth_ip.attr)
>   return boot_kobj->is_visible(boot_kobj->data,
>ISCSI_BOOT_ETH_IP_ADDR);
> + else if (attr ==  &iscsi_boot_attr_eth_prefix.attr)
> + return boot_kobj->is_visible(boot_kobj->data,
> +  ISCSI_BOOT_ETH_PREFIX_LEN);
>   else if (attr ==  &iscsi_boot_attr_eth_subnet.attr)
>   return boot_kobj->is_visible(boot_kobj->data,
>ISCSI_BOOT_ETH_SUBNET_MASK);
> diff --git a/include/linux/iscsi_boot_sysfs.h 
> b/include/linux/iscsi_boot_sysfs.h
> index 2a8b1659bf35..548d55395488 100644
> --- a/include/linux/iscsi_boot_sysfs.h
> +++ b/include/linux/iscsi_boot_sysfs.h
> @@ -23,6 +23,7 @@ enum iscsi_boot_eth_properties_enum {
>   ISCSI_BOOT_ETH_INDEX,
>   ISCSI_BOOT_ETH_FLAGS,
>   ISCSI_BOOT_ETH_IP_ADDR,
> + ISCSI_BOOT_ETH_PREFIX_LEN,
>   ISCSI_BOOT_ETH_SUBNET_MASK,
>   ISCSI_BOOT_ETH_ORIGIN,
>   ISCSI_BOOT_ETH_GATEWAY,
> 

--
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] fcoe: fix reset of fip selection time.

2016-02-29 Thread Usha Ketineni
Do not reset fip selection time for every advertisement
in fcoe_ctlr_recv_adv() but set it only once for the first
validated FCF. Otherwise FCF selection won't happen when the
advertisements consistently arrive with sub FCOE_CTLR_START_DELAY
periodicity.

Tested-by: Narendra K 
Acked-by: Neil Horman 
Reviewed-by: Johannes Thumshirn 
Acked-by: Vasu Dev 
Signed-off-by: Usha Ketineni 
---
 drivers/scsi/fcoe/fcoe_ctlr.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index d68d572..0c85ef6 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -1079,7 +1079,8 @@ static void fcoe_ctlr_recv_adv(struct fcoe_ctlr *fip, 
struct sk_buff *skb)
 * If this is the first validated FCF, note the time and
 * set a timer to trigger selection.
 */
-   if (mtu_valid && !fip->sel_fcf && fcoe_ctlr_fcf_usable(fcf)) {
+   if (mtu_valid && !fip->sel_fcf && !fip->sel_time &&
+   fcoe_ctlr_fcf_usable(fcf)) {
fip->sel_time = jiffies +
msecs_to_jiffies(FCOE_CTLR_START_DELAY);
if (!timer_pending(&fip->timer) ||

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


Re: [PATCH 00/35 v4] separate operations from flags in the bio/request structs

2016-02-29 Thread Mike Christie
On 02/29/2016 11:13 AM, Christoph Hellwig wrote:
> Any reason you've dropped my ACK for the previous version?

Sorry. I think I accidentally dropped it when I rebased back over to
linux-next. It looks like it only got stuck on the first patch. I will
fix that up on the resend for those kbuild errors.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 00/35 v4] separate operations from flags in the bio/request structs

2016-02-29 Thread Christoph Hellwig
Any reason you've dropped my ACK for the previous version?

Jens, is this something you're fine with?  Would be great to figure
out a way to get this into 4.6.  There's probably going to be
plenty of conflicts, so having some sort of stable base tree
would be nice..

(Talking about conflicts, seems like the block for-linus and for-next
trees already conflict quite a bit..)
--
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: small diff in reported GiB size of an SSD

2016-02-29 Thread Toralf Förster
James Bottomley:
> On Mon, 2016-02-29 at 13:31 +, Toralf Förster wrote:
> commit 564b026fbd0d28e9f70fb3831293d2922bb7855b
> Author: James Bottomley 
> Date:   Wed Jan 20 14:58:29 2016 -0800
> 
> string_helpers: fix precision loss for some inputs
>  
> James
> 
> 
 cool - thx

-- 
Toralf
PGP: C4EACDDE 0076E94E, OTR: 420E74C8 30246EE7
--
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: small diff in reported GiB size of an SSD

2016-02-29 Thread James Bottomley
On Mon, 2016-02-29 at 13:31 +, Toralf Förster wrote:
> I'm just curious about this diff in dmesg output between 4.3.2 and
> 4.3.3 at a 64 bit Gentoo hardened system:
> 
> $ diff dmesg-4.4.[23]-hardened | grep logical
> < sd 0:0:0:0: [sda] 468862128 512-byte logical blocks: (240 GB/223
> GiB)
> > sd 0:0:0:0: [sda] 468862128 512-byte logical blocks: (240 GB/224
> > GiB)
> 

commit 564b026fbd0d28e9f70fb3831293d2922bb7855b
Author: James Bottomley 
Date:   Wed Jan 20 14:58:29 2016 -0800

string_helpers: fix precision loss for some inputs
 
James

--
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: [Lsf-pc] [LSF/MM ATTEND] Online Logical Head Depop and SMR disks chunked writepages

2016-02-29 Thread Jan Kara
On Mon 29-02-16 02:02:16, Damien Le Moal wrote:
> 
> >On Wed 24-02-16 01:53:24, Damien Le Moal wrote:
> >> 
> >> >On Tue 23-02-16 05:31:13, Damien Le Moal wrote:
> >> >> 
> >> >> >On 02/22/16 18:56, Damien Le Moal wrote:
> >> >> >> 2) Write back of dirty pages to SMR block devices:
> >> >> >>
> >> >> >> Dirty pages of a block device inode are currently processed using the
> >> >> >> generic_writepages function, which can be executed simultaneously
> >> >> >> by multiple contexts (e.g sync, fsync, msync, sync_file_range, etc).
> >> >> >> Mutual exclusion of the dirty page processing being achieved only at
> >> >> >> the page level (page lock & page writeback flag), multiple processes
> >> >> >> executing a "sync" of overlapping block ranges over the same zone of
> >> >> >> an SMR disk can cause an out-of-LBA-order sequence of write requests
> >> >> >> being sent to the underlying device. On a host managed SMR disk, 
> >> >> >> where
> >> >> >> sequential write to disk zones is mandatory, this result in errors 
> >> >> >> and
> >> >> >> the impossibility for an application using raw sequential disk write
> >> >> >> accesses to be guaranteed successful completion of its write or fsync
> >> >> >> requests.
> >> >> >>
> >> >> >> Using the zone information attached to the SMR block device queue
> >> >> >> (introduced by Hannes), calls to the generic_writepages function can
> >> >> >> be made mutually exclusive on a per zone basis by locking the zones.
> >> >> >> This guarantees sequential request generation for each zone and avoid
> >> >> >> write errors without any modification to the generic code 
> >> >> >> implementing
> >> >> >> generic_writepages.
> >> >> >>
> >> >> >> This is but one possible solution for supporting SMR host-managed
> >> >> >> devices without any major rewrite of page cache management and
> >> >> >> write-back processing. The opinion of the audience regarding this
> >> >> >> solution and discussing other potential solutions would be greatly
> >> >> >> appreciated.
> >> >> >
> >> >> >Hello Damien,
> >> >> >
> >> >> >Is it sufficient to support filesystems like BTRFS on top of SMR 
> >> >> >drives 
> >> >> >or would you also like to see that filesystems like ext4 can use SMR 
> >> >> >drives ? In the latter case: the behavior of SMR drives differs so 
> >> >> >significantly from that of other block devices that I'm not sure that 
> >> >> >we 
> >> >> >should try to support these directly from infrastructure like the page 
> >> >> >cache. If we look e.g. at NAND SSDs then we see that the 
> >> >> >characteristics 
> >> >> >of NAND do not match what filesystems expect (e.g. large erase 
> >> >> >blocks). 
> >> >> >That is why every SSD vendor provides an FTL (Flash Translation 
> >> >> >Layer), 
> >> >> >either inside the SSD or as a separate software driver. An FTL 
> >> >> >implements a so-called LFS (log-structured filesystem). With what I 
> >> >> >know 
> >> >> >about SMR this technology looks also suitable for implementation of a 
> >> >> >LFS. Has it already been considered to implement an LFS driver for SMR 
> >> >> >drives ? That would make it possible for any filesystem to access an 
> >> >> >SMR 
> >> >> >drive as any other block device. I'm not sure of this but maybe it 
> >> >> >will 
> >> >> >be possible to share some infrastructure with the LightNVM driver 
> >> >> >(directory drivers/lightnvm in the Linux kernel tree). This driver 
> >> >> >namely implements an FTL.
> >> >> 
> >> >> I totally agree with you that trying to support SMR disks by only 
> >> >> modifying
> >> >> the page cache so that unmodified standard file systems like BTRFS or 
> >> >> ext4
> >> >> remain operational is not realistic at best, and more likely simply 
> >> >> impossible.
> >> >> For this kind of use case, as you said, an FTL or a device mapper 
> >> >> driver are
> >> >> much more suitable.
> >> >> 
> >> >> The case I am considering for this discussion is for raw block device 
> >> >> accesses
> >> >> by an application (writes from user space to /dev/sdxx). This is a very 
> >> >> likely
> >> >> use case scenario for high capacity SMR disks with applications like 
> >> >> distributed
> >> >> object stores / key value stores.
> >> >> 
> >> >> In this case, write-back of dirty pages in the block device file inode 
> >> >> mapping
> >> >> is handled in fs/block_dev.c using the generic helper function 
> >> >> generic_writepages.
> >> >> This does not guarantee the generation of the required sequential write 
> >> >> pattern
> >> >> per zone necessary for host-managed disks. As I explained, aligning 
> >> >> calls of this
> >> >> function to zone boundaries while locking the zones under write-back 
> >> >> solves
> >> >> simply the problem (implemented and tested). This is of course only one 
> >> >> possible
> >> >> solution. Pushing modifications deeper in the code or providing a
> >> >> "generic_sequential_writepages" helper function are other potential 
> >> >> solutions
> >> >> that in my opinio

small diff in reported GiB size of an SSD

2016-02-29 Thread Toralf Förster
I'm just curious about this diff in dmesg output between 4.3.2 and 4.3.3 at a 
64 bit Gentoo hardened system:

$ diff dmesg-4.4.[23]-hardened | grep logical
< sd 0:0:0:0: [sda] 468862128 512-byte logical blocks: (240 GB/223 GiB)
> sd 0:0:0:0: [sda] 468862128 512-byte logical blocks: (240 GB/224 GiB)

-- 
Toralf
PGP: C4EACDDE 0076E94E, OTR: 420E74C8 30246EE7
--
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] target/cxgbit: add INET dependency

2016-02-29 Thread Arnd Bergmann
The newly added cxgbit driver directly calls functions of the
IPv4 network stack, which fails if that is disabled:

ERROR: "ip_route_output_flow" [drivers/target/iscsi/cxgbit/cxgbit.ko] undefined!
ERROR: "__ip_dev_find" [drivers/target/iscsi/cxgbit/cxgbit.ko] undefined!

This adds a Kconfig dependency to ensure we can't enable this
driver without the complete network stack it needs.

Signed-off-by: Arnd Bergmann 
Fixes: b7ca3321e114 ("cxgbit: add Kconfig and Makefile")
---
 drivers/target/iscsi/cxgbit/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/target/iscsi/cxgbit/Kconfig 
b/drivers/target/iscsi/cxgbit/Kconfig
index cf335b4dbb4e..ce6f5cca315d 100644
--- a/drivers/target/iscsi/cxgbit/Kconfig
+++ b/drivers/target/iscsi/cxgbit/Kconfig
@@ -1,6 +1,7 @@
 config ISCSI_TARGET_CXGB4
tristate "Chelsio iSCSI target offload driver"
depends on ISCSI_TARGET && CHELSIO_T4
+   depends on INET
select CHELSIO_T4_UWIRE
---help---
To compile this driver as module, choose M here: the module
-- 
2.7.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


Re: [PATCH v2 3/3] scsi: allow scsi devices to use direct complete

2016-02-29 Thread Mika Westerberg
On Sat, Feb 27, 2016 at 01:07:06AM -0800, dbasehore . wrote:
> That's an interesting question. Part of direct complete is to leave
> the device runtime suspended even after the system resumes if
> possible. The comments in pm_complete_with_resume_check indicate that
> the firmware may resume a device. I could see this happening with some
> kind of SCSI device.
> 
> If this is possible, are we able to put the device back into a
> consistent state (runtime suspended) by calling suspend for the scsi
> device? If not, we might need to use pm_complete_with_resume_check for
> the complete callback.

To me the latter option sounds safer.

I tried this series (as I'm interested in AHCI host controller runtime
PM) and noticed possible issue.

I have following two additional patches from linux-next applied to get
system resume working (otherwise resume is never finished):

  d07ab6d11477 block: Add blk_set_runtime_active()
  356fd2663cff scsi: Set request queue runtime PM status back to active on 
resume

Then I do this:

  # echo auto > /sys/block/sda/device/power/control
  # echo 5000 > /sys/block/sda/device/power/autosuspend_delay_ms

  # echo auto > /sys/bus/pci/devices/\:00\:12.0/ata1/power/control

The last line unblocks runtime PM from the parent device.

After 5 seconds of idle I see that the disk gets runtime suspended:

  [  566.858971] sd 0:0:0:0: [sda] Synchronizing SCSI cache
  [  567.049288] sd 0:0:0:0: [sda] Stopping disk

Now suspend the machine:

  # rtcwake -s10 -mmem

Once the system resumes I get this:

  [  668.879149] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
  [  668.927319] ata1.00: configured for UDMA/133
  [  669.392246] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
  [  669.440427] ata1.00: configured for UDMA/133
  [  669.445352] sd 0:0:0:0: [sda] Starting disk
  [  669.464647] sda: detected capacity change from 0 to 240057409536
  [  669.482596] sda: detected capacity change from 0 to 240057409536

It looks like we get resumed two times. If I have this patch reverted I
can see it happening only once. Also with the patch applied and if the
parent device has runtime PM blocked, it happens only once.
--
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