Hi Gokul, Thank you for the patch! Yet something to improve: [auto build test ERROR on remoteproc/rproc-next] [also build test ERROR on linus/master v6.0-rc5 next-20220913] [cannot apply to pza/reset/next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Gokul-krishna-Krishnakumar/Memory-allocation-change-in-scm-mdt_loader/20220913-024309 base: git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux.git rproc-next config: arm-defconfig compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/93615f3d80d56bd470c334e2055f86bea3e53c25 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Gokul-krishna-Krishnakumar/Memory-allocation-change-in-scm-mdt_loader/20220913-024309 git checkout 93615f3d80d56bd470c334e2055f86bea3e53c25 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/soc/qcom/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot All error/warnings (new ones prefixed by >>): drivers/soc/qcom/mdt_loader.c: In function 'qcom_mdt_read_metadata': >> drivers/soc/qcom/mdt_loader.c:172:19: error: implicit declaration of function 'qcom_get_scm_device' [-Werror=implicit-function-declaration] 172 | scm_dev = qcom_get_scm_device(); | ^~~~~~~~~~~~~~~~~~~ >> drivers/soc/qcom/mdt_loader.c:172:17: warning: assignment to 'struct device *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 172 | scm_dev = qcom_get_scm_device(); | ^ >> drivers/soc/qcom/mdt_loader.c:195:81: warning: passing argument 4 of 'dma_free_coherent' makes integer from pointer without a cast [-Wint-conversion] 195 | dma_free_coherent(scm_dev, ehdr_size + hash_size, data, mdata_phys); | ^~~~~~~~~~ | | | dma_addr_t * {aka unsigned int *} In file included from drivers/soc/qcom/mdt_loader.c:19: include/linux/dma-mapping.h:433:44: note: expected 'dma_addr_t' {aka 'unsigned int'} but argument is of type 'dma_addr_t *' {aka 'unsigned int *'} 433 | void *cpu_addr, dma_addr_t dma_handle) | ~~~~~~~~~~~^~~~~~~~~~ cc1: some warnings being treated as errors vim +/qcom_get_scm_device +172 drivers/soc/qcom/mdt_loader.c 107 108 /** 109 * qcom_mdt_read_metadata() - read header and metadata from mdt or mbn 110 * @fw: firmware of mdt header or mbn 111 * @data_len: length of the read metadata blob 112 * @fw_name: name of the firmware, for construction of segment file names 113 * @dev: device handle to associate resources with 114 * @mdata_phys: phys address for the assigned metadata buffer 115 * 116 * The mechanism that performs the authentication of the loading firmware 117 * expects an ELF header directly followed by the segment of hashes, with no 118 * padding inbetween. This function allocates a chunk of memory for this pair 119 * and copy the two pieces into the buffer. 120 * 121 * In the case of split firmware the hash is found directly following the ELF 122 * header, rather than at p_offset described by the second program header. 123 * 124 * The caller is responsible to free (kfree()) the returned pointer. 125 * 126 * Return: pointer to data, or ERR_PTR() 127 */ 128 void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len, 129 const char *fw_name, struct device *dev, 130 dma_addr_t *mdata_phys) 131 { 132 const struct elf32_phdr *phdrs; 133 const struct elf32_hdr *ehdr; 134 unsigned int hash_segment = 0; 135 struct device *scm_dev = NULL; 136 size_t hash_offset; 137 size_t hash_size; 138 size_t ehdr_size; 139 unsigned int i; 140 ssize_t ret; 141 void *data; 142 143 ehdr = (struct elf32_hdr *)fw->data; 144 phdrs = (struct elf32_phdr *)(ehdr + 1); 145 146 if (ehdr->e_phnum < 2) 147 return ERR_PTR(-EINVAL); 148 149 if (phdrs[0].p_type == PT_LOAD) 150 return ERR_PTR(-EINVAL); 151 152 for (i = 1; i < ehdr->e_phnum; i++) { 153 if ((phdrs[i].p_flags & QCOM_MDT_TYPE_MASK) == QCOM_MDT_TYPE_HASH) { 154 hash_segment = i; 155 break; 156 } 157 } 158 159 if (!hash_segment) { 160 dev_err(dev, "no hash segment found in %s\n", fw_name); 161 return ERR_PTR(-EINVAL); 162 } 163 164 ehdr_size = phdrs[0].p_filesz; 165 hash_size = phdrs[hash_segment].p_filesz; 166 167 /* 168 * During the scm call memory protection will be enabled for the meta 169 * data blob, so make sure it's physically contiguous, 4K aligned and 170 * non-cachable to avoid XPU violations. 171 */ > 172 scm_dev = qcom_get_scm_device(); 173 data = dma_alloc_coherent(scm_dev, ehdr_size + hash_size, mdata_phys, 174 GFP_KERNEL); 175 if (!data) { 176 dev_err(dev, "Allocation of metadata buffer failed.\n"); 177 return NULL; 178 } 179 180 /* Copy ELF header */ 181 memcpy(data, fw->data, ehdr_size); 182 183 if (ehdr_size + hash_size == fw->size) { 184 /* Firmware is split and hash is packed following the ELF header */ 185 hash_offset = phdrs[0].p_filesz; 186 memcpy(data + ehdr_size, fw->data + hash_offset, hash_size); 187 } else if (phdrs[hash_segment].p_offset + hash_size <= fw->size) { 188 /* Hash is in its own segment, but within the loaded file */ 189 hash_offset = phdrs[hash_segment].p_offset; 190 memcpy(data + ehdr_size, fw->data + hash_offset, hash_size); 191 } else { 192 /* Hash is in its own segment, beyond the loaded file */ 193 ret = mdt_load_split_segment(data + ehdr_size, phdrs, hash_segment, fw_name, dev); 194 if (ret) { > 195 dma_free_coherent(scm_dev, ehdr_size + hash_size, data, mdata_phys); 196 return ERR_PTR(ret); 197 } 198 } 199 200 *data_len = ehdr_size + hash_size; 201 202 return data; 203 } 204 EXPORT_SYMBOL_GPL(qcom_mdt_read_metadata); 205 -- 0-DAY CI Kernel Test Service https://01.org/lkp