lkml.org 
[lkml]   [2019]   [Aug]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Regression due to d98849aff879 (dma-direct: handle DMA_ATTR_NO_KERNEL_MAPPING in common code)
Date
On 8/6/19 9:06 AM, Lucas Stach wrote:
> Am Dienstag, den 06.08.2019, 16:04 +0200 schrieb Christoph Hellwig:
>> Ok, does this work?
>>
>> --
>> From 34d35f335a98f515f2516b515051e12eae744c8d Mon Sep 17 00:00:00 2001
>>> From: Christoph Hellwig <hch@lst.de>
>> Date: Tue, 6 Aug 2019 14:33:23 +0300
>> Subject: dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING
>>
>> The new DMA_ATTR_NO_KERNEL_MAPPING needs to actually assign
>> a dma_addr to work.  Also skip it if the architecture needs
>> forced decryption handling, as that needs a kernel virtual
>> address.
>>
>> Fixes: d98849aff879 (dma-direct: handle DMA_ATTR_NO_KERNEL_MAPPING in common code)
>>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>> ---
>>  kernel/dma/direct.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
>> index 59bdceea3737..b01064d884f2 100644
>> --- a/kernel/dma/direct.c
>> +++ b/kernel/dma/direct.c
>> @@ -130,11 +130,13 @@ void *dma_direct_alloc_pages(struct device *dev, size_t size,
>>>   if (!page)
>>>   return NULL;
>>  
>>> - if (attrs & DMA_ATTR_NO_KERNEL_MAPPING) {
>>> + if ((attrs & DMA_ATTR_NO_KERNEL_MAPPING) &&
>> +     !force_dma_unencrypted(dev)) {

I think you need to keep everything inside the original if statement since
the caller is expecting a page pointer to be returned in this case and not
the page_address() which is returned when the DMA_ATTR_NO_KERNEL_MAPPING
is not present.

>
> dma_direct_free_pages() then needs the same check, as otherwise the cpu

Agreed. And the cpu_addr passed in here will be the page pointer, so
will need to keep everything inside the if check of the
DMA_ATTR_NO_KERNEL_MAPPING attr here as well.

Thanks,
Tom

> address is treated as a cookie instead of a real address and the
> encryption needs to be re-enabled.
>
> Regards,
> Lucas
>
>>   /* remove any dirty cache lines on the kernel alias */
>>>   if (!PageHighMem(page))
>>>   arch_dma_prep_coherent(page, size);
>>>   /* return the page pointer as the opaque cookie */
>>> + *dma_handle = phys_to_dma(dev, page_to_phys(page));
>>>   return page;
>>>   }
>>  
\
 
 \ /
  Last update: 2019-08-06 16:20    [W:0.091 / U:17.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site