dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: thellstrom@vmware.com
Cc: dri-devel@lists.freedesktop.org
Subject: [bug report] vmwgfx: Implement fence objects
Date: Fri, 10 Sep 2021 10:30:14 +0300	[thread overview]
Message-ID: <20210910073014.GA32250@kili> (raw)

Hello Thomas Hellstrom,

The patch ae2a104058e2: "vmwgfx: Implement fence objects" from Sep 1,
2011, leads to the following
Smatch static checker warning:

	drivers/dma-buf/dma-fence.c:790 dma_fence_default_wait()
	warn: user controlled unbound timeout

drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
   784  int vmw_fence_obj_wait_ioctl(struct drm_device *dev, void *data,
   785                               struct drm_file *file_priv)
   786  {
   787          struct drm_vmw_fence_wait_arg *arg =
   788              (struct drm_vmw_fence_wait_arg *)data;
   789          unsigned long timeout;
   790          struct ttm_base_object *base;
   791          struct vmw_fence_obj *fence;
   792          struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
   793          int ret;
   794          uint64_t wait_timeout = ((uint64_t)arg->timeout_us * HZ);

timeout comes from the ioctl.

   795  
   796          /*
   797           * 64-bit division not present on 32-bit systems, so do an
   798           * approximation. (Divide by 1000000).
   799           */
   800  
   801          wait_timeout = (wait_timeout >> 20) + (wait_timeout >> 24) -
   802            (wait_timeout >> 26);
   803  
   804          if (!arg->cookie_valid) {
   805                  arg->cookie_valid = 1;
   806                  arg->kernel_cookie = jiffies + wait_timeout;
   807          }
   808  
   809          base = vmw_fence_obj_lookup(tfile, arg->handle);
   810          if (IS_ERR(base))
   811                  return PTR_ERR(base);
   812  
   813          fence = &(container_of(base, struct vmw_user_fence, base)->fence);
   814  
   815          timeout = jiffies;
   816          if (time_after_eq(timeout, (unsigned long)arg->kernel_cookie)) {
   817                  ret = ((vmw_fence_obj_signaled(fence)) ?
   818                         0 : -EBUSY);
   819                  goto out;
   820          }
   821  
   822          timeout = (unsigned long)arg->kernel_cookie - timeout;
   823  
   824          ret = vmw_fence_obj_wait(fence, arg->lazy, true, timeout);

This is a new Smatch warning.  To try figure out places which can
trigger sysbot "task hung" warnings.  I don't know if an upper bound on
timeout is appropriate here because this is new experimental check...

   825  
   826  out:
   827          ttm_base_object_unref(&base);

regards,
dan carpenter

                 reply	other threads:[~2021-09-10  7:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210910073014.GA32250@kili \
    --to=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=thellstrom@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox