All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: [Patch v3 04/12] iommu/amd: add copy_irq_table function
Date: Tue, 26 Jan 2016 18:29:18 +0800	[thread overview]
Message-ID: <1453804166-25646-5-git-send-email-bhe@redhat.com> (raw)
In-Reply-To: <1453804166-25646-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

If irq table exists in old kernel create a new one and copy the content
of old irq table to the newly created.

Signed-off-by: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 drivers/iommu/amd_iommu.c       |  2 +-
 drivers/iommu/amd_iommu_init.c  | 43 +++++++++++++++++++++++++++++++++++++++++
 drivers/iommu/amd_iommu_proto.h |  1 +
 3 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index aeae07a..63f4c6b 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -3628,7 +3628,7 @@ struct amd_ir_data {
 static struct irq_chip amd_ir_chip;
 
 
-static void set_dte_irq_entry(u16 devid, struct irq_remap_table *table)
+void set_dte_irq_entry(u16 devid, struct irq_remap_table *table)
 {
 	u64 dte;
 
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 91659d8..450adad 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -660,6 +660,49 @@ static int get_dev_entry_bit(u16 devid, u8 bit)
 	return (amd_iommu_dev_table[devid].data[i] & (1UL << _bit)) >> _bit;
 }
 
+static void copy_irq_table(u16 devid)
+{
+	struct irq_remap_table *table = NULL;
+	u16 alias;
+	u64 dte;
+	u64 *old_intr_virt;
+
+	alias = amd_iommu_alias_table[devid];
+	table = irq_lookup_table[alias];
+	if (table) {
+	        irq_lookup_table[devid] = table;
+		set_dte_irq_entry(devid, table);
+	        return;
+	}
+	dte     = amd_iommu_dev_table[devid].data[2];
+	dte &= DTE_IRQ_PHYS_ADDR_MASK;
+	if( (!dte&DTE_IRQ_REMAP_ENABLE) || ( dte == 0) )
+	        return;
+
+	table = kzalloc(sizeof(*table), GFP_ATOMIC);
+	if (!table){
+	        pr_warn("AMD-Vi: amd irq table allocation failed\n");
+	        return;
+	}
+
+	table->table = kmem_cache_alloc(amd_iommu_irq_cache, GFP_ATOMIC);
+        if (!table->table) {
+                kfree(table);
+                table = NULL;
+		return;
+        }
+	memset(table->table, 0, MAX_IRQS_PER_TABLE * sizeof(u32));
+
+	old_intr_virt = memremap(dte, MAX_IRQS_PER_TABLE * sizeof(u32), MEMREMAP_WB);
+	memcpy(table->table, old_intr_virt, MAX_IRQS_PER_TABLE * sizeof(u32));
+	irq_lookup_table[devid] = table;
+	set_dte_irq_entry(devid, table);
+	if (devid != alias) {
+                irq_lookup_table[alias] = table;
+		set_dte_irq_entry(alias, table);
+        }
+	memunmap(old_intr_virt);
+}
 
 void amd_iommu_apply_erratum_63(u16 devid)
 {
diff --git a/drivers/iommu/amd_iommu_proto.h b/drivers/iommu/amd_iommu_proto.h
index 743e209..ab562e0 100644
--- a/drivers/iommu/amd_iommu_proto.h
+++ b/drivers/iommu/amd_iommu_proto.h
@@ -101,5 +101,6 @@ static inline bool iommu_feature(struct amd_iommu *iommu, u64 f)
 /* kdump checking  */
 extern bool translation_pre_enabled(void);
 extern void clear_translation_pre_enabled(void);
+extern void set_dte_irq_entry(u16 devid, struct irq_remap_table *table);
 
 #endif /* _ASM_X86_AMD_IOMMU_PROTO_H  */
-- 
2.1.0

  parent reply	other threads:[~2016-01-26 10:29 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-26 10:29 [Patch v3 00/12] Fix AMD IOMMU faults in kdump kernel Baoquan He
     [not found] ` <1453804166-25646-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-26 10:29   ` [Patch v3 01/12] iommu/amd: Use standard bitmap operation to set bitmap Baoquan He
2016-01-26 10:29   ` [Patch v3 02/12] iommu/amd: Detect pre enabled translation Baoquan He
2016-01-26 10:29   ` [Patch v3 03/12] iommu/amd: move dte irq macro defitions to amd_iommu_types.h Baoquan He
     [not found]     ` <1453804166-25646-4-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-27 10:25       ` Wan Zongshun
     [not found]         ` <56A89B1F.6010004-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
2016-01-28  9:50           ` Baoquan He
2016-01-26 10:29   ` Baoquan He [this message]
     [not found]     ` <1453804166-25646-5-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-27 11:23       ` [Patch v3 04/12] iommu/amd: add copy_irq_table function Wan Zongshun
     [not found]         ` <56A8A896.70405-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
2016-01-28  9:52           ` Baoquan He
2016-01-26 10:29   ` [Patch v3 05/12] iommu/amd: change IOMMU_PTE_P to IOMMU_PTE_V Baoquan He
     [not found]     ` <1453804166-25646-6-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-27 10:18       ` Wan Zongshun
     [not found]         ` <56A89981.5010007-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
2016-01-28 10:05           ` Baoquan He
     [not found]             ` <20160128100533.GD3851-ejN7fcUYdH/by3iVrkZq2A@public.gmane.org>
2016-01-29  2:55               ` Wan Zongshun
     [not found]                 ` <56AAD4B8.8050701-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
2016-01-29  3:12                   ` Baoquan He
2016-01-26 10:29   ` [Patch v3 06/12] iommu/amd: Clean up the useless IOMMU_PTE_U/IOMMU_PTE_FC Baoquan He
     [not found]     ` <1453804166-25646-7-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-27 10:22       ` Wan Zongshun
     [not found]         ` <56A89A74.6060501-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
2016-01-28 10:30           ` Baoquan He
2016-01-26 10:29   ` [Patch v3 07/12] iommu/amd: Add function copy_dev_tables Baoquan He
2016-01-26 10:29   ` [Patch v3 08/12] iommu/amd: set the device table and re-enable event/cmd buffer Baoquan He
2016-01-26 10:29   ` [Patch v3 09/12] iommu/amd: Don't update the domain information to iommu dev before dev init Baoquan He
2016-01-26 10:29   ` [Patch v3 10/12] iommu/amd: Update related domain info to dev when dev driver init Baoquan He
2016-01-26 10:29   ` [Patch v3 11/12] iommu/amd: No need to wait iommu completion if no dte irq entry change Baoquan He
     [not found]     ` <1453804166-25646-12-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-27 11:03       ` Wan Zongshun
     [not found]         ` <56A8A3EC.7090701-6ukY98dZOFrYtjvyW6yDsg@public.gmane.org>
2016-01-28 10:24           ` Baoquan He
     [not found]             ` <20160128102401.GE3851-ejN7fcUYdH/by3iVrkZq2A@public.gmane.org>
2016-01-29  2:57               ` Wan Zongshun
2016-01-26 10:29   ` [Patch v3 12/12] iommu/amd: fix a code bug in do_attach Baoquan He
     [not found]     ` <1453804166-25646-13-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-01-26 10:51       ` Baoquan He
2016-01-26 10:48   ` [Patch v3 00/12] Fix AMD IOMMU faults in kdump kernel Baoquan He
2016-01-26 10:52   ` Baoquan He

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=1453804166-25646-5-git-send-email-bhe@redhat.com \
    --to=bhe-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.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.