* [PATCH v1] ufs: introduce UFSHCD_QUIRK_BROKEN_DWORD_UTRD quirk
@ 2016-11-08 7:49 Kiwoong Kim
2016-11-08 19:34 ` Subhash Jadavani
0 siblings, 1 reply; 3+ messages in thread
From: Kiwoong Kim @ 2016-11-08 7:49 UTC (permalink / raw)
To: James E.J. Bottomley, linux-scsi, Martin K. Petersen,
vinholikatti
Cc: 추헌광
Some UFS host controllers may think
granularitys of PRDT length and offset as bytes, not double words.
Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
---
drivers/scsi/ufs/ufshcd.c | 24 +++++++++++++++++++-----
drivers/scsi/ufs/ufshcd.h | 2 ++
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 8e19631..549e3e8 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1161,8 +1161,13 @@ static int ufshcd_map_sg(struct ufshcd_lrb *lrbp)
return sg_segments;
if (sg_segments) {
- lrbp->utr_descriptor_ptr->prd_table_length =
- cpu_to_le16((u16) (sg_segments));
+ if (hba->quirks & UFSHCD_QUIRK_BROKEN_DWORD_UTRD)
+ lrbp->utr_descriptor_ptr->prd_table_length =
+ cpu_to_le16((u16)(sg_segments *
+ sizeof(struct ufshcd_sg_entry)));
+ else
+ lrbp->utr_descriptor_ptr->prd_table_length =
+ cpu_to_le16((u16) (sg_segments));
prd_table = (struct ufshcd_sg_entry *)lrbp->ucd_prdt_ptr;
@@ -2385,12 +2390,21 @@ static void ufshcd_host_memory_configure(struct ufs_hba *hba)
cpu_to_le32(upper_32_bits(cmd_desc_element_addr));
/* Response upiu and prdt offset should be in double words */
- utrdlp[i].response_upiu_offset =
+ if (hba->quirks & UFSHCD_QUIRK_BROKEN_DWORD_UTRD) {
+ utrdlp[i].response_upiu_offset =
+ cpu_to_le16(response_offset);
+ utrdlp[i].prd_table_offset =
+ cpu_to_le16(prdt_offset);
+ utrdlp[i].response_upiu_length =
+ cpu_to_le16(ALIGNED_UPIU_SIZE);
+ } else {
+ utrdlp[i].response_upiu_offset =
cpu_to_le16((response_offset >> 2));
- utrdlp[i].prd_table_offset =
+ utrdlp[i].prd_table_offset =
cpu_to_le16((prdt_offset >> 2));
- utrdlp[i].response_upiu_length =
+ utrdlp[i].response_upiu_length =
cpu_to_le16(ALIGNED_UPIU_SIZE >> 2);
+ }
hba->lrb[i].utr_descriptor_ptr = (utrdlp + i);
hba->lrb[i].ucd_req_ptr =
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 8cf3991..565f005 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -494,6 +494,8 @@ struct ufs_hba {
#define UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION UFS_BIT(5)
#define UFSHCD_QUIRK_GET_VS_RESULT UFS_BIT(6)
+ #define UFSHCD_QUIRK_BROKEN_DWORD_UTRD UFS_BIT(7)
+
unsigned int quirks; /* Deviations from standard UFSHCI spec. */
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v1] ufs: introduce UFSHCD_QUIRK_BROKEN_DWORD_UTRD quirk
2016-11-08 7:49 [PATCH v1] ufs: introduce UFSHCD_QUIRK_BROKEN_DWORD_UTRD quirk Kiwoong Kim
@ 2016-11-08 19:34 ` Subhash Jadavani
2016-11-09 2:17 ` Kiwoong Kim
0 siblings, 1 reply; 3+ messages in thread
From: Subhash Jadavani @ 2016-11-08 19:34 UTC (permalink / raw)
To: Kiwoong Kim
Cc: James E.J. Bottomley, linux-scsi, Martin K. Petersen,
vinholikatti, 추헌광, linux-scsi-owner
On 2016-11-07 23:49, Kiwoong Kim wrote:
> Some UFS host controllers may think
> granularitys of PRDT length and offset as bytes, not double words.
>
> Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
> ---
> drivers/scsi/ufs/ufshcd.c | 24 +++++++++++++++++++-----
> drivers/scsi/ufs/ufshcd.h | 2 ++
> 2 files changed, 21 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 8e19631..549e3e8 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -1161,8 +1161,13 @@ static int ufshcd_map_sg(struct ufshcd_lrb
> *lrbp)
> return sg_segments;
>
> if (sg_segments) {
> - lrbp->utr_descriptor_ptr->prd_table_length =
> - cpu_to_le16((u16) (sg_segments));
> + if (hba->quirks & UFSHCD_QUIRK_BROKEN_DWORD_UTRD)
This might sound more specific:
s/UFSHCD_QUIRK_BROKEN_DWORD_UTRD/UFSHCD_QUIRK_PRDT_BYTE_GRAN .
> + lrbp->utr_descriptor_ptr->prd_table_length =
> + cpu_to_le16((u16)(sg_segments *
> + sizeof(struct ufshcd_sg_entry)));
> + else
> + lrbp->utr_descriptor_ptr->prd_table_length =
> + cpu_to_le16((u16) (sg_segments));
>
> prd_table = (struct ufshcd_sg_entry *)lrbp->ucd_prdt_ptr;
>
> @@ -2385,12 +2390,21 @@ static void
> ufshcd_host_memory_configure(struct ufs_hba *hba)
> cpu_to_le32(upper_32_bits(cmd_desc_element_addr));
>
> /* Response upiu and prdt offset should be in double words */
> - utrdlp[i].response_upiu_offset =
> + if (hba->quirks & UFSHCD_QUIRK_BROKEN_DWORD_UTRD) {
> + utrdlp[i].response_upiu_offset =
> + cpu_to_le16(response_offset);
> + utrdlp[i].prd_table_offset =
> + cpu_to_le16(prdt_offset);
> + utrdlp[i].response_upiu_length =
> + cpu_to_le16(ALIGNED_UPIU_SIZE);
> + } else {
> + utrdlp[i].response_upiu_offset =
> cpu_to_le16((response_offset >> 2));
> - utrdlp[i].prd_table_offset =
> + utrdlp[i].prd_table_offset =
> cpu_to_le16((prdt_offset >> 2));
> - utrdlp[i].response_upiu_length =
> + utrdlp[i].response_upiu_length =
> cpu_to_le16(ALIGNED_UPIU_SIZE >> 2);
> + }
>
> hba->lrb[i].utr_descriptor_ptr = (utrdlp + i);
> hba->lrb[i].ucd_req_ptr =
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 8cf3991..565f005 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -494,6 +494,8 @@ struct ufs_hba {
> #define UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION UFS_BIT(5)
>
> #define UFSHCD_QUIRK_GET_VS_RESULT UFS_BIT(6)
> + #define UFSHCD_QUIRK_BROKEN_DWORD_UTRD UFS_BIT(7)
> +
This extra line space isn't needed.
>
> unsigned int quirks; /* Deviations from standard UFSHCI spec. */
--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 3+ messages in thread* RE: [PATCH v1] ufs: introduce UFSHCD_QUIRK_BROKEN_DWORD_UTRD quirk
2016-11-08 19:34 ` Subhash Jadavani
@ 2016-11-09 2:17 ` Kiwoong Kim
0 siblings, 0 replies; 3+ messages in thread
From: Kiwoong Kim @ 2016-11-09 2:17 UTC (permalink / raw)
To: 'Subhash Jadavani'
Cc: 'James E.J. Bottomley', linux-scsi,
'Martin K. Petersen', vinholikatti, '???',
linux-scsi-owner
> > Some UFS host controllers may think
> > granularitys of PRDT length and offset as bytes, not double words.
> >
> > Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
> > ---
> > drivers/scsi/ufs/ufshcd.c | 24 +++++++++++++++++++-----
> > drivers/scsi/ufs/ufshcd.h | 2 ++
> > 2 files changed, 21 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> > index 8e19631..549e3e8 100644
> > --- a/drivers/scsi/ufs/ufshcd.c
> > +++ b/drivers/scsi/ufs/ufshcd.c
> > @@ -1161,8 +1161,13 @@ static int ufshcd_map_sg(struct ufshcd_lrb
> > *lrbp)
> > return sg_segments;
> >
> > if (sg_segments) {
> > - lrbp->utr_descriptor_ptr->prd_table_length =
> > - cpu_to_le16((u16) (sg_segments));
> > + if (hba->quirks & UFSHCD_QUIRK_BROKEN_DWORD_UTRD)
>
> This might sound more specific:
> s/UFSHCD_QUIRK_BROKEN_DWORD_UTRD/UFSHCD_QUIRK_PRDT_BYTE_GRAN .
That sounds good. I'll apply what you said.
>
> > + lrbp->utr_descriptor_ptr->prd_table_length =
> > + cpu_to_le16((u16)(sg_segments *
> > + sizeof(struct ufshcd_sg_entry)));
> > + else
> > + lrbp->utr_descriptor_ptr->prd_table_length =
> > + cpu_to_le16((u16) (sg_segments));
> >
> > prd_table = (struct ufshcd_sg_entry *)lrbp->ucd_prdt_ptr;
> >
> > @@ -2385,12 +2390,21 @@ static void
> > ufshcd_host_memory_configure(struct ufs_hba *hba)
> >
> cpu_to_le32(upper_32_bits(cmd_desc_element_addr));
> >
> > /* Response upiu and prdt offset should be in double words
> */
> > - utrdlp[i].response_upiu_offset =
> > + if (hba->quirks & UFSHCD_QUIRK_BROKEN_DWORD_UTRD) {
> > + utrdlp[i].response_upiu_offset =
> > + cpu_to_le16(response_offset);
> > + utrdlp[i].prd_table_offset =
> > + cpu_to_le16(prdt_offset);
> > + utrdlp[i].response_upiu_length =
> > + cpu_to_le16(ALIGNED_UPIU_SIZE);
> > + } else {
> > + utrdlp[i].response_upiu_offset =
> > cpu_to_le16((response_offset >> 2));
> > - utrdlp[i].prd_table_offset =
> > + utrdlp[i].prd_table_offset =
> > cpu_to_le16((prdt_offset >> 2));
> > - utrdlp[i].response_upiu_length =
> > + utrdlp[i].response_upiu_length =
> > cpu_to_le16(ALIGNED_UPIU_SIZE >> 2);
> > + }
> >
> > hba->lrb[i].utr_descriptor_ptr = (utrdlp + i);
> > hba->lrb[i].ucd_req_ptr =
> > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> > index 8cf3991..565f005 100644
> > --- a/drivers/scsi/ufs/ufshcd.h
> > +++ b/drivers/scsi/ufs/ufshcd.h
> > @@ -494,6 +494,8 @@ struct ufs_hba {
> > #define UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION UFS_BIT(5)
> >
> > #define UFSHCD_QUIRK_GET_VS_RESULT UFS_BIT(6)
> > + #define UFSHCD_QUIRK_BROKEN_DWORD_UTRD UFS_BIT(7)
> > +
>
> This extra line space isn't needed.
Okay.
>
> >
> > unsigned int quirks; /* Deviations from standard UFSHCI spec.
> */
>
> --
> The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
> Linux Foundation Collaborative Project
> --
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-11-09 2:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-08 7:49 [PATCH v1] ufs: introduce UFSHCD_QUIRK_BROKEN_DWORD_UTRD quirk Kiwoong Kim
2016-11-08 19:34 ` Subhash Jadavani
2016-11-09 2:17 ` Kiwoong Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.