From patchwork Tue Feb 13 19:39: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: 13555600 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 0A7B0C4829A for ; Tue, 13 Feb 2024 19:49:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyeV-0002I0-GU; Tue, 13 Feb 2024 14:41:11 -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 1rZyeT-0002Gk-Hz for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41: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 1rZyeR-0006DT-9j for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:09 -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=iLYkZARu1vtJ3SiTWVKioF4o+HiVbNwnzi4KqCUj564=; b=X69PTqMcK+VXusg/nzA854DFNG QBD1Alir6pgA8McyDqQNgm0G/SUbHidnB+BnhjOcYLkeU1jgiGGwUNelvAAyvJXlHVHyMZuC4T3dr 7h9pOhk7VYjQ7fLoXJNCWmXOxUnAf7fJnsDbfygJp6LBLJ4Q32htLxD7ZEs3+z69QFPWhvMqRJd13 865WirEPTM4BIL5loarpMikPAZbZfIkpiH7MsqFey605P+LLXgRhYGNDj+OZ2UMn5QLYVyxUMw5tn aufIQ06edGJkQExWI2uN/C2xzK95sf6HWNxyvcWz5nvwO9kFMIDGF7eghehIM9YRHBuHWqIzrzND4 Cn1yk4T6Eqw2Ys95gHd8J6BBiE0pnQCxkberb2jN2DCnkzj9sfqTpqxYWlYOydzuFPd2UkJn+toF7 kAwc7IUC1ImVmbK1vIEtNft4E9EKUnl5b2xibQ9jxZchCmjmF4gMlcQdDGSclQOOEfVyp9rGbT+H1 Kq44r0NxqTDyTR7oA8kOf/q385y2NhARhkgI8fAnk53ui1mg0ffZPw+/gXg3GSmigZE35dbCUTrCW pq4azE9Ft6alGi18smocHP6zhoBDnJDZF5S/6kX0czhrFoVqlZwDCOITcGorw/iUffZG1VGklbEdK SemqkqqaovBOjljSXDGGUEdTJtCDtaQMuTsw5lSlI=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZydg-0008m4-4B; Tue, 13 Feb 2024 19:40:24 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:25 +0000 Message-Id: <20240213194052.1162753-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 01/88] esp.c: don't clear cmdfifo when esp_select() fails in get_cmd() 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 FIFO contents should not be affected if the target selection fails. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-2-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 3a1c9f7c3b..68d07edc05 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -252,11 +252,9 @@ static uint32_t get_cmd(ESPState *s, uint32_t maxlen) fifo8_push_all(&s->cmdfifo, buf, dmalen); } else { if (esp_select(s) < 0) { - fifo8_reset(&s->cmdfifo); return -1; } esp_raise_drq(s); - fifo8_reset(&s->cmdfifo); return 0; } } else { @@ -271,7 +269,6 @@ static uint32_t get_cmd(ESPState *s, uint32_t maxlen) trace_esp_get_cmd(dmalen, target); if (esp_select(s) < 0) { - fifo8_reset(&s->cmdfifo); return -1; } return dmalen; From patchwork Tue Feb 13 19:39: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: 13555558 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 AA668C48260 for ; Tue, 13 Feb 2024 19:42:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyeY-0002Ii-3N; Tue, 13 Feb 2024 14:41: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 1rZyeU-0002Hk-Ef for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:10 -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 1rZyeT-0006EC-2P for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:10 -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=ufc3Eg8hezOcAS6d9idy+jWAkfMlLCSSNAhNoTUn1bc=; b=dRooZi5KpagC+f3RacrRAOh+Ew YVNeng0BF7Ju/cFMoEGqDnYpoXHZG9mJmFUwL6W0pFZeKgmnXt2xusM7CqQplUZ+rJqnJRhcEVoZj ViIGxn0I9L8cslBcs7hmyDHJFBV/PxFkgDaWDwEF/3HdfaNFISOEl2BEmo0eGy8YM3mJ9UFzXZvxp uH9vwprxsBNBMGl13Qo90NBz9q+YGGcagBGOTWdVcHOefG90o5lEGODL1ehz4g5JRdny8A1bNkIvz E2eftzJG/YyXTxTvKxRpAWTeb3oqUwye+Yj43d3p7jVTXOyCaDXZZr3viXEAk5Kx0XyNTy9Q7t631 GUXvhfI855YCr5lPx31lI1bqlb35KPhw3nrO/oLxYQ+iS1dkNuJNUulclYKUzCVxfuhTFFjSb81+A 8FYrRISKXiZdHulsZOBXZuibkXuTyIAeFi7ww6ZByZ+vV/rccyJLcZYuyVyYVIzKZjC3626vEHV+3 QFD1JXLbeCGEeONein9fCdNQgRkkQWxEU/lebaPd4bOl1lwMtWP2xRoO7I6jnWXexp2Kj1B3D1mH3 3DXIHfTXWYxMI5lHGxn7t35scNvkPoayjvLItOUe3cu2dbi97m0NN+1x/jWm/L+EppjnESn1TRV2h wj1BhFg2o6TH0mRw/ZPx3lTkQCZC5dYHSCWf/l+rI=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZydk-0008m4-7G; Tue, 13 Feb 2024 19:40:28 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:26 +0000 Message-Id: <20240213194052.1162753-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 02/88] esp.c: move existing request cancel check into esp_select() 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 Since get_cmd() can be called multiple times during a mixed FIFO/DMA request, move the existing request cancel check into esp_select() which always occurs at the start of new SCSI request. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-3-mark.cave-ayland@ilande.co.uk> 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 68d07edc05..b382865426 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -209,6 +209,11 @@ static int esp_select(ESPState *s) s->ti_size = 0; fifo8_reset(&s->fifo); + if (s->current_req) { + /* Started a new command before the old one finished. Cancel it. */ + scsi_req_cancel(s->current_req); + } + s->current_dev = scsi_device_find(&s->bus, 0, target, 0); if (!s->current_dev) { /* No such drive */ @@ -235,11 +240,6 @@ static uint32_t get_cmd(ESPState *s, uint32_t maxlen) uint32_t dmalen, n; int target; - if (s->current_req) { - /* Started a new command before the old one finished. Cancel it. */ - scsi_req_cancel(s->current_req); - } - target = s->wregs[ESP_WBUSID] & BUSID_DID; if (s->dma) { dmalen = MIN(esp_get_tc(s), maxlen); From patchwork Tue Feb 13 19:39: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: 13555554 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 3DFFDC48260 for ; Tue, 13 Feb 2024 19:42:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyeZ-0002MM-N7; Tue, 13 Feb 2024 14:41:15 -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 1rZyeY-0002In-C5 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:14 -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 1rZyeX-0006Ew-0q for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:14 -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=4jW7lXLEbxFgTtylTDdvoHs79P2KJ++hoi/n37K19Ho=; b=GiSgqyWP0EVzcXKKt4GOR7VVat 0Z5DS/gYc2PS0PnzTBae7PMUayxVr1pZBJrJPCl8jFG92yfdeduN6bbNzKiH4oOV6BdDI27uZhh1Z D452QUn9AhqHNzUMFGVc3/InSU7M1Uy+qWtH/5+h1wqhgmB/wOMYsgz8FyOV19aCHKqGw2LENFFVw CFhHMLd4tgY/EU+8hqQCienKsIseo7zXosnYoHk5viYAmnXZGPtfFIsvhKfDG3BpW9wOESB4LZQ++ vR9CBWxzbcRXHdG3txiFbjlIFUdZ1vQ0JA+f6fqWp0iZSg/Dg6tdz9VKlQKqnF/EOoGO5kYSiAotH /jaIgMD5bxwD88TS3p5kxRDIB52usd3sTBg2dhxmnyAqKCZgEVek+ouf/wuN9gXXQaZgiC5CFle1h LRxCACutKwxciuGIRSWJLfcAqXgYij0tWnJiLJO1OOonizOYbBJk3joIhAS7fD706rldWPgj5HrpY 4USFTPcc0je2/nQ3AGVFmwdt22Im1xORWS5XnF13v44ptEgtBBfXhiAzsRaZayvAYWJJZf0XuxzvU zajUZunpplKvPj5DcF5S2ftIsR4HOfAa4m2YSPd8zcgxf3HC2gdMaKExQnQc1zsQcVUxj4Euk4m44 T/fz6qnA1IfZzXJd+K7yxmpR3eJjVdbUUqt+sTfbU=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZydo-0008m4-AL; Tue, 13 Feb 2024 19:40:32 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:27 +0000 Message-Id: <20240213194052.1162753-4-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 03/88] esp.c: add FIFO wraparound support to esp_fifo_pop_buf() 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 fifo8_pop_buf() function returns a pointer to the FIFO buffer up to the specified length. Since the FIFO buffer is modelled as an array then once the FIFO wraps around, only the continuous portion of the buffer can be returned. In future the use of continuous and unaligned accesses will advance the internal FIFO head pointer, so modify esp_fifo_pop_buf() to ensure that any wraparound content is also returned up to the requested length. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-4-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index b382865426..8d8f6a817a 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -121,17 +121,30 @@ static uint8_t esp_fifo_pop(Fifo8 *fifo) static uint32_t esp_fifo_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen) { const uint8_t *buf; - uint32_t n; + uint32_t n, n2; + int len; if (maxlen == 0) { return 0; } - buf = fifo8_pop_buf(fifo, maxlen, &n); + len = maxlen; + buf = fifo8_pop_buf(fifo, len, &n); if (dest) { memcpy(dest, buf, n); } + /* Add FIFO wraparound if needed */ + len -= n; + len = MIN(len, fifo8_num_used(fifo)); + if (len) { + buf = fifo8_pop_buf(fifo, len, &n2); + if (dest) { + memcpy(&dest[n], buf, n2); + } + n += n2; + } + return n; } From patchwork Tue Feb 13 19:39: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: 13555574 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 86184C4829A for ; Tue, 13 Feb 2024 19:44:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyee-0002Px-LQ; Tue, 13 Feb 2024 14:41:20 -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 1rZyec-0002PI-Jz for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:18 -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 1rZyeb-0006FH-70 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:18 -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=eSyr3No0APEoI/lcC8TKsbyD63zHKLL4xNSL+PAfQpI=; b=nWDexq/kRZ1IaQVLpamz12kP85 RVFt4LrnmJnUpGhP3iJuNldQ0CFU6h4IEMQGHrek31WAKiLeWJV2exRsWUhJX4TJM8ARR8Hya5Xv5 68OUcsZ0IExwdemCd2G/8j7nyuPkWaTiCy/8+PrCU3SDO/TKeKYNgGF1FTet/V9k9muPGfGPilfFx EaOJuT+VVzF1C9FG6OLYs7DaWP0izNzcMu1MeTe51xhHyR17WFl20Y/xDjYIJqqHn9Ay3+fzFbJco zFMFTaaViutqzEpLRI7XZH7AwUMtChhTaIW0WwJA/uSwv5PSZojGzyQ8r2OeqgiofjZw32rX/Ntu8 p2raoKvisSpDXQYC8EmeZ2JrSJUygvbShX8wD/UdExMfVVzRsWC/ZGA9jGxE0G7+9qQ60W0/NrYgt sYtRP5u3IFKm+SF7PCKHu3uUdnmPLN+hiGXc2pt98dQz8IsP4fvrpqvwhByG3zy2rdWrXFP1i3h08 XTvT/Za7JHMylL/HiSPhNv0x6Qv3H3MnYLTCQd9GY1dsNqJScDz8SskPW0/jkzMHrCrc2hq+hOOFF JYD9nMzduS7B5XvkzfvvJwsTUw9CIVF3WFQOI8HId6RZMGf0YhCGcsMyCF0KJaoSAKkKN07BLBlfw wXHqssGYx8dW4+y67DZjLA9URMKdPeFy2s+Q9fIAY=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyds-0008m4-DQ; Tue, 13 Feb 2024 19:40:36 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:28 +0000 Message-Id: <20240213194052.1162753-5-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 04/88] esp.c: remove FIFO clear from esp_select() 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 FIFO contents should not be affected by performing SCSI target selection. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-5-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 8d8f6a817a..89fce05e58 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -220,7 +220,6 @@ static int esp_select(ESPState *s) target = s->wregs[ESP_WBUSID] & BUSID_DID; s->ti_size = 0; - fifo8_reset(&s->fifo); if (s->current_req) { /* Started a new command before the old one finished. Cancel it. */ From patchwork Tue Feb 13 19:39: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: 13555594 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 12538C48260 for ; Tue, 13 Feb 2024 19:48:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyei-0002R4-BX; Tue, 13 Feb 2024 14:41:24 -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 1rZyeg-0002Qh-LH for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:22 -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 1rZyef-0006Fj-7d for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:22 -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=MVDMmvJTqOzEPP0u0xre999nw8BU0NcMg9uxPxgcwTs=; b=HODkoB9MMC79g23+Apc7B3wJEP OcEpUQYGXOw2EjMt/Uk0bXeAQRIbj0XgO3C+UAleveOquUi90O6gq32Nt7FubtUSPxdfSi9KujINY aEj4NrQoFoXEhbPTvdT7d600JrT9uf+Vfv8AkeRgLDGWeEpXRiUaTecTbiGuAFGJCWkxi1nXxNutJ 4Wfn3wXG6Q6gnT1aQ4jT4qBN0fBhFy8jrtp/P7D+kAjIS6Ezgen+Lzi+Pj10/283oma1ttKG79k38 4dCfOEUGOKu+tdtbagbCnZ7e3sJSIA6qM/7uoO/c8Vj5cyeNUrTAGJKLAZqNSKmDI05PP1ALe4jn1 Kcgtph+Fma9bpiRxbk46Ex1SZGP0rgmp1Re5MLzDzVrq6FigRxWSMUMScNMPoQBjNQ0HI97H6Rh9v qgSVDp/nkwQTollLmXu370v8DUJ3Dd1jGwtQEgddNkmEjwlptKaP7uuc//gseW8Ww9/FC6wDs7Ca7 YaOZzR5Ppadp10iOyhadwnxH80Y8T4UWmDCpFwdssekInSHoIodKsveXAEWjcLZoQBvcboTFi+M/K agny72NQknczsuzIC9k7UqvEYKWftQHFNwD9yID9/ykLQ0AsX3qdTPqgn2ssL6rH8gH0BXikSPSh1 SdQQ+2I2IImrzUYQAmJKxEa+afRd1QgFvniY3Xpw8=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZydw-0008m4-GY; Tue, 13 Feb 2024 19:40:40 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:29 +0000 Message-Id: <20240213194052.1162753-6-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 05/88] esp.c: move esp_select() to ESP selection commands from get_cmd() 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 Since the DREQ value depends upon the result of the selection process, add a workaround to each esp_select() to manually assert DREQ durring the MESSAGE OUT and COMMAND phases. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-6-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 89fce05e58..8c1c6bfc1c 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -263,10 +263,6 @@ static uint32_t get_cmd(ESPState *s, uint32_t maxlen) dmalen = MIN(fifo8_num_free(&s->cmdfifo), dmalen); fifo8_push_all(&s->cmdfifo, buf, dmalen); } else { - if (esp_select(s) < 0) { - return -1; - } - esp_raise_drq(s); return 0; } } else { @@ -280,9 +276,6 @@ static uint32_t get_cmd(ESPState *s, uint32_t maxlen) } trace_esp_get_cmd(dmalen, target); - if (esp_select(s) < 0) { - return -1; - } return dmalen; } @@ -380,12 +373,18 @@ static void handle_satn(ESPState *s) return; } esp_set_pdma_cb(s, SATN_PDMA_CB); + if (esp_select(s) < 0) { + return; + } cmdlen = get_cmd(s, ESP_CMDFIFO_SZ); if (cmdlen > 0) { s->cmdfifo_cdb_offset = 1; s->do_cmd = 0; do_cmd(s); } else if (cmdlen == 0) { + if (s->dma) { + esp_raise_drq(s); + } s->do_cmd = 1; /* Target present, but no cmd yet - switch to command phase */ s->rregs[ESP_RSEQ] = SEQ_CD; @@ -411,12 +410,18 @@ static void handle_s_without_atn(ESPState *s) return; } esp_set_pdma_cb(s, S_WITHOUT_SATN_PDMA_CB); + if (esp_select(s) < 0) { + return; + } cmdlen = get_cmd(s, ESP_CMDFIFO_SZ); if (cmdlen > 0) { s->cmdfifo_cdb_offset = 0; s->do_cmd = 0; do_cmd(s); } else if (cmdlen == 0) { + if (s->dma) { + esp_raise_drq(s); + } s->do_cmd = 1; /* Target present, but no cmd yet - switch to command phase */ s->rregs[ESP_RSEQ] = SEQ_CD; @@ -446,6 +451,9 @@ static void handle_satn_stop(ESPState *s) return; } esp_set_pdma_cb(s, SATN_STOP_PDMA_CB); + if (esp_select(s) < 0) { + return; + } cmdlen = get_cmd(s, 1); if (cmdlen > 0) { trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); @@ -456,6 +464,9 @@ static void handle_satn_stop(ESPState *s) s->rregs[ESP_RSEQ] = SEQ_MO; esp_raise_irq(s); } else if (cmdlen == 0) { + if (s->dma) { + esp_raise_drq(s); + } s->do_cmd = 1; /* Target present, switch to message out phase */ s->rregs[ESP_RSEQ] = SEQ_MO; From patchwork Tue Feb 13 19:39: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: 13555559 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 B6AEBC48BC4 for ; Tue, 13 Feb 2024 19:42:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyem-0002Wj-9C; Tue, 13 Feb 2024 14:41: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 1rZyek-0002W4-LO for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41: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 1rZyej-0006G2-9x for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41: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=uLiM6plWEwzlkiZfu7sRaC/5jsVXGWNfxKLn+cAJ7PQ=; b=WEh8QXyUuCRcGXmvViGGH+SW+L 9qEdSeoOYGDknC5ePJqk49f3Cb7s8prgdgRstXBfoKw4J89RE9rOT9Veiwts8l8kpu88UtNbld2nN q+lwODWjXqTLvrZsQpGsUEAVTs9TCh8e6wikHzUQwD9E596grcK+39F9K+WhHf7wD6UBuJxYZ9PM4 tIDo9L9NIVs5lnVJMlf3ZokgZ7MJqW6GHabvfcer3XYCjKy2a5oz+lODeENFEh/oxHc1ZJsBhui31 NgwctbkaXN+ZM4V2C7u4hk7YGcIKjB79h6j041IxHfFZDbd4G8KiGIV1JHXGu/jCb3IPyKZqtB5dh JDTjzF1faHPpk0wSsmG0zzWO9QzH6LAmftgRZOd9t22ahN+NSdzFpX1/v2aebHLvadHgTl8vWvWw+ 7ZUy/vZa0N1teRe/9kUWnJKvrQuxXxXiZx/cbEzb5Q/2c+Gkj+W4rJh4Nq1sET4gv1mCCIZ/DmLuI uSXY5lxh1oriAnS6Jj1L9qnQsBSnDGmB1YeNJk+KuBNrKX2qOmNuJmeIDhsWAtVi85+HnmUTnnWra vXsmxRHVow/3uqcG5wfJjwbE8nBt/a9g5YjYTsQL/X5AM2MTM4uvv2o+7zNuO6lH6+xRGoqc8TSun Ny9qPZWga21etqJOISI4XSn40HkJPXgfAkrjIH11o=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZye0-0008m4-Jg; Tue, 13 Feb 2024 19:40:44 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:30 +0000 Message-Id: <20240213194052.1162753-7-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 06/88] esp.c: update esp_set_tc() to set STAT_TC flag 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 flag is set once the transfer counter counts down to zero. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-7-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 8c1c6bfc1c..c7b79a2949 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -161,9 +161,15 @@ static uint32_t esp_get_tc(ESPState *s) static void esp_set_tc(ESPState *s, uint32_t dmalen) { + uint32_t old_tc = esp_get_tc(s); + s->rregs[ESP_TCLO] = dmalen; s->rregs[ESP_TCMID] = dmalen >> 8; s->rregs[ESP_TCHI] = dmalen >> 16; + + if (old_tc && dmalen == 0) { + s->rregs[ESP_RSTAT] |= STAT_TC; + } } static uint32_t esp_get_stc(ESPState *s) From patchwork Tue Feb 13 19:39: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: 13555555 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 C7ABCC4829A for ; Tue, 13 Feb 2024 19:42:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyer-0002aJ-UZ; Tue, 13 Feb 2024 14:41:33 -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 1rZyep-0002Y8-T8 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:31 -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 1rZyen-0006Gc-BL for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:30 -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=gL3rxkF+WyxBCs1v0/c31P8hNMH9IELl4XbMUORFGh4=; b=wYGIPipJGIHCc9w5qdfe7apKdG VP/+CH1G86f6zmfnRZHBHSzfagfmmWFAkLPwvmMZ1VCM/8QGxGPhtlAx3kA8A6BgORhAiByadiqbP 1VYM3oM0c83hw+Kd+Odh69kM1LrcnVWh78cUJJmhm8bE6n+9xZqA0N8Pmf7u8GNVNZ+LxbOfOIpVs HhMOlTfxu29yJ7bERwesHO1s3LCKh+kOr28DVmAOYZuym85FtMqHN8fNbuIFPkrLI8bBalM6MQLL8 sTPK4kVNOxkeRKB9Sb5Nl/9G8WPCbZK7DbdQBBr7AlPgS47hFXMJg3DqYXFjVGd0xMFwNWBIQx2eE PJ/+DVnp5J5Yawxi9LEIzcUSSuedgJuqfXQeHHTes1GNEP2ID6Y+gttYxxMac4afR2rJHnCpv17xs NaH2VrUtCI3rIYiJIk+Ynddvv1HRTB3jaadmNF8UQm1XvGILGSZgRdgLKZhAGf1rNUZD8d6+ZI7Ux 0zpA/zbjtoOoiqYpkJOiNP7Q2JTA7cfbSaAKzwdV19zEHCSNs6y7JkT9wT+E+YIRiKBt3jDmnaQEA Svoji56SdZPIsCOWk5whZGUDuebijCGg6QQxik2u/+0JfsqZKLFSRFlPTRcgKf3ZHbzZCuwW7nVxG VjWC7mLX4OmZefqd6CK5VEc0NfWkWPq0ZFgvnL9Fw=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZye4-0008m4-Mh; Tue, 13 Feb 2024 19:40:48 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:31 +0000 Message-Id: <20240213194052.1162753-8-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 07/88] esp.c: start removal of manual STAT_TC setting when transfer counter reaches zero 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 should be exclusively managed by esp_set_tc() rather than being manually set in multiple places. Start by removing the occurrences exclusive to PDMA and command completion which are those that can be currently removed without affecting any test images. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-8-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index c7b79a2949..e717b2e216 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -611,11 +611,6 @@ static void do_dma_pdma_cb(ESPState *s) s->async_len -= len; s->ti_size -= len; esp_set_tc(s, esp_get_tc(s) - len); - - if (esp_get_tc(s) == 0) { - /* Indicate transfer to FIFO is complete */ - s->rregs[ESP_RSTAT] |= STAT_TC; - } return; } @@ -720,9 +715,6 @@ static void esp_do_dma(ESPState *s) esp_set_tc(s, esp_get_tc(s) - len); esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); - - /* Indicate transfer to FIFO is complete */ - s->rregs[ESP_RSTAT] |= STAT_TC; return; } } @@ -870,7 +862,8 @@ void esp_command_complete(SCSIRequest *req, size_t resid) * transfers from the target the last byte is still in the FIFO */ if (s->ti_size == 0) { - s->rregs[ESP_RSTAT] = STAT_TC | STAT_ST; + s->rregs[ESP_RSTAT] &= ~7; + s->rregs[ESP_RSTAT] |= STAT_ST; esp_dma_done(s); esp_lower_drq(s); } From patchwork Tue Feb 13 19:39: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: 13555557 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 3BB59C4829A for ; Tue, 13 Feb 2024 19:42:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyer-0002aK-U1; Tue, 13 Feb 2024 14:41:33 -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 1rZyep-0002Y7-Qd for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:31 -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 1rZyen-0006Gi-Sz for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:31 -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=P9yi8vyd03plkgnTYwxxAM7QdMbpNlZtBZuZcPeGvCI=; b=whEOi8lvS/9c/+bjIcUMF0kGsb CJCKMktGZCRRvU/RdpAFKVeJ4imRwwMhMI9mAkX/E30Zor2JKZOQXk0ZtR8P/H9M0TJNxJ48V1HUj FUp13g+ve//zhAZWgsEwEIxWP+q31DTkNcD00PS3b+eEg2XEvVR2plkHpD74Go6e7YpWPt+iIIj+p aqZsMDhxZTGupEP2PjCLxx0VkgnyeMRCWApNzK4u5myeeYgpsHJCFKPig9byqHG+WIiLbSa+mHObb 5LKDK+50lNCuP6w7Pgg52TmdHrLBMPdpOeOXtdNrsLwMzbY/UxK6KpOV3Qc9em1L61GZofvXgBCkF kYFHfAtr8bjaD0d5Jmr5j0VmbATX2D4a8rI8wgyCn2HFtQOeZoSCWwnFtwlldK6HAKQq5FsLWfbzv nBHGIQNLLeo+BNQTyTXavVBoWZV4Tp4sVn84UqXoxQ66yqBbjQdcONVcOBfmb2LRHrREzYMccZEia lnTxHQkpCB7gjGWGUsGJOTfhmEOCkwzxy3iqWcV0ohA1Nb9NOWmbE4fN770lR5WrTvU/kaXXgAXiP MV580gJZi0ePwlEbZjXZHYr0pIX3QyFeqKpgp+5zXWK51FOFk0RUJU343js6SQmTAFqTrIuUPPAxT I3hGshF5WPnETq9B/xZQfa0CTA9/tk6dhiTm7D0cQ=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZye8-0008m4-Pq; Tue, 13 Feb 2024 19:40:49 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:32 +0000 Message-Id: <20240213194052.1162753-9-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 08/88] esp.c: move command execution logic to new esp_run_cmd() function 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 helps to simplify esp_reg_write() and potentially allows for a 2-level deep FIFO to be implemented in future. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-9-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 177 ++++++++++++++++++++++++++------------------------ 1 file changed, 92 insertions(+), 85 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index e717b2e216..fecfef7c89 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -980,6 +980,97 @@ static void parent_esp_reset(ESPState *s, int irq, int level) } } +static void esp_run_cmd(ESPState *s) +{ + uint8_t cmd = s->rregs[ESP_CMD]; + + if (cmd & CMD_DMA) { + s->dma = 1; + /* Reload DMA counter. */ + if (esp_get_stc(s) == 0) { + esp_set_tc(s, 0x10000); + } else { + esp_set_tc(s, esp_get_stc(s)); + } + } else { + s->dma = 0; + } + switch (cmd & CMD_CMD) { + case CMD_NOP: + trace_esp_mem_writeb_cmd_nop(cmd); + break; + case CMD_FLUSH: + trace_esp_mem_writeb_cmd_flush(cmd); + fifo8_reset(&s->fifo); + break; + case CMD_RESET: + trace_esp_mem_writeb_cmd_reset(cmd); + esp_soft_reset(s); + break; + case CMD_BUSRESET: + trace_esp_mem_writeb_cmd_bus_reset(cmd); + esp_bus_reset(s); + if (!(s->wregs[ESP_CFG1] & CFG1_RESREPT)) { + s->rregs[ESP_RINTR] |= INTR_RST; + esp_raise_irq(s); + } + break; + case CMD_TI: + trace_esp_mem_writeb_cmd_ti(cmd); + handle_ti(s); + break; + case CMD_ICCS: + trace_esp_mem_writeb_cmd_iccs(cmd); + write_response(s); + s->rregs[ESP_RINTR] |= INTR_FC; + s->rregs[ESP_RSTAT] |= STAT_MI; + break; + case CMD_MSGACC: + trace_esp_mem_writeb_cmd_msgacc(cmd); + s->rregs[ESP_RINTR] |= INTR_DC; + s->rregs[ESP_RSEQ] = 0; + s->rregs[ESP_RFLAGS] = 0; + esp_raise_irq(s); + break; + case CMD_PAD: + trace_esp_mem_writeb_cmd_pad(cmd); + s->rregs[ESP_RSTAT] = STAT_TC; + s->rregs[ESP_RINTR] |= INTR_FC; + s->rregs[ESP_RSEQ] = 0; + break; + case CMD_SATN: + trace_esp_mem_writeb_cmd_satn(cmd); + break; + case CMD_RSTATN: + trace_esp_mem_writeb_cmd_rstatn(cmd); + break; + case CMD_SEL: + trace_esp_mem_writeb_cmd_sel(cmd); + handle_s_without_atn(s); + break; + case CMD_SELATN: + trace_esp_mem_writeb_cmd_selatn(cmd); + handle_satn(s); + break; + case CMD_SELATNS: + trace_esp_mem_writeb_cmd_selatns(cmd); + handle_satn_stop(s); + break; + case CMD_ENSEL: + trace_esp_mem_writeb_cmd_ensel(cmd); + s->rregs[ESP_RINTR] = 0; + break; + case CMD_DISSEL: + trace_esp_mem_writeb_cmd_dissel(cmd); + s->rregs[ESP_RINTR] = 0; + esp_raise_irq(s); + break; + default: + trace_esp_error_unhandled_command(cmd); + break; + } +} + uint64_t esp_reg_read(ESPState *s, uint32_t saddr) { uint32_t val; @@ -1076,91 +1167,7 @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) break; case ESP_CMD: s->rregs[saddr] = val; - if (val & CMD_DMA) { - s->dma = 1; - /* Reload DMA counter. */ - if (esp_get_stc(s) == 0) { - esp_set_tc(s, 0x10000); - } else { - esp_set_tc(s, esp_get_stc(s)); - } - } else { - s->dma = 0; - } - switch (val & CMD_CMD) { - case CMD_NOP: - trace_esp_mem_writeb_cmd_nop(val); - break; - case CMD_FLUSH: - trace_esp_mem_writeb_cmd_flush(val); - fifo8_reset(&s->fifo); - break; - case CMD_RESET: - trace_esp_mem_writeb_cmd_reset(val); - esp_soft_reset(s); - break; - case CMD_BUSRESET: - trace_esp_mem_writeb_cmd_bus_reset(val); - esp_bus_reset(s); - if (!(s->wregs[ESP_CFG1] & CFG1_RESREPT)) { - s->rregs[ESP_RINTR] |= INTR_RST; - esp_raise_irq(s); - } - break; - case CMD_TI: - trace_esp_mem_writeb_cmd_ti(val); - handle_ti(s); - break; - case CMD_ICCS: - trace_esp_mem_writeb_cmd_iccs(val); - write_response(s); - s->rregs[ESP_RINTR] |= INTR_FC; - s->rregs[ESP_RSTAT] |= STAT_MI; - break; - case CMD_MSGACC: - trace_esp_mem_writeb_cmd_msgacc(val); - s->rregs[ESP_RINTR] |= INTR_DC; - s->rregs[ESP_RSEQ] = 0; - s->rregs[ESP_RFLAGS] = 0; - esp_raise_irq(s); - break; - case CMD_PAD: - trace_esp_mem_writeb_cmd_pad(val); - s->rregs[ESP_RSTAT] = STAT_TC; - s->rregs[ESP_RINTR] |= INTR_FC; - s->rregs[ESP_RSEQ] = 0; - break; - case CMD_SATN: - trace_esp_mem_writeb_cmd_satn(val); - break; - case CMD_RSTATN: - trace_esp_mem_writeb_cmd_rstatn(val); - break; - case CMD_SEL: - trace_esp_mem_writeb_cmd_sel(val); - handle_s_without_atn(s); - break; - case CMD_SELATN: - trace_esp_mem_writeb_cmd_selatn(val); - handle_satn(s); - break; - case CMD_SELATNS: - trace_esp_mem_writeb_cmd_selatns(val); - handle_satn_stop(s); - break; - case CMD_ENSEL: - trace_esp_mem_writeb_cmd_ensel(val); - s->rregs[ESP_RINTR] = 0; - break; - case CMD_DISSEL: - trace_esp_mem_writeb_cmd_dissel(val); - s->rregs[ESP_RINTR] = 0; - esp_raise_irq(s); - break; - default: - trace_esp_error_unhandled_command(val); - break; - } + esp_run_cmd(s); break; case ESP_WBUSID ... ESP_WSYNO: break; From patchwork Tue Feb 13 19:39: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: 13555568 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 7F0EBC48260 for ; Tue, 13 Feb 2024 19:43:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyev-0002it-S3; Tue, 13 Feb 2024 14:41:37 -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 1rZyeu-0002il-DA for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:36 -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 1rZyet-0006HD-0M for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:36 -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=nO+ngFbqX34GmWdyHyDwlZOuxb9VSNiPAp1CSju1IoQ=; b=q9DpdXp/mMLAWYx0xdvmZzNgvD i7batKoXDJRflAre8sbl22d3uh5nJGCPA8iNdy5vZ2km1DVFq+AyxoXsYcWDCEbag6oZ5/EZ8N7ew IM/yCm4MK6e92kbpGdBKE7ZVWpDXQF7RQ+63x7+YQwAi5KAxzcKKgtuN8Mj0uxam86hmtdbZU5Syv Lca+w6+ICmpL8/6oEwBPHGahAnIerujdqF6Bs2sZextadspa0v2IQ7nnoYE19heUAgchrY0KmpQ94 y3qEUGZ+zN7yUJcwBpsLCu/orx8W0PvVUaE5B48eJThnCiG1DYDrFf15oK7DtJiebToNuVFr/GgT0 nPY4lRUveulx41kMx6YBRERYayNIzSBhxEqrroOVvfUutrXO+/lZgjhCrIKO7BNDbtfrIfjyZeVWd CNyoGX69rfLkocO3aE/qfC84OV0WfS3KKYS0r7Cj2DkEU6tl9cIl8ImES1ap/+uUUTdAeiUKoq28H zjprvzA+a9uGX1GSktzAENF7N1dDJ76FoeAV6OJG8gz8rH9zGiIfWxWZuqUADKLKh5nUBpkWjbxr2 wYEEbVrwsutEQjHJaw7MQflWkPXCpbGHh8v/ozpXRv9Ops79hfbJ2gNr93EId6wpmeKbza38KdkDq yKaTdB3dI1Eq46rCxEou6uda5XASiXp+JN8s5uvjA=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZye9-0008m4-A7; Tue, 13 Feb 2024 19:40:53 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:33 +0000 Message-Id: <20240213194052.1162753-10-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 09/88] esp.c: update TC check logic in do_dma_pdma_cb() to check for TC == 0 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 Invert the logic so that the end of DMA transfer check becomes one that checks for TC == 0 in the from device path in do_dma_pdma_cb(). Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-10-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index fecfef7c89..63c828c1b2 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -602,21 +602,19 @@ static void do_dma_pdma_cb(ESPState *s) return; } - if (esp_get_tc(s) != 0) { - /* Copy device data to FIFO */ - len = MIN(s->async_len, esp_get_tc(s)); - len = MIN(len, fifo8_num_free(&s->fifo)); - fifo8_push_all(&s->fifo, s->async_buf, len); - s->async_buf += len; - s->async_len -= len; - s->ti_size -= len; - esp_set_tc(s, esp_get_tc(s) - len); - return; + if (esp_get_tc(s) == 0) { + esp_lower_drq(s); + esp_dma_done(s); } - /* Partially filled a scsi buffer. Complete immediately. */ - esp_lower_drq(s); - esp_dma_done(s); + /* Copy device data to FIFO */ + len = MIN(s->async_len, esp_get_tc(s)); + len = MIN(len, fifo8_num_free(&s->fifo)); + fifo8_push_all(&s->fifo, s->async_buf, len); + s->async_buf += len; + s->async_len -= len; + s->ti_size -= len; + esp_set_tc(s, esp_get_tc(s) - len); } } From patchwork Tue Feb 13 19:39:34 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: 13555560 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 E1013C4829A for ; Tue, 13 Feb 2024 19:42:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyez-0002pW-Gd; Tue, 13 Feb 2024 14:41: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 1rZyex-0002kz-Kh for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41: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 1rZyew-0006HT-2R for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:39 -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=zqLutRoVYbdRbzEtVwJ/AxxYbcmeOYUsOM5J78wPJM8=; b=zWG3RH1t6YtTs6c3MnYVlOKvmi COHuE0XdW9whOGIRe7wAn1tLN2k6RMazHObNWuYFBPDZdQ+W3DFIx9s4H4alNkK0BoT4vNnXadvCn zRcTp9IP8r5Fh8tjjiakj6ajbfd8iAKqrX08XdM0+NsunVTZjj+Hmw+YWBU3M8+hsTHa/3190Flmx 4VBy9OCa2pxqnJZ4DzN3kG3xkqGsX5aNW2gP9TZb84ajyrZpGPhummNPVmswvdeeX+Doyhm71hpRw TH5fH6d96j8sSaEgN1aQhD2L0AfGJa8yiNhsTpHXxWaToOFUzlmoFVvG1YxeizRDO1ksy4Rh5hiOp DAFX4RA8rWejRKCzaJgqGUqgOtkRBdQMczyY6Q3c2iUfBKhhgvVIdEunfbPznI0CVSczPfcjoOgXd 8h73IpxNpZjPdig5lXP7nbiht9HU7g+K9BRxa/XpakwmIXDJ73zXTxTI08ve8op4ys/zz7whA+R9D wey5XecZQumyEyyauOeXWta5fspIe/GT7OnMlrXqCpv/gScr3fUO5ct42VgDyVpz/EUmOPsWs4Z4S XyEeAS/uUpVvzYJcc22KSywNGJmI5q2hJ1jfnxHcTca11yjWUn8Ko3uCgpHs4ihZm9BE6ZhBYBOpN b9KVpoc0CB//NIhXXtq0w9Rh4kzDVnUPZR0tU3th8=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyeD-0008m4-DD; Tue, 13 Feb 2024 19:40:57 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:34 +0000 Message-Id: <20240213194052.1162753-11-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 10/88] esp.c: move buffer and TC logic into separate to/from device paths in esp_do_dma() 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 ultimate aim is to for esp_do_dma() behaviour to be determined by the SCSI bus phase, in which case it is necessary to have separate to/from device paths. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-11-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 65 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 63c828c1b2..9893840255 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -678,14 +678,53 @@ static void esp_do_dma(ESPState *s) if (to_device) { if (s->dma_memory_read) { s->dma_memory_read(s->dma_opaque, s->async_buf, len); + + esp_set_tc(s, esp_get_tc(s) - len); + s->async_buf += len; + s->async_len -= len; + s->ti_size += len; + + if (s->async_len == 0) { + scsi_req_continue(s->current_req); + /* + * If there is still data to be read from the device then + * complete the DMA operation immediately. Otherwise defer + * until the scsi layer has completed. + */ + return; + } + + /* Partially filled a scsi buffer. Complete immediately. */ + esp_dma_done(s); + esp_lower_drq(s); } else { esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); - return; } } else { if (s->dma_memory_write) { s->dma_memory_write(s->dma_opaque, s->async_buf, len); + + esp_set_tc(s, esp_get_tc(s) - len); + s->async_buf += len; + s->async_len -= len; + s->ti_size -= len; + + if (s->async_len == 0) { + scsi_req_continue(s->current_req); + /* + * If there is still data to be read from the device then + * complete the DMA operation immediately. Otherwise defer + * until the scsi layer has completed. + */ + if (esp_get_tc(s) != 0 || s->ti_size == 0) { + return; + } + } + + /* Partially filled a scsi buffer. Complete immediately. */ + esp_dma_done(s); + esp_lower_drq(s); } else { /* Adjust TC for any leftover data in the FIFO */ if (!fifo8_is_empty(&s->fifo)) { @@ -713,32 +752,8 @@ static void esp_do_dma(ESPState *s) esp_set_tc(s, esp_get_tc(s) - len); esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); - return; } } - esp_set_tc(s, esp_get_tc(s) - len); - s->async_buf += len; - s->async_len -= len; - if (to_device) { - s->ti_size += len; - } else { - s->ti_size -= len; - } - if (s->async_len == 0) { - scsi_req_continue(s->current_req); - /* - * If there is still data to be read from the device then - * complete the DMA operation immediately. Otherwise defer - * until the scsi layer has completed. - */ - if (to_device || esp_get_tc(s) != 0 || s->ti_size == 0) { - return; - } - } - - /* Partially filled a scsi buffer. Complete immediately. */ - esp_dma_done(s); - esp_lower_drq(s); } static void esp_do_nodma(ESPState *s) From patchwork Tue Feb 13 19:39:35 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: 13555591 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 017C0C48260 for ; Tue, 13 Feb 2024 19:48:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyf4-0002wX-5e; Tue, 13 Feb 2024 14:41:46 -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 1rZyf1-0002w3-Ih for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:43 -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 1rZyf0-0006IE-7a for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:43 -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=CQ5UkPsbIeBr8TdR6L3O6LadqjAggrnKeQrTFsf0tRI=; b=wiwFUHptsy0+TxCVcTUcqjO2Og MQnXYzoO/Vqn84UfpSx4Lus8c8P4GWxbKRziFmjOuQcC1YMgZ3tompBin50gLlgsh77BgauFglvuV 1WrcxVkMA4TLwNWI8xhuPRZvVBDvjnWbML4y55ML8ft/6Tr5Gz7t7ydpWqu95lSKKWFtsep7m/QOo gwshx5m2g/rGds3a5D6nCq+3sL834YJbULLHZYzsAW/IcI/Ylz7A9DYBnT2Wn8a2c4c0wsIB2mARk rpahQzThUA4xDieec8rv/Ju9oSkLN5kH4xFJUagVCEi+6lVlUkzaXi0liFw7eMcdBZz1W4QLZukFL ANHs4bs1q4+DuIOfBMsJB6+N4+PFbJ5vVRQm9ZrSRr0XBFNAqg6z/ZdCrwIGJ2UmHCilOGSogYucA ekrYtNicDnI3NyHu0H0+WJWaY8mPKeyuGLG/RILaDhWeoBvrk22lSIuPIyEcqRTviz4BQ4Zq7taZe fMz+hYy91TIBIor9n4sgjnZ5uiG+cwCF4nJEP4gXVFPlhH3FjThzz74pVk1ewBIgLCMrnfDYbVkH3 7bmtR0CDF9jMpCfnBTvTvDgubwwt1GfkRcpav6lSSqv5jFJ48BbyPtI9k2/Ah0pYk5qX/TGGqSRuy tk7+XBQYCLw3ueJArHUyL2TxGIvXFd37/rOZ4xmg8=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyeH-0008m4-GH; Tue, 13 Feb 2024 19:41:01 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:35 +0000 Message-Id: <20240213194052.1162753-12-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 11/88] esp.c: remove unused case from esp_pdma_read() 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 do_cmd variable is only set for the MESSAGE OUT and COMMAND phases i.e. those which involve transfers from the host to the SCSI bus, and so the unused case can be removed. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-12-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 9893840255..6191c17f10 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -187,12 +187,7 @@ static uint8_t esp_pdma_read(ESPState *s) { uint8_t val; - if (s->do_cmd) { - val = esp_fifo_pop(&s->cmdfifo); - } else { - val = esp_fifo_pop(&s->fifo); - } - + val = esp_fifo_pop(&s->fifo); return val; } From patchwork Tue Feb 13 19:39:36 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: 13555556 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 0925AC48260 for ; Tue, 13 Feb 2024 19:42:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyfJ-00032v-OY; Tue, 13 Feb 2024 14:42:01 -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 1rZyfI-00032h-ER for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:00 -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 1rZyf4-0006IU-Az for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:00 -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=Je02mCt9XBjHhIXM7fupKVBJ602KX1m94ilxNmva87w=; b=pOuVa6oOtld+VfaUHapNCxb59z 2JQVw6NLMxvzM/j9zqsHcLGqNC1b6++Fb6PLSTMWm+tYWWnBHwkTlUgb8aUtc1KXLDmd/IC7pCJ0P 0DaIKLRjE7KAH7jPhry1qilDzmH5fPtt642IilANomknFk3y4eq9/yj2NVeZv1fuh5eIwe+trrqjW iivYJ3/WYZfKSt05vLQUP8ZRqykg3fdSRYUGFBZ7JOTo6F9fhM8fK21CN9ArOREgKgKM50T7ITJBp fFPpP/HRSqvMrzJqzWYmovv+im4tFg1fd+fMa20V9e/vcT9uH07BL2NiFSYl3s79cPOLy8vhgcPCV Dxd/W7sQV2trGsgacvgasRz3uNNdUtk6boGNQaIrZfuXcWYesDSRLYfL92PMeh5HC2627qEjcIgBY gZ3f701u89i7pzgDu94scvocp5z7AygVezstWI7xO56H3JOG/vR07SsVKJh5cWCiLJ1CQqiDHoI6A EgqHCczt2M4QYYaN0sLs8jOY01XQOchpowSJTNmvgmWi6ADZA649hfT3rtKsh7gHROyrXFiBKJ4Hk MPDzclocFN551/E4eWLfXwjTbKEuY7NQmG45ut/2f9B/rf3/+0fd4IyNSmJSzeNN3+gvr78dNGEjZ jny2oGichW4glAgFU9RpQGRb0SakWjYTdjrJelGhg=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyeL-0008m4-JM; Tue, 13 Feb 2024 19:41:05 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:36 +0000 Message-Id: <20240213194052.1162753-13-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 12/88] esp.c: don't accumulate directly into cmdfifo 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 accumulate in the real FIFO as done in real hardware, and then transfer to cmdfifo when we're ready to process the MESSAGE OUT and COMMAND phase data. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-13-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 49 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 6191c17f10..9e9bbe8431 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -199,11 +199,7 @@ static void esp_pdma_write(ESPState *s, uint8_t val) return; } - if (s->do_cmd) { - esp_fifo_push(&s->cmdfifo, val); - } else { - esp_fifo_push(&s->fifo, val); - } + esp_fifo_push(&s->fifo, val); dmalen--; esp_set_tc(s, dmalen); @@ -358,6 +354,14 @@ static void do_cmd(ESPState *s) static void satn_pdma_cb(ESPState *s) { + uint8_t buf[ESP_FIFO_SZ]; + int n; + + /* Copy FIFO into cmdfifo */ + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) { s->cmdfifo_cdb_offset = 1; s->do_cmd = 0; @@ -395,6 +399,14 @@ static void handle_satn(ESPState *s) static void s_without_satn_pdma_cb(ESPState *s) { + uint8_t buf[ESP_FIFO_SZ]; + int n; + + /* Copy FIFO into cmdfifo */ + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) { s->cmdfifo_cdb_offset = 0; s->do_cmd = 0; @@ -432,6 +444,14 @@ static void handle_s_without_atn(ESPState *s) static void satn_stop_pdma_cb(ESPState *s) { + uint8_t buf[ESP_FIFO_SZ]; + int n; + + /* Copy FIFO into cmdfifo */ + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) { trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); s->do_cmd = 1; @@ -523,10 +543,16 @@ static void esp_dma_done(ESPState *s) static void do_dma_pdma_cb(ESPState *s) { int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO); + uint8_t buf[ESP_CMDFIFO_SZ]; int len; uint32_t n; if (s->do_cmd) { + /* Copy FIFO into cmdfifo */ + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + /* Ensure we have received complete command after SATN and stop */ if (esp_get_tc(s) || fifo8_is_empty(&s->cmdfifo)) { return; @@ -754,10 +780,16 @@ static void esp_do_dma(ESPState *s) static void esp_do_nodma(ESPState *s) { int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO); + uint8_t buf[ESP_FIFO_SZ]; uint32_t cmdlen; - int len; + int len, n; if (s->do_cmd) { + /* Copy FIFO into cmdfifo */ + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + cmdlen = fifo8_num_used(&s->cmdfifo); trace_esp_handle_ti_cmd(cmdlen); s->ti_size = 0; @@ -1159,7 +1191,10 @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) break; case ESP_FIFO: if (s->do_cmd) { - esp_fifo_push(&s->cmdfifo, val); + if (!fifo8_is_full(&s->fifo)) { + esp_fifo_push(&s->fifo, val); + esp_fifo_push(&s->cmdfifo, fifo8_pop(&s->fifo)); + } /* * If any unexpected message out/command phase data is From patchwork Tue Feb 13 19:39:37 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: 13555575 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 53ABCC48260 for ; Tue, 13 Feb 2024 19:45:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyfG-00032f-HD; Tue, 13 Feb 2024 14:41:58 -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 1rZyfE-00032B-Au for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:56 -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 1rZyf9-0006K5-Bv for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:41:56 -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=EShdRQWC7vQ6K4PEVAzQ6/SigFV+JenqAVvUK74MbiI=; b=wo4mQMaNqJONY4tQwVvowgFKeF J4huo0NjdrXm10UNUeGw+kGRcG+jatsrJTrygpxiHeIZWQ9Ffk+as8OF2oxmR7jwPWZwozDuDQdZM 0uAW+2fb+B4yJD2c/XJ71DwkTd7dlm7A2W7P86y3rn4tyDZRSj6bQZk90b86HnFj9CD0TroLezd2K SMFuybHSGGJA278gtUFhU39MQZQz7A/gmhNwr9QDBu9gI4u0qhM9fNBSi0373oNibLadZZ2yGTF6l +xp53G0i0Nh5B4UiTLJ/3T9BjKQnuQUPoHY3aDQBsw3JZIu2tntRY7YdmlQbnc4BFIiTKUASislh1 02UQAo42/BGEOdn8fg3P05uRasxr1nj7w6a4Cn5WhDbwHNi5R3tLGugfcAyp8P+CfzD6kVHTtYIdM 7+y58WPuvvbi9dxv7zXDQPj/BUe8oIqAGEQy+uuZOvpSUuDoI4HXSFsGIggZ3wzeisWVZJdxFuHq6 gwLV4x9LQ21qRnMUp0/s8QzD0c4Ao31un4lyyqNrX3BdxE9Keg+k67uCgZZtCbzU+qTjDiBNwTPav 7JpAVoIB4aC8ny2PI3gH1jUsravWCukbQiqcjAcfc0J+GOjcuahI3Iwjq6Z6W862yNHPaWpLgQZv3 eV5hsWsSyAXjDK1sMYl6eZy5whPKswpi8c8imey7I=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyeP-0008m4-MV; Tue, 13 Feb 2024 19:41:09 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:37 +0000 Message-Id: <20240213194052.1162753-14-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 13/88] esp.c: decrement the TC during MESSAGE OUT and COMMAND phases 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 is to ensure that STAT_TC is triggered during the right parts of the transfer when it is controlled exclusively by the TC. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-14-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 9e9bbe8431..f08b816aba 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -259,6 +259,7 @@ static uint32_t get_cmd(ESPState *s, uint32_t maxlen) s->dma_memory_read(s->dma_opaque, buf, dmalen); dmalen = MIN(fifo8_num_free(&s->cmdfifo), dmalen); fifo8_push_all(&s->cmdfifo, buf, dmalen); + esp_set_tc(s, esp_get_tc(s) - dmalen); } else { return 0; } @@ -657,6 +658,7 @@ static void esp_do_dma(ESPState *s) len = MIN(len, fifo8_num_free(&s->cmdfifo)); s->dma_memory_read(s->dma_opaque, buf, len); fifo8_push_all(&s->cmdfifo, buf, len); + esp_set_tc(s, esp_get_tc(s) - len); } else { esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); From patchwork Tue Feb 13 19:39:38 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: 13555598 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 AA693C4829A for ; Tue, 13 Feb 2024 19:49:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyfM-00033K-Es; Tue, 13 Feb 2024 14:42:04 -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 1rZyfL-00033C-8w for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:03 -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 1rZyfJ-0006K7-Gk for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:03 -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=1XhA0oV5S1LQeoJiXw+URVI0N9FdYJbeufHJsP1rm8U=; b=AXisTelhoXFLKBBLDAM7uVd37A 5rmlSv8P1P/GN2x2xJR9zzWPPi6v7qsS+kQ7MWMXZRXah29w4ZllxyQ+c+697ybrobSVpOC4v/9Lk 9uCFSqm7rlxDi5IM1m59wv+9kh5HMk2WsPMHyHVPyndGlCONdkJvqFybvH+oc7FwFvBC9KIMJLxLA 8Yza7vPQrqsX6kdhB+e8rkj1vlMfce1MQ4ddQo9cccxkB8S30zHKRnvS3lW2GAWs6fY9zWehC4SHn I73N68UjdDaVk70FDembGsjjZ2UeKVPHMjdgly1KSA+XhpLk7MtvQQo1Ga68qaIawia3i9B6Oh6b8 Tye17c9/aPK20nLqfuhPkXf+Cr473S1L2WKC2LRF1VdNo1qe2Bbfk/SXolNOox5EyFWWiiz7gb+r/ OPWNqWrS2b1QHkukjjjnfe3SjjvCXO9XqCDapnjpo4y3NK8FIUVSOFBvB84E+P2aojs7G7lMSt85w tUKNefQfQpWYzOD3Jq2qN2WywuURYx/Vrv6HhG0MFSf70TqNko9b7MD3iNgJNGEdtlI9I3mhJqoAQ IZxJl9axUJmhuZv3BUTaFPsh6I0hFZqAALfkGrGdvSP0RC14oD5h3NNYb6/Z1i9vqZQRHhAZbhjXA V7pLKOuRH/uuqsEpwiLHvyA9qoXm9xj0ohP7lTIxw=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyeT-0008m4-Ph; Tue, 13 Feb 2024 19:41:10 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:38 +0000 Message-Id: <20240213194052.1162753-15-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 14/88] esp.c: introduce esp_set_phase() helper function 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 function is used to set the current SCSI bus phase in the ESP_RSTAT register without affecting any of flag bits. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-15-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 51 ++++++++++++++++++++++++++++++-------------- hw/scsi/trace-events | 1 + 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index f08b816aba..3fc7417d7c 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -183,6 +183,19 @@ 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_pdma_read(ESPState *s) { uint8_t val; @@ -316,9 +329,9 @@ static void do_command_phase(ESPState *s) * complete before raising the command completion interrupt */ s->data_in_ready = false; - s->rregs[ESP_RSTAT] |= STAT_DI; + esp_set_phase(s, STAT_DI); } else { - s->rregs[ESP_RSTAT] |= STAT_DO; + esp_set_phase(s, STAT_DO); s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; esp_raise_irq(s); esp_lower_drq(s); @@ -394,7 +407,7 @@ static void handle_satn(ESPState *s) s->do_cmd = 1; /* Target present, but no cmd yet - switch to command phase */ s->rregs[ESP_RSEQ] = SEQ_CD; - s->rregs[ESP_RSTAT] = STAT_CD; + esp_set_phase(s, STAT_CD); } } @@ -439,7 +452,7 @@ static void handle_s_without_atn(ESPState *s) s->do_cmd = 1; /* Target present, but no cmd yet - switch to command phase */ s->rregs[ESP_RSEQ] = SEQ_CD; - s->rregs[ESP_RSTAT] = STAT_CD; + esp_set_phase(s, STAT_CD); } } @@ -457,7 +470,8 @@ static void satn_stop_pdma_cb(ESPState *s) trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); s->do_cmd = 1; s->cmdfifo_cdb_offset = 1; - s->rregs[ESP_RSTAT] = STAT_TC | STAT_CD; + esp_set_phase(s, STAT_CD); + s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; s->rregs[ESP_RSEQ] = SEQ_CD; esp_raise_irq(s); @@ -481,7 +495,7 @@ static void handle_satn_stop(ESPState *s) trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); s->do_cmd = 1; s->cmdfifo_cdb_offset = 1; - s->rregs[ESP_RSTAT] = STAT_MO; + esp_set_phase(s, STAT_MO); s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; s->rregs[ESP_RSEQ] = SEQ_MO; esp_raise_irq(s); @@ -492,13 +506,14 @@ static void handle_satn_stop(ESPState *s) s->do_cmd = 1; /* Target present, switch to message out phase */ s->rregs[ESP_RSEQ] = SEQ_MO; - s->rregs[ESP_RSTAT] = STAT_MO; + esp_set_phase(s, STAT_MO); } } static void write_response_pdma_cb(ESPState *s) { - s->rregs[ESP_RSTAT] = STAT_TC | STAT_ST; + esp_set_phase(s, STAT_ST); + s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; s->rregs[ESP_RSEQ] = SEQ_CD; esp_raise_irq(s); @@ -516,7 +531,8 @@ static void write_response(ESPState *s) if (s->dma) { if (s->dma_memory_write) { s->dma_memory_write(s->dma_opaque, buf, 2); - s->rregs[ESP_RSTAT] = STAT_TC | STAT_ST; + esp_set_phase(s, STAT_ST); + s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; s->rregs[ESP_RSEQ] = SEQ_CD; } else { @@ -575,7 +591,8 @@ static void do_dma_pdma_cb(ESPState *s) * and then switch to command phase */ s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); - s->rregs[ESP_RSTAT] = STAT_TC | STAT_CD; + esp_set_phase(s, STAT_CD); + s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RSEQ] = SEQ_CD; s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); @@ -681,7 +698,8 @@ static void esp_do_dma(ESPState *s) * and then switch to command phase */ s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); - s->rregs[ESP_RSTAT] = STAT_TC | STAT_CD; + esp_set_phase(s, STAT_CD); + s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RSEQ] = SEQ_CD; s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); @@ -810,7 +828,8 @@ static void esp_do_nodma(ESPState *s) * and then switch to command phase */ s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); - s->rregs[ESP_RSTAT] = STAT_TC | STAT_CD; + esp_set_phase(s, STAT_CD); + s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RSEQ] = SEQ_CD; s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); @@ -904,8 +923,7 @@ void esp_command_complete(SCSIRequest *req, size_t resid) * transfers from the target the last byte is still in the FIFO */ if (s->ti_size == 0) { - s->rregs[ESP_RSTAT] &= ~7; - s->rregs[ESP_RSTAT] |= STAT_ST; + esp_set_phase(s, STAT_ST); esp_dma_done(s); esp_lower_drq(s); } @@ -1065,7 +1083,7 @@ static void esp_run_cmd(ESPState *s) trace_esp_mem_writeb_cmd_iccs(cmd); write_response(s); s->rregs[ESP_RINTR] |= INTR_FC; - s->rregs[ESP_RSTAT] |= STAT_MI; + esp_set_phase(s, STAT_MI); break; case CMD_MSGACC: trace_esp_mem_writeb_cmd_msgacc(cmd); @@ -1133,7 +1151,8 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr) * The last byte of a non-DMA transfer has been read out * of the FIFO so switch to status phase */ - s->rregs[ESP_RSTAT] = STAT_TC | STAT_ST; + esp_set_phase(s, STAT_ST); + s->rregs[ESP_RSTAT] |= STAT_TC; } } s->rregs[ESP_FIFO] = esp_fifo_pop(&s->fifo); diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events index bdd4e2c7c7..d72f741ed8 100644 --- a/hw/scsi/trace-events +++ b/hw/scsi/trace-events @@ -197,6 +197,7 @@ esp_mem_writeb_cmd_selatns(uint32_t val) "Select with ATN & stop (0x%2.2x)" esp_mem_writeb_cmd_ensel(uint32_t val) "Enable selection (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-pci.c esp_pci_error_invalid_dma_direction(void) "invalid DMA transfer direction" From patchwork Tue Feb 13 19:39:39 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: 13555585 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 A5678C48260 for ; Tue, 13 Feb 2024 19:46:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyfb-0003u6-9Q; Tue, 13 Feb 2024 14:42:20 -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 1rZyfU-0003PE-DZ for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:12 -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 1rZyfN-0006KW-EF for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42: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=6uG9Tx27iG+4/+h2LAjDcJhD3VB945hLmfnIevydm4A=; b=k4FJG7GJUS+IFXCUpZ4kx8x8km +4AKVcuRdmbR7pahbYjubLx1RF8mga9pTC9uX/7yAx9zY/fhO8sk6xe++5HepfxAK3xte/ULFxYJR kJNjCIPFfF3A7Aj6hBuKZKF6pmqD5nZYl1XNzDBaQEMTgZac+dClt4q/zdebv4NraVjShYANRADQn 7kPwMODIUqAMT0UbZkc3tDJjs5xocQBY0SprMFageu58rC9V3c8S/RR+NDzcp4kSHVMJ/c91bSNiv 4BO7uSJMUpSwp8FF6al3mQZQPdfuXW2v6+bhbcwap058qnMz8oFTv6vdtFfX7yAiuV1I9NY6+x0J7 6wqlkpj5Na9tarFp03NFi+NfqqZKcQsK5oKcb6zAjHiB21S+MzQThpL4Ec9+e3bsoFIQ+IXIerRoC FUtaX+Ofi10pQSYR5OsfLu3scaK2M1JlnLUtcpCxJbqjp+9/UCEi9x3wank7uCSXvqIfPhVn9WZmc yvtxxMBlNdcImbl+elqj50BtJIpJjqiE7BIYNo+YKsveYEa4nFUiCaSHjViOGdJtiHHVgcH1aZaj+ 0KrfKNXAz52pvgekl1/ne6npGrVLtcGee83pVxegmmYJ6irXjx3ulIXyWTIJ4q6wFnZ6KSKzPd7wG B7RNQky1fcicbl6W7NDOdex2sqHBY98Zt5qEr/+0U=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyeU-0008m4-QK; Tue, 13 Feb 2024 19:41:14 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:39 +0000 Message-Id: <20240213194052.1162753-16-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 15/88] esp.c: remove another set of manual STAT_TC updates 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 Following on from the recent changes to when the TC is updated, it is now possible to remove another set of manual STAT_TC updates so that its state is now managed within esp_set_tc(). Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-16-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 3fc7417d7c..6fd5c8767a 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -513,7 +513,6 @@ static void handle_satn_stop(ESPState *s) static void write_response_pdma_cb(ESPState *s) { esp_set_phase(s, STAT_ST); - s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; s->rregs[ESP_RSEQ] = SEQ_CD; esp_raise_irq(s); @@ -532,7 +531,6 @@ static void write_response(ESPState *s) if (s->dma_memory_write) { s->dma_memory_write(s->dma_opaque, buf, 2); esp_set_phase(s, STAT_ST); - s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; s->rregs[ESP_RSEQ] = SEQ_CD; } else { @@ -550,10 +548,8 @@ static void write_response(ESPState *s) static void esp_dma_done(ESPState *s) { - s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RINTR] |= INTR_BS; s->rregs[ESP_RFLAGS] = 0; - esp_set_tc(s, 0); esp_raise_irq(s); } @@ -592,7 +588,6 @@ static void do_dma_pdma_cb(ESPState *s) */ s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); esp_set_phase(s, STAT_CD); - s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RSEQ] = SEQ_CD; s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); @@ -699,7 +694,6 @@ static void esp_do_dma(ESPState *s) */ s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); esp_set_phase(s, STAT_CD); - s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RSEQ] = SEQ_CD; s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); @@ -829,7 +823,6 @@ static void esp_do_nodma(ESPState *s) */ s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); esp_set_phase(s, STAT_CD); - s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RSEQ] = SEQ_CD; s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); @@ -952,7 +945,6 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) * completion interrupt */ s->data_in_ready = true; - s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); } @@ -997,7 +989,6 @@ static void handle_ti(ESPState *s) if (s->dma) { dmalen = esp_get_tc(s); trace_esp_handle_ti(dmalen); - s->rregs[ESP_RSTAT] &= ~STAT_TC; esp_do_dma(s); } else { trace_esp_handle_ti(s->ti_size); @@ -1152,7 +1143,6 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr) * of the FIFO so switch to status phase */ esp_set_phase(s, STAT_ST); - s->rregs[ESP_RSTAT] |= STAT_TC; } } s->rregs[ESP_FIFO] = esp_fifo_pop(&s->fifo); From patchwork Tue Feb 13 19:39:40 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: 13555563 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 465EEC48260 for ; Tue, 13 Feb 2024 19:43:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyfY-0003V7-OX; Tue, 13 Feb 2024 14:42: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 1rZyfT-0003KR-SJ for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42: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 1rZyfR-0006Kq-38 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42: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=txS0EkWpqSoeHABEVeI8A4WFbirOC3ILO1uIwpoPXpY=; b=OJF/1Qb7W5/wfqDpp5Kh+7JZt4 qkRvskThNGwGkTmu5szXNjFpSBAb585HTbiVsz/uHssPBDzh5deHPBhmiMSBu1g+W1NArec++7J5S TfERCPquBBGW9YPTYF5URfJ5x7SOeBIHaRCl9WUYEAhYzg+VOJ5sRqAxZN1tXy2ToWGJ/5RpL83Fc 8uC9gti1JMWZWmXTqvApeZjigpkPDqIS/dUm+gxZTfLJBoT4RbuSvJUjQHDoSa8QhBojKwDyW7PqW B+RQwc9UiBPYJoCJULfaKWhLlAUOzC9elWpRLLVr8RzZlRxWyvuUnMvOe0rsa0KMB7xNGsi0PGSxz 0T58Rif47ap3VJZpF1ULwnaNvCQ3KC26o7nt51s9tQ8SJYBhwbju6K00ELsH5izH55OTO19CO2csz uLVAJaJ+HkoK5RaTaSp8hX+lT4WIOl6O72+OIo4gDumBR46SRi6agwyT2dZGfvLAqppRKeTVKWkQz 3o4Eoz080/UeeyTv9kCJLKnSR9V3LDdqcK/xRW95607yW1094qlwNfxJg1N/eBIKYWVVeXxxY1ysJ XCGeNSx64uXVTRU2LiMPXTqmTJShZzGKjWvUC6vh/ZDQI4h7E2b4NFzZuA9MsP9tNQ78bnyqZAffY 8UPQC5lG7Cn7Phhxco9zu5AWSgTGccVrE/93nJ3qA=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyeY-0008m4-TT; Tue, 13 Feb 2024 19:41:18 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:40 +0000 Message-Id: <20240213194052.1162753-17-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 16/88] esp.c: remove MacOS TI workaround that pads FIFO transfers to ESP_FIFO_SZ X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This workaround is no longer required with the current code and so can be removed. [Note: whilst MacOS itself can boot correctly, removing this hack prevents a bootable EMILE CDROM from working. This is caused by a separate bug which will be fixed by a subsequent patch] Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-17-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 6fd5c8767a..f41b2421f9 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -772,18 +772,6 @@ static void esp_do_dma(ESPState *s) s->async_buf += len; s->async_len -= len; s->ti_size -= len; - - /* - * MacOS toolbox uses a TI length of 16 bytes for all commands, so - * commands shorter than this must be padded accordingly - */ - if (len < esp_get_tc(s) && esp_get_tc(s) <= ESP_FIFO_SZ) { - while (fifo8_num_used(&s->fifo) < ESP_FIFO_SZ) { - esp_fifo_push(&s->fifo, 0); - len++; - } - } - esp_set_tc(s, esp_get_tc(s) - len); esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); From patchwork Tue Feb 13 19:39:41 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: 13555586 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 A3394C48260 for ; Tue, 13 Feb 2024 19:46:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyfp-0004nb-2H; Tue, 13 Feb 2024 14:42:33 -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 1rZyfY-0003lo-Vb for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:18 -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 1rZyfU-0006LF-N9 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:13 -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=SiPqZDoxN/9au4TtZYiE2hyFQvJj4ZHJhzc5lZsATWs=; b=eXPXS7sQMPFZJGLKn4eThDtCTN KKVkH5rCv9OHV9X5TTMeTwLFn4C03QI9yAlEPiCi9eKF9oUZZt1dv4/YdKGEGwoQBFAkWJ/FN4tWA ElPmHJv8bKiLsCBU2QVIPDl8wE+VZ8uKeb60NkeCNhGLB4297LwRfMlcDRc/z2jQ81bBfcacqgTXG N9Jy0Gf7+eO/Ux9jwb3T5JpaAPq8vPu8qJgVZWafNbwiAAw6jIIW8xa5vNu1Rb6dyTd2fQNpXJh4G RQqEFA8DBn4jgml6BKa/ZUC9bfn406cpwNCIjfxZg54Asw9YB4vd2rpev+6Ge4/SZNS2LR9I2pAZ7 70eBnp7Wl1QnsZZRIZKLsNvEweBynTyaJK5TzEoM+ioYuMxuXvJBLFGVsJaM9C1DZe1Lo3cTs7Sgg 9QVQ3s5JhZU3r5O0ScHFsZKq3NPU/OJprDXTjwnOVoI4schpj1Ykn3gGTQa22625D6Z8YmVSKQoxv oohC6+GPCXCpw5XL6ThWdi95FWW+njRNV4grHYCfPB/tr4n6E7T++8r8eQK64k+M0ueeBk3PNQzfM OFFzMdR73RAyHi5kLRYhD0YznxXVClS0JBppxSQKoBhLVfKeDIV3mQQ3VNdV/HA1jfOKZ2V2LbBNs 0y97J3AhMqnHvt57LpJM0hbwk4LyCYGf/z3wELZqM=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyec-0008m4-G3; Tue, 13 Feb 2024 19:41:21 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:41 +0000 Message-Id: <20240213194052.1162753-18-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 17/88] esp.c: don't reset the TC and ESP_RSEQ state when executing a SCSI command 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 is no need to manually reset these values as the ESP emulation now correctly handles them within its existing logic. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-18-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index f41b2421f9..a4a1f41a40 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -319,10 +319,7 @@ static void do_command_phase(ESPState *s) s->ti_size = datalen; fifo8_reset(&s->cmdfifo); if (datalen != 0) { - s->rregs[ESP_RSTAT] = STAT_TC; - s->rregs[ESP_RSEQ] = SEQ_CD; s->ti_cmd = 0; - esp_set_tc(s, 0); if (datalen > 0) { /* * Switch to DATA IN phase but wait until initial data xfer is From patchwork Tue Feb 13 19:39:42 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: 13555565 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 6892BC4829A for ; Tue, 13 Feb 2024 19:43:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyfm-0004TW-NO; Tue, 13 Feb 2024 14:42:30 -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 1rZyfa-0003pT-Tg for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:18 -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 1rZyfY-0006Ln-D4 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42: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=6Lwfrh1EvAiWa40uM3VENBzmpRMnletbaa8WGmra4kE=; b=VA0OfjvZ+i+opJQTovzFSdnGmk SBzcYpCDPDvfAkyJOlh9u8C0+5ejIaPrcS/URc4LGu8NFxRD4IQHhbLGentQ9pj6k2FfQ4SfoKXMQ 5ZwgoQEwCiNegtITfnCTbQNKO23Az80al/7+3i2zT3kZDz+dkMe7HDv0wkCJQ2wm0AyyPt02u5Chp H9V0ROjBiqx8V9sP5lwVx2FxPI5lqSS2E4nAC+Zjyb2sBtnYoKM8Es6mwe39+3Um1dW37xJ3J/c11 0q9tWsXmHZ4gry9CDt9ExTdCVsF6XHNaLm5Pb5S5yE95wVpTXcGOCYM0RkAxcNzrkbLmgNTOiZ6s5 S+OsU1ialXqXyXDY5tjdV4FuzDkbAJYUHpn5l67pK6wKk5t8RaMR6Fabz850iDFirXKAqfE1+c22I ydw+e4vxc5cDiJCvcvCrPQGW+UnTrdGeNmxuZm16BxT/IxJlO7igxbKIXY0enb/CcWjJZ8elWiOqQ XcLNkcR1snRaDTKX7HfGWn/2/W4GvQVxIa+8sHCbQFK7GSquZsrX31FR/9iVjiVvhwLJwn0bYJNw+ CUsHxGrbKTn/eFVO7CYq7UQejpNEUzUi/rjjlPUjxDE1oG5FCoimvijRE7j2uRIcCbZHGjmNXXD6i 14/yQsyzuyFfqkpJVSLVzES1/IvGHaVy0dSMF+pOg=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyeg-0008m4-2e; Tue, 13 Feb 2024 19:41:25 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:42 +0000 Message-Id: <20240213194052.1162753-19-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 18/88] esp.c: don't clear RFLAGS register when DMA is complete 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 internal state of the ESP sequencer is not affected when raising an interrupt to indicate the end of a DMA transfer. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-19-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index a4a1f41a40..5b9c3f1e5e 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -546,7 +546,6 @@ static void write_response(ESPState *s) static void esp_dma_done(ESPState *s) { s->rregs[ESP_RINTR] |= INTR_BS; - s->rregs[ESP_RFLAGS] = 0; esp_raise_irq(s); } From patchwork Tue Feb 13 19:39:43 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: 13555592 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 96307C4829A for ; Tue, 13 Feb 2024 19:48:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyfn-0004et-NO; Tue, 13 Feb 2024 14:42:31 -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 1rZyfe-00049W-Oq for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:22 -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 1rZyfc-0006MP-AB for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:21 -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=taIgXtH5PF98j3TWyQtb+SKAB0L35TLaLRp9AOCoESk=; b=WHTNtzyo2hQpxczWDHlPjME1Ks JD7nQ9ZWVh98uPvA2qbkTgpT3s2Z5xe9F9pDfYupPCNTZvA/Pfact8lAn0D6FS/bx21JmAScY/v8g BtGX4CC6XZkwl4mzd8Gbbf4B4KnK3vbGhLgNJiX2Et9rAXL2UhgAfvhFXD3Bo8v5/uOCBrnqL8FWZ xEY5r3Ldyg1a5tC8HRjimM7/D6uv/bH/l1LaoNwhHzIipLSaaHzPb7+ESRDcbC60J6UCWmYmxvLxv 8mLqtPcU7DcB6aFwHjGY+BKfs68COtSlTwiECe3InL9E+eHHEgqBwHMru0DiBziKkTNKo/FO0FEW8 sfFg5k1LlnsY6ElEM/+E5StOZSEvFikwgRf0BGISnTPvinJfljd00MBe8nE4TI4aaDzvuebww2C36 MWfRxlHcMoh+ay0ZSo88G53ULZJH7qQ/neyDO6lJNtqDYFHiE6MTtpyWKwRwq1SCID1gf5RsXDDRY /2XVvk75WNW9MHOp1zIcDAAG230U7X0cLRkA+hkgq75W9Y7Y+wHTmMZ6pabcD5KmB50B8o9BdSnwj RMIz/r6E/78gfrqBpIz31mc+ykh5YDZMnn/U+JJLz2mLIEtJtu1tFUSyrk4CryRc3txWlQMY5yVxs lwIq6bXCbid6hpbEdfFc0laKt1kapHU6lkee/cOrU=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyej-0008m4-LT; Tue, 13 Feb 2024 19:41:29 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:43 +0000 Message-Id: <20240213194052.1162753-20-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 19/88] esp.c: remove zero transfer size check from esp_do_dma() 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 TI end of transfer interrupt only occurs when the TC reaches zero and is not related to the SCSI layer transfer. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-20-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 5b9c3f1e5e..dc515e6435 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -748,7 +748,7 @@ static void esp_do_dma(ESPState *s) * complete the DMA operation immediately. Otherwise defer * until the scsi layer has completed. */ - if (esp_get_tc(s) != 0 || s->ti_size == 0) { + if (esp_get_tc(s) != 0) { return; } } From patchwork Tue Feb 13 19:39:44 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: 13555584 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 9D22AC4829F for ; Tue, 13 Feb 2024 19:46:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyfp-0004uh-S4; Tue, 13 Feb 2024 14:42:33 -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 1rZyfn-0004Zt-4y for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:31 -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 1rZyfi-0006N0-MZ for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:29 -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=BCkhcY2O5ooyqkqZePv9Rcdiugc/548cCTEiXFiu3jE=; b=DHMbTuIQV5m50hHaxljZ7FeTRu TnpnP11nNHqv34VD6fluMkTA7KcS/LGWbsIRMceUi5bZP+qh2HAtqTKrQmN9QtoThKRJrK+PexEOG e2p9Rsf3KkJlPpL0KLoJJQVax3W6SZMTA16U0RwkZVyWkLzLmHQG72jWoOAVCF78s79gssFvLODSL i2j0Dl2Murt9hLuKQYGwgNSPWb/ym9V5HrhUMu3Zj8evg2qop85EqNo6fbvgazJZuo3UI7rrubmWg oOD1Cl/8raBZe4Ly2sDxrwPYh+k7t52oqTcIfNKV3JL9jvF1RvaU26tj7CVJsH2m7RBTDWf31lwpy cb66T4IL7THRXiPEE8DljunsNrOF+rNqoobsmbAx/rcozNKJugwU1pbJYL82gz+4+jDXcWjd0MXZ8 zYdMRfs1aA5b0AP6kTPLAzXOHjh2lumwiliyM72+73FjFSNq/WL92+az7ZTZIy7AhIChh8zdZZfon vdxXkRGnlYZuGwQ8NUaRpJeFZYJyrJ8aSEC10Sr91bNzFED1xpFvY0xdnp91aWeYQHPqQ8PyZKmrt 9Y6PXeK5UUnm+pkg/zL7teHEZ56Fcy7QWC/GI6IVPnkTo4l10V/Kznx/QZ6cXK/YJFZcXCiSW3Dyu j7X1Hi+SJTBVL5Q0wh3+9nuNb691aimhrSRglp3QM=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyen-0008m4-OZ; Tue, 13 Feb 2024 19:41:33 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:44 +0000 Message-Id: <20240213194052.1162753-21-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 20/88] esp.c: update condition for esp_dma_done() in esp_do_dma() from device path 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 No change to the condition itself, other than to clarify that esp_dma_done() must be called when TC is zero. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-21-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index dc515e6435..96723efcf3 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -743,19 +743,13 @@ static void esp_do_dma(ESPState *s) if (s->async_len == 0) { scsi_req_continue(s->current_req); - /* - * If there is still data to be read from the device then - * complete the DMA operation immediately. Otherwise defer - * until the scsi layer has completed. - */ - if (esp_get_tc(s) != 0) { - return; - } } - /* Partially filled a scsi buffer. Complete immediately. */ - esp_dma_done(s); - esp_lower_drq(s); + if (esp_get_tc(s) == 0) { + /* Partially filled a scsi buffer. Complete immediately. */ + esp_dma_done(s); + esp_lower_drq(s); + } } else { /* Adjust TC for any leftover data in the FIFO */ if (!fifo8_is_empty(&s->fifo)) { From patchwork Tue Feb 13 19:39:45 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: 13555595 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 61F49C4829A for ; Tue, 13 Feb 2024 19:49:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyfr-000553-BW; Tue, 13 Feb 2024 14:42:35 -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 1rZyfn-0004a7-72 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:31 -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 1rZyfk-0006NT-JF for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:30 -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=+iBKlrCd0SeFLixRh0a+X917yw2Et/Lod3SuX2H3jdo=; b=gOr/kM1c+FAdIYf5G2SYvCylP7 b4LoajafxtSZwSUhM3zIFkjsiR5SI2iX5x+a6xWOxd/Ol155NzIP6kXJeFWeMpyWIFyq2Y8aOjWPk WUjTta2+uYbXfq/LWwvlXiclJ8V307szNaNnXY8yXD+VLjVjOK1KML+5jsGp+oAz7OCRDb5BuBEkx kkWsLXVDrCVpMH5YezAnlulXi0Dcg59pzUADxRX3nAZ2na5Y+5ARGf8odoQO5x2pprDLRC06B9b2K muA8TqrNogqWgWiLtaosM1kgxLt/Ht/N103dOos8ANl0qX9QMx9zeQ/OvfBkkmP5NargHexae7Ypg 1srV6LI+j09VHzOZ0+PhGYf4DmG7WDpI8gVAM7NWfdrbU/RkDLut82k+w16JCn8/davFAPQFntnlW J647n3f6oAvQn/BKWzV98oiOFddLiqUIGDmvyWdPX4F1cQJtlFZDSQKsxDKJ3UO8VV5kyjJUb3vzZ 18GCbo0QOvCATwYjk25PTaYHPn2lIOHaQP36wYYoRcnsKfld3f2yU1IfrJo9zQL3djc3Vfb9VmEn1 O0hCfshL8e9B4aBnVPebwkfuDYTnSMk3uBiy+qvpLGjO9875a4T59QMgSwgvm1UEZzcv3/xQRU0Td k8Rsmh9IiEavZHse5x5fJokYo6myoItK5lZzEOzEY=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyer-0008m4-B2; Tue, 13 Feb 2024 19:41:36 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:45 +0000 Message-Id: <20240213194052.1162753-22-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 21/88] esp.c: update condition for esp_dma_done() in esp_do_dma() to device path 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 Ensure that esp_dma_done() is only called when TC is zero, which is currently always the case for DMA transfers. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-22-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 96723efcf3..06be9f2e74 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -725,9 +725,11 @@ static void esp_do_dma(ESPState *s) return; } - /* Partially filled a scsi buffer. Complete immediately. */ - esp_dma_done(s); - esp_lower_drq(s); + if (esp_get_tc(s) == 0) { + /* Partially filled a scsi buffer. Complete immediately. */ + esp_dma_done(s); + esp_lower_drq(s); + } } else { esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); From patchwork Tue Feb 13 19:39:46 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: 13555582 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 14DE4C4829A for ; Tue, 13 Feb 2024 19:46:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyfs-00058C-8t; Tue, 13 Feb 2024 14:42:36 -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 1rZyfp-0004wS-Vt for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:34 -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 1rZyfo-0006Nx-Fj for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:33 -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=dF+0iXt3A2oU6ZpqfQ69+kz5PzEX70MTcPwj4fQaWo0=; b=aL52GBRBwrXOfwjkFzZMOOmmmX wugRlMJYY7/j5/Xo+YaRnE0QRCtJD0bNLXlvgglAT3QPzLspjXGYyoWLde82sMNNmYlYckdNGJd9z BZke1fuuj4YR7lsNC4TOGMn4PtxqwFrYX1PLSPa48fus7zfR1g9pnD40bBNQOgTTfoKVdqbkePl6j Si4jmKVx3PQWJ+L6tpSaqPLA8TqaNpgcQn2ZslHlHm6CJRO++whzBasDrzXERq9AQ5KaJqc7llkFp xAJ9Xb4j1lMTE2CY0/PJ080xx+J1t+saFqnzd+bO5rEQH3wy3EJJS8nkdPMnkff1WpieMpFBeMdpb MKfI5HkQpVMw3Lr9jUXRicfmYErCpQ8+WKu2/YFAPQUrmiZHtfxMvSHqNNkNFdgt+EjCH8xXnCxlD ag2A2XGYrnqF9MaRXyP2HZi3MmqVRsI61JSrmnM8v3oT/Qv+DS9KyySyaCRAbJK+VH9jHdVKH0pA0 r/Zb8ICufNt/zw0Ay3nzv4l9owsJWRbhpXZGDGt7ePYumK8bOHG1eJD3kqXZ3IcAHWuASgdozgiQP ykDb4WIKtohsiFEqdo7q7q2mL63GIaKyIyjrP+uER8OeUKrm+E2UDikmb1TL66A5xKu2d42eRiSfr q3UkWz0Mg1egOay67EYitoSD9435uBgSDdjESJ9BU=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyeu-0008m4-Tz; Tue, 13 Feb 2024 19:41:41 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:46 +0000 Message-Id: <20240213194052.1162753-23-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 22/88] esp.c: ensure that the PDMA callback is called for every device read 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 Rather than wait for the FIFO to fill up before calling the PDMA callback, push that logic directly into the from_device logic in do_dma_pdma_cb(). Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-23-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 06be9f2e74..d80a38daa0 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -625,14 +625,14 @@ static void do_dma_pdma_cb(ESPState *s) return; } else { - if (s->async_len == 0) { + if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { /* Defer until the scsi layer has completed */ scsi_req_continue(s->current_req); s->data_in_ready = false; return; } - if (esp_get_tc(s) == 0) { + if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { esp_lower_drq(s); esp_dma_done(s); } @@ -1419,9 +1419,7 @@ static uint64_t sysbus_esp_pdma_read(void *opaque, hwaddr addr, val = (val << 8) | esp_pdma_read(s); break; } - if (fifo8_num_used(&s->fifo) < 2) { - esp_pdma_cb(s); - } + esp_pdma_cb(s); return val; } From patchwork Tue Feb 13 19:39:47 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: 13555578 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 744F8C4829A for ; Tue, 13 Feb 2024 19:45:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyft-0005Em-33; Tue, 13 Feb 2024 14:42:37 -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 1rZyfr-000550-6q for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:35 -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 1rZyfp-0006OA-OZ for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:34 -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=1nMvqXh1NHBqZnJ3Ay1RbxNHeCYbCSC3uTLrwTaNqtA=; b=0KieOt/Ejmzx160tJ9JFO5wMX4 qXlvllAgWj+FeHO/6vWzhTCKF+dO7f6N1yeA3VKK6mpJAS8IeHAakpZmU39VPN9Pg3VuZbSLp/RcF AHL26wkUIsjE2y3S+pzZEq4k6xUaM3/habXgkKw7XM7JjqvoCchgGXPmjbugE90QjycQXA4S6PsdJ Hoxo4Hmtum/R0/Zv63Icf8qlQ4+sBliZFn+qK+oCPGOlFiwMxBb0mNJ8ItJOYSkdcuIQj/CqUNt9J KBo6gxUf2/yP6amRU/HxpdMC7pN3rpElQlyIlRezkfInKVUsi6kAAa85dqXblUJxIXt7qtoMHgWeC RLr6OjIN3vV4JgOsD9VPhTf7xzKVi6WFdJv6le1BOwS2UcBTqBDo+7tyyfXk7R99++q/ipxxzC6Mq wQFo8OduIWLQkZgm/AfIHTLovJSrme3bskYhKTdqiN7vgSbxD5gRlyoendxKObYe/Qi43qNtZTs83 GRk4NbxOObEBuDhuzZKcz355u0kGDuGk2ZQQOrMPQ1ASAbQ8FyJZgn/clZSYoGkfiviS+PMAgmCLa 8ve5PuEcJXFcmHgM+CGUNit2BP60eAALt3RCrJen3EZ4rtNq9fRqcSsZjKtpUjhCZL7c+3uD2wXjt nuOeaGdO9g2l3LRmUsiJxOpDrCk+Icc6pJzgcu4PQ=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyez-0008m4-Dy; Tue, 13 Feb 2024 19:41:43 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:47 +0000 Message-Id: <20240213194052.1162753-24-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 23/88] esp.c: don't immediately raise INTR_BS if SCSI data needed in esp_do_dma() 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 In the case when more data is requested from the SCSI layer during a DMA data transfer from a device, don't immediately fall through to the TC check logic. Otherwise when TC is zero INTR_BS will be raised immediately rather than when the next set of SCSI data is ready. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-24-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index d80a38daa0..1f9902aec0 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -745,6 +745,7 @@ static void esp_do_dma(ESPState *s) if (s->async_len == 0) { scsi_req_continue(s->current_req); + return; } if (esp_get_tc(s) == 0) { From patchwork Tue Feb 13 19:39:48 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: 13555590 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 2513CC4829A for ; Tue, 13 Feb 2024 19:48:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyg4-0006o4-Po; Tue, 13 Feb 2024 14:42:48 -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 1rZyg1-0006FR-Mu for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:46 -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 1rZyfu-0006OK-9A for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:45 -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=TXYSIPnBdGCc0Di0xXyXoy0f7ULVQNWNqIqFCCGNsSw=; b=UOoTDSJANt5OBXja4QOXxXN/ot VaA6O1Cf+0QZ5RsUh3gTgRJrRebROsmvp6okH9rA/QJ1sh3qBoB975YqkQBP7d4RGBXT1fkzwh3fo tmU2iqJYAieLhTZWECSBTWjZPhNJnDnKc12Ns1opj8TIQra8HTvxHFIIioPo4iGH3BPhtd4dczT4m 4eotXN1zOS2hELAkmae0nhqRIOKjZN7vXFwP4Dzmhri08dkPfxzub3rrtGAarwV63DcOsQrv9x1aV 18dxEDrp3SjCHy3h4IVJLYypbbswibHAIpwuRvnoM/fJS/B3kHxLDkaL1AUpFpqkZ1wIUzTlyJwIT lKNB2z7PHFiQ4/Qf980uebpcwk+JdG41RkWRU5BDxdoNLrs6F4bCer8kLcmWvElVJw64A8y5J9GdF V4yAXwWJvbcLyqnpChDMM7FcyOHvAXmIc48e4EscJljiYlps1B2Or+HKATzrha+JPBWd2JmAyprOQ ZTtjjgiid+vJD30nHbsusUGx4tnHnjzCKXrIxo36U0tkTiaPlul8rGVEqla74fU8pcqwuc+NIYzYR FklTb3lDH30HzxNCbUQYmkQOHQNG2k/F1jrYtcddw4FhjSbEiGk6YvhB9nMnOD34U/dr27A9Au/7m nwZSKneV45NIZYdThTAzgM77VqdpDlZ2pGSW9FuDQ=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyf1-0008m4-2L; Tue, 13 Feb 2024 19:41:47 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:48 +0000 Message-Id: <20240213194052.1162753-25-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 24/88] esp.c: remove TC adjustment in esp_do_dma() from device path 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 the TC is updated for each PDMA access (rather than once the FIFO is full) there is no need to adjust the TC at start of each DMA transfer if the FIFO is not empty. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-25-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 1f9902aec0..ec82097a01 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -754,11 +754,6 @@ static void esp_do_dma(ESPState *s) esp_lower_drq(s); } } else { - /* Adjust TC for any leftover data in the FIFO */ - if (!fifo8_is_empty(&s->fifo)) { - esp_set_tc(s, esp_get_tc(s) - fifo8_num_used(&s->fifo)); - } - /* Copy device data to FIFO */ len = MIN(len, fifo8_num_free(&s->fifo)); fifo8_push_all(&s->fifo, s->async_buf, len); From patchwork Tue Feb 13 19:39:49 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: 13555561 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 BC18CC48260 for ; Tue, 13 Feb 2024 19:42:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyfz-0005vY-DJ; Tue, 13 Feb 2024 14:42:43 -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 1rZyfv-0005Ws-Ns for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42: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 1rZyfu-0006OM-9I for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:39 -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=7PJF5PajYxkwWq+WBczJf1hF4O+SwUXBWFXRG3xfWu8=; b=PJE/XEiwijUcPB74TVyWd5Dk/j XolD3hOsSf1+Fz2bDkOKMB61+58tl6WKIhVdNAZ6jqczDK0FpCkP7W+Y8jfcunRcY2KAKNQ2X/qqP rjEJ3juSPmVTWR49IxVhSbJnnRJqxYkcw1eVr6cWsfW831tl2rlthzCDj3Lscvqn4/LERQLcvXu03 TptiAQUpTB896xSdiwRFlIlcrjsTZsXW2HI2Sqnv/gy9eakNDsgGZ8Gqn9O7OgVM9+i1AvyOcaWUt nCJ834GoeqiVQqVYo30kJj7b/+4VmXygkrHdb7VTR+FqjjMrJh8533illXUP1GvLOzRvHtwb2ik9e L/iIMvgsTbN1RHA6Ee8ZBmBPlMOepUOb/Jml/bzCeTfTQPfG+3nh4KeF/rGNzbOX4eqMiia+4YM1j ZG1PefilwZ6VQ60jd7i3SS0TONtvdhih/TgEzRWFk+3GJ0gRJW4Lx2OjZ3EHZpUldXp4MBn7BjNDn en6Jwoc04hbnraj6EBnlsMM2wb9DYnOrzpx33QsbGIaC1u3TQHYZSR7EMKTsdEBetyGm2B0gggZOQ fkGxoWdkKNgRusbjF6VZ8bwZY67IG+HdqoifO4dxhZvSDauYhv0vTd77SgVWrt/WQsFbkiNaQIdE7 IOK5FkYGD2t1qHBKH9u8+0hgdw1juBfa9oVHcZuxE=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyf5-0008m4-5V; Tue, 13 Feb 2024 19:41:47 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:49 +0000 Message-Id: <20240213194052.1162753-26-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 25/88] esp.c: remove unaligned adjustment in do_dma_pdma_cb() to device path 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 With the latest changes this condition cannot occur anymore and so the logic can be completely removed. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-26-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index ec82097a01..3db90c9ab7 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -604,15 +604,6 @@ static void do_dma_pdma_cb(ESPState *s) s->async_len -= n; s->ti_size += n; - if (n < len) { - /* Unaligned accesses can cause FIFO wraparound */ - len = len - n; - n = esp_fifo_pop_buf(&s->fifo, s->async_buf, len); - s->async_buf += n; - s->async_len -= n; - s->ti_size += n; - } - if (s->async_len == 0) { scsi_req_continue(s->current_req); return; From patchwork Tue Feb 13 19:39:50 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: 13555564 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 BB1A5C48260 for ; Tue, 13 Feb 2024 19:43:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyg2-0006HJ-SI; Tue, 13 Feb 2024 14:42:46 -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 1rZyfz-0005xI-Sy for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:43 -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 1rZyfy-0006Om-7G for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:43 -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=wBIBZWuMiDoOYKRhjfAiD1yeByPTZKfzMJ5uBORyLnw=; b=nM1NfNAi351jd1iv+pSUaxIuv5 lMAFvmHPHYd3tqlAU5mauh4ootjGTs1OBeVg+za9tYl0QJ1ii/IF8e0hk/aBmwUiEQUKygxgFylXz jwEJGM6DaTPGMd3EQDSS/ZoQp1+hVwXp0CTevkL/Blrb7RwshVq5+uZ4vn5MTNBSPEPGz6nLFf85v whwI0o7yip7Cnbqcdybp29VPPPcsg+l3mX+yV3vLB3G3wz7ul76ivJJDyUaDk9jFAzbCH4BUtKPFY BF4NHk8DccQx76VN6kVzF8tWsyybY8rfTisx53fusxYD1fn64VOSM4qz2hviS3TMWovtMbh/mLsxB Raby29bOm9Msj0u4l+OSXPVYIYlJxEaub4/jk/kBjHIiPdPafJKxq0qOGEC2eG4RyfGQUdjGzeFFj oI+F/XJtJwrP+oAF7pAqk9bA3CK18QFXmuhImA7wnoHbkxuUEfzCJyxgNuSRtaB2Rane+PHouN4n/ 7rmI18zMoZ8UDsrb9NRhltHekG9DMBda+qpOhGOiQKUlDT5Dy+p8mqXOEH9rkhj8jm3+bbtPUgTIB Ms2A7QfeWGgDTZVcOCOHun05Cm83wBCBdzboqHE/ICknoLB7hh55d74XM1CqJ2eZQkKn4aSITV4V0 lvNQ+DAVlbqqd91PRbETrB1J0Mo9iesenbHm8ElC8=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyf5-0008m4-G1; Tue, 13 Feb 2024 19:41:51 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:50 +0000 Message-Id: <20240213194052.1162753-27-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 26/88] esp.c: remove unneeded if() check 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 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 following ti_cmd checks ensure that only DMA and non-DMA TI commmands will can call into the esp_do_dma() and esp_do_nodma() callbacks. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-27-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 3db90c9ab7..96123c5f7d 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -916,16 +916,13 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) esp_raise_irq(s); } - if (s->ti_cmd == 0) { - /* - * Always perform the initial transfer upon reception of the next TI - * command to ensure the DMA/non-DMA status of the command is correct. - * It is not possible to use s->dma directly in the section below as - * some OSs send non-DMA NOP commands after a DMA transfer. Hence if the - * async data transfer is delayed then s->dma is set incorrectly. - */ - return; - } + /* + * Always perform the initial transfer upon reception of the next TI + * command to ensure the DMA/non-DMA status of the command is correct. + * It is not possible to use s->dma directly in the section below as + * some OSs send non-DMA NOP commands after a DMA transfer. Hence if the + * async data transfer is delayed then s->dma is set incorrectly. + */ if (s->ti_cmd == (CMD_TI | CMD_DMA)) { if (dmalen) { From patchwork Tue Feb 13 19:39:51 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: 13555587 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 CE2ACC48BC4 for ; Tue, 13 Feb 2024 19:46:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyg6-0006vv-0l; Tue, 13 Feb 2024 14:42:50 -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 1rZyg1-0006GV-PB for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:46 -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 1rZyg0-0006PJ-91 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:45 -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=rztxPF2KL8bBXmJOqN6I30ocrg/o4uM0EjWkKsf+Its=; b=iYTOdRchRnUgbERToQ1Z50ELyv jDEoEATzGWGCD2t2BKun9iVWI3uIj/5Ok9YLNlAiALbcYp5D5Lxj2/zTGJljyPUpKbRGn1ZJ1IB2p KYwVqpl38eH7op9qX9L6Xf1wwZNgzetNUtkAAOsWEYh9M/ECLBthHO0/PhH0woVr+FRNXuN5Ga+HX 60G1jiLUD+x/I21M/SEgygPh77woRlTuvsFaEV/OiH/gkCASpVhGWZPnF/hbbSBPq1ioBMjfl9Ke4 NGGde7NG52/OqBd7Yk+FVtnarMBpMqywfn4pADcCHYH3o7LgDqMKhiVAZ9ovsWezWIl6KgjaagERL 6Pmyfgt6gE5xAfI0m+wViy9tl3tt+eEzgSO+dhkYsslrl2hHeUBdDP1Ixya2gYYI2TQL1/22KdiwR pl6LLqMTrIvhFm7eN6OyILuN5EfZisrq3Zkmu7Bin5XNZAiOzdDnN8L9WOxzdKpDOMGUivEY3Ypaf ZH9FpQygZHS8E4ZB1dqEpsZqkVOxDp6X2NWOEWKTN8SetKc4fltxf+SwiIvZtpoMYK9YN7dE+mZSM d9FPDJKNtv0bgzAESD3wh6SlnudFWyz1FJxvqlr5hs9UZFNUtneHkLKe5z9F1DnifqtVbfygYbM0p lYZKBV0bdwRIPujRFslTyWacH70xrG43Vo5t3luME=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyf9-0008m4-M3; Tue, 13 Feb 2024 19:41:53 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:51 +0000 Message-Id: <20240213194052.1162753-28-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 27/88] esp.c: update end of transfer logic at the end of 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 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 Since esp_dma_done() is called in both cases, and ti_size cannot be zero (otherwise esp_command_complete() would have been called instead), replace the conditional logic with a single call to esp_dma_done(). Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-28-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 96123c5f7d..6b0811d3ce 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -925,16 +925,10 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) */ if (s->ti_cmd == (CMD_TI | CMD_DMA)) { - if (dmalen) { - esp_do_dma(s); - } else if (s->ti_size <= 0) { - /* - * If this was the last part of a DMA transfer then the - * completion interrupt is deferred to here. - */ - esp_dma_done(s); - esp_lower_drq(s); - } + /* When the SCSI layer returns more data, raise deferred INTR_BS */ + esp_dma_done(s); + + esp_do_dma(s); } else if (s->ti_cmd == CMD_TI) { esp_do_nodma(s); } From patchwork Tue Feb 13 19:39:52 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: 13555576 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 8DEC1C4829A for ; Tue, 13 Feb 2024 19:45:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZygC-00079f-1H; Tue, 13 Feb 2024 14:42:56 -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 1rZyg6-0006yI-Iw for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:50 -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 1rZyg5-0006Pk-0O for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:50 -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=kibjptY/wMmzUFXbCnZjWuBRPf2BC6ZaxFiieDa/v6k=; b=Q72zMpdeK6U2Vm5n1l8W8ZV07G OlOVLIWGhp/9FKlJ4ODCYvWie27zuXuulNs23GD7G1H3ZayYnMA3hlCdHv8DR+bQSgTZBWn31tUPg wAOUmEmNhIBLhE7PSSdz73Yrpdwfl+C1Zxz4AO+RyDAlMElEQp/dOOrBfJh1m1iPIX8juPZ9qlTA6 v6fZGlpwpCKji/QczyBsskFnaNnjzjeSk/ubkLForphtdRd05aQ/gg8z0Te9Db5ZcgSAIDOGzr22s CsGiP4FCpaCR9haJyGImJx22Uq/GJkJK8rCwl27fvKMy7qLwtTudOIWutWeuluFZB3dhQQIrs6Q5W RWdJxtZ7nxcua3vYGs/AUR8MUWq8rF9RF6c8l1WmKQhNkuVnhsu57UKDt7it0RdwTMSRoXcFybpZt qjkuZGs2LxV4nSEoEnOROePfFkUoABriP73fMQBw8Z/pJ3eHOHp2gZFiXMDWRK29N5dJZuS9defIB XCSDQA7dv78Tk2uWE6YUuLfkprD9Uq5v89SoZXXyBaRD5waNJ2btaCqPlF4Djd58jhxr4SzRPF6ng t+mpTAkY4cm5J2A0Hh8j6NS3t5StSF3nkQTVf9Oa4y0X/EDyKKRmr+hvVsiQr4m8gSCkzV1CJsvzx NPHnJuHBR6q4GzUc8GGXux1yVrTN/lsOCpW9C/VBI=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfB-0008m4-K3; Tue, 13 Feb 2024 19:41:57 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:52 +0000 Message-Id: <20240213194052.1162753-29-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 28/88] esp.c: consolidate async_len and TC == 0 checks in do_dma_pdma_cb() and esp_do_dma() 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 Ensure that the async_len checks for requesting data from the SCSI layer and the TC == 0 checks to detect the end of the DMA transfer are consistent in both do_dma_pdma_cb() and esp_do_dma(). In particular this involves adding the check to see if the FIFO is at its low threshold since PDMA and mixed DMA and non-DMA requests can leave data remaining in the FIFO. At the same time update all the comments so that they are also consistent between all similar code paths. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-29-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 6b0811d3ce..f20026c3dc 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -604,12 +604,13 @@ static void do_dma_pdma_cb(ESPState *s) s->async_len -= n; s->ti_size += n; - if (s->async_len == 0) { + if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { + /* Defer until the scsi layer has completed */ scsi_req_continue(s->current_req); return; } - if (esp_get_tc(s) == 0) { + if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { esp_lower_drq(s); esp_dma_done(s); } @@ -706,24 +707,30 @@ static void esp_do_dma(ESPState *s) s->async_len -= len; s->ti_size += len; - if (s->async_len == 0) { + if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { + /* Defer until the scsi layer has completed */ scsi_req_continue(s->current_req); - /* - * If there is still data to be read from the device then - * complete the DMA operation immediately. Otherwise defer - * until the scsi layer has completed. - */ return; } - if (esp_get_tc(s) == 0) { - /* Partially filled a scsi buffer. Complete immediately. */ + if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { esp_dma_done(s); esp_lower_drq(s); } } else { esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); + + if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { + /* Defer until the scsi layer has completed */ + scsi_req_continue(s->current_req); + return; + } + + if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { + esp_dma_done(s); + esp_lower_drq(s); + } } } else { if (s->dma_memory_write) { @@ -734,13 +741,13 @@ static void esp_do_dma(ESPState *s) s->async_len -= len; s->ti_size -= len; - if (s->async_len == 0) { + if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { + /* Defer until the scsi layer has completed */ scsi_req_continue(s->current_req); return; } - if (esp_get_tc(s) == 0) { - /* Partially filled a scsi buffer. Complete immediately. */ + if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { esp_dma_done(s); esp_lower_drq(s); } @@ -754,6 +761,17 @@ static void esp_do_dma(ESPState *s) esp_set_tc(s, esp_get_tc(s) - len); esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); + + if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { + /* Defer until the scsi layer has completed */ + scsi_req_continue(s->current_req); + return; + } + + if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { + esp_lower_drq(s); + esp_dma_done(s); + } } } } From patchwork Tue Feb 13 19:39:53 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: 13555562 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 35F07C4829A for ; Tue, 13 Feb 2024 19:42:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyg9-00071N-5M; Tue, 13 Feb 2024 14:42:53 -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 1rZyg6-0006y3-Fb for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:50 -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 1rZyg5-0006Pm-0S for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:50 -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=m1ImFGpa7DxWE0DTTuWjbOMbJeHgbQNvbOZuqOrXhag=; b=nWFBzRYJlg3ysCW+PlmnbbmF3o XWw/ho76lNRnFA9jxEsG8lEqJldFUUHzDyexT1qy9HHtWSD1ynOzkLbz1Y3EO8+2QG09w8xj5g9n8 1rlGCdgvBSMlTI4rqpODJ1R+tbboSbxP/Kianex8zH5v/4LS/0lWOnfM0O9qXAgDETmwZP9se7Zsw FlIGJhbrpWMr73LfdKVXDx2z5fkscZQQdPIkb8GRKfGawq5ExFLCk+ZkKkHIwsnjIE+afkilo9g8J 8fzkoU9PkEObHEvgnDKtGxBEYEMw7O1ml+QMNZGrem1K9Ac10bcnx/516H2o/oeE2mvWK6tZmuo/m Bxj28qlipaViiEuRcyaImch1Z4RgLD+JBK5uFhu9G00SShmLhWHmJ4Fh8lGpvtRBMNIzKHsvf/mPy izbf+sM4/qzHUQVK/rqD5gM4iZHfhSXXB1l9tn1Upyja8xokaGQWDnWgEHTlvB6d/44nh8D/6t3tr ag95aTR/IdP0B1696drk/ffnx9uy+tp+KWNrW+1mqxWjL07pN8clWEMbA4OXUh7GjdAuH0ZAKGcOf uuhB/dFG9tvfjmcUbK65248zD59R7swOz4uc/vyQvYtDzis0wTnkmSUQ2rAKx2qgckcY/I1VPrrs6 CRO4Rls4CkagZKGD8OjSyOiNIubs40rv88no7X9SU=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfF-0008m4-N5; Tue, 13 Feb 2024 19:41:57 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:53 +0000 Message-Id: <20240213194052.1162753-30-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 29/88] esp.c: fix premature end of phase logic esp_command_complete 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 two cases here: the first is when the TI command underflows, in which case we raise INTR_BS to indicate an early change of phase, and the second is when the TI command overflows because the host requested a transfer for more data than is available. In the latter case force TC to zero so that the TI completion logic executes correctly. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-30-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index f20026c3dc..c6151d306e 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -887,7 +887,6 @@ void esp_command_complete(SCSIRequest *req, size_t resid) if (s->ti_size != 0) { trace_esp_command_complete_unexpected(); } - s->ti_size = 0; } s->async_len = 0; @@ -897,13 +896,26 @@ void esp_command_complete(SCSIRequest *req, size_t resid) s->status = req->status; /* - * If the transfer is finished, switch to status phase. For non-DMA - * transfers from the target the last byte is still in the FIFO + * Switch to status phase. For non-DMA transfers from the target the last + * byte is still in the FIFO */ + esp_set_phase(s, STAT_ST); if (s->ti_size == 0) { - esp_set_phase(s, STAT_ST); + /* + * Transfer complete: force TC to zero just in case a TI command was + * requested for more data than the command returns (Solaris 8 does + * this) + */ + esp_set_tc(s, 0); esp_dma_done(s); - esp_lower_drq(s); + } else { + /* + * Transfer truncated: raise INTR_BS to indicate early change of + * phase + */ + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + s->ti_size = 0; } if (s->current_req) { From patchwork Tue Feb 13 19:39:54 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: 13555573 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 0CBB1C48260 for ; Tue, 13 Feb 2024 19:44:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZygG-0007ae-S9; Tue, 13 Feb 2024 14:43:00 -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 1rZygF-0007RO-2h for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:59 -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 1rZyg9-0006Q4-Hc for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:58 -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=A7Ml3OJRuG9i9wCVUKZri2ee9kNdSQpXNdwl+PnHGcw=; b=1ABVLHiY1qs+tqCUxSYyUUf2lF TRfvxHcl7GlSPzFgrwnc9aP5rHQdxP59VM82dcvclcy4idBqOx4R77In8jkOYBJ/5wvvrx6ougndP f4MypvrJcAdUQCH/klZkixQYQ1FoWgmGFNP9Bu+3ifTTieLtq/AN3D0ROwQrYHoFPG0VyagBhUtgR S2OJlUpCS7Ohx2cZvmHt6eG0EdUL++mu7sfRC3E5KGWhs0x6vs450STT3Pw+o8Jowl0PeiqS/5vAe DG7ZTs2dFJdEaH4GX3RK01mojARelp45ROca1PAe0gZ9GK+zpARGT1Epr3OxwfD9gvgbkZFMq5Hlh vSYCeiITyHsYrNaNUBSt7YBI7hHMoXPEtmnHebIrP01TVD8pIghTQJzDu4rmfE2DT5xJsBtArLNkt VryBv8tHIDenSeuSfADw7exxBvGe8nGGYa1WZHWqxYYftMt/jSS0+X7z7QlzA8kAGRXcMSxLm7iBz lZRleR5vX+hIGktcLxoMw3QGwS+HBajZY02V2GnTvMZbdPNhVYVhEHncnFTdAAldIpaEaJs/zX/su WcMbJeoYaK0KnxNqk0v1+LDTV7Uxl/Sj014/hBs54zQ90BjPd41busaV2zEoykhmwbMNHWGY/w2FX zozWL9X3JztyZvMkTzA/QP+YBlWPczxGbQD93J7PA=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfG-0008m4-0n; Tue, 13 Feb 2024 19:42:01 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:54 +0000 Message-Id: <20240213194052.1162753-31-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 30/88] esp.c: move TC and FIFO check logic into esp_dma_done() 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 helps simplify the existing implementation. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-31-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index c6151d306e..4d58a49c73 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -545,8 +545,11 @@ static void write_response(ESPState *s) static void esp_dma_done(ESPState *s) { - s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(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); + } } static void do_dma_pdma_cb(ESPState *s) @@ -610,12 +613,7 @@ static void do_dma_pdma_cb(ESPState *s) return; } - if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { - esp_lower_drq(s); - esp_dma_done(s); - } - - return; + esp_dma_done(s); } else { if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { /* Defer until the scsi layer has completed */ @@ -624,10 +622,7 @@ static void do_dma_pdma_cb(ESPState *s) return; } - if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { - esp_lower_drq(s); - esp_dma_done(s); - } + esp_dma_done(s); /* Copy device data to FIFO */ len = MIN(s->async_len, esp_get_tc(s)); @@ -713,10 +708,7 @@ static void esp_do_dma(ESPState *s) return; } - if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { - esp_dma_done(s); - esp_lower_drq(s); - } + esp_dma_done(s); } else { esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); @@ -727,10 +719,7 @@ static void esp_do_dma(ESPState *s) return; } - if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { - esp_dma_done(s); - esp_lower_drq(s); - } + esp_dma_done(s); } } else { if (s->dma_memory_write) { @@ -747,10 +736,7 @@ static void esp_do_dma(ESPState *s) return; } - if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { - esp_dma_done(s); - esp_lower_drq(s); - } + esp_dma_done(s); } else { /* Copy device data to FIFO */ len = MIN(len, fifo8_num_free(&s->fifo)); @@ -768,10 +754,7 @@ static void esp_do_dma(ESPState *s) return; } - if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { - esp_lower_drq(s); - esp_dma_done(s); - } + esp_dma_done(s); } } } From patchwork Tue Feb 13 19:39:55 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: 13555580 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 C5B1CC48260 for ; Tue, 13 Feb 2024 19:46:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZygG-0007Zl-Nm; Tue, 13 Feb 2024 14:43:00 -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 1rZygF-0007RQ-2Q for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:59 -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 1rZygC-0006Qm-TK for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:42:58 -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=P1NfptW+n1Q4+bwv4LEHKcXl0PIqkO0R8wltEoCkpow=; b=RqBs9ULl5Grphoq7R2ZGha0x83 ZVbdE5MooTsc3mti7UKB8Rt5/HTvDL2SKjAQ1NGuqaztNzsBlZcEmd7DK90Z/n16WhHkg7s6ws+e2 o1Vd7FxZLngFY7aZb6MJfdMNkk5ZkWpgGw+xUQGdwoLb3DeBZhHqcJS54Fzefe3ULXijCm+iPXrJe awJ0nUweGrmm1Nk+0JYeT9coqDXbDL4CEruFhOKOgtg0b7NJaM6c/e54RdF6hxZQPx1gZzDJByJL5 efQOlhJCY+92PR2S1MfSaBXa3x1z67zOS8JSfmBSQujG9uSpr4Utn4gMYGg705eHcGjzeEWs7Ndpa 7/smiGe6RToASNyeSzw3eKkj0OSn+OO9jD8xpb16gpy8GLtT0MuqiQ9buE0gPCqwt2XYM5Z47/maE KT1Y+KEvaJbLFOUsoOPtZ9SvqQAwLSeeTnItG6cEMKBeiQDULhGZa8KrjHGf92vKExjqDJYQusQr+ ICNZFJpGprFKKi7fzM21thRViwsymI6lqRoJh3RuuF0R+mH9Mu8Ep5qWfLLXUrLbm6tiqZ64AbPBT bwt5VVFHFQs86wkW38CMtxcBaJqegamouj8hkvTzCLvJgRynM+stSULoKTzvMNCG4ThKClLoHEkTH zh4dzsuwqfgjWphnAFYiaf2DFrOUs3om+6l1t+SlM=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfK-0008m4-4H; Tue, 13 Feb 2024 19:42:06 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:55 +0000 Message-Id: <20240213194052.1162753-32-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 31/88] esp.c: rename esp_dma_done() to esp_dma_ti_check() 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 is because a single DMA request can be transferred using multiple TI commands, and so a TC equal to zero may not represent the completion of the SCSI DMA command. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-32-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 4d58a49c73..14c6d05253 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -543,7 +543,7 @@ static void write_response(ESPState *s) esp_raise_irq(s); } -static void esp_dma_done(ESPState *s) +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; @@ -613,7 +613,7 @@ static void do_dma_pdma_cb(ESPState *s) return; } - esp_dma_done(s); + esp_dma_ti_check(s); } else { if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { /* Defer until the scsi layer has completed */ @@ -622,7 +622,7 @@ static void do_dma_pdma_cb(ESPState *s) return; } - esp_dma_done(s); + esp_dma_ti_check(s); /* Copy device data to FIFO */ len = MIN(s->async_len, esp_get_tc(s)); @@ -708,7 +708,7 @@ static void esp_do_dma(ESPState *s) return; } - esp_dma_done(s); + esp_dma_ti_check(s); } else { esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); @@ -719,7 +719,7 @@ static void esp_do_dma(ESPState *s) return; } - esp_dma_done(s); + esp_dma_ti_check(s); } } else { if (s->dma_memory_write) { @@ -736,7 +736,7 @@ static void esp_do_dma(ESPState *s) return; } - esp_dma_done(s); + esp_dma_ti_check(s); } else { /* Copy device data to FIFO */ len = MIN(len, fifo8_num_free(&s->fifo)); @@ -754,7 +754,7 @@ static void esp_do_dma(ESPState *s) return; } - esp_dma_done(s); + esp_dma_ti_check(s); } } } @@ -890,7 +890,7 @@ void esp_command_complete(SCSIRequest *req, size_t resid) * this) */ esp_set_tc(s, 0); - esp_dma_done(s); + esp_dma_ti_check(s); } else { /* * Transfer truncated: raise INTR_BS to indicate early change of @@ -939,7 +939,7 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) if (s->ti_cmd == (CMD_TI | CMD_DMA)) { /* When the SCSI layer returns more data, raise deferred INTR_BS */ - esp_dma_done(s); + esp_dma_ti_check(s); esp_do_dma(s); } else if (s->ti_cmd == CMD_TI) { From patchwork Tue Feb 13 19:39:56 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: 13555593 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 79262C4829A for ; Tue, 13 Feb 2024 19:48:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZygL-0007nX-5I; Tue, 13 Feb 2024 14:43:06 -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 1rZygH-0007cZ-Rf for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:02 -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 1rZygG-0006Sm-EK for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:01 -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=3PlvwSfea5jNKUmo4ddcBd6qzlhvJkQiXyTHLU10kQk=; b=FkFl6BQzuv9mM4x9nQ123GPBEe 52sVO3di7zB4A5qFUuMV6n0ztH/O1UK6ZBZ+4ZjD0AXcgXzeCtiOrvhgRAP8BR8DxJxmjph97kf88 j7QVUtbmyUJVS8ZmOg8N+yZFd9AsUzaUz9ZMA8/cfQSmF2yqcmEg5tORVPm9GLB1XDIIQ+xwrMHyr kYEzH2oDbtNZ3EX49YHyuVrSuqujKZ+XWpIrHFwoSBToeyTdcBHZICtmZoWSs1p9/PRp6mn1w/Fx+ eE0QKr7xKpqDyQLwDxSN0ifih8qGnX3d0lXhuvmsbkERE+EEJyKHYtkCQYsWRe1GXKWb4Hni+zRUH 67saqCSwa5RZmc+ZRWEA05vtcuhRJlRhX4w9DXUwJpfOtkFBDlzvLuuifaRRhjUgaYrCJYTeZQFJH BAB+6OW4okVs5Y+7v4GUqH+gmwW2daDH6cMVUIAM0P5E5m4RoGcSj11Pold8Xwh/Z5+4jZqEyHM5y HEnVn6yJv4JYKrrbOqyC/ELkeBudKyRDjPeyQEYlXpmN8mJSzlK1mTmdb3fbdI4yFtDWCMNliVHG1 eajh3WkCdgcpRuqQJSjIaavV3rvy+IHNQQf5AQMBVKHbd3/wQ+96OSbhwSpKaXGdZg7ediNDSM8Sk npQSp/2QdRQeCcYawvhel9R53XYvKWWRsP+7ebiPQ=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfO-0008m4-77; Tue, 13 Feb 2024 19:42:09 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:56 +0000 Message-Id: <20240213194052.1162753-33-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 32/88] esp.c: copy PDMA logic for transfers to device from do_dma_pdma_cb() to esp_do_dma() 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 is so that PDMA transfers can be performend by esp_do_dma() as well as do_dma_pdma_cb(). Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-33-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 14c6d05253..65b4baab83 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -640,6 +640,7 @@ static void esp_do_dma(ESPState *s) uint32_t len, cmdlen; int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO); uint8_t buf[ESP_CMDFIFO_SZ]; + int n; len = esp_get_tc(s); if (s->do_cmd) { @@ -710,6 +711,14 @@ static void esp_do_dma(ESPState *s) esp_dma_ti_check(s); } else { + /* Copy FIFO data to device */ + len = MIN(s->async_len, ESP_FIFO_SZ); + len = MIN(len, fifo8_num_used(&s->fifo)); + n = esp_fifo_pop_buf(&s->fifo, s->async_buf, len); + s->async_buf += n; + s->async_len -= n; + s->ti_size += n; + esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); From patchwork Tue Feb 13 19:39:57 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: 13555603 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 66769C48260 for ; Tue, 13 Feb 2024 19:49:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZygR-0008BC-6C; Tue, 13 Feb 2024 14:43:11 -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 1rZygO-0007y7-Uh for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43: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 1rZygN-0006T7-FO for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43: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=cwET+lM8NWpH3LaH5ZhywFZDErG/NIsZyk1qq6PTdLM=; b=Ufr8RSccRMJMgycphDnEnF9Us2 IeIPddI9AhHABPSEO42rkXEZ1xOOX5YZSTrbGDxYiqADSmnkARMXeML4uhHMAWdUb7Mo3cH4/+VCa f95v5y5gaPqTyq0mVNVVD1BuYyYj40Hxp2egAEwcu3bBLiX+2VD8nQoWT0hPepu5gYsxJ2ivx2rVh vycZiEnOV0UvX1fTD3WSxNiEWOknxn4jbS9iY3FLAjc/PpF0W+00ZMna6iBhLBX1N4vcaL/ViQrK3 9RiDNQLWim34YhtaPWVsi3zX56jI5zQ1TAggFTVczGdE5IWKnS3M3ldxlXnPaLgk1xhqQoia3MFOJ XH5G6L0zNGzK73MOiiAWQVA64Mv/MJzc5QuhwIviorXKh/sP0916B2v9fjW+pCiXZLKAEyQF2A20x cHXQQiyeGRw6bnXdrJ7qFVtRWHEx8XKWgP66QvRuSAiqvPTBNlHlyEOadKJfZzgPpmouKtXTI6e80 S23uPwn/ghgQfy0ShJlttBNv6n+jWFccNQ5VYlCL6cYUqO4DqX7b7disIShPYqELNVZ+tL9+O99fN xfscGgs7xINGm9s6Cz3lRtoyGG76fxo9Q48xtl8pePC07IPCG//piZJdNvMyINkm6xl8fw5TmNoMl 7FHwRXHyQ07r1YkrwkOEcsduyioOrQ3OmlajNGO6Y=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfR-0008m4-Pp; Tue, 13 Feb 2024 19:42:13 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:57 +0000 Message-Id: <20240213194052.1162753-34-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 33/88] esp.c: copy logic for do_cmd transfers from do_dma_pdma_cb() to esp_do_dma() 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 is so that PDMA transfers can be performend by esp_do_dma() as well as do_dma_pdma_cb(). Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-34-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 65b4baab83..14284ef54a 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -656,9 +656,18 @@ static void esp_do_dma(ESPState *s) fifo8_push_all(&s->cmdfifo, buf, len); esp_set_tc(s, esp_get_tc(s) - len); } else { + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + esp_set_tc(s, esp_get_tc(s) - n); + esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); - return; + + /* Ensure we have received complete command after SATN and stop */ + if (esp_get_tc(s) || fifo8_is_empty(&s->cmdfifo)) { + return; + } } trace_esp_handle_ti_cmd(cmdlen); s->ti_size = 0; From patchwork Tue Feb 13 19:39:58 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: 13555602 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 68773C4829A for ; Tue, 13 Feb 2024 19:49:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZygR-0008G4-KB; Tue, 13 Feb 2024 14:43:11 -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 1rZygQ-00085O-4w for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:10 -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 1rZygO-0006TL-Hu for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:09 -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=jtHuybESn9RMD5N86rN7fm1Ea108OnJ+SQGaxYKfcKI=; b=GdVHlfsq/POiZffYLRMX5y+EuQ p9PKNM3cqC3ylQ3prF2nRBuqcsFg3FIhTpj/K10FtYG1P8g2OjNPS/cpheI8zh8PHjuIkDpvpyj5y dZBWD/8tvQZ62JZ1/bjm/L7ZnSDl3ZQ2gb3dZZ5M9sFx7nmQ5kZu5fj8MGQYBEA3FlRNnZdNViUDk 0X2CUy2Z1km/88Q+4BpsfjjmJCp4glgfbi97dmlG7X2YUzzmoFvzzvSGoHsOEg7j/XJDBulVLhg+i PKhtwj3IA1Ena1FigRMAkwYD1KAb1G16mwfNCJZHKkrs/1cYBq7d8fqqzkYW+JQeSxjxFwq1ffiER 5QF4oxcPpU+M6qhZ4EJ/uOrxgDRg9SFhM4OunOFRsLGW+JGgzThkpFup7sEn6KKWe7ssTDiBGbn7U wde0CcGiADE6Mhe5HRlTEC3lwjdmyN6o7TXjolp8gW/LbVDipP+ZSTTbIqDrHAxQvx3el923DdLBK G/ik0a8Nhn34GylnbRgPoPBRm2fzBh4oL175KyxeXkqNZ6cfZGgWB1gFdCOmj8wEdAyl9LTD9Rpse 2rLoAXdtkdtvnMWJRzoKXteUijP/P4J1F4mp6zYMOrIJn8lJJw3RHFdbhBjcGrf5PcjPc22Dpn5lq rjEMeh30edciA5azCaquzPVQUQhMApr2b5SJtkFsQ=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfV-0008m4-Su; Tue, 13 Feb 2024 19:42:17 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:58 +0000 Message-Id: <20240213194052.1162753-35-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 34/88] esp.c: update esp_do_dma() bypass if async_len is zero to include non-zero transfer check 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 In the PDMA case the last transfer from the device to the FIFO has occurred (async_len is zero) but esp_do_dma() is still being called to drain the remaining FIFO contents. The additional non-zero transfer check ensures that we still defer the SCSI layer in the case where we are waiting for data for a TI command or a DMA enable signal. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-35-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 14284ef54a..9647be4cc3 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -696,7 +696,7 @@ static void esp_do_dma(ESPState *s) if (!s->current_req) { return; } - if (s->async_len == 0) { + if (s->async_len == 0 && esp_get_tc(s) && s->ti_size) { /* Defer until data is available. */ return; } From patchwork Tue Feb 13 19:39:59 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: 13555569 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 7D1CDC4829F for ; Tue, 13 Feb 2024 19:43:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZygW-0000BK-0E; Tue, 13 Feb 2024 14:43: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 1rZygV-000071-79 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43: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 1rZygS-0006Tj-KL for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:14 -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=mJr37RlinPGRhEfpEIyzgMlMfF6VqeJF3dO28hs/Om0=; b=fjouwqiIzI8Qm5lUkYiNVeTW8g 53NMu/xqOjmw1xW1aPl+9D57UtPtSkyJspei5aiwZg+O5VM2J8Pvss429kVa+CjeLVrUtBUhe3WtI QOVJZlBrX937BOLBQJ/FejBgg62GcTFTvth5og26tnQ6jmZxl7OrTdj7hGOtVlU4JmoKOqzIzc/MH UzDyIVqzSBlV56Mb+gyX2VzGWcyTetQwNWgsR0AiW5Jkw8DQEElp1+6UIEcU5icEEyAkk+NRqIkFu sI1U5PBXBRJUAUB64h8bT1BR9d69a8uL/NXhtGQ4uHsOEuJ2Y897s2q84q4qZjOEPF/QfaxDTEVzp wPPm2/S1JF73yd8ig1Z2Q4k4dvmnQvEl5CiaEbyjkcK/Rt9fEAAZcIsLPZdr3LRBPr7PxMClF80VD 0o0WgTOCipY7FmIjpojtwGRXq+6QAaGK3msdneB+5KxjanJ+vXhueo8u6dtHj6bHH4BXyRwgq8N1q hT38JLSw/7Jnvd5W74DciLqlk8jPyz2H1hW+e03hjNDmGwdoAmXFbLoGU3J6UgQqxxS9bOmkCMwBt ck37h9Oufn/nIkQP6D+y+Vf4D2xVwCX3i4PcJh+jE0fQNkIvFweixyWt4QWrHfIgakzpHfK6QRJpK olOT/mdGM+h4n798h9C16nEYXks6zLNjtkXt+sa88=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfZ-0008m4-Sw; Tue, 13 Feb 2024 19:42:21 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:39:59 +0000 Message-Id: <20240213194052.1162753-36-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 35/88] esp.c: move end of SCSI transfer check after TC adjustment in do_dma_pdma_cb() 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 it is possible to move the end of SCSI transfer check to after the TC adjustment in do_dma_pdma_cb() when transferring data from the device without triggering an assert() in the SCSI code. This brings this check in line with all the others in esp_do_dma() and do_dma_pdma_cb(). Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-36-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 9647be4cc3..df4d5f8811 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -615,15 +615,6 @@ static void do_dma_pdma_cb(ESPState *s) esp_dma_ti_check(s); } else { - if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { - /* Defer until the scsi layer has completed */ - scsi_req_continue(s->current_req); - s->data_in_ready = false; - return; - } - - esp_dma_ti_check(s); - /* Copy device data to FIFO */ len = MIN(s->async_len, esp_get_tc(s)); len = MIN(len, fifo8_num_free(&s->fifo)); @@ -632,6 +623,15 @@ static void do_dma_pdma_cb(ESPState *s) s->async_len -= len; s->ti_size -= len; esp_set_tc(s, esp_get_tc(s) - len); + + if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { + /* Defer until the scsi layer has completed */ + scsi_req_continue(s->current_req); + s->data_in_ready = false; + return; + } + + esp_dma_ti_check(s); } } From patchwork Tue Feb 13 19:40:00 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: 13555579 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 018DFC4829F for ; Tue, 13 Feb 2024 19:46:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZygZ-0000SR-Nf; Tue, 13 Feb 2024 14:43: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 1rZygY-0000Oe-89 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:18 -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 1rZygW-0006UV-PE for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43: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=3lh4EKqM0Upn+N3VvhTeQfOb1mZrCBum2A1v0jFULbw=; b=Ya5vpiw9/g2iXSoJoVsRiwR915 Nmsny+KsHEi98/G4PT3IUep5rExluZfdpGW53p7Vs6ZFBwy5AHfhBP5sFyf8B5obRFc6OHOp9vsYI v7pH6ISeVeX36bLy1YMA6cdYjZ8SWHPeY3vKGVd1RKaSYeziZT0DiyMQe71PBfDvoGB796xA6MXwz Ei+qB60rG+p350s0Ce/yf46b+OEdV0Y4bd+F5zjh9CjkpA7x1QZ7SPAxDybc/NmgPl487sXFt7S6q pAlWJKiDwhKICInl1uPAol4Thnz+qJmumFIt/SmTvdqTONoKxwtgoOZwXi1v9QF7qEiTI9lvRUFzs gwv9/mig3vjq2Pvtll5nvju59IbPxqNzWduu5ltg0R+3Uq681JO0f+xG6Bvh+f2LclSfcHpzngTdS NkvhsTQNSMhaTrUY3Bqbqf5v0r0eUQjpHDddvlgU406C+H4icxtkIumZtPi1xzeGp2ZLLbItk3Mj2 e/BNCcukloEpsrQ8UfzN7CDjUKECG6JmiAu55UWv/86jY2HlgnMZqAnq98QtdEiM4VlMu92ue6wm9 hXPocB2WytjDQW2OR61AKLX541j6PjFMfGnt+cKGeAnpEzosfj2Il4+9hv5PouNtti6QmMoYjQtEu xhAf8/TN+SMuVQkVpY3Z4HiexbXsnJJew0umGX0uc=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfd-0008m4-Vm; Tue, 13 Feb 2024 19:42:25 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:00 +0000 Message-Id: <20240213194052.1162753-37-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 36/88] esp.c: remove s_without_satn_pdma_cb() PDMA callback 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 can now be handled by the existing do_dma_pdma_cb() function. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-37-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 22 +--------------------- include/hw/scsi/esp.h | 1 - 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index df4d5f8811..16cb6c72fd 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -408,23 +408,6 @@ static void handle_satn(ESPState *s) } } -static void s_without_satn_pdma_cb(ESPState *s) -{ - uint8_t buf[ESP_FIFO_SZ]; - int n; - - /* Copy FIFO into cmdfifo */ - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); - - if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) { - s->cmdfifo_cdb_offset = 0; - s->do_cmd = 0; - do_cmd(s); - } -} - static void handle_s_without_atn(ESPState *s) { int32_t cmdlen; @@ -433,7 +416,7 @@ static void handle_s_without_atn(ESPState *s) s->dma_cb = handle_s_without_atn; return; } - esp_set_pdma_cb(s, S_WITHOUT_SATN_PDMA_CB); + esp_set_pdma_cb(s, DO_DMA_PDMA_CB); if (esp_select(s) < 0) { return; } @@ -856,9 +839,6 @@ static void esp_pdma_cb(ESPState *s) case SATN_PDMA_CB: satn_pdma_cb(s); break; - case S_WITHOUT_SATN_PDMA_CB: - s_without_satn_pdma_cb(s); - break; case SATN_STOP_PDMA_CB: satn_stop_pdma_cb(s); break; diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index 13b17496f8..b727181da9 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -153,7 +153,6 @@ struct SysBusESPState { /* PDMA callbacks */ enum pdma_cb { SATN_PDMA_CB = 0, - S_WITHOUT_SATN_PDMA_CB = 1, SATN_STOP_PDMA_CB = 2, WRITE_RESPONSE_PDMA_CB = 3, DO_DMA_PDMA_CB = 4 From patchwork Tue Feb 13 19:40:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13555589 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 C3722C48260 for ; Tue, 13 Feb 2024 19:48:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZygx-0001P4-Jz; Tue, 13 Feb 2024 14:43:43 -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 1rZygp-0000zD-3j for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:35 -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 1rZyga-0006Us-OK for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:33 -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:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To: Cc: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=TJHBiJkh3bmcyNfBAoMhEkxZc4TXoXWWwMTukArRF8A=; b=tgSnx751buvdE4b+9R3TczMsvO rjgRhP/QiJwWDTarFhOfmeOoQ3Mhad2fpzhpJv01MfdExUM+ID4y5fDxY3dsnUalgyXISHC1Eup9V MoYmCicBbu1cZJGgTVbE/aKH0JBDryFsrO4/2q44YG4STEtf5T1MndABFpEJcpudeUwkWHFkZFinJ pjHCyFFjmYdcoDvdEJY3hft1WNh1beYssI3nAMRbTP6I2+HvVMK7oIfdvqULURmxDclO1LdaB61rs 4L6P2pvsgc6q8IT6rlI7KYeP/qyGfoHDtK1biR+8MExLEwCHpUS+/SGESgowjwaYdoEGhz45etTMj rlfHyrMVN4WPEtnpiEUnRPuIW9zDshQ1+sZoZpd7ysIDHqeG5I66EiZDuwPJ9KxYza0Qjx9nMDQHw DdaTo/i6dJwvtyiVSxX5wh2l24fRYecqq+v+qIkjp24PIJRaJV92yT3QxGCuc0BOu7ssN0ozz4o10 bqHKU5yVdQYsbvQPthOkM++X/616Tq9F7cgHC9zNy4+7T5T3TYlb147D4QoG4qUoVEqLzvF84jelE ZcpMXh1+v3HTiCU/HP7gYNd2/dV1/Kkl1xs/o+YSob8wgtL9koK3FINQWQTHYkZ8XKIRQGX2OgNXL egRtlvgEwhdsNKUMazQeEgTUNIulUI/yidxwOD0AU=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfi-0008m4-2c; Tue, 13 Feb 2024 19:42:30 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:01 +0000 Message-Id: <20240213194052.1162753-38-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 37/88] esp.c: introduce esp_get_phase() function 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 Make use of this new function in all places where the SCSI phase bits are manually masked from the ESP_RSTAT register. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20240112125420.514425-38-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 16cb6c72fd..de8d98082a 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -196,6 +196,11 @@ static void esp_set_phase(ESPState *s, uint8_t 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; @@ -537,7 +542,7 @@ static void esp_dma_ti_check(ESPState *s) static void do_dma_pdma_cb(ESPState *s) { - int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO); + int to_device = (esp_get_phase(s) == STAT_DO); uint8_t buf[ESP_CMDFIFO_SZ]; int len; uint32_t n; @@ -554,7 +559,7 @@ static void do_dma_pdma_cb(ESPState *s) } s->ti_size = 0; - if ((s->rregs[ESP_RSTAT] & 7) == STAT_CD) { + if (esp_get_phase(s) == STAT_CD) { /* No command received */ if (s->cmdfifo_cdb_offset == fifo8_num_used(&s->cmdfifo)) { return; @@ -621,7 +626,7 @@ static void do_dma_pdma_cb(ESPState *s) static void esp_do_dma(ESPState *s) { uint32_t len, cmdlen; - int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO); + int to_device = (esp_get_phase(s) == STAT_DO); uint8_t buf[ESP_CMDFIFO_SZ]; int n; @@ -654,7 +659,7 @@ static void esp_do_dma(ESPState *s) } trace_esp_handle_ti_cmd(cmdlen); s->ti_size = 0; - if ((s->rregs[ESP_RSTAT] & 7) == STAT_CD) { + if (esp_get_phase(s) == STAT_CD) { /* No command received */ if (s->cmdfifo_cdb_offset == fifo8_num_used(&s->cmdfifo)) { return; @@ -762,7 +767,7 @@ static void esp_do_dma(ESPState *s) static void esp_do_nodma(ESPState *s) { - int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO); + int to_device = (esp_get_phase(s) == STAT_DO); uint8_t buf[ESP_FIFO_SZ]; uint32_t cmdlen; int len, n; @@ -776,7 +781,7 @@ static void esp_do_nodma(ESPState *s) cmdlen = fifo8_num_used(&s->cmdfifo); trace_esp_handle_ti_cmd(cmdlen); s->ti_size = 0; - if ((s->rregs[ESP_RSTAT] & 7) == STAT_CD) { + if (esp_get_phase(s) == STAT_CD) { /* No command received */ if (s->cmdfifo_cdb_offset == fifo8_num_used(&s->cmdfifo)) { return; @@ -856,7 +861,7 @@ static void esp_pdma_cb(ESPState *s) void esp_command_complete(SCSIRequest *req, size_t resid) { ESPState *s = req->hba_private; - int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO); + int to_device = (esp_get_phase(s) == STAT_DO); trace_esp_command_complete(); @@ -909,7 +914,7 @@ void esp_command_complete(SCSIRequest *req, size_t resid) void esp_transfer_data(SCSIRequest *req, uint32_t len) { ESPState *s = req->hba_private; - int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO); + int to_device = (esp_get_phase(s) == STAT_DO); uint32_t dmalen = esp_get_tc(s); assert(!s->do_cmd); @@ -1103,7 +1108,7 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr) qemu_log_mask(LOG_UNIMP, "esp: PIO data read not implemented\n"); s->rregs[ESP_FIFO] = 0; } else { - if ((s->rregs[ESP_RSTAT] & 0x7) == STAT_DI) { + if (esp_get_phase(s) == STAT_DI) { if (s->ti_size) { esp_do_nodma(s); } else { From patchwork Tue Feb 13 19:40:02 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: 13555570 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 5084CC48260 for ; Tue, 13 Feb 2024 19:44:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZygw-0001FA-NZ; Tue, 13 Feb 2024 14:43:42 -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 1rZygn-0000mU-9n for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:34 -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 1rZygb-0006Uw-4s for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:32 -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=3mv2UQoAA8iNjt3Y2Y/V81trk2GrrhQGmIBesJpxTBg=; b=rkXG3o+rwBMKCdeidVS5A9Movw bi4ts5diyoTbCRSAWimFdjvM4jH8v+eqOPoq7l1Fo84gnAZdCKuwz+hcp3Cuq9+fmnzaq0Mi+2jt0 zdpM4riXMSF8liv30BLUDmx5fL5dtG7UiHxkIkMT1i1961iJqU0X/FKBTCgceNWsbuf8OPOBXcHxI 7P0grWWU0jjX97F/J2sZmZ5UE4fW6iwWO10S5hrXnIOUEh/53831Tp73lHAzv5oM5q9oP/pTcEm/T 75Ld6xZDH+w26oKJTvLhIltj9d5lpukPS+npT/RGKxNQ9eLUV2HGY6PFBY66Y3PvgR3ikT8fLzJ3g 4SKsMe71KEGPhJgUAWo9cTKru31ljIcpVQwtsEuIikukjz3JBD7qtAMww8PYmMt5Uo+8cEleuSFpf ULjThvCab4XjUAhgecke0xVwRWs8kbsqRgQxXVWxHmEXWzqjTZZWaB3A1ru6US+pLhai4jIY3Lg6f CghU5gazBKavRYKM4JdbssUtUbo7hlWNwWxckKz2Y/SJG/XVagy7bjMtZRLFTYlS+Wr0kAcZfO5m/ nvSb27JcbJpJ6fVD95VZYQExR/m+3lzGAxZPqK2z8ygIPtWfdKdfhajop+YMwkl4q/8wAidCLwUQl aba5ubn2D7Mfc9lJIkzRGtSTBrd3RuwTEra1yZ9lY=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfm-0008m4-5k; Tue, 13 Feb 2024 19:42:30 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:02 +0000 Message-Id: <20240213194052.1162753-39-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 38/88] esp.c: convert esp_do_dma() to switch statement based upon SCSI 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 Currently only the DATA IN and DATA OUT phases are supported. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-39-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index de8d98082a..67d1d39db2 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -626,7 +626,6 @@ static void do_dma_pdma_cb(ESPState *s) static void esp_do_dma(ESPState *s) { uint32_t len, cmdlen; - int to_device = (esp_get_phase(s) == STAT_DO); uint8_t buf[ESP_CMDFIFO_SZ]; int n; @@ -681,17 +680,19 @@ static void esp_do_dma(ESPState *s) } return; } - if (!s->current_req) { - return; - } - if (s->async_len == 0 && esp_get_tc(s) && s->ti_size) { - /* Defer until data is available. */ - return; - } - if (len > s->async_len) { - len = s->async_len; - } - if (to_device) { + + switch (esp_get_phase(s)) { + case STAT_DO: + if (!s->current_req) { + return; + } + if (s->async_len == 0 && esp_get_tc(s) && s->ti_size) { + /* Defer until data is available. */ + return; + } + if (len > s->async_len) { + len = s->async_len; + } if (s->dma_memory_read) { s->dma_memory_read(s->dma_opaque, s->async_buf, len); @@ -727,7 +728,19 @@ static void esp_do_dma(ESPState *s) esp_dma_ti_check(s); } - } else { + break; + + case STAT_DI: + if (!s->current_req) { + return; + } + if (s->async_len == 0 && esp_get_tc(s) && s->ti_size) { + /* Defer until data is available. */ + return; + } + if (len > s->async_len) { + len = s->async_len; + } if (s->dma_memory_write) { s->dma_memory_write(s->dma_opaque, s->async_buf, len); @@ -762,6 +775,7 @@ static void esp_do_dma(ESPState *s) esp_dma_ti_check(s); } + break; } } From patchwork Tue Feb 13 19:40:03 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: 13555567 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 2C3CBC48260 for ; Tue, 13 Feb 2024 19:43:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZygw-0001GY-O9; Tue, 13 Feb 2024 14:43:42 -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 1rZygo-0000uA-8i for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:34 -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 1rZyge-0006VE-N6 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:33 -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=b7eg0dzE654FUliKtZMmVkvW1/RaVBoC5GMBhFJ4dD0=; b=IsehB2xUnYtfTd0YR1PzPEvJDy I/Ric9QsipGVhBp6mlwZt18YiI5OTlHv5tZnZF5JhRA6Lr9VDOlXhb6qvntBtna1FdMS7jnrVYkpX QSbhhlgc7OqdG1M4MKPkptFzfo0P6MQH+D/UPimfcb1etdaRe61Le/z9Xv1be/jYUvKUFkjR9nkoE Q4ZgP/pv3Bz5u2GQitGoGbMtZKfdGb1c7FIXyzNgHCowKkx+AibLOi8+13uv2HYXh7C8VRpOuP0EI tDBeyHKacDm453z3b3xxoJxIGmdt7hkt6lv9PepQmbtF1E/I50zXfIQ39Yl3LeH89Hw1EDT3PqbnA uRKQdYjpHlOJ/th31N3eGxGJpZYtMDDd+Mhq77eZ29E3igHS5xuxQqzoNIkZiVxbPrXUJzVPZ2zfi GeRj3ezG5RN9g63EXelR7JzbiJ9s52/vBH/fQZqpgWHDPYxv/WKdR3jKi78ADkvRNTJ6CJ4fhcK+0 8nNDrbM52NAwfML9YOzMpsyUeVbkTOeaxVc/L8hHwWShZmmue7/jwbuiTT6V0peEyykrV18d87aQ4 WB+0cy4ZpkvJg+iQJFHd/IURMtIKlbEXRmwQv0wvYddldKTUv4/6rEsahsjcx6nZPmOmcRyeVQLyU vNSfxN3ZMKJ038/zK15ASbMtTrNOWA1Zdn4FbVgW0=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfm-0008m4-Ff; Tue, 13 Feb 2024 19:42:33 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:03 +0000 Message-Id: <20240213194052.1162753-40-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 39/88] esp.c: convert do_dma_pdma_db() to switch statement based upon SCSI 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 Currently only the DATA IN and DATA OUT phases are supported. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-40-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 67d1d39db2..f6d05b0de7 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -542,7 +542,6 @@ static void esp_dma_ti_check(ESPState *s) static void do_dma_pdma_cb(ESPState *s) { - int to_device = (esp_get_phase(s) == STAT_DO); uint8_t buf[ESP_CMDFIFO_SZ]; int len; uint32_t n; @@ -582,11 +581,11 @@ static void do_dma_pdma_cb(ESPState *s) return; } - if (!s->current_req) { - return; - } - - if (to_device) { + switch (esp_get_phase(s)) { + case STAT_DO: + if (!s->current_req) { + return; + } /* Copy FIFO data to device */ len = MIN(s->async_len, ESP_FIFO_SZ); len = MIN(len, fifo8_num_used(&s->fifo)); @@ -602,7 +601,12 @@ static void do_dma_pdma_cb(ESPState *s) } esp_dma_ti_check(s); - } else { + break; + + case STAT_DI: + if (!s->current_req) { + return; + } /* Copy device data to FIFO */ len = MIN(s->async_len, esp_get_tc(s)); len = MIN(len, fifo8_num_free(&s->fifo)); @@ -620,6 +624,7 @@ static void do_dma_pdma_cb(ESPState *s) } esp_dma_ti_check(s); + break; } } From patchwork Tue Feb 13 19:40:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13555601 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 14035C48BC4 for ; Tue, 13 Feb 2024 19:49:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZygx-0001Om-Jp; Tue, 13 Feb 2024 14:43:43 -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 1rZygn-0000lV-7G for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:34 -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 1rZygi-0006VZ-6W for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:32 -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=lS57P6Rml/Felg/6eLbNqxqYrNxDTK3LO+WE0zSQ2p0=; b=hIKg0CaAJ8SgIZgjvzJ25LxAsn ZRpKvO117lEXGTmJ3ioanNpxYit16S6W2L25n2UdC98A+e9eIfuiYKQZLVuOkiZbi9MVrf9ADtiZO Zsd2yBH/8thGp2Xb0i3aOg6rj12EtOAfTdA7XGIxCqOdBb1opIsOO/fEaV42tzgHid/8mffmhNyN+ VZ7UXYHmdc7h0esBFwOSfZT5oth1VSDrYYbkOmCBh7MFrX4sx7H87cOHXX85d/rZu2SpSHT0CW1ks m8umn8+KUOphpOPDWbJNExcsI2jA2ctpHU0z8kHTTT/+/TQyo8Ws08cySUTz+94c3Niv3ZaKqRnhn BHm5kaachsd8GbHMkMrCceXkmvE8o5f/ZQYA5jLs+1PrT1f+Apa91T7JkgInqbhJvMhqbsMOtbZq9 gUfTHrIBvG9TDIJ0rrG26bEs98RPbNrZ2ONuHGE49xFCnISyAgM6+Qr+zdUifBE9qdi8v167a7onf PYe7FWrccXQlp4UBNCgYXXF/niqrz44NSvpDzbp9Ts864KKaQGqwAFPzQ4rtxv0uXFVCim2+SCn6m FU6aU3qatjxb96ZOBZ9Rc6mEvKGl6vtmt7apscf4GGiLuyu3Q6B7AftB1HFw+rtk5Uc7U6uqTQcNK eJBjwSpvlR88PwG0JmWEZuGIAHqrZknI31q5jjMss=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfq-0008m4-2C; Tue, 13 Feb 2024 19:42:37 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:04 +0000 Message-Id: <20240213194052.1162753-41-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 40/88] esp.c: convert esp_do_nodma() to switch statement based upon SCSI 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 Currently only the DATA IN and DATA OUT phases are supported. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-41-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 54 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index f6d05b0de7..c1b44e5f18 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -786,7 +786,6 @@ static void esp_do_dma(ESPState *s) static void esp_do_nodma(ESPState *s) { - int to_device = (esp_get_phase(s) == STAT_DO); uint8_t buf[ESP_FIFO_SZ]; uint32_t cmdlen; int len, n; @@ -823,38 +822,55 @@ static void esp_do_nodma(ESPState *s) return; } - if (!s->current_req) { - return; - } - - if (s->async_len == 0) { - /* Defer until data is available. */ - return; - } - - if (to_device) { + switch (esp_get_phase(s)) { + case STAT_DO: + if (!s->current_req) { + return; + } + if (s->async_len == 0) { + /* Defer until data is available. */ + return; + } 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); s->async_buf += len; s->async_len -= len; s->ti_size += len; - } else { + + if (s->async_len == 0) { + scsi_req_continue(s->current_req); + return; + } + + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + break; + + case STAT_DI: + if (!s->current_req) { + return; + } + if (s->async_len == 0) { + /* Defer until data is available. */ + return; + } if (fifo8_is_empty(&s->fifo)) { fifo8_push(&s->fifo, s->async_buf[0]); s->async_buf++; s->async_len--; s->ti_size--; } - } - if (s->async_len == 0) { - scsi_req_continue(s->current_req); - return; - } + if (s->async_len == 0) { + scsi_req_continue(s->current_req); + return; + } - s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + break; + } } static void esp_pdma_cb(ESPState *s) From patchwork Tue Feb 13 19:40:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13555566 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 0F405C4829A for ; Tue, 13 Feb 2024 19:43:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyh0-0001hv-Fs; Tue, 13 Feb 2024 14:43:46 -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 1rZygw-0001HA-ME for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:42 -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 1rZygv-0006Wb-58 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:42 -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=FAt0pCq8njB+6+50rTsiZHlccpr9qzd45MqpAKHkmm0=; b=J6Hd3MQ0kDl5ECo3Jv77nNJOY9 /DXDNOxpN5ppfEDlXIdSKqKGNtohLV/dxVcdpxUfIzoW30wSZufmnM4VYv7NLMeBpCPA60QoA01yG kTJpbxsHTenxyS3OZhUEFsFsF5GOnIxQHJFMlE6OmKhNgZZH8EeYUZsb6R2qE92LDVGp7HXYhYuDP nlO3gODjK6CZKDxbe3C5BLjLqKVGjwwOeFRg76sWZQVDJWgG8iFc3YJM8DbPn7+/X+qKmtMm12KCD SQi1qUVvTXbfkoRNvsPdAtRN+r4Uj01sCNS5TyVw3QqPxsIKoffmrp0VJFaP1SZTM64dW0iXBSMsW IkHclMwkQTYKl9gQB7EhII6DRjdJOgRTaTkXGn86drmW+60pABVj2QiguBecrBt40OpaiL3mTyAXL u79BZ4uqRMZRPHtazEm91H/Yl1KD2541lTnANLTNehu5/rqTxyVbo/UJ6dF2Y3RD2xRhK9ZdAMbF7 bmqDSwoBPeqsNBHpC+FpJapuS5dibQT/9l8LHKQs0+OGqY4FJTUzJqwhRZl435Tz2cUii1kq0Psjp Rsxwzl2tC13xO+hCC5ds11ox1RwB4eM1PEWasQD+eDG5A4MpdLo+XrGw6b9wC0LwQFD6tMwp9AqH1 /4QgU/K+PR2U8UEBjXUWt360NGQer3GYuLm4Yzf5A=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyft-0008m4-L4; Tue, 13 Feb 2024 19:42:41 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:05 +0000 Message-Id: <20240213194052.1162753-42-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 41/88] esp.c: convert esp_do_dma() do_cmd path to check for SCSI phase instead 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 Currently do_cmd is used to determine whether MESSAGE OUT and COMMAND phase data is being accumulated in cmdfifo. Update esp_do_dma() to check directly for these two SCSI phases instead. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-42-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index c1b44e5f18..22739d3875 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -635,11 +635,10 @@ static void esp_do_dma(ESPState *s) int n; len = esp_get_tc(s); - if (s->do_cmd) { - /* - * handle_ti_cmd() case: esp_do_dma() is called only from - * handle_ti_cmd() with do_cmd != NULL (see the assert()) - */ + + switch (esp_get_phase(s)) { + case STAT_MO: + case STAT_CD: cmdlen = fifo8_num_used(&s->cmdfifo); trace_esp_do_dma(cmdlen, len); if (s->dma_memory_read) { @@ -683,10 +682,8 @@ static void esp_do_dma(ESPState *s) s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); } - return; - } + break; - switch (esp_get_phase(s)) { case STAT_DO: if (!s->current_req) { return; From patchwork Tue Feb 13 19:40:06 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: 13555572 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 BAAD0C48260 for ; Tue, 13 Feb 2024 19:44:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyhN-0003Hh-5Q; Tue, 13 Feb 2024 14:44: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 1rZyh1-0001rf-2R for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:48 -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 1rZygx-0006X1-Vy for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:45 -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=JXa+2Gs+6maY4QFvhNHnOxGTM8gMrR5n+minckNx8qc=; b=VXH4Bmp+DsnY395VsXOGUKt/28 Mqf4HBIbIwmbcFjEPM7sSoE98BpcMPZPzuhkQ7MrMJjpntePNK6ck8aZUlb861VJu1Vn8Qlo3IzGr ow100fbdTRmmyYWUb872XOWA6ohowMpxWpRDX5XlAb1anvXFp0brXPTpgFYGmQMdUXkf12zKmkY8q KWUc9Rie6Frke5zsBqQ/cHYRJ+/5GAYG8Na7XcSbXZikpU6O6sgNfyMrINs0CULe5z7lRSMtUAkt2 bpKtQw5+Q21AuY/iTNOeuszF+yzuJPdRYN/OHMjEWrcYH2Okl7b7K/b9woOyZfHViIvh7ksT4fOLu mjFZtlXia/kKPK8EEgnunPb7SpkbzmXd3EFODjSEh6xIJeHrM32erzqaXHIkmAHDcYBB92LfCmIHj GIv1ADW/6jR6RrURIbD8cZXTPQF+KEb6sYPMgYH692vMKMwNRf9SxzvKFi9sm1Xe4isKTzWEjSgqu usZKXRDt87CFyRByEPxroxCo+xgZ991x8svVVKHhG1EiRWRLA6fGbqOZdYvRz2J9BYvPLO8jUXo+m BJoID09wlrhdyvIEbLPk6wmnoqL/4B/mKWRRfzUi+3KBV8TKONK2lhiLmL8W3vS8Dx5hIyxEL6/c2 MlsbK7Yd2chAOogBxYfP5lwjPuVvB25x2JEQPQ+hw=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyfx-0008m4-7c; Tue, 13 Feb 2024 19:42:45 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:06 +0000 Message-Id: <20240213194052.1162753-43-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 42/88] esp.c: convert do_dma_pdma_cb() do_cmd path to check for SCSI phase instead 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 Currently do_cmd is used to determine whether MESSAGE OUT and COMMAND phase data is being accumulated in cmdfifo. Update esp_do_dma() to check directly for these two SCSI phases instead. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-43-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 22739d3875..b48e020689 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -546,7 +546,9 @@ static void do_dma_pdma_cb(ESPState *s) int len; uint32_t n; - if (s->do_cmd) { + switch (esp_get_phase(s)) { + case STAT_MO: + case STAT_CD: /* Copy FIFO into cmdfifo */ n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); n = MIN(fifo8_num_free(&s->cmdfifo), n); @@ -578,10 +580,8 @@ static void do_dma_pdma_cb(ESPState *s) s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); } - return; - } + break; - switch (esp_get_phase(s)) { case STAT_DO: if (!s->current_req) { return; From patchwork Tue Feb 13 19:40:07 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: 13555571 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 B0C8BC48260 for ; Tue, 13 Feb 2024 19:44:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyh3-000279-FY; Tue, 13 Feb 2024 14:43:49 -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 1rZygy-0001dN-O3 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:44 -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 1rZygw-0006X3-WD for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:44 -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=FQzD0zwlDAHBmJoAyYJ+3VSSgw7i9cg0yGepAyKd3Fg=; b=lPkPaZQrxf0fXrdu7phcFuXAp8 2ST3k8bQDMGgX8M6Xj72CB1gD7B+YABBCrIcMBG9g0+u234JNOxcgwC9OEBH9N9pOGxuS0WlVShmP lYYjI8TWukhC5fSg8jo6A3gxzs83c+qWxKgNhM3RMia2RD+unQtU3P4rEFasDti40hR2q8iJxlHPy Ezgls3QRku4CcoqSxnATLFRz+r2SS1b30YFwmUnOGgUGNpPprMLVsqqYedqjM8fKEmbebNMC5bnrj 5x0d47rYxtka2nVK4ePypLxgl4VIFbtw8/KeLHlkTYaA9L6AcV+JYU35ETZuMpluj3l2mKJhHUnpY k59A0UNF+afHOxLIssRXSZFnjDIn4yhAXm6OOPZdKsCd3Y8/YbbZ6wPrmFX16AY9d3WcLNsNwYw07 oB+q2id1OBPdLAIigzihShOj8+LOuuuCtnnQf5siQ7tbK/WHx06Lvo4FucmzewQKsgFD6+ipOV9hu VkNeX71UYy/K3X+RTIgDAHc/PhYFthxGvAA2HuKQnSk+ApyheUsb8pNz00foGNSeN0OpRFnffAE1C lI0H8riQOBuqfpLCwwkOwQg8jOPJc5RYU+sJ57geYqn8W4XH9sS1W3ajBbvooTvhcu2jcP7soR3oe rgi2efiSWbuu1vOfvxG4OFVhvZa2joV9fysO+b89Y=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyg1-0008m4-Al; Tue, 13 Feb 2024 19:42:45 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:07 +0000 Message-Id: <20240213194052.1162753-44-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 43/88] esp.c: convert esp_do_nodma() do_cmd path to check for SCSI phase instead 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 Currently do_cmd is used to determine whether MESSAGE OUT and COMMAND phase data is being accumulated in cmdfifo. Update esp_do_dma() to check directly for these two SCSI phases instead. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-44-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index b48e020689..14759ada78 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -787,7 +787,9 @@ static void esp_do_nodma(ESPState *s) uint32_t cmdlen; int len, n; - if (s->do_cmd) { + switch (esp_get_phase(s)) { + case STAT_MO: + case STAT_CD: /* Copy FIFO into cmdfifo */ n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); n = MIN(fifo8_num_free(&s->cmdfifo), n); @@ -816,10 +818,8 @@ static void esp_do_nodma(ESPState *s) s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); } - return; - } + break; - switch (esp_get_phase(s)) { case STAT_DO: if (!s->current_req) { return; From patchwork Tue Feb 13 19:40:08 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: 13555583 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 9D1E6C48260 for ; Tue, 13 Feb 2024 19:46:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyhD-0002hg-Ta; Tue, 13 Feb 2024 14:44:02 -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 1rZyh1-0001rW-1w for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:48 -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 1rZygy-0006XF-Oa for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:46 -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=Jph3CVd/Fj+VABXOF8+TEldU+YdJgSoPah+PCOJK10w=; b=AQXBtAxG1xccolyIZu/VwS0fMS 8R3Zc2unOPnQvxYErbBtUjdWWprrm8S9UDmLR4bB3zsViTb7ajB3VFxgSqNRokRVlPc+ig9n1QlfO IrydA/JlFSe+rdUwb4B8mpgBxUG1AN1BA6fVrbbYM+osm6O3GCgYBS2MHh/F1E5FGYLORb2cPsNXR Sio7YrTVahJbpuOXLCPZKaOhHetmeVL+57ey4Y0MkL4R97gy+mna6MX4818ICJ7T2hNQsm0HwYNzP VIs3s442ctXOIO/oqwYQZVBNcYQuA6JS3GWFJWt4tiQYyjRZy9h0nh8aI/La22Z+TV6DYQltoMDrk 4cYJmT0FOOQuHvKWq4zmrsQK1lqTqKY64nlsQvOL1O7PKqBHxSxlKYX1xxeDMNeUCdzMZg34e571e +UDhr6WZkK1GUmdrzdh0lpuDqtPkiBe+/sGYoaxhAjSvw8APre8X1OA1HlPY+HPrt8/SSHMvPDYO3 yFQGCKBXNyMbOwakz8D1mkt0ULcyuOEWOcCEsIdcHJVO1UpyD2OrFYo49WXiho3GNnfIzy0SlAM5I B77DJ/FS/PpyBFqZWi/W8+iGaa4rdSt30LbcEOW1tuYT/SIN2hzdzbcayQVCoT3zo7/UjqArTiNoN oaSQbaFaFVyOooFUMsv0OTvS5u/pIOFwI2L3seQCs=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyg1-0008m4-Nu; Tue, 13 Feb 2024 19:42:49 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:08 +0000 Message-Id: <20240213194052.1162753-45-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 44/88] esp.c: convert esp_reg_write() do_cmd path to check for SCSI phase instead 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 Currently do_cmd is used to determine whether MESSAGE OUT and COMMAND phase data is being accumulated in cmdfifo. Update esp_do_dma() to check directly for these two SCSI phases instead. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-45-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 14759ada78..e679b1c39b 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1207,7 +1207,7 @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) s->rregs[ESP_RSTAT] &= ~STAT_TC; break; case ESP_FIFO: - if (s->do_cmd) { + if (esp_get_phase(s) == STAT_MO || esp_get_phase(s) == STAT_CD) { if (!fifo8_is_full(&s->fifo)) { esp_fifo_push(&s->fifo, val); esp_fifo_push(&s->cmdfifo, fifo8_pop(&s->fifo)); From patchwork Tue Feb 13 19:40:09 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: 13555588 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 CB911C4829A for ; Tue, 13 Feb 2024 19:46:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyhL-0002ua-G7; Tue, 13 Feb 2024 14:44:07 -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 1rZyh1-0001rN-1N for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:48 -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 1rZygx-0006XX-W8 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:45 -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=6leqQy8il9T0BgowRDTi4peOmLDXSmBsnwCsxoyV74s=; b=sSDiG3lZ5hVUUM33A79WFzrjqs WGsrSipasZ8e58J+k/RONQJDWW0uiEXDtF+8c2iy22x+mT+tmY2dfF/TpGj1T/Kdsd5C46PfQ9YI9 d104tO+HwdkUzpwcEC+XSN5T4yOOAV4LEYiNU4k1pU8XX4bVIBpNQbn5IqWanWCDY60o33NNgcmci VCE294afmoy3d5jQj5G7bRI7tMVqdKB9+jCzSZlnZYWPOMqS6yyEpiikXgJv/7tJ6AXTomns7PYYj Wt4K03aayvEWBYpe0cq94g77ftKXssOuV3G086x0MicaxofCGTQE3kexYCH5K4XN7uBXdsxpmg4P4 MFYU8XVOLzyJeQtFMumVe2epQpfd2ZmuI9QpGQWiDFB1Uifes8xzW/nYMRuCwtifSQzK9H/TVhyim AHWBjWCIGKKFRun+ZLX+8WeCgd9FLxvjyDSyloHCg4uXCT/xC30B9icZsXIJCTJrlU4jfAaLlS5xl lttqlY+No8woUcjyQEfJHC5VCO8KKTTSKDD/Gdsn4zB8Rjlxn766pKP94SC3e1stWNp5o+Ht6WZay BOYCqmvTSbqRAh6xD7zIJqxSZiG3YBqICOjBtK4SzoQW9sV8Z8N5sa0DyUyh1wAEh7JBizs/+quYo A/1hDZKgByB+HX6/vayK2bpepa1WZxp1uswD0WCmk=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyg5-0008m4-AU; Tue, 13 Feb 2024 19:42:52 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:09 +0000 Message-Id: <20240213194052.1162753-46-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 45/88] esp.c: remove do_cmd from 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 the accumulation of the CDB is handled by SCSI phase, there is no need for a separate variable to control it. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-46-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index e679b1c39b..1f7dff4ca6 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -380,7 +380,6 @@ static void satn_pdma_cb(ESPState *s) if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) { s->cmdfifo_cdb_offset = 1; - s->do_cmd = 0; do_cmd(s); } } @@ -400,13 +399,11 @@ static void handle_satn(ESPState *s) cmdlen = get_cmd(s, ESP_CMDFIFO_SZ); if (cmdlen > 0) { s->cmdfifo_cdb_offset = 1; - s->do_cmd = 0; do_cmd(s); } else if (cmdlen == 0) { if (s->dma) { esp_raise_drq(s); } - s->do_cmd = 1; /* Target present, but no cmd yet - switch to command phase */ s->rregs[ESP_RSEQ] = SEQ_CD; esp_set_phase(s, STAT_CD); @@ -428,13 +425,11 @@ static void handle_s_without_atn(ESPState *s) cmdlen = get_cmd(s, ESP_CMDFIFO_SZ); if (cmdlen > 0) { s->cmdfifo_cdb_offset = 0; - s->do_cmd = 0; do_cmd(s); } else if (cmdlen == 0) { if (s->dma) { esp_raise_drq(s); } - s->do_cmd = 1; /* Target present, but no cmd yet - switch to command phase */ s->rregs[ESP_RSEQ] = SEQ_CD; esp_set_phase(s, STAT_CD); @@ -453,7 +448,6 @@ static void satn_stop_pdma_cb(ESPState *s) if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) { trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); - s->do_cmd = 1; s->cmdfifo_cdb_offset = 1; esp_set_phase(s, STAT_CD); s->rregs[ESP_RSTAT] |= STAT_TC; @@ -478,7 +472,6 @@ static void handle_satn_stop(ESPState *s) cmdlen = get_cmd(s, 1); if (cmdlen > 0) { trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); - s->do_cmd = 1; s->cmdfifo_cdb_offset = 1; esp_set_phase(s, STAT_MO); s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; @@ -488,7 +481,6 @@ static void handle_satn_stop(ESPState *s) if (s->dma) { esp_raise_drq(s); } - s->do_cmd = 1; /* Target present, switch to message out phase */ s->rregs[ESP_RSEQ] = SEQ_MO; esp_set_phase(s, STAT_MO); @@ -567,7 +559,6 @@ static void do_dma_pdma_cb(ESPState *s) } /* Command has been received */ - s->do_cmd = 0; do_cmd(s); } else { /* @@ -669,7 +660,6 @@ static void esp_do_dma(ESPState *s) } /* Command has been received */ - s->do_cmd = 0; do_cmd(s); } else { /* @@ -805,7 +795,6 @@ static void esp_do_nodma(ESPState *s) } /* Command has been received */ - s->do_cmd = 0; do_cmd(s); } else { /* @@ -949,7 +938,6 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) int to_device = (esp_get_phase(s) == STAT_DO); uint32_t dmalen = esp_get_tc(s); - assert(!s->do_cmd); trace_esp_transfer_data(dmalen, s->ti_size); s->async_len = len; s->async_buf = scsi_req_get_buf(req); @@ -1012,7 +1000,6 @@ void esp_hard_reset(ESPState *s) fifo8_reset(&s->fifo); fifo8_reset(&s->cmdfifo); s->dma = 0; - s->do_cmd = 0; s->dma_cb = NULL; s->rregs[ESP_CFG1] = 7; From patchwork Tue Feb 13 19:40:10 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: 13555599 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 36DB3C48260 for ; Tue, 13 Feb 2024 19:49:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyhO-0003Zq-BW; Tue, 13 Feb 2024 14:44: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 1rZyh2-00024C-S8 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:49 -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 1rZyh1-0006YG-4E for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:48 -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=31Pv7/3D3sVU7lCfzBxymFeAjRw7ZoiBrks9lmvWPgo=; b=V1/vUDW0FQVf9fQ6rTAyXDgyFQ LUyen5KQPj2fdSaUqtwkHmrXyoGFXMfEMe6GD9V6RTBqJdfLldJ6LsQ+2bdhinAYbvVHKExM0Uw/S CEazaADs/9R69I5TgTQJyORUp3jSJl1kLccajQjJkQSYxx07yIZOaj/EYOhKknH90PzTPV/xBs1M1 K5U9+27KAuE/CmCxnUUAprRN4nujm+HziS80Z2nvwBtBoqbz2qkrn9Rn8tnsFY/e7TyM+i+t7F/59 rbVNSrWfGpg6qc1In4HiRc/GvPw47cWobn0r1EPtfcfecXabLCNnJk9Pl27HG6aIlAvo3OKiFZN9b 8dYuwXdEuxmtF79T1doNVcvC4EXrFxu297B4R5hUFsypsmIeOC1ocUvd4YMr8Slc23u56BgH/bLfb 2j7O4t0FMlxaAF+881+YjUA/HmWN9qmWOgUD6wa0HygB+obZ/U/umNv6+jpuS23Qw6oO6bcF+dbpM DTZFJSBC5o8mPo5PWJ5lMdfVxB9hkByMiJJI9YmEh2xUPfXGt/5m9ZT9yDk5UNEI3LJrlFlfM9A9y 3xsNT8PLENFvrT+gE7DXNpxnf4QTWsNlTdYaV4h23ZVwh6nsYRK33j/iBh9qho5SGh98I+rw4wc95 kTRAbLA5h1fi75YNOkOSZG4bsXmr0vkh4klj20Nsg=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyg8-0008m4-TN; Tue, 13 Feb 2024 19:42:56 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:10 +0000 Message-Id: <20240213194052.1162753-47-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 46/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in esp_do_dma() 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 makes it clearer that ATN is asserted until the end of the next TI command in the MESSAGE OUT phase. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-47-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 1f7dff4ca6..2f54fd1285 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -629,6 +629,31 @@ static void esp_do_dma(ESPState *s) switch (esp_get_phase(s)) { case STAT_MO: + if (s->dma_memory_read) { + len = MIN(len, fifo8_num_free(&s->cmdfifo)); + s->dma_memory_read(s->dma_opaque, buf, len); + fifo8_push_all(&s->cmdfifo, buf, len); + esp_set_tc(s, esp_get_tc(s) - len); + s->cmdfifo_cdb_offset += len; + } else { + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + s->cmdfifo_cdb_offset += n; + } + + esp_set_pdma_cb(s, DO_DMA_PDMA_CB); + esp_raise_drq(s); + + /* ATN remains asserted until TC == 0 */ + if (esp_get_tc(s) == 0) { + esp_set_phase(s, STAT_CD); + s->rregs[ESP_RSEQ] = SEQ_CD; + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + } + break; + case STAT_CD: cmdlen = fifo8_num_used(&s->cmdfifo); trace_esp_do_dma(cmdlen, len); @@ -641,36 +666,15 @@ static void esp_do_dma(ESPState *s) n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); n = MIN(fifo8_num_free(&s->cmdfifo), n); fifo8_push_all(&s->cmdfifo, buf, n); - esp_set_tc(s, esp_get_tc(s) - n); esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); - - /* Ensure we have received complete command after SATN and stop */ - if (esp_get_tc(s) || fifo8_is_empty(&s->cmdfifo)) { - return; - } } trace_esp_handle_ti_cmd(cmdlen); s->ti_size = 0; - if (esp_get_phase(s) == STAT_CD) { - /* No command received */ - if (s->cmdfifo_cdb_offset == fifo8_num_used(&s->cmdfifo)) { - return; - } - + if (esp_get_tc(s) == 0) { /* Command has been received */ do_cmd(s); - } else { - /* - * Extra message out bytes received: update cmdfifo_cdb_offset - * and then switch to command phase - */ - s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); - esp_set_phase(s, STAT_CD); - s->rregs[ESP_RSEQ] = SEQ_CD; - s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); } break; From patchwork Tue Feb 13 19:40:11 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: 13555596 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 2E061C48260 for ; Tue, 13 Feb 2024 19:49:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyhP-0003i8-5n; Tue, 13 Feb 2024 14:44:11 -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 1rZyh7-0002hh-JU for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:57 -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 1rZyh5-0006ZP-2r for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:53 -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=o7p7DnWA6qnww2W25YEv6RDerIM7CBNg9Bc5riyx9NA=; b=N33j2mHOqpr6+v1Lc8TnhzJzev O+sKNHjfTx+YgiBWKC8nige0aWcgx7yxojN+rnRWe3P31YsQ3GINPVvuoyHXkjq90LTNDBRruAW2G wRDQnF5q01NUZiQmuSTtl6Y7tM5Yhk4aCnZr/XcsNcvEBqo8Ekwfw1yBb+695mBdmORK/7/0eOvr/ jr+uKrwR1lMYZFZBuQyqSOJ8DIv7GYYlKDPA9dmNiXzGjGPF5s37Bgw7zB35PWZF3ifzLkwtZTp2d 0NCf7qGBmyGGTHINxLD991asxp1ZsWMGhT7YbqMJqCYmVQLqcQoTd3LiLkbOs0an0TrBb08+QnzZm KJLd9HeNEXJFV3ky2QGa8+y4yPuNBa46//4eWPSEbubMK7fIR3cfEY+ievl9FTPsNiS8Pitfu6ewD ndrh2tYuB7WR/UoV5tlPd3HRAAOaBSR7tTqfELSXUchbZ/5OEvFdb4636F2YtkrM1i5fNvTpxZVgu rK6uA2SQ6fPl5+J/RzYZR6VmBrLUeD2hjF+IsgQJ5C39RjRPL4JJC4SZvlL0xT5ZTEMlZyasrH30X +qVGxneYEx6Vo5zQeVs5n6UPZHzxlz3ME4FrS2z67fjGkCCdlSq3Pf9rEVT1xFhEJiU0eWXzzuaY6 THKvblzIsZUuHXj8KM7SjNI8/44e9rhLVi5cGwnRI=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygC-0008m4-Fv; Tue, 13 Feb 2024 19:43:00 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:11 +0000 Message-Id: <20240213194052.1162753-48-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 47/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in do_dma_pdma_cb() 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 makes it clearer that ATN is asserted until the end of the next TI command in the MESSAGE OUT phase. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-48-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 66 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 2f54fd1285..7ab195f884 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -536,36 +536,30 @@ static void do_dma_pdma_cb(ESPState *s) { uint8_t buf[ESP_CMDFIFO_SZ]; int len; - uint32_t n; + uint32_t n, cmdlen; + + len = esp_get_tc(s); switch (esp_get_phase(s)) { case STAT_MO: - case STAT_CD: - /* Copy FIFO into cmdfifo */ - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); - - /* Ensure we have received complete command after SATN and stop */ - if (esp_get_tc(s) || fifo8_is_empty(&s->cmdfifo)) { - return; + if (s->dma_memory_read) { + len = MIN(len, fifo8_num_free(&s->cmdfifo)); + s->dma_memory_read(s->dma_opaque, buf, len); + fifo8_push_all(&s->cmdfifo, buf, len); + esp_set_tc(s, esp_get_tc(s) - len); + s->cmdfifo_cdb_offset += len; + } else { + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + s->cmdfifo_cdb_offset += n; } - s->ti_size = 0; - if (esp_get_phase(s) == STAT_CD) { - /* No command received */ - if (s->cmdfifo_cdb_offset == fifo8_num_used(&s->cmdfifo)) { - return; - } + esp_set_pdma_cb(s, DO_DMA_PDMA_CB); + esp_raise_drq(s); - /* Command has been received */ - do_cmd(s); - } else { - /* - * Extra message out bytes received: update cmdfifo_cdb_offset - * and then switch to command phase - */ - s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); + /* ATN remains asserted until TC == 0 */ + if (esp_get_tc(s) == 0) { esp_set_phase(s, STAT_CD); s->rregs[ESP_RSEQ] = SEQ_CD; s->rregs[ESP_RINTR] |= INTR_BS; @@ -573,6 +567,30 @@ static void do_dma_pdma_cb(ESPState *s) } break; + case STAT_CD: + cmdlen = fifo8_num_used(&s->cmdfifo); + trace_esp_do_dma(cmdlen, len); + if (s->dma_memory_read) { + len = MIN(len, fifo8_num_free(&s->cmdfifo)); + s->dma_memory_read(s->dma_opaque, buf, len); + fifo8_push_all(&s->cmdfifo, buf, len); + esp_set_tc(s, esp_get_tc(s) - len); + } else { + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + + esp_set_pdma_cb(s, DO_DMA_PDMA_CB); + esp_raise_drq(s); + } + trace_esp_handle_ti_cmd(cmdlen); + s->ti_size = 0; + if (esp_get_tc(s) == 0) { + /* Command has been received */ + do_cmd(s); + } + break; + case STAT_DO: if (!s->current_req) { return; From patchwork Tue Feb 13 19:40:12 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: 13555597 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 C6ED5C48260 for ; Tue, 13 Feb 2024 19:49:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyhM-00035V-7a; Tue, 13 Feb 2024 14:44:08 -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 1rZyhB-0002pa-DP for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:59 -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 1rZyh8-0006dB-Qr for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:43:57 -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=ja7JRkqFqFJV0kPbamIs3T/PoZGNFQ6OhAooTnpxG2U=; b=Z20UO9taJFl8swF4D+W5c000Od oCAz3r497yW4HOlhpRm1V9cFQkweOwHbw/Uc2uTgvxKzvK5dyUi9Jmauf42S49P6Zeo5dPhCqfTp2 YTqG51ZmklG6+z3aQ5UExZYQ4tHUacTyBbAF303YdA7fwWWjGdsn84Jz6Po3s291uLHKOS1s6Su2E bR+t5Z7Yi2K9qWSU1m703sB7ORIuinfUBblxFOdi7GiJhvMU953gjIcQ42GmjTGQa9gPH5VSza0uz jFk2g6An/5U9AKdiH7iNxHY3duJHJEAKrDYBFiFNO+0YE0RWtgX88/OXmfK6ILyJv5DEyQ6KZ1JIo 5ioCdsYzw0I4bqt+jffwqyL3419sypkEckKkHburlOouO9M3Gki3GW5eoDQDEKlN1K2TXYCR6ptXE i8wITDSc2OffRgEtSU6sEd6hkqOpw5EVlvpZlK7m2s54l9+8MTsOD3tGrDRLidEQyy/wxGO8hxiAY PIBZUvbM3tF3ZHh+zTszZrBRJ566n/7IF+EBmyARUvL+2FZ+PopplTK/kIGV9tLoW39Ew2QCQNKSD 9PTjkhBlzVcuTGezJ+tZv9pHaxZNxaARttbFzxxvfNjdqjMCj+6EwAQAeMe2ouj0hr/qhxqxOOmFW SHHug+SRRQjz0YYQSRQHLFcSsJLEKUX3rMkVHlhMI=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygG-0008m4-J3; Tue, 13 Feb 2024 19:43:04 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:12 +0000 Message-Id: <20240213194052.1162753-49-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 48/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in esp_do_nodma() 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 makes it clearer that ATN is asserted until the end of the next TI command in the MESSAGE OUT phase. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-49-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 7ab195f884..81144ace83 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -801,6 +801,23 @@ static void esp_do_nodma(ESPState *s) switch (esp_get_phase(s)) { case STAT_MO: + /* Copy FIFO into cmdfifo */ + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + s->cmdfifo_cdb_offset += n; + + /* + * Extra message out bytes received: update cmdfifo_cdb_offset + * and then switch to command phase + */ + s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); + esp_set_phase(s, STAT_CD); + s->rregs[ESP_RSEQ] = SEQ_CD; + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + break; + case STAT_CD: /* Copy FIFO into cmdfifo */ n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); @@ -810,25 +827,14 @@ static void esp_do_nodma(ESPState *s) cmdlen = fifo8_num_used(&s->cmdfifo); trace_esp_handle_ti_cmd(cmdlen); s->ti_size = 0; - if (esp_get_phase(s) == STAT_CD) { - /* No command received */ - if (s->cmdfifo_cdb_offset == fifo8_num_used(&s->cmdfifo)) { - return; - } - /* Command has been received */ - do_cmd(s); - } else { - /* - * Extra message out bytes received: update cmdfifo_cdb_offset - * and then switch to command phase - */ - s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); - esp_set_phase(s, STAT_CD); - s->rregs[ESP_RSEQ] = SEQ_CD; - s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); + /* No command received */ + if (s->cmdfifo_cdb_offset == fifo8_num_used(&s->cmdfifo)) { + return; } + + /* Command has been received */ + do_cmd(s); break; case STAT_DO: From patchwork Tue Feb 13 19:40:13 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: 13555577 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 C4834C48260 for ; Tue, 13 Feb 2024 19:45:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyhN-0003UP-Vs; Tue, 13 Feb 2024 14:44: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 1rZyhE-0002qA-B3 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:44:02 -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 1rZyhC-0006eW-QP for qemu-devel@nongnu.org; Tue, 13 Feb 2024 14:44:00 -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=OX9tAdGC0Xi6/uPf3DfJDeljWUSeH7tBFFTxYDRwDNA=; b=Aj7bUdNs5OqoQw0TvyrK1kR1ln EBPndOx+X58M82TjjGsPsqno3vBLRDbP6OQ0ZI3vMZNHm/CVDWDyPbJGbIDaGPP4DQ2IvM3q+Zvv7 svf/+zYuKrfkHzpWa1DrtU1eEBCc6BjeAH1Ywhu2MRl4f5eChbRnkguwHYXXX+pJ6QASTIU7Hjsql wavepHN6WhKUuUOYdtcthSuWr1XGtGjL6a5xEtuds+BdfV3v2QJKsjnlWqFQ8kZiJccGr92BjCmTR L5kB6fPNN94qxoU8LBIevBJkuhbnOeW5+lfh2xTlKtME9OqGy5GSLl/sFAcQUVY99rJ7qNQ+lzXdV RPAepa4+/iC+x4kvoIraE36SX+mlA/mZnAiWmO25Rt6AR0AY4M+JAN4cZrGqD2ubn4cdoIf5xhi54 lgjqVb2/8U5Y5o69CY6EAOCBsZ5CdvEmJVNbZ7pa51Kc5gst52+BAuOb33NbQaSW3RZJ9wPVC+g2S Nn04Wa2I1RMq7cSyZtpn7hMfnGRmxxSRc2twUbiTpNilg9V1es2kTfnWfXBVGtT7b1qwPN6DSNfdf hx3Mdn0qVXMjk+GXHoWr8vMLCjyvcxq2diAy/6LL6SbIhdS85v6o4odMqlvnIyBumjUHpDr+yYhrS 4ZTWpQtEej1Bk9VgwA0bxNFBd6iWqO1uO+/NDLFBs=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygK-0008m4-5L; Tue, 13 Feb 2024 19:43:08 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:13 +0000 Message-Id: <20240213194052.1162753-50-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 49/88] esp.c: move CMD_SELATN end of message phase detection to esp_do_dma() and do_dma_pdma_cb() 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 special logic in satn_pdma_cb() is now no longer required since esp_do_dma() can be used as a direct replacement. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-50-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 75 +++++++++++++++++++++++++------------------ include/hw/scsi/esp.h | 1 - 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 81144ace83..f8c20d0584 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -261,6 +261,9 @@ static int esp_select(ESPState *s) return 0; } +static void esp_do_dma(ESPState *s); +static void esp_do_nodma(ESPState *s); + static uint32_t get_cmd(ESPState *s, uint32_t maxlen) { uint8_t buf[ESP_CMDFIFO_SZ]; @@ -368,45 +371,26 @@ static void do_cmd(ESPState *s) do_command_phase(s); } -static void satn_pdma_cb(ESPState *s) -{ - uint8_t buf[ESP_FIFO_SZ]; - int n; - - /* Copy FIFO into cmdfifo */ - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); - - if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) { - s->cmdfifo_cdb_offset = 1; - do_cmd(s); - } -} - static void handle_satn(ESPState *s) { - int32_t cmdlen; - if (s->dma && !s->dma_enabled) { s->dma_cb = handle_satn; return; } - esp_set_pdma_cb(s, SATN_PDMA_CB); + esp_set_pdma_cb(s, DO_DMA_PDMA_CB); if (esp_select(s) < 0) { return; } - cmdlen = get_cmd(s, ESP_CMDFIFO_SZ); - if (cmdlen > 0) { - s->cmdfifo_cdb_offset = 1; - do_cmd(s); - } else if (cmdlen == 0) { - if (s->dma) { - esp_raise_drq(s); + + esp_set_phase(s, STAT_MO); + + if (s->dma) { + esp_do_dma(s); + } else { + if (get_cmd(s, ESP_CMDFIFO_SZ)) { + s->cmdfifo_cdb_offset = 1; + do_cmd(s); } - /* Target present, but no cmd yet - switch to command phase */ - s->rregs[ESP_RSEQ] = SEQ_CD; - esp_set_phase(s, STAT_CD); } } @@ -558,6 +542,21 @@ static void do_dma_pdma_cb(ESPState *s) esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); + switch (s->rregs[ESP_CMD]) { + case CMD_SELATN | CMD_DMA: + if (fifo8_num_used(&s->cmdfifo) >= 1) { + /* First byte received, switch to command phase */ + esp_set_phase(s, STAT_CD); + s->cmdfifo_cdb_offset = 1; + + if (fifo8_num_used(&s->cmdfifo) > 1) { + /* Process any additional command phase data */ + esp_do_dma(s); + } + } + break; + } + /* ATN remains asserted until TC == 0 */ if (esp_get_tc(s) == 0) { esp_set_phase(s, STAT_CD); @@ -663,6 +662,21 @@ static void esp_do_dma(ESPState *s) esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); + switch (s->rregs[ESP_CMD]) { + case CMD_SELATN | CMD_DMA: + if (fifo8_num_used(&s->cmdfifo) >= 1) { + /* First byte received, switch to command phase */ + esp_set_phase(s, STAT_CD); + s->cmdfifo_cdb_offset = 1; + + if (fifo8_num_used(&s->cmdfifo) > 1) { + /* Process any additional command phase data */ + esp_do_dma(s); + } + } + break; + } + /* ATN remains asserted until TC == 0 */ if (esp_get_tc(s) == 0) { esp_set_phase(s, STAT_CD); @@ -890,9 +904,6 @@ static void esp_do_nodma(ESPState *s) static void esp_pdma_cb(ESPState *s) { switch (s->pdma_cb) { - case SATN_PDMA_CB: - satn_pdma_cb(s); - break; case SATN_STOP_PDMA_CB: satn_stop_pdma_cb(s); break; diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index b727181da9..9945645837 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -152,7 +152,6 @@ struct SysBusESPState { /* PDMA callbacks */ enum pdma_cb { - SATN_PDMA_CB = 0, SATN_STOP_PDMA_CB = 2, WRITE_RESPONSE_PDMA_CB = 3, DO_DMA_PDMA_CB = 4 From patchwork Tue Feb 13 19:40:14 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: 13555637 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 879CEC48260 for ; Tue, 13 Feb 2024 20:09:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0X-0004f6-O4; Tue, 13 Feb 2024 15:03:57 -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 1rZyzj-0003O1-Bl for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03: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 1rZyzf-00028b-7V for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03:05 -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=uJXGwrxSXVhXmHfs4lrUdgtZdqpD1CNQpU7RxspzTMQ=; b=kN8fwL0BF26nKu/V9iFgQ4B4UZ PgKoEarj5e91t2TlIYsyC1e1W83nf7rI5FqVtlb19wdg+9lIvHQDbNBPCCN2z4KjBzxX+0Z4Icd8m hIfjUoiwd9tDB37N+Tr88bb6b06tXB6EwlzV0En2GxnGd1YaAQ56UfRCSta0iUkaORxEw8SoerQ/P 934bKwY4tTv41oe1OESFKzzqgm50n84V1LsqI9fMlJZp4grHif+1nhatUbFRREZkOj1pJr42U4cpD c/9zDNr3tEK9jXYd9mK643rD3ck9fOz7w9mCUhdt8cGsRxMXFLhBARM3bgBPVqw6Yp1hRdOiDA0p5 hVT+OrGgC8skaTZA/Fvji/WYPLf0XPa+Mu/IYzjqzR+uKHVP1sJjNsNthwcPRkgVnY87rzIPwyq1T X2dYMGTkwFZhTLDhuYOqhECTcK236OwPRmgEjcnymki2vi9SKi5oDu8DTjurkPqm39nv5ipcZ2vU4 Pk9zbsfHVw3Ky8ONO9Z43LTThsxn/K6nSDx3+sytarsOXwa8gzbqdJKbBmMDeWAlvVDY65v/ctuOr CSfxvFxPyiNcvgwoEFGo654uCpCEewpdmrheAl43lIRE1fVQuIf2T/P20tZIRv8qqx7lxVay9xhrv m/rw20IE3YwEA06Pnp7u8P5rrvNpiAwmWtkO8QNVA=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygO-0008m4-8j; Tue, 13 Feb 2024 19:43:11 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:14 +0000 Message-Id: <20240213194052.1162753-51-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 50/88] esp.c: move CMD_TI end of message phase detection to esp_do_dma() and do_dma_pdma_cb() 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 existing check for TC == 0 is only valid during a TI command. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-51-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index f8c20d0584..9f787d12a8 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -555,14 +555,16 @@ static void do_dma_pdma_cb(ESPState *s) } } break; - } - /* ATN remains asserted until TC == 0 */ - if (esp_get_tc(s) == 0) { - esp_set_phase(s, STAT_CD); - s->rregs[ESP_RSEQ] = SEQ_CD; - s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); + case CMD_TI | CMD_DMA: + /* ATN remains asserted until TC == 0 */ + if (esp_get_tc(s) == 0) { + esp_set_phase(s, STAT_CD); + s->rregs[ESP_RSEQ] = SEQ_CD; + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + } + break; } break; @@ -675,14 +677,16 @@ static void esp_do_dma(ESPState *s) } } break; - } - /* ATN remains asserted until TC == 0 */ - if (esp_get_tc(s) == 0) { - esp_set_phase(s, STAT_CD); - s->rregs[ESP_RSEQ] = SEQ_CD; - s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); + case CMD_TI | CMD_DMA: + /* ATN remains asserted until TC == 0 */ + if (esp_get_tc(s) == 0) { + esp_set_phase(s, STAT_CD); + s->rregs[ESP_RSEQ] = SEQ_CD; + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + } + break; } break; From patchwork Tue Feb 13 19:40:15 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: 13555610 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 0ED49C4829A for ; Tue, 13 Feb 2024 20:02:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyxk-00014r-3w; Tue, 13 Feb 2024 15:01:04 -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 1rZyxX-0000z9-23 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:54 -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 1rZyxR-0001n2-N0 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:48 -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=9iDD6O2+jvA94mMNo3uokhjxaw5j/YMMMk4z58jg9zA=; b=hkJhKQjkfeEk6pDivbHOejEVto IV+rMN4qQZQsqTxNNqihK8CWjXYTvdIvhEHVMyVsHK4Pbci/509Ama6wSru8pRWku/iAK2O1qqp35 tnxVT4p0e0bOOrssZhfRY3oBrO2WVvsClM9wFvyjHnwFM85gAiuANKEilQmw1CiBPGXF2WK//umKj 3GTzVgEivz8lKngb52VTaZqCEZprK/1n/sUwGMaCmT4WLK4X3QnEJRfEtg/X2Yvqsd2M5epsGN+YZ rwMyB97J4MQZL/ANppoLPQnVmfJCAtkW0UG8zaDGcOXSXKYLd4DU7f6jzPE8hBfuISyHSkpQ0YPAE cBezeeBNI7K0R+r7CR8vcaXM4O4eLkXINKlyNIflGWinBo/GrdKDPMPmnRVReKwZ0XXS25KQmpaDe 6ph7fXAfpIVvmBlLw2xyiq2mA8fLlXwLInNiJcUn+SPopa3whY5DBZozO18Zz7pdvYWeFy1HnKyoh 6QOx6TlSLcP0A+DFVMHAhDa0vaNIVZyOWRNM6YLpBTwBru/lqg06u25fnvNXOL2LAw5OhjAopzA8P TI30d3dfsJCa7o+j522ZMbNMeQXjhS7Ot+gunx34d6HQQHcc0uTP6TBz8+z+E5ejDuOGBJRxtfAHu VpFKpLBJmvbLSex51uwlQqLrwUylbU48vMIqdX2z0=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygR-0008m4-QI; Tue, 13 Feb 2024 19:43:15 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:15 +0000 Message-Id: <20240213194052.1162753-52-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 51/88] esp.c: don't use get_cmd() for CMD_SEL DMA 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 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 can now be done using the existing logic in esp_do_dma() and do_dma_pdma_cb(). Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-52-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 9f787d12a8..3cf8b2b4eb 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -396,8 +396,6 @@ static void handle_satn(ESPState *s) static void handle_s_without_atn(ESPState *s) { - int32_t cmdlen; - if (s->dma && !s->dma_enabled) { s->dma_cb = handle_s_without_atn; return; @@ -406,17 +404,17 @@ static void handle_s_without_atn(ESPState *s) if (esp_select(s) < 0) { return; } - cmdlen = get_cmd(s, ESP_CMDFIFO_SZ); - if (cmdlen > 0) { - s->cmdfifo_cdb_offset = 0; - do_cmd(s); - } else if (cmdlen == 0) { - if (s->dma) { - esp_raise_drq(s); + + esp_set_phase(s, STAT_CD); + s->rregs[ESP_RSEQ] = SEQ_CD; + s->cmdfifo_cdb_offset = 0; + + if (s->dma) { + esp_do_dma(s); + } else { + if (get_cmd(s, ESP_CMDFIFO_SZ)) { + do_cmd(s); } - /* Target present, but no cmd yet - switch to command phase */ - s->rregs[ESP_RSEQ] = SEQ_CD; - esp_set_phase(s, STAT_CD); } } From patchwork Tue Feb 13 19:40:16 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: 13555633 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 57E4CC48260 for ; Tue, 13 Feb 2024 20:09:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0N-0004GO-Ny; Tue, 13 Feb 2024 15:03: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 1rZyyY-0002IE-UG for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:57 -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 1rZyyX-0001we-Cf for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:54 -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=hViVfptURSaNNRc4wl0KKMQuepAQGRlsU+bgrRPmQ1Q=; b=AP80zht16pDQYnIsE+OJPKx7AW AaFmLrSNkzt+sFZp+9Pyti19lEKgakXGJKCg8uUrP3axBWdXPj6//ARrp2wA9yb+8yLCvAANM0LOV H4VBCmhj2Cz6Y/vG/08uIsQygvy1pqwXN4mZyIxEcZvSXJD/SwgOEFgME5gIOUC97LoW57USU536z dielfcEDlmF5Hzt2y6DxZVvec5L1PVGfIICp/OKix5GTkELQ0Cunh8uyHJIz0ssHlrUFQOkeR75JX l/awl+u4iZO1b6i1zObYDIRdEHzyuVl0ww3OfzSni5ShRCutIm3gkkYncoiZHyFP+4DN5eh1mMxZp ann2yxZJ03iIAZ53HJ7laHLEnhsMs2ND3P358YkWgQLGNsnI9bCAlGZTsFekZFhOt58NkTNmakPCb FZBiscavta90C6EyPZo6gOeyK62yDUicYtqcYb4DgAbE3azGX0UZVwutj6y06kDzlzt0INTKvnYQv 6eYvMYyQO+QzSPSvogd0RFmplJPLVNpt07EbM+koLxVm9U3IHP3NDCs7oDtuCNUM/R64xyMjd0FrK WWEwTqrMx9/ibfQXLWzaRBtQLl10vrsodaXVXF1g5kMdOnutk+KRXgIgz4uJMtA4F2ZVyu6UcrKav eIj1oEjVNZ9HoFHhdWtIvsyBXt6zs3p75sM6HTu3I=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygV-0008m4-EA; Tue, 13 Feb 2024 19:43:19 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:16 +0000 Message-Id: <20240213194052.1162753-53-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 52/88] esp.c: move CMD_SELATNS end of command logic to esp_do_dma() and do_dma_pdma_cb() 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 special logic in satn_stop_pdma_cb() is now no longer required since esp_do_dma() can be used as a direct replacement. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-53-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 82 +++++++++++++++++++++---------------------- include/hw/scsi/esp.h | 1 - 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 3cf8b2b4eb..29e3869173 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -418,54 +418,31 @@ static void handle_s_without_atn(ESPState *s) } } -static void satn_stop_pdma_cb(ESPState *s) -{ - uint8_t buf[ESP_FIFO_SZ]; - int n; - - /* Copy FIFO into cmdfifo */ - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); - - if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) { - trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); - s->cmdfifo_cdb_offset = 1; - esp_set_phase(s, STAT_CD); - s->rregs[ESP_RSTAT] |= STAT_TC; - s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; - s->rregs[ESP_RSEQ] = SEQ_CD; - esp_raise_irq(s); - } -} - static void handle_satn_stop(ESPState *s) { - int32_t cmdlen; - if (s->dma && !s->dma_enabled) { s->dma_cb = handle_satn_stop; return; } - esp_set_pdma_cb(s, SATN_STOP_PDMA_CB); + esp_set_pdma_cb(s, DO_DMA_PDMA_CB); if (esp_select(s) < 0) { return; } - cmdlen = get_cmd(s, 1); - if (cmdlen > 0) { - trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); - s->cmdfifo_cdb_offset = 1; - esp_set_phase(s, STAT_MO); - s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; - s->rregs[ESP_RSEQ] = SEQ_MO; - esp_raise_irq(s); - } else if (cmdlen == 0) { - if (s->dma) { - esp_raise_drq(s); + + esp_set_phase(s, STAT_MO); + s->rregs[ESP_RSEQ] = SEQ_MO; + + if (s->dma) { + esp_do_dma(s); + } else { + if (get_cmd(s, 1)) { + trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); + + /* Raise command completion interrupt */ + s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; + s->rregs[ESP_RSEQ] = SEQ_MO; + esp_raise_irq(s); } - /* Target present, switch to message out phase */ - s->rregs[ESP_RSEQ] = SEQ_MO; - esp_set_phase(s, STAT_MO); } } @@ -554,6 +531,19 @@ static void do_dma_pdma_cb(ESPState *s) } break; + case CMD_SELATNS | CMD_DMA: + if (fifo8_num_used(&s->cmdfifo) == 1) { + /* First byte received, stop in message out phase */ + esp_set_phase(s, STAT_CD); + s->cmdfifo_cdb_offset = 1; + + /* Raise command completion interrupt */ + s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; + s->rregs[ESP_RSEQ] = SEQ_CD; + esp_raise_irq(s); + } + break; + case CMD_TI | CMD_DMA: /* ATN remains asserted until TC == 0 */ if (esp_get_tc(s) == 0) { @@ -676,6 +666,19 @@ static void esp_do_dma(ESPState *s) } break; + case CMD_SELATNS | CMD_DMA: + if (fifo8_num_used(&s->cmdfifo) == 1) { + /* First byte received, stop in message out phase */ + esp_set_phase(s, STAT_CD); + s->cmdfifo_cdb_offset = 1; + + /* Raise command completion interrupt */ + s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; + s->rregs[ESP_RSEQ] = SEQ_CD; + esp_raise_irq(s); + } + break; + case CMD_TI | CMD_DMA: /* ATN remains asserted until TC == 0 */ if (esp_get_tc(s) == 0) { @@ -906,9 +909,6 @@ static void esp_do_nodma(ESPState *s) static void esp_pdma_cb(ESPState *s) { switch (s->pdma_cb) { - case SATN_STOP_PDMA_CB: - satn_stop_pdma_cb(s); - break; case WRITE_RESPONSE_PDMA_CB: write_response_pdma_cb(s); break; diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index 9945645837..a4b2ed115c 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -152,7 +152,6 @@ struct SysBusESPState { /* PDMA callbacks */ enum pdma_cb { - SATN_STOP_PDMA_CB = 2, WRITE_RESPONSE_PDMA_CB = 3, DO_DMA_PDMA_CB = 4 }; From patchwork Tue Feb 13 19:40:17 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: 13555616 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 A667EC4829A for ; Tue, 13 Feb 2024 20:05:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyyh-0002MR-4g; Tue, 13 Feb 2024 15:02:04 -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 1rZyxw-0001Xj-Oz for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01: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 1rZyxu-0001s2-GE for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01: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=lTn4V1T64Cxftxgo+RVGj1lemtFejAQRM/dLtRcBqz0=; b=wmy0mDAPqfLqN/YEN2BO76UMzL QLh3JTR25Fa/SmTLrcYrtI+8k/TuHvaQQ7Sbv53HKsZXo57C9PXxcVnnHCnxjub+qC30zUSlrWRIH WDLoxIcYEJPJQsk1O4wv8Ce9XSCdJQAzXw6q8GdEELdw04Yz+wx1OEzw0q/xloewMYRrVpe1G3nV7 nZE/o6WbGAjhsAfWx1zZ1qr1zRA4940tUscB/Hc3dMJcNvZeA3c8g1i7H9a919fNCw5Sy3kMKcvCe mZKWkrdyXzbVAy6oZRmpq+q+E+OMed9wzoC9w99W0oJlwWPV0ncGFMIx35ATe1qxxF98yulEy6+cJ JpQkBGdPDUS8S9l7yWOCI0WsZv/mDfwX6NMOSvCgAPhfsyQg+/w9CFEyrg/LtZ3SzvwQseQFhH4gG XuLyBoG6XM+0/x2Ce8kiz2JgsH6tvjq2uAOH8WYYts/suYkKQ7U64gDP2tPfYjvsM9pRT828sVoUv YyAtUiQgo3vRh7Esd0ZI/k7mmk7pLcGL4gKJch9qGt+WiPfi908AhsJXNr9B0kdZ18XQ+KRKhNc/s PAWHyr9J0aGh+gykLV550D+MTREnp78q2JP6jElNjBjGL137U4IYy1MrN0TxPS3jOQ+QmINWkGYLj lCPG9qUvRpwCNyoHE/dgtRElJ+9Sf49RJcZ9An11E=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygZ-0008m4-HG; Tue, 13 Feb 2024 19:43:23 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:17 +0000 Message-Id: <20240213194052.1162753-54-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 53/88] esp.c: replace do_dma_pdma_cb() with esp_do_dma() 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 the DMA logic is identical between do_dma_pdma_cb() and esp_do_dma() we can replace do_dma_pdma_cb() with esp_do_dma(). Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-54-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 138 +------------------------------------------------- 1 file changed, 1 insertion(+), 137 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 29e3869173..f69b2709fc 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -491,141 +491,6 @@ static void esp_dma_ti_check(ESPState *s) } } -static void do_dma_pdma_cb(ESPState *s) -{ - uint8_t buf[ESP_CMDFIFO_SZ]; - int len; - uint32_t n, cmdlen; - - len = esp_get_tc(s); - - switch (esp_get_phase(s)) { - case STAT_MO: - if (s->dma_memory_read) { - len = MIN(len, fifo8_num_free(&s->cmdfifo)); - s->dma_memory_read(s->dma_opaque, buf, len); - fifo8_push_all(&s->cmdfifo, buf, len); - esp_set_tc(s, esp_get_tc(s) - len); - s->cmdfifo_cdb_offset += len; - } else { - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); - s->cmdfifo_cdb_offset += n; - } - - esp_set_pdma_cb(s, DO_DMA_PDMA_CB); - esp_raise_drq(s); - - switch (s->rregs[ESP_CMD]) { - case CMD_SELATN | CMD_DMA: - if (fifo8_num_used(&s->cmdfifo) >= 1) { - /* First byte received, switch to command phase */ - esp_set_phase(s, STAT_CD); - s->cmdfifo_cdb_offset = 1; - - if (fifo8_num_used(&s->cmdfifo) > 1) { - /* Process any additional command phase data */ - esp_do_dma(s); - } - } - break; - - case CMD_SELATNS | CMD_DMA: - if (fifo8_num_used(&s->cmdfifo) == 1) { - /* First byte received, stop in message out phase */ - esp_set_phase(s, STAT_CD); - s->cmdfifo_cdb_offset = 1; - - /* Raise command completion interrupt */ - s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; - s->rregs[ESP_RSEQ] = SEQ_CD; - esp_raise_irq(s); - } - break; - - case CMD_TI | CMD_DMA: - /* ATN remains asserted until TC == 0 */ - if (esp_get_tc(s) == 0) { - esp_set_phase(s, STAT_CD); - s->rregs[ESP_RSEQ] = SEQ_CD; - s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); - } - break; - } - break; - - case STAT_CD: - cmdlen = fifo8_num_used(&s->cmdfifo); - trace_esp_do_dma(cmdlen, len); - if (s->dma_memory_read) { - len = MIN(len, fifo8_num_free(&s->cmdfifo)); - s->dma_memory_read(s->dma_opaque, buf, len); - fifo8_push_all(&s->cmdfifo, buf, len); - esp_set_tc(s, esp_get_tc(s) - len); - } else { - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); - - esp_set_pdma_cb(s, DO_DMA_PDMA_CB); - esp_raise_drq(s); - } - trace_esp_handle_ti_cmd(cmdlen); - s->ti_size = 0; - if (esp_get_tc(s) == 0) { - /* Command has been received */ - do_cmd(s); - } - break; - - case STAT_DO: - if (!s->current_req) { - return; - } - /* Copy FIFO data to device */ - len = MIN(s->async_len, ESP_FIFO_SZ); - len = MIN(len, fifo8_num_used(&s->fifo)); - n = esp_fifo_pop_buf(&s->fifo, s->async_buf, len); - s->async_buf += n; - s->async_len -= n; - s->ti_size += n; - - if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { - /* Defer until the scsi layer has completed */ - scsi_req_continue(s->current_req); - return; - } - - esp_dma_ti_check(s); - break; - - case STAT_DI: - if (!s->current_req) { - return; - } - /* Copy device data to FIFO */ - len = MIN(s->async_len, esp_get_tc(s)); - len = MIN(len, fifo8_num_free(&s->fifo)); - fifo8_push_all(&s->fifo, s->async_buf, len); - s->async_buf += len; - s->async_len -= len; - s->ti_size -= len; - esp_set_tc(s, esp_get_tc(s) - len); - - if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { - /* Defer until the scsi layer has completed */ - scsi_req_continue(s->current_req); - s->data_in_ready = false; - return; - } - - esp_dma_ti_check(s); - break; - } -} - static void esp_do_dma(ESPState *s) { uint32_t len, cmdlen; @@ -669,7 +534,6 @@ static void esp_do_dma(ESPState *s) case CMD_SELATNS | CMD_DMA: if (fifo8_num_used(&s->cmdfifo) == 1) { /* First byte received, stop in message out phase */ - esp_set_phase(s, STAT_CD); s->cmdfifo_cdb_offset = 1; /* Raise command completion interrupt */ @@ -913,7 +777,7 @@ static void esp_pdma_cb(ESPState *s) write_response_pdma_cb(s); break; case DO_DMA_PDMA_CB: - do_dma_pdma_cb(s); + esp_do_dma(s); break; default: g_assert_not_reached(); From patchwork Tue Feb 13 19:40:18 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: 13555609 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 2F9FDC4829F for ; Tue, 13 Feb 2024 20:02:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyy9-0001XT-6o; Tue, 13 Feb 2024 15:01:34 -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 1rZyxt-0001Rg-A0 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:13 -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 1rZyxr-0001rs-Na for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:13 -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=c68NltF/sG/5kE0KjHWJUPi/rnJR3fFpkAyJcJORF5A=; b=wpQ4tQHAZpVQ68QkNSO7RzydcU pHBzIvMOj/9bulGnW1JFyHyK397O5paPIfbX1GVYQQzkwYj6z020JtGnYIdFHnc/VfyzMO0SPOJSl R8GCoqu8M4ZoJnwchDiSpFnO97HZ5lKU8fYA0cmOCGUCElhnu1t5ET03nYo1yWSa/AnS5ir5plL+W V+iU2Rgv5M7LBtgejZDGXy3cv8KrrBOpLVa1TBIVaXF0AOc7inlOBlXTeSiyMiUGE373L8haz4B12 sozaIxf8ENzbhDtY+wcQGmCTUKZi+LPIKiwsTCUN+LLqvgLNpFkNn50qEoHI5FTUVqhtpAdERml+f KuBgQNix2DHGheJ7kD4vaUmz8ONPOQIU4O2iFvY9libbX01zk201BvH0OZsgMCmT6nggFaSb3V3kI JrQ2BTmQjtkBNwQVpIQ9Ybgi69AknNXNzwhW1W/nKoD0GhgtTJFLKiVVy0BmgYtwzGk8Fug6byI+j zDcg8uv9OjwSpn1PDH0FsnsvCsyUFEnh0EDvITxleu4JmPbqS3bEZtIPHCyxcDJDSZYd8+rTcLsOb k7t8Dp+6ymTHmEj+lTHuH3bTXJBQ2yMZ/RFZq0n8A1lnIaS6tQXP503FcYMzr6ZHVmaNwVO1YciHu z+NJu+2cX9+m5Vsp6N6lOlyK5geZDcatdXNH+AInY=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygd-0008m4-3t; Tue, 13 Feb 2024 19:43:23 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:18 +0000 Message-Id: <20240213194052.1162753-55-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 54/88] esp.c: move CMD_ICCS command logic to esp_do_dma() 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 special logic in write_response_pdma_cb() is now no longer required since esp_do_dma() can be used as a direct replacement. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-55-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 82 ++++++++++++++++++++++++++++++------------- include/hw/scsi/esp.h | 1 - 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index f69b2709fc..c6e5ddd537 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -446,40 +446,23 @@ static void handle_satn_stop(ESPState *s) } } -static void write_response_pdma_cb(ESPState *s) -{ - esp_set_phase(s, STAT_ST); - s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; - s->rregs[ESP_RSEQ] = SEQ_CD; - esp_raise_irq(s); -} - static void write_response(ESPState *s) { uint8_t buf[2]; trace_esp_write_response(s->status); - buf[0] = s->status; - buf[1] = 0; - if (s->dma) { - if (s->dma_memory_write) { - s->dma_memory_write(s->dma_opaque, buf, 2); - esp_set_phase(s, STAT_ST); - s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; - s->rregs[ESP_RSEQ] = SEQ_CD; - } else { - esp_set_pdma_cb(s, WRITE_RESPONSE_PDMA_CB); - esp_raise_drq(s); - return; - } + esp_do_dma(s); } else { + buf[0] = s->status; + buf[1] = 0; + fifo8_reset(&s->fifo); fifo8_push_all(&s->fifo, buf, 2); s->rregs[ESP_RFLAGS] = 2; + esp_raise_irq(s); } - esp_raise_irq(s); } static void esp_dma_ti_check(ESPState *s) @@ -673,6 +656,58 @@ static void esp_do_dma(ESPState *s) esp_dma_ti_check(s); } break; + + case STAT_ST: + switch (s->rregs[ESP_CMD]) { + case CMD_ICCS | CMD_DMA: + len = MIN(len, 1); + + if (len) { + buf[0] = s->status; + + if (s->dma_memory_write) { + s->dma_memory_write(s->dma_opaque, buf, len); + esp_set_tc(s, esp_get_tc(s) - len); + } else { + fifo8_push_all(&s->fifo, buf, len); + esp_set_tc(s, esp_get_tc(s) - len); + } + + esp_set_phase(s, STAT_MI); + + if (esp_get_tc(s) > 0) { + /* Process any message in phase data */ + esp_do_dma(s); + } + } + break; + } + break; + + case STAT_MI: + switch (s->rregs[ESP_CMD]) { + case CMD_ICCS | CMD_DMA: + len = MIN(len, 1); + + if (len) { + buf[0] = 0; + + if (s->dma_memory_write) { + s->dma_memory_write(s->dma_opaque, buf, len); + esp_set_tc(s, esp_get_tc(s) - len); + } else { + fifo8_push_all(&s->fifo, buf, len); + esp_set_tc(s, esp_get_tc(s) - len); + } + + /* Raise end of command interrupt */ + s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; + s->rregs[ESP_RSEQ] = SEQ_CD; + esp_raise_irq(s); + } + break; + } + break; } } @@ -773,9 +808,6 @@ static void esp_do_nodma(ESPState *s) static void esp_pdma_cb(ESPState *s) { switch (s->pdma_cb) { - case WRITE_RESPONSE_PDMA_CB: - write_response_pdma_cb(s); - break; case DO_DMA_PDMA_CB: esp_do_dma(s); break; diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index a4b2ed115c..0207fdd7a6 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -152,7 +152,6 @@ struct SysBusESPState { /* PDMA callbacks */ enum pdma_cb { - WRITE_RESPONSE_PDMA_CB = 3, DO_DMA_PDMA_CB = 4 }; From patchwork Tue Feb 13 19:40:19 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: 13555643 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 B0F59C4829F for ; Tue, 13 Feb 2024 20:12:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0N-0004E0-5a; Tue, 13 Feb 2024 15:03: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 1rZyyw-0002Ym-Pj for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:21 -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 1rZyyv-00023o-AE for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:18 -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=EA5YnaUP3gDHF5AaE9uZujarI/GD/Dg9Sof51XT/n9E=; b=HlRioVnoEYONPiOoQoc9nRxgJT 70Fg7A6wb37KXLbD64BYULEbKAsdmhLIKfwJyjHEwpk7K2cmFTb6OtzdU4Oy1vlpm3abvbURR8cDn RwYnKTuZyQo+Q0GsdV3yd4DwW44Zpz2pdVQ1d9/i8yB/sHWPBfYETjJtWwyrU3gLswcNlpp4jyapm OHNIR9Jddujp0R5ak3/QCe3T6AuJQwS13hC4r/UEZj1aX57q+bEd3EzNZBZOojVjuISP43VmV7aIr /yBxWhOzvHWvC/fddrgFPwL2jmkPK+vUu1W13hhKfMbP2sDWBUiXu0asSfPbAPgnDqITTdmo4e4Wf EA+UNpaUPYGExmDnHkRxr68tiSjdX8NC3qjNES87Ymrd0Ua83iYpNy8dG1xxI3PqAsioFLEwfAwKp LHcq7xKYHg5yOyBjbeJbFCR79uqVleew++dhvH3vUhRvZd8Y75CcDUnnVexACR2RyVVisg9+4A5TY F7701FJ/Hm8IzrJWyzpUjUAmZmKtOABs8n0Dk2Tk9hUnATUP1zkLe/AxpJfmfQd/CcLb0/jM7ZujW y7TWHQ8lq5TBG+KHXebNxBZtd5WZMGuwnLO55p+LT2f/ZugeK0N5SO6T+7fZgpdX3L6nrHAeN7fy4 cNZAufW9D+BCnAq3sB9fSioO4GBw0TaTwdeBWbzK4=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygd-0008m4-El; Tue, 13 Feb 2024 19:43:26 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:19 +0000 Message-Id: <20240213194052.1162753-56-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 55/88] esp.c: always use esp_do_dma() in pdma_cb() 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 is now only a single implementation contained within esp_do_dma() so call it directly. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-56-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index c6e5ddd537..bdbdb209f7 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -807,13 +807,7 @@ static void esp_do_nodma(ESPState *s) static void esp_pdma_cb(ESPState *s) { - switch (s->pdma_cb) { - case DO_DMA_PDMA_CB: - esp_do_dma(s); - break; - default: - g_assert_not_reached(); - } + esp_do_dma(s); } void esp_command_complete(SCSIRequest *req, size_t resid) From patchwork Tue Feb 13 19:40:20 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: 13555615 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 172BFC4829F for ; Tue, 13 Feb 2024 20:04:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0d-0004on-Sq; Tue, 13 Feb 2024 15:04:06 -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 1rZz0B-0003vQ-B5 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03:35 -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 1rZz09-0002An-NN for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03:35 -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=cfhlzrwDQ8CNlxP8yl8X90lb9cN5al37GV4VXNcU3zQ=; b=R+pzdNrFNxUWjp1xxkBCUk0gjl CzIknfmMnFuBuhd/7389yd97398Fz1/Yt2uPxAQu12HBdqa1d7cnRksO0m8OF1BjC04Gyn9J3dXnK ewt26HJjC5/137KZIdbF1gzNqoETQXncxe6g1Tbte0Wpi6iUuKminMX05p1jEIZ8MgadKfFAvzgvo 9hgCaJlYJuEbZSrTiWCxc4IiGfOul1doVNNDSw2N4/fJC2JWJVryRMWWLvEEaudYy36I5I94BGIn/ wPnqRJlBf2U6ZuXz+hLtuGHqjXVdWu31aU07+hjF0G6noQ1pBVqDuAOunUWRV2DejezB74yKyMJwY 6wU3fh2IZo//TPbjGAufkjGLCN0cTIkHXrdRL4EUaOc9na+PJST29yiOZH+r8nG8tpVNTV+qzu7fz Bqpk2RIUxJnUYcgfaCI3y4moeyv0kUwYBU6NI+qrSgM7cRMwYOwSv6f5W+dfFqn1pZbA9LcAYA5Px qoke+BzRjiShU9UD9J6l1ltE83ji65MZNzzPBp+ttks41OsyDttC42g3U/zScWEUk+G711drpm9YH bUuEPIsjHBmxifL/w5Sb2NA/39Jezm7FiFUImKhSDFgOOzadpGjUh2XI4rRax+9nRqq3tK9lyKUgg ttN6/xdtf8oiNuL6oqOb2ZpeAkM4s6mxZe30UIq+s=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygh-0008m4-3c; Tue, 13 Feb 2024 19:43:30 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:20 +0000 Message-Id: <20240213194052.1162753-57-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 56/88] esp.c: remove unused PDMA callback implementation 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 Note that this is a migration break for the q800 machine because the extra PDMA information is no longer included. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-57-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 55 ++++--------------------------------------- include/hw/scsi/esp.h | 6 ----- 2 files changed, 5 insertions(+), 56 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index bdbdb209f7..5061c9d5a1 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -223,11 +223,6 @@ static void esp_pdma_write(ESPState *s, uint8_t val) esp_set_tc(s, dmalen); } -static void esp_set_pdma_cb(ESPState *s, enum pdma_cb cb) -{ - s->pdma_cb = cb; -} - static int esp_select(ESPState *s) { int target; @@ -377,7 +372,7 @@ static void handle_satn(ESPState *s) s->dma_cb = handle_satn; return; } - esp_set_pdma_cb(s, DO_DMA_PDMA_CB); + if (esp_select(s) < 0) { return; } @@ -400,7 +395,7 @@ static void handle_s_without_atn(ESPState *s) s->dma_cb = handle_s_without_atn; return; } - esp_set_pdma_cb(s, DO_DMA_PDMA_CB); + if (esp_select(s) < 0) { return; } @@ -424,7 +419,7 @@ static void handle_satn_stop(ESPState *s) s->dma_cb = handle_satn_stop; return; } - esp_set_pdma_cb(s, DO_DMA_PDMA_CB); + if (esp_select(s) < 0) { return; } @@ -497,7 +492,6 @@ static void esp_do_dma(ESPState *s) s->cmdfifo_cdb_offset += n; } - esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); switch (s->rregs[ESP_CMD]) { @@ -551,7 +545,6 @@ static void esp_do_dma(ESPState *s) n = MIN(fifo8_num_free(&s->cmdfifo), n); fifo8_push_all(&s->cmdfifo, buf, n); - esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); } trace_esp_handle_ti_cmd(cmdlen); @@ -597,7 +590,6 @@ static void esp_do_dma(ESPState *s) s->async_len -= n; s->ti_size += n; - esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { @@ -644,7 +636,6 @@ static void esp_do_dma(ESPState *s) s->async_len -= len; s->ti_size -= len; esp_set_tc(s, esp_get_tc(s) - len); - esp_set_pdma_cb(s, DO_DMA_PDMA_CB); esp_raise_drq(s); if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { @@ -805,11 +796,6 @@ static void esp_do_nodma(ESPState *s) } } -static void esp_pdma_cb(ESPState *s) -{ - esp_do_dma(s); -} - void esp_command_complete(SCSIRequest *req, size_t resid) { ESPState *s = req->hba_private; @@ -1229,33 +1215,6 @@ static int esp_post_load(void *opaque, int version_id) return 0; } -/* - * PDMA (or pseudo-DMA) is only used on the Macintosh and requires the - * guest CPU to perform the transfers between the SCSI bus and memory - * itself. This is indicated by the dma_memory_read and dma_memory_write - * functions being NULL (in contrast to the ESP PCI device) whilst - * dma_enabled is still set. - */ - -static bool esp_pdma_needed(void *opaque) -{ - ESPState *s = ESP(opaque); - - return s->dma_memory_read == NULL && s->dma_memory_write == NULL && - s->dma_enabled; -} - -static const VMStateDescription vmstate_esp_pdma = { - .name = "esp/pdma", - .version_id = 0, - .minimum_version_id = 0, - .needed = esp_pdma_needed, - .fields = (const VMStateField[]) { - VMSTATE_UINT8(pdma_cb, ESPState), - VMSTATE_END_OF_LIST() - } -}; - const VMStateDescription vmstate_esp = { .name = "esp", .version_id = 6, @@ -1290,10 +1249,6 @@ const VMStateDescription vmstate_esp = { VMSTATE_UINT8_TEST(lun, ESPState, esp_is_version_6), VMSTATE_END_OF_LIST() }, - .subsections = (const VMStateDescription * const []) { - &vmstate_esp_pdma, - NULL - } }; static void sysbus_esp_mem_write(void *opaque, hwaddr addr, @@ -1342,7 +1297,7 @@ static void sysbus_esp_pdma_write(void *opaque, hwaddr addr, esp_pdma_write(s, val); break; } - esp_pdma_cb(s); + esp_do_dma(s); } static uint64_t sysbus_esp_pdma_read(void *opaque, hwaddr addr, @@ -1363,7 +1318,7 @@ static uint64_t sysbus_esp_pdma_read(void *opaque, hwaddr addr, val = (val << 8) | esp_pdma_read(s); break; } - esp_pdma_cb(s); + esp_do_dma(s); return val; } diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index 0207fdd7a6..6f942864a6 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -51,7 +51,6 @@ struct ESPState { ESPDMAMemoryReadWriteFunc dma_memory_write; void *dma_opaque; void (*dma_cb)(ESPState *s); - uint8_t pdma_cb; uint8_t mig_version_id; @@ -150,11 +149,6 @@ struct SysBusESPState { #define TCHI_FAS100A 0x4 #define TCHI_AM53C974 0x12 -/* PDMA callbacks */ -enum pdma_cb { - DO_DMA_PDMA_CB = 4 -}; - void esp_dma_enable(ESPState *s, int irq, int level); void esp_request_cancelled(SCSIRequest *req); void esp_command_complete(SCSIRequest *req, size_t resid); From patchwork Tue Feb 13 19:40: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: 13555617 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 18171C48260 for ; Tue, 13 Feb 2024 20:05:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyxm-00018Z-If; Tue, 13 Feb 2024 15:01:06 -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 1rZyxa-00010b-TT for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:02 -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 1rZyxY-0001pd-Nb for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:53 -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=ZCNugVb7WxY59bZ+uR6Pp0z4WpoZ+ACglW7b8SjGukM=; b=FrVMlI+2PXjxP/xH21mb4rAMFP TlAfogi7sctyFuYByCnmKDdGtEOstWJYtUxrdf27ad+qU0J7EgXWDx32DRJXS89i9qcbLVDaAOr1h jYLg1vl7c5DC7wyP9bbpbRz6OrB6pxfud4sns1Ge59/UDCNV/6z3Ka6ZB3VPwElSDlai5nC/sAbWd cso+rfYC5APQhjqQ31UZNEVH8iM/kAP+DuM3YPKMiwf7Rx3OXfdLINB1ECXflLMMQIfE4jS8Y2EFn 4r1cHrICNyJ38BFlAfGfMxFtPWl1X/r9Ph9VWIBhNmKEv/QO0xNCBOfrmRRLZBtidh0o/LZO8fGOy eUnLApMzuytqOKzyjs5ygzBvR/hS1LD1kVFKQFycgLkitH1CCKNLLy3UiBoVotF0tyrEwavA0guVC VCbsShUCOdv3z8emhAAgcRgWr9UO+qUOGvB/xYXLx92gt33YbKTRBmUbqFwOqAZi1Y1MfDpBCQfIz tMNlVx4Q22UYtoqpEsd5cc4SLdH7XjL2Pk+C0QLUGtehte6LUyRuL65lgbU18mYtMOMT+EyYgv+tv puRY8jejyMhR7oYQ0Wc3wKINqvP98mg3kPVLPVB/Lb51psAxpsUselRUdUlFlMKGHB01XFcpHcXkf K0mZovzRUHVsLX5ybsa22mySO83GbnyLsZ7AzwEGs=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygk-0008m4-MV; Tue, 13 Feb 2024 19:43:33 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:21 +0000 Message-Id: <20240213194052.1162753-58-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 57/88] esp.c: rename data_in_ready to to data_ready 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 field is currently used to handle deferred interrupts for the DATA IN phase but the code will soon be updated to do the same for the DATA OUT phase. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-58-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 8 ++++---- include/hw/scsi/esp.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 5061c9d5a1..73c723afcc 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -328,7 +328,7 @@ static void do_command_phase(ESPState *s) * Switch to DATA IN phase but wait until initial data xfer is * complete before raising the command completion interrupt */ - s->data_in_ready = false; + s->data_ready = false; esp_set_phase(s, STAT_DI); } else { esp_set_phase(s, STAT_DO); @@ -859,12 +859,12 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) s->async_len = len; s->async_buf = scsi_req_get_buf(req); - if (!to_device && !s->data_in_ready) { + if (!to_device && !s->data_ready) { /* * Initial incoming data xfer is complete so raise command * completion interrupt */ - s->data_in_ready = true; + s->data_ready = true; s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); } @@ -1241,7 +1241,7 @@ const VMStateDescription vmstate_esp = { VMSTATE_UINT32_TEST(mig_cmdlen, ESPState, esp_is_before_version_5), VMSTATE_UINT32(do_cmd, ESPState), VMSTATE_UINT32_TEST(mig_dma_left, ESPState, esp_is_before_version_5), - VMSTATE_BOOL_TEST(data_in_ready, ESPState, esp_is_version_5), + VMSTATE_BOOL_TEST(data_ready, ESPState, esp_is_version_5), VMSTATE_UINT8_TEST(cmdfifo_cdb_offset, ESPState, esp_is_version_5), VMSTATE_FIFO8_TEST(fifo, ESPState, esp_is_version_5), VMSTATE_FIFO8_TEST(cmdfifo, ESPState, esp_is_version_5), diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index 6f942864a6..1036606943 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -40,7 +40,7 @@ struct ESPState { uint8_t lun; uint32_t do_cmd; - bool data_in_ready; + bool data_ready; uint8_t ti_cmd; int dma_enabled; From patchwork Tue Feb 13 19:40: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: 13555630 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 74AEBC48BC4 for ; Tue, 13 Feb 2024 20:09:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0n-0005CW-W8; Tue, 13 Feb 2024 15:04: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 1rZz0c-0004mF-Ee for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:04:03 -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 1rZz0P-0002DK-Vk for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:04:02 -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=O7NEKvkbj4MXy755AuslcZ73cjKfcA574sHWMKhGl18=; b=MNWsJ5Q3ymM6Sq4CX3NGrv86Mg 6CVQUdDd2VwWEVlsQlwiwVod2D/XnryNEcmonnk6JQSqoXdZqmZeR0jJGEvLCq0g7Vvd34UpsMUjP Y+9ZaARs33D8L8a83W8EBNZwgaOjubygKXD2xJBu7UfVi+RRTfH2tF4tnIv+38FCfy474o7M/gjoF /h4cM7boLGV1mdlGKZCZlVW/S4ow+21fZuf+R3TkzdHgRAI9ze464LHnVdIPEh1JLsyR69shmDc/t OltvFSTMmq4g4Lu93zAsaGYZfK7SwFC49nbaVyNfeBauACGk2jsiYCs3ZQ9blIcJpup5XbB7g+DB7 Jyz/kZxejcKZy5RAKLEcw8mC0yWJo2FDfSnE/J5+wvnLY5r5FOQeqxmbd8LIbXdZ2BdK0ntcr5B8w oTAVnqWLfIvz7R42tyFwixbaJH2Dl6gVk1FJH1GGc0HhBrVrcLaUg0d+T9wYlHlldNxXIjHZq/KPZ r+1iZ8ACsXP/k08cfovtOSYU8yEFoII73QtFWV4a7PM6Asf8zdcBeXeTjyeyJvTzRJRwjF02oIQg1 KS+WwZLPPed/zPpAmW7Bs6nevb8GrXOBKe5rC9CGCkfLxX2qRtSpuDZOEVLcAdEO3fy3/FuNyE3Ch XRhgzL4dDP9GMj/zVnVDGDHtW88+Qxw3NQjWZQgwE=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygn-0008m4-4y; Tue, 13 Feb 2024 19:43:37 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:22 +0000 Message-Id: <20240213194052.1162753-59-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 58/88] esp.c: separate logic based upon ESP command in esp_command_complete() 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 handling of the INTR_FC and INTR_BS bits is different depending upon the last command executed by the ESP. Note that currently INTR_FC is managed elsewhere, but that will change soon. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-59-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 73c723afcc..75538f5859 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -823,25 +823,27 @@ void esp_command_complete(SCSIRequest *req, size_t resid) * Switch to status phase. For non-DMA transfers from the target the last * byte is still in the FIFO */ - esp_set_phase(s, STAT_ST); - if (s->ti_size == 0) { - /* - * Transfer complete: force TC to zero just in case a TI command was - * requested for more data than the command returns (Solaris 8 does - * this) - */ - esp_set_tc(s, 0); - esp_dma_ti_check(s); - } else { + s->ti_size = 0; + + switch (s->rregs[ESP_CMD]) { + case CMD_SEL | CMD_DMA: + case CMD_SEL: + case CMD_SELATN | CMD_DMA: + case CMD_SELATN: /* - * Transfer truncated: raise INTR_BS to indicate early change of - * phase + * No data phase for sequencer command so raise deferred bus service + * interrupt */ s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); - s->ti_size = 0; + break; } + /* Raise bus service interrupt to indicate change to STATUS phase */ + esp_set_phase(s, STAT_ST); + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + esp_lower_drq(s); + if (s->current_req) { scsi_req_unref(s->current_req); s->current_req = NULL; From patchwork Tue Feb 13 19:40: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: 13555636 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 6BB23C4829A for ; Tue, 13 Feb 2024 20:09:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0Q-0004NA-8X; Tue, 13 Feb 2024 15:03:50 -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 1rZyz0-0002b7-BH for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:22 -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 1rZyyy-000249-Mv for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:22 -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=aJTWAvOYqywrLnvX1OR2Ngh7aiAwrAzm/3AnJXr6yik=; b=X5Ize7XVLzxFVaXA+kZbjk8qXY FyTDm6wimhNWrmmheUl5gxaWxjmxVAjPut8n+N8eDcxbnvrLaCdr0atRD+N5noLUgVeGNJgE5PAnC FO7uyYHyQHn8GFQWer+4Z23Syq9Bcv/7eYYXD3UWhNW7kuGxgim6u3d7vgtwqqdulqBnD3GyVtpgm 0XpGSNo+XWdKW5QSyE/1nWeea7SkRc41LWF3/RsyY92TtR/hsTUtx3iig6OK2UJnz9/RZgnBTVxwL +9YiOs6EDmXQ/WG7Mad+1m2kFC7oiq89lsCL5fILC8kOmeTICmD3QT+0VMYwPN6zc7PQYoPgZX4BP EfPp1W4e8diS31xyZkivO55o0QciNX6nLEcdG3TW/SPE7TzI+tquUNfDj18ASW/bvSnV10WThTRU2 0LS7Qfjhv8wpIWhqKbsgtFTzArPFI2s0kkDCc/OutmbNhWZ+Lyxx22jECEslyzHEyIxGBf7+iwENB m6b0V3WedK1uZKS4Y8hBZjXHGFExqV3riwO2y8b6FPzAQtctJvf3ycP1yR+t9R9g9lCDBRCCjm3eC bsg1bMmVdcYlqaoatoaxvTvwuyW6VJ809fgnrYR1qp9jBh4GtIfL7vm/0o+P9LYH5VQiHGJPqFdh7 w9yiJ5YfltWNzTe5F7YV9oYEjKJzq0UGw/NWAyiM0=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygr-0008m4-83; Tue, 13 Feb 2024 19:43:41 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:23 +0000 Message-Id: <20240213194052.1162753-60-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 59/88] esp.c: separate logic based upon ESP command 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 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 handling of the INTR_FC and INTR_BS bits is different depending upon the last command executed by the ESP. Note that currently INTR_FC is managed elsewhere, but that will change soon. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-60-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 75538f5859..b6cf1b43db 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -862,13 +862,33 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) s->async_buf = scsi_req_get_buf(req); if (!to_device && !s->data_ready) { - /* - * Initial incoming data xfer is complete so raise command - * completion interrupt - */ s->data_ready = true; - s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); + + switch (s->rregs[ESP_CMD]) { + case CMD_SEL | CMD_DMA: + case CMD_SEL: + case CMD_SELATN | CMD_DMA: + case CMD_SELATN: + case CMD_SELATNS | CMD_DMA: + case CMD_SELATNS: + /* + * Initial incoming data xfer is complete so raise command + * completion interrupt + */ + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + break; + + case CMD_TI | CMD_DMA: + case CMD_TI: + /* + * Bus service interrupt raised because of initial change to + * DATA phase + */ + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + break; + } } /* From patchwork Tue Feb 13 19:40: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: 13555635 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 4E6A1C4829A for ; Tue, 13 Feb 2024 20:09:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0X-0004eJ-6B; Tue, 13 Feb 2024 15:03:57 -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 1rZyzd-0003Fd-Qu for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03:02 -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 1rZyzY-00027o-5F for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:58 -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=wTIIn4LXMvqmJOH0ClVC7o3f1Q3UtQq1YSsuVb+bW9U=; b=038VrftRNVrLCE/+2pvD0dqIwr 9z7svIqFiTpVpLdv4FX7rr/4/oUwt9peNkZHO6L07+yIpoUvMGatYITwhs72qCN2BuNlOtMp+OtG7 70vse2i16HxiwRPjlxpFsuSpEZzYkR3msi2ITQTmk15d+khToRuS4kJZqkWvjWJKvpUrBAHsDsch4 B+ZhN4VF+sZuR05tqD2F7roHkk9TkcZ2LrR6E55gEwKjZIHtY72bpDYBSDiOcJXDPY8mmUHtfEuvo UwbABdUMAiXeNbHsJdIT64op/zJQb9Aq4KAIY3/SFyVktEasgopXc1YT46555InB7OB5eLNIN3g/j fx6Mccyd/2xmys97BTeYZNoPUNzyTxQ1dVgwZkJlqJh0iU9d/shJBjs2N2b3BpI6MoMfrD9bw0VSc oThPItNODGpGPE7DpYT8BncO6rUBuPs83E3AdnF4NOwdnWfjjr9PMOBtH0zTXUbUjKQ4Vn6KsmEG7 kO/S9fgBK5rDy5Jxr2GugpvyvxmnwQDfBNWs6Pj25PAS619atsnKfgBqW20p/cK+TWmmV/fYmA9W3 JJEG85xZ7ZrfgDBg/C5GBS5puJ538hUfF3BIxe7IuoxkeM86RC5QLbKa1M8EszYQJFe+JtXI8y/24 pc8MO2uBp/qI+ju2kHTVSOLpX+O1VYyk95RUZdQrU=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygv-0008m4-ET; Tue, 13 Feb 2024 19:43:44 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:24 +0000 Message-Id: <20240213194052.1162753-61-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 60/88] esp.c: use deferred interrupts for both DATA IN and DATA OUT phases 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 brings DATA OUT transfers in line with DATA IN transfers by ensuring that the guest visible function complete interrupt is only set once the SCSI layer has returned. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-61-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index b6cf1b43db..d71465718c 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -248,10 +248,8 @@ static int esp_select(ESPState *s) /* * Note that we deliberately don't raise the IRQ here: this will be done - * either in do_command_phase() for DATA OUT transfers or by the deferred - * IRQ mechanism in esp_transfer_data() for DATA IN transfers + * either in esp_transfer_data() or esp_command_complete() */ - s->rregs[ESP_RINTR] |= INTR_FC; s->rregs[ESP_RSEQ] = SEQ_CD; return 0; } @@ -321,20 +319,17 @@ static void do_command_phase(ESPState *s) datalen = scsi_req_enqueue(s->current_req); s->ti_size = datalen; fifo8_reset(&s->cmdfifo); + s->data_ready = false; if (datalen != 0) { s->ti_cmd = 0; + /* + * Switch to DATA phase but wait until initial data xfer is + * complete before raising the command completion interrupt + */ if (datalen > 0) { - /* - * Switch to DATA IN phase but wait until initial data xfer is - * complete before raising the command completion interrupt - */ - s->data_ready = false; esp_set_phase(s, STAT_DI); } else { esp_set_phase(s, STAT_DO); - s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; - esp_raise_irq(s); - esp_lower_drq(s); } scsi_req_continue(s->current_req); return; @@ -832,9 +827,9 @@ void esp_command_complete(SCSIRequest *req, size_t resid) case CMD_SELATN: /* * No data phase for sequencer command so raise deferred bus service - * interrupt + * and function complete interrupt */ - s->rregs[ESP_RINTR] |= INTR_BS; + s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; break; } @@ -854,14 +849,13 @@ void esp_command_complete(SCSIRequest *req, size_t resid) void esp_transfer_data(SCSIRequest *req, uint32_t len) { ESPState *s = req->hba_private; - int to_device = (esp_get_phase(s) == STAT_DO); uint32_t dmalen = esp_get_tc(s); trace_esp_transfer_data(dmalen, s->ti_size); s->async_len = len; s->async_buf = scsi_req_get_buf(req); - if (!to_device && !s->data_ready) { + if (!s->data_ready) { s->data_ready = true; switch (s->rregs[ESP_CMD]) { @@ -869,6 +863,13 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) case CMD_SEL: case CMD_SELATN | CMD_DMA: case CMD_SELATN: + /* + * Initial incoming data xfer is complete for sequencer command + * so raise deferred bus service and function complete interrupt + */ + s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; + break; + case CMD_SELATNS | CMD_DMA: case CMD_SELATNS: /* @@ -876,7 +877,6 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) * completion interrupt */ s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); break; case CMD_TI | CMD_DMA: @@ -886,9 +886,10 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) * DATA phase */ s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); break; } + + esp_raise_irq(s); } /* From patchwork Tue Feb 13 19:40: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: 13555645 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 9CF88C4829A for ; Tue, 13 Feb 2024 20:12:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0F-0003yT-Nb; Tue, 13 Feb 2024 15:03:40 -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 1rZyyD-0001we-EY for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:35 -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 1rZyyA-0001tR-Bi for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:31 -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=FxqkEyFdghhzUVVrJhMt3r//ymnaPjWR4IuvQZuvoH0=; b=DOILSh1B7I4UkcBtHuatvWcV2p eOYcXGgyE5o7QxziLqLr9Y4KA7Y26xahFS6EUGIHZrRIInR50YqT82qUBLfkljMUSBw9dMDGl8IwW 65wp/u1najC95n92DUwoIodlXmnv1HYxAIFpzUcUJWrpSJ6vJ4cfFVSG7OnLGrRvINemxUzVo9P3Q WN93P0z7cLgxSmmgQ1AYDZ1FkfRBSlBc57oHui+GTP8e5Fgu9pAE4xLn5pAbi8xCsnAuUb2VQQ0q2 Z9n/Hgxqw9rfXI3iwc44uB8UGqW95x2vEsZ0kXGhQwbyRAN0BYyrbWAAZp3GcNzvoTDVBvTP/qWqL 3yNmzqtlqYGAOMDg/V2tRhfuO2EFWAxC10kI8cIIK0dN49Jj34QRAQY/abuamdhdDEP59VhNi3V9X OIb8dSypfds8WsNr0o6MwaaJfdf7DS7ZnmPrLQJWS7bHFBN8086a67vxSoVUauOTohgVuhjTXwSOx ZTdcRSRi4t8VNN3GsoUMhsmhLSnx2A9qatWbF76JM46GkKEIhfXzTqF+WsGPgPLK1TSXVveOD1lkP two52e4NuXCUj+NEGkiaJYC6izMVgDCdr86NTWjyopI0R+Hi5iIrnzWPKW1rKt4UisBiQGpSHth3U vzfE6IdXw4bj84721zbFoHAVBETHZDT3UZSSvQAsM=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZygz-0008m4-15; Tue, 13 Feb 2024 19:43:46 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:25 +0000 Message-Id: <20240213194052.1162753-62-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 61/88] esp.c: remove DATA IN phase logic when reading from 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 Whilst the FIFO is used a storage buffer for both DMA and non-DMA requests, the loading and unloading is managed directly issuing commands to the ESP. As a result there is no need to manually invoke the non-DMA command handler. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-62-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index d71465718c..4c1ca63a57 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1067,17 +1067,6 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr) qemu_log_mask(LOG_UNIMP, "esp: PIO data read not implemented\n"); s->rregs[ESP_FIFO] = 0; } else { - if (esp_get_phase(s) == STAT_DI) { - if (s->ti_size) { - esp_do_nodma(s); - } else { - /* - * The last byte of a non-DMA transfer has been read out - * of the FIFO so switch to status phase - */ - esp_set_phase(s, STAT_ST); - } - } s->rregs[ESP_FIFO] = esp_fifo_pop(&s->fifo); } val = s->rregs[ESP_FIFO]; From patchwork Tue Feb 13 19:40: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: 13555622 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 81FA5C4829A for ; Tue, 13 Feb 2024 20:07:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz06-0003rz-NS; Tue, 13 Feb 2024 15:03:30 -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 1rZyyq-0002Tf-5J for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:14 -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 1rZyyo-0001xu-37 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02: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=2FAFcHNBlVLQuB2GKtdmyAj++mdJ98v5Jcq+mSJLpUg=; b=LlhKRo4zu0s5JcJ/MvAAh1HCvt gs1sZqZW3fcus8zw5cvF151odD6qW4pj21RuqjBDCFjz5iQe32ukkvmeTfJh2ufvSq1egZtA9FS2Y 9Kg//8uYyDlmpfSD5k8kKhqyNVr3qhtAXWF3AJmiCbKfPB9bfF8wPkZsIJ+ljWRf7K30AI8o8wnkq JpN0WaClxFUxVw5tuqOQF0k5m1Vx3hbOqAjNllIEXECV6eInFl1oTAvAvMtsj0I66wOmqbEjdkCme +JVpdU52q7g8ZHNkgqclfEh1OjREOlU6QRSIMawyacqg3QxeuXl5XIhoAVOkh4Wqv0GBadJ/ramqt MgY9H9grJ5gdy0znlYc1VZ6YLdx+eOQ9N+2kFzxQrSSCDPg8TwxRb5Vyw5ZesEBJf6K2lp+PFxPuD HpSP4ocfF31ihs0MOV/FMdHaRCKkSLC8wXT2ErLsuNq63vuv6qRWq5o2NTQHIcVYDYuX64j1pkrxy D6NwUOczK6Pz4Uoh56N/6xHYPeZYaidpfzNJ3Q9sodjiCyQELDzhztIRrDzVpfG/T/IGYxd5jqL+1 8+kyPgoC0V4kHvSceGHeWJmDp+n9DGVD+PiiEyGU2/SRUkGFSsw/nOdguyo0SZCNz+Cuyc3KApi/c eB6hIDC2tHTjGRgqTteLyigF+3EzvBbuEAKD0ot1Y=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyh0-0008m4-IN; Tue, 13 Feb 2024 19:43:46 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:26 +0000 Message-Id: <20240213194052.1162753-63-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 62/88] esp.c: zero command register when TI command terminates due to phase change 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 is the behaviour documented in the datasheet and allows the state machine to correctly process multiple consecutive TI commands. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-63-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 4c1ca63a57..ccb8ad4bae 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -519,6 +519,7 @@ static void esp_do_dma(ESPState *s) /* ATN remains asserted until TC == 0 */ if (esp_get_tc(s) == 0) { esp_set_phase(s, STAT_CD); + s->rregs[ESP_CMD] = 0; s->rregs[ESP_RSEQ] = SEQ_CD; s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); @@ -717,6 +718,7 @@ static void esp_do_nodma(ESPState *s) */ s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); esp_set_phase(s, STAT_CD); + s->rregs[ESP_CMD] = 0; s->rregs[ESP_RSEQ] = SEQ_CD; s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); @@ -831,6 +833,11 @@ void esp_command_complete(SCSIRequest *req, size_t resid) */ s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; break; + + case CMD_TI | CMD_DMA: + case CMD_TI: + s->rregs[ESP_CMD] = 0; + break; } /* Raise bus service interrupt to indicate change to STATUS phase */ @@ -885,6 +892,7 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) * Bus service interrupt raised because of initial change to * DATA phase */ + s->rregs[ESP_CMD] = 0; s->rregs[ESP_RINTR] |= INTR_BS; break; } From patchwork Tue Feb 13 19:40: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: 13555623 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 E1E3AC48260 for ; Tue, 13 Feb 2024 20:07:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz07-0003se-9S; Tue, 13 Feb 2024 15:03:31 -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 1rZyzI-0002sG-P5 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:42 -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 1rZyzG-00025a-TO for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:40 -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=AmLOTtmmzpqanLcUed+jgsCYVlRhvb8feYQvHXvDt9A=; b=UReSvDpJIQhQJRmYN7ql4pKDmB w0zM0UvtThCXeDuBMhNp4TWGNyyLCy3fyxkvfvJQEOtxRwN8H8z9MNyfxx1AJgUTSqDh3goN270Wj JXkovmLthD+uo2L41Ki6HOp6GTfu+0vsY4ONvqF9GARTH7aCfI1viiolQ10fDqNtd871HSGzz+8Oy b3Ey4npMdIC9JWslSL8wGRrxB4l0z7vgPXgIXiAZqhkfiGLcg1JQbXHttKi0oqC7W//XVEC/3mQeb Qs+Ks2ZiksDucj2cbdQ02v2WF1RbIwxnSbNg41zmb/Qfg5Z8lEaWd2XApEk+9YKYkCMSjtzEFqUGn lZ4YnPIFpAe3ipVlW+bZWOKFrY7T9a1lFUN//Pb5vMwJwfHM7JWOk+tM4EbS+VAwj4+YN5NXmUYhU WWsgMoYTz683yleYa1K0MHELwFKE4gY5DfMUqV8rpkhaEoo8UUr/mNl4BZRV/oWE5cZeA9GixROBI aaFIqVHKlqZzQzwE6x8G8NY+ImjHK1fxdsZ+vWhwWCutB0DBx5FxwC+yajnPOsHfDFXAs85b1aKw8 vryT2BYRBkk9xykB8BU944aQXmncL5GGP+89mK4jPpRr1Z3D8emRai3QdRV0zYjSanrU/QVstVEme r+P8Xb6ucuH1LWRu29B6qMdy36ka8vNJI0oArGaxc=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyh0-0008m4-SI; Tue, 13 Feb 2024 19:43:47 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:27 +0000 Message-Id: <20240213194052.1162753-64-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 63/88] esp.c: remove unneeded ti_cmd field 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 According to the datasheet the previous ESP command remains in the ESP_CMD register, which caused a problem when consecutive TI commands were issued as it becomes impossible for the state machine to know when the first TI command finishes. This was the original reason for introducing the ti_cmd field which kept track of the last written command for this purpose. However closer reading of the datasheet shows that a TI command that terminates due to a change of SCSI target phase resets the ESP_CMD register to zero which solves this problem. Now that this has been fixed in the previous commit, remove the unneeded ti_cmd field and access the ESP_CMD register directly instead. Bump the vmstate_esp version to indicate that the ti_cmd field is no longer included. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-64-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 19 +++++++++++++------ include/hw/scsi/esp.h | 3 ++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index ccb8ad4bae..bcebd00831 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -321,7 +321,6 @@ static void do_command_phase(ESPState *s) fifo8_reset(&s->cmdfifo); s->data_ready = false; if (datalen != 0) { - s->ti_cmd = 0; /* * Switch to DATA phase but wait until initial data xfer is * complete before raising the command completion interrupt @@ -908,12 +907,12 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) * async data transfer is delayed then s->dma is set incorrectly. */ - if (s->ti_cmd == (CMD_TI | CMD_DMA)) { + if (s->rregs[ESP_CMD] == (CMD_TI | CMD_DMA)) { /* When the SCSI layer returns more data, raise deferred INTR_BS */ esp_dma_ti_check(s); esp_do_dma(s); - } else if (s->ti_cmd == CMD_TI) { + } else if (s->rregs[ESP_CMD] == CMD_TI) { esp_do_nodma(s); } } @@ -927,7 +926,6 @@ static void handle_ti(ESPState *s) return; } - s->ti_cmd = s->rregs[ESP_CMD]; if (s->dma) { dmalen = esp_get_tc(s); trace_esp_handle_ti(dmalen); @@ -1200,6 +1198,14 @@ static bool esp_is_version_6(void *opaque, int version_id) return version_id >= 6; } +static bool esp_is_between_version_5_and_6(void *opaque, int version_id) +{ + ESPState *s = ESP(opaque); + + version_id = MIN(version_id, s->mig_version_id); + return version_id >= 5 && version_id <= 6; +} + int esp_pre_save(void *opaque) { ESPState *s = ESP(object_resolve_path_component( @@ -1237,7 +1243,7 @@ static int esp_post_load(void *opaque, int version_id) const VMStateDescription vmstate_esp = { .name = "esp", - .version_id = 6, + .version_id = 7, .minimum_version_id = 3, .post_load = esp_post_load, .fields = (const VMStateField[]) { @@ -1265,7 +1271,8 @@ const VMStateDescription vmstate_esp = { VMSTATE_UINT8_TEST(cmdfifo_cdb_offset, ESPState, esp_is_version_5), VMSTATE_FIFO8_TEST(fifo, ESPState, esp_is_version_5), VMSTATE_FIFO8_TEST(cmdfifo, ESPState, esp_is_version_5), - VMSTATE_UINT8_TEST(ti_cmd, ESPState, esp_is_version_5), + VMSTATE_UINT8_TEST(mig_ti_cmd, ESPState, + esp_is_between_version_5_and_6), VMSTATE_UINT8_TEST(lun, ESPState, esp_is_version_6), VMSTATE_END_OF_LIST() }, diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index 1036606943..39b416f538 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -41,7 +41,6 @@ struct ESPState { uint32_t do_cmd; bool data_ready; - uint8_t ti_cmd; int dma_enabled; uint32_t async_len; @@ -62,6 +61,8 @@ struct ESPState { uint8_t mig_ti_buf[ESP_FIFO_SZ]; uint8_t mig_cmdbuf[ESP_CMDFIFO_SZ]; uint32_t mig_cmdlen; + + uint8_t mig_ti_cmd; }; #define TYPE_SYSBUS_ESP "sysbus-esp" From patchwork Tue Feb 13 19:40: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: 13555614 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 081A4C48260 for ; Tue, 13 Feb 2024 20:04:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyxk-00015P-Dv; Tue, 13 Feb 2024 15:01:04 -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 1rZyxK-0000qY-RY for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00: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 1rZyxI-0001kx-Px for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:37 -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=f1NEFO4A0Vqg4tfIZJi/bQTZ9CGMao8x83kojNhLktk=; b=T1KdvEqQUD6rfsiY0u+o9+CBq1 qvXjjqIAiNm7Tmct0gKtztsm+b9i1Ty7Glw/60WEW60ZrpB/1REbajNhmdQVFxyuCKg48kIK7j/Gu Q8eBt78sD4yonEFPCBJaMZZZmczDFGs8oqYKj6aZo3roTJvi+wFb9pkUK0p+cLVmeFh9O4v9k8MH8 KC6ExYI5qGCx3F4S7JqF73pW4rGLwkhJoH+i6n25DQ3AoiaslNlAa8gvr73rmd2U7ibXC0f+CBnZT yBz69iUyxWbQ3L0b54LsY5kPaRZ/xah/2eP92J9nY3SlhEZIUohruuSWAMIPrNALKui1FzVhDj9m/ s2UAU8FVDjTxS//i3q6j4qDS6T0H6//WhjGnOyP9ec/4l/6VlIFhxhIMPWF+5JLgU1OzE8+I8sUab lQ5ntY6waqSa/sDTzV3Oa8Re3paF2s4fGkv5wk/ndH38JBR6R1eU2tb/SVJivPKp6Avm0t/qJt3Q2 bflfPZbpYzK+X4s+7vxBB/ES7PUh3kXVvnhoI7q77qQ7hLNWOBCWBqCsYkxDx78wQ8sCs6pZrVfA7 JJ+gHp8aCk5ftFkRSFveEITpK2e/JIZuj9ImE0YSqHCbxlHgKDMGbalJe7tiB3gsNU98EWcaY9C1q 92J1YeoZW6402xoBSv9Oj8LQhtWNKaNaWjv01gjgQ=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyh1-0008m4-9D; Tue, 13 Feb 2024 19:43:47 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:28 +0000 Message-Id: <20240213194052.1162753-65-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 64/88] esp.c: don't raise INTR_BS interrupt in DATA IN phase until TI command issued 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 In the case where a SCSI command with a DATA IN phase has been issued, the host may preload the FIFO with unaligned bytes before issuing the main DMA transfer. When accumulating data in the FIFO don't raise the INTR_BS interrupt until the TI command is issued, otherwise the unexpected interrupt can confuse the host. In particular this is needed to prevent the MacOS Disk Utility from failing when switching non-DMA transfers to use esp_do_nodma(). Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-65-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index bcebd00831..dd6bf6f033 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -786,6 +786,11 @@ static void esp_do_nodma(ESPState *s) return; } + /* If preloading the FIFO, defer until TI command issued */ + if (s->rregs[ESP_CMD] != CMD_TI) { + return; + } + s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); break; From patchwork Tue Feb 13 19:40: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: 13555626 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 7B41BC48260 for ; Tue, 13 Feb 2024 20: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 1rZyxm-00018W-5m; Tue, 13 Feb 2024 15:01:06 -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 1rZyxk-000160-Lb for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:04 -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 1rZyxj-0001r7-1j for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:04 -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=fpzBA+7GFlMOQ4t/d6UBbflE8tH54gT4wO/aQ7VHP80=; b=RsWLnDeHkr72mhsCOBHkrGPpFv 0zETWLK+rCpF4u+2GLKb/QPOJbX1xBJ2cvHmjaVaKIHI8ghkrwkg2fY5afQfE8zhb8XvQYQT+lm3Y zRCwPpQmVDR74l6pvVpbJFcsF5500lfTOsJELkOPVvRg7CTZZV+Emzxa3ln5CKK2F28/uohasj4UY WZ6DtfGemM35jXfveRQ/ohHMxDiU9jiOsqcPrJ/BLh9m3f9jBLQ7ovQz21QTJv7YN/layWXIVVPkJ J6qDCqdfvesueJqcTtrIMgrcq5p3WbjKtbSY0mu/ZrY6mdMlJgJlOaqd7Qoumji/mIkF8eC6GyZ2x /hNksCdtK5jvzRpvdoID+5I04Rekyy/95vRsZe+4zG0Myh6V23dSnTO8sjrES2S0jb345HUTuWE40 4JHUdgNAnk4Us0f9xgRynVJWpwvMd5Mo7kGRPFkA9AZlkimf56laSSKhoCF1kn+g1+P5rzDVJ0tqX 1KcITbeB7x5ox8EIWC3qLpjWhbso31ipfEaAIocqB887yMtMxLzg2cdvnMdHa2KbSSqlBRJiVweD+ 4q/tjBT0RaGTa1e2dnkZA82ftZyAuvR5x9EvYkUuxa0bAogzVAfZ7BI4zbTJww7pclL6wEFsqzevK vBSBDUPXKExCQ8372DU6qfVh0YYyd0vnXOXi34biE=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyh1-0008m4-J8; Tue, 13 Feb 2024 19:43:51 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:29 +0000 Message-Id: <20240213194052.1162753-66-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 65/88] esp.c: move non-DMA TI logic to separate esp_nodma_ti_dataout() function 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 is to allow the logic to be moved during the next commit. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-66-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index dd6bf6f033..97e48e9526 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -697,11 +697,38 @@ static void esp_do_dma(ESPState *s) } } +static void esp_nodma_ti_dataout(ESPState *s) +{ + int len; + + if (!s->current_req) { + return; + } + if (s->async_len == 0) { + /* Defer until data is available. */ + return; + } + 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); + s->async_buf += len; + s->async_len -= len; + s->ti_size += len; + + if (s->async_len == 0) { + scsi_req_continue(s->current_req); + return; + } + + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); +} + static void esp_do_nodma(ESPState *s) { uint8_t buf[ESP_FIFO_SZ]; uint32_t cmdlen; - int len, n; + int n; switch (esp_get_phase(s)) { case STAT_MO: @@ -743,27 +770,7 @@ static void esp_do_nodma(ESPState *s) break; case STAT_DO: - if (!s->current_req) { - return; - } - if (s->async_len == 0) { - /* Defer until data is available. */ - return; - } - 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); - s->async_buf += len; - s->async_len -= len; - s->ti_size += len; - - if (s->async_len == 0) { - scsi_req_continue(s->current_req); - return; - } - - s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); + esp_nodma_ti_dataout(s); break; case STAT_DI: From patchwork Tue Feb 13 19:40: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: 13555632 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 9F1E0C48260 for ; Tue, 13 Feb 2024 20:09:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0m-00055e-KI; Tue, 13 Feb 2024 15:04:13 -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 1rZz0E-00041b-VN for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03: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 1rZz0C-0002B4-Ca for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03: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=0NRcn/IVWnhbhGG6RcEiTn0iGpwFckjaZk+w0L8ahyA=; b=bdkxWR+tDMagtkFOfuf11XpUTj 9XbhRr5xR+hIw0Av5cgG3lS4Qpbz7rp/kLfPb4kYcS/oD0oEs63hjwkSND79iy+EfU88nwfZWwnIS b1oYDUQwXBiXKd4E+KHsgvb2LgOSw5QneXD/SE0wtZGZTQAwA74VhknPl2pGghPvzcDjrDcebsnBX OwQCIEba6A8MY6fmJneJlyX1tujJhMaFShd5NU0uWq7gZU5E/ZRsUTOJHdlb3oIuX8CCHl+f7ZF59 LzWNU9nsVgXvi7IWwzkafbBjc5hJXYkwuAnpnhiPzP+CJ5f+tfB7deEg8GVZ3KK3viMqxLr6dIDBS xThqIvn3gseBpzHBOs3lWPkYK/Z5RSGwDDV/b3xRaZYuu/p0M0oySTpQHEnLWCvYBJ27PCUvReTh6 RxbUE4OyEPSdG//3bB5DNHa4SK4zhhEntZzhowwaC5lRG9uSxpbhDkqpHRWUdssLVEPCskB+f0j4R M0eQ6p4R9Z/WSCEzk/uBS1+365a5Tag1RmApAdgoyPhgJkKoYkLHQ09jKqyB/VMIRDPCBscVpuxsL AIUAUdXwJxfF+dTDbAjY1w2CO/sBCYfxMtKfoAS35mQGTOQV1YKiBDxMuAI3jKqQKUkSP6ibwjYoN 4KWfrL/5nzgBjDoWKXdit/bx1pBqXhmsUhQL9n9Qw=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyh5-0008m4-ME; Tue, 13 Feb 2024 19:43:55 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:30 +0000 Message-Id: <20240213194052.1162753-67-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 66/88] esp.c: process non-DMA FIFO writes in esp_do_nodma() 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 Currently any write to the ESP FIFO in the MESSAGE OUT or COMMAND phases will manually raise the bus service interrupt. Instead of duplicating the interrupt logic in esp_reg_write(), update esp_do_nodma() to correctly process incoming FIFO data during the MESSAGE OUT and COMMAND phases. Part of this change is to call esp_nodma_ti_dataout() from handle_ti() to ensure that the DATA OUT phase FIFO transfer only occurs when executing a non-DMA TI command instead of for each byte entering the FIFO. One slight complication is that NextSTEP uses multiple TI commands to transfer the CDB one byte at a time (as opposed to loading the FIFO and using a single TI command), so it is necessary to determine the expected length of the SCSI CDB being received. This is handled by the introduction of a new esp_cdb_length() function which returns the expected SCSI CDB length based upon the first command byte. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-67-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 121 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 86 insertions(+), 35 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 97e48e9526..5bb8cc4ea7 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -420,6 +420,7 @@ static void handle_satn_stop(ESPState *s) esp_set_phase(s, STAT_MO); s->rregs[ESP_RSEQ] = SEQ_MO; + s->cmdfifo_cdb_offset = 0; if (s->dma) { esp_do_dma(s); @@ -454,6 +455,22 @@ static void write_response(ESPState *s) } } +static int esp_cdb_length(ESPState *s) +{ + const uint8_t *pbuf; + int cmdlen, len; + + cmdlen = fifo8_num_used(&s->cmdfifo); + if (cmdlen < s->cmdfifo_cdb_offset) { + return 0; + } + + pbuf = fifo8_peek_buf(&s->cmdfifo, cmdlen, NULL); + len = scsi_cdb_length((uint8_t *)&pbuf[s->cmdfifo_cdb_offset]); + + return len; +} + static void esp_dma_ti_check(ESPState *s) { if (esp_get_tc(s) == 0 && fifo8_num_used(&s->fifo) < 2) { @@ -738,16 +755,40 @@ static void esp_do_nodma(ESPState *s) fifo8_push_all(&s->cmdfifo, buf, n); s->cmdfifo_cdb_offset += n; - /* - * Extra message out bytes received: update cmdfifo_cdb_offset - * and then switch to command phase - */ - s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); - esp_set_phase(s, STAT_CD); - s->rregs[ESP_CMD] = 0; - s->rregs[ESP_RSEQ] = SEQ_CD; - s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); + switch (s->rregs[ESP_CMD]) { + case CMD_SELATN: + if (fifo8_num_used(&s->cmdfifo) >= 1) { + /* First byte received, switch to command phase */ + esp_set_phase(s, STAT_CD); + s->cmdfifo_cdb_offset = 1; + + if (fifo8_num_used(&s->cmdfifo) > 1) { + /* Process any additional command phase data */ + esp_do_nodma(s); + } + } + break; + + case CMD_SELATNS: + if (fifo8_num_used(&s->cmdfifo) == 1) { + /* First byte received, stop in message out phase */ + s->cmdfifo_cdb_offset = 1; + + /* Raise command completion interrupt */ + s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; + esp_raise_irq(s); + } + break; + + case CMD_TI: + /* ATN remains asserted until FIFO empty */ + s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); + esp_set_phase(s, STAT_CD); + s->rregs[ESP_CMD] = 0; + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + break; + } break; case STAT_CD: @@ -756,21 +797,40 @@ static void esp_do_nodma(ESPState *s) n = MIN(fifo8_num_free(&s->cmdfifo), n); fifo8_push_all(&s->cmdfifo, buf, n); - cmdlen = fifo8_num_used(&s->cmdfifo); - trace_esp_handle_ti_cmd(cmdlen); - s->ti_size = 0; + switch (s->rregs[ESP_CMD]) { + case CMD_TI: + cmdlen = fifo8_num_used(&s->cmdfifo); + trace_esp_handle_ti_cmd(cmdlen); + + /* CDB may be transferred in one or more TI commands */ + if (esp_cdb_length(s) && esp_cdb_length(s) == + fifo8_num_used(&s->cmdfifo) - s->cmdfifo_cdb_offset) { + /* Command has been received */ + do_cmd(s); + } else { + /* + * If data was transferred from the FIFO then raise bus + * service interrupt to indicate transfer complete. Otherwise + * defer until the next FIFO write. + */ + if (n) { + /* Raise interrupt to indicate transfer complete */ + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + } + } + break; - /* No command received */ - if (s->cmdfifo_cdb_offset == fifo8_num_used(&s->cmdfifo)) { - return; + case CMD_SEL: + case CMD_SELATN: + /* FIFO already contain entire CDB */ + do_cmd(s); + break; } - - /* Command has been received */ - do_cmd(s); break; case STAT_DO: - esp_nodma_ti_dataout(s); + /* Accumulate data in FIFO until non-DMA TI is executed */ break; case STAT_DI: @@ -945,6 +1005,10 @@ static void handle_ti(ESPState *s) } else { trace_esp_handle_ti(s->ti_size); esp_do_nodma(s); + + if (esp_get_phase(s) == STAT_DO) { + esp_nodma_ti_dataout(s); + } } } @@ -1141,23 +1205,10 @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) s->rregs[ESP_RSTAT] &= ~STAT_TC; break; case ESP_FIFO: - if (esp_get_phase(s) == STAT_MO || esp_get_phase(s) == STAT_CD) { - if (!fifo8_is_full(&s->fifo)) { - esp_fifo_push(&s->fifo, val); - esp_fifo_push(&s->cmdfifo, fifo8_pop(&s->fifo)); - } - - /* - * If any unexpected message out/command phase data is - * transferred using non-DMA, raise the interrupt - */ - if (s->rregs[ESP_CMD] == CMD_TI) { - s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); - } - } else { + if (!fifo8_is_full(&s->fifo)) { esp_fifo_push(&s->fifo, val); } + esp_do_nodma(s); break; case ESP_CMD: s->rregs[saddr] = val; From patchwork Tue Feb 13 19:40: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: 13555644 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 A87C4C4829A for ; Tue, 13 Feb 2024 20:12:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyzt-0003Y2-N0; Tue, 13 Feb 2024 15:03:17 -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 1rZyy8-0001tJ-Gk for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:34 -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 1rZyy5-0001su-UR for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:27 -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=eJ1paP8kPRvhyZEgQSLmYnxE9wIiYP8JdAt5y+q0tAc=; b=kqaz/UC/I7sJibyd6dqU9JPSbc QZO2glXTsiw8OwbELYWRBLZVGZw2TzQO6byCNBzxJzW90BRl06PmldY0gk8UoW9yLqy3HO6QdDJLX KG1UhBLIn1K9BHaRY05/6b1G8JKqdyhYBSHh7TYgFQUbHbgYsD/pTbQXVEE/t9KL3zQoCkYMJYdi3 iDHfTRj2srhJ/Yp7iR2tTr7osoHn/IjW+xNP5tX3jYZktLQfyWyzYwZ/4ep+7eZIBG+baH0nfdfbW sEQTJoBre2yGEZ0oQXQqE+rMAF4jswNYs0s8f0nqS66VLICoOaEDCzGnmjnGr0cJlyKtHv5cojYAc EeSBMJRPpBUSdY586awvIZ2rWO/AxUxLFXvZCjv/8ZJRLMu4hWb2iPPEdHOyeZQa17g/gvvhQHPOk FPKpBH6L7g/nJYrBOaQ5f5XJCPUdHSMd2BG/dXf0ZeYtiXQx+SH/qmJ/S+LDlG3gYRanopuCd8y4M oqn+dK8p1bfcUOKvNUO6J9oHlxPTil1evE5HwN3Yqw4yHQEXcwya3hl6/BfixtfSZx03H9oVJ1/Qq KNwElBKGLgvjtMvdUA4CNAf1BJhTGQlLghj0I+bUHsA/U3dTxGk3MjnyJbcJfXzUD2z9EbYHyM+TQ vsTEzjgPAQW4foF6Zbk70Uy6RTfol7AbMDx2xfv1U=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyh9-0008m4-PK; Tue, 13 Feb 2024 19:43:59 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:31 +0000 Message-Id: <20240213194052.1162753-68-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 67/88] esp.c: replace get_cmd() with esp_do_nodma() 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 the esp_do_nodma() state machine correctly handles incoming FIFO data, all remaining users of get_cmd() can be replaced with esp_do_nodma() and the get_cmd() function removed completely. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-68-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 54 ++++----------------------------------------------- 1 file changed, 4 insertions(+), 50 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 5bb8cc4ea7..277eb8647b 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -257,40 +257,6 @@ static int esp_select(ESPState *s) static void esp_do_dma(ESPState *s); static void esp_do_nodma(ESPState *s); -static uint32_t get_cmd(ESPState *s, uint32_t maxlen) -{ - uint8_t buf[ESP_CMDFIFO_SZ]; - uint32_t dmalen, n; - int target; - - target = s->wregs[ESP_WBUSID] & BUSID_DID; - if (s->dma) { - dmalen = MIN(esp_get_tc(s), maxlen); - if (dmalen == 0) { - return 0; - } - if (s->dma_memory_read) { - s->dma_memory_read(s->dma_opaque, buf, dmalen); - dmalen = MIN(fifo8_num_free(&s->cmdfifo), dmalen); - fifo8_push_all(&s->cmdfifo, buf, dmalen); - esp_set_tc(s, esp_get_tc(s) - dmalen); - } else { - return 0; - } - } else { - dmalen = MIN(fifo8_num_used(&s->fifo), maxlen); - if (dmalen == 0) { - return 0; - } - n = esp_fifo_pop_buf(&s->fifo, buf, dmalen); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); - } - trace_esp_get_cmd(dmalen, target); - - return dmalen; -} - static void do_command_phase(ESPState *s) { uint32_t cmdlen; @@ -376,10 +342,7 @@ static void handle_satn(ESPState *s) if (s->dma) { esp_do_dma(s); } else { - if (get_cmd(s, ESP_CMDFIFO_SZ)) { - s->cmdfifo_cdb_offset = 1; - do_cmd(s); - } + esp_do_nodma(s); } } @@ -401,9 +364,7 @@ static void handle_s_without_atn(ESPState *s) if (s->dma) { esp_do_dma(s); } else { - if (get_cmd(s, ESP_CMDFIFO_SZ)) { - do_cmd(s); - } + esp_do_nodma(s); } } @@ -425,14 +386,7 @@ static void handle_satn_stop(ESPState *s) if (s->dma) { esp_do_dma(s); } else { - if (get_cmd(s, 1)) { - trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); - - /* Raise command completion interrupt */ - s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; - s->rregs[ESP_RSEQ] = SEQ_MO; - esp_raise_irq(s); - } + esp_do_nodma(s); } } @@ -770,7 +724,7 @@ static void esp_do_nodma(ESPState *s) break; case CMD_SELATNS: - if (fifo8_num_used(&s->cmdfifo) == 1) { + if (fifo8_num_used(&s->cmdfifo) >= 1) { /* First byte received, stop in message out phase */ s->cmdfifo_cdb_offset = 1; From patchwork Tue Feb 13 19:40: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: 13555638 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 1497CC48260 for ; Tue, 13 Feb 2024 20:09:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz03-0003nw-JP; Tue, 13 Feb 2024 15:03: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 1rZyyQ-000298-GM for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:49 -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 1rZyyO-0001tq-V3 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:46 -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=y5k/Qsj7Cz3nbSk7L69u+FdeVqYBrUsnn213llf00Ts=; b=s2uayqGZRoimD2DDtTGBE46OlC +lZg7lDXy2uHPE/KzsfSSJCQgBLVtgzDXiGnmj2ocw5GiC3bHT4DTXlyP+wxn6NWeA35g9FF0Tr5i uWjMuA0oJppkFzPc6cNEfrfHAL51j3CcH4la9kmH+/Swhf5/KH+gNErP024hLn22GpwR5qIMBfaEL rKIyTh7jmjZORPWRdwzYhkm2qYwqAK7cSiZPfJJljt7wbhmGlee44pr/VPJTTHU5NISLVs4uqcMMA gzQBZMLEhuf27TYoZkneSpFCdlngj/ZrfVWlz6E2HZ6DwasUWEznixV59VrLVG2Dvy9ZrUaLhUWr/ dnzmOf5pngzRMMlNuoMIeV8dUCZTgIIF7B1RMGyDX5EvvruVXYECknUWtEGvM9eQcfbDBcakDra9C RbJTS2jTb927by2sVRPkIpKy8C5SyyJ26K0KM0IfmwjCR5HYjX2MVtvzqVzxqWQMTiX8F4L+urYW4 uCEByPr5gnessvxjvzGYhgSvbeMUmFZJ/RsiuPJMowGA4322uee26v3TNnCCOKDAVIQ/sELY6fs+4 JlT9ebFqs4DPZ7bDEtgvTnPIkja2gDdhnTEtEvC1xvlxqTyzflGO2bZ3gUCpMX1v63XNuiOdzo6Dl BSzJn/lrwwjOAfw8ID6YFtMzaAqVkVdYf9m1DiN34=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhD-0008m4-Bs; Tue, 13 Feb 2024 19:44:03 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:32 +0000 Message-Id: <20240213194052.1162753-69-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 68/88] esp.c: move write_response() non-DMA logic to esp_do_nodma() 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 moves the remaining non-DMA STATUS and MESSAGE IN phase logic from write_response() to esp_do_nodma(). Note that we can also now drop the extra fifo_reset() which is no longer required. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-69-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 277eb8647b..824ebe9ff0 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -392,20 +392,12 @@ static void handle_satn_stop(ESPState *s) static void write_response(ESPState *s) { - uint8_t buf[2]; - trace_esp_write_response(s->status); if (s->dma) { esp_do_dma(s); } else { - buf[0] = s->status; - buf[1] = 0; - - fifo8_reset(&s->fifo); - fifo8_push_all(&s->fifo, buf, 2); - s->rregs[ESP_RFLAGS] = 2; - esp_raise_irq(s); + esp_do_nodma(s); } } @@ -815,6 +807,28 @@ static void esp_do_nodma(ESPState *s) s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); break; + + case STAT_ST: + switch (s->rregs[ESP_CMD]) { + case CMD_ICCS: + fifo8_push(&s->fifo, s->status); + esp_set_phase(s, STAT_MI); + + /* Process any message in phase data */ + esp_do_nodma(s); + break; + } + break; + + case STAT_MI: + switch (s->rregs[ESP_CMD]) { + case CMD_ICCS: + fifo8_push(&s->fifo, 0); + + esp_raise_irq(s); + break; + } + break; } } From patchwork Tue Feb 13 19:40: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: 13555607 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 A0C37C4829A for ; Tue, 13 Feb 2024 20:01:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyxL-0000qS-Az; Tue, 13 Feb 2024 15:00:39 -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 1rZyx9-0000hj-12 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:31 -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 1rZyx4-0001hQ-Mf for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:25 -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=LWOTl987PIcH80dpnfqtbG3+CxPjlNs17wDfO2QvnWM=; b=IgDwwzeicle1YoU1IjzinSsmXc gLeIKNBHDg4FS+KmoKWxxNH8ti9bgtn0y4edkbZs6aveOkGfsUhmZTMga/ilYmWBuWqmcGvm8FjZY wOI0NN//TfOw+r8v6yp3Pv+c0uzC1/2FS851BqLy4wJUEBH2ZMgtllee8RkmDp7jUEkj11hWROA/3 2Tyac2fjxp5A4L4kIfX2Q+qiq/HK1b+2WoVCeGp8dMUDMYAinaX737lyEB/Fec3UfDOxw3ZreP9lL X6W7zXPEzXdVPNE/WeJFr6wZajBAUpcMlpblS5k8phxwH4Ky2vOM+rW1dpJ1t+4eHTjHVVBJDIHCe ykm33Ef0pw6bU0vQ5/ob0Ou0lIxE8THKHeriGj8HzHzi8cM4q4mUGX4zb9QVOw21OU9B4q0FYX1dh u+FkBVorrl+TwtArGpnpvQ929xY8CvJNPFViMrnXvxsDRXn9jWhN0pdBOXL+YtyirbIXnerAiKYWh hqW5W3h/h8yKwdJDyIhNGGvhgnSTuh7xA79D7kh2VwbGUS7L0h2R5g7Zga3p2uNIsz8TDJdfSNAri nIQFSmlxFYyur/8D0b1Mc2G27fzdzDI5AQW5pOspJbMRon2gSfmBPyrymzPzra6oTZ0purKqZDMRk xxsx+N/bVebivcaLt8VRN7iMda6x54ESXhsy82M3k=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhH-0008m4-Ew; Tue, 13 Feb 2024 19:44:06 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:33 +0000 Message-Id: <20240213194052.1162753-70-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 69/88] esp.c: consolidate end of command sequence after ICCS command 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 end of command sequences for the ICCS command are currently different between the DMA and non-DMA versions, and also different from the description in the datasheet. Update the sequence so that only INTR_FC is asserted in both cases, and keep all the logic in esp_do_dma() and esp_do_nodma() rather than having some of it within esp_run_cmd(). Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-70-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 824ebe9ff0..6c62417985 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -650,8 +650,7 @@ static void esp_do_dma(ESPState *s) } /* Raise end of command interrupt */ - s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; - s->rregs[ESP_RSEQ] = SEQ_CD; + s->rregs[ESP_RINTR] |= INTR_FC; esp_raise_irq(s); } break; @@ -825,6 +824,8 @@ static void esp_do_nodma(ESPState *s) case CMD_ICCS: fifo8_push(&s->fifo, 0); + /* Raise end of command interrupt */ + s->rregs[ESP_RINTR] |= INTR_FC; esp_raise_irq(s); break; } @@ -1056,8 +1057,6 @@ static void esp_run_cmd(ESPState *s) case CMD_ICCS: trace_esp_mem_writeb_cmd_iccs(cmd); write_response(s); - s->rregs[ESP_RINTR] |= INTR_FC; - esp_set_phase(s, STAT_MI); break; case CMD_MSGACC: trace_esp_mem_writeb_cmd_msgacc(cmd); From patchwork Tue Feb 13 19:40:34 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: 13555608 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 75AD2C48260 for ; Tue, 13 Feb 2024 20:01:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyxO-0000sU-5W; Tue, 13 Feb 2024 15:00:42 -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 1rZyxD-0000jL-Ml for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:33 -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 1rZyxB-0001j9-N7 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:31 -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=UcLQegnMEj2QqxMcZ4nrFanoPpIbn3t7tK5XSeRX+u0=; b=tyI6Xb+xl6FB2GEljcdfjKOmgA sY21XsQfZANUepFTKDv6lAtxfjbLAH6zajmq7mb4ajQJE/dJHpvNcIu5AI8JNTQM+0+dU/CTI8bd7 kIS1ISy1S/R8Avj0ilqut6kfSt/XENJXygxvokUBKfBSrBiPjRsOlQxcyWdetdURfRrQnBOsi+BaQ 5r2NO7p9lLFx7Y1bskIdyYYkQWusLIaNfQQxKdXDDhGuvvmm/UugnDhAbCrekvAAT1YnU3zVUzc4W hMIcOdZPd6R9n/f6oGhmz647mv2/upwe8sJpMLb4/AD18DxYQSeH1uDeXEFtOpnWqtXkCUONoDSKo b4aDE9/yldEYHO9/q18RZV1MAM0ZIpeAP+xbs8XYGvqTUnVLm92TXwXAJ73sz9zWFKklhJ6Nbm5Bb 2MRh9/lSBe2eAtPqS3Y7zXy3f19is2M865YltDaI7aVROtArM4+CB9qlThqhg0ILfs328LGNwcpEp uu0TXiQSFYWdZJRkl1fElC1kUPgWEUTnSzelbq66HHLnT4l0Yo20MEeJgmw7hzROONutyt09f9kpf f9CfLigx+BgKtEjs0z/77SOk+9eicAHXl/Pn7O5NHg8xpldMUEdi6AWKcrO9D7V7NfiMA0njaOOxv LD7grMCJXUN6EBJfZhEuqFL0UV1mb0qj5CX/kbuyU=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhL-0008m4-1Z; Tue, 13 Feb 2024 19:44:10 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:34 +0000 Message-Id: <20240213194052.1162753-71-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 70/88] esp.c: ensure that STAT_INT is cleared when reading ESP_RINTR 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 Both esp_raise_irq() and esp_lower_irq() check the STAT_INT bit in ESP_RSTAT to ensure that the IRQ is raised or lowered if its state changes. When reading ESP_RINTR, esp_lower_irq() was being called *after* ESP_RSTAT had been cleared meaning that STAT_INT was already clear, and so if STAT_INT was asserted beforehand then the esp_lower_irq() would have no effect. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-71-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 6c62417985..604fb9235d 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1127,6 +1127,7 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr) */ val = s->rregs[ESP_RINTR]; s->rregs[ESP_RINTR] = 0; + esp_lower_irq(s); s->rregs[ESP_RSTAT] &= ~STAT_TC; /* * According to the datasheet ESP_RSEQ should be cleared, but as the @@ -1137,7 +1138,6 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr) * * s->rregs[ESP_RSEQ] = SEQ_0; */ - esp_lower_irq(s); break; case ESP_TCHI: /* Return the unique id if the value has never been written */ From patchwork Tue Feb 13 19:40:35 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: 13555625 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 D32C5C4829A for ; Tue, 13 Feb 2024 20:08:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyxl-000177-EN; Tue, 13 Feb 2024 15:01:05 -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 1rZyxQ-0000tp-Mu for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:46 -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 1rZyxM-0001le-4t for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:43 -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=C/4b2qXYE5TasC3qTglGpRtlfM4iIhOd0YqVHhOTuUg=; b=FOVrJMCrwPIXzmG42lgsAJ5TZc 7JvG9F6P1DkgxcGdDhXR9gZ94ad47IsIhNCyC8mT8+2d8rZtJnpXTV2gF66Hd2/gICVHYCBCJvYFy EaTVMLRGSA/CCo/1mffKpSG6dPRZe84DCLizU+oOnFMPk0SNf9KA/7UarozSBXFNHJH/TrLHKmths QsxS17GzuYXF4SmxttkaJQC2lu6z2vd1j0/PoULIs7QawUZyN2MaipxXhkbpbQJzqIXRD+tiVsaq2 PlAsyh5zaBbl8h/NnijbvsAjOrab9s2Tn+yVd9VF+Dbk9ckYSI2rdQJtX1wTjjpEjpc2XkoUSyH3X p+dGddc1v6UJDPrqOnv6PwPEPOtVlM1I/cZ9cUMF8THIhWJzAFhKfMkQlLMXCxqWAMjygOpgB3fF3 ARq8cjEEOShCnj4jwnAYKie83zddKo3YZNsnUxqkmwRMXRTVgbhEwsMIo3Lhut3O4peDg53Phjxeu 3K25gmLfrlt0tYHl8GgzlzlzRIj7ngpwa1N/LsScNyH3OFMlw57/b13Tp+s4+jGhU/fl9HcyEyWUR DhNHRZ5s5KyUUnKlkDJZYz4dXZhTS3hXhtu+yLlA7IJM00BtP+8+nMrPQAuVjlv9Qy4wwQ4Hf7kqG OnPPmbKkVaN106G4mbuFT8kS2kWwRPJZ/0HD+SMHA=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhO-0008m4-KN; Tue, 13 Feb 2024 19:44:11 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:35 +0000 Message-Id: <20240213194052.1162753-72-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 71/88] esp.c: don't clear the SCSI phase when reading ESP_RINTR 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 According to the documentation ESP_RSTAT is cleared (except the STAT_TC bit) when ESP_RINTR is read. This should not include the SCSI bus phase bits which are currently live from the SCSI bus, otherwise the current SCSI phase is lost when clearing an end-of-transfer interrupt. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-72-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 604fb9235d..8ea100ee9c 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1128,7 +1128,7 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr) val = s->rregs[ESP_RINTR]; s->rregs[ESP_RINTR] = 0; esp_lower_irq(s); - s->rregs[ESP_RSTAT] &= ~STAT_TC; + s->rregs[ESP_RSTAT] &= STAT_TC | 7; /* * According to the datasheet ESP_RSEQ should be cleared, but as the * emulation currently defers information transfers to the next TI From patchwork Tue Feb 13 19:40:36 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: 13555628 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 4D259C4829F for ; Tue, 13 Feb 2024 20:09:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz02-0003n9-UF; Tue, 13 Feb 2024 15:03: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 1rZyzF-0002rA-Ji for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02: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 1rZyzE-00025J-3T for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:37 -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=KXawe9fYSD+GPXaSvzemteq4Msk+Mi6Gp4c7C6r7U3s=; b=hS0lcz16meiLn6W3kGxtludZIr nzOmTy2Oq5/c3r5JHGpRP7WmLpDdjYWSbSwMNXx8q5OoYThDHunAQTKttB6z9LcuEEQeol6/ck6HM MyrL7lgiw2OR19bQsrN+0MCgIrwJuNvvm2Du81/cvkGtzI/52/ftprLvbu+0lMk4+hu6vPHnCWT6m xkkG3M8lzv7m/ee+Kq6xi/JCU/SE/QuL58Ap7FTGpWajY6lq/BdUMSMxRkj7REYhgTxkkHHe8WZf6 FOFRPlptwH6Thy5BBJraiUATLgcj/VvXhZeVBaQw6mIOYLTfTO9R97F5E09UiKLvDYRR5gekUOLMg nBMMx0+5b8fXDDqNLoT4hEhTyxE4fnPmxIF+wDIwgexqA2bQAnSKTSm8u/V8j2c2lUGy1+TN0A9x8 WK2SRn8QCgTc+Cl1+pNmhjK8m6QnYMcrlCHRwSTmaay/ZZgov74dH1w7jt/qgXKv6Poqv1tBYbIv6 yfr9uRHGdvOOmk6j1uuQwA6ABDgKEzUhEhx4Go3BJmLYij+x4+/VJ+voxcXwTLvK4C1Vjejuhs459 80r8ErxOPGPxbPOWVUMGjcVJremyocjltOW9UPAWLM/hipmtxJhraFSUOrwMHEkNfSVUpluq0IMXx KAP0RChioQ0EuGQNkc4pejaPGagzlhVFXylB0NVjg=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhP-0008m4-7w; Tue, 13 Feb 2024 19:44:14 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:36 +0000 Message-Id: <20240213194052.1162753-73-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 72/88] esp.c: handle TC underflow for DMA SCSI requests 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 Detect the case where the guest underflows TC by requesting a DMA transfer which is larger than the available data. If this case is detected, immediately complete the SCSI request and handle any remaining FIFO accesses in the STATUS phase by raising INTR_BS once the FIFO is below the threshold. Note that handling the premature SCSI bus phase change in the case of TC underflow fixes booting EMILE on m68k once again. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-73-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 8ea100ee9c..a3e18bb3d7 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -579,6 +579,12 @@ static void esp_do_dma(ESPState *s) s->async_len -= len; s->ti_size -= len; + if (s->async_len == 0 && s->ti_size == 0 && esp_get_tc(s)) { + /* If the guest underflows TC then terminate SCSI request */ + scsi_req_continue(s->current_req); + return; + } + if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { /* Defer until the scsi layer has completed */ scsi_req_continue(s->current_req); @@ -596,6 +602,12 @@ static void esp_do_dma(ESPState *s) esp_set_tc(s, esp_get_tc(s) - len); esp_raise_drq(s); + if (s->async_len == 0 && s->ti_size == 0 && esp_get_tc(s)) { + /* If the guest underflows TC then terminate SCSI request */ + scsi_req_continue(s->current_req); + return; + } + if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { /* Defer until the scsi layer has completed */ scsi_req_continue(s->current_req); @@ -630,6 +642,15 @@ static void esp_do_dma(ESPState *s) } } break; + + default: + /* Consume remaining data if the guest underflows TC */ + if (fifo8_num_used(&s->fifo) < 2) { + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + esp_lower_drq(s); + } + break; } break; @@ -884,7 +905,9 @@ void esp_command_complete(SCSIRequest *req, size_t resid) esp_set_phase(s, STAT_ST); s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); - esp_lower_drq(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); From patchwork Tue Feb 13 19:40:37 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: 13555642 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 8FE7FC48260 for ; Tue, 13 Feb 2024 20:12:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyxs-0001Jy-HG; Tue, 13 Feb 2024 15:01: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 1rZyxq-00019b-M3 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:10 -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 1rZyxl-0001rZ-Ij for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:09 -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=xIQhiDMF5ShO7draXOu9AcwBlKFxzqVjZOPlxwEsOao=; b=FG8bFFnfmjsMgc1yi6EDYWgWrk OUfT18FFbj27BcVbNZIMAtAYwbt1DUdXPAQZfmRUkyzYKWel6qbdvtlMNXrr3Ja6PMZuR8vG+GWIr o01f2yS2J/zAz3D0ZWTNiuz7IT/TZ2pJZITI34DqWBZtbsfql/ke1DYfYYrV7mkLyDgQX1nUFNyQe ob4tpxfcq0ZpQa0NI39eseJ4DRAV/rhj/FPot0a62qX2fcZVn8uG16z2twYENsOX8CvbnqSYwPFnJ 7RKXOAzSbI0FcLkK99S6vjid4N2sbe3GC86J9PBUXVlv6z3MrvKC6t3mC2uuUCn6T/PaB50zC3mBR Kb0nMFzk9of5hYJ8Y0PP5ODCIBf2MsBMicAcG6lqQxyy32fW9Gl2zrOVUN9cZAjRU7qHH+arMqkaK 8s2V/aUs8O99yougEf/OGFpNytVuOPwOC56bpCZZQOkxRPaWjf6vRnr6vIfN6hotflu2F/Ru+0lcZ rGbNIFJNhGVLDpZJsLU4yMewjuWJ50HL26WgXGNDmnpyXs/2WqGo9UZwFyy2PphJLjYjE2cBHtDeJ h6BnMRJIZGOzrMJjVn+NDNd8/P0GHUEe4BGmQI/tL+ECNZ1/uLz5+7fiKyRTUeOYCi/FNwpOgynTB nWL2CvA4lZ94f7D0CB41e0pnZrP1f5B8Skr+OpEtY=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhS-0008m4-Qn; Tue, 13 Feb 2024 19:44:18 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:37 +0000 Message-Id: <20240213194052.1162753-74-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 73/88] esp.c: remove restriction on FIFO read access when DMA memory routines defined 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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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 latest state machines can handle mixing DMA and non-DMA FIFO access for all SCSI phases except DATA IN and DATA OUT. For DATA IN and DATA OUT phases, the transfer is complete when TC == 0 and the updated logic will now handle TC underflow correctly, which makes it just about impossible to manually manipulate the FIFO during a DMA transfer. Remove the restriction on FIFO read access when DMA memory routines are defined which also allows the NeXTCube machine to pass its self-test. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-74-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index a3e18bb3d7..f9d848171f 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1133,14 +1133,7 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr) switch (saddr) { case ESP_FIFO: - if (s->dma_memory_read && s->dma_memory_write && - (s->rregs[ESP_RSTAT] & STAT_PIO_MASK) == 0) { - /* Data out. */ - qemu_log_mask(LOG_UNIMP, "esp: PIO data read not implemented\n"); - s->rregs[ESP_FIFO] = 0; - } else { - s->rregs[ESP_FIFO] = esp_fifo_pop(&s->fifo); - } + s->rregs[ESP_FIFO] = esp_fifo_pop(&s->fifo); val = s->rregs[ESP_FIFO]; break; case ESP_RINTR: From patchwork Tue Feb 13 19:40:38 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: 13555631 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 9F21EC4829F for ; Tue, 13 Feb 2024 20:09:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0G-00043P-Po; Tue, 13 Feb 2024 15:03: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 1rZyyW-0002Hq-C1 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:53 -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 1rZyyR-0001uz-IC for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:52 -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=u/8TH5HgQOszsQHe2cvReXCj23ynFx2AMdVoG5FQJ3c=; b=uX+0cBmw3HPNs219Ee6KosNZ0L UXa0fHd415Fg1w18V3qCznwZp2ylQiUuSYw83y5QP4LNSfJOCdomUw1f+kmFtiHiJqJxQlOh5e58Q HBi+mCisdoBb0hn7crp1lME8DosAhE+15c/US71kdv18imvE7Hu1fpUfB+G5MfnER85pilbF08i69 8KTdZC1euH2TKo92zNcQ2Atumw6ZVYZlacu9SLg1TkNdmP/lKmsUIaHVs44H5mlxy7gIdk+Pbd5mA eKUtrF1QWqQbUuf+9QNR3vBHYq2Tg/q64PPIoi/vWlSutLcoubFb5rYzQJOQxQqcOXGp9ajlcd8WK 23Dl837qvPrYlylrcCkRdwhgxP3gSszYAYEDmQ1NiVL16uHElH0+7AGy5msirrZr9Oor1TD0mkQ/d o0t/FmL4OcpJMITSZPG8yrZ6/mgUQARv6h27aZpDKpQVLweBIKuhjOAYLRSvC01t0AdaR3zriSkXo jdHG35g0hlLr3QlwuJK72OXhadY9WbJ4wT+AQh3KaOQ3iYbUqcAAwKZ+IEYEK8BwPs2VkubZVPWTi pLf/XB65rqMDGjlqCVoGwVGTeTqrY1nhJq3cndVPPdny53aEYtoZGYiFC3qbplaLHBLRnitzHfI2e Et0Hl8+tuUtdCTW6v2q1o/Kr2Xjk1CAbGcRS9+Qyg=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhW-0008m4-DO; Tue, 13 Feb 2024 19:44:21 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:38 +0000 Message-Id: <20240213194052.1162753-75-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 74/88] esp.c: handle non-DMA FIFO writes used to terminate DMA 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 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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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 Certain versions of MacOS send the first 5 bytes of the CDB using DMA and then send the last byte of the CDB by writing to the FIFO. Update the non-DMA state machine to detect the end of the CDB and execute the SCSI command using similar logic as that which already exists for transferring the remainder of the CDB using the ESP TI command. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-75-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index f9d848171f..aa7dec71e3 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -787,6 +787,16 @@ static void esp_do_nodma(ESPState *s) } break; + case CMD_SEL | CMD_DMA: + case CMD_SELATN | CMD_DMA: + /* Handle when DMA transfer is terminated by non-DMA FIFO write */ + if (esp_cdb_length(s) && esp_cdb_length(s) == + fifo8_num_used(&s->cmdfifo) - s->cmdfifo_cdb_offset) { + /* Command has been received */ + do_cmd(s); + } + break; + case CMD_SEL: case CMD_SELATN: /* FIFO already contain entire CDB */ From patchwork Tue Feb 13 19:40:39 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: 13555624 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 29005C48260 for ; Tue, 13 Feb 2024 20:08:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0U-0004YA-Ph; Tue, 13 Feb 2024 15:03:54 -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 1rZyzD-0002q1-2I for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02: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 1rZyzB-00024P-GU for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:34 -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=DXz/XkjLmoOh4xUlStStFIWpQWovnmYeHWy5j+nGFhI=; b=hBZBnb3tZwOAy/sf43FsQLhf2P IAbUpRHbRiOUB1DFQrNagbydZlGe9K5hGVxN6ri4imefbH3yrhryVq95FRVZqy8sZjJva8h7sgOUT cTl1In4oA4f2sCVFYqcML6XZcyM/z1ouQ9dE0CzwAIw6RSP9jxlMcTUdYDBdOKtY25UVYu/7M9hB2 LUO3yhP/6lkmtvKxE03AxSUoF46xroL4xh45mECG26N1xwORh+7g9qFMCWXcORKdv+mWkZXty7+uY SK8pCOlkgqEC0rP0CFg+4ZZvDljiQWNm91BU5Uk/xbFVgGf46Qlx8gWpVRAk+CTEMv6f2gjmHGAcq hdNfKQUFY62O6kNnGFVoOGmvQX+19PeqhmuJ4bzKfMjaM7RPc2Woowg6TIlBZr1pcnnaFlcKfgtUs TKJDDYNfGqUYzXbrzbX3xncqj5a3pFaLkux8f5FYQnY9CBHP6EsHY0QlgfwWPDyUVPrSaeC6e6nnL vFIK53IxPluc3Ix9LInVaELJS+o9OM8Xf51StFcolHs/7f/07JfaFzcxWnD5mwZlesCDlK4z8fUNF iB6ZhObavdvbe9R2uzjRWVffmrreZnVxDgk0U5i8DRasXcW1wD5qu6YW9s6krFKR7HxMqcPXf4GDF hN2QcQfZ/zwJpDuAynshh84e+mtJw8Y7zBJpx9e0M=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhZ-0008m4-WF; Tue, 13 Feb 2024 19:44:25 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:39 +0000 Message-Id: <20240213194052.1162753-76-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 75/88] esp.c: improve ESP_RSEQ logic consolidation 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 ESP_RSEQ logic is scattered in a few places throughout the ESP state machine which is mainly because the ESP_RSEQ register isn't always reset when executing an ESP select command. Once this is done, the ESP_RSEQ register only needs to be updated at the point where the sequencer command completes. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-76-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index aa7dec71e3..ca26415d5f 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -230,6 +230,7 @@ static int esp_select(ESPState *s) target = s->wregs[ESP_WBUSID] & BUSID_DID; s->ti_size = 0; + s->rregs[ESP_RSEQ] = SEQ_0; if (s->current_req) { /* Started a new command before the old one finished. Cancel it. */ @@ -241,7 +242,6 @@ static int esp_select(ESPState *s) /* No such drive */ s->rregs[ESP_RSTAT] = 0; s->rregs[ESP_RINTR] = INTR_DC; - s->rregs[ESP_RSEQ] = SEQ_0; esp_raise_irq(s); return -1; } @@ -250,7 +250,6 @@ static int esp_select(ESPState *s) * Note that we deliberately don't raise the IRQ here: this will be done * either in esp_transfer_data() or esp_command_complete() */ - s->rregs[ESP_RSEQ] = SEQ_CD; return 0; } @@ -358,7 +357,6 @@ static void handle_s_without_atn(ESPState *s) } esp_set_phase(s, STAT_CD); - s->rregs[ESP_RSEQ] = SEQ_CD; s->cmdfifo_cdb_offset = 0; if (s->dma) { @@ -380,7 +378,6 @@ static void handle_satn_stop(ESPState *s) } esp_set_phase(s, STAT_MO); - s->rregs[ESP_RSEQ] = SEQ_MO; s->cmdfifo_cdb_offset = 0; if (s->dma) { @@ -456,6 +453,7 @@ static void esp_do_dma(ESPState *s) if (fifo8_num_used(&s->cmdfifo) >= 1) { /* First byte received, switch to command phase */ esp_set_phase(s, STAT_CD); + s->rregs[ESP_RSEQ] = SEQ_CD; s->cmdfifo_cdb_offset = 1; if (fifo8_num_used(&s->cmdfifo) > 1) { @@ -468,11 +466,11 @@ static void esp_do_dma(ESPState *s) case CMD_SELATNS | CMD_DMA: if (fifo8_num_used(&s->cmdfifo) == 1) { /* First byte received, stop in message out phase */ + s->rregs[ESP_RSEQ] = SEQ_MO; s->cmdfifo_cdb_offset = 1; /* Raise command completion interrupt */ s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; - s->rregs[ESP_RSEQ] = SEQ_CD; esp_raise_irq(s); } break; @@ -482,7 +480,6 @@ static void esp_do_dma(ESPState *s) if (esp_get_tc(s) == 0) { esp_set_phase(s, STAT_CD); s->rregs[ESP_CMD] = 0; - s->rregs[ESP_RSEQ] = SEQ_CD; s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); } @@ -726,6 +723,7 @@ static void esp_do_nodma(ESPState *s) if (fifo8_num_used(&s->cmdfifo) >= 1) { /* First byte received, switch to command phase */ esp_set_phase(s, STAT_CD); + s->rregs[ESP_RSEQ] = SEQ_CD; s->cmdfifo_cdb_offset = 1; if (fifo8_num_used(&s->cmdfifo) > 1) { @@ -738,6 +736,7 @@ static void esp_do_nodma(ESPState *s) case CMD_SELATNS: if (fifo8_num_used(&s->cmdfifo) >= 1) { /* First byte received, stop in message out phase */ + s->rregs[ESP_RSEQ] = SEQ_MO; s->cmdfifo_cdb_offset = 1; /* Raise command completion interrupt */ @@ -903,6 +902,7 @@ void esp_command_complete(SCSIRequest *req, size_t resid) * and function complete interrupt */ s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; + s->rregs[ESP_RSEQ] = SEQ_CD; break; case CMD_TI | CMD_DMA: @@ -948,6 +948,7 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) * so raise deferred bus service and function complete interrupt */ s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; + s->rregs[ESP_RSEQ] = SEQ_CD; break; case CMD_SELATNS | CMD_DMA: @@ -957,6 +958,7 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) * completion interrupt */ s->rregs[ESP_RINTR] |= INTR_BS; + s->rregs[ESP_RSEQ] = SEQ_MO; break; case CMD_TI | CMD_DMA: From patchwork Tue Feb 13 19:40:40 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: 13555646 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 178E7C4829A for ; Tue, 13 Feb 2024 20:13:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0P-0004M7-LX; Tue, 13 Feb 2024 15:03:49 -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 1rZz08-0003vC-Nt for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03:35 -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 1rZz04-00029q-NZ for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03:32 -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=DhTM4gDIDmfJQO7x8t9iO5PJ+w4+Q1a1WN+zHbtezaM=; b=SCAFyRYYoMOdpWm+SD2uSQQdsa BIJ6ibPpYpo7bHtIRF5mp8CMpHJoboGsPg6XCOmdtuENJVEtf8Eq/B/m+A7sh2TQvAqV/GzKbAkiB 4J0rWOP6cnnLrM1RNpsL1qWFV4D38uxjPli9veHi6ESQYRSwhqLZGQlWB9REuZosXZyKDl2bc9Cau sd+4iFhLifJVZcIFdKY5wc8y8NsrEH/EygRYVq34Sxwfg1tVfVc4B3L7WIP2IVNsO4nt9pZ+sMkD4 GwXTBVHDpMfvQQv6rJfyVINZ+ZYFuzj1BTxLErvBM2xXWKaRPLesUIdgPXhZv7CZbF+Z2SRObG6x3 vCR0ianj2gVKJaQlj85MHBdLOqjvZyouTB/3jbgBBTahVRnBwGnp9oAdFkACJ8SUXPZ66caMGBP6s 77skUdS/qwLvSjl7wqbuK9TqYjK2EczR7L2e3JjJ5VG+/cbP6TlszIuRzrTpJ3bJyRyHlu752OsT9 EUXsg7Ws6WqeDV7geG+IsbT69w4WUNCXRzz48Ji4RgBL1vzvFHU/YQmO/YnMl8xFBM3U2NamF6Ap5 ukIYKJM8ffSBolhZIK8HDA5iabRrDW1PUWAv3WcFI3UXjJ9JLN3qUU07sCzMluuTdedOT4QRYijUs +IP/FcOPbjMabJW2qgUG29k+9JO5ot9GRlPejwAPQ=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhe-0008m4-34; Tue, 13 Feb 2024 19:44:30 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:40 +0000 Message-Id: <20240213194052.1162753-77-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 76/88] esp.c: only transfer non-DMA COMMAND phase data for specific 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 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 contents of the FIFO should only be copied to cmdfifo for ESP commands that are sending data to the SCSI bus, which are the SEL_* commands and the TI command. Otherwise any incoming data should be held in the FIFO as normal. This fixes booting of really old 32-bit SPARC Linux kernels such as Aurelien's debian_etch_sparc_small.qcow2 test image. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-77-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index ca26415d5f..17e2db442c 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -757,13 +757,13 @@ static void esp_do_nodma(ESPState *s) break; case STAT_CD: - /* Copy FIFO into cmdfifo */ - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); - switch (s->rregs[ESP_CMD]) { case CMD_TI: + /* Copy FIFO into cmdfifo */ + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + cmdlen = fifo8_num_used(&s->cmdfifo); trace_esp_handle_ti_cmd(cmdlen); @@ -788,6 +788,11 @@ static void esp_do_nodma(ESPState *s) case CMD_SEL | CMD_DMA: case CMD_SELATN | CMD_DMA: + /* Copy FIFO into cmdfifo */ + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + /* Handle when DMA transfer is terminated by non-DMA FIFO write */ if (esp_cdb_length(s) && esp_cdb_length(s) == fifo8_num_used(&s->cmdfifo) - s->cmdfifo_cdb_offset) { @@ -798,7 +803,11 @@ static void esp_do_nodma(ESPState *s) case CMD_SEL: case CMD_SELATN: - /* FIFO already contain entire CDB */ + /* FIFO already contain entire CDB: copy to cmdfifo and execute */ + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + do_cmd(s); break; } From patchwork Tue Feb 13 19:40:41 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: 13555641 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 9BD3DC4829A for ; Tue, 13 Feb 2024 20:12:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0F-0003xT-FX; Tue, 13 Feb 2024 15:03:39 -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 1rZyyt-0002XF-OS for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:18 -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 1rZyys-00023K-4S for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02: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=z8el69Zp6Nc98KrJ5/G461ogfL7GkfD2+gn9nmhlztg=; b=ZBIE8CCt8chDinu5JfusXy3sSh AvCoA+iEw0D4Xp+/DfOf4VOpcb6U2LyVaYXd55naB0i8UdpVHP4bihGfOkYPQGX/D6GfXNUQH8Mxd MCB8MJND2BzGl+wJ70JwoQc1bBfw2eOHYWpQvQ2Kbq4ynbyurVF5h5pUYau/YsFMnqTxGHkGrH7u7 pJacq2oax6c6hngMD8JT+mgBg5eHUNHml+JVR+ikx50knn89hb1k7xP3XRRSe+0Wo9Sjt9FNl/gJR D/Jq9gfk6PI7A8VI4tDWSb+QS2h/R58Mek6EYLI6cHhQw8OA5rLmPulN5fFj0AhtcT9fhZCm6uF/3 awCiOZBh1dBf4rHw9+Wzya+v0ObfFWzPPgemLfXKHQLMvscfqzbwU7FLxHOR+GaQcxs1T5piyu9m5 S+HnhHC706nV++ISvc/KIXRJ4Gipgd0sXVESPJzAU88pybTNS8KFmqKSPb9ovSq3f9n4mtRVbjH/O UEX3u/aAwZRwNXaauGxNuhZMURY66quAF+5vpBGrGir1LZssNaJA2CUGlqsMkYcS90d4YnbPh789q 7hjLFSXLpDybV6cGBJonRpOr4Jmj0WmlvvTbrG2ymflBl5wNyHAw3hbaxNsvxHJp+mkrbAKw48LbR 4ZpcPcxUpigXN/YFZ9+XNU+pDXwZ/gm/6kzlnq9ZY=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhi-0008m4-6A; Tue, 13 Feb 2024 19:44:34 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:41 +0000 Message-Id: <20240213194052.1162753-78-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 77/88] esp.c: only transfer non-DMA MESSAGE OUT phase data for specific 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 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 contents of the FIFO should only be copied to cmdfifo for ESP commands that are sending data to the SCSI bus, which are the SEL_* commands and the TI command. Otherwise any incoming data should be held in the FIFO as normal. This fixes booting of NetBSD m68k under the Q800 machine once again. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-78-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 17e2db442c..d63039af89 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -712,14 +712,13 @@ static void esp_do_nodma(ESPState *s) switch (esp_get_phase(s)) { case STAT_MO: - /* Copy FIFO into cmdfifo */ - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); - s->cmdfifo_cdb_offset += n; - switch (s->rregs[ESP_CMD]) { case CMD_SELATN: + /* Copy FIFO into cmdfifo */ + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + if (fifo8_num_used(&s->cmdfifo) >= 1) { /* First byte received, switch to command phase */ esp_set_phase(s, STAT_CD); @@ -734,6 +733,11 @@ static void esp_do_nodma(ESPState *s) break; case CMD_SELATNS: + /* Copy one byte from FIFO into cmdfifo */ + n = esp_fifo_pop_buf(&s->fifo, buf, 1); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + if (fifo8_num_used(&s->cmdfifo) >= 1) { /* First byte received, stop in message out phase */ s->rregs[ESP_RSEQ] = SEQ_MO; @@ -746,6 +750,11 @@ static void esp_do_nodma(ESPState *s) break; case CMD_TI: + /* Copy FIFO into cmdfifo */ + n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + n = MIN(fifo8_num_free(&s->cmdfifo), n); + fifo8_push_all(&s->cmdfifo, buf, n); + /* ATN remains asserted until FIFO empty */ s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); esp_set_phase(s, STAT_CD); From patchwork Tue Feb 13 19:40:42 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: 13555606 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 959F8C48260 for ; Tue, 13 Feb 2024 20:01:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyxO-0000sc-5l; Tue, 13 Feb 2024 15:00:43 -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 1rZyx3-0000hS-Jf for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:31 -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 1rZyx1-0001dW-Up for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:21 -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=I/0aIaJ3v6q72PKhg5mEQTiEqIUx6SgVereXLL07mtg=; b=lkVy3QuyNz9kBoD7wGF9pnXZXz +WkXf6ZE//mVSEWg9kqKGSmB8EeLfVlG497b2BKmqKm6tjUJYlB1Tfat7WpeK/6S9DFaGrTOarUE/ 7TFZHrJqi4CBI/KJQ3G+0ZsN2KAqvgT97N3TiXNfak1047BhSCSzyzfzkZcP3IMuyjVkfoErTjFCw yNuUNscA+nhge3KNXa0ZCcQA5BJYDGGjo+xNlXMpKpAySBYodZr7ljbTVw9TfZabQvam0WHVa/Ahn IdwutpKJIk2qNXqEswCRk+pbV6fqB2WS5OalhjPgBaKmKzZa74jNrKDbjUvcgYUCsqWAaTzhjxKMP j6nra4DvFmfIwqW3cXFRlhFy02uQly5CZ2U/JuO0YKEaAEMqDZokbP+MNcDd//alL9McxNcHsM6Os Te4u+YQlmlnPOHhRZFXiFnMzQ6nzt8L+45jEWAVjw5MxHMyyQKfybirSYxdWyYNozhjxIkPK+W2MQ 4NPpiVztOqau0cIhN+AXKcC7fsm98gFJB8eQTwP8RHVY09RZarQps9XK9DJ/VqEUlP+rMix6GCJkv sI9hbBie35M1zEq4vmMnlyX0vrxIO+llwxbnaJaXsoKOqR9y8IqTa6SgWmG2ruggG3f49/Sr9Iq2F 1O81My3PVd5egSix1Q+uTp6DcMzipu9LGjZxtoMdU=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhm-0008m4-89; Tue, 13 Feb 2024 19:44:34 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:42 +0000 Message-Id: <20240213194052.1162753-79-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 78/88] esp.c: consolidate DMA and PDMA logic in DATA OUT 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 This allows the removal of duplicate logic shared between the two implementations. Note that we restrict esp_raise_drq() to PDMA to help reduce the log verbosity for normal DMA. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-79-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index d63039af89..394774c379 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -521,40 +521,29 @@ static void esp_do_dma(ESPState *s) if (len > s->async_len) { len = s->async_len; } + if (s->dma_memory_read) { s->dma_memory_read(s->dma_opaque, s->async_buf, len); - esp_set_tc(s, esp_get_tc(s) - len); - s->async_buf += len; - s->async_len -= len; - s->ti_size += len; - - if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { - /* Defer until the scsi layer has completed */ - scsi_req_continue(s->current_req); - return; - } - - esp_dma_ti_check(s); } else { /* Copy FIFO data to device */ len = MIN(s->async_len, ESP_FIFO_SZ); len = MIN(len, fifo8_num_used(&s->fifo)); - n = esp_fifo_pop_buf(&s->fifo, s->async_buf, len); - s->async_buf += n; - s->async_len -= n; - s->ti_size += n; - + len = esp_fifo_pop_buf(&s->fifo, s->async_buf, len); esp_raise_drq(s); + } - if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { - /* Defer until the scsi layer has completed */ - scsi_req_continue(s->current_req); - return; - } + s->async_buf += len; + s->async_len -= len; + s->ti_size += len; - esp_dma_ti_check(s); + if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { + /* Defer until the scsi layer has completed */ + scsi_req_continue(s->current_req); + return; } + + esp_dma_ti_check(s); break; case STAT_DI: From patchwork Tue Feb 13 19:40:43 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: 13555620 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 981EBC4829A for ; Tue, 13 Feb 2024 20:06:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyxl-00016y-9q; Tue, 13 Feb 2024 15:01:05 -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 1rZyxg-00011U-T0 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:02 -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 1rZyxb-0001qY-R8 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:58 -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=OFphqt2kaDocqz1MJe/EF9OApPTK3lUJ59fjH/qFx2E=; b=ojHVr8Vm7pTmTMYl/W2/sKswX9 c0tA0MlCzHRzKw2tNeynwE9IdU8q100u3VIOe8IrV43bt3Zb+ymw1MElTKL3ToqdEXwK352TmmH4P grX19qyh8chKnxlHzJGZV9qME1gFmjctiugfrOjRE4WKugfuGDqoNJhZb43N/T69UJjRSgog3TMQU sSoXzIGqsqiFepMk1pOXLZjWeSfJdK/vpSeSZTpeTY+2k2IlLdl1M8dX83Cnzq6YPGJWIoTC2/yLU 24zidMh37Yx1ygyxHHirxIvEQ1i98N8YgDz9srpBIeghJqdJmdplLCi2/qXEoX22To1AhDi42JdIi IAxGcrikml9Piatil7PqQ7bij8px2t0bQM5nyU0gL8g4vI7r/OwBdGEWaaviNhmhJ4qdFcx8B1uZE vFDA/X+TdJxe50QTz/QK97Jka5gxC5cbWJLlzd+nPNCIKdf8Tv01KFoySka2lqi9m6x64DIcFN0Cx O8ry+lGigVx6kzK7/jAJOWm/ceJS5Mx/AHQux5KmDo4sIxBGOk0CVbptMZk1J4r64ltFmgbw7q802 3ihgXc9EDgsNNcVPH5rI6qLMNy5xejZDuZfz+/PORZE8B9jvLbMy5WrRJWgKTaXJxJ3aXLiZVWer7 9KMHX2VXQL0oXul7oRHg9W0/9EGdEOt5nBW1/sQWI=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhm-0008m4-J9; Tue, 13 Feb 2024 19:44:38 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:43 +0000 Message-Id: <20240213194052.1162753-80-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 79/88] esp.c: consolidate DMA and PDMA logic in DATA IN 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 This allows the removal of duplicate logic shared between the two implementations. Note that we restrict esp_raise_drq() to PDMA to help reduce the log verbosity for normal DMA. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-80-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 51 +++++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 394774c379..49fc059eaa 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -557,51 +557,34 @@ static void esp_do_dma(ESPState *s) if (len > s->async_len) { len = s->async_len; } + if (s->dma_memory_write) { s->dma_memory_write(s->dma_opaque, s->async_buf, len); - - esp_set_tc(s, esp_get_tc(s) - len); - s->async_buf += len; - s->async_len -= len; - s->ti_size -= len; - - if (s->async_len == 0 && s->ti_size == 0 && esp_get_tc(s)) { - /* If the guest underflows TC then terminate SCSI request */ - scsi_req_continue(s->current_req); - return; - } - - if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { - /* Defer until the scsi layer has completed */ - scsi_req_continue(s->current_req); - return; - } - - esp_dma_ti_check(s); } else { /* Copy device data to FIFO */ len = MIN(len, fifo8_num_free(&s->fifo)); fifo8_push_all(&s->fifo, s->async_buf, len); - s->async_buf += len; - s->async_len -= len; - s->ti_size -= len; - esp_set_tc(s, esp_get_tc(s) - len); esp_raise_drq(s); + } - if (s->async_len == 0 && s->ti_size == 0 && esp_get_tc(s)) { - /* If the guest underflows TC then terminate SCSI request */ - scsi_req_continue(s->current_req); - return; - } + s->async_buf += len; + s->async_len -= len; + s->ti_size -= len; + esp_set_tc(s, esp_get_tc(s) - len); - if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { - /* Defer until the scsi layer has completed */ - scsi_req_continue(s->current_req); - return; - } + if (s->async_len == 0 && s->ti_size == 0 && esp_get_tc(s)) { + /* If the guest underflows TC then terminate SCSI request */ + scsi_req_continue(s->current_req); + return; + } - esp_dma_ti_check(s); + if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { + /* Defer until the scsi layer has completed */ + scsi_req_continue(s->current_req); + return; } + + esp_dma_ti_check(s); break; case STAT_ST: From patchwork Tue Feb 13 19:40:44 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: 13555618 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 A0BDFC4829A for ; Tue, 13 Feb 2024 20:05:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0n-000572-KN; Tue, 13 Feb 2024 15:04:13 -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 1rZz0e-0004rb-RO for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:04:05 -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 1rZz0d-0002I8-9I for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:04:04 -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=FH27qHWz11n07C8E0Vgf3CBwLl5tQW+/t0p2tOdInEU=; b=IJYGx0eei5sm9vvjgtk2v6EhwW Rabgl+i148UAuHa1U7YK8XkqYJrRToy1aiy4rM6VwAgpqZm3CtKuqXlhUg3Wy75EaxmaKf67IjkzX WRGlr0VqbypBHilWPGuzj+Wex7juTHcJ+ZrcuTQViAaLpjT1kEBeRkFnlLLfnbWeu6WP2W0XrBi3/ mH/Rq/ZF1EpCmhfMI4ie6dycIIxfYo9Qg7uEG5mCHWi5qExYgSpPK5x9snH1gdQ8GkSkc12yS7O/i co4O+cq5oksQtD5JX/sxamyao4J6fGyVdn6xZnaTXrpZXlmzte7P2dEe7xC35SBsOh/FziYWEhfzp hlNqKQKRjr1E+6qNbnfkELEToKQL0053SwK+zepLaV6AS1sPF+l1KJdHf2m/dTo0OM2o9/se9HUr7 izOQpM4Y6e0Njnvv0XUMxcT76DIH2gkcIT8L3+Ht23GL5WLFdzANJ06WPpfUN3AAUIn7XFoibh9bk /qg9WKwDbAQIaVGK5luhgd9XIxRbD6ZZwJ9eV32n2VpGteK7SaknWsBM9iAqE1Fd0jtzQtMqlvArk TjyHcfRoMJNDpaTkWbSlv8bvynefFbnbD7tI+KYyY8f4tLn8bAf/jRZ8rtHsaClJOuq9oe3qMku0P OS8Q6PAGxLWGUiBVXB6o6lhFviWxIsfyeMoHBXeko=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhq-0008m4-5l; Tue, 13 Feb 2024 19:44:42 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:44 +0000 Message-Id: <20240213194052.1162753-81-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 80/88] esp.c: consolidate DMA and PDMA logic in MESSAGE OUT 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 This allows the removal of duplicate logic shared between the two implementations. Note that we restrict esp_raise_drq() to PDMA to help reduce the log verbosity for normal DMA. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-81-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 49fc059eaa..ae65c2ef37 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -436,17 +436,15 @@ static void esp_do_dma(ESPState *s) if (s->dma_memory_read) { len = MIN(len, fifo8_num_free(&s->cmdfifo)); s->dma_memory_read(s->dma_opaque, buf, len); - fifo8_push_all(&s->cmdfifo, buf, len); esp_set_tc(s, esp_get_tc(s) - len); - s->cmdfifo_cdb_offset += len; } else { - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); - s->cmdfifo_cdb_offset += n; + len = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + len = MIN(fifo8_num_free(&s->cmdfifo), len); + esp_raise_drq(s); } - esp_raise_drq(s); + fifo8_push_all(&s->cmdfifo, buf, len); + s->cmdfifo_cdb_offset += len; switch (s->rregs[ESP_CMD]) { case CMD_SELATN | CMD_DMA: From patchwork Tue Feb 13 19:40:45 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: 13555611 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 CE6A3C4829A for ; Tue, 13 Feb 2024 20:02:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyxj-000115-G8; Tue, 13 Feb 2024 15:01:03 -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 1rZyxH-0000l3-HK for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:35 -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 1rZyxG-0001kF-6U for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:00:35 -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=U4wFtyvUgxolXpHyM1ojgGUeq66JkAtIYffuiQI5DGM=; b=YuQymqtRV25pn4mWOAeNZlmJCq mx9UwxWimgbAOe+qVspjCQ2/4woEfl6CE7O0D73bP+OR/KkPeetZaKrF2mxvnwcduZ6tcGM3J+XHv 3eeaPRzJqEIkYMVtcg6db71120vr8BxqPGtodTYeTpWY6zVV30KnZJ+fKSIn7Q3507sMIAFbbSUFo AGd2VRDniLa9uBvBUOuWTrZYYLIqjMQRMBictxWh2TlACaI3OhlXv6dbrBeKpr8TmQYxBLpobpLs5 DOgTAimhaw0K3A5MrHYxuV3V8gxqQRBb1mKqG41d6lQL1bb6nU2K2ylSfuHvJhgQvzQL+CCmZur+0 8Mnt/ac8+VOJ8yrplbdMfEGXihgww9SRQPmdPAsRZpGph9ibKhln48c3bK7qr1eKT1QeRZ+Afc7tq kpbzqjCGqlkiR+rvCDx9OewKcy+1spy2wA67gaO2BEWe7+KmVOdLaX8QkWglrakB8aePQohiNMnpO oVhIx78FwMaa+0ZJkN+NBFkNI0IkcSIa653krFS1NYxLCq0sDEHvVIbqwYhvcLpVnDt0iVaWpRo2K Esp4y/3xMOJGloZX66bNZSn7HZhzH/tW6W+kS4wbVSic5a0vYEwyjxbFdcY9zTfHk5Dn9xfsDTn3+ 9kwf/2QngA5tiluaSZCBiace3Jt8eCHPqV0RAszVw=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhu-0008m4-8p; Tue, 13 Feb 2024 19:44:45 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:45 +0000 Message-Id: <20240213194052.1162753-82-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 81/88] esp.c: remove redundant n variable in PDMA 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 This variable can be replaced by the existing len variable. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-82-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index ae65c2ef37..8ef6d203e0 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -427,7 +427,6 @@ static void esp_do_dma(ESPState *s) { uint32_t len, cmdlen; uint8_t buf[ESP_CMDFIFO_SZ]; - int n; len = esp_get_tc(s); @@ -494,10 +493,9 @@ static void esp_do_dma(ESPState *s) fifo8_push_all(&s->cmdfifo, buf, len); esp_set_tc(s, esp_get_tc(s) - len); } else { - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); - + len = esp_fifo_pop_buf(&s->fifo, 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); From patchwork Tue Feb 13 19:40:46 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: 13555629 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 307F6C4829A for ; Tue, 13 Feb 2024 20:09:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0Z-0004hV-HU; Tue, 13 Feb 2024 15:04:02 -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 1rZyzm-0003Ot-K4 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03:12 -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 1rZyzk-000297-9c for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03:09 -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=lCcVmtBwJiODyfDlYMr5RG6ZC3miM3ji9vFj9Uh7JIo=; b=I+tAnq0kHrHJlZDu6BVU2r1OuV cdCyxR7Nk4wKAHhM8C5NoHZXm8d4ce10UxCMJ8G0AXLuK7kGRjFRMEOAtNSPmNrrD4x1jc5nk3IM/ eWtsdR0cwUDMaP6M/T2h3kvcjdQ9DjBu8wp0KmlYNIfhPw4HevsG2HC909vfK1EhRRnZd91XY/1UR jbGmy9FNEpsE6WeJlGnsMKzeJzdT6EZfpsk9EebxTMeiqiXBvDfTJdjC18l1a/fVjDphI4lxdvhIG 1GHzoITUUTheESn4rN7h/ntyIQGlJgGhyIugybD3sBdCS8HS5ORIm949ruagesHAG2emY2//0Jd9R 1ZjI0/xUV85sYh9+kDIhjzPKA8Dd0KY7Mig4ESnrG+yTUcs7qP9NGWm86j/mY6QSXDrqJsTreYKng ElGd2bwCvZZfeBxsgZuFNEbiAosVQC0TZFQSkYfTBGgTVtpY3Ald+TgGaPVFNbkx4q9EELOTGQ5hQ OIs/toDABKwp+2Oci+4+miRMxeQCIIumyjd0f6bCztebwGruVCnv6UmfU0QbVCXka0lQeP1MJ4Snq O8BvlVtWzBuPxfHQRVO8DBbbKo2FM9vCEnFEhUlQUObLPrUo4lEnSigfNSVM4323JEM3qyv5Ltx+R gQEuf09zK1nbBOUCUE9m/0lTI8Ch9ovk0+KhSf04E=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhx-0008m4-Rf; Tue, 13 Feb 2024 19:44:46 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:46 +0000 Message-Id: <20240213194052.1162753-83-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 82/88] esp.c: consolidate DMA and PDMA logic in STATUS and MESSAGE IN phases 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 the removal of duplicate logic shared between the two implementations. Note that we restrict esp_raise_drq() to PDMA to help reduce the log verbosity for normal DMA. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-83-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 8ef6d203e0..879e311bc4 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -593,12 +593,11 @@ static void esp_do_dma(ESPState *s) if (s->dma_memory_write) { s->dma_memory_write(s->dma_opaque, buf, len); - esp_set_tc(s, esp_get_tc(s) - len); } else { fifo8_push_all(&s->fifo, buf, len); - esp_set_tc(s, esp_get_tc(s) - len); } + esp_set_tc(s, esp_get_tc(s) - len); esp_set_phase(s, STAT_MI); if (esp_get_tc(s) > 0) { @@ -629,12 +628,12 @@ static void esp_do_dma(ESPState *s) if (s->dma_memory_write) { s->dma_memory_write(s->dma_opaque, buf, len); - esp_set_tc(s, esp_get_tc(s) - len); } else { fifo8_push_all(&s->fifo, buf, len); - esp_set_tc(s, esp_get_tc(s) - len); } + esp_set_tc(s, esp_get_tc(s) - len); + /* Raise end of command interrupt */ s->rregs[ESP_RINTR] |= INTR_FC; esp_raise_irq(s); From patchwork Tue Feb 13 19:40:47 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: 13555634 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 74DACC4829F for ; Tue, 13 Feb 2024 20:09:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz03-0003nL-2n; Tue, 13 Feb 2024 15:03: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 1rZyyc-0002MC-GF for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:00 -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 1rZyya-0001wp-U1 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:58 -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=5tsbqbWziA7rxQL/rF+IBFUInDY6z+t7XYQwcNJxq7o=; b=cAVQkLfraRRfCbFOX+TjqpTnoR KsI7oT63jSRdy/QQpo3CAvnh2JIJQIOx3yykvI9UrzpxpD9/PRXz1Kc/t9onIv2HhkBmzUOxW60tL deKArZSqPQ+IweNpbVrtKrJ1rQvbVldxNc5+WS92D9yDvlzQHXJI6Xp9FWsuX94R6DlK1xxg8sDwL OzwyPXcfG40kX3KKqcdoPeB/NPoJMnn2Udpx8aS5zIgc8u9GJ5pIczoIIUOXvzwLKEZ8c9vOXOyRa idehMKlfzW06iEj4kF91TIemQ+lHpMM6pfdm6mOOYylgfBGVtbNDm7GqV61aSccSB/M5wtWPkWEYe K7KGy5DYVWYbqJiJ9G5FUMepFMrf1mLswH8Df0WohSQQMDbap2515rEObyyPAcxvvxR+Px1k4fEmc TSAxn1jGkIDvIUs1PiSYkYYMyIBJpdB1Bfjg3nYptEATv+pQmmkLZRaGebHLOFSORszgN/loTJcgI IDvIWVs2JoJC3rL+WheIuMFptWHdDk6uf0/VXaaNxG748ughlhGSraHAPDB5XCjPEmI0XMln2o8u7 p+JduQ4qO7wG2pdGo3vvzgB9yHj/c6JuzxtDQUv6VU8JX5OfWNyUDqd5phvAg8MD2ui0wV6YtJ8m7 6rxDoSxbwYgcTnyundKad8AbAzxnqDXLDiwDVIINI=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhy-0008m4-5N; Tue, 13 Feb 2024 19:44:46 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:47 +0000 Message-Id: <20240213194052.1162753-84-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 83/88] esp.c: replace n variable with len in esp_do_nodma() 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 brings esp_do_nodma() in line with esp_do_dma(). Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-84-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 879e311bc4..73379a3c65 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -675,16 +675,16 @@ static void esp_do_nodma(ESPState *s) { uint8_t buf[ESP_FIFO_SZ]; uint32_t cmdlen; - int n; + int len; switch (esp_get_phase(s)) { case STAT_MO: switch (s->rregs[ESP_CMD]) { case CMD_SELATN: /* Copy FIFO into cmdfifo */ - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); + len = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + len = MIN(fifo8_num_free(&s->cmdfifo), len); + fifo8_push_all(&s->cmdfifo, buf, len); if (fifo8_num_used(&s->cmdfifo) >= 1) { /* First byte received, switch to command phase */ @@ -701,9 +701,9 @@ static void esp_do_nodma(ESPState *s) case CMD_SELATNS: /* Copy one byte from FIFO into cmdfifo */ - n = esp_fifo_pop_buf(&s->fifo, buf, 1); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); + len = esp_fifo_pop_buf(&s->fifo, buf, 1); + len = MIN(fifo8_num_free(&s->cmdfifo), len); + fifo8_push_all(&s->cmdfifo, buf, len); if (fifo8_num_used(&s->cmdfifo) >= 1) { /* First byte received, stop in message out phase */ @@ -718,9 +718,9 @@ static void esp_do_nodma(ESPState *s) case CMD_TI: /* Copy FIFO into cmdfifo */ - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); + len = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + len = MIN(fifo8_num_free(&s->cmdfifo), len); + fifo8_push_all(&s->cmdfifo, buf, len); /* ATN remains asserted until FIFO empty */ s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo); @@ -736,9 +736,9 @@ static void esp_do_nodma(ESPState *s) switch (s->rregs[ESP_CMD]) { case CMD_TI: /* Copy FIFO into cmdfifo */ - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); + len = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + len = MIN(fifo8_num_free(&s->cmdfifo), len); + fifo8_push_all(&s->cmdfifo, buf, len); cmdlen = fifo8_num_used(&s->cmdfifo); trace_esp_handle_ti_cmd(cmdlen); @@ -754,7 +754,7 @@ static void esp_do_nodma(ESPState *s) * service interrupt to indicate transfer complete. Otherwise * defer until the next FIFO write. */ - if (n) { + if (len) { /* Raise interrupt to indicate transfer complete */ s->rregs[ESP_RINTR] |= INTR_BS; esp_raise_irq(s); @@ -765,9 +765,9 @@ static void esp_do_nodma(ESPState *s) case CMD_SEL | CMD_DMA: case CMD_SELATN | CMD_DMA: /* Copy FIFO into cmdfifo */ - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); + len = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + len = MIN(fifo8_num_free(&s->cmdfifo), len); + fifo8_push_all(&s->cmdfifo, buf, len); /* Handle when DMA transfer is terminated by non-DMA FIFO write */ if (esp_cdb_length(s) && esp_cdb_length(s) == @@ -780,9 +780,9 @@ static void esp_do_nodma(ESPState *s) case CMD_SEL: case CMD_SELATN: /* FIFO already contain entire CDB: copy to cmdfifo and execute */ - n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); - n = MIN(fifo8_num_free(&s->cmdfifo), n); - fifo8_push_all(&s->cmdfifo, buf, n); + len = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo)); + len = MIN(fifo8_num_free(&s->cmdfifo), len); + fifo8_push_all(&s->cmdfifo, buf, len); do_cmd(s); break; From patchwork Tue Feb 13 19:40:48 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: 13555627 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 B4376C4829F for ; Tue, 13 Feb 2024 20: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 1rZz0Q-0004PF-Qh; Tue, 13 Feb 2024 15:03:51 -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 1rZyzW-00037d-TN for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:56 -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 1rZyzU-00025q-06 for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:02:53 -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=9+5sH1gn+fBcVBUOmEXdp10vT03mkKKkKC6r5FGwQIM=; b=Ba7nqoOuF8Bc6Ac/YqTnFOo9tX jEXNrF9St9By8VXLShS2NEn6KyWVQya4EFs2qboP3F8yzG6HbKDocy/BvDnDXbacUWL5kjpt8K3WH IsnzUQrIEll00j1Suh7NgdCCpWRtnK9xauLpPIAAU6ZitqzELDs40OsX3iUP7h7dcBgygNIj16MtO 5X8t6o2zZG/sUQXr6qhy5Pfdp490tNND2b2W3WAhcyS8E9QvpBWLY9E6QlF3ECt5wLlHyg8mlFHK+ ZKrONvGGzgdeyoqxb2Jk/4pPAhtIU1XHCtYzbGC/C31+mEMsGrv0tEhMh6lcd/L8Y3yLwACagBZaq WStdjlUTCRcx6o8FShjSwEHto0OYlFS7o4/dLHcYuHyOyK8p2NCMM14tVWKxAjWEIFG9PMk0ruIc4 9k7bsyYZZ6K7wMRkQnYN33RhlHYwx/H4LTbTDc6dPHhP45VhGC7o7ho34QiUIqlMInMzGPGCzuCS0 ezdQX6TLpXjl5qaKl/siOX74okxtD0FnEdNmiaksyNOH8z8kmCJUE6/kKy9J4Y7oMsttzdQ7vrUZE o4vdKuHjnatECYz7LPkPnjQ4tKqGlzfRGeB5uEp3UPCZQVsfNco9qAjDINCG7xAFhSpwTnpDsXx4Y Jb1/o5uexRQVFt9XGkb02rw1weDJsJ7AX4VbmKEGc=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyhy-0008m4-Ib; Tue, 13 Feb 2024 19:44:50 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:48 +0000 Message-Id: <20240213194052.1162753-85-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 84/88] esp.c: implement DMA Transfer Pad command for DATA phases 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 Transfer Pad command is used to either drop incoming FIFO data during the DATA IN phase or generate a series of zero bytes in the FIFO during the DATA OUT phase. Implement the DMA Transfer Pad command for the DATA phases which is used by the NeXTCube firmware in the DATA IN phase to ignore part of the incoming SCSI data as it is copied into memory. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-85-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 97 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 28 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 73379a3c65..5583b3eb56 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -387,6 +387,15 @@ static void handle_satn_stop(ESPState *s) } } +static void handle_pad(ESPState *s) +{ + if (s->dma) { + esp_do_dma(s); + } else { + esp_do_nodma(s); + } +} + static void write_response(ESPState *s) { trace_esp_write_response(s->status); @@ -518,20 +527,38 @@ static void esp_do_dma(ESPState *s) len = s->async_len; } - if (s->dma_memory_read) { - s->dma_memory_read(s->dma_opaque, s->async_buf, len); - esp_set_tc(s, esp_get_tc(s) - len); - } else { - /* 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); - esp_raise_drq(s); - } + switch (s->rregs[ESP_CMD]) { + case CMD_TI | CMD_DMA: + if (s->dma_memory_read) { + s->dma_memory_read(s->dma_opaque, s->async_buf, len); + esp_set_tc(s, esp_get_tc(s) - len); + } else { + /* 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); + esp_raise_drq(s); + } - s->async_buf += len; - s->async_len -= len; - s->ti_size += len; + s->async_buf += len; + s->async_len -= len; + s->ti_size += len; + break; + + case CMD_PAD | CMD_DMA: + /* Copy TC zero bytes into the incoming stream */ + if (!s->dma_memory_read) { + len = MIN(s->async_len, ESP_FIFO_SZ); + len = MIN(len, fifo8_num_free(&s->fifo)); + } + + memset(s->async_buf, 0, len); + + s->async_buf += len; + s->async_len -= len; + s->ti_size += len; + break; + } if (s->async_len == 0 && fifo8_num_used(&s->fifo) < 2) { /* Defer until the scsi layer has completed */ @@ -554,19 +581,35 @@ static void esp_do_dma(ESPState *s) len = s->async_len; } - if (s->dma_memory_write) { - s->dma_memory_write(s->dma_opaque, s->async_buf, len); - } else { - /* Copy device data to FIFO */ - len = MIN(len, fifo8_num_free(&s->fifo)); - fifo8_push_all(&s->fifo, s->async_buf, len); - esp_raise_drq(s); - } + switch (s->rregs[ESP_CMD]) { + case CMD_TI | CMD_DMA: + if (s->dma_memory_write) { + s->dma_memory_write(s->dma_opaque, s->async_buf, len); + } else { + /* Copy device data to FIFO */ + len = MIN(len, fifo8_num_free(&s->fifo)); + fifo8_push_all(&s->fifo, s->async_buf, len); + esp_raise_drq(s); + } + + s->async_buf += len; + s->async_len -= len; + s->ti_size -= len; + esp_set_tc(s, esp_get_tc(s) - len); + break; + + case CMD_PAD | CMD_DMA: + /* Drop TC bytes from the incoming stream */ + if (!s->dma_memory_write) { + len = MIN(len, fifo8_num_free(&s->fifo)); + } - s->async_buf += len; - s->async_len -= len; - s->ti_size -= len; - esp_set_tc(s, esp_get_tc(s) - len); + s->async_buf += len; + s->async_len -= len; + s->ti_size -= len; + esp_set_tc(s, esp_get_tc(s) - len); + break; + } if (s->async_len == 0 && s->ti_size == 0 && esp_get_tc(s)) { /* If the guest underflows TC then terminate SCSI request */ @@ -1087,9 +1130,7 @@ static void esp_run_cmd(ESPState *s) break; case CMD_PAD: trace_esp_mem_writeb_cmd_pad(cmd); - s->rregs[ESP_RSTAT] = STAT_TC; - s->rregs[ESP_RINTR] |= INTR_FC; - s->rregs[ESP_RSEQ] = 0; + handle_pad(s); break; case CMD_SATN: trace_esp_mem_writeb_cmd_satn(cmd); From patchwork Tue Feb 13 19:40:49 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: 13555639 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 5A4E0C4829A for ; Tue, 13 Feb 2024 20:11:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0N-0004E9-4R; Tue, 13 Feb 2024 15:03: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 1rZyzr-0003TC-BG for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03: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 1rZyzn-00029K-VB for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03:14 -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=2jpEwFF0iWK0ipjHESSVnu863cezPVN31mvVo4kKl7k=; b=GHAac6CtGWCrYeiIJJD9PRwrvF VNrY6YztYjDxzoCiZgfSHW/MXJhOfhAzwWtKAqZkpFoYEdQ+dAo7RaEb+6CC0F6SjUjiIB6hRN/iu 6fmiLBKwtb7aJHasgTn6HdffNXcNfPBVJNvA10xmyyM7MQNr77epjzpueZgdOp3sLKTKqbMb9Juxu piS108BY+TA21NMiZnV6WUaEr4amfYErlrV/dirrjWZbv4aPr8LwRadqsZ262GHXFQcQ2IiuzabpY neMXQPXkwjWybPuBjYRxZGPQcXNjrUUg8AwFJMMSBvXm/dksev5Zh523vamjVqiw19HmHOG3wLsj1 Dan9vsHJiBK9pzEfSNgVf39UwE5cOIoGUOQaVyyvcVF5Zfu64S6V7bDeTTlXLfvUdSrr1dgenQrME Mjh5eBrRTKKcKGEScpS4+DFk2HxtKJtCYubFXyuMbzxCZOmv5BCSUuW7sz+t1Lf/uOepAQDmyeidN O2jTkCafBxe3KPzVaNKgpts4U6wkm2Oxv5GFfZVTqGuTm7babRDkekXRYVQy9S7C9JAWKZdLH6esR g88LqOsgqLDi8YyejQ+Jf/ldTChvTn7NWx+CjARGv+U35xfxYnLqeuhdj2gHSUQszhMG8W8ZYGu70 Z5H/GIQsK6sbdf3p8v1XdFQsQrgJagxe7hW5+3Ay8=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyi2-0008m4-Le; Tue, 13 Feb 2024 19:44:50 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:49 +0000 Message-Id: <20240213194052.1162753-86-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 85/88] esp.c: rename irq_data IRQ to drq_irq 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 IRQ represented by irq_data is actually the DRQ (DMA request) line so rename it accordingly. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-86-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 8 ++++---- include/hw/scsi/esp.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 5583b3eb56..fb68606f00 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -62,13 +62,13 @@ static void esp_lower_irq(ESPState *s) static void esp_raise_drq(ESPState *s) { - qemu_irq_raise(s->irq_data); + qemu_irq_raise(s->drq_irq); trace_esp_raise_drq(); } static void esp_lower_drq(ESPState *s) { - qemu_irq_lower(s->irq_data); + qemu_irq_lower(s->drq_irq); trace_esp_lower_drq(); } @@ -1062,7 +1062,7 @@ void esp_hard_reset(ESPState *s) static void esp_soft_reset(ESPState *s) { qemu_irq_lower(s->irq); - qemu_irq_lower(s->irq_data); + qemu_irq_lower(s->drq_irq); esp_hard_reset(s); } @@ -1489,7 +1489,7 @@ static void sysbus_esp_realize(DeviceState *dev, Error **errp) } sysbus_init_irq(sbd, &s->irq); - sysbus_init_irq(sbd, &s->irq_data); + sysbus_init_irq(sbd, &s->drq_irq); assert(sysbus->it_shift != -1); s->chip_id = TCHI_FAS100A; diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index 39b416f538..c6e8b64e20 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -25,7 +25,7 @@ struct ESPState { uint8_t rregs[ESP_REGS]; uint8_t wregs[ESP_REGS]; qemu_irq irq; - qemu_irq irq_data; + qemu_irq drq_irq; uint8_t chip_id; bool tchi_written; int32_t ti_size; From patchwork Tue Feb 13 19:40:50 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: 13555621 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 637FCC48260 for ; Tue, 13 Feb 2024 20:07:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz0B-0003uh-RR; Tue, 13 Feb 2024 15:03:36 -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 1rZyy4-0001kr-7r for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:34 -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 1rZyy2-0001sa-MO for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01: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=DVjGUjdm8pNlCRfHncMDmo1GFwUsywzB/AtKRFCKdSk=; b=vcq6m5vZXrBszbAJvXhDLQAAA2 wQ16r4kjHFsHMvr1WWZ4Xkmzq3GhncWaQneudH2aohooIogJLccOUCexNAFdrX5E2g58acYEH7+Pt dm3Y9m3q1ERpclV2ZzpxxhFgrrJyp/lftR2rGwt6L8gPlgFT/klQMx0Q7mK7U8rsRiOckXTgDQ1+9 /GAVkp/u63BOMnapEN6hllROVedNOi9Cgo6MIkwq6OIIYBuAXbSM0TO40GrCKCMPq4uSq8Mwh0pZO 9Q719erDwPOHN5Ww3QKLVVRpS90T8KPZqV/3dvoyEBf9yt/C27rn1YQJg6Q5Tz4GjiMOB49U/Llia EQfUW9Ut58LjDRiRdPZ+ZePWMI+oPf/tOQgdlelBw7kfnAYoVbOYqqRbWfWDUcIM+FPFQM5S/1q8Z V7paq1+xDY6icvuCNFkRUtE4qpa54jDVrfNKUqMLUlqTf641xnvb3ZzYcIVnipI2K36KXpg8jqDq7 o3v3e0i2/rkGpEj5coJhargKYf9Hyt1AWfENrNZiTNbumHl5vnQ7JcJmaBtI2fA5iVCmSY/Oqs5am VQn+3xxGMnFxVW7arsK/9EGzIFnu49kMxwnNO+TF+bgoRdq4iKY0kOmplipI+bg0lDqtWjbZqNCWT PZz0GW/PcbVIdeVEGCp2noYTA89xd/BtLiUAcR1dk=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyi2-0008m4-Vb; Tue, 13 Feb 2024 19:44:54 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:50 +0000 Message-Id: <20240213194052.1162753-87-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 86/88] esp.c: keep track of the DRQ state during DMA 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 Currently the DRQ IRQ is updated every time DMA data is sent/received which is both inefficient and causes excessive logging of the DRQ state. Add a new drq_state bool that only updates the DRQ IRQ if its state changes. This commit adds the new drq_state bool to the migration state: since the version number has already been increased earlier in the series, there is no need to repeat it again here. The DRQ IRQ is (currently) only used for PDMA transfers which already have a migration break in this series so there are no problems setting its value post-load. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-87-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 15 +++++++++++---- include/hw/scsi/esp.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index fb68606f00..04615d8b5f 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -62,14 +62,20 @@ static void esp_lower_irq(ESPState *s) static void esp_raise_drq(ESPState *s) { - qemu_irq_raise(s->drq_irq); - trace_esp_raise_drq(); + if (!(s->drq_state)) { + qemu_irq_raise(s->drq_irq); + trace_esp_raise_drq(); + s->drq_state = true; + } } static void esp_lower_drq(ESPState *s) { - qemu_irq_lower(s->drq_irq); - trace_esp_lower_drq(); + if (s->drq_state) { + qemu_irq_lower(s->drq_irq); + trace_esp_lower_drq(); + s->drq_state = false; + } } void esp_dma_enable(ESPState *s, int irq, int level) @@ -1358,6 +1364,7 @@ const VMStateDescription vmstate_esp = { VMSTATE_UINT8_TEST(mig_ti_cmd, ESPState, esp_is_between_version_5_and_6), VMSTATE_UINT8_TEST(lun, ESPState, esp_is_version_6), + VMSTATE_BOOL(drq_state, ESPState), VMSTATE_END_OF_LIST() }, }; diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index c6e8b64e20..533d856aa3 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -26,6 +26,7 @@ struct ESPState { uint8_t wregs[ESP_REGS]; qemu_irq irq; qemu_irq drq_irq; + bool drq_state; uint8_t chip_id; bool tchi_written; int32_t ti_size; From patchwork Tue Feb 13 19:40:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 13555640 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 AEE32C4829A for ; Tue, 13 Feb 2024 20:12:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZyzK-0002pD-U7; Tue, 13 Feb 2024 15:02:45 -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 1rZyy1-0001em-Am for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:30 -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 1rZyxx-0001sI-OE for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:01:19 -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:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To: Cc: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=NPacf57cv+s+u41vQHu7kQi06cdjYXiQrL26bSu/Qfs=; b=K9ja7ZNs5XyTu0vHpEj1Kq99Ki fTGTVOzCekqHvbhEb8/qi3amU9FzC0gaPjR02e2SjGvxeVGbKg46CKx1E3XJsZWY9FVgG0ypWp0yh 0OWIeKSW/YFznA3qmYte2SyKTJRR2lBP/ACZa7tVB2go3i7+cjL2lx1STtSRelGUhDhD9EhycvsOS uWpLpc28Cft0DkKQPtTzOQPEAsgkJLv6JjuXwfFNIf1MG8LnPC+LRHIIDCcW3dWBlZ2PFxqToVYiB oRfbaDZRke8OKe1tQcAfTJJGemftTfBB/5OYtZZzGXfqAhfO1Z++8YwdNcr7tcLzGBJ9EdfsTiNCY pU8095ieJgY78y2pWiSewCyjDRysVLSfCi7O6Cr0Pkz3ym38TRIKOL+BKjtFv96ZPlLUd8oeReSgq K2q1+KZZoUfBeNXsEhRcvQxZ4L3XEnQM0elHrtqhDye8b7zir9OIlJ9TjLMg8leHeiwuNICzacovP blQH3wiIzhAsGKrxHyZkyJkQM9tgMbXv5N/c19yaGArNLyTp72QY9rSDum6haFKGnwhRR4MnklRVI 159fraE1UuR1U6sv4HRSGKP6QQvfAm3wpQ4iyybWyNudBQ4f6+aoSJW2l8Gx6+pjOYs8lGKv9XLpX yROX+3RiOomPyg8cduYhrwNawklObgHDa8ofxqMio=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyi7-0008m4-2Q; Tue, 13 Feb 2024 19:44:59 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:51 +0000 Message-Id: <20240213194052.1162753-88-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 87/88] esp.c: switch TypeInfo registration to use DEFINE_TYPES() macro 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 use of the DEFINE_TYPES() macro will soon be recommended over the use of calling type_init() directly. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20240112125420.514425-88-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 04615d8b5f..b8762d5ee0 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1549,14 +1549,6 @@ static void sysbus_esp_class_init(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } -static const TypeInfo sysbus_esp_info = { - .name = TYPE_SYSBUS_ESP, - .parent = TYPE_SYS_BUS_DEVICE, - .instance_init = sysbus_esp_init, - .instance_size = sizeof(SysBusESPState), - .class_init = sysbus_esp_class_init, -}; - static void esp_finalize(Object *obj) { ESPState *s = ESP(obj); @@ -1582,19 +1574,22 @@ static void esp_class_init(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } -static const TypeInfo esp_info = { - .name = TYPE_ESP, - .parent = TYPE_DEVICE, - .instance_init = esp_init, - .instance_finalize = esp_finalize, - .instance_size = sizeof(ESPState), - .class_init = esp_class_init, +static const TypeInfo esp_info_types[] = { + { + .name = TYPE_SYSBUS_ESP, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_init = sysbus_esp_init, + .instance_size = sizeof(SysBusESPState), + .class_init = sysbus_esp_class_init, + }, + { + .name = TYPE_ESP, + .parent = TYPE_DEVICE, + .instance_init = esp_init, + .instance_finalize = esp_finalize, + .instance_size = sizeof(ESPState), + .class_init = esp_class_init, + }, }; -static void esp_register_types(void) -{ - type_register_static(&sysbus_esp_info); - type_register_static(&esp_info); -} - -type_init(esp_register_types) +DEFINE_TYPES(esp_info_types) From patchwork Tue Feb 13 19:40:52 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: 13555619 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 07038C48260 for ; Tue, 13 Feb 2024 20:05:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZz05-0003qm-DT; Tue, 13 Feb 2024 15:03:29 -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 1rZyzt-0003Yx-Rs for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03:18 -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 1rZyzs-00029Z-7A for qemu-devel@nongnu.org; Tue, 13 Feb 2024 15:03: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=dIHxPmxBRjAdkbTgjMO6HK+ZBxRAFVh/P8ME+umupjM=; b=Ern9tEG4vaDqFP6HfR1ItMPg6D 2YkZE2Il73WN+Lvb9D6EfxD/s0+5cLzyZUE93Fgk96KNIfBVgnpZcrr2ExYAfwkNwnMuyXLFm41qo n4RCjtWW9c2Sz8/O//45bjDGabw12eNBwQWBHHKG+Ayh5uaUMdCR+JQe56kWK8rOE1pPtrpR4xcCz XVGiZzVKXU0XhhyVtJbpFyxMYDfORJ3UYJQbW9NP6TIzQMHlaf9y1Ug7K4IbJ2epFkjmZC7Ho4Md6 BZh/3fo4YP11epxZ0X4ciZqEFLCVhAL9F6B5TsgossfkAcNAs8pU1czlGGRtx7Au3sRVj9JQ246i1 8XECDtYybB+QpNEZdJOjcGfy/DwWPPdyjnrMcfMmCc48bYopIXNfdwEk0nkxmmaadjgVR49v7wMBL K2nbfPWsgV+bncvf9+YJ3wHd6omaeKckSG+CaP2lzHtpuBRTYTCnsCJCpBVVGJELjmLGvhY+jLjJt 3tL0fj4VJfLKddudeuDH/zRkdQ6LoxBExCHgOzzi7r1PUNx4vc+IcZVkuNOqAgaa8NUBCQGlH32oI I0zGALvhDejdGqcVjZC48yjDagP0R+9GJpXxHoccFPcrn0ISzt8ZLLy1w3mq/iorlSMn+rQLpIyXy 9/42hDCWExlSAEg5y20vSvjsOj3ytiq0lSvy6nu1U=; Received: from [2a00:23c4:8bb2:1300:c500:f104:bc51:e670] (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 1rZyiB-0008m4-5T; Tue, 13 Feb 2024 19:44:59 +0000 From: Mark Cave-Ayland To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 13 Feb 2024 19:40:52 +0000 Message-Id: <20240213194052.1162753-89-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> References: <20240213194052.1162753-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a00:23c4:8bb2:1300:c500:f104:bc51:e670 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PULL 88/88] esp.c: add my copyright to 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 series has involved rewriting and/or updating a considerable part of the ESP emulation so update the copyright in esp.c to reflect this. Signed-off-by: Mark Cave-Ayland Tested-by: Helge Deller Tested-by: Thomas Huth Message-Id: <20240112125420.514425-89-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- hw/scsi/esp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index b8762d5ee0..590ff99744 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -3,6 +3,7 @@ * * Copyright (c) 2005-2006 Fabrice Bellard * Copyright (c) 2012 Herve Poussineau + * Copyright (c) 2023 Mark Cave-Ayland * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal