linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <treding@nvidia.com>
To: Dan Carpenter <error27@gmail.com>
Cc: oe-kbuild@lists.linux.dev,
	"Christian König" <christian.koenig@amd.com>,
	lkp@intel.com, oe-kbuild-all@lists.linux.dev,
	"Linux Memory Management List" <linux-mm@kvack.org>
Subject: Re: [linux-next:master 8309/10976] drivers/gpu/host1x/context.c:82 host1x_memory_context_list_init() warn: missing error code 'err'
Date: Thu, 13 Apr 2023 10:57:52 +0200	[thread overview]
Message-ID: <ZDfEEOEoMA55t4ol@orome> (raw)
In-Reply-To: <ac98d66d-8735-4963-8cdb-be891d134cb3@kili.mountain>

[-- Attachment #1: Type: text/plain, Size: 5912 bytes --]

On Thu, Apr 13, 2023 at 08:06:08AM +0300, Dan Carpenter wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head:   7d8214bba44c1aa6a75921a09a691945d26a8d43
> commit: f75d19827b731c6f24930ef77e5a46cf2242bc68 [8309/10976] drm/tegra: Allow compile test on !ARM v2
> config: xtensa-randconfig-m041-20230411 (https://download.01.org/0day-ci/archive/20230413/202304131214.MOOEMszN-lkp@intel.com/config)
> compiler: xtensa-linux-gcc (GCC) 12.1.0
> 
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@intel.com>
> | Reported-by: Dan Carpenter <error27@gmail.com>
> | Link: https://lore.kernel.org/r/202304131214.MOOEMszN-lkp@intel.com/
> 
> smatch warnings:
> drivers/gpu/host1x/context.c:82 host1x_memory_context_list_init() warn: missing error code 'err'
> 
> vim +/err +82 drivers/gpu/host1x/context.c
> 
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  21  int host1x_memory_context_list_init(struct host1x *host1x)
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  22  {
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  23  	struct host1x_memory_context_list *cdl = &host1x->context_list;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  24  	struct device_node *node = host1x->dev->of_node;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  25  	struct host1x_memory_context *ctx;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  26  	unsigned int i;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  27  	int err;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  28  
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  29  	cdl->devs = NULL;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  30  	cdl->len = 0;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  31  	mutex_init(&cdl->lock);
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  32  
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  33  	err = of_property_count_u32_elems(node, "iommu-map");
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  34  	if (err < 0)
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  35  		return 0;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  36  
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  37  	cdl->devs = kcalloc(err, sizeof(*cdl->devs), GFP_KERNEL);
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  38  	if (!cdl->devs)
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  39  		return -ENOMEM;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  40  	cdl->len = err / 4;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  41  
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  42  	for (i = 0; i < cdl->len; i++) {
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  43  		ctx = &cdl->devs[i];
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  44  
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  45  		ctx->host = host1x;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  46  
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  47  		device_initialize(&ctx->dev);
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  48  
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  49  		/*
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  50  		 * Due to an issue with T194 NVENC, only 38 bits can be used.
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  51  		 * Anyway, 256GiB of IOVA ought to be enough for anyone.
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  52  		 */
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  53  		ctx->dma_mask = DMA_BIT_MASK(38);
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  54  		ctx->dev.dma_mask = &ctx->dma_mask;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  55  		ctx->dev.coherent_dma_mask = ctx->dma_mask;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  56  		dev_set_name(&ctx->dev, "host1x-ctx.%d", i);
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  57  		ctx->dev.bus = &host1x_context_device_bus_type;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  58  		ctx->dev.parent = host1x->dev;
> 55879dad0f3ae8 Yang Yingliang  2022-11-26  59  		ctx->dev.release = host1x_memory_context_release;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  60  
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  61  		dma_set_max_seg_size(&ctx->dev, UINT_MAX);
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  62  
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  63  		err = device_add(&ctx->dev);
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  64  		if (err) {
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  65  			dev_err(host1x->dev, "could not add context device %d: %d\n", i, err);
> 55879dad0f3ae8 Yang Yingliang  2022-11-26  66  			put_device(&ctx->dev);
> 55879dad0f3ae8 Yang Yingliang  2022-11-26  67  			goto unreg_devices;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  68  		}
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  69  
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  70  		err = of_dma_configure_id(&ctx->dev, node, true, &i);
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  71  		if (err) {
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  72  			dev_err(host1x->dev, "IOMMU configuration failed for context device %d: %d\n",
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  73  				i, err);
> 55879dad0f3ae8 Yang Yingliang  2022-11-26  74  			device_unregister(&ctx->dev);
> 55879dad0f3ae8 Yang Yingliang  2022-11-26  75  			goto unreg_devices;
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  76  		}
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  77  
> 9026ba722360ce Thierry Reding  2022-11-17  78  		if (!tegra_dev_iommu_get_stream_id(&ctx->dev, &ctx->stream_id) ||
> 9026ba722360ce Thierry Reding  2022-11-17  79  		    !device_iommu_mapped(&ctx->dev)) {
> 8aa5bcb6161206 Mikko Perttunen 2022-06-27  80  			dev_err(host1x->dev, "Context device %d has no IOMMU!\n", i);
> 55879dad0f3ae8 Yang Yingliang  2022-11-26  81  			device_unregister(&ctx->dev);
> 55879dad0f3ae8 Yang Yingliang  2022-11-26 @82  			goto unreg_devices;
> 
> error code?

We don't actually want this to be a fatal failure, so err = 0 is what we
want here. Should we set err = 0 explicitly here to appease smatch?

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

       reply	other threads:[~2023-04-13  8:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <ac98d66d-8735-4963-8cdb-be891d134cb3@kili.mountain>
2023-04-13  8:57 ` Thierry Reding [this message]
2023-04-13  9:05   ` Dan Carpenter
2023-04-13  9:20     ` Thierry Reding

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=ZDfEEOEoMA55t4ol@orome \
    --to=treding@nvidia.com \
    --cc=christian.koenig@amd.com \
    --cc=error27@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@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