mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Andrew F. Davis" <afd@ti.com>
To: John Stultz <john.stultz@linaro.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Laura Abbott <labbott@redhat.com>,
	Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Liam Mark <lmark@codeaurora.org>,
	Pratik Patel <pratikp@codeaurora.org>,
	Brian Starkey <Brian.Starkey@arm.com>,
	Vincent Donnefort <Vincent.Donnefort@arm.com>,
	Sudipto Paul <Sudipto.Paul@arm.com>,
	Christoph Hellwig <hch@infradead.org>,
	Chenbo Feng <fengc@google.com>,
	Alistair Strachan <astrachan@google.com>,
	Hridya Valsaraju <hridya@google.com>,
	Sandeep Patil <sspatil@google.com>,
	Hillf Danton <hdanton@sina.com>, Dave Airlie <airlied@gmail.com>,
	dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH v15 1/5] dma-buf: Add dma-buf heaps framework
Date: Wed, 6 Nov 2019 12:18:00 -0500	[thread overview]
Message-ID: <26700d4b-07c6-65b1-9fc6-bb3e239202e5@ti.com> (raw)
In-Reply-To: <CALAqxLW1vgLCik5WfDN7qkRsO=K9U4otNBp72aOH5UNN1jUgMQ@mail.gmail.com>

On 11/6/19 12:03 PM, John Stultz wrote:
> On Wed, Nov 6, 2019 at 5:52 AM Andrew F. Davis <afd@ti.com> wrote:
>>
>> On 11/5/19 11:22 PM, John Stultz wrote:
>>> +unsigned int dma_heap_ioctl_cmds[] = {
>>> +     DMA_HEAP_IOC_ALLOC,
>>> +};
>>> +
>>> +static long dma_heap_ioctl(struct file *file, unsigned int ucmd,
>>> +                        unsigned long arg)
>>> +{
>>> +     char stack_kdata[128];
>>> +     char *kdata = stack_kdata;
>>> +     unsigned int kcmd;
>>> +     unsigned int in_size, out_size, drv_size, ksize;
>>> +     int nr = _IOC_NR(ucmd);
>>> +     int ret = 0;
>>> +
>>> +     if (nr >= ARRAY_SIZE(dma_heap_ioctl_cmds))
>>> +             return -EINVAL;
>>> +
>>> +     /* Get the kernel ioctl cmd that matches */
>>> +     kcmd = dma_heap_ioctl_cmds[nr];
>>
>>
>> Why do we need this indirection here and all the complexity below? I
>> know DRM ioctl does something like this but it has a massive table,
>> legacy ioctls, driver defined ioctls, etc..
>>
>> I don't expect we will ever need complex handling like this, could we
>> switch back to the more simple handler from v13?
> 
> I agree it does add complexity, but I'm not sure I see how to avoid
> some of this. The logic trying to handle that the user may pass a cmd
> that has the same _IOC_NR() as DMA_HEAP_IOC_ALLOC but not the same
> size. So the simple "switch(cmd) { case DMA_HEAP_IOC_ALLOC:" we had
> before won't work (as the cmd will be a different value).
> 


DMA_HEAP_IOC_ALLOC encodes everything we need, if the size is different
then the switch case will not match. It handled everything we have.


> Thus why I thought the cleanest approach would be to use the
> dma_heap_ioctl_cmds array to convert from whatever the user cmd is to
> the matching kernel cmd value.
> 


There are no kernel or user commands, just commands, they will match or
they are not valid. If someday we some need a variable sized ioctl then
we can deal with that then.

Andrew


> Do you have an alternative suggestion that I'm overlooking?
> 
> thanks
> -john
> 

  reply	other threads:[~2019-11-06 17:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06  4:22 [PATCH v15 0/5] DMA-BUF Heaps (destaging ION) John Stultz
2019-11-06  4:22 ` [PATCH v15 1/5] dma-buf: Add dma-buf heaps framework John Stultz
2019-11-06 13:52   ` Andrew F. Davis
2019-11-06 17:03     ` John Stultz
2019-11-06 17:18       ` Andrew F. Davis [this message]
2019-11-06 18:23         ` Andrew F. Davis
2019-11-06  4:22 ` [PATCH v15 2/5] dma-buf: heaps: Add heap helpers John Stultz
2019-11-06  4:22 ` [PATCH v15 3/5] dma-buf: heaps: Add system heap to dmabuf heaps John Stultz
2019-11-06  4:22 ` [PATCH v15 4/5] dma-buf: heaps: Add CMA " John Stultz
2019-11-06  4:22 ` [PATCH v15 5/5] kselftests: Add dma-heap test John Stultz

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=26700d4b-07c6-65b1-9fc6-bb3e239202e5@ti.com \
    --to=afd@ti.com \
    --cc=Brian.Starkey@arm.com \
    --cc=Sudipto.Paul@arm.com \
    --cc=Vincent.Donnefort@arm.com \
    --cc=airlied@gmail.com \
    --cc=astrachan@google.com \
    --cc=benjamin.gaignard@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fengc@google.com \
    --cc=hch@infradead.org \
    --cc=hdanton@sina.com \
    --cc=hridya@google.com \
    --cc=john.stultz@linaro.org \
    --cc=labbott@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lmark@codeaurora.org \
    --cc=pratikp@codeaurora.org \
    --cc=sspatil@google.com \
    --cc=sumit.semwal@linaro.org \
    /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

all inboxes | Powered by JetHome®