From patchwork Fri Jan 16 14:24:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 43249 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 106B1240D8 for ; Fri, 16 Jan 2015 14:26:59 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id x12sf11263274wgg.0 for ; Fri, 16 Jan 2015 06:26:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=PdZsV8xuVkHCIx4/R6OZWK2ZmDsgFDFurxPk4TMmTv4=; b=T8eHbsLsSh9yF2+KIp+Fj1L0k7eYyW4FfyaNqVeJj2y3AUVsgOCQYckBpztDmJ2Tco Q6Doq67w3uor4Ug1nE9HiStAREaEieDLH4+6rF4xSlIEOpJw0VU31jFWUK/dWVvJ+mWu neTivUrGn4uJWOW5bGj229ndNOUmJH4XBSRRE2Vy8XYCKll4s7Wz4PDlg2H56EVUTQpV uL01TAu9OJI3mhKSwJDT0ftFdZdkvJvI4IIBsYLQ02apPqITi4leVlI+AX1s5pJ2RDny oJgcV9w/jC5ZVh99QUwf/UIBBX+lpQrYUGQS/WoB1wpnzbC/mZq7ynT/1sgc0YVgw5UY jSow== X-Gm-Message-State: ALoCoQnT8UpqgfK0GRW1RyPKzKW+s4VXjBMbPJYmtJGHRpx+vdV2TyWVKmaJ1dgTacscDuvvCa+g X-Received: by 10.112.42.104 with SMTP id n8mr270122lbl.19.1421418418351; Fri, 16 Jan 2015 06:26:58 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.196 with SMTP id ba4ls376843lab.40.gmail; Fri, 16 Jan 2015 06:26:58 -0800 (PST) X-Received: by 10.152.3.100 with SMTP id b4mr15387505lab.68.1421418418206; Fri, 16 Jan 2015 06:26:58 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id jc11si4585638lac.31.2015.01.16.06.26.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Jan 2015 06:26:58 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id b6so18654782lbj.8 for ; Fri, 16 Jan 2015 06:26:58 -0800 (PST) X-Received: by 10.112.14.6 with SMTP id l6mr16005327lbc.91.1421418418116; Fri, 16 Jan 2015 06:26:58 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp325483lbb; Fri, 16 Jan 2015 06:26:56 -0800 (PST) X-Received: by 10.224.69.200 with SMTP id a8mr25397300qaj.40.1421418411900; Fri, 16 Jan 2015 06:26:51 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id l6si6170420qca.20.2015.01.16.06.26.51 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 16 Jan 2015 06:26:51 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YC7pi-0004Ko-66; Fri, 16 Jan 2015 14:25:06 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YC7ph-0004K0-27 for xen-devel@lists.xenproject.org; Fri, 16 Jan 2015 14:25:05 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id A3/E8-29352-04F19B45; Fri, 16 Jan 2015 14:25:04 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-10.tower-206.messagelabs.com!1421418303!13183958!1 X-Originating-IP: [74.125.82.172] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16991 invoked from network); 16 Jan 2015 14:25:03 -0000 Received: from mail-we0-f172.google.com (HELO mail-we0-f172.google.com) (74.125.82.172) by server-10.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 16 Jan 2015 14:25:03 -0000 Received: by mail-we0-f172.google.com with SMTP id k11so20486118wes.3 for ; Fri, 16 Jan 2015 06:25:03 -0800 (PST) X-Received: by 10.180.38.66 with SMTP id e2mr6570823wik.55.1421418303451; Fri, 16 Jan 2015 06:25:03 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id x6sm6270862wjf.24.2015.01.16.06.25.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jan 2015 06:25:02 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 16 Jan 2015 14:24:02 +0000 Message-Id: <1421418247-30068-8-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1421418247-30068-1-git-send-email-julien.grall@linaro.org> References: <1421418247-30068-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com, Jan Beulich Subject: [Xen-devel] [PATCH v2 07/12] xen/iommu: Consolidate device assignment ops into a single set X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: On ARM, the way to assign device tree node is exactly the same as PCI. Futhermore, all devices can be represented by a 'device_t'. Therefore there is no need to add separate ops. The x86 iommu drivers has not been modified to replace 'struct pci_dev' by "device_t" because the latter is an alias of the former. Signed-off-by: Julien Grall CC: Jan Beulich --- Changes in v2: - Use the newly type device_t - It's not neccessary to modify the x86 iommu drivers --- xen/drivers/passthrough/device_tree.c | 5 +++-- xen/drivers/passthrough/pci.c | 20 +++++++++++--------- xen/include/xen/iommu.h | 17 ++++++----------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c index 3e47df5..377d41d 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -41,7 +41,7 @@ int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev) if ( !list_empty(&dev->domain_list) ) goto fail; - rc = hd->platform_ops->assign_dt_device(d, dev); + rc = hd->platform_ops->assign_device(d, 0, dt_to_dev(dev)); if ( rc ) goto fail; @@ -68,7 +68,8 @@ int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev) spin_lock(&dtdevs_lock); - rc = hd->platform_ops->reassign_dt_device(d, hardware_domain, dev); + rc = hd->platform_ops->reassign_device(d, hardware_domain, + 0, dt_to_dev(dev)); if ( rc ) goto fail; diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index 78c6977..71415d1 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -1254,7 +1254,7 @@ int iommu_add_device(struct pci_dev *pdev) if ( !iommu_enabled || !hd->platform_ops ) return 0; - rc = hd->platform_ops->add_device(pdev->devfn, pdev); + rc = hd->platform_ops->add_device(pdev->devfn, pci_to_dev(pdev)); if ( rc || !pdev->phantom_stride ) return rc; @@ -1263,7 +1263,7 @@ int iommu_add_device(struct pci_dev *pdev) devfn += pdev->phantom_stride; if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) return 0; - rc = hd->platform_ops->add_device(devfn, pdev); + rc = hd->platform_ops->add_device(devfn, pci_to_dev(pdev)); if ( rc ) printk(XENLOG_WARNING "IOMMU: add %04x:%02x:%02x.%u failed (%d)\n", pdev->seg, pdev->bus, PCI_SLOT(devfn), PCI_FUNC(devfn), rc); @@ -1284,7 +1284,7 @@ int iommu_enable_device(struct pci_dev *pdev) !hd->platform_ops->enable_device ) return 0; - return hd->platform_ops->enable_device(pdev); + return hd->platform_ops->enable_device(pci_to_dev(pdev)); } int iommu_remove_device(struct pci_dev *pdev) @@ -1306,7 +1306,7 @@ int iommu_remove_device(struct pci_dev *pdev) devfn += pdev->phantom_stride; if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) break; - rc = hd->platform_ops->remove_device(devfn, pdev); + rc = hd->platform_ops->remove_device(devfn, pci_to_dev(pdev)); if ( !rc ) continue; @@ -1315,7 +1315,7 @@ int iommu_remove_device(struct pci_dev *pdev) return rc; } - return hd->platform_ops->remove_device(pdev->devfn, pdev); + return hd->platform_ops->remove_device(pdev->devfn, pci_to_dev(pdev)); } /* @@ -1376,7 +1376,7 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn) pdev->fault.count = 0; - if ( (rc = hd->platform_ops->assign_device(d, devfn, pdev)) ) + if ( (rc = hd->platform_ops->assign_device(d, devfn, pci_to_dev(pdev))) ) goto done; for ( ; pdev->phantom_stride; rc = 0 ) @@ -1384,7 +1384,7 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn) devfn += pdev->phantom_stride; if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) break; - rc = hd->platform_ops->assign_device(d, devfn, pdev); + rc = hd->platform_ops->assign_device(d, devfn, pci_to_dev(pdev)); if ( rc ) printk(XENLOG_G_WARNING "d%d: assign %04x:%02x:%02x.%u failed (%d)\n", d->domain_id, seg, bus, PCI_SLOT(devfn), PCI_FUNC(devfn), @@ -1419,7 +1419,8 @@ int deassign_device(struct domain *d, u16 seg, u8 bus, u8 devfn) devfn += pdev->phantom_stride; if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) ) break; - ret = hd->platform_ops->reassign_device(d, hardware_domain, devfn, pdev); + ret = hd->platform_ops->reassign_device(d, hardware_domain, devfn, + pci_to_dev(pdev)); if ( !ret ) continue; @@ -1429,7 +1430,8 @@ int deassign_device(struct domain *d, u16 seg, u8 bus, u8 devfn) } devfn = pdev->devfn; - ret = hd->platform_ops->reassign_device(d, hardware_domain, devfn, pdev); + ret = hd->platform_ops->reassign_device(d, hardware_domain, devfn, + pci_to_dev(pdev)); if ( ret ) { dprintk(XENLOG_G_ERR, diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index ecb2627..bf4aff0 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -124,22 +124,17 @@ struct page_info; struct iommu_ops { int (*init)(struct domain *d); void (*hwdom_init)(struct domain *d); -#ifdef HAS_PCI - int (*add_device)(u8 devfn, struct pci_dev *); - int (*enable_device)(struct pci_dev *pdev); - int (*remove_device)(u8 devfn, struct pci_dev *); - int (*assign_device)(struct domain *, u8 devfn, struct pci_dev *); + int (*add_device)(u8 devfn, device_t *dev); + int (*enable_device)(device_t *dev); + int (*remove_device)(u8 devfn, device_t *dev); + int (*assign_device)(struct domain *, u8 devfn, device_t *dev); int (*reassign_device)(struct domain *s, struct domain *t, - u8 devfn, struct pci_dev *); + u8 devfn, device_t *dev); +#ifdef HAS_PCI int (*get_device_group_id)(u16 seg, u8 bus, u8 devfn); int (*update_ire_from_msi)(struct msi_desc *msi_desc, struct msi_msg *msg); void (*read_msi_from_ire)(struct msi_desc *msi_desc, struct msi_msg *msg); #endif /* HAS_PCI */ -#ifdef HAS_DEVICE_TREE - int (*assign_dt_device)(struct domain *d, const struct dt_device_node *dev); - int (*reassign_dt_device)(struct domain *s, struct domain *t, - const struct dt_device_node *dev); -#endif void (*teardown)(struct domain *d); int (*map_page)(struct domain *d, unsigned long gfn, unsigned long mfn,