From: Manish Jaggi <mjaggi@caviumnetworks.com>
To: Julien Grall <julien.grall@linaro.org>, xen-devel@lists.xenproject.org
Cc: Keir Fraser <keir@xen.org>,
ian.campbell@citrix.com,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
manish.jaggi@caviumnetworks.com, tim@xen.org,
stefano.stabellini@citrix.com, Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH v4 2/8] xen/arm: Introduce a generic way to describe device
Date: Mon, 30 Mar 2015 15:21:48 +0530 [thread overview]
Message-ID: <55191CB4.6000309@caviumnetworks.com> (raw)
In-Reply-To: <1424890381-4225-3-git-send-email-julien.grall@linaro.org>
On Thursday 26 February 2015 12:22 AM, Julien Grall wrote:
> Currently, Xen is supporting PCI and Platform device (based on Device Tree).
>
> While Xen only supports Platform device on ARM, Xen will gain support of
> PCI soon.
>
> Some drivers, such as IOMMU drivers, may handle PCI and platform device in
> the same way. Only few lines of code differs.
>
> Rather than requesting to provide 2 set of functions (one for PCI and
> one for platform device), introduce a generic structure "device" which
> is embedded in each specialized device.
>
> As x86 only supports PCI, introduce a new type device_t which will be an
> alias to pci_dev for this architecture. It will avoid to add a new field
> for this place.
>
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> Acked-by: Jan Beulich <jbeulich@suse.com>
> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> CC: Keir Fraser <keir@xen.org>
> CC: Andrew Cooper <andrew.cooper3@citrix.com>
>
> ---
> Changes in v4:
> - Add Jan and Stefano's ack
> - Typoes
>
> Changes in v3:
> - Drop common/device.c as it wasn't used after v1
>
> Changes in v2:
> - As x86 will only support PCI, only introduce the generic
> device on ARM
> - Introduce a typedef device_t to be used in common code
> - Drop the PCI code for ARM for now. It will be reintroduced
> when PCI support will be added
> - s#asm/device.h#xen/device.h# is not anymore needed
> ---
> xen/common/device_tree.c | 3 +++
> xen/include/asm-arm/device.h | 26 ++++++++++++++++++++++++++
> xen/include/asm-x86/device.h | 25 +++++++++++++++++++++++++
> xen/include/xen/device_tree.h | 13 +++++++++++++
> xen/include/xen/iommu.h | 1 +
> xen/include/xen/pci.h | 1 +
> 6 files changed, 69 insertions(+)
> create mode 100644 xen/include/asm-x86/device.h
>
> diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
> index 34a1b9e..d1c716f 100644
> --- a/xen/common/device_tree.c
> +++ b/xen/common/device_tree.c
> @@ -1454,6 +1454,9 @@ static unsigned long __init unflatten_dt_node(const void *fdt,
> ((char *)pp->value)[sz - 1] = 0;
> dt_dprintk("fixed up name for %s -> %s\n", pathp,
> (char *)pp->value);
> + /* Generic device initialization */
> + np->dev.type = DEV_DT;
> + np->dev.of_node = np;
> }
> }
> if ( allnextpp )
> diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h
> index b6b32bc..1cedd49 100644
> --- a/xen/include/asm-arm/device.h
> +++ b/xen/include/asm-arm/device.h
> @@ -2,8 +2,34 @@
> #define __ASM_ARM_DEVICE_H
>
> #include <xen/init.h>
> +
> +enum device_type
> +{
> + DEV_DT,
> +};
> +
> +struct dev_archdata {
> + void *iommu; /* IOMMU private data */
> +};
> +
> +/* struct device - The basic device structure */
> +struct device
> +{
> + enum device_type type;
> +#ifdef HAS_DEVICE_TREE
> + struct dt_device_node *of_node; /* Used by drivers imported from Linux */
> +#endif
> + struct dev_archdata archdata;
> +};
> +
> +typedef struct device device_t;
> +
> #include <xen/device_tree.h>
>
> +/* TODO: Correctly implement dev_is_pci when PCI is supported on ARM */
> +#define dev_is_pci(dev) ((void)(dev), 0)
> +#define dev_is_dt(dev) ((dev->type == DEV_DT)
> +
> enum device_class
> {
> DEVICE_SERIAL,
> diff --git a/xen/include/asm-x86/device.h b/xen/include/asm-x86/device.h
> new file mode 100644
> index 0000000..f2acc7e
> --- /dev/null
> +++ b/xen/include/asm-x86/device.h
> @@ -0,0 +1,25 @@
> +#ifndef __ASM_X86_DEVICE_H
> +#define __ASM_X86_DEVICE_H
> +
> +#include <xen/pci.h>
> +
> +/*
> + * x86 only supports PCI. Therefore it's possible to directly use
> + * pci_dev to avoid adding new field.
> + */
> +
> +typedef struct pci_dev device_t;
> +
> +#define dev_is_pci(dev) ((void)(dev), 1)
> +#define pci_to_dev(pci) (pci)
When HAS_PCI and HAS_PASSTHROUGH is enabled for ARM, pci_to_dev is
undefined for ARM and compilation fails.
How do you propose to fix this?
Should I add a device as a member in pci_dev, as you mentioned in the
commit "... embedded in each specialized device"
> +
> +#endif /* __ASM_X86_DEVICE_H */
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
> index 6502369..c8a0375 100644
> --- a/xen/include/xen/device_tree.h
> +++ b/xen/include/xen/device_tree.h
> @@ -11,7 +11,9 @@
> #define __XEN_DEVICE_TREE_H__
>
> #include <asm/byteorder.h>
> +#include <asm/device.h>
> #include <public/xen.h>
> +#include <xen/kernel.h>
> #include <xen/init.h>
> #include <xen/string.h>
> #include <xen/types.h>
> @@ -80,8 +82,19 @@ struct dt_device_node {
> /* IOMMU specific fields */
> bool is_protected;
> struct list_head domain_list;
> +
> + struct device dev;
> };
>
> +#define dt_to_dev(dt_node) (&(dt_node)->dev)
> +
> +static inline struct dt_device_node *dev_to_dt(struct device *dev)
> +{
> + ASSERT(dev->type == DEV_DT);
> +
> + return container_of(dev, struct dt_device_node, dev);
> +}
> +
> #define MAX_PHANDLE_ARGS 16
> struct dt_phandle_args {
> struct dt_device_node *np;
> diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
> index 8eb764a..ecb2627 100644
> --- a/xen/include/xen/iommu.h
> +++ b/xen/include/xen/iommu.h
> @@ -25,6 +25,7 @@
> #include <xen/pci.h>
> #include <public/hvm/ioreq.h>
> #include <public/domctl.h>
> +#include <asm/device.h>
> #include <asm/iommu.h>
>
> extern bool_t iommu_enable, iommu_enabled;
> diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
> index 5f295f3..3988ee68 100644
> --- a/xen/include/xen/pci.h
> +++ b/xen/include/xen/pci.h
> @@ -13,6 +13,7 @@
> #include <xen/irq.h>
> #include <xen/pci_regs.h>
> #include <xen/pfn.h>
> +#include <asm/device.h>
> #include <asm/pci.h>
>
> /*
next prev parent reply other threads:[~2015-03-30 9:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-25 18:52 [PATCH v4 0/8] xen/arm: Resync the SMMU driver with the Linux one Julien Grall
2015-02-25 18:52 ` [PATCH v4 1/8] xen/iommu: arm: Remove temporary the SMMU driver Julien Grall
2015-02-25 18:52 ` [PATCH v4 2/8] xen/arm: Introduce a generic way to describe device Julien Grall
2015-03-30 9:51 ` Manish Jaggi [this message]
2015-02-25 18:52 ` [PATCH v4 3/8] xen/iommu: Consolidate device assignment ops into a single set Julien Grall
2015-02-25 18:52 ` [PATCH v4 4/8] xen/arm: Describe devices supported by a driver with dt_device_match Julien Grall
2015-02-25 18:52 ` [PATCH v4 5/8] xen/iommu: arm: Import the SMMU driver from Linux Julien Grall
2015-02-25 18:52 ` [PATCH v4 6/8] xen/iommu: smmu: Add Xen specific code to be able to use the driver Julien Grall
2015-03-02 7:03 ` Manish Jaggi
2015-03-04 2:08 ` Manish Jaggi
2015-03-02 13:17 ` Ian Campbell
2015-03-02 13:45 ` Julien Grall
2015-03-02 13:54 ` Ian Campbell
2015-02-25 18:53 ` [PATCH v4 7/8] xen/iommu: smmu: Advertise when the SMMU support coherent table walk Julien Grall
2015-03-02 13:10 ` Ian Campbell
2015-03-02 15:23 ` Julien Grall
2015-03-02 16:24 ` Ian Campbell
2015-02-25 18:53 ` [PATCH v4 8/8] DO NOT APPLY xen/iommu: smmu: Changes to support Midway SMMU Julien Grall
2015-03-02 14:47 ` [PATCH v4 0/8] xen/arm: Resync the SMMU driver with the Linux one 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=55191CB4.6000309@caviumnetworks.com \
--to=mjaggi@caviumnetworks.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@linaro.org \
--cc=keir@xen.org \
--cc=manish.jaggi@caviumnetworks.com \
--cc=stefano.stabellini@citrix.com \
--cc=stefano.stabellini@eu.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.