If tbo.mem.bus.caching is cached, buffer is intended to be mapped as cached from CPU. Map it with ioremap_cache.
This wasn't necessary before as device memory was never mapped as cached from CPU side. It becomes necessary for aldebaran as device memory is mapped cached from CPU.
Signed-off-by: Oak Zeng Oak.Zeng@amd.com Reviewed-by: Christian Konig Christian.Koenig@amd.com --- drivers/gpu/drm/ttm/ttm_bo_util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 031e581..7429464 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -91,6 +91,10 @@ static int ttm_resource_ioremap(struct ttm_device *bdev,
if (mem->bus.caching == ttm_write_combined) addr = ioremap_wc(mem->bus.offset, bus_size); +#ifdef CONFIG_X86 + else if (mem->bus.caching == ttm_cached) + addr = ioremap_cache(mem->bus.offset, bus_size); +#endif else addr = ioremap(mem->bus.offset, bus_size); if (!addr) { @@ -372,6 +376,11 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo, if (mem->bus.caching == ttm_write_combined) map->virtual = ioremap_wc(bo->mem.bus.offset + offset, size); +#ifdef CONFIG_X86 + else if (mem->bus.caching == ttm_cached) + map->virtual = ioremap_cache(bo->mem.bus.offset + offset, + size); +#endif else map->virtual = ioremap(bo->mem.bus.offset + offset, size); @@ -490,6 +499,11 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map) else if (mem->bus.caching == ttm_write_combined) vaddr_iomem = ioremap_wc(mem->bus.offset, bo->base.size); + else if (mem->bus.caching == ttm_cached) +#ifdef CONFIG_X86 + vaddr_iomem = ioremap_cache(mem->bus.offset, + bo->base.size); +#endif else vaddr_iomem = ioremap(mem->bus.offset, bo->base.size);
I was wondering if a managed version of such API exists but looks like none. We only have devm_ioremap_wc but that is valid only for PAGE_CACHE_MODE_WC whereas ioremap_cache uses _WB. One more small comment below.
Acked-by: Rajneesh Bhardwaj rajneesh.bhardwaj@amd.com
On 3/4/2021 11:04 AM, Oak Zeng wrote:
If tbo.mem.bus.caching is cached, buffer is intended to be mapped as cached from CPU. Map it with ioremap_cache.
This wasn't necessary before as device memory was never mapped as cached from CPU side. It becomes necessary for aldebaran as device memory is mapped cached from CPU.
Signed-off-by: Oak Zeng Oak.Zeng@amd.com Reviewed-by: Christian Konig Christian.Koenig@amd.com
drivers/gpu/drm/ttm/ttm_bo_util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 031e581..7429464 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -91,6 +91,10 @@ static int ttm_resource_ioremap(struct ttm_device *bdev,
if (mem->bus.caching == ttm_write_combined) addr = ioremap_wc(mem->bus.offset, bus_size);
+#ifdef CONFIG_X86
Please use #if defined (CONFIG_X86)
else if (mem->bus.caching == ttm_cached)
addr = ioremap_cache(mem->bus.offset, bus_size);
+#endif else addr = ioremap(mem->bus.offset, bus_size); if (!addr) { @@ -372,6 +376,11 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo, if (mem->bus.caching == ttm_write_combined) map->virtual = ioremap_wc(bo->mem.bus.offset + offset, size); +#ifdef CONFIG_X86
else if (mem->bus.caching == ttm_cached)
map->virtual = ioremap_cache(bo->mem.bus.offset + offset,
size);
+#endif else map->virtual = ioremap(bo->mem.bus.offset + offset, size); @@ -490,6 +499,11 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map) else if (mem->bus.caching == ttm_write_combined) vaddr_iomem = ioremap_wc(mem->bus.offset, bo->base.size);
else if (mem->bus.caching == ttm_cached)
+#ifdef CONFIG_X86
vaddr_iomem = ioremap_cache(mem->bus.offset,
bo->base.size);
+#endif else vaddr_iomem = ioremap(mem->bus.offset, bo->base.size);
Am 04.03.21 um 18:01 schrieb Bhardwaj, Rajneesh:
I was wondering if a managed version of such API exists but looks like none. We only have devm_ioremap_wc but that is valid only for PAGE_CACHE_MODE_WC whereas ioremap_cache uses _WB. One more small comment below.
Acked-by: Rajneesh Bhardwaj rajneesh.bhardwaj@amd.com
On 3/4/2021 11:04 AM, Oak Zeng wrote:
If tbo.mem.bus.caching is cached, buffer is intended to be mapped as cached from CPU. Map it with ioremap_cache.
This wasn't necessary before as device memory was never mapped as cached from CPU side. It becomes necessary for aldebaran as device memory is mapped cached from CPU.
Signed-off-by: Oak Zeng Oak.Zeng@amd.com Reviewed-by: Christian Konig Christian.Koenig@amd.com
drivers/gpu/drm/ttm/ttm_bo_util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 031e581..7429464 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -91,6 +91,10 @@ static int ttm_resource_ioremap(struct ttm_device *bdev, if (mem->bus.caching == ttm_write_combined) addr = ioremap_wc(mem->bus.offset, bus_size); +#ifdef CONFIG_X86
Please use #if defined (CONFIG_X86)
Actually #ifdef is usually preferred.
Christian.
+ else if (mem->bus.caching == ttm_cached) + addr = ioremap_cache(mem->bus.offset, bus_size); +#endif else addr = ioremap(mem->bus.offset, bus_size); if (!addr) { @@ -372,6 +376,11 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo, if (mem->bus.caching == ttm_write_combined) map->virtual = ioremap_wc(bo->mem.bus.offset + offset, size); +#ifdef CONFIG_X86 + else if (mem->bus.caching == ttm_cached) + map->virtual = ioremap_cache(bo->mem.bus.offset + offset, + size); +#endif else map->virtual = ioremap(bo->mem.bus.offset + offset, size); @@ -490,6 +499,11 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map) else if (mem->bus.caching == ttm_write_combined) vaddr_iomem = ioremap_wc(mem->bus.offset, bo->base.size); + else if (mem->bus.caching == ttm_cached) +#ifdef CONFIG_X86 + vaddr_iomem = ioremap_cache(mem->bus.offset, + bo->base.size); +#endif else vaddr_iomem = ioremap(mem->bus.offset, bo->base.size);
amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
On 3/4/2021 12:31 PM, Christian König wrote:
[CAUTION: External Email]
Am 04.03.21 um 18:01 schrieb Bhardwaj, Rajneesh:
I was wondering if a managed version of such API exists but looks like none. We only have devm_ioremap_wc but that is valid only for PAGE_CACHE_MODE_WC whereas ioremap_cache uses _WB. One more small comment below.
Acked-by: Rajneesh Bhardwaj rajneesh.bhardwaj@amd.com
On 3/4/2021 11:04 AM, Oak Zeng wrote:
If tbo.mem.bus.caching is cached, buffer is intended to be mapped as cached from CPU. Map it with ioremap_cache.
This wasn't necessary before as device memory was never mapped as cached from CPU side. It becomes necessary for aldebaran as device memory is mapped cached from CPU.
Signed-off-by: Oak Zeng Oak.Zeng@amd.com Reviewed-by: Christian Konig Christian.Koenig@amd.com
drivers/gpu/drm/ttm/ttm_bo_util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 031e581..7429464 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -91,6 +91,10 @@ static int ttm_resource_ioremap(struct ttm_device *bdev, if (mem->bus.caching == ttm_write_combined) addr = ioremap_wc(mem->bus.offset, bus_size); +#ifdef CONFIG_X86
Please use #if defined (CONFIG_X86)
Actually #ifdef is usually preferred.
oops, i was referring to IS_ENABLED (CONFIG) and not if defined.
Christian.
+ else if (mem->bus.caching == ttm_cached) + addr = ioremap_cache(mem->bus.offset, bus_size); +#endif else addr = ioremap(mem->bus.offset, bus_size); if (!addr) { @@ -372,6 +376,11 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo, if (mem->bus.caching == ttm_write_combined) map->virtual = ioremap_wc(bo->mem.bus.offset + offset, size); +#ifdef CONFIG_X86 + else if (mem->bus.caching == ttm_cached) + map->virtual = ioremap_cache(bo->mem.bus.offset + offset, + size); +#endif else map->virtual = ioremap(bo->mem.bus.offset + offset, size); @@ -490,6 +499,11 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map) else if (mem->bus.caching == ttm_write_combined) vaddr_iomem = ioremap_wc(mem->bus.offset, bo->base.size); + else if (mem->bus.caching == ttm_cached) +#ifdef CONFIG_X86 + vaddr_iomem = ioremap_cache(mem->bus.offset, + bo->base.size); +#endif else vaddr_iomem = ioremap(mem->bus.offset, bo->base.size);
amd-gfx mailing list amd-gfx@lists.freedesktop.org https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free...
Am 04.03.21 um 18:40 schrieb Bhardwaj, Rajneesh:
On 3/4/2021 12:31 PM, Christian König wrote:
[CAUTION: External Email]
Am 04.03.21 um 18:01 schrieb Bhardwaj, Rajneesh:
I was wondering if a managed version of such API exists but looks like none. We only have devm_ioremap_wc but that is valid only for PAGE_CACHE_MODE_WC whereas ioremap_cache uses _WB. One more small comment below.
Acked-by: Rajneesh Bhardwaj rajneesh.bhardwaj@amd.com
On 3/4/2021 11:04 AM, Oak Zeng wrote:
If tbo.mem.bus.caching is cached, buffer is intended to be mapped as cached from CPU. Map it with ioremap_cache.
This wasn't necessary before as device memory was never mapped as cached from CPU side. It becomes necessary for aldebaran as device memory is mapped cached from CPU.
Signed-off-by: Oak Zeng Oak.Zeng@amd.com Reviewed-by: Christian Konig Christian.Koenig@amd.com
drivers/gpu/drm/ttm/ttm_bo_util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 031e581..7429464 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -91,6 +91,10 @@ static int ttm_resource_ioremap(struct ttm_device *bdev, if (mem->bus.caching == ttm_write_combined) addr = ioremap_wc(mem->bus.offset, bus_size); +#ifdef CONFIG_X86
Please use #if defined (CONFIG_X86)
Actually #ifdef is usually preferred.
oops, i was referring to IS_ENABLED (CONFIG) and not if defined.
Well, that is indeed a good idea for most config options.
But in this case #ifdef alone should work as well.
Christian.
Christian.
+ else if (mem->bus.caching == ttm_cached) + addr = ioremap_cache(mem->bus.offset, bus_size); +#endif else addr = ioremap(mem->bus.offset, bus_size); if (!addr) { @@ -372,6 +376,11 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo, if (mem->bus.caching == ttm_write_combined) map->virtual = ioremap_wc(bo->mem.bus.offset + offset, size); +#ifdef CONFIG_X86 + else if (mem->bus.caching == ttm_cached) + map->virtual = ioremap_cache(bo->mem.bus.offset + offset, + size); +#endif else map->virtual = ioremap(bo->mem.bus.offset + offset, size); @@ -490,6 +499,11 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map) else if (mem->bus.caching == ttm_write_combined) vaddr_iomem = ioremap_wc(mem->bus.offset, bo->base.size); + else if (mem->bus.caching == ttm_cached) +#ifdef CONFIG_X86 + vaddr_iomem = ioremap_cache(mem->bus.offset, + bo->base.size); +#endif else vaddr_iomem = ioremap(mem->bus.offset, bo->base.size);
amd-gfx mailing list amd-gfx@lists.freedesktop.org https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.free...
Hi Oak,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on drm-intel/for-linux-next] [also build test ERROR on drm-tip/drm-tip linus/master v5.12-rc1 next-20210304] [cannot apply to tegra-drm/drm/tegra/for-next drm-exynos/exynos-drm-next drm/drm-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/Oak-Zeng/drm-ttm-ioremap-buffer-acc... base: git://anongit.freedesktop.org/drm-intel for-linux-next config: arm-defconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 9.3.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/0day-ci/linux/commit/e89ba86e56d95eb097cacfac83b667a92acb... git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Oak-Zeng/drm-ttm-ioremap-buffer-according-to-TTM-mem-caching-setting/20210305-000626 git checkout e89ba86e56d95eb097cacfac83b667a92acbf56b # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm
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 >>):
drivers/gpu/drm/ttm/ttm_bo_util.c: In function 'ttm_bo_vmap':
drivers/gpu/drm/ttm/ttm_bo_util.c:508:3: error: expected expression before 'else'
508 | else | ^~~~
vim +/else +508 drivers/gpu/drm/ttm/ttm_bo_util.c
ba4e7d973dd09b Thomas Hellstrom 2009-06-10 485 43676605f890b2 Thomas Zimmermann 2020-11-03 486 int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map) 43676605f890b2 Thomas Zimmermann 2020-11-03 487 { 43676605f890b2 Thomas Zimmermann 2020-11-03 488 struct ttm_resource *mem = &bo->mem; 43676605f890b2 Thomas Zimmermann 2020-11-03 489 int ret; 43676605f890b2 Thomas Zimmermann 2020-11-03 490 43676605f890b2 Thomas Zimmermann 2020-11-03 491 ret = ttm_mem_io_reserve(bo->bdev, mem); 43676605f890b2 Thomas Zimmermann 2020-11-03 492 if (ret) 43676605f890b2 Thomas Zimmermann 2020-11-03 493 return ret; 43676605f890b2 Thomas Zimmermann 2020-11-03 494 43676605f890b2 Thomas Zimmermann 2020-11-03 495 if (mem->bus.is_iomem) { 43676605f890b2 Thomas Zimmermann 2020-11-03 496 void __iomem *vaddr_iomem; 43676605f890b2 Thomas Zimmermann 2020-11-03 497 43676605f890b2 Thomas Zimmermann 2020-11-03 498 if (mem->bus.addr) 43676605f890b2 Thomas Zimmermann 2020-11-03 499 vaddr_iomem = (void __iomem *)mem->bus.addr; 43676605f890b2 Thomas Zimmermann 2020-11-03 500 else if (mem->bus.caching == ttm_write_combined) e11bfb99d6ece2 Christian König 2020-12-09 501 vaddr_iomem = ioremap_wc(mem->bus.offset, e11bfb99d6ece2 Christian König 2020-12-09 502 bo->base.size); e89ba86e56d95e Oak Zeng 2021-03-04 503 else if (mem->bus.caching == ttm_cached) e89ba86e56d95e Oak Zeng 2021-03-04 504 #ifdef CONFIG_X86 e89ba86e56d95e Oak Zeng 2021-03-04 505 vaddr_iomem = ioremap_cache(mem->bus.offset, e89ba86e56d95e Oak Zeng 2021-03-04 506 bo->base.size); e89ba86e56d95e Oak Zeng 2021-03-04 507 #endif 43676605f890b2 Thomas Zimmermann 2020-11-03 @508 else e11bfb99d6ece2 Christian König 2020-12-09 509 vaddr_iomem = ioremap(mem->bus.offset, bo->base.size); 43676605f890b2 Thomas Zimmermann 2020-11-03 510 43676605f890b2 Thomas Zimmermann 2020-11-03 511 if (!vaddr_iomem) 43676605f890b2 Thomas Zimmermann 2020-11-03 512 return -ENOMEM; 43676605f890b2 Thomas Zimmermann 2020-11-03 513 43676605f890b2 Thomas Zimmermann 2020-11-03 514 dma_buf_map_set_vaddr_iomem(map, vaddr_iomem); 43676605f890b2 Thomas Zimmermann 2020-11-03 515 43676605f890b2 Thomas Zimmermann 2020-11-03 516 } else { 43676605f890b2 Thomas Zimmermann 2020-11-03 517 struct ttm_operation_ctx ctx = { 43676605f890b2 Thomas Zimmermann 2020-11-03 518 .interruptible = false, 43676605f890b2 Thomas Zimmermann 2020-11-03 519 .no_wait_gpu = false 43676605f890b2 Thomas Zimmermann 2020-11-03 520 }; 43676605f890b2 Thomas Zimmermann 2020-11-03 521 struct ttm_tt *ttm = bo->ttm; 43676605f890b2 Thomas Zimmermann 2020-11-03 522 pgprot_t prot; 43676605f890b2 Thomas Zimmermann 2020-11-03 523 void *vaddr; 43676605f890b2 Thomas Zimmermann 2020-11-03 524 43676605f890b2 Thomas Zimmermann 2020-11-03 525 ret = ttm_tt_populate(bo->bdev, ttm, &ctx); 43676605f890b2 Thomas Zimmermann 2020-11-03 526 if (ret) 43676605f890b2 Thomas Zimmermann 2020-11-03 527 return ret; 43676605f890b2 Thomas Zimmermann 2020-11-03 528 43676605f890b2 Thomas Zimmermann 2020-11-03 529 /* 43676605f890b2 Thomas Zimmermann 2020-11-03 530 * We need to use vmap to get the desired page protection 43676605f890b2 Thomas Zimmermann 2020-11-03 531 * or to make the buffer object look contiguous. 43676605f890b2 Thomas Zimmermann 2020-11-03 532 */ 43676605f890b2 Thomas Zimmermann 2020-11-03 533 prot = ttm_io_prot(bo, mem, PAGE_KERNEL); e11bfb99d6ece2 Christian König 2020-12-09 534 vaddr = vmap(ttm->pages, ttm->num_pages, 0, prot); 43676605f890b2 Thomas Zimmermann 2020-11-03 535 if (!vaddr) 43676605f890b2 Thomas Zimmermann 2020-11-03 536 return -ENOMEM; 43676605f890b2 Thomas Zimmermann 2020-11-03 537 43676605f890b2 Thomas Zimmermann 2020-11-03 538 dma_buf_map_set_vaddr(map, vaddr); 43676605f890b2 Thomas Zimmermann 2020-11-03 539 } 43676605f890b2 Thomas Zimmermann 2020-11-03 540 43676605f890b2 Thomas Zimmermann 2020-11-03 541 return 0; 43676605f890b2 Thomas Zimmermann 2020-11-03 542 } 43676605f890b2 Thomas Zimmermann 2020-11-03 543 EXPORT_SYMBOL(ttm_bo_vmap); 43676605f890b2 Thomas Zimmermann 2020-11-03 544
--- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi Oak,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on drm-intel/for-linux-next] [also build test ERROR on drm-tip/drm-tip linus/master v5.12-rc1 next-20210304] [cannot apply to tegra-drm/drm/tegra/for-next drm-exynos/exynos-drm-next drm/drm-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/Oak-Zeng/drm-ttm-ioremap-buffer-acc... base: git://anongit.freedesktop.org/drm-intel for-linux-next config: arm64-randconfig-r021-20210304 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project eec7f8f7b1226be422a76542cb403d02538f453a) 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 # install arm64 cross compiling tool for clang build # apt-get install binutils-aarch64-linux-gnu # https://github.com/0day-ci/linux/commit/e89ba86e56d95eb097cacfac83b667a92acb... git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Oak-Zeng/drm-ttm-ioremap-buffer-according-to-TTM-mem-caching-setting/20210305-000626 git checkout e89ba86e56d95eb097cacfac83b667a92acbf56b # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64
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 >>):
drivers/gpu/drm/ttm/ttm_bo_util.c:508:3: error: expected expression
else ^ 1 error generated.
vim +508 drivers/gpu/drm/ttm/ttm_bo_util.c
ba4e7d973dd09b66 Thomas Hellstrom 2009-06-10 485 43676605f890b218 Thomas Zimmermann 2020-11-03 486 int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map) 43676605f890b218 Thomas Zimmermann 2020-11-03 487 { 43676605f890b218 Thomas Zimmermann 2020-11-03 488 struct ttm_resource *mem = &bo->mem; 43676605f890b218 Thomas Zimmermann 2020-11-03 489 int ret; 43676605f890b218 Thomas Zimmermann 2020-11-03 490 43676605f890b218 Thomas Zimmermann 2020-11-03 491 ret = ttm_mem_io_reserve(bo->bdev, mem); 43676605f890b218 Thomas Zimmermann 2020-11-03 492 if (ret) 43676605f890b218 Thomas Zimmermann 2020-11-03 493 return ret; 43676605f890b218 Thomas Zimmermann 2020-11-03 494 43676605f890b218 Thomas Zimmermann 2020-11-03 495 if (mem->bus.is_iomem) { 43676605f890b218 Thomas Zimmermann 2020-11-03 496 void __iomem *vaddr_iomem; 43676605f890b218 Thomas Zimmermann 2020-11-03 497 43676605f890b218 Thomas Zimmermann 2020-11-03 498 if (mem->bus.addr) 43676605f890b218 Thomas Zimmermann 2020-11-03 499 vaddr_iomem = (void __iomem *)mem->bus.addr; 43676605f890b218 Thomas Zimmermann 2020-11-03 500 else if (mem->bus.caching == ttm_write_combined) e11bfb99d6ece23b Christian König 2020-12-09 501 vaddr_iomem = ioremap_wc(mem->bus.offset, e11bfb99d6ece23b Christian König 2020-12-09 502 bo->base.size); e89ba86e56d95eb0 Oak Zeng 2021-03-04 503 else if (mem->bus.caching == ttm_cached) e89ba86e56d95eb0 Oak Zeng 2021-03-04 504 #ifdef CONFIG_X86 e89ba86e56d95eb0 Oak Zeng 2021-03-04 505 vaddr_iomem = ioremap_cache(mem->bus.offset, e89ba86e56d95eb0 Oak Zeng 2021-03-04 506 bo->base.size); e89ba86e56d95eb0 Oak Zeng 2021-03-04 507 #endif 43676605f890b218 Thomas Zimmermann 2020-11-03 @508 else e11bfb99d6ece23b Christian König 2020-12-09 509 vaddr_iomem = ioremap(mem->bus.offset, bo->base.size); 43676605f890b218 Thomas Zimmermann 2020-11-03 510 43676605f890b218 Thomas Zimmermann 2020-11-03 511 if (!vaddr_iomem) 43676605f890b218 Thomas Zimmermann 2020-11-03 512 return -ENOMEM; 43676605f890b218 Thomas Zimmermann 2020-11-03 513 43676605f890b218 Thomas Zimmermann 2020-11-03 514 dma_buf_map_set_vaddr_iomem(map, vaddr_iomem); 43676605f890b218 Thomas Zimmermann 2020-11-03 515 43676605f890b218 Thomas Zimmermann 2020-11-03 516 } else { 43676605f890b218 Thomas Zimmermann 2020-11-03 517 struct ttm_operation_ctx ctx = { 43676605f890b218 Thomas Zimmermann 2020-11-03 518 .interruptible = false, 43676605f890b218 Thomas Zimmermann 2020-11-03 519 .no_wait_gpu = false 43676605f890b218 Thomas Zimmermann 2020-11-03 520 }; 43676605f890b218 Thomas Zimmermann 2020-11-03 521 struct ttm_tt *ttm = bo->ttm; 43676605f890b218 Thomas Zimmermann 2020-11-03 522 pgprot_t prot; 43676605f890b218 Thomas Zimmermann 2020-11-03 523 void *vaddr; 43676605f890b218 Thomas Zimmermann 2020-11-03 524 43676605f890b218 Thomas Zimmermann 2020-11-03 525 ret = ttm_tt_populate(bo->bdev, ttm, &ctx); 43676605f890b218 Thomas Zimmermann 2020-11-03 526 if (ret) 43676605f890b218 Thomas Zimmermann 2020-11-03 527 return ret; 43676605f890b218 Thomas Zimmermann 2020-11-03 528 43676605f890b218 Thomas Zimmermann 2020-11-03 529 /* 43676605f890b218 Thomas Zimmermann 2020-11-03 530 * We need to use vmap to get the desired page protection 43676605f890b218 Thomas Zimmermann 2020-11-03 531 * or to make the buffer object look contiguous. 43676605f890b218 Thomas Zimmermann 2020-11-03 532 */ 43676605f890b218 Thomas Zimmermann 2020-11-03 533 prot = ttm_io_prot(bo, mem, PAGE_KERNEL); e11bfb99d6ece23b Christian König 2020-12-09 534 vaddr = vmap(ttm->pages, ttm->num_pages, 0, prot); 43676605f890b218 Thomas Zimmermann 2020-11-03 535 if (!vaddr) 43676605f890b218 Thomas Zimmermann 2020-11-03 536 return -ENOMEM; 43676605f890b218 Thomas Zimmermann 2020-11-03 537 43676605f890b218 Thomas Zimmermann 2020-11-03 538 dma_buf_map_set_vaddr(map, vaddr); 43676605f890b218 Thomas Zimmermann 2020-11-03 539 } 43676605f890b218 Thomas Zimmermann 2020-11-03 540 43676605f890b218 Thomas Zimmermann 2020-11-03 541 return 0; 43676605f890b218 Thomas Zimmermann 2020-11-03 542 } 43676605f890b218 Thomas Zimmermann 2020-11-03 543 EXPORT_SYMBOL(ttm_bo_vmap); 43676605f890b218 Thomas Zimmermann 2020-11-03 544
--- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
dri-devel@lists.freedesktop.org