diff mbox series

[44/59] drm/ttm: allow drivers to provide their own manager subclasses

Message ID 20200804025632.3868079-45-airlied@gmail.com (mailing list archive)
State New, archived
Headers show
Series ttm misc cleanups, mem refactoring, rename objects. (v2) | expand

Commit Message

Dave Airlie Aug. 4, 2020, 2:56 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

This will get removed eventually and all drivers will use this.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 include/drm/ttm/ttm_bo_driver.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Christian König Aug. 4, 2020, 11:30 a.m. UTC | #1
Am 04.08.20 um 04:56 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This will get removed eventually and all drivers will use this.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

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

> ---
>   include/drm/ttm/ttm_bo_driver.h | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 03b253d14e6a..6940d85a531a 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -419,7 +419,7 @@ struct ttm_bo_device {
>   	 * access via ttm_manager_type.
>   	 */
>   	struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES];
> -
> +	struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
>   	/*
>   	 * Protected by internal locks.
>   	 */
> @@ -450,9 +450,18 @@ struct ttm_bo_device {
>   static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
>   							    int mem_type)
>   {
> +	if (bdev->man_drv[mem_type])
> +		return bdev->man_drv[mem_type];
>   	return &bdev->man_priv[mem_type];
>   }
>   
> +static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
> +					  int type,
> +					  struct ttm_mem_type_manager *manager)
> +{
> +	bdev->man_drv[type] = manager;
> +}
> +
>   /**
>    * struct ttm_lru_bulk_move_pos
>    *
Ben Skeggs Aug. 5, 2020, 5:49 a.m. UTC | #2
On Tue, 4 Aug 2020 at 21:30, Christian König <christian.koenig@amd.com> wrote:
>
> Am 04.08.20 um 04:56 schrieb Dave Airlie:
> > From: Dave Airlie <airlied@redhat.com>
> >
> > This will get removed eventually and all drivers will use this.
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>

>
> > ---
> >   include/drm/ttm/ttm_bo_driver.h | 11 ++++++++++-
> >   1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> > index 03b253d14e6a..6940d85a531a 100644
> > --- a/include/drm/ttm/ttm_bo_driver.h
> > +++ b/include/drm/ttm/ttm_bo_driver.h
> > @@ -419,7 +419,7 @@ struct ttm_bo_device {
> >        * access via ttm_manager_type.
> >        */
> >       struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES];
> > -
> > +     struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
> >       /*
> >        * Protected by internal locks.
> >        */
> > @@ -450,9 +450,18 @@ struct ttm_bo_device {
> >   static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
> >                                                           int mem_type)
> >   {
> > +     if (bdev->man_drv[mem_type])
> > +             return bdev->man_drv[mem_type];
> >       return &bdev->man_priv[mem_type];
> >   }
> >
> > +static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
> > +                                       int type,
> > +                                       struct ttm_mem_type_manager *manager)
> > +{
> > +     bdev->man_drv[type] = manager;
> > +}
> > +
> >   /**
> >    * struct ttm_lru_bulk_move_pos
> >    *
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 03b253d14e6a..6940d85a531a 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -419,7 +419,7 @@  struct ttm_bo_device {
 	 * access via ttm_manager_type.
 	 */
 	struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES];
-
+	struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES];
 	/*
 	 * Protected by internal locks.
 	 */
@@ -450,9 +450,18 @@  struct ttm_bo_device {
 static inline struct ttm_mem_type_manager *ttm_manager_type(struct ttm_bo_device *bdev,
 							    int mem_type)
 {
+	if (bdev->man_drv[mem_type])
+		return bdev->man_drv[mem_type];
 	return &bdev->man_priv[mem_type];
 }
 
+static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
+					  int type,
+					  struct ttm_mem_type_manager *manager)
+{
+	bdev->man_drv[type] = manager;
+}
+
 /**
  * struct ttm_lru_bulk_move_pos
  *