Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1215184imm; Sat, 11 Aug 2018 08:28:16 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxiWFjEPYKYjoh2K6TN7/Any1NR4yVsBwgp6l28E0BJm4Z+qBDez1mt7PAU/YjU+QWHSzqH X-Received: by 2002:a17:902:7d8f:: with SMTP id a15-v6mr10394097plm.332.1534001296796; Sat, 11 Aug 2018 08:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534001296; cv=none; d=google.com; s=arc-20160816; b=YnwfzBJKUzrUMypaLX+coN6v7XHT44cdNkjBbs7GwYRFP5wKV+qC3dSTU+1xw4RrZm fTx0kVxxC1r7syyTuMDx7OMskhzsc7lqbClfcYgt/1QbDPN6YIe5AB3WETyUPEPtBWGw ORfLY14B5olf3GvzP+E4n0+PFq1kmwhQDHM8mRHuFgNgL/SS8dRK1sA8amJj7+SGPof4 5qd7BeE4f/1j86U2U6k4cZHnySoVx/x6KddY7h2ZF5oYNY8CAXiwDUMJtQbb+z6HUYgi +9eM0/THzkWQV0bsl7+nOgF8nm7wPeY/eEfUpQ+W1ed618Ik4VXKnBd9FOaveVlRhla2 VTKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=NjiOtMwrkE7eCLR5P4cIM8UwS1FO/jhA5jzal0l5upU=; b=xZ04DjEUEEidZJaSVUCV4IqioB1uN15QiYJifXXJEc012xkxk1cAn+1DqNuPWIjynr oRANyrI64/61O3HzqytzUNQwB5sTCAcAYbxS6r72TMBLKpHHLHhtgoD/tya//Iw/+J+d Tea3S+ynq9nb9POm0OSvIJxrsll/MzhvWBMWn/AFK/OlV/UoaHkeg6aZGhTKh5Cav3oq 1tBWDTUHKWu0QEBmMsGpcnWyybj86A1USAVXpb+SYFdawBY+rPwKVA5QzaVYQIhR4BDk rp7aZP4wh8b6LRSwdvd5Fby0YvIdY4dpUs+2+ijDNxXAsazrb9ybeY9Opbo8DegEuAVp Cz3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=drAo4IM+; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d38-v6si12864525pgl.88.2018.08.11.08.28.01; Sat, 11 Aug 2018 08:28:16 -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=pass header.i=@gmail.com header.s=20161025 header.b=drAo4IM+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727496AbeHKSBp (ORCPT + 99 others); Sat, 11 Aug 2018 14:01:45 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:44805 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727386AbeHKSBp (ORCPT ); Sat, 11 Aug 2018 14:01:45 -0400 Received: by mail-qt0-f193.google.com with SMTP id b15-v6so13299793qtp.11; Sat, 11 Aug 2018 08:27:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=NjiOtMwrkE7eCLR5P4cIM8UwS1FO/jhA5jzal0l5upU=; b=drAo4IM+qziWZucV/j3zNicqfcRYRG/9CA80UlUdmQ6n8JE6JoeVjPhT8LDPlrgWWn Z/RtzYqT4mH96pbwXLS2XrmWM5Bdts4mNNW+bGztX2Bv4UERz+9WvjN1eb/zZAjCuxQx DkI37piHbZJTL1SpOGXUwnRc/0m9krt4cxm/8TER5M8LbkTtGghE3cSae91sN0u1VNx8 Ya2iTfpW9C/IigwQolhLF9A2zL4NTIw4g/cVnAG7OaZWmtsIWFnl/VoxsAlNGJ232367 N6GIVbnh4UaJI6K9cm0Qi4GuSb2D5dVdGV2UB/wYN7lQkXln2Md2QhQAsG6a7mBvOjr/ 4qLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=NjiOtMwrkE7eCLR5P4cIM8UwS1FO/jhA5jzal0l5upU=; b=POD3Dyk/BidhavESAhF+ZTPNGDkkowuL+Sg4YEYX0FDU30Uj9PUcV5kJK0J6HWRTEB 4b2qrAB+iWSWuSWWYTY/psZGjjQ+ch2SnlBPW6FlRiWH/MGnclm23JhVQ1t/OohmI4pb /hYhoLt6NkflnZex2saGC3FfGEDBVeqO+IMu/RNqTSgogvAzI1kyc6idGIhHyZGPY0uL gW4UfQQ1OwjzT8Uhsw/Jit3OUoE2kapMKNzjUKv2bVS2Hh2pei9uh5eEH9KE0bGphHdi sT1BVc4FX8HX3LC1dJWuCWl3RxAgUZDMRR+eCRNQIbxTSKWg2wW4Mg94/ngSOsqO3ZpW ueFw== X-Gm-Message-State: AOUpUlED8XsqhNDNIdhmfOFg9/LwkhyaZZTsX8neKnEw0V22w9VjTMeN cYR64Qek3LxLrqbFtAj1qG4= X-Received: by 2002:ac8:70c5:: with SMTP id g5-v6mr10509230qtp.376.1534001232266; Sat, 11 Aug 2018 08:27:12 -0700 (PDT) Received: from [10.151.0.126] ([104.237.86.7]) by smtp.gmail.com with ESMTPSA id d202-v6sm7238291qkb.38.2018.08.11.08.26.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Aug 2018 08:27:11 -0700 (PDT) Subject: Re: [RFC PATCH 0/7] A General Accelerator Framework, WarpDrive To: Jean-Philippe Brucker , Kenneth Lee , Jerome Glisse Cc: Herbert Xu , "kvm@vger.kernel.org" , Jonathan Corbet , Greg Kroah-Hartman , Zaibo Xu , "linux-doc@vger.kernel.org" , "Kumar, Sanjay K" , "Tian, Kevin" , "iommu@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "linuxarm@huawei.com" , Alex Williamson , "linux-crypto@vger.kernel.org" , Philippe Ombredanne , Thomas Gleixner , Hao Fang , "David S . Miller" , "linux-accelerators@lists.ozlabs.org" References: <20180802040557.GL160746@Turing-Arch-b> <20180802142243.GA3481@redhat.com> <20180803034721.GC91035@Turing-Arch-b> <20180803143944.GA4079@redhat.com> <20180806031252.GG91035@Turing-Arch-b> <20180806153257.GB6002@redhat.com> <11bace0e-dc14-5d2c-f65c-25b852f4e9ca@gmail.com> <20180808151835.GA3429@redhat.com> <20180809080352.GI91035@Turing-Arch-b> <20180809144613.GB3386@redhat.com> <20180810033913.GK91035@Turing-Arch-b> <0f6bac9b-8381-1874-9367-46b5f4cef56e@arm.com> From: Kenneth Lee Message-ID: <6ea4dcfd-d539-93e4-acf1-d09ea35f0ddc@gmail.com> Date: Sat, 11 Aug 2018 23:26:48 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <0f6bac9b-8381-1874-9367-46b5f4cef56e@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2018年08月10日 星期五 09:12 下午, Jean-Philippe Brucker 写道: > Hi Kenneth, > > On 10/08/18 04:39, Kenneth Lee wrote: >>> You can achieve everything you want to achieve with existing upstream >>> solution. Re-inventing a whole new driver infrastructure should really >>> be motivated with strong and obvious reasons. >> I want to understand better of your idea. If I create some unified helper >> APIs in drivers/iommu/, say: >> >> wd_create_dev(parent_dev, wd_dev) >> wd_release_dev(wd_dev) >> >> The API create chrdev to take request from user space for open(resource >> allocation), iomap, epoll (irq), and dma_map(with pasid automatically). >> >> Do you think it is acceptable? > Maybe not drivers/iommu/ :) That subsystem only contains tools for > dealing with DMA, I don't think epoll, resource enumeration or iomap fit > in there. Yes. I should consider where to put it carefully. > > Creating new helpers seems to be precisely what we're trying to avoid in > this thread, and vfio-mdev does provide the components that you > describe, so I wouldn't discard it right away. When the GPU, net, block > or another subsystem doesn't fit your needs, either because your > accelerator provides some specialized function, or because for > performance reasons your client wants direct MMIO access, you can at > least build your driver and library on top of those existing VFIO > components: > > * open allocates a partition of an accelerator. > * vfio_device_info, vfio_region_info and vfio_irq_info enumerates > available resources. > * vfio_irq_set deals with epoll. > * mmap gives you a private MMIO doorbell. > * vfio_iommu_type1 provides the DMA operations. > > Currently missing: > > * Sharing the parent IOMMU between mdev, which is also what the "IOMMU > aware mediated device" series tackles, and seems like a logical addition > to VFIO. I'd argue that the existing IOMMU ops (or ones implemented by > the SVA series) can be used to deal with this > > * The interface to discover an accelerator near your memory node, or one > that you can chain with other devices. If I understood correctly the > conclusion was that the API (a topology description in sysfs?) should be > common to various subsystems, in which case vfio-mdev (or the mediating > driver) could also use it. > > * The queue abstraction discussed on patch 3/7. Perhaps the current vfio > resource description of MMIO and IRQ is sufficient here as well, since > vendors tend to each implement their own queue schemes. If you need > additional features, read/write fops give the mediating driver a lot of > freedom. To support features that are too specific for drivers/vfio/ you > can implement a config space with capabilities and registers of your > choice. If you're versioning the capabilities, the code to handle them > could even be shared between different accelerator drivers and libraries. Thank you, Jean, The major reason that I want to remove dependency to VFIO is: I accepted that the whole logic of VFIO was built on the idea of creating virtual device. Let's consider it in this way: We have hardware with IOMMU support. So we create a default_domain to the particular IOMMU (unit) in the group for the kernel driver to use it. Now the device is going to be used by a VM or a Container. So we unbind it from the original driver, and put the default_domain away,  create a new domain for this particular use case.  So now the device shows up as a platform or pci device to the user space. This is what VFIO try to provide. Mdev extends the scenario but dose not change the intention. And I think that is why Alex emphasis pre-allocating resource to the mdev. But what WarpDrive need is to get service from the hardware itself and set mapping to its current domain, aka defaut_domain. If we do it in VFIO-mdev, it looks like the VFIO framework takes all the effort to put the default_domain away and create a new one and be ready for user space to use. But I tell him stop using the new domain and try the original one... It is not reasonable, isn't it:) So why don't I just take the request and set it into the default_domain directly? The true requirement of WarpDrive is to let process set the page table for particular pasid or substream id, so it can accept command with address in the process space. It needs no device. From this perspective, it seems there is no reason to keep it in VFIO. Thanks Kenneth > > Thanks, > Jean >