From nobody Fri Apr 19 23:04:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1605529569; cv=none; d=zohomail.com; s=zohoarc; b=a3hl++DRFXAnDv/+Lnxc38hdl2eEC/72ts1rH0QbkG2mFJ8b+rwNU63/q4V3DLf2qyE/cm//VxIPCGL9fhEyiW0lCOkWfp9zX+cSeMdIdfrRNVHLRreZt6FpxZby8DsFc1gh6RZTdoUIoYku6wiy/0wbOwSYNbNTLHYhSnEah/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605529569; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=0H8wfrnvTqFQqPMQME8tO+W3NEwbTUvBHFwPM8WFe0I=; b=BGKrNVVoI2fVudlul98NB8ntfaUNMMHmwr2N7ChL7d4cdYtmuL8q6uJccbncGTsr8AHfhydOIFciYtFhqoKVDt/ds2WOiyI8C8UGaaQOkPRpiHu7kdaLJy+uyICprqApe6gnM2ZO4BcAojtC2jYhMlvCxHjVBakvbh0sFkRabxU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1605529569556964.21999391496; Mon, 16 Nov 2020 04:26:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.27883.56482 (Exim 4.92) (envelope-from ) id 1kedZy-0001f3-KK; Mon, 16 Nov 2020 12:25:54 +0000 Received: by outflank-mailman (output) from mailman id 27883.56482; Mon, 16 Nov 2020 12:25:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kedZy-0001ew-H2; Mon, 16 Nov 2020 12:25:54 +0000 Received: by outflank-mailman (input) for mailman id 27883; Mon, 16 Nov 2020 12:25:53 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kedZx-0001eS-8T for xen-devel@lists.xenproject.org; Mon, 16 Nov 2020 12:25:53 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 58ed8055-d374-449b-baad-1c717da4b7ff; Mon, 16 Nov 2020 12:25:52 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C2079101E; Mon, 16 Nov 2020 04:25:51 -0800 (PST) Received: from scm-wfh-server-rahsin01.stack04.eu02.mi.arm.com (unknown [10.58.246.76]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8F5063F70D; Mon, 16 Nov 2020 04:25:50 -0800 (PST) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kedZx-0001eS-8T for xen-devel@lists.xenproject.org; Mon, 16 Nov 2020 12:25:53 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 58ed8055-d374-449b-baad-1c717da4b7ff; Mon, 16 Nov 2020 12:25:52 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C2079101E; Mon, 16 Nov 2020 04:25:51 -0800 (PST) Received: from scm-wfh-server-rahsin01.stack04.eu02.mi.arm.com (unknown [10.58.246.76]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8F5063F70D; Mon, 16 Nov 2020 04:25:50 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 58ed8055-d374-449b-baad-1c717da4b7ff From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v3 1/3] xen/ns16550: Make ns16550 driver usable on ARM with HAS_PCI enabled. Date: Mon, 16 Nov 2020 12:25:16 +0000 Message-Id: <955996aa8cd7f17f9f39c60bd3b9b74ffaa5c5f7.1605527997.git.rahul.singh@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" NS16550 driver has PCI support that is under HAS_PCI flag. When HAS_PCI is enabled for ARM, compilation error is observed for ARM architecture because ARM platforms do not have full PCI support available. Introducing new kconfig option CONFIG_HAS_NS16550_PCI to support ns16550 PCI for X86. For X86 platforms it is enabled by default. For ARM platforms it is disabled by default, once we have proper support for NS16550 PCI for ARM we can enable it. No functional change. Signed-off-by: Rahul Singh Reviewed-by: Stefano Stabellini --- Changes in v3: - remove help text from the Kconfig file because of prompt-less option. --- xen/drivers/char/Kconfig | 4 ++++ xen/drivers/char/ns16550.c | 32 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig index b572305657..abb59fdb0f 100644 --- a/xen/drivers/char/Kconfig +++ b/xen/drivers/char/Kconfig @@ -4,6 +4,10 @@ config HAS_NS16550 help This selects the 16550-series UART support. For most systems, say Y. =20 +config HAS_NS16550_PCI + def_bool y + depends on X86 && HAS_NS16550 && HAS_PCI + config HAS_CADENCE_UART bool "Xilinx Cadence UART driver" default y diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index d8b52eb813..bd1c2af956 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -16,7 +16,7 @@ #include #include #include -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI #include #include #include @@ -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 =3D1, pb-bdf effective, port behind brid= ge */ bool_t ps_bdf_enable; /* if =3D1, ps_bdf effective, port on pci card= */ @@ -117,14 +117,14 @@ static const struct serial_param_var __initconst sp_v= ars[] =3D { {"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 }; =20 -#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) =20 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 >=3D 0x10000 ) return; =20 @@ -719,7 +719,7 @@ static void __init ns16550_init_preirq(struct serial_po= rt *port) =20 static void __init ns16550_init_irq(struct serial_port *port) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI struct ns16550 *uart =3D port->uart; =20 if ( uart->msi ) @@ -761,7 +761,7 @@ static void __init ns16550_init_postirq(struct serial_p= ort *port) uart->timeout_ms =3D max_t( unsigned int, 1, (bits * uart->fifo_size * 1000) / uart->baud); =20 -#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) =20 stop_timer(&uart->timer); =20 -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( uart->bar ) uart->cr =3D 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) =20 static void _ns16550_resume(struct serial_port *port) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI struct ns16550 *uart =3D port->uart; =20 if ( uart->bar ) @@ -1013,7 +1013,7 @@ static int __init check_existence(struct ns16550 *uar= t) return 1; /* Everything is MMIO */ #endif =20 -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI pci_serial_early_init(uart); #endif =20 @@ -1044,7 +1044,7 @@ static int __init check_existence(struct ns16550 *uar= t) return (status =3D=3D 0x90); } =20 -#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 *u= art, char **str) =20 if ( *conf =3D=3D ',' && *++conf !=3D ',' ) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( strncmp(conf, "pci", 3) =3D=3D 0 ) { if ( pci_uart_config(uart, 1/* skip AMT */, uart - ns16550_com= ) ) @@ -1327,7 +1327,7 @@ static bool __init parse_positional(struct ns16550 *u= art, char **str) =20 if ( *conf =3D=3D ',' && *++conf !=3D ',' ) { -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( strncmp(conf, "msi", 3) =3D=3D 0 ) { conf +=3D 3; @@ -1339,7 +1339,7 @@ static bool __init parse_positional(struct ns16550 *u= art, char **str) uart->irq =3D simple_strtol(conf, &conf, 10); } =20 -#ifdef CONFIG_HAS_PCI +#ifdef CONFIG_HAS_NS16550_PCI if ( *conf =3D=3D ',' && *++conf !=3D ',' ) { conf =3D parse_pci(conf, NULL, &uart->ps_bdf[0], @@ -1419,7 +1419,7 @@ static bool __init parse_namevalue_pairs(char *str, s= truct ns16550 *uart) uart->reg_width =3D simple_strtoul(param_value, NULL, 0); break; =20 -#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]) ) --=20 2.17.1 From nobody Fri Apr 19 23:04:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1605529576; cv=none; d=zohomail.com; s=zohoarc; b=FF8Z+wTFTyDPgnz/eXXjlC3wxwSqjBxX5Ly6oqEZfpI/oSt9XB/Z20bcwQuh7gbWNaWRxy4zmIyfx643yTRQHeQhbeEGZwTg3jNx8MybNzvqVnw7jQAKu/JXVAmWrurhTZVcc6CNzkQr6HdYGoUEdcXBtUMufWTpPbMeqQkTQIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605529576; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=qa48SMAIcgFco3DfM3V1Zluqb6zy8Cv9Mh5frxow+jQ=; b=TxU8Ad9k/EgXwzgYWX8PUcviRRvatAbdMKoSB2gIfbEyFIMc1YbTaj4zgUdQLbe9HNLdgxRuSLm6OEGFkCBIDH4QWB1nK2CRhf7XPXDWqEhewdCmGUoORnmR9c+knPz3HvS2UJNz9jCT247yfuwoFrggCOjP46PTAI66AY+w9as= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1605529576092964.4940989640625; Mon, 16 Nov 2020 04:26:16 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.27884.56494 (Exim 4.92) (envelope-from ) id 1keda2-0001iV-Uf; Mon, 16 Nov 2020 12:25:58 +0000 Received: by outflank-mailman (output) from mailman id 27884.56494; Mon, 16 Nov 2020 12:25:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1keda2-0001iO-Qv; Mon, 16 Nov 2020 12:25:58 +0000 Received: by outflank-mailman (input) for mailman id 27884; Mon, 16 Nov 2020 12:25:58 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1keda2-0001eS-74 for xen-devel@lists.xenproject.org; Mon, 16 Nov 2020 12:25:58 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 609224b9-9d12-4d98-9da4-f09cc646477a; Mon, 16 Nov 2020 12:25:55 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 088DA101E; Mon, 16 Nov 2020 04:25:55 -0800 (PST) Received: from scm-wfh-server-rahsin01.stack04.eu02.mi.arm.com (unknown [10.58.246.76]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8C23D3F70D; Mon, 16 Nov 2020 04:25:53 -0800 (PST) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1keda2-0001eS-74 for xen-devel@lists.xenproject.org; Mon, 16 Nov 2020 12:25:58 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 609224b9-9d12-4d98-9da4-f09cc646477a; Mon, 16 Nov 2020 12:25:55 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 088DA101E; Mon, 16 Nov 2020 04:25:55 -0800 (PST) Received: from scm-wfh-server-rahsin01.stack04.eu02.mi.arm.com (unknown [10.58.246.76]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8C23D3F70D; Mon, 16 Nov 2020 04:25:53 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 609224b9-9d12-4d98-9da4-f09cc646477a From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, Jan Beulich , Paul Durrant , Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v3 2/3] xen/pci: Move x86 specific code to x86 directory. Date: Mon, 16 Nov 2020 12:25:17 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" passthrough/pci.c file is common for all architecture, but there is x86 specific code in this file. Move x86 specific code to the drivers/passthrough/io.c file to avoid compilation error for other architecture. As drivers/passthrough/io.c is compiled only for x86 move it to x86 directory and rename it to hvm.c. No functional change. Signed-off-by: Rahul Singh --- Changes in v3: - fixed typo - As per suggestion move the code to the file io.c and move that file to x86 directory and rename it hvm.c --- xen/drivers/passthrough/Makefile | 3 - xen/drivers/passthrough/pci.c | 78 +-------------------- xen/drivers/passthrough/x86/Makefile | 1 + xen/drivers/passthrough/{io.c =3D> x86/hvm.c} | 66 +++++++++++++++++ xen/drivers/passthrough/x86/iommu.c | 7 ++ xen/include/xen/pci.h | 2 + 6 files changed, 77 insertions(+), 80 deletions(-) rename xen/drivers/passthrough/{io.c =3D> x86/hvm.c} (95%) diff --git a/xen/drivers/passthrough/Makefile b/xen/drivers/passthrough/Mak= efile index e973e16c74..cc646612c7 100644 --- a/xen/drivers/passthrough/Makefile +++ b/xen/drivers/passthrough/Makefile @@ -6,6 +6,3 @@ obj-$(CONFIG_ARM) +=3D arm/ obj-y +=3D iommu.o obj-$(CONFIG_HAS_PCI) +=3D pci.o obj-$(CONFIG_HAS_DEVICE_TREE) +=3D device_tree.o - -x86-$(CONFIG_HVM) :=3D io.o -obj-$(CONFIG_X86) +=3D $(x86-y) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 51e584127e..e8a28df126 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -14,9 +14,6 @@ * this program; If not, see . */ =20 -#include -#include -#include #include #include #include @@ -24,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -842,71 +838,6 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn) return ret; } =20 -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 =3D pirq_dpci; - - return -ERESTART; -} - -static int pci_clean_dpci_irqs(struct domain *d) -{ - struct hvm_irq_dpci *hvm_irq_dpci =3D NULL; - - if ( !is_iommu_enabled(d) ) - return 0; - - if ( !is_hvm_domain(d) ) - return 0; - - spin_lock(&d->event_lock); - hvm_irq_dpci =3D domain_get_irq_dpci(d); - if ( hvm_irq_dpci !=3D NULL ) - { - int ret =3D 0; - - if ( hvm_irq_dpci->pending_pirq_dpci ) - { - if ( pt_pirq_softirq_active(hvm_irq_dpci->pending_pirq_dpci) ) - ret =3D -ERESTART; - else - hvm_irq_dpci->pending_pirq_dpci =3D NULL; - } - - if ( !ret ) - ret =3D pt_pirq_iterate(d, pci_clean_dpci_irq, NULL); - if ( ret ) - { - spin_unlock(&d->event_lock); - return ret; - } - - hvm_domain_irq(d)->dpci =3D 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) @@ -966,7 +897,7 @@ int pci_release_devices(struct domain *d) int ret; =20 pcidevs_lock(); - ret =3D pci_clean_dpci_irqs(d); + ret =3D arch_pci_clean_pirqs(d); if ( ret ) { pcidevs_unlock(); @@ -1370,13 +1301,6 @@ static int __init setup_dump_pcidevs(void) } __initcall(setup_dump_pcidevs); =20 -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; diff --git a/xen/drivers/passthrough/x86/Makefile b/xen/drivers/passthrough= /x86/Makefile index a70cf9460d..69284a5d19 100644 --- a/xen/drivers/passthrough/x86/Makefile +++ b/xen/drivers/passthrough/x86/Makefile @@ -1,2 +1,3 @@ obj-y +=3D ats.o obj-y +=3D iommu.o +obj-$(CONFIG_HVM) +=3D hvm.o diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/x86/hvm= .c similarity index 95% rename from xen/drivers/passthrough/io.c rename to xen/drivers/passthrough/x86/hvm.c index 6b1305a3e5..41cfa2e200 100644 --- a/xen/drivers/passthrough/io.c +++ b/xen/drivers/passthrough/x86/hvm.c @@ -1036,6 +1036,72 @@ unlock: spin_unlock(&d->event_lock); } =20 +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 =3D pirq_dpci; + + return -ERESTART; +} + +int arch_pci_clean_pirqs(struct domain *d) +{ + struct hvm_irq_dpci *hvm_irq_dpci =3D NULL; + + if ( !is_iommu_enabled(d) ) + return 0; + + if ( !is_hvm_domain(d) ) + return 0; + + spin_lock(&d->event_lock); + hvm_irq_dpci =3D domain_get_irq_dpci(d); + if ( hvm_irq_dpci !=3D NULL ) + { + int ret =3D 0; + + if ( hvm_irq_dpci->pending_pirq_dpci ) + { + if ( pt_pirq_softirq_active(hvm_irq_dpci->pending_pirq_dpci) ) + ret =3D -ERESTART; + else + hvm_irq_dpci->pending_pirq_dpci =3D NULL; + } + + if ( !ret ) + ret =3D pt_pirq_iterate(d, pci_clean_dpci_irq, NULL); + if ( ret ) + { + spin_unlock(&d->event_lock); + return ret; + } + + hvm_domain_irq(d)->dpci =3D NULL; + free_hvm_irq_dpci(hvm_irq_dpci); + } + spin_unlock(&d->event_lock); + + return 0; +} + /* * Note: 'pt_pirq_softirq_reset' can clear the STATE_SCHED before we get to * doing it. If that is the case we let 'pt_pirq_softirq_reset' do ref-cou= nting. diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/= x86/iommu.c index f17b1820f4..875e67b53b 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -308,6 +308,13 @@ struct page_info *iommu_alloc_pgtable(struct domain *d) return pg; } =20 +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 diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h index 20a54a5bb4..78d83afe64 100644 --- a/xen/include/xen/pci.h +++ b/xen/include/xen/pci.h @@ -208,4 +208,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); =20 +int arch_pci_clean_pirqs(struct domain *d); + #endif /* __XEN_PCI_H__ */ --=20 2.17.1 From nobody Fri Apr 19 23:04:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1605529579; cv=none; d=zohomail.com; s=zohoarc; b=Y7a0WeswfRMgDIyMrLhEh3eNq7byZL6LCH9J3shHGLmt3cZanv5YT2sGvw2KjN0wQShgcnd4+jQQre1qfGZnHVgEfF+eP+g4rPsQQwbq4SIdOuJ/VQOqh053lADpT4UDVG5O3VeDwMBqanZQRpNkMocKJbxUx6CAS3GXaH4Y8bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605529579; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=g0O5OIOfiorbhjvZpiaYRWP7dVEEDlPwjDfEcCb3n6U=; b=lwqHb5T8AgKIHug4OnpfYS1ZCXGw4vCp6bsYH5v1CXv3nRiwUfLH6RmEPIe5Xu8EQNQGGO2o/F7wqeYc2WkkQ9erRpiBWugN20Gs5OtaRyHzRqV4A+X3R8NcdbsGYzvy3o79mSqJVjqOvEUgbdSUL1U+ZQ0qHv+ug+VnBeBkI/Q= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1605529579442360.47487106183166; Mon, 16 Nov 2020 04:26:19 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.27885.56506 (Exim 4.92) (envelope-from ) id 1keda9-0001od-AE; Mon, 16 Nov 2020 12:26:05 +0000 Received: by outflank-mailman (output) from mailman id 27885.56506; Mon, 16 Nov 2020 12:26:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1keda9-0001oS-6S; Mon, 16 Nov 2020 12:26:05 +0000 Received: by outflank-mailman (input) for mailman id 27885; Mon, 16 Nov 2020 12:26:04 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1keda7-0001ni-UL for xen-devel@lists.xenproject.org; Mon, 16 Nov 2020 12:26:03 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 16d0ef04-b0e7-4ebb-bc97-b44bf1880adf; Mon, 16 Nov 2020 12:26:02 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 14DF0101E; Mon, 16 Nov 2020 04:26:02 -0800 (PST) Received: from scm-wfh-server-rahsin01.stack04.eu02.mi.arm.com (unknown [10.58.246.76]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 668DC3F70D; Mon, 16 Nov 2020 04:26:01 -0800 (PST) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1keda7-0001ni-UL for xen-devel@lists.xenproject.org; Mon, 16 Nov 2020 12:26:03 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 16d0ef04-b0e7-4ebb-bc97-b44bf1880adf; Mon, 16 Nov 2020 12:26:02 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 14DF0101E; Mon, 16 Nov 2020 04:26:02 -0800 (PST) Received: from scm-wfh-server-rahsin01.stack04.eu02.mi.arm.com (unknown [10.58.246.76]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 668DC3F70D; Mon, 16 Nov 2020 04:26:01 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 16d0ef04-b0e7-4ebb-bc97-b44bf1880adf From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, Jan Beulich , Paul Durrant Subject: [PATCH v3 3/3] xen/pci: solve compilation error on ARM with HAS_PCI enabled. Date: Mon, 16 Nov 2020 12:25:18 +0000 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If mem-sharing, mem-paging, or log-dirty functionality is not enabled for non-x86 architecture when HAS_PCI is enabled, the compiler will throw an error. Move code to x86 specific directory to fix compilation error. Also, modify the code to use likely() in place of unlikley() for each condition to make code more optimized. No functional change. Signed-off-by: Rahul Singh --- Changes in v3: - rename arch_iommu_usable() to arch_iommu_use_permitted() - fixed comments. --- xen/drivers/passthrough/pci.c | 8 +------- xen/drivers/passthrough/x86/iommu.c | 12 ++++++++++++ xen/include/xen/iommu.h | 2 ++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index e8a28df126..804b24a0e0 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -1411,12 +1410,7 @@ static int assign_device(struct domain *d, u16 seg, = u8 bus, u8 devfn, u32 flag) if ( !is_iommu_enabled(d) ) return 0; =20 - /* Prevent device assign if mem paging or mem sharing have been=20 - * enabled for this domain */ - if ( d !=3D dom_io && - unlikely(mem_sharing_enabled(d) || - vm_event_check_ring(d->vm_event_paging) || - p2m_get_hostp2m(d)->global_logdirty) ) + if( !arch_iommu_use_permitted(d) ) return -EXDEV; =20 /* device_assigned() should already have cleared the device for assign= ment */ diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/= x86/iommu.c index 875e67b53b..26f57b7e88 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -23,6 +23,7 @@ #include #include #include +#include =20 const struct iommu_init_ops *__initdata iommu_init_ops; struct iommu_ops __read_mostly iommu_ops; @@ -315,6 +316,17 @@ int iommu_update_ire_from_msi( ? iommu_call(&iommu_ops, update_ire_from_msi, msi_desc, msg) : = 0; } =20 +bool arch_iommu_use_permitted(const struct domain *d) +{ + /* + * Prevent device assign if mem paging, mem sharing or log-dirty + * have been enabled for this domain. + */ + return d =3D=3D dom_io || + (likely(!mem_sharing_enabled(d)) && + likely(!vm_event_check_ring(d->vm_event_paging)) && + likely(!p2m_get_hostp2m(d)->global_logdirty)); +} /* * Local variables: * mode: C diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 191021870f..056eaa09fc 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -381,6 +381,8 @@ DECLARE_PER_CPU(bool_t, iommu_dont_flush_iotlb); extern struct spinlock iommu_pt_cleanup_lock; extern struct page_list_head iommu_pt_cleanup_list; =20 +bool arch_iommu_use_permitted(const struct domain *d); + #endif /* _IOMMU_H_ */ =20 /* --=20 2.17.1