linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Sui JIngfeng <sui.jingfeng@linux.dev>
To: Julia Lawall <julia.lawall@inria.fr>,
	Lucas Stach <l.stach@pengutronix.de>
Cc: Linux Memory Management List <linux-mm@kvack.org>,
	oe-kbuild-all@lists.linux.dev
Subject: Re: [linux-next:master 139/1036] drivers/gpu/drm/etnaviv/etnaviv_drv.c:614:3-14: ERROR: probable double put. (fwd)
Date: Mon, 22 Jan 2024 21:38:38 +0800	[thread overview]
Message-ID: <6d51b75b-dfb6-4eda-9f48-ee83d4969b23@linux.dev> (raw)
In-Reply-To: <94afe420-f3b-5620-2380-82c9c62838f0@inria.fr>

Hi,


On 2024/1/22 20:33, Julia Lawall wrote:
> The of_node_put on line 614 does not look useful.

Yes, you are right. It seems that I introduce a problem. Sorry Lucas. 😭

The following code snippet probably will helps to fix this warning:

``` if(!dev->platform_data){
structdevice_node*core_node = NULL;

for_each_compatible_node(core_node, NULL, "vivante,gc"){
if(!of_device_is_available(core_node))
continue;

drm_of_component_match_add(&pdev->dev, &match,
component_compare_of, core_node);

} if (core_node) of_node_put(core_node);
}

```



I think I should post a patch to fix this?


