Skip to contentSkip to conversation

introduce a quirk to allow only page-aligned sg entries

PATCH RESEND Applied Kiwoong Kim 2 participants 5 messages Jan 19, 2021 – Jan 23, 2021 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20210119034502epcas2p1b78378690bcbdc6453f657a3379ab90a@epcas2p1.samsung.com

#1 lore raw

v6 cover introduce a quirk to allow only page-aligned sg entries

v5 -> v6: replace the way with using a quirk
v4 -> v5: collect received tags
v3 -> v4: fix some typos
v2 -> v3: rename exynos functions
v1 -> v2: rename the vops and fix some typos

Kiwoong Kim (2):
ufs: introduce a quirk to allow only page-aligned sg entries
ufs: ufs-exynos: use UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE

 drivers/scsi/ufs/ufs-exynos.c | 3 ++-
 drivers/scsi/ufs/ufshcd.c     | 2 ++
 drivers/scsi/ufs/ufshcd.h     | 4 ++++
 3 files changed, 8 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#2 lore raw

PATCH RESEND v6 1/2 ufs: introduce a quirk to allow only page-aligned sg entries

Some SoCs could require one scatterlist entry for smaller than page size, i.e. 4KB. For the cases of dispatching commands with more than one scatterlist entry and under 4KB size, They could behave as follows:

Given that a command to read something
from device is dispatched with two scatterlist entries that are named AAA and BBB. After dispatching, host builds two PRDT entries and during transmission, device sends just one DATA IN because device doesn't care on host dma. The host then tranfers the whole data from start address of the area named AAA. In consequence, the area that follows AAA would be corrupted.

    |<------------->|
    +-------+------------         +-------+
    +  AAA  + (corrupted)   ...   +  BBB  +
    +-------+------------         +-------+

In this case, you need to force an aligment with page size for sg entries.

---
 drivers/scsi/ufs/ufshcd.c | 2 ++
 drivers/scsi/ufs/ufshcd.h | 4 ++++
 2 files changed, 6 insertions(+)
drivers/scsi/ufs/ufshcd.c +2 -0
index e221add..847eb02 100644
@@ -4792,6 +4792,8 @@ static int ufshcd_slave_configure(struct scsi_device *sdev)
 	struct request_queue *q = sdev->request_queue;
 
 	blk_queue_update_dma_pad(q, PRDT_DATA_BYTE_COUNT_PAD - 1);
+	if (hba->quirks & UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE)
+		blk_queue_update_dma_alignment(q, PAGE_SIZE - 1);
 
 	if (ufshcd_is_rpm_autosuspend_allowed(hba))
 		sdev->rpm_autosuspend = 1;
drivers/scsi/ufs/ufshcd.h +4 -0
index 9bb5f0e..9e7223f 100644
@@ -549,6 +549,10 @@ enum ufshcd_quirks {
 	 */
 	UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL		= 1 << 12,
 
+	/*
+	 * This quirk allows only sg entries aligned with page size.
+	 */
+	UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE		= 1 << 13,
 };
 
 enum ufshcd_caps {
Signature · 1 line
2.7.4
#3 lore raw

PATCH RESEND v6 2/2 ufs: ufs-exynos: use UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE

In reply to Kiwoong Kim

Exynos needs alignment with page size because it isn't capable to transfer data in one DATA IN to seversal areas.

---
 drivers/scsi/ufs/ufs-exynos.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/ufs/ufs-exynos.c +2 -1
index a8770ff..d1f0031 100644
@@ -1236,7 +1236,8 @@ struct exynos_ufs_drv_data exynos_ufs_drvs = {
 				  UFSHCI_QUIRK_BROKEN_HCE |
 				  UFSHCI_QUIRK_SKIP_RESET_INTR_AGGR |
 				  UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR |
-				  UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL,
+				  UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL |
+				  UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE,
 	.opts			= EXYNOS_UFS_OPT_HAS_APB_CLK_CTRL |
 				  EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL |
 				  EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX |
Signature · 1 line
2.7.4
#4 lore raw
In reply to Kiwoong Kim

Kiwoong,

Quoted 3 lines

Kiwoong Kim (2):
ufs: introduce a quirk to allow only page-aligned sg entries
ufs: ufs-exynos: use UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE

Applied to 5.12/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#5 lore raw
In reply to Kiwoong Kim
Quoted 11 lines · Kiwoong Kim

v5 -> v6: replace the way with using a quirk
v4 -> v5: collect received tags
v3 -> v4: fix some typos
v2 -> v3: rename exynos functions
v1 -> v2: rename the vops and fix some typos

Kiwoong Kim (2):
ufs: introduce a quirk to allow only page-aligned sg entries
ufs: ufs-exynos: use UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE

[...]

Applied to 5.12/scsi-queue, thanks!

[1/2] ufs: introduce a quirk to allow only page-aligned sg entries

      https://git.kernel.org/mkp/scsi/c/2b2bfc8aa519
[2/2] ufs: ufs-exynos: use UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE
      https://git.kernel.org/mkp/scsi/c/f1ef9047aaab
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering