From patchwork Fri Feb 5 17:07:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Huang X-Patchwork-Id: 8237611 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6226E9F3CD for ; Fri, 5 Feb 2016 17:07:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6D21B20392 for ; Fri, 5 Feb 2016 17:07:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 619FC20375 for ; Fri, 5 Feb 2016 17:07:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755569AbcBERHm (ORCPT ); Fri, 5 Feb 2016 12:07:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37154 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755443AbcBERHl (ORCPT ); Fri, 5 Feb 2016 12:07:41 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 162C1C0A9CD3; Fri, 5 Feb 2016 17:07:41 +0000 (UTC) Received: from apm-mustang-ev3-34.khw.lab.eng.bos.redhat.com (apm-mustang-ev3-34.khw.lab.eng.bos.redhat.com [10.16.184.128]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u15H7aS5017859; Fri, 5 Feb 2016 12:07:40 -0500 From: Wei Huang To: kvmarm@lists.cs.columbia.edu Cc: marc.zyngier@arm.com, christoffer.dall@linaro.org, kvm@vger.kernel.org, hanjun.guo@linaro.org, fu.wei@linaro.org, drjones@redhat.com, wei@redhat.com, al.stone@linaro.org Subject: [PATCH V1 3/7] KVM: GIC: Create a common probe function for GIC Date: Fri, 5 Feb 2016 12:07:30 -0500 Message-Id: <1454692054-8984-4-git-send-email-wei@redhat.com> In-Reply-To: <1454692054-8984-1-git-send-email-wei@redhat.com> References: <1454692054-8984-1-git-send-email-wei@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch creates common functions for both GICv2 and GICv3. The existing functions are renamed to new names specifically for DT. Signed-off-by: Wei Huang --- virt/kvm/arm/vgic-v2.c | 44 +++++++++++++++++++++++++++++++------------- virt/kvm/arm/vgic-v3.c | 37 ++++++++++++++++++++++++------------- 2 files changed, 55 insertions(+), 26 deletions(-) diff --git a/virt/kvm/arm/vgic-v2.c b/virt/kvm/arm/vgic-v2.c index 6540a6d..7dd5fb3 100644 --- a/virt/kvm/arm/vgic-v2.c +++ b/virt/kvm/arm/vgic-v2.c @@ -182,23 +182,16 @@ static const struct of_device_id vgic_v2_ids[] = { {}, }; -/** - * vgic_v2_probe - probe for a GICv2 compatible interrupt controller in DT - * @ops: address of a pointer to the GICv2 operations - * @params: address of a pointer to HW-specific parameters - * - * Returns 0 if a GICv2 has been found, with the low level operations - * in *ops and the HW parameters in *params. Returns an error code - * otherwise. +/* + * Returns 0 if a GICv2 can be found in DT and the details of GICv2 + * configuration are stored in *vgic. Otherwise returns an error code. */ -int vgic_v2_probe(const struct vgic_ops **ops, - const struct vgic_params **params) +static int vgic_v2_dt_probe(struct vgic_params *vgic) { int ret; struct resource vctrl_res; struct resource vcpu_res; struct device_node *vgic_node; - struct vgic_params *vgic = &vgic_v2_params; vgic_node = of_find_matching_node(NULL, vgic_v2_ids); if (!vgic_node) { @@ -269,8 +262,6 @@ int vgic_v2_probe(const struct vgic_ops **ops, vgic->type = VGIC_V2; vgic->max_gic_vcpus = VGIC_V2_MAX_CPUS; - *ops = &vgic_v2_ops; - *params = vgic; goto out; out_unmap: @@ -279,3 +270,30 @@ out: of_node_put(vgic_node); return ret; } + +/** + * vgic_v2_probe - probe for a GICv2 compatible interrupt controller + * @ops: address of a pointer to the GICv2 operations + * @params: address of a pointer to HW-specific parameters + * + * Returns 0 if a GICv2 has been found, with the low level operations + * in *ops and the HW parameters in *params. Returns an error code + * otherwise. + */ +int vgic_v2_probe(const struct vgic_ops **ops, + const struct vgic_params **params) +{ + int ret; + struct vgic_params *vgic = &vgic_v2_params; + + ret = vgic_v2_dt_probe(vgic); + if (ret) + goto err_out; + + *ops = &vgic_v2_ops; + *params = vgic; + + return 0; +err_out: + return ret; +} diff --git a/virt/kvm/arm/vgic-v3.c b/virt/kvm/arm/vgic-v3.c index 33a5fdf..b036134 100644 --- a/virt/kvm/arm/vgic-v3.c +++ b/virt/kvm/arm/vgic-v3.c @@ -220,23 +220,16 @@ static const struct of_device_id vgic_v3_ids[] = { {}, }; -/** - * vgic_v3_probe - probe for a GICv3 compatible interrupt controller in DT - * @ops: address of a pointer to the GICv3 operations - * @params: address of a pointer to HW-specific parameters - * - * Returns 0 if a GICv3 has been found, with the low level operations - * in *ops and the HW parameters in *params. Returns an error code - * otherwise. +/* + * Returns 0 if a GICv3 can be found in DT and the details of GICv3 + * configuration are stored in *vgic. Otherwise returns an error code. */ -int vgic_v3_probe(const struct vgic_ops **ops, - const struct vgic_params **params) +static int vgic_v3_dt_probe(struct vgic_params *vgic) { int ret = 0; u32 gicv_idx; struct resource vcpu_res; struct device_node *vgic_node; - struct vgic_params *vgic = &vgic_v3_params; vgic_node = of_find_matching_node(NULL, vgic_v3_ids); if (!vgic_node) { @@ -292,11 +285,29 @@ int vgic_v3_probe(const struct vgic_ops **ops, kvm_info("%s@%llx IRQ%d\n", vgic_node->name, vcpu_res.start, vgic->maint_irq); +out: + of_node_put(vgic_node); + return ret; +} +/** + * vgic_v3_probe - probe for a GICv3 compatible interrupt controller + * @ops: address of a pointer to the GICv3 operations + * @params: address of a pointer to HW-specific parameters + * + * Returns 0 if a GICv3 has been found, with the low level operations + * in *ops and the HW parameters in *params. Returns an error code + * otherwise. + */ +int vgic_v3_probe(const struct vgic_ops **ops, + const struct vgic_params **params) +{ + int ret = 0; + struct vgic_params *vgic = &vgic_v3_params; + + ret = vgic_v3_dt_probe(vgic); *ops = &vgic_v3_ops; *params = vgic; -out: - of_node_put(vgic_node); return ret; }