From nobody Fri May 3 13:41:26 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=1604419234; cv=none; d=zohomail.com; s=zohoarc; b=YnVNVqAGDxTBIWTFxC7qINqhYDp1vq8gPrCoOua2rZSHQHv0LZ34xd+7yxgJqsEPqCIL8X+p8a9K9I6JPJ/Y464tCQ3fKCC0C079jZire+ol7I6wNUI77+ErX/1ATXEC+VbF9E+8o8w9XOAbvgjS4VwgmvHeO0Pz6A4pU1NjRE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604419234; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=LnjVmfNJio/odAwuXIk9CBNNN6nrjIVTNnMH74rtBgw=; b=B5AJkw0ssapHK2eBorqsbdeeh3PxwLaejpqeT5DgpD5omNG0rxFPFSbHbtQwhNv4YHa1RYwq9A4wwKerwJYVzwSpVPXDGcy51SwYN8uB7qO6RXrc7/Sv3Jm3VG3/XNhHZQLjWUXLiUNAhBGGEvFi45fZxAldhr3du5/olx87qVc= 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 1604419233961819.5012739969733; Tue, 3 Nov 2020 08:00:33 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.18394.43416 (Exim 4.92) (envelope-from ) id 1kZyjF-0008I3-SJ; Tue, 03 Nov 2020 16:00:13 +0000 Received: by outflank-mailman (output) from mailman id 18394.43416; Tue, 03 Nov 2020 16:00:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kZyjF-0008Hv-On; Tue, 03 Nov 2020 16:00:13 +0000 Received: by outflank-mailman (input) for mailman id 18394; Tue, 03 Nov 2020 16:00:13 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kZyjF-0008Hp-9D for xen-devel@lists.xenproject.org; Tue, 03 Nov 2020 16:00:13 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 507e93cd-939e-458d-936c-960503b38e8e; Tue, 03 Nov 2020 16:00:11 +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 644061424; Tue, 3 Nov 2020 08:00:06 -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 2CB253F66E; Tue, 3 Nov 2020 08:00:05 -0800 (PST) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kZyjF-0008Hp-9D for xen-devel@lists.xenproject.org; Tue, 03 Nov 2020 16:00:13 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 507e93cd-939e-458d-936c-960503b38e8e; Tue, 03 Nov 2020 16:00:11 +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 644061424; Tue, 3 Nov 2020 08:00:06 -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 2CB253F66E; Tue, 3 Nov 2020 08:00:05 -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: 507e93cd-939e-458d-936c-960503b38e8e 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 v2 1/4] xen/ns16550: solve compilation error on ARM with CONFIG_HAS_PCI enabled. Date: Tue, 3 Nov 2020 15:59:12 +0000 Message-Id: <2aa79510731918d78d515a1679cc141fcf16883e.1604417224.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" ARM platforms do not have PCI support available. When CONFIG_HAS_PCI is enabled for ARM a compilation error is observed for ns16550 driver. Fixed compilation error after 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: Bertrand Marquis --- Changes in v2: - Silently enable the HAS_NS16550_PCI for x86 by default.=20 --- xen/drivers/char/Kconfig | 7 +++++++ xen/drivers/char/ns16550.c | 32 ++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/xen/drivers/char/Kconfig b/xen/drivers/char/Kconfig index b572305657..12a53607d1 100644 --- a/xen/drivers/char/Kconfig +++ b/xen/drivers/char/Kconfig @@ -4,6 +4,13 @@ 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 + 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 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 May 3 13:41:26 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=1604419237; cv=none; d=zohomail.com; s=zohoarc; b=OR/flWjX9pHyCq8d5u4SYKbn1lugW0IWAmm6lTfHPtF0MeE5oUImnNrutbFR+WcmlhUPaWztDIHxy4B99brzajgp/kbHV4URHUXlbp+Fg8jH39XzvddKRcyFOU2GkayAiSyjlXFQDSd88SP7RLiLcEgQI95/zEeelmD8qI73NOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604419237; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=qdgZtK8y/ACGsgAIM3fr1CZz7AoU7IiX/0Pkj8FY99w=; b=D0KYK5mwGu5EEIXjM05PPD8iGtEuMO10f7wG4B0gQA0FVLNyA7AWnxilTrr9aPAU5T3cLylIYr0fwUyHD0DZ5jKUS3dXk49f5/MUJB4qipsW6PL/xpG/ql4ME81GSrd/cv6N2KSMLk0T/HYFB1WGaEARU0XD64fS+Tmxda/ewK4= 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 1604419236984877.0031721794925; Tue, 3 Nov 2020 08:00:36 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.18395.43428 (Exim 4.92) (envelope-from ) id 1kZyjH-0008Jg-7E; Tue, 03 Nov 2020 16:00:15 +0000 Received: by outflank-mailman (output) from mailman id 18395.43428; Tue, 03 Nov 2020 16:00:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kZyjH-0008JX-2B; Tue, 03 Nov 2020 16:00:15 +0000 Received: by outflank-mailman (input) for mailman id 18395; Tue, 03 Nov 2020 16:00:14 +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 1kZyjG-0008I1-0D for xen-devel@lists.xenproject.org; Tue, 03 Nov 2020 16:00:14 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 0d301239-0fe5-4670-a290-67d4b4fefb0d; Tue, 03 Nov 2020 16:00:12 +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 1660E139F; Tue, 3 Nov 2020 08:00:12 -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 B8DAD3F66E; Tue, 3 Nov 2020 08:00:10 -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 1kZyjG-0008I1-0D for xen-devel@lists.xenproject.org; Tue, 03 Nov 2020 16:00:14 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 0d301239-0fe5-4670-a290-67d4b4fefb0d; Tue, 03 Nov 2020 16:00:12 +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 1660E139F; Tue, 3 Nov 2020 08:00:12 -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 B8DAD3F66E; Tue, 3 Nov 2020 08:00:10 -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: 0d301239-0fe5-4670-a290-67d4b4fefb0d 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 v2 2/4] xen/pci: Introduce new CONFIG_PCI_ATS flag for PCI ATS functionality. Date: Tue, 3 Nov 2020 15:59:13 +0000 Message-Id: <27814e614618c413ac61a9f7a48d795c557bfe5c.1604417224.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" PCI 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. Signed-off-by: Rahul Singh Reviewed-by: Bertrand Marquis Reviewed-by: Jan Beulich --- Changes in v2: - Fixed return value of PCI ATS related functions when PCI_ATS is not enab= led. - Make PCI_ATS user selectable kconfig option. --- xen/drivers/passthrough/ats.h | 26 ++++++++++++++++++++++++++ xen/drivers/passthrough/x86/Makefile | 2 +- xen/drivers/pci/Kconfig | 9 +++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/xen/drivers/passthrough/ats.h b/xen/drivers/passthrough/ats.h index 22ae209b37..3a71fedcb4 100644 --- a/xen/drivers/passthrough/ats.h +++ b/xen/drivers/passthrough/ats.h @@ -17,6 +17,8 @@ =20 #include =20 +#ifdef CONFIG_PCI_ATS + #define ATS_REG_CAP 4 #define ATS_REG_CTL 6 #define ATS_QUEUE_DEPTH_MASK 0x1f @@ -48,5 +50,29 @@ static inline int pci_ats_device(int seg, int bus, int d= evfn) return pci_find_ext_capability(seg, bus, devfn, PCI_EXT_CAP_ID_ATS); } =20 +#else + +#define ats_enabled (false) + +static inline int enable_ats_device(struct pci_dev *pdev, + struct list_head *ats_list) +{ + return -EOPNOTSUPP; +} + +static inline void disable_ats_device(struct pci_dev *pdev) { } + +static inline int pci_ats_enabled(int seg, int bus, int devfn) +{ + return 0; +} + +static inline int pci_ats_device(int seg, int bus, int devfn) +{ + return 0; +} + +#endif /* CONFIG_PCI_ATS */ + #endif /* _ATS_H_ */ =20 diff --git a/xen/drivers/passthrough/x86/Makefile b/xen/drivers/passthrough= /x86/Makefile index a70cf9460d..aa515c680d 100644 --- a/xen/drivers/passthrough/x86/Makefile +++ b/xen/drivers/passthrough/x86/Makefile @@ -1,2 +1,2 @@ -obj-y +=3D ats.o +obj-$(CONFIG_PCI_ATS) +=3D ats.o obj-y +=3D iommu.o diff --git a/xen/drivers/pci/Kconfig b/xen/drivers/pci/Kconfig index 7da03fa13b..3cb79ea954 100644 --- a/xen/drivers/pci/Kconfig +++ b/xen/drivers/pci/Kconfig @@ -1,3 +1,12 @@ =20 config HAS_PCI bool + +config PCI_ATS + bool "PCI ATS support" + default y + depends on X86 && HAS_PCI + ---help--- + Enable PCI Address Translation Services. + + If unsure, say Y. --=20 2.17.1 From nobody Fri May 3 13:41:26 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=1604419246; cv=none; d=zohomail.com; s=zohoarc; b=BK2yoLcp72NwFYdGO6cG2YYzuGY8d/HQXjtgAVWqKBg+KthktclM5puVc8letQUTEb5rg9J8xRDjTr0aejBmFfF4X/Kd3LZkIpJJFdPURGhiLsbYy7WhMpJYfeWybxorOE4U1q8waDF6zb8gVlTeH++qMxAfqCqh/zVKNPkagrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604419246; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=UarHPNhkSUaL9SdnqYHNSDgJjRAlzqACKrZSPPgBOv8=; b=VkBVNK0TvgII2S86zOBx3mKKfFqDBcJp1m2/4dfpyTrl8JXkGX1efjpD6G8V/knKVmgk2Hlh2m4XcQOdJWszANVyR/yehUkFHoceC0p1f5uHg7ak/3h+EROvcnBE+T+oAUOuf3sE4iE0l2WbPZzmxwTl2GBJlW7Qx+gWozJUXNU= 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 1604419245965281.4610363247034; Tue, 3 Nov 2020 08:00:45 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.18396.43440 (Exim 4.92) (envelope-from ) id 1kZyjM-0008QC-GR; Tue, 03 Nov 2020 16:00:20 +0000 Received: by outflank-mailman (output) from mailman id 18396.43440; Tue, 03 Nov 2020 16:00:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kZyjM-0008Q3-CS; Tue, 03 Nov 2020 16:00:20 +0000 Received: by outflank-mailman (input) for mailman id 18396; Tue, 03 Nov 2020 16:00:18 +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 1kZyjK-0008I1-Tc for xen-devel@lists.xenproject.org; Tue, 03 Nov 2020 16:00:18 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 8a62af32-53e9-42dd-8610-ff795a755265; Tue, 03 Nov 2020 16:00:17 +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 D5D2F139F; Tue, 3 Nov 2020 08:00:16 -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 644413F66E; Tue, 3 Nov 2020 08:00:15 -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 1kZyjK-0008I1-Tc for xen-devel@lists.xenproject.org; Tue, 03 Nov 2020 16:00:18 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 8a62af32-53e9-42dd-8610-ff795a755265; Tue, 03 Nov 2020 16:00:17 +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 D5D2F139F; Tue, 3 Nov 2020 08:00:16 -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 644413F66E; Tue, 3 Nov 2020 08:00:15 -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: 8a62af32-53e9-42dd-8610-ff795a755265 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 v2 3/4] xen/pci: Move x86 specific code to x86 directory. Date: Tue, 3 Nov 2020 15:59:14 +0000 Message-Id: <687101e7e0e6feb64dd8ea63c8cf1aacf1684049.1604417224.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" passthrough/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. Signed-off-by: Rahul Singh Reviewed-by: Bertrand Marquis Reviewed-by: Stefano Stabellini --- Changes is v2: - fixed comments. - rename pci_clean_dpci_irqs() to arch_pci_clean_pirqs(). --- xen/drivers/passthrough/pci.c | 76 +---------------------- xen/drivers/passthrough/x86/Makefile | 1 + xen/drivers/passthrough/x86/iommu.c | 7 +++ xen/drivers/passthrough/x86/pci.c | 91 ++++++++++++++++++++++++++++ xen/include/xen/pci.h | 2 + 5 files changed, 102 insertions(+), 75 deletions(-) create mode 100644 xen/drivers/passthrough/x86/pci.c diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 2a3bce1462..04d3e2c0f9 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -14,7 +14,6 @@ * this program; If not, see . */ =20 -#include #include #include #include @@ -24,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -847,71 +845,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) @@ -971,7 +904,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(); @@ -1375,13 +1308,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 aa515c680d..d02ff75de5 100644 --- a/xen/drivers/passthrough/x86/Makefile +++ b/xen/drivers/passthrough/x86/Makefile @@ -1,2 +1,3 @@ obj-$(CONFIG_PCI_ATS) +=3D ats.o obj-y +=3D iommu.o +obj-y +=3D pci.o 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/drivers/passthrough/x86/pci.c b/xen/drivers/passthrough/x8= 6/pci.c new file mode 100644 index 0000000000..59588aa8d4 --- /dev/null +++ b/xen/drivers/passthrough/x86/pci.c @@ -0,0 +1,91 @@ +/* + * 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 f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program; If not, see . + */ + +#include +#include + +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; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h index c4d3879761..fd28d11f6e 100644 --- a/xen/include/xen/pci.h +++ b/xen/include/xen/pci.h @@ -209,4 +209,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 May 3 13:41:26 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=1604419318; cv=none; d=zohomail.com; s=zohoarc; b=XurH4q3eHx1I5lmYaWBXjXsWsIVfsG9jFuvQbjA6F7jcgXdnyv7Tl/P1f6P1iSw77ZLfTDQIcJRm8crqmhrYIoQEhayBTWOEgpWYkDejSFYW4aJnrRfwbnJpQpycO6GD0pmtVvb2EyF2spIqrgUZHTNnsvLW1ZM54FGb548HDug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604419318; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=A7kS8i4R+dTjvsuZDA7UlZTRwnPhaVpXkwpyzJUmITs=; b=JT55PmoAVRIQgjrJ/YIEY1Wu9NLjTvqroAlZW2/1L+ab7j6VFtEw4Orznrg516Ez+o4UMTYI5C+PJM3g5X+dTuE+cPC97B7FtpE/P8f5uNszneiBWBRBp9t2n5UvWWy2I+nrNHb3DvMXPzoA53o280t8UvSUSTF8xTmQSIQ5veA= 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 1604419318572503.5841638900041; Tue, 3 Nov 2020 08:01:58 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.18397.43452 (Exim 4.92) (envelope-from ) id 1kZyjR-0008Ud-20; Tue, 03 Nov 2020 16:00:25 +0000 Received: by outflank-mailman (output) from mailman id 18397.43452; Tue, 03 Nov 2020 16:00:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kZyjQ-0008UR-Ul; Tue, 03 Nov 2020 16:00:24 +0000 Received: by outflank-mailman (input) for mailman id 18397; Tue, 03 Nov 2020 16:00:23 +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 1kZyjP-0008I1-RI for xen-devel@lists.xenproject.org; Tue, 03 Nov 2020 16:00:23 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 1dae1f68-0d34-4a5d-86ae-4e8e5e1977e4; Tue, 03 Nov 2020 16:00:19 +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 97EC413A1; Tue, 3 Nov 2020 08:00:19 -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 E8F123F66E; Tue, 3 Nov 2020 08:00:18 -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 1kZyjP-0008I1-RI for xen-devel@lists.xenproject.org; Tue, 03 Nov 2020 16:00:23 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 1dae1f68-0d34-4a5d-86ae-4e8e5e1977e4; Tue, 03 Nov 2020 16:00:19 +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 97EC413A1; Tue, 3 Nov 2020 08:00:19 -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 E8F123F66E; Tue, 3 Nov 2020 08:00:18 -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: 1dae1f68-0d34-4a5d-86ae-4e8e5e1977e4 From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: Bertrand.Marquis@arm.com, Jan Beulich , Paul Durrant Subject: [PATCH v2 4/4] xen/pci: solve compilation error on ARM with HAS_PCI enabled. Date: Tue, 3 Nov 2020 15:59:15 +0000 Message-Id: <7b60501fa689a4f2795ea6c34a7475d288f154a9.1604417224.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" If mem-sharing, mem-paging and log-dirty functionality is not enabled for architecture when HAS_PCI is enabled, compiler will throw an error. Move code to x86 specific directory to fix compilation error. No functional change. Signed-off-by: Rahul Singh Reviewed-by: Bertrand Marquis --- Changes in v2: - Move mem-sharing , men-paging and log-dirty specific code to x86 directo= ry.=20 --- xen/drivers/passthrough/pci.c | 8 +------- xen/drivers/passthrough/x86/iommu.c | 13 +++++++++++++ xen/include/xen/iommu.h | 2 ++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 04d3e2c0f9..433989e654 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -1418,12 +1417,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_usable(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..b3d151a14c 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,18 @@ int iommu_update_ire_from_msi( ? iommu_call(&iommu_ops, update_ire_from_msi, msi_desc, msg) : = 0; } =20 +bool_t arch_iommu_usable(struct domain *d) +{ + + /* Prevent device assign if mem paging or mem sharing have been + * 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) ) + return false; + else + return true; +} /* * Local variables: * mode: C diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 191021870f..493528cee3 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_t arch_iommu_usable(struct domain *d); + #endif /* _IOMMU_H_ */ =20 /* --=20 2.17.1