All of lore.kernel.org
 help / color / mirror / Atom feed
* [pinchartl:rpi/v6.5/isp/v2 9/24] drivers/staging/vc04_services/vc-sm-cma/vc_sm.c:517:17: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1
@ 2023-08-29  2:12 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2023-08-29  2:12 UTC (permalink / raw)
  To: Dave Stevenson; +Cc: llvm, oe-kbuild-all, Laurent Pinchart, Umang Jain

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/pinchartl/linux.git rpi/v6.5/isp/v2
head:   f21e9808068119a1ea8f1ddb5677c982b79ac10d
commit: e67ba2c176b1030aeaa370a3979e178eb71a775d [9/24] staging: vc04_services: Add new vc-sm-cma driver
config: arm-randconfig-001-20230829 (https://download.01.org/0day-ci/archive/20230829/202308291030.dfFJKL96-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230829/202308291030.dfFJKL96-lkp@intel.com/reproduce)

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>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308291030.dfFJKL96-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/staging/vc04_services/vc-sm-cma/vc_sm.c:517:17: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
           buffer->in_use = 1;
                          ^ ~
   drivers/staging/vc04_services/vc-sm-cma/vc_sm.c:416:1: warning: no previous prototype for function 'vc_sm_cma_import_dmabuf_internal' [-Wmissing-prototypes]
   vc_sm_cma_import_dmabuf_internal(struct sm_state_t *state,
   ^
   drivers/staging/vc04_services/vc-sm-cma/vc_sm.c:415:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int
   ^
   static 
   2 warnings generated.


vim +/int +517 drivers/staging/vc04_services/vc-sm-cma/vc_sm.c

   413	
   414	/* Import a dma_buf to be shared with VC. */
   415	int
   416	vc_sm_cma_import_dmabuf_internal(struct sm_state_t *state,
   417					 struct dma_buf *dma_buf,
   418					 int fd,
   419					 struct dma_buf **imported_buf)
   420	{
   421		DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
   422		struct vc_sm_buffer *buffer = NULL;
   423		struct vc_sm_import import = { };
   424		struct vc_sm_import_result result = { };
   425		struct dma_buf_attachment *attach = NULL;
   426		struct sg_table *sgt = NULL;
   427		dma_addr_t dma_addr;
   428		int ret = 0;
   429		int status;
   430	
   431		/* Setup our allocation parameters */
   432		pr_debug("%s: importing dma_buf %p/fd %d\n", __func__, dma_buf, fd);
   433	
   434		if (fd < 0)
   435			get_dma_buf(dma_buf);
   436		else
   437			dma_buf = dma_buf_get(fd);
   438	
   439		if (!dma_buf)
   440			return -EINVAL;
   441	
   442		attach = dma_buf_attach(dma_buf, &sm_state->pdev->dev);
   443		if (IS_ERR(attach)) {
   444			ret = PTR_ERR(attach);
   445			goto error;
   446		}
   447	
   448		sgt = dma_buf_map_attachment_unlocked(attach, DMA_BIDIRECTIONAL);
   449		if (IS_ERR(sgt)) {
   450			ret = PTR_ERR(sgt);
   451			goto error;
   452		}
   453	
   454		/* Verify that the address block is contiguous */
   455		if (sgt->nents != 1) {
   456			ret = -ENOMEM;
   457			goto error;
   458		}
   459	
   460		/* Allocate local buffer to track this allocation. */
   461		buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
   462		if (!buffer) {
   463			ret = -ENOMEM;
   464			goto error;
   465		}
   466	
   467		import.type = VC_SM_ALLOC_NON_CACHED;
   468		dma_addr = sg_dma_address(sgt->sgl);
   469		import.addr = (u32)dma_addr;
   470		if ((import.addr & 0xC0000000) != 0xC0000000) {
   471			pr_err("%s: Expecting an uncached alias for dma_addr %pad\n",
   472			       __func__, &dma_addr);
   473			import.addr |= 0xC0000000;
   474		}
   475		import.size = sg_dma_len(sgt->sgl);
   476		import.allocator = current->tgid;
   477		import.kernel_id = get_kernel_id(buffer);
   478	
   479		memcpy(import.name, VC_SM_RESOURCE_NAME_DEFAULT,
   480		       sizeof(VC_SM_RESOURCE_NAME_DEFAULT));
   481	
   482		pr_debug("[%s]: attempt to import \"%s\" data - type %u, addr %pad, size %u.\n",
   483			 __func__, import.name, import.type, &dma_addr, import.size);
   484	
   485		/* Allocate the videocore buffer. */
   486		status = vc_sm_cma_vchi_import(sm_state->sm_handle, &import, &result,
   487					       &sm_state->int_trans_id);
   488		if (status == -EINTR) {
   489			pr_debug("[%s]: requesting import memory action restart (trans_id: %u)\n",
   490				 __func__, sm_state->int_trans_id);
   491			ret = -ERESTARTSYS;
   492			sm_state->restart_sys = -EINTR;
   493			sm_state->int_action = VC_SM_MSG_TYPE_IMPORT;
   494			goto error;
   495		} else if (status || !result.res_handle) {
   496			pr_debug("[%s]: failed to import memory on videocore (status: %u, trans_id: %u)\n",
   497				 __func__, status, sm_state->int_trans_id);
   498			ret = -ENOMEM;
   499			goto error;
   500		}
   501	
   502		mutex_init(&buffer->lock);
   503		INIT_LIST_HEAD(&buffer->attachments);
   504		memcpy(buffer->name, import.name,
   505		       min(sizeof(buffer->name), sizeof(import.name) - 1));
   506	
   507		/* Keep track of the buffer we created. */
   508		buffer->vc_handle = result.res_handle;
   509		buffer->size = import.size;
   510		buffer->vpu_state = VPU_MAPPED;
   511	
   512		buffer->imported_dma_buf = dma_buf;
   513	
   514		buffer->attach = attach;
   515		buffer->sgt = sgt;
   516		buffer->dma_addr = dma_addr;
 > 517		buffer->in_use = 1;
   518		buffer->kernel_id = import.kernel_id;
   519	
   520		/*
   521		 * We're done - we need to export a new dmabuf chaining through most
   522		 * functions, but enabling us to release our own internal references
   523		 * here.
   524		 */
   525		exp_info.ops = &dma_buf_import_ops;
   526		exp_info.size = import.size;
   527		exp_info.flags = O_RDWR;
   528		exp_info.priv = buffer;
   529	
   530		buffer->dma_buf = dma_buf_export(&exp_info);
   531		if (IS_ERR(buffer->dma_buf)) {
   532			ret = PTR_ERR(buffer->dma_buf);
   533			goto error;
   534		}
   535	
   536		vc_sm_add_resource(buffer);
   537	
   538		*imported_buf = buffer->dma_buf;
   539	
   540		return 0;
   541	
   542	error:
   543		if (result.res_handle) {
   544			struct vc_sm_free_t free = { result.res_handle, 0 };
   545	
   546			vc_sm_cma_vchi_free(sm_state->sm_handle, &free,
   547					    &sm_state->int_trans_id);
   548		}
   549		free_kernel_id(import.kernel_id);
   550		kfree(buffer);
   551		if (sgt)
   552			dma_buf_unmap_attachment_unlocked(attach, sgt, DMA_BIDIRECTIONAL);
   553		if (attach)
   554			dma_buf_detach(dma_buf, attach);
   555		dma_buf_put(dma_buf);
   556		return ret;
   557	}
   558	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-29  2:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-29  2:12 [pinchartl:rpi/v6.5/isp/v2 9/24] drivers/staging/vc04_services/vc-sm-cma/vc_sm.c:517:17: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.