> julia
>
> ---------- Forwarded message ----------
> Date: Mon, 22 Jan 2024 19:18:22 +0800
> From: kernel test robot <lkp@intel.com>
> To: oe-kbuild@lists.linux.dev
> Cc: lkp@intel.com, Julia Lawall <julia.lawall@inria.fr>
> Subject: [linux-next:master 139/1036]
>      drivers/gpu/drm/etnaviv/etnaviv_drv.c:614:3-14: ERROR: probable double put.
>
> BCC: lkp@intel.com
> CC: oe-kbuild-all@lists.linux.dev
> CC: Linux Memory Management List <linux-mm@kvack.org>
> TO: Sui Jingfeng <suijingfeng@loongson.cn>
> CC: Lucas Stach <l.stach@pengutronix.de>
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head:   319fbd8fc6d339e0a1c7b067eed870c518a13a02
> commit: 56df40c804fa40712239478355abe265aeda2197 [139/1036] drm/etnaviv: Add a helper to get the first available GPU device node
> :::::: branch date: 10 hours ago
> :::::: commit date: 3 months ago
> config: x86_64-randconfig-102-20240122 (https://download.01.org/0day-ci/archive/20240122/202401221903.GjEKVu8R-lkp@intel.com/config)
> compiler: ClangBuiltLinux clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Reported-by: Julia Lawall <julia.lawall@inria.fr>
> | Closes: https://lore.kernel.org/r/202401221903.GjEKVu8R-lkp@intel.com/
>
> cocci warnings: (new ones prefixed by >>)
>>> drivers/gpu/drm/etnaviv/etnaviv_drv.c:614:3-14: ERROR: probable double put.
> vim +614 drivers/gpu/drm/etnaviv/etnaviv_drv.c
>
> a8c21a5451d831 The etnaviv authors 2015-12-03  597
> a8c21a5451d831 The etnaviv authors 2015-12-03  598  static int etnaviv_pdev_probe(struct platform_device *pdev)
> a8c21a5451d831 The etnaviv authors 2015-12-03  599  {
> a8c21a5451d831 The etnaviv authors 2015-12-03  600  	struct device *dev = &pdev->dev;
> 0ea057a9cb2be4 Michael Walle       2021-09-07  601  	struct device_node *first_node = NULL;
> a8c21a5451d831 The etnaviv authors 2015-12-03  602  	struct component_match *match = NULL;
> a8c21a5451d831 The etnaviv authors 2015-12-03  603
> 246774d17fc05a Lucas Stach         2018-01-24  604  	if (!dev->platform_data) {
> a8c21a5451d831 The etnaviv authors 2015-12-03  605  		struct device_node *core_node;
> a8c21a5451d831 The etnaviv authors 2015-12-03  606
> 246774d17fc05a Lucas Stach         2018-01-24  607  		for_each_compatible_node(core_node, NULL, "vivante,gc") {
> 246774d17fc05a Lucas Stach         2018-01-24  608  			if (!of_device_is_available(core_node))
> 246774d17fc05a Lucas Stach         2018-01-24  609  				continue;
> a8c21a5451d831 The etnaviv authors 2015-12-03  610
> 97ac0e47aed5f6 Russell King        2016-10-19  611  			drm_of_component_match_add(&pdev->dev, &match,
> 0a522394202f1f Yong Wu             2022-02-14  612  						   component_compare_of, core_node);
> 56df40c804fa40 Sui Jingfeng        2023-10-02  613
> 56df40c804fa40 Sui Jingfeng        2023-10-02 @614  			of_node_put(core_node);
> a8c21a5451d831 The etnaviv authors 2015-12-03  615  		}
> 246774d17fc05a Lucas Stach         2018-01-24  616  	} else {
> a8c21a5451d831 The etnaviv authors 2015-12-03  617  		char **names = dev->platform_data;
> a8c21a5451d831 The etnaviv authors 2015-12-03  618  		unsigned i;
> a8c21a5451d831 The etnaviv authors 2015-12-03  619
> a8c21a5451d831 The etnaviv authors 2015-12-03  620  		for (i = 0; names[i]; i++)
> 0a522394202f1f Yong Wu             2022-02-14  621  			component_match_add(dev, &match, component_compare_dev_name, names[i]);
> a8c21a5451d831 The etnaviv authors 2015-12-03  622  	}
> a8c21a5451d831 The etnaviv authors 2015-12-03  623
> f5be833dc86f49 Michael Walle       2021-09-07  624  	/*
> f5be833dc86f49 Michael Walle       2021-09-07  625  	 * PTA and MTLB can have 40 bit base addresses, but
> f5be833dc86f49 Michael Walle       2021-09-07  626  	 * unfortunately, an entry in the MTLB can only point to a
> f5be833dc86f49 Michael Walle       2021-09-07  627  	 * 32 bit base address of a STLB. Moreover, to initialize the
> f5be833dc86f49 Michael Walle       2021-09-07  628  	 * MMU we need a command buffer with a 32 bit address because
> f5be833dc86f49 Michael Walle       2021-09-07  629  	 * without an MMU there is only an indentity mapping between
> f5be833dc86f49 Michael Walle       2021-09-07  630  	 * the internal 32 bit addresses and the bus addresses.
> f5be833dc86f49 Michael Walle       2021-09-07  631  	 *
> f5be833dc86f49 Michael Walle       2021-09-07  632  	 * To make things easy, we set the dma_coherent_mask to 32
> f5be833dc86f49 Michael Walle       2021-09-07  633  	 * bit to make sure we are allocating the command buffers and
> f5be833dc86f49 Michael Walle       2021-09-07  634  	 * TLBs in the lower 4 GiB address space.
> f5be833dc86f49 Michael Walle       2021-09-07  635  	 */
> f5be833dc86f49 Michael Walle       2021-09-07  636  	if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(40)) ||
> f5be833dc86f49 Michael Walle       2021-09-07  637  	    dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32))) {
> f5be833dc86f49 Michael Walle       2021-09-07  638  		dev_dbg(&pdev->dev, "No suitable DMA available\n");
> f5be833dc86f49 Michael Walle       2021-09-07  639  		return -ENODEV;
> f5be833dc86f49 Michael Walle       2021-09-07  640  	}
> f5be833dc86f49 Michael Walle       2021-09-07  641
> 0ea057a9cb2be4 Michael Walle       2021-09-07  642  	/*
> 0ea057a9cb2be4 Michael Walle       2021-09-07  643  	 * Apply the same DMA configuration to the virtual etnaviv
> 0ea057a9cb2be4 Michael Walle       2021-09-07  644  	 * device as the GPU we found. This assumes that all Vivante
> 0ea057a9cb2be4 Michael Walle       2021-09-07  645  	 * GPUs in the system share the same DMA constraints.
> 0ea057a9cb2be4 Michael Walle       2021-09-07  646  	 */
> 56df40c804fa40 Sui Jingfeng        2023-10-02  647  	first_node = etnaviv_of_first_available_node();
> 56df40c804fa40 Sui Jingfeng        2023-10-02  648  	if (first_node) {
> 0ea057a9cb2be4 Michael Walle       2021-09-07  649  		of_dma_configure(&pdev->dev, first_node, true);
> 56df40c804fa40 Sui Jingfeng        2023-10-02  650  		of_node_put(first_node);
> 56df40c804fa40 Sui Jingfeng        2023-10-02  651  	}
> 0ea057a9cb2be4 Michael Walle       2021-09-07  652
> a8c21a5451d831 The etnaviv authors 2015-12-03  653  	return component_master_add_with_match(dev, &etnaviv_master_ops, match);
> a8c21a5451d831 The etnaviv authors 2015-12-03  654  }
> a8c21a5451d831 The etnaviv authors 2015-12-03  655
>


  reply	other threads:[~2024-01-22 13:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22 12:33 [linux-next:master 139/1036] drivers/gpu/drm/etnaviv/etnaviv_drv.c:614:3-14: ERROR: probable double put. (fwd) Julia Lawall
2024-01-22 13:38 ` Sui JIngfeng [this message]
2024-01-22 13:49 ` Sui JIngfeng
2024-01-23  9:25   ` Lucas Stach
2024-01-23 11:46     ` Sui Jingfeng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6d51b75b-dfb6-4eda-9f48-ee83d4969b23@linux.dev \
    --to=sui.jingfeng@linux.dev \
    --cc=julia.lawall@inria.fr \
    --cc=l.stach@pengutronix.de \
    --cc=linux-mm@kvack.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).