scsi: ufs: core: Limit DMA alignment check
authorBjorn Andersson <quic_bjorande@quicinc.com>
Wed, 1 Feb 2023 03:49:17 +0000 (19:49 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 8 Feb 2023 23:49:48 +0000 (18:49 -0500)
commit339aa12218728cad1caf6de3ff7a83771aeed164
tree83093c3d321121637307cc29fb1fb82667b16fcb
parentcf065a7da517367fd1b15295933db10631a956d7
scsi: ufs: core: Limit DMA alignment check

The three DMA memory regions allocated for the host memory space are
documented to require alignment of 128, 1024, and 1024 respectively, but
the returned address is checked for PAGE_SIZE alignment.

In the case where these allocations are serviced by e.g. the Arm SMMU, the
size and alignment will be determined by its supported page sizes. In most
cases SZ_4K and a few larger sizes are available.

In the typical configuration this does not cause problems, but in the event
that the system PAGE_SIZE is increased beyond 4k, it's no longer reasonable
to expect that the allocation will be PAGE_SIZE aligned.

Limit the DMA alignment check to the actual alignment requirements written
in the comments in the code, to avoid the UFS core refusing to initialize
with such configuration.

Link: https://lore.kernel.org/r/20230201034917.1902330-1-quic_bjorande@quicinc.com
Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Asutosh Das <quic_asutoshd@quicinc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/core/ufshcd.c