Received: by 2002:a19:2d51:0:0:0:0:0 with SMTP id t17csp1788124lft; Sat, 2 Jul 2022 00:37:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sOLpmSrRSWjJfjsdAGQdQe7r/BapT2b1mmO62VTUxhGfNRw4B9koHS+RNnkiRPM6ul3NEk X-Received: by 2002:a25:8887:0:b0:669:97f5:d0b8 with SMTP id d7-20020a258887000000b0066997f5d0b8mr19919394ybl.432.1656747432946; Sat, 02 Jul 2022 00:37:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656747432; cv=none; d=google.com; s=arc-20160816; b=DOTKR1sZWzjNpg157leZb0/tkNtKu2MQxCvPzkGXKUr2uE5ea81u9e8xyuxTfxGxV3 jQYmH0x0peeUYPGiGRGOd6GJWRjdMK4VXvUpmjxCfrrxw051h4apI9/cZTI1avNJXKt8 7sUsgCHBoGqiK0oAt006vokgU0t9wvBzCnvpB+xcYZEhqc/r+V8w9doDOwM6XS7DhquW gpm8MjfTU1NP8EmUATJ0m2IgEIY80A6shA7I0gxxALcXkkCoMirPt1cLO+ANYGaF2uQ/ HRy2YtWOXNUojkLCNe5qWQxTYzpIoWIbXDA9B7VIjDDWTouFVy9O4ur/FN4+xwbgBj2R KkXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=fZHpAcs8JyhgGXMZpICaz6hZyxwSP0Sr1/ADXeOeyCY=; b=SnFtapEakw7a2F+0z0Rr0YMGbjC04dZLRJSdh9ASnZD6a7Bux0J9Fas+DItdNM6jmk nGeLFIxE0Y2MveAOxsyXIGhPxRUK9gQCNYTlOxGZ6uQwJBXFgsjboxLuF2J2I+Zy8Mtp /Vccp803VpWfJbQy9EI27bxIg4ehmhBrGjMktPN2OCHft8R6KmPVrcvtylfy4ZP12qua 2dWjZIwmdhKIPTZX4N8LaPmkMgNfRcUGSx295AK+rIsoNiqp5LCcnG695adN46x3OVWC ip1rHFvMVec7KD6p8H2gAhdBwGdvbqsQKhvpKLvpbOE/ad6joPYCeAd9jaUTm25fgHrd 0TjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@pjd.dev header.s=fm1 header.b=mboDY+vF; dkim=fail header.i=@messagingengine.com header.s=i9e814621.fm2 header.b=pz7ZaQmT; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v144-20020a252f96000000b00668cd480945si31847281ybv.337.2022.07.02.00.37.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 02 Jul 2022 00:37:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@pjd.dev header.s=fm1 header.b=mboDY+vF; dkim=fail header.i=@messagingengine.com header.s=i9e814621.fm2 header.b=pz7ZaQmT; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Received: from localhost ([::1]:50674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7Xgm-0000hW-7y for alex.bennee@linaro.org; Sat, 02 Jul 2022 03:37:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7XgY-0000hH-Mg; Sat, 02 Jul 2022 03:36:58 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:57713) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7XgT-0003SE-9n; Sat, 02 Jul 2022 03:36:58 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 8E78F580B5B; Sat, 2 Jul 2022 03:36:49 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sat, 02 Jul 2022 03:36:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pjd.dev; h=cc:cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1656747409; x= 1656751009; bh=fZHpAcs8JyhgGXMZpICaz6hZyxwSP0Sr1/ADXeOeyCY=; b=m boDY+vF6DVww7gyebrkzHoxO5JPRHf/fGRSp3IuUFnsAF2XaTJiqrx6FuXBUO5pE pu7+/ZK+eYfCbtuTUAY9KvkecF6OL+NbfejmCb9ugBtdmZSGWu4/tDKRTWmT2Ev0 B3XRp+SktrpsixJvRZ8RwPuF6GZT+nhSUtJsmnNvILYyKrvw9cpVcU1D5JgqfkHu XLMsUChNKlMhHA4udXWTj1loqNn+DQJSX6NWwyg9H48asvaYHFL6N5+ZZwn+0bPM fGw4JdqZX8s4VSdGMDMOHzu0SxnJOFNYsNl8ghKemcJbPNN7R+tHjPc59T50soas kXCaXtOKGk4Czj5v7qlIQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=i9e814621.fm2; t= 1656747409; x=1656751009; bh=fZHpAcs8JyhgGXMZpICaz6hZyxwSP0Sr1/A DXeOeyCY=; b=pz7ZaQmTawS4qVvuYsMO4MqVlGPFV+ETku91yBvauoEV03TN88V VCjGyGCQylQGhL04RjKMc+3Bsexw+lb9+sbOUGphtTxbsxwTjfMC4zHlau8Fxm0b ZpUOc3qtxbqeQh1XD8ArAxpqDMh1D1wqDbtoGFZio4Oih/s86G6y0TRxymRAeKVO wCPAtwJCmsq3XP6AxXObAsYrVIeN6gFVLlEqh8Ylc/BqwkL3aYGZKO7T0WRIf2J7 oNZJYkOPqtHWTRVzQeTmml/ILPXWXMcy9gdWG4fuRKqaxIFCCp41dcEXfsuvVX2H /yN/RudLu7xGN45DUQiirrU3z1btH+evvEA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudehgedguddvvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvfevuffkfhggtggugfgjse htkeertddttddunecuhfhrohhmpefrvghtvghrucffvghlvghvohhrhigrshcuoehpvght vghrsehpjhgurdguvghvqeenucggtffrrghtthgvrhhnpefhgeffvedufeevteegkeetie ejhffhudeujedvgedvheffheejveethffhffefueenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrsehpjhgurdguvghv X-ME-Proxy: Feedback-ID: i9e814621:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 2 Jul 2022 03:36:48 -0400 (EDT) Date: Sat, 2 Jul 2022 00:36:46 -0700 From: Peter Delevoryas To: =?iso-8859-1?Q?C=E9dric?= Le Goater Cc: Peter Delevoryas , peter.maydell@linaro.org, andrew@aj.id.au, joel@jms.id.au, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: Re: [PATCH] aspeed: Create SRAM name from first CPU index Message-ID: References: <20220701180603.38408-1-me@pjd.dev> <3b367b09-075e-a21b-8d24-3b2be091f816@kaod.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Received-SPF: pass client-ip=66.111.4.224; envelope-from=peter@pjd.dev; helo=new2-smtp.messagingengine.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_FMBLA_NEWDOM=1.498, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: 84fEOTHjUoC9 On Sat, Jul 02, 2022 at 12:01:48AM -0700, Peter Delevoryas wrote: > On Sat, Jul 02, 2022 at 08:01:14AM +0200, Cédric Le Goater wrote: > > On 7/1/22 20:06, Peter Delevoryas wrote: > > > To support multiple SoC's running simultaneously, we need a unique name for > > > each RAM region. DRAM is created by the machine, but SRAM is created by the > > > SoC, since in hardware it is part of the SoC's internals. > > > > > > We need a way to uniquely identify each SRAM region though, for VM > > > migration. Since each of the SoC's CPU's has an index which identifies it > > > uniquely from other CPU's in the machine, we can use the index of any of the > > > CPU's in the SoC to uniquely identify differentiate the SRAM name from other > > > SoC SRAM's. In this change, I just elected to use the index of the first CPU > > > in each SoC. > > > > hopefully the index is allocated. Did you check ? > > You mean the CpuState.cpu_index? I think it's allocated at this point, I > actually had to do some debugging just to get it working cause I typo'd the > CPU(...) cast at first. I also tried it with the multi-SoC board in your > aspeed-7.1 branch: > > (qemu) qom-get /machine/bmc aspeed.sram.0[0] > "/machine/bmc/aspeed.sram.0[0]" > (qemu) qom-get /machine/unattached aspeed.sram.2[0] > "/machine/unattached/aspeed.sram.2[0]" > > I think the SRAM in the ast1030 is initialized without a parent object > (memory_region_init_ram(..., NULL, ...)) so that's why it's in the unattached > area. But we could fix that, maybe I should send a v2 with that too? > > > > > > > > Signed-off-by: Peter Delevoryas > > > --- > > > hw/arm/aspeed_ast10x0.c | 5 ++++- > > > hw/arm/aspeed_ast2600.c | 5 +++-- > > > hw/arm/aspeed_soc.c | 5 +++-- > > > 3 files changed, 10 insertions(+), 5 deletions(-) > > > > > > diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c > > > index 33ef331771..b6b6f0d053 100644 > > > --- a/hw/arm/aspeed_ast10x0.c > > > +++ b/hw/arm/aspeed_ast10x0.c > > > @@ -159,6 +159,7 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) > > > DeviceState *armv7m; > > > Error *err = NULL; > > > int i; > > > + char name[64]; > > > if (!clock_has_source(s->sysclk)) { > > > error_setg(errp, "sysclk clock must be wired up by the board code"); > > > @@ -183,7 +184,9 @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) > > > sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), &error_abort); > > > /* Internal SRAM */ > > > - memory_region_init_ram(&s->sram, NULL, "aspeed.sram", sc->sram_size, &err); > > > + snprintf(name, sizeof(name), "aspeed.sram.%d", > > > + CPU(s->armv7m.cpu)->cpu_index); > > > + memory_region_init_ram(&s->sram, NULL, name, sc->sram_size, &err); > > > if (err != NULL) { > > > error_propagate(errp, err); > > > return; > > > diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c > > > index 3f0611ac11..7efb9f888a 100644 > > > --- a/hw/arm/aspeed_ast2600.c > > > +++ b/hw/arm/aspeed_ast2600.c > > > @@ -276,6 +276,7 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > > > AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); > > > Error *err = NULL; > > > qemu_irq irq; > > > + char name[64]; > > > > May be ? > > > > g_autofree char *sram_name = > > g_strdup_printf("aspeed.sram.%d", CPU(&s->cpu[0])->cpu_index); > > Hmmm yeah sure why not, I can fix the unattached AST1030 SRAM too. I always > wanted to use g_autofree some day hehe. Actually, can't do this: cpu_index is _not_ initialized at this point (the start of the function). armv7m needs to be realized first in the ast1030, cpu[]'s need to be realized in other SoC's. I don't think it would be preferable to move the autofree statement lower because the convention is to put declarations at the start of the enclosing block, let me know if you have another idea though. > > > > > > > Thanks, > > > > C. > > > > > > > /* IO space */ > > > aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->iomem), "aspeed.io", > > > @@ -335,8 +336,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) > > > } > > > /* SRAM */ > > > - memory_region_init_ram(&s->sram, OBJECT(dev), "aspeed.sram", > > > - sc->sram_size, &err); > > > + snprintf(name, sizeof(name), "aspeed.sram.%d", CPU(&s->cpu[0])->cpu_index); > > > + memory_region_init_ram(&s->sram, OBJECT(dev), name, sc->sram_size, &err); > > > if (err) { > > > error_propagate(errp, err); > > > return; > > > diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c > > > index 0f675e7fcd..1ddba33d2a 100644 > > > --- a/hw/arm/aspeed_soc.c > > > +++ b/hw/arm/aspeed_soc.c > > > @@ -239,6 +239,7 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > > > AspeedSoCState *s = ASPEED_SOC(dev); > > > AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); > > > Error *err = NULL; > > > + char name[64]; > > > /* IO space */ > > > aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->iomem), "aspeed.io", > > > @@ -259,8 +260,8 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) > > > } > > > /* SRAM */ > > > - memory_region_init_ram(&s->sram, OBJECT(dev), "aspeed.sram", > > > - sc->sram_size, &err); > > > + snprintf(name, sizeof(name), "aspeed.sram.%d", CPU(&s->cpu[0])->cpu_index); > > > + memory_region_init_ram(&s->sram, OBJECT(dev), name, sc->sram_size, &err); > > > if (err) { > > > error_propagate(errp, err); > > > return; > >