From: Tom Rotenberg Subject: Re: Intel IOMMU: Assigning IGD device: 00:02.1 on some machines, causes Xen to freeze for >2mins because of RMRR mappings Date: Wed, 2 Dec 2009 12:57:41 +0200 Message-ID: <8686c3cd0912020257m3f2f70cau3d22ec1fc7fdaafa@mail.gmail.com> References: <8686c3cd0911290956x3fd5af62o785378329d30776d@mail.gmail.com> <715D42877B251141A38726ABF5CABF2C05538D3CF2@pdsmsx503.ccr.corp.intel.com> <8686c3cd0911300317x2d85f9c7y47c7ff6e26aafb5a@mail.gmail.com> <715D42877B251141A38726ABF5CABF2C05538D3FDA@pdsmsx503.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <715D42877B251141A38726ABF5CABF2C05538D3FDA@pdsmsx503.ccr.corp.intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "Han, Weidong" , Keir Fraser Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org And, the other question: how can i make this hypercall preemptive? as it may still take too much time for an hypercall (taking into account, it needs to map ~10.000 pages...) On Mon, Nov 30, 2009 at 4:54 PM, Han, Weidong wrote= : > You also need to include below code in the loop: > =A0 =A0iommu_flush_cache_entry(pte); > =A0 =A0unmap_vtd_domain_page(page); > > At the end, need to flush iotlb for all pages: > =A0 =A0 =A0 =A0if ( iommu_flush_iotlb_psi(iommu, domain_iommu_domid(d), > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (padd= r_t)gfn << PAGE_SHIFT_4K, pages, =A0----> "pages" means page number > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 !pte_= present, flush_dev_iotlb) ) > =A0 =A0 =A0 =A0 =A0 =A0iommu_flush_write_buffer(iommu); > > Regards, > Weidong > > -----Original Message----- > From: Tom Rotenberg [mailto:tom.rotenberg@gmail.com] > Sent: Monday, November 30, 2009 7:17 PM > To: Han, Weidong > Cc: xen-devel@lists.xensource.com > Subject: Re: Intel IOMMU: Assigning IGD device: 00:02.1 on some machines,= causes Xen to freeze for >2mins because of RMRR mappings > > Can u please guid me a little bit, on how to write such function which > will work on a batch of pages? > Should i just enclose the: > " > ... > =A0 =A0pg_maddr =3D addr_to_dma_page_maddr(d, (paddr_t)gfn << PAGE_SHIFT_= 4K, 1); > =A0 =A0if ( pg_maddr =3D=3D 0 ) > =A0 =A0{ > =A0 =A0 =A0 =A0spin_unlock(&hd->mapping_lock); > =A0 =A0 =A0 =A0return -ENOMEM; > =A0 =A0} > =A0 =A0page =3D (struct dma_pte *)map_vtd_domain_page(pg_maddr); > =A0 =A0pte =3D page + (gfn & LEVEL_MASK); > =A0 =A0pte_present =3D dma_pte_present(*pte); > =A0 =A0dma_set_pte_addr(*pte, (paddr_t)mfn << PAGE_SHIFT_4K); > =A0 =A0dma_set_pte_prot(*pte, DMA_PTE_READ | DMA_PTE_WRITE); > > =A0 =A0/* Set the SNP on leaf page table if Snoop Control available */ > =A0 =A0if ( iommu_snoop ) > =A0 =A0 =A0 =A0dma_set_pte_snp(*pte); > ... > " > > in a loop? > > On Mon, Nov 30, 2009 at 4:30 AM, Han, Weidong wro= te: >> Tom, >> >> Yes, you can add an API to map batches of pages instead of mapping each = page in a separate call. >> >> RMRR regions of USB controller is ignored because they won't be used in = guest. The RMRR 0x7dc00000 to 0x80000000 is shared by 00:02.0 and 00:02.1, = it will be used by IGD in guest. But you can have a try to ignore it for 00= :02.1. >> >> >> Regards, >> Weidong >> >> -----Original Message----- >> From: Tom Rotenberg [mailto:tom.rotenberg@gmail.com] >> Sent: Monday, November 30, 2009 1:56 AM >> To: xen-devel@lists.xensource.com >> Cc: Han, Weidong >> Subject: Intel IOMMU: Assigning IGD device: 00:02.1 on some machines, ca= uses Xen to freeze for >2mins because of RMRR mappings >> >> Hi All, >> >> I am using a Dell E6400 machine, with IGD (Intel graphics device), >> which i'm trying to pass-through into a domU with Windows XP. When i >> assign only the 00:02.0 device, it seems to work ok, but when i try to >> assign the 00:02.1 device, the whole machine seems to freeze form more >> then 2 mins, causing a lot of messgaes in dom0, such as: SATA doesn't >> respond, etc. >> >> After some analysis i made, i discovered the followings: >> * When calling the (Intel) iommu_assign_device, it checks if the >> device has any details in the RMRR table, and if so it calls the >> 'iommu_prepare_rmrr_dev()' function. >> * The device 00:02.1 has an RMRR information, which details the whole >> area between: =A00x7dc00000 to 0x80000000 =A0(it contains ~9000 pages) >> * For each such page, Xen calls the 'intel_iommu_map_page()' function. >> This causes the hypercall to take a lot of time to process, and this >> makes dom0 to stop getting responds from devices, such as SATA, etc,, >> which may lead to a whole system =A0crash. >> >> My question are: >> 1. Can this hypercall be in some way preemptive, so it won't stuck the >> whole system (i noticed that there are other hypercalls, which are >> preemptive) ? >> 2. Why can't the mapping of the pages, be done in batches of pages, >> instead of mapping each page in a separate call to >> 'intel_iommu_map_page()' ? >> 3. i noticed that for USB devices, the code there ignores the USB >> RMRR... can this be done also for the 00:02.1 device? >> >> Tom >> >