Re: [PATCH V7 1/6] scsi: ufs: fix endianness sparse warnings

2013-11-18 Thread vinayak holikatti
On Mon, Sep 23, 2013 at 5:44 PM, vinayak holikatti
 wrote:
> On Thu, Sep 19, 2013 at 4:44 PM, Sujit Reddy Thumma
>  wrote:
>>
>> Fix many warnings with incorrect endian assumptions
>> which makes the code unportable to new architectures.
>>
>> The UFS specification defines the byte order as big-endian
>> for UPIU structure and little-endian for the host controller
>> transfer/task management descriptors.
>>
>> Signed-off-by: Sujit Reddy Thumma 
>> ---
>>  drivers/scsi/ufs/ufs.h| 36 ++--
>>  drivers/scsi/ufs/ufshcd.c | 42 --
>>  drivers/scsi/ufs/ufshci.h | 32 
>>  3 files changed, 42 insertions(+), 68 deletions(-)
>>
>> diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
>> index 7210500..f42d1ce 100644
>> --- a/drivers/scsi/ufs/ufs.h
>> +++ b/drivers/scsi/ufs/ufs.h
>> @@ -196,9 +196,9 @@ enum {
>>   * @dword_2: UPIU header DW-2
>>   */
>>  struct utp_upiu_header {
>> -   u32 dword_0;
>> -   u32 dword_1;
>> -   u32 dword_2;
>> +   __be32 dword_0;
>> +   __be32 dword_1;
>> +   __be32 dword_2;
>>  };
>>
>>  /**
>> @@ -207,7 +207,7 @@ struct utp_upiu_header {
>>   * @cdb: Command Descriptor Block CDB DW-4 to DW-7
>>   */
>>  struct utp_upiu_cmd {
>> -   u32 exp_data_transfer_len;
>> +   __be32 exp_data_transfer_len;
>> u8 cdb[MAX_CDB_SIZE];
>>  };
>>
>> @@ -228,10 +228,10 @@ struct utp_upiu_query {
>> u8 idn;
>> u8 index;
>> u8 selector;
>> -   u16 reserved_osf;
>> -   u16 length;
>> -   u32 value;
>> -   u32 reserved[2];
>> +   __be16 reserved_osf;
>> +   __be16 length;
>> +   __be32 value;
>> +   __be32 reserved[2];
>>  };
>>
>>  /**
>> @@ -256,9 +256,9 @@ struct utp_upiu_req {
>>   * @sense_data: Sense data field DW-8 to DW-12
>>   */
>>  struct utp_cmd_rsp {
>> -   u32 residual_transfer_count;
>> -   u32 reserved[4];
>> -   u16 sense_data_len;
>> +   __be32 residual_transfer_count;
>> +   __be32 reserved[4];
>> +   __be16 sense_data_len;
>> u8 sense_data[18];
>>  };
>>
>> @@ -286,10 +286,10 @@ struct utp_upiu_rsp {
>>   */
>>  struct utp_upiu_task_req {
>> struct utp_upiu_header header;
>> -   u32 input_param1;
>> -   u32 input_param2;
>> -   u32 input_param3;
>> -   u32 reserved[2];
>> +   __be32 input_param1;
>> +   __be32 input_param2;
>> +   __be32 input_param3;
>> +   __be32 reserved[2];
>>  };
>>
>>  /**
>> @@ -301,9 +301,9 @@ struct utp_upiu_task_req {
>>   */
>>  struct utp_upiu_task_rsp {
>> struct utp_upiu_header header;
>> -   u32 output_param1;
>> -   u32 output_param2;
>> -   u32 reserved[3];
>> +   __be32 output_param1;
>> +   __be32 output_param2;
>> +   __be32 reserved[3];
>>  };
>>
>>  /**
>> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
>> index 04884d6..064c9d9 100644
>> --- a/drivers/scsi/ufs/ufshcd.c
>> +++ b/drivers/scsi/ufs/ufshcd.c
>> @@ -163,7 +163,7 @@ static inline int ufshcd_is_device_present(u32 reg_hcs)
>>   */
>>  static inline int ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp)
>>  {
>> -   return lrbp->utr_descriptor_ptr->header.dword_2 & MASK_OCS;
>> +   return le32_to_cpu(lrbp->utr_descriptor_ptr->header.dword_2) & 
>> MASK_OCS;
>>  }
>>
>>  /**
>> @@ -176,7 +176,7 @@ static inline int ufshcd_get_tr_ocs(struct ufshcd_lrb 
>> *lrbp)
>>  static inline int
>>  ufshcd_get_tmr_ocs(struct utp_task_req_desc *task_req_descp)
>>  {
>> -   return task_req_descp->header.dword_2 & MASK_OCS;
>> +   return le32_to_cpu(task_req_descp->header.dword_2) & MASK_OCS;
>>  }
>>
>>  /**
>> @@ -390,26 +390,6 @@ static inline void ufshcd_copy_sense_data(struct 
>> ufshcd_lrb *lrbp)
>>  }
>>
>>  /**
>> - * ufshcd_query_to_cpu() - formats the buffer to native cpu endian
>> - * @response: upiu query response to convert
>> - */
>> -static inline void ufshcd_query_to_cpu(struct utp_upiu_query *response)
>> -{
>> -   response->length = be16_to_cpu(response->length);
>> -   response->value = be32_to_cpu(response->value

Re: [PATCH v2] ufs: adjust queue settings to PRDT limitations

2013-10-10 Thread vinayak holikatti
On Wed, Sep 25, 2013 at 7:17 PM, Akinobu Mita  wrote:
> The data byte count field of PRDT indicates the length of data block
> which is a segment of data transfer for SCSI commands.  The value of
> this field shall have Dword granularity and the the maximum of length
> is 256KB.
>
> This adjusts dma pad mask and max segment size to the above-mentioned
> PRDT limitations.
>
> Signed-off-by: Akinobu Mita 
> Cc: Subhash Jadavani 
> Cc: Vinayak Holikatti 
> Cc: Santosh Y 
> Cc: "James E.J. Bottomley" 
> Cc: linux-scsi@vger.kernel.org
> ---
> * Change from v1
> - Add comments for PRDT limitations as suggested by Subhash Jadavani
>
>  drivers/scsi/ufs/ufshcd.c | 15 +++
>  drivers/scsi/ufs/ufshci.h |  5 +
>  2 files changed, 20 insertions(+)
>
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index a2abe9a..660792e 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -1918,6 +1918,20 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev)
>  }
>
>  /**
> + * ufshcd_slave_configure - adjust SCSI device configurations
> + * @sdev: pointer to SCSI device
> + */
> +static int ufshcd_slave_configure(struct scsi_device *sdev)
> +{
> +   struct request_queue *q = sdev->request_queue;
> +
> +   blk_queue_update_dma_pad(q, PRDT_DATA_BYTE_COUNT_PAD - 1);
> +   blk_queue_max_segment_size(q, PRDT_DATA_BYTE_COUNT_MAX);
> +
> +   return 0;
> +}
> +
> +/**
>   * ufshcd_slave_destroy - remove SCSI device configurations
>   * @sdev: pointer to SCSI device
>   */
> @@ -2748,6 +2762,7 @@ static struct scsi_host_template ufshcd_driver_template 
> = {
> .proc_name  = UFSHCD,
> .queuecommand   = ufshcd_queuecommand,
> .slave_alloc= ufshcd_slave_alloc,
> +   .slave_configure= ufshcd_slave_configure,
> .slave_destroy  = ufshcd_slave_destroy,
> .eh_abort_handler   = ufshcd_abort,
> .eh_device_reset_handler = ufshcd_device_reset,
> diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
> index 0475c66..b2b7004 100644
> --- a/drivers/scsi/ufs/ufshci.h
> +++ b/drivers/scsi/ufs/ufshci.h
> @@ -296,6 +296,11 @@ enum {
> MASK_OCS= 0x0F,
>  };
>
> +/* The maximum length of the data byte count field in the PRDT is 256KB */
> +#define PRDT_DATA_BYTE_COUNT_MAX   (256 * 1024)
> +/* The granularity of the data byte count field in the PRDT is 32-bit */
> +#define PRDT_DATA_BYTE_COUNT_PAD   4
> +
>  /**
>   * struct ufshcd_sg_entry - UFSHCI PRD Entry
>   * @base_addr: Lower 32bit physical address DW-0

Acked-by: Vinayak Holikatti 
--
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 V7 6/6] scsi: ufs: Improve UFS fatal error handling

2013-09-23 Thread vinayak holikatti
andler(struct ufs_hba *hba)
> +static void ufshcd_update_uic_error(struct ufs_hba *hba)
>  {
> u32 reg;
>
> +   /* PA_INIT_ERROR is fatal and needs UIC reset */
> +   reg = ufshcd_readl(hba, REG_UIC_ERROR_CODE_DATA_LINK_LAYER);
> +   if (reg & UIC_DATA_LINK_LAYER_ERROR_PA_INIT)
> +   hba->uic_error |= UFSHCD_UIC_DL_PA_INIT_ERROR;
> +
> +   /* UIC NL/TL/DME errors needs software retry */
> +   reg = ufshcd_readl(hba, REG_UIC_ERROR_CODE_NETWORK_LAYER);
> +   if (reg)
> +   hba->uic_error |= UFSHCD_UIC_NL_ERROR;
> +
> +   reg = ufshcd_readl(hba, REG_UIC_ERROR_CODE_TRANSPORT_LAYER);
> +   if (reg)
> +   hba->uic_error |= UFSHCD_UIC_TL_ERROR;
> +
> +   reg = ufshcd_readl(hba, REG_UIC_ERROR_CODE_DME);
> +   if (reg)
> +   hba->uic_error |= UFSHCD_UIC_DME_ERROR;
> +
> +   dev_dbg(hba->dev, "%s: UIC error flags = 0x%08x\n",
> +   __func__, hba->uic_error);
> +}
> +
> +/**
> + * ufshcd_check_errors - Check for errors that need s/w attention
> + * @hba: per-adapter instance
> + */
> +static void ufshcd_check_errors(struct ufs_hba *hba)
> +{
> +   bool queue_eh_work = false;
> +
> if (hba->errors & INT_FATAL_ERRORS)
> -   goto fatal_eh;
> +   queue_eh_work = true;
>
> if (hba->errors & UIC_ERROR) {
> -   reg = ufshcd_readl(hba, REG_UIC_ERROR_CODE_DATA_LINK_LAYER);
> -   if (reg & UIC_DATA_LINK_LAYER_ERROR_PA_INIT)
> -   goto fatal_eh;
> +   hba->uic_error = 0;
> +   ufshcd_update_uic_error(hba);
> +   if (hba->uic_error)
> +   queue_eh_work = true;
> }
> -   return;
> -fatal_eh:
> -   /* handle fatal errors only when link is functional */
> -   if (hba->ufshcd_state == UFSHCD_STATE_OPERATIONAL) {
> -   /* block commands at driver layer until error is handled */
> -   hba->ufshcd_state = UFSHCD_STATE_ERROR;
> -   schedule_work(&hba->feh_workq);
> +
> +   if (queue_eh_work) {
> +   /* handle fatal errors only when link is functional */
> +   if (hba->ufshcd_state == UFSHCD_STATE_OPERATIONAL) {
> +   /* block commands from scsi mid-layer */
> +   scsi_block_requests(hba->host);
> +
> +   /* transfer error masks to sticky bits */
> +   hba->saved_err |= hba->errors;
> +   hba->saved_uic_err |= hba->uic_error;
> +
> +   hba->ufshcd_state = UFSHCD_STATE_ERROR;
> +   schedule_work(&hba->eh_work);
> +   }
> }
> +   /*
> +* if (!queue_eh_work) -
> +* Other errors are either non-fatal where host recovers
> +* itself without s/w intervention or errors that will be
> +* handled by the SCSI core layer.
> +*/
>  }
>
>  /**
> @@ -2514,7 +2567,7 @@ static void ufshcd_sl_intr(struct ufs_hba *hba, u32 
> intr_status)
>  {
> hba->errors = UFSHCD_ERROR_MASK & intr_status;
> if (hba->errors)
> -   ufshcd_err_handler(hba);
> +   ufshcd_check_errors(hba);
>
> if (intr_status & UFSHCD_UIC_MASK)
> ufshcd_uic_cmd_compl(hba, intr_status);
> @@ -2889,12 +2942,12 @@ static int ufshcd_eh_host_reset_handler(struct 
> scsi_cmnd *cmd)
>  */
> do {
> spin_lock_irqsave(hba->host->host_lock, flags);
> -   if (!(work_pending(&hba->feh_workq) ||
> +   if (!(work_pending(&hba->eh_work) ||
> hba->ufshcd_state == UFSHCD_STATE_RESET))
> break;
> spin_unlock_irqrestore(hba->host->host_lock, flags);
> dev_dbg(hba->dev, "%s: reset in progress\n", __func__);
> -   flush_work(&hba->feh_workq);
> +   flush_work(&hba->eh_work);
> } while (1);
>
> hba->ufshcd_state = UFSHCD_STATE_RESET;
> @@ -3130,7 +3183,7 @@ int ufshcd_init(struct device *dev, struct ufs_hba 
> **hba_handle,
> init_waitqueue_head(&hba->tm_tag_wq);
>
>     /* Initialize work queues */
> -   INIT_WORK(&hba->feh_workq, ufshcd_fatal_err_handler);
> +   INIT_WORK(&hba->eh_work, ufshcd_err_handler);
> INIT_WORK(&hba->eeh_work, ufshcd_exception_event_handler);
>
> /* Initialize UIC command mutex */
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 48c7d9b..acf318e 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -183,9 +183,12 @@ struct ufs_dev_cmd {
>   * @eh_flags: Error handling flags
>   * @intr_mask: Interrupt Mask Bits
>   * @ee_ctrl_mask: Exception event control mask
> - * @feh_workq: Work queue for fatal controller error handling
> + * @eh_work: Worker to handle UFS errors that require s/w attention
>   * @eeh_work: Worker to handle exception events
>   * @errors: HBA errors
> + * @uic_error: UFS interconnect layer error status
> + * @saved_err: sticky error mask
> + * @saved_uic_err: sticky UIC error mask
>   * @dev_cmd: ufs device management command information
>   * @auto_bkops_enabled: to track whether bkops is enabled in device
>   */
> @@ -233,11 +236,14 @@ struct ufs_hba {
> u16 ee_ctrl_mask;
>
> /* Work Queues */
> -   struct work_struct feh_workq;
> +   struct work_struct eh_work;
> struct work_struct eeh_work;
>
> /* HBA Errors */
> u32 errors;
> +   u32 uic_error;
> +   u32 saved_err;
> +   u32 saved_uic_err;
>
> /* Device management request data */
> struct ufs_dev_cmd dev_cmd;

Acked-by: Vinayak Holikatti 
--
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 V7 5/6] scsi: ufs: Fix device and host reset methods

2013-09-23 Thread vinayak holikatti
ailed %d\n", __func__, err);
> +
> +   return err;
> +}
> +
> +/**
> + * ufshcd_reset_and_restore - reset and re-initialize host/device
> + * @hba: per-adapter instance
> + *
> + * Reset and recover device, host and re-establish link. This
> + * is helpful to recover the communication in fatal error conditions.
> + *
> + * Returns zero on success, non-zero on failure
> + */
> +static int ufshcd_reset_and_restore(struct ufs_hba *hba)
> +{
> +   int err = 0;
> +   unsigned long flags;
> +
> +   err = ufshcd_host_reset_and_restore(hba);
> +
> +   /*
> +* After reset the door-bell might be cleared, complete
> +* outstanding requests in s/w here.
> +*/
> +   spin_lock_irqsave(hba->host->host_lock, flags);
> +   ufshcd_transfer_req_compl(hba);
> +   ufshcd_tmc_handler(hba);
> +   spin_unlock_irqrestore(hba->host->host_lock, flags);
> +
> +   return err;
> +}
> +
> +/**
> + * ufshcd_eh_host_reset_handler - host reset handler registered to scsi layer
> + * @cmd - SCSI command pointer
> + *
> + * Returns SUCCESS/FAILED
> + */
> +static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd)
> +{
> +   int err;
> +   unsigned long flags;
> +   struct ufs_hba *hba;
> +
> +   hba = shost_priv(cmd->device->host);
> +
> +   /*
> +* Check if there is any race with fatal error handling.
> +* If so, wait for it to complete. Even though fatal error
> +* handling does reset and restore in some cases, don't assume
> +* anything out of it. We are just avoiding race here.
> +*/
> +   do {
> +   spin_lock_irqsave(hba->host->host_lock, flags);
> +   if (!(work_pending(&hba->feh_workq) ||
> +   hba->ufshcd_state == UFSHCD_STATE_RESET))
> +   break;
> +   spin_unlock_irqrestore(hba->host->host_lock, flags);
> +   dev_dbg(hba->dev, "%s: reset in progress\n", __func__);
> +   flush_work(&hba->feh_workq);
> +   } while (1);
> +
> +   hba->ufshcd_state = UFSHCD_STATE_RESET;
> +   ufshcd_set_eh_in_progress(hba);
> +   spin_unlock_irqrestore(hba->host->host_lock, flags);
> +
> +   err = ufshcd_reset_and_restore(hba);
> +
> +   spin_lock_irqsave(hba->host->host_lock, flags);
> +   if (!err) {
> +   err = SUCCESS;
> +   hba->ufshcd_state = UFSHCD_STATE_OPERATIONAL;
> +   } else {
> +   err = FAILED;
> +   hba->ufshcd_state = UFSHCD_STATE_ERROR;
> +   }
> +   ufshcd_clear_eh_in_progress(hba);
> +   spin_unlock_irqrestore(hba->host->host_lock, flags);
> +
> +   return err;
> +}
> +
> +/**
>   * ufshcd_async_scan - asynchronous execution for link startup
>   * @data: data pointer to pass to this function
>   * @cookie: cookie data
> @@ -2813,8 +2942,13 @@ static void ufshcd_async_scan(void *data, 
> async_cookie_t cookie)
> goto out;
>
> ufshcd_force_reset_auto_bkops(hba);
> -   scsi_scan_host(hba->host);
> -   pm_runtime_put_sync(hba->dev);
> +   hba->ufshcd_state = UFSHCD_STATE_OPERATIONAL;
> +
> +   /* If we are in error handling context no need to scan the host */
> +   if (!ufshcd_eh_in_progress(hba)) {
> +   scsi_scan_host(hba->host);
> +   pm_runtime_put_sync(hba->dev);
> +   }
>  out:
> return;
>  }
> @@ -2827,8 +2961,8 @@ static struct scsi_host_template ufshcd_driver_template 
> = {
> .slave_alloc= ufshcd_slave_alloc,
> .slave_destroy  = ufshcd_slave_destroy,
> .eh_abort_handler   = ufshcd_abort,
> -   .eh_device_reset_handler = ufshcd_device_reset,
> -   .eh_host_reset_handler  = ufshcd_host_reset,
> +   .eh_device_reset_handler = ufshcd_eh_device_reset_handler,
> +   .eh_host_reset_handler   = ufshcd_eh_host_reset_handler,
> .this_id= -1,
> .sg_tablesize   = SG_ALL,
> .cmd_per_lun= UFSHCD_CMD_PER_LUN,
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 84d09d1..48c7d9b 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -180,6 +180,7 @@ struct ufs_dev_cmd {
>   * @pwr_done: completion for power mode change
>   * @tm_condition: condition variable for task management
>   * @ufshcd_state: UFSHCD states
> + * @eh_flags: Error handling flags
>   * @intr_mask: Interrupt Mask Bits
>   * @ee_ctrl_mask: Exception event control mask
>   * @feh_workq: Work queue for fatal controller error handling
> @@ -227,6 +228,7 @@ struct ufs_hba {
> struct completion *pwr_done;
>
> u32 ufshcd_state;
> +   u32 eh_flags;
> u32 intr_mask;
> u16 ee_ctrl_mask;
>

Acked-by: Vinayak Holikatti 
--
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 V7 3/6] scsi: ufs: Fix broken task management command implementation

2013-09-23 Thread vinayak holikatti
task_req_upiup->input_param2 = cpu_to_be32(task_id);
>
> /* send command to the controller */
> __set_bit(free_slot, &hba->outstanding_tasks);
> @@ -2556,20 +2599,24 @@ ufshcd_issue_tm_cmd(struct ufs_hba *hba,
> spin_unlock_irqrestore(host->host_lock, flags);
>
> /* wait until the task management command is completed */
> -   err =
> -   wait_event_interruptible_timeout(hba->ufshcd_tm_wait_queue,
> -(test_bit(free_slot,
> -&hba->tm_condition) != 0),
> -60 * HZ);
> +   err = wait_event_timeout(hba->tm_wq,
> +   test_bit(free_slot, &hba->tm_condition),
> +   msecs_to_jiffies(TM_CMD_TIMEOUT));
> if (!err) {
> -   dev_err(hba->dev,
> -   "Task management command timed-out\n");
> -   err = FAILED;
> -   goto out;
> +   dev_err(hba->dev, "%s: task management cmd 0x%.2x 
> timed-out\n",
> +   __func__, tm_function);
> +   if (ufshcd_clear_tm_cmd(hba, free_slot))
> +   dev_WARN(hba->dev, "%s: unable clear tm cmd (slot %d) 
> after timeout\n",
> +   __func__, free_slot);
> +   err = -ETIMEDOUT;
> +   } else {
> +   err = ufshcd_task_req_compl(hba, free_slot, tm_response);
> }
> +
> clear_bit(free_slot, &hba->tm_condition);
> -   err = ufshcd_task_req_compl(hba, free_slot);
> -out:
> +   ufshcd_put_tm_slot(hba, free_slot);
> +   wake_up(&hba->tm_tag_wq);
> +
> return err;
>  }
>
> @@ -2586,14 +2633,21 @@ static int ufshcd_device_reset(struct scsi_cmnd *cmd)
> unsigned int tag;
> u32 pos;
> int err;
> +   u8 resp = 0xF;
> +   struct ufshcd_lrb *lrbp;
>
> host = cmd->device->host;
> hba = shost_priv(host);
> tag = cmd->request->tag;
>
> -   err = ufshcd_issue_tm_cmd(hba, &hba->lrb[tag], UFS_LOGICAL_RESET);
> -   if (err == FAILED)
> +   lrbp = &hba->lrb[tag];
> +   err = ufshcd_issue_tm_cmd(hba, lrbp->lun, 0, UFS_LOGICAL_RESET, 
> &resp);
> +   if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) {
> +   err = FAILED;
> goto out;
> +   } else {
> +   err = SUCCESS;
> +   }
>
> for (pos = 0; pos < hba->nutrs; pos++) {
> if (test_bit(pos, &hba->outstanding_reqs) &&
> @@ -2650,6 +2704,8 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
> unsigned long flags;
> unsigned int tag;
> int err;
> +   u8 resp = 0xF;
> +   struct ufshcd_lrb *lrbp;
>
> host = cmd->device->host;
> hba = shost_priv(host);
> @@ -2665,9 +2721,15 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
> }
> spin_unlock_irqrestore(host->host_lock, flags);
>
> -   err = ufshcd_issue_tm_cmd(hba, &hba->lrb[tag], UFS_ABORT_TASK);
> -   if (err == FAILED)
> +   lrbp = &hba->lrb[tag];
> +   err = ufshcd_issue_tm_cmd(hba, lrbp->lun, lrbp->task_tag,
> +   UFS_ABORT_TASK, &resp);
> +   if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) {
> +   err = FAILED;
> goto out;
> +   } else {
> +   err = SUCCESS;
> +   }
>
> scsi_dma_unmap(cmd);
>
> @@ -2890,7 +2952,8 @@ int ufshcd_init(struct device *dev, struct ufs_hba 
> **hba_handle,
> host->max_cmd_len = MAX_CDB_SIZE;
>
> /* Initailize wait queue for task management */
> -   init_waitqueue_head(&hba->ufshcd_tm_wait_queue);
> +   init_waitqueue_head(&hba->tm_wq);
> +   init_waitqueue_head(&hba->tm_tag_wq);
>
> /* Initialize work queues */
> INIT_WORK(&hba->feh_workq, ufshcd_fatal_err_handler);
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 767ee9e..84d09d1 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -174,7 +174,9 @@ struct ufs_dev_cmd {
>   * @irq: Irq number of the controller
>   * @active_uic_cmd: handle of active UIC command
>   * @uic_cmd_mutex: mutex for uic command
> - * @ufshcd_tm_wait_queue: wait queue for task management
> + * @tm_wq: wait queue for task management
> + * @tm_tag_wq: wait queue for free task management slots
> + * @tm_slots_in_use: bit map of task management request slots in use
>   * @pwr_done: completion for power mode change
>   * @tm_condition: condition variable for task management
>   * @ufshcd_state: UFSHCD states
> @@ -217,8 +219,10 @@ struct ufs_hba {
> struct uic_command *active_uic_cmd;
> struct mutex uic_cmd_mutex;
>
> -   wait_queue_head_t ufshcd_tm_wait_queue;
> +   wait_queue_head_t tm_wq;
> +   wait_queue_head_t tm_tag_wq;
> unsigned long tm_condition;
> +   unsigned long tm_slots_in_use;
>
> struct completion *pwr_done;
>
Acked-by: Vinayak Holikatti 
--
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 V7 4/6] scsi: ufs: Fix hardware race conditions while aborting a command

2013-09-23 Thread vinayak holikatti
ASK, &resp);
> if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) {
> -   err = FAILED;
> +   if (!err)
> +   err = resp; /* service response error */
> goto out;
> -   } else {
> -   err = SUCCESS;
> }
>
> +   err = ufshcd_clear_cmd(hba, tag);
> +   if (err)
> +   goto out;
> +
> scsi_dma_unmap(cmd);
>
> spin_lock_irqsave(host->host_lock, flags);
> -
> -   /* clear the respective UTRLCLR register bit */
> -   ufshcd_utrl_clear(hba, tag);
> -
> __clear_bit(tag, &hba->outstanding_reqs);
> hba->lrb[tag].cmd = NULL;
> spin_unlock_irqrestore(host->host_lock, flags);
> @@ -2745,6 +2778,13 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
> clear_bit_unlock(tag, &hba->lrb_in_use);
> wake_up(&hba->dev_cmd.tag_wq);
>  out:
> +   if (!err) {
> +   err = SUCCESS;
> +   } else {
> +   dev_err(hba->dev, "%s: failed with err %d\n", __func__, err);
> +   err = FAILED;
> +   }
> +
> return err;
>  }
>
Acked-by: Vinayak Holikatti 
--
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 V7 2/6] scsi: ufs: make undeclared functions static

2013-09-23 Thread vinayak holikatti
On Thu, Sep 19, 2013 at 4:44 PM, Sujit Reddy Thumma
 wrote:
> Make undeclared functions static and declare exported symbols
> to suppress warnings from sparse tool.
>
> Signed-off-by: Sujit Reddy Thumma 
> ---
>  drivers/scsi/ufs/ufshcd.c | 4 ++--
>  drivers/scsi/ufs/ufshcd.h | 2 ++
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 064c9d9..d476cc3 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -1148,7 +1148,7 @@ out_unlock:
>   *
>   * Returns 0 for success, non-zero in case of failure
>  */
> -int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
> +static int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
> enum attr_idn idn, u8 index, u8 selector, u32 
> *attr_val)
>  {
> struct ufs_query_req *request;
> @@ -1459,7 +1459,7 @@ EXPORT_SYMBOL_GPL(ufshcd_dme_get_attr);
>   *
>   * Returns 0 on success, non-zero value on failure
>   */
> -int ufshcd_uic_change_pwr_mode(struct ufs_hba *hba, u8 mode)
> +static int ufshcd_uic_change_pwr_mode(struct ufs_hba *hba, u8 mode)
>  {
> struct uic_command uic_cmd = {0};
> struct completion pwr_done;
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 577679a..767ee9e 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -263,6 +263,8 @@ static inline void check_upiu_size(void)
> GENERAL_UPIU_REQUEST_SIZE + QUERY_DESC_MAX_SIZE);
>  }
>
> +extern int ufshcd_suspend(struct ufs_hba *hba, pm_message_t state);
> +extern int ufshcd_resume(struct ufs_hba *hba);
>  extern int ufshcd_runtime_suspend(struct ufs_hba *hba);
>  extern int ufshcd_runtime_resume(struct ufs_hba *hba);
>  extern int ufshcd_runtime_idle(struct ufs_hba *hba);
>

Acked-by: Vinayak Holikatti 
--
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 V7 1/6] scsi: ufs: fix endianness sparse warnings

