From patchwork Fri Aug 16 17:19:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11098069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 77D4817E2 for ; Fri, 16 Aug 2019 17:21:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6238228A0D for ; Fri, 16 Aug 2019 17:21:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 563D428A31; Fri, 16 Aug 2019 17:21:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D962828A0D for ; Fri, 16 Aug 2019 17:21:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hyftW-0005Dl-P9; Fri, 16 Aug 2019 17:20:06 +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.89) (envelope-from ) id 1hyftW-00057A-1w for xen-devel@lists.xenproject.org; Fri, 16 Aug 2019 17:20:06 +0000 X-Inumbo-ID: 166753ac-c04a-11e9-8bb8-12813bfff9fa Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 166753ac-c04a-11e9-8bb8-12813bfff9fa; Fri, 16 Aug 2019 17:20:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1565976005; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ayJEXljTEjZ7oSaACmhECKqiGUw5cXiXCH8pIY2dFgA=; b=b5wRSjjGlA01tt+sPR5/PHD/+nddYzH9dWxeoJWuGuXc2bskz9N1C/WA DysVMpOI8Zk7C165X/mBCz65Vbb3ZKusrVPLkUl6XDoXOj+zehdaN7LaG IvGhqI6WnvJBjfWHugjmGXo5r1ZU7tc30NiUau6Cz3H2pQpKIRDTjofJX k=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=paul.durrant@citrix.com; spf=Pass smtp.mailfrom=Paul.Durrant@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of paul.durrant@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="paul.durrant@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of Paul.Durrant@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="Paul.Durrant@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: sryNxE9bxfVsem4DIZLpL0S/bEMLAmjOqjENjZ9O6vvchNHqd+X67wt3LpNmn+MHxknda7arOu IbY1184W5TNxTbtGjhvKm0MVthAl7utVnTA7TQLLWAezqdzumOOOUXtYIS5DEZBw/Rl0M1wTKH U3FBtnMi+UIizJvXjI3waDA0V0HYXQ/KkYFXYMDHld+rqs5fIXCdO4MQ6M5qSEkO3fMduwMRd+ XjzkAl7/p1onS1g826S1F8ttYNuocSAmkj5ei5AvOiinqrdcXHI/lfe5YLsQohY+u52GlMfq6n kKU= X-SBRS: 2.7 X-MesageID: 4596315 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,394,1559534400"; d="scan'208";a="4596315" From: Paul Durrant To: Date: Fri, 16 Aug 2019 18:19:52 +0100 Message-ID: <20190816172001.3905-2-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb671 In-Reply-To: <20190816172001.3905-1-paul.durrant@citrix.com> References: <20190816172001.3905-1-paul.durrant@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v6 01/10] make passthrough/pci.c:deassign_device() static X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Paul Durrant , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This function is only ever called from within the same source module and really has no business being declared xen/iommu.h. This patch relocates the function ahead of the first called and makes it static. Signed-off-by: Paul Durrant Acked-by: Jan Beulich Reviewed-by: Roger Pau Monné --- Previously part of series https://lists.xenproject.org/archives/html/xen-devel/2019-07/msg02267.html v6: - Re-base due to re-positioning in series v5: - minor style fixes - use %pd, rather than d%d --- xen/drivers/passthrough/pci.c | 99 ++++++++++++++++++----------------- xen/include/xen/iommu.h | 1 - 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 7c196ba58b..89536cc067 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -889,6 +889,56 @@ static int pci_clean_dpci_irqs(struct domain *d) return 0; } +/* caller should hold the pcidevs_lock */ +static int deassign_device(struct domain *d, uint16_t seg, uint8_t bus, + uint8_t devfn) +{ + const struct domain_iommu *hd = dom_iommu(d); + struct pci_dev *pdev; + int ret = 0; + + if ( !iommu_enabled || !hd->platform_ops ) + return -EINVAL; + + ASSERT(pcidevs_locked()); + pdev = pci_get_pdev_by_domain(d, seg, bus, devfn); + if ( !pdev ) + return -ENODEV; + + while ( pdev->phantom_stride ) + { + devfn += pdev->phantom_stride; + if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) + break; + ret = hd->platform_ops->reassign_device(d, hardware_domain, devfn, + pci_to_dev(pdev)); + if ( !ret ) + continue; + + printk(XENLOG_G_ERR "%pd: deassign %04x:%02x:%02x.%u failed (%d)\n", + d, seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), ret); + return ret; + } + + devfn = pdev->devfn; + ret = hd->platform_ops->reassign_device(d, hardware_domain, devfn, + pci_to_dev(pdev)); + if ( ret ) + { + dprintk(XENLOG_G_ERR, + "%pd: deassign device (%04x:%02x:%02x.%u) failed\n", + d, seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); + return ret; + } + + pdev->fault.count = 0; + + if ( !has_arch_pdevs(d) && has_iommu_pt(d) ) + iommu_teardown(d); + + return ret; +} + int pci_release_devices(struct domain *d) { struct pci_dev *pdev; @@ -1476,55 +1526,6 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag) return rc; } -/* caller should hold the pcidevs_lock */ -int deassign_device(struct domain *d, u16 seg, u8 bus, u8 devfn) -{ - const struct domain_iommu *hd = dom_iommu(d); - struct pci_dev *pdev = NULL; - int ret = 0; - - if ( !iommu_enabled || !hd->platform_ops ) - return -EINVAL; - - ASSERT(pcidevs_locked()); - pdev = pci_get_pdev_by_domain(d, seg, bus, devfn); - if ( !pdev ) - return -ENODEV; - - while ( pdev->phantom_stride ) - { - devfn += pdev->phantom_stride; - if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) - break; - ret = hd->platform_ops->reassign_device(d, hardware_domain, devfn, - pci_to_dev(pdev)); - if ( !ret ) - continue; - - printk(XENLOG_G_ERR "d%d: deassign %04x:%02x:%02x.%u failed (%d)\n", - d->domain_id, seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), ret); - return ret; - } - - devfn = pdev->devfn; - ret = hd->platform_ops->reassign_device(d, hardware_domain, devfn, - pci_to_dev(pdev)); - if ( ret ) - { - dprintk(XENLOG_G_ERR, - "d%d: deassign device (%04x:%02x:%02x.%u) failed\n", - d->domain_id, seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn)); - return ret; - } - - pdev->fault.count = 0; - - if ( !has_arch_pdevs(d) && has_iommu_pt(d) ) - iommu_teardown(d); - - return ret; -} - static int iommu_get_device_group( struct domain *d, u16 seg, u8 bus, u8 devfn, XEN_GUEST_HANDLE_64(uint32) buf, int max_sdevs) diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 48f87480a7..314f28f323 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -70,7 +70,6 @@ int iommu_hardware_setup(void); int iommu_domain_init(struct domain *d); void iommu_hwdom_init(struct domain *d); void iommu_domain_destroy(struct domain *d); -int deassign_device(struct domain *d, u16 seg, u8 bus, u8 devfn); void arch_iommu_domain_destroy(struct domain *d); int arch_iommu_domain_init(struct domain *d);