Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751338AbdGMCi3 (ORCPT ); Wed, 12 Jul 2017 22:38:29 -0400 Received: from mga07.intel.com ([134.134.136.100]:4700 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751073AbdGMCi1 (ORCPT ); Wed, 12 Jul 2017 22:38:27 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,352,1496127600"; d="scan'208";a="1171864694" Date: Thu, 13 Jul 2017 10:31:51 +0800 From: Wu Hao To: Alan Tull 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 Subject: Re: [PATCH v2 17/22] fpga: intel: add fpga region platform driver for FME Message-ID: <20170713023151.GA28569@hao-dev> References: <1498441938-14046-1-git-send-email-hao.wu@intel.com> <1498441938-14046-18-git-send-email-hao.wu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4972 Lines: 146 On Wed, Jul 12, 2017 at 11:09:46AM -0500, Alan Tull wrote: > On Sun, Jun 25, 2017 at 8:52 PM, Wu Hao wrote: > > Hi Hao, > > Thanks for using the region patchset. This looks good except for one > thing below. Hi Alan Thank you very much for your review. : ) > > > This patch adds fpga region platform driver for Intel FPGA Management > > Engine. It register a fpga region with given fpga manager / bridge > > device. > > > > Signed-off-by: Tim Whisonant > > Signed-off-by: Enno Luebbers > > Signed-off-by: Shiva Rao > > Signed-off-by: Christopher Rauer > > Signed-off-by: Wu Hao > > --- > > drivers/fpga/Kconfig | 7 +++ > > drivers/fpga/Makefile | 1 + > > drivers/fpga/intel-fpga-fme-region.c | 91 ++++++++++++++++++++++++++++++++++++ > > 3 files changed, 99 insertions(+) > > create mode 100644 drivers/fpga/intel-fpga-fme-region.c > > > > diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig > > index 05e2a8e..db1a6ea 100644 > > --- a/drivers/fpga/Kconfig > > +++ b/drivers/fpga/Kconfig > > @@ -165,6 +165,13 @@ config INTEL_FPGA_FME_BRIDGE > > Say Y to enable FPGA Bridge driver for Intel FPGA Management > > Engine. > > > > +config INTEL_FPGA_FME_REGION > > + tristate "Intel FPGA FME Region Driver" > > + depends on INTEL_FPGA_FME && FPGA_REGION > > + help > > + Say Y to enable FPGA Region driver for Intel FPGA Management > > + Engine. > > + > > endif > > > > endif # FPGA > > diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile > > index 131c105..fd0a71f 100644 > > --- a/drivers/fpga/Makefile > > +++ b/drivers/fpga/Makefile > > @@ -33,6 +33,7 @@ obj-$(CONFIG_INTEL_FPGA_PCI) += intel-fpga-pci.o > > obj-$(CONFIG_INTEL_FPGA_FME) += intel-fpga-fme.o > > obj-$(CONFIG_INTEL_FPGA_FME_MGR) += intel-fpga-fme-mgr.o > > obj-$(CONFIG_INTEL_FPGA_FME_BRIDGE) += intel-fpga-fme-br.o > > +obj-$(CONFIG_INTEL_FPGA_FME_REGION) += intel-fpga-fme-region.o > > > > intel-fpga-pci-objs := intel-pcie.o intel-feature-dev.o > > intel-fpga-fme-objs := intel-fme-main.o intel-fme-pr.o > > diff --git a/drivers/fpga/intel-fpga-fme-region.c b/drivers/fpga/intel-fpga-fme-region.c > > new file mode 100644 > > index 0000000..2b5ca4d > > --- /dev/null > > +++ b/drivers/fpga/intel-fpga-fme-region.c > > @@ -0,0 +1,91 @@ > > +/* > > + * FPGA Region Driver for Intel FPGA Management Engine (FME) > > + * > > + * Copyright (C) 2017 Intel Corporation, Inc. > > + * > > + * Authors: > > + * Wu Hao > > + * Joseph Grecco > > + * Enno Luebbers > > + * Tim Whisonant > > + * Ananda Ravuri > > + * Henry Mitchel > > + * > > + * This work is licensed under the terms of the GNU GPL version 2. See > > + * the COPYING file in the top-level directory. > > + */ > > + > > +#include > > +#include > > + > > +#include "intel-feature-dev.h" > > +#include "intel-fme.h" > > + > > +static int fme_region_get_bridges(struct fpga_region *region, > > + struct fpga_image_info *info) > > +{ > > + struct fme_region_pdata *pdata = region->priv; > > + struct device *dev = &pdata->br->dev; > > + > > + return fpga_bridge_get_to_list(dev, info, ®ion->bridge_list); > > +} > > + > > +static int fme_region_probe(struct platform_device *pdev) > > +{ > > + struct device *dev = &pdev->dev; > > + struct fme_region_pdata *pdata = dev_get_platdata(dev); > > + struct fpga_region *region; > > + struct fpga_manager *mgr; > > + int ret; > > + > > + mgr = fpga_mgr_get(&pdata->mgr->dev); > > + if (IS_ERR(mgr)) > > + return -EPROBE_DEFER; > > + > > + region = devm_kzalloc(dev, sizeof(*region), GFP_KERNEL); > > + if (!region) { > > + ret = -ENOMEM; > > + goto eprobe_mgr_put; > > + } > > + > > + region->mgr = mgr; > > + region->get_bridges = fme_region_get_bridges; > > + region->priv = pdata; > > + > > + ret = fpga_region_register(dev, region); > > + if (ret) > > + goto eprobe_mgr_put; > > + > > + dev_dbg(dev, "Intel FME FPGA Region probed\n"); > > + > > + return 0; > > + > > +eprobe_mgr_put: > > + fpga_mgr_put(mgr); > > + return ret; > > +} > > + > > +static int fme_region_remove(struct platform_device *pdev) > > +{ > > + struct fpga_region *region = dev_get_drvdata(&pdev->dev); > > + > > + fpga_mgr_put(region->mgr); > > + fpga_region_unregister(region); > > Please unregister before putting the mgr ;) > Sure, make sense, I will fix this in the next version. Thanks Hao