From: Subhash Jadavani <subhashj@codeaurora.org>
To: Seungwon Jeon <tgih.jun@samsung.com>
Cc: linux-scsi@vger.kernel.org,
'Vinayak Holikatti' <vinholikatti@gmail.com>,
'Santosh Y' <santoshsy@gmail.com>,
"'James E.J. Bottomley'" <JBottomley@parallels.com>
Subject: Re: [PATCH 4/7] scsi: ufs: add dme configuration primitives
Date: Tue, 13 Aug 2013 12:26:19 +0530 [thread overview]
Message-ID: <5209D893.3020100@codeaurora.org> (raw)
In-Reply-To: <002801ce8d24$fb743880$f25ca980$%jun@samsung.com>
On 7/30/2013 6:32 PM, Seungwon Jeon wrote:
> On Mon, July 29, 2013, Subhash Jadavani wrote:
>> On 7/26/2013 7:17 PM, Seungwon Jeon wrote:
>>> Implements to support GET and SET operations of the DME.
>>> These operations are used to configure the behavior of
>>> the UNIPRO. Along with basic operation, {Peer/AttrSetType}
>>> can be mixed.
>>>
>>> Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com>
>>> ---
>>> drivers/scsi/ufs/ufshcd.c | 88 +++++++++++++++++++++++++++++++++++++++++++++
>>> drivers/scsi/ufs/ufshcd.h | 51 ++++++++++++++++++++++++++
>>> drivers/scsi/ufs/ufshci.h | 6 +++
>>> 3 files changed, 145 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
>>> index 7152ec4..8277c40 100644
>>> --- a/drivers/scsi/ufs/ufshcd.c
>>> +++ b/drivers/scsi/ufs/ufshcd.c
>>> @@ -188,6 +188,18 @@ static inline int ufshcd_get_uic_cmd_result(struct ufs_hba *hba)
>>> }
>>>
>>> /**
>>> + * ufshcd_get_dme_attr_val - Get the value of attribute returned by UIC command
>>> + * @hba: Pointer to adapter instance
>>> + *
>>> + * This function gets UIC command argument3
>>> + * Returns 0 on success, non zero value on error
>>> + */
>>> +static inline u32 ufshcd_get_dme_attr_val(struct ufs_hba *hba)
>>> +{
>>> + return ufshcd_readl(hba, REG_UIC_COMMAND_ARG_3);
>>> +}
>>> +
>>> +/**
>>> * ufshcd_is_valid_req_rsp - checks if controller TR response is valid
>>> * @ucd_rsp_ptr: pointer to response UPIU
>>> *
>>> @@ -821,6 +833,80 @@ static int ufshcd_dme_link_startup(struct ufs_hba *hba)
>>> }
>>>
>>> /**
>>> + * ufshcd_dme_set_attr - UIC command for DME_SET, DME_PEER_SET
>>> + * @hba: per adapter instance
>>> + * @attr_sel: uic command argument1
>>> + * @attr_set: attribute set type as uic command argument2
>>> + * @mib_val: setting value as uic command argument3
>>> + * @peer: indicate wherter peer or non-peer
>> typo: s/wtherter/whether
>> This would sound better: s/non-peer/local
> Ok.
thanks.
>
>> Do above for ufshcd_dme_get_attr() function as well.
>>> + *
>>> + * Returns 0 on success, non-zero value on failure
>>> + */
>>> +int ufshcd_dme_set_attr(struct ufs_hba *hba, u32 attr_sel,
>>> + u8 attr_set, u32 mib_val, u8 peer)
>>> +{
>>> + struct uic_command uic_cmd = {0};
>>> + static const char *const action[] = {
>>> + "dme-set",
>>> + "dme-peer-set"
>>> + };
>>> + const char *set = action[!!peer];
>>> + int ret;
>>> +
>>> + uic_cmd.command = peer ?
>>> + UIC_CMD_DME_PEER_SET : UIC_CMD_DME_SET;
>>> + uic_cmd.argument1 = attr_sel;
>>> + uic_cmd.argument2 = UIC_ARG_ATTR_TYPE(attr_set);
>>> + uic_cmd.argument3 = mib_val;
>>> +
>>> + ret = ufshcd_send_uic_cmd(hba, &uic_cmd);
>>> + if (ret)
>>> + dev_err(hba->dev, "%s: attr-id 0x%x error code %d\n",
>>> + set, UIC_GET_ATTR_ID(attr_sel), ret);
>> Its also good to print the "mib_val" which we were trying to set. It
>> might be possible that DME_SET failed because we are trying to set out
>> of range value to MIB attribute.
> I'll add it.
thanks
>
>>> +
>>> + return ret;
>>> +}
>>> +EXPORT_SYMBOL_GPL(ufshcd_dme_set_attr);
>>> +
>>> +/**
>>> + * ufshcd_dme_get_attr - UIC command for DME_GET, DME_PEER_GET
>>> + * @hba: per adapter instance
>>> + * @attr_sel: uic command argument1
>>> + * @mib_val: the value of the attribute as returned by the UIC command
>>> + * @peer: indicate wherter peer or non-peer
>>> + *
>>> + * Returns 0 on success, non-zero value on failure
>>> + */
>>> +int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
>>> + u32 *mib_val, u8 peer)
>>> +{
>>> + struct uic_command uic_cmd = {0};
>>> + static const char *const action[] = {
>>> + "dme-get",
>>> + "dme-peer-get"
>>> + };
>>> + const char *get = action[!!peer];
>>> + int ret;
>>> +
>>> + uic_cmd.command = peer ?
>>> + UIC_CMD_DME_PEER_GET : UIC_CMD_DME_GET;
>>> + uic_cmd.argument1 = attr_sel;
>>> +
>>> + ret = ufshcd_send_uic_cmd(hba, &uic_cmd);
>>> + if (ret) {
>>> + dev_err(hba->dev, "%s: attr-id 0x%x error code %d\n",
>>> + get, UIC_GET_ATTR_ID(attr_sel), ret);
>>> + goto out;
>>> + }
>>> +
>>> + if (mib_val)
>>> + *mib_val = uic_cmd.argument3;
>>> +out:
>>> + return ret;
>>> +}
>>> +EXPORT_SYMBOL_GPL(ufshcd_dme_get_attr);
>>> +
>>> +/**
>>> * ufshcd_make_hba_operational - Make UFS controller operational
>>> * @hba: per adapter instance
>>> *
>>> @@ -1256,6 +1342,8 @@ static void ufshcd_uic_cmd_compl(struct ufs_hba *hba)
>>> if (hba->active_uic_cmd) {
>>> hba->active_uic_cmd->argument2 |=
>>> ufshcd_get_uic_cmd_result(hba);
>>> + hba->active_uic_cmd->argument3 =
>>> + ufshcd_get_dme_attr_val(hba);
>> We can optimize here by reading the dme_attribute value only if
>> active_uic_cmd->command is set to DME_GET or DME_PEER_GET. For all other
>> DME commands, meaning of this is "reserved" for read.
> Right, you have a point.
> But when considering the access of 'hba->active_uic_cmd->command" every time and additional 'branch statement',
> it looks like no difference in terms of the optimization.
> Reading the dme_attribute value could be trivial thing.
I would consider the peripheral register to be time heavy (as it may run
on slower peripheral bus) compared to variable read (from cache/RAM) &
branch statement. But i leave it upto you and it would be fine anyway.
>
>> Also, i guess reading of the argument2 and argument3 registers can be
>> moved to ufshcd_wait_for_uic_cmd() function (process context) intead of
>> interrupt context.
> Yes, it may be possible.
> But I wanted to update the result of uic command as soon as IS.UCCS occurs and simplify error handling.
Ok.
>
> Thanks,
> Seungwon Jeon
>
>>> complete(&hba->active_uic_cmd->done);
>>> }
>>> }
>>> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
>>> index 49590ee..50bcd29 100644
>>> --- a/drivers/scsi/ufs/ufshcd.h
>>> +++ b/drivers/scsi/ufs/ufshcd.h
>>> @@ -199,6 +199,11 @@ int ufshcd_init(struct device *, struct ufs_hba ** , void __iomem * ,
>>> unsigned int);
>>> void ufshcd_remove(struct ufs_hba *);
>>>
>>> +extern int ufshcd_dme_set_attr(struct ufs_hba *hba, u32 attr_sel,
>>> + u8 attr_set, u32 mib_val, u8 peer);
>>> +extern int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel,
>>> + u32 *mib_val, u8 peer);
>>> +
>>> /**
>>> * ufshcd_hba_stop - Send controller to reset state
>>> * @hba: per adapter instance
>>> @@ -208,4 +213,50 @@ static inline void ufshcd_hba_stop(struct ufs_hba *hba)
>>> ufshcd_writel(hba, CONTROLLER_DISABLE, REG_CONTROLLER_ENABLE);
>>> }
>>>
>>> +/* UIC command interfaces for DME primitives */
>>> +#define DME_LOCAL 0
>>> +#define DME_PEER 1
>>> +#define ATTR_SET_NOR 0 /* NORMAL */
>>> +#define ATTR_SET_ST 1 /* STATIC */
>>> +
>>> +static inline int ufshcd_dme_set(struct ufs_hba *hba, u32 attr_sel,
>>> + u32 mib_val)
>>> +{
>>> + return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_NOR,
>>> + mib_val, DME_LOCAL);
>>> +}
>>> +
>>> +static inline int ufshcd_dme_st_set(struct ufs_hba *hba, u32 attr_sel,
>>> + u32 mib_val)
>>> +{
>>> + return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_ST,
>>> + mib_val, DME_LOCAL);
>>> +}
>>> +
>>> +static inline int ufshcd_dme_peer_set(struct ufs_hba *hba, u32 attr_sel,
>>> + u32 mib_val)
>>> +{
>>> + return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_NOR,
>>> + mib_val, DME_PEER);
>>> +}
>>> +
>>> +static inline int ufshcd_dme_peer_st_set(struct ufs_hba *hba, u32 attr_sel,
>>> + u32 mib_val)
>>> +{
>>> + return ufshcd_dme_set_attr(hba, attr_sel, ATTR_SET_ST,
>>> + mib_val, DME_PEER);
>>> +}
>>> +
>>> +static inline int ufshcd_dme_get(struct ufs_hba *hba,
>>> + u32 attr_sel, u32 *mib_val)
>>> +{
>>> + return ufshcd_dme_get_attr(hba, attr_sel, mib_val, DME_LOCAL);
>>> +}
>>> +
>>> +static inline int ufshcd_dme_peer_get(struct ufs_hba *hba,
>>> + u32 attr_sel, u32 *mib_val)
>>> +{
>>> + return ufshcd_dme_get_attr(hba, attr_sel, mib_val, DME_PEER);
>>> +}
>>> +
>>> #endif /* End of Header */
>>> diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
>>> index a8f69cc..df4901e 100644
>>> --- a/drivers/scsi/ufs/ufshci.h
>>> +++ b/drivers/scsi/ufs/ufshci.h
>>> @@ -191,6 +191,12 @@ enum {
>>> #define CONFIG_RESULT_CODE_MASK 0xFF
>>> #define GENERIC_ERROR_CODE_MASK 0xFF
>>>
>>> +#define UIC_ARG_MIB_SEL(attr, sel) ((((attr) & 0xFFFF) << 16) |\
>>> + ((sel) & 0xFFFF))
>>> +#define UIC_ARG_MIB(attr) UIC_ARG_MIB_SEL(attr, 0)
>>> +#define UIC_ARG_ATTR_TYPE(t) (((t) & 0xFF) << 16)
>>> +#define UIC_GET_ATTR_ID(v) (((v) >> 16) & 0xFFFF)
>>> +
>>> /* UIC Commands */
>>> enum {
>>> UIC_CMD_DME_GET = 0x01,
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-08-13 6:56 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-20 0:41 [PATCH v2 0/3] ufs: fix bugs in probing and removing driver paths Akinobu Mita
2013-07-20 0:41 ` [PATCH v2 1/3] ufshcd-pci: release ioremapped region during removing driver Akinobu Mita
2013-07-26 13:45 ` [PATCH 1/7] scsi: ufs: amend the ocs handling with fatal error Seungwon Jeon
2013-07-29 6:17 ` Subhash Jadavani
2013-07-29 10:05 ` Seungwon Jeon
2013-07-29 10:27 ` Subhash Jadavani
2013-07-29 10:51 ` Sujit Reddy Thumma
2013-07-30 13:02 ` Seungwon Jeon
2013-08-12 7:17 ` Subhash Jadavani
2013-08-13 11:50 ` Seungwon Jeon
2013-08-13 13:39 ` Subhash Jadavani
2013-07-29 18:03 ` Santosh Y
2013-07-20 0:41 ` [PATCH v2 2/3] ufs: don't disable_irq() if the IRQ can be shared among devices Akinobu Mita
2013-07-26 13:44 ` [PATCH 0/7] scsi: ufs: some fixes and updates Seungwon Jeon
2013-08-23 13:00 ` [PATCH v2 0/6] " Seungwon Jeon
2013-08-25 11:23 ` Dolev Raviv
2013-08-26 14:40 ` [PATCH v3 " Seungwon Jeon
2013-08-28 10:46 ` Subhash Jadavani
2013-07-20 0:41 ` [PATCH v2 3/3] ufs: don't stop controller before scsi_remove_host() Akinobu Mita
2013-07-26 13:46 ` [PATCH 2/7] scsi: ufs: find out sense data over scsi status values Seungwon Jeon
2013-07-29 6:35 ` Subhash Jadavani
2013-07-30 13:00 ` Seungwon Jeon
2013-07-29 10:51 ` Sujit Reddy Thumma
2013-07-30 13:03 ` Seungwon Jeon
2013-07-30 3:53 ` Santosh Y
2013-07-30 13:03 ` Seungwon Jeon
2013-07-31 0:15 ` Elliott, Robert (Server Storage)
2013-08-06 12:08 ` Seungwon Jeon
2013-08-23 13:00 ` [PATCH v2 1/6] " Seungwon Jeon
2013-08-23 13:00 ` [PATCH v2 2/6] scsi: ufs: fix the setting interrupt aggregation counter Seungwon Jeon
2013-08-23 13:00 ` [PATCH v2 3/6] scsi: ufs: add dme configuration primitives Seungwon Jeon
2013-08-23 13:00 ` [PATCH v2 4/6] scsi: ufs: add unipro attribute IDs Seungwon Jeon
2013-08-23 13:00 ` [PATCH v2 5/6] scsi: ufs: add operation for the uic power mode change Seungwon Jeon
2013-08-23 13:00 ` [PATCH v2 6/6] scsi: ufs: configure the attribute for power mode Seungwon Jeon
2013-08-26 14:40 ` [PATCH v3 1/6] scsi: ufs: find out sense data over scsi status values Seungwon Jeon
2013-08-27 8:53 ` Subhash Jadavani
2013-08-28 12:43 ` Yaniv Gardi
2013-08-26 14:40 ` [PATCH v3 2/6] scsi: ufs: fix the setting interrupt aggregation counter Seungwon Jeon
2013-08-27 9:01 ` Subhash Jadavani
2013-08-28 12:43 ` Yaniv Gardi
2013-08-26 14:40 ` [PATCH v3 3/6] scsi: ufs: add dme configuration primitives Seungwon Jeon
2013-08-27 9:15 ` Subhash Jadavani
2013-08-28 12:44 ` Yaniv Gardi
2013-08-26 14:40 ` [PATCH v3 4/6] scsi: ufs: add unipro attribute IDs Seungwon Jeon
2013-08-27 9:14 ` Subhash Jadavani
2013-08-28 12:46 ` Yaniv Gardi
2013-08-26 14:40 ` [PATCH v3 5/6] scsi: ufs: add operation for the uic power mode change Seungwon Jeon
2013-08-27 9:53 ` Subhash Jadavani
2013-08-27 11:28 ` Seungwon Jeon
2013-08-27 11:47 ` Subhash Jadavani
2013-08-27 11:58 ` Seungwon Jeon
2013-08-28 12:45 ` Yaniv Gardi
2013-08-26 14:41 ` [PATCH v3 6/6] scsi: ufs: configure the attribute for power mode Seungwon Jeon
2013-08-27 10:21 ` Subhash Jadavani
2013-08-27 10:27 ` Subhash Jadavani
2013-09-09 11:51 ` [PATCH] scsi: ufs: export the helper functions for vender probe/remove Seungwon Jeon
2013-07-26 13:46 ` [PATCH 3/7] scsi: ufs: fix the setting interrupt aggregation counter Seungwon Jeon
2013-07-29 7:03 ` Subhash Jadavani
2013-07-30 13:01 ` Seungwon Jeon
2013-07-26 13:47 ` [PATCH 4/7] scsi: ufs: add dme configuration primitives Seungwon Jeon
2013-07-29 9:24 ` Subhash Jadavani
2013-07-30 13:02 ` Seungwon Jeon
2013-08-13 6:56 ` Subhash Jadavani [this message]
2013-07-26 13:48 ` [PATCH 5/7] scsi: ufs: add unipro attribute IDs Seungwon Jeon
2013-07-29 9:26 ` Subhash Jadavani
2013-07-26 13:48 ` [PATCH 6/7] scsi: ufs: add operation for the uic power mode change Seungwon Jeon
2013-07-29 9:53 ` Subhash Jadavani
2013-07-30 13:02 ` Seungwon Jeon
2013-07-26 13:49 ` [PATCH 7/7] scsi: ufs: configure the attribute for power mode Seungwon Jeon
2013-07-31 13:28 ` Subhash Jadavani
2013-08-06 12:08 ` Seungwon Jeon
2013-08-13 7:00 ` Subhash Jadavani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5209D893.3020100@codeaurora.org \
--to=subhashj@codeaurora.org \
--cc=JBottomley@parallels.com \
--cc=linux-scsi@vger.kernel.org \
--cc=santoshsy@gmail.com \
--cc=tgih.jun@samsung.com \
--cc=vinholikatti@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).