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: Hillf Danton <hdanton@sina.com>,
	Sudipto Paul <Sudipto.Paul@arm.com>,
	Sandeep Patil <sspatil@google.com>,
	Vincent Donnefort <Vincent.Donnefort@arm.com>,
	Chenbo Feng <fengc@google.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Liam Mark <lmark@codeaurora.org>,
	Christoph Hellwig <hch@infradead.org>,
	Alistair Strachan <astrachan@google.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Hridya Valsaraju <hridya@google.com>,
	Pratik Patel <pratikp@codeaurora.org>
Subject: Re: [PATCH v15 1/5] dma-buf: Add dma-buf heaps framework
Date: Wed, 6 Nov 2019 13:23:12 -0500	[thread overview]
Message-ID: <546505bd-7ea7-6ae4-5dfa-44a3154fd5ea@ti.com> (raw)
In-Reply-To: <26700d4b-07c6-65b1-9fc6-bb3e239202e5@ti.com>

On 11/6/19 12:18 PM, Andrew F. Davis wrote:
> 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.
> 


Had a little discussion about this on IRC #dri-devel (check logs for
today if you want to follow along). Conclusion being the way it is done
here should be fine to help support forward compatibility. If optional
extensions to the structure are made that grow the size of data passed
in then we can ignore that and zero out the returned data without harm.
It is up to the flags field to mark incompatible changes that should
error out from kernel.
Andrew

> Andrew
> 
> 
>> Do you have an alternative suggestion that I'm overlooking?
>>
>> thanks
>> -john
>>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 

  reply	other threads:[~2019-11-06 18:23 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
2019-11-06 18:23         ` Andrew F. Davis [this message]
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=546505bd-7ea7-6ae4-5dfa-44a3154fd5ea@ti.com \
    --to=afd@ti.com \
    --cc=Sudipto.Paul@arm.com \
    --cc=Vincent.Donnefort@arm.com \
    --cc=astrachan@google.com \
    --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=linux-kernel@vger.kernel.org \
    --cc=lmark@codeaurora.org \
    --cc=pratikp@codeaurora.org \
    --cc=sspatil@google.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

all inboxes | Powered by JetHome®