diff mbox series

[v2,4/4] drm/qxl: use qxl pin function

Message ID 20200929095115.24430-5-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show
Series drm/qxl: fix stale mm entries on driver shutdown | expand

Commit Message

Gerd Hoffmann Sept. 29, 2020, 9:51 a.m. UTC
Otherwise ttm throws a WARN because we try to pin without a reservation.

Fixes: 9d36d4320462 ("drm/qxl: switch over to the new pin interface")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/qxl/qxl_object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Daniel Vetter Sept. 29, 2020, 10:53 a.m. UTC | #1
On Tue, Sep 29, 2020 at 11:51:15AM +0200, Gerd Hoffmann wrote:
> Otherwise ttm throws a WARN because we try to pin without a reservation.
> 
> Fixes: 9d36d4320462 ("drm/qxl: switch over to the new pin interface")
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  drivers/gpu/drm/qxl/qxl_object.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
> index d3635e3e3267..eb45267d51db 100644
> --- a/drivers/gpu/drm/qxl/qxl_object.c
> +++ b/drivers/gpu/drm/qxl/qxl_object.c
> @@ -145,7 +145,7 @@ int qxl_bo_create(struct qxl_device *qdev,
>  		return r;
>  	}
>  	if (pinned)
> -		ttm_bo_pin(&bo->tbo);
> +		qxl_bo_pin(bo);

I think this is now after ttm_bo_init, and at that point the object is
visible to lru users and everything. So I do think you need to grab locks
here instead of just incrementing the pin count alone.

It's also I think a bit racy, since ttm_bo_init drops the lock, so someone
might have snuck in and evicted the object already.

I think what you need is to call ttm_bo_init_reserved, then ttm_bo_pin,
then ttm_bo_unreserve, all explicitly.
-Daniel

>  	*bo_ptr = bo;
>  	return 0;
>  }
> -- 
> 2.27.0
>
Christian König Sept. 29, 2020, 11:24 a.m. UTC | #2
Am 29.09.20 um 12:53 schrieb Daniel Vetter:
> On Tue, Sep 29, 2020 at 11:51:15AM +0200, Gerd Hoffmann wrote:
>> Otherwise ttm throws a WARN because we try to pin without a reservation.
>>
>> Fixes: 9d36d4320462 ("drm/qxl: switch over to the new pin interface")
>> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>> ---
>>   drivers/gpu/drm/qxl/qxl_object.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
>> index d3635e3e3267..eb45267d51db 100644
>> --- a/drivers/gpu/drm/qxl/qxl_object.c
>> +++ b/drivers/gpu/drm/qxl/qxl_object.c
>> @@ -145,7 +145,7 @@ int qxl_bo_create(struct qxl_device *qdev,
>>   		return r;
>>   	}
>>   	if (pinned)
>> -		ttm_bo_pin(&bo->tbo);
>> +		qxl_bo_pin(bo);
> I think this is now after ttm_bo_init, and at that point the object is
> visible to lru users and everything. So I do think you need to grab locks
> here instead of just incrementing the pin count alone.
>
> It's also I think a bit racy, since ttm_bo_init drops the lock, so someone
> might have snuck in and evicted the object already.
>
> I think what you need is to call ttm_bo_init_reserved, then ttm_bo_pin,
> then ttm_bo_unreserve, all explicitly.

Ah, yes Daniel is right. I thought I've fixed that up, but looks like I 
only did that for VMWGFX.

Sorry for the noise, fix to correctly address this is underway.

Regards,
Christian.

> -Daniel
>
>>   	*bo_ptr = bo;
>>   	return 0;
>>   }
>> -- 
>> 2.27.0
>>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
index d3635e3e3267..eb45267d51db 100644
--- a/drivers/gpu/drm/qxl/qxl_object.c
+++ b/drivers/gpu/drm/qxl/qxl_object.c
@@ -145,7 +145,7 @@  int qxl_bo_create(struct qxl_device *qdev,
 		return r;
 	}
 	if (pinned)
-		ttm_bo_pin(&bo->tbo);
+		qxl_bo_pin(bo);
 	*bo_ptr = bo;
 	return 0;
 }