Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3685655imm; Mon, 10 Sep 2018 23:51:43 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbWVXgX+z8+5BaTcYV2JAiq1g+l8ZTxA4Iz26Vn2Ub8hmZqE6ff64amSAA+iIQRe+I0o8BZ X-Received: by 2002:a63:da56:: with SMTP id l22-v6mr26746258pgj.179.1536648703719; Mon, 10 Sep 2018 23:51:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536648703; cv=none; d=google.com; s=arc-20160816; b=GlyMpvW1C/nxkEDURf+i0+OPXTXpUpeyRGLuvnPpZ8EBzREvogbSCR2tTMW5iBH9Y2 dA52wYk3ihmpc0xtHIslXQwA7Sd4dsl3NX5jCnyxiGF73FfRMfyEVf0Rsr2Xljc1nvTl 2sXmwJOn8s7ekShpfzOvQNVxpMYiMX+CTaSfO8XKYbEqOBSvDvDgLfjCEA65IEuM1UbY J0rUznrOGAIGZ9vdPw5i5TusZNSNL+uW6SavtEfmeR7PQFlpVSCVY9qfFJqwUJtl0nwa Baqnd76DzoQvssD6Hfp/RMNgY9AMNthbdTQDckR4R0QbygFuL+ferDeuB3sBBMOc5ger MdPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=IpTZTHcr3qZeCOK1LvJpCwMPYdF23ywDLXVkCrEx8+Q=; b=fQ7XAFJWH9guMp+K9CxEC6hHRPJrHdTcq4YAPUEDSRkzWJ8L0OqoSSos4Ip4rG74eI 3cHj0qxc3UkOcwAfWpaD7ZuxpaUA7kcFqiCVm6A4A3WnAoP/F8sWWHhBNcSNEuJhhXwr Wr8i5/y0fMXrqnNOnI+EJ5JC0fMjYNiPWk8lkaQz2Cb0kjrNggKr0A4iAKOC0QQ6Bt9r dJFQ5l3N+ozHHDEjT6jMfxo8Za6JNVqv0f7ASMrMedoCJtMhlE4yaHNBuoNYK9jttrh+ GE/iLSsMvk2eOn5R5yMI0wgttz+rI8Wf5QkOIOaPii0p7U9UsSJnwmRsnrn9gbMkwKjq THrQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g23-v6si3396115pgh.277.2018.09.10.23.50.56; Mon, 10 Sep 2018 23:51:43 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727730AbeIKLsG (ORCPT + 99 others); Tue, 11 Sep 2018 07:48:06 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39352 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726483AbeIKLsG (ORCPT ); Tue, 11 Sep 2018 07:48:06 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EFB6040776F0; Tue, 11 Sep 2018 06:50:15 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 536DC2156889; Tue, 11 Sep 2018 06:50:15 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 8B55E16E08; Tue, 11 Sep 2018 08:50:14 +0200 (CEST) Date: Tue, 11 Sep 2018 08:50:14 +0200 From: Gerd Hoffmann To: Laurent Pinchart Cc: dri-devel@lists.freedesktop.org, David Airlie , Tomeu Vizoso , Daniel Vetter , 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" , linux-api@vger.kernel.org Subject: Re: [PATCH v7] Add udmabuf misc device Message-ID: <20180911065014.vo6qp6hkb7cjftdc@sirius.home.kraxel.org> References: <20180827093444.23623-1-kraxel@redhat.com> <21053714.0Xa7F2u2PE@avalon> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <21053714.0Xa7F2u2PE@avalon> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 11 Sep 2018 06:50:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 11 Sep 2018 06:50:16 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? 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. > > + struct udmabuf *ubuf; > > + ubuf = kzalloc(sizeof(struct udmabuf), GFP_KERNEL); > > sizeof(*ubuf) Why? Should not make a difference ... > > + 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 prepare a fixup patch series addressing most of the other review comments. cheers, Gerd