* [Intel-gfx] [PATCH] Remove custom dumb_map_offset implementations in i915 driver
@ 2023-11-10 10:58 Dipam Turkar
2023-11-10 11:28 ` Tvrtko Ursulin
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Dipam Turkar @ 2023-11-10 10:58 UTC (permalink / raw)
To: jani.nikula
Cc: Dipam Turkar, intel-gfx, linux-kernel, dri-devel, daniel,
rodrigo.vivi, airlied
Making i915 use drm_gem_create_mmap_offset() instead of its custom
implementations for associating GEM object with a fake offset.
Signed-off-by: Dipam Turkar <dipamt1729@gmail.com>
---
drivers/gpu/drm/i915/gem/i915_gem_mman.c | 192 -----------------------
drivers/gpu/drm/i915/gem/i915_gem_mman.h | 4 -
drivers/gpu/drm/i915/i915_driver.c | 3 +-
3 files changed, 2 insertions(+), 197 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index aa4d842d4c5a..6b73fe509270 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
@@ -600,198 +600,6 @@ void i915_gem_object_release_mmap_offset(struct drm_i915_gem_object *obj)
spin_unlock(&obj->mmo.lock);
}
-static struct i915_mmap_offset *
-lookup_mmo(struct drm_i915_gem_object *obj,
- enum i915_mmap_type mmap_type)
-{
- struct rb_node *rb;
-
- spin_lock(&obj->mmo.lock);
- rb = obj->mmo.offsets.rb_node;
- while (rb) {
- struct i915_mmap_offset *mmo =
- rb_entry(rb, typeof(*mmo), offset);
-
- if (mmo->mmap_type == mmap_type) {
- spin_unlock(&obj->mmo.lock);
- return mmo;
- }
-
- if (mmo->mmap_type < mmap_type)
- rb = rb->rb_right;
- else
- rb = rb->rb_left;
- }
- spin_unlock(&obj->mmo.lock);
-
- return NULL;
-}
-
-static struct i915_mmap_offset *
-insert_mmo(struct drm_i915_gem_object *obj, struct i915_mmap_offset *mmo)
-{
- struct rb_node *rb, **p;
-
- spin_lock(&obj->mmo.lock);
- rb = NULL;
- p = &obj->mmo.offsets.rb_node;
- while (*p) {
- struct i915_mmap_offset *pos;
-
- rb = *p;
- pos = rb_entry(rb, typeof(*pos), offset);
-
- if (pos->mmap_type == mmo->mmap_type) {
- spin_unlock(&obj->mmo.lock);
- drm_vma_offset_remove(obj->base.dev->vma_offset_manager,
- &mmo->vma_node);
- kfree(mmo);
- return pos;
- }
-
- if (pos->mmap_type < mmo->mmap_type)
- p = &rb->rb_right;
- else
- p = &rb->rb_left;
- }
- rb_link_node(&mmo->offset, rb, p);
- rb_insert_color(&mmo->offset, &obj->mmo.offsets);
- spin_unlock(&obj->mmo.lock);
-
- return mmo;
-}
-
-static struct i915_mmap_offset *
-mmap_offset_attach(struct drm_i915_gem_object *obj,
- enum i915_mmap_type mmap_type,
- struct drm_file *file)
-{
- struct drm_i915_private *i915 = to_i915(obj->base.dev);
- struct i915_mmap_offset *mmo;
- int err;
-
- GEM_BUG_ON(obj->ops->mmap_offset || obj->ops->mmap_ops);
-
- mmo = lookup_mmo(obj, mmap_type);
- if (mmo)
- goto out;
-
- mmo = kmalloc(sizeof(*mmo), GFP_KERNEL);
- if (!mmo)
- return ERR_PTR(-ENOMEM);
-
- mmo->obj = obj;
- mmo->mmap_type = mmap_type;
- drm_vma_node_reset(&mmo->vma_node);
-
- err = drm_vma_offset_add(obj->base.dev->vma_offset_manager,
- &mmo->vma_node, obj->base.size / PAGE_SIZE);
- if (likely(!err))
- goto insert;
-
- /* Attempt to reap some mmap space from dead objects */
- err = intel_gt_retire_requests_timeout(to_gt(i915), MAX_SCHEDULE_TIMEOUT,
- NULL);
- if (err)
- goto err;
-
- i915_gem_drain_freed_objects(i915);
- err = drm_vma_offset_add(obj->base.dev->vma_offset_manager,
- &mmo->vma_node, obj->base.size / PAGE_SIZE);
- if (err)
- goto err;
-
-insert:
- mmo = insert_mmo(obj, mmo);
- GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo);
-out:
- if (file)
- drm_vma_node_allow_once(&mmo->vma_node, file);
- return mmo;
-
-err:
- kfree(mmo);
- return ERR_PTR(err);
-}
-
-static int
-__assign_mmap_offset(struct drm_i915_gem_object *obj,
- enum i915_mmap_type mmap_type,
- u64 *offset, struct drm_file *file)
-{
- struct i915_mmap_offset *mmo;
-
- if (i915_gem_object_never_mmap(obj))
- return -ENODEV;
-
- if (obj->ops->mmap_offset) {
- if (mmap_type != I915_MMAP_TYPE_FIXED)
- return -ENODEV;
-
- *offset = obj->ops->mmap_offset(obj);
- return 0;
- }
-
- if (mmap_type == I915_MMAP_TYPE_FIXED)
- return -ENODEV;
-
- if (mmap_type != I915_MMAP_TYPE_GTT &&
- !i915_gem_object_has_struct_page(obj) &&
- !i915_gem_object_has_iomem(obj))
- return -ENODEV;
-
- mmo = mmap_offset_attach(obj, mmap_type, file);
- if (IS_ERR(mmo))
- return PTR_ERR(mmo);
-
- *offset = drm_vma_node_offset_addr(&mmo->vma_node);
- return 0;
-}
-
-static int
-__assign_mmap_offset_handle(struct drm_file *file,
- u32 handle,
- enum i915_mmap_type mmap_type,
- u64 *offset)
-{
- struct drm_i915_gem_object *obj;
- int err;
-
- obj = i915_gem_object_lookup(file, handle);
- if (!obj)
- return -ENOENT;
-
- err = i915_gem_object_lock_interruptible(obj, NULL);
- if (err)
- goto out_put;
- err = __assign_mmap_offset(obj, mmap_type, offset, file);
- i915_gem_object_unlock(obj);
-out_put:
- i915_gem_object_put(obj);
- return err;
-}
-
-int
-i915_gem_dumb_mmap_offset(struct drm_file *file,
- struct drm_device *dev,
- u32 handle,
- u64 *offset)
-{
- struct drm_i915_private *i915 = to_i915(dev);
- enum i915_mmap_type mmap_type;
-
- if (HAS_LMEM(to_i915(dev)))
- mmap_type = I915_MMAP_TYPE_FIXED;
- else if (pat_enabled())
- mmap_type = I915_MMAP_TYPE_WC;
- else if (!i915_ggtt_has_aperture(to_gt(i915)->ggtt))
- return -ENODEV;
- else
- mmap_type = I915_MMAP_TYPE_GTT;
-
- return __assign_mmap_offset_handle(file, handle, mmap_type, offset);
-}
-
/**
* i915_gem_mmap_offset_ioctl - prepare an object for GTT mmap'ing
* @dev: DRM device
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.h b/drivers/gpu/drm/i915/gem/i915_gem_mman.h
index 196417fd0f5c..253435795caf 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.h
@@ -20,10 +20,6 @@ struct mutex;
int i915_gem_mmap_gtt_version(void);
int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma);
-int i915_gem_dumb_mmap_offset(struct drm_file *file_priv,
- struct drm_device *dev,
- u32 handle, u64 *offset);
-
void __i915_gem_object_release_mmap_gtt(struct drm_i915_gem_object *obj);
void i915_gem_object_release_mmap_gtt(struct drm_i915_gem_object *obj);
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index d50347e5773a..a18a33896ba4 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -42,6 +42,7 @@
#include <drm/drm_aperture.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_ioctl.h>
+#include <drm/drm_gem.h>
#include <drm/drm_managed.h>
#include <drm/drm_probe_helper.h>
@@ -1826,7 +1827,7 @@ static const struct drm_driver i915_drm_driver = {
.gem_prime_import = i915_gem_prime_import,
.dumb_create = i915_gem_dumb_create,
- .dumb_map_offset = i915_gem_dumb_mmap_offset,
+ .dumb_map_offset = drm_gem_dumb_mmap_offset,
.ioctls = i915_ioctls,
.num_ioctls = ARRAY_SIZE(i915_ioctls),
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Intel-gfx] [PATCH] Remove custom dumb_map_offset implementations in i915 driver
2023-11-10 10:58 [Intel-gfx] [PATCH] Remove custom dumb_map_offset implementations in i915 driver Dipam Turkar
@ 2023-11-10 11:28 ` Tvrtko Ursulin
2023-11-10 16:52 ` kernel test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Tvrtko Ursulin @ 2023-11-10 11:28 UTC (permalink / raw)
To: Dipam Turkar, jani.nikula
Cc: intel-gfx, linux-kernel, dri-devel, daniel, rodrigo.vivi, airlied
On 10/11/2023 10:58, Dipam Turkar wrote:
> Making i915 use drm_gem_create_mmap_offset() instead of its custom
> implementations for associating GEM object with a fake offset.
Does it compile?
Regards,
Tvrtko
> Signed-off-by: Dipam Turkar <dipamt1729@gmail.com>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_mman.c | 192 -----------------------
> drivers/gpu/drm/i915/gem/i915_gem_mman.h | 4 -
> drivers/gpu/drm/i915/i915_driver.c | 3 +-
> 3 files changed, 2 insertions(+), 197 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> index aa4d842d4c5a..6b73fe509270 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> @@ -600,198 +600,6 @@ void i915_gem_object_release_mmap_offset(struct drm_i915_gem_object *obj)
> spin_unlock(&obj->mmo.lock);
> }
>
> -static struct i915_mmap_offset *
> -lookup_mmo(struct drm_i915_gem_object *obj,
> - enum i915_mmap_type mmap_type)
> -{
> - struct rb_node *rb;
> -
> - spin_lock(&obj->mmo.lock);
> - rb = obj->mmo.offsets.rb_node;
> - while (rb) {
> - struct i915_mmap_offset *mmo =
> - rb_entry(rb, typeof(*mmo), offset);
> -
> - if (mmo->mmap_type == mmap_type) {
> - spin_unlock(&obj->mmo.lock);
> - return mmo;
> - }
> -
> - if (mmo->mmap_type < mmap_type)
> - rb = rb->rb_right;
> - else
> - rb = rb->rb_left;
> - }
> - spin_unlock(&obj->mmo.lock);
> -
> - return NULL;
> -}
> -
> -static struct i915_mmap_offset *
> -insert_mmo(struct drm_i915_gem_object *obj, struct i915_mmap_offset *mmo)
> -{
> - struct rb_node *rb, **p;
> -
> - spin_lock(&obj->mmo.lock);
> - rb = NULL;
> - p = &obj->mmo.offsets.rb_node;
> - while (*p) {
> - struct i915_mmap_offset *pos;
> -
> - rb = *p;
> - pos = rb_entry(rb, typeof(*pos), offset);
> -
> - if (pos->mmap_type == mmo->mmap_type) {
> - spin_unlock(&obj->mmo.lock);
> - drm_vma_offset_remove(obj->base.dev->vma_offset_manager,
> - &mmo->vma_node);
> - kfree(mmo);
> - return pos;
> - }
> -
> - if (pos->mmap_type < mmo->mmap_type)
> - p = &rb->rb_right;
> - else
> - p = &rb->rb_left;
> - }
> - rb_link_node(&mmo->offset, rb, p);
> - rb_insert_color(&mmo->offset, &obj->mmo.offsets);
> - spin_unlock(&obj->mmo.lock);
> -
> - return mmo;
> -}
> -
> -static struct i915_mmap_offset *
> -mmap_offset_attach(struct drm_i915_gem_object *obj,
> - enum i915_mmap_type mmap_type,
> - struct drm_file *file)
> -{
> - struct drm_i915_private *i915 = to_i915(obj->base.dev);
> - struct i915_mmap_offset *mmo;
> - int err;
> -
> - GEM_BUG_ON(obj->ops->mmap_offset || obj->ops->mmap_ops);
> -
> - mmo = lookup_mmo(obj, mmap_type);
> - if (mmo)
> - goto out;
> -
> - mmo = kmalloc(sizeof(*mmo), GFP_KERNEL);
> - if (!mmo)
> - return ERR_PTR(-ENOMEM);
> -
> - mmo->obj = obj;
> - mmo->mmap_type = mmap_type;
> - drm_vma_node_reset(&mmo->vma_node);
> -
> - err = drm_vma_offset_add(obj->base.dev->vma_offset_manager,
> - &mmo->vma_node, obj->base.size / PAGE_SIZE);
> - if (likely(!err))
> - goto insert;
> -
> - /* Attempt to reap some mmap space from dead objects */
> - err = intel_gt_retire_requests_timeout(to_gt(i915), MAX_SCHEDULE_TIMEOUT,
> - NULL);
> - if (err)
> - goto err;
> -
> - i915_gem_drain_freed_objects(i915);
> - err = drm_vma_offset_add(obj->base.dev->vma_offset_manager,
> - &mmo->vma_node, obj->base.size / PAGE_SIZE);
> - if (err)
> - goto err;
> -
> -insert:
> - mmo = insert_mmo(obj, mmo);
> - GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo);
> -out:
> - if (file)
> - drm_vma_node_allow_once(&mmo->vma_node, file);
> - return mmo;
> -
> -err:
> - kfree(mmo);
> - return ERR_PTR(err);
> -}
> -
> -static int
> -__assign_mmap_offset(struct drm_i915_gem_object *obj,
> - enum i915_mmap_type mmap_type,
> - u64 *offset, struct drm_file *file)
> -{
> - struct i915_mmap_offset *mmo;
> -
> - if (i915_gem_object_never_mmap(obj))
> - return -ENODEV;
> -
> - if (obj->ops->mmap_offset) {
> - if (mmap_type != I915_MMAP_TYPE_FIXED)
> - return -ENODEV;
> -
> - *offset = obj->ops->mmap_offset(obj);
> - return 0;
> - }
> -
> - if (mmap_type == I915_MMAP_TYPE_FIXED)
> - return -ENODEV;
> -
> - if (mmap_type != I915_MMAP_TYPE_GTT &&
> - !i915_gem_object_has_struct_page(obj) &&
> - !i915_gem_object_has_iomem(obj))
> - return -ENODEV;
> -
> - mmo = mmap_offset_attach(obj, mmap_type, file);
> - if (IS_ERR(mmo))
> - return PTR_ERR(mmo);
> -
> - *offset = drm_vma_node_offset_addr(&mmo->vma_node);
> - return 0;
> -}
> -
> -static int
> -__assign_mmap_offset_handle(struct drm_file *file,
> - u32 handle,
> - enum i915_mmap_type mmap_type,
> - u64 *offset)
> -{
> - struct drm_i915_gem_object *obj;
> - int err;
> -
> - obj = i915_gem_object_lookup(file, handle);
> - if (!obj)
> - return -ENOENT;
> -
> - err = i915_gem_object_lock_interruptible(obj, NULL);
> - if (err)
> - goto out_put;
> - err = __assign_mmap_offset(obj, mmap_type, offset, file);
> - i915_gem_object_unlock(obj);
> -out_put:
> - i915_gem_object_put(obj);
> - return err;
> -}
> -
> -int
> -i915_gem_dumb_mmap_offset(struct drm_file *file,
> - struct drm_device *dev,
> - u32 handle,
> - u64 *offset)
> -{
> - struct drm_i915_private *i915 = to_i915(dev);
> - enum i915_mmap_type mmap_type;
> -
> - if (HAS_LMEM(to_i915(dev)))
> - mmap_type = I915_MMAP_TYPE_FIXED;
> - else if (pat_enabled())
> - mmap_type = I915_MMAP_TYPE_WC;
> - else if (!i915_ggtt_has_aperture(to_gt(i915)->ggtt))
> - return -ENODEV;
> - else
> - mmap_type = I915_MMAP_TYPE_GTT;
> -
> - return __assign_mmap_offset_handle(file, handle, mmap_type, offset);
> -}
> -
> /**
> * i915_gem_mmap_offset_ioctl - prepare an object for GTT mmap'ing
> * @dev: DRM device
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.h b/drivers/gpu/drm/i915/gem/i915_gem_mman.h
> index 196417fd0f5c..253435795caf 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.h
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.h
> @@ -20,10 +20,6 @@ struct mutex;
> int i915_gem_mmap_gtt_version(void);
> int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma);
>
> -int i915_gem_dumb_mmap_offset(struct drm_file *file_priv,
> - struct drm_device *dev,
> - u32 handle, u64 *offset);
> -
> void __i915_gem_object_release_mmap_gtt(struct drm_i915_gem_object *obj);
> void i915_gem_object_release_mmap_gtt(struct drm_i915_gem_object *obj);
>
> diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
> index d50347e5773a..a18a33896ba4 100644
> --- a/drivers/gpu/drm/i915/i915_driver.c
> +++ b/drivers/gpu/drm/i915/i915_driver.c
> @@ -42,6 +42,7 @@
> #include <drm/drm_aperture.h>
> #include <drm/drm_atomic_helper.h>
> #include <drm/drm_ioctl.h>
> +#include <drm/drm_gem.h>
> #include <drm/drm_managed.h>
> #include <drm/drm_probe_helper.h>
>
> @@ -1826,7 +1827,7 @@ static const struct drm_driver i915_drm_driver = {
> .gem_prime_import = i915_gem_prime_import,
>
> .dumb_create = i915_gem_dumb_create,
> - .dumb_map_offset = i915_gem_dumb_mmap_offset,
> + .dumb_map_offset = drm_gem_dumb_mmap_offset,
>
> .ioctls = i915_ioctls,
> .num_ioctls = ARRAY_SIZE(i915_ioctls),
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Intel-gfx] [PATCH] Remove custom dumb_map_offset implementations in i915 driver
2023-11-10 10:58 [Intel-gfx] [PATCH] Remove custom dumb_map_offset implementations in i915 driver Dipam Turkar
2023-11-10 11:28 ` Tvrtko Ursulin
@ 2023-11-10 16:52 ` kernel test robot
2023-11-10 18:20 ` kernel test robot
2023-11-10 18:37 ` kernel test robot
3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2023-11-10 16:52 UTC (permalink / raw)
To: Dipam Turkar, jani.nikula
Cc: Dipam Turkar, intel-gfx, rodrigo.vivi, linux-kernel, dri-devel,
daniel, oe-kbuild-all, airlied
Hi Dipam,
kernel test robot noticed the following build errors:
[auto build test ERROR on drm-tip/drm-tip]
url: https://github.com/intel-lab-lkp/linux/commits/Dipam-Turkar/Remove-custom-dumb_map_offset-implementations-in-i915-driver/20231110-185942
base: git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link: https://lore.kernel.org/r/20231110105811.380646-1-dipamt1729%40gmail.com
patch subject: [Intel-gfx] [PATCH] Remove custom dumb_map_offset implementations in i915 driver
config: x86_64-randconfig-012-20231110 (https://download.01.org/0day-ci/archive/20231111/202311110053.K5lNjN1W-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231111/202311110053.K5lNjN1W-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311110053.K5lNjN1W-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
drivers/gpu/drm/i915/gem/i915_gem_mman.c: In function 'i915_gem_mmap_offset_ioctl':
>> drivers/gpu/drm/i915/gem/i915_gem_mman.c:673:16: error: implicit declaration of function '__assign_mmap_offset_handle' [-Werror=implicit-function-declaration]
673 | return __assign_mmap_offset_handle(file, args->handle, type, &args->offset);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/i915/gem/i915_gem_mman.c: In function 'i915_gem_fb_mmap':
>> drivers/gpu/drm/i915/gem/i915_gem_mman.c:896:23: error: implicit declaration of function 'mmap_offset_attach' [-Werror=implicit-function-declaration]
896 | mmo = mmap_offset_attach(obj, mmap_type, NULL);
| ^~~~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/gem/i915_gem_mman.c:896:21: warning: assignment to 'struct i915_mmap_offset *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
896 | mmo = mmap_offset_attach(obj, mmap_type, NULL);
| ^
cc1: some warnings being treated as errors
--
>> drivers/gpu/drm/i915/i915_driver.c:1826:28: error: 'drm_gem_dumb_mmap_offset' undeclared here (not in a function); did you mean 'drm_gem_dumb_map_offset'?
1826 | .dumb_map_offset = drm_gem_dumb_mmap_offset,
| ^~~~~~~~~~~~~~~~~~~~~~~~
| drm_gem_dumb_map_offset
vim +/__assign_mmap_offset_handle +673 drivers/gpu/drm/i915/gem/i915_gem_mman.c
cc662126b4134e Abdiel Janulgue 2019-12-04 603
b414fcd5be0b00 Chris Wilson 2019-05-28 604 /**
cc662126b4134e Abdiel Janulgue 2019-12-04 605 * i915_gem_mmap_offset_ioctl - prepare an object for GTT mmap'ing
b414fcd5be0b00 Chris Wilson 2019-05-28 606 * @dev: DRM device
b414fcd5be0b00 Chris Wilson 2019-05-28 607 * @data: GTT mapping ioctl data
b414fcd5be0b00 Chris Wilson 2019-05-28 608 * @file: GEM object info
b414fcd5be0b00 Chris Wilson 2019-05-28 609 *
b414fcd5be0b00 Chris Wilson 2019-05-28 610 * Simply returns the fake offset to userspace so it can mmap it.
b414fcd5be0b00 Chris Wilson 2019-05-28 611 * The mmap call will end up in drm_gem_mmap(), which will set things
b414fcd5be0b00 Chris Wilson 2019-05-28 612 * up so we can get faults in the handler above.
b414fcd5be0b00 Chris Wilson 2019-05-28 613 *
b414fcd5be0b00 Chris Wilson 2019-05-28 614 * The fault handler will take care of binding the object into the GTT
b414fcd5be0b00 Chris Wilson 2019-05-28 615 * (since it may have been evicted to make room for something), allocating
b414fcd5be0b00 Chris Wilson 2019-05-28 616 * a fence register, and mapping the appropriate aperture address into
b414fcd5be0b00 Chris Wilson 2019-05-28 617 * userspace.
b414fcd5be0b00 Chris Wilson 2019-05-28 618 */
b414fcd5be0b00 Chris Wilson 2019-05-28 619 int
cc662126b4134e Abdiel Janulgue 2019-12-04 620 i915_gem_mmap_offset_ioctl(struct drm_device *dev, void *data,
b414fcd5be0b00 Chris Wilson 2019-05-28 621 struct drm_file *file)
b414fcd5be0b00 Chris Wilson 2019-05-28 622 {
cc662126b4134e Abdiel Janulgue 2019-12-04 623 struct drm_i915_private *i915 = to_i915(dev);
cc662126b4134e Abdiel Janulgue 2019-12-04 624 struct drm_i915_gem_mmap_offset *args = data;
cc662126b4134e Abdiel Janulgue 2019-12-04 625 enum i915_mmap_type type;
126d5de38542d4 Chris Wilson 2019-12-04 626 int err;
cc662126b4134e Abdiel Janulgue 2019-12-04 627
8d65859a4cbae9 Chris Wilson 2019-12-07 628 /*
8d65859a4cbae9 Chris Wilson 2019-12-07 629 * Historically we failed to check args.pad and args.offset
8d65859a4cbae9 Chris Wilson 2019-12-07 630 * and so we cannot use those fields for user input and we cannot
8d65859a4cbae9 Chris Wilson 2019-12-07 631 * add -EINVAL for them as the ABI is fixed, i.e. old userspace
8d65859a4cbae9 Chris Wilson 2019-12-07 632 * may be feeding in garbage in those fields.
8d65859a4cbae9 Chris Wilson 2019-12-07 633 *
8d65859a4cbae9 Chris Wilson 2019-12-07 634 * if (args->pad) return -EINVAL; is verbotten!
8d65859a4cbae9 Chris Wilson 2019-12-07 635 */
8d65859a4cbae9 Chris Wilson 2019-12-07 636
126d5de38542d4 Chris Wilson 2019-12-04 637 err = i915_user_extensions(u64_to_user_ptr(args->extensions),
126d5de38542d4 Chris Wilson 2019-12-04 638 NULL, 0, NULL);
126d5de38542d4 Chris Wilson 2019-12-04 639 if (err)
126d5de38542d4 Chris Wilson 2019-12-04 640 return err;
cc662126b4134e Abdiel Janulgue 2019-12-04 641
cc662126b4134e Abdiel Janulgue 2019-12-04 642 switch (args->flags) {
cc662126b4134e Abdiel Janulgue 2019-12-04 643 case I915_MMAP_OFFSET_GTT:
5c24c9d227e9bb Michał Winiarski 2021-12-19 644 if (!i915_ggtt_has_aperture(to_gt(i915)->ggtt))
cc662126b4134e Abdiel Janulgue 2019-12-04 645 return -ENODEV;
cc662126b4134e Abdiel Janulgue 2019-12-04 646 type = I915_MMAP_TYPE_GTT;
cc662126b4134e Abdiel Janulgue 2019-12-04 647 break;
cc662126b4134e Abdiel Janulgue 2019-12-04 648
cc662126b4134e Abdiel Janulgue 2019-12-04 649 case I915_MMAP_OFFSET_WC:
bdd8b6c98239ca Lucas De Marchi 2021-12-01 650 if (!pat_enabled())
cc662126b4134e Abdiel Janulgue 2019-12-04 651 return -ENODEV;
cc662126b4134e Abdiel Janulgue 2019-12-04 652 type = I915_MMAP_TYPE_WC;
cc662126b4134e Abdiel Janulgue 2019-12-04 653 break;
cc662126b4134e Abdiel Janulgue 2019-12-04 654
cc662126b4134e Abdiel Janulgue 2019-12-04 655 case I915_MMAP_OFFSET_WB:
cc662126b4134e Abdiel Janulgue 2019-12-04 656 type = I915_MMAP_TYPE_WB;
cc662126b4134e Abdiel Janulgue 2019-12-04 657 break;
cc662126b4134e Abdiel Janulgue 2019-12-04 658
cc662126b4134e Abdiel Janulgue 2019-12-04 659 case I915_MMAP_OFFSET_UC:
bdd8b6c98239ca Lucas De Marchi 2021-12-01 660 if (!pat_enabled())
cc662126b4134e Abdiel Janulgue 2019-12-04 661 return -ENODEV;
cc662126b4134e Abdiel Janulgue 2019-12-04 662 type = I915_MMAP_TYPE_UC;
cc662126b4134e Abdiel Janulgue 2019-12-04 663 break;
cc662126b4134e Abdiel Janulgue 2019-12-04 664
7961c5b60f23df Maarten Lankhorst 2021-07-14 665 case I915_MMAP_OFFSET_FIXED:
7961c5b60f23df Maarten Lankhorst 2021-07-14 666 type = I915_MMAP_TYPE_FIXED;
7961c5b60f23df Maarten Lankhorst 2021-07-14 667 break;
7961c5b60f23df Maarten Lankhorst 2021-07-14 668
cc662126b4134e Abdiel Janulgue 2019-12-04 669 default:
cc662126b4134e Abdiel Janulgue 2019-12-04 670 return -EINVAL;
cc662126b4134e Abdiel Janulgue 2019-12-04 671 }
cc662126b4134e Abdiel Janulgue 2019-12-04 672
cf3e3e86d77970 Maarten Lankhorst 2021-06-10 @673 return __assign_mmap_offset_handle(file, args->handle, type, &args->offset);
cc662126b4134e Abdiel Janulgue 2019-12-04 674 }
cc662126b4134e Abdiel Janulgue 2019-12-04 675
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Intel-gfx] [PATCH] Remove custom dumb_map_offset implementations in i915 driver
2023-11-10 10:58 [Intel-gfx] [PATCH] Remove custom dumb_map_offset implementations in i915 driver Dipam Turkar
2023-11-10 11:28 ` Tvrtko Ursulin
2023-11-10 16:52 ` kernel test robot
@ 2023-11-10 18:20 ` kernel test robot
2023-11-10 18:37 ` kernel test robot
3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2023-11-10 18:20 UTC (permalink / raw)
To: Dipam Turkar, jani.nikula
Cc: Dipam Turkar, intel-gfx, rodrigo.vivi, linux-kernel, dri-devel,
daniel, oe-kbuild-all, airlied
Hi Dipam,
kernel test robot noticed the following build errors:
[auto build test ERROR on drm-tip/drm-tip]
url: https://github.com/intel-lab-lkp/linux/commits/Dipam-Turkar/Remove-custom-dumb_map_offset-implementations-in-i915-driver/20231110-185942
base: git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link: https://lore.kernel.org/r/20231110105811.380646-1-dipamt1729%40gmail.com
patch subject: [Intel-gfx] [PATCH] Remove custom dumb_map_offset implementations in i915 driver
config: x86_64-randconfig-014-20231110 (https://download.01.org/0day-ci/archive/20231111/202311110234.QjYxC2bv-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231111/202311110234.QjYxC2bv-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311110234.QjYxC2bv-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/gpu/drm/i915/gem/i915_gem_mman.c: In function 'i915_gem_mmap_offset_ioctl':
drivers/gpu/drm/i915/gem/i915_gem_mman.c:673:16: error: implicit declaration of function '__assign_mmap_offset_handle' [-Werror=implicit-function-declaration]
673 | return __assign_mmap_offset_handle(file, args->handle, type, &args->offset);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/i915/gem/i915_gem_mman.c: In function 'i915_gem_fb_mmap':
drivers/gpu/drm/i915/gem/i915_gem_mman.c:896:23: error: implicit declaration of function 'mmap_offset_attach' [-Werror=implicit-function-declaration]
896 | mmo = mmap_offset_attach(obj, mmap_type, NULL);
| ^~~~~~~~~~~~~~~~~~
drivers/gpu/drm/i915/gem/i915_gem_mman.c:896:21: warning: assignment to 'struct i915_mmap_offset *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
896 | mmo = mmap_offset_attach(obj, mmap_type, NULL);
| ^
In file included from drivers/gpu/drm/i915/gem/i915_gem_mman.c:912:
drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c: In function 'assert_mmap_offset':
>> drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c:624:15: error: implicit declaration of function '__assign_mmap_offset'; did you mean 'assert_mmap_offset'? [-Werror=implicit-function-declaration]
624 | ret = __assign_mmap_offset(obj, default_mapping(i915), &offset, NULL);
| ^~~~~~~~~~~~~~~~~~~~
| assert_mmap_offset
cc1: some warnings being treated as errors
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for DRM_I915_DEBUG_GEM
Depends on [n]: HAS_IOMEM [=y] && DRM_I915 [=y] && EXPERT [=y] && DRM_I915_WERROR [=n]
Selected by [y]:
- DRM_I915_DEBUG [=y] && HAS_IOMEM [=y] && DRM_I915 [=y] && EXPERT [=y] && !COMPILE_TEST [=n]
vim +624 drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c
450cede7f3804c Thomas Hellström 2021-08-31 611
b414fcd5be0b00 Chris Wilson 2019-05-28 612 static bool assert_mmap_offset(struct drm_i915_private *i915,
b414fcd5be0b00 Chris Wilson 2019-05-28 613 unsigned long size,
b414fcd5be0b00 Chris Wilson 2019-05-28 614 int expected)
b414fcd5be0b00 Chris Wilson 2019-05-28 615 {
b414fcd5be0b00 Chris Wilson 2019-05-28 616 struct drm_i915_gem_object *obj;
cf3e3e86d77970 Maarten Lankhorst 2021-06-10 617 u64 offset;
cf3e3e86d77970 Maarten Lankhorst 2021-06-10 618 int ret;
b414fcd5be0b00 Chris Wilson 2019-05-28 619
450cede7f3804c Thomas Hellström 2021-08-31 620 obj = create_sys_or_internal(i915, size);
b414fcd5be0b00 Chris Wilson 2019-05-28 621 if (IS_ERR(obj))
cf3e3e86d77970 Maarten Lankhorst 2021-06-10 622 return expected && expected == PTR_ERR(obj);
b414fcd5be0b00 Chris Wilson 2019-05-28 623
7961c5b60f23df Maarten Lankhorst 2021-07-14 @624 ret = __assign_mmap_offset(obj, default_mapping(i915), &offset, NULL);
b414fcd5be0b00 Chris Wilson 2019-05-28 625 i915_gem_object_put(obj);
b414fcd5be0b00 Chris Wilson 2019-05-28 626
cf3e3e86d77970 Maarten Lankhorst 2021-06-10 627 return ret == expected;
b414fcd5be0b00 Chris Wilson 2019-05-28 628 }
b414fcd5be0b00 Chris Wilson 2019-05-28 629
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Intel-gfx] [PATCH] Remove custom dumb_map_offset implementations in i915 driver
2023-11-10 10:58 [Intel-gfx] [PATCH] Remove custom dumb_map_offset implementations in i915 driver Dipam Turkar
` (2 preceding siblings ...)
2023-11-10 18:20 ` kernel test robot
@ 2023-11-10 18:37 ` kernel test robot
3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2023-11-10 18:37 UTC (permalink / raw)
To: Dipam Turkar, jani.nikula
Cc: Dipam Turkar, intel-gfx, rodrigo.vivi, linux-kernel, dri-devel,
daniel, oe-kbuild-all, airlied
Hi Dipam,
kernel test robot noticed the following build warnings:
[auto build test WARNING on drm-tip/drm-tip]
url: https://github.com/intel-lab-lkp/linux/commits/Dipam-Turkar/Remove-custom-dumb_map_offset-implementations-in-i915-driver/20231110-185942
base: git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link: https://lore.kernel.org/r/20231110105811.380646-1-dipamt1729%40gmail.com
patch subject: [Intel-gfx] [PATCH] Remove custom dumb_map_offset implementations in i915 driver
config: x86_64-randconfig-001-20231110 (https://download.01.org/0day-ci/archive/20231111/202311110226.CsxS1u1i-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231111/202311110226.CsxS1u1i-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311110226.CsxS1u1i-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/gpu/drm/i915/gem/i915_gem_mman.c: In function 'i915_gem_mmap_offset_ioctl':
drivers/gpu/drm/i915/gem/i915_gem_mman.c:673:9: error: implicit declaration of function '__assign_mmap_offset_handle'; did you mean 'i915_gem_mmap_offset_ioctl'? [-Werror=implicit-function-declaration]
return __assign_mmap_offset_handle(file, args->handle, type, &args->offset);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
i915_gem_mmap_offset_ioctl
drivers/gpu/drm/i915/gem/i915_gem_mman.c: In function 'i915_gem_fb_mmap':
drivers/gpu/drm/i915/gem/i915_gem_mman.c:896:9: error: implicit declaration of function 'mmap_offset_attach'; did you mean 'dma_free_attrs'? [-Werror=implicit-function-declaration]
mmo = mmap_offset_attach(obj, mmap_type, NULL);
^~~~~~~~~~~~~~~~~~
dma_free_attrs
>> drivers/gpu/drm/i915/gem/i915_gem_mman.c:896:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
mmo = mmap_offset_attach(obj, mmap_type, NULL);
^
cc1: some warnings being treated as errors
vim +896 drivers/gpu/drm/i915/gem/i915_gem_mman.c
eaee1c085863951 Nirmoy Das 2023-04-04 874
eaee1c085863951 Nirmoy Das 2023-04-04 875 int i915_gem_fb_mmap(struct drm_i915_gem_object *obj, struct vm_area_struct *vma)
eaee1c085863951 Nirmoy Das 2023-04-04 876 {
eaee1c085863951 Nirmoy Das 2023-04-04 877 struct drm_i915_private *i915 = to_i915(obj->base.dev);
eaee1c085863951 Nirmoy Das 2023-04-04 878 struct drm_device *dev = &i915->drm;
eaee1c085863951 Nirmoy Das 2023-04-04 879 struct i915_mmap_offset *mmo = NULL;
eaee1c085863951 Nirmoy Das 2023-04-04 880 enum i915_mmap_type mmap_type;
eaee1c085863951 Nirmoy Das 2023-04-04 881 struct i915_ggtt *ggtt = to_gt(i915)->ggtt;
eaee1c085863951 Nirmoy Das 2023-04-04 882
eaee1c085863951 Nirmoy Das 2023-04-04 883 if (drm_dev_is_unplugged(dev))
eaee1c085863951 Nirmoy Das 2023-04-04 884 return -ENODEV;
eaee1c085863951 Nirmoy Das 2023-04-04 885
eaee1c085863951 Nirmoy Das 2023-04-04 886 /* handle ttm object */
eaee1c085863951 Nirmoy Das 2023-04-04 887 if (obj->ops->mmap_ops) {
eaee1c085863951 Nirmoy Das 2023-04-04 888 /*
eaee1c085863951 Nirmoy Das 2023-04-04 889 * ttm fault handler, ttm_bo_vm_fault_reserved() uses fake offset
eaee1c085863951 Nirmoy Das 2023-04-04 890 * to calculate page offset so set that up.
eaee1c085863951 Nirmoy Das 2023-04-04 891 */
eaee1c085863951 Nirmoy Das 2023-04-04 892 vma->vm_pgoff += drm_vma_node_start(&obj->base.vma_node);
eaee1c085863951 Nirmoy Das 2023-04-04 893 } else {
eaee1c085863951 Nirmoy Das 2023-04-04 894 /* handle stolen and smem objects */
eaee1c085863951 Nirmoy Das 2023-04-04 895 mmap_type = i915_ggtt_has_aperture(ggtt) ? I915_MMAP_TYPE_GTT : I915_MMAP_TYPE_WC;
eaee1c085863951 Nirmoy Das 2023-04-04 @896 mmo = mmap_offset_attach(obj, mmap_type, NULL);
274d4b96b12f78c Dan Carpenter 2023-06-06 897 if (IS_ERR(mmo))
274d4b96b12f78c Dan Carpenter 2023-06-06 898 return PTR_ERR(mmo);
eaee1c085863951 Nirmoy Das 2023-04-04 899 }
eaee1c085863951 Nirmoy Das 2023-04-04 900
eaee1c085863951 Nirmoy Das 2023-04-04 901 /*
eaee1c085863951 Nirmoy Das 2023-04-04 902 * When we install vm_ops for mmap we are too late for
eaee1c085863951 Nirmoy Das 2023-04-04 903 * the vm_ops->open() which increases the ref_count of
eaee1c085863951 Nirmoy Das 2023-04-04 904 * this obj and then it gets decreased by the vm_ops->close().
eaee1c085863951 Nirmoy Das 2023-04-04 905 * To balance this increase the obj ref_count here.
eaee1c085863951 Nirmoy Das 2023-04-04 906 */
eaee1c085863951 Nirmoy Das 2023-04-04 907 obj = i915_gem_object_get(obj);
eaee1c085863951 Nirmoy Das 2023-04-04 908 return i915_gem_object_mmap(obj, mmo, vma);
eaee1c085863951 Nirmoy Das 2023-04-04 909 }
eaee1c085863951 Nirmoy Das 2023-04-04 910
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-10 18:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-10 10:58 [Intel-gfx] [PATCH] Remove custom dumb_map_offset implementations in i915 driver Dipam Turkar
2023-11-10 11:28 ` Tvrtko Ursulin
2023-11-10 16:52 ` kernel test robot
2023-11-10 18:20 ` kernel test robot
2023-11-10 18:37 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).