Skip to contentSkip to conversation

iommu: Eliminate an odd local variable

PATCH In review Andrii Anisov 2 participants 3 messages Jan 21, 2019 – Jan 22, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu: Eliminate an odd local variable

From: Andrii Anisov <[email protected]>

Wipe out excessive lines from an iommu_unmap(), and align it with an iommu_map() code.

---
 xen/drivers/passthrough/iommu.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
xen/drivers/passthrough/iommu.c +3 -6
index bd1af35..b31a1a9 100644
@@ -385,19 +385,16 @@ int iommu_unmap(struct domain *d, dfn_t dfn, unsigned int page_order,
 
     for ( i = 0; i < (1ul << page_order); i++ )
     {
-        int err = hd->platform_ops->unmap_page(d, dfn_add(dfn, i),
+        rc = hd->platform_ops->unmap_page(d, dfn_add(dfn, i),
                                                flush_flags);
 
-        if ( likely(!err) )
+        if ( likely(!rc) )
             continue;
 
         if ( !d->is_shutting_down && printk_ratelimit() )
             printk(XENLOG_ERR
                    "d%d: IOMMU unmapping dfn %"PRI_dfn" failed: %d\n",
-                   d->domain_id, dfn_x(dfn_add(dfn, i)), err);
-
-        if ( !rc )
-            rc = err;
+                   d->domain_id, dfn_x(dfn_add(dfn, i)), rc);
 
         if ( !is_hardware_domain(d) )
         {
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 21.01.19 at 17:04, <[email protected]> wrote:

Wipe out excessive lines from an iommu_unmap(), and align it with an iommu_map() code.

What's excessive there? How come you alter the function's return value without saying why? The more that you make it potentially return success when there was an error.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw

Hello Jan,

Quoted 3 lines · Jan Beulich

What's excessive there? How come you alter the function's return value without saying why? The more that you make it potentially return success when there was an error.

Ah, I've realized the difference. In unmap, for hardware domain, we will iterate through pages even if some page failed to unmap, preserving the first caught error. So my patch is wrong.

Sorry for disturbing.

Signature · 7 lines
Sincerely,
Andrii Anisov.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel