dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct
@ 2019-04-25  9:11 Koenig, Christian
  0 siblings, 0 replies; 7+ messages in thread
From: Koenig, Christian @ 2019-04-25  9:11 UTC (permalink / raw)
  To: Thomas Hellstrom
  Cc: Pv-drivers, Linux-graphics-maintainer, linux-kernel, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 4729 bytes --]



Am 25.04.2019 10:35 schrieb Thomas Hellstrom <thellstrom@vmware.com>:
Hi, Christian,

On Wed, 2019-04-24 at 16:20 +0200, Thomas Hellström wrote:
> On Wed, 2019-04-24 at 14:10 +0000, Koenig, Christian wrote:
> > Am 24.04.19 um 14:00 schrieb Thomas Hellstrom:
> > > Add a pointer to the struct vm_operations_struct in the
> > > bo_device,
> > > and
> > > assign that pointer to the default value currently used.
> > >
> > > The driver can then optionally modify that pointer and the new
> > > value
> > > can be used for each new vma created.
> > >
> > > Cc: "Christian König" <christian.koenig@amd.com>
> > >
> > > Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
> > > Reviewed-by: Christian König <christian.koenig@amd.com>
> >
> > Going to pick those two TTM patches up for amd-staging-drm-next.
>
> Will you be relying on either patch for related work? Otherwise it
> would be simpler for us to use vmwgfx-next for the whole series,
> targeting 5.3.
>
> Thomas

Is this OK with you?

I wanted to base some cleanup work on this, but this can wait as well.

So fine with me to merge this through vmwgfx-next.

Regards,
Christian.


Thanks,
Thomas



