From nobody Sun May 19 17:58:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1562036570; cv=none; d=zoho.com; s=zohoarc; b=l/58hMA8L6+HtS+ba8YltQlr8tATCU6OLUQBKcw3iX7fLw69r3cUYuBI6avOJzHyXrAxikNGgACG4dzumOKfZXXDBq6xY17/ozINlR27X/DXyWoNOrCVjg69AbpiaONW1dqOQCW8YWkg4lDFBsDZOO9lkounqkUlSo3gAyQAOdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562036570; 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:ARC-Authentication-Results; bh=DYDEX66VpXk/Hd3bMHyCwZlKvEMTBtLVg0UWr0RCVqs=; b=Cqooi/IAiZwHICVtL4f8m4WaaHhmayUzgsyIOK21TBD26wxoO6Eg26vJqHgs2BmpDR/62CJP7OFGYopfgdyzmGIAarFjI4DI2Evm1QJnJq/G9RmmcBoM6f/ZxXIs4c0XHynNpOqcxQO/p9Vq7RKwCFcyJaxDK4KN3HGwLBQTRng= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1562036570510539.9953333446401; Mon, 1 Jul 2019 20:02:50 -0700 (PDT) Received: from localhost ([::1]:47724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi945-0007t9-So for importer@patchew.org; Mon, 01 Jul 2019 23:02:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52695) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi6RW-0000lx-A4 for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:14:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hi6RR-0006jn-Hh for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:14:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60635) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hi6R3-0006Ku-5O; Mon, 01 Jul 2019 20:14:13 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7C535AFE3; Tue, 2 Jul 2019 00:13:46 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8ED601001B10; Tue, 2 Jul 2019 00:13:27 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Tue, 2 Jul 2019 02:12:53 +0200 Message-Id: <20190702001301.4768-2-philmd@redhat.com> In-Reply-To: <20190702001301.4768-1-philmd@redhat.com> References: <20190702001301.4768-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 02 Jul 2019 00:13:47 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/9] hw/block/pflash_cfi01: Removed an unused timer 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: Peter Maydell , "Michael S. Tsirkin" , Max Filippov , Gerd Hoffmann , "Edgar E. Iglesias" , qemu-block@nongnu.org, Aleksandar Rikalo , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Markus Armbruster , Laszlo Ersek , David Gibson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , qemu-arm@nongnu.org, Alistair Francis , John Snow , Richard Henderson , Kevin Wolf , Max Reitz , Michael Walle , qemu-ppc@nongnu.org, Wei Yang , Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The 'CFI02' NOR flash was introduced in commit 29133e9a0fff, with timing modelled. One year later, the CFI01 model was introduced (commit 05ee37ebf630) based on the CFI02 model. As noted in the header, "It does not support timings". 12 years later, we never had to model the device timings. Time to remove the unused timer, we can still add it back if required. Suggested-by: Laszlo Ersek Reviewed-by: Wei Yang Reviewed-by: Laszlo Ersek Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- v2: Fixed commit description (Laszlo) --- hw/block/pflash_cfi01.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 35080d915f..dcc9885bf0 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -42,7 +42,6 @@ #include "hw/block/flash.h" #include "sysemu/block-backend.h" #include "qapi/error.h" -#include "qemu/timer.h" #include "qemu/bitops.h" #include "qemu/error-report.h" #include "qemu/host-utils.h" @@ -90,7 +89,6 @@ struct PFlashCFI01 { uint8_t cfi_table[0x52]; uint64_t counter; unsigned int writeblock_size; - QEMUTimer *timer; MemoryRegion mem; char *name; void *storage; @@ -114,18 +112,6 @@ static const VMStateDescription vmstate_pflash =3D { } }; =20 -static void pflash_timer (void *opaque) -{ - PFlashCFI01 *pfl =3D opaque; - - trace_pflash_timer_expired(pfl->cmd); - /* Reset flash */ - pfl->status ^=3D 0x80; - memory_region_rom_device_set_romd(&pfl->mem, true); - pfl->wcycle =3D 0; - pfl->cmd =3D 0; -} - /* Perform a CFI query based on the bank width of the flash. * If this code is called we know we have a device_width set for * this flash. @@ -775,7 +761,6 @@ static void pflash_cfi01_realize(DeviceState *dev, Erro= r **errp) pfl->max_device_width =3D pfl->device_width; } =20 - pfl->timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, pflash_timer, pfl); pfl->wcycle =3D 0; pfl->cmd =3D 0; pfl->status =3D 0; --=20 2.20.1 From nobody Sun May 19 17:58:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1562035964; cv=none; d=zoho.com; s=zohoarc; b=fp6yjYcE/Ur8ZbC7qBCCkjQuhPWRuGoauv8xjaVBulcTK2ZUHuP5htd80hzdoDOR3mVX+3VoxNurzR1h3ZMZgv/0aSghMu7iarDzjAZdPKsKzxiddNdWLlvNY35CIpK6V1J1y+0bn6R1E5x16IL7GcFDnE9+iB6l2VGgYa5LznI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562035964; 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:ARC-Authentication-Results; bh=dsT9IJx8CxoEZOOsvssZSrxBwWvcXkza8g6jjUg5x3k=; b=jhM6fPmX9OgiA7Ag04TCsmrKXMlZVZBaN6Dsg0rrbDfQknQ5lfY6jDwqzb3KzBJe+q2Zik4KUNOzT0BDHFTnojZ9/B0+VMx51VmoBNsBtSY6TTfUYEfA/0QK4GGKm7NK6r+M/wdez9xdG7IgT7MWxZ00RmvGOuC0FXsT1qEA1gQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1562035964857842.9958142256579; Mon, 1 Jul 2019 19:52:44 -0700 (PDT) Received: from localhost ([::1]:47582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi8uP-0006dP-Nv for importer@patchew.org; Mon, 01 Jul 2019 22:52:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52737) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi6RY-0000p0-1a for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:14:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hi6RW-0006na-H7 for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:14:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56846) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hi6R2-0006Uj-SK; Mon, 01 Jul 2019 20:14:13 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE37DC05FBD7; Tue, 2 Jul 2019 00:14:05 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3AEF81001B01; Tue, 2 Jul 2019 00:13:46 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Tue, 2 Jul 2019 02:12:54 +0200 Message-Id: <20190702001301.4768-3-philmd@redhat.com> In-Reply-To: <20190702001301.4768-1-philmd@redhat.com> References: <20190702001301.4768-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 02 Jul 2019 00:14:06 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/9] hw/block/pflash_cfi01: Use the correct READ_ARRAY value 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: Peter Maydell , "Michael S. Tsirkin" , Max Filippov , Gerd Hoffmann , "Edgar E. Iglesias" , qemu-block@nongnu.org, Aleksandar Rikalo , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Markus Armbruster , Laszlo Ersek , David Gibson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , qemu-arm@nongnu.org, Alistair Francis , John Snow , Richard Henderson , Kevin Wolf , Max Reitz , Michael Walle , qemu-ppc@nongnu.org, Wei Yang , Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" In the "Read Array Flowchart" the command has a value of 0xFF. In the document [*] the "Read Array Flowchart", the READ_ARRAY command has a value of 0xff. Use the correct value in the pflash model. There is no change of behavior in the guest, because: - when the guest were sending 0xFF, the reset_flash label was setting the command value as 0x00 - 0x00 was used internally for READ_ARRAY [*] "Common Flash Interface (CFI) and Command Sets" (Intel Application Note 646) Appendix B "Basic Command Set" Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Reviewed-by: John Snow --- hw/block/pflash_cfi01.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index dcc9885bf0..743b5d5794 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -280,10 +280,9 @@ static uint32_t pflash_read(PFlashCFI01 *pfl, hwaddr o= ffset, /* This should never happen : reset state & treat it as a read */ DPRINTF("%s: unknown command state: %x\n", __func__, pfl->cmd); pfl->wcycle =3D 0; - pfl->cmd =3D 0; + pfl->cmd =3D 0xff; /* fall through to read code */ - case 0x00: - /* Flash area read */ + case 0xff: /* Read Array */ ret =3D pflash_data_read(pfl, offset, width, be); break; case 0x10: /* Single byte program */ @@ -449,8 +448,6 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, case 0: /* read mode */ switch (cmd) { - case 0x00: /* ??? */ - goto reset_flash; case 0x10: /* Single Byte Program */ case 0x40: /* Single Byte Program */ DPRINTF("%s: Single Byte Program\n", __func__); @@ -527,7 +524,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, if (cmd =3D=3D 0xd0) { /* confirm */ pfl->wcycle =3D 0; pfl->status |=3D 0x80; - } else if (cmd =3D=3D 0xff) { /* read array mode */ + } else if (cmd =3D=3D 0xff) { /* Read Array */ goto reset_flash; } else goto error_flash; @@ -554,7 +551,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, } else if (cmd =3D=3D 0x01) { pfl->wcycle =3D 0; pfl->status |=3D 0x80; - } else if (cmd =3D=3D 0xff) { + } else if (cmd =3D=3D 0xff) { /* read array mode */ goto reset_flash; } else { DPRINTF("%s: Unknown (un)locking command\n", __func__); @@ -646,7 +643,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, trace_pflash_reset(); memory_region_rom_device_set_romd(&pfl->mem, true); pfl->wcycle =3D 0; - pfl->cmd =3D 0; + pfl->cmd =3D 0xff; } =20 =20 @@ -762,7 +759,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Erro= r **errp) } =20 pfl->wcycle =3D 0; - pfl->cmd =3D 0; + pfl->cmd =3D 0xff; pfl->status =3D 0; /* Hardcoded CFI table */ /* Standard "QRY" string */ --=20 2.20.1 From nobody Sun May 19 17:58:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1562035503; cv=none; d=zoho.com; s=zohoarc; b=XSFriyIHQDhLkiFBnXtpIAYtOk2t0iPRqNPfF4M/E+QB4ciN++aOjlzvy23/HuQH6Ibd3KngXUreZ0MTwZf7mmiqvlqKNMYvQRK9iCkRVRJhWg4H7ZdDBaas1Zp9DD+wpsRNlibmHmL5kXQ3YBb8V0rdWVlZBEeavwN8ezCc5L0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562035503; 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:ARC-Authentication-Results; bh=vPO5AIoRXuTRdO/ZDZSwyu4O6sp5huAZIyzOTIAi98k=; b=WxjGzIeu1Jz+VhkwaIdv+7UJDe97xbu3Gd+xP6Z7RIQfCnaIp8rKcHGHMuDDT15DhsBawzfOuroF1EBC+EIEmKeoeJdD2t2kt1O9dCMblcaKBkryw51qRB4nDh4sVo8ujA4srRgb1Za6ixVTzCtfWrTMfTjVjjumQnvN7iSvKT8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1562035503858621.5573726473424; Mon, 1 Jul 2019 19:45:03 -0700 (PDT) Received: from localhost ([::1]:47504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi8mx-00010K-F2 for importer@patchew.org; Mon, 01 Jul 2019 22:44:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52892) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi6Rk-00018B-OV for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:14:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hi6Ri-0006vb-7v for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:14:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36494) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hi6RR-0006fq-I2; Mon, 01 Jul 2019 20:14:38 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 215B530872CC; Tue, 2 Jul 2019 00:14:25 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A9881001B01; Tue, 2 Jul 2019 00:14:06 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Tue, 2 Jul 2019 02:12:55 +0200 Message-Id: <20190702001301.4768-4-philmd@redhat.com> In-Reply-To: <20190702001301.4768-1-philmd@redhat.com> References: <20190702001301.4768-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 02 Jul 2019 00:14:25 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 3/9] hw/block/pflash_cfi01: Extract pflash_mode_read_array() 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: Peter Maydell , "Michael S. Tsirkin" , Max Filippov , Gerd Hoffmann , "Edgar E. Iglesias" , qemu-block@nongnu.org, Aleksandar Rikalo , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Markus Armbruster , Laszlo Ersek , David Gibson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , qemu-arm@nongnu.org, Alistair Francis , John Snow , Richard Henderson , Kevin Wolf , Max Reitz , Michael Walle , qemu-ppc@nongnu.org, Wei Yang , Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The same pattern is used when setting the flash in READ_ARRAY mode: - Set the state machine command to READ_ARRAY - Reset the write_cycle counter - Reset the memory region in ROMD Refactor the current code by extracting this pattern. It is used twice: - On a write access (on command failure, error, or explicitly asked) - When the device is initialized. Here the ROMD mode is hidden by the memory_region_init_rom_device() call. Rename the 'reset_flash' as 'mode_read_array' to make explicit we do not reset the device, we simply set its internal state machine in the READ_ARRAY mode. We do not reset the status register error bits, as a device reset would do. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Reviewed-by: John Snow --- hw/block/pflash_cfi01.c | 36 ++++++++++++++++++++---------------- hw/block/trace-events | 1 + 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 743b5d5794..33c77f6569 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -112,6 +112,14 @@ static const VMStateDescription vmstate_pflash =3D { } }; =20 +static void pflash_mode_read_array(PFlashCFI01 *pfl) +{ + trace_pflash_mode_read_array(); + pfl->cmd =3D 0xff; /* Read Array */ + pfl->wcycle =3D 0; + memory_region_rom_device_set_romd(&pfl->mem, true); +} + /* Perform a CFI query based on the bank width of the flash. * If this code is called we know we have a device_width set for * this flash. @@ -470,7 +478,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, case 0x50: /* Clear status bits */ DPRINTF("%s: Clear status bits\n", __func__); pfl->status =3D 0x0; - goto reset_flash; + goto mode_read_array; case 0x60: /* Block (un)lock */ DPRINTF("%s: Block unlock\n", __func__); break; @@ -495,10 +503,10 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr off= set, break; case 0xf0: /* Probe for AMD flash */ DPRINTF("%s: Probe for AMD flash\n", __func__); - goto reset_flash; + goto mode_read_array; case 0xff: /* Read array mode */ DPRINTF("%s: Read array mode\n", __func__); - goto reset_flash; + goto mode_read_array; default: goto error_flash; } @@ -525,7 +533,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, pfl->wcycle =3D 0; pfl->status |=3D 0x80; } else if (cmd =3D=3D 0xff) { /* Read Array */ - goto reset_flash; + goto mode_read_array; } else goto error_flash; =20 @@ -552,15 +560,15 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr off= set, pfl->wcycle =3D 0; pfl->status |=3D 0x80; } else if (cmd =3D=3D 0xff) { /* read array mode */ - goto reset_flash; + goto mode_read_array; } else { DPRINTF("%s: Unknown (un)locking command\n", __func__); - goto reset_flash; + goto mode_read_array; } break; case 0x98: if (cmd =3D=3D 0xff) { - goto reset_flash; + goto mode_read_array; } else { DPRINTF("%s: leaving query mode\n", __func__); } @@ -620,7 +628,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, " the data is already written to storage!\n" "Flash device reset into READ mode.\n", __func__); - goto reset_flash; + goto mode_read_array; } break; default: @@ -630,7 +638,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, default: /* Should never happen */ DPRINTF("%s: invalid write state\n", __func__); - goto reset_flash; + goto mode_read_array; } return; =20 @@ -639,11 +647,8 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offs= et, "(offset " TARGET_FMT_plx ", wcycle 0x%x cmd 0x%x value = 0x%x)" "\n", __func__, offset, pfl->wcycle, pfl->cmd, value); =20 - reset_flash: - trace_pflash_reset(); - memory_region_rom_device_set_romd(&pfl->mem, true); - pfl->wcycle =3D 0; - pfl->cmd =3D 0xff; + mode_read_array: + pflash_mode_read_array(pfl); } =20 =20 @@ -758,8 +763,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Erro= r **errp) pfl->max_device_width =3D pfl->device_width; } =20 - pfl->wcycle =3D 0; - pfl->cmd =3D 0xff; + pflash_mode_read_array(pfl); pfl->status =3D 0; /* Hardcoded CFI table */ /* Standard "QRY" string */ diff --git a/hw/block/trace-events b/hw/block/trace-events index 97a17838ed..d627cfc3f5 100644 --- a/hw/block/trace-events +++ b/hw/block/trace-events @@ -7,6 +7,7 @@ fdc_ioport_write(uint8_t reg, uint8_t value) "write reg 0x%= 02x val 0x%02x" # pflash_cfi02.c # pflash_cfi01.c pflash_reset(void) "reset" +pflash_mode_read_array(void) "mode: read array" pflash_read(uint64_t offset, uint8_t cmd, int width, uint8_t wcycle) "offs= et:0x%04"PRIx64" cmd:0x%02x width:%d wcycle:%u" pflash_write(uint64_t offset, uint32_t value, int width, uint8_t wcycle) "= offset:0x%04"PRIx64" value:0x%03x width:%d wcycle:%u" pflash_timer_expired(uint8_t cmd) "command 0x%02x done" --=20 2.20.1 From nobody Sun May 19 17:58:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1562035917; cv=none; d=zoho.com; s=zohoarc; b=cW7y9rD7ZvgxKCNuySv3pqhdy/w4k8AOT4+lBHySCXSBlNmgYBItAtGV0Tx2br0GiXVRSbPk35JPI3rOqALWFo/cR9nmmyUq58QoqLP+7emIEDzoITs0orJ5IGCRR17tvcXSvU0FXqgXzupubIZySTO7wagUCBamppoCT4Z+GUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562035917; 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:ARC-Authentication-Results; bh=f4Mjs58DjpSAoRfRs1XAH9yfOOv/w6uSEKRUZsNZc7Y=; b=cID3r8DVHZi3SeJP+jRpUzQPYyYwaaRdDpWiB7/vyFXU9nfvW4dq8ozDNqLAxrsuNlDs5cWnE91221Icve8VPl/SNrH95PQ9xOa+DY95DA39mUHxDEQm7NIX6RJCab1p1IeflBv6QtcBgvCtPjo87Wx02h8LXe0n8dTwqp/xrRs= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1562035917978917.4181802366267; Mon, 1 Jul 2019 19:51:57 -0700 (PDT) Received: from localhost ([::1]:47562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi8tT-0005Mb-Lp for importer@patchew.org; Mon, 01 Jul 2019 22:51:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53041) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi6SF-0001Ke-7m for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:15:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hi6SA-000787-Cx for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:15:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44344) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hi6Rc-0006r4-PL; Mon, 01 Jul 2019 20:14:50 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55F4C30860DC; Tue, 2 Jul 2019 00:14:47 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD2431001B01; Tue, 2 Jul 2019 00:14:25 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Tue, 2 Jul 2019 02:12:56 +0200 Message-Id: <20190702001301.4768-5-philmd@redhat.com> In-Reply-To: <20190702001301.4768-1-philmd@redhat.com> References: <20190702001301.4768-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 02 Jul 2019 00:14:47 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 4/9] hw/block/pflash_cfi01: Start state machine as READY to accept commands 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: Peter Maydell , "Michael S. Tsirkin" , Max Filippov , Gerd Hoffmann , "Edgar E. Iglesias" , qemu-block@nongnu.org, Aleksandar Rikalo , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Markus Armbruster , Laszlo Ersek , David Gibson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , qemu-arm@nongnu.org, Alistair Francis , John Snow , Richard Henderson , Kevin Wolf , Max Reitz , Michael Walle , qemu-ppc@nongnu.org, Wei Yang , Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When the state machine is ready to accept command, the bit 7 of the status register (SR) is set to 1. The guest polls the status register and check this bit before writting command to the internal 'Write State Machine' (WSM). Set SR.7 bit to 1 when the device is created. Reference: Read Array Flowchart "Common Flash Interface (CFI) and Command Sets" (Intel Application Note 646) Appendix B "Basic Command Set" Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Reviewed-by: John Snow --- hw/block/pflash_cfi01.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 33c77f6569..dd1dfd266b 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -764,7 +764,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Erro= r **errp) } =20 pflash_mode_read_array(pfl); - pfl->status =3D 0; + pfl->status =3D 0x80; /* WSM ready */ /* Hardcoded CFI table */ /* Standard "QRY" string */ pfl->cfi_table[0x10] =3D 'Q'; --=20 2.20.1 From nobody Sun May 19 17:58:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1562036817; cv=none; d=zoho.com; s=zohoarc; b=DgMZ7JnD2ENdUYTOUO0w5mNtc+JnHLRXag17y6dZ2ebkpMNHfTXcQRYtcUvp5EBSAaZ9SB76AduLpicS03JR/hJwRiHdKAh0gF94Vrdlc667z07zPTi5Hb8YseIhCLZZSr9Myi4A/2jSVGw4NiiK0prylV3u3V/xKvIik+Lsbt4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562036817; 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:ARC-Authentication-Results; bh=gh+IF3528QN9xxf9b4OJaTLOUNHEe/okfGUYFCVpSIo=; b=fdf/fIBNTZxYmsX+cFaaBu2UMZwJkJl9vZucHajbbrKLJKxb54r6D/DELs2CzKiwQPCQ3/IyQycpWHEUA7U1S8PYcToN26FqfkWIUSku+Klpkuhk843fDU37y2G4ljYa1F9ykFtfaOWPiqVO1e8Nj7M0CLSJXTrTMo8VQkDU6j8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1562036817707981.0342068405935; Mon, 1 Jul 2019 20:06:57 -0700 (PDT) Received: from localhost ([::1]:47776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi987-0004Oo-PV for importer@patchew.org; Mon, 01 Jul 2019 23:06:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53117) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi6SP-0001RB-3j for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:15:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hi6SN-0007Bv-TB for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:15:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54516) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hi6S4-00070Z-1S; Mon, 01 Jul 2019 20:15:17 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A60BFF74BC; Tue, 2 Jul 2019 00:15:07 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EEA1A1001B10; Tue, 2 Jul 2019 00:14:47 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Tue, 2 Jul 2019 02:12:57 +0200 Message-Id: <20190702001301.4768-6-philmd@redhat.com> In-Reply-To: <20190702001301.4768-1-philmd@redhat.com> References: <20190702001301.4768-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 02 Jul 2019 00:15:07 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 5/9] hw/block/pflash_cfi01: Add the DeviceReset() handler 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: Peter Maydell , "Michael S. Tsirkin" , Max Filippov , Gerd Hoffmann , "Edgar E. Iglesias" , qemu-block@nongnu.org, Aleksandar Rikalo , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Markus Armbruster , Laszlo Ersek , David Gibson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , qemu-arm@nongnu.org, Alistair Francis , John Snow , Richard Henderson , Kevin Wolf , Max Reitz , Michael Walle , qemu-ppc@nongnu.org, Wei Yang , Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" A "system reset" sets the device state machine in READ_ARRAY mode and, after some delay, set the SR.7 READY bit. We do not model timings, so we set the SR.7 bit directly. This pflash device is a child of TYPE_DEVICE. The TYPE_DEVICE interface provide a DeviceReset handler which will be called after the device is realized, and each time the machine resets itself. To avoid incoherent states when the machine resets (see but report below), factor out the reset code into pflash_cfi01_system_reset, and register the method as a device reset callback. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D1678713 Reported-by: Laszlo Ersek Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/block/pflash_cfi01.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index dd1dfd266b..8d632ea941 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -763,8 +763,6 @@ static void pflash_cfi01_realize(DeviceState *dev, Erro= r **errp) pfl->max_device_width =3D pfl->device_width; } =20 - pflash_mode_read_array(pfl); - pfl->status =3D 0x80; /* WSM ready */ /* Hardcoded CFI table */ /* Standard "QRY" string */ pfl->cfi_table[0x10] =3D 'Q'; @@ -852,6 +850,18 @@ static void pflash_cfi01_realize(DeviceState *dev, Err= or **errp) pfl->cfi_table[0x3f] =3D 0x01; /* Number of protection fields */ } =20 +static void pflash_cfi01_system_reset(DeviceState *dev) +{ + PFlashCFI01 *pfl =3D PFLASH_CFI01(dev); + + pflash_mode_read_array(pfl); + /* + * The WSM ready timer occurs at most 150ns after system reset. + * This model deliberately ignores this delay. + */ + pfl->status =3D 0x80; +} + static Property pflash_cfi01_properties[] =3D { DEFINE_PROP_DRIVE("drive", PFlashCFI01, blk), /* num-blocks is the number of blocks actually visible to the guest, @@ -896,6 +906,7 @@ static void pflash_cfi01_class_init(ObjectClass *klass,= void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 + dc->reset =3D pflash_cfi01_system_reset; dc->realize =3D pflash_cfi01_realize; dc->props =3D pflash_cfi01_properties; dc->vmsd =3D &vmstate_pflash; --=20 2.20.1 From nobody Sun May 19 17:58:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1562036434; cv=none; d=zoho.com; s=zohoarc; b=FVk2BUZnr8iCaVYGmgUVxTCNsc8U78NrP2y/6TJr02Pt+imvO7Dwo/KyJY9jMFmQnzFz4lXk+L4gD9ovMKJDHciXhL6/VgyJ+Is6TRtnuTs7wmsVP6zGreY1AomHTlWdBSflpv84AvftVAOZE/uLFf8+A/rELlheBYGXHwHBKzU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562036434; 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:ARC-Authentication-Results; bh=31cwnLrCT9yJ68fWYEjxfnsfPwxSbsVVG+Q3OvRzFzI=; b=NYm8IbHNypYcJMURUS3UjMEvKcX1OTc9m5aWaJcP2oPyvORCp6zX8+ojos3sACtnfZMnVe9tvXGKnpwC7412koL0QLIVWuYZ1WIeNIVtBfpVtw9jUQzPZWorGbJhP1d8jrLrPODzeBklZT90wBWc4kC0d4g/RvZwH3Ma+RdPei4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1562036434555645.5778513668658; Mon, 1 Jul 2019 20:00:34 -0700 (PDT) Received: from localhost ([::1]:47712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi921-0006LP-0t for importer@patchew.org; Mon, 01 Jul 2019 23:00:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53161) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi6SS-0001U3-0H for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:15:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hi6SR-0007DD-1h for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:15:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52600) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hi6SH-00079j-Fu; Mon, 01 Jul 2019 20:15:29 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 205313079B8E; Tue, 2 Jul 2019 00:15:28 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 66F001001B01; Tue, 2 Jul 2019 00:15:07 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Tue, 2 Jul 2019 02:12:58 +0200 Message-Id: <20190702001301.4768-7-philmd@redhat.com> In-Reply-To: <20190702001301.4768-1-philmd@redhat.com> References: <20190702001301.4768-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 02 Jul 2019 00:15:28 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 6/9] hw/block/pflash_cfi01: Simplify CFI_QUERY processing 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: Peter Maydell , "Michael S. Tsirkin" , Max Filippov , Gerd Hoffmann , "Edgar E. Iglesias" , qemu-block@nongnu.org, Aleksandar Rikalo , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Markus Armbruster , Laszlo Ersek , David Gibson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , qemu-arm@nongnu.org, Alistair Francis , John Snow , Richard Henderson , Kevin Wolf , Max Reitz , Michael Walle , qemu-ppc@nongnu.org, Wei Yang , Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The current code does: if (write_cycle =3D=3D 0) if (command =3D=3D CFI_QUERY) break write_cycle +=3D 1 last_command =3D command if (write_cycle =3D=3D 1) if (last_command =3D=3D CFI_QUERY) if (command =3D=3D READ_ARRAY write_cycle =3D 0 last_command =3D READ_ARRAY Simplify by not increasing the write_cycle on CFI_QUERY, the next command are processed as normal wcycle=3D0. This matches the hardware datasheet (we do not enter the WRITE state machine, thus no write cycle involved). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- hw/block/pflash_cfi01.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 8d632ea941..c1b02219b2 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -492,7 +492,8 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, return; case 0x98: /* CFI query */ DPRINTF("%s: CFI query\n", __func__); - break; + pfl->cmd =3D cmd; + return; case 0xe8: /* Write to buffer */ DPRINTF("%s: Write to buffer\n", __func__); /* FIXME should save @offset, @width for case 1+ */ @@ -566,13 +567,6 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offs= et, goto mode_read_array; } break; - case 0x98: - if (cmd =3D=3D 0xff) { - goto mode_read_array; - } else { - DPRINTF("%s: leaving query mode\n", __func__); - } - break; default: goto error_flash; } --=20 2.20.1 From nobody Sun May 19 17:58:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1562036145; cv=none; d=zoho.com; s=zohoarc; b=FqSUOO7/eTgdJJYKePuVtCHKuV6w4XVqGY7pi/x4HaMo/be7VpWp5pJc42CDiTU6zZWu3K2Ekg3wdh1VlNytqynyzW1CiHqAf5TyZz3lCygTIidSnTtgpGeUB+AiWZhn3Qv5UOekJBwRuOx7oIKKEMs0RcAAjGEJSUS9nrkG/8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562036145; 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:ARC-Authentication-Results; bh=PnM61XSHG9eIeTIBTJjrZhb9tTx3ZD6bCAkyqh9eb/4=; b=fR6UT32K3MWRDtACqOt0ZUDDZTk9MJMwq8Ijv54D5iMPlgmWHOPSuVmUgaoBEd0OvI988jocsCPDsTw2fad8ndMWcw/RfpBxtRTyOmx+W2Mj2lUMAfqg2pSxxke5zbNRGHiWNV1Tdru+3eArAw/iHpS+Z9auo53VaFPeV4jF3xs= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1562036145326379.6723164069912; Mon, 1 Jul 2019 19:55:45 -0700 (PDT) Received: from localhost ([::1]:47628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi8xJ-00015k-5D for importer@patchew.org; Mon, 01 Jul 2019 22:55:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53815) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi6US-0001pY-9R for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:18:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hi6TW-0007gY-Md for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:16:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44544) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hi6Sc-0007I1-34; Mon, 01 Jul 2019 20:15:50 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F3E2C30860DE; Tue, 2 Jul 2019 00:15:48 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E552A1001943; Tue, 2 Jul 2019 00:15:28 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Tue, 2 Jul 2019 02:12:59 +0200 Message-Id: <20190702001301.4768-8-philmd@redhat.com> In-Reply-To: <20190702001301.4768-1-philmd@redhat.com> References: <20190702001301.4768-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 02 Jul 2019 00:15:49 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 7/9] hw/block/pflash_cfi01: Improve command comments 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: Peter Maydell , "Michael S. Tsirkin" , Max Filippov , Gerd Hoffmann , "Edgar E. Iglesias" , qemu-block@nongnu.org, Aleksandar Rikalo , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Markus Armbruster , Laszlo Ersek , David Gibson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , qemu-arm@nongnu.org, Alistair Francis , John Snow , Richard Henderson , Kevin Wolf , Max Reitz , Michael Walle , qemu-ppc@nongnu.org, Wei Yang , Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- hw/block/pflash_cfi01.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index c1b02219b2..f50d0a9d37 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -208,11 +208,11 @@ static uint32_t pflash_devid_query(PFlashCFI01 *pfl, = hwaddr offset) * Offsets 2/3 are block lock status, is not emulated. */ switch (boff & 0xFF) { - case 0: + case 0: /* Manufacturer ID */ resp =3D pfl->ident0; trace_pflash_manufacturer_id(resp); break; - case 1: + case 1: /* Device ID */ resp =3D pfl->ident1; trace_pflash_device_id(resp); break; @@ -456,11 +456,11 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr off= set, case 0: /* read mode */ switch (cmd) { - case 0x10: /* Single Byte Program */ - case 0x40: /* Single Byte Program */ + case 0x10: /* Single Byte Program (setup) */ + case 0x40: /* Single Byte Program (setup) [Intel] */ DPRINTF("%s: Single Byte Program\n", __func__); break; - case 0x20: /* Block erase */ + case 0x20: /* Block erase (setup) */ p =3D pfl->storage; offset &=3D ~(pfl->sector_len - 1); =20 @@ -516,8 +516,8 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, break; case 1: switch (pfl->cmd) { - case 0x10: /* Single Byte Program */ - case 0x40: /* Single Byte Program */ + case 0x10: /* Single Byte Program (confirm) */ + case 0x40: /* Single Byte Program (confirm) [Intel] */ DPRINTF("%s: Single Byte Program\n", __func__); if (!pfl->ro) { pflash_data_write(pfl, offset, value, width, be); @@ -528,7 +528,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, pfl->status |=3D 0x80; /* Ready! */ pfl->wcycle =3D 0; break; - case 0x20: /* Block erase */ + case 0x20: /* Block erase (confirm) */ case 0x28: if (cmd =3D=3D 0xd0) { /* confirm */ pfl->wcycle =3D 0; --=20 2.20.1 From nobody Sun May 19 17:58:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1562036374; cv=none; d=zoho.com; s=zohoarc; b=Hya/nk1aKhngDkhIrMedCTqKd+0m9IOL66cgoaHeDA2zni77MGoIe5S7MaeEAPEIPee6JCTM4iSim0d5//VkAH+yXTI48bJ6CV1xIjmtdTtliEXhFjz7106zE8OjHBDay1H4NLtbdjmFvY9Ho5CY9ZU7sU6wLbTqQS6lJWUqctU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562036374; 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:ARC-Authentication-Results; bh=CUNz2Td9Rh9euVSOdVQevi+dkHHAs1FRmf5GMdwDsZI=; b=fJ5l2XMhVdf2kB6Ojjw6euzcm0ZniJTaHbIaO4w7RXwQlAUG9xNnRfDQmlCtNKYBB1YP6TwUs1qk10EF2vlsVvx00esIc9MFU+9mOZjuiMge/4rC0xZrUYpVIhCuQSXnyTLSdEZi52/cfci2tElneBUmeiIPy/5fFPOW5COzm40= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1562036374485370.3915246527406; Mon, 1 Jul 2019 19:59:34 -0700 (PDT) Received: from localhost ([::1]:47702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi90y-0005LS-7w for importer@patchew.org; Mon, 01 Jul 2019 22:59:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33357) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi75c-0001YH-Iw for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:56:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hi6VC-0008H8-7W for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:18:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36788) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hi6TG-0007NJ-QQ; Mon, 01 Jul 2019 20:16:31 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 34A80300C033; Tue, 2 Jul 2019 00:16:10 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C07B31001281; Tue, 2 Jul 2019 00:15:49 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Tue, 2 Jul 2019 02:13:00 +0200 Message-Id: <20190702001301.4768-9-philmd@redhat.com> In-Reply-To: <20190702001301.4768-1-philmd@redhat.com> References: <20190702001301.4768-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 02 Jul 2019 00:16:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 8/9] hw/block/pflash_cfi01: Replace DPRINTF by qemu_log_mask(GUEST_ERROR) 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: Peter Maydell , "Michael S. Tsirkin" , Max Filippov , Gerd Hoffmann , "Edgar E. Iglesias" , qemu-block@nongnu.org, Aleksandar Rikalo , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Markus Armbruster , Laszlo Ersek , David Gibson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , qemu-arm@nongnu.org, Alistair Francis , John Snow , Richard Henderson , Kevin Wolf , Max Reitz , Michael Walle , qemu-ppc@nongnu.org, Wei Yang , Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- hw/block/pflash_cfi01.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index f50d0a9d37..e891112b67 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -286,7 +286,9 @@ static uint32_t pflash_read(PFlashCFI01 *pfl, hwaddr of= fset, switch (pfl->cmd) { default: /* This should never happen : reset state & treat it as a read */ - DPRINTF("%s: unknown command state: %x\n", __func__, pfl->cmd); + qemu_log_mask(LOG_GUEST_ERROR, "%s: Invalid state, " + "wcycle %d cmd 0x02%x\n", + __func__, pfl->wcycle, pfl->cmd); pfl->wcycle =3D 0; pfl->cmd =3D 0xff; /* fall through to read code */ @@ -631,7 +633,9 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, break; default: /* Should never happen */ - DPRINTF("%s: invalid write state\n", __func__); + qemu_log_mask(LOG_GUEST_ERROR, "%s: Invalid state, " + "wcycle %d cmd (0x02%x -> value 0x02%x)\n", + __func__, pfl->wcycle, pfl->cmd, value); goto mode_read_array; } return; --=20 2.20.1 From nobody Sun May 19 17:58:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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=1562037269; cv=none; d=zoho.com; s=zohoarc; b=arKVYAjMYyAgLokY9voaZ0Pq7PCYykkcbL5lr/vbCiduJ5TzU4ELQ1dgl8s1o4MjKmPW3liInRyaNjwY2dYFBu1I8BYoYSoWH45mpQx/98EBQDtJPnB//lR1KX0d6vXsm6tA3l2xi+FGah2H0PFaJYdlsWQph4vOHpQKell7+SY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562037269; 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:ARC-Authentication-Results; bh=86b3a1xJfma5A9tMa8Ytn9XAT92HPBNuARql80Zg+b8=; b=aOz6I69f88ieyGxS509GY8LYfVCIoigZvzFypTHjsqSiPtsLCPU/dvwvoXvEG4sC2Ylzw2R7VS36UT19IwUzCmcelenjArge551TYXGrNKHfWbf3flLWQ6YIu75D88CedwgMLTb5CtWKZcKf1zS9mEi034Gec4aZugZKfif/zt8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1562037269537320.0639435997108; Mon, 1 Jul 2019 20:14:29 -0700 (PDT) Received: from localhost ([::1]:47852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi9FN-0004E8-UJ for importer@patchew.org; Mon, 01 Jul 2019 23:14:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58550) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hi6v4-0007Ya-KI for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:45:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hi6VJ-0008JI-Fy for qemu-devel@nongnu.org; Mon, 01 Jul 2019 20:18:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53582) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hi6TL-0007ZO-7s; Mon, 01 Jul 2019 20:16:41 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39F236EB96; Tue, 2 Jul 2019 00:16:32 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC2361001B32; Tue, 2 Jul 2019 00:16:10 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Tue, 2 Jul 2019 02:13:01 +0200 Message-Id: <20190702001301.4768-10-philmd@redhat.com> In-Reply-To: <20190702001301.4768-1-philmd@redhat.com> References: <20190702001301.4768-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 02 Jul 2019 00:16:32 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 9/9] hw/block/pflash_cfi01: Hold the PRI table offset in a variable 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: Peter Maydell , "Michael S. Tsirkin" , Max Filippov , Gerd Hoffmann , "Edgar E. Iglesias" , qemu-block@nongnu.org, Aleksandar Rikalo , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Markus Armbruster , Laszlo Ersek , David Gibson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eduardo Habkost , qemu-arm@nongnu.org, Alistair Francis , John Snow , Richard Henderson , Kevin Wolf , Max Reitz , Michael Walle , qemu-ppc@nongnu.org, Wei Yang , Aleksandar Markovic , Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Manufacturers are allowed to move the PRI table, this is why the offset is queryable via fixed offsets 0x15/0x16. Add a variable to hold the offset, so it will be easier to later move the PRI table. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- hw/block/pflash_cfi01.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index e891112b67..f65840eb2b 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -762,6 +762,7 @@ static void pflash_cfi01_realize(DeviceState *dev, Erro= r **errp) } =20 /* Hardcoded CFI table */ + const uint16_t pri_ofs =3D 0x31; /* Standard "QRY" string */ pfl->cfi_table[0x10] =3D 'Q'; pfl->cfi_table[0x11] =3D 'R'; @@ -770,14 +771,17 @@ static void pflash_cfi01_realize(DeviceState *dev, Er= ror **errp) pfl->cfi_table[0x13] =3D 0x01; pfl->cfi_table[0x14] =3D 0x00; /* Primary extended table address (none) */ - pfl->cfi_table[0x15] =3D 0x31; - pfl->cfi_table[0x16] =3D 0x00; + pfl->cfi_table[0x15] =3D pri_ofs; + pfl->cfi_table[0x16] =3D pri_ofs >> 8; /* Alternate command set (none) */ pfl->cfi_table[0x17] =3D 0x00; pfl->cfi_table[0x18] =3D 0x00; /* Alternate extended table (none) */ pfl->cfi_table[0x19] =3D 0x00; pfl->cfi_table[0x1A] =3D 0x00; + + /* CFI: System Interface Information */ + /* Vcc min */ pfl->cfi_table[0x1B] =3D 0x45; /* Vcc max */ @@ -802,6 +806,9 @@ static void pflash_cfi01_realize(DeviceState *dev, Erro= r **errp) pfl->cfi_table[0x25] =3D 0x04; /* Max timeout for chip erase */ pfl->cfi_table[0x26] =3D 0x00; + + /* CFI: Device Geometry Definition */ + /* Device size */ pfl->cfi_table[0x27] =3D ctz32(device_len); /* + 1; */ /* Flash device interface (8 & 16 bits) */ @@ -826,26 +833,30 @@ static void pflash_cfi01_realize(DeviceState *dev, Er= ror **errp) pfl->cfi_table[0x2E] =3D (blocks_per_device - 1) >> 8; pfl->cfi_table[0x2F] =3D sector_len_per_device >> 8; pfl->cfi_table[0x30] =3D sector_len_per_device >> 16; + assert(0x30 < pri_ofs); + + /* CFI: Primary-Vendor Specific */ =20 /* Extended */ - pfl->cfi_table[0x31] =3D 'P'; - pfl->cfi_table[0x32] =3D 'R'; - pfl->cfi_table[0x33] =3D 'I'; + pfl->cfi_table[0x00 + pri_ofs] =3D 'P'; + pfl->cfi_table[0x01 + pri_ofs] =3D 'R'; + pfl->cfi_table[0x02 + pri_ofs] =3D 'I'; =20 - pfl->cfi_table[0x34] =3D '1'; - pfl->cfi_table[0x35] =3D '0'; + pfl->cfi_table[0x03 + pri_ofs] =3D '1'; + pfl->cfi_table[0x04 + pri_ofs] =3D '0'; =20 - pfl->cfi_table[0x36] =3D 0x00; - pfl->cfi_table[0x37] =3D 0x00; - pfl->cfi_table[0x38] =3D 0x00; - pfl->cfi_table[0x39] =3D 0x00; + pfl->cfi_table[0x05 + pri_ofs] =3D 0x00; /* Optional features */ + pfl->cfi_table[0x06 + pri_ofs] =3D 0x00; + pfl->cfi_table[0x07 + pri_ofs] =3D 0x00; + pfl->cfi_table[0x08 + pri_ofs] =3D 0x00; =20 - pfl->cfi_table[0x3a] =3D 0x00; + pfl->cfi_table[0x09 + pri_ofs] =3D 0x00; /* Func. supported after susp= end */ =20 - pfl->cfi_table[0x3b] =3D 0x00; - pfl->cfi_table[0x3c] =3D 0x00; + pfl->cfi_table[0x0a + pri_ofs] =3D 0x00; /* Block status register mask= */ + pfl->cfi_table[0x0b + pri_ofs] =3D 0x00; =20 - pfl->cfi_table[0x3f] =3D 0x01; /* Number of protection fields */ + pfl->cfi_table[0x0e + pri_ofs] =3D 0x01; /* Number of protection field= s */ + assert(0x0e + pri_ofs < ARRAY_SIZE(pfl->cfi_table)); } =20 static void pflash_cfi01_system_reset(DeviceState *dev) --=20 2.20.1