Skip to content

Commit 869749e

Browse files
petegriffingregkh
authored andcommitted
scsi: ufs: exynos: Disable iocc if dma-coherent property isn't set
[ Upstream commit f92bb74 ] If dma-coherent property isn't set then descriptors are non-cacheable and the iocc shareability bits should be disabled. Without this UFS can end up in an incompatible configuration and suffer from random cache related stability issues. Suggested-by: Bart Van Assche <bvanassche@acm.org> Fixes: cc52e15 ("scsi: ufs: ufs-exynos: Support ExynosAuto v9 UFS") Signed-off-by: Peter Griffin <peter.griffin@linaro.org> Link: https://lore.kernel.org/r/20250319-exynos-ufs-stability-fixes-v2-3-96722cc2ba1b@linaro.org Cc: Chanho Park <chanho61.park@samsung.com> Cc: stable@vger.kernel.org Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 56f3327 commit 869749e

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

drivers/ufs/host/ufs-exynos.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ static int exynos_ufs_shareability(struct exynos_ufs *ufs)
210210
/* IO Coherency setting */
211211
if (ufs->sysreg) {
212212
return regmap_update_bits(ufs->sysreg,
213-
ufs->shareability_reg_offset,
214-
ufs->iocc_mask, ufs->iocc_mask);
213+
ufs->iocc_offset,
214+
ufs->iocc_mask, ufs->iocc_val);
215215
}
216216

217217
attr->tx_dif_p_nsec = 3200000;
@@ -1147,13 +1147,22 @@ static int exynos_ufs_parse_dt(struct device *dev, struct exynos_ufs *ufs)
11471147
ufs->sysreg = NULL;
11481148
else {
11491149
if (of_property_read_u32_index(np, "samsung,sysreg", 1,
1150-
&ufs->shareability_reg_offset)) {
1150+
&ufs->iocc_offset)) {
11511151
dev_warn(dev, "can't get an offset from sysreg. Set to default value\n");
1152-
ufs->shareability_reg_offset = UFS_SHAREABILITY_OFFSET;
1152+
ufs->iocc_offset = UFS_SHAREABILITY_OFFSET;
11531153
}
11541154
}
11551155

11561156
ufs->iocc_mask = ufs->drv_data->iocc_mask;
1157+
/*
1158+
* no 'dma-coherent' property means the descriptors are
1159+
* non-cacheable so iocc shareability should be disabled.
1160+
*/
1161+
if (of_dma_is_coherent(dev->of_node))
1162+
ufs->iocc_val = ufs->iocc_mask;
1163+
else
1164+
ufs->iocc_val = 0;
1165+
11571166
ufs->pclk_avail_min = PCLK_AVAIL_MIN;
11581167
ufs->pclk_avail_max = PCLK_AVAIL_MAX;
11591168

drivers/ufs/host/ufs-exynos.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ struct exynos_ufs {
231231
ktime_t entry_hibern8_t;
232232
const struct exynos_ufs_drv_data *drv_data;
233233
struct regmap *sysreg;
234-
u32 shareability_reg_offset;
234+
u32 iocc_offset;
235235
u32 iocc_mask;
236+
u32 iocc_val;
236237

237238
u32 opts;
238239
#define EXYNOS_UFS_OPT_HAS_APB_CLK_CTRL BIT(0)

0 commit comments

Comments
 (0)