From patchwork Fri May 22 17:45:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11566067 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79EB81391 for ; Fri, 22 May 2020 17:46:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5085120738 for ; Fri, 22 May 2020 17:46:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="C6g1BO8v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5085120738 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcBkh-0000Vi-Fz for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 May 2020 13:46:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcBjn-0007DT-Gv for qemu-devel@nongnu.org; Fri, 22 May 2020 13:45:39 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:59493 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 1jcBjk-0006De-RG for qemu-devel@nongnu.org; Fri, 22 May 2020 13:45:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590169535; 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=gFARda38uI5LKaq1O+Flf3O67TPescdkjgmAvm6EoVA=; b=C6g1BO8v36Gimo27HLZSrcMkrj3jbTmODSp6O88u4MM2rDut9M/UNPs8EzATzGSbj/Qb+d dQPwLGW3RfdePjgAm/clMmOZEENQ5GTuADhoaS9V8o5n/zoYZbUEVBdmXjXZWeUpPF8AtW mWIVMhfnH/hpww7210TlBb6gzRmx1u4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-484-D6NuH4naNd-C6uYxoIvo8w-1; Fri, 22 May 2020 13:45:32 -0400 X-MC-Unique: D6NuH4naNd-C6uYxoIvo8w-1 Received: by mail-wr1-f72.google.com with SMTP id x8so4672338wrl.16 for ; Fri, 22 May 2020 10:45:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gFARda38uI5LKaq1O+Flf3O67TPescdkjgmAvm6EoVA=; b=FHrk9Wx0XupW0GEH8QZ6Jh/3osecdr+lydPCvJwdj1UoglQGbW03FZHjRQIZRlOXJ7 OCo+EivgHEWj5zQVnbr7LxYWnQQDQHHTVD6vbbTVyTQDSmVbIqPgmTQPiTE2NPFbow+A KxnjviwirFz++8Psod/KA+QUfUshW+ewTIyvCPwQZK+nO7RHSTHfJgzJPMEp83V28enC ngYZrwh9hMWPWZfwBNNAIVATpTwZ6QGj5K+39oy41mMR9XcWFPr+CEfd4BpwHBr//E3A 51X8DaeG78oImHk2u2cyiUtsCE27CWekcDp5wtNTpmloEhpqtyoZIzH+Jv2GjGSb66Hq vHsQ== X-Gm-Message-State: AOAM532IKNsONE5SHofugyYeIgoPb5I6Dn6bTvH4AYNzmlqfh0/9nUZV CowqX8dBzaeQGnaFVkgZaVqyi9rVPUlKlurPp7295McsbSsPXkp6hWrbQDAeTPDDmAgoWamD9FJ 9pcSpZ3XDf7RXCmU= X-Received: by 2002:a7b:cf2c:: with SMTP id m12mr2325183wmg.70.1590169530877; Fri, 22 May 2020 10:45:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlYUiP2QPSXxk1lO2RckYv3wfLRr8jMzClSL2DViVr9f1j1GbuSVBtsysTUajaV6qq/g4y1A== X-Received: by 2002:a7b:cf2c:: with SMTP id m12mr2325168wmg.70.1590169530619; Fri, 22 May 2020 10:45:30 -0700 (PDT) Received: from localhost.localdomain (17.red-88-21-202.staticip.rima-tde.net. [88.21.202.17]) by smtp.gmail.com with ESMTPSA id v11sm10344738wrv.53.2020.05.22.10.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 10:45:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 1/4] hw/block/pflash_cfi01: Removed an unused timer Date: Fri, 22 May 2020 19:45:21 +0200 Message-Id: <20200522174524.29152-2-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200522174524.29152-1-philmd@redhat.com> References: <20200522174524.29152-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/22 10:36:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, =?utf-8?q?Philippe?= =?utf-8?q?_Mathieu-Daud=C3=A9?= , Max Reitz , Alistair Francis , Wei Yang , Laszlo Ersek Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Alistair Francis Tested-by: Laszlo Ersek [Laszlo Ersek: Regression tested EDK2 OVMF IA32X64, ArmVirtQemu Aarch64 https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg04373.html] Message-Id: <20190716221555.11145-2-philmd@redhat.com> Signed-off-by: Philippe Mathieu-Daudé --- 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 8e8887253d..d67f84d655 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -42,7 +42,6 @@ #include "hw/qdev-properties.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" @@ -91,7 +90,6 @@ struct PFlashCFI01 { uint8_t cfi_table[0x52]; uint64_t counter; unsigned int writeblock_size; - QEMUTimer *timer; MemoryRegion mem; char *name; void *storage; @@ -115,18 +113,6 @@ static const VMStateDescription vmstate_pflash = { } }; -static void pflash_timer (void *opaque) -{ - PFlashCFI01 *pfl = opaque; - - trace_pflash_timer_expired(pfl->cmd); - /* Reset flash */ - pfl->status ^= 0x80; - memory_region_rom_device_set_romd(&pfl->mem, true); - pfl->wcycle = 0; - pfl->cmd = 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, Error **errp) pfl->max_device_width = pfl->device_width; } - pfl->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, pflash_timer, pfl); pfl->wcycle = 0; pfl->cmd = 0; pfl->status = 0x80; /* WSM ready */ From patchwork Fri May 22 17:45:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11566073 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08FC81391 for ; Fri, 22 May 2020 17:48:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D47C42072C for ; Fri, 22 May 2020 17:48:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="T+eH1pWJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D47C42072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcBmh-00032q-4g for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 May 2020 13:48:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcBjo-0007Hy-Sm for qemu-devel@nongnu.org; Fri, 22 May 2020 13:45:40 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:21013 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 1jcBjo-0006Fd-0X for qemu-devel@nongnu.org; Fri, 22 May 2020 13:45:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590169538; 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=mGJcMQjK5aZXrUwTJnYJzoIr1ktljNKQXX01xjHQ4Jg=; b=T+eH1pWJw39HIvQe+IZKJxcZA/rknQsQJkPUmoIrRYB3rcRFga2C0rpGIS9EfCmDhxwGcW jiXdRbrscPsvVcLGIjA/78kTf736OMaL2O/6ngHVasqoYtWHZbL8YeHtrVLbeLomAynRti B2prFg6FAqrsX21XiNxr+YR0GVLbBX8= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-67-A6a7LrhJNMGlPJ7sfQ6g4Q-1; Fri, 22 May 2020 13:45:37 -0400 X-MC-Unique: A6a7LrhJNMGlPJ7sfQ6g4Q-1 Received: by mail-wr1-f72.google.com with SMTP id l1so989326wrc.8 for ; Fri, 22 May 2020 10:45:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mGJcMQjK5aZXrUwTJnYJzoIr1ktljNKQXX01xjHQ4Jg=; b=Pr7Qy2gG7Y9GqoxWsKr55XAMguRE/+ZLs7+blUMPuJ01gDj6PMNAseieEKHsstmjJY PAfVXCKXlK5zJta7xGIPbWe+VY6Y6H8//+MV23wgTFiAo53249yleqh1vIoOWNQmMb6A v22yQhO+6ped2InR5Mjpkgsijzru4RgSDwcAwfb0R61fqjGFAXK5nYBG1Dd8h+L/8kXi yMwY5LSDtPAqquk6laeASwQcvM/0TK4pxGOmkIqtX8ub1k3bi4stcqb4+NA85dbMoI0q T0eOZusxazxnYjVlXyv4UJYn2X6Lv1XZPIu7T2LU7CYa2tSNotDThgwJXRHiC2ZXe+tp obPg== X-Gm-Message-State: AOAM533RI5nS5BVbas6dF3ti2wsO3jljVoy1Ed7nGsk86oWSJYRL/Wf9 U62LrM5Z0MeyNSgZUZ//6lNbBabpnMeP81DLrW59dbP3Kb2pjZ+PRPfVO91LAqR1SHZZDxOMZXW u5dm3t3OEAlatbSI= X-Received: by 2002:adf:f6c4:: with SMTP id y4mr4626891wrp.81.1590169535540; Fri, 22 May 2020 10:45:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6BGywPYoOqVPY864Pzp2yne9Jhxx9xgvedyiPGFH1HwdZrMo9OHG9eTi66A06fhR6Uppolw== X-Received: by 2002:adf:f6c4:: with SMTP id y4mr4626873wrp.81.1590169535277; Fri, 22 May 2020 10:45:35 -0700 (PDT) Received: from localhost.localdomain (17.red-88-21-202.staticip.rima-tde.net. [88.21.202.17]) by smtp.gmail.com with ESMTPSA id a184sm10220663wmh.24.2020.05.22.10.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 10:45:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 2/4] hw/block/pflash_cfi01: Document use of non-CFI compliant command '0x00' Date: Fri, 22 May 2020 19:45:22 +0200 Message-Id: <20200522174524.29152-3-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200522174524.29152-1-philmd@redhat.com> References: <20200522174524.29152-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/22 11:12:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alistair Francis , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The command 0x00 is used by this model since its origin (commit 05ee37ebf630). In this commit the command is described with a amusing '/* ??? */' comment, probably meaning 'FIXME'. switch (cmd) { case 0x00: /* ??? */ ... This comment survived 12 years because the 0x00 value is indeed not specified by the CFI open standard (as of this commit). The 'cmd' field is transfered during migration. To keep the migration feature working with older QEMU version, we have to take a lot of care with migrated field. We figured out it is too late to remove a non-specified value from this model (this would make migration review very complex). It is however not too late to improve the documentation. Add few comments to remember this is a special value related to QEMU, and we won't find information about it on the CFI spec. Reviewed-by: Alistair Francis Message-Id: <20190716221555.11145-3-philmd@redhat.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/block/pflash_cfi01.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index d67f84d655..3cd483d26a 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -278,9 +278,13 @@ static uint32_t pflash_read(PFlashCFI01 *pfl, hwaddr offset, /* This should never happen : reset state & treat it as a read */ DPRINTF("%s: unknown command state: %x\n", __func__, pfl->cmd); pfl->wcycle = 0; - pfl->cmd = 0; + /* + * The command 0x00 is not assigned by the CFI open standard, + * but QEMU historically uses it for the READ_ARRAY command (0xff). + */ + pfl->cmd = 0x00; /* fall through to read code */ - case 0x00: + case 0x00: /* This model reset value for READ_ARRAY (not CFI compliant) */ /* Flash area read */ ret = pflash_data_read(pfl, offset, width, be); break; @@ -449,7 +453,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, case 0: /* read mode */ switch (cmd) { - case 0x00: /* ??? */ + case 0x00: /* This model reset value for READ_ARRAY (not CFI) */ goto reset_flash; case 0x10: /* Single Byte Program */ case 0x40: /* Single Byte Program */ @@ -646,7 +650,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, trace_pflash_reset(); memory_region_rom_device_set_romd(&pfl->mem, true); pfl->wcycle = 0; - pfl->cmd = 0; + pfl->cmd = 0x00; /* This model reset value for READ_ARRAY (not CFI) */ } @@ -762,7 +766,11 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp) } pfl->wcycle = 0; - pfl->cmd = 0; + /* + * The command 0x00 is not assigned by the CFI open standard, + * but QEMU historically uses it for the READ_ARRAY command (0xff). + */ + pfl->cmd = 0x00; pfl->status = 0x80; /* WSM ready */ /* Hardcoded CFI table */ /* Standard "QRY" string */ From patchwork Fri May 22 17:45:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11566069 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98CB8913 for ; Fri, 22 May 2020 17:47:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7026D20738 for ; Fri, 22 May 2020 17:47:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AnNVy4m0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7026D20738 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcBlC-0001G0-Ky for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 May 2020 13:47:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcBjt-0007VW-JQ for qemu-devel@nongnu.org; Fri, 22 May 2020 13:45:45 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:42014 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 1jcBjs-0006HM-FG for qemu-devel@nongnu.org; Fri, 22 May 2020 13:45:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590169543; 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=9opZe6voHNiZF2I8d27OC0NCQS7HY6LsO5ZpOjdW7vY=; b=AnNVy4m0xBDYI2bYJIsZmWtZaSSUZnIBg0S5iepPc6KPw7IHnZ9s+ul7v/rSW6yVG5cpnN Un3FgCRdUgdUz1dMD7cYiabnf9nEut2YuBR+UlS8yyhC//CZvyu8agsTxNCVNuhUdiJfmA LgDJp1EcyDvucudOJYTVdh85o3+cdHk= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-45-ooJHew8YNa6OJheTQPeCCQ-1; Fri, 22 May 2020 13:45:41 -0400 X-MC-Unique: ooJHew8YNa6OJheTQPeCCQ-1 Received: by mail-wr1-f69.google.com with SMTP id c14so3513977wrm.15 for ; Fri, 22 May 2020 10:45:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9opZe6voHNiZF2I8d27OC0NCQS7HY6LsO5ZpOjdW7vY=; b=ewPJf1qokZ9MOb7CW4ZzjFqdydpyraSRNBrZQ72xwBC/R6GtQtUO1Cpo9lQhjIY8Aa 8DXgfzPc2qbydeEQx9V6AX3go9hp4FB4VGs3e9WdHVhHmRkMkmpHqDe2b88fhH76a7Ss XFfTNc1NFX+7QiXOFAHMA6xsZ1Bn4sJRJa0Jsi+bLVDF+MzUQEChvPUEyUC8IzHxXdtA Qgav79SLi343oXe44pVdbZPkxhzZhhyzBx3heWQrkwtJA0mrtzYyPjlrQlowsySppjk/ 1Mag0vh6jV8CcbWU3bZOenJAkdiFF21EWVc651ZNwKhI4lu7UMJrDjjYbwKzPELS+NuX hIRA== X-Gm-Message-State: AOAM531+3Y2ywzBQcjDIb8TXb7Cd5wTEHrfcfQ47riP6J7XlBMKOG2rc ShIaQ+v3I8z/zWvo+880+6WoMeS1VkcL6D9NHhpesNh9C+TJprxvIo+tKPTxC2HW6sdbJOrqeN6 gt8scLGBbnbN0fZ4= X-Received: by 2002:a1c:66d6:: with SMTP id a205mr15142861wmc.163.1590169539963; Fri, 22 May 2020 10:45:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNzIjvevKGKpccIR4WKM+keCZWuLDXzUXtOv4tnp4kCYxUV6JNXAPbL3Ci7J9jeunL4WoQHA== X-Received: by 2002:a1c:66d6:: with SMTP id a205mr15142845wmc.163.1590169539796; Fri, 22 May 2020 10:45:39 -0700 (PDT) Received: from localhost.localdomain (17.red-88-21-202.staticip.rima-tde.net. [88.21.202.17]) by smtp.gmail.com with ESMTPSA id 88sm7549072wre.45.2020.05.22.10.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 10:45:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 3/4] hw/block/pflash_cfi01: Rename 'reset_flash' label as 'mode_read_array' Date: Fri, 22 May 2020 19:45:23 +0200 Message-Id: <20200522174524.29152-4-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200522174524.29152-1-philmd@redhat.com> References: <20200522174524.29152-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/22 08:01:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, =?utf-8?q?Philippe?= =?utf-8?q?_Mathieu-Daud=C3=A9?= , Max Reitz , Alistair Francis , John Snow Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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. Reviewed-by: John Snow Reviewed-by: Alistair Francis Message-Id: <20190716221555.11145-5-philmd@redhat.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/block/pflash_cfi01.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 3cd483d26a..2ca173aa46 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -454,7 +454,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, /* read mode */ switch (cmd) { case 0x00: /* This model reset value for READ_ARRAY (not CFI) */ - goto reset_flash; + goto mode_read_array; case 0x10: /* Single Byte Program */ case 0x40: /* Single Byte Program */ DPRINTF("%s: Single Byte Program\n", __func__); @@ -477,7 +477,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, case 0x50: /* Clear status bits */ DPRINTF("%s: Clear status bits\n", __func__); pfl->status = 0x0; - goto reset_flash; + goto mode_read_array; case 0x60: /* Block (un)lock */ DPRINTF("%s: Block unlock\n", __func__); break; @@ -502,10 +502,10 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, break; case 0xf0: /* Probe for AMD flash */ DPRINTF("%s: Probe for AMD flash\n", __func__); - goto reset_flash; - case 0xff: /* Read array mode */ + goto mode_read_array; + case 0xff: /* Read Array */ DPRINTF("%s: Read array mode\n", __func__); - goto reset_flash; + goto mode_read_array; default: goto error_flash; } @@ -531,8 +531,8 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, if (cmd == 0xd0) { /* confirm */ pfl->wcycle = 0; pfl->status |= 0x80; - } else if (cmd == 0xff) { /* read array mode */ - goto reset_flash; + } else if (cmd == 0xff) { /* Read Array */ + goto mode_read_array; } else goto error_flash; @@ -558,16 +558,16 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, } else if (cmd == 0x01) { pfl->wcycle = 0; pfl->status |= 0x80; - } else if (cmd == 0xff) { - goto reset_flash; + } else if (cmd == 0xff) { /* Read Array */ + 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 == 0xff) { - goto reset_flash; + if (cmd == 0xff) { /* Read Array */ + goto mode_read_array; } else { DPRINTF("%s: leaving query mode\n", __func__); } @@ -627,7 +627,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, " 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: @@ -637,7 +637,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, default: /* Should never happen */ DPRINTF("%s: invalid write state\n", __func__); - goto reset_flash; + goto mode_read_array; } return; @@ -646,7 +646,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset, "(offset " TARGET_FMT_plx ", wcycle 0x%x cmd 0x%x value 0x%x)" "\n", __func__, offset, pfl->wcycle, pfl->cmd, value); - reset_flash: + mode_read_array: trace_pflash_reset(); memory_region_rom_device_set_romd(&pfl->mem, true); pfl->wcycle = 0; From patchwork Fri May 22 17:45:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11566081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFB261391 for ; Fri, 22 May 2020 17:49:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96D502072C for ; Fri, 22 May 2020 17:49:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZAMlAEPJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96D502072C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:56192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcBnm-0004Y8-S4 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 May 2020 13:49:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcBjw-0007fh-Uy for qemu-devel@nongnu.org; Fri, 22 May 2020 13:45:50 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:26235 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 1jcBjv-0006I6-Uj for qemu-devel@nongnu.org; Fri, 22 May 2020 13:45:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590169547; 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=ZDKCWTN0BUU3keGoiOAEHskel55kf5sdpYAUP1vRz1g=; b=ZAMlAEPJ8SSLANT99opdA2t5bPhmyhrJ/m1t7Y7PRjvWGbSUkBPCsNDX6ja5Ni3I/xN03x DRjOzTzYbIpSErj2qlr+kfVxTJ+bR4ftITN1qDpKorffs5LlT3kps2Oh6QrOAhvRzVKxwL KB6bEEbMj6Uz8y8HREgJ58skfJqu9h0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-UzQuEz6ENgalx2cC5dsREQ-1; Fri, 22 May 2020 13:45:45 -0400 X-MC-Unique: UzQuEz6ENgalx2cC5dsREQ-1 Received: by mail-wm1-f71.google.com with SMTP id l2so4435073wmi.2 for ; Fri, 22 May 2020 10:45:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZDKCWTN0BUU3keGoiOAEHskel55kf5sdpYAUP1vRz1g=; b=rMnDOHI31lMiQivsBOfD+JoXIyTyoMZ98mI79EYIuftJF7hOhm8RCjswXnGvkmwuQs KjPvS3ZSp4JnObHxxBsKl1x8Zc5n6bmS65O9ooedeG4M3Cd2wIW+sUDmLsgsxb6paSwY a0hnJ3qqDxHC7Nza1zjAQ0qxBfBczpiogyYwfdgMsH5f5RU9lPUB3XkJ+IuHrcG/l0Ew NERVtz/lYfEE46YSkJWJ5kZdpTSWvYNJqM+qUekyNq5WKVtUnnlDXbAbawRlPVAd7wil pBcB4DCeYN4CBED7SqlMTuaNZU17nSirHQ2kjQb6PdDAp1JuGfnfrbCI5AbzUSuYb6/D yY1w== X-Gm-Message-State: AOAM531RBi6PZPdC0k+l544tj27o76u15HuSMQVAzBL2Ux4z+o45MAAQ EXcXUhRSEyTZrPfdD9p2d5c050X+3h2eo6YdYlgv8IpIRBmEICdv6/ZSKra/yOILWZ98+Ns4+Lo BIsQcO1tSRIQZB+M= X-Received: by 2002:a1c:7d92:: with SMTP id y140mr13910653wmc.10.1590169544369; Fri, 22 May 2020 10:45:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDCEEyReoRGKrZz+Zpl9TngdOt730rvbP7Vh1S10CiWTf8tV8KAsF3/kbQhqb+tSuLH9QH5w== X-Received: by 2002:a1c:7d92:: with SMTP id y140mr13910640wmc.10.1590169544190; Fri, 22 May 2020 10:45:44 -0700 (PDT) Received: from localhost.localdomain (17.red-88-21-202.staticip.rima-tde.net. [88.21.202.17]) by smtp.gmail.com with ESMTPSA id p23sm10058484wma.17.2020.05.22.10.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 10:45:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 4/4] hw/block/pflash: Check return value of blk_pwrite() Date: Fri, 22 May 2020 19:45:24 +0200 Message-Id: <20200522174524.29152-5-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200522174524.29152-1-philmd@redhat.com> References: <20200522174524.29152-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/22 10:36:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Mansour Ahmadi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Mansour Ahmadi When updating the PFLASH file contents, we should check for a possible failure of blk_pwrite(). Similar to commit 3a688294e. Reported-by: Coverity (CID 1357678 CHECKED_RETURN) Signed-off-by: Mansour Ahmadi Message-Id: <20200408003552.58095-1-mansourweb@gmail.com> [PMD: Add missing "qemu/error-report.h" include and TODO comment] Signed-off-by: Philippe Mathieu-Daudé --- hw/block/pflash_cfi01.c | 8 +++++++- hw/block/pflash_cfi02.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 2ca173aa46..11922c0f96 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -42,6 +42,7 @@ #include "hw/qdev-properties.h" #include "sysemu/block-backend.h" #include "qapi/error.h" +#include "qemu/error-report.h" #include "qemu/bitops.h" #include "qemu/error-report.h" #include "qemu/host-utils.h" @@ -389,13 +390,18 @@ static void pflash_update(PFlashCFI01 *pfl, int offset, int size) { int offset_end; + int ret; if (pfl->blk) { offset_end = offset + size; /* widen to sector boundaries */ offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE); offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE); - blk_pwrite(pfl->blk, offset, pfl->storage + offset, + ret = blk_pwrite(pfl->blk, offset, pfl->storage + offset, offset_end - offset, 0); + if (ret < 0) { + /* TODO set error bit in status */ + error_report("Could not update PFLASH: %s", strerror(-ret)); + } } } diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index c277b0309d..ac7e34ecbf 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -37,6 +37,7 @@ #include "hw/block/flash.h" #include "hw/qdev-properties.h" #include "qapi/error.h" +#include "qemu/error-report.h" #include "qemu/bitmap.h" #include "qemu/timer.h" #include "sysemu/block-backend.h" @@ -393,13 +394,18 @@ static uint64_t pflash_read(void *opaque, hwaddr offset, unsigned int width) static void pflash_update(PFlashCFI02 *pfl, int offset, int size) { int offset_end; + int ret; if (pfl->blk) { offset_end = offset + size; /* widen to sector boundaries */ offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE); offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE); - blk_pwrite(pfl->blk, offset, pfl->storage + offset, + ret = blk_pwrite(pfl->blk, offset, pfl->storage + offset, offset_end - offset, 0); + if (ret < 0) { + /* TODO set error bit in status */ + error_report("Could not update PFLASH: %s", strerror(-ret)); + } } }