All of lore.kernel.org
 help / color / mirror / Atom feed
From: Subhash Jadavani <subhashj@codeaurora.org>
To: Kiwoong Kim <kwmad.kim@samsung.com>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	linux-scsi@vger.kernel.org,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	vinholikatti@gmail.com, 추헌광 <hg.chu@samsung.com>,
	linux-scsi-owner@vger.kernel.org
Subject: Re: [PATCH v1] ufs: introcude UFSHCD_QUIRK_GET_VS_RESULT quirk
Date: Tue, 08 Nov 2016 11:16:57 -0800	[thread overview]
Message-ID: <22d0ea8492548a02faf6dd4f46ff435b@codeaurora.org> (raw)
In-Reply-To: <002001d23994$8cce5080$a66af180$@samsung.com>

On 2016-11-07 23:48, Kiwoong Kim wrote:
> Some UFS host controllers may not report a result of
> UIC command completion properly.
> In such cases, they should get the result from UIC directly
> if their architectures support that.
> 
> Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
> ---
>  drivers/scsi/ufs/ufshcd.c | 27 +++++++++++++++++++++++----
>  drivers/scsi/ufs/ufshcd.h | 20 ++++++++++++++++++++
>  2 files changed, 43 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index d4a5a9c..8e19631 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -1011,7 +1011,10 @@ static inline bool
> ufshcd_ready_for_uic_cmd(struct ufs_hba *hba)
>   */
>  static inline u8 ufshcd_get_upmcrs(struct ufs_hba *hba)
>  {
> -	return (ufshcd_readl(hba, REG_CONTROLLER_STATUS) >> 8) & 0x7;
> +	if (hba->quirks & UFSHCD_QUIRK_GET_VS_RESULT)
> +		return (u8)ufshcd_vops_get_vs_info(hba, VS_OP_03);
> +	else
> +		return (ufshcd_readl(hba, REG_CONTROLLER_STATUS) >> 8) & 0x7;
>  }
> 
>  /**
> @@ -1038,6 +1041,17 @@ ufshcd_dispatch_uic_cmd(struct ufs_hba *hba,
> struct uic_command *uic_cmd)
>  		      REG_UIC_COMMAND);
>  }
> 
> +static inline enum vs_opcode ufshcd_get_vs_opcode(struct uic_command 
> *uic_cmd)
> +{
> +	if (uic_cmd->command == UIC_CMD_DME_LINK_STARTUP)
> +		return VS_OP_00;
> +	else if ((uic_cmd->command == UIC_CMD_DME_HIBER_ENTER))
> +		return VS_OP_01;
> +	else if ((uic_cmd->command == UIC_CMD_DME_HIBER_EXIT))
> +		return VS_OP_02;
> +	else
> +		return VS_OP_INVALID;
> +}
>  /**
>   * ufshcd_wait_for_uic_cmd - Wait complectioin of UIC command
>   * @hba: per adapter instance
> @@ -1051,11 +1065,16 @@ ufshcd_wait_for_uic_cmd(struct ufs_hba *hba,
> struct uic_command *uic_cmd)
>  {
>  	int ret;
>  	unsigned long flags;
> +	enum vs_opcode vs_op = ufshcd_get_vs_opcode(uic_cmd);

Please move this after we check the quirk below.

> 
>  	if (wait_for_completion_timeout(&uic_cmd->done,
> -					msecs_to_jiffies(UIC_CMD_TIMEOUT)))
> -		ret = uic_cmd->argument2 & MASK_UIC_COMMAND_RESULT;
> -	else
> +					msecs_to_jiffies(UIC_CMD_TIMEOUT))) {
> +		if (hba->quirks & UFSHCD_QUIRK_GET_VS_RESULT &&
> +					vs_op != VS_OP_INVALID)
> +			ret = ufshcd_vops_get_vs_info(hba, vs_op);
> +		else
> +			ret = uic_cmd->argument2 & MASK_UIC_COMMAND_RESULT;
> +	} else
>  		ret = -ETIMEDOUT;
> 
>  	spin_lock_irqsave(hba->host->host_lock, flags);
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 13504b4..8cf3991 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -245,6 +245,14 @@ struct ufs_pwr_mode_info {
>  	struct ufs_pa_layer_attr info;
>  };
> 
> +enum vs_opcode {
> +	VS_OP_00 = 0x00,
> +	VS_OP_01,
> +	VS_OP_02,
> +	VS_OP_03,
> +	VS_OP_INVALID = 0xFF,
> +};
> +

How do we interpret these codes? and how is this useful for non-exynos 
UFS host controller? Please make it generic which can be used by other 
controllers in future (if required).

>  /**
>   * struct ufs_hba_variant_ops - variant specific callbacks
>   * @name: variant name
> @@ -297,6 +305,7 @@ struct ufs_hba_variant_ops {
>  	int     (*resume)(struct ufs_hba *, enum ufs_pm_op);
>  	void	(*dbg_register_dump)(struct ufs_hba *hba);
>  	int	(*phy_initialization)(struct ufs_hba *);
> +	int	(*get_vs_info)(struct ufs_hba *hba, enum vs_opcode);
>  };
> 
>  /* clock gating state  */
> @@ -484,6 +493,8 @@ struct ufs_hba {
>  	 */
>  	#define UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION		UFS_BIT(5)
> 
> +	#define UFSHCD_QUIRK_GET_VS_RESULT			UFS_BIT(6)

Name is weird, can we name it to reflect the actual purpose of this 
quirk? something like UFSHCD_QUIRK_BROKEN_UIC_COMPL ?

> +
>  	unsigned int quirks;	/* Deviations from standard UFSHCI spec. */
> 
>  	/* Device deviations from standard UFS device spec. */
> @@ -853,4 +864,13 @@ static inline void
> ufshcd_vops_dbg_register_dump(struct ufs_hba *hba)
>  		hba->vops->dbg_register_dump(hba);
>  }
> 
> +static inline int ufshcd_vops_get_vs_info(struct ufs_hba *hba,


You may name it as *get_uic_coml_info() ?

> +					enum vs_opcode op)
> +{
> +	if (hba->vops && hba->vops->get_vs_info)
> +		return hba->vops->get_vs_info(hba, op);
> +
> +	return -ENOTSUPP;
> +}
> +
>  #endif /* End of Header */

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

  reply	other threads:[~2016-11-08 19:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-08  7:48 [PATCH v1] ufs: introcude UFSHCD_QUIRK_GET_VS_RESULT quirk Kiwoong Kim
2016-11-08 19:16 ` Subhash Jadavani [this message]
2016-11-09  6:46   ` Kiwoong Kim
2016-11-09 19:04     ` Subhash Jadavani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=22d0ea8492548a02faf6dd4f46ff435b@codeaurora.org \
    --to=subhashj@codeaurora.org \
    --cc=hg.chu@samsung.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=kwmad.kim@samsung.com \
    --cc=linux-scsi-owner@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=vinholikatti@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.