Enable DMA clustering in the UFS driver
Subsystems (4)
Bart Van Assche
reviewercover Enable DMA clustering in the UFS driver
Hi Martin,
The third patch in this series enables DMA clustering in the UFS driver since UFS host controllers support DMA clustering. The first two patches fix bugs in the Exynos host controller driver.
Please consider this patch series for the next merge window.
Thanks,
Bart.
Bart Van Assche (3):
scsi: ufs: Exynos: Fix DMA alignment for PAGE_SIZE != 4096
scsi: ufs: Exynos: Fix the maximum segment size
scsi: ufs: Enable DMA clustering
drivers/ufs/core/ufshcd.c | 5 ++--- drivers/ufs/host/ufs-exynos.c | 12 +++++++++--- include/ufs/ufshcd.h | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-)
Bart Van Assche
reviewerPATCH 1/3 scsi: ufs: Exynos: Fix DMA alignment for PAGE_SIZE != 4096
The Exynos UFS controller only supports scatter/gather list elements that are aligned on a 4 KiB boundary. Fix DMA alignment in case PAGE_SIZE != 4096. Rename UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE into UFSHCD_QUIRK_4KB_DMA_ALIGNMENT.
--- drivers/ufs/core/ufshcd.c | 4 ++-- drivers/ufs/host/ufs-exynos.c | 2 +- include/ufs/ufshcd.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/ufs/core/ufshcd.c +2 -2
@@ -5029,8 +5029,8 @@ static int ufshcd_slave_configure(struct scsi_device *sdev)ufshcd_hpb_configure (hba, sdev);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 (hba->quirks &UFSHCD_QUIRK_4KB_DMA_ALIGNMENT ) +blk_queue_update_dma_alignment (q,4096 -1 );/* * Block runtime-pm until all consumers are added. * Refer ufshcd_setup_links().
drivers/ufs/host/ufs-exynos.c +1 -1
@@ -1673,7 +1673,7 @@ static const struct exynos_ufs_drv_data exynos_ufs_drvs = {UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR |UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL |UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING | - UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE, + UFSHCD_QUIRK_4KB_DMA_ALIGNMENT, .opts =EXYNOS_UFS_OPT_HAS_APB_CLK_CTRL |EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL | EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX |
include/ufs/ufshcd.h +2 -2
@@ -567,9 +567,9 @@ enum ufshcd_quirks {UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING =1 <<13 ,/* -* This quirk allows only sg entries aligned with page size. +* Align DMA SG entries on a 4 KiB boundary. */ - UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE = 1 << 14, + UFSHCD_QUIRK_4KB_DMA_ALIGNMENT = 1 << 14,/* * This quirk needs to be enabled if the host controller does not
RE: [PATCH 1/3] scsi: ufs: Exynos: Fix DMA alignment for PAGE_SIZE != 4096
Hi Bart
Quoted 18 lines
-----Original Message-----
From: Bart Van Assche [mailto:[email protected]]
Sent: Saturday, January 7, 2023 3:28 AM
To: Martin K . Petersen <[email protected]>
Cc: Jaegeuk Kim <[email protected]>; Avri Altman <[email protected]>; Adrian Hunter <[email protected]>; linux- [email protected]; Bart Van Assche <[email protected]>; Kiwoong Kim <[email protected]>; James E.J. Bottomley <[email protected]>; Krzysztof Kozlowski <[email protected]>; Bean Huo <[email protected]>; Stanley Chu <[email protected]>; Jinyoung Choi <[email protected]>; Chanho Park <[email protected]>; Alim Akhtar <[email protected]>; Arthur Simchaev <[email protected]>; Keoseong Park <[email protected]>; Yoshihiro Shimoda <[email protected]>
Subject: [PATCH 1/3] scsi: ufs: Exynos: Fix DMA alignment forPAGE_SIZE!= 4096
Quoted 1 line
The Exynos UFS controller only supports scatter/gather list elements that
are
Quoted 6 lines
aligned on a 4 KiB boundary. Fix DMA alignment in case
PAGE_SIZE!= 4096. RenameUFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZEintoUFSHCD_QUIRK_4KB_DMA_ALIGNMENT.Cc Kiwoong Kim <[email protected]>Fixes 2b2bfc8aa519 ("scsi: ufs: Introduce a quirk to allow only
page-aligned sg
Quoted 3 lines
entries")
Signed-off-by Bart Van Assche <[email protected]>---
Thanks!
Tested on platforms containing Exynos HCI, so feel free to add
Quoted 58 lines
drivers/ufs/core/ufshcd.c | 4 ++-- drivers/ufs/host/ufs-exynos.c | 2 +- include/ufs/ufshcd.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)drivers/ufs/core/ufshcd.c index renamed from drivers/ufs/core/ufshcd.c +0
-0
99ca5b035028..be18edf4ef7f100644drivers/ufs/core/ufshcd.c +2
-2@@ -5029,8 +5029,8 @@ static int ufshcd_slave_configure(struct scsi_device *sdev)ufshcd_hpb_configure (hba, sdev);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 (hba->quirks &UFSHCD_QUIRK_4KB_DMA_ALIGNMENT ) +blk_queue_update_dma_alignment (q,4096 -1 );/* * Block runtime-pm until all consumers are added.
* Referufshcd_setup_links().drivers/ufs/host/ufs-exynos.c +0
-0@@ -1673,7 +1673,7 @@ static const struct exynos_ufs_drv_data exynos_ufs_drvs = {
UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR|
UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL|
UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING|
-UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE,drivers/ufs/host/ufs-exynos.c +1
-0+ UFSHCD_QUIRK_4KB_DMA_ALIGNMENT,.opts = EXYNOS_UFS_OPT_HAS_APB_CLK_CTRL |
EXYNOS_UFS_OPT_BROKEN_AUTO_CLK_CTRL|
EXYNOS_UFS_OPT_BROKEN_RX_SEL_IDX|include/ufs/ufshcd.h index renamed from include/ufs/ufshcd.h +0
-0
dd5912b4db77..583611444f12100644include/ufs/ufshcd.h +2
-2@@ -567,9 +567,9 @@ enum ufshcd_quirks {UFSHCD_QUIRK_SKIP_DEF_UNIPRO_TIMEOUT_SETTING =1 <<13 ,/* -* This quirk allows only sg entries aligned with page size. +* Align DMA SG entries on a 4 KiB boundary. */ -UFSHCD_QUIRK_ALIGN_SG_WITH_PAGE_SIZE =1 <<14 , +UFSHCD_QUIRK_4KB_DMA_ALIGNMENT =1 << 14,/* * This quirk needs to be enabled if the host controller does not
Bart Van Assche
reviewerPATCH 2/3 scsi: ufs: Exynos: Fix the maximum segment size
In reply to Bart Van AsschePrepare for enabling DMA clustering and also for supporting PAGE_SIZE != 4096 by declaring explicitly that the maximum segment size is 4096 bytes for Exynos UFS host controllers.
--- drivers/ufs/host/ufs-exynos.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/ufs/host/ufs-exynos.c +8 -2
@@ -1586,15 +1586,21 @@ static int exynos_ufs_probe(struct platform_device *pdev)const struct ufs_hba_variant_ops *vops = &ufs_hba_exynos_ops;const struct exynos_ufs_drv_data *drv_data =device_get_match_data (dev); +struct ufs_hba *hba;if (drv_data && drv_data->vops) vops = drv_data->vops; err =ufshcd_pltfrm_init (pdev, vops); -if (err) +if (err) {dev_err (dev,"ufshcd_pltfrm_init() failed %d\n" , err); +return err; + } + + hba =dev_get_drvdata (dev); + hba->host->max_segment_size =4096 ; -return err; +return 0 ; }static int exynos_ufs_remove (struct platform_device *pdev)
RE: [PATCH 2/3] scsi: ufs: Exynos: Fix the maximum segment size
Hi Bart
Quoted 13 lines
-----Original Message-----
From: Bart Van Assche [mailto:[email protected]]
Sent: Saturday, January 7, 2023 3:28 AM
To: Martin K . Petersen <[email protected]>
Cc: Jaegeuk Kim <[email protected]>; Avri Altman <[email protected]>; Adrian Hunter <[email protected]>; linux- [email protected]; Bart Van Assche <[email protected]>; Kiwoong Kim <[email protected]>; James E.J. Bottomley <[email protected]>; Krzysztof Kozlowski <[email protected]>; Chanho Park <[email protected]>; Alim Akhtar <[email protected]>; Bean Huo <[email protected]>
Subject: [PATCH 2/3] scsi: ufs: Exynos: Fix the maximum segment size
Quoted 2 lines
Prepare for enabling DMA clustering and also for supporting
PAGE_SIZE!= 4096 by declaring explicitly that the maximum segment size is 4096 bytes
for
Quoted 5 lines
Exynos UFS host controllers.
Cc Kiwoong Kim <[email protected]>Signed-off-by Bart Van Assche <[email protected]>---
Thanks!
Tested on platforms containing Exynos HCI, so feel free to add
For some reason, I didn't receive you patch-3/3 in my inbox.
Quoted 32 lines
drivers/ufs/host/ufs-exynos.c| 10 ++++++++--1 file changed, 8 insertions(+), 2 deletions(-)drivers/ufs/host/ufs-exynos.c +8
-2@@ -1586,15 +1586,21 @@ static int exynos_ufs_probe(struct platform_device *pdev)const struct ufs_hba_variant_ops *vops = &ufs_hba_exynos_ops;const struct exynos_ufs_drv_data *drv_data =device_get_match_data (dev); +struct ufs_hba *hba;if (drv_data && drv_data->vops) vops = drv_data->vops; err =ufshcd_pltfrm_init (pdev, vops); -if (err) +if (err) {dev_err (dev,"ufshcd_pltfrm_init() failed %d\n" , err); +return err; + } + + hba =dev_get_drvdata (dev); + hba->host->max_segment_size =4096 ; -return err; +return 0 ; }static int
exynos_ufs_remove(struct platform_device *pdev)
Bart Van Assche
reviewerRe: [PATCH 2/3] scsi: ufs: Exynos: Fix the maximum segment size
Quoted 1 line · Alim Akhtar
For some reason, I didn't receive you patch-3/3 in my inbox.
That's unfortunate. That's probably because I use a shell script to generate the Cc-list for UFS driver patches:
scripts/get_maintainer.pl --no-git --no-l --no-r --no-roles --no-rolestats "${1:-&STDIN}"
Anyway, patch 3/3 is available here: https://lore.kernel.org/linux-scsi/[email protected]/
Bart.
Bart Van Assche
reviewerPATCH 3/3 scsi: ufs: Enable DMA clustering
In reply to Bart Van AsscheAll UFS host controllers support DMA clustering. Hence enable DMA clustering.
Note: without patch "Exynos: Fix the maximum segment size", this patch breaks support for the Exynos controller.
--- drivers/ufs/core/ufshcd.c | 1 - 1 file changed, 1 deletion(-)
drivers/ufs/core/ufshcd.c +0 -1
@@ -8429,7 +8429,6 @@ static struct scsi_host_template ufshcd_driver_template = { .max_host_blocked = 1, .track_queue_depth = 1, .sdev_groups = ufshcd_driver_groups, - .dma_boundary = PAGE_SIZE - 1, .rpm_autosuspend_delay = RPM_AUTOSUSPEND_DELAY_MS, };
Avri Altman
reviewerRE: [PATCH 3/3] scsi: ufs: Enable DMA clustering
Quoted 15 lines
All UFS host controllers support DMA clustering. Hence enable DMA clustering.
Note: without patch "Exynos: Fix the maximum segment size", this patch breaks support for the Exynos controller.
Signed-off-by Bart Van Assche <[email protected]>--- drivers/ufs/core/ufshcd.c | 1 - 1 file changed, 1 deletion(-)drivers/ufs/core/ufshcd.c index renamed from drivers/ufs/core/ufshcd.c +0
-0
be18edf4ef7f..fe83fdda8d23100644
drivers/ufs/core/ufshcd.c static struct scsi_host_template · line 8433
Quoted 5 lines
drivers/ufs/core/ufshcd.c +0
-1@@ -8429,7 +8429,6 @@ static struct scsi_host_template ufshcd_driver_template = { .max_host_blocked = 1, .track_queue_depth = 1, .sdev_groups = ufshcd_driver_groups, - .dma_boundary = PAGE_SIZE - 1,
Isn't DBC <= 256KB implies that for a boundary?
Thanks,
Avri
Quoted 1 line
drivers/ufs/core/ufshcd.c +0
-0.rpm_autosuspend_delay = RPM_AUTOSUSPEND_DELAY_MS, };
Bart Van Assche
reviewerRe: [PATCH 3/3] scsi: ufs: Enable DMA clustering
Quoted 10 lines · Avri Altman
Quoted 10 lines
All UFS host controllers support DMA clustering. Hence enable DMA clustering.
Note: without patch "Exynos: Fix the maximum segment size", this patch breaks support for the Exynos controller.
Signed-off-by Bart Van Assche <[email protected]>--- drivers/ufs/core/ufshcd.c | 1 - 1 file changed, 1 deletion(-)
Quoted 12 lines
drivers/ufs/core/ufshcd.c static struct scsi_host_template · line 8433
Quoted 10 lines
drivers/ufs/core/ufshcd.c index renamed from drivers/ufs/core/ufshcd.c +0
-0
be18edf4ef7f..fe83fdda8d23100644drivers/ufs/core/ufshcd.c +0
-1@@ -8429,7 +8429,6 @@ static struct scsi_host_template ufshcd_driver_template = { .max_host_blocked = 1, .track_queue_depth = 1, .sdev_groups = ufshcd_driver_groups, - .dma_boundary = PAGE_SIZE - 1,Isn't DBC <= 256KB implies that for a boundary?
Hi Avri,
I don't think so. I think that the 256 KiB limit for the PRDT corresponds to the max_segment_size parameter. The dma_boundary parameter represents a boundary that must not be crossed by DMA scatter/gather lists. I'm not aware of any restrictions on DMA scatter/gather lists for UFS controllers other than the 256 KiB limit for a single PRDT and a limitation to 32-bits addresses for controllers that only support 32-bits DMA. The latter restriction is already handled by ufshcd_set_dma_mask().
Bart.
Re: [PATCH 3/3] scsi: ufs: Enable DMA clustering
In reply to Bart Van AsscheQuoted 2 lines · Bart Van Assche
All UFS host controllers support DMA clustering. Hence enable DMA clustering.
The patch history of ufshcd.c seems to suggest the dma_boundary setting was never intentional, but was inherited by default.
However, I guess it is not impossible that removing the setting exposes issues for existing controllers.
I suggest perhaps expanding upon the commit message and the cc list so more people will be aware of the change.
Possibly worth including the explanation in your reply to Avri concerning PRDT 256K DBC limit
Quoted 5 lines
Note: without patch "Exynos: Fix the maximum segment size", this patch breaks support for the Exynos controller.
Signed-off-by Bart Van Assche <[email protected]>
Otherwise:
Quoted 16 lines
--- drivers/ufs/core/ufshcd.c | 1 - 1 file changed, 1 deletion(-)drivers/ufs/core/ufshcd.c +0
-1@@ -8429,7 +8429,6 @@ static struct scsi_host_template ufshcd_driver_template = { .max_host_blocked = 1, .track_queue_depth = 1, .sdev_groups = ufshcd_driver_groups, - .dma_boundary = PAGE_SIZE - 1, .rpm_autosuspend_delay = RPM_AUTOSUSPEND_DELAY_MS, };
Bart Van Assche
reviewerRe: [PATCH 3/3] scsi: ufs: Enable DMA clustering
Quoted 17 lines · Adrian Hunter
Quoted 2 lines · Bart Van Assche
All UFS host controllers support DMA clustering. Hence enable DMA clustering.
The patch history of
ufshcd.cseems to suggest thedma_boundarysetting was never intentional, but was inherited by default.However, I guess it is not impossible that removing the setting exposes issues for existing controllers.
I suggest perhaps expanding upon the commit message and the cc list so more people will be aware of the change.
Possibly worth including the explanation in your reply to Avri concerning PRDT 256K DBC limit
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Note: without patch "Exynos: Fix the maximum segment size", this patch breaks support for the Exynos controller.
Signed-off-by Bart Van Assche <[email protected]>Otherwise:
Acked-by Adrian Hunter <[email protected]>
Hi Adrian,
I will make the requested changes.
Thanks for the review!
Bart.