From: Keir Fraser <keir.xen@gmail.com>
To: Jan Beulich <JBeulich@suse.com>, xen-devel <xen-devel@lists.xen.org>
Cc: Wei Huang <wei.huang2@amd.com>, Wei Wang <weiwang.dd@gmail.com>,
xiantao.zhang@intel.com, Gang Wei <gang.wei@intel.com>
Subject: Re: [PATCH 5/5 v2] VT-d: adjust IOMMU interrupt affinities when all CPUs are online
Date: Wed, 21 Nov 2012 12:45:03 +0000 [thread overview]
Message-ID: <CCD27D4F.451D1%keir.xen@gmail.com> (raw)
In-Reply-To: <50ACD36702000078000AA5B3@nat28.tlf.novell.com>
On 21/11/2012 12:13, "Jan Beulich" <JBeulich@suse.com> wrote:
> Since these interrupts get setup before APs get brought online, their
> affinities naturally could only ever point to CPU 0 alone so far.
> Adjust this to include potentially multiple CPUs in the target mask
> (when running in one of the cluster modes), and take into account NUMA
> information (to handle the interrupts on a CPU on the node where the
> respective IOMMU is).
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
> ---
> v2: Call adjust_vtd_irq_affinities() explicitly from enter_state()
> rather than through acpi_dmar_zap().
>
> --- a/xen/arch/x86/acpi/power.c
> +++ b/xen/arch/x86/acpi/power.c
> @@ -219,6 +219,7 @@ static int enter_state(u32 state)
> mtrr_aps_sync_begin();
> enable_nonboot_cpus();
> mtrr_aps_sync_end();
> + adjust_vtd_irq_affinities();
> acpi_dmar_zap();
> thaw_domains();
> system_state = SYS_STATE_active;
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -1971,6 +1971,33 @@ void clear_fault_bits(struct iommu *iomm
> spin_unlock_irqrestore(&iommu->register_lock, flags);
> }
>
> +static void adjust_irq_affinity(struct acpi_drhd_unit *drhd)
> +{
> + const struct acpi_rhsa_unit *rhsa = drhd_to_rhsa(drhd);
> + unsigned int node = rhsa ? pxm_to_node(rhsa->proximity_domain)
> + : NUMA_NO_NODE;
> + const cpumask_t *cpumask = &cpu_online_map;
> +
> + if ( node < MAX_NUMNODES && node_online(node) &&
> + cpumask_intersects(&node_to_cpumask(node), cpumask) )
> + cpumask = &node_to_cpumask(node);
> + dma_msi_set_affinity(irq_to_desc(drhd->iommu->msi.irq), cpumask);
> +}
> +
> +int adjust_vtd_irq_affinities(void)
> +{
> + struct acpi_drhd_unit *drhd;
> +
> + if ( !iommu_enabled )
> + return 0;
> +
> + for_each_drhd_unit ( drhd )
> + adjust_irq_affinity(drhd);
> +
> + return 0;
> +}
> +__initcall(adjust_vtd_irq_affinities);
> +
> static int init_vtd_hw(void)
> {
> struct acpi_drhd_unit *drhd;
> @@ -1984,13 +2011,10 @@ static int init_vtd_hw(void)
> */
> for_each_drhd_unit ( drhd )
> {
> - struct irq_desc *desc;
> + adjust_irq_affinity(drhd);
>
> iommu = drhd->iommu;
>
> - desc = irq_to_desc(iommu->msi.irq);
> - dma_msi_set_affinity(desc, desc->arch.cpu_mask);
> -
> clear_fault_bits(iommu);
>
> spin_lock_irqsave(&iommu->register_lock, flags);
> --- a/xen/include/xen/iommu.h
> +++ b/xen/include/xen/iommu.h
> @@ -137,6 +137,9 @@ int iommu_do_domctl(struct xen_domctl *,
> void iommu_iotlb_flush(struct domain *d, unsigned long gfn, unsigned int
> page_count);
> void iommu_iotlb_flush_all(struct domain *d);
>
> +/* While VT-d specific, this must get declared in a generic header. */
> +int adjust_vtd_irq_affinities(void);
> +
> /*
> * The purpose of the iommu_dont_flush_iotlb optional cpu flag is to
> * avoid unecessary iotlb_flush in the low level IOMMU code.
>
>
>
next prev parent reply other threads:[~2012-11-21 12:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-21 10:06 [PATCH 0/5] HPET and IOMMU adjustments Jan Beulich
2012-11-21 10:16 ` [PATCH 1/5] x86/HPET: include FSB interrupt information in 'M' debug key output Jan Beulich
2012-11-21 10:17 ` [PATCH 2/5] VT-d: include IOMMU " Jan Beulich
2012-11-21 10:18 ` [PATCH 3/5] AMD IOMMU: " Jan Beulich
2012-11-21 10:19 ` [PATCH 4/5] x86/HPET: fix FSB interrupt masking Jan Beulich
2012-11-21 10:19 ` [PATCH 5/5] VT-d: adjust IOMMU interrupt affinities when all CPUs are online Jan Beulich
2012-11-21 11:10 ` Keir Fraser
2012-11-21 11:17 ` Jan Beulich
2012-11-21 11:29 ` Keir Fraser
2012-11-21 11:58 ` Jan Beulich
2012-11-21 12:13 ` [PATCH 5/5 v2] " Jan Beulich
2012-11-21 12:45 ` Keir Fraser [this message]
2012-11-21 11:11 ` [PATCH 0/5] HPET and IOMMU adjustments Keir Fraser
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=CCD27D4F.451D1%keir.xen@gmail.com \
--to=keir.xen@gmail.com \
--cc=JBeulich@suse.com \
--cc=gang.wei@intel.com \
--cc=wei.huang2@amd.com \
--cc=weiwang.dd@gmail.com \
--cc=xen-devel@lists.xen.org \
--cc=xiantao.zhang@intel.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;
as well as URLs for NNTP newsgroup(s).