Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2227010pxv; Sat, 26 Jun 2021 13:20:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynKidWNDK1ZWJTMeT3VCuULFBgUn7LCySS8RaJIqSnCDBgTmzcv/C93Mm74joGgAbUyV+i X-Received: by 2002:a92:7b01:: with SMTP id w1mr12365203ilc.100.1624738821608; Sat, 26 Jun 2021 13:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624738821; cv=none; d=google.com; s=arc-20160816; b=mmeAu6L9zP6Rnea3naZRB53ZfxSGDCnHRVOa+iF7Mnb5cput+Vghl0Uj980JzA3fak 1fATA4XWB8xRjFKrL5qWcNvSEWYvl6vrHyxnZdLatGc0WF8rCXwsI9YV+R9S9UU4HeWs Pu6d0tLGq7drSQMe38CiiEKMdu1PAyO8he6ab+i3iuLxpjUNfkU19InjG9mFCUfoyFyv svg2xT1tY9IpWVW98DJrZ/JujJiYtoIkKDnOmmRFYzKH2Wvpo4LqVQELfSgCV4qwum1l w35+KdYBs2qPgizfn79aCK2CXucMBRpxMwzF6aOmk9uANVSQWDvg6llt1BeGYOUwI3Hr DcoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:ironport-hdrordr; bh=ixsDncZDAMHv0sT+wC2T6bX6P8XliCpBhD4Cc4clu/A=; b=SMHqTig6QGCAItsByKlWDv7/grlJAD10LYY8y2Hl/AZejiWD285alrPYtZC5zwjQ6h opAIrn2l6skVW55M4czaIRKQYd1roP7qkanviJ+c5dpeh/qodbrf0V8BEkRJ3EJaK/LG +6SwVsD8PbQDAZcYdKNNnDNl441tFfMny/xE+gKPo0WAx0dEEQh7joDEGm7V4GcptvBI RmIXvOfvROL2FALb1RJomZZnKZAGXr6qUlI71uNFrisa/HAkS68WoIW/C0fy/Zhhk0sA iwpdg4CUMd+s+7W2T+UOJc1Awn4lKAwpTA3jWevvg9UMmHqgHDksqBYN7airX0+7p7wI iMBw== 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 w3si2795915ilq.110.2021.06.26.13.20.09; Sat, 26 Jun 2021 13:20:21 -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 S230324AbhFZUSW (ORCPT + 99 others); Sat, 26 Jun 2021 16:18:22 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:44850 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbhFZUSV (ORCPT ); Sat, 26 Jun 2021 16:18:21 -0400 IronPort-HdrOrdr: =?us-ascii?q?A9a23=3A7ODs7KEPDnBm+VZOpLqE78eALOsnbusQ8zAX?= =?us-ascii?q?PiFKOHhom6Oj/PxG8M5w6fawslcssRIb6LW90cu7IU80nKQdibX5f43SPzUO01?= =?us-ascii?q?HHEGgN1+ffKnHbak/D398Y5ONbf69yBMaYNzVHpMzxiTPWL+od?= X-IronPort-AV: E=Sophos;i="5.83,302,1616454000"; d="scan'208";a="386249508" Received: from 173.121.68.85.rev.sfr.net (HELO hadrien) ([85.68.121.173]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2021 22:15:57 +0200 Date: Sat, 26 Jun 2021 22:15:56 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Christophe JAILLET cc: Julia.Lawall@inria.fr, Gilles.Muller@inria.fr, nicolas.palix@imag.fr, michal.lkml@markovi.net, cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] Coccinelle: Update and rename api/alloc/pci_free_consistent.cocci In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 16 Jun 2021, Christophe JAILLET wrote: > 'pci_alloc_consistent()' is about to be removed from the kernel. > It is now more useful to check for dma_alloc_coherent/dma_free_coherent. > > So change the script accordingly and rename it. There also seem to be a lot of false positives, where the value is used in unexpected ways, such as: for (i = 0; i < nr_pages; ++i) { cpu_addr = dma_alloc_coherent(dma_dev, PAGE_SIZE, &dma_addr, CIO_DMA_GFP); if (!cpu_addr) return gp_dma; gen_pool_add_virt(gp_dma, (unsigned long) cpu_addr, dma_addr, PAGE_SIZE, -1); } Maybe the rule should be dropped? julia > > Signed-off-by: Christophe JAILLET > --- > Not sure that the script works. > There are 718 'dma_alloc_coherent' calls in 5.13-rc6. It is surprising > to have no match at all, not even a single false positive. > --- > ..._consistent.cocci => dma_free_coherent.cocci} | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > rename scripts/coccinelle/free/{pci_free_consistent.cocci => dma_free_coherent.cocci} (52%) > > diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci b/scripts/coccinelle/free/dma_free_coherent.cocci > similarity index 52% > rename from scripts/coccinelle/free/pci_free_consistent.cocci > rename to scripts/coccinelle/free/dma_free_coherent.cocci > index d51e92556b42..75f159e7b6d7 100644 > --- a/scripts/coccinelle/free/pci_free_consistent.cocci > +++ b/scripts/coccinelle/free/dma_free_coherent.cocci > @@ -1,10 +1,10 @@ > // SPDX-License-Identifier: GPL-2.0-only > -/// Find missing pci_free_consistent for every pci_alloc_consistent. > +/// Find missing dma_free_coherent for every dma_alloc_coherent. > /// > // Confidence: Moderate > // Copyright: (C) 2013 Petr Strnad. > // URL: http://coccinelle.lip6.fr/ > -// Keywords: pci_free_consistent, pci_alloc_consistent > +// Keywords: dma_free_coherent, dma_alloc_coherent > // Options: --no-includes --include-headers > > virtual report > @@ -17,12 +17,12 @@ position p1,p2; > type T; > @@ > > -id = pci_alloc_consistent@p1(x,y,&z) > +id = dma_alloc_coherent@p1(x,y,&z) > ... when != e = id > if (id == NULL || ...) { ... return ...; } > -... when != pci_free_consistent(x,y,id,z) > - when != if (id) { ... pci_free_consistent(x,y,id,z) ... } > - when != if (y) { ... pci_free_consistent(x,y,id,z) ... } > +... when != dma_free_coherent(x,y,id,z) > + when != if (id) { ... dma_free_coherent(x,y,id,z) ... } > + when != if (y) { ... dma_free_coherent(x,y,id,z) ... } > when != e = (T)id > when exists > ( > @@ -40,7 +40,7 @@ p1 << search.p1; > p2 << search.p2; > @@ > > -msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line) > +msg = "ERROR: missing dma_free_coherent; dma_alloc_coherent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line) > coccilib.report.print_report(p2[0],msg) > > @script:python depends on org@ > @@ -48,6 +48,6 @@ p1 << search.p1; > p2 << search.p2; > @@ > > -msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line) > +msg = "ERROR: missing dma_free_coherent; dma_alloc_coherent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line) > cocci.print_main(msg,p1) > cocci.print_secs("",p2) > -- > 2.30.2 > >