Received: by 10.213.65.68 with SMTP id h4csp1588250imn; Mon, 26 Mar 2018 10:23:34 -0700 (PDT) X-Google-Smtp-Source: AG47ELujYbcU04Ag6cDk1JjAGBt+XRQSWDCOdykTNwiUQdDanMzqM2Azr71lQwwVUB3oRqdRFnuB X-Received: by 10.98.214.218 with SMTP id a87mr25704355pfl.124.1522085014249; Mon, 26 Mar 2018 10:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522085014; cv=none; d=google.com; s=arc-20160816; b=N87dChZMy9AclwBYhUIgJvVUWcT3M0gDpT4/NF+CyuVarC50YD6XbEpXG6nV8Vtdgl 2cAM16jcpPTSOJziEiEG9Vg+6Gb0iLf2F7kEoNbq5IcgO2qs8FysF7EfK0iPstvbkQbm mHaIm5vkLPjt55WgIhIpwAys54Ahwv6PFptryBGrUedCkP9SovPdtAHgoX8eZbwX3dl6 7BVAcrNn2+BXAqcmy6VjjGc6/reK6CDYEkIqkHKX/Cj2Xb/ZDoS7QVoLNp4kCj6Ay2Ft rZJoiI7lhyi9PvFgig/wlazG2F4vkL+3pzEPBp3YY+Dwu4hZQjg/NdEOyyK5D5njXvMR IYhw== 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:dmarc-filter :arc-authentication-results; bh=dRii03N639Jvqupg8Ueh5dBIs9U/ACme/4uMgRs5ETs=; b=OUmip+ADwpw5swFlRZsnr6vr0TbmnxEq5x1iL5Qe1qcJcRlkO/DroyTgfQzaXEOTaz WdGiDHhL4SQdvZS+HfHPe8bjSN4XFaBwkndj/V68qUDrdDKmDpaPLag0iDB3LHbWX++H mdh21ef6gWoP4Q7GuHHDfJW4VxJ2Q9SAKVFnATfa+b7dhrbU1jmBjviGecDdnatT+J1d SbFa206HIMyGETXE8mG7RzRqPt8xKSYOwOX+JrGDF65PRYL+FM4YxljB6o+ba3E4mode dLl6s6y/pK3Dn+8HkB3qEaSTqkl9MiRaiV5n7vxStwVaY1UVDd0SZWSAIkGST+jAyObe 1gPA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g8si10262712pgv.740.2018.03.26.10.23.18; Mon, 26 Mar 2018 10:23:34 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752647AbeCZRWI (ORCPT + 99 others); Mon, 26 Mar 2018 13:22:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:34274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751964AbeCZRWG (ORCPT ); Mon, 26 Mar 2018 13:22:06 -0400 Received: from mail-qt0-f170.google.com (mail-qt0-f170.google.com [209.85.216.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E8D22172B; Mon, 26 Mar 2018 17:22:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E8D22172B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=atull@kernel.org Received: by mail-qt0-f170.google.com with SMTP id f16so7942848qth.3; Mon, 26 Mar 2018 10:22:05 -0700 (PDT) X-Gm-Message-State: AElRT7EFvFTOQ8sI1zWE0A0FCYWQ7SKUZKE6h9nYUVAImep47ocqQd/k t5af3ZrjNbfUN9cOozu4my5fFnxautMta2H3HMY= X-Received: by 10.200.24.248 with SMTP id o53mr56836785qtk.79.1522084924382; Mon, 26 Mar 2018 10:22:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.27.18 with HTTP; Mon, 26 Mar 2018 10:21:23 -0700 (PDT) In-Reply-To: <20180323043304.GA14733@hao-dev> References: <1518513893-4719-1-git-send-email-hao.wu@intel.com> <1518513893-4719-5-git-send-email-hao.wu@intel.com> <20180323043304.GA14733@hao-dev> From: Alan Tull Date: Mon, 26 Mar 2018 12:21:23 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 04/24] fpga: add device feature list support To: Wu Hao Cc: Moritz Fischer , linux-fpga@vger.kernel.org, linux-kernel , linux-api@vger.kernel.org, "Kang, Luwei" , "Zhang, Yi Z" , Tim Whisonant , Enno Luebbers , Shiva Rao , Christopher Rauer , Xiao Guangrong 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 Thu, Mar 22, 2018 at 11:33 PM, Wu Hao wrote: >> > + >> > +/* >> > + * This function resets the FPGA Port and its accelerator (AFU) by function >> > + * __fpga_port_disable and __fpga_port_enable (set port soft reset bit and >> > + * then clear it). Userspace can do Port reset at any time, e.g during DMA >> > + * or Partial Reconfiguration. But it should never cause any system level >> > + * issue, only functional failure (e.g DMA or PR operation failure) and be >> > + * recoverable from the failure. >> > + * >> > + * Note: the accelerator (AFU) is not accessible when its port is in reset >> > + * (disabled). Any attempts on MMIO access to AFU while in reset, will >> > + * result errors reported via port error reporting sub feature (if present). >> > + */ >> > +static inline int __fpga_port_reset(struct platform_device *pdev) >> > +{ >> > + int ret; >> > + >> > + ret = __fpga_port_disable(pdev); >> > + if (ret) >> > + return ret; >> > + >> > + __fpga_port_enable(pdev); >> > + >> > + return 0; >> > +} >> > + >> > +static inline int fpga_port_reset(struct platform_device *pdev) >> > +{ >> > + struct feature_platform_data *pdata = dev_get_platdata(&pdev->dev); >> > + int ret; >> > + >> > + mutex_lock(&pdata->lock); >> > + ret = __fpga_port_reset(pdev); >> > + mutex_unlock(&pdata->lock); >> > + >> > + return ret; >> > +} >> >> I'm still scratching my head about how the enumeration code also has >> code that handles resetting the PL in a FPGA region and >> enabling/disabling the bridge. We've discussed this before [1] and I >> know you've looked into it, I'm still trying to figure out how this >> can be made modular, so when someone needs to support a different port >> in the future, it isn't a complete rewrite. >> >> Speaking of resets, one way forward would be to create a reset >> controller for the port (and if possible move the port code to the >> bridge platform driver). The current linux-next repo adds support for >> reset lookups, so that reset controllers are supported for non-DT >> platforms [2]. >> >> So the bridge driver would implement the enable/disable functions and >> create a reset controller, the fpga-region (or whoever else needs it) >> could look the reset controller and use the reset. By using the >> kernel reset framework, we don't have to have that piece of code >> shared around by having a reset function in a .h file. And it avoids >> adding extra dependencies between modules. Also, where necessary, I'd >> rather add functionality to the existing bridge/mgr/region frameworks, >> adding common interfaces at that level to allow reuse (like adding >> status to fpga-mgr). Ideally, this DFL framework would sit on top of >> mgr and bridge and allow those to be swapped out for reuse of the DFL >> framework on other devices. Also it will save future headaches as mgr >> or port implementations evolve. > > Thanks a lot for the suggestion. I really really appreciate this. Yes, this is a good discussion, thanks. > > Actually if we consider the virutalization case as I mentioned in [1] below, > that means AFU and its Port will be turned into a PCI VF and assigned (passed > through) to a virtual machine. There is no FME block on that PCI VF device, > (the FME is always kept in PCI PF device in the host) and currently the bridge > is created by FME module for PR functionatily. So in the guest virtual machine, > nobody creates the reset controller actually. > > As I mentioned in [1], one possible method is, put these port reset functions to > AFU (Port) module, and share those functions with FME bridge module. Yes, the port reset functions could move into an AFU driver, and then also the AFU driver could also create a reset controller and register a lookup [2] for the reset. That would be just a few lines of code. The reset controller would control enabling/disabling the port. The bridge driver could get the reset controller to use during FPGA programming. That is instead of sharing a reset function with the bridge driver. It decouples the FPGA bridge driver and simplifies it to be something that just needs to control a reset instead of needing to include a specific .h file that makes a port reset function available. > I think > that will make the code in the common DFL framework a little more clean, Yes, IIUC that may also make it easier as the port/AFU gets added functionality that is intended to be controlled by the VF anyway (while the only port-related thing that is needed by the FME is port enable/disable). > but it > will introduce some module dependency here for sure, (e.g FME modules can't > finish PR without AFU (Port) Module loaded). That sounds like an OK type of dependency, i.e. if the modules are not all loaded, it doesn't work. :-) > But anyway it may be still > acceptable for users as all these modules could be loaded automatically. How do > you think? :) The other thing I want to get right now is if there is a different AFU/port that needs a different driver. Can the DFL be changed to specify what AFU/port to load? I really really want to avoid large code rewrites in the future that we can anticipate now. Such as someone implements their own static image, it has DFL, but the port is somewhat different. Instead of seeing features as just something that gets added, the DFL also specifies what port driver and mgr driver to load. The stuff we discussed above is a good step towards that, but not all of it. Alan > > Thanks > Hao > > >> >> Alan >> >> [1] https://lkml.org/lkml/2017/12/22/398 >> [2] https://patchwork.kernel.org/patch/10247475/