From patchwork Wed Mar 13 08:57:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591128 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7EB99C54791 for ; Wed, 13 Mar 2024 08:59:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKRj-0007aV-Rf; Wed, 13 Mar 2024 04:58:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKRi-0007Zm-5w for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:58:46 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKRg-0002Ci-O6 for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:58:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8ou60ZFfGz5wGuATfQwlf3o/Sr8yITEBKcHYAHL8PJg=; b=nRm+swVMS5GtExiogDX+ko214U ZUavRH1cqgLILijo9cmVatQGZYQWkiXjD4L/WpvtOX87yFwVVKVpXlUlo56nmYxf2pWvpZIlm14Pr cqTiSnaXE38hdIkwhF7ID+9HMSS34gjmtFR7t89oO1ONEFPS1GQXDxQ29xPFEv+7MooWoRikdwnBv y6sThI4CQ4Yc35oPKFkOL50g2MxKLDos9LHOWu9f+ggFvvK+y8sW78Oj6QSgsdMNcMkC1JcG4LJen DZ9wQSwKqI+JDzOPW5PUpg4/5/WLQgoN5SvWZng7TpPqZZGgqRnikh1ki3RODzFwAL5j5SPSTshRc y34E+8W+LC7CpBOMwU3TO2L4z+OtEx8/2iXRXMvRrYjkJx9zyw6WdUAG3RGunAnCQZllVqiil/ouL uh/qiaYQAMQw0mG2VWiNZu8JjGtbPb9/orECuR2QwDM/AdhwQD302JmRf7hg1IVIOWUq8pZ9dseGw OGoy6l4Q8e5hR45iVH47D7km7SVdW+y0x+xJKlJEX9UjalFGZn2mys8lGw2i1VyTo4foZFkz2+WQf lxa/gnkMf5AACpPvYJb5M6SXzF9C6eus2ZaKxrzNYQ6/3urv5ii/CWuWu0HyuUXHNcsVbf0gooW1V OLnawhpRAkFqS0MzSsY+ZgJDaD1u76VN46RSh4OQ4=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKQl-000CUN-9d; Wed, 13 Mar 2024 08:57:51 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:57:55 +0000 Message-Id: <20240313085810.2655062-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 01/16] esp.c: replace cmdfifo use of esp_fifo_pop_buf() in do_command_phase() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The aim is to restrict the esp_fifo_*() functions so that they only operate on the hardware FIFO. When reading from cmdfifo in do_command_phase() use the underlying Fifo8 functions directly. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 590ff99744..f8230c74b3 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -265,7 +265,7 @@ static void esp_do_nodma(ESPState *s); static void do_command_phase(ESPState *s) { - uint32_t cmdlen; + uint32_t cmdlen, n; int32_t datalen; SCSIDevice *current_lun; uint8_t buf[ESP_CMDFIFO_SZ]; @@ -275,7 +275,7 @@ static void do_command_phase(ESPState *s) if (!cmdlen || !s->current_dev) { return; } - esp_fifo_pop_buf(&s->cmdfifo, buf, cmdlen); + memcpy(buf, fifo8_pop_buf(&s->cmdfifo, cmdlen, &n), cmdlen); current_lun = scsi_device_find(&s->bus, 0, s->current_dev->id, s->lun); if (!current_lun) { From patchwork Wed Mar 13 08:57:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3746FC54E58 for ; Wed, 13 Mar 2024 08:59:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKRn-0007b9-NF; Wed, 13 Mar 2024 04:58:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKRm-0007ay-1u for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:58:50 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKRk-0002Dn-LL for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:58:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+WHNdaOKHm7Ucu9jlXaFyhsYY37eka0uaRCKHKRa+UA=; b=icG4CAJ1Uees4OVM/Mg7ePPDeL Y45qyMyFlPBkuulUqyqaFV6/CuWrAewkb0crpw/TEGK0BJqmxhE3hfw3/xGtiHUVrdGtyWzJLwT+t SuvhlkTqaqmub3WfbAq8YrKfAUdm4mRLQngklayxAN6n2kKVTH2lOZG7TKEjBS4CWzhVpbeXtHTzL jiksq1Ogx1KfnLFrAjk1xHeYKR+D6Y5X7V+Bb7bCKxv3FEqYakHGV3jpVdLKQF/DqX+aDOvLYCXyK hnZKXRnvscxG6AdCYxRYWwteIdUPH2Uu5XVTwSsSA617CtB3uD/daPkRf3HVixH7pBzAQgfr0mGVA TLWSG/HKJJqbOu3U/tb+JFrKvpOcTTj1TkraY/MAxG1MyZ36clcNR/e4rnY/cjs3S6llXrkMCIXXg R3jvJyB0ET6eh2DoC5zCYBNKrGGo9exRrW1kH4QrnokFrTNk9een3rLH4GYnesKVpdMNxuo6jO8CO Ec30L5KylO+pEEKFpeW4NZl1Z60kwTAEHPuB6oL2NGQoTC92HbI9jcvVP+8OxR/gsoJ1I43PIK6bA POAWnnp86BlcRCzLmgtKzfFj3ytGLuQyfzW4yyukdImcnmhD7CF5W+V6KSzh03lfFRIJOn1XBkx5w YJUVdj//ZEd2Xx216aNHLxC/gfOJ2xQqqN8dAv4gs=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKQp-000CUN-JI; Wed, 13 Mar 2024 08:57:55 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:57:56 +0000 Message-Id: <20240313085810.2655062-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 02/16] esp.c: replace cmdfifo use of esp_fifo_pop_buf() in do_message_phase() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The aim is to restrict the esp_fifo_*() functions so that they only operate on the hardware FIFO. When reading from cmdfifo in do_message_phase() use the underlying Fifo8 functions directly. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index f8230c74b3..100560244b 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -309,6 +309,8 @@ static void do_command_phase(ESPState *s) static void do_message_phase(ESPState *s) { + uint32_t n; + if (s->cmdfifo_cdb_offset) { uint8_t message = esp_fifo_pop(&s->cmdfifo); @@ -320,7 +322,10 @@ static void do_message_phase(ESPState *s) /* Ignore extended messages for now */ if (s->cmdfifo_cdb_offset) { int len = MIN(s->cmdfifo_cdb_offset, fifo8_num_used(&s->cmdfifo)); - esp_fifo_pop_buf(&s->cmdfifo, NULL, len); + + if (len) { + fifo8_pop_buf(&s->cmdfifo, len, &n); + } s->cmdfifo_cdb_offset = 0; } } From patchwork Wed Mar 13 08:57:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DDDABC54791 for ; Wed, 13 Mar 2024 08:59:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKRq-0007bq-JR; Wed, 13 Mar 2024 04:58:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKRp-0007bQ-Jt for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:58:53 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKRo-0002Ef-7x for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:58:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=0fckCtdAs7r1KlB/LRZZ2cQg6ZKtZEkOPsZO/6bCfjc=; b=RtFVETXTd42mqQ0/q9V6ZSJxR5 e2nSyBQusnW2quEFDBvf0RXGkL6oGbRn3XWjs/+282N0BcT38XKs5gVTcVMUGTIEYMMx30qmpiWzg EU8HjawFELNwf1ll8AqoYiL1nW/ATOyc/W1lVdnOhW4ujuPL6bKpXzZMwaNjC4mCb6OmU4xPH0if/ pRNkrWqYlM74N9Mo8quaVZgk+efmbXudZoct/8jiA548Mhz64w8jttpoQyAW3U/EJxGAXAC/7pUU7 A6Xr44+nL11tLVMEWZ7l1V4FlaOl+Pl4A7kJQYYqjORJzwvSu541wjTfG6yI/P8t4WyNFDf5hK/oa S7KGVYjjnxUQgf8e5ZR8FSjl7dYDvh0Xn1gP0j1pJRKdOYXLVFzVxFDFHrji985o8YVSNTQNuM4XA UD8BVjWsG3qg0DaY4/2ppuQiexdqBMy+X33IWC7Juul6iUYHbxc2AF0U2JtgL72fz8WO8PrwjcIQh +PIqxZubmkWqq+MQKBjAnaqB6LHVcugmF6YkHPYsAaz7jOd2tuJforG6j8JJ/KREPSQHCxXnKQXTo 9PcLZ4/wIx+2cuHlczbUgIAnkviH11v001UtqYu51Ka+jIUjloy8TUvwvMayDdK3Abt+closle5G/ ypFvneIB1XsR11iRKlJZNLSJNyMFf9LGa3OLvtvnM=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKQt-000CUN-PS; Wed, 13 Mar 2024 08:57:59 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:57:57 +0000 Message-Id: <20240313085810.2655062-4-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 03/16] esp.c: replace cmdfifo use of esp_fifo_pop() in do_message_phase() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 100560244b..7a24515bb9 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -312,7 +312,8 @@ static void do_message_phase(ESPState *s) uint32_t n; if (s->cmdfifo_cdb_offset) { - uint8_t message = esp_fifo_pop(&s->cmdfifo); + uint8_t message = fifo8_is_empty(&s->cmdfifo) ? 0 : + fifo8_pop(&s->cmdfifo); trace_esp_do_identify(message); s->lun = message & 7; From patchwork Wed Mar 13 08:57:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 76ADBC54791 for ; Wed, 13 Mar 2024 08:59:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKRu-0007ci-Nl; Wed, 13 Mar 2024 04:58:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKRs-0007c9-PG for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:58:56 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKRq-0002FB-8C for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:58:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=u58i1+LLPuxvI3guGDd39J9e/skbnTykrkeX11/aaS4=; b=AtJT/+tZSqWlI0vqZPsO568f3L vafZzPKxiWRu3REA8cMcOY1ZscDue0Q13G82W+pm2HjFlt6/MbVdf3FsIyMc68eGwWqs7Rp+3rjKP H+FWdC/tWAIOHFpNrc9xrxB79697/wToO2SQuWA/CYlqZ+R0XNDYKeMe/iq5w4CZYvGt46+cYDdT4 Lz4erWA5cms9EczZiTmBdt8RW+HLR0BR3Lr+HtggKdH3VBy0FVZOJJIHkSkxbcDTSrDq/aV008x0l 2kL9V1eUt95wF+yFLlHLZnOrc9Yrt1OQkwemtTraMD1lr2Bouiy9mlvFq1hyRNFO2SIVrMJEsM9fa PNmqDxTzsinijBNRdH6nAM7wPIF21Js4wTKZ5vhj//VItQ2wa0JkJRXGqr1raugBcmYFf/mxXtXS+ OQlyVqB1w8p7Vpn8Q+i281UYwe/3kZuUtZ1Jfc0NOYD/hJ8yWNTiclj80Wz2Y3Ui9VAiDFTWSlejB h7gN2t1yWg/G/qDB1drTGWrHWOTYCMp9Iodv7DXmHi96XrrUSSm70pQTzmPerU8Vtp1EzZTqMwBGg 9vNdrPQ9TyVlF8kAYzddCVeShueHDvcoowbOBHDGKQral/Jo0GCNFemKvXGdtiQtT3Eg6gOiupIEk f5I68d/oaj8/QibGmFlQYXR0zL9CIo6ZRcCdTeo/I=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKQx-000CUN-Vu; Wed, 13 Mar 2024 08:58:01 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:57:58 +0000 Message-Id: <20240313085810.2655062-5-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 04/16] esp.c: change esp_fifo_push() to take ESPState X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Now that all users of esp_fifo_push() operate on the main FIFO there is no need to pass the FIFO explicitly. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 7a24515bb9..b898e43e2b 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -106,14 +106,14 @@ void esp_request_cancelled(SCSIRequest *req) } } -static void esp_fifo_push(Fifo8 *fifo, uint8_t val) +static void esp_fifo_push(ESPState *s, uint8_t val) { - if (fifo8_num_used(fifo) == fifo->capacity) { + if (fifo8_num_used(&s->fifo) == s->fifo.capacity) { trace_esp_error_fifo_overrun(); return; } - fifo8_push(fifo, val); + fifo8_push(&s->fifo, val); } static uint8_t esp_fifo_pop(Fifo8 *fifo) @@ -224,7 +224,7 @@ static void esp_pdma_write(ESPState *s, uint8_t val) return; } - esp_fifo_push(&s->fifo, val); + esp_fifo_push(s, val); dmalen--; esp_set_tc(s, dmalen); @@ -1240,7 +1240,7 @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) break; case ESP_FIFO: if (!fifo8_is_full(&s->fifo)) { - esp_fifo_push(&s->fifo, val); + esp_fifo_push(s, val); } esp_do_nodma(s); break; From patchwork Wed Mar 13 08:57:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8DE80C54E60 for ; Wed, 13 Mar 2024 08:59:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKRx-0007dY-FB; Wed, 13 Mar 2024 04:59:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKRt-0007cL-5t for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:58:57 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKRr-0002Fm-PW for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:58:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PjRSzKrKLRaHnmivNuI06sMUXSnVympUdAmF8DrmVSs=; b=WuWwCkQ671+yNpXNOL1vF4A54C R3yy+8ZDUwPqOZB5cUYXgW76UM5T/T4BYJKhHM1M+cdWhmv00uHltKeMpiq912PxbNBJDd5t+iBvn Vl31gGiw3P3PmRQUPhydB9JAoxvunzHg9ao3ME2/1qUBFhYVdWTXCo0+W43TNli+lMNFj6NWH3doD NuHGZ3UjJvmGOMcCqiynzE6LotbHvfhqlI5n8Yqf2v1HMoTFBRJIr6oWgyMPDc2yRAQ6r33YsgNwD iVpdo9ixTfl4XHn0GgqIYMyd/qMTlazjdd+TcTBlNJ0sKju4qwI+3FubSTAWEKIkpj87hKicQ+d8P n1mFw82hv+zjGUFpq3ICBkBumEyPyUj0FUv8U/vuPwy04uiRNy22z8lYjlGHusqM0Wxr2rkuxr7T+ vkzZWHG65VDFbULvsh6ibpaOUKDiQIg72ueYhNl1THi3nHe1C/8DfFhOib8/tz4i1FZQRPTDCd+7i aKmFoDRmCzrwQiBw7jIzN6xJJG2ot66A0cYqvHH3xvJ9AFwZo6XYLB1fK6XX4d5G4TcwgrkGWym1Y ywbtHMq584BdNfezrHW9VoaoGQ6RRevQPsW0Lp1Z/siiuRvLY1BgMmGBMlFyG4X3aQsgpJNUOtc07 5VjesLGBxfnBL6mY9aOZ32s27X5hcX9IRh6LiEYDU=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKQz-000CUN-U3; Wed, 13 Mar 2024 08:58:02 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:57:59 +0000 Message-Id: <20240313085810.2655062-6-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 05/16] esp.c: change esp_fifo_pop() to take ESPState X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Now that all users of esp_fifo_pop() operate on the main FIFO there is no need to pass the FIFO explicitly. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index b898e43e2b..0e42ff50e7 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -116,13 +116,13 @@ static void esp_fifo_push(ESPState *s, uint8_t val) fifo8_push(&s->fifo, val); } -static uint8_t esp_fifo_pop(Fifo8 *fifo) +static uint8_t esp_fifo_pop(ESPState *s) { - if (fifo8_is_empty(fifo)) { + if (fifo8_is_empty(&s->fifo)) { return 0; } - return fifo8_pop(fifo); + return fifo8_pop(&s->fifo); } static uint32_t esp_fifo_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen) @@ -212,7 +212,7 @@ static uint8_t esp_pdma_read(ESPState *s) { uint8_t val; - val = esp_fifo_pop(&s->fifo); + val = esp_fifo_pop(s); return val; } @@ -1184,7 +1184,7 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr) switch (saddr) { case ESP_FIFO: - s->rregs[ESP_FIFO] = esp_fifo_pop(&s->fifo); + s->rregs[ESP_FIFO] = esp_fifo_pop(s); val = s->rregs[ESP_FIFO]; break; case ESP_RINTR: From patchwork Wed Mar 13 08:58:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 99257C54E58 for ; Wed, 13 Mar 2024 08:59:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKRx-0007dZ-FE; Wed, 13 Mar 2024 04:59:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKRv-0007dH-Px for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:58:59 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKRu-0002Ga-FG for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:58:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/CxDqHS9crhtz8sbTfN1gtZ311MXUlC4KQUJRPAGct8=; b=AhrvEHppl3Krw43NcOa4CUu/7p DmGVKT2qW8AsZJs6wWWu36VsexymkSpaydjeiAlgkIIS3JyhF/xap783Mnm6jLL1KjCnxfPfATwgk rwJrMWW9PYQO+Y76ZfsAvFqPl78vHtuSP8o7GgVnnuG7s45zwZ9NLZZ6UK2Ata/seYY/Z1e8Vxbxy WQVo6/KM6wzoIjyhfGYdH4qNusPvrcnvwjJxYOxKd7RUuKN4PAWyIQ/C9By5HeGIAVLeL+cM2fORJ 57vCvNFikZysgRjh+xDST7TbO5KKK+5/zwe+Jy0exDLFJ9guW0uOM5Ne2BxSZOCv6GpuIyrjdKdOq cst/1/mD9h+pNDma2TOwu/4/1kKwn/RyqqNIMK6q7vbGDzSWDDRvtAiq+DOAzapdrP1SmQiqbmmyi Oioo3ue3Ki4Bu42IxkVXFeN7bBckl1vB7lLn9PKlGJY7Erdfip8JTrq7h2Et0HMByNtx3dLjYda5W 66KlPvH1eOKTczblOH0TyU34iZkM48DDM5NV9RLdvMAEJfacZuIcIAh6Cp/EASOWrLcBPuWD+W8La 5+YKzIWKRDfqzHISipM5fFvX7BkZC518ga3E20YUUtq54uUcCgMt1fA3SXwNcUr+q112cLHJV4wFr mD+rDcqxUsRWc1XwEZ3kq7YxKmKQcyNreHWxQ+ixI=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKR0-000CUN-7n; Wed, 13 Mar 2024 08:58:06 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:58:00 +0000 Message-Id: <20240313085810.2655062-7-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 06/16] esp.c: use esp_fifo_push() instead of fifo8_push() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org There are still a few places that use fifo8_push() instead of esp_fifo_push() in order to push a value into the FIFO. Update those places to use esp_fifo_push() instead. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 0e42ff50e7..fb2ceca36a 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -858,7 +858,7 @@ static void esp_do_nodma(ESPState *s) return; } if (fifo8_is_empty(&s->fifo)) { - fifo8_push(&s->fifo, s->async_buf[0]); + esp_fifo_push(s, s->async_buf[0]); s->async_buf++; s->async_len--; s->ti_size--; @@ -881,7 +881,7 @@ static void esp_do_nodma(ESPState *s) case STAT_ST: switch (s->rregs[ESP_CMD]) { case CMD_ICCS: - fifo8_push(&s->fifo, s->status); + esp_fifo_push(s, s->status); esp_set_phase(s, STAT_MI); /* Process any message in phase data */ @@ -893,7 +893,7 @@ static void esp_do_nodma(ESPState *s) case STAT_MI: switch (s->rregs[ESP_CMD]) { case CMD_ICCS: - fifo8_push(&s->fifo, 0); + esp_fifo_push(s, 0); /* Raise end of command interrupt */ s->rregs[ESP_RINTR] |= INTR_FC; From patchwork Wed Mar 13 08:58:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591136 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EEB70C54E58 for ; Wed, 13 Mar 2024 09:03:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKS2-0007hm-FE; Wed, 13 Mar 2024 04:59:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKS0-0007hF-OK for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:04 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKRz-0002HY-54 for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Lw8//lSc6Mq8MOSxXg0a/v6O5ctJELxo7DCvrAv0b7A=; b=Ev6DqF2+kqJnHoM8JNe23Y9PcI WQrGcLtRNJi036IKuOtSIAmAIIl5AoCa1dZYDlDhNldi9jI1QuC/uQUgyvp9aDOJoo3YAhD9tRqSM Pt5Ggqtu3gKCeYD1/2979K62pF9ctY1QJrYxLPQMb/Gb8U5NdZ46+wxoOsH9y+nZKmXLk21j3HUg/ tOQum3NnacE4GXFqqTQnXTkRS6vObUwV4X+YtcQ/bfB9Rf+cy/+KS/TDxvyPVc5f0Fec5uXSEh6y5 R+AoLpF83HicJVj4PMyi2Sh8qESDojSMTNaB/QfRJMwDiWXM43dwiivderfGDZeyiNccdwMM6KgQz s/bQqBhm8HCnaURzPM/PhPsU1sYoeMdFOgvgzllabHpUaPIuuYH1Cgx1ZEKfJVBBK2yvXe88OnlhO vjeCl5GCvjBvyV+oCtrpGnqR3xKFcvEFz3FhJxd9SzrNNRR1EMLb1GxSKXFwm8BL+NQGGFiz9xc2U wFwuOL3QiyDDBNe0Lv6VNGuXW2imum2n4FLudQ7gv9uu3RdnXTghnu9S5/R1xeDeu8AnCM1BAE4Hc ZM+csGGT4Y0xBTXhqhAAIscYAvT77zdMZj/Q1er/s59Zbygll+zlCr8nmZhq9m7nuN7d/UP+CyF+6 CrAdRSHfxgBxlzCRAlrDyohGKpA2ZSTwjiCDqUzeA=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKR4-000CUN-E5; Wed, 13 Mar 2024 08:58:10 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:58:01 +0000 Message-Id: <20240313085810.2655062-8-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 07/16] esp.c: change esp_fifo_pop_buf() to take ESPState X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Now that all users of esp_fifo_pop_buf() operate on the main FIFO there is no need to pass the FIFO explicitly. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index fb2ceca36a..4d9220ab22 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -125,7 +125,7 @@ static uint8_t esp_fifo_pop(ESPState *s) return fifo8_pop(&s->fifo); } -static uint32_t esp_fifo_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen) +static uint32_t esp_fifo_pop_buf(ESPState *s, uint8_t *dest, int maxlen) { const uint8_t *buf; uint32_t n, n2; @@ -136,16 +136,16 @@ static uint32_t esp_fifo_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen) } len = maxlen; - buf = fifo8_pop_buf(fifo, len, &n); + buf = fifo8_pop_buf(&s->fifo, len, &n); if (dest) { memcpy(dest, buf, n); } /* Add FIFO wraparound if needed */ len -= n; - len = MIN(len, fifo8_num_used(fifo)); + len = MIN(len, fifo8_num_used(&s->fifo)); if (len) { - buf = fifo8_pop_buf(fifo, len, &n2); + buf = fifo8_pop_buf(&s->fifo, len, &n2); if (dest) { memcpy(&dest[n], buf, n2); } @@ -459,7 +459,7 @@ static void esp_do_dma(ESPState *s) s->dma_memory_read(s->dma_opaque, buf, len); esp_set_tc(s, esp_get_tc(s) - len); } else { - len = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + len = esp_fifo_pop_buf(s, buf, fifo8_num_used(&s->fifo)); len = MIN(fifo8_num_free(&s->cmdfifo), len); esp_raise_drq(s); } @@ -515,7 +515,7 @@ static void esp_do_dma(ESPState *s) fifo8_push_all(&s->cmdfifo, buf, len); esp_set_tc(s, esp_get_tc(s) - len); } else { - len = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + len = esp_fifo_pop_buf(s, buf, fifo8_num_used(&s->fifo)); len = MIN(fifo8_num_free(&s->cmdfifo), len); fifo8_push_all(&s->cmdfifo, buf, len); esp_raise_drq(s); @@ -549,7 +549,7 @@ static void esp_do_dma(ESPState *s) /* Copy FIFO data to device */ len = MIN(s->async_len, ESP_FIFO_SZ); len = MIN(len, fifo8_num_used(&s->fifo)); - len = esp_fifo_pop_buf(&s->fifo, s->async_buf, len); + len = esp_fifo_pop_buf(s, s->async_buf, len); esp_raise_drq(s); } @@ -713,7 +713,7 @@ static void esp_nodma_ti_dataout(ESPState *s) } len = MIN(s->async_len, ESP_FIFO_SZ); len = MIN(len, fifo8_num_used(&s->fifo)); - esp_fifo_pop_buf(&s->fifo, s->async_buf, len); + esp_fifo_pop_buf(s, s->async_buf, len); s->async_buf += len; s->async_len -= len; s->ti_size += len; @@ -738,7 +738,7 @@ static void esp_do_nodma(ESPState *s) switch (s->rregs[ESP_CMD]) { case CMD_SELATN: /* Copy FIFO into cmdfifo */ - len = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + len = esp_fifo_pop_buf(s, buf, fifo8_num_used(&s->fifo)); len = MIN(fifo8_num_free(&s->cmdfifo), len); fifo8_push_all(&s->cmdfifo, buf, len); @@ -757,7 +757,7 @@ static void esp_do_nodma(ESPState *s) case CMD_SELATNS: /* Copy one byte from FIFO into cmdfifo */ - len = esp_fifo_pop_buf(&s->fifo, buf, 1); + len = esp_fifo_pop_buf(s, buf, 1); len = MIN(fifo8_num_free(&s->cmdfifo), len); fifo8_push_all(&s->cmdfifo, buf, len); @@ -774,7 +774,7 @@ static void esp_do_nodma(ESPState *s) case CMD_TI: /* Copy FIFO into cmdfifo */ - len = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + len = esp_fifo_pop_buf(s, buf, fifo8_num_used(&s->fifo)); len = MIN(fifo8_num_free(&s->cmdfifo), len); fifo8_push_all(&s->cmdfifo, buf, len); @@ -792,7 +792,7 @@ static void esp_do_nodma(ESPState *s) switch (s->rregs[ESP_CMD]) { case CMD_TI: /* Copy FIFO into cmdfifo */ - len = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + len = esp_fifo_pop_buf(s, buf, fifo8_num_used(&s->fifo)); len = MIN(fifo8_num_free(&s->cmdfifo), len); fifo8_push_all(&s->cmdfifo, buf, len); @@ -821,7 +821,7 @@ static void esp_do_nodma(ESPState *s) case CMD_SEL | CMD_DMA: case CMD_SELATN | CMD_DMA: /* Copy FIFO into cmdfifo */ - len = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + len = esp_fifo_pop_buf(s, buf, fifo8_num_used(&s->fifo)); len = MIN(fifo8_num_free(&s->cmdfifo), len); fifo8_push_all(&s->cmdfifo, buf, len); @@ -836,7 +836,7 @@ static void esp_do_nodma(ESPState *s) case CMD_SEL: case CMD_SELATN: /* FIFO already contain entire CDB: copy to cmdfifo and execute */ - len = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + len = esp_fifo_pop_buf(s, buf, fifo8_num_used(&s->fifo)); len = MIN(fifo8_num_free(&s->cmdfifo), len); fifo8_push_all(&s->cmdfifo, buf, len); From patchwork Wed Mar 13 08:58:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A4B4FC54791 for ; Wed, 13 Mar 2024 09:01:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKS5-0007iC-Dv; Wed, 13 Mar 2024 04:59:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKS4-0007ht-Mi for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:08 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKS3-0002It-8e for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cqkIYrP2+End915WdRdFh5GYVktf4P5AsVieIYKOZqE=; b=vZ0Mf44r5J7eGx7KDkzN+sOv0h SG6EkJqPj//NRH0+d3mOPW1tcQd802MQcQs75N6HQzL/oVCheC+REh4PuDbsuRlvK3YagY5yXPtf6 SEDzbZF31cwhs2CEbXEI+Ov9mnqfG1CYCThVPmwriYk8ay7MWQROWMVIi4C6tVVx0upQoyars//PN lnB6kaqr7ZsEZZkp5QJPH9Mjn3qiabGrCu+XwMd5KIRwt9weYi2qSMNHeJEH+kAeEB21s1AHpJnvV bAkhXv29Ffg1CUuEDaQvEYyTccqvPCBD4EpnEQQysV0wWEwzfJyh8iTbgrXgh8xY4sk/QNycgP9MW IGZ7t7h5D8IgD8nR0RVgsmGX3aNA4ZBKhR9fRvqQtxy33VgyySAdnqRsShEw9IqXJobFMb8zSekZp 4/9nuILytPx21nJ7tv1afsEJpbEkR7XKEFUWL7e6F+Kr4TISHD8/WZOZdbk0BtB660mG7pUc8mycX MTBWT6CCYhtn/vRX/INn2zs0EVC6Sj2M/d527CE5ROo/Y+X69Emr4jSqvI/BGM6t+PWrqJ6/geqR9 YYYSS/lPH2aHhOH/D8qbn1g50Sl5NcjZRCQMxKJM19WTPnShIdIWwgdwjBmiYVBYZs5ju0egeC6+M vjgnLvOCjKE6sZ6zy0r+shjsuw9smjswzlgskDGPU=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKR8-000CUN-Km; Wed, 13 Mar 2024 08:58:14 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:58:02 +0000 Message-Id: <20240313085810.2655062-9-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 08/16] esp.c: introduce esp_fifo_push_buf() function for pushing to the FIFO X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Instead of pushing data into the FIFO directly with fifo8_push_all(), add a new esp_fifo_push_buf() function and use it accordingly. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 4d9220ab22..6b7a972947 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -116,6 +116,11 @@ static void esp_fifo_push(ESPState *s, uint8_t val) fifo8_push(&s->fifo, val); } +static void esp_fifo_push_buf(ESPState *s, uint8_t *buf, int len) +{ + fifo8_push_all(&s->fifo, buf, len); +} + static uint8_t esp_fifo_pop(ESPState *s) { if (fifo8_is_empty(&s->fifo)) { @@ -601,7 +606,7 @@ static void esp_do_dma(ESPState *s) } else { /* Copy device data to FIFO */ len = MIN(len, fifo8_num_free(&s->fifo)); - fifo8_push_all(&s->fifo, s->async_buf, len); + esp_fifo_push_buf(s, s->async_buf, len); esp_raise_drq(s); } @@ -650,7 +655,7 @@ static void esp_do_dma(ESPState *s) if (s->dma_memory_write) { s->dma_memory_write(s->dma_opaque, buf, len); } else { - fifo8_push_all(&s->fifo, buf, len); + esp_fifo_push_buf(s, buf, len); } esp_set_tc(s, esp_get_tc(s) - len); @@ -685,7 +690,7 @@ static void esp_do_dma(ESPState *s) if (s->dma_memory_write) { s->dma_memory_write(s->dma_opaque, buf, len); } else { - fifo8_push_all(&s->fifo, buf, len); + esp_fifo_push_buf(s, buf, len); } esp_set_tc(s, esp_get_tc(s) - len); From patchwork Wed Mar 13 08:58:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591124 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 179E0C54791 for ; Wed, 13 Mar 2024 08:59:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKS9-0007w8-Ay; Wed, 13 Mar 2024 04:59:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKS7-0007m5-Tn for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:11 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKS6-0002JF-FW for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=joJZwegwbCqnRe+4e8PodTC16lX8ha3QZwpNcj9I3iQ=; b=isaKPJ56t3c2jW669Gfg3QADTc ZJe7PB3VWNJd2osIuozsk0eRzJFYln3eFYrqr8RjgUcPY3Ld4igEpy3Z6yeDchUN3s8dT1i9dDXPT i0XjiDEXzL8C6vKDiJb/AJaOZ5ZarpqvLu7IA7t/TINOhD8XC7+6QJ9iZuCtbaDnnCWxE9lFIoSjI diXCJZfnqMhSz5wvXZEbgp8eDR0M8ttYnPZ1XFHBElKazYWMCIdjdhh+IBAaKpZi3uNyX+UDL41e+ d0ZbXEXvBITt0Yju8ZIPWNYLvGKd0R8+InwafwkA+UeVdFTYvVmbEdEfgEQNVMFLXImI5mLymWOzd pB0udbjSJkRrlEAiazO/7/uw4pDi2O1H+OGlBUKKkOHPx3dPNPrQGm5vlJBMiTHcDrYRAm8Vp+rjC Wp5TT6C74ktB8W/hI0zPvoKVM7Is9rnipiKFnknpOX0MRYAbOHQkMxzVfK7P3oe5X5lQAChXfGmDb 5PaXX0soDz0neP+nIH7UNtSEt6+NQH1J9RspWqZroC9HZL9XUZ4LLW6by5/EMP1lhwFkJrynWAblq gfPgYT/T0uauacO53E+MMkV4c7nw42c7rthar18tYMp9fyj2tx8QqalB9fdJEmhPiT0WE469Orxr4 ozovg6JdzaaHkMZZl0IJw320/aMGgqceOWhL34W80=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKRC-000CUN-P6; Wed, 13 Mar 2024 08:58:18 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:58:03 +0000 Message-Id: <20240313085810.2655062-10-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 09/16] esp.c: don't assert() if FIFO empty when executing non-DMA SELATNS X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The current logic assumes that at least 1 byte is present in the FIFO when executing a non-DMA SELATNS command, but this may not be the case if the guest executes an invalid ESP command sequence. Reported-by: Chuhong Yuan Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 6b7a972947..55143a1208 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -762,7 +762,8 @@ static void esp_do_nodma(ESPState *s) case CMD_SELATNS: /* Copy one byte from FIFO into cmdfifo */ - len = esp_fifo_pop_buf(s, buf, 1); + len = esp_fifo_pop_buf(s, buf, + MIN(fifo8_num_used(&s->fifo), 1)); len = MIN(fifo8_num_free(&s->cmdfifo), len); fifo8_push_all(&s->cmdfifo, buf, len); From patchwork Wed Mar 13 08:58:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 097B0C54E58 for ; Wed, 13 Mar 2024 08:59:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKSF-0008K9-H8; Wed, 13 Mar 2024 04:59:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSD-0008Du-5S for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:17 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSB-0002Jc-PE for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=zo6qBEL1QSeFZLNolV3DrVpqMBTkyiEf6bkbgHwJp1M=; b=VF33LB3X0NMWtsV9JEm4ag0k4n svLqY8LdaJpJMyO6pZIS0LBK0zeHQfBSFJNiHBqAkbwvYus9X5508z3i7xLesGS1vzPsHDWinXhmn dC72KyCxN2Jfx0lXaIqfzktxFe6gd7PQAU3II3VF7A1ISfeyXoeM3RngInlZVxgdxyXejTQmPjxM2 kq+dQzj16VhXTlGSjZADz149VscRFJfqYWGRev5rpZfhsrJP7BtekyfCIcOAWXbF3f8ojKeWwuBYv tsg6EVBwziSNWqFR6qeX5q5KT+DXzfC5yw5eeKynCPTH1hYkOVyQK2WxdnIl6umjVWHP61vlaht36 K7j/X02Y6Zil0WLMAC9eFxxbp+yQAEmS2CFsdJd+56qJ6seZSybQXcx+AtnH9TDcsUMqNKiQKS08L tSMXMaF7PjVMX9PQRHrPZQlExpWGlcdeWmLR5XPxp4hPWQXvgOAVL4Lk5Rnue1Y0pwdKuZT96zO51 afbLgUuA12FnR5h1khcdT6RaupOWluobFSpAwIPUDSnTutBljPEPdH66Fm2DU3zVrNs4MLUi1P7zG KuCcBvI/9kjXegKKj8Cj1QFRFmOTaRD/uy9PtPrExRaqQee5coPlgYFKBPrd2Kg3J5V27MYrfRSM9 dVZGHujqj16PTi8BRJJc1u2Z2aEOUZM7ObkzMsva4=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKRG-000CUN-TO; Wed, 13 Mar 2024 08:58:23 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:58:04 +0000 Message-Id: <20240313085810.2655062-11-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 10/16] esp.c: don't assert() if FIFO empty when executing esp_cdb_length() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This does not happen during normal usage, but can occur if the guest issues an invalid ESP command sequence. Reported-by: Chuhong Yuan Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 55143a1208..0050493e18 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -431,7 +431,7 @@ static int esp_cdb_length(ESPState *s) int cmdlen, len; cmdlen = fifo8_num_used(&s->cmdfifo); - if (cmdlen < s->cmdfifo_cdb_offset) { + if (cmdlen == 0 || cmdlen < s->cmdfifo_cdb_offset) { return 0; } From patchwork Wed Mar 13 08:58:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591132 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 81DBBC54E58 for ; Wed, 13 Mar 2024 09:00:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKSJ-00008f-Es; Wed, 13 Mar 2024 04:59:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSH-0008Pt-8x for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:21 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSF-0002KK-TG for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EtgVSaI4FwDRYAfcTxXw0jb8uPvvtv54Q8eHTb3fSt4=; b=HkMo6dbM4qOG3oKq17lRhwsiGM Dkji7WjjqY5N38+ejnobQrWK0JQVr8ZtGZhl8zwoxFTP/3waoS58pGUCoLU8kFcHpyY5OPS2HoCos kfw65Nwf0rmoDg7PskNbiX4cPxDIN9Jrj63IA/piovHP73lCSl4KBnrqHUGmEwNaPWuXizmWoeBSA x6yU/OJ2u2TqPMMowUvCSCF6NIMmvAUdXa0fHy9zCqdvGaXf60+3S1ce8EIJpsZnpQ93rlhaJGg4+ hAbR/mt2yIEr6P746ykh9UrdcDWgUMvWi2/fUbBbZTCQk/uCwyz1pxq3n6ueNqGNjvWidiQsmds13 fh+PqDkROzgEBq4g7tnEedTQVpS3scwm2OqWkcfZh97CVXQuzhfSSAkbaKlKalBVUjdAETzPT3Nb9 mDv958rKPMhQfNKPuICC4zKmkvzC6PplAEISkwUsIKN6elfN7CTi2GTxEhZyLaLOGceXiBjvNePpb arlYqAbKbweAdxAPmsmpQldPkbJrUZLJS07DDDzW7QJFY6NufDQWa2bt/g5JXmocYMaVxJs23YqF7 4Dc/UPBxXn2VhbZ1ezFVUOGmp1ta1HyG29WPxbExf4UyW/o0kZZzcyZHdu28ESmi4LdZSThfjjRP3 1hS3eLY2j2lY7CvyJepVO2miKc57ERUQHeCCDgfnU=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKRL-000CUN-4i; Wed, 13 Mar 2024 08:58:27 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:58:05 +0000 Message-Id: <20240313085810.2655062-12-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 11/16] esp.c: don't overflow cmdfifo if cmdfifo_cdb_offset >= ESP_CMDFIFO_SZ X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org If cmdfifo contains ESP_CMDFIFO_SZ bytes and cmdfifo_cdb_offset is also ESP_CMDFIFO_SZ then if the guest issues an ESP command sequence that invokes esp_cdb_length(), scsi_cdb_length() can read one byte beyond the end of the FIFO buffer. Add an extra length check to esp_cdb_length() to prevent reading past the end of the cmdfifo data in this case. Reported-by: Chuhong Yuan Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 0050493e18..05784b3f77 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -431,7 +431,8 @@ static int esp_cdb_length(ESPState *s) int cmdlen, len; cmdlen = fifo8_num_used(&s->cmdfifo); - if (cmdlen == 0 || cmdlen < s->cmdfifo_cdb_offset) { + if (cmdlen == 0 || cmdlen < s->cmdfifo_cdb_offset || + cmdlen >= ESP_CMDFIFO_SZ) { return 0; } From patchwork Wed Mar 13 08:58:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591130 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0ED32C54791 for ; Wed, 13 Mar 2024 09:00:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKSI-0008WI-6t; Wed, 13 Mar 2024 04:59:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSH-0008Q7-Am for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:21 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSF-0002KI-Sp for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=qqbagrYxG+I8+bUWxEwYLtlRwpjAZkn97vFKt6NO+uc=; b=TWu4nNCFzs/zSCmn73nhdkQ8Zc S7sXJu6rGsXm7iSW53hA2IlJ5AGMeqKuXVtq4NZodF726s+X5j+v6jHpMhJgMnKoylZpmCsoSZWss oDVfEtmuldiqrO7QCxpDwniKtJHNIyCjCC/BheaeXi/krcBHaY3Hotjey8vF04OLMrb2Q7cGQpqDh R9/2fA770x3DZYx5PXfs20MX9p7DSyMg8ZDHbjmGBIdsAiuYrt25UhRvZ5xCAi1htfAt0/ASyvsUt peKJzha6uBeVTjyFupn6Dp7Mp+BPc+ZkEKXu4V0ETVtxtc9P7yQHW0nanApLaCcilpxGq21zryolq jc2gI/ha1F+pHK0vhejjSlgGt+BSrMH8Ojr0YWl10QVk3aD1zJgMbBpRNRiPEpHqbQqT1XQ88+pxn Nr3d8drOqow0lXGuS7wL5RizBszehd5cIBKNDCxo7Mg6UoV6+rO4NbSu//oLvpHIdMvkXgMBH9ehf 97UP/W4MnJ5LrbLYXmu9Zm0QYaKVegujefcbw0O2CFDYYUDOIlLXFaGjdwBYo+p4MBPDufMDXEw4P fU2OMpXt8Gpx4f7HgffDLHglZuX2gBQ6SmjoG55uqZ/Adg1PatgvV38XvXNM6DTKBdg7ExcVmDjeJ RTxgosJtRU6bhIj7PwKcXhOsp21EQceFPhfLWG4bY=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKRP-000CUN-AY; Wed, 13 Mar 2024 08:58:27 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:58:06 +0000 Message-Id: <20240313085810.2655062-13-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 12/16] esp.c: move esp_set_phase() and esp_get_phase() towards the beginning of the file X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This allows these functions to be used earlier in the file without needing a separate forward declaration. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 05784b3f77..86145256ea 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -79,6 +79,24 @@ static void esp_lower_drq(ESPState *s) } } +static const char *esp_phase_names[8] = { + "DATA OUT", "DATA IN", "COMMAND", "STATUS", + "(reserved)", "(reserved)", "MESSAGE OUT", "MESSAGE IN" +}; + +static void esp_set_phase(ESPState *s, uint8_t phase) +{ + s->rregs[ESP_RSTAT] &= ~7; + s->rregs[ESP_RSTAT] |= phase; + + trace_esp_set_phase(esp_phase_names[phase]); +} + +static uint8_t esp_get_phase(ESPState *s) +{ + return s->rregs[ESP_RSTAT] & 7; +} + void esp_dma_enable(ESPState *s, int irq, int level) { if (level) { @@ -195,24 +213,6 @@ static uint32_t esp_get_stc(ESPState *s) return dmalen; } -static const char *esp_phase_names[8] = { - "DATA OUT", "DATA IN", "COMMAND", "STATUS", - "(reserved)", "(reserved)", "MESSAGE OUT", "MESSAGE IN" -}; - -static void esp_set_phase(ESPState *s, uint8_t phase) -{ - s->rregs[ESP_RSTAT] &= ~7; - s->rregs[ESP_RSTAT] |= phase; - - trace_esp_set_phase(esp_phase_names[phase]); -} - -static uint8_t esp_get_phase(ESPState *s) -{ - return s->rregs[ESP_RSTAT] & 7; -} - static uint8_t esp_pdma_read(ESPState *s) { uint8_t val; From patchwork Wed Mar 13 08:58:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591134 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A81F1C54E60 for ; Wed, 13 Mar 2024 09:01:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKSU-0000mR-Tq; Wed, 13 Mar 2024 04:59:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSS-0000dZ-BB for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:32 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSQ-0002KU-OA for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=qELr3Q32KiKjiCbBinPtYdx/SGPTR47wLITRxGSIDgQ=; b=yhl+J5ZwPBF/lBhTMjM3CK+y6K W4fY71U5jaKiCA9PYpn3cTEVv02darsyhGA6gH2/xRnWQsc7HDTomNzgILo83E2sGe1cTzf3f7igD D23n8i5P5oZ4VM3PaKQ8+GaqZTBg6yy6NKxj9C3fyD7G6a34UtvuJM4533euwWww17tOHVVA3ZnXw hYLqMC+SgsW2SqtcJnEXChXWtxY99fhLnRruypT0xarRogmxQbIP7yhD4cPqN1DsNVGhO7v3rm0HA 1gbPEfaEAxRBVXfh621RlXFfs6ND4fbE1rVEixLmDsFrrRMUR0aQ0nynSv4StSMnjqFAvqwBjIJe7 lQlXrcuvD81LK6YQAwCQ74tto4L7bk8+OouZof1XosVbPpMj2sfMpi8/jAqR0BRicDj8TmgIuCMij k8UPoz3u/9QNHEaoHaxp6VujhD/IVYBHNtXtpqwp/dDyZQ88jLJd295fen8pwj5C1MWj4pCVysI6/ Bt8fZMTwCwYBAq5W5g6EQb9DkMLVM5X6YhlNO5FYhH+YkTKVVvt7v0/6GXyp+rwYhz0k047oSWjrj dO9wx0UwyqdHGKHIuRnoC0bCHeEOTdi0Ju77ODmA7W+kgaFv9BoCdKVNLE3g3zE75PD9qz6xbhecv /0AfzmmrW+doNDJglWNQniQTDWsrsH2HtKDRMlipg=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKRP-000CUN-KV; Wed, 13 Mar 2024 08:58:27 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:58:07 +0000 Message-Id: <20240313085810.2655062-14-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 13/16] esp.c: introduce esp_update_drq() and update esp_fifo_{push, pop}_buf() to use it X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This new function sets the DRQ line correctly according to the current transfer mode, direction and FIFO contents. Update esp_fifo_push_buf() and esp_fifo_pop_buf() to use it so that DRQ is always set correctly when reading/writing multiple bytes to/from the FIFO. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 86145256ea..53a1c7ceaf 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -124,6 +124,48 @@ void esp_request_cancelled(SCSIRequest *req) } } +static void esp_update_drq(ESPState *s) +{ + bool to_device; + + switch (esp_get_phase(s)) { + case STAT_MO: + case STAT_CD: + case STAT_DO: + to_device = true; + break; + + case STAT_DI: + case STAT_ST: + case STAT_MI: + to_device = false; + break; + + default: + return; + } + + if (s->dma) { + /* DMA request so update DRQ according to transfer direction */ + if (to_device) { + if (fifo8_num_free(&s->fifo) < 2) { + esp_lower_drq(s); + } else { + esp_raise_drq(s); + } + } else { + if (fifo8_num_used(&s->fifo) < 2) { + esp_lower_drq(s); + } else { + esp_raise_drq(s); + } + } + } else { + /* Not a DMA request */ + esp_lower_drq(s); + } +} + static void esp_fifo_push(ESPState *s, uint8_t val) { if (fifo8_num_used(&s->fifo) == s->fifo.capacity) { @@ -137,6 +179,7 @@ static void esp_fifo_push(ESPState *s, uint8_t val) static void esp_fifo_push_buf(ESPState *s, uint8_t *buf, int len) { fifo8_push_all(&s->fifo, buf, len); + esp_update_drq(s); } static uint8_t esp_fifo_pop(ESPState *s) @@ -155,6 +198,7 @@ static uint32_t esp_fifo_pop_buf(ESPState *s, uint8_t *dest, int maxlen) int len; if (maxlen == 0) { + esp_update_drq(s); return 0; } @@ -175,6 +219,7 @@ static uint32_t esp_fifo_pop_buf(ESPState *s, uint8_t *dest, int maxlen) n += n2; } + esp_update_drq(s); return n; } From patchwork Wed Mar 13 08:58:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 70BF8C54791 for ; Wed, 13 Mar 2024 09:02:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKST-0000j4-NV; Wed, 13 Mar 2024 04:59:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSR-0000cP-Vb for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:32 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSQ-0002KQ-Hq for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=eIAikjkEW9wDBWxLTvUpNDdrycvYswU4shGYX63s4gI=; b=u7mW8Bj3/hPg9S4kfy5JWjW6F4 3VhqNxEu0kMzDD/gjPP7miGtXgGxByM+woEIks/RH7IbSfONDVZLnOb6M7WOg7lIr5ri+SM6CHtxO kaGioWPRaeJev0gMjEWhb1uAlDyTGKEklZfxEPrGnuOQo5sn6z4mv20+3aEsmPLk6/g93FN+XaMaW o7x03SJLz8EYLc3iNFX2axlH+gZCa/N9osjqPLxl2xmuoKCiSQ2EC6Zk+qzeU08XenKS5ECRDLptz CwE65vKzGdi13DCvxGmljKpxx4GQ6fU3NHGjaYDWOzTpxR/t8bpX2q9u0rdjfz7iS8FT9o3bVe3jV 9o6MfDDMQllfMJ9yqxXdli5ANdSb2eXy5MDMa8DTIr3nSS2h+XdDaT6Ws0Cz7yU57G+L0i+SRbKlF Y9a49TvlcLQNC47I5hhhaomI79JKye5wP3ID0S9Y0fSwMTJN7JTNhaMMcQtMbtPPNWB/0ZaSC3jea buV8Vh7/TIjMk5nJFcF9HgzS2D0L2a6Siptjbqv9lumG5qjWeuD4D224Sn0c7C7Ubu8t/Ud516dxW wBUkAKDCkAeuuZTjPqgFH/IOacnX3TCRy2b9itbjBSpxlfyWnBeQ9gCiyCNh6XRzRUjRSRmT5sdg3 qCDI1+HLZlnrr9PGkKcKG2tFjsJrD+fqjDo37z+wc=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKRQ-000CUN-4n; Wed, 13 Mar 2024 08:58:28 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:58:08 +0000 Message-Id: <20240313085810.2655062-15-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 14/16] esp.c: update esp_fifo_{push, pop}() to call esp_update_drq() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This ensures that the DRQ line is always set correctly when reading/writing single bytes to/from the FIFO. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 53a1c7ceaf..52a69599b2 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -170,10 +170,11 @@ static void esp_fifo_push(ESPState *s, uint8_t val) { if (fifo8_num_used(&s->fifo) == s->fifo.capacity) { trace_esp_error_fifo_overrun(); - return; + } else { + fifo8_push(&s->fifo, val); } - fifo8_push(&s->fifo, val); + esp_update_drq(s); } static void esp_fifo_push_buf(ESPState *s, uint8_t *buf, int len) @@ -184,11 +185,16 @@ static void esp_fifo_push_buf(ESPState *s, uint8_t *buf, int len) static uint8_t esp_fifo_pop(ESPState *s) { + uint8_t val; + if (fifo8_is_empty(&s->fifo)) { - return 0; + val = 0; + } else { + val = fifo8_pop(&s->fifo); } - return fifo8_pop(&s->fifo); + esp_update_drq(s); + return val; } static uint32_t esp_fifo_pop_buf(ESPState *s, uint8_t *dest, int maxlen) From patchwork Wed Mar 13 08:58:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EAF14C54E60 for ; Wed, 13 Mar 2024 09:03:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKSX-0000tE-O0; Wed, 13 Mar 2024 04:59:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSV-0000pZ-S7 for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:36 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSU-0002MG-Ch for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5rX1wiRaS4o6ho1ycS+cL0P6COf4Jdwl5irTlQ1l1FA=; b=RxVtQeAJ/oXuvXGs/qUSLpEVeu m9ChnZkM3187TBjVnckDNxQEyR0qg534xNNGZ5/dJnYEhzjcLK2w6PaADi94ssu047rYBNXKc6gzd M9GTmjuEJzP0/QfSrGoqz3MRAASTH6+Zr3+igt5r2WXKCGjgjLRMHwhFC8+d/KXbPoj8czhJaxDkJ ABHirnxml6frssRAhx5aqlBxSxyoDYiZ4iJFfOVWs9gNg0CWAtB+JZFBWhLMpqF83pKcB12NIe6X2 np/VIQGEIM5CUfGack7Hb+n1v73oE359KmLxYoxc+lPSUk0GAKSaF8I4dtqZe/1LmMSHNKk39DWhS popoEixfF6kpy0QL65B2+BkEIXX2mXYDOTzZT1JEOcwcLfmMeIxKJQnRLoveys02zWfCLyf5QUwCE 41o7R48trpvQ3blH1kVRh1NN7tdzpTNgr3iBVbafDluF11oRpJwx1ygUD8SF6fyJZIvpNx9qnNG4f sriCsvliGo8ERN6AFts5iJU6e5zalWd3sG4v51hRUFINh0+VGKKl6hXCQprBiRpHFLHnXxqepfk8x dGsVZLGKTCG95ZR5yomhqB9q0ORl7VYSY158zKE6fNUmfpK3gdncezdZDVm2wgik+bkVuESe+InTl tZqY85UMdkrhdwp1zY3Hd4MiavEiymNOJXRVH4nbI=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKRQ-000CUN-Ip; Wed, 13 Mar 2024 08:58:32 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:58:09 +0000 Message-Id: <20240313085810.2655062-16-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 15/16] esp.c: ensure esp_pdma_write() always calls esp_fifo_push() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This ensures that esp_update_drq() is called via esp_fifo_push() whenever the host uses PDMA to transfer data to a SCSI device. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 52a69599b2..68346ceaeb 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -276,14 +276,12 @@ static void esp_pdma_write(ESPState *s, uint8_t val) { uint32_t dmalen = esp_get_tc(s); - if (dmalen == 0) { - return; - } - esp_fifo_push(s, val); - dmalen--; - esp_set_tc(s, dmalen); + if (dmalen && s->drq_state) { + dmalen--; + esp_set_tc(s, dmalen); + } } static int esp_select(ESPState *s) From patchwork Wed Mar 13 08:58:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13591131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D6B25C54E58 for ; Wed, 13 Mar 2024 09:00:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkKSp-0001Ps-CH; Wed, 13 Mar 2024 04:59:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSa-0000xA-A4 for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:40 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkKSY-0002Me-HI for qemu-devel@nongnu.org; Wed, 13 Mar 2024 04:59:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HKxA34eftxuciJ72XV/d/Ny5Ajj9BUiqdu6fSQNsew4=; b=n/MsKff3peisfhnFilSS74YAED SgQMvUdpFLUZ17cLDQBnleH7nHPMX6nV3nvX3sprewppOc6aLK144Apn/vC2ItmwkM6hjW5bxeduc 2/BQAv7ebwAq2f5rfYv8olgO2iuHPtbfOCVPt7pDN9oc1ZBPGQI7WS9VKdBBBvXrMjF4hvywYgow3 acfUBGdYzBKQLAIMay/6TqZcRKCvbJ/dej1JkBo5zdkJX8OI/zZ+i1Pm7DrH4/yHSEJGBP/1KjSG2 q5HArD4cbWyJK8am5P0lXwuo4gM4M0u2DdYTCm8z+10Zt1AM5EEqwt3lRpB0NizABqQ5PuHTp9lya MO6IL6+lBbMtudiNTq0HAIPW4V3CdeO1NLLxz0zVWNTzDuKPHkX6nkRUjOVUbIj03Z3SZaoJI0S+p WfFS+bylIcQKccBI6RQHAbVHDNN4eCHte1vVf9/XGxKkZnLnoPm5Dk/Xgm9x1Cr8MRopcW/1qtrom Ix4yZs2pDI+3CBEWXsjeRzxctPhpSbZT9HGq3pN5OcwBPKWvAXR8i6it0j1DK/EGVgyuDoVKr+8ID SSQigfTE9vbm1jIaDNi1WML2rsA6f+SNYhdrNyLMonawNd6MoaE3mv8pcQtwub5Ty1R2NYpzbK3cH y9apfVH5uMmw2QJ2GY4tgHbfV/HiJb38oqZZFOdvo=; Received: from [2a00:23c4:8bb3:1000:1218:d855:1998:7fa8] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rkKRU-000CUN-Nd; Wed, 13 Mar 2024 08:58:36 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Wed, 13 Mar 2024 08:58:10 +0000 Message-Id: <20240313085810.2655062-17-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> References: <20240313085810.2655062-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb3:1000:1218:d855:1998:7fa8 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 16/16] esp.c: remove explicit setting of DRQ within ESP state machine X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Now the esp_update_drq() is called for all reads/writes to the FIFO, there is no need to manually raise and lower the DRQ signal. Signed-off-by: Mark Cave-Ayland Resolves: https://gitlab.com/qemu-project/qemu/-/issues/611 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1831 Reviewed-by: Philippe Mathieu-Daudé --- hw/scsi/esp.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 68346ceaeb..2b479b1b5a 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -496,7 +496,6 @@ static void esp_dma_ti_check(ESPState *s) if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); - esp_lower_drq(s); } } @@ -516,7 +515,6 @@ static void esp_do_dma(ESPState *s) } else { len = esp_fifo_pop_buf(s, buf, fifo8_num_used(&s->fifo)); len = MIN(fifo8_num_free(&s->cmdfifo), len); - esp_raise_drq(s); } fifo8_push_all(&s->cmdfifo, buf, len); @@ -573,7 +571,6 @@ static void esp_do_dma(ESPState *s) len = esp_fifo_pop_buf(s, buf, fifo8_num_used(&s->fifo)); len = MIN(fifo8_num_free(&s->cmdfifo), len); fifo8_push_all(&s->cmdfifo, buf, len); - esp_raise_drq(s); } trace_esp_handle_ti_cmd(cmdlen); s->ti_size = 0; @@ -605,7 +602,6 @@ static void esp_do_dma(ESPState *s) len = MIN(s->async_len, ESP_FIFO_SZ); len = MIN(len, fifo8_num_used(&s->fifo)); len = esp_fifo_pop_buf(s, s->async_buf, len); - esp_raise_drq(s); } s->async_buf += len; @@ -657,7 +653,6 @@ static void esp_do_dma(ESPState *s) /* Copy device data to FIFO */ len = MIN(len, fifo8_num_free(&s->fifo)); esp_fifo_push_buf(s, s->async_buf, len); - esp_raise_drq(s); } s->async_buf += len; @@ -723,7 +718,6 @@ static void esp_do_dma(ESPState *s) if (fifo8_num_used(&s->fifo) < 2) { s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); - esp_lower_drq(s); } break; } @@ -1013,9 +1007,6 @@ void esp_command_complete(SCSIRequest *req, size_t resid) s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); - /* Ensure DRQ is set correctly for TC underflow or normal completion */ - esp_dma_ti_check(s); - if (s->current_req) { scsi_req_unref(s->current_req); s->current_req = NULL;