lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 13 Jul 2020 14:48:41 +0100
From:   Ian Abbott <abbotti@....co.uk>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        Suraj Upadhyay <usuraj35@...il.com>,
        gregkh@...uxfoundation.org, hsweeten@...ionengravers.com
Cc:     linux-kernel@...r.kernel.org, devel@...verdev.osuosl.org,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] staging: comedi: s626: Remove pci-dma-compat wrapper
 APIs.

On 11/07/2020 14:38, Christophe JAILLET wrote:
> Le 11/07/2020 à 14:35, Suraj Upadhyay a écrit :
>> The legacy API wrappers in include/linux/pci-dma-compat.h
>> should go away as it creates unnecessary midlayering
>> for include/linux/dma-mapping.h APIs, instead use dma-mapping.h
>> APIs directly.
>>
>> The patch has been generated with the coccinelle script below
>> and compile-tested.
>>
>> [...]
>> @@ expression E1, E2, E3; @@
>> - pci_alloc_consistent(E1, E2, E3)
>> + dma_alloc_coherent(&E1->dev, E2, E3, GFP_ATOMIC)
>>
>> @@ expression E1, E2, E3; @@
>> - pci_zalloc_consistent(E1, E2, E3)
>> + dma_alloc_coherent(&E1->dev, E2, E3, GFP_ATOMIC)
> 
> This is the tricky part of this kind of cleanup, see below.
> 
> GFP_ATOMIC can't be wrong because it is was exactly what was done with 
> the pci_ function.
> However, most of the time, it can safely be replaced by GFP_KERNEL which 
> gives more opportunities to the memory allocator.
> 
>> [...]
>> diff --git a/drivers/staging/comedi/drivers/s626.c 
>> b/drivers/staging/comedi/drivers/s626.c
>> index 084a8e7b9fc2..c159416662fd 100644
>> --- a/drivers/staging/comedi/drivers/s626.c
>> +++ b/drivers/staging/comedi/drivers/s626.c
>> @@ -2130,13 +2130,15 @@ static int s626_allocate_dma_buffers(struct 
>> comedi_device *dev)
>>       void *addr;
>>       dma_addr_t appdma;
>> -    addr = pci_alloc_consistent(pcidev, S626_DMABUF_SIZE, &appdma);
>> +    addr = dma_alloc_coherent(&pcidev->dev, S626_DMABUF_SIZE, &appdma,
>> +                  GFP_ATOMIC);
>>       if (!addr)
>>           return -ENOMEM;
>>       devpriv->ana_buf.logical_base = addr;
>>       devpriv->ana_buf.physical_base = appdma;
>> -    addr = pci_alloc_consistent(pcidev, S626_DMABUF_SIZE, &appdma);
>> +    addr = dma_alloc_coherent(&pcidev->dev, S626_DMABUF_SIZE, &appdma,
>> +                  GFP_ATOMIC);
>>       if (!addr)
>>           return -ENOMEM;
>>       devpriv->rps_buf.logical_base = addr;
> 's626_allocate_dma_buffers()' is only called from 's626_auto_attach()'.
> In this function, around the call to 's626_allocate_dma_buffers()', you 
> can see:
>    - a few lines before, a call to 'comedi_alloc_devpriv()'
> 
>    - a few lines after, a call to 'comedi_alloc_subdevices()'
> 
> These 2 functions make some memory allocation using GFP_KERNEL.
> 
> So it is likely that using GFP_KERNEL in your proposal is also valid.

Indeed, GFP_KERNEL is perfectly fine here.  It could be done as a 
follow-up patch, or done in a v2 of this patch with a mention in the 
patch description.

-- 
-=( Ian Abbott <abbotti@....co.uk> || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268.  Registered address:    )=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