From: Wei Wang2 <wei.wang2@amd.com>
To: Keir Fraser <keir@xen.org>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH 1/3] amd iommu: reduce io page level for hvm guest
Date: Thu, 27 Jan 2011 15:30:32 +0100 [thread overview]
Message-ID: <201101271530.33656.wei.wang2@amd.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 787 bytes --]
Keir,
These 3 patches optimize and cleanup amd iommu codes for 4.1. If not too
late please add them into the release.
Thanks,
Wei
1.Since in most case, 2 or 3 - level IO page tables are sufficient, this patch
updates page table level for device assignment to reduces overhead of dma
translation
2. Clean up amd_iommu_reserve_domain_unity_map function to reduce code
duplication.
3. Clean up invalidate_iommu_page function. Make it suitable for variable page
sizes and can be reused by invalidate_all_iommu_pages.
Signed-off-by: Wei Wang <wei.wang2@amd.com>
--
Advanced Micro Devices GmbH
Sitz: Dornach, Gemeinde Aschheim,
Landkreis München Registergericht München,
HRB Nr. 43632
WEEE-Reg-Nr: DE 12919551
Geschäftsführer:
Alberto Bozzo, Andrew Bowd
[-- Attachment #2: iommu_pgmode.patch --]
[-- Type: text/x-diff, Size: 1887 bytes --]
diff -r 67d5b8004947 xen/drivers/passthrough/amd/iommu_map.c
--- a/xen/drivers/passthrough/amd/iommu_map.c Wed Jan 26 11:58:45 2011 +0000
+++ b/xen/drivers/passthrough/amd/iommu_map.c Thu Jan 27 15:11:25 2011 +0100
@@ -411,10 +411,14 @@ static u64 iommu_l2e_from_pfn(struct pag
void *pde = NULL;
void *table_vaddr;
u64 next_table_maddr = 0;
-
- BUG_ON( table == NULL || level == 0 );
-
- while ( level > 1 )
+ unsigned int lowest = 1;
+
+ BUG_ON( table == NULL || level < lowest );
+
+ if ( level == lowest )
+ return page_to_maddr(table);
+
+ while ( level > lowest )
{
offset = io_pfn >> ((PTE_PER_TABLE_SHIFT *
(level - IOMMU_PAGING_MODE_LEVEL_1)));
diff -r 67d5b8004947 xen/drivers/passthrough/amd/pci_amd_iommu.c
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c Wed Jan 26 11:58:45 2011 +0000
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c Thu Jan 27 15:11:25 2011 +0100
@@ -190,10 +190,7 @@ static int get_paging_mode(unsigned long
{
int level = 1;
- BUG_ON(!max_page);
-
- if ( entries > max_page )
- entries = max_page;
+ BUG_ON( !entries );
while ( entries > PTE_PER_TABLE_SIZE )
{
@@ -278,6 +275,7 @@ static int reassign_device( struct domai
struct pci_dev *pdev;
struct amd_iommu *iommu;
int bdf;
+ struct hvm_iommu *t = domain_hvm_iommu(target);
ASSERT(spin_is_locked(&pcidevs_lock));
pdev = pci_get_pdev_by_domain(source, bus, devfn);
@@ -299,6 +297,9 @@ static int reassign_device( struct domai
list_move(&pdev->domain_list, &target->arch.pdev_list);
pdev->domain = target;
+
+ if ( target->max_pages > 0 )
+ t->paging_mode = get_paging_mode(target->max_pages);
amd_iommu_setup_domain_device(target, iommu, bdf);
AMD_IOMMU_DEBUG("Re-assign %02x:%02x.%x from domain %d to domain %d\n",
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
reply other threads:[~2011-01-27 14:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=201101271530.33656.wei.wang2@amd.com \
--to=wei.wang2@amd.com \
--cc=keir@xen.org \
--cc=xen-devel@lists.xensource.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 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.