Skip to content

Commit

Permalink
ARM/dma-mappіng: don't override ->dma_coherent when set from a bus no…
Browse files Browse the repository at this point in the history
…tifier

Commit ae626eb ("ARM/dma-mapping: use dma-direct unconditionally")
caused a regression on the mvebu platform, wherein devices that are
dma-coherent are marked as dma-noncoherent, because although
mvebu_hwcc_notifier() after that commit still marks then as coherent,
the arm_coherent_dma_ops() function, which is called later, overwrites
this setting, since it is being called from drivers/of/device.c with
coherency parameter determined by of_dma_is_coherent(), and the
device-trees do not declare the 'dma-coherent' property.

Fix this by defaulting never clearing the dma_coherent flag in
arm_coherent_dma_ops().

Fixes: ae626eb ("ARM/dma-mapping: use dma-direct unconditionally")
Reported-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tested-by: Marek Behún <kabel@kernel.org>
  • Loading branch information
Christoph Hellwig committed Oct 6, 2022
1 parent f7f04d1 commit 49bc8be
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions arch/arm/mm/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -1769,8 +1769,16 @@ static void arm_teardown_iommu_dma_ops(struct device *dev) { }
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
const struct iommu_ops *iommu, bool coherent)
{
dev->archdata.dma_coherent = coherent;
dev->dma_coherent = coherent;
/*
* Due to legacy code that sets the ->dma_coherent flag from a bus
* notifier we can't just assign coherent to the ->dma_coherent flag
* here, but instead have to make sure we only set but never clear it
* for now.
*/
if (coherent) {
dev->archdata.dma_coherent = true;
dev->dma_coherent = true;
}

/*
* Don't override the dma_ops if they have already been set. Ideally
Expand Down

0 comments on commit 49bc8be

Please sign in to comment.