All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: David Herrmann <dh.herrmann@gmail.com>
Cc: "Daniel Thompson" <daniel.thompson@linaro.org>,
	"Stéphane Marchesin" <marcheu@google.com>,
	"Thomas Hellstrom" <thellstrom@vmware.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"Jerome Glisse" <jglisse@redhat.com>,
	"David Reveman" <reveman@google.com>,
	"Daniel Vetter" <daniel.vetter@ffwll.ch>,
	"Daniel Vetter" <daniel.vetter@intel.com>
Subject: Re: [PATCH v7 3/5] dma-buf: Add ioctls to allow userspace to flush
Date: Thu, 11 Feb 2016 21:10:55 +0200	[thread overview]
Message-ID: <20160211191054.GG23290@intel.com> (raw)
In-Reply-To: <CANq1E4ThVv1-nuqJCkTqTNt1xqtGbLgtw4YLVwtp=mkhB6jBNg@mail.gmail.com>

On Thu, Feb 11, 2016 at 07:19:45PM +0100, David Herrmann wrote:
> Hi
> 
> On Thu, Feb 11, 2016 at 7:08 PM, Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> > On Thu, Feb 11, 2016 at 03:54:38PM -0200, Tiago Vignatti wrote:
> >>
> >> Thanks for reviewing, David. Please take a look in my comments in-line.
> >>
> >>
> >> On 02/09/2016 07:26 AM, David Herrmann wrote:
> >> >
> >> > On Tue, Dec 22, 2015 at 10:36 PM, Tiago Vignatti
> >> > <tiago.vignatti@intel.com> wrote:
> >> >> From: Daniel Vetter <daniel.vetter@ffwll.ch>
> > <snip>
> >> >> +
> >> >> +#define DMA_BUF_SYNC_READ      (1 << 0)
> >> >> +#define DMA_BUF_SYNC_WRITE     (2 << 0)
> >> >> +#define DMA_BUF_SYNC_RW        (DMA_BUF_SYNC_READ | DMA_BUF_SYNC_WRITE)
> >> >> +#define DMA_BUF_SYNC_START     (0 << 2)
> >> >> +#define DMA_BUF_SYNC_END       (1 << 2)
> >> >> +#define DMA_BUF_SYNC_VALID_FLAGS_MASK \
> >> >> +       (DMA_BUF_SYNC_RW | DMA_BUF_SYNC_END)
> >> >> +
> >> >> +#define DMA_BUF_BASE           'b'
> >> >> +#define DMA_BUF_IOCTL_SYNC     _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
> >> >
> >> > Why _IOW? A read-only ioctl should be able to call DMA_BUF_SYNC_READ, right?
> >>
> >> yup. I've changed it to _IOWR now.
> >
> > AFAICS the ioctl only does copy_from_user() so _IOW seemed perfectly
> > correct to me.
> 
> AFAIK, the _IOC_DIR() arguments in ioctls specify the mode of the
> operation, not the way the arguments are used. So if read(2) was an
> ioctl, it would be annotated as _IOC_READ (even though it _writes_
> into the passed buffer). write(2) would be annotated as _IOC_WRITE
> (even though it _reads_ the buffer). As such, they correspond to the
> file-access mode, whether you opened it readable and/or writable.
> 
> Anyway, turns out VFS does not verify those. As such, you can specify
> whatever you want. I just checked with different existing ioctls
> throughout the kernel (`git grep _IOC_DIR`), and they seem to match
> what I describe.

Not sure which ones you checked because I don't think I've ever seen
that interpretation in the kernel. Though I suppose often it sort of
matches, eg. when the ioctl just gets/sets some value. Any relationship
to some hardware operation is mostly coincidental (well, except when
the hardware really just does some kind of read/write operation).
And for lost ioctls there is no hardware interaction whatsoever.

As far as checking the file access mode goes, well lots of ioctls
totally ignore it.

About the direction you're right. _IOW means userspace writes to
the kernel, and _IOR means userspace reads from the kernel. Which
is exactly what the code did.

