From patchwork Fri Nov 20 17:46:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 11921461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 429AAC2D0E4 for ; Fri, 20 Nov 2020 17:54:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 598192240B for ; Fri, 20 Nov 2020 17:54:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 598192240B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kaod.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgAcD-0000jg-9c for qemu-devel@archiver.kernel.org; Fri, 20 Nov 2020 12:54:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgAV4-0008UJ-KZ for qemu-devel@nongnu.org; Fri, 20 Nov 2020 12:47:14 -0500 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:58220) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kgAV2-00057J-I2 for qemu-devel@nongnu.org; Fri, 20 Nov 2020 12:47:09 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-381-DYWRbe43PmCKn5it_ST3jg-1; Fri, 20 Nov 2020 12:46:53 -0500 X-MC-Unique: DYWRbe43PmCKn5it_ST3jg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C4A76107AD29; Fri, 20 Nov 2020 17:46:51 +0000 (UTC) Received: from bahia.redhat.com (ovpn-112-44.ams2.redhat.com [10.36.112.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C24B5C1D5; Fri, 20 Nov 2020 17:46:50 +0000 (UTC) From: Greg Kurz To: qemu-devel@nongnu.org Subject: [PATCH for-6.0 2/8] spapr/xive: Introduce spapr_xive_nr_ends() Date: Fri, 20 Nov 2020 18:46:40 +0100 Message-Id: <20201120174646.619395-3-groug@kaod.org> In-Reply-To: <20201120174646.619395-1-groug@kaod.org> References: <20201120174646.619395-1-groug@kaod.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Received-SPF: softfail client-ip=207.211.30.44; envelope-from=groug@kaod.org; helo=us-smtp-delivery-44.mimecast.com X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric_L?= =?utf-8?q?e_Goater?= , David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We're going to kill the "nr_ends" field in a subsequent patch. Prepare ground by using an helper instead of peeking into the sPAPR XIVE structure directly. Signed-off-by: Greg Kurz --- include/hw/ppc/spapr_xive.h | 1 + hw/intc/spapr_xive.c | 23 ++++++++++++++--------- hw/intc/spapr_xive_kvm.c | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/hw/ppc/spapr_xive.h b/include/hw/ppc/spapr_xive.h index 26c8d90d7196..4b967f13c030 100644 --- a/include/hw/ppc/spapr_xive.h +++ b/include/hw/ppc/spapr_xive.h @@ -75,6 +75,7 @@ void spapr_xive_map_mmio(SpaprXive *xive); int spapr_xive_end_to_target(uint8_t end_blk, uint32_t end_idx, uint32_t *out_server, uint8_t *out_prio); +uint32_t spapr_xive_nr_ends(const SpaprXive *xive); /* * KVM XIVE device helpers diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index 60e0d5769dcc..f473ad9cba47 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -192,7 +192,7 @@ void spapr_xive_pic_print_info(SpaprXive *xive, Monitor *mon) uint32_t end_idx = xive_get_field64(EAS_END_INDEX, eas->w); XiveEND *end; - assert(end_idx < xive->nr_ends); + assert(end_idx < spapr_xive_nr_ends(xive)); end = &xive->endt[end_idx]; if (xive_end_is_valid(end)) { @@ -270,7 +270,7 @@ static void spapr_xive_reset(void *dev) } /* Clear all ENDs */ - for (i = 0; i < xive->nr_ends; i++) { + for (i = 0; i < spapr_xive_nr_ends(xive); i++) { spapr_xive_end_reset(&xive->endt[i]); } } @@ -288,6 +288,11 @@ static void spapr_xive_instance_init(Object *obj) xive->fd = -1; } +uint32_t spapr_xive_nr_ends(const SpaprXive *xive) +{ + return xive->nr_ends; +} + static void spapr_xive_realize(DeviceState *dev, Error **errp) { SpaprXive *xive = SPAPR_XIVE(dev); @@ -336,7 +341,7 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp) * Allocate the routing tables */ xive->eat = g_new0(XiveEAS, xive->nr_irqs); - xive->endt = g_new0(XiveEND, xive->nr_ends); + xive->endt = g_new0(XiveEND, spapr_xive_nr_ends(xive)); xive->nodename = g_strdup_printf("interrupt-controller@%" PRIx64, xive->tm_base + XIVE_TM_USER_PAGE * (1 << TM_SHIFT)); @@ -375,7 +380,7 @@ static int spapr_xive_get_end(XiveRouter *xrtr, { SpaprXive *xive = SPAPR_XIVE(xrtr); - if (end_idx >= xive->nr_ends) { + if (end_idx >= spapr_xive_nr_ends(xive)) { return -1; } @@ -389,7 +394,7 @@ static int spapr_xive_write_end(XiveRouter *xrtr, uint8_t end_blk, { SpaprXive *xive = SPAPR_XIVE(xrtr); - if (end_idx >= xive->nr_ends) { + if (end_idx >= spapr_xive_nr_ends(xive)) { return -1; } @@ -1138,7 +1143,7 @@ static target_ulong h_int_get_source_config(PowerPCCPU *cpu, /* EAS_END_BLOCK is unused on sPAPR */ end_idx = xive_get_field64(EAS_END_INDEX, eas.w); - assert(end_idx < xive->nr_ends); + assert(end_idx < spapr_xive_nr_ends(xive)); end = &xive->endt[end_idx]; nvt_blk = xive_get_field32(END_W6_NVT_BLOCK, end->w6); @@ -1216,7 +1221,7 @@ static target_ulong h_int_get_queue_info(PowerPCCPU *cpu, return H_P2; } - assert(end_idx < xive->nr_ends); + assert(end_idx < spapr_xive_nr_ends(xive)); end = &xive->endt[end_idx]; args[0] = xive->end_base + (1ull << (end_xsrc->esb_shift + 1)) * end_idx; @@ -1304,7 +1309,7 @@ static target_ulong h_int_set_queue_config(PowerPCCPU *cpu, return H_P2; } - assert(end_idx < xive->nr_ends); + assert(end_idx < spapr_xive_nr_ends(xive)); memcpy(&end, &xive->endt[end_idx], sizeof(XiveEND)); switch (qsize) { @@ -1470,7 +1475,7 @@ static target_ulong h_int_get_queue_config(PowerPCCPU *cpu, return H_P2; } - assert(end_idx < xive->nr_ends); + assert(end_idx < spapr_xive_nr_ends(xive)); end = &xive->endt[end_idx]; args[0] = 0; diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index 66bf4c06fe55..1566016f0e28 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -531,7 +531,7 @@ static int kvmppc_xive_get_queues(SpaprXive *xive, Error **errp) int i; int ret; - for (i = 0; i < xive->nr_ends; i++) { + for (i = 0; i < spapr_xive_nr_ends(xive); i++) { if (!xive_end_is_valid(&xive->endt[i])) { continue; } @@ -701,7 +701,7 @@ int kvmppc_xive_post_load(SpaprXive *xive, int version_id) assert(xive->fd != -1); /* Restore the ENDT first. The targetting depends on it. */ - for (i = 0; i < xive->nr_ends; i++) { + for (i = 0; i < spapr_xive_nr_ends(xive); i++) { if (!xive_end_is_valid(&xive->endt[i])) { continue; }