drm/i915: Set I915_BO_ALLOC_USER for framebuffer
Subsystems (3)
PATCH 1/3 drm/i915: Set I915_BO_ALLOC_USER for framebuffer
Framebuffer is exposed to userspace so set I915_BO_ALLOC_USER flag for it. This also make sure that ttm allocates offset for lmem objects.
--- drivers/gpu/drm/i915/display/intel_dpt.c | 4 +++- drivers/gpu/drm/i915/display/intel_fbdev.c | 3 ++- drivers/gpu/drm/i915/display/intel_plane_initial.c | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_dpt.c +3 -1
@@ -254,7 +254,9 @@ intel_dpt_create(struct intel_framebuffer *fb) size =round_up (size *sizeof (gen8_pte_t),I915_GTT_PAGE_SIZE ); - dpt_obj =i915_gem_object_create_lmem (i915, size,I915_BO_ALLOC_CONTIGUOUS ); + dpt_obj =i915_gem_object_create_lmem (i915, size, +I915_BO_ALLOC_CONTIGUOUS | +I915_BO_ALLOC_USER );if (IS_ERR (dpt_obj) &&i915_ggtt_has_aperture (to_gt (i915)->ggtt)) dpt_obj =i915_gem_object_create_stolen (i915, size);if (IS_ERR (dpt_obj) && !HAS_LMEM (i915)) {
drivers/gpu/drm/i915/display/intel_fbdev.c +2 -1
@@ -163,7 +163,8 @@ static int intelfb_alloc(struct drm_fb_helper *helper, obj =ERR_PTR (-ENODEV );if (HAS_LMEM (dev_priv)) { obj =i915_gem_object_create_lmem (dev_priv, size, -I915_BO_ALLOC_CONTIGUOUS ); +I915_BO_ALLOC_CONTIGUOUS | +I915_BO_ALLOC_USER ); }else {/* * If the FB is too big, just don't use it since fbdev is not very
drivers/gpu/drm/i915/display/intel_plane_initial.c +2 -1
@@ -110,7 +110,8 @@ initial_plane_vma(struct drm_i915_private *i915, size * 2 > i915->dsm.usable_size)return NULL ; - obj =i915_gem_object_create_region_at (mem, phys_base, size,0 ); + obj =i915_gem_object_create_region_at (mem, phys_base, size, +I915_BO_ALLOC_USER );if (IS_ERR (obj))return NULL ;
Signature · 1 line
2.39.0
PATCH 2/3 drm/i915: Add a helper func for gem obj mmap
Move gem obj mmap code to i915_gem_object_mmap() so that this can be used by others.
--- drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 20 ++--------------- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 25 ++++++++++++++++++++++ drivers/gpu/drm/i915/gem/i915_gem_mman.h | 1 + 3 files changed, 28 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c +2 -18
@@ -12,6 +12,7 @@#include <asm/smp.h> #include "gem/i915_gem_dmabuf.h" +#include "gem/i915_gem_mman.h" #include "i915_drv.h" #include "i915_gem_object.h" #include "i915_scatterlist.h"
@@ -94,27 +95,10 @@ static void i915_gem_dmabuf_vunmap(struct dma_buf *dma_buf,static int i915_gem_dmabuf_mmap (struct dma_buf *dma_buf,struct vm_area_struct *vma) {struct drm_i915_gem_object *obj =dma_buf_to_obj (dma_buf); -struct drm_i915_private *i915 =to_i915 (obj->base.dev); -int ret;dma_resv_assert_held (dma_buf->resv); -if (obj->base.size < vma->vm_end - vma->vm_start) -return -EINVAL ; - -if (HAS_LMEM (i915)) -return drm_gem_prime_mmap (&obj->base, vma); - -if (!obj->base.filp) -return -ENODEV ; - - ret =call_mmap (obj->base.filp, vma); -if (ret) -return ret; - -vma_set_file (vma, obj->base.filp); - -return 0 ; +return i915_gem_object_mmap (obj, vma); }static int i915_gem_begin_cpu_access (struct dma_buf *dma_buf,enum dma_data_direction direction)
drivers/gpu/drm/i915/gem/i915_gem_mman.c +25 -0
@@ -11,6 +11,8 @@#include <drm/drm_cache.h> +#include "gem/i915_gem_lmem.h" +#include "gt/intel_gt.h" #include "gt/intel_gt_requests.h"
@@ -1043,6 +1045,29 @@ int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma)return 0 ; } +int i915_gem_object_mmap (struct drm_i915_gem_object *obj,struct vm_area_struct *vma) +{ +struct drm_i915_private *i915 =to_i915 (obj->base.dev); +int ret; + +if (obj->base.size < vma->vm_end - vma->vm_start) +return -EINVAL ; + +if (HAS_LMEM (i915)) +return drm_gem_prime_mmap (&obj->base, vma); + +if (obj->base.filp) { + ret =call_mmap (obj->base.filp, vma); +if (ret) +return ret; + +vma_set_file (vma, obj->base.filp); +return 0 ; + } + +return -ENODEV ; +} +#if IS_ENABLED (CONFIG_DRM_I915_SELFTEST )#include "selftests/i915_gem_mman.c" #endif
drivers/gpu/drm/i915/gem/i915_gem_mman.h +1 -0
@@ -30,4 +30,5 @@ void i915_gem_object_release_mmap_gtt(struct drm_i915_gem_object *obj);void i915_gem_object_runtime_pm_release_mmap_offset (struct drm_i915_gem_object *obj);void i915_gem_object_release_mmap_offset (struct drm_i915_gem_object *obj); +int i915_gem_object_mmap (struct drm_i915_gem_object *obj,struct vm_area_struct *vma);#endif
Signature · 1 line
2.39.0
Re: [PATCH 2/3] drm/i915: Add a helper func for gem obj mmap
Quoted 68 lines · Nirmoy Das
Move gem obj mmap code to
i915_gem_object_mmap()so that this can be used by others.Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 20 ++--------------- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 25 ++++++++++++++++++++++ drivers/gpu/drm/i915/gem/i915_gem_mman.h | 1 + 3 files changed, 28 insertions(+), 18 deletions(-)drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c +2
-18@@ -12,6 +12,7 @@#include <asm/smp.h> #include "gem/i915_gem_dmabuf.h" +#include "gem/i915_gem_mman.h" #include "i915_drv.h" #include "i915_gem_object.h" #include "i915_scatterlist.h" @@ -94,27 +95,10 @@ static void i915_gem_dmabuf_vunmap(struct dma_buf *dma_buf,static int i915_gem_dmabuf_mmap (struct dma_buf *dma_buf,struct vm_area_struct *vma) {struct drm_i915_gem_object *obj =dma_buf_to_obj (dma_buf); -struct drm_i915_private *i915 =to_i915 (obj->base.dev); -int ret;dma_resv_assert_held (dma_buf->resv); -if (obj->base.size < vma->vm_end - vma->vm_start) -return -EINVAL ; - -if (HAS_LMEM (i915)) -return drm_gem_prime_mmap (&obj->base, vma); - -if (!obj->base.filp) -return -ENODEV ; - - ret =call_mmap (obj->base.filp, vma); -if (ret) -return ret; - -vma_set_file (vma, obj->base.filp); - -return 0 ; +return i915_gem_object_mmap (obj, vma); }static int i915_gem_begin_cpu_access (struct dma_buf *dma_buf,enum dma_data_direction direction)drivers/gpu/drm/i915/gem/i915_gem_mman.c +2
-0@@ -11,6 +11,8 @@#include <drm/drm_cache.h> +#include "gem/i915_gem_lmem.h" +#include "gt/intel_gt.h" #include "gt/intel_gt_requests.h" @@ -1043,6 +1045,29 @@ int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma)return 0 ; }
drivers/gpu/drm/i915/gem/i915_gem_mman.c int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma) · line 1057
Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +10
-0+int i915_gem_object_mmap (struct drm_i915_gem_object *obj,struct vm_area_struct *vma) +{ +struct drm_i915_private *i915 =to_i915 (obj->base.dev); +int ret; + +if (obj->base.size < vma->vm_end - vma->vm_start) +return -EINVAL ; + +if (HAS_LMEM (i915)) +return drm_gem_prime_mmap (&obj->base, vma);
Calling some prime stuff here doesn't smell right.
Quoted 28 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +13
-0+ +if (obj->base.filp) { + ret =call_mmap (obj->base.filp, vma); +if (ret) +return ret; + +vma_set_file (vma, obj->base.filp); +return 0 ; + } + +return -ENODEV ; +} +#if IS_ENABLED (CONFIG_DRM_I915_SELFTEST )#include "selftests/i915_gem_mman.c" #endif drivers/gpu/drm/i915/gem/i915_gem_mman.h +1
-0@@ -30,4 +30,5 @@ void i915_gem_object_release_mmap_gtt(struct drm_i915_gem_object *obj);void i915_gem_object_runtime_pm_release_mmap_offset (struct drm_i915_gem_object *obj);void i915_gem_object_release_mmap_offset (struct drm_i915_gem_object *obj); +int i915_gem_object_mmap (struct drm_i915_gem_object *obj,struct vm_area_struct *vma);#endif Signature · 1 line
2.39.0
Signature · 2 lines
Ville Syrjälä Intel
Re: [PATCH 2/3] drm/i915: Add a helper func for gem obj mmap
Quoted 69 lines · Ville Syrjälä
Quoted 68 lines · Nirmoy Das
Move gem obj mmap code to
i915_gem_object_mmap()so that this can be used by others.Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 20 ++--------------- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 25 ++++++++++++++++++++++ drivers/gpu/drm/i915/gem/i915_gem_mman.h | 1 + 3 files changed, 28 insertions(+), 18 deletions(-)drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c +2
-18@@ -12,6 +12,7 @@#include <asm/smp.h> #include "gem/i915_gem_dmabuf.h" +#include "gem/i915_gem_mman.h" #include "i915_drv.h" #include "i915_gem_object.h" #include "i915_scatterlist.h" @@ -94,27 +95,10 @@ static void i915_gem_dmabuf_vunmap(struct dma_buf *dma_buf,static int i915_gem_dmabuf_mmap (struct dma_buf *dma_buf,struct vm_area_struct *vma) {struct drm_i915_gem_object *obj =dma_buf_to_obj (dma_buf); -struct drm_i915_private *i915 =to_i915 (obj->base.dev); -int ret;dma_resv_assert_held (dma_buf->resv); -if (obj->base.size < vma->vm_end - vma->vm_start) -return -EINVAL ; - -if (HAS_LMEM (i915)) -return drm_gem_prime_mmap (&obj->base, vma); - -if (!obj->base.filp) -return -ENODEV ; - - ret =call_mmap (obj->base.filp, vma); -if (ret) -return ret; - -vma_set_file (vma, obj->base.filp); - -return 0 ; +return i915_gem_object_mmap (obj, vma); }static int i915_gem_begin_cpu_access (struct dma_buf *dma_buf,enum dma_data_direction direction)drivers/gpu/drm/i915/gem/i915_gem_mman.c +2
-0@@ -11,6 +11,8 @@#include <drm/drm_cache.h> +#include "gem/i915_gem_lmem.h" +#include "gt/intel_gt.h" #include "gt/intel_gt_requests.h" @@ -1043,6 +1045,29 @@ int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma)return 0 ; }
Quoted 11 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma) · line 1057
Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +10
-0+int i915_gem_object_mmap (struct drm_i915_gem_object *obj,struct vm_area_struct *vma) +{ +struct drm_i915_private *i915 =to_i915 (obj->base.dev); +int ret; + +if (obj->base.size < vma->vm_end - vma->vm_start) +return -EINVAL ; + +if (HAS_LMEM (i915)) +return drm_gem_prime_mmap (&obj->base, vma);Calling some prime stuff here doesn't smell right.
Yes, I should use drm_gem_mmap_obj() here.
Quoted 29 lines
Quoted 29 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +13
-0+ +if (obj->base.filp) { + ret =call_mmap (obj->base.filp, vma); +if (ret) +return ret; + +vma_set_file (vma, obj->base.filp); +return 0 ; + } + +return -ENODEV ; +} +#if IS_ENABLED (CONFIG_DRM_I915_SELFTEST )#include "selftests/i915_gem_mman.c" #endif drivers/gpu/drm/i915/gem/i915_gem_mman.h +1
-0@@ -30,4 +30,5 @@ void i915_gem_object_release_mmap_gtt(struct drm_i915_gem_object *obj);void i915_gem_object_runtime_pm_release_mmap_offset (struct drm_i915_gem_object *obj);void i915_gem_object_release_mmap_offset (struct drm_i915_gem_object *obj); +int i915_gem_object_mmap (struct drm_i915_gem_object *obj,struct vm_area_struct *vma);#endif Signature · 1 line
2.39.0
RFC PATCH 3/3 drm/i915/display: Implement fb_mmap callback function
In reply to Nirmoy DasIf stolen memory allocation fails for fbdev, the driver will fallback to system memory. Calculation of smem_start is wrong for such framebuffer objs if the platform comes with no gmadr or no aperture. Solve this by adding fb_mmap callback which also gives driver more control.
--- drivers/gpu/drm/i915/display/intel_fbdev.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpu/drm/i915/display/intel_fbdev.c +20 -0
@@ -40,8 +40,10 @@#include <drm/drm_crtc.h> #include <drm/drm_fb_helper.h> #include <drm/drm_fourcc.h> +#include <drm/drm_gem_framebuffer_helper.h> #include "gem/i915_gem_lmem.h" +#include "gem/i915_gem_mman.h" #include "i915_drv.h" #include "intel_display_types.h"
@@ -120,6 +122,23 @@ static int intel_fbdev_pan_display(struct fb_var_screeninfo *var,return ret; } +#define to_intel_fbdev (x) container_of(x, struct intel_fbdev, helper) +static int intel_fbdev_mmap (struct fb_info *info,struct vm_area_struct *vma) +{ +struct intel_fbdev *fbdev =to_intel_fbdev (info->par); +struct drm_gem_object *bo =drm_gem_fb_get_obj (&fbdev->fb->base,0 ); +struct drm_i915_gem_object *obj =to_intel_bo (bo); +struct drm_device *dev = fbdev->helper.dev; + + vma->vm_page_prot = +pgprot_writecombine (vm_get_page_prot (vma->vm_flags)); + +if (obj->stolen) +return vm_iomap_memory (vma, info->fix.smem_start, + info->fix.smem_len); + +return i915_gem_object_mmap (obj, vma); +}static const struct fb_ops intelfb_ops = { .owner =THIS_MODULE ,DRM_FB_HELPER_DEFAULT_OPS ,
@@ -131,6 +150,7 @@ static const struct fb_ops intelfb_ops = { .fb_imageblit = drm_fb_helper_cfb_imageblit, .fb_pan_display = intel_fbdev_pan_display, .fb_blank = intel_fbdev_blank, + .fb_mmap = intel_fbdev_mmap, }; static int intelfb_alloc(struct drm_fb_helper *helper,
Signature · 1 line
2.39.0
kernel test robot
build botRe: [PATCH RFC 3/3] drm/i915/display: Implement fb_mmap callback function
reproduce (this is a W=1 build):
Hi Nirmoy,
[FYI, it's a private test report for your RFC patch.] [auto build test ERROR on drm-tip/drm-tip]
url: https://github.com/intel-lab-lkp/linux/commits/Nirmoy-Das/drm-i915-Add-a-helper-func-for-gem-obj-mmap/20230306-183112 base: git://anongit.freedesktop.org/drm/drm-tip drm-tip patch link: https://lore.kernel.org/r/20230306102850.18299-3-nirmoy.das%40intel.com patch subject: [PATCH RFC 3/3] drm/i915/display: Implement fb_mmap callback function config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20230306/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/2c504ed19ce4930ccadb2e9060cc79056969c599 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Nirmoy-Das/drm-i915-Add-a-helper-func-for-gem-obj-mmap/20230306-183112 git checkout 2c504ed19ce4930ccadb2e9060cc79056969c599 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 olddefconfig make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/drm/i915/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/gpu/drm/i915/display/intel_fbdev.c: In function 'intel_fbdev_mmap':
>> drivers/gpu/drm/i915/display/intel_fbdev.c:131:28: error: unused variable 'dev' [-Werror=unused-variable]
131 | struct drm_device *dev = fbdev->helper.dev;
| ^~~cc1: all warnings being treated as errors
vim +/dev +131 drivers/gpu/drm/i915/display/intel_fbdev.c
124
125 #define to_intel_fbdev(x) container_of(x, struct intel_fbdev, helper)
126 static int intel_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma)
127 {
128 struct intel_fbdev *fbdev = to_intel_fbdev(info->par);
129 struct drm_gem_object *bo = drm_gem_fb_get_obj(&fbdev->fb->base, 0);
130 struct drm_i915_gem_object *obj = to_intel_bo(bo);
> 131 struct drm_device *dev = fbdev->helper.dev;
132
133 vma->vm_page_prot =
134 pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
135
136 if (obj->stolen)
137 return vm_iomap_memory(vma, info->fix.smem_start,
138 info->fix.smem_len);
139
140 return i915_gem_object_mmap(obj, vma);
141 }
142 static const struct fb_ops intelfb_ops = {
143 .owner = THIS_MODULE,
144 DRM_FB_HELPER_DEFAULT_OPS,
145 .fb_set_par = intel_fbdev_set_par,
146 .fb_read = drm_fb_helper_cfb_read,
147 .fb_write = drm_fb_helper_cfb_write,
148 .fb_fillrect = drm_fb_helper_cfb_fillrect,
149 .fb_copyarea = drm_fb_helper_cfb_copyarea,
150 .fb_imageblit = drm_fb_helper_cfb_imageblit,
151 .fb_pan_display = intel_fbdev_pan_display,
152 .fb_blank = intel_fbdev_blank,
153 .fb_mmap = intel_fbdev_mmap,
154 };
155
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botRe: [PATCH RFC 3/3] drm/i915/display: Implement fb_mmap callback function
In reply to Nirmoy Dasreproduce (this is a W=1 build):
Hi Nirmoy,
[FYI, it's a private test report for your RFC patch.] [auto build test WARNING on drm-tip/drm-tip]
url: https://github.com/intel-lab-lkp/linux/commits/Nirmoy-Das/drm-i915-Add-a-helper-func-for-gem-obj-mmap/20230306-183112 base: git://anongit.freedesktop.org/drm/drm-tip drm-tip patch link: https://lore.kernel.org/r/20230306102850.18299-3-nirmoy.das%40intel.com patch subject: [PATCH RFC 3/3] drm/i915/display: Implement fb_mmap callback function config: x86_64-rhel-8.3 (https://download.01.org/0day-ci/archive/20230306/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/2c504ed19ce4930ccadb2e9060cc79056969c599 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Nirmoy-Das/drm-i915-Add-a-helper-func-for-gem-obj-mmap/20230306-183112 git checkout 2c504ed19ce4930ccadb2e9060cc79056969c599 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 olddefconfig make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/gpu/drm/i915/display/intel_fbdev.c: In function 'intel_fbdev_mmap':
>> drivers/gpu/drm/i915/display/intel_fbdev.c:131:28: warning: unused variable 'dev' [-Wunused-variable]
131 | struct drm_device *dev = fbdev->helper.dev;
| ^~~vim +/dev +131 drivers/gpu/drm/i915/display/intel_fbdev.c
124
125 #define to_intel_fbdev(x) container_of(x, struct intel_fbdev, helper)
126 static int intel_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma)
127 {
128 struct intel_fbdev *fbdev = to_intel_fbdev(info->par);
129 struct drm_gem_object *bo = drm_gem_fb_get_obj(&fbdev->fb->base, 0);
130 struct drm_i915_gem_object *obj = to_intel_bo(bo);
> 131 struct drm_device *dev = fbdev->helper.dev;
132
133 vma->vm_page_prot =
134 pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
135
136 if (obj->stolen)
137 return vm_iomap_memory(vma, info->fix.smem_start,
138 info->fix.smem_len);
139
140 return i915_gem_object_mmap(obj, vma);
141 }
142 static const struct fb_ops intelfb_ops = {
143 .owner = THIS_MODULE,
144 DRM_FB_HELPER_DEFAULT_OPS,
145 .fb_set_par = intel_fbdev_set_par,
146 .fb_read = drm_fb_helper_cfb_read,
147 .fb_write = drm_fb_helper_cfb_write,
148 .fb_fillrect = drm_fb_helper_cfb_fillrect,
149 .fb_copyarea = drm_fb_helper_cfb_copyarea,
150 .fb_imageblit = drm_fb_helper_cfb_imageblit,
151 .fb_pan_display = intel_fbdev_pan_display,
152 .fb_blank = intel_fbdev_blank,
153 .fb_mmap = intel_fbdev_mmap,
154 };
155
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Re: [PATCH RFC 3/3] drm/i915/display: Implement fb_mmap callback function
In reply to Nirmoy DasQuoted 27 lines · Nirmoy Das
If stolen memory allocation fails for fbdev, the driver will fallback to system memory. Calculation of
smem_startis wrong for such framebuffer objs if the platform comes with no gmadr or no aperture. Solve this by addingfb_mmapcallback which also gives driver more control.Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/i915/display/intel_fbdev.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/gpu/drm/i915/display/intel_fbdev.c +2
-0@@ -40,8 +40,10 @@#include <drm/drm_crtc.h> #include <drm/drm_fb_helper.h> #include <drm/drm_fourcc.h> +#include <drm/drm_gem_framebuffer_helper.h> #include "gem/i915_gem_lmem.h" +#include "gem/i915_gem_mman.h" #include "i915_drv.h" #include "intel_display_types.h"
drivers/gpu/drm/i915/display/intel_fbdev.c static int intel_fbdev_pan_display(struct fb_var_screeninfo *var, · line 131
Quoted 10 lines
drivers/gpu/drm/i915/display/intel_fbdev.c +7
-0@@ -120,6 +122,23 @@ static int intel_fbdev_pan_display(struct fb_var_screeninfo *var,return ret; } +#define to_intel_fbdev (x) container_of(x, struct intel_fbdev, helper) +static int intel_fbdev_mmap (struct fb_info *info,struct vm_area_struct *vma) +{ +struct intel_fbdev *fbdev =to_intel_fbdev (info->par); +struct drm_gem_object *bo =drm_gem_fb_get_obj (&fbdev->fb->base,0 ); +struct drm_i915_gem_object *obj =to_intel_bo (bo); +struct drm_device *dev = fbdev->helper.dev;
You seem to be missing the fb vs. mmio handling here entirely.
drivers/gpu/drm/i915/display/intel_fbdev.c static int intel_fbdev_pan_display(struct fb_var_screeninfo *var, · line 134
Quoted 3 lines
drivers/gpu/drm/i915/display/intel_fbdev.c +3
-0+ + vma->vm_page_prot = +pgprot_writecombine (vm_get_page_prot (vma->vm_flags));
Does that do something sane on eg. !PAT?
drivers/gpu/drm/i915/display/intel_fbdev.c static int intel_fbdev_pan_display(struct fb_var_screeninfo *var, · line 138
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_fbdev.c +4
-0+ +if (obj->stolen) +return vm_iomap_memory (vma, info->fix.smem_start, + info->fix.smem_len);
Why doesn't i915_gem_object_mmap() know how to handle stolen?
Quoted 16 lines
drivers/gpu/drm/i915/display/intel_fbdev.c +4
-0+ +return i915_gem_object_mmap (obj, vma); +}static const struct fb_ops intelfb_ops = { .owner =THIS_MODULE ,DRM_FB_HELPER_DEFAULT_OPS ,@@ -131,6 +150,7 @@ static const struct fb_ops intelfb_ops = { .fb_imageblit = drm_fb_helper_cfb_imageblit, .fb_pan_display = intel_fbdev_pan_display, .fb_blank = intel_fbdev_blank, + .fb_mmap = intel_fbdev_mmap, }; static int intelfb_alloc(struct drm_fb_helper *helper,Signature · 1 line
2.39.0
Signature · 2 lines
Ville Syrjälä Intel
Re: [PATCH RFC 3/3] drm/i915/display: Implement fb_mmap callback function
Hi Ville,
Quoted 31 lines · Ville Syrjälä
Quoted 30 lines · Nirmoy Das
If stolen memory allocation fails for fbdev, the driver will fallback to system memory. Calculation of
smem_startis wrong for such framebuffer objs if the platform comes with no gmadr or no aperture. Solve this by addingfb_mmapcallback which also gives driver more control.Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/i915/display/intel_fbdev.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/gpu/drm/i915/display/intel_fbdev.c +2
-0@@ -40,8 +40,10 @@#include <drm/drm_crtc.h> #include <drm/drm_fb_helper.h> #include <drm/drm_fourcc.h> +#include <drm/drm_gem_framebuffer_helper.h> #include "gem/i915_gem_lmem.h" +#include "gem/i915_gem_mman.h" #include "i915_drv.h" #include "intel_display_types.h" @@ -120,6 +122,23 @@ static int intel_fbdev_pan_display(struct fb_var_screeninfo *var,return ret; }
Quoted 8 lines
drivers/gpu/drm/i915/display/intel_fbdev.c static int intel_fbdev_pan_display(struct fb_var_screeninfo *var, · line 131
Quoted 7 lines
drivers/gpu/drm/i915/display/intel_fbdev.c +7
-0+#define to_intel_fbdev (x) container_of(x, struct intel_fbdev, helper) +static int intel_fbdev_mmap (struct fb_info *info,struct vm_area_struct *vma) +{ +struct intel_fbdev *fbdev =to_intel_fbdev (info->par); +struct drm_gem_object *bo =drm_gem_fb_get_obj (&fbdev->fb->base,0 ); +struct drm_i915_gem_object *obj =to_intel_bo (bo); +struct drm_device *dev = fbdev->helper.dev;You seem to be missing the fb vs. mmio handling here entirely.
Could you please expand this more, I am not so familiar to fbdev code.
Quoted 11 lines
drivers/gpu/drm/i915/display/intel_fbdev.c static int intel_fbdev_pan_display(struct fb_var_screeninfo *var, · line 134
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_fbdev.c +3
-0+ + vma->vm_page_prot = +pgprot_writecombine (vm_get_page_prot (vma->vm_flags));Does that do something sane on eg. !PAT?
drivers/gpu/drm/i915/display/intel_fbdev.c static int intel_fbdev_pan_display(struct fb_var_screeninfo *var, · line 138
Quoted 4 lines
drivers/gpu/drm/i915/display/intel_fbdev.c +4
-0+ +if (obj->stolen) +return vm_iomap_memory (vma, info->fix.smem_start, + info->fix.smem_len);Why doesn't
i915_gem_object_mmap()know how to handle stolen?
Sent out another rfc series to address this.
Regards,
Nirmoy
Quoted 17 lines
Quoted 17 lines
drivers/gpu/drm/i915/display/intel_fbdev.c +4
-0+ +return i915_gem_object_mmap (obj, vma); +}static const struct fb_ops intelfb_ops = { .owner =THIS_MODULE ,DRM_FB_HELPER_DEFAULT_OPS ,@@ -131,6 +150,7 @@ static const struct fb_ops intelfb_ops = { .fb_imageblit = drm_fb_helper_cfb_imageblit, .fb_pan_display = intel_fbdev_pan_display, .fb_blank = intel_fbdev_blank, + .fb_mmap = intel_fbdev_mmap, }; static int intelfb_alloc(struct drm_fb_helper *helper,Signature · 1 line
2.39.0
kernel test robot
build botRe: [PATCH RFC 3/3] drm/i915/display: Implement fb_mmap callback function
In reply to Nirmoy Dasreproduce (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 #…
Hi Nirmoy,
[FYI, it's a private test report for your RFC patch.] [auto build test WARNING on drm-tip/drm-tip]
url: https://github.com/intel-lab-lkp/linux/commits/Nirmoy-Das/drm-i915-Add-a-helper-func-for-gem-obj-mmap/20230306-183112 base: git://anongit.freedesktop.org/drm/drm-tip drm-tip patch link: https://lore.kernel.org/r/20230306102850.18299-3-nirmoy.das%40intel.com patch subject: [PATCH RFC 3/3] drm/i915/display: Implement fb_mmap callback function config: i386-randconfig-a012-20230306 (https://download.01.org/0day-ci/archive/20230307/[email protected]/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
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/2c504ed19ce4930ccadb2e9060cc79056969c599
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Nirmoy-Das/drm-i915-Add-a-helper-func-for-gem-obj-mmap/20230306-183112 git checkout 2c504ed19ce4930ccadb2e9060cc79056969c599
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/gpu/drm/i915/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/gpu/drm/i915/display/intel_fbdev.c:131:21: warning: unused variable 'dev' [-Wunused-variable]
struct drm_device *dev = fbdev->helper.dev;
^1 warning generated.
vim +/dev +131 drivers/gpu/drm/i915/display/intel_fbdev.c
124
125 #define to_intel_fbdev(x) container_of(x, struct intel_fbdev, helper)
126 static int intel_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma)
127 {
128 struct intel_fbdev *fbdev = to_intel_fbdev(info->par);
129 struct drm_gem_object *bo = drm_gem_fb_get_obj(&fbdev->fb->base, 0);
130 struct drm_i915_gem_object *obj = to_intel_bo(bo);
> 131 struct drm_device *dev = fbdev->helper.dev;
132
133 vma->vm_page_prot =
134 pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
135
136 if (obj->stolen)
137 return vm_iomap_memory(vma, info->fix.smem_start,
138 info->fix.smem_len);
139
140 return i915_gem_object_mmap(obj, vma);
141 }
142 static const struct fb_ops intelfb_ops = {
143 .owner = THIS_MODULE,
144 DRM_FB_HELPER_DEFAULT_OPS,
145 .fb_set_par = intel_fbdev_set_par,
146 .fb_read = drm_fb_helper_cfb_read,
147 .fb_write = drm_fb_helper_cfb_write,
148 .fb_fillrect = drm_fb_helper_cfb_fillrect,
149 .fb_copyarea = drm_fb_helper_cfb_copyarea,
150 .fb_imageblit = drm_fb_helper_cfb_imageblit,
151 .fb_pan_display = intel_fbdev_pan_display,
152 .fb_blank = intel_fbdev_blank,
153 .fb_mmap = intel_fbdev_mmap,
154 };
155
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: failure for series starting with [1/3] drm/i915: Set I915_BO_ALLOC_USER for framebuffer
In reply to Nirmoy Das== Series Details ==
== Series Details ==
Series: series starting with [1/3] drm/i915: Set I915_BO_ALLOC_USER for framebuffer
URL : https://patchwork.freedesktop.org/series/114693/
State : failure
== Summary ==
Error: make failed
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
CC [M] drivers/gpu/drm/i915/display/intel_fbdev.odrivers/gpu/drm/i915/display/intel_fbdev.c: In function ‘intel_fbdev_mmap’:drivers/gpu/drm/i915/display/intel_fbdev.c:131:21: error: unused variable ‘dev’ [-Werror=unused-variable]
131 | struct drm_device *dev = fbdev->helper.dev;
| ^~~
cc1: all warnings being treated as errors
make[5]: *** [scripts/Makefile.build:252: drivers/gpu/drm/i915/display/intel_fbdev.o] Error 1 make[4]: *** [scripts/Makefile.build:494: drivers/gpu/drm/i915] Error 2
make[3]: *** [scripts/Makefile.build:494: drivers/gpu/drm] Error 2
make[2]: *** [scripts/Makefile.build:494: drivers/gpu] Error 2
make[1]: *** [scripts/Makefile.build:494: drivers] Error 2
make: *** [Makefile:2028: .] Error 2
Quoted 3 lines · Nirmoy Das
Framebuffer is exposed to userspace so set
I915_BO_ALLOC_USERflag for it. This also make sure that ttm allocates offset for lmem objects.
I have no idea what that means.
Quoted 53 lines
Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/i915/display/intel_dpt.c | 4 +++- drivers/gpu/drm/i915/display/intel_fbdev.c | 3 ++- drivers/gpu/drm/i915/display/intel_plane_initial.c | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/display/intel_dpt.c +3
-1@@ -254,7 +254,9 @@ intel_dpt_create(struct intel_framebuffer *fb) size =round_up (size *sizeof (gen8_pte_t),I915_GTT_PAGE_SIZE ); - dpt_obj =i915_gem_object_create_lmem (i915, size,I915_BO_ALLOC_CONTIGUOUS ); + dpt_obj =i915_gem_object_create_lmem (i915, size, +I915_BO_ALLOC_CONTIGUOUS | +I915_BO_ALLOC_USER );if (IS_ERR (dpt_obj) &&i915_ggtt_has_aperture (to_gt (i915)->ggtt)) dpt_obj =i915_gem_object_create_stolen (i915, size);if (IS_ERR (dpt_obj) && !HAS_LMEM (i915)) {drivers/gpu/drm/i915/display/intel_fbdev.c +2
-1@@ -163,7 +163,8 @@ static int intelfb_alloc(struct drm_fb_helper *helper, obj =ERR_PTR (-ENODEV );if (HAS_LMEM (dev_priv)) { obj =i915_gem_object_create_lmem (dev_priv, size, -I915_BO_ALLOC_CONTIGUOUS ); +I915_BO_ALLOC_CONTIGUOUS | +I915_BO_ALLOC_USER ); }else {/* * If the FB is too big, just don't use it since fbdev is not very drivers/gpu/drm/i915/display/intel_plane_initial.c +2
-1@@ -110,7 +110,8 @@ initial_plane_vma(struct drm_i915_private *i915, size * 2 > i915->dsm.usable_size)return NULL ; - obj =i915_gem_object_create_region_at (mem, phys_base, size,0 ); + obj =i915_gem_object_create_region_at (mem, phys_base, size, +I915_BO_ALLOC_USER );if (IS_ERR (obj))return NULL ;Signature · 1 line
2.39.0
Signature · 2 lines
Ville Syrjälä Intel
Quoted 5 lines · Ville Syrjälä
Quoted 3 lines · Nirmoy Das
Framebuffer is exposed to userspace so set
I915_BO_ALLOC_USERflag for it. This also make sure that ttm allocates offset for lmem objects.I have no idea what that means.
Sorry for poor explanation.
Without I915_BO_ALLOC_USER, ttm will assume the obj as kernel buffer and will not allocate fake offset which I needed for fb_mmap callback to work.
Regards,
Nirmoy
Quoted 53 lines
Quoted 53 lines
Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/i915/display/intel_dpt.c | 4 +++- drivers/gpu/drm/i915/display/intel_fbdev.c | 3 ++- drivers/gpu/drm/i915/display/intel_plane_initial.c | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/display/intel_dpt.c +3
-1@@ -254,7 +254,9 @@ intel_dpt_create(struct intel_framebuffer *fb) size =round_up (size *sizeof (gen8_pte_t),I915_GTT_PAGE_SIZE ); - dpt_obj =i915_gem_object_create_lmem (i915, size,I915_BO_ALLOC_CONTIGUOUS ); + dpt_obj =i915_gem_object_create_lmem (i915, size, +I915_BO_ALLOC_CONTIGUOUS | +I915_BO_ALLOC_USER );if (IS_ERR (dpt_obj) &&i915_ggtt_has_aperture (to_gt (i915)->ggtt)) dpt_obj =i915_gem_object_create_stolen (i915, size);if (IS_ERR (dpt_obj) && !HAS_LMEM (i915)) {drivers/gpu/drm/i915/display/intel_fbdev.c +2
-1@@ -163,7 +163,8 @@ static int intelfb_alloc(struct drm_fb_helper *helper, obj =ERR_PTR (-ENODEV );if (HAS_LMEM (dev_priv)) { obj =i915_gem_object_create_lmem (dev_priv, size, -I915_BO_ALLOC_CONTIGUOUS ); +I915_BO_ALLOC_CONTIGUOUS | +I915_BO_ALLOC_USER ); }else {/* * If the FB is too big, just don't use it since fbdev is not very drivers/gpu/drm/i915/display/intel_plane_initial.c +2
-1@@ -110,7 +110,8 @@ initial_plane_vma(struct drm_i915_private *i915, size * 2 > i915->dsm.usable_size)return NULL ; - obj =i915_gem_object_create_region_at (mem, phys_base, size,0 ); + obj =i915_gem_object_create_region_at (mem, phys_base, size, +I915_BO_ALLOC_USER );if (IS_ERR (obj))return NULL ;Signature · 1 line
2.39.0
Quoted 6 lines · Nirmoy
Quoted 4 lines · Ville Syrjälä
Quoted 3 lines · Nirmoy Das
Framebuffer is exposed to userspace so set
I915_BO_ALLOC_USERflag for it. This also make sure that ttm allocates offset for lmem objects.
Quoted 6 lines
Quoted 1 line
I have no idea what that means.
Sorry for poor explanation.
Without
I915_BO_ALLOC_USER, ttm will assume the obj as kernel buffer and will not allocate fake offset which I needed forfb_mmapcallback to work.
So that's the fake vm_pgoff thing? Doesn't that exist just so mmap() through /dev/dri* can be passed a "gem handle"? With fbdev mmap we already know which BO we want to map so why would any of that stuff even be needed?
Quoted 57 lines
Regards,
NirmoyQuoted 53 lines
Quoted 53 lines
Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/i915/display/intel_dpt.c | 4 +++- drivers/gpu/drm/i915/display/intel_fbdev.c | 3 ++- drivers/gpu/drm/i915/display/intel_plane_initial.c | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/display/intel_dpt.c +3
-1@@ -254,7 +254,9 @@ intel_dpt_create(struct intel_framebuffer *fb) size =round_up (size *sizeof (gen8_pte_t),I915_GTT_PAGE_SIZE ); - dpt_obj =i915_gem_object_create_lmem (i915, size,I915_BO_ALLOC_CONTIGUOUS ); + dpt_obj =i915_gem_object_create_lmem (i915, size, +I915_BO_ALLOC_CONTIGUOUS | +I915_BO_ALLOC_USER );if (IS_ERR (dpt_obj) &&i915_ggtt_has_aperture (to_gt (i915)->ggtt)) dpt_obj =i915_gem_object_create_stolen (i915, size);if (IS_ERR (dpt_obj) && !HAS_LMEM (i915)) {drivers/gpu/drm/i915/display/intel_fbdev.c +2
-1@@ -163,7 +163,8 @@ static int intelfb_alloc(struct drm_fb_helper *helper, obj =ERR_PTR (-ENODEV );if (HAS_LMEM (dev_priv)) { obj =i915_gem_object_create_lmem (dev_priv, size, -I915_BO_ALLOC_CONTIGUOUS ); +I915_BO_ALLOC_CONTIGUOUS | +I915_BO_ALLOC_USER ); }else {/* * If the FB is too big, just don't use it since fbdev is not very drivers/gpu/drm/i915/display/intel_plane_initial.c +2
-1@@ -110,7 +110,8 @@ initial_plane_vma(struct drm_i915_private *i915, size * 2 > i915->dsm.usable_size)return NULL ; - obj =i915_gem_object_create_region_at (mem, phys_base, size,0 ); + obj =i915_gem_object_create_region_at (mem, phys_base, size, +I915_BO_ALLOC_USER );if (IS_ERR (obj))return NULL ;Signature · 1 line
2.39.0
Signature · 2 lines
Ville Syrjälä Intel
Quoted 7 lines · Ville Syrjälä
Quoted 6 lines · Nirmoy
Quoted 5 lines · Ville Syrjälä
Quoted 3 lines · Nirmoy Das
Framebuffer is exposed to userspace so set
I915_BO_ALLOC_USERflag for it. This also make sure that ttm allocates offset for lmem objects.I have no idea what that means.
Quoted 8 lines
Quoted 4 lines
Sorry for poor explanation.
Without
I915_BO_ALLOC_USER, ttm will assume the obj as kernel buffer and will not allocate fake offset which I needed forfb_mmapcallback to work.So that's the fake
vm_pgoffthing? Doesn't that exist just sommap()through/dev/dri*can be passed a "gem handle"? With fbdev mmap we already know which BO we want to map so why would any of that stuff even be needed?
I was mainly concentrating on using drm mmap API to achieve fb_mmap which eventually will call i915_gem_mmap()
and expects a fake offset for the obj. I see your point: fb_mmap can be done without using drm mmap API which should be much simple . I will look into this and resend.
Thanks,
Nirmoy
Quoted 55 lines
Quoted 55 lines
Regards,
NirmoyQuoted 52 lines
Quoted 52 lines
Signed-off-by Nirmoy Das <[email protected]>--- drivers/gpu/drm/i915/display/intel_dpt.c | 4 +++- drivers/gpu/drm/i915/display/intel_fbdev.c | 3 ++- drivers/gpu/drm/i915/display/intel_plane_initial.c | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/display/intel_dpt.c +3
-1@@ -254,7 +254,9 @@ intel_dpt_create(struct intel_framebuffer *fb) size =round_up (size *sizeof (gen8_pte_t),I915_GTT_PAGE_SIZE ); - dpt_obj =i915_gem_object_create_lmem (i915, size,I915_BO_ALLOC_CONTIGUOUS ); + dpt_obj =i915_gem_object_create_lmem (i915, size, +I915_BO_ALLOC_CONTIGUOUS | +I915_BO_ALLOC_USER );if (IS_ERR (dpt_obj) &&i915_ggtt_has_aperture (to_gt (i915)->ggtt)) dpt_obj =i915_gem_object_create_stolen (i915, size);if (IS_ERR (dpt_obj) && !HAS_LMEM (i915)) {drivers/gpu/drm/i915/display/intel_fbdev.c +2
-1@@ -163,7 +163,8 @@ static int intelfb_alloc(struct drm_fb_helper *helper, obj =ERR_PTR (-ENODEV );if (HAS_LMEM (dev_priv)) { obj =i915_gem_object_create_lmem (dev_priv, size, -I915_BO_ALLOC_CONTIGUOUS ); +I915_BO_ALLOC_CONTIGUOUS | +I915_BO_ALLOC_USER ); }else {/* * If the FB is too big, just don't use it since fbdev is not very drivers/gpu/drm/i915/display/intel_plane_initial.c +2
-1@@ -110,7 +110,8 @@ initial_plane_vma(struct drm_i915_private *i915, size * 2 > i915->dsm.usable_size)return NULL ; - obj =i915_gem_object_create_region_at (mem, phys_base, size,0 ); + obj =i915_gem_object_create_region_at (mem, phys_base, size, +I915_BO_ALLOC_USER );if (IS_ERR (obj))return NULL ;Signature · 1 line
2.39.0