linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/vmwgfx: Replace deprecated PTR_RET
@ 2019-12-08 10:53 Lukas Bulwahn
  2019-12-09 10:21 ` Julia Lawall
  2019-12-09 14:08 ` Thomas Hellstrom
  0 siblings, 2 replies; 4+ messages in thread
From: Lukas Bulwahn @ 2019-12-08 10:53 UTC (permalink / raw)
  To: Thomas Hellstrom, dri-devel
  Cc: David Airlie, Daniel Vetter, Sinclair Yeh,
	linux-graphics-maintainer, kernel-janitors, linux-kernel,
	Lukas Bulwahn

Commit 508108ea2747 ("drm/vmwgfx: Don't refcount command-buffer managed
resource lookups during command buffer validation") slips in use of
deprecated PTR_RET. Use PTR_ERR_OR_ZERO instead.

As the PTR_ERR_OR_ZERO is a bit longer than PTR_RET, we introduce
local variable ret for proper indentation and line-length limits.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
---
applies cleanly on current master (9455d25f4e3b) and next-20191207
compile-tested on x86_64_defconfig + DRM_VMWGFX=y

 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 934ad7c0c342..73489a45decb 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -2377,9 +2377,12 @@ static int vmw_cmd_dx_clear_rendertarget_view(struct vmw_private *dev_priv,
 {
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXClearRenderTargetView) =
 		container_of(header, typeof(*cmd), header);
+	struct vmw_resource *ret;
 
-	return PTR_RET(vmw_view_id_val_add(sw_context, vmw_view_rt,
-					   cmd->body.renderTargetViewId));
+	ret = vmw_view_id_val_add(sw_context, vmw_view_rt,
+				  cmd->body.renderTargetViewId);
+
+	return PTR_ERR_OR_ZERO(ret);
 }
 
 /**
@@ -2396,9 +2399,12 @@ static int vmw_cmd_dx_clear_depthstencil_view(struct vmw_private *dev_priv,
 {
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXClearDepthStencilView) =
 		container_of(header, typeof(*cmd), header);
+	struct vmw_resource *ret;
+
+	ret = vmw_view_id_val_add(sw_context, vmw_view_ds,
+				  cmd->body.depthStencilViewId);
 
-	return PTR_RET(vmw_view_id_val_add(sw_context, vmw_view_ds,
-					   cmd->body.depthStencilViewId));
+	return PTR_ERR_OR_ZERO(ret);
 }
 
 static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv,
@@ -2741,9 +2747,12 @@ static int vmw_cmd_dx_genmips(struct vmw_private *dev_priv,
 {
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXGenMips) =
 		container_of(header, typeof(*cmd), header);
+	struct vmw_resource *ret;
+
+	ret = vmw_view_id_val_add(sw_context, vmw_view_sr,
+				  cmd->body.shaderResourceViewId);
 
-	return PTR_RET(vmw_view_id_val_add(sw_context, vmw_view_sr,
-					   cmd->body.shaderResourceViewId));
+	return PTR_ERR_OR_ZERO(ret);
 }
 
 /**
-- 
2.17.1


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

* Re: [PATCH] drm/vmwgfx: Replace deprecated PTR_RET
  2019-12-08 10:53 [PATCH] drm/vmwgfx: Replace deprecated PTR_RET Lukas Bulwahn
@ 2019-12-09 10:21 ` Julia Lawall
  2019-12-09 19:05   ` Lukas Bulwahn
  2019-12-09 14:08 ` Thomas Hellstrom
  1 sibling, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2019-12-09 10:21 UTC (permalink / raw)
  To: Lukas Bulwahn
  Cc: Thomas Hellstrom, dri-devel, David Airlie, Daniel Vetter,
	Sinclair Yeh, linux-graphics-maintainer, kernel-janitors,
	linux-kernel

> De: "Lukas Bulwahn" <lukas.bulwahn@gmail.com>
> À: "Thomas Hellstrom" <thellstrom@vmware.com>, dri-devel@lists.freedesktop.org
> Cc: "David Airlie" <airlied@linux.ie>, "Daniel Vetter" <daniel@ffwll.ch>, "Sinclair Yeh" <syeh@vmware.com>,
> linux-graphics-maintainer@vmware.com, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, "Lukas Bulwahn"
> <lukas.bulwahn@gmail.com>
> Envoyé: Dimanche 8 Décembre 2019 18:53:28
> Objet: [PATCH] drm/vmwgfx: Replace deprecated PTR_RET

> Commit 508108ea2747 ("drm/vmwgfx: Don't refcount command-buffer managed
> resource lookups during command buffer validation") slips in use of
> deprecated PTR_RET. Use PTR_ERR_OR_ZERO instead.
> 
> As the PTR_ERR_OR_ZERO is a bit longer than PTR_RET, we introduce
> local variable ret for proper indentation and line-length limits.

Is 0 actually possible?  I have the impression that it is not, but perhaps I missed something.

julia


> Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
> ---
> applies cleanly on current master (9455d25f4e3b) and next-20191207
> compile-tested on x86_64_defconfig + DRM_VMWGFX=y
> 
> drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 21 +++++++++++++++------
> 1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> index 934ad7c0c342..73489a45decb 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> @@ -2377,9 +2377,12 @@ static int vmw_cmd_dx_clear_rendertarget_view(struct
> vmw_private *dev_priv,
> {
> 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXClearRenderTargetView) =
> 		container_of(header, typeof(*cmd), header);
> +	struct vmw_resource *ret;
> 
> -	return PTR_RET(vmw_view_id_val_add(sw_context, vmw_view_rt,
> -					   cmd->body.renderTargetViewId));
> +	ret = vmw_view_id_val_add(sw_context, vmw_view_rt,
> +				  cmd->body.renderTargetViewId);
> +
> +	return PTR_ERR_OR_ZERO(ret);
> }
> 
> /**
> @@ -2396,9 +2399,12 @@ static int vmw_cmd_dx_clear_depthstencil_view(struct
> vmw_private *dev_priv,
> {
> 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXClearDepthStencilView) =
> 		container_of(header, typeof(*cmd), header);
> +	struct vmw_resource *ret;
> +
> +	ret = vmw_view_id_val_add(sw_context, vmw_view_ds,
> +				  cmd->body.depthStencilViewId);
> 
> -	return PTR_RET(vmw_view_id_val_add(sw_context, vmw_view_ds,
> -					   cmd->body.depthStencilViewId));
> +	return PTR_ERR_OR_ZERO(ret);
> }
> 
> static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv,
> @@ -2741,9 +2747,12 @@ static int vmw_cmd_dx_genmips(struct vmw_private
> *dev_priv,
> {
> 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXGenMips) =
> 		container_of(header, typeof(*cmd), header);
> +	struct vmw_resource *ret;
> +
> +	ret = vmw_view_id_val_add(sw_context, vmw_view_sr,
> +				  cmd->body.shaderResourceViewId);
> 
> -	return PTR_RET(vmw_view_id_val_add(sw_context, vmw_view_sr,
> -					   cmd->body.shaderResourceViewId));
> +	return PTR_ERR_OR_ZERO(ret);
> }
> 
> /**
> --
> 2.17.1

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

* Re: [PATCH] drm/vmwgfx: Replace deprecated PTR_RET
  2019-12-08 10:53 [PATCH] drm/vmwgfx: Replace deprecated PTR_RET Lukas Bulwahn
  2019-12-09 10:21 ` Julia Lawall
@ 2019-12-09 14:08 ` Thomas Hellstrom
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Hellstrom @ 2019-12-09 14:08 UTC (permalink / raw)
  To: dri-devel, lukas.bulwahn
  Cc: daniel, syeh, Linux-graphics-maintainer, linux-kernel, airlied,
	kernel-janitors

On Sun, 2019-12-08 at 11:53 +0100, Lukas Bulwahn wrote:
> Commit 508108ea2747 ("drm/vmwgfx: Don't refcount command-buffer
> managed
> resource lookups during command buffer validation") slips in use of
> deprecated PTR_RET. Use PTR_ERR_OR_ZERO instead.
> 
> As the PTR_ERR_OR_ZERO is a bit longer than PTR_RET, we introduce
> local variable ret for proper indentation and line-length limits.
> 
> Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
> ---
> applies cleanly on current master (9455d25f4e3b) and next-20191207
> compile-tested on x86_64_defconfig + DRM_VMWGFX=y
> 
>  drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> index 934ad7c0c342..73489a45decb 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> @@ -2377,9 +2377,12 @@ static int
> vmw_cmd_dx_clear_rendertarget_view(struct vmw_private *dev_priv,
>  {
>  	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXClearRenderTargetView) =
>  		container_of(header, typeof(*cmd), header);
> +	struct vmw_resource *ret;
>  
> -	return PTR_RET(vmw_view_id_val_add(sw_context, vmw_view_rt,
> -					   cmd-
> >body.renderTargetViewId));
> +	ret = vmw_view_id_val_add(sw_context, vmw_view_rt,
> +				  cmd->body.renderTargetViewId);
> +
> +	return PTR_ERR_OR_ZERO(ret);
>  }
>  
>  /**
> @@ -2396,9 +2399,12 @@ static int
> vmw_cmd_dx_clear_depthstencil_view(struct vmw_private *dev_priv,
>  {
>  	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXClearDepthStencilView) =
>  		container_of(header, typeof(*cmd), header);
> +	struct vmw_resource *ret;
> +
> +	ret = vmw_view_id_val_add(sw_context, vmw_view_ds,
> +				  cmd->body.depthStencilViewId);
>  
> -	return PTR_RET(vmw_view_id_val_add(sw_context, vmw_view_ds,
> -					   cmd-
> >body.depthStencilViewId));
> +	return PTR_ERR_OR_ZERO(ret);
>  }
>  
>  static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv,
> @@ -2741,9 +2747,12 @@ static int vmw_cmd_dx_genmips(struct
> vmw_private *dev_priv,
>  {
>  	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXGenMips) =
>  		container_of(header, typeof(*cmd), header);
> +	struct vmw_resource *ret;
> +
> +	ret = vmw_view_id_val_add(sw_context, vmw_view_sr,
> +				  cmd->body.shaderResourceViewId);
>  
> -	return PTR_RET(vmw_view_id_val_add(sw_context, vmw_view_sr,
> -					   cmd-
> >body.shaderResourceViewId));
> +	return PTR_ERR_OR_ZERO(ret);
>  }
>  
>  /**

Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>

I will include this in vmwgfx-next.
Thanks,
Thomas


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

* Re: [PATCH] drm/vmwgfx: Replace deprecated PTR_RET
  2019-12-09 10:21 ` Julia Lawall
@ 2019-12-09 19:05   ` Lukas Bulwahn
  0 siblings, 0 replies; 4+ messages in thread
From: Lukas Bulwahn @ 2019-12-09 19:05 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Thomas Hellstrom, dri-devel, David Airlie, Daniel Vetter,
	Sinclair Yeh, linux-graphics-maintainer, kernel-janitors,
	Linux Kernel Mailing List

On Mon, Dec 9, 2019 at 11:21 AM Julia Lawall <julia.lawall@inria.fr> wrote:
>
> > De: "Lukas Bulwahn" <lukas.bulwahn@gmail.com>
> > À: "Thomas Hellstrom" <thellstrom@vmware.com>, dri-devel@lists.freedesktop.org
> > Cc: "David Airlie" <airlied@linux.ie>, "Daniel Vetter" <daniel@ffwll.ch>, "Sinclair Yeh" <syeh@vmware.com>,
> > linux-graphics-maintainer@vmware.com, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, "Lukas Bulwahn"
> > <lukas.bulwahn@gmail.com>
> > Envoyé: Dimanche 8 Décembre 2019 18:53:28
> > Objet: [PATCH] drm/vmwgfx: Replace deprecated PTR_RET
>
> > Commit 508108ea2747 ("drm/vmwgfx: Don't refcount command-buffer managed
> > resource lookups during command buffer validation") slips in use of
> > deprecated PTR_RET. Use PTR_ERR_OR_ZERO instead.
> >
> > As the PTR_ERR_OR_ZERO is a bit longer than PTR_RET, we introduce
> > local variable ret for proper indentation and line-length limits.
>
> Is 0 actually possible?  I have the impression that it is not, but perhaps I missed something.
>

I did not sanity-check if 0 is possible before patch submission, just
cleaning the syntatic stuff here to prepare final removal of the
deprecated PTR_RET.
But as far as I see:

vmw_cmd_dx_clear_rendertarget_view
-> vmw_view_id_val_add
-> vmw_view_lookup
-> vmw_cmdbuf_res_lookup

which would then return a proper pointer/a non PTR_ERR value and
hence, it would be possible that PTR_ERR_OR_ZERO returns 0. It all
looks pretty sane.

Lukas

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

end of thread, other threads:[~2019-12-09 20:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-08 10:53 [PATCH] drm/vmwgfx: Replace deprecated PTR_RET Lukas Bulwahn
2019-12-09 10:21 ` Julia Lawall
2019-12-09 19:05   ` Lukas Bulwahn
2019-12-09 14:08 ` Thomas Hellstrom

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