2013-09-23 Thread vinayak holikatti
 ufs_hba *hba, 
> struct ufshcd_lrb *lrbp)
> UPIU_RSP_CODE_OFFSET;
>
> memcpy(&query_res->upiu_res, &lrbp->ucd_rsp_ptr->qr, QUERY_OSF_SIZE);
> -   ufshcd_query_to_cpu(&query_res->upiu_res);
>
>
> /* Get the descriptor */
> @@ -749,7 +728,7 @@ static void ufshcd_prepare_utp_query_req_upiu(struct 
> ufs_hba *hba,
>  {
> struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;
> struct ufs_query *query = &hba->dev_cmd.query;
> -   u16 len = query->request.upiu_req.length;
> +   u16 len = be16_to_cpu(query->request.upiu_req.length);
> u8 *descp = (u8 *)lrbp->ucd_req_ptr + GENERAL_UPIU_REQUEST_SIZE;
>
> /* Query request header */
> @@ -766,7 +745,6 @@ static void ufshcd_prepare_utp_query_req_upiu(struct 
> ufs_hba *hba,
> /* Copy the Query Request buffer as is */
> memcpy(&ucd_req_ptr->qr, &query->request.upiu_req,
> QUERY_OSF_SIZE);
> -   ufshcd_query_to_be(&ucd_req_ptr->qr);
>
> /* Copy the Descriptor */
> if ((len > 0) && (query->request.upiu_req.opcode ==
> @@ -1151,7 +1129,7 @@ static int ufshcd_query_flag(struct ufs_hba *hba, enum 
> query_opcode opcode,
> }
>
> if (flag_res)
> -   *flag_res = (response->upiu_res.value &
> +   *flag_res = (be32_to_cpu(response->upiu_res.value) &
> MASK_QUERY_UPIU_FLAG_LOC) & 0x1;
>
>  out_unlock:
> @@ -1195,7 +1173,7 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum 
> query_opcode opcode,
> switch (opcode) {
> case UPIU_QUERY_OPCODE_WRITE_ATTR:
> request->query_func = UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST;
> -   request->upiu_req.value = *attr_val;
> +   request->upiu_req.value = cpu_to_be32(*attr_val);
> break;
> case UPIU_QUERY_OPCODE_READ_ATTR:
> request->query_func = UPIU_QUERY_FUNC_STANDARD_READ_REQUEST;
> @@ -1222,7 +1200,7 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum 
> query_opcode opcode,
> goto out_unlock;
> }
>
> -   *attr_val = response->upiu_res.value;
> +   *attr_val = be32_to_cpu(response->upiu_res.value);
>
>  out_unlock:
> mutex_unlock(&hba->dev_cmd.lock);
> @@ -2568,12 +2546,8 @@ ufshcd_issue_tm_cmd(struct ufs_hba *hba,
> task_req_upiup->header.dword_1 =
> UPIU_HEADER_DWORD(0, tm_function, 0, 0);
>
> -   task_req_upiup->input_param1 = lrbp->lun;
> -   task_req_upiup->input_param1 =
> -   cpu_to_be32(task_req_upiup->input_param1);
> -   task_req_upiup->input_param2 = lrbp->task_tag;
> -   task_req_upiup->input_param2 =
> -   cpu_to_be32(task_req_upiup->input_param2);
> +   task_req_upiup->input_param1 = cpu_to_be32(lrbp->lun);
> +   task_req_upiup->input_param2 = cpu_to_be32(lrbp->task_tag);
>
> /* send command to the controller */
> __set_bit(free_slot, &hba->outstanding_tasks);
> diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
> index 0475c66..9abc7e3 100644
> --- a/drivers/scsi/ufs/ufshci.h
> +++ b/drivers/scsi/ufs/ufshci.h
> @@ -304,10 +304,10 @@ enum {
>   * @size: size of physical segment DW-3
>   */
>  struct ufshcd_sg_entry {
> -   u32base_addr;
> -   u32upper_addr;
> -   u32reserved;
> -   u32size;
> +   __le32base_addr;
> +   __le32upper_addr;
> +   __le32reserved;
> +   __le32size;
>  };
>
>  /**
> @@ -330,10 +330,10 @@ struct utp_transfer_cmd_desc {
>   * @dword3: Descriptor Header DW3
>   */
>  struct request_desc_header {
> -   u32 dword_0;
> -   u32 dword_1;
> -   u32 dword_2;
> -   u32 dword_3;
> +   __le32 dword_0;
> +   __le32 dword_1;
> +   __le32 dword_2;
> +   __le32 dword_3;
>  };
>
>  /**
> @@ -352,16 +352,16 @@ struct utp_transfer_req_desc {
> struct request_desc_header header;
>
> /* DW 4-5*/
> -   u32  command_desc_base_addr_lo;
> -   u32  command_desc_base_addr_hi;
> +   __le32  command_desc_base_addr_lo;
> +   __le32  command_desc_base_addr_hi;
>
> /* DW 6 */
> -   u16  response_upiu_length;
> -   u16  response_upiu_offset;
> +   __le16  response_upiu_length;
> +   __le16  response_upiu_offset;
>
> /* DW 7 */
> -   u16  prd_table_length;
> -   u16  prd_table_offset;
> +   __le16  prd_table_length;
> +   __le16  prd_table_offset;
>  };
>
>  /**
> @@ -376,10 +376,10 @@ struct utp_task_req_desc {
> struct request_desc_header header;
>
> /* DW 4-11 */
> -   u32 task_req_upiu[TASK_REQ_UPIU_SIZE_DWORDS];
> +   __le32 task_req_upiu[TASK_REQ_UPIU_SIZE_DWORDS];
>
> /* DW 12-19 */
> -   u32 task_rsp_upiu[TASK_RSP_UPIU_SIZE_DWORDS];
> +   __le32 task_rsp_upiu[TASK_RSP_UPIU_SIZE_DWORDS];
>  };
>
>  #endif /* End of Header */
>
Acked-by: Vinayak Holikatti 
--
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 V6 Resend2 2/2] [SCSI] ufs: Correct the expected data transfersize

2013-02-26 Thread Vinayak Holikatti
This patch corrects the expected data transfer size of the
command UPIU. The current implementation of cmd->transfersize
is wrong as it probably equal to sector size. With this
implementation the transfer size is updated correctly

Reported-by: KOBAYASHI Yoshitake 
Reviewed-by: Arnd Bergmann 
Reviewed-by: Namjae Jeon 
Reviewed-by: Subhash Jadavani 
Tested-by: Maya Erez 
Signed-off-by: Santosh Yaraganavi 
Signed-off-by: Vinayak Holikatti 
---
 drivers/scsi/ufs/ufshcd.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 60fd40c..c32a478 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -478,7 +478,7 @@ static void ufshcd_compose_upiu(struct ufshcd_lrb *lrbp)
ucd_cmd_ptr->header.dword_2 = 0;
 
ucd_cmd_ptr->exp_data_transfer_len =
-   cpu_to_be32(lrbp->cmd->transfersize);
+   cpu_to_be32(lrbp->cmd->sdb.length);
 
memcpy(ucd_cmd_ptr->cdb,
   lrbp->cmd->cmnd,
-- 
1.7.5.4

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


[PATCH V6 Resend2 1/2] [SCSI] ufs: Add Platform glue driver for ufshcd

2013-02-26 Thread Vinayak Holikatti
This patch adds Platform glue driver for ufshcd.

Reviewed-by: Arnd Bergmann 
Reviewed-by: Namjae Jeon 
Reviewed-by: Subhash Jadavani 
Reviewed-by: Sujit Reddy Thumma 
Tested-by: Maya Erez 
Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/Kconfig |   11 ++
 drivers/scsi/ufs/Makefile|1 +
 drivers/scsi/ufs/ufshcd-pltfrm.c |  217 ++
 3 files changed, 229 insertions(+), 0 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.c

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 0371047..35faf24 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -57,3 +57,14 @@ config SCSI_UFSHCD_PCI
  If you have a controller with this interface, say Y or M here.
 
  If unsure, say N.
+
+config SCSI_UFSHCD_PLATFORM
+   tristate "Platform bus based UFS Controller support"
+   depends on SCSI_UFSHCD
+   ---help---
+   This selects the UFS host controller support. Select this if
+   you have an UFS controller on Platform bus.
+
+   If you have a controller with this interface, say Y or M here.
+
+ If unsure, say N.
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 9eda0df..1e5bd48 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,3 +1,4 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
+obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
new file mode 100644
index 000..03319ac
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -0,0 +1,217 @@
+/*
+ * Universal Flash Storage Host controller Platform bus based glue driver
+ *
+ * This code is based on drivers/scsi/ufs/ufshcd-pltfrm.c
+ * Copyright (C) 2011-2013 Samsung India Software Operations
+ *
+ * Authors:
+ * Santosh Yaraganavi 
+ *     Vinayak Holikatti 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * See the COPYING file in the top-level directory or visit
+ * <http://www.gnu.org/licenses/gpl-2.0.html>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This program is provided "AS IS" and "WITH ALL FAULTS" and
+ * without warranty of any kind. You are solely responsible for
+ * determining the appropriateness of using and distributing
+ * the program and assume all risks associated with your exercise
+ * of rights with respect to the program, including but not limited
+ * to infringement of third party rights, the risks and costs of
+ * program errors, damage to or loss of data, programs or equipment,
+ * and unavailability or interruption of operations. Under no
+ * circumstances will the contributor of this Program be liable for
+ * any damages of any kind arising from your use or distribution of
+ * this program.
+ */
+
+#include "ufshcd.h"
+#include 
+
+#ifdef CONFIG_PM
+/**
+ * ufshcd_pltfrm_suspend - suspend power management function
+ * @dev: pointer to device handle
+ *
+ *
+ * Returns 0
+ */
+static int ufshcd_pltfrm_suspend(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct ufs_hba *hba =  platform_get_drvdata(pdev);
+
+   /*
+* TODO:
+* 1. Call ufshcd_suspend
+* 2. Do bus specific power management
+*/
+
+   disable_irq(hba->irq);
+
+   return 0;
+}
+
+/**
+ * ufshcd_pltfrm_resume - resume power management function
+ * @dev: pointer to device handle
+ *
+ * Returns 0
+ */
+static int ufshcd_pltfrm_resume(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct ufs_hba *hba =  platform_get_drvdata(pdev);
+
+   /*
+* TODO:
+* 1. Call ufshcd_resume.
+* 2. Do bus specific wake up
+*/
+
+   enable_irq(hba->irq);
+
+   return 0;
+}
+#else
+#define ufshcd_pltfrm_suspend  NULL
+#define ufshcd_pltfrm_resume   NULL
+#endif
+
+/**
+ * ufshcd_pltfrm_probe - probe routine of the driver
+ * @pdev: pointer to Platform device handle
+ *
+ * Returns 0 on success, non-zero value on failure
+ */
+static int ufshcd_pltfrm_probe(struct platform_device *pdev)
+{
+   struct ufs_hba *hba;
+   void __iomem *mmio_base;
+   struct resource *mem_res;
+   struct resource *irq_res;
+   resource_size_t mem_size;
+   int err;
+   struct device *dev = &pdev->dev;
+
+   mem_res = platform_get_resource(pdev, IORESOUR

Re: [PATCH V6 Resend 0/4] [SCSI] ufs: Adds glue drivers to ufshcd

2013-02-25 Thread vinayak holikatti
James,

I have rebased these patches with top scsi-misc tree.


On Mon, Feb 25, 2013 at 9:44 PM, Vinayak Holikatti
 wrote:
> This patch set adds following features
>  - Seggregate PCI specific code in ufshcd.c and corrected copyright
>  - Adds PCI glue driver ufshcd-pci.c and ufshcd.c become core module
>  - Adds Platform glue driver ufshcd-pltfrm.c
>  - Update correct transfer size in Command UPIU
>
> Vinayak Holikatti (4):
>   [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code
>   [SCSI] drivers/scsi/ufs: Separate PCI code into glue driver
>   [SCSI] ufs: Add Platform glue driver for ufshcd
>   [SCSI] ufs: Correct the expected data transfersize
>
>  drivers/scsi/ufs/Kconfig |   87 +---
>  drivers/scsi/ufs/Makefile|2 +
>  drivers/scsi/ufs/ufs.h   |   44 ++---
>  drivers/scsi/ufs/ufshcd-pci.c|  211 +++
>  drivers/scsi/ufs/ufshcd-pltfrm.c |  217 +++
>  drivers/scsi/ufs/ufshcd.c|  425 
> --
>  drivers/scsi/ufs/ufshcd.h|  202 ++
>  drivers/scsi/ufs/ufshci.h|   44 ++---
>  8 files changed, 811 insertions(+), 421 deletions(-)
>  create mode 100644 drivers/scsi/ufs/ufshcd-pci.c
>  create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.c
>  create mode 100644 drivers/scsi/ufs/ufshcd.h
>
> --
> 1.7.5.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V6 Resend 4/4] [SCSI] ufs: Correct the expected data transfersize

2013-02-25 Thread Vinayak Holikatti
This patch corrects the expected data transfer size of the
command UPIU. The current implementation of cmd->transfersize
is wrong as it probably equal to sector size. With this
implementation the transfer size is updated correctly

Reported-by: KOBAYASHI Yoshitake 
Reviewed-by: Arnd Bergmann 
Reviewed-by: Namjae Jeon 
Reviewed-by: Subhash Jadavani 
Tested-by: Maya Erez 
Signed-off-by: Santosh Yaraganavi 
Signed-off-by: Vinayak Holikatti 
---
 drivers/scsi/ufs/ufshcd.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 60fd40c..c32a478 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -478,7 +478,7 @@ static void ufshcd_compose_upiu(struct ufshcd_lrb *lrbp)
ucd_cmd_ptr->header.dword_2 = 0;
 
ucd_cmd_ptr->exp_data_transfer_len =
-   cpu_to_be32(lrbp->cmd->transfersize);
+   cpu_to_be32(lrbp->cmd->sdb.length);
 
memcpy(ucd_cmd_ptr->cdb,
   lrbp->cmd->cmnd,
-- 
1.7.5.4

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


[PATCH V6 Resend 3/4] [SCSI] ufs: Add Platform glue driver for ufshcd

2013-02-25 Thread Vinayak Holikatti
This patch adds Platform glue driver for ufshcd.

Reviewed-by: Arnd Bergmann 
Reviewed-by: Namjae Jeon 
Reviewed-by: Subhash Jadavani 
Reviewed-by: Sujit Reddy Thumma 
Tested-by: Maya Erez 
Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/Kconfig |   11 ++
 drivers/scsi/ufs/Makefile|1 +
 drivers/scsi/ufs/ufshcd-pltfrm.c |  217 ++
 3 files changed, 229 insertions(+), 0 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.c

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 0371047..35faf24 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -57,3 +57,14 @@ config SCSI_UFSHCD_PCI
  If you have a controller with this interface, say Y or M here.
 
  If unsure, say N.
+
+config SCSI_UFSHCD_PLATFORM
+   tristate "Platform bus based UFS Controller support"
+   depends on SCSI_UFSHCD
+   ---help---
+   This selects the UFS host controller support. Select this if
+   you have an UFS controller on Platform bus.
+
+   If you have a controller with this interface, say Y or M here.
+
+ If unsure, say N.
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 9eda0df..1e5bd48 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,3 +1,4 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
+obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
new file mode 100644
index 000..a661b31
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -0,0 +1,217 @@
+/*
+ * Universal Flash Storage Host controller Platform bus based glue driver
+ *
+ * This code is based on drivers/scsi/ufs/ufshcd-pltfrm.c
+ * Copyright (C) 2011-2013 Samsung India Software Operations
+ *
+ * Authors:
+ * Santosh Yaraganavi 
+ *     Vinayak Holikatti 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * See the COPYING file in the top-level directory or visit
+ * <http://www.gnu.org/licenses/gpl-2.0.html>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This program is provided "AS IS" and "WITH ALL FAULTS" and
+ * without warranty of any kind. You are solely responsible for
+ * determining the appropriateness of using and distributing
+ * the program and assume all risks associated with your exercise
+ * of rights with respect to the program, including but not limited
+ * to infringement of third party rights, the risks and costs of
+ * program errors, damage to or loss of data, programs or equipment,
+ * and unavailability or interruption of operations. Under no
+ * circumstances will the contributor of this Program be liable for
+ * any damages of any kind arising from your use or distribution of
+ * this program.
+ */
+
+#include "ufshcd.h"
+#include 
+
+#ifdef CONFIG_PM
+/**
+ * ufshcd_pltfrm_suspend - suspend power management function
+ * @pdev: pointer to Platform device handle
+ * @mesg: power state
+ *
+ * Returns 0
+ */
+static int ufshcd_pltfrm_suspend(struct platform_device *pdev,
+pm_message_t mesg)
+{
+   struct ufs_hba *hba =  platform_get_drvdata(pdev);
+
+   /*
+* TODO:
+* 1. Call ufshcd_suspend
+* 2. Do bus specific power management
+*/
+
+   disable_irq(hba->irq);
+
+   return 0;
+}
+
+/**
+ * ufshcd_pltfrm_resume - resume power management function
+ * @pdev: pointer to Platform device handle
+ *
+ * Returns 0
+ */
+static int ufshcd_pltfrm_resume(struct platform_device *pdev)
+{
+   struct ufs_hba *hba =  platform_get_drvdata(pdev);
+
+   /*
+* TODO:
+* 1. Call ufshcd_resume.
+* 2. Do bus specific wake up
+*/
+
+   enable_irq(hba->irq);
+
+   return 0;
+}
+#else
+#define ufshcd_pltfrm_suspend  NULL
+#define ufshcd_pltfrm_resume   NULL
+#endif
+
+/**
+ * ufshcd_pltfrm_probe - probe routine of the driver
+ * @pdev: pointer to Platform device handle
+ *
+ * Returns 0 on success, non-zero value on failure
+ */
+static int __devinit
+ufshcd_pltfrm_probe(struct platform_device *pdev)
+{
+   struct ufs_hba *hba;
+   void __iomem *mmio_base;
+   struct resource *mem_res;
+   struct resource *irq_res;
+   resource_size_t mem_size;
+   int err;
+   struct device *dev = &pdev->dev;
+
+   mem_res = platform_get_resource(pdev, IORESOURCE_MEM

[PATCH V6 Resend 2/4] [SCSI] drivers/scsi/ufs: Separate PCI code into glue driver

2013-02-25 Thread Vinayak Holikatti
This patch separates PCI code from ufshcd.c and makes it as a
core driver module and adds a new file ufshcd-pci.c as PCI glue
driver.

Reviewed-by: Arnd Bergmann 
Reviewed-by: Namjae Jeon 
Reviewed-by: Subhash Jadavani 
Tested-by: Maya Erez 
Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/Kconfig  |   26 +++-
 drivers/scsi/ufs/Makefile |1 +
 drivers/scsi/ufs/ufshcd-pci.c |  211 ++
 drivers/scsi/ufs/ufshcd.c |  327 +
 drivers/scsi/ufs/ufshcd.h |  202 +
 5 files changed, 440 insertions(+), 327 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pci.c
 create mode 100644 drivers/scsi/ufs/ufshcd.h

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 8ee40df..0371047 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -33,7 +33,27 @@
 # this program.
 
 config SCSI_UFSHCD
-   tristate "Universal Flash Storage host controller driver"
-   depends on PCI && SCSI
+   tristate "Universal Flash Storage Controller Driver Core"
+   depends on SCSI
---help---
-   This is a generic driver which supports PCIe UFS Host controllers.
+   This selects the support for UFS devices in Linux, say Y and make
+ sure that you know the name of your UFS host adapter (the card
+ inside your computer that "speaks" the UFS protocol, also
+ called UFS Host Controller), because you will be asked for it.
+ The module will be called ufshcd.
+
+ To compile this driver as a module, choose M here and read
+ .
+ However, do not compile this as a module if your root file system
+ (the one containing the directory /) is located on a UFS device.
+
+config SCSI_UFSHCD_PCI
+   tristate "PCI bus based UFS Controller support"
+   depends on SCSI_UFSHCD && PCI
+   ---help---
+   This selects the PCI UFS Host Controller Interface. Select this if
+   you have UFS Host Controller with PCI Interface.
+
+ If you have a controller with this interface, say Y or M here.
+
+ If unsure, say N.
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index adf7895..9eda0df 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,2 +1,3 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
+obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
new file mode 100644
index 000..ae30691
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -0,0 +1,211 @@
+/*
+ * Universal Flash Storage Host controller PCI glue driver
+ *
+ * This code is based on drivers/scsi/ufs/ufshcd-pci.c
+ * Copyright (C) 2011-2013 Samsung India Software Operations
+ *
+ * Authors:
+ * Santosh Yaraganavi 
+ * Vinayak Holikatti 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * See the COPYING file in the top-level directory or visit
+ * <http://www.gnu.org/licenses/gpl-2.0.html>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This program is provided "AS IS" and "WITH ALL FAULTS" and
+ * without warranty of any kind. You are solely responsible for
+ * determining the appropriateness of using and distributing
+ * the program and assume all risks associated with your exercise
+ * of rights with respect to the program, including but not limited
+ * to infringement of third party rights, the risks and costs of
+ * program errors, damage to or loss of data, programs or equipment,
+ * and unavailability or interruption of operations. Under no
+ * circumstances will the contributor of this Program be liable for
+ * any damages of any kind arising from your use or distribution of
+ * this program.
+ */
+
+#include "ufshcd.h"
+#include 
+
+#ifdef CONFIG_PM
+/**
+ * ufshcd_pci_suspend - suspend power management function
+ * @pdev: pointer to PCI device handle
+ * @state: power state
+ *
+ * Returns -ENOSYS
+ */
+static int ufshcd_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+   /*
+* TODO:
+* 1. Call ufshcd_suspend
+* 2. Do bus specific power management
+*/
+
+   return -ENOSYS;
+}
+
+/**
+ * ufshcd_pci_resume - resume power management function
+ * @pdev: pointer to PCI device handle
+ *
+ * Returns -ENOSYS
+ */
+static int ufshcd_pci_resume(struct pci_dev *pdev)
+{
+   /*
+* TODO:
+* 1. Ca

[PATCH V6 Resend 1/4] [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code

2013-02-25 Thread Vinayak Holikatti
This patch seggregates the PCI specific code in ufshcd.c to make it
ready for splitting into core ufs driver and PCI glue driver. Also
copyright header modification to remove extra warranty disclaim.

Reviewed-by: Arnd Bergmann 
Reviewed-by: Namjae Jeon 
Reviewed-by: Subhash Jadavani 
Tested-by: Maya Erez 
Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/Kconfig  |   50 +++
 drivers/scsi/ufs/ufs.h|   44 +++
 drivers/scsi/ufs/ufshcd.c |  348 +++-
 drivers/scsi/ufs/ufshci.h |   44 +++
 4 files changed, 267 insertions(+), 219 deletions(-)

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 8f27f9d..8ee40df 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -2,45 +2,35 @@
 # Kernel configuration file for the UFS Host Controller
 #
 # This code is based on drivers/scsi/ufs/Kconfig
-# Copyright (C) 2011  Samsung Samsung India Software Operations
+# Copyright (C) 2011-2013 Samsung India Software Operations
+#
+# Authors:
+#  Santosh Yaraganavi 
+#  Vinayak Holikatti 
 #
-# Santosh Yaraganavi 
-# Vinayak Holikatti 
-
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; either version 2
 # of the License, or (at your option) any later version.
-
+# See the COPYING file in the top-level directory or visit
+# <http://www.gnu.org/licenses/gpl-2.0.html>
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-
-# NO WARRANTY
-# THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
-# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
-# LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
-# solely responsible for determining the appropriateness of using and
-# distributing the Program and assumes all risks associated with its
-# exercise of rights under this Agreement, including but not limited to
-# the risks and costs of program errors, damage to or loss of data,
-# programs or equipment, and unavailability or interruption of operations.
-
-# DISCLAIMER OF LIABILITY
-# NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
-# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-# USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
-# HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
-# USA.
+#
+# This program is provided "AS IS" and "WITH ALL FAULTS" and
+# without warranty of any kind. You are solely responsible for
+# determining the appropriateness of using and distributing
+# the program and assume all risks associated with your exercise
+# of rights with respect to the program, including but not limited
+# to infringement of third party rights, the risks and costs of
+# program errors, damage to or loss of data, programs or equipment,
+# and unavailability or interruption of operations. Under no
+# circumstances will the contributor of this Program be liable for
+# any damages of any kind arising from your use or distribution of
+# this program.
 
 config SCSI_UFSHCD
tristate "Universal Flash Storage host controller driver"
diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index b207529..139bc06 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -2,45 +2,35 @@
  * Universal Flash Storage Host controller driver
  *
  * This code is based on drivers/scsi/ufs/ufs.h
- * Copyright (C) 2011-2012 Samsung India Software Operations
+ * Copyright (C) 2011-2013 Samsung India Software Operations
  *
- * Santosh Yaraganavi 
- * Vinayak Holikatti 
+ * Authors:
+ * Santosh Yaraganavi 
+ * Vinayak Holikatti 
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
+ * See the COPYING file in the top-level directory or visit
+ * <http://www.gnu.org/licenses/gpl-2.0.html>
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOU

[PATCH V6 Resend 0/4] [SCSI] ufs: Adds glue drivers to ufshcd

2013-02-25 Thread Vinayak Holikatti
This patch set adds following features
 - Seggregate PCI specific code in ufshcd.c and corrected copyright
 - Adds PCI glue driver ufshcd-pci.c and ufshcd.c become core module
 - Adds Platform glue driver ufshcd-pltfrm.c
 - Update correct transfer size in Command UPIU

Vinayak Holikatti (4):
  [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code
  [SCSI] drivers/scsi/ufs: Separate PCI code into glue driver
  [SCSI] ufs: Add Platform glue driver for ufshcd
  [SCSI] ufs: Correct the expected data transfersize

 drivers/scsi/ufs/Kconfig |   87 +---
 drivers/scsi/ufs/Makefile|2 +
 drivers/scsi/ufs/ufs.h   |   44 ++---
 drivers/scsi/ufs/ufshcd-pci.c|  211 +++
 drivers/scsi/ufs/ufshcd-pltfrm.c |  217 +++
 drivers/scsi/ufs/ufshcd.c|  425 --
 drivers/scsi/ufs/ufshcd.h|  202 ++
 drivers/scsi/ufs/ufshci.h|   44 ++---
 8 files changed, 811 insertions(+), 421 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pci.c
 create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.c
 create mode 100644 drivers/scsi/ufs/ufshcd.h

-- 
1.7.5.4

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


Re: [PATCH V6 1/4] [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code

2013-02-24 Thread vinayak holikatti
On Sun, Feb 24, 2013 at 2:53 PM, James Bottomley
 wrote:
> On Tue, 2013-02-05 at 22:17 +0530, vinholika...@gmail.com wrote:
>> From: Vinayak Holikatti 
>>
>> This patch seggregates the PCI specific code in ufshcd.c to make it
>> ready for splitting into core ufs driver and PCI glue driver. Also
>> copyright header modification to remove extra warranty disclaim.
>>
>> Reviewed-by: Arnd Bergmann 
>> Reviewed-by: Namjae Jeon 
>> Reviewed-by: Subhash Jadavani 
>> Signed-off-by: Vinayak Holikatti 
>> Signed-off-by: Santosh Yaraganavi 
>> ---
>>  drivers/scsi/ufs/Kconfig  |   50 +++
>>  drivers/scsi/ufs/ufs.h|   44 +++
>>  drivers/scsi/ufs/ufshcd.c |  350 
>> +++--
>>  drivers/scsi/ufs/ufshci.h |   44 +++
>>  4 files changed, 268 insertions(+), 220 deletions(-)
>
> This patch doesn't apply:
>
> jejb@dabdike> patch -p1 < .git/rebase-apply/patch
> patching file drivers/scsi/ufs/Kconfig
> patching file drivers/scsi/ufs/ufs.h
> patching file drivers/scsi/ufs/ufshcd.c
> Hunk #26 FAILED at 1823.
> Hunk #27 succeeded at 1898 (offset -1 lines).
> Hunk #28 succeeded at 1924 (offset -1 lines).
> Hunk #29 FAILED at 2039.
> 2 out of 29 hunks FAILED -- saving rejects to file
> drivers/scsi/ufs/ufshcd.c.rej
> patching file drivers/scsi/ufs/ufshci.h
>
> The rejects are pretty complex hunks; could you please rebase to the top
> of the scsi-misc tree?  Thanks,

Ok, I will do it.

>
> 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: [PATCH V6 0/4] [SCSI] ufs: Adds glue drivers to ufshcd

2013-02-12 Thread vinayak holikatti
Hi James,

look like these patches are fine. Can you please integrate these
patches in your tree.


On Tue, Feb 5, 2013 at 10:17 PM,   wrote:
> From: Vinayak Holikatti 
>
> This patch set adds following features
>  - Seggregate PCI specific code in ufshcd.c and corrected copyright
>  - Adds PCI glue driver ufshcd-pci.c and ufshcd.c become core module
>  - Adds Platform glue driver ufshcd-pltfrm.c
>  - Update correct transfer size in Command UPIU
>
> Vinayak Holikatti (4):
>   [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code
>   [SCSI] drivers/scsi/ufs: Separate PCI code into glue driver
>   [SCSI] ufs: Add Platform glue driver for ufshcd
>   [SCSI] ufs: Correct the expected data transfersize
>
>  drivers/scsi/ufs/Kconfig |   87 +---
>  drivers/scsi/ufs/Makefile|2 +
>  drivers/scsi/ufs/ufs.h   |   44 ++---
>  drivers/scsi/ufs/ufshcd-pci.c|  211 +++
>  drivers/scsi/ufs/ufshcd-pltfrm.c |  217 +++
>  drivers/scsi/ufs/ufshcd.c|  426 
> --
>  drivers/scsi/ufs/ufshcd.h|  202 ++
>  drivers/scsi/ufs/ufshci.h|   44 ++---
>  8 files changed, 811 insertions(+), 422 deletions(-)
>  create mode 100644 drivers/scsi/ufs/ufshcd-pci.c
>  create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.c
>  create mode 100644 drivers/scsi/ufs/ufshcd.h
>
> --
> 1.7.5.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V5 3/4] [SCSI] ufs: Add Platform glue driver for ufshcd

2013-01-16 Thread vinayak holikatti
On Fri, Jan 11, 2013 at 6:00 PM, Subhash Jadavani
 wrote:
> On 1/11/2013 4:11 PM, Sujit Reddy Thumma wrote:
>>
>> On 1/9/2013 5:41 PM, vinayak holikatti wrote:
>>>
>>> On Mon, Jan 7, 2013 at 1:11 PM, Sujit Reddy Thumma
>>>  wrote:
>>>>
>>>> Hi Vinayak,
>>>>
>>>> I have few comments below:
>>>>
>>>>
>>>>>>>> +#ifdef CONFIG_PM
>>>>>>>> +/**
>>>>>>>> + * ufshcd_pltfrm_suspend - suspend power management function
>>>>>>>> + * @pdev: pointer to Platform device handle
>>>>>>>> + * @mesg: power state
>>>>>>>> + *
>>>>>>>> + * Returns -ENOSYS
>>>>
>>>>
>>>> What breaks if you return 0 instead of return -ENOSYS? Returning error
>>>> seems
>>>> to break platform suspend/resume until all the TODO's are addressed. If
>>>> the
>>>> current s/w cannot make h/w suspend, it should be okay to let the rest
>>>> of
>>>> the system be suspended.
>>>>
>>>
>>> In that case how will the controller be in a working state once it
>>> resumes.
>>> It does not make sense to return zero and to notify the OS that
>>> everything is fine.
>>
>>
>> Since the suspend routine doesn't do anything except returning zero, no
>> power/clocks would be removed and the controller should be in the same state
>> after resume. Do you see any system that removes power/clocks to controllers
>> during suspend without knowledge of corresponding drivers? If so, then such
>> systems must be fixed. In any case, blocking entire system suspend just
>> because s/w isn't taking care of powering down one controller is not a good
>> idea.
>>
>> I would like to hear from others on this as well.
>
>
> Yes, i agree with Sujit that there is no point in blocking the entire system
> suspend just because ufshcd haven't implemented their suspend functionality.
> returning 0 from this function should be fine. And as Sujit already
> mentioned, if during resume you don't find the UFS (controller / phy) state
> as it was left in suspend then it's a particular system's issue and which
> needs to be fixed.
We Implemented Suspend/Resume place holders seeing the kernel documentation
in submitting device drivers
I would like to know if the suggested code change works with any
existing system.
Does any one have similar point of view as Sujit and Subhash have?

>
>>
>>>
>>>>>>>> + */
>>>>>>>> +static int ufshcd_pltfrm_suspend(struct platform_device *pdev,
>>>>>>>> +pm_message_t mesg)
>>>>>>>> +{
>>>>>>>> +   /*
>>>>>>>> +* TODO:
>>>>>>>> +* 1. Call ufshcd_suspend
>>>>>>>> +* 2. Do bus specific power management
>>>>>>>> +*/
>>>>>>>> +
>>>>>>>> +   return -ENOSYS;
>>>>
>>>>
>>>> Returning error doesn't allow entire system to be suspended. Perhaps,
>>>> you
>>>> can do disable_irq() and return 0?
>>>>
>>>>>>>> +}
>>>>>>>> +
>>>>>>>> +/**
>>>>>>>> + * ufshcd_pltfrm_resume - resume power management function
>>>>>>>> + * @pdev: pointer to Platform device handle
>>>>>>>> + *
>>>>>>>> + * Returns -ENOSYS
>>>>>>>> + */
>>>>>>>> +static int ufshcd_pltfrm_resume(struct platform_device *pdev)
>>>>>>>> +{
>>>>>>>> +   /*
>>>>>>>> +* TODO:
>>>>>>>> +* 1. Call ufshcd_resume.
>>>>>>>> +* 2. Do bus specific wake up
>>>>>>>> +*/
>>>>>>>> +
>>>>>>>> +   return -ENOSYS;
>>>>
>>>>
>>>> enable_irq() and return 0?
>>>>
>>>>>>>> +}
>>>>>>>> +#endif
>>>>>>>> +
>>>>
>>>>
>>>>>>>> +static int __devexit ufshcd_pltfrm_remove(struct platform_device
>>>>>>>> *pdev)
>>>>>>>> +{

Re: [PATCH V5 3/4] [SCSI] ufs: Add Platform glue driver for ufshcd

2013-01-09 Thread vinayak holikatti
On Mon, Jan 7, 2013 at 1:11 PM, Sujit Reddy Thumma
 wrote:
> Hi Vinayak,
>
> I have few comments below:
>
>
>>>>> +#ifdef CONFIG_PM
>>>>> +/**
>>>>> + * ufshcd_pltfrm_suspend - suspend power management function
>>>>> + * @pdev: pointer to Platform device handle
>>>>> + * @mesg: power state
>>>>> + *
>>>>> + * Returns -ENOSYS
>
> What breaks if you return 0 instead of return -ENOSYS? Returning error seems
> to break platform suspend/resume until all the TODO's are addressed. If the
> current s/w cannot make h/w suspend, it should be okay to let the rest of
> the system be suspended.
>

In that case how will the controller be in a working state once it resumes.
It does not make sense to return zero and to notify the OS that
everything is fine.

>>>>> + */
>>>>> +static int ufshcd_pltfrm_suspend(struct platform_device *pdev,
>>>>> +pm_message_t mesg)
>>>>> +{
>>>>> +   /*
>>>>> +* TODO:
>>>>> +* 1. Call ufshcd_suspend
>>>>> +* 2. Do bus specific power management
>>>>> +*/
>>>>> +
>>>>> +   return -ENOSYS;
>
> Returning error doesn't allow entire system to be suspended. Perhaps, you
> can do disable_irq() and return 0?
>
>>>>> +}
>>>>> +
>>>>> +/**
>>>>> + * ufshcd_pltfrm_resume - resume power management function
>>>>> + * @pdev: pointer to Platform device handle
>>>>> + *
>>>>> + * Returns -ENOSYS
>>>>> + */
>>>>> +static int ufshcd_pltfrm_resume(struct platform_device *pdev)
>>>>> +{
>>>>> +   /*
>>>>> +* TODO:
>>>>> +* 1. Call ufshcd_resume.
>>>>> +* 2. Do bus specific wake up
>>>>> +*/
>>>>> +
>>>>> +   return -ENOSYS;
>
> enable_irq() and return 0?
>
>>>>> +}
>>>>> +#endif
>>>>> +
>
>>>>> +static int __devexit ufshcd_pltfrm_remove(struct platform_device
>>>>> *pdev)
>>>>> +{
>>>>> +   struct resource *mem_res;
>>>>> +   struct resource *irq_res;
>>>>> +   resource_size_t mem_size;
>>>>> +   struct ufs_hba *hba =  platform_get_drvdata(pdev);
>>>>> +
>>>>> +   irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>>>>
>>>> It would be better to save the irq number under "struct ufs_hba" during
>>>> probe. So here during remove you just need simply need to call the
>>>> "free_irq(irq_res->start, hba)"
>>>
>>> Will modify the code accordingly in the next patchset.
>>>>>
>>>>> +
>>>>> +   if (!irq_res)
>>>>> +   dev_err(&pdev->dev, "ufshcd: IRQ resource not
>>>>> available\n");
>>>>> +   else
>>>>> +   free_irq(irq_res->start, hba);
>
>
> The documentation of free_irq says:
> "... On a shared IRQ the caller must ensure the interrupt is disabled on the
> card it drives before calling this function. .." I don't see disable_irq()
> getting called either here or ufshcd_remove().

Why would you want to disable the entire IRQ line when it is shared?
Logical thing is to disable the interrupt on the controller.

>
>
>>>>> +
>>>>> +   ufshcd_remove(hba);
>>>>
>>>> Remove should be exactly opposite of probe(). So shouldn't you call the
>>>> ufshcd_remove() first and then free_irq() after that.
>>>
>>> Some bugging controllers might raise the interrupt after resources are
>>> removed.
>>> this sequence will prevent it.
>>
>>
>> Could you please add the same as comment in above code sequence?
>>
>>>>> +   mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>>
>>>> You might want to save the pointer to mem_res in "struct ufs_hba" during
>>>> probe and may use the same here.
>>>>>
>>>>> +   if (!mem_res)
>>>>> +   dev_err(&pdev->dev, "ufshcd: Memory resource not
>>>>> available\n");
>>>>> +   else {
>>>>> +  

Re: [PATCH V5 3/4] [SCSI] ufs: Add Platform glue driver for ufshcd

2013-01-03 Thread vinayak holikatti
On Thu, Dec 27, 2012 at 8:28 PM, Subhash Jadavani
 wrote:
> On 12/27/2012 1:45 AM, vinholika...@gmail.com wrote:
>>
>> From: Vinayak Holikatti 
>>
>> This patch adds Platform glue driver for ufshcd.
>>
>> Reviewed-by: Arnd Bergmann 
>> Reviewed-by: Namjae Jeon 
>> Signed-off-by: Vinayak Holikatti 
>> Signed-off-by: Santosh Yaraganavi 
>> ---
>>   drivers/scsi/ufs/Kconfig |   11 ++
>>   drivers/scsi/ufs/Makefile|1 +
>>   drivers/scsi/ufs/ufshcd-pltfrm.c |  205
>> ++
>>   3 files changed, 217 insertions(+), 0 deletions(-)
>>   create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.c
>>
>> diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
>> index d77ae97..96e1721 100644
>> --- a/drivers/scsi/ufs/Kconfig
>> +++ b/drivers/scsi/ufs/Kconfig
>> @@ -57,3 +57,14 @@ config SCSI_UFSHCD_PCI
>>   If you have a controller with this interface, say Y or M here.
>>   If unsure, say N.
>> +
>> +config SCSI_UFSHCD_PLATFORM
>> +   tristate "Platform based UFS Controller support"
>
> This may sound more explicit: s/"Platform based"/"Platform bus based"
>>
>> +   depends on SCSI_UFSHCD
>> +   ---help---
>> +   This selects the UFS host controller support. If you have a
>> +  platform with UFS controller, say Y or M here.
>
> s/"If you have a platform with UFS controller,"/"If you have UFS controller
> on platform bus,"
>>
>> +
>> +  If you have a controller with this interface, say Y or M here.
>
> Why do we need this line? we already one comment above.
>>
>> +
>> + If unsure, say N.
>> diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
>> index 9eda0df..1e5bd48 100644
>> --- a/drivers/scsi/ufs/Makefile
>> +++ b/drivers/scsi/ufs/Makefile
>> @@ -1,3 +1,4 @@
>>   # UFSHCD makefile
>>   obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
>>   obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
>> +obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
>> diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c
>> b/drivers/scsi/ufs/ufshcd-pltfrm.c
>> new file mode 100644
>> index 000..94acfdc
>> --- /dev/null
>> +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
>> @@ -0,0 +1,205 @@
>> +/*
>> + * Universal Flash Storage Host controller driver
>
> Please add some comment to indicate that this is platform bus UFS host
> controller driver.
The File name itself would identify the nature of driver. can add for more info.
>>
>> + *
>> + * This code is based on drivers/scsi/ufs/ufshcd-pltfrm.c
>> + * Copyright (C) 2011-2012 Samsung India Software Operations
>> + *
>> + * Authors:
>> + * Santosh Yaraganavi 
>> + * Vinayak Holikatti 
>> + *
>> + * This program is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU General Public License
>> + * as published by the Free Software Foundation; either version 2
>> + * of the License, or (at your option) any later version.
>> + * See the COPYING file in the top-level directory or visit
>> + * <http://www.gnu.org/licenses/gpl-2.0.html>
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + *
>> + * This program is provided "AS IS" and "WITH ALL FAULTS" and
>> + * without warranty of any kind. You are solely responsible for
>> + * determining the appropriateness of using and distributing
>> + * the program and assume all risks associated with your exercise
>> + * of rights with respect to the program, including but not limited
>> + * to infringement of third party rights, the risks and costs of
>> + * program errors, damage to or loss of data, programs or equipment,
>> + * and unavailability or interruption of operations. Under no
>> + * circumstances will the contributor of this Program be liable for
>> + * any damages of any kind arising from your use or distribution of
>> + * this program.
>> + */
>> +
>> +#include "ufshcd.h"
>> +#include 
>> +
>> +#ifdef CONFIG_PM
>> +/**
>> + * ufshcd_pltfrm_suspend - suspend power management function
>> + * @pdev: pointer to Platform device handle
>> + * @mesg: power state
>> + *
>> + 

Re: [PATCH V5 1/4] [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code

2013-01-03 Thread vinayak holikatti
On Thu, Dec 27, 2012 at 7:59 PM, Subhash Jadavani
 wrote:
>
> Few comments inline:
>
> On 12/27/2012 1:45 AM, vinholika...@gmail.com wrote:
>>
>> From: Vinayak Holikatti 
>>
>> This patch seggregates the PCI specific code in ufshcd.c to make it
>> ready for splitting into core ufs driver and PCI glue driver. Also
>> copyright header modification to remove extra warranty disclaim.
>>
>> Reviewed-by: Arnd Bergmann 
>> Reviewed-by: Namjae Jeon 
>> Signed-off-by: Vinayak Holikatti 
>> Signed-off-by: Santosh Yaraganavi 
>> ---
>>   drivers/scsi/ufs/Kconfig  |   50 +++
>>   drivers/scsi/ufs/ufs.h|   42 ++
>>   drivers/scsi/ufs/ufshcd.c |  339
>> +++--
>>   drivers/scsi/ufs/ufshci.h |   42 ++
>>   4 files changed, 255 insertions(+), 218 deletions(-)
>>
>> diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
>> index 8f27f9d..9c84569 100644
>> --- a/drivers/scsi/ufs/Kconfig
>> +++ b/drivers/scsi/ufs/Kconfig
>> @@ -2,45 +2,35 @@
>>   # Kernel configuration file for the UFS Host Controller
>>   #
>>   # This code is based on drivers/scsi/ufs/Kconfig
>> -# Copyright (C) 2011  Samsung Samsung India Software Operations
>> +# Copyright (C) 2011-2012 Samsung India Software Operations
>> +#
>> +# Authors:
>> +#  Santosh Yaraganavi 
>> +#  Vinayak Holikatti 
>>   #
>> -# Santosh Yaraganavi 
>> -# Vinayak Holikatti 
>> -
>>   # This program is free software; you can redistribute it and/or
>>   # modify it under the terms of the GNU General Public License
>>   # as published by the Free Software Foundation; either version 2
>>   # of the License, or (at your option) any later version.
>> -
>> +# See the COPYING file in the top-level directory or visit
>> +# <http://www.gnu.org/licenses/gpl-2.0.html>
>> +#
>>   # This program is distributed in the hope that it will be useful,
>>   # but WITHOUT ANY WARRANTY; without even the implied warranty of
>>   # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>   # GNU General Public License for more details.
>> -
>> -# NO WARRANTY
>> -# THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
>> -# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
>> -# LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
>> -# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
>> -# solely responsible for determining the appropriateness of using and
>> -# distributing the Program and assumes all risks associated with its
>> -# exercise of rights under this Agreement, including but not limited to
>> -# the risks and costs of program errors, damage to or loss of data,
>> -# programs or equipment, and unavailability or interruption of
>> operations.
>> -
>> -# DISCLAIMER OF LIABILITY
>> -# NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
>> -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
>> -# DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
>> -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
>> -# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
>> -# USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
>> GRANTED
>> -# HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
>> -
>> -# You should have received a copy of the GNU General Public License
>> -# along with this program; if not, write to the Free Software
>> -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
>> 02110-1301,
>> -# USA.
>> +#
>> +# This program is provided "AS IS" and "WITH ALL FAULTS" and
>> +# without warranty of any kind. You are solely responsible for
>> +# determining the appropriateness of using and distributing
>> +# the program and assume all risks associated with your exercise
>> +# of rights with respect to the program, including but not limited
>> +# to infringement of third party rights, the risks and costs of
>> +# program errors, damage to or loss of data, programs or equipment,
>> +# and unavailability or interruption of operations. Under no
>> +# circumstances will the contributor of this Program be liable for
>> +# any damages of any kind arising from your use or distribution of
>> +# this program.
>> config SCSI_UFSHCD
>> tristate "Universal Flash Storage host controller driver"
>> diff --git a/

Re: [PATCH 192/493] scsi: remove use of __devinit

2012-11-27 Thread vinayak holikatti
>  drivers/scsi/ufs/ufshcd.c |  2 +-

Acked-by: Vinayak Holikatti 

only for drivers/scsi/ufs/ufshcd.c

> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 4a370f8..a79ff87 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -1811,7 +1811,7 @@ static int ufshcd_set_dma_mask(struct ufs_hba *hba)
>   *
>   * Returns 0 on success, non-zero value on failure
>   */
> -static int __devinit
> +static int
>  ufshcd_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  {
>     struct Scsi_Host *host;


-- 
Regards,
Vinayak Holikatti
--
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 097/493] scsi: remove use of __devexit_p

2012-11-26 Thread vinayak holikatti
>  drivers/scsi/ufs/ufshcd.c | 2 +-

Acked-by: Vinayak Holikatti 

only for drivers/scsi/ufs/ufshcd.c

> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 58f4ba6..4a370f8 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -1947,7 +1947,7 @@ static struct pci_driver ufshcd_pci_driver = {
> .name = UFSHCD,
> .id_table = ufshcd_pci_tbl,
> .probe = ufshcd_probe,
> -   .remove = __devexit_p(ufshcd_remove),
> +   .remove = ufshcd_remove,
> .shutdown = ufshcd_shutdown,
>  #ifdef CONFIG_PM
>     .suspend = ufshcd_suspend,

Thanks,
Vinayak Holikatti
--
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 V4 1/4] [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code

2012-11-21 Thread vinayak holikatti
On Wed, Nov 21, 2012 at 4:26 PM, James Bottomley
 wrote:
> On Wed, 2012-11-21 at 16:02 +0530, vinayak holikatti wrote:
>> On Wed, Nov 14, 2012 at 2:56 AM, James Bottomley
>>  wrote:
>> > On Thu, 2012-10-18 at 17:37 +0530, vinayak holikatti wrote:
>> >> I am Vacation will look into it when i am back to work.
>> >> > This doesn't apply on 3.7-rc1. Am I missing any patches in between ?
>> >
>> > OK, so it doesn't apply for me either:
>> >
>> > patching file drivers/scsi/ufs/ufshcd.c
>> > Hunk #11 FAILED at 902.
>> > Hunk #15 succeeded at 1157 with fuzz 1 (offset 2 lines).
>> > Hunk #16 succeeded at 1271 (offset 2 lines).
>> > Hunk #17 succeeded at 1300 (offset 2 lines).
>> > Hunk #18 succeeded at 1364 (offset 2 lines).
>> > Hunk #19 succeeded at 1499 (offset 2 lines).
>> > Hunk #20 succeeded at 1542 (offset 2 lines).
>> > Hunk #21 succeeded at 1678 (offset 2 lines).
>> > Hunk #22 succeeded at 1706 (offset 2 lines).
>> > Hunk #23 succeeded at 1727 (offset 2 lines).
>> > Hunk #24 succeeded at 1775 (offset 2 lines).
>> > Hunk #25 succeeded at 1819 (offset 2 lines).
>> > Hunk #26 succeeded at 1872 (offset 2 lines).
>> > Hunk #27 succeeded at 1898 (offset 2 lines).
>> > Hunk #28 FAILED at 2011.
>> > 2 out of 28 hunks FAILED -- saving rejects to file
>> > drivers/scsi/ufs/ufshcd.c.rej
>> >
>> I have generated patches based on linux/kernel/git/jejb/scsi.git this
>> tree, Also i have
>> confirmed that patches get applied successfully on this git tree.
>>
>> James,
>> Which tree are you refering to. Let me know, which tree i should use to
>> generate the patches.
>
> All patches for the merge window should be against the misc branch of
> the scsi.git tree.
>
> James
>
Ok, I will create the patches against misc branch and resend these patches.
Thanks
Vinayak Holikatti
--
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 V4 1/4] [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code

2012-11-21 Thread vinayak holikatti
On Wed, Nov 14, 2012 at 2:56 AM, James Bottomley
 wrote:
> On Thu, 2012-10-18 at 17:37 +0530, vinayak holikatti wrote:
>> I am Vacation will look into it when i am back to work.
>> > This doesn't apply on 3.7-rc1. Am I missing any patches in between ?
>
> OK, so it doesn't apply for me either:
>
> patching file drivers/scsi/ufs/ufshcd.c
> Hunk #11 FAILED at 902.
> Hunk #15 succeeded at 1157 with fuzz 1 (offset 2 lines).
> Hunk #16 succeeded at 1271 (offset 2 lines).
> Hunk #17 succeeded at 1300 (offset 2 lines).
> Hunk #18 succeeded at 1364 (offset 2 lines).
> Hunk #19 succeeded at 1499 (offset 2 lines).
> Hunk #20 succeeded at 1542 (offset 2 lines).
> Hunk #21 succeeded at 1678 (offset 2 lines).
> Hunk #22 succeeded at 1706 (offset 2 lines).
> Hunk #23 succeeded at 1727 (offset 2 lines).
> Hunk #24 succeeded at 1775 (offset 2 lines).
> Hunk #25 succeeded at 1819 (offset 2 lines).
> Hunk #26 succeeded at 1872 (offset 2 lines).
> Hunk #27 succeeded at 1898 (offset 2 lines).
> Hunk #28 FAILED at 2011.
> 2 out of 28 hunks FAILED -- saving rejects to file
> drivers/scsi/ufs/ufshcd.c.rej
>
I have generated patches based on linux/kernel/git/jejb/scsi.git this
tree, Also i have
confirmed that patches get applied successfully on this git tree.

James,
Which tree are you refering to. Let me know, which tree i should use to
generate the patches.

> 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: [PATCH V4 1/4] [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code

2012-10-18 Thread vinayak holikatti
On Thu, Oct 18, 2012 at 12:13 PM, Venkatraman S  wrote:
> On Wednesday 17 October 2012 05:23 PM, Vinayak Holikatti wrote:
>>
>> This patch seggregates the PCI specific code in ufshcd.c to make it
>> ready for splitting into core ufs driver and PCI glue driver. Also
>> copyright header modification to remove extra warranty disclaim.
>>
>> Reviewed-by: Arnd Bergmann 
>> Reviewed-by: Namjae Jeon 
>> Signed-off-by: Vinayak Holikatti 
>> Signed-off-by: Santosh Yaraganavi 
>> ---
>>   drivers/scsi/ufs/Kconfig  |   50 +++
>>   drivers/scsi/ufs/ufs.h|   42 ++
>>   drivers/scsi/ufs/ufshcd.c |  358
>> ++---
>>   drivers/scsi/ufs/ufshci.h |   42 ++
>>   4 files changed, 256 insertions(+), 236 deletions(-)
>>
I am Vacation will look into it when i am back to work.
> This doesn't apply on 3.7-rc1. Am I missing any patches in between ?



-- 
Regards,
Vinayak Holikatti
--
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 V4 4/4] [SCSI] ufs: Correct the expected data transfer size

2012-10-17 Thread Vinayak Holikatti
This patch corrects the expected data transfer size of the
command UPIU. The current implementation of cmd->transfersize
is wrong as it probably equal to sector size. With this
implementation the transfer size is updated correctly

Reported-by: KOBAYASHI Yoshitake 
Reviewed-by: Arnd Bergmann 
Reviewed-by: Namjae Jeon 
Signed-off-by: Santosh Yaraganavi 
Signed-off-by: Vinayak Holikatti 
---
 drivers/scsi/ufs/ufshcd.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 5d7bd47..57c16ec 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -478,7 +478,7 @@ static void ufshcd_compose_upiu(struct ufshcd_lrb *lrbp)
ucd_cmd_ptr->header.dword_2 = 0;
 
ucd_cmd_ptr->exp_data_transfer_len =
-   cpu_to_be32(lrbp->cmd->transfersize);
+   cpu_to_be32(lrbp->cmd->sdb.length);
 
memcpy(ucd_cmd_ptr->cdb,
   lrbp->cmd->cmnd,
-- 
1.7.5.4

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


[PATCH V4 3/4] [SCSI] ufs: Add Platform glue driver for ufshcd

2012-10-17 Thread Vinayak Holikatti
This patch adds Platform glue driver for ufshcd.

Reviewed-by: Arnd Bergmann 
Reviewed-by: Namjae Jeon 
Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/Kconfig |   11 ++
 drivers/scsi/ufs/Makefile|1 +
 drivers/scsi/ufs/ufshcd-pltfrm.c |  205 ++
 3 files changed, 217 insertions(+), 0 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.c

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index d77ae97..96e1721 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -57,3 +57,14 @@ config SCSI_UFSHCD_PCI
  If you have a controller with this interface, say Y or M here.
 
  If unsure, say N.
+
+config SCSI_UFSHCD_PLATFORM
+   tristate "Platform based UFS Controller support"
+   depends on SCSI_UFSHCD
+   ---help---
+   This selects the UFS host controller support. If you have a
+  platform with UFS controller, say Y or M here.
+
+  If you have a controller with this interface, say Y or M here.
+
+ If unsure, say N.
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 9eda0df..1e5bd48 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,3 +1,4 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
+obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
new file mode 100644
index 000..73ac7c7
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -0,0 +1,205 @@
+/*
+ * Universal Flash Storage Host controller driver
+ *
+ * This code is based on drivers/scsi/ufs/ufshcd.c
+ * Copyright (C) 2011-2012 Samsung India Software Operations
+ *
+ * Authors:
+ * Santosh Yaraganavi 
+ *     Vinayak Holikatti 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * See the COPYING file in the top-level directory or visit
+ * <http://www.gnu.org/licenses/gpl-2.0.html>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This program is provided "AS IS" and "WITH ALL FAULTS" and
+ * without warranty of any kind. You are solely responsible for
+ * determining the appropriateness of using and distributing
+ * the program and assume all risks associated with your exercise
+ * of rights with respect to the program, including but not limited
+ * to infringement of third party rights, the risks and costs of
+ * program errors, damage to or loss of data, programs or equipment,
+ * and unavailability or interruption of operations. Under no
+ * circumstances will the contributor of this Program be liable for
+ * any damages of any kind arising from your use or distribution of
+ * this program.
+ */
+
+#include "ufshcd.h"
+#include 
+
+#ifdef CONFIG_PM
+/**
+ * ufshcd_pltfrm_suspend - suspend power management function
+ * @pdev: pointer to Platform device handle
+ * @mesg: power state
+ *
+ * Returns -ENOSYS
+ */
+static int ufshcd_pltfrm_suspend(struct platform_device *pdev,
+pm_message_t mesg)
+{
+   /*
+* TODO:
+* 1. Call ufshcd_suspend
+* 2. Do bus specific power management
+*/
+
+   return -ENOSYS;
+}
+
+/**
+ * ufshcd_pltfrm_resume - resume power management function
+ * @pdev: pointer to Platform device handle
+ *
+ * Returns -ENOSYS
+ */
+static int ufshcd_pltfrm_resume(struct platform_device *pdev)
+{
+   /*
+* TODO:
+* 1. Call ufshcd_resume.
+* 2. Do bus specific wake up
+*/
+
+   return -ENOSYS;
+}
+#endif
+
+/**
+ * ufshcd_pltfrm_probe - probe routine of the driver
+ * @pdev: pointer to Platform device handle
+ *
+ * Returns 0 on success, non-zero value on failure
+ */
+static int __devinit
+ufshcd_pltfrm_probe(struct platform_device *pdev)
+{
+   struct ufs_hba *hba;
+   void __iomem *mmio_base;
+   struct resource *mem_res;
+   struct resource *irq_res;
+   resource_size_t mem_size;
+   int err;
+   struct device *dev = &pdev->dev;
+
+   mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!mem_res) {
+   dev_err(&pdev->dev,
+   "%s: Memory resource not available\n", __FILE__);
+   err = -ENODEV;
+   goto out_error;
+   }
+
+   mem_size = resource_size(mem_res);
+   if (!request_mem_region(mem_res->start, mem_size, "ufshcd")) {
+   

[PATCH V4 2/4] [SCSI] drivers/scsi/ufs: Separate PCI code into glue driver

2012-10-17 Thread Vinayak Holikatti
This patch separates PCI code from ufshcd.c and makes it as a
core driver module and adds a new file ufshcd-pci.c as PCI glue
driver.

Reviewed-by: Arnd Bergmann 
Reviewed-by: Namjae Jeon 
Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/Kconfig  |   26 +++-
 drivers/scsi/ufs/Makefile |1 +
 drivers/scsi/ufs/ufshcd-pci.c |  211 +++
 drivers/scsi/ufs/ufshcd.c |  323 +
 drivers/scsi/ufs/ufshcd.h |  200 +
 5 files changed, 437 insertions(+), 324 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pci.c
 create mode 100644 drivers/scsi/ufs/ufshcd.h

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 9c84569..d77ae97 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -33,7 +33,27 @@
 # this program.
 
 config SCSI_UFSHCD
-   tristate "Universal Flash Storage host controller driver"
-   depends on PCI && SCSI
+   tristate "Universal Flash Storage Controller Driver Core"
+   depends on SCSI
---help---
-   This is a generic driver which supports PCIe UFS Host controllers.
+   This selects the support for UFS devices in Linux, say Y and make
+ sure that you know the name of your UFS host adapter (the card
+ inside your computer that "speaks" the UFS protocol, also
+ called UFS Host Controller), because you will be asked for it.
+ The module will be called ufshcd.
+
+ To compile this driver as a module, choose M here and read
+ .
+ However, do not compile this as a module if your root file system
+ (the one containing the directory /) is located on a UFS device.
+
+config SCSI_UFSHCD_PCI
+   tristate "PCI bus based UFS Controller support"
+   depends on SCSI_UFSHCD && PCI
+   ---help---
+   This selects the PCI UFS Host Controller Interface.
+ Most controllers found today are PCI devices.
+
+ If you have a controller with this interface, say Y or M here.
+
+ If unsure, say N.
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index adf7895..9eda0df 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,2 +1,3 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
+obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
new file mode 100644
index 000..ba86b5e
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -0,0 +1,211 @@
+/*
+ * Universal Flash Storage Host controller driver
+ *
+ * This code is based on drivers/scsi/ufs/ufshcd-pci.c
+ * Copyright (C) 2011-2012 Samsung India Software Operations
+ *
+ * Authors:
+ * Santosh Yaraganavi 
+ * Vinayak Holikatti 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * See the COPYING file in the top-level directory or visit
+ * <http://www.gnu.org/licenses/gpl-2.0.html>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This program is provided "AS IS" and "WITH ALL FAULTS" and
+ * without warranty of any kind. You are solely responsible for
+ * determining the appropriateness of using and distributing
+ * the program and assume all risks associated with your exercise
+ * of rights with respect to the program, including but not limited
+ * to infringement of third party rights, the risks and costs of
+ * program errors, damage to or loss of data, programs or equipment,
+ * and unavailability or interruption of operations. Under no
+ * circumstances will the contributor of this Program be liable for
+ * any damages of any kind arising from your use or distribution of
+ * this program.
+ */
+
+#include "ufshcd.h"
+#include 
+
+#ifdef CONFIG_PM
+/**
+ * ufshcd_pci_suspend - suspend power management function
+ * @pdev: pointer to PCI device handle
+ * @state: power state
+ *
+ * Returns -ENOSYS
+ */
+static int ufshcd_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+   /*
+* TODO:
+* 1. Call ufshcd_suspend
+* 2. Do bus specific power management
+*/
+
+   return -ENOSYS;
+}
+
+/**
+ * ufshcd_pci_resume - resume power management function
+ * @pdev: pointer to PCI device handle
+ *
+ * Returns -ENOSYS
+ */
+static int ufshcd_pci_resume(struct pci_dev *pdev)
+{
+   /*
+* TODO:
+* 1. Call ufshcd_resume.
+* 2. Do bus specific wake up
+*/
+
+   

[PATCH V4 1/4] [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code

2012-10-17 Thread Vinayak Holikatti
This patch seggregates the PCI specific code in ufshcd.c to make it
ready for splitting into core ufs driver and PCI glue driver. Also
copyright header modification to remove extra warranty disclaim.

Reviewed-by: Arnd Bergmann 
Reviewed-by: Namjae Jeon 
Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/Kconfig  |   50 +++
 drivers/scsi/ufs/ufs.h|   42 ++
 drivers/scsi/ufs/ufshcd.c |  358 ++---
 drivers/scsi/ufs/ufshci.h |   42 ++
 4 files changed, 256 insertions(+), 236 deletions(-)

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 8f27f9d..9c84569 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -2,45 +2,35 @@
 # Kernel configuration file for the UFS Host Controller
 #
 # This code is based on drivers/scsi/ufs/Kconfig
-# Copyright (C) 2011  Samsung Samsung India Software Operations
+# Copyright (C) 2011-2012 Samsung India Software Operations
+#
+# Authors:
+#  Santosh Yaraganavi 
+#  Vinayak Holikatti 
 #
-# Santosh Yaraganavi 
-# Vinayak Holikatti 
-
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; either version 2
 # of the License, or (at your option) any later version.
-
+# See the COPYING file in the top-level directory or visit
+# <http://www.gnu.org/licenses/gpl-2.0.html>
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-
-# NO WARRANTY
-# THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
-# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
-# LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
-# solely responsible for determining the appropriateness of using and
-# distributing the Program and assumes all risks associated with its
-# exercise of rights under this Agreement, including but not limited to
-# the risks and costs of program errors, damage to or loss of data,
-# programs or equipment, and unavailability or interruption of operations.
-
-# DISCLAIMER OF LIABILITY
-# NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
-# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-# USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
-# HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
-# USA.
+#
+# This program is provided "AS IS" and "WITH ALL FAULTS" and
+# without warranty of any kind. You are solely responsible for
+# determining the appropriateness of using and distributing
+# the program and assume all risks associated with your exercise
+# of rights with respect to the program, including but not limited
+# to infringement of third party rights, the risks and costs of
+# program errors, damage to or loss of data, programs or equipment,
+# and unavailability or interruption of operations. Under no
+# circumstances will the contributor of this Program be liable for
+# any damages of any kind arising from your use or distribution of
+# this program.
 
 config SCSI_UFSHCD
tristate "Universal Flash Storage host controller driver"
diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index b207529..4b3d611 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -4,43 +4,33 @@
  * This code is based on drivers/scsi/ufs/ufs.h
  * Copyright (C) 2011-2012 Samsung India Software Operations
  *
- * Santosh Yaraganavi 
- * Vinayak Holikatti 
+ * Authors:
+ * Santosh Yaraganavi 
+ * Vinayak Holikatti 
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
+ * See the COPYING file in the top-level directory or visit
+ * <http://www.gnu.org/licenses/gpl-2.0.html>
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * NO WARR

[PATCH V4 0/4] [SCSI] ufs: Adds glue drivers to ufshcd

2012-10-17 Thread Vinayak Holikatti
This patch set adds following features
 - Seggregate PCI specific code in ufshcd.c and corrected copyright
 - Adds PCI glue driver ufshcd-pci.c and ufshcd.c become core module
 - Adds Platform glue driver ufshcd-pltfrm.c
 - Update correct transfer size in Command UPIU

Vinayak Holikatti (4):
  [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code
  [SCSI] drivers/scsi/ufs: Separate PCI code into glue driver
  [SCSI] ufs: Add Platform glue driver for ufshcd
  [SCSI] ufs: Correct the expected data transfer size

 drivers/scsi/ufs/Kconfig |   87 +---
 drivers/scsi/ufs/Makefile|2 +
 drivers/scsi/ufs/ufs.h   |   42 ++---
 drivers/scsi/ufs/ufshcd-pci.c|  211 ++
 drivers/scsi/ufs/ufshcd-pltfrm.c |  205 ++
 drivers/scsi/ufs/ufshcd.c|  433 +++--
 drivers/scsi/ufs/ufshcd.h|  200 ++
 drivers/scsi/ufs/ufshci.h|   42 ++---
 8 files changed, 786 insertions(+), 436 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pci.c
 create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.c
 create mode 100644 drivers/scsi/ufs/ufshcd.h

-- 
1.7.5.4

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


Re: [PATCH V3 1/4] [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code

2012-08-04 Thread vinayak holikatti
On Wed, Aug 1, 2012 at 8:08 PM, Arnd Bergmann  wrote:
> On Thursday 26 July 2012, Vinayak Holikatti wrote:
>
>> -static void ufshcd_remove(struct pci_dev *pdev)
>> +void ufshcd_remove(struct ufs_hba *hba)
>>  {
>> - struct ufs_hba *hba = pci_get_drvdata(pdev);
>> -
>>   /* disable interrupts */
>>   ufshcd_int_config(hba, UFSHCD_INT_DISABLE);
>> - free_irq(pdev->irq, hba);
>>
>>   ufshcd_hba_stop(hba);
>>   ufshcd_hba_free(hba);
>>
>>   scsi_remove_host(hba->host);
>>   scsi_host_put(hba->host);
>> +}
>> +EXPORT_SYMBOL(ufshcd_remove);
>
> For driver internal symbols, you should always use "EXPORT_SYMBOL_GPL"
> here.
Ok, will use EXPORT_SYMBOL_GPL
>
> Arnd
>



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


Re: [PATCH V3 0/4] [SCSI] ufs: Adds glue drivers to ufshcd

2012-07-26 Thread vinayak holikatti
On Thu, Jul 26, 2012 at 5:05 PM, S, Venkatraman  wrote:
> On Thu, Jul 26, 2012 at 4:42 PM, vinayak holikatti
>  wrote:
>> On Thu, Jul 26, 2012 at 4:02 PM, S, Venkatraman  wrote:
>>> On Thu, Jul 26, 2012 at 2:12 PM, Vinayak Holikatti
>>>  wrote:
>>>> This patch set adds following features
>>>>  - Seggregate PCI specific code in ufshcd.c
>>>>  - Adds PCI glue driver ufshcd-pci.c and ufshcd.c become core module
>>>>  - Adds Platform glue driver ufshcd-pltfrm.c
>>>>  - Update correct transfer size in Command UPIU
>>>>
>>>> Vinayak Holikatti (4):
>>>>   [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code
>>>>   [SCSI] drivers/scsi/ufs: Separate PCI code into glue driver
>>>>   [SCSI] ufs: Add Platform glue driver for ufshcd
>>>>   [SCSI] ufs: Correct the expected data transfer size
>>>>
>>>>  drivers/scsi/ufs/Kconfig |   37 +++-
>>>>  drivers/scsi/ufs/Makefile|2 +
>>>>  drivers/scsi/ufs/ufshcd-pci.c|  228 
>>>>  drivers/scsi/ufs/ufshcd-pltfrm.c |  222 
>>>>  drivers/scsi/ufs/ufshcd.c|  422 
>>>> ++
>>>>  drivers/scsi/ufs/ufshcd.h|  206 +++
>>>>  drivers/scsi/ufs/ufshcd_common.h |   53 +
>>>>  7 files changed, 813 insertions(+), 357 deletions(-)
>>>
>>> Two minor observations..
>>> 1) If both pci and platform have to do the exact same thing in their
>>> _suspend() and _resume() routines, perhaps there is scope for making
>>> them as common (the steps outlined in them should be done in core
>>> ufshcd) ?
>> Both will not have to do the exact same thing. We have plan to implement
>> ufshcd_suspend and ufshcd_resume which will be generic and will be part
>> of ufshcd core, as you said.
>
> Thanks. The comments in the driver files don't reflect this; it'd be
> wise to create
> the placeholder for core_suspend()/resume() in ufshcd.c, instead of
> the platform drivers.
Ok, I will make a place holder in ufshcd.c in next version of patch.
>
>>>
>>> 2) Need to include ufshcd_common.h in ufshcd.c so that the prototypes
>>> are supplied for the exported functions.
>> Thank you, I will make necessary changes in next version of patches.
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V3 0/4] [SCSI] ufs: Adds glue drivers to ufshcd

2012-07-26 Thread vinayak holikatti
On Thu, Jul 26, 2012 at 4:02 PM, S, Venkatraman  wrote:
> On Thu, Jul 26, 2012 at 2:12 PM, Vinayak Holikatti
>  wrote:
>> This patch set adds following features
>>  - Seggregate PCI specific code in ufshcd.c
>>  - Adds PCI glue driver ufshcd-pci.c and ufshcd.c become core module
>>  - Adds Platform glue driver ufshcd-pltfrm.c
>>  - Update correct transfer size in Command UPIU
>>
>> Vinayak Holikatti (4):
>>   [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code
>>   [SCSI] drivers/scsi/ufs: Separate PCI code into glue driver
>>   [SCSI] ufs: Add Platform glue driver for ufshcd
>>   [SCSI] ufs: Correct the expected data transfer size
>>
>>  drivers/scsi/ufs/Kconfig |   37 +++-
>>  drivers/scsi/ufs/Makefile|2 +
>>  drivers/scsi/ufs/ufshcd-pci.c|  228 
>>  drivers/scsi/ufs/ufshcd-pltfrm.c |  222 
>>  drivers/scsi/ufs/ufshcd.c|  422 
>> ++
>>  drivers/scsi/ufs/ufshcd.h|  206 +++
>>  drivers/scsi/ufs/ufshcd_common.h |   53 +
>>  7 files changed, 813 insertions(+), 357 deletions(-)
>
> Two minor observations..
> 1) If both pci and platform have to do the exact same thing in their
> _suspend() and _resume() routines, perhaps there is scope for making
> them as common (the steps outlined in them should be done in core
> ufshcd) ?
Both will not have to do the exact same thing. We have plan to implement
ufshcd_suspend and ufshcd_resume which will be generic and will be part
of ufshcd core, as you said.
>
> 2) Need to include ufshcd_common.h in ufshcd.c so that the prototypes
> are supplied for the exported functions.
Thank you, I will make necessary changes in next version of patches.

-- 
Regards,
Vinayak Holikatti
--
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 V3 4/4] [SCSI] ufs: Correct the expected data transfer size

2012-07-26 Thread Vinayak Holikatti
This patch corrects the expected data transfer size of the
command UPIU. The current implementation of cmd->transfersize
is wrong as it probably equal to sector size. With this
implementation the transfer size is updated correctly

Reported-by: KOBAYASHI Yoshitake 
Reviewed-by: Namjae Jeon 
Signed-off-by: Santosh Yaraganavi 
Signed-off-by: Vinayak Holikatti 
---
 drivers/scsi/ufs/ufshcd.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index dfc3e85..5e732c3 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -488,7 +488,7 @@ static void ufshcd_compose_upiu(struct ufshcd_lrb *lrbp)
ucd_cmd_ptr->header.dword_2 = 0;
 
ucd_cmd_ptr->exp_data_transfer_len =
-   cpu_to_be32(lrbp->cmd->transfersize);
+   cpu_to_be32(lrbp->cmd->sdb.length);
 
memcpy(ucd_cmd_ptr->cdb,
   lrbp->cmd->cmnd,
-- 
1.7.9.5

--
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 V3 3/4] [SCSI] ufs: Add Platform glue driver for ufshcd

2012-07-26 Thread Vinayak Holikatti
This patch adds Platform glue driver for ufshcd.

Reviewed-by: Namjae Jeon 
Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/Kconfig |   11 ++
 drivers/scsi/ufs/Makefile|1 +
 drivers/scsi/ufs/ufshcd-pltfrm.c |  222 ++
 3 files changed, 234 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.c

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 265a8c8..8c06330 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -67,3 +67,14 @@ config SCSI_UFSHCD_PCI
  If you have a controller with this interface, say Y or M here.
 
  If unsure, say N.
+
+config SCSI_UFSHCD_PLATFORM
+   tristate "Platform based UFS Controller support"
+   depends on SCSI_UFSHCD
+   ---help---
+   This selects the UFS host controller support. If you have a
+  platform with UFS controller, say Y or M here.
+
+  If you have a controller with this interface, say Y or M here.
+
+ If unsure, say N.
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 9eda0df..1e5bd48 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,3 +1,4 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
+obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
new file mode 100644
index 000..68e1675
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -0,0 +1,222 @@
+/*
+ * Universal Flash Storage Host controller driver
+ *
+ * This code is based on drivers/scsi/ufs/ufshcd-pltfm.c
+ * Copyright (C) 2011-2012 Samsung India Software Operations
+ *
+ * Santosh Yaraganavi 
+ * Vinayak Holikatti 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#include "ufshcd.h"
+#include "ufshcd_common.h"
+#include 
+
+#ifdef CONFIG_PM
+/**
+ * ufshcd_pltfrm_suspend - suspend power management function
+ * @pdev: pointer to Platform device handle
+ * @mesg: power state
+ *
+ * Returns -ENOSYS
+ */
+static int ufshcd_pltfrm_suspend(struct platform_device *pdev,
+pm_message_t mesg)
+{
+   /*
+* TODO:
+* 1. Block SCSI requests from SCSI midlayer
+* 2. Change the internal driver state to non operational
+* 3. Set UTRLRSR and UTMRLRSR bits to zero
+* 4. Wait until outstanding commands are completed
+* 5. Set HCE to zero to send the UFS host controller to reset state
+*/
+
+   return -ENOSYS;
+}
+
+/**
+ * ufshcd_pltfrm_resume - resume power management function
+ * @pdev: pointer to Platform device handle
+ *
+ * Returns -ENOSYS
+ */
+static int ufshcd_pltfrm_resume(struct platform_device *pdev)
+{
+   /*
+* TODO:
+* 1. Set HCE to 1, to start the UFS host controller
+* initialization process
+* 2. Set UTRLRSR and UTMRLRSR bits to 1
+* 3. Change 

[PATCH V3 2/4] [SCSI] drivers/scsi/ufs: Separate PCI code into glue driver

2012-07-26 Thread Vinayak Holikatti
This patch separates PCI code from ufshcd.c and makes it as a
core driver module and adds a new file ufshcd-pci.c as PCI glue
driver.

Reviewed-by: Namjae Jeon 
Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/Kconfig |   26 ++-
 drivers/scsi/ufs/Makefile|1 +
 drivers/scsi/ufs/ufshcd-pci.c|  228 ++
 drivers/scsi/ufs/ufshcd.c|  329 ++
 drivers/scsi/ufs/ufshcd.h|  206 
 drivers/scsi/ufs/ufshcd_common.h |   53 ++
 6 files changed, 521 insertions(+), 322 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pci.c
 create mode 100644 drivers/scsi/ufs/ufshcd.h
 create mode 100644 drivers/scsi/ufs/ufshcd_common.h

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 8f27f9d..265a8c8 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -43,7 +43,27 @@
 # USA.
 
 config SCSI_UFSHCD
-   tristate "Universal Flash Storage host controller driver"
-   depends on PCI && SCSI
+   tristate "Universal Flash Storage Controller Driver Core"
+   depends on SCSI
---help---
-   This is a generic driver which supports PCIe UFS Host controllers.
+   This selects the support for UFS devices in Linux, say Y and make
+ sure that you know the name of your UFS host adapter (the card
+ inside your computer that "speaks" the UFS protocol, also
+ called UFS Host Controller), because you will be asked for it.
+ The module will be called ufshcd.
+
+ To compile this driver as a module, choose M here and read
+ .
+ However, do not compile this as a module if your root file system
+ (the one containing the directory /) is located on a UFS device.
+
+config SCSI_UFSHCD_PCI
+   tristate "PCI bus based UFS Controller support"
+   depends on SCSI_UFSHCD && PCI
+   ---help---
+   This selects the PCI UFS Host Controller Interface.
+ Most controllers found today are PCI devices.
+
+ If you have a controller with this interface, say Y or M here.
+
+ If unsure, say N.
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index adf7895..9eda0df 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,2 +1,3 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
+obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
new file mode 100644
index 000..d078744
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -0,0 +1,228 @@
+/*
+ * Universal Flash Storage Host controller driver
+ *
+ * This code is based on drivers/scsi/ufs/ufshcd-pci.c
+ * Copyright (C) 2011-2012 Samsung India Software Operations
+ *
+ * Santosh Yaraganavi 
+ * Vinayak Holikatti 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#include "ufshcd.h"
+#include "ufshcd_common.h"

[PATCH V3 1/4] [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code

2012-07-26 Thread Vinayak Holikatti
This patch seggregates the PCI specific code in ufshcd.c to make it
ready for splitting into core ufs driver and PCI glue driver.

Reviewed-by: Namjae Jeon 
Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/ufshcd.c |  277 -
 1 file changed, 150 insertions(+), 127 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 6a4fd00..c7b8f4b 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -129,7 +129,7 @@ struct uic_command {
  * @utrdl_dma_addr: UTRDL DMA address
  * @utmrdl_dma_addr: UTMRDL DMA address
  * @host: Scsi_Host instance of the driver
- * @pdev: PCI device handle
+ * @dev: device handle
  * @lrb: local reference block
  * @outstanding_tasks: Bits representing outstanding task requests
  * @outstanding_reqs: Bits representing outstanding transfer requests
@@ -159,7 +159,7 @@ struct ufs_hba {
dma_addr_t utmrdl_dma_addr;
 
struct Scsi_Host *host;
-   struct pci_dev *pdev;
+   struct device *dev;
 
struct ufshcd_lrb *lrb;
 
@@ -335,21 +335,21 @@ static inline void ufshcd_free_hba_memory(struct ufs_hba 
*hba)
 
if (hba->utmrdl_base_addr) {
utmrdl_size = sizeof(struct utp_task_req_desc) * hba->nutmrs;
-   dma_free_coherent(&hba->pdev->dev, utmrdl_size,
+   dma_free_coherent(hba->dev, utmrdl_size,
  hba->utmrdl_base_addr, hba->utmrdl_dma_addr);
}
 
if (hba->utrdl_base_addr) {
utrdl_size =
(sizeof(struct utp_transfer_req_desc) * hba->nutrs);
-   dma_free_coherent(&hba->pdev->dev, utrdl_size,
+   dma_free_coherent(hba->dev, utrdl_size,
  hba->utrdl_base_addr, hba->utrdl_dma_addr);
}
 
if (hba->ucdl_base_addr) {
ucdl_size =
(sizeof(struct utp_transfer_cmd_desc) * hba->nutrs);
-   dma_free_coherent(&hba->pdev->dev, ucdl_size,
+   dma_free_coherent(hba->dev, ucdl_size,
  hba->ucdl_base_addr, hba->ucdl_dma_addr);
}
 }
@@ -724,7 +724,7 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba)
 
/* Allocate memory for UTP command descriptors */
ucdl_size = (sizeof(struct utp_transfer_cmd_desc) * hba->nutrs);
-   hba->ucdl_base_addr = dma_alloc_coherent(&hba->pdev->dev,
+   hba->ucdl_base_addr = dma_alloc_coherent(hba->dev,
 ucdl_size,
 &hba->ucdl_dma_addr,
 GFP_KERNEL);
@@ -737,7 +737,7 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba)
 */
if (!hba->ucdl_base_addr ||
WARN_ON(hba->ucdl_dma_addr & (PAGE_SIZE - 1))) {
-   dev_err(&hba->pdev->dev,
+   dev_err(hba->dev,
"Command Descriptor Memory allocation failed\n");
goto out;
}
@@ -747,13 +747,13 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba)
 * UFSHCI requires 1024 byte alignment of UTRD
 */
utrdl_size = (sizeof(struct utp_transfer_req_desc) * hba->nutrs);
-   hba->utrdl_base_addr = dma_alloc_coherent(&hba->pdev->dev,
+   hba->utrdl_base_addr = dma_alloc_coherent(hba->dev,
  utrdl_size,
  &hba->utrdl_dma_addr,
  GFP_KERNEL);
if (!hba->utrdl_base_addr ||
WARN_ON(hba->utrdl_dma_addr & (PAGE_SIZE - 1))) {
-   dev_err(&hba->pdev->dev,
+   dev_err(hba->dev,
"Transfer Descriptor Memory allocation failed\n");
goto out;
}
@@ -763,13 +763,13 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba)
 * UFSHCI requires 1024 byte alignment of UTMRD
 */
utmrdl_size = sizeof(struct utp_task_req_desc) * hba->nutmrs;
-   hba->utmrdl_base_addr = dma_alloc_coherent(&hba->pdev->dev,
+   hba->utmrdl_base_addr = dma_alloc_coherent(hba->dev,
   utmrdl_size,
   &hba->utmrdl_dma_addr,
   GFP_KERNEL);
if (!hba->utmrdl_base_addr ||
WARN_ON(hba->utmrdl_dma_addr & (PAGE_SIZE - 1))) {
-   dev_err(&hba->pdev->dev,
+   dev_err(hba->dev,
"Task Management Descriptor Memory allocation failed\n");
   

[PATCH V3 0/4] [SCSI] ufs: Adds glue drivers to ufshcd

2012-07-26 Thread Vinayak Holikatti
This patch set adds following features
 - Seggregate PCI specific code in ufshcd.c
 - Adds PCI glue driver ufshcd-pci.c and ufshcd.c become core module
 - Adds Platform glue driver ufshcd-pltfrm.c
 - Update correct transfer size in Command UPIU

Vinayak Holikatti (4):
  [SCSI] drivers/scsi/ufs: Seggregate PCI Specific Code
  [SCSI] drivers/scsi/ufs: Separate PCI code into glue driver
  [SCSI] ufs: Add Platform glue driver for ufshcd
  [SCSI] ufs: Correct the expected data transfer size

 drivers/scsi/ufs/Kconfig |   37 +++-
 drivers/scsi/ufs/Makefile|2 +
 drivers/scsi/ufs/ufshcd-pci.c|  228 
 drivers/scsi/ufs/ufshcd-pltfrm.c |  222 
 drivers/scsi/ufs/ufshcd.c|  422 ++
 drivers/scsi/ufs/ufshcd.h|  206 +++
 drivers/scsi/ufs/ufshcd_common.h |   53 +
 7 files changed, 813 insertions(+), 357 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pci.c
 create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.c
 create mode 100644 drivers/scsi/ufs/ufshcd.h
 create mode 100644 drivers/scsi/ufs/ufshcd_common.h

-- 
1.7.9.5

--
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/4] [SCSI] ufs: Adds glue drivers to ufshcd

2012-07-19 Thread vinayak holikatti
On Mon, Jul 16, 2012 at 9:52 PM, Arnd Bergmann  wrote:
> On Monday 16 July 2012, James Bottomley wrote:
>> On Fri, 2012-07-13 at 15:45 +, Arnd Bergmann wrote:
>> > On Friday 13 July 2012, Vinayak Holikatti wrote:
>> > > This patch set adds following features
>> > >  - Seprates PCI specific code from ufshcd.c to make it as core
>> > >  - Adds PCI glue driver ufshcd-pci.c
>> > >  - Adds Platform glue driver ufshcd-pltfrm.c
>> > >  - Update correct transfer size in Command UPIU
>> >
>> > Acked-by: Arnd Bergmann 
>>
>> I need a maintainer ack for this to go upstream.
>>
>> Also, looking at this, I think this patch series isn't bisectable:
>> Patch 1 removes PCI support and patch 2 adds it back in a different
>> form.  However, any PCI based UFS system would stop working if the
>> bisect landed at patch 1.  I think you can fix this just by combining
>> patches 1 and 2.
>
> I suggested to split the patch in two in a private review that we
> did on the linaro mailing list. I gave my Ack because the split
> was done, but I failed to notice that it was done differently
> from what I suggested in
>
> On Monday 02 July 2012, Arnd Bergmann wrote:
>> I would recommend that you split this patch into two separate
>> changesets, where you do all the changes to existing code in the
>> first patch, and only move but don't change code in the second one
>> that creates the new file.
>
> I agree that breaking bisectibility by ripping out the PCI code
> first is not good. The version 2 is not actually easier to review
> at all than the first version, it just splits the changes by
> file, which is pointless.
I will roll out another patch series which will address the current issue.
Firstly will modify existing code with PCI code and then in the second
move the code to new file ufshcd-pci.c
>
> Arnd
>
--
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/4] [SCSI] ufs: Add Platform glue driver for ufshcd

2012-07-16 Thread vinayak holikatti
On Mon, Jul 16, 2012 at 7:19 PM, Namjae Jeon  wrote:
> Hi Vinayak.
>> + * ufshcd_pltfrm_remove - remove platform driver routine
>> + * @pdev: pointer to platform device handle
>> + *
>> + * Returns 0 on success, non-zero value on failure
>> + */
>> +static int __devexit ufshcd_pltfrm_remove(struct platform_device *pdev)
>> +{
>> + struct resource *mem_res;
>> + struct resource *irq_res;
>> + resource_size_t mem_size;
>> + struct ufs_hba *hba =  platform_get_drvdata(pdev);
>> +
>> + ufshcd_remove(hba);
>> + irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>> + if (!irq_res)
>> + dev_err(&pdev->dev, "ufshcd: IRQ resource not available\n");
>> + free_irq(irq_res->start, hba);
> Is there no possibility of null pointer dereferencing error ?(irq_res->start)
> I think that free_irq should be not called if irq_res is NULL.
I agree, I have overlooked at this logic, the free_irq should have
been in the else
part of this section. I will make the modification in the next version
of patches.
>> + mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> Looks mem_res is also same with upper case.
> Thanks.
>> + mem_size = resource_size(mem_res);
>> + release_mem_region(mem_res->start, mem_size);
>> + platform_set_drvdata(pdev, NULL);
>> + return 0;
>> +}
>> +
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 4/4] [SCSI] ufs: Correct the expected data transfer size

2012-07-13 Thread Vinayak Holikatti
This patch corrects the expected data transfer size of the
command UPIU. The current implementation of cmd->transfersize
is wrong as it probably equal to sector size. With this
implementation the transfer size is updated correctly

Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/ufshcd.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index dfc3e85..5e732c3 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -488,7 +488,7 @@ static void ufshcd_compose_upiu(struct ufshcd_lrb *lrbp)
ucd_cmd_ptr->header.dword_2 = 0;
 
ucd_cmd_ptr->exp_data_transfer_len =
-   cpu_to_be32(lrbp->cmd->transfersize);
+   cpu_to_be32(lrbp->cmd->sdb.length);
 
memcpy(ucd_cmd_ptr->cdb,
   lrbp->cmd->cmnd,
-- 
1.7.9.5

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


[PATCH V2 3/4] [SCSI] ufs: Add Platform glue driver for ufshcd

2012-07-13 Thread Vinayak Holikatti
This patch adds Platform glue driver for ufshcd.

Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/Kconfig |   11 ++
 drivers/scsi/ufs/Makefile|1 +
 drivers/scsi/ufs/ufshcd-pltfrm.c |  215 ++
 3 files changed, 227 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.c

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 265a8c8..8c06330 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -67,3 +67,14 @@ config SCSI_UFSHCD_PCI
  If you have a controller with this interface, say Y or M here.
 
  If unsure, say N.
+
+config SCSI_UFSHCD_PLATFORM
+   tristate "Platform based UFS Controller support"
+   depends on SCSI_UFSHCD
+   ---help---
+   This selects the UFS host controller support. If you have a
+  platform with UFS controller, say Y or M here.
+
+  If you have a controller with this interface, say Y or M here.
+
+ If unsure, say N.
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 9eda0df..1e5bd48 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,3 +1,4 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
+obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
new file mode 100644
index 000..1d3a63f
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -0,0 +1,215 @@
+/*
+ * Universal Flash Storage Host controller driver
+ *
+ * This code is based on drivers/scsi/ufs/ufshcd-pltfm.c
+ * Copyright (C) 2011-2012 Samsung India Software Operations
+ *
+ * Santosh Yaraganavi 
+ * Vinayak Holikatti 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#include "ufshcd.h"
+#include "ufshcd_common.h"
+#include 
+
+#ifdef CONFIG_PM
+/**
+ * ufshcd_suspend - suspend power management function
+ * @pdev: pointer to Platform device handle
+ * @mesg: power state
+ *
+ * Returns -ENOSYS
+ */
+static int ufshcd_pltfrm_suspend(struct platform_device *pdev,
+pm_message_t mesg)
+{
+   /*
+* TODO:
+* 1. Block SCSI requests from SCSI midlayer
+* 2. Change the internal driver state to non operational
+* 3. Set UTRLRSR and UTMRLRSR bits to zero
+* 4. Wait until outstanding commands are completed
+* 5. Set HCE to zero to send the UFS host controller to reset state
+*/
+
+   return -ENOSYS;
+}
+
+/**
+ * ufshcd_resume - resume power management function
+ * @pdev: pointer to Platform device handle
+ *
+ * Returns -ENOSYS
+ */
+static int ufshcd_pltfrm_resume(struct platform_device *pdev)
+{
+   /*
+* TODO:
+* 1. Set HCE to 1, to start the UFS host controller
+* initialization process
+* 2. Set UTRLRSR and UTMRLRSR bits to 1
+* 3. Change the internal driver state to operational
+

[PATCH V2 2/4] [SCSI] drivers/scsi/ufs: Add PCI glue driver

2012-07-13 Thread Vinayak Holikatti
This patch adds PCI glue driver support

Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/Kconfig |   11 ++
 drivers/scsi/ufs/Makefile|1 +
 drivers/scsi/ufs/ufshcd-pci.c|  227 ++
 drivers/scsi/ufs/ufshcd.c|  154 +-
 drivers/scsi/ufs/ufshcd.h|  206 ++
 drivers/scsi/ufs/ufshcd_common.h |   53 +
 6 files changed, 499 insertions(+), 153 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pci.c
 create mode 100644 drivers/scsi/ufs/ufshcd.h
 create mode 100644 drivers/scsi/ufs/ufshcd_common.h

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 8c0cd22..265a8c8 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -56,3 +56,14 @@ config SCSI_UFSHCD
  .
  However, do not compile this as a module if your root file system
  (the one containing the directory /) is located on a UFS device.
+
+config SCSI_UFSHCD_PCI
+   tristate "PCI bus based UFS Controller support"
+   depends on SCSI_UFSHCD && PCI
+   ---help---
+   This selects the PCI UFS Host Controller Interface.
+ Most controllers found today are PCI devices.
+
+ If you have a controller with this interface, say Y or M here.
+
+ If unsure, say N.
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index adf7895..9eda0df 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,2 +1,3 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
+obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
new file mode 100644
index 000..0c0cc92
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -0,0 +1,227 @@
+/*
+ * Universal Flash Storage Host controller driver
+ *
+ * This code is based on drivers/scsi/ufs/ufshcd-pci.c
+ * Copyright (C) 2011-2012 Samsung India Software Operations
+ *
+ * Santosh Yaraganavi 
+ * Vinayak Holikatti 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * NO WARRANTY
+ * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+ * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
+ * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
+ * solely responsible for determining the appropriateness of using and
+ * distributing the Program and assumes all risks associated with its
+ * exercise of rights under this Agreement, including but not limited to
+ * the risks and costs of program errors, damage to or loss of data,
+ * programs or equipment, and unavailability or interruption of operations.
+
+ * DISCLAIMER OF LIABILITY
+ * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+ * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+ * USA.
+ */
+
+#include "ufshcd.h"
+#include "ufshcd_common.h"
+#include 
+
+#ifdef CONFIG_PM
+/**
+ * ufshcd_suspend - suspend power management function
+ * @pdev: pointer to PCI device handle
+ * @state: power state
+ *
+ * Returns -ENOSYS
+ */
+static int ufshcd_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+   /*
+* TODO:
+* 1. Block SCSI requests from SCSI midlayer
+* 2. Change the internal driver state to non operational
+* 3. Set UTRLRSR and UTMRLRSR bits to zero
+* 4. Wait until outstanding commands are completed
+* 5. Set HCE to zero to send the UFS host controller to reset state
+*/
+
+   return -ENOSYS;
+}
+
+/**
+ * ufshcd_resume - resume power management function
+ * @pdev: pointer to PCI device handle
+ *
+ * Returns -ENOSYS
+ */
+static int ufshcd_pci_resume(struct pci_dev *pdev)
+{
+   /*
+

[PATCH V2 1/4] [SCSI] drivers/scsi/ufs: Remove PCI specific code

2012-07-13 Thread Vinayak Holikatti
This patch removes the PCI specific code to make it into
core ufs driver. This separation allows room for other
bus specific glue drivers to be added in future

Signed-off-by: Vinayak Holikatti 
Signed-off-by: Santosh Yaraganavi 
---
 drivers/scsi/ufs/Kconfig  |   15 ++-
 drivers/scsi/ufs/ufshcd.c |  270 -
 2 files changed, 80 insertions(+), 205 deletions(-)

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 8f27f9d..8c0cd22 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -43,7 +43,16 @@
 # USA.
 
 config SCSI_UFSHCD
-   tristate "Universal Flash Storage host controller driver"
-   depends on PCI && SCSI
+   tristate "Universal Flash Storage Controller Driver Core"
+   depends on SCSI
---help---
-   This is a generic driver which supports PCIe UFS Host controllers.
+   This selects the support for UFS devices in Linux, say Y and make
+ sure that you know the name of your UFS host adapter (the card
+ inside your computer that "speaks" the UFS protocol, also
+ called UFS Host Controller), because you will be asked for it.
+ The module will be called ufshcd.
+
+ To compile this driver as a module, choose M here and read
+ .
+ However, do not compile this as a module if your root file system
+ (the one containing the directory /) is located on a UFS device.
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 6a4fd00..ef442c9 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -129,7 +129,7 @@ struct uic_command {
  * @utrdl_dma_addr: UTRDL DMA address
  * @utmrdl_dma_addr: UTMRDL DMA address
  * @host: Scsi_Host instance of the driver
- * @pdev: PCI device handle
+ * @dev: device handle
  * @lrb: local reference block
  * @outstanding_tasks: Bits representing outstanding task requests
  * @outstanding_reqs: Bits representing outstanding transfer requests
@@ -159,7 +159,7 @@ struct ufs_hba {
dma_addr_t utmrdl_dma_addr;
 
struct Scsi_Host *host;
-   struct pci_dev *pdev;
+   struct device *dev;
 
struct ufshcd_lrb *lrb;
 
@@ -335,21 +335,21 @@ static inline void ufshcd_free_hba_memory(struct ufs_hba 
*hba)
 
if (hba->utmrdl_base_addr) {
utmrdl_size = sizeof(struct utp_task_req_desc) * hba->nutmrs;
-   dma_free_coherent(&hba->pdev->dev, utmrdl_size,
+   dma_free_coherent(hba->dev, utmrdl_size,
  hba->utmrdl_base_addr, hba->utmrdl_dma_addr);
}
 
if (hba->utrdl_base_addr) {
utrdl_size =
(sizeof(struct utp_transfer_req_desc) * hba->nutrs);
-   dma_free_coherent(&hba->pdev->dev, utrdl_size,
+   dma_free_coherent(hba->dev, utrdl_size,
  hba->utrdl_base_addr, hba->utrdl_dma_addr);
}
 
if (hba->ucdl_base_addr) {
ucdl_size =
(sizeof(struct utp_transfer_cmd_desc) * hba->nutrs);
-   dma_free_coherent(&hba->pdev->dev, ucdl_size,
+   dma_free_coherent(hba->dev, ucdl_size,
  hba->ucdl_base_addr, hba->ucdl_dma_addr);
}
 }
@@ -724,7 +724,7 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba)
 
/* Allocate memory for UTP command descriptors */
ucdl_size = (sizeof(struct utp_transfer_cmd_desc) * hba->nutrs);
-   hba->ucdl_base_addr = dma_alloc_coherent(&hba->pdev->dev,
+   hba->ucdl_base_addr = dma_alloc_coherent(hba->dev,
 ucdl_size,
 &hba->ucdl_dma_addr,
 GFP_KERNEL);
@@ -737,7 +737,7 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba)
 */
if (!hba->ucdl_base_addr ||
WARN_ON(hba->ucdl_dma_addr & (PAGE_SIZE - 1))) {
-   dev_err(&hba->pdev->dev,
+   dev_err(hba->dev,
"Command Descriptor Memory allocation failed\n");
goto out;
}
@@ -747,13 +747,13 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba)
 * UFSHCI requires 1024 byte alignment of UTRD
 */
utrdl_size = (sizeof(struct utp_transfer_req_desc) * hba->nutrs);
-   hba->utrdl_base_addr = dma_alloc_coherent(&hba->pdev->dev,
+   hba->utrdl_base_addr = dma_alloc_coherent(hba->dev,
  utrdl_size,
  &hba->utrdl_dma_addr,
  GFP_KERNEL);
if (!hba->utrdl_base_addr ||
 

[PATCH V2 0/4] [SCSI] ufs: Adds glue drivers to ufshcd

2012-07-13 Thread Vinayak Holikatti
This patch set adds following features
 - Seprates PCI specific code from ufshcd.c to make it as core
 - Adds PCI glue driver ufshcd-pci.c
 - Adds Platform glue driver ufshcd-pltfrm.c
 - Update correct transfer size in Command UPIU

Vinayak Holikatti (4):
  [SCSI] drivers/scsi/ufs: Remove PCI specific code
  [SCSI] drivers/scsi/ufs: Add PCI glue driver
  [SCSI] ufs: Add Platform glue driver for ufshcd
  [SCSI] ufs: Correct the expected data transfer size

 drivers/scsi/ufs/Kconfig |   37 +++-
 drivers/scsi/ufs/Makefile|2 +
 drivers/scsi/ufs/ufshcd-pci.c|  227 
 drivers/scsi/ufs/ufshcd-pltfrm.c |  215 +++
 drivers/scsi/ufs/ufshcd.c|  422 ++
 drivers/scsi/ufs/ufshcd.h|  206 +++
 drivers/scsi/ufs/ufshcd_common.h |   53 +
 7 files changed, 805 insertions(+), 357 deletions(-)
 create mode 100644 drivers/scsi/ufs/ufshcd-pci.c
 create mode 100644 drivers/scsi/ufs/ufshcd-pltfrm.c
 create mode 100644 drivers/scsi/ufs/ufshcd.h
 create mode 100644 drivers/scsi/ufs/ufshcd_common.h

-- 
1.7.9.5

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


Re: [PATCH 3/4] [SCSI] ufs: Add AMBA glue driver to ufshcd

2012-07-10 Thread vinayak holikatti
On Mon, Jul 2, 2012 at 8:50 PM, Arnd Bergmann  wrote:
> On Monday 02 July 2012, Vinayak Holikatti wrote:
>> +static struct amba_id ufshcd_amba_ids[] = {
>> +   {
>> +   /* Fake id for Primecell.*/
>> +   .id = 0x00041FF0,
>> +   .mask   = 0x000f,
>> +   },
>> +   { 0, 0 },
>> +};
>
> Hi Vinayak,
>
> Can you explain where this fake ID comes from? Is this ID actually
> used by any hardware that is around somewhere? If not, I think it
> would be better not to provide an AMBA driver at all, but instead
> use the platform driver from patch 2 for all non-PCI uses.
The fake ID is just a dummy ID. As you say, we will drop the amba driver
for now. When primecell controller comes up, we will have the driver integrated.
>
> Arnd
--
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/4] [SCSI] ufs: Add Platform glue driver for ufshcd

2012-07-10 Thread vinayak holikatti
On Mon, Jul 2, 2012 at 8:57 PM, Arnd Bergmann  wrote:
> On Monday 02 July 2012, Vinayak Holikatti wrote:
>> +static struct platform_driver ufshcd_pltfrm_driver = {
>> +   .probe  = ufshcd_pltfrm_probe,
>> +   .remove = __devexit_p(ufshcd_pltfrm_remove),
>> +#ifdef CONFIG_PM
>> +   .suspend = ufshcd_pltfrm_suspend,
>> +   .resume = ufshcd_pltfrm_resume,
>> +#endif
>> +   .driver = {
>> +   .name   = "ufshcd",
>> +   .owner  = THIS_MODULE,
>> +   },
>> +};
>
> Hi Vinayak,
>
> Please add a device tree match table here to allow the driver to be
> used by modern platforms that only do device tree based hardware
> detection. Just look in other drivers for existing uses of
> "of_match_table" to be used.
>
> I'm not sure what the "compatible" string should be in this case,
> because the it matches a JEDEC specification, not a particular
> vendor's implementation of it. The match table can have multiple
> entries, which is useful if you have multiple implementations
> that are slightly different or don't fully conform to the spec.
>
> Maybe a list like
>
> static const struct of_device_id ufs_of_match[] = {
> { .compatible = "jedec,ufs-1.1" },
> }
>
> would be enough for now.
Ok, will implement device tree match table.
>
> Arnd
--
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/4] [SCSI] ufs: Separate PCI glue driver for ufshcd

2012-07-10 Thread vinayak holikatti
On Mon, Jul 2, 2012 at 8:47 PM, Arnd Bergmann  wrote:
> On Monday 02 July 2012, Vinayak Holikatti wrote:
>>
>> This patch separates PCI and core UFS host controller driver.
>> In the current implementation PCI specific code is with ufshcd.c.
>> To provide way for adding multiple bus glue driver, this patch
>> separates PCI layer from ufshcd core. Now ufshcd compiles as separate
>> module and ufshcd-pci as separate module.
>>
>> Signed-off-by: Vinayak Holikatti 
>> Signed-off-by: Santosh Yaraganavi 
>
> Hi Vinayak,
>
> This patch looks good at first sight, but it's a little hard to
> review in the form that you are posting.
>
> I would recommend that you split this patch into two separate
> changesets, where you do all the changes to existing code in the
> first patch, and only move but don't change code in the second one
> that creates the new file.
 Ok, will spilt accordinglly to make it two changesets.
>
> Arnd
--
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