Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3316869ybf; Tue, 3 Mar 2020 03:50:49 -0800 (PST) X-Google-Smtp-Source: ADFU+vtwG/5A9/SuGlgXHUTn7dGCIEHN7coFWs5eKmFaP5U73igyv4R7UcvtWC+E7CtzYMzgk8PK X-Received: by 2002:a05:6830:22c5:: with SMTP id q5mr3014545otc.184.1583236249602; Tue, 03 Mar 2020 03:50:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583236249; cv=none; d=google.com; s=arc-20160816; b=W8U6zsZhT+6E3iCej7WQyEXC8z+oKAvrVPMr+SgWX8py6Rj92XnAjTXeQLFmcqeDEH 4OzT8GZeLczCi86pBYnGPRDeUk5JeP4ySp8ZgktEKtFQSJpd6l9ivKt0TQsuOPTEtAg0 5lI/th91IACgWap2Gp+xxXNt2eP5KKFtLnUZBzxDMRsyRQav8jR+idgygt3hHnPN9v+F /Ea7mQK0sva0QbaqjSQ4DM2UQax/Vzh6JKcQKFP6r/oHrEqTObUKHAAyO0FqJBOnbqF7 po8BtOIU2nR6kJbce7iBrS30t08efWdPcVa0hoyRKt7k0GXwog+/2Y7oa6MM/jXPM/ws 511w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=PZ26SY4OwzsSrrvvDGgwwk0/Jl3p0EnMD6uJWZM6hTo=; b=SM87vJI9uJKR+u23d+95lkgchN04/Kfla+Gg62ZsJMWYcAoW1BIFwiQ5AeQVEcGO3T 3HxJt3+juLRSUkXDm/iNiMtOdgcnpuMkY2dG7dah9BRPaUDtHMpe6OPoaLzBguo4vJQR PAe3RU+wR2lbfqi4AWgicxXoDi7q19+7B74+kPxMaLiVZLHfN/K5hYwMNkR9DC4rUWdv Qoc4pCO+FP6ME9160Z4sfMbTd80FvgYLtHMr20jxH/9xMioGUl9Y6Di8QaYgah+ij46F 0h9FdGOvyjmKCZIwKLwHDBrtOmaASsIBcppZeZGn/G4qyg8i6MHRd9nyyMPKzd+wf8yv fS4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Os41xsdy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si8242602oto.105.2020.03.03.03.50.37; Tue, 03 Mar 2020 03:50:49 -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=@linaro.org header.s=google header.b=Os41xsdy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729044AbgCCLpU (ORCPT + 99 others); Tue, 3 Mar 2020 06:45:20 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33444 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727738AbgCCLpU (ORCPT ); Tue, 3 Mar 2020 06:45:20 -0500 Received: by mail-wr1-f65.google.com with SMTP id x7so3977416wrr.0 for ; Tue, 03 Mar 2020 03:45:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=PZ26SY4OwzsSrrvvDGgwwk0/Jl3p0EnMD6uJWZM6hTo=; b=Os41xsdyARcThMKgbHdgjT2+ry+sDNsiEi589q5nCVRho3STC+L29GGxO7sHC3e8mR +DAjmJXd+wBqZoeuUGQ8IfRJ48h7xqleIj9yg2t3x6sEaZjLp5+8uR/M69QtkqCLZmjB 5n8viie8sqPIAQv/el8Cu2RHEevc3PnyAk+WKwjd7N72EO/PmDcplEzStoeeQXpTBd+B zfRLNNZFj6pgVODZ62JI9IxMFgP86GXWT9mVSe4OzNNIkcutBUlneGzQGtPujn3Tdhfk 1G5BM85dir9NDY07dZk8lt6CEKfsyf/B7f4J5D74lvlB/MqFZqRi3bR/uEa3D6amHtMi DtDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PZ26SY4OwzsSrrvvDGgwwk0/Jl3p0EnMD6uJWZM6hTo=; b=fqV01QCMeBiKVOv6/FpL6nD/UpT94z6UrpxOAHzrPSYWfH85SUt4Y5qCPJjuzdpvPy zlsF9n4O+YaYLvSZPV99dQEwzEnM9C/g+HD7HFYW+7xlvip/0ENZjkz6QPwxNNNZ0F4g mfGeXPlW3UoC8o6oS6DD4Va43vH0R2KfZbQJPvEUQ54dSlf9Und4IC1Dfdx1BzQjQZX9 BKsP6tIkVPAaSP0hoLPqXyoIs1734I0OiyblveswKcohC9XF912v1GoG6RuZQ6StjuTy PLTr8s53buu7D37+gEiW7lWtot/dIGU8KKCwwhOfv+dKd1ybaRVYZJROnNVLEqDkkzzz hG/g== X-Gm-Message-State: ANhLgQ2t/dAk5kV28I5/VyxodShFJ0Ni2iTwBNN8iop2HkOBw4hWWQR+ ebZNqcQgPnDPqTHBrJ50tnZOOQ== X-Received: by 2002:a05:6000:2:: with SMTP id h2mr5422393wrx.182.1583235918023; Tue, 03 Mar 2020 03:45:18 -0800 (PST) Received: from myrica ([2001:171b:c9a8:fbc0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id a7sm3510943wmb.0.2020.03.03.03.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2020 03:45:17 -0800 (PST) Date: Tue, 3 Mar 2020 12:45:10 +0100 From: Jean-Philippe Brucker To: "Raj, Ashok" Cc: Zhangfei Gao , Greg Kroah-Hartman , Arnd Bergmann , Herbert Xu , jonathan.cameron@huawei.com, dave.jiang@intel.com, grant.likely@arm.com, Jerome Glisse , ilias.apalodimas@linaro.org, francois.ozog@linaro.org, kenneth-lee-2012@foxmail.com, Wangzhou , "haojian . zhuang" , guodong.xu@linaro.org, linux-accelerators@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, iommu@lists.linux-foundation.org, Kenneth Lee , Zaibo Xu , Ashok Raj Subject: Re: [PATCH v12 2/4] uacce: add uacce driver Message-ID: <20200303114510.GA584461@myrica> References: <1579097568-17542-1-git-send-email-zhangfei.gao@linaro.org> <1579097568-17542-3-git-send-email-zhangfei.gao@linaro.org> <20200224182201.GA22668@araj-mobl1.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200224182201.GA22668@araj-mobl1.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 24, 2020 at 10:22:02AM -0800, Raj, Ashok wrote: > Hi Kenneth, > > sorry for waking up late on this patchset. > > > On Wed, Jan 15, 2020 at 10:12:46PM +0800, Zhangfei Gao wrote: > [... trimmed] > > > + > > +static int uacce_fops_open(struct inode *inode, struct file *filep) > > +{ > > + struct uacce_mm *uacce_mm = NULL; > > + struct uacce_device *uacce; > > + struct uacce_queue *q; > > + int ret = 0; > > + > > + uacce = xa_load(&uacce_xa, iminor(inode)); > > + if (!uacce) > > + return -ENODEV; > > + > > + q = kzalloc(sizeof(struct uacce_queue), GFP_KERNEL); > > + if (!q) > > + return -ENOMEM; > > + > > + mutex_lock(&uacce->mm_lock); > > + uacce_mm = uacce_mm_get(uacce, q, current->mm); > > I think having this at open time is a bit unnatural. Since when a process > does fork, we do not inherit the PASID. Although it inherits the fd > but cannot use the mmaped address in the child. Both the queue and the PASID are tied to a single address space. When it disappears, the queue is stopped (zombie state) and the PASID is freed. The fd is not usable nor recoverable at this point, it's just waiting to be released. > If you move this to the mmap time, its more natural. The child could > do a mmap() get a new PASID + mmio space to work with the hardware. I like the idea, as it ties the lifetime of the bond to that of the queue mapping, but I have two small concerns: * It adds a lot of side-effect to mmap(). In addition to mapping the MMIO region it would now create both the bond and the queue. For userspace, figuring out why the mmap() fails would be more difficult. * It forces uacce drivers to implement an mmap() interface, and have MMIO regions to share. I suspect it's going to be the norm but at the moment it's not mandatory, drivers could just implement ioctls ops. I guess the main benefit would be reusing an fd after the original address space dies, but is it a use-case? I'd rather go one step further in the other direction, declare that an fd is a queue and is exclusive to an address space, by preventing any operation (ioctl and mmap) from an mm other than the one that opened the fd. It's not natural but it'd keep the kernel driver simple as we wouldn't have to reconfigure the queue during the lifetime of the fd. Thanks, Jean