linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH v6 0/2] introduce a quirk to allow only page-aligned sg entries
       [not found] <CGME20210119034502epcas2p1b78378690bcbdc6453f657a3379ab90a@epcas2p1.samsung.com>
@ 2021-01-19  3:33 ` Kiwoong Kim
       [not found]   ` <CGME20210119034503epcas2p1d5be1d29bc5def9d4f622e5edfd31df8@epcas2p1.samsung.com>
                     ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Kiwoong Kim @ 2021-01-19  3:33 UTC (permalink / raw)
  To: linux-scsi, alim.akhtar, avri.altman, jejb, martin.petersen,
	beanhuo, asutoshd, cang, bvanassche, grant.jung, sc.suh,
	hy50.seo, sh425.lee, bhoon95.kim
  Cc: 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

 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(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RESEND PATCH -6 1/2] ufs: introduce a quirk to allow only page-aligned sg entries
       [not found]   ` <CGME20210119034503epcas2p1d5be1d29bc5def9d4f622e5edfd31df8@epcas2p1.samsung.com>
@ 2021-01-19  3:33     ` Kiwoong Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Kiwoong Kim @ 2021-01-19  3:33 UTC (permalink / raw)
  To: linux-scsi, alim.akhtar, avri.altman, jejb, martin.petersen,
	beanhuo, asutoshd, cang, bvanassche, grant.jung, sc.suh,
	hy50.seo, sh425.lee, bhoon95.kim
  Cc: Kiwoong Kim

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.

Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 2 ++
 drivers/scsi/ufs/ufshcd.h | 4 ++++
 2 files changed, 6 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index e221add..847eb02 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -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;
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 9bb5f0e..9e7223f 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -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 {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RESEND PATCH -6 2/2] ufs: ufs-exynos: use UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE
       [not found]   ` <CGME20210119034504epcas2p478f76a8f9cb0cbecff219a2098cb2eaf@epcas2p4.samsung.com>
@ 2021-01-19  3:33     ` Kiwoong Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Kiwoong Kim @ 2021-01-19  3:33 UTC (permalink / raw)
  To: linux-scsi, alim.akhtar, avri.altman, jejb, martin.petersen,
	beanhuo, asutoshd, cang, bvanassche, grant.jung, sc.suh,
	hy50.seo, sh425.lee, bhoon95.kim
  Cc: Kiwoong Kim

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

Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
---
 drivers/scsi/ufs/ufs-exynos.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufs-exynos.c b/drivers/scsi/ufs/ufs-exynos.c
index a8770ff..d1f0031 100644
--- a/drivers/scsi/ufs/ufs-exynos.c
+++ b/drivers/scsi/ufs/ufs-exynos.c
@@ -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 |
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RESEND PATCH v6 0/2] introduce a quirk to allow only page-aligned sg entries
  2021-01-19  3:33 ` [RESEND PATCH v6 0/2] introduce a quirk to allow only page-aligned sg entries Kiwoong Kim
       [not found]   ` <CGME20210119034503epcas2p1d5be1d29bc5def9d4f622e5edfd31df8@epcas2p1.samsung.com>
       [not found]   ` <CGME20210119034504epcas2p478f76a8f9cb0cbecff219a2098cb2eaf@epcas2p4.samsung.com>
@ 2021-01-21  2:55   ` Martin K. Petersen
  2021-01-23  4:22   ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2021-01-21  2:55 UTC (permalink / raw)
  To: Kiwoong Kim
  Cc: linux-scsi, alim.akhtar, avri.altman, jejb, martin.petersen,
	beanhuo, asutoshd, cang, bvanassche, grant.jung, sc.suh,
	hy50.seo, sh425.lee, bhoon95.kim


Kiwoong,

> 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!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RESEND PATCH v6 0/2] introduce a quirk to allow only page-aligned sg entries
  2021-01-19  3:33 ` [RESEND PATCH v6 0/2] introduce a quirk to allow only page-aligned sg entries Kiwoong Kim
                     ` (2 preceding siblings ...)
  2021-01-21  2:55   ` [RESEND PATCH v6 0/2] introduce a quirk to allow only page-aligned sg entries Martin K. Petersen
@ 2021-01-23  4:22   ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2021-01-23  4:22 UTC (permalink / raw)
  To: asutoshd, hy50.seo, bhoon95.kim, grant.jung, sc.suh, sh425.lee,
	alim.akhtar, beanhuo, jejb, bvanassche, cang, linux-scsi,
	avri.altman, Kiwoong Kim
  Cc: Martin K . Petersen

On Tue, 19 Jan 2021 12:33:40 +0900, Kiwoong Kim wrote:

> 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

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-23  4:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210119034502epcas2p1b78378690bcbdc6453f657a3379ab90a@epcas2p1.samsung.com>
2021-01-19  3:33 ` [RESEND PATCH v6 0/2] introduce a quirk to allow only page-aligned sg entries Kiwoong Kim
     [not found]   ` <CGME20210119034503epcas2p1d5be1d29bc5def9d4f622e5edfd31df8@epcas2p1.samsung.com>
2021-01-19  3:33     ` [RESEND PATCH -6 1/2] ufs: " Kiwoong Kim
     [not found]   ` <CGME20210119034504epcas2p478f76a8f9cb0cbecff219a2098cb2eaf@epcas2p4.samsung.com>
2021-01-19  3:33     ` [RESEND PATCH -6 2/2] ufs: ufs-exynos: use UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE Kiwoong Kim
2021-01-21  2:55   ` [RESEND PATCH v6 0/2] introduce a quirk to allow only page-aligned sg entries Martin K. Petersen
2021-01-23  4:22   ` 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).