VT-d Device-TLB flush issue
v14 cover VT-d Device-TLB flush issue
From: Quan Xu <[email protected]>
these patches fix current timeout concern and also allow limited ATS support.
these patches are the rest ones:
1. move the domain crash logic up to the generic IOMMU layer
2. If Device-TLB flush timed out, we hide the target ATS device immediately. By hiding the device, we make sure it can't be assigned to any domain any longer (see device_assigned).
---
Not covered in this series:
a) Eliminate the panic() in IOMMU_WAIT_OP, used only in VT-d register read/write. Further discussion is required on whether and how to improve it.
b) Handle IOTLB/Context/IEC flush timeout.
---
Quan Xu (3):
IOMMU/x86: use a struct pci_dev* instead of SBDF
IOMMU: add domain crash logic
IOMMU: fix vt-d Device-TLB flush timeout issue
xen/drivers/passthrough/amd/iommu_cmd.c | 19 ++++---- xen/drivers/passthrough/amd/pci_amd_iommu.c | 4 +- xen/drivers/passthrough/ats.h | 10 ++--- xen/drivers/passthrough/iommu.c | 54 ++++++++++++++++++++++- xen/drivers/passthrough/pci.c | 6 +-- xen/drivers/passthrough/vtd/extern.h | 5 ++- xen/drivers/passthrough/vtd/intremap.c | 8 ++-- xen/drivers/passthrough/vtd/iommu.c | 25 ++++++++--- xen/drivers/passthrough/vtd/qinval.c | 56 ++++++++++++++++++------ xen/drivers/passthrough/vtd/x86/ats.c | 21 +++++---- xen/drivers/passthrough/x86/ats.c | 67 ++++++++++++++++++----------- xen/include/xen/iommu.h | 3 ++ xen/include/xen/pci.h | 1 + 13 files changed, 195 insertions(+), 84 deletions(-)
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v14 1/3 IOMMU/x86: use a struct pci_dev* instead of SBDF
From: Quan Xu <[email protected]>
A struct pci_dev* instead of SBDF is stored inside struct pci_ats_dev and parameter to *_ats_device().
Also use ats_dev for "struct pci_ats_dev" variable, while pdev (_pdev, if there is already a pdev) for "struct pci_dev" in the scope of IOMMU.
---
v14: change 'ats_pdev' to 'ats_dev'.
--- xen/drivers/passthrough/amd/iommu_cmd.c | 19 ++++---- xen/drivers/passthrough/amd/pci_amd_iommu.c | 4 +- xen/drivers/passthrough/ats.h | 10 ++--- xen/drivers/passthrough/vtd/intremap.c | 8 ++-- xen/drivers/passthrough/vtd/iommu.c | 14 +++--- xen/drivers/passthrough/vtd/x86/ats.c | 24 +++++++---- xen/drivers/passthrough/x86/ats.c | 67 ++++++++++++++++++----------- 7 files changed, 84 insertions(+), 62 deletions(-)
xen/drivers/passthrough/amd/iommu_cmd.c +9 -10
@@ -289,35 +289,34 @@ void amd_iommu_flush_iotlb(u8 devfn, const struct pci_dev *pdev,unsigned long flags;struct amd_iommu *iommu;unsigned int req_id, queueid, maxpend; -struct pci_ats_dev *ats_pdev; +struct pci_ats_dev *ats_dev;if ( !ats_enabled )return ; - ats_pdev =get_ats_device (pdev->seg, pdev->bus, pdev->devfn); -if ( ats_pdev ==NULL ) + ats_dev =get_ats_device (pdev); +if ( ats_dev ==NULL )return ; -if ( !pci_ats_enabled (ats_pdev->seg, ats_pdev->bus, ats_pdev->devfn) ) +if ( !pci_ats_enabled (pdev->seg, pdev->bus, pdev->devfn) )return ; - iommu =find_iommu_for_device (ats_pdev->seg, -PCI_BDF2 (ats_pdev->bus, ats_pdev->devfn)); + iommu =find_iommu_for_device (pdev->seg,PCI_BDF2 (pdev->bus, pdev->devfn));if ( !iommu ) {AMD_IOMMU_DEBUG ("%s: Can't find iommu for %04x:%02x:%02x.%u\n" , - __func__, ats_pdev->seg, ats_pdev->bus, -PCI_SLOT (ats_pdev->devfn),PCI_FUNC (ats_pdev->devfn)); + __func__, pdev->seg, pdev->bus, +PCI_SLOT (pdev->devfn),PCI_FUNC (pdev->devfn));return ; }if ( !iommu_has_cap (iommu,PCI_CAP_IOTLB_SHIFT ) )return ; - req_id =get_dma_requestor_id (iommu->seg,PCI_BDF2 (ats_pdev->bus, devfn)); + req_id =get_dma_requestor_id (iommu->seg,PCI_BDF2 (pdev->bus, pdev->devfn)); queueid = req_id; - maxpend = ats_pdev->ats_queue_depth &0xff ; + maxpend = ats_dev->ats_queue_depth &0xff ;/* send INVALIDATE_IOTLB_PAGES command */ spin_lock_irqsave (&iommu->lock, flags);
xen/drivers/passthrough/amd/pci_amd_iommu.c +2 -2
@@ -162,7 +162,7 @@ static void amd_iommu_setup_domain_device( !pci_ats_enabled(iommu->seg, bus, pdev->devfn) ) {if ( devfn == pdev->devfn ) -enable_ats_device (iommu->seg, bus, devfn, iommu); +enable_ats_device (iommu, pdev);amd_iommu_flush_iotlb (devfn, pdev,INV_IOMMU_ALL_PAGES_ADDRESS ,0 ); }
@@ -356,7 +356,7 @@ void amd_iommu_disable_domain_device(struct domain *domain,if ( devfn == pdev->devfn &&pci_ats_device (iommu->seg, bus, devfn) &&pci_ats_enabled (iommu->seg, bus, devfn) ) -disable_ats_device (iommu->seg, bus, devfn); +disable_ats_device (pdev); } static int reassign_device(struct domain *source, struct domain *target,
xen/drivers/passthrough/ats.h +4 -6
@@ -19,9 +19,7 @@struct pci_ats_dev {struct list_head list; -u16 seg; -u8 bus; -u8 devfn; +struct pci_dev *pdev;u16 ats_queue_depth;/* ATS device invalidation queue depth */ const void *iommu;/* No common IOMMU struct so use void pointer */ };
@@ -34,9 +32,9 @@ struct pci_ats_dev {extern struct list_head ats_devices;extern bool_t ats_enabled; -int enable_ats_device (int seg,int bus,int devfn,const void *iommu); -void disable_ats_device (int seg,int bus,int devfn); -struct pci_ats_dev *get_ats_device (int seg,int bus,int devfn); +int enable_ats_device (const void *iommu,struct pci_dev *pdev); +void disable_ats_device (struct pci_dev *pdev); +struct pci_ats_dev *get_ats_device (const struct pci_dev *pdev);static inline int pci_ats_enabled (int seg,int bus,int devfn) {
xen/drivers/passthrough/vtd/intremap.c +4 -4
@@ -952,7 +952,7 @@ int pi_update_irte(const struct vcpu *v, const struct pirq *pirq,const struct msi_desc *msi_desc;int remap_index;int rc =0 ; -const struct pci_dev *pci_dev; +const struct pci_dev *pdev;const struct acpi_drhd_unit *drhd;struct iommu *iommu;struct ir_ctrl *ir_ctrl;
@@ -972,8 +972,8 @@ int pi_update_irte(const struct vcpu *v, const struct pirq *pirq, goto unlock_out; } - pci_dev = msi_desc->dev; -if ( !pci_dev ) + pdev = msi_desc->dev; +if ( !pdev ) { rc = -ENODEV ; goto unlock_out;
@@ -990,7 +990,7 @@ int pi_update_irte(const struct vcpu *v, const struct pirq *pirq,* 'struct msi_desc' in some other place, so we don't need to waste * time searching it here. */ - drhd =acpi_find_matched_drhd_unit (pci_dev); + drhd =acpi_find_matched_drhd_unit (pdev);if ( !drhd )return -ENODEV ;
xen/drivers/passthrough/vtd/iommu.c +7 -7
@@ -1461,8 +1461,8 @@ int domain_context_mapping_one(return rc; } -static int domain_context_mapping ( -struct domain *domain,u8 devfn,const struct pci_dev *pdev) +static int domain_context_mapping (struct domain *domain,u8 devfn, +struct pci_dev *pdev) {struct acpi_drhd_unit *drhd;int ret =0 ;
@@ -1498,7 +1498,7 @@ static int domain_context_mapping( ret =domain_context_mapping_one (domain, drhd->iommu, bus, devfn, pdev);if ( !ret && devfn == pdev->devfn &&ats_device (pdev, drhd) >0 ) -enable_ats_device (seg, bus, devfn, drhd->iommu); +enable_ats_device (drhd->iommu, pdev);break ;
@@ -1611,8 +1611,8 @@ int domain_context_unmap_one(return rc; } -static int domain_context_unmap ( -struct domain *domain,u8 devfn,const struct pci_dev *pdev) +static int domain_context_unmap (struct domain *domain,u8 devfn, +struct pci_dev *pdev) {struct acpi_drhd_unit *drhd;struct iommu *iommu;
@@ -1648,7 +1648,7 @@ static int domain_context_unmap( PCI_SLOT(devfn), PCI_FUNC(devfn)); ret =domain_context_unmap_one (domain, iommu, bus, devfn);if ( !ret && devfn == pdev->devfn &&ats_device (pdev, drhd) >0 ) -disable_ats_device (seg, bus, devfn); +disable_ats_device (pdev);break ;
@@ -1994,7 +1994,7 @@ static int intel_iommu_enable_device(struct pci_dev *pdev)if ( ret <=0 )return ret; - ret =enable_ats_device (pdev->seg, pdev->bus, pdev->devfn, drhd->iommu); + ret =enable_ats_device (drhd->iommu, pdev);return ret >=0 ?0 : ret; }
xen/drivers/passthrough/vtd/x86/ats.c +15 -9
@@ -71,12 +71,14 @@ int ats_device(const struct pci_dev *pdev, const struct acpi_drhd_unit *drhd)return pos; } -static int device_in_domain (struct iommu *iommu,struct pci_ats_dev *pdev,u16 did) +static int device_in_domain (struct iommu *iommu,struct pci_ats_dev *ats_dev,u16 did) {struct root_entry *root_entry =NULL ;struct context_entry *ctxt_entry =NULL ;int tt, found =0 ; +struct pci_dev *pdev = ats_dev->pdev; +ASSERT (pdev); root_entry = (struct root_entry *)map_vtd_domain_page (iommu->root_maddr);if ( !root_entry || !root_present (root_entry[pdev->bus]) ) goto out;
@@ -108,37 +110,41 @@ out:int dev_invalidate_iotlb (struct iommu *iommu,u16 did,u64 addr,unsigned int size_order,u64 type) { -struct pci_ats_dev *pdev; +struct pci_ats_dev *ats_dev;int ret =0 ;if ( !ecap_dev_iotlb (iommu->ecap) )return ret; -list_for_each_entry ( pdev, &ats_devices, list ) +list_for_each_entry ( ats_dev, &ats_devices, list ) { -u16 sid =PCI_BDF2 (pdev->bus, pdev->devfn); +struct pci_dev *pdev = ats_dev->pdev; +u16 sid;bool_t sbit;int rc =0 ; +ASSERT (pdev); + sid =PCI_BDF2 (pdev->bus, pdev->devfn); +/* Only invalidate devices that belong to this IOMMU */ -if ( pdev->iommu != iommu ) +if ( ats_dev->iommu != iommu )continue ;switch ( type ) {case DMA_TLB_DSI_FLUSH : -if ( !device_in_domain (iommu, pdev, did) ) +if ( !device_in_domain (iommu, ats_dev, did) )break ;/* fall through if DSI condition met */ case DMA_TLB_GLOBAL_FLUSH :/* invalidate all translations: sbit=1,bit_63=0,bit[62:12]=1 */ sbit =1 ; addr = (~0UL <<PAGE_SHIFT_4K ) &0x7FFFFFFFFFFFFFFF ; - rc =qinval_device_iotlb_sync (iommu, pdev->ats_queue_depth, + rc =qinval_device_iotlb_sync (iommu, ats_dev->ats_queue_depth, sid, sbit, addr);break ;case DMA_TLB_PSI_FLUSH : -if ( !device_in_domain (iommu, pdev, did) ) +if ( !device_in_domain (iommu, ats_dev, did) )break ;/* if size <= 4K, set sbit = 0, else set sbit = 1 */
@@ -154,7 +160,7 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did, addr |= (((u64 )1 << (size_order -1 )) -1 ) <<PAGE_SHIFT_4K ; } - rc =qinval_device_iotlb_sync (iommu, pdev->ats_queue_depth, + rc =qinval_device_iotlb_sync (iommu, ats_dev->ats_queue_depth, sid, sbit, addr);break ;default :
xen/drivers/passthrough/x86/ats.c +43 -24
124 lines not on this page · raw message
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v14 1/3] IOMMU/x86: use a struct pci_dev* instead of SBDF
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 04.07.16 at 11:11, <[email protected]> wrote:
xen/drivers/passthrough/ats.h line 25
Quoted 10 lines
xen/drivers/passthrough/ats.h +1
-3@@ -19,9 +19,7 @@struct pci_ats_dev {struct list_head list; -u16 seg; -u8 bus; -u8 devfn; +struct pci_dev *pdev;u16 ats_queue_depth;/* ATS device invalidation queue depth */ const void *iommu;/* No common IOMMU struct so use void pointer */ };
Taking into consideration the single use the struct iommu * here has, I think a different approach is needed to achieve the goal: Eliminate the global "ats_devices" and link ATS devices on a per-IOMMU list. Since that'll leave (besides the list member and the struct pci_dev back pointer) only ats_queue_depth, I then don't see the existence of the structure above warranted anymore: It should be subsumed into struct pci_dev.
xen/drivers/passthrough/ats.h struct pci_ats_dev { · line 35
Quoted 8 lines
xen/drivers/passthrough/ats.h +1
-3@@ -34,9 +32,9 @@ struct pci_ats_dev {extern struct list_head ats_devices;extern bool_t ats_enabled; -int enable_ats_device (int seg,int bus,int devfn,const void *iommu); -void disable_ats_device (int seg,int bus,int devfn); -struct pci_ats_dev *get_ats_device (int seg,int bus,int devfn); +int enable_ats_device (const void *iommu,struct pci_dev *pdev);
The ordering of parameters is backwards here.
Quoted 21 lines
xen/drivers/passthrough/x86/ats.c +4
-2@@ -22,10 +22,12 @@ LIST_HEAD(ats_devices);bool_t __read_mostly ats_enabled =0 ;boolean_param ("ats" , ats_enabled); -int enable_ats_device (int seg,int bus,int devfn,const void *iommu) +int enable_ats_device (const void *iommu,struct pci_dev *pdev) { -struct pci_ats_dev *pdev =NULL ; +struct pci_ats_dev *ats_dev =NULL ;u32 value; +u16 seg = pdev->seg; +u8 bus = pdev->bus, devfn = pdev->devfn;int pos; pos =pci_find_ext_capability (seg, bus, devfn,PCI_EXT_CAP_ID_ATS );@@ -39,9 +41,14 @@ int enable_ats_device(int seg, int bus, int devfn, const void *iommu) PCI_FUNC(devfn), pos + ATS_REG_CTL);if ( value &ATS_ENABLE ) {
xen/drivers/passthrough/x86/ats.c int enable_ats_device(int seg, int bus, int devfn, const void *iommu) · line 51
Quoted 10 lines
xen/drivers/passthrough/x86/ats.c +7
-2- list_for_each_entry ( pdev, &ats_devices, list ) + list_for_each_entry ( ats_dev, &ats_devices, list ) { -if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn ) +struct pci_dev *_pdev = ats_dev->pdev; + +ASSERT (_pdev); +if ( _pdev->seg == seg && + _pdev->bus == bus && + _pdev->devfn == devfn )
Why do you do SBDF based compares, when you can simply compare the two pointers now? (And btw., local variables should never begin with an underscore.)
Since you had indicated that today is your last day at Intel, I guess I'll see to pick up this series (or maybe Kevin could) to bring it to the point where it can go in.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v14 1/3] IOMMU/x86: use a struct pci_dev* instead of SBDF
Quoted 5 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line · On 04.07.16 at 11:11, <[email protected]> wrote:
Since you had indicated that today is your last day at Intel, I guess I'll see to pick up this series (or maybe Kevin could) to bring it to the point where it can go in.
Jan, this is the best idea if you can pick this series. Thanks very much!!
I very much appreciated!!
-Quan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v14 2/3 IOMMU: add domain crash logic
In reply to Xu, QuanFrom: Quan Xu <[email protected]>
Add domain crash logic to the generic IOMMU layer to benefit all platforms.
No spamming of the log can occur. For DomU, we avoid logging any message for already dying domains. For Dom0, that'll still be more verbose than we'd really like, but it at least wouldn't outright flood the console.
--- xen/drivers/passthrough/iommu.c | 30 ++++++++++++++++++++++++++++-- xen/drivers/passthrough/vtd/iommu.c | 11 +++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-)
xen/drivers/passthrough/iommu.c +28 -2
@@ -318,21 +318,47 @@ int iommu_iotlb_flush(struct domain *d, unsigned long gfn, unsigned int page_count) {const struct domain_iommu *hd =dom_iommu (d); +int rc;if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_flush )return 0 ; -return hd->platform_ops->iotlb_flush (d, gfn, page_count); + rc = hd->platform_ops->iotlb_flush (d, gfn, page_count); +if (unlikely (rc) ) + { +if ( !d->is_shutting_down &&printk_ratelimit () ) +printk (XENLOG_ERR +"d%d: IOMMU IOTLB flush failed: %d, gfn %#lx, page count %u\n" , + d->domain_id, rc, gfn, page_count); + +if ( !is_hardware_domain (d) ) +domain_crash (d); + } + +return rc; }int iommu_iotlb_flush_all (struct domain *d) {const struct domain_iommu *hd =dom_iommu (d); +int rc;if ( !iommu_enabled || !hd->platform_ops || !hd->platform_ops->iotlb_flush_all )return 0 ; -return hd->platform_ops->iotlb_flush_all (d); + rc = hd->platform_ops->iotlb_flush_all (d); +if (unlikely (rc) ) + { +if ( !d->is_shutting_down &&printk_ratelimit () ) +printk (XENLOG_ERR +"d%d: IOMMU IOTLB flush all failed: %d\n" , + d->domain_id, rc); + +if ( !is_hardware_domain (d) ) +domain_crash (d); + } + +return rc; }int __init iommu_setup (void )
xen/drivers/passthrough/vtd/iommu.c +11 -0
@@ -1847,6 +1847,17 @@ int iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte, } } +if (unlikely (rc) ) + { +if ( !d->is_shutting_down &&printk_ratelimit () ) + printk(XENLOG_ERR VTDPREFIX +" d%d: IOMMU pages flush failed: %d\n" , + d->domain_id, rc); + +if ( !is_hardware_domain (d) ) +domain_crash (d); + } +return rc; }
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v14 3/3 IOMMU: fix vt-d Device-TLB flush timeout issue
In reply to Xu, QuanFrom: Quan Xu <[email protected]>
If Device-TLB flush timed out, we hide the target ATS device immediately. By hiding the device, we make sure it can't be assigned to any domain any longer (see device_assigned).
---
v14: release the lock before return.
--- xen/drivers/passthrough/iommu.c | 24 +++++++++++++++ xen/drivers/passthrough/pci.c | 6 ++-- xen/drivers/passthrough/vtd/extern.h | 5 ++-- xen/drivers/passthrough/vtd/qinval.c | 56 +++++++++++++++++++++++++++-------- xen/drivers/passthrough/vtd/x86/ats.c | 11 ++----- xen/include/xen/iommu.h | 3 ++ xen/include/xen/pci.h | 1 + 7 files changed, 79 insertions(+), 27 deletions(-)
xen/drivers/passthrough/iommu.c +24 -0
@@ -361,6 +361,30 @@ int iommu_iotlb_flush_all(struct domain *d)return rc; } +void iommu_dev_iotlb_flush_timeout (struct domain *d, +struct pci_dev *pdev) +{ +pcidevs_lock (); + +ASSERT (pdev->domain); +if ( d != pdev->domain ) + { +pcidevs_unlock (); +return ; + } + +list_del (&pdev->domain_list); + pdev->domain =NULL ; +pci_hide_existing_device (pdev); +if ( !d->is_shutting_down &&printk_ratelimit () ) +printk (XENLOG_ERR +"dom%d: ATS device %04x:%02x:%02x.%u flush failed\n" , + d->domain_id, pdev->seg, pdev->bus,PCI_SLOT (pdev->devfn), +PCI_FUNC (pdev->devfn)); + +pcidevs_unlock (); +} +int __init iommu_setup (void ) {int rc = -ENODEV ;
xen/drivers/passthrough/pci.c +3 -3
@@ -419,7 +419,7 @@ static void free_pdev(struct pci_seg *pseg, struct pci_dev *pdev)xfree (pdev); } -static void _pci_hide_device (struct pci_dev *pdev) +void pci_hide_existing_device (struct pci_dev *pdev) {if ( pdev->domain )return ;
@@ -436,7 +436,7 @@ int __init pci_hide_device(int bus, int devfn) pdev =alloc_pdev (get_pseg (0 ), bus, devfn);if ( pdev ) { -_pci_hide_device (pdev); +pci_hide_existing_device (pdev); rc =0 ; }pcidevs_unlock ();
@@ -466,7 +466,7 @@ int __init pci_ro_device(int seg, int bus, int devfn) }__set_bit (PCI_BDF2 (bus, devfn), pseg->ro_map); -_pci_hide_device (pdev); +pci_hide_existing_device (pdev);return 0 ; }
xen/drivers/passthrough/vtd/extern.h +3 -2
@@ -25,6 +25,7 @@#define VTDPREFIX "[VT-D]" +struct pci_ats_dev ;extern bool_t rwbf_quirk;void print_iommu_regs (struct acpi_drhd_unit *drhd);
@@ -60,8 +61,8 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did, u64 addr, unsigned int size_order, u64 type);int __must_check qinval_device_iotlb_sync (struct iommu *iommu, -u32 max_invs_pend, -u16 sid,u16 size,u64 addr); +struct pci_ats_dev *ats_dev, +u16 did,u16 size,u64 addr);unsigned int get_cache_line_size (void );void cacheline_flush (char *);
xen/drivers/passthrough/vtd/qinval.c +43 -13
116 lines not on this page · raw message
xen/drivers/passthrough/vtd/x86/ats.c +2 -9
@@ -118,14 +118,9 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,list_for_each_entry ( ats_dev, &ats_devices, list ) { -struct pci_dev *pdev = ats_dev->pdev; -u16 sid;bool_t sbit;int rc =0 ; -ASSERT (pdev); - sid =PCI_BDF2 (pdev->bus, pdev->devfn); -/* Only invalidate devices that belong to this IOMMU */ if ( ats_dev->iommu != iommu )continue ;
@@ -140,8 +135,7 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,/* invalidate all translations: sbit=1,bit_63=0,bit[62:12]=1 */ sbit =1 ; addr = (~0UL <<PAGE_SHIFT_4K ) &0x7FFFFFFFFFFFFFFF ; - rc =qinval_device_iotlb_sync (iommu, ats_dev->ats_queue_depth, - sid, sbit, addr); + rc =qinval_device_iotlb_sync (iommu, ats_dev, did, sbit, addr);break ;case DMA_TLB_PSI_FLUSH :if ( !device_in_domain (iommu, ats_dev, did) )
@@ -160,8 +154,7 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did, addr |= (((u64 )1 << (size_order -1 )) -1 ) <<PAGE_SHIFT_4K ; } - rc =qinval_device_iotlb_sync (iommu, ats_dev->ats_queue_depth, - sid, sbit, addr); + rc =qinval_device_iotlb_sync (iommu, ats_dev, did, sbit, addr);break ;default : dprintk(XENLOG_WARNING VTDPREFIX, "invalid vt-d flush type\n");
xen/include/xen/iommu.h +3 -0
@@ -207,6 +207,9 @@ int __must_check iommu_iotlb_flush(struct domain *d, unsigned long gfn, unsigned int page_count);int __must_check iommu_iotlb_flush_all (struct domain *d); +void iommu_dev_iotlb_flush_timeout (struct domain *d, +struct pci_dev *pdev); +/* * The purpose of the iommu_dont_flush_iotlb optional cpu flag is to * avoid unecessary iotlb_flush in the low level IOMMU code.
xen/include/xen/pci.h +1 -0
@@ -118,6 +118,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,int pci_remove_device (u16 seg,u8 bus,u8 devfn);int pci_ro_device (int seg,int bus,int devfn);int pci_hide_device (int bus,int devfn); +void pci_hide_existing_device (struct pci_dev *pdev);struct pci_dev *pci_get_pdev (int seg,int bus,int devfn);struct pci_dev *pci_get_real_pdev (int seg,int bus,int devfn); struct pci_dev *pci_get_pdev_by_domain(
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v14 3/3] IOMMU: fix vt-d Device-TLB flush timeout issue
Quoted 9 lines
From: Xu, Quan
Sent: Monday, July 04, 2016 5:12 PMFrom: Quan Xu <[email protected]>
If Device-TLB flush timed out, we hide the target ATS device immediately. By hiding the device, we make sure it can't be assigned to any domain any longer (see
device_assigned).
Quoted 5 lines
Signed-off-by Quan Xu <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v14 3/3] IOMMU: fix vt-d Device-TLB flush timeout issue
Quoted 9 lines · Kevin
Quoted 9 lines
From: Xu, Quan
Sent: Monday, July 04, 2016 5:12 PMFrom: Quan Xu <[email protected]>
If Device-TLB flush timed out, we hide the target ATS device immediately. By hiding the device, we make sure it can't be assigned to any domain any longer (see
device_assigned).
Quoted 7 lines
Quoted 5 lines
Signed-off-by Quan Xu <[email protected]>Acked-by Kevin Tian <[email protected]>
Jan, now there patches are all acked-by Kevin. Is it ready to go in? If not, could you send out your comments, I shall be very grateful and fix it today.
Quan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v14 3/3] IOMMU: fix vt-d Device-TLB flush timeout issue
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 05.07.16 at 04:04, <[email protected]> wrote:
Quoted 15 lines · Kevin
Quoted 14 lines
From: Xu, Quan
Sent: Monday, July 04, 2016 5:12 PMFrom: Quan Xu <[email protected]>
If Device-TLB flush timed out, we hide the target ATS device immediately. By hiding the device, we make sure it can't be assigned to any domain any longer (see
device_assigned).Signed-off-by Quan Xu <[email protected]>
Quoted 5 lines
Quoted 1 line
Acked-by Kevin Tian <[email protected]>Jan, now there patches are all acked-by Kevin. Is it ready to go in? If not, could you send out your comments, I shall be very grateful and fix it today.
You sent the most recent version yesterday. Please allow more than just one day before you ping.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v14 3/3] IOMMU: fix vt-d Device-TLB flush timeout issue
Quoted 17 lines · Jan Beulich
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 05.07.16 at 04:04, <[email protected]> wrote:
Quoted 15 lines · Kevin
Quoted 14 lines
From: Xu, Quan
Sent: Monday, July 04, 2016 5:12 PMFrom: Quan Xu <[email protected]>
If Device-TLB flush timed out, we hide the target ATS device immediately. By hiding the device, we make sure it can't be assigned to any domain any longer (see
device_assigned).Signed-off-by Quan Xu <[email protected]>
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Acked-by Kevin Tian <[email protected]>Jan, now there patches are all acked-by Kevin. Is it ready to go in? If not, could you send out your comments, I shall be very grateful and fix it today.
You sent the most recent version yesterday. Please allow more than just one day before you ping.
Sorry for that, as today is my last working day at Intel Corporation.
I really want to close it as a milestone (but if there is still some comment, I will continue to fix it).
Quan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v14 3/3] IOMMU: fix vt-d Device-TLB flush timeout issue
In reply to Xu, Quanxen/drivers/passthrough/iommu.c int iommu_iotlb_flush_all(struct domain *d) · line 364
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 04.07.16 at 11:11, <[email protected]> wrote:
xen/drivers/passthrough/iommu.c +1
-0@@ -361,6 +361,30 @@ int iommu_iotlb_flush_all(struct domain *d)return rc; } +void iommu_dev_iotlb_flush_timeout(struct domain *d,
const
Quoted 12 lines
xen/drivers/passthrough/iommu.c +12
-0+ struct pci_dev *pdev) +{ +pcidevs_lock (); + +ASSERT (pdev->domain); +if ( d != pdev->domain ) + { +pcidevs_unlock (); +return ; + } + +list_del (&pdev->domain_list);
xen/drivers/passthrough/iommu.c int iommu_iotlb_flush_all(struct domain *d) · line 386
Quoted 10 lines
xen/drivers/passthrough/iommu.c +10
-0+ pdev->domain =NULL ; +pci_hide_existing_device (pdev); +if ( !d->is_shutting_down &&printk_ratelimit () ) +printk (XENLOG_ERR +"dom%d: ATS device %04x:%02x:%02x.%u flush failed\n" , + d->domain_id, pdev->seg, pdev->bus,PCI_SLOT (pdev->devfn), +PCI_FUNC (pdev->devfn)); + +pcidevs_unlock (); +}
I'm missing the domain_crash() part here (which would be the only reason why the parameter above can't be const).
xen/drivers/passthrough/iommu.c int iommu_iotlb_flush_all(struct domain *d) · line 388
Quoted 2 lines
xen/drivers/passthrough/iommu.c +2
-0+static int __must_check dev_invalidate_sync (struct iommu *iommu, +struct pci_dev *pdev,u16 did)
const
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v14 3/3] IOMMU: fix vt-d Device-TLB flush timeout issue
Jan,
Just check it, do you agree to pick up this series?
Quan
Quoted 36 lines · Jan Beulich
xen/drivers/passthrough/iommu.c int iommu_iotlb_flush_all(struct domain *d) · line 364
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 04.07.16 at 11:11, <[email protected]> wrote:
xen/drivers/passthrough/iommu.c +1
-0@@ -361,6 +361,30 @@ int iommu_iotlb_flush_all(struct domain *d)return rc; } +void iommu_dev_iotlb_flush_timeout(struct domain *d,const
Quoted 11 lines
xen/drivers/passthrough/iommu.c +11
-0+ struct pci_dev *pdev) { +pcidevs_lock (); + +ASSERT (pdev->domain); +if ( d != pdev->domain ) + { +pcidevs_unlock (); +return ; + } + +list_del (&pdev->domain_list);xen/drivers/passthrough/iommu.c int iommu_iotlb_flush_all(struct domain *d) · line 386
Quoted 10 lines
xen/drivers/passthrough/iommu.c +10
-0+ pdev->domain =NULL ; +pci_hide_existing_device (pdev); +if ( !d->is_shutting_down &&printk_ratelimit () ) +printk (XENLOG_ERR +"dom%d: ATS device %04x:%02x:%02x.%u flush failed\n" , + d->domain_id, pdev->seg, pdev->bus,PCI_SLOT (pdev->devfn), +PCI_FUNC (pdev->devfn)); + +pcidevs_unlock (); +}I'm missing the
domain_crash()part here (which would be the only reason why the parameter above can't be const).
Quoted 7 lines
xen/drivers/passthrough/iommu.c int iommu_iotlb_flush_all(struct domain *d) · line 388
Quoted 3 lines
xen/drivers/passthrough/iommu.c +3
-0+static int __must_check dev_invalidate_sync (struct iommu *iommu, +struct pci_dev *pdev,u16 +did)const
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v14 3/3] IOMMU: fix vt-d Device-TLB flush timeout issue
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 05.07.16 at 15:56, <[email protected]> wrote:
Just check it, do you agree to pick up this series?
Depends on Kevin's view; I wanted to send out review feedback publicly regardless of who'd be picking it up.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel