[PATCH] drm/ttm: ioremap buffer according to TTM mem caching setting

Zeng, Oak Oak.Zeng at amd.com
Tue Mar 2 22:45:15 UTC 2021


[AMD Official Use Only - Internal Distribution Only]

Hi Daniel, Thomas, Dan,

Does below message mean the calling ioremap_cache failed intel's driver build? I can see both ioremap_cache and ioremap_wc are defined in arch/x86/mm/ioremap.c - why ioremap_wc doesn't break intel driver's build?

Are we supposed to use memremap (offset, size, MEMREMAP_WB) to replace ioremap_cache? When I read here https://lwn.net/Articles/653585/ I felt that ioremap_cache returns an address annotated with _iomem while memremap returns an address without __iomem annotation. In our use case, GPU memory is treated as UEFI SPM (specific purpose memory). I am not very sure whether memremap (thus no __iomem annotation) is the right thing to do. What I am sure is, we have tested ioremap_cache and it works fine on AMD system.

I will send out a test patch replacing ioremap_cache with ioremap_wc, to trigger Intel build robot to see whether it fails Intel build. I suppose it will not fail Intel build.

Regards,
Oak

From: Christian König <ckoenig.leichtzumerken at gmail.com>
Sent: Tuesday, March 2, 2021 6:31 AM
To: amd-gfx at lists.freedesktop.org; dri-devel at lists.freedesktop.org; Daniel Vetter <daniel at ffwll.ch>; Dave Airlie <airlied at redhat.com>; Thomas Hellström (Intel) <thomas_os at shipmail.org>
Cc: Zeng, Oak <Oak.Zeng at amd.com>; kbuild-all at lists.01.org; Kuehling, Felix <Felix.Kuehling at amd.com>; Kasiviswanathan, Harish <Harish.Kasiviswanathan at amd.com>; Deucher, Alexander <Alexander.Deucher at amd.com>; Huang, JinHuiEric <JinHuiEric.Huang at amd.com>; Koenig, Christian <Christian.Koenig at amd.com>
Subject: Re: [PATCH] drm/ttm: ioremap buffer according to TTM mem caching setting

Hi guys,

adding the usual suspects direct. Does anybody of hand know how to check if an architecture supports ioremap_cache()?

For now we only need this on X86, but I would feel better if we don't use an #ifdef here.

Regards,
Christian.
Am 02.03.21 um 05:12 schrieb kernel test robot:

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-20210302]

[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<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit-scm.com%2Fdocs%2Fgit-format-patch&data=04%7C01%7COak.Zeng%40amd.com%7C08f51e87e36c4de858bc08d8dd6eb16b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637502814793168696%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=p4iynMPvZGknfSGSyZnXV3kLwScMLbPDB8zVsmxhtk0%3D&reserved=0>]



url:    https://github.com/0day-ci/linux/commits/Oak-Zeng/drm-ttm-ioremap-buffer-according-to-TTM-mem-caching-setting/20210302-064500<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2F0day-ci%2Flinux%2Fcommits%2FOak-Zeng%2Fdrm-ttm-ioremap-buffer-according-to-TTM-mem-caching-setting%2F20210302-064500&data=04%7C01%7COak.Zeng%40amd.com%7C08f51e87e36c4de858bc08d8dd6eb16b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637502814793178689%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=2sc4jZR3bVRF0xDDqNOtUcNR9qiJMF2ATmCDAX%2BSWrQ%3D&reserved=0>

base:   git://anongit.freedesktop.org/drm-intel for-linux-next

config: parisc-randconfig-r012-20210302 (attached as .config)

compiler: hppa-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):

        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fraw.githubusercontent.com%2Fintel%2Flkp-tests%2Fmaster%2Fsbin%2Fmake.cross&data=04%7C01%7COak.Zeng%40amd.com%7C08f51e87e36c4de858bc08d8dd6eb16b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637502814793178689%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=uILcLE%2F24bhSU%2Bo5GmWGAK6s6xDFivP6lrm6JgtM50Y%3D&reserved=0> -O ~/bin/make.cross

        chmod +x ~/bin/make.cross

        # https://github.com/0day-ci/linux/commit/225bb3711439ec559dd72ae5af8e62d34ea60a64<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2F0day-ci%2Flinux%2Fcommit%2F225bb3711439ec559dd72ae5af8e62d34ea60a64&data=04%7C01%7COak.Zeng%40amd.com%7C08f51e87e36c4de858bc08d8dd6eb16b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637502814793188685%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=2TOSPuKEMRcZjMfxO9lxgwFxgXwHqERCOgRednI7OE8%3D&reserved=0>

        git remote add linux-review https://github.com/0day-ci/linux<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2F0day-ci%2Flinux&data=04%7C01%7COak.Zeng%40amd.com%7C08f51e87e36c4de858bc08d8dd6eb16b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637502814793188685%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=TlXvs5mxH0RV9qQFaUF2B1LZisTWbnt4hfFd2OC7gGw%3D&reserved=0>

        git fetch --no-tags linux-review Oak-Zeng/drm-ttm-ioremap-buffer-according-to-TTM-mem-caching-setting/20210302-064500

        git checkout 225bb3711439ec559dd72ae5af8e62d34ea60a64

        # save the attached .config to linux build tree

        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=parisc



If you fix the issue, kindly add following tag as appropriate

Reported-by: kernel test robot <lkp at intel.com><mailto:lkp at intel.com>



All errors (new ones prefixed by >>):



   drivers/gpu/drm/ttm/ttm_bo_util.c: In function 'ttm_resource_ioremap':

drivers/gpu/drm/ttm/ttm_bo_util.c:95:11: error: implicit declaration of function 'ioremap_cache'; did you mean 'ioremap_uc'? [-Werror=implicit-function-declaration]

      95 |    addr = ioremap_cache(mem->bus.offset, bus_size);

         |           ^~~~~~~~~~~~~

         |           ioremap_uc

   drivers/gpu/drm/ttm/ttm_bo_util.c:95:9: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]

      95 |    addr = ioremap_cache(mem->bus.offset, bus_size);

         |         ^

   drivers/gpu/drm/ttm/ttm_bo_util.c: In function 'ttm_bo_ioremap':

   drivers/gpu/drm/ttm/ttm_bo_util.c:379:17: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]

     379 |    map->virtual = ioremap_cache(bo->mem.bus.offset + offset,

         |                 ^

   drivers/gpu/drm/ttm/ttm_bo_util.c: In function 'ttm_bo_vmap':

   drivers/gpu/drm/ttm/ttm_bo_util.c:500:16: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]

     500 |    vaddr_iomem = ioremap_cache(mem->bus.offset,

         |                ^

   cc1: some warnings being treated as errors





vim +95 drivers/gpu/drm/ttm/ttm_bo_util.c



    74

    75  static int ttm_resource_ioremap(struct ttm_bo_device *bdev,

    76                                struct ttm_resource *mem,

    77                                void **virtual)

    78  {

    79          int ret;

    80          void *addr;

    81

    82          *virtual = NULL;

    83          ret = ttm_mem_io_reserve(bdev, mem);

    84          if (ret || !mem->bus.is_iomem)

    85                  return ret;

    86

    87          if (mem->bus.addr) {

    88                  addr = mem->bus.addr;

    89          } else {

    90                  size_t bus_size = (size_t)mem->num_pages << PAGE_SHIFT;

    91

    92                  if (mem->bus.caching == ttm_write_combined)

    93                         addr = ioremap_wc(mem->bus.offset, bus_size);

    94                  else if (mem->bus.caching == ttm_cached)

  > 95                         addr = ioremap_cache(mem->bus.offset, bus_size);

    96                  else

    97                         addr = ioremap(mem->bus.offset, bus_size);

    98                  if (!addr) {

    99                         ttm_mem_io_free(bdev, mem);

   100                         return -ENOMEM;

   101                  }

   102          }

   103          *virtual = addr;

   104          return 0;

   105  }

   106



---

0-DAY CI Kernel Test Service, Intel Corporation

https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.01.org%2Fhyperkitty%2Flist%2Fkbuild-all%40lists.01.org&data=04%7C01%7COak.Zeng%40amd.com%7C08f51e87e36c4de858bc08d8dd6eb16b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637502814793198680%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=8vaxBMiRPv5mgZyKjDnsNtzAz%2BDltnzlkUMDMg45%2BrI%3D&reserved=0>



_______________________________________________

amd-gfx mailing list

amd-gfx at lists.freedesktop.org<mailto:amd-gfx at lists.freedesktop.org>

https://lists.freedesktop.org/mailman/listinfo/amd-gfx<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7COak.Zeng%40amd.com%7C08f51e87e36c4de858bc08d8dd6eb16b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637502814793198680%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=eRpwM7V33brBQtOxnkAfPTlp383tcA1x55zPPw1W0gA%3D&reserved=0>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20210302/f89d118d/attachment-0001.htm>


More information about the amd-gfx mailing list