Re: [PATCH net] macmace: Set platform device coherent_dma_mask

From: Michael Schmitz
Date: Fri May 11 2018 - 18:02:23 EST


Hi Finn,

Am 11.05.2018 um 22:06 schrieb Finn Thain:
>> You would have to be careful not to overwrite a pdev->dev.dma_mask and
>> pdev->dev.dma_coherent_mask that might have been set in a platform
>> device passed via platform_device_register here. Coldfire is the only
>> m68k platform currently using that, but there might be others in future.
>>
>
> That Coldfire patch could be reverted if this is a better solution.

True, but there might be other uses for deviating from a platform
default (I'm thinking of Atari SCSI and floppy drivers here). But we
could chose the correct mask to set in arch_setup_pdev_archdata()
instead, as it's a platform property not a driver property in that case.

>> ... But I don't think there are smaller DMA masks used by m68k drivers
>> that use the platform device mechanism at present. I've only looked at
>> arch/m68k though.
>
> So we're back at the same problem that Geert's suggestion also raised: how
> to identify potentially affected platform devices and drivers?
>
> Maybe we can take a leaf out of Christoph's book, and leave a noisy
> WARNING splat in the log.
>
> void arch_setup_pdev_archdata(struct platform_device *pdev)
> {
> WARN_ON_ONCE(pdev->dev.coherent_dma_mask != DMA_MASK_NONE ||
> pdev->dev.dma_mask != NULL);

I'd suggest using WARN_ON() so we catch all uses on a particular platform.

I initially thought it necessary to warn on unset mask here, but I see
that would throw up a lot of redundant false positives.

Cheers,

Michael