From nobody Thu Dec 18 19:30:10 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576495571; cv=none; d=zohomail.com; s=zohoarc; b=dUM3P9VJO6Y84eYziD/ncKq84oa/KhZrA4bwx6cbuYn2LNBm8c2bdnnhxdVFhwUgYD4Pf9IyB0lblI9N5qLtCISkpq0f/x6me2C9BAiqEHwyXeh8jqi7COwR3UclYphag+Pk0iMfl7d198hqK+/lo7IDixqfG532jdv9ADmVWKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576495571; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oFUUQobexKmEiGcHc00gtIO7FQq8Xq2VFD8z4YpIbXU=; b=IWFlBWbMIIlUrRzF7wfKGg5V4LB01KEvBOPjA2HxYd+UMHFa31WfR65NokcYIT0F4+pgRJGU6kvHiahP2nrKI+5s1cFjPvpOiaL9P+NGyOrtvesw3bK4cjHR7JFrGSrSCfz7YaZ+gGmUDG8un4JyzswBzW0UJ++AypaB88dzqws= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576495571760937.5770510816637; Mon, 16 Dec 2019 03:26:11 -0800 (PST) Received: from localhost ([::1]:51650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1igoVu-0003go-8A for importer@patchew.org; Mon, 16 Dec 2019 06:26:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50935) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1igoFf-0007fe-DL for qemu-devel@nongnu.org; Mon, 16 Dec 2019 06:09:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1igoFe-0007qu-55 for qemu-devel@nongnu.org; Mon, 16 Dec 2019 06:09:23 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:36298) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1igoFd-0007nc-VB for qemu-devel@nongnu.org; Mon, 16 Dec 2019 06:09:22 -0500 Received: by mail-wm1-x343.google.com with SMTP id p17so6224784wma.1 for ; Mon, 16 Dec 2019 03:09:21 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id x10sm20976131wrp.58.2019.12.16.03.09.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2019 03:09:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=oFUUQobexKmEiGcHc00gtIO7FQq8Xq2VFD8z4YpIbXU=; b=O2/ibXdp/R2HNKVFg9vgznlZ9Rs7S0/UyMbitKpb3gHOG/KXDb15dZRPn/orXtyE8m 5LtRN5DSwo/R4dOUWGVUVQaOE+6tkql7W6W9URa/Niz4+U7CcFd4ADmwFt6BODt+fwHo TGgzjh/8IVPPMhOquRUOClouqnwrLPbtXggY+XtOMB9/hEIcOKps0zrbfY5KE82A2zkY qfOTX+Bh17RU9/F5BJyl7vmsBhJZIL/j+lQ3i5KGA4Q3Acnl29gylLkD3dZ8nE8AyGz4 OiujELXODU3Rfi+UinYJVfysaxXGHmBehpI5XMD4cTP3Z12onT5IzXQVUpJavSmqHEhu LR4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oFUUQobexKmEiGcHc00gtIO7FQq8Xq2VFD8z4YpIbXU=; b=U/9gg3u2CzWqVzkL6LR/8/ogxrTg+ruBAa+zSLPxf6f7t7xyoliB/ezOkIeH8vXckd mtB94kgN485FqUCqJQ20Sc7aYhm9rn/f82jKct6A0B8aUUA/gXTzeLvCP0nctwgZqMup zzTwq7MvidwS88Ad4WKO1uQ7HPgEsLmMrvQrNCZNX+/VkxcLDCeOK0C0ZVDGqbihLeEQ sgwO6Pr4AqihDj4uDRdyH7Vw2dM2rQ3IeXC3r+sVzKlROVN1EWfJZBS2Unwk3MhjmxRf O8Li66zObqiTlEKYYyg34bT9zyxhGcf8LtkpDuCy0tQDL7HP2a0O+n7P1L3pWz8dEvxg gVCg== X-Gm-Message-State: APjAAAX3LEJi2KEdYUao/dzce614ZY1Ioi3DVQ/IsJzVV9y9eFErEHB9 Ep3ZQaoxInZyy+j8oQ/xUEINcmQGv/GcOw== X-Google-Smtp-Source: APXvYqyylastqGrQXAl8xNNK5fyzbyH6O8gEB2z+TuXcSvCK6UnEELalme4yxD/fxBe+YU3LC7KsVw== X-Received: by 2002:a1c:dc08:: with SMTP id t8mr30838010wmg.139.1576494560782; Mon, 16 Dec 2019 03:09:20 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/34] aspeed/smc: Restore default AHB window mapping at reset Date: Mon, 16 Dec 2019 11:08:42 +0000 Message-Id: <20191216110904.30815-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191216110904.30815-1-peter.maydell@linaro.org> References: <20191216110904.30815-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: C=C3=A9dric Le Goater The current model only restores the Segment Register values but leaves the previous CS mapping behind. Introduce a helper setting the register value and mapping the region at the requested address. Use this helper when a Segment register is set and at reset. Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Joel Stanley Signed-off-by: C=C3=A9dric Le Goater Message-id: 20191119141211.25716-11-clg@kaod.org Signed-off-by: Peter Maydell --- hw/ssi/aspeed_smc.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c index f0c7bbbad30..955ec21852a 100644 --- a/hw/ssi/aspeed_smc.c +++ b/hw/ssi/aspeed_smc.c @@ -475,10 +475,26 @@ static bool aspeed_smc_flash_overlap(const AspeedSMCS= tate *s, return false; } =20 +static void aspeed_smc_flash_set_segment_region(AspeedSMCState *s, int cs, + uint64_t regval) +{ + AspeedSMCFlash *fl =3D &s->flashes[cs]; + AspeedSegments seg; + + s->ctrl->reg_to_segment(s, regval, &seg); + + memory_region_transaction_begin(); + memory_region_set_size(&fl->mmio, seg.size); + memory_region_set_address(&fl->mmio, seg.addr - s->ctrl->flash_window_= base); + memory_region_set_enabled(&fl->mmio, true); + memory_region_transaction_commit(); + + s->regs[R_SEG_ADDR0 + cs] =3D regval; +} + static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs, uint64_t new) { - AspeedSMCFlash *fl =3D &s->flashes[cs]; AspeedSegments seg; =20 s->ctrl->reg_to_segment(s, new, &seg); @@ -529,13 +545,7 @@ static void aspeed_smc_flash_set_segment(AspeedSMCStat= e *s, int cs, aspeed_smc_flash_overlap(s, &seg, cs); =20 /* All should be fine now to move the region */ - memory_region_transaction_begin(); - memory_region_set_size(&fl->mmio, seg.size); - memory_region_set_address(&fl->mmio, seg.addr - s->ctrl->flash_window_= base); - memory_region_set_enabled(&fl->mmio, true); - memory_region_transaction_commit(); - - s->regs[R_SEG_ADDR0 + cs] =3D new; + aspeed_smc_flash_set_segment_region(s, cs, new); } =20 static uint64_t aspeed_smc_flash_default_read(void *opaque, hwaddr addr, @@ -897,10 +907,10 @@ static void aspeed_smc_reset(DeviceState *d) qemu_set_irq(s->cs_lines[i], true); } =20 - /* setup default segment register values for all */ + /* setup the default segment register values and regions for all */ for (i =3D 0; i < s->ctrl->max_slaves; ++i) { - s->regs[R_SEG_ADDR0 + i] =3D - s->ctrl->segment_to_reg(s, &s->ctrl->segments[i]); + aspeed_smc_flash_set_segment_region(s, i, + s->ctrl->segment_to_reg(s, &s->ctrl->segments[i])); } =20 /* HW strapping flash type for the AST2600 controllers */ --=20 2.20.1