[PATCH v1 2/5] vpci: rework error path in vpci_process_pending()

Stewart Hildebrand posted 5 patches 5 months ago
There is a newer version of this series
[PATCH v1 2/5] vpci: rework error path in vpci_process_pending()
Posted by Stewart Hildebrand 5 months ago
This will make further refactoring simpler.

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 xen/drivers/vpci/header.c | 42 +++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index e42c8efa2302..c1463d2ce076 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -214,27 +214,7 @@ bool vpci_process_pending(struct vcpu *v)
         }
 
         if ( rc )
-        {
-            spin_lock(&pdev->vpci->lock);
-            /* Disable memory decoding unconditionally on failure. */
-            modify_decoding(pdev, v->vpci.cmd & ~PCI_COMMAND_MEMORY,
-                            false);
-            spin_unlock(&pdev->vpci->lock);
-
-            /* Clean all the rangesets */
-            for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
-                if ( !rangeset_is_empty(header->bars[i].mem) )
-                     rangeset_purge(header->bars[i].mem);
-
-            v->vpci.pdev = NULL;
-
-            read_unlock(&v->domain->pci_lock);
-
-            if ( !is_hardware_domain(v->domain) )
-                domain_crash(v->domain);
-
-            return false;
-        }
+            goto fail;
     }
     v->vpci.pdev = NULL;
 
@@ -245,6 +225,26 @@ bool vpci_process_pending(struct vcpu *v)
     read_unlock(&v->domain->pci_lock);
 
     return false;
+
+ fail:
+    spin_lock(&pdev->vpci->lock);
+    /* Disable memory decoding unconditionally on failure. */
+    modify_decoding(pdev, v->vpci.cmd & ~PCI_COMMAND_MEMORY, false);
+    spin_unlock(&pdev->vpci->lock);
+
+    /* Clean all the rangesets */
+    for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
+        if ( !rangeset_is_empty(header->bars[i].mem) )
+             rangeset_purge(header->bars[i].mem);
+
+    v->vpci.pdev = NULL;
+
+    read_unlock(&v->domain->pci_lock);
+
+    if ( !is_hardware_domain(v->domain) )
+        domain_crash(v->domain);
+
+    return false;
 }
 
 static int __init apply_map(struct domain *d, const struct pci_dev *pdev,
-- 
2.49.0
Re: [PATCH v1 2/5] vpci: rework error path in vpci_process_pending()
Posted by Roger Pau Monné 4 months, 4 weeks ago
On Sat, May 31, 2025 at 08:54:00AM -0400, Stewart Hildebrand wrote:
> This will make further refactoring simpler.

I think you want to add:

No functional change intended.

To the commit message.

> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>

Acked-by: Roger Pau Monné <roger.pau@citrix.com>

The success and error paths have some shared code, that might be good
to unify, but that requires further rework.

Thanks, Roger.

Re: [PATCH v1 2/5] vpci: rework error path in vpci_process_pending()
Posted by Stewart Hildebrand 4 months, 3 weeks ago
On 6/5/25 05:53, Roger Pau Monné wrote:
> On Sat, May 31, 2025 at 08:54:00AM -0400, Stewart Hildebrand wrote:
>> This will make further refactoring simpler.
> 
> I think you want to add:
> 
> No functional change intended.
> 
> To the commit message.

Yep, will do.

> 
>> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
> 
> Acked-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks!

> The success and error paths have some shared code, that might be good
> to unify, but that requires further rework.
> 
> Thanks, Roger.