From patchwork Fri Jun 17 08:19:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9182991 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E32E76075D for ; Fri, 17 Jun 2016 08:19:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D00742835E for ; Fri, 17 Jun 2016 08:19:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C429C28390; Fri, 17 Jun 2016 08:19:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 406B42835E for ; Fri, 17 Jun 2016 08:19:56 +0000 (UTC) Received: from localhost ([::1]:54702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDp0N-0001At-Cd for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 Jun 2016 04:19:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDozv-00018o-CC for qemu-devel@nongnu.org; Fri, 17 Jun 2016 04:19:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDozr-0006x0-Uo for qemu-devel@nongnu.org; Fri, 17 Jun 2016 04:19:27 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDozr-0006wB-8t for qemu-devel@nongnu.org; Fri, 17 Jun 2016 04:19:23 -0400 Received: by mail-wm0-x241.google.com with SMTP id r201so2615124wme.0 for ; Fri, 17 Jun 2016 01:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=07BdnWOF26oUxy+YWKYoPlU1mHZJgdpa3W4SQ4+BjIY=; b=hh4adgKC+q0qr1p0XxY+0NHp2K+7UeD445dO9VFsbQln0KAB0XqcShoiCNfprHRIp5 35IWjnLRYQDrr0XQBvmQdNQubS5lBwIEQGMG/pavs4YLhCRPsqS072BjbFKOTNS5i/lD E+rOmiYmA/RO9ZJHISKBelhiZmIPHNtQ6rA5uEBUGgDG+cx4e5mKWmdcKiC8ivCLKnnj 67yrF6nD+gK6A5easAKtxPyNAjIorP6D0/57JHZvCdx64ytM+HnJgXp1igYTzQlmXyc2 yOkNJytBdkKsdYgcC4zliy93UidSvKadoC2W4Byww1p8SIRZ6XbumBgjMK1E9C+Ke+In qBGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=07BdnWOF26oUxy+YWKYoPlU1mHZJgdpa3W4SQ4+BjIY=; b=h8hwz1ZB8eqDvGbqviQIWmAZhvsWGwJLgJEIBPLuwwKcWPkQ8vWcEntc0NkyiAWEsU vEnjH4VgtJEIG/6DbHxwGt/Hok0zf18RAFuBkSyKCJBIb5ACMpcAH4KZuLwShusIePeq NGpTcOWIoAPHUMJUmMxZaE6h4cxadzZUb77GjUYZS1b5mNzOT2YyjhPMux61UqAv+HoO 6m5BJuet59RsvL75cdFndPLNjr4UGiFhgo/4zrPPacmee/KOROZQXr4YqXrMuSn6M388 GodL1e6wVam/JYJ39qaMOuoFzgR7oDYG95PTIv7EnqicZq2j7xjEZ2z0ycpKBp0SEUiB 5NvQ== X-Gm-Message-State: ALyK8tI9aiu0QffKY2wnuBdWEgJ+x+M0VIUEL3DyCiAwX8JSVF1YRnAF2S76VtrXXaZcvg== X-Received: by 10.28.224.5 with SMTP id x5mr18584844wmg.11.1466151562356; Fri, 17 Jun 2016 01:19:22 -0700 (PDT) Received: from donizetti.localdomain (host91-153-dynamic.21-79-r.retail.telecomitalia.it. [79.21.153.91]) by smtp.gmail.com with ESMTPSA id t190sm2546718wmt.24.2016.06.17.01.19.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jun 2016 01:19:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 17 Jun 2016 10:19:17 +0200 Message-Id: <1466151557-12676-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.5.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH] scsi: esp: remove handling of SATN/STOP X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amit.shah@redhat.com, =?UTF-8?q?Herv=C3=A9=20Poussineau?= , ppandit@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The implementation of SATN/STOP is completely busted. The idea would be that the next DMA read is for a SCSI message and after that the adapter would transition to the command phase. The recent fix to SATN/STOP broke migration, which is one more reason to drop SATN/STOP handling completely. It is only used in practice to send 3-byte messages (target number + tag type + tag number) for tagged command queuing on adapters that lack the SATN3 command, and we do not advertise support for TCQ. Signed-off-by: Paolo Bonzini --- hw/scsi/esp.c | 58 +++++++++------------------------------------------ include/hw/scsi/esp.h | 3 --- 2 files changed, 10 insertions(+), 51 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index baa0a2c..d11151f 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -192,23 +192,6 @@ static void handle_s_without_atn(ESPState *s) } } -static void handle_satn_stop(ESPState *s) -{ - if (s->dma && !s->dma_enabled) { - s->dma_cb = handle_satn_stop; - return; - } - s->cmdlen = get_cmd(s, s->cmdbuf, sizeof(s->cmdbuf)); - if (s->cmdlen) { - trace_esp_handle_satn_stop(s->cmdlen); - s->do_cmd = 1; - s->rregs[ESP_RSTAT] = STAT_TC | STAT_CD; - s->rregs[ESP_RINTR] = INTR_BS | INTR_FC; - s->rregs[ESP_RSEQ] = SEQ_CD; - esp_raise_irq(s); - } -} - static void write_response(ESPState *s) { trace_esp_write_response(s->status); @@ -246,13 +229,6 @@ static void esp_do_dma(ESPState *s) int to_device; len = s->dma_left; - if (s->do_cmd) { - trace_esp_do_dma(s->cmdlen, len); - assert (s->cmdlen <= sizeof(s->cmdbuf) && - len <= sizeof(s->cmdbuf) - s->cmdlen); - s->dma_memory_read(s->dma_opaque, &s->cmdbuf[s->cmdlen], len); - return; - } if (s->async_len == 0) { /* Defer until data is available. */ return; @@ -316,7 +292,6 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) { ESPState *s = req->hba_private; - assert(!s->do_cmd); trace_esp_transfer_data(s->dma_left, s->ti_size); s->async_len = len; s->async_buf = scsi_req_get_buf(req); @@ -346,9 +321,7 @@ static void handle_ti(ESPState *s) } s->dma_counter = dmalen; - if (s->do_cmd) - minlen = (dmalen < ESP_CMDBUF_SZ) ? dmalen : ESP_CMDBUF_SZ; - else if (s->ti_size < 0) + if (s->ti_size < 0) minlen = (dmalen < -s->ti_size) ? dmalen : -s->ti_size; else minlen = (dmalen < s->ti_size) ? dmalen : s->ti_size; @@ -358,13 +331,6 @@ static void handle_ti(ESPState *s) s->rregs[ESP_RSTAT] &= ~STAT_TC; esp_do_dma(s); } - if (s->do_cmd) { - trace_esp_handle_ti_cmd(s->cmdlen); - s->ti_size = 0; - s->cmdlen = 0; - s->do_cmd = 0; - do_cmd(s, s->cmdbuf); - } } void esp_hard_reset(ESPState *s) @@ -376,7 +342,6 @@ void esp_hard_reset(ESPState *s) s->ti_rptr = 0; s->ti_wptr = 0; s->dma = 0; - s->do_cmd = 0; s->dma_cb = NULL; s->rregs[ESP_CFG1] = 7; @@ -450,13 +415,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 (s->cmdlen < ESP_CMDBUF_SZ) { - s->cmdbuf[s->cmdlen++] = val & 0xff; - } else { - trace_esp_error_fifo_overrun(); - } - } else if (s->ti_wptr == TI_BUFSZ - 1) { + if (s->ti_wptr == TI_BUFSZ - 1) { trace_esp_error_fifo_overrun(); } else { s->ti_size++; @@ -534,8 +493,7 @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) break; case CMD_SELATNS: trace_esp_mem_writeb_cmd_selatns(val); - handle_satn_stop(s); - break; + goto unhandled; case CMD_ENSEL: trace_esp_mem_writeb_cmd_ensel(val); s->rregs[ESP_RINTR] = 0; @@ -546,6 +504,7 @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) esp_raise_irq(s); break; default: + unhandled: trace_esp_error_unhandled_command(val); break; } @@ -585,9 +544,12 @@ const VMStateDescription vmstate_esp = { VMSTATE_BUFFER(ti_buf, ESPState), VMSTATE_UINT32(status, ESPState), VMSTATE_UINT32(dma, ESPState), - VMSTATE_BUFFER(cmdbuf, ESPState), - VMSTATE_UINT32(cmdlen, ESPState), - VMSTATE_UINT32(do_cmd, ESPState), + /* Used to be cmdbuf, cmdlen, do_cmd, but the implementation + * of "Select with ATN and stop" was totally busted. + */ + VMSTATE_UNUSED(16), + VMSTATE_UNUSED(4), + VMSTATE_UNUSED(1), VMSTATE_UINT32(dma_left, ESPState), VMSTATE_END_OF_LIST() } diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index d2c4886..8967167 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -32,9 +32,6 @@ struct ESPState { SCSIBus bus; SCSIDevice *current_dev; SCSIRequest *current_req; - uint8_t cmdbuf[ESP_CMDBUF_SZ]; - uint32_t cmdlen; - uint32_t do_cmd; /* The amount of data left in the current DMA transfer. */ uint32_t dma_left;