FROMGIT: 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 Change-Id: Iddb462133be5473b012ef58997d6e05867c7f2cc 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> (cherry picked from commit 339aa12218728cad1caf6de3ff7a83771aeed164 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next) Signed-off-by: Bart Van Assche <bvanassche@google.com>
This commit is contained in:
committed by
Bart Van Assche
parent
7c11d103b0
commit
c386657d2e
@@ -3783,12 +3783,9 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba)
|
||||
|
||||
/*
|
||||
* UFSHCI requires UTP command descriptor to be 128 byte aligned.
|
||||
* make sure hba->ucdl_dma_addr is aligned to PAGE_SIZE
|
||||
* if hba->ucdl_dma_addr is aligned to PAGE_SIZE, then it will
|
||||
* be aligned to 128 bytes as well
|
||||
*/
|
||||
if (!hba->ucdl_base_addr ||
|
||||
WARN_ON(hba->ucdl_dma_addr & (PAGE_SIZE - 1))) {
|
||||
WARN_ON(hba->ucdl_dma_addr & (128 - 1))) {
|
||||
dev_err(hba->dev,
|
||||
"Command Descriptor Memory allocation failed\n");
|
||||
goto out;
|
||||
@@ -3804,7 +3801,7 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba)
|
||||
&hba->utrdl_dma_addr,
|
||||
GFP_KERNEL);
|
||||
if (!hba->utrdl_base_addr ||
|
||||
WARN_ON(hba->utrdl_dma_addr & (PAGE_SIZE - 1))) {
|
||||
WARN_ON(hba->utrdl_dma_addr & (1024 - 1))) {
|
||||
dev_err(hba->dev,
|
||||
"Transfer Descriptor Memory allocation failed\n");
|
||||
goto out;
|
||||
@@ -3828,7 +3825,7 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba)
|
||||
&hba->utmrdl_dma_addr,
|
||||
GFP_KERNEL);
|
||||
if (!hba->utmrdl_base_addr ||
|
||||
WARN_ON(hba->utmrdl_dma_addr & (PAGE_SIZE - 1))) {
|
||||
WARN_ON(hba->utmrdl_dma_addr & (1024 - 1))) {
|
||||
dev_err(hba->dev,
|
||||
"Task Management Descriptor Memory allocation failed\n");
|
||||
goto out;
|
||||
|
||||
Reference in New Issue
Block a user