[gabbayo:habanalabs-next 23/24] drivers/misc/habanalabs/habanalabs_ioctl.c:149:3: note: in expansion of macro 'if'

kbuild test robot lkp at intel.com
Tue Apr 2 10:00:19 UTC 2019


tree:   git://people.freedesktop.org/~gabbayo/linux habanalabs-next
head:   aaebb2539ebbebac78f31df2d6ea9f463a27cb8c
commit: 0778d45ef52dd3b9bc92765de7e7f97a80224a06 [23/24] habanalabs: add new IOCTL for debug, tracing and profiling
config: i386-randconfig-x018-201913 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        git checkout 0778d45ef52dd3b9bc92765de7e7f97a80224a06
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:11:0,
                    from include/linux/list.h:9,
                    from include/linux/kobject.h:19,
                    from include/linux/cdev.h:5,
                    from drivers/misc/habanalabs/habanalabs.h:16,
                    from drivers/misc/habanalabs/habanalabs_ioctl.c:9:
   drivers/misc/habanalabs/habanalabs_ioctl.c: In function 'debug_coresight':
   drivers/misc/habanalabs/habanalabs_ioctl.c:149:29: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      if (copy_from_user(input, (void __user *)args->input_ptr,
                                ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> drivers/misc/habanalabs/habanalabs_ioctl.c:149:3: note: in expansion of macro 'if'
      if (copy_from_user(input, (void __user *)args->input_ptr,
      ^~
   drivers/misc/habanalabs/habanalabs_ioctl.c:149:29: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      if (copy_from_user(input, (void __user *)args->input_ptr,
                                ^
   include/linux/compiler.h:58:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
>> drivers/misc/habanalabs/habanalabs_ioctl.c:149:3: note: in expansion of macro 'if'
      if (copy_from_user(input, (void __user *)args->input_ptr,
      ^~
   drivers/misc/habanalabs/habanalabs_ioctl.c:149:29: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      if (copy_from_user(input, (void __user *)args->input_ptr,
                                ^
   include/linux/compiler.h:69:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
>> drivers/misc/habanalabs/habanalabs_ioctl.c:149:3: note: in expansion of macro 'if'
      if (copy_from_user(input, (void __user *)args->input_ptr,
      ^~
   drivers/misc/habanalabs/habanalabs_ioctl.c:179:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      if (copy_to_user((void __user *)args->output_ptr, output,
                       ^
   include/linux/compiler.h:58:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
   drivers/misc/habanalabs/habanalabs_ioctl.c:179:3: note: in expansion of macro 'if'
      if (copy_to_user((void __user *)args->output_ptr, output,
      ^~
   drivers/misc/habanalabs/habanalabs_ioctl.c:179:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      if (copy_to_user((void __user *)args->output_ptr, output,
                       ^
   include/linux/compiler.h:58:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
   drivers/misc/habanalabs/habanalabs_ioctl.c:179:3: note: in expansion of macro 'if'
      if (copy_to_user((void __user *)args->output_ptr, output,
      ^~
   drivers/misc/habanalabs/habanalabs_ioctl.c:179:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
      if (copy_to_user((void __user *)args->output_ptr, output,
                       ^
   include/linux/compiler.h:69:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
   drivers/misc/habanalabs/habanalabs_ioctl.c:179:3: note: in expansion of macro 'if'
      if (copy_to_user((void __user *)args->output_ptr, output,
      ^~

vim +/if +149 drivers/misc/habanalabs/habanalabs_ioctl.c

     2	
     3	/*
     4	 * Copyright 2016-2019 HabanaLabs, Ltd.
     5	 * All Rights Reserved.
     6	 */
     7	
     8	#include <uapi/misc/habanalabs.h>
   > 9	#include "habanalabs.h"
    10	
    11	#include <linux/fs.h>
    12	#include <linux/uaccess.h>
    13	#include <linux/slab.h>
    14	
    15	static u32 hl_debug_struct_size[HL_DEBUG_OP_TIMESTAMP + 1] = {
    16		[HL_DEBUG_OP_ETR] = sizeof(struct hl_debug_params_etr),
    17		[HL_DEBUG_OP_ETF] = sizeof(struct hl_debug_params_etf),
    18		[HL_DEBUG_OP_STM] = sizeof(struct hl_debug_params_stm),
    19		[HL_DEBUG_OP_FUNNEL] = 0,
    20		[HL_DEBUG_OP_BMON] = sizeof(struct hl_debug_params_bmon),
    21		[HL_DEBUG_OP_SPMU] = sizeof(struct hl_debug_params_spmu),
    22		[HL_DEBUG_OP_TIMESTAMP] = 0
    23	
    24	};
    25	
    26	static int device_status_info(struct hl_device *hdev, struct hl_info_args *args)
    27	{
    28		struct hl_info_device_status dev_stat = {0};
    29		u32 size = args->return_size;
    30		void __user *out = (void __user *) (uintptr_t) args->return_pointer;
    31	
    32		if ((!size) || (!out))
    33			return -EINVAL;
    34	
    35		dev_stat.status = hl_device_status(hdev);
    36	
    37		return copy_to_user(out, &dev_stat,
    38				min((size_t)size, sizeof(dev_stat))) ? -EFAULT : 0;
    39	}
    40	
    41	static int hw_ip_info(struct hl_device *hdev, struct hl_info_args *args)
    42	{
    43		struct hl_info_hw_ip_info hw_ip = {0};
    44		u32 size = args->return_size;
    45		void __user *out = (void __user *) (uintptr_t) args->return_pointer;
    46		struct asic_fixed_properties *prop = &hdev->asic_prop;
    47		u64 sram_kmd_size, dram_kmd_size;
    48	
    49		if ((!size) || (!out))
    50			return -EINVAL;
    51	
    52		sram_kmd_size = (prop->sram_user_base_address -
    53					prop->sram_base_address);
    54		dram_kmd_size = (prop->dram_user_base_address -
    55					prop->dram_base_address);
    56	
    57		hw_ip.device_id = hdev->asic_funcs->get_pci_id(hdev);
    58		hw_ip.sram_base_address = prop->sram_user_base_address;
    59		hw_ip.dram_base_address = prop->dram_user_base_address;
    60		hw_ip.tpc_enabled_mask = prop->tpc_enabled_mask;
    61		hw_ip.sram_size = prop->sram_size - sram_kmd_size;
    62		hw_ip.dram_size = prop->dram_size - dram_kmd_size;
    63		if (hw_ip.dram_size > 0)
    64			hw_ip.dram_enabled = 1;
    65		hw_ip.num_of_events = prop->num_of_events;
    66		memcpy(hw_ip.armcp_version,
    67			prop->armcp_info.armcp_version, VERSION_MAX_LEN);
    68		hw_ip.armcp_cpld_version = __le32_to_cpu(prop->armcp_info.cpld_version);
    69		hw_ip.psoc_pci_pll_nr = prop->psoc_pci_pll_nr;
    70		hw_ip.psoc_pci_pll_nf = prop->psoc_pci_pll_nf;
    71		hw_ip.psoc_pci_pll_od = prop->psoc_pci_pll_od;
    72		hw_ip.psoc_pci_pll_div_factor = prop->psoc_pci_pll_div_factor;
    73	
    74		return copy_to_user(out, &hw_ip,
    75			min((size_t)size, sizeof(hw_ip))) ? -EFAULT : 0;
    76	}
    77	
    78	static int hw_events_info(struct hl_device *hdev, struct hl_info_args *args)
    79	{
    80		u32 size, max_size = args->return_size;
    81		void __user *out = (void __user *) (uintptr_t) args->return_pointer;
    82		void *arr;
    83	
    84		if ((!max_size) || (!out))
    85			return -EINVAL;
    86	
    87		arr = hdev->asic_funcs->get_events_stat(hdev, &size);
    88	
    89		return copy_to_user(out, arr, min(max_size, size)) ? -EFAULT : 0;
    90	}
    91	
    92	static int dram_usage_info(struct hl_device *hdev, struct hl_info_args *args)
    93	{
    94		struct hl_info_dram_usage dram_usage = {0};
    95		u32 max_size = args->return_size;
    96		void __user *out = (void __user *) (uintptr_t) args->return_pointer;
    97		struct asic_fixed_properties *prop = &hdev->asic_prop;
    98		u64 dram_kmd_size;
    99	
   100		if ((!max_size) || (!out))
   101			return -EINVAL;
   102	
   103		dram_kmd_size = (prop->dram_user_base_address -
   104					prop->dram_base_address);
   105		dram_usage.dram_free_mem = (prop->dram_size - dram_kmd_size) -
   106						atomic64_read(&hdev->dram_used_mem);
   107		dram_usage.ctx_dram_mem = atomic64_read(&hdev->user_ctx->dram_phys_mem);
   108	
   109		return copy_to_user(out, &dram_usage,
   110			min((size_t) max_size, sizeof(dram_usage))) ? -EFAULT : 0;
   111	}
   112	
   113	static int hw_idle(struct hl_device *hdev, struct hl_info_args *args)
   114	{
   115		struct hl_info_hw_idle hw_idle = {0};
   116		u32 max_size = args->return_size;
   117		void __user *out = (void __user *) (uintptr_t) args->return_pointer;
   118	
   119		if ((!max_size) || (!out))
   120			return -EINVAL;
   121	
   122		hw_idle.is_idle = hdev->asic_funcs->is_device_idle(hdev, NULL, 0);
   123	
   124		return copy_to_user(out, &hw_idle,
   125			min((size_t) max_size, sizeof(hw_idle))) ? -EFAULT : 0;
   126	}
   127	
   128	static int debug_coresight(struct hl_device *hdev, struct hl_debug_args *args)
   129	{
   130		struct hl_debug_params *params;
   131		void *input = NULL, *output = NULL;
   132		int rc;
   133	
   134		params = kzalloc(sizeof(*params), GFP_KERNEL);
   135		if (!params)
   136			return -ENOMEM;
   137	
   138		params->reg_idx = args->reg_idx;
   139		params->enable = args->enable;
   140		params->op = args->op;
   141	
   142		if (args->input_ptr && args->input_size) {
   143			input = kzalloc(args->input_size, GFP_KERNEL);
   144			if (!input) {
   145				rc = -ENOMEM;
   146				goto out;
   147			}
   148	
 > 149			if (copy_from_user(input, (void __user *)args->input_ptr,
   150					args->input_size)) {
   151				dev_err(hdev->dev,
   152					"copy from user failed in debug ioctl\n");
   153				rc = -EFAULT;
   154				goto out;
   155			}
   156	
   157			params->input = input;
   158		}
   159	
   160		if (args->output_ptr && args->output_size) {
   161			output = kzalloc(args->output_size, GFP_KERNEL);
   162			if (!output) {
   163				rc = -ENOMEM;
   164				goto out;
   165			}
   166	
   167			params->output = output;
   168			params->output_size = args->output_size;
   169		}
   170	
   171		rc = hdev->asic_funcs->debug_coresight(hdev, params);
   172		if (rc) {
   173			dev_err(hdev->dev,
   174				"debug coresight operation failed %d\n", rc);
   175			goto out;
   176		}
   177	
   178		if (output) {
   179			if (copy_to_user((void __user *)args->output_ptr, output,
   180					args->output_size)) {
   181				dev_err(hdev->dev,
   182					"copy to user failed in debug ioctl\n");
   183				rc = -EFAULT;
   184				goto out;
   185			}
   186		}
   187	
   188	out:
   189		kfree(params);
   190		kfree(output);
   191		kfree(input);
   192	
   193		return rc;
   194	}
   195	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 28668 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20190402/8a663149/attachment-0001.gz>


More information about the dri-devel mailing list