All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Winkler, Tomas" <tomas.winkler@intel.com>
To: "Joao.Pinto@synopsys.com" <Joao.Pinto@synopsys.com>
Cc: "vinholikatti@gmail.com" <vinholikatti@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"hch@infradead.org" <hch@infradead.org>,
	"akinobu.mita@gmail.com" <akinobu.mita@gmail.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"gbroner@codeaurora.org" <gbroner@codeaurora.org>,
	"subhashj@codeaurora.org" <subhashj@codeaurora.org>,
	"CARLOS.PALMINHA@synopsys.com" <CARLOS.PALMINHA@synopsys.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	"ijc+devicetree@hellion.org.uk" <ijc+devicetree@hellion.org.uk>,
	"julian.calaby@gmail.com" <julian.calaby@gmail.com>,
	"arnd@arndb.de" <arnd@arndb.de>
Subject: Re: [PATCH v12 3/9] added UFS 2.0 capabilities
Date: Thu, 31 Mar 2016 20:27:25 +0000	[thread overview]
Message-ID: <1459455981.23778.31.camel@intel.com> (raw)
In-Reply-To: <40585ae835f02d3b5550a32553b2189754e365b6.1459448160.git.jpinto@synopsys.com>

On Thu, 2016-03-31 at 19:57 +0100, Joao Pinto wrote:
> Adding UFS 2.0 support to the UFS core driver.
> 
> Signed-off-by: Joao Pinto <jpinto@synopsys.com>

Looks good to me, though not tested yet
Tomas

> ---
> Changes v11->v12 (Tomas Winkler):
> - devicetree binding tweak was moved to a separated patch
> - unipro tweaks were moved to a separated patch
> - ufshcd_compose_upiu was decomposed in 2 functions
> - UTP_CMD_TYPE_UFS_STORAGE is now 0x1 (previously was 0x11)
> Changes v8->v11:
> - Nothing changed (just to keep up with patch set version).
> Changes v7->v8:
> - Added "jedec, ufs-2.0" to the ufschd-platform compatibility strings
> Changes v0->v7:
> - Nothing changed (just to keep up with patch set version).
> 
>  drivers/scsi/ufs/ufshcd.c | 90 ++++++++++++++++++++++++++-----------
> ----------
>  drivers/scsi/ufs/ufshci.h |  5 +++
>  2 files changed, 54 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 9c1b94b..a69d637 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -1127,7 +1127,7 @@ static void ufshcd_disable_intr(struct ufs_hba
> *hba, u32 intrs)
>   * @cmd_dir: requests data direction
>   */
>  static void ufshcd_prepare_req_desc_hdr(struct ufshcd_lrb *lrbp,
> -		u32 *upiu_flags, enum dma_data_direction cmd_dir)
> +			u32 *upiu_flags, enum dma_data_direction
> cmd_dir)
>  {
>  	struct utp_transfer_req_desc *req_desc = lrbp
> ->utr_descriptor_ptr;
>  	u32 data_direction;
> @@ -1253,47 +1253,55 @@ static inline void
> ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp)
>  }
>  
>  /**
> - * ufshcd_compose_upiu - form UFS Protocol Information Unit(UPIU)
> + * ufshcd_comp_devman_upiu - UFS Protocol Information Unit(UPIU) 
> + *			     for Device Management Purposes
>   * @hba - per adapter instance
>   * @lrb - pointer to local reference block
>   */
> -static int ufshcd_compose_upiu(struct ufs_hba *hba, struct
> ufshcd_lrb *lrbp)
> +static int ufshcd_comp_devman_upiu(struct ufs_hba *hba, struct
> ufshcd_lrb *lrbp)
>  {
>  	u32 upiu_flags;
>  	int ret = 0;
>  
> -	switch (lrbp->command_type) {
> -	case UTP_CMD_TYPE_SCSI:
> -		if (likely(lrbp->cmd)) {
> -			ufshcd_prepare_req_desc_hdr(lrbp,
> &upiu_flags,
> -					lrbp->cmd
> ->sc_data_direction);
> -			ufshcd_prepare_utp_scsi_cmd_upiu(lrbp,
> upiu_flags);
> -		} else {
> -			ret = -EINVAL;
> -		}
> -		break;
> -	case UTP_CMD_TYPE_DEV_MANAGE:
> -		ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
> DMA_NONE);
> -		if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
> -			ufshcd_prepare_utp_query_req_upiu(
> -					hba, lrbp, upiu_flags);
> -		else if (hba->dev_cmd.type == DEV_CMD_TYPE_NOP)
> -			ufshcd_prepare_utp_nop_upiu(lrbp);
> -		else
> -			ret = -EINVAL;
> -		break;
> -	case UTP_CMD_TYPE_UFS:
> -		/* For UFS native command implementation */
> -		ret = -ENOTSUPP;
> -		dev_err(hba->dev, "%s: UFS native command are not
> supported\n",
> -			__func__);
> -		break;
> -	default:
> -		ret = -ENOTSUPP;
> -		dev_err(hba->dev, "%s: unknown command type:
> 0x%x\n",
> -				__func__, lrbp->command_type);
> -		break;
> -	} /* end of switch */
> +	if (hba->ufs_version == UFSHCI_VERSION_20)
> +		lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
> +	else
> +		lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE;
> +
> +	ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
> +	if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
> +		ufshcd_prepare_utp_query_req_upiu(hba, lrbp,
> upiu_flags);
> +	else if (hba->dev_cmd.type == DEV_CMD_TYPE_NOP)
> +		ufshcd_prepare_utp_nop_upiu(lrbp);
> +	else
> +		ret = -EINVAL;
> +
> +	return ret;
> +}
> +
> +/**
> + * ufshcd_comp_scsi_upiu - UFS Protocol Information Unit(UPIU) 
> + *			   for SCSI Purposes
> + * @hba - per adapter instance
> + * @lrb - pointer to local reference block
> + */
> +static int ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct
> ufshcd_lrb *lrbp)
> +{
> +	u32 upiu_flags;
> +	int ret = 0;
> +
> +	if (hba->ufs_version == UFSHCI_VERSION_20)
> +		lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
> +	else
> +		lrbp->command_type = UTP_CMD_TYPE_SCSI;
> +
> +	if (likely(lrbp->cmd)) {
> +		ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
> +						lrbp->cmd
> ->sc_data_direction);
> +		ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
> +	} else {
> +		ret = -EINVAL;
> +	}
>  
>  	return ret;
>  }
> @@ -1405,10 +1414,9 @@ static int ufshcd_queuecommand(struct
> Scsi_Host *host, struct scsi_cmnd *cmd)
>  	lrbp->task_tag = tag;
>  	lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
>  	lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba) ? true :
> false;
> -	lrbp->command_type = UTP_CMD_TYPE_SCSI;
>  
> -	/* form UPIU before issuing the command */
> -	ufshcd_compose_upiu(hba, lrbp);
> +	ufshcd_comp_scsi_upiu(hba, lrbp);
> +
>  	err = ufshcd_map_sg(lrbp);
>  	if (err) {
>  		lrbp->cmd = NULL;
> @@ -1433,11 +1441,10 @@ static int ufshcd_compose_dev_cmd(struct
> ufs_hba *hba,
>  	lrbp->sense_buffer = NULL;
>  	lrbp->task_tag = tag;
>  	lrbp->lun = 0; /* device management cmd is not specific to
> any LUN */
> -	lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE;
>  	lrbp->intr_cmd = true; /* No interrupt aggregation */
>  	hba->dev_cmd.type = cmd_type;
>  
> -	return ufshcd_compose_upiu(hba, lrbp);
> +	return ufshcd_comp_devman_upiu(hba, lrbp);
>  }
>  
>  static int
> @@ -3403,7 +3410,8 @@ static void ufshcd_transfer_req_compl(struct
> ufs_hba *hba)
>  			/* Do not touch lrbp after scsi done */
>  			cmd->scsi_done(cmd);
>  			__ufshcd_release(hba);
> -		} else if (lrbp->command_type ==
> UTP_CMD_TYPE_DEV_MANAGE) {
> +		} else if (lrbp->command_type ==
> UTP_CMD_TYPE_DEV_MANAGE ||
> +			lrbp->command_type ==
> UTP_CMD_TYPE_UFS_STORAGE) {
>  			if (hba->dev_cmd.complete)
>  				complete(hba->dev_cmd.complete);
>  		}
> diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
> index 0ae0967..20ece18 100644
> --- a/drivers/scsi/ufs/ufshci.h
> +++ b/drivers/scsi/ufs/ufshci.h
> @@ -275,6 +275,11 @@ enum {
>  	UTP_CMD_TYPE_DEV_MANAGE		= 0x2,
>  };
>  
> +/* To accomodate UFS2.0 required Command type */
> +enum {
> +	UTP_CMD_TYPE_UFS_STORAGE	= 0x1,
> +};
> +
>  enum {
>  	UTP_SCSI_COMMAND		= 0x00000000,
>  	UTP_NATIVE_UFS_COMMAND		= 0x10000000,

  reply	other threads:[~2016-03-31 20:27 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-31 18:57 [PATCH v12 0/9] add support for DWC UFS Controller Joao Pinto
2016-03-31 18:57 ` [PATCH v12 1/9] fixed typo in ufshcd-pltfrm Joao Pinto
2016-03-31 18:57 ` [PATCH v12 2/9] add UFS 2.0 to ufshcd-pltfrm bindings Joao Pinto
2016-04-04  5:15   ` Rob Herring
2016-03-31 18:57 ` [PATCH v12 3/9] added UFS 2.0 capabilities Joao Pinto
2016-03-31 20:27   ` Winkler, Tomas [this message]
2016-04-01  9:19     ` Joao Pinto
2016-03-31 18:57 ` [PATCH v12 4/9] added unipro attributes Joao Pinto
     [not found] ` <cover.1459448160.git.jpinto-HKixBCOQz3hWk0Htik3J/w@public.gmane.org>
2016-03-31 18:57   ` [PATCH v12 5/9] added link status to ufshci Joao Pinto
2016-03-31 18:57     ` Joao Pinto
2016-03-31 18:57 ` [PATCH v12 6/9] added support for DesignWare Controller Joao Pinto
2016-04-13 12:19   ` [PATCH v14 " Akinobu Mita
2016-04-13 12:57     ` Joao Pinto
2016-04-13 13:30       ` Akinobu Mita
2016-03-31 18:57 ` [PATCH v12 7/9] added support for Synopsys G210 Test Chip Joao Pinto
2016-03-31 18:57 ` [PATCH v12 8/9] add TC G210 platform driver Joao Pinto
2016-04-04  5:15   ` Rob Herring
2016-04-04 10:48     ` Joao Pinto
2016-04-04 10:48       ` Joao Pinto
2016-04-07 17:57       ` Rob Herring
2016-04-08  9:13         ` Joao Pinto
2016-04-08  9:13           ` Joao Pinto
2016-03-31 18:57 ` [PATCH v12 9/9] add TC G210 pci driver Joao Pinto
2016-04-04 23:34 ` [PATCH v13 0/9] add support for DWC UFS Controller Martin K. Petersen
2016-04-05  9:09   ` Joao Pinto
2016-04-05  9:09     ` Joao Pinto
2016-04-05 10:15     ` Winkler, Tomas
     [not found]       ` <5B8DA87D05A7694D9FA63FD143655C1B541E3FE8-Jy8z56yoSI8MvF1YICWikbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2016-04-05 10:27         ` Joao Pinto
2016-04-05 10:27           ` Joao Pinto
2016-04-15 14:09 ` [PATCH v14 " Hannes Reinecke

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=1459455981.23778.31.camel@intel.com \
    --to=tomas.winkler@intel.com \
    --cc=CARLOS.PALMINHA@synopsys.com \
    --cc=Joao.Pinto@synopsys.com \
    --cc=akinobu.mita@gmail.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=gbroner@codeaurora.org \
    --cc=hch@infradead.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=julian.calaby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=subhashj@codeaurora.org \
    --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.