From: kernel test robot <lkp@intel.com>
To: Walter Wu <walter-zh.wu@mediatek.com>,
Christoph Hellwig <hch@lst.de>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Robin Murphy <robin.murphy@arm.com>,
Matthias Brugger <matthias.bgg@gmail.com>
Cc: Walter Wu <walter-zh.wu@mediatek.com>,
kbuild-all@lists.01.org, wsd_upstream <wsd_upstream@mediatek.com>,
llvm@lists.linux.dev, linux-kernel@vger.kernel.org,
iommu@lists.linux-foundation.org,
linux-mediatek@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING
Date: Mon, 1 Nov 2021 14:10:14 +0800 [thread overview]
Message-ID: <202111011445.HGoPM2pA-lkp@intel.com> (raw)
In-Reply-To: <20211101031558.7184-1-walter-zh.wu@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 6953 bytes --]
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@intel.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
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35151 bytes --]
[-- Attachment #3: Type: text/plain, Size: 156 bytes --]
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: Walter Wu <walter-zh.wu@mediatek.com>,
Christoph Hellwig <hch@lst.de>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Robin Murphy <robin.murphy@arm.com>,
Matthias Brugger <matthias.bgg@gmail.com>
Cc: llvm@lists.linux.dev, kbuild-all@lists.01.org,
iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
wsd_upstream <wsd_upstream@mediatek.com>,
linux-mediatek@lists.infradead.org,
Walter Wu <walter-zh.wu@mediatek.com>
Subject: Re: [PATCH] dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING
Date: Mon, 1 Nov 2021 14:10:14 +0800 [thread overview]
Message-ID: <202111011445.HGoPM2pA-lkp@intel.com> (raw)
In-Reply-To: <20211101031558.7184-1-walter-zh.wu@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 6953 bytes --]
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@intel.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
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35151 bytes --]
[-- Attachment #3: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: Walter Wu <walter-zh.wu@mediatek.com>,
Christoph Hellwig <hch@lst.de>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Robin Murphy <robin.murphy@arm.com>,
Matthias Brugger <matthias.bgg@gmail.com>
Cc: llvm@lists.linux.dev, kbuild-all@lists.01.org,
iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
wsd_upstream <wsd_upstream@mediatek.com>,
linux-mediatek@lists.infradead.org,
Walter Wu <walter-zh.wu@mediatek.com>
Subject: Re: [PATCH] dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING
Date: Mon, 1 Nov 2021 14:10:14 +0800 [thread overview]
Message-ID: <202111011445.HGoPM2pA-lkp@intel.com> (raw)
In-Reply-To: <20211101031558.7184-1-walter-zh.wu@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 6953 bytes --]
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@intel.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
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35151 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: Walter Wu <walter-zh.wu@mediatek.com>,
Christoph Hellwig <hch@lst.de>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Robin Murphy <robin.murphy@arm.com>,
Matthias Brugger <matthias.bgg@gmail.com>
Cc: llvm@lists.linux.dev, kbuild-all@lists.01.org,
iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
wsd_upstream <wsd_upstream@mediatek.com>,
linux-mediatek@lists.infradead.org,
Walter Wu <walter-zh.wu@mediatek.com>
Subject: Re: [PATCH] dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING
Date: Mon, 1 Nov 2021 14:10:14 +0800 [thread overview]
Message-ID: <202111011445.HGoPM2pA-lkp@intel.com> (raw)
In-Reply-To: <20211101031558.7184-1-walter-zh.wu@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 6953 bytes --]
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@intel.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
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35151 bytes --]
[-- Attachment #3: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: Re: [PATCH] dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING
Date: Mon, 01 Nov 2021 14:10:14 +0800 [thread overview]
Message-ID: <202111011445.HGoPM2pA-lkp@intel.com> (raw)
In-Reply-To: <20211101031558.7184-1-walter-zh.wu@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 7124 bytes --]
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@intel.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
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 35151 bytes --]
next prev parent reply other threads:[~2021-11-01 6:10 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-01 3:15 [PATCH] dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING Walter Wu
2021-11-01 3:15 ` Walter Wu
2021-11-01 3:15 ` Walter Wu
2021-11-01 3:15 ` Walter Wu
2021-11-01 6:10 ` kernel test robot [this message]
2021-11-01 6:10 ` kernel test robot
2021-11-01 6:10 ` kernel test robot
2021-11-01 6:10 ` kernel test robot
2021-11-01 6:10 ` kernel test robot
2021-11-01 8:34 ` Ard Biesheuvel
2021-11-01 8:34 ` Ard Biesheuvel
2021-11-01 8:34 ` Ard Biesheuvel
2021-11-01 8:34 ` Ard Biesheuvel
2021-11-01 12:20 ` Walter Wu
2021-11-01 12:20 ` Walter Wu
2021-11-01 12:20 ` Walter Wu
2021-11-01 12:20 ` Walter Wu
2021-11-01 14:17 ` Ard Biesheuvel
2021-11-01 14:17 ` Ard Biesheuvel
2021-11-01 14:17 ` Ard Biesheuvel
2021-11-01 14:17 ` Ard Biesheuvel
2021-11-02 3:21 ` Walter Wu
2021-11-02 3:21 ` Walter Wu
2021-11-02 3:21 ` Walter Wu
2021-11-02 3:21 ` Walter Wu
2021-11-02 6:43 ` Christoph Hellwig
2021-11-02 6:43 ` Christoph Hellwig
2021-11-02 6:43 ` Christoph Hellwig
2021-11-02 6:43 ` Christoph Hellwig
2021-11-01 10:29 ` Robin Murphy
2021-11-01 10:29 ` Robin Murphy
2021-11-01 10:29 ` Robin Murphy
2021-11-01 10:29 ` Robin Murphy
2021-11-01 12:07 ` Walter Wu
2021-11-01 12:07 ` Walter Wu
2021-11-01 12:07 ` Walter Wu
2021-11-01 12:07 ` Walter Wu
2021-11-02 6:41 ` Christoph Hellwig
2021-11-02 6:41 ` Christoph Hellwig
2021-11-02 6:41 ` Christoph Hellwig
2021-11-02 6:41 ` Christoph Hellwig
2021-11-02 7:08 ` Walter Wu
2021-11-02 7:08 ` Walter Wu
2021-11-02 7:08 ` Walter Wu
2021-11-02 7:08 ` Walter Wu
2021-11-02 7:26 ` Walter Wu
2021-11-02 7:26 ` Walter Wu
2021-11-02 7:26 ` Walter Wu
2021-11-02 7:26 ` Walter Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202111011445.HGoPM2pA-lkp@intel.com \
--to=lkp@intel.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=kbuild-all@lists.01.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=llvm@lists.linux.dev \
--cc=m.szyprowski@samsung.com \
--cc=matthias.bgg@gmail.com \
--cc=robin.murphy@arm.com \
--cc=walter-zh.wu@mediatek.com \
--cc=wsd_upstream@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.