>
> > Christian.
> >
> > > ---
> > >   drivers/gpu/drm/ttm/ttm_bo.c    | 1 +
> > >   drivers/gpu/drm/ttm/ttm_bo_vm.c | 6 +++---
> > >   include/drm/ttm/ttm_bo_driver.h | 6 ++++++
> > >   3 files changed, 10 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c
> > > b/drivers/gpu/drm/ttm/ttm_bo.c
> > > index 3f56647cdb35..1c85bec00472 100644
> > > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > > @@ -1656,6 +1656,7 @@ int ttm_bo_device_init(struct ttm_bo_device
> > > *bdev,
> > >    mutex_lock(&ttm_global_mutex);
> > >    list_add_tail(&bdev->device_list, &glob->device_list);
> > >    mutex_unlock(&ttm_global_mutex);
> > > + bdev->vm_ops = &ttm_bo_vm_ops;
> > >
> > >    return 0;
> > >   out_no_sys:
> > > diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > > b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > > index e86a29a1e51f..bfb25b81fed7 100644
> > > --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > > +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > > @@ -395,7 +395,7 @@ static int ttm_bo_vm_access(struct
> > > vm_area_struct *vma, unsigned long addr,
> > >    return ret;
> > >   }
> > >
> > > -static const struct vm_operations_struct ttm_bo_vm_ops = {
> > > +const struct vm_operations_struct ttm_bo_vm_ops = {
> > >    .fault = ttm_bo_vm_fault,
> > >    .open = ttm_bo_vm_open,
> > >    .close = ttm_bo_vm_close,
> > > @@ -445,7 +445,7 @@ int ttm_bo_mmap(struct file *filp, struct
> > > vm_area_struct *vma,
> > >    if (unlikely(ret != 0))
> > >            goto out_unref;
> > >
> > > - vma->vm_ops = &ttm_bo_vm_ops;
> > > + vma->vm_ops = bdev->vm_ops;
> > >
> > >    /*
> > >     * Note: We're transferring the bo reference to
> > > @@ -477,7 +477,7 @@ int ttm_fbdev_mmap(struct vm_area_struct
> > > *vma,
> > > struct ttm_buffer_object *bo)
> > >
> > >    ttm_bo_get(bo);
> > >
> > > - vma->vm_ops = &ttm_bo_vm_ops;
> > > + vma->vm_ops = bo->bdev->vm_ops;
> > >    vma->vm_private_data = bo;
> > >    vma->vm_flags |= VM_MIXEDMAP;
> > >    vma->vm_flags |= VM_IO | VM_DONTEXPAND;
> > > diff --git a/include/drm/ttm/ttm_bo_driver.h
> > > b/include/drm/ttm/ttm_bo_driver.h
> > > index cbf3180cb612..cfeaff5d9706 100644
> > > --- a/include/drm/ttm/ttm_bo_driver.h
> > > +++ b/include/drm/ttm/ttm_bo_driver.h
> > > @@ -443,6 +443,9 @@ extern struct ttm_bo_global {
> > >    * @driver: Pointer to a struct ttm_bo_driver struct setup by
> > > the
> > > driver.
> > >    * @man: An array of mem_type_managers.
> > >    * @vma_manager: Address space manager
> > > + * @vm_ops: Pointer to the struct vm_operations_struct used for
> > > this
> > > + * device's VM operations. The driver may override this before
> > > the
> > > first
> > > + * mmap() call.
> > >    * lru_lock: Spinlock that protects the buffer+device lru lists
> > > and
> > >    * ddestroy lists.
> > >    * @dev_mapping: A pointer to the struct address_space
> > > representing the
> > > @@ -461,6 +464,7 @@ struct ttm_bo_device {
> > >    struct ttm_bo_global *glob;
> > >    struct ttm_bo_driver *driver;
> > >    struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
> > > + const struct vm_operations_struct *vm_ops;
> > >
> > >    /*
> > >     * Protected by internal locks.
> > > @@ -489,6 +493,8 @@ struct ttm_bo_device {
> > >    bool no_retry;
> > >   };
> > >
> > > +extern const struct vm_operations_struct ttm_bo_vm_ops;
> > > +
> > >   /**
> > >    * struct ttm_lru_bulk_move_pos
> > >    *


[-- Attachment #1.2: Type: text/html, Size: 8246 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct
  2019-04-24 14:20     ` Thomas Hellstrom
@ 2019-04-25  8:35       ` Thomas Hellstrom
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Hellstrom @ 2019-04-25  8:35 UTC (permalink / raw)
  To: dri-devel, Linux-graphics-maintainer, Christian.Koenig
  Cc: linux-kernel, Pv-drivers

Hi, Christian,

On Wed, 2019-04-24 at 16:20 +0200, Thomas Hellström wrote:
> On Wed, 2019-04-24 at 14:10 +0000, Koenig, Christian wrote:
> > Am 24.04.19 um 14:00 schrieb Thomas Hellstrom:
> > > Add a pointer to the struct vm_operations_struct in the
> > > bo_device,
> > > and
> > > assign that pointer to the default value currently used.
> > > 
> > > The driver can then optionally modify that pointer and the new
> > > value
> > > can be used for each new vma created.
> > > 
> > > Cc: "Christian König" <christian.koenig@amd.com>
> > > 
> > > Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
> > > Reviewed-by: Christian König <christian.koenig@amd.com>
> > 
> > Going to pick those two TTM patches up for amd-staging-drm-next.
> 
> Will you be relying on either patch for related work? Otherwise it
> would be simpler for us to use vmwgfx-next for the whole series,
> targeting 5.3.
> 
> Thomas

Is this OK with you?

Thanks,
Thomas



> 
> > Christian.
> > 
> > > ---
> > >   drivers/gpu/drm/ttm/ttm_bo.c    | 1 +
> > >   drivers/gpu/drm/ttm/ttm_bo_vm.c | 6 +++---
> > >   include/drm/ttm/ttm_bo_driver.h | 6 ++++++
> > >   3 files changed, 10 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c
> > > b/drivers/gpu/drm/ttm/ttm_bo.c
> > > index 3f56647cdb35..1c85bec00472 100644
> > > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > > @@ -1656,6 +1656,7 @@ int ttm_bo_device_init(struct ttm_bo_device
> > > *bdev,
> > >   	mutex_lock(&ttm_global_mutex);
> > >   	list_add_tail(&bdev->device_list, &glob->device_list);
> > >   	mutex_unlock(&ttm_global_mutex);
> > > +	bdev->vm_ops = &ttm_bo_vm_ops;
> > >   
> > >   	return 0;
> > >   out_no_sys:
> > > diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > > b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > > index e86a29a1e51f..bfb25b81fed7 100644
> > > --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > > +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > > @@ -395,7 +395,7 @@ static int ttm_bo_vm_access(struct
> > > vm_area_struct *vma, unsigned long addr,
> > >   	return ret;
> > >   }
> > >   
> > > -static const struct vm_operations_struct ttm_bo_vm_ops = {
> > > +const struct vm_operations_struct ttm_bo_vm_ops = {
> > >   	.fault = ttm_bo_vm_fault,
> > >   	.open = ttm_bo_vm_open,
> > >   	.close = ttm_bo_vm_close,
> > > @@ -445,7 +445,7 @@ int ttm_bo_mmap(struct file *filp, struct
> > > vm_area_struct *vma,
> > >   	if (unlikely(ret != 0))
> > >   		goto out_unref;
> > >   
> > > -	vma->vm_ops = &ttm_bo_vm_ops;
> > > +	vma->vm_ops = bdev->vm_ops;
> > >   
> > >   	/*
> > >   	 * Note: We're transferring the bo reference to
> > > @@ -477,7 +477,7 @@ int ttm_fbdev_mmap(struct vm_area_struct
> > > *vma,
> > > struct ttm_buffer_object *bo)
> > >   
> > >   	ttm_bo_get(bo);
> > >   
> > > -	vma->vm_ops = &ttm_bo_vm_ops;
> > > +	vma->vm_ops = bo->bdev->vm_ops;
> > >   	vma->vm_private_data = bo;
> > >   	vma->vm_flags |= VM_MIXEDMAP;
> > >   	vma->vm_flags |= VM_IO | VM_DONTEXPAND;
> > > diff --git a/include/drm/ttm/ttm_bo_driver.h
> > > b/include/drm/ttm/ttm_bo_driver.h
> > > index cbf3180cb612..cfeaff5d9706 100644
> > > --- a/include/drm/ttm/ttm_bo_driver.h
> > > +++ b/include/drm/ttm/ttm_bo_driver.h
> > > @@ -443,6 +443,9 @@ extern struct ttm_bo_global {
> > >    * @driver: Pointer to a struct ttm_bo_driver struct setup by
> > > the
> > > driver.
> > >    * @man: An array of mem_type_managers.
> > >    * @vma_manager: Address space manager
> > > + * @vm_ops: Pointer to the struct vm_operations_struct used for
> > > this
> > > + * device's VM operations. The driver may override this before
> > > the
> > > first
> > > + * mmap() call.
> > >    * lru_lock: Spinlock that protects the buffer+device lru lists
> > > and
> > >    * ddestroy lists.
> > >    * @dev_mapping: A pointer to the struct address_space
> > > representing the
> > > @@ -461,6 +464,7 @@ struct ttm_bo_device {
> > >   	struct ttm_bo_global *glob;
> > >   	struct ttm_bo_driver *driver;
> > >   	struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
> > > +	const struct vm_operations_struct *vm_ops;
> > >   
> > >   	/*
> > >   	 * Protected by internal locks.
> > > @@ -489,6 +493,8 @@ struct ttm_bo_device {
> > >   	bool no_retry;
> > >   };
> > >   
> > > +extern const struct vm_operations_struct ttm_bo_vm_ops;
> > > +
> > >   /**
> > >    * struct ttm_lru_bulk_move_pos
> > >    *

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct
  2019-04-24 14:10   ` Koenig, Christian
@ 2019-04-24 14:20     ` Thomas Hellstrom
  2019-04-25  8:35       ` Thomas Hellstrom
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Hellstrom @ 2019-04-24 14:20 UTC (permalink / raw)
  To: dri-devel, Linux-graphics-maintainer, Christian.Koenig
  Cc: linux-kernel, Pv-drivers

On Wed, 2019-04-24 at 14:10 +0000, Koenig, Christian wrote:
> Am 24.04.19 um 14:00 schrieb Thomas Hellstrom:
> > Add a pointer to the struct vm_operations_struct in the bo_device,
> > and
> > assign that pointer to the default value currently used.
> > 
> > The driver can then optionally modify that pointer and the new
> > value
> > can be used for each new vma created.
> > 
> > Cc: "Christian König" <christian.koenig@amd.com>
> > 
> > Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
> > Reviewed-by: Christian König <christian.koenig@amd.com>
> 
> Going to pick those two TTM patches up for amd-staging-drm-next.

Will you be relying on either patch for related work? Otherwise it
would be simpler for us to use vmwgfx-next for the whole series,
targeting 5.3.

Thomas

> 
> Christian.
> 
> > ---
> >   drivers/gpu/drm/ttm/ttm_bo.c    | 1 +
> >   drivers/gpu/drm/ttm/ttm_bo_vm.c | 6 +++---
> >   include/drm/ttm/ttm_bo_driver.h | 6 ++++++
> >   3 files changed, 10 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c
> > b/drivers/gpu/drm/ttm/ttm_bo.c
> > index 3f56647cdb35..1c85bec00472 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -1656,6 +1656,7 @@ int ttm_bo_device_init(struct ttm_bo_device
> > *bdev,
> >   	mutex_lock(&ttm_global_mutex);
> >   	list_add_tail(&bdev->device_list, &glob->device_list);
> >   	mutex_unlock(&ttm_global_mutex);
> > +	bdev->vm_ops = &ttm_bo_vm_ops;
> >   
> >   	return 0;
> >   out_no_sys:
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > index e86a29a1e51f..bfb25b81fed7 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> > @@ -395,7 +395,7 @@ static int ttm_bo_vm_access(struct
> > vm_area_struct *vma, unsigned long addr,
> >   	return ret;
> >   }
> >   
> > -static const struct vm_operations_struct ttm_bo_vm_ops = {
> > +const struct vm_operations_struct ttm_bo_vm_ops = {
> >   	.fault = ttm_bo_vm_fault,
> >   	.open = ttm_bo_vm_open,
> >   	.close = ttm_bo_vm_close,
> > @@ -445,7 +445,7 @@ int ttm_bo_mmap(struct file *filp, struct
> > vm_area_struct *vma,
> >   	if (unlikely(ret != 0))
> >   		goto out_unref;
> >   
> > -	vma->vm_ops = &ttm_bo_vm_ops;
> > +	vma->vm_ops = bdev->vm_ops;
> >   
> >   	/*
> >   	 * Note: We're transferring the bo reference to
> > @@ -477,7 +477,7 @@ int ttm_fbdev_mmap(struct vm_area_struct *vma,
> > struct ttm_buffer_object *bo)
> >   
> >   	ttm_bo_get(bo);
> >   
> > -	vma->vm_ops = &ttm_bo_vm_ops;
> > +	vma->vm_ops = bo->bdev->vm_ops;
> >   	vma->vm_private_data = bo;
> >   	vma->vm_flags |= VM_MIXEDMAP;
> >   	vma->vm_flags |= VM_IO | VM_DONTEXPAND;
> > diff --git a/include/drm/ttm/ttm_bo_driver.h
> > b/include/drm/ttm/ttm_bo_driver.h
> > index cbf3180cb612..cfeaff5d9706 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -443,6 +443,9 @@ extern struct ttm_bo_global {
> >    * @driver: Pointer to a struct ttm_bo_driver struct setup by the
> > driver.
> >    * @man: An array of mem_type_managers.
> >    * @vma_manager: Address space manager
> > + * @vm_ops: Pointer to the struct vm_operations_struct used for
> > this
> > + * device's VM operations. The driver may override this before the
> > first
> > + * mmap() call.
> >    * lru_lock: Spinlock that protects the buffer+device lru lists
> > and
> >    * ddestroy lists.
> >    * @dev_mapping: A pointer to the struct address_space
> > representing the
> > @@ -461,6 +464,7 @@ struct ttm_bo_device {
> >   	struct ttm_bo_global *glob;
> >   	struct ttm_bo_driver *driver;
> >   	struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
> > +	const struct vm_operations_struct *vm_ops;
> >   
> >   	/*
> >   	 * Protected by internal locks.
> > @@ -489,6 +493,8 @@ struct ttm_bo_device {
> >   	bool no_retry;
> >   };
> >   
> > +extern const struct vm_operations_struct ttm_bo_vm_ops;
> > +
> >   /**
> >    * struct ttm_lru_bulk_move_pos
> >    *

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct
  2019-04-24 12:00 ` [PATCH 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct Thomas Hellstrom
@ 2019-04-24 14:10   ` Koenig, Christian
  2019-04-24 14:20     ` Thomas Hellstrom
  0 siblings, 1 reply; 7+ messages in thread
From: Koenig, Christian @ 2019-04-24 14:10 UTC (permalink / raw)
  To: Thomas Hellstrom, Linux-graphics-maintainer, dri-devel
  Cc: Pv-drivers, linux-kernel

Am 24.04.19 um 14:00 schrieb Thomas Hellstrom:
> Add a pointer to the struct vm_operations_struct in the bo_device, and
> assign that pointer to the default value currently used.
>
> The driver can then optionally modify that pointer and the new value
> can be used for each new vma created.
>
> Cc: "Christian König" <christian.koenig@amd.com>
>
> Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
> Reviewed-by: Christian König <christian.koenig@amd.com>

Going to pick those two TTM patches up for amd-staging-drm-next.

Christian.

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c    | 1 +
>   drivers/gpu/drm/ttm/ttm_bo_vm.c | 6 +++---
>   include/drm/ttm/ttm_bo_driver.h | 6 ++++++
>   3 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 3f56647cdb35..1c85bec00472 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1656,6 +1656,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
>   	mutex_lock(&ttm_global_mutex);
>   	list_add_tail(&bdev->device_list, &glob->device_list);
>   	mutex_unlock(&ttm_global_mutex);
> +	bdev->vm_ops = &ttm_bo_vm_ops;
>   
>   	return 0;
>   out_no_sys:
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index e86a29a1e51f..bfb25b81fed7 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -395,7 +395,7 @@ static int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
>   	return ret;
>   }
>   
> -static const struct vm_operations_struct ttm_bo_vm_ops = {
> +const struct vm_operations_struct ttm_bo_vm_ops = {
>   	.fault = ttm_bo_vm_fault,
>   	.open = ttm_bo_vm_open,
>   	.close = ttm_bo_vm_close,
> @@ -445,7 +445,7 @@ int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
>   	if (unlikely(ret != 0))
>   		goto out_unref;
>   
> -	vma->vm_ops = &ttm_bo_vm_ops;
> +	vma->vm_ops = bdev->vm_ops;
>   
>   	/*
>   	 * Note: We're transferring the bo reference to
> @@ -477,7 +477,7 @@ int ttm_fbdev_mmap(struct vm_area_struct *vma, struct ttm_buffer_object *bo)
>   
>   	ttm_bo_get(bo);
>   
> -	vma->vm_ops = &ttm_bo_vm_ops;
> +	vma->vm_ops = bo->bdev->vm_ops;
>   	vma->vm_private_data = bo;
>   	vma->vm_flags |= VM_MIXEDMAP;
>   	vma->vm_flags |= VM_IO | VM_DONTEXPAND;
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index cbf3180cb612..cfeaff5d9706 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -443,6 +443,9 @@ extern struct ttm_bo_global {
>    * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
>    * @man: An array of mem_type_managers.
>    * @vma_manager: Address space manager
> + * @vm_ops: Pointer to the struct vm_operations_struct used for this
> + * device's VM operations. The driver may override this before the first
> + * mmap() call.
>    * lru_lock: Spinlock that protects the buffer+device lru lists and
>    * ddestroy lists.
>    * @dev_mapping: A pointer to the struct address_space representing the
> @@ -461,6 +464,7 @@ struct ttm_bo_device {
>   	struct ttm_bo_global *glob;
>   	struct ttm_bo_driver *driver;
>   	struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
> +	const struct vm_operations_struct *vm_ops;
>   
>   	/*
>   	 * Protected by internal locks.
> @@ -489,6 +493,8 @@ struct ttm_bo_device {
>   	bool no_retry;
>   };
>   
> +extern const struct vm_operations_struct ttm_bo_vm_ops;
> +
>   /**
>    * struct ttm_lru_bulk_move_pos
>    *


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct
  2019-04-24 12:00 [PATCH 0/9] Emulated coherent graphics memory v2 Thomas Hellstrom
@ 2019-04-24 12:00 ` Thomas Hellstrom
  2019-04-24 14:10   ` Koenig, Christian
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Hellstrom @ 2019-04-24 12:00 UTC (permalink / raw)
  To: Linux-graphics-maintainer, dri-devel
  Cc: Pv-drivers, Thomas Hellstrom, linux-kernel, Christian König

Add a pointer to the struct vm_operations_struct in the bo_device, and
assign that pointer to the default value currently used.

The driver can then optionally modify that pointer and the new value
can be used for each new vma created.

Cc: "Christian König" <christian.koenig@amd.com>

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c    | 1 +
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 6 +++---
 include/drm/ttm/ttm_bo_driver.h | 6 ++++++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 3f56647cdb35..1c85bec00472 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1656,6 +1656,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
 	mutex_lock(&ttm_global_mutex);
 	list_add_tail(&bdev->device_list, &glob->device_list);
 	mutex_unlock(&ttm_global_mutex);
+	bdev->vm_ops = &ttm_bo_vm_ops;
 
 	return 0;
 out_no_sys:
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index e86a29a1e51f..bfb25b81fed7 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -395,7 +395,7 @@ static int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
 	return ret;
 }
 
-static const struct vm_operations_struct ttm_bo_vm_ops = {
+const struct vm_operations_struct ttm_bo_vm_ops = {
 	.fault = ttm_bo_vm_fault,
 	.open = ttm_bo_vm_open,
 	.close = ttm_bo_vm_close,
@@ -445,7 +445,7 @@ int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
 	if (unlikely(ret != 0))
 		goto out_unref;
 
-	vma->vm_ops = &ttm_bo_vm_ops;
+	vma->vm_ops = bdev->vm_ops;
 
 	/*
 	 * Note: We're transferring the bo reference to
@@ -477,7 +477,7 @@ int ttm_fbdev_mmap(struct vm_area_struct *vma, struct ttm_buffer_object *bo)
 
 	ttm_bo_get(bo);
 
-	vma->vm_ops = &ttm_bo_vm_ops;
+	vma->vm_ops = bo->bdev->vm_ops;
 	vma->vm_private_data = bo;
 	vma->vm_flags |= VM_MIXEDMAP;
 	vma->vm_flags |= VM_IO | VM_DONTEXPAND;
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index cbf3180cb612..cfeaff5d9706 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -443,6 +443,9 @@ extern struct ttm_bo_global {
  * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
  * @man: An array of mem_type_managers.
  * @vma_manager: Address space manager
+ * @vm_ops: Pointer to the struct vm_operations_struct used for this
+ * device's VM operations. The driver may override this before the first
+ * mmap() call.
  * lru_lock: Spinlock that protects the buffer+device lru lists and
  * ddestroy lists.
  * @dev_mapping: A pointer to the struct address_space representing the
@@ -461,6 +464,7 @@ struct ttm_bo_device {
 	struct ttm_bo_global *glob;
 	struct ttm_bo_driver *driver;
 	struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
+	const struct vm_operations_struct *vm_ops;
 
 	/*
 	 * Protected by internal locks.
@@ -489,6 +493,8 @@ struct ttm_bo_device {
 	bool no_retry;
 };
 
+extern const struct vm_operations_struct ttm_bo_vm_ops;
+
 /**
  * struct ttm_lru_bulk_move_pos
  *
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct
  2019-04-12 16:04 ` [PATCH 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct Thomas Hellstrom
@ 2019-04-13 18:39   ` Koenig, Christian
  0 siblings, 0 replies; 7+ messages in thread
From: Koenig, Christian @ 2019-04-13 18:39 UTC (permalink / raw)
  To: Thomas Hellstrom, dri-devel, Linux-graphics-maintainer, linux-kernel

Am 12.04.19 um 18:04 schrieb Thomas Hellstrom:
> Add a pointer to the struct vm_operations_struct in the bo_device, and
> assign that pointer to the default value currently used.
>
> The driver can then optionally modify that pointer and the new value
> can be used for each new vma created.
>
> Cc: "Christian König" <christian.koenig@amd.com>
> Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>

Yes, please. This way we can also finally cleanup the VM operations hack 
we use in radeon and maybe still even amdgpu.

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c    | 1 +
>   drivers/gpu/drm/ttm/ttm_bo_vm.c | 6 +++---
>   include/drm/ttm/ttm_bo_driver.h | 6 ++++++
>   3 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 3f56647cdb35..1c85bec00472 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1656,6 +1656,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
>   	mutex_lock(&ttm_global_mutex);
>   	list_add_tail(&bdev->device_list, &glob->device_list);
>   	mutex_unlock(&ttm_global_mutex);
> +	bdev->vm_ops = &ttm_bo_vm_ops;
>   
>   	return 0;
>   out_no_sys:
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index e86a29a1e51f..bfb25b81fed7 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -395,7 +395,7 @@ static int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
>   	return ret;
>   }
>   
> -static const struct vm_operations_struct ttm_bo_vm_ops = {
> +const struct vm_operations_struct ttm_bo_vm_ops = {
>   	.fault = ttm_bo_vm_fault,
>   	.open = ttm_bo_vm_open,
>   	.close = ttm_bo_vm_close,
> @@ -445,7 +445,7 @@ int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
>   	if (unlikely(ret != 0))
>   		goto out_unref;
>   
> -	vma->vm_ops = &ttm_bo_vm_ops;
> +	vma->vm_ops = bdev->vm_ops;
>   
>   	/*
>   	 * Note: We're transferring the bo reference to
> @@ -477,7 +477,7 @@ int ttm_fbdev_mmap(struct vm_area_struct *vma, struct ttm_buffer_object *bo)
>   
>   	ttm_bo_get(bo);
>   
> -	vma->vm_ops = &ttm_bo_vm_ops;
> +	vma->vm_ops = bo->bdev->vm_ops;
>   	vma->vm_private_data = bo;
>   	vma->vm_flags |= VM_MIXEDMAP;
>   	vma->vm_flags |= VM_IO | VM_DONTEXPAND;
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index cbf3180cb612..cfeaff5d9706 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -443,6 +443,9 @@ extern struct ttm_bo_global {
>    * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
>    * @man: An array of mem_type_managers.
>    * @vma_manager: Address space manager
> + * @vm_ops: Pointer to the struct vm_operations_struct used for this
> + * device's VM operations. The driver may override this before the first
> + * mmap() call.
>    * lru_lock: Spinlock that protects the buffer+device lru lists and
>    * ddestroy lists.
>    * @dev_mapping: A pointer to the struct address_space representing the
> @@ -461,6 +464,7 @@ struct ttm_bo_device {
>   	struct ttm_bo_global *glob;
>   	struct ttm_bo_driver *driver;
>   	struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
> +	const struct vm_operations_struct *vm_ops;
>   
>   	/*
>   	 * Protected by internal locks.
> @@ -489,6 +493,8 @@ struct ttm_bo_device {
>   	bool no_retry;
>   };
>   
> +extern const struct vm_operations_struct ttm_bo_vm_ops;
> +
>   /**
>    * struct ttm_lru_bulk_move_pos
>    *

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct
  2019-04-12 16:04 [PATCH 0/9] Emulated coherent graphics memory Thomas Hellstrom
@ 2019-04-12 16:04 ` Thomas Hellstrom
  2019-04-13 18:39   ` Koenig, Christian
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Hellstrom @ 2019-04-12 16:04 UTC (permalink / raw)
  To: dri-devel, Linux-graphics-maintainer, linux-kernel
  Cc: Thomas Hellstrom, Christian König

Add a pointer to the struct vm_operations_struct in the bo_device, and
assign that pointer to the default value currently used.

The driver can then optionally modify that pointer and the new value
can be used for each new vma created.

Cc: "Christian König" <christian.koenig@amd.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c    | 1 +
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 6 +++---
 include/drm/ttm/ttm_bo_driver.h | 6 ++++++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 3f56647cdb35..1c85bec00472 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1656,6 +1656,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
 	mutex_lock(&ttm_global_mutex);
 	list_add_tail(&bdev->device_list, &glob->device_list);
 	mutex_unlock(&ttm_global_mutex);
+	bdev->vm_ops = &ttm_bo_vm_ops;
 
 	return 0;
 out_no_sys:
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index e86a29a1e51f..bfb25b81fed7 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -395,7 +395,7 @@ static int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
 	return ret;
 }
 
-static const struct vm_operations_struct ttm_bo_vm_ops = {
+const struct vm_operations_struct ttm_bo_vm_ops = {
 	.fault = ttm_bo_vm_fault,
 	.open = ttm_bo_vm_open,
 	.close = ttm_bo_vm_close,
@@ -445,7 +445,7 @@ int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
 	if (unlikely(ret != 0))
 		goto out_unref;
 
-	vma->vm_ops = &ttm_bo_vm_ops;
+	vma->vm_ops = bdev->vm_ops;
 
 	/*
 	 * Note: We're transferring the bo reference to
@@ -477,7 +477,7 @@ int ttm_fbdev_mmap(struct vm_area_struct *vma, struct ttm_buffer_object *bo)
 
 	ttm_bo_get(bo);
 
-	vma->vm_ops = &ttm_bo_vm_ops;
+	vma->vm_ops = bo->bdev->vm_ops;
 	vma->vm_private_data = bo;
 	vma->vm_flags |= VM_MIXEDMAP;
 	vma->vm_flags |= VM_IO | VM_DONTEXPAND;
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index cbf3180cb612..cfeaff5d9706 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -443,6 +443,9 @@ extern struct ttm_bo_global {
  * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
  * @man: An array of mem_type_managers.
  * @vma_manager: Address space manager
+ * @vm_ops: Pointer to the struct vm_operations_struct used for this
+ * device's VM operations. The driver may override this before the first
+ * mmap() call.
  * lru_lock: Spinlock that protects the buffer+device lru lists and
  * ddestroy lists.
  * @dev_mapping: A pointer to the struct address_space representing the
@@ -461,6 +464,7 @@ struct ttm_bo_device {
 	struct ttm_bo_global *glob;
 	struct ttm_bo_driver *driver;
 	struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
+	const struct vm_operations_struct *vm_ops;
 
 	/*
 	 * Protected by internal locks.
@@ -489,6 +493,8 @@ struct ttm_bo_device {
 	bool no_retry;
 };
 
+extern const struct vm_operations_struct ttm_bo_vm_ops;
+
 /**
  * struct ttm_lru_bulk_move_pos
  *
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-04-25  9:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-25  9:11 [PATCH 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct Koenig, Christian
  -- strict thread matches above, loose matches on Subject: below --
2019-04-24 12:00 [PATCH 0/9] Emulated coherent graphics memory v2 Thomas Hellstrom
2019-04-24 12:00 ` [PATCH 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct Thomas Hellstrom
2019-04-24 14:10   ` Koenig, Christian
2019-04-24 14:20     ` Thomas Hellstrom
2019-04-25  8:35       ` Thomas Hellstrom
2019-04-12 16:04 [PATCH 0/9] Emulated coherent graphics memory Thomas Hellstrom
2019-04-12 16:04 ` [PATCH 4/9] drm/ttm: Allow the driver to provide the ttm struct vm_operations_struct Thomas Hellstrom
2019-04-13 18:39   ` Koenig, Christian

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).