Patch "powerpc/iommu: Report the correct most efficient DMA mask for PCI devices" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    powerpc/iommu: Report the correct most efficient DMA mask for PCI devices

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     powerpc-iommu-report-the-correct-most-efficient-dma-.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 2ac0a1f09246f3189ede508b550d5b494464a60c
Author: Alexey Kardashevskiy <aik@xxxxxxxxx>
Date:   Thu Sep 30 13:44:54 2021 +1000

    powerpc/iommu: Report the correct most efficient DMA mask for PCI devices
    
    [ Upstream commit 23c216b335d1fbd716076e8263b54a714ea3cf0e ]
    
    According to dma-api.rst, the dma_get_required_mask() helper should return
    "the mask that the platform requires to operate efficiently". Which in
    the case of PPC64 means the bypass mask and not a mask from an IOMMU table
    which is shorter and slower to use due to map/unmap operations (especially
    expensive on "pseries").
    
    However the existing implementation ignores the possibility of bypassing
    and returns the IOMMU table mask on the pseries platform which makes some
    drivers (mpt3sas is one example) choose 32bit DMA even though bypass is
    supported. The powernv platform sort of handles it by having a bigger
    default window with a mask >=40 but it only works as drivers choose
    63/64bit if the required mask is >32 which is rather pointless.
    
    This reintroduces the bypass capability check to let drivers make
    a better choice of the DMA mask.
    
    Fixes: f1565c24b596 ("powerpc: use the generic dma_ops_bypass mode")
    Signed-off-by: Alexey Kardashevskiy <aik@xxxxxxxxx>
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20210930034454.95794-1-aik@xxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/powerpc/kernel/dma-iommu.c b/arch/powerpc/kernel/dma-iommu.c
index a1c744194018..9ac0651795cf 100644
--- a/arch/powerpc/kernel/dma-iommu.c
+++ b/arch/powerpc/kernel/dma-iommu.c
@@ -117,6 +117,15 @@ u64 dma_iommu_get_required_mask(struct device *dev)
 	struct iommu_table *tbl = get_iommu_table_base(dev);
 	u64 mask;
 
+	if (dev_is_pci(dev)) {
+		u64 bypass_mask = dma_direct_get_required_mask(dev);
+
+		if (dma_iommu_dma_supported(dev, bypass_mask)) {
+			dev_info(dev, "%s: returning bypass mask 0x%llx\n", __func__, bypass_mask);
+			return bypass_mask;
+		}
+	}
+
 	if (!tbl)
 		return 0;
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux