Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1325058ybt; Sat, 11 Jul 2020 06:41:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8UCwwvkY5vqOWrNy9kjoXW0/Hf2lxzoqOBCJu7xTj5a6SA7Z5c/0g5R5gGM0udBXOq6EN X-Received: by 2002:a05:6402:1a4b:: with SMTP id bf11mr66044350edb.191.1594474909272; Sat, 11 Jul 2020 06:41:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594474909; cv=none; d=google.com; s=arc-20160816; b=clLnsZcKJjEVPqPRG4BhsTRUjAHrXIej50YoWfC2OPtxsXyKZFSsFSr18lFo2MQGwv h/nvILhjG6cCTb+xZ0cXqQrS57vkTfnrFetA++83rIOO/0dxNj89Zfyundwo82KQeksi RTwZ4QtbWh19zEs6wq9S8iOyN53WZQUp9SlZ+Un3j2EvWFiqIzcfPouPvUUWvhnSXqXd D+ganKtoxhjs1oa9pvyczm/+6rnJtP4tPCCy/6x7lzHE2wkxSw1aBdFX/eXSABzNjqjL VbcQe8MiS7/NbZPO90kTa0PSf5mx5cxs7ZzhBfSq8PnNvMBfhiukNfTBEiS34riZ1tVe KiXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=FayZbR+wkybJTKPgdEsuT2gFR4AaFicMy1CFvRhvjTY=; b=xBGaSQcPv+5nEwqeyiij7xVK7Su91G+qYmS/qFqiAx5PWCjAWDJmPQeGG3ziXl4IDT OHCcnKfCe9pt5+iFiMFZa5nggU1oH4aPYeYOWmj9erJy6oCEgwxQq8ObkGRHf6xg1a/Y W92cuQFrmm10Lx1E7HrPwRBZldy7lHcHoVZgKqTjSoR2uTIONSaLVKBSKbsYOuVzKgur xuFeJFAtGH1pfqASImyTqC8YWxx8utKq/50L1LOwqg2Zrt7PtgJzgKdqk+YvZVCk5GC5 Nor96PJz1nXBBzP38/IbI1EeW8KCp4LlPYiyob4BACOk9qgV/P2DmMO2E9vvrc2zsLkl dyTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch2si5962650edb.80.2020.07.11.06.41.27; Sat, 11 Jul 2020 06:41:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728302AbgGKNim (ORCPT + 99 others); Sat, 11 Jul 2020 09:38:42 -0400 Received: from smtp09.smtpout.orange.fr ([80.12.242.131]:42743 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726342AbgGKNim (ORCPT ); Sat, 11 Jul 2020 09:38:42 -0400 Received: from [192.168.42.210] ([93.22.151.150]) by mwinf5d84 with ME id 1ped2300E3Ewh7h03pedBR; Sat, 11 Jul 2020 15:38:39 +0200 X-ME-Helo: [192.168.42.210] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 11 Jul 2020 15:38:39 +0200 X-ME-IP: 93.22.151.150 Subject: Re: [PATCH] staging: comedi: s626: Remove pci-dma-compat wrapper APIs. To: Suraj Upadhyay , gregkh@linuxfoundation.org, abbotti@mev.co.uk, hsweeten@visionengravers.com Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, kernel-janitors@vger.kernel.org References: <20200711123533.GA15038@blackclown> From: Christophe JAILLET Message-ID: <6f701731-d0af-1bd5-5854-42f0ba39ed35@wanadoo.fr> Date: Sat, 11 Jul 2020 15:38:37 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200711123533.GA15038@blackclown> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Just my 2c. CJ