From nobody Wed May 1 00:29:52 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=1606328232; cv=none; d=zohomail.com; s=zohoarc; b=axMWUAe+nrzysQe6FWZgPrCXhLrwPn9aAIM4tbv7BoSZ38ARkzKw2ZqJnv3b8lf0DEPSe1EyPZ/tNWnO/eOb7npBVoTG/a5rWLIZn2QOuc3/SfErV5RtFcwPFJWdMfbDPYqpv2BEi5uySN2PQG5RIOrg/iXIm2rRQzSEo2gBkjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606328232; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=q4wfSazuqL1xQCGUo7lD1winh355HKXQxgsKT7ZWQSE=; b=Xtx17L5YVDY0P50AaRke/wQU8SL2KsEP7eW6KsYSTmApwn3+ZVYjT3JGU7nAsiXB8Qz0Rmi/t/HheWjfD4UExfvFn0wAe0rqzAqApRgpQYkqV7DOycdht5KwXe/EY8dlhdvg4ICxDOkW6bd4SlnCSKxO7P4As5DAnSHeRGuqUZo= 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 1606328232782284.3806582326008; Wed, 25 Nov 2020 10:17:12 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.37951.70552 (Exim 4.92) (envelope-from ) id 1khzLV-0001R0-PY; Wed, 25 Nov 2020 18:16:49 +0000 Received: by outflank-mailman (output) from mailman id 37951.70552; Wed, 25 Nov 2020 18:16:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khzLV-0001Qt-Ma; Wed, 25 Nov 2020 18:16:49 +0000 Received: by outflank-mailman (input) for mailman id 37951; Wed, 25 Nov 2020 18:16:48 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khzLU-0001Oz-9Q for xen-devel@lists.xenproject.org; Wed, 25 Nov 2020 18:16:48 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 28b115bf-7771-4d9e-820d-affdbf0e73bb; Wed, 25 Nov 2020 18:16:45 +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 205EE11D4; Wed, 25 Nov 2020 10:16:45 -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 AD29E3F23F; Wed, 25 Nov 2020 10:16:43 -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 1khzLU-0001Oz-9Q for xen-devel@lists.xenproject.org; Wed, 25 Nov 2020 18:16:48 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 28b115bf-7771-4d9e-820d-affdbf0e73bb; Wed, 25 Nov 2020 18:16:45 +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 205EE11D4; Wed, 25 Nov 2020 10:16:45 -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 AD29E3F23F; Wed, 25 Nov 2020 10:16:43 -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: 28b115bf-7771-4d9e-820d-affdbf0e73bb From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Jan Beulich , Paul Durrant , Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v4 1/3] xen/pci: Move x86 specific code to x86 directory. Date: Wed, 25 Nov 2020 18:16:02 +0000 Message-Id: <3500f44e3b6f8f05f9d05fa170817d5bc6f39f22.1606326929.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 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 intended. Signed-off-by: Rahul Singh Acked-by: Jan Beulich Reviewed-by: Bertrand Marquis Reviewed-by: Stefano Stabellini --- Changes in v4: - fixed compilation error when CONFIG_HVM is disabled=20 - remove iommu_update_ire_from_msi from the patch will send another patch to fix. --- xen/drivers/passthrough/Makefile | 3 - xen/drivers/passthrough/pci.c | 71 +-------------------- xen/drivers/passthrough/x86/Makefile | 1 + xen/drivers/passthrough/{io.c =3D> x86/hvm.c} | 66 +++++++++++++++++++ xen/include/xen/pci.h | 9 +++ 5 files changed, 77 insertions(+), 73 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..3c6ab1bcb6 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(); 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/include/xen/pci.h b/xen/include/xen/pci.h index 20a54a5bb4..8e3d4d9454 100644 --- a/xen/include/xen/pci.h +++ b/xen/include/xen/pci.h @@ -208,4 +208,13 @@ 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 +#ifdef CONFIG_HVM +int arch_pci_clean_pirqs(struct domain *d); +#else +static inline int arch_pci_clean_pirqs(struct domain *d) +{ + return 0; +} +#endif /* CONFIG_HVM */ + #endif /* __XEN_PCI_H__ */ --=20 2.17.1 From nobody Wed May 1 00:29:52 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=1606328230; cv=none; d=zohomail.com; s=zohoarc; b=bg4HBroyRQj/U+6u1PPkpXp5O5eapga6q8guE9weZ93pVSoCMGJfmtO3v7WyXgg2mGU2ceZgFjDKCvkj4jG6iIDKLT16iKQCh1niVf1aPS79WkjQSXlVd1YdLZG262IVhkKQSymp309Hi/+QKnI7Ao+PVZ7OryGdszZZkRTeK1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606328230; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=6KQoASODljokc4o3Lq46FcWLLOYIJ7sdSG8r3tSJ5DU=; b=mas/pc4t/Nbws6CmgjWh6lyi3Bid2Xu0ivfl6Z6zaZdb9crUrwGM70R+epgJn+KphypIunMPqa0nJIPhCZVOTuk3QZWSbyXRaB6S+ctqhTyk4VEsfI7UjNNMYBfJAO/PxQhk2dFi0XXLe7w2Gn6F8FE03Xe8VUlSTnX36zXDEVY= 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 1606328230335649.540027029285; Wed, 25 Nov 2020 10:17:10 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.37952.70564 (Exim 4.92) (envelope-from ) id 1khzLb-0001U9-3k; Wed, 25 Nov 2020 18:16:55 +0000 Received: by outflank-mailman (output) from mailman id 37952.70564; Wed, 25 Nov 2020 18:16:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khzLa-0001U0-Vx; Wed, 25 Nov 2020 18:16:54 +0000 Received: by outflank-mailman (input) for mailman id 37952; Wed, 25 Nov 2020 18:16:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khzLZ-0001Oz-9c for xen-devel@lists.xenproject.org; Wed, 25 Nov 2020 18:16:53 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 617e2fad-6fc2-48fd-8ed6-856b402076a1; Wed, 25 Nov 2020 18:16:47 +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 91E7E11D4; Wed, 25 Nov 2020 10:16:47 -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 C93D93F23F; Wed, 25 Nov 2020 10:16:46 -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 1khzLZ-0001Oz-9c for xen-devel@lists.xenproject.org; Wed, 25 Nov 2020 18:16:53 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 617e2fad-6fc2-48fd-8ed6-856b402076a1; Wed, 25 Nov 2020 18:16:47 +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 91E7E11D4; Wed, 25 Nov 2020 10:16:47 -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 C93D93F23F; Wed, 25 Nov 2020 10:16:46 -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: 617e2fad-6fc2-48fd-8ed6-856b402076a1 From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Jan Beulich , Paul Durrant Subject: [PATCH v4 2/3] xen/pci: solve compilation error on ARM with HAS_PCI enabled. Date: Wed, 25 Nov 2020 18:16:03 +0000 Message-Id: <2ce402cfae6d90433626bcdc6314e5ee5dda103f.1606326929.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, or log-dirty functionality is not enabled for architecture when HAS_PCI is enabled, the compiler will throw an error. Move code to x86 specific file 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 intended. Signed-off-by: Rahul Singh Acked-by: Jan Beulich Reviewed-by: Bertrand Marquis --- Changes in v4: - fixed minor comments --- 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 3c6ab1bcb6..4c21655b7d 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -20,7 +20,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_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 f17b1820f4..cea1032b3d 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -18,6 +18,7 @@ #include #include #include +#include #include =20 #include @@ -308,6 +309,18 @@ struct page_info *iommu_alloc_pgtable(struct domain *d) return pg; } =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 From nobody Wed May 1 00:29:52 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=1606328233; cv=none; d=zohomail.com; s=zohoarc; b=X20Qdx99hmD7XD+Ph+2hoUO+8aXV0X7xuZdSPurxitwI+PQ5riKAzSsZOIAGXlk1TGusIje81K0IVza4evtpldpm1jSl37ZzdDe37TS54doWTnLVWraDIScbzdLD8evReYNOHFBkYHy1MoDSGSkQytAEPJIekZwQrZwrFqVoDQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606328233; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pDJ5jQDnMuelr009ngl7NbNVbQedVfmHYDt2wSOCZRM=; b=dwDOC2i/irXDFIZJP97QpGIy0Gbq21VCXprCsR3x1gASTlaQWYg+euR32N6xryaQ21WZe/gxm3L933eXr6ytOtfKeBdXbz2yByvUgk1TRgTatT+c1kr9GRMCeSa5cL2dZnDsjxtlqSSsyDCheOyAocZsFZOAWQdQFlGNtLdAFL8= 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 1606328233157691.6918986215454; Wed, 25 Nov 2020 10:17:13 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.37955.70576 (Exim 4.92) (envelope-from ) id 1khzLg-0001a6-Fc; Wed, 25 Nov 2020 18:17:00 +0000 Received: by outflank-mailman (output) from mailman id 37955.70576; Wed, 25 Nov 2020 18:17:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khzLg-0001Zv-BZ; Wed, 25 Nov 2020 18:17:00 +0000 Received: by outflank-mailman (input) for mailman id 37955; Wed, 25 Nov 2020 18:16:58 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khzLe-0001Oz-9f for xen-devel@lists.xenproject.org; Wed, 25 Nov 2020 18:16:58 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 8db06e9a-3041-4f8a-a772-db9e0c6eee0a; Wed, 25 Nov 2020 18:16:50 +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 BDFEB11D4; Wed, 25 Nov 2020 10:16:50 -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 715AE3F23F; Wed, 25 Nov 2020 10:16:49 -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 1khzLe-0001Oz-9f for xen-devel@lists.xenproject.org; Wed, 25 Nov 2020 18:16:58 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 8db06e9a-3041-4f8a-a772-db9e0c6eee0a; Wed, 25 Nov 2020 18:16:50 +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 BDFEB11D4; Wed, 25 Nov 2020 10:16:50 -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 715AE3F23F; Wed, 25 Nov 2020 10:16:49 -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: 8db06e9a-3041-4f8a-a772-db9e0c6eee0a From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, rahul.singh@arm.com, Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v4 3/3] ns16550: Gate all PCI code with CONFIG_X86 Date: Wed, 25 Nov 2020 18:16:04 +0000 Message-Id: <6d64bb35a6ce247faaa3df2ebae27b6bfa1d969e.1606326929.git.rahul.singh@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The NS16550 driver is assuming that NS16550 PCI card are usable if the architecture supports PCI (i.e. CONFIG_HAS_PCI=3Dy). However, the code is very x86 focus and will fail to build on Arm (/!\ it is not all the errors): ns16550.c: In function =E2=80=98ns16550_init_irq=E2=80=99: ns16550.c:726:21: error: implicit declaration of function =E2=80=98create_i= rq=E2=80=99; did you mean =E2=80=98release_irq=E2=80=99? [-Werror=3Dimplicit-function-de= claration] uart->irq =3D create_irq(0, false); ^~~~~~~~~~ release_irq ns16550.c:726:21: error: nested extern declaration of =E2=80=98create_irq= =E2=80=99 [-Werror=3Dnested-externs] ns16550.c: In function =E2=80=98ns16550_init_postirq=E2=80=99: ns16550.c:768:33: error: =E2=80=98mmio_ro_ranges=E2=80=99 undeclared (first= use in this function); did you mean =E2=80=98mmio_handler=E2=80=99? rangeset_add_range(mmio_ro_ranges, uart->io_base, ^~~~~~~~~~~~~~ mmio_handler ns16550.c:768:33: note: each undeclared identifier is reported only once for each function it appears in ns16550.c:780:20: error: variable =E2=80=98msi=E2=80=99 has initializer but= incomplete type struct msi_info msi =3D { ^~~~~~~~ Enabling support for NS16550 PCI card on Arm would require more plumbing in addition to fixing the compilation error. Arm systems tend to have platform UART available such as NS16550, PL011. So there are limited reasons to get NS16550 PCI support for now on Arm. Guard all remaining PCI code that is not under x86 flag with CONFIG_X86. No functional change intended. Signed-off-by: Rahul Singh Acked-by: Stefano Stabellini Reviewed-by: Bertrand Marquis --- Changes in v4: - As per the discussion guard all remaining PCI code with CONFIG_X86 --- xen/drivers/char/ns16550.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index 9235d854fe..26e601857a 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -16,7 +16,7 @@ #include #include #include -#ifdef CONFIG_HAS_PCI +#if defined(CONFIG_X86) && defined(CONFIG_HAS_PCI) #include #include #include @@ -51,7 +51,7 @@ static struct ns16550 { unsigned int timeout_ms; bool_t intr_works; bool_t dw_usr_bsy; -#ifdef CONFIG_HAS_PCI +#if defined(CONFIG_X86) && defined(CONFIG_HAS_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= */ @@ -66,7 +66,7 @@ static struct ns16550 { #endif } ns16550_com[2] =3D { { 0 } }; =20 -#ifdef CONFIG_HAS_PCI +#if defined(CONFIG_X86) && defined(CONFIG_HAS_PCI) struct ns16550_config { u16 vendor_id; u16 dev_id; @@ -256,7 +256,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 +#if defined(CONFIG_X86) && defined(CONFIG_HAS_PCI) if ( !uart->ps_bdf_enable || uart->io_base >=3D 0x10000 ) return; =20 @@ -355,7 +355,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 +#if defined(CONFIG_X86) && defined(CONFIG_HAS_PCI) struct ns16550 *uart =3D port->uart; =20 if ( uart->msi ) @@ -397,7 +397,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 +#if defined(CONFIG_X86) && defined(CONFIG_HAS_PCI) if ( uart->bar || uart->ps_bdf_enable ) { if ( uart->param && uart->param->mmio && @@ -477,7 +477,7 @@ static void ns16550_suspend(struct serial_port *port) =20 stop_timer(&uart->timer); =20 -#ifdef CONFIG_HAS_PCI +#if defined(CONFIG_X86) && defined(CONFIG_HAS_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); @@ -486,7 +486,7 @@ static void ns16550_suspend(struct serial_port *port) =20 static void _ns16550_resume(struct serial_port *port) { -#ifdef CONFIG_HAS_PCI +#if defined(CONFIG_X86) && defined(CONFIG_HAS_PCI) struct ns16550 *uart =3D port->uart; =20 if ( uart->bar ) --=20 2.17.1