xen/arm: Make PCI passthrough code non-x86 specific
cover xen/arm: Make PCI passthrough code non-x86 specific
This patch series is preparatory work to make PCI passthrough code non-x86 specific.
Rahul Singh (4):
xen/ns16550: solve compilation error on ARM with CONFIG_HAS_PCI
enabled.
xen/pci: Introduce new CONFIG_HAS_PCI_ATS flag for PCI ATS
functionality.
xen/pci: Move x86 specific code to x86 directory. xen/pci: solve compilation error when memory paging is not enabled.
xen/arch/x86/Kconfig | 1 + xen/drivers/char/Kconfig | 7 ++ xen/drivers/char/ns16550.c | 32 ++++---- xen/drivers/passthrough/ats.h | 24 ++++++ xen/drivers/passthrough/pci.c | 79 +------------------ xen/drivers/passthrough/vtd/x86/Makefile | 2 +- xen/drivers/passthrough/x86/Makefile | 3 +- xen/drivers/passthrough/x86/iommu.c | 7 ++ xen/drivers/passthrough/x86/pci.c | 97 ++++++++++++++++++++++++ xen/drivers/pci/Kconfig | 3 + xen/include/xen/pci.h | 2 + 11 files changed, 164 insertions(+), 93 deletions(-) create mode 100644 xen/drivers/passthrough/x86/pci.c
Signature · 1 line
2.17.1
PATCH 1/4 xen/ns16550: solve compilation error on ARM with CONFIG_HAS_PCI enabled.
ARM platforms does not support ns16550 PCI support. When CONFIG_HAS_PCI is enabled for ARM a compilation error is observed.
Fixed compilation error after introducing new kconfig option CONFIG_HAS_NS16550_PCI for x86 platforms to support ns16550 PCI.
No functional change.
--- xen/drivers/char/Kconfig | 7 +++++++ xen/drivers/char/ns16550.c | 32 ++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-)
xen/drivers/char/Kconfig +7 -0
@@ -4,6 +4,13 @@ config HAS_NS16550 help This selects the 16550-series UART support. For most systems, say Y. +config HAS_NS16550_PCI + bool "NS16550 UART PCI support" if X86 + default y + depends on X86 && HAS_NS16550 && HAS_PCI + help + This selects the 16550-series UART PCI support. For most systems, say Y. + config HAS_CADENCE_UART bool "Xilinx Cadence UART driver" default y
xen/drivers/char/ns16550.c +16 -16
@@ -16,7 +16,7 @@#include <xen/timer.h> #include <xen/serial.h> #include <xen/iocap.h> -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI #include <xen/pci.h> #include <xen/pci_regs.h> #include <xen/pci_ids.h>
@@ -54,7 +54,7 @@ enum serial_param_type { reg_shift, reg_width, stop_bits, -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI bridge_bdf, device, port_bdf,
@@ -83,7 +83,7 @@ static struct ns16550 {unsigned int timeout_ms;bool_t intr_works;bool_t dw_usr_bsy; -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI /* PCI card parameters. */ bool_t pb_bdf_enable;/* if =1, pb-bdf effective, port behind bridge */ bool_t ps_bdf_enable;/* if =1, ps_bdf effective, port on pci card */
@@ -117,14 +117,14 @@ static const struct serial_param_var __initconst sp_vars[] = { {"reg-shift", reg_shift}, {"reg-width", reg_width}, {"stop-bits", stop_bits}, -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI {"bridge", bridge_bdf}, {"dev", device}, {"port", port_bdf}, #endif }; -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI struct ns16550_config { u16 vendor_id; u16 dev_id;
@@ -620,7 +620,7 @@ static int ns16550_getc(struct serial_port *port, char *pc)static void pci_serial_early_init (struct ns16550 *uart) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( !uart->ps_bdf_enable || uart->io_base >=0x10000 )return ;
@@ -719,7 +719,7 @@ static void __init ns16550_init_preirq(struct serial_port *port)static void __init ns16550_init_irq (struct serial_port *port) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI struct ns16550 *uart = port->uart;if ( uart->msi )
@@ -761,7 +761,7 @@ static void __init ns16550_init_postirq(struct serial_port *port) uart->timeout_ms =max_t ( unsigned int, 1, (bits * uart->fifo_size * 1000) / uart->baud); -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( uart->bar || uart->ps_bdf_enable ) { if ( uart->param && uart->param->mmio &&
@@ -841,7 +841,7 @@ static void ns16550_suspend(struct serial_port *port)stop_timer (&uart->timer); -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( uart->bar ) uart->cr =pci_conf_read16 (PCI_SBDF (0 , uart->ps_bdf[0 ], uart->ps_bdf[1 ], uart->ps_bdf[2 ]),PCI_COMMAND );
@@ -850,7 +850,7 @@ static void ns16550_suspend(struct serial_port *port)static void _ns16550_resume (struct serial_port *port) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI struct ns16550 *uart = port->uart;if ( uart->bar )
@@ -1013,7 +1013,7 @@ static int __init check_existence(struct ns16550 *uart)return 1 ;/* Everything is MMIO */ #endif -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI pci_serial_early_init (uart);#endif
@@ -1044,7 +1044,7 @@ static int __init check_existence(struct ns16550 *uart)return (status ==0x90 ); } -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI static int __init pci_uart_config (struct ns16550 *uart,bool_t skip_amt,unsigned int idx) {
@@ -1305,7 +1305,7 @@ static bool __init parse_positional(struct ns16550 *uart, char **str)if ( *conf ==',' && *++conf !=',' ) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if (strncmp (conf,"pci" ,3 ) ==0 ) {if (pci_uart_config (uart,1 /* skip AMT */ , uart - ns16550_com) )
@@ -1327,7 +1327,7 @@ static bool __init parse_positional(struct ns16550 *uart, char **str)if ( *conf ==',' && *++conf !=',' ) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if (strncmp (conf,"msi" ,3 ) ==0 ) { conf +=3 ;
@@ -1339,7 +1339,7 @@ static bool __init parse_positional(struct ns16550 *uart, char **str) uart->irq =simple_strtol (conf, &conf,10 ); } -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( *conf ==',' && *++conf !=',' ) { conf = parse_pci(conf, NULL, &uart->ps_bdf[0],
@@ -1419,7 +1419,7 @@ static bool __init parse_namevalue_pairs(char *str, struct ns16550 *uart) uart->reg_width =simple_strtoul (param_value,NULL ,0 );break ; -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI case bridge_bdf:if ( !parse_pci (param_value,NULL , &uart->ps_bdf[0 ], &uart->ps_bdf[1 ], &uart->ps_bdf[2 ]) )
Signature · 1 line
2.17.1
PATCH 2/4 xen/pci: Introduce new CONFIG_HAS_PCI_ATS flag for PCI ATS functionality.
In reply to Rahul SinghPCI ATS functionality is not enabled and tested for ARM architecture but it is enabled for x86 and referenced in common passthrough/pci.c code.
Therefore introducing the new flag to enable the ATS functionality for x86 only to avoid issues for ARM architecture.
No functional change.
--- xen/arch/x86/Kconfig | 1 + xen/drivers/passthrough/ats.h | 24 ++++++++++++++++++++++++ xen/drivers/passthrough/vtd/x86/Makefile | 2 +- xen/drivers/passthrough/x86/Makefile | 2 +- xen/drivers/pci/Kconfig | 3 +++ 5 files changed, 30 insertions(+), 2 deletions(-)
xen/arch/x86/Kconfig +1 -0
@@ -20,6 +20,7 @@ config X86 select HAS_NS16550 select HAS_PASSTHROUGH select HAS_PCI + select HAS_PCI_ATS select HAS_PDX select HAS_SCHED_GRANULARITY select HAS_UBSAN
xen/drivers/passthrough/ats.h +24 -0
@@ -17,6 +17,8 @@#include <xen/pci_regs.h> +#ifdef CONFIG_HAS_PCI_ATS +#define ATS_REG_CAP 4#define ATS_REG_CTL 6#define ATS_QUEUE_DEPTH_MASK 0x1f
@@ -48,5 +50,27 @@ static inline int pci_ats_device(int seg, int bus, int devfn)return pci_find_ext_capability (seg, bus, devfn,PCI_EXT_CAP_ID_ATS ); } +#else + +static inline int enable_ats_device (struct pci_dev *pdev, +struct list_head *ats_list) +{ +return -ENODEV ; +} + +static inline void disable_ats_device (struct pci_dev *pdev) { } + +static inline int pci_ats_enabled (int seg,int bus,int devfn) +{ +return -ENODEV ; +} + +static inline int pci_ats_device (int seg,int bus,int devfn) +{ +return -ENODEV ; +} + +#endif /* CONFIG_HAS_PCI_ATS */ +#endif /* _ATS_H_ */
xen/drivers/passthrough/vtd/x86/Makefile +1 -1
@@ -1,3 +1,3 @@ -obj-y += ats.o +obj-$(CONFIG_HAS_PCI_ATS) += ats.o obj-$(CONFIG_HVM) += hvm.o obj-y += vtd.o
xen/drivers/passthrough/x86/Makefile +1 -1
@@ -1,2 +1,2 @@ -obj-y += ats.o +obj-$(CONFIG_HAS_PCI_ATS) += ats.o obj-y += iommu.o
xen/drivers/pci/Kconfig +3 -0
@@ -1,3 +1,6 @@ config HAS_PCI bool + +config HAS_PCI_ATS + bool
Signature · 1 line
2.17.1
PATCH 3/4 xen/pci: Move x86 specific code to x86 directory.
In reply to Rahul Singhpassthrough/pci.c file is common for all architecture, but there is x86 sepcific code in this file.
Move x86 specific code to the x86 directory to avoid compilation error for other architecture.
No functional change.
--- xen/drivers/passthrough/pci.c | 75 +-------------------- xen/drivers/passthrough/x86/Makefile | 1 + xen/drivers/passthrough/x86/iommu.c | 7 ++ xen/drivers/passthrough/x86/pci.c | 97 ++++++++++++++++++++++++++++ xen/include/xen/pci.h | 2 + 5 files changed, 108 insertions(+), 74 deletions(-) create mode 100644 xen/drivers/passthrough/x86/pci.c
xen/drivers/passthrough/pci.c +1 -74
@@ -24,7 +24,6 @@#include <xen/irq.h> #include <xen/param.h> #include <xen/vm_event.h> -#include <asm/hvm/irq.h> #include <xen/delay.h> #include <xen/keyhandler.h> #include <xen/event.h>
@@ -847,71 +846,6 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)return ret; } -static int pci_clean_dpci_irq (struct domain *d, -struct hvm_pirq_dpci *pirq_dpci,void *arg) -{ -struct dev_intx_gsi_link *digl, *tmp; - -pirq_guest_unbind (d,dpci_pirq (pirq_dpci)); - -if (pt_irq_need_timer (pirq_dpci->flags) ) -kill_timer (&pirq_dpci->timer); - - list_for_each_entry_safe ( digl, tmp, &pirq_dpci->digl_list, list ) - { -list_del (&digl->list); -xfree (digl); - } - -radix_tree_delete (&d->pirq_tree,dpci_pirq (pirq_dpci)->pirq); - -if ( !pt_pirq_softirq_active (pirq_dpci) ) -return 0 ; - -domain_get_irq_dpci (d)->pending_pirq_dpci = pirq_dpci; - -return -ERESTART ; -} - -static int pci_clean_dpci_irqs (struct domain *d) -{ -struct hvm_irq_dpci *hvm_irq_dpci =NULL ; - -if ( !is_iommu_enabled (d) ) -return 0 ; - -if ( !is_hvm_domain (d) ) -return 0 ; - -spin_lock (&d->event_lock); - hvm_irq_dpci =domain_get_irq_dpci (d); -if ( hvm_irq_dpci !=NULL ) - { -int ret =0 ; - -if ( hvm_irq_dpci->pending_pirq_dpci ) - { -if (pt_pirq_softirq_active (hvm_irq_dpci->pending_pirq_dpci) ) - ret = -ERESTART ; -else - hvm_irq_dpci->pending_pirq_dpci =NULL ; - } - -if ( !ret ) - ret =pt_pirq_iterate (d, pci_clean_dpci_irq,NULL ); -if ( ret ) - { -spin_unlock (&d->event_lock); -return ret; - } - -hvm_domain_irq (d)->dpci =NULL ; -free_hvm_irq_dpci (hvm_irq_dpci); - } -spin_unlock (&d->event_lock); -return 0 ; -} -/* Caller should hold the pcidevs_lock */ static int deassign_device (struct domain *d,uint16_t seg,uint8_t bus,uint8_t devfn)
@@ -971,7 +905,7 @@ int pci_release_devices(struct domain *d)int ret;pcidevs_lock (); - ret =pci_clean_dpci_irqs (d); + ret =arch_pci_release_devices (d);if ( ret ) {pcidevs_unlock ();
@@ -1375,13 +1309,6 @@ static int __init setup_dump_pcidevs(void) }__initcall (setup_dump_pcidevs); -int iommu_update_ire_from_msi ( -struct msi_desc *msi_desc,struct msi_msg *msg) -{ -return iommu_intremap - ?iommu_call (&iommu_ops, update_ire_from_msi, msi_desc, msg) :0 ; -} -static int iommu_add_device (struct pci_dev *pdev) {const struct domain_iommu *hd;
xen/drivers/passthrough/x86/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_HAS_PCI_ATS) += ats.o obj-y += iommu.o +obj-y += pci.o
xen/drivers/passthrough/x86/iommu.c +7 -0
@@ -308,6 +308,13 @@ struct page_info *iommu_alloc_pgtable(struct domain *d)return pg; } +int iommu_update_ire_from_msi ( +struct msi_desc *msi_desc,struct msi_msg *msg) +{ +return iommu_intremap + ?iommu_call (&iommu_ops, update_ire_from_msi, msi_desc, msg) :0 ; +} +/* * Local variables: * mode: C
xen/drivers/passthrough/x86/pci.c new file +97 -0
97 lines not on this page · raw message
xen/include/xen/pci.h +2 -0
@@ -212,4 +212,6 @@ int msixtbl_pt_register(struct domain *, struct pirq *, uint64_t gtable);void msixtbl_pt_unregister (struct domain *,struct pirq *);void msixtbl_pt_cleanup (struct domain *d); +int arch_pci_release_devices (struct domain *d); +#endif /* __XEN_PCI_H__ */
Signature · 1 line
2.17.1
PATCH 4/4 xen/pci: solve compilation error when memory paging is not enabled.
In reply to Rahul Singhd->vm_event_paging struct is defined under CONFIG_HAS_MEM_PAGING in sched.h but referenced in passthrough/pci.c directly.
If CONFIG_HAS_MEM_PAGING is not enabled for architecture, compiler will throws an error.
No functional change.
--- xen/drivers/passthrough/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
xen/drivers/passthrough/pci.c +3 -1
@@ -1419,13 +1419,15 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)if ( !is_iommu_enabled (d) )return 0 ; -/* Prevent device assign if mem paging or mem sharing have been +#if defined(CONFIG_HAS_MEM_PAGING ) || defined(CONFIG_MEM_SHARING ) +/* Prevent device assign if mem paging or mem sharing have been * enabled for this domain */ if ( d != dom_io &&unlikely (mem_sharing_enabled (d) ||vm_event_check_ring (d->vm_event_paging) ||p2m_get_hostp2m (d)->global_logdirty) )return -EXDEV ; +#endif /* device_assigned() should already have cleared the device for assignment */ ASSERT (pcidevs_locked ());
Signature · 1 line
2.17.1
Re: [PATCH v1 1/4] xen/ns16550: solve compilation error on ARM with CONFIG_HAS_PCI enabled.
In reply to Rahul SinghQuoted 1 line · Rahul Singh
ARM platforms does not support ns16550 PCI support. When
CONFIG_HAS_PCI
^ do
Quoted 6 lines
is enabled for ARM a compilation error is observed.
Fixed compilation error after introducing new kconfig option
CONFIG_HAS_NS16550_PCIfor x86 platforms to support ns16550 PCI.No functional change.
Written like that it would seem that ARM platforms do not support NS16550 on the PCI bus, but actually, it would be theoretically possible to have an NS16550 card slotted in a PCI bus on ARM, right?
The problem is the current limitation in terms of Xen internal plumbings, such as lack of MSI support. Is that correct?
If so, I'd update the commit message to reflect the situation a bit better.
Quoted 11 lines
Signed-off-by Rahul Singh <[email protected]>--- xen/drivers/char/Kconfig | 7 +++++++ xen/drivers/char/ns16550.c | 32 ++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-)xen/drivers/char/Kconfig +0
-0
xen/drivers/char/Kconfig config HAS_NS16550 · line 12
Quoted 9 lines
xen/drivers/char/Kconfig +6
-0@@ -4,6 +4,13 @@ config HAS_NS16550 help This selects the 16550-series UART support. For most systems, say Y. +config HAS_NS16550_PCI + bool "NS16550 UART PCI support" if X86 + default y + depends on X86 && HAS_NS16550 && HAS_PCI + help + This selects the 16550-series UART PCI support. For most systems, say Y.
I think that this should be a silent option:
if HAS_NS16550 && HAS_PCI && X86 -> automatically enable otherwise -> automatically disable
No need to show it to the user.
The rest of course is fine.
Quoted 153 lines
xen/drivers/char/Kconfig +0
-0config HAS_CADENCE_UART bool "Xilinx Cadence UART driver" default yxen/drivers/char/ns16550.c +16
-16@@ -16,7 +16,7 @@#include <xen/timer.h> #include <xen/serial.h> #include <xen/iocap.h> -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI #include <xen/pci.h> #include <xen/pci_regs.h> #include <xen/pci_ids.h> @@ -54,7 +54,7 @@ enum serial_param_type { reg_shift, reg_width, stop_bits, -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI bridge_bdf, device, port_bdf,@@ -83,7 +83,7 @@ static struct ns16550 {unsigned int timeout_ms;bool_t intr_works;bool_t dw_usr_bsy; -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI /* PCI card parameters. */ bool_t pb_bdf_enable;/* if =1, pb-bdf effective, port behind bridge */ bool_t ps_bdf_enable;/* if =1, ps_bdf effective, port on pci card */ @@ -117,14 +117,14 @@ static const struct serial_param_var __initconst sp_vars[] = { {"reg-shift", reg_shift}, {"reg-width", reg_width}, {"stop-bits", stop_bits}, -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI {"bridge", bridge_bdf}, {"dev", device}, {"port", port_bdf}, #endif }; -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI struct ns16550_config { u16 vendor_id; u16 dev_id;@@ -620,7 +620,7 @@ static int ns16550_getc(struct serial_port *port, char *pc)static void pci_serial_early_init (struct ns16550 *uart) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( !uart->ps_bdf_enable || uart->io_base >=0x10000 )return ;@@ -719,7 +719,7 @@ static void __init ns16550_init_preirq(struct serial_port *port)static void __init ns16550_init_irq (struct serial_port *port) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI struct ns16550 *uart = port->uart;if ( uart->msi )@@ -761,7 +761,7 @@ static void __init ns16550_init_postirq(struct serial_port *port) uart->timeout_ms =max_t ( unsigned int, 1, (bits * uart->fifo_size * 1000) / uart->baud); -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( uart->bar || uart->ps_bdf_enable ) { if ( uart->param && uart->param->mmio &&@@ -841,7 +841,7 @@ static void ns16550_suspend(struct serial_port *port)stop_timer (&uart->timer); -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( uart->bar ) uart->cr =pci_conf_read16 (PCI_SBDF (0 , uart->ps_bdf[0 ], uart->ps_bdf[1 ], uart->ps_bdf[2 ]),PCI_COMMAND );@@ -850,7 +850,7 @@ static void ns16550_suspend(struct serial_port *port)static void _ns16550_resume (struct serial_port *port) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI struct ns16550 *uart = port->uart;if ( uart->bar )@@ -1013,7 +1013,7 @@ static int __init check_existence(struct ns16550 *uart)return 1 ;/* Everything is MMIO */ #endif -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI pci_serial_early_init (uart);#endif @@ -1044,7 +1044,7 @@ static int __init check_existence(struct ns16550 *uart)return (status ==0x90 ); } -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI static int __init pci_uart_config (struct ns16550 *uart,bool_t skip_amt,unsigned int idx) {@@ -1305,7 +1305,7 @@ static bool __init parse_positional(struct ns16550 *uart, char **str)if ( *conf ==',' && *++conf !=',' ) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if (strncmp (conf,"pci" ,3 ) ==0 ) {if (pci_uart_config (uart,1 /* skip AMT */ , uart - ns16550_com) )@@ -1327,7 +1327,7 @@ static bool __init parse_positional(struct ns16550 *uart, char **str)if ( *conf ==',' && *++conf !=',' ) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if (strncmp (conf,"msi" ,3 ) ==0 ) { conf +=3 ;@@ -1339,7 +1339,7 @@ static bool __init parse_positional(struct ns16550 *uart, char **str) uart->irq =simple_strtol (conf, &conf,10 ); } -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( *conf ==',' && *++conf !=',' ) { conf = parse_pci(conf, NULL, &uart->ps_bdf[0],@@ -1419,7 +1419,7 @@ static bool __init parse_namevalue_pairs(char *str, struct ns16550 *uart) uart->reg_width =simple_strtoul (param_value,NULL ,0 );break ; -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI case bridge_bdf:if ( !parse_pci (param_value,NULL , &uart->ps_bdf[0 ], &uart->ps_bdf[1 ], &uart->ps_bdf[2 ]) )Signature · 1 line
2.17.1
Re: [PATCH v1 2/4] xen/pci: Introduce new CONFIG_HAS_PCI_ATS flag for PCI ATS functionality.
In reply to Rahul SinghQuoted 51 lines · Rahul Singh
PCI ATS functionality is not enabled and tested for ARM architecture but it is enabled for x86 and referenced in common
passthrough/pci.ccode.Therefore introducing the new flag to enable the ATS functionality for x86 only to avoid issues for ARM architecture.
No functional change.
Signed-off-by Rahul Singh <[email protected]>--- xen/arch/x86/Kconfig | 1 + xen/drivers/passthrough/ats.h | 24 ++++++++++++++++++++++++ xen/drivers/passthrough/vtd/x86/Makefile | 2 +- xen/drivers/passthrough/x86/Makefile | 2 +- xen/drivers/pci/Kconfig | 3 +++ 5 files changed, 30 insertions(+), 2 deletions(-)xen/arch/x86/Kconfig +1
-0@@ -20,6 +20,7 @@ config X86 select HAS_NS16550 select HAS_PASSTHROUGH select HAS_PCI + select HAS_PCI_ATS select HAS_PDX select HAS_SCHED_GRANULARITY select HAS_UBSANxen/drivers/passthrough/ats.h +6
-0@@ -17,6 +17,8 @@#include <xen/pci_regs.h> +#ifdef CONFIG_HAS_PCI_ATS +#define ATS_REG_CAP 4#define ATS_REG_CTL 6#define ATS_QUEUE_DEPTH_MASK 0x1f@@ -48,5 +50,27 @@ static inline int pci_ats_device(int seg, int bus, int devfn) return pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS); } +#else + +static inline int enable_ats_device (struct pci_dev *pdev, +struct list_head *ats_list)
xen/drivers/passthrough/ats.h static inline int pci_ats_device(int seg, int bus, int devfn) · line 66
Quoted 10 lines
xen/drivers/passthrough/ats.h +10
-0+{ +return -ENODEV ; +} + +static inline void disable_ats_device (struct pci_dev *pdev) { } + +static inline int pci_ats_enabled (int seg,int bus,int devfn) +{ +return -ENODEV ; +}
pci_ats_enabled returns 0 when ATS is not enabled
xen/drivers/passthrough/ats.h static inline int pci_ats_device(int seg, int bus, int devfn) · line 70
Quoted 3 lines
xen/drivers/passthrough/ats.h +3
-0+static inline int pci_ats_device (int seg,int bus,int devfn) +{ +return -ENODEV ;
also returns 0 when ATS is not enabled
Quoted 37 lines
xen/drivers/passthrough/ats.h +4
-0+} + +#endif /* CONFIG_HAS_PCI_ATS */ +#endif /* _ATS_H_ */ xen/drivers/passthrough/vtd/x86/Makefile +1
-1@@ -1,3 +1,3 @@ -obj-y += ats.o +obj-$(CONFIG_HAS_PCI_ATS) += ats.o obj-$(CONFIG_HVM) += hvm.o obj-y += vtd.oxen/drivers/passthrough/x86/Makefile +1
-1@@ -1,2 +1,2 @@ -obj-y += ats.o +obj-$(CONFIG_HAS_PCI_ATS) += ats.o obj-y += iommu.oxen/drivers/pci/Kconfig +3
-0@@ -1,3 +1,6 @@ config HAS_PCI bool + +config HAS_PCI_ATS + boolSignature · 1 line
2.17.1
Quoted 2 lines · Rahul Singh
This patch series is preparatory work to make PCI passthrough code non-x86 specific.
Do you have a simple patch I could use to test the compilation on ARM? Even just a hack to help me review the series?
Right now I can only test that the compilation on x86 is unbroken.
Thanks!
- Stefano
Quoted 25 lines
Rahul Singh (4):
xen/ns16550: solve compilation error on ARM withCONFIG_HAS_PCI
enabled.
xen/pci: Introduce newCONFIG_HAS_PCI_ATSflag for PCI ATS
functionality.
xen/pci: Move x86 specific code to x86 directory. xen/pci: solve compilation error when memory paging is not enabled.xen/arch/x86/Kconfig | 1 + xen/drivers/char/Kconfig | 7 ++ xen/drivers/char/ns16550.c | 32 ++++---- xen/drivers/passthrough/ats.h | 24 ++++++ xen/drivers/passthrough/pci.c | 79 +------------------ xen/drivers/passthrough/vtd/x86/Makefile | 2 +- xen/drivers/passthrough/x86/Makefile | 3 +- xen/drivers/passthrough/x86/iommu.c | 7 ++ xen/drivers/passthrough/x86/pci.c | 97 ++++++++++++++++++++++++ xen/drivers/pci/Kconfig | 3 + xen/include/xen/pci.h | 2 + 11 files changed, 164 insertions(+), 93 deletions(-) create mode 100644 xen/drivers/passthrough/x86/pci.cSignature · 1 line
2.17.1
Re: [PATCH v1 3/4] xen/pci: Move x86 specific code to x86 directory.
In reply to Rahul SinghQuoted 2 lines · Rahul Singh
passthrough/pci.cfile is common for all architecture, but there is x86 sepcific code in this file.
^ specific
Quoted 20 lines
Move x86 specific code to the x86 directory to avoid compilation error for other architecture.
No functional change.
Signed-off-by Rahul Singh <[email protected]>--- xen/drivers/passthrough/pci.c | 75 +-------------------- xen/drivers/passthrough/x86/Makefile | 1 + xen/drivers/passthrough/x86/iommu.c | 7 ++ xen/drivers/passthrough/x86/pci.c | 97 ++++++++++++++++++++++++++++ xen/include/xen/pci.h | 2 + 5 files changed, 108 insertions(+), 74 deletions(-) create mode 100644 xen/drivers/passthrough/x86/pci.cxen/drivers/passthrough/pci.c +0
-0
xen/drivers/passthrough/pci.c line 29
Quoted 7 lines
xen/drivers/passthrough/pci.c +0
-1@@ -24,7 +24,6 @@#include <xen/irq.h> #include <xen/param.h> #include <xen/vm_event.h> -#include <asm/hvm/irq.h> #include <xen/delay.h> #include <xen/keyhandler.h> #include <xen/event.h>
sched.h is not needed anymore among the #include
Quoted 132 lines
xen/drivers/passthrough/pci.c +1
-73@@ -847,71 +846,6 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)return ret; } -static int pci_clean_dpci_irq (struct domain *d, -struct hvm_pirq_dpci *pirq_dpci,void *arg) -{ -struct dev_intx_gsi_link *digl, *tmp; - -pirq_guest_unbind (d,dpci_pirq (pirq_dpci)); - -if (pt_irq_need_timer (pirq_dpci->flags) ) -kill_timer (&pirq_dpci->timer); - - list_for_each_entry_safe ( digl, tmp, &pirq_dpci->digl_list, list ) - { -list_del (&digl->list); -xfree (digl); - } - -radix_tree_delete (&d->pirq_tree,dpci_pirq (pirq_dpci)->pirq); - -if ( !pt_pirq_softirq_active (pirq_dpci) ) -return 0 ; - -domain_get_irq_dpci (d)->pending_pirq_dpci = pirq_dpci; - -return -ERESTART ; -} - -static int pci_clean_dpci_irqs (struct domain *d) -{ -struct hvm_irq_dpci *hvm_irq_dpci =NULL ; - -if ( !is_iommu_enabled (d) ) -return 0 ; - -if ( !is_hvm_domain (d) ) -return 0 ; - -spin_lock (&d->event_lock); - hvm_irq_dpci =domain_get_irq_dpci (d); -if ( hvm_irq_dpci !=NULL ) - { -int ret =0 ; - -if ( hvm_irq_dpci->pending_pirq_dpci ) - { -if (pt_pirq_softirq_active (hvm_irq_dpci->pending_pirq_dpci) ) - ret = -ERESTART ; -else - hvm_irq_dpci->pending_pirq_dpci =NULL ; - } - -if ( !ret ) - ret =pt_pirq_iterate (d, pci_clean_dpci_irq,NULL ); -if ( ret ) - { -spin_unlock (&d->event_lock); -return ret; - } - -hvm_domain_irq (d)->dpci =NULL ; -free_hvm_irq_dpci (hvm_irq_dpci); - } -spin_unlock (&d->event_lock); -return 0 ; -} -/* Caller should hold the pcidevs_lock */ static int deassign_device (struct domain *d,uint16_t seg,uint8_t bus,uint8_t devfn)@@ -971,7 +905,7 @@ int pci_release_devices(struct domain *d)int ret;pcidevs_lock (); - ret =pci_clean_dpci_irqs (d); + ret =arch_pci_release_devices (d);if ( ret ) {pcidevs_unlock ();@@ -1375,13 +1309,6 @@ static int __init setup_dump_pcidevs(void) }__initcall (setup_dump_pcidevs); -int iommu_update_ire_from_msi ( -struct msi_desc *msi_desc,struct msi_msg *msg) -{ -return iommu_intremap - ?iommu_call (&iommu_ops, update_ire_from_msi, msi_desc, msg) :0 ; -} -static int iommu_add_device (struct pci_dev *pdev) {const struct domain_iommu *hd;xen/drivers/passthrough/x86/Makefile +1
-0@@ -1,2 +1,3 @@ obj-$(CONFIG_HAS_PCI_ATS) += ats.o obj-y += iommu.o +obj-y += pci.oxen/drivers/passthrough/x86/iommu.c +7
-0@@ -308,6 +308,13 @@ struct page_info *iommu_alloc_pgtable(struct domain *d)return pg; } +int iommu_update_ire_from_msi ( +struct msi_desc *msi_desc,struct msi_msg *msg) +{ +return iommu_intremap + ?iommu_call (&iommu_ops, update_ire_from_msi, msi_desc, msg) :0 ; +} +/* * Local variables: * mode: C xen/drivers/passthrough/x86/pci.c new file +5
-0@@ -0,0 +1,97 @@ +/* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +*
xen/drivers/passthrough/x86/pci.c line 15
Quoted 10 lines
xen/drivers/passthrough/x86/pci.c new file +10
-0+* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <xen/param.h>
not needed
xen/drivers/passthrough/x86/pci.c line 18
Quoted 3 lines
xen/drivers/passthrough/x86/pci.c new file +3
-0+#include <xen/sched.h> +#include <xen/pci.h> +#include <xen/pci_regs.h>
not needed
Quoted 89 lines
xen/drivers/passthrough/x86/pci.c new file +78
-0+static int pci_clean_dpci_irq (struct domain *d, +struct hvm_pirq_dpci *pirq_dpci,void *arg) +{ +struct dev_intx_gsi_link *digl, *tmp; + +pirq_guest_unbind (d,dpci_pirq (pirq_dpci)); + +if (pt_irq_need_timer (pirq_dpci->flags) ) +kill_timer (&pirq_dpci->timer); + + list_for_each_entry_safe ( digl, tmp, &pirq_dpci->digl_list, list ) + { +list_del (&digl->list); +xfree (digl); + } + +radix_tree_delete (&d->pirq_tree,dpci_pirq (pirq_dpci)->pirq); + +if ( !pt_pirq_softirq_active (pirq_dpci) ) +return 0 ; + +domain_get_irq_dpci (d)->pending_pirq_dpci = pirq_dpci; + +return -ERESTART ; +} + +static int pci_clean_dpci_irqs (struct domain *d) +{ +struct hvm_irq_dpci *hvm_irq_dpci =NULL ; + +if ( !is_iommu_enabled (d) ) +return 0 ; + +if ( !is_hvm_domain (d) ) +return 0 ; + +spin_lock (&d->event_lock); + hvm_irq_dpci =domain_get_irq_dpci (d); +if ( hvm_irq_dpci !=NULL ) + { +int ret =0 ; + +if ( hvm_irq_dpci->pending_pirq_dpci ) + { +if (pt_pirq_softirq_active (hvm_irq_dpci->pending_pirq_dpci) ) + ret = -ERESTART ; +else + hvm_irq_dpci->pending_pirq_dpci =NULL ; + } + +if ( !ret ) + ret =pt_pirq_iterate (d, pci_clean_dpci_irq,NULL ); +if ( ret ) + { +spin_unlock (&d->event_lock); +return ret; + } + +hvm_domain_irq (d)->dpci =NULL ; +free_hvm_irq_dpci (hvm_irq_dpci); + } +spin_unlock (&d->event_lock); +return 0 ; +} + +int arch_pci_release_devices (struct domain *d) +{ +return pci_clean_dpci_irqs (d); +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/include/xen/pci.h +2
-0@@ -212,4 +212,6 @@ int msixtbl_pt_register(struct domain *, struct pirq *, uint64_t gtable);void msixtbl_pt_unregister (struct domain *,struct pirq *);void msixtbl_pt_cleanup (struct domain *d); +int arch_pci_release_devices (struct domain *d); +#endif /* __XEN_PCI_H__ */
Re: [PATCH v1 1/4] xen/ns16550: solve compilation error on ARM with CONFIG_HAS_PCI enabled.
In reply to Stefano StabelliniQuoted 18 lines · Stefano Stabellini
xen/drivers/char/Kconfig config HAS_NS16550 · line 12
Quoted 12 lines · Rahul Singh
xen/drivers/char/Kconfig +6
-0@@ -4,6 +4,13 @@ config HAS_NS16550 help This selects the 16550-series UART support. For most systems, say Y. +config HAS_NS16550_PCI + bool "NS16550 UART PCI support" if X86 + default y + depends on X86 && HAS_NS16550 && HAS_PCI + help + This selects the 16550-series UART PCI support. For most systems, say Y.I think that this should be a silent option:
ifHAS_NS16550&&HAS_PCI&& X86 -> automatically enable otherwise -> automatically disable
Quoted 1 line
No need to show it to the user.
I agree in principle, but I don't see why an X86 dependency gets added here. HAS_PCI really should be all that's needed.
Jan
Re: [PATCH v1 2/4] xen/pci: Introduce new CONFIG_HAS_PCI_ATS flag for PCI ATS functionality.
In reply to Stefano StabelliniQuoted 8 lines · Stefano Stabellini
xen/arch/x86/Kconfig config X86 · line 23
Quoted 7 lines · Rahul Singh
xen/arch/x86/Kconfig +1
-0@@ -20,6 +20,7 @@ config X86 select HAS_NS16550 select HAS_PASSTHROUGH select HAS_PCI + select HAS_PCI_ATS
From an abstract perspective - is there a way to have a PCI subsystem where it is impossible for an ATS-capable devices to be present? I think this shouldn't be a HAS_* option, but an ordinary user selectable one. We may then even want to consider having it off by default on x86 (the command line option defaults to off as well, after all).
Quoted 22 lines
Quoted 8 lines
xen/arch/x86/Kconfig +4
-0@@ -48,5 +50,27 @@ static inline int pci_ats_device(int seg, int bus, int devfn) return pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS); } +#else + +static inline int enable_ats_device(struct pci_dev *pdev, + struct list_head *ats_list)xen/arch/x86/Kconfig static inline int pci_ats_device(int seg, int bus, int devfn) · line 66
Quoted 10 lines
xen/arch/x86/Kconfig +10
-0+{ + return -ENODEV; +} + +static inline void disable_ats_device(struct pci_dev *pdev) { } + +static inline int pci_ats_enabled(int seg, int bus, int devfn) +{ + return -ENODEV; +}
pci_ats_enabledreturns 0 when ATS is not enabled
Quoted 5 lines
xen/arch/x86/Kconfig static inline int pci_ats_device(int seg, int bus, int devfn) · line 69
Quoted 3 lines
xen/arch/x86/Kconfig +3
-0+static inline int pci_ats_device(int seg, int bus, int devfn) +{ + return -ENODEV;also returns 0 when ATS is not enabled
And really both ought to be returning bool.
Jan
Re: [PATCH v1 2/4] xen/pci: Introduce new CONFIG_HAS_PCI_ATS flag for PCI ATS functionality.
In reply to Rahul Singhxen/drivers/passthrough/ats.h static inline int pci_ats_device(int seg, int bus, int devfn) · line 58
Quoted 10 lines · Rahul Singh
xen/drivers/passthrough/ats.h +6
-0@@ -48,5 +50,27 @@ static inline int pci_ats_device(int seg, int bus, int devfn) return pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS); } +#else + +static inline int enable_ats_device (struct pci_dev *pdev, +struct list_head *ats_list) +{ +return -ENODEV ;
In addition to what Stefano has said, I don't think this is an appropriate return value here either - -EOPNOTSUPP would seem quite a bit closer to reality.
Jan
Re: [PATCH v1 1/4] xen/ns16550: solve compilation error on ARM with CONFIG_HAS_PCI enabled.
In reply to Stefano StabelliniHello Stefano,
Quoted 5 lines · Stefano Stabellini
Quoted 1 line · Rahul Singh
ARM platforms does not support ns16550 PCI support. When
CONFIG_HAS_PCI^ do
Ok I will fix that in next version.
Quoted 12 lines
Quoted 7 lines
is enabled for ARM a compilation error is observed.
Fixed compilation error after introducing new kconfig option
CONFIG_HAS_NS16550_PCIfor x86 platforms to support ns16550 PCI.No functional change.
Written like that it would seem that ARM platforms do not support NS16550 on the PCI bus, but actually, it would be theoretically possible to have an NS16550 card slotted in a PCI bus on ARM, right?
Quoted 6 lines
The problem is the current limitation in terms of Xen internal plumbings, such as lack of MSI support. Is that correct?
If so, I'd update the commit message to reflect the situation a bit better.
Yes you are right on ARM platforms PCI is not fully supported because of that I decided to disable it for ARM. Once we have full support for PCI device we can enable it for ARM also. I will modify the commit msg to reflect the same.
Quoted 26 lines
Quoted 12 lines
Signed-off-by Rahul Singh <[email protected]>---
xen/drivers/char/Kconfig | 7 +++++++xen/drivers/char/ns16550.c| 32 ++++++++++++++++----------------2 files changed, 23 insertions(+), 16 deletions(-)xen/drivers/char/Kconfig +0
-0xen/drivers/char/Kconfig config HAS_NS16550 · line 12
Quoted 9 lines
xen/drivers/char/Kconfig +6
-0@@ -4,6 +4,13 @@ config HAS_NS16550 help This selects the 16550-series UART support. For most systems, say Y. +config HAS_NS16550_PCI + bool "NS16550 UART PCI support" if X86 + default y + depends on X86 && HAS_NS16550 && HAS_PCI + help + This selects the 16550-series UART PCI support. For most systems, say Y.I think that this should be a silent option:
ifHAS_NS16550&&HAS_PCI&& X86 -> automatically enable otherwise -> automatically disable
Quoted 3 lines
No need to show it to the user.
The rest of course is fine.
Ok I will fix that. I will do the same as done for HAS_NS16550 ,
x86: silent option depend on HAS_NS16550 && HAS_PCI
ARM: user can decide to enable or disable via menuconfig depend on HAS_NS16550 && HAS_PCI.
Quoted 147 lines
Quoted 147 lines
config
HAS_CADENCE_UART
bool "Xilinx Cadence UART driver"
default yxen/drivers/char/ns16550.c +12
-12@@ -16,7 +16,7 @@#include <xen/timer.h> #include <xen/serial.h> #include <xen/iocap.h> -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI #include <xen/pci.h> #include <xen/pci_regs.h> #include <xen/pci_ids.h> @@ -54,7 +54,7 @@ enum serial_param_type { reg_shift, reg_width, stop_bits, -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI bridge_bdf, device, port_bdf,@@ -83,7 +83,7 @@ static struct ns16550 {unsigned int timeout_ms;bool_t intr_works;bool_t dw_usr_bsy; -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI /* PCI card parameters. */ bool_t pb_bdf_enable;/* if =1, pb-bdf effective, port behind bridge */ bool_t ps_bdf_enable;/* if =1, ps_bdf effective, port on pci card */ @@ -117,14 +117,14 @@ static const struct serial_param_var __initconst sp_vars[] = { {"reg-shift", reg_shift}, {"reg-width", reg_width}, {"stop-bits", stop_bits}, -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI {"bridge", bridge_bdf}, {"dev", device}, {"port", port_bdf}, #endif }; -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI struct ns16550_config { u16 vendor_id; u16 dev_id;@@ -620,7 +620,7 @@ static int ns16550_getc(struct serial_port *port, char *pc)static void pci_serial_early_init (struct ns16550 *uart) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( !uart->ps_bdf_enable || uart->io_base >=0x10000 )return ;@@ -719,7 +719,7 @@ static void __init ns16550_init_preirq(struct serial_port *port)static void __init ns16550_init_irq (struct serial_port *port) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI struct ns16550 *uart = port->uart;if ( uart->msi )@@ -761,7 +761,7 @@ static void __init ns16550_init_postirq(struct serial_port *port) uart->timeout_ms =max_t ( unsigned int, 1, (bits * uart->fifo_size * 1000) / uart->baud); -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( uart->bar || uart->ps_bdf_enable ) { if ( uart->param && uart->param->mmio &&@@ -841,7 +841,7 @@ static void ns16550_suspend(struct serial_port *port)stop_timer (&uart->timer); -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( uart->bar ) uart->cr =pci_conf_read16 (PCI_SBDF (0 , uart->ps_bdf[0 ], uart->ps_bdf[1 ], uart->ps_bdf[2 ]),PCI_COMMAND );@@ -850,7 +850,7 @@ static void ns16550_suspend(struct serial_port *port)static void _ns16550_resume (struct serial_port *port) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI struct ns16550 *uart = port->uart;if ( uart->bar )@@ -1013,7 +1013,7 @@ static int __init check_existence(struct ns16550 *uart)return 1 ;/* Everything is MMIO */ #endif -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI pci_serial_early_init (uart);#endif @@ -1044,7 +1044,7 @@ static int __init check_existence(struct ns16550 *uart)return (status ==0x90 ); } -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI static int
__initpci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx){xen/drivers/char/ns16550.c +3
-3@@ -1305,7 +1305,7 @@ static bool __init parse_positional(struct ns16550 *uart, char **str)if ( *conf ==',' && *++conf !=',' ) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if (strncmp (conf,"pci" ,3 ) ==0 ) {if (pci_uart_config (uart,1 /* skip AMT */ , uart - ns16550_com) )@@ -1327,7 +1327,7 @@ static bool __init parse_positional(struct ns16550 *uart, char **str)if ( *conf ==',' && *++conf !=',' ) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if (strncmp (conf,"msi" ,3 ) ==0 ) { conf +=3 ;@@ -1339,7 +1339,7 @@ static bool __init parse_positional(struct ns16550 *uart, char **str) uart->irq =simple_strtol (conf, &conf,10 ); } -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( *conf ==',' && *++conf !=',' ) { conf = parse_pci(conf, NULL, &uart->ps_bdf[0],@@ -1419,7 +1419,7 @@ static bool __init parse_namevalue_pairs(char *str, struct ns16550 *uart) uart->reg_width =simple_strtoul (param_value,NULL ,0 );break ;
Quoted 7 lines
Quoted 7 lines
xen/drivers/char/ns16550.c +1
-1-#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI case bridge_bdf:if ( !parse_pci (param_value,NULL , &uart->ps_bdf[0 ], &uart->ps_bdf[1 ], &uart->ps_bdf[2 ]) )Signature · 1 line
2.17.1
Regards,
Rahul
Re: [PATCH v1 1/4] xen/ns16550: solve compilation error on ARM with CONFIG_HAS_PCI enabled.
In reply to Jan BeulichHello Jan,
Quoted 21 lines · Jan Beulich
Quoted 18 lines · Stefano Stabellini
xen/drivers/char/Kconfig config HAS_NS16550 · line 12
Quoted 12 lines · Rahul Singh
xen/drivers/char/Kconfig +6
-0@@ -4,6 +4,13 @@ config HAS_NS16550 help This selects the 16550-series UART support. For most systems, say Y. +config HAS_NS16550_PCI + bool "NS16550 UART PCI support" if X86 + default y + depends on X86 && HAS_NS16550 && HAS_PCI + help + This selects the 16550-series UART PCI support. For most systems, say Y.I think that this should be a silent option:
ifHAS_NS16550&&HAS_PCI&& X86 -> automatically enable otherwise -> automatically disable
Quoted 5 lines
Quoted 1 line
No need to show it to the user.
I agree in principle, but I don't see why an X86 dependency gets added here.
HAS_PCIreally should be all that's needed.
Yes you are right . I will remove the X86 and make HAS_NS16550_PCI depend on "HAS_NS16550 && HAS_PCI"
Quoted 1 line
Jan
Regards,
Rahul
Re: [PATCH v1 1/4] xen/ns16550: solve compilation error on ARM with CONFIG_HAS_PCI enabled.
Hi,
Quoted 21 lines · Rahul Singh
Quoted 21 lines · Jan Beulich
Quoted 18 lines · Stefano Stabellini
xen/drivers/char/Kconfig config HAS_NS16550 · line 12
Quoted 12 lines · Rahul Singh
xen/drivers/char/Kconfig +6
-0@@ -4,6 +4,13 @@ config HAS_NS16550 help This selects the 16550-series UART support. For most systems, say Y. +config HAS_NS16550_PCI + bool "NS16550 UART PCI support" if X86 + default y + depends on X86 && HAS_NS16550 && HAS_PCI + help + This selects the 16550-series UART PCI support. For most systems, say Y.I think that this should be a silent option:
ifHAS_NS16550&&HAS_PCI&& X86 -> automatically enable otherwise -> automatically disable
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
No need to show it to the user.
I agree in principle, but I don't see why an X86 dependency gets added here.
HAS_PCIreally should be all that's needed.Yes you are right . I will remove the X86 and make
HAS_NS16550_PCIdepend on "HAS_NS16550&&HAS_PCI"
There are quite a bit of work to make the PCI part of the implementation build on Arm because the code refer to x86 functions.
While in theory, an NS16550 PCI card could be used on Arm, there is only a slim chance for an actual users. So I am not convinced the effort is worth it here.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 3/4] xen/pci: Move x86 specific code to x86 directory.
In reply to Rahul SinghQuoted 2 lines · Rahul Singh
passthrough/pci.cfile is common for all architecture, but there is x86 sepcific code in this file.
The code you move doesn't look to be x86 specific in the sense that it makes no sense on other architectures, but just because certain pieces are missing on Arm. With this I question whether is it really appropriate to move this code. I do realize that in similar earlier cases my questioning was mostly ignored ...
Quoted 75 lines
xen/drivers/passthrough/x86/pci.c new file +72
-0@@ -0,0 +1,97 @@ +/* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <xen/param.h> +#include <xen/sched.h> +#include <xen/pci.h> +#include <xen/pci_regs.h> + +static int pci_clean_dpci_irq (struct domain *d, +struct hvm_pirq_dpci *pirq_dpci,void *arg) +{ +struct dev_intx_gsi_link *digl, *tmp; + +pirq_guest_unbind (d,dpci_pirq (pirq_dpci)); + +if (pt_irq_need_timer (pirq_dpci->flags) ) +kill_timer (&pirq_dpci->timer); + + list_for_each_entry_safe ( digl, tmp, &pirq_dpci->digl_list, list ) + { +list_del (&digl->list); +xfree (digl); + } + +radix_tree_delete (&d->pirq_tree,dpci_pirq (pirq_dpci)->pirq); + +if ( !pt_pirq_softirq_active (pirq_dpci) ) +return 0 ; + +domain_get_irq_dpci (d)->pending_pirq_dpci = pirq_dpci; + +return -ERESTART ; +} + +static int pci_clean_dpci_irqs (struct domain *d) +{ +struct hvm_irq_dpci *hvm_irq_dpci =NULL ; + +if ( !is_iommu_enabled (d) ) +return 0 ; + +if ( !is_hvm_domain (d) ) +return 0 ; + +spin_lock (&d->event_lock); + hvm_irq_dpci =domain_get_irq_dpci (d); +if ( hvm_irq_dpci !=NULL ) + { +int ret =0 ; + +if ( hvm_irq_dpci->pending_pirq_dpci ) + { +if (pt_pirq_softirq_active (hvm_irq_dpci->pending_pirq_dpci) ) + ret = -ERESTART ; +else + hvm_irq_dpci->pending_pirq_dpci =NULL ; + } + +if ( !ret ) + ret =pt_pirq_iterate (d, pci_clean_dpci_irq,NULL ); +if ( ret )
xen/drivers/passthrough/x86/pci.c line 82
Quoted 10 lines
xen/drivers/passthrough/x86/pci.c new file +10
-0+ { +spin_unlock (&d->event_lock); +return ret; + } + +hvm_domain_irq (d)->dpci =NULL ; +free_hvm_irq_dpci (hvm_irq_dpci); + } +spin_unlock (&d->event_lock); +return 0 ;
While moving please add the missing blank line before the main return statement of the function.
xen/drivers/passthrough/x86/pci.c line 88
Quoted 6 lines
xen/drivers/passthrough/x86/pci.c new file +6
-0+} + +int arch_pci_release_devices (struct domain *d) +{ +return pci_clean_dpci_irqs (d); +}
Why the extra function layer?
Jan
Re: [PATCH v1 4/4] xen/pci: solve compilation error when memory paging is not enabled.
In reply to Rahul SinghQuoted 6 lines · Rahul Singh
xen/drivers/passthrough/pci.c +0
-0@@ -1419,13 +1419,15 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)if ( !is_iommu_enabled (d) )return 0 ;
xen/drivers/passthrough/pci.c static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag) · line 1430
Quoted 10 lines
xen/drivers/passthrough/pci.c +3
-1-/* Prevent device assign if mem paging or mem sharing have been +#if defined(CONFIG_HAS_MEM_PAGING ) || defined(CONFIG_MEM_SHARING ) +/* Prevent device assign if mem paging or mem sharing have been * enabled for this domain */ if ( d != dom_io &&unlikely (mem_sharing_enabled (d) ||vm_event_check_ring (d->vm_event_paging) ||p2m_get_hostp2m (d)->global_logdirty) )return -EXDEV ; +#endif
Besides this also disabling mem-sharing and log-dirty related logic, I don't think the change is correct: Each item being checked needs individually disabling depending on its associated CONFIG_*. For this, perhaps you want to introduce something like mem_paging_enabled(d), to avoid the need for #ifdef here?
Jan
Re: [PATCH v1 3/4] xen/pci: Move x86 specific code to x86 directory.
In reply to Jan BeulichQuoted 9 lines · Jan Beulich
Quoted 2 lines · Rahul Singh
passthrough/pci.cfile is common for all architecture, but there is x86 sepcific code in this file.The code you move doesn't look to be x86 specific in the sense that it makes no sense on other architectures, but just because certain pieces are missing on Arm. With this I question whether is it really appropriate to move this code. I do realize that in similar earlier cases my questioning was mostly ignored ...
There are no plan to get support for PIRQ on Arm. All the interrupts will be properly sent to the guest using a virtual interrupt controller.
Regarding the code itself, there are still a few bits that are x86 specific (see struct dev_intx_gsi_link). So I think the right action for now is to move the code to an x86 directory.
This can be adjusted in the future if there is another architecture that would require to use PIRQ.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 4/4] xen/pci: solve compilation error when memory paging is not enabled.
In reply to Jan BeulichHello Jan,
Quoted 9 lines · Jan Beulich
Quoted 6 lines · Rahul Singh
xen/drivers/passthrough/pci.c +0
-0@@ -1419,13 +1419,15 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)if ( !is_iommu_enabled (d) )return 0 ;
Quoted 17 lines
xen/drivers/passthrough/pci.c static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag) · line 1430
Quoted 10 lines
xen/drivers/passthrough/pci.c +3
-1-/* Prevent device assign if mem paging or mem sharing have been +#if defined(CONFIG_HAS_MEM_PAGING ) || defined(CONFIG_MEM_SHARING ) +/* Prevent device assign if mem paging or mem sharing have been * enabled for this domain */ if ( d != dom_io &&unlikely (mem_sharing_enabled (d) ||vm_event_check_ring (d->vm_event_paging) ||p2m_get_hostp2m (d)->global_logdirty) )return -EXDEV ; +#endif Besides this also disabling mem-sharing and log-dirty related logic, I don't think the change is correct: Each item being checked needs individually disabling depending on its associated CONFIG_*. For this, perhaps you want to introduce something like
mem_paging_enabled(d), to avoid the need for #ifdef here?
Ok I will fix that in next version.
Quoted 1 line
Jan
Regards,
Rahul
Re: [PATCH v1 3/4] xen/pci: Move x86 specific code to x86 directory.
In reply to Jan BeulichHello Jan,
Quoted 92 lines · Jan Beulich
Quoted 2 lines · Rahul Singh
passthrough/pci.cfile is common for all architecture, but there is x86 sepcific code in this file.The code you move doesn't look to be x86 specific in the sense that it makes no sense on other architectures, but just because certain pieces are missing on Arm. With this I question whether is it really appropriate to move this code. I do realize that in similar earlier cases my questioning was mostly ignored ...
Quoted 80 lines
xen/drivers/passthrough/x86/pci.c new file +77
-0@@ -0,0 +1,97 @@ +/* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <xen/param.h> +#include <xen/sched.h> +#include <xen/pci.h> +#include <xen/pci_regs.h> + +static int pci_clean_dpci_irq (struct domain *d, +struct hvm_pirq_dpci *pirq_dpci,void *arg) +{ +struct dev_intx_gsi_link *digl, *tmp; + +pirq_guest_unbind (d,dpci_pirq (pirq_dpci)); + +if (pt_irq_need_timer (pirq_dpci->flags) ) +kill_timer (&pirq_dpci->timer); + + list_for_each_entry_safe ( digl, tmp, &pirq_dpci->digl_list, list ) + { +list_del (&digl->list); +xfree (digl); + } + +radix_tree_delete (&d->pirq_tree,dpci_pirq (pirq_dpci)->pirq); + +if ( !pt_pirq_softirq_active (pirq_dpci) ) +return 0 ; + +domain_get_irq_dpci (d)->pending_pirq_dpci = pirq_dpci; + +return -ERESTART ; +} + +static int pci_clean_dpci_irqs (struct domain *d) +{ +struct hvm_irq_dpci *hvm_irq_dpci =NULL ; + +if ( !is_iommu_enabled (d) ) +return 0 ; + +if ( !is_hvm_domain (d) ) +return 0 ; + +spin_lock (&d->event_lock); + hvm_irq_dpci =domain_get_irq_dpci (d); +if ( hvm_irq_dpci !=NULL ) + { +int ret =0 ; + +if ( hvm_irq_dpci->pending_pirq_dpci ) + { +if (pt_pirq_softirq_active (hvm_irq_dpci->pending_pirq_dpci) ) + ret = -ERESTART ; +else + hvm_irq_dpci->pending_pirq_dpci =NULL ; + } + +if ( !ret ) + ret =pt_pirq_iterate (d, pci_clean_dpci_irq,NULL ); +if ( ret ) + { +spin_unlock (&d->event_lock); +return ret; + } +
Quoted 8 lines
xen/drivers/passthrough/x86/pci.c line 82
Quoted 5 lines
xen/drivers/passthrough/x86/pci.c new file +5
-0+hvm_domain_irq (d)->dpci =NULL ; +free_hvm_irq_dpci (hvm_irq_dpci); + } +spin_unlock (&d->event_lock); +return 0 ;While moving please add the missing blank line before the main return statement of the function.
Ok I will fix that in next version.
Quoted 9 lines
xen/drivers/passthrough/x86/pci.c line 88
Quoted 7 lines
xen/drivers/passthrough/x86/pci.c new file +6
-0+} + +int arch_pci_release_devices (struct domain *d) +{ +return pci_clean_dpci_irqs (d); +}Why the extra function layer?
Is that ok if I rename the function pci_clean_dpci_irqs() to arch_pci_clean_pirqs() ?
Quoted 3 lines
Jan
Regards,
Rahul
Re: [PATCH v1 3/4] xen/pci: Move x86 specific code to x86 directory.
Quoted 10 lines · Rahul Singh
Quoted 8 lines · Jan Beulich
xen/drivers/passthrough/x86/pci.c line 88
Quoted 4 lines · Rahul Singh
xen/drivers/passthrough/x86/pci.c new file +4
-0+int arch_pci_release_devices (struct domain *d) +{ +return pci_clean_dpci_irqs (d); +}Why the extra function layer?
Is that ok if I rename the function
pci_clean_dpci_irqs()toarch_pci_clean_pirqs()?
I see no problem with you doing so.
Jan
Re: [PATCH v1 1/4] xen/ns16550: solve compilation error on ARM with CONFIG_HAS_PCI enabled.
In reply to Julien GrallHello Julen,
Quoted 31 lines · Julien Grall
Hi,
Quoted 26 lines · Rahul Singh
Quoted 26 lines · Jan Beulich
Quoted 18 lines · Stefano Stabellini
xen/drivers/char/Kconfig config HAS_NS16550 · line 12
Quoted 12 lines · Rahul Singh
xen/drivers/char/Kconfig +6
-0@@ -4,6 +4,13 @@ config HAS_NS16550 help This selects the 16550-series UART support. For most systems, say Y. +config HAS_NS16550_PCI + bool "NS16550 UART PCI support" if X86 + default y + depends on X86 && HAS_NS16550 && HAS_PCI + help + This selects the 16550-series UART PCI support. For most systems, say Y.I think that this should be a silent option:
ifHAS_NS16550&&HAS_PCI&& X86 -> automatically enable otherwise -> automatically disableQuoted 1 line
No need to show it to the user.
I agree in principle, but I don't see why an X86 dependency gets added here.
HAS_PCIreally should be all that's needed.
Quoted 7 lines
Quoted 1 line
Yes you are right . I will remove the X86 and make
HAS_NS16550_PCIdepend on "HAS_NS16550&&HAS_PCI"There are quite a bit of work to make the PCI part of the implementation build on Arm because the code refer to x86 functions.
While in theory, an NS16550 PCI card could be used on Arm, there is only a slim chance for an actual users. So I am not convinced the effort is worth it here.
Cheers,
Ok. I will enable by default HAS_NS16550_PCI on X86 only. Once we have proper support for NS16550 PCI on ARM we can enable it at that time. I will modify as follows:
config HAS_NS16550_PCI
bool
default y
depends on X86 && HAS_NS16550 && HAS_PCI
help
This selects the 16550-series UART PCI support. For most systems, say Y.
Quoted 3 lines
Signature · 2 lines
-- Julien Grall
Thanks,
Rahul
Re: [PATCH v1 1/4] xen/ns16550: solve compilation error on ARM with CONFIG_HAS_PCI enabled.
Quoted 6 lines · Rahul Singh
Ok. I will enable by default
HAS_NS16550_PCIon X86 only. Once we have proper support for NS16550 PCI on ARM we can enable it at that time. I will modify as follows:config
HAS_NS16550_PCI
bool
default y
def_bool y
Jan
Re: [PATCH v1 4/4] xen/pci: solve compilation error when memory paging is not enabled.
In reply to Rahul SinghHello Jan,
Quoted 31 lines · Rahul Singh
Hello Jan,
Quoted 9 lines · Jan Beulich
Quoted 6 lines · Rahul Singh
xen/drivers/passthrough/pci.c +0
-0@@ -1419,13 +1419,15 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)if ( !is_iommu_enabled (d) )return 0 ;Quoted 17 lines
xen/drivers/passthrough/pci.c static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag) · line 1430
Quoted 10 lines
xen/drivers/passthrough/pci.c +3
-1-/* Prevent device assign if mem paging or mem sharing have been +#if defined(CONFIG_HAS_MEM_PAGING ) || defined(CONFIG_MEM_SHARING ) +/* Prevent device assign if mem paging or mem sharing have been * enabled for this domain */ if ( d != dom_io &&unlikely (mem_sharing_enabled (d) ||vm_event_check_ring (d->vm_event_paging) ||p2m_get_hostp2m (d)->global_logdirty) )return -EXDEV ; +#endif Besides this also disabling mem-sharing and log-dirty related logic, I don't think the change is correct: Each item being checked needs individually disabling depending on its associated CONFIG_*. For this, perhaps you want to introduce something like
mem_paging_enabled(d), to avoid the need for #ifdef here?
Quoted 1 line
Ok I will fix that in next version.
I just check and found out that mem-sharing , men-paging and log-dirty is x86 specific and not implemented for ARM.
Is that will be ok if I move above code to x86 specific directory and introduce new function arch_pcidev_is_assignable() that will test if pcidev is assignable or not ?
Quoted 2 lines
Quoted 2 lines
Jan
Regards,
Rahul
Re: [PATCH v1 4/4] xen/pci: solve compilation error when memory paging is not enabled.
Quoted 27 lines · Rahul Singh
Quoted 27 lines · Rahul Singh
Quoted 25 lines · Jan Beulich
Quoted 6 lines · Rahul Singh
xen/drivers/passthrough/pci.c +0
-0@@ -1419,13 +1419,15 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)if ( !is_iommu_enabled (d) )return 0 ;xen/drivers/passthrough/pci.c static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag) · line 1430
Quoted 10 lines
xen/drivers/passthrough/pci.c +3
-1-/* Prevent device assign if mem paging or mem sharing have been +#if defined(CONFIG_HAS_MEM_PAGING ) || defined(CONFIG_MEM_SHARING ) +/* Prevent device assign if mem paging or mem sharing have been * enabled for this domain */ if ( d != dom_io &&unlikely (mem_sharing_enabled (d) ||vm_event_check_ring (d->vm_event_paging) ||p2m_get_hostp2m (d)->global_logdirty) )return -EXDEV ; +#endif Besides this also disabling mem-sharing and log-dirty related logic, I don't think the change is correct: Each item being checked needs individually disabling depending on its associated CONFIG_*. For this, perhaps you want to introduce something like
mem_paging_enabled(d), to avoid the need for #ifdef here?
Quoted 4 lines
Quoted 1 line
Ok I will fix that in next version.
I just check and found out that mem-sharing , men-paging and log-dirty is x86 specific and not implemented for ARM.
Is that will be ok if I move above code to x86 specific directory and introduce new functionarch_pcidev_is_assignable()that will test if pcidev is assignable or not ?
As an immediate workaround - perhaps (long term the individual pieces should still be individually checked here, as they're not inherently x86-specific). Since there's no device property involved here, the suggested name looks misleading. Perhaps arch_iommu_usable(d)?
Jan
Re: [PATCH v1 4/4] xen/pci: solve compilation error when memory paging is not enabled.
Hello Jan,
Quoted 32 lines · Jan Beulich
Quoted 29 lines · Rahul Singh
Quoted 28 lines · Rahul Singh
Quoted 8 lines · Jan Beulich
Quoted 6 lines · Rahul Singh
xen/drivers/passthrough/pci.c +0
-0@@ -1419,13 +1419,15 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)if ( !is_iommu_enabled (d) )return 0 ;Quoted 17 lines
xen/drivers/passthrough/pci.c static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag) · line 1430
Quoted 10 lines
xen/drivers/passthrough/pci.c +3
-1-/* Prevent device assign if mem paging or mem sharing have been +#if defined(CONFIG_HAS_MEM_PAGING ) || defined(CONFIG_MEM_SHARING ) +/* Prevent device assign if mem paging or mem sharing have been * enabled for this domain */ if ( d != dom_io &&unlikely (mem_sharing_enabled (d) ||vm_event_check_ring (d->vm_event_paging) ||p2m_get_hostp2m (d)->global_logdirty) )return -EXDEV ; +#endif Besides this also disabling mem-sharing and log-dirty related logic, I don't think the change is correct: Each item being checked needs individually disabling depending on its associated CONFIG_*. For this, perhaps you want to introduce something like
mem_paging_enabled(d), to avoid the need for #ifdef here?Ok I will fix that in next version.
Quoted 8 lines
Quoted 2 lines
I just check and found out that mem-sharing , men-paging and log-dirty is x86 specific and not implemented for ARM.
Is that will be ok if I move above code to x86 specific directory and introduce new functionarch_pcidev_is_assignable()that will test if pcidev is assignable or not ?As an immediate workaround - perhaps (long term the individual pieces should still be individually checked here, as they're not inherently x86-specific). Since there's no device property involved here, the suggested name looks misleading. Perhaps
arch_iommu_usable(d)?
Thanks. I will modify the code as per suggestion and will share the version v2 for review.
Quoted 2 lines
Jan
Regards,
Rahul