ufs: core: Add host quirk QUIRK_MCQ_EXPAND_QUEUE_SLOT
Subsystems (3)
cover ufs: core: Add host quirk QUIRK_MCQ_EXPAND_QUEUE_SLOT
Support quirk for host controller not able to distinguish queue full or empty.
Alice Chao (1):
ufs: core: Add host quirk QUIRK_MCQ_EXPAND_QUEUE_SLOT
drivers/ufs/core/ufs-mcq.c | 5 ++++- include/ufs/ufshcd.h | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-)
Signature · 1 line
2.18.0
PATCH 1/1 ufs: core: Add host quirk QUIRK_MCQ_EXPAND_QUEUE_SLOT
From: Alice Chao <[email protected]>
This quirk needs to be enabled if the host controller cannot distinguish queue full or empty.
--- drivers/ufs/core/ufs-mcq.c | 5 ++++- include/ufs/ufshcd.h | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/ufs/core/ufs-mcq.c +4 -1
@@ -436,7 +436,10 @@ int ufshcd_mcq_init(struct ufs_hba *hba)for (i =0 ; i < hba->nr_hw_queues; i++) { hwq = &hba->uhq[i]; - hwq->max_entries = hba->nutrs; +if (ufshcd_is_mcq_expand_queue_slot (hba)) + hwq->max_entries = hba->nutrs +1 ; +else + hwq->max_entries = hba->nutrs;spin_lock_init (&hwq->sq_lock);spin_lock_init (&hwq->cq_lock);mutex_init (&hwq->sq_mutex);
include/ufs/ufshcd.h +11 -0
@@ -643,6 +643,12 @@ enum ufshcd_quirks {* thus need this quirk to skip related flow. */ UFSHCD_QUIRK_MCQ_BROKEN_RTC =1 <<21 , + +/* +* This quirk needs to be enabled if the host controller cannot +* distinguish queue full or empty. +*/ + UFSHCD_QUIRK_MCQ_EXPAND_QUEUE_SLOT = 1 << 22, }; enum ufshcd_caps {
@@ -1198,6 +1204,11 @@ static inline bool ufshcd_enable_wb_if_scaling_up(struct ufs_hba *hba)return hba->caps &UFSHCD_CAP_WB_WITH_CLK_SCALING ; } +static inline bool ufshcd_is_mcq_expand_queue_slot (struct ufs_hba *hba) +{ +return hba->quirks &UFSHCD_QUIRK_MCQ_EXPAND_QUEUE_SLOT ; +} +#define ufsmcq_writel (hba, val, reg) \ writel((val), (hba)->mcq_base + (reg))#define ufsmcq_readl (hba, reg) \
Signature · 1 line
2.18.0
Bart Van Assche
reviewerQuoted 1 line · Chun-Hung Wu
This quirk needs to be enabled if the host controller cannot distinguish queue full or empty.
From the UFSHCI 4.0 specification: "When the head and tail doorbells are equal, the queue is empty. [ ... ] When the head and tail doorbells are not equal, the queue contains queue entries."
How is it possible that a host controller cannot distinguish queue full or queue empty? Which (head - tail) values cause trouble? More information is needed.
Thanks,
Bart.
Quoted 13 lines · Bart Van Assche
External email : Please do not click links or open attachments until you have verified the sender or the content.
Quoted 2 lines · Chun-Hung Wu
This quirk needs to be enabled if the host controller cannot distinguish queue full or empty.
From the UFSHCI 4.0 specification: "When the head and tail doorbells
are
equal, the queue is empty. [ ... ] When the head and tail doorbells are
not equal, the queue contains queue entries."
Quoted 9 lines
How is it possible that a host controller cannot distinguish queue full
or queue empty? Which (head - tail) values cause trouble? More information is needed.Thanks,
Bart.
From UFSHCI 4.0 spec "When the head and tail doorbells are equal, the queue is empty. *Nothe that this definition means there will always be one empty queue entry"
One of our platform does not keep one empty queue
entry for CQ full
case, that's why we need this patch to fix this corner case.
Thanks,
Chun-Hung
Bart Van Assche
reviewerQuoted 6 lines · Chun-Hung Wu (巫駿宏)
From UFSHCI 4.0 spec "When the head and tail doorbells are equal, the queue is empty. *Nothe that this definition means there will always be one empty queue entry"
One of our platform does not keep one empty queue
entry for CQ full
case, that's why we need this patch to fix this corner case.
The UFSHCI driver should make sure that there is always one empty queue entry. Does "platform" in the above text refer to the SoC that includes the UFSHCI controller?
What is totally unclear to me is why the following code depends on the UFSHCI controller type:
+ if (ufshcd_is_mcq_expand_queue_slot(hba))
+ hwq->max_entries = hba->nutrs + 1;
+ else
+ hwq->max_entries = hba->nutrs;
Shouldn't hwq->max_entries = hba->nutrs + 1 be used for all UFSHCI 4.0 controllers?
Thanks,
Bart.
Quoted 13 lines · Bart Van Assche
External email : Please do not click links or open attachments until you have verified the sender or the content.
Quoted 1 line · Chun-Hung Wu (巫駿宏)
From UFSHCI 4.0 spec "When the head and tail doorbells are equal,
the
Quoted 1 line
queue is empty. *Nothe that this definition means there will always
be
Quoted 4 lines
one empty queue entry"
One of our platform does not keep one empty queue entry for CQ full
case, that's why we need this patch to fix this corner case.
Quoted 5 lines
The UFSHCI driver should make sure that there is always one empty queue
entry. Does "platform" in the above text refer to the SoC that includes
the UFSHCI controller?
Yes here "platform" indicates SoC that includes the UFSHCI controller.
Quoted 10 lines
What is totally unclear to me is why the following code depends on the
UFSHCI controller type:drivers/ufs/core/ufs-mcq.c +4
-0+if (ufshcd_is_mcq_expand_queue_slot (hba)) +hwq->max_entries = hba->nutrs +1 ; +else +hwq->max_entries = hba->nutrs;
Quoted 8 lines
Shouldn't
hwq->max_entries=hba->nutrs+ 1 be used for all UFSHCI 4.0
controllers?Thanks,
Bart.
I think UFSHCI 4.0 spec "When the head and tail doorbells are equal,the queue is empty. *Nothe that this definition means there will alwaysbe one empty queue entry" means that "UFSHCI controller" should always keep one empty queue entry.
One of our host does not follow the spec, therefore, this host will treat CQ full(head = tail) as CQ empty (head = tail). That's why we propose this quirk to expand one queue slot for hosts have such issue. It will make CQ full(head != tail)[keep one empty queue entry] not equal to CQ empty(head = tail).hwq->max_entries will be used to set SQ&CQ size in SQ&CQ Configuration Registers, we think it should only apply to specific hosts need this quirk not all.
Thanks,
Chun-Hung
Avri Altman
reviewerQuoted 4 lines
Support quirk for host controller not able to distinguish queue full or empty.
Alice Chao (1):
ufs: core: Add host quirkQUIRK_MCQ_EXPAND_QUEUE_SLOT
As part of introducing the quirk, you need to set it on for someone.
Thanks,
Avri
Quoted 7 lines
drivers/ufs/core/ufs-mcq.c | 5 ++++- include/ufs/ufshcd.h | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-)--
2.18.0