[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202111011445.HGoPM2pA-lkp@intel.com>
Date: Mon, 1 Nov 2021 14:10:14 +0800
From: kernel test robot <lkp@...el.com>
To: Walter Wu <walter-zh.wu@...iatek.com>,
Christoph Hellwig <hch@....de>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Robin Murphy <robin.murphy@....com>,
Matthias Brugger <matthias.bgg@...il.com>
Cc: llvm@...ts.linux.dev, kbuild-all@...ts.01.org,
iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
wsd_upstream <wsd_upstream@...iatek.com>,
linux-mediatek@...ts.infradead.org,
Walter Wu <walter-zh.wu@...iatek.com>
Subject: Re: [PATCH] dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING
Hi Walter,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linux/master]
[also build test ERROR on linus/master v5.15 next-20211029]
[cannot apply to hch-configfs/for-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]
url: https://github.com/0day-ci/linux/commits/Walter-Wu/dma-direct-fix-DMA_ATTR_NO_KERNEL_MAPPING/20211101-111657
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2f111a6fd5b5297b4e92f53798ca086f7c7d33a4
config: i386-randconfig-r036-20211101 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 82ed106567063ea269c6d5669278b733e173a42f)
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/0day-ci/linux/commit/4694d2ac8f4f9a7476f829f9f43a25111424eca8
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Walter-Wu/dma-direct-fix-DMA_ATTR_NO_KERNEL_MAPPING/20211101-111657
git checkout 4694d2ac8f4f9a7476f829f9f43a25111424eca8
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
All errors (new ones prefixed by >>):
>> kernel/dma/direct.c:174:3: error: implicit declaration of function 'set_memory_valid' [-Werror,-Wimplicit-function-declaration]
set_memory_valid((unsigned long)phys_to_virt(dma_to_phys(dev, *dma_handle)),
^
kernel/dma/direct.c:287:3: error: implicit declaration of function 'set_memory_valid' [-Werror,-Wimplicit-function-declaration]
set_memory_valid((unsigned long)phys_to_virt(dma_to_phys(dev, dma_addr)),
^
2 errors generated.
vim +/set_memory_valid +174 kernel/dma/direct.c
152
153 void *dma_direct_alloc(struct device *dev, size_t size,
154 dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs)
155 {
156 struct page *page;
157 void *ret;
158 int err;
159
160 size = PAGE_ALIGN(size);
161 if (attrs & DMA_ATTR_NO_WARN)
162 gfp |= __GFP_NOWARN;
163
164 if ((attrs & DMA_ATTR_NO_KERNEL_MAPPING) &&
165 !force_dma_unencrypted(dev) && !is_swiotlb_for_alloc(dev)) {
166 page = __dma_direct_alloc_pages(dev, size, gfp & ~__GFP_ZERO);
167 if (!page)
168 return NULL;
169 /* remove any dirty cache lines on the kernel alias */
170 if (!PageHighMem(page))
171 arch_dma_prep_coherent(page, size);
172 *dma_handle = phys_to_dma_direct(dev, page_to_phys(page));
173 /* remove kernel mapping for pages */
> 174 set_memory_valid((unsigned long)phys_to_virt(dma_to_phys(dev, *dma_handle)),
175 size >> PAGE_SHIFT, 0);
176 /* return the page pointer as the opaque cookie */
177 return page;
178 }
179
180 if (!IS_ENABLED(CONFIG_ARCH_HAS_DMA_SET_UNCACHED) &&
181 !IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) &&
182 !IS_ENABLED(CONFIG_DMA_GLOBAL_POOL) &&
183 !dev_is_dma_coherent(dev) &&
184 !is_swiotlb_for_alloc(dev))
185 return arch_dma_alloc(dev, size, dma_handle, gfp, attrs);
186
187 if (IS_ENABLED(CONFIG_DMA_GLOBAL_POOL) &&
188 !dev_is_dma_coherent(dev))
189 return dma_alloc_from_global_coherent(dev, size, dma_handle);
190
191 /*
192 * Remapping or decrypting memory may block. If either is required and
193 * we can't block, allocate the memory from the atomic pools.
194 * If restricted DMA (i.e., is_swiotlb_for_alloc) is required, one must
195 * set up another device coherent pool by shared-dma-pool and use
196 * dma_alloc_from_dev_coherent instead.
197 */
198 if (IS_ENABLED(CONFIG_DMA_COHERENT_POOL) &&
199 !gfpflags_allow_blocking(gfp) &&
200 (force_dma_unencrypted(dev) ||
201 (IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) &&
202 !dev_is_dma_coherent(dev))) &&
203 !is_swiotlb_for_alloc(dev))
204 return dma_direct_alloc_from_pool(dev, size, dma_handle, gfp);
205
206 /* we always manually zero the memory once we are done */
207 page = __dma_direct_alloc_pages(dev, size, gfp & ~__GFP_ZERO);
208 if (!page)
209 return NULL;
210
211 if ((IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) &&
212 !dev_is_dma_coherent(dev)) ||
213 (IS_ENABLED(CONFIG_DMA_REMAP) && PageHighMem(page))) {
214 /* remove any dirty cache lines on the kernel alias */
215 arch_dma_prep_coherent(page, size);
216
217 /* create a coherent mapping */
218 ret = dma_common_contiguous_remap(page, size,
219 dma_pgprot(dev, PAGE_KERNEL, attrs),
220 __builtin_return_address(0));
221 if (!ret)
222 goto out_free_pages;
223 if (force_dma_unencrypted(dev)) {
224 err = set_memory_decrypted((unsigned long)ret,
225 1 << get_order(size));
226 if (err)
227 goto out_free_pages;
228 }
229 memset(ret, 0, size);
230 goto done;
231 }
232
233 if (PageHighMem(page)) {
234 /*
235 * Depending on the cma= arguments and per-arch setup
236 * dma_alloc_contiguous could return highmem pages.
237 * Without remapping there is no way to return them here,
238 * so log an error and fail.
239 */
240 dev_info(dev, "Rejecting highmem page from CMA.\n");
241 goto out_free_pages;
242 }
243
244 ret = page_address(page);
245 if (force_dma_unencrypted(dev)) {
246 err = set_memory_decrypted((unsigned long)ret,
247 1 << get_order(size));
248 if (err)
249 goto out_free_pages;
250 }
251
252 memset(ret, 0, size);
253
254 if (IS_ENABLED(CONFIG_ARCH_HAS_DMA_SET_UNCACHED) &&
255 !dev_is_dma_coherent(dev)) {
256 arch_dma_prep_coherent(page, size);
257 ret = arch_dma_set_uncached(ret, size);
258 if (IS_ERR(ret))
259 goto out_encrypt_pages;
260 }
261 done:
262 *dma_handle = phys_to_dma_direct(dev, page_to_phys(page));
263 return ret;
264
265 out_encrypt_pages:
266 if (force_dma_unencrypted(dev)) {
267 err = set_memory_encrypted((unsigned long)page_address(page),
268 1 << get_order(size));
269 /* If memory cannot be re-encrypted, it must be leaked */
270 if (err)
271 return NULL;
272 }
273 out_free_pages:
274 __dma_direct_free_pages(dev, page, size);
275 return NULL;
276 }
277
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Download attachment ".config.gz" of type "application/gzip" (35151 bytes)
Powered by blists - more mailing lists