From nobody Tue Feb 10 06:27:14 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709921633; cv=none; d=zohomail.com; s=zohoarc; b=UBwUOvoomgJbcpSd8NGzZpANZWznsGsNPo/l4atruiZOnq8RMhO3EIEIBXRRZOo++b77XJaWWMKgk4W5M+jaPcktvzodTemFsTIefBCudgUJeF2e2yFud3REBuu8dvh2vHxpXdUSBbp/H6PGQ+ZsRU519NZVFtApanPCRFpg/DA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709921633; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ff3Hzr/qQnFeHJ3R0iUom7wtGXBzK9NGYQzCU5YsyUA=; b=UjcH81MCOBGj3fONlhHz8953f7raH/Gz6e9YE0D+bkiKjuWFCNOONt37VbR7PasLT/LXpItDqqrnFTNSnVCEonEGX9d99y4pEFo2eHd4W+EkTZsA1NNsi5TYs3yDIycEeFIrGtFc4LF0iKmLPJcnDCLEsvDAqQS4b9FRPu7OL/o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709921633146972.5218848820693; Fri, 8 Mar 2024 10:13:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riehm-00079z-0P; Fri, 08 Mar 2024 13:12:26 -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 1riehj-000780-UL for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riehh-0005o0-G8 for qemu-devel@nongnu.org; Fri, 08 Mar 2024 13:12:23 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-JNZ7ypJBPZK1txaij32Wug-1; Fri, 08 Mar 2024 13:12:18 -0500 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5670ee87ca4so1108720a12.2 for ; Fri, 08 Mar 2024 10:12:17 -0800 (PST) Received: from [192.168.10.118] ([151.49.77.21]) by smtp.gmail.com with ESMTPSA id x14-20020aa7dace000000b005671100145dsm22397eds.55.2024.03.08.10.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 10:12:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709921539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ff3Hzr/qQnFeHJ3R0iUom7wtGXBzK9NGYQzCU5YsyUA=; b=IuqpmqQhWftqmnZDu6ftGxdifvL87JTbFywVOaSolwdbpJxSeEimQnSJwp/OyuefJAgg9z aNTgrnSXigSJ3xaB9BnasDdndFi5hupmtRW19/wHg6FNGH/1tESUvz2DBMPs8q/M3IT9h3 L6kAThQbz2xXbFgKTtGvm7zhBgQxqeo= X-MC-Unique: JNZ7ypJBPZK1txaij32Wug-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709921535; x=1710526335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ff3Hzr/qQnFeHJ3R0iUom7wtGXBzK9NGYQzCU5YsyUA=; b=Bsb6T45IuTxHpNI0cFivXsjCG6ZlVuCwfOyLKToxNHMSpJhA9HGGbd+qz/JkccQCMt JXzWFsHwcgWFY9r44x9I6eQJB8nxcfhWOJLJnvVhzqCVwUd2z8TmckKWTwpSTE7p5z7R ZyCvXc8raw9aUUmcNxxXXc0AACIVLWk6DG6TWgIxjtMrZefStZ+VE7u6jNeVcJbEWFGb EHKbPUcHz59mcE/3Tvr9tmlYeEPXXn3x0U3G4TNLs8Lm8tcMYVWrcJOSOqeoU16iN+T6 Dqihv8qv/+3kkzdHTE+mIi15hQYfKc5hFvhPJMHoI7Myl7wPJJAAWGCKaFxhs2MIaqS/ fIgA== X-Gm-Message-State: AOJu0Yy3D4mXKn+h6dpY8hfc5ghgof+SECWFZL+qjRR5WGOHsURIqFbC ZCo074NBTy7lMFgePJAeqhZ7UUPnTtVISpBYPpfKm+Tf7Aez+aR98H5ckft7QbgvgppNictTTey r7sHQRrl3B0gYdER7IDghiNMWFiFF9ePHC3fqGqjSqKdxIAFUMYStH5RLlkx35JG6ED+E1dNH1o BLSpIPkDWRGuboNSUxwFEIWDCXaZutiWaX9rC3 X-Received: by 2002:a50:9faa:0:b0:565:59a:a103 with SMTP id c39-20020a509faa000000b00565059aa103mr29893edf.33.1709921535244; Fri, 08 Mar 2024 10:12:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPnsqjXmf/kRkEMik4h43dtMchE9C+ZRTsPbTw4NMAyyI5/k3Ji+e91QH6IqGuhsqS1o5hsw== X-Received: by 2002:a50:9faa:0:b0:565:59a:a103 with SMTP id c39-20020a509faa000000b00565059aa103mr29876edf.33.1709921534821; Fri, 08 Mar 2024 10:12:14 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Sven Schnelle , Helge Deller Subject: [PULL 4/9] hw/scsi/lsi53c895a: stop script on phase mismatch Date: Fri, 8 Mar 2024 19:11:56 +0100 Message-ID: <20240308181202.617329-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240308181202.617329-1-pbonzini@redhat.com> References: <20240308181202.617329-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.572, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709921633561100001 Content-Type: text/plain; charset="utf-8" From: Sven Schnelle Netbsd isn't happy with qemu lsi53c895a emulation: cd0(esiop0:0:2:0): command with tag id 0 reset esiop0: autoconfiguration error: phase mismatch without command esiop0: autoconfiguration error: unhandled scsi interrupt, sist=3D0x80 ssta= t1=3D0x0 DSA=3D0x23a64b1 DSP=3D0x50 This is because lsi_bad_phase() triggers a phase mismatch, which stops SCRIPT processing. However, after returning to lsi_command_complete(), SCRIPT is restarted with lsi_resume_script(). Fix this by adding a return value to lsi_bad_phase(), and only resume script processing when lsi_bad_phase() didn't trigger a host interrupt. Signed-off-by: Sven Schnelle Tested-by: Helge Deller Message-ID: <20240302214453.2071388-1-svens@stackframe.org> Signed-off-by: Paolo Bonzini --- hw/scsi/lsi53c895a.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index 4ff94703816..59b88aff3fb 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -573,8 +573,9 @@ static inline void lsi_set_phase(LSIState *s, int phase) s->sstat1 =3D (s->sstat1 & ~PHASE_MASK) | phase; } =20 -static void lsi_bad_phase(LSIState *s, int out, int new_phase) +static int lsi_bad_phase(LSIState *s, int out, int new_phase) { + int ret =3D 0; /* Trigger a phase mismatch. */ if (s->ccntl0 & LSI_CCNTL0_ENPMJ) { if ((s->ccntl0 & LSI_CCNTL0_PMJCTL)) { @@ -587,8 +588,10 @@ static void lsi_bad_phase(LSIState *s, int out, int ne= w_phase) trace_lsi_bad_phase_interrupt(); lsi_script_scsi_interrupt(s, LSI_SIST0_MA, 0); lsi_stop_script(s); + ret =3D 1; } lsi_set_phase(s, new_phase); + return ret; } =20 =20 @@ -792,7 +795,7 @@ static int lsi_queue_req(LSIState *s, SCSIRequest *req,= uint32_t len) static void lsi_command_complete(SCSIRequest *req, size_t resid) { LSIState *s =3D LSI53C895A(req->bus->qbus.parent); - int out; + int out, stop =3D 0; =20 out =3D (s->sstat1 & PHASE_MASK) =3D=3D PHASE_DO; trace_lsi_command_complete(req->status); @@ -800,7 +803,10 @@ static void lsi_command_complete(SCSIRequest *req, siz= e_t resid) s->command_complete =3D 2; if (s->waiting && s->dbc !=3D 0) { /* Raise phase mismatch for short transfers. */ - lsi_bad_phase(s, out, PHASE_ST); + stop =3D lsi_bad_phase(s, out, PHASE_ST); + if (stop) { + s->waiting =3D 0; + } } else { lsi_set_phase(s, PHASE_ST); } @@ -810,7 +816,9 @@ static void lsi_command_complete(SCSIRequest *req, size= _t resid) lsi_request_free(s, s->current); scsi_req_unref(req); } - lsi_resume_script(s); + if (!stop) { + lsi_resume_script(s); + } } =20 /* Callback to indicate that the SCSI layer has completed a transfer. */ --=20 2.43.2