From: "Vivi, Rodrigo" <rodrigo.vivi@intel.com>
To: "ville.syrjala@linux.intel.com" <ville.syrjala@linux.intel.com>
Cc: "intel-gfx@lists.freedesktop.org" <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 2/2] drm/i915: Fix the return value of pipe crc read function.
Date: Wed, 3 Aug 2016 14:44:23 +0000 [thread overview]
Message-ID: <1470235454.5637.46.camel@intel.com> (raw)
In-Reply-To: <20160803073144.GH4329@intel.com>
On Wed, 2016-08-03 at 10:31 +0300, Ville Syrjälä wrote:
> On Tue, Aug 02, 2016 at 09:42:07PM -0700, Rodrigo Vivi wrote:
> >
> > A read(fd, buf, len) function should return the number
> > of bytes read. In our case we need to return the
> > number of bytes we copy to user, instead of returning
> > the number of bytes we read internally.
> >
> > It was really strange when I saw i-g-t test case using
> > len '54' but getting '56' as return. First thought was
> > how do we read more than we asked? But also I checked
> > and there was really only 54. Until I realized it
> > was all our fault. EFAULT!
> >
> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > ---
> > drivers/gpu/drm/i915/i915_debugfs.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_debugfs.c
> > b/drivers/gpu/drm/i915/i915_debugfs.c
> > index 7052c47..b7b8d79 100644
> > --- a/drivers/gpu/drm/i915/i915_debugfs.c
> > +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> > @@ -3659,7 +3659,7 @@ i915_pipe_crc_read(struct file *filep, char
> > __user *user_buf, size_t count,
> >
> > spin_unlock_irq(&pipe_crc->lock);
> >
> > - return bytes_read;
> > + return PIPE_CRC_LINE_LEN;
> Nope. We can read multiple entries in one go.
>
> bytes_read += snprintf()
>
> so it's mostly good. The only case where it fails if we don't have
> enough space for the snprintf(), as snprintf() will then return the
> number of bytes it would have written. That can actually happen on
> account of the hex vs. decimal mess with the frame counter.
Oh, I see.
So what about:
if (bytes_read > count)
return -E-something?
>
> >
> > }
> >
> > static const struct file_operations i915_pipe_crc_fops = {
> > --
> > 2.5.5
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-08-03 14:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-03 4:42 [PATCH 1/2] drm/i915: Fix copy_to_user usage for pipe_crc Rodrigo Vivi
2016-08-03 4:42 ` [PATCH 2/2] drm/i915: Fix the return value of pipe crc read function Rodrigo Vivi
2016-08-03 7:31 ` Ville Syrjälä
2016-08-03 14:44 ` Vivi, Rodrigo [this message]
2016-08-05 21:50 ` Pandiyan, Dhinakaran
2016-08-03 7:48 ` Daniel Vetter
2016-08-03 6:49 ` ✗ Ro.CI.BAT: failure for series starting with [1/2] drm/i915: Fix copy_to_user usage for pipe_crc Patchwork
2016-08-03 7:29 ` [PATCH 1/2] " Ville Syrjälä
2016-08-03 7:44 ` Daniel Vetter
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=1470235454.5637.46.camel@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=ville.syrjala@linux.intel.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