Anyway ioctl-numbers.txt says this:
_IO    an ioctl with no parameters
_IOW   an ioctl with write parameters (copy_from_user)
_IOR   an ioctl with read parameters  (copy_to_user)
_IOWR  an ioctl with both write and read parameters.

so I win ;)

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2016-02-11 19:11 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 21:36 Direct userspace dma-buf mmap (v7) Tiago Vignatti
2015-12-22 21:36 ` [PATCH v7 1/5] drm: prime: Honour O_RDWR during prime-handle-to-fd Tiago Vignatti
2015-12-22 21:36 ` [PATCH v7 2/5] dma-buf: Remove range-based flush Tiago Vignatti
2015-12-22 21:36 ` [PATCH v7 3/5] dma-buf: Add ioctls to allow userspace to flush Tiago Vignatti
2016-02-09  9:26   ` David Herrmann
2016-02-09 10:20     ` Daniel Vetter
2016-02-09 10:52       ` Daniel Vetter
2016-02-11 17:54     ` Tiago Vignatti
2016-02-11 18:00       ` Alex Deucher
2016-02-11 18:08       ` David Herrmann
2016-02-11 18:08       ` Ville Syrjälä
2016-02-11 18:19         ` David Herrmann
2016-02-11 19:10           ` Ville Syrjälä [this message]
2016-02-11 22:04             ` [PATCH v9] " Tiago Vignatti
2016-02-12 14:50               ` David Herrmann
2016-02-12 15:02                 ` Daniel Vetter
2016-02-25 18:01               ` Chris Wilson
2016-02-29 14:54                 ` Daniel Vetter
2016-02-29 15:02                   ` Chris Wilson
2016-03-05  9:34                     ` Daniel Vetter
2016-03-14 20:21                       ` Tiago Vignatti
2016-03-15  8:51                         ` Chris Wilson
2016-03-17 18:18                         ` [PATCH] prime_mmap_coherency: Add return error tests for prime sync ioctl Tiago Vignatti
2016-03-17 21:01                           ` Chris Wilson
2016-03-17 21:15                             ` Tiago Vignatti
2016-03-17 21:18                             ` [PATCH v2] " Tiago Vignatti
2016-03-18  9:44                               ` Chris Wilson
2016-03-18  9:53                                 ` [Intel-gfx] " Chris Wilson
2016-03-18 18:08                                 ` [PATCH v3] " Tiago Vignatti
2016-03-18 18:11                                   ` Daniel Vetter
2016-03-18 18:17                                     ` Tiago Vignatti
2016-03-18 20:43                                   ` Chris Wilson
2015-12-22 21:36 ` [PATCH v7 4/5] drm/i915: Implement end_cpu_access Tiago Vignatti
2015-12-22 21:36 ` [PATCH v7 5/5] drm/i915: Use CPU mapping for userspace dma-buf mmap() Tiago Vignatti
2015-12-22 21:36 ` [PATCH igt v7 1/6] lib: Add gem_userptr and __gem_userptr helpers Tiago Vignatti
2015-12-22 21:36 ` [PATCH igt v7 2/6] prime_mmap: Add new test for calling mmap() on dma-buf fds Tiago Vignatti
2015-12-22 21:36 ` [PATCH igt v7 3/6] prime_mmap: Add basic tests to write in a bo using CPU Tiago Vignatti
2015-12-22 21:36 ` [PATCH igt v7 4/6] lib: Add prime_sync_start and prime_sync_end helpers Tiago Vignatti
2015-12-22 21:36 ` [PATCH igt v7 5/6] tests: Add kms_mmap_write_crc for cache coherency tests Tiago Vignatti
2015-12-22 21:36 ` [PATCH igt v7 6/6] tests: Add prime_mmap_coherency " Tiago Vignatti
2016-02-04 20:55 ` Direct userspace dma-buf mmap (v7) Stéphane Marchesin
2016-02-05 13:53   ` Tiago Vignatti
2016-02-09  8:47     ` 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=20160211191054.GG23290@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=daniel.thompson@linaro.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dh.herrmann@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jglisse@redhat.com \
    --cc=marcheu@google.com \
    --cc=reveman@google.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.