From nobody Sat May 18 04:13:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587563436; cv=none; d=zohomail.com; s=zohoarc; b=LFBZQmT8jH5XuB/gMO7uqPs7nwgSjj2ImApLWKLgX4uFYQya2bO8Vpyr7XJbh4cCOEllo+gw/1GYqEK81dMOCnorPCD7TSQjrasM/KBqa2K9fOLUwilNl2AaIaRgI80ft75sQu9SXwEcAze/FyjjJ2aJOExfLjh2Bs9+5GWZiFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587563436; h=Content-Type:Content-Transfer-Encoding:Cc: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=cfTlLXtoGanxq3ON/PmXohAadgw+dyYLdekRQbAtnks=; b=a8q+gXD/7MqBJdAt2i1ZhdRK+/UJMWWI0Ca99zhLH4ibUh6+ixaAGGsd+48UeuOId2s0AXNR1YAoR/8OenpIewJ3vaF8OZx3cq+HFeF47D2pWsZODO/k6kcTY5WGPUm6fiTlXjqderV7SAesRPKx6un8LjcdPXC5lEOGM1kuvDk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1587563436315825.3149317497252; Wed, 22 Apr 2020 06:50:36 -0700 (PDT) Received: from localhost ([::1]:51084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRFlr-0002kw-1m for importer@patchew.org; Wed, 22 Apr 2020 09:50:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39468) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRFjk-00008d-Oi for qemu-devel@nongnu.org; Wed, 22 Apr 2020 09:48:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRFji-000896-G4 for qemu-devel@nongnu.org; Wed, 22 Apr 2020 09:48:23 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:37432 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jRFjh-00084T-U2 for qemu-devel@nongnu.org; Wed, 22 Apr 2020 09:48:22 -0400 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-90-pmaZnJSVPniW2U4bk3QMHQ-1; Wed, 22 Apr 2020 09:48:19 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 117418010FB; Wed, 22 Apr 2020 13:48:18 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7ADC8600DE; Wed, 22 Apr 2020 13:48:17 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CF29811358BD; Wed, 22 Apr 2020 15:48:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587563300; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cfTlLXtoGanxq3ON/PmXohAadgw+dyYLdekRQbAtnks=; b=cAor98Nnhw+MOeARumw6SjCPNu3cXYwum236D8nnn6PG2eYKYWuOhOiRS53viwhP0+THNb UAt1cryr/qA9CG5D4JI2pVPhV9+zP4b/84XjS2sCuOBf4GIb3jE2otGKXOxlrwdHUq/+oG LbglJWp7MVHjVxI7XWhlIaq6VPGnEPs= X-MC-Unique: pmaZnJSVPniW2U4bk3QMHQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 1/4] sam460ex: Suppress useless warning on -m 32 and -m 64 Date: Wed, 22 Apr 2020 15:48:12 +0200 Message-Id: <20200422134815.1584-2-armbru@redhat.com> In-Reply-To: <20200422134815.1584-1-armbru@redhat.com> References: <20200422134815.1584-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/22 02:57:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: philmd@redhat.com, David Gibson , qemu-ppc@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Requesting 32 or 64 MiB of RAM with the sam460ex machine type produces a useless warning: qemu-system-ppc: warning: Memory size is too small for SDRAM type, adju= sting type This is because sam460ex_init() asks spd_data_generate() for DDR2, which is impossible, so spd_data_generate() corrects it to DDR. The warning goes back to commit 08fd99179a "sam460ex: Clean up SPD EEPROM creation". Make sam460ex_init() pass the correct SDRAM type to get rid of the warning. Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/sam460ex.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 898453cf30..1e3eaac0db 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -335,7 +335,8 @@ static void sam460ex_init(MachineState *machine) dev =3D sysbus_create_simple(TYPE_PPC4xx_I2C, 0x4ef600700, uic[0][2]); i2c =3D PPC4xx_I2C(dev)->bus; /* SPD EEPROM on RAM module */ - spd_data =3D spd_data_generate(DDR2, ram_sizes[0], &err); + spd_data =3D spd_data_generate(ram_sizes[0] < 128 * MiB ? DDR : DDR2, + ram_sizes[0], &err); if (err) { warn_report_err(err); } --=20 2.21.1 From nobody Sat May 18 04:13:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587563557; cv=none; d=zohomail.com; s=zohoarc; b=i7bqrhXNXGhcCkJiQve7yIj8IikeR0Do0hnEs+Nk4LJ0asMdPh8mcAP3XDLF7X29bA7OP1hzpdu18lYF154K5J78MHVfdGeiJBT7fK7MlWKIcnOe0xkHmBRXkLhefZjE58+0btGUa7AJkiRsVD0GoBnO5iCyeWmKAxm9hqSOmxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587563557; h=Content-Type:Content-Transfer-Encoding:Cc: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=d7TJzgKj/BU5th/onq2uYSXeTrVpdBFq0vVLEz28oKM=; b=HryJXjSaNN0ADPl68UmOvhSNURZVyQulpWaq+VTm1AAciZs+GZpLFiyVkUQoUvaufbY30iMWs7fiPuq3bPs0/SrgdkZ+902b9/bT8BM9OvMdo2suTFrjDeXwi0D76Tx/FZIu7M/FHHh4fp24uiY0gX9+kbwCFKMR58ddYn0ojxk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1587563557102662.888582525401; Wed, 22 Apr 2020 06:52:37 -0700 (PDT) Received: from localhost ([::1]:51138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRFnn-0005zC-Ms for importer@patchew.org; Wed, 22 Apr 2020 09:52:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39492) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRFjl-0000Ad-TU for qemu-devel@nongnu.org; Wed, 22 Apr 2020 09:48:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRFjj-0008E1-O9 for qemu-devel@nongnu.org; Wed, 22 Apr 2020 09:48:25 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:34390 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jRFjj-0008A7-7l for qemu-devel@nongnu.org; Wed, 22 Apr 2020 09:48:23 -0400 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-265-KN4QXt0PNSS4jyZaSiZDhQ-1; Wed, 22 Apr 2020 09:48:19 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F1C2D8017F3; Wed, 22 Apr 2020 13:48:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 59792272CC; Wed, 22 Apr 2020 13:48:17 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D4DA811358BE; Wed, 22 Apr 2020 15:48:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587563302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d7TJzgKj/BU5th/onq2uYSXeTrVpdBFq0vVLEz28oKM=; b=EFWQgZCxk0sw7bAr13RuVlXVGiljdK3l4BmN2Y7NbOG3xnWqxy+lNWIo3aEBVT4+xU6Qt8 vvBXPq7uBOAfbr5+2kLp3Yc4z0VIVMbYqxAtT3LJO8Rf/it/TH3lriBEfeOi/ubIQvmyT6 2sYMgcuJlwu9wXb7bBdkB/OT/a8q2CI= X-MC-Unique: KN4QXt0PNSS4jyZaSiZDhQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 2/4] smbus: Fix spd_data_generate() error API violation Date: Wed, 22 Apr 2020 15:48:13 +0200 Message-Id: <20200422134815.1584-3-armbru@redhat.com> In-Reply-To: <20200422134815.1584-1-armbru@redhat.com> References: <20200422134815.1584-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/22 02:12:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: philmd@redhat.com, David Gibson , qemu-ppc@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The Error ** argument must be NULL, &error_abort, &error_fatal, or a pointer to a variable containing NULL. Passing an argument of the latter kind twice without clearing it in between is wrong: if the first call sets an error, it no longer points to NULL for the second call. spd_data_generate() can pass @errp to error_setg() more than once when it adjusts both memory size and type. Harmless, because no caller passes anything that needs adjusting. Until the previous commit, sam460ex passed types that needed adjusting, but not sizes. spd_data_generate()'s contract is rather awkward: If everything's fine, return non-null and don't set an error. Else, if memory size or type need adjusting, return non-null and set an error describing the adjustment. Else, return null and set an error reporting why no data can be generated. Its callers treat the error as a warning even when null is returned. They don't create the "smbus-eeprom" device then. Suspicious. Since the previous commit, only "everything's fine" can actually happen. Drop the unused code and simplify the callers. This gets rid of the error API violation. Signed-off-by: Markus Armbruster --- include/hw/i2c/smbus_eeprom.h | 2 +- hw/i2c/smbus_eeprom.c | 30 ++++-------------------------- hw/mips/mips_fulong2e.c | 10 ++-------- hw/ppc/sam460ex.c | 12 +++--------- 4 files changed, 10 insertions(+), 44 deletions(-) diff --git a/include/hw/i2c/smbus_eeprom.h b/include/hw/i2c/smbus_eeprom.h index 15e2151b50..68b0063ab6 100644 --- a/include/hw/i2c/smbus_eeprom.h +++ b/include/hw/i2c/smbus_eeprom.h @@ -31,6 +31,6 @@ void smbus_eeprom_init(I2CBus *bus, int nb_eeprom, const uint8_t *eeprom_spd, int size); =20 enum sdram_type { SDR =3D 0x4, DDR =3D 0x7, DDR2 =3D 0x8 }; -uint8_t *spd_data_generate(enum sdram_type type, ram_addr_t size, Error **= errp); +uint8_t *spd_data_generate(enum sdram_type type, ram_addr_t size); =20 #endif diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index 5adf3b15b5..07fbbf87f1 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -195,8 +195,7 @@ void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom, } =20 /* Generate SDRAM SPD EEPROM data describing a module of type and size */ -uint8_t *spd_data_generate(enum sdram_type type, ram_addr_t ram_size, - Error **errp) +uint8_t *spd_data_generate(enum sdram_type type, ram_addr_t ram_size) { uint8_t *spd; uint8_t nbanks; @@ -222,29 +221,10 @@ uint8_t *spd_data_generate(enum sdram_type type, ram_= addr_t ram_size, g_assert_not_reached(); } size =3D ram_size >> 20; /* work in terms of megabytes */ - if (size < 4) { - error_setg(errp, "SDRAM size is too small"); - return NULL; - } sz_log2 =3D 31 - clz32(size); size =3D 1U << sz_log2; - if (ram_size > size * MiB) { - error_setg(errp, "SDRAM size 0x"RAM_ADDR_FMT" is not a power of 2,= " - "truncating to %u MB", ram_size, size); - } - if (sz_log2 < min_log2) { - error_setg(errp, - "Memory size is too small for SDRAM type, adjusting typ= e"); - if (size >=3D 32) { - type =3D DDR; - min_log2 =3D 5; - max_log2 =3D 12; - } else { - type =3D SDR; - min_log2 =3D 2; - max_log2 =3D 9; - } - } + assert(ram_size =3D=3D size * MiB); + assert(sz_log2 >=3D min_log2); =20 nbanks =3D 1; while (sz_log2 > max_log2 && nbanks < 8) { @@ -252,9 +232,7 @@ uint8_t *spd_data_generate(enum sdram_type type, ram_ad= dr_t ram_size, nbanks++; } =20 - if (size > (1ULL << sz_log2) * nbanks) { - error_setg(errp, "Memory size is too big for SDRAM, truncating"); - } + assert(size =3D=3D (1ULL << sz_log2) * nbanks); =20 /* split to 2 banks if possible to avoid a bug in MIPS Malta firmware = */ if (nbanks =3D=3D 1 && sz_log2 > min_log2) { diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index 5040afd581..ef02d54b33 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -297,7 +297,6 @@ static void mips_fulong2e_init(MachineState *machine) MemoryRegion *bios =3D g_new(MemoryRegion, 1); long bios_size; uint8_t *spd_data; - Error *err =3D NULL; int64_t kernel_entry; PCIBus *pci_bus; ISABus *isa_bus; @@ -377,13 +376,8 @@ static void mips_fulong2e_init(MachineState *machine) } =20 /* Populate SPD eeprom data */ - spd_data =3D spd_data_generate(DDR, machine->ram_size, &err); - if (err) { - warn_report_err(err); - } - if (spd_data) { - smbus_eeprom_init_one(smbus, 0x50, spd_data); - } + spd_data =3D spd_data_generate(DDR, machine->ram_size); + smbus_eeprom_init_one(smbus, 0x50, spd_data); =20 mc146818_rtc_init(isa_bus, 2000, NULL); =20 diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 1e3eaac0db..42a8c9fb7f 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -292,7 +292,6 @@ static void sam460ex_init(MachineState *machine) SysBusDevice *sbdev; struct boot_info *boot_info; uint8_t *spd_data; - Error *err =3D NULL; int success; =20 cpu =3D POWERPC_CPU(cpu_create(machine->cpu_type)); @@ -336,14 +335,9 @@ static void sam460ex_init(MachineState *machine) i2c =3D PPC4xx_I2C(dev)->bus; /* SPD EEPROM on RAM module */ spd_data =3D spd_data_generate(ram_sizes[0] < 128 * MiB ? DDR : DDR2, - ram_sizes[0], &err); - if (err) { - warn_report_err(err); - } - if (spd_data) { - spd_data[20] =3D 4; /* SO-DIMM module */ - smbus_eeprom_init_one(i2c, 0x50, spd_data); - } + ram_sizes[0]); + spd_data[20] =3D 4; /* SO-DIMM module */ + smbus_eeprom_init_one(i2c, 0x50, spd_data); /* RTC */ i2c_create_slave(i2c, "m41t80", 0x68); =20 --=20 2.21.1 From nobody Sat May 18 04:13:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587563536; cv=none; d=zohomail.com; s=zohoarc; b=SaPLApOh2uxw90mQCcr57Y+dDSyZuBrfPu/YER5I1kMToZjzvdwvdfj0FqY1HjEk73VZA/7Eb7xEpZ7Cfuj0k6XI+tVQRuUwFjDn7EIrjyX+I6lbEKScE4Exu8s6NGs3XgZpq0gUodbCt+NVfP7/xA5DFQaBCqoQ+5sQYXgNGoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587563536; h=Content-Type:Content-Transfer-Encoding:Cc: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=wTkkZ0baNr2PlF+36UnREU+T0co/N68a0grMAwtmAHg=; b=aekgVySlNZbNOVi8QNP9+qzaHj12x1Mxl10gGakYExmYejCdlrLYna6GlUppcUBgnRJ0JsOD3dZMFQz9dsVauddsAZ5QxPqXa6tLLlXt1w1k5ZmjNOAuCycQzhHVkw+DMrYLOJwATLQjGnA3iQssWN0C5fENF9n+R9ZL1mPwF18= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 158756353689983.70319074202109; Wed, 22 Apr 2020 06:52:16 -0700 (PDT) Received: from localhost ([::1]:51130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRFnT-0005dF-Ji for importer@patchew.org; Wed, 22 Apr 2020 09:52:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39508) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRFjm-0000C3-PJ for qemu-devel@nongnu.org; Wed, 22 Apr 2020 09:48:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRFjk-0008F6-9Q for qemu-devel@nongnu.org; Wed, 22 Apr 2020 09:48:26 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:36900 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jRFjj-0008AE-SC for qemu-devel@nongnu.org; Wed, 22 Apr 2020 09:48:23 -0400 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-28-qS4tS5Z-NLmamLmmeDkMwA-1; Wed, 22 Apr 2020 09:48:18 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D58A4DB60; Wed, 22 Apr 2020 13:48:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7A5F360C87; Wed, 22 Apr 2020 13:48:17 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DAA6E11358BF; Wed, 22 Apr 2020 15:48:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587563302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wTkkZ0baNr2PlF+36UnREU+T0co/N68a0grMAwtmAHg=; b=VdO1TvxHwANlpOpu+wDaunu2uKVrpLYFUhngkvYSwZ+KxowIXwiFI/Wf6T2GGV76gMOUAv wIVzKvwg+YrzXZO32NXXQLbyOElXRIXvp0ELoYkFxqi6K8jSe9ms9K08dRGbJnhHMd20eq hmczIlSf6ZkykMrYaZMK8x/gAd4Nzkk= X-MC-Unique: qS4tS5Z-NLmamLmmeDkMwA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 3/4] bamboo, sam460ex: Tidy up error message for unsupported RAM size Date: Wed, 22 Apr 2020 15:48:14 +0200 Message-Id: <20200422134815.1584-4-armbru@redhat.com> In-Reply-To: <20200422134815.1584-1-armbru@redhat.com> References: <20200422134815.1584-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=205.139.110.120; envelope-from=armbru@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/22 04:15:03 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 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: philmd@redhat.com, David Gibson , qemu-ppc@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Improve $ ppc-softmmu/qemu-system-ppc -M sam460ex -m 4096 qemu-system-ppc: Max 1 banks of 2048 ,1024 ,512 ,256 ,128 ,64 ,32 MB DI= MM/bank supported qemu-system-ppc: Possible valid RAM size: 2048 to qemu-system-ppc: at most 1 bank of 2048, 1024, 512, 256, 128, 64, 32 Mi= B each supported Possible valid RAM size: 1024 MiB Signed-off-by: Markus Armbruster Reviewed-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/ppc4xx_devs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c index 3376c43ff5..f1651e04d9 100644 --- a/hw/ppc/ppc4xx_devs.c +++ b/hw/ppc/ppc4xx_devs.c @@ -716,11 +716,11 @@ void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_ban= ks, for (i =3D 0; sdram_bank_sizes[i]; i++) { g_string_append_printf(s, "%" PRIi64 "%s", sdram_bank_sizes[i] / MiB, - sdram_bank_sizes[i + 1] ? " ," : ""); + sdram_bank_sizes[i + 1] ? ", " : ""); } - error_report("Max %d banks of %s MB DIMM/bank supported", - nr_banks, s->str); - error_report("Possible valid RAM size: %" PRIi64, + error_report("at most %d bank%s of %s MiB each supported", + nr_banks, nr_banks =3D=3D 1 ? "" : "s", s->str); + error_printf("Possible valid RAM size: %" PRIi64 " MiB \n", used_size ? used_size / MiB : sdram_bank_sizes[i - 1] / MiB); =20 g_string_free(s, true); --=20 2.21.1 From nobody Sat May 18 04:13:31 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587563396; cv=none; d=zohomail.com; s=zohoarc; b=ZL1ysIvgmotK3jbzncFImf3kl4lnYo3seTcXp4wLXB4GL0AqmvYws5WuUxu+Q93c2guxabbEaDtBedSLOnL1YC2hbV8iFKRlb2pYcvq7u9+5LGWRfmDB+n2r/Awa1Urkf/2Un8KBMPAjIggjNUb3jsFoffKnocjJ6jigxkvQTdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587563396; h=Content-Type:Content-Transfer-Encoding:Cc: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=ZMenhwkXU3W7qk+WShZLNVc7ADewiurDzFW6wwCy6vU=; b=JaUZsDBAcxPWiOnANlf0j2fFcdbq+WDwEp78zqNhkCG6btEYbq+Cb03FEBU0UOqvEZdOqM95U/DGXVfihT9kUqbQ163bT+6Ep6nFhKKIWRgP4GT5IkgsE0FUps+5FhgM/m5ZR5YaWsJBtx6oYYe+AweEVz/KC68fQqf7gZoPIsA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1587563396103600.7816645585443; Wed, 22 Apr 2020 06:49:56 -0700 (PDT) Received: from localhost ([::1]:51082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRFlB-0001tg-LT for importer@patchew.org; Wed, 22 Apr 2020 09:49:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39520) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRFjn-0000De-La for qemu-devel@nongnu.org; Wed, 22 Apr 2020 09:48:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRFji-00088f-D1 for qemu-devel@nongnu.org; Wed, 22 Apr 2020 09:48:27 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:26560 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jRFjh-00084F-Tt for qemu-devel@nongnu.org; Wed, 22 Apr 2020 09:48:22 -0400 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-413-Ozl7pB1pNPSY3WNVJhrVYw-1; Wed, 22 Apr 2020 09:48:19 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D606D81CBE1; Wed, 22 Apr 2020 13:48:17 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-113-6.ams2.redhat.com [10.36.113.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 69AC16084A; Wed, 22 Apr 2020 13:48:17 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E0A8D11358C0; Wed, 22 Apr 2020 15:48:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587563300; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZMenhwkXU3W7qk+WShZLNVc7ADewiurDzFW6wwCy6vU=; b=dC5tWEIgHCO7YZ602Yzgo8/7W+Q3BYdbaGrbZc89Yvsln9yTmH57KNG5vVUcU3AwtxgeYd ehascRJc8xj/OFHL+7AWjIWxpkehHDXdmPshxEtq0tx8VOZrRq07XCVtn5TLwx+amwcyyI dPIDuuoKktQyQMv0NS8Wk5QGGJcjOro= X-MC-Unique: Ozl7pB1pNPSY3WNVJhrVYw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2 4/4] smbus: Fix spd_data_generate() for number of banks > 2 Date: Wed, 22 Apr 2020 15:48:15 +0200 Message-Id: <20200422134815.1584-5-armbru@redhat.com> In-Reply-To: <20200422134815.1584-1-armbru@redhat.com> References: <20200422134815.1584-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/22 02:12:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 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: philmd@redhat.com, David Gibson , qemu-ppc@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" spd_data_generate() splits @ram_size bytes into @nbanks RAM banks of 1 << sz_log2 MiB each, like this: size =3D ram_size >> 20; /* work in terms of megabytes */ [...] nbanks =3D 1; while (sz_log2 > max_log2 && nbanks < 8) { sz_log2--; nbanks++; } Each iteration halves the size of a bank, and increments the number of banks. Wrong: it should double the number of banks. The bug goes back all the way to commit b296b664ab "smbus: Add a helper to generate SPD EEPROM data". It can't bite because spd_data_generate()'s current users pass only @ram_size that result in *zero* iterations: machine RAM size #banks type bank size fulong2e 256 MiB 1 DDR 256 MiB sam460ex 2048 MiB 1 DDR2 2048 MiB 1024 MiB 1 DDR2 1024 MiB 512 MiB 1 DDR2 512 MiB 256 MiB 1 DDR2 256 MiB 128 MiB 1 SDR 128 MiB 64 MiB 1 SDR 64 MiB 32 MiB 1 SDR 32 MiB Apply the obvious, minimal fix. I admit I'm tempted to rip out the unused (and obviously untested) feature instead, because YAGNI. Note that this is not the final result, as spd_data_generate() next increases #banks from 1 to 2 if possible. This is done "to avoid a bug in MIPS Malta firmware". We don't even use this function with machine type malta. *Shrug* Signed-off-by: Markus Armbruster --- hw/i2c/smbus_eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i2c/smbus_eeprom.c b/hw/i2c/smbus_eeprom.c index 07fbbf87f1..e199fc8678 100644 --- a/hw/i2c/smbus_eeprom.c +++ b/hw/i2c/smbus_eeprom.c @@ -229,7 +229,7 @@ uint8_t *spd_data_generate(enum sdram_type type, ram_ad= dr_t ram_size) nbanks =3D 1; while (sz_log2 > max_log2 && nbanks < 8) { sz_log2--; - nbanks++; + nbanks *=3D 2; } =20 assert(size =3D=3D (1ULL << sz_log2) * nbanks); --=20 2.21.1