All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomasz Wroblewski <tomasz.wroblewski@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: "xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH] Fix acpi_dmar_zap/reinstate() (fixes S3 regression)
Date: Tue, 22 Jan 2013 16:27:32 +0100	[thread overview]
Message-ID: <50FEAFE4.1030303@citrix.com> (raw)
In-Reply-To: <50FE9B1802000078000B84A1@nat28.tlf.novell.com>

[-- Attachment #1: Type: text/plain, Size: 654 bytes --]

On 22/01/13 13:58, Jan Beulich wrote:

Jan,

attaching updated patch which uses ioremap() instead of acpi_get_table. 
Tested it across some S3 iterations on xen tip from today and Lenovo 
T520 and seems to work well (although there are some unrelated scheduler 
issues on resume which we have patched separately on our end; intending 
to submit these patches as well later on). Doesn't work on older trees 
from before your "implement vmap()" commit. You mentioned that this 
would be fixable on older trees via adding the acpi table range to the 
1:1 mapping - how would one go about this as I'm not sure where is the 
relevant code located?

Thanks!



[-- Attachment #2: fix-dmar-zap-reinstate-v2.patch --]
[-- Type: text/x-patch, Size: 3829 bytes --]

diff -r 4b476378fc35 xen/drivers/acpi/tables/tbutils.c
--- a/xen/drivers/acpi/tables/tbutils.c	Mon Jan 21 17:03:10 2013 +0000
+++ b/xen/drivers/acpi/tables/tbutils.c	Tue Jan 22 15:13:43 2013 +0000
@@ -525,3 +525,23 @@
 
 	return_ACPI_STATUS(AE_OK);
 }
+
+acpi_status acpi_tb_get_table_physical_location(char *signature, acpi_physical_address *out_addr, u32 *out_size)
+{
+    acpi_native_uint i;
+
+    if (!signature || !out_addr || !out_size) {
+        return (AE_BAD_PARAMETER);
+    }
+
+    for (i = 0; i < acpi_gbl_root_table_list.count; i++) {
+        if (!ACPI_COMPARE_NAME(&(acpi_gbl_root_table_list.tables[i].signature), signature)) {
+            continue;
+        }
+        *out_addr = acpi_gbl_root_table_list.tables[i].address;
+        *out_size = acpi_gbl_root_table_list.tables[i].length;
+        return AE_OK;
+    }
+    return AE_NOT_FOUND;
+}
+
diff -r 4b476378fc35 xen/drivers/passthrough/vtd/dmar.c
--- a/xen/drivers/passthrough/vtd/dmar.c	Mon Jan 21 17:03:10 2013 +0000
+++ b/xen/drivers/passthrough/vtd/dmar.c	Tue Jan 22 15:13:43 2013 +0000
@@ -29,6 +29,7 @@
 #include <xen/pci.h>
 #include <xen/pci_regs.h>
 #include <asm/string.h>
+#include <acpi/actables.h>
 #include "dmar.h"
 #include "iommu.h"
 #include "extern.h"
@@ -46,7 +47,6 @@
 static LIST_HEAD_READ_MOSTLY(acpi_atsr_units);
 static LIST_HEAD_READ_MOSTLY(acpi_rhsa_units);
 
-static struct acpi_table_header *__read_mostly dmar_table;
 static int __read_mostly dmar_flags;
 static u64 __read_mostly igd_drhd_address;
 
@@ -821,26 +821,56 @@
 /* SINIT saved in SinitMleData in TXT heap (which is DMA protected) */
 #define parse_dmar_table(h) tboot_parse_dmar_table(h)
 
+static struct acpi_table_header *map_dmar(void)
+{
+    acpi_physical_address addr;
+    u32 sz;
+
+    if (acpi_tb_get_table_physical_location(ACPI_SIG_DMAR, &addr, &sz)) {
+        return NULL;
+    }
+    return (struct acpi_table_header*) ioremap(addr, sz);
+}
+
+static void unmap_dmar(struct acpi_table_header *dmar_table)
+{
+    iounmap(dmar_table);
+}
+
 int __init acpi_dmar_init(void)
 {
-    acpi_get_table(ACPI_SIG_DMAR, 0, &dmar_table);
     return parse_dmar_table(acpi_parse_dmar);
 }
 
 void acpi_dmar_reinstate(void)
 {
-    if ( dmar_table == NULL )
-        return;
-    dmar_table->signature[0] = 'D';
-    dmar_table->checksum += 'X'-'D';
+    unsigned long flags;
+    struct acpi_table_header *dmar_table;
+    /* Disabling IRQs avoids cross-CPU TLB flush in map_pages_to_xen(). */
+    local_irq_save(flags);
+    dmar_table = map_dmar(); /* needs to be dynamically fetched here as acpi_get_table reuses the returned virtual address */
+    if (dmar_table) {
+        dmar_table->signature[0] = 'D';
+        dmar_table->checksum += 'X'-'D';
+        unmap_dmar(dmar_table);
+    }
+    local_irq_restore(flags);
 }
 
 void acpi_dmar_zap(void)
 {
-    if ( dmar_table == NULL )
-        return;
-    dmar_table->signature[0] = 'X';
-    dmar_table->checksum -= 'X'-'D';
+    unsigned long flags;
+    struct acpi_table_header *dmar_table;
+    /* Disabling IRQs avoids cross-CPU TLB flush in map_pages_to_xen(). */
+    local_irq_save(flags);
+    dmar_table = map_dmar();
+    if (dmar_table) {
+        dmar_table->signature[0] = 'X';
+        dmar_table->checksum -= 'X'-'D';
+        unmap_dmar(dmar_table);
+    }
+    local_irq_restore(flags);
+
 }
 
 int platform_supports_intremap(void)
diff -r 4b476378fc35 xen/include/acpi/actables.h
--- a/xen/include/acpi/actables.h	Mon Jan 21 17:03:10 2013 +0000
+++ b/xen/include/acpi/actables.h	Tue Jan 22 15:13:43 2013 +0000
@@ -61,6 +61,8 @@
 		   char *oem_id,
 		   char *oem_table_id, acpi_native_uint * table_index);
 
+acpi_status acpi_tb_get_table_physical_location(char *signature, acpi_physical_address *out_addr, u32 *out_size);
+
 /*
  * tbinstal - Table removal and deletion
  */

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  parent reply	other threads:[~2013-01-22 15:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-22 12:08 [PATCH] Fix acpi_dmar_zap/reinstate() (fixes S3 regression) Tomasz Wroblewski
2013-01-22 12:58 ` Jan Beulich
2013-01-22 13:36   ` Tomasz Wroblewski
2013-01-22 14:13     ` Jan Beulich
2013-01-22 15:27   ` Tomasz Wroblewski [this message]
2013-01-22 15:55     ` Jan Beulich
2013-01-22 17:22       ` [PATCH v3] " Tomasz Wroblewski
2013-01-23  8:47         ` Jan Beulich
2013-01-23  9:02           ` [PATCH v4] " Tomasz Wroblewski
2013-01-23  9:26             ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50FEAFE4.1030303@citrix.com \
    --to=tomasz.wroblewski@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.