From patchwork Fri Jan 30 18:49:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 44047 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C6F4320CA8 for ; Fri, 30 Jan 2015 18:51:45 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id n3sf3423654wiv.0 for ; Fri, 30 Jan 2015 10:51:45 -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=+jEZpffVI3kTMq02YavZWxuRs3Nk8VkdS0agraLA1Co=; b=VpeVJMdl2iC4emyT981r/8FFZmB16p4nqpY9WAjjckNAt2nHEBbnWcIKWZchgqsUVg fjKpNqq/xIMoE7/kRO7o9WrgPyxi/68x7hoUXXSeasB6qzmaQVgz4tVDO0LLFwvcxKnu 6kH5aHL5rmELqDWXrfQzqJdtlu/JHNM5MeN+Te5XytmyK9ZvWvlM1UtV0JzIjCdo7bDA 0AIrOBZlj1qHOX9RVQ1p6NeYAtiM5JHFmCcnPgFW8xBZuw8/Hd55GT9pqXsce0SLMu+3 wsXH1unnfRd5mYOr611lCIYO+YVySMaUgAyOZlOfu6tLd/sovS7UJY/8xOf5XvSxyD93 wwiw== X-Gm-Message-State: ALoCoQnNR/PR3M6i2oITL/eOpc8bpk21TaiZNSOBbnoPjpM7/igy+11oKGI+9VRgk9h6+3JFyaud X-Received: by 10.180.105.129 with SMTP id gm1mr19475wib.3.1422643905062; Fri, 30 Jan 2015 10:51:45 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.13 with SMTP id n13ls479230laa.80.gmail; Fri, 30 Jan 2015 10:51:44 -0800 (PST) X-Received: by 10.112.72.197 with SMTP id f5mr7868756lbv.21.1422643904764; Fri, 30 Jan 2015 10:51:44 -0800 (PST) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id yi9si10729516lbb.13.2015.01.30.10.51.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 Jan 2015 10:51:44 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id f15so37809076lbj.0 for ; Fri, 30 Jan 2015 10:51:44 -0800 (PST) X-Received: by 10.112.135.196 with SMTP id pu4mr7995744lbb.41.1422643904557; Fri, 30 Jan 2015 10:51:44 -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 h5csp377625lbj; Fri, 30 Jan 2015 10:51:43 -0800 (PST) X-Received: by 10.220.87.148 with SMTP id w20mr3980787vcl.59.1422643902781; Fri, 30 Jan 2015 10:51:42 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id u3si1369326vdv.62.2015.01.30.10.51.42 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 30 Jan 2015 10:51:42 -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 1YHGdx-0007E3-DD; Fri, 30 Jan 2015 18:50:13 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YHGdv-0007Cm-Fs for xen-devel@lists.xenproject.org; Fri, 30 Jan 2015 18:50:11 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id 68/D0-03000-262DBC45; Fri, 30 Jan 2015 18:50:10 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-11.tower-21.messagelabs.com!1422643810!13571481!1 X-Originating-IP: [209.85.212.181] 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 25125 invoked from network); 30 Jan 2015 18:50:10 -0000 Received: from mail-wi0-f181.google.com (HELO mail-wi0-f181.google.com) (209.85.212.181) by server-11.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 30 Jan 2015 18:50:10 -0000 Received: by mail-wi0-f181.google.com with SMTP id fb4so4421547wid.2 for ; Fri, 30 Jan 2015 10:50:10 -0800 (PST) X-Received: by 10.195.12.35 with SMTP id en3mr14853928wjd.129.1422643809961; Fri, 30 Jan 2015 10:50:09 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id n1sm169040wib.11.2015.01.30.10.50.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Jan 2015 10:50:09 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 30 Jan 2015 18:49:22 +0000 Message-Id: <1422643768-23614-8-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422643768-23614-1-git-send-email-julien.grall@linaro.org> References: <1422643768-23614-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v3 07/13] 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.169 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 --- 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 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,