LKML Archive on lore.kernel.org help / color / mirror / Atom feed
* [PATCH 0/4] Add required changes to ufshcd to support exynos ufs hci [not found] <CGME20180506102636epcas2p3432b71e5c867f6cfec16cf2a8c74b0e2@epcas2p3.samsung.com> @ 2018-05-06 10:14 ` Alim Akhtar [not found] ` <CGME20180506102638epcas1p17bea76e1a5dbac535d5d6a10181f7e29@epcas1p1.samsung.com> ` (5 more replies) 0 siblings, 6 replies; 13+ messages in thread From: Alim Akhtar @ 2018-05-06 10:14 UTC (permalink / raw) To: linux-scsi, linux-kernel Cc: jejb, martin.petersen, vivek.gautam, subhashj, vinholikatti, olof, alim.akhtar Hi All These patches are part of a larger patch series [1] which attempts upstreaming EXYNOS UFS driver support. There was not much activities after v5 of that series. In between I saw there were other teams in Samsung tried upstreaming the same, but that has not really gone anywhere. I have taken this task again and here is another attempt to upstream exynos-ufs driver support. I have divided the patches into two series, one which adds required infra in the ufshcd core needed by exynos-ufs driver and other part will have actual exynos-ufs driver. Splitting this has a advantage of less reviewing over head. I am floating these as a new patch set. [1] https://www.spinics.net/lists/linux-scsi/msg90292.html These patches are based on mainline v4.17-rc3. Alim Akhtar (4): scsi: ufs: add quirk to fix mishandling utrlclr/utmrlclr scsi: ufs: add quirk not to allow reset of interrupt aggregation scsi: ufs: add quirk to enable host controller without hce scsi: ufs: make ufshcd_config_pwr_mode of non-static func drivers/scsi/ufs/ufshcd.c | 104 ++++++++++++++++++++++++++++++++++++++++++---- drivers/scsi/ufs/ufshcd.h | 18 ++++++++ 2 files changed, 114 insertions(+), 8 deletions(-) -- 2.7.4 ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <CGME20180506102638epcas1p17bea76e1a5dbac535d5d6a10181f7e29@epcas1p1.samsung.com>]
* [PATCH 1/4] scsi: ufs: add quirk to fix mishandling utrlclr/utmrlclr [not found] ` <CGME20180506102638epcas1p17bea76e1a5dbac535d5d6a10181f7e29@epcas1p1.samsung.com> @ 2018-05-06 10:14 ` Alim Akhtar 2018-05-16 21:23 ` Subhash Jadavani 2018-05-17 4:06 ` Asutosh Das (asd) 0 siblings, 2 replies; 13+ messages in thread From: Alim Akhtar @ 2018-05-06 10:14 UTC (permalink / raw) To: linux-scsi, linux-kernel Cc: jejb, martin.petersen, vivek.gautam, subhashj, vinholikatti, olof, alim.akhtar In the right behavior, setting the bit to '0' indicates clear and '1' indicates no change. If host controller handles this the other way, UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR can be used. Signed-off-by: Seungwon Jeon <essuuj@gmail.com> Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> --- drivers/scsi/ufs/ufshcd.c | 21 +++++++++++++++++++-- drivers/scsi/ufs/ufshcd.h | 5 +++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 00e7905..9898ce5 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -675,7 +675,24 @@ static inline void ufshcd_put_tm_slot(struct ufs_hba *hba, int slot) */ static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos) { - ufshcd_writel(hba, ~(1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR); + if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR) + ufshcd_writel(hba, (1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR); + else + ufshcd_writel(hba, ~(1 << pos), + REG_UTP_TRANSFER_REQ_LIST_CLEAR); +} + +/** + * ufshcd_utmrl_clear - Clear a bit in UTRMLCLR register + * @hba: per adapter instance + * @pos: position of the bit to be cleared + */ +static inline void ufshcd_utmrl_clear(struct ufs_hba *hba, u32 pos) +{ + if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR) + ufshcd_writel(hba, (1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR); + else + ufshcd_writel(hba, ~(1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR); } /** @@ -5398,7 +5415,7 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag) goto out; spin_lock_irqsave(hba->host->host_lock, flags); - ufshcd_writel(hba, ~(1 << tag), REG_UTP_TASK_REQ_LIST_CLEAR); + ufshcd_utmrl_clear(hba, tag); spin_unlock_irqrestore(hba->host->host_lock, flags); /* poll for max. 1 sec to clear door bell register by h/w */ diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 8110dcd..43035f8 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -595,6 +595,11 @@ struct ufs_hba { */ #define UFSHCD_QUIRK_PRDT_BYTE_GRAN 0x80 + /* + * Cleaer handling for transfer/task request list is just opposite. + */ + #define UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR 0x100 + unsigned int quirks; /* Deviations from standard UFSHCI spec. */ /* Device deviations from standard UFS device spec. */ -- 2.7.4 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/4] scsi: ufs: add quirk to fix mishandling utrlclr/utmrlclr 2018-05-06 10:14 ` [PATCH 1/4] scsi: ufs: add quirk to fix mishandling utrlclr/utmrlclr Alim Akhtar @ 2018-05-16 21:23 ` Subhash Jadavani 2018-05-17 4:06 ` Asutosh Das (asd) 1 sibling, 0 replies; 13+ messages in thread From: Subhash Jadavani @ 2018-05-16 21:23 UTC (permalink / raw) To: Alim Akhtar Cc: linux-scsi, linux-kernel, jejb, martin.petersen, vivek.gautam, vinholikatti, olof, linux-scsi-owner On 2018-05-06 03:14, Alim Akhtar wrote: > In the right behavior, setting the bit to '0' indicates clear and > '1' indicates no change. If host controller handles this the other way, > UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR can be used. > > Signed-off-by: Seungwon Jeon <essuuj@gmail.com> > Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> > --- > drivers/scsi/ufs/ufshcd.c | 21 +++++++++++++++++++-- > drivers/scsi/ufs/ufshcd.h | 5 +++++ > 2 files changed, 24 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 00e7905..9898ce5 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -675,7 +675,24 @@ static inline void ufshcd_put_tm_slot(struct > ufs_hba *hba, int slot) > */ > static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos) > { > - ufshcd_writel(hba, ~(1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR); > + if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR) > + ufshcd_writel(hba, (1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR); > + else > + ufshcd_writel(hba, ~(1 << pos), > + REG_UTP_TRANSFER_REQ_LIST_CLEAR); > +} > + > +/** > + * ufshcd_utmrl_clear - Clear a bit in UTRMLCLR register > + * @hba: per adapter instance > + * @pos: position of the bit to be cleared > + */ > +static inline void ufshcd_utmrl_clear(struct ufs_hba *hba, u32 pos) > +{ > + if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR) > + ufshcd_writel(hba, (1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR); > + else > + ufshcd_writel(hba, ~(1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR); > } > > /** > @@ -5398,7 +5415,7 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba > *hba, int tag) > goto out; > > spin_lock_irqsave(hba->host->host_lock, flags); > - ufshcd_writel(hba, ~(1 << tag), REG_UTP_TASK_REQ_LIST_CLEAR); > + ufshcd_utmrl_clear(hba, tag); > spin_unlock_irqrestore(hba->host->host_lock, flags); > > /* poll for max. 1 sec to clear door bell register by h/w */ > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index 8110dcd..43035f8 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -595,6 +595,11 @@ struct ufs_hba { > */ > #define UFSHCD_QUIRK_PRDT_BYTE_GRAN 0x80 > > + /* > + * Cleaer handling for transfer/task request list is just opposite. > + */ > + #define UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR 0x100 > + > unsigned int quirks; /* Deviations from standard UFSHCI spec. */ > > /* Device deviations from standard UFS device spec. */ Looks good to me. Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org> -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/4] scsi: ufs: add quirk to fix mishandling utrlclr/utmrlclr 2018-05-06 10:14 ` [PATCH 1/4] scsi: ufs: add quirk to fix mishandling utrlclr/utmrlclr Alim Akhtar 2018-05-16 21:23 ` Subhash Jadavani @ 2018-05-17 4:06 ` Asutosh Das (asd) 1 sibling, 0 replies; 13+ messages in thread From: Asutosh Das (asd) @ 2018-05-17 4:06 UTC (permalink / raw) To: Alim Akhtar, linux-scsi, linux-kernel Cc: jejb, martin.petersen, vivek.gautam, subhashj, vinholikatti, olof On 5/6/2018 3:44 PM, Alim Akhtar wrote: > In the right behavior, setting the bit to '0' indicates clear and > '1' indicates no change. If host controller handles this the other way, > UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR can be used. > > Signed-off-by: Seungwon Jeon <essuuj@gmail.com> > Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> > --- > drivers/scsi/ufs/ufshcd.c | 21 +++++++++++++++++++-- > drivers/scsi/ufs/ufshcd.h | 5 +++++ > 2 files changed, 24 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 00e7905..9898ce5 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -675,7 +675,24 @@ static inline void ufshcd_put_tm_slot(struct ufs_hba *hba, int slot) > */ > static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos) > { > - ufshcd_writel(hba, ~(1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR); > + if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR) > + ufshcd_writel(hba, (1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR); > + else > + ufshcd_writel(hba, ~(1 << pos), > + REG_UTP_TRANSFER_REQ_LIST_CLEAR); > +} > + > +/** > + * ufshcd_utmrl_clear - Clear a bit in UTRMLCLR register > + * @hba: per adapter instance > + * @pos: position of the bit to be cleared > + */ > +static inline void ufshcd_utmrl_clear(struct ufs_hba *hba, u32 pos) > +{ > + if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR) > + ufshcd_writel(hba, (1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR); > + else > + ufshcd_writel(hba, ~(1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR); > } > > /** > @@ -5398,7 +5415,7 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag) > goto out; > > spin_lock_irqsave(hba->host->host_lock, flags); > - ufshcd_writel(hba, ~(1 << tag), REG_UTP_TASK_REQ_LIST_CLEAR); > + ufshcd_utmrl_clear(hba, tag); > spin_unlock_irqrestore(hba->host->host_lock, flags); > > /* poll for max. 1 sec to clear door bell register by h/w */ > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index 8110dcd..43035f8 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -595,6 +595,11 @@ struct ufs_hba { > */ > #define UFSHCD_QUIRK_PRDT_BYTE_GRAN 0x80 > > + /* > + * Cleaer handling for transfer/task request list is just opposite. > + */ Spell check - should be 'Clear' > + #define UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR 0x100 > + > unsigned int quirks; /* Deviations from standard UFSHCI spec. */ > > /* Device deviations from standard UFS device spec. */ > Looks good to me, except the spell-check. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <CGME20180506102639epcas2p13ac44966a64e539f611ccdc2479e1abb@epcas2p1.samsung.com>]
* [PATCH 2/4] scsi: ufs: add quirk not to allow reset of interrupt aggregation [not found] ` <CGME20180506102639epcas2p13ac44966a64e539f611ccdc2479e1abb@epcas2p1.samsung.com> @ 2018-05-06 10:14 ` Alim Akhtar 2018-05-16 21:24 ` Subhash Jadavani 0 siblings, 1 reply; 13+ messages in thread From: Alim Akhtar @ 2018-05-06 10:14 UTC (permalink / raw) To: linux-scsi, linux-kernel Cc: jejb, martin.petersen, vivek.gautam, subhashj, vinholikatti, olof, alim.akhtar Some host controller supports interrupt aggregation, but doesn't allow to reset counter and timer by s/w. Signed-off-by: Seungwon Jeon <essuuj@gmail.com> Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> --- drivers/scsi/ufs/ufshcd.c | 3 ++- drivers/scsi/ufs/ufshcd.h | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9898ce5..253257c 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4695,7 +4695,8 @@ static void ufshcd_transfer_req_compl(struct ufs_hba *hba) * false interrupt if device completes another request after resetting * aggregation and before reading the DB. */ - if (ufshcd_is_intr_aggr_allowed(hba)) + if (ufshcd_is_intr_aggr_allowed(hba) && + !(hba->quirks & UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR)) ufshcd_reset_intr_aggr(hba); tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL); diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 43035f8..5c91ff1 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -600,6 +600,12 @@ struct ufs_hba { */ #define UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR 0x100 + /* + * This quirk needs to be enabled if host controller doesn't allow + * that the interrupt aggregation timer and counter are reset by s/w. + */ + #define UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR 0x200 + unsigned int quirks; /* Deviations from standard UFSHCI spec. */ /* Device deviations from standard UFS device spec. */ -- 2.7.4 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/4] scsi: ufs: add quirk not to allow reset of interrupt aggregation 2018-05-06 10:14 ` [PATCH 2/4] scsi: ufs: add quirk not to allow reset of interrupt aggregation Alim Akhtar @ 2018-05-16 21:24 ` Subhash Jadavani 0 siblings, 0 replies; 13+ messages in thread From: Subhash Jadavani @ 2018-05-16 21:24 UTC (permalink / raw) To: Alim Akhtar Cc: linux-scsi, linux-kernel, jejb, martin.petersen, vivek.gautam, vinholikatti, olof, linux-scsi-owner On 2018-05-06 03:14, Alim Akhtar wrote: > Some host controller supports interrupt aggregation, but doesn't > allow to reset counter and timer by s/w. > > Signed-off-by: Seungwon Jeon <essuuj@gmail.com> > Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> > --- > drivers/scsi/ufs/ufshcd.c | 3 ++- > drivers/scsi/ufs/ufshcd.h | 6 ++++++ > 2 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 9898ce5..253257c 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -4695,7 +4695,8 @@ static void ufshcd_transfer_req_compl(struct > ufs_hba *hba) > * false interrupt if device completes another request after > resetting > * aggregation and before reading the DB. > */ > - if (ufshcd_is_intr_aggr_allowed(hba)) > + if (ufshcd_is_intr_aggr_allowed(hba) && > + !(hba->quirks & UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR)) > ufshcd_reset_intr_aggr(hba); > > tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL); > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index 43035f8..5c91ff1 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -600,6 +600,12 @@ struct ufs_hba { > */ > #define UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR 0x100 > > + /* > + * This quirk needs to be enabled if host controller doesn't allow > + * that the interrupt aggregation timer and counter are reset by s/w. > + */ > + #define UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR 0x200 > + > unsigned int quirks; /* Deviations from standard UFSHCI spec. */ > > /* Device deviations from standard UFS device spec. */ Looks good to me. Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org> -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <CGME20180506102641epcas1p40fb2055e82d32d7cfa594af132273d31@epcas1p4.samsung.com>]
* [PATCH 3/4] scsi: ufs: add quirk to enable host controller without hce [not found] ` <CGME20180506102641epcas1p40fb2055e82d32d7cfa594af132273d31@epcas1p4.samsung.com> @ 2018-05-06 10:14 ` Alim Akhtar 2018-05-16 21:26 ` Subhash Jadavani 0 siblings, 1 reply; 13+ messages in thread From: Alim Akhtar @ 2018-05-06 10:14 UTC (permalink / raw) To: linux-scsi, linux-kernel Cc: jejb, martin.petersen, vivek.gautam, subhashj, vinholikatti, olof, alim.akhtar Some host controller doesn't support host controller enable via HCE. Signed-off-by: Seungwon Jeon <essuuj@gmail.com> Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> --- drivers/scsi/ufs/ufshcd.c | 75 +++++++++++++++++++++++++++++++++++++++++++++-- drivers/scsi/ufs/ufshcd.h | 5 ++++ 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 253257c..5bfd385 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -3400,6 +3400,52 @@ static int ufshcd_dme_link_startup(struct ufs_hba *hba) "dme-link-startup: error code %d\n", ret); return ret; } +/** + * ufshcd_dme_reset - UIC command for DME_RESET + * @hba: per adapter instance + * + * DME_RESET command is issued in order to reset UniPro stack. + * This function now deal with cold reset. + * + * Returns 0 on success, non-zero value on failure + */ +static int ufshcd_dme_reset(struct ufs_hba *hba) +{ + struct uic_command uic_cmd = {0}; + int ret; + + uic_cmd.command = UIC_CMD_DME_RESET; + + ret = ufshcd_send_uic_cmd(hba, &uic_cmd); + if (ret) + dev_err(hba->dev, + "dme-reset: error code %d\n", ret); + + return ret; +} + +/** + * ufshcd_dme_enable - UIC command for DME_ENABLE + * @hba: per adapter instance + * + * DME_ENABLE command is issued in order to enable UniPro stack. + * + * Returns 0 on success, non-zero value on failure + */ +static int ufshcd_dme_enable(struct ufs_hba *hba) +{ + struct uic_command uic_cmd = {0}; + int ret; + + uic_cmd.command = UIC_CMD_DME_ENABLE; + + ret = ufshcd_send_uic_cmd(hba, &uic_cmd); + if (ret) + dev_err(hba->dev, + "dme-reset: error code %d\n", ret); + + return ret; +} static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba *hba) { @@ -4058,7 +4104,7 @@ static inline void ufshcd_hba_stop(struct ufs_hba *hba, bool can_sleep) } /** - * ufshcd_hba_enable - initialize the controller + * ufshcd_hba_execute_hce - initialize the controller * @hba: per adapter instance * * The controller resets itself and controller firmware initialization @@ -4067,7 +4113,7 @@ static inline void ufshcd_hba_stop(struct ufs_hba *hba, bool can_sleep) * * Returns 0 on success, non-zero value on failure */ -static int ufshcd_hba_enable(struct ufs_hba *hba) +static int ufshcd_hba_execute_hce(struct ufs_hba *hba) { int retry; @@ -4122,6 +4168,31 @@ static int ufshcd_hba_enable(struct ufs_hba *hba) return 0; } +static int ufshcd_hba_enable(struct ufs_hba *hba) +{ + int ret; + + if (hba->quirks & UFSHCI_QUIRK_BROKEN_HCE) { + ufshcd_set_link_off(hba); + ufshcd_vops_hce_enable_notify(hba, PRE_CHANGE); + + /* enable UIC related interrupts */ + ufshcd_enable_intr(hba, UFSHCD_UIC_MASK); + ret = ufshcd_dme_reset(hba); + if (!ret) { + ret = ufshcd_dme_enable(hba); + if (!ret) + ufshcd_vops_hce_enable_notify(hba, POST_CHANGE); + if (ret) + dev_err(hba->dev, + "Host controller enable failed with non-hce\n"); + } + } else { + ret = ufshcd_hba_execute_hce(hba); + } + + return ret; +} static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer) { int tx_lanes, i, err = 0; diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 5c91ff1..013a07e 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -606,6 +606,11 @@ struct ufs_hba { */ #define UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR 0x200 + /* + * This quirks needs to be enabled if host controller cannot be + * enabled via HCE register. + */ + #define UFSHCI_QUIRK_BROKEN_HCE 0x400 unsigned int quirks; /* Deviations from standard UFSHCI spec. */ /* Device deviations from standard UFS device spec. */ -- 2.7.4 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/4] scsi: ufs: add quirk to enable host controller without hce 2018-05-06 10:14 ` [PATCH 3/4] scsi: ufs: add quirk to enable host controller without hce Alim Akhtar @ 2018-05-16 21:26 ` Subhash Jadavani 0 siblings, 0 replies; 13+ messages in thread From: Subhash Jadavani @ 2018-05-16 21:26 UTC (permalink / raw) To: Alim Akhtar Cc: linux-scsi, linux-kernel, jejb, martin.petersen, vivek.gautam, vinholikatti, olof On 2018-05-06 03:14, Alim Akhtar wrote: > Some host controller doesn't support host controller enable via HCE. > > Signed-off-by: Seungwon Jeon <essuuj@gmail.com> > Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> > --- > drivers/scsi/ufs/ufshcd.c | 75 > +++++++++++++++++++++++++++++++++++++++++++++-- > drivers/scsi/ufs/ufshcd.h | 5 ++++ > 2 files changed, 78 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 253257c..5bfd385 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -3400,6 +3400,52 @@ static int ufshcd_dme_link_startup(struct > ufs_hba *hba) > "dme-link-startup: error code %d\n", ret); > return ret; > } > +/** > + * ufshcd_dme_reset - UIC command for DME_RESET > + * @hba: per adapter instance > + * > + * DME_RESET command is issued in order to reset UniPro stack. > + * This function now deal with cold reset. > + * > + * Returns 0 on success, non-zero value on failure > + */ > +static int ufshcd_dme_reset(struct ufs_hba *hba) > +{ > + struct uic_command uic_cmd = {0}; > + int ret; > + > + uic_cmd.command = UIC_CMD_DME_RESET; > + > + ret = ufshcd_send_uic_cmd(hba, &uic_cmd); > + if (ret) > + dev_err(hba->dev, > + "dme-reset: error code %d\n", ret); > + > + return ret; > +} > + > +/** > + * ufshcd_dme_enable - UIC command for DME_ENABLE > + * @hba: per adapter instance > + * > + * DME_ENABLE command is issued in order to enable UniPro stack. > + * > + * Returns 0 on success, non-zero value on failure > + */ > +static int ufshcd_dme_enable(struct ufs_hba *hba) > +{ > + struct uic_command uic_cmd = {0}; > + int ret; > + > + uic_cmd.command = UIC_CMD_DME_ENABLE; > + > + ret = ufshcd_send_uic_cmd(hba, &uic_cmd); > + if (ret) > + dev_err(hba->dev, > + "dme-reset: error code %d\n", ret); > + > + return ret; > +} > > static inline void ufshcd_add_delay_before_dme_cmd(struct ufs_hba > *hba) > { > @@ -4058,7 +4104,7 @@ static inline void ufshcd_hba_stop(struct > ufs_hba *hba, bool can_sleep) > } > > /** > - * ufshcd_hba_enable - initialize the controller > + * ufshcd_hba_execute_hce - initialize the controller > * @hba: per adapter instance > * > * The controller resets itself and controller firmware initialization > @@ -4067,7 +4113,7 @@ static inline void ufshcd_hba_stop(struct > ufs_hba *hba, bool can_sleep) > * > * Returns 0 on success, non-zero value on failure > */ > -static int ufshcd_hba_enable(struct ufs_hba *hba) > +static int ufshcd_hba_execute_hce(struct ufs_hba *hba) > { > int retry; > > @@ -4122,6 +4168,31 @@ static int ufshcd_hba_enable(struct ufs_hba > *hba) > return 0; > } > > +static int ufshcd_hba_enable(struct ufs_hba *hba) > +{ > + int ret; > + > + if (hba->quirks & UFSHCI_QUIRK_BROKEN_HCE) { > + ufshcd_set_link_off(hba); > + ufshcd_vops_hce_enable_notify(hba, PRE_CHANGE); > + > + /* enable UIC related interrupts */ > + ufshcd_enable_intr(hba, UFSHCD_UIC_MASK); > + ret = ufshcd_dme_reset(hba); > + if (!ret) { > + ret = ufshcd_dme_enable(hba); > + if (!ret) > + ufshcd_vops_hce_enable_notify(hba, POST_CHANGE); > + if (ret) > + dev_err(hba->dev, > + "Host controller enable failed with non-hce\n"); > + } > + } else { > + ret = ufshcd_hba_execute_hce(hba); > + } > + > + return ret; > +} > static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer) > { > int tx_lanes, i, err = 0; > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index 5c91ff1..013a07e 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -606,6 +606,11 @@ struct ufs_hba { > */ > #define UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR 0x200 > > + /* > + * This quirks needs to be enabled if host controller cannot be > + * enabled via HCE register. > + */ > + #define UFSHCI_QUIRK_BROKEN_HCE 0x400 > unsigned int quirks; /* Deviations from standard UFSHCI spec. */ > > /* Device deviations from standard UFS device spec. */ Looks good to me. Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org> -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <CGME20180506102643epcas2p24ed80d7ede859db73c2595724d9c2414@epcas2p2.samsung.com>]
* [PATCH 4/4] scsi: ufs: make ufshcd_config_pwr_mode of non-static func [not found] ` <CGME20180506102643epcas2p24ed80d7ede859db73c2595724d9c2414@epcas2p2.samsung.com> @ 2018-05-06 10:14 ` Alim Akhtar 2018-05-16 7:51 ` Avri Altman 2018-05-16 21:27 ` Subhash Jadavani 0 siblings, 2 replies; 13+ messages in thread From: Alim Akhtar @ 2018-05-06 10:14 UTC (permalink / raw) To: linux-scsi, linux-kernel Cc: jejb, martin.petersen, vivek.gautam, subhashj, vinholikatti, olof, alim.akhtar This makes ufshcd_config_pwr_mode non-static so that other vendors like exynos can use the same. Signed-off-by: Seungwon Jeon <essuuj@gmail.com> Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> --- drivers/scsi/ufs/ufshcd.c | 5 ++--- drivers/scsi/ufs/ufshcd.h | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 5bfd385..68aefcd 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -233,8 +233,6 @@ static void ufshcd_suspend_clkscaling(struct ufs_hba *hba); static void __ufshcd_suspend_clkscaling(struct ufs_hba *hba); static int ufshcd_scale_clks(struct ufs_hba *hba, bool scale_up); static irqreturn_t ufshcd_intr(int irq, void *__hba); -static int ufshcd_config_pwr_mode(struct ufs_hba *hba, - struct ufs_pa_layer_attr *desired_pwr_mode); static int ufshcd_change_power_mode(struct ufs_hba *hba, struct ufs_pa_layer_attr *pwr_mode); static inline bool ufshcd_valid_tag(struct ufs_hba *hba, int tag) @@ -3969,7 +3967,7 @@ static int ufshcd_change_power_mode(struct ufs_hba *hba, * @hba: per-adapter instance * @desired_pwr_mode: desired power configuration */ -static int ufshcd_config_pwr_mode(struct ufs_hba *hba, +int ufshcd_config_pwr_mode(struct ufs_hba *hba, struct ufs_pa_layer_attr *desired_pwr_mode) { struct ufs_pa_layer_attr final_params = { 0 }; @@ -3987,6 +3985,7 @@ static int ufshcd_config_pwr_mode(struct ufs_hba *hba, return ret; } +EXPORT_SYMBOL_GPL(ufshcd_config_pwr_mode); /** * ufshcd_complete_dev_init() - checks device readiness diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 013a07e..b42a5a3 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -805,6 +805,8 @@ 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); +extern int ufshcd_config_pwr_mode(struct ufs_hba *hba, + struct ufs_pa_layer_attr *desired_pwr_mode); /* UIC command interfaces for DME primitives */ #define DME_LOCAL 0 -- 2.7.4 ^ permalink raw reply [flat|nested] 13+ messages in thread
* RE: [PATCH 4/4] scsi: ufs: make ufshcd_config_pwr_mode of non-static func 2018-05-06 10:14 ` [PATCH 4/4] scsi: ufs: make ufshcd_config_pwr_mode of non-static func Alim Akhtar @ 2018-05-16 7:51 ` Avri Altman 2018-05-16 21:27 ` Subhash Jadavani 1 sibling, 0 replies; 13+ messages in thread From: Avri Altman @ 2018-05-16 7:51 UTC (permalink / raw) To: Alim Akhtar, linux-scsi, linux-kernel Cc: jejb, martin.petersen, vivek.gautam, subhashj, vinholikatti, olof > -----Original Message----- > From: linux-scsi-owner@vger.kernel.org <linux-scsi-owner@vger.kernel.org> > On Behalf Of Alim Akhtar > Sent: Sunday, May 06, 2018 1:14 PM > To: linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org > Cc: jejb@linux.vnet.ibm.com; martin.petersen@oracle.com; > vivek.gautam@codeaurora.org; subhashj@codeaurora.org; > vinholikatti@gmail.com; olof@lixom.net; alim.akhtar@samsung.com > Subject: [PATCH 4/4] scsi: ufs: make ufshcd_config_pwr_mode of non-static > func > > This makes ufshcd_config_pwr_mode non-static so that other vendors like > exynos can use the same. > > Signed-off-by: Seungwon Jeon <essuuj@gmail.com> > Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> Acked-by: Avri Altman <avri.altman@wdc.com> Might be also useful exporting an API for all uic commands? Thanks, Avri ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/4] scsi: ufs: make ufshcd_config_pwr_mode of non-static func 2018-05-06 10:14 ` [PATCH 4/4] scsi: ufs: make ufshcd_config_pwr_mode of non-static func Alim Akhtar 2018-05-16 7:51 ` Avri Altman @ 2018-05-16 21:27 ` Subhash Jadavani 1 sibling, 0 replies; 13+ messages in thread From: Subhash Jadavani @ 2018-05-16 21:27 UTC (permalink / raw) To: Alim Akhtar Cc: linux-scsi, linux-kernel, jejb, martin.petersen, vivek.gautam, vinholikatti, olof On 2018-05-06 03:14, Alim Akhtar wrote: > This makes ufshcd_config_pwr_mode non-static so that other vendors > like exynos can use the same. > > Signed-off-by: Seungwon Jeon <essuuj@gmail.com> > Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> > --- > drivers/scsi/ufs/ufshcd.c | 5 ++--- > drivers/scsi/ufs/ufshcd.h | 2 ++ > 2 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 5bfd385..68aefcd 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -233,8 +233,6 @@ static void ufshcd_suspend_clkscaling(struct > ufs_hba *hba); > static void __ufshcd_suspend_clkscaling(struct ufs_hba *hba); > static int ufshcd_scale_clks(struct ufs_hba *hba, bool scale_up); > static irqreturn_t ufshcd_intr(int irq, void *__hba); > -static int ufshcd_config_pwr_mode(struct ufs_hba *hba, > - struct ufs_pa_layer_attr *desired_pwr_mode); > static int ufshcd_change_power_mode(struct ufs_hba *hba, > struct ufs_pa_layer_attr *pwr_mode); > static inline bool ufshcd_valid_tag(struct ufs_hba *hba, int tag) > @@ -3969,7 +3967,7 @@ static int ufshcd_change_power_mode(struct > ufs_hba *hba, > * @hba: per-adapter instance > * @desired_pwr_mode: desired power configuration > */ > -static int ufshcd_config_pwr_mode(struct ufs_hba *hba, > +int ufshcd_config_pwr_mode(struct ufs_hba *hba, > struct ufs_pa_layer_attr *desired_pwr_mode) > { > struct ufs_pa_layer_attr final_params = { 0 }; > @@ -3987,6 +3985,7 @@ static int ufshcd_config_pwr_mode(struct ufs_hba > *hba, > > return ret; > } > +EXPORT_SYMBOL_GPL(ufshcd_config_pwr_mode); > > /** > * ufshcd_complete_dev_init() - checks device readiness > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index 013a07e..b42a5a3 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -805,6 +805,8 @@ 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); > +extern int ufshcd_config_pwr_mode(struct ufs_hba *hba, > + struct ufs_pa_layer_attr *desired_pwr_mode); > > /* UIC command interfaces for DME primitives */ > #define DME_LOCAL 0 Looks good to me. Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org> -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/4] Add required changes to ufshcd to support exynos ufs hci 2018-05-06 10:14 ` [PATCH 0/4] Add required changes to ufshcd to support exynos ufs hci Alim Akhtar ` (3 preceding siblings ...) [not found] ` <CGME20180506102643epcas2p24ed80d7ede859db73c2595724d9c2414@epcas2p2.samsung.com> @ 2018-05-16 4:30 ` Alim Akhtar 2018-05-18 14:52 ` Martin K. Petersen 5 siblings, 0 replies; 13+ messages in thread From: Alim Akhtar @ 2018-05-16 4:30 UTC (permalink / raw) To: Alim Akhtar Cc: linux-scsi, linux-kernel, jejb, martin.petersen, vivek.gautam, subhashj, vinayak holikatti, Olof Johansson Hi All, Any thought on this patch set? On Sun, May 6, 2018 at 3:44 PM, Alim Akhtar <alim.akhtar@samsung.com> wrote: > Hi All > > These patches are part of a larger patch series [1] which attempts upstreaming > EXYNOS UFS driver support. There was not much activities after v5 of that > series. In between I saw there were other teams in Samsung tried upstreaming > the same, but that has not really gone anywhere. > I have taken this task again and here is another attempt to upstream exynos-ufs > driver support. I have divided the patches into two series, one which adds > required infra in the ufshcd core needed by exynos-ufs driver and other part > will have actual exynos-ufs driver. Splitting this has a advantage of less > reviewing over head. > > I am floating these as a new patch set. > > [1] https://www.spinics.net/lists/linux-scsi/msg90292.html > > These patches are based on mainline v4.17-rc3. > > Alim Akhtar (4): > scsi: ufs: add quirk to fix mishandling utrlclr/utmrlclr > scsi: ufs: add quirk not to allow reset of interrupt aggregation > scsi: ufs: add quirk to enable host controller without hce > scsi: ufs: make ufshcd_config_pwr_mode of non-static func > > drivers/scsi/ufs/ufshcd.c | 104 ++++++++++++++++++++++++++++++++++++++++++---- > drivers/scsi/ufs/ufshcd.h | 18 ++++++++ > 2 files changed, 114 insertions(+), 8 deletions(-) > > -- > 2.7.4 > -- Regards, Alim ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/4] Add required changes to ufshcd to support exynos ufs hci 2018-05-06 10:14 ` [PATCH 0/4] Add required changes to ufshcd to support exynos ufs hci Alim Akhtar ` (4 preceding siblings ...) 2018-05-16 4:30 ` [PATCH 0/4] Add required changes to ufshcd to support exynos ufs hci Alim Akhtar @ 2018-05-18 14:52 ` Martin K. Petersen 5 siblings, 0 replies; 13+ messages in thread From: Martin K. Petersen @ 2018-05-18 14:52 UTC (permalink / raw) To: Alim Akhtar Cc: linux-scsi, linux-kernel, jejb, martin.petersen, vivek.gautam, subhashj, vinholikatti, olof Alim, > These patches are part of a larger patch series [1] which attempts > upstreaming EXYNOS UFS driver support. There was not much activities > after v5 of that series. In between I saw there were other teams in > Samsung tried upstreaming the same, but that has not really gone > anywhere. I have taken this task again and here is another attempt to > upstream exynos-ufs driver support. I have divided the patches into > two series, one which adds required infra in the ufshcd core needed by > exynos-ufs driver and other part will have actual exynos-ufs > driver. Splitting this has a advantage of less reviewing over head. Applied to 4.18/scsi-queue. Thank you! -- Martin K. Petersen Oracle Linux Engineering ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2018-05-18 14:53 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CGME20180506102636epcas2p3432b71e5c867f6cfec16cf2a8c74b0e2@epcas2p3.samsung.com> 2018-05-06 10:14 ` [PATCH 0/4] Add required changes to ufshcd to support exynos ufs hci Alim Akhtar [not found] ` <CGME20180506102638epcas1p17bea76e1a5dbac535d5d6a10181f7e29@epcas1p1.samsung.com> 2018-05-06 10:14 ` [PATCH 1/4] scsi: ufs: add quirk to fix mishandling utrlclr/utmrlclr Alim Akhtar 2018-05-16 21:23 ` Subhash Jadavani 2018-05-17 4:06 ` Asutosh Das (asd) [not found] ` <CGME20180506102639epcas2p13ac44966a64e539f611ccdc2479e1abb@epcas2p1.samsung.com> 2018-05-06 10:14 ` [PATCH 2/4] scsi: ufs: add quirk not to allow reset of interrupt aggregation Alim Akhtar 2018-05-16 21:24 ` Subhash Jadavani [not found] ` <CGME20180506102641epcas1p40fb2055e82d32d7cfa594af132273d31@epcas1p4.samsung.com> 2018-05-06 10:14 ` [PATCH 3/4] scsi: ufs: add quirk to enable host controller without hce Alim Akhtar 2018-05-16 21:26 ` Subhash Jadavani [not found] ` <CGME20180506102643epcas2p24ed80d7ede859db73c2595724d9c2414@epcas2p2.samsung.com> 2018-05-06 10:14 ` [PATCH 4/4] scsi: ufs: make ufshcd_config_pwr_mode of non-static func Alim Akhtar 2018-05-16 7:51 ` Avri Altman 2018-05-16 21:27 ` Subhash Jadavani 2018-05-16 4:30 ` [PATCH 0/4] Add required changes to ufshcd to support exynos ufs hci Alim Akhtar 2018-05-18 14:52 ` Martin K. Petersen
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).