From nobody Sun Nov 9 17:51:10 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551815845094153.76591925538548; Tue, 5 Mar 2019 11:57:25 -0800 (PST) Received: from localhost ([127.0.0.1]:48496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1GBm-0007HM-2Y for importer@patchew.org; Tue, 05 Mar 2019 14:57:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1GA3-0006HW-1e for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1GA2-0005rB-9l for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:34 -0500 Received: from smtp.duncanthrax.net ([2001:470:70c5:1111::170]:56945) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1GA1-0005kc-Qn for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:34 -0500 Received: from [134.3.47.207] (helo=t470p.stackframe.org) by smtp.eurescom.eu with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1h1G9x-0004To-V4; Tue, 05 Mar 2019 20:55:30 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=e7FyrcRLh4e7VbGBOCB2JSF1j1+j3xQgs9+D2RzjISU=; b=TXhJp+mrKu/LC9OKhPqUjClfxI x7d30kPW0RYsyBsJfu0Hahm+9/jV9t3Fmfg7qaozoxCGcG+R1Rzs3HbrMGpJxY3MVaHewUnuI42ZW fcTatIXrny422ZWf4+NrpIuWuIX2KAOajgiifP3xGzZwdgGSPAeqXMCyk7n1Ql1FscU0=; From: Sven Schnelle To: Paolo Bonzini Date: Tue, 5 Mar 2019 20:55:15 +0100 Message-Id: <20190305195519.24303-2-svens@stackframe.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190305195519.24303-1-svens@stackframe.org> References: <20190305195519.24303-1-svens@stackframe.org> 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: 2001:470:70c5:1111::170 Subject: [Qemu-devel] [PATCH v2 1/5] lsi: use ldn_le_p()/stn_le_p() 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: Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Sven Schnelle , QEMU Developers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Instead of using the open-coded versions, use the helper already present as this makes the code easier to read and less error-prone. Signed-off-by: Sven Schnelle Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/lsi53c895a.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index 5623da8950..5f336606b9 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -289,8 +289,7 @@ typedef struct { uint8_t sbr; uint32_t adder; =20 - /* Script ram is stored as 32-bit words in host byteorder. */ - uint32_t script_ram[2048]; + uint8_t script_ram[2048 * sizeof(uint32_t)]; } LSIState; =20 #define TYPE_LSI53C810 "lsi53c810" @@ -2079,29 +2078,14 @@ static void lsi_ram_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { LSIState *s =3D opaque; - uint32_t newval; - uint32_t mask; - int shift; - - newval =3D s->script_ram[addr >> 2]; - shift =3D (addr & 3) * 8; - mask =3D ((uint64_t)1 << (size * 8)) - 1; - newval &=3D ~(mask << shift); - newval |=3D val << shift; - s->script_ram[addr >> 2] =3D newval; + stn_le_p(s->script_ram + addr, size, val); } =20 static uint64_t lsi_ram_read(void *opaque, hwaddr addr, unsigned size) { LSIState *s =3D opaque; - uint32_t val; - uint32_t mask; - - val =3D s->script_ram[addr >> 2]; - mask =3D ((uint64_t)1 << (size * 8)) - 1; - val >>=3D (addr & 3) * 8; - return val & mask; + return ldn_le_p(s->script_ram + addr, size); } =20 static const MemoryRegionOps lsi_ram_ops =3D { @@ -2244,7 +2228,7 @@ static const VMStateDescription vmstate_lsi_scsi =3D { VMSTATE_BUFFER_UNSAFE(scratch, LSIState, 0, 18 * sizeof(uint32_t)), VMSTATE_UINT8(sbr, LSIState), =20 - VMSTATE_BUFFER_UNSAFE(script_ram, LSIState, 0, 2048 * sizeof(uint3= 2_t)), + VMSTATE_BUFFER_UNSAFE(script_ram, LSIState, 0, 8192), VMSTATE_END_OF_LIST() } }; --=20 2.20.1 From nobody Sun Nov 9 17:51:10 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551815994115494.83967045019494; Tue, 5 Mar 2019 11:59:54 -0800 (PST) Received: from localhost ([127.0.0.1]:48522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1GEB-0000r2-26 for importer@patchew.org; Tue, 05 Mar 2019 14:59:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1GA3-0006Hf-8X for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1GA2-0005r3-7i for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:35 -0500 Received: from smtp.duncanthrax.net ([2001:470:70c5:1111::170]:54813) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1GA1-0005nN-VB for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:34 -0500 Received: from [134.3.47.207] (helo=t470p.stackframe.org) by smtp.eurescom.eu with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1h1G9z-0004To-Bt; Tue, 05 Mar 2019 20:55:31 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=28iQ3FDpLCg47t649CJPKW7xyEGo4GqB8Mr6e3deE/g=; b=VCIGrDEgDOxfqSoN0pzl99bx8G MhoT3639Spsf+Xzkpwxt/+SZBoqk42ufYTvzuECMCLAPMx5UkEzLrbjhYg7xU5KGiGgKfqpORQdf8 cYkq+wVnPpOMt1Cv3CUT3YU1onW0xx9I2JcVYGLF8TxZgE6VUR4DtDfG0Jq8pMRDXZa8=; From: Sven Schnelle To: Paolo Bonzini Date: Tue, 5 Mar 2019 20:55:16 +0100 Message-Id: <20190305195519.24303-3-svens@stackframe.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190305195519.24303-1-svens@stackframe.org> References: <20190305195519.24303-1-svens@stackframe.org> 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: 2001:470:70c5:1111::170 Subject: [Qemu-devel] [PATCH v2 2/5] 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: Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Sven Schnelle , QEMU Developers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This makes the code easier to read - no functional change. Signed-off-by: Sven Schnelle Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 5f336606b9..cafe84c85b 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 2.20.1 From nobody Sun Nov 9 17:51:10 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551815997951171.72100201244564; Tue, 5 Mar 2019 11:59:57 -0800 (PST) Received: from localhost ([127.0.0.1]:48520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1GEA-0000qT-TV for importer@patchew.org; Tue, 05 Mar 2019 14:59:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1GA3-0006Hk-Bc for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1GA2-0005rI-Ae for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:35 -0500 Received: from smtp.duncanthrax.net ([2001:470:70c5:1111::170]:54261) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1GA2-0005pG-2H for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:34 -0500 Received: from [134.3.47.207] (helo=t470p.stackframe.org) by smtp.eurescom.eu with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1h1GA0-0004To-Eg; Tue, 05 Mar 2019 20:55:32 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=3YV9TGQH2OkHk+kKtnihHO2HN+eSB42dV805aOlijqo=; b=F16W9d70iYzFaJkiFaIkl5M122 oHZz5vb2lFohysDCKPYIPJmFMcBBxinlxx2ZADuCq8TiXZv5NAcofDvx+BLoKiOydlMM6RvLCvNLj GaK4xgplSkpznAJvtsUElfsbxHbs7G2TXRsObEVHHPl+enVdt+Niumsqa9ThpE8kmoWU=; From: Sven Schnelle To: Paolo Bonzini Date: Tue, 5 Mar 2019 20:55:17 +0100 Message-Id: <20190305195519.24303-4-svens@stackframe.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190305195519.24303-1-svens@stackframe.org> References: <20190305195519.24303-1-svens@stackframe.org> 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: 2001:470:70c5:1111::170 Subject: [Qemu-devel] [PATCH v2 3/5] lsi: use enum type for s->msg_action 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: Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Sven Schnelle , QEMU Developers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This makes the code easier to read - no functional change. Signed-off-by: Sven Schnelle Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/lsi53c895a.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index cafe84c85b..843fa90b39 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -201,6 +201,13 @@ enum { LSI_DMA_IN_PROGRESS, /* DMA operation is in progress */ }; =20 +enum { + LSI_MSG_ACTION_COMMAND =3D 0, + LSI_MSG_ACTION_DISCONNECT =3D 1, + LSI_MSG_ACTION_DOUT =3D 2, + LSI_MSG_ACTION_DIN =3D 3, +}; + typedef struct { /*< private >*/ PCIDevice parent_obj; @@ -214,8 +221,6 @@ typedef struct { =20 int carry; /* ??? Should this be an a visible register somewhere? */ int status; - /* Action to take at the end of a MSG IN phase. - 0 =3D COMMAND, 1 =3D disconnect, 2 =3D DATA OUT, 3 =3D DATA IN. */ int msg_action; int msg_len; uint8_t msg[LSI_MAX_MSGIN_LEN]; @@ -323,7 +328,7 @@ static void lsi_soft_reset(LSIState *s) trace_lsi_reset(); s->carry =3D 0; =20 - s->msg_action =3D 0; + s->msg_action =3D LSI_MSG_ACTION_COMMAND; s->msg_len =3D 0; s->waiting =3D LSI_NOWAIT; s->dsa =3D 0; @@ -686,7 +691,7 @@ static void lsi_reselect(LSIState *s, lsi_request *p) trace_lsi_reselect(id); s->scntl1 |=3D LSI_SCNTL1_CON; lsi_set_phase(s, PHASE_MI); - s->msg_action =3D p->out ? 2 : 3; + s->msg_action =3D p->out ? LSI_MSG_ACTION_DOUT : LSI_MSG_ACTION_DIN; s->current->dma_len =3D p->pending; lsi_add_msg_byte(s, 0x80); if (s->current->tag & LSI_TAG_VALID) { @@ -857,7 +862,7 @@ static void lsi_do_command(LSIState *s) lsi_add_msg_byte(s, 4); /* DISCONNECT */ /* wait data */ lsi_set_phase(s, PHASE_MI); - s->msg_action =3D 1; + s->msg_action =3D LSI_MSG_ACTION_DISCONNECT; lsi_queue_command(s); } else { /* wait command complete */ @@ -878,7 +883,7 @@ static void lsi_do_status(LSIState *s) s->sfbr =3D status; pci_dma_write(PCI_DEVICE(s), s->dnad, &status, 1); lsi_set_phase(s, PHASE_MI); - s->msg_action =3D 1; + s->msg_action =3D LSI_MSG_ACTION_DISCONNECT; lsi_add_msg_byte(s, 0); /* COMMAND COMPLETE */ } =20 @@ -901,16 +906,16 @@ static void lsi_do_msgin(LSIState *s) /* ??? Check if ATN (not yet implemented) is asserted and maybe switch to PHASE_MO. */ switch (s->msg_action) { - case 0: + case LSI_MSG_ACTION_COMMAND: lsi_set_phase(s, PHASE_CMD); break; - case 1: + case LSI_MSG_ACTION_DISCONNECT: lsi_disconnect(s); break; - case 2: + case LSI_MSG_ACTION_DOUT: lsi_set_phase(s, PHASE_DO); break; - case 3: + case LSI_MSG_ACTION_DIN: lsi_set_phase(s, PHASE_DI); break; default: @@ -1062,7 +1067,7 @@ bad: qemu_log_mask(LOG_UNIMP, "Unimplemented message 0x%02x\n", msg); lsi_set_phase(s, PHASE_MI); lsi_add_msg_byte(s, 7); /* MESSAGE REJECT */ - s->msg_action =3D 0; + s->msg_action =3D LSI_MSG_ACTION_COMMAND; } =20 #define LSI_BUF_SIZE 4096 --=20 2.20.1 From nobody Sun Nov 9 17:51:10 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551815844262117.80133348468735; Tue, 5 Mar 2019 11:57:24 -0800 (PST) Received: from localhost ([127.0.0.1]:48494 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1GBl-0007Gj-6x for importer@patchew.org; Tue, 05 Mar 2019 14:57:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45392) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1GA4-0006IL-3P for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1GA3-0005sC-2K for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:36 -0500 Received: from smtp.duncanthrax.net ([2001:470:70c5:1111::170]:59626) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1GA2-0005qz-Py for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:34 -0500 Received: from [134.3.47.207] (helo=t470p.stackframe.org) by smtp.eurescom.eu with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1h1GA1-0004To-Ni; Tue, 05 Mar 2019 20:55:33 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=Hwi8YNNbO1hLdBZCeB1VYoWi3ZKbcNzPcsh7fXyrW2s=; b=EKq3JqMyPmKjzx/z3jMWSHH1zb 0Rse0noRbpPWQK3IwMEgI/+JmsD4ALqkOiOYBD/2mibmYqTr0AQbTeMvIHiQl3S2dLZjPX5bDvGWg ZKIZ0hlynDbgKvzRO5T62h/aIcXuvi70jkPQAR27+22xG1rD7Z9WOvAJ3Iofn8mzTTm0=; From: Sven Schnelle To: Paolo Bonzini Date: Tue, 5 Mar 2019 20:55:18 +0100 Message-Id: <20190305195519.24303-5-svens@stackframe.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190305195519.24303-1-svens@stackframe.org> References: <20190305195519.24303-1-svens@stackframe.org> 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: 2001:470:70c5:1111::170 Subject: [Qemu-devel] [PATCH v2 4/5] lsi: use SCSI phase names instead of numbers in trace 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: Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Sven Schnelle , QEMU Developers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This makes trace logs much easier to read, especially for people who are not fluent in SCSI. Signed-off-by: Sven Schnelle Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/lsi53c895a.c | 31 +++++++++++++++++++++++-------- hw/scsi/trace-events | 6 +++--- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index 843fa90b39..7d66d1a870 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -306,6 +306,22 @@ typedef struct { #define LSI53C895A(obj) \ OBJECT_CHECK(LSIState, (obj), TYPE_LSI53C895A) =20 +static const char *scsi_phases[] =3D { + "DOUT", + "DIN", + "CMD", + "STATUS", + "RSVOUT", + "RSVIN", + "MSGOUT", + "MSGIN" +}; + +static const char *scsi_phase_name(int phase) +{ + return scsi_phases[phase & PHASE_MASK]; +} + static inline int lsi_irq_on_rsl(LSIState *s) { return (s->sien0 & LSI_SIST0_RSL) && (s->scid & LSI_SCID_RRE); @@ -1201,8 +1217,9 @@ again: s->ia =3D s->dsp - 12; } if ((s->sstat1 & PHASE_MASK) !=3D ((insn >> 24) & 7)) { - trace_lsi_execute_script_blockmove_badphase(s->sstat1 & PHASE_= MASK, - (insn >> 24) & 7); + trace_lsi_execute_script_blockmove_badphase( + scsi_phase_name(s->sstat1), + scsi_phase_name(insn >> 24)); lsi_script_scsi_interrupt(s, LSI_SIST0_MA, 0); break; } @@ -1234,8 +1251,8 @@ again: lsi_do_msgin(s); break; default: - qemu_log_mask(LOG_UNIMP, "lsi_scsi: Unimplemented phase %d\n", - s->sstat1 & PHASE_MASK); + qemu_log_mask(LOG_UNIMP, "lsi_scsi: Unimplemented phase %s\n", + scsi_phase_name(s->sstat1)); } s->dfifo =3D s->dbc & 0xff; s->ctest5 =3D (s->ctest5 & 0xfc) | ((s->dbc >> 8) & 3); @@ -1463,10 +1480,8 @@ again: cond =3D s->carry !=3D 0; } if (cond =3D=3D jmp && (insn & (1 << 17))) { - trace_lsi_execute_script_tc_compp( - (s->sstat1 & PHASE_MASK), - jmp ? '=3D' : '!', - ((insn >> 24) & 7)); + trace_lsi_execute_script_tc_compp(scsi_phase_name(s->sstat= 1), + jmp ? '=3D' : '!', scsi_phase_name(insn >> 24)); cond =3D (s->sstat1 & PHASE_MASK) =3D=3D ((insn >> 24) & 7= ); } if (cond =3D=3D jmp && (insn & (1 << 18))) { diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events index 29aaa752d1..09f3fc3086 100644 --- a/hw/scsi/trace-events +++ b/hw/scsi/trace-events @@ -268,7 +268,7 @@ lsi_memcpy(uint32_t dest, uint32_t src, int count) "mem= cpy dest 0x%"PRIx32" src lsi_wait_reselect(void) "Wait Reselect" lsi_execute_script(uint32_t dsp, uint32_t insn, uint32_t addr) "SCRIPTS ds= p=3D0x%"PRIx32" opcode 0x%"PRIx32" arg 0x%"PRIx32 lsi_execute_script_blockmove_delayed(void) "Delayed select timeout" -lsi_execute_script_blockmove_badphase(uint8_t phase, uint8_t expected) "Wr= ong phase got %d expected %d" +lsi_execute_script_blockmove_badphase(const char *phase, const char *expec= ted) "Wrong phase got %s expected %s" lsi_execute_script_io_alreadyreselected(void) "Already reselected, jumping= to alternative address" lsi_execute_script_io_selected(uint8_t id, const char *atn) "Selected targ= et %d%s" lsi_execute_script_io_disconnect(void) "Wait Disconnect" @@ -278,8 +278,8 @@ lsi_execute_script_io_opcode(const char *opcode, int re= g, const char *opname, ui lsi_execute_script_tc_nop(void) "NOP" lsi_execute_script_tc_delayedselect_timeout(void) "Delayed select timeout" lsi_execute_script_tc_compc(int result) "Compare carry %d" -lsi_execute_script_tc_compp(uint8_t phase, int op, uint8_t insn_phase) "Co= mpare phase %d %c=3D %d" -lsi_execute_script_tc_compd(uint32_t sfbr, uint8_t mask, int op, int resul= t) "Compare data 0x%"PRIx32" & 0x%x %c=3D 0x%x" +lsi_execute_script_tc_compp(const char *phase, char op, const char *insn_p= hase) "Compare phase %s %c=3D %s" +lsi_execute_script_tc_compd(uint32_t sfbr, uint8_t mask, char op, int resu= lt) "Compare data 0x%"PRIx32" & 0x%x %c=3D 0x%x" lsi_execute_script_tc_jump(uint32_t addr) "Jump to 0x%"PRIx32 lsi_execute_script_tc_call(uint32_t addr) "Call 0x%"PRIx32 lsi_execute_script_tc_return(uint32_t addr) "Return to 0x%"PRIx32 --=20 2.20.1 From nobody Sun Nov 9 17:51:10 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551816106074929.9348158544719; Tue, 5 Mar 2019 12:01:46 -0800 (PST) Received: from localhost ([127.0.0.1]:48572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1GFv-0002OH-2l for importer@patchew.org; Tue, 05 Mar 2019 15:01:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1GA8-0006MV-RW for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1GA8-0005yg-9G for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:40 -0500 Received: from smtp.duncanthrax.net ([2001:470:70c5:1111::170]:36718) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1GA8-0005xw-13 for qemu-devel@nongnu.org; Tue, 05 Mar 2019 14:55:40 -0500 Received: from [134.3.47.207] (helo=t470p.stackframe.org) by smtp.eurescom.eu with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1h1GA6-0004To-VI; Tue, 05 Mar 2019 20:55:39 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=duncanthrax.net; s=dkim; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=a9j/sIffMTSILrFz2BTa0TVHvNMYCzaT1s2lIjoCt70=; b=d66GOmKerGL39Kln4fZe37wYUT ULSqsT2oOirLP6vWbtyomcdA12rO/lXWM4NPdKLfFchKbRO3XBgLeVGK9UkuNkq7W4uvzvosweNzv RkBiM0O5DONWJR0q3Sw8qhHkA4jNufgsayUBI5IiUCrJHhhqVfDWbtKZTAUxpGbCWC2Q=; From: Sven Schnelle To: Paolo Bonzini Date: Tue, 5 Mar 2019 20:55:19 +0100 Message-Id: <20190305195519.24303-6-svens@stackframe.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190305195519.24303-1-svens@stackframe.org> References: <20190305195519.24303-1-svens@stackframe.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:470:70c5:1111::170 Subject: [Qemu-devel] [PATCH v2 5/5] lsi: return dfifo value 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: Fam Zheng , Sven Schnelle , QEMU Developers Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Code was assigning DFIFO, but didn't return the value to users. Signed-off-by: Sven Schnelle --- hw/scsi/lsi53c895a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index 7d66d1a870..3783779da6 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -1688,7 +1688,7 @@ static uint8_t lsi_reg_readb(LSIState *s, int offset) break; CASE_GET_REG32(temp, 0x1c) case 0x20: /* DFIFO */ - ret =3D 0; + ret =3D s->dfifo; break; case 0x21: /* CTEST4 */ ret =3D s->ctest4; --=20 2.20.1