Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Hanjun Guo <hanjun.guo@linaro.org>
To: Wei Huang <wei@redhat.com>, kvmarm@lists.cs.columbia.edu
Cc: kvm@vger.kernel.org, marc.zyngier@arm.com,
	christoffer.dall@linaro.org, pbonzini@redhat.com,
	drjones@redhat.com, a.spyridakis@virtualopensystems.com
Subject: Re: [PATCH V2 2/5] kvm: arm64: Dispatch virt GIC probing to device tree and ACPI
Date: Thu, 11 Jun 2015 19:34:23 +0800	[thread overview]
Message-ID: <5579723F.2040503@linaro.org> (raw)
In-Reply-To: <1433909767-12189-3-git-send-email-wei@redhat.com>

On 06/10/2015 12:16 PM, Wei Huang wrote:
> This patch creates a dispatch function to support virt GIC probing
> in both device tree (DT) and ACPI environment. kvm_vgic_hyp_init()
> will probe DT first. If failed, it will try ACPI.
>
> Signed-off-by: Wei Huang <wei@redhat.com>
> ---
>   include/kvm/arm_vgic.h | 18 +++++++++---------
>   virt/kvm/arm/vgic-v2.c |  8 ++++----
>   virt/kvm/arm/vgic-v3.c |  8 ++++----
>   virt/kvm/arm/vgic.c    | 42 +++++++++++++++++++++++++++++++-----------
>   4 files changed, 48 insertions(+), 28 deletions(-)
>
> diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
> index 133ea00..3ee732a 100644
> --- a/include/kvm/arm_vgic.h
> +++ b/include/kvm/arm_vgic.h
> @@ -332,17 +332,17 @@ int kvm_vgic_vcpu_active_irq(struct kvm_vcpu *vcpu);
>   #define vgic_initialized(k)	(!!((k)->arch.vgic.nr_cpus))
>   #define vgic_ready(k)		((k)->arch.vgic.ready)
>
> -int vgic_v2_probe(struct device_node *vgic_node,
> -		  const struct vgic_ops **ops,
> -		  const struct vgic_params **params);
> +int vgic_v2_dt_probe(struct device_node *vgic_node,
> +		     const struct vgic_ops **ops,
> +		     const struct vgic_params **params);
>   #ifdef CONFIG_ARM_GIC_V3
> -int vgic_v3_probe(struct device_node *vgic_node,
> -		  const struct vgic_ops **ops,
> -		  const struct vgic_params **params);
> +int vgic_v3_dt_probe(struct device_node *vgic_node,
> +		     const struct vgic_ops **ops,
> +		     const struct vgic_params **params);
>   #else
> -static inline int vgic_v3_probe(struct device_node *vgic_node,
> -				const struct vgic_ops **ops,
> -				const struct vgic_params **params)
> +static inline int vgic_v3_dt_probe(struct device_node *vgic_node,
> +				   const struct vgic_ops **ops,
> +				   const struct vgic_params **params)
>   {
>   	return -ENODEV;
>   }
> diff --git a/virt/kvm/arm/vgic-v2.c b/virt/kvm/arm/vgic-v2.c
> index f9b9c7c..295996f 100644
> --- a/virt/kvm/arm/vgic-v2.c
> +++ b/virt/kvm/arm/vgic-v2.c
> @@ -167,7 +167,7 @@ static const struct vgic_ops vgic_v2_ops = {
>   static struct vgic_params vgic_v2_params;
>
>   /**
> - * vgic_v2_probe - probe for a GICv2 compatible interrupt controller in DT
> + * vgic_v2_dt_probe - probe for a GICv2 compatible interrupt controller in DT
>    * @node:	pointer to the DT node
>    * @ops: 	address of a pointer to the GICv2 operations
>    * @params:	address of a pointer to HW-specific parameters
> @@ -176,9 +176,9 @@ static struct vgic_params vgic_v2_params;
>    * in *ops and the HW parameters in *params. Returns an error code
>    * otherwise.
>    */
> -int vgic_v2_probe(struct device_node *vgic_node,
> -		  const struct vgic_ops **ops,
> -		  const struct vgic_params **params)
> +int vgic_v2_dt_probe(struct device_node *vgic_node,
> +		     const struct vgic_ops **ops,
> +		     const struct vgic_params **params)
>   {
>   	int ret;
>   	struct resource vctrl_res;
> diff --git a/virt/kvm/arm/vgic-v3.c b/virt/kvm/arm/vgic-v3.c
> index dff0602..91814e2 100644
> --- a/virt/kvm/arm/vgic-v3.c
> +++ b/virt/kvm/arm/vgic-v3.c
> @@ -211,7 +211,7 @@ static const struct vgic_ops vgic_v3_ops = {
>   static struct vgic_params vgic_v3_params;
>
>   /**
> - * vgic_v3_probe - probe for a GICv3 compatible interrupt controller in DT
> + * vgic_v3_dt_probe - probe for a GICv3 compatible interrupt controller in DT
>    * @node:	pointer to the DT node
>    * @ops: 	address of a pointer to the GICv3 operations
>    * @params:	address of a pointer to HW-specific parameters
> @@ -220,9 +220,9 @@ static struct vgic_params vgic_v3_params;
>    * in *ops and the HW parameters in *params. Returns an error code
>    * otherwise.
>    */
> -int vgic_v3_probe(struct device_node *vgic_node,
> -		  const struct vgic_ops **ops,
> -		  const struct vgic_params **params)
> +int vgic_v3_dt_probe(struct device_node *vgic_node,
> +		     const struct vgic_ops **ops,
> +		     const struct vgic_params **params)
>   {
>   	int ret = 0;
>   	u32 gicv_idx;
> diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
> index 78fb820..b4010f0 100644
> --- a/virt/kvm/arm/vgic.c
> +++ b/virt/kvm/arm/vgic.c
> @@ -25,6 +25,7 @@
>   #include <linux/of_address.h>
>   #include <linux/of_irq.h>
>   #include <linux/uaccess.h>
> +#include <linux/acpi.h>
>
>   #include <linux/irqchip/arm-gic.h>
>
> @@ -2088,32 +2089,51 @@ static struct notifier_block vgic_cpu_nb = {
>   };
>
>   static const struct of_device_id vgic_ids[] = {
> -	{ .compatible = "arm,cortex-a15-gic",	.data = vgic_v2_probe, },
> -	{ .compatible = "arm,cortex-a7-gic",	.data = vgic_v2_probe, },
> -	{ .compatible = "arm,gic-400",		.data = vgic_v2_probe, },
> -	{ .compatible = "arm,gic-v3",		.data = vgic_v3_probe, },
> +	{ .compatible = "arm,cortex-a15-gic",	.data = vgic_v2_dt_probe, },
> +	{ .compatible = "arm,cortex-a7-gic",	.data = vgic_v2_dt_probe, },
> +	{ .compatible = "arm,gic-400",		.data = vgic_v2_dt_probe, },
> +	{ .compatible = "arm,gic-v3",		.data = vgic_v3_dt_probe, },
>   	{},
>   };
>
> -int kvm_vgic_hyp_init(void)
> +static int kvm_vgic_dt_probe(void)
>   {
>   	const struct of_device_id *matched_id;
>   	const int (*vgic_probe)(struct device_node *,const struct vgic_ops **,
>   				const struct vgic_params **);
>   	struct device_node *vgic_node;
> -	int ret;
>
>   	vgic_node = of_find_matching_node_and_match(NULL,
>   						    vgic_ids, &matched_id);
> -	if (!vgic_node) {
> -		kvm_err("error: no compatible GIC node found\n");
> +	if (!vgic_node)
>   		return -ENODEV;
> -	}
>
>   	vgic_probe = matched_id->data;
> -	ret = vgic_probe(vgic_node, &vgic_ops, &vgic);
> -	if (ret)
> +
> +	return vgic_probe(vgic_node, &vgic_ops, &vgic);
> +}
> +
> +#ifdef CONFIG_ACPI
> +static int kvm_vgic_acpi_probe(void)
> +{
> +	return -EINVAL;
> +}
> +#endif /* CONFIG_ACPI */
> +
> +int kvm_vgic_hyp_init(void)
> +{
> +	int ret;
> +
> +	ret = kvm_vgic_dt_probe();
> +#ifdef CONFIG_ACPI
> +	if (ret && !acpi_disabled)
> +		ret = kvm_vgic_acpi_probe();
> +#endif

How about:

#ifdef CONFIG_ACPI
static int kvm_vgic_acpi_probe(void)
{
	return -EINVAL;
}
#else
static inline int kvm_vgic_acpi_probe(void) { }
#endif /* CONFIG_ACPI */

Then no need for #ifdef CONFIG_ACPI ... #endif in the function.

Thanks
Hanjun

  reply	other threads:[~2015-06-11 11:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-10  4:16 [PATCH V2 0/5] Enable ACPI support for KVM ARM Wei Huang
2015-06-10  4:16 ` [PATCH V2 1/5] kvm: arm64: Enable ACPI support for virt arch timer Wei Huang
2015-06-10 12:51   ` Andrew Jones
2015-06-11 11:27   ` Hanjun Guo
2015-06-10  4:16 ` [PATCH V2 2/5] kvm: arm64: Dispatch virt GIC probing to device tree and ACPI Wei Huang
2015-06-11 11:34   ` Hanjun Guo [this message]
2015-06-10  4:16 ` [PATCH V2 3/5] kvm: arm64: Detect GIC version for proper ACPI vGIC probing Wei Huang
2015-06-10 12:53   ` Andrew Jones
2015-06-10 16:43   ` Marc Zyngier
2015-06-11  4:51     ` Wei Huang
2015-06-11  7:54       ` Marc Zyngier
2015-06-10  4:16 ` [PATCH V2 4/5] kvm: arm64: Implement ACPI probing code for GICv2 Wei Huang
2015-06-10  4:16 ` [PATCH V2 5/5] kvm: arm64: Implement ACPI probing code for GICv3 Wei Huang
2015-06-10 13:04   ` Andrew Jones
2015-06-10 13:23 ` [PATCH V2 0/5] Enable ACPI support for KVM ARM Andrew Jones
2015-06-11 11:47   ` Hanjun Guo
2016-01-14  0:27 ` Graeme Gregory

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=5579723F.2040503@linaro.org \
    --to=hanjun.guo@linaro.org \
    --cc=a.spyridakis@virtualopensystems.com \
    --cc=christoffer.dall@linaro.org \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=marc.zyngier@arm.com \
    --cc=pbonzini@redhat.com \
    --cc=wei@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox