dmar, dma_pool, etc
Niclas Zeising
zeising at freebsd.org
Tue Apr 30 10:38:24 UTC 2019
On 2019-04-30 01:15, Tycho Nightingale wrote:
>
> Hi,
>
>> On Apr 29, 2019, at 4:24 PM, Tycho Nightingale <tychon at freebsd.org> wrote:
>>
>>
>>> On Apr 29, 2019, at 2:34 PM, Niclas Zeising <zeising at freebsd.org> wrote:
>>>
>>> On 2019-04-29 20:27, Niclas Zeising wrote:
>>>> On 2019-04-29 18:00, Tycho Nightingale wrote:
>>>>>> On Apr 29, 2019, at 11:06 AM, Niclas Zeising <zeising at FreeBSD.org> wrote:
>>>>>>
>>>>>> As a side note, I can readily reproduce the hang on a spare laptop, please let me know if I can help in testing or diagnosing in any way.
>>>>>
>>>>>
>>>>> If you can readily reproduce the hang, since there are 2 halves that comprised the fix (the DMA pool and non-pool mappings) it would be instructive to try reverting either dmapool.h or dma-mapping.h independently to see if that helps.
>>>>>
>>>> Hi!
>>>> I will test this and report back. Thank you!
>>>> Regards
>>>
>>> Hi!
>>> Just reverting dmapool.h or dma-mapping.h doesn't work, it won't build. I need to revert more than that. Can you help me figure out what to revert in either case, or provide a patch?
>>
>> Thanks for trying. I managed to setup my HW and reproduce this and I see your point that it doesn’t cleave in half perfectly.
>>
>> Since I’ve got a (non)-working test case, let me investigate a bit further.
>
> I believe I’ve figured this out. At least in my case I’ve been able to eliminate the hangs with the patch included at the bottom of this email.
>
> The issue stems from the implementation of dma_map_sg(). According to the linux DMA documentation[1], entries of the scatter/gather list may be coalesced:
>
> int
> dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, enum dma_data_direction direction)
>
> Returns: the number of DMA address segments mapped (this may be shorter
> than <nents> passed in if some elements of the scatter/gather list are
> physically or virtually adjacent and an IOMMU maps them with a single
> entry).
>
> My implementation of dma_map_sg() does just that. As it turns out there are several consumers of dma_map_sg(), e.g. i915_gem_map_dma_buf() and i915_gem_gtt_prepare_pages(), and mock_map_dma_buf() among others that aren’t compliant with this documented API. Going back to the non-coalesced version is likely the only path forward as bugs in the callee redefine this API de facto.
Hi!
Does this mean that the mentioned functions should be fixed to work with
coalesced scatter/gather lists?
>
> If this addresses the hangs you are seeing, I will post this on Phabricator.
I'll try the patch, and see what happens. I'll also spread it to others
with the same issue, to get more input.
Thank you for helping out with this!
Regards
>
> [1] https://www.kernel.org/doc/Documentation/DMA-API.txt
>
--
Niclas Zeising
More information about the freebsd-x11
mailing list