From: Julien Grall <julien.grall@linaro.org>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel@lists.xenproject.org, stefano.stabellini@citrix.com,
ian.campbell@citrix.com, Xiantao Zhang <xiantao.zhang@intel.com>,
tim@xen.org
Subject: Re: [PATCH v2 08/15] xen/passthrough: iommu: Split generic IOMMU code
Date: Mon, 24 Feb 2014 12:46:50 +0000 [thread overview]
Message-ID: <530B3F3A.6000202@linaro.org> (raw)
In-Reply-To: <530B2F8A020000780011EAA4@nat28.tlf.novell.com>
Hi Jan,
On 02/24/2014 10:39 AM, Jan Beulich wrote:
>>>> On 23.02.14 at 23:16, Julien Grall <julien.grall@linaro.org> wrote:
>> +int iommu_do_domctl(
>> + struct xen_domctl *domctl, struct domain *d,
>> + XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>> {
>> - const struct iommu_ops *ops = iommu_get_ops();
>> - if ( iommu_intremap )
>> - ops->read_msi_from_ire(msi_desc, msg);
>> -}
>> + int ret = 0;
>>
>> -unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg)
>> -{
>> - const struct iommu_ops *ops = iommu_get_ops();
>> - return ops->read_apic_from_ire(apic, reg);
>> -}
>> + if ( !iommu_enabled )
>> + return -ENOSYS;
>>
>> -int __init iommu_setup_hpet_msi(struct msi_desc *msi)
>> -{
>> - const struct iommu_ops *ops = iommu_get_ops();
>> - return ops->setup_hpet_msi ? ops->setup_hpet_msi(msi) : -ENODEV;
>> -}
>> + switch ( domctl->cmd )
>> + {
>> +#ifdef HAS_PCI
>> + case XEN_DOMCTL_get_device_group:
>> + case XEN_DOMCTL_test_assign_device:
>> + case XEN_DOMCTL_assign_device:
>> + case XEN_DOMCTL_deassign_device:
>> + ret = iommu_do_pci_domctl(domctl, d, u_domctl);
>> + break;
>> +#endif
>> + default:
>> + ret = -ENOSYS;
>> + }
>
> Please simply have the default case chain to iommu_do_pci_domctl(),
> avoiding the need to change two source files when new sub-ops get
> added.
I wrote in this manner because we will add soon "iommu_do_dt_domctl" to
handle DOMCTL for device tree assignment.
For one of this function we will have to deal with this trick. Or ... we
can do:
ret = iommu_do_pci_domctl(...)
if ( ret != ENOSYS )
return ret;
ret = iommu_do_dt_domctl(...)
IHMO, I would prefer the former solution.
>
> Also, last case in the set of case statements or not - the default
> case should also have a break statement.
I will add it.
>> --- a/xen/drivers/passthrough/pci.c
>> +++ b/xen/drivers/passthrough/pci.c
>> ...
>> @@ -980,6 +983,440 @@ static int __init setup_dump_pcidevs(void)
>> }
>> __initcall(setup_dump_pcidevs);
>>
>> +static int iommu_populate_page_table(struct domain *d)
>> +{
>
> Now why is this function being moved here? It doesn't appear to
> have anything PCI specific at all.
Because this function is only used in assign_device.
I also remember this function can't work on ARM (arch.relmem_list
doesn't exists). I will move this code in x86/iommu.c because it's seems
architecture initialization.
>
>> --- /dev/null
>> +++ b/xen/drivers/passthrough/x86/iommu.c
>> @@ -0,0 +1,65 @@
>> +/*
>> + * This program is free software; you can redistribute it and/or modify it
>> + * under the terms and conditions of the GNU General Public License,
>> + * version 2, as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope it will be useful, but WITHOUT
>> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
>> + * more details.
>> + *
>> + * You should have received a copy of the GNU General Public License along with
>> + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
>> + * Place - Suite 330, Boston, MA 02111-1307 USA.
>> + */
>> +
>> +#include <xen/sched.h>
>> +#include <xen/iommu.h>
>> +#include <xen/paging.h>
>> +#include <xen/guest_access.h>
>> +#include <xen/event.h>
>> +#include <xen/softirq.h>
>> +#include <xsm/xsm.h>
>> +
>> +void iommu_update_ire_from_apic(
>> + unsigned int apic, unsigned int reg, unsigned int value)
>> +{
>> + const struct iommu_ops *ops = iommu_get_ops();
>> + ops->update_ire_from_apic(apic, reg, value);
>> +}
>
> While one might argue that this one is x86-specific (albeit from past
> IA64 days we know it isn't entirely), ...
>
>> +
>> +int iommu_update_ire_from_msi(
>> + struct msi_desc *msi_desc, struct msi_msg *msg)
>> +{
>> + const struct iommu_ops *ops = iommu_get_ops();
>> + return iommu_intremap ? ops->update_ire_from_msi(msi_desc, msg) : 0;
>> +}
>
> ... this one clearly isn't - I'm sure once you support PCI on ARM, you
> will also want/need to support MSI. (The same then of course goes
> for the respective functions' declarations.)
Right, I guess it's the same for iommu_read_msi_from_ire.
>> --- /dev/null
>> +++ b/xen/include/asm-x86/iommu.h
>> @@ -0,0 +1,46 @@
>> +/*
>> + * This program is free software; you can redistribute it and/or modify it
>> + * under the terms and conditions of the GNU General Public License,
>> + * version 2, as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope it will be useful, but WITHOUT
>> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
>> + * more details.
>> + *
>> + * You should have received a copy of the GNU General Public License along with
>> + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
>> + * Place - Suite 330, Boston, MA 02111-1307 USA.
>> +*/
>> +#ifndef __ARCH_X86_IOMMU_H__
>> +#define __ARCH_X86_IOMMU_H__
>> +
>> +#define MAX_IOMMUS 32
>> +
>> +#include <asm/msi.h>
>
> Please don't, if at all possible.
I'm not sure to understand ... what do you mean? Don't include "asm/msi.h"?
>> @@ -84,52 +82,56 @@ void free_hvm_irq_dpci(struct hvm_irq_dpci *dpci);
>> bool_t pt_irq_need_timer(uint32_t flags);
>>
>> #define PT_IRQ_TIME_OUT MILLISECS(8)
>> +#endif /* HAS_PCI */
>>
>> +#ifdef CONFIG_X86
>> struct msi_desc;
>> struct msi_msg;
>> +#endif /* CONFIG_X86 */
>
> Hardly - this again is a direct descendant from PCI.
I will #ifdef HAS_PCI.
>> +#ifdef CONFIG_X86
>> void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value);
>> 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);
>> unsigned int (*read_apic_from_ire)(unsigned int apic, unsigned int reg);
>> int (*setup_hpet_msi)(struct msi_desc *);
>> + void (*share_p2m)(struct domain *d);
>> +#endif /* CONFIG_X86 */
>
> Is that last one really x86-specific in any way?
On ARM, P2M are share by default. You don't need to call this function
explicitly. So I think we can safely say it's x86-specific.
Developper won't call this function by mistake.
Cheers,
--
Julien Grall
next prev parent reply other threads:[~2014-02-24 12:46 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-23 22:16 [PATCH v2 00/15] IOMMU support for ARM Julien Grall
2014-02-23 22:16 ` [PATCH v2 01/15] xen/common: grant-table: only call IOMMU if paging mode translate is disabled Julien Grall
2014-02-23 22:16 ` [PATCH v2 02/15] xen/passthrough: vtd: Don't export iommu_domain_teardown Julien Grall
2014-02-24 11:34 ` Jan Beulich
2014-02-24 12:10 ` Julien Grall
2014-02-24 12:18 ` Jan Beulich
2014-02-24 12:21 ` Julien Grall
2014-02-23 22:16 ` [PATCH v2 03/15] xen/passthrough: vtd: Don't export iommu_set_pgd Julien Grall
2014-02-23 22:16 ` [PATCH v2 04/15] xen/dts: Add dt_property_read_bool Julien Grall
2014-02-23 22:16 ` [PATCH v2 05/15] xen/dts: Add dt_parse_phandle_with_args and dt_parse_phandle Julien Grall
2014-02-23 22:16 ` [PATCH v2 06/15] xen/passthrough: rework dom0_pvh_reqs to use it also on ARM Julien Grall
2014-02-23 22:16 ` [PATCH v2 07/15] xen/passthrough: iommu: Don't need to map dom0 page when the PT is shared Julien Grall
2014-02-23 22:16 ` [PATCH v2 08/15] xen/passthrough: iommu: Split generic IOMMU code Julien Grall
2014-02-24 10:39 ` Jan Beulich
2014-02-24 12:46 ` Julien Grall [this message]
2014-02-24 13:13 ` Jan Beulich
2014-02-23 22:16 ` [PATCH v2 09/15] xen/passthrough: iommu: Introduce arch specific code Julien Grall
2014-02-24 10:44 ` Jan Beulich
2014-02-24 11:10 ` Andrew Cooper
2014-02-24 13:05 ` Julien Grall
2014-02-24 12:57 ` Julien Grall
2014-02-24 13:16 ` Jan Beulich
2014-02-24 13:33 ` Julien Grall
2014-02-23 22:16 ` [PATCH v2 10/15] xen/passthrough: iommu: Basic support of device tree assignment Julien Grall
2014-02-24 10:47 ` Jan Beulich
2014-02-24 13:07 ` Julien Grall
2014-02-23 22:16 ` [PATCH v2 11/15] xen/passthrough: Introduce IOMMU ARM architecture Julien Grall
2014-02-23 22:16 ` [PATCH v2 12/15] MAINTAINERS: Add drivers/passthrough/arm Julien Grall
2014-02-23 22:16 ` [PATCH v2 13/15] xen/arm: Don't give IOMMU devices to dom0 when iommu is disabled Julien Grall
2014-02-23 22:16 ` [PATCH v2 14/15] xen/arm: Add the property "protected-devices" in the hypervisor node Julien Grall
2014-02-24 11:54 ` Stefano Stabellini
2014-02-24 12:05 ` Julien Grall
2014-02-23 22:16 ` [PATCH v2 15/15] drivers/passthrough: arm: Add support for SMMU drivers Julien Grall
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=530B3F3A.6000202@linaro.org \
--to=julien.grall@linaro.org \
--cc=JBeulich@suse.com \
--cc=ian.campbell@citrix.com \
--cc=stefano.stabellini@citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.org \
--cc=xiantao.zhang@intel.com \
/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.