diff mbox series

[5/7] accel/qaic: Call drm_gem_create_mmap_offset() once for each BO

Message ID 20231208163457.1295993-6-quic_jhugo@quicinc.com (mailing list archive)
State New, archived
Headers show
Series qaic cleanups for 6.8 | expand

Commit Message

Jeffrey Hugo Dec. 8, 2023, 4:34 p.m. UTC
From: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>

Every time QAIC_MMAP_BO ioctl is called for a BO,
drm_gem_create_mmap_offset() is called. Calling
drm_gem_create_mmap_offset() more then once for a BO seems redundant.

Signed-off-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
---
 drivers/accel/qaic/qaic_data.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Jacek Lawrynowicz Dec. 11, 2023, 11:26 a.m. UTC | #1
Reviewed-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>

On 08.12.2023 17:34, Jeffrey Hugo wrote:
> From: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
> 
> Every time QAIC_MMAP_BO ioctl is called for a BO,
> drm_gem_create_mmap_offset() is called. Calling
> drm_gem_create_mmap_offset() more then once for a BO seems redundant.
> 
> Signed-off-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com>
> Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
> Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
> ---
>  drivers/accel/qaic/qaic_data.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
> index 7faa00705c1d..f88d925c8001 100644
> --- a/drivers/accel/qaic/qaic_data.c
> +++ b/drivers/accel/qaic/qaic_data.c
> @@ -718,6 +718,10 @@ int qaic_create_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *fi
>  	if (ret)
>  		goto free_bo;
>  
> +	ret = drm_gem_create_mmap_offset(obj);
> +	if (ret)
> +		goto free_bo;
> +
>  	ret = drm_gem_handle_create(file_priv, obj, &args->handle);
>  	if (ret)
>  		goto free_bo;
> @@ -745,7 +749,7 @@ int qaic_mmap_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *file
>  	struct drm_gem_object *obj;
>  	struct qaic_device *qdev;
>  	struct qaic_user *usr;
> -	int ret;
> +	int ret = 0;
>  
>  	usr = file_priv->driver_priv;
>  	usr_rcu_id = srcu_read_lock(&usr->qddev_lock);
> @@ -767,9 +771,7 @@ int qaic_mmap_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *file
>  		goto unlock_dev_srcu;
>  	}
>  
> -	ret = drm_gem_create_mmap_offset(obj);
> -	if (ret == 0)
> -		args->offset = drm_vma_node_offset_addr(&obj->vma_node);
> +	args->offset = drm_vma_node_offset_addr(&obj->vma_node);
>  
>  	drm_gem_object_put(obj);
>
diff mbox series

Patch

diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
index 7faa00705c1d..f88d925c8001 100644
--- a/drivers/accel/qaic/qaic_data.c
+++ b/drivers/accel/qaic/qaic_data.c
@@ -718,6 +718,10 @@  int qaic_create_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *fi
 	if (ret)
 		goto free_bo;
 
+	ret = drm_gem_create_mmap_offset(obj);
+	if (ret)
+		goto free_bo;
+
 	ret = drm_gem_handle_create(file_priv, obj, &args->handle);
 	if (ret)
 		goto free_bo;
@@ -745,7 +749,7 @@  int qaic_mmap_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *file
 	struct drm_gem_object *obj;
 	struct qaic_device *qdev;
 	struct qaic_user *usr;
-	int ret;
+	int ret = 0;
 
 	usr = file_priv->driver_priv;
 	usr_rcu_id = srcu_read_lock(&usr->qddev_lock);
@@ -767,9 +771,7 @@  int qaic_mmap_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *file
 		goto unlock_dev_srcu;
 	}
 
-	ret = drm_gem_create_mmap_offset(obj);
-	if (ret == 0)
-		args->offset = drm_vma_node_offset_addr(&obj->vma_node);
+	args->offset = drm_vma_node_offset_addr(&obj->vma_node);
 
 	drm_gem_object_put(obj);