From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758086AbbJ3FJO (ORCPT ); Fri, 30 Oct 2015 01:09:14 -0400 Received: from e28smtp02.in.ibm.com ([122.248.162.2]:33453 "EHLO e28smtp02.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757999AbbJ3FJM (ORCPT ); Fri, 30 Oct 2015 01:09:12 -0400 X-Helo: d28dlp03.in.ibm.com X-MailFrom: weiyang@linux.vnet.ibm.com X-RcptTo: linux-pci@vger.kernel.org Date: Fri, 30 Oct 2015 13:09:04 +0800 From: Wei Yang To: Bjorn Helgaas Cc: Alexander Duyck , linux-pci@vger.kernel.org, Ethan Zhao , Wei Yang , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/7] PCI: Remove VFs in reverse order if virtfn_add() fails Message-ID: <20151030050904.GB5119@richards-mbp.cn.ibm.com> Reply-To: Wei Yang References: <20151029221701.11908.82718.stgit@bhelgaas-glaptop2.roam.corp.google.com> <20151029222308.11908.95902.stgit@bhelgaas-glaptop2.roam.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151029222308.11908.95902.stgit@bhelgaas-glaptop2.roam.corp.google.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15103005-0005-0000-0000-0000086ABC67 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 29, 2015 at 05:23:08PM -0500, Bjorn Helgaas wrote: >From: Alexander Duyck > >If virtfn_add() fails, we call virtfn_remove() for any previously added >devices. Remove the devices in reverse order (first-added is >last-removed), which is more natural and doesn't require an additional >variable. > >[bhelgaas: changelog, split to separate patch for reviewability] >Signed-off-by: Alexander Duyck >Signed-off-by: Bjorn Helgaas Interesting. Reviewed-by: Wei Yang >--- > drivers/pci/iov.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > >diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c >index ca400a9..c86d94c 100644 >--- a/drivers/pci/iov.c >+++ b/drivers/pci/iov.c >@@ -233,7 +233,7 @@ int __weak pcibios_sriov_enable(struct pci_dev *pdev, u16 num_vfs) > static int sriov_enable(struct pci_dev *dev, int nr_virtfn) > { > int rc; >- int i, j; >+ int i; > int nres; > u16 initial; > struct resource *res; >@@ -328,8 +328,8 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) > return 0; > > failed: >- for (j = 0; j < i; j++) >- virtfn_remove(dev, j, 0); >+ while (i--) >+ virtfn_remove(dev, i, 0); > > iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE); > pci_cfg_access_lock(dev); -- Richard Yang Help you, Help me