From nobody Sun Nov 9 23:07:15 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552118409110280.63087951576017; Sat, 9 Mar 2019 00:00:09 -0800 (PST) Received: from localhost ([127.0.0.1]:55396 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Wtp-0004Xv-St for importer@patchew.org; Sat, 09 Mar 2019 03:00:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Win-0003xM-TA for qemu-devel@nongnu.org; Sat, 09 Mar 2019 02:48:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2Wim-0000e3-TG for qemu-devel@nongnu.org; Sat, 09 Mar 2019 02:48:41 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:47016) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h2Wim-0000dJ-Je for qemu-devel@nongnu.org; Sat, 09 Mar 2019 02:48:40 -0500 Received: by mail-wr1-x42f.google.com with SMTP id i16so23627107wrs.13 for ; Fri, 08 Mar 2019 23:48:40 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id 11sm5252294wmg.27.2019.03.08.23.48.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 23:48:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0KtITCFgm7yckdK/wn/O5zJgkB2Z62Yl4ofit5ZEqQ0=; b=ge5VS7DPruTEiCSWkOjQdqtjyfe7Fw1EtuyJ4r6UfVPqcrPOkD3p6rjnjw9GTzJ6PW /Yhba8PcqVAiGcrXAcoPmjzOQV+uD7ovGZ2/YVIhsDbcS3CQeBweJsm70MG5wrG4LF1d yjq7sWwi00iJ1+gNbCX/XBa3TCJfTY7hIbXai9Qe2YlbtuYAj/zp5379btUHB9SpG4Rb tjNQrkz1XwIPZPHuiUMx/xDJ1R/WzkreEK9d2Y+7x4g1uKkcsTB10flFfauQU0S4AzC5 X0/cp4ASAW3UpZuSOH24b1crdeLdE05FD+tNMQcVC0zmklTY4b+NbBIHKUSS23z9kYG1 WEng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=0KtITCFgm7yckdK/wn/O5zJgkB2Z62Yl4ofit5ZEqQ0=; b=YjcVXKVnQQdcIgxjO+CczvuqOmGddoywgfh2pp9cFuky8K+zLVigo792W2ZZdANWr7 y0B4lq5isKSv/PmYCll3OzNHDAx5pig0GulkPbuR4PjGxTm0vY1idQdV9JjEr1hfF4JW dhU8osO75YMH4wc8qMA5Ig6BY/rtsBBCDvaZN+tR0ahZxS+XEDRUB3JYevjYgOb4fLxW ycjsmaWRSrYF0sIcwdqOdMIQvr2yZu4Iyq3ooNkRtzxhHeKE4YKcKPtsGQ3QhrF6U99t Yj3vuKjKYEuzw3DuWSL5yReLQLP1+eJ/SKlMMMfWA3+Jxb1OeQNfbPjqDKo6uBm4F1c2 PQkA== X-Gm-Message-State: APjAAAWH7XvuuT0ZHDT3MejHt7eiBn8bd7s84g/C9QHIUqcoV07Wv9hb 9Ba+KoyTJyBJLrLNlgIyruLIp92b X-Google-Smtp-Source: APXvYqxuXv3cu+3GHHZBlpvCEDglhzU81ApL14GR0mmvRc4DdnvsMuWoH/J03AA8LpNinPavZzFfgA== X-Received: by 2002:adf:8273:: with SMTP id 106mr14223058wrb.34.1552117719396; Fri, 08 Mar 2019 23:48:39 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 9 Mar 2019 08:48:14 +0100 Message-Id: <1552117698-12355-22-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1552117698-12355-1-git-send-email-pbonzini@redhat.com> References: <1552117698-12355-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f Subject: [Qemu-devel] [PULL 21/25] lsi: use enum type for s->waiting 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: Sven Schnelle Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Sven Schnelle This makes the code easier to read - no functional change. Signed-off-by: Sven Schnelle Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20190305195519.24303-3-svens@stackframe.org> --- hw/scsi/lsi53c895a.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index 402b785..c17bb4f 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -194,6 +194,13 @@ typedef struct lsi_request { QTAILQ_ENTRY(lsi_request) next; } lsi_request; =20 +enum { + LSI_NOWAIT, /* SCRIPTS are running or stopped */ + LSI_WAIT_RESELECT, /* Wait Reselect instruction has been issued */ + LSI_DMA_SCRIPTS, /* processing DMA from lsi_execute_script */ + LSI_DMA_IN_PROGRESS, /* DMA operation is in progress */ +}; + typedef struct { /*< private >*/ PCIDevice parent_obj; @@ -212,10 +219,6 @@ typedef struct { int msg_action; int msg_len; uint8_t msg[LSI_MAX_MSGIN_LEN]; - /* 0 if SCRIPTS are running or stopped. - * 1 if a Wait Reselect instruction has been issued. - * 2 if processing DMA from lsi_execute_script. - * 3 if a DMA operation is in progress. */ int waiting; SCSIBus bus; int current_lun; @@ -322,7 +325,7 @@ static void lsi_soft_reset(LSIState *s) =20 s->msg_action =3D 0; s->msg_len =3D 0; - s->waiting =3D 0; + s->waiting =3D LSI_NOWAIT; s->dsa =3D 0; s->dnad =3D 0; s->dbc =3D 0; @@ -564,10 +567,10 @@ static void lsi_bad_phase(LSIState *s, int out, int n= ew_phase) static void lsi_resume_script(LSIState *s) { if (s->waiting !=3D 2) { - s->waiting =3D 0; + s->waiting =3D LSI_NOWAIT; lsi_execute_script(s); } else { - s->waiting =3D 0; + s->waiting =3D LSI_NOWAIT; } } =20 @@ -744,7 +747,7 @@ static int lsi_queue_req(LSIState *s, SCSIRequest *req,= uint32_t len) Since no interrupt stacking is implemented in the emulation, it is also required that there are no pending interrupts waiting for service from the device driver. */ - if (s->waiting =3D=3D 1 || + if (s->waiting =3D=3D LSI_WAIT_RESELECT || (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON) && !(s->istat0 & (LSI_ISTAT0_SIP | LSI_ISTAT0_DIP)))) { /* Reselect device. */ @@ -789,7 +792,7 @@ static void lsi_transfer_data(SCSIRequest *req, uint32_= t len) int out; =20 assert(req->hba_private); - if (s->waiting =3D=3D 1 || req->hba_private !=3D s->current || + if (s->waiting =3D=3D LSI_WAIT_RESELECT || req->hba_private !=3D s->cu= rrent || (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) { if (lsi_queue_req(s, req, len)) { return; @@ -803,7 +806,7 @@ static void lsi_transfer_data(SCSIRequest *req, uint32_= t len) s->current->dma_len =3D len; s->command_complete =3D 1; if (s->waiting) { - if (s->waiting =3D=3D 1 || s->dbc =3D=3D 0) { + if (s->waiting =3D=3D LSI_WAIT_RESELECT || s->dbc =3D=3D 0) { lsi_resume_script(s); } else { lsi_do_dma(s, out); @@ -1093,7 +1096,7 @@ static void lsi_wait_reselect(LSIState *s) lsi_reselect(s, p); } if (s->current =3D=3D NULL) { - s->waiting =3D 1; + s->waiting =3D LSI_WAIT_RESELECT; } } =20 @@ -1202,16 +1205,16 @@ again: s->dnad64 =3D addr_high; switch (s->sstat1 & 0x7) { case PHASE_DO: - s->waiting =3D 2; + s->waiting =3D LSI_DMA_SCRIPTS; lsi_do_dma(s, 1); if (s->waiting) - s->waiting =3D 3; + s->waiting =3D LSI_DMA_IN_PROGRESS; break; case PHASE_DI: - s->waiting =3D 2; + s->waiting =3D LSI_DMA_SCRIPTS; lsi_do_dma(s, 0); if (s->waiting) - s->waiting =3D 3; + s->waiting =3D LSI_DMA_IN_PROGRESS; break; case PHASE_CMD: lsi_do_command(s); @@ -1278,6 +1281,7 @@ again: } s->sbcl |=3D LSI_SBCL_BSY; lsi_set_phase(s, PHASE_MO); + s->waiting =3D LSI_NOWAIT; break; case 1: /* Disconnect */ trace_lsi_execute_script_io_disconnect(); @@ -1544,7 +1548,7 @@ again: } } } - if (insn_processed > 10000 && !s->waiting) { + if (insn_processed > 10000 && s->waiting =3D=3D LSI_NOWAIT) { /* Some windows drivers make the device spin waiting for a memory location to change. If we have been executed a lot of code then assume this is the case and force an unexpected device disconne= ct. @@ -1556,7 +1560,7 @@ again: } lsi_script_scsi_interrupt(s, LSI_SIST0_UDC, 0); lsi_disconnect(s); - } else if (s->istat1 & LSI_ISTAT1_SRUN && !s->waiting) { + } else if (s->istat1 & LSI_ISTAT1_SRUN && s->waiting =3D=3D LSI_NOWAIT= ) { if (s->dcntl & LSI_DCNTL_SSM) { lsi_script_dma_interrupt(s, LSI_DSTAT_SSI); } else { @@ -1887,9 +1891,9 @@ static void lsi_reg_writeb(LSIState *s, int offset, u= int8_t val) s->istat0 &=3D ~LSI_ISTAT0_INTF; lsi_update_irq(s); } - if (s->waiting =3D=3D 1 && val & LSI_ISTAT0_SIGP) { + if (s->waiting =3D=3D LSI_WAIT_RESELECT && val & LSI_ISTAT0_SIGP) { trace_lsi_awoken(); - s->waiting =3D 0; + s->waiting =3D LSI_NOWAIT; s->dsp =3D s->dnad; lsi_execute_script(s); } --=20 1.8.3.1