From nobody Sat Nov 23 20:10:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730498540032995.6051700967332; Fri, 1 Nov 2024 15:02:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6zhg-0004LY-R9; Fri, 01 Nov 2024 18:01:12 -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 1t6zhd-0004KX-RJ for qemu-devel@nongnu.org; Fri, 01 Nov 2024 18:01:10 -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 1t6zhZ-0002nn-CD for qemu-devel@nongnu.org; Fri, 01 Nov 2024 18:01:09 -0400 Received: from [2a00:23c4:8bb8:f600:91a1:336d:3931:745] (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 1t6zhC-0002pk-ER; Fri, 01 Nov 2024 22:00:42 +0000 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; bh=+d773DwhBknavPzpCmrrvLZ47FDvAPTWHJ8AGBcn2Ss=; b=Uers8bq6snMVzs2hw0jo49FpJR L3ska1TuvMetzciUTUAttZqgsU4hP/V4+XjFstycj0RI+qUcIpveES11HMlJ/0VBzPBBxzZZjTwwl T5L1YnJeT3NyJJS8eoQ0f1wvpwiAX/aLbE+m/8EX/RHoRAAlpR38nwTgOU+F0lGIwEFud1HpNi5h1 RVJ1ZwLiUJQUAWyWYC/2TL/676LmmvmBYOn4MkJNKFuvg/4y97/OqTzzgA5fV9ls+XiVXbNRVRVmG Mvt3WPXFDS2hvwb8tWpCNEmAbBR/QkV74/k/gIROqWkb0spB+ifHfUkKjAZ4laXa3nCaToWE0XY07 WQnSZKv0MwMVp9DsfaW4mmn3MxjihPMLURNvuXGC0XQYHov2W6bOEgngFMw93yeWHN3dQ4wadiAeZ rHTWgMGFg27d++QGOzys7kQKUUGaZEREhpH0bevuKIwNnrFgBQvvW6qHEcSFtWobwNEmlq/N6havW 1KyUORZg9eg0Xeus677BJMD/HdE55vmPlZ6yADHoVkdAzBux0dGYAF69yXX+bbwXwh/S5TksVIbGN 1AtH4JjvefYNbvSggA9TTWmwYBtwk5mWOx4SmjqST81CTvcDcn07IVZ4mGVWriKo4vQraw8IRCF2k +m/4kBOjUOzjFdIU8KauAz4RmG4ThMisOHzNnLbu0=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Fri, 1 Nov 2024 22:00:48 +0000 Message-Id: <20241101220052.1463805-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241101220052.1463805-1-mark.cave-ayland@ilande.co.uk> References: <20241101220052.1463805-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8bb8:f600:91a1:336d:3931:745 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 1/5] esp.c: only raise IRQ in esp_transfer_data() for CMD_SEL, CMD_SELATN and CMD_TI commands 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1730498540502116600 Content-Type: text/plain; charset="utf-8" Clarify the logic in esp_transfer_data() to ensure that the deferred interr= upt code can only be triggered for CMD_SEL, CMD_SELATN and CMD_TI commands. This sho= uld already be the case, but make it explicit to ensure the logic isn't triggered unexp= ectedly. Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index ac841dc32e..5723290d62 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1015,6 +1015,7 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) */ s->rregs[ESP_RINTR] |=3D INTR_BS | INTR_FC; s->rregs[ESP_RSEQ] =3D SEQ_CD; + esp_raise_irq(s); break; =20 case CMD_SELATNS | CMD_DMA: @@ -1025,6 +1026,7 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) */ s->rregs[ESP_RINTR] |=3D INTR_BS; s->rregs[ESP_RSEQ] =3D SEQ_MO; + esp_raise_irq(s); break; =20 case CMD_TI | CMD_DMA: @@ -1035,10 +1037,9 @@ void esp_transfer_data(SCSIRequest *req, uint32_t le= n) */ s->rregs[ESP_CMD] =3D 0; s->rregs[ESP_RINTR] |=3D INTR_BS; + esp_raise_irq(s); break; } - - esp_raise_irq(s); } =20 /* --=20 2.39.5 From nobody Sat Nov 23 20:10:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730498512948188.3462037834845; Fri, 1 Nov 2024 15:01:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6zhg-0004LL-MS; Fri, 01 Nov 2024 18:01:12 -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 1t6zhe-0004Kn-79 for qemu-devel@nongnu.org; Fri, 01 Nov 2024 18:01:10 -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 1t6zhc-0002oH-U7 for qemu-devel@nongnu.org; Fri, 01 Nov 2024 18:01:09 -0400 Received: from [2a00:23c4:8bb8:f600:91a1:336d:3931:745] (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 1t6zhC-0002pk-OL; Fri, 01 Nov 2024 22:00:46 +0000 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; bh=8wl31vWEym+Plbj9w5jpEhR79vNFKay4sFyDrn0ogbU=; b=xjrU9aHq+owXYS+RYQT3kWOwP5 0ip2442C2Hp/4FuRZj6FzHshUTfVn5sUSjCSdq0vy+QYoWu9IrDRbNzVtz2Y70aqtPe3eKFVsOPju VGJsKff+bx/15ZJ7QOKQxTPPpOgD4mTcXbwQg7Vtn88MpGE8vQenkFgMnV0l5yC/en+Neko0S+aiM DDRtbStXvjeO+1unS9+YqOxEUpOrqaYXV3uO8M+DpfYUFSRkmo6zJ/ESKXFedrC53kjPOZhKwrtJQ epIX9MqR2kNiAmz8bUBZSgKmrhf9hjDMqoPh15nyyClIYUvAoK65HkWVrfNE1JM1LmvLG/FBw+8Yl BJ8pfxF9uZJ0kmr6YD1l+B3axWR7KYfuRERLQtUPmhSN7hdrVB3lWa25r5LwVe85Gm61c5AInykX7 1mDJJJLT/+Fwd0ndyVSZk3FUy/xO6e7TbUfTDOl/gwOcQZCE4o75KqwxQzW5IAo6Oikrt5oYyGNSF 2jEhJ6T/73akFBPU3MExJwwKx+bRaZLHYgtEW0LBYAeQYhaHld1dwJ1drIr5P0qINv7d23rTdx/T6 NoI4YKIL+vUPZF2iMy54XR/n1grV2WLCz/znNxCIy7yJVnih0M+UDRxG42wHiIp6XOGmMlBQE5Usp vpRPU/N6DIlOgWLjjilt3TrmddNjCoPRGzGXMMsj8=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Fri, 1 Nov 2024 22:00:49 +0000 Message-Id: <20241101220052.1463805-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241101220052.1463805-1-mark.cave-ayland@ilande.co.uk> References: <20241101220052.1463805-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8bb8:f600:91a1:336d:3931:745 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 2/5] esp.c: improve comment in esp_transfer_data() 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1730498514356116600 Content-Type: text/plain; charset="utf-8" Whilst working on the previous patch, the existing comment was not enough to document when the TI command codepath was being used. Update and improve the comment accordingly. Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 5723290d62..36e92dcd7b 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1032,8 +1032,9 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) case CMD_TI | CMD_DMA: case CMD_TI: /* - * Bus service interrupt raised because of initial change to - * DATA phase + * If the final COMMAND phase data was transferred using a TI + * command, clear ESP_CMD to terminate the TI command and raise + * the completion interrupt */ s->rregs[ESP_CMD] =3D 0; s->rregs[ESP_RINTR] |=3D INTR_BS; --=20 2.39.5 From nobody Sat Nov 23 20:10:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730498526724773.9964282090931; Fri, 1 Nov 2024 15:02:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6zhl-0004MR-Hb; Fri, 01 Nov 2024 18:01:17 -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 1t6zhi-0004Lx-7w for qemu-devel@nongnu.org; Fri, 01 Nov 2024 18:01:14 -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 1t6zhg-0002os-DX for qemu-devel@nongnu.org; Fri, 01 Nov 2024 18:01:13 -0400 Received: from [2a00:23c4:8bb8:f600:91a1:336d:3931:745] (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 1t6zhG-0002pk-Un; Fri, 01 Nov 2024 22:00:51 +0000 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; bh=nNbqaq73wvELgQmDX95TXQpt1EGVEYkXwH7FUiKjs7g=; b=Hv3+3VNUp+EQyERTjSYpwf82hM tnZEE2ehChvNQgNe15fAwKafKSq6rffVIs1PSHn5BDH4m66dWGF3KqKFq0lQpFQT/up4pKoo21i/F DgrHzj3OSuid0sS+O9jNVlchEC073MbgyLlcFWU8q4QKBWOFKUcP2Q2EeaB40MtcVDA21BDGfielS L7BTX9VX2OHkeZv9Yp+ESpORMeqyGOjoUw4Y5hV5olmBW+f1mqxIwMO8QVA7qWYZLrlexGiw4ZQFe KBHnhdftcYjnQrh2S1AEnlsT7J1lA9fEd2RGSizLtXML04xx8q2Sa1l2eu3UiieW1S6sGiUhG0Pmx 2mGvDNnVvBcS8z9y2aII0+uazNYrOeYl1woXa8jPy9bIj2pJ4HH4IBOBDmgGfPvPSUmaiuAvO4FvD WGZNFlCoWdKmgVrLyk/dYPmgP3DIulEpC2azw1GUQbCXiWl2ZDFTzpRWs4rISbL4wcIPYbG87t1rF e3bk1Yp+8sgL3YIogdMOQPE7AyWytv2gQJxStPiEYVBuY76VwZeCSQAMbbqu/U/tzi+NksuwZRjHz 7rC7iLL0hi4j7nph7olH9SaKp6iGhP4K7nPARyeEFTjs0JO5l0WsAV/1fnZmOLKBhOFFJTWK3BnAL v6Myqr/TEX3W44SS6RF8n82pKNQ7flsxFRMWw2vb4=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Fri, 1 Nov 2024 22:00:50 +0000 Message-Id: <20241101220052.1463805-4-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241101220052.1463805-1-mark.cave-ayland@ilande.co.uk> References: <20241101220052.1463805-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8bb8:f600:91a1:336d:3931:745 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 3/5] esp.h: remove separate ESPState typedef 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1730498528451116600 Content-Type: text/plain; charset="utf-8" This is not needed as it is now handled by the OBJECT_DECLARE_SIMPLE_TYPE()= macro. Signed-off-by: Mark Cave-Ayland --- include/hw/scsi/esp.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index 533d856aa3..c9afcb7cac 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -14,8 +14,6 @@ typedef void (*ESPDMAMemoryReadWriteFunc)(void *opaque, u= int8_t *buf, int len); #define ESP_FIFO_SZ 16 #define ESP_CMDFIFO_SZ 32 =20 -typedef struct ESPState ESPState; - #define TYPE_ESP "esp" OBJECT_DECLARE_SIMPLE_TYPE(ESPState, ESP) =20 --=20 2.39.5 From nobody Sat Nov 23 20:10:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730498534549325.8602840875542; Fri, 1 Nov 2024 15:02:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6zhm-0004Ml-HE; Fri, 01 Nov 2024 18:01:18 -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 1t6zhi-0004Ly-CG for qemu-devel@nongnu.org; Fri, 01 Nov 2024 18:01:14 -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 1t6zhg-0002ou-P4 for qemu-devel@nongnu.org; Fri, 01 Nov 2024 18:01:14 -0400 Received: from [2a00:23c4:8bb8:f600:91a1:336d:3931:745] (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 1t6zhL-0002pk-4t; Fri, 01 Nov 2024 22:00:51 +0000 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; bh=/uYBu+gUI1nuecU2A3hb7azcbIn5ZKJLuhQ4Mw9pBDM=; b=S9IfIu9AuM0VAAv7y4jFE2J2dc fPXG5LOcPdskjw3R/Ws87A1RQeE4g0xZSb0JJdD6ES/R+xomUo2ZLlCS5bGlZyX9MzDk0oyzFl+9F 5X3xmbbM0ptCsjZ6ZQxnuHf+kXmrfe2Id4RgQUufcE4RT5Ii2tcogyU+Y5BAK1nhVKat6yPyoYe+V YCIztvlNOJqoDZScZwVaFnEdhqMxESh1dipX2GJENfCO4idUruHRB4nFFS072u4woN7ZA5XD7McpY MBL3CHnPk3mq38BqI9EsBabg+MxhHGPeamwEIMvG+WSIRq9DxuAoNA9cdCMI5XlZbSscqZZfKfBrv li6fW6SHz/8e/htUa1smDMUu36rXXDdA35Ks6TYlehj210G3YnKdiiKQgmf7xTVuRI96fOOdAtfNx uC7OS7rnfKn8QyNZ47GC4M42HVNDr47upygJvmJI/LsA3jTnrPv3L53ncO+FANT4+3XmJIVCboNxO TWpr6Di3m4+ZBhJogNGw9u8i0UqAxSJ93J2aaq5eYcB6br7xJvFdLl0psRuEvErSMs31EwMi+i7C0 PDedLhMCLY2i1NsesN7RmAe074xNupVeeQfXNggY6MhFUdgfeGFBrFMUQlFEBUI/K5GiBzBhLM+oh aXbchEmHUsvaJxXgmAW7kXl1sJ28Of7jbK43WGBjo=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Fri, 1 Nov 2024 22:00:51 +0000 Message-Id: <20241101220052.1463805-5-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241101220052.1463805-1-mark.cave-ayland@ilande.co.uk> References: <20241101220052.1463805-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8bb8:f600:91a1:336d:3931:745 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 4/5] esp.c: add asc_mode property to indicate the current ESP mode 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1730498536619116600 Content-Type: text/plain; charset="utf-8" Add a new asc_mode property to ESPState which indicates the current mode of the ESP and update the ESP state machine accordingly. Bump the vmstate version and include migration logic to ensure that asc_mode is set to initiator mode such that any commands in progress will always continue. Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 21 ++++++++++++++++++++- include/hw/scsi/esp.h | 8 ++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 36e92dcd7b..3370546287 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -278,6 +278,7 @@ static int esp_select(ESPState *s) if (!s->current_dev) { /* No such drive */ s->rregs[ESP_RSTAT] =3D 0; + s->asc_mode =3D ESP_ASC_MODE_DIS; s->rregs[ESP_RINTR] =3D INTR_DC; esp_raise_irq(s); return -1; @@ -287,6 +288,7 @@ static int esp_select(ESPState *s) * Note that we deliberately don't raise the IRQ here: this will be do= ne * either in esp_transfer_data() or esp_command_complete() */ + s->asc_mode =3D ESP_ASC_MODE_INI; return 0; } =20 @@ -311,6 +313,7 @@ static void do_command_phase(ESPState *s) if (!current_lun) { /* No such drive */ s->rregs[ESP_RSTAT] =3D 0; + s->asc_mode =3D ESP_ASC_MODE_DIS; s->rregs[ESP_RINTR] =3D INTR_DC; s->rregs[ESP_RSEQ] =3D SEQ_0; esp_raise_irq(s); @@ -1095,6 +1098,7 @@ void esp_hard_reset(ESPState *s) fifo8_reset(&s->cmdfifo); s->dma =3D 0; s->dma_cb =3D NULL; + s->asc_mode =3D ESP_ASC_MODE_DIS; =20 s->rregs[ESP_CFG1] =3D 7; } @@ -1163,6 +1167,7 @@ static void esp_run_cmd(ESPState *s) break; case CMD_MSGACC: trace_esp_mem_writeb_cmd_msgacc(cmd); + s->asc_mode =3D ESP_ASC_MODE_DIS; s->rregs[ESP_RINTR] |=3D INTR_DC; s->rregs[ESP_RSEQ] =3D 0; s->rregs[ESP_RFLAGS] =3D 0; @@ -1330,6 +1335,14 @@ static bool esp_is_between_version_5_and_6(void *opa= que, int version_id) return version_id >=3D 5 && version_id <=3D 6; } =20 +static bool esp_is_version_8(void *opaque, int version_id) +{ + ESPState *s =3D ESP(opaque); + + version_id =3D MIN(version_id, s->mig_version_id); + return version_id >=3D 8; +} + int esp_pre_save(void *opaque) { ESPState *s =3D ESP(object_resolve_path_component( @@ -1361,13 +1374,18 @@ static int esp_post_load(void *opaque, int version_= id) } } =20 + if (version_id < 8) { + /* Assume initiator mode to allow all commands to continue */ + s->asc_mode =3D ESP_ASC_MODE_INI; + } + s->mig_version_id =3D vmstate_esp.version_id; return 0; } =20 const VMStateDescription vmstate_esp =3D { .name =3D "esp", - .version_id =3D 7, + .version_id =3D 8, .minimum_version_id =3D 3, .post_load =3D esp_post_load, .fields =3D (const VMStateField[]) { @@ -1399,6 +1417,7 @@ const VMStateDescription vmstate_esp =3D { esp_is_between_version_5_and_6), VMSTATE_UINT8_TEST(lun, ESPState, esp_is_version_6), VMSTATE_BOOL(drq_state, ESPState), + VMSTATE_UINT8_TEST(asc_mode, ESPState, esp_is_version_8), VMSTATE_END_OF_LIST() }, }; diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index c9afcb7cac..64cbd11765 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -14,6 +14,12 @@ typedef void (*ESPDMAMemoryReadWriteFunc)(void *opaque, = uint8_t *buf, int len); #define ESP_FIFO_SZ 16 #define ESP_CMDFIFO_SZ 32 =20 +enum ESPASCMode { + ESP_ASC_MODE_DIS =3D 0, /* Disconnected */ + ESP_ASC_MODE_INI =3D 1, /* Initiator */ + ESP_ASC_MODE_TGT =3D 2 /* Target */ +}; + #define TYPE_ESP "esp" OBJECT_DECLARE_SIMPLE_TYPE(ESPState, ESP) =20 @@ -38,6 +44,7 @@ struct ESPState { uint8_t cmdfifo_cdb_offset; uint8_t lun; uint32_t do_cmd; + uint8_t asc_mode; =20 bool data_ready; int dma_enabled; @@ -138,6 +145,7 @@ struct SysBusESPState { #define INTR_FC 0x08 #define INTR_BS 0x10 #define INTR_DC 0x20 +#define INTR_IL 0x40 #define INTR_RST 0x80 =20 #define SEQ_0 0x0 --=20 2.39.5 From nobody Sat Nov 23 20:10:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730498541876988.6946887322866; Fri, 1 Nov 2024 15:02:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6zhp-0004N7-0w; Fri, 01 Nov 2024 18:01:21 -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 1t6zhn-0004Mt-26 for qemu-devel@nongnu.org; Fri, 01 Nov 2024 18:01:19 -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 1t6zhl-0002pQ-Fp for qemu-devel@nongnu.org; Fri, 01 Nov 2024 18:01:18 -0400 Received: from [2a00:23c4:8bb8:f600:91a1:336d:3931:745] (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 1t6zhL-0002pk-I7; Fri, 01 Nov 2024 22:00:55 +0000 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; bh=NwEJZFksF0m56FX8W6tSedaKNxFFPRUpoadz83xr864=; b=H0Wfr0sqA+Ebde3tL9+ZJgLH47 6XbsTz+EGyfb5aZ1YQvauuuQqt1ZVVwMOh0NeL338goj53xQ7RZ1bCUD3IGN85rksXd7gBSGolt9s X96edYSRQ6kn7eTbBMDmy34uHi2IxnzcS8jWe9E4jL1P801DmKhBGTDa5i8SYuNxen+60DzJyEXgu MmPEe4bh7ikEXQ9dz6w1yl/6LpfBBU9BPjxEkJc7Yv90ZfLh8L4NubDnV8pzKAfFGLv9uzsJUDJeH 7jVNKbTKcOzFau15x5s0EPElHPq0t3MQBygmro7nU29XRgxn9UN3j04YaldgIOwvEde+9R1aJh4K0 XCIvb0HJ65sEreQXYrRJRiopUYcwop2rzmW6YS6FCyf5vmTE9XHaGA5dCIcZSmWNoOq7P3DVnMHux iIgU8vUP4bYBCnkfBpgO/X64SujgDn60Z80EO4zQ4rClUrpAByW5Ct/k+ySrJnOG2XdW3pBIZyhpi OV4uXlX+XARNDRrNgYRPXbGdOY4x8pE7bRchc1ut7/9h8JIECht6uy0ceeHs/sKvW3DSC3Opz+QQ1 A4mbdbaieLdxuecdzW2tmGh1nC/rsOmmN9soBwGqqIpBn0O+XDxAX2/QSsM8t02tqzKKaFP2TZZYU XQ8pbKo2L8L5NVeCQhlsRT16W6IdnHYzqHsVqhkxQ=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Fri, 1 Nov 2024 22:00:52 +0000 Message-Id: <20241101220052.1463805-6-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241101220052.1463805-1-mark.cave-ayland@ilande.co.uk> References: <20241101220052.1463805-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8bb8:f600:91a1:336d:3931:745 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 5/5] esp.c: only allow ESP commands permitted in the current asc_mode 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1730498542892116600 Content-Type: text/plain; charset="utf-8" If an ESP command is issued in an incorrect mode then an illegal command interrupt should be generated. Add a new esp_cmd_is_valid() function to indicate whether the ESP command is valid for the current mode, and if not then raise the illegal command interrupt. This fixes WinNT MIPS which issues ICCS after a Chip Reset which is not permitted, but will fail with an INACCESSIBLE_BOOT_DEVICE error unless an interrupt is generated. Signed-off-by: Mark Cave-Ayland Fixes: 83428f7a97 ("esp.c: move write_response() non-DMA logic to esp_do_no= dma()") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2464 --- hw/scsi/esp.c | 37 +++++++++++++++++++++++++++++++++++++ hw/scsi/trace-events | 1 + include/hw/scsi/esp.h | 7 +++++++ 3 files changed, 45 insertions(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 3370546287..7b6b8a4a57 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1122,6 +1122,38 @@ static void parent_esp_reset(ESPState *s, int irq, i= nt level) } } =20 +static bool esp_cmd_is_valid(ESPState *s, uint8_t cmd) +{ + uint8_t cmd_group =3D (cmd & CMD_GRP_MASK) >> 4; + + /* Always allow misc commands */ + if (cmd_group =3D=3D CMD_GRP_MISC) { + return true; + } + + switch (s->asc_mode) { + case ESP_ASC_MODE_DIS: + /* Disconnected mode: only allow disconnected commands */ + if (cmd_group =3D=3D CMD_GRP_DISC) { + return true; + } + break; + + case ESP_ASC_MODE_INI: + /* Initiator mode: allow initiator commands */ + if (cmd_group =3D=3D CMD_GRP_INIT) { + return true; + } + break; + + default: + g_assert_not_reached(); + } + + trace_esp_invalid_cmd(cmd, s->asc_mode); + return false; +} + static void esp_run_cmd(ESPState *s) { uint8_t cmd =3D s->rregs[ESP_CMD]; @@ -1278,6 +1310,11 @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint= 64_t val) break; case ESP_CMD: s->rregs[saddr] =3D val; + if (!esp_cmd_is_valid(s, s->rregs[saddr])) { + s->rregs[ESP_RSTAT] |=3D INTR_IL; + esp_raise_irq(s); + break; + } esp_run_cmd(s); break; case ESP_WBUSID ... ESP_WSYNO: diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events index f0f2a98c2e..6c2788e202 100644 --- a/hw/scsi/trace-events +++ b/hw/scsi/trace-events @@ -198,6 +198,7 @@ esp_mem_writeb_cmd_ensel(uint32_t val) "Enable selectio= n (0x%2.2x)" esp_mem_writeb_cmd_dissel(uint32_t val) "Disable selection (0x%2.2x)" esp_mem_writeb_cmd_ti(uint32_t val) "Transfer Information (0x%2.2x)" esp_set_phase(const char *phase) "setting bus phase to %s" +esp_invalid_cmd(uint8_t cmd, uint8_t asc_mode) "command 0x%x asc_mode 0x%x" =20 # esp-pci.c esp_pci_error_invalid_dma_direction(void) "invalid DMA transfer direction" diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index 64cbd11765..3526bad746 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -111,6 +111,13 @@ struct SysBusESPState { #define CMD_DMA 0x80 #define CMD_CMD 0x7f =20 +#define CMD_GRP_MASK 0x70 + +#define CMD_GRP_MISC 0x00 +#define CMD_GRP_INIT 0x01 +#define CMD_GRP_TRGT 0x02 +#define CMD_GRP_DISC 0x04 + #define CMD_NOP 0x00 #define CMD_FLUSH 0x01 #define CMD_RESET 0x02 --=20 2.39.5