From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
To: <pbonzini@redhat.com>, <rkrcmar@redhat.com>, <joro@8bytes.org>,
<alex.williamson@redhat.com>
Cc: <kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<sherry.hurwitz@amd.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Subject: [PART2 RFC v2 07/10] iommu/amd: Enable vAPIC interrupt remapping mode by default
Date: Mon, 13 Jun 2016 17:06:47 -0500 [thread overview]
Message-ID: <1465855611-10092-8-git-send-email-suravee.suthikulpanit@amd.com> (raw)
In-Reply-To: <1465855611-10092-1-git-send-email-suravee.suthikulpanit@amd.com>
Introduce struct iommu_dev_data.use_vapic flag, which IOMMU driver
uses to determine if it should enable vAPIC support, by setting
the ga_mode bit in the device's interrupt remapping table entry.
Currently, it is enabled for all pass-through device if vAPIC mode
is enabled.
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
drivers/iommu/amd_iommu.c | 18 ++++++++++++++++--
drivers/iommu/amd_iommu_init.c | 2 +-
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 7176c94..1c6693b 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -105,6 +105,7 @@ struct iommu_dev_data {
bool pri_tlp; /* PASID TLB required for
PPR completions */
u32 errata; /* Bitmap for errata to apply */
+ u32 use_vapic; /* Enable device to use vapic mode */
};
/*
@@ -3232,6 +3233,10 @@ static void amd_iommu_detach_device(struct iommu_domain *dom,
if (!iommu)
return;
+ if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) &&
+ (dom->type == IOMMU_DOMAIN_UNMANAGED))
+ dev_data->use_vapic = 0;
+
iommu_completion_wait(iommu);
}
@@ -3257,6 +3262,13 @@ static int amd_iommu_attach_device(struct iommu_domain *dom,
ret = attach_device(dev, domain);
+ if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)) {
+ if (dom->type == IOMMU_DOMAIN_UNMANAGED)
+ dev_data->use_vapic = 1;
+ else
+ dev_data->use_vapic = 0;
+ }
+
iommu_completion_wait(iommu);
return ret;
@@ -4161,7 +4173,8 @@ static void irq_remapping_prepare_irte(struct amd_ir_data *data,
irte->lo.val = 0;
irte->hi.val = 0;
- irte->lo.fields_remap.guest_mode = 0;
+ irte->lo.fields_remap.guest_mode = dev_data ?
+ dev_data->use_vapic : 0;
irte->lo.fields_remap.int_type = apic->irq_delivery_mode;
irte->lo.fields_remap.dm = apic->irq_dest_mode;
irte->hi.fields.vector = irq_cfg->vector;
@@ -4405,6 +4418,7 @@ static int amd_ir_set_affinity(struct irq_data *data,
struct irq_2_irte *irte_info = &ir_data->irq_2_irte;
struct irq_cfg *cfg = irqd_cfg(data);
struct irq_data *parent = data->parent_data;
+ struct iommu_dev_data *dev_data = search_dev_data(irte_info->devid);
int ret;
ret = parent->chip->irq_set_affinity(parent, mask, force);
@@ -4420,7 +4434,7 @@ static int amd_ir_set_affinity(struct irq_data *data,
ir_data->irte_entry.fields.destination = cfg->dest_apicid;
modify_irte(irte_info->devid, irte_info->index,
ir_data->irte_entry);
- } else {
+ } else if (!dev_data || !dev_data->use_vapic) {
struct irte_ga *entry = &ir_data->irte_ga_entry;
entry->hi.fields.vector = cfg->vector;
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 60b0394..5f7b6be 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -146,7 +146,7 @@ struct ivmd_header {
bool amd_iommu_dump;
bool amd_iommu_irq_remap __read_mostly;
-int amd_iommu_guest_ir;
+int amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_VAPIC;
static bool amd_iommu_detected;
static bool __initdata amd_iommu_disabled;
--
1.9.1
next prev parent reply other threads:[~2016-06-13 22:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-13 22:06 [PART2 RFC v2 00/10] iommu/AMD: Introduce IOMMU AVIC support Suravee Suthikulpanit
2016-06-13 22:06 ` [PART2 RFC v2 01/10] iommu/amd: Detect and enable guest vAPIC support Suravee Suthikulpanit
2016-06-13 22:06 ` [PART2 RFC v2 02/10] iommu/amd: Add support for 128-bit IRTE Suravee Suthikulpanit
2016-06-13 22:06 ` [PART2 RFC v2 03/10] iommu/amd: Detect and initialize guest vAPIC log Suravee Suthikulpanit
2016-06-13 22:06 ` [PART2 RFC v2 04/10] iommu/amd: Adding GALOG interrupt handler Suravee Suthikulpanit
2016-06-13 22:06 ` [PART2 RFC v2 05/10] iommu/amd: Introduce amd_iommu_update_ga() Suravee Suthikulpanit
2016-06-13 22:06 ` [PART2 RFC v2 06/10] iommu/amd: Implements irq_set_vcpu_affinity() hook to setup vapic mode for pass-through devices Suravee Suthikulpanit
2016-06-13 22:06 ` Suravee Suthikulpanit [this message]
2016-06-13 22:06 ` [PART2 RFC v2 08/10] svm: Introduce AMD IOMMU avic_ga_log_notifier Suravee Suthikulpanit
2016-06-13 22:06 ` [PART2 RFC v2 09/10] svm: Implements update_pi_irte hook to setup posted interrupt Suravee Suthikulpanit
2016-06-13 22:06 ` [PART2 RFC v2 10/10] svm: Update AMD IOMMU IRTE with vcpu scheduling information when enable AVIC Suravee Suthikulpanit
2016-06-21 13:50 ` [PART2 RFC v2 00/10] iommu/AMD: Introduce IOMMU AVIC support Joerg Roedel
2016-06-21 14:27 ` Suravee Suthikulanit
2016-06-21 14:46 ` Joerg Roedel
2016-06-21 15:45 ` Suravee Suthikulanit
2016-06-21 15:15 ` Paolo Bonzini
2016-07-05 18:51 ` Suravee Suthikulpanit
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=1465855611-10092-8-git-send-email-suravee.suthikulpanit@amd.com \
--to=suravee.suthikulpanit@amd.com \
--cc=alex.williamson@redhat.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=sherry.hurwitz@amd.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®