ufs: ufs-exynos: set dma_alignment to 4095
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): CGME20210112025710epcas2p1c43b5cd5812881996190ae396116b26a@epcas2p1.samsung.com
v5 cover permit to set block parameters per vendor
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: add a vops to configure block parameter
ufs: ufs-exynos: set dma_alignment to 4095
drivers/scsi/ufs/ufs-exynos.c | 9 +++++++++ drivers/scsi/ufs/ufshcd.c | 2 ++ drivers/scsi/ufs/ufshcd.h | 8 ++++++++ 3 files changed, 19 insertions(+)
Signature · 1 line
2.7.4
PATCH v5 1/2 ufs: add a vops to configure block parameter
There could be some cases to set block parameters per host, because of its own dma structure or whatever.
--- drivers/scsi/ufs/ufshcd.c | 2 ++ drivers/scsi/ufs/ufshcd.h | 8 ++++++++ 2 files changed, 10 insertions(+)
drivers/scsi/ufs/ufshcd.c +2 -0
@@ -4758,6 +4758,8 @@ static int ufshcd_slave_configure(struct scsi_device *sdev)ufshcd_crypto_setup_rq_keyslot_manager (hba, q); +ufshcd_vops_slave_configure (hba, sdev); +return 0 ; }
drivers/scsi/ufs/ufshcd.h +8 -0
@@ -329,6 +329,7 @@ struct ufs_hba_variant_ops { void *data);int (*program_key)(struct ufs_hba *hba,const union ufs_crypto_cfg_entry *cfg,int slot); +void (*slave_configure)(struct scsi_device *sdev); };/* clock gating state */
@@ -1228,6 +1229,13 @@ static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba, hba->vops->config_scaling_param (hba, profile, data); } +static inline void ufshcd_vops_slave_configure (struct ufs_hba *hba, +struct scsi_device *sdev) +{ +if (hba->vops && hba->vops->slave_configure) + hba->vops->slave_configure (sdev); +} +extern struct ufs_pm_lvl_states ufs_pm_lvl_states[];/*
Signature · 1 line
2.7.4
PATCH v5 2/2 ufs: ufs-exynos: set dma_alignment to 4095
In reply to Kiwoong KimExynos requires 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, Exynos behaves 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 +
+-------+------------ +-------+--- drivers/scsi/ufs/ufs-exynos.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/scsi/ufs/ufs-exynos.c +9 -0
@@ -14,6 +14,7 @@#include <linux/of_address.h> #include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/blkdev.h> #include "ufshcd.h" #include "ufshcd-pltfrm.h"
@@ -1193,6 +1194,13 @@ static int exynos_ufs_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)return 0 ; } +static void exynos_ufs_slave_configure (struct scsi_device *sdev) +{ +struct request_queue *q = sdev->request_queue; + +blk_queue_update_dma_alignment (q,PAGE_SIZE -1 ); +} +static struct ufs_hba_variant_ops ufs_hba_exynos_ops = { .name ="exynos_ufs" , .init = exynos_ufs_init,
@@ -1204,6 +1212,7 @@ static struct ufs_hba_variant_ops ufs_hba_exynos_ops = { .hibern8_notify = exynos_ufs_hibern8_notify, .suspend = exynos_ufs_suspend, .resume = exynos_ufs_resume, + .slave_configure = exynos_ufs_slave_configure, };static int exynos_ufs_probe (struct platform_device *pdev)
Signature · 1 line
2.7.4
Quoted 14 lines
Exynos requires 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, Exynos behaves 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.
Quoted 6 lines
|<------------->| +-------+------------ +-------+ + AAA + (corrupted) ... + BBB + +-------+------------ +-------+Signed-off-by Kiwoong Kim <[email protected]>
Just use quirk instead of all these indirections.