Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1102526img; Tue, 26 Feb 2019 14:19:29 -0800 (PST) X-Google-Smtp-Source: AHgI3IZLWt7sFS9V2tOsgccPkz6g1/NbDPU91Vp0ZSbkP3UULfU/Xcw69hUTNUyNo2zp9d3vcbV0 X-Received: by 2002:a63:ec48:: with SMTP id r8mr26632746pgj.50.1551219569888; Tue, 26 Feb 2019 14:19:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551219569; cv=none; d=google.com; s=arc-20160816; b=uDbytPWT4fcb1NCjMtYKTciZYPo8Y5B+qKUss87dyQUYh2hb7/rtGVtsCr3e34n0jC 4jnEhcnP8uMoqIq1lG3yQ45u1dnIZWl91swD5OnPOg0FTUDkPFT8HqAjrkcU2SDVIHvH 4SnPjuOwJJ6yzziLtiSSwdY0kVH+2zZPHfP4lqafDPZ5/dqs6Bx6Xj7GmoYKAOrYL3NB jmxv2IUjAvkeeMsxWTYW/RPJ9n+cgC3Nue6OVp46qcCTgVVUte3Jj3PZ/2FAYolie2o9 lzbT5NiB09KW5IIXo2o6LB1KaWqqeGjwQJz2p36aafkiFUU75EaL8/kyowi2TypaMcpB QVTQ== 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:dkim-signature; bh=/+yNuls6czdZcPULun1ednM3lhS7p4rXYXcfFu5j9/s=; b=xhGUUw1ZCHJ1BhzxDJDdwFebBFXOz4+7ONGRKyWnoZiQ9Ya7D81d6pz3jNyJh531tq nFyD9AGDLmpvn1IaO5L1CZ/Fhmp6q5T4YuXzwtjTr3suk2HQr8HSHbnZS4ZYH2ac6AYu G0d5l6ictjoJ3nKG4ebw/VsT1PbA/JUCGUFurrMHMGqfC/wdSX9rs1I6ky0ms0h9RbJp zuZEUt2MketCleGg/YcQIvsOf/MPMOI4MXIq+C1QpUow5n6XHU/qwtoOkVGxja53eKr4 RlnSRjXQQd3X1X7A1u6oMveQ96UhHLXAwrEJwPYTnd34W6sLJZlV2wuC08Oz1foV83uI 48ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xilinx.onmicrosoft.com header.s=selector1-xilinx-com header.b=PV2hawhx; 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 p91si13591900plb.69.2019.02.26.14.19.14; Tue, 26 Feb 2019 14:19:29 -0800 (PST) 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=pass header.i=@xilinx.onmicrosoft.com header.s=selector1-xilinx-com header.b=PV2hawhx; 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 S1729232AbfBZWSl (ORCPT + 99 others); Tue, 26 Feb 2019 17:18:41 -0500 Received: from mail-eopbgr710078.outbound.protection.outlook.com ([40.107.71.78]:22304 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728989AbfBZWSk (ORCPT ); Tue, 26 Feb 2019 17:18:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/+yNuls6czdZcPULun1ednM3lhS7p4rXYXcfFu5j9/s=; b=PV2hawhxjYsXuszOr8kuQUoq9AU2b8EsDNcUlM7JJelrkLKBEbdwoypIIYs+7VBjS2kkq6dXnV+OptcBy6+Z9jWPwelIeNhYACJS5ipOD7NXAp+gvPK6BbLp+N5B835PPG5BubjFEHFqK5rpPv7+p5b4ZSQOzDMD74dcNLvyG7c= Received: from BYAPR02CA0043.namprd02.prod.outlook.com (2603:10b6:a03:54::20) by BL0PR02MB4516.namprd02.prod.outlook.com (2603:10b6:208:4a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.15; Tue, 26 Feb 2019 22:18:32 +0000 Received: from CY1NAM02FT049.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::201) by BYAPR02CA0043.outlook.office365.com (2603:10b6:a03:54::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.15 via Frontend Transport; Tue, 26 Feb 2019 22:18:32 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by CY1NAM02FT049.mail.protection.outlook.com (10.152.75.83) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1643.11 via Frontend Transport; Tue, 26 Feb 2019 22:18:31 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1gyl3X-0004Np-5g; Tue, 26 Feb 2019 14:18:31 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1gyl3S-0005vi-0n; Tue, 26 Feb 2019 14:18:26 -0800 Received: from xsj-pvapsmtp01 (smtp.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id x1QMINdL023256; Tue, 26 Feb 2019 14:18:24 -0800 Received: from [172.19.2.244] (helo=localhost) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1gyl3P-0005vI-Rm; Tue, 26 Feb 2019 14:18:23 -0800 Date: Tue, 26 Feb 2019 14:16:28 -0800 From: Hyun Kwon To: Greg Kroah-Hartman CC: Hyun Kwon , Stefano Stabellini , Sonal Santan , Cyril Chemparathy , Jiaying Liang , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , "linaro-mm-sig@lists.linaro.org" , Michal Simek , "linux-arm-kernel@lists.infradead.org" , "linux-media@vger.kernel.org" Subject: Re: [PATCH RFC 1/1] uio: Add dma-buf import ioctls Message-ID: <20190226221627.GA10631@smtp.xilinx.com> References: <1550953697-7288-1-git-send-email-hyun.kwon@xilinx.com> <1550953697-7288-2-git-send-email-hyun.kwon@xilinx.com> <20190226115311.GA4094@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: <20190226115311.GA4094@kroah.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(376002)(396003)(346002)(39860400002)(2980300002)(51914003)(189003)(199004)(106002)(9786002)(76506005)(2906002)(26005)(106466001)(63266004)(54906003)(33656002)(47776003)(4326008)(6246003)(77096007)(57986006)(6306002)(426003)(966005)(486006)(316002)(16586007)(44832011)(476003)(126002)(336012)(11346002)(446003)(478600001)(58126008)(186003)(81156014)(8936002)(81166006)(8676002)(305945005)(1076003)(36386004)(50466002)(6916009)(229853002)(14444005)(356004)(23676004)(2486003)(76176011)(5660300002)(18370500001)(107986001);DIR:OUT;SFP:1101;SCL:1;SRVR:BL0PR02MB4516;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;LANG:en;PTR:unknown-60-83.xilinx.com;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0362e5ec-1279-4648-e330-08d69c385781 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4608103)(4709054)(2017052603328)(7153060);SRVR:BL0PR02MB4516; X-MS-TrafficTypeDiagnostic: BL0PR02MB4516: X-MS-Exchange-PUrlCount: 1 X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Microsoft-Exchange-Diagnostics: 1;BL0PR02MB4516;20:4kTMlCAfn28Vk3gk4MA35VUHdnCfEwJNhhrfPaARO2GdaW831q543nLSCBWwNVPM2sF5qCtsnQrl0KqenrXIU/MhvRO6b0WnF/Kd+V7D2oD9ji3ChasJgssBMyk+cRAm425Z0MZZsckXXceA2JeTfRW9bO6NVGMFOSMHoRkJDsnWxjLmej9+U+ZQTzMJSpsT2MHdCIRPhldbSUL6E8ONiXFpHsRRVSKFVRa39xZKYujVy88cgpuOrFpKI8ltblw5iIXoBPUf5DCMFDttW5w4B6bXiVjTeR31mMoe8xNTg7kEgGzQeEp90TF9aOM3/ZkjKvRL36FI11bytdSBFhwWDqPuFufX1QkS+Pn4Jvqg4WWFRGam48N/UajQ8xSwsaRtxbeC2OCDNHNNN56a5RW4IlUOFxisUHwrN3e5KB408lDmdw75P5R6fnyvzWfgExGuvcKXOe3MCL/5lthzabsAlFhz95LCK9zgHxQz5J+qgeFCUTurHrgKcLr/cWkrJnSj X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 096029FF66 X-Micro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3v9KLLjOU2JwHZHdotCNIf1nar3sLRQBxFw/0MpK4bTIfaIhVsmRfclbscZnreMOI9qu1EMBuz5sGFbuZtY8IS50m45bKA/2w9apzdJNlbiZMO+eMPVVq2h6x5m1ZSfH9Qk9PaDnOYmamECsD+lxVaRo/BnCiqnKgIx7+hpM1umk6rMNFBDoZKJYN4JimqahUX7RDYE9ar9X0TUXbWzETsVbg6Rkm9vxbEiNG/DjWY46hnGcs6+V56we17/LrHYYfY/jfxp0JNE1Nte3MBHgJvMpVT5cxRXXa0+9ILLYuMlVdS0/yLYKD6i4ixmTZDnsE9qouH8frDtBkYeHtCBcjRfrc3ia+L3jKH9Ab5cHXFK5J6+SgSi82kb4V65YveQD3nrGsfpNyur2UZ5qU= X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2019 22:18:31.5942 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0362e5ec-1279-4648-e330-08d69c385781 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR02MB4516 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Greg, Thanks for the comments. On Tue, 2019-02-26 at 03:53:11 -0800, Greg Kroah-Hartman wrote: > On Sat, Feb 23, 2019 at 12:28:17PM -0800, Hyun Kwon wrote: > > Add the dmabuf map / unmap interfaces. This allows the user driver > > to be able to import the external dmabuf and use it from user space. > > > > Signed-off-by: Hyun Kwon > > --- > > drivers/uio/Makefile | 2 +- > > drivers/uio/uio.c | 43 +++++++++ > > drivers/uio/uio_dmabuf.c | 210 +++++++++++++++++++++++++++++++++++++++++++ > > drivers/uio/uio_dmabuf.h | 26 ++++++ > > include/uapi/linux/uio/uio.h | 33 +++++++ > > 5 files changed, 313 insertions(+), 1 deletion(-) > > create mode 100644 drivers/uio/uio_dmabuf.c > > create mode 100644 drivers/uio/uio_dmabuf.h > > create mode 100644 include/uapi/linux/uio/uio.h > > > > diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile > > index c285dd2..5da16c7 100644 > > --- a/drivers/uio/Makefile > > +++ b/drivers/uio/Makefile > > @@ -1,5 +1,5 @@ > > # SPDX-License-Identifier: GPL-2.0 > > -obj-$(CONFIG_UIO) += uio.o > > +obj-$(CONFIG_UIO) += uio.o uio_dmabuf.o > > obj-$(CONFIG_UIO_CIF) += uio_cif.o > > obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o > > obj-$(CONFIG_UIO_DMEM_GENIRQ) += uio_dmem_genirq.o > > diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c > > index 1313422..6841f98 100644 > > --- a/drivers/uio/uio.c > > +++ b/drivers/uio/uio.c > > @@ -24,6 +24,12 @@ > > #include > > #include > > #include > > +#include > > +#include > > + > > +#include > > + > > +#include "uio_dmabuf.h" > > > > #define UIO_MAX_DEVICES (1U << MINORBITS) > > > > @@ -454,6 +460,8 @@ static irqreturn_t uio_interrupt(int irq, void *dev_id) > > struct uio_listener { > > struct uio_device *dev; > > s32 event_count; > > + struct list_head dbufs; > > + struct mutex dbufs_lock; /* protect @dbufs */ > > }; > > > > static int uio_open(struct inode *inode, struct file *filep) > > @@ -500,6 +508,9 @@ static int uio_open(struct inode *inode, struct file *filep) > > if (ret) > > goto err_infoopen; > > > > + INIT_LIST_HEAD(&listener->dbufs); > > + mutex_init(&listener->dbufs_lock); > > + > > return 0; > > > > err_infoopen: > > @@ -529,6 +540,10 @@ static int uio_release(struct inode *inode, struct file *filep) > > struct uio_listener *listener = filep->private_data; > > struct uio_device *idev = listener->dev; > > > > + ret = uio_dmabuf_cleanup(idev, &listener->dbufs, &listener->dbufs_lock); > > + if (ret) > > + dev_err(&idev->dev, "failed to clean up the dma bufs\n"); > > + > > mutex_lock(&idev->info_lock); > > if (idev->info && idev->info->release) > > ret = idev->info->release(idev->info, inode); > > @@ -652,6 +667,33 @@ static ssize_t uio_write(struct file *filep, const char __user *buf, > > return retval ? retval : sizeof(s32); > > } > > > > +static long uio_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) > > We have resisted adding a uio ioctl for a long time, can't you do this > through sysfs somehow? > The dmabuf is managed as per process resource, so it's hard to do it through sysfs. > A meta-comment about your ioctl structure: > > > +#define UIO_DMABUF_DIR_BIDIR 1 > > +#define UIO_DMABUF_DIR_TO_DEV 2 > > +#define UIO_DMABUF_DIR_FROM_DEV 3 > > +#define UIO_DMABUF_DIR_NONE 4 > > enumerated type? > > > + > > +struct uio_dmabuf_args { > > + __s32 dbuf_fd; > > + __u64 dma_addr; > > + __u64 size; > > + __u32 dir; > > Why the odd alignment? Are you sure this is the best packing for such a > structure? > > Why is dbuf_fd __s32? dir can be __u8, right? The dmabuf fd is defined as int, so __s32 seems correct. Please let me know otherwise. The dir can be __u8. Will fix if there is v2 at all. > > I don't know that dma layer very well, it would be good to get some > review from others to see if this really is even a viable thing to do. > The fd handling seems a bit "odd" here, but maybe I just do not > understand it. Agreed. So I'm looking forward to feedback or if there's more sensible alternative. Thanks, -hyun > > thanks, > > greg k-h > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel