Re: [PATCH v2] iommu/dma: Explicitly sort PCI DMA windows

From: Rob Herring
Date: Mon May 09 2022 - 15:27:40 EST


On Mon, May 9, 2022 at 5:16 AM Robin Murphy <robin.murphy@xxxxxxx> wrote:
>
> Originally, creating the dma_ranges resource list in pre-sorted fashion
> was the simplest and most efficient way to enforce the order required by
> iova_reserve_pci_windows(). However since then at least one PCI host
> driver is now re-sorting the list for its own probe-time processing,
> which doesn't seem entirely unreasonable, so that basic assumption no
> longer holds. Make iommu-dma robust and get the sort order it needs by
> explicitly sorting, which means we can also save the effort at creation
> time and just build the list in whatever natural order the DT had.
>
> Signed-off-by: Robin Murphy <robin.murphy@xxxxxxx>
> ---
>
> v2: Clean up now-unused local variable
>
> drivers/iommu/dma-iommu.c | 13 ++++++++++++-
> drivers/pci/of.c | 8 +-------
> 2 files changed, 13 insertions(+), 8 deletions(-)

Reviewed-by: Rob Herring <robh@xxxxxxxxxx>