From patchwork Fri Jan 12 12:52: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: 13518377 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 7B035C4725D for ; Fri, 12 Jan 2024 12:55:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH3q-0007fW-UN; Fri, 12 Jan 2024 07:54: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 1rOH3j-0007du-S7 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:54:52 -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 1rOH3e-0006NL-Mb for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:54:49 -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=mJYQo4Js1hKOdK9+l8fMHg//y3I8p0o7rNQUv17cCXk=; b=J/wm6EHaK3w83H1FMSuh4uOWbR rSWApUDgZgyYiHwTPlcI+dYWRuCth3mWsds7RaRJxl3F6BW+INBZFETRsBBMsGAQtYqU35uRdr867 f9BKFRxUu9G65IYSTjJbPovg+QPBXds5W3wJZ6SHWsZv2yyVxW/8NPDcekeCk19JpJziC84jRIKz9 luj8hc9zBcODB33yWWQleezCvX2K8dU4v4V5Af+PTXh8kuE03ZdFi6LkkDyUhviyKsaC8lxzPDFO4 QUDC11LrST0MhT4TTMrM2F0gnifwNN64QM514pPuj1smExy6/mnxnt3NbL9/te36iq8WoYle9KeWs wW1WhWBl7Izr+WxoRCoOWUGaf+vO+RX6mcPoZFDZ+SCBeRnrTR5LvEllfV2e72Padph4xFOlVSmN/ 0+Q5M19dUwcawpcVvc9YoObz0msP8Si/6vomwK9v0SC/e/ckF3wu5hBoHeOB1Wyr9sFUn/Q1JX6oK yBXVk5bYUTaqBWGiZDOpWOpekG8y5Nm2XE7mQLR9pmUf92gqD7/bh9BbAq2pXvE4Tn877X2F0bfSK JwBkzINak0+PSqWrMuwClm+9M/8a7oe9/Y4iChw7pjENaMNZ8IbYgmHcpaOPNwxtj+1GhUfKCKge6 2n4URuIEP2jzIEgxdGsa3SNh869vzoX99lE9CsTOQ=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH2s-0008jM-IE; Fri, 12 Jan 2024 12:54:02 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:52:53 +0000 Message-Id: <20240112125420.514425-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 01/88] esp: 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 --- 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 Fri Jan 12 12:52: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: 13518375 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 6E2A3C4706C for ; Fri, 12 Jan 2024 12:55:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH3o-0007f7-PT; Fri, 12 Jan 2024 07:54: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 1rOH3j-0007dt-RH for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:54:51 -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 1rOH3f-0006NO-R6 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:54:49 -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=qMKPIv7n3BpNzLL/42ApfjQFsQY3H7ShLO+eO9sIBdM=; b=c9yTH16VPIOBj9Y9EvwNH7wxwI 8FDkNjH4pVINM5eGJI/bKiBBFaBhV/6VY9vFYLoJKawfinZ0gCQ7BW8qU4SXs05WzVW0Sxnv3P9fC Q/ulEWH1aaS8RfYseTXunofbn3TwGpNWdUSk3u3Iq6aM5OVWsab488w6Ixyb27n3YyrJ+1O64K3nA ppS1d72Ay0MgILX6E5EeFcZtXlUSi3ypAjgVnC51T3uuLlQdA/3rHEZbzD5hnvxiv79S8P8mFE+Cs r7wubPwX8l7k0uNNuW79o/tHYEZQiLsx+aUboC0hIjsw+nMKXSZ+HHo/YMehTAVyVPxvr7krsM304 VD5H/rWwkM9dLqaY8scjzQtHcsm7XxSX5ZLM+Gd4jPTUwP5To7+A8NKlaBIeowtaVLNuUkb53NKli FZhVgd3R3drNlwXBGV4FZIv4lFMtrRrSTiJFJTY24SarHZ3cq+86WrpChBNBZqccd+iotuBZtiPZp UCxp4Ab2PdvX+EagxrVMnBYj8hPvxPyTHuqHT1jnKUvNCS3O8aUvkCBxTCxmmGKFdizEKdQ/j+Tat AzGKIWPYigVZVPaHTT68XAYhoXqquLAAHMq4naQNDSS13ComNFmQ+6qMpADhS9LRI8PBb69SRogYV FwkDEIodPODXkHoPsT34bsVnYPR72NQmbONq1KUOk=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH2w-0008jM-S9; Fri, 12 Jan 2024 12:54:06 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:52:54 +0000 Message-Id: <20240112125420.514425-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 02/88] esp: 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 --- 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 Fri Jan 12 12:52: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: 13518462 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 7AAA4C4706C for ; Fri, 12 Jan 2024 13:16:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH3s-0007fx-KL; Fri, 12 Jan 2024 07:55: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 1rOH3j-0007dx-Td for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:54: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 1rOH3g-0006OW-VC for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:54: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=LrtHaOwavcENjDXgLckDEnbzM2gGcemUsTqaptRr640=; b=ruFMKuLlD3sIvbdkfO18SF7PRG XBr083CyZlTsO0bBYU3JUeDsVDHqZJKvJCMLiZcd4urzbgCnADrkNXZbiCEjDQqppJaJ4fv8g6uCu 1tqmAcA69Ja4AE0ePMSxUX18Wgc9kZ6251g4U/Gzrx4h2mt0FQR9S18hG4tOjmD0NyIJjAEuuNZ1S /DkKoccLxLw5kMFapZj1L2IQVtDbA0CZQ4iJoTHVeINlhAlVFbI7kcx9DEkC5QDoB54sK0DNQ+r25 Gf9wdKV5KCcW6YpDZmQF3PNnoInbxzE7Zfi//lMiv1pxBa0g5Ga1Z6xvROjzgxgRGA670qC408SDz VLOqHqUn31exalzJtLIKvWRJTWomId90CTi87BrNeG9PjxlGaW/5duInA73k4OeUTVVoMmUpjYc5p t+DC4kM561zK4+O6mF3luPqMoWAE87W9UgPl1TCSS0RICw42Ao4s16dT+36KloDmHZknn19U4S4yq 46QhYVJBGWlwxhOHDBYKK0vGcOWM9cv8Pdt00E2xhETLajOeiAl5+iLJsJeEMe7Wlx++Q/+9j/3Bo jJ1YrfMsQqF5KPi10EpSwG07o2tFASeFEu/9m0ToBs7NqvuRj9kMWZ2rjtNNqqlpRrz1bCuErRrcr 5uTVYgYmd4OjOYcWwgZA/OhA1KEp0ckg9zzXxZAqo=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH31-0008jM-5K; Fri, 12 Jan 2024 12:54:11 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:52:55 +0000 Message-Id: <20240112125420.514425-4-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:52: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: 13518455 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 78473C4706C for ; Fri, 12 Jan 2024 13:12:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH3s-0007fw-Gm; Fri, 12 Jan 2024 07:55: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 1rOH3m-0007eB-4p for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:54: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 1rOH3j-0006QG-Ia for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:54: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=jt2y0PgrrcIgnCVtfPN4JS85f4NUUFLJ2eLjR16bKV4=; b=v/kgi89KgRs3okHg9NouT8kUuI 1donAzmZsVUpt1t+vg2uVwsDI6Ksoa2MmIGkW7lvqQkV/06z1dEvApsEvAEQg2+HtAaWAB9oGVsY4 vT9hvBfpV6pAhMDdPsg/J+xeQDtJVlNibMhIgUORVjgkGYOL1deqXFhlpdZGk47akNM9zkrUQMt/E 49jIWKb2Sm9Kd2rhwgk5wIa4drNcBtBXP0DrHmJetuDDpOQfi4R8W0fNATrp63GZ3DIDBRVatqy91 XUl2OLfW26qFnVpftboMhCOfEAEcTh8ophRTor6k55tGtQUYrsW/j2Gc1lV4bby7yHd9eUIRpvlkm AhCF36ZYxQsRnxX+1Zoiic1GFqFf4F5xt+ASp5cGeEHhiRvUSYzy5g31i5k6MQCDaPFdK0FZOj9uI q5Xpcy+mbiUoU5l7+k1ADAv7atd2cKE++I14ZRPSq69fsnkhXqUSSaFRvf7FHU0ec405k1LMuhTug eSo+ueeNXgLq9xfN3RsUeG/hJNF5ZnnhpfkCfjGmSt83GsJCZqjn/175/9PNSxHseNBoeCJUwM0Ja LVcmnKpzJceDvcYYISeuPC8hKESKX9q50NUW/30dq8ClPBBU4TT3Y8bI7M6TDo3kaAoNh18qHB3Ds VU//W4iqK6fbfhGLJ71rJjtD+Y0KOvwQD1o7o1HV8=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH35-0008jM-Fo; Fri, 12 Jan 2024 12:54:15 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:52:56 +0000 Message-Id: <20240112125420.514425-5-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 04/88] esp: 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 --- 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 Fri Jan 12 12:52: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: 13518379 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 9F0DAC4725D for ; Fri, 12 Jan 2024 12:56:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH3q-0007fO-Fw; Fri, 12 Jan 2024 07:54: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 1rOH3m-0007eS-Ub for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:54: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 1rOH3k-0006Rs-SU for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:54: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=2Z7t6nFfDDvi+pCFGJVq7Tjpp5/DfqHou+6ng4VXJgs=; b=q5Vc8FrxbzrL6PDqZvsDYBcc1y kaxPjSBk4NwaKgqWL8/CYnZNxBdi3AyOlqniklVm+BvzYPSfOvWY4y4Z2TlxextOCl8z2owwZycaO tkauEdMR/85y7gny7G1bayDpGgL0Qp3qtx0bQSJpJgP6Rl6AiKtM54xGSdT9zEtuhVMPRjwJ7sl9V Qvh7oYDTc9WdhSVZqEkeXutVZ+2F7c3txAYod/2QglliEjraepMh1JZr+nW527AsZ1thwGd46WdRo VGdNQRE522Bo8nfXiPc6TQLh+Kkt0T0gObRWPfiZFFaaw8BB9jeh6srqS82roZMaW9KAtVrhCglBh qqgGRsARCWhXdpLJvU/F/2ajx1fJ7kUlKurHeDht4TRGYNKfs2bRCIOGI9Cqk1us9e4QEGzB2+QI7 oL/TqBCMI9i0AQALrWkda5E8suBVJbTB34gktk+kPL/5rY349lFcNtw/WTvY7Opu70QxEagrQMYnM ZjeMDicECq1dQI343OJCL7nKXXaeJ+MDcXq1iXTpcjeiGUb8kDmpClcmfVUs0OrcqSfnXK0e44qab rc8XE7GXNNpMiykj/qUxEdH2JEU27NMJRgYt6mXEKSYHXuTnKj9k2iUE2k25TKO0YXAR2AuOerLes 7PLCPxjLD4oVTVnXT3Kj1FFyLYHiM6xJy23l5TSFY=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH39-0008jM-Ow; Fri, 12 Jan 2024 12:54:15 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:52:57 +0000 Message-Id: <20240112125420.514425-6-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 05/88] esp: 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 --- 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 Fri Jan 12 12:52: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: 13518383 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 D2295C4706C for ; Fri, 12 Jan 2024 12:56:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH3t-0007gD-MV; Fri, 12 Jan 2024 07:55: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 1rOH3q-0007fV-Lg for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:54:58 -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 1rOH3p-0006U8-6W for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:54: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=bOun1zsF8nfOtU07eyhiinZkCZ4tXaO6uzVOI4lszwk=; b=1Nd+JOCPOX2pf1nv45tYLjiI43 l2vnwwnt3+uPvZe/CQK+wvIOKr7GOtafcyHE+Goo9DRY+k0ASrcqwd2rEmBGG/+Exs+9mxCQAJZfJ Egwe4gXxhmTQsPh0ip/49k0Ksn2LJvewuqqH0oxJmfFPYIQ4nPF6m48QQdAImnAjFt1nJcupQ4MlR PMIH5PJ8G+VahV9Atf+kChO1VGcfbEY4XTEoHy3VGQpYy7oV/YY0++HOolC6P+XM25o0VNAdIfQze iFsP9X7amFiP1iS2kUFHMsqcN+Hizh5VGMx/myf0APFgpHFKvThcDA21q23itiVT3QBqZVcZOHLGW xlYY93LLbLyl1HtYsUKHx/Ni6QKxPy1UcvEjfbYkMpcaG6QntV6KBjBtImd0jFGdvqSfu4ry61Y5i HDagprjEhFhTCfAQFiSIl7K6fRiENMFpeKrf86kyGiWOiGOs3xVBgt0zwUoueoYw3H4Ps6n8qSsNN iwG8uBDytehP1+U6rtaIMeY77CwiDykYb+eeWT+xzU2DgnICxt8MKod3raaCrriVBOFSk2qdMlsKe UtlZ2sJzX4JeRX1Sf5ROxrJQWpJeWRVDkFvY3dOtRFYskMMtHLz/9dHWebdyVgOogOI+VYYsRmNU2 FKPKjQksefKnwfzcZoyuYaHMrMJWGBacmer0989J8=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH3A-0008jM-5l; Fri, 12 Jan 2024 12:54:20 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:52:58 +0000 Message-Id: <20240112125420.514425-7-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 06/88] esp: 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 --- 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 Fri Jan 12 12:52: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: 13518390 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 F2B4CC4706C for ; Fri, 12 Jan 2024 12:59:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH3v-0007hZ-Fv; Fri, 12 Jan 2024 07:55: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 1rOH3u-0007gy-Go for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55: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 1rOH3s-0006Vv-7o for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55: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=RVoheZPunkRsW7VL3P4H+EBYLDchD0JJLbv2AiQ5eLw=; b=GC6qrqwOjbewwjktQ8qKPxrUko 4NVqnEfdfSUZ4y8c+VOwmuqrgUyrGS2OqY+Vy25TrNX+hu0jCn8eQQxq6Mrwx9g7ovWd5sSozgjeE AJYN7piLNV5TAp3NW5rZaw8lVUOVtrQhANI1SKevLg3wT+FpJA9S8OwGU1q1tqS4Ab7yZziO6A+aC GQhja3ORjM/sEDnqRuGv/22DvLRw0QnG4h6/y+l8XtfiJpYk7HsWqTZPmt0DbB/4oTP2xn7AIV1Wa o4CePpQZa9hxZayR6G7LAOGJdtiOYjBhdrkdKz00lBQe0r3aDj8jRxvMjhI/Ra71uuS8zBWGgmh3f 09rWNOnv0hrH0E7byDjT40m4LcByb/xqaWD95wGQiCaKoPmR/HUkxacQK3jja51HV6cZ/RsC1Ic8J KSc06nk+XF1xyZMXv70XqFfm8L0Vg3OKgpWjv6IKogfyCdULNUgiY4XK9c9QmyEVtXQhr0RUGo7BJ asCTJNQHjn9wvutNJtzGJqn9pSKNzTS3BvXN5DweJqTJI7VoTHGLyNXFsDHk4LM090MRy8U6SR521 gSuR2pcl6Ol4K/RBTkvUhA7gaY/FJa7QIbMTyHqLgePMbvmnDO1hn2bILSMW3VVtiWxUd2Z20nsJ7 qKembai2HbgwsuvLxCn3KwYS43DFzHFrsA1Rau6mM=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH3E-0008jM-Fb; Fri, 12 Jan 2024 12:54:24 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:52:59 +0000 Message-Id: <20240112125420.514425-8-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 07/88] esp: 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 --- 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 Fri Jan 12 12:53: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: 13518419 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 59822C47422 for ; Fri, 12 Jan 2024 13:05:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH40-0007i5-8y; Fri, 12 Jan 2024 07:55: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 1rOH3z-0007hr-Fk for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55:07 -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 1rOH3x-0006iU-FM for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=27fRoZHGPFVk58crHINcAUyDNW4V4OJIC2VY021bTNk=; b=adokEO1nzjAQ0x3B9aHjllU2CG 7RWuaOxe6T9QpN5poGJhmXf0VcesLflZwMIPawndac+EfiIdX3liCUPmcfy01LJVvyXA6QF9zFHsN aJz42zzTMPCtgP2JYbvfjbsEByTKo0nLPWkS33XNPDV30UoZO1u3GcqkbJlkmssscLzLMhjNTZIDn jn1GbTrPOMUrsTglUwqivqaHUl43hYzTU8It4rPRxDBvuuFUQCRF9JDz1g3U56vK/wt6JoPHacs5L 3trOoY0ySgEhC2cuCnw4L+PgW3RunsVMJRetKVfH0ZgjuBeXoc3H4eiX7ldP/+W4MiECYJ0Ttl3t5 DSqU8ktIhPtEv+owhzherS46z9ZtvisoG20V0qGa31R9Ckpu97Xer4nc+OQIHHkr+3w1gQ4hvfBNc GovP5oX8Y8/C+yWW+lUpsR15wg3iHp/wGutuby7zmd6Ac0b5+3EIseaTbeiahKQpWWk0lEYS5Ac8F m2ptvrQFXHdUl8uENWzoEHhGfaUAwi7dch82uK+lzgustUbe2WRLPkH+tUrB9VrvBrM1hsx9rLlS2 unSgeRYQp3O6LFDVy6c096ZTybE48FKcTq2MmMgYb+6nU9NNzSeQfdVYCPmKBbGVpK7LdOH0+XaX6 rhmD6nTj0yQtHNXpFaSEfmsX0hG2PedhQOz2OccsI=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH3I-0008jM-P8; Fri, 12 Jan 2024 12:54:28 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:00 +0000 Message-Id: <20240112125420.514425-9-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 08/88] esp: 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 --- 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 Fri Jan 12 12:53:01 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: 13518376 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 C06DEC47422 for ; Fri, 12 Jan 2024 12:55:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH44-0007it-S5; Fri, 12 Jan 2024 07:55: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 1rOH43-0007iN-GY for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55: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 1rOH41-0006mn-IR for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55: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=UWy1SFEHPyFakfRqBUrdjQtvIxVgd8l6c3BoIPJD0R4=; b=tl5yYtt57Xrqx+DZZF2tP1HxJj vPNiwTA0N8/WRavufjXFb6YrWKbXskQ4h87YjIiwMVoxfr6oiTm3EMSGZ5Yq02LcJzccJDRiE+ONv 0d2DIqz6eCaVHaXNu7ZPVQM8uhw5LQz/pGJ/4ZBLh50aXWbiszXhf0Um6it+eSa19DASvdhK/rE+z Q8qroW5JvVFlp6S/D4qYcYls/P94OGs1J0hLi3bCmwO9HYJD17pNOAUAhufT89VT1sTpCNzGUioyj uOykA1J1ZYxDqyAoKrqpNIB17jdgQbLN+mRcIW0s0KemqyJ0Y+qDbSr+0wH/8lGBSAWuGccDzc2gJ Ycrh+6PP97SauVSfC/147KwgMXuJlqPhOtoABW/UKBg+wGhY07DYfTtO4keN//9X3mebzyJ7Hfedj S3EHFqUzhZLDVxBrFocZFW+gxhalqTiypyIq8SlaWzWTi8Qhn0Wgi8rBspx/Xyu4TbR6aHAa8pQgp tg8cOq8890V5JrPBFOmNG4Wv6Ts/mG+w03i0hdTk127vuEAOxl/OZ8NSizsKKyUB3RYUMM/oTrjgL SYwVVk/YE2jvzre4bASD70dnj/SNR72FBjy7Om5Kx3QykmjsEN+V//JsOkcFKx3RLXQcNuCA66Ehz m726Cq0uQmiN4KdApM0OmOncVcEE+7VKKXsLR2Xpc=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH3N-0008jM-60; Fri, 12 Jan 2024 12:54:33 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:01 +0000 Message-Id: <20240112125420.514425-10-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 09/88] esp: 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 --- 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 Fri Jan 12 12:53: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: 13518380 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 A9F16C4706C for ; Fri, 12 Jan 2024 12:56:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH49-0007jY-A7; Fri, 12 Jan 2024 07:55: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 1rOH47-0007jC-Ld for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55: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 1rOH45-0006nO-Pe for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55: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=dduij/1KHNbwQV3V0mAVvsaSDJf7TLad9xOYWtTXP10=; b=Vapt6Xe2zL+Z31KTreVMzM54XA rD96adoMm6S4KVsIqc0isksrG5+m+OChxltpGjO6VjA6DnxPAsA45GF8eiczBr+J8XkfA+fDorByq CSbT9Nw69ihbOEYeMe4I+JUv6OYse20twaQqXoS5aznZpiNQs8blFqznRFQ6/QD1pWaVCgWVM2MdK IT/c2BsNZ4zs/0NA6wtoNbmAbATLVvD/RoXSNKc1SU7X6y0z6sU9nA3G3XESK8AqRNTKRTVqlXu5N ueB0Wxw9sJgZuvw5iOQiXTzCV5Rp8JQnjIJvv9Bu5UbpeT6G4Lqtw8IHwk+tct5zXtXJNoUPWJhsl WzwLte30My8K++CeYGwsqRuDnaJd6SHuFNpkot5ObH70cWk/GmLw9m9317sarVWnVf9LXb9KIsdnH TfKb5sCC0cWHRkXodXFNwk45wzLdDqFbbBfR15pU6mtnm04l/st6iQnprL7tKmz41UNvI/ZATbUiy YaZXyRlxOCx1X0aliLopu9K2QSXi7rPjANEkl9AccbQkScI3r2cLM8g11oy/M74FqA/Cj2YrnSd6f wKpOVR32thkQKs5tZjiFXoQAU6LYxQ95wJZK73UhNK+IiQJMYr7fvejAMJCwfSoxLFdxVQW6QQEiW EGFcM3R485wcoj7b1N4VN3rJfLJYNj63HogVCzcAs=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH3R-0008jM-FW; Fri, 12 Jan 2024 12:54:37 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:02 +0000 Message-Id: <20240112125420.514425-11-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 10/88] esp: 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 --- 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 Fri Jan 12 12:53: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: 13518414 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 CF34BC4725D for ; Fri, 12 Jan 2024 13:05:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH4D-0007jr-2v; Fri, 12 Jan 2024 07:55:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rOH4B-0007jj-M7 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55:19 -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 1rOH4A-0006on-7m for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55: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: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=myDJe4/tV7pbo92BZXghNd4hfgAdbUryo4MWAxqSheI=; b=wcLdOo0W/pLj2PAkvcCGV3RAMf NwKw76/7NLgRcvkWCOflNQjbyfuMeww8zRx0oTglVHXzFIIosIfy2QtWu73UNLtVqoGX1adSplx5H E55QbAXLTvqv0ONnciBtKvG0zyQZpsnfEZvYQmQDy2+Dz3m4lf9zLklDN+ceOaHNlV2RCi+EbyRYX Tv2TQWYjWNdzSpXFixZN/LMF3TbVO1rcIaHrQoeU+KXDdLT9AsnM/SHwvSWThwsDV3dxjfGZB0MSl /VpQRqF8VbK9+oK3cuUSn/3LNaCJs6LofZNQPrbT9b1EdWclsBv+sQorTOmLwdieQwpXnHfCnMQ88 CHuB6ciAuMR2H1tjGJJA9HkDCYDcx+EEAA/W9IAPrLwcE71LHtm+U4YmlqEvcXv1jEDtBj583NjLZ hsigf75DU3tTJnNUbbdIZub2NfR8a7yRcmDYbhc7IcTEBUGUKUCDnHr0M9kP5gHi1plQk48egM+pC qT6DXVv2Y5Zq0a49uKGj97iRuezB56/6t7UKk7XtgjvKy+z/jcyYqEhvEAzqqHl69iEDgvA2OcdYI kfbj0IQHe27AaU3FxEgxbfUbSXL3yPXCIHDUHfWWoUxnS1j1Tt9T2sGAfR5FQzVxKFcZfopfcWWtS +hOwTU6R/qYzjHdLTkpvn1Lm+pkJThafsRMgGXoy4=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH3V-0008jM-PL; Fri, 12 Jan 2024 12:54:41 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:03 +0000 Message-Id: <20240112125420.514425-12-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518389 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 2EDB0C4725D for ; Fri, 12 Jan 2024 12:58:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH4H-0007kS-Fn; Fri, 12 Jan 2024 07:55:25 -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 1rOH4G-0007kG-3z for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55:24 -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 1rOH4E-0006qA-Et for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55:23 -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=qwygGo0CcBS3qdJUdX8c4HByuf6EAaxnYb+eq38j2qo=; b=wfmjNwZQvJK4Vjwp2+IVSH7bEh Z7QqDS77Y8ax9TaorTAyNfdqN2RXUaLB7nC6Errve+vT1fkW8QPkkhlkM/1JiJ+tdKzFQ/nAUZEBG W1eCaudIP2K2HzVor3+4EntXlRgFRvH6uAj0svHvxReizpl3imE4Lw+yohd+nvGDZ6gmjila8cCja kFcY1EQ/sjN6vcY4AcE5t/lZJEIoKxiCHG23bwRrtNo8YCN03zYqsgaR/t72vGwJT9MTedRRSSMC/ UZqu10cn35SV1gErZ/MfLvYje/hILK7Zn8SYQNVcZJVf1C3rpz51wcvG03wZMkyfyW+3R5ZQF07Z7 G+odaVMJlNPVspljYBty4Opp4MFYjj5mB/UQqQkDn2X6XBJzw2HrNPO5r2Bsd5o5EnjXhr95Y7AG8 Bvrp6MiawSuxF8T5+OQ/VBm1O3AQPNwO3VDyE2E1f3xa2JKF1A2Kejp60+mb9WkbSmnqv1eDqj3i8 iBjZXBfApOo0yTA1IvZ5X2+WksHEyK5trzeeKW7rtTuRN6KqpiE6CoNSCKstcAXup8EDphVVQyGmC yikSv4e8BdztbIglE4HME/YCIDTI1twrxabkjOF17L1gBtWj0G6CeviY/v4cd+RYJN8QQV24BKLa5 0rFUi1ZdMwZ89FLWvBQLPXryUPYo2OBjYpkKFlsxA=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH3a-0008jM-2s; Fri, 12 Jan 2024 12:54:46 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:04 +0000 Message-Id: <20240112125420.514425-13-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518385 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 4FC30C4725D for ; Fri, 12 Jan 2024 12:57:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH4M-0007p2-Ms; Fri, 12 Jan 2024 07:55: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 1rOH4J-0007kl-UN for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55:28 -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 1rOH4I-0006sC-Dr for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55: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=lq49uNZB3MLODjuJyeTX8Ffd1tQLBuTAp1UP6rI1PfI=; b=rivqto6bA/3ZMi3PJzHDyxu9jM gLnJTDsLWhu7bOoawQXPyy572YkUcr2ts3SpBpFMC3XQwES1f0JSRTosnIn/EKFC6fkv8sI9YbHp2 79/28sCW2BHJjWUm6aRpEEO69YGtL4ITAb+8jNQDSp2a8jlJgyv8B4UNJu3j4qCWEM81A/UiN9sF7 8YcDXz0L99dKHyjgTfsJJLjtZxlJpRhsiqWbNsQ9Y1Bt9H66EovSYvPdLqhF8DC+jg7G66el/03Va DCd6XZ6BbbqvLEOiIpNvBX/s8hzW7+7X0mCfWs3Ij/JowqqRrMzajXgswgl35bqsu7zf1YxIdxtdh p51tFknKoRtgaBHPz5uAVwcPmPt07dx8FT1pOcSAx0MDySUlNy9eD72DtqUmzq8Owrwiy1yHNQgZZ 9SVxR4n2jGMvbBHcYhkM+wJvKJPRYsljz2AL3bgrmj9e2BIdIpw4A+jh/WmfZiiMGYp2Bxf7BpBkh wGTFSiVm8BaN+4A9b/ERm2rXRin1jdRcdGKFwMcwd2E6V66yxXkPC4B28UnD/hF3sh32dm1gZ0/LJ +6MYYDYne5tFU40dbN0jR3bolHYORtXCv7x80KtpwNFHdNqLxOKRTWZqpcJ1hloT6zrCHj2utiYHS 62ZCfxQgW9VFacW3D5Lz2cn0ALZFTJzvAh7W3WF9E=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH3e-0008jM-Cc; Fri, 12 Jan 2024 12:54:50 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:05 +0000 Message-Id: <20240112125420.514425-14-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518378 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 AF3DCC4725D for ; Fri, 12 Jan 2024 12:56:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH4Q-00084w-SE; Fri, 12 Jan 2024 07:55: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 1rOH4O-0007yq-Ua for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55:32 -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 1rOH4M-0006uM-Pl for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55: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=AfcHn9JhGFR8cnvbyQwF08ZVB2JJDc2qmWLxIwV/uug=; b=r9I6jJVqmMT7maosB2JY0KyITT rYSeox3Bp5wT1BGxCi4Pw0hF114AY/FqjqFi/wHJZJygR6FLNmq/HrS0wJ3O/fnxN+n8+gmHnoCvw g7x3ywDuTpqm7l+OED2q7widBPVpQ+8g59R0xfvDowBxf2vNv12VVbtQKpKgiDgHkruvScSz1DPjY o/Sx/euGeK0/5+/Ijb2TwCy+ezriah7Mhoj0hhL2Qrxs5RiahPjggjN321+Qfnv/a5uvc01AWoCRt sw+8M3L/HjP06OfkGAn4+QQwTLLzU9S8zfQZHp6/wvrbCSRNlQbgn7suhJh4JRlCJyYF2zre5K3K+ OGdsTc3iGVvvu89TRth0M/fDvwWwMwAz/iavnt1Vu0kgVB3uvRHJG5JwdC0knCDTsJAhcuxhBQMNY Elr4oQRT1ZOajFxGWXNJG7A7E2a5HdqrbDtM8prSc5y2Q+o/lsgC9Eb6ba31eWWJUyF3kuqvGXV9J s0cDt7c29lC75Mz1xweSTonsaFvFU2GKxTbBIblDNh8KXNbL0Z/A2yNOySSPt/f6IxkE0H4C5KHt8 5aFKs9QtPc8gMxPpomSq2/cN/nzFXzZjOVjr8ypWV0r5kb7bDuVdO+m/xQbNd2K/4qYG0b1kGo1yR jwxr7xpVQprs4nC4a9MUZToFUaVatim+uaKbmuBVA=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH3i-0008jM-MF; Fri, 12 Jan 2024 12:54:54 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:06 +0000 Message-Id: <20240112125420.514425-15-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518400 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 54779C47422 for ; Fri, 12 Jan 2024 13:02:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH4f-0008Mr-3s; Fri, 12 Jan 2024 07:55: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 1rOH4b-0008Hp-BM for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55:45 -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 1rOH4Y-0006uY-1F for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55: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=9JhZDwPgEkO/WfNmBUOI4/IOi6gjgdQRkbpOAIlnVlI=; b=RWPARnpfPzekDcZ7zYON3YkH1T Af66ZkNzlMhjP/rthyvz0GlmI1IdC7yzQ4APED/6zzdb9HRXdErunpbf/c8m5qI+aG6KnGXLI8T/m W7mzBX0r1kS7cqAs3mle6ASCk9DDQjCvYpFR4UaO1ETR5Pf8adD/+hcevt61IXb4fg9WkgNxFOlqw 3QcWV3Q2FHpOlHKZZsWMi09Q62HUHKJn6hxba3vdKfQwqgflKSU3IxvN7KBXEsqQyAtoI74Nmndsn qjJ3wHezIa0Dftb3+jYwlTFVaaoEFVlKNHJC5GE4D5pZeJEAFR4dnQLBIyPQnQLXLk1LaWJSmYCNo uBGy0uyBWVlRwzMytziu30MVB2y9Ytx3URgU0/okUAMzQrfKPxJ6UGM3JidWsmXKXY3KTXwM2mNuP zvIqDyUpF06m+l2Aa4H7go8lMHQeyVbuw7P6xZwjmTmzdVQxudlhpD2m53KLha84uOBmBeZ1Ayqdh gUNnDuWoIcyZX1Lkha6SLSI8TunC3zGzB7pTWYqjgWjifiWW3tP55U7KavH73JRd00irwu8roe9Yg qn1t+cBUPtLgTCukD5ohpLN9qqqcCXj7zt9kDhbIOods/N2Tq7XdktLq0plemsiELkC9ASDBQ1Fq6 3UgffT330stU+WlhXzutV8tceHDiOaKwuggOzdnVE=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH3m-0008jM-Vp; Fri, 12 Jan 2024 12:54:55 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:07 +0000 Message-Id: <20240112125420.514425-16-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518387 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 0C1DAC4706C for ; Fri, 12 Jan 2024 12:57:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH4i-0000FT-28; Fri, 12 Jan 2024 07:55:52 -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 1rOH4d-0008Iv-74 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55:47 -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 1rOH4b-0006wV-QA for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55: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=Kohj8aWe0bSl+Prntzy99RkYfDJVZ6WkKBOYa/gxkRE=; b=XR48erWfnxyYw+EFl534VLwDpU my0+bxsUjP1Sz0mgx4hCnsixAJy+CmkeTwc3qz94AWWqT+NeAFqpCaKyD8zoQSGJkqp8+aOn+SDF1 fCj5PzgLsO1HqyrR0GbYCHkHGQq5tiJjTZJwqHqmted7FKkjVjIGiuaDo/9EFl8pvhOQdBboQ9LyU k9sAV7JD654c5puW9K7BajgopMspHJEXUGqicMDuMiiTwVY2HMhpOfxJ5GrYLh7w9khCn3BoQvznf i0ZL3yZdXsf08wTYxnfjKdT0/afUJmUp6tglXy7j4dP7n2qztJ+NoCj93LWPN16klVALp/cQfXYpT Ugcaj1nDiy/3GJ3sSBTdlcsJT3epT4vXqyCDCPuDpu75swRUljnJyLf+iImtqfg1LsRbeu7S+RtmJ ikjbQyug7wIgz/Gwh4m/mYBoB/1n16EQuI5PQATNsWI1MQJOWDrkfec4L9SeGbgdJH9T5ywmlifrO JC5gZM1b6uR1Ax516MJqpBDnT6fJyqBWsIkp90Pe2NMkW42EqiuKlxXNQHYUFweL8kujiCOHEP9UW jHAuLVP0OES2bdfz/SAoxrZ2D6lZHw4OD3AEB+9O6m/spVy5+THcjTtV0qkr+7mLQJJCQAHF56hKx J0FVptWYsPAtjaGqbDi1LCyhPyqiqwdpfLrmUBK+0=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH3n-0008jM-GG; Fri, 12 Jan 2024 12:54:59 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:08 +0000 Message-Id: <20240112125420.514425-17-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518382 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 60465C4706C for ; Fri, 12 Jan 2024 12:56:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH4l-0000Qo-NX; Fri, 12 Jan 2024 07:55:55 -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 1rOH4g-0000CA-V1 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55:51 -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 1rOH4e-0006xn-PK for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55: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=e6mCLf/9017hCj5XWuJdYBBrxktVwOh7syFJi7T1WOs=; b=l8P9EYisGv3pw3jDivQESBQ6LJ jSfwYWCQhM8ZtrjzfXKaGpCEPXoCL4Q5yoJ2tjWUk7r1UA/Du2mENco+TdWzCbrmnxc5/HJkv1c0U C2U0L6ZF43IgLg7M948vXWhxRVGElVGXkfNcSO51156MW0iu3T7p4BywTVrBCCdNOUifjI6Eeq7UO yXCdZdoT0I5LAPuU09b4LUYCmtbxQarKr5m6sNE3P2KzGY/iwf/EnO8bFETiqS5ZEwJkLuIs4isLV 6/cHoykpa1RGxTXIG8KqKptnjXO4SNkuDVq3K303T+IPVMI6FvNvLIUhX8f2NPYxozv+rChfY1Tqx ZzxtcLC0+Nn/vTYNUqApDbJkujflN0obWtt9f46SnAJvOx4I/9i1ySIsgH6Y+DrF9iHGYbksli2qh Wp3iRj9dxkqznOBwSPQ7oMGzwGLJPHTbVWe7WY7PZLXObDbQbn8Mip5gjPFKKpWrF32h9Vmi7BLQ2 yEsncCrKODovMRRyvgzVOGfRffxA0e5wCxKrimu9dw2WjN4UlbkhWmLUwt2TdLXqmxuskfFcQgLdu Cv+2jkvS8Garl9GL6g9Bhj38GT5oqAg9BtJt68rMyePD4kGVtVvbWa7Rhi4jxkDwOntXZ4K6XVI+J reo9WsnXkN88N107m/zIDjBNtG0TRFKx4uBl1tbrc=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH3r-0008jM-Px; Fri, 12 Jan 2024 12:55:03 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:09 +0000 Message-Id: <20240112125420.514425-18-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518436 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 1A8A0C4725D for ; Fri, 12 Jan 2024 13:06:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH4r-0000qR-UA; Fri, 12 Jan 2024 07:56: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 1rOH4p-0000jB-RR for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55: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 1rOH4n-00073T-3h for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55:59 -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=s4rPKcFLbX8niKpWjf2P8IvVU6A5UW/0xlz5tWOi3+k=; b=kIyF1TcoOvMnkuaX01cYS99Bpn xk1ZmjGmkTYx68IreI3a5m48bi44d0tzmSg8Ybj+oCybI44n9x0Ig7nGlwrcsOqEqCm5VzpchOshX a51Kgx6Nl83gtxXQXBodHIGTPEUCiLCYvh9HYP/UkRNyCzgHMq/W1yfp3i70puR+BiKyky72ZQRcF AHwAmVu4MvszVZK21zThfcaHqHow055hzjTLlZBLJertyXlPO9p/gnwk2ngF13t/fcfY+RhGEY846 SsGlvngtGXkO3osHl6uFDQT5ObxXlLHS77y+pze/L/ezVKMAHRd6jnHDUEwx2/ViRr3oKeLxP3Nx2 QBUoa1YV7u8rgMZLPL6zw9fQZzVEqrxhQC+Ri9a8lsAdggCCLiD/CFVaEJJsue7GQQUz6amfUWOIT lRJdZfXwCoUrBGAPueLgHxPqHm0Qva8qLBCP1+eJy9Kif0fyiyAV6sJLhnF6VkIrbIVe+e3E4GByI +Ykr2yRo8SGm4k5WSeb+h6E16wrTVKkNjCM6q/SnNpuVdFFPojJbf3U2qtFyszgBc/VZbglodMLmU mff53vfVy1ZDbh0PFlB2gVsy8rqNH89R24D8iup/3VVltJvVoOBunuS/dC34NAYf2Y8WvzIDzZyfx viE0axamDU6OyXXWm4aqR0T6AfU4SHTxgsFctwM1Y=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH3v-0008jM-WD; Fri, 12 Jan 2024 12:55:08 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:10 +0000 Message-Id: <20240112125420.514425-19-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518431 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 45148C4706C for ; Fri, 12 Jan 2024 13:06:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH4r-0000qS-UG; Fri, 12 Jan 2024 07:56: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 1rOH4q-0000lk-8Z for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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 1rOH4o-00075I-A4 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:55:59 -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=JkX7WGFxHLJ8aWALorhF1bcRcASoyBoUM32C8OS0urY=; b=SMxQuEhoW0x2jrwwhW7PL4gFE1 kOLSrFbX4OfUeAHRsb3b3XpGYFbNr8Md5NLEmbD7z7RY6Mqj391aq4qmGKtNCQmfTXoG0KA5HtJwd awwpawexwVz74Gty+JuqJp6DkYtcN/HYcckucGQCEyFBRGxo7BOBNW7M/bI4Cri1gzSab4fPdCq8y 4BoNsEnDGJf/4kB1Z8LVvd/05SanFFCpqeY/89ic6nR4V+apeRAmUBUtAXizUnuFh3taaoXLqFX3/ 1EF/LzikYOAPuFE2IV9zFqWfdFYnqdgYtm/Mk3Dsfzg/gxrNdFukIlhfeP6SiUHPfG5HOkj1VvXHh cQQlQCe4KdtCHJ/smR04JBN+38AUNy2mtRLxPzobaqP5sPp+8j1GK6v0ENkIYkysHE6jTBDpTIBtn TpM6am24MBawXYSq9qW/bC+boOpe+dH8Vi8wWqxVVu3FMBQaKqfaGjYEAn/euTwzqIGus2Trk+5P1 YlTkc6aObc5fjm0F2BfDWQBFSEmRvHbwcCzT9YI3H3uI/eFpYd37bsUkf8vSA/4OLSw2Smpg11kJb jsDZaUA6tnsPy9fm7VtZcXLV0eTUY1caYyTFzh5OOYJjAQuXc34wnP2YQurcYKuGVxXgvueVdfxxe bdOykqrX4hz2xvHTGjQb58ulb6dMWFeTMhQjDxPjw=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH40-0008jM-6s; Fri, 12 Jan 2024 12:55:12 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:11 +0000 Message-Id: <20240112125420.514425-20-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 19/88] esp: 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 --- 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 Fri Jan 12 12:53: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: 13518401 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 CC928C4706C for ; Fri, 12 Jan 2024 13:03:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH4w-000187-An; Fri, 12 Jan 2024 07:56: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 1rOH4u-00012l-J2 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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 1rOH4s-0007BU-WE for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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=tJdK0jGFlBbCMpIBpAerVRNgezRRrjb4h7h9R1wNMF0=; b=bdBVud5GHsmWQNFsF3DPruJ0hw cryJzwW3MdWtiIFkXwQghc02pAeVpU4PPuzm9RSCfKe5FOBlbBQd1femb3woPifsCGodn5sg+7jnM deeeHjgNVfzy0XE44HcsRSZfcMmsI0c4IBs/gClPFxBF6e/OQHx+OMCQi/1aqsMnMUHmF/4H7vnXk LN00LDXqqulHMlyCGFhR32GRU8eddqi0L8h2EBmt75la4QWVLirHjz+aTUdEKcgIyAozf/BOGetBV a4rJ42qX0EL1AsS5suyANXD7qwskWavBImtJ+qeBx5BrRJtOuv2pzYdZOw3LZqR6L7wY7Nm2CFltP 2XRr6i31F1BVj++V0UnDew1ivsDWrydR8cEa5A8sntMj9pCYG+A/c7SBPu4WBYvw9FVvIBlS+ORHv yZesxNhG92qUl4TKB1caefS9chOpR8SDNRrKHTo2tmte5kg81CZLzGULDo1KVoJ6WBIwCAHOPOrlN eSn9XDJru8sCqTFkFL+rGdYKZRMpf8trhWeVpoQSiM7gJWqFGPnqYxblHC9XZ4dcTa4ljDbLeVarw i5PL9iN6VKYdOwhcJA/yBXOVmhxYfsfZPxoQfGyVuS71eyTunXczKFmUL20SsIhawUyGtgXDvvWvE U15C0u9MzZcSyc6ZPoPJO0iZjBnzbMVzRBWk1I4CA=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH44-0008jM-Ga; Fri, 12 Jan 2024 12:55:16 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:12 +0000 Message-Id: <20240112125420.514425-21-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518381 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 9AB34C4706C for ; Fri, 12 Jan 2024 12:56:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5B-0001Zh-PP; Fri, 12 Jan 2024 07:56:23 -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 1rOH52-0001O3-Ib for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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 1rOH4x-0007FS-6I for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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=2z0FKqMn6UPzV+I5UHN9RM5PK+3b5SwEo7FgjWvykkc=; b=xjQUuV6/jHNMOzeDUhhADqFO+D 9X5wf1gLr04ixkdgk7SD/iFV2FBS9Lje6/B/5A0ExKmsK4ZIzgJ60W1b3/cVLCjrjlTFP2D9tnybR RMzNs45Mpqw9Tw7cHP0lRdPLI6vsmzWGa35XElWdNevLt9bD9hKRB1QJfKi+wkWannzqVv71SJnJm 4BG66koevy+yyxRbb2J045JJZdOKBPA6vbuM41Jb/QoDX4U0ZsWOR9h3kvPiviwkeDboAE3NeAjU1 lFggiOi4E5JZmamTvmlR2D4KM1Vl2/Pyy2lpEVQVJsxXlH9PFj7DBLzjF6NcXZisOx+5R7vqWVqK6 PbtvUxv6RdntYh8Ty5UKxRVHvgv6stEn03DVJv8yClUY7IJtnCYbC+wOpgHNTgTN+XF9r5oGFPYHX gcoNNQ1u7iuv+zrN1fA+YZQvzEDR4gAg9px4zJXpnaPKvYkBDQ0hk16q4Snxf4uqqcFkpIrBuKQzJ yYK8y8/b11vI6V7jG/JIBkQ2qsQ12zKgyDNDTJ+vwAL5oU4eUmI434aioSN06H5qxCahlwW9jCR4W sRbtHvMg3ftODaqmg4cBJXNNPSND0QCN48ttKFrMqDcG07kZZsTXUntBhoQBETswA3F/79onOYfcs GbZsIDTibr55v0fkbPpw3TqCOXSI2kIxrtHdihaLQ=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH48-0008jM-Pe; Fri, 12 Jan 2024 12:55:20 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:13 +0000 Message-Id: <20240112125420.514425-22-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518388 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 E8622C4706C for ; Fri, 12 Jan 2024 12:58:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5R-00025K-DH; Fri, 12 Jan 2024 07:56: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 1rOH59-0001UF-BF for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56:19 -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 1rOH51-0007Iv-5j for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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=Qab9peJFZQHq4g0ah/0J+qGpM5fA/VyNtmbY/bhz/FQ=; b=TwuqYR9q5G6e+TdGXshy9h5lBB BMjlxefMNnUZObQuEEpRgVFZhdWysrlZMnjr19y/LfMyVvXBbu4vE0ugVrm5WHcWOcQQBk1bPoOhc 260t3hng9yEhpCzNM1wzWpOe043qtRlJf7UcUXKuNXw8n8hDnI6lUbeBXUbYElNy0qmWPMZo4Vzl9 gPx0PafasG1jDT/nWPWC+0Np+JCiugEbZyU+uOTsDWHHC/KslrTq3SeKF3NgOfcqxWfEIlryYgFGj upodAj7Qo4DuoWjAXNonvioxBJh6MQp9TLVHGHBwJ1FT1V7/kaNYIKH/FJlpatApQa7P//trnNxjy QecmtcrtjbHDc3AxoHCTYORJv48ykUakmcoKgK4xOBOI57tb/CrUCdbYa1J3Dxc18RjaJNHF/AKCL dS3+zxsqG/M2/3AHEummXG0PkBvev9RjLQvv7BkbgS6eDPgLN/JoMZ8EStegd+UKLAmjfSvg4N9iR 2MLjj7wrdwvNO6+9bl3H1DDShIfFQPfJlla9wgU7+Wj069zwztPFpZyj23Hd+bI1C+vxXC6CGB5lx q5YaQ497D9SRcE/AtdcgSBt5ylhmBgRI2bEu3jLxqLFFtlkx3auCcAkJkM9BcXq1uAYoE2//2hWIj uvX+I0nmgCZrhpOaY1oCGxpYXXppfSKSqorxmN7Vw=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4D-0008jM-3B; Fri, 12 Jan 2024 12:55:25 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:14 +0000 Message-Id: <20240112125420.514425-23-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518426 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 DAA9AC47422 for ; Fri, 12 Jan 2024 13:05:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5D-0001g9-Sb; Fri, 12 Jan 2024 07:56:23 -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 1rOH59-0001UK-CD for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56:19 -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 1rOH51-0007JF-Bi for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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=ro3dv/qpfIKLlKcfAVCTgpDRW7D8TqJ2daI3AjjceJA=; b=tl76huMN0FLu7QfMogYHWywmaL MhD6b/8ewiaqGZ2z6EqjFw1WCQQPa8g0gM5w+rzPrhwMqiYhMGRnOK9n37qMuyUyH0Ejxk8a4bKNB tMyVgt0wNsxmXSZuxYDsXHxNy8jtOc1RgUdjCGOb2USDHFDau2tA4vGRE4X5+1H68Egy5nTvLneF5 BeDRkacIxShn9OVhhou/ewCavx+C/i4RjFx9jAPAiT5KbRTSDWwmn9CyBEkHob6rSmrW8SYTXAQ+m kVqcwzM/gJIbVm3p4FwRrFSx3L2ntwGUnaH4zs1I6ndiB3QbjVMGQIeLwfFChc7KNxfHeRN/c8Fjc FZiujPUSPl314SScfxK4Q9z68p7/ppRwdQHDkXpvN8kHyVJa09oTGgsOzVSHqLtTIYG/7pvoDj2sL +CK7+N/8DZvMVM4eB2ug71qOCgnJBXwroxAVwvJUN1GhNeN7/YIm8k1SFFdsAWOn52gqzVhyAhFar 2V6Y8oLG+mZJlNbrOXCjcu9MgrYRYGAjfMRimXf6gDGqrETMfRHSfKBFfwaeB6bzNSSVWvt95wAOs vpnKKWZkNO5DPkCrMN5ZUEt0w1kwmXBtATYw8RVrFHH5+lj/cEEim1Vtrr473exFwkOWd25SttwYC GzdYWsfj1kYjVTNWy5dzczSWfIrNaSgprHFtqKW7U=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4H-0008jM-D1; Fri, 12 Jan 2024 12:55:25 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:15 +0000 Message-Id: <20240112125420.514425-24-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518461 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 9D707C4706C for ; Fri, 12 Jan 2024 13:16:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5P-00023N-JB; Fri, 12 Jan 2024 07:56: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 1rOH59-0001UH-BF for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56:19 -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 1rOH52-0007K2-9l for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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=jrNWwJPR310x2+wDGr3cs+8zpWtPvEByRAcrfFXS/EM=; b=g4ZnqS4AX7Y+zAk3BeZBrJ6pRI KbfB1VJLwe41UJSIO07CEitqtmokrsN1uhP4NhsX8Rl7nmt2V8UjpUCR/u9Ogx/w1fCqxsn8q9hjJ /rKJeBRn1VBciOmm4GNiEnyxRtXSF0Kd+ktjimLZhYMADTrujzjltDF8PCiv0inGZiHntYLia3k0c d58gHO6p3wpvV6sFGFsAgm83/+WV1eAJFJU+vYiwqvHKEBqxOCPD8h5PLDinpoEH510OBheP76mhm 7nz9/yZHnV5uZZ9oIxscA6CfI1SQfeOz0JiV8etjtr43kx8A8CmMyzPTnO4z2we5RiQqUtEtt7N2S frkXqwixB+6f1NObPkserhH48ilgGSfDOR8/JkC3RCerSFE9vwNimDB4Oe7fmBO1jZRRINxewCwSh noRMF++72p5WByrnb71+sARNFImSWTtybgj3TvZ7eOfYxwYvE6qpbK+bQVCmicpmNyVwGqJ+qzPXO 2kJ8EJUKw71YMPRQalFmEUHXA8ZjFtl30cOgk205d7k00y4PrvZJrHPKugr6KeLRszTLINaJfrdX+ XGTrJBwbWwZClpUqqt8a+IXEOL64X90P+wP/P7jNStBG00+AMP09lFsVyG4eQBcVYEzjzHm0fzU2A D5ojO1PgXWI+TJviITv1xHECzIcdA1YKKLRUiP6ts=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4H-0008jM-Mp; Fri, 12 Jan 2024 12:55:25 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:16 +0000 Message-Id: <20240112125420.514425-25-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518399 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 8C0FEC4725D for ; Fri, 12 Jan 2024 13:02:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5S-0002HV-Qb; Fri, 12 Jan 2024 07:56:38 -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 1rOH5B-0001gM-W8 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56:23 -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 1rOH55-0007L9-5L for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56:20 -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=57dIgtjCjsEbnwP2zK0STdYYihbV2C8Z1lAAbvWJyhQ=; b=g64uwjbi40elvQ5OO8uuX15JXz ZqErI5PxPcdMPrzasAU4mjwoRcAd98LnXPbLv7L97oa2xkiodGkSqtY+jJggLhnzvyIrxT3uR1PdZ h8f2Gwov+rOVOTN1/w+kwydm/f+BJcWXv0BQJleA/02H1A1YOuWAChjLtL8CbAmKHG/xvQe3AoV/B 8J/bBD+vcR0HQ6EesQyW7PQHlyaFzaMjxpymP6qW1IZGWvS+QcpEqpAsQ+dvplvfXPM3sVzzg2NFb roqi9qiCn0hfy2dnoPX45BupcKJawU387Idc8T3jCG4TQO/PEEOZ2wL3r5w2YTyE1zS+vVvnqSp98 uNJ3B2Pb1HX9pYfVOHb/RglbqhNmilsid646VFOexjYQS3IwqpbHu5ZiPksSEO2GvR0yn+Of6iIXG Wzyc2psFSVd2DiVWO+NTpbtnNPPu1EOEH09iz9zMlr1jP0LKEGeUn/Sguv5FwB+FOM1HaWze13JeU e8URD4iIu+6BRY1kVqLg2kqB6AryIm5asDx1iFdUk91v1fsXflUOQNBXItX9b5lwT7jYkQ+L7Xmin ea4yS1CKsH6BHWhxe0Q2gYnmxTxPsy05Atuwn9nQTUfxG04vPjfMI6UFp3m9xNEzhtwPc8pN5csUS O/LhFaBZlbx/3w5H4R6XLz3XEQvdGbg+iXJnPIX4I=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4I-0008jM-0O; Fri, 12 Jan 2024 12:55:30 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:17 +0000 Message-Id: <20240112125420.514425-26-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518425 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 797FBC4725D for ; Fri, 12 Jan 2024 13:05:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5T-0002RS-TP; Fri, 12 Jan 2024 07:56: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 1rOH5F-0001kA-Rz for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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 1rOH5C-0007MZ-Bp for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56:23 -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=noBEM1vgwgC3/a8GeQ1iSWp0MNpWGitlTAL7oRoptXo=; b=bwGurSf+FsNEBj9ywkbYaaozjs MT+rw8oh/5GylGhJDA2Wybvt5Y0QYYfSk19RPfDrXBdcHZqWSs3HssZ9fN2uyUlQGb1yLXtU8w4Qx a/j51E04Xjrdeq+EkttzoryF7VHUjBt/HMveXFkRQkJO7wgZ7bO/zbWV2rWpqov8HUvMkx7rt+QtH QrCgy5cTmGz32Hvz6ljCXylkL33BDGj95n1fgbn1AupTkhdnNAKS4GBXo5KoffyZYSPz0PNn/mA5s MFW3B19kiec4m1662vr0aosZXlBtkl1g/jB1u3sScXritNQZ0bh+zBcr0s9JeyQaokGu4L66ALTnu yEVDu9D3rf7xiucCpY8YMO0myXJu40M2Qd6FACu29zhQzofCqpg2uTsSWyHO0O1cuPuxbgkwet/jd WcnOUFSX1AHj9E/q7HplvNu25iw1B69downCjvD9MbSAL/NnI7wiqNNdIfu0i+6YW8GkApO0spdyK p2RNc+DDdCZj675YlcIefUwxR8t3aqAXK7qJhIuCViNIrAsXvH8o1UXS8k+Bqw6JSA9qofn+bOJ8u ZWrZ0C5eKsDrbDEzRa6O9EGPlYC1jELc66IkHIrrlSIgZvclgZiLsmd4+KxdQihWVClu4tgCaeHc7 5pbyGlnOmoKPejRUhncF96eo9oZqvni5lv861sDZM=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4M-0008jM-AH; Fri, 12 Jan 2024 12:55:34 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:18 +0000 Message-Id: <20240112125420.514425-27-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518386 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 D2ADDC4725D for ; Fri, 12 Jan 2024 12:57:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5U-0002YQ-IT; Fri, 12 Jan 2024 07:56: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 1rOH5L-0001zu-JT for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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 1rOH5E-0007N8-IG for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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=0Z/RmCqKEGcQUxlqoVzURtE6xvdTuZGHnEEF2GIpMuE=; b=J4a8wIgp83GW6lrnxSkDyClNcB 4Jku+AgCeaMHqoWCI+URBOR/8MzAfeUdeCye3i3gImFGlIdaUmUkKOo+6k8jTZbyT2PrZrX9Nuwzy qlL+cHjrPRn7B/+iboSFlqUqMqJAB9vMOktmBV4SgkhgrOEDCC2uhu1WOQ0qDsDOw70IraZtKvEeF hpiUh1r2RgBOt8/ItGGXyYPiIzjJnW8aEPgFBidovIWOKoPlJi6fmrz4MvT1hcDJMrstqdDd2/NGR s7E41XOSScY+WsWWrLRRhDGazFa3OexrN/Tu/vSpzvos+BlceovYd363/i+z1LP3RDKGpKhXHR8Pj oRZbVC+roXNmcdY3aZTF6TQNAkp3tCZxD468cJAM1UOozM4Fj10Un4FRJRTcwMH24Yr67kUVMpaWa N6OW3SNPlNNt42nbu9remL3JSvcgg8IjJRJH9TthQtBXq79j708OvgYS4HDeQSSkbiP+cvTijGwnb YwBwVYOomW+OVYu4Cq+/mANGpbKNN3TGypYJYy2DiHxKnjXksD1/9rdk+E1B1voshIU8QgZOmhCH7 leZc2cHn/UdogVCieUSJ5F+dgirplUGyyCjK8twNtvu2uBMXOn7aPN7ojYjr6Z9zEduvLy0xZT11i 04drDYL/dV40cF84oAixAeQVxJzwTsvPPCA3Ql6gs=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4Q-0008jM-Jv; Fri, 12 Jan 2024 12:55:38 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:19 +0000 Message-Id: <20240112125420.514425-28-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518384 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 B7B2DC47422 for ; Fri, 12 Jan 2024 12:56:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5W-0002gN-0P; Fri, 12 Jan 2024 07:56: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 1rOH5T-0002S7-Rw for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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 1rOH5I-0007S2-TZ for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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=vhGa8G/D4xOpLPY1j1zK4i3OsOVDrN1vRe9nfcMuvuk=; b=irMYkNFD1YCImcRzKqyziekCMS 6NAstoZ6Eyx7UixR/2AnbfjQD1f0K8EEwGN6SRWbuw1kPd51f/3cwXDiETR1FQQtdaoTF0PABqFCY tqvqkAaJ65FkjYjsjyhZgL5zNnX1P0veA9sWr5zAk/ignfPI3W9ZwAVZVGtut9etFSz4zj51tJg/g 3d/Hepp56TlAcI7nS6DYsgjSH4OIGpSKq2tZd8lCSXmZVK3WEnaU6U0EGXQrMHvz8cv/AB72syMHN cfj2crqP4ufwE0z+r6Bxbslnp05j+aFyOeK5KZtjVV1GIqV432FVv4JeECkAGC0NYF34DkAXYg6+D apvXd80uz9phEM6K+6P3T+DlnbZhCslQGB13OQ7oR+LxVnLZBAmUj/EA7b7sDCyoit8bRHJ95LEr8 Cxi/qep1r9bdOmv3UGJKbqZkH+Nl9RkDrB3lswyPC4h8UKNikyic13hoRJ4c4FeFDBbqK25A0KJgf J9QeJ+PGg2fEFgNTojY4oyct/sYo/XS2kuG/JdYL/qZmkYjjxjKZsUthIB8kYwuhgAT0dH3oNncNe 42nid4bjwyDTdI7bHp+9EzOE7q6lD0n0LCAeiVCINFUViqeiBy1QNfRA+k42hS4N/hbmsDgGIIdGd FPum+4kzBs9Y+JhbF937nldJ2UaH1HhMzgPCLZZt4=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4U-0008jM-Ry; Fri, 12 Jan 2024 12:55:42 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:20 +0000 Message-Id: <20240112125420.514425-29-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518392 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 59BDEC4725D for ; Fri, 12 Jan 2024 13:00:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5b-00032v-Ey; Fri, 12 Jan 2024 07:56: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 1rOH5W-0002hm-IG for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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 1rOH5N-0007St-8R for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56:41 -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=apWjp60OGDbXskhoqhQ7L2Unt4rYkRzNC6E6Qr8eL5I=; b=V+NoSuqZEl325GMRL82bXJoKU6 0+kPuGmtystglOOR/wkSroDzp6al4f3in+gJJxt1t20UL1K+LAUqxtBA5u+DdHIENhHwaiD5B7c1C vP95DKs/xxj4Wb08KkCUNI1sfzcuvKt6S/ig2Ry1ZY+CrWPdKVO1gpiVWVy2q65d8XNbkFNDC7tCG IUiYGAb93dn0/LFYmSsan7cHEgtepdAXnWHMg1OFOM2f1ModOVTa+yc7Ij/gEHRMfzi4wyayrNzdJ 3ZglXFcQA9hPzzAhyLg4u75A9/lH8PLSBZ9JpMplZnz0so1SE1t+7PK/LWtz4R5NPQScu/4HMiH/y xFIE71sUWeVaZWbHgryIS2mspSik0XUU3FdkcE3PiuH7egefAUdeS9hEodhD9lUTOniNyYZ0sha0D VLCfTvUZJIRhnOV5n4NX82EOsYrgdDjTMRMDbpN8INaraJDq/0PoX8hsH7laJ2bGaHJP0sm/L9vta Kj9WncVvyhyPebymzr6C9oLnlhpUs28ngfgGS69VWrGPtjlAeCY89G5A6hYyOxGXXPz1Hy1heRe7H rhXzsDtgibe/xXpTWTgdakUv6G7zMRI9gOXqNPVvyaMfTwkG47kDcMCQRHNgDyOh2voJ8BIGAw49T 0DZzM1w7fo3Qag0U+FEVwMpgT2R3YZK9a+Wc35f5o=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4Z-0008jM-71; Fri, 12 Jan 2024 12:55:47 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:21 +0000 Message-Id: <20240112125420.514425-30-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518403 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 82ADAC4725D for ; Fri, 12 Jan 2024 13:03:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5Z-0002tt-29; Fri, 12 Jan 2024 07:56: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 1rOH5W-0002hk-Ge for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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 1rOH5N-0007Sx-Q7 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56:41 -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=bfcsiNmXe9IZUms/qdM/I60bFpo0q1GAd6mI+r/EQcM=; b=ORsMb+kAEoDqN7hOxa3U0uNEK9 gtH4U1liJexngw8/n+DcyZbAkjm2EhVl74ZlpXsRH3JxlJ1sEIBJ7kmD/h+A/MAwB0yujDEE0rYY9 3hn8lkJ/PuJi91xqq2/1QSgACExtwDo753B5zuZta8Y8vmCPcz0sO6dSqF9Tgz+tNfC+h3ovzZhZA mBIWgf9XquqbmfUxqkh+53ZgiIKvKdJ5hkuSzwksXOOgUcNd+YNQzIpSxymWCq4dpFkr7ZSjYOHux yvFNkfvFMJBh1k7DjRiCFcDzB1XeUqY6YLPWMc4MOlPQaax3mapiqx0s+QWMvL+53YhqTOuG/g0M+ JsNvT+tzIdCQ7+mqGQ0aZyJ6/fDd9CIKxWjLXQ60Ua7M+6Tlxs9sWP9OH8ioGaXvcQDY8ChkJ+Nas YAJdIqckfx3RxDX3I2F5+dDt1+dMPOuwNWg+V6BkQDrEOC1N9B0pyRVEubUOY4XuxGm0zFZBvsMI7 yJJm+CR2JmFYmpjL15jnoNQFtu2JL3Kpizi+zG2/xPQ2BTpOSNU+zgOZoL/iKcnFlQZhgPwLNqoFR h3dbd0lu15mQ/jCt9S+XjxDdhAa43nypXe5s5FltKtsVprHfsjJqKogwjhtRlochdxsvkES7A89Es bjWYNdyKEbDKBuKYY3z5EvLPn+d5jiLFA4jivRYnM=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4d-0008jM-Gu; Fri, 12 Jan 2024 12:55:47 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:22 +0000 Message-Id: <20240112125420.514425-31-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518413 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 635D8C4706C for ; Fri, 12 Jan 2024 13:05:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5j-0003mW-6u; Fri, 12 Jan 2024 07:56:55 -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 1rOH5g-0003WO-VJ for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56:52 -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 1rOH5e-0007UP-QB for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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=NzEKvboNhYJQisWsPCRE6C2WgN0Zmo1yRngmU4ZE8u0=; b=oFeUKSFSFkxaJZGOSNnA8LBsip kXM0OyptPzN4RLx28N61h+7pc+BlVnybWXoYqcarUPCcq5wd2XOTWjZZBkwHOrmydUK8L27hMPTiU fVyWknUUk1lfVHaSxL6haZYaIsP9OJT/AnjdawVdrGx3Ykxft1tVPQ8GaNVPGxVX+occRo8lec6WF ueThLLcM/f19PzKymjEgppSRDpui9QaemwHeMs22uMc5nYIb/qdiDnRQm+ZyXdR4dilUrmkhP+sAp PdTP0lgQmk4IWhfw0TEbU6BrQoaQU0zLdjEOIRp8cY2GKAnwW4q9+N5ARrHHCJscNEusLvoUQktP2 PGwj5+wYgBhbnXMoUJI2PYGMfSv+kddNyxg8pVlz7/8gecA6Zi6EoCETPaPWXcTW2cWZNYuOaimSP NsOKAI7Z9LSaVzDBR86Orppf/+8pqivjZUd9hRFUXbiKAtYG5qCJg8bodAh0VMjF1ndVEaEiHCa05 oKUsDI8ywboicPYT6NKHi6QOqyEV7cbP8he6nCIDC6mvxB8B3Tq1/xAgTHEkHeEymhfG/tNKzmDwa DoiTgAMNsgpfhCpvsukw11j6sVuZKplYcvgUvWWSeXggDWjcVJTXqxHu+7uTHuDT5R1xKGU2etW7w mTh2apcxeCb8o7tPWgsvv0xQo0U2ueImJM//luBZQ=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4d-0008jM-U7; Fri, 12 Jan 2024 12:55:52 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:23 +0000 Message-Id: <20240112125420.514425-32-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518430 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 1E939C4725D for ; Fri, 12 Jan 2024 13:05:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5j-0003sU-VJ; Fri, 12 Jan 2024 07:56: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 1rOH5i-0003fL-3e for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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 1rOH5e-0007Vt-Vf for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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=xY+rT1LSmlYCTSyqa1KnuN21DtTR1jjOD5PBtIyFuc4=; b=iEUSXcE+yZ6mpQwzfAkHhFxB9+ LlM0FUf2eRJ5GZJHakcyY1/vBRo1xAr/qXUpCSSnPMSetlHi1Rx+FQF/+1ypwuZiaHASm+Ly1yYjV c/aY5trIxFjs6DiArlGWOVejdu+PZj4eq1Ss8ah4wSEzgBJ9SlsbjJ81MhegwhvPFA1hbs5GaZUwZ wjfFVy3R9Agx2dkWH7hPyBX4yO0hcGdWpuWbzkwz5ffCXLshN2anquRyx+zxOibRVRvKBwpy5pUOU 0Y7Ut3iLHLzCchATih4RpWNL7KN35beYlR1AYMfBSRsCxlhinNJawQ3+0ykVZGnKhgqC137H8lEP5 u2vtG0FLunXz8yAYiGnWvGST5PyWm/Z9lH4HD0XXA59UcJj82W1ouI0HYFUDpJhqdd8cIuWAEk7ya h/76bh7YPLjKdZk+WyWvncElF04zj2eZqYtz2j4hvI8tj018GJbHkz1D9mraEc0rHJICeFdYMQmil c/1qu5WaFV5MuohsNyDr1lfAadsf2HXeDx6PARGTgGUldRUNcXaVZvSNIVMelG9RJcPcFLIwma3H2 TV0Zbt7lqE7JaOB5s/TeUHcQxPfwuUH2V8s2niixf6gFd/ai8gbE9yNajfoPLZG9nz0gv2FM6hi+5 +mXc3l+r1YH4HKzG8jkk7zu9xpEL3BvW6S4yI/AbY=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4i-0008jM-7m; Fri, 12 Jan 2024 12:55:56 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:24 +0000 Message-Id: <20240112125420.514425-33-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518395 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 765E4C4706C for ; Fri, 12 Jan 2024 13:01:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5k-0003uQ-8L; Fri, 12 Jan 2024 07:56: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 1rOH5i-0003hc-G8 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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 1rOH5f-0007Wc-Iq for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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=Z3QBOz3FMqE2H09aqXMvaGnxq8QGkgS6Z1kIP/kLno8=; b=DyKp4bdD5eP5hDxmW4UxFP5MkZ +wWyFIeGJ0cWbLVpmVcj88w2GLqC6NGiyI+TmxeL+RTX9uz3Ki8YQUQCqcRBIqjBUTic22pIjKeu+ haKgVkBA7MuwdjKHpp5GSBZ8DiUDwcbbmhsd1j3eJorhiJusHFsHajfiQ5Weli7BOCJ7/hvqF1Qqi eRmeIv92WMa0TETuw7Yw2Oz7ahcSaxW140oL2IkA3BQ+AS7moPsehiX25pyLw0i9oHmlYHurI9m+o k/bLkXDh3yVEHn+vvSU+KhSqYpKH+/HTXcyCUEqdVRCId6/O5/I/xiQ0nVhfxrV8jeNlIRPSVlUjI QfDk8imdi+RMFC1QeDXqihBMqF5dmSn6kcpSIeY9swVxlwJqmnR1emYyIyL84OM04oIqWg6NFsMbU LnoqU7ylFD6MN2XAVKf7/AnSBWDcW0CbQYGxPvZE6jpTV8PcS1O5TX0VS5m6Kc5WFNO0cmXStzFJ9 zm9H8fKtgLbqmegMFn0G9RjLdothLpwe4cB7x5T4/6yekg+BdREK7E67gnbUfGaRL7IOkhDFZg5Kv mLWP73q/vLF85Bx8fNHKf2xPsozw2eRHiJmMVoIeOJW5rAzpkrnUkZXXJk6otB8wFovtUfxrafQON DLLbgH3yXsViR5z89ZuNrUb6YVnN3hO68j6wQ9dhM=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4m-0008jM-H8; Fri, 12 Jan 2024 12:55:56 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:25 +0000 Message-Id: <20240112125420.514425-34-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518402 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 2B1ACC47422 for ; Fri, 12 Jan 2024 13:03:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5h-0003dO-TI; Fri, 12 Jan 2024 07:56: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 1rOH5g-0003T9-F4 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56:52 -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 1rOH5e-0007aY-Od for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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=q/AdNcGn3vCK1TaCYWE81JK3tzPwF4guPaAP74tcRoE=; b=BWZDlSFcnVyJVpCrWHOOCQ9Dui kIECxxaJPH24cd6Ocioo3agZ0V9OdNgVzg2juzEKLHF/LTNazO1NjqAK5Ats75mDvzXWo5Rcjwn4y 6Xm3TgRLjBByyO9PRuE5E/dudyMpBNG5e7YlJqw268H+YDTZ2YRUaqms11gfuReLc+l0GKVoXTFxG EtQsMEROR/EATSEfcIvpJA6aIk0WPZUvV1hO/R6zOgPD7MN0K3IfJLTtJO3SczvYs9Zpe7UkR0wYA aPYodgJrUjQTn5UcDX0XDVBuOgDYssGoIVoa3k8HaqXmAOCVL9zSdbxbNAbO7MTG9FZBwR7n23hyH 9WulcaKJiJf8Uqda0bInUm1JKXpxmXtOQ2IaGXkZfvJi7iSM/l2ffrYx8m3zTC8sOMLPz0bQbiVwS RdG+PnpdlCzlcZRTV/m6EKEQrVov9n2swS7+8UresQDbb+8OXbeJBnA7viJL13sra8iCcZ28Qehv+ gqO9fXS+FMxpxrZuKEs+cc9YGZbgmteKSTfRS+huOEHIhkZepjJJJ4yBp5CQw9phBHg/hU6cS209M HX+rLrbAIrUOA676m4s3dsTITO3yz4ZOsllNHTaKDk1qmX7PvhEbKlLLQZPSKIo6qWeA38LVJ9HnC Ujdbv7CR8jBnK5DHTDvQXSDr8hgg7c7sfuw37+18E=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4m-0008jM-UV; Fri, 12 Jan 2024 12:56:01 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:26 +0000 Message-Id: <20240112125420.514425-35-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518393 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 610DCC4706C for ; Fri, 12 Jan 2024 13:00:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5k-0003zW-Tq; Fri, 12 Jan 2024 07:56: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 1rOH5i-0003fY-5n for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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 1rOH5f-0007b4-G7 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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=02eQijiD/ARIh0JCjiUEsftdph0x5Z1TzAPssMWncPA=; b=r/yZxy0KEbupB5tQaC0CGWX7lv oY/VR5PaAmhqYr+xuL4EDbbkreTCFVWpcst71sTZtwJgZixRp+UBBZYfJ+/lPhcHw87leSOuCuyy2 AL6KE8Kn5+GI5Q1PW2OwI7GFxuha6Cle7arHkwFQvWeTz3g/bxWEcklKlPEUaPpTlQLSXajtAMss5 NpsExjbc/I2hyi1AzolKIM6lCA15+nxhPMOUBqq2NZQEv+DZHK02xqgyk2SOQCVHSAFpY9P6rVHKg st/jjMoRMlFIcOO0L11X9dufN/hX8BDASQtuJxdrt8naWeXimGYVjeV3snfafBGOASwL9wV/hpyJw QarwkWnlzZosL8F4w/UmF66vpc6jguze7BUaUapsnudOA2LDNvVGDtYFHe4B7/VMlwNle/o9YFwP+ M9+wChMyWi8BEbJ7T1BO5bpQNQp7Hbgr6OScDzBmY3JPAt1R/0Yj79WpK0ItnIxTJKwjtBwPtVEBY VTNm1h0iP7NiLbMpea+58cHHB/6mlosJkYNp9WLYPoxAoFNvB9FSBrfhEq3M5EpxY+K1v+SfmGVyz 4udLFCeGdUur1k61V9vps0Ethn24wtuZ59oZXOsLVWq/rvcpGdw60BcvCvE6VFaOtVMv7A2udj94d 70iEFNuHo/L2LDGpzyNZlTT1mZKlzgwJaM80kcyo0=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4r-0008jM-B5; Fri, 12 Jan 2024 12:56:01 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:27 +0000 Message-Id: <20240112125420.514425-36-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518417 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 13CD2C4725D for ; Fri, 12 Jan 2024 13:05:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5m-00045s-02; Fri, 12 Jan 2024 07:56: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 1rOH5j-0003pc-F8 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56:55 -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 1rOH5g-0007e5-HB for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56:55 -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=pWhbAo1KuskGcxzVSqb6P67HV9y1ZJu+Eye91KL2wmE=; b=TGGXW08pKV6gqh4xRDvxJQ+pKm Z9X/123MvNe/iuBGhg2cwMaQUNDT8GKTA8ZpnI1/jUi4SOBrSqu49hRsZeInpXvzG/S/wcp27Xdsr WJGACrGCfOOj8zszZLYT4kY7ahTlBgtrH2ghYv3beT6APkaMFYTSM+xpJVEkCjxfgd/llRenZrK+F Hy/WGr1t3tXAkjXray7ONBDTtrUxGcpIrTGqO611PpZ0ZsZMxQlb46316Xke4axuZliGVbdz1ABj8 ixiV1iu+YSyE+R0TVDzhA5Uy7Q2o2ANg7GtsRT99MNf2ddLhZN1ZrwgmVqep6sg1YuMdMQFEg9q1m moepfnwxbYZZqrMP2bzZmeQ67pLycmpRNkF6Z4yXWk9T/ODTcfB/4jf7zTAMcN3HeFiVbC86RECk5 bomXsmubyrPPbYOJ4+jtuIPQ1UzSnH94AfVN/NfQ/ou16hq2Lq0BDkeJknQbenHSwLXVqnaIIq+OO IRsWU5BYDnWtNner3uioh0SqyAX5hmCWQ+4Bx7RoVa+OYubHgLNgbgDdqIRKxBBl1SdKgmQfXJgX7 OqwUXEo7P9STNcXmnKMJLsftXG3HiNqVxwUqAykb8+v+Qw2yJBVh+F/nWIznuIs972JNgbAu0eMAP tSSphru5vDjwHYWBhtk2kxfodY0KVrJCrtgNgn0aw=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4s-0008jM-2O; Fri, 12 Jan 2024 12:56:06 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:28 +0000 Message-Id: <20240112125420.514425-37-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53:29 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: 13518408 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 3638CC4706C for ; Fri, 12 Jan 2024 13:03:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5p-0004MD-CD; Fri, 12 Jan 2024 07:57: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 1rOH5m-00048m-D1 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56:58 -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 1rOH5k-0007kR-H3 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:56: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=yOo+aEy0k2OX72yvt4axQlFJAgTlc3T4leGrB2paOPQ=; b=mN2iFGGPOqSAerGDuQUNRVwvno P0W7TMbVGcM11Hm20S/YlfLyjlWEpCSx0sMkZ/Y0S0YgMWhAYZkNSXecfz63Wz7AlSPVBo9p291sW LWL8DLhrPNE8FwnI7D/9MBd6G9LXZZx6v7w7TdjU3hYVVonmkkHnARK7KRnuK4/pk7Xwr46bOpHys g7yjyp/wuPDBU0z09M3FcncjVlquc3Snm8aEDUnBE01ZpQINUA3nbBn6ullSVuQvmmoGuN8cCStbf mlrUjO/4erR/Yt52BEwt/nvRYxA8RwPklgWISeMG23VaTkZWYZhSCHVOMFSTgw6CSG3HvDZJqZ3QN 6nEpQyqazXDfOcJ4p3XUjhCBKTM47DH+j+efjMDTcTc1eXHFfb7bvELU0nNzcH3GfBxDxoRcCZc2Y o3u7nU6RCNLW+19vpiOZvcM89wM0neCOvW4o/yUAI8yb7CsLr7ZFBZCT7WOs4K9UwGiMDp9QEAsuV wUip3u8ycH41mJr9ggXO7xzmVDMrWegyyrN/7df8VU79O/nK+DelWpsj5O/J00/OrdkQuSVLBva/l aLba7S14Y/AAdE47gr91bpyNZxrBq0B9HuOldiM8QNBjUEBlMpZngLvBonYd/Crecdk4dvbLwrVQ1 mG+18WbVAiRzlDgHP7KjFbxSVG7oKSYr7YNkXcfVU=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH4w-0008jM-Dd; Fri, 12 Jan 2024 12:56:10 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:29 +0000 Message-Id: <20240112125420.514425-38-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 Reviewed-by: Philippe Mathieu-Daudé --- 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 Fri Jan 12 12:53: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: 13518394 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 770C8C47422 for ; Fri, 12 Jan 2024 13:00:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH5v-0004ef-Cn; Fri, 12 Jan 2024 07:57: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 1rOH5r-0004RD-K3 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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 1rOH5o-0007nH-PU for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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=9pl16iNldZ9IF0y564sSpZydusQK9ud+WmO8TtyxMWE=; b=qXadWR3PB43BNg4FyaWASBvlGB j+966r/CoMkdM9FudgsqJ1xKfc41KNYJzH7bu4nc8uvX4npfq6zVBusyN/QpoGG64UcwWAlKMEj3r rimbwT9T1JerKJFQhJPa+eHTO8nkd4BKbV8b4MnEgv8XhVPoI9/7oYpIKrVw956HKca5BJqVSTkzB YqlI+aKlemjJCOTpB4Vh+mMZ6KLHe4YtjBcep+GKiX/sEJF9m4iafJZOYAxmAUlRkx9jdXJWCkogL c9Ws+la+nu6fi6MltwJ9ifyaml3XBqUGBMufRP9VHYvUi08d41/ptA7VDnDj/uV4pU9dMku5zZQzU uGv8fqNUuVCSFbGdlZH/Eg9uYJkGzvat4blT+yTnfGdenty+kmezdVER+jQi9DKNlQPtL/E0wiSE/ wF/em2U9d14UCUi/QJcTKVY0HsGEocDg+pwcKB8BV4duhKbIPBT0CATOWBEfsRzLbg8PGj3uUxnZm R4QMsoIe9Upr2l3RzYrEADAev8u9VumVsyU4mT6Qgt4o59Ya8Rg5xMYM/Mok4+Ngsp5Spdf7OQWtN N52uganedhWa32c3zR921c8WcJTStwZxx62fpkp92ETSdJ6N3SzbMuj4JsvQ54oPYMUYt2NFNAgtv 29lDNJx9LlChHxRhcsyNRIPQq+JX9uqFeZgRQh90s=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH50-0008jM-LW; Fri, 12 Jan 2024 12:56:14 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:30 +0000 Message-Id: <20240112125420.514425-39-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518415 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 911B4C47422 for ; Fri, 12 Jan 2024 13:05:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH62-00051L-A8; Fri, 12 Jan 2024 07:57: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 1rOH5x-0004oX-D0 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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 1rOH5p-0007oB-HA for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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=4I3vrCruvicw8FrV1AtQV3HKf1cbfLoGPnBOCRBxK8I=; b=Qkszo023LJyvLeUUdX4mTfqLD7 R6xojjx9zNEKsv2XqJ4Ck/qbRmBHIIWu8SqOJrXGHb0kLVtSIVKRW4xt/cAqm0j4CkALllcd8z3Zv pGBgdR9NI4ERJ2BAdoHNDlPpAM80kfz83rO7odSGRyQGglGGVIBTX4VmVUGzDY5sgYnWjDQgZW5D8 L062B0mTXEwN+RcBegOoquueaex2c5vfmgIulTYp7+oh/SoFu9TBJ6Z3gprXvMGWj51dO67iAeAi1 tntqfOGggCuK6Y1QFUYlWQ7XILZbvp+cd5P+ByG9HXx/xkUfvhndnGEtjfuD5qcEuRc3R+0ua0eR+ GJHl7V5FH9qdhMrzQk4kY59pKxNkvXO5VJ9oWm9oUMRBTDXDEMezk8KfuzyzuiGR4V8xI6vKIiso+ yb/LZLYSmkbfvwGEvD3N2yZFvMJGjCLmMNpulkYmxS3HAwZqjMa+nMLQm6bHz7XZg0K9SiwdnL8e1 qsxBjCLuNE+3w+946S9zeD8P35q9k7atRfyQGQIkfmdwfAi6ySapkgIteJB6xVsRb/HmDGzP4ljnG P6dI5GKL1aWT/1mwWJNQ1ziffKTWqfdD5ILo0YWpSAwS3CM6d+99GIME3o/i1HkmTStFAG0Xbgvht WvG4a09tjta6r9WeYkHXAoCAQtsTjqdqHq8utomQQ=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH54-0008jM-V9; Fri, 12 Jan 2024 12:56:15 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:31 +0000 Message-Id: <20240112125420.514425-40-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518391 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 04935C4706C for ; Fri, 12 Jan 2024 13:00:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH65-0005Ak-Ar; Fri, 12 Jan 2024 07:57: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 1rOH5z-0004t2-Hf for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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 1rOH5s-0007sT-NH for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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=62bCXuS7Ab7j+3JsZ13NQqjjmERHQQn64Giv3KrN3Ik=; b=ls6c6+Hnbebv0AMVKIadIFswG7 kbOO7h6qp3rqa7mtAWuedn10jzM6lgr95fTMAj/X7Ft5fUcws1FUA02wfPEQXj53dFCLB7CJ94nvz MvneAT7F1gUVQG1eKkzhIfmeFMEIBsCxajWGCRVjxlWcg4vrnxiWD4TphzPOK/Dpdh6ifzPD4W0Np xfe/ktQvfJ7ncDyzxk+3f8cINbpwK0huDYZRMJKcCEgORTsh5Pl0VNfbCVXs6LwOYXW3wXZ1gYgHw 7E8yv8TU1tk9tnCFLaZI6Qcn3kE5Pqv4QtJyN4GSvE5XRcN2FEMYXpPfKZB236BEial0el08eftDD cbanaiOiSNDwJV1i9g9JaSEVFInhB+2r/Y9Mdj2MnOro1jnuhvODL16gpwoF8X2tcjZeu5sl6PQ1j irl7e5BeLbHaFOoRtiEPd0rGJIRyyY5QkjfRC2TSP4BGWdqJQA/Z0nWTo2n5ONbLC9iT7a6+22BbO 9wujuk1B+Y8Wqwl1FFjzytiGJ0XYcyJ2Jo22d/7EdW1DPzqXb9PhyJTexwBwna8LdAXj6WWNCb3LR TcQWSTuBPP2zAQ1vivoN1UTQA085S4GJ6nVfeE3cKMJL5fmf/UEdVlMPSoi54JsQUqjnowOF7OoXV 1ko08nGRUld08+o/beWVMP6ZUz1dEjKAKQ1a0ng+c=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH55-0008jM-C1; Fri, 12 Jan 2024 12:56:15 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:32 +0000 Message-Id: <20240112125420.514425-41-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518435 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 D9EFDC4706C for ; Fri, 12 Jan 2024 13:06:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH68-0005BY-53; Fri, 12 Jan 2024 07:57: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 1rOH5z-0004rt-Bp for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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 1rOH5t-0007tc-Ie for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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=6HWAoI4FhyTXVqyr5pu3vcbWtES6sLbkmpCqYzLTP4M=; b=Upvd9lrjnsIcAWlPUhkGbu6MsT PXwqoWkoqoC8mQcP2nne1juVNtzHQU7d2eXfumRGdblwunryQMvqZ/aNro8pWoGQBqCiO+8mQBIRz 3kTpnjjg8TdsGQ95V0uvDWAgsxCeLyVrA//ls5SzuQW3T4MxVD8MgrygkfNqAVC/2YWn5sBMcm99g 3ReGl/uOjFhkokhluuB1yEjQYDvGmrMG3T0zHFQnNHRpDvDYuwL1q8HWGKIsQaRlc+xUqTym8JWJh 5keTCnNXDpe8b4lg+K6at3FIj/NXfGgDygsFOCqbZ5RIdNR3SyaufyAc1+KeuzT6p5CO+aP7iJVdQ 0n+2m5bmp89UaME6ImR2CciOtMl2HHVmFJnKJFa+JxzcGJsuN6Iooad8LAe4LxhTDlMuKVMglfW3D 0znfNLkIMAKM23Hy+NWWrx2qvcduA+H/r/f/lTTMXbHETcf3WtvYpOnFyPT0vHpO/I9qBUkkj8vck 5dFGPRzhHEMYt6B2Rn+TTrW5NN0DrBB72ZrVzE271mieZU2QN1tOetokH9CyovT9m6RFMU7eOMH3x g+qI/fzx/kn3Iwi0EdfIxVuIZ/FBvxvr/WasZYQRH3Rq13nz+Pee9SJbsC6PJTtG7lwxJzAYi/p78 6mDSwAavFnzCT4ZU03EptL2Xls0fYIB9KHgDj5ms8=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH55-0008jM-PE; Fri, 12 Jan 2024 12:56:19 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:33 +0000 Message-Id: <20240112125420.514425-42-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518411 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 7E640C4706C for ; Fri, 12 Jan 2024 13:05:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH62-00050p-70; Fri, 12 Jan 2024 07:57: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 1rOH5z-0004t3-Hv for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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 1rOH5u-0007u4-67 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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=lSzkhQ+BjPap4au27j9l5drApsMIxeCabu+p4z0lkcI=; b=GHpe8xhr2jAYGIT1zjwRplKTXU glotikqxWmi0lw+zho/gAcuMsO9hdhMtsq080XdhlLw1DNIBMhXea1LSs1/tXeBG2uG1xx/95oNgp KJ7XN3QubrfotXeIrGO0bBzYPRUf8PlBIFT9tc61VHvMtUHsPd0Tn2q//aZGWlNHl6QGBvWpHGBsY Pirzjxr08XTw2mJsFguyQ5jwKfGgIevk306kW+pep9ViA8g4QqjGCtpPg+AdzVLB/B/wA7byRhqib 92T495grefjt9LaAUrFu+zC9/JhZ9utCVyFpRqE+yXDGk+BKOI337TwB2yYDos1i+qywQHHzBP/Ef TczVW83omiZIvE2lJBAqV6LrAj9LEAOdoZ365l9L/tPNsIRmor/uvwnn2Yl63JK3pyh6xDeIrIWGc RV2S1CdNdcWmWrSVu4jdUfi1diSR8oAQkQgYVpwcHi4Hz7hhQ4tSLfVy25PVT3fxAq4EcsNiLusFE bDrHFxFs4mQGzvmWR8HkpF/BLsv57MZ8XIlnnYiNHyDyFT033r0/bbrAeX4FtxUBJ4d/iZiBwJZmn K2W1jo7W2fZ0aQpfCxEY5WLH77rgHrKcQLAaanSY019l0vgdSEZAom7AoWKjAWiy4s1GnGGEbPwOa Avhio2f9PWNubQlZDhSftCot0+WjumzdnyF8PWs40=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5A-0008jM-2j; Fri, 12 Jan 2024 12:56:20 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:34 +0000 Message-Id: <20240112125420.514425-43-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518429 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 71D77C4725D for ; Fri, 12 Jan 2024 13:05:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH68-0005E2-K5; Fri, 12 Jan 2024 07:57: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 1rOH61-0004wM-Fi for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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 1rOH5x-0007vD-E9 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57:12 -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=dWCao+pH3JlS1wOi5u68nSmhJ+bHGx6WXb1iP8+2Sdc=; b=TsYuvBUaI7exEj7/dcQLlxhFds 1JhYCWWUZiGdwPq9MvCfv1Sa/PPtyH3XE5JTJcWJJZzp6qkoZ1TB80d/hQ/Zur+EjIQnlqfOEcfku 3E1HDhWaHMm6htDWExEuH3HB72kyOzgGrKa5sGcK1giZUTy5yT4rGCGc+R66YSKY+1T5oOyDz3gY4 P6zDQCOhFu57R2iMeOHtVSxA7jTmAfRMC2ViuyeYfA1oYFQ0++YD9o+2R5RM5U2JSs/OaE0uH6e6n 9eLsPgPO35McRVeePBREXRVQMu/uhtO0QPl/QCKDFDHOtLT/gG7s3XhzPw0pdh+k1fPnb0yZvQHzM j3Z4g7ZOzRNdhV3ZgziLLC0N5oL+Mv1MWP3DuY/zlpnzgqcSfK6qXD5bSViowy339sgUohGAzeNbs EmOI5sfV31VV/Jh8RQaZfR+ZSlmXoydbpzxD7LW+rjo9k7gpV+quEw6LlaAuSgjrYtVGlkkdITUcZ jZY0+aLhIycE4GBuWLgBl+tBMXwdRgHwN6amFzJwdYNCw1vkhoiqJ9yy5L+PKetkVxUHbIQbgShz6 LGrRztD1SzhMVsYh/HxqfjJpxg71ryZwZ6oa2qx+SJcNvQVAuags83Ze1OL7S7oNLEAG2IaeAfUIN zUL6EGQ7Eu1x23o5lAXawD3XeH0Jtsptkp5FG7Duk=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5A-0008jM-G1; Fri, 12 Jan 2024 12:56:24 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:35 +0000 Message-Id: <20240112125420.514425-44-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518441 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 9935BC4706C for ; Fri, 12 Jan 2024 13:07:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH6N-0005tu-4N; Fri, 12 Jan 2024 07:57: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 1rOH6C-0005FG-Ed for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57:24 -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 1rOH6A-0007zb-UW for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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=Do91i1z/vdEnPYun5SdZNLBnRTuoV6Reo+oomgiC/Oc=; b=CJvAKNcMOwiDK/i0z97v3E9hR8 hveYyZE1M6Obk/4c8XZQcBkSH7u1cSvOF7EoM5j3raV4VMNulkPVhHKhE+3Ar4D1odlYgopdtSPCx PyLyod0pRGJTsEyegt/nYtCoBgrLUeOxb+DpoM4s7XL9Hkenor0DPH9rG1D/S9HinN/j6+aFCSTuT XDAxMEMiiBO5/L3R78KDiwTTmKguhEB5XSA4G43oh/ehVkETAPHwuJgstIFbInqywRx/vjj65oL7L U39NVnKZAzGDxOnWU5B+AvmS4JuYhAtVo825eRfa9yZTEjbIb560orxFjuqwIMlqFqsYQY8pPF9R+ JkWUomvBsAhM8V4m8vzFQGVUkCMdAYTEOekthOp1SBQ1SCRPYX2embEk6znyWWXDA35/nP8rukk9R WrMGqHb3aqQ1zh0XlEhRuxRvUtCEby/39zz9/EPleKWlr9sDHiZjbhLFmZxISQr1b7rthdDyhT3j9 hLbVt2uY0Q0tY+GwfEJ0XEzeY4mCMZGBwirnywtGGjuCxYpH++4QXm5ZbCx3IIPTJEnir/C595l14 ok/wLIAl/negydQfKOaY7uVt/rZ+G44OO+kjS2KVjRJQsXOmlTSpbmBgMxk5dqNQ06+6HpqXh0flE qV/HYuRxt4pN//UF3nz5V9AjwA4km29KJt3frHl5s=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5E-0008jM-PX; Fri, 12 Jan 2024 12:56:28 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:36 +0000 Message-Id: <20240112125420.514425-45-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518398 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 D0627C4706C for ; Fri, 12 Jan 2024 13:02:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH6J-0005W7-2F; Fri, 12 Jan 2024 07:57: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 1rOH6D-0005K9-8Q for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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 1rOH6A-0007zl-Ve for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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=XjvKNvvNYVcbakH7I/R4iwae7f6AGT69FXsk4797g3Q=; b=yLvU3lh5AUU60lolyzD5W7D8U2 IgZKzq/8LVKtZ6FEm1d5NvSqiX1v+G7/eG4mo/A8Np1B5meNiYZmLpmumbCm5NgLXFC5ugRdJWBqj M3ZOMgoTcUFFekd+dPc9zHTjSi3mE1Wa5ZnIu/H0eV4SXpbewZJJlrIEs0tm5Q4DlJx2PdEpyUAu8 rRdwl4Cz4UHdieZPldSTL7O6j3CWpcGh7RCZwGVm309pT7Ln1MyoSRdslQCCTqpoVRwYYxL3tcNNx D3rrYBWGN5Ga9LZjKctP9cVtwFtvze3bGmEZeD30XqxHNXrpKRv+bLDnvDYhXWRpf2geqpcWbbOLU m/MTUBsYG7oKnI9ouZV46s1T3VdWnm5VRoAf3gkadPrJnnnuGTLlFhfS2Z0zwcj0lZJ7V3HSf4Qd+ Re6og5h20DF9eXv2Dd5wQqOYkt8cbXXSZkxkkje0P2ckGqIBCt0pNCCm2La3TZdBGOksFM9Hx1669 SAHin7p0j5Psu1OFNYvXakvPnHgZyMXJfXc1Nxgx0EtzjasRaRu+MWeVK9xD5NI2emflPSqEFhh+K 7pS65fr7+bh34sic2w8ZthUs3J54wTYtx8lDocTziOG/eMaJqiwWaYG1Bw2/9IV4dZI9calpMnqIO cGipOLO1HRZXP7J+GvrAVTpd4Bmw1S8JiP9BnP0ks=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5I-0008jM-W0; Fri, 12 Jan 2024 12:56:31 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:37 +0000 Message-Id: <20240112125420.514425-46-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518396 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 C6B8DC47422 for ; Fri, 12 Jan 2024 13:01:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH6M-0005tW-VX; Fri, 12 Jan 2024 07:57: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 1rOH6D-0005MK-Sm for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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 1rOH6B-00081C-1K for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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=2giIfY8yPqy5lAkB/Z0OCqmxwdcZs/C6aYH/9//6JF8=; b=JX4kz/GMfEoGixp9f61rzicn/u PvuPG1r5yuXksC9tH1mL/HJU028DLRNA/kVuV8qdtSkswF3SI+pt/SYgwUFQ/7TcJNi9Xy9MVaGeo TfKopLnfExTjR3axT0k10r/juNcqDMJOksDD14BLEmF3JC0fGA86GtfoiyqPWhUVKq9IgOpw44yO/ ojg42wBKOMOWwA5V3p0B0SH3yKO0WR8uplMuhO6Tr12h1vwvKs9C8gfyOzyAOwXZTY8QATI9qUbie Zet5cRVqlOgYDx3bk0iPmjwF68VsSo771YonNRg+A/nTOQ0l11BNFc5+RfcU/qkXZf1/HWs4rRTxX 0ko8sr2PXVUchXJ9MseT8AvRlNyxV1F56ImiO2AoExy2bRwoT//mwfP33RvIzSA0Dwaw5EMrcViXb 7pQatIcHwKrkVLUukZXy8V0u7Z1gJT8BraE8avPAwiB+5AnrdbWMA1Rp0obyfe1Ywu+zDaWFjw1Ci jZdfv576+T5pij5+MJxOpA21JpexbFhMX3uokDXzR+XdWv9AehpRkdkpIwf/IWXWWUaIu2sjjynID L3pDTI60MOitDkrv+SNej+f64gR3747NpnObopqm5xsMq9lCtVZFxtRaISg2VaPPC9SW2QDozkQmQ 7ANmx+ngyVwDY6MRH7GBg53Qj0XVZN8fy1OyprqBs=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5L-0008jM-Le; Fri, 12 Jan 2024 12:56:35 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:38 +0000 Message-Id: <20240112125420.514425-47-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518404 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 1474DC47422 for ; Fri, 12 Jan 2024 13:03:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH6L-0005jL-UX; Fri, 12 Jan 2024 07:57: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 1rOH6F-0005R4-7b for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57:28 -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 1rOH6D-00082k-1m for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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=wstJLKvNAgXe9YaUVx6tYio/b/aUMEsB3UumkYyXfjQ=; b=yEIaaMJ7b4x1H2088JeQMvZXGp UYIzqYcq934qBSpd+3uJdvS3cw1hjxRtHEriWXAv5cfb/0NduxcA1RvdQpUJkC1/Qc0fYmRQsWN8S w8fmcGMLMyWIhJd3+ZaI5OrH9AgT2qtPaYzHl6QFcMLRer4PSLFmeItb91BUt6B2Z8nTfybpseEtF aswyoPkWgONxSvoUXRPDU1c3km3hXzTtZe9Ay/pvfPwi2AvH7b0p0/ULfT+gd6upDVcBLutz0Zpfq NFLkw2jDpGHoaX/OQHEA0wj8hVfI3ERFQ6U+nKHE11exLIHDLacSxt9jYZHBUOO/r+P20a0RBVCcz vZHCtLdpTDTsIEaga5kGQBeFtfszzJJ1X3mjgSAhX2ZrPzkzA0OKG4yuxbbcR3cEz8vO5dP93PsCU 4Msyk2F8O67akn01PPpSXZaEN3Erfs70u/ddE3gMzgNa7mwxcuqH1UdB1cYW8XGcqHHblzOkjHwjb yjDeR5nGC3YPZCVMh/yMFPGArMJS+YuUVCBVzpE5m7VRWkWzK17FMYkTManWvi3qAYbuR4sIXwlFr SZM7egZ7z+ssLcFyNmYpt+LMb80UOk+qbi6z3lfeh0N4ZP1Up2P1w0S/kecoLemGje8S/zv9Jf6N7 3Mlyzc68wKtkMxsFvJr6yQNi8vgBxKBI6jhWZG5gQ=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5P-0008jM-No; Fri, 12 Jan 2024 12:56:39 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:39 +0000 Message-Id: <20240112125420.514425-48-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518470 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 57EB6C4725D for ; Fri, 12 Jan 2024 13:19:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH6P-00068Q-KK; Fri, 12 Jan 2024 07:57: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 1rOH6L-0005e1-Bq for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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 1rOH6I-00085L-NV for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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=c77aZQsYe7pho4cvIx5xwNADDh2K4Z7Pz/sry5fvQ+U=; b=A2XS3h9suXTtMX6R3CXVwhf6QZ eaYH01UbNH2fe8kStg9gEn08DKshm6ZnUGIfq8tOO7VjBmTGgrh1UacKrM9NGUmTrZdOWc4SbKvov 4E61q/XY8JBzTESsORj9/k5TiNPqxaXYhpVOerOCD209JOc1Rczqr2d+/3cFcYy0+ApTwagKV+Zox NwxAMbv3VngZe3j06J674WFHMpp0ZdPEHN33B16yi5YPuwFjO2mNtcqdqNz4EzacC3zlS47uHzYvW uW/s9n3h4V9FMMRJO3TtgJjX8P+q4qZg7yBKDPltskWHk3XNjMgAR1F4wxdlydYTwcc6cktKmveSK xPsd0M/RQ4UkCVhdZ5UTfj2/8YjRescc/mhiEV0pyGeYeiyYn9qbm2BJkXpSyxyusNufo6A88E4gP uYgoXP1Q9KBWfVWeQj7//c2Ztc5fF+LzIhGCBueR5Emq26NF5tmXmcunEJOW9jhnRRYjrQrUxAasD eq8uQVvdtvZFHEWePeK7AUFDGVid3/BFoleoTPsERKbaiWqTawib9+1CVYiAhO3Yx9WJMhve18Wc6 155dPh8PtMktpktLUdxveGIruar7QgS+41S5j3ARwb6mBleLDbdyvnE/mGg62JDvB2t3+/iB3ulqG sepKF78t8+K3m8UAWwiJi7amzXY8MUQKIpcAa+AE8=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5U-0008jM-1f; Fri, 12 Jan 2024 12:56:44 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:40 +0000 Message-Id: <20240112125420.514425-49-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518434 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 8DBBBC47422 for ; Fri, 12 Jan 2024 13:06:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH6N-0005vN-Bp; Fri, 12 Jan 2024 07:57: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 1rOH6L-0005e9-Bh for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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 1rOH6I-00085B-Mv for qemu-devel@nongnu.org; Fri, 12 Jan 2024 07:57: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=HZHwF1e1qETj/0627t2GqtCtKN96y497BGAjGZGqqNA=; b=sJvPTiqgAU+7+vPt+8PhLIhZgh ZeO/QYcsmCyG8TgOl7ttTfMmBLayfDN7II75DJ3LPzvBTZyWb9pFlbZ9VIgg/UdZnGnZQNE1hS4WO T9zfbkd5paIYuabwjf6havBRGyzjxcJmjFDTqw64mHjC2RMzbn9cBCbEBT6OSGAdjJFB0r5V5BcB0 JHTQFzGV2y19047atdDmta4ENUcqqC+5zVRH42IH2a7EivCrYbunHyoEYEoVykxH7bZySyk4xOtFa m6MFjfWeZvKcALlJZBSoIiYYnX1tfDjoyRygffeF6qRaRnZJRhJ4VHYHCYRhP/Wt8iupS0MaUzI5L 1go6CJ3RrxA4b1wOz/hygTMWBBkLMLVMy431bJsY6pB7HHOowHJKsmfQ0aH6hPWuG6CEDik4WLI2U TcUdIQsLs2EtNkcWN2IJ5z/S1D/RVM6yCb6IWwJKl6G7A9/uf+harWSf7qNbKCZAdHfKOOgLQDSS/ axj9vs8Se8BuSz9QIjSoBKaRGDNoFMDXXr/YuDyiHTjiU8JZbebH5pNOD6LzIuApMNzqyaRAQfEwl AvidDQElLhBRmlB7Ya5aALjNMjND4jHMIQ/97aN59+ZfYk+72CBktVl+Zb2jE7xUVqLiVoQ5slztR EjTMKHW7BQMjJjnsHXgppcHi/onWWxNGE46v7mHME=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5Y-0008jM-BP; Fri, 12 Jan 2024 12:56:44 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:41 +0000 Message-Id: <20240112125420.514425-50-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518410 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 57CDCC4706C for ; Fri, 12 Jan 2024 13:03:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBD-0004cb-6v; Fri, 12 Jan 2024 08:02: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 1rOH9v-00031T-9s for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:01:17 -0500 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rOH9t-0001bX-Rr for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:01: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=/UjXNQaHvk0LV04fdzty+43sk89fo6UkY63C3wA0Aos=; b=Jt4ZBooXB9TBCWPDX5iOPuEMKZ vllPsbRFO7vlCJtVa4T7sUHqXQd89uJUnRNCrrETl6giPwQ6z6ldXZ1VUfZ9wNzK+wS/T9bl7zxg1 fBvgdjb6bz+9EDEPTDzdUHe9Nmf4BSKAKG1iPxQJ2EyoscRpJj0Vl0VLN1SuWYspV/eM/g/JQ9HlW bIf7q4mg7NdDhUkh8yP1RmImBRRNBZ12MeUkfYW/pAnTSzFQRLODPNNFB7dxOaDFT1G021zRxpVmc PWwMZjr8D03w5jXNhKK7JSriR+tKt1JeTj9u0W6pdHYKiTgBosGhgTO0oKZjsHqyq3d7vMqj6Ixlg 9ECVHu7Si6fNugK0QTcELEjB0mt3WLForP0zF3AvAVF8kdmaFYsmXQuwSBoKYQLzzyM7lGj4H1N8J K+WSveDnHa2BtUYLMZgEUIiKe97tu2l2Fyw+GD7DodoWEFQ57Sb0Skp65t1wrIilUif546uml8Etw aFXO06YI7NJZvG9UUDV0gHszGPJVSsPKqG+6b+jm4uFz4M8Tj5HU3WeNMkvtPDiDRydjLaQBt1p0c 6z/xBn2i85FzlVbE+3rmVeJNyuAcW/8LynfzBpej1fgOyl3jC5acjgTw1/Rx7n8/Mky7h2AMPPAhl AdeqJpRi0nhcAQLFdIOy8jDIHnIo8M4bl85AagrWA=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5Y-0008jM-Ry; Fri, 12 Jan 2024 12:56:48 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:42 +0000 Message-Id: <20240112125420.514425-51-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518416 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 2D85FC47DA2 for ; Fri, 12 Jan 2024 13:05:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBM-0005kM-Dc; Fri, 12 Jan 2024 08:02:44 -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 1rOHB9-0004UX-3g for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:02: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 1rOHB7-000243-D9 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:02: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=85Pac9PQZZ68RZ3WymSxF8x6LDnKuCXTtOKl/cSo8ZQ=; b=l4noEbJpAMEZhhn+8j21C+yh6B i1UEvzBW9IzQRaTFig6m27FXJ0TzhN5GcSJ0aKAHVig0T0lpbj/rn3ZFMwmF/vb+XpQPU9VayfJMS USxs2d6hDzGsAUggD6iCFY7FVBH/XuFp55hs4kpNgjfckS5Klz8qcnf8SmBQG70rTRUPj94nXXyMS oy8y4TIIBjVKqebIhIhtrdxMha8bOv8Z39i9RlsicSaRoX6iuUr3A0PSYlTE6Z09qtaq/Ty3OgF1l jHFBOUpmSWIY6o5EV6YZ+NdZrvgjokCteUmN6WJPc0NIbSAY+xHxYKMyX7GoZRhobuAs9klrgYwl2 Om/iH5NklUUVpDFQQmQXZZEYDVjdwIBluCgpZYOUDUqoZQiSQPuU6VdG0oiB438IBYjRLc8E2kQCo 3U3Brb4Ohlg1xBVLCLB0+ZWErkKZYiFS//bYpvf9DZl7o82b+5CNbdcABLgFcH97HpXFhPUgT1c07 Cr2GObTUnHBQhISVEazH6Ul36PaLdoKamefAQIfVow7DocVpOnYEbMh5jQZH6XDE5SM7lmyp0RbW0 yfZkz3Q7MFatmuWRr1loExqxOLyDDZls97RuxmJUFqbJ3EtCPcuOeCdWjXfGL6b4wqZresEJwVzqp buZI8WUBE42J5dyubF/KXxmxqBDKBl72hGu3u7/p8=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5d-0008jM-5H; Fri, 12 Jan 2024 12:56:49 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:43 +0000 Message-Id: <20240112125420.514425-52-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518453 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 66F9FC47422 for ; Fri, 12 Jan 2024 13:11:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHDg-000560-Fq; Fri, 12 Jan 2024 08:05: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 1rOHD0-0004Ud-Rj for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:04: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 1rOHCy-00039b-MU for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:04: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=metDBkUl6dTkUgNCecnTDKJZsWyDSk6gx8iev0W1uCQ=; b=X/WXD1dIpBq8I4F2lg79t7rK3A jPucSr27fhhmyUj9T/pTuYno8jGCh1W4yzQoSxGPYRbg8EsJ4R84eRckKdE9bjuEBRDEIEleYptEu KPjpx12e9JGanthTLw1+GvZsu6pKXP+yzkiOiktJl2A417SDWf/UX/QTpa3az7/tdrszhErPoSgHa fxAGDu837XOdw1Gt3uWwtUpxkO/MhnntxXcUIDk5YYXO+RNbP/0JwKGESR6bQVXJTIzQyLljOfn2L agDd/TFE/MLdoIXcWYdtjhHFNnBjRw9pVa/MqnDwUunoOnIa4lr0ZD2kDV2SSJfZA+ocCn2AGwig6 VbYLQSkevFpkUmWpiyDF/z7tpYZQcFpXqjOXx/OaMivrUbqKMgdR2h/v35UC1qLyp3/AXIf92g0h4 HdNjqtraq0CbI+Ak7k37Ng7J9E8fO28QaztzTh01UG3+WC422XtsFRGlKw7YSUs+Prb7uKi1RRuAf W5wwj2BEQoTzwqTi8jzuAtDmALKivayo0mDVLycJxFxDTwSERtAp+5G53dRpsdYZpH8rCiXGQxq3j fP8q2wwC6LRSaqhu3qK9QAh3zYPEzwHPsikJ65FEJKpC7M3FCy6BgFoFmLTyPFjhPaV3OGC63NdPl M645jSAAs4LHg3SOdxKoyD5qylcfL8k6Oha+awHL0=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5d-0008jM-IZ; Fri, 12 Jan 2024 12:56:53 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:44 +0000 Message-Id: <20240112125420.514425-53-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518406 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 00669C4706C for ; Fri, 12 Jan 2024 13:03:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBw-0001Xm-Vn; Fri, 12 Jan 2024 08:03:22 -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 1rOHBl-0001AL-Um for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:03: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 1rOHBj-0002Mi-PZ for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08: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=zOa5eaUY2Xcg6LheQdT49DvzHXEXfxC3Fr2RtZvTfNc=; b=Ac0ZSsnQcqTVVadlb/8GF4zPKT fXU/qQObiBy+TwzP7KHxBpb1KPzvkqRWM6zDjfSV4Wp5TB+bqZZFQNG/sJJCOYJ2EXJhWdnBgW8nC wbkJ4497jrM/iLXW1RSM9fhj5XVTD994ABuNzhMy8zZcx8fTWQDvj2zzM8X2TAfA2lm8BQuPoQEpu 3J77jSZ+jBb1DFCURUI9NBKLKV7DXzOlpBEqiI3sq8Mm1yzq31TlV09lW2yw8gz3aIV26cye7Y1K4 Kv+Hu/bAEMhi4nege1kaWJ7Vo2IsvDV6C7thnzgPIFijIcRvEJ2TzSp5ZwabRL32X/xbvYIE+XT6l LhYGSrL2mRHJc+g39Fpp8MkKVzsmyHBg4+guDHLVT53DYjOfMYSSKR9Tihh7NdV3c8jStIR/3Hq7u 8szlbZohldWZZvfU4oW/dcJb+sfe6LThxHLoclHwFl9i9EhR/n3K2xpYQcj/dG1dOMmz4JKjCi+DZ 7PI38StoBE8sUQiR4kN6qGT/2w/uMzdxE5HT0j51HxrBNr6Urt2Xqg5d7fOGRzxUZTqBFj/0B3csU eEBwzqERMHQLN/DuW+Xc8NYtqf1pPOi6WLKkGGq5vSyERj77JEFRI3x3FriIoN5P7vxa7iUjoLiFZ yzHMeG9+5Fq3Bu0fS8YA3saqEc+93SMjpKoeDfOhg=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5h-0008jM-SM; Fri, 12 Jan 2024 12:56:54 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:45 +0000 Message-Id: <20240112125420.514425-54-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518424 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 81F38C4706C for ; Fri, 12 Jan 2024 13:05:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH9X-0002FO-Hp; Fri, 12 Jan 2024 08:00:52 -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 1rOH9R-0001ya-AJ for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08: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 1rOH9N-0001Gj-9H for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:00: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=8xI8vflAYA1yRD6nzOMwUkXrNNBU14YuiIIZilCh/3E=; b=lCypg7INoZMSHcEd7uuNemxwoT 6LpWivSzldzTjCDHPpp7QDyF/bVCiHpwlQ7vc/7wTTFej1p84Rr3Mp4x564bJJs6fSF5Rq5nFmB6F DPHLAzcAEcdKjXdcTR4HrayqQ+vzO9DUhFVbCDmHmmTKTZok6e3sN8zkclSh/e0GALnKNWXANRgCM um8VIOSGbijuzE6QLMBPCFc9sEhtz0TixTw+WfAcOiTYXvBLX1JncuDU2RX/V2W8FeNLWBgKDcH8k L5nyi5b1oEbiMQ6Fa8/0YHABVjd77X0bahEyKfp9qg9S1PwfBXJi6k64sZOu4SGWs6eEHQp3ktPnq 4wFJtv4B8hHk4YCWR4qxzaktGdWOdFqIFi4qPw7Pxg1K63yDXrttld+9wmULIVQjN+diR8Q/GpNaw 7zB9aNLVpducY4VjYvKYxOZ26gXuhK8+Wrc5ncpmgW+dW2YFbAg72QIZDRE6vLHFMNYF0UrKkuwCC mzoj6wTO/hgUvOz1Zn+g0p7/m3HLU83ndQVpXwabK6ug3PF/r77qqS8TbtP6Xi6nDhSpRzEwDvzV+ eNuZR/yHsLom1TtBWQ66dJ2k/oo8owTHNTz7Qv8w1f+GylBSNPSsoqNPuPhgCzl5AXkzuYqlPisTH XF75JBewCSbsR8vZJYrq1j2gFYPyTHv5BMCWi4Wls=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5i-0008jM-CU; Fri, 12 Jan 2024 12:56:58 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:46 +0000 Message-Id: <20240112125420.514425-55-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518446 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 BFD4AC4725D for ; Fri, 12 Jan 2024 13:08:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBI-00057t-1M; Fri, 12 Jan 2024 08:02: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 1rOHAV-0003qr-DA for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:01: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 1rOHAS-0001rN-Tl for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:01: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=DlE4PqcoYESx4Jr5i+wEaitpO9yTgimL2P1SrYBPLPg=; b=eL0yhHJrxvdWYaRu530utTzkY5 +HuKUezhhOcITDkGZzU/9OfbGEuTbyE3+Sm2tiuHJL7pAnewOS4sCB3Dqb4TD4lNISfEX8Gyd8qXO Amj680GQE7BtN2f08IvfZKOmFbJvjuvvn44a0ZV/1XsO4hBPWI+9Zola4BrkxkE5mFqeqToNszV1o 4a7bZi6Tfzrp1mIv4wMqqQfRwr12oWOT78VeOQxkqu2M6Dh3aLXpxnjebqlQqINayTb0mfYNiRupx MLs+pQ2jXQHESQo+LvIuNVhfLDqUMP2vrMBc/a1tQwmJFly5Swy/ZXA+YRQYSCaQOp0h6Ckc4gj+g qxWx+hmfEDgnjVNyVcaowYy6jCwIloo22qoVrl49DhO1t7+2thSvauqLYvtt+Hkj9TP/rY8Bm+5Zp +pdsGFYyp2zxnhaO6rRVj24ADOKktk3PurDbBhoYleZPyGWOlgWx4m/jzwDkK3pNjnnhB17NlgzTe JJTm7gQqo23TygUNSmtCWFpimM6oiJ7E/pH8P7aRIY9ZlLQpDmOcabJYTI9eYdSGwz3Zn3/MFoiKn VJ1JuE+x2kqjzsoZrwXNT+Yyx9IiP65+g1dKUNp8avnJ4fWuHEGuucoEDoCeta8n6Xm9olgiQ6m2l CGMe4H2gr/N4U/VpSX2ISyyAoyNtWG1yfR2qJ01G4=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5m-0008jM-ME; Fri, 12 Jan 2024 12:56:58 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:47 +0000 Message-Id: <20240112125420.514425-56-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518457 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 5751AC4706C for ; Fri, 12 Jan 2024 13:13:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH9V-00024P-27; Fri, 12 Jan 2024 08:00: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 1rOH8z-0001nc-FL for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:00: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 1rOH8u-00014o-Bq for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:00: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=dW0o6rcEzdYw074HWBK4feyS72H/1RkJMFCgnmq/DHo=; b=w4CPE7aNz8qjUJ0HCdxKxR3AgI FiOo//5wp2Ts7CHl/wupcKzGWMQdPYp7pWZB9JkMmC8rhnx3BzH/ljZMpIwupizCovIWh14p1l6mu BIwv1xeuJKGYNl9uhusMdjt7Dov5l2h+7OVok2B3kM3oDlFb9ZfgmEgaVJTMKe6J9MlBVEKaFw5sx FxOVT/1HOjR0FUE7oc/omcuLybI6sNlCCxe/BC16JudfeBNZDbOZNKn+r6csYsKSnYT2xo7WMsvHV Z7kuRJVLaaHnbU+OAC7q4p6w2noJ6uSHNP2xlZBR0CNaiNGmVaiEzHFm2LPts0QgS/MZFXAk+3/5Y rW1F7GGrKNUvbohSCDMGz6XcgHi7TA5KuWL6XEDLWpTRyfiYYUkfeMZKyX8rhZFbhbTvk6D4BvLAh Ud4N1Gx8SVszc4hHTwFwyBaj37EnZPb4F9E9oJ4a5RN1fXqOeUinxlVW1Wi+414ADQPERG7qEzTFq i/UVpLFUFIBrc3OaF4E/CwhkK5bfxSxDEQ7+cFQVyt3j6sMpJnqjhW+KgElmaLPGC/TJKjmrFZyZj gCPhcFhlzNzXf/Wow0TWoGwPpQC+BbbyF+C6g2/EqmHn82FA+if/lRJXk3s2U8RwtZGHi+as9q6rn kFi3AMMZv1671GrH5zqdwgpFSCguVsLBQ5Dq+nkHM=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5m-0008jM-W8; Fri, 12 Jan 2024 12:57:03 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:48 +0000 Message-Id: <20240112125420.514425-57-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518397 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 06D81C4725D for ; Fri, 12 Jan 2024 13:01:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH9g-0002fr-LI; Fri, 12 Jan 2024 08: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 1rOH9H-0001vv-Cq for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:00: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 1rOH9D-0001Fp-NB for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:00: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=RX8suPy1gNm2SICly4WBODoxn3FIMb8MK+d3UzOnUYI=; b=PuytSSWIJfG1SyRLGuUJdbLE0y 1/9kQopKpqngcDyHX8lwjmWpLoPnX4pA4I2fhDvt5dceLe4JC5MSUeXB/z0GmcnnIFvsd3TCXeJTd KVykgBiZ6YkWjmJvzhmoCowhZ07wSrfc204jin4f3CTpGWbCfR/6Xr0mDH81b/bN+hocUl57AZwxo wWEn4kSIpya6Z3khJAjzcQaYSr7U2BCopm7TK77jqocwn89Qk1BXfnRMF3MOPRS9s93XS/MOs+P37 jzby190mgMG4Wa84gsqSIHZ+E9EPZbpjdS6LYtlDc47wfE3o1yEcVTNwEXcuwWi3Kn3v0xmFir69F eBJeHwcrR+H6UJeXckXIxNTqlDU2bEBFc4f64LzX2X8KzQ9/aKlLWP7AFlN+VsAD6gjn0QcD7bV+S N1NO4hrMXINZqwciOzlzf909lpJcEJqqSmF/+4gSzfjDt9ES4hVz/ruANSybFd5CPJj+lAJrWe9c6 VQ9p1W+9u41pLBvraD3TUJ/VFsg0TgjAqLGpKWxcULvnJwWiXcA7z2zcbWdIxYUAGFYwWULnuxuWS 9YfJ3QgYAgF08C1bLH0XWsoPpaOVxSm8ty/U5lPpTF995M1fJabep35fK2N9YhaEBUpru3pa2N0U3 RTI5r1N4NOgp8myEgXg1/g0DkfCud6c4A0cV42+h8=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5r-0008jM-9R; Fri, 12 Jan 2024 12:57:07 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:49 +0000 Message-Id: <20240112125420.514425-58-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518432 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 58713C4725D for ; Fri, 12 Jan 2024 13:06:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHC5-0002A7-Lt; Fri, 12 Jan 2024 08: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 1rOHBx-0001eH-3o for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:03: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 1rOHBs-0002OS-Sj for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:03: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=ZO5PmPAUOowGailjrSg7vG1qJlLEPqgqkC2eSQUBz3s=; b=RseBXJjRprC6QN1XmYXUsU4m6M D0xqswkjCxkEIkK554mnMqDyhSTR2jOpfz9OHSTP7aRXOmoBRdIuUiwsJhtrM/rj+Y4KRwsdX5lU1 x9gmeMCI+1njY4g5iVdZ4vPLwWdTL7eeKnMvsnkHOqDtCEq6ymW1kppY9fZEMmj8j+aKdTmr8Lx8n QxqmDTqZLd7PodwtTdDaW2gDSWaWuL+hsve2qSzwlFggxFaymmYMU2936UrolLefsIhw2OSkQgsDT aIyfLhr62EneyFw/UISvXd9D15PV9tqzFWQy6wmDLN1F28QQ7DWf1gfqbLgbXmMwm1+gR/4kqETed irrIUW0ZeK1GPMk+uzDQEmiKDHprcCCW9mTbZINt+WD44Agp+v477jEGde5doetiyGOe0rIgbPoHQ +BrSHhyfGosNGKONkNzMYdTUzWjaD8C+mYXR4DVsrC0ZWH1BFOjftKLRe8tbM1KHGOxRt4l9RqLr8 wPplaVVIPPnJRmuVz9QxnRpqMxFXFCWyXCd/GwAdy9s3NoTB/arRXrDK3/Sg9WFXBVo/CSfSrljp3 KNo0Z+oumWGiT9ZMKyLfRQGeCyCPO0Knu4TOSECs+vsxauvINNyi64ez7mr/z8qMDkiDkVXeAWB/U +x5/J6pg2aRCE+JvkaSoxQifJtNeiAHpORNimsHdA=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH5v-0008jM-Pu; Fri, 12 Jan 2024 12:57:11 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:50 +0000 Message-Id: <20240112125420.514425-59-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518412 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 91FD1C4706C for ; Fri, 12 Jan 2024 13:05:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBU-0006nb-Q1; Fri, 12 Jan 2024 08:02: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 1rOHBN-00061K-IN for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:02:45 -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 1rOHBL-00027H-LI for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:02: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=YaFxIth4U9eE5pdikW1aXAmuWvCgiaPW5YzRJYFSYPk=; b=lMTeBHTkXtEMoe12dq9XcAEwZ9 1W2yHNuecGRWusMXEJAdiyR1FPYEuMbOZmkumxetO51+fZZxt6i8ISWGuOwBR7prq62QPJ/6T3FuC CyRbVn4yGaI6FwsebYnrk8b/Z6MF90qO+9qdTX6LysHYNImMVE8CkxWzRblUroT5rY8d6dMvRaVai HFe0DziJmZKbMAxgJhoRYTDWR1xcuXyE1eeyid6UZ80efeb6SCU61SVNCKwiyqY4lovUlnDSAAJO5 EFj4kxyd2XrxgCyxPkuvtFZdtSG3esgIsY0yKszcCfAYFXII48bq2Pu8JmCK+fOJ4AWSfkO+/4E+u +LiiodoHcqKKjOQaRQSVcwuQ6Bt/OCQmc6BuTg4fyMkkRj0toQevwAuP3DOgIYGYaL5V+mrI1d+T7 Ikn69BK4i+5bIF+m+X0kgmejhWdtwb1v2VDn8wuKG08BirXPU28Sp9eOsUAOQevH4YHu660fWzNt4 gm1jeRx5PQS+bffA4Yp8XVJCYg6zWoH0jrP8terWRaeZqZPeT01GgJFlRB9I47pY/hWrZC+E0psqJ /+9dea7bMwd+j1N9WQepBbFwhoUcg+S3Ie6zFHB/BxIgfMaM/YFUUpIES0pXrLQriba4FXpfie2mt 9qQvtUvUJmsVx8Fw7w0nVOjlGN6mNcEs3UCasj2R4=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH60-0008jM-6e; Fri, 12 Jan 2024 12:57:14 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:51 +0000 Message-Id: <20240112125420.514425-60-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518438 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 AC72CC4706C for ; Fri, 12 Jan 2024 13:06:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHDn-00064h-Ig; Fri, 12 Jan 2024 08:05: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 1rOHDC-0004ZG-UA for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:04: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 1rOHD5-0003A4-Ei for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:04: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=e5P4kUId6IlggOfevBgblAkFTfABYMw7RWbRatrL8t8=; b=pnGBRTjPYv5HRnmiBSOqZy3eB8 px2deWlPssO5TG9YqQQ2TwcYELmNEgHrjbHF+9Z3RxdfM8OnGKKsAgr+adwOaw3TNqAvM6xZs7L6f 9Dys+i4uJWDjU6KVjPlQO0kqBLt7SRijGkf8qoCfeMzaToxGcBlLbxUmxhGOx5TUXMaCBcrai/gf7 u6qMy66+o3CyVgtzGnZCeyaw5nZQLuCvfJKWkFJ5k5zvVVcVNzsxmvQXsQyW3VNVivG3lUr2PK4K0 D1nghVycAWT8tPFh/wunkI1KYEr3hbLKhF159LJG89Fu4sFhqkZfLiFP7xMFHNr3pyvyQ1NsYlw9Q GVOPM55oPGLRpLl/xqikFYgyokjt2w8B8LnexCZNRo7AKvCGnoxd9Vl1CjhApy5MY4Ny/NUevlHBo DxaMY6A8EhnNpvaq8u+d6Jr+TlYF549BIvuQaJk5FOoqDK8staowD/hhHH40kMBcZDccHVAX56q93 JVFLiZilS3b5z2BZYsmTePZUPuleHXUEzt4Kxk6P0QtpxxgHhVs67j4jryNsteK5eDYLIoOywEz90 pjyE9onb+VYZmiw1kfp7m7WKTzXvbwKKVeiBm+OQpxH5EMcmd5FVBLrKEkIt6ky8/SXQkvZPjffm9 ee7PWVO7LzUKj1dljpShBwswOsRfWezy5sK5e4LRU=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH62-0008jM-La; Fri, 12 Jan 2024 12:57:14 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:52 +0000 Message-Id: <20240112125420.514425-61-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518460 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 BC8C1C4706C for ; Fri, 12 Jan 2024 13:14:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHCP-0003GI-8C; Fri, 12 Jan 2024 08: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 1rOHC4-00029p-KA for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:03:29 -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 1rOHC2-0002YP-Jq for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:03:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NgTNrJzKu4Dc9Z+RRe6FhnpzkC+mlxVnSkgKXnGTgG0=; b=05YNDNTWfF0MSzNcxHD7u9K258 pn2rPSXKG/FWbFbZlU+blJwv/BNia64N43EgS20F8/iHVwY8VjTqeQblp78GGpe47d851ZFEAsGKg 6m+kX8kDcxlayylq2rSUFaiOx5nfJet5uFinDRlPw+VVDMetcIdXD0eNerwsevpvzZEbDeHkCrzP2 EFKH2SDtSRh8M3vB7eZZTOqZWKtKhlx4AEG8hvTC0U5ZfG9GIWYr1vB5aNOqm8wXrJyJ5/jlDJHQ9 UAQGVLDtsuBegse8zfZ1Qwvvlzkam90pv98LXGyyD/UmP4RcH4sIj8HpwtpgJ51e60KT6RGgI5xCp sbQH54wydAeFbQYHJOZypigZhl6Q6DqS7h1mdwUyrSkX5j4XBaZBTamZkBv4wuP/RPks4ph7d9lPG td/rFd5SfDjyysMwE8iQVzYfBYeBdQT4hAs9NyFl3VbctaHw29/yJD7FZCyuGlakYz5LM9qzIwVap C+BYbCGcaafDk7vUd79hmdkAqUjzsY1mVYlyIfoMy5ZLkjtoVlUWlc0v1nTpqYUz1wn8fKuTc3C1h c/QkJFnp2UHUBYIW+52MyJ3S9wYcnMsPD9Ig0KMPFvAequte9yYdVJNSzU8PyvK9xdseFiwvb1psP 1uQRFXKunsUGRjhzkn/m5TNfuPjERAWkHIJK63/Wo=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH63-0008jM-2S; Fri, 12 Jan 2024 12:57:19 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:53 +0000 Message-Id: <20240112125420.514425-62-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518420 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 45A29C4725D for ; Fri, 12 Jan 2024 13:05:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHCS-0003bX-63; Fri, 12 Jan 2024 08:03:52 -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 1rOHCK-0002za-0t for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:03: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 1rOHCI-0002fr-Cm for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:03: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=3Kh8ctsP6aKA0lMz/rYJ3sO368U+kPgcGR1gxhjIZa4=; b=iL8bcbpsBi22qqtNyUxej9u9BD yL7Qarz2jN8q001ODLqEpyFvFJLetOZ9+ilNExiAhSRKDOwlY1dKUqraFeQqN76VeHtnlV6ROnOiv STM2BJHgzq+VTJfIxjU50hpba/FteXB9pVbtD6MJwfo/3WJ53kW4laC92zfodcp9wU+QYY7BSdK7x 3YiEDRmYoji88Urnu/Of3iyTW+9qmozp1L7nxQIoxanoMPPzVyDDnZT0yin98LtkiLOhah76BAWqj iYSsYQaXzhwfzPf68VrjBZ7KPtM6XTUakRPZSj3NHLvuohQRQLw1NGzhwmFRhXd8rPekDij5qcM0h IPareXhEp73jgurKKnFU4gbJstjo5iRr/u/GTlvKVP8QcXLexmXXsuLlYtaT2Kb2cR8QMcUfsnfxY lvB6bVmL7ZzKXgbWgRVZnzXrDHwqeB6/S3nwRzZF/9VVgfEXw8Nn8EJJyknsdvMc87aTPn0k2Mkp4 Sp3dvchotNcTo0x+/EOLLSVgfaWWEUzJKh4TTGeFM7wDre62XGJRZsGffZM1dAXD9FxTzaUxtjRRq fZQXFR7uoOwXIN29ZmBD4eUJVlsKZ0chtAKVSu2w5M6rE1awaPWXk7xeJLrtfUbgsQJBuev3sxgk5 thivtMgAE8km7Dz22g5UWLRsFv2zywVtABrgrFq3Q=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH67-0008jM-C7; Fri, 12 Jan 2024 12:57:23 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:54 +0000 Message-Id: <20240112125420.514425-63-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518418 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 C37D0C4706C for ; Fri, 12 Jan 2024 13:05:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHCU-0003sz-Aw; Fri, 12 Jan 2024 08: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 1rOHCQ-0003SO-O5 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:03: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 1rOHCO-0002mc-OK for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:03: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=SNVGuDAiOl4Y2cc0LW/69S8I9XTCJhPHlEiJvwmXo8Q=; b=yzyw30PR5l0ip/XRhJvKbuYjwD ituxTwJ4Icz60uPyG2mCLBXaNdOhUD5PyYayzxqidJcKqYO2/zKVkPPG4Q/6oDdtY8bOwRVVxbAH7 SnUiBxp3JMjcitC+YxtPTLJ9oEagauwhaGQnfVGF9g+yBBsd+v5piIu/00CM/0DZwUOnNEwKkwz4S cY4BugXIrJwvsYqNVtnaJ5NHt0/3QsAT+JQiRSy7XRJT8UPfOymo+P99mkeUMSmV2JgWXM/o/Io5x W+RzvwCLQmea9mfiwF8s/7VY1ZjA46URH8RU7WN5SJT7ideiEto8Mzcbb5Zq3CCmkYioWjLIrI35T PFGhGnGYDhVc+NRX4KSQsboUq9JFrZ7qxpIM07+IAFbWLF10s5Qi8SmlNqn7FwyJVz1sW2Aux2zcE FSFQg19wzl+9PxUeJzXUkQEiZu2R9B2hrsY6NV0KQyoUOhJpLvFjejDFaugr54Ofv5MOQtilcUJXs 9At1HVSfi5xUtZyo6BKN1uMVYr1j89h7r+QB0Whi+sWwuY4R0tp+x6g3vmynvb4B9gFJ/WaHn3HNW Gxn46mTuaA1/7nKh55UEkeTgRna+jJAlUsmOcL4lXxr44LiCt6i3TKp0CGKa8rVdP00ctOmscM/oO JpEWEKJz9U9XGYToewqA9bTbRJYVIZW+u3ICb0uwk=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6B-0008jM-M4; Fri, 12 Jan 2024 12:57:27 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:55 +0000 Message-Id: <20240112125420.514425-64-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518407 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 21639C47422 for ; Fri, 12 Jan 2024 13:03:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHAG-0003Cs-G5; Fri, 12 Jan 2024 08:01: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 1rOH9g-0002mQ-IN for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08: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 1rOH9d-0001Wh-Bk for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:00:59 -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=AH7kvaRfyBpaN6wRUabwxD93irCPDXxz0fMJ6vNsumo=; b=NvsXR8YCVnHXKXoZ+XFtkygWEc tH7vk+ZLgwvBeIjrUNlogL0hsnrHN40n2Xocx+xdBMNAmacNf2y+WCZe6J5uiGROMPpEMP4ieS1+y 3jJP5zIW2aK4SOGFmEWi8DBamcxrZNjg8ri0Fus7LZBwru40WCjiTwt/w127fZ5Wn23RJyFpGNC/6 mdw5LN4SoCfyxFLtsWNDalLNxOyAsmt0isSraRNeq6PFkARtnoCKe7BP3eM/iMqDh0sDoKb2Q6ugg 5Pj9ipn0O9AqL+bi9EMYDWSyQHBk6/GFqEvsROw5Cb+LnVVVfMmhJO5EkHDFgNZnSQpjJlKkS79K3 zYkvWwXHzR9BkkT3imPWX8nX29R3PI5rGVOzjbSOm6gwnCs1R6gz7TzI9C15XC6TjeMQzaWbRToii EQxOQOqLmURWTshSV5Ph7POGEtXQx0NBPrmnAKbpkpE4D6kWxAvvt6NLWjxBc6+ZLE86VZ0V8fNfr xz60NiwiBnqQYL29gIXu0EiuQ0VGkFLqJYKZe7I/PvY6jFn88IFiK/+hwfQY8hkODVXtOkMNEqEZ1 9AhFbt7DR2oyM4mgiRbNedhc+YTZk3YWVuxwuZw6vPalHDEs7PCF+fGNcndh947W9pmGFUehPilSR eRRy3lhAS6P0tIaURjw/47rXRXd3YoguVkGcY8xBI=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6F-0008jM-VZ; Fri, 12 Jan 2024 12:57:32 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:56 +0000 Message-Id: <20240112125420.514425-65-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518454 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 0215AC4725D for ; Fri, 12 Jan 2024 13:12:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBN-0005uP-U6; Fri, 12 Jan 2024 08:02: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 1rOHB2-0004IY-5d for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:02: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 1rOHB0-00023a-5O for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:02:23 -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=loJm3RrZyp7pgJavwhQcogirW54ozY6kkT80o70H/ps=; b=TaZTcrKLRK3zfHLqdGkRR8LHE9 M298xCk5Wadssq+CTdM/kynI2xHLhyRUJuDIEVmvWr5sPoT1CwAZVUr34z1x6w2IFRWH/gUdwRWO5 ko2+647jIv/1/zhEQZetPnSDGqwikNdNDl1IOj7Nz+xsyaM2hMTmimlR6vaVWju2eVSOxHHAOF906 PFUzhCxJz1qavghJTIrGWO/xx2z6N8jIasqw6qHcEHtaLwu52Tx/3lUkkA++gnVrO2cZQY6onnPEL OQvRHdns3/CxirWZ+D9xWI3sQEt2vWGEn8wa24g2X8hAme1eD5T7Qs/fVoRl05G+MsZ8GCs/ptAWp GwG3vcBcAjwH/v0tFu3nj/or4gRQVxk7CWMMk+PP832Luxc28KmlVywk7PBSzuYEShcSCQjto1wAm oUYcG65MOPbw4Ac6PWzFM2bcEK+IqqOU9hnCebllugqgWsbFJVuscH8hwROFUmz6juqb1eRs8k9B/ eTn5MVBevliXR6jioQZKh6+ay6j8i2smRxLHhGoRmin1Et5vIhsoI5xudZcsCAxulgywjFLF0gzUw 8fF0akZcpUf2WeFm7yjNQeoRE3gNsBrK4L8C2JUdcGFy94U4zHKTG+FWTs3oQp1DVR5C1Z0b9or/T hxUbcA19Mnsc51L5H8NuOwp57QOKwiL+mFUE591rs=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6K-0008jM-6O; Fri, 12 Jan 2024 12:57:36 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:57 +0000 Message-Id: <20240112125420.514425-66-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518445 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 A2F01C4725D for ; Fri, 12 Jan 2024 13:08:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHAv-00047H-Mx; Fri, 12 Jan 2024 08:02: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 1rOH9o-0002zT-2n for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08: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 1rOH9l-0001Z0-8c for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:01:06 -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=1DRhYIdoW/MiCzFiz4koo8gjIUUvdeds73MY7nMAx+E=; b=mrHaBnHSsI+khuqULi2Gf6P0vE yhJTCnbP7qGxStodg/1BtReKKvHX/Bs/Wb4atQRMaoSN0Q7RtT5l/prd3LsyM+6l7MXV3rSFWP+Ye 4/Ab0tl/T1FSxUknT3UDBuFhW86Liy6oosY6eb2Z/HecawLOCRzEIo7tk2skQ7LdCQ48WleCT+3Um Je1ZdR4C2VmzEbQ36SNSkX7JInWswNn35hWYeFW51eBghnMRiGaYoTnja3FEkpjIto+tp2+RflHYE WZMRVm8lxVrzgloX9Zdbw90u5rPL1mA3XVTmFCQVbAdNOl1wTffz11hUCFLX8xZQkL22JXZ1bv2Ag 62fM8R6i0hFXRgY/L/M0ruB+LwCK0zX4wi/IUUyrUgjzv0SdmwpewgjAm7lGQlKwcFGvZxmCLJNOR AP9vRVGLQ1Zq339/qigfQtp35cqw6NTpI3TF8IRifWEC5IC1ZSWrudwo9BIEtyCiA70KixsARIEP3 zFTrD9OC2Kss4lquaKy7FR0FHmtQBgTJmBK+ObjCpzHKLFV/Nf5Y7rmKLZwn5nI35wW2bdDSZNJvv Bsamz1218ei68V3c0rIjrD8BYULVgmfeua1FJBuu6L6RSZ410NDIaS1DyK+e3H1OjKzlxfNVGcP9M uBTIqtBF4SfO/qNAp1eMR1qCMlqn8wdJLU/HkkDuk=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6O-0008jM-FS; Fri, 12 Jan 2024 12:57:36 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:58 +0000 Message-Id: <20240112125420.514425-67-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:53: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: 13518449 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 5263FC4706C for ; Fri, 12 Jan 2024 13:10:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHDs-0006gW-B7; Fri, 12 Jan 2024 08:05: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 1rOHDW-0004qi-U0 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:05:01 -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 1rOHDU-0003ES-7S for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:04: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=eUl8FFsRu9UjNl2mOZKaUEzOkTe6mvJkj3P/yeaifIE=; b=Fd7lVGPA2cdPTb67qePUBGa2Q/ No+8Dl1s3zkJRZphUZV61CRojl28LkXtwP0V6o939muTpU3PuOj47yu6YIpYuVtsdvkZp23pf/z9H IVv7VuAv3/KjYA3nyD1i9VqGebN1Eu/ET+SMzQyX4NP5yYDgILOYbp8gz5Rca5/N5si5BWXKogK3T GHf//WHFPjJqOrkjJMwNONHRa4cOTomNrxoAYcK/r/chCKj1H/Qqrb4KRDn+kvm655PxQxN5pLW3A UROlFxLh3AH46DsiFi5lqCcWHj8zWyWKQCNdb4PKUNC8oD/Rk55iG5YH65A9QzumqMi8CrLma/Vcw IdJobleV2ZKAL875uYltXiMt7FaeM3tbWhv7SJ1TlEumDKTHjhUaVgWNbXYhrW7AB64BRBmQRSEbP uTHWP7aMmtY4DjnB/stJ5+no9nBA4yjjt2H9S5/Fw7BiwxGHJlrnEcNW+29zjhM1/ybV7nD+1FnSq gYIotgnn+TZbHt2mI97cmahxvlkdCJM3HygNtako0yZv5ngZzUn+YUaCUXHZikmZ4xZJuFx641s3z WaoGTR8c8iZBzZJF8q9swNqpWufdD76Q3COemQQt+9bgiTiMxYec3ssnLh+f1fxVgyOz/N91wXCdK Kjw7tOlP+UUX2kewnsgpV539y9oFzcSyj+1kCJIms=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6O-0008jM-Vm; Fri, 12 Jan 2024 12:57:38 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:53:59 +0000 Message-Id: <20240112125420.514425-68-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518450 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 5A04AC47422 for ; Fri, 12 Jan 2024 13:10:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHDf-00051U-Pf; Fri, 12 Jan 2024 08:05: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 1rOHCf-0004MS-2G for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:04: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 1rOHCd-0002yj-6t for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08: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=8B7V1v2+kwT4bDpY+vrvIlSYZpgJoQzndmCv9dP7RxM=; b=DFtAx0eJ3IQfnujuvcP8BSnNJm NZfFOV0yKJxzWY8sGmWIY+pHrqyXhk3/nkSKBxwyBXDxnoTwgfZtwyVWcmAj44ysgkFFdmahjjw0X Q7PO807Y6AXAXhik2PNJJHdjl2/beMZbpPDrRmZIwdlT7warI+TlBcLSve/RCm0ntAImxKNQMPIwm MEgS6kzJIHgISRAP41Sp7iO+TrgGzJNgpG2DwUPxf36f5dL3Xrymlxs7FFUIdAxWFny3zLJhPde0+ AJ1f+0X+A58jOj5Vmr3B/QZBxo/2uaUL5A4xciOXLpb/ShK/YCDYnNvSB07QkCho8mbFGZCgjX/Eh lE2kBJ7+gORuR0XmEvvE056thNa+elyoJuxNsMxBwi0YI3EI3VAht/uzGiGAiZUnuXuKp09jqm4b7 MUI/nGoAEUJ5KO39n+4q0ynnvC8xsHGnz98XmynIFWLwhoYuIF91jREtm4I2no0/lTvoTnSGtg6w7 ImW8L7ElQsR0ligBMjOl/TS33GF5XnLIyTeGbOwIWHA7eg4TMpN51thZ0RR2VdjQw1seARJdCm4WO jcv9Bn+8srhu8zZdPsMfS06xRj7st2g0KMh8dLJDyNGJKA84mBoSGmIGE2NV04fWX4aAwRjdxfkrG 1LHTucNvfrpfXm9S0E9/BpY5/BDUxPFutM6i9W5Aw=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6Q-0008jM-Db; Fri, 12 Jan 2024 12:57:38 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:00 +0000 Message-Id: <20240112125420.514425-69-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54:01 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: 13518459 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 099DCC47422 for ; Fri, 12 Jan 2024 13:14:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHDg-00053Z-26; Fri, 12 Jan 2024 08:05: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 1rOHCm-0004My-DK for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:04: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 1rOHCk-00032q-Am for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:04: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=3qX0hv0RhPB8tC6ZQexYbL35eZAx1aD0Ti58keQafw8=; b=lGEW8RnY5wJjylhY91EUEkdd3d qysDdOYAfp31l1eO+WgpJvP2M5PbxwlbL/YozH7vSLWMKJjot1Ikv0PCPNk+RO85jIP+wYZbSAvQo L3DdihhbRmYnNEyjYQdMjcwjbnoDusAgpViD43BsvFjHppuxaNYkZ1spAoxCH3GMSZxwFwfy9ssyP uSepbbaNHU45hkUGThWRoPLbuo7fpmVFsLmXrjHElyA5RYCfIYUhQ9UHz40M68Ftru0uErh+68Y5S QA7EZCls6mZVVfq0ANftPFHqKbWbUoRLg4AvbbzOkJeIFxXbqilhQBay7dFgm4ImsUUr3EN9vKvvR prB0RNG/CwA+KJXt0d4/YpeXcOBYdLFn8yBg/cN+jMhfZWZZpcmjlL4F0FYVFpKKPx8jfOhYauSP7 HlOldn7U5AXfobnFCh6D98ZVxMzjydoprV50HbaRxhD5aZnK4O9W81Xp5/Qna4EDQCNWvXOI//yFq HiUgtt1AJzTv1Hgwo4enwkidTbc1yveQhuaoReQjsiY75cbrYXNg90u7imEzeLCiDRoT9H1edfE9/ MWh0Oz1yzidLTotB0bqfZy8i6kjOFlzi08pHrlb9ZuyUgzRXtoCD+DSvRX8vf+jZugX3eUBIw7sUl K9JbVlqKIh49pJbPHZeha/K9g0WJ4w2MgtwtUBgNg=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6Q-0008jM-RD; Fri, 12 Jan 2024 12:57:42 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:01 +0000 Message-Id: <20240112125420.514425-70-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518423 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 EA507C4725D for ; Fri, 12 Jan 2024 13:05:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHB7-0004Rf-S2; Fri, 12 Jan 2024 08:02: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 1rOHAc-0003uF-66 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:01: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 1rOHAa-0001xz-J0 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:01: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=AwCFNghRr2ccUEvp2DS9gkDztp6Uyv4u07aWmdBAAtQ=; b=m+91OkakIUxF8odvm73jfQWI9y Ja5q1neTgeqSWsD97I0zgcMMBfYirrC+XOInbmiqjhRESgH89V+GJWt602LPvOkepMVdM1RZg73Cj +y94Nf+6ZO7Nylp8lz+tQaJA6KwaIaPaKEZe5735/mCqqHqm0cJ4uMc+VINLArdstmenp2h31CieR Ns5ZBSuSIEd48mC1Fzqdx3R2tZ3GGw8wKQMJFBuXSSHsrKdUrk3upDfLSbXqMiWXDlO7PlzaQ4J3A RnmrwzH9ieOKl1IB1O//HMl67zCpWPsvIqtz/MwDAdDsBUCMfUwFGWYwUDRLRmkwroRKeMPt/niNs qxCsAtRAJlbhQEWPX/WDIb7gujX4T/rxUsQWvesZkLWKJhw40+rMmCxF+nCIyArFhBxCsRqFSCs5t rOPaAMGSjPbTLo9ubhXiMaFP9xYkpwCxflFc/vwwHt7jDLYHIwodBBqEbguNbWKfPDdRP5hNumMmX YZDZizVb7hCA+RwlgO7Y34PuJhU4VdNwVttN+VJejGJkECymf6lsIqcaWoIdOJ/pqJY8uXWMfo8+q 1lce6sGli4WQ495C+5YebZvj9nzaZCZbG1S/eBRMhKJ/QK22cVVyg/gqr+1qPhuupEZejoV2GaBjF NPhATMxe4EiYeIEfU7UVGgzBWFbNuV5QD8NMeD8fE=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6V-0008jM-4I; Fri, 12 Jan 2024 12:57:47 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:02 +0000 Message-Id: <20240112125420.514425-71-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518458 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 EEC93C4706C for ; Fri, 12 Jan 2024 13:14:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBH-00054G-H0; Fri, 12 Jan 2024 08:02: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 1rOHAv-0004Bt-0Z for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08: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 1rOHAr-000231-EL for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:02: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=l3dad72Fn6EHurpGqR/Kh29ypmbUbOCNnJyUEvUbgSg=; b=lJU+afwkZ3MTfR7ViHtLEjMek2 y82zl5j2MGVzugWXlpElwvsbKolt5rQiKtrT611kFnn2rWR/J1gf3x7/8PiYfEegqF7xLRXu2uPUx QLjXW7gRsFsT0/mA9LENe0J7ARppq6HstLutJH1kHkHUfSdoRM4SOakp37ro90JqJPR6KIETz7ZPP uxmiUfvXje4Gtgk6SdZSBpx8lRZShknW8cXdWRiULVGKZ21RPc+YgwOi1NGxwN/deb6JbEkbBShGr HQK+uX5SoxtfDG+QsmqP/AvuHakYyeZvE3vaAtiOsOYgBItWhcX+DF96mGnk/kkmALCBeGWAPxfSq BsREmx7fsEjW5LibPdZ4jA+lTMgchQeFId9i8OtyFnZ8zYzU7plRXUEmJqJSLHL54gQCerFgifc5c 2it3P99CSiaNsJbQcSfUffqOyiZLjfHjMLD+3TMAMEdfv/OpmLvJqbRxcOzGlpIrQwTvMqhtwUyYT QlHO76QzIhDzTyqdrMVBxgwXS6+CMu8MG520m4WbQ+Dx9B7CK5UBB/4Nwd7oN+HYIqImP+QNzPF5r 8Ut4MD/ar4oXOisbiBpPjxo2hF7Af/tsJIuAlmPKacY3H6vhUnYl16aSQyy2VVAGRqlKTSGnb6cmk v/WELbAo8Dbd3wjDK/OeISmkD+xC7SjOP+aK19MDs=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6Z-0008jM-Dp; Fri, 12 Jan 2024 12:57:51 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:03 +0000 Message-Id: <20240112125420.514425-72-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518427 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 0302EC4706C for ; Fri, 12 Jan 2024 13:05:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBF-0004nP-4h; Fri, 12 Jan 2024 08:02: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 1rOHA2-00035n-Hu for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08: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 1rOHA0-0001dl-S3 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:01: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=lsw3BrZEe81TWsQ6pxZhqW8GrE5i0KuQpfnBI/8+sGM=; b=M8v02a4OL9jxjra6L9GOj52onj nXcffEeGOO0wLqR4A1uSUe0Y0Ig3sfDb35PEgURMR1fcH/OGuQBSLNPk1HiOaw/KYO/SsU5IOO06D g3gsTQMb2QbBl88OXszbS9kwisJYg7P0QebpMmb2OU1n7fqgxC/uYy0IIxM4zcEEGtJbgmhGXdWv8 B7JW5DHIsRiJnf8uPSIJLB9JElgC1ylQjJvbVR9lygmeybuoWG0Hp1XUqth21NqRLF+jjOOrI1yfB yuI9H0VAhjMt6ObNBXkq4JW8aPcjcOebzmI3l8exK3qCbhNxF+KyxfAWf1862C2NHuBXjNnzvCP/3 dEwy8i3YrGdorrbqPLT/Hab/KcVY9YpbFefNFGmL5hOf04EzvKioYjdeU13vX/CZLXaG12GimaOHm XHV1LDvhciN35Q2+rwQcg+pEsubM4DgSXwKNPWegnpkN8/cqDAiBoZEqbeDGMbAKtqGeNWn65WgqP v7l2Mv2apGKjFrR5Ez9o9ReVLAzgUqWITp6EW6D74+AvtmcOQuy1zNXp/O+QsJVyG5qZEZaXfGLPP U2/qEn712wVdRoUQ2lpWc61/axW4hx9dQlsCBkFHeutfmMeMvtoQn9EvOcKGgYIM9gga86JJkImc8 bm3v20iLChr3IXS1F7RJEvZlrPVN81s9zIwAptTXk=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6d-0008jM-Ne; Fri, 12 Jan 2024 12:57:55 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:04 +0000 Message-Id: <20240112125420.514425-73-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518428 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 C3558C4706C for ; Fri, 12 Jan 2024 13:05:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBX-0007OC-Qa; Fri, 12 Jan 2024 08:02:55 -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 1rOHBV-00073B-58 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:02: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 1rOHBT-0002Bt-68 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:02: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=Cmw6I4jbaWD3QpctZrYmBINWPkyQ+rF0nYeNhKu/uSM=; b=b4TNlkAjKOdgvynPGw4qbgoELD gkhQgOVbnK+Y4vmstc3VERCu7mkL4ZBEwmQ3urmC1t671TUaVzPaeAkax23rlNZAMw20BDO+9JNJ5 6DwBeCXaTXWrlJnlsWdhpPdlpXPqDLJl4yBfH1hc/cyrLy/q6fuRP/UjARx5lERhVrJhotSvEfcCr e6aoCMFjHDu+oUANhJzdG3mlLORTczd09umBp9rg2cev1xiRNwhfH8ertr4jehf+32tF8++fPjmWI i71bzub7SbSvDMEEkb3Q9gkGZCj153Z1Fy3A4I4IFybGj5FbC2SZbX0IqHAIkRbT9YfsW5W89YkZM +CvvHcqATowGXsv9Fn5QaBpnSNbn24RCixgojlFzKZHOQOFp8rDh7clODBWjdGjeVaydHPZed/ISb aswF/XtJ0FdY+9eOA9O3iMfz/qy/TOut3BMWvCYERzD6qLpgTbBqUTIqHyJlzb36DKbcDPS+twcwK eif5WcPa02V5nWeWpxZLkR6XuPugDcbaVx3sDzj5X3jV4M3QduVv0qNHwESOVLyc20tpLiqzl/drB bAtFvScxBavV1cNzJI1lrv/d1jmdEOiGI3hSd5SsidswMayoxo3r8X5v6mx1QF5e82JQNpswo8XDH ULnGmMpCbKppVptOZeMZl/M58DlHbbwfVDpLFw6rM=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6i-0008jM-0z; Fri, 12 Jan 2024 12:57:56 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:05 +0000 Message-Id: <20240112125420.514425-74-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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, 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 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 --- 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 Fri Jan 12 12:54: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: 13518433 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 482EFC47DA2 for ; Fri, 12 Jan 2024 13:06:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOH9b-0002Y7-CE; Fri, 12 Jan 2024 08:00: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 1rOH98-0001vc-Nv for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08: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 1rOH94-00019G-Ou for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08: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=aYkI1ympF2TtAe3OjgOf0aiycDwRi+cMrXqX8Pger3U=; b=HFnOoNWENgZqPtNuGCDf7ihRYy 4vUroXSxO9pXU66sijy4IR/REJbONlvj5Zzy4bMAOakxdSA/Bp5qD4IlcyswDdSmHvtO5KWxkiNWs Rrd6OU8BL2LcIsWEtl7bd3Yi7nZfF03esQc8XSEbOHO1pM+wto6W50qz3PBocyb9MVJDR5CAV25e6 5m/tPedj+8l9jubaWBmUc/+KHV/5DSrGToFIFbbhzQ55Tea3m6qYKant7eGCvJtYUvKTRkGuBqs2a ReAx59TKnN0HmfY3bUpBomqWXqSKfFBX3slei0gOqN1xUOVP01C4/JO2ZsreN8Isp/p13gtVZz/MK zCmlDtKs/yZfiGJP0BaZkZDcbUvl91DqI7F37iXPW5TKGYdnig07y/tGnHvR+4n/lPghfp5thtoau SfdPchal5wYD0VHCs+DUIZ6IcbwgZOJZ2djEY5Q/JIeGoPARG0+++cG9tQ2mmvBrzqujocRiF295i KKblM5MuP2HiCKxMvZStNOdBXaZVt2DlZ6IcMZ0iMvnNbERjaR9hMFE1jj1lEz2mv2ZH1MpYjlY05 tsk9ef4I0q0B5pcQqkwv98gAnLJleCJ+YFrk/wnzyqNf7LgTmD7uCSDxjm/vg2TKwyrsD4zGAjB+A 9vBO++2SwnwfP7+XIIzKQKQVCmLpX5sUrbtXWBuWM=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6i-0008jM-EK; Fri, 12 Jan 2024 12:57:56 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:06 +0000 Message-Id: <20240112125420.514425-75-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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, 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 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 --- 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 Fri Jan 12 12:54: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: 13518448 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 06039C4706C for ; Fri, 12 Jan 2024 13:09:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBK-0005UM-6H; Fri, 12 Jan 2024 08:02: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 1rOHAl-00047G-9N for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:02: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 1rOHAi-0001ze-5i for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:02: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=YmsipulYnKdj65V4XC+FS4+WOnQRd8u61l/CYJ7Pnpo=; b=hwKRx6eXB0hQ33apniBrmwjwvf Uqn3mWQlmcR7ItMYqb/4XFmBx0+ZxxF3VBdickik/kkYOELeWnRM0bwnktuJL+Tewrr8vPI4trBXC 14nzZSpjsgazeR9snvWPLTvXqUgxmw8bewDZqV0CGbEgKT5oi7GMY06wtxhtVQIdSbB6hHZSGAqQO iiXpQCcXYtMJrv1TjqR0UvipXOJ2ZiHNedF5EN3IsBZ+Jqx2N/Y8KQhlLA6mVDrrQ3P05nmaMISzv FkU2cRLqMT/dzrxxd3Z6vdUKQrWi9gh1lOPlhraO8gRWSlxhqoRzcfA9nkjiU3G4kuzth+W0wUfce lPnjoLSqd5VL1A7MNF8aO9IkBfMwOYmxZ2xJkdm4uOFyc1b1763We4WZ3UmKh1I0MyZUX/fek1yvg 90rO5AFyEP25LpOM6KwMXfX9pyBFAjvoJGaPKz+gaddKRQJrdZT3oFDurvzHYDICfTGbXkf0lRSfu OzvhttMlvRJIHC2f6cp4lIZSLLG7Xj1oW2aUrJrhZuOAmSHqcd7lvmc8gjJKp2cS4NK7FNzQWnfib lIDAgkkY3FHnyWqF2v9J7U4jr91KjkmvwhsWGbT1fGhLOWXjYyXCGeihyLI8U7oRr09BRizxwdus/ p+bJCgo/ab2wFUQUyAGiTx/xbO9t/vo/pW376yaTA=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6i-0008jM-O9; Fri, 12 Jan 2024 12:58:00 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:07 +0000 Message-Id: <20240112125420.514425-76-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518467 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 A3AF0C4706C for ; Fri, 12 Jan 2024 13:19:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHAs-00046w-4v; Fri, 12 Jan 2024 08:02: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 1rOH9Y-0002KI-2i for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:00:52 -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 1rOH9W-0001Ns-7q for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:00:51 -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=x156p7wfBoslhd+bnv42ZW1jfmF4Zc961WxQ1y+2R9s=; b=NiYPx/ZVHUCVgmR0t4fnxIfOdK piZXHjOcG7F4PfpQg98X2/cvW1uZHuhb/6GJ0MpKSaZ14N41PHZxP1O2XXNadeFA87rn1SNb6tLUo OOeFAXpTOai158F0vHukP2k5iHEmk+4t7H9/dz1zprP+iVtDdIXNzvq8r/WGJSUV7TZXFdsbcz0XP uvBkHuU3u9YsJATeFeaWTwfGiQJ1dv43E3j3IfiQ0/N4B0fEEUHzPzGSLao2tdI4NlzHWQEpI6e11 g120NduFNS3bDCvzc/iYgVZy9QF5pFpfFjFog5H6vc3W0+rp2uspKC5LtZl+tNd4b205j32KGiqIw plg+sOkazPTfVaFk0fiPgc7Nh9gnYe3aIdOQJuw0EhaqbC7VODyUZZOUBbSrELg6NS6dUIkABmypz HiFoVY3/rnEiYKHWVsbppLwInXP3FHJxFczAjyNmrtQjVrYTWtIxlUjQs0Y0mwq71XEq6U9IwJIo5 kNZtWGJT6aRNTcjf070Upz0hKnjP+T/o61Ipy3Tn0+kpMKI3unp/RE4GUr5YDMwG55KNQ7MsMILU6 te5pSwGfgoOhfZhNQ1ohjC545zEDlxeDAdlASnSj+T614nQmXk4VDxhJh16KyIuwT/HHKDKQaJ/JV iJUppYaRm6xRu1POS2y6Wsd+bLBiei6k6kBkdZchk=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6n-0008jM-1e; Fri, 12 Jan 2024 12:58:05 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:08 +0000 Message-Id: <20240112125420.514425-77-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518437 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 44A64C4725D for ; Fri, 12 Jan 2024 13:06:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHCM-0002z8-81; Fri, 12 Jan 2024 08:03: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 1rOHCD-0002sp-16 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:03: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 1rOHCA-0002aj-5D for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08: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=oc1EdbXYwT+2pK47wP2cm+Sv5Ow2RDunfUR9sxZxHmo=; b=Z6GIfU+uuzN7qukStcxAUgGnZ7 aa3FA8bpwsIiK2DEpOXTTonlL0g0zlH+UAWeAFZgEAO82b4OQNBr+jAG/ep8UQbhgTFyXOJGIyok3 dgJkm0PSxsbIHLFQSObIwHPQEMEMjzxUpaHtrKpZCIDJd4lJha671fYjMYJZSd2i+VeihhRujFUNo zEAgA+xPmh7DRU3atxYvdhTjWfXYzKijNFDExdHJkGQ2gDvn3z++3MnQyKxwkrDyVAR8YPLbJdOwo E47McytiPq8DUNbuR5edP0vEfFqy00+YHouP5djMQN7DWG4wi5iWbpWFgfvdMQXMqNZzNVRQIRTKt qbd1gGVUPkejfpBshJD59q2fGL+0GmrknFuiH7qiON30aumxmx3HCEpyXDzJLdgYPdtiOvdYhcX/M f2cucPmBeSDYBWyTSleGhCtopRQkF22LfWmfbAv/7eGO6zVKSGyXyxeaFixnIuHYJPCH0+iu0F9sI /v2tUcgkRtkzf9kXgg7RBI/v5Dy1dgPAX1khdhYzo8/4i+HDcdnMt6o3HqlokNZHJhkpSyI3ncLaU wItmMQKQhtOcYyfjc7TEzSM6GFonNZ0TO+YIy6ahPSEKp2Cr9Fr/zTXnDXFEItyTsimR3s1BRd+kr 8hBVSrq4TOvN/OqRPDLSyZ0I8qP3DJqFxkmCLDS9s=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6r-0008jM-BB; Fri, 12 Jan 2024 12:58:09 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:09 +0000 Message-Id: <20240112125420.514425-78-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518469 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 6B4D4C47422 for ; Fri, 12 Jan 2024 13:19:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBP-0006FP-OJ; Fri, 12 Jan 2024 08:02: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 1rOHBG-0004uP-3L for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:02:38 -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 1rOHBD-00024w-UJ for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08: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=hTiBIvU/chvkJ/J+N/HUIfIavZdoB7wH/zpxm8f4Qg4=; b=ILoyHtdnUx2n6icda/tuzDmpZE wBv0z32BK5HqlD1IqDktRNW17d6N7sryFOGTPQLzRNTndBzzmPTjkhVnpvmoy0EBFnrlcaP4nsWXi 53jMknWjV9o/aOGh8BSuXEjRSjQQRcH8E1qVfP5Nctdvga8onvC3XFJhjqdltfSNUJn6337mQ8cme Bl6yyYgri2jsre4aJ/90bi4Hpy6kmrTc4py4Nh+/tJwcn+UE2I3OL1RGc3KXqIyKBKThUXa0/ye2a Kqvygh2rYfyHMErnMAk1XK3AvAp1wcdxXyaK4gW7XKzUKuuHPinN1e0wiR9BgHSmtdR89XV5tSjKy sX4a0KAV5Gc4vp2SC6jczgMFOpCFI9yM1EbLfHQD7Q7g7eTjFnhEnK1qMti+NRPDtyGQlcjjz1GcN tyx2GH3dGsDcMosHktWA75keEemCXKLu3TBH4H4fUxhJfKyRVVhlBCvL2hdL9DdeYZ3AKotbwdGnO T8tvqqrqbXZLMiafrg2/9LDw7BR5B8xHBdhUjvtiImlsyzwNGfsDZ1+NnS6xvY9TMJnwz2onjGwmy PID0aHiCfvuPfJthzmwOP4gOkKrxk7KtjH4KVUztL7qsXl4/QpBrKhArOEFS7gixvufQzqsR1ta7V SEg0QkYHr2Pcg44ItOVt/ZtxJAfKPu70fjdRc5Sho=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6v-0008jM-L1; Fri, 12 Jan 2024 12:58:13 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:10 +0000 Message-Id: <20240112125420.514425-79-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518451 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 3521DC4706C for ; Fri, 12 Jan 2024 13:10:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBH-00057O-QL; Fri, 12 Jan 2024 08:02: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 1rOHA9-0003B5-LZ for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08: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 1rOHA7-0001iJ-OS for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:01: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=c/x5L4qSUT7C+ztN0bhREfCYFtPG3NyJ8o4FL3Ik+aQ=; b=J1odOXDL+vEi5mcrgPKsP7q4EC CXm7XgdOKYLFkZ1bm5StSRc9gNz7xa72qglL06fPVTPU+5Q4F7bfFvFtayIm5z2n9dN5tgdhFoNuj 72GuzyLL/PeCbrv3g8yhfmJoG2gbTjtqPIBOdf00tv8geXnqNKvDcgX/qFURjbs+GLLCufLvEfCgj VvOEjronnD1gIT0ad2VJnF6r22OElwVvSegQw0GQsjd6vmt3DQFZe0LB5NTncXL3333ywczahgRTA TGiN5wS/f3jTOBZsHEzHrd0XdsUj/Fja+nvm7HFlFNfYkNmkKJJcNpGQYSgxN6sq9x6O6Gi6bLpaD tstbHCxlnFlgWdwuxm3QzaIwzPMm8XZbsozj8TP0TOZNLPH8+wRFLz6hVGolyr+cAvYUk/3wQfnMp gpN9q+3VbkJWP/3Py4Q2sDYC0fuHcx3+syMPCA2v1ekjetY1AfLdp4F8tU1+jHP6Ef8W2tnsQCZEH vH7HFhdpPe3a8d+jJj5VI+8QZUjKTkgzcq9MQji3X0mhuDLDVvysBL429Eg3z+yTrzOBjRdPflITM ImI0xHEiPCDCgr9jVl60bVHmx90q/N7O7Ixr6U88OqsYVQJOLoRTDcYzPNxhSXg3BzMwiJTVkluP7 3QRYEcPruTV/fWr3eJBfoVYMi6YJWCPrH9zal5ddE=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH6z-0008jM-VP; Fri, 12 Jan 2024 12:58:18 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:11 +0000 Message-Id: <20240112125420.514425-80-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518422 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 D0B1FC4706C for ; Fri, 12 Jan 2024 13:05:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBK-0005TE-40; Fri, 12 Jan 2024 08:02: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 1rOHAN-0003hX-I3 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:01: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 1rOHAL-0001pb-Ow for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:01: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=isg4eqT6mpj+u8nlsxSn/JAamHZfsm6I9p691tnNUXo=; b=BFa0RnH8P07+y4L2kkLO0btmcq Jzs/CVJdBBk4nM88IKcHXcvCNSWb9GQ487cDQzecKko0Mp4ushY3oc1O2oCg3R+Q2ZWGkFNUPo9F4 +dfqMykC6/I5nVUFQJ1F51o00GI/LxL2KePcNTDXMsIWXpjeZv98wvMF5/OceEYCFI4HJz6vIRu66 gRW7Qpb/kjkDhgJ1CDTvy1W5udaakCdveMr2N9imQQ0gOurCD+gdE51eJrOnn323aMkhAas7tU1uW WubmOkAvA/WA5UUt8g7JdrrFXzShxl7erVTxXMm0ro9dPBfYbMeJ7X/NUCYPbozZ1VAlIlyc6flh/ FjmL3f4TFkMJ+YDMzJ+HLIn8RwkhFShLyvWsHF1tP62NYuFwSj7+q/QDTbblQqW0O603OAX8IR3bg Zc98MB/StsBEII/fOxs8nzcG+PUC9qvQmrGgRhRB1HhOK3D1usTFmtiL025xM0r1vrui09p55FTQo /UyE/ZFvXtx7M8aljcjxNhdQcqPktFYmnMW3cEnxlyez3R093k2BbMA1x32ntUhyVS635r5o5Qtac 0rqnNE7dKOPIMg/5NwIgyXxe8IhpT0713kF1T/aa3E/A33uHjVewRVoMlojsDJOQX8zkjL4rBBD6N Nkoi+eZPG/8KwzqMrPOFDXzGGaItLX/iXqFlfNMmM=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH74-0008jM-8D; Fri, 12 Jan 2024 12:58:22 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:12 +0000 Message-Id: <20240112125420.514425-81-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518442 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 A608DC4725D for ; Fri, 12 Jan 2024 13:07:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBK-0005Vs-Ml; Fri, 12 Jan 2024 08:02: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 1rOHAF-0003Ge-QU for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:01: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 1rOHAE-0001mN-88 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:01: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=VlCGoS6t247f8EcMG8OT8xZVuVkUAlkJYCgQ8hwRDXk=; b=TAW9XbZaGsdABskLmNrnNUlSnk yffTLsqTwEvrM+fKFKmXa6GLi0vy1hNwLMd/5b4kF4Cps7ItEGCQ7ENIcg1XLMOPP8ivsTKgJfd9S 7eQmXl0YKyfy9OwI0skPFC/gDtbkvPUeq2A7kU7v7KN9+ob687HkUQfvhlwqGlBjlm10iToLJ9MP2 7lcQ8mQQTYo6/msIiXSi9TYm0SEZNhG6q8gTKHOZiIUZB/nnQZlTgL6A1BdmEc7DHbJeyLtFhgCht lQ415psGRnchQ7FqEu03+MsVSpr+XqYvt+WOs4sXk90MpTR5CkuYWgRS+Mgt5BTee9SZcCGZrLJ5v SywehM7j/998MQCQkbo0S2k2v9vRYsXQ3AcobwPQO43ubq4TknXCHaTxtbwPkYk+UbGnAiwbx8gT1 iVanZKBPnnVxGg6Da8EI+omreBXg9ki9W3cPWbVkhyXu5IrukdGGUE+MmyY7wI/VmLThuI1uLjbtQ lwN3AbwNCshrr86TmWNPDFbEx9J8Bkm3U9Mr1Ql+9AchAAvXCm0wGimX7YvSmYPoJkRUB6NjV1tyr TXLRp1gZRHI/OyOxvzZsqDMTCfODjSGKgAyYI0XdrJu4auWfyF0nBPc109nGM+JXYqWDsbKJILgKF rh/b9DQeOAjdWjdBkv0zzctwVlElO7i7owigfJqes=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH78-0008jM-Hz; Fri, 12 Jan 2024 12:58:26 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:13 +0000 Message-Id: <20240112125420.514425-82-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518443 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 A6A92C4725D for ; Fri, 12 Jan 2024 13:08:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHD0-0004Sw-5z; Fri, 12 Jan 2024 08:04: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 1rOHCY-0004Js-HF for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:04: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 1rOHCW-0002uv-5b for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:03: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=IRWmVN7u1WyIsFFHEiosyYaiKIebFBg95VXoAT5KMFM=; b=eoTsX7NUEdHxcm7OBvkkbJEq6A zTv4bIne4UIGKusBnnEEzHOMbDQMxjMdiZHTgjjeLajQ1OcuqsJx0Nf1QtktHJ1dONEyUqPNjFF9I 8wBdMLWJuiuxfS59/7MLg22WXkveW60e/T3qRFXCxgSV5Mn/I6prbyILF+qCW2QRoT285j0JipOLf kIHb3JWzavyb5b3acUo9fz+bimNt0+EeW0lxfU5pbh2KzNB7iQHhTjGzLcg92uGrt0wuOHM3NC9WG Ib80aZb8mVFDz9pLmUpmwKiHfUo8dL+8lt70Si30oPZrbHlcuGjnB+Jppq1MqlEvEE1XNeIrs0w0V p3FhGXdTQthXARAifcbe/iQfZitLwXAvlXMXYOFXwTyPOWE1G/WqviQQxWG3uIA1Uz4WAF9EjZnZN HMCQdCIzpfPqdnHNnR44Xdf3/grVqATlcbM8+h9fGM5LeQFa6VQl7smP8tTYSgjlNrytYSVVEQve9 a6X2s2Z/1P681cvPkZKOnhDQXy2TdtJGwgDeAZotoOqXRtLdUpqkxn4PS4K6OaDSBhiaFgpzI1Jfl ky30B9IpfscexogpH1l7HMsErKYEemuDQRZrWiOMlHWwUG2UxOeji4jVzHom78peNRvspAREbRhp/ A8LSyUJuvqPQMo0Ng4YksOdzRG6ThlBx6+0gPAwNA=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH7C-0008jM-Rg; Fri, 12 Jan 2024 12:58:27 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:14 +0000 Message-Id: <20240112125420.514425-83-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518447 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 020ADC4706C for ; Fri, 12 Jan 2024 13:08:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHDq-0006O8-53; Fri, 12 Jan 2024 08:05: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 1rOHDm-0005yP-Ds for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:05: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 1rOHDk-0003a6-Bj for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:05: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=IL7dkV0KEoDsJkhEOTP7/jzlgKLuLvovOal0c7WQ+LQ=; b=TDlCV48hixLjSrS4Y4bnBHGUpW Lz6BQbhXYNntHoAcYxgFlwGJqXcG28B+xkr/miZB05leMIMj0TZyj62moGyNQ6QdMrPguEU56BmmH lR7KWfKmltM3jmCUfcan/cj6uUDZMHh+12EzSJ5N2xlXSzzU2MowIf5GgEmiQ0a7M1JW0MYqzDpcF YiKciJt6PJIkHMNGe3q3vfd3yTEKbcUBYXR0n716irfaXN4aAB5ByK3B9gc/iJYw1wdzYetv+Fh6T G5OaMcmruxyomPVWTZpfZBcUF9TqPFMaDgxk5mB1gop7NRL8k+RjPn6OiBXKiww8+RnBw0X6hneEd mOO6lYBBuFyFnNtk2ET1z9uABDN121ywyJC3ZYqfTJstFV5zyoV+T5pSaBfMTAD7S9WzUFIqO443w JihRQ1jGhcgaKTzAZn14uGTNuw+ettAXHnqvrgnWsh/Zyvestsmslhvpe+UGVx2kV3hIB66b2cPE6 YvS/NfsbGp2L2KjAOFnR7/44bFNdkNyw575/P8Y4jVNDKA/F/Xww1FR/6F+U6zzLm1/LnM/QGv00T ekl/8qSn2vVINBMovrdUXjvkjoB6v65QsMTy9rszg+iSJaWezt2WDk17HgtWCt9+jNhA+zyJOx36E EHBTN0rnLxGKofyu3/i+i/WZc3yKPiwuphbb07Hgk=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH7D-0008jM-5x; Fri, 12 Jan 2024 12:58:31 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:15 +0000 Message-Id: <20240112125420.514425-84-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518456 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 3AB9EC47422 for ; Fri, 12 Jan 2024 13:12:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHBg-0000K1-RB; Fri, 12 Jan 2024 08:03: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 1rOHBe-0008PE-7T for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08: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 1rOHBa-0002J3-VX for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:03: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=dqtNfmH/y5LEFl4e5Sf22fl1pgdCOZPPeZCqeQS8/KE=; b=mF2aN2mlhh7zDSZ0ZXm9uez0xf 39+xpj5cZ4hwZzy6sVRezvlDOtn/9deDqS6E0tNMXJN+LV4cWqdmDjH87qC6+gz68yfXqCCjtsWzF e2jUzrulaGSW63wCxTDo0HTrG1+qM+XyEhNGG7B7VFirVBOEm2Qj+btFhgWPhzmF9B4XjHT7gCbwp Olpx22uVF0TQSXBDgMoHVhWYKWohBMWUF6gcR+HEPqlZDc1vSpPUvALG232faCH/K6bv+ROeNT8jp pTpl0c1B8bJ4omt/KOnRfj72GkD2dB1RXrhu5gr5ysWgROtvHatiVruAkMYv4v7hOs6j94uigKlJS ZOakryoiiW1Sd1yrmAMJz7ZsTpz+sJ8oL7J7ACzKuS1GrYoVaTTx158y9WTevmGHu/lFl59fQSffi 3uJ9hz7NvD7tKhisUuiZz7zH3oBXpFDtwc67I6A1QeZYt73tjA4mnmugNZpRcaydfcnKNiI1NHCjz VEPsydGcRW3cQQP4bEQK7bFJAN25C7OZoyXa+zm31IEjIFuo8xONN2oT2bfLvKfVxLdo0i8vt9Ssj 3r7plBvRnvoQr7dSrxokrWe4cPlg6c/IeIh9Tin/557B4l1R63UWe3QDQ5UG85+3OBziD7oYEnxIJ oyPV3HaI9bqCYDrTRDRDMpEB1H0p8vubhuFJUqJq4=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH7H-0008jM-Eu; Fri, 12 Jan 2024 12:58:35 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:16 +0000 Message-Id: <20240112125420.514425-85-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518421 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 D6896C47422 for ; Fri, 12 Jan 2024 13:05:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHDm-0005wU-Q2; Fri, 12 Jan 2024 08:05: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 1rOHDe-00052y-Ge for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:05:07 -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 1rOHDc-0003Vz-Kh for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:05:06 -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=OgDATLDCHEwFonub5prGyeLIQDXbjiADXevzh5OjrJ8=; b=Y18DuqJ5MBl8ghfORyFHxTBzSg tQtOxtSJ9PWsaE0UuUBMteJY1G76YrZC84ua4kWO/WWXj/fje9yAKyMZu3WsHbPBrOib2GpctcW+O 0sA2WVxAfD86dqK9FVTB0y77NtAZ55CP5JP75rTYB8rIYfDHLl/AfsZNJrWMhmRy86tZ2GC2VG4WL 5xtvgKl3hLWhZ0gzDrZtf8DDMjfb/SYRQZzC3eHYs1Y6RAupuiyz0NoxtchIsmlDxoPSmaixgw+md OgxvLPnN7xqaENFA62X+scgB7noZK8EsfhFI38BgshAwCWSqEv/4n9h3Myj0vBQUfcpfVq56JG+6A 3oipYOqjWN03y9jdvFQv1Wy6wfCDFQjdJ647Mp+nfhgmaZFfKat6xpj8mNouciu843uWwRG94LDWc vCfrVKorF/J3yX3LNbkxuzTuQUh7S9Y5IgDp01hADbOWy9oqscfZd2ZD0L3LrOc2ZddZD/Ch7pMSC j2QP1tJJS3C8waVyg8S1GJWGi0ZuJl4t54cZrJYDFOpUg4R2D6BhUC/tLzct5La6WAhbF964z+nSF Sla5xiAq+rGYixS9lti20ERWfUun3WtmyWuNEFRdST3ArKuDfC1vezTb4YHtZ6aJFba0TmIyhBVm5 Af1WA6xwqdB3XunTIq1em8Cff/Lu90Z5/o7ylnWew=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH7L-0008jM-Lf; Fri, 12 Jan 2024 12:58:35 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:17 +0000 Message-Id: <20240112125420.514425-86-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54: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: 13518439 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 29279C4706C for ; Fri, 12 Jan 2024 13:07:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHDj-0005UW-Iw; Fri, 12 Jan 2024 08:05: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 1rOHCt-0004PJ-AW for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:04: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 1rOHCr-00033B-Pm for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:04: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: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=0rMPBBScfvVeY/lAhBIKBN4+Jy5N9kgQG6GJlxR384g=; b=O1wtN+YL9BAntmtfnpUiQ8yVMI 2eY0r+TaPm7wql3sPTE72KLlfi2kBbH+jEQO86PQgcrtpe0M2l1rzbSlJklCCOaGl13f5juLgEJk9 reQQ0uZhQHmRCRX13zZ8JTzzSQ1jVHID2q6cOBYaZo5lydVFMNVGImbUXNUCCsSE7CbeYEPftawV/ s3W1gfd4apfy8AWz4/GW0nmSAlqU5VzCCXPQNvtwisjq4SQid5VK4MrOsnhzCsqMhJtv2shLCsaMS x+X/OAeWHNag+ayc/mGCrujddBrB8CXNTbVyKsSBC8wjLalOkoNVHbtSAT4uQiC+MOrfVMBLNVf0P jFHE9nb9Wy0ud6OP0LVvLfokxWN0n1pqlIhw7GLuU4SAizZ47XQO5EDEVbUHJXQpP8d23ptjF7la0 jYgsDp2GFCu4usG762dtMMaF5SIrR9OciCpkOBJuQFiLI7z9TpKGKUWAHsKdC6bcxTKeR5oe7E9lX 77HAm41aoiiL2I09sFe8L3FoZdoz9vBDXVAmIYjM0qJo2ydzN/rRIRtnTQYImIctGKLeT8cj4EhAC MlwCJHTht3Maz3NAKT/om374N6EfMnOJ8NsektgJwVWpVAus8og+UgOTgzJosaBbg3vVLmza1kLtW 0XVlQs839yW7YSIsykFJ+28GLQ6m9lXRPo/eeKLl4=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH7M-0008jM-2Q; Fri, 12 Jan 2024 12:58:40 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:18 +0000 Message-Id: <20240112125420.514425-87-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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 Fri Jan 12 12:54:19 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: 13518440 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 5A855C4706C for ; Fri, 12 Jan 2024 13:07:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHDx-0007TC-II; Fri, 12 Jan 2024 08:05:25 -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 1rOHDs-0006qE-NE for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:05:20 -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 1rOHDq-0003e3-Qq for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:05:20 -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=Ob+mF+Q+ybuW/aQQDHwJ6hST/S85cmCXIzfHssHpc0c=; b=oPS5vSYbVL4OLFbcLgZsWaKNNy j49l/jJjY9KygSmy1pJhSnlyw7r2hynaFQxhw9ZkygGwO/wnYEex4Kvchg8GlrgaaUmfMhmrHmovg zLblkNHx4Homm4rRwNeKLJdjh0VGMRu6NkkQVGJeJBnoqpME4ciStkNE56VvziSU1XGJRCBwoTVQ6 kxxqj16dAPg3U4YpopVAUubE90r64FrTz91Qg2bHjmU5OTio96p0lzK2hZGiUGUMikVtsNjKNvtYz ENwQNoZSftNRaPGYbZYdj7mgfPSBc5uAwPNn3NqvWdgoa51yoblYeEVEA4KP1zdZ6o3+y3fAHgzCd zLIM9rmh07eYAiIiJxPTE8X1A+l4Xl5P8FyxtCh2z85fGwpqC+GQau6xRkPSy4mlploT1dnCiPYrX GbHVNQyAQQH56eeXTksMiPOlZiz2Aw2o9qfXQsfy/oEFYEmOHanPQKGlhkyzSyINA7mHJkf2JRaqt heZ42Iae4SzLdvmmGQay7h8ZylcTO7zJXSl4I5QX0+4mgYHJ9jjej5GEtj7xyGc42NWQP4Go8Q6jo P8a8zt80KJ5xVDFDW0VhCdv43i8A7Q0MkaVB/IExaSrLbgphz20hvYAbpxoQ5ze23ZBTx5yamEtYb cCBbiGDE8hdIUISJPcLdkN80fH+bXShvJ3ER5do2Y=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH7Q-0008jM-C2; Fri, 12 Jan 2024 12:58:40 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:19 +0000 Message-Id: <20240112125420.514425-88-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 Reviewed-by: Philippe Mathieu-Daudé --- 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 Fri Jan 12 12:54: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: 13518452 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 8DAF5C4706C for ; Fri, 12 Jan 2024 13:10:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOHDl-0005a6-2b; Fri, 12 Jan 2024 08:05: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 1rOHDN-0004ek-RH for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:04: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 1rOHDI-0003AW-R0 for qemu-devel@nongnu.org; Fri, 12 Jan 2024 08:04: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=smlVZmV9rs78GsLFFCye6cQ56AeVA+Z6TX5m3wCBznI=; b=gD9pWl1DA0Tg8GR5qxvqAL0QF5 d6MggctbhvMeI6mmCs04lVEr8OIWSNn7gRc8Yx4GMPMyMQDJGUNGBY61Q4zSQQlZe1V0A8nHAnymr lyrWDovjH0VJuBVImsF8Bld1bmTNgACCV2gnTtdQaQBV4ulJSovVq123QlOwlUtG7E2UIwIe+WJ2a Sja1wDHO8+8vyHk3o5fgMfF7ygo3QBawXFVweKh5VU/8XA3md7TWJ04F0Ouu9QRjHfOwRRxwPfst/ x5ndvMlFx/2Fd7xwpJOjy7ggzg5nGCiJQp0WXZK4qopyq+SLVmzeotyc6d+OTI1JWItrvOb2nNJfB 0ycb7HpWgJtnCm2tMZ2OViyiw2zH8/N2PPASyFttyV6tRz48G+lhQA81NlKh9ci5i/4MJUGMRkis/ U7/zaZojlU1DbxmrZCu2bx4XepAjtxbnSTRItq4KdlB1CWjRh7WLDHxojcYLWmbbe0OcC7gDHljX0 A799Vz69Boaz76CU2NB/RfjgXM4ui5kGExNQCsg4oUUq1/Cae7NrO7H0hzDXCE909jDH3ovqX6VMm yHu7g3uzEleA2c+76iy8XEZqaBBq1gQgMiH0O9yRhUPNHX50y8rdPxIu2DFKd6xNvSdEb8NGljXIE QCbmJ4y5oZPMMUNReNgdSjbA0YXrICGyd2Mv9HHVg=; Received: from [2a02:8012:c93d:0:260e:bf57:a4e9:8142] (helo=cheesecake.fritz.box) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rOH7Q-0008jM-PF; Fri, 12 Jan 2024 12:58:40 +0000 From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, hpoussin@reactos.org, laurent@vivier.eu, thuth@redhat.com, qemu-devel@nongnu.org Date: Fri, 12 Jan 2024 12:54:20 +0000 Message-Id: <20240112125420.514425-89-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> References: <20240112125420.514425-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a02:8012:c93d:0:260e:bf57:a4e9:8142 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH 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 --- 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