Skip to contentSkip to conversation

iommu VT-d: separate rmrr addition function

PATCH Elena Ufimtseva 1 participant 1 message Mar 12, 2015

lore
Share & tools
lore
#0 lore raw
Quoted 11 lines · ----- [email protected] wrote:
Quoted 10 lines · Jan Beulich

xen/drivers/passthrough/vtd/dmar.c out: · line 570

Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 09.03.15 at 15:42, <[email protected]> wrote:
xen/drivers/passthrough/vtd/dmar.c +1 -0
@@ -567,6 +567,66 @@ out:
     return ret;
 }
 
+int register_one_rmrr(struct acpi_rmrr_unit *rmrru)

static - I don't see why the command line processing in patch 2

Quoted 6 lines

can't

Quoted 1 line

be put in this file.

I wanted to keep it close to iommu command line parser in iommu.c. Andrew mentioned that the parser should be defined as custom_param. Did you mean that as well and that it should be moved to dmar.c?

Never mind, I saw the answer.

Quoted 157 lines
Quoted 11 lines
Quoted 11 lines
xen/drivers/passthrough/vtd/dmar.c +9 -0
+{
+    u8 b, d, f;
+    bool_t ignore = 0;
+    unsigned int i = 0;
+    int ret = 0;
+
+    /* Skip checking if segment is not accessible yet. */
+    if ( !pci_known_segment(rmrru->segment) )
+        i = UINT_MAX;
Quoted 8 lines

xen/drivers/passthrough/vtd/dmar.c out: · line 585

Quoted 6 lines
xen/drivers/passthrough/vtd/dmar.c +6 -0
+
+    for ( ; i < rmrru->scope.devices_cnt; i++ )
+    {
+        b = PCI_BUS(rmrru->scope.devices[i]);
+        d = PCI_SLOT(rmrru->scope.devices[i]);
+        f = PCI_FUNC(rmrru->scope.devices[i]);

Please make this the declarations (with initializers) of these

variables;

Quoted 7 lines

they don't appear to be used outside this scope.

Quoted 5 lines
xen/drivers/passthrough/vtd/dmar.c +5 -0
+
+        if ( pci_device_detect(rmrru->segment, b, d, f) == 0 )
+        {
+            dprintk(XENLOG_WARNING VTDPREFIX,
+                    " Non-existent device (%04x:%02x:%02x.%u) is

reported"

Quoted 1 line

xen/drivers/passthrough/vtd/dmar.c out: · line 591

Quoted 1 line
xen/drivers/passthrough/vtd/dmar.c +1 -0
+                    " in RMRR (%"PRIx64", %"PRIx64")'s

scope!\n",

Quoted 8 lines
Quoted 8 lines
xen/drivers/passthrough/vtd/dmar.c +8 -0
+                    rmrru->segment, b, d, f,
+                    rmrru->base_address, rmrru->end_address);
+            ignore = 1;
+        }
+        else
+        {
+            ignore = 0;
+            break;
Quoted 8 lines

xen/drivers/passthrough/vtd/dmar.c out: · line 607

Quoted 8 lines
xen/drivers/passthrough/vtd/dmar.c +8 -0
+        }
+    }
+
+    if ( ignore )
+    {
+        dprintk(XENLOG_WARNING VTDPREFIX,
+            "  Ignore the RMRR (%"PRIx64", %"PRIx64") due to "
+            "devices under its scope are not PCI

discoverable!\n",

Quoted 21 lines
Quoted 10 lines
xen/drivers/passthrough/vtd/dmar.c +10 -0
+            rmrru->base_address, rmrru->end_address);
+        ret = -EFAULT;
+    }
+    else if ( rmrru->base_address > rmrru->end_address )
+    {
+        dprintk(XENLOG_WARNING VTDPREFIX,
+            "  The RMRR (%"PRIx64", %"PRIx64") is incorrect!\n",
+            rmrru->base_address, rmrru->end_address);
+        ret = -EFAULT;
+    }

xen/drivers/passthrough/vtd/dmar.c out: · line 627

Quoted 10 lines
xen/drivers/passthrough/vtd/dmar.c +10 -0
+    else
+    {
+        if ( iommu_verbose )
+            dprintk(VTDPREFIX,
+                    "  RMRR region: base_addr %"PRIx64
+                    " end_address %"PRIx64"\n",
+                    rmrru->base_address, rmrru->end_address);
+        acpi_register_rmrr_unit(rmrru);
+    }
+    return ret;
Quoted 3 lines

Blank line before return please.

xen/drivers/passthrough/vtd/dmar.c acpi_parse_one_rmrr(struct acpi_dmar_header

Quoted 1 line
xen/drivers/passthrough/vtd/dmar.c +0 -0
@@ -618,66 +678,14 @@ acpi_parse_one_rmrr(struct acpi_dmar_header

*header)

Quoted 1 line

xen/drivers/passthrough/vtd/dmar.c acpi_parse_one_rmrr(struct acpi_dmar_header · line 678

Quoted 1 line
xen/drivers/passthrough/vtd/dmar.c +0 -0
                                &rmrru->scope, RMRR_TYPE,

rmrr->segment);

Quoted 12 lines
Quoted 12 lines
xen/drivers/passthrough/vtd/dmar.c +0 -9
     if ( ret || (rmrru->scope.devices_cnt == 0) )
-        xfree(rmrru);
-    else
     {
-        u8 b, d, f;
-        bool_t ignore = 0;
-        unsigned int i = 0;
-
-        /* Skip checking if segment is not accessible yet. */
-        if ( !pci_known_segment(rmrr->segment) )
-            i = UINT_MAX;
Quoted 8 lines

xen/drivers/passthrough/vtd/dmar.c acpi_parse_one_rmrr(struct acpi_dmar_header · line 637

Quoted 8 lines
xen/drivers/passthrough/vtd/dmar.c +0 -8
-
-        for ( ; i < rmrru->scope.devices_cnt; i++ )
-        {
-            b = PCI_BUS(rmrru->scope.devices[i]);
-            d = PCI_SLOT(rmrru->scope.devices[i]);
-            f = PCI_FUNC(rmrru->scope.devices[i]);
-
-            if ( pci_device_detect(rmrr->segment, b, d, f) == 0

)

Quoted 3 lines

xen/drivers/passthrough/vtd/dmar.c acpi_parse_one_rmrr(struct acpi_dmar_header · line 640

Quoted 3 lines
xen/drivers/passthrough/vtd/dmar.c +0 -3
-            {
-                dprintk(XENLOG_WARNING VTDPREFIX,
-                        " Non-existent device (%04x:%02x:%02x.%u)

is reported"

Quoted 1 line

xen/drivers/passthrough/vtd/dmar.c acpi_parse_one_rmrr(struct acpi_dmar_header · line 641

Quoted 1 line
xen/drivers/passthrough/vtd/dmar.c +0 -1
-                        " in RMRR (%"PRIx64", %"PRIx64")'s

scope!\n",

Quoted 2 lines

xen/drivers/passthrough/vtd/dmar.c acpi_parse_one_rmrr(struct acpi_dmar_header · line 643

Quoted 2 lines
xen/drivers/passthrough/vtd/dmar.c +0 -2
-                        rmrr->segment, b, d, f,
-                        rmrru->base_address,

rmrru->end_address);

Quoted 5 lines
Quoted 5 lines
xen/drivers/passthrough/vtd/dmar.c +0 -5
-                ignore = 1;
-            }
-            else
-            {
-                ignore = 0;
Quoted 8 lines

xen/drivers/passthrough/vtd/dmar.c acpi_parse_one_rmrr(struct acpi_dmar_header · line 656

Quoted 8 lines
xen/drivers/passthrough/vtd/dmar.c +0 -8
-                break;
-            }
-        }
-
-        if ( ignore )
-        {
-            dprintk(XENLOG_WARNING VTDPREFIX,
-                "  Ignore the RMRR (%"PRIx64", %"PRIx64") due to

"

Quoted 1 line

xen/drivers/passthrough/vtd/dmar.c acpi_parse_one_rmrr(struct acpi_dmar_header · line 657

Quoted 1 line
xen/drivers/passthrough/vtd/dmar.c +0 -1
-                "devices under its scope are not PCI

discoverable!\n",

Quoted 7 lines

xen/drivers/passthrough/vtd/dmar.c acpi_parse_one_rmrr(struct acpi_dmar_header · line 664

Quoted 7 lines
xen/drivers/passthrough/vtd/dmar.c +0 -7
-                rmrru->base_address, rmrru->end_address);
-            xfree(rmrru);
-        }
-        else if ( base_addr > end_addr )
-        {
-            dprintk(XENLOG_WARNING VTDPREFIX,
-                "  The RMRR (%"PRIx64", %"PRIx64") is

incorrect!\n",

Quoted 11 lines

xen/drivers/passthrough/vtd/dmar.c acpi_parse_one_rmrr(struct acpi_dmar_header · line 675

Quoted 11 lines
xen/drivers/passthrough/vtd/dmar.c +0 -11
-                rmrru->base_address, rmrru->end_address);
-            xfree(rmrru);
-            ret = -EFAULT;
-        }
-        else
-        {
-            if ( iommu_verbose )
-                dprintk(VTDPREFIX,
-                        "  RMRR region: base_addr %"PRIx64
-                        " end_address %"PRIx64"\n",
-                        rmrru->base_address,

rmrru->end_address);

Quoted 6 lines
Quoted 6 lines
xen/drivers/passthrough/vtd/dmar.c +2 -2
-            acpi_register_rmrr_unit(rmrru);
-        }
+        xfree(rmrru);
+        return ret;
     }
 
Quoted 7 lines

xen/drivers/passthrough/vtd/dmar.c acpi_parse_one_rmrr(struct acpi_dmar_header · line 688

Quoted 4 lines
xen/drivers/passthrough/vtd/dmar.c +3 -0
+    ret = register_one_rmrr(rmrru);
+    if ( ret )
+        xfree(rmrru);
     return ret;

Please try to make this a single xfree() and a single return (with again a blank line preceding it).

Got it, I will make changes you mentioned.

Quoted 2 lines

Jan