From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gregory@weka.io>
Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53])
 by dpdk.org (Postfix) with ESMTP id 2E39F5688
 for <dev@dpdk.org>; Thu,  1 Jun 2017 13:14:40 +0200 (CEST)
Received: by mail-wm0-f53.google.com with SMTP id n195so27457382wmg.1
 for <dev@dpdk.org>; Thu, 01 Jun 2017 04:14:40 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weka.io; s=google;
 h=from:to:cc:subject:date:message-id:organization:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=noseQcXF6sjwhpZVX2vmyB64rUkf4UBJFLoy70ebYTY=;
 b=EDMw2HCNNn1dYZjatTLU3J01aQdHqsMSihuFSRBc50hZggga9iPQwj3B6kB8+uU4U1
 Cw+LHv8xPeKBiVy1g2Z3WFhvfyxxQlfhgQCBiYyt82566E7NTiUOolRfL+BGUXtrbSi9
 NtxJerYYOEko+iAoQy+Va2E8eMxu7m+lzokjM=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:organization
 :in-reply-to:references:mime-version:content-transfer-encoding;
 bh=noseQcXF6sjwhpZVX2vmyB64rUkf4UBJFLoy70ebYTY=;
 b=tg9KQ8DtaWMzsh9hfcWLRAvACaCeESo8vOM19k3AdXR2CKutYVOtFNn5Q7NCofFQFz
 13/3h90fJhh+2GBz0ecgTE9wxYBF/Iwbm60kb2u2oo+atqF166p+6+w6SJqb2GSnZsYv
 AwWZLuoCPFSDKCscKu+zcgRry/b0EIqSjNPmiQDJbaB3jhYQVWVW6Sotta83IsMORIPc
 VTZsmjVaGobJ23IDu9IIW2iLVobphwrZzXHtZFjIZXRWnfPmDMYjj/iYWjFUNw7oDmFH
 qodkNaauoBf677+7RNJFDfUw/zGUKa4z63cf/ah+hti86lPP9l+2iVTDuReGI12yNedq
 PljQ==
X-Gm-Message-State: AODbwcBRYx4cl96cQpvyVwK++lsGiFkMsWl8ERjKZc9HNNCTr2ZGAQVj
 koPL0cJSx/QDhb/jCVE=
X-Received: by 10.28.193.198 with SMTP id r189mr9104083wmf.82.1496315679753;
 Thu, 01 Jun 2017 04:14:39 -0700 (PDT)
Received: from polaris.localnet (bzq-82-81-85-138.red.bezeqint.net.
 [82.81.85.138])
 by smtp.gmail.com with ESMTPSA id 43sm19854385wrx.26.2017.06.01.04.14.38
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Thu, 01 Jun 2017 04:14:39 -0700 (PDT)
From: Gregory Etelson <gregory@weka.io>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Shijith Thotton <shijith.thotton@caviumnetworks.com>,
 Stephen Hemminger <stephen@networkplumber.org>, dev@dpdk.org,
 Qi Zhang <qi.z.zhang@intel.com>, Wenzhuo Lu <wenzhuo.lu@intel.com>,
 Thomas Monjalon <thomas@monjalon.net>, Jianfeng Tan <jianfeng.tan@intel.com>
Date: Thu, 01 Jun 2017 14:14:37 +0300
Message-ID: <1661537.DnT1oieyyl@polaris>
Organization: Weka.IO
In-Reply-To: <f55be7d7-24af-4ea8-2808-c2e50731dce1@intel.com>
References: <1748341.rbpcFmWp0q@polaris>
 <1496228966-18573-1-git-send-email-shijith.thotton@caviumnetworks.com>
 <f55be7d7-24af-4ea8-2808-c2e50731dce1@intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7Bit
X-Content-Filtered-By: Mailman/MimeDel 2.1.15
Subject: Re: [dpdk-dev] [RFC PATCH] igb_uio: issue FLR during open and
	release of device file
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 01 Jun 2017 11:14:40 -0000


On Wednesday, 31 May 2017 15:20:08 IDT Ferruh Yigit wrote:
> On 5/31/2017 12:09 PM, Shijith Thotton wrote:
> > Set UIO info device file operations open and release. Call pci reset
> > function inside open and release to clear device state at start and
> > end. Copied this behaviour from vfio_pci kernel module code. With this
> > change, it is not mandatory to issue FLR by PMD's during init and close.
> 
> Cc: Jianfeng Tan <jianfeng.tan@intel.com>
> 
> Jianfeng also implemented following patch:
> http://dpdk.org/dev/patchwork/patch/17495/
> 
> Which also implements release and open ops, for slightly different
> reason (prevent DMA access after app exit), but mainly both are to
> gracefully handle application exit status.
> 
> btw, for Jianfeng's case, can adding pci_clear_master() in release and
> moving pci_set_master() to open help preventing unwanted DMA?
> 
> 
> Gregory,
> 
> Can you please check if this patch fixes your issue?
> 
> Thanks,
> ferruh

The tests are running.
I'll update you on completion.

Regards,
Gregory


> 
> > 
> > Signed-off-by: Shijith Thotton <shijith.thotton@caviumnetworks.com>
> > ---
> >  lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 30 ++++++++++++++++++++++++++++++
> >  1 file changed, 30 insertions(+)
> > 
> > diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> > index b9d427c..5bc58d2 100644
> > --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> > +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c
> > @@ -170,6 +170,34 @@ struct rte_uio_pci_dev {
> >  	return IRQ_HANDLED;
> >  }
> >  
> > +/**
> > + * This gets called while opening uio device file. It clears any previous state
> > + * associated with the pci device.
> > + */
> > +static int
> > +igbuio_pci_open(struct uio_info *info, struct inode *inode)
> > +{
> > +	struct rte_uio_pci_dev *udev = info->priv;
> > +	struct pci_dev *dev = udev->pdev;
> > +
> > +	/* reset the pci device */
> > +	pci_reset_function(dev);
> > +
> > +	return 0;
> > +}
> > +
> > +static int
> > +igbuio_pci_release(struct uio_info *info, struct inode *inode)
> > +{
> > +	struct rte_uio_pci_dev *udev = info->priv;
> > +	struct pci_dev *dev = udev->pdev;
> > +
> > +	/* try to reset the pci device */
> > +	pci_try_reset_function(dev);
> > +
> > +	return 0;
> > +}
> > +
> >  #ifdef CONFIG_XEN_DOM0
> >  static int
> >  igbuio_dom0_mmap_phys(struct uio_info *info, struct vm_area_struct *vma)
> > @@ -372,6 +400,8 @@ struct rte_uio_pci_dev {
> >  	udev->info.version = "0.1";
> >  	udev->info.handler = igbuio_pci_irqhandler;
> >  	udev->info.irqcontrol = igbuio_pci_irqcontrol;
> > +	udev->info.open = igbuio_pci_open;
> > +	udev->info.release = igbuio_pci_release;
> >  #ifdef CONFIG_XEN_DOM0
> >  	/* check if the driver run on Xen Dom0 */
> >  	if (xen_initial_domain())
> > 
> 
>