diff mbox series

drm/vmwgfx: reserve fence slots on new resources

Message ID 20220422092002.32427-1-christian.koenig@amd.com (mailing list archive)
State New, archived
Headers show
Series drm/vmwgfx: reserve fence slots on new resources | expand

Commit Message

Christian König April 22, 2022, 9:20 a.m. UTC
When resources are allocated dynamically during an IOCTL we need to make sure
that a fence slot is reserved so that the resulting fence can be added in the
end.

Signed-off-by: Christian König <christian.koenig@amd.com>
Fixes: c8d4c18bfbc4 ("dma-buf/drivers: make reserving a shared slot mandatory v4")
---
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Christian König April 22, 2022, 9:21 a.m. UTC | #1
Am 22.04.22 um 11:20 schrieb Christian König:
> When resources are allocated dynamically during an IOCTL we need to make sure
> that a fence slot is reserved so that the resulting fence can be added in the
> end.

I should probably add that this is only compile tested.

Zack you should probably give it a try for your issue.

Thanks for the help and sorry for the noise,
Christian.

>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> Fixes: c8d4c18bfbc4 ("dma-buf/drivers: make reserving a shared slot mandatory v4")
> ---
>   drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
> index a7d62a4eb47b..edce228f737c 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
> @@ -399,6 +399,10 @@ static int vmw_resource_do_validate(struct vmw_resource *res,
>   		ret = func->create(res);
>   		if (unlikely(ret != 0))
>   			return ret;
> +
> +		ret = dma_resv_reserve_fences(res->backup->base.base.resv, 1);
> +		if (unlikely(ret))
> +			goto out_bind_failed;
>   	}
>   
>   	if (func->bind &&
Zack Rusin April 22, 2022, 4:13 p.m. UTC | #2
On Fri, 2022-04-22 at 11:21 +0200, Christian König wrote:
> Am 22.04.22 um 11:20 schrieb Christian König:
> > When resources are allocated dynamically during an IOCTL we need to
> > make sure
> > that a fence slot is reserved so that the resulting fence can be
> > added in the
> > end.
> 
> I should probably add that this is only compile tested.
> 
> Zack you should probably give it a try for your issue.

I think we're on the right track but cotables are the only objects that
create a bo in the create callback so we endup double reserving all the
other backup objects. If you don't mind I'd prefer to move the code to
localize the reservation to the problematic spot. I'll send it in a sec
(6d0fdf27e98a ("drm/vmwgfx: Reserve fence slots on buffer objects in
cotables") let me know if I can add a Co-developed-by: Christian König
<christian.koenig@amd.com> tag to it.

z
Christian König April 22, 2022, 7:23 p.m. UTC | #3
Am 22.04.22 um 18:13 schrieb Zack Rusin:
> On Fri, 2022-04-22 at 11:21 +0200, Christian König wrote:
>> Am 22.04.22 um 11:20 schrieb Christian König:
>>> When resources are allocated dynamically during an IOCTL we need to
>>> make sure
>>> that a fence slot is reserved so that the resulting fence can be
>>> added in the
>>> end.
>> I should probably add that this is only compile tested.
>>
>> Zack you should probably give it a try for your issue.
> I think we're on the right track but cotables are the only objects that
> create a bo in the create callback so we endup double reserving all the
> other backup objects. If you don't mind I'd prefer to move the code to
> localize the reservation to the problematic spot. I'll send it in a sec
> (6d0fdf27e98a ("drm/vmwgfx: Reserve fence slots on buffer objects in
> cotables") let me know if I can add a Co-developed-by: Christian König
> <christian.koenig@amd.com> tag to it.

Sure, please go ahead. You know the code much better than I do anyway.

Thanks,
Christian.

>
> z
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index a7d62a4eb47b..edce228f737c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -399,6 +399,10 @@  static int vmw_resource_do_validate(struct vmw_resource *res,
 		ret = func->create(res);
 		if (unlikely(ret != 0))
 			return ret;
+
+		ret = dma_resv_reserve_fences(res->backup->base.base.resv, 1);
+		if (unlikely(ret))
+			goto out_bind_failed;
 	}
 
 	if (func->bind &&