From: Manish Jaggi <mjaggi@caviumnetworks.com>
To: Julien Grall <julien.grall@citrix.com>, xen-devel@lists.xenproject.org
Cc: tim@xen.org, Julien Grall <julien.grall@linaro.org>,
stefano.stabellini@citrix.com, ian.campbell@citrix.com,
Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH v6 07/19] xen/passthrough: Introduce iommu_construct
Date: Wed, 29 Apr 2015 05:37:50 +0530 [thread overview]
Message-ID: <554020D6.3070102@caviumnetworks.com> (raw)
In-Reply-To: <1430231563-25648-8-git-send-email-julien.grall@citrix.com>
On 28/04/15 8:02 pm, Julien Grall wrote:
> From: Julien Grall <julien.grall@linaro.org>
>
> This new function will correctly initialize the IOMMU page table for the
> current domain.
>
> Also use it in iommu_assign_dt_device even though the current IOMMU
> implementation on ARM shares P2M with the processor.
>
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> Acked-by: Jan Beulich <jbeulich@suse.com>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
>
> ---
> Changes in v5:
> - Limit the scope of rc
> - Add Jan's and Ian's ack
>
> Changes in v4:
> - Move memory_type_changed in iommu_construct. Added by commit
> 06ed8cc "x86: avoid needless EPT table ajustment and cache
> flush"
> - And an ASSERT and a comment in iommu_assign_dt_device to
> explain why the call is safe for DOM0
>
> Changes in v3:
> - The ASSERT in iommu_construct was redundant with the if ()
> - Remove d->need_iommu = 1 in assign_device has it's already
> done by iommu_construct.
> - Simplify the code in the caller of iommu_construct
>
> Changes in v2:
> - Add missing Signed-off-by
> - Rename iommu_buildup to iommu_construct
> ---
> xen/drivers/passthrough/arm/iommu.c | 6 ++++++
> xen/drivers/passthrough/device_tree.c | 12 ++++++++++++
> xen/drivers/passthrough/iommu.c | 26 ++++++++++++++++++++++++++
> xen/drivers/passthrough/pci.c | 22 ++++------------------
> xen/include/xen/iommu.h | 2 ++
> 5 files changed, 50 insertions(+), 18 deletions(-)
>
> diff --git a/xen/drivers/passthrough/arm/iommu.c b/xen/drivers/passthrough/arm/iommu.c
> index 3007b99..9234657 100644
> --- a/xen/drivers/passthrough/arm/iommu.c
> +++ b/xen/drivers/passthrough/arm/iommu.c
> @@ -68,3 +68,9 @@ void arch_iommu_domain_destroy(struct domain *d)
> {
> iommu_dt_domain_destroy(d);
> }
> +
> +int arch_iommu_populate_page_table(struct domain *d)
> +{
> + /* The IOMMU shares the p2m with the CPU */
> + return -ENOSYS;
> +}
> diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c
> index 377d41d..4d82a09 100644
> --- a/xen/drivers/passthrough/device_tree.c
> +++ b/xen/drivers/passthrough/device_tree.c
> @@ -41,6 +41,18 @@ int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev)
> if ( !list_empty(&dev->domain_list) )
> goto fail;
>
> + if ( need_iommu(d) <= 0 )
> + {
> + /*
> + * The hwdom is forced to use IOMMU for protecting assigned
> + * device. Therefore the IOMMU data is already set up.
> + */
> + ASSERT(!is_hardware_domain(d));
> + rc = iommu_construct(d);
> + if ( rc )
> + goto fail;
> + }
> +
> rc = hd->platform_ops->assign_device(d, 0, dt_to_dev(dev));
>
> if ( rc )
> diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
> index 92ea26f..ae42aae 100644
> --- a/xen/drivers/passthrough/iommu.c
> +++ b/xen/drivers/passthrough/iommu.c
> @@ -187,6 +187,32 @@ void iommu_teardown(struct domain *d)
> tasklet_schedule(&iommu_pt_cleanup_tasklet);
> }
>
> +int iommu_construct(struct domain *d)
> +
What is the meaning of construct here. How it is different from init ?
Also iommu refers to iommu_domain or there is some other datastructure
which is being updated ?
Please write function header comments or use similar naming prefix in code.
> + if ( need_iommu(d) > 0 )
> + return 0;
> +
> + if ( !iommu_use_hap_pt(d) )
> + {
> + int rc;
> +
> + rc = arch_iommu_populate_page_table(d);
> + if ( rc )
> + return rc;
> + }
> +
> + d->need_iommu = 1;
> + /*
> + * There may be dirty cache lines when a device is assigned
> + * and before need_iommu(d) becoming true, this will cause
> + * memory_type_changed lose effect if memory type changes.
> + * Call memory_type_changed here to amend this.
> + */
> + memory_type_changed(d);
> +
> + return 0;
> +}
> +
> void iommu_domain_destroy(struct domain *d)
> {
> struct hvm_iommu *hd = domain_hvm_iommu(d);
> diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
> index 9f3413c..af26423 100644
> --- a/xen/drivers/passthrough/pci.c
> +++ b/xen/drivers/passthrough/pci.c
> @@ -1358,25 +1358,11 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn)
> if ( !spin_trylock(&pcidevs_lock) )
> return -ERESTART;
>
> - if ( need_iommu(d) <= 0 )
> + rc = iommu_construct(d);
> + if ( rc )
> {
> - if ( !iommu_use_hap_pt(d) )
> - {
> - rc = arch_iommu_populate_page_table(d);
> - if ( rc )
> - {
> - spin_unlock(&pcidevs_lock);
> - return rc;
> - }
> - }
> - d->need_iommu = 1;
> - /*
> - * There may be dirty cache lines when a device is assigned
> - * and before need_iommu(d) becoming true, this will cause
> - * memory_type_changed lose effect if memory type changes.
> - * Call memory_type_changed here to amend this.
> - */
> - memory_type_changed(d);
> + spin_unlock(&pcidevs_lock);
> + return rc;
> }
>
> pdev = pci_get_pdev_by_domain(hardware_domain, seg, bus, devfn);
> diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
> index bf4aff0..e9d2d5c 100644
> --- a/xen/include/xen/iommu.h
> +++ b/xen/include/xen/iommu.h
> @@ -65,6 +65,8 @@ int arch_iommu_domain_init(struct domain *d);
> int arch_iommu_populate_page_table(struct domain *d);
> void arch_iommu_check_autotranslated_hwdom(struct domain *d);
>
> +int iommu_construct(struct domain *d);
> +
> /* Function used internally, use iommu_domain_destroy */
> void iommu_teardown(struct domain *d);
>
next prev parent reply other threads:[~2015-04-29 0:08 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-28 14:32 [PATCH v6 00/19] xen/arm: Add support for non-PCI passthrough Julien Grall
2015-04-28 14:32 ` [PATCH v6 01/19] xen/arm: Let the toolstack configure the number of SPIs Julien Grall
2015-04-28 14:32 ` [PATCH v6 02/19] xen/arm: vgic: Add spi_to_pending Julien Grall
2015-04-28 14:32 ` [PATCH v6 03/19] xen/arm: Release IRQ routed to a domain when it's destroying Julien Grall
2015-04-28 14:32 ` [PATCH v6 04/19] xen/arm: Implement hypercall DOMCTL_{, un}bind_pt_pirq Julien Grall
2015-04-28 14:32 ` [PATCH v6 05/19] xen: guestcopy: Provide an helper to safely copy string from guest Julien Grall
2015-04-28 14:32 ` [PATCH v6 06/19] xen/dts: Provide an helper to get a DT node from a path provided by a guest Julien Grall
2015-04-28 14:32 ` [PATCH v6 07/19] xen/passthrough: Introduce iommu_construct Julien Grall
2015-04-29 0:07 ` Manish Jaggi [this message]
2015-04-28 14:32 ` [PATCH v6 08/19] xen/passthrough: arm: release the DT devices assigned to a guest earlier Julien Grall
2015-04-28 14:32 ` [PATCH v6 09/19] xen/passthrough: iommu_deassign_device_dt: By default reassign device to nobody Julien Grall
2015-04-28 14:32 ` [PATCH v6 10/19] xen/iommu: arm: Wire iommu DOMCTL for ARM Julien Grall
2015-04-28 14:32 ` [PATCH v6 11/19] xen/xsm: Add helpers to check permission for device tree passthrough Julien Grall
2015-04-28 14:32 ` [PATCH v6 12/19] xen/passthrough: Extend XEN_DOMCTL_*assign_device to support DT device Julien Grall
2015-04-28 14:32 ` [PATCH v6 13/19] tools/libxl: Create a per-arch function to map IRQ to a domain Julien Grall
2015-04-28 14:32 ` [PATCH v6 14/19] tools/libxl: Check if fdt_{first, next}_subnode are present in libfdt Julien Grall
2015-05-08 14:27 ` Ian Campbell
2015-05-08 14:49 ` Julien Grall
2015-04-28 14:32 ` [PATCH v6 15/19] tools/(lib)xl: Add partial device tree support for ARM Julien Grall
2015-04-28 14:32 ` [PATCH v6 16/19] tools/libxl: arm: Use an higher value for the GIC phandle Julien Grall
2015-04-28 14:32 ` [PATCH v6 17/19] libxl: Add support for Device Tree passthrough Julien Grall
2015-04-28 14:32 ` [PATCH v6 18/19] xl: Add new option dtdev Julien Grall
2015-04-28 14:32 ` [PATCH v6 19/19] docs/misc: arm: Add documentation about Device Tree passthrough Julien Grall
2015-05-08 13:48 ` [PATCH v6 00/19] xen/arm: Add support for non-PCI passthrough Ian Campbell
2015-05-08 13:59 ` Jan Beulich
2015-05-08 14:20 ` Ian Campbell
2015-05-08 15:01 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=554020D6.3070102@caviumnetworks.com \
--to=mjaggi@caviumnetworks.com \
--cc=ian.campbell@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@citrix.com \
--cc=julien.grall@linaro.org \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.