Commit 26f968d7 authored by Alim Akhtar's avatar Alim Akhtar Committed by Martin K. Petersen

scsi: ufs: Introduce UFSHCD_QUIRK_PRDT_BYTE_GRAN quirk

Some UFS host controllers like Exynos uses granularities of PRDT length and
offset as bytes, whereas others use actual segment count.

Link: https://lore.kernel.org/r/20200528011658.71590-5-alim.akhtar@samsung.comReviewed-by: default avatarAvri Altman <avri.altman@wdc.com>
Signed-off-by: default avatarKiwoong Kim <kwmad.kim@samsung.com>
Signed-off-by: default avatarAlim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 39bf2d83
...@@ -2168,8 +2168,14 @@ static int ufshcd_map_sg(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) ...@@ -2168,8 +2168,14 @@ static int ufshcd_map_sg(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
return sg_segments; return sg_segments;
if (sg_segments) { if (sg_segments) {
if (hba->quirks & UFSHCD_QUIRK_PRDT_BYTE_GRAN)
lrbp->utr_descriptor_ptr->prd_table_length =
cpu_to_le16((sg_segments *
sizeof(struct ufshcd_sg_entry)));
else
lrbp->utr_descriptor_ptr->prd_table_length = lrbp->utr_descriptor_ptr->prd_table_length =
cpu_to_le16((u16)sg_segments); cpu_to_le16((u16) (sg_segments));
prd_table = (struct ufshcd_sg_entry *)lrbp->ucd_prdt_ptr; prd_table = (struct ufshcd_sg_entry *)lrbp->ucd_prdt_ptr;
...@@ -3518,11 +3524,21 @@ static void ufshcd_host_memory_configure(struct ufs_hba *hba) ...@@ -3518,11 +3524,21 @@ static void ufshcd_host_memory_configure(struct ufs_hba *hba)
cpu_to_le32(upper_32_bits(cmd_desc_element_addr)); cpu_to_le32(upper_32_bits(cmd_desc_element_addr));
/* Response upiu and prdt offset should be in double words */ /* Response upiu and prdt offset should be in double words */
if (hba->quirks & UFSHCD_QUIRK_PRDT_BYTE_GRAN) {
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 = utrdlp[i].response_upiu_offset =
cpu_to_le16(response_offset >> 2); cpu_to_le16(response_offset >> 2);
utrdlp[i].prd_table_offset = cpu_to_le16(prdt_offset >> 2); 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); cpu_to_le16(ALIGNED_UPIU_SIZE >> 2);
}
ufshcd_init_lrb(hba, &hba->lrb[i], i); ufshcd_init_lrb(hba, &hba->lrb[i], i);
} }
......
...@@ -537,6 +537,12 @@ enum ufshcd_quirks { ...@@ -537,6 +537,12 @@ enum ufshcd_quirks {
* enabled via HCE register. * enabled via HCE register.
*/ */
UFSHCI_QUIRK_BROKEN_HCE = 1 << 8, UFSHCI_QUIRK_BROKEN_HCE = 1 << 8,
/*
* This quirk needs to be enabled if the host controller regards
* resolution of the values of PRDTO and PRDTL in UTRD as byte.
*/
UFSHCD_QUIRK_PRDT_BYTE_GRAN = 1 << 9,
}; };
enum ufshcd_caps { enum ufshcd_caps {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment