From patchwork Wed Feb 25 18:52:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 45104 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C5A8320502 for ; Wed, 25 Feb 2015 18:55:45 +0000 (UTC) Received: by lbdu10 with SMTP id u10sf4404531lbd.3 for ; Wed, 25 Feb 2015 10:55:44 -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=3ukCBb6EMHIlx7plWQZ0JbBf+0Wn+2XdYwZxavTci2s=; b=Wet0dYMcOlIotN7+h1YftKqUBcDiG9PzDePt+GeNRuruUevfTJnCpNZ8vABRYrHrdI AnjelSg5UnK7rtvdk69XqSEJJjrl/rk6sb9rFXQFXuUXZVl4AZxt4jyyQtBnKnfOCia9 rGewt5Fbl65Zlnb3rzYcq5APgEvN22j357S/4A8ROL+HQ07IhjorQIZtle1ULhEtpra5 wloBm69q6/D7Fj50a04IvL7mIW86PCA+IZW19wFF9zKVrybTpPmVKtZ6mkrCpaNBX+Xh 6re0+GEhGPuLkDqrj45BftUqeVwTXxFsqi/SjdbAQYzurO9uPOIGoWb3MYbgXqrCV8iR eyOA== X-Gm-Message-State: ALoCoQn1lujZU1xJ9gDGd1OUSTfJK0z8mepacE6/eJSJTQkpMkX5tw0lc0dtUflEFpipiQHPI1/c X-Received: by 10.180.39.164 with SMTP id q4mr759599wik.5.1424890544670; Wed, 25 Feb 2015 10:55:44 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.191.168 with SMTP id gz8ls771445lac.16.gmail; Wed, 25 Feb 2015 10:55:43 -0800 (PST) X-Received: by 10.112.77.201 with SMTP id u9mr4042127lbw.49.1424890543309; Wed, 25 Feb 2015 10:55:43 -0800 (PST) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id i1si1526488lam.148.2015.02.25.10.55.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Feb 2015 10:55:43 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbiz11 with SMTP id z11so5927391lbi.8 for ; Wed, 25 Feb 2015 10:55:43 -0800 (PST) X-Received: by 10.112.135.196 with SMTP id pu4mr4092066lbb.41.1424890543209; Wed, 25 Feb 2015 10:55:43 -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.35.133 with SMTP id h5csp2819951lbj; Wed, 25 Feb 2015 10:55:42 -0800 (PST) X-Received: by 10.140.39.70 with SMTP id u64mr9472438qgu.22.1424890541711; Wed, 25 Feb 2015 10:55:41 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id 66si34946021qhf.1.2015.02.25.10.55.41 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 25 Feb 2015 10:55:41 -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 1YQh5X-0005qQ-GQ; Wed, 25 Feb 2015 18:53:39 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YQh5W-0005q7-GV for xen-devel@lists.xenproject.org; Wed, 25 Feb 2015 18:53:38 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id AD/6A-02991-13A1EE45; Wed, 25 Feb 2015 18:53:37 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-5.tower-31.messagelabs.com!1424890416!11040633!1 X-Originating-IP: [74.125.82.54] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12233 invoked from network); 25 Feb 2015 18:53:37 -0000 Received: from mail-wg0-f54.google.com (HELO mail-wg0-f54.google.com) (74.125.82.54) by server-5.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 25 Feb 2015 18:53:37 -0000 Received: by wggz12 with SMTP id z12so5619822wgg.2 for ; Wed, 25 Feb 2015 10:53:36 -0800 (PST) X-Received: by 10.194.192.167 with SMTP id hh7mr8973879wjc.151.1424890416670; Wed, 25 Feb 2015 10:53:36 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id kr5sm61071839wjc.1.2015.02.25.10.53.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Feb 2015 10:53:35 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 25 Feb 2015 18:52:56 +0000 Message-Id: <1424890381-4225-4-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1424890381-4225-1-git-send-email-julien.grall@linaro.org> References: <1424890381-4225-1-git-send-email-julien.grall@linaro.org> Cc: ian.campbell@citrix.com, Stefano Stabellini , manish.jaggi@caviumnetworks.com, Julien Grall , tim@xen.org, stefano.stabellini@citrix.com, Jan Beulich Subject: [Xen-devel] [PATCH v4 3/8] 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.182 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 Acked-by: Jan Beulich Acked-by: Stefano Stabellini \ Acked-by: Ian Campbell --- Changes in v4: - Add Ian's ack Changes in v3: - Add Stefano and Jan's ack 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 b93e7d8..4b83583 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)); } /* @@ -1383,7 +1383,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 ) @@ -1391,7 +1391,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), @@ -1426,7 +1426,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; @@ -1436,7 +1437,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,