Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3849583imm; Tue, 11 Sep 2018 03:08:03 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbeBnaMAbp64kCjWBeiV8r2t3gwGzhsyQGAs+XxKgmG4B51IiyiwiORK2tQYIZ4wJs9S+3r X-Received: by 2002:a17:902:b902:: with SMTP id bf2-v6mr26625369plb.185.1536660483067; Tue, 11 Sep 2018 03:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536660483; cv=none; d=google.com; s=arc-20160816; b=J8kZCRjtH3ae64ltOh35KqQUd/3t7zrz6ZOh5vUYXsIarncQH0Os3IRM2SGmsC7v14 BTMVTaEVqWsAQqYGRRW3rNmzzAc383C0mFzwwgZzUmZzH/S1NGoQ68H3R5UNdF5F2GC2 IkYsXjIVL6+5otBT5cDZnO183hWGAPMyn0sFtgqFXnRJl2eaxVhXuDNxU4OfYCclxksi UwGB7EZvDihd4gYf+rlxilby5y76n5IKpC2NGZqC1IzrtGNod0XAHkH/XOBPlMuSdboX cXuOdcG4Nf1qZvcok5OC47IkvFE/jmF7CPTw38xi4BtUHs1rjOQCX3y6a9FdUIDTJFrP vqFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=AEvYVSj8VgyrmXoxNRvMkOz78B2Fm8X5If4+UdZGxS4=; b=EOZGt5dHiI9kT/nl0hSPqTMye/XjwveVUhFLW0m3GJzwxLN9IZ8CVgT3x0sxRH1yJy /CXzAJy1sdUB/L5gG6P10lWy/hzzQJE4l7nD+fTHdBVjwNfdAfv98Jqd4am0lmqU4xWh uVFjl5xwxDGlIimoBL88IqEmb9yFnInuJuTSyr5uENbpLneJxAUJ3GkgCk4BdM2yvOLF rhJpqd8ZSvGXpTXYlkibmsXrRpXZKFpZkvLxjGPuIF6eBWEZVmgTb7o/n9iateEzHB/b PMGg0/R62dxApCTcnFIyXzxhDiIw/zp/Hp82hcXpv5QWpcOOKrC5g0M3QVPQGmww6Y1x 8T3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b="T3/Hoetl"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a34-v6si19619003pld.149.2018.09.11.03.07.47; Tue, 11 Sep 2018 03:08:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b="T3/Hoetl"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726808AbeIKPEc (ORCPT + 99 others); Tue, 11 Sep 2018 11:04:32 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:33540 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726563AbeIKPEc (ORCPT ); Tue, 11 Sep 2018 11:04:32 -0400 Received: by mail-it0-f67.google.com with SMTP id j198-v6so8486871ita.0 for ; Tue, 11 Sep 2018 03:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=AEvYVSj8VgyrmXoxNRvMkOz78B2Fm8X5If4+UdZGxS4=; b=T3/HoetlctL0qZ2alZc+y2nDE6C6rzdpDwh1b72hJ0kumd7RCcsWzj35l+cdTYcoL0 XQfJNGrupPyr4bJr8MJZZyax3VrwzNFYtpGD9/8XOcB13MH1Pc9Z6P/7J9oQ651Qoyf6 MpTRXtv7kqkyU9ZJEEHEzYikpTNMf9QwNrwzk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=AEvYVSj8VgyrmXoxNRvMkOz78B2Fm8X5If4+UdZGxS4=; b=Ql3mPkzfijG+wm1GVcgEKq3Ir9H67uFukHm4oaHwvUbRWuo/gTnQ9cf5E+VCPDUlCP qbKT4jN4KABsWw3WULRHQW91AQHOdMkS/JJlh9U9N1SuY0Iap7vB4KmHuNA/XpFl7v7t hFrWu19a8Kl7SBuT2cL/sGIUjywAgVa/2eaoba0/JdjjQnfD1Y/nThTOnf8TIXGQo+3M 603Q7FlaCLgKQeGNiv+ZibJl6jqEgcO5z8UMX1NbibaON2Eyixgslr4APgWnEBwp79YY wF83mkW/jqp1VKxW5DiK9C6S0RgSbZNSt/c4ekihvOFRzY+yFH+eyUf4fZSBCRCKVkQr iTvg== X-Gm-Message-State: APzg51Bg67N0+U7BRC5uTED3FJ3sL+V3AJnqPHzxPXJ8SqdO/lw6NB/H WaxO/kwE5nBk8vLDMVdzrLTJioAdRsZXOTj80pgxUg== X-Received: by 2002:a02:10c6:: with SMTP id 189-v6mr22417696jay.54.1536660356568; Tue, 11 Sep 2018 03:05:56 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:bf05:0:0:0:0:0 with HTTP; Tue, 11 Sep 2018 03:05:55 -0700 (PDT) X-Originating-IP: [2a02:168:569e:0:3106:d637:d723:e855] In-Reply-To: <18750721.r4B5nx0M26@avalon> References: <20180827093444.23623-1-kraxel@redhat.com> <21053714.0Xa7F2u2PE@avalon> <20180911065014.vo6qp6hkb7cjftdc@sirius.home.kraxel.org> <18750721.r4B5nx0M26@avalon> From: Daniel Vetter Date: Tue, 11 Sep 2018 12:05:55 +0200 X-Google-Sender-Auth: PL_rPXak95JCfD_2v68fhamPvJM Message-ID: Subject: Re: [PATCH v7] Add udmabuf misc device To: Laurent Pinchart Cc: Gerd Hoffmann , dri-devel , David Airlie , Tomeu Vizoso , Jonathan Corbet , Sumit Semwal , Shuah Khan , "open list:DOCUMENTATION" , open list , "open list:DMA BUFFER SHARING FRAMEWORK" , "moderated list:DMA BUFFER SHARING FRAMEWORK" , "open list:KERNEL SELFTEST FRAMEWORK" , "open list:ABI/API" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 11, 2018 at 11:50 AM, Laurent Pinchart wrote: > Hi Gerd, > > On Tuesday, 11 September 2018 09:50:14 EEST Gerd Hoffmann wrote: >> Hi, >> >> >> +#define UDMABUF_CREATE _IOW('u', 0x42, struct udmabuf_create) >> > >> > Why do you start at 0x42 if you reserve the 0x40-0x4f range ? >> >> No particular strong reason, just that using 42 was less boring than >> starting with 0x40. >> >> >> +#define UDMABUF_CREATE_LIST _IOW('u', 0x43, struct >> >> udmabuf_create_list) >> > >> > Where's the documentation ? :-) >> >> Isn't it simple enough? > > No kernel UAPI is simple enough to get away without documenting it. Simplest option would be to throw a bit of kerneldoc into the uapi header, add Documentation/driver-api/dma-buf.rst. -Daniel > >> But, well, yes, I guess I can add some kerneldoc comments. >> >> >> +static int udmabuf_vm_fault(struct vm_fault *vmf) >> >> +{ >> >> + struct vm_area_struct *vma = vmf->vma; >> >> + struct udmabuf *ubuf = vma->vm_private_data; >> >> + >> >> + if (WARN_ON(vmf->pgoff >= ubuf->pagecount)) >> >> + return VM_FAULT_SIGBUS; >> > >> > Just curious, when do you expect this to happen ? >> >> It should not. If it actually happens it would be a bug somewhere, >> thats why the WARN_ON. > > But you seem to consider that this condition that should never happen still > has a high enough chance of happening that it's worth a WARN_ON(). I was > wondering why this one in particular, and not other conditions that also can't > happen and are not checked through the code. > >> >> + struct udmabuf *ubuf; >> >> >> >> + ubuf = kzalloc(sizeof(struct udmabuf), GFP_KERNEL); >> > >> > sizeof(*ubuf) >> >> Why? Should not make a difference ... > > Because the day we replace > > struct udmabuf *ubuf; > > with > > struct udmabuf_ext *ubuf; > > and forget to change the next line, we'll introduce a bug. That's why > sizeof(variable) is preferred over sizeof(type). Another reason is that I can > easily see that > > ubuf = kzalloc(sizeof(*ubuf), GFP_KERNEL); > > is correct, while using sizeof(type) requires me to go and look up the > declaration of the variable. > >> >> + memfd = fget(list[i].memfd); >> >> + if (!memfd) >> >> + goto err_put_pages; >> >> + if (!shmem_mapping(file_inode(memfd)->i_mapping)) >> >> + goto err_put_pages; >> >> + seals = memfd_fcntl(memfd, F_GET_SEALS, 0); >> >> + if (seals == -EINVAL || >> >> + (seals & SEALS_WANTED) != SEALS_WANTED || >> >> + (seals & SEALS_DENIED) != 0) >> >> + goto err_put_pages; >> > >> > All these conditions will return -EINVAL. I'm not familiar with the memfd >> > API, should some error conditions return a different error code to make >> > them distinguishable by userspace ? >> >> Hmm, I guess EBADFD would be reasonable in case the file handle isn't a >> memfd. Other suggestions? > > I'll let others comment on this as I don't feel qualified to pick proper error > codes, not being familiar with the memfd API. > >> I'll prepare a fixup patch series addressing most of the other >> review comments. > > -- > Regards, > > Laurent Pinchart > > > -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch