From patchwork Fri Feb 16 21:06:21 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: 13560683 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 52FA5C48BF3 for ; Fri, 16 Feb 2024 21:08:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb5QQ-000696-F9; Fri, 16 Feb 2024 16:07:14 -0500 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 1rb5QJ-00062s-WA for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:08 -0500 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 1rb5Q6-0005Kf-S3 for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:07 -0500 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=Dr6x5iYAX4hTuGmV8ahyMigVPe Mb6EkGCJk2swfG8rV5MkEKX+4KK4I7ojfT+vVA1E2bnAyfd1h1Zf6kJEarg1L9EE+IJk3spgleYeL oPUPApjiKUJWRazz/uKDyBFHjyKwWhyMIw8q/vKxe61Q3ChUfawtVp+/lva/2eEBT8p/omDHlD5Ug Fr0V5SdLewKf60NATYuSGH/uNX2e8WHZlyqS3KMj9MRfVIYSX98fCDpgXK4ORbvrnJfmwxMBS/vuB GMGTmmWyDS6xGD5QUqVJ6B0OY9OfYesQAIthTd50dU0988CiEwxeUlriqYGb82GTYDGGvcmAGJdwq 8cV1jD4zpBtRv00ntBZ83ABBfkoQ0lBJAx4XkC/UOrVs1LO8nutl49koHCdnm8iElFNf79mlO/Iuc 2BzTpLlcHGlh6lKbVj3HYf7ryBJ0m8p62ak4LapL2rdYqksFM9ImL2g3TPpHwIoCUvBIoldwN7xa1 WvuVovn4pSyrx8g8qoi0kw1/4NKzkC54zsfEZSdXrB5OtiOYtRIjyhHMZWj9I8W3CItcnOO3ewy/k x+cLsZDyHkDh7T+AsSQXZW5ka++2V/6ip0sa7DtifSFwMPWqtsW8Szu3/mN4CWjBCSPgj2wv3q/Xf jWil4ZwQYeTnW2uYM4nlmQqaYSFwwzOv1Qln7WYvg=; Received: from [2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f] (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 1rb5PI-0000vT-9p; Fri, 16 Feb 2024 21:06:08 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Fri, 16 Feb 2024 21:06:21 +0000 Message-Id: <20240216210633.1376066-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> References: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 01/13] 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 --- 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 Fri Feb 16 21:06:22 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: 13560689 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 A6154C48260 for ; Fri, 16 Feb 2024 21:09:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb5QQ-00069e-V2; Fri, 16 Feb 2024 16:07:14 -0500 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 1rb5QK-000657-VI for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:08 -0500 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 1rb5QE-0005LC-4L for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:08 -0500 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=RklaEEXYWSR+hKTSBFAGwZ1IdF L0B4I2F40W15oHU5sKrUheHnjeAYhIURry0JsDqL3Py8bBXA/7zzJuRkBpHmoOiUJN+bF5z24DpwF D0LtwsIlKTAHQZDhP5xP/FvEWmHpxn7XdNd/LGOohk/gyHeH3jG/DsYO0lueFYbIzvUtVZqo7umay 4yeLOxIGs5nGhRGvJoFYGMnyy2XDJoteL4Qe+8b/2uY38GcrBdQxyE4fMgSd3GK5DKDqqUFOahvqb upKeLMLqjuH0M72Y+IQNp6iLY7zGKOQjOfkFbs2Ey0S2AzlXQSNioHK72wqbLCGGjle8TYewdtqmh tadeuLF+oO6AWZldrGBlUs7IYCUgCBnQLemoaBtZ/F+hBLU9Bav4phCkKUnKKz4Re69BiIEwboLKY ASIRPrPJB3QGMvD9TZKJErLWyNrG8sTWI3/o37UDsGC0816uC7GHNkvsacJQu0UNQEa2Oobroabg9 uZRIJyV0ofQPZEzuQsJLEM7jGUMI2MocmZev5sYzDlnyZFnYAFyNxZ7IW3jRwqcWLkETmzyRqOytl EFXcCfqAxoKnYlyTX+xLKE6qxyyFCAOI56UD3UzyoDEMet+Sczuu/lC9U4hsOYpHoZyyAgnHXv4Ma HrYgzzjCsNRPXsudjBZrThKEyEo/fHv22IVY18lYk=; Received: from [2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f] (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 1rb5PM-0000vT-GE; Fri, 16 Feb 2024 21:06:12 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Fri, 16 Feb 2024 21:06:22 +0000 Message-Id: <20240216210633.1376066-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> References: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 02/13] 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 --- 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 Fri Feb 16 21:06:23 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: 13560703 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 0A9C1C48BF3 for ; Fri, 16 Feb 2024 21:09:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb5QL-00065w-Hd; Fri, 16 Feb 2024 16:07:09 -0500 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 1rb5QK-000632-3G for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:08 -0500 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 1rb5QE-0005LI-4Z for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:07 -0500 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=ZV6a8NPtXlnyXE32YZfhi30KwN EOmCnsQF0xuJ+16VbAB5sQVmrCF97URmVIIttjTuXvLOBUfYNFxxLA023cn5yuT9CZiB3agTE+mIA RvTaGvabWAT5KYPCLHSWvu0F5OhIyTMhEdgxRBpbW8cyHT1NbgRrIs/oBa9eBH00+CqRc7th8bs3K WPQS643kUZ/0fK0SJNtQjWuTod29v5r08B5C6UarjxmyTqAv8GrcFmYSwv6YKH1BrbLCHsg8Zgwjy diAxKiqkUytzlgRmgjQl9QYtboriqyHNOy4TxA/MHquqqYqFDuaRICKvPpk8mfOQcbOqZCD+oP12U CP7kkjxc+8DaS4GMQemkbmK+2g1SLkwVo16K/NC0PhaGif91BCswnbA6fwH/CJE/me+hW55EmxQe3 62S8k/vOc1zGThvJzwTo1YX1tK+G457e6nYOl0vOMC1h7nU04i6C3V0URPE8rWrqZtqKfOx5mWuPv nVXLkzNqtoP0AzP0h6sHK72f2dj+QrIx7JlMIglYMAzQP2wOQN9/YFLrBcwFXzlkuJ1Y+6K44GdjJ QgtDXD3lN+H85uMp67KQrzOh0nhR/RWat2QZ30UhYsEnA5YSZx7daeozP6HbD9nKoZBjGlo5d2S7z jw+l2LYO4JIVS/IDc2Pse5C4Anw5EBsysM3M4k3pA=; Received: from [2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f] (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 1rb5PQ-0000vT-Md; Fri, 16 Feb 2024 21:06:16 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Fri, 16 Feb 2024 21:06:23 +0000 Message-Id: <20240216210633.1376066-4-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> References: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 03/13] 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 --- 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 Fri Feb 16 21:06:24 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: 13560685 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 1E03DC48260 for ; Fri, 16 Feb 2024 21:08:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb5QM-00066o-8E; Fri, 16 Feb 2024 16:07:10 -0500 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 1rb5QL-000658-26 for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:09 -0500 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 1rb5QI-0005LW-Uz for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:08 -0500 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=zM9CedDtpp6gLarlzLPv2/IgbF dfVrNfs2rufXOPeiJpNuZx70O0BzRsNLjcZ9Y2Op6VFR4E01a/GSfEc5f3sCIx52DkMoYaliCwtUo Xy+DkojzlhQZ2klIrJ3UY89Lm+FImp/GTpJDF/imROx9I35z+nX6WNmATSnzEbIwPQS96lCyelM8/ 9ONrZSQZ0lXiOysXea/7yZCIMj6+9e91nqBGMOo+X6JKQHMspR3ppKQqiSvcbOvGtH27igzDKlQyX lRsT4nafYmICgneXvqzCV+lYXZGoAmDhirD6D9Ds43NxEBu0BCs0QsqV85S8ZNfrzRze2BPbtcXVr 01slea9afQ8Vji1C4alCI38zNfVNuYJ3qmiEdS4p//qFoHbcMigfqdlb8YZKsogDwK8ARSi9HF/EX O/8QRv/KfioUU7NVISKCTtHBHrYWoTP6kAKZXbjcfnHyvqnvt2g5HNE2lDtPAEkMan77ongkLqvj1 6OYx5rE94KRy1N5OoE4GLD1p6vSzUUKi1vOr47oZbKXixCdn+2meqD++uYn8q0EiMxq+VqVHnLIVo +YVjcCTksaK9KcfS/rBRM1n1cK0PwOMwn1vuSLp4rWnPkIRkldaDENISDAQAGrfsGw87bOr/mvth5 Pm6WhfWc6iVVNmUykdmGEbbPSPW394bpj5gBzeQcs=; Received: from [2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f] (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 1rb5PU-0000vT-T3; Fri, 16 Feb 2024 21:06:20 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Fri, 16 Feb 2024 21:06:24 +0000 Message-Id: <20240216210633.1376066-5-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> References: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 04/13] 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 --- 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 Fri Feb 16 21:06:25 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: 13560707 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 478CFC48260 for ; Fri, 16 Feb 2024 21:09:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb5QO-00068X-Su; Fri, 16 Feb 2024 16:07:12 -0500 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 1rb5QN-00067a-Jj for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:11 -0500 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 1rb5QM-0005Mw-3u for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:11 -0500 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=IJdmAaHZX50+eSGO906mmbdTxW Mljo5Z7Za3pP1wXQgNARFylLcsyAoJ9vYzCnDmzeHOezwJJI9Z9TPehuzZtJYyud9mu2a+8/8fK/a S2SFD7SZvD5LwQOpVVzk8b2ngkfNssfjJ8xfj0ZdH6bOtuy5wjYgAXE/Ag5txPaD23cu0mfLUTLx/ pzV4Czhns9sWUjVOjydjhx7YDoKw3cLX/4/XCxC6jTnelSGBMSZ2YYYkWhIygqxRPxkGIzaQUFINc JbXKXfdxPImy8FSs0psQNkB2GS+yUODNzkSEOH2GQyukSc8JWBCCb95DrkJ3v8FWNcRZXaZRROe0P CczebfaRBUBqcc2KvOPyvC/Nv1VKo3RGpOzqphqoig+UJXKIDPbuCHXC1xaKBtv4+u8SpxgmgQt8J Ez2mpfcx2HVNRUZ7KXD/1yeClSvlAu+/IRRL77DFhuDCi92NH9f9lmEJ0I0bVJ3HzfDtianVeUuMF JhZ/5hOVkHQp5hVoil5lewpOWARk4m7xS/MFD8kYWrrrmvM2b1F53me34DSkFlR/m1SypRhNx4OdU eIQ4GYwv6c5J7C5PVlp5erWV2zJUov95QwCIyZfE4GQbwNAFK0AXU/+MjJ3NFiHpmPU4q0osYpa8b RXm1Mv/xBOBgVRXUedJeF0x9fwzD1VYIA7Xg2aaCA=; Received: from [2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f] (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 1rb5PZ-0000vT-3B; Fri, 16 Feb 2024 21:06:25 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Fri, 16 Feb 2024 21:06:25 +0000 Message-Id: <20240216210633.1376066-6-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> References: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 05/13] 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 --- 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 Fri Feb 16 21:06:26 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: 13560686 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 B77C8C48BF3 for ; Fri, 16 Feb 2024 21:08:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb5QS-0006BE-OL; Fri, 16 Feb 2024 16:07:16 -0500 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 1rb5QR-0006AK-QD for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:15 -0500 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 1rb5QQ-0005Oh-6d for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:15 -0500 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=GuzhnaVs9PHMCNnwrfNnSNjuiE XLeIFcU0h+Xeg/6mq932h+j8uq1Aq32aBrq+hoktTwJcWAuJRan8Z9eQc7l3KEDwSoqrJSekNMF7P CtdIPGhv94DCxrTNdQXaRSyPMYr1vM1rljLhTTFw/2htgyUg32aBAk5XAdK5GfsGvLQEKajDHi8yX jj1p01ojuODBKYM8MfdyYpZNiB7USs9IV2acS9Y0UGUtNldF/wyWQsM3ITq3s4bZYwfXZE0kbRi18 HqohkaRmnx7LfD86DtXjaMufDworBN7dlKsG0t6lxzDMAdgYUZMkMxHKNU6w6tu+WYWAAGLn4DB80 AjI+9U6JD1Pape0CJZ9UzUbTRvzmIOQVDqtN06Z6ZO4KmLWDKkhfisbBAo2WGZEH54jouDYZrshs1 DXfBwHQww5yubvosu5OutuUDPfWAJnGxFRM6KHmBsfh6nctngF8KDqrjH7VpYP6PBWkGlrlUwgbYd UfgeFmKUof7isBA6o/8Ln+DPSD4fRm6mCND4iymGczPGvGsmcIOmSe7UHB03ZLwuHLiXQQLg3AMUk 2qt8OJZpbbs2BOfOQ5oEUh2v5N68z18RUYeWOl0l9KVKcE1D7s6pUNNgDQ3jB6insYWTGvO59BkU+ OvPK/XHc7bWJ0Hz7tndFqFl8BBARKst6c69Vr8Psk=; Received: from [2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f] (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 1rb5Pd-0000vT-Cz; Fri, 16 Feb 2024 21:06:29 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Fri, 16 Feb 2024 21:06:26 +0000 Message-Id: <20240216210633.1376066-7-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> References: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 06/13] 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 --- 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 Fri Feb 16 21:06:27 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: 13560709 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 86270C48260 for ; Fri, 16 Feb 2024 21:09:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb5QX-0006Cf-4a; Fri, 16 Feb 2024 16:07:21 -0500 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 1rb5QT-0006BW-0s for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:17 -0500 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 1rb5QQ-0005Oj-Eu for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:16 -0500 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=wP+2Oc8K1TOdBWZnTI0VYzKSWc bwSv3FK+8A1tjXGPSCwy58191Wmkwbw4hrzrkcPQkWIyh2vbDbGiuVVNPbDqqcKhkYhGgXXWS9z61 wi3ZX6r9F0Fld9lhFCppDLujMsxjIR6k0+i9uegweoHG24vvQQyoEUBsPNYEC8fTJIQ3HO9RTaATD +91i9wcsnyEdJFcoAFp385pVZXLfgmXnUOcInWBxvzB93ID7K2VeOjW2sz3AwK+fw3a9jJBb6eMVY KqvuyxxNte6wh75iKe3kD1jsiduTRP0hzWJtpm2XNwBVh65QOI6gfdJAV9Qa8s+9A8yTIOb6akRRR +U/U3rscBZs6JjTWkl1x2sjC65o3UGkv7D2tymyo9rao/WcYaKdd3pD2mn6VjcuJoouBXduvxx3FU uWnGuqnXvdghNxqgMgY+ozmNIPCbV9oDUD6L0HalPZinsFojMAMWR/ogJUDTG/9LUNt/mu9MPy0bE uBn1IZ0YlcEf/cdHz/y08VH3zlg4spGpojTxTasJhxJTNgIL87Vsw//XnOgAf4VjaYuHR1fQlXT/i 8LTgviqLYZ1Zsc3QSzOHwx878Qatlqj6u3cWoxbLi09EFqkiTJMKtQr3U2jVVZCu35OF357xzdV7t 2t8CzqiVCZ3p8A+vjXwd2nhfELJK4MvrD4qbEfRaY=; Received: from [2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f] (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 1rb5Ph-0000vT-JD; Fri, 16 Feb 2024 21:06:29 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Fri, 16 Feb 2024 21:06:27 +0000 Message-Id: <20240216210633.1376066-8-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> References: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 07/13] 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 --- 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 Fri Feb 16 21:06:28 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: 13560687 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 C5DC7C48260 for ; Fri, 16 Feb 2024 21:08:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb5QU-0006C2-CQ; Fri, 16 Feb 2024 16:07:18 -0500 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 1rb5QS-0006BT-Uf for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:16 -0500 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 1rb5QQ-0005Or-OW for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:16 -0500 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=N0eHwru+TZram3KxBlQge6AjBL 7gMSTXKgIe7HqwF53KHORZS/KvpE0EU0Ke1nt52EfSlqVEdYKJcDHCLCnQVQO+w1x6RRz08LpAxaq LDSQSO8Y8OwXI4j1wrw6O+ZMlO6zVswHoJAn1l/DPzHeqpDadSi7aD8OLXxh1ztQwCeJM3tWPuOq1 vVsuhaeKhdLXRef4mrtvxRPQkHohIXc32hSjTjAbF+FZ7Qm93idhmaFhf2g2Xyk/drYI+1ryyaM+u 8XqUNLguytJSKUYeVxnwNWHNfCvqnfqWpdEo2kn/cNvdvahI+aH2YHeQc8nC6DX/DhF5+I7/6AmU2 ExPWi4rtsiL6KzAPIPoSffe1at8G4ghr8lSqvuZ02eOg7mlEhBxh/Nf1cloez+d12dYKlk/dM6lYS SzcocPoVE8tu0N08oU58aub1kDQHO4eXuZUZQnZOeXAyOxIykhwWQrxwWdtjkCXT2vvWmORRIt5Uz sAiYOw3I/CkzSYMnPxEUJijzhAO/x6ziidmargpRVKRRv3brcCLV4SK9ylbzYWixmrRZLJoWBjVLD 5x4OUASHSyMs/yBRlo/XWXOGQ1TqaaIKFwcTKLElnnbqhCvHtEqQEzAyLRiyRRsy7PnmpqV7cWeRI q7aV2LGC0nAZCmTnd63QrAvqSMR7lfs0O7RelCTBY=; Received: from [2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f] (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 1rb5Pi-0000vT-05; Fri, 16 Feb 2024 21:06:30 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Fri, 16 Feb 2024 21:06:28 +0000 Message-Id: <20240216210633.1376066-9-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> References: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 08/13] 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 --- 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 Fri Feb 16 21:06:29 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: 13560705 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 11B4CC48BF6 for ; Fri, 16 Feb 2024 21:09:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb5QV-0006Ce-Gk; Fri, 16 Feb 2024 16:07:19 -0500 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 1rb5QT-0006Br-DT for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:17 -0500 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 1rb5QR-0005P7-Vt for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:17 -0500 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=7iyI+dCE7cdPGgsLC9iMuM+R+Y4JcyGUoDTeMuI0kb4=; b=QrGrRrbN16AH/As4kMoHZMlqIX 2nLFtWfdo3ISzQesdBUtF6/nhLkYnBGhL4DlglpKD2dZcKQvdh0d5acs2WPsk9fBB/zHSaRnmVFOc uMnbQQUH1a6ohf0hSD3syNNuL3Gw/cj2Cb+u1gF2VnHKBAAeDosstjK3lfRsy/Za9ynawS6gSdh0R 3SWNc4oVaIKdaZuZEm2A9r/973cZcGJ3d0sYrsAqNMkJwK1vLoHyf0Y6uYDeqWeQ1yvYNMwCxfRlf Bibe4wLSGL+xk1l6jwNSdwUSu2E378t8r2JB5ev9dtV8j2+4zSEvkcTSJt/nsPRz2mdW8rrZYO947 RLHviY2hP2ZMzBcSyMfTvziRgUNTlrGLIr2NcWuTYtofdJjDqJ5XwJZ5cYehy1q525itGBi27dTzV hheYWWishMJNKMxJO7UtrnLCRw0p6Llj6tMDlXBCIkf630YuSo5z6y4c/ZXOHfXYxCCIR/hiS2sJT ATJuqnABV/NEBy4CfgJyoZdqTmjFOuKPy44P5yJmrG3DKUD3w3adWCMVRYRPzuiffO9b3b6jNums2 1ijLOWVSwUc7J8iSWtiE5Zq/PEdAk6ASB6J/w0QCWoX39yE4w3E5/aGVV9mRUROhMiHcZ92BGO2Cv Fv2e2jNyFVbhf+wsRB9GHqTvhHUf4+li9dXrU7Wkg=; Received: from [2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f] (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 1rb5Pi-0000vT-AE; Fri, 16 Feb 2024 21:06:30 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Fri, 16 Feb 2024 21:06:29 +0000 Message-Id: <20240216210633.1376066-10-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> References: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 09/13] 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 --- 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 6b7a972947..96aa576601 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 Fri Feb 16 21:06:30 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: 13560684 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 D29FEC48260 for ; Fri, 16 Feb 2024 21:08:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb5Qe-0006Dr-47; Fri, 16 Feb 2024 16:07:28 -0500 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 1rb5Qc-0006Dc-OW for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:26 -0500 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 1rb5QW-0005Ph-2I for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:26 -0500 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=91aoXrvj1OdEhkGYyOANAVWf4Lp8Edic++hD2qJwrwc=; b=Pw+JwVsHXFJQYMdrVEnw3FT0GO fJi+FpIJ1zC9eKjb0CMDiIQmBs65/oXPeVAxEdXnj7QT9vIaAXtWM/audZ3ltSvrheEMDFfqV+L5S 7c1kpcDQyXK4wIi4pmVYYAOdXTC77OvdEjdCUPBkoTc15f9MzIh426tU+IGoXVJKCisnumWN+Rzdl Co59SPvhlh7NvzQEuFWMo1yo1Orp5sQxVWnSAddRyxDpM81zXRXEqrzNmn+VXDaX1CX8jBq/SyLwK q4JTUApp0zZx5356q0zujDeYx0pT3a2TM9Lqu6A8yxKNWa3KQRo9AJ60Svzrly7wBLbBAVw3inDtp lyYvnrHogocWp284be+x8QSsdG3F8NymbLQtsKJlEgHemd8B68hcaKdsZpWMBHtE3r/cT1mKcZtPO QZxhK/h8cM/pfdoDGk0qhtN7srAJzc7PLzik3muMnECuiMNrpqKOzTAgnpZTWcfPfGmKCRIS3NjRz HFjyD9y4TeyOTBkJCU1jHNIgnk2knRkbv4OUgY8+Bn7LRr81m8NZNOB62iQjvC7AirYIprsmufPJG LPgbgBcpI4+/cp2Fl8HrJxVXBks0eCN9nEK+CWMglx7ltWfYV367r2VE9/NhoWHqFyKy4dkcmcpok E7xMnvVJue09XcfqTz3BIDD35V07Uo3yhwCFtHPRY=; Received: from [2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f] (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 1rb5Pi-0000vT-Jw; Fri, 16 Feb 2024 21:06:34 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Fri, 16 Feb 2024 21:06:30 +0000 Message-Id: <20240216210633.1376066-11-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> References: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 10/13] 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 --- hw/scsi/esp.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 96aa576601..ca0fa5098d 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 Fri Feb 16 21:06:31 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: 13560706 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 53CBAC48BF5 for ; Fri, 16 Feb 2024 21:09:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb5Qd-0006Dk-2U; Fri, 16 Feb 2024 16:07:27 -0500 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 1rb5Qb-0006DA-0s for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:25 -0500 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 1rb5QZ-0005Pu-Mg for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:24 -0500 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=QUfv1x5Fmy4iHLPilnaDDf+n20KuwA7XLLsoDAioGvM=; b=nLDHWrXiObYnR2U1g1XuLj+/Mn qY58NlAXxQZjdzqk6QMcerX23il3owPR/iPNw0mg2zbR/9wkrLhV+UmB/acIaK04esV+loXnLJ/J9 Yr14Pjl2IxGQC8ruEAq1kySj9Zo9z2E6mdYZCJzguZvpsCaHuX0azL2Lf/ehHBlTpdpTkFzYDONja lST4PIecjzUTJb6GohWvziCxySWlQ6t91YlirJPWHg37a0FumfyUq1TZRbBdW7uPDvbebHlfbjLu+ PhGGR0n7D7bvctEKBm/1CJ6IyGFdedxVB8c82ZQx2UM4yfRWMwuzbTTkthBftSXuUbVaCsQ3mjeE0 j1JAuDSYCKycFNatx13qv1WEq67cqJoMo2PD55ke4yj4rEhUe789gIrLjOvHlGMUDT3axU5gP/L3f 2eHWFhhaWZReqQzlgSEu9Ktysi0mKaHCTt0QVapOPNHbVH6tDqjbQKvjudeymRJ3vzpGkMNfgzpHG KkvY/g0OsVkfP7/6OKSTH88o5c+zsb32yeQ6TsOPzjNOftHRXV2tH8C2P3JKjv1zO4JnSXXf5tPDF xL5iXN2XhmEMhcus51I4P+ii/d0Cr+CrNhuyjGfwjhjaxQVIsfXQRmWuCtLe4NtxjgEat/4yKuxRd sq3oawna7XlXqpM+cxhfLavb0/6XVU4K+jlrEkamQ=; Received: from [2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f] (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 1rb5Pm-0000vT-Tm; Fri, 16 Feb 2024 21:06:39 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Fri, 16 Feb 2024 21:06:31 +0000 Message-Id: <20240216210633.1376066-12-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> References: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 11/13] 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 --- 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 ca0fa5098d..2150cd457b 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 Fri Feb 16 21:06:32 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: 13560688 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 4B104C48BF3 for ; Fri, 16 Feb 2024 21:08:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb5Qq-0006Ok-KJ; Fri, 16 Feb 2024 16:07:41 -0500 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 1rb5Qn-0006Eg-2A for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:37 -0500 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 1rb5Qd-0005QA-05 for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:28 -0500 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=uvd6nXwhTYTsEf+BMYvVSp2xRCX7/yZoN//4EaZsgTM=; b=iOD8e87U9cKfkYr/gHE7xhFMPQ qi6bhM7rgeXLaV+6n5xOspvoxX5z5XETi7ZpY553UbjLptPhFwB0wsw83LpaIEiVe7FImsb+1BOrN Br8Hp5Y1BVYHroTJ28DlDJuYojgECg1pO3zzE2ZjrDx5tuSgQeRwu1Zd4YgDhEV5BBisxoh0JtHbU LqJCMJxZE75HNx85oq4d6Iz97pdaPWjQsiz7UniXcnKDLCIIiGxUaA4JxyZPbPwY+Lz/7guTyGkG1 Tdre+bQwH2CQo+sO1SNTwoIwueWhVm5SBop+MWk5fmwVa/zxEBTzNnZJynnd3d4QN+LsXXvoOsH/7 PMwkMGR/t4oECkYOkrKwfFsDFBBHDRg4R+V5QetYbX1+BhdjPg43OaNpMA0SZH+kpLg/7PINpW9qP DrGQLOztIQRhI/Y7v+SpcY8l6NQXNBOHMQMCZ7Uw0z0+Z+7LA29DZWBypwQeOFk4lcdhf1EjeUWcS WT9IY9uPKkkodsy0uwuMOQmee69lq9krwY7DLw3YB/3U/cmbVZNkUPsAYZ9wate99ZasidKvNeCpT 8gKvhecQWI871HRL9aH/dPHCOFOQF5QzZ6USyus5qO4255sRIplEOrIH1/XSu42gvDTjKvCW7khjz 5NrvJEepKHvG8XYjCy7HicJ9iLjVQuO2pxp99j6Tc=; Received: from [2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f] (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 1rb5Pr-0000vT-3v; Fri, 16 Feb 2024 21:06:43 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Fri, 16 Feb 2024 21:06:32 +0000 Message-Id: <20240216210633.1376066-13-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> References: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 12/13] 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 --- 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 2150cd457b..a147509885 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 Fri Feb 16 21:06:33 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: 13560704 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 D0A0CC48260 for ; Fri, 16 Feb 2024 21:09:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rb5Qx-0006hY-GP; Fri, 16 Feb 2024 16:07:47 -0500 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 1rb5Qo-0006Eq-Cy for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:39 -0500 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 1rb5Qm-0005Qp-Pt for qemu-devel@nongnu.org; Fri, 16 Feb 2024 16:07:38 -0500 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=TndlSOqHn8wvYTLw9S+LlH2H/zQCMiOOADBR2HO3ZwI=; b=vlaqvMaHUwUn6PaOLHfHk7a/Ag 0se9z/ZA3HExjdnvRggnT6qL9cM+7ONfldUWxWbD/KwOnufgrmsDdsyYW9Y7VWMdmAtTJqAHOsyiw bKBkOZRF8b3RXeaFSqVfZmN1MIfgO9mlr8+22CzbRoBdgUcFenuduAWfRCS3lliQeAhvhV1vE/w3S rtISiOP9ZPEZvBFReApKJ0nLTL7rC06gO79IOT3A6VkGsYOUmZSvOg8z9DYdNlBAz4RlEJjFGXcbD ZV2vi4swJjpbqO+44aRK39uJEq+XNLqOoyKmS+NwphOMy1XWuw5qNsHTWc9+DguVH2IMWz8MdGBgd 0nWUUymdvTZlgR1KeAp3eAdJUkLxKNzJZTjGF0jZgpYzppY392xPv+RtmMxxuXhMT4PEgmi7OrS3y 7Plq3Hzopg9Nmv0ps3Xaak7sLYGnovQ2PqOgOcy/tthjeIHYS8lu4+iDG+nLznsOnGxjtE8om0OqS eZ+J9OGzDCkrGSA7uJq547lNbF47h7OtO5KNcpPsbK3YgUuWnO2IAJQDSnibwSbVGvPl1Zpitg9IP xHwP0A0yGlLC19YFX1Yales7TwNrMiIm++wQbrj4nztje11Hmu97U1PUIMGSBv94+rO4ZjeH4eS1W M3JbgjbKZ+9ySstyU2OVvkAyHxfZI3BWLqeetcJVk=; Received: from [2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f] (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 1rb5Pv-0000vT-AM; Fri, 16 Feb 2024 21:06:47 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, laurent@vivier.eu, qemu-devel@nongnu.org Date: Fri, 16 Feb 2024 21:06:33 +0000 Message-Id: <20240216210633.1376066-14-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> References: <20240216210633.1376066-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:b76e:9764:d1ca:4e3f X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 13/13] 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 Fixes: https://gitlab.com/qemu-project/qemu/-/issues/611 Fixes: https://gitlab.com/qemu-project/qemu/-/issues/1831 --- hw/scsi/esp.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index a147509885..2f45bae940 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -495,7 +495,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); } } @@ -515,7 +514,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); @@ -572,7 +570,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; @@ -604,7 +601,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; @@ -656,7 +652,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; @@ -722,7 +717,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; } @@ -1011,9 +1005,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;