linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: [linux-next:master 8309/10976] drivers/gpu/host1x/context.c:82 host1x_memory_context_list_init() warn: missing error code 'err'
       [not found] <ac98d66d-8735-4963-8cdb-be891d134cb3@kili.mountain>
@ 2023-04-13  8:57 ` Thierry Reding
  2023-04-13  9:05   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Thierry Reding @ 2023-04-13  8:57 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: oe-kbuild, Christian König, lkp, oe-kbuild-all,
	Linux Memory Management List

[-- 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 --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [linux-next:master 8309/10976] drivers/gpu/host1x/context.c:82 host1x_memory_context_list_init() warn: missing error code 'err'
  2023-04-13  8:57 ` [linux-next:master 8309/10976] drivers/gpu/host1x/context.c:82 host1x_memory_context_list_init() warn: missing error code 'err' Thierry Reding
@ 2023-04-13  9:05   ` Dan Carpenter
  2023-04-13  9:20     ` Thierry Reding
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2023-04-13  9:05 UTC (permalink / raw)
  To: Thierry Reding
  Cc: oe-kbuild, Christian König, lkp, oe-kbuild-all,
	Linux Memory Management List

On Thu, Apr 13, 2023 at 10:57:52AM +0200, Thierry Reding wrote:
> On Thu, Apr 13, 2023 at 08:06:08AM +0300, Dan Carpenter wrote:
> > 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?

Yes, please.

regards,
dan carpenter



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [linux-next:master 8309/10976] drivers/gpu/host1x/context.c:82 host1x_memory_context_list_init() warn: missing error code 'err'
  2023-04-13  9:05   ` Dan Carpenter
@ 2023-04-13  9:20     ` Thierry Reding
  0 siblings, 0 replies; 3+ messages in thread
From: Thierry Reding @ 2023-04-13  9:20 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: oe-kbuild, Christian König, lkp, oe-kbuild-all,
	Linux Memory Management List

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

On Thu, Apr 13, 2023 at 12:05:15PM +0300, Dan Carpenter wrote:
> On Thu, Apr 13, 2023 at 10:57:52AM +0200, Thierry Reding wrote:
> > On Thu, Apr 13, 2023 at 08:06:08AM +0300, Dan Carpenter wrote:
> > > 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?
> 
> Yes, please.

Looks like Mikko has a different interpretation:

	http://patchwork.ozlabs.org/project/linux-tegra/patch/20230413082202.114721-2-cyndis@kapsi.fi/

I suppose that's another way to do it. It's not exactly backwards-
compatible with existing DTs, though.

Thierry

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-13  9:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ac98d66d-8735-4963-8cdb-be891d134cb3@kili.mountain>
2023-04-13  8:57 ` [linux-next:master 8309/10976] drivers/gpu/host1x/context.c:82 host1x_memory_context_list_init() warn: missing error code 'err' Thierry Reding
2023-04-13  9:05   ` Dan Carpenter
2023-04-13  9:20     ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox