[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v9 05/16] vpci/header: rework exit path in init_bars


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Tue, 29 Aug 2023 23:19:43 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=N2ERcj6JUMizs9Szx0x2ffT7vSpYcqMvosqrwubMiSw=; b=I3CG+YRWH+GFCXOjVWR5Vg72nYWBzGZMC8NaNMBzwB6RHcFaRmK3gyhpezHNnZ2C8uN4+o1Dat51/SOZnO4I1ymKnhECg2x8CNmM/aY9Ogjhh1XHB3RFO5T4zduAPatn2Rt+rrritzw0I+qm/SlqzrfHif4/BcBmWu//gmKgcPf2//IPxu5y1y7Pbc0elHynSJS4hPV62ELtmamzG4Da+1xq8PzdYRD3hbcim6lR0GpWs251H02EVvwRIe6qo1zyk5cIi7MGe0bRgIjqXkwhq1iZa5BbS1aaV7bSsUcpxjY9bwRtiw8gyAFf0TQRk91dydmQQt3+rYBSpTjZYW971w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B4d+f4pv70rXV2sw928uvv07hADPv1MUOhzWAB1MNwYbqKoyCLC3iIn+IQ3gFjEV8S8aSMV2UjgD0M5pgUq07Wkom8VK3iNM+p4gkiKGvLqI7CaM8CQ87O2+V1y7P5HSczFLNUTxKj3UxuKBCbJIz9B/Be+YETf/2v1djj988jn0IRyr8/eT1GohhFuDHQtHGkpgO8RyD1yWl+SXRnKuabWoeu/86xvWxL2c5eYat17+7Y8A6Iha5au+GEYa5heljSXgAjU3gt9sR/zovieOMeiv25eBWECF41Lf9QCxSYTxuulfXc2KCTHZQ7duInlbyDSweXR2PLKiBxQFlfpfRw==
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 29 Aug 2023 23:20:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZ2s9KQBAEWRsQM0+8e3gDHK2mZA==
  • Thread-topic: [PATCH v9 05/16] vpci/header: rework exit path in init_bars

Introduce "fail" label in init_bars() function to have the centralized
error return path. This is the pre-requirement for the future changes
in this function.

This patch does not introduce functional changes.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
Suggested-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
--
Since v9:
- New in v9
---
 xen/drivers/vpci/header.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 3b797df82f..e58bbdf68d 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -581,11 +581,7 @@ static int cf_check init_bars(struct pci_dev *pdev)
             rc = vpci_add_register(pdev->vpci, vpci_hw_read32, bar_write, reg,
                                    4, &bars[i]);
             if ( rc )
-            {
-                pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
-                return rc;
-            }
-
+                goto fail;
             continue;
         }
 
@@ -604,10 +600,7 @@ static int cf_check init_bars(struct pci_dev *pdev)
         rc = pci_size_mem_bar(pdev->sbdf, reg, &addr, &size,
                               (i == num_bars - 1) ? PCI_BAR_LAST : 0);
         if ( rc < 0 )
-        {
-            pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
-            return rc;
-        }
+            goto fail;
 
         if ( size == 0 )
         {
@@ -622,10 +615,7 @@ static int cf_check init_bars(struct pci_dev *pdev)
         rc = vpci_add_register(pdev->vpci, vpci_hw_read32, bar_write, reg, 4,
                                &bars[i]);
         if ( rc )
-        {
-            pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
-            return rc;
-        }
+            goto fail;
     }
 
     /* Check expansion ROM. */
@@ -647,6 +637,10 @@ static int cf_check init_bars(struct pci_dev *pdev)
     }
 
     return (cmd & PCI_COMMAND_MEMORY) ? modify_bars(pdev, cmd, false) : 0;
+
+ fail:
+    pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
+    return rc;
 }
 REGISTER_VPCI_INIT(init_bars, VPCI_PRIORITY_MIDDLE);
 
-- 
2.41.0